From patchwork Tue Sep 30 17:49:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 5005351 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC0909F327 for ; Tue, 30 Sep 2014 17:49:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F10FD20220 for ; Tue, 30 Sep 2014 17:49:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 11D972021B for ; Tue, 30 Sep 2014 17:49:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753597AbaI3Rtp (ORCPT ); Tue, 30 Sep 2014 13:49:45 -0400 Received: from mailgw12.technion.ac.il ([132.68.225.12]:19323 "EHLO mailgw12.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753559AbaI3Rto (ORCPT ); Tue, 30 Sep 2014 13:49:44 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah8FAGDsKlSERCAB/2dsb2JhbABggw6BKtF1AoENFgEBeoQEAQUnUhBRVxmIPrg0hl+POmQHFoQ1BYtNniuJJ4NmaYEGgUQBAQE X-IPAS-Result: Ah8FAGDsKlSERCAB/2dsb2JhbABggw6BKtF1AoENFgEBeoQEAQUnUhBRVxmIPrg0hl+POmQHFoQ1BYtNniuJJ4NmaYEGgUQBAQE X-IronPort-AV: E=Sophos;i="5.04,628,1406581200"; d="scan'208";a="123967603" Received: from csa.cs.technion.ac.il ([132.68.32.1]) by mailgw12.technion.ac.il with ESMTP; 30 Sep 2014 20:49:39 +0300 Received: from csn.cs.technion.ac.il (csn.cs.technion.ac.il [132.68.32.15]) by csa.cs.technion.ac.il (Postfix) with ESMTP id 5978F140040; Tue, 30 Sep 2014 20:49:38 +0300 (IDT) Received: from csl-tapuz20.cs.technion.ac.il (csl-tapuz20.cs.technion.ac.il [132.68.206.58]) by csn.cs.technion.ac.il (Postfix) with ESMTPSA id 1D570A0C6D; Tue, 30 Sep 2014 20:49:38 +0300 (IDT) From: Nadav Amit To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, nadav.amit@gmail.com, Nadav Amit Subject: [PATCH 4/6] KVM: x86: Fix determining flat mode in recalculate_apic_map Date: Tue, 30 Sep 2014 20:49:17 +0300 Message-Id: <1412099359-5316-5-git-send-email-namit@cs.technion.ac.il> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412099359-5316-1-git-send-email-namit@cs.technion.ac.il> References: <1412099359-5316-1-git-send-email-namit@cs.technion.ac.il> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Determining flat mode according to cid_mask is wrong, since currently KVM supports zero clusters in x2apic mode. Use ldr_bits instead. 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;