Skip to contentSkip to conversation

PPC: KVM: store SLB slot number

PATCH Applied Alexey Kardashevskiy 3 participants 3 messages Jan 31, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PPC: KVM: store SLB slot number

When ppc_store_slb() is called from kvm_arch_get_registers(), it stores a SLB in CPUPPCState::slb[slot]. However it drops the slot number from ESID so when kvm_arch_put_registers() puts SLBs back to KVM, they do not have correct "index" field anymore. This broke migration with LPCR_AIR enabled as now the guest is handling interrupts in virtual mode and unable to reconstruct correct SLBs anymore.

This adds "index" field for valid SLBs when putting them to KVM.

---
 target-ppc/kvm.c | 3 +++
 1 file changed, 3 insertions(+)
target-ppc/kvm.c +3 -0
index 26e854a..380f933 100644
@@ -819,6 +819,9 @@ int kvm_arch_put_registers(CPUState *cs, int level)
 #ifdef TARGET_PPC64
         for (i = 0; i < ARRAY_SIZE(env->slb); i++) {
             sregs.u.s.ppc64.slb[i].slbe = env->slb[i].esid;
+            if (env->slb[i].esid & SLB_ESID_V) {
+                sregs.u.s.ppc64.slb[i].slbe |= i;
+            }
             sregs.u.s.ppc64.slb[i].slbv = env->slb[i].vsid;
         }
 #endif
Signature · 1 line
1.8.4.rc4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Alexey Kardashevskiy

When ppc_store_slb() is called from kvm_arch_get_registers(), it stores a SLB in CPUPPCState::slb[slot]. However it drops the slot number from ESID so when kvm_arch_put_registers() puts SLBs back to KVM, they do not have correct "index" field anymore. This broke migration with LPCR_AIR enabled as now the guest is handling interrupts in virtual mode and unable to reconstruct correct SLBs anymore.

This adds "index" field for valid SLBs when putting them to KVM.

Quoted 20 lines
---
 target-ppc/kvm.c | 3 +++
 1 file changed, 3 insertions(+)
target-ppc/kvm.c +3 -0
index 26e854a..380f933 100644
@@ -819,6 +819,9 @@ int kvm_arch_put_registers(CPUState *cs, int level)
 #ifdef TARGET_PPC64
         for (i = 0; i < ARRAY_SIZE(env->slb); i++) {
             sregs.u.s.ppc64.slb[i].slbe = env->slb[i].esid;
+            if (env->slb[i].esid & SLB_ESID_V) {
+                sregs.u.s.ppc64.slb[i].slbe |= i;
+            }
             sregs.u.s.ppc64.slb[i].slbv = env->slb[i].vsid;
         }
 #endif
Signature · 1 line
1.8.4.rc4
#2 lore raw
In reply to Alexey Kardashevskiy
Quoted 10 lines · Alexey Kardashevskiy

When ppc_store_slb() is called from kvm_arch_get_registers(), it stores a SLB in CPUPPCState::slb[slot]. However it drops the slot number from ESID so when kvm_arch_put_registers() puts SLBs back to KVM, they do not have correct "index" field anymore. This broke migration with LPCR_AIR enabled as now the guest is handling interrupts in virtual mode and unable to reconstruct correct SLBs anymore.

This adds "index" field for valid SLBs when putting them to KVM.

Thanks, applied to ppc-next (and marked CC stable).

Alex