RE: [PATCH v4] blockjob: Fix crash with IOthread when block commit after snapshot

2021-01-31 Thread 仇大玉
Any comments?

It's really a bug and can cause the qemu to segmentfault.

Thanks,
Michael

-Original Message-
From: 仇大玉 
Sent: 2021年1月28日 13:16
To: qemu-block@nongnu.org; qemu-de...@nongnu.org
Cc: kw...@redhat.com; mre...@redhat.com; js...@redhat.com; 08005...@163.com
Subject: RE: [PATCH v4] blockjob: Fix crash with IOthread when block commit 
after snapshot

Any comments?

-Original Message-
From: 08005...@163.com <08005...@163.com> 
Sent: 2021年1月28日 9:31
To: kw...@redhat.com; mre...@redhat.com; js...@redhat.com
Cc: qemu-block@nongnu.org; qemu-de...@nongnu.org; 仇大玉 
Subject: [PATCH v4] blockjob: Fix crash with IOthread when block commit after 
snapshot

From: Michael Qiu 

v4: rebase to latest code

v3: reformat the commit log, remove duplicate content

v2: modify the coredump backtrace within commit log with the newest
qemu with master branch

Currently, if guest has workloads, IO thread will acquire aio_context lock 
before do io_submit, it leads to segmentfault when do block commit after 
snapshot. Just like below:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f7c7d91f700 (LWP 99907)] 0x5576d0f65aab in 
bdrv_mirror_top_pwritev at ../block/mirror.c:1437
1437../block/mirror.c: No such file or directory.
(gdb) p s->job
$17 = (MirrorBlockJob *) 0x0
(gdb) p s->stop
$18 = false

(gdb) bt

Switch to qemu main thread:
/lib/../lib64/libpthread.so.0
/lib/../lib64/libpthread.so.0
../util/qemu-thread-posix.c:79
qapi/qapi-commands-block-core.c:346
../qapi/qmp-dispatch.c:110
/lib/../lib64/libglib-2.0.so.0

In IO thread when do bdrv_mirror_top_pwritev, the job is NULL, and stop field 
is false, this means the MirrorBDSOpaque "s" object has not been initialized 
yet, and this object is initialized by block_job_create(), but the initialize 
process is stuck in acquiring the lock.

The rootcause is that qemu do release/acquire when hold the lock, at the same 
time, IO thread get the lock after release stage, and the crash occured.

Actually, in this situation, job->job.aio_context will not equal to 
qemu_get_aio_context(), and will be the same as bs->aio_context, thus, no need 
to release the lock, becasue bdrv_root_attach_child() will not change the 
context.

This patch fix this issue.

Signed-off-by: Michael Qiu 
---
 blockjob.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/blockjob.c b/blockjob.c
index 98ac8af982..51a09f3b60 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -214,13 +214,15 @@ int block_job_add_bdrv(BlockJob *job, const char *name, 
BlockDriverState *bs,
 BdrvChild *c;
 
 bdrv_ref(bs);
-if (job->job.aio_context != qemu_get_aio_context()) {
+if (bdrv_get_aio_context(bs) != job->job.aio_context &&
+job->job.aio_context != qemu_get_aio_context()) {
 aio_context_release(job->job.aio_context);
 }
 c = bdrv_root_attach_child(bs, name, &child_job, 0,
job->job.aio_context, perm, shared_perm, job,
errp);
-if (job->job.aio_context != qemu_get_aio_context()) {
+if (bdrv_get_aio_context(bs) != job->job.aio_context &&
+job->job.aio_context != qemu_get_aio_context()) {
 aio_context_acquire(job->job.aio_context);
 }
 if (c == NULL) {
--
2.22.0




Re: [PATCH 05/10] meson: Introduce target-specific Kconfig

2021-01-31 Thread Philippe Mathieu-Daudé
On 1/31/21 1:36 PM, Philippe Mathieu-Daudé wrote:
> On 1/31/21 12:13 PM, Philippe Mathieu-Daudé wrote:
>> Add a target-specific Kconfig.
>>
>> Target foo now has CONFIG_FOO defined.
>>
>> Two architecture have a particularity, ARM and MIPS:
>> their 64-bit version include the 32-bit subset.
>>
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
> ...
> 
>> diff --git a/meson.build b/meson.build
>> index f00b7754fd4..a2dda0ce95e 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -1322,7 +1322,8 @@
>>command: [minikconf,
>>  get_option('default_devices') ? '--defconfig' : 
>> '--allnoconfig',
>>  config_devices_mak, '@DEPFILE@', '@INPUT@',
>> -host_kconfig, accel_kconfig])
>> +host_kconfig, accel_kconfig,
>> +'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'])
>>  
>>  config_devices_data = configuration_data()
>>  config_devices = keyval.load(config_devices_mak)
>> diff --git a/Kconfig b/Kconfig
>> index bf694c42afe..c01e261e4e9 100644
>> --- a/Kconfig
>> +++ b/Kconfig
>> @@ -1,4 +1,5 @@
>>  source Kconfig.host
>>  source backends/Kconfig
>>  source accel/Kconfig
>> +source target/Kconfig
>>  source hw/Kconfig
>> diff --git a/target/Kconfig b/target/Kconfig
>> new file mode 100644
>> index 000..a6f719f223a
>> --- /dev/null
>> +++ b/target/Kconfig
>> @@ -0,0 +1,23 @@
>> +source alpha/Kconfig
>> +source arm/Kconfig
>> +source avr/Kconfig
>> +source cris/Kconfig
>> +source hppa/Kconfig
>> +source i386/Kconfig
>> +source lm32/Kconfig
>> +source m68k/Kconfig
>> +source microblaze/Kconfig
>> +source mips/Kconfig
>> +source moxie/Kconfig
>> +source nios2/Kconfig
>> +source openrisc/Kconfig
>> +source ppc/Kconfig
>> +source riscv/Kconfig
>> +source rx/Kconfig
>> +source s390x/Kconfig
>> +source sh4/Kconfig
>> +source sparc/Kconfig
>> +source tilegx/Kconfig
>> +source tricore/Kconfig
>> +source unicore32/Kconfig
>> +source xtensa/Kconfig
>> diff --git a/target/arm/Kconfig b/target/arm/Kconfig
>> new file mode 100644
>> index 000..3f3394a22b2
>> --- /dev/null
>> +++ b/target/arm/Kconfig
>> @@ -0,0 +1,6 @@
>> +config ARM
>> +bool
>> +
>> +config AARCH64
>> +bool
>> +select ARM
> 
> This isn't correct yet, as Kconfig is primarly designed for devices,
> and per docs/devel/kconfig.rst:
> 
>   "devices are usually ``default y`` if and only if they have at
>least one ``depends on``;"
> 
> So having one machine "depends on AARCH64" selects AARCH64 on ARM :/
> I'll see if explicit each arch as 'default n' helps...

Taking this comment back, the approach works but is fragile, as
an incorrect dependency can select the wrong arch and it is hard
to detect.



Re: [PATCH v6 01/11] sysemu/tcg: Introduce tcg_builtin() helper

2021-01-31 Thread Philippe Mathieu-Daudé
On 1/31/21 3:18 PM, Claudio Fontana wrote:
> On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
>> Modules are registered early with type_register_static().
>>
>> We would like to call tcg_enabled() when registering QOM types,
> 
> 
> Hi Philippe,
> 
> could this not be controlled by meson at this stage?
> On X86, I register the tcg-specific types in tcg/* in modules that are only 
> built for TCG.
> 
> Maybe tcg_builtin() is useful anyway, thinking long term at loadable modules,
> but there we are interested in whether tcg code is available or not, 
> regardless of whether it's builtin,
> or needs to be loaded via a .so plugin..
> 
> maybe tcg_available()?

The alternatives I found:

- reorder things in vl.c?

- use ugly #ifdef'ry, see this patch:
  https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg08037.html

- this earlier approach I previously discarded:

-- >8 --
diff --git a/include/qom/object.h b/include/qom/object.h
index d378f13a116..30590c6fac3 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -403,9 +403,12 @@ struct Object
  *   parent class initialization has occurred, but before the class itself
  *   is initialized.  This is the function to use to undo the effects of
  *   memcpy from the parent class to the descendants.
- * @class_data: Data to pass to the @class_init,
+ * @class_data: Data to pass to the @class_registerable, @class_init,
  *   @class_base_init. This can be useful when building dynamic
  *   classes.
+ * @registerable: This function is called when modules are registered,
+ *   prior to any class initialization. When present and returning %false,
+ *   the type is not registered, the class is not present (not usable).
  * @interfaces: The list of interfaces associated with this type.  This
  *   should point to a static array that's terminated with a zero filled
  *   element.
@@ -428,6 +431,7 @@ struct TypeInfo
 void (*class_base_init)(ObjectClass *klass, void *data);
 void *class_data;

+bool (*registerable)(void *data);
 InterfaceInfo *interfaces;
 };

diff --git a/qom/object.c b/qom/object.c
index 2fa0119647c..0febaffa12e 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -138,6 +138,10 @@ static TypeImpl *type_new(const TypeInfo *info)
 static TypeImpl *type_register_internal(const TypeInfo *info)
 {
 TypeImpl *ti;
+
+if (info->registerable && !info->registerable(info->class_data)) {
+return NULL;
+}
 ti = type_new(info);

 type_table_add(ti);

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 990509d3852..1a2b1889da4 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -24,6 +24,7 @@
 #include "hw/loader.h"
 #include "hw/arm/boot.h"
 #include "sysemu/sysemu.h"
+#include "sysemu/tcg.h"
 #include "qom/object.h"

 #define SMPBOOT_ADDR0x300 /* this should leave enough space for
ATAGS */
@@ -368,18 +369,26 @@ static void raspi3b_machine_class_init(ObjectClass
*oc, void *data)
 };
 #endif /* TARGET_AARCH64 */

