* [Qemu-devel] [PATCH] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
@ 2018-05-08 14:15 Christian Borntraeger
2018-05-08 14:24 ` Thomas Huth
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christian Borntraeger @ 2018-05-08 14:15 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-devel, qemu-s390x, Cornelia Huck, 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>
Acked-by: Jason J. Herne <jjherne@linux.ibm.com>
---
hw/s390x/ipl.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 150f6c0582..c0fed26f03 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -104,7 +104,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;
+ uint64_t *iplpsw;
+ uint64_t pentry;
+ char *magic;
int kernel_size;
Error *err = NULL;
@@ -156,6 +158,17 @@ 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 this is Linux use KERN_IMAGE_START */
+ magic = rom_ptr(0x10008);
+ if (magic && !memcmp(magic, "S390EP", 6)) {
+ pentry = KERN_IMAGE_START;
+ } else {
+ /* if not Linux use the IPL PSW */
+ iplpsw = rom_ptr(0);
+ if (iplpsw) {
+ pentry = *iplpsw & 0x7fffffffUL;
+ }
+ }
}
if (kernel_size < 0) {
error_setg(&err, "could not load kernel '%s'", ipl->kernel);
--
2.14.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
2018-05-08 14:15 [Qemu-devel] [PATCH] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
@ 2018-05-08 14:24 ` Thomas Huth
2018-05-08 16:46 ` Christian Borntraeger
2018-05-08 16:47 ` Christian Borntraeger
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2018-05-08 14:24 UTC (permalink / raw)
To: Christian Borntraeger, Peter Maydell
Cc: qemu-devel, qemu-s390x, Cornelia Huck, David Hildenbrand,
Halil Pasic, Janosch Frank, Alexander Graf, Richard Henderson
On 08.05.2018 16:15, 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>
> Acked-by: Jason J. Herne <jjherne@linux.ibm.com>
> ---
> hw/s390x/ipl.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index 150f6c0582..c0fed26f03 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -104,7 +104,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;
> + uint64_t *iplpsw;
> + uint64_t pentry;
> + char *magic;
> int kernel_size;
> Error *err = NULL;
>
> @@ -156,6 +158,17 @@ 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 this is Linux use KERN_IMAGE_START */
> + magic = rom_ptr(0x10008);
> + if (magic && !memcmp(magic, "S390EP", 6)) {
> + pentry = KERN_IMAGE_START;
> + } else {
> + /* if not Linux use the IPL PSW */
> + iplpsw = rom_ptr(0);
> + if (iplpsw) {
> + pentry = *iplpsw & 0x7fffffffUL;
> + }
else {
error_report("Failed to determine entry point");
exit(1);
}
?
Otherwise some version of GCC might complain that pentry is used
uninitialized later.
Alternatively, use "assert(iplpsw)" instead of the "if (iplpws)" ?
> + }
> }
> if (kernel_size < 0) {
> error_setg(&err, "could not load kernel '%s'", ipl->kernel);
>
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
2018-05-08 14:15 [Qemu-devel] [PATCH] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
2018-05-08 14:24 ` Thomas Huth
@ 2018-05-08 16:46 ` Christian Borntraeger
2018-05-08 16:47 ` Christian Borntraeger
2 siblings, 0 replies; 4+ messages in thread
From: Christian Borntraeger @ 2018-05-08 16:46 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-devel, qemu-s390x, Cornelia Huck, Thomas Huth,
David Hildenbrand, Halil Pasic, Janosch Frank, Alexander Graf,
Richard Henderson
On 05/08/2018 04:15 PM, 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>
> Acked-by: Jason J. Herne <jjherne@linux.ibm.com>
> ---
> hw/s390x/ipl.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index 150f6c0582..c0fed26f03 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -104,7 +104,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;
> + uint64_t *iplpsw;
> + uint64_t pentry;
> + char *magic;
> int kernel_size;
> Error *err = NULL;
>
> @@ -156,6 +158,17 @@ 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 this is Linux use KERN_IMAGE_START */
> + magic = rom_ptr(0x10008);
> + if (magic && !memcmp(magic, "S390EP", 6)) {
> + pentry = KERN_IMAGE_START;
> + } else {
> + /* if not Linux use the IPL PSW */
> + iplpsw = rom_ptr(0);
> + if (iplpsw) {
> + pentry = *iplpsw & 0x7fffffffUL;
This needs an endianess conversion I think.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
2018-05-08 14:15 [Qemu-devel] [PATCH] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
2018-05-08 14:24 ` Thomas Huth
2018-05-08 16:46 ` Christian Borntraeger
@ 2018-05-08 16:47 ` Christian Borntraeger
2 siblings, 0 replies; 4+ messages in thread
From: Christian Borntraeger @ 2018-05-08 16:47 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-devel, qemu-s390x, Cornelia Huck, Thomas Huth,
David Hildenbrand, Halil Pasic, Janosch Frank, Alexander Graf,
Richard Henderson
On 05/08/2018 04:15 PM, 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>
> Acked-by: Jason J. Herne <jjherne@linux.ibm.com>
> ---
> hw/s390x/ipl.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index 150f6c0582..c0fed26f03 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -104,7 +104,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;
> + uint64_t *iplpsw;
> + uint64_t pentry;
> + char *magic;
> int kernel_size;
> Error *err = NULL;
>
> @@ -156,6 +158,17 @@ 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 this is Linux use KERN_IMAGE_START */
> + magic = rom_ptr(0x10008);
> + if (magic && !memcmp(magic, "S390EP", 6)) {
> + pentry = KERN_IMAGE_START;
> + } else {
> + /* if not Linux use the IPL PSW */
> + iplpsw = rom_ptr(0);
> + if (iplpsw) {
> + pentry = *iplpsw & 0x7fffffffUL;
I forgot endianess conversion here.
> + }
> + }
> }
> if (kernel_size < 0) {
> error_setg(&err, "could not load kernel '%s'", ipl->kernel);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-05-08 16:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-08 14:15 [Qemu-devel] [PATCH] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Christian Borntraeger
2018-05-08 14:24 ` Thomas Huth
2018-05-08 16:46 ` Christian Borntraeger
2018-05-08 16:47 ` Christian Borntraeger
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.