[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d22f2dce-7229-aac8-036b-5312927632e4@gmail.com>
Date: Wed, 22 Aug 2018 21:09:36 +0200
From: Christian König <ckoenig.leichtzumerken@...il.com>
To: Jiandi An <jiandi.an@....com>, dri-devel@...ts.freedesktop.org
Cc: airlied@...ux.ie, linux-kernel@...r.kernel.org, ray.huang@....com,
Jerry.Zhang@....com, christian.koenig@....com
Subject: Re: [PATCH 1/1] drm/ttm: Set memory as decrypted for ttm framebuffer
mappings
Am 22.08.2018 um 20:57 schrieb Jiandi An:
> Framebuffer memory needs to be accessed decrypted. Ensure the
> memory encryption mask is not set for the ttm framebuffer mappings.
NAK, the memory not only needs to be decrypted while CPU accessed but
all the time.
ttm_page_alloc.c and ttm_page_alloc_dma.c should already take care of
that while mapping the pages.
Regards,
Christian.
>
> Signed-off-by: Jiandi An <jiandi.an@....com>
> ---
> drivers/gpu/drm/ttm/ttm_bo_util.c | 12 +++++++++++-
> drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 ++++--
> 2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 046a6dda690a..b3f5d26f571e 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -29,6 +29,7 @@
> * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
> */
>
> +#include <asm/set_memory.h>
> #include <drm/ttm/ttm_bo_driver.h>
> #include <drm/ttm/ttm_placement.h>
> #include <drm/drm_vma_manager.h>
> @@ -639,7 +640,11 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
> if (ret)
> return ret;
> if (!bo->mem.bus.is_iomem) {
> - return ttm_bo_kmap_ttm(bo, start_page, num_pages, map);
> + ret = ttm_bo_kmap_ttm(bo, start_page, num_pages, map);
> + if (!ret && sev_active())
> + set_memory_decrypted((unsigned long) map->virtual,
> + num_pages);
> + return ret;
> } else {
> offset = start_page << PAGE_SHIFT;
> size = num_pages << PAGE_SHIFT;
> @@ -661,9 +666,14 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
> iounmap(map->virtual);
> break;
> case ttm_bo_map_vmap:
> + if (sev_active())
> + set_memory_encrypted((unsigned long) map->virtual,
> + bo->num_pages);
> vunmap(map->virtual);
> break;
> case ttm_bo_map_kmap:
> + if (sev_active())
> + set_memory_encrypted((unsigned long) map->virtual, 1);
> kunmap(map->page);
> break;
> case ttm_bo_map_premapped:
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index 6fe91c1b692d..211d3549fd9f 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -249,10 +249,12 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
> * Speculatively prefault a number of pages. Only error on
> * first page.
> */
> +
> + /* Mark framebuffer pages decrypted */
> + cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot);
> +
> for (i = 0; i < TTM_BO_VM_NUM_PREFAULT; ++i) {
> if (bo->mem.bus.is_iomem) {
> - /* Iomem should not be marked encrypted */
> - cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot);
> pfn = ttm_bo_io_mem_pfn(bo, page_offset);
> } else {
> page = ttm->pages[page_offset];
Powered by blists - more mailing lists