+static bool raspi_machine_requiring_tcg_accel(void *data)
+{
+return tcg_builtin();
+}
+
 static const TypeInfo raspi_machine_types[] = {
 {
 .name   = MACHINE_TYPE_NAME("raspi0"),
 .parent = TYPE_RASPI_MACHINE,
+.registerable   = raspi_machine_requiring_tcg_accel,
 .class_init = raspi0_machine_class_init,
 }, {
 .name   = MACHINE_TYPE_NAME("raspi1ap"),
 .parent = TYPE_RASPI_MACHINE,
+.registerable   = raspi_machine_requiring_tcg_accel,
 .class_init = raspi1ap_machine_class_init,
 }, {
 .name   = MACHINE_TYPE_NAME("raspi2b"),
 .parent = TYPE_RASPI_MACHINE,
+.registerable   = raspi_machine_requiring_tcg_accel,
 .class_init = raspi2b_machine_class_init,
 #ifdef TARGET_AARCH64
 }, {
---

> 
> Ciao,
> 
> Claudio
> 
>> but tcg_enabled() returns tcg_allowed which is a runtime property
>> initialized later (See commit 2f181fbd5a9 which introduced the
>> MachineInitPhase in "hw/qdev-core.h" representing the different
>> phases of machine initialization and commit 0427b6257e2 which
>> document the initialization order).
>>
>> As we are only interested if the TCG accelerator is builtin,
>> regardless of being enabled, introduce the tcg_builtin() helper.
>>
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
>> Cc: Markus Armbruster 
>> ---
>>  include/sysemu/tcg.h | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h
>> index 00349fb18a7..6ac5c2ca89d 100644
>> --- a/include/sysemu/tcg.h
>> +++ b/include/sysemu/tcg.h
>> @@ -13,8 +13,10 @@ void tcg_exec_init(unsigned long tb_size, int splitwx);
>>  #ifdef CONFIG_TCG
>>  extern bool tcg_allowed;
>>  #define tcg_enabled() (tcg_allowed)
>> +#define tcg_builtin() 1
>>  #else
>>  #define tcg_enabled() 0
>> +#define tcg_builtin() 0
>>  #endif
>>  
>>  #endif
>>
> 



Re: [PATCH v6 00/11] Support disabling TCG on ARM (part 2)

2021-01-31 Thread Philippe Mathieu-Daudé
On 1/31/21 3:40 PM, Claudio Fontana wrote:
> On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
>> Cover from Samuel Ortiz from (part 1) [1]:
>>
>>   This patchset allows for building and running ARM targets with TCG
>>   disabled. [...]
>>
>>   The rationale behind this work comes from the NEMU project where
>>   we're trying to only support x86 and ARM 64-bit architectures,
>>   without including the TCG code base. We can only do so if we can
>>   build and run ARM binaries with TCG disabled.
>>
>> Peter mentioned in v5 [6] that since 32-bit host has been removed,
>> we have to remove v7 targets. This is not done in this series, as
>> linking succeeds, and there is enough material to review (no need
>> to spend time on that extra patch if the current approach is not
>> accepted).
>>
>> CI: https://gitlab.com/philmd/qemu/-/pipelines/249272441
>>
>> v6:
>> - rebased on "target/arm/Kconfig" series
>> - introduce/use tcg_builtin() for realview machines
>>
>> v5:
>> - addressed Paolo/Richard/Thomas review comments from v4 [5].
>>
>> v4 almost 2 years later... [2]:
>> - Rebased on Meson
>> - Addressed Richard review comments
>> - Addressed Claudio review comments
>>
>> v3 almost 18 months later [3]:
>> - Rebased
>> - Addressed Thomas review comments
>> - Added Travis-CI job to keep building --disable-tcg on ARM
>>
>> v2 [4]:
>> - Addressed review comments from Richard and Thomas from v1 [1]
>>
>> Regards,
>>
>> Phil.
>>
>> [1]: https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg02451.html
>> [2]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg689168.html
>> [3]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg641796.html
>> [4]: https://lists.gnu.org/archive/html/qemu-devel/2019-08/msg05003.html
>> [5]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg746041.html
>> [6]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg777669.html
>>
>> Based-on: <2021013316.232778-1-f4...@amsat.org>
>>   "target: Provide target-specific Kconfig"
>>
>> Philippe Mathieu-Daudé (9):
>>   sysemu/tcg: Introduce tcg_builtin() helper
>>   exec: Restrict TCG specific headers
>>   target/arm: Restrict ARMv4 cpus to TCG accel
>>   target/arm: Restrict ARMv5 cpus to TCG accel
>>   target/arm: Restrict ARMv6 cpus to TCG accel
>>   target/arm: Restrict ARMv7 R-profile cpus to TCG accel
>>   target/arm: Restrict ARMv7 M-profile cpus to TCG accel
>>   target/arm: Reorder meson.build rules
>>   .travis.yml: Add a KVM-only Aarch64 job
>>
>> Samuel Ortiz (1):
>>   target/arm: Do not build TCG objects when TCG is off
>>
>> Thomas Huth (1):
>>   target/arm: Make m_helper.c optional via CONFIG_ARM_V7M
>>
>>  default-configs/devices/aarch64-softmmu.mak |  1 -
>>  default-configs/devices/arm-softmmu.mak | 27 
>>  include/exec/helper-proto.h |  2 +
>>  include/sysemu/tcg.h|  2 +
>>  target/arm/cpu.h| 12 
>>  hw/arm/realview.c   |  7 +-
>>  target/arm/cpu_tcg.c|  4 +-
>>  target/arm/helper.c |  7 --
>>  target/arm/m_helper-stub.c  | 73 +
>>  tests/qtest/cdrom-test.c|  6 +-
>>  .travis.yml | 32 +
>>  hw/arm/Kconfig  | 38 +++
>>  target/arm/Kconfig  | 17 +
>>  target/arm/meson.build  | 28 +---
>>  14 files changed, 196 insertions(+), 60 deletions(-)
>>  create mode 100644 target/arm/m_helper-stub.c
>>
> 
> Looking at this series, just my 2 cents on how I would suggest to go forward:
> I could again split my series in two parts, with only the TCG Ops in the 
> first part.
> 
> Then this series could be merged, enabling --disable-tcg for ARM,
> 
> then I could extend the second part of my series to include ARM as well.
> 
> Wdyt? (Probably Richard?)

¯\_(ツ)_/¯

I respun because Richard unqueue your series, and it looks
there is no big clashing.

Anyhow meanwhile peer review is useful, and thanks for yours ;)

> 
> Thanks,
> 
> Claudio
> 
> 
> 
> 



Re: [PATCH v6 00/11] Support disabling TCG on ARM (part 2)

2021-01-31 Thread Claudio Fontana
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> Cover from Samuel Ortiz from (part 1) [1]:
> 
>   This patchset allows for building and running ARM targets with TCG
>   disabled. [...]
> 
>   The rationale behind this work comes from the NEMU project where
>   we're trying to only support x86 and ARM 64-bit architectures,
>   without including the TCG code base. We can only do so if we can
>   build and run ARM binaries with TCG disabled.
> 
> Peter mentioned in v5 [6] that since 32-bit host has been removed,
> we have to remove v7 targets. This is not done in this series, as
> linking succeeds, and there is enough material to review (no need
> to spend time on that extra patch if the current approach is not
> accepted).
> 
> CI: https://gitlab.com/philmd/qemu/-/pipelines/249272441
> 
> v6:
> - rebased on "target/arm/Kconfig" series
> - introduce/use tcg_builtin() for realview machines
> 
> v5:
> - addressed Paolo/Richard/Thomas review comments from v4 [5].
> 
> v4 almost 2 years later... [2]:
> - Rebased on Meson
> - Addressed Richard review comments
> - Addressed Claudio review comments
> 
> v3 almost 18 months later [3]:
> - Rebased
> - Addressed Thomas review comments
> - Added Travis-CI job to keep building --disable-tcg on ARM
> 
> v2 [4]:
> - Addressed review comments from Richard and Thomas from v1 [1]
> 
> Regards,
> 
> Phil.
> 
> [1]: https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg02451.html
> [2]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg689168.html
> [3]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg641796.html
> [4]: https://lists.gnu.org/archive/html/qemu-devel/2019-08/msg05003.html
> [5]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg746041.html
> [6]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg777669.html
> 
> Based-on: <2021013316.232778-1-f4...@amsat.org>
>   "target: Provide target-specific Kconfig"
> 
> Philippe Mathieu-Daudé (9):
>   sysemu/tcg: Introduce tcg_builtin() helper
>   exec: Restrict TCG specific headers
>   target/arm: Restrict ARMv4 cpus to TCG accel
>   target/arm: Restrict ARMv5 cpus to TCG accel
>   target/arm: Restrict ARMv6 cpus to TCG accel
>   target/arm: Restrict ARMv7 R-profile cpus to TCG accel
>   target/arm: Restrict ARMv7 M-profile cpus to TCG accel
>   target/arm: Reorder meson.build rules
>   .travis.yml: Add a KVM-only Aarch64 job
> 
> Samuel Ortiz (1):
>   target/arm: Do not build TCG objects when TCG is off
> 
> Thomas Huth (1):
>   target/arm: Make m_helper.c optional via CONFIG_ARM_V7M
> 
>  default-configs/devices/aarch64-softmmu.mak |  1 -
>  default-configs/devices/arm-softmmu.mak | 27 
>  include/exec/helper-proto.h |  2 +
>  include/sysemu/tcg.h|  2 +
>  target/arm/cpu.h| 12 
>  hw/arm/realview.c   |  7 +-
>  target/arm/cpu_tcg.c|  4 +-
>  target/arm/helper.c |  7 --
>  target/arm/m_helper-stub.c  | 73 +
>  tests/qtest/cdrom-test.c|  6 +-
>  .travis.yml | 32 +
>  hw/arm/Kconfig  | 38 +++
>  target/arm/Kconfig  | 17 +
>  target/arm/meson.build  | 28 +---
>  14 files changed, 196 insertions(+), 60 deletions(-)
>  create mode 100644 target/arm/m_helper-stub.c
> 

Looking at this series, just my 2 cents on how I would suggest to go forward:
I could again split my series in two parts, with only the TCG Ops in the first 
part.

Then this series could be merged, enabling --disable-tcg for ARM,

then I could extend the second part of my series to include ARM as well.

Wdyt? (Probably Richard?)

Thanks,

Claudio







Re: [PATCH v6 07/11] target/arm: Restrict ARMv7 M-profile cpus to TCG accel

2021-01-31 Thread Claudio Fontana
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> KVM requires the target cpu to be at least ARMv8 architecture
> (support on ARMv7 has been dropped in commit 82bf7ae84ce:
> "target/arm: Remove KVM support for 32-bit Arm hosts").
> 
> Beside, KVM only supports A-profile, thus won't be able to run
> M-profile cpus.
> 
> Only enable the following ARMv7 M-Profile CPUs when TCG is available:
> 
>   - Cortex-M0
>   - Cortex-M3
>   - Cortex-M4
>   - Cortex-M33
> 
> The following machines are no more built when TCG is disabled:
> 
>   - emcraft-sf2  SmartFusion2 SOM kit from Emcraft (M2S010)
>   - highbank Calxeda Highbank (ECX-1000)
>   - lm3s6965evb  Stellaris LM3S6965EVB (Cortex-M3)
>   - lm3s811evb   Stellaris LM3S811EVB (Cortex-M3)
>   - midway   Calxeda Midway (ECX-2000)
>   - mps2-an385   ARM MPS2 with AN385 FPGA image for Cortex-M3
>   - mps2-an386   ARM MPS2 with AN386 FPGA image for Cortex-M4
>   - mps2-an500   ARM MPS2 with AN500 FPGA image for Cortex-M7
>   - mps2-an505   ARM MPS2 with AN505 FPGA image for Cortex-M33
>   - mps2-an511   ARM MPS2 with AN511 DesignStart FPGA image for 
> Cortex-M3
>   - mps2-an521   ARM MPS2 with AN521 FPGA image for dual Cortex-M33
>   - musca-a  ARM Musca-A board (dual Cortex-M33)
>   - musca-b1 ARM Musca-B1 board (dual Cortex-M33)
>   - netduino2Netduino 2 Machine (Cortex-M3)
>   - netduinoplus2Netduino Plus 2 Machine(Cortex-M4)
> 
> We don't need to enforce CONFIG_ARM_V7M in default-configs anymore.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/devices/arm-softmmu.mak | 11 ---
>  hw/arm/Kconfig  |  7 +++
>  target/arm/Kconfig  |  1 +
>  3 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/default-configs/devices/arm-softmmu.mak 
> b/default-configs/devices/arm-softmmu.mak
> index 175530595ce..0fc80d7d6df 100644
> --- a/default-configs/devices/arm-softmmu.mak
> +++ b/default-configs/devices/arm-softmmu.mak
> @@ -1,28 +1,17 @@
>  # Default configuration for arm-softmmu
>  
> -# TODO: ARM_V7M is currently always required - make this more flexible!
> -CONFIG_ARM_V7M=y
> -
>  # CONFIG_PCI_DEVICES=n
>  # CONFIG_TEST_DEVICES=n
>  
>  CONFIG_ARM_VIRT=y
>  CONFIG_CUBIEBOARD=y
>  CONFIG_EXYNOS4=y
> -CONFIG_HIGHBANK=y
> -CONFIG_MUSCA=y
> -CONFIG_STELLARIS=y
>  CONFIG_REALVIEW=y
>  CONFIG_VEXPRESS=y
>  CONFIG_ZYNQ=y
>  CONFIG_NPCM7XX=y
> -CONFIG_NETDUINO2=y
> -CONFIG_NETDUINOPLUS2=y
> -CONFIG_MPS2=y
>  CONFIG_RASPI=y
>  CONFIG_SABRELITE=y
> -CONFIG_EMCRAFT_SF2=y
> -CONFIG_MICROBIT=y
>  CONFIG_FSL_IMX7=y
>  CONFIG_FSL_IMX6UL=y
>  CONFIG_ALLWINNER_H3=y
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 4baf1f97694..62f8b0d24e7 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -60,6 +60,7 @@ config EXYNOS4
>  
>  config HIGHBANK
>  bool
> +default y if TCG && ARM
>  select A9MPCORE
>  select A15MPCORE
>  select AHCI
> @@ -95,6 +96,7 @@ config MAINSTONE
>  
>  config MUSCA
>  bool
> +default y if TCG && ARM
>  select ARMSSE
>  select PL011
>  select PL031
> @@ -115,10 +117,12 @@ config MUSICPAL
>  
>  config NETDUINO2
>  bool
> +default y if TCG && ARM
>  select STM32F205_SOC
>  
>  config NETDUINOPLUS2
>  bool
> +default y if TCG && ARM
>  select STM32F405_SOC
>  
>  config NSERIES
> @@ -240,6 +244,7 @@ config SABRELITE
>  
>  config STELLARIS
>  bool
> +default y if TCG && ARM
>  select ARM_V7M
>  select CMSDK_APB_WATCHDOG
>  select I2C
> @@ -443,6 +448,7 @@ config ASPEED_SOC
>  
>  config MPS2
>  bool
> +default y if TCG && ARM
>  select ARMSSE
>  select LAN9118
>  select MPS2_FPGAIO
> @@ -496,6 +502,7 @@ config NRF51_SOC
>  
>  config EMCRAFT_SF2
>  bool
> +default y if TCG && ARM
>  select MSF2
>  select SSI_M25P80
>  
> diff --git a/target/arm/Kconfig b/target/arm/Kconfig
> index 4dc96c46520..07a2fad7a2b 100644
> --- a/target/arm/Kconfig
> +++ b/target/arm/Kconfig
> @@ -24,4 +24,5 @@ config ARM_V7R
>  
>  config ARM_V7M
>  bool
> +depends on TCG && ARM
>  select PTIMER
> 

Acked-by: Claudio Fontana 



Re: [PATCH v6 06/11] target/arm: Restrict ARMv7 R-profile cpus to TCG accel

2021-01-31 Thread Claudio Fontana
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> KVM requires the target cpu to be at least ARMv8 architecture
> (support on ARMv7 has been dropped in commit 82bf7ae84ce:
> "target/arm: Remove KVM support for 32-bit Arm hosts").
> 
> Beside, KVM only supports A-profile, thus won't be able to run
> R-profile cpus.
> 
> Only enable the following ARMv7 R-Profile CPUs when TCG is available:
> 
>   - Cortex-R5
>   - Cortex-R5F
> 
> The following machine is no more built when TCG is disabled:
> 
>   - xlnx-zcu102  Xilinx ZynqMP ZCU102 board with 4xA53s and 2xR5Fs
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/devices/aarch64-softmmu.mak | 1 -
>  hw/arm/Kconfig  | 2 ++
>  target/arm/Kconfig  | 4 
>  3 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/default-configs/devices/aarch64-softmmu.mak 
> b/default-configs/devices/aarch64-softmmu.mak
> index 958b1e08e40..a4202f56817 100644
> --- a/default-configs/devices/aarch64-softmmu.mak
> +++ b/default-configs/devices/aarch64-softmmu.mak
> @@ -3,6 +3,5 @@
>  # We support all the 32 bit boards so need all their config
>  include arm-softmmu.mak
>  
> -CONFIG_XLNX_ZYNQMP_ARM=y
>  CONFIG_XLNX_VERSAL=y
>  CONFIG_SBSA_REF=y
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 6c4bce4d637..4baf1f97694 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -360,8 +360,10 @@ config STM32F405_SOC
>  
>  config XLNX_ZYNQMP_ARM
>  bool
> +default y if TCG && ARM
>  select AHCI
>  select ARM_GIC
> +select ARM_V7R
>  select CADENCE
>  select DDC
>  select DPCD
> diff --git a/target/arm/Kconfig b/target/arm/Kconfig
> index fbb7bba9018..4dc96c46520 100644
> --- a/target/arm/Kconfig
> +++ b/target/arm/Kconfig
> @@ -18,6 +18,10 @@ config ARM_V6
>  bool
>  depends on TCG && ARM
>  
> +config ARM_V7R
> +bool
> +depends on TCG && ARM
> +
>  config ARM_V7M
>  bool
>  select PTIMER
> 

Acked-by: Claudio Fontana 



Re: [PATCH v6 05/11] target/arm: Restrict ARMv6 cpus to TCG accel

2021-01-31 Thread Claudio Fontana
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> KVM requires the target cpu to be at least ARMv8 architecture
> (support on ARMv7 has been dropped in commit 82bf7ae84ce:
> "target/arm: Remove KVM support for 32-bit Arm hosts").
> 
> Only enable the following ARMv6 CPUs when TCG is available:
> 
>   - ARM1136
>   - ARM1176
>   - ARM11MPCore
>   - Cortex-M0
> 
> The following machines are no more built when TCG is disabled:
> 
>   - kzm  ARM KZM Emulation Baseboard (ARM1136)
>   - microbit BBC micro:bit (Cortex-M0)
>   - n800 Nokia N800 tablet aka. RX-34 (OMAP2420)
>   - n810 Nokia N810 tablet aka. RX-44 (OMAP2420)
>   - realview-eb-mpcore   ARM RealView Emulation Baseboard (ARM11MPCore)
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/devices/arm-softmmu.mak | 2 --
>  hw/arm/realview.c   | 2 +-
>  tests/qtest/cdrom-test.c| 2 +-
>  hw/arm/Kconfig  | 6 ++
>  target/arm/Kconfig  | 4 
>  5 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/default-configs/devices/arm-softmmu.mak 
> b/default-configs/devices/arm-softmmu.mak
> index 0aad35da0c4..175530595ce 100644
> --- a/default-configs/devices/arm-softmmu.mak
> +++ b/default-configs/devices/arm-softmmu.mak
> @@ -10,9 +10,7 @@ CONFIG_ARM_VIRT=y
>  CONFIG_CUBIEBOARD=y
>  CONFIG_EXYNOS4=y
>  CONFIG_HIGHBANK=y
> -CONFIG_FSL_IMX31=y
>  CONFIG_MUSCA=y
> -CONFIG_NSERIES=y
>  CONFIG_STELLARIS=y
>  CONFIG_REALVIEW=y
>  CONFIG_VEXPRESS=y
> diff --git a/hw/arm/realview.c b/hw/arm/realview.c
> index 2dcf0a4c23e..0606d22da14 100644
> --- a/hw/arm/realview.c
> +++ b/hw/arm/realview.c
> @@ -463,8 +463,8 @@ static void realview_machine_init(void)
>  {
>  if (tcg_builtin()) {
>  type_register_static(&realview_eb_type);
> +type_register_static(&realview_eb_mpcore_type);
>  }
> -type_register_static(&realview_eb_mpcore_type);
>  type_register_static(&realview_pb_a8_type);
>  type_register_static(&realview_pbx_a9_type);
>  }
> diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
> index 1f1bc26fa7a..cb0409c5a11 100644
> --- a/tests/qtest/cdrom-test.c
> +++ b/tests/qtest/cdrom-test.c
> @@ -224,8 +224,8 @@ int main(int argc, char **argv)
>  const char *armmachines[] = {
>  #ifdef CONFIG_TCG
>  "realview-eb",
> -#endif /* CONFIG_TCG */
>  "realview-eb-mpcore",
> +#endif /* CONFIG_TCG */
>  "realview-pb-a8",
>  "realview-pbx-a9", "versatileab", "versatilepb", "vexpress-a15",
>  "vexpress-a9", "virt", NULL
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 560442bfc5c..6c4bce4d637 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -123,6 +123,8 @@ config NETDUINOPLUS2
>  
>  config NSERIES
>  bool
> +default y if TCG && ARM
> +select ARM_V6
>  select OMAP
>  select TMP105   # tempature sensor
>  select BLIZZARD # LCD/TV controller
> @@ -401,6 +403,8 @@ config FSL_IMX25
>  
>  config FSL_IMX31
>  bool
> +default y if TCG && ARM
> +select ARM_V6
>  select SERIAL
>  select IMX
>  select IMX_I2C
> @@ -478,11 +482,13 @@ config FSL_IMX6UL
>  
>  config MICROBIT
>  bool
> +default y if TCG && ARM
>  select NRF51_SOC
>  
>  config NRF51_SOC
>  bool
>  select I2C
> +select ARM_V6
>  select ARM_V7M
>  select UNIMP
>  
> diff --git a/target/arm/Kconfig b/target/arm/Kconfig
> index 9b3635617dc..fbb7bba9018 100644
> --- a/target/arm/Kconfig
> +++ b/target/arm/Kconfig
> @@ -14,6 +14,10 @@ config ARM_V5
>  bool
>  depends on TCG && ARM
>  
> +config ARM_V6
> +bool
> +depends on TCG && ARM
> +
>  config ARM_V7M
>  bool
>  select PTIMER
> 

Added Cc: Eduardo,

Looks good to me in general,

Acked-by: Claudio Fontana 

I am just wondering about that if (tcg_builtin()) / (or _available() as I 
suggest elsewhere), 
should we instead use the build system already at this stage, so no such check 
is necessary?

It could be a successive change, but then tcg_builtin() would be introduced, 
only to become useless after the proper refactoring is done,
and the build system is used to select the right modules to compile, which 
would do the registration.

Ciao,

Claudio




Re: [PATCH v6 04/11] target/arm: Restrict ARMv5 cpus to TCG accel

2021-01-31 Thread Claudio Fontana
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> KVM requires the target cpu to be at least ARMv8 architecture
> (support on ARMv7 has been dropped in commit 82bf7ae84ce:
> "target/arm: Remove KVM support for 32-bit Arm hosts").
> 
> Only enable the following ARMv5 CPUs when TCG is available:
> 
>   - ARM926
>   - ARM946
>   - ARM1026
>   - XScale (PXA250/255/260/261/262/270)
> 
> The following machines are no more built when TCG is disabled:
> 
>   - akitaSharp SL-C1000 (Akita) PDA (PXA270)
>   - ast2500-evb  Aspeed AST2500 EVB (ARM1176)
>   - ast2600-evb  Aspeed AST2600 EVB (Cortex A7)
>   - borzoi   Sharp SL-C3100 (Borzoi) PDA (PXA270)
>   - canon-a1100  Canon PowerShot A1100 IS (ARM946)
>   - collie   Sharp SL-5500 (Collie) PDA (SA-1110)
>   - connex   Gumstix Connex (PXA255)
>   - g220a-bmcBytedance G220A BMC (ARM1176)
>   - imx25-pdkARM i.MX25 PDK board (ARM926)
>   - integratorcp ARM Integrator/CP (ARM926EJ-S)
>   - mainstoneMainstone II (PXA27x)
>   - musicpal Marvell 88w8618 / MusicPal (ARM926EJ-S)
>   - palmetto-bmc OpenPOWER Palmetto BMC (ARM926EJ-S)
>   - realview-eb  ARM RealView Emulation Baseboard (ARM926EJ-S)
>   - romulus-bmc  OpenPOWER Romulus BMC (ARM1176)
>   - sonorapass-bmc   OCP SonoraPass BMC (ARM1176)
>   - spitzSharp SL-C3000 (Spitz) PDA (PXA270)
>   - supermicrox11-bmcSupermicro X11 BMC (ARM926EJ-S)
>   - swift-bmcOpenPOWER Swift BMC (ARM1176)
>   - tacoma-bmc   OpenPOWER Tacoma BMC (Cortex A7)
>   - terrier  Sharp SL-C3200 (Terrier) PDA (PXA270)
>   - tosa Sharp SL-6000 (Tosa) PDA (PXA255)
>   - verdex   Gumstix Verdex (PXA270)
>   - versatileab  ARM Versatile/AB (ARM926EJ-S)
>   - versatilepb  ARM Versatile/PB (ARM926EJ-S)
>   - witherspoon-bmc  OpenPOWER Witherspoon BMC (ARM1176)
>   - z2   Zipit Z2 (PXA27x)
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/devices/arm-softmmu.mak | 12 
>  hw/arm/realview.c   |  5 -
>  tests/qtest/cdrom-test.c|  6 +-
>  hw/arm/Kconfig  | 19 +++
>  target/arm/Kconfig  |  4 
>  5 files changed, 32 insertions(+), 14 deletions(-)
> 
> diff --git a/default-configs/devices/arm-softmmu.mak 
> b/default-configs/devices/arm-softmmu.mak
> index 6ae964c14fd..0aad35da0c4 100644
> --- a/default-configs/devices/arm-softmmu.mak
> +++ b/default-configs/devices/arm-softmmu.mak
> @@ -10,33 +10,21 @@ CONFIG_ARM_VIRT=y
>  CONFIG_CUBIEBOARD=y
>  CONFIG_EXYNOS4=y
>  CONFIG_HIGHBANK=y
> -CONFIG_INTEGRATOR=y
>  CONFIG_FSL_IMX31=y
> -CONFIG_MUSICPAL=y
>  CONFIG_MUSCA=y
>  CONFIG_NSERIES=y
>  CONFIG_STELLARIS=y
>  CONFIG_REALVIEW=y
> -CONFIG_VERSATILE=y
>  CONFIG_VEXPRESS=y
>  CONFIG_ZYNQ=y
> -CONFIG_MAINSTONE=y
> -CONFIG_GUMSTIX=y
> -CONFIG_SPITZ=y
> -CONFIG_TOSA=y
> -CONFIG_Z2=y
>  CONFIG_NPCM7XX=y
> -CONFIG_COLLIE=y
> -CONFIG_ASPEED_SOC=y
>  CONFIG_NETDUINO2=y
>  CONFIG_NETDUINOPLUS2=y
>  CONFIG_MPS2=y
>  CONFIG_RASPI=y
> -CONFIG_DIGIC=y
>  CONFIG_SABRELITE=y
>  CONFIG_EMCRAFT_SF2=y
>  CONFIG_MICROBIT=y
> -CONFIG_FSL_IMX25=y
>  CONFIG_FSL_IMX7=y
>  CONFIG_FSL_IMX6UL=y
>  CONFIG_ALLWINNER_H3=y
> diff --git a/hw/arm/realview.c b/hw/arm/realview.c
> index 0831159d158..2dcf0a4c23e 100644
> --- a/hw/arm/realview.c
> +++ b/hw/arm/realview.c
> @@ -18,6 +18,7 @@
>  #include "hw/pci/pci.h"
>  #include "net/net.h"
>  #include "sysemu/sysemu.h"
> +#include "sysemu/tcg.h"
>  #include "hw/boards.h"
>  #include "hw/i2c/i2c.h"
>  #include "exec/address-spaces.h"
> @@ -460,7 +461,9 @@ static const TypeInfo realview_pbx_a9_type = {
>  
>  static void realview_machine_init(void)
>  {
> -type_register_static(&realview_eb_type);
> +if (tcg_builtin()) {
> +type_register_static(&realview_eb_type);
> +}
>  type_register_static(&realview_eb_mpcore_type);
>  type_register_static(&realview_pb_a8_type);
>  type_register_static(&realview_pbx_a9_type);
> diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
> index 5af944a5fb7..1f1bc26fa7a 100644
> --- a/tests/qtest/cdrom-test.c
> +++ b/tests/qtest/cdrom-test.c
> @@ -222,7 +222,11 @@ int main(int argc, char **argv)
>  add_cdrom_param_tests(mips64machines);
>  } else if (g_str_equal(arch, "arm") || g_str_equal(arch, "aarch64")) {
>  const char *armmachines[] = {
> -"realview-eb", "realview-eb-mpcore", "realview-pb-a8",
> +#ifdef CONFIG_TCG
> +"realview-eb",
> +#endif /* CONFIG_TCG */
> +"realview-eb-mpcore",
> +"realview-pb-a8",
>  "realview-pbx-a9", "versatileab", "versatilepb", "vexpress-a15",
>  "vexpress-a9", "virt", NULL
>  };
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index f2957b33

Re: [PATCH v6 03/11] target/arm: Restrict ARMv4 cpus to TCG accel

2021-01-31 Thread Claudio Fontana
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> KVM requires the target cpu to be at least ARMv8 architecture
> (support on ARMv7 has been dropped in commit 82bf7ae84ce:
> "target/arm: Remove KVM support for 32-bit Arm hosts").
> 
> Only enable the following ARMv4 CPUs when TCG is available:
> 
>   - StrongARM (SA1100/1110)
>   - OMAP1510 (TI925T)
> 
> The following machines are no more built when TCG is disabled:
> 
>   - cheetah  Palm Tungsten|E aka. Cheetah PDA (OMAP310)
>   - sx1  Siemens SX1 (OMAP310) V2
>   - sx1-v1   Siemens SX1 (OMAP310) V1
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/devices/arm-softmmu.mak | 2 --
>  hw/arm/Kconfig  | 4 
>  target/arm/Kconfig  | 4 
>  3 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/default-configs/devices/arm-softmmu.mak 
> b/default-configs/devices/arm-softmmu.mak
> index 0824e9be795..6ae964c14fd 100644
> --- a/default-configs/devices/arm-softmmu.mak
> +++ b/default-configs/devices/arm-softmmu.mak
> @@ -14,8 +14,6 @@ CONFIG_INTEGRATOR=y
>  CONFIG_FSL_IMX31=y
>  CONFIG_MUSICPAL=y
>  CONFIG_MUSCA=y
> -CONFIG_CHEETAH=y
> -CONFIG_SX1=y
>  CONFIG_NSERIES=y
>  CONFIG_STELLARIS=y
>  CONFIG_REALVIEW=y
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index f3ecb73a3d8..f2957b33bee 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -31,6 +31,8 @@ config ARM_VIRT
>  
>  config CHEETAH
>  bool
> +default y if TCG && ARM
> +select ARM_V4
>  select OMAP
>  select TSC210X
>  
> @@ -249,6 +251,8 @@ config COLLIE
>  
>  config SX1
>  bool
> +default y if TCG && ARM
> +select ARM_V4
>  select OMAP
>  
>  config VERSATILE
> diff --git a/target/arm/Kconfig b/target/arm/Kconfig
> index ae89d05c7e5..811e1e81652 100644
> --- a/target/arm/Kconfig
> +++ b/target/arm/Kconfig
> @@ -6,6 +6,10 @@ config AARCH64
>  bool
>  select ARM
>  
> +config ARM_V4
> +bool
> +depends on TCG && ARM
> +
>  config ARM_V7M
>  bool
>  select PTIMER
> 

Looks good to me

Acked-by: Claudio Fontana 




Re: [PATCH v6 02/11] exec: Restrict TCG specific headers

2021-01-31 Thread Claudio Fontana
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> Fixes when building with --disable-tcg on ARM:
> 
>   In file included from target/arm/helper.c:16:
>   include/exec/helper-proto.h:42:10: fatal error: tcg-runtime.h: No such file 
> or directory
>  42 | #include "tcg-runtime.h"
> |  ^~~
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  include/exec/helper-proto.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
> index 659f9298e8f..740bff3bb4d 100644
> --- a/include/exec/helper-proto.h
> +++ b/include/exec/helper-proto.h
> @@ -39,8 +39,10 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), 
> dh_ctype(t3), \
>  
>  #include "helper.h"
>  #include "trace/generated-helpers.h"
> +#ifdef CONFIG_TCG
>  #include "tcg-runtime.h"
>  #include "plugin-helpers.h"
> +#endif /* CONFIG_TCG */
>  
>  #undef IN_HELPER_PROTO
>  
> 

Ok, this would go away when applying the refactoring to ARM though right?

Ie the file should not need including at all later on right?

Anyway:

Reviewed-by: Claudio Fontana 



Re: [PATCH v6 01/11] sysemu/tcg: Introduce tcg_builtin() helper

2021-01-31 Thread Claudio Fontana
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> Modules are registered early with type_register_static().
> 
> We would like to call tcg_enabled() when registering QOM types,


Hi Philippe,

could this not be controlled by meson at this stage?
On X86, I register the tcg-specific types in tcg/* in modules that are only 
built for TCG.

Maybe tcg_builtin() is useful anyway, thinking long term at loadable modules,
but there we are interested in whether tcg code is available or not, regardless 
of whether it's builtin,
or needs to be loaded via a .so plugin..

maybe tcg_available()?

Ciao,

Claudio

> but tcg_enabled() returns tcg_allowed which is a runtime property
> initialized later (See commit 2f181fbd5a9 which introduced the
> MachineInitPhase in "hw/qdev-core.h" representing the different
> phases of machine initialization and commit 0427b6257e2 which
> document the initialization order).
> 
> As we are only interested if the TCG accelerator is builtin,
> regardless of being enabled, introduce the tcg_builtin() helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> Cc: Markus Armbruster 
> ---
>  include/sysemu/tcg.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h
> index 00349fb18a7..6ac5c2ca89d 100644
> --- a/include/sysemu/tcg.h
> +++ b/include/sysemu/tcg.h
> @@ -13,8 +13,10 @@ void tcg_exec_init(unsigned long tb_size, int splitwx);
>  #ifdef CONFIG_TCG
>  extern bool tcg_allowed;
>  #define tcg_enabled() (tcg_allowed)
> +#define tcg_builtin() 1
>  #else
>  #define tcg_enabled() 0
> +#define tcg_builtin() 0
>  #endif
>  
>  #endif
> 




Re: [RFC PATCH 1/4] hw/ide/Kconfig: IDE_ISA requires ISA_BUS

2021-01-31 Thread Philippe Mathieu-Daudé
On 1/29/21 8:59 PM, Paolo Bonzini wrote:
> On 29/01/21 20:44, Philippe Mathieu-Daudé wrote:
>> hw/ide/ioport.c has a strong dependency on hw/isa/isa-bus.c:
>>
>>    /usr/bin/ld: libcommon.fa.p/hw_ide_ioport.c.o: in function
>> `ide_init_ioport':
>>    /usr/bin/ld: hw/ide/ioport.c:61: undefined reference to
>> `isa_register_portio_list'
>>
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
>>   hw/ide/Kconfig | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/ide/Kconfig b/hw/ide/Kconfig
>> index 5d9106b1ac2..41cdd9cbe03 100644
>> --- a/hw/ide/Kconfig
>> +++ b/hw/ide/Kconfig
>> @@ -12,7 +12,7 @@ config IDE_PCI
>>     config IDE_ISA
>>   bool
>> -    depends on ISA_BUS
>> +    select ISA_BUS
>>   select IDE_QDEV
>>     config IDE_PIIX
> 
> This is incorrect.  Buses are "depended on", not selected, and this is
> documented in docs/devel/kconfig.rst.

This is a kludge to deal with the current state of hw/i386/Kconfig.

I tried to clean it twice (mostly because unused things are pulled
in the MIPS targets), but I eventually gave up after accepting the
PC machines are Frankenstein ones built for virtualization, and I've
been told "if it ain't broke, don't fix it".



Re: [PATCH v6 06/11] target/arm: Restrict ARMv7 R-profile cpus to TCG accel

2021-01-31 Thread Philippe Mathieu-Daudé
On 1/31/21 12:50 PM, Philippe Mathieu-Daudé wrote:
> KVM requires the target cpu to be at least ARMv8 architecture
> (support on ARMv7 has been dropped in commit 82bf7ae84ce:
> "target/arm: Remove KVM support for 32-bit Arm hosts").
> 
> Beside, KVM only supports A-profile, thus won't be able to run
> R-profile cpus.
> 
> Only enable the following ARMv7 R-Profile CPUs when TCG is available:
> 
>   - Cortex-R5
>   - Cortex-R5F
> 
> The following machine is no more built when TCG is disabled:
> 
>   - xlnx-zcu102  Xilinx ZynqMP ZCU102 board with 4xA53s and 2xR5Fs
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/devices/aarch64-softmmu.mak | 1 -
>  hw/arm/Kconfig  | 2 ++
>  target/arm/Kconfig  | 4 
>  3 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/default-configs/devices/aarch64-softmmu.mak 
> b/default-configs/devices/aarch64-softmmu.mak
> index 958b1e08e40..a4202f56817 100644
> --- a/default-configs/devices/aarch64-softmmu.mak
> +++ b/default-configs/devices/aarch64-softmmu.mak
> @@ -3,6 +3,5 @@
>  # We support all the 32 bit boards so need all their config
>  include arm-softmmu.mak
>  
> -CONFIG_XLNX_ZYNQMP_ARM=y
>  CONFIG_XLNX_VERSAL=y
>  CONFIG_SBSA_REF=y
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 6c4bce4d637..4baf1f97694 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -360,8 +360,10 @@ config STM32F405_SOC
>  
>  config XLNX_ZYNQMP_ARM
>  bool
> +default y if TCG && ARM

The correct line is:

  "default y if TCG && AARCH64"

>  select AHCI
>  select ARM_GIC
> +select ARM_V7R
>  select CADENCE
>  select DDC
>  select DPCD
> diff --git a/target/arm/Kconfig b/target/arm/Kconfig
> index fbb7bba9018..4dc96c46520 100644
> --- a/target/arm/Kconfig
> +++ b/target/arm/Kconfig
> @@ -18,6 +18,10 @@ config ARM_V6
>  bool
>  depends on TCG && ARM
>  
> +config ARM_V7R
> +bool
> +depends on TCG && ARM
> +
>  config ARM_V7M
>  bool
>  select PTIMER
> 




Re: [PATCH 05/10] meson: Introduce target-specific Kconfig

2021-01-31 Thread Philippe Mathieu-Daudé
On 1/31/21 12:13 PM, Philippe Mathieu-Daudé wrote:
> Add a target-specific Kconfig.
> 
> Target foo now has CONFIG_FOO defined.
> 
> Two architecture have a particularity, ARM and MIPS:
> their 64-bit version include the 32-bit subset.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
...

> diff --git a/meson.build b/meson.build
> index f00b7754fd4..a2dda0ce95e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1322,7 +1322,8 @@
>command: [minikconf,
>  get_option('default_devices') ? '--defconfig' : 
> '--allnoconfig',
>  config_devices_mak, '@DEPFILE@', '@INPUT@',
> -host_kconfig, accel_kconfig])
> +host_kconfig, accel_kconfig,
> +'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'])
>  
>  config_devices_data = configuration_data()
>  config_devices = keyval.load(config_devices_mak)
> diff --git a/Kconfig b/Kconfig
> index bf694c42afe..c01e261e4e9 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -1,4 +1,5 @@
>  source Kconfig.host
>  source backends/Kconfig
>  source accel/Kconfig
> +source target/Kconfig
>  source hw/Kconfig
> diff --git a/target/Kconfig b/target/Kconfig
> new file mode 100644
> index 000..a6f719f223a
> --- /dev/null
> +++ b/target/Kconfig
> @@ -0,0 +1,23 @@
> +source alpha/Kconfig
> +source arm/Kconfig
> +source avr/Kconfig
> +source cris/Kconfig
> +source hppa/Kconfig
> +source i386/Kconfig
> +source lm32/Kconfig
> +source m68k/Kconfig
> +source microblaze/Kconfig
> +source mips/Kconfig
> +source moxie/Kconfig
> +source nios2/Kconfig
> +source openrisc/Kconfig
> +source ppc/Kconfig
> +source riscv/Kconfig
> +source rx/Kconfig
> +source s390x/Kconfig
> +source sh4/Kconfig
> +source sparc/Kconfig
> +source tilegx/Kconfig
> +source tricore/Kconfig
> +source unicore32/Kconfig
> +source xtensa/Kconfig
> diff --git a/target/arm/Kconfig b/target/arm/Kconfig
> new file mode 100644
> index 000..3f3394a22b2
> --- /dev/null
> +++ b/target/arm/Kconfig
> @@ -0,0 +1,6 @@
> +config ARM
> +bool
> +
> +config AARCH64
> +bool
> +select ARM

This isn't correct yet, as Kconfig is primarly designed for devices,
and per docs/devel/kconfig.rst:

  "devices are usually ``default y`` if and only if they have at
   least one ``depends on``;"

So having one machine "depends on AARCH64" selects AARCH64 on ARM :/
I'll see if explicit each arch as 'default n' helps...



Re: [PATCH v6 11/11] .travis.yml: Add a KVM-only Aarch64 job

2021-01-31 Thread Philippe Mathieu-Daudé
On Sun, Jan 31, 2021 at 12:51 PM Philippe Mathieu-Daudé  wrote:
>
> From: Philippe Mathieu-Daudé 
>
> Add a job to build QEMU on Aarch64 with TCG disabled, so
> this configuration won't bitrot over time.
>
> We explicitly modify default-configs/aarch64-softmmu.mak to
> only select the 'virt' and 'SBSA-REF' machines.
>
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> Job ran for 7 min 30 sec
> https://travis-ci.org/github/philmd/qemu/jobs/731428859

BTW I added this patch for completeness but I couldn't test it again
as I don't have anymore Travis-CI credit. I however tested it on a similar
Ubuntu Aarch64 host.



[PATCH v6 11/11] .travis.yml: Add a KVM-only Aarch64 job

2021-01-31 Thread Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé 

Add a job to build QEMU on Aarch64 with TCG disabled, so
this configuration won't bitrot over time.

We explicitly modify default-configs/aarch64-softmmu.mak to
only select the 'virt' and 'SBSA-REF' machines.

Signed-off-by: Philippe Mathieu-Daudé 
---
Job ran for 7 min 30 sec
https://travis-ci.org/github/philmd/qemu/jobs/731428859
---
 .travis.yml | 32 
 1 file changed, 32 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 5f1dea873ec..4f1d662b5fc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -264,6 +264,38 @@ jobs:
 - CONFIG="--disable-containers --target-list=${MAIN_SOFTMMU_TARGETS}"
 - UNRELIABLE=true
 
+- name: "[aarch64] GCC (disable-tcg)"
+  arch: arm64
+  dist: focal
+  addons:
+apt_packages:
+  - libaio-dev
+  - libattr1-dev
+  - libbrlapi-dev
+  - libcap-ng-dev
+  - libgcrypt20-dev
+  - libgnutls28-dev
+  - libgtk-3-dev
+  - libiscsi-dev
+  - liblttng-ust-dev
+  - libncurses5-dev
+  - libnfs-dev
+  - libnss3-dev
+  - libpixman-1-dev
+  - libpng-dev
+  - librados-dev
+  - libsdl2-dev
+  - libseccomp-dev
+  - liburcu-dev
+  - libusb-1.0-0-dev
+  - libvdeplug-dev
+  - libvte-2.91-dev
+  - ninja-build
+  env:
+- CONFIG="--disable-containers --disable-tcg --enable-kvm 
--disable-xen --disable-tools --disable-docs"
+- TEST_CMD="make check-unit"
+- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-aarch64"
+
 - name: "[ppc64] GCC check-tcg"
   arch: ppc64le
   dist: focal
-- 
2.26.2




[PATCH v6 10/11] target/arm: Do not build TCG objects when TCG is off

2021-01-31 Thread Philippe Mathieu-Daudé
From: Samuel Ortiz 

We can now safely turn all TCG dependent build off when CONFIG_TCG is
off. This allows building ARM binaries with --disable-tcg.

Signed-off-by: Samuel Ortiz 
[PMD: Heavily rebased during more than 2 years then finally rewritten]
Reviewed-by: Richard Henderson 
Signed-off-by: Philippe Mathieu-Daudé 
---
 target/arm/meson.build | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/target/arm/meson.build b/target/arm/meson.build
index aac9a383a61..11b7c0e18fe 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -27,7 +27,8 @@
   'gdbstub64.c',
 ))
 
-arm_ss.add(files(
+arm_tcg_ss = ss.source_set()
+arm_tcg_ss.add(files(
   'crypto_helper.c',
   'debug_helper.c',
   'iwmmxt_helper.c',
@@ -38,12 +39,12 @@
   'vec_helper.c',
   'cpu_tcg.c',
 ))
-arm_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('m_helper.c'), if_false: 
files('m_helper-stub.c'))
+arm_tcg_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('m_helper.c'), if_false: 
files('m_helper-stub.c'))
 arm_ss.add(when: 'CONFIG_TCG', if_false: files('m_helper-stub.c'))
 
 arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: 
files('kvm-stub.c'))
 
-arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
+arm_tcg_ss.add(when: 'TARGET_AARCH64', if_true: files(
   'helper-a64.c',
   'mte_helper.c',
   'pauth_helper.c',
@@ -52,14 +53,16 @@
   'translate-sve.c',
 ))
 
+arm_ss.add_all(when: 'CONFIG_TCG', if_true: arm_tcg_ss)
+
 arm_softmmu_ss = ss.source_set()
 arm_softmmu_ss.add(files(
   'arch_dump.c',
   'arm-powerctl.c',
   'machine.c',
   'monitor.c',
-  'psci.c',
 ))
+arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('psci.c'))
 
 target_arch += {'arm': arm_ss}
 target_softmmu_arch += {'arm': arm_softmmu_ss}
-- 
2.26.2




[PATCH v6 09/11] target/arm: Reorder meson.build rules

2021-01-31 Thread Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé 

Reorder the rules to make this file easier to modify.
No logical change introduced in this commit.

Reviewed-by: Richard Henderson 
Signed-off-by: Philippe Mathieu-Daudé 
---
 target/arm/meson.build | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/target/arm/meson.build b/target/arm/meson.build
index 6c6081966cd..aac9a383a61 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -14,31 +14,36 @@
 
 arm_ss = ss.source_set()
 arm_ss.add(gen)
+arm_ss.add(zlib)
 arm_ss.add(files(
   'cpu.c',
-  'crypto_helper.c',
-  'debug_helper.c',
   'gdbstub.c',
   'helper.c',
+  'vfp_helper.c',
+))
+
+arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
+  'cpu64.c',
+  'gdbstub64.c',
+))
+
+arm_ss.add(files(
+  'crypto_helper.c',
+  'debug_helper.c',
   'iwmmxt_helper.c',
   'neon_helper.c',
   'op_helper.c',
   'tlb_helper.c',
   'translate.c',
   'vec_helper.c',
-  'vfp_helper.c',
   'cpu_tcg.c',
 ))
-arm_ss.add(zlib)
-
 arm_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('m_helper.c'), if_false: 
files('m_helper-stub.c'))
 arm_ss.add(when: 'CONFIG_TCG', if_false: files('m_helper-stub.c'))
 
 arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: 
files('kvm-stub.c'))
 
 arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
-  'cpu64.c',
-  'gdbstub64.c',
   'helper-a64.c',
   'mte_helper.c',
   'pauth_helper.c',
-- 
2.26.2




[PATCH v6 07/11] target/arm: Restrict ARMv7 M-profile cpus to TCG accel

2021-01-31 Thread Philippe Mathieu-Daudé
KVM requires the target cpu to be at least ARMv8 architecture
(support on ARMv7 has been dropped in commit 82bf7ae84ce:
"target/arm: Remove KVM support for 32-bit Arm hosts").

Beside, KVM only supports A-profile, thus won't be able to run
M-profile cpus.

Only enable the following ARMv7 M-Profile CPUs when TCG is available:

  - Cortex-M0
  - Cortex-M3
  - Cortex-M4
  - Cortex-M33

The following machines are no more built when TCG is disabled:

  - emcraft-sf2  SmartFusion2 SOM kit from Emcraft (M2S010)
  - highbank Calxeda Highbank (ECX-1000)
  - lm3s6965evb  Stellaris LM3S6965EVB (Cortex-M3)
  - lm3s811evb   Stellaris LM3S811EVB (Cortex-M3)
  - midway   Calxeda Midway (ECX-2000)
  - mps2-an385   ARM MPS2 with AN385 FPGA image for Cortex-M3
  - mps2-an386   ARM MPS2 with AN386 FPGA image for Cortex-M4
  - mps2-an500   ARM MPS2 with AN500 FPGA image for Cortex-M7
  - mps2-an505   ARM MPS2 with AN505 FPGA image for Cortex-M33
  - mps2-an511   ARM MPS2 with AN511 DesignStart FPGA image for 
Cortex-M3
  - mps2-an521   ARM MPS2 with AN521 FPGA image for dual Cortex-M33
  - musca-a  ARM Musca-A board (dual Cortex-M33)
  - musca-b1 ARM Musca-B1 board (dual Cortex-M33)
  - netduino2Netduino 2 Machine (Cortex-M3)
  - netduinoplus2Netduino Plus 2 Machine(Cortex-M4)

We don't need to enforce CONFIG_ARM_V7M in default-configs anymore.

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/arm-softmmu.mak | 11 ---
 hw/arm/Kconfig  |  7 +++
 target/arm/Kconfig  |  1 +
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/default-configs/devices/arm-softmmu.mak 
b/default-configs/devices/arm-softmmu.mak
index 175530595ce..0fc80d7d6df 100644
--- a/default-configs/devices/arm-softmmu.mak
+++ b/default-configs/devices/arm-softmmu.mak
@@ -1,28 +1,17 @@
 # Default configuration for arm-softmmu
 
-# TODO: ARM_V7M is currently always required - make this more flexible!
-CONFIG_ARM_V7M=y
-
 # CONFIG_PCI_DEVICES=n
 # CONFIG_TEST_DEVICES=n
 
 CONFIG_ARM_VIRT=y
 CONFIG_CUBIEBOARD=y
 CONFIG_EXYNOS4=y
-CONFIG_HIGHBANK=y
-CONFIG_MUSCA=y
-CONFIG_STELLARIS=y
 CONFIG_REALVIEW=y
 CONFIG_VEXPRESS=y
 CONFIG_ZYNQ=y
 CONFIG_NPCM7XX=y
-CONFIG_NETDUINO2=y
-CONFIG_NETDUINOPLUS2=y
-CONFIG_MPS2=y
 CONFIG_RASPI=y
 CONFIG_SABRELITE=y
-CONFIG_EMCRAFT_SF2=y
-CONFIG_MICROBIT=y
 CONFIG_FSL_IMX7=y
 CONFIG_FSL_IMX6UL=y
 CONFIG_ALLWINNER_H3=y
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 4baf1f97694..62f8b0d24e7 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -60,6 +60,7 @@ config EXYNOS4
 
 config HIGHBANK
 bool
+default y if TCG && ARM
 select A9MPCORE
 select A15MPCORE
 select AHCI
@@ -95,6 +96,7 @@ config MAINSTONE
 
 config MUSCA
 bool
+default y if TCG && ARM
 select ARMSSE
 select PL011
 select PL031
@@ -115,10 +117,12 @@ config MUSICPAL
 
 config NETDUINO2
 bool
+default y if TCG && ARM
 select STM32F205_SOC
 
 config NETDUINOPLUS2
 bool
+default y if TCG && ARM
 select STM32F405_SOC
 
 config NSERIES
@@ -240,6 +244,7 @@ config SABRELITE
 
 config STELLARIS
 bool
+default y if TCG && ARM
 select ARM_V7M
 select CMSDK_APB_WATCHDOG
 select I2C
@@ -443,6 +448,7 @@ config ASPEED_SOC
 
 config MPS2
 bool
+default y if TCG && ARM
 select ARMSSE
 select LAN9118
 select MPS2_FPGAIO
@@ -496,6 +502,7 @@ config NRF51_SOC
 
 config EMCRAFT_SF2
 bool
+default y if TCG && ARM
 select MSF2
 select SSI_M25P80
 
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
index 4dc96c46520..07a2fad7a2b 100644
--- a/target/arm/Kconfig
+++ b/target/arm/Kconfig
@@ -24,4 +24,5 @@ config ARM_V7R
 
 config ARM_V7M
 bool
+depends on TCG && ARM
 select PTIMER
-- 
2.26.2




[PATCH v6 03/11] target/arm: Restrict ARMv4 cpus to TCG accel

2021-01-31 Thread Philippe Mathieu-Daudé
KVM requires the target cpu to be at least ARMv8 architecture
(support on ARMv7 has been dropped in commit 82bf7ae84ce:
"target/arm: Remove KVM support for 32-bit Arm hosts").

Only enable the following ARMv4 CPUs when TCG is available:

  - StrongARM (SA1100/1110)
  - OMAP1510 (TI925T)

The following machines are no more built when TCG is disabled:

  - cheetah  Palm Tungsten|E aka. Cheetah PDA (OMAP310)
  - sx1  Siemens SX1 (OMAP310) V2
  - sx1-v1   Siemens SX1 (OMAP310) V1

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/arm-softmmu.mak | 2 --
 hw/arm/Kconfig  | 4 
 target/arm/Kconfig  | 4 
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/default-configs/devices/arm-softmmu.mak 
b/default-configs/devices/arm-softmmu.mak
index 0824e9be795..6ae964c14fd 100644
--- a/default-configs/devices/arm-softmmu.mak
+++ b/default-configs/devices/arm-softmmu.mak
@@ -14,8 +14,6 @@ CONFIG_INTEGRATOR=y
 CONFIG_FSL_IMX31=y
 CONFIG_MUSICPAL=y
 CONFIG_MUSCA=y
-CONFIG_CHEETAH=y
-CONFIG_SX1=y
 CONFIG_NSERIES=y
 CONFIG_STELLARIS=y
 CONFIG_REALVIEW=y
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index f3ecb73a3d8..f2957b33bee 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -31,6 +31,8 @@ config ARM_VIRT
 
 config CHEETAH
 bool
+default y if TCG && ARM
+select ARM_V4
 select OMAP
 select TSC210X
 
@@ -249,6 +251,8 @@ config COLLIE
 
 config SX1
 bool
+default y if TCG && ARM
+select ARM_V4
 select OMAP
 
 config VERSATILE
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
index ae89d05c7e5..811e1e81652 100644
--- a/target/arm/Kconfig
+++ b/target/arm/Kconfig
@@ -6,6 +6,10 @@ config AARCH64
 bool
 select ARM
 
+config ARM_V4
+bool
+depends on TCG && ARM
+
 config ARM_V7M
 bool
 select PTIMER
-- 
2.26.2




[PATCH v6 08/11] target/arm: Make m_helper.c optional via CONFIG_ARM_V7M

2021-01-31 Thread Philippe Mathieu-Daudé
From: Thomas Huth 

We've already got the CONFIG_ARM_V7M switch, but it currently can
not be disabled yet. The m_helper.c code should not be compiled
into the binary if the switch is not enabled. We also have to
provide some stubs in a separate file to make sure that we still
can link the other code without CONFIG_ARM_V7M.

Signed-off-by: Thomas Huth 
Message-Id: <20190903154810.27365-4-th...@redhat.com>
[PMD: Keep m_helper-stub.c but extend it, rewrite the rest]
Signed-off-by: Philippe Mathieu-Daudé 
---
Rewrite since v3, therefore removed Richard R-b tag.
Signed-off-by: Philippe Mathieu-Daudé 
---
 target/arm/cpu.h   | 12 ---
 target/arm/cpu_tcg.c   |  4 ++-
 target/arm/helper.c|  7 
 target/arm/m_helper-stub.c | 73 ++
 target/arm/meson.build |  4 ++-
 5 files changed, 79 insertions(+), 21 deletions(-)
 create mode 100644 target/arm/m_helper-stub.c

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index d080239863c..0bd0e51e498 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2281,12 +2281,6 @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t 
excp_idx,
 /* Interface between CPU and Interrupt controller.  */
 #ifndef CONFIG_USER_ONLY
 bool armv7m_nvic_can_take_pending_exception(void *opaque);
-#else
-static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
-{
-return true;
-}
-#endif
 /**
  * armv7m_nvic_set_pending: mark the specified exception as pending
  * @opaque: the NVIC
@@ -2392,13 +2386,7 @@ int armv7m_nvic_raw_execution_priority(void *opaque);
  * @secure: the security state to test
  * This corresponds to the pseudocode IsReqExecPriNeg().
  */
-#ifndef CONFIG_USER_ONLY
 bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure);
-#else
-static inline bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
-{
-return false;
-}
 #endif
 
 /* Interface for defining coprocessor registers.
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
index 98544db2df3..3e1c9b40353 100644
--- a/target/arm/cpu_tcg.c
+++ b/target/arm/cpu_tcg.c
@@ -15,6 +15,7 @@
 /* CPU models. These are not needed for the AArch64 linux-user build. */
 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
 
+#ifndef CONFIG_USER_ONLY
 static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 {
 CPUClass *cc = CPU_GET_CLASS(cs);
@@ -38,6 +39,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int 
interrupt_request)
 }
 return ret;
 }
