public inbox for linux-hyperv@vger.kernel.org
 help / color / mirror / Atom feed
From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"romank@linux.microsoft.com" <romank@linux.microsoft.com>
Cc: "kys@microsoft.com" <kys@microsoft.com>,
	"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"decui@microsoft.com" <decui@microsoft.com>,
	"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
	"will@kernel.org" <will@kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"lpieralisi@kernel.org" <lpieralisi@kernel.org>,
	"kw@linux.com" <kw@linux.com>,
	"robh@kernel.org" <robh@kernel.org>,
	"jinankjain@linux.microsoft.com" <jinankjain@linux.microsoft.com>,
	"skinsburskii@linux.microsoft.com"
	<skinsburskii@linux.microsoft.com>,
	"mrathor@linux.microsoft.com" <mrathor@linux.microsoft.com>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v2 2/6] Drivers: hv: Use nested hypercall for post message and signal event
Date: Mon, 7 Jul 2025 11:19:17 -0700	[thread overview]
Message-ID: <32b541e0-bc5f-485a-bfe4-190519b4c150@linux.microsoft.com> (raw)
In-Reply-To: <SN6PR02MB41576CBCA98ECA4C77BCC2D7D44FA@SN6PR02MB4157.namprd02.prod.outlook.com>

On 7/6/2025 8:13 PM, Michael Kelley wrote:
> From: Nuno Das Neves <nunodasneves@linux.microsoft.com> Sent: Thursday, July 3, 2025 3:45 PM
>>
>> When running nested, these hypercalls must be sent to the L0 hypervisor
>> or VMBus will fail.
>>
>> Remove hv_do_nested_hypercall() and hv_do_fast_nested_hypercall8()
>> altogether and open-code these cases, since there are only 2 and all
>> they do is add the nested bit.
>>
>> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
>> Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
>> ---
>>  arch/x86/include/asm/mshyperv.h | 20 --------------------
>>  drivers/hv/connection.c         |  7 +++++--
>>  drivers/hv/hv.c                 |  6 ++++--
>>  3 files changed, 9 insertions(+), 24 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
>> index 5ec92e3e2e37..e00a8431ef8e 100644
>> --- a/arch/x86/include/asm/mshyperv.h
>> +++ b/arch/x86/include/asm/mshyperv.h
>> @@ -111,12 +111,6 @@ 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(u64 control, u64 input1)
>>  {
>> @@ -164,13 +158,6 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
>>  	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(u64 control, u64 input1, u64 input2)
>>  {
>> @@ -222,13 +209,6 @@ static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2)
>>  	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/drivers/hv/connection.c b/drivers/hv/connection.c
>> index be490c598785..47c93cee1ef6 100644
>> --- a/drivers/hv/connection.c
>> +++ b/drivers/hv/connection.c
>> @@ -518,8 +518,11 @@ void vmbus_set_event(struct vmbus_channel *channel)
>>  					 channel->sig_event, 0);
>>  		else
>>  			WARN_ON_ONCE(1);
>> -	} else {
>> -		hv_do_fast_hypercall8(HVCALL_SIGNAL_EVENT, channel->sig_event);
>> +	} else if (hv_nested) {
> 
> As coded, this won't make any hypercall for the non-nested case.
> The "else if (hv_nested)" should be just "else".

Ah, forgot to change this line. Thank you for catching it

Nuno

> 
> Michael
> 
>> +		u64 control = HVCALL_SIGNAL_EVENT;
>> +
>> +		control |= hv_nested ? HV_HYPERCALL_NESTED : 0;
>> +		hv_do_fast_hypercall8(control, channel->sig_event);
>>  	}
>>  }
>>  EXPORT_SYMBOL_GPL(vmbus_set_event);
>> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
>> index 308c8f279df8..b14c5f9e0ef2 100644
>> --- a/drivers/hv/hv.c
>> +++ b/drivers/hv/hv.c
>> @@ -85,8 +85,10 @@ int hv_post_message(union hv_connection_id connection_id,
>>  		else
>>  			status = HV_STATUS_INVALID_PARAMETER;
>>  	} else {
>> -		status = hv_do_hypercall(HVCALL_POST_MESSAGE,
>> -					 aligned_msg, NULL);
>> +		u64 control = HVCALL_POST_MESSAGE;
>> +
>> +		control |= hv_nested ? HV_HYPERCALL_NESTED : 0;
>> +		status = hv_do_hypercall(control, aligned_msg, NULL);
>>  	}
>>
>>  	local_irq_restore(flags);
>> --
>> 2.34.1


  reply	other threads:[~2025-07-07 18:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 22:44 [PATCH v2 0/6] Nested virtualization fixes for root partition Nuno Das Neves
2025-07-03 22:44 ` [PATCH v2 1/6] PCI: hv: Don't load the driver for baremetal " Nuno Das Neves
2025-07-07  3:12   ` Michael Kelley
2025-07-07 16:04   ` Bjorn Helgaas
2025-07-03 22:44 ` [PATCH v2 2/6] Drivers: hv: Use nested hypercall for post message and signal event Nuno Das Neves
2025-07-07  3:13   ` Michael Kelley
2025-07-07 18:19     ` Nuno Das Neves [this message]
2025-07-03 22:44 ` [PATCH v2 3/6] x86/hyperv: Fix usage of cpu_online_mask to get valid cpu Nuno Das Neves
2025-07-07  3:13   ` Michael Kelley
2025-07-03 22:44 ` [PATCH v2 4/6] x86/hyperv: Clean up hv_map/unmap_interrupt() return values Nuno Das Neves
2025-07-07  3:14   ` Michael Kelley
2025-07-03 22:44 ` [PATCH v2 5/6] x86: hyperv: Expose hv_map_msi_interrupt function Nuno Das Neves
2025-07-07  3:14   ` Michael Kelley
2025-07-07 18:23     ` Nuno Das Neves
2025-07-03 22:44 ` [PATCH v2 6/6] PCI: hv: Use the correct hypercall for unmasking interrupts on nested Nuno Das Neves
2025-07-07  3:15   ` Michael Kelley
2025-07-07 16:05   ` Bjorn Helgaas
2025-07-09 23:51 ` [PATCH v2 0/6] Nested virtualization fixes for root partition Wei Liu
2025-07-10  0:33   ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32b541e0-bc5f-485a-bfe4-190519b4c150@linux.microsoft.com \
    --to=nunodasneves@linux.microsoft.com \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=jinankjain@linux.microsoft.com \
    --cc=kw@linux.com \
    --cc=kys@microsoft.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=mingo@redhat.com \
    --cc=mrathor@linux.microsoft.com \
    --cc=robh@kernel.org \
    --cc=romank@linux.microsoft.com \
    --cc=skinsburskii@linux.microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=wei.liu@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox