From patchwork Tue Apr 18 21:20:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9686421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6912D602C2 for ; Tue, 18 Apr 2017 21:24:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59C40269DA for ; Tue, 18 Apr 2017 21:24:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DF0A27816; Tue, 18 Apr 2017 21:24:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81C84269DA for ; Tue, 18 Apr 2017 21:24:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932983AbdDRVVS (ORCPT ); Tue, 18 Apr 2017 17:21:18 -0400 Received: from mail-sn1nam02on0060.outbound.protection.outlook.com ([104.47.36.60]:26976 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758000AbdDRVVJ (ORCPT ); Tue, 18 Apr 2017 17:21:09 -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; bh=0XtfP4qCfZPdvwPM5Th3XMXafLvZSMxwK0HY/ngT0ys=; b=QVnIfpb2GQ3HyuSztYRyH/JK9L7u2RUQg0LSiMN8w8FkIFgOe97Z3dI8FKOmyONNykADHHM3WqhsaehIJoExCAH6lmYuRUtTbWOzJ9OriKH0E2IITGEHxEExdhphCu2FMwbxmo6I0zbs4g6oQMbeXTL5jYoYyra8kpUsABsKdNo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by BN6PR12MB1137.namprd12.prod.outlook.com (10.168.226.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Tue, 18 Apr 2017 21:21:00 +0000 From: Tom Lendacky Subject: [PATCH v5 26/32] x86, drm, fbdev: Do not specify encrypted memory for video mappings To: , , , , , , , , , 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: Tue, 18 Apr 2017 16:20:56 -0500 Message-ID: <20170418212056.10190.25468.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> References: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR1701CA0015.namprd17.prod.outlook.com (10.172.58.25) To BN6PR12MB1137.namprd12.prod.outlook.com (10.168.226.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a5f8c19-0398-4858-4e98-08d486a0d2d4 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 3:T5p4cg0OaHITVZaiiCyy20c+V4nTikH4yweRqw3ffVJfMaR7PEnT3+wGzQ/0iRQ6iXLMPvOHA8MrWMCtb++4HoTZpxEKwnzCVEi84vK+GfFMLr1GxBfZPrmm5bQMMe/EM7t71ucuDVS94UPGK7zFi5KCEa5md3Bqujn6PIV4Jt5rVc263zgJWBlaXRngmJeZ3t9gnPtkQCyvNmPRtILes1DqSrfCd9Jj4weGC58Rn/gt8n3/F8SJqjqxqySjHMOGXSdYI43FJWN/Qj4sVymxwhLfnLQQiAFL+MOtnf0FFJGaurpJYv36fdS9oox56co/0pjDwGv3biCXG9xL5B0/F+7XYyCC4ap2voMaEtogTj0=; 25:/Db+oIonloBWIY4FqGVs7LMI5fSEcJp/pFMsSh3J9apX9bA7pLKniQYqPn9auVakYUAm5lxHDTFwiwJCkt7QK5lbBi5fF72hu7RYNcm+zuG4ixApPKyfHRvVdqpKFU1f/13d36ykUk+6qRilyU5CejtnPCaH9q8RwFgnIIAEbQK8wE5b+1kJHSVdaJAyahXYAjA+Zj4e91s/IAINgVk5d8H/NuTpT6Vs+bi2fAi5nLxCTFPaKTJkKlRx22qI9seSu7oDsLWbG/AlY8ThMG/o+1Sau9JvvTfYSW4Sdxrr4JIieWuClW3l/397o16o7nou4938Y4xQrs765MGDIbX8JaGmvwY8fpstmBivABYYy9NY/vijzLmCEB+YJDBSTq+CkPntqahStnYFyjS3Wm5MX5d7VbxTpg6ve6DvZLPOecYFTcq5dUmb1Yt1qOg6CMwvh1/cLut9vUeGQZrxbD1niQ== X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 31:KSN+1p+PtxB7ysiXuDsjVxLQmGvKtRK73clCfZuplZSdWLE1VlFT3EL270Mipwjn89qVmAG9aBOTJf1PYo/yU7lqjeoipQLtHXZDbtzRw4CuFLQwDt/RFUJdu8PKWiT67tQY3HrsSXkGIYX5QZmkN0JEbDD0SvW2KuZ1s0beXRQs0JHqtOCmExLksyu4Sa/6guHcjA8HwqyuJf2XZENCA3RKHStjIBzEBT3C+rujRYE=; 20:1/04fD0FybnCyc8H+TU3/rPsNYwExEC8EBoOJTZNdeoLN7iwOsN7V2e6stzykFpCjbEnBYcwBs5A1vwJwgedjfz4ev6Iq7EQFjJhB5B8g59ODSDNDvzV4tR5iXs/k1GxX8F+66A79FPpz3+YyQCA5H8dnqH02zSKvffYZCMz6KfIOnp8o7gJlXv7GPOEUPvK6Qk1OTqO71Swd+kSrYT8Tp8nACiXDt62cBzFV6oiJwZqVCLpi3giw+qZAqEOyaDWGFawdKg/jPw6IEORQMcNm/qLeQkON2fDnwYAnA4AW0gjT+CsZeLrOst1elR9+NR+NkWqAMkaItRtq9ZUepADrO8eaJd3NczNqUu8Y0yOzP0tQVHw8knjq9OdRKTzo9TuMhLHLZ+B1fXl1UBm8UUvxWDqzBStjXUwuoghoIcI2E0vAyEsSqf1ouqFzkv1c+upuysrx57vkgcyjvKttmVukqumW1Zmp+6quMSDB0Ghit2X6eV/SYp6thzqy+CdW2qm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(20161123564025)(6072148); SRVR:BN6PR12MB1137; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 4:yvYrIHJf3Us3W7SBeWT7tt/3hqKw9ToCK7qlKcNhQiNQpv58D9Lz42XHsnHiBeRWx6MvXINOtgIQLwl9L++J0q9MDaLgkZtZ/HUGW8HXSvUHbb2PKZA/OeSmeM9DdmQgYFYHiHTT9irDd0eMCJnr0G5z+GzeQsa1kj6QcM+T5p7DL/EBM0oisMpCaVV7eOIJPZdX/X+J/QilH9THZ8Y99AS3Xw2PNnH8tGFBpWiLB+ET3+OJCxoAGACN7Ul9I9DlplPXzn0v1N2CO1692oGiSITHOyH+rGqQ9SEoPHQW43Iahf1HIVasHkoOouB6bPhidoJxtL3w0A8vt27tqz/iNrNDYdDwiRmCInyvSbD9tlWynsv/ul+0XW26jvFHkjjvqPytaZ2VEtJq8q9Os/viRDrOI0DDQJ+h3J+QrgqTwccuSa5n2N1p2lRiA7p9Ui30yCOoAkAizqtlyeyeCV9xkKNnhqXjZc1vE6qoeNA48npZTCbNPfZDIMMgLBa7qGB6M62wRI58sWXKfaIlwhbvCgl5Q8HXY/GHSfHFhwdEm+C4uPAOHuRb1gHvk7FivqBi82fB/+t0qcNAtJriNL5MwWFiEA2zUGEAfuO/cwoSCH/CIeao8xyf4qjJUPg3NeSmEZZKG83FKuzfQCgkgyz1I8miP3Bn4Al7qWihrbH+rrsGtKeFWewkjzKSDLsM+cNWixwCWKjyMjQBpMx1rNikHZ4Kgf/gRMh0y2MyYtBKEY8Zt+pzAGDJ/BCZD45n4Pp9EjD8OefybiIB8M6u/bzDAA== X-Forefront-PRVS: 028166BF91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39850400002)(39400400002)(39410400002)(39860400002)(39450400003)(7736002)(7406005)(2201001)(6506006)(7416002)(23676002)(53936002)(86362001)(54906002)(5660300001)(9686003)(83506001)(305945005)(81166006)(8676002)(55016002)(42186005)(2950100002)(53416004)(230700001)(50986999)(6666003)(1076002)(76176999)(103116003)(6116002)(33646002)(97746001)(3846002)(25786009)(47776003)(4001350100001)(50466002)(38730400002)(66066001)(54356999)(2906002)(189998001)(4326008)(921003)(71626007)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1137; H:tlendack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6:rnHRzsV81ggW3ZK9UVEDt5f5WKyOJHo59YzQsMcBX4/eZRlKBn32yVp2ef7SvHNyIUOGldN2zqx969d+CvuOAnQjaFamDmPZzrFKPJq9a7z6iOydGs5p4jWyySq84G+BC33K3D9x8dKds2qPS2cZ6LQAMEcDgQkK+fg16wWCh986pOJD0aiHk+lrzdC1zpX68HMwwB4Od54lNzYs3YJz2LEACs7o1LXKEPv/gosM+KdEgcjF7PDrKk3XzOQD7TNWvx5hPu3TkwcxOgA0WOCxP0FCphzuodlJKFm03Fcr2hGrKng1ekccoogMjn0KRKhUccL46v3zLhV60+UBJkqE+dbSZjG/xurl9wwlmWrm0oPVlPzMOcV+m8XFYRKndS8LLCFTnVvYqNrHikyH0i//edk2+WNp+9sqDVZaO6jDBpGashe3lWu7YKEZe3rd4fYdw2kHxVX5GdQR4YTeyfdLlfoJXnm4i/te7iw2LK1r228=; 5:eVw/si3+/qfeFZNp6rcrVtGMK0+d46Orki5SjEM2MpMFHyR1Ai81offIN4m6NkO6ria0HOCrErKOht4/YRr25FchD3ityEmFOeOzPK42Lxd9y9k0+0V5nfIloUHv2+L5R8//Snvgd0lszRES+jz3xg==; 24:82z9WRfWbU7gCsDX6KK7Dv0SbaK/BCQu/LOM3p3XWHoXarnGvkyAEs58iepAEMv6Edm5EiIT9PVuzbmxxuA5iNyKp5l10C5fBGmuTbKrX4Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 7:P+irRA3Cr4+uasVebEWaBloQPOcyXfd8qV+687O1RXnfR2LAn4xdzcBn9fDzaE5lrhF5hM90qDfMgjdtZ85kPgILcFu8NlnlgwLsYIOYCvUKcN3SlU/mGtnh2JIQwQgezDOyzxYXFgNCMz//OyZJFA5EN79Gjg5ut6i7TMhhh2P0dxhiRq5S+hv/HrjpuAdzhnNh2CiwJ5PTByG+cZI6YRVlortQrN+ggAO2nwf/0sXW/1vktrPpx8RaVS4q1l8IOc9r+uqNQW77/NTGeBHL/P36F/hYcE61xCgs7eaRklps/gePW0M+jnxANU1VGWgKhzrfowJ+EAZUI2rJ7GML3g==; 20:8jahqzIZ1C67isoucdsNI2v2TWYGgwqym7SCO6zLCAZIhQpDW0OHdSC3hXxMqgX+tWAw0uL+mTpsHmD8Ar/YQkwcnTDvfllfmTaoCnKq6vz73jx5EmnmV8rvLt/mXG7DfOzlTZk9oeZ9v3bSyggubnBAtF/My3PdLCCym3lq3N7AZtbQQiAY63YP0zyLJfuIc08QLItc8vXKhgRQdY2xGKeJM+PZQnI2nUZXuNXuCBooBZ+4PN7DjSy9bYD0l2AQ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2017 21:21:00.9011 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1137 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 13 +++++++++++++ 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(+), 2 deletions(-) diff --git a/arch/x86/include/asm/vga.h b/arch/x86/include/asm/vga.h index c4b9dc2..5c7567a 100644 --- a/arch/x86/include/asm/vga.h +++ b/arch/x86/include/asm/vga.h @@ -7,12 +7,25 @@ #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. */ +#ifdef CONFIG_AMD_MEM_ENCRYPT +#define VGA_MAP_MEM(x, s) \ +({ \ + unsigned long start = (unsigned long)phys_to_virt(x); \ + set_memory_decrypted(start, (s) >> PAGE_SHIFT); \ + start; \ +}) +#else #define VGA_MAP_MEM(x, s) (unsigned long)phys_to_virt(x) +#endif #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 0a850b1..5f14f20 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -1824,11 +1824,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 bc93de3..96af539 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 35ffb37..7958279 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 = ((bo->mem.bus.base + bo->mem.bus.offset) >> PAGE_SHIFT) + 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 8e8d60e..51ee424 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);