* [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
@ 2018-06-12 12:59 Christian Borntraeger
2018-06-12 13:03 ` Cornelia Huck
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Christian Borntraeger @ 2018-06-12 12:59 UTC (permalink / raw)
To: Cornelia Huck
Cc: qemu-devel, qemu-s390x, Thomas Huth, David Hildenbrand,
Halil Pasic, Janosch Frank, Alexander Graf, Richard Henderson,
Christian Borntraeger
Right now the IPL device always starts from address 0x10000 (the usual
Linux entry point). To run other guests (e.g. test programs) it is
useful to use the IPL PSW from address 0. We can use the Linux magic
at 0x10008 to decide.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
v3->v4:
- iplpsw-> ipl_psw
- move check for load failures into the non-elf case
- change comment about ipl psw
v2->v3:
- check for iplpsw to avoid assert on file errors
- use 4 bytes at 4 instead of 8 bytes at 0
v1->v2:
- use LINUX_MAGIC_ADDR define
- use assert for valid iplpsw pointer
- add endianess conversion
hw/s390x/ipl.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 04245b5258..0d67349004 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -29,6 +29,7 @@
#include "exec/exec-all.h"
#define KERN_IMAGE_START 0x010000UL
+#define LINUX_MAGIC_ADDR 0x010008UL
#define KERN_PARM_AREA 0x010480UL
#define INITRD_START 0x800000UL
#define INITRD_PARM_START 0x010408UL
@@ -105,7 +106,9 @@ static uint64_t bios_translate_addr(void *opaque, uint64_t srcaddr)
static void s390_ipl_realize(DeviceState *dev, Error **errp)
{
S390IPLState *ipl = S390_IPL(dev);
- uint64_t pentry = KERN_IMAGE_START;
+ uint32_t *ipl_psw;
+ uint64_t pentry;
+ char *magic;
int kernel_size;
Error *err = NULL;
@@ -157,10 +160,24 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
NULL, 1, EM_S390, 0, 0);
if (kernel_size < 0) {
kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
- }
- if (kernel_size < 0) {
- error_setg(&err, "could not load kernel '%s'", ipl->kernel);
- goto error;
+ if (kernel_size < 0) {
+ error_setg(&err, "could not load kernel '%s'", ipl->kernel);
+ goto error;
+ }
+ /* if this is Linux use KERN_IMAGE_START */
+ magic = rom_ptr(LINUX_MAGIC_ADDR);
+ if (magic && !memcmp(magic, "S390EP", 6)) {
+ pentry = KERN_IMAGE_START;
+ } else {
+ /* if not Linux load the address of the (short) IPL PSW */
+ ipl_psw = rom_ptr(4);
+ if (ipl_psw) {
+ pentry = be32_to_cpu(*ipl_psw) & 0x7fffffffUL;
+ } else {
+ error_setg(&err, "Could not get IPL PSW");
+ goto error;
+ }
+ }
}
/*
* Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
--
2.17.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
2018-06-12 12:59 [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
@ 2018-06-12 13:03 ` Cornelia Huck
2018-06-12 13:07 ` David Hildenbrand
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Cornelia Huck @ 2018-06-12 13:03 UTC (permalink / raw)
To: Christian Borntraeger
Cc: qemu-devel, qemu-s390x, Thomas Huth, David Hildenbrand,
Halil Pasic, Janosch Frank, Alexander Graf, Richard Henderson
On Tue, 12 Jun 2018 14:59:33 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:
> Right now the IPL device always starts from address 0x10000 (the usual
> Linux entry point). To run other guests (e.g. test programs) it is
> useful to use the IPL PSW from address 0. We can use the Linux magic
> at 0x10008 to decide.
>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> v3->v4:
> - iplpsw-> ipl_psw
> - move check for load failures into the non-elf case
> - change comment about ipl psw
> v2->v3:
> - check for iplpsw to avoid assert on file errors
> - use 4 bytes at 4 instead of 8 bytes at 0
> v1->v2:
> - use LINUX_MAGIC_ADDR define
> - use assert for valid iplpsw pointer
> - add endianess conversion
> hw/s390x/ipl.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
Looks good to me. Will queue after getting some R-bs for this version.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
2018-06-12 12:59 [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
2018-06-12 13:03 ` Cornelia Huck
@ 2018-06-12 13:07 ` David Hildenbrand
2018-06-12 17:16 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-06-13 8:25 ` [Qemu-devel] " Cornelia Huck
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2018-06-12 13:07 UTC (permalink / raw)
To: Christian Borntraeger, Cornelia Huck
Cc: qemu-devel, qemu-s390x, Thomas Huth, Halil Pasic, Janosch Frank,
Alexander Graf, Richard Henderson
On 12.06.2018 14:59, Christian Borntraeger wrote:
> Right now the IPL device always starts from address 0x10000 (the usual
> Linux entry point). To run other guests (e.g. test programs) it is
> useful to use the IPL PSW from address 0. We can use the Linux magic
> at 0x10008 to decide.
>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> v3->v4:
> - iplpsw-> ipl_psw
> - move check for load failures into the non-elf case
> - change comment about ipl psw
> v2->v3:
> - check for iplpsw to avoid assert on file errors
> - use 4 bytes at 4 instead of 8 bytes at 0
> v1->v2:
> - use LINUX_MAGIC_ADDR define
> - use assert for valid iplpsw pointer
> - add endianess conversion
> hw/s390x/ipl.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index 04245b5258..0d67349004 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -29,6 +29,7 @@
> #include "exec/exec-all.h"
>
> #define KERN_IMAGE_START 0x010000UL
> +#define LINUX_MAGIC_ADDR 0x010008UL
> #define KERN_PARM_AREA 0x010480UL
> #define INITRD_START 0x800000UL
> #define INITRD_PARM_START 0x010408UL
> @@ -105,7 +106,9 @@ static uint64_t bios_translate_addr(void *opaque, uint64_t srcaddr)
> static void s390_ipl_realize(DeviceState *dev, Error **errp)
> {
> S390IPLState *ipl = S390_IPL(dev);
> - uint64_t pentry = KERN_IMAGE_START;
> + uint32_t *ipl_psw;
> + uint64_t pentry;
> + char *magic;
> int kernel_size;
> Error *err = NULL;
>
> @@ -157,10 +160,24 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
> NULL, 1, EM_S390, 0, 0);
> if (kernel_size < 0) {
> kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
> - }
> - if (kernel_size < 0) {
> - error_setg(&err, "could not load kernel '%s'", ipl->kernel);
> - goto error;
> + if (kernel_size < 0) {
> + error_setg(&err, "could not load kernel '%s'", ipl->kernel);
> + goto error;
> + }
> + /* if this is Linux use KERN_IMAGE_START */
> + magic = rom_ptr(LINUX_MAGIC_ADDR);
> + if (magic && !memcmp(magic, "S390EP", 6)) {
> + pentry = KERN_IMAGE_START;
> + } else {
> + /* if not Linux load the address of the (short) IPL PSW */
> + ipl_psw = rom_ptr(4);
> + if (ipl_psw) {
> + pentry = be32_to_cpu(*ipl_psw) & 0x7fffffffUL;
> + } else {
> + error_setg(&err, "Could not get IPL PSW");
> + goto error;
> + }
> + }
Reviewed-by: David Hildenbrand <david@redhat.com>
> }
> /*
> * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [qemu-s390x] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
2018-06-12 12:59 [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
2018-06-12 13:03 ` Cornelia Huck
2018-06-12 13:07 ` David Hildenbrand
@ 2018-06-12 17:16 ` Thomas Huth
2018-06-13 8:25 ` [Qemu-devel] " Cornelia Huck
3 siblings, 0 replies; 5+ messages in thread
From: Thomas Huth @ 2018-06-12 17:16 UTC (permalink / raw)
To: Christian Borntraeger, Cornelia Huck
Cc: Janosch Frank, David Hildenbrand, Alexander Graf, Halil Pasic,
qemu-devel, qemu-s390x, Richard Henderson
On 12.06.2018 14:59, Christian Borntraeger wrote:
> Right now the IPL device always starts from address 0x10000 (the usual
> Linux entry point). To run other guests (e.g. test programs) it is
> useful to use the IPL PSW from address 0. We can use the Linux magic
> at 0x10008 to decide.
>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> v3->v4:
> - iplpsw-> ipl_psw
> - move check for load failures into the non-elf case
> - change comment about ipl psw
> v2->v3:
> - check for iplpsw to avoid assert on file errors
> - use 4 bytes at 4 instead of 8 bytes at 0
> v1->v2:
> - use LINUX_MAGIC_ADDR define
> - use assert for valid iplpsw pointer
> - add endianess conversion
> hw/s390x/ipl.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index 04245b5258..0d67349004 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -29,6 +29,7 @@
> #include "exec/exec-all.h"
>
> #define KERN_IMAGE_START 0x010000UL
> +#define LINUX_MAGIC_ADDR 0x010008UL
> #define KERN_PARM_AREA 0x010480UL
> #define INITRD_START 0x800000UL
> #define INITRD_PARM_START 0x010408UL
> @@ -105,7 +106,9 @@ static uint64_t bios_translate_addr(void *opaque, uint64_t srcaddr)
> static void s390_ipl_realize(DeviceState *dev, Error **errp)
> {
> S390IPLState *ipl = S390_IPL(dev);
> - uint64_t pentry = KERN_IMAGE_START;
> + uint32_t *ipl_psw;
> + uint64_t pentry;
> + char *magic;
> int kernel_size;
> Error *err = NULL;
>
> @@ -157,10 +160,24 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
> NULL, 1, EM_S390, 0, 0);
> if (kernel_size < 0) {
> kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
> - }
> - if (kernel_size < 0) {
> - error_setg(&err, "could not load kernel '%s'", ipl->kernel);
> - goto error;
> + if (kernel_size < 0) {
> + error_setg(&err, "could not load kernel '%s'", ipl->kernel);
> + goto error;
> + }
> + /* if this is Linux use KERN_IMAGE_START */
> + magic = rom_ptr(LINUX_MAGIC_ADDR);
> + if (magic && !memcmp(magic, "S390EP", 6)) {
> + pentry = KERN_IMAGE_START;
> + } else {
> + /* if not Linux load the address of the (short) IPL PSW */
> + ipl_psw = rom_ptr(4);
> + if (ipl_psw) {
> + pentry = be32_to_cpu(*ipl_psw) & 0x7fffffffUL;
> + } else {
> + error_setg(&err, "Could not get IPL PSW");
> + goto error;
> + }
> + }
> }
> /*
> * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
2018-06-12 12:59 [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
` (2 preceding siblings ...)
2018-06-12 17:16 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
@ 2018-06-13 8:25 ` Cornelia Huck
3 siblings, 0 replies; 5+ messages in thread
From: Cornelia Huck @ 2018-06-13 8:25 UTC (permalink / raw)
To: Christian Borntraeger
Cc: qemu-devel, qemu-s390x, Thomas Huth, David Hildenbrand,
Halil Pasic, Janosch Frank, Alexander Graf, Richard Henderson
On Tue, 12 Jun 2018 14:59:33 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:
> Right now the IPL device always starts from address 0x10000 (the usual
> Linux entry point). To run other guests (e.g. test programs) it is
> useful to use the IPL PSW from address 0. We can use the Linux magic
> at 0x10008 to decide.
>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> v3->v4:
> - iplpsw-> ipl_psw
> - move check for load failures into the non-elf case
> - change comment about ipl psw
> v2->v3:
> - check for iplpsw to avoid assert on file errors
> - use 4 bytes at 4 instead of 8 bytes at 0
> v1->v2:
> - use LINUX_MAGIC_ADDR define
> - use assert for valid iplpsw pointer
> - add endianess conversion
> hw/s390x/ipl.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
Thanks, applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-13 8:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 12:59 [Qemu-devel] [PATCH v4 1/1] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
2018-06-12 13:03 ` Cornelia Huck
2018-06-12 13:07 ` David Hildenbrand
2018-06-12 17:16 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-06-13 8:25 ` [Qemu-devel] " Cornelia Huck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.