All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Sairaj Kodilkar" <sarunkod@amd.com>,
	qemu-devel@nongnu.org
Cc: mst@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com,
	richard.henderson@linaro.org, eduardo@habkost.net,
	suravee.suthikulpanit@amd.com, alejandro.j.jimenez@oracle.com,
	joao.m.martins@oracle.com
Subject: Re: [PATCH v3 2/2] hw/i386/amd_iommu: Fix xtsup when vcpus < 255
Date: Mon, 19 May 2025 13:05:00 +0530	[thread overview]
Message-ID: <4613b159-9b72-4686-9cde-ae541ebdc78b@amd.com> (raw)
In-Reply-To: <e10a625b-31d2-4759-b775-9b7d8409de53@linaro.org>

Hi Philippe,


On 5/16/2025 8:08 PM, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> On 16/5/25 12:05, Sairaj Kodilkar wrote:
>> From: Vasant Hegde <vasant.hegde@amd.com>
>>
>> If vCPUs > 255 then x86 common code (x86_cpus_init()) call kvm_enable_x2apic().
>> But if vCPUs <= 255 then the common code won't calls kvm_enable_x2apic().
>>
>> This is because commit 8c6619f3e692 ("hw/i386/amd_iommu: Simplify non-KVM
>> checks on XTSup feature") removed the call to kvm_enable_x2apic when xtsup
>> is "on", which break things when guest is booted with x2apic mode and
>> there are <= 255 vCPUs.
>>
>> Fix this by adding back kvm_enable_x2apic() call when xtsup=on.
>>
>> Fixes: 8c6619f3e692 ("hw/i386/amd_iommu: Simplify non-KVM checks on XTSup
>> feature")
>> Reported-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
>> Tested-by: Tested-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
>> Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Cc: Joao Martins <joao.m.martins@oracle.com>
>> Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
>> Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com>
>> ---
>>   hw/i386/amd_iommu.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
>> index df8ba5d39ada..af85706b8a0d 100644
>> --- a/hw/i386/amd_iommu.c
>> +++ b/hw/i386/amd_iommu.c
>> @@ -1649,6 +1649,14 @@ static void amdvi_sysbus_realize(DeviceState *dev,
>> Error **errp)
>>           exit(EXIT_FAILURE);
>>       }
>>   +    if (s->xtsup) {
> 
> I suppose we need:
> 
>        if (s->xtsup && kvm_enabled()) {
> 
> otherwise that will trigger back the problem I tried to fix.
> Did you try building QEMU with KVM disabled?

My understanding is if KVM is disabled then kvm_irqchip_is_split() will return
false and we exit on below condition check.

Yes. I had tried `configure --disable-kvm` and it was built fine.

-Vasant

> 
>> +        if (kvm_irqchip_is_split() && !kvm_enable_x2apic()) {
>> +            error_report("AMD IOMMU xtsup=on requires x2APIC support on "
>> +                          "the KVM side");
>> +            exit(EXIT_FAILURE);
>> +        }
>> +    }
>> +
>>       pci_setup_iommu(bus, &amdvi_iommu_ops, s);
>>       amdvi_init(s);
>>   }
> 



  reply	other threads:[~2025-05-19  7:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16 10:05 [PATCH v3 0/2] amd_iommu: Fixes Sairaj Kodilkar
2025-05-16 10:05 ` [PATCH v3 1/2] hw/i386/amd_iommu: Fix device setup failure when PT is on Sairaj Kodilkar
2025-05-16 14:43   ` Philippe Mathieu-Daudé
2025-05-19  3:59     ` Sairaj Kodilkar
2025-05-16 10:05 ` [PATCH v3 2/2] hw/i386/amd_iommu: Fix xtsup when vcpus < 255 Sairaj Kodilkar
2025-05-16 14:38   ` Philippe Mathieu-Daudé
2025-05-19  7:35     ` Vasant Hegde [this message]
2025-05-16 10:36 ` [PATCH v3 0/2] amd_iommu: Fixes Michael S. Tsirkin
2025-05-16 10:45   ` Sairaj Kodilkar
2025-06-02 20:54 ` Michael Tokarev
2025-06-10  8:33   ` Sairaj Kodilkar

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=4613b159-9b72-4686-9cde-ae541ebdc78b@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=alejandro.j.jimenez@oracle.com \
    --cc=eduardo@habkost.net \
    --cc=joao.m.martins@oracle.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sarunkod@amd.com \
    --cc=suravee.suthikulpanit@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.