Convert HPTE_DIRTY() macro as hpte_is_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 | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index b67ab1ee685..5bc49598a97 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1411,7 +1411,11 @@ static bool hpte_is_valid(SpaprMachineState *s, unsigned index)
return ldq_be_p(hpte_get(s, index)) & HPTE64_V_VALID;
}
-#define HPTE_DIRTY(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY)
+static bool hpte_is_dirty(SpaprMachineState *s, unsigned index)
+{
+ return ldq_be_p(hpte_get(s, index)) & 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))
@@ -2257,7 +2261,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
/* Consume non-dirty HPTEs */
while ((index < htabslots)
- && !HPTE_DIRTY(hpte_get(spapr->htab, index))) {
+ && !hpte_is_dirty(spapr->htab, index)) {
index++;
examined++;
}
@@ -2265,7 +2269,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
chunkstart = index;
/* Consume valid dirty HPTEs */
while ((index < htabslots) && (index - chunkstart < USHRT_MAX)
- && HPTE_DIRTY(hpte_get(spapr->htab, index))
+ && hpte_is_dirty(spapr->htab, index)
&& hpte_is_valid(spapr->htab, index)) {
CLEAN_HPTE(hpte_get(spapr->htab, index));
index++;
@@ -2275,7 +2279,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
invalidstart = index;
/* Consume invalid dirty HPTEs */
while ((index < htabslots) && (index - invalidstart < USHRT_MAX)
- && HPTE_DIRTY(hpte_get(spapr->htab, index))
+ && hpte_is_dirty(spapr->htab, index)
&& !hpte_is_valid(spapr->htab, index)) {
CLEAN_HPTE(hpte_get(spapr->htab, index));
index++;
--
2.45.2
Hi Philippe,
Similar issue here as with patch 2 ..
On 12/18/24 23:51, Philippe Mathieu-Daudé wrote:
> Convert HPTE_DIRTY() macro as hpte_is_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 | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index b67ab1ee685..5bc49598a97 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1411,7 +1411,11 @@ static bool hpte_is_valid(SpaprMachineState *s, unsigned index)
> return ldq_be_p(hpte_get(s, index)) & HPTE64_V_VALID;
> }
>
> -#define HPTE_DIRTY(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY)
> +static bool hpte_is_dirty(SpaprMachineState *s, unsigned index)
> +{
> + return ldq_be_p(hpte_get(s, index)) & 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))
>
> @@ -2257,7 +2261,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
>
> /* Consume non-dirty HPTEs */
> while ((index < htabslots)
> - && !HPTE_DIRTY(hpte_get(spapr->htab, index))) {
> + && !hpte_is_dirty(spapr->htab, index)) {
hpte_is_dirty expects SpaprMachineState * as arg, need to update
accordingly.
regards,
Harsh
> index++;
> examined++;
> }
> @@ -2265,7 +2269,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
> chunkstart = index;
> /* Consume valid dirty HPTEs */
> while ((index < htabslots) && (index - chunkstart < USHRT_MAX)
> - && HPTE_DIRTY(hpte_get(spapr->htab, index))
> + && hpte_is_dirty(spapr->htab, index)
> && hpte_is_valid(spapr->htab, index)) {
> CLEAN_HPTE(hpte_get(spapr->htab, index));
> index++;
> @@ -2275,7 +2279,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
> invalidstart = index;
> /* Consume invalid dirty HPTEs */
> while ((index < htabslots) && (index - invalidstart < USHRT_MAX)
> - && HPTE_DIRTY(hpte_get(spapr->htab, index))
> + && hpte_is_dirty(spapr->htab, index)
> && !hpte_is_valid(spapr->htab, index)) {
> CLEAN_HPTE(hpte_get(spapr->htab, index));
> index++;
On Thu Dec 19, 2024 at 4:21 AM AEST, Philippe Mathieu-Daudé wrote:
> Convert HPTE_DIRTY() macro as hpte_is_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>
All the other helper changes look good +/- suggestions from the
first one.
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> hw/ppc/spapr.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index b67ab1ee685..5bc49598a97 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1411,7 +1411,11 @@ static bool hpte_is_valid(SpaprMachineState *s, unsigned index)
> return ldq_be_p(hpte_get(s, index)) & HPTE64_V_VALID;
> }
>
> -#define HPTE_DIRTY(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY)
> +static bool hpte_is_dirty(SpaprMachineState *s, unsigned index)
> +{
> + return ldq_be_p(hpte_get(s, index)) & 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))
>
> @@ -2257,7 +2261,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
>
> /* Consume non-dirty HPTEs */
> while ((index < htabslots)
> - && !HPTE_DIRTY(hpte_get(spapr->htab, index))) {
> + && !hpte_is_dirty(spapr->htab, index)) {
> index++;
> examined++;
> }
> @@ -2265,7 +2269,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
> chunkstart = index;
> /* Consume valid dirty HPTEs */
> while ((index < htabslots) && (index - chunkstart < USHRT_MAX)
> - && HPTE_DIRTY(hpte_get(spapr->htab, index))
> + && hpte_is_dirty(spapr->htab, index)
> && hpte_is_valid(spapr->htab, index)) {
> CLEAN_HPTE(hpte_get(spapr->htab, index));
> index++;
> @@ -2275,7 +2279,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr,
> invalidstart = index;
> /* Consume invalid dirty HPTEs */
> while ((index < htabslots) && (index - invalidstart < USHRT_MAX)
> - && HPTE_DIRTY(hpte_get(spapr->htab, index))
> + && hpte_is_dirty(spapr->htab, index)
> && !hpte_is_valid(spapr->htab, index)) {
> CLEAN_HPTE(hpte_get(spapr->htab, index));
> index++;
© 2016 - 2026 Red Hat, Inc.