From 0a59d2a3e9ed9965b303abd469065486ced5da77 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 23 Jul 2020 09:41:40 +0200 Subject: [PATCH] radeonsi/tmz: add safety assert when tmz is enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds asserts verifying the following conditions when using a secure job: - fb textures are encrypted (both colors and depth/stencil buffers) - all writeable bo are encrypted Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_descriptors.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 76c35ca8028..8f71ffdd2f3 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -2729,6 +2729,25 @@ bool si_gfx_resources_check_encrypted(struct si_context *sctx) } } +#ifndef NDEBUG + if (use_encrypted_bo) { + /* Verify that color buffers are encrypted */ + for (int i = 0; i < sctx->framebuffer.state.nr_cbufs; i++) { + struct pipe_surface *surf = sctx->framebuffer.state.cbufs[i]; + if (!surf) + continue; + struct si_texture *tex = (struct si_texture *)surf->texture; + assert(!surf->texture || (tex->buffer.flags & RADEON_FLAG_ENCRYPTED)); + } + /* Verify that depth/stencil buffer is encrypted */ + if (sctx->framebuffer.state.zsbuf) { + struct pipe_surface *surf = sctx->framebuffer.state.zsbuf; + struct si_texture *tex = (struct si_texture *)surf->texture; + assert(!surf->texture || (tex->buffer.flags & RADEON_FLAG_ENCRYPTED)); + } + } +#endif + return use_encrypted_bo; }