Skip to contentSkip to conversation

MIPS patches for 2022-06-11

GIT PULL Applied Philippe Mathieu-Daudé 3 participants 52 messages Jun 11, 2022 – Jun 12, 2022

lore
Share & tools
lore
#0 lore raw

From: Philippe Mathieu-Daudé <[email protected]>

The following changes since commit 30796f556790631c86c733ab06756981be0e1def:

Merge tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging (2022-06-10 18:15:34 -0700)

are available in the Git repository at:

https://github.com/philmd/qemu.git tags/mips-20220611

for you to fetch changes up to 37da3bcf01ccd19336fd8f43bedcd0841d71bb6a:

docs/devel: Fix link to developer mailing lists (2022-06-11 11:44:50 +0200)

----------------------------------------------------------------
MIPS patches queue

- Various TCG fixes (Marcin Nowakowski, Ni Hui, Stefan Pejic, Stefan Pejic)
- Sysbus floppy controller fix (Peter Maydell)
- QOM'ification of PIIX southbridge (Mark Cave-Ayland, Bernhard Beschow)
- Various fixes on ISA devices commonly used by x86/mips machines (Bernhard)
- Few cleanups in accel/tcg & documentation (Bernhard)

----------------------------------------------------------------

Bernhard Beschow (23):
hw/southbridge/piix: Aggregate all PIIX southbridge type names hw/isa/piix4: Use object_initialize_child() for embedded struct hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn hw/isa/piix4: QOM'ify PCI device creation and wiring hw/isa/piix4: Factor out ISABus retrieval from piix4_create() hw/isa/piix4: QOM'ify PIIX4 PM creation
hw/isa/piix4: Inline and remove piix4_create() hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn hw/isa/piix3: QOM'ify PCI device creation and wiring hw/isa/piix3: Factor out ISABus retrieval from piix3_create() hw/isa/piix3: Inline and remove piix3_create() hw/i386/microvm-dt: Force explicit failure if retrieving QOM property
fails
hw/i386/microvm-dt: Determine mc146818rtc's IRQ number from QOM
property
hw/rtc/mc146818rtc: QOM'ify io_base offset
hw: Reuse TYPE_I8042 define
hw/audio/cs4231a: Const'ify global tables
hw/i386/pc: Unexport PC_CPU_MODEL_IDS macro
hw/i386/pc: Unexport functions used only internally hw/i386/pc: Remove orphan declarations hw/net/fsl_etsec/etsec: Remove obsolete and unused etsec_create() accel/tcg/cpu-exec: Unexport dump_drift_info()
accel/tcg: Inline dump_opcount_info() and remove it docs/devel: Fix link to developer mailing lists

Dragan Mladjenovic (4):
target/mips: Fix emulation of nanoMIPS EXTRV_S.H instruction target/mips: Fix emulation of nanoMIPS BPOSGE32C instruction target/mips: Fix emulation of nanoMIPS BNEC[32] instruction target/mips: Fix handling of unaligned memory access for nanoMIPS ISA

Marcin Nowakowski (1):
target/mips: Fix WatchHi.M handling

Mark Cave-Ayland (11):
hw/acpi/piix4: move xen_enabled() logic from piix4_pm_init() to

    piix4_pm_realize()
  hw/acpi/piix4: change smm_enabled from int to bool
  hw/acpi/piix4: convert smm_enabled bool to qdev property
  hw/acpi/piix4: move PIIX4PMState into separate piix4.h header
  hw/acpi/piix4: alter piix4_pm_init() to return PIIX4PMState
  hw/acpi/piix4: rename piix4_pm_init() to piix4_pm_initfn()
  hw/acpi/piix4: use qdev gpio to wire up sci_irq
  hw/acpi/piix4: use qdev gpio to wire up smi_irq
  hw/i386/pc_piix: create PIIX4_PM device directly instead of using
    piix4_pm_initfn()
  hw/isa/piix4.c: create PIIX4_PM device directly instead of using
    piix4_pm_initfn()

hw/acpi/piix4: remove unused piix4_pm_initfn() function

Ni Hui (6):
target/mips: Fix SAT_S trans helper
target/mips: Fix df_extract_val() and df_extract_df() dfe lookup target/mips: Fix msa checking condition in trans_msa_elm_fn() target/mips: Do not treat msa INSERT as NOP when wd is zero target/mips: Fix store adress of high 64bit in helper_msa_st_b() target/mips: Fix FTRUNC_S and FTRUNC_U trans helper

Peter Maydell (1):
hw/block/fdc-sysbus: Always mark sysbus floppy controllers as not
having DMA

Stefan Pejic (3):
target/mips: Fix emulation of nanoMIPS MTHLIP instruction target/mips: Add missing default cases for some nanoMIPS pools target/mips: Undeprecate nanoMIPS ISA support in QEMU

 MAINTAINERS                              |   3 +-
 accel/tcg/cpu-exec.c                     |   4 +-
 accel/tcg/translate-all.c                |   5 -
 docs/about/deprecated.rst                |  30 ------
 docs/devel/submitting-a-patch.rst        |   6 +-
 hw/acpi/piix4.c                          |  77 +++------------
 hw/audio/cs4231a.c                       |   8 +-
 hw/block/fdc-sysbus.c                    |  16 +++-
 hw/i386/acpi-build.c                     |   1 +
 hw/i386/microvm-dt.c                     |   9 +-
 hw/i386/pc.c                             |  17 +++-
 hw/i386/pc_piix.c                        |  23 +++--
 hw/isa/piix3.c                           |  98 ++++++++++---------
 hw/isa/piix4.c                           | 116 ++++++++++++-----------
 hw/mips/jazz.c                           |   2 +-
 hw/mips/malta.c                          |   9 +-
 hw/net/fsl_etsec/etsec.c                 |  23 -----
 hw/net/fsl_etsec/etsec.h                 |   7 --
 hw/rtc/mc146818rtc.c                     |   9 +-
 hw/sparc64/sun4u.c                       |   2 +-
 include/exec/cpu-all.h                   |   3 -
 include/hw/acpi/piix4.h                  |  75 +++++++++++++++
 include/hw/block/fdc.h                   |   3 +-
 include/hw/i386/pc.h                     |  14 ---
 include/hw/isa/isa.h                     |   2 -
 include/hw/rtc/mc146818rtc.h             |   2 +-
 include/hw/southbridge/piix.h            |  12 +--
 target/mips/cpu.c                        |   2 +-
 target/mips/cpu.h                        |   3 +-
 target/mips/tcg/msa_helper.c             |   2 +-
 target/mips/tcg/msa_translate.c          |  29 +++---
 target/mips/tcg/nanomips_translate.c.inc |  33 ++++++-
 target/mips/tcg/sysemu/cp0_helper.c      |   3 +-
 target/mips/tcg/translate.c              |   5 +-
 34 files changed, 333 insertions(+), 320 deletions(-)
 create mode 100644 include/hw/acpi/piix4.h
Signature · 1 line
2.36.1
#1 lore raw

[PULL 01/49] target/mips: Fix WatchHi.M handling

From: Marcin Nowakowski <[email protected]>

bit 31 (M) of WatchHiN register is a read-only register indicating whether the next WatchHi register is present. It must not be reset during user writes to the register.

Message-Id: <[email protected]>

---
 target/mips/cpu.c                   | 2 +-
 target/mips/cpu.h                   | 1 +
 target/mips/tcg/sysemu/cp0_helper.c | 3 ++-
 3 files changed, 4 insertions(+), 2 deletions(-)
target/mips/cpu.c +1 -1
index ad74fbe636..c15c955367 100644
@@ -305,7 +305,7 @@ static void mips_cpu_reset(DeviceState *dev)
 
         for (i = 0; i < 7; i++) {
             env->CP0_WatchLo[i] = 0;
-            env->CP0_WatchHi[i] = 0x80000000;
+            env->CP0_WatchHi[i] = 1 << CP0WH_M;
         }
         env->CP0_WatchLo[7] = 0;
         env->CP0_WatchHi[7] = 0;
