From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,MSGID_FROM_MTA_HEADER,NICE_REPLY_A,RCVD_ILLEGAL_IP, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74218C433DF for ; Thu, 27 Aug 2020 15:54:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 374522087D for ; Thu, 27 Aug 2020 15:54:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="GROkznrg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 374522087D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBKE4-0002Uk-Dz for qemu-devel@archiver.kernel.org; Thu, 27 Aug 2020 11:54:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBKDI-0001qz-VG for qemu-devel@nongnu.org; Thu, 27 Aug 2020 11:53:21 -0400 Received: from mail-eopbgr690075.outbound.protection.outlook.com ([40.107.69.75]:44934 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBKDG-0002GU-Nb for qemu-devel@nongnu.org; Thu, 27 Aug 2020 11:53:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G4L7Dpz+wCu6jnDwkYgrxjhcL2XBdsn5v6BXnO78vJzB0UXYrRq9tASKEpMAwC72vzV5geF43SJ3TsyUdRar4kS3j2CErY2azVzFjghRPc7jhjyGq/CdbMG55mIXRyng1+X69uQHonfkAAKyf0sMfLyfdqjKNQ45bxMv9aiIFZrYuBFFGIuKvoKsJmYaxbjbJahChz7xlvrB92VES3+kWj+CAX9507DoJHB37Ejb2QaGbBRe4j0T1moCNDkzCUr2uyH3JGBD3Eqt8hIiBIuN0mCL52cyDL5a0Y1mGv4LExEH2Q0DniaK5+5ugGGlLKAw/iRZT2zMbHf0mYok+yvXSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TmX5UKo4Sh5d3rsLlCaDrFwq6J5U68wIG+U3QNRBYZU=; b=jWUZsoZKOwmBiL+tJnqxr5AK+dEKC1d5mgcDBPMZNoITnEYQd9xLC/BXo/ntC9F0f7nBmygmUdc0lXJkVPzTkXBguNaDFhiubJA704O0xUtdBIkbarRwnFAuJX5rmPiUL4IVE49LIs0LFXvpYpHReBa4KvJwbWBpb5C1Eel/s0wm/IndEH03gxyxjj/yS/Eqzyr/LOD6sGrKweuyEFWw1hV5TYh17jEWOGtRy4KsmrMaxdzul49exWPQ2pvJjkL869LmnSck82Hl6adwpPCidUOzv5VFEYMRw7tXhpvXqNOt5ZSgDW/X/PFRlB4MwIdRUp3dpFpJoU+P1BejzsKVwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TmX5UKo4Sh5d3rsLlCaDrFwq6J5U68wIG+U3QNRBYZU=; b=GROkznrgYWwfCDvgpuZRA3mrFC24mAWGejogCbv5GngpumrING2x9Ex/YxfSKrS2uH74SBW+c7Yod1O0XnLs3hSmW0Wpvuy3yA+iWSMF92TvBKY7tSOEQMcphWuDpwpHjuq68ZfgFsGbdNWZVcDJX+qV0fphldbm2MmpD1k02t4= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM6PR12MB3082.namprd12.prod.outlook.com (2603:10b6:5:11b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19; Thu, 27 Aug 2020 15:53:15 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::299a:8ed2:23fc:6346]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::299a:8ed2:23fc:6346%3]) with mapi id 15.20.3305.032; Thu, 27 Aug 2020 15:53:15 +0000 Subject: Re: [PATCH 0/4] SEV-ES guest support From: Tom Lendacky To: qemu-devel@nongnu.org, kvm@vger.kernel.org References: Message-ID: <4a529793-5448-458e-d9a8-31a8aa39f67c@amd.com> Date: Thu, 27 Aug 2020 10:53:13 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SN4PR0501CA0128.namprd05.prod.outlook.com (2603:10b6:803:42::45) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SN4PR0501CA0128.namprd05.prod.outlook.com (2603:10b6:803:42::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.10 via Frontend Transport; Thu, 27 Aug 2020 15:53:14 +0000 X-Originating-IP: [67.79.209.213] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d9366339-f740-49f6-0102-08d84aa14ef6 X-MS-TrafficTypeDiagnostic: DM6PR12MB3082: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4HR5gJNRBl8EEAckCBu1CGHGVE8JaY0nv4+EK2GYL9TNQpg9pcDdwZxFLuGvAgm9Rfu+4dV1sA/QbkljiOmM7s2Cx7RXDuGcsHqTyyD6EdWnzH1baWf6UZOOBHAQ9vCzcWcam3ZqW3KhkKdZOPS5SFQRyAdPhaM/IN+pYwGDHJuADKz4ZNwmNd9gptpe4zk5njSYmKrZQqeUeEMCknp7Db2+zFsqSA/shGd1iHrldc+NMv1h9b7SDA9fBXCbLEnUbf8iBOBTNX7ADRTmN7BrjtnNfu5zPXRqZb/uZepPUa+gduhQ/DKL7SuBydjZFE8KktdyeEhkRjswXDmc89oky0h2ijIdrTgYFzUYMkV/mhu9vLzrax1Fm5ub1Uq6b7YvqMfqs1XHupfGKMLGP/KsEccKbAOW0yCMS+mUyb6ZmXrEPCqrFhnj9a6x4uEKQVddwlKry4ceI+yWPbjG1WsghA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR12MB1355.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(39860400002)(136003)(396003)(366004)(2906002)(5660300002)(6486002)(54906003)(36756003)(966005)(478600001)(31686004)(53546011)(186003)(83380400001)(52116002)(26005)(4326008)(8936002)(2616005)(8676002)(956004)(66556008)(7416002)(316002)(86362001)(16576012)(66946007)(31696002)(66476007)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: OTfGjScodq1nlHOiQ2ESv0QY0fcl+sS1OIrSRIkdxLKrzm5N3Ec804v950hiMmP+4w2VThstEpESClqFj3YtsulzE293xbog6cECUe7Lkpuxf18JZX7vwlRvyWnHfTbFnq4z3J3YWtGWtRh+Bdh9DuHkqkYoA4D03/QJcPW5G1h3cATdSqKoEh6hF12cK2vfiSBwL5AtOEs5YXNH50fnJXA/RAInisKmlVT4zHEiPPuhkp44eU0u/xW3yuvxBc9GQn/Im5QDIc/IeMsu1EGE0B91BHcFREizJ6PpBAuxmtNz1BONQtn7/7dmNRL49xdo2Uf2X74HUPw0a+ybK2QOXtp26C84BDRF5Mm7BYlqpEGMiJhUpnGV0hcyefwpqK9pVsVvXcQOxrb7wHpo51hYij+hV5e57MPyvktTxlTmUe+7g5G4FwngwFBNA29BiRIk5W5SJ1EVQZ3ZATprcc6gz59N76dZWw/lur4yB1zM2c9wWZAASgtw/exMINfg9zqE6+5jMRB7eWxeOfqynF3RLaFKNZiSbI8xEyJlrPZXuLI7CwqBlyawh7GHqRVlv4V+oB4aMm6ip2MLl4RfDCxGfrgo1gzdLtYzHCw1ddGYLmHNHbu7PT32eWH57d0VWP98utfADxE2gEQMNbmZ4vrm9Q== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9366339-f740-49f6-0102-08d84aa14ef6 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2020 15:53:15.0850 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LWgjoN21iZTkyW5ibepV1eIGphzwFzq8Pb793CUYox6KQej2Gkda94Ukcm5iRb2DCtMLiXt/kMaq6QRk4uXEnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3082 Received-SPF: none client-ip=40.107.69.75; envelope-from=Thomas.Lendacky@amd.com; helo=NAM04-CO1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 11:53:16 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, NICE_REPLY_A=-1.782, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S . Tsirkin" , Marcelo Tosatti , "Dr. David Alan Gilbert" , Paolo Bonzini , Jiri Slaby , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 8/25/20 2:05 PM, Tom Lendacky wrote: > From: Tom Lendacky > > This patch series provides support for launching an SEV-ES guest. I've made the changes associated with the checkpatch script output. I'll wait a few more days for other feedback before submitting a v2. Sorry about the miss in regards to running checkpatch. Thanks, Tom > > Secure Encrypted Virtualization - Encrypted State (SEV-ES) expands on the > SEV support to protect the guest register state from the hypervisor. See > "AMD64 Architecture Programmer's Manual Volume 2: System Programming", > section "15.35 Encrypted State (SEV-ES)" [1]. > > In order to allow a hypervisor to perform functions on behalf of a guest, > there is architectural support for notifying a guest's operating system > when certain types of VMEXITs are about to occur. This allows the guest to > selectively share information with the hypervisor to satisfy the requested > function. The notification is performed using a new exception, the VMM > Communication exception (#VC). The information is shared through the > Guest-Hypervisor Communication Block (GHCB) using the VMGEXIT instruction. > The GHCB format and the protocol for using it is documented in "SEV-ES > Guest-Hypervisor Communication Block Standardization" [2]. > > The main areas of the Qemu code that are updated to support SEV-ES are > around the SEV guest launch process and AP booting in order to support > booting multiple vCPUs. > > There are no new command line switches required. Instead, the desire for > SEV-ES is presented using the SEV policy object. Bit 2 of the SEV policy > object indicates that SEV-ES is required. > > The SEV launch process is updated in two ways. The first is that a the > KVM_SEV_ES_INIT ioctl is used to initialize the guest instead of the > standard KVM_SEV_INIT ioctl. The second is that before the SEV launch > measurement is calculated, the LAUNCH_UPDATE_VMSA SEV API is invoked for > each vCPU that Qemu has created. Once the LAUNCH_UPDATE_VMSA API has been > invoked, no direct changes to the guest register state can be made. > > AP booting poses some interesting challenges. The INIT-SIPI-SIPI sequence > is typically used to boot the APs. However, the hypervisor is not allowed > to update the guest registers. For the APs, the reset vector must be known > in advance. An OVMF method to provide a known reset vector address exists > by providing an SEV information block, identified by UUID, near the end of > the firmware [3]. OVMF will program the jump to the actual reset vector in > this area of memory. Since the memory location is known in advance, an AP > can be created with the known reset vector address as its starting CS:IP. > The GHCB document [2] talks about how SMP booting under SEV-ES is > performed. > > [1] https://www.amd.com/system/files/TechDocs/24593.pdf > [2] https://developer.amd.com/wp-content/resources/56421.pdf > [3] 30937f2f98c4 ("OvmfPkg: Use the SEV-ES work area for the SEV-ES AP reset vector") > https://github.com/tianocore/edk2/commit/30937f2f98c42496f2f143fe8374ae7f7e684847 > > --- > > These patches are based on commit: > d0ed6a69d3 ("Update version for v5.1.0 release") > > (I tried basing on the latest Qemu commit, but I was having build issues > that level) > > A version of the tree can be found at: > https://github.com/AMDESE/qemu/tree/sev-es-v9 > > Tom Lendacky (4): > sev/i386: Add initial support for SEV-ES > sev/i386: Allow AP booting under SEV-ES > sev/i386: Don't allow a system reset under an SEV-ES guest > sev/i386: Enable an SEV-ES guest based on SEV policy > > accel/kvm/kvm-all.c | 68 ++++++++++++++++++++++++++++ > accel/stubs/kvm-stub.c | 5 +++ > hw/i386/pc_sysfw.c | 10 ++++- > include/sysemu/cpus.h | 2 + > include/sysemu/hw_accel.h | 4 ++ > include/sysemu/kvm.h | 18 ++++++++ > include/sysemu/sev.h | 2 + > softmmu/cpus.c | 5 +++ > softmmu/vl.c | 5 ++- > target/i386/cpu.c | 1 + > target/i386/kvm.c | 2 + > target/i386/sev-stub.c | 5 +++ > target/i386/sev.c | 95 ++++++++++++++++++++++++++++++++++++++- > target/i386/sev_i386.h | 1 + > 14 files changed, 219 insertions(+), 4 deletions(-) >