Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2469560yba; Mon, 15 Apr 2019 12:17:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7EqHXGEk778Wbr2mDlaO7J/zx49+LDu3p+KlrZqvG/aTJYYFtH/AXEWyEgf5lrXH9MpXB X-Received: by 2002:a63:30c5:: with SMTP id w188mr71210995pgw.76.1555355860638; Mon, 15 Apr 2019 12:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355860; cv=none; d=google.com; s=arc-20160816; b=sbeRsZQU9kl+3/aqJJ1w6bI94HIvBP4vJjo9e1FoCSHIIRsKDxFuogQXNlvEvowAB1 /NnKqJ4igu+NtY1BYS3etx+X9Ml7j9IV4po94KoimaZNqh8/CEPqTsh/C09buxjJD/KD ueq5qP/kzidZy/ETDtto+vqoV+GmC6lgJvqZP1L8P8ykSxpOIu53F69aDH/GsmBsQmP5 5I66uhUGtGswjSbLHdt10vKw/wKPjpUt56ZE5nOHW1z/kLrCcBEJPNhG5TfCxFqHCsFB GqTMzndgyTdj8CxOir5rQuO650/eFBetwB6WkUnvKhyGdXZ6KpHR2IX1FL41Rc71rulE JDuw== 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=mVMwL9wk2QafFOKQ6PrAXFdtOVFY81+YQv5ZU+/lk3A=; b=dHPHcQFNQYq6qM8YRkVUBe0BTqyxX1kHDnXRhErRZ4af3CJJiZWu5YNWeCwUxrxSjq fk163C7eJaQtFE+hmSlgzns6lBmobJ2+8d2cXRh8SWmtkNYnjFptGCFamlDS5ZD6yVYd N5BVa/gUd76flwrTSa1IodQBNl8cPEW+4N3Zk7XJ5reho26cTDDe+h15/aD/xUnjGsu4 vfJMZHUrmyZLJtGKljPNgUaZXobjp2ttcEFlfho3AZSr5NCILfdyc+h+W7/KHiPBiK3S ke1avAKYFNJf/Asn4px/ee9PeH9tjlFjvMhpz6MGD3DtVEkTf0ijG4l7KRFSiKd1Xakq +iow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ft+7RJjB; 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 f8si33722242pgu.482.2019.04.15.12.17.24; Mon, 15 Apr 2019 12:17:40 -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=Ft+7RJjB; 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 S1731809AbfDOTO4 (ORCPT + 99 others); Mon, 15 Apr 2019 15:14:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:52738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731765AbfDOTOc (ORCPT ); Mon, 15 Apr 2019 15:14:32 -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 88B9D2075B; Mon, 15 Apr 2019 19:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355672; bh=LPYxgzrjn3gUx1Pjhl0CVwF+Ip40X+EZsm37eXdbZow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ft+7RJjBX4wcipEroowCQHYbXRbBa8ld2k5psVKUO6cRd9Q479zyFC0iMYyeWC4rf /tpYS+EUNOA+hF6UcvfP0L+4Ewj07USyDQKB2buUqz6qB4aX7PYQVccKTBcyT2aEID KAmEOLyfHYa5+Qdd0KU7lLDVx+HX8B5j3BQLGJXE= 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 5.0 116/117] KVM: x86: nVMX: fix x2APIC VTPR read intercept Date: Mon, 15 Apr 2019 21:01:26 +0200 Message-Id: <20190415183750.654071873@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183744.887851196@linuxfoundation.org> References: <20190415183744.887851196@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/nested.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -578,7 +578,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(