From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.54]) by mx.groups.io with SMTP id smtpd.web11.69419.1629381921668066804 for ; Thu, 19 Aug 2021 07:05:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=RznaWmeo; 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.102.54, mailfrom: ashish.kalra@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nlaVKGEEA4yF8R5puu4UdRMf+hjkfhh9M27/iszkRAGHxUXwutdRhtf1E2v96xYnMok/ey7t0xfZfv4rN6qjLU2FgunG0GrjcOtLD92JYSfSckR0Hl9M5ayoz76breiAzhrPBNcd2bYc6KAkTJPMEbenG/yZnAGbcdAh3D5JfCuHo3dpsU/T0/9a5DDHeCoNszRThX5nWmsi0ipwjqoUV0I6MkB/dGZ0y51MM6ndb9k1uEarEEMrIIpoy86BmKZns65udRehCkjjEd0lIyblfZO0TcjjHut5+eBc3dnZGSyip3mkeMn6GVMokp5D8B1dW1nb+ZPUQc6U+8+4jWz+UQ== 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=LtBGgFzaPh5o+ba89JN1YGb+sPyUtLNB37tuuHU+4AhyNUr56dyolWYot59p5LCerbCzjb8WMqQMBIbHCGvOKDt3ZomLh10ktZqKoxls9TA9hIO1QxdBj72KTQ1Ixh/+ae96loS+9QREORtp4NL/56/ueNrQKpM5nslo3c7ZJk4k6WRmS3iBb55BUunm3YxyZeS9MAuZah4HcUtov1JzGMCv7awNGP7bxVYc6C68jnSGkfcCGMujIj5mx3r9svQ/CHnGLl1g2JXfqYkvGoatBfpnYU1O6ldc0PUjB73z7w1WP3e1peMlME0jjXRN6Bg8bZvRVZ/MLhXujk6ZrL4FFA== 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=RznaWmeogXNjwURQS3TXqcB0Ez9fyEWs6ciT5GopnEwj6gD87WN1IeLPBu8zlDEuZsWUWq13FaKL/y+Lj3DDsKbZa3hiG9jF/5jyjJiRMYAU5lf9FyqqRFcpuSnfzxQV4pRQb9vczN9zbFDklNSGeetRn5qKYTM92WPxSkv9Ftk= 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 SN6PR12MB4751.namprd12.prod.outlook.com (2603:10b6:805:df::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Thu, 19 Aug 2021 14:05:15 +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.4415.024; Thu, 19 Aug 2021 14:05:15 +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, erdemaktas@google.com, jiewen.yao@intel.com, min.m.xu@intel.com, jordan.l.justen@intel.com, ard.biesheuvel@arm.com Subject: [PATCH v7 4/6] OvmfPkg/VmgExitLib: Encryption state change hypercall support in VC handler Date: Thu, 19 Aug 2021 14:05:04 +0000 Message-Id: <211d9e0624c81262879aa7594483b77c6a87d273.1629380011.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN1PR12CA0089.namprd12.prod.outlook.com (2603:10b6:802:21::24) 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 SN1PR12CA0089.namprd12.prod.outlook.com (2603:10b6:802:21::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Thu, 19 Aug 2021 14:05:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eeebeb23-dc4e-4abc-c166-08d9631a5e24 X-MS-TrafficTypeDiagnostic: SN6PR12MB4751: 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: 5jXVZGliKZGMZzc+FkHHohr9WgJU53EMYEjzPrcnugTw1Do64DOQKH8gBa+vVjIjepsJxc/VM0WUj+n8SE3DV0cWRYIZz56TjUi9eN0FnLy6+glrsMBhPj1vV5Cgcg9NFcx3CKoN9xrOAQiTLhon+QcmhZlidZWEqPQdYPTlIuKDM4nSPY9XcMPcedSxpTI9NJnBDUF4FAF+uWptNhKG2OP5dJwVkYi1OLjb3HmrX8RTK0vuJvMx+XRHj+kCOE2vkAv6U2PFD1Cdpz9EC2jJhEkNAJIWKB1usQiyOnLldbV6gdZ2kHz+O+vc85EG+YClLnWAXYvWR6eG1IV2r8AWQkJ3SjP9Lu+A8gFAXirLeHVN/OP752jnfVk3smEQw7PROM4PPiYpHIuh9VLMp+AbBYPGTxBG96wlJgFNjSoojQWoM1r0s9UfacoOz+iaOGilCXqRo/AmM13mnUawQ2IrZdePc3AtqA1d/9fUVcAuUARezMNqAJBOgeOi3Efb44x/FZAtIbtJXv46oTTb129/PZ8/f9PCx3I/NbR4dwYVF8EZ75nt/uPN8mPYR7JIUXDgZ8NqZKOxHHwYdWMeAY5/F2lQk+8etTVBb2nApFdhSzIsrxuEaIvxsl3JSWDr1fc4JMPJ5ERZ7lViyWioU2uJtpZx7nPZsRq2IpkBW8hxYHUIOlzjiSmlZkKf6NAtRcF4FiLxC4rGkZcldHrTIS7TIA== 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)(366004)(39860400002)(396003)(346002)(136003)(376002)(2616005)(478600001)(7696005)(52116002)(6916009)(316002)(38100700002)(38350700002)(956004)(8936002)(66946007)(66556008)(66476007)(6486002)(36756003)(6666004)(2906002)(5660300002)(4326008)(186003)(86362001)(8676002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4pbKQNJqQx/AczXAR2TfMSZRBoT80USjUOa0K9qV7Vjvu4OzoJ44N0KsxesC?= =?us-ascii?Q?WbknJ0aGQZn1uFwsCGnaVd3Qojpf6FYRYkYeLG8iO16rlxPbjZJKHTnEMoSg?= =?us-ascii?Q?joxQ5dgK47hPd5b1AoaleuHveUddp2sD6e3KdqOLYyvuYiZfzQRLu9CEJSLi?= =?us-ascii?Q?9n7Zb4B42Qu6If6/41eyR86Hsw0KjUp8tzBDK/aoaAsKdQ1NuUP+8C+UeY5g?=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Vw2FCrdIlYd/JWGxCJJPYJJp/fI/dI?= =?us-ascii?Q?RnJPFRiLnjqszyoQfn/Wl9wHxc125G8ECC1H8I+SfO437cCpVm3a5kJLJfAs?= =?us-ascii?Q?iFZgBsqYsBf7zLVHwqwN0r9FuiMKCXXLzhvrksfDTu13sB/wTka/bA32J0VT?= =?us-ascii?Q?WZNx1tyJr39hYiJ8LFLiDdai/paDLw5fsyIZxAPgd+mYx9G6tx+J1nCEcykT?= =?us-ascii?Q?mHmmD83jWRAtRSFFxfb0Ey26?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeebeb23-dc4e-4abc-c166-08d9631a5e24 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2767.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2021 14:05:15.0581 (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: y0menupRVY2by8ZRHVDdd4K9U8ery19cWQKqEzt84vQnc7LzYVCbQ8ZWMf95CSTtt56SDc2cqVieq2AOKYbhyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4751 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