qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, Peter Xu <peterx@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	Eduardo Habkost <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/5] apic: add send_msi() to APICCommonClass
Date: Tue, 27 Sep 2016 15:55:17 +0200	[thread overview]
Message-ID: <20160927135517.GB26148@potion> (raw)
In-Reply-To: <20160926143834.7e0b6b52@nial.brq.redhat.com>

2016-09-26 14:38+0200, Igor Mammedov:
> On Thu, 22 Sep 2016 23:04:29 +0200
> Radim Krčmář <rkrcmar@redhat.com> wrote:
> 
>> The MMIO based interface to APIC doesn't work well with MSIs that have
>> upper address bits set (remapped x2APIC MSIs).  A specialized interface
>> is a quick and dirty way to avoid the shortcoming.
>> 
>> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
>> ---
>>  hw/i386/kvm/apic.c              | 19 +++++++++++++------
>>  hw/i386/xen/xen_apic.c          |  6 ++++++
>>  hw/intc/apic.c                  |  6 ++++++
>>  include/hw/i386/apic_internal.h |  4 ++++
>>  4 files changed, 29 insertions(+), 6 deletions(-)
>> 
>> diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c
>> index feb00024f20c..7cc1acd63d32 100644
>> --- a/hw/i386/kvm/apic.c
>> +++ b/hw/i386/kvm/apic.c
>> @@ -168,6 +168,17 @@ static void kvm_apic_external_nmi(APICCommonState *s)
>>      run_on_cpu(CPU(s->cpu), do_inject_external_nmi, s);
>>  }
>>  
>> +static void kvm_send_msi(MSIMessage *msg)
>> +{
>> +    int ret;
>> +
>> +    ret = kvm_irqchip_send_msi(kvm_state, *msg);
>> +    if (ret < 0) {
>> +        fprintf(stderr, "KVM: injection failed, MSI lost (%s)\n",
>> +                strerror(-ret));
>> +    }
>> +}
>> +
>>  static uint64_t kvm_apic_mem_read(void *opaque, hwaddr addr,
>>                                    unsigned size)
>>  {
>> @@ -178,13 +189,8 @@ static void kvm_apic_mem_write(void *opaque, hwaddr addr,
>>                                 uint64_t data, unsigned size)
>>  {
>>      MSIMessage msg = { .address = addr, .data = data };
>> -    int ret;
>>  
>> -    ret = kvm_irqchip_send_msi(kvm_state, msg);
>> -    if (ret < 0) {
>> -        fprintf(stderr, "KVM: injection failed, MSI lost (%s)\n",
>> -                strerror(-ret));
>> -    }
>> +    kvm_send_msi(&msg);
>>  }
>>  
>>  static const MemoryRegionOps kvm_apic_io_ops = {
>> @@ -231,6 +237,7 @@ static void kvm_apic_class_init(ObjectClass *klass, void *data)
>>      k->enable_tpr_reporting = kvm_apic_enable_tpr_reporting;
>>      k->vapic_base_update = kvm_apic_vapic_base_update;
>>      k->external_nmi = kvm_apic_external_nmi;
>> +    k->send_msi = kvm_send_msi;
>>  }
>>  
>>  static const TypeInfo kvm_apic_info = {
>> diff --git a/hw/i386/xen/xen_apic.c b/hw/i386/xen/xen_apic.c
>> index 21d68ee04b0a..55769eba7ede 100644
>> --- a/hw/i386/xen/xen_apic.c
>> +++ b/hw/i386/xen/xen_apic.c
>> @@ -68,6 +68,11 @@ static void xen_apic_external_nmi(APICCommonState *s)
>>  {
>>  }
>>  
>> +static void xen_send_msi(MSIMessage *msi)
>> +{
>> +    xen_hvm_inject_msi(msi->address, msi->data);
>> +}
>> +
>>  static void xen_apic_class_init(ObjectClass *klass, void *data)
>>  {
>>      APICCommonClass *k = APIC_COMMON_CLASS(klass);
>> @@ -78,6 +83,7 @@ static void xen_apic_class_init(ObjectClass *klass, void *data)
>>      k->get_tpr = xen_apic_get_tpr;
>>      k->vapic_base_update = xen_apic_vapic_base_update;
>>      k->external_nmi = xen_apic_external_nmi;
>> +    k->send_msi = xen_send_msi;
>>  }
>>  
>>  static const TypeInfo xen_apic_info = {
>> diff --git a/hw/intc/apic.c b/hw/intc/apic.c
>> index 7bd1d279c463..4f3fb44d05e4 100644
>> --- a/hw/intc/apic.c
>> +++ b/hw/intc/apic.c
>> @@ -900,6 +900,11 @@ static void apic_unrealize(DeviceState *dev, Error **errp)
>>      local_apics[s->id] = NULL;
>>  }
>>  
>> +static void apic_send_msi_struct(MSIMessage *msi)
>> +{
>> +    apic_send_msi(msi->address, msi->data);
>> +}
> why not to make apic_send_msi(MSIMessage *msi) instead of adding a wrapper?

Good point, I'll change it.

> Also when interface is switched to send_msi() in 3/5,
> aren't you loosing following checks in apic_mem_writel():
> 
>     if (addr > 0xfff || !index) {

We don't need them.  addr <= 0xfff (the first page) was checked because of the
the APIC register page that overlaid the MSI space.  I think that the comment
in code explains it:

        /* 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. */

  reply	other threads:[~2016-09-27 13:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22 21:04 [Qemu-devel] [PATCH 0/5] intel_iommu: fix EIM Radim Krčmář
2016-09-22 21:04 ` [Qemu-devel] [PATCH 1/5] apic: add global apic_get_class() Radim Krčmář
2016-09-23  9:17   ` Peter Xu
2016-09-27 13:28     ` Radim Krčmář
2016-09-22 21:04 ` [Qemu-devel] [PATCH 2/5] apic: add send_msi() to APICCommonClass Radim Krčmář
2016-09-23  9:35   ` Peter Xu
2016-09-26 12:38   ` Igor Mammedov
2016-09-27 13:55     ` Radim Krčmář [this message]
2016-09-22 21:04 ` [Qemu-devel] [PATCH 3/5] intel_iommu: pass whole remapped addresses to apic Radim Krčmář
2016-09-23  9:41   ` Peter Xu
2016-09-27 13:56     ` Radim Krčmář
2016-09-27 13:57   ` Igor Mammedov
2016-09-22 21:04 ` [Qemu-devel] [PATCH 4/5] intel_iommu: add "eim" property Radim Krčmář
2016-09-22 21:04 ` [Qemu-devel] [PATCH 5/5] intel_iommu: do not allow EIM without KVM support Radim Krčmář
2016-09-23  9:27   ` Paolo Bonzini
2016-09-23 10:02     ` Peter Xu
2016-09-23 10:03       ` Paolo Bonzini
2016-09-23 10:12         ` Peter Xu
2016-09-23 10:39           ` Paolo Bonzini
2016-09-23 10:52             ` Peter Xu
2016-09-27 14:01     ` Radim Krčmář
2016-09-27 21:30       ` Paolo Bonzini
2016-09-27 13:07   ` Igor Mammedov

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=20160927135517.GB26148@potion \
    --to=rkrcmar@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).