mbox series

[v3,0/5] pc-bios: s390x: Cleanup part 2

Message ID 20200831150910.317171-1-frankja@linux.ibm.com
Headers show
Series pc-bios: s390x: Cleanup part 2 | expand

Message

Janosch Frank Aug. 31, 2020, 3:09 p.m. UTC
So, here are a few more cleanup patches mostly cleaning up ipl code
and some of the assembly.

The patches are available here:
https://github.com/frankjaa/qemu/pull/new/cleanup_bios2

v3:
	* Split PSW save rework again
	* Added noreturn annotation
	* Minor cleanup

v2:
	* Fixed psw saving in use reset psw patch (thanks Jason)
	* Dropped a lot of patches which weren't strictly necessary
	* Added disabled wait patch
	* Added RFC PSW save patch

Janosch Frank (5):
  pc-bios: s390x: Fix bootmap.c zipl component entry data handling
  pc-bios: s390x: Save PSW rework
  pc-bios: s390x: Use reset PSW if avaliable
  pc-bios: s390x: Save io and external new PSWs before overwriting them
  pc-bios: s390x: Go into disabled wait when encountering a PGM
    exception

 pc-bios/s390-ccw/bootmap.c  |  6 ++--
 pc-bios/s390-ccw/bootmap.h  |  7 +++-
 pc-bios/s390-ccw/jump2ipl.c | 51 +++++++++++++++++------------
 pc-bios/s390-ccw/netmain.c  |  3 ++
 pc-bios/s390-ccw/s390-ccw.h |  1 +
 pc-bios/s390-ccw/start.S    | 65 +++++++++++++++++++++++++++----------
 6 files changed, 92 insertions(+), 41 deletions(-)

Comments

no-reply@patchew.org Aug. 31, 2020, 6:31 p.m. UTC | #1
Patchew URL: https://patchew.org/QEMU/20200831150910.317171-1-frankja@linux.ibm.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20200831150910.317171-1-frankja@linux.ibm.com
Subject: [PATCH v3 0/5] pc-bios: s390x: Cleanup part 2

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20200831150910.317171-1-frankja@linux.ibm.com -> patchew/20200831150910.317171-1-frankja@linux.ibm.com
Switched to a new branch 'test'
62c6c18 pc-bios: s390x: Go into disabled wait when encountering a PGM exception
28a68e4 pc-bios: s390x: Save io and external new PSWs before overwriting them
58aec9e pc-bios: s390x: Use reset PSW if avaliable
b4cf040 pc-bios: s390x: Save PSW rework
30bab1a pc-bios: s390x: Fix bootmap.c zipl component entry data handling

=== OUTPUT BEGIN ===
1/5 Checking commit 30bab1ae7536 (pc-bios: s390x: Fix bootmap.c zipl component entry data handling)
2/5 Checking commit b4cf040a1e53 (pc-bios: s390x: Save PSW rework)
3/5 Checking commit 58aec9efd157 (pc-bios: s390x: Use reset PSW if avaliable)
4/5 Checking commit 28a68e4503b1 (pc-bios: s390x: Save io and external new PSWs before overwriting them)
ERROR: externs should be avoided in .c files
#22: FILE: pc-bios/s390-ccw/jump2ipl.c:17:
+extern uint64_t psw_save_io[], psw_save_ext[];

total: 1 errors, 0 warnings, 118 lines checked

Patch 4/5 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

