From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 7/9] KVM: x86: use proper format of APIC ID register Date: Tue, 17 May 2016 17:34:31 +0200 Message-ID: References: <1462568045-31085-1-git-send-email-rkrcmar@redhat.com> <1462568045-31085-8-git-send-email-rkrcmar@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: "Lan, Tianyu" , Igor Mammedov , Jan Kiszka , Peter Xu To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org Return-path: Received: from mail-wm0-f65.google.com ([74.125.82.65]:33238 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750875AbcEQPee (ORCPT ); Tue, 17 May 2016 11:34:34 -0400 Received: by mail-wm0-f65.google.com with SMTP id r12so5685649wme.0 for ; Tue, 17 May 2016 08:34:34 -0700 (PDT) In-Reply-To: <1462568045-31085-8-git-send-email-rkrcmar@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/05/2016 22:54, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > We currently always shift APIC ID as if APIC was in xAPIC mode. > x2APIC mode wants to use more bits and storing a hardware-compabible > value is the the sanest option. VMX can stop intercepting the APIC I= D > register then. >=20 > KVM API to set the lapic expects that bottom 8 bits of APIC ID are in > top 8 bits of APIC_ID register. Definite that x2APIC IDs are byte > swapped to keep compatibility without new toggles. That's a bit too clever... Can we make KVM_CAP_MSI_X2APIC an enable-able capability (and then better rename it KVM_CAP_X2APIC_ID), and then all ids become 32 bit? This fixes the APIC ID issue here, and avoids introducing a new routing type in patch 5. The cost is a little extra complexity in QEMU, but I think it's bearabl= e. Paolo > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > --- > Documentation/virtual/kvm/api.txt | 6 ++++++ > arch/x86/kvm/lapic.c | 44 ++++++++++++++++++++++++++++-= ---------- > arch/x86/kvm/lapic.h | 7 ++++++- > arch/x86/kvm/vmx.c | 4 ---- > arch/x86/kvm/x86.c | 2 ++ > 5 files changed, 46 insertions(+), 17 deletions(-) >=20 > diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtua= l/kvm/api.txt > index 07bcedc0ba09..b1ddea38e6b9 100644 > --- a/Documentation/virtual/kvm/api.txt > +++ b/Documentation/virtual/kvm/api.txt > @@ -1583,6 +1583,11 @@ struct kvm_lapic_state { > Reads the Local APIC registers and copies them into the input argume= nt. The > data format and layout are the same as documented in the architectur= e manual. > =20 > +Note that the APIC ID is stored in APIC_ID register in big endian fo= rmat. > +This makes no difference for xAPIC APIC ID, which is still in the to= p 8 bits, > +but x2APIC ID needs to be byteswapped. The reason is compatibility = with KVM's > +definition of x2APIC. (The hardware stores x2APIC ID as little endi= an.) > +