public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
To: "Michael Kelley (LINUX)" <mikelley@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>
Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	Sunil Muthuswamy <sunilmut@microsoft.com>,
	KY Srinivasan <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Dexuan Cui <decui@microsoft.com>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>
Subject: Re: [PATCH] iommu/hyper-v: Allow hyperv irq remapping without x2apic
Date: Fri, 11 Nov 2022 14:53:59 -0800	[thread overview]
Message-ID: <2f721208-d169-2baa-fa1f-b8450e80ddd7@linux.microsoft.com> (raw)
In-Reply-To: <BYAPR21MB168819214A20DF2E4835E763D7009@BYAPR21MB1688.namprd21.prod.outlook.com>

On 11/11/2022 9:58 AM, Michael Kelley (LINUX) wrote:
> From: Wei Liu <wei.liu@kernel.org> Sent: Friday, November 11, 2022 9:27 AM
>>
>> On Fri, Nov 11, 2022 at 04:55:22PM +0000, Michael Kelley (LINUX) wrote:
>>> From: Wei Liu <wei.liu@kernel.org> Sent: Friday, November 11, 2022 8:33 AM
>>>>
>>>> Hi Tianyu
>>>>
>>>> On Wed, Nov 09, 2022 at 11:07:33AM -0800, Nuno Das Neves wrote:
>>>>> If x2apic is not available, hyperv-iommu skips remapping
>>>>> irqs. This breaks root partition which always needs irqs
>>>>> remapped.
>>>>>
>>>>> Fix this by allowing irq remapping regardless of x2apic,
>>>>> and change hyperv_enable_irq_remapping() to return
>>>>> IRQ_REMAP_XAPIC_MODE in case x2apic is missing.
>>>>>
>>>>
>>>> Do you remember why it was x2apic only?
>>>>
>>>> We tested this patch on different VM SKUs and it worked fine. I'm just
>>>> wondering if there would be some subtle breakages that we couldn't
>>>> easily test.
>>>>
>>>> Thanks,
>>>> Wei.
>>>
>>> My recollection is that originally Hyper-V provided the x2apic in the
>>> guest only when the number of vCPUs exceeded 255, and that was
>>> the only case where IRQ remapping was needed.  The intent was to
>>> not disturb the case where # of vCPUs was < 255 and the xapic is used.
>>> I don't remember there being any potential for subtle breakages.
>>
>> Thanks for the information.
>>
>>>
>>> I think more recent versions of Hyper-V now provide the x2apic
>>> in the guest in some cases when # of vCPUs is < 255.
>>>
>>
>> On Azure the default for AMD SKUs is still xapic unless the number of
>> VCPUs exceeds 2XX (can't remember the exact number -- maybe it is 255).
> 
> I don't think Azure has any VM sizes based on AMD processors with more
> than 255 vCPUs.  All the >255 vCPUs VM sizes use Intel processors.
> 
> FWIW, I have a D2ds_v5 VM (2 CPUs & Intel processor) that shows an
> x2apic instead of an xapic.  My memory is vague, but I think that's the
> requirements to get an x2apic in a smaller VM:  must be a "v5" series and
> must be Intel processor.
> 
> Michael
>

Yes this seems to be the case, although I didn't realise it until now!
I sort of assumed since x2apic has been around so long, all the intel VMs
just had it enabled...

>>
>> Nuno, can you list the tests you've done? They will need to cover Linux
>> running as a normal guest on Azure and Hyper-V.
>>>> Thanks,
>> Wei.
>>

I've tested this patch on these Azure SKUs:
- Standard_D2S_v2 (intel xapic)
- Standard_D4ds_v4 (intel xapic)
- Standard_D4ds_v5 (intel x2apic)
- Standard_D4ads_v5 (amd xapic)

I've tested with linux Dom0 (nested hyperv root partition) and as a
regular L1 guest.

>>
>>> Michael
>>>
>>>>
>>>>> Tested with root and non-root hyperv partitions.
>>>>>
>>>>> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
>>>>> ---
>>>>>  drivers/iommu/Kconfig        | 6 +++---
>>>>>  drivers/iommu/hyperv-iommu.c | 7 ++++---
>>>>>  2 files changed, 7 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
>>>>> index dc5f7a156ff5..cf7433652db0 100644
>>>>> --- a/drivers/iommu/Kconfig
>>>>> +++ b/drivers/iommu/Kconfig
>>>>> @@ -474,13 +474,13 @@ config QCOM_IOMMU
>>>>>  	  Support for IOMMU on certain Qualcomm SoCs.
>>>>>
>>>>>  config HYPERV_IOMMU
>>>>> -	bool "Hyper-V x2APIC IRQ Handling"
>>>>> +	bool "Hyper-V IRQ Handling"
>>>>>  	depends on HYPERV && X86
>>>>>  	select IOMMU_API
>>>>>  	default HYPERV
>>>>>  	help
>>>>> -	  Stub IOMMU driver to handle IRQs as to allow Hyper-V Linux
>>>>> -	  guests to run with x2APIC mode enabled.
>>>>> +	  Stub IOMMU driver to handle IRQs to support Hyper-V Linux
>>>>> +	  guest and root partitions.
>>>>>
>>>>>  config VIRTIO_IOMMU
>>>>>  	tristate "Virtio IOMMU driver"
>>>>> diff --git a/drivers/iommu/hyperv-iommu.c b/drivers/iommu/hyperv-iommu.c
>>>>> index e190bb8c225c..abd1826a9e63 100644
>>>>> --- a/drivers/iommu/hyperv-iommu.c
>>>>> +++ b/drivers/iommu/hyperv-iommu.c
>>>>> @@ -123,8 +123,7 @@ static int __init hyperv_prepare_irq_remapping(void)
>>>>>  	const struct irq_domain_ops *ops;
>>>>>
>>>>>  	if (!hypervisor_is_type(X86_HYPER_MS_HYPERV) ||
>>>>> -	    x86_init.hyper.msi_ext_dest_id() ||
>>>>> -	    !x2apic_supported())
>>>>> +	    x86_init.hyper.msi_ext_dest_id())
>>>>>  		return -ENODEV;
>>>>>
>>>>>  	if (hv_root_partition) {
>>>>> @@ -170,7 +169,9 @@ static int __init hyperv_prepare_irq_remapping(void)
>>>>>
>>>>>  static int __init hyperv_enable_irq_remapping(void)
>>>>>  {
>>>>> -	return IRQ_REMAP_X2APIC_MODE;
>>>>> +	if (x2apic_supported())
>>>>> +		return IRQ_REMAP_X2APIC_MODE;
>>>>> +	return IRQ_REMAP_XAPIC_MODE;
>>>>>  }
>>>>>
>>>>>  struct irq_remap_ops hyperv_irq_remap_ops = {
>>>>> --
>>>>> 2.25.1
>>>>>

  reply	other threads:[~2022-11-11 22:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 19:07 [PATCH] iommu/hyper-v: Allow hyperv irq remapping without x2apic Nuno Das Neves
2022-11-10 13:41 ` Stanislav Kinsburskii
2022-11-11 16:32 ` Wei Liu
2022-11-11 16:55   ` Michael Kelley (LINUX)
2022-11-11 17:27     ` Wei Liu
2022-11-11 17:58       ` Michael Kelley (LINUX)
2022-11-11 22:53         ` Nuno Das Neves [this message]
2022-11-14 13:59           ` Wei Liu
2022-11-14 19:09             ` Michael Kelley (LINUX)
2022-11-16  1:25               ` Nuno Das Neves
2022-11-16 18:49                 ` Michael Kelley (LINUX)

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=2f721208-d169-2baa-fa1f-b8450e80ddd7@linux.microsoft.com \
    --to=nunodasneves@linux.microsoft.com \
    --cc=Tianyu.Lan@microsoft.com \
    --cc=decui@microsoft.com \
    --cc=dwmw2@infradead.org \
    --cc=haiyangz@microsoft.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=sunilmut@microsoft.com \
    --cc=wei.liu@kernel.org \
    --cc=will@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