Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2122969pxb; Fri, 22 Oct 2021 14:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNXgjckCmFiJ/pvkJTdovYU1idsYihHhpL+W5XNPW4YMva+RFH23PcqYcZt/v0CZVnDO2n X-Received: by 2002:a05:6402:64f:: with SMTP id u15mr3318534edx.243.1634938415915; Fri, 22 Oct 2021 14:33:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1634938415; cv=pass; d=google.com; s=arc-20160816; b=nqTYXaWwF67QsKDYyuVPW79mqdrqx54viWrh3PIvN0E/qi8sGyK+B1TFsroRHsOtGA 2VDqp8aXbd0nVwkAdXM/z9SEVFvsB+xFn0W0VlVUZiRBh72XdQqa/B6z3bK391Ibtgev fyn+w75jFaWsrNa3bQeW+QZEeGcTbqUNN7v3hlMZbor7vfygGHy/WNy9Qv4x2UfAWwSv Hu0EF5JLALA6sQv+VUxzmVcTB5h7HfE8de+HIq0Ffup8VkQfLfhQQ28cG7gZsNwNRou0 LlfAtCt7reh+mA3v82jMVM4jb6OVuawTSqXbicstJH/mY91ZeYHHO3tOycbSMR7Y65QA QtZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :msip_labels:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=z+W2rI0U0BK9UCAGJnDpsgZCVsrvbwQxmXhS1+Y5gLU=; b=JM+E5pP9B4LQU02g2YHhKMN7gV0LhGdHhCngat+9gVV0F6WO2TdIKpfZYyCRH+9ngV Cq6E28stvbHb6SAhcaZ/Mb9N8X2xbk579P7KFZW+kkrlwIwAArcy9RcN/14lefcQ69uP i/5g85yVu+FmzmraEWtf+uw+CcGcuro1NK3K8bv3ikrJ7MiExMt6Tsjmk09rMcVhfQa3 OhZIFu7R5XR+flzEGvVbtyjmYJyVIH2glpmV7d8KOpZCRK7DJbfvYXji+goRdGksz4Jk aAb4LemPnHoTqnVT8YqeuoDBU08A8in7CbhUOwBfnsI5qz9Vwd7k5BMbGml2fI9/dfal SINA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=QtsvY4AW; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si13604930ejx.160.2021.10.22.14.33.11; Fri, 22 Oct 2021 14:33:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=QtsvY4AW; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234182AbhJVVdM (ORCPT + 99 others); Fri, 22 Oct 2021 17:33:12 -0400 Received: from [52.101.62.24] ([52.101.62.24]:55010 "EHLO na01-obe.outbound.protection.outlook.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231997AbhJVVdK (ORCPT ); Fri, 22 Oct 2021 17:33:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UvyFu8v0TfAPtXk35TCtX9FBNSJvbQha37iQkOGmA22Y5jjynIZAG1W4AlaBYohjfdhhUrrGH3gUznVXDPAMVcv6RK7oVj3XmTnIi5y0XnpT32yibAQfBS4FlyUFD1mP+P5kN5QmM/8sULB4sNoeVMEy/a2Elritc9Z3EuHXc9wDAk8bjlu+QyFNEJXxmXoHGJ4SQRFD4Pckmt3LLw7VQS/OuoTsopyzM6O21/M32xffJ8dlhnuIyTAdfmZN0nYMH82tUb6yjmUfTCLZ0rnnlh86agjmBqZYt52x9s3opio3fMU9GSv0qrTvAhd/bqWJKSrSTcMbbeFv0+PdoSDJLw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z+W2rI0U0BK9UCAGJnDpsgZCVsrvbwQxmXhS1+Y5gLU=; b=jOHSBSYvZkckT5TDca6KbnJB4aRuVCd/Z4Hs7nDt94O87u4DFP6WPrhRkXXX+uP7LIzdcU3GYWMtbGLM9iX3R7Tbv3LlOhe2mSWkJmCYt7EppdtN6i33/mGKOsST5NYt3XrMRSPZqPdgEYs8DOWMIEU1W/V5/vA6INgBCLav/vwFb6OQt4KSWjLsbgzv7tpkXO0y0puZrUqU3luKzwIthQZu+9FmnlXYoBXdO9mU3xqevfWtulHzJyqMn5ouxSgOBPBCnkeDR7Gl6GDSml5Of73Ek+uxjxXViNH4i0//Z2GcSl/WDo1h6z4GKUHCwrqkIXqAz6By25Z3wdoP0D+V2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z+W2rI0U0BK9UCAGJnDpsgZCVsrvbwQxmXhS1+Y5gLU=; b=QtsvY4AWMes0obUB2z7l5DjUr8DdAGNUJlHrF8H6YwYyHYyVjCQkX+8dycMq1/ZSz6MH13GKnpfD2PHr+G+hmGbIrBpj8CtoOkQBUy4WMIdTZGw9a739IOLNKx14V+QrSH4+dp4EevUq583MhMzXr8fC90fFaTFBzcWlgj2MBic= Received: from MWHPR21MB1593.namprd21.prod.outlook.com (2603:10b6:301:7c::11) by MWHPR21MB1577.namprd21.prod.outlook.com (2603:10b6:301:77::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.4; Fri, 22 Oct 2021 20:58:01 +0000 Received: from MWHPR21MB1593.namprd21.prod.outlook.com ([fe80::240b:d555:8c74:205c]) by MWHPR21MB1593.namprd21.prod.outlook.com ([fe80::240b:d555:8c74:205c%4]) with mapi id 15.20.4649.011; Fri, 22 Oct 2021 20:58:01 +0000 From: Michael Kelley To: Tianyu Lan , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "wei.liu@kernel.org" , Dexuan Cui , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "x86@kernel.org" , "hpa@zytor.com" , "dave.hansen@linux.intel.com" , "luto@kernel.org" , "peterz@infradead.org" , "davem@davemloft.net" , "kuba@kernel.org" , "gregkh@linuxfoundation.org" , "arnd@arndb.de" , "brijesh.singh@amd.com" , "jroedel@suse.de" , Tianyu Lan , "thomas.lendacky@amd.com" , "pgonda@google.com" , "akpm@linux-foundation.org" , "kirill.shutemov@linux.intel.com" , "rppt@kernel.org" , "david@redhat.com" , "aneesh.kumar@linux.ibm.com" , "saravanand@fb.com" , "rientjes@google.com" CC: "linux-arch@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , vkuznets , "konrad.wilk@oracle.com" , "hch@lst.de" , "robin.murphy@arm.com" , "joro@8bytes.org" , "parri.andrea@gmail.com" , "dave.hansen@intel.com" Subject: RE: [PATCH V8.1 5/9] x86/sev-es: Expose sev_es_ghcb_hv_call() to call ghcb hv call out of sev code Thread-Topic: [PATCH V8.1 5/9] x86/sev-es: Expose sev_es_ghcb_hv_call() to call ghcb hv call out of sev code Thread-Index: AQHXx0n2gV45EoRZbEKwYtomMcK0Bqvff3+Q Date: Fri, 22 Oct 2021 20:58:00 +0000 Message-ID: References: <20211021154110.3734294-6-ltykernel@gmail.com> <20211022133721.2123-1-ltykernel@gmail.com> In-Reply-To: <20211022133721.2123-1-ltykernel@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=23f3987a-cec8-4da3-984f-8b375fbd179f;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2021-10-22T20:54:42Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 35474ded-f756-406e-eca4-08d9959ea269 x-ms-traffictypediagnostic: MWHPR21MB1577: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3968; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: yA2Y7WfWQBsXHvKSN9djOm608cPhyvdSg5AZEfG+ovgxPNZ8ogiZz0YpdkxD+/7NI6pQ/k0HYkTmdBdlZdYRgIcmLqnPvO5y7RTlXTrh6t3aC+BrMHQG48yhDIHytxD1eaLHROMvE1xU0+9NOiGODV6SOBLojaBRQd97BGY1+ZL7bQbtNoZwKRAQZdcj0PxqjzGJ8KIPC4wFk97TxyWoUFwWbOh7QLsuo51q9BIetyF5eM+eKaYrnjv4hTTLAEcbBUsltSot9SO8twNeYPqCPnNz0s9R6hfLqDCKtAEzelIrfCGf2uj1ykEXfQHDiY7rKlqx5aSNitQJohmhuKHD6RBlbbheQImCpHlFkDECbExOzoUxV1mTCP0ptAhttw+OJhrzxkDWN95YNJeZgwJXSAoLXecdos8wr31ueaeIcZfXKLP2S3DUgEUV5Noet8YniC5ZuyWtRLsL0EPdSlADx6O4ijW3FiKhs65TqzF05X0Bd36oKufHNHzc6oLOFc0Vt6DlltWesu+Uk3GwFbqCgy5T2ESDBrqOXcpiTPZ/G/hJ5uYSHX9PshiFPdhQCIMExKSxTq1wm9yakozJXWHpVPEyFNMjhgCg0yMyesJ+DFFw+//khuVVNsyiF6XDhQ0v2jAH+lUXteDJaijHAa7438zluWk7x96QOBZuCwcdQRtu5zSapEqDfsBZiOyQ8GWQP/GuxQAUc8okcB/DP1CxTGfvecFu/Vq+yskm81TScRg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR21MB1593.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(9686003)(8936002)(55016002)(4326008)(66946007)(8676002)(6506007)(10290500003)(26005)(66446008)(186003)(33656002)(66476007)(64756008)(71200400001)(66556008)(52536014)(76116006)(508600001)(110136005)(54906003)(316002)(7696005)(86362001)(83380400001)(5660300002)(2906002)(82960400001)(7406005)(122000001)(38100700002)(82950400001)(7416002)(8990500004)(921005)(38070700005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-ch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?us-ascii?Q?M03HyTy9FJjdYBv0iFrWT5YLbWtZLpzQPHnotT/NYBdlEQu54bEBUxvBp6mO?= =?us-ascii?Q?CnSd4UnzfbJp6Vl5WzvdACjN1wOM89L/aVXxj6/AgsyAWBTZFZ1m/Hggusqy?= =?us-ascii?Q?nd85Kd/VJ55XfalA7+FBlwhzaDTwMc9+SnCCnO7br6eyUczg2uSCoUP0iyLI?= =?us-ascii?Q?crByeHJLPulNFBbHxYj6vXed3+JBGTlzPlxBHOQ05V3gabVQG1hNNb48r7Fw?= =?us-ascii?Q?sWV19LjtpxnwDyGHdakLDobwQasgp52YFL74K8/5wBUHR2hDvWxM69iPKFE+?= =?us-ascii?Q?hdwTKvsiHoIo5HRtf+XmlKWBynnCbZJWQWfCUNrC8dPBEFAM2WaaJi+DfhWr?= =?us-ascii?Q?pBRVTsg+ipWAoyvyHvYhiLfQ2Tlw6ej5PK0jettLKYO7hcR0WSeuGmi48soF?= =?us-ascii?Q?QTAV6up0NsQ7+wHnNQ/YSh2SwxBY5EU77hRwK6pqgFS4ZUmIG3tnwi9mMjGp?= =?us-ascii?Q?Cw/RgDH3Ne/JrJqvDVsWHqVjZ50PzOvy8HOp/HU6WQmIXKBFNdfUjbXoqGVr?= =?us-ascii?Q?KoXG6VUf7EqDhl0w99lKdw5V9Qjt4ZM9hp/vam2zirQ+fH0t46amxJVqwttO?= =?us-ascii?Q?9V/sigkgcsJzbwUxzKYt4CKOC1nNTcTd?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR21MB1593.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35474ded-f756-406e-eca4-08d9959ea269 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2021 20:58:01.0209 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mikelley@ntdev.microsoft.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB1577 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tianyu Lan Sent: Friday, October 22, 2021 6:37 = AM >=20 > Hyper-V needs to call ghcb hv call to write/read MSR in Isolation VM. > So expose sev_es_ghcb_hv_call() to call it in the Hyper-V code. >=20 > Hyper-V Isolation VM is unenlightened guests and run a paravisor in the > VMPL0 for communicating and GHCB pages are being allocated and set up by > that paravisor. Linux gets ghcb page pa via MSR_AMD64_SEV_ES_GHCB > from paravisor and should not change it. Add set_ghcb_msr parameter for > sev_es_ghcb_hv_call() and not set ghcb page pa when it's false. >=20 > Signed-off-by: Tianyu Lan > --- > Change since v8: > Fix commit in the sev_es_ghcb_hv_call(). >=20 > arch/x86/include/asm/sev.h | 12 ++++++++++++ > arch/x86/kernel/sev-shared.c | 25 ++++++++++++++++--------- > arch/x86/kernel/sev.c | 13 +++++++------ > 3 files changed, 35 insertions(+), 15 deletions(-) >=20 > diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h > index fa5cd05d3b5b..5b7f7e2b81f7 100644 > --- a/arch/x86/include/asm/sev.h > +++ b/arch/x86/include/asm/sev.h > @@ -81,12 +81,24 @@ static __always_inline void sev_es_nmi_complete(void) > __sev_es_nmi_complete(); > } > extern int __init sev_es_efi_map_ghcbs(pgd_t *pgd); > +extern enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb, > + bool set_ghcb_msr, > + struct es_em_ctxt *ctxt, > + u64 exit_code, u64 exit_info_1, > + u64 exit_info_2); > #else > static inline void sev_es_ist_enter(struct pt_regs *regs) { } > static inline void sev_es_ist_exit(void) { } > static inline int sev_es_setup_ap_jump_table(struct real_mode_header *rm= h) { return 0; } > static inline void sev_es_nmi_complete(void) { } > static inline int sev_es_efi_map_ghcbs(pgd_t *pgd) { return 0; } > +static inline enum > +es_result sev_es_ghcb_hv_call(struct ghcb *ghcb, > + bool set_ghcb_msr, u64 exit_code, The "struct es_em_ctxt *ctxt" argument is missing from this declaration, which would presumably produce a compile error. > + u64 exit_info_1, u64 exit_info_2) > +{ > + return ES_VMM_ERROR; > +} > #endif >=20 > #endif