[PATCH] pc-bios/s390-ccw: Use reset_psw pointer instead of hard-coded null pointer

Thomas Huth posted 1 patch 3 years ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210423083604.526367-1-thuth@redhat.com
Maintainers: Christian Borntraeger <borntraeger@de.ibm.com>, Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>
There is a newer version of this series
pc-bios/s390-ccw/jump2ipl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] pc-bios/s390-ccw: Use reset_psw pointer instead of hard-coded null pointer
Posted by Thomas Huth 3 years ago
When compiling the s390-ccw bios with clang, it emits a warning like this:

 pc-bios/s390-ccw/jump2ipl.c:86:9: warning: indirection of non-volatile null
  pointer will be deleted, not trap [-Wnull-dereference]
     if (*((uint64_t *)0) & RESET_PSW_MASK) {
         ^~~~~~~~~~~~~~~~
 pc-bios/s390-ccw/jump2ipl.c:86:9: note: consider using __builtin_trap() or
  qualifying pointer with 'volatile'

We could add a "volatile" here to shut it up, but on the other hand,
we also have a pointer variable called "reset_psw" in this file already
that points to the PSW at address 0, so we can simply use that pointer
variable instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/jump2ipl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pc-bios/s390-ccw/jump2ipl.c b/pc-bios/s390-ccw/jump2ipl.c
index b9c70d64a5..de1541ea5d 100644
--- a/pc-bios/s390-ccw/jump2ipl.c
+++ b/pc-bios/s390-ccw/jump2ipl.c
@@ -83,7 +83,7 @@ void jump_to_low_kernel(void)
     }
 
     /* Trying to get PSW at zero address */
-    if (*((uint64_t *)0) & RESET_PSW_MASK) {
+    if (*reset_psw & RESET_PSW_MASK) {
         /*
          * Surely nobody will try running directly from lowcore, so
          * let's use 0 as an indication that we want to load the reset
-- 
2.27.0


Re: [PATCH] pc-bios/s390-ccw: Use reset_psw pointer instead of hard-coded null pointer
Posted by Cornelia Huck 3 years ago
On Fri, 23 Apr 2021 10:36:04 +0200
Thomas Huth <thuth@redhat.com> wrote:

> When compiling the s390-ccw bios with clang, it emits a warning like this:
> 
>  pc-bios/s390-ccw/jump2ipl.c:86:9: warning: indirection of non-volatile null
>   pointer will be deleted, not trap [-Wnull-dereference]
>      if (*((uint64_t *)0) & RESET_PSW_MASK) {
>          ^~~~~~~~~~~~~~~~
>  pc-bios/s390-ccw/jump2ipl.c:86:9: note: consider using __builtin_trap() or
>   qualifying pointer with 'volatile'
> 
> We could add a "volatile" here to shut it up, but on the other hand,
> we also have a pointer variable called "reset_psw" in this file already
> that points to the PSW at address 0, so we can simply use that pointer
> variable instead.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  pc-bios/s390-ccw/jump2ipl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/pc-bios/s390-ccw/jump2ipl.c b/pc-bios/s390-ccw/jump2ipl.c
> index b9c70d64a5..de1541ea5d 100644
> --- a/pc-bios/s390-ccw/jump2ipl.c
> +++ b/pc-bios/s390-ccw/jump2ipl.c
> @@ -83,7 +83,7 @@ void jump_to_low_kernel(void)
>      }
>  
>      /* Trying to get PSW at zero address */

Maybe make this

/* Trying to get PSW at zero address (pointed to by reset_psw) */

I'm always getting a headache when I'm reading this file, so let's make
it easy :)

> -    if (*((uint64_t *)0) & RESET_PSW_MASK) {
> +    if (*reset_psw & RESET_PSW_MASK) {
>          /*
>           * Surely nobody will try running directly from lowcore, so
>           * let's use 0 as an indication that we want to load the reset


Re: [PATCH] pc-bios/s390-ccw: Use reset_psw pointer instead of hard-coded null pointer
Posted by Philippe Mathieu-Daudé 3 years ago
On 4/23/21 10:36 AM, Thomas Huth wrote:
> When compiling the s390-ccw bios with clang, it emits a warning like this:
> 
>  pc-bios/s390-ccw/jump2ipl.c:86:9: warning: indirection of non-volatile null
>   pointer will be deleted, not trap [-Wnull-dereference]
>      if (*((uint64_t *)0) & RESET_PSW_MASK) {
>          ^~~~~~~~~~~~~~~~
>  pc-bios/s390-ccw/jump2ipl.c:86:9: note: consider using __builtin_trap() or
>   qualifying pointer with 'volatile'
> 
> We could add a "volatile" here to shut it up, but on the other hand,
> we also have a pointer variable called "reset_psw" in this file already
> that points to the PSW at address 0, so we can simply use that pointer
> variable instead.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  pc-bios/s390-ccw/jump2ipl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>