diff mbox series

[3/5] ppc: spapr: assert early rather late in h_enter_nested()

Message ID 20230331065344.112341-4-harshpb@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Cleanup [h_enter|spapr_exit]_nested routines | expand

Commit Message

Harsh Prateek Bora March 31, 2023, 6:53 a.m. UTC
Currently, it asserts very late in the code flow if lpid is already initialized.
Ideally, it should assert in the beginning if that is the case. This patch
brings assert check in the beginning alongwith the related initialization.

Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
---
 hw/ppc/spapr_hcall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Fabiano Rosas April 14, 2023, 11:55 a.m. UTC | #1
Harsh Prateek Bora <harshpb@linux.ibm.com> writes:

> Currently, it asserts very late in the code flow if lpid is already initialized.

That's not about initializing. It is about making sure the LPIDR is
0. Which has a specific meaning according to the ISA.

> Ideally, it should assert in the beginning if that is the case. This patch
> brings assert check in the beginning alongwith the related initialization.
>

Maybe just leave it where it is. There's not much to gain from moving this.
Harsh Prateek Bora April 17, 2023, 7:15 a.m. UTC | #2
On 4/14/23 17:25, Fabiano Rosas wrote:
> Harsh Prateek Bora <harshpb@linux.ibm.com> writes:
> 
>> Currently, it asserts very late in the code flow if lpid is already initialized.
> 
> That's not about initializing. It is about making sure the LPIDR is
> 0. Which has a specific meaning according to the ISA.
> 
Yes, I could rephrase the commit log, but I am okay with your below 
suggestion for now.

>> Ideally, it should assert in the beginning if that is the case. This patch
>> brings assert check in the beginning alongwith the related initialization.
>>
> 
> Maybe just leave it where it is. There's not much to gain from moving this.
> 
Will drop this change for now as value-add is relatively lesser.
diff mbox series

Patch

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index a13e5256ab..a77b4c9076 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1621,6 +1621,9 @@  static target_ulong h_enter_nested(PowerPCCPU *cpu,
     struct kvmppc_pt_regs *regs;
     hwaddr len;
 
+    assert(env->spr[SPR_LPIDR] == 0);
+    env->spr[SPR_LPIDR] = hv_state.lpid;
+
     if (spapr->nested_ptcr == 0) {
         return H_NOT_AVAILABLE;
     }
@@ -1667,9 +1670,6 @@  static target_ulong h_enter_nested(PowerPCCPU *cpu,
 
     address_space_unmap(CPU(cpu)->as, regs, len, len, false);
 
-    assert(env->spr[SPR_LPIDR] == 0);
-    env->spr[SPR_LPIDR] = hv_state.lpid;
-
     spapr_cpu->nested_tb_offset = hv_state.tb_offset;
 
     /*