Re: [PATCH v14 05/22] KVM: selftests: Expose segment definitions to assembly files

From: Ackerley Tng

Date: Tue Sep 08 2026 - 15:04:11 EST


Lisa Wang <wyihan@xxxxxxxxxx> writes:

> From: Sagi Shahar <sagis@xxxxxxxxxx>
>
> Move kernel segment definitions to a separate file which can be included
> from assembly files.
>
> Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> Reviewed-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx>
> Signed-off-by: Sagi Shahar <sagis@xxxxxxxxxx>
> Signed-off-by: Lisa Wang <wyihan@xxxxxxxxxx>
> Reviewed-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>
> ---
> tools/testing/selftests/kvm/include/x86/processor_asm.h | 12 ++++++++++++
> tools/testing/selftests/kvm/lib/x86/processor.c | 5 +----
> 2 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/x86/processor_asm.h b/tools/testing/selftests/kvm/include/x86/processor_asm.h
> new file mode 100644
> index 000000000000..713b6bc0aeb7
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/include/x86/processor_asm.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Used for storing defines used by both c and assembly code.
> + */
> +#ifndef SELFTEST_KVM_PROCESSOR_ASM_H
> +#define SELFTEST_KVM_PROCESSOR_ASM_H
> +
> +#define KERNEL_CS 0x8
> +#define KERNEL_DS 0x10
> +#define KERNEL_TSS 0x18
> +
> +#endif /* SELFTEST_KVM_PROCESSOR_ASM_H */
> diff --git a/tools/testing/selftests/kvm/lib/x86/processor.c b/tools/testing/selftests/kvm/lib/x86/processor.c
> index 7d23344854cc..97acc5aaf7b7 100644
> --- a/tools/testing/selftests/kvm/lib/x86/processor.c
> +++ b/tools/testing/selftests/kvm/lib/x86/processor.c
> @@ -8,6 +8,7 @@
> #include "kvm_util.h"
> #include "pmu.h"
> #include "processor.h"
> +#include "processor_asm.h"
> #include "smm.h"
> #include "svm_util.h"
> #include "sev.h"
> @@ -18,10 +19,6 @@
> #define NUM_INTERRUPTS 256
> #endif
>
> -#define KERNEL_CS 0x8
> -#define KERNEL_DS 0x10
> -#define KERNEL_TSS 0x18
> -
> gva_t exception_handlers;
> bool host_cpu_is_amd;
> bool host_cpu_is_intel;
>
> --
> 2.55.0.229.g6434b31f56-goog

Reviewed-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>