target/mips/cpu.h +1 -0
index 5335ac10a3..6b6b8776d1 100644
@@ -1005,6 +1005,7 @@ typedef struct CPUArchState {
  */
     uint64_t CP0_WatchHi[8];
 #define CP0WH_ASID 16
+#define CP0WH_M    31
 /*
  * CP0 Register 20
  */
target/mips/tcg/sysemu/cp0_helper.c +2 -1
index aae2af6ecc..5da1124589 100644
@@ -1396,10 +1396,11 @@ void helper_mtc0_watchlo(CPUMIPSState *env, target_ulong arg1, uint32_t sel)
 void helper_mtc0_watchhi(CPUMIPSState *env, target_ulong arg1, uint32_t sel)
 {
     uint64_t mask = 0x40000FF8 | (env->CP0_EntryHi_ASID_mask << CP0WH_ASID);
+    uint64_t m_bit = env->CP0_WatchHi[sel] & (1 << CP0WH_M); /* read-only */
     if ((env->CP0_Config5 >> CP0C5_MI) & 1) {
         mask |= 0xFFFFFFFF00000000ULL; /* MMID */
     }
-    env->CP0_WatchHi[sel] = arg1 & mask;
+    env->CP0_WatchHi[sel] = m_bit | (arg1 & mask);
     env->CP0_WatchHi[sel] &= ~(env->CP0_WatchHi[sel] & arg1 & 0x7);
 }
 
Signature · 1 line
2.36.1
#2 lore raw

[PULL 02/49] target/mips: Fix SAT_S trans helper

In reply to Philippe Mathieu-Daudé

From: Ni Hui <[email protected]>

Fix the SAT_S and SAT_U trans helper confusion.

Fixes 4701d23aef ("target/mips: Convert MSA BIT instruction format to decodetree")

Message-Id: <[email protected]>

---
 target/mips/tcg/msa_translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/msa_translate.c +1 -1
index 7576b3ed86..76307102f2 100644
@@ -399,7 +399,7 @@ TRANS(BSETI,    trans_msa_bit, gen_helper_msa_bseti_df);
 TRANS(BNEGI,    trans_msa_bit, gen_helper_msa_bnegi_df);
 TRANS(BINSLI,   trans_msa_bit, gen_helper_msa_binsli_df);
 TRANS(BINSRI,   trans_msa_bit, gen_helper_msa_binsri_df);
-TRANS(SAT_S,    trans_msa_bit, gen_helper_msa_sat_u_df);
+TRANS(SAT_S,    trans_msa_bit, gen_helper_msa_sat_s_df);
 TRANS(SAT_U,    trans_msa_bit, gen_helper_msa_sat_u_df);
 TRANS(SRARI,    trans_msa_bit, gen_helper_msa_srari_df);
 TRANS(SRLRI,    trans_msa_bit, gen_helper_msa_srlri_df);
Signature · 1 line
2.36.1
#3 lore raw

[PULL 10/49] target/mips: Fix emulation of nanoMIPS BPOSGE32C instruction

In reply to Philippe Mathieu-Daudé

From: Dragan Mladjenovic <[email protected]>

There are currently two problems related to the emulation of the instruction BPOSGE32C.

The nanoMIPS instruction BPOSGE32C belongs to DSP R3 instructions (actually, as of now, it is the only instruction of DSP R3). The presence of DSP R3 instructions in QEMU is indicated by the flag MIPS_HFLAG_DSP_R3 (0x20000000). This flag is currently being properly set in CPUMIPSState's hflags (for example, for I7200 nanoMIPS CPU). However, it is not propagated to DisasContext's hflags, since the flag MIPS_HFLAG_DSP_R3 is not set in MIPS_HFLAG_TMASK (while similar flags MIPS_HFLAG_DSP_R2 and MIPS_HFLAG_DSP are set in this mask, and there is no problem in functioning check_dsp_r2(), check_dsp()). This means the function check_dsp_r3() currently does not work properly, and the emulation of BPOSGE32C can not work properly as well.

Change MIPS_HFLAG_TMASK from 0x1F5807FF to 0x3F5807FF (logical OR with 0x20000000) to fix this.

Additionally, check_cp1_enabled() is currently incorrectly called while emulating BPOSGE32C. BPOSGE32C is in the same pool (P.BR1) as FPU branch instruction BC1EQZC and BC1NEZC, but it not a part of FPU (CP1) instructions, and check_cp1_enabled() should not be involved while emulating BPOSGE32C.

Rearrange invocations of check_cp1_enabled() within P.BR1 pool handling to affect only BC1EQZC and BC1NEZC emulation, and not BPOSGE32C emulation.

Message-Id: <[email protected]>

---
 target/mips/cpu.h                        | 2 +-
 target/mips/tcg/nanomips_translate.c.inc | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
target/mips/cpu.h +1 -1
index 6b6b8776d1..42efa989e4 100644
@@ -1077,7 +1077,7 @@ typedef struct CPUArchState {
 #define EXCP_INST_NOTAVAIL 0x2 /* No valid instruction word for BadInstr */
     uint32_t hflags;    /* CPU State */
     /* TMASK defines different execution modes */
-#define MIPS_HFLAG_TMASK  0x1F5807FF
+#define MIPS_HFLAG_TMASK  0x3F5807FF
 #define MIPS_HFLAG_MODE   0x00007 /* execution modes                    */
     /*
      * The KSU flags must be the lowest bits in hflags. The flag order
target/mips/tcg/nanomips_translate.c.inc +2 -1
index 9ee4df2135..941cfaa6bb 100644
@@ -4478,12 +4478,13 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
             case NM_P_BR3A:
                 s = sextract32(ctx->opcode, 0, 1) << 14 |
                     extract32(ctx->opcode, 1, 13) << 1;
-                check_cp1_enabled(ctx);
                 switch (extract32(ctx->opcode, 16, 5)) {
                 case NM_BC1EQZC:
+                    check_cp1_enabled(ctx);
                     gen_compute_branch_cp1_nm(ctx, OPC_BC1EQZ, rt, s);
                     break;
                 case NM_BC1NEZC:
+                    check_cp1_enabled(ctx);
                     gen_compute_branch_cp1_nm(ctx, OPC_BC1NEZ, rt, s);
                     break;
                 case NM_BPOSGE32C:
Signature · 1 line
2.36.1
#4 lore raw

[PULL 03/49] target/mips: Fix df_extract_val() and df_extract_df() dfe lookup

In reply to Philippe Mathieu-Daudé

From: Ni Hui <[email protected]>

Actually look into dfe structure data so that df_extract_val() and df_extract_df() can return immediate and datafield other than BYTE.

Fixes 4701d23aef ("target/mips: Convert MSA BIT instruction format to decodetree")

Message-Id: <[email protected]>

---
 target/mips/tcg/msa_translate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target/mips/tcg/msa_translate.c +3 -3
index 76307102f2..aa45bae0aa 100644
@@ -68,8 +68,8 @@ struct dfe {
 static int df_extract_val(DisasContext *ctx, int x, const struct dfe *s)
 {
     for (unsigned i = 0; i < 4; i++) {
-        if (extract32(x, s->start, s->length) == s->mask) {
-            return extract32(x, 0, s->start);
+        if (extract32(x, s[i].start, s[i].length) == s[i].mask) {
+            return extract32(x, 0, s[i].start);
         }
     }
     return -1;
@@ -82,7 +82,7 @@ static int df_extract_val(DisasContext *ctx, int x, const struct dfe *s)
 static int df_extract_df(DisasContext *ctx, int x, const struct dfe *s)
 {
     for (unsigned i = 0; i < 4; i++) {
-        if (extract32(x, s->start, s->length) == s->mask) {
+        if (extract32(x, s[i].start, s[i].length) == s[i].mask) {
             return i;
         }
     }
Signature · 1 line
2.36.1
#5 lore raw

[PULL 07/49] target/mips: Fix FTRUNC_S and FTRUNC_U trans helper

In reply to Philippe Mathieu-Daudé

From: Ni Hui <[email protected]>

Fix the FTRUNC_S and FTRUNC_U trans helper problem.

Fixes 5c5b64000c ("target/mips: Convert MSA 2RF instruction format to decodetree")

Message-Id: <[email protected]>

---
 target/mips/tcg/msa_translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/mips/tcg/msa_translate.c +2 -2
index 0b3dd0957c..1bcdbb1121 100644
@@ -752,8 +752,8 @@ static bool trans_msa_2rf(DisasContext *ctx, arg_msa_r *a,
 }
 
 TRANS(FCLASS,   trans_msa_2rf, gen_helper_msa_fclass_df);
-TRANS(FTRUNC_S, trans_msa_2rf, gen_helper_msa_fclass_df);
-TRANS(FTRUNC_U, trans_msa_2rf, gen_helper_msa_ftrunc_s_df);
+TRANS(FTRUNC_S, trans_msa_2rf, gen_helper_msa_ftrunc_s_df);
+TRANS(FTRUNC_U, trans_msa_2rf, gen_helper_msa_ftrunc_u_df);
 TRANS(FSQRT,    trans_msa_2rf, gen_helper_msa_fsqrt_df);
 TRANS(FRSQRT,   trans_msa_2rf, gen_helper_msa_frsqrt_df);
 TRANS(FRCP,     trans_msa_2rf, gen_helper_msa_frcp_df);
Signature · 1 line
2.36.1
#6 lore raw

[PULL 04/49] target/mips: Fix msa checking condition in trans_msa_elm_fn()

In reply to Philippe Mathieu-Daudé

From: Ni Hui <[email protected]>

Fix issue that condition of check_msa_enabled(ctx) is reversed that causes segfault when msa elm_fn op encountered.

Fixes 2f2745c81a ("target/mips: Convert MSA COPY_U opcode to decodetree")
Fixes 97fe675519 ("target/mips: Convert MSA COPY_S and INSERT opcodes to decodetree")

Message-Id: <[email protected]>

---
 target/mips/tcg/msa_translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/msa_translate.c +1 -1
index aa45bae0aa..92ccc6f921 100644
@@ -599,7 +599,7 @@ static bool trans_msa_elm_fn(DisasContext *ctx, arg_msa_elm_df *a,
         return false;
     }
 
-    if (check_msa_enabled(ctx)) {
+    if (!check_msa_enabled(ctx)) {
         return true;
     }
 
Signature · 1 line
2.36.1
#7 lore raw

[PULL 11/49] target/mips: Fix emulation of nanoMIPS BNEC[32] instruction

In reply to Philippe Mathieu-Daudé

From: Dragan Mladjenovic <[email protected]>

If both rs and rt are the same register, the nanoMIPS instruction BNEC[32] rs, rt, address is equivalent to NOP (branch is not taken and there is no delay slot). This commit provides such behavior. Without this commit, this scenario results in an incorrect behavior.

Message-Id: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
target/mips/tcg/nanomips_translate.c.inc +6 -1
index 941cfaa6bb..1ee5c8c8d4 100644
@@ -4528,7 +4528,12 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
             switch (extract32(ctx->opcode, 14, 2)) {
             case NM_BNEC:
                 check_nms(ctx);
-                gen_compute_branch_nm(ctx, OPC_BNE, 4, rs, rt, s);
+                if (rs == rt) {
+                    /* NOP */
+                    ctx->hflags |= MIPS_HFLAG_FBNSLOT;
+                } else {
+                    gen_compute_branch_nm(ctx, OPC_BNE, 4, rs, rt, s);
+                }
                 break;
             case NM_BLTC:
                 if (rs != 0 && rt != 0 && rs == rt) {
Signature · 1 line
2.36.1
#8 lore raw

[PULL 06/49] target/mips: Fix store adress of high 64bit in helper_msa_st_b()

In reply to Philippe Mathieu-Daudé

From: Ni Hui <[email protected]>

This patch fix the issue that helper_msa_st_b() write high 64bit data to where the low 64bit resides, leaving high 64bit undefined.

Fixes 68ad9260e0 ("target/mips: Use 8-byte memory ops for msa load/store")

Message-Id: <[email protected]>

---
 target/mips/tcg/msa_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/msa_helper.c +1 -1
index 4dde5d639a..736283e2af 100644
@@ -8329,7 +8329,7 @@ void helper_msa_st_b(CPUMIPSState *env, uint32_t wd,
 
     /* Store 8 bytes at a time.  Vector element ordering makes this LE.  */
     cpu_stq_le_data_ra(env, addr + 0, pwd->d[0], ra);
-    cpu_stq_le_data_ra(env, addr + 0, pwd->d[1], ra);
+    cpu_stq_le_data_ra(env, addr + 8, pwd->d[1], ra);
 }
 
 void helper_msa_st_h(CPUMIPSState *env, uint32_t wd,
Signature · 1 line
2.36.1
#9 lore raw

[PULL 09/49] target/mips: Fix emulation of nanoMIPS EXTRV_S.H instruction

In reply to Philippe Mathieu-Daudé

From: Dragan Mladjenovic <[email protected]>

The field rs in the instruction EXTRV_S.H rt, ac, rs is specified in nanoMIPS documentation as opcode[20..16]. It is, however, erroneously considered as opcode[25..21] in the current QEMU implementation. In function gen_pool32axf_2_nanomips_insn(), the variable v0_t corresponds to rt/opcode[25..21], and v1_t corresponds to rs/opcode[20..16]), and v0_t is by mistake passed to the helper gen_helper_extr_s_h().

Use v1_t rather than v0_t in the invocation of gen_helper_extr_s_h() to fix this.

Fixes 8b3698b294 ("target/mips: Add emulation of DSP ASE for nanoMIPS")

Message-Id: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/nanomips_translate.c.inc +1 -1
index 58ae35a156..9ee4df2135 100644
@@ -2036,7 +2036,7 @@ static void gen_pool32axf_2_nanomips_insn(DisasContext *ctx, uint32_t opc,
         case NM_EXTRV_S_H:
             check_dsp(ctx);
             tcg_gen_movi_tl(t0, rd >> 3);
-            gen_helper_extr_s_h(t0, t0, v0_t, cpu_env);
+            gen_helper_extr_s_h(t0, t0, v1_t, cpu_env);
             gen_store_gpr(t0, ret);
             break;
         }
Signature · 1 line
2.36.1
#10 lore raw

[PULL 05/49] target/mips: Do not treat msa INSERT as NOP when wd is zero

In reply to Philippe Mathieu-Daudé

From: Ni Hui <[email protected]>

Only for msa COPY_U/COPY_S with wd zero, we treat it as NOP.

Move this special rule into COPY_U and COPY_S trans function.

Fixes 97fe675519 ("target/mips: Convert MSA COPY_S and INSERT opcodes to decodetree")

Message-Id: <[email protected]>

---
 target/mips/tcg/msa_translate.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
target/mips/tcg/msa_translate.c +10 -5
index 92ccc6f921..0b3dd0957c 100644
@@ -603,11 +603,6 @@ static bool trans_msa_elm_fn(DisasContext *ctx, arg_msa_elm_df *a,
         return true;
     }
 
-    if (a->wd == 0) {
-        /* Treat as NOP. */
-        return true;
-    }
-
     gen_msa_elm[a->df](cpu_env,
                        tcg_constant_i32(a->wd),
                        tcg_constant_i32(a->ws),
@@ -624,6 +619,11 @@ static bool trans_msa_elm_fn(DisasContext *ctx, arg_msa_elm_df *a,
 
 static bool trans_COPY_U(DisasContext *ctx, arg_msa_elm_df *a)
 {
+    if (a->wd == 0) {
+        /* Treat as NOP. */
+        return true;
+    }
+
     static gen_helper_piii * const gen_msa_copy_u[4] = {
         gen_helper_msa_copy_u_b, gen_helper_msa_copy_u_h,
         NULL_IF_MIPS32(gen_helper_msa_copy_u_w), NULL
@@ -634,6 +634,11 @@ static bool trans_COPY_U(DisasContext *ctx, arg_msa_elm_df *a)
 
 static bool trans_COPY_S(DisasContext *ctx, arg_msa_elm_df *a)
 {
+    if (a->wd == 0) {
+        /* Treat as NOP. */
+        return true;
+    }
+
     static gen_helper_piii * const gen_msa_copy_s[4] = {
         gen_helper_msa_copy_s_b, gen_helper_msa_copy_s_h,
         gen_helper_msa_copy_s_w, NULL_IF_MIPS32(gen_helper_msa_copy_s_d)
Signature · 1 line
2.36.1
#11 lore raw

[PULL 16/49] hw/acpi/piix4: move xen_enabled() logic from piix4_pm_init() to piix4_pm_realize()

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

This logic can be included as part of piix4_pm_realize() and does not need to be handled externally.

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +4 -3
index fe5625d07a..bf20fa139b 100644
@@ -525,6 +525,10 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
     s->machine_ready.notify = piix4_pm_machine_ready;
     qemu_add_machine_init_done_notifier(&s->machine_ready);
 
+    if (xen_enabled()) {
+        s->use_acpi_hotplug_bridge = false;
+    }
+
     piix4_acpi_system_hot_add_init(pci_address_space_io(dev),
                                    pci_get_bus(dev), s);
     qbus_set_hotplug_handler(BUS(pci_get_bus(dev)), OBJECT(s));
@@ -551,9 +555,6 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
     s->irq = sci_irq;
     s->smi_irq = smi_irq;
     s->smm_enabled = smm_enabled;
-    if (xen_enabled()) {
-        s->use_acpi_hotplug_bridge = false;
-    }
 
     pci_realize_and_unref(pci_dev, bus, &error_fatal);
 
Signature · 1 line
2.36.1
#12 lore raw

[PULL 08/49] target/mips: Fix emulation of nanoMIPS MTHLIP instruction

In reply to Philippe Mathieu-Daudé

From: Stefan Pejic <[email protected]>

The field ac in nanoMIPS instruction MTHLIP rs, ac is specified in nanoMIPS documentation as opcode[15..14] (2 bits). However, in the current QEMU code, the corresponding argument passed to the helper gen_helper_mthlip() has the value of opcode[15..11] (5 bits). Right shift the value of this argument by three bits to fix this.

Message-Id: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/nanomips_translate.c.inc +1 -1
index 916cece4d2..58ae35a156 100644
@@ -1597,7 +1597,7 @@ static void gen_pool32axf_1_nanomips_insn(DisasContext *ctx, uint32_t opc,
         check_dsp(ctx);
         switch (extract32(ctx->opcode, 12, 2)) {
         case NM_MTHLIP:
-            tcg_gen_movi_tl(t0, v2);
+            tcg_gen_movi_tl(t0, v2 >> 3);
             gen_helper_mthlip(t0, v0_t, cpu_env);
             break;
         case NM_SHILOV:
Signature · 1 line
2.36.1
#13 lore raw

[PULL 14/49] target/mips: Undeprecate nanoMIPS ISA support in QEMU

In reply to Philippe Mathieu-Daudé

From: Stefan Pejic <[email protected]>

nanoMIPS ISA support in QEMU is actively used by MediaTek and is planned to be maintained and potentially extended by MediaTek in future.

Un-orphan nanoMIPS ISA support in QEMU by setting a maintainer from MediaTek and remove deprecation notes from documentation as well.

Message-Id: <[email protected]>

---
 MAINTAINERS               |  3 ++-
 docs/about/deprecated.rst | 30 ------------------------------
 2 files changed, 2 insertions(+), 31 deletions(-)
MAINTAINERS +2 -1
index b3af081c51..0df25ed4b0 100644
@@ -246,7 +246,8 @@ F: docs/system/cpu-models-mips.rst.inc
 F: tests/tcg/mips/
 
 MIPS TCG CPUs (nanoMIPS ISA)
-S: Orphan
+M: Stefan Pejic <[email protected]>
+S: Maintained
 F: disas/nanomips.*
 F: target/mips/tcg/*nanomips*
 
docs/about/deprecated.rst +0 -30
index aa2e320207..19a91b575f 100644
@@ -213,17 +213,6 @@ MIPS ``Trap-and-Emul`` KVM support (since 6.0)
 The MIPS ``Trap-and-Emul`` KVM host and guest support has been removed
 from Linux upstream kernel, declare it deprecated.
 
-System emulator CPUS
---------------------
-
-MIPS ``I7200`` CPU Model (since 5.2)
-''''''''''''''''''''''''''''''''''''
-
-The ``I7200`` guest CPU relies on the nanoMIPS ISA, which is deprecated
-(the ISA has never been upstreamed to a compiler toolchain). Therefore
-this CPU is also deprecated.
-
-
 QEMU API (QAPI) events
 ----------------------
 
@@ -337,16 +326,6 @@ The above, converted to the current supported format::
 
   json:{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"}
 
-linux-user mode CPUs
---------------------
-
-MIPS ``I7200`` CPU (since 5.2)
-''''''''''''''''''''''''''''''
-
-The ``I7200`` guest CPU relies on the nanoMIPS ISA, which is deprecated
-(the ISA has never been upstreamed to a compiler toolchain). Therefore
-this CPU is also deprecated.
-
 Backwards compatibility
 -----------------------
 
@@ -376,15 +355,6 @@ versions, aliases will point to newer CPU model versions
 depending on the machine type, so management software must
 resolve CPU model aliases before starting a virtual machine.
 
-Guest Emulator ISAs
--------------------
-
-nanoMIPS ISA
-''''''''''''
-
-The ``nanoMIPS`` ISA has never been upstreamed to any compiler toolchain.
-As it is hard to generate binaries for it, declare it deprecated.
-
 Tools
 -----
 
Signature · 1 line
2.36.1
#14 lore raw

[PULL 12/49] target/mips: Fix handling of unaligned memory access for nanoMIPS ISA

In reply to Philippe Mathieu-Daudé

From: Dragan Mladjenovic <[email protected]>

nanoMIPS ISA does not support unaligned memory access. Adjust DisasContext's default_tcg_memop_mask to reflect this.

Message-Id: <[email protected]>

---
 target/mips/tcg/translate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/mips/tcg/translate.c +3 -2
index 6de5b66650..5f460fb687 100644
@@ -16023,8 +16023,9 @@ static void mips_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
 #else
         ctx->mem_idx = hflags_mmu_index(ctx->hflags);
 #endif
-    ctx->default_tcg_memop_mask = (ctx->insn_flags & (ISA_MIPS_R6 |
-                                  INSN_LOONGSON3A)) ? MO_UNALN : MO_ALIGN;
+    ctx->default_tcg_memop_mask = (!(ctx->insn_flags & ISA_NANOMIPS32) &&
+                                  (ctx->insn_flags & (ISA_MIPS_R6 |
+                                  INSN_LOONGSON3A))) ? MO_UNALN : MO_ALIGN;
 
     /*
      * Execute a branch and its delay slot as a single instruction.
Signature · 1 line
2.36.1
#15 lore raw

[PULL 23/49] hw/acpi/piix4: use qdev gpio to wire up smi_irq

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

Initialize the SMI IRQ in piix4_pm_init().

The smi_irq can now be wired up directly using a qdev gpio instead of having to set the IRQ externally in piix4_pm_initfn().

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c               | 4 ++--
 hw/i386/pc_piix.c             | 3 ++-
 hw/isa/piix4.c                | 2 +-
 include/hw/southbridge/piix.h | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)
hw/acpi/piix4.c +2 -2
index fe5ec0a723..32033bc9d7 100644
@@ -502,10 +502,11 @@ static void piix4_pm_init(Object *obj)
     PIIX4PMState *s = PIIX4_PM(obj);
 
     qdev_init_gpio_out(DEVICE(obj), &s->irq, 1);
+    qdev_init_gpio_out_named(DEVICE(obj), &s->smi_irq, "smi-irq", 1);
 }
 
 PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                              qemu_irq smi_irq, bool smm_enabled)
+                              bool smm_enabled)
 {
     PCIDevice *pci_dev;
     DeviceState *dev;
@@ -517,7 +518,6 @@ PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
     qdev_prop_set_bit(dev, "smm-enabled", smm_enabled);
 
     s = PIIX4_PM(dev);
-    s->smi_irq = smi_irq;
 
     pci_realize_and_unref(pci_dev, bus, &error_fatal);
 
hw/i386/pc_piix.c +2 -1
index 27acba4146..89c4f07c9f 100644
@@ -283,9 +283,10 @@ static void pc_init1(MachineState *machine,
         PIIX4PMState *piix4_pm;
 
         smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
-        piix4_pm = piix4_pm_initfn(pci_bus, piix3_devfn + 3, 0xb100, smi_irq,
+        piix4_pm = piix4_pm_initfn(pci_bus, piix3_devfn + 3, 0xb100,
                                    x86_machine_is_smm_enabled(x86ms));
         qdev_connect_gpio_out(DEVICE(piix4_pm), 0, x86ms->gsi[9]);
+        qdev_connect_gpio_out_named(DEVICE(piix4_pm), "smi-irq", 0, smi_irq);
         pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(piix4_pm), "i2c"));
         /* TODO: Populate SPD eeprom data.  */
         smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
hw/isa/piix4.c +1 -1
index 0b6ea22143..775e15eb20 100644
@@ -311,7 +311,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 
     pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
     if (smbus) {
-        pms = piix4_pm_initfn(pci_bus, devfn + 3, 0x1100, NULL, 0);
+        pms = piix4_pm_initfn(pci_bus, devfn + 3, 0x1100, 0);
         qdev_connect_gpio_out(DEVICE(pms), 0,
                               qdev_get_gpio_in_named(dev, "isa", 9));
         *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pms), "i2c"));
include/hw/southbridge/piix.h +1 -1
index 105d158f78..b69e0dfb04 100644
@@ -17,7 +17,7 @@
 #include "hw/acpi/piix4.h"
 
 PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                              qemu_irq smi_irq, bool smm_enabled);
+                              bool smm_enabled);
 
 /* PIRQRC[A:D]: PIRQx Route Control Registers */
 #define PIIX_PIRQCA 0x60
Signature · 1 line
2.36.1
#16 lore raw

[PULL 17/49] hw/acpi/piix4: change smm_enabled from int to bool

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

This is in preparation for conversion to a qdev property.

Message-Id: <[email protected]>

[PMD: Change simm_enabled from int to bool, suggested by Ani Sinha]
---
 hw/acpi/piix4.c               | 4 ++--
 include/hw/southbridge/piix.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +2 -2
index bf20fa139b..558c250884 100644
@@ -74,7 +74,7 @@ struct PIIX4PMState {
 
     qemu_irq irq;
     qemu_irq smi_irq;
-    int smm_enabled;
+    bool smm_enabled;
     bool smm_compat;
     Notifier machine_ready;
     Notifier powerdown_notifier;
@@ -538,7 +538,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
 
 I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                       qemu_irq sci_irq, qemu_irq smi_irq,
-                      int smm_enabled, DeviceState **piix4_pm)
+                      bool smm_enabled, DeviceState **piix4_pm)
 {
     PCIDevice *pci_dev;
     DeviceState *dev;
include/hw/southbridge/piix.h +1 -1
index f63f83e5c6..ff8d96ae8c 100644
@@ -19,7 +19,7 @@
 
 I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                       qemu_irq sci_irq, qemu_irq smi_irq,
-                      int smm_enabled, DeviceState **piix4_pm);
+                      bool smm_enabled, DeviceState **piix4_pm);
 
 /* PIRQRC[A:D]: PIRQx Route Control Registers */
 #define PIIX_PIRQCA 0x60
Signature · 1 line
2.36.1
#17 lore raw

[PULL 13/49] target/mips: Add missing default cases for some nanoMIPS pools

In reply to Philippe Mathieu-Daudé

From: Stefan Pejic <[email protected]>

Switch statements for the code segments that handle nanoMIPS instruction pools P.LL, P.SC, P.SHIFT, P.LS.S1, P.LS.E0, PP.LSXS do not have proper default case, resulting in not generating reserved instruction exception for certain illegal opcodes.

Fix this by adding default cases for these switch statements that trigger reserved instruction exception.

Message-Id: <[email protected]>

---
 target/mips/tcg/nanomips_translate.c.inc | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
target/mips/tcg/nanomips_translate.c.inc +19 -0
index 1ee5c8c8d4..c0ba2bf1b1 100644
@@ -2707,6 +2707,9 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt)
         case NM_SDC1XS:
             tcg_gen_shli_tl(t0, t0, 3);
             break;
+        default:
+            gen_reserved_instruction(ctx);
+            goto out;
         }
     }
     gen_op_addr_add(ctx, t0, t0, t1);
@@ -2797,6 +2800,7 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt)
         break;
     }
 
