From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (NAM02-BL2-obe.outbound.protection.outlook.com [40.107.75.40]) by mx.groups.io with SMTP id smtpd.web12.14942.1602775661908169555 for ; Thu, 15 Oct 2020 08:27:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=v31PfHyI; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.75.40, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JPQAb9tv0j1mevKvoMXabq28lOQS++WShgIZTH9AhIfTSosi5bvCXPlJAxI3m26yBC5Fhf8T2j6Ae3XE5Ps/NnZ2WFMbuaV1krAHpUYlUaSR1/d+oI6qXyV6NArn531ucICJNy7dHBgiwM3TytKZPTHQ64D8GstdD71YEk8dUDwouHxCtML6zfb7xsL56UiiEBNGBkkOF6vzMai7MWStg4PojDmK0NkmvoC5Srt7AvKdE8cMpCjytVAokqadMhOsjWfjQhwMsxE74T4INNsAV63mPjXoSAJ1TUy3RjKFjrtM5C+LEW4ScsT7kxNk50oOHoUrqykRhfTLMlp9XN0a3Q== 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=tizIS1/kVfKTdrmbxOuvI8NB/T95H/C/gcKoV7tixPI=; b=chziA3O+9acETPfUpC+9PU+s8u/7rvyELslPS3aP4M4YUoc5Utkucx5cusBqLdwBoeV9CqtO6DASGANRBzut+Lk2zGEuNysDbc7Is79O8ke3n1f5DjIOEnyVWaPJtkbCGFG6wbgkMLrp/PQJW4IBjDRLp7tI1Bm06XyDUqTp8jXx5YqAiY9qFaiOdwKIOaPR6lXlIW865zRXCbMpj5QswwPQmLbOpdF8hTx7TlDnGOloMqjnSMP6VC86NBl/CB3l+6RthKQLQk3VL4lN6nBug5BygDeNgTWS814ZUXeDtRP62DkQvP3VGuO8KxAcbedGSFsWQhfCc+WQiJrv/gorow== 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=tizIS1/kVfKTdrmbxOuvI8NB/T95H/C/gcKoV7tixPI=; b=v31PfHyIHsr9ouHOu+J43anC2xQrn5d4Mqn5nlaJ6ncbnxIrRI7V42Bqn5nrwqDddkFpxRCOKxZswcFQY9jnLzju2JVktUjNOBJdHABnfsjcXyXdUzDAKChncR5++aB2fwjJk28JqG8ZEOdbXdYjs6tHMDWN7m2bM8GNH8NbEug= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM6PR12MB3081.namprd12.prod.outlook.com (2603:10b6:5:38::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Thu, 15 Oct 2020 15:27:40 +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; Thu, 15 Oct 2020 15:27:40 +0000 Subject: Re: [PATCH 2/9] OvmfPkg/VmgExitLib: Set the SW exit fields when performing VMGEXIT To: Laszlo Ersek , devel@edk2.groups.io Cc: Brijesh Singh , Jordan Justen , Ard Biesheuvel References: <34bc7f77-2b5a-2e74-e78e-ddf606b6305b@redhat.com> From: "Lendacky, Thomas" Message-ID: <729bf290-2864-a127-a93d-7b47b7db9b4a@amd.com> Date: Thu, 15 Oct 2020 10:27:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: <34bc7f77-2b5a-2e74-e78e-ddf606b6305b@redhat.com> X-Originating-IP: [67.79.209.213] X-ClientProxiedBy: SN6PR04CA0075.namprd04.prod.outlook.com (2603:10b6:805:f2::16) 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 office-linux.texastahm.com (67.79.209.213) by SN6PR04CA0075.namprd04.prod.outlook.com (2603:10b6:805:f2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20 via Frontend Transport; Thu, 15 Oct 2020 15:27:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 65a0b005-d46e-4cac-c344-08d8711eda39 X-MS-TrafficTypeDiagnostic: DM6PR12MB3081: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1vW0C0Mm1W+pglw78tdOr+s8su7z6IuTUU3q3p9zxo1UGkYgeTXBF/CUDEpHi1JCrexOqUY/RX4JjEn4FYhlsfuR17l5tEkeT+AwKFdgPESL6B+VpfWI7YeE/6yfYYiy7kBNPcNkbo3WBebFzFovr1UZ86UVlxbGsgbkfLxxpuJGl1u4V6nwfttV7Ek/DfOK2kYz24MIQMMQdhCGwJZWO0xVc6JZUgenAPkOTT+mMyT29Ff4toEUD5NKLLnYiw8ZOtpHO50SddkOxz/LEM7LdifTuxVfyX/UTyHVnV8bmMUaqf98LIoh571U6RvWKDnINJb/C0o0mbefh7U9pUNTVLZ4XOXgsiAQDQzktr2sgY/NTd5/DH27yxfqBzOeP+wNfaI2+Oy5ogaAZmNwQLF2hxG3RTKZeSyXHJriFM0IDwo= 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)(396003)(376002)(136003)(366004)(346002)(31696002)(31686004)(5660300002)(66556008)(66946007)(478600001)(8676002)(8936002)(52116002)(2616005)(83380400001)(956004)(66476007)(16526019)(34490700002)(6512007)(6506007)(186003)(26005)(36756003)(4326008)(316002)(6486002)(53546011)(2906002)(54906003)(86362001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: sAtiZTk3QjHu3sLKey6wvVG9RP3RgUNt+CWxbGt0+RHykm6+PP0oeVHxSV4C5Exx6MhsPjObp4XyYZHUtM/YaKHeJPZNbBMOK+oE1ywp29clEB0TjnXPifZm4tBR6NNbOPdm22N12FQUH7SARK3TaC3NZqv8QichjV4sASvygqETGXFaif+9DycUrY43XGht0wVnWhaXecwELLSNkF11vmowaoOiPw6EfkJSN7w8YyjrEvU2eieDQzM2NEXtVPmOsGHZEKcmailYpeabH9t7Tk/5XUb8kBxSDmMaFZzTIff8OHggJdU+XbUOR8IqMvzp2IXAJLIlNZQQWumX15iObRbJtX0OJUO1aY1Iinal3oPTVTE+x+5k6MaSIlo5CtXUhdBhQkUX+YEdDhU+PZJWbux3jDrIOTO8AmNWmN7xiorFlBH44uNh0D9hPMcabgyCtXBvBGlUxb5bNw6tjWWa3RbGiTIDk3Xyhz/+gsLaB50W+LlKpfrdPH1oUXHvaHOnQbEYEuAMp8UsmdxkJC1u9163wEzGHhYHjS6tZ/TmwMjcWw5G4zicQr42Usrb6ygl4pMpNaxsUIsECrttC+oyiArliyd0RbsM7hDm3sy0AokMxWmUjA0nW/m3eOG9e41BHiU8WkooBm/zaFF8lPnQbg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65a0b005-d46e-4cac-c344-08d8711eda39 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 15:27:39.9690 (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: UiOQTIPUENKI9/DxQCi+6Pod6jqKyi6iZeC5fA6CIwjrNuD7c9CvWIH8XvpW76OVJEV3c13baWRdWi98fUmVzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3081 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 10/15/20 3:47 AM, Laszlo Ersek wrote: > On 10/10/20 18:07, Tom Lendacky wrote: >> From: Tom Lendacky >> >> All fields that are set in the GHCB should have their associated bit in >> the GHCB ValidBitmap field set. Add support to set the bits for the >> software exit information fields when performing a VMGEXIT (SwExitCode, >> SwExitInfo1, SwExitInfo2). >> >> Fixes: 61bacc0fa16f ("OvmfPkg/VmgExitLib: Implement library support for VmgExitLib in OVMF") Btw, what is the preferred method for a Fixes: tag in edk2? I've seen it three different ways - the above way and also: Fixes: 61bacc0fa16fd6f595a2c4222425cb6286e19977 and Fixes: 61bacc0fa16f ("OvmfPkg/VmgExitLib: Implement library support ...") Thanks, Tom >> Cc: Jordan Justen >> Cc: Laszlo Ersek >> Cc: Ard Biesheuvel >> Cc: Tom Lendacky >> Cc: Brijesh Singh >> Signed-off-by: Tom Lendacky >> --- >> OvmfPkg/Library/VmgExitLib/VmgExitLib.c | 30 ++++++++++++++++++++ >> 1 file changed, 30 insertions(+) >> >> diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitLib.c b/OvmfPkg/Library/VmgExitLib/VmgExitLib.c >> index 53040cc6f649..6cf649c6101b 100644 >> --- a/OvmfPkg/Library/VmgExitLib/VmgExitLib.c >> +++ b/OvmfPkg/Library/VmgExitLib/VmgExitLib.c >> @@ -78,6 +78,32 @@ VmgExitErrorCheck ( >> return Status; >> } >> >> +/** >> + Marks a field at the specified offset as valid in the GHCB. >> + >> + The ValidBitmap area represents the areas of the GHCB that have been marked >> + valid. Set the area of the GHCB at the specified offset as valid. >> + >> + @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communication Block >> + @param[in] Offset Offset in the GHCB to mark valid >> + >> +**/ >> +STATIC >> +VOID >> +GhcbSetOffsetValid ( >> + IN OUT GHCB *Ghcb, >> + IN GHCB_QWORD_OFFSET Offset >> + ) >> +{ >> + UINT32 OffsetIndex; >> + UINT32 OffsetBit; >> + >> + OffsetIndex = Offset / 8; >> + OffsetBit = Offset & 0x07; > > (1) I suggest improving the consistency of operators -- please either > use division and remainder ("Offset / 8" and "Offset % 8"), or bit shift > and masking ("Offset >> 3" and "Offset & 0x7") > > With that: > > Acked-by: Laszlo Ersek > > Thanks > Laszlo > >> + >> + Ghcb->SaveArea.ValidBitmap[OffsetIndex] |= (1 << OffsetBit); >> +} >> + >> /** >> Perform VMGEXIT. >> >> @@ -110,6 +136,10 @@ VmgExit ( >> Ghcb->SaveArea.SwExitInfo1 = ExitInfo1; >> Ghcb->SaveArea.SwExitInfo2 = ExitInfo2; >> >> + GhcbSetOffsetValid (Ghcb, GhcbSwExitCode); >> + GhcbSetOffsetValid (Ghcb, GhcbSwExitInfo1); >> + GhcbSetOffsetValid (Ghcb, GhcbSwExitInfo2); >> + >> // >> // Guest memory is used for the guest-hypervisor communication, so fence >> // the invocation of the VMGEXIT instruction to ensure GHCB accesses are >> >