Poison some more target-specific defines
v2 cover Poison some more target-specific defines
This series marks some more #defines as poisoned, which are target-specific (declared in config-target.h) and thus must not be used in common code.
v2:
- First two patches are the same as in v1
- Reworked the CONFIG_KVM patches according to Paolo's review feedback
- Added two new patches to finally poison CONFIG_SOFTMMU, too
- Added a final patch to move bootdevice.o to common-obj now (based on an earlier patch where I also tried to move numa.o and balloon.o, too - but these files are indirectly target-dependent as I now know, so they can't be moved)
Thomas Huth (7):
include/exec/poison: Add missing TARGET defines include/exec/poison: Mark some CONFIG defines as poisoned, too Move CONFIG_KVM related definitions to kvm_i386.h include/exec/poison: Mark CONFIG_KVM as poisoned, too
cpu: Introduce a wrapper for tlb_flush() that can be used in common
code
include/exec/poison: Mark CONFIG_SOFTMMU as poisoned
Makefile: Move bootdevice.o to common-obj-y
Makefile.objs | 2 +- Makefile.target | 2 +- bootdevice.c | 2 +- hw/acpi/ich9.c | 1 - hw/i386/pc_q35.c | 1 + include/exec/cpu-common.h | 2 ++ include/exec/poison.h | 33 +++++++++++++++++++++++++++++++++ include/hw/i386/pc.h | 13 ------------- include/qom/cpu.h | 8 ++++++++ include/sysemu/kvm.h | 31 ++++++++++++------------------- qom/cpu.c | 5 ++--- target/i386/kvm_i386.h | 23 +++++++++++++++++++++++ translate-all.c | 8 ++++++++ 13 files changed, 92 insertions(+), 39 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/7 include/exec/poison: Add missing TARGET defines
Since we've got some new CPU targets in QEMU during the last months and years, we've got some new TARGET_xxx defines now which should be marked as poisoned for common code.
--- include/exec/poison.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/exec/poison.h +11 -0
@@ -12,17 +12,28 @@#pragma GCC poison TARGET_CRIS#pragma GCC poison TARGET_LM32#pragma GCC poison TARGET_M68K +#pragma GCC poison TARGET_MICROBLAZE#pragma GCC poison TARGET_MIPS +#pragma GCC poison TARGET_ABI_MIPSO32#pragma GCC poison TARGET_MIPS64 +#pragma GCC poison TARGET_ABI_MIPSN64 +#pragma GCC poison TARGET_MOXIE +#pragma GCC poison TARGET_NIOS2#pragma GCC poison TARGET_OPENRISC#pragma GCC poison TARGET_PPC#pragma GCC poison TARGET_PPCEMB#pragma GCC poison TARGET_PPC64#pragma GCC poison TARGET_ABI32 +#pragma GCC poison TARGET_S390X#pragma GCC poison TARGET_SH4#pragma GCC poison TARGET_SPARC#pragma GCC poison TARGET_SPARC64 +#pragma GCC poison TARGET_TRICORE +#pragma GCC poison TARGET_UNICORE32 +#pragma GCC poison TARGET_XTENSA +#pragma GCC poison TARGET_NAME +#pragma GCC poison TARGET_SUPPORTS_MTTCG#pragma GCC poison TARGET_WORDS_BIGENDIAN#pragma GCC poison BSWAP_NEEDED
Signature · 1 line
1.8.3.1
PATCH v2 2/7 include/exec/poison: Mark some CONFIG defines as poisoned, too
In reply to Thomas HuthThese are defined in config-target.h and thus should never be used in common code.
--- include/exec/poison.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/exec/poison.h +20 -0
@@ -61,5 +61,25 @@#pragma GCC poison CPU_INTERRUPT_TGT_INT_1#pragma GCC poison CPU_INTERRUPT_TGT_INT_2 +#pragma GCC poison CONFIG_ALPHA_DIS +#pragma GCC poison CONFIG_ARM_A64_DIS +#pragma GCC poison CONFIG_ARM_DIS +#pragma GCC poison CONFIG_CRIS_DIS +#pragma GCC poison CONFIG_I386_DIS +#pragma GCC poison CONFIG_LM32_DIS +#pragma GCC poison CONFIG_M68K_DIS +#pragma GCC poison CONFIG_MICROBLAZE_DIS +#pragma GCC poison CONFIG_MIPS_DIS +#pragma GCC poison CONFIG_MOXIE_DIS +#pragma GCC poison CONFIG_NIOS2_DIS +#pragma GCC poison CONFIG_PPC_DIS +#pragma GCC poison CONFIG_S390_DIS +#pragma GCC poison CONFIG_SH4_DIS +#pragma GCC poison CONFIG_SPARC_DIS +#pragma GCC poison CONFIG_XTENSA_DIS + +#pragma GCC poison CONFIG_LINUX_USER +#pragma GCC poison CONFIG_VHOST_NET +#endif #endif
Signature · 1 line
1.8.3.1
PATCH v2 3/7 Move CONFIG_KVM related definitions to kvm_i386.h
In reply to Thomas Huthpc.h and sysemu/kvm.h are also included from common code (where CONFIG_KVM is not available), so the #defines that depend on CONFIG_KVM should not be declared here to avoid that anybody is using them in a wrong way. Since we're also going to poison CONFIG_KVM for common code, let's move them to kvm_i386.h instead. Most of the dummy definitions from sysemu/kvm.h are also unused since the code that uses them is only compiled for CONFIG_KVM (e.g. target/i386/kvm.c), so the unused defines are also simply dropped here instead of being moved.
--- hw/i386/pc_q35.c | 1 + include/hw/i386/pc.h | 13 ------------- include/sysemu/kvm.h | 15 --------------- target/i386/kvm_i386.h | 23 +++++++++++++++++++++++ 4 files changed, 24 insertions(+), 28 deletions(-)
hw/i386/pc_q35.c +1 -0
@@ -36,6 +36,7 @@#include "hw/timer/mc146818rtc.h" #include "hw/xen/xen.h" #include "sysemu/kvm.h" +#include "kvm_i386.h" #include "hw/kvm/clock.h" #include "hw/pci-host/q35.h" #include "exec/address-spaces.h"
include/hw/i386/pc.h +0 -13
@@ -20,19 +20,6 @@#define HPET_INTCAP "hpet-intcap" -#ifdef CONFIG_KVM -#define kvm_pit_in_kernel () \ - (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split()) -#define kvm_pic_in_kernel () \ - (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split()) -#define kvm_ioapic_in_kernel () \ - (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split()) -#else -#define kvm_pit_in_kernel () 0 -#define kvm_pic_in_kernel () 0 -#define kvm_ioapic_in_kernel () 0 -#endif -/** * PCMachineState: * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling
include/sysemu/kvm.h +0 -15
@@ -22,21 +22,6 @@#ifdef CONFIG_KVM #include <linux/kvm.h> #include <linux/kvm_para.h> -#else -/* These constants must never be used at runtime if kvm_enabled() is false. -* They exist so we don't need #ifdefs around KVM-specific code that already -* checks kvm_enabled() properly. -*/ -#define KVM_CPUID_SIGNATURE 0 -#define KVM_CPUID_FEATURES 0 -#define KVM_FEATURE_CLOCKSOURCE 0 -#define KVM_FEATURE_NOP_IO_DELAY 0 -#define KVM_FEATURE_MMU_OP 0 -#define KVM_FEATURE_CLOCKSOURCE2 0 -#define KVM_FEATURE_ASYNC_PF 0 -#define KVM_FEATURE_STEAL_TIME 0 -#define KVM_FEATURE_PV_EOI 0 -#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 0#endif extern bool kvm_allowed;
target/i386/kvm_i386.h +23 -0
@@ -15,6 +15,29 @@#define kvm_apic_in_kernel () (kvm_irqchip_in_kernel()) +#ifdef CONFIG_KVM + +#define kvm_pit_in_kernel () \ + (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split()) +#define kvm_pic_in_kernel () \ + (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split()) +#define kvm_ioapic_in_kernel () \ + (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split()) + +#else + +#define kvm_pit_in_kernel () 0 +#define kvm_pic_in_kernel () 0 +#define kvm_ioapic_in_kernel () 0 + +/* These constants must never be used at runtime if kvm_enabled() is false. +* They exist so we don't need #ifdefs around KVM-specific code that already +* checks kvm_enabled() properly. +*/ +#define KVM_CPUID_FEATURES 0 + +#endif /* CONFIG_KVM */ +bool kvm_allows_irq0_override (void );bool kvm_has_smm (void );bool kvm_has_adjust_clock_stable (void );
Signature · 1 line
1.8.3.1
PATCH v2 4/7 include/exec/poison: Mark CONFIG_KVM as poisoned, too
In reply to Thomas HuthCONFIG_KVM is only defined for target-specific code, so nobody should use it by accident in common code. To avoid such subtle bugs, CONFIG_KVM is now marked as poisoned in common code. The header include/sysemu/kvm.h is somewhat special since it is included all over the place from common code, too, so we need some extra logic via "#ifdef NEED_CPU_H" here to make sure that we can compile all files without problems.
--- hw/acpi/ich9.c | 1 - include/exec/poison.h | 1 + include/sysemu/kvm.h | 18 +++++++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-)
hw/acpi/ich9.c +0 -1
@@ -33,7 +33,6 @@#include "sysemu/sysemu.h" #include "hw/acpi/acpi.h" #include "hw/acpi/tco.h" -#include "sysemu/kvm.h" #include "exec/address-spaces.h" #include "hw/i386/ich9.h"
include/exec/poison.h +1 -0
@@ -80,6 +80,7 @@#pragma GCC poison CONFIG_LINUX_USER#pragma GCC poison CONFIG_VHOST_NET +#pragma GCC poison CONFIG_KVM#endif #endif
include/sysemu/kvm.h +13 -5
@@ -19,11 +19,18 @@#include "exec/memattrs.h" #include "hw/irq.h" -#ifdef CONFIG_KVM -#include <linux/kvm.h> -#include <linux/kvm_para.h> +#ifdef NEED_CPU_H +# ifdef CONFIG_KVM +# include <linux/kvm.h> +# include <linux/kvm_para.h> +# define CONFIG_KVM_IS_POSSIBLE +# endif +#else +# define CONFIG_KVM_IS_POSSIBLE #endif +#ifdef CONFIG_KVM_IS_POSSIBLE +extern bool kvm_allowed;extern bool kvm_kernel_irqchip;extern bool kvm_split_irqchip;
@@ -40,7 +47,6 @@ extern bool kvm_direct_msi_allowed;extern bool kvm_ioeventfd_any_length_allowed;extern bool kvm_msi_use_devid; -#if definedCONFIG_KVM || !definedNEED_CPU_H #define kvm_enabled () (kvm_allowed)/** * kvm_irqchip_in_kernel:
@@ -163,6 +169,7 @@ extern bool kvm_msi_use_devid;#define kvm_msi_devid_required () (kvm_msi_use_devid)#else +#define kvm_enabled () (0)#define kvm_irqchip_in_kernel () (false)#define kvm_irqchip_is_split () (false)
@@ -178,7 +185,8 @@ extern bool kvm_msi_use_devid;#define kvm_direct_msi_enabled () (false)#define kvm_ioeventfd_any_length_enabled () (false)#define kvm_msi_devid_required () (false) -#endif + +#endif /* CONFIG_KVM_IS_POSSIBLE */ struct kvm_run ;struct kvm_lapic_state ;
Signature · 1 line
1.8.3.1
PATCH v2 5/7 cpu: Introduce a wrapper for tlb_flush() that can be used in common code
In reply to Thomas HuthCommit 1f5c00cfdb8114c ("qom/cpu: move tlb_flush to cpu_common_reset") moved the call to tlb_flush() from the target-specific reset handlers into the common code qom/cpu.c file, and protected the call with "#ifdef CONFIG_SOFTMMU" to avoid that it is called for linux-user only targets. But since qom/cpu.c is common code, CONFIG_SOFTMMU is *never* defined here, so the tlb_flush() was simply never executed anymore. Fix it by introducing a wrapper for tlb_flush() in a file that is re-compiled for each target, i.e. in translate-all.c.
--- include/exec/cpu-common.h | 2 ++ qom/cpu.c | 5 ++--- translate-all.c | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-)
include/exec/cpu-common.h +2 -0
@@ -28,6 +28,8 @@ void qemu_init_cpu_list(void);void cpu_list_lock (void );void cpu_list_unlock (void ); +void tcg_flush_softmmu_tlb (CPUState *cs); +#if !defined(CONFIG_USER_ONLY ) enum device_endian {
qom/cpu.c +2 -3
@@ -26,6 +26,7 @@#include "qemu/notify.h" #include "qemu/log.h" #include "exec/log.h" +#include "exec/cpu-common.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "hw/qdev-properties.h"
@@ -296,9 +297,7 @@ static void cpu_common_reset(CPUState *cpu)atomic_set (&cpu->tb_jmp_cache[i],NULL ); } -#ifdef CONFIG_SOFTMMU -tlb_flush (cpu,0 ); -#endif +tcg_flush_softmmu_tlb (cpu); } }
translate-all.c +8 -0
@@ -2219,3 +2219,11 @@ int page_unprotect(target_ulong address, uintptr_t pc) return 0; }#endif /* CONFIG_USER_ONLY */ + +/* This is a wrapper for common code that can not use CONFIG_SOFTMMU */ +void tcg_flush_softmmu_tlb (CPUState *cs) +{ +#ifdef CONFIG_SOFTMMU +tlb_flush (cs); +#endif +}
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 5/7] cpu: Introduce a wrapper for tlb_flush() that can be used in common code
Quoted 59 lines · Thomas Huth
Commit
1f5c00cfdb8114c("qom/cpu: movetlb_flushtocpu_common_reset") moved the call totlb_flush()from the target-specific reset handlers into the common codeqom/cpu.cfile, and protected the call with "#ifdefCONFIG_SOFTMMU" to avoid that it is called for linux-user only targets. But sinceqom/cpu.cis common code,CONFIG_SOFTMMUis *never* defined here, so thetlb_flush()was simply never executed anymore. Fix it by introducing a wrapper fortlb_flush()in a file that is re-compiled for each target, i.e. intranslate-all.c.Fixes 1f5c00cfdb8114c1e3a13426588ceb64f82c9ddbSigned-off-by Thomas Huth <[email protected]>--- include/exec/cpu-common.h | 2 ++ qom/cpu.c | 5 ++--- translate-all.c | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-)include/exec/cpu-common.h +2
-0@@ -28,6 +28,8 @@ void qemu_init_cpu_list(void);void cpu_list_lock (void );void cpu_list_unlock (void ); +void tcg_flush_softmmu_tlb (CPUState *cs); +#if !defined(CONFIG_USER_ONLY ) enum device_endian {qom/cpu.c +2
-3@@ -26,6 +26,7 @@#include "qemu/notify.h" #include "qemu/log.h" #include "exec/log.h" +#include "exec/cpu-common.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "hw/qdev-properties.h" @@ -296,9 +297,7 @@ static void cpu_common_reset(CPUState *cpu)atomic_set (&cpu->tb_jmp_cache[i],NULL ); } -#ifdef CONFIG_SOFTMMU -tlb_flush (cpu,0 ); -#endif +tcg_flush_softmmu_tlb (cpu); } }translate-all.c +0
-0@@ -2219,3 +2219,11 @@ int page_unprotect(target_ulong address, uintptr_t pc)return 0 ;
translate-all.c int page_unprotect(target_ulong address, uintptr_t pc) · line 2229
Quoted 10 lines
translate-all.c +8
-0}#endif /* CONFIG_USER_ONLY */ + +/* This is a wrapper for common code that can not use CONFIG_SOFTMMU */ +void tcg_flush_softmmu_tlb (CPUState *cs) +{ +#ifdef CONFIG_SOFTMMU +tlb_flush (cs); +#endif +}
Don't you usually have a empty inline for the stub in the headers so the non-SoftMMU build can optimize away rather than link to an empty function?
--
Alex Bennée
Re: [Qemu-devel] [PATCH 5/7] cpu: Introduce a wrapper for tlb_flush() that can be used in common code
Quoted 67 lines · Alex Bennée
Quoted 64 lines · Thomas Huth
Commit
1f5c00cfdb8114c("qom/cpu: movetlb_flushtocpu_common_reset") moved the call totlb_flush()from the target-specific reset handlers into the common codeqom/cpu.cfile, and protected the call with "#ifdefCONFIG_SOFTMMU" to avoid that it is called for linux-user only targets. But sinceqom/cpu.cis common code,CONFIG_SOFTMMUis *never* defined here, so thetlb_flush()was simply never executed anymore. Fix it by introducing a wrapper fortlb_flush()in a file that is re-compiled for each target, i.e. intranslate-all.c.Fixes 1f5c00cfdb8114c1e3a13426588ceb64f82c9ddbSigned-off-by Thomas Huth <[email protected]>--- include/exec/cpu-common.h | 2 ++ qom/cpu.c | 5 ++--- translate-all.c | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-)include/exec/cpu-common.h +2
-0@@ -28,6 +28,8 @@ void qemu_init_cpu_list(void);void cpu_list_lock (void );void cpu_list_unlock (void ); +void tcg_flush_softmmu_tlb (CPUState *cs); +#if !defined(CONFIG_USER_ONLY ) enum device_endian {qom/cpu.c +2
-3@@ -26,6 +26,7 @@#include "qemu/notify.h" #include "qemu/log.h" #include "exec/log.h" +#include "exec/cpu-common.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "hw/qdev-properties.h" @@ -296,9 +297,7 @@ static void cpu_common_reset(CPUState *cpu)atomic_set (&cpu->tb_jmp_cache[i],NULL ); } -#ifdef CONFIG_SOFTMMU -tlb_flush (cpu,0 ); -#endif +tcg_flush_softmmu_tlb (cpu); } }translate-all.c +3
-0@@ -2219,3 +2219,11 @@ int page_unprotect(target_ulong address, uintptr_t pc) return 0; }#endif /* CONFIG_USER_ONLY */ + +/* This is a wrapper for common code that can not use CONFIG_SOFTMMU */ +void tcg_flush_softmmu_tlb (CPUState *cs)
Quoted 8 lines
translate-all.c int page_unprotect(target_ulong address, uintptr_t pc) · line 2229
Quoted 5 lines
translate-all.c +5
-0+{ +#ifdef CONFIG_SOFTMMU +tlb_flush (cs); +#endif +}Don't you usually have a empty inline for the stub in the headers so the non-SoftMMU build can optimize away rather than link to an empty function?
Optimizing reset doesn't seem worthwhile. :)
Paolo
PATCH v2 6/7 include/exec/poison: Mark CONFIG_SOFTMMU as poisoned
In reply to Thomas HuthCONFIG_SOFTMMU should never be used in common code, so mark it as poisoned, too.
--- include/exec/poison.h | 1 + include/qom/cpu.h | 8 ++++++++ 2 files changed, 9 insertions(+)
include/exec/poison.h +1 -0
@@ -81,6 +81,7 @@#pragma GCC poison CONFIG_LINUX_USER#pragma GCC poison CONFIG_VHOST_NET#pragma GCC poison CONFIG_KVM +#pragma GCC poison CONFIG_SOFTMMU#endif #endif
include/qom/cpu.h +8 -0
@@ -783,6 +783,8 @@ bool cpu_throttle_active(void);*/ int cpu_throttle_get_percentage (void ); +#ifdef NEED_CPU_H +#ifndef CONFIG_USER_ONLY typedef void (*CPUInterruptHandler )(CPUState *,int );
@@ -829,6 +831,8 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, }#endif +#endif /* NEED_CPU_H */ +/** * cpu_set_pc: * @cpu: The CPU to set the program counter for.
@@ -1005,6 +1009,8 @@ void cpu_exec_initfn(CPUState *cpu);void cpu_exec_realizefn (CPUState *cpu,Error **errp);void cpu_exec_unrealizefn (CPUState *cpu); +#ifdef NEED_CPU_H +#ifdef CONFIG_SOFTMMU extern const struct VMStateDescription vmstate_cpu_common;#else
@@ -1019,6 +1025,8 @@ extern const struct VMStateDescription vmstate_cpu_common; .offset = 0, \ } +#endif /* NEED_CPU_H */ +#define UNASSIGNED_CPU_INDEX -1#endif
Signature · 1 line
1.8.3.1
PATCH v2 7/7 Makefile: Move bootdevice.o to common-obj-y
In reply to Thomas HuthThere does not seem to be any target specific code in this file, so we can put it into "common-obj" instead of "obj" to compile it only once for all targets.
--- Makefile.objs | 2 +- Makefile.target | 2 +- bootdevice.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Makefile.objs +1 -1
@@ -40,7 +40,7 @@ io-obj-y = io/ ifeq ($(CONFIG_SOFTMMU),y) common-obj-y = blockdev.o blockdev-nbd.o block/ -common-obj-y += iothread.o +common-obj-y += bootdevice.o iothread.o common-obj-y += net/ common-obj-y += qdev-monitor.o device-hotplug.o common-obj-$(CONFIG_WIN32) += os-win32.o
Makefile.target +1 -1
@@ -140,7 +140,7 @@ endif #CONFIG_BSD_USER # System emulator target ifdef CONFIG_SOFTMMU obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o -obj-y += qtest.o bootdevice.o +obj-y += qtest.o obj-y += hw/ obj-$(CONFIG_KVM) += kvm-all.o obj-y += memory.o cputlb.o
bootdevice.c +1 -1
@@ -27,7 +27,7 @@#include "sysemu/sysemu.h" #include "qapi/visitor.h" #include "qemu/error-report.h" -#include "hw/hw.h" +#include "sysemu/reset.h" #include "hw/qdev-core.h" typedef struct FWBootEntry FWBootEntry ;
Signature · 1 line
1.8.3.1
Quoted 4 lines · Thomas Huth
This series marks some more #defines as poisoned, which are target-specific (declared in
config-target.h) and thus must not be used in common code.
Quoted 8 lines
v2:
- First two patches are the same as in v1
- Reworked theCONFIG_KVMpatches according to Paolo's review feedback
- Added two new patches to finally poisonCONFIG_SOFTMMU, too
- Added a final patch to move bootdevice.o to common-obj now (based on an earlier patch where I also tried to move numa.o and balloon.o, too - but these files are indirectly target-dependent as I now know, so they can't be moved)
Why do you say they can't be moved? They can, and your series should change nothing about it, thanks to what you're doing now with CONFIG_KVM_IS_POSSIBLE (which was also done before with NEED_CPU_H).
If it compiles, it's perfect. :) (Almost---your patches 5-6 show it's not entirely true, but poisoning helps).
Paolo
Quoted 25 lines
Thomas Huth (7):
include/exec/poison: Add missing TARGET definesinclude/exec/poison: Mark some CONFIG defines as poisoned, too MoveCONFIG_KVMrelated definitions tokvm_i386.hinclude/exec/poison: MarkCONFIG_KVMas poisoned, too
cpu: Introduce a wrapper fortlb_flush()that can be used in common
code
include/exec/poison: MarkCONFIG_SOFTMMUas poisoned
Makefile: Move bootdevice.o to common-obj-yMakefile.objs | 2 +- Makefile.target | 2 +- bootdevice.c | 2 +- hw/acpi/ich9.c | 1 - hw/i386/pc_q35.c | 1 + include/exec/cpu-common.h | 2 ++ include/exec/poison.h | 33 +++++++++++++++++++++++++++++++++ include/hw/i386/pc.h | 13 ------------- include/qom/cpu.h | 8 ++++++++ include/sysemu/kvm.h | 31 ++++++++++++------------------- qom/cpu.c | 5 ++--- target/i386/kvm_i386.h | 23 +++++++++++++++++++++++ translate-all.c | 8 ++++++++ 13 files changed, 92 insertions(+), 39 deletions(-)
Quoted 14 lines · Paolo Bonzini
Quoted 4 lines · Thomas Huth
This series marks some more #defines as poisoned, which are target-specific (declared in
config-target.h) and thus must not be used in common code.Quoted 8 lines
v2:
- First two patches are the same as in v1
- Reworked theCONFIG_KVMpatches according to Paolo's review feedback
- Added two new patches to finally poisonCONFIG_SOFTMMU, too
- Added a final patch to move bootdevice.o to common-obj now (based on an earlier patch where I also tried to move numa.o and balloon.o, too - but these files are indirectly target-dependent as I now know, so they can't be moved)
Quoted 3 lines
Why do you say they can't be moved? They can, and your series should change nothing about it, thanks to what you're doing now with
CONFIG_KVM_IS_POSSIBLE(which was also done before withNEED_CPU_H).
numa.c and balloon.c both use ram_addr_t (numa.c uses it directly, and balloon.c indirectly via the QEMUBalloonEvent typedef from the header). And ram_addr_t is currently target-specific - it depends on CONFIG_XEN_BACKEND. So this could break in certain subtle cases, e.g. when compiling on a 32-bit host with XEN enabled.
Thomas
Quoted 8 lines · Thomas Huth
Quoted 3 lines
Why do you say they can't be moved? They can, and your series should change nothing about it, thanks to what you're doing now with
CONFIG_KVM_IS_POSSIBLE(which was also done before withNEED_CPU_H).
numa.candballoon.cboth useram_addr_t(numa.cuses it directly, andballoon.cindirectly via the QEMUBalloonEvent typedef from the header). Andram_addr_tis currently target-specific - it depends onCONFIG_XEN_BACKEND. So this could break in certain subtle cases, e.g. when compiling on a 32-bit host with XEN enabled.
Can ram_addr_t be poisoned on target-independent files?
Paolo
Quoted 6 lines · Paolo Bonzini
Quoted 3 lines · Thomas Huth
Quoted 3 lines
Why do you say they can't be moved? They can, and your series should change nothing about it, thanks to what you're doing now with
CONFIG_KVM_IS_POSSIBLE(which was also done before withNEED_CPU_H).
Quoted 7 lines
Quoted 5 lines
numa.candballoon.cboth useram_addr_t(numa.cuses it directly, andballoon.cindirectly via the QEMUBalloonEvent typedef from the header). Andram_addr_tis currently target-specific - it depends onCONFIG_XEN_BACKEND. So this could break in certain subtle cases, e.g. when compiling on a 32-bit host with XEN enabled.Can
ram_addr_tbe poisoned on target-independent files?
This is quite similar to trying to poison CONFIG_USER_ONLY ... every common file that depends on include/exec/memory.h or /include/exec/cpu-common.h then does not compile anymore - and as far as I can see, this can't be fixed with some trivial "#ifdef NEED_CPU_H"s in most cases anymore.
Since you've asked on IRC for a list of files which do not compile anymore in this case, here we go (some of them are also quite easy to fix, I think, but some need some bigger reworks, I guess):
stubs/xen-common.ostubs/xen-hvm.ostubs/qmp_pc_dimm_device_list.ostubs/pc_madt_cpu_entry.o
device-hotplug.o
qdev-monitor.o
accel.o
dma-helpers.o
device_tree.o
qmp.o
cpus-common.o
hmp.o
vl.oaudio/audio.oaudio/wavcapture.obackends/hostmem-ram.obackends/hostmem.obackends/hostmem-file.obackends/cryptodev.obackends/cryptodev-builtin.ohw/9pfs/9p.ohw/acpi/core.ohw/acpi/pcihp.ohw/acpi/piix4.ohw/acpi/ich9.ohw/acpi/cpu_hotplug.ohw/acpi/memory_hotplug.ohw/acpi/tco.ohw/acpi/cpu.ohw/acpi/nvdimm.ohw/acpi/acpi_interface.ohw/acpi/vmgenid.ohw/acpi/aml-build.ohw/acpi/ipmi.ohw/audio/sb16.ohw/acpi/acpi-stub.ohw/audio/es1370.ohw/audio/ac97.ohw/audio/adlib.ohw/audio/gus.ohw/audio/cs4231a.ohw/audio/pcspk.ohw/audio/hda-codec.ohw/audio/intel-hda.ohw/audio/wm8750.ohw/audio/lm4549.ohw/audio/pl041.ohw/audio/cs4231.ohw/audio/marvell_88w8618.ohw/audio/milkymist-ac97.ohw/block/cdrom.ohw/audio/soundhw.ohw/block/fdc.ohw/block/m25p80.ohw/block/nand.ohw/block/pflash_cfi01.ohw/block/pflash_cfi02.ohw/block/ecc.ohw/block/onenand.ohw/block/nvme.ohw/char/ipoctal232.ohw/bt/hci.ohw/char/parallel.ohw/char/pl011.ohw/char/serial.ohw/char/escc.ohw/char/serial-isa.ohw/char/serial-pci.ohw/char/xilinx_uartlite.ohw/char/virtio-console.ohw/char/etraxfs_ser.ohw/char/cadence_uart.ohw/char/debugcon.ohw/char/grlib_apbuart.ohw/char/imx_serial.ohw/char/lm32_juart.ohw/char/lm32_uart.ohw/char/milkymist-uart.ohw/char/sclpconsole.ohw/char/sclpconsole-lm.ohw/core/qdev-properties.ohw/core/qdev.ohw/core/bus.ohw/core/empty_slot.ohw/core/ptimer.ohw/core/sysbus.ohw/core/machine.ohw/core/loader.ohw/core/loader-fit.ohw/core/qdev-properties-system.ohw/core/register.ohw/core/or-irq.ohw/core/platform-bus.ohw/cpu/core.ohw/display/ads7846.ohw/display/g364fb.ohw/display/jazz_led.ohw/display/cirrus_vga.ohw/display/ssd0303.ohw/display/ssd0323.ohw/display/pl110.ohw/display/vga-pci.ohw/display/vga-isa.ohw/display/vga-isa-mm.ohw/display/vmware_vga.ohw/display/exynos4210_fimd.ohw/display/framebuffer.ohw/display/milkymist-vgafb.ohw/dma/puv3_dma.ohw/display/tc6393xb.ohw/display/milkymist-tmu2.ohw/dma/rc4030.ohw/dma/pl080.ohw/dma/i82374.ohw/dma/i8257.ohw/dma/pl330.ohw/dma/xilinx_axidma.ohw/dma/xlnx-zynq-devcfg.ohw/dma/etraxfs_dma.ohw/dma/sparc32_dma.ohw/dma/sun4m_iommu.ohw/gpio/max7310.ohw/gpio/puv3_gpio.ohw/gpio/pl061.ohw/gpio/zaurus.ohw/gpio/mpc8xxx.ohw/gpio/gpio_key.ohw/i2c/core.ohw/i2c/smbus.ohw/i2c/smbus_eeprom.ohw/i2c/i2c-ddc.ohw/i2c/versatile_i2c.ohw/i2c/smbus_ich9.ohw/i2c/pm_smbus.ohw/i2c/bitbang_i2c.ohw/i2c/exynos4210_i2c.ohw/i2c/imx_i2c.ohw/i2c/aspeed_i2c.ohw/ide/core.ohw/ide/atapi.ohw/ide/qdev.ohw/ide/pci.ohw/ide/isa.ohw/ide/piix.ohw/ide/cmd646.ohw/ide/macio.ohw/ide/mmio.ohw/ide/via.ohw/ide/microdrive.ohw/ide/ahci.ohw/ide/ich.ohw/input/adb.ohw/input/pckbd.ohw/input/hid.ohw/input/lm832x.ohw/input/pl050.ohw/input/stellaris_input.ohw/input/ps2.ohw/input/tsc2005.ohw/input/vmmouse.ohw/input/virtio-input.ohw/input/virtio-input-host.ohw/intc/heathrow_pic.ohw/input/virtio-input-hid.ohw/intc/i8259_common.ohw/intc/i8259.ohw/intc/pl190.ohw/intc/puv3_intc.ohw/intc/xilinx_intc.ohw/intc/etraxfs_pic.ohw/intc/imx_avic.ohw/intc/lm32_pic.ohw/intc/realview_gic.ohw/intc/ioapic_common.ohw/intc/slavio_intctl.ohw/intc/arm_gic_common.ohw/intc/arm_gic.ohw/intc/arm_gicv2m.ohw/intc/arm_gicv3_common.ohw/intc/arm_gicv3.ohw/intc/arm_gicv3_dist.ohw/intc/arm_gicv3_its_common.ohw/intc/arm_gicv3_redist.ohw/intc/openpic.ohw/ipack/ipack.ohw/ipack/tpci200.ohw/ipmi/ipmi.ohw/ipmi/ipmi_bmc_sim.ohw/ipmi/ipmi_bmc_extern.ohw/ipmi/isa_ipmi_kcs.ohw/ipmi/isa_ipmi_bt.ohw/isa/apm.ohw/isa/isa-bus.ohw/isa/i82378.ohw/isa/pc87312.ohw/isa/vt82c686.ohw/isa/piix4.ohw/mem/pc-dimm.ohw/mem/nvdimm.ohw/misc/max111x.ohw/misc/tmp105.ohw/misc/tmp421.ohw/misc/applesmc.ohw/misc/debugexit.ohw/misc/sga.ohw/misc/pc-testdev.ohw/misc/pci-testdev.ohw/misc/unimp.ohw/misc/arm_l2x0.ohw/misc/arm_integrator_debug.ohw/misc/a9scu.ohw/misc/puv3_pm.ohw/misc/arm11scu.ohw/misc/macio/macio.ohw/misc/macio/cuda.ohw/misc/macio/mac_dbdma.ohw/net/dp8393x.ohw/net/ne2000.ohw/net/eepro100.ohw/net/pcnet-pci.ohw/net/pcnet.ohw/net/e1000x_common.ohw/net/e1000.ohw/net/net_tx_pkt.ohw/net/e1000e.ohw/net/rtl8139.ohw/net/e1000e_core.ohw/net/smc91c111.ohw/net/vmxnet3.ohw/net/lan9118.ohw/net/ne2000-isa.ohw/net/opencores_eth.ohw/net/xgmac.ohw/net/mipsnet.ohw/net/xilinx_axienet.ohw/net/allwinner_emac.ohw/net/imx_fec.ohw/net/stellaris_enet.ohw/net/cadence_gem.ohw/net/lance.ohw/net/ftgmac100.ohw/net/rocker/rocker.ohw/net/rocker/rocker_desc.ohw/nvram/ds1225y.ohw/nvram/eeprom93xx.ohw/nvram/fw_cfg.ohw/nvram/chrp_nvram.ohw/nvram/mac_nvram.ohw/pci-bridge/pci_bridge_dev.ohw/pci-bridge/pcie_root_port.ohw/pci-bridge/gen_pcie_root_port.ohw/pci-bridge/xio3130_upstream.ohw/pci-bridge/pci_expander_bridge.ohw/pci-bridge/xio3130_downstream.ohw/pci-bridge/ioh3420.ohw/pci-bridge/dec.ohw/pci-bridge/i82801b11.ohw/pci-host/pam.ohw/pci-host/prep.ohw/pci-host/grackle.ohw/pci-host/uninorth.ohw/pci-host/ppce500.ohw/pci-host/versatile.ohw/pci-host/apb.ohw/pci-host/bonito.ohw/pci-host/piix.ohw/pci-host/q35.ohw/pci-host/gpex.ohw/pci-host/xilinx-pcie.ohw/pci/pci.ohw/pci/pci_bridge.ohw/pci/msix.ohw/pci/msi.ohw/pci/shpc.ohw/pci/slotid_cap.ohw/pci/pci_host.ohw/pci/pcie_host.ohw/pci/pcie.ohw/pci/pcie_port.ohw/pci/pcie_aer.ohw/pci/pci-stub.ohw/pcmcia/pcmcia.ohw/scsi/scsi-generic.ohw/scsi/scsi-disk.ohw/scsi/scsi-bus.ohw/scsi/lsi53c895a.ohw/scsi/mptsas.ohw/scsi/mptconfig.ohw/scsi/mptendian.ohw/scsi/megasas.ohw/scsi/esp.ohw/scsi/vmw_pvscsi.ohw/scsi/esp-pci.ohw/sd/pl181.ohw/sd/ssi-sd.ohw/sd/sd.ohw/sd/core.ohw/sd/sdhci.ohw/smbios/smbios_type_38.ohw/smbios/smbios.ohw/ssi/pl022.ohw/ssi/ssi.ohw/ssi/xilinx_spi.ohw/ssi/aspeed_smc.ohw/ssi/xilinx_spips.ohw/ssi/stm32f2xx_spi.ohw/timer/arm_timer.ohw/timer/arm_mptimer.ohw/timer/armv7m_systick.ohw/timer/a9gtimer.ohw/timer/cadence_ttc.ohw/timer/ds1338.ohw/timer/i8254_common.ohw/timer/i8254.ohw/timer/hpet.ohw/timer/m48t59.ohw/timer/m48t59-isa.ohw/timer/pl031.ohw/timer/puv3_ost.ohw/timer/xilinx_timer.ohw/timer/slavio_timer.ohw/timer/twl92230.ohw/timer/etraxfs_timer.ohw/timer/grlib_gptimer.ohw/timer/imx_epit.ohw/timer/imx_gpt.ohw/timer/lm32_timer.ohw/timer/milkymist-sysctl.ohw/timer/stm32f2xx_timer.ohw/timer/aspeed_timer.ohw/timer/sun4v-rtc.ohw/tpm/tpm_tis.ohw/tpm/tpm_passthrough.ohw/tpm/tpm_util.ohw/usb/core.ohw/usb/libhw.ohw/usb/combined-packet.ohw/usb/bus.ohw/usb/desc.ohw/usb/desc-msos.ohw/usb/hcd-uhci.ohw/usb/hcd-ohci.ohw/usb/hcd-ehci-pci.ohw/usb/hcd-ehci-sysbus.ohw/usb/hcd-ehci.ohw/usb/hcd-xhci-nec.ohw/usb/hcd-xhci.ohw/usb/hcd-musb.ohw/usb/dev-hub.ohw/usb/dev-hid.ohw/usb/dev-wacom.ohw/usb/dev-storage.ohw/usb/dev-uas.ohw/usb/dev-audio.ohw/usb/dev-serial.ohw/usb/dev-network.ohw/usb/dev-bluetooth.ohw/usb/dev-smartcard-reader.ohw/usb/dev-mtp.ohw/usb/host-legacy.ohw/usb/host-libusb.ohw/virtio/virtio-rng.ohw/virtio/virtio-bus.ohw/virtio/virtio-mmio.ohw/virtio/vhost-stub.ohw/virtio/virtio-pci.ohw/watchdog/wdt_i6300esb.ohw/watchdog/wdt_ib700.ohw/watchdog/wdt_diag288.ohw/watchdog/wdt_aspeed.omigration/socket.omigration/migration.omigration/tls.omigration/channel.omigration/savevm.omigration/colo-comm.omigration/colo.omigration/colo-failover.omigration/vmstate.omigration/vmstate-types.omigration/qemu-file.omigration/qemu-file-channel.omigration/postcopy-ram.omigration/block.onet/net.onet/vhost-user.onet/filter.onet/tap.oqom/cpu.oslirp/slirp.oui/console.oui/input.oui/vnc.o
Thomas
Quoted 5 lines · Thomas Huth
This is quite similar to trying to poison
CONFIG_USER_ONLY... every common file that depends oninclude/exec/memory.hor /include/exec/cpu-common.h then does not compile anymore - and as far as I can see, this can't be fixed with some trivial "#ifdef NEED_CPU_H"s in most cases anymore.
Oh, indeed. :( I'll put removing ram_addr_t from memory.h on my todo list. I think most of those can go under NEED_CPU_H or can be replaced with size_t.
Those parts of cpu-common.h instead should move to include/exec/ram_addr.h sooner rather than later.
Paolo
Quoted 3 lines
Since you've asked on IRC for a list of files which do not compile anymore in this case, here we go (some of them are also quite easy to fix, I think, but some need some bigger reworks, I guess):