+out:
     tcg_temp_free(t0);
     tcg_temp_free(t1);
 }
@@ -3944,6 +3948,9 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                     gen_shift_imm(ctx, OPC_ROTR, rt, rs,
                                   extract32(ctx->opcode, 0, 5));
                     break;
+                default:
+                    gen_reserved_instruction(ctx);
+                    break;
                 }
             }
             break;
@@ -4245,6 +4252,9 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                         check_xnp(ctx);
                         gen_llwp(ctx, rs, 0, rt, extract32(ctx->opcode, 3, 5));
                         break;
+                    default:
+                        gen_reserved_instruction(ctx);
+                        break;
                     }
                     break;
                 case NM_P_SC:
@@ -4257,6 +4267,9 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                         gen_scwp(ctx, rs, 0, rt, extract32(ctx->opcode, 3, 5),
                                  false);
                         break;
+                    default:
+                        gen_reserved_instruction(ctx);
+                        break;
                     }
                     break;
                 case NM_CACHE:
@@ -4265,6 +4278,9 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                         gen_cache_operation(ctx, rt, rs, s);
                     }
                     break;
+                default:
+                    gen_reserved_instruction(ctx);
+                    break;
                 }
                 break;
             case NM_P_LS_E0:
@@ -4371,6 +4387,9 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                         break;
                     }
                     break;
+                default:
+                    gen_reserved_instruction(ctx);
+                    break;
                 }
                 break;
             case NM_P_LS_WM:
Signature · 1 line
2.36.1
#18 lore raw

[PULL 15/49] hw/block/fdc-sysbus: Always mark sysbus floppy controllers as not having DMA

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

The sysbus floppy controllers (devices sysbus-fdc and sun-fdtwo) don't support DMA. The core floppy controller code expects this to be indicated by setting FDCtrl::dma_chann to -1. This used to be done in the device instance_init functions sysbus_fdc_initfn() and sun4m_fdc_initfn(), but in commit 1430759ec3e we refactored this code and accidentally lost the setting of dma_chann.

For sysbus-fdc this has no ill effects because we were redundantly also setting dma_chann in fdctrl_init_sysbus(), but for sun-fdtwo this means that guests which try to enable DMA on the floppy controller will cause QEMU to crash because FDCtrl::dma is NULL.

Set dma_chann to -1 in the common instance init, and remove the redundant code in fdctrl_init_sysbus() that is also setting it.

There is a six-year-old FIXME comment in the jazz board code to the effect that in theory it should support doing DMA via a custom DMA controller. If anybody ever chooses to fix that they can do it by adding support for setting both FDCtrl::dma_chann and FDCtrl::dma. (A QOM link property 'dma-controller' on the sysbus device which can be set to an instance of IsaDmaClass is probably the way to go.)

Fixes 1430759ec3 ("hw/block/fdc: Extract SysBus floppy controllers to fdc-sysbus.c")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/958

Message-Id: <[email protected]>

---
 hw/block/fdc-sysbus.c  | 16 +++++++++++-----
 hw/mips/jazz.c         |  2 +-
 include/hw/block/fdc.h |  3 +--
 3 files changed, 13 insertions(+), 8 deletions(-)
hw/block/fdc-sysbus.c +11 -5
index 57fc8773f1..86ea51d003 100644
@@ -94,18 +94,14 @@ static void fdctrl_handle_tc(void *opaque, int irq, int level)
     trace_fdctrl_tc_pulse(level);
 }
 
-void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
-                        hwaddr mmio_base, DriveInfo **fds)
+void fdctrl_init_sysbus(qemu_irq irq, hwaddr mmio_base, DriveInfo **fds)
 {
-    FDCtrl *fdctrl;
     DeviceState *dev;
     SysBusDevice *sbd;
     FDCtrlSysBus *sys;
 
     dev = qdev_new("sysbus-fdc");
     sys = SYSBUS_FDC(dev);
-    fdctrl = &sys->state;
-    fdctrl->dma_chann = dma_chann; /* FIXME */
     sbd = SYS_BUS_DEVICE(dev);
     sysbus_realize_and_unref(sbd, &error_fatal);
     sysbus_connect_irq(sbd, 0, irq);
@@ -138,6 +134,16 @@ static void sysbus_fdc_common_instance_init(Object *obj)
     FDCtrlSysBus *sys = SYSBUS_FDC(obj);
     FDCtrl *fdctrl = &sys->state;
 
+    /*
+     * DMA is not currently supported for sysbus floppy controllers.
+     * If we wanted to add support then probably the best approach is
+     * to have a QOM link property 'dma-controller' which the board
+     * code can set to an instance of IsaDmaClass, and an integer
+     * property 'dma-channel', so that we can set fdctrl->dma and
+     * fdctrl->dma_chann accordingly.
+     */
+    fdctrl->dma_chann = -1;
+
     qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */
 
     memory_region_init_io(&fdctrl->iomem, obj,
hw/mips/jazz.c +1 -1
index 6598d7dddd..96dc6ab32d 100644
@@ -353,7 +353,7 @@ static void mips_jazz_init(MachineState *machine,
         fds[n] = drive_get(IF_FLOPPY, 0, n);
     }
     /* FIXME: we should enable DMA with a custom IsaDma device */
-    fdctrl_init_sysbus(qdev_get_gpio_in(rc4030, 1), -1, 0x80003000, fds);
+    fdctrl_init_sysbus(qdev_get_gpio_in(rc4030, 1), 0x80003000, fds);
 
     /* Real time clock */
     mc146818_rtc_init(isa_bus, 1980, NULL);
include/hw/block/fdc.h +1 -2
index 1ecca7cac7..35248c0837 100644
@@ -10,8 +10,7 @@
 #define TYPE_ISA_FDC "isa-fdc"
 
 void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds);
-void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
-                        hwaddr mmio_base, DriveInfo **fds);
+void fdctrl_init_sysbus(qemu_irq irq, hwaddr mmio_base, DriveInfo **fds);
 void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
                        DriveInfo **fds, qemu_irq *fdc_tc);
 
Signature · 1 line
2.36.1
#19 lore raw

[PULL 26/49] hw/acpi/piix4: remove unused piix4_pm_initfn() function

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

This function is now unused and so can be completely removed.

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c               | 19 -------------------
 include/hw/southbridge/piix.h |  4 ----
 2 files changed, 23 deletions(-)
hw/acpi/piix4.c +0 -19
index 32033bc9d7..0a81f1ad93 100644
@@ -505,25 +505,6 @@ static void piix4_pm_init(Object *obj)
     qdev_init_gpio_out_named(DEVICE(obj), &s->smi_irq, "smi-irq", 1);
 }
 
-PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                              bool smm_enabled)
-{
-    PCIDevice *pci_dev;
-    DeviceState *dev;
-    PIIX4PMState *s;
-
-    pci_dev = pci_new(devfn, TYPE_PIIX4_PM);
-    dev = DEVICE(pci_dev);
-    qdev_prop_set_uint32(dev, "smb_io_base", smb_io_base);
-    qdev_prop_set_bit(dev, "smm-enabled", smm_enabled);
-
-    s = PIIX4_PM(dev);
-
-    pci_realize_and_unref(pci_dev, bus, &error_fatal);
-
-    return s;
-}
-
 static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
 {
     PIIX4PMState *s = opaque;
include/hw/southbridge/piix.h +0 -4
index b69e0dfb04..976b4da582 100644
@@ -14,10 +14,6 @@
 
 #include "hw/pci/pci.h"
 #include "qom/object.h"
-#include "hw/acpi/piix4.h"
-
-PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                              bool smm_enabled);
 
 /* PIRQRC[A:D]: PIRQx Route Control Registers */
 #define PIIX_PIRQCA 0x60