+#endif /* CONFIG_USER_ONLY */
 
 static void arm926_initfn(Object *obj)
 {
@@ -666,9 +668,9 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
 acc->info = data;
 #ifndef CONFIG_USER_ONLY
 cc->do_interrupt = arm_v7m_cpu_do_interrupt;
+cc->cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt;
 #endif
 
-cc->cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt;
 cc->gdb_core_xml_file = "arm-m-profile.xml";
 }
 
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 47e266d7e64..fe3d0291f9c 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -12825,13 +12825,6 @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
 }
 }
 
-#ifndef CONFIG_TCG
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
-{
-g_assert_not_reached();
-}
-#endif
-
 ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el)
 {
 ARMMMUIdx idx;
diff --git a/target/arm/m_helper-stub.c b/target/arm/m_helper-stub.c
new file mode 100644
index 000..6d751424e86
--- /dev/null
+++ b/target/arm/m_helper-stub.c
@@ -0,0 +1,73 @@
+/*
+ * ARM V7M related stubs.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "qemu/osdep.h"
+#include "cpu.h"
+#include "exec/helper-proto.h"
+#include "internals.h"
+
+void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
+{
+g_assert_not_reached();
+}
+
+void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
+{
+g_assert_not_reached();
+}
+
+uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
+{
+g_assert_not_reached();
+}
+
+void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
+{
+g_assert_not_reached();
+}
+
+uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
+{
+g_assert_not_reached();
+}
+
+void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
+{
+g_assert_not_reached();
+}
+
+void write_v7m_exception(CPUARMState *env, uint32_t new_exc)
+{
+g_assert_not_reached();
+}
+
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
+{
+g_assert_not_reached();
+}
+
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
+{
+g_assert_not_reached();
+}
+
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
+{
+g_assert_not_reached();
+}
+
+#ifndef CONFIG_USER_ONLY
+
+bool armv7m_nvic_can_take_pending_exception(void *opaque)
+{
+g_assert_not_reached();
+}
+
+void arm_v7m_cpu_do_interrupt(CPUState *cs)
+{
+g_assert_not_reached();
+}
+
+#endif /* CONFIG_USER_ONLY */
diff --git a/ta

[PATCH v6 06/11] target/arm: Restrict ARMv7 R-profile cpus to TCG accel

2021-01-31 Thread Philippe Mathieu-Daudé
KVM requires the target cpu to be at least ARMv8 architecture
(support on ARMv7 has been dropped in commit 82bf7ae84ce:
"target/arm: Remove KVM support for 32-bit Arm hosts").

Beside, KVM only supports A-profile, thus won't be able to run
R-profile cpus.

Only enable the following ARMv7 R-Profile CPUs when TCG is available:

  - Cortex-R5
  - Cortex-R5F

The following machine is no more built when TCG is disabled:

  - xlnx-zcu102  Xilinx ZynqMP ZCU102 board with 4xA53s and 2xR5Fs

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/aarch64-softmmu.mak | 1 -
 hw/arm/Kconfig  | 2 ++
 target/arm/Kconfig  | 4 
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/default-configs/devices/aarch64-softmmu.mak 
b/default-configs/devices/aarch64-softmmu.mak
index 958b1e08e40..a4202f56817 100644
--- a/default-configs/devices/aarch64-softmmu.mak
+++ b/default-configs/devices/aarch64-softmmu.mak
@@ -3,6 +3,5 @@
 # We support all the 32 bit boards so need all their config
 include arm-softmmu.mak
 
-CONFIG_XLNX_ZYNQMP_ARM=y
 CONFIG_XLNX_VERSAL=y
 CONFIG_SBSA_REF=y
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 6c4bce4d637..4baf1f97694 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -360,8 +360,10 @@ config STM32F405_SOC
 
 config XLNX_ZYNQMP_ARM
 bool
+default y if TCG && ARM
 select AHCI
 select ARM_GIC
+select ARM_V7R
 select CADENCE
 select DDC
 select DPCD
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
index fbb7bba9018..4dc96c46520 100644
--- a/target/arm/Kconfig
+++ b/target/arm/Kconfig
@@ -18,6 +18,10 @@ config ARM_V6
 bool
 depends on TCG && ARM
 
+config ARM_V7R
+bool
+depends on TCG && ARM
+
 config ARM_V7M
 bool
 select PTIMER
-- 
2.26.2




[PATCH v6 05/11] target/arm: Restrict ARMv6 cpus to TCG accel

2021-01-31 Thread Philippe Mathieu-Daudé
KVM requires the target cpu to be at least ARMv8 architecture
(support on ARMv7 has been dropped in commit 82bf7ae84ce:
"target/arm: Remove KVM support for 32-bit Arm hosts").

Only enable the following ARMv6 CPUs when TCG is available:

  - ARM1136
  - ARM1176
  - ARM11MPCore
  - Cortex-M0

The following machines are no more built when TCG is disabled:

  - kzm  ARM KZM Emulation Baseboard (ARM1136)
  - microbit BBC micro:bit (Cortex-M0)
  - n800 Nokia N800 tablet aka. RX-34 (OMAP2420)
  - n810 Nokia N810 tablet aka. RX-44 (OMAP2420)
  - realview-eb-mpcore   ARM RealView Emulation Baseboard (ARM11MPCore)

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/arm-softmmu.mak | 2 --
 hw/arm/realview.c   | 2 +-
 tests/qtest/cdrom-test.c| 2 +-
 hw/arm/Kconfig  | 6 ++
 target/arm/Kconfig  | 4 
 5 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/default-configs/devices/arm-softmmu.mak 
b/default-configs/devices/arm-softmmu.mak
index 0aad35da0c4..175530595ce 100644
--- a/default-configs/devices/arm-softmmu.mak
+++ b/default-configs/devices/arm-softmmu.mak
@@ -10,9 +10,7 @@ CONFIG_ARM_VIRT=y
 CONFIG_CUBIEBOARD=y
 CONFIG_EXYNOS4=y
 CONFIG_HIGHBANK=y
-CONFIG_FSL_IMX31=y
 CONFIG_MUSCA=y
-CONFIG_NSERIES=y
 CONFIG_STELLARIS=y
 CONFIG_REALVIEW=y
 CONFIG_VEXPRESS=y
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 2dcf0a4c23e..0606d22da14 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -463,8 +463,8 @@ static void realview_machine_init(void)
 {
 if (tcg_builtin()) {
 type_register_static(&realview_eb_type);
+type_register_static(&realview_eb_mpcore_type);
 }
-type_register_static(&realview_eb_mpcore_type);
 type_register_static(&realview_pb_a8_type);
 type_register_static(&realview_pbx_a9_type);
 }
diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
index 1f1bc26fa7a..cb0409c5a11 100644
--- a/tests/qtest/cdrom-test.c
+++ b/tests/qtest/cdrom-test.c
@@ -224,8 +224,8 @@ int main(int argc, char **argv)
 const char *armmachines[] = {
 #ifdef CONFIG_TCG
 "realview-eb",
-#endif /* CONFIG_TCG */
 "realview-eb-mpcore",
+#endif /* CONFIG_TCG */
 "realview-pb-a8",
 "realview-pbx-a9", "versatileab", "versatilepb", "vexpress-a15",
 "vexpress-a9", "virt", NULL
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 560442bfc5c..6c4bce4d637 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -123,6 +123,8 @@ config NETDUINOPLUS2
 
 config NSERIES
 bool
+default y if TCG && ARM
+select ARM_V6
 select OMAP
 select TMP105   # tempature sensor
 select BLIZZARD # LCD/TV controller
@@ -401,6 +403,8 @@ config FSL_IMX25
 
 config FSL_IMX31
 bool
+default y if TCG && ARM
+select ARM_V6
 select SERIAL
 select IMX
 select IMX_I2C
@@ -478,11 +482,13 @@ config FSL_IMX6UL
 
 config MICROBIT
 bool
+default y if TCG && ARM
 select NRF51_SOC
 
 config NRF51_SOC
 bool
 select I2C
+select ARM_V6
 select ARM_V7M
 select UNIMP
 
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
index 9b3635617dc..fbb7bba9018 100644
--- a/target/arm/Kconfig
+++ b/target/arm/Kconfig
@@ -14,6 +14,10 @@ config ARM_V5
 bool
 depends on TCG && ARM
 
+config ARM_V6
+bool
+depends on TCG && ARM
+
 config ARM_V7M
 bool
 select PTIMER
-- 
2.26.2




[PATCH v6 04/11] target/arm: Restrict ARMv5 cpus to TCG accel

2021-01-31 Thread Philippe Mathieu-Daudé
KVM requires the target cpu to be at least ARMv8 architecture
(support on ARMv7 has been dropped in commit 82bf7ae84ce:
"target/arm: Remove KVM support for 32-bit Arm hosts").

Only enable the following ARMv5 CPUs when TCG is available:

  - ARM926
  - ARM946
  - ARM1026
  - XScale (PXA250/255/260/261/262/270)

The following machines are no more built when TCG is disabled:

  - akitaSharp SL-C1000 (Akita) PDA (PXA270)
  - ast2500-evb  Aspeed AST2500 EVB (ARM1176)
  - ast2600-evb  Aspeed AST2600 EVB (Cortex A7)
  - borzoi   Sharp SL-C3100 (Borzoi) PDA (PXA270)
  - canon-a1100  Canon PowerShot A1100 IS (ARM946)
  - collie   Sharp SL-5500 (Collie) PDA (SA-1110)
  - connex   Gumstix Connex (PXA255)
  - g220a-bmcBytedance G220A BMC (ARM1176)
  - imx25-pdkARM i.MX25 PDK board (ARM926)
  - integratorcp ARM Integrator/CP (ARM926EJ-S)
  - mainstoneMainstone II (PXA27x)
  - musicpal Marvell 88w8618 / MusicPal (ARM926EJ-S)
  - palmetto-bmc OpenPOWER Palmetto BMC (ARM926EJ-S)
  - realview-eb  ARM RealView Emulation Baseboard (ARM926EJ-S)
  - romulus-bmc  OpenPOWER Romulus BMC (ARM1176)
  - sonorapass-bmc   OCP SonoraPass BMC (ARM1176)
  - spitzSharp SL-C3000 (Spitz) PDA (PXA270)
  - supermicrox11-bmcSupermicro X11 BMC (ARM926EJ-S)
  - swift-bmcOpenPOWER Swift BMC (ARM1176)
  - tacoma-bmc   OpenPOWER Tacoma BMC (Cortex A7)
  - terrier  Sharp SL-C3200 (Terrier) PDA (PXA270)
  - tosa Sharp SL-6000 (Tosa) PDA (PXA255)
  - verdex   Gumstix Verdex (PXA270)
  - versatileab  ARM Versatile/AB (ARM926EJ-S)
  - versatilepb  ARM Versatile/PB (ARM926EJ-S)
  - witherspoon-bmc  OpenPOWER Witherspoon BMC (ARM1176)
  - z2   Zipit Z2 (PXA27x)

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/arm-softmmu.mak | 12 
 hw/arm/realview.c   |  5 -
 tests/qtest/cdrom-test.c|  6 +-
 hw/arm/Kconfig  | 19 +++
 target/arm/Kconfig  |  4 
 5 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/default-configs/devices/arm-softmmu.mak 
b/default-configs/devices/arm-softmmu.mak
index 6ae964c14fd..0aad35da0c4 100644
--- a/default-configs/devices/arm-softmmu.mak
+++ b/default-configs/devices/arm-softmmu.mak
@@ -10,33 +10,21 @@ CONFIG_ARM_VIRT=y
 CONFIG_CUBIEBOARD=y
 CONFIG_EXYNOS4=y
 CONFIG_HIGHBANK=y
-CONFIG_INTEGRATOR=y
 CONFIG_FSL_IMX31=y
-CONFIG_MUSICPAL=y
 CONFIG_MUSCA=y
 CONFIG_NSERIES=y
 CONFIG_STELLARIS=y
 CONFIG_REALVIEW=y
-CONFIG_VERSATILE=y
 CONFIG_VEXPRESS=y
 CONFIG_ZYNQ=y
-CONFIG_MAINSTONE=y
-CONFIG_GUMSTIX=y
-CONFIG_SPITZ=y
-CONFIG_TOSA=y
-CONFIG_Z2=y
 CONFIG_NPCM7XX=y
-CONFIG_COLLIE=y
-CONFIG_ASPEED_SOC=y
 CONFIG_NETDUINO2=y
 CONFIG_NETDUINOPLUS2=y
 CONFIG_MPS2=y
 CONFIG_RASPI=y
-CONFIG_DIGIC=y
 CONFIG_SABRELITE=y
 CONFIG_EMCRAFT_SF2=y
 CONFIG_MICROBIT=y
-CONFIG_FSL_IMX25=y
 CONFIG_FSL_IMX7=y
 CONFIG_FSL_IMX6UL=y
 CONFIG_ALLWINNER_H3=y
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 0831159d158..2dcf0a4c23e 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -18,6 +18,7 @@
 #include "hw/pci/pci.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
+#include "sysemu/tcg.h"
 #include "hw/boards.h"
 #include "hw/i2c/i2c.h"
 #include "exec/address-spaces.h"
@@ -460,7 +461,9 @@ static const TypeInfo realview_pbx_a9_type = {
 
 static void realview_machine_init(void)
 {
-type_register_static(&realview_eb_type);
+if (tcg_builtin()) {
+type_register_static(&realview_eb_type);
+}
 type_register_static(&realview_eb_mpcore_type);
 type_register_static(&realview_pb_a8_type);
 type_register_static(&realview_pbx_a9_type);
diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
index 5af944a5fb7..1f1bc26fa7a 100644
--- a/tests/qtest/cdrom-test.c
+++ b/tests/qtest/cdrom-test.c
@@ -222,7 +222,11 @@ int main(int argc, char **argv)
 add_cdrom_param_tests(mips64machines);
 } else if (g_str_equal(arch, "arm") || g_str_equal(arch, "aarch64")) {
 const char *armmachines[] = {
-"realview-eb", "realview-eb-mpcore", "realview-pb-a8",
+#ifdef CONFIG_TCG
+"realview-eb",
+#endif /* CONFIG_TCG */
+"realview-eb-mpcore",
+"realview-pb-a8",
 "realview-pbx-a9", "versatileab", "versatilepb", "vexpress-a15",
 "vexpress-a9", "virt", NULL
 };
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index f2957b33bee..560442bfc5c 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -42,6 +42,8 @@ config CUBIEBOARD
 
 config DIGIC
 bool
+default y if TCG && ARM
+select ARM_V5
 select PTIMER
 select PFLASH_CFI02
 
@@ -72,6 +74,8 @@ config HIGHBANK
 
 config INTEGRATOR
 bool
+default y if TCG && A

[PATCH v6 02/11] exec: Restrict TCG specific headers

2021-01-31 Thread Philippe Mathieu-Daudé
Fixes when building with --disable-tcg on ARM:

  In file included from target/arm/helper.c:16:
  include/exec/helper-proto.h:42:10: fatal error: tcg-runtime.h: No such file 
or directory
 42 | #include "tcg-runtime.h"
|  ^~~

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/exec/helper-proto.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
index 659f9298e8f..740bff3bb4d 100644
--- a/include/exec/helper-proto.h
+++ b/include/exec/helper-proto.h
@@ -39,8 +39,10 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), 
dh_ctype(t3), \
 
 #include "helper.h"
 #include "trace/generated-helpers.h"
+#ifdef CONFIG_TCG
 #include "tcg-runtime.h"
 #include "plugin-helpers.h"
+#endif /* CONFIG_TCG */
 
 #undef IN_HELPER_PROTO
 
-- 
2.26.2




[PATCH v6 01/11] sysemu/tcg: Introduce tcg_builtin() helper

2021-01-31 Thread Philippe Mathieu-Daudé
Modules are registered early with type_register_static().

We would like to call tcg_enabled() when registering QOM types,
but tcg_enabled() returns tcg_allowed which is a runtime property
initialized later (See commit 2f181fbd5a9 which introduced the
MachineInitPhase in "hw/qdev-core.h" representing the different
phases of machine initialization and commit 0427b6257e2 which
document the initialization order).

As we are only interested if the TCG accelerator is builtin,
regardless of being enabled, introduce the tcg_builtin() helper.

Signed-off-by: Philippe Mathieu-Daudé 
---
Cc: Markus Armbruster 
---
 include/sysemu/tcg.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h
index 00349fb18a7..6ac5c2ca89d 100644
--- a/include/sysemu/tcg.h
+++ b/include/sysemu/tcg.h
@@ -13,8 +13,10 @@ void tcg_exec_init(unsigned long tb_size, int splitwx);
 #ifdef CONFIG_TCG
 extern bool tcg_allowed;
 #define tcg_enabled() (tcg_allowed)
+#define tcg_builtin() 1
 #else
 #define tcg_enabled() 0
+#define tcg_builtin() 0
 #endif
 
 #endif
-- 
2.26.2




[PATCH v6 00/11] Support disabling TCG on ARM (part 2)

2021-01-31 Thread Philippe Mathieu-Daudé
Cover from Samuel Ortiz from (part 1) [1]:

  This patchset allows for building and running ARM targets with TCG
  disabled. [...]

  The rationale behind this work comes from the NEMU project where
  we're trying to only support x86 and ARM 64-bit architectures,
  without including the TCG code base. We can only do so if we can
  build and run ARM binaries with TCG disabled.

Peter mentioned in v5 [6] that since 32-bit host has been removed,
we have to remove v7 targets. This is not done in this series, as
linking succeeds, and there is enough material to review (no need
to spend time on that extra patch if the current approach is not
accepted).

CI: https://gitlab.com/philmd/qemu/-/pipelines/249272441

v6:
- rebased on "target/arm/Kconfig" series
- introduce/use tcg_builtin() for realview machines

v5:
- addressed Paolo/Richard/Thomas review comments from v4 [5].

v4 almost 2 years later... [2]:
- Rebased on Meson
- Addressed Richard review comments
- Addressed Claudio review comments

v3 almost 18 months later [3]:
- Rebased
- Addressed Thomas review comments
- Added Travis-CI job to keep building --disable-tcg on ARM

v2 [4]:
- Addressed review comments from Richard and Thomas from v1 [1]

Regards,

Phil.

[1]: https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg02451.html
[2]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg689168.html
[3]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg641796.html
[4]: https://lists.gnu.org/archive/html/qemu-devel/2019-08/msg05003.html
[5]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg746041.html
[6]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg777669.html

Based-on: <2021013316.232778-1-f4...@amsat.org>
  "target: Provide target-specific Kconfig"

Philippe Mathieu-Daudé (9):
  sysemu/tcg: Introduce tcg_builtin() helper
  exec: Restrict TCG specific headers
  target/arm: Restrict ARMv4 cpus to TCG accel
  target/arm: Restrict ARMv5 cpus to TCG accel
  target/arm: Restrict ARMv6 cpus to TCG accel
  target/arm: Restrict ARMv7 R-profile cpus to TCG accel
  target/arm: Restrict ARMv7 M-profile cpus to TCG accel
  target/arm: Reorder meson.build rules
  .travis.yml: Add a KVM-only Aarch64 job

Samuel Ortiz (1):
  target/arm: Do not build TCG objects when TCG is off

Thomas Huth (1):
  target/arm: Make m_helper.c optional via CONFIG_ARM_V7M

 default-configs/devices/aarch64-softmmu.mak |  1 -
 default-configs/devices/arm-softmmu.mak | 27 
 include/exec/helper-proto.h |  2 +
 include/sysemu/tcg.h|  2 +
 target/arm/cpu.h| 12 
 hw/arm/realview.c   |  7 +-
 target/arm/cpu_tcg.c|  4 +-
 target/arm/helper.c |  7 --
 target/arm/m_helper-stub.c  | 73 +
 tests/qtest/cdrom-test.c|  6 +-
 .travis.yml | 32 +
 hw/arm/Kconfig  | 38 +++
 target/arm/Kconfig  | 17 +
 target/arm/meson.build  | 28 +---
 14 files changed, 196 insertions(+), 60 deletions(-)
 create mode 100644 target/arm/m_helper-stub.c

-- 
2.26.2




Re: [PATCH 05/10] meson: Introduce target-specific Kconfig

2021-01-31 Thread Artyom Tarasenko
вс, 31 янв. 2021 г., 12:13 Philippe Mathieu-Daudé :

> Add a target-specific Kconfig.
>
> Target foo now has CONFIG_FOO defined.
>
> Two architecture have a particularity, ARM and MIPS:
> their 64-bit version include the 32-bit subset.
>
> Signed-off-by: Philippe Mathieu-Daudé 
>

For SPARC part:
Acked-by: Artyom Tarasenko 

---
> I suppose X86_64 should also select I386?
> No clue about PPC/RISCV.
> ---
>  meson.build   |  3 ++-
>  Kconfig   |  1 +
>  target/Kconfig| 23 +++
>  target/alpha/Kconfig  |  2 ++
>  target/arm/Kconfig|  6 ++
>  target/avr/Kconfig|  2 ++
>  target/cris/Kconfig   |  2 ++
>  target/hppa/Kconfig   |  2 ++
>  target/i386/Kconfig   |  5 +
>  target/lm32/Kconfig   |  2 ++
>  target/m68k/Kconfig   |  2 ++
>  target/microblaze/Kconfig |  2 ++
>  target/mips/Kconfig   |  6 ++
>  target/moxie/Kconfig  |  2 ++
>  target/nios2/Kconfig  |  2 ++
>  target/openrisc/Kconfig   |  2 ++
>  target/ppc/Kconfig|  5 +
>  target/riscv/Kconfig  |  5 +
>  target/rx/Kconfig |  2 ++
>  target/s390x/Kconfig  |  2 ++
>  target/sh4/Kconfig|  2 ++
>  target/sparc/Kconfig  |  5 +
>  target/tilegx/Kconfig |  2 ++
>  target/tricore/Kconfig|  2 ++
>  target/unicore32/Kconfig  |  2 ++
>  target/xtensa/Kconfig |  2 ++
>  26 files changed, 92 insertions(+), 1 deletion(-)
>  create mode 100644 target/Kconfig
>  create mode 100644 target/alpha/Kconfig
>  create mode 100644 target/arm/Kconfig
>  create mode 100644 target/avr/Kconfig
>  create mode 100644 target/cris/Kconfig
>  create mode 100644 target/hppa/Kconfig
>  create mode 100644 target/i386/Kconfig
>  create mode 100644 target/lm32/Kconfig
>  create mode 100644 target/m68k/Kconfig
>  create mode 100644 target/microblaze/Kconfig
>  create mode 100644 target/mips/Kconfig
>  create mode 100644 target/moxie/Kconfig
>  create mode 100644 target/nios2/Kconfig
>  create mode 100644 target/openrisc/Kconfig
>  create mode 100644 target/ppc/Kconfig
>  create mode 100644 target/riscv/Kconfig
>  create mode 100644 target/rx/Kconfig
>  create mode 100644 target/s390x/Kconfig
>  create mode 100644 target/sh4/Kconfig
>  create mode 100644 target/sparc/Kconfig
>  create mode 100644 target/tilegx/Kconfig
>  create mode 100644 target/tricore/Kconfig
>  create mode 100644 target/unicore32/Kconfig
>  create mode 100644 target/xtensa/Kconfig
>
> diff --git a/meson.build b/meson.build
> index f00b7754fd4..a2dda0ce95e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1322,7 +1322,8 @@
>command: [minikconf,
>  get_option('default_devices') ? '--defconfig' :
> '--allnoconfig',
>  config_devices_mak, '@DEPFILE@', '@INPUT@',
> -host_kconfig, accel_kconfig])
> +host_kconfig, accel_kconfig,
> +'CONFIG_' + config_target['TARGET_ARCH'].to_upper() +
> '=y'])
>
>  config_devices_data = configuration_data()
>  config_devices = keyval.load(config_devices_mak)
> diff --git a/Kconfig b/Kconfig
> index bf694c42afe..c01e261e4e9 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -1,4 +1,5 @@
>  source Kconfig.host
>  source backends/Kconfig
>  source accel/Kconfig
> +source target/Kconfig
>  source hw/Kconfig
> diff --git a/target/Kconfig b/target/Kconfig
> new file mode 100644
> index 000..a6f719f223a
> --- /dev/null
> +++ b/target/Kconfig
> @@ -0,0 +1,23 @@
> +source alpha/Kconfig
> +source arm/Kconfig
> +source avr/Kconfig
> +source cris/Kconfig
> +source hppa/Kconfig
> +source i386/Kconfig
> +source lm32/Kconfig
> +source m68k/Kconfig
> +source microblaze/Kconfig
> +source mips/Kconfig
> +source moxie/Kconfig
> +source nios2/Kconfig
> +source openrisc/Kconfig
> +source ppc/Kconfig
> +source riscv/Kconfig
> +source rx/Kconfig
> +source s390x/Kconfig
> +source sh4/Kconfig
> +source sparc/Kconfig
> +source tilegx/Kconfig
> +source tricore/Kconfig
> +source unicore32/Kconfig
> +source xtensa/Kconfig
> diff --git a/target/alpha/Kconfig b/target/alpha/Kconfig
> new file mode 100644
> index 000..267222c05b8
> --- /dev/null
> +++ b/target/alpha/Kconfig
> @@ -0,0 +1,2 @@
> +config ALPHA
> +bool
> diff --git a/target/arm/Kconfig b/target/arm/Kconfig
> new file mode 100644
> index 000..3f3394a22b2
> --- /dev/null
> +++ b/target/arm/Kconfig
> @@ -0,0 +1,6 @@
> +config ARM
> +bool
> +
> +config AARCH64
> +bool
> +select ARM
> diff --git a/target/avr/Kconfig b/target/avr/Kconfig
> new file mode 100644
> index 000..155592d3537
> --- /dev/null
> +++ b/target/avr/Kconfig
> @@ -0,0 +1,2 @@
> +config AVR
> +bool
> diff --git a/target/cris/Kconfig b/target/cris/Kconfig
> new file mode 100644
> index 000..3fdc309fbbd
> --- /dev/null
> +++ b/target/cris/Kconfig
> @@ -0,0 +1,2 @@
> +config CRIS
> +bool
> diff --git a/target/hppa/Kconfig b/target/hppa/Kconfig
> new file mode 100644
> inde

