diff mbox series

[6/6] KVM: X86/SVM: Use root_level in svm_load_mmu_pgd()

Message ID 20220605063417.308311-7-jiangshanlai@gmail.com (mailing list archive)
State New, archived
Headers show
Series KVM: Trivial cleanups | expand

Commit Message

Lai Jiangshan June 5, 2022, 6:34 a.m. UTC
From: Lai Jiangshan <jiangshan.ljs@antgroup.com>

The caller always call it with root_level = vcpu->arch.mmu->root_role.level.

Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
 arch/x86/kvm/svm/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Matlack June 8, 2022, 4:54 p.m. UTC | #1
On Sun, Jun 05, 2022 at 02:34:17PM +0800, Lai Jiangshan wrote:
> From: Lai Jiangshan <jiangshan.ljs@antgroup.com>
> 
> The caller always call it with root_level = vcpu->arch.mmu->root_role.level.

It'd be helpful to be more specific about the caller. e.g.

  Use root_level in svm_load_mmu_pg() rather that looking up the root
  level in vcpu->arch.mmu->root_role.level. svm_load_mmu_pgd() has only
  one caller, kvm_mmu_load_pgd(), which always passes
  vcpu->arch.mmu->root_role.level as root_level.

  No functional change intended.

> 
> Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
> ---
>  arch/x86/kvm/svm/svm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 3b49337998ec..f45d11739314 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -3951,7 +3951,7 @@ static void svm_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa,
>  		hv_track_root_tdp(vcpu, root_hpa);
>  
>  		cr3 = vcpu->arch.cr3;
> -	} else if (vcpu->arch.mmu->root_role.level >= PT64_ROOT_4LEVEL) {
> +	} else if (root_level >= PT64_ROOT_4LEVEL) {
>  		cr3 = __sme_set(root_hpa) | kvm_get_active_pcid(vcpu);
>  	} else {
>  		/* PCID in the guest should be impossible with a 32-bit MMU. */
> -- 
> 2.19.1.6.gb485710b
>
diff mbox series

Patch

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 3b49337998ec..f45d11739314 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3951,7 +3951,7 @@  static void svm_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa,
 		hv_track_root_tdp(vcpu, root_hpa);
 
 		cr3 = vcpu->arch.cr3;
-	} else if (vcpu->arch.mmu->root_role.level >= PT64_ROOT_4LEVEL) {
+	} else if (root_level >= PT64_ROOT_4LEVEL) {
 		cr3 = __sme_set(root_hpa) | kvm_get_active_pcid(vcpu);
 	} else {
 		/* PCID in the guest should be impossible with a 32-bit MMU. */