qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/7] Misc fixes for 2023-11-28
@ 2023-11-28 13:37 Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 1/7] target/hexagon/idef-parser/prepare: use env to invoke bash Philippe Mathieu-Daudé
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-28 13:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Michael Rolnik, BALATON Zoltan,
	Philippe Mathieu-Daudé

The following changes since commit e867b01cd6658a64c16052117dbb18093a2f9772:

  Merge tag 'qga-pull-2023-11-25' of https://github.com/kostyanf14/qemu into staging (2023-11-27 08:59:00 -0500)

are available in the Git repository at:

  https://github.com/philmd/qemu.git tags/misc-next-20231128

for you to fetch changes up to 0180a744636e6951996240b96a250d20ad0fad0d:

  docs/s390: Fix wrong command example in s390-cpu-topology.rst (2023-11-28 14:27:18 +0100)

----------------------------------------------------------------
Misc fixes for 8.2

* buildsys: Invoke bash via 'env' (Samuel)

* doc: Fix example in s390-cpu-topology.rst (Zhao)

* HW: Fix AVR ATMega reset stack (Gihun) and VT82C686 IRQ routing (Zoltan)

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

BALATON Zoltan (4):
  hw/isa/vt82c686: Bring back via_isa_set_irq()
  hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts
  hw/isa/vt82c686: Route PIRQ inputs using via_isa_set_irq()
  hw/audio/via-ac97: Route interrupts using via_isa_set_irq()

Gihun Nam (1):
  hw/avr/atmega: Fix wrong initial value of stack pointer

Samuel Tardieu (1):
  target/hexagon/idef-parser/prepare: use env to invoke bash

Zhao Liu (1):
  docs/s390: Fix wrong command example in s390-cpu-topology.rst

 docs/devel/s390-cpu-topology.rst   |  6 +--
 include/hw/isa/vt82c686.h          |  2 +
 target/avr/cpu.h                   |  3 ++
 hw/audio/via-ac97.c                |  8 +--
 hw/avr/atmega.c                    |  4 ++
 hw/isa/vt82c686.c                  | 79 ++++++++++++++++++++----------
 hw/usb/vt82c686-uhci-pci.c         |  9 ++++
 target/avr/cpu.c                   | 10 +++-
 target/hexagon/idef-parser/prepare |  2 +-
 9 files changed, 87 insertions(+), 36 deletions(-)

-- 
2.41.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PULL 1/7] target/hexagon/idef-parser/prepare: use env to invoke bash
  2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
@ 2023-11-28 13:37 ` Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 2/7] hw/isa/vt82c686: Bring back via_isa_set_irq() Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-28 13:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Michael Rolnik, BALATON Zoltan, Samuel Tardieu,
	Philippe Mathieu-Daudé, Anton Johansson,
	Alessandro Di Federico

From: Samuel Tardieu <sam@rfc1149.net>

This file is the only one involved in the compilation process which
still uses the /bin/bash path.

Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Message-ID: <20231123211506.636533-1-sam@rfc1149.net>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/hexagon/idef-parser/prepare | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/hexagon/idef-parser/prepare b/target/hexagon/idef-parser/prepare
index 72d6fcbd21..cb3622d4f8 100755
--- a/target/hexagon/idef-parser/prepare
+++ b/target/hexagon/idef-parser/prepare
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 #
 #  Copyright(c) 2019-2021 rev.ng Labs Srl. All Rights Reserved.
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PULL 2/7] hw/isa/vt82c686: Bring back via_isa_set_irq()
  2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 1/7] target/hexagon/idef-parser/prepare: use env to invoke bash Philippe Mathieu-Daudé
@ 2023-11-28 13:37 ` Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 3/7] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-28 13:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Michael Rolnik, BALATON Zoltan,
	Philippe Mathieu-Daudé, Jiaxun Yang

From: BALATON Zoltan <balaton@eik.bme.hu>

The VIA integrated south bridge chips combine several functions and
allow routing their interrupts to any of the ISA IRQs also allowing
multiple sources to share the same ISA IRQ. E.g. pegasos2 firmware
configures everything to use IRQ 9 but amigaone routes them to
separate ISA IRQs so the current simplified routing does not work.
Bring back via_isa_set_irq() and change it to take the component that
wants to change an IRQ and keep track of interrupt status of each
source separately and do the mapping to ISA IRQ within the ISA bridge.

