Skip to contentSkip to conversation

target-ppc: fix sync of SPR_SDR1 with KVM

PATCH In review Greg Kurz 2 participants 5 messages Mar 1, 2016 – Mar 4, 2016

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 target-ppc: fix sync of SPR_SDR1 with KVM

The gdbstub can't access guest memory with current master. This is what you get in gdb:

0x00000000100009b8 in main (argc=<error reading variable: Cannot access memory at address 0x3fffce4d3620>, argv=<error reading variable: Cannot access memory at address 0x3fffce4d3628>) at fp.c:11

Bisect leads to the following commit:

commit fa48b4328c39b2532e47efcfcba6d4031512f514

Author: David Gibson <[email protected]>
Date:   Tue Feb 9 09:30:21 2016 +1000

target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM

Looking at the env->external_htab users, I've spotted a behaviour change in kvm_arch_get_registers(), which now always calls ppc_store_sdr1().

Checking kvmppc_kern_htab, like it is done in the MMU helpers, fixes the issue.

---
 target-ppc/kvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/kvm.c +1 -1
index d67c169ba324..dbc37f25af2b 100644
@@ -1190,7 +1190,7 @@ int kvm_arch_get_registers(CPUState *cs)
             return ret;
         }
 
-        if (!env->external_htab) {
+        if (!kvmppc_kern_htab && !env->external_htab) {
             ppc_store_sdr1(env, sregs.u.s.sdr1);
         }
 
#1 lore raw
Quoted 15 lines · Greg Kurz

The gdbstub can't access guest memory with current master. This is what you get in gdb:

0x00000000100009b8 in main (argc=<error reading variable: Cannot access memory at address 0x3fffce4d3620>, argv=<error reading variable: Cannot access memory at address 0x3fffce4d3628>) at fp.c:11

Bisect leads to the following commit:

commit fa48b4328c39b2532e47efcfcba6d4031512f514

Author: David Gibson <[email protected]>
Date:   Tue Feb 9 09:30:21 2016 +1000

target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM

Quoted 7 lines

Looking at the env->external_htab users, I've spotted a behaviour change in kvm_arch_get_registers(), which now always calls ppc_store_sdr1().

Checking kvmppc_kern_htab, like it is done in the MMU helpers, fixes the issue.

Mea culpa. Good catch, applied to ppc-for-2.6, thanks.

Quoted 18 lines
---
 target-ppc/kvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/kvm.c +1 -1
index d67c169ba324..dbc37f25af2b 100644
@@ -1190,7 +1190,7 @@ int kvm_arch_get_registers(CPUState *cs)
             return ret;
         }
 
-        if (!env->external_htab) {
+        if (!kvmppc_kern_htab && !env->external_htab) {
             ppc_store_sdr1(env, sregs.u.s.sdr1);
         }
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#2 lore raw
Quoted 19 lines · David Gibson
Quoted 18 lines · Greg Kurz

The gdbstub can't access guest memory with current master. This is what you get in gdb:

0x00000000100009b8 in main (argc=<error reading variable: Cannot access memory at address 0x3fffce4d3620>, argv=<error reading variable: Cannot access memory at address 0x3fffce4d3628>) at fp.c:11

Bisect leads to the following commit:

commit fa48b4328c39b2532e47efcfcba6d4031512f514

Author: David Gibson <[email protected]>
Date:   Tue Feb 9 09:30:21 2016 +1000

target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM

Looking at the env->external_htab users, I've spotted a behaviour change in kvm_arch_get_registers(), which now always calls ppc_store_sdr1().

Quoted 6 lines
Quoted 4 lines

Checking kvmppc_kern_htab, like it is done in the MMU helpers, fixes the issue.

Mea culpa. Good catch, applied to ppc-for-2.6, thanks.

Ah.. wait.. this patch breaks compile for the ppc32 target. Can you fix this please.

Quoted 19 lines
Quoted 18 lines
---
 target-ppc/kvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/kvm.c +1 -1
index d67c169ba324..dbc37f25af2b 100644
@@ -1190,7 +1190,7 @@ int kvm_arch_get_registers(CPUState *cs)
             return ret;
         }
 