5/5 Checking commit 62c6c187c90f (pc-bios: s390x: Go into disabled wait when encountering a PGM exception)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20200831150910.317171-1-frankja@linux.ibm.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Janosch Frank Sept. 2, 2020, 8:46 a.m. UTC | #2
On 9/1/20 6:59 PM, Thomas Huth wrote:
> On 31/08/2020 17.09, Janosch Frank wrote:
>> If a blob provides a reset PSW then we should use it instead of
>> branching to the PSW address and using our own mask.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  pc-bios/s390-ccw/bootmap.c  |  3 ++-
>>  pc-bios/s390-ccw/jump2ipl.c | 22 +++++++++++++++++-----
>>  pc-bios/s390-ccw/s390-ccw.h |  1 +
>>  3 files changed, 20 insertions(+), 6 deletions(-)
>>
>> diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
>> index 8747c4ea26..5a03b1eb8b 100644
>> --- a/pc-bios/s390-ccw/bootmap.c
>> +++ b/pc-bios/s390-ccw/bootmap.c
>> @@ -515,7 +515,8 @@ static void zipl_run(ScsiBlockPtr *pte)
>>      IPL_assert(entry->component_type == ZIPL_COMP_ENTRY_EXEC, "No EXEC entry");
>>  
>>      /* should not return */
>> -    jump_to_IPL_code(entry->compdat.load_psw & PSW_MASK_SHORT_ADDR);
>> +    write_reset_psw(entry->compdat.load_psw);
>> +    jump_to_IPL_code(0);
>>  }
>>  
>>  static void ipl_scsi(void)
>> diff --git a/pc-bios/s390-ccw/jump2ipl.c b/pc-bios/s390-ccw/jump2ipl.c
>> index b6aad32def..5b8352d257 100644
>> --- a/pc-bios/s390-ccw/jump2ipl.c
>> +++ b/pc-bios/s390-ccw/jump2ipl.c
>> @@ -12,15 +12,21 @@
>>  
>>  #define KERN_IMAGE_START 0x010000UL
>>  #define RESET_PSW_MASK (PSW_MASK_SHORTPSW | PSW_MASK_64)
>> +#define RESET_PSW ((uint64_t)&jump_to_IPL_addr | RESET_PSW_MASK)
>>  
>>  static uint64_t *reset_psw = 0, save_psw, ipl_continue;
>>  
>> +void write_reset_psw(uint64_t psw)
>> +{
>> +    *reset_psw = psw;
>> +}
>> +
>>  static void jump_to_IPL_addr(void)
>>  {
>>      __attribute__((noreturn)) void (*ipl)(void) = (void *)ipl_continue;
>>  
>>      /* Restore reset PSW */
>> -    *reset_psw = save_psw;
>> +    write_reset_psw(save_psw);
>>  
>>      ipl();
>>      /* should not return */
>> @@ -43,9 +49,10 @@ void jump_to_IPL_code(uint64_t address)
>>       * content of non-BIOS memory after we loaded the guest, so we
>>       * save the original content and restore it in jump_to_IPL_2.
>>       */
>> -    save_psw = *reset_psw;
>> -    *reset_psw = (uint64_t) &jump_to_IPL_addr;
>> -    *reset_psw |= RESET_PSW_MASK;
>> +    if (address) {
>> +        save_psw = *reset_psw;
>> +        write_reset_psw(RESET_PSW);
>> +    }
>>      ipl_continue = address;
>>      debug_print_int("set IPL addr to", ipl_continue);
> 
> In case you respin this series, I think I'd move the "ipl_continue =
> address" into the if-statement, too, and change the debug_print_int line
> to use address instead of ipl_continue.

Hmm, my intention was to always have something printed.
But I guess it would make more sense to print the reset psw addr in the
~address case.


> 
>> @@ -77,7 +84,12 @@ void jump_to_low_kernel(void)
>>  
>>      /* Trying to get PSW at zero address */
>>      if (*((uint64_t *)0) & RESET_PSW_MASK) {
>> -        jump_to_IPL_code((*((uint64_t *)0)) & PSW_MASK_SHORT_ADDR);
>> +        /*
>> +         * Surely nobody will try running directly from lowcore, so
>> +         * let's use 0 as an indication that we want to load the reset
>> +         * psw at 0x0 and not jump to the entry.
>> +         */
>> +        jump_to_IPL_code(0);
>>      }
>>  
>>      /* No other option left, so use the Linux kernel start address */
>> diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
>> index 36b884cced..7090720422 100644
>> --- a/pc-bios/s390-ccw/s390-ccw.h
>> +++ b/pc-bios/s390-ccw/s390-ccw.h
>> @@ -78,6 +78,7 @@ int virtio_read(ulong sector, void *load_addr);
>>  void zipl_load(void);
>>  
>>  /* jump2ipl.c */
>> +void write_reset_psw(uint64_t psw);
>>  void jump_to_IPL_code(uint64_t address);
>>  void jump_to_low_kernel(void);
> 
> Looks sane to me:
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 
>
Thomas Huth Sept. 2, 2020, 9:50 a.m. UTC | #3
On 02/09/2020 10.46, Janosch Frank wrote:
> On 9/1/20 6:59 PM, Thomas Huth wrote:
>> On 31/08/2020 17.09, Janosch Frank wrote:
>>> If a blob provides a reset PSW then we should use it instead of
>>> branching to the PSW address and using our own mask.
>>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> ---
>>>  pc-bios/s390-ccw/bootmap.c  |  3 ++-
>>>  pc-bios/s390-ccw/jump2ipl.c | 22 +++++++++++++++++-----
>>>  pc-bios/s390-ccw/s390-ccw.h |  1 +
>>>  3 files changed, 20 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
>>> index 8747c4ea26..5a03b1eb8b 100644
>>> --- a/pc-bios/s390-ccw/bootmap.c
>>> +++ b/pc-bios/s390-ccw/bootmap.c
>>> @@ -515,7 +515,8 @@ static void zipl_run(ScsiBlockPtr *pte)
>>>      IPL_assert(entry->component_type == ZIPL_COMP_ENTRY_EXEC, "No EXEC entry");
>>>  
>>>      /* should not return */
>>> -    jump_to_IPL_code(entry->compdat.load_psw & PSW_MASK_SHORT_ADDR);
>>> +    write_reset_psw(entry->compdat.load_psw);
>>> +    jump_to_IPL_code(0);
>>>  }
>>>  
>>>  static void ipl_scsi(void)
>>> diff --git a/pc-bios/s390-ccw/jump2ipl.c b/pc-bios/s390-ccw/jump2ipl.c
>>> index b6aad32def..5b8352d257 100644
>>> --- a/pc-bios/s390-ccw/jump2ipl.c
>>> +++ b/pc-bios/s390-ccw/jump2ipl.c
>>> @@ -12,15 +12,21 @@
>>>  
>>>  #define KERN_IMAGE_START 0x010000UL
>>>  #define RESET_PSW_MASK (PSW_MASK_SHORTPSW | PSW_MASK_64)
>>> +#define RESET_PSW ((uint64_t)&jump_to_IPL_addr | RESET_PSW_MASK)
>>>  
>>>  static uint64_t *reset_psw = 0, save_psw, ipl_continue;
>>>  
>>> +void write_reset_psw(uint64_t psw)
>>> +{
>>> +    *reset_psw = psw;
>>> +}
>>> +
>>>  static void jump_to_IPL_addr(void)
>>>  {
>>>      __attribute__((noreturn)) void (*ipl)(void) = (void *)ipl_continue;
>>>  
>>>      /* Restore reset PSW */
>>> -    *reset_psw = save_psw;
>>> +    write_reset_psw(save_psw);
>>>  
>>>      ipl();
>>>      /* should not return */
>>> @@ -43,9 +49,10 @@ void jump_to_IPL_code(uint64_t address)
>>>       * content of non-BIOS memory after we loaded the guest, so we
>>>       * save the original content and restore it in jump_to_IPL_2.
>>>       */
>>> -    save_psw = *reset_psw;
>>> -    *reset_psw = (uint64_t) &jump_to_IPL_addr;
>>> -    *reset_psw |= RESET_PSW_MASK;
>>> +    if (address) {
>>> +        save_psw = *reset_psw;
>>> +        write_reset_psw(RESET_PSW);
>>> +    }
>>>      ipl_continue = address;
>>>      debug_print_int("set IPL addr to", ipl_continue);
>>
>> In case you respin this series, I think I'd move the "ipl_continue =
>> address" into the if-statement, too, and change the debug_print_int line
>> to use address instead of ipl_continue.
> 
> Hmm, my intention was to always have something printed.
> But I guess it would make more sense to print the reset psw addr in the
> ~address case.

I meant to only move the "ipl_continue = address" line and keep the
debug_print_int() at its current place (you just have to replace
ipl_continue there). But you're right, it would make more sense to print
the PSW at address 0 in that case instead.

 Thomas