This may not handle cases when an ISA IRQ is controlled by devices
directly, not going through via_isa_set_irq() such as serial, parallel
or keyboard but these IRQs being conventionally fixed are not likely
to be change by guests or share with other devices so this does not
cause a problem in practice.

This reverts commit 4e5a20b6da9b1f6d2e9621ed7eb8b239560104ae.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-ID: <1c3902d4166234bef0a476026441eaac3dd6cda5.1701035944.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/isa/vt82c686.h |  2 ++
 hw/isa/vt82c686.c         | 41 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
index b6e95b2851..da1722daf2 100644
--- a/include/hw/isa/vt82c686.h
+++ b/include/hw/isa/vt82c686.h
@@ -34,4 +34,6 @@ struct ViaAC97State {
     uint32_t ac97_cmd;
 };
 
+void via_isa_set_irq(PCIDevice *d, int n, int level);
+
 #endif
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 57bdfb4e78..6fad8293e6 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -549,6 +549,7 @@ struct ViaISAState {
     PCIDevice dev;
     qemu_irq cpu_intr;
     qemu_irq *isa_irqs_in;
+    uint16_t irq_state[ISA_NUM_IRQS];
     ViaSuperIOState via_sio;
     MC146818RtcState rtc;
     PCIIDEState ide;
@@ -592,6 +593,46 @@ static const TypeInfo via_isa_info = {
     },
 };
 
+void via_isa_set_irq(PCIDevice *d, int pin, int level)
+{
+    ViaISAState *s = VIA_ISA(pci_get_function_0(d));
+    uint8_t irq = d->config[PCI_INTERRUPT_LINE], max_irq = 15;
+    int f = PCI_FUNC(d->devfn);
+    uint16_t mask = BIT(f);
+
+    switch (f) {
+    case 2: /* USB ports 0-1 */
+    case 3: /* USB ports 2-3 */
+        max_irq = 14;
+        break;
+    }
+
+    /* Keep track of the state of all sources */
+    if (level) {
+        s->irq_state[0] |= mask;
+    } else {
+        s->irq_state[0] &= ~mask;
+    }
+    if (irq == 0 || irq == 0xff) {
+        return; /* disabled */
+    }
+    if (unlikely(irq > max_irq || irq == 2)) {
+        qemu_log_mask(LOG_GUEST_ERROR, "Invalid ISA IRQ routing %d for %d",
+                      irq, f);
+        return;
+    }
+    /* Record source state at mapped IRQ */
+    if (level) {
+        s->irq_state[irq] |= mask;
+    } else {
+        s->irq_state[irq] &= ~mask;
+    }
+    /* Make sure there are no stuck bits if mapping has changed */
+    s->irq_state[irq] &= s->irq_state[0];
+    /* ISA IRQ level is the OR of all sources routed to it */
+    qemu_set_irq(s->isa_irqs_in[irq], !!s->irq_state[irq]);
+}
+
 static void via_isa_request_i8259_irq(void *opaque, int irq, int level)
 {
     ViaISAState *s = opaque;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PULL 3/7] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts
  2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 1/7] target/hexagon/idef-parser/prepare: use env to invoke bash Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 2/7] hw/isa/vt82c686: Bring back via_isa_set_irq() Philippe Mathieu-Daudé
@ 2023-11-28 13:37 ` Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 4/7] hw/isa/vt82c686: Route PIRQ inputs using via_isa_set_irq() Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-28 13:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Michael Rolnik, BALATON Zoltan,
	Philippe Mathieu-Daudé, Gerd Hoffmann, Jiaxun Yang

From: BALATON Zoltan <balaton@eik.bme.hu>

This device is part of a superio/ISA bridge chip and IRQs from it are
routed to an ISA interrupt. Use via_isa_set_irq() function to implement
this in a vt82c686-uhci-pci specific irq handler.

This reverts commit 422a6e8075752bc5342afd3eace23a4990dd7d98.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-ID: <ed5cdeaba7cf01eebdaa35f84c63427f4d8876b1.1701035944.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/usb/vt82c686-uhci-pci.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/usb/vt82c686-uhci-pci.c b/hw/usb/vt82c686-uhci-pci.c
index b4884c9011..6162806172 100644
--- a/hw/usb/vt82c686-uhci-pci.c
+++ b/hw/usb/vt82c686-uhci-pci.c
@@ -1,7 +1,14 @@
 #include "qemu/osdep.h"
+#include "hw/irq.h"
 #include "hw/isa/vt82c686.h"
 #include "hcd-uhci.h"
 
+static void uhci_isa_set_irq(void *opaque, int irq_num, int level)
+{
+    UHCIState *s = opaque;
+    via_isa_set_irq(&s->dev, 0, level);
+}
+
 static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
 {
     UHCIState *s = UHCI(dev);
@@ -15,6 +22,8 @@ static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
     pci_set_long(pci_conf + 0xc0, 0x00002000);
 
     usb_uhci_common_realize(dev, errp);
+    object_unref(s->irq);
+    s->irq = qemu_allocate_irq(uhci_isa_set_irq, s, 0);
 }
 
 static UHCIInfo uhci_info[] = {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PULL 4/7] hw/isa/vt82c686: Route PIRQ inputs using via_isa_set_irq()
  2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2023-11-28 13:37 ` [PULL 3/7] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts Philippe Mathieu-Daudé
