mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Oliver Upton" <oupton@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	"James Houghton" <jthoughton@google.com>,
	"Will Deacon" <will@kernel.org>, "Fuad Tabba" <tabba@google.com>,
	kvm@vger.kernel.org, kvmarm@lists.linux.dev,
	cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] KVM: selftests: Fix arm64 sysreg header dependencies
Date: Thu, 24 Sep 2026 09:32:58 -0700	[thread overview]
Message-ID: <arVQutV75u2gGVr4@google.com> (raw)
In-Reply-To: <20260922071945.693714-2-fuad.tabba@linux.dev>

On Tue, Sep 22, 2026, Fuad Tabba wrote:
> The rule generating the arm64 sysreg header targets the generated
> directory, and its only prerequisite is tools/arch/arm64/tools/*,
> which expands to the inner Makefile. An existing directory looks up
> to date, so an incremental build never regenerates sysreg-defs.h for
> a change to the sysreg table. A selftest referencing a register added
> to the table since then fails with undeclared SYS_* identifiers. Clean
> builds are unaffected.
> 
> Always recurse into tools/arch/arm64/tools, whose Makefile already
> tracks the generator's inputs, and target the header rather than its
> directory. The recursion leaves the header untouched when nothing
> changed, so the dependents rebuild only when the header does.
> 
> Fixes: 70c7b704ca725 ("KVM: selftests: Avoid using forced target for generating arm64 headers")
> Link: https://lore.kernel.org/r/arGRhHgP_izSwW4T@kernel.org
> Assisted-by: LLM
> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
> ---
>  tools/testing/selftests/kvm/Makefile.kvm | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
> index 96bab7002d39e..81dca3dbc16b4 100644
> --- a/tools/testing/selftests/kvm/Makefile.kvm
> +++ b/tools/testing/selftests/kvm/Makefile.kvm
> @@ -303,10 +303,16 @@ 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)/*)
> +# The inner Makefile tracks the generator's inputs and leaves the header
> +# untouched when nothing changed, so dependents rebuild only when it does.
> +$(GEN_SYSREG_DEFS): FORCE
>  	$(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir)
> +
> +FORCE:
> +.PHONY: FORCE
>  endif

Definitely doesn't have to be now, but at some point should we split out some of
this arch-specific sub-Makefiles?  It's nice not having to hunt around to figure
out which tests are supported by which arch, but the amount of arch specific goo
we're accruing is getting unwieldy.

>  no-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \
> @@ -359,10 +365,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 +378,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:
> -- 
> 2.39.5
> 

  reply	other threads:[~2026-09-24 16:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  7:19 [PATCH v2 0/2] KVM: selftests: Fix incremental build dependencies Fuad Tabba
2026-09-22  7:19 ` [PATCH v2 1/2] KVM: selftests: Fix arm64 sysreg header dependencies Fuad Tabba
2026-09-24 16:32   ` Sean Christopherson [this message]
2026-09-24 18:18     ` Fuad Tabba
2026-09-22  7:19 ` [PATCH v2 2/2] selftests/cgroup: Make the object directory an order-only prerequisite Fuad Tabba
2026-09-22 13:44   ` Michal Koutný

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=arVQutV75u2gGVr4@google.com \
    --to=seanjc@google.com \
    --cc=cgroups@vger.kernel.org \
    --cc=fuad.tabba@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=jthoughton@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=oupton@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tabba@google.com \
    --cc=tj@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®