Skip to contentSkip to conversation

accel: Allow targets to use Kconfig

PATCH Superseded Philippe Mathieu-Daudé 2 participants 16 messages May 22, 2020 – Jun 5, 2020 Kbuild

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v4 cover accel: Allow targets to use Kconfig

Missing review:
- patch #4 'rules.mak: Add startwith rule'
- patch #5 'rules.mak: Add base-arch rule'.

This series include generic patches I took of the KVM/ARM specific series which will follow.

- List orphan accelerators in MAINTAINERS
- Add accel/Kconfig
- Allow targets to use their how Kconfig

Since v3:
- Fixed base-arch() rule (rth)
- Dropped 'semihosting: Make the feature depend of TCG'

Since v2:
- Addressed Thomas review comments
- Fixed problem when including TARGET instead of BASE_TARGET

Since v1:
https://www.mail-archive.com/[email protected]/msg689024.html
- Drop HVF MAINTAINERS patch (merged elsewhere)
- Kconfig-select SEMIHOSTING (bonzini)
- Drop user-mode selection patches
- consider m68k/nios2/xtensa/riscv (pm215)
- reword Kconfig SEMIHOSTING description (pm215)
- reset some of rth R-b tags

Previous RFC for semihosting posted earlier:
https://www.mail-archive.com/[email protected]/msg631218.html

$ git backport-diff -u v3 -r v4
Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/11:[----] [--] 'MAINTAINERS: Fix KVM path expansion glob' 002/11:[----] [--] 'MAINTAINERS: Add an 'overall' entry for accelerators' 003/11:[----] [--] 'MAINTAINERS: Add an entry for the HAX accelerator' 004/11:[down] 'rules.mak: Add startwith() rule'
005/11:[0025] [FC] 'rules.mak: Add base-arch() rule'
006/11:[----] [--] 'Makefile: Remove dangerous EOL trailing backslash' 007/11:[----] [--] 'Makefile: Write MINIKCONF variables as one entry per line' 008/11:[----] [--] 'accel/Kconfig: Extract accel selectors into their own config' 009/11:[----] [--] 'accel/Kconfig: Add the TCG selector' 010/11:[----] [--] 'Makefile: Allow target-specific optional Kconfig' 011/11:[----] [--] 'accel/tcg: Add stub for probe_access()'

Supersedes: <[email protected]>

Philippe Mathieu-Daudé (11):
MAINTAINERS: Fix KVM path expansion glob
MAINTAINERS: Add an 'overall' entry for accelerators
MAINTAINERS: Add an entry for the HAX accelerator rules.mak: Add startwith() rule
rules.mak: Add base-arch() rule
Makefile: Remove dangerous EOL trailing backslash
Makefile: Write MINIKCONF variables as one entry per line accel/Kconfig: Extract accel selectors into their own config accel/Kconfig: Add the TCG selector
Makefile: Allow target-specific optional Kconfig accel/tcg: Add stub for probe_access()

 Makefile               | 15 +++++++++++----
 rules.mak              | 34 ++++++++++++++++++++++++++++++++++
 accel/stubs/tcg-stub.c |  7 +++++++
 Kconfig.host           |  7 -------
 MAINTAINERS            | 19 ++++++++++++++++++-
 accel/Kconfig          |  9 +++++++++
 6 files changed, 79 insertions(+), 12 deletions(-)
 create mode 100644 accel/Kconfig
Signature · 1 line
2.21.3
#1 lore raw

PATCH v4 1/11 MAINTAINERS: Fix KVM path expansion glob

The KVM files has been moved from target-ARCH to the target/ARCH/ folder in commit fcf5ef2a. Fix the pathname expansion.

Fixes fcf5ef2a ("Move target-* CPU file into a target/ folder")
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
index 12edb66dac..00c1c1ed8b 100644
@@ -361,7 +361,7 @@ Overall KVM CPUs
 M: Paolo Bonzini <[email protected]>
 L: [email protected]
 S: Supported
