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.78]) by mx.groups.io with SMTP id smtpd.web10.1355.1585071693386973448 for ; Tue, 24 Mar 2020 10:41:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=TnEQtFNu; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.78, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cURzlmsu6LONotMvO5IB9p32Mn5JcSwziRpBmB8804OhOFQz8l/7PxFAEc9c/AysnPNPgYZ2xWZCXLHGTZXE7puZGnD5EtJ3onBkERhoFdhpOP3qtIQkIs1nrcE5fFKHTEsnWBfNVmdfDo4WSaWZQVDWXVUVRWiu0NDxKU+e0cq6pr74Bkw1UyAASJNDaWRwX4tULdn801aD+HgwyvVcGrVO7MdBMzxrrzo8udJUCPjeOEfuUyc/z/GZI+DPOEUXV7yRiwVVIM1sxlyZqC+tMG/+cTqnFqgrEDhrJ3IELBpHYSRnQQYxxIp7yUo1DiFs8BBHIQo3XaEZHw3C+TbP/g== 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=sul0qx6fX4C4j+HEnNyWB5RPJsMni4Bj2eYD9ot/oHU=; b=PrFQsTRwKzB7LCB2YT39fjRlnMHH+BoSNIiu35Uo+GYhVi/q2xrSOLvtno/lRFNt73S6k1QIQofEr6bHhV3nyWAxlJANiLZ7N1R7vy39JQ24poD8Ep+YhZpZlY3w1wMw/n5k84cxeNN7P+cPs+rj0PPTB6VaRz9K10QgozVGmShJOQMutaMzfckFOGv4Jf7X0cC1wQeyY17zRz1NM3OZoLg4yXxu3MEFU9oEw3L9W+a1wooTNs4exYDlRmyKv+3lnlxwSjBpfEJEsaIrBEaddu3NDO4J0OtHaMGvwXThJyPXCPVCxwfstkKx+30Nt2uap8/QC+uKxTQ4s/IAv/qfCA== 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=sul0qx6fX4C4j+HEnNyWB5RPJsMni4Bj2eYD9ot/oHU=; b=TnEQtFNuiLy67zfT448Tu1mndRb9lePhSBZv7W/JBou8DlbLTu+fDSPweVZWiOAFuOmh4/y3q8hd/Fg/yHcIN/l5f+FLHBpPabDWHWGKoqGgls0AEUZU1ghnt4zX07HNg4tp3xWjAgPEEKXGVB1Pbe2+CSCIYcTkpjvTSKFijWM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) by DM6PR12MB3915.namprd12.prod.outlook.com (2603:10b6:5:1c4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.22; Tue, 24 Mar 2020 17:41:32 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733%7]) with mapi id 15.20.2835.023; Tue, 24 Mar 2020 17:41:32 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , Brijesh Singh Subject: [PATCH v6 23/42] UefiCpuPkg/CpuExceptionHandler: Add support for MWAIT/MWAITX NAE events Date: Tue, 24 Mar 2020 12:40:37 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM5PR06CA0025.namprd06.prod.outlook.com (2603:10b6:3:5d::11) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) 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 DM5PR06CA0025.namprd06.prod.outlook.com (2603:10b6:3:5d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Tue, 24 Mar 2020 17:41:31 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ccc61506-ccfb-4e6a-87c0-08d7d01a970b X-MS-TrafficTypeDiagnostic: DM6PR12MB3915:|DM6PR12MB3915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-Forefront-PRVS: 03524FBD26 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(366004)(346002)(136003)(396003)(39860400002)(8676002)(8936002)(186003)(316002)(54906003)(16526019)(956004)(66476007)(36756003)(6486002)(19627235002)(66946007)(6916009)(66556008)(2616005)(26005)(4326008)(966005)(81156014)(478600001)(81166006)(5660300002)(2906002)(7696005)(52116002)(86362001)(136400200001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3915;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G6usW6B2qNDmQn6fYjhJZXdLRBiQ7RQQi9OTIGXUqbsUNPKSZnEuJa9u09kK1rGi2qA7ynfd2pNcymrnFjjM4hf3HefbFmBXCcWEKwx7d15YBwMaS01UYfo7tYyWalD/KfZA+yEVB2JHU9cQ4DNbrlvKmdQeTpLda+r8O/0QlrSCo8Aj3yX0M1Yrt8PVV8YGDPUsW9Rxnl8N0ZROjEXcMP/6T5K2HGmNbUA7+M55swu0+Aqe3KpsRJ8zalRhtOxzFVC/YxsKnWvBcjOT+BK+2fW/FVEjoVJEgYmkJCu9p5LwvP0LwTBb7t0mzv3scIc81qnElh5/MGlbrLXV80zmU4vUywXLLX8BpkAsMK34vasSE3FK0T56UPFEMcsVSseWNvzu3x0wkUv8MYpRFKV8y3I0pDfrrEfMFZtqURf5Gtv7gqOUTkSaNj8MvETuA+CY/Zs9SRZi28vThhuCxPw7M5D4o91pwITbD/s76qRJ618ITDJc5kVoMMdkNn7K0O72r+jmH9Hz58xPjcpjVOncunI5Cujb+C22vnfNXoopr2zXGlUbaRtlaN78BoIO9fPhFbSJjmEcXjJS7vJwEbWQsA== X-MS-Exchange-AntiSpam-MessageData: lDH2gmAxV54maBe5Ema4xl5v70O4KOVfCmxZaOVYTls/U7GkHVMirplGobPw9ODLeF8gknjzDOzKlcbH0R4y31LFKRVRWVTds1JNZQpXMpThPRtxbOwzGmSaZeQZGxp9ZOOLPLISN7Y92dqmU7Mqnw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccc61506-ccfb-4e6a-87c0-08d7d01a970b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2020 17:41:32.0725 (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: lfvMZcJC0uxkq8eAhUDQsP/gEUslnb7yIFNENMMdNiucTWmTkrNPR9mxmCxgd74Esve1JUYsYWQ0+PulJVPMYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 Under SEV-ES, a MWAIT/MWAITX intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Tom Lendacky --- .../X64/ArchAMDSevVcHandler.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c index 90255cd55e5e..1fdbb122c35d 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c @@ -591,6 +591,31 @@ MmioExit ( return Status; } +STATIC +UINT64 +MwaitExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINT64 Status; + + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax = Regs->Rax; + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Rcx = Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + + Status = VmgExit (Ghcb, SvmExitMwait, 0, 0); + if (Status) { + return Status; + } + + return 0; +} + STATIC UINT64 MonitorExit ( @@ -1107,6 +1132,10 @@ DoVcCommon ( NaeExit = MonitorExit; break; + case SvmExitMwait: + NaeExit = MwaitExit; + break; + case SvmExitNpf: NaeExit = MmioExit; break; -- 2.17.1