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.55]) by mx.groups.io with SMTP id smtpd.web10.1666.1580857345373237202 for ; Tue, 04 Feb 2020 15:02:25 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=eeMYe4Jz; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.92.55, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oLiam6WT6eceH1ta80zJCFBDM6EbMZyYymut8ZWJJ1kYHRuTgQTYIAXlNdmDHh32dQvjlbtxhcJuwgzAUKs/91cABiUL8Et6OtmEru8vv4mZkcc/0w6GUqw/SKoJnAv+Sd6G6pIN0uNy2EtrLbYzqMZ7Qtp3yQdyyTn7OSnUCCeNUXyvm7kl1+PdLgNTzIH9xmMBoJQPb7GcjCpuq4yUP8bIWeHQjycZ+RI7I0RyVgKivlTbuT8Gdwy5wryoMjyT3Md997YkIVQhfr9c/btbzz1w1gVGCvfmZWvmhErsckBpq2oFDfUn1YzaE0M5fArc5oIxIRH5nfPA/95zh3wyGQ== 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=bkAF7fRWDFHrwkkADfxVuIBV9u7uW0OxV4VsCQ4GzzY=; b=jSCLpVejaVbfYWv7wmzuwiiJYwC/aMs4h/LLk7YQBVbkx7aYiWTWCkTnPtiF1s/GAM7p164GLJylqV2U5ex1k98M9Ffv7QBQaMDP/kXImyWbJobgx8ca/AALnPfvDogKnpxBb2s/WiHfOXhSh1OQZlSLoextNjEhg/P619ukRb63J/0A2HzAiZnLpqTKciyHqRBvSjR8olUHvFyDxo0JzuvEPaT1S/vaKXWKccZJSGfaijsoiu4JFHNwDV/U32nxYQi5927kqn2SI0nH1EUlYxv7TQPU1rubEmB0UfIlB+Sgqm+ks34/WyRkOQg5S2JKZWcKZQj7e9FWS/DCJtDOBQ== 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=bkAF7fRWDFHrwkkADfxVuIBV9u7uW0OxV4VsCQ4GzzY=; b=eeMYe4JzW3hmpfTjR7tLxR12fwktF5H3KRcTPQ/aTRL6+ntwKrV1j30xMFRdlRGPRKyyJwByoFg/vbf8JDbxdASsDnUrq868kw6aHBaJ9Gfa/zfzQa5iUrNy0NgSJMUoWyzI0P1dt6W7htk1X0q2H2aMXJnTQlR3YmpOpUPwE5g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.71.154) by DM6PR12MB3930.namprd12.prod.outlook.com (10.255.174.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.29; Tue, 4 Feb 2020 23:02:24 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270%7]) with mapi id 15.20.2707.020; Tue, 4 Feb 2020 23:02:24 +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 v4 21/40] UefiCpuPkg/CpuExceptionHandler: Add support for MWAIT/MWAITX NAE events Date: Tue, 4 Feb 2020 17:01:25 -0600 Message-Id: <249fb0ca366c123d5044a674689f36d982170048.1580857303.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 Received: from tlendack-t1.amd.com (165.204.77.1) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.32 via Frontend Transport; Tue, 4 Feb 2020 23:02:22 +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: 49c573ed-7dba-4ad1-38bf-08d7a9c64bd0 X-MS-TrafficTypeDiagnostic: DM6PR12MB3930:|DM6PR12MB3930: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-Forefront-PRVS: 03030B9493 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(366004)(376002)(136003)(396003)(346002)(199004)(189003)(4326008)(478600001)(6916009)(81156014)(2616005)(956004)(81166006)(8676002)(966005)(316002)(54906003)(19627235002)(2906002)(6486002)(66476007)(66556008)(52116002)(7696005)(186003)(26005)(16526019)(5660300002)(86362001)(36756003)(66946007)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3930;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; 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: wRE2d3hr+g8VrrRB3ORUjrHeGXqpkfjVpAtDedVbP73MU0f4ydk7N9QJyeTJ4DPJ4GYxcIrT1pGGx88sYkWpfSNgWvyg2faVE67IE2VcGqqr4ox5tSiLFoa56+IXnocB4GOOYDjMUZM2Fn63iDU8jroapWoNAjWr0wSQa5iTNPPwN7AcaAA9cZBCwV7sRkNhhL8eCOnvbsAni97SBAke/UP4tQyapX6/058fqTOvG5m8rI0ttIRcCijNJh5XewFUa9hnUwoX/ipfEfItVL+kGUbjK//o+y2w8mdA5b/DdUkkmsviky9tOSSNojQoK1yuu2M6I0Efd50bKmxJ61FIDOnq7ttkcrtlwB0p6lo1C8rOPdNBzPylt6748o87WEBa+l/tdsALB/ig1Gwl5T/ZwJPC8ADoghlDK410GFHw5M7W416d3pxZFljr4ciAS4sbfnhi7tP7klhZoaeqZNu4ucvGKJpMhdWXjLlYvIgZFL/90nlVHg3q5QYNGMfwjfsLBxTlUvSTw0jlM/RVcp2BKg== X-MS-Exchange-AntiSpam-MessageData: DGno/BRSojP0rfKBWz+mUKd478ai2LE8g/FZ7LpCJMNfJSOoOPteIZvjS5judIdKoyv/Ivn3jB8SurdfhwngDdGLCIYZrrP1MHDtqG2fOdWY9MKmXfd7PanUwgkYazs5JSR3FextijRJXCFmGaYElg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49c573ed-7dba-4ad1-38bf-08d7a9c64bd0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2020 23:02:23.9009 (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: AMpIFa0c5glEGw0D0p5q/6GZKgPwpvUiD4SL+9h9y2mYwiECy4ZEYCNOSDb+LjiKAQNDD220EPbHVTulF91XLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3930 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/AMDSevVcCommon.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index 93341a647e48..4318014ceb45 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.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