Re: [PATCH 02/29] KVM: API definitions for plane userspace exit
From: Sean Christopherson
Date: Tue Jun 03 2025 - 20:10:28 EST
On Tue, Apr 01, 2025, Paolo Bonzini wrote:
> Copy over the uapi definitions from the Documentation/ directory.
>
> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> ---
> include/uapi/linux/kvm.h | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index 1e0a511c43d0..b0cca93ebcb3 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -135,6 +135,16 @@ struct kvm_xen_exit {
> } u;
> };
>
> +struct kvm_plane_event_exit {
> +#define KVM_PLANE_EVENT_INTERRUPT 1
> + __u16 cause;
> + __u16 pending_event_planes;
> + __u16 target;
> + __u16 padding;
> + __u32 flags;
> + __u64 extra[8];
> +};
> +
> struct kvm_tdx_exit {
> #define KVM_EXIT_TDX_VMCALL 1
> __u32 type;
> @@ -262,7 +272,8 @@ struct kvm_tdx_exit {
> #define KVM_EXIT_NOTIFY 37
> #define KVM_EXIT_LOONGARCH_IOCSR 38
> #define KVM_EXIT_MEMORY_FAULT 39
> -#define KVM_EXIT_TDX 40
> +#define KVM_EXIT_PLANE_EVENT 40
> +#define KVM_EXIT_TDX 41
>
> /* For KVM_EXIT_INTERNAL_ERROR */
> /* Emulate instruction failed. */
> @@ -295,7 +306,13 @@ struct kvm_run {
> /* in */
> __u8 request_interrupt_window;
> __u8 HINT_UNSAFE_IN_KVM(immediate_exit);
> - __u8 padding1[6];
> +
> + /* in/out */
> + __u8 plane;
We should add padding before or after "plane"; there's a 1-byte hole here that's
hard to spot at first glance (ran pahole just to verify my eyeballs):
struct kvm_run {
__u8 request_interrupt_window; /* 0 1 */
__u8 immediate_exit__unsafe; /* 1 1 */
__u8 plane; /* 2 1 */
/* XXX 1 byte hole, try to pack */
__u16 suspended_planes; /* 4 2 */
__u16 req_exit_planes; /* 6 2 */
}
Probably pad before, so that "plane" is just before the xxx_planes fields?