diff mbox series

Fix booting & OPAL call return values with DEBUG=1

Message ID 20171206055647.18159-1-stewart@linux.vnet.ibm.com
State Accepted
Headers show
Series Fix booting & OPAL call return values with DEBUG=1 | expand

Commit Message

Stewart Smith Dec. 6, 2017, 5:56 a.m. UTC
On a debug build, _mcount would trash r3 and opal_exit_check
would not restore it, leaving OPAL calls returning garbage.

this fix simply preserves the return value and doesn't let
the compiler get fancy on us. We effectively just get an
extra `mr` instruction to restore r3.

Fixes: 9c565ee6bca4b665d9d1120bfff5e88ee80615bc
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reported-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Suggested-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 core/opal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Andrew Donnellan Dec. 6, 2017, 6 a.m. UTC | #1
On 06/12/17 16:56, Stewart Smith wrote:
> On a debug build, _mcount would trash r3 and opal_exit_check
> would not restore it, leaving OPAL calls returning garbage.
> 
> this fix simply preserves the return value and doesn't let
> the compiler get fancy on us. We effectively just get an
> extra `mr` instruction to restore r3.
> 
> Fixes: 9c565ee6bca4b665d9d1120bfff5e88ee80615bc
> Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Reported-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> Suggested-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>

Thanks!

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Tested-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> ---
>   core/opal.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/core/opal.c b/core/opal.c
> index 193dc89805de..d33d527c7dec 100644
> --- a/core/opal.c
> +++ b/core/opal.c
> @@ -171,9 +171,9 @@ again:
>   	return OPAL_SUCCESS;
>   }
> 
> -void opal_exit_check(int64_t retval, struct stack_frame *eframe);
> +int64_t opal_exit_check(int64_t retval, struct stack_frame *eframe);
> 
> -void opal_exit_check(int64_t retval, struct stack_frame *eframe)
> +int64_t opal_exit_check(int64_t retval, struct stack_frame *eframe)
>   {
>   	struct cpu_thread *cpu = this_cpu();
>   	uint64_t token = eframe->gpr[0];
> @@ -185,6 +185,7 @@ void opal_exit_check(int64_t retval, struct stack_frame *eframe)
>   		sync(); /* release barrier vs quiescing */
>   		cpu->in_opal_call--;
>   	}
> +	return retval;
>   }
> 
>   int64_t opal_quiesce(uint32_t quiesce_type, int32_t cpu_target)
>
Stewart Smith Dec. 6, 2017, 9:36 p.m. UTC | #2
Stewart Smith <stewart@linux.vnet.ibm.com> writes:
> On a debug build, _mcount would trash r3 and opal_exit_check
> would not restore it, leaving OPAL calls returning garbage.
>
> this fix simply preserves the return value and doesn't let
> the compiler get fancy on us. We effectively just get an
> extra `mr` instruction to restore r3.
>
> Fixes: 9c565ee6bca4b665d9d1120bfff5e88ee80615bc
> Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Reported-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> Suggested-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
> ---
>  core/opal.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Merged to master as of 0562b64e55b0e0780064823155f45b1ddf0893a6
diff mbox series

Patch

diff --git a/core/opal.c b/core/opal.c
index 193dc89805de..d33d527c7dec 100644
--- a/core/opal.c
+++ b/core/opal.c
@@ -171,9 +171,9 @@  again:
 	return OPAL_SUCCESS;
 }
 
-void opal_exit_check(int64_t retval, struct stack_frame *eframe);
+int64_t opal_exit_check(int64_t retval, struct stack_frame *eframe);
 
-void opal_exit_check(int64_t retval, struct stack_frame *eframe)
+int64_t opal_exit_check(int64_t retval, struct stack_frame *eframe)
 {
 	struct cpu_thread *cpu = this_cpu();
 	uint64_t token = eframe->gpr[0];
@@ -185,6 +185,7 @@  void opal_exit_check(int64_t retval, struct stack_frame *eframe)
 		sync(); /* release barrier vs quiescing */
 		cpu->in_opal_call--;
 	}
+	return retval;
 }
 
 int64_t opal_quiesce(uint32_t quiesce_type, int32_t cpu_target)