From patchwork Fri Oct 20 14:30:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10020423 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 3A8D160211 for ; Fri, 20 Oct 2017 14:39:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E19A28E6C for ; Fri, 20 Oct 2017 14:39:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 125F528E74; Fri, 20 Oct 2017 14:39:13 +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 3DEC428E87 for ; Fri, 20 Oct 2017 14:39:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752531AbdJTObT (ORCPT ); Fri, 20 Oct 2017 10:31:19 -0400 Received: from mail-dm3nam03on0088.outbound.protection.outlook.com ([104.47.41.88]:47104 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751978AbdJTObR (ORCPT ); Fri, 20 Oct 2017 10:31:17 -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=tQrkXMvNk+U6bd6bWaTynApdGrKU9ncAmGgpJtkhC30=; b=FYqaG3MzcRhsAAeNZ/IFTlQsi7gX2fDeWZ8+ohzJ7aTF+DpbdkXhn5aYG2J8xnGeF9drLUkt/UsO3BXfF665Seq6I6Z0vJPmX2wARj+OjmCe//84X+rK144OqdW3RejCi/JZdBOEFjLvvsaf6dytQkGXmaPGdM90GEw8yeIu+w8= Received: from ubuntu-010236106000.amd.com (165.204.78.1) by SN1PR12MB0160.namprd12.prod.outlook.com (10.162.3.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Fri, 20 Oct 2017 14:31:13 +0000 From: Brijesh Singh To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Borislav Petkov , Brijesh Singh , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Jonathan Corbet , Borislav Petkov , Tom Lendacky Subject: [Part1 PATCH v7 01/17] Documentation/x86: Add AMD Secure Encrypted Virtualization (SEV) description Date: Fri, 20 Oct 2017 09:30:43 -0500 Message-Id: <20171020143059.3291-2-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171020143059.3291-1-brijesh.singh@amd.com> References: <20171020143059.3291-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR14CA0029.namprd14.prod.outlook.com (10.171.172.143) To SN1PR12MB0160.namprd12.prod.outlook.com (10.162.3.147) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80a1ea49-c991-4ed8-8ab3-08d517c737da X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603229); SRVR:SN1PR12MB0160; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0160; 3:xdndPkHlGoUspNbdaRo7EunCy1rMqt8+PHEeKoNRw+q9aidC3GV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6+Xwm3ZjQP4Q/DsDyhCaf1a5C3aAdYTghh0fdh9VzpGVtnc0hOuJvXrC2MdJJWVCSBvbjMMg3TTU8iC2z3vhJqbcj5Yk6l+kVsBV7DYxxB+NZ7cs96nKNSUFX1U+1Byt8LNBoRXMRzlymGsQtvjAM1LkmonllkK9R/1kVohlBEhdwin5+CYVeMy5pmbvbrN6TP8wnkZDJ4V8TpiLXCArZxByRG6kCsX8EL+vwQDY2PkdvpFVF6CvspgpO0rkd1GDpjsDCvEmhJJeBFltgSqbpT0E4oRDBhqmsIoODp9UkfvSPc; 4:qLKM53TzLoACSSOG6yUHqcfM5bhmRDUe0IXcCcjVOzGkxvGWjin194bkohL7kRotD7CW/dlXed44vu+KywvaFE/WeKsBqlWysV+S9qFbsvNIw70cN1L9fz/518n9t9IwRQzIBl/Z+TlFW8aiTAn5aivQSlrsMNKMo2o3iv2p4enTffFaBKsNmOqOmAs9epRC5NsPw5N9NYAwpiOx2k6H+nFgWNXv0F6x2i7VzOFAvxNXiFoctBCGal3q+CiDeuXOzSSm2eDvhPgEZQfs+cfA6hxKjgL1hBn2c1cFGgmsRwpyNgnsciyEMU1LAbUd3B3dUKaz5H3fzOXyYNekZGT76ZHDuCFImTTrsAKHr/reT9I= X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(767451399110)(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(3231020)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0160; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0160; X-Forefront-PRVS: 0466CA5A45 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(376002)(346002)(199003)(189002)(54906003)(1076002)(6666003)(189998001)(68736007)(8676002)(305945005)(50226002)(7736002)(101416001)(76176999)(8936002)(97736004)(25786009)(81166006)(81156014)(16526018)(6486002)(478600001)(48376002)(2906002)(50466002)(4326008)(47776003)(66066001)(5660300001)(2950100002)(53936002)(106356001)(3846002)(50986999)(16586007)(53416004)(6116002)(5003940100001)(36756003)(33646002)(86362001)(105586002)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0160; H:ubuntu-010236106000.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0160; 23:IDREKEm58fLEmjcaXWCnVSKL+BKOL2ot5rvIsmk1/?= =?us-ascii?Q?pdWswJL/iipSfWcfIsugLgtVllTEX6dvUrUc8jaJZgQ8bD7yQbsELvZzrsrt?= =?us-ascii?Q?sRQzA9vFswFZfWohPZTf95AP3AIoV1Y0sg24nuitEskBsoEMIBEKPR513lkk?= =?us-ascii?Q?7Ps2gn+ob+vJyj0+G1AEjGnc6ro8CsP5vouzQc/ssB1xLOdLFTc78pFG/Ljx?= =?us-ascii?Q?bOV+w2EuV4R+HsxbxWdWeY6I8UfpN5QrTWK/HnT+vXpJ876Quvap+nRhEky+?= =?us-ascii?Q?ahfkEUY2MgI5vTA9lZu6WY5gB3U4lUHZ5+pp75WdxJVHrbxwfeV4vl1x9/Tp?= =?us-ascii?Q?f9cBOFJiPgqydz7M4O/Dh/NgWLB8flWWiMwK7p+ZT8DO7Li3P++ffluZGxY2?= =?us-ascii?Q?VPsN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UAUPTAO1eDkhawkt9k8GFG+E8R6erLusxOHwuth0efUHKbc2vFj/apCdyJGwFVvbGt8nPtxgPmHlgQ0/9I6B7uztcDoM15s7UhezIGdj2RvYnqKM3MquOuLNdz50nKwt5QlHllDtUgtzp5EhIj4k06ie42BrFKrGA+OHsHrxg==; 5:jlG6LJ9R1S/VRK9giw6PeeFFOTcvi5nT8mj07ywd3o9anI+vCl7b1pEJdFWjZ/skQdMdpuvxS66Cj0Rbe8L6DmXoyafIeDpgu9SjaJYEdD1AkLNbRgjX8rq0DEDIxq1JyXKPEQKpTCTKubk4YUvs2w==; 24:nK8Emv+Voi8HNVs/F9RS3wpWVNLcohg+6rigBamZ4v0Im9MgtS19r3I9FjxwKK7I6feNkRi0Ow2VLEtNdLEYrEaqZD2XGEAJJxDwFsDgF5M=; 7:VuzXDuxqPYp/E5ByuUwmowsY3vDtgqW0TuzsKybr2QHRdK1vH4DaepHwrdwHiRHYycOLBkv/f+3898k6ovOUcJkyfCRAFFQSCjWGPwcPFFMPVmOBqwT4xsPEMraNUF4SkSI9bp+U+3K3TrI7vsuB7cMyw4SuWtso4WvjAQd8K+IbodSLBrTWo5pKrLYJkmPI+lrVkv23C4z1KXHGNIdHuP1wibygzBXEtk6ru+ZdMQE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0160; 20:+lMYMvVbv+wU7+vvoO7tn4FhUFMFkP2/BDQbbBunzReCoC+foYol5G5h9+nR1o5xxfaeNWzSlqKf5kJ9d54h60rP6d39EOTt73s5nlOBO+nkiKm+OS3ryTAVMkdYmccrsXf4tO/YCJdwm9ecLvJbD8rwLi95JnyKdr8DXsKQZCZpFw+aSp1cwd5p5JCtd6TstHSFSZIdNIOvffgG483puoRbSrZotUFmkqf4unSpU9HmREMIJexWRGgIKCyPXa4T X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2017 14:31:13.3918 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80a1ea49-c991-4ed8-8ab3-08d517c737da X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0160 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update the AMD memory encryption document describing the Secure Encrypted Virtualization (SEV) feature. Signed-off-by: Brijesh Singh Reviewed-by: Borislav Petkov Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Jonathan Corbet Cc: Borislav Petkov Cc: Tom Lendacky --- Documentation/x86/amd-memory-encryption.txt | 30 +++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/Documentation/x86/amd-memory-encryption.txt b/Documentation/x86/amd-memory-encryption.txt index f512ab718541..afc41f544dab 100644 --- a/Documentation/x86/amd-memory-encryption.txt +++ b/Documentation/x86/amd-memory-encryption.txt @@ -1,4 +1,5 @@ -Secure Memory Encryption (SME) is a feature found on AMD processors. +Secure Memory Encryption (SME) and Secure Encrypted Virtualization (SEV) are +features found on AMD processors. SME provides the ability to mark individual pages of memory as encrypted using the standard x86 page tables. A page that is marked encrypted will be @@ -6,24 +7,38 @@ automatically decrypted when read from DRAM and encrypted when written to DRAM. SME can therefore be used to protect the contents of DRAM from physical attacks on the system. +SEV enables running encrypted virtual machines (VMs) in which the code and data +of the guest VM are secured so that a decrypted version is available only +within the VM itself. SEV guest VMs have the concept of private and shared +memory. Private memory is encrypted with the guest-specific key, while shared +memory may be encrypted with hypervisor key. When SME is enabled, the hypervisor +key is the same key which is used in SME. + A page is encrypted when a page table entry has the encryption bit set (see below on how to determine its position). The encryption bit can also be specified in the cr3 register, allowing the PGD table to be encrypted. Each successive level of page tables can also be encrypted by setting the encryption bit in the page table entry that points to the next table. This allows the full page table hierarchy to be encrypted. Note, this means that just because the -encryption bit is set in cr3, doesn't imply the full hierarchy is encyrpted. +encryption bit is set in cr3, doesn't imply the full hierarchy is encrypted. Each page table entry in the hierarchy needs to have the encryption bit set to achieve that. So, theoretically, you could have the encryption bit set in cr3 so that the PGD is encrypted, but not set the encryption bit in the PGD entry for a PUD which results in the PUD pointed to by that entry to not be encrypted. -Support for SME can be determined through the CPUID instruction. The CPUID -function 0x8000001f reports information related to SME: +When SEV is enabled, instruction pages and guest page tables are always treated +as private. All the DMA operations inside the guest must be performed on shared +memory. Since the memory encryption bit is controlled by the guest OS when it +is operating in 64-bit or 32-bit PAE mode, in all other modes the SEV hardware +forces the memory encryption bit to 1. + +Support for SME and SEV can be determined through the CPUID instruction. The +CPUID function 0x8000001f reports information related to SME: 0x8000001f[eax]: Bit[0] indicates support for SME + Bit[1] indicates support for SEV 0x8000001f[ebx]: Bits[5:0] pagetable bit number used to activate memory encryption @@ -39,6 +54,13 @@ determine if SME is enabled and/or to enable memory encryption: Bit[23] 0 = memory encryption features are disabled 1 = memory encryption features are enabled +If SEV is supported, MSR 0xc0010131 (MSR_AMD64_SEV) can be used to determine if +SEV is active: + + 0xc0010131: + Bit[0] 0 = memory encryption is not active + 1 = memory encryption is active + Linux relies on BIOS to set this bit if BIOS has determined that the reduction in the physical address space as a result of enabling memory encryption (see CPUID information above) will not conflict with the address space resource