public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path
@ 2023-12-12  7:04 Oliver Upton
  2023-12-12 11:36 ` Cornelia Huck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Oliver Upton @ 2023-12-12  7:04 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, Marc Zyngier, James Morse, Suzuki K Poulose, Zenghui Yu,
	broonie, Oliver Upton

Building the KVM selftests from the main selftests Makefile (as opposed
to the kvm subdirectory) doesn't work as OUTPUT is set, forcing the
generated header to spill into the selftests directory. Additionally,
relative paths do not work when building outside of the srctree, as the
canonical selftests path is replaced with 'kselftest' in the output.

Work around both of these issues by explicitly overriding OUTPUT on the
submake cmdline. Move the whole fragment below the point lib.mk gets
included such that $(abs_objdir) is available.

Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
 tools/testing/selftests/kvm/Makefile | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 52c59bad7213..5f4f6be7a866 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -17,16 +17,6 @@ else
 	ARCH_DIR := $(ARCH)
 endif
 
-ifeq ($(ARCH),arm64)
-tools_dir := $(top_srcdir)/tools
-arm64_tools_dir := $(tools_dir)/arch/arm64/tools/
-GEN_HDRS := $(top_srcdir)/tools/arch/arm64/include/generated/
-CFLAGS += -I$(GEN_HDRS)
-
-$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*)
-	$(MAKE) -C $(arm64_tools_dir) O=$(tools_dir)
-endif
-
 LIBKVM += lib/assert.c
 LIBKVM += lib/elf.c
 LIBKVM += lib/guest_modes.c
@@ -234,6 +224,22 @@ CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
 ifeq ($(ARCH),s390)
 	CFLAGS += -march=z10
 endif
+ifeq ($(ARCH),arm64)
+tools_dir := $(top_srcdir)/tools
+arm64_tools_dir := $(tools_dir)/arch/arm64/tools/
+
+ifneq ($(abs_objdir),)
+arm64_hdr_outdir := $(abs_objdir)/tools/
+else
+arm64_hdr_outdir := $(tools_dir)/
+endif
+
+GEN_HDRS := $(arm64_hdr_outdir)arch/arm64/include/generated/
+CFLAGS += -I$(GEN_HDRS)
+
+$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*)
+	$(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir)
+endif
 
 no-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \
         $(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)

base-commit: 33cc938e65a98f1d29d0a18403dbbee050dcad9a
-- 
2.43.0.472.g3155946c3a-goog


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

* Re: [PATCH] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path
  2023-12-12  7:04 [PATCH] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path Oliver Upton
@ 2023-12-12 11:36 ` Cornelia Huck
  2023-12-12 15:28 ` Mark Brown
  2023-12-12 17:05 ` Oliver Upton
  2 siblings, 0 replies; 4+ messages in thread
From: Cornelia Huck @ 2023-12-12 11:36 UTC (permalink / raw)
  To: Oliver Upton, kvmarm
  Cc: kvm, Marc Zyngier, James Morse, Suzuki K Poulose, Zenghui Yu,
	broonie, Oliver Upton

On Tue, Dec 12 2023, Oliver Upton <oliver.upton@linux.dev> wrote:

> Building the KVM selftests from the main selftests Makefile (as opposed
> to the kvm subdirectory) doesn't work as OUTPUT is set, forcing the
> generated header to spill into the selftests directory. Additionally,
> relative paths do not work when building outside of the srctree, as the
> canonical selftests path is replaced with 'kselftest' in the output.
>
> Work around both of these issues by explicitly overriding OUTPUT on the
> submake cmdline. Move the whole fragment below the point lib.mk gets
> included such that $(abs_objdir) is available.
>
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> ---
>  tools/testing/selftests/kvm/Makefile | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


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

* Re: [PATCH] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path
  2023-12-12  7:04 [PATCH] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path Oliver Upton
  2023-12-12 11:36 ` Cornelia Huck
@ 2023-12-12 15:28 ` Mark Brown
  2023-12-12 17:05 ` Oliver Upton
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-12-12 15:28 UTC (permalink / raw)
  To: Oliver Upton
  Cc: kvmarm, kvm, Marc Zyngier, James Morse, Suzuki K Poulose,
	Zenghui Yu

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

On Tue, Dec 12, 2023 at 07:04:32AM +0000, Oliver Upton wrote:
> Building the KVM selftests from the main selftests Makefile (as opposed
> to the kvm subdirectory) doesn't work as OUTPUT is set, forcing the
> generated header to spill into the selftests directory. Additionally,
> relative paths do not work when building outside of the srctree, as the
> canonical selftests path is replaced with 'kselftest' in the output.

Tested-by: Mark Brown <broonie@kernel.org>

Hopefully we can get this to Linus' tree quickly!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path
  2023-12-12  7:04 [PATCH] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path Oliver Upton
  2023-12-12 11:36 ` Cornelia Huck
  2023-12-12 15:28 ` Mark Brown
@ 2023-12-12 17:05 ` Oliver Upton
  2 siblings, 0 replies; 4+ messages in thread
From: Oliver Upton @ 2023-12-12 17:05 UTC (permalink / raw)
  To: Oliver Upton, kvmarm
  Cc: broonie, Marc Zyngier, James Morse, Zenghui Yu, Suzuki K Poulose,
	kvm

On Tue, 12 Dec 2023 07:04:32 +0000, Oliver Upton wrote:
> Building the KVM selftests from the main selftests Makefile (as opposed
> to the kvm subdirectory) doesn't work as OUTPUT is set, forcing the
> generated header to spill into the selftests directory. Additionally,
> relative paths do not work when building outside of the srctree, as the
> canonical selftests path is replaced with 'kselftest' in the output.
> 
> Work around both of these issues by explicitly overriding OUTPUT on the
> submake cmdline. Move the whole fragment below the point lib.mk gets
> included such that $(abs_objdir) is available.
> 
> [...]

Thanks folks for the quick review / testing. I'll get this out ASAP, the
VGIC RD changes from Marc need to go in for 6.7 anyway.

[1/1] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path
      https://git.kernel.org/kvmarm/kvmarm/c/0c12e6c8267f

--
Best,
Oliver

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

end of thread, other threads:[~2023-12-12 17:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-12  7:04 [PATCH] KVM: selftests: Ensure sysreg-defs.h is generated at the expected path Oliver Upton
2023-12-12 11:36 ` Cornelia Huck
2023-12-12 15:28 ` Mark Brown
2023-12-12 17:05 ` Oliver Upton

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