[PATCH] Fixes: f32fb32820b1 ("KVM: x86: Add hook for determining max NPT mapping level")

Ackerley Tng posted 1 patch 3 months ago
arch/x86/kvm/mmu/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] Fixes: f32fb32820b1 ("KVM: x86: Add hook for determining max NPT mapping level")
Posted by Ackerley Tng 3 months ago
The `if (req_max_level)` test was meant ignore req_max_level if
PG_LEVEL_NONE was returned. Hence, this function should return
max_level instead of the ignored req_max_level.

Signed-off-by: Ackerley Tng <ackerleytng@google.com>
Change-Id: I403898aacc379ed98ba5caa41c9f1c52f277adc2
---
 arch/x86/kvm/mmu/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 901be9e420a4..e6b73774645d 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -4335,7 +4335,7 @@ static u8 kvm_max_private_mapping_level(struct kvm *kvm, kvm_pfn_t pfn,
 	if (req_max_level)
 		max_level = min(max_level, req_max_level);
 
-	return req_max_level;
+	return max_level;
 }
 
 static int kvm_faultin_pfn_private(struct kvm_vcpu *vcpu,
-- 
2.46.0.rc2.264.g509ed76dc8-goog
Re: [PATCH] Fixes: f32fb32820b1 ("KVM: x86: Add hook for determining max NPT mapping level")
Posted by Paolo Bonzini 3 months ago
On Thu, Aug 1, 2024 at 7:40 PM Ackerley Tng <ackerleytng@google.com> wrote:
>
> The `if (req_max_level)` test was meant ignore req_max_level if
> PG_LEVEL_NONE was returned. Hence, this function should return
> max_level instead of the ignored req_max_level.
>
> Signed-off-by: Ackerley Tng <ackerleytng@google.com>
> Change-Id: I403898aacc379ed98ba5caa41c9f1c52f277adc2

It's worth pointing out that this is only a latent issue for now,
since guest_memfd does not support large pages ( __kvm_gmem_get_pfn
always returns 0).

Queued with a small note in the commit message and fixed subject.

Thanks,

Paolo


> ---
>  arch/x86/kvm/mmu/mmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 901be9e420a4..e6b73774645d 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -4335,7 +4335,7 @@ static u8 kvm_max_private_mapping_level(struct kvm *kvm, kvm_pfn_t pfn,
>         if (req_max_level)
>                 max_level = min(max_level, req_max_level);
>
> -       return req_max_level;
> +       return max_level;
>  }
>
>  static int kvm_faultin_pfn_private(struct kvm_vcpu *vcpu,
> --
> 2.46.0.rc2.264.g509ed76dc8-goog
>
Re: [PATCH] Fixes: f32fb32820b1 ("KVM: x86: Add hook for determining max NPT mapping level")
Posted by Sean Christopherson 3 months ago
On Thu, Aug 01, 2024, Ackerley Tng wrote:
> The `if (req_max_level)` test was meant ignore req_max_level if
> PG_LEVEL_NONE was returned. Hence, this function should return
> max_level instead of the ignored req_max_level.
> 

Fixes: ?

> Signed-off-by: Ackerley Tng <ackerleytng@google.com>
> Change-Id: I403898aacc379ed98ba5caa41c9f1c52f277adc2

Bad gerrit, bad!
Re: [PATCH] Fixes: f32fb32820b1 ("KVM: x86: Add hook for determining max NPT mapping level")
Posted by Yosry Ahmed 3 months ago
On Thu, Aug 1, 2024 at 10:58 AM Sean Christopherson <seanjc@google.com> wrote:
>
> On Thu, Aug 01, 2024, Ackerley Tng wrote:
> > The `if (req_max_level)` test was meant ignore req_max_level if
> > PG_LEVEL_NONE was returned. Hence, this function should return
> > max_level instead of the ignored req_max_level.
> >
>
> Fixes: ?

I think it's in the subject :)

>
> > Signed-off-by: Ackerley Tng <ackerleytng@google.com>
> > Change-Id: I403898aacc379ed98ba5caa41c9f1c52f277adc2
>
> Bad gerrit, bad!
>