diff mbox series

[v3,3/5] KVM: selftests: Generate sysreg-defs.h and add to include path

Message ID 20231011195740.3349631-4-oliver.upton@linux.dev (mailing list archive)
State New, archived
Headers show
Series KVM: selftests: Add ID reg test, update headers | expand

Commit Message

Oliver Upton Oct. 11, 2023, 7:57 p.m. UTC
Start generating sysreg-defs.h for arm64 builds in anticipation of
updating sysreg.h to a version that depends on it.

Reviewed-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
 tools/testing/selftests/kvm/Makefile | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

Comments

Eric Auger Oct. 18, 2023, 9:52 a.m. UTC | #1
Hi Oliver,

On 10/11/23 21:57, Oliver Upton wrote:
> Start generating sysreg-defs.h for arm64 builds in anticipation of
> updating sysreg.h to a version that depends on it.
> 
> Reviewed-by: Mark Brown <broonie@kernel.org>
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric

> ---
>  tools/testing/selftests/kvm/Makefile | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
> index a3bb36fb3cfc..07b3f4dc1a77 100644
> --- a/tools/testing/selftests/kvm/Makefile
> +++ b/tools/testing/selftests/kvm/Makefile
> @@ -17,6 +17,17 @@ else
>  	ARCH_DIR := $(ARCH)
>  endif
>  
> +ifeq ($(ARCH),arm64)
> +arm64_tools_dir := $(top_srcdir)/tools/arch/arm64/tools/
> +GEN_HDRS := $(top_srcdir)/tools/arch/arm64/include/generated/
> +CFLAGS += -I$(GEN_HDRS)
> +
> +prepare:
> +	$(MAKE) -C $(arm64_tools_dir)
> +else
> +prepare:
> +endif
> +
>  LIBKVM += lib/assert.c
>  LIBKVM += lib/elf.c
>  LIBKVM += lib/guest_modes.c
> @@ -256,13 +267,18 @@ $(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c
>  $(SPLIT_TESTS_TARGETS): %: %.o $(SPLIT_TESTS_OBJS)
>  	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
>  
> -EXTRA_CLEAN += $(LIBKVM_OBJS) $(TEST_DEP_FILES) $(TEST_GEN_OBJ) $(SPLIT_TESTS_OBJS) cscope.*
> +EXTRA_CLEAN += $(GEN_HDRS) \
> +	       $(LIBKVM_OBJS) \
> +	       $(SPLIT_TESTS_OBJS) \
> +	       $(TEST_DEP_FILES) \
> +	       $(TEST_GEN_OBJ) \
> +	       cscope.*
>  
>  x := $(shell mkdir -p $(sort $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
> -$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c
> +$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c prepare
>  	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
>  
> -$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S
> +$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S prepare
>  	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
>  
>  # Compile the string overrides as freestanding to prevent the compiler from
> @@ -274,6 +290,7 @@ $(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
>  x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
>  $(TEST_GEN_PROGS): $(LIBKVM_OBJS)
>  $(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
> +$(TEST_GEN_OBJ): prepare
>  
>  cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
>  cscope:
Nina Schoetterl-Glausch Oct. 23, 2023, 1:53 p.m. UTC | #2
On Wed, 2023-10-11 at 19:57 +0000, Oliver Upton wrote:
> Start generating sysreg-defs.h for arm64 builds in anticipation of
> updating sysreg.h to a version that depends on it.
> 
> Reviewed-by: Mark Brown <broonie@kernel.org>
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> ---
>  tools/testing/selftests/kvm/Makefile | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
> index a3bb36fb3cfc..07b3f4dc1a77 100644
> --- a/tools/testing/selftests/kvm/Makefile
> +++ b/tools/testing/selftests/kvm/Makefile
> @@ -17,6 +17,17 @@ else
>  	ARCH_DIR := $(ARCH)
>  endif
> 
> +ifeq ($(ARCH),arm64)
> +arm64_tools_dir := $(top_srcdir)/tools/arch/arm64/tools/
> +GEN_HDRS := $(top_srcdir)/tools/arch/arm64/include/generated/
> +CFLAGS += -I$(GEN_HDRS)
> +
> +prepare:
> +	$(MAKE) -C $(arm64_tools_dir)
> +else
> +prepare:

This is a force target, all targets depending on this one will always have their recipe run,
so we'll pretty much rebuild everything.
Is this intentional?

> +endif
> +
>  LIBKVM += lib/assert.c
>  LIBKVM += lib/elf.c
>  LIBKVM += lib/guest_modes.c
> @@ -256,13 +267,18 @@ $(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c
>  $(SPLIT_TESTS_TARGETS): %: %.o $(SPLIT_TESTS_OBJS)
>  	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
> 
> -EXTRA_CLEAN += $(LIBKVM_OBJS) $(TEST_DEP_FILES) $(TEST_GEN_OBJ) $(SPLIT_TESTS_OBJS) cscope.*
> +EXTRA_CLEAN += $(GEN_HDRS) \
> +	       $(LIBKVM_OBJS) \
> +	       $(SPLIT_TESTS_OBJS) \
> +	       $(TEST_DEP_FILES) \
> +	       $(TEST_GEN_OBJ) \
> +	       cscope.*
> 
>  x := $(shell mkdir -p $(sort $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
> -$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c
> +$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c prepare
>  	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
> 
> -$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S
> +$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S prepare
>  	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
> 
>  # Compile the string overrides as freestanding to prevent the compiler from
> @@ -274,6 +290,7 @@ $(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
>  x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
>  $(TEST_GEN_PROGS): $(LIBKVM_OBJS)
>  $(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
> +$(TEST_GEN_OBJ): prepare
> 
>  cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
>  cscope:
Aishwarya TCV Oct. 25, 2023, 9:02 a.m. UTC | #3
On 11/10/2023 20:57, Oliver Upton wrote:
> Start generating sysreg-defs.h for arm64 builds in anticipation of
> updating sysreg.h to a version that depends on it.
> 
> Reviewed-by: Mark Brown <broonie@kernel.org>
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> ---
>  tools/testing/selftests/kvm/Makefile | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 

Hi Oliver,


Currently when building kselftest against next-master with arm64 arch
and defconfig+kselftest-kvm  “make[4]: *** [Makefile:26: prepare] Error
2” is observed.

The bisect log is below and a full log from a failing test job can be
seen here:

https://storage.kernelci.org/next/master/next-20231023/arm64/defconfig/gcc-10/logs/kselftest.log

make[4]: Entering directory '/tmp/kci/linux/tools/testing/selftests/kvm'
Makefile:270: warning: overriding recipe for target
'/tmp/kci/linux/build/kselftest/kvm/get-reg-list'
Makefile:265: warning: ignoring old recipe for target
'/tmp/kci/linux/build/kselftest/kvm/get-reg-list'
make -C ../../../../tools/arch/arm64/tools/
make[5]: Entering directory '/tmp/kci/linux/tools/arch/arm64/tools'
Makefile:10: ../tools/scripts/Makefile.include: No such file or directory
make[5]: *** No rule to make target '../tools/scripts/Makefile.include'.
 Stop.
make[5]: Leaving directory '/tmp/kci/linux/tools/arch/arm64/tools'
make[4]: *** [Makefile:26: prepare] Error 2
make[4]: Leaving directory '/tmp/kci/linux/tools/testing/selftests/kvm'

git bisect log
git bisect start
# good: [58720809f52779dc0f08e53e54b014209d13eebb] Linux 6.6-rc6
git bisect good 58720809f52779dc0f08e53e54b014209d13eebb
# bad: [4230ea146b1e64628f11e44290bb4008e391bc24] Add linux-next
specific files for 20231019
git bisect bad 4230ea146b1e64628f11e44290bb4008e391bc24
# good: [2958944f7786b88cb86f7b3377c1a8bda75fd506] Merge branch
'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git
git bisect good 2958944f7786b88cb86f7b3377c1a8bda75fd506
# good: [359cb2003c0c273b13ec11b3df076ceac95e5eda] Merge branch
'for-next' of
https://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.git
git bisect good 359cb2003c0c273b13ec11b3df076ceac95e5eda
# bad: [53cc85767a1dba86b892f72f18e44138ec5e3f83] Merge branch
'for-next' of
git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git
git bisect bad 53cc85767a1dba86b892f72f18e44138ec5e3f83
# good: [84ceabd4408bd0bae48b58e2c18ddc5263cd5be4] Merge branch
'next-integrity' of
git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity
git bisect good 84ceabd4408bd0bae48b58e2c18ddc5263cd5be4
# good: [35c2f21c0d4a633305773355e86b41e28d835f67] Merge branch 'master'
of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
git bisect good 35c2f21c0d4a633305773355e86b41e28d835f67
# bad: [92a288da516dc7aaab6e92ba3de7d51c415227b1] Merge branch
'topic/ppc-kvm' of
git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git
git bisect bad 92a288da516dc7aaab6e92ba3de7d51c415227b1
# good: [5df10099418f139bbf2f4e0d7b9a8727e76274ec] srcu: Explain why
callbacks invocations can't run concurrently
git bisect good 5df10099418f139bbf2f4e0d7b9a8727e76274ec
# good: [2ca9297790bdd24b4baa6e432d393e92272f7dc5] Merge branch
kvm-arm64/writable-id-regs into kvmarm/next
git bisect good 2ca9297790bdd24b4baa6e432d393e92272f7dc5
# good: [7ae3136edc0787c890e07fbd1d16d54557644068] Merge branch
'rcu/next' of
git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
git bisect good 7ae3136edc0787c890e07fbd1d16d54557644068
# bad: [50a1ee6541d7c7bac0a43b773b68f20c3ffcbe67] Merge branch 'next' of
git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git
git bisect bad 50a1ee6541d7c7bac0a43b773b68f20c3ffcbe67
# bad: [54a9ea73527d55ab746d5425e10f3fa748e00e70] KVM: arm64: selftests:
Test for setting ID register from usersapce
git bisect bad 54a9ea73527d55ab746d5425e10f3fa748e00e70
# good: [e2bdd172e6652c2f5554d125a5048bc9f9b0dfa3] perf build: Generate
arm64's sysreg-defs.h and add to include path
git bisect good e2bdd172e6652c2f5554d125a5048bc9f9b0dfa3
# bad: [0359c946b13153bd57fac65f4f3600ba5673e3de] tools headers arm64:
Update sysreg.h with kernel sources
git bisect bad 0359c946b13153bd57fac65f4f3600ba5673e3de
# bad: [9697d84cc3b6d9bff4b1fbffc10a4bb1398af9ba] KVM: selftests:
Generate sysreg-defs.h and add to include path
git bisect bad 9697d84cc3b6d9bff4b1fbffc10a4bb1398af9ba
# first bad commit: [9697d84cc3b6d9bff4b1fbffc10a4bb1398af9ba] KVM:
selftests: Generate sysreg-defs.h and add to include path

Thanks,
Aishwarya
Oliver Upton Oct. 25, 2023, 7:07 p.m. UTC | #4
On Wed, Oct 25, 2023 at 10:02:36AM +0100, Aishwarya TCV wrote:
> On 11/10/2023 20:57, Oliver Upton wrote:
> > Start generating sysreg-defs.h for arm64 builds in anticipation of
> > updating sysreg.h to a version that depends on it.
> > 
> > Reviewed-by: Mark Brown <broonie@kernel.org>
> > Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> > ---
> >  tools/testing/selftests/kvm/Makefile | 23 ++++++++++++++++++++---
> >  1 file changed, 20 insertions(+), 3 deletions(-)
> > 
> 
> Hi Oliver,
> 
> 
> Currently when building kselftest against next-master with arm64 arch
> and defconfig+kselftest-kvm  “make[4]: *** [Makefile:26: prepare] Error
> 2” is observed.

Looks like we're descending into tools/arch/arm64/tools/ w/
$(srctree) == ".", which I believe is coming from the top makefile. The
following diff fixes it for me, care to give it a go?

diff --git a/tools/arch/arm64/tools/Makefile b/tools/arch/arm64/tools/Makefile
index f867e6036c62..7f64b8bb5107 100644
--- a/tools/arch/arm64/tools/Makefile
+++ b/tools/arch/arm64/tools/Makefile
@@ -1,13 +1,13 @@
 # SPDX-License-Identifier: GPL-2.0
 
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+ifeq ($(top_srcdir),)
+top_srcdir := $(patsubst %/,%,$(dir $(CURDIR)))
+top_srcdir := $(patsubst %/,%,$(dir $(top_srcdir)))
+top_srcdir := $(patsubst %/,%,$(dir $(top_srcdir)))
+top_srcdir := $(patsubst %/,%,$(dir $(top_srcdir)))
 endif
 
-include $(srctree)/tools/scripts/Makefile.include
+include $(top_srcdir)/tools/scripts/Makefile.include
 
 AWK	?= awk
 MKDIR	?= mkdir
@@ -19,10 +19,10 @@ else
 Q = @
 endif
 
-arm64_tools_dir = $(srctree)/arch/arm64/tools
+arm64_tools_dir = $(top_srcdir)/arch/arm64/tools
 arm64_sysreg_tbl = $(arm64_tools_dir)/sysreg
 arm64_gen_sysreg = $(arm64_tools_dir)/gen-sysreg.awk
-arm64_generated_dir = $(srctree)/tools/arch/arm64/include/generated
+arm64_generated_dir = $(top_srcdir)/tools/arch/arm64/include/generated
 arm64_sysreg_defs = $(arm64_generated_dir)/asm/sysreg-defs.h
 
 all: $(arm64_sysreg_defs)
Aishwarya TCV Oct. 26, 2023, 1:06 a.m. UTC | #5
On 25/10/2023 20:07, Oliver Upton wrote:
> On Wed, Oct 25, 2023 at 10:02:36AM +0100, Aishwarya TCV wrote:
>> On 11/10/2023 20:57, Oliver Upton wrote:
>>> Start generating sysreg-defs.h for arm64 builds in anticipation of
>>> updating sysreg.h to a version that depends on it.
>>>
>>> Reviewed-by: Mark Brown <broonie@kernel.org>
>>> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
>>> ---
>>>  tools/testing/selftests/kvm/Makefile | 23 ++++++++++++++++++++---
>>>  1 file changed, 20 insertions(+), 3 deletions(-)
>>>
>>
>> Hi Oliver,
>>
>>
>> Currently when building kselftest against next-master with arm64 arch
>> and defconfig+kselftest-kvm  “make[4]: *** [Makefile:26: prepare] Error
>> 2” is observed.
> 
> Looks like we're descending into tools/arch/arm64/tools/ w/
> $(srctree) == ".", which I believe is coming from the top makefile. The
> following diff fixes it for me, care to give it a go?
> 
> diff --git a/tools/arch/arm64/tools/Makefile b/tools/arch/arm64/tools/Makefile
> index f867e6036c62..7f64b8bb5107 100644
> --- a/tools/arch/arm64/tools/Makefile
> +++ b/tools/arch/arm64/tools/Makefile

Confirming that the patch worked fine in the testing. Attached the log
below:

make[4]: Entering directory '/linux/tools/testing/selftests/kvm'
Makefile:270: warning: overriding recipe for target
'/linux/build-arm64/kselftest/kvm/get-reg-list'
Makefile:265: warning: ignoring old recipe for target
'/linux/build-arm64/kselftest/kvm/get-reg-list'
make -C ../../../../tools/arch/arm64/tools/
make[5]: Entering directory '/linux/tools/arch/arm64/tools'
  GEN     /linux/tools/arch/arm64/include/generated/asm/sysreg-defs.h
make[5]: Leaving directory '/linux/tools/arch/arm64/tools'

Thanks,
Aishwarya
Oliver Upton Oct. 27, 2023, 12:59 a.m. UTC | #6
Hi Nina,

Apologies, I missed this email in my inbox and happened to see it on
lore.

On Mon, Oct 23, 2023 at 03:53:59PM +0200, Nina Schoetterl-Glausch wrote:

[...]

> > +ifeq ($(ARCH),arm64)
> > +arm64_tools_dir := $(top_srcdir)/tools/arch/arm64/tools/
> > +GEN_HDRS := $(top_srcdir)/tools/arch/arm64/include/generated/
> > +CFLAGS += -I$(GEN_HDRS)
> > +
> > +prepare:
> > +	$(MAKE) -C $(arm64_tools_dir)
> > +else
> > +prepare:
> 
> This is a force target, all targets depending on this one will always have their recipe run,
> so we'll pretty much rebuild everything.
> Is this intentional?

No, I just wasn't thinking about what I was doing :)

I've sent out a fix for this, plan to have it resolved before sending
out the PR for 6.7.

[*] https://lore.kernel.org/kvmarm/20231027005439.3142015-3-oliver.upton@linux.dev/
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index a3bb36fb3cfc..07b3f4dc1a77 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -17,6 +17,17 @@  else
 	ARCH_DIR := $(ARCH)
 endif
 
+ifeq ($(ARCH),arm64)
+arm64_tools_dir := $(top_srcdir)/tools/arch/arm64/tools/
+GEN_HDRS := $(top_srcdir)/tools/arch/arm64/include/generated/
+CFLAGS += -I$(GEN_HDRS)
+
+prepare:
+	$(MAKE) -C $(arm64_tools_dir)
+else
+prepare:
+endif
+
 LIBKVM += lib/assert.c
 LIBKVM += lib/elf.c
 LIBKVM += lib/guest_modes.c
@@ -256,13 +267,18 @@  $(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c
 $(SPLIT_TESTS_TARGETS): %: %.o $(SPLIT_TESTS_OBJS)
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
 
-EXTRA_CLEAN += $(LIBKVM_OBJS) $(TEST_DEP_FILES) $(TEST_GEN_OBJ) $(SPLIT_TESTS_OBJS) cscope.*
+EXTRA_CLEAN += $(GEN_HDRS) \
+	       $(LIBKVM_OBJS) \
+	       $(SPLIT_TESTS_OBJS) \
+	       $(TEST_DEP_FILES) \
+	       $(TEST_GEN_OBJ) \
+	       cscope.*
 
 x := $(shell mkdir -p $(sort $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
-$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c
+$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c prepare
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
 
-$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S
+$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S prepare
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
 
 # Compile the string overrides as freestanding to prevent the compiler from
@@ -274,6 +290,7 @@  $(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
 x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
 $(TEST_GEN_PROGS): $(LIBKVM_OBJS)
 $(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
+$(TEST_GEN_OBJ): prepare
 
 cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
 cscope: