From patchwork Mon Aug 22 23:24:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9294747 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 E3572607D0 for ; Mon, 22 Aug 2016 23:49:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEEB9281DB for ; Mon, 22 Aug 2016 23:49:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C266028459; Mon, 22 Aug 2016 23:49:57 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 300FB281DB for ; Mon, 22 Aug 2016 23:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753301AbcHVXty (ORCPT ); Mon, 22 Aug 2016 19:49:54 -0400 Received: from mail-by2nam03on0054.outbound.protection.outlook.com ([104.47.42.54]:58815 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754177AbcHVXtv (ORCPT ); Mon, 22 Aug 2016 19:49:51 -0400 X-Greylist: delayed 526 seconds by postgrey-1.27 at vger.kernel.org; Mon, 22 Aug 2016 19:49:51 EDT 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=pM5IjsSx8cxQKUb0SAqTZSWG5Cc4foHyzC7QU1Z4Vq0=; b=eVxnq/evHfjbk3W+lNuIn6wQqVmATfcdSty+X0dLQ/Ve3ybKb/Q+WT2zctqft+6w/3TPbSoI5sDHadi42GlbLeqywd68sjxGNM/TIjvx9J64PukqYTv0aubIUHmidPbstW+dKq0/JPOuFSaqNJqT87jiXqfmnV6KLCYGnFWKURc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by BY2PR12MB0663.namprd12.prod.outlook.com (10.163.113.152) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Mon, 22 Aug 2016 23:24:23 +0000 Subject: [RFC PATCH v1 04/28] x86: Secure Encrypted Virtualization (SEV) support From: Brijesh Singh To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Mon, 22 Aug 2016 19:24:19 -0400 Message-ID: <147190825949.9523.11406635622434950066.stgit@brijesh-build-machine> In-Reply-To: <147190820782.9523.4967724730957229273.stgit@brijesh-build-machine> References: <147190820782.9523.4967724730957229273.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY1PR13CA0032.namprd13.prod.outlook.com (10.162.30.170) To BY2PR12MB0663.namprd12.prod.outlook.com (10.163.113.152) X-MS-Office365-Filtering-Correlation-Id: 563c970e-e05c-46f9-bb37-08d3cae3754b X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0663; 2:pJ6+vrJCEdjxcy6FY5Ngo2VzjAoJJpNKZTWoeJsezIIiKt8hOTSUOHQqXOCDJCjpFUFVRoYblppHPsMSytC9+ske9Soo0E8wwN163l2YoZauErsHDFy8aVUXbMlOlquUTfqRw8RhuezHUz3H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tQDufNdXJQqw5gcEXN4M2o5jNx4Ox8lQN/fErOg+T2OmO4G2+XCZBf/kuUX/WUQsi6rVb9W/X+O7Uddr7ZTuX4BzN/kSPY0iQ0OWJ0ddtwvWvY9oLdATgkpk4orlFpQAGulbfNsNAvlwarlB3NlCMSMuTNdfu+/KTmVP7Wm9EjkKMfX0H/U7kW83R5GPtrpEykBdUZqlKe1BkqI4uczpPJ29yMPL8I0wSjoazPWYd8rg4uvQBqZwPgfWKHxzTeF9PsdOju3SPfGYpNh81EnAfFAnmrde1VTbjKnP+Kagf3qQWi6PYBH9sWBI/LT48/KP32NcaTddwS4rsm0BqdtP4TBAWxwZCM8Hc+Tcv6DXZdOYyqGUvN1Fx1LGfk2eG9kPO9MbI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BY2PR12MB0663; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0663; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0663; 4:68I6lu+ZjnkY0vnJBFHooamt5e0gf5vDjHqsQOii7YsD+cwc4+AwXIcaqw3UVF1quJNvdhmIhR3/D5h/KiBA1Ga0IZOlvjDHEvpAStpVOk2SQ+hxXEyOU9G+YSGxjWJtwq/tbqTtxQw/A4ceC3w+2H5o5BmFuRqnQmZJ+yTaEPXbUa/EXfRJPR4oc/PFlm2u2F+4HWoGGzCqxUQXN5FayqiC1ndYj1lKNOrHFoOvo79DWpZuU+a7qld13SvvvQu1l9daPrDEtiFG3loeqX8MPbwgamcfxWlTO0wPV50uGhzG/fx+qSIkNFxiM7UFrMeTQWiYOJD5Hct51synraJgImZUdmuvkIneAfdDRHxu+qqnVHCgX2dCWKs32ikGi0zs+TtrUvxtcXvGBqLcAK5PCVHxABIKuECeAbDtebYReGk63fQ0MyJ7jW43QTSynDSo X-Forefront-PRVS: 00429279BA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(189002)(199003)(33646002)(7416002)(92566002)(50466002)(77096005)(42186005)(7406005)(230700001)(575784001)(19580395003)(101416001)(83506001)(19580405001)(2950100001)(9686002)(76176999)(54356999)(81156014)(4001350100001)(586003)(106356001)(50986999)(86362001)(47776003)(81166006)(305945005)(105586002)(97736004)(5001770100001)(7846002)(229853001)(23676002)(189998001)(8676002)(2906002)(7736002)(3846002)(2201001)(6116002)(33716001)(66066001)(103116003)(107886002)(68736007)(5660300001)(921003)(217873001)(83996005)(2101003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0663; H:[127.0.1.1]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwNjYzOzIzOkNkb3pQR055RlhRYTlDMlpyYWZuUUhQQm5Y?= =?utf-8?B?aW9hdXFqTk9wNUdyNzZCMUtWOTE1VGYraXFXMTlUN0x0TVN4akN3a1VIcndD?= =?utf-8?B?cGJWNlN1dnoyTEQ0K3BXMG9ldVdNMzVuTzQzUk5TcmdqaGMzZStmcFhDdVdv?= =?utf-8?B?ME9ORlZnbDU0RkltbXFmWkU3WDRSTWZUeUNuUVVjVkMvRDNRY01xRjFKenF4?= =?utf-8?B?THc5YVB3TlhDdTFBbElrdUo1VERWWjZraVNzMjl1dHYxYk9aak1yQmhHdEkz?= =?utf-8?B?SUNhV1FBb1VvNURwdzRKRHJ6WmcvOEJUWCs4aENhNGdOMjBKVzhaeHVSWHZj?= =?utf-8?B?NCtra2E1anIzdHo5OTZ6andmQ2RRNEw0MU03MzQyeXdyNWZzODFMV2NSczc1?= =?utf-8?B?NWVTTDBRdWtQUW43eEhTM2dyZ0draG9kdTJILzd6RTNXTUpZZnZUUE1yaVRy?= =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zITQuaSUGm8ed5YdFDIrFSeIJaZjbHslJ4d51VIIZm8cxyLkyUZPBkgHL8fAMF1XHn9IOm/ONCg4HUVWQ==; 24:7Xs0fdOxz/KlNu+ZK3zD12+n8CvyWxglWzYXin+zv9+hQVBquxhPKSPeKnxlk5ZH5cKbhk5jHnaD5XMGZj4QIwber4I7F874XR/aS0OFEHA=; 7:nQBXy5vC1GkQ4tcNj6riZ3lCSJ9wg6MSpY3s/edBtwYeZlpSGKMUdpT2xgqqTIhBVph8EdA/l57+mhx3kdEwiYtLetRxL9ASwjfnDwmxqrcMtqBkG2luHvCRc6b7wMVwRUbg3FTeaKaSPuZADWuc0Pg5VdBeNVnINjslZUR4a58FWpE3TyQgz+PwALpAYQcCuJHjpb56XJIsijQx2I/OzREN6JU3S4HkLU7oXanO1DGVOia7Saq7r5iaz5fDM3Tv SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0663; 20:fss5K4WuDXlv9ePRq2DEajZGLTXuDeBfZ2A3XIHP/lD+mwnG9yDaeDqMW9+Q5v3JrQl9SATwYdQmfyocHUlRi3cLxnfn0kWUFNO9YR2wdE8cYJdZJpLMzIRMHaaZ5Jw18M0BDThTYgCvWGlkbVZBpuco35uMcuRjaHAOwiesPMKRmat95xLVjVktmc3zz7WzAfNM7eLzEBtguc5LJMj4rEgs2royuq6bcZolB5Ru4Ch0xT9ugN9fde2N3OAOMpX/; 23:szVsm7juV29ny4dqvw4558hwExJlVzEDlaJRXW/PyCYF0ci+uPBS9KVSLMzuw9rKDEUwFsVMsTfqQlStZbnY0u7SFBPMQxlk5st86EJHZC8kqKbkqFLc5LqEJKT6lsfA3NDPK/pDsSJEeDpXTBE1/B65U5FbqhMAX5hgv3ESnQNrv5M9mFAIYXGWGwfCTtpD X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2016 23:24:23.7034 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0663 X-OriginatorOrg: amd.com Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tom Lendacky Provide support for Secure Encyrpted Virtualization (SEV). This initial support defines the SEV active flag in order for the kernel to determine if it is running with SEV active or not. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/mem_encrypt.h | 3 +++ arch/x86/kernel/mem_encrypt.S | 8 ++++++++ arch/x86/kernel/x8664_ksyms_64.c | 1 + 3 files changed, 12 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h index e395729..9c592d1 100644 --- a/arch/x86/include/asm/mem_encrypt.h +++ b/arch/x86/include/asm/mem_encrypt.h @@ -20,6 +20,7 @@ #ifdef CONFIG_AMD_MEM_ENCRYPT extern unsigned long sme_me_mask; +extern unsigned int sev_active; u8 sme_get_me_loss(void); @@ -50,6 +51,8 @@ void swiotlb_set_mem_dec(void *vaddr, unsigned long size); #define sme_me_mask 0UL +#define sev_active 0 + static inline u8 sme_get_me_loss(void) { return 0; diff --git a/arch/x86/kernel/mem_encrypt.S b/arch/x86/kernel/mem_encrypt.S index bf9f6a9..6a8cd18 100644 --- a/arch/x86/kernel/mem_encrypt.S +++ b/arch/x86/kernel/mem_encrypt.S @@ -96,6 +96,10 @@ ENDPROC(sme_enable) ENTRY(sme_encrypt_kernel) #ifdef CONFIG_AMD_MEM_ENCRYPT + /* If SEV is active then the kernel is already encrypted */ + cmpl $0, sev_active(%rip) + jnz .Lencrypt_exit + /* If SME is not active then no need to encrypt the kernel */ cmpq $0, sme_me_mask(%rip) jz .Lencrypt_exit @@ -334,6 +338,10 @@ sme_me_loss: .byte 0x00 .align 8 +ENTRY(sev_active) + .word 0x00000000 + .align 8 + mem_encrypt_enable_option: .asciz "mem_encrypt=on" .align 8 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c index 651c4c8..14bfc0b 100644 --- a/arch/x86/kernel/x8664_ksyms_64.c +++ b/arch/x86/kernel/x8664_ksyms_64.c @@ -88,4 +88,5 @@ EXPORT_SYMBOL(___preempt_schedule_notrace); #ifdef CONFIG_AMD_MEM_ENCRYPT EXPORT_SYMBOL_GPL(sme_me_mask); EXPORT_SYMBOL_GPL(sme_get_me_loss); +EXPORT_SYMBOL_GPL(sev_active); #endif