Hi Jing,
On 8/8/23 00:22, Jing Zhang wrote:
Import automatic system register definition generation from kernel and
update system register usage accordingly.
Signed-off-by: Jing Zhang <jingzhangos@xxxxxxxxxx>
---
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index c692cc86e7da..a8cf0cb04db7 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -200,14 +200,15 @@ ifeq ($(ARCH),x86_64)
LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
else
LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
+ARCH_GENERATED_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include/generated
endif
CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
- -Wno-gnu-variable-sized-type-not-at-end -MD\
+ -Wno-gnu-variable-sized-type-not-at-end -MD \
-fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \
-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
-I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
-I$(<D) -Iinclude/$(ARCH_DIR) -I ../rseq -I.. $(EXTRA_CFLAGS) \
- $(KHDR_INCLUDES)
+ -I$(ARCH_GENERATED_INCLUDE) $(KHDR_INCLUDES)
ifeq ($(ARCH),s390)
CFLAGS += -march=z10
endif
@@ -255,8 +256,16 @@ $(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S
$(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@
+ifeq ($(ARCH),arm64)
+GEN_SYSREGS := $(ARCH_GENERATED_INCLUDE)/asm/sysreg-defs.h
+ARCH_TOOLS := $(top_srcdir)/tools/arch/$(ARCH)/tools/
+
+$(GEN_SYSREGS): $(ARCH_TOOLS)/gen-sysreg.awk $(ARCH_TOOLS)/sysreg
+ mkdir -p $(dir $@); awk -f $(ARCH_TOOLS)/gen-sysreg.awk $(ARCH_TOOLS)/sysreg > $@
+endif
+
x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
-$(TEST_GEN_PROGS): $(LIBKVM_OBJS)
+$(TEST_GEN_PROGS): $(LIBKVM_OBJS) $(GEN_SYSREGS)
I don't this this really works. Since the $(GEN_SYSREG) is the
prerequisites of $(TEST_GEN_PROGS). Only when $(TEST_GEN_PROGS) being
compiled, the $(GEN_SYSREG) can be generated.
But the fact is, the $(TEST_GEN_PROGS) is relies on $(TEST_GEN_OBJ),
which means $(TEST_GEN_OBJ) will be compiled before $(TEST_GEN_PROGS),
but $(TEST_GEN_OBJ) depends on $(GEN_SYSREG) again, at the time, the
$(GEN_SYSREG) hasn't been generated, so it will has error:
No such file or directory.
#include "asm/sysreg-defs.h"
I think the correct way to generate $(GEN_SYSREGS) is add a prerequisite
for $(TEST_GEN_OBJ), like:
$(TEST_GEN_OBJ): $(GEN_SYSREGS)
Thanks,
Shaoqin
$(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
--
Shaoqin