KVM: arm64: Fix the descriptor address in __kvm_at_swap_desc()
PATCH 1/1 KVM: arm64: Fix the descriptor address in __kvm_at_swap_desc()
From: "Zenghui Yu (Huawei)" <[email protected]>
Using "(u64 __user *)hva + offset" to get the virtual addresses of S1/S2 descriptors looks really wrong, if offset is not zero. What we want to get for swapping is hva + offset, not hva + offset*8. ;-)
Fix it.
--- arch/arm64/kvm/at.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/at.c +1 -1
@@ -1753,7 +1753,7 @@ int __kvm_at_swap_desc(struct kvm *kvm, gpa_t ipa, u64 old, u64 new)if (!writable)return -EPERM ; - ptep = (u64 __user *)hva + offset; + ptep = (void __user *)hva + offset;if (cpus_have_final_cap (ARM64_HAS_LSE_ATOMICS )) r =__lse_swap_desc (ptep, old, new);else
Signature · 1 line
2.53.0
Marc Zyngier
maintainerQuoted 20 lines · Zenghui Yu
From: "Zenghui Yu (Huawei)" <[email protected]>
Using "(u64
__user*)hva + offset" to get the virtual addresses of S1/S2 descriptors looks really wrong, if offset is not zero. What we want to get for swapping is hva + offset, not hva + offset*8. ;-)Fix it.
Fixes f6927b41d573 ("KVM: arm64: Add helper for swapping guest descriptor")Signed-off-by Zenghui Yu (Huawei) <[email protected]>--- arch/arm64/kvm/at.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/kvm/at.c +0
-0
arch/arm64/kvm/at.c int __kvm_at_swap_desc(struct kvm *kvm, gpa_t ipa, u64 old, u64 new) · line 1759
Quoted 8 lines
arch/arm64/kvm/at.c +1
-1@@ -1753,7 +1753,7 @@ int __kvm_at_swap_desc(struct kvm *kvm, gpa_t ipa, u64 old, u64 new)if (!writable)return -EPERM ; - ptep = (u64 __user *)hva + offset; + ptep = (void __user *)hva + offset;if (cpus_have_final_cap (ARM64_HAS_LSE_ATOMICS )) r =__lse_swap_desc (ptep, old, new);else
Holy crap! How did we miss that???
Thanks a lot for spotting it, I'll queue that now.
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 8 lines · Zenghui Yu
Using "(u64
__user*)hva + offset" to get the virtual addresses of S1/S2 descriptors looks really wrong, if offset is not zero. What we want to get for swapping is hva + offset, not hva + offset*8. ;-)Fix it.
[...]
Applied to fixes, thanks!
[1/1] KVM: arm64: Fix the descriptor address in __kvm_at_swap_desc()
commit: 0496acc42fb51eee040b5170cec05cec41385540
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.