configure: Support CONFIG_* extension
cover configure: Support CONFIG_* extension
riscv already wants to change NR_CPUS sometimes, so a CONFIG_NR_CPUS, which can be changed at compile time, would be helpful. We could just provide support for that with the configure command line, but other configurations will eventually come along (there are already two more in another riscv branch). Add support for extending config.h with a manually provided config.h-type file and also add support for using it for CONFIG_NR_CPUS for riscv.
Andrew Jones (2):
configure: Introduce add-config
riscv: Make NR_CPUS configurable
configure | 17 ++++++++++++++++- lib/riscv/asm/setup.h | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-)
Signature · 1 line
2.46.0
PATCH 1/2 configure: Introduce add-config
Allow users to add additional CONFIG_* and override defaults by concatenating a given file with #define's and #undef's to lib/config.h
--- configure | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
configure +14 -0
@@ -64,6 +64,8 @@ usage() { no environ is provided by the user (enabled by default) --erratatxt=FILE specify a file to use instead of errata.txt. Use '--erratatxt=' to ensure no file is used. + --add-config=FILE specify a file containing configs (CONFIG_*) to add on to the + generated lib/config.h. Use #undef to override default configs. --host-key-document=HOST_KEY_DOCUMENT Specify the machine-specific host-key document for creating a PVM image with 'genprotimg' (s390x only)
@@ -153,6 +155,10 @@ while [[ "$1" = -* ]]; do erratatxt= [ "$arg" ] && erratatxt=$(eval realpath "$arg") ;; + --add-config) + add_config= + [ "$arg" ] && add_config=$(eval realpath "$arg") + ;; --host-key-document) host_key_document="$arg" ;;
@@ -213,6 +219,10 @@ if [ "$erratatxt" ] && [ ! -f "$erratatxt" ]; then echo "erratatxt: $erratatxt does not exist or is not a regular file" exit 1 fi +if [ "$add_config" ] && [ ! -f "$add_config" ]; then + echo "add-config: $add_config does not exist or is not a regular file" + exit 1 +fi arch_name=$arch [ "$arch" = "aarch64" ] && arch="arm64"
@@ -502,4 +512,8 @@ cat <<EOF >> lib/config.h EOF fi +if [ "$add_config" ]; then + echo "/* Additional configs from $add_config */" >> lib/config.h + cat "$add_config" >> lib/config.h +fi echo "#endif" >> lib/config.h
Signature · 1 line
2.46.0
Re: [kvm-unit-tests PATCH 1/2] configure: Introduce add-config
Quoted 3 lines · Andrew Jones
Allow users to add additional CONFIG_* and override defaults by concatenating a given file with #define's and #undef's to
lib/config.h
That's a horrible config format lol, but probbaly the simplest way to get something working. What if you included the user config first, then make the generated config test ifndef before defining the default?
Is it better to have a config file than to just add more --options to configure? If we had thousands of options maybe, but so far we are getting by with configure options. I think I prefer that for now unless we wholesale moved everything to a .config style.
Thanks,
Nick
Quoted 50 lines
Signed-off-by Andrew Jones <[email protected]>--- configure | 14 ++++++++++++++ 1 file changed, 14 insertions(+)configure +14
-0@@ -64,6 +64,8 @@ usage() { no environ is provided by the user (enabled by default) --erratatxt=FILE specify a file to use instead of errata.txt. Use '--erratatxt=' to ensure no file is used. + --add-config=FILE specify a file containing configs (CONFIG_*) to add on to the + generated lib/config.h. Use #undef to override default configs. --host-key-document=HOST_KEY_DOCUMENT Specify the machine-specific host-key document for creating a PVM image with 'genprotimg' (s390x only)@@ -153,6 +155,10 @@ while [[ "$1" = -* ]]; do erratatxt= [ "$arg" ] && erratatxt=$(eval realpath "$arg") ;; + --add-config) + add_config= + [ "$arg" ] && add_config=$(eval realpath "$arg") + ;; --host-key-document) host_key_document="$arg" ;;@@ -213,6 +219,10 @@ if [ "$erratatxt" ] && [ ! -f "$erratatxt" ]; then echo "erratatxt: $erratatxt does not exist or is not a regular file" exit 1 fi +if [ "$add_config" ] && [ ! -f "$add_config" ]; then + echo "add-config: $add_config does not exist or is not a regular file" + exit 1 +fi arch_name=$arch [ "$arch" = "aarch64" ] && arch="arm64"@@ -502,4 +512,8 @@ cat <<EOF >> lib/config.h EOF fi +if [ "$add_config" ]; then + echo "/* Additional configs from $add_config */" >> lib/config.h + cat "$add_config" >> lib/config.h +fi echo "#endif" >> lib/config.h
Re: [kvm-unit-tests PATCH 1/2] configure: Introduce add-config
Quoted 8 lines · Nicholas Piggin
Quoted 3 lines · Andrew Jones
Allow users to add additional CONFIG_* and override defaults by concatenating a given file with #define's and #undef's to
lib/config.hThat's a horrible config format lol, but probbaly the simplest way to get something working. What if you included the user config first, then make the generated config test ifndef before defining the default?
User config first and then #ifndef would indeed be better.
Quoted 4 lines
Is it better to have a config file than to just add more --options to configure? If we had thousands of options maybe, but so far we are getting by with configure options.
I have some unposted patches where I introduce two more configs, which is what inspired me to stop adding configure command line options.
Quoted 2 lines
I think I prefer that for now
unless we wholesale moved everything to a .config style.
Moving to .config would be good, and importing and applying Kconfiglib doesn't look too daunting either. We can put this --add-config idea on hold until we've had a chance to experiment.
Thanks,
drew
PATCH 2/2 riscv: Make NR_CPUS configurable
In reply to Andrew JonesUnit tests would like to go nuts with the number of harts in order to help shake out issues with hart number assumptions. Rather than set a huge number that will only be used when a platform supports a huge number or when QEMU is told to exceed the recommended number of vcpus, make the number configurable. However, we do bump the default from 16 to 2*xlen since we would like to always force kvm-unit-tests to use cpumasks with more than one word in order to ensure that code stays maintained.
To override the default for NR_CPUS to, e.g. 256, testers should use --add-config. For example,
$ cat <<EOF > 256.config #undef CONFIG_NR_CPUS #define CONFIG_NR_CPUS 256 EOF $ ./configure --arch=riscv64 --cross-prefix=riscv64-linux-gnu- --add-config=256.config
--- configure | 3 ++- lib/riscv/asm/setup.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
configure +2 -1
@@ -508,7 +508,8 @@ EOF elif [ "$arch" = "riscv32" ] || [ "$arch" = "riscv64" ]; then cat <<EOF >> lib/config.h -#define CONFIG_UART_EARLY_BASE 0x10000000 +#define CONFIG_NR_CPUS (__riscv_xlen * 2) +#define CONFIG_UART_EARLY_BASE 0x10000000 EOF fi
lib/riscv/asm/setup.h +2 -1
@@ -2,9 +2,10 @@#ifndef _ASMRISCV_SETUP_H_#define _ASMRISCV_SETUP_H_#include <libcflat.h> +#include <config.h> #include <asm/processor.h> -#define NR_CPUS 16 +#define NR_CPUS CONFIG_NR_CPUSextern struct thread_info cpus[NR_CPUS ];extern int nr_cpus;extern uint64_t timebase_frequency;
Signature · 1 line
2.46.0