From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
David Matlack <dmatlack@google.com>
Cc: Jim Mattson <jmattson@google.com>, Peter Xu <peterx@redhat.com>,
Yang Zhong <yang.zhong@intel.com>,
Wei Wang <wei.w.wang@intel.com>, Ben Gardon <bgardon@google.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Fix nx_huge_pages_test on TDP-disabled hosts
Date: Tue, 27 Sep 2022 14:13:10 +0200 [thread overview]
Message-ID: <d0fc4ef7-6e7c-3734-225b-411c57b4acaa@redhat.com> (raw)
In-Reply-To: <YzIlxmMOeSZHsnOu@google.com>
On 9/27/22 00:20, Sean Christopherson wrote:
> void __virt_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr,
> uint64_t nr_bytes, size_t page_size)
> {
> uint64_t nr_pages = DIV_ROUND_UP(nr_bytes, page_size);
>
> TEST_ASSERT(vaddr + size > vaddr, "Vaddr overflow");
> TEST_ASSERT(paddr + size > paddr, "Paddr overflow");
>
> while (npages--) {
> virt_pg_map(vm, vaddr, paddr);
> vaddr += page_size;
> paddr += page_size;
> }
> }
>
> void virt_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr,
> uint64_t nr_bytes)
> {
> __virt_map(vm, vaddr, paddr, nr_bytes, vm->page_size);
> }
I would just keep nr_pages in virt_map to begin with, for the sake of
this patch. Changing virt_map can be done later (and should be separate
anyway).
>> - virt_map(vm, HPAGE_GVA, HPAGE_GPA, HPAGE_SLOT_NPAGES);
>> + /*
>> + * Use 2MiB virtual mappings so that KVM can map the region with huge
>> + * pages even if TDP is disabled.
>> + */
>> + virt_map_2m(vm, HPAGE_GVA, HPAGE_GPA, HPAGE_SLOT_2MB_PAGES);
>
> Hmm, what about probing TDP support and deliberately using 4KiB pages when TDP is
> enabled? That would give a bit of bonus coverage by verifying that KVM creates
> huge pages irrespective of guest mapping level.
Nice idea indeed.
Paolo
prev parent reply other threads:[~2022-09-27 12:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-26 17:52 [PATCH] KVM: selftests: Fix nx_huge_pages_test on TDP-disabled hosts David Matlack
2022-09-26 22:20 ` Sean Christopherson
2022-09-27 12:13 ` Paolo Bonzini [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=d0fc4ef7-6e7c-3734-225b-411c57b4acaa@redhat.com \
--to=pbonzini@redhat.com \
--cc=bgardon@google.com \
--cc=dmatlack@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=seanjc@google.com \
--cc=wei.w.wang@intel.com \
--cc=yang.zhong@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