From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bosr1-0002Yu-6q for qemu-devel@nongnu.org; Tue, 27 Sep 2016 09:55:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bosqw-0001yw-8c for qemu-devel@nongnu.org; Tue, 27 Sep 2016 09:55:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bosqv-0001yh-VF for qemu-devel@nongnu.org; Tue, 27 Sep 2016 09:55:22 -0400 Date: Tue, 27 Sep 2016 15:55:17 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Message-ID: <20160927135517.GB26148@potion> References: <20160922210432.18680-1-rkrcmar@redhat.com> <20160922210432.18680-3-rkrcmar@redhat.com> <20160926143834.7e0b6b52@nial.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160926143834.7e0b6b52@nial.brq.redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/5] apic: add send_msi() to APICCommonClass List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, Peter Xu , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" 2016-09-26 14:38+0200, Igor Mammedov: > On Thu, 22 Sep 2016 23:04:29 +0200 > Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: >=20 >> The MMIO based interface to APIC doesn't work well with MSIs that have >> upper address bits set (remapped x2APIC MSIs). A specialized interfac= e >> is a quick and dirty way to avoid the shortcoming. >>=20 >> Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 >> --- >> 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(-) >>=20 >> 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); >> } >> =20 >> +static void kvm_send_msi(MSIMessage *msg) >> +{ >> + int ret; >> + >> + ret =3D 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, hwad= dr addr, >> uint64_t data, unsigned size) >> { >> MSIMessage msg =3D { .address =3D addr, .data =3D data }; >> - int ret; >> =20 >> - ret =3D 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); >> } >> =20 >> static const MemoryRegionOps kvm_apic_io_ops =3D { >> @@ -231,6 +237,7 @@ static void kvm_apic_class_init(ObjectClass *klass= , void *data) >> k->enable_tpr_reporting =3D kvm_apic_enable_tpr_reporting; >> k->vapic_base_update =3D kvm_apic_vapic_base_update; >> k->external_nmi =3D kvm_apic_external_nmi; >> + k->send_msi =3D kvm_send_msi; >> } >> =20 >> static const TypeInfo kvm_apic_info =3D { >> 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) >> { >> } >> =20 >> +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 =3D APIC_COMMON_CLASS(klass); >> @@ -78,6 +83,7 @@ static void xen_apic_class_init(ObjectClass *klass, = void *data) >> k->get_tpr =3D xen_apic_get_tpr; >> k->vapic_base_update =3D xen_apic_vapic_base_update; >> k->external_nmi =3D xen_apic_external_nmi; >> + k->send_msi =3D xen_send_msi; >> } >> =20 >> static const TypeInfo xen_apic_info =3D { >> 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, Erro= r **errp) >> local_apics[s->id] =3D NULL; >> } >> =20 >> +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 wrap= per? 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(): >=20 > if (addr > 0xfff || !index) { We don't need them. addr <=3D 0xfff (the first page) was checked because= of the the APIC register page that overlaid the MSI space. I think that the com= ment 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. */