On Mon, May 16, 2022 at 3:17 PM Peter Xu <peterx@xxxxxxxxxx> wrote: > > On Fri, Apr 29, 2022 at 06:39:35PM +0000, David Matlack wrote: > > +static void perf_test_l1_guest_code(struct vmx_pages *vmx, uint64_t vcpu_id) > > +{ > > +#define L2_GUEST_STACK_SIZE 64 > > + unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE]; > > + unsigned long *rsp; > > + > > + GUEST_ASSERT(vmx->vmcs_gpa); > > + GUEST_ASSERT(prepare_for_vmx_operation(vmx)); > > + GUEST_ASSERT(load_vmcs(vmx)); > > + GUEST_ASSERT(ept_1g_pages_supported()); > > + > > + rsp = &l2_guest_stack[L2_GUEST_STACK_SIZE - 1]; > > + *rsp = vcpu_id; > > + prepare_vmcs(vmx, perf_test_l2_guest_entry, rsp); > > Just to purely ask: is this setting the same stack pointer to all the > vcpus? No, but I understand the confusion since typically selftests use symbols like "l2_guest_code" that are global. But "l2_guest_stack" is actually a local variable so it will be allocated on the stack. Each vCPU runs on a separate stack, so they will each run with their own "l2_guest_stack". > > > + > > + GUEST_ASSERT(!vmlaunch()); > > + GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL); > > + GUEST_DONE(); > > +} > > [...] > > > +/* Identity map the entire guest physical address space with 1GiB Pages. */ > > +void nested_map_all_1g(struct vmx_pages *vmx, struct kvm_vm *vm) > > +{ > > + __nested_map(vmx, vm, 0, 0, vm->max_gfn << vm->page_shift, PG_LEVEL_1G); > > +} > > Could max_gfn be large? Could it consumes a bunch of pages even if mapping > 1G only? Since the selftests only support 4-level EPT, this will use at most 513 pages. If we add support for 5-level EPT we may need to revisit this approach. > > Thanks, > > -- > Peter Xu >