@ 2023-11-28 13:37 ` Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 5/7] hw/audio/via-ac97: Route interrupts " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-28 13:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Michael Rolnik, BALATON Zoltan,
	Philippe Mathieu-Daudé, Jiaxun Yang

From: BALATON Zoltan <balaton@eik.bme.hu>

The chip has 4 pins (called PIRQA-D in VT82C686B and PINTA-D in
VT8231) that are meant to be connected to PCI IRQ lines and allow
routing PCI interrupts to the ISA PIC. Route these in
via_isa_set_irq() to make it possible to share them with internal
functions that can also be routed to the same ISA IRQs.

Fixes: 2fdadd02e675caca4aba4ae26317701fe2c4c901
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-ID: <8c4513d8b78fac40e6d4e65a0a4b3a7f2f278a4b.1701035944.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/isa/vt82c686.c | 67 ++++++++++++++++++-----------------------------
 1 file changed, 25 insertions(+), 42 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 6fad8293e6..a3eb6769fc 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -593,6 +593,21 @@ static const TypeInfo via_isa_info = {
     },
 };
 
+static int via_isa_get_pci_irq(const ViaISAState *s, int pin)
+{
+    switch (pin) {
+    case 0:
+        return s->dev.config[0x55] >> 4;
+    case 1:
+        return s->dev.config[0x56] & 0xf;
+    case 2:
+        return s->dev.config[0x56] >> 4;
+    case 3:
+        return s->dev.config[0x57] >> 4;
+    }
+    return 0;
+}
+
 void via_isa_set_irq(PCIDevice *d, int pin, int level)
 {
     ViaISAState *s = VIA_ISA(pci_get_function_0(d));
@@ -601,6 +616,10 @@ void via_isa_set_irq(PCIDevice *d, int pin, int level)
     uint16_t mask = BIT(f);
 
     switch (f) {
+    case 0: /* PIRQ/PINT inputs */
+        irq = via_isa_get_pci_irq(s, pin);
+        f = 8 + pin; /* Use function 8-11 for PCI interrupt inputs */
+        break;
     case 2: /* USB ports 0-1 */
     case 3: /* USB ports 2-3 */
         max_irq = 14;
@@ -633,52 +652,17 @@ void via_isa_set_irq(PCIDevice *d, int pin, int level)
     qemu_set_irq(s->isa_irqs_in[irq], !!s->irq_state[irq]);
 }
 
+static void via_isa_pirq(void *opaque, int pin, int level)
+{
+    via_isa_set_irq(opaque, pin, level);
+}
+
 static void via_isa_request_i8259_irq(void *opaque, int irq, int level)
 {
     ViaISAState *s = opaque;
     qemu_set_irq(s->cpu_intr, level);
 }
 
-static int via_isa_get_pci_irq(const ViaISAState *s, int irq_num)
-{
-    switch (irq_num) {
-    case 0:
-        return s->dev.config[0x55] >> 4;
-    case 1:
-        return s->dev.config[0x56] & 0xf;
-    case 2:
-        return s->dev.config[0x56] >> 4;
-    case 3:
-        return s->dev.config[0x57] >> 4;
-    }
-    return 0;
-}
-
-static void via_isa_set_pci_irq(void *opaque, int irq_num, int level)
-{
-    ViaISAState *s = opaque;
-    PCIBus *bus = pci_get_bus(&s->dev);
-    int i, pic_level, pic_irq = via_isa_get_pci_irq(s, irq_num);
-
-    /* IRQ 0: disabled, IRQ 2,8,13: reserved */
-    if (!pic_irq) {
-        return;
-    }
-    if (unlikely(pic_irq == 2 || pic_irq == 8 || pic_irq == 13)) {
-        qemu_log_mask(LOG_GUEST_ERROR, "Invalid ISA IRQ routing");
-    }
-
-    /* The pic level is the logical OR of all the PCI irqs mapped to it. */
-    pic_level = 0;
-    for (i = 0; i < PCI_NUM_PINS; i++) {
-        if (pic_irq == via_isa_get_pci_irq(s, i)) {
-            pic_level |= pci_bus_get_irq_level(bus, i);
-        }
-    }
-    /* Now we change the pic irq level according to the via irq mappings. */
-    qemu_set_irq(s->isa_irqs_in[pic_irq], pic_level);
-}
-
 static void via_isa_realize(PCIDevice *d, Error **errp)
 {
     ViaISAState *s = VIA_ISA(d);
@@ -689,6 +673,7 @@ static void via_isa_realize(PCIDevice *d, Error **errp)
     int i;
 
     qdev_init_gpio_out(dev, &s->cpu_intr, 1);
+    qdev_init_gpio_in_named(dev, via_isa_pirq, "pirq", PCI_NUM_PINS);
     isa_irq = qemu_allocate_irqs(via_isa_request_i8259_irq, s, 1);
     isa_bus = isa_bus_new(dev, pci_address_space(d), pci_address_space_io(d),
                           errp);
@@ -702,8 +687,6 @@ static void via_isa_realize(PCIDevice *d, Error **errp)
     i8254_pit_init(isa_bus, 0x40, 0, NULL);
     i8257_dma_init(isa_bus, 0);
 
-    qdev_init_gpio_in_named(dev, via_isa_set_pci_irq, "pirq", PCI_NUM_PINS);
-
     /* RTC */
     qdev_prop_set_int32(DEVICE(&s->rtc), "base_year", 2000);
     if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PULL 5/7] hw/audio/via-ac97: Route interrupts using via_isa_set_irq()
  2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2023-11-28 13:37 ` [PULL 4/7] hw/isa/vt82c686: Route PIRQ inputs using via_isa_set_irq() Philippe Mathieu-Daudé
