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>
This commit is contained in:
Sean Christopherson 2026-06-25 15:04:47 -07:00
parent eb7313b66c
commit de28ef6548

View File

@ -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