-        if (!env->external_htab) {
+        if (!kvmppc_kern_htab && !env->external_htab) {
             ppc_store_sdr1(env, sregs.u.s.sdr1);
         }
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
author
#3 lore raw
Quoted 23 lines · On Thu, 3 Mar 2016 15:35:07 +1100 David Gibson <[email protected]>…
Quoted 22 lines · David Gibson
Quoted 21 lines · Greg Kurz

The gdbstub can't access guest memory with current master. This is what you get in gdb:

0x00000000100009b8 in main (argc=<error reading variable: Cannot access memory at address 0x3fffce4d3620>, argv=<error reading variable: Cannot access memory at address 0x3fffce4d3628>) at fp.c:11

Bisect leads to the following commit:

commit fa48b4328c39b2532e47efcfcba6d4031512f514

Author: David Gibson <[email protected]>
Date:   Tue Feb 9 09:30:21 2016 +1000

target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM

Looking at the env->external_htab users, I've spotted a behaviour change in kvm_arch_get_registers(), which now always calls ppc_store_sdr1().

Checking kvmppc_kern_htab, like it is done in the MMU helpers, fixes the issue.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Mea culpa. Good catch, applied to ppc-for-2.6, thanks.

Ah.. wait.. this patch breaks compile for the ppc32 target. Can you fix this please.

Oops... I'm on vacation this week. Not sure I can find time before next monday... :\

Quoted 22 lines
Quoted 19 lines
Quoted 18 lines
---
 target-ppc/kvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/kvm.c +1 -1
index d67c169ba324..dbc37f25af2b 100644
@@ -1190,7 +1190,7 @@ int kvm_arch_get_registers(CPUState *cs)
             return ret;
         }
 
-        if (!env->external_htab) {
+        if (!kvmppc_kern_htab && !env->external_htab) {
             ppc_store_sdr1(env, sregs.u.s.sdr1);
         }
 
#4 lore raw
Quoted 28 lines · Greg Kurz
Quoted 25 lines · On Thu, 3 Mar 2016 15:35:07 +1100 David Gibson <[email protected]>…
Quoted 24 lines · David Gibson
Quoted 22 lines · Greg Kurz

The gdbstub can't access guest memory with current master. This is what you get in gdb:

0x00000000100009b8 in main (argc=<error reading variable: Cannot access memory at address 0x3fffce4d3620>, argv=<error reading variable: Cannot access memory at address 0x3fffce4d3628>) at fp.c:11

Bisect leads to the following commit:

commit fa48b4328c39b2532e47efcfcba6d4031512f514

Author: David Gibson <[email protected]>
Date:   Tue Feb 9 09:30:21 2016 +1000

target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM

Looking at the env->external_htab users, I've spotted a behaviour change in kvm_arch_get_registers(), which now always calls ppc_store_sdr1().

Checking kvmppc_kern_htab, like it is done in the MMU helpers, fixes the issue.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Mea culpa. Good catch, applied to ppc-for-2.6, thanks.

Ah.. wait.. this patch breaks compile for the ppc32 target. Can you fix this please.

Oops... I'm on vacation this week. Not sure I can find time before next monday... :\

Ok. I've had a closer look and realized that the earlier commit (fa48b43) was basically a bad idea. I'll shortly post something to accomplish its aims in a different and better way.

Quoted 24 lines
Quoted 23 lines
Quoted 20 lines
Quoted 19 lines
---
 target-ppc/kvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/kvm.c +1 -1
index d67c169ba324..dbc37f25af2b 100644
@@ -1190,7 +1190,7 @@ int kvm_arch_get_registers(CPUState *cs)
             return ret;
         }
 
-        if (!env->external_htab) {
+        if (!kvmppc_kern_htab && !env->external_htab) {
             ppc_store_sdr1(env, sregs.u.s.sdr1);
         }
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson