From nobody Mon Feb 9 12:12:11 2026 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FC9A2BD59A for ; Tue, 10 Jun 2025 22:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749596276; cv=none; b=ggZyaxT5J2EGWbfqanXbv+/2ruo/BOlW9UOal30F1SbVcyBYpYN2IzZbkbWgIXaGe8hDkuo5EyFJNoArbOgGvKESXzkjW360Td+d/O93K6g3JBt7PJOpKAF4PL6/r/7hS0bsV8Jyp73EpfgqzkcHvrTpamT/zIDraGM4F/v5CUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749596276; c=relaxed/simple; bh=WJ/GMU/xzF2OXuravj1ifO4vfSp1RRYL7XD1ZEUK4r8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WMhxj90/CKwaVoXZAaRqMmYLL/DRAppgKSvExrCB1deSyuBNaTwbczUIjM5CSbrL2dNt5K7789aXXVoEK5tnFpw0nYuEEQojV7d3/TGUusxhqnjUDKfMPdtSnn3gwfQIjx5AVp0gCZLfxkZZux6nbaSRkBCugt4FbAcwIuUZeow= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=llPwxt4z; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="llPwxt4z" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7462aff55bfso4991503b3a.2 for ; Tue, 10 Jun 2025 15:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1749596274; x=1750201074; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=aPjiw0cgNLeamyirB4dOeXsfFa7tz6KDF0aXc9RAbzo=; b=llPwxt4zzj40mimZd8/Cky1QclkagQDGEmYsBbT/kMp0LgzSWiweMqCX32wzIPMpRn M1kFA66nbnCPHHfBI8Exbl1QEM7k1+1VnMqcOywxfLP0H6oPCOQVNzUxhpSsijYPWEG3 VElhWVxV4IR4XvZ9cNrjXfimEX+ujjD6qSHRTvloN/JfydFEkcG3Pl7fpmTX257wRnLv clcFS+UB1o8I522FQdMmFUVI9DjQwjj0cf0rYYMpnB1Synb8Ka8vwdHXEh7jSYYksE8Z +9B51N39BIJVDOqObMPCcln4rODfRpLkf9sB1gEfXi8ChsyHHiI2L3y+MkfGQ7S3/B+w Gl/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749596274; x=1750201074; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aPjiw0cgNLeamyirB4dOeXsfFa7tz6KDF0aXc9RAbzo=; b=YX4vgjPcJLvdW8qlsO6OlfJ90LoEFd1ZnmpyzFIvWxUFkxQ73jld2zIRn0QFIsflwr Xjz13fbJVn0vDxtTNM1bFeeO+6craVGyK2VZeiSKT3USUPN/bNGCX3vfNhtcX7fEl7Mn R+Q3UYDE7hSCA3YIjQMrmsRPG6mxMcCbKEUyVL/eZgWVu7Tm+QfGsdSWm9LTfIJa0vTS q+ZqhpBxA23MipEKkBSKz7lvk9dfVhXJVqO3Ky/4g0mJaIGb9I5yqQYBGUW7ulxhkGdt MKJqq9qMUEq/4ejqyp4cnWiZdBDb56tSvHqIDKx2XDtigISM4TbSF/DFouK7ZonnSNiP 53MQ== X-Forwarded-Encrypted: i=1; AJvYcCU5t/NgHwbm/cXINGnoJVD40rUesY2e4OBi3a0wR1hyBLtvkSPdH5qWen7e4lgO5pn+qerK7o94Nq4P78A=@vger.kernel.org X-Gm-Message-State: AOJu0YzR8E5D2wOeDe1bOyJ7a6KDaYx9IWSyRHCfvVCcZJz+JaIlv26K tpW+6B/Bwf8jdl5zG07IewEwgkG3DkDt7/D0wsR4c5KoC5FPpTirH/S7Q9AYmp4tKk6gxgG86q1 +0deM1Q== X-Google-Smtp-Source: AGHT+IHw+fYQ+JlF3Ar9HXBBbIQL6EkrfLH+q1Yr/8tHzcJ4ZaB0UZe7g+zuKBkMp6FnOc2eUNC+b4DEpMI= X-Received: from pgmn9.prod.google.com ([2002:a63:5c49:0:b0:b2e:bfa8:7724]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:6f89:b0:1f5:7ea8:a791 with SMTP id adf61e73a8af0-21f86602592mr1755783637.10.1749596274683; Tue, 10 Jun 2025 15:57:54 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 10 Jun 2025 15:57:13 -0700 In-Reply-To: <20250610225737.156318-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250610225737.156318-1-seanjc@google.com> X-Mailer: git-send-email 2.50.0.rc0.642.g800a2b2222-goog Message-ID: <20250610225737.156318-9-seanjc@google.com> Subject: [PATCH v2 08/32] KVM: SVM: Massage name and param of helper that merges vmcb01 and vmcb12 MSRPMs From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Gao , Borislav Petkov , Xin Li , Dapeng Mi , Francesco Lavra , Manali Shukla Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename nested_svm_vmrun_msrpm() to nested_svm_merge_msrpm() to better capture its role, and opportunistically feed it @vcpu instead of @svm, as grabbing "svm" only to turn around and grab svm->vcpu is rather silly. No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Dapeng Mi --- arch/x86/kvm/svm/nested.c | 15 +++++++-------- arch/x86/kvm/svm/svm.c | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 8427a48b8b7a..89a77f0f1cc8 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -189,8 +189,9 @@ void recalc_intercepts(struct vcpu_svm *svm) * is optimized in that it only merges the parts where KVM MSR permission = bitmap * may contain zero bits. */ -static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) +static bool nested_svm_merge_msrpm(struct kvm_vcpu *vcpu) { + struct vcpu_svm *svm =3D to_svm(vcpu); int i; =20 /* @@ -205,7 +206,7 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) if (!svm->nested.force_msr_bitmap_recalc) { struct hv_vmcb_enlightenments *hve =3D &svm->nested.ctl.hv_enlightenment= s; =20 - if (kvm_hv_hypercall_enabled(&svm->vcpu) && + if (kvm_hv_hypercall_enabled(vcpu) && hve->hv_enlightenments_control.msr_bitmap && (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS))) goto set_msrpm_base_pa; @@ -230,7 +231,7 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) =20 offset =3D svm->nested.ctl.msrpm_base_pa + (p * 4); =20 - if (kvm_vcpu_read_guest(&svm->vcpu, offset, &value, 4)) + if (kvm_vcpu_read_guest(vcpu, offset, &value, 4)) return false; =20 svm->nested.msrpm[p] =3D svm->msrpm[p] | value; @@ -937,7 +938,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) if (enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, true)) goto out_exit_err; =20 - if (nested_svm_vmrun_msrpm(svm)) + if (nested_svm_merge_msrpm(vcpu)) goto out; =20 out_exit_err: @@ -1819,13 +1820,11 @@ static int svm_set_nested_state(struct kvm_vcpu *vc= pu, =20 static bool svm_get_nested_state_pages(struct kvm_vcpu *vcpu) { - struct vcpu_svm *svm =3D to_svm(vcpu); - if (WARN_ON(!is_guest_mode(vcpu))) return true; =20 if (!vcpu->arch.pdptrs_from_userspace && - !nested_npt_enabled(svm) && is_pae_paging(vcpu)) + !nested_npt_enabled(to_svm(vcpu)) && is_pae_paging(vcpu)) /* * Reload the guest's PDPTRs since after a migration * the guest CR3 might be restored prior to setting the nested @@ -1834,7 +1833,7 @@ static bool svm_get_nested_state_pages(struct kvm_vcp= u *vcpu) if (CC(!load_pdptrs(vcpu, vcpu->arch.cr3))) return false; =20 - if (!nested_svm_vmrun_msrpm(svm)) { + if (!nested_svm_merge_msrpm(vcpu)) { vcpu->run->exit_reason =3D KVM_EXIT_INTERNAL_ERROR; vcpu->run->internal.suberror =3D KVM_INTERNAL_ERROR_EMULATION; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ec97ea1d7b38..854904a80b7e 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3137,7 +3137,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct = msr_data *msr) * * For nested: * The handling of the MSR bitmap for L2 guests is done in - * nested_svm_vmrun_msrpm. + * nested_svm_merge_msrpm(). * We update the L1 MSR bit as well since it will end up * touching the MSR anyway now. */ --=20 2.50.0.rc0.642.g800a2b2222-goog