Signature · 1 line
2.36.1
#20 lore raw

[PULL 19/49] hw/acpi/piix4: move PIIX4PMState into separate piix4.h header

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

This allows the QOM types in hw/acpi/piix4.c to be used elsewhere by simply including hw/acpi/piix4.h.

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c               | 43 +-------------------
 hw/i386/acpi-build.c          |  1 +
 include/hw/acpi/piix4.h       | 75 +++++++++++++++++++++++++++++++++++
 include/hw/southbridge/piix.h |  2 -
 4 files changed, 78 insertions(+), 43 deletions(-)
 create mode 100644 include/hw/acpi/piix4.h
hw/acpi/piix4.c +2 -41
index 316e41e1d0..c2177c5093 100644
@@ -28,6 +28,8 @@
 #include "hw/pci/pci.h"
 #include "hw/qdev-properties.h"
 #include "hw/acpi/acpi.h"
+#include "hw/acpi/pcihp.h"
+#include "hw/acpi/piix4.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/xen.h"
@@ -56,47 +58,6 @@ struct pci_status {
     uint32_t down;
 };
 
-struct PIIX4PMState {
-    /*< private >*/
-    PCIDevice parent_obj;
-    /*< public >*/
-
-    MemoryRegion io;
-    uint32_t io_base;
-
-    MemoryRegion io_gpe;
-    ACPIREGS ar;
-
-    APMState apm;
-
-    PMSMBus smb;
-    uint32_t smb_io_base;
-
-    qemu_irq irq;
-    qemu_irq smi_irq;
-    bool smm_enabled;
-    bool smm_compat;
-    Notifier machine_ready;
-    Notifier powerdown_notifier;
-
-    AcpiPciHpState acpi_pci_hotplug;
-    bool use_acpi_hotplug_bridge;
-    bool use_acpi_root_pci_hotplug;
-    bool not_migrate_acpi_index;
-
-    uint8_t disable_s3;
-    uint8_t disable_s4;
-    uint8_t s4_val;
-
-    bool cpu_hotplug_legacy;
-    AcpiCpuHotplug gpe_cpu;
-    CPUHotplugState cpuhp_state;
-
-    MemHotplugState acpi_memory_hotplug;
-};
-
-OBJECT_DECLARE_SIMPLE_TYPE(PIIX4PMState, PIIX4_PM)
-
 static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
                                            PCIBus *bus, PIIX4PMState *s);
 
hw/i386/acpi-build.c +1 -0
index 73d0bf5937..cad6f5ac41 100644
@@ -44,6 +44,7 @@
 #include "hw/acpi/tpm.h"
 #include "hw/acpi/vmgenid.h"
 #include "hw/acpi/erst.h"
+#include "hw/acpi/piix4.h"
 #include "sysemu/tpm_backend.h"
 #include "hw/rtc/mc146818rtc_regs.h"
 #include "migration/vmstate.h"
include/hw/acpi/piix4.h new file +75 -0

75 lines not on this page · raw message

include/hw/southbridge/piix.h +0 -2
index ff8d96ae8c..04cbc3fe30 100644
@@ -15,8 +15,6 @@
 #include "hw/pci/pci.h"
 #include "qom/object.h"
 
-#define TYPE_PIIX4_PM "PIIX4_PM"
-
 I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                       qemu_irq sci_irq, qemu_irq smi_irq,
                       bool smm_enabled, DeviceState **piix4_pm);
Signature · 1 line
2.36.1
#21 lore raw

[PULL 20/49] hw/acpi/piix4: alter piix4_pm_init() to return PIIX4PMState

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

This exposes the PIIX4_PM device to the caller to allow any qdev gpios to be mapped outside of piix4_pm_init().

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c               | 11 ++++-------
 hw/i386/pc_piix.c             | 10 +++++-----
 hw/isa/piix4.c                |  8 +++++---
 include/hw/southbridge/piix.h |  7 ++++---
 4 files changed, 18 insertions(+), 18 deletions(-)
hw/acpi/piix4.c +4 -7
index c2177c5093..c4cfb75020 100644
@@ -497,9 +497,9 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
     piix4_pm_add_properties(s);
 }
 
-I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                      qemu_irq sci_irq, qemu_irq smi_irq,
-                      bool smm_enabled, DeviceState **piix4_pm)
+PIIX4PMState *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
+                            qemu_irq sci_irq, qemu_irq smi_irq,
+                            bool smm_enabled)
 {
     PCIDevice *pci_dev;
     DeviceState *dev;
@@ -509,9 +509,6 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
     dev = DEVICE(pci_dev);
     qdev_prop_set_uint32(dev, "smb_io_base", smb_io_base);
     qdev_prop_set_bit(dev, "smm-enabled", smm_enabled);
-    if (piix4_pm) {
-        *piix4_pm = dev;
-    }
 
     s = PIIX4_PM(dev);
     s->irq = sci_irq;
@@ -519,7 +516,7 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 
     pci_realize_and_unref(pci_dev, bus, &error_fatal);
 
-    return s->smb.smbus;
+    return s;
 }
 
 static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
hw/i386/pc_piix.c +5 -5
index bd63511c1c..3359b40f54 100644
@@ -280,14 +280,14 @@ static void pc_init1(MachineState *machine,
     }
 
     if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
-        DeviceState *piix4_pm;
+        PIIX4PMState *piix4_pm;
 
         smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
+        piix4_pm = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
+                                 x86ms->gsi[9], smi_irq,
+                                 x86_machine_is_smm_enabled(x86ms));
+        pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(piix4_pm), "i2c"));
         /* TODO: Populate SPD eeprom data.  */
-        pcms->smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
-                                    x86ms->gsi[9], smi_irq,
-                                    x86_machine_is_smm_enabled(x86ms),
-                                    &piix4_pm);
         smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
 
         object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
hw/isa/piix4.c +5 -3
index 8607e0ac36..7d9bedd1bb 100644
@@ -293,6 +293,7 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 {
     PIIX4State *s;
+    PIIX4PMState *pms;
     PCIDevice *pci;
     DeviceState *dev;
     int devfn = PCI_DEVFN(10, 0);
@@ -310,9 +311,10 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 
     pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
     if (smbus) {
-        *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
-                               qdev_get_gpio_in_named(dev, "isa", 9),
-                               NULL, 0, NULL);
+        pms = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
+                            qdev_get_gpio_in_named(dev, "isa", 9),
+                            NULL, 0);
+        *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pms), "i2c"));
     }
 
     pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
include/hw/southbridge/piix.h +4 -3
index 04cbc3fe30..a362ec7484 100644
@@ -14,10 +14,11 @@
 
 #include "hw/pci/pci.h"
 #include "qom/object.h"
+#include "hw/acpi/piix4.h"
 
-I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                      qemu_irq sci_irq, qemu_irq smi_irq,
-                      bool smm_enabled, DeviceState **piix4_pm);
+PIIX4PMState *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
+                            qemu_irq sci_irq, qemu_irq smi_irq,
+                            bool smm_enabled);
 
 /* PIRQRC[A:D]: PIRQx Route Control Registers */
 #define PIIX_PIRQCA 0x60
Signature · 1 line
2.36.1
#22 lore raw

[PULL 18/49] hw/acpi/piix4: convert smm_enabled bool to qdev property

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

This allows the smm_enabled value to be set using a standard qdev property instead of being referenced directly in piix4_pm_init().

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/acpi/piix4.c +2 -1
index 558c250884..316e41e1d0 100644
@@ -547,6 +547,7 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
     pci_dev = pci_new(devfn, TYPE_PIIX4_PM);
     dev = DEVICE(pci_dev);
     qdev_prop_set_uint32(dev, "smb_io_base", smb_io_base);
+    qdev_prop_set_bit(dev, "smm-enabled", smm_enabled);
     if (piix4_pm) {
         *piix4_pm = dev;
     }
@@ -554,7 +555,6 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
     s = PIIX4_PM(dev);
     s->irq = sci_irq;
     s->smi_irq = smi_irq;
-    s->smm_enabled = smm_enabled;
 
     pci_realize_and_unref(pci_dev, bus, &error_fatal);
 
@@ -664,6 +664,7 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),
     DEFINE_PROP_BOOL("smm-compat", PIIX4PMState, smm_compat, false),
+    DEFINE_PROP_BOOL("smm-enabled", PIIX4PMState, smm_enabled, false),
     DEFINE_PROP_BOOL("x-not-migrate-acpi-index", PIIX4PMState,
                       not_migrate_acpi_index, false),
     DEFINE_PROP_END_OF_LIST(),
Signature · 1 line
2.36.1
#23 lore raw

[PULL 30/49] hw/isa/piix4: QOM'ify PCI device creation and wiring

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

PCI interrupt wiring and device creation were performed in create() functions which are obsolete. Move these tasks into QOM functions to modernize the code.

Message-Id: <[email protected]>

---
 hw/isa/piix4.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)
hw/isa/piix4.c +22 -8
index 18aa24424f..058bebb5e2 100644
@@ -35,6 +35,7 @@
 #include "hw/rtc/mc146818rtc.h"
 #include "hw/ide/pci.h"
 #include "hw/acpi/piix4.h"
+#include "hw/usb/hcd-uhci.h"
 #include "migration/vmstate.h"
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
@@ -46,6 +47,8 @@ struct PIIX4State {
     qemu_irq *isa;
 
     RTCState rtc;
+    PCIIDEState ide;
+    UHCIState uhci;
     /* Reset Control Register */
     MemoryRegion rcr_mem;
     uint8_t rcr;
@@ -205,6 +208,7 @@ static const MemoryRegionOps piix4_rcr_ops = {
 static void piix4_realize(PCIDevice *dev, Error **errp)
 {
     PIIX4State *s = PIIX4_PCI_DEVICE(dev);
+    PCIBus *pci_bus = pci_get_bus(dev);
     ISABus *isa_bus;
     qemu_irq *i8259_out_irq;
 
@@ -243,6 +247,21 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
         return;
     }
     s->rtc.irq = isa_get_irq(ISA_DEVICE(&s->rtc), s->rtc.isairq);
+
+    /* IDE */
+    qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1);
+    if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) {
+        return;
+    }
+    pci_ide_create_devs(PCI_DEVICE(&s->ide));
+
+    /* USB */
+    qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2);
+    if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) {
+        return;
+    }
+
+    pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
 }
 
 static void piix4_init(Object *obj)
@@ -250,6 +269,8 @@ static void piix4_init(Object *obj)
     PIIX4State *s = PIIX4_PCI_DEVICE(obj);
 
     object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
+    object_initialize_child(obj, "ide", &s->ide, "piix4-ide");
+    object_initialize_child(obj, "uhci", &s->uhci, "piix4-usb-uhci");
 }
 
 static void piix4_class_init(ObjectClass *klass, void *data)
@@ -293,7 +314,6 @@ type_init(piix4_register_types)
 
 DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 {
-    PIIX4State *s;
     PCIDevice *pci;
     DeviceState *dev;
     int devfn = PCI_DEVFN(10, 0);
@@ -301,15 +321,11 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
     pci = pci_create_simple_multifunction(pci_bus, devfn,  true,
                                           TYPE_PIIX4_PCI_DEVICE);
     dev = DEVICE(pci);
-    s = PIIX4_PCI_DEVICE(pci);
+
     if (isa_bus) {
         *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
     }
 
-    pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide");
-    pci_ide_create_devs(pci);
-
-    pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
     if (smbus) {
         pci = pci_new(devfn + 3, TYPE_PIIX4_PM);
         qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100);
@@ -320,7 +336,5 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
         *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pci), "i2c"));
     }
 
-    pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
-
     return dev;
 }
Signature · 1 line
2.36.1
#24 lore raw

[PULL 21/49] hw/acpi/piix4: rename piix4_pm_init() to piix4_pm_initfn()

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

When QOMifying a device it is typical to use _init() as the suffix for an instance_init function, however this name is already in use by the legacy piix4_pm_init() wrapper function. Eventually the wrapper function will be removed, but for now rename it to piix4_pm_initfn() to avoid a naming collision.

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c               | 6 +++---
 hw/i386/pc_piix.c             | 6 +++---
 hw/isa/piix4.c                | 6 +++---
 include/hw/southbridge/piix.h | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)
hw/acpi/piix4.c +3 -3
index c4cfb75020..418ec4ee56 100644
@@ -497,9 +497,9 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
     piix4_pm_add_properties(s);
 }
 
-PIIX4PMState *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                            qemu_irq sci_irq, qemu_irq smi_irq,
-                            bool smm_enabled)
+PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
+                              qemu_irq sci_irq, qemu_irq smi_irq,
+                              bool smm_enabled)
 {
     PCIDevice *pci_dev;
     DeviceState *dev;
hw/i386/pc_piix.c +3 -3
index 3359b40f54..fde0fdc088 100644
@@ -283,9 +283,9 @@ static void pc_init1(MachineState *machine,
         PIIX4PMState *piix4_pm;
 
         smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
-        piix4_pm = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
-                                 x86ms->gsi[9], smi_irq,
-                                 x86_machine_is_smm_enabled(x86ms));
+        piix4_pm = piix4_pm_initfn(pci_bus, piix3_devfn + 3, 0xb100,
+                                   x86ms->gsi[9], smi_irq,
+                                   x86_machine_is_smm_enabled(x86ms));
         pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(piix4_pm), "i2c"));
         /* TODO: Populate SPD eeprom data.  */
         smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
hw/isa/piix4.c +3 -3
index 7d9bedd1bb..33a7015ea3 100644
@@ -311,9 +311,9 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 
     pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
     if (smbus) {
-        pms = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
-                            qdev_get_gpio_in_named(dev, "isa", 9),
-                            NULL, 0);
+        pms = piix4_pm_initfn(pci_bus, devfn + 3, 0x1100,
+                              qdev_get_gpio_in_named(dev, "isa", 9),
+                              NULL, 0);
         *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pms), "i2c"));
     }
 
include/hw/southbridge/piix.h +3 -3
index a362ec7484..f75a4adf5f 100644
@@ -16,9 +16,9 @@
 #include "qom/object.h"
 #include "hw/acpi/piix4.h"
 
-PIIX4PMState *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                            qemu_irq sci_irq, qemu_irq smi_irq,
-                            bool smm_enabled);
+PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
+                              qemu_irq sci_irq, qemu_irq smi_irq,
+                              bool smm_enabled);
 
 /* PIRQRC[A:D]: PIRQx Route Control Registers */
 #define PIIX_PIRQCA 0x60
Signature · 1 line
2.36.1
#25 lore raw

[PULL 27/49] hw/southbridge/piix: Aggregate all PIIX southbridge type names

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

TYPE_PIIX3_PCI_DEVICE resides there as already, so add the remaining ones, too.

Message-Id: <[email protected]>

---
 hw/isa/piix3.c                | 3 ---
 include/hw/isa/isa.h          | 2 --
 include/hw/southbridge/piix.h | 4 ++++
 3 files changed, 4 insertions(+), 5 deletions(-)
hw/isa/piix3.c +0 -3
index bfccd666d4..c92b36c4f2 100644
@@ -36,9 +36,6 @@
 
 #define XEN_PIIX_NUM_PIRQS      128ULL
 
-#define TYPE_PIIX3_DEVICE "PIIX3"
-#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen"
-
 static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
 {
     qemu_set_irq(piix3->pic[pic_irq],
include/hw/isa/isa.h +0 -2
index 6f9380007d..6c8a8a92cb 100644
@@ -129,6 +129,4 @@ static inline ISABus *isa_bus_from_device(ISADevice *d)
     return ISA_BUS(qdev_get_parent_bus(DEVICE(d)));
 }
 
-#define TYPE_PIIX4_PCI_DEVICE "piix4-isa"
-
 #endif
include/hw/southbridge/piix.h +4 -0
index 976b4da582..3b97186f75 100644
@@ -64,6 +64,10 @@ typedef struct PIIXState PIIX3State;
 DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
                          TYPE_PIIX3_PCI_DEVICE)
 
+#define TYPE_PIIX3_DEVICE "PIIX3"
+#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen"
+#define TYPE_PIIX4_PCI_DEVICE "piix4-isa"
+
 PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
 
 DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus);
Signature · 1 line
2.36.1
#26 lore raw

[PULL 22/49] hw/acpi/piix4: use qdev gpio to wire up sci_irq

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

Introduce piix4_pm_init() instance init function and use it to initialise the separate qdev gpio for the SCI IRQ.

The sci_irq can now be wired up directly using a qdev gpio instead of having to set the IRQ externally in piix4_pm_initfn().

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c               | 12 +++++++++---
 hw/i386/pc_piix.c             |  4 ++--
 hw/isa/piix4.c                |  6 +++---
 include/hw/southbridge/piix.h |  3 +--
 4 files changed, 15 insertions(+), 10 deletions(-)
hw/acpi/piix4.c +9 -3
index 418ec4ee56..fe5ec0a723 100644
@@ -497,9 +497,15 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
     piix4_pm_add_properties(s);
 }
 
+static void piix4_pm_init(Object *obj)
+{
+    PIIX4PMState *s = PIIX4_PM(obj);
+
+    qdev_init_gpio_out(DEVICE(obj), &s->irq, 1);
+}
+
 PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                              qemu_irq sci_irq, qemu_irq smi_irq,
-                              bool smm_enabled)
+                              qemu_irq smi_irq, bool smm_enabled)
 {
     PCIDevice *pci_dev;
     DeviceState *dev;
@@ -511,7 +517,6 @@ PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
     qdev_prop_set_bit(dev, "smm-enabled", smm_enabled);
 
     s = PIIX4_PM(dev);
-    s->irq = sci_irq;
     s->smi_irq = smi_irq;
 
     pci_realize_and_unref(pci_dev, bus, &error_fatal);
@@ -663,6 +668,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
 static const TypeInfo piix4_pm_info = {
     .name          = TYPE_PIIX4_PM,
     .parent        = TYPE_PCI_DEVICE,
+    .instance_init  = piix4_pm_init,
     .instance_size = sizeof(PIIX4PMState),
     .class_init    = piix4_pm_class_init,
     .interfaces = (InterfaceInfo[]) {
hw/i386/pc_piix.c +2 -2
index fde0fdc088..27acba4146 100644
@@ -283,9 +283,9 @@ static void pc_init1(MachineState *machine,
         PIIX4PMState *piix4_pm;
 
         smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
-        piix4_pm = piix4_pm_initfn(pci_bus, piix3_devfn + 3, 0xb100,
-                                   x86ms->gsi[9], smi_irq,
+        piix4_pm = piix4_pm_initfn(pci_bus, piix3_devfn + 3, 0xb100, smi_irq,
                                    x86_machine_is_smm_enabled(x86ms));
+        qdev_connect_gpio_out(DEVICE(piix4_pm), 0, x86ms->gsi[9]);
         pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(piix4_pm), "i2c"));
         /* TODO: Populate SPD eeprom data.  */
         smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
hw/isa/piix4.c +3 -3
index 33a7015ea3..0b6ea22143 100644
@@ -311,9 +311,9 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 
     pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
     if (smbus) {
-        pms = piix4_pm_initfn(pci_bus, devfn + 3, 0x1100,
-                              qdev_get_gpio_in_named(dev, "isa", 9),
-                              NULL, 0);
+        pms = piix4_pm_initfn(pci_bus, devfn + 3, 0x1100, NULL, 0);
+        qdev_connect_gpio_out(DEVICE(pms), 0,
+                              qdev_get_gpio_in_named(dev, "isa", 9));
         *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pms), "i2c"));
     }
 
include/hw/southbridge/piix.h +1 -2
index f75a4adf5f..105d158f78 100644
@@ -17,8 +17,7 @@
 #include "hw/acpi/piix4.h"
 
 PIIX4PMState *piix4_pm_initfn(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                              qemu_irq sci_irq, qemu_irq smi_irq,
-                              bool smm_enabled);
+                              qemu_irq smi_irq, bool smm_enabled);
 
 /* PIRQRC[A:D]: PIRQx Route Control Registers */
 #define PIIX_PIRQCA 0x60
Signature · 1 line
2.36.1
#27 lore raw

[PULL 31/49] hw/isa/piix4: Factor out ISABus retrieval from piix4_create()

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Modernizes the code.

Message-Id: <[email protected]>

---
 hw/isa/piix4.c                | 6 +-----
 hw/mips/malta.c               | 3 ++-
 include/hw/southbridge/piix.h | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)
hw/isa/piix4.c +1 -5
index 058bebb5e2..96df21a610 100644
@@ -312,7 +312,7 @@ static void piix4_register_types(void)
 
 type_init(piix4_register_types)
 
-DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
+DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus)
 {
     PCIDevice *pci;
     DeviceState *dev;
@@ -322,10 +322,6 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
                                           TYPE_PIIX4_PCI_DEVICE);
     dev = DEVICE(pci);
 
-    if (isa_bus) {
-        *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
-    }
-
     if (smbus) {
         pci = pci_new(devfn + 3, TYPE_PIIX4_PM);
         qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100);
hw/mips/malta.c +2 -1
index 9ffdc5b8f1..e446b25ad0 100644
@@ -1399,7 +1399,8 @@ void mips_malta_init(MachineState *machine)
     empty_slot_init("GT64120", 0, 0x20000000);
 
     /* Southbridge */
-    dev = piix4_create(pci_bus, &isa_bus, &smbus);
+    dev = piix4_create(pci_bus, &smbus);
+    isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
 
     /* Interrupt controller */
     qdev_connect_gpio_out_named(dev, "intr", 0, i8259_irq);
include/hw/southbridge/piix.h +1 -1
index 3b97186f75..dab5c9704e 100644
@@ -70,6 +70,6 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
 
 PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
 
-DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus);
+DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus);
 
 #endif
Signature · 1 line
2.36.1
#28 lore raw

[PULL 24/49] hw/i386/pc_piix: create PIIX4_PM device directly instead of using piix4_pm_initfn()

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

Now that all external logic has been removed from piix4_pm_initfn() the PIIX4_PM device can be instantiated directly.

Message-Id: <[email protected]>

---
 hw/i386/pc_piix.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +8 -3
index 89c4f07c9f..7d5546600b 100644
@@ -47,6 +47,7 @@
 #include "hw/xen/xen-x86.h"
 #include "exec/memory.h"
 #include "hw/acpi/acpi.h"
+#include "hw/acpi/piix4.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "sysemu/xen.h"
@@ -280,11 +281,15 @@ static void pc_init1(MachineState *machine,
     }
 
     if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
-        PIIX4PMState *piix4_pm;
+        PCIDevice *piix4_pm;
 
         smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
-        piix4_pm = piix4_pm_initfn(pci_bus, piix3_devfn + 3, 0xb100,
-                                   x86_machine_is_smm_enabled(x86ms));
+        piix4_pm = pci_new(piix3_devfn + 3, TYPE_PIIX4_PM);
+        qdev_prop_set_uint32(DEVICE(piix4_pm), "smb_io_base", 0xb100);
+        qdev_prop_set_bit(DEVICE(piix4_pm), "smm-enabled",
+                          x86_machine_is_smm_enabled(x86ms));
+        pci_realize_and_unref(piix4_pm, pci_bus, &error_fatal);
+
         qdev_connect_gpio_out(DEVICE(piix4_pm), 0, x86ms->gsi[9]);
         qdev_connect_gpio_out_named(DEVICE(piix4_pm), "smi-irq", 0, smi_irq);
         pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(piix4_pm), "i2c"));
Signature · 1 line
2.36.1
#29 lore raw

[PULL 36/49] hw/isa/piix3: Factor out ISABus retrieval from piix3_create()

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Modernizes the code.

Message-Id: <[email protected]>

---
 hw/i386/pc_piix.c             | 3 ++-
 hw/isa/piix3.c                | 3 +--
 include/hw/southbridge/piix.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
hw/i386/pc_piix.c +2 -1
index 7d5546600b..70c337c44b 100644
@@ -207,9 +207,10 @@ static void pc_init1(MachineState *machine,
                               pci_memory, ram_memory);
         pcms->bus = pci_bus;
 
-        piix3 = piix3_create(pci_bus, &isa_bus);
+        piix3 = piix3_create(pci_bus);
         piix3->pic = x86ms->gsi;
         piix3_devfn = piix3->dev.devfn;
+        isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
     } else {
         pci_bus = NULL;
         i440fx_state = NULL;
hw/isa/piix3.c +1 -2
index 89064eb837..d57a7fe6d6 100644
@@ -417,7 +417,7 @@ static void piix3_register_types(void)
 
 type_init(piix3_register_types)
 
-PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus)
+PIIX3State *piix3_create(PCIBus *pci_bus)
 {
     PIIX3State *piix3;
     PCIDevice *pci_dev;
@@ -426,7 +426,6 @@ PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus)
 
     pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type);
     piix3 = PIIX3_PCI_DEVICE(pci_dev);
-    *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
 
     return piix3;
 }
include/hw/southbridge/piix.h +1 -1
index 9a2dd93c2d..f805fb8683 100644
@@ -68,6 +68,6 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
 #define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen"
 #define TYPE_PIIX4_PCI_DEVICE "piix4-isa"
 
-PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
+PIIX3State *piix3_create(PCIBus *pci_bus);
 
 #endif
Signature · 1 line
2.36.1
#30 lore raw

[PULL 25/49] hw/isa/piix4.c: create PIIX4_PM device directly instead of using piix4_pm_initfn()

In reply to Philippe Mathieu-Daudé

From: Mark Cave-Ayland <[email protected]>

Now that all external logic has been removed from piix4_pm_initfn() the PIIX4_PM device can be instantiated directly.

Message-Id: <[email protected]>

---
 hw/isa/piix4.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
hw/isa/piix4.c +7 -4
index 775e15eb20..9a6d981037 100644
@@ -34,6 +34,7 @@
 #include "hw/timer/i8254.h"
 #include "hw/rtc/mc146818rtc.h"
 #include "hw/ide/pci.h"
+#include "hw/acpi/piix4.h"
 #include "migration/vmstate.h"
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
@@ -293,7 +294,6 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 {
     PIIX4State *s;
-    PIIX4PMState *pms;
     PCIDevice *pci;
     DeviceState *dev;
     int devfn = PCI_DEVFN(10, 0);
@@ -311,10 +311,13 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 
     pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
     if (smbus) {
-        pms = piix4_pm_initfn(pci_bus, devfn + 3, 0x1100, 0);
-        qdev_connect_gpio_out(DEVICE(pms), 0,
+        pci = pci_new(devfn + 3, TYPE_PIIX4_PM);
+        qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100);
+        qdev_prop_set_bit(DEVICE(pci), "smm-enabled", 0);
+        pci_realize_and_unref(pci, pci_bus, &error_fatal);
+        qdev_connect_gpio_out(DEVICE(pci), 0,
                               qdev_get_gpio_in_named(dev, "isa", 9));
-        *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pms), "i2c"));
+        *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pci), "i2c"));
     }
 
     pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
Signature · 1 line
2.36.1
#31 lore raw

[PULL 33/49] hw/isa/piix4: Inline and remove piix4_create()

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

During the previous changesets piix4_create() became a trivial wrapper around more generic functions. Modernize the code.

Message-Id: <[email protected]>

---
 hw/isa/piix4.c                | 13 -------------
 hw/mips/malta.c               |  5 ++++-
 include/hw/southbridge/piix.h |  2 --
 3 files changed, 4 insertions(+), 16 deletions(-)
hw/isa/piix4.c +0 -13
index d97b245df3..15f344dbb7 100644
@@ -323,16 +323,3 @@ static void piix4_register_types(void)
 }
 
 type_init(piix4_register_types)
-
-DeviceState *piix4_create(PCIBus *pci_bus)
-{
-    PCIDevice *pci;
-    DeviceState *dev;
-    int devfn = PCI_DEVFN(10, 0);
-
-    pci = pci_create_simple_multifunction(pci_bus, devfn,  true,
-                                          TYPE_PIIX4_PCI_DEVICE);
-    dev = DEVICE(pci);
-
-    return dev;
-}
hw/mips/malta.c +4 -1
index be9f26d841..7a0ec513b0 100644
@@ -1237,6 +1237,7 @@ void mips_malta_init(MachineState *machine)
     int fl_idx = 0;
     int be;
     MaltaState *s;
+    PCIDevice *piix4;
     DeviceState *dev;
     DeviceState *pm_dev;
 
@@ -1400,7 +1401,9 @@ void mips_malta_init(MachineState *machine)
     empty_slot_init("GT64120", 0, 0x20000000);
 
     /* Southbridge */
-    dev = piix4_create(pci_bus);
+    piix4 = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0), true,
+                                            TYPE_PIIX4_PCI_DEVICE);
+    dev = DEVICE(piix4);
     isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
     pm_dev = DEVICE(object_resolve_path_component(OBJECT(dev), "pm"));
     smbus = I2C_BUS(qdev_get_child_bus(pm_dev, "i2c"));
include/hw/southbridge/piix.h +0 -2
index 2357ce0287..9a2dd93c2d 100644
@@ -70,6 +70,4 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
 
 PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
 
