On Thu, Mar 7, 2024 at 3:27 PM David Matlack <dmatlack@xxxxxxxxxx> wrote: > > On 2024-03-07 02:37 PM, Sean Christopherson wrote: > > On Thu, Mar 07, 2024, David Matlack wrote: > > > Create memslot 0 at 0x100000000 (4GiB) to avoid it overlapping with > > > KVM's private memslot for the APIC-access page. > > > > This is going to cause other problems, e.g. from max_guest_memory_test.c > > > > /* > > * Skip the first 4gb and slot0. slot0 maps <1gb and is used to back > > * the guest's code, stack, and page tables. Because selftests creates > > * an IRQCHIP, a.k.a. a local APIC, KVM creates an internal memslot > > * just below the 4gb boundary. This test could create memory at > > * 1gb-3gb,but it's simpler to skip straight to 4gb. > > */ > > const uint64_t start_gpa = SZ_4G; > > > > Trying to move away from starting at '0' is going to be problematic/annoying, > > e.g. using low memory allows tests to safely assume 4GiB+ is always available. > > And I'd prefer not to make the infrastucture all twisty and weird for all tests > > just because memstress tests want to play with huge amounts of memory. > > > > Any chance we can solve this by using huge pages in the guest, and adjusting the > > gorilla math in vm_nr_pages_required() accordingly? There's really no reason to > > use 4KiB pages for a VM with 256GiB of memory. That'd also be more represantitive > > of real world workloads (at least, I hope real world workloads are using 2MiB or > > 1GiB pages in this case). > > There are real world workloads that use TiB of RAM with 4KiB mappings > (looking at you SAP HANA). > > What about giving tests an explicit "start" GPA they can use? That would > fix max_guest_memory_test and avoid tests making assumptions about 4GiB > being a magically safe address to use. > > e.g. Something like this on top: Gah, I missed nx_huge_page_test.c, which needs similar changes to max_memory_test.c. Also if you prefer the "start" address be a compile time constant we can pick an arbitrary number above 4GiB and use that (e.g. start=32GiB would be more than enough for a 12TiB guest).