From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.53]) by mx.groups.io with SMTP id smtpd.web11.607.1604685210782339419 for ; Fri, 06 Nov 2020 09:53:31 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=XsrB/1is; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.237.53, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gK2U3suYASFGCpgqyFzQj33vJPgirZFBxikkFnBKs3n83yIjzgtUMTW6omFQjGxJ8zOLeZXo8+yhCIMSxexUQpx1OpmZezH5CVzkuLPzM2E2ktkwWJm/mEGUSC/vUN7CSkq/+QRJa8nWenvjHtlI0oIK05TjGhQzFTyvajuNGPmIJwK3t8GCLDO9JzNKTOqHqOLlaQ6H1g+hpBPZ2NM5AnFK67cq3tG2N3bi2voxouG9ofnUiWsCO6/9KIEfqPWzqD06IDl65cF7QSWbCjv5wN6+MbhB8wRxVYCIY/QFixw05By/0FZSYITWWe5dfxK8KTWLCYKiGREqDw4m5lSQvA== 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=Y+XC8LUmM0+lBOI7YY+hJxl8UzrgNyKhgqyZcbgIXzU=; b=Gyy5ZNnInIpt7Z5rrVR2WrohVyN0F3EYenWS2RzwcrbPxZlP4jNPHOc09krv3VLTI93fQJZp+SgtXFKYLJW6AgYu7IEco8RBLUYtv1xcKV4y7u4W1irlqMv9KTUkeroE4GPHR17mGPfxNXDrcfD7tJfAKDJXuQlouTyNymYBCbHr/2esJ10A9QuuGRkqHsi74Q4Z+EA2Ax1xX3F9cMeeG1n5f/1iYd3QFieP2DuYuhRToCZyKk9n3UJlBwiTHztLZmDnWXTl3fYS3OxaKPsADd95UVvPnf1HNfvbw/KmR4vA1XzyJ6c3UXgNty1hS2xez1QnQw3sl1F77g7z/7lgkw== 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=Y+XC8LUmM0+lBOI7YY+hJxl8UzrgNyKhgqyZcbgIXzU=; b=XsrB/1isDFsFeXP45vFtL+h7f5tQ3sjYSyZaa1AgXcF/bCl6unrYb5sSRyboWGnlqU69bf5Wi8gzBxKmcPE18Va3oyH3HjJye5FK+hg/AjhBydZAvrCL6cSF1ETxUeMRWrnYLoR6+OtDcKUR26qBwulC8cAcXPTC78ssfgruRho= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM6PR12MB4385.namprd12.prod.outlook.com (2603:10b6:5:2a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.21; Fri, 6 Nov 2020 17:53:29 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::e442:c052:8a2c:5fba]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::e442:c052:8a2c:5fba%6]) with mapi id 15.20.3499.032; Fri, 6 Nov 2020 17:53:29 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Ard Biesheuvel , Eric Dong , Laszlo Ersek , Liming Gao , Jordan Justen , Michael D Kinney , Rahul Kumar , Zhiguang Liu , Ray Ni Subject: [PATCH v4 00/11] SEV-ES guest support fixes and cleanup Date: Fri, 6 Nov 2020 11:53:02 -0600 Message-ID: X-Mailer: git-send-email 2.28.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM6PR02CA0064.namprd02.prod.outlook.com (2603:10b6:5:177::41) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM6PR02CA0064.namprd02.prod.outlook.com (2603:10b6:5:177::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.21 via Frontend Transport; Fri, 6 Nov 2020 17:53:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c4e8d8b7-f0df-449f-d57a-08d8827cde58 X-MS-TrafficTypeDiagnostic: DM6PR12MB4385: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:374; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vw2zAP4iitgPJUvwIKFrmL668LFSBMCYHB4GfZwty1Rd59S1h9Tl73THThP9uxgEiz5KrQOSbRi9Gu0N/lRJhIfaTw4hFmEiZi0+BZw5Iy/c7De9QDGhHRQ9eN2QAq4dqVVmg8TS1MCxLXGB26Zp1WTARoRBNtA/iNvhuqjKyGo427uVN+VAOaaIuVdYTYZp1NOQVm1fZ1mPqcU9KSYm86/1ykTb4k0xcIj15EvlS/uZvA6oJe8g8J1vXPOrJlVBE6UcBlSckNXpjH/H4+r3QYcPwg5nRTD1cNZ8KLtDsTYmEjdGRMSNSrCWMud39L6gkZ9BKWXPJetCmc4HPnEzG1JkpgjxKh9LNIcJ7G9Dup5Igj3ECi0YZK09yzNAozG5+CywwBQAsAeou/Ld3M+CNw== 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)(366004)(376002)(136003)(346002)(396003)(39860400002)(316002)(966005)(86362001)(83380400001)(52116002)(7696005)(66946007)(5660300002)(6916009)(6666004)(8936002)(36756003)(7416002)(19627235002)(8676002)(478600001)(66476007)(16526019)(26005)(2906002)(186003)(66556008)(6486002)(4326008)(54906003)(956004)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ew9vm8zqJSmIXgF4jYYHXAlCtoNjbo3+DyLDeGkbQDANtaT8DzS2QiEzQZUhQltLXgb86sVUlHJjsU6MW9G5X3OugFvIvkHa8AkidJRBvNqzzLm9QRlRZln5sOgP9HOkEz5s+T539sCoBIjy1v/0iF/3eUJ6qTbEH6grzbcfiiLO2ZCKvPuqukr2qjQftRlF7yQzQ5lnO6jW4sX6aKbmV5jWhtZPdo5XsqkWwrLgK1c7zfJJEBpfQ/IyZ3wzG7WK7g353L8ZJ9sU8XXTxG+uTMBrfhQ+h18/sE8Vd8iknOwbOFCU/uP52rCPjeKtMTPWGNtlT6sFphDOdeM0hBS/0SwKb5f0ky8k6b0paJZMkF6ej3duKvX0HKI0+atgNEzTM3FWn3jfPrMDuHAY2c2W5S/0j6aYsw7Fg7qGwYVDuZEWx+IQvoXRuRwQOtUQa8tii8CQQN6sZ968B0Mdg+uBagJAtYrGmEdVxZMSqvoUfS8qCAv57YzU0n1jednUmdd8FrQ+WPzmnu5JKAmD4qp3FIJ83/UqUY/aIn6qo3HEPo0iKkeZZvwIEDfuQ0PEJa8dyQiBN2LtzWukOkUeUgrzxwZDZ9Kl66ol47fNzLgrcQdm8sfeqInOu7pKvHLtSJd5r8Dm+Pf9xpMEWMIoACi3Pg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4e8d8b7-f0df-449f-d57a-08d8827cde58 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2020 17:53:29.2383 (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: RiTfT5aOGp/3m2Yg42RT7KspgOXAtlBz2oWtra/mOEImJbLqnzEzqrI3nxjcxvQ2jHjFbmO/I8qzDczcsSYFiw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4385 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky This patch series provides some fixes, updates and cleanup to the SEV-ES guest support: - Update the calculation of the qword offset of fields within the GHCB by removing the hardcoding of the offsets and using the OFFSET_OF () and sizeof () functions to calculate the values. Remove unused values and add values that will be used in later patches. - Set the SwExitCode, SwExitInfo1, SwExitInfo2 and SwScratch valid bits in the GHCB ValidBitmap area when these fields are for a VMGEXIT. This is done by adding two new interfaces to the VmgExitLib library to set and test the bits of the GHCB ValidBitmap. This reduces code duplication and keeps access to the ValidBitmap field within the VmgExitLib library. - Update the Qemu flash drive services support to add SEV-ES support for erasing blocks. - Disable interrupts when using the GHCB. - Use the processor number for setting the AP stack pointer instead of the APIC ID by calling GetProcessorNumber(). BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3008 --- These patches are based on commit: dc0dae2d18d4 ("BaseTools: Fix BaseTools nmake cleanall hang issue") Cc: Ard Biesheuvel Cc: Eric Dong Cc: Laszlo Ersek Cc: Liming Gao Cc: Jordan Justen Cc: Michael D Kinney Cc: Rahul Kumar Cc: Zhiguang Liu Cc: Ray Ni Cc: Tom Lendacky Cc: Brijesh Singh Changes since v3: - Replace the use of "sizeof (UINT64)" in the GHCB_REGISTER enum with a macro that uses "sizeof (UINT64)" to avoid ECC errors during CI (suggested by Laszlo). Changes since v2: - Don't rename the GHCB_REGISTER enum type. Changes since v1: - For the GHCB savearea changes, create a new reserved area name instead of "renumbering" the reserved areas. - Rework the ValidBitmap set/test support to be part of the VmgExitLib library. Create two new interfaces for setting and testing bits in the GHCB ValidBitmap field and adjust all existing code and the new code in this series to use these interfaces for the ValidBitmap updates/checks. - Don't disable interrupts for just the Qemu flash services support, but rather, cover all users of the GHCB by disabling interrupts in VmgInit() and restoring them in VmgDone(). This requires changes to those interaces. Tom Lendacky (11): MdePkg: Clean up GHCB field offsets and save area UefiCpuPkg/VmgExitLib: Add interfaces to set/read GHCB ValidBitmap bits OvmfPkg/VmgExitLib: Implement new VmgExitLib interfaces OvmfPkg/VmgExitLib: Set the SW exit fields when performing VMGEXIT OvmfPkg/VmgExitLib: Set the SwScratch valid bit for IOIO events OvmfPkg/VmgExitLib: Set the SwScratch valid bit for MMIO events UefiCpuPkg/MpInitLib: Set the SW exit fields when performing VMGEXIT OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Set the SwScratch valid bit OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Fix erase blocks for SEV-ES UefiCpuPkg, OvmfPkg: Disable interrupts when using the GHCB UefiCpuPkg/MpInitLib: For SEV-ES guest, set stack based on processor number MdePkg/Include/Register/Amd/Ghcb.h | 43 +++---- UefiCpuPkg/Include/Library/VmgExitLib.h | 51 +++++++- OvmfPkg/Library/VmgExitLib/VmgExitLib.c | 84 ++++++++++++- OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 129 ++++++--------= ------ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 4 +- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashDxe.c | 6 +- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 5 +- UefiCpuPkg/Library/MpInitLib/MpLib.c | 14 ++- UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c | 60 +++++++-- UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 6 + 10 files changed, 261 insertions(+), 141 deletions(-) --=20 2.28.0