[PATCH 08/10] default-configs: Remove unnecessary SEMIHOSTING selection

2021-01-31 Thread Philippe Mathieu-Daudé
Commit 56b5170c87e ("semihosting: Move ARM semihosting code to
shared directories") selected ARM_COMPATIBLE_SEMIHOSTING which
already selects SEMIHOSTING. No need to select it again.

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/arm-softmmu.mak | 1 -
 default-configs/devices/riscv32-softmmu.mak | 1 -
 default-configs/devices/riscv64-softmmu.mak | 1 -
 3 files changed, 3 deletions(-)

diff --git a/default-configs/devices/arm-softmmu.mak 
b/default-configs/devices/arm-softmmu.mak
index 0500156a0c7..341d439de6f 100644
--- a/default-configs/devices/arm-softmmu.mak
+++ b/default-configs/devices/arm-softmmu.mak
@@ -41,6 +41,5 @@ CONFIG_MICROBIT=y
 CONFIG_FSL_IMX25=y
 CONFIG_FSL_IMX7=y
 CONFIG_FSL_IMX6UL=y
-CONFIG_SEMIHOSTING=y
 CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 CONFIG_ALLWINNER_H3=y
diff --git a/default-configs/devices/riscv32-softmmu.mak 
b/default-configs/devices/riscv32-softmmu.mak
index d847bd5692e..5c9ad2590ef 100644
--- a/default-configs/devices/riscv32-softmmu.mak
+++ b/default-configs/devices/riscv32-softmmu.mak
@@ -3,7 +3,6 @@
 # Uncomment the following lines to disable these optional devices:
 #
 #CONFIG_PCI_DEVICES=n
-CONFIG_SEMIHOSTING=y
 CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 
 # Boards:
diff --git a/default-configs/devices/riscv64-softmmu.mak 
b/default-configs/devices/riscv64-softmmu.mak
index d5eec75f05e..d5b2e25b6df 100644
--- a/default-configs/devices/riscv64-softmmu.mak
+++ b/default-configs/devices/riscv64-softmmu.mak
@@ -3,7 +3,6 @@
 # Uncomment the following lines to disable these optional devices:
 #
 #CONFIG_PCI_DEVICES=n
-CONFIG_SEMIHOSTING=y
 CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 
 # Boards:
-- 
2.26.2




[PATCH 07/10] target/arm: Move V7M feature to target Kconfig

2021-01-31 Thread Philippe Mathieu-Daudé
V7M is an architecture feature, move its declaration to target/arm/.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/arm/Kconfig | 4 
 target/arm/Kconfig | 4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 09298881f2f..f3ecb73a3d8 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -292,10 +292,6 @@ config ZYNQ
 select XILINX_SPIPS
 select ZYNQ_DEVCFG
 
-config ARM_V7M
-bool
-select PTIMER
-
 config ALLWINNER_A10
 bool
 select AHCI
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
index 3f3394a22b2..1f05de47ca6 100644
--- a/target/arm/Kconfig
+++ b/target/arm/Kconfig
@@ -4,3 +4,7 @@ config ARM
 config AARCH64
 bool
 select ARM
+
+config ARM_V7M
+bool
+select PTIMER
-- 
2.26.2




[PATCH 06/10] target/i386: Move SEV feature to target Kconfig

2021-01-31 Thread Philippe Mathieu-Daudé
SEV is an architecture feature, move its declaration to target/i386/.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/Kconfig | 4 
 target/i386/Kconfig | 4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 7f91f30877f..3d67c172dab 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -1,7 +1,3 @@
-config SEV
-bool
-depends on KVM
-
 config PC
 bool
 imply APPLESMC
diff --git a/target/i386/Kconfig b/target/i386/Kconfig
index ce6968906ee..27c76c554c7 100644
--- a/target/i386/Kconfig
+++ b/target/i386/Kconfig
@@ -3,3 +3,7 @@ config I386
 
 config X86_64
 bool
+
+config SEV
+bool
+depends on KVM && I386
-- 
2.26.2




[PATCH 10/10] target: Move SEMIHOSTING feature to target Kconfig

2021-01-31 Thread Philippe Mathieu-Daudé
SEMIHOSTING is an architecture feature, move its declaration to
each target/ARCH/.

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/lm32-softmmu.mak| 2 --
 default-configs/devices/m68k-softmmu.mak| 2 --
 default-configs/devices/mips-softmmu-common.mak | 3 ---
 default-configs/devices/nios2-softmmu.mak   | 2 --
 default-configs/devices/unicore32-softmmu.mak   | 1 -
 default-configs/devices/xtensa-softmmu.mak  | 2 --
 target/lm32/Kconfig | 1 +
 target/m68k/Kconfig | 1 +
 target/mips/Kconfig | 1 +
 target/nios2/Kconfig| 1 +
 target/unicore32/Kconfig| 1 +
 target/xtensa/Kconfig   | 1 +
 12 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/default-configs/devices/lm32-softmmu.mak 
b/default-configs/devices/lm32-softmmu.mak
index 1bce3f6e8b6..1f69795b749 100644
--- a/default-configs/devices/lm32-softmmu.mak
+++ b/default-configs/devices/lm32-softmmu.mak
@@ -4,8 +4,6 @@
 #
 #CONFIG_MILKYMIST_TMU2=n# disabling it actually causes compile-time 
failures
 
-CONFIG_SEMIHOSTING=y
-
 # Boards:
 #
 CONFIG_LM32_EVR=y
diff --git a/default-configs/devices/m68k-softmmu.mak 
b/default-configs/devices/m68k-softmmu.mak
index 6629fd2aa33..4fef4bd731d 100644
--- a/default-configs/devices/m68k-softmmu.mak
+++ b/default-configs/devices/m68k-softmmu.mak
@@ -1,7 +1,5 @@
 # Default configuration for m68k-softmmu
 
-CONFIG_SEMIHOSTING=y
-
 # Boards:
 #
 CONFIG_AN5206=y
diff --git a/default-configs/devices/mips-softmmu-common.mak 
b/default-configs/devices/mips-softmmu-common.mak
index ea78fe72759..af652ec7bdd 100644
--- a/default-configs/devices/mips-softmmu-common.mak
+++ b/default-configs/devices/mips-softmmu-common.mak
@@ -1,8 +1,5 @@
 # Common mips*-softmmu CONFIG defines
 
-# CONFIG_SEMIHOSTING is always required on this architecture
-CONFIG_SEMIHOSTING=y
-
 CONFIG_ISA_BUS=y
 CONFIG_PCI=y
 CONFIG_PCI_DEVICES=y
diff --git a/default-configs/devices/nios2-softmmu.mak 
b/default-configs/devices/nios2-softmmu.mak
index 1bc4082ea99..e130d024e62 100644
--- a/default-configs/devices/nios2-softmmu.mak
+++ b/default-configs/devices/nios2-softmmu.mak
@@ -1,7 +1,5 @@
 # Default configuration for nios2-softmmu
 
-CONFIG_SEMIHOSTING=y
-
 # Boards:
 #
 CONFIG_NIOS2_10M50=y
diff --git a/default-configs/devices/unicore32-softmmu.mak 
b/default-configs/devices/unicore32-softmmu.mak
index 899288e3d71..0bfce48c6da 100644
--- a/default-configs/devices/unicore32-softmmu.mak
+++ b/default-configs/devices/unicore32-softmmu.mak
@@ -3,4 +3,3 @@
 # Boards:
 #
 CONFIG_PUV3=y
-CONFIG_SEMIHOSTING=y
diff --git a/default-configs/devices/xtensa-softmmu.mak 
b/default-configs/devices/xtensa-softmmu.mak
index 4fe1bf00c94..49e4c9da88c 100644
--- a/default-configs/devices/xtensa-softmmu.mak
+++ b/default-configs/devices/xtensa-softmmu.mak
@@ -1,7 +1,5 @@
 # Default configuration for Xtensa
 
-CONFIG_SEMIHOSTING=y
-
 # Boards:
 #
 CONFIG_XTENSA_SIM=y
diff --git a/target/lm32/Kconfig b/target/lm32/Kconfig
index 09de5b703a3..286710fd47b 100644
--- a/target/lm32/Kconfig
+++ b/target/lm32/Kconfig
@@ -1,2 +1,3 @@
 config LM32
 bool
+select SEMIHOSTING
diff --git a/target/m68k/Kconfig b/target/m68k/Kconfig
index 23debad519a..9eae71486ff 100644
--- a/target/m68k/Kconfig
+++ b/target/m68k/Kconfig
@@ -1,2 +1,3 @@
 config M68K
 bool
+select SEMIHOSTING
diff --git a/target/mips/Kconfig b/target/mips/Kconfig
index 6adf1453548..eb19c94c7d4 100644
--- a/target/mips/Kconfig
+++ b/target/mips/Kconfig
@@ -1,5 +1,6 @@
 config MIPS
 bool
+select SEMIHOSTING
 
 config MIPS64
 bool
diff --git a/target/nios2/Kconfig b/target/nios2/Kconfig
index 1529ab8950d..c65550c861a 100644
--- a/target/nios2/Kconfig
+++ b/target/nios2/Kconfig
@@ -1,2 +1,3 @@
 config NIOS2
 bool
+select SEMIHOSTING
diff --git a/target/unicore32/Kconfig b/target/unicore32/Kconfig
index 62c9d10b38f..c699d5238ea 100644
--- a/target/unicore32/Kconfig
+++ b/target/unicore32/Kconfig
@@ -1,2 +1,3 @@
 config UNICORE32
 bool
+select SEMIHOSTING
diff --git a/target/xtensa/Kconfig b/target/xtensa/Kconfig
index a3c8dc7f6d7..5e46049262d 100644
--- a/target/xtensa/Kconfig
+++ b/target/xtensa/Kconfig
@@ -1,2 +1,3 @@
 config XTENSA
 bool
+select SEMIHOSTING
-- 
2.26.2




[PATCH 03/10] hw/sh4/Kconfig: Rename CONFIG_LM32 -> CONFIG_LM32_PERIPHERALS

2021-01-31 Thread Philippe Mathieu-Daudé
We want to be able to use the 'LM32' config for architecture
specific features. As CONFIG_LM32 is only used to select
peripherals, rename it CONFIG_LM32_PERIPHERALS.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/char/meson.build  | 4 ++--
 hw/intc/meson.build  | 2 +-
 hw/lm32/Kconfig  | 4 ++--
 hw/timer/meson.build | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/char/meson.build b/hw/char/meson.build
index 3b8cb6a2f5b..b05dcc41c59 100644
--- a/hw/char/meson.build
+++ b/hw/char/meson.build
@@ -8,8 +8,8 @@
 softmmu_ss.add(when: 'CONFIG_IPACK', if_true: files('ipoctal232.c'))
 softmmu_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('parallel-isa.c'))
 softmmu_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugcon.c'))
-softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_juart.c'))
-softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_uart.c'))
+softmmu_ss.add(when: 'CONFIG_LM32_PERIPHERALS', if_true: files('lm32_juart.c'))
+softmmu_ss.add(when: 'CONFIG_LM32_PERIPHERALS', if_true: files('lm32_uart.c'))
 softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-uart.c'))
 softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_uart.c'))
 softmmu_ss.add(when: 'CONFIG_PARALLEL', if_true: files('parallel.c'))
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
index b05bab2f4b6..bfaab908ac7 100644
--- a/hw/intc/meson.build
+++ b/hw/intc/meson.build
@@ -14,7 +14,7 @@
 softmmu_ss.add(when: 'CONFIG_I8259', if_true: files('i8259_common.c', 
'i8259.c'))
 softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_avic.c', 'imx_gpcv2.c'))
 softmmu_ss.add(when: 'CONFIG_IOAPIC', if_true: files('ioapic_common.c'))
-softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_pic.c'))
+softmmu_ss.add(when: 'CONFIG_LM32_PERIPHERALS', if_true: files('lm32_pic.c'))
 softmmu_ss.add(when: 'CONFIG_OPENPIC', if_true: files('openpic.c'))
 softmmu_ss.add(when: 'CONFIG_PL190', if_true: files('pl190.c'))
 softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_intc.c'))
