qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [0/5] Assorted small pseries bug fixes
@ 2011-11-14  3:18 David Gibson
  2011-11-14  3:18 ` [Qemu-devel] [PATCH 1/5] pseries: Correct RAM size check for SLOF David Gibson
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: David Gibson @ 2011-11-14  3:18 UTC (permalink / raw)
  To: agraf; +Cc: michael, qemu-ppc, qemu-devel

This series contains a number of small bugfixes for the pseries
machine.

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

* [Qemu-devel] [PATCH 1/5] pseries: Correct RAM size check for SLOF
  2011-11-14  3:18 [Qemu-devel] [0/5] Assorted small pseries bug fixes David Gibson
@ 2011-11-14  3:18 ` David Gibson
  2011-11-14  3:18 ` [Qemu-devel] [PATCH 2/5] pseries: Fix buggy spapr_vio_find_by_reg() David Gibson
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2011-11-14  3:18 UTC (permalink / raw)
  To: agraf; +Cc: michael, qemu-ppc, qemu-devel

The SLOF firmware used on the pseries machine needs a reasonable amount of
(guest) RAM in order to run, so we have a check in the machine init
function to check that this is available.  However, SLOF runs in real mode
(MMU off) which means it can only actually access the RMA (Real Mode Area),
not all of RAM.  In many cases the RMA is the same as all RAM, but when
running with Book3S HV KVM on PowerPC 970, the RMA must be especially
allocated to be (host) physically contiguous.  In this case, the RMA size
is determined by what the host admin allocated at boot time, and will
usually be less than the whole guest RAM size.

This patch corrects the test to see if SLOF has enough memory for this
case.

In addition, more recent versions of SLOF that were committed earlier don't
need quite as much memory as earlier versions.  Therefore, this patch also
reduces the amount of RAM we require to run SLOF.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/spapr.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/spapr.c b/hw/spapr.c
index 40cfc9b..2b901f1 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -57,7 +57,7 @@
 #define FW_MAX_SIZE             0x400000
 #define FW_FILE_NAME            "slof.bin"
 
-#define MIN_RAM_SLOF		512UL
+#define MIN_RMA_SLOF		128UL
 
 #define TIMEBASE_FREQ           512000000ULL
 
@@ -562,9 +562,9 @@ static void ppc_spapr_init(ram_addr_t ram_size,
 
         spapr->entry_point = KERNEL_LOAD_ADDR;
     } else {
-        if (ram_size < (MIN_RAM_SLOF << 20)) {
+        if (rma_size < (MIN_RMA_SLOF << 20)) {
             fprintf(stderr, "qemu: pSeries SLOF firmware requires >= "
-                    "%ldM guest RAM\n", MIN_RAM_SLOF);
+                    "%ldM guest RMA (Real Mode Area memory)\n", MIN_RMA_SLOF);
             exit(1);
         }
         filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, FW_FILE_NAME);
-- 
1.7.7.1

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

* [Qemu-devel] [PATCH 2/5] pseries: Fix buggy spapr_vio_find_by_reg()
  2011-11-14  3:18 [Qemu-devel] [0/5] Assorted small pseries bug fixes David Gibson
  2011-11-14  3:18 ` [Qemu-devel] [PATCH 1/5] pseries: Correct RAM size check for SLOF David Gibson
@ 2011-11-14  3:18 ` David Gibson
  2011-11-14  3:18 ` [Qemu-devel] [PATCH 3/5] pseries: Check we have a chardev in spapr_vty_init() David Gibson
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2011-11-14  3:18 UTC (permalink / raw)
  To: agraf; +Cc: michael, qemu-ppc, qemu-devel

The spapr_vio_find_by_reg() function in hw/spapr_vio.c is supposed to find
the device structure for a PAPR virtual IO device with the given reg value,
and return NULL if none exists.

It does the first ok, but if no device with that reg exists, it just
returns the last device traversed in the list.  This patch fixes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/spapr_vio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index 25cfc9d..b7b3ddd 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -66,11 +66,11 @@ VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg)
     QTAILQ_FOREACH(qdev, &bus->bus.children, sibling) {
         dev = (VIOsPAPRDevice *)qdev;
         if (dev->reg == reg) {
-            break;
+            return dev;
         }
     }
 
