Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp765810imm; Wed, 22 Aug 2018 12:10:59 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx8Ktaw3RG2eDwAfIwx0xHncIHHBO610ZYglpmgYSf4it4faM4SfBhd5T3J8p/cEWkTkAXF X-Received: by 2002:a63:1b41:: with SMTP id b1-v6mr9041752pgm.72.1534965059838; Wed, 22 Aug 2018 12:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534965059; cv=none; d=google.com; s=arc-20160816; b=wqRB8dVXsE3q8F1aLLmGuQkD9r0EW1uzzQrVObfEhneTqIBA1eiT2HB+0pk8OyFL99 g2TGOlkLBJkqR9Ea82QhveQ1UPv9vNCW+riTY5iY6XwQ6xWBx7wAGvm+/Q8waTvAzq97 lIYFrcnBAd7vX/kxxxcvHlrK1Mr2PwXOfOEzIJLuOQv/iW3O9udYlbcaIGC7o1ohp0NN 9YwZeq5hvE/HuaCfqvKHiNjaRSf6Exfe1mBHS4tzKrIlwu6ZJdd44pYX9IcMkyX8aAnH SjR3iolGzKm6hPAnPDpb5NgMAVoDYvximAksHRF2PjsGU623xeATA06sichkEowzi3yC Zw1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to:dkim-signature :arc-authentication-results; bh=hEoSw1QzYWzj86YS1vACPT9CSMn5dtE9BIFeI0QDP4w=; b=WLnKtwlo0udxRHbocAzIRILq85wcGsk/T7Z7W2emqBOVF5v8AZcM+O5N/uFL4KsGQw qH4d3qdv9YWNT/+FeBSnnWWt31B0DgFv0tobiI7WJSNpizh7217C5RVuVD0K706hhvPA MCaKzY4GKIIfSBy2vcxSB8SAKStDHAXHCJN90Y+hFZz4OIVOr+fe/Ywpd+2ETLjv5zga O4DLNW2vbSzb+2YFSSmKZf8zPhhzpOVS9c0XH13+HknNqe+fpXU5lt0PbMGv5tQLTPvZ d/Cd2FzzksR9xGjR6NmwW9zf4G7LkSm4/K/xmuVGlYgOi+f86dTbZLzB+lHWZ88LAtCy 5zuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WYCB7Fmx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5-v6si2182607plr.151.2018.08.22.12.10.44; Wed, 22 Aug 2018 12:10:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WYCB7Fmx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728061AbeHVWfp (ORCPT + 99 others); Wed, 22 Aug 2018 18:35:45 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34531 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727678AbeHVWfp (ORCPT ); Wed, 22 Aug 2018 18:35:45 -0400 Received: by mail-wr1-f67.google.com with SMTP id g33-v6so2499040wrd.1 for ; Wed, 22 Aug 2018 12:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=hEoSw1QzYWzj86YS1vACPT9CSMn5dtE9BIFeI0QDP4w=; b=WYCB7FmxEBwyKbSupFOZtiJHLx5JvrkVKZ9hnPtIQgBin8HBUaiXUH6RZPHeh2h8WH yE0MxbrXfbxBJC4CzSITlOnu2G0ZQkiNE/hDb5TzDhHV32YjuEcLoSWwrKWHuwYqMNku /LZ3LPPnWFx8xfR3lQsJduzsbeqfbtDqr81QkSyy8naVdlPk9PAaPPCrhPah8u1JKk4Z di0edELJfRDkut+UOH91dJDl+Hc1ewZaRADrq8J7amplhlIVuwQvqdpjp8PxHoHrajy5 VQwGqCyD4lvsEHns4cPgpA3s58DeUL6F3af5UbDHuY0ZA+IcRRdhOSq9jrHJiE6sBXAO uGfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=hEoSw1QzYWzj86YS1vACPT9CSMn5dtE9BIFeI0QDP4w=; b=V+iaZSxxpqq7YlyFcFpGws9OJuDfw427+bCNQPFQZbKfZ2m8UtxmjTr1SZJ1jKrw0s JWwlLr25JMIAI93Upma9ync5KwwKTzA1P6X0HSWdzoavpp+ml09l77ekEnCae758w/t6 1iL6PaMv8sM1ZghGLTYPvMzoLr8P8fZ6TOLYdiExaKh+X/sHr6m+DVDU8ZHB4ZwrRR0Y BdQUFW0Vi+clMUcph0KI8K9QKoNp6MWV6r5gTWrMOZNXeXGLbKwjjdkGVEXiVOlcGntn 7tDS02Fjjh/W87Sv44L8kGfEj+Q2YD9lUMa8A35rd61X7RzSd5lCo7AFqTMaA/b1qVWs m8Aw== X-Gm-Message-State: APzg51BrZuh9gPJRQTBq2pM19OtsTKUXexNtpqqrfgyy0EaGtEY23WYn bpHV1r5MHhbjeYeD5Onj/Cs= X-Received: by 2002:adf:9a21:: with SMTP id z30-v6mr9282942wrb.47.1534964977975; Wed, 22 Aug 2018 12:09:37 -0700 (PDT) Received: from ?IPv6:2a02:908:1257:4460:1ab8:55c1:a639:6740? ([2a02:908:1257:4460:1ab8:55c1:a639:6740]) by smtp.gmail.com with ESMTPSA id o3-v6sm2089857wrn.58.2018.08.22.12.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 12:09:37 -0700 (PDT) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH 1/1] drm/ttm: Set memory as decrypted for ttm framebuffer mappings To: Jiandi An , dri-devel@lists.freedesktop.org Cc: airlied@linux.ie, linux-kernel@vger.kernel.org, ray.huang@amd.com, Jerry.Zhang@amd.com, christian.koenig@amd.com References: <20180822185754.104729-1-jiandi.an@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Wed, 22 Aug 2018 21:09:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180822185754.104729-1-jiandi.an@amd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 > */ > > +#include > #include > #include > #include > @@ -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];