From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.46]) by mx.groups.io with SMTP id smtpd.web10.19626.1602864572049940538 for ; Fri, 16 Oct 2020 09:09:32 -0700 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=zALBCwrb; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.92.46, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h9GTu0WuanumQgQWk5alcz7l+/4oMaIGcnYdqvrpA5g6ZaaMFVkDkok3K4FUBZ1GRjiWgwbcaNZGY/E7dsileQl4ZCoAXdxEq5iaE0idyMCnZAYCVMkVcjwoqr06/Hg87qIf/pUVcQK1RO6V1lkX61xXjeH7QRsgKUyn0FVBMiYd6HQ1t6J+RSXZhLPzNk7KMnnhKsu64SnYyiWgO6fu/XvOVgxdlwYVQoDfUgpBo+Y84xtnbZVSVG3bFOv7FAbibJ/627YSGjUIVYIKjuqcxG4IZNyAUwYX3GQy5/mPGn5ZJ3SPlIAwPPG2azobZdFCb9Zczv/0d0lX7YtRdM426w== 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=Gd9LxdDF2deKuTh9BNl6/x+wXYI+w7ejTRKCRJ9UEH8=; b=OGvFDUKqmuRWZOcCWtMDPTncYJrns2EMCcTkPtTZSxpIYchNpuyddzjC7yYr3ypQYMs0x3zD6wihR+XhmtPa+csRNpBkyTrdtRhgLiLjWIf8KW6Pj6DozweUu5cLKwkwwVUG7VfclE9lAzrYBUkUgsr4EJzTd48afbc04yn5h0xIGKaFDtH1LZEs/R4uk3Y58TdztJJi4gHFt+f43m8NpN8S/HshKnsvXqv+466upsLDd8H4o4VZpqZpBVNMY1fKx6B4xU7dBJGz3Fai1fMr9KCnWUoDdsIpPse1ma883Ff8zjDG88rIqGs84jP7BHhU3qZvaHhx8szLQN2V6YvkPA== 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=Gd9LxdDF2deKuTh9BNl6/x+wXYI+w7ejTRKCRJ9UEH8=; b=zALBCwrbqNPjpIa4Y/L8aJAlpZVhdzGCmYprNrgP8qFU9E1Vp3NVpEXuVcWCkz/KqemcrX7IUTMwsA0sDfeJnqWixLsSgqCb35H8gZ4sBUAn933bdO0WbdSFWTXMcnyTLbNXRPcsl0mKmEjpc5J8xGGn3Twj28MSZQMiE4sTyGo= 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 DM6PR12MB4926.namprd12.prod.outlook.com (2603:10b6:5:1bb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 16 Oct 2020 16:09:30 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4d88:9239:2419:7348]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4d88:9239:2419:7348%2]) with mapi id 15.20.3455.030; Fri, 16 Oct 2020 16:09:30 +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 v2 00/11] SEV-ES guest support fixes and cleanup Date: Fri, 16 Oct 2020 11:09:06 -0500 Message-ID: X-Mailer: git-send-email 2.28.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR21CA0004.namprd21.prod.outlook.com (2603:10b6:3:ac::14) 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 DM5PR21CA0004.namprd21.prod.outlook.com (2603:10b6:3:ac::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.3 via Frontend Transport; Fri, 16 Oct 2020 16:09:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a6b6adc3-e0ab-458f-d857-08d871eddcd3 X-MS-TrafficTypeDiagnostic: DM6PR12MB4926: 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: NF6X4fnUVJFWOsL8/AZWi+yzQFZ0ZcXt2JATQWpK4jnIlYXeQwO3azIU6ADNJlhK++iR2S8ZB5T2PP5kY4FPIDdZKGQjsdv8w/easHI/yhjPacZmjrgeHE23AdYxH1BKVyQemTldM4jadzlEOzTA/52wrBb3NOFb+QGl3FRKC+Yl/+Q0PtUPcHw6B+bg8W5UdhW7k8AgF7FzeULP/uqmCz6/NboVzL7eGfG+JJhvjVkIo7iZeL7vnUi4BlQm/xDNot9xv1VA3s3uRtUxVyXMLvE8hFA2n/gAOBJKi9X5Cf0PMzMSmIaVZLSwzkI7fiH/53JMcCV8zH6VWsNVlv3vk7GM2pni8Gyd5RJiEUcL21lovBoP14E8EMlhZFki4OhnguQ8ixSWrZRv8cyh/LIUaX6/tPSIjQ8GCnESEnZWodZUse7dOiR11C+IQM9eTZKgzSLP9k8gW0BQx1WIpaUwXg== 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)(39860400002)(136003)(396003)(376002)(366004)(346002)(7696005)(52116002)(83380400001)(66556008)(66476007)(86362001)(66946007)(36756003)(4326008)(19627235002)(2906002)(316002)(6666004)(54906003)(6486002)(34490700002)(5660300002)(6916009)(26005)(7416002)(956004)(2616005)(16526019)(478600001)(8936002)(966005)(8676002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aYCLjJjDHZe36U66nkV6t/ZPOHt6XMJ75da+lJctOtitDjQHGTj5tJRSPRd3O0T2tuhDbU+2TP691RxFS2lwchd7+WeySt8Nk1GeiqtOWzGUSU79xcrdCsp99i++wYIrUz2YJmPBMmj+JWWQB7A+YYWnJNSRajFb/hpN2UCdFaLLn88Sl1UzuINZahhMerzdBCDUHq8lSWAAY0s4a+HHr+GvJAN5CTjpFsDCOFLpCmFRSAqM6pf8YOys8qJCCZj82LGkvTJUtAhfHXdQ1lutDz3B78uWIcati02SQ2v6BcHz8qujlw7pNVUyExi2yizIEdlzaOwY5u6PIA2gnyQpOcgOKK0f+XVPmK6u5eku8SpWRz/Kz7fLkvG8eoJurCRl9LpkbSoxUQJ+Sm+yl5CvtOSLMgAJBP//Hl8kIbtQZroD9sIk3EISZMfShwZLDdcGa9vxahLBsjyFp5GALdqqcRIGKYMcL1Yq94FD0kpfZ/NZjJbxQauvM/QERlHtf5h5wxsTjqGxEpgyTknA+/p5in6y0O604vgV41noBGWe9Gv6YclBe+cxDdHV+o+uhU0+n6DIEdTEkRfcn9fBb4/CL6HkQ8LmRswujZfvX/TvB2pbZ5POrl9MpWpU11wrpYD7ohN7omP5KBRQ115UD8gBZg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6b6adc3-e0ab-458f-d857-08d871eddcd3 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 16:09:30.1812 (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: 2TZjvd+siWlJogUSxWugvujrTZcuMLNZhopggtjH1l8ryL28Uys6qxmUi7dTlPcSCdNKTwlliF2nll/4TmgUuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4926 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: ae511331e0fb ("BaseTools Build_Rule: Add the missing ASM16_FLAGS for ASM16 = source file") 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 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, OvmfPkg: 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 | 40 +++--- 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, 258 insertions(+), 141 deletions(-) --=20 2.28.0