-    return dev;
+    return NULL;
 }
 
 #ifdef CONFIG_FDT
-- 
1.7.7.1

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

* [Qemu-devel] [PATCH 3/5] pseries: Check we have a chardev in spapr_vty_init()
  2011-11-14  3:18 [Qemu-devel] [0/5] Assorted small pseries bug fixes David Gibson
  2011-11-14  3:18 ` [Qemu-devel] [PATCH 1/5] pseries: Correct RAM size check for SLOF David Gibson
  2011-11-14  3:18 ` [Qemu-devel] [PATCH 2/5] pseries: Fix buggy spapr_vio_find_by_reg() David Gibson
@ 2011-11-14  3:18 ` David Gibson
  2011-11-14  3:19 ` [Qemu-devel] [PATCH 4/5] pseries: Default reg for vty should be SPAPR_VTY_BASE_ADDRESS David Gibson
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2011-11-14  3:18 UTC (permalink / raw)
  To: agraf; +Cc: michael, qemu-ppc, qemu-devel

From: Michael Ellerman <michael@ellerman.id.au>

If qemu is run like:

 qemu-system-ppc64 -nodefaults -device spapr-vty

We end up in spapr_vty_init() with dev->chardev == NULL. Currently
that leads to a segfault because we unconditionally call
qemu_chr_add_handlers().

Although we could make that call conditional, I think a spapr-vty
without a chardev is basically useless so fail the init. This is
similar to what the serial code does for example.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/spapr_vty.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
index a9d4b03..f4f3ee3 100644
--- a/hw/spapr_vty.c
+++ b/hw/spapr_vty.c
@@ -58,6 +58,11 @@ static int spapr_vty_init(VIOsPAPRDevice *sdev)
 {
     VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)sdev;
 
+    if (!dev->chardev) {
+        fprintf(stderr, "spapr-vty: Can't create vty without a chardev!\n");
+        exit(1);
+    }
+
     qemu_chr_add_handlers(dev->chardev, vty_can_receive,
                           vty_receive, NULL, dev);
 
-- 
1.7.7.1

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

* [Qemu-devel] [PATCH 4/5] pseries: Default reg for vty should be SPAPR_VTY_BASE_ADDRESS
  2011-11-14  3:18 [Qemu-devel] [0/5] Assorted small pseries bug fixes David Gibson
                   ` (2 preceding siblings ...)
  2011-11-14  3:18 ` [Qemu-devel] [PATCH 3/5] pseries: Check we have a chardev in spapr_vty_init() David Gibson
@ 2011-11-14  3:19 ` David Gibson
  2011-11-14  3:19 ` [Qemu-devel] [PATCH 5/5] pseries: Allow kernel's early debug output to work David Gibson
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2011-11-14  3:19 UTC (permalink / raw)
  To: agraf; +Cc: michael, qemu-ppc, qemu-devel

From: Michael Ellerman <michael@ellerman.id.au>

