[PATCH v3 6/7] hw/ppc/spapr: Convert DIRTY_HPTE() macro as hpte_set_dirty() method

Philippe Mathieu-Daudé posted 7 patches 3 months, 3 weeks ago
There is a newer version of this series
[PATCH v3 6/7] hw/ppc/spapr: Convert DIRTY_HPTE() macro as hpte_set_dirty() method
Posted by Philippe Mathieu-Daudé 3 months, 3 weeks ago
Convert DIRTY_HPTE() macro as hpte_set_dirty() method.
Since sPAPR is in big endian configuration at reset,
use the big endian LD/ST API to access the HPTEs.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/ppc/spapr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 4e1fe832c29..dedf6fb2916 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1422,7 +1422,11 @@ static void hpte_set_clean(SpaprMachineState *s, unsigned index)
              ldq_be_p(hpte_get(s, index)) & ~HPTE64_V_HPTE_DIRTY);
 }
 
-#define DIRTY_HPTE(_hpte)  ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY))
+static void hpte_set_dirty(SpaprMachineState *s, unsigned index)
+{
+    stq_be_p(hpte_get(s, index),
+             ldq_be_p(hpte_get(s, index)) | HPTE64_V_HPTE_DIRTY);
+}
 
 /*
  * Get the fd to access the kernel htab, re-opening it if necessary
@@ -1633,7 +1637,7 @@ int spapr_reallocate_hpt(SpaprMachineState *spapr, int shift, Error **errp)
         spapr->htab_shift = shift;
 
         for (i = 0; i < size / HASH_PTE_SIZE_64; i++) {
-            DIRTY_HPTE(hpte_get(spapr->htab, i));
+            hpte_set_dirty(spapr->htab, i);
         }
     }
     /* We're setting up a hash table, so that means we're not radix */
-- 
2.45.2


Re: [PATCH v3 6/7] hw/ppc/spapr: Convert DIRTY_HPTE() macro as hpte_set_dirty() method
Posted by Nicholas Piggin 3 months, 2 weeks ago
On Thu Dec 19, 2024 at 4:21 AM AEST, Philippe Mathieu-Daudé wrote:
> Convert DIRTY_HPTE() macro as hpte_set_dirty() method.
> Since sPAPR is in big endian configuration at reset,
> use the big endian LD/ST API to access the HPTEs.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/ppc/spapr.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 4e1fe832c29..dedf6fb2916 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1422,7 +1422,11 @@ static void hpte_set_clean(SpaprMachineState *s, unsigned index)
>               ldq_be_p(hpte_get(s, index)) & ~HPTE64_V_HPTE_DIRTY);
>  }
>  
> -#define DIRTY_HPTE(_hpte)  ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY))
> +static void hpte_set_dirty(SpaprMachineState *s, unsigned index)
> +{
> +    stq_be_p(hpte_get(s, index),
> +             ldq_be_p(hpte_get(s, index)) | HPTE64_V_HPTE_DIRTY);
> +}
>  
>  /*
>   * Get the fd to access the kernel htab, re-opening it if necessary
> @@ -1633,7 +1637,7 @@ int spapr_reallocate_hpt(SpaprMachineState *spapr, int shift, Error **errp)
>          spapr->htab_shift = shift;
>  
>          for (i = 0; i < size / HASH_PTE_SIZE_64; i++) {
> -            DIRTY_HPTE(hpte_get(spapr->htab, i));
> +            hpte_set_dirty(spapr->htab, i);
>          }
>      }
>      /* We're setting up a hash table, so that means we're not radix */