From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1FF163DC4D5; Mon, 4 May 2026 14:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903393; cv=none; b=fn2Xy5ZSLYq7wtA85b+4CfLglFm7qfrs+Qpxs/besqehEenQN1B7bkcfmWqGFEbJbYzLToYO8sw7SPka6/zortnOK58GCUaBt/byOkyUEzHpwcmllM1rqoXOnaSOC2016jq7AKT5/VBcz134sRsWyUNx8FdHVnwmCBmeEFrbYF0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903393; c=relaxed/simple; bh=ZAoE8ByVM+pEluMzbWJO+WryfKsCaJ8tHtZd38PS82U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RmlV4EGPENBZvLCMJjFR5r95sUvPcBiFjnkB98IR/7wn4ES1yrMJ+8LUDOTyiOl55wixOGsVwc7WNDhBRJqHn1Fk7L2xQBgAl/mnp/GVkC+I1+B1ohx0orRhl+doCzLo/I0X2Kvskbq44Bl0PMGWApOA5RxwrpCgQndnqj5urak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TVwNQZOC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TVwNQZOC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC284C2BCB8; Mon, 4 May 2026 14:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777903393; bh=ZAoE8ByVM+pEluMzbWJO+WryfKsCaJ8tHtZd38PS82U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TVwNQZOCk/ga/zXO7xTVtCGIc67JFdE3XI7GYO+bcbVARoBqJmEHm59S/5Ls+gH1j GPIyI9SfXxK/qF/q8KN2bArYzDgGWA0VHxuVGuf3GWTebjUCJvi96YrH4vA2jfiBkw HzqfXfCQL+jM0pK8ZyeHVDY6DImmr9Tk91RrqzPQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yosry Ahmed , Sean Christopherson Subject: [PATCH 7.0 217/307] KVM: nSVM: Refactor checking LBRV enablement in vmcb12 into a helper Date: Mon, 4 May 2026 15:51:42 +0200 Message-ID: <20260504135151.030835824@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135142.814938198@linuxfoundation.org> References: <20260504135142.814938198@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 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yosry Ahmed commit 290c8d82023ab0e1d2782d37136541e017174d7c upstream. Refactor the vCPU cap and vmcb12 flag checks into a helper. The unlikely() annotation is dropped, it's unlikely (huh) to make a difference and the CPU will probably predict it better on its own. CC: stable@vger.kernel.org Co-developed-by: Sean Christopherson Signed-off-by: Yosry Ahmed Link: https://patch.msgid.link/20260303003421.2185681-7-yosry@kernel.org Signed-off-by: Sean Christopherson Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/nested.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -651,6 +651,12 @@ void nested_vmcb02_compute_g_pat(struct svm->nested.vmcb02.ptr->save.g_pat = svm->vmcb01.ptr->save.g_pat; } +static bool nested_vmcb12_has_lbrv(struct kvm_vcpu *vcpu) +{ + return guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV) && + (to_svm(vcpu)->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK); +} + static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12) { bool new_vmcb12 = false; @@ -715,8 +721,7 @@ static void nested_vmcb02_prepare_save(s vmcb_mark_dirty(vmcb02, VMCB_DR); } - if (unlikely(guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV) && - (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) { + if (nested_vmcb12_has_lbrv(vcpu)) { /* * Reserved bits of DEBUGCTL are ignored. Be consistent with * svm_set_msr's definition of reserved bits. @@ -1243,8 +1248,7 @@ int nested_svm_vmexit(struct vcpu_svm *s if (!nested_exit_on_intr(svm)) kvm_make_request(KVM_REQ_EVENT, &svm->vcpu); - if (unlikely(guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV) && - (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) { + if (nested_vmcb12_has_lbrv(vcpu)) { svm_copy_lbrs(&vmcb12->save, &vmcb02->save); } else { svm_copy_lbrs(&vmcb01->save, &vmcb02->save);