@ 2023-11-28 13:37 ` Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 6/7] hw/avr/atmega: Fix wrong initial value of stack pointer Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-28 13:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Michael Rolnik, BALATON Zoltan,
	Philippe Mathieu-Daudé, Gerd Hoffmann, Jiaxun Yang

From: BALATON Zoltan <balaton@eik.bme.hu>

This device is a function of VIA south bridge and should allow setting
interrupt routing within that chip. This is implemented in
via_isa_set_irq().

Fixes: eb604411a78b82c468e2b8d81a9401eb8b9c7658
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-ID: <5329840e4be6dd8ae143d07cbfe61d8d2d106654.1701035944.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/audio/via-ac97.c | 8 ++++----
 hw/isa/vt82c686.c   | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c
index 30095a4c7a..4c127a1def 100644
--- a/hw/audio/via-ac97.c
+++ b/hw/audio/via-ac97.c
@@ -211,14 +211,14 @@ static void out_cb(void *opaque, int avail)
                     AUD_set_active_out(s->vo, 0);
                 }
                 if (c->type & STAT_EOL) {
-                    pci_set_irq(&s->dev, 1);
+                    via_isa_set_irq(&s->dev, 0, 1);
                 }
             }
             if (CLEN_IS_FLAG(c)) {
                 c->stat |= STAT_FLAG;
                 c->stat |= STAT_PAUSED;
                 if (c->type & STAT_FLAG) {
-                    pci_set_irq(&s->dev, 1);
+                    via_isa_set_irq(&s->dev, 0, 1);
                 }
             }
             if (CLEN_IS_STOP(c)) {
@@ -305,13 +305,13 @@ static void sgd_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
         if (val & STAT_EOL) {
             s->aur.stat &= ~(STAT_EOL | STAT_PAUSED);
             if (s->aur.type & STAT_EOL) {
-                pci_set_irq(&s->dev, 0);
+                via_isa_set_irq(&s->dev, 0, 0);
             }
         }
         if (val & STAT_FLAG) {
             s->aur.stat &= ~(STAT_FLAG | STAT_PAUSED);
             if (s->aur.type & STAT_FLAG) {
-                pci_set_irq(&s->dev, 0);
+                via_isa_set_irq(&s->dev, 0, 0);
             }
         }
         break;
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index a3eb6769fc..9c2333a277 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -622,6 +622,7 @@ void via_isa_set_irq(PCIDevice *d, int pin, int level)
         break;
     case 2: /* USB ports 0-1 */
     case 3: /* USB ports 2-3 */
+    case 5: /* AC97 audio */
         max_irq = 14;
         break;
     }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PULL 6/7] hw/avr/atmega: Fix wrong initial value of stack pointer
  2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2023-11-28 13:37 ` [PULL 5/7] hw/audio/via-ac97: Route interrupts " Philippe Mathieu-Daudé
