aboutsummaryrefslogtreecommitdiff
path: root/include/hw
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-07-02 07:11:47 -0700
committerRichard Henderson <richard.henderson@linaro.org>2024-07-02 07:11:47 -0700
commitff6d8490e33acf44ed8afd549e203a42d6f813b5 (patch)
tree4cd8b525300f6f59d3b4cfec341cadc031290e4b /include/hw
parentc80a339587fe4148292c260716482dd2f86d4476 (diff)
parentf0936cbc1d42410ccd58c042bc26fa33a23a77d6 (diff)
downloadqemu-ff6d8490e33acf44ed8afd549e203a42d6f813b5.zip
qemu-ff6d8490e33acf44ed8afd549e203a42d6f813b5.tar.gz
qemu-ff6d8490e33acf44ed8afd549e203a42d6f813b5.tar.bz2
Merge tag 'hw-misc-20240702' of https://github.com/philmd/qemu into staging
Misc HW patches queue - Prevent NULL deref in sPAPR network model (Oleg) - Automatic deprecation of versioned machine types (Daniel) - Correct 'dump-guest-core' property name in hint (Akihiko) - Prevent IRQ leak in MacIO IDE model (Mark) - Remove dead #ifdef'ry related to unsupported macOS 12.0 (Akihiko) - Remove "hw/hw.h" where unnecessary (Thomas) # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmaDiSQACgkQ4+MsLN6t # wN4jmBAA2kxwFAGbKvokANDAZBwWmJdnuIPcqS+jdo/wCuQXOo1ROADd3NFlgQWx # z1xOv/LiAmQiUeeiP+nlA8gWCdW93PErU07og1p1+N2D1sBO6oG5QDlT/tTFuEGd # IL21jG2xWkEemd3PSN2pHKrytpS0e4S0cNZIKgTUTKdv+Mb2ZEiQi7K4zUTjcmjz # nlsSjTXdyKBmoiqNGhITWfbR2IUWjtCpzUO44ceqXd5HDpvfGhpKI7Uwun1W2xNU # yw1XrAFd64Qhd/lvc28G1DLfDdtRIoaRGxgLzQbU6621s0o50Ecs6TNHseuUAKvd # tQhOtM8IEuZ6jVw8nswCPIcJyjbeY29kjI4WmD2weF1fZbDey6Emlrf+dkJUIuCb # TximyTXw3rb1nREUVsEQLF69BKjTjE5+ETaplcTWGHCoH2+uA/5MqygalTH1Ub9W # TwVWSUwpNvIJ3RTsT20YVowkill8piF+ECldTKzJuWjqDviiJDoMm5EFdkkcUB20 # nMyhGoiXtiQ4NYU0/B6HbHOXZkqLbhWcx9G281xJ+RRwjUyVxXD3zHGR9AoOp9ls # EAo/2URJtGN95LJmzCtaD+oo0wRZ5+7lmnqHPPXkYUdwFm4bhe3dP4NggIrS0cXn # 19wvBqQuPwywxIbFEu6327YtfPRcImWIlFthWnm9lUyDmbOqDKw= # =fLCx # -----END PGP SIGNATURE----- # gpg: Signature made Mon 01 Jul 2024 09:59:16 PM PDT # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full] * tag 'hw-misc-20240702' of https://github.com/philmd/qemu: (22 commits) Remove inclusion of hw/hw.h from files that don't need it net/vmnet: Drop ifdef for macOS versions older than 12.0 block/file-posix: Drop ifdef for macOS versions older than 12.0 audio: Drop ifdef for macOS versions older than 12.0 hvf: Drop ifdef for macOS versions older than 12.0 hw/ide/macio: switch from using qemu_allocate_irq() to qdev input GPIOs system/physmem: Fix reference to dump-guest-core docs: document special exception for machine type deprecation & removal hw/i386: remove obsolete manual deprecation reason string of i440fx machines hw/ppc: remove obsolete manual deprecation reason string of spapr machines hw: skip registration of outdated versioned machine types hw: set deprecation info for all versioned machine types include/hw: temporarily disable deletion of versioned machine types include/hw: add macros for deprecation & removal of versioned machines hw/i386: convert 'q35' machine definitions to use new macros hw/i386: convert 'i440fx' machine definitions to use new macros hw/m68k: convert 'virt' machine definitions to use new macros hw/ppc: convert 'spapr' machine definitions to use new macros hw/s390x: convert 'ccw' machine definitions to use new macros hw/arm: convert 'virt' machine definitions to use new macros ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'include/hw')
-rw-r--r--include/hw/boards.h298
-rw-r--r--include/hw/i386/pc.h28
-rw-r--r--include/hw/misc/macio/macio.h7
-rw-r--r--include/hw/misc/xlnx-cfi-if.h1
4 files changed, 331 insertions, 3 deletions
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 73ad319..ef6f18f 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -413,6 +413,304 @@ struct MachineState {
struct NumaState *numa_state;
};
+/*
+ * The macros which follow are intended to facilitate the
+ * definition of versioned machine types, using a somewhat
+ * similar pattern across targets.
+ *
+ * For example, a macro that can be used to define versioned
+ * 'virt' machine types would look like:
+ *
+ * #define DEFINE_VIRT_MACHINE_IMPL(latest, ...) \
+ * static void MACHINE_VER_SYM(class_init, virt, __VA_ARGS__)( \
+ * ObjectClass *oc, \
+ * void *data) \
+ * { \
+ * MachineClass *mc = MACHINE_CLASS(oc); \
+ * MACHINE_VER_SYM(options, virt, __VA_ARGS__)(mc); \
+ * mc->desc = "QEMU " MACHINE_VER_STR(__VA_ARGS__) " Virtual Machine"; \
+ * MACHINE_VER_DEPRECATION(__VA_ARGS__); \
+ * if (latest) { \
+ * mc->alias = "virt"; \
+ * } \
+ * } \
+ * static const TypeInfo MACHINE_VER_SYM(info, virt, __VA_ARGS__) = { \
+ * .name = MACHINE_VER_TYPE_NAME("virt", __VA_ARGS__), \
+ * .parent = TYPE_VIRT_MACHINE, \
+ * .class_init = MACHINE_VER_SYM(class_init, virt, __VA_ARGS__), \
+ * }; \
+ * static void MACHINE_VER_SYM(register, virt, __VA_ARGS__)(void) \
+ * { \
+ * MACHINE_VER_DELETION(__VA_ARGS__); \
+ * type_register_static(&MACHINE_VER_SYM(info, virt, __VA_ARGS__)); \
+ * } \
+ * type_init(MACHINE_VER_SYM(register, virt, __VA_ARGS__));
+ *
+ * Following this, one (or more) helpers can be added for
+ * whichever scenarios need to be catered for with a machine:
+ *
+ * // Normal 2 digit, marked as latest e.g. 'virt-9.0'
+ * #define DEFINE_VIRT_MACHINE_LATEST(major, minor) \
+ * DEFINE_VIRT_MACHINE_IMPL(true, major, minor)
+ *
+ * // Normal 2 digit e.g. 'virt-9.0'
+ * #define DEFINE_VIRT_MACHINE(major, minor) \
+ * DEFINE_VIRT_MACHINE_IMPL(false, major, minor)
+ *
+ * // Bugfix 3 digit e.g. 'virt-9.0.1'
+ * #define DEFINE_VIRT_MACHINE_BUGFIX(major, minor, micro) \
+ * DEFINE_VIRT_MACHINE_IMPL(false, major, minor, micro)
+ *
+ * // Tagged 2 digit e.g. 'virt-9.0-extra'
+ * #define DEFINE_VIRT_MACHINE_TAGGED(major, minor, tag) \
+ * DEFINE_VIRT_MACHINE_IMPL(false, major, minor, _, tag)
+ *
+ * // Tagged bugfix 2 digit e.g. 'virt-9.0.1-extra'
+ * #define DEFINE_VIRT_MACHINE_TAGGED(major, minor, micro, tag) \
+ * DEFINE_VIRT_MACHINE_IMPL(false, major, minor, micro, _, tag)
+ */
+
+/*
+ * Helper for dispatching different macros based on how
+ * many __VA_ARGS__ are passed. Supports 1 to 5 variadic
+ * arguments, with the called target able to be prefixed
+ * with 0 or more fixed arguments too. To be called thus:
+ *
+ * _MACHINE_VER_PICK(__VA_ARGS,
+ * MACRO_MATCHING_5_ARGS,
+ * MACRO_MATCHING_4_ARGS,
+ * MACRO_MATCHING_3_ARGS,
+ * MACRO_MATCHING_2_ARGS,
+ * MACRO_MATCHING_1_ARG) (FIXED-ARG-1,
+ * ...,
+ * FIXED-ARG-N,
+ * __VA_ARGS__)
+ */
+#define _MACHINE_VER_PICK(x1, x2, x3, x4, x5, x6, ...) x6
+
+/*
+ * Construct a human targeted machine version string.
+ *
+ * Can be invoked with various signatures
+ *
+ * MACHINE_VER_STR(sym, prefix, major, minor)
+ * MACHINE_VER_STR(sym, prefix, major, minor, micro)
+ * MACHINE_VER_STR(sym, prefix, major, minor, _, tag)
+ * MACHINE_VER_STR(sym, prefix, major, minor, micro, _, tag)
+ *
+ * Respectively emitting symbols with the format
+ *
+ * "{major}.{minor}"
+ * "{major}.{minor}-{tag}"
+ * "{major}.{minor}.{micro}"
+ * "{major}.{minor}.{micro}-{tag}"
+ */
+#define _MACHINE_VER_STR2(major, minor) \
+ #major "." #minor
+
+#define _MACHINE_VER_STR3(major, minor, micro) \
+ #major "." #minor "." #micro
+
+#define _MACHINE_VER_STR4(major, minor, _unused_, tag) \
+ #major "." #minor "-" #tag
+
+#define _MACHINE_VER_STR5(major, minor, micro, _unused_, tag) \
+ #major "." #minor "." #micro "-" #tag
+
+#define MACHINE_VER_STR(...) \
+ _MACHINE_VER_PICK(__VA_ARGS__, \
+ _MACHINE_VER_STR5, \
+ _MACHINE_VER_STR4, \
+ _MACHINE_VER_STR3, \
+ _MACHINE_VER_STR2) (__VA_ARGS__)
+
+
+/*
+ * Construct a QAPI type name for a versioned machine
+ * type
+ *
+ * Can be invoked with various signatures
+ *
+ * MACHINE_VER_TYPE_NAME(prefix, major, minor)
+ * MACHINE_VER_TYPE_NAME(prefix, major, minor, micro)
+ * MACHINE_VER_TYPE_NAME(prefix, major, minor, _, tag)
+ * MACHINE_VER_TYPE_NAME(prefix, major, minor, micro, _, tag)
+ *
+ * Respectively emitting symbols with the format
+ *
+ * "{prefix}-{major}.{minor}"
+ * "{prefix}-{major}.{minor}.{micro}"
+ * "{prefix}-{major}.{minor}-{tag}"
+ * "{prefix}-{major}.{minor}.{micro}-{tag}"
+ */
+#define _MACHINE_VER_TYPE_NAME2(prefix, major, minor) \
+ prefix "-" #major "." #minor TYPE_MACHINE_SUFFIX
+
+#define _MACHINE_VER_TYPE_NAME3(prefix, major, minor, micro) \
+ prefix "-" #major "." #minor "." #micro TYPE_MACHINE_SUFFIX
+
+#define _MACHINE_VER_TYPE_NAME4(prefix, major, minor, _unused_, tag) \
+ prefix "-" #major "." #minor "-" #tag TYPE_MACHINE_SUFFIX
+
+#define _MACHINE_VER_TYPE_NAME5(prefix, major, minor, micro, _unused_, tag) \
+ prefix "-" #major "." #minor "." #micro "-" #tag TYPE_MACHINE_SUFFIX
+
+#define MACHINE_VER_TYPE_NAME(prefix, ...) \
+ _MACHINE_VER_PICK(__VA_ARGS__, \
+ _MACHINE_VER_TYPE_NAME5, \
+ _MACHINE_VER_TYPE_NAME4, \
+ _MACHINE_VER_TYPE_NAME3, \
+ _MACHINE_VER_TYPE_NAME2) (prefix, __VA_ARGS__)
+
+/*
+ * Construct a name for a versioned machine type that is
+ * suitable for use as a C symbol (function/variable/etc).
+ *
+ * Can be invoked with various signatures
+ *
+ * MACHINE_VER_SYM(sym, prefix, major, minor)
+ * MACHINE_VER_SYM(sym, prefix, major, minor, micro)
+ * MACHINE_VER_SYM(sym, prefix, major, minor, _, tag)
+ * MACHINE_VER_SYM(sym, prefix, major, minor, micro, _, tag)
+ *
+ * Respectively emitting symbols with the format
+ *
+ * {prefix}_machine_{major}_{minor}_{sym}
+ * {prefix}_machine_{major}_{minor}_{micro}_{sym}
+ * {prefix}_machine_{major}_{minor}_{tag}_{sym}
+ * {prefix}_machine_{major}_{minor}_{micro}_{tag}_{sym}
+ */
+#define _MACHINE_VER_SYM2(sym, prefix, major, minor) \
+ prefix ## _machine_ ## major ## _ ## minor ## _ ## sym
+
+#define _MACHINE_VER_SYM3(sym, prefix, major, minor, micro) \
+ prefix ## _machine_ ## major ## _ ## minor ## _ ## micro ## _ ## sym
+
+#define _MACHINE_VER_SYM4(sym, prefix, major, minor, _unused_, tag) \
+ prefix ## _machine_ ## major ## _ ## minor ## _ ## tag ## _ ## sym
+
+#define _MACHINE_VER_SYM5(sym, prefix, major, minor, micro, _unused_, tag) \
+ prefix ## _machine_ ## major ## _ ## minor ## _ ## micro ## _ ## tag ## _ ## sym
+
+#define MACHINE_VER_SYM(sym, prefix, ...) \
+ _MACHINE_VER_PICK(__VA_ARGS__, \
+ _MACHINE_VER_SYM5, \
+ _MACHINE_VER_SYM4, \
+ _MACHINE_VER_SYM3, \
+ _MACHINE_VER_SYM2) (sym, prefix, __VA_ARGS__)
+
+
+/*
+ * How many years/major releases for each phase
+ * of the life cycle. Assumes use of versioning
+ * scheme where major is bumped each year
+ */
+#define MACHINE_VER_DELETION_MAJOR 6
+#define MACHINE_VER_DEPRECATION_MAJOR 3
+
+/*
+ * Expands to a static string containing a deprecation
+ * message for a versioned machine type
+ */
+#define MACHINE_VER_DEPRECATION_MSG \
+ "machines more than " stringify(MACHINE_VER_DEPRECATION_MAJOR) \
+ " years old are subject to deletion after " \
+ stringify(MACHINE_VER_DELETION_MAJOR) " years"
+
+#define _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) \
+ (((QEMU_VERSION_MAJOR - major) > cutoff) || \
+ (((QEMU_VERSION_MAJOR - major) == cutoff) && \
+ (QEMU_VERSION_MINOR - minor) >= 0))
+
+#define _MACHINE_VER_IS_EXPIRED2(cutoff, major, minor) \
+ _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
+#define _MACHINE_VER_IS_EXPIRED3(cutoff, major, minor, micro) \
+ _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
+#define _MACHINE_VER_IS_EXPIRED4(cutoff, major, minor, _unused, tag) \
+ _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
+#define _MACHINE_VER_IS_EXPIRED5(cutoff, major, minor, micro, _unused, tag) \
+ _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
+
+#define _MACHINE_IS_EXPIRED(cutoff, ...) \
+ _MACHINE_VER_PICK(__VA_ARGS__, \
+ _MACHINE_VER_IS_EXPIRED5, \
+ _MACHINE_VER_IS_EXPIRED4, \
+ _MACHINE_VER_IS_EXPIRED3, \
+ _MACHINE_VER_IS_EXPIRED2) (cutoff, __VA_ARGS__)
+
+/*
+ * Evaluates true when a machine type with (major, minor)
+ * or (major, minor, micro) version should be considered
+ * deprecated based on the current versioned machine type
+ * lifecycle rules
+ */
+#define MACHINE_VER_IS_DEPRECATED(...) \
+ _MACHINE_IS_EXPIRED(MACHINE_VER_DEPRECATION_MAJOR, __VA_ARGS__)
+
+/*
+ * Evaluates true when a machine type with (major, minor)
+ * or (major, minor, micro) version should be considered
+ * for deletion based on the current versioned machine type
+ * lifecycle rules
+ */
+#define MACHINE_VER_SHOULD_DELETE(...) \
+ _MACHINE_IS_EXPIRED(MACHINE_VER_DELETION_MAJOR, __VA_ARGS__)
+
+/*
+ * Sets the deprecation reason for a versioned machine based
+ * on its age
+ *
+ * This must be unconditionally used in the _class_init
+ * function for all machine types which support versioning.
+ *
+ * Initially it will effectively be a no-op, but after a
+ * suitable period of time has passed, it will set the
+ * 'deprecation_reason' field on the machine, to warn users
+ * about forthcoming removal.
+ */
+#define MACHINE_VER_DEPRECATION(...) \
+ do { \
+ if (MACHINE_VER_IS_DEPRECATED(__VA_ARGS__)) { \
+ mc->deprecation_reason = MACHINE_VER_DEPRECATION_MSG; \
+ } \
+ } while (0)
+
+/*
+ * Prevents registration of a versioned machined based on
+ * its age
+ *
+ * This must be unconditionally used in the register
+ * method for all machine types which support versioning.
+ *
+ * Inijtially it will effectively be a no-op, but after a
+ * suitable period of time has passed, it will cause
+ * execution of the method to return, avoiding registration
+ * of the machine
+ *
+ * The new deprecation and deletion policy for versioned
+ * machine types was introduced in QEMU 9.1.0.
+ *
+ * Under the new policy a number of old machine types (any
+ * prior to 2.12) would be liable for immediate deletion
+ * which would be a violation of our historical deprecation
+ * and removal policy
+ *
+ * Thus deletions are temporarily gated on existance of
+ * the env variable "QEMU_DELETE_MACHINES" / QEMU version
+ * number >= 10.1.0. This gate can be deleted in the 10.1.0
+ * dev cycle
+ */
+#define MACHINE_VER_DELETION(...) \
+ do { \
+ if (MACHINE_VER_SHOULD_DELETE(__VA_ARGS__)) { \
+ if (getenv("QEMU_DELETE_MACHINES") || \
+ QEMU_VERSION_MAJOR > 10 || (QEMU_VERSION_MAJOR == 10 && \
+ QEMU_VERSION_MINOR >= 1)) { \
+ return; \
+ } \
+ } \
+ } while (0)
+
#define DEFINE_MACHINE(namestr, machine_initfn) \
static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
{ \
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 46bc411..4e55d7e 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -317,4 +317,32 @@ extern const size_t pc_compat_2_3_len;
} \
type_init(pc_machine_init_##suffix)
+#define DEFINE_PC_VER_MACHINE(namesym, namestr, initfn, ...) \
+ static void MACHINE_VER_SYM(init, namesym, __VA_ARGS__)( \
+ MachineState *machine) \
+ { \
+ initfn(machine); \
+ } \
+ static void MACHINE_VER_SYM(class_init, namesym, __VA_ARGS__)( \
+ ObjectClass *oc, \
+ void *data) \
+ { \
+ MachineClass *mc = MACHINE_CLASS(oc); \
+ MACHINE_VER_SYM(options, namesym, __VA_ARGS__)(mc); \
+ mc->init = MACHINE_VER_SYM(init, namesym, __VA_ARGS__); \
+ MACHINE_VER_DEPRECATION(__VA_ARGS__); \
+ } \
+ static const TypeInfo MACHINE_VER_SYM(info, namesym, __VA_ARGS__) = \
+ { \
+ .name = MACHINE_VER_TYPE_NAME(namestr, __VA_ARGS__), \
+ .parent = TYPE_PC_MACHINE, \
+ .class_init = MACHINE_VER_SYM(class_init, namesym, __VA_ARGS__), \
+ }; \
+ static void MACHINE_VER_SYM(register, namesym, __VA_ARGS__)(void) \
+ { \
+ MACHINE_VER_DELETION(__VA_ARGS__); \
+ type_register(&MACHINE_VER_SYM(info, namesym, __VA_ARGS__)); \
+ } \
+ type_init(MACHINE_VER_SYM(register, namesym, __VA_ARGS__));
+
#endif
diff --git a/include/hw/misc/macio/macio.h b/include/hw/misc/macio/macio.h
index 2b54da6..16aa95b 100644
--- a/include/hw/misc/macio/macio.h
+++ b/include/hw/misc/macio/macio.h
@@ -80,8 +80,6 @@ struct MACIOIDEState {
uint32_t channel;
qemu_irq real_ide_irq;
qemu_irq real_dma_irq;
- qemu_irq ide_irq;
- qemu_irq dma_irq;
MemoryRegion mem;
IDEBus bus;
@@ -92,6 +90,11 @@ struct MACIOIDEState {
uint32_t irq_reg;
};
+#define MACIO_IDE_PMAC_NIRQS 2
+
+#define MACIO_IDE_PMAC_DMA_IRQ 0
+#define MACIO_IDE_PMAC_IDE_IRQ 1
+
void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table);
void macio_ide_register_dma(MACIOIDEState *ide);
diff --git a/include/hw/misc/xlnx-cfi-if.h b/include/hw/misc/xlnx-cfi-if.h
index f9bd122..5010401 100644
--- a/include/hw/misc/xlnx-cfi-if.h
+++ b/include/hw/misc/xlnx-cfi-if.h
@@ -11,7 +11,6 @@
#define XLNX_CFI_IF_H 1
#include "qemu/help-texts.h"
-#include "hw/hw.h"
#include "qom/object.h"
#define TYPE_XLNX_CFI_IF "xlnx-cfi-if"