diff mbox series

[PULL,10/30] ppc/spapr: H_ENTER_NESTED should restore host XER ca field

Message ID 20230626055647.1147743-11-clg@kaod.org (mailing list archive)
State New, archived
Headers show
Series [PULL,01/30] target/ppc: gdbstub init spr gdb_id for all CPUs | expand

Commit Message

Cédric Le Goater June 26, 2023, 5:56 a.m. UTC
From: Nicholas Piggin <npiggin@gmail.com>

Fix missing env->ca restore when going from L2 back to the host.

Fixes: 120f738a467 ("spapr: implement nested-hv capability for the virtual hypervisor")
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/ppc/spapr_hcall.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michael Tokarev June 26, 2023, 12:26 p.m. UTC | #1
26.06.2023 08:56, Cédric Le Goater wrote:
> From: Nicholas Piggin <npiggin@gmail.com>
> 
> Fix missing env->ca restore when going from L2 back to the host.
> 
> Fixes: 120f738a467 ("spapr: implement nested-hv capability for the virtual hypervisor")
> Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>   hw/ppc/spapr_hcall.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index b9047555757f..0582b524d108 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -1773,6 +1773,7 @@ out_restore_l1:
>       env->cfar = spapr_cpu->nested_host_state->cfar;
>       env->xer = spapr_cpu->nested_host_state->xer;
>       env->so = spapr_cpu->nested_host_state->so;
> +    env->ca = spapr_cpu->nested_host_state->ca;
>       env->ov = spapr_cpu->nested_host_state->ov;
>       env->ov32 = spapr_cpu->nested_host_state->ov32;
>       env->ca32 = spapr_cpu->nested_host_state->ca32;

Is it -stable material too, or don't bother?
120f738a467 is 7.0.

Thanks,

/mjt
Cédric Le Goater June 26, 2023, 9:45 p.m. UTC | #2
On 6/26/23 14:26, Michael Tokarev wrote:
> 26.06.2023 08:56, Cédric Le Goater wrote:
>> From: Nicholas Piggin <npiggin@gmail.com>
>>
>> Fix missing env->ca restore when going from L2 back to the host.
>>
>> Fixes: 120f738a467 ("spapr: implement nested-hv capability for the virtual hypervisor")
>> Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   hw/ppc/spapr_hcall.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
>> index b9047555757f..0582b524d108 100644
>> --- a/hw/ppc/spapr_hcall.c
>> +++ b/hw/ppc/spapr_hcall.c
>> @@ -1773,6 +1773,7 @@ out_restore_l1:
>>       env->cfar = spapr_cpu->nested_host_state->cfar;
>>       env->xer = spapr_cpu->nested_host_state->xer;
>>       env->so = spapr_cpu->nested_host_state->so;
>> +    env->ca = spapr_cpu->nested_host_state->ca;
>>       env->ov = spapr_cpu->nested_host_state->ov;
>>       env->ov32 = spapr_cpu->nested_host_state->ov32;
>>       env->ca32 = spapr_cpu->nested_host_state->ca32;
> 
> Is it -stable material too, or don't bother?
> 120f738a467 is 7.0.

I would say so. The CPU is missing state (Carry bit) when restoring context,
it could be important for some instructions.

Nick, did you have specific test case ?

Thanks,

C.
Nicholas Piggin June 26, 2023, 11:15 p.m. UTC | #3
On Tue Jun 27, 2023 at 7:45 AM AEST, Cédric Le Goater wrote:
> On 6/26/23 14:26, Michael Tokarev wrote:
> > 26.06.2023 08:56, Cédric Le Goater wrote:
> >> From: Nicholas Piggin <npiggin@gmail.com>
> >>
> >> Fix missing env->ca restore when going from L2 back to the host.
> >>
> >> Fixes: 120f738a467 ("spapr: implement nested-hv capability for the virtual hypervisor")
> >> Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
> >> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> >> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> >> ---
> >>   hw/ppc/spapr_hcall.c | 1 +
> >>   1 file changed, 1 insertion(+)
> >>
> >> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> >> index b9047555757f..0582b524d108 100644
> >> --- a/hw/ppc/spapr_hcall.c
> >> +++ b/hw/ppc/spapr_hcall.c
> >> @@ -1773,6 +1773,7 @@ out_restore_l1:
> >>       env->cfar = spapr_cpu->nested_host_state->cfar;
> >>       env->xer = spapr_cpu->nested_host_state->xer;
> >>       env->so = spapr_cpu->nested_host_state->so;
> >> +    env->ca = spapr_cpu->nested_host_state->ca;
> >>       env->ov = spapr_cpu->nested_host_state->ov;
> >>       env->ov32 = spapr_cpu->nested_host_state->ov32;
> >>       env->ca32 = spapr_cpu->nested_host_state->ca32;
> > 
> > Is it -stable material too, or don't bother?
> > 120f738a467 is 7.0.
>
> I would say so. The CPU is missing state (Carry bit) when restoring context,
> it could be important for some instructions.
>
> Nick, did you have specific test case ?

No I just found it when doing the conversion to the new host save
structure. Now I think about it again, XER is volatile across hcalls
in general so I think the patch is not fixing any practical bug.

Thanks,
Nick
diff mbox series

Patch

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index b9047555757f..0582b524d108 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1773,6 +1773,7 @@  out_restore_l1:
     env->cfar = spapr_cpu->nested_host_state->cfar;
     env->xer = spapr_cpu->nested_host_state->xer;
     env->so = spapr_cpu->nested_host_state->so;
+    env->ca = spapr_cpu->nested_host_state->ca;
     env->ov = spapr_cpu->nested_host_state->ov;
     env->ov32 = spapr_cpu->nested_host_state->ov32;
     env->ca32 = spapr_cpu->nested_host_state->ca32;