Re: [PATCH 6/6] KVM: selftests: x86: Add test for KVM_PRE_FAULT_MEMORY

Isaku Yamahata
2024-04-22T17:50:35Z

On Fri, Apr 19, 2024 at 04:59:27AM -0400,
Paolo Bonzini <pbonzini@redhat.com> wrote:

> From: Isaku Yamahata <isaku.yamahata@intel.com>
>
> Add a test case to exercise KVM_PRE_FAULT_MEMORY and run the guest to access the
> pre-populated area. It tests KVM_PRE_FAULT_MEMORY ioctl for KVM_X86_DEFAULT_VM
> and KVM_X86_SW_PROTECTED_VM.
>
> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
> Message-ID: <32427791ef42e5efaafb05d2ac37fa4372715f47.1712785629.git.isaku.yamahata@intel.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> tools/include/uapi/linux/kvm.h | 8 +
> tools/testing/selftests/kvm/Makefile | 1 +
> .../selftests/kvm/pre_fault_memory_test.c | 146 ++++++++++++++++++
> 3 files changed, 155 insertions(+)
> create mode 100644 tools/testing/selftests/kvm/pre_fault_memory_test.c
>
> diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
> index c3308536482b..4d66d8afdcd1 100644
> --- a/tools/include/uapi/linux/kvm.h
> +++ b/tools/include/uapi/linux/kvm.h
> @@ -2227,4 +2227,12 @@ struct kvm_create_guest_memfd {
> __u64 reserved[6];
> };
>
> +#define KVM_PRE_FAULT_MEMORY _IOWR(KVMIO, 0xd5, struct kvm_pre_fault_memory)
> +
> +struct kvm_pre_fault_memory {
> + __u64 gpa;
> + __u64 size;
> + __u64 flags;

nitpick: catch up for struct update.
+ __u64 padding[5];

> +};
> +
> #endif /* __LINUX_KVM_H */
--
Isaku Yamahata <isaku.yamahata@intel.com>