mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: Fix arm64 sysreg header dependencies
@ 2026-09-02 13:41 Fuad Tabba
  2026-09-21  7:10 ` Fuad Tabba
  2026-09-21 20:20 ` Oliver Upton
  0 siblings, 2 replies; 4+ messages in thread
From: Fuad Tabba @ 2026-09-02 13:41 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Shuah Khan
  Cc: Oliver Upton, Will Deacon, Fuad Tabba, kvmarm, kvm,
	linux-kselftest, linux-kernel

The rule generating the arm64 sysreg header targets the generated
directory, and its only prerequisites are tools/arch/arm64/tools/*,
which is the inner Makefile. An existing directory looks up to date,
so an incremental build never regenerates sysreg-defs.h. A selftest
referencing a register added to the table since then fails with
undeclared SYS_* identifiers. Clean builds are unaffected.

Depend on the generator's inputs, and target the header rather than its
directory, whose mtime does not change when the header is rewritten.

Fixes: 70c7b704ca725 ("KVM: selftests: Avoid using forced target for generating arm64 headers")
Assisted-by: LLM
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
Unlike the two existing sysreg-defs.h rules, this one's recipe is a recursive
make, so its prerequisites are not the recipe's arguments. They only decide
whether to recurse, which is a question tools/arch/arm64/tools/Makefile already
answers. An alternative is therefore to drop the two explicit inputs in favour
of:

	$(GEN_SYSREG_DEFS): FORCE

leaving that Makefile as the only place naming the generator's inputs. Both
forms regenerate the header and rebuild the dependents in the same invocation,
and neither rebuilds anything when nothing changed. I kept the explicit
prerequisites so that the recursion stays conditional, but I am happy to respin
with FORCE if you would rather.

 tools/testing/selftests/kvm/Makefile.kvm | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
index 96bab7002d39e..4a1f1bfcff0e3 100644
--- a/tools/testing/selftests/kvm/Makefile.kvm
+++ b/tools/testing/selftests/kvm/Makefile.kvm
@@ -303,9 +303,14 @@ arm64_hdr_outdir := $(tools_dir)/
 endif
 
 GEN_HDRS := $(arm64_hdr_outdir)arch/arm64/include/generated/
+GEN_SYSREG_DEFS := $(GEN_HDRS)asm/sysreg-defs.h
 CFLAGS += -I$(GEN_HDRS)
 
-$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*)
+# A directory's mtime does not track the header inside it.
+# Sysreg inputs duplicated from tools/arch/arm64/tools/Makefile, keep in sync.
+$(GEN_SYSREG_DEFS): $(top_srcdir)/arch/arm64/tools/sysreg \
+		    $(top_srcdir)/arch/arm64/tools/gen-sysreg.awk \
+		    $(wildcard $(arm64_tools_dir)/*)
 	$(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir)
 endif
 
@@ -359,10 +364,10 @@ EXTRA_CLEAN += $(GEN_HDRS) \
 	       $(TEST_GEN_OBJ) \
 	       cscope.*
 
-$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_HDRS)
+$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_SYSREG_DEFS)
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
 
-$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S $(GEN_HDRS)
+$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S $(GEN_SYSREG_DEFS)
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
 
 # Compile the string overrides as freestanding to prevent the compiler from
@@ -372,10 +377,10 @@ $(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@
 
 $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
-$(SPLIT_TEST_GEN_OBJ): $(GEN_HDRS)
+$(SPLIT_TEST_GEN_OBJ): $(GEN_SYSREG_DEFS)
 $(TEST_GEN_PROGS): $(LIBKVM_OBJS)
 $(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
-$(TEST_GEN_OBJ): $(GEN_HDRS)
+$(TEST_GEN_OBJ): $(GEN_SYSREG_DEFS)
 
 cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
 cscope:

base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: selftests: Fix arm64 sysreg header dependencies
  2026-09-02 13:41 [PATCH] KVM: selftests: Fix arm64 sysreg header dependencies Fuad Tabba
@ 2026-09-21  7:10 ` Fuad Tabba
  2026-09-21 20:20 ` Oliver Upton
  1 sibling, 0 replies; 4+ messages in thread
From: Fuad Tabba @ 2026-09-21  7:10 UTC (permalink / raw)
  To: Oliver Upton
  Cc: Paolo Bonzini, Will Deacon, kvmarm, kvm, linux-kselftest,
	linux-kernel, Sean Christopherson, Shuah Khan

Hi Oliver,

On Wed, 2 Sep 2026 14:41:18 +0100, Fuad Tabba <fuad.tabba@linux.dev> wrote:
> The rule generating the arm64 sysreg header targets the generated
> directory, and its only prerequisites are tools/arch/arm64/tools/*,
> which is the inner Makefile. An existing directory looks up to date,
> so an incremental build never regenerates sysreg-defs.h. A selftest
> referencing a register added to the table since then fails with
> undeclared SYS_* identifiers. Clean builds are unaffected.

[...]

Gentle ping on this one. It's arm64-only (the Makefile.kvm rule that
generates sysreg-defs.h), so I think it'd go through kvmarm rather
than Paolo's tree. Could you take a look when you get a chance?

Cheers,
/fuad

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: selftests: Fix arm64 sysreg header dependencies
  2026-09-02 13:41 [PATCH] KVM: selftests: Fix arm64 sysreg header dependencies Fuad Tabba
  2026-09-21  7:10 ` Fuad Tabba
@ 2026-09-21 20:20 ` Oliver Upton
  2026-09-22  7:09   ` Fuad Tabba
  1 sibling, 1 reply; 4+ messages in thread
From: Oliver Upton @ 2026-09-21 20:20 UTC (permalink / raw)
  To: Fuad Tabba
  Cc: Paolo Bonzini, Sean Christopherson, Shuah Khan, Will Deacon,
	Fuad Tabba, kvmarm, kvm, linux-kselftest, linux-kernel

Hey Fuad,

Thanks for the fix here.

On Wed, Sep 02, 2026 at 02:41:18PM +0100, Fuad Tabba wrote:
> ---
> Unlike the two existing sysreg-defs.h rules, this one's recipe is a recursive
> make, so its prerequisites are not the recipe's arguments. They only decide
> whether to recurse, which is a question tools/arch/arm64/tools/Makefile already
> answers. An alternative is therefore to drop the two explicit inputs in favour
> of:
> 
> 	$(GEN_SYSREG_DEFS): FORCE
> 
> leaving that Makefile as the only place naming the generator's inputs. Both
> forms regenerate the header and rebuild the dependents in the same invocation,
> and neither rebuilds anything when nothing changed. I kept the explicit
> prerequisites so that the recursion stays conditional, but I am happy to respin
> with FORCE if you would rather.

This might be the better approach at this point. In the unlikely event
that new dependencies get added to the kernel side of this, I'll give it
approximately a 0% chance that the author will update this rule :)

Thanks,
Oliver

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: selftests: Fix arm64 sysreg header dependencies
  2026-09-21 20:20 ` Oliver Upton
@ 2026-09-22  7:09   ` Fuad Tabba
  0 siblings, 0 replies; 4+ messages in thread
From: Fuad Tabba @ 2026-09-22  7:09 UTC (permalink / raw)
  To: Oliver Upton
  Cc: Paolo Bonzini, Sean Christopherson, Shuah Khan, Will Deacon,
	kvmarm, kvm, linux-kselftest, linux-kernel

On Mon, 21 Sept 2026 at 21:20, Oliver Upton <oupton@kernel.org> wrote:
>
> Hey Fuad,
>
> Thanks for the fix here.
>
> On Wed, Sep 02, 2026 at 02:41:18PM +0100, Fuad Tabba wrote:
> > ---
> > Unlike the two existing sysreg-defs.h rules, this one's recipe is a recursive
> > make, so its prerequisites are not the recipe's arguments. They only decide
> > whether to recurse, which is a question tools/arch/arm64/tools/Makefile already
> > answers. An alternative is therefore to drop the two explicit inputs in favour
> > of:
> >
> >       $(GEN_SYSREG_DEFS): FORCE
> >
> > leaving that Makefile as the only place naming the generator's inputs. Both
> > forms regenerate the header and rebuild the dependents in the same invocation,
> > and neither rebuilds anything when nothing changed. I kept the explicit
> > prerequisites so that the recursion stays conditional, but I am happy to respin
> > with FORCE if you would rather.
>
> This might be the better approach at this point. In the unlikely event
> that new dependencies get added to the kernel side of this, I'll give it
> approximately a 0% chance that the author will update this rule :)

I'm on it!
/fuad

>
> Thanks,
> Oliver

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-22  7:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-02 13:41 [PATCH] KVM: selftests: Fix arm64 sysreg header dependencies Fuad Tabba
2026-09-21  7:10 ` Fuad Tabba
2026-09-21 20:20 ` Oliver Upton
2026-09-22  7:09   ` Fuad Tabba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®