diff --git a/hw/lm32/Kconfig b/hw/lm32/Kconfig
index 20c36edc402..5867f4db0cf 100644
--- a/hw/lm32/Kconfig
+++ b/hw/lm32/Kconfig
@@ -1,4 +1,4 @@
-config LM32
+config LM32_PERIPHERALS
 bool
 select PTIMER
 
@@ -14,5 +14,5 @@ config MILKYMIST
 
 config LM32_EVR
 bool
-select LM32
+select LM32_PERIPHERALS
 select PFLASH_CFI02
diff --git a/hw/timer/meson.build b/hw/timer/meson.build
index d3f53dce400..36ca0d34942 100644
--- a/hw/timer/meson.build
+++ b/hw/timer/meson.build
@@ -19,7 +19,7 @@
 softmmu_ss.add(when: 'CONFIG_I8254', if_true: files('i8254_common.c', 
'i8254.c'))
 softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_epit.c'))
 softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_gpt.c'))
-softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_timer.c'))
+softmmu_ss.add(when: 'CONFIG_LM32_PERIPHERALS', if_true: files('lm32_timer.c'))
 softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-sysctl.c'))
 softmmu_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_gictimer.c'))
 softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-timer.c'))
-- 
2.26.2




[PATCH 02/10] hw/lm32/Kconfig: Introduce CONFIG_LM32_EVR for lm32-evr/uclinux boards

