From cfd54835e6e8a28c743dc7d67c662d151ab4923a Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 9 Sep 2013 10:23:32 +0200 Subject: VMX: use proper instruction mnemonics if assembler supports them With the hex byte emission we were taking away a good part of flexibility from the compiler, as for simplicity reasons these were built using fixed operands. All half way modern build environments would allow using the mnemonics (but we can't disable the hex variants yet, since the binutils around at the time gcc 4.1 got released didn't support these yet). I didn't convert __vmread() yet because that would, just like for __vmread_safe(), imply converting to a macro so that the output operand can be the caller supplied variable rather than an intermediate one. As that would require touching all invocation points of __vmread() (of which there are quite a few), I'd first like to be certain the approach is acceptable; the main question being whether the now conditional code might be considered to cause future maintenance issues, and the second being that of parameter/argument ordering (here I made __vmread_safe() match __vmwrite(), but one could also take the position that read and write should use the inverse order of one another, in line with the actual instruction operands). Additionally I was quite puzzled to find that all the asm()-s involved here have memory clobbers - what are they needed for? Or can they be dropped at least in some cases? Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Reviewed-by: Tim Deegan --- Config.mk | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Config.mk') diff --git a/Config.mk b/Config.mk index f169be482b..a26c7c0f2b 100644 --- a/Config.mk +++ b/Config.mk @@ -4,6 +4,12 @@ ifeq ($(filter /%,$(XEN_ROOT)),) $(error XEN_ROOT must be absolute) endif +# Convenient variables +comma := , +squote := ' +empty := +space := $(empty) $(empty) + # fallback for older make realpath = $(wildcard $(foreach file,$(1),$(shell cd -P $(dir $(file)) && echo "$$PWD/$(notdir $(file))"))) @@ -128,6 +134,21 @@ endef check-$(gcc) = $(call cc-ver-check,CC,0x040100,"Xen requires at least gcc-4.1") $(eval $(check-y)) +# as-insn: Check whether assembler supports an instruction. +# Usage: cflags-y += $(call as-insn "insn",option-yes,option-no) +as-insn = $(if $(shell echo 'void _(void) { asm volatile ( $(2) ); }' \ + | $(1) -c -x c -o /dev/null - 2>&1),$(4),$(3)) + +# as-insn-check: Add an option to compilation flags, but only if insn is +# supported by assembler. +# Usage: $(call as-insn-check CFLAGS,CC,"nop",-DHAVE_GAS_NOP) +as-insn-check = $(eval $(call as-insn-check-closure,$(1),$(2),$(3),$(4))) +define as-insn-check-closure + ifeq ($$(call as-insn,$$($(2)),$(3),y,n),y) + $(1) += $(4) + endif +endef + define buildmakevars2shellvars export PREFIX="$(PREFIX)"; \ export XEN_SCRIPT_DIR="$(XEN_SCRIPT_DIR)"; \ -- cgit v1.2.3