From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com [40.107.96.76]) by mx.groups.io with SMTP id smtpd.web11.18995.1627907576023213932 for ; Mon, 02 Aug 2021 05:32:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=ybe4ly34; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.96.76, mailfrom: ashish.kalra@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3dsB2qetnzeYahwmozPMOby03FWLugNLrnWd9/U82wrV3pEzLDZ1lJ9+sTs8mp/L5tc+CX9RnESsj6DFdfH/cx8JoiUzEOqtYBBJs4H5sqYsQNSUnlKfzf2l6VUiBmpRv+VyYExAdXt8a5Labu8O/u8w77zG/iA80/4gNwUYGmVcApCShJl5ekquttyAYOZQHSc3L9yRe7+HPeUQHCSEsnW7TudeZ33ZQyJMPTndkycHb218YuPpolX4/K38MAD7P+xXFBqcplylPlNigW6MMr5EAF29EbPy6X+Ljz4qKsTKcA3eFJfxR1tf9cmZu/PmBrjmIK0L0ZiscCafRbfbg== 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=MKf+Re/HuJ/+8EVzKQtD1e2k71bFlKQLuVBW77W10KE=; b=Hc/SA/PLMaChJRyLu4RCkX3pwUFCQ5Hl4RLw3aPPGizTUUF0Vnyam2LpEQeiEKxFcN6xCA8suLNPKR6A5u7UQ8sDH/2502LgL1uXCjwZnIWMUHf+U+nH+zFHRmdLvj3uw35MKob5zfuWcdZXLxGt3tx231pezUPnlJJ1tT66tiFDrwEYYH5ATHYdHQWwQnxQ+HNBlxobv2S8WmOjVlK8gdT7O8WHYFZJZyVNlAZvn33qRj9suEAyohcTfVlUPEvGnI1SG+ZwzgO7LstcOjjW0etNErwSUPmyGo5DMki/FhRrnYPVlXHPSitq/Uc1N3R1+J3bfGPJmjrWlUYNS8wwuw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MKf+Re/HuJ/+8EVzKQtD1e2k71bFlKQLuVBW77W10KE=; b=ybe4ly34lyteatZiKH89V+8icSm9gKp/30lEfjO5cM01qi7KUwLyu1i4MEFxUZWN8GGenGWXwvcdWxrzTW561DQ9QDuDFT+mzPJwIPozXRbYZKQQ+aSwsh6c163SKiSTI5kfcYggpHxYSTACSK7rGgNv+wPHcOTIa4xjQ20FAQM= 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 SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) by SN1PR12MB2445.namprd12.prod.outlook.com (2603:10b6:802:31::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Mon, 2 Aug 2021 12:32:52 +0000 Received: from SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::491e:2642:bae2:8b73]) by SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::491e:2642:bae2:8b73%7]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 12:32:52 +0000 From: "Ashish Kalra" To: devel@edk2.groups.io Cc: dovmurik@linux.vnet.ibm.com, brijesh.singh@amd.com, tobin@ibm.com, Thomas.Lendacky@amd.com, jejb@linux.ibm.com, jordan.l.justen@intel.com, ard.biesheuvel@arm.com, erdemaktas@google.com, jiewen.yao@intel.com, min.m.xu@intel.com Subject: [PATCH v6 4/6] OvmfPkg/VmgExitLib: Encryption state change hypercall support in VC handler Date: Mon, 2 Aug 2021 12:32:40 +0000 Message-Id: <374f6071fc9a572d90754dae1d35b2d0eb46cbd8.1627906232.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SA9PR13CA0180.namprd13.prod.outlook.com (2603:10b6:806:28::35) To SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) Return-Path: Ashish.Kalra@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ashkalra_ubuntu_server.amd.com (165.204.77.1) by SA9PR13CA0180.namprd13.prod.outlook.com (2603:10b6:806:28::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.6 via Frontend Transport; Mon, 2 Aug 2021 12:32:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f61a346c-b34b-4cab-565e-08d955b1a542 X-MS-TrafficTypeDiagnostic: SN1PR12MB2445: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2RdO9TE2dYxbQgsDT9gwxYZZhhli1p9QTzlxg+uQJiZkCmZI20Im4+hX17FHDoZf/Gf6hSFobt5vtI8yphzDeqe8iHRyyleM7w9SeY28tRElZZSenOtGd1+2oOwwetRdlPZ+FZOF8A9Iq8WKN5bH/PWTZK1evoD2XIQQM379ZqXmqP3QWEurwlqfqY7bRmdyFbYVKjra6nQ6Lc8S9HMl+oTZS47GDg3YcYB2xKJeYDZEAyqxjSBqL5qvHLmgS8k/m3b56brTZ9Vm0uaW21JY0uSp8NBodLpRcGO0945DjIV0RniygP0Nte4nTwnpFyO3fhFoHdrOXwTC/NhH/hq+TbiFtmT5d5nx2yNIlyWuhLzkQLhwm9jCw2hiiAY1E4pU75DM5OvazOoejiQ1Q8bYEc8q1KpSYKWTTbLZQY/zNYi1MZsBIPopn+HtMby/gDHnUtazK1aQr10nazXoLW/z0M84G33iKPYrJ/0hGqrYsMYW7ZshZJHiuDdbxGEJuLmOPhhvrWbTRgVgJxHaXUfS9Lqr+vOQ8WMWSsdPV9DV5c6ckEGmitXLeohY773lJglPKxpjouIv+67F8Sn0Teow3f1dAIx4x+dIquGC7MrLcj2xgYbmuI2rwDmJZWxvbg71DwRlEv9/eEQYUfBh7E/ZQPN9f3kGxo4Gu1gjn8i+xHr0uLoXcFRz4r801Y+bJ5gAzjWVlwKS7ZpottBMRL6boQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2767.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(376002)(366004)(39860400002)(346002)(956004)(6916009)(5660300002)(4326008)(316002)(7696005)(66946007)(66556008)(66476007)(6486002)(8676002)(478600001)(36756003)(86362001)(52116002)(8936002)(38100700002)(6666004)(38350700002)(2906002)(2616005)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?EvbKEflCcOGZZh16C8FpiUd8ZVi+noWSkej3u5XesO8CF55cLqprFe5Hzyf+?= =?us-ascii?Q?IvQogPVAKuIIc1ABzU5hVA/Z3LPhvR3QJ7yzaAjYBGfp95sBHiPQqkT+HhiX?= =?us-ascii?Q?Zzzbxq7I2acEm29HgoGiybrn1MIcNSEC3h3B6VE1G7vLk+4NbhOVPrFUnRJZ?= =?us-ascii?Q?bhsThBTULKkpRTBR8kVhERX47ct+UHqrgI6WBRttr+tuvU5B6CIrvQbs56RM?=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k/Q0VUpJgjmWrAdHw/zbWrd5Ih?= =?us-ascii?Q?mm/UWVcJVGqZPS+nOXjt2SKKjeL1wTYnuWAweS7XtMuBYtEnuBtAiZ8GlSPZ?= =?us-ascii?Q?6coexFc1drPKbbKwRLeeBfbYvPTF0p1Atd0iwOwpN1y7NuBp6Qmt70OlGw6p?= =?us-ascii?Q?YgW2DDqtyhZ0eK+v1fo/8tcT31Vvy8xlo4LEdPHcY9+UGag0DhPDvbpp7SPU?= =?us-ascii?Q?4DFKPq3hFqngjkb8y4XCC7Ez?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f61a346c-b34b-4cab-565e-08d955b1a542 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2767.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 12:32:52.0985 (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: ALJaxFWOgm+vdrvgt3r1upAc/ODvF6YS/3S9oQZrQhFTAtGjocoRTbB7gLXJe1J27Fth96K8nnb2Dx/Ez/2ZRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2445 Content-Type: text/plain From: Ashish Kalra Make the #VC handler aware of the page encryption state change hypercall by adding support to check KVM_HC_MAP_GPA_RANGE hypercall and add the additional register values used by hypercall in the GHCB. Cc: Jordan Justen Cc: Ard Biesheuvel Signed-off-by: Ashish Kalra --- OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c index 41b0c8cc53..2d06343e92 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -1171,6 +1171,19 @@ VmmCallExit ( Ghcb->SaveArea.Cpl = (UINT8) (Regs->Cs & 0x3); VmgSetOffsetValid (Ghcb, GhcbCpl); + if (Regs->Rax == KVM_HC_MAP_GPA_RANGE) { + // + // KVM_HC_MAP_GPA_RANGE hypercall requires these + // extra registers. + // + Ghcb->SaveArea.Rbx = Regs->Rbx; + VmgSetOffsetValid (Ghcb, GhcbRbx); + Ghcb->SaveArea.Rcx = Regs->Rcx; + VmgSetOffsetValid (Ghcb, GhcbRcx); + Ghcb->SaveArea.Rdx = Regs->Rdx; + VmgSetOffsetValid (Ghcb, GhcbRdx); + } + Status = VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0); if (Status != 0) { return Status; -- 2.17.1