2021-01-31 Thread Philippe Mathieu-Daudé
We want to be able to use the 'LM32' config for architecture
specific features. Introduce CONFIG_LM32_EVR to select the
lm32-evr / lm32-uclinux boards.

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/lm32-softmmu.mak | 2 +-
 hw/lm32/Kconfig  | 6 +-
 hw/lm32/meson.build  | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/default-configs/devices/lm32-softmmu.mak 
b/default-configs/devices/lm32-softmmu.mak
index 115b3e34c98..1bce3f6e8b6 100644
--- a/default-configs/devices/lm32-softmmu.mak
+++ b/default-configs/devices/lm32-softmmu.mak
@@ -8,5 +8,5 @@ CONFIG_SEMIHOSTING=y
 
 # Boards:
 #
-CONFIG_LM32=y
+CONFIG_LM32_EVR=y
 CONFIG_MILKYMIST=y
diff --git a/hw/lm32/Kconfig b/hw/lm32/Kconfig
index ed2e3060b04..20c36edc402 100644
--- a/hw/lm32/Kconfig
+++ b/hw/lm32/Kconfig
@@ -1,7 +1,6 @@
 config LM32
 bool
 select PTIMER
-select PFLASH_CFI02
 
 config MILKYMIST
 bool
@@ -12,3 +11,8 @@ config MILKYMIST
 select FRAMEBUFFER
 select SD
 select USB_OHCI
+
+config LM32_EVR
+bool
+select LM32
+select PFLASH_CFI02
diff --git a/hw/lm32/meson.build b/hw/lm32/meson.build
index 8caf0a727ff..42d6f8db3d9 100644
--- a/hw/lm32/meson.build
+++ b/hw/lm32/meson.build
@@ -1,6 +1,6 @@
 lm32_ss = ss.source_set()
 # LM32 boards
-lm32_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_boards.c'))
+lm32_ss.add(when: 'CONFIG_LM32_EVR', if_true: files('lm32_boards.c'))
 lm32_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist.c'))
 
 hw_arch += {'lm32': lm32_ss}
-- 
2.26.2




[PATCH 05/10] meson: Introduce target-specific Kconfig

2021-01-31 Thread Philippe Mathieu-Daudé
Add a target-specific Kconfig.

Target foo now has CONFIG_FOO defined.

Two architecture have a particularity, ARM and MIPS:
their 64-bit version include the 32-bit subset.

Signed-off-by: Philippe Mathieu-Daudé 
---
I suppose X86_64 should also select I386?
No clue about PPC/RISCV.
---
 meson.build   |  3 ++-
 Kconfig   |  1 +
 target/Kconfig| 23 +++
 target/alpha/Kconfig  |  2 ++
 target/arm/Kconfig|  6 ++
 target/avr/Kconfig|  2 ++
 target/cris/Kconfig   |  2 ++
 target/hppa/Kconfig   |  2 ++
 target/i386/Kconfig   |  5 +
 target/lm32/Kconfig   |  2 ++
 target/m68k/Kconfig   |  2 ++
 target/microblaze/Kconfig |  2 ++
 target/mips/Kconfig   |  6 ++
 target/moxie/Kconfig  |  2 ++
 target/nios2/Kconfig  |  2 ++
 target/openrisc/Kconfig   |  2 ++
 target/ppc/Kconfig|  5 +
 target/riscv/Kconfig  |  5 +
 target/rx/Kconfig |  2 ++
 target/s390x/Kconfig  |  2 ++
 target/sh4/Kconfig|  2 ++
 target/sparc/Kconfig  |  5 +
 target/tilegx/Kconfig |  2 ++
 target/tricore/Kconfig|  2 ++
 target/unicore32/Kconfig  |  2 ++
 target/xtensa/Kconfig |  2 ++
 26 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 target/Kconfig
 create mode 100644 target/alpha/Kconfig
 create mode 100644 target/arm/Kconfig
 create mode 100644 target/avr/Kconfig
 create mode 100644 target/cris/Kconfig
 create mode 100644 target/hppa/Kconfig
 create mode 100644 target/i386/Kconfig
 create mode 100644 target/lm32/Kconfig
 create mode 100644 target/m68k/Kconfig
 create mode 100644 target/microblaze/Kconfig
 create mode 100644 target/mips/Kconfig
 create mode 100644 target/moxie/Kconfig
 create mode 100644 target/nios2/Kconfig
 create mode 100644 target/openrisc/Kconfig
 create mode 100644 target/ppc/Kconfig
 create mode 100644 target/riscv/Kconfig
 create mode 100644 target/rx/Kconfig
 create mode 100644 target/s390x/Kconfig
 create mode 100644 target/sh4/Kconfig
 create mode 100644 target/sparc/Kconfig
 create mode 100644 target/tilegx/Kconfig
 create mode 100644 target/tricore/Kconfig
 create mode 100644 target/unicore32/Kconfig
 create mode 100644 target/xtensa/Kconfig

diff --git a/meson.build b/meson.build
index f00b7754fd4..a2dda0ce95e 100644
--- a/meson.build
+++ b/meson.build
@@ -1322,7 +1322,8 @@
   command: [minikconf,
 get_option('default_devices') ? '--defconfig' : 
'--allnoconfig',
 config_devices_mak, '@DEPFILE@', '@INPUT@',
-host_kconfig, accel_kconfig])
+host_kconfig, accel_kconfig,
+'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'])
 
 config_devices_data = configuration_data()
 config_devices = keyval.load(config_devices_mak)
diff --git a/Kconfig b/Kconfig
index bf694c42afe..c01e261e4e9 100644
--- a/Kconfig
+++ b/Kconfig
@@ -1,4 +1,5 @@
 source Kconfig.host
 source backends/Kconfig
 source accel/Kconfig
+source target/Kconfig
 source hw/Kconfig
