From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5AD81DD0EF; Tue, 13 Oct 2026 12:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791895220; cv=none; b=lb4pRi/Y2H4imYFa1ivxZ+unnYuqhceSNz4tuudGr75D0DsaiywpKgiQFk1u3QHwvRCcctixU2rpDl1ht40J4ZIGrV/0hzdOzbp1s6YnuFpxR9EXOo23ER/8DDUpE5CnDIi6vmAsz9Ysw+sA/8sX8zuZDzLiD4tQWbbXv99JAp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791895220; c=relaxed/simple; bh=gTuEnT2TPg8xZvMKs4yXf2KJXnACuQfhI7zoAVQxHAI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sMK8Mb50SFtEYc5pZD/F7IbyKcLxJwN0LNoWjNHQVcaqgsHoZ+gEg71yYEPg9dDKyFtu0/ggVhnGGz+fJ1SPGc+kBZTjfRNUzg1pdf95ZyD4P/3QNzcD3LZ8axKMAsoxKNQqhHCJxPr+HCtaue/hckqtar8ThMJci548++XyJeA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vBF3SIjl; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vBF3SIjl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4490E1F0089E; Tue, 13 Oct 2026 12:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791895218; bh=59QV7rHxvScX9Yh/ehFOo07AKz47aNdY+4CYTzT63RA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vBF3SIjlbnvLUvVjs0WUMVeZ7Xr2KN9iWtDTTrzzfe9xfRYjoiRGExh+J4+VcMEwg xDJVJ86w/qFEyspJnZbtTCAG2nVjPLsDnQqDdf7zwL18YQRYqgtk5xJt2/d1pfDGl5 xMwidafisJW+LMNxSZcm31zO7dtEOyLkY5IFSj9Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini Subject: [PATCH 6.12 201/497] KVM: nVMX: Force MSR bitmap refresh if runtime eVMCS controls are modified Date: Tue, 13 Oct 2026 13:36:08 +0200 Message-ID: <20261013112912.662334001@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112907.864180619@linuxfoundation.org> References: <20261013112907.864180619@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sean Christopherson commit 2abb25273c82061dd4670690c81c319c03740bf6 upstream. Force a refresh of the vmcs02 MSR bitmap during nested VM-Enter if the runtime eVMCS controls (pin, primary, secondary, etc.) are being updated. If L1 isn't intercepting TPR writes, runs L2 with TPR virtualization, and then runs the same L2 with TPR virtualization disabled, KVM will fail to refresh msr_bitmap02 and leave TPR in passthrough mode even though TPR virtualization is disabled. I.e. failure to refresh the bitmap lets L2 (or L1 by proxy) read and write L0's TPR. Fixes: 502d2bf5f2fd ("KVM: nVMX: Implement Enlightened MSR Bitmap feature") Cc: stable@vger.kernel.org Reviewed-by: Vitaly Kuznetsov Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx/nested.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -1665,6 +1665,9 @@ static void copy_vmcs12_to_shadow(struct static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx, u32 hv_clean_fields) { #ifdef CONFIG_KVM_HYPERV + const u64 runtime_controls = HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 | + HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 | + HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC; struct vmcs12 *vmcs12 = vmx->nested.cached_vmcs12; struct hv_enlightened_vmcs *evmcs = nested_vmx_evmcs(vmx); struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(&vmx->vcpu); @@ -1673,6 +1676,9 @@ static void copy_enlightened_to_vmcs12(s vmcs12->tpr_threshold = evmcs->tpr_threshold; vmcs12->guest_rip = evmcs->guest_rip; + if ((hv_clean_fields & runtime_controls) != runtime_controls) + vmx->nested.force_msr_bitmap_recalc = true; + if (unlikely(!(hv_clean_fields & HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL))) { hv_vcpu->nested.pa_page_gpa = evmcs->partition_assist_page;