Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1393713rwb; Wed, 14 Dec 2022 09:36:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6HBcCtjWU69kpWYNP+NSVFfKmt+SSYVP6eHS0+sekVV7dOWOtxzvsg88W1bMpOu6cHLSrG X-Received: by 2002:a17:906:7209:b0:7ad:8057:4f06 with SMTP id m9-20020a170906720900b007ad80574f06mr12142987ejk.59.1671039409766; Wed, 14 Dec 2022 09:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671039409; cv=none; d=google.com; s=arc-20160816; b=k7cQZLBDsEMuzmugI1Scgf8sjQJKwUrJIDkmbubWiwJZIh+FRrtmUbI6FptYpzHYDl outOqL7DzSiyIsRu8ROG+jRpl2mHsQNJC8dReCRX7DY6fHcgL8GYM7WGugFGiIkig7h8 Nevh1dUVxZwLrrBGj7Qrfxtoj0EiLvgeedAg3u2yjMdthG5SUQ7EC/5ypaeeeLzDWooU OBvkSTfPK9RcOfAYGj1dHrG2nBJ0tPYCyzoWee/qG9EpIbJe9fKqzVR2v8r2bi9n4lDO KEZ5TXV17GR1LX43zmF76u62/gczcgTl64FlBmlFw3at9xmHfEUZX3acvYmDLAf8++jf r3qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=JbIaMBIdK52AjMoBMrBke3Z1zrJcQBz3xIZyjvUMOSw=; b=Y6AcL65Ww5VsFLvjG7ggISn+j+4Zl6g6QvboFkWY9IkIsusazav8YOVRXOln2ltb0W dwFZO1PnBv/qy7tUVNtMZbNx5ma6U4F829sNcFHwTe7jyWHqdpi8tg5vxglti3FUBSMf ggyLnz9p/LWchJjG3sSAgreUIfo+vMXj3vd6mVHy/pShYP/BL/CoEIxjzHONUd977jzw bX2fEdSbt6ABtlNOd0ymjHyYqb0YkrXy3uHNzKUVPqfJV80FlcjoCyrk5yPZvoHDJW8R Eb78fQX2xiTxSo3y7Jd07VRn8f2xm0G3lQhYBpwJbjCSzfbW6lJUXIoMQVXwHfazggIK vI0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="RD/1XoCF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw16-20020a1709066a1000b0077cfdda438csi12449583ejc.35.2022.12.14.09.36.32; Wed, 14 Dec 2022 09:36:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="RD/1XoCF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238699AbiLNRZn (ORCPT + 69 others); Wed, 14 Dec 2022 12:25:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238566AbiLNRZj (ORCPT ); Wed, 14 Dec 2022 12:25:39 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EE3A525E92; Wed, 14 Dec 2022 09:25:35 -0800 (PST) Received: from [192.168.0.5] (75-172-37-193.tukw.qwest.net [75.172.37.193]) by linux.microsoft.com (Postfix) with ESMTPSA id AB56F20B87CB; Wed, 14 Dec 2022 09:25:34 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AB56F20B87CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1671038734; bh=JbIaMBIdK52AjMoBMrBke3Z1zrJcQBz3xIZyjvUMOSw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=RD/1XoCFPyhMxLcfEZI0L+WKfcCHHpnd09gYMgsFywjiUbSjlTKH6+qDVtapOjSrA 2xod3Cox6EJ/B6+nnoP6czuSDBPAVDpuhTZc1sg7I6WlYzSG29d+FiLucQ9TH2XcRJ nO9OYDt4/XUqJwOt/0pQGfwoDgVqbAx8XjdG33Mc= Message-ID: <2db76a30-f699-292a-b181-a65c470de120@linux.microsoft.com> Date: Wed, 14 Dec 2022 09:25:34 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH v9 3/5] x86/hyperv: Add an interface to do nested hypercalls Content-Language: en-US To: Jinank Jain , jinankjain@microsoft.com Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, arnd@arndb.de, peterz@infradead.org, jpoimboe@kernel.org, seanjc@google.com, kirill.shutemov@linux.intel.com, ak@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, anrayabh@linux.microsoft.com, mikelley@microsoft.com References: <39cb54b306e2fd751bfa91c26b4e3eb78a9f098d.1670749201.git.jinankjain@linux.microsoft.com> From: Nuno Das Neves In-Reply-To: <39cb54b306e2fd751bfa91c26b4e3eb78a9f098d.1670749201.git.jinankjain@linux.microsoft.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/13/2022 10:33 PM, Jinank Jain wrote: > According to TLFS, in order to communicate to L0 hypervisor there needs > to be an additional bit set in the control register. This communication > is required to perform privileged instructions which can only be > performed by L0 hypervisor. An example of that could be setting up the > VMBus infrastructure. > > Signed-off-by: Jinank Jain > --- > arch/x86/include/asm/hyperv-tlfs.h | 3 ++- > arch/x86/include/asm/mshyperv.h | 42 +++++++++++++++++++++++++++--- > include/asm-generic/hyperv-tlfs.h | 1 + > 3 files changed, 41 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h > index b5019becb618..7758c495541d 100644 > --- a/arch/x86/include/asm/hyperv-tlfs.h > +++ b/arch/x86/include/asm/hyperv-tlfs.h > @@ -380,7 +380,8 @@ struct hv_nested_enlightenments_control { > __u32 reserved:31; > } features; > struct { > - __u32 reserved; > + __u32 inter_partition_comm:1; > + __u32 reserved:31; > } hypercallControls; > } __packed; > > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h > index c38e4c66a3ac..9e5535044ed0 100644 > --- a/arch/x86/include/asm/mshyperv.h > +++ b/arch/x86/include/asm/mshyperv.h > @@ -74,10 +74,16 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output) > return hv_status; > } > > +/* Hypercall to the L0 hypervisor */ > +static inline u64 hv_do_nested_hypercall(u64 control, void *input, void *output) > +{ > + return hv_do_hypercall(control | HV_HYPERCALL_NESTED, input, output); > +} > + > /* Fast hypercall with 8 bytes of input and no output */ > -static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1) > +static inline u64 _hv_do_fast_hypercall8(u64 control, u64 input1) > { > - u64 hv_status, control = (u64)code | HV_HYPERCALL_FAST_BIT; > + u64 hv_status; > > #ifdef CONFIG_X86_64 > { > @@ -105,10 +111,24 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1) > return hv_status; > } > > +static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1) > +{ > + u64 control = (u64)code | HV_HYPERCALL_FAST_BIT; > + > + return _hv_do_fast_hypercall8(control, input1); > +} > + > +static inline u64 hv_do_fast_nested_hypercall8(u16 code, u64 input1) > +{ > + u64 control = (u64)code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED; > + > + return _hv_do_fast_hypercall8(control, input1); > +} > + > /* Fast hypercall with 16 bytes of input */ > -static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2) > +static inline u64 _hv_do_fast_hypercall16(u64 control, u64 input1, u64 input2) > { > - u64 hv_status, control = (u64)code | HV_HYPERCALL_FAST_BIT; > + u64 hv_status; > > #ifdef CONFIG_X86_64 > { > @@ -139,6 +159,20 @@ static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2) > return hv_status; > } > > +static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2) > +{ > + u64 control = (u64)code | HV_HYPERCALL_FAST_BIT; > + > + return _hv_do_fast_hypercall16(control, input1, input2); > +} > + > +static inline u64 hv_do_fast_nested_hypercall16(u16 code, u64 input1, u64 input2) > +{ > + u64 control = (u64)code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED; > + > + return _hv_do_fast_hypercall16(control, input1, input2); > +} > + > extern struct hv_vp_assist_page **hv_vp_assist_page; > > static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu) > diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h > index b17c6eeb9afa..e61ee461c4fc 100644 > --- a/include/asm-generic/hyperv-tlfs.h > +++ b/include/asm-generic/hyperv-tlfs.h > @@ -194,6 +194,7 @@ enum HV_GENERIC_SET_FORMAT { > #define HV_HYPERCALL_VARHEAD_OFFSET 17 > #define HV_HYPERCALL_VARHEAD_MASK GENMASK_ULL(26, 17) > #define HV_HYPERCALL_RSVD0_MASK GENMASK_ULL(31, 27) > +#define HV_HYPERCALL_NESTED BIT_ULL(31) > #define HV_HYPERCALL_REP_COMP_OFFSET 32 > #define HV_HYPERCALL_REP_COMP_1 BIT_ULL(32) > #define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32) Reviewed-by: Nuno Das Neves