mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: isaku.yamahata@intel.com, binbin.wu@linux.intel.com,
	seanjc@google.com, rick.p.edgecombe@intel.com
Subject: Re: [PATCH 6/6] KVM: selftests: x86: Add test for KVM_PRE_FAULT_MEMORY
Date: Wed, 24 Apr 2024 09:59:43 +0800	[thread overview]
Message-ID: <60c1bfe3-2210-4670-afa9-d4f789208650@intel.com> (raw)
In-Reply-To: <b7d6bb0c-6ee4-4f93-a1a0-5ee6f49c0c59@intel.com>

On 4/23/2024 11:18 PM, Xiaoyao Li wrote:
> On 4/19/2024 4:59 PM, Paolo Bonzini wrote:
> 
> ...
> 
>> +static void __test_pre_fault_memory(unsigned long vm_type, bool private)
>> +{
>> +    const struct vm_shape shape = {
>> +        .mode = VM_MODE_DEFAULT,
>> +        .type = vm_type,
>> +    };
>> +    struct kvm_vcpu *vcpu;
>> +    struct kvm_run *run;
>> +    struct kvm_vm *vm;
>> +    struct ucall uc;
>> +
>> +    uint64_t guest_test_phys_mem;
>> +    uint64_t guest_test_virt_mem;
>> +    uint64_t alignment, guest_page_size;
>> +
>> +    vm = vm_create_shape_with_one_vcpu(shape, &vcpu, guest_code);
>> +
>> +    alignment = guest_page_size = 
>> vm_guest_mode_params[VM_MODE_DEFAULT].page_size;
>> +    guest_test_phys_mem = (vm->max_gfn - TEST_NPAGES) * guest_page_size;
>> +#ifdef __s390x__
>> +    alignment = max(0x100000UL, guest_page_size);
>> +#else
>> +    alignment = SZ_2M;
>> +#endif
>> +    guest_test_phys_mem = align_down(guest_test_phys_mem, alignment);
>> +    guest_test_virt_mem = guest_test_phys_mem;
> 
> guest_test_virt_mem cannot be assigned as guest_test_phys_mem, which 
> leads to following virt_map() fails with

The root cause is that vm->pa_bits is 52 while vm->va_bits is 48. So 
vm->max_gfn is beyond the capability of va space

> ==== Test Assertion Failure ====
>    lib/x86_64/processor.c:197: sparsebit_is_set(vm->vpages_valid, (vaddr 
>  >> vm->page_shift))
>    pid=4773 tid=4773 errno=0 - Success
>       1    0x000000000040f55c: __virt_pg_map at processor.c:197
>       2    0x000000000040605e: virt_pg_map at kvm_util_base.h:1065
>       3     (inlined by) virt_map at kvm_util.c:1571
>       4    0x0000000000402b75: __test_pre_fault_memory at 
> pre_fault_memory_test.c:96
>       5    0x000000000040246e: test_pre_fault_memory at 
> pre_fault_memory_test.c:133 (discriminator 3)
>       6     (inlined by) main at pre_fault_memory_test.c:140 
> (discriminator 3)
>       7    0x00007fcb68429d8f: ?? ??:0
>       8    0x00007fcb68429e3f: ?? ??:0
>       9    0x00000000004024e4: _start at ??:?
>    Invalid virtual address, vaddr: 0xfffffffc00000
> 
>> +
>> +    vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS,
>> +                    guest_test_phys_mem, TEST_SLOT, TEST_NPAGES,
>> +                    private ? KVM_MEM_GUEST_MEMFD : 0);
>> +    virt_map(vm, guest_test_virt_mem, guest_test_phys_mem, TEST_NPAGES);
> 
> 
> 
> 
> 


      reply	other threads:[~2024-04-24  1:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19  8:59 [PATCH v4 0/6] KVM: Guest Memory Pre-Population API Paolo Bonzini
2024-04-19  8:59 ` [PATCH 1/6] KVM: Document KVM_PRE_FAULT_MEMORY ioctl Paolo Bonzini
2024-04-22 17:55   ` Isaku Yamahata
2024-04-19  8:59 ` [PATCH 2/6] KVM: Add KVM_PRE_FAULT_MEMORY vcpu ioctl to pre-populate guest memory Paolo Bonzini
2024-04-22  5:39   ` Binbin Wu
2024-04-24 16:05     ` Paolo Bonzini
2024-04-22  7:19   ` Binbin Wu
2024-04-22 18:00   ` Isaku Yamahata
2024-04-19  8:59 ` [PATCH 3/6] KVM: x86/mmu: Extract __kvm_mmu_do_page_fault() Paolo Bonzini
2024-04-22  8:46   ` Xiaoyao Li
2024-06-12 20:47     ` Sean Christopherson
2024-04-19  8:59 ` [PATCH 4/6] KVM: x86/mmu: Make __kvm_mmu_do_page_fault() return mapped level Paolo Bonzini
2024-04-19  8:59 ` [PATCH 5/6] KVM: x86: Implement kvm_arch_vcpu_pre_fault_memory() Paolo Bonzini
2024-04-22 15:37   ` Xiaoyao Li
2024-06-12 21:02     ` Sean Christopherson
2024-04-19  8:59 ` [PATCH 6/6] KVM: selftests: x86: Add test for KVM_PRE_FAULT_MEMORY Paolo Bonzini
2024-04-22 17:50   ` Isaku Yamahata
2024-04-23 15:18   ` Xiaoyao Li
2024-04-24  1:59     ` Xiaoyao Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60c1bfe3-2210-4670-afa9-d4f789208650@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®