From: Sean Christopherson <seanjc@google.com>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Use "gpa" and "gva" for local variable names in pre-fault test
Date: Fri, 17 Oct 2025 15:17:22 -0700 [thread overview]
Message-ID: <aPLAch-UpHtCeK_s@google.com> (raw)
In-Reply-To: <aO2pROT5K+4J7j9k@yzhao56-desk.sh.intel.com>
On Tue, Oct 14, 2025, Yan Zhao wrote:
> On Tue, Oct 07, 2025 at 03:45:15PM -0700, Sean Christopherson wrote:
> > - guest_test_phys_mem = align_down(guest_test_phys_mem, alignment);
> > - guest_test_virt_mem = guest_test_phys_mem & ((1ULL << (vm->va_bits - 1)) - 1);
> > + gpa = align_down(gpa, alignment);
> > + gva = gpa & ((1ULL << (vm->va_bits - 1)) - 1);
> >
> > - vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS,
> > - guest_test_phys_mem, TEST_SLOT, TEST_NPAGES,
> > + vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, gpa,
> Wrap at 80 characters?
>
> > + TEST_SLOT, TEST_NPAGES,
Hmm, yeah. Probably this?
vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, gpa, TEST_SLOT,
TEST_NPAGES, private ? KVM_MEM_GUEST_MEMFD : 0);
which I like more than:
vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, gpa, TEST_SLOT,
TEST_NPAGES,
private ? KVM_MEM_GUEST_MEMFD : 0);
> > private ? KVM_MEM_GUEST_MEMFD : 0);
> > - virt_map(vm, guest_test_virt_mem, guest_test_phys_mem, TEST_NPAGES);
> > + virt_map(vm, gva, gpa, TEST_NPAGES);
> >
> > if (private)
> > - vm_mem_set_private(vm, guest_test_phys_mem, TEST_SIZE);
> > + vm_mem_set_private(vm, gpa, TEST_SIZE);
> >
> > - pre_fault_memory(vcpu, guest_test_phys_mem, 0, SZ_2M, 0, private);
> > - pre_fault_memory(vcpu, guest_test_phys_mem, SZ_2M, PAGE_SIZE * 2, PAGE_SIZE, private);
> > - pre_fault_memory(vcpu, guest_test_phys_mem, TEST_SIZE, PAGE_SIZE, PAGE_SIZE, private);
> > + pre_fault_memory(vcpu, gpa, 0, SZ_2M, 0, private);
> > + pre_fault_memory(vcpu, gpa, SZ_2M, PAGE_SIZE * 2, PAGE_SIZE, private);
> > + pre_fault_memory(vcpu, gpa, TEST_SIZE, PAGE_SIZE, PAGE_SIZE, private);
> >
> > - vcpu_args_set(vcpu, 1, guest_test_virt_mem);
> > + vcpu_args_set(vcpu, 1, gva);
> Should we cleanup guest_code() as below?
>
> -static void guest_code(uint64_t base_gpa)
> +static void guest_code(uint64_t base_gva)
> {
> volatile uint64_t val __used;
> int i;
>
> for (i = 0; i < TEST_NPAGES; i++) {
> - uint64_t *src = (uint64_t *)(base_gpa + i * PAGE_SIZE);
> + uint64_t *src = (uint64_t *)(base_gva + i * PAGE_SIZE);
>
> val = *src;
> }
Yah, no reason not to (lot's of tests assume GPA==GVA, but that's not a good
reason to be deliberately confusing).
next prev parent reply other threads:[~2025-10-17 22:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 22:45 [PATCH] KVM: selftests: Use "gpa" and "gva" for local variable names in pre-fault test Sean Christopherson
2025-10-14 1:37 ` Yan Zhao
2025-10-17 22:17 ` Sean Christopherson [this message]
2025-11-04 17:45 ` Sean Christopherson
2025-11-05 2:02 ` Yan Zhao
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=aPLAch-UpHtCeK_s@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yan.y.zhao@intel.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