qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bui Quang Minh <minhquangbui99@gmail.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org, "David Woodhouse" <dwmw2@infradead.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [REPOST PATCH v3 5/5] amd_iommu: report x2APIC support to the operating system
Date: Mon, 15 May 2023 21:41:55 +0700	[thread overview]
Message-ID: <3cee23fd-fae1-458b-2b8b-656a2ff3195b@gmail.com> (raw)
In-Reply-To: <20230514164040-mutt-send-email-mst@kernel.org>

On 5/15/23 03:44, Michael S. Tsirkin wrote:
> On Sun, May 14, 2023 at 03:55:11PM +0700, Bui Quang Minh wrote:
>> On 5/12/23 21:39, Michael S. Tsirkin wrote:
>>> On Tue, Apr 11, 2023 at 09:24:40PM +0700, Bui Quang Minh wrote:
>>>> This commit adds XTSup configuration to let user choose to whether enable
>>>> this feature or not. When XTSup is enabled, additional bytes in IRTE with
>>>> enabled guest virtual VAPIC are used to support 32-bit destination id.
>>>>
>>>> Additionally, this commit changes to use IVHD type 0x11 in ACPI table for
>>>> feature report to operating system. This is because Linux does not use
>>>> XTSup in IOMMU Feature Reporting field of IVHD type 0x10 but only use XTSup
>>>> bit in EFR Register Image of IVHD 0x11 to indicate x2APIC support (see
>>>> init_iommu_one in linux/drivers/iommu/amd/init.c)
>>>>
>>>> Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
>>>
>>> I'm concerned that switching to type 11 will break some older guests.
>>> It would be better if we could export both type 10 and type 11
>>> ivhd. A question however would be how does this interact
>>> with older guests. For example:
>>> https://lists.linuxfoundation.org/pipermail/iommu/2016-January/015310.html
>>> it looks like linux before 2016 only expected one ivhd entry?
>>
>> Export both type 0x10 and 0x11 looks reasonable to me. Before the above
>> commit, I see that Linux still loops through multiple ivhd but only handles
>> one with type 0x10. On newer kernel, it will choose to handle the type that
>> appears last corresponding the first devid, which is weird in my opinion.
>> +static u8 get_highest_supported_ivhd_type(struct acpi_table_header *ivrs)
>> +{
>> +	u8 *base = (u8 *)ivrs;
>> +	struct ivhd_header *ivhd = (struct ivhd_header *)
>> +					(base + IVRS_HEADER_LENGTH);
>> +	u8 last_type = ivhd->type;
>> +	u16 devid = ivhd->devid;
>> +
>> +	while (((u8 *)ivhd - base < ivrs->length) &&
>> +	       (ivhd->type <= ACPI_IVHD_TYPE_MAX_SUPPORTED)) {
>> +		u8 *p = (u8 *) ivhd;
>> +
>> +		if (ivhd->devid == devid)
>> +			last_type = ivhd->type;
>> +		ivhd = (struct ivhd_header *)(p + ivhd->length);
>> +	}
>> +
>> +	return last_type;
>> +}
> 
> Yes I don't get the logic here either.
> Talk to kernel devs who wrote this?
> 
> commit 8c7142f56fedfc6824b5bca56fee1f443e01746b
> Author: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Date:   Fri Apr 1 09:05:59 2016 -0400
> 
>      iommu/amd: Use the most comprehensive IVHD type that the driver can support
>      
>      The IVRS in more recent AMD system usually contains multiple
>      IVHD block types (e.g. 0x10, 0x11, and 0x40) for each IOMMU.
>      The newer IVHD types provide more information (e.g. new features
>      specified in the IOMMU spec), while maintain compatibility with
>      the older IVHD type.
>      
>      Having multiple IVHD type allows older IOMMU drivers to still function
>      (e.g. using the older IVHD type 0x10) while the newer IOMMU driver can use
>      the newer IVHD types (e.g. 0x11 and 0x40). Therefore, the IOMMU driver
>      should only make use of the newest IVHD type that it can support.
>      
>      This patch adds new logic to determine the highest level of IVHD type
>      it can support, and use it throughout the to initialize the driver.
>      This requires adding another pass to the IVRS parsing to determine
>      appropriate IVHD type (see function get_highest_supported_ivhd_type())
>      before parsing the contents.
>      
>      [Vincent: fix the build error of IVHD_DEV_ACPI_HID flag not found]
>      
>      Signed-off-by: Wan Zongshun <vincent.wan@amd.com>
>      Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>      Signed-off-by: Joerg Roedel <jroedel@suse.de>

I've sent a email to talk to kernel developers about this function. Here 
is the link to the email: 
https://lore.kernel.org/all/e8a87c2b-a29a-ccf9-49c6-3cfceaa208bb@gmail.com/


  reply	other threads:[~2023-05-15 14:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 14:24 [REPOST PATCH v3 0/5] Support x2APIC mode with TCG accelerator Bui Quang Minh
2023-04-11 14:24 ` [REPOST PATCH v3 1/5] i386/tcg: implement x2APIC registers MSR access Bui Quang Minh
2023-04-11 14:24 ` [REPOST PATCH v3 2/5] apic: add support for x2APIC mode Bui Quang Minh
2023-04-11 14:24 ` [REPOST PATCH v3 3/5] apic, i386/tcg: add x2apic transitions Bui Quang Minh
2023-04-11 14:24 ` [REPOST PATCH v3 4/5] intel_iommu: allow Extended Interrupt Mode when using userspace APIC Bui Quang Minh
2023-05-18 20:00   ` Michael S. Tsirkin
2023-04-11 14:24 ` [REPOST PATCH v3 5/5] amd_iommu: report x2APIC support to the operating system Bui Quang Minh
2023-05-12 14:39   ` Michael S. Tsirkin
2023-05-14  8:55     ` Bui Quang Minh
2023-05-14 20:44       ` Michael S. Tsirkin
2023-05-15 14:41         ` Bui Quang Minh [this message]
2023-05-22 16:59       ` Bui Quang Minh
2023-04-21  7:57 ` [REPOST PATCH v3 0/5] Support x2APIC mode with TCG accelerator Michael S. Tsirkin
2023-04-21 15:46   ` Bui Quang Minh
2023-05-12 14:19 ` Bui Quang Minh

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=3cee23fd-fae1-458b-2b8b-656a2ff3195b@gmail.com \
    --to=minhquangbui99@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=dwmw2@infradead.org \
    --cc=eduardo@habkost.net \
    --cc=imammedo@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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;
as well as URLs for NNTP newsgroup(s).