From patchwork Wed Nov 9 17:04:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 9419825 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 4D861601C0 for ; Wed, 9 Nov 2016 17:05:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ABDE2621F for ; Wed, 9 Nov 2016 17:05:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F26629392; Wed, 9 Nov 2016 17:05:05 +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 A282C2621F for ; Wed, 9 Nov 2016 17:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754106AbcKIRFB (ORCPT ); Wed, 9 Nov 2016 12:05:01 -0500 Received: from mail-pf0-f170.google.com ([209.85.192.170]:34427 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752046AbcKIRFA (ORCPT ); Wed, 9 Nov 2016 12:05:00 -0500 Received: by mail-pf0-f170.google.com with SMTP id n85so129690041pfi.1 for ; Wed, 09 Nov 2016 09:04:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q3lTJzg2XrtNmWjDUPImu+wXJA2s46d90stevVbCLOw=; b=RDXlW4DJDNKPy99d8/qC1xqzHTutl/D0BhZ1fTd5FUi/obM76rFyv/xx8FGRWMSRsX iVdHJZzR8m1skbKTWbFQhKnVI1OUvnifvGQwaImsh/zio+Y3+H7V3bm5jQU187cAH2Sv nXUM5ek5TZAWq+Wp2/gYEGdtnT2DyxANYmfeMO/cyX6CWfBm8sxvApfUXQv8Dfam2dkc DGP3rZGqFpCixWFzVtrGthMiXKQSkssWYBvEGJ42KjTIMcTYFBb3xq1b+emso+6BJcPA qGt1eusx67/f+vaRFvPugiViEiB1RQiGAGuEQiHOlfCXkNvE7/qpTV9pFrNmZCaxxdUM MLNw== 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:in-reply-to :references; bh=q3lTJzg2XrtNmWjDUPImu+wXJA2s46d90stevVbCLOw=; b=Zag94H9LOLYqVzvOSZftLgM4G1GRajiVYQtd2jAeDUcxt5jVVLdvYy4dEHoTxPqNP8 7hLsaQijeM3zlvsPhCueaH1unvjnEbGAQDW2IIhZ8MNevWWADqjrNLpiroLGKzB74Xuu juCRuhtFJmk0o1xCdP/LNprtIQo8Ypol0Fb/ypBKf3RlfSwtKbZuJByM9i7obh5rvUis ZHpHR7P5aJatYTcTtnDD98+9c1KD0m2JiHmjOaSbE5O1eVnmYUVmQA5liqLrM5t3JAub CLvbGGjeG4/5SGIAw3bdP2vLoSh+2MjRtDFiCsFEfeqL4xzlHeywiVWVWfhAkoUCpbd4 Xupw== X-Gm-Message-State: ABUngvdtFs13cLQlRIF2cJ634QRzrHeVMNih8J0MuP9IoNzWnBDG87uKfP8s8ntcKvurGh+5 X-Received: by 10.99.174.79 with SMTP id e15mr2952064pgp.116.1478711099107; Wed, 09 Nov 2016 09:04:59 -0800 (PST) Received: from jmattson.sea.corp.google.com ([100.100.206.154]) by smtp.gmail.com with ESMTPSA id d197sm605384pfd.38.2016.11.09.09.04.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Nov 2016 09:04:58 -0800 (PST) From: Jim Mattson To: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org Cc: Jim Mattson Subject: [PATCH v2] kvm: nVMX: CPUID.01H:EDX.APIC[bit 9] should mirror IA32_APIC_BASE[11] Date: Wed, 9 Nov 2016 09:04:36 -0800 Message-Id: <1478711076-1426-1-git-send-email-jmattson@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: References: 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 --- arch/x86/kvm/cpuid.c | 4 ++++ arch/x86/kvm/lapic.c | 1 + 2 files changed, 5 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index afa7bbb..84b62ee 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -81,6 +81,10 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu) best->ecx |= F(OSXSAVE); } + best->edx &= ~F(APIC); + if (vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE) + best->edx |= F(APIC); + if (apic) { if (best->ecx & F(TSC_DEADLINE_TIMER)) apic->lapic_timer.timer_mode_mask = 3 << 17; 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);