aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2024-12-20 22:30:59 +0100
committerNicholas Piggin <npiggin@gmail.com>2025-03-11 22:43:31 +1000
commitc5411a065370ae2b056107ae68727c5cbb998233 (patch)
treec309218bd07b1d0e462c6e0e27176c8925e61b68
parentc894bdf78b32ed825903f4f05c765eecf2e4f1cc (diff)
downloadqemu-c5411a065370ae2b056107ae68727c5cbb998233.zip
qemu-c5411a065370ae2b056107ae68727c5cbb998233.tar.gz
qemu-c5411a065370ae2b056107ae68727c5cbb998233.tar.bz2
hw/ppc/spapr: Convert HPTE_VALID() macro as hpte_is_valid() method
Convert HPTE_VALID() macro as hpte_is_valid() 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. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Nicholas Piggin <npiggin@gmail.com> Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Message-ID: <20241220213103.6314-3-philmd@linaro.org> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
-rw-r--r--hw/ppc/spapr.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0cae485..daf997c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1409,7 +1409,11 @@ static uint64_t *hpte_get_ptr(SpaprMachineState *s, unsigned index)
return &table[2 * index];
}
-#define HPTE_VALID(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_VALID)
+static bool hpte_is_valid(SpaprMachineState *s, unsigned index)
+{
+ return ldq_be_p(hpte_get_ptr(s, index)) & HPTE64_V_VALID;
+}
+
#define HPTE_DIRTY(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY)
#define CLEAN_HPTE(_hpte) ((*(uint64_t *)(_hpte)) &= tswap64(~HPTE64_V_HPTE_DIRTY))
#define DIRTY_HPTE(_hpte) ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY))
@@ -2206,7 +2210,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr,
/* Consume invalid HPTEs */
while ((index < htabslots)
- && !HPTE_VALID(hpte_get_ptr(spapr, index))) {
+ && !hpte_is_valid(spapr, index)) {
CLEAN_HPTE(hpte_get_ptr(spapr, index));
index++;
}
@@ -2214,7 +2218,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr,
/* Consume valid HPTEs */
chunkstart = index;
while ((index < htabslots) && (index - chunkstart < USHRT_MAX)
- && HPTE_VALID(hpte_get_ptr(spapr, index))) {
+ && hpte_is_valid(spapr, index)) {
CLEAN_HPTE(hpte_get_ptr(spapr, index));
index++;
}
@@ -2264,7 +2268,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
/* Consume valid dirty HPTEs */
while ((index < htabslots) && (index - chunkstart < USHRT_MAX)
&& HPTE_DIRTY(hpte_get_ptr(spapr, index))
- && HPTE_VALID(hpte_get_ptr(spapr, index))) {
+ && hpte_is_valid(spapr, index)) {
CLEAN_HPTE(hpte_get_ptr(spapr, index));
index++;
examined++;
@@ -2274,7 +2278,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
/* Consume invalid dirty HPTEs */
while ((index < htabslots) && (index - invalidstart < USHRT_MAX)
&& HPTE_DIRTY(hpte_get_ptr(spapr, index))
- && !HPTE_VALID(hpte_get_ptr(spapr, index))) {
+ && !hpte_is_valid(spapr, index)) {
CLEAN_HPTE(hpte_get_ptr(spapr, index));
index++;
examined++;