@ 2023-11-28 13:37 ` Philippe Mathieu-Daudé
  2023-11-28 13:37 ` [PULL 7/7] docs/s390: Fix wrong command example in s390-cpu-topology.rst Philippe Mathieu-Daudé
  2023-11-28 23:14 ` [PULL 0/7] Misc fixes for 2023-11-28 Stefan Hajnoczi
  7 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-28 13:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Michael Rolnik, BALATON Zoltan, Gihun Nam,
	Philippe Mathieu-Daudé

From: Gihun Nam <gihun.nam@outlook.com>

The current implementation initializes the stack pointer of AVR devices
to 0. Although older AVR devices used to be like that, newer ones set
it to RAMEND.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1525
Signed-off-by: Gihun Nam <gihun.nam@outlook.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <PH0P222MB0010877445B594724D40C924DEBDA@PH0P222MB0010.NAMP222.PROD.OUTLOOK.COM>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/avr/cpu.h |  3 +++
 hw/avr/atmega.c  |  4 ++++
 target/avr/cpu.c | 10 +++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/target/avr/cpu.h b/target/avr/cpu.h
index 8a17862737..7960c5c57a 100644
--- a/target/avr/cpu.h
+++ b/target/avr/cpu.h
@@ -145,6 +145,9 @@ struct ArchCPU {
     CPUState parent_obj;
 
     CPUAVRState env;
+
+    /* Initial value of stack pointer */
+    uint32_t init_sp;
 };
 
 /**
diff --git a/hw/avr/atmega.c b/hw/avr/atmega.c
index a34803e642..31c8992d75 100644
--- a/hw/avr/atmega.c
+++ b/hw/avr/atmega.c
@@ -233,6 +233,10 @@ static void atmega_realize(DeviceState *dev, Error **errp)
 
     /* CPU */
     object_initialize_child(OBJECT(dev), "cpu", &s->cpu, mc->cpu_type);
+
+    object_property_set_uint(OBJECT(&s->cpu), "init-sp",
+                             mc->io_size + mc->sram_size - 1, &error_abort);
+
     qdev_realize(DEVICE(&s->cpu), NULL, &error_abort);
     cpudev = DEVICE(&s->cpu);
 
diff --git a/target/avr/cpu.c b/target/avr/cpu.c
index 44de1e18d1..999c010ded 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -25,6 +25,7 @@
 #include "cpu.h"
 #include "disas/dis-asm.h"
 #include "tcg/debug-assert.h"
+#include "hw/qdev-properties.h"
 
 static void avr_cpu_set_pc(CPUState *cs, vaddr value)
 {
@@ -95,7 +96,7 @@ static void avr_cpu_reset_hold(Object *obj)
     env->rampY = 0;
     env->rampZ = 0;
     env->eind = 0;
-    env->sp = 0;
+    env->sp = cpu->init_sp;
 
     env->skip = 0;
 
@@ -152,6 +153,11 @@ static void avr_cpu_initfn(Object *obj)
                       sizeof(cpu->env.intsrc) * 8);
 }
 
+static Property avr_cpu_properties[] = {
+    DEFINE_PROP_UINT32("init-sp", AVRCPU, init_sp, 0),
+    DEFINE_PROP_END_OF_LIST()
+};
+
 static ObjectClass *avr_cpu_class_by_name(const char *cpu_model)
 {
     ObjectClass *oc;
@@ -228,6 +234,8 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data)
 
     device_class_set_parent_realize(dc, avr_cpu_realizefn, &mcc->parent_realize);
 
+    device_class_set_props(dc, avr_cpu_properties);
+
     resettable_class_set_parent_phases(rc, NULL, avr_cpu_reset_hold, NULL,
                                        &mcc->parent_phases);
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PULL 7/7] docs/s390: Fix wrong command example in s390-cpu-topology.rst
  2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2023-11-28 13:37 ` [PULL 6/7] hw/avr/atmega: Fix wrong initial value of stack pointer Philippe Mathieu-Daudé
