Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752638AbdFGTSX (ORCPT ); Wed, 7 Jun 2017 15:18:23 -0400 Received: from mail-sn1nam01on0049.outbound.protection.outlook.com ([104.47.32.49]:63808 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751989AbdFGTSP (ORCPT ); Wed, 7 Jun 2017 15:18:15 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; From: Tom Lendacky Subject: [PATCH v6 28/34] x86, drm, fbdev: Do not specify encrypted memory for video mappings To: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org Cc: Rik van Riel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Brijesh Singh , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dave Young , Thomas Gleixner , Dmitry Vyukov Date: Wed, 07 Jun 2017 14:18:04 -0500 Message-ID: <20170607191804.28645.72185.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170607191309.28645.15241.stgit@tlendack-t1.amdoffice.net> References: <20170607191309.28645.15241.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR1101CA0008.namprd11.prod.outlook.com (10.174.237.18) To CY4PR12MB1141.namprd12.prod.outlook.com (10.168.163.149) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PR12MB1141: X-MS-Office365-Filtering-Correlation-Id: 253d0797-ee39-4cc6-1184-08d4add9ef99 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(201703131423075)(201703031133081);SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;3:dxCx5C7IJoYfKXYdgCsroNOIql4/j0+QxyB7bu3G0bM48Guv61edEig9O80sqTlSHeynnIhCW2xHr6aaKZsQKAl3zx07DNIvbFcwOt1AenvYNyn5mmqgE5206K8W0cQ0EbWiE75x2sxjGdSd7Gq4hz+YcmNruNuyYVJI9huOR8hqfQphIpSCgh/AcgzaG81jF6sc1C0naqzTldoMs49G4BAuj9KaUVhtngByThIm6fkMPWWLFwhnh6y2E6kqHX27CNzrlkcYk7OCV00mOODhu6nOUsSewELukAF12WcGJDmjvqiBrbZFI2TAHuheh7gyHibHyGcn6eLb5h4dPgkesSZTEOUqAPodEmhe0AILp/o=;25:gCUJYVmW1Y8BXOzTgLwziHs1old4DM4L9/M7j3yX3sFeiMBSCCN/gGDgB0eUk+NArvNN8GqMoakVoj0iPMUkckcPnn80gAH7ueECah/ty7YrK1BpBghmVs41Yd7tDp6eHshJjp8mJRngWR9jrVEtBJ//R0k5R20o3cPpxnmaKu7tpOppkqyLI/eiOVKGoh/3nELeGgr7PnXJ40VP2c317WGvXtfmN/BrBohQEQYWgHAPX3ezxykuZXM4Hhz3FYNQLEyqkrRq/k8DfxjqYcyC0K1y3+gKhjWHC3mLkZKKGJq+TCBjco0pwlj5BaX5+33aks/F0pgmoYuT+DMnCCFloGH3w1HZSiZ71TYF8mMagzUrlQtGYrDdnSi9DULDx2QeF8+QrAj+2YyV0J3kWCgCyS3Lh7IAwVIj/hBjsmW49HnKlCVZa04msP8utx6rDhq2syTKjsu9vW8NaqOpDTVlhyWuIZcV8hh2wQW+U1xpY6U= X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;31:3p+cpRWQCliQYcStr/DCQDkJrrdPMIQMelmd16US5BYNzbwj2PAlXr9wPiGEOOMUbjmbPjKPIdID4b//lYF8p5aQkbGdOtZSC1tR2Hi1E96vqp5Q/CvkTtJrX8FOFT6MJX/6cxadO71qGva8Bkmes+fdSV5amwk4nWQcKRRG92kJbOWGK1tDth/cbAhv5LzLPJyz1wuLVx5hrI0QkNboy1M1o5sy8ewEdxMd2s8ub8o=;20:n+rz63Rm9P7SZtB360AOiZvDscXG8yG6pn1eEGnNa3Cwq0Mnt3jDLMqLN+R/WNiKzJgqJ+Q8O/cQZjfb8tmMBPfEYhhc3t7rEt9cnVhsA52I2YznRT7SjmUtl6I/i1fmrKc35oxsLf9OqYDDx0T8iSGxXHEeAxjKp0rnf4RyhV0J88Yg2Wr5LKuXJvxIgRVu1v3nIgpNyz6AF9MIT8m1FRubgx1hWWCREL4i46rdW9RVna1qqWG+n3oLiLw+zl/8er67hujb1XCPX4sMzIXwOlHUkAmdoutFRHrxVF4QQdJkM71VX/Eo3yTHh76yykEtfCajVJioUUGnE3pJ0ekElH5ssUb6ItEL1W3j9wgROkc3l21nzDjla8yCsArQygdo6VFVlJEkpx3v8sGmddz4sRXfh8gipy7nslDONbXWSlN4UCTrMaL6u6aG7DJzNWoK4NE7D8SVOQ/nvyrl/DJAQkNIDQKHS5GFYWwnIdQIASyeheeo4xfzZglvvz61O/uH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123558100)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR12MB1141;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzQ6SHhUWTl0dzE0T2xSOGJTaWFoSjJLOGJvVmpJ?= =?utf-8?B?VUtad0RDL3ZRMFM1M25kZkRvb3NHSHpBUGNkU1dETE56dTdiblJUQ1E5UG5R?= =?utf-8?B?NXJYdldQbVJoL0JCTUlmZGtmRDlSaDNNSVV2eDEycWg3N21rWGZxODMvZUpn?= =?utf-8?B?RHRBV2UzY3FxOVhFdk4vT2hUbjdvVXRsc0JhYnpMNGJtcXpOWS9sM0NrKy9T?= =?utf-8?B?bTFMaFFqMFo1ZXQrbTdaYzhRL0tCUld5b1p4bjV2RlZPa2hHcW9haFJIUGZn?= =?utf-8?B?b2paMEY4QVZVQzdYVUtpb3dGL2xxWVhUb0pETWJjY0ZqemNoUFBoUnlIbllx?= =?utf-8?B?TjhHU0xUVTlVc0VodlpnYll5WVNIOXJad2dWMUZySSsrcStrQkg3M1lUUkQx?= =?utf-8?B?WFMzTjFzYnNhWVF4Ky9BVy81RElBWTJkZEZ3NEhFSUU3UWNpNzczSHdSR3BH?= =?utf-8?B?THdDcFdVYU5iNi8zNVhMMkFrRlhSa3NyYXRERURtMVFlUUVIYnpLcSs1YUg2?= =?utf-8?B?Rkdpczc0bWRTK2FwcW1LVnZvQ2VIcFlSZHF1VldlRFVCT1oyWmVIaVZJL1Z3?= =?utf-8?B?OG1vaHBsNEtpNUVYdmRVT2NicFBQWXZKczcyR25EMDAwZDFBYk5IZzlzRGpo?= =?utf-8?B?bEZQOS9GeFAzUmZCM1Z5K2RIU2NIQktMTCtwMzlTYTJvdGtmenJOeHVxK29E?= =?utf-8?B?VkFiTFE1MS9uQTZTQzl2dUtjVlRNQ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2Ii?= X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39450400003)(39840400002)(39860400002)(39410400002)(39850400002)(39400400002)(9686003)(54906002)(55016002)(6506006)(66066001)(4326008)(47776003)(110136004)(103116003)(25786009)(38730400002)(72206003)(478600001)(83506001)(305945005)(7736002)(86362001)(76176999)(50466002)(53936002)(54356999)(97746001)(7416002)(7406005)(23676002)(1076002)(6116002)(33646002)(3846002)(50986999)(230700001)(53416004)(42186005)(5660300001)(4001350100001)(8676002)(81166006)(2906002)(2950100002)(6666003)(189998001)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1141;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzIzOk5VTGxJWDZDRlVBVTQ1YjRvRG9UZWVVbytN?= =?utf-8?B?N2lSNkpJdURYVWQ3WkZxNEVrOEdEWURtVHpiQ012QW1hMUJyVnBTTWM5aThW?= =?utf-8?B?dGFHdXhtSE1DUTB2aTU5RWVjQk4za3lEcDU3VVZraGZWMmwwRlV4WHFjSTIy?= =?utf-8?B?cGJhdFlMVVFkZzBicEttbjh1UnAwY0JoQWxVWFpTRXVmY205aEJWS3NtSjE3?= =?utf-8?B?UmV2OWpJcnhsRDFQcm1BS09pSUNtT2k0ZFh4Q1RzbEV0MmFxRStHLzZ4U2Iy?= =?utf-8?B?dU0vRjNEVHRTMGFHVkJDUnlNVkRjMjhKOENpclpCdHltbFlnUkkvK0J4cEkz?= =?utf-8?B?SjRWeFZtaDA4cm51UGgrM3dIaGJjMnhvSjdLaUZ2VHBRd1VITmNEVER2L1pj?= =?utf-8?B?Q2pSdWMvKzc2Zk5kdmhZY2NqbDB0Zjh1bnNMTXVuMFZrRS9yQ0Z4N3B1WTh6?= =?utf-8?B?cmNhUklPV3h5RnlXZGFhN1E4cjFJO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pRrsTkILUzN5BdtK6pjZVWASAQ5lHRFiHfgFXTFf1rgxRuuXLVaVCQl7UxUToCVq+uCiuTz65NGF2x64SnpyHlYK9L/y3dPIxfcCEjR80diAglzVITQNOQHAN8BTTfgU8BF4NgqX4juKTqx/PH3Ct3e2wdCEnT82+F2C1F9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2017 19:18:07.3814 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1141 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6329 Lines: 189 Since video memory needs to be accessed decrypted, be sure that the memory encryption mask is not set for the video ranges. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/vga.h | 14 +++++++++++++- arch/x86/mm/pageattr.c | 2 ++ drivers/gpu/drm/drm_gem.c | 2 ++ drivers/gpu/drm/drm_vm.c | 4 ++++ drivers/gpu/drm/ttm/ttm_bo_vm.c | 7 +++++-- drivers/gpu/drm/udl/udl_fb.c | 4 ++++ drivers/video/fbdev/core/fbmem.c | 12 ++++++++++++ 7 files changed, 42 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/vga.h b/arch/x86/include/asm/vga.h index c4b9dc2..9f42bee 100644 --- a/arch/x86/include/asm/vga.h +++ b/arch/x86/include/asm/vga.h @@ -7,12 +7,24 @@ #ifndef _ASM_X86_VGA_H #define _ASM_X86_VGA_H +#include + /* * On the PC, we can just recalculate addresses and then * access the videoram directly without any black magic. + * To support memory encryption however, we need to access + * the videoram as decrypted memory. */ -#define VGA_MAP_MEM(x, s) (unsigned long)phys_to_virt(x) +#define VGA_MAP_MEM(x, s) \ +({ \ + unsigned long start = (unsigned long)phys_to_virt(x); \ + \ + if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) \ + set_memory_decrypted(start, (s) >> PAGE_SHIFT); \ + \ + start; \ +}) #define vga_readb(x) (*(x)) #define vga_writeb(x, y) (*(y) = (x)) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index d9e09fb..13fc5db 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -1825,11 +1825,13 @@ int set_memory_encrypted(unsigned long addr, int numpages) { return __set_memory_enc_dec(addr, numpages, true); } +EXPORT_SYMBOL_GPL(set_memory_encrypted); int set_memory_decrypted(unsigned long addr, int numpages) { return __set_memory_enc_dec(addr, numpages, false); } +EXPORT_SYMBOL_GPL(set_memory_decrypted); int set_pages_uc(struct page *page, int numpages) { diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index b1e28c9..019f48c 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -928,6 +929,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, vma->vm_ops = dev->driver->gem_vm_ops; vma->vm_private_data = obj; vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); /* Take a ref for this mapping of the object, so that the fault * handler can dereference the mmap offset's pointer to the object. diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index 1170b32..ed4bcbf 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -40,6 +40,7 @@ #include #include #endif +#include #include #include "drm_internal.h" #include "drm_legacy.h" @@ -58,6 +59,9 @@ static pgprot_t drm_io_prot(struct drm_local_map *map, { pgprot_t tmp = vm_get_page_prot(vma->vm_flags); + /* We don't want graphics memory to be mapped encrypted */ + tmp = pgprot_decrypted(tmp); + #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING)) tmp = pgprot_noncached(tmp); diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 9f53df9..622dab6 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -39,6 +39,7 @@ #include #include #include +#include #define TTM_BO_VM_NUM_PREFAULT 16 @@ -230,9 +231,11 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf) * first page. */ for (i = 0; i < TTM_BO_VM_NUM_PREFAULT; ++i) { - if (bo->mem.bus.is_iomem) + if (bo->mem.bus.is_iomem) { + /* Iomem should not be marked encrypted */ + cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot); pfn = bdev->driver->io_mem_pfn(bo, page_offset); - else { + } else { page = ttm->pages[page_offset]; if (unlikely(!page && i == 0)) { retval = VM_FAULT_OOM; diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c index 4a65003..92e1690 100644 --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -169,6 +170,9 @@ static int udl_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) pr_notice("mmap() framebuffer addr:%lu size:%lu\n", pos, size); + /* We don't want the framebuffer to be mapped encrypted */ + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); + while (size > 0) { page = vmalloc_to_pfn((void *)pos); if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 069fe79..b5e7c33 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -1405,6 +1406,12 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd, mutex_lock(&info->mm_lock); if (fb->fb_mmap) { int res; + + /* + * The framebuffer needs to be accessed decrypted, be sure + * SME protection is removed ahead of the call + */ + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); res = fb->fb_mmap(info, vma); mutex_unlock(&info->mm_lock); return res; @@ -1430,6 +1437,11 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd, mutex_unlock(&info->mm_lock); vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); + /* + * The framebuffer needs to be accessed decrypted, be sure + * SME protection is removed + */ + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); fb_pgprotect(file, vma, start); return vm_iomap_memory(vma, start, len);