In commit b4a78527359a4540d84d4cdf629d01cbb262f698 ("Place pseries vty
devices at addresses more similar to existing machines"), we changed the
default reg for the vty to 0x30000000, however we didn't update the default
value for a user specified vty device. Fix that.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/spapr_vty.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
index f4f3ee3..8150395 100644
--- a/hw/spapr_vty.c
+++ b/hw/spapr_vty.c
@@ -145,7 +145,7 @@ static VIOsPAPRDeviceInfo spapr_vty = {
     .qdev.name = "spapr-vty",
     .qdev.size = sizeof(VIOsPAPRVTYDevice),
     .qdev.props = (Property[]) {
-        DEFINE_SPAPR_PROPERTIES(VIOsPAPRVTYDevice, sdev, 0, 0),
+        DEFINE_SPAPR_PROPERTIES(VIOsPAPRVTYDevice, sdev, SPAPR_VTY_BASE_ADDRESS, 0),
         DEFINE_PROP_CHR("chardev", VIOsPAPRVTYDevice, chardev),
         DEFINE_PROP_END_OF_LIST(),
     },
-- 
1.7.7.1

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

* [Qemu-devel] [PATCH 5/5] pseries: Allow kernel's early debug output to work
  2011-11-14  3:18 [Qemu-devel] [0/5] Assorted small pseries bug fixes David Gibson
                   ` (3 preceding siblings ...)
  2011-11-14  3:19 ` [Qemu-devel] [PATCH 4/5] pseries: Default reg for vty should be SPAPR_VTY_BASE_ADDRESS David Gibson
@ 2011-11-14  3:19 ` David Gibson
  2011-11-15 23:28 ` [Qemu-devel] [0/5] Assorted small pseries bug fixes Alexander Graf
  2011-11-18 13:23 ` [Qemu-devel] " Alexander Graf
  6 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2011-11-14  3:19 UTC (permalink / raw)
  To: agraf; +Cc: michael, qemu-ppc, qemu-devel

The PAPR specification defines a virtual TTY/console interface for guest
OSes to use via the H_PUT_TERM_CHAR and H_GET_TERM_CHAR hypercalls.  There
can be multiple virtual ttys, so these take a "termno" parameter.  This
encodes which vty to use as the 'reg' property on the device tree node
associated with that vty.

However, with the early debug options enabled, the Linux kernel will
attempt debugging output through the vty very early, before it has read
the device tree.  In this case it always uses a termno of 0.  This works
on the existing PowerVM hypervisor, so we assume there must be a hack /
feature in there which interprets termno==0 to mean the default primary
console.

To help with debugging kernels, including existing distribution kernels,
this patch implements a similar feature / hack in qemu.  If termno==0
is supplied to H_{GET,PUT}_TERM_CHAR, they use the first available vty
device instead.

We need to be careful in the case that the user has manually created
an spapr-vty at address 0. So first we search for the specified reg and
only if that doesn't match do we fall back.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/spapr_vty.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
index 8150395..f23cc36 100644
--- a/hw/spapr_vty.c
+++ b/hw/spapr_vty.c
@@ -69,6 +69,9 @@ static int spapr_vty_init(VIOsPAPRDevice *sdev)
     return 0;
 }
 
+/* Forward declaration */
+static VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg);
+
 static target_ulong h_put_term_char(CPUState *env, sPAPREnvironment *spapr,
                                     target_ulong opcode, target_ulong *args)
 {
@@ -76,9 +79,10 @@ static target_ulong h_put_term_char(CPUState *env, sPAPREnvironment *spapr,
     target_ulong len = args[1];
     target_ulong char0_7 = args[2];
     target_ulong char8_15 = args[3];
-    VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
+    VIOsPAPRDevice *sdev;
     uint8_t buf[16];
 
+    sdev = vty_lookup(spapr, reg);
     if (!sdev) {
         return H_PARAMETER;
     }
@@ -102,9 +106,10 @@ static target_ulong h_get_term_char(CPUState *env, sPAPREnvironment *spapr,
     target_ulong *len = args + 0;
     target_ulong *char0_7 = args + 1;
     target_ulong *char8_15 = args + 2;
-    VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
+    VIOsPAPRDevice *sdev;
     uint8_t buf[16];
 
+    sdev = vty_lookup(spapr, reg);
     if (!sdev) {
         return H_PARAMETER;
     }
@@ -151,6 +156,29 @@ static VIOsPAPRDeviceInfo spapr_vty = {
     },
 };
 
+static VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg)
+{
+    VIOsPAPRDevice *sdev;
+
+    sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
+    if (!sdev && reg == 0) {
+        DeviceState *qdev;
+
+        /* Hack for kernel early debug, which always specifies reg==0.
+         * We search all VIO devices, and grab the first available vty
+         * device.  This attempts to mimic existing PowerVM behaviour
+         * (early debug does work there, despite having no vty with
+         * reg==0. */
+        QTAILQ_FOREACH(qdev, &spapr->vio_bus->bus.children, sibling) {
+            if (qdev->info == &spapr_vty.qdev) {
+                return DO_UPCAST(VIOsPAPRDevice, qdev, qdev);
+            }
+        }
+    }
+
+    return sdev;
+}
+
 static void spapr_vty_register(void)
 {
     spapr_vio_bus_register_withprop(&spapr_vty);
-- 
1.7.7.1

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

* Re: [Qemu-devel] [0/5] Assorted small pseries bug fixes
  2011-11-14  3:18 [Qemu-devel] [0/5] Assorted small pseries bug fixes David Gibson
                   ` (4 preceding siblings ...)
  2011-11-14  3:19 ` [Qemu-devel] [PATCH 5/5] pseries: Allow kernel's early debug output to work David Gibson
@ 2011-11-15 23:28 ` Alexander Graf
  2011-11-16  1:01   ` [Qemu-devel] [Qemu-ppc] " David Gibson
  2011-11-18 13:23 ` [Qemu-devel] " Alexander Graf
  6 siblings, 1 reply; 9+ messages in thread
From: Alexander Graf @ 2011-11-15 23:28 UTC (permalink / raw)
  To: David Gibson; +Cc: michael, qemu-ppc, qemu-devel


On 14.11.2011, at 04:18, David Gibson wrote:

> This series contains a number of small bugfixes for the pseries
> machine.
> 

Which ones of these would you push for 1.0?


Alex

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

* Re: [Qemu-devel] [Qemu-ppc] [0/5] Assorted small pseries bug fixes
  2011-11-15 23:28 ` [Qemu-devel] [0/5] Assorted small pseries bug fixes Alexander Graf
@ 2011-11-16  1:01   ` David Gibson
  0 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2011-11-16  1:01 UTC (permalink / raw)
  To: Alexander Graf; +Cc: michael, qemu-ppc, qemu-devel

On Wed, Nov 16, 2011 at 12:28:29AM +0100, Alexander Graf wrote:
> 
> On 14.11.2011, at 04:18, David Gibson wrote:
> 
> > This series contains a number of small bugfixes for the pseries
> > machine.
> > 
> 
> Which ones of these would you push for 1.0?

All of them, they're bugfixes.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

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

* Re: [Qemu-devel] [0/5] Assorted small pseries bug fixes
  2011-11-14  3:18 [Qemu-devel] [0/5] Assorted small pseries bug fixes David Gibson
                   ` (5 preceding siblings ...)
  2011-11-15 23:28 ` [Qemu-devel] [0/5] Assorted small pseries bug fixes Alexander Graf
@ 2011-11-18 13:23 ` Alexander Graf
  6 siblings, 0 replies; 9+ messages in thread
From: Alexander Graf @ 2011-11-18 13:23 UTC (permalink / raw)
  To: David Gibson; +Cc: michael, qemu-ppc, qemu-devel


On 14.11.2011, at 04:18, David Gibson wrote:

> This series contains a number of small bugfixes for the pseries
> machine.
> 

Thanks, applied all to ppc-next and ppc-1.0.


Alex

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

end of thread, other threads:[~2011-11-18 13:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14  3:18 [Qemu-devel] [0/5] Assorted small pseries bug fixes David Gibson
2011-11-14  3:18 ` [Qemu-devel] [PATCH 1/5] pseries: Correct RAM size check for SLOF David Gibson
2011-11-14  3:18 ` [Qemu-devel] [PATCH 2/5] pseries: Fix buggy spapr_vio_find_by_reg() David Gibson
2011-11-14  3:18 ` [Qemu-devel] [PATCH 3/5] pseries: Check we have a chardev in spapr_vty_init() David Gibson
2011-11-14  3:19 ` [Qemu-devel] [PATCH 4/5] pseries: Default reg for vty should be SPAPR_VTY_BASE_ADDRESS David Gibson
2011-11-14  3:19 ` [Qemu-devel] [PATCH 5/5] pseries: Allow kernel's early debug output to work David Gibson
2011-11-15 23:28 ` [Qemu-devel] [0/5] Assorted small pseries bug fixes Alexander Graf
2011-11-16  1:01   ` [Qemu-devel] [Qemu-ppc] " David Gibson
2011-11-18 13:23 ` [Qemu-devel] " Alexander Graf

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).