Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2473477yba; Mon, 15 Apr 2019 12:22:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpNPcHws9PoE2MgAb5tHS0ItSuebfT7OIGf4RJecR9iwIsmXBRIrQBat4m5Jgrr8SpSova X-Received: by 2002:aa7:8c42:: with SMTP id e2mr76926313pfd.24.1555356164000; Mon, 15 Apr 2019 12:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356163; cv=none; d=google.com; s=arc-20160816; b=X+knJB1UehDKi1X7JmMN5xxiZlRYfwD/KclO1siY9OAwRZatrCnrhYDkcujMdLyK92 jhkPTZVwqqIljKOH4Y7s8Gw+lQzjTOblvjHY9eLWLU4fp5pZMTV5o1nz1zX0mCnIhFrD pYxgjWc9VuOEjDnX/Nv6ZN2NZINAW5I6dPTgdOL8wuEyShraxWEm/RJj3qlqtE5oLfAt xi78sQERMPOS6HDAhHlAp+v0myD6oW2UIR3JOGBZyQ83Huir93/ElbAQ0HJSJf+xGav9 o6d7teAuAhck6DKv005UJo0s0r9h5FfROz0pakRWrseo+5T+gUVfPiK2wLHkRcUShTOT e9qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OK1FWJP6x/fWLUFykVJTFkR0hM7IbQ8IpruH2uDzWw4=; b=VBUK29+smAP/i1X2eywUC0F6vsxOGN1UaLUyeIi0XpphPHUu3AwF6rmPWRdZtTuvy6 CJOQN0B2/ECJqB14jMQWO4dGNTnKhBksHCzm8lWe+QCApO4FrPyhXH7lsqh0Dk32a0LJ CqT7xsdhQPWGRZ4NscVyA1NK4yO2WD8JX6xCkT4i0U4kQKDw4n3UuXyWawLqp7+2wT3S jm5+txjgCghhwhXQGDOevvxCi4QTz2/86JkuOaqR0sK8gpZvMMtqM3HuBY/OjPyTNvFZ iHblhozKSVDGdv96Dn8eBq6kVcMdrG1PuSqpjyMRqItxcjniZ4GwUmk7NeIh8V5LWd4e RyJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZanAqjPd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4si37770065pgv.154.2019.04.15.12.22.27; Mon, 15 Apr 2019 12:22:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZanAqjPd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730718AbfDOTJY (ORCPT + 99 others); Mon, 15 Apr 2019 15:09:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:45100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730156AbfDOTJW (ORCPT ); Mon, 15 Apr 2019 15:09:22 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B92D9218D3; Mon, 15 Apr 2019 19:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355361; bh=ZPfbinaIDSBXj26kC+wKkpVdB2e8FkA6XhD9b6yiN04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZanAqjPdbwkoDMGLExRAhbKb8Uctx+c3c/NUw5MIMdtD82rRMc1oXQACvCPj6KwVD F1YE5CN5BDyWYBsaEd7zLhK/kmbKD/NIt6DKqNrf/T2qGcz7olAupaRXoLMVSah80B X/9xtE0F0zatEWwAbd+HnQosTDGtq9VP1yqRiKtc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Orr , Jim Mattson , Paolo Bonzini Subject: [PATCH 4.19 101/101] KVM: x86: nVMX: fix x2APIC VTPR read intercept Date: Mon, 15 Apr 2019 20:59:39 +0200 Message-Id: <20190415183745.696894660@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Orr commit c73f4c998e1fd4249b9edfa39e23f4fda2b9b041 upstream. Referring to the "VIRTUALIZING MSR-BASED APIC ACCESSES" chapter of the SDM, when "virtualize x2APIC mode" is 1 and "APIC-register virtualization" is 0, a RDMSR of 808H should return the VTPR from the virtual APIC page. However, for nested, KVM currently fails to disable the read intercept for this MSR. This means that a RDMSR exit takes precedence over "virtualize x2APIC mode", and KVM passes through L1's TPR to L2, instead of sourcing the value from L2's virtual APIC page. This patch fixes the issue by disabling the read intercept, in VMCS02, for the VTPR when "APIC-register virtualization" is 0. The issue described above and fix prescribed here, were verified with a related patch in kvm-unit-tests titled "Test VMX's virtualize x2APIC mode w/ nested". Signed-off-by: Marc Orr Reviewed-by: Jim Mattson Fixes: c992384bde84f ("KVM: vmx: speed up MSR bitmap merge") Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -11660,7 +11660,7 @@ static inline bool nested_vmx_prepare_ms nested_vmx_disable_intercept_for_msr( msr_bitmap_l1, msr_bitmap_l0, X2APIC_MSR(APIC_TASKPRI), - MSR_TYPE_W); + MSR_TYPE_R | MSR_TYPE_W); if (nested_cpu_has_vid(vmcs12)) { nested_vmx_disable_intercept_for_msr(