Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp752592imm; Wed, 22 Aug 2018 11:59:38 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxLwT5iCYgZtu3Cb6OdzkO3oanhbj3ifJnQWNqCIxKpcHS2x+MpZ/xmS9fktC3vlpJUcx++ X-Received: by 2002:a63:481:: with SMTP id 123-v6mr22564850pge.129.1534964378575; Wed, 22 Aug 2018 11:59:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534964378; cv=none; d=google.com; s=arc-20160816; b=V/CMkySZOot5lI5VvT2wrlomylP3v/cYTKouySsKyYKHOkhk2SkDqpeZcHReIyF5Ou F3FoBYenpP3y93VP1ZVjN9Nf4kURj4W3XwUlDpKUzrrQ4+pT6JHLQqdjBX/SXZcDXCHQ g5CxqTq2Po81SVV4VGtR1utxt0S3prSVATfQIGaSyF0y63Svittdcfb2fIDLPSfXS2Lb VPncKDPeRyts2po2TaDGeTyjb503qXszYwrhc4rWK3Mud3HvQy8+YTs+eT52UMjvOkO4 f1YhNxZw6YNcZISJJb302RTaDBiNN5IGr3QAdz9ILIC8oqEjOnsVmfU0aqgum2RaInDw mJsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=n2aGte5Qb0XSOwV/mBVy2KAkgjt+5Li/7sITVteoltU=; b=brz+mBu0RwlG2DulsEmqjKK05rA8PR/8e3/zV7Ki17qbmwQr/jx0twU8RtA0WeXV5b r9hPLQg7eee7UTmjws2pywLnlWewhLhlgyKWM57Wdf2FA5wG2m3SKMLNEFUCJd7KfD5o uNMcmB2eb0oMib7r2jF1NflGYYmdPcjxo6JdTgtizKO0o3cL77JmT2Yf/HoVmXcrP9CO QQhkhDo6o71LjEvCqhQbXG2qU8LxuFiCLn1lsqc6Na9dVEbgNOilfx3jPFe5iT3diXga DL14nXR2uQqboxDY5AjY6EDPVLJKCnr5JzE6niw77/Q0LFdBPWQF7JMCvJVoEnHcFtnM xpPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=msQmFTsb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17-v6si1751429pfi.183.2018.08.22.11.59.22; Wed, 22 Aug 2018 11:59:38 -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=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=msQmFTsb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727991AbeHVWYU (ORCPT + 99 others); Wed, 22 Aug 2018 18:24:20 -0400 Received: from mail-dm3nam03on0077.outbound.protection.outlook.com ([104.47.41.77]:30240 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727874AbeHVWYU (ORCPT ); Wed, 22 Aug 2018 18:24:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n2aGte5Qb0XSOwV/mBVy2KAkgjt+5Li/7sITVteoltU=; b=msQmFTsbPRd7IaKrE20xVVqfOfnaJqYmdwVoeoD7j43z3QJAOgwTfleLIGCqIQBSLVsgCdjMMnhvn+HafxJihUr9wreutTQmBofUn60LqlEhVi3VjSqcWjSzXf2oeWSwKDkqW9GJNgT7rj6SbDAuv9hwR27UXTYfJRsCQzLystU= Received: from jiandi-diesel.amd.com (165.204.77.1) by CY4PR1201MB2532.namprd12.prod.outlook.com (2603:10b6:903:d8::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Wed, 22 Aug 2018 18:58:13 +0000 From: Jiandi An To: dri-devel@lists.freedesktop.org Cc: jiandi.an@amd.com, christian.koenig@amd.com, ray.huang@amd.com, Jerry.Zhang@amd.com, airlied@linux.ie, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] drm/ttm: Set memory as decrypted for ttm framebuffer mappings Date: Wed, 22 Aug 2018 13:57:54 -0500 Message-Id: <20180822185754.104729-1-jiandi.an@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DF4PR8401CA0034.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7602::20) To CY4PR1201MB2532.namprd12.prod.outlook.com (2603:10b6:903:d8::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 915d666a-586b-443e-521e-08d608613646 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:CY4PR1201MB2532; X-Microsoft-Exchange-Diagnostics: 1;CY4PR1201MB2532;3:qtK7pw1BNIhQvALR6/IKMh1C/bH8IxtaR6L4tRTl42k4ajnVkdtngMRiP6b54ngOw1jiGj9197Cui386fKmmZdAThE1b0YuZHfOnQmlFhqP68S9ksHvnl7hU9pjXNIQHutaHorwzuftKd9kmuiErz+jF7/2h0yIJhGYnWCfTlzSfHfjC1CZ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2tiOmcwxCxgQvsLEebPtr7L27jfMODzO/81bhjeYtIpI4JVFt6cDrA7nJYBr/goS4oWrgtc5Zw0+iW/6Tf9WhauDg0oy9iUnmDFKDxYq5tdyMuSDXfLt0t7CRBiyDhCDePCxAHriQOO41rzJQo31/6fhqUOz9026UzUvH;4:kUGFIEjt8P161z7/FIwtuV4poFNyxGyr3k23/zQVT1I2KCP8XUOTF3wLVeveZ4eJB7mCq6kUhhgzjO7yTTmqRdMv7Ml+V/a0Z09+q5VXl1fn6DA3mLCSyTulFpFI6yrCFo9Lga3u4TJEeSl7cpBrIjzRy7XWHzDiLvjH/FGIaLHNTevbWOff6PQDYhumjdxoX5GhKb13ax8YIh3tCQvKm6g9tQ5JG63z9ep7eEZ89Ps73hW3FWvt/Rb1XS84qvjwZYNr76rC37rlYbgRdajOglSo/fogif7XnAgRJVOeT+jpx+Uqx6v2tl8GWjjTmYdB X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:CY4PR1201MB2532;BCL:0;PCL:0;RULEID:;SRVR:CY4PR1201MB2532; X-Forefront-PRVS: 0772E5DAD5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(136003)(346002)(39860400002)(376002)(366004)(396003)(199004)(189003)(47776003)(66066001)(386003)(6346003)(53936002)(97736004)(48376002)(2906002)(50466002)(305945005)(956004)(81156014)(26005)(44832011)(81166006)(8676002)(25786009)(16586007)(2616005)(186003)(6486002)(476003)(316002)(5660300001)(2361001)(6116002)(3846002)(86362001)(106356001)(16526019)(478600001)(105586002)(486006)(1076002)(68736007)(50226002)(6666003)(6916009)(2351001)(72206003)(8936002)(53416004)(7696005)(52116002)(51416003)(36756003)(7736002)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR1201MB2532;H:jiandi-diesel.amd.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jiandi.An@amd.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR1201MB2532;23:yYWbadqp8sRS7qagtSbppXOOnF3WyK3bgFT/PL3?= =?us-ascii?Q?qBIZyP5aAnHMyJk+oDfazeK99NjKsGtPRRzL0mMcVTqWKACTFmOQdwKvadJ+?= =?us-ascii?Q?e8udBLz4MlVbJUyOy62RNLO38dq4EkKJeCNRiAvZfbUnh8cPvXkI3T5UbwH1?= =?us-ascii?Q?z1MJVdsHpUnP4ly/sxStPM1G726c0s/0HeJFloYhNpwuyEVBQQBfjoI57wyf?= =?us-ascii?Q?XxFGHW27zP81oHTVfrcGDJfm8fjxy1M2NocTpi6pbNhzc68NvpXsLWOuhkBq?= =?us-ascii?Q?YR3vGmxJzpxoCfNKgGmWXX5WHnfns8AObylFLB1h41d9SZjANg9yHNWwIADg?= =?us-ascii?Q?ob0bPC/ah9JTSqLCeNYfTPG+5u6/Q6vKUteM8HmyARDBZf3hJkCH+yeLWjxB?= =?us-ascii?Q?MLG+bd5vZPQ7bY4fTUAhVXhbtI1GWlClZbc6ix0pFHuA5H4Au6m8Xs2GCi4R?= =?us-ascii?Q?QQs+0scBSrgHMveDuL2IDq3eFjj5gqubhLraNmBebvEMC/o2IgZTnJPnv4td?= =?us-ascii?Q?P+OA2GiThMwFz9vhL17Y/S9H+glSfWTOuwVH99h/mE019/DyW0wzjVY+D1/A?= =?us-ascii?Q?8kRM5Uc6oKd8g9X21Wn9gSGLPNxhsAfOcNjP3Ub1BPje/akz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Microsoft-Exchange-Diagnostics: 1;CY4PR1201MB2532;20:0vg/xKHKyr7cgX4HoOfaU/DFzy2rTLwGkpOFsXYx0g2WqoMpetPTjFCok7anOvOkKqPAIsv6gAxGszbFkbQiMdqL7Gx0K1gJkutONXFvPF5w+EkqsILzswVEZYhMEN/eLSsTIPWTpCm1FA3PD8Obnr5h756NjC7Mg7fmv4u6YCSvdtAG7fJEdD7VZXoO771ZbPx6V9IdXPCTr83e9HYq0CXdm4ZXyuUb59+G9p4+vG7CmR8VTa/zmCq6ONqj2ZNd X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2018 18:58:13.0418 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 915d666a-586b-443e-521e-08d608613646 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB2532 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Framebuffer memory needs to be accessed decrypted. Ensure the memory encryption mask is not set for the ttm framebuffer mappings. 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]; -- 2.17.1