From de28ef6548a25bfb82ff0ea390821752ee7fb629 Mon Sep 17 00:00:00 2001 From: Sean Christopherson Date: Thu, 25 Jun 2026 15:04:47 -0700 Subject: [PATCH] KVM: x86: Add static asserts to document connection b/w TSS structs and macros Add static asserts to sanity check the I/O permission map and TSS size macros against tss_segment_32. Alternatively, the macros could simply use offsetof() and sizeof(), but having literal numbers makes it easier to understand the bigger picture, and provides a good excuse for the sanity checks. Opportunistically add the necessary includes to make tss.h self sufficient. No functional change intended. Reviewed-by: Kai Huang Link: https://patch.msgid.link/20260625220450.3354415-7-seanjc@google.com Signed-off-by: Sean Christopherson --- arch/x86/kvm/tss.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/tss.h b/arch/x86/kvm/tss.h index 117bf8bec07d..55ced8975840 100644 --- a/arch/x86/kvm/tss.h +++ b/arch/x86/kvm/tss.h @@ -2,6 +2,10 @@ #ifndef __TSS_SEGMENT_H #define __TSS_SEGMENT_H +#include +#include +#include + struct tss_segment_32 { u32 prev_task_link; u32 esp0; @@ -64,4 +68,7 @@ struct tss_segment_16 { #define RMODE_TSS_SIZE \ (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) +static_assert(offsetof(struct tss_segment_32, io_map) == TSS_IOPB_BASE_OFFSET); +static_assert(sizeof(struct tss_segment_32) == TSS_BASE_SIZE); + #endif