diff mbox

[V9,2/5] target-ppc: Fix htab_mask calculation

Message ID 87lhxhtrlq.fsf@linux.vnet.ibm.com
State New
Headers show

Commit Message

Aneesh Kumar K.V Feb. 11, 2014, 6:46 p.m. UTC
Hi Greg,

can you try the below patch and see if it fix the TCG mode failure ?

-aneesh

commit d98b5098bc04f44ef4e175f689345e92cf469231
Author: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Date:   Tue Feb 11 23:43:12 2014 +0530

    tcg fixes

Comments

Greg Kurz Feb. 12, 2014, 10:32 a.m. UTC | #1
On Wed, 12 Feb 2014 00:16:25 +0530
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> 
> Hi Greg,
> 
> can you try the below patch and see if it fix the TCG mode failure ?
> 
> -aneesh
> 

Hi Aneesh,

The patche fixes the issue indeed. Maybe a helper could be factored out
since we have 4 times the same magic formula :)

Cheers.

--
Greg

> commit d98b5098bc04f44ef4e175f689345e92cf469231
> Author: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Date:   Tue Feb 11 23:43:12 2014 +0530
> 
>     tcg fixes
> 
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index e1f778faf3ae..d3aca706fdc9 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -91,7 +91,10 @@ static target_ulong h_enter(PowerPCCPU *cpu,
> sPAPREnvironment *spapr,
> 
>      pteh &= ~0x60ULL;
> 
> -    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
> +    /*
> +     * hash value/pteg group index is normalized by htab_mask
> +     */
> +    if (((pte_index & ~7ULL) / HPTES_PER_GROUP) & ~env->htab_mask) {
>          return H_PARAMETER;
>      }
> 
> @@ -140,7 +143,10 @@ static RemoveResult remove_hpte(CPUPPCState *env,
> target_ulong ptex, uint64_t token;
>      target_ulong v, r, rb;
> 
> -    if ((ptex * HASH_PTE_SIZE_64) & ~env->htab_mask) {
> +    /*
> +     * hash value/pteg group index is normalized by htab_mask
> +     */
> +    if (((ptex & ~7ULL) / HPTES_PER_GROUP) & ~env->htab_mask) {
>          return REMOVE_PARM;
>      }
> 
> @@ -266,7 +272,10 @@ static target_ulong h_protect(PowerPCCPU *cpu,
> sPAPREnvironment *spapr, uint64_t token;
>      target_ulong v, r, rb;
> 
> -    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
> +    /*
> +     * hash value/pteg group index is normalized by htab_mask
> +     */
> +    if (((pte_index & ~7ULL) / HPTES_PER_GROUP) & ~env->htab_mask) {
>          return H_PARAMETER;
>      }
> 
> @@ -303,7 +312,10 @@ static target_ulong h_read(PowerPCCPU *cpu,
> sPAPREnvironment *spapr, uint8_t *hpte;
>      int i, ridx, n_entries = 1;
> 
> -    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
> +    /*
> +     * hash value/pteg group index is normalized by htab_mask
> +     */
> +    if (((pte_index & ~7ULL) / HPTES_PER_GROUP) & ~env->htab_mask) {
>          return H_PARAMETER;
>      }
> 
> 
>
diff mbox

Patch

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index e1f778faf3ae..d3aca706fdc9 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -91,7 +91,10 @@  static target_ulong h_enter(PowerPCCPU *cpu, sPAPREnvironment *spapr,
 
     pteh &= ~0x60ULL;
 
-    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
+    /*
+     * hash value/pteg group index is normalized by htab_mask
+     */
+    if (((pte_index & ~7ULL) / HPTES_PER_GROUP) & ~env->htab_mask) {
         return H_PARAMETER;
     }
 
@@ -140,7 +143,10 @@  static RemoveResult remove_hpte(CPUPPCState *env, target_ulong ptex,
     uint64_t token;
     target_ulong v, r, rb;
 
-    if ((ptex * HASH_PTE_SIZE_64) & ~env->htab_mask) {
+    /*
+     * hash value/pteg group index is normalized by htab_mask
+     */
+    if (((ptex & ~7ULL) / HPTES_PER_GROUP) & ~env->htab_mask) {
         return REMOVE_PARM;
     }
 
@@ -266,7 +272,10 @@  static target_ulong h_protect(PowerPCCPU *cpu, sPAPREnvironment *spapr,
     uint64_t token;
     target_ulong v, r, rb;
 
-    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
+    /*
+     * hash value/pteg group index is normalized by htab_mask
+     */
+    if (((pte_index & ~7ULL) / HPTES_PER_GROUP) & ~env->htab_mask) {
         return H_PARAMETER;
     }
 
@@ -303,7 +312,10 @@  static target_ulong h_read(PowerPCCPU *cpu, sPAPREnvironment *spapr,
     uint8_t *hpte;
     int i, ridx, n_entries = 1;
 
-    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
+    /*
+     * hash value/pteg group index is normalized by htab_mask
+     */
+    if (((pte_index & ~7ULL) / HPTES_PER_GROUP) & ~env->htab_mask) {
         return H_PARAMETER;
     }