From: Thomas Huth <thuth@redhat.com>
To: Janosch Frank <frankja@linux.ibm.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH RFC v2 3/4] pc-bios: s390x: Save io and external new PSWs before overwriting them
Date: Thu, 27 Aug 2020 18:16:55 +0200 [thread overview]
Message-ID: <741b1d4f-1d01-2ec8-77b7-183e08a56aec@redhat.com> (raw)
In-Reply-To: <3428e0f6-43a1-b509-d804-fad083c21cb8@linux.ibm.com>
On 27/08/2020 16.30, Janosch Frank wrote:
> On 8/27/20 2:52 PM, Thomas Huth wrote:
>> On 27/08/2020 11.31, Janosch Frank wrote:
>>> Currently we always overwrite the mentioned exception new PSWs before
>>> loading the enabled wait PSW. Let's save the PSW before overwriting
>>> and restore it right before starting the loaded kernel.
>>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> ---
>>>
>>> Maybe we should rather statically allocate a lowcore so we don't dirty
>>> 0x0 at all.
>>>
>>> ---
>>> pc-bios/s390-ccw/jump2ipl.c | 3 ++
>>> pc-bios/s390-ccw/start.S | 62 +++++++++++++++++++++++++++----------
>>> 2 files changed, 48 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/pc-bios/s390-ccw/jump2ipl.c b/pc-bios/s390-ccw/jump2ipl.c
>>> index 143d027bf7..a44f3ab5b3 100644
>>> --- a/pc-bios/s390-ccw/jump2ipl.c
>>> +++ b/pc-bios/s390-ccw/jump2ipl.c
>>> @@ -13,12 +13,15 @@
>>> #define KERN_IMAGE_START 0x010000UL
>>> #define RESET_PSW_MASK (PSW_MASK_SHORTPSW | PSW_MASK_64)
>>>
>>> +extern uint64_t *psw_save_io, *psw_save_ext;
>>
>> I think that should be
>>
>> extern uint64_t psw_save_io[], psw_save_ext[];
>>
>> instead ... otherwise you'll end up with some funny bugs here, won't you?
>
> What kind of bugs are you expecting?
Well, "extern uint64_t var[];" and "extern uint64_t *var;" are two
different kind of things. One is an array, one is a pointer variable.
Looking at your assembler code, you obviously tried to declare an array
there, not a pointer variable.
Have a try with this test program:
#include <string.h>
extern unsigned long *var;
void main(void)
{
asm volatile (" nop ; nop ; nop "); /* marker */
memcpy((void *)0x1f0, var, 16);
asm volatile (" nop ; nop ; nop "); /* marker */
}
After compiling that with -O2, and disassembling the corresponding .o
file, I get this code between the nops:
c: c4 18 00 00 00 00 lgrl %r1,c <main+0xc>
e: R_390_PC32DBL var+0x2
12: e7 00 10 00 00 06 vl %v0,0(%r1)
18: e7 00 01 f0 00 0e vst %v0,496
The "lgrl %r1,var" is likely not what you wanted here.
If you now replace the "*var" with "var[]", you get this instead:
c: c0 10 00 00 00 00 larl %r1,c <main+0xc>
e: R_390_PC32DBL var+0x2
12: e7 00 10 00 00 06 vl %v0,0(%r1)
18: e7 00 01 f0 00 0e vst %v0,496
"larl" looks better now, doesn't it?
>>
>>> uint64_t *reset_psw = 0, save_psw, ipl_continue;
>>>
>>> static void jump_to_IPL_2(void)
>>> {
>>> /* Restore reset PSW and io and external new PSWs */
>>
>> Ok, now the comment makes sense :-)
>>> *reset_psw = save_psw;
>>> + memcpy((void *)0x1f0, psw_save_io, 16);
>>> + memcpy((void *)0x1b0, psw_save_ext, 16);
>>
>> Could you use &lowcore->external_new_psw and &lowcore->io_new_psw
>> instead of the magic numbers?
>
> I can, but that means that I need to declare lowcore in netmain.c as
> well as including s390-arch.h
If that does not cause any other big hurdles, I think I'd prefer that
instead of using magic numbers.
Thanks,
Thomas
next prev parent reply other threads:[~2020-08-27 16:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 9:31 [PATCH v2 0/4] pc-bios: s390x: Cleanup part 2 Janosch Frank
2020-08-27 9:31 ` [PATCH v2 1/4] pc-bios: s390x: Fix bootmap.c zipl component entry data handling Janosch Frank
2020-08-27 9:31 ` [PATCH v2 2/4] pc-bios: s390x: Use reset PSW if avaliable Janosch Frank
2020-08-27 12:43 ` Thomas Huth
2020-08-27 9:31 ` [PATCH RFC v2 3/4] pc-bios: s390x: Save io and external new PSWs before overwriting them Janosch Frank
2020-08-27 12:52 ` Thomas Huth
2020-08-27 14:30 ` Janosch Frank
2020-08-27 16:16 ` Thomas Huth [this message]
2020-08-27 9:31 ` [PATCH v2 4/4] pc-bios: s390x: Go into disabled wait when encountering a PGM exception Janosch Frank
2020-08-31 8:23 ` Christian Borntraeger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=741b1d4f-1d01-2ec8-77b7-183e08a56aec@redhat.com \
--to=thuth@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).