Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753856AbcDZW7A (ORCPT ); Tue, 26 Apr 2016 18:59:00 -0400 Received: from mail-bn1on0085.outbound.protection.outlook.com ([157.56.110.85]:53156 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753149AbcDZW6z (ORCPT ); Tue, 26 Apr 2016 18:58:55 -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: [RFC PATCH v1 16/18] x86: Do not specify encrypted memory for VGA mapping To: , , , , , , , , CC: Radim =?utf-8?b?S3LEjW3DocWZ?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Joerg Roedel , "Konrad Rzeszutek Wilk" , Paolo Bonzini , "Ingo Molnar" , Borislav Petkov , "H. Peter Anvin" , Andrey Ryabinin , "Alexander Potapenko" , Thomas Gleixner , "Dmitry Vyukov" Date: Tue, 26 Apr 2016 17:58:45 -0500 Message-ID: <20160426225845.13567.94417.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20160426225553.13567.19459.stgit@tlendack-t1.amdoffice.net> References: <20160426225553.13567.19459.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: SN1PR15CA0027.namprd15.prod.outlook.com (10.163.200.37) To DM3PR1201MB1120.namprd12.prod.outlook.com (10.164.198.20) X-MS-Office365-Filtering-Correlation-Id: 36343060-aeaa-4f88-6432-08d36e2654b9 X-Microsoft-Exchange-Diagnostics: 1;DM3PR1201MB1120;2:0KcMIg46ab+PXcdjBpKcwFDVNnvz+Bik4SGh/rA4YJYKMQFtZUa9sDJ0rjDshQ+cZF2rjDYTpW4xNyW9n4fiutX4NgiQvDUel3YPYrOiPqYPD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4zs1b2ScKlpPgtRd0BHzSqQFNCxSs9JOA8Okkcb4ktGqmjrj1oQrimKIfwSupVcz76KquTA032LR/vDNZF;4:qmXQhfbu7Ie9IjW0Rlb2dbSH7xdVJc6rgw35eI6PaZD2X03g6NYg4cIoV3gkO+q2mLDsWUSErd/0pmBRuRI8T7MHWTP5b1UfA+/DMezxk+dXpQn1Znlvj9Vq55djmJzpvx7aOfNU70w7FWgghodBn+U1S8OUSnlAWCq9InoyZu3OEVtfuMiwAooBwZedx7RUNWCblUwGHc+9UYdJOwTSjGZoY8XPE79CAzz2VYhWjQZKGKHPpmJPOqCoK75WmAu+M6W/xBdpFfGaHoEPHfiu+kNPhPKcGFajJmcF59JP9/8x9eMttymbXAU3orYhk1pLUS6HW4slkPx5f+09g3xW6CxNd9CSv4u4mssDRNr22RM9N/6je+NakG9htTKMCCofA6cLdJp0/1++CuwV8LojtKrgFiAg69tERoDthi84L0Q= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521072)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:DM3PR1201MB1120;BCL:0;PCL:0;RULEID:;SRVR:DM3PR1201MB1120; X-Forefront-PRVS: 0924C6A0D5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(42186005)(97746001)(81166005)(5008740100001)(5004730100002)(66066001)(47776003)(2201001)(2950100001)(92566002)(103116003)(53416004)(19580395003)(77096005)(19580405001)(50466002)(86362001)(5001770100001)(4326007)(4001350100001)(23676002)(33646002)(230700001)(9686002)(76176999)(50986999)(189998001)(2906002)(1096002)(1076002)(6116002)(586003)(54356999)(229853001)(71626007)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR1201MB1120;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTN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pnZe6B0QyOmqcrK1K2K8p035aMG9HWWpw2xZa4GtRI=;20:74++R0UALjm6ii8fLKYJswFdx49om/8Kb68VltZpgQGSt7JcNipKuVr3GOPJXneWmIFCB01gjT/SQtkRGOy0ejXNalwO3QpAFeEfHaGyFbuj+E8AbrmcV0d3vEa/N33zx+qhjNdThBvleImFgdXgIFptctuJEFvKNzvcbKcmXURaQEXOWu2n3OCOh9AqbgbXZpjz7DyXg2+CqY/BhyCjD25eq+/MqsMZoEMjFp18lm3TuyFEsPmVHuIRYp3Xe/Nr X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2016 22:58:48.8307 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR1201MB1120 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1113 Lines: 38 Since the VGA memory needs to be accessed unencrypted be sure that the memory encryption mask is not set for the VGA range being mapped. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/vga.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/include/asm/vga.h b/arch/x86/include/asm/vga.h index c4b9dc2..55fe164 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 un-encrypted memory. */ +#ifdef CONFIG_AMD_MEM_ENCRYPT +#define VGA_MAP_MEM(x, s) \ +({ \ + unsigned long start = (unsigned long)phys_to_virt(x); \ + sme_set_mem_dec((void *)start, s); \ + 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))