diff options
| author | Sean Christopherson <seanjc@google.com> | 2026-06-25 15:04:47 -0700 |
|---|---|---|
| committer | Sean Christopherson <seanjc@google.com> | 2026-07-08 13:41:19 -0700 |
| commit | de28ef6548a25bfb82ff0ea390821752ee7fb629 (patch) | |
| tree | f56001bda4b0610cc35bfd6bfe9954272d901113 | |
| parent | eb7313b66c59b4b8c135d3eb01f68268d4070594 (diff) | |
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 <kai.huang@intel.com>
Link: https://patch.msgid.link/20260625220450.3354415-7-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
| -rw-r--r-- | arch/x86/kvm/tss.h | 7 |
1 files changed, 7 insertions, 0 deletions
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 <linux/build_bug.h> +#include <linux/stddef.h> +#include <linux/types.h> + 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 |
