Sagi Shahar wrote:
> If virt_map() is called before any call to ____vm_vaddr_alloc() it
> will create the mapping using an invalid pgd.
> 
> Add call to virt_pgd_alloc() as part of virt_map() before creating the
> mapping, similarly to ____vm_vaddr_alloc()
> 
> Signed-off-by: Sagi Shahar <sa...@google.com>

Reviewed-by: Ira Weiny <ira.we...@intel.com>

> ---
>  tools/testing/selftests/kvm/lib/kvm_util.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c 
> b/tools/testing/selftests/kvm/lib/kvm_util.c
> index c3f5142b0a54..b4c8702ba4bd 100644
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -1609,6 +1609,7 @@ void virt_map(struct kvm_vm *vm, uint64_t vaddr, 
> uint64_t paddr,
>       TEST_ASSERT(vaddr + size > vaddr, "Vaddr overflow");
>       TEST_ASSERT(paddr + size > paddr, "Paddr overflow");
>  
> +     virt_pgd_alloc(vm);
>       while (npages--) {
>               virt_pg_map(vm, vaddr, paddr);
>               sparsebit_set(vm->vpages_mapped, vaddr >> vm->page_shift);
> -- 
> 2.51.0.rc1.193.gad69d77794-goog
> 



Reply via email to