From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 4/6] KVM: x86: Fix determining flat mode in recalculate_apic_map Date: Sat, 4 Oct 2014 09:50:28 +0300 Message-ID: <20141004065027.GQ26540@minantech.com> References: <1412099359-5316-1-git-send-email-namit@cs.technion.ac.il> <1412099359-5316-5-git-send-email-namit@cs.technion.ac.il> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: pbonzini@redhat.com, kvm@vger.kernel.org, nadav.amit@gmail.com To: Nadav Amit Return-path: Received: from mail-lb0-f172.google.com ([209.85.217.172]:50690 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750823AbaJDGue (ORCPT ); Sat, 4 Oct 2014 02:50:34 -0400 Received: by mail-lb0-f172.google.com with SMTP id b6so2068956lbj.17 for ; Fri, 03 Oct 2014 23:50:32 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1412099359-5316-5-git-send-email-namit@cs.technion.ac.il> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Sep 30, 2014 at 08:49:17PM +0300, Nadav Amit wrote: > Determining flat mode according to cid_mask is wrong, since currently KVM > supports zero clusters in x2apic mode. Use ldr_bits instead. As a comment above the 'if' you are fixing says the code assumes all APICs are in the same mode (if they are not that's an OS bug). In that case the code never gets here with x2apic mode. > > Since we recalculate the apic map whenever the DFR is changed, the bug appears > to have no effect, and perhaps the entire check can be removed. > > Signed-off-by: Nadav Amit > --- > arch/x86/kvm/lapic.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index b8345dd..cfce429 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -171,7 +171,7 @@ static void recalculate_apic_map(struct kvm *kvm) > new->cid_mask = (1 << KVM_X2APIC_CID_BITS) - 1; > new->lid_mask = 0xffff; > } else if (kvm_apic_sw_enabled(apic) && > - !new->cid_mask /* flat mode */ && > + new->ldr_bits == 8 /* flat mode */ && > kvm_apic_get_reg(apic, APIC_DFR) == APIC_DFR_CLUSTER) { > new->cid_shift = 4; > new->cid_mask = 0xf; > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Gleb.