-DeviceState *piix4_create(PCIBus *pci_bus);
-
 #endif
Signature · 1 line
2.36.1
#32 lore raw

[PULL 29/49] hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

The pci_map_irq_fn was implemented below type_init() which made it inaccessible to QOM functions. So move it up.

Message-Id: <[email protected]>

---
 hw/isa/piix4.c | 50 +++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)
hw/isa/piix4.c +25 -25
index 1d04fb6a55..18aa24424f 100644
@@ -74,6 +74,31 @@ static void piix4_set_irq(void *opaque, int irq_num, int level)
     }
 }
 
+static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
+{
+    int slot;
+
+    slot = PCI_SLOT(pci_dev->devfn);
+
+    switch (slot) {
+    /* PIIX4 USB */
+    case 10:
+        return 3;
+    /* AMD 79C973 Ethernet */
+    case 11:
+        return 1;
+    /* Crystal 4281 Sound */
+    case 12:
+        return 2;
+    /* PCI slot 1 to 4 */
+    case 18 ... 21:
+        return ((slot - 18) + irq_num) & 0x03;
+    /* Unknown device, don't do any translation */
+    default:
+        return irq_num;
+    }
+}
+
 static void piix4_isa_reset(DeviceState *dev)
 {
     PIIX4State *d = PIIX4_PCI_DEVICE(dev);
@@ -266,31 +291,6 @@ static void piix4_register_types(void)
 
 type_init(piix4_register_types)
 
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
-{
-    int slot;
-
-    slot = PCI_SLOT(pci_dev->devfn);
-
-    switch (slot) {
-    /* PIIX4 USB */
-    case 10:
-        return 3;
-    /* AMD 79C973 Ethernet */
-    case 11:
-        return 1;
-    /* Crystal 4281 Sound */
-    case 12:
-        return 2;
-    /* PCI slot 1 to 4 */
-    case 18 ... 21:
-        return ((slot - 18) + irq_num) & 0x03;
-    /* Unknown device, don't do any translation */
-    default:
-        return irq_num;
-    }
-}
-
 DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
 {
     PIIX4State *s;
Signature · 1 line
2.36.1
#33 lore raw

[PULL 41/49] hw: Reuse TYPE_I8042 define

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

TYPE_I8042 is exported, so reuse it for consistency.

Message-Id: <[email protected]>

---
 hw/i386/pc.c       | 4 ++--
 hw/sparc64/sun4u.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/i386/pc.c +2 -2
index 1b6067ff22..af9e5edb04 100644
@@ -1097,7 +1097,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl,
         return;
     }
 
-    i8042 = isa_create_simple(isa_bus, "i8042");
+    i8042 = isa_create_simple(isa_bus, TYPE_I8042);
     if (!no_vmport) {
         isa_create_simple(isa_bus, TYPE_VMPORT);
         vmmouse = isa_try_new("vmmouse");
@@ -1105,7 +1105,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl,
         vmmouse = NULL;
     }
     if (vmmouse) {
-        object_property_set_link(OBJECT(vmmouse), "i8042", OBJECT(i8042),
+        object_property_set_link(OBJECT(vmmouse), TYPE_I8042, OBJECT(i8042),
                                  &error_abort);
         isa_realize_and_unref(vmmouse, isa_bus, &error_fatal);
     }
hw/sparc64/sun4u.c +1 -1
index d1bc77d27e..0e27715ac4 100644
@@ -334,7 +334,7 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp)
     parallel_hds_isa_init(s->isa_bus, MAX_PARALLEL_PORTS);
 
     /* Keyboard */
-    isa_create_simple(s->isa_bus, "i8042");
+    isa_create_simple(s->isa_bus, TYPE_I8042);
 
     /* Floppy */
     for (i = 0; i < MAX_FD; i++) {
Signature · 1 line
2.36.1
#34 lore raw

[PULL 28/49] hw/isa/piix4: Use object_initialize_child() for embedded struct

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Message-Id: <[email protected]>

---
 hw/isa/piix4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/isa/piix4.c +1 -1
index 9a6d981037..1d04fb6a55 100644
@@ -224,7 +224,7 @@ static void piix4_init(Object *obj)
 {
     PIIX4State *s = PIIX4_PCI_DEVICE(obj);
 
-    object_initialize(&s->rtc, sizeof(s->rtc), TYPE_MC146818_RTC);
+    object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
 }
 
 static void piix4_class_init(ObjectClass *klass, void *data)
Signature · 1 line
2.36.1
#35 lore raw

[PULL 39/49] hw/i386/microvm-dt: Determine mc146818rtc's IRQ number from QOM property

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Since commit 3b004a16540aa41f2aa6a1ceb0bf306716766914 'hw/rtc/
mc146818rtc: QOM'ify IRQ number' mc146818rtc's IRQ number is configurable. Fix microvm-dt to respect its value.

Message-Id: <[email protected]>

---
 hw/i386/microvm-dt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/microvm-dt.c +1 -1
index fde74819f2..287818c641 100644
@@ -209,7 +209,7 @@ static void dt_add_isa_serial(MicrovmMachineState *mms, ISADevice *dev)
 static void dt_add_isa_rtc(MicrovmMachineState *mms, ISADevice *dev)
 {
     const char compat[] = "motorola,mc146818";
-    uint32_t irq = RTC_ISA_IRQ;
+    uint32_t irq = object_property_get_uint(OBJECT(dev), "irq", &error_fatal);
     hwaddr base = RTC_ISA_BASE;
     hwaddr size = 8;
     char *nodename;
Signature · 1 line
2.36.1
#36 lore raw

[PULL 32/49] hw/isa/piix4: QOM'ify PIIX4 PM creation

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Just like the real hardware, create the PIIX4 ACPI controller as part of the PIIX4 southbridge. This also mirrors how the IDE and USB functions are already created.

Message-Id: <[email protected]>

---
 hw/isa/piix4.c                | 24 +++++++++++++-----------
 hw/mips/malta.c               |  5 ++++-
 include/hw/southbridge/piix.h |  2 +-
 3 files changed, 18 insertions(+), 13 deletions(-)
hw/isa/piix4.c +13 -11
index 96df21a610..d97b245df3 100644
@@ -49,6 +49,7 @@ struct PIIX4State {
     RTCState rtc;
     PCIIDEState ide;
     UHCIState uhci;
+    PIIX4PMState pm;
     /* Reset Control Register */
     MemoryRegion rcr_mem;
     uint8_t rcr;
@@ -261,6 +262,13 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
         return;
     }
 
+    /* ACPI controller */
+    qdev_prop_set_int32(DEVICE(&s->pm), "addr", dev->devfn + 3);
+    if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
+        return;
+    }
+    qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]);
+
     pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
 }
 
@@ -271,6 +279,10 @@ static void piix4_init(Object *obj)
     object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
     object_initialize_child(obj, "ide", &s->ide, "piix4-ide");
     object_initialize_child(obj, "uhci", &s->uhci, "piix4-usb-uhci");
+
+    object_initialize_child(obj, "pm", &s->pm, TYPE_PIIX4_PM);
+    qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", 0x1100);
+    qdev_prop_set_bit(DEVICE(&s->pm), "smm-enabled", 0);
 }
 
 static void piix4_class_init(ObjectClass *klass, void *data)
@@ -312,7 +324,7 @@ static void piix4_register_types(void)
 
 type_init(piix4_register_types)
 
-DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus)
+DeviceState *piix4_create(PCIBus *pci_bus)
 {
     PCIDevice *pci;
     DeviceState *dev;
@@ -322,15 +334,5 @@ DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus)
                                           TYPE_PIIX4_PCI_DEVICE);
     dev = DEVICE(pci);
 
-    if (smbus) {
-        pci = pci_new(devfn + 3, TYPE_PIIX4_PM);
-        qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100);
-        qdev_prop_set_bit(DEVICE(pci), "smm-enabled", 0);
-        pci_realize_and_unref(pci, pci_bus, &error_fatal);
-        qdev_connect_gpio_out(DEVICE(pci), 0,
-                              qdev_get_gpio_in_named(dev, "isa", 9));
-        *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pci), "i2c"));
-    }
-
     return dev;
 }
hw/mips/malta.c +4 -1
index e446b25ad0..be9f26d841 100644
@@ -1238,6 +1238,7 @@ void mips_malta_init(MachineState *machine)
     int be;
     MaltaState *s;
     DeviceState *dev;
+    DeviceState *pm_dev;
 
     s = MIPS_MALTA(qdev_new(TYPE_MIPS_MALTA));
     sysbus_realize_and_unref(SYS_BUS_DEVICE(s), &error_fatal);
@@ -1399,8 +1400,10 @@ void mips_malta_init(MachineState *machine)
     empty_slot_init("GT64120", 0, 0x20000000);
 
     /* Southbridge */
-    dev = piix4_create(pci_bus, &smbus);
+    dev = piix4_create(pci_bus);
     isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
+    pm_dev = DEVICE(object_resolve_path_component(OBJECT(dev), "pm"));
+    smbus = I2C_BUS(qdev_get_child_bus(pm_dev, "i2c"));
 
     /* Interrupt controller */
     qdev_connect_gpio_out_named(dev, "intr", 0, i8259_irq);
include/hw/southbridge/piix.h +1 -1
index dab5c9704e..2357ce0287 100644
@@ -70,6 +70,6 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
 
 PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
 
-DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus);
+DeviceState *piix4_create(PCIBus *pci_bus);
 
 #endif
Signature · 1 line
2.36.1
#37 lore raw

[PULL 49/49] docs/devel: Fix link to developer mailing lists

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Ammends commit 9f73de8df0335c9387f4ee39e207a65a1615676f 'docs: rSTify the "SubmitAPatch" wiki'.

Message-Id: <[email protected]>

---
 docs/devel/submitting-a-patch.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
docs/devel/submitting-a-patch.rst +3 -3
index d3876ec1b7..09a8d12c2c 100644
@@ -18,9 +18,9 @@ one-shot fix, the bare minimum we ask is that:
    <http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1b33f0082ac22d71f66385a60d8157f#n297>`__
    policy.) ``git commit -s`` or ``git format-patch -s`` will add one.
 -  All contributions to QEMU must be **sent as patches** to the
