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.51]) by mx.groups.io with SMTP id smtpd.web12.10854.1591363693975952779 for ; Fri, 05 Jun 2020 06:28:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=SxWM7nPC; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.51, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A3DmM8jvXYcyNb4IgzvltpzHOq17HRJ3BKaiCN46gFODxn1mjEd36YPjYPl6cFrtCYi5oMez1hdWc8IZCqHeMuBbebI2TRNGDEEEgUYycEAmvdxxRx9EDt3f4PvLPkG9F6Mwz4jhMzJ3Iwd+KCb/ln5xZpWLtR6tYIjEKmUIKtPrzOUbvCqVGBxYnxiOq8TgPTKUBxu00Q3c4kv/9e+/maz/Ot4GCnir46oFxE649v91iPI+0GQZjcaMksvt74QzF2hZ8mKtqsIR9JV2uE1QSwTrBy3NheZH+5gR2TiSZ1Y8grDsOB0IAm3emacqiftDUELc2lm3slaXkY2h2j5WtQ== 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=Hr6J+qLI2XSotBx1w7hKz3jfpcPQORUx+0UqwaPxTbE=; b=lPlCaJ0U6vMfbLD0kjB9XqKxd8k2Oz4TAePpOmPLLsK0C8AAFjPKaHoABPespe7sXubo1RFrfg/RwUlJDeYyUuTE40xOQQLgERm4v6l/FzgfbnZOubuemsHfvjpw4J2cy1phg3l1aEnwiKunWN5tc2SX6y73AsYOZ9KsbfI9fYgJ4MUA99gLnqWER1g8CSC+g2afgO55Bp2fviHctRBFK77/U+pdBeZXJpqNjMEzTttSfVzhAl6Y4HF0zslaAY8hfGc5vmawxgJaLHNxd4gHAuzr4vhSAxCbd9vBV7vv2LQ/nKr4jE4S+BBaTwrJrRveLFnfXG8Inbt/qXge4Tp7XQ== 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=Hr6J+qLI2XSotBx1w7hKz3jfpcPQORUx+0UqwaPxTbE=; b=SxWM7nPCPm2S8hm8je/xhujXDy813ubZ1ZvpRzZOapz/L7MEGJqlHdocsHpfIR5kx2+VOVx3E9vZuWJrewBVlShiM3Lp2x+wd/elkPJM9VQ26uoKjzR/6H8PWNsbCwf8ATP/tY5inQs9bAKk/8V8hAa/i7umdwAqPvLgdwN80f0= 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:12 +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:12 +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 24/46] OvmfPkg/VmgExitLib: Add support for MONITOR/MONITORX NAE events Date: Fri, 5 Jun 2020 08:27:15 -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:11 +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: aa1a6a1d-d4fc-496d-79c0-08d809544ba2 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: adJX0g6wcGZGijGbWXjios+FKzB8BPFGYkxAtNpqMTBE9qiq/I6VhfWW7O0NsKgWLn67BJwu+5PFmvMZqyoHxRLUqcSZ9osMr/fIF2No9cO4f36Qxe6TEavH9wwySzGAlv8HmIyrf+Xe5KdMwVCPvonqKzqHwP44Wtw1N4l9hgcbFPqtd/p8/jWUnhtY/MByBQMIKPu0UOtF9EbfzRMUdIQT/tZSK+PaOLDhtGHiyA7zlXkeTtaNOseE16KRLIOL9N+tnRF1Etg8hEbTRMCZ7FfOdRicwIpbxmuyol5DTyuuZOLdS3kMnDnKPNqeHw963zwOH899pWRYhutFzie5PaxdO0n9M8P1AIr2+WKBdZjhsMQx6w37l8eGlHVULbhht4ntZXAjX41mwUAEmrGwdqOSqBuipazCD479sGwjs7RCCGzsL2VB2H3AY7PuaWd28eelqOMK0Yv+66loSBte1A== 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: nI2wvAqqftHZrN/JlkzEEZks2qwSei+Jp3SPtePLkua/owIT3APfSz6b/r+uLytDb03o1SiDJDFxdKCTSoFkSsJLlH0LuU4lglNCFRo/8Rt0BF9JM2PiHt9aPONif2E6HghmqQarbmfen1CZ+jnJoYoIOCu+xS8wOXHZAG0kgHVe+HmX3/AVSqxfOv1W4BsDoLQVJlcWh/Y3bhJPJaBGc5HYQKYL+Ukfjqp8Iuke3QLOoJaH3ZIjk5+PLBn0fXiGxH74wjtUxlrqPhiY4GHadBGM0pQYMHB+Kk16Odq4vkF29PyWahQglcsIQGuK0UP5kfJUou0SRJOeKxZGNVa9vSIHSj9pY94FE3lsJ3szd0zkvvvzs90+1e6yNc8FzuxlN64EtHCEqRjDDR3sGxK+ESUMuIBbcILzWRnrEK8GIauCJBFI7ZGGhTiuxp9VmnZCFih1EpRWduLbFvQhBqZuN5jtbmqFZ4pfRdgFF3IYH4U= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa1a6a1d-d4fc-496d-79c0-08d809544ba2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2020 13:28:12.6036 (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: Jcav2p4o0y8hA5jak0ghfSfaiHWGIUqvBdlDQUrHDuqB9e7Y3ciXSsICJZcDfeowH3ewJloMKTvwUrBoreF9Vg== 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 MONITOR/MONITORX 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 | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index 8c2b34c4a83b..bb068a45ae00 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -854,6 +854,40 @@ MmioExit ( return Status;=0D }=0D =0D +/**=0D + Handle a MONITOR event.=0D +=0D + Use the VMGEXIT instruction to handle a MONITOR 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 +MonitorExit (=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; // Identity mapped, so VA =3D PA=0D + GhcbSetRegValid (Ghcb, GhcbRax);=0D + Ghcb->SaveArea.Rcx =3D Regs->Rcx;=0D + GhcbSetRegValid (Ghcb, GhcbRcx);=0D + Ghcb->SaveArea.Rdx =3D Regs->Rdx;=0D + GhcbSetRegValid (Ghcb, GhcbRdx);=0D +=0D + return VmgExit (Ghcb, SVM_EXIT_MONITOR, 0, 0);=0D +}=0D +=0D /**=0D Handle a WBINVD event.=0D =0D @@ -1492,6 +1526,10 @@ VmgExitHandleVc ( NaeExit =3D WbinvdExit;=0D break;=0D =0D + case SVM_EXIT_MONITOR:=0D + NaeExit =3D MonitorExit;=0D + break;=0D +=0D case SVM_EXIT_NPF:=0D NaeExit =3D MmioExit;=0D break;=0D --=20 2.27.0