diff --git a/target/Kconfig b/target/Kconfig
new file mode 100644
index 000..a6f719f223a
--- /dev/null
+++ b/target/Kconfig
@@ -0,0 +1,23 @@
+source alpha/Kconfig
+source arm/Kconfig
+source avr/Kconfig
+source cris/Kconfig
+source hppa/Kconfig
+source i386/Kconfig
+source lm32/Kconfig
+source m68k/Kconfig
+source microblaze/Kconfig
+source mips/Kconfig
+source moxie/Kconfig
+source nios2/Kconfig
+source openrisc/Kconfig
+source ppc/Kconfig
+source riscv/Kconfig
+source rx/Kconfig
+source s390x/Kconfig
+source sh4/Kconfig
+source sparc/Kconfig
+source tilegx/Kconfig
+source tricore/Kconfig
+source unicore32/Kconfig
+source xtensa/Kconfig
diff --git a/target/alpha/Kconfig b/target/alpha/Kconfig
new file mode 100644
index 000..267222c05b8
--- /dev/null
+++ b/target/alpha/Kconfig
@@ -0,0 +1,2 @@
+config ALPHA
+bool
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
new file mode 100644
index 000..3f3394a22b2
--- /dev/null
+++ b/target/arm/Kconfig
@@ -0,0 +1,6 @@
+config ARM
+bool
+
+config AARCH64
+bool
+select ARM
diff --git a/target/avr/Kconfig b/target/avr/Kconfig
new file mode 100644
index 000..155592d3537
--- /dev/null
+++ b/target/avr/Kconfig
@@ -0,0 +1,2 @@
+config AVR
+bool
diff --git a/target/cris/Kconfig b/target/cris/Kconfig
new file mode 100644
index 000..3fdc309fbbd
--- /dev/null
+++ b/target/cris/Kconfig
@@ -0,0 +1,2 @@
+config CRIS
+bool
diff --git a/target/hppa/Kconfig b/target/hppa/Kconfig
new file mode 100644
index 000..395a35d799c
--- /dev/null
+++ b/target/hppa/Kconfig
@@ -0,0 +1,2 @@
+config HPPA
+bool
diff --git a/target/i386/Kconfig b/target/i386/Kconfig
new file mode 100644
index 000..ce6968906ee
--- /dev/null
+++ b/target/i386/Kconfig
@@ -0,0 +1,5 @@
+config I386
+bool
+
+config X86_64
+bool
diff --git a/target/lm32/Kconfig b/target/lm32/Kconfig
new file mode 100644
index 000

[PATCH 04/10] hw/lm32/Kconfig: Have MILKYMIST select LM32_PERIPHERALS

2021-01-31 Thread Philippe Mathieu-Daudé
The Milkymist board requires more than the PTIMER. Directly
select the LM32_PERIPHERALS. This fixes:

  /usr/bin/ld:
  libqemu-lm32-softmmu.fa.p/target_lm32_gdbstub.c.o: in function 
`lm32_cpu_gdb_read_register':
  target/lm32/gdbstub.c:46: undefined reference to `lm32_pic_get_im'
  target/lm32/gdbstub.c:48: undefined reference to `lm32_pic_get_ip'
  libqemu-lm32-softmmu.fa.p/target_lm32_op_helper.c.o: in function 
`helper_wcsr_im':
  target/lm32/op_helper.c:107: undefined reference to `lm32_pic_set_im'
  libqemu-lm32-softmmu.fa.p/target_lm32_op_helper.c.o: in function 
`helper_wcsr_ip':
  target/lm32/op_helper.c:114: undefined reference to `lm32_pic_set_ip'
  libqemu-lm32-softmmu.fa.p/target_lm32_op_helper.c.o: in function 
`helper_wcsr_jtx':
  target/lm32/op_helper.c:120: undefined reference to `lm32_juart_set_jtx'
  libqemu-lm32-softmmu.fa.p/target_lm32_op_helper.c.o: in function 
`helper_wcsr_jrx':
  target/lm32/op_helper.c:125: undefined reference to `lm32_juart_set_jrx'
  libqemu-lm32-softmmu.fa.p/target_lm32_translate.c.o: in function 
`lm32_cpu_dump_state':
  target/lm32/translate.c:1161: undefined reference to `lm32_pic_get_ip'
  target/lm32/translate.c:1161: undefined reference to `lm32_pic_get_im'

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/lm32/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/lm32/Kconfig b/hw/lm32/Kconfig
index 5867f4db0cf..38ad22c54e4 100644
--- a/hw/lm32/Kconfig
+++ b/hw/lm32/Kconfig
@@ -6,11 +6,11 @@ config MILKYMIST
 bool
 # FIXME: disabling it results in compile-time errors
 select MILKYMIST_TMU2 if OPENGL && X11
-select PTIMER
 select PFLASH_CFI01
 select FRAMEBUFFER
 select SD
 select USB_OHCI
+select LM32_PERIPHERALS
 
 config LM32_EVR
 bool
-- 
2.26.2




[PATCH 09/10] target: Move ARM_COMPATIBLE_SEMIHOSTING feature to target Kconfig

2021-01-31 Thread Philippe Mathieu-Daudé
ARM_COMPATIBLE_SEMIHOSTING is an architecture feature, move its
declaration to each target/ARCH/.

Note, we do not modify the linux-user targets, as user-mode builds
don't use Kconfig.

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/devices/arm-softmmu.mak | 1 -
 default-configs/devices/riscv32-softmmu.mak | 1 -
 default-configs/devices/riscv64-softmmu.mak | 1 -
 target/arm/Kconfig  | 1 +
 target/riscv/Kconfig| 2 ++
 5 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/default-configs/devices/arm-softmmu.mak 
b/default-configs/devices/arm-softmmu.mak
index 341d439de6f..0824e9be795 100644
--- a/default-configs/devices/arm-softmmu.mak
+++ b/default-configs/devices/arm-softmmu.mak
@@ -41,5 +41,4 @@ CONFIG_MICROBIT=y
 CONFIG_FSL_IMX25=y
 CONFIG_FSL_IMX7=y
 CONFIG_FSL_IMX6UL=y
-CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 CONFIG_ALLWINNER_H3=y
diff --git a/default-configs/devices/riscv32-softmmu.mak 
b/default-configs/devices/riscv32-softmmu.mak
index 5c9ad2590ef..94a236c9c25 100644
--- a/default-configs/devices/riscv32-softmmu.mak
+++ b/default-configs/devices/riscv32-softmmu.mak
@@ -3,7 +3,6 @@
 # Uncomment the following lines to disable these optional devices:
 #
 #CONFIG_PCI_DEVICES=n
-CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 
 # Boards:
 #
diff --git a/default-configs/devices/riscv64-softmmu.mak 
b/default-configs/devices/riscv64-softmmu.mak
index d5b2e25b6df..76b61956489 100644
--- a/default-configs/devices/riscv64-softmmu.mak
+++ b/default-configs/devices/riscv64-softmmu.mak
@@ -3,7 +3,6 @@
 # Uncomment the following lines to disable these optional devices:
 #
 #CONFIG_PCI_DEVICES=n
-CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 
 # Boards:
 #
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
index 1f05de47ca6..ae89d05c7e5 100644
--- a/target/arm/Kconfig
+++ b/target/arm/Kconfig
@@ -1,5 +1,6 @@
 config ARM
 bool
+select ARM_COMPATIBLE_SEMIHOSTING
 
 config AARCH64
 bool
diff --git a/target/riscv/Kconfig b/target/riscv/Kconfig
index b9e5932f13f..c3b9d8a1cf1 100644
--- a/target/riscv/Kconfig
+++ b/target/riscv/Kconfig
@@ -1,5 +1,7 @@
 config RISCV32
 bool
+select ARM_COMPATIBLE_SEMIHOSTING
 
 config RISCV64
 bool
+select ARM_COMPATIBLE_SEMIHOSTING
-- 
2.26.2




[PATCH 01/10] hw/sh4/Kconfig: Rename CONFIG_SH4 -> CONFIG_SH4_PERIPHERALS

2021-01-31 Thread Philippe Mathieu-Daudé
We want to be able to use the 'SH4' config for architecture
specific features. As CONFIG_SH4 is only used to select
peripherals, rename it CONFIG_SH4_PERIPHERALS.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/block/meson.build | 2 +-
 hw/char/meson.build  | 2 +-
 hw/intc/meson.build  | 2 +-
 hw/sh4/Kconfig   | 6 +++---
 hw/timer/meson.build | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/block/meson.build b/hw/block/meson.build
index 602ca6c8541..7f24b42c283 100644
--- a/hw/block/meson.build
+++ b/hw/block/meson.build
@@ -12,7 +12,7 @@
 softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80.c'))
 softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c'))
 softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
-softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('tc58128.c'))
+softmmu_ss.add(when: 'CONFIG_SH4_PERIPHERALS', if_true: files('tc58128.c'))
 softmmu_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('nvme.c', 'nvme-ns.c'))
 
 specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
diff --git a/hw/char/meson.build b/hw/char/meson.build
index 196ac91fa29..3b8cb6a2f5b 100644
--- a/hw/char/meson.build
+++ b/hw/char/meson.build
@@ -31,7 +31,7 @@
 softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_aux.c'))
 softmmu_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
 softmmu_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c'))
-softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('sh_serial.c'))
+softmmu_ss.add(when: 'CONFIG_SH4_PERIPHERALS', if_true: files('sh_serial.c'))
 softmmu_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: 
files('stm32f2xx_usart.c'))
 softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: 
files('mchp_pfsoc_mmuart.c'))
 
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
index 53cba115690..b05bab2f4b6 100644
--- a/hw/intc/meson.build
+++ b/hw/intc/meson.build
@@ -47,7 +47,7 @@
 specific_ss.add(when: 'CONFIG_RX_ICU', if_true: files('rx_icu.c'))
 specific_ss.add(when: 'CONFIG_S390_FLIC', if_true: files('s390_flic.c'))
 specific_ss.add(when: 'CONFIG_S390_FLIC_KVM', if_true: 
files('s390_flic_kvm.c'))
-specific_ss.add(when: 'CONFIG_SH4', if_true: files('sh_intc.c'))
+specific_ss.add(when: 'CONFIG_SH4_PERIPHERALS', if_true: files('sh_intc.c'))
 specific_ss.add(when: 'CONFIG_SIFIVE_CLINT', if_true: files('sifive_clint.c'))
 specific_ss.add(when: 'CONFIG_SIFIVE_PLIC', if_true: files('sifive_plic.c'))
 specific_ss.add(when: 'CONFIG_XICS', if_true: files('xics.c'))
diff --git a/hw/sh4/Kconfig b/hw/sh4/Kconfig
index 4cbce3a0ed5..fbac8c09152 100644
--- a/hw/sh4/Kconfig
+++ b/hw/sh4/Kconfig
@@ -9,16 +9,16 @@ config R2D
 select USB_OHCI_PCI
 select PCI
 select SM501
-select SH4
+select SH4_PERIPHERALS
 
 config SHIX
 bool
 select SH7750
-select SH4
+select SH4_PERIPHERALS
 
 config SH7750
 bool
 
-config SH4
+config SH4_PERIPHERALS
 bool
 select PTIMER
diff --git a/hw/timer/meson.build b/hw/timer/meson.build
index be343f68fed..d3f53dce400 100644
--- a/hw/timer/meson.build
+++ b/hw/timer/meson.build
@@ -30,7 +30,7 @@
 softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_ost.c'))
 softmmu_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_timer.c'))
 softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_systmr.c'))
-softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('sh_timer.c'))
+softmmu_ss.add(when: 'CONFIG_SH4_PERIPHERALS', if_true: files('sh_timer.c'))
 softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_timer.c'))
 softmmu_ss.add(when: 'CONFIG_STM32F2XX_TIMER', if_true: 
files('stm32f2xx_timer.c'))
 softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_timer.c'))
-- 
2.26.2




[PATCH 00/10] target: Provide target-specific Kconfig

2021-01-31 Thread Philippe Mathieu-Daudé
Hi,

This series add a Kconfig file to each target, allowing
to select target-specific features there, instead of from
the hardware Kconfig.

This simplifies managing multi-arch features such semihosting.

Series organization:

1/ Some targets use the architecture symbol to select boards and
peripherals (SH4 and LM32), we need to clean that first.

2/ Introduce empty target Kconfig, update meson.

3/ Move architectural features out of hardware:
   - x86 SEV
   - ARM v7m
   - generic semihosting

[following only important to patchew, unrelated to this series]
Based-on: <20210131105918.228787-1-f4...@amsat.org>

Philippe Mathieu-Daudé (10):
  hw/sh4/Kconfig: Rename CONFIG_SH4 -> CONFIG_SH4_PERIPHERALS
  hw/lm32/Kconfig: Introduce CONFIG_LM32_EVR for lm32-evr/uclinux boards
  hw/sh4/Kconfig: Rename CONFIG_LM32 -> CONFIG_LM32_PERIPHERALS
  hw/lm32/Kconfig: Have MILKYMIST select LM32_PERIPHERALS
  meson: Introduce target-specific Kconfig
  target/i386: Move SEV feature to target Kconfig
  target/arm: Move V7M feature to target Kconfig
  default-configs: Remove unnecessary SEMIHOSTING selection
  target: Move ARM_COMPATIBLE_SEMIHOSTING feature to target Kconfig
  target: Move SEMIHOSTING feature to target Kconfig

 default-configs/devices/arm-softmmu.mak   |  2 --
 default-configs/devices/lm32-softmmu.mak  |  4 +---
 default-configs/devices/m68k-softmmu.mak  |  2 --
 .../devices/mips-softmmu-common.mak   |  3 ---
 default-configs/devices/nios2-softmmu.mak |  2 --
 default-configs/devices/riscv32-softmmu.mak   |  2 --
 default-configs/devices/riscv64-softmmu.mak   |  2 --
 default-configs/devices/unicore32-softmmu.mak |  1 -
 default-configs/devices/xtensa-softmmu.mak|  2 --
 meson.build   |  3 ++-
 Kconfig   |  1 +
 hw/arm/Kconfig|  4 
 hw/block/meson.build  |  2 +-
 hw/char/meson.build   |  6 ++---
 hw/i386/Kconfig   |  4 
 hw/intc/meson.build   |  4 ++--
 hw/lm32/Kconfig   | 10 +---
 hw/lm32/meson.build   |  2 +-
 hw/sh4/Kconfig|  6 ++---
 hw/timer/meson.build  |  4 ++--
 target/Kconfig| 23 +++
 target/alpha/Kconfig  |  2 ++
 target/arm/Kconfig| 11 +
 target/avr/Kconfig|  2 ++
 target/cris/Kconfig   |  2 ++
 target/hppa/Kconfig   |  2 ++
 target/i386/Kconfig   |  9 
 target/lm32/Kconfig   |  3 +++
 target/m68k/Kconfig   |  3 +++
 target/microblaze/Kconfig |  2 ++
 target/mips/Kconfig   |  7 ++
 target/moxie/Kconfig  |  2 ++
 target/nios2/Kconfig  |  3 +++
 target/openrisc/Kconfig   |  2 ++
 target/ppc/Kconfig|  5 
 target/riscv/Kconfig  |  7 ++
 target/rx/Kconfig |  2 ++
 target/s390x/Kconfig  |  2 ++
 target/sh4/Kconfig|  2 ++
 target/sparc/Kconfig  |  5 
 target/tilegx/Kconfig |  2 ++
 target/tricore/Kconfig|  2 ++
 target/unicore32/Kconfig  |  3 +++
 target/xtensa/Kconfig |  3 +++
 44 files changed, 129 insertions(+), 43 deletions(-)
 create mode 100644 target/Kconfig
 create mode 100644 target/alpha/Kconfig
 create mode 100644 target/arm/Kconfig
 create mode 100644 target/avr/Kconfig
 create mode 100644 target/cris/Kconfig
 create mode 100644 target/hppa/Kconfig
 create mode 100644 target/i386/Kconfig
 create mode 100644 target/lm32/Kconfig
 create mode 100644 target/m68k/Kconfig
 create mode 100644 target/microblaze/Kconfig
 create mode 100644 target/mips/Kconfig
 create mode 100644 target/moxie/Kconfig
 create mode 100644 target/nios2/Kconfig
 create mode 100644 target/openrisc/Kconfig
 create mode 100644 target/ppc/Kconfig
 create mode 100644 target/riscv/Kconfig
 create mode 100644 target/rx/Kconfig
 create mode 100644 target/s390x/Kconfig
 create mode 100644 target/sh4/Kconfig
 create mode 100644 target/sparc/Kconfig
 create mode 100644 target/tilegx/Kconfig
 create mode 100644 target/tricore/Kconfig
 create mode 100644 target/unicore32/Kconfig
 create mode 100644 target/xtensa/Kconfig

-- 
2.26.2