@ 2023-11-28 13:37 ` Philippe Mathieu-Daudé
  2023-11-28 23:14 ` [PULL 0/7] Misc fixes for 2023-11-28 Stefan Hajnoczi
  7 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-28 13:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Michael Rolnik, BALATON Zoltan, Zhao Liu,
	Nina Schoetterl-Glausch, Philippe Mathieu-Daudé, Thomas Huth

From: Zhao Liu <zhao1.liu@intel.com>

From s390_possible_cpu_arch_ids() in hw/s390x/s390-virtio-ccw.c, the
"core-id" is the index of possible_cpus->cpus[], so it should only be
less than possible_cpus->len, which is equal to ms->smp.max_cpus.

Fix the wrong "core-id" 112, because it isn't less than maxcpus (36) in
-smp, and the valid core ids are 0-35 inclusive.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Message-ID: <20231127134917.568552-1-zhao1.liu@linux.intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 docs/devel/s390-cpu-topology.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/devel/s390-cpu-topology.rst b/docs/devel/s390-cpu-topology.rst
index 9eab28d5e5..48313b92d4 100644
--- a/docs/devel/s390-cpu-topology.rst
+++ b/docs/devel/s390-cpu-topology.rst
@@ -15,7 +15,7 @@ have default values:
     -smp 1,drawers=3,books=3,sockets=2,cores=2,maxcpus=36 \
     -device z14-s390x-cpu,core-id=19,entitlement=high \
     -device z14-s390x-cpu,core-id=11,entitlement=low \
-    -device z14-s390x-cpu,core-id=112,entitlement=high \
+    -device z14-s390x-cpu,core-id=12,entitlement=high \
    ...
 
 Additions to query-cpus-fast
@@ -78,7 +78,7 @@ modifiers for all configured vCPUs.
       "dedicated": true,
       "thread-id": 537005,
       "props": {
-        "core-id": 112,
+        "core-id": 12,
         "socket-id": 0,
         "drawer-id": 3,
         "book-id": 2
@@ -86,7 +86,7 @@ modifiers for all configured vCPUs.
       "cpu-state": "operating",
       "entitlement": "high",
       "qom-path": "/machine/peripheral-anon/device[2]",
-      "cpu-index": 112,
+      "cpu-index": 12,
       "target": "s390x"
     }
   ]
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PULL 0/7] Misc fixes for 2023-11-28
  2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2023-11-28 13:37 ` [PULL 7/7] docs/s390: Fix wrong command example in s390-cpu-topology.rst Philippe Mathieu-Daudé
@ 2023-11-28 23:14 ` Stefan Hajnoczi
  7 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2023-11-28 23:14 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, qemu-s390x, Michael Rolnik, BALATON Zoltan,
	Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 115 bytes --]

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-11-28 23:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-28 13:37 [PULL 0/7] Misc fixes for 2023-11-28 Philippe Mathieu-Daudé
2023-11-28 13:37 ` [PULL 1/7] target/hexagon/idef-parser/prepare: use env to invoke bash Philippe Mathieu-Daudé
2023-11-28 13:37 ` [PULL 2/7] hw/isa/vt82c686: Bring back via_isa_set_irq() Philippe Mathieu-Daudé
2023-11-28 13:37 ` [PULL 3/7] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts Philippe Mathieu-Daudé
2023-11-28 13:37 ` [PULL 4/7] hw/isa/vt82c686: Route PIRQ inputs using via_isa_set_irq() Philippe Mathieu-Daudé
2023-11-28 13:37 ` [PULL 5/7] hw/audio/via-ac97: Route interrupts " Philippe Mathieu-Daudé
2023-11-28 13:37 ` [PULL 6/7] hw/avr/atmega: Fix wrong initial value of stack pointer Philippe Mathieu-Daudé
2023-11-28 13:37 ` [PULL 7/7] docs/s390: Fix wrong command example in s390-cpu-topology.rst Philippe Mathieu-Daudé
2023-11-28 23:14 ` [PULL 0/7] Misc fixes for 2023-11-28 Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).