From patchwork Fri Nov 4 22:00:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 9413433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B649B6022E for ; Fri, 4 Nov 2016 22:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A71C52B227 for ; Fri, 4 Nov 2016 22:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AC442B229; Fri, 4 Nov 2016 22:00:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4218F2B227 for ; Fri, 4 Nov 2016 22:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757095AbcKDWAn (ORCPT ); Fri, 4 Nov 2016 18:00:43 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35899 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754558AbcKDWAm (ORCPT ); Fri, 4 Nov 2016 18:00:42 -0400 Received: by mail-pf0-f170.google.com with SMTP id 189so58205750pfz.3 for ; Fri, 04 Nov 2016 15:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=14UqGu2Fu+mM+BocO8zdlNu7vltSzWZVlBWjxngM+l8=; b=ZR+kvYJSKQHwGdMqvGB7xByFGBHt7dJSOl0qGXRAxwFs8Ck5BNi3Roty7swPrEEYiF OCJKPz7uyCdS4ozkZ+w9dAjSTwNnHAijm+GUfpM0uRPtyv8d9/3UQJ1s1yUaSbVmKNZB 3miQPKKUEvPyM4mMjwptOyXHmSMdL9HYu8x+L4nWI/SNSQ9xDAIHMAewV+l/r+8Yjx3O mnRjPOavejGE93XD6sHCUm7SZwniBUe3h12Dcc5rg0Er+f3Q/4mltYMWJ5z3BM5IYv/0 3nw41MA839yJ7Jil04N4kZ9zfogVgE3ELr724CDG7npXGQj72CkwaeUIwkgkQi4YROuC l9Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=14UqGu2Fu+mM+BocO8zdlNu7vltSzWZVlBWjxngM+l8=; b=P/IL0Z0OIeLF4/jVNyYKoO/mbRxx8SCmX52YENcd3/MZAA1qcjYhBL1/J+5fjmTIp1 xkyQiBuN5SWdMAZ3A4mdgIvlQywTqoGru7A8DpOMckU/Y/taxxzTgt/knAwZHCMdMkbY BMsF7SeNVn4KPJ4KaTyoXHAk14yFR+q3DqnPiTTSlvJbvxUgFepCl24QnrBu5xDmcHtm pXwbJ4mWUHYSLO2i/k/aBWRan/qwiijTkujgtXORWp3+Ig6PKPPlHWcZacU6kyRilLuS WJhwk5HHBX8fLqwoTJIJBHWB0ahFRsasUo3RiGkKRbsQudowjZeYVIKy3/rHnA6AnEEh Wdlg== X-Gm-Message-State: ABUngvcGJ7bj2YjOIPAnDX/beI0ByC4DPuiwmcjJR13N5h8TXt5JMPEjqiCbqj4mA/ug4j8q X-Received: by 10.98.14.82 with SMTP id w79mr29961604pfi.153.1478296841547; Fri, 04 Nov 2016 15:00:41 -0700 (PDT) Received: from jmattson.sea.corp.google.com ([100.100.206.154]) by smtp.gmail.com with ESMTPSA id b64sm22542236pfc.74.2016.11.04.15.00.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Nov 2016 15:00:41 -0700 (PDT) From: Jim Mattson To: kvm@vger.kernel.org Cc: Jim Mattson Subject: [PATCH] kvm: nVMX: CPUID.01H:EDX.APIC[bit 9] should mirror IA32_APIC_BASE[11] Date: Fri, 4 Nov 2016 15:00:02 -0700 Message-Id: <1478296802-23291-1-git-send-email-jmattson@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From the Intel SDM, volume 3, section 10.4.3, "Enabling or Disabling the Local APIC," When IA32_APIC_BASE[11] is 0, the processor is functionally equivalent to an IA-32 processor without an on-chip APIC. The CPUID feature flag for the APIC (see Section 10.4.2, "Presence of the Local APIC") is also set to 0. Signed-off-by: Jim Mattson Reviewed-by: Ben Serebrin Reviewed-by: David Matlack --- arch/x86/kvm/cpuid.c | 3 +++ arch/x86/kvm/lapic.c | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index afa7bbb..0a49fd2 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -81,7 +81,10 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu) best->ecx |= F(OSXSAVE); } + best->edx &= ~F(APIC); if (apic) { + if (vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE) + best->edx |= F(APIC); if (best->ecx & F(TSC_DEADLINE_TIMER)) apic->lapic_timer.timer_mode_mask = 3 << 17; else diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 23b99f3..eda4284e 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1758,6 +1758,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value) /* update jump label if enable bit changes */ if ((old_value ^ value) & MSR_IA32_APICBASE_ENABLE) { + kvm_update_cpuid(vcpu); if (value & MSR_IA32_APICBASE_ENABLE) { kvm_apic_set_xapic_id(apic, vcpu->vcpu_id); static_key_slow_dec_deferred(&apic_hw_disabled);