Re: [PATCH v4 09/12] KVM: selftests: Add basic stress test for save+restore and #PF handling

From: Sean Christopherson

Date: Tue Jul 28 2026 - 11:14:25 EST


On Mon, Jul 27, 2026, Yosry Ahmed wrote:
> diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
> index 88c6c8046ddec..e67b1e9893f68 100644
> --- a/tools/testing/selftests/kvm/Makefile.kvm
> +++ b/tools/testing/selftests/kvm/Makefile.kvm
> @@ -112,6 +112,7 @@ TEST_GEN_PROGS_x86 += x86/set_sregs_test
> TEST_GEN_PROGS_x86 += x86/smaller_maxphyaddr_emulation_test
> TEST_GEN_PROGS_x86 += x86/smm_test
> TEST_GEN_PROGS_x86 += x86/state_test
> +TEST_GEN_PROGS_x86 += x86/save_restore_pf_stress_test

Sort alphabetically (I'm guessing you forgot to move this when renaming from
stress_xxx to save_xxx).

> TEST_GEN_PROGS_x86 += x86/vmx_preemption_timer_test
> TEST_GEN_PROGS_x86 += x86/svm_vmcall_test
> TEST_GEN_PROGS_x86 += x86/svm_int_ctl_test
> diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h
> index 06d9ba1c4df33..2889782b0016b 100644
> --- a/tools/testing/selftests/kvm/include/x86/processor.h
> +++ b/tools/testing/selftests/kvm/include/x86/processor.h
> @@ -614,6 +614,15 @@ static inline void set_cr0(u64 val)
> __asm__ __volatile__("mov %0, %%cr0" : : "r" (val) : "memory");
> }
>
> +static inline u64 get_cr2(void)
> +{
> + u64 cr2;
> +
> + __asm__ __volatile__("mov %%cr2, %[cr2]"
> + : /* output */ [cr2]"=r"(cr2));

Drop the "/* output */" comment, if the reader doesn't know how asm constraints
work *and* can't deduce that it's an output given the function name and return
value, then they probably shouldn't be reading this code.

Oh, yeesh, all of these getters have that silly comment. Drop it here, I'll send
a patch to remove those bad examples.

> + return cr2;
> +}
> +