From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.81]) by mx.groups.io with SMTP id smtpd.web10.10770.1591363694978904080 for ; Fri, 05 Jun 2020 06:28:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=baoV0l0I; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.81, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Br7KO4P+hngCeFIIPtOb2QZQmukHcuETeNjALLq64hRVxkOJ7pqLcq32CPTSebLmO1F3kdxu7PN13sqCr/ChDLYXApvcpDge2qHlozroqsxHR2PWP1CAqkCJ41p9LWMREAdzBZIN/+jnQm4AP7F5Qsvl+n/ZgfGtjpASd8C96Nw98Aec5DEs1aijlth9HHz75TGRq9u/n24JzHS2eh089C0Eh0vC57mq2lw4mVFR5QBOOFZigPZTx8zNcYbMWBS/8fIovT0Iv+pnS6fBgWuXn3m5uToyForaOrDYFg3DXRw9qsuiBOD6v8RY10IXyvjUVW2OfOgPLEaMCk+bIys8Rg== 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=fr1Yzlx/SHLV6phHP9Fl2jwHHorf2DA57ZWNi23Nsc4=; b=AKXClafOCTRWvLwD6UXfdVcZpsgZHyZjpPHe0Kf1z+3ikAYAaQUlQ2GEhAokqZw2jKO5wKtV6RLx72d8KFmjzKXbfUpM9avgZ+CNfXpeMEuHiE9dFO6l9AEIGaWdKdMzySoZvT6QqXHV4yWm61R7Z36Q6hjgG6hSLdHxyRxDzusubHmAOBP/Ywgx8KjJsrHNhLWsEjZua5oui5kYEJ4suaHmXA1qYkQysGFxpNP0ZRDsxiGTO3iApTTgSnhlvb/puM6nKJcZYiRlg+ACtIjiEsACu4qZ7kjvL2Wocw+J+uwLipjY0G68J4fI9Z2/2I9qF7/wmEkANgEW4rW153RGig== 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=fr1Yzlx/SHLV6phHP9Fl2jwHHorf2DA57ZWNi23Nsc4=; b=baoV0l0IMi32DfASl1/9zIwsQOOvLzoVI0Cc+7PGg16eg1EbWfwnUKEdgJKDsvKXrRm0uULIp03nW1vt0xbRj9Xww6xlDnJFL5icUWB2BISIYi2rJuY3nyqRYVGKpXCE65At6eapLC18kSh2Pm8g1uqdh5w/ynEOx7/0WDgUyHA= 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 DM5PR12MB1354.namprd12.prod.outlook.com (2603:10b6:3:7a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20; Fri, 5 Jun 2020 13:28:13 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1%10]) with mapi id 15.20.3066.019; Fri, 5 Jun 2020 13:28:13 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Cc: Brijesh Singh , Ard Biesheuvel , Eric Dong , Jordan Justen , Laszlo Ersek , Liming Gao , Michael D Kinney , Ray Ni Subject: [PATCH v9 25/46] OvmfPkg/VmgExitLib: Add support for MWAIT/MWAITX NAE events Date: Fri, 5 Jun 2020 08:27:16 -0500 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR19CA0060.namprd19.prod.outlook.com (2603:10b6:3:116::22) 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 DM5PR19CA0060.namprd19.prod.outlook.com (2603:10b6:3:116::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Fri, 5 Jun 2020 13:28:12 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fc151b14-6ed6-4a7f-be37-08d809544c34 X-MS-TrafficTypeDiagnostic: DM5PR12MB1354: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 0425A67DEF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 24ugZ/xWIR7YmNg5CS4MCtv+Q0Nb4NkGVnjqv4MczngILUuBPPVURt7TKNNnaq2I4+r03ZKUFFnorMjwToj7V1vpQEdhEQ3iDbZ9EIJKUmLz+pEkhczYk2k7uIhpQhJ62G/aUyKVews/V0EZFZ1ziABFT4/Z14voqmea97DmZ2EvIir3QOV+m/Wb/QacDskTImuVYGRF3ARpuo7FJ/LcClajXP/by3JXMDpqD68GECrrUYqzSfJODg76/7TRupoPiFbRO5Jvma5UhHmfMDe8GqKH/mTIqp+/dZWv6cahrNhClJvqo10DEi40TXib7DW8jX3ZJ0Ip4sxrzEXVXM6XExHdEbrK5rkZI70OYDqzko7QRG1UH19O/FH4qBtzsGarQXY401LA7gc8hzBuo2+Rn+vQmW48nbUyj2V2H2np6fVp+lkMgaMVa9QIpHjuCNYeD5obiIQhNfwoTvUEH1/VYA== 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;SFTY:;SFS:(4636009)(346002)(39860400002)(376002)(366004)(396003)(136003)(52116002)(83380400001)(26005)(316002)(7696005)(54906003)(6486002)(478600001)(956004)(16526019)(86362001)(4326008)(36756003)(2616005)(966005)(6916009)(2906002)(8936002)(5660300002)(8676002)(66476007)(66946007)(66556008)(186003)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 6MPrFd2NBi5Jsvwfoqzdcccpz/Dkb2QSZ6F/A4lJsnZUJfgKYS4Jmid3D7ebS++Zd8aChb9hK2yW1GSO1ifXCx4/arlntXMbtkd3rmmx2tQDXKJqtWSmGnyzN1HgiIKJmSZ5GTFAKRegxLdqyzO7V07jiFj7+AZ19A4Gj2BsmSrJWGJz48tJ6Uofp2RKTfvKItrajSFpy9lsa0bGTp6lnyPHiOIisQb9/JzlXQSzciQTGOrwoAES3F0xp9XWtTtdxmJXzCFlS68n5wMOGWEKbioiwj9TqMzdeSPhx4Nwwsjc99cpkNQ0Q7DvhH1OI3Fs6iLk1IMJLMhakquKfOHp0izPPwRX0rNF+USMEPCM3PDTyoyBxggukZbEilr1nKFuHaanoq42+qmjHSkFPB7eB8faCDdsdZghTRLQpOGrmLPaPj4D6bO1xRCOuIa2rAcHCf6v6wDflFSP3I0xgOTe6QPB7UpimaKG6+fFc0LIGX4= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc151b14-6ed6-4a7f-be37-08d809544c34 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2020 13:28:13.6611 (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: i02ocsHroqEozNZHBCGPXgO5G+4j9AL6a0WUM4sCgmCexCBdTGPTmGA0d5qH+nUfZGTAWob8ctEjMGEBVXV6lA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1354 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 Under SEV-ES, a MWAIT/MWAITX intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Acked-by: Laszlo Ersek Signed-off-by: Tom Lendacky --- OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index bb068a45ae00..9d93e30a8ea4 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -854,6 +854,38 @@ MmioExit ( return Status;=0D }=0D =0D +/**=0D + Handle a MWAIT event.=0D +=0D + Use the VMGEXIT instruction to handle a MWAIT event.=0D +=0D + @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communi= cation=0D + Block=0D + @param[in, out] Regs x64 processor context=0D + @param[in] InstructionData Instruction parsing context=0D +=0D + @return 0 Event handled successfully=0D + @return Others New exception value to propagate=0D +=0D +**/=0D +STATIC=0D +UINT64=0D +MwaitExit (=0D + IN OUT GHCB *Ghcb,=0D + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs,=0D + IN SEV_ES_INSTRUCTION_DATA *InstructionData=0D + )=0D +{=0D + DecodeModRm (Regs, InstructionData);=0D +=0D + Ghcb->SaveArea.Rax =3D Regs->Rax;=0D + GhcbSetRegValid (Ghcb, GhcbRax);=0D + Ghcb->SaveArea.Rcx =3D Regs->Rcx;=0D + GhcbSetRegValid (Ghcb, GhcbRcx);=0D +=0D + return VmgExit (Ghcb, SVM_EXIT_MWAIT, 0, 0);=0D +}=0D +=0D /**=0D Handle a MONITOR event.=0D =0D @@ -1530,6 +1562,10 @@ VmgExitHandleVc ( NaeExit =3D MonitorExit;=0D break;=0D =0D + case SVM_EXIT_MWAIT:=0D + NaeExit =3D MwaitExit;=0D + break;=0D +=0D case SVM_EXIT_NPF:=0D NaeExit =3D MmioExit;=0D break;=0D --=20 2.27.0