-F: */kvm.*
+F: */*/kvm*
 F: accel/kvm/
 F: accel/stubs/kvm-stub.c
 F: include/hw/kvm/
Signature · 1 line
2.21.3
#2 lore raw

PATCH v4 2/11 MAINTAINERS: Add an 'overall' entry for accelerators

In reply to Philippe Mathieu-Daudé

---
Cc: Paolo Bonzini <[email protected]>

v2: Cover accel/accel.c & accel/Makefile.objs (thuth)

---
 MAINTAINERS | 11 +++++++++++
 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
index 00c1c1ed8b..f7ee0c77f1 100644
@@ -415,6 +415,17 @@ S: Supported
 F: target/i386/kvm.c
 F: scripts/kvm/vmxcap
 
+Guest CPU Cores (other accelerators)
+------------------------------------
+Overall
+M: Richard Henderson <[email protected]>
+R: Paolo Bonzini <[email protected]>
+S: Maintained
+F: include/sysemu/accel.h
+F: accel/accel.c
+F: accel/Makefile.objs
+F: accel/stubs/Makefile.objs
+
 X86 HVF CPUs
 M: Roman Bolshakov <[email protected]>
 S: Maintained
Signature · 1 line
2.21.3
#3 lore raw

PATCH v4 3/11 MAINTAINERS: Add an entry for the HAX accelerator

In reply to Philippe Mathieu-Daudé

---
Cc: Sergio Andres Gomez Del Real <[email protected]>
Cc: Vincent Palatin <[email protected]>
Cc: Yu Ning <[email protected]>
Cc: Tao Wu <[email protected]>
Cc: [email protected]
Cc: Colin Xu <[email protected]>
Cc: Hang Yuan <[email protected]>
Cc: David Chou <[email protected]>
Cc: Wenchao Wang <[email protected]>

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index f7ee0c77f1..0377978201 100644
@@ -426,6 +426,12 @@ F: accel/accel.c
 F: accel/Makefile.objs
 F: accel/stubs/Makefile.objs
 
+HAX Accelerator
+S: Orphan
+F: accel/stubs/hax-stub.c
+F: target/i386/hax-all.c
+F: include/sysemu/hax.h
+
 X86 HVF CPUs
 M: Roman Bolshakov <[email protected]>
 S: Maintained
Signature · 1 line
2.21.3
#4 lore raw

Re: [PATCH v4 03/11] MAINTAINERS: Add an entry for the HAX accelerator

Quoted 10 lines · Philippe Mathieu-Daudé

---
Cc: Sergio Andres Gomez Del Real <[email protected]>
Cc: Vincent Palatin <[email protected]>
Cc: Yu Ning <[email protected]>
Cc: Tao Wu <[email protected]>
Cc: [email protected]
Cc: Colin Xu <[email protected]>
Cc: Hang Yuan <[email protected]>
Cc: David Chou <[email protected]>

FYI Hang Yuan and David Chou emails are bouncing.

Quoted 10 lines
Cc Wenchao Wang <[email protected]>
---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +0 -0
index f7ee0c77f1..0377978201 100644

MAINTAINERS F: accel/accel.c · line 430

Quoted 5 lines
MAINTAINERS +2 -0
@@ -426,6 +426,12 @@ F: accel/accel.c
 F: accel/Makefile.objs
 F: accel/stubs/Makefile.objs
 
+HAX Accelerator
+S: Orphan

This patch has been posted 4 times, first time more than 2 months ago:
https://www.mail-archive.com/[email protected]/msg689009.html

Quoted 8 lines
MAINTAINERS +4 -0
+F: accel/stubs/hax-stub.c
+F: target/i386/hax-all.c
+F: include/sysemu/hax.h
+
 X86 HVF CPUs
 M: Roman Bolshakov <[email protected]>
 S: Maintained
#5 lore raw

PATCH v4 4/11 rules.mak: Add startwith() rule

In reply to Philippe Mathieu-Daudé

Add a rule to test if a string starts with a substring.

---
 rules.mak | 7 +++++++
 1 file changed, 7 insertions(+)
rules.mak +7 -0
index 694865b63e..e39bee93d5 100644
@@ -191,6 +191,13 @@ ne = $(if $(subst $2,,$1)$(subst $1,,$2),y,n)
 isempty = $(if $1,n,y)
 notempty = $(if $1,y,n)
 
+# startwith
+# Usage: $(call startwith, startstr, fullstr)
+#
+# This macro returns a string (TRUE) when @fullstr starts with
+# @startstr, else returns the empty string (FALSE)
+startwith = $(findstring :$(strip $1),:$(strip $2))
+
 # Generate files with tracetool
 TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py
 
Signature · 1 line
2.21.3
#6 lore raw

PATCH v4 5/11 rules.mak: Add base-arch() rule

In reply to Philippe Mathieu-Daudé

Add a rule to return the base architecture for a QEMU target.

The current list of TARGET_BASE_ARCH is:

  $ git grep  TARGET_BASE_ARCH configure
  configure:7785:TARGET_BASE_ARCH=""
  configure:7795:    TARGET_BASE_ARCH=i386
  configure:7813:    TARGET_BASE_ARCH=arm
  configure:7846:    TARGET_BASE_ARCH=mips
  configure:7854:    TARGET_BASE_ARCH=mips
  configure:7864:    TARGET_BASE_ARCH=openrisc
  configure:7871:    TARGET_BASE_ARCH=ppc
  configure:7879:    TARGET_BASE_ARCH=ppc
  configure:7887:    TARGET_BASE_ARCH=ppc
  configure:7894:    TARGET_BASE_ARCH=riscv
  configure:7900:    TARGET_BASE_ARCH=riscv
  configure:7920:    TARGET_BASE_ARCH=sparc
  configure:7925:    TARGET_BASE_ARCH=sparc

The rule can be tested calling 'print-base-arch-$TARGET':

  $ make \
      print-base-arch-openrisc \
      print-base-arch-aarch64 \
      print-base-arch-x86_64 \
      print-base-arch-mips64el \
      print-base-arch-ppc64
  openrisc=openrisc
  aarch64=arm
  x86_64=i386
  mips64el=mips
  ppc64=ppc

---
v4:
- use startwith()
- fix openrisc (rth)

---
 rules.mak | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
rules.mak +27 -0
index e39bee93d5..2ce527e885 100644
@@ -445,3 +445,30 @@ atomic = $(eval $1: $(call sentinel,$1) ; @:) \
 
 print-%:
 	@echo '$*=$($*)'
+
+# base-arch
+# Usage: $(call base-arch, target)
+#
+# @target: the target architecture.
+#
+# This macro will return the base architecture for a target.
+#
+# As example, $(call base-arch, aarch64) returns 'arm'.
+base-arch = $(strip \
+		$(if $(call startwith,mips,$1),mips,\
+		  $(if $(call startwith,ppc,$1),ppc,\
+		    $(if $(call startwith,sparc,$1),sparc,\
+		      $(if $(call startwith,risc,$1),risc,\
+		        $(if $(call startwith,aarch64,$1),arm,\
+		          $(if $(call startwith,x86_64,$1),i386,\
+		            $1\
+		           )\
+		         )\
+		       )\
+		     )\
+		   )\
+		 )\
+		)
+
+print-base-arch-%:
+	@echo '$*=$(call base-arch, $*)'
Signature · 1 line
2.21.3
#7 lore raw

Re: [PATCH v4 05/11] rules.mak: Add base-arch() rule

rules.mak atomic = $(eval $1: $(call sentinel,$1) ; @:) \ · line 461

Quoted 1 line · Philippe Mathieu-Daudé
rules.mak +1 -0
+		      $(if $(call startwith,risc,$1),risc,\

Should be "riscv" not "risc". Especially the substitution.

rules.mak atomic = $(eval $1: $(call sentinel,$1) ; @:) \ · line 463

Quoted 2 lines
rules.mak +2 -0
+		        $(if $(call startwith,aarch64,$1),arm,\
+		          $(if $(call startwith,x86_64,$1),i386,\

We don't have an exact equality function?

r~

#8 lore raw

Re: [PATCH v4 05/11] rules.mak: Add base-arch() rule

Quoted 4 lines · Richard Henderson

rules.mak atomic = $(eval $1: $(call sentinel,$1) ; @:) \ · line 461

Quoted 1 line · Philippe Mathieu-Daudé
rules.mak +1 -0
+		      $(if $(call startwith,risc,$1),risc,\

Should be "riscv" not "risc". Especially the substitution.

Indeed.

Quoted 5 lines

rules.mak atomic = $(eval $1: $(call sentinel,$1) ; @:) \ · line 463

Quoted 3 lines
rules.mak +2 -0
+		        $(if $(call startwith,aarch64,$1),arm,\
+		          $(if $(call startwith,x86_64,$1),i386,\

We don't have an exact equality function?

There is this one which returns y/n:

  # String testing functions: inputs to these can be any string;
  # the output is always either "y" or "n". Leading and trailing whitespace
  # is ignored when comparing strings.
  # String equality
  eq = $(if $(subst $2,,$1)$(subst $1,,$2),n,y)

I'll add a simpler strequal().

#9 lore raw

Re: [PATCH v4 05/11] rules.mak: Add base-arch() rule

Quoted 13 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Richard Henderson

rules.mak atomic = $(eval $1: $(call sentinel,$1) ; @:) \ · line 461

Quoted 1 line · Philippe Mathieu-Daudé
rules.mak +1 -0
+		      $(if $(call startwith,risc,$1),risc,\

Should be "riscv" not "risc". Especially the substitution.

Indeed.

Quoted 5 lines

rules.mak atomic = $(eval $1: $(call sentinel,$1) ; @:) \ · line 463

Quoted 3 lines
rules.mak +2 -0
+		        $(if $(call startwith,aarch64,$1),arm,\
+		          $(if $(call startwith,x86_64,$1),i386,\

We don't have an exact equality function?

For aarch64_be we want to use startwith(). I'll update x86_64.

Quoted 11 lines

There is this one which returns y/n:

  # String testing functions: inputs to these can be any string;
  # the output is always either "y" or "n". Leading and trailing whitespace
  # is ignored when comparing strings.
  # String equality
  eq = $(if $(subst $2,,$1)$(subst $1,,$2),n,y)

I'll add a simpler strequal().

#10 lore raw

PATCH v4 6/11 Makefile: Remove dangerous EOL trailing backslash

In reply to Philippe Mathieu-Daudé

One might get caught trying to understand unexpected Makefile behavior. Trailing backslash can help to split very long lines, but are rather dangerous when nothing follow. Preserve other developers debugging time by removing this one.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 40e4f7677b..6c9d718b2c 100644
@@ -420,7 +420,7 @@ MINIKCONF_ARGS = \
 
 MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig
 MINIKCONF_DEPS = $(MINIKCONF_INPUTS) $(wildcard $(SRC_PATH)/hw/*/Kconfig)
-MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py \
+MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py
 
 $(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_DEPS) $(BUILD_DIR)/config-host.mak
 	$(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) > [email protected], "GEN", "[email protected]")
Signature · 1 line
2.21.3
#11 lore raw

PATCH v4 7/11 Makefile: Write MINIKCONF variables as one entry per line

In reply to Philippe Mathieu-Daudé

Having one entry per line helps reviews/refactors. As we are going to modify the MINIKCONF variables, split them now to ease further review.

---
 Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
Makefile +6 -3
index 6c9d718b2c..7666f81e8a 100644
@@ -418,12 +418,15 @@ MINIKCONF_ARGS = \
     CONFIG_LINUX=$(CONFIG_LINUX) \
     CONFIG_PVRDMA=$(CONFIG_PVRDMA)
 
-MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig
-MINIKCONF_DEPS = $(MINIKCONF_INPUTS) $(wildcard $(SRC_PATH)/hw/*/Kconfig)
+MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host \
+                   $(SRC_PATH)/hw/Kconfig
+MINIKCONF_DEPS = $(MINIKCONF_INPUTS) \
+                 $(wildcard $(SRC_PATH)/hw/*/Kconfig)
 MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py
 
 $(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_DEPS) $(BUILD_DIR)/config-host.mak
-	$(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) > [email protected], "GEN", "[email protected]")
+	$(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) \
+		> [email protected], "GEN", "[email protected]")
 	$(call quiet-command, if test -f $@; then \
 	  if cmp -s [email protected] $@; then \
 	    mv [email protected] $@; \
Signature · 1 line
2.21.3
#12 lore raw

PATCH v4 8/11 accel/Kconfig: Extract accel selectors into their own config

In reply to Philippe Mathieu-Daudé

Move the accel selectors from the global Kconfig.host to their own Kconfig file.

---
 Makefile      | 1 +
 Kconfig.host  | 7 -------
 accel/Kconfig | 6 ++++++
 3 files changed, 7 insertions(+), 7 deletions(-)
 create mode 100644 accel/Kconfig
Makefile +1 -0
index 7666f81e8a..648757f79a 100644
@@ -419,6 +419,7 @@ MINIKCONF_ARGS = \
     CONFIG_PVRDMA=$(CONFIG_PVRDMA)
 
 MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host \
+                   $(SRC_PATH)/accel/Kconfig \
                    $(SRC_PATH)/hw/Kconfig
 MINIKCONF_DEPS = $(MINIKCONF_INPUTS) \
                  $(wildcard $(SRC_PATH)/hw/*/Kconfig)
Kconfig.host +0 -7
index 55136e037d..a6d871c399 100644
@@ -2,9 +2,6 @@
 # down to Kconfig.  See also MINIKCONF_ARGS in the Makefile:
 # these two need to be kept in sync.
 
-config KVM
-    bool
-
 config LINUX
     bool
 
@@ -31,10 +28,6 @@ config VHOST_KERNEL
     bool
     select VHOST
 
-config XEN
-    bool
-    select FSDEV_9P if VIRTFS
-
 config VIRTFS
     bool
 
accel/Kconfig new file +6 -0
new file mode 100644
index 0000000000..c21802bb49
@@ -0,0 +1,6 @@
+config KVM
+    bool
+
+config XEN
+    bool
+    select FSDEV_9P if VIRTFS
Signature · 1 line
2.21.3
#13 lore raw

PATCH v4 9/11 accel/Kconfig: Add the TCG selector

In reply to Philippe Mathieu-Daudé

Expose the CONFIG_TCG selector to let minikconf.py uses it.

When building with --disable-tcg build, this helps to deselect devices that are TCG-dependent.

---
 Makefile      | 1 +
 accel/Kconfig | 3 +++
 2 files changed, 4 insertions(+)
Makefile +1 -0
index 648757f79a..f8a45e1379 100644
@@ -405,6 +405,7 @@ endif
 MINIKCONF_ARGS = \
     $(CONFIG_MINIKCONF_MODE) \
     $@ $*/config-devices.mak.d $< $(MINIKCONF_INPUTS) \
+    CONFIG_TCG=$(CONFIG_TCG) \
     CONFIG_KVM=$(CONFIG_KVM) \
     CONFIG_SPICE=$(CONFIG_SPICE) \
     CONFIG_IVSHMEM=$(CONFIG_IVSHMEM) \
accel/Kconfig +3 -0
index c21802bb49..2ad94a3839 100644
@@ -1,3 +1,6 @@
+config TCG
+    bool
+
 config KVM
     bool
 
Signature · 1 line
2.21.3
#14 lore raw

PATCH v4 10/11 Makefile: Allow target-specific optional Kconfig

In reply to Philippe Mathieu-Daudé

Allow use of target-specific Kconfig file.

---
v3: Use base-arch() to include TARGET_BASE_ARCH/Kconfig

---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index f8a45e1379..d5009cd304 100644
@@ -423,11 +423,13 @@ MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host \
                    $(SRC_PATH)/accel/Kconfig \
                    $(SRC_PATH)/hw/Kconfig
 MINIKCONF_DEPS = $(MINIKCONF_INPUTS) \
-                 $(wildcard $(SRC_PATH)/hw/*/Kconfig)
+                 $(wildcard $(SRC_PATH)/hw/*/Kconfig) \
+                 $(wildcard $(SRC_PATH)/target/*/Kconfig)
 MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py
 
 $(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_DEPS) $(BUILD_DIR)/config-host.mak
 	$(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) \
+		$(wildcard $(SRC_PATH)/target/$(call base-arch, $(firstword $(subst -, ,$@)))/Kconfig) \
 		> [email protected], "GEN", "[email protected]")
 	$(call quiet-command, if test -f $@; then \
 	  if cmp -s [email protected] $@; then \
Signature · 1 line
2.21.3
#15 lore raw

PATCH v4 11/11 accel/tcg: Add stub for probe_access()

In reply to Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

The TCG helpers where added in b92e5a22ec3 in softmmu_template.h. probe_write() was added in there in 3b4afc9e75a to be moved out to accel/tcg/cputlb.c in 3b08f0a9254, and was later refactored as probe_access() in c25c283df0f.
Since it is a TCG specific helper, add a stub to avoid failures when building without TCG, such:

target/arm/helper.o: In function `probe_read':
include/exec/exec-all.h:362: undefined reference to `probe_access'

---
Cc: Richard Henderson <[email protected]>
Cc: Emilio G. Cota <[email protected]>
Cc: Alex Bennée <[email protected]>
Cc: David Hildenbrand <[email protected]>

---
 accel/stubs/tcg-stub.c | 7 +++++++
 1 file changed, 7 insertions(+)
accel/stubs/tcg-stub.c +7 -0
index 677191a69c..e4bbf997aa 100644
@@ -22,3 +22,10 @@ void tb_flush(CPUState *cpu)
 void tlb_set_dirty(CPUState *cpu, target_ulong vaddr)
 {
 }
+
+void *probe_access(CPUArchState *env, target_ulong addr, int size,
+                   MMUAccessType access_type, int mmu_idx, uintptr_t retaddr)
+{
+     /* Handled by hardware accelerator. */
+     g_assert_not_reached();
+}
Signature · 1 line
2.21.3