Message ID | 20190921150420.30743-4-thuth@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Make it possible to compile with CONFIG_ARM_V7M=n | expand |
On Sat, 21 Sep 2019 at 16:04, Thomas Huth <thuth@redhat.com> wrote: > > qemu-system-arm/-aarch64 currently can't be built without setting the > switch CONFIG_ARM_V7M=y - which we currently always do in the config file > default-configs/arm-softmmu.mak. This is because the code in target/arm/ > calls many functions from this armv7m_nvic.c, and thus linking fails > without this file. > > So armv7m_nvic.c should not be under the CONFIG_ARM_V7M switch, but always > compiled for arm builds. Since we can not simply do this in hw/intc/ (with > "obj-y += ..." it would get compiled for all other architectures, too), > let's move the file to hw/arm/ instead and always enable it there. > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > hw/arm/Makefile.objs | 2 ++ > hw/{intc => arm}/armv7m_nvic.c | 0 > hw/arm/trace-events | 17 +++++++++++++++++ > hw/intc/Makefile.objs | 1 - > hw/intc/trace-events | 17 ----------------- > 5 files changed, 19 insertions(+), 18 deletions(-) > rename hw/{intc => arm}/armv7m_nvic.c (100%) Please don't move this file. This is an interrupt controller (with some other functionality jammed into it) and so it should be in hw/intc. It's true that it's rather tightly-coupled to the CPU, but the same is true for our GICv3 model. thanks -- PMM
On 23/09/2019 16.52, Peter Maydell wrote: > On Sat, 21 Sep 2019 at 16:04, Thomas Huth <thuth@redhat.com> wrote: >> >> qemu-system-arm/-aarch64 currently can't be built without setting the >> switch CONFIG_ARM_V7M=y - which we currently always do in the config file >> default-configs/arm-softmmu.mak. This is because the code in target/arm/ >> calls many functions from this armv7m_nvic.c, and thus linking fails >> without this file. >> >> So armv7m_nvic.c should not be under the CONFIG_ARM_V7M switch, but always >> compiled for arm builds. Since we can not simply do this in hw/intc/ (with >> "obj-y += ..." it would get compiled for all other architectures, too), >> let's move the file to hw/arm/ instead and always enable it there. >> >> Signed-off-by: Thomas Huth <thuth@redhat.com> >> --- >> hw/arm/Makefile.objs | 2 ++ >> hw/{intc => arm}/armv7m_nvic.c | 0 >> hw/arm/trace-events | 17 +++++++++++++++++ >> hw/intc/Makefile.objs | 1 - >> hw/intc/trace-events | 17 ----------------- >> 5 files changed, 19 insertions(+), 18 deletions(-) >> rename hw/{intc => arm}/armv7m_nvic.c (100%) > > Please don't move this file. This is an interrupt > controller (with some other functionality jammed into it) > and so it should be in hw/intc. It's true that it's rather > tightly-coupled to the CPU, but the same is true for our > GICv3 model. Ok, then what would you suggest to solve the problem that this file has always to be linked into the binary? I can't use "obj-y += ..." in hw/intc/Makefile.objs since that would mean that the file also gets compiled for non-Arm boards. Would you prefer a bunch of stubs instead that get used if CONFIG_ARM_V7M is not set? Thomas
On Mon, 23 Sep 2019 at 18:54, Thomas Huth <thuth@redhat.com> wrote: > Ok, then what would you suggest to solve the problem that this file has > always to be linked into the binary? I can't use "obj-y += ..." in > hw/intc/Makefile.objs since that would mean that the file also gets > compiled for non-Arm boards. Would you prefer a bunch of stubs instead > that get used if CONFIG_ARM_V7M is not set? I thought obj-y was for only-this-target and obj-common-y was for all-boards ? thanks -- PMM
On 23/09/2019 20.27, Peter Maydell wrote: > On Mon, 23 Sep 2019 at 18:54, Thomas Huth <thuth@redhat.com> wrote: >> Ok, then what would you suggest to solve the problem that this file has >> always to be linked into the binary? I can't use "obj-y += ..." in >> hw/intc/Makefile.objs since that would mean that the file also gets >> compiled for non-Arm boards. Would you prefer a bunch of stubs instead >> that get used if CONFIG_ARM_V7M is not set? > > I thought obj-y was for only-this-target and obj-common-y was > for all-boards ? Well, obj-y is for the current target that gets compiled. But if you use it in a Makefile that gets used by all targets, the file gets compiled for each target individually. Just try to change "obj-$(CONFIG_ARM_V7M) += armv7m_nvic.o" into "obj-y += armv7m_nvic.o" in hw/int/Makefile.objs, and you'll see it break: CC alpha-softmmu/hw/intc/armv7m_nvic.o In file included from include/hw/intc/armv7m_nvic.h:13, from hw/intc/armv7m_nvic.c:19: target/arm/cpu.h:1416: error: "FPCR_DZE" redefined [-Werror] #define FPCR_DZE (1 << 9) /* Divide by Zero exception trap enable */ Thomas
On Mon, 23 Sep 2019 at 19:36, Thomas Huth <thuth@redhat.com> wrote: > > On 23/09/2019 20.27, Peter Maydell wrote: > > On Mon, 23 Sep 2019 at 18:54, Thomas Huth <thuth@redhat.com> wrote: > >> Ok, then what would you suggest to solve the problem that this file has > >> always to be linked into the binary? I can't use "obj-y += ..." in > >> hw/intc/Makefile.objs since that would mean that the file also gets > >> compiled for non-Arm boards. Would you prefer a bunch of stubs instead > >> that get used if CONFIG_ARM_V7M is not set? > > > > I thought obj-y was for only-this-target and obj-common-y was > > for all-boards ? > > Well, obj-y is for the current target that gets compiled. But if you use > it in a Makefile that gets used by all targets, the file gets compiled > for each target individually. > > Just try to change "obj-$(CONFIG_ARM_V7M) += armv7m_nvic.o" into > "obj-y += armv7m_nvic.o" in hw/int/Makefile.objs, and you'll see it break: > > CC alpha-softmmu/hw/intc/armv7m_nvic.o > In file included from include/hw/intc/armv7m_nvic.h:13, > from hw/intc/armv7m_nvic.c:19: > target/arm/cpu.h:1416: error: "FPCR_DZE" redefined [-Werror] > #define FPCR_DZE (1 << 9) /* Divide by Zero exception trap enable */ Sure, so don't define CONFIG_ARM_V7M in a default-config for a non-Arm architecture. Then you get the behaviour you want: the file is compiled only for the arm targets. This is exactly the same as for the GICv3's arm_gicv3_cpuif.c, which is also protected by a CONFIG_ flag that's only set by the Arm default-configs, because it needs to be compiled as a target-specific file for arm and only arm. thanks -- PMM
On 23/09/2019 20.50, Peter Maydell wrote: > On Mon, 23 Sep 2019 at 19:36, Thomas Huth <thuth@redhat.com> wrote: >> >> On 23/09/2019 20.27, Peter Maydell wrote: >>> On Mon, 23 Sep 2019 at 18:54, Thomas Huth <thuth@redhat.com> wrote: >>>> Ok, then what would you suggest to solve the problem that this file has >>>> always to be linked into the binary? I can't use "obj-y += ..." in >>>> hw/intc/Makefile.objs since that would mean that the file also gets >>>> compiled for non-Arm boards. Would you prefer a bunch of stubs instead >>>> that get used if CONFIG_ARM_V7M is not set? >>> >>> I thought obj-y was for only-this-target and obj-common-y was >>> for all-boards ? >> >> Well, obj-y is for the current target that gets compiled. But if you use >> it in a Makefile that gets used by all targets, the file gets compiled >> for each target individually. >> >> Just try to change "obj-$(CONFIG_ARM_V7M) += armv7m_nvic.o" into >> "obj-y += armv7m_nvic.o" in hw/int/Makefile.objs, and you'll see it break: >> >> CC alpha-softmmu/hw/intc/armv7m_nvic.o >> In file included from include/hw/intc/armv7m_nvic.h:13, >> from hw/intc/armv7m_nvic.c:19: >> target/arm/cpu.h:1416: error: "FPCR_DZE" redefined [-Werror] >> #define FPCR_DZE (1 << 9) /* Divide by Zero exception trap enable */ > > Sure, so don't define CONFIG_ARM_V7M in a default-config for > a non-Arm architecture. Then you get the behaviour you want: > the file is compiled only for the arm targets. Sigh, the point of this series is that it should also possible to compile *without* CONFIG_ARM_V7M in default-configs if you want (and yes, there are people out there who want to be able to compile a minimalistic QEMU). It's currently not possible to disable this switch. But ok, if you're not really interested in providing a possibility to make qemu-system-arm a little bit more flexible in this regard, never mind, I'll look into other issues instead. Thomas
On Tue, 24 Sep 2019 at 05:44, Thomas Huth <thuth@redhat.com> wrote: > > On 23/09/2019 20.50, Peter Maydell wrote: > > On Mon, 23 Sep 2019 at 19:36, Thomas Huth <thuth@redhat.com> wrote: > >> Just try to change "obj-$(CONFIG_ARM_V7M) += armv7m_nvic.o" into > >> "obj-y += armv7m_nvic.o" in hw/int/Makefile.objs, and you'll see it break: > >> > >> CC alpha-softmmu/hw/intc/armv7m_nvic.o > >> In file included from include/hw/intc/armv7m_nvic.h:13, > >> from hw/intc/armv7m_nvic.c:19: > >> target/arm/cpu.h:1416: error: "FPCR_DZE" redefined [-Werror] > >> #define FPCR_DZE (1 << 9) /* Divide by Zero exception trap enable */ > > > > Sure, so don't define CONFIG_ARM_V7M in a default-config for > > a non-Arm architecture. Then you get the behaviour you want: > > the file is compiled only for the arm targets. > > Sigh, the point of this series is that it should also possible to > compile *without* CONFIG_ARM_V7M in default-configs if you want (and > yes, there are people out there who want to be able to compile a > minimalistic QEMU). It's currently not possible to disable this switch. > But ok, if you're not really interested in providing a possibility to > make qemu-system-arm a little bit more flexible in this regard, never > mind, I'll look into other issues instead. No, I'm happy that we should be able to compile without CONFIG_ARM_V7M selected. I'm just confused about why you think this requires that we move this file out of hw/intc. Case 1: arm target, CONFIG_ARM_V7M=y (presumably in a Kconfig world this is set by default if the user doesn't flip that switch): obj-$(CONFIG_ARM_V7M) expands to obj-y, file compiled, OK Case 2: arm target, CONFIG_ARM_V7M=n set by user via Kconfig: obj-$(CONFIG_ARM_V7M) expands to obj-n, file not compiled, which is also what we want Case 3: not an arm target, CONFIG_ARM_V7M will be either 'n' (or empty?) and is not settable by user: expands to obj-n again, which is also what we want Is there some Kconfig restriction I'm not aware of that messes things up? thanks -- PMM
On 24/09/2019 11.42, Peter Maydell wrote: > On Tue, 24 Sep 2019 at 05:44, Thomas Huth <thuth@redhat.com> wrote: >> >> On 23/09/2019 20.50, Peter Maydell wrote: >>> On Mon, 23 Sep 2019 at 19:36, Thomas Huth <thuth@redhat.com> wrote: >>>> Just try to change "obj-$(CONFIG_ARM_V7M) += armv7m_nvic.o" into >>>> "obj-y += armv7m_nvic.o" in hw/int/Makefile.objs, and you'll see it break: >>>> >>>> CC alpha-softmmu/hw/intc/armv7m_nvic.o >>>> In file included from include/hw/intc/armv7m_nvic.h:13, >>>> from hw/intc/armv7m_nvic.c:19: >>>> target/arm/cpu.h:1416: error: "FPCR_DZE" redefined [-Werror] >>>> #define FPCR_DZE (1 << 9) /* Divide by Zero exception trap enable */ >>> >>> Sure, so don't define CONFIG_ARM_V7M in a default-config for >>> a non-Arm architecture. Then you get the behaviour you want: >>> the file is compiled only for the arm targets. >> >> Sigh, the point of this series is that it should also possible to >> compile *without* CONFIG_ARM_V7M in default-configs if you want (and >> yes, there are people out there who want to be able to compile a >> minimalistic QEMU). It's currently not possible to disable this switch. >> But ok, if you're not really interested in providing a possibility to >> make qemu-system-arm a little bit more flexible in this regard, never >> mind, I'll look into other issues instead. > > No, I'm happy that we should be able to compile without CONFIG_ARM_V7M > selected. I'm just confused about why you think this requires that > we move this file out of hw/intc. > > Case 1: arm target, CONFIG_ARM_V7M=y (presumably in a Kconfig world > this is set by default if the user doesn't flip that switch): > obj-$(CONFIG_ARM_V7M) expands to obj-y, file compiled, OK > Case 2: arm target, CONFIG_ARM_V7M=n set by user via Kconfig: > obj-$(CONFIG_ARM_V7M) expands to obj-n, file not compiled, which is > also what we want The problem is this "case 2" - it does not work. For example, try to delete everything from default-configs/aarch64-softmmu.mak (especially the "include"), and just stick a "CONFIG_ARM_VIRT=y" in there. Linking of qemu-system-aarch64 will fail with lots of "undefined reference to `armv7m_nvic_set_pending'" etc. messages. Thomas
On 9/24/19 11:48 AM, Thomas Huth wrote: > On 24/09/2019 11.42, Peter Maydell wrote: >> On Tue, 24 Sep 2019 at 05:44, Thomas Huth <thuth@redhat.com> wrote: >>> >>> On 23/09/2019 20.50, Peter Maydell wrote: >>>> On Mon, 23 Sep 2019 at 19:36, Thomas Huth <thuth@redhat.com> wrote: >>>>> Just try to change "obj-$(CONFIG_ARM_V7M) += armv7m_nvic.o" into >>>>> "obj-y += armv7m_nvic.o" in hw/int/Makefile.objs, and you'll see it break: >>>>> >>>>> CC alpha-softmmu/hw/intc/armv7m_nvic.o >>>>> In file included from include/hw/intc/armv7m_nvic.h:13, >>>>> from hw/intc/armv7m_nvic.c:19: >>>>> target/arm/cpu.h:1416: error: "FPCR_DZE" redefined [-Werror] >>>>> #define FPCR_DZE (1 << 9) /* Divide by Zero exception trap enable */ >>>> >>>> Sure, so don't define CONFIG_ARM_V7M in a default-config for >>>> a non-Arm architecture. Then you get the behaviour you want: >>>> the file is compiled only for the arm targets. >>> >>> Sigh, the point of this series is that it should also possible to >>> compile *without* CONFIG_ARM_V7M in default-configs if you want (and >>> yes, there are people out there who want to be able to compile a >>> minimalistic QEMU). It's currently not possible to disable this switch. >>> But ok, if you're not really interested in providing a possibility to >>> make qemu-system-arm a little bit more flexible in this regard, never >>> mind, I'll look into other issues instead. >> >> No, I'm happy that we should be able to compile without CONFIG_ARM_V7M >> selected. I'm just confused about why you think this requires that >> we move this file out of hw/intc. >> >> Case 1: arm target, CONFIG_ARM_V7M=y (presumably in a Kconfig world >> this is set by default if the user doesn't flip that switch): >> obj-$(CONFIG_ARM_V7M) expands to obj-y, file compiled, OK >> Case 2: arm target, CONFIG_ARM_V7M=n set by user via Kconfig: >> obj-$(CONFIG_ARM_V7M) expands to obj-n, file not compiled, which is >> also what we want > The problem is this "case 2" - it does not work. For example, try to > delete everything from default-configs/aarch64-softmmu.mak (especially > the "include"), and just stick a "CONFIG_ARM_VIRT=y" in there. > Linking of qemu-system-aarch64 will fail with lots of "undefined > reference to `armv7m_nvic_set_pending'" etc. messages. This is what I tried to fix with this patch: "target/arm: Do not build A/M-profile cpus when using KVM" https://lists.gnu.org/archive/html/qemu-devel/2019-08/msg05006.html I addressed Richard/your's review comments, so the series is ready for respin.
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs index 43ce8d5b19..3c94d383a0 100644 --- a/hw/arm/Makefile.objs +++ b/hw/arm/Makefile.objs @@ -27,6 +27,8 @@ obj-$(CONFIG_VEXPRESS) += vexpress.o obj-$(CONFIG_ZYNQ) += xilinx_zynq.o obj-$(CONFIG_SABRELITE) += sabrelite.o +# Note: armv7m_nvic.o is currently always required for linking +obj-y += armv7m_nvic.o obj-$(CONFIG_ARM_V7M) += armv7m.o obj-$(CONFIG_EXYNOS4) += exynos4210.o obj-$(CONFIG_PXA2XX) += pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o diff --git a/hw/intc/armv7m_nvic.c b/hw/arm/armv7m_nvic.c similarity index 100% rename from hw/intc/armv7m_nvic.c rename to hw/arm/armv7m_nvic.c diff --git a/hw/arm/trace-events b/hw/arm/trace-events index 0acedcedc6..3068202a4c 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -1,5 +1,22 @@ # See docs/devel/tracing.txt for syntax documentation. +# armv7m_nvic.c +nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d" +nvic_recompute_state_secure(int vectpending, bool vectpending_is_s_banked, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d is_s_banked %d vectpending_prio %d exception_prio %d" +nvic_set_prio(int irq, bool secure, uint8_t prio) "NVIC set irq %d secure-bank %d priority %d" +nvic_irq_update(int vectpending, int pendprio, int exception_prio, int level) "NVIC vectpending %d pending prio %d exception_prio %d: setting irq line to %d" +nvic_escalate_prio(int irq, int irqprio, int runprio) "NVIC escalating irq %d to HardFault: insufficient priority %d >= %d" +nvic_escalate_disabled(int irq) "NVIC escalating irq %d to HardFault: disabled" +nvic_set_pending(int irq, bool secure, bool targets_secure, bool derived, int en, int prio) "NVIC set pending irq %d secure-bank %d targets_secure %d derived %d (enabled: %d priority %d)" +nvic_clear_pending(int irq, bool secure, int en, int prio) "NVIC clear pending irq %d secure-bank %d (enabled: %d priority %d)" +nvic_acknowledge_irq(int irq, int prio) "NVIC acknowledge IRQ: %d now active (prio %d)" +nvic_get_pending_irq_info(int irq, bool secure) "NVIC next IRQ %d: targets_secure: %d" +nvic_complete_irq(int irq, bool secure) "NVIC complete IRQ %d (secure %d)" +nvic_set_irq_level(int irq, int level) "NVIC external irq %d level set to %d" +nvic_set_nmi_level(int level) "NVIC external NMI level set to %d" +nvic_sysreg_read(uint64_t addr, uint32_t value, unsigned size) "NVIC sysreg read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" +nvic_sysreg_write(uint64_t addr, uint32_t value, unsigned size) "NVIC sysreg write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" + # virt-acpi-build.c virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out." diff --git a/hw/intc/Makefile.objs b/hw/intc/Makefile.objs index f726d87532..2d981abb4e 100644 --- a/hw/intc/Makefile.objs +++ b/hw/intc/Makefile.objs @@ -26,7 +26,6 @@ obj-$(CONFIG_APIC) += apic.o apic_common.o obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_kvm.o obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_its_kvm.o -obj-$(CONFIG_ARM_V7M) += armv7m_nvic.o obj-$(CONFIG_EXYNOS4) += exynos4210_gic.o exynos4210_combiner.o obj-$(CONFIG_GRLIB) += grlib_irqmp.o obj-$(CONFIG_IOAPIC) += ioapic.o diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 90c9d07c1a..09a7fedee8 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -179,23 +179,6 @@ gicv3_redist_badwrite(uint32_t cpu, uint64_t offset, uint64_t data, unsigned siz gicv3_redist_set_irq(uint32_t cpu, int irq, int level) "GICv3 redistributor 0x%x interrupt %d level changed to %d" gicv3_redist_send_sgi(uint32_t cpu, int irq) "GICv3 redistributor 0x%x pending SGI %d" -# armv7m_nvic.c -nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d" -nvic_recompute_state_secure(int vectpending, bool vectpending_is_s_banked, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d is_s_banked %d vectpending_prio %d exception_prio %d" -nvic_set_prio(int irq, bool secure, uint8_t prio) "NVIC set irq %d secure-bank %d priority %d" -nvic_irq_update(int vectpending, int pendprio, int exception_prio, int level) "NVIC vectpending %d pending prio %d exception_prio %d: setting irq line to %d" -nvic_escalate_prio(int irq, int irqprio, int runprio) "NVIC escalating irq %d to HardFault: insufficient priority %d >= %d" -nvic_escalate_disabled(int irq) "NVIC escalating irq %d to HardFault: disabled" -nvic_set_pending(int irq, bool secure, bool targets_secure, bool derived, int en, int prio) "NVIC set pending irq %d secure-bank %d targets_secure %d derived %d (enabled: %d priority %d)" -nvic_clear_pending(int irq, bool secure, int en, int prio) "NVIC clear pending irq %d secure-bank %d (enabled: %d priority %d)" -nvic_acknowledge_irq(int irq, int prio) "NVIC acknowledge IRQ: %d now active (prio %d)" -nvic_get_pending_irq_info(int irq, bool secure) "NVIC next IRQ %d: targets_secure: %d" -nvic_complete_irq(int irq, bool secure) "NVIC complete IRQ %d (secure %d)" -nvic_set_irq_level(int irq, int level) "NVIC external irq %d level set to %d" -nvic_set_nmi_level(int level) "NVIC external NMI level set to %d" -nvic_sysreg_read(uint64_t addr, uint32_t value, unsigned size) "NVIC sysreg read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" -nvic_sysreg_write(uint64_t addr, uint32_t value, unsigned size) "NVIC sysreg write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" - # heathrow_pic.c heathrow_write(uint64_t addr, unsigned int n, uint64_t value) "0x%"PRIx64" %u: 0x%"PRIx64 heathrow_read(uint64_t addr, unsigned int n, uint64_t value) "0x%"PRIx64" %u: 0x%"PRIx64
qemu-system-arm/-aarch64 currently can't be built without setting the switch CONFIG_ARM_V7M=y - which we currently always do in the config file default-configs/arm-softmmu.mak. This is because the code in target/arm/ calls many functions from this armv7m_nvic.c, and thus linking fails without this file. So armv7m_nvic.c should not be under the CONFIG_ARM_V7M switch, but always compiled for arm builds. Since we can not simply do this in hw/intc/ (with "obj-y += ..." it would get compiled for all other architectures, too), let's move the file to hw/arm/ instead and always enable it there. Signed-off-by: Thomas Huth <thuth@redhat.com> --- hw/arm/Makefile.objs | 2 ++ hw/{intc => arm}/armv7m_nvic.c | 0 hw/arm/trace-events | 17 +++++++++++++++++ hw/intc/Makefile.objs | 1 - hw/intc/trace-events | 17 ----------------- 5 files changed, 19 insertions(+), 18 deletions(-) rename hw/{intc => arm}/armv7m_nvic.c (100%)