diff mbox

[1/3] target-ppc: Update slb array with correct index values.

Message ID 1376915356-31011-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com
State New
Headers show

Commit Message

Aneesh Kumar K.V Aug. 19, 2013, 12:29 p.m. UTC
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>

Without this, a value of rb=0 and rs=0, results in replacing the 0th
index. This can be observed when using gdb remote debugging support.

(gdb) x/10i do_fork
   0xc000000000085330 <do_fork>:        Cannot access memory at address 0xc000000000085330
(gdb)

This is because when we do the slb sync via kvm_cpu_synchronize_state,
we overwrite the slb entry (0th entry) for 0xc00000000008533

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 target-ppc/kvm.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Andreas Färber Aug. 19, 2013, 12:42 p.m. UTC | #1
Am 19.08.2013 14:29, schrieb Aneesh Kumar K.V:
> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
> 
> Without this, a value of rb=0 and rs=0, results in replacing the 0th

"... rs=0 results in ..."

> index. This can be observed when using gdb remote debugging support.
> 
> (gdb) x/10i do_fork
>    0xc000000000085330 <do_fork>:        Cannot access memory at address 0xc000000000085330
> (gdb)
> 
> This is because when we do the slb sync via kvm_cpu_synchronize_state,
> we overwrite the slb entry (0th entry) for 0xc00000000008533

Is there a trailing 0 missing here?

> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  target-ppc/kvm.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
> index 30a870e..5d4e613 100644
> --- a/target-ppc/kvm.c
> +++ b/target-ppc/kvm.c
> @@ -1034,8 +1034,18 @@ int kvm_arch_get_registers(CPUState *cs)
>          /* Sync SLB */
>  #ifdef TARGET_PPC64
>          for (i = 0; i < 64; i++) {
> -            ppc_store_slb(env, sregs.u.s.ppc64.slb[i].slbe,
> -                               sregs.u.s.ppc64.slb[i].slbv);
> +            target_ulong rb  = sregs.u.s.ppc64.slb[i].slbe;

Double space.

> +            /*
> +             * KVM_GET_SREGS doesn't retun slb entry with slot information
> +             * same as index. So don't depend on the slot information in
> +             * the returned value.
> +             */
> +            rb &= ~0xfff;
> +            /*
> +             * use the array index as the slot
> +             */
> +            rb |= i;
> +            ppc_store_slb(env, rb, sregs.u.s.ppc64.slb[i].slbv);
>          }
>  #endif
>  

Regards,
Andreas
Andreas Färber Aug. 19, 2013, 12:50 p.m. UTC | #2
Am 19.08.2013 14:42, schrieb Andreas Färber:
> Am 19.08.2013 14:29, schrieb Aneesh Kumar K.V:
>> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>>
>> Without this, a value of rb=0 and rs=0, results in replacing the 0th
> 
> "... rs=0 results in ..."
> 
>> index. This can be observed when using gdb remote debugging support.
>>
>> (gdb) x/10i do_fork
>>    0xc000000000085330 <do_fork>:        Cannot access memory at address 0xc000000000085330
>> (gdb)
>>
>> This is because when we do the slb sync via kvm_cpu_synchronize_state,
>> we overwrite the slb entry (0th entry) for 0xc00000000008533
> 
> Is there a trailing 0 missing here?
> 
>>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>> ---
>>  target-ppc/kvm.c | 14 ++++++++++++--
>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
>> index 30a870e..5d4e613 100644
>> --- a/target-ppc/kvm.c
>> +++ b/target-ppc/kvm.c
>> @@ -1034,8 +1034,18 @@ int kvm_arch_get_registers(CPUState *cs)
>>          /* Sync SLB */
>>  #ifdef TARGET_PPC64
>>          for (i = 0; i < 64; i++) {
>> -            ppc_store_slb(env, sregs.u.s.ppc64.slb[i].slbe,
>> -                               sregs.u.s.ppc64.slb[i].slbv);
>> +            target_ulong rb  = sregs.u.s.ppc64.slb[i].slbe;
> 
> Double space.
> 
>> +            /*
>> +             * KVM_GET_SREGS doesn't retun slb entry with slot information

"return"

>> +             * same as index. So don't depend on the slot information in
>> +             * the returned value.
>> +             */
>> +            rb &= ~0xfff;
>> +            /*
>> +             * use the array index as the slot
>> +             */
>> +            rb |= i;
>> +            ppc_store_slb(env, rb, sregs.u.s.ppc64.slb[i].slbv);
>>          }
>>  #endif
>>  
> 
> Regards,
> Andreas
>
diff mbox

Patch

diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 30a870e..5d4e613 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1034,8 +1034,18 @@  int kvm_arch_get_registers(CPUState *cs)
         /* Sync SLB */
 #ifdef TARGET_PPC64
         for (i = 0; i < 64; i++) {
-            ppc_store_slb(env, sregs.u.s.ppc64.slb[i].slbe,
-                               sregs.u.s.ppc64.slb[i].slbv);
+            target_ulong rb  = sregs.u.s.ppc64.slb[i].slbe;
+            /*
+             * KVM_GET_SREGS doesn't retun slb entry with slot information
+             * same as index. So don't depend on the slot information in
+             * the returned value.
+             */
+            rb &= ~0xfff;
+            /*
+             * use the array index as the slot
+             */
+            rb |= i;
+            ppc_store_slb(env, rb, sregs.u.s.ppc64.slb[i].slbv);
         }
 #endif