diff mbox series

[v4,4/6] hw/ppc/spapr: Convert CLEAN_HPTE() macro as hpte_set_clean() method

Message ID 20241220213103.6314-5-philmd@linaro.org
State New
Headers show
Series hw/ppc: Remove tswap() calls | expand

Commit Message

Philippe Mathieu-Daudé Dec. 20, 2024, 9:31 p.m. UTC
Convert CLEAN_HPTE() macro as hpte_set_clean() method.

sPAPR data structures including the hash page table are big-endian
regardless of current CPU endian mode, so use the big-endian LD/ST
API to access the hash PTEs.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/ppc/spapr.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 31df6fdc40c..e68e8c320f4 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1416,7 +1416,12 @@  static bool hpte_is_dirty(SpaprMachineState *s, unsigned index)
     return ldq_be_p(hpte_get_ptr(s, index)) & HPTE64_V_HPTE_DIRTY;
 }
 
-#define CLEAN_HPTE(_hpte)  ((*(uint64_t *)(_hpte)) &= tswap64(~HPTE64_V_HPTE_DIRTY))
+static void hpte_set_clean(SpaprMachineState *s, unsigned index)
+{
+    stq_be_p(hpte_get_ptr(s, index),
+             ldq_be_p(hpte_get_ptr(s, index)) & ~HPTE64_V_HPTE_DIRTY);
+}
+
 #define DIRTY_HPTE(_hpte)  ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY))
 
 /*
@@ -2213,7 +2218,7 @@  static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr,
         /* Consume invalid HPTEs */
         while ((index < htabslots)
                && !hpte_is_valid(spapr, index)) {
-            CLEAN_HPTE(hpte_get_ptr(spapr, index));
+            hpte_set_clean(spapr, index);
             index++;
         }
 
@@ -2221,7 +2226,7 @@  static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr,
         chunkstart = index;
         while ((index < htabslots) && (index - chunkstart < USHRT_MAX)
                && hpte_is_valid(spapr, index)) {
-            CLEAN_HPTE(hpte_get_ptr(spapr, index));
+            hpte_set_clean(spapr, index);
             index++;
         }
 
@@ -2271,7 +2276,7 @@  static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
         while ((index < htabslots) && (index - chunkstart < USHRT_MAX)
                && hpte_is_dirty(spapr, index)
                && hpte_is_valid(spapr, index)) {
-            CLEAN_HPTE(hpte_get_ptr(spapr, index));
+            hpte_set_clean(spapr, index);
             index++;
             examined++;
         }
@@ -2281,7 +2286,7 @@  static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
         while ((index < htabslots) && (index - invalidstart < USHRT_MAX)
                && hpte_is_dirty(spapr, index)
                && !hpte_is_valid(spapr, index)) {
-            CLEAN_HPTE(hpte_get_ptr(spapr, index));
+            hpte_set_clean(spapr, index);
             index++;
             examined++;
         }