qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bui Quang Minh <minhquangbui99@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH v2 1/5] i386/tcg: implement x2APIC registers MSR access
Date: Tue, 28 Mar 2023 23:33:42 +0700	[thread overview]
Message-ID: <2fa1ed57-76ff-bea0-d0df-e3fa32d422f5@gmail.com> (raw)
In-Reply-To: <d04ebc4920c336dd6dc87ae0e1e25693b40d6e4d.camel@infradead.org>

On 3/27/23 23:56, David Woodhouse wrote:
> On Sun, 2023-03-26 at 12:20 +0700, Bui Quang Minh wrote:
>>
>> +static void apic_mem_write(void *opaque, hwaddr addr, uint64_t val,
>> +                           unsigned size)
>> +{
>> +    int index = (addr >> 4) & 0xff;
>> +
>> +    if (size < 4) {
>> +        return;
>> +    }
>> +
>> +    if (addr > 0xfff || !index) {
>> +        /* MSI and MMIO APIC are at the same memory location,
>> +         * but actually not on the global bus: MSI is on PCI bus
>> +         * APIC is connected directly to the CPU.
>> +         * Mapping them on the global bus happens to work because
>> +         * MSI registers are reserved in APIC MMIO and vice versa.
>> */
>> +        MSIMessage msi = { .address = addr, .data = val };
>> +        apic_send_msi(&msi);
>> +        return;
>> +    }
> 
> I know you're just moving this bit around, but note that it means we
> *can't* implement the 15-bit MSI trick as things stand, because those
> extra 7 bits end up in bits 4-11 of the address, and that means the
> 'addr > 0xfff' check isn't correct any more.
> 
> However, that's only relevant in X2APIC mode... and there's no MMIO
> access to registers in X2APIC mode. So the check could perhaps become
> something like...
> 
>      DeviceState *apic = cpu_get_current_apic();
>      if (!apic || is_x2apic_mode(apic) || addr > 0xfff || !index) {
>          /* MSI and MMIO APIC are at the same memory location,
>           * but actually not on the global bus: MSI is on PCI bus
>           * APIC is connected directly to the CPU.
>           * Mapping them on the global bus happens to work because
>           * MSI registers are reserved in xAPIC MMIO and vice versa.
>           * In X2APIC mode, there is no MMIO and bits 4-11 of the
>           * address *might* be used to encode the extended dest ID.
>           */
> 
>          MSIMessage msi = ...

In my opinion, I think the with the emulated interrupt remap hardware we 
don't need to do MSI trick. The behavior is the same with real hardware, 
in order to use x2APIC an interrupt remap hardware is required, the OS 
will configure the interrupt source (IOxAPIC, MSI-capable) to use the 
remappable format for interrupt request.


  reply	other threads:[~2023-03-28 16:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-26  5:20 [PATCH v2 0/5] Support x2APIC mode with TCG accelerator Bui Quang Minh
2023-03-26  5:20 ` [PATCH v2 1/5] i386/tcg: implement x2APIC registers MSR access Bui Quang Minh
2023-03-27 16:56   ` David Woodhouse
2023-03-28 16:33     ` Bui Quang Minh [this message]
2023-03-26  5:20 ` [PATCH v2 2/5] apic: add support for x2APIC mode Bui Quang Minh
2023-03-27 11:04   ` David Woodhouse
2023-03-27 15:33     ` Bui Quang Minh
2023-03-27 15:37       ` David Woodhouse
2023-03-27 15:45         ` Bui Quang Minh
2023-03-27 16:22           ` David Woodhouse
2023-03-27 16:35             ` Bui Quang Minh
2023-03-27 16:49               ` David Woodhouse
2023-03-28 15:58                 ` Bui Quang Minh
2023-03-29 14:53                   ` Bui Quang Minh
2023-03-29 15:30                     ` Bui Quang Minh
2023-03-30  8:28                       ` Igor Mammedov
2023-04-03 16:01                         ` Bui Quang Minh
2023-04-03 10:27                       ` David Woodhouse
2023-04-03 16:38                         ` Bui Quang Minh
2023-04-09 14:31                           ` Bui Quang Minh
2023-03-26  5:20 ` [PATCH v2 3/5] apic, i386/tcg: add x2apic transitions Bui Quang Minh
2023-03-26  5:20 ` [PATCH v2 4/5] intel_iommu: allow Extended Interrupt Mode when using userspace APIC Bui Quang Minh
2023-03-26  5:20 ` [PATCH v2 5/5] amd_iommu: report x2APIC support to the operating system 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=2fa1ed57-76ff-bea0-d0df-e3fa32d422f5@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).