-   qemu-devel `mailing list <MailingLists>`__. Patch contributions
-   should not be posted on the bug tracker, posted on forums, or
-   externally hosted and linked to. (We have other mailing lists too,
+   qemu-devel `mailing list <https://wiki.qemu.org/Contribute/MailingLists>`__.
+   Patch contributions should not be posted on the bug tracker, posted on
+   forums, or externally hosted and linked to. (We have other mailing lists too,
    but all patches must go to qemu-devel, possibly with a Cc: to another
    list.) ``git send-email`` (`step-by-step setup
    guide <https://git-send-email.io/>`__ and `hints and
Signature · 1 line
2.36.1
#38 lore raw

[PULL 34/49] hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

The pci_map_irq_fn was implemented below type_init() which made it inaccessible to QOM functions. So move it up.

Message-Id: <[email protected]>

---
 hw/isa/piix3.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
hw/isa/piix3.c +11 -11
index c92b36c4f2..d50a07b58b 100644
@@ -79,6 +79,17 @@ static void piix3_set_irq(void *opaque, int pirq, int level)
     piix3_set_irq_level(piix3, pirq, level);
 }
 
+/*
+ * Return the global irq number corresponding to a given device irq
+ * pin. We could also use the bus number to have a more precise mapping.
+ */
+static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
+{
+    int slot_addend;
+    slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
+    return (pci_intx + slot_addend) & 3;
+}
+
 static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int pin)
 {
     PIIX3State *piix3 = opaque;
@@ -367,17 +378,6 @@ static void piix3_register_types(void)
 
 type_init(piix3_register_types)
 
-/*
- * Return the global irq number corresponding to a given device irq
- * pin. We could also use the bus number to have a more precise mapping.
- */
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
-{
-    int slot_addend;
-    slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
-    return (pci_intx + slot_addend) & 3;
-}
-
 PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus)
 {
     PIIX3State *piix3;
Signature · 1 line
2.36.1
#39 lore raw

[PULL 45/49] hw/i386/pc: Remove orphan declarations

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Message-Id: <[email protected]>

---
 include/hw/i386/pc.h | 3 ---
 1 file changed, 3 deletions(-)
include/hw/i386/pc.h +0 -3
index eb3d093bca..b7735dccfc 100644
@@ -171,9 +171,6 @@ void pc_cmos_init(PCMachineState *pcms,
                   BusState *ide0, BusState *ide1,
                   ISADevice *s);
 void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus);
-void pc_pci_device_init(PCIBus *pci_bus);
-
-typedef void (*cpu_set_smm_t)(int smm, void *arg);
 
 void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs);
 
Signature · 1 line
2.36.1
#40 lore raw

[PULL 35/49] hw/isa/piix3: QOM'ify PCI device creation and wiring

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

PCI interrupt wiring was performed in create() functions which are obsolete. Move these tasks into QOM functions to modernize the code.

In order to avoid duplicate checking for xen_enabled() the realize methods are now split.

Message-Id: <[email protected]>

---
 hw/isa/piix3.c | 67 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 45 insertions(+), 22 deletions(-)
hw/isa/piix3.c +45 -22
index d50a07b58b..89064eb837 100644
@@ -24,6 +24,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/range.h"
+#include "qapi/error.h"
 #include "hw/southbridge/piix.h"
 #include "hw/irq.h"
 #include "hw/isa/isa.h"
@@ -278,7 +279,7 @@ static const MemoryRegionOps rcr_ops = {
     .endianness = DEVICE_LITTLE_ENDIAN
 };
 
-static void piix3_realize(PCIDevice *dev, Error **errp)
+static void pci_piix3_realize(PCIDevice *dev, Error **errp)
 {
     PIIX3State *d = PIIX3_PCI_DEVICE(dev);
 
@@ -317,7 +318,6 @@ static void pci_piix3_class_init(ObjectClass *klass, void *data)
     dc->desc        = "ISA bridge";
     dc->vmsd        = &vmstate_piix3;
     dc->hotpluggable   = false;
-    k->realize      = piix3_realize;
     k->vendor_id    = PCI_VENDOR_ID_INTEL;
     /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */
     k->device_id    = PCI_DEVICE_ID_INTEL_82371SB_0;
@@ -343,11 +343,28 @@ static const TypeInfo piix3_pci_type_info = {
     },
 };
 
+static void piix3_realize(PCIDevice *dev, Error **errp)
+{
+    ERRP_GUARD();
+    PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev);
+    PCIBus *pci_bus = pci_get_bus(dev);
+
+    pci_piix3_realize(dev, errp);
+    if (*errp) {
+        return;
+    }
+
+    pci_bus_irqs(pci_bus, piix3_set_irq, pci_slot_get_pirq,
+                 piix3, PIIX_NUM_PIRQS);
+    pci_bus_set_route_irq_fn(pci_bus, piix3_route_intx_pin_to_irq);
+};
+
 static void piix3_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
     k->config_write = piix3_write_config;
+    k->realize = piix3_realize;
 }
 
 static const TypeInfo piix3_info = {
@@ -356,11 +373,33 @@ static const TypeInfo piix3_info = {
     .class_init    = piix3_class_init,
 };
 
+static void piix3_xen_realize(PCIDevice *dev, Error **errp)
+{
+    ERRP_GUARD();
+    PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev);
+    PCIBus *pci_bus = pci_get_bus(dev);
+
+    pci_piix3_realize(dev, errp);
+    if (*errp) {
+        return;
+    }
+
+    /*
+     * Xen supports additional interrupt routes from the PCI devices to
+     * the IOAPIC: the four pins of each PCI device on the bus are also
+     * connected to the IOAPIC directly.
+     * These additional routes can be discovered through ACPI.
+     */
+    pci_bus_irqs(pci_bus, xen_piix3_set_irq, xen_pci_slot_get_pirq,
+                 piix3, XEN_PIIX_NUM_PIRQS);
+};
+
 static void piix3_xen_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
     k->config_write = piix3_write_config_xen;
+    k->realize = piix3_xen_realize;
 };
 
 static const TypeInfo piix3_xen_info = {
@@ -382,27 +421,11 @@ PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus)
 {
     PIIX3State *piix3;
     PCIDevice *pci_dev;
+    const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE
+                                     : TYPE_PIIX3_DEVICE;
 
-    /*
-     * Xen supports additional interrupt routes from the PCI devices to
-     * the IOAPIC: the four pins of each PCI device on the bus are also
-     * connected to the IOAPIC directly.
-     * These additional routes can be discovered through ACPI.
-     */
-    if (xen_enabled()) {
-        pci_dev = pci_create_simple_multifunction(pci_bus, -1, true,
-                                                  TYPE_PIIX3_XEN_DEVICE);
-        piix3 = PIIX3_PCI_DEVICE(pci_dev);
-        pci_bus_irqs(pci_bus, xen_piix3_set_irq, xen_pci_slot_get_pirq,
-                     piix3, XEN_PIIX_NUM_PIRQS);
-    } else {
-        pci_dev = pci_create_simple_multifunction(pci_bus, -1, true,
-                                                  TYPE_PIIX3_DEVICE);
-        piix3 = PIIX3_PCI_DEVICE(pci_dev);
-        pci_bus_irqs(pci_bus, piix3_set_irq, pci_slot_get_pirq,
-                     piix3, PIIX_NUM_PIRQS);
-        pci_bus_set_route_irq_fn(pci_bus, piix3_route_intx_pin_to_irq);
-    }
+    pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type);
+    piix3 = PIIX3_PCI_DEVICE(pci_dev);
     *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
 
     return piix3;
Signature · 1 line
2.36.1
#41 lore raw

[PULL 46/49] hw/net/fsl_etsec/etsec: Remove obsolete and unused etsec_create()

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

etsec_create() wraps qdev API which is outdated. It is also unused, so remove it.

Message-Id: <[email protected]>

---
 hw/net/fsl_etsec/etsec.c | 23 -----------------------
 hw/net/fsl_etsec/etsec.h |  7 -------
 2 files changed, 30 deletions(-)
hw/net/fsl_etsec/etsec.c +0 -23
index 4e6cc708de..b75d8e3dce 100644
@@ -443,26 +443,3 @@ static void etsec_register_types(void)
 }
 
 type_init(etsec_register_types)
-
-DeviceState *etsec_create(hwaddr         base,
-                          MemoryRegion * mr,
-                          NICInfo      * nd,
-                          qemu_irq       tx_irq,
-                          qemu_irq       rx_irq,
-                          qemu_irq       err_irq)
-{
-    DeviceState *dev;
-
-    dev = qdev_new("eTSEC");
-    qdev_set_nic_properties(dev, nd);
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
-
-    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, tx_irq);
-    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 1, rx_irq);
-    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 2, err_irq);
-
-    memory_region_add_subregion(mr, base,
-                                SYS_BUS_DEVICE(dev)->mmio[0].memory);
-
-    return dev;
-}
hw/net/fsl_etsec/etsec.h +0 -7
index fddf551544..3c625c955c 100644
@@ -155,13 +155,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(eTSEC, ETSEC_COMMON)
 #define eTSEC_TRANSMIT 1
 #define eTSEC_RECEIVE  2
 
-DeviceState *etsec_create(hwaddr        base,
-                          MemoryRegion *mr,
-                          NICInfo      *nd,
-                          qemu_irq      tx_irq,
-                          qemu_irq      rx_irq,
-                          qemu_irq      err_irq);
-
 void etsec_update_irq(eTSEC *etsec);
 
 void etsec_walk_tx_ring(eTSEC *etsec, int ring_nbr);
Signature · 1 line
2.36.1
#42 lore raw

[PULL 40/49] hw/rtc/mc146818rtc: QOM'ify io_base offset

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Exposing the io_base offset as a QOM property not only allows it to be configurable but also to be displayed in HMP:

Before:

(qemu) info qtree

       ...
          dev: mc146818rtc, id ""
            gpio-out "" 1
            base_year = 0 (0x0)
            irq = 8 (0x8)
            lost_tick_policy = "discard"

After:

          dev: mc146818rtc, id ""
            gpio-out "" 1
            base_year = 0 (0x0)
            iobase = 112 (0x70)
            irq = 8 (0x8)
            lost_tick_policy = "discard"

Message-Id: <[email protected]>

---
 hw/i386/microvm-dt.c         | 2 +-
 hw/rtc/mc146818rtc.c         | 9 ++++++---
 include/hw/rtc/mc146818rtc.h | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)
hw/i386/microvm-dt.c +1 -1
index 287818c641..b3049e4f9f 100644
@@ -210,7 +210,7 @@ static void dt_add_isa_rtc(MicrovmMachineState *mms, ISADevice *dev)
 {
     const char compat[] = "motorola,mc146818";
     uint32_t irq = object_property_get_uint(OBJECT(dev), "irq", &error_fatal);
-    hwaddr base = RTC_ISA_BASE;
+    hwaddr base = object_property_get_uint(OBJECT(dev), "iobase", &error_fatal);
     hwaddr size = 8;
     char *nodename;
 
hw/rtc/mc146818rtc.c +6 -3
index ef9765bb8f..1ebb412479 100644
@@ -74,6 +74,8 @@
 #define RTC_CLOCK_RATE            32768
 #define UIP_HOLD_LENGTH           (8 * NANOSECONDS_PER_SECOND / 32768)
 
+#define RTC_ISA_BASE 0x70
+
 static void rtc_set_time(RTCState *s);
 static void rtc_update_time(RTCState *s);
 static void rtc_set_cmos(RTCState *s, const struct tm *tm);
@@ -941,7 +943,7 @@ static void rtc_realizefn(DeviceState *dev, Error **errp)
     qemu_register_suspend_notifier(&s->suspend_notifier);
 
     memory_region_init_io(&s->io, OBJECT(s), &cmos_ops, s, "rtc", 2);
-    isa_register_ioport(isadev, &s->io, RTC_ISA_BASE);
+    isa_register_ioport(isadev, &s->io, s->io_base);
 
     /* register rtc 0x70 port for coalesced_pio */
     memory_region_set_flush_coalesced(&s->io);
@@ -950,7 +952,7 @@ static void rtc_realizefn(DeviceState *dev, Error **errp)
     memory_region_add_subregion(&s->io, 0, &s->coalesced_io);
     memory_region_add_coalescing(&s->coalesced_io, 0, 1);
 
-    qdev_set_legacy_instance_id(dev, RTC_ISA_BASE, 3);
+    qdev_set_legacy_instance_id(dev, s->io_base, 3);
 
     object_property_add_tm(OBJECT(s), "date", rtc_get_date);
 
@@ -983,6 +985,7 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
 
 static Property mc146818rtc_properties[] = {
     DEFINE_PROP_INT32("base_year", RTCState, base_year, 1980),
+    DEFINE_PROP_UINT16("iobase", RTCState, io_base, RTC_ISA_BASE),
     DEFINE_PROP_UINT8("irq", RTCState, isairq, RTC_ISA_IRQ),
     DEFINE_PROP_LOSTTICKPOLICY("lost_tick_policy", RTCState,
                                lost_tick_policy, LOST_TICK_POLICY_DISCARD),
@@ -1028,7 +1031,7 @@ static void rtc_build_aml(AcpiDevAmlIf *adev, Aml *scope)
      * does, even though qemu only responds to the first two ports.
      */
     crs = aml_resource_template();
-    aml_append(crs, aml_io(AML_DECODE16, RTC_ISA_BASE, RTC_ISA_BASE,
+    aml_append(crs, aml_io(AML_DECODE16, s->io_base, s->io_base,
                            0x01, 0x08));
     aml_append(crs, aml_irq_no_flags(s->isairq));
 
include/hw/rtc/mc146818rtc.h +1 -1
index 33d85753c0..1db0fcee92 100644
@@ -26,6 +26,7 @@ struct RTCState {
     uint8_t cmos_data[128];
     uint8_t cmos_index;
     uint8_t isairq;
+    uint16_t io_base;
     int32_t base_year;
     uint64_t base_rtc;
     uint64_t last_update;
@@ -49,7 +50,6 @@ struct RTCState {
 };
 
 #define RTC_ISA_IRQ 8
-#define RTC_ISA_BASE 0x70
 
 ISADevice *mc146818_rtc_init(ISABus *bus, int base_year,
                              qemu_irq intercept_irq);
Signature · 1 line
2.36.1
#43 lore raw

[PULL 37/49] hw/isa/piix3: Inline and remove piix3_create()

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

During the previous changesets piix3_create() became a trivial wrapper around more generic functions. Modernize the code.

Message-Id: <[email protected]>

---
 hw/i386/pc_piix.c             |  6 +++++-
 hw/isa/piix3.c                | 13 -------------
 include/hw/southbridge/piix.h |  2 --
 3 files changed, 5 insertions(+), 16 deletions(-)
hw/i386/pc_piix.c +5 -1
index 70c337c44b..0fc2361ffe 100644
@@ -197,6 +197,9 @@ static void pc_init1(MachineState *machine,
 
     if (pcmc->pci_enabled) {
         PIIX3State *piix3;
+        PCIDevice *pci_dev;
+        const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE
+                                         : TYPE_PIIX3_DEVICE;
 
         pci_bus = i440fx_init(host_type,
                               pci_type,
@@ -207,7 +210,8 @@ static void pc_init1(MachineState *machine,
                               pci_memory, ram_memory);
         pcms->bus = pci_bus;
 
-        piix3 = piix3_create(pci_bus);
+        pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type);
+        piix3 = PIIX3_PCI_DEVICE(pci_dev);
         piix3->pic = x86ms->gsi;
         piix3_devfn = piix3->dev.devfn;
         isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
hw/isa/piix3.c +0 -13
index d57a7fe6d6..6388558f92 100644
@@ -416,16 +416,3 @@ static void piix3_register_types(void)
 }
 
 type_init(piix3_register_types)
-
-PIIX3State *piix3_create(PCIBus *pci_bus)
-{
-    PIIX3State *piix3;
-    PCIDevice *pci_dev;
-    const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE
-                                     : TYPE_PIIX3_DEVICE;
-
-    pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type);
-    piix3 = PIIX3_PCI_DEVICE(pci_dev);
-
-    return piix3;
-}
include/hw/southbridge/piix.h +0 -2
index f805fb8683..2693778b23 100644
@@ -68,6 +68,4 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
 #define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen"
 #define TYPE_PIIX4_PCI_DEVICE "piix4-isa"
 
-PIIX3State *piix3_create(PCIBus *pci_bus);
-
 #endif
Signature · 1 line
2.36.1
#44 lore raw

[PULL 43/49] hw/i386/pc: Unexport PC_CPU_MODEL_IDS macro

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

The macro seems to be used only internally, so remove it.

Message-Id: <[email protected]>

---
 hw/i386/pc.c         | 9 +++++++++
 include/hw/i386/pc.h | 8 --------
 2 files changed, 9 insertions(+), 8 deletions(-)
hw/i386/pc.c +9 -0
index af9e5edb04..272d7227d5 100644
@@ -98,6 +98,15 @@
 #include "trace.h"
 #include CONFIG_DEVICES
 
+/*
+ * Helper for setting model-id for CPU models that changed model-id
+ * depending on QEMU versions up to QEMU 2.4.
+ */
+#define PC_CPU_MODEL_IDS(v) \
+    { "qemu32-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
+    { "qemu64-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
+    { "athlon-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },
+
 GlobalProperty pc_compat_7_0[] = {};
 const size_t pc_compat_7_0_len = G_N_ELEMENTS(pc_compat_7_0);
 
include/hw/i386/pc.h +0 -8
index 003a86b721..b58ac343ba 100644
@@ -288,14 +288,6 @@ extern const size_t pc_compat_1_5_len;
 extern GlobalProperty pc_compat_1_4[];
 extern const size_t pc_compat_1_4_len;
 
-/* Helper for setting model-id for CPU models that changed model-id
- * depending on QEMU versions up to QEMU 2.4.
- */
-#define PC_CPU_MODEL_IDS(v) \
-    { "qemu32-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
-    { "qemu64-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
-    { "athlon-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },
-
 #define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
     static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
     { \
Signature · 1 line
2.36.1
#45 lore raw

[PULL 38/49] hw/i386/microvm-dt: Force explicit failure if retrieving QOM property fails

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

New code will be added where this is best practice. So update existing code as well.

Message-Id: <[email protected]>

---
 hw/i386/microvm-dt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/i386/microvm-dt.c +3 -2
index 9c3c4995b4..fde74819f2 100644
@@ -32,6 +32,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/cutils.h"
+#include "qapi/error.h"
 #include "sysemu/device_tree.h"
 #include "hw/char/serial.h"
 #include "hw/i386/fw_cfg.h"
@@ -187,8 +188,8 @@ static void dt_add_ioapic(MicrovmMachineState *mms, SysBusDevice *dev)
 static void dt_add_isa_serial(MicrovmMachineState *mms, ISADevice *dev)
 {
     const char compat[] = "ns16550";
-    uint32_t irq = object_property_get_int(OBJECT(dev), "irq", NULL);
-    hwaddr base = object_property_get_int(OBJECT(dev), "iobase", NULL);
+    uint32_t irq = object_property_get_int(OBJECT(dev), "irq", &error_fatal);
+    hwaddr base = object_property_get_int(OBJECT(dev), "iobase", &error_fatal);
     hwaddr size = 8;
     char *nodename;
 
Signature · 1 line
2.36.1
#46 lore raw

[PULL 42/49] hw/audio/cs4231a: Const'ify global tables

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

The tables contain spcifically crafted constants for algorithms, so make them immutable.

Message-Id: <[email protected]>

---
 hw/audio/cs4231a.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/audio/cs4231a.c +4 -4
index 0723e39430..7f17a72a9c 100644
@@ -84,7 +84,7 @@ struct CSState {
     int transferred;
     int aci_counter;
     SWVoiceOut *voice;
-    int16_t *tab;
+    const int16_t *tab;
 };
 
 #define MODE2 (1 << 6)
@@ -142,13 +142,13 @@ enum {
     Capture_Lower_Base_Count
 };
 
-static int freqs[2][8] = {
+static const int freqs[2][8] = {
     { 8000, 16000, 27420, 32000,    -1,    -1, 48000, 9000 },
     { 5510, 11025, 18900, 22050, 37800, 44100, 33075, 6620 }
 };
 
 /* Tables courtesy http://hazelware.luggle.com/tutorials/mulawcompression.html */
-static int16_t MuLawDecompressTable[256] =
+static const int16_t MuLawDecompressTable[256] =
 {
      -32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956,
      -23932,-22908,-21884,-20860,-19836,-18812,-17788,-16764,
@@ -184,7 +184,7 @@ static int16_t MuLawDecompressTable[256] =
          56,    48,    40,    32,    24,    16,     8,     0
 };
 
-static int16_t ALawDecompressTable[256] =
+static const int16_t ALawDecompressTable[256] =
 {
      -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
      -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
Signature · 1 line
2.36.1
#47 lore raw

[PULL 44/49] hw/i386/pc: Unexport functions used only internally

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Message-Id: <[email protected]>

---
 hw/i386/pc.c         | 4 ++--
 include/hw/i386/pc.h | 3 ---
 2 files changed, 2 insertions(+), 5 deletions(-)
hw/i386/pc.c +2 -2
index 272d7227d5..774cb2bf07 100644
@@ -572,7 +572,7 @@ static const char * const fdc_container_path[] = {
  * Locate the FDC at IO address 0x3f0, in order to configure the CMOS registers
  * and ACPI objects.
  */
-ISADevice *pc_find_fdc0(void)
+static ISADevice *pc_find_fdc0(void)
 {
     int i;
     Object *container;
@@ -716,7 +716,7 @@ static const int ne2000_io[NE2000_NB_MAX] = { 0x300, 0x320, 0x340, 0x360,
                                               0x280, 0x380 };
 static const int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 };
 
-void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd)
+static void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd)
 {
     static int nb_ne2k = 0;
 
include/hw/i386/pc.h +0 -3
index b58ac343ba..eb3d093bca 100644
@@ -167,7 +167,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
                           uint32_t hpet_irqs);
-void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
 void pc_cmos_init(PCMachineState *pcms,
                   BusState *ide0, BusState *ide1,
                   ISADevice *s);
@@ -178,8 +177,6 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg);
 
 void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs);
 
-ISADevice *pc_find_fdc0(void);
-
 /* port92.c */
 #define PORT92_A20_LINE "a20"
 
Signature · 1 line
2.36.1
#48 lore raw

[PULL 47/49] accel/tcg/cpu-exec: Unexport dump_drift_info()

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Commit 3a841ab53f165910224dc4bebabf1a8f1d04200c 'qapi: introduce x-query-jit QMP command' basically moved the only function using dump_drift_info() to cpu-exec.c. Therefore, dump_drift_info() doesn't need to be exported any longer.

Message-Id: <[email protected]>

---
 accel/tcg/cpu-exec.c   | 2 +-
 include/exec/cpu-all.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
accel/tcg/cpu-exec.c +1 -1
index 635aeecc0a..7cbf9996b7 100644
@@ -1048,7 +1048,7 @@ void tcg_exec_unrealizefn(CPUState *cpu)
 
 #ifndef CONFIG_USER_ONLY
 
-void dump_drift_info(GString *buf)
+static void dump_drift_info(GString *buf)
 {
     if (!icount_enabled()) {
         return;
include/exec/cpu-all.h +0 -2
index 5d5290deb5..9a716be80d 100644
@@ -419,8 +419,6 @@ static inline bool tlb_hit(target_ulong tlb_addr, target_ulong addr)
 }
 
 #ifdef CONFIG_TCG
-/* accel/tcg/cpu-exec.c */
-void dump_drift_info(GString *buf);
 /* accel/tcg/translate-all.c */
 void dump_exec_info(GString *buf);
 void dump_opcount_info(GString *buf);
Signature · 1 line
2.36.1
#49 lore raw

[PULL 48/49] accel/tcg: Inline dump_opcount_info() and remove it

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

dump_opcount_info() is a one-line wrapper around tcg_dump_op_count() which is also exported. So use the latter directly.

Message-Id: <[email protected]>

---
 accel/tcg/cpu-exec.c      | 2 +-
 accel/tcg/translate-all.c | 5 -----
 include/exec/cpu-all.h    | 1 -
 3 files changed, 1 insertion(+), 7 deletions(-)
accel/tcg/cpu-exec.c +1 -1
index 7cbf9996b7..a565a3f8ec 100644
@@ -1091,7 +1091,7 @@ HumanReadableText *qmp_x_query_opcount(Error **errp)
         return NULL;
     }
 
-    dump_opcount_info(buf);
+    tcg_dump_op_count(buf);
 
     return human_readable_text_from_str(buf);
 }
accel/tcg/translate-all.c +0 -5
index 291034cb09..8fd23a9d05 100644
@@ -2124,11 +2124,6 @@ void dump_exec_info(GString *buf)
     tcg_dump_info(buf);
 }
 
-void dump_opcount_info(GString *buf)
-{
-    tcg_dump_op_count(buf);
-}
-
 #else /* CONFIG_USER_ONLY */
 
 void cpu_interrupt(CPUState *cpu, int mask)
include/exec/cpu-all.h +0 -1
index 9a716be80d..f5bda2c3ca 100644
@@ -421,7 +421,6 @@ static inline bool tlb_hit(target_ulong tlb_addr, target_ulong addr)
 #ifdef CONFIG_TCG
 /* accel/tcg/translate-all.c */
 void dump_exec_info(GString *buf);
-void dump_opcount_info(GString *buf);
 #endif /* CONFIG_TCG */
 
 #endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.36.1
#50 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 15 lines · Philippe Mathieu-Daudé

The following changes since commit 30796f556790631c86c733ab06756981be0e1def:

Merge tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging (2022-06-10 18:15:34 -0700)

are available in the Git repository at:

https://github.com/philmd/qemu.git tags/mips-20220611

for you to fetch changes up to 37da3bcf01ccd19336fd8f43bedcd0841d71bb6a:

docs/devel: Fix link to developer mailing lists (2022-06-11 11:44:50 +0200)

----------------------------------------------------------------
MIPS patches queue

Quoted 7 lines

- Various TCG fixes (Marcin Nowakowski, Ni Hui, Stefan Pejic, Stefan Pejic)
- Sysbus floppy controller fix (Peter Maydell)
- QOM'ification of PIIX southbridge (Mark Cave-Ayland, Bernhard Beschow)
- Various fixes on ISA devices commonly used by x86/mips machines (Bernhard)
- Few cleanups in accel/tcg & documentation (Bernhard)

----------------------------------------------------------------

A job failed:
https://gitlab.com/qemu-project/qemu/-/jobs/2577882715#L169

122/237 qemu:qtest+qtest-aarch64 / qtest-aarch64/tpm-tis-device-test ERROR 0.15s killed by signal 13 SIGPIPE
qemu-system-aarch64: -tpmdev emulator,id=dev,chardev=chr: 'chr' is not emulating TPM device. Error: Interrupted system call
(test program exited with status code -13)

This doesn't seem related to this PR.

Anyhow, if this isn't too late I'm sending a v2 with a missing patch.

Regards,

Phil.

#51 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

The following changes since commit 30796f556790631c86c733ab06756981be0e1def:

   Merge tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging (2022-06-10 18:15:34 -0700)

are available in the Git repository at:

   https://github.com/philmd/qemu.git tags/mips-20220611

for you to fetch changes up to 37da3bcf01ccd19336fd8f43bedcd0841d71bb6a:

docs/devel: Fix link to developer mailing lists (2022-06-11 11:44:50 +0200)

Quoted 8 lines

----------------------------------------------------------------
MIPS patches queue

- Various TCG fixes (Marcin Nowakowski, Ni Hui, Stefan Pejic, Stefan Pejic)
- Sysbus floppy controller fix (Peter Maydell)
- QOM'ification of PIIX southbridge (Mark Cave-Ayland, Bernhard Beschow)
- Various fixes on ISA devices commonly used by x86/mips machines (Bernhard)
- Few cleanups in accel/tcg & documentation (Bernhard)

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.

r~

Quoted 109 lines

----------------------------------------------------------------

Bernhard Beschow (23):
hw/southbridge/piix: Aggregate all PIIX southbridge type names hw/isa/piix4: Use object_initialize_child() for embedded struct hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn hw/isa/piix4: QOM'ify PCI device creation and wiring hw/isa/piix4: Factor out ISABus retrieval from piix4_create() hw/isa/piix4: QOM'ify PIIX4 PM creation
hw/isa/piix4: Inline and remove piix4_create() hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn hw/isa/piix3: QOM'ify PCI device creation and wiring hw/isa/piix3: Factor out ISABus retrieval from piix3_create() hw/isa/piix3: Inline and remove piix3_create() hw/i386/microvm-dt: Force explicit failure if retrieving QOM property
fails
hw/i386/microvm-dt: Determine mc146818rtc's IRQ number from QOM
property
hw/rtc/mc146818rtc: QOM'ify io_base offset
hw: Reuse TYPE_I8042 define
hw/audio/cs4231a: Const'ify global tables
hw/i386/pc: Unexport PC_CPU_MODEL_IDS macro
hw/i386/pc: Unexport functions used only internally hw/i386/pc: Remove orphan declarations hw/net/fsl_etsec/etsec: Remove obsolete and unused etsec_create() accel/tcg/cpu-exec: Unexport dump_drift_info()
accel/tcg: Inline dump_opcount_info() and remove it docs/devel: Fix link to developer mailing lists

Dragan Mladjenovic (4):
target/mips: Fix emulation of nanoMIPS EXTRV_S.H instruction target/mips: Fix emulation of nanoMIPS BPOSGE32C instruction target/mips: Fix emulation of nanoMIPS BNEC[32] instruction target/mips: Fix handling of unaligned memory access for nanoMIPS ISA

Marcin Nowakowski (1):
target/mips: Fix WatchHi.M handling

Mark Cave-Ayland (11):
hw/acpi/piix4: move xen_enabled() logic from piix4_pm_init() to

     piix4_pm_realize()
   hw/acpi/piix4: change smm_enabled from int to bool
   hw/acpi/piix4: convert smm_enabled bool to qdev property
   hw/acpi/piix4: move PIIX4PMState into separate piix4.h header
   hw/acpi/piix4: alter piix4_pm_init() to return PIIX4PMState
   hw/acpi/piix4: rename piix4_pm_init() to piix4_pm_initfn()
   hw/acpi/piix4: use qdev gpio to wire up sci_irq
   hw/acpi/piix4: use qdev gpio to wire up smi_irq
   hw/i386/pc_piix: create PIIX4_PM device directly instead of using
     piix4_pm_initfn()
   hw/isa/piix4.c: create PIIX4_PM device directly instead of using
     piix4_pm_initfn()

hw/acpi/piix4: remove unused piix4_pm_initfn() function

Ni Hui (6):
target/mips: Fix SAT_S trans helper
target/mips: Fix df_extract_val() and df_extract_df() dfe lookup target/mips: Fix msa checking condition in trans_msa_elm_fn() target/mips: Do not treat msa INSERT as NOP when wd is zero target/mips: Fix store adress of high 64bit in helper_msa_st_b() target/mips: Fix FTRUNC_S and FTRUNC_U trans helper

Peter Maydell (1):
hw/block/fdc-sysbus: Always mark sysbus floppy controllers as not
having DMA

Stefan Pejic (3):
target/mips: Fix emulation of nanoMIPS MTHLIP instruction target/mips: Add missing default cases for some nanoMIPS pools target/mips: Undeprecate nanoMIPS ISA support in QEMU

  MAINTAINERS                              |   3 +-
  accel/tcg/cpu-exec.c                     |   4 +-
  accel/tcg/translate-all.c                |   5 -
  docs/about/deprecated.rst                |  30 ------
  docs/devel/submitting-a-patch.rst        |   6 +-
  hw/acpi/piix4.c                          |  77 +++------------
  hw/audio/cs4231a.c                       |   8 +-
  hw/block/fdc-sysbus.c                    |  16 +++-
  hw/i386/acpi-build.c                     |   1 +
  hw/i386/microvm-dt.c                     |   9 +-
  hw/i386/pc.c                             |  17 +++-
  hw/i386/pc_piix.c                        |  23 +++--
  hw/isa/piix3.c                           |  98 ++++++++++---------
  hw/isa/piix4.c                           | 116 ++++++++++++-----------
  hw/mips/jazz.c                           |   2 +-
  hw/mips/malta.c                          |   9 +-
  hw/net/fsl_etsec/etsec.c                 |  23 -----
  hw/net/fsl_etsec/etsec.h                 |   7 --
  hw/rtc/mc146818rtc.c                     |   9 +-
  hw/sparc64/sun4u.c                       |   2 +-
  include/exec/cpu-all.h                   |   3 -
  include/hw/acpi/piix4.h                  |  75 +++++++++++++++
  include/hw/block/fdc.h                   |   3 +-
  include/hw/i386/pc.h                     |  14 ---
  include/hw/isa/isa.h                     |   2 -
  include/hw/rtc/mc146818rtc.h             |   2 +-
  include/hw/southbridge/piix.h            |  12 +--
  target/mips/cpu.c                        |   2 +-
  target/mips/cpu.h                        |   3 +-
  target/mips/tcg/msa_helper.c             |   2 +-
  target/mips/tcg/msa_translate.c          |  29 +++---
  target/mips/tcg/nanomips_translate.c.inc |  33 ++++++-
  target/mips/tcg/sysemu/cp0_helper.c      |   3 +-
  target/mips/tcg/translate.c              |   5 +-
  34 files changed, 333 insertions(+), 320 deletions(-)

create mode 100644 include/hw/acpi/piix4.h