On Wed, Jul 26, 2023 at 12:34:15PM +0200, Jan Beulich wrote:
> --- a/xen/arch/x86/Kconfig
> +++ b/xen/arch/x86/Kconfig
> @@ -118,6 +118,36 @@ config HVM
>  
>         If unsure, say Y.
>  
> +choice
> +     prompt "base psABI level"
> +     default X86_64_BASELINE
> +     help
> +       The psABI defines 4 levels of ISA extension sets as a coarse granular
> +       way of identifying advanced functionality that would be uniformly
> +       available in respectively newer hardware.  While v4 is not really of
> +       interest for Xen, the others can be selected here, making the
> +       resulting Xen no longer work on older hardware.  This option won't
> +       have any effect if the toolchain doesn't support the distinction.
> +
> +       If unsure, stick to the default.
> +
> +config X86_64_BASELINE
> +     bool "baseline"
> +
> +config X86_64_V2
> +     bool "v2"
> +     help
> +       This enables POPCNT and CX16, besides other extensions which are of
> +       no interest here.
> +
> +config X86_64_V3
> +     bool "v3"
> +     help
> +       This enables BMI, BMI2, LZCNT, MOVBE, and XSAVE, besides other
> +       extensions which are of no interest here.
> +
> +endchoice
> +
>  config XEN_SHSTK
>       bool "Supervisor Shadow Stacks"
>       depends on HAS_AS_CET_SS
> --- a/xen/arch/x86/arch.mk
> +++ b/xen/arch/x86/arch.mk
> @@ -36,6 +36,29 @@ CFLAGS += -mno-red-zone -fpic
>  # the SSE setup for variadic function calls.
>  CFLAGS += -mno-mmx -mno-sse $(call cc-option,$(CC),-mskip-rax-setup)
>  
> +# Enable the selected baseline ABI, if supported by the compiler.
> +x86-64-$(CONFIG_X86_64_BASELINE) :=
> +x86-64-$(CONFIG_X86_64_V2) := x86-64-v2
> +x86-64-$(CONFIG_X86_64_V3) := x86-64-v3
> +
> +ifneq ($(x86-64-y),)
> +CFLAGS-psabi := $(call cc-option,$(CC),-march=$(x86-64-y))
> +
> +ifeq ($(CFLAGS-psabi),)
> +# Fall back to using the subset of -m... options that are of interest.
> +x86-64-v2 := -mpopcnt -mcx16
> +x86-64-v3 := $(x86-64-v2) -mbmi -mbmi2 -mlzcnt -mmovbe -mxsave
> +$(call cc-options-add,CFLAGS-psabi,CC,$($(x86-64-y)))
> +
> +ifneq ($(strip $(CFLAGS-psabi)),$($(x86-64-y)))
> +$(warning Options not recognized by $(CC): $(filter-out 
> $(CFLAGS-psabi),$($(x86-64-y))))
> +XEN_CONFIG_UNSATISFIED += X86_64_Vn

I think I understand Andrew's point on the previous version of this
patch. Here, we barely just print a warning if the compiler isn't
capable to do what we ask, then do the build and maybe print something
after the fact. So we can end up with a build of Xen with an embedded
.config which says X86_64_V3 where in fact it's only a build with the
baseline ABI.

Can't we just fail the build right here instead?

I don't see any need to let Kconfig know if the compiler can do
x86-64-vX or not, beside only presenting actual available options in
`make *config`, and it would override options selected by editing
.config directly.

> +endif
> +endif # CFLAGS-psabi
> +
> +CFLAGS += $(CFLAGS-psabi)
> +endif # x86-64-y

Cheers,

-- 
Anthony PERARD

Reply via email to