All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"BALATON Zoltan" <balaton@eik.bme.hu>,
	qemu-ppc@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH v3 3/7] hw/ppc/spapr: Convert HPTE_VALID() macro as hpte_is_valid() method
Date: Thu, 19 Dec 2024 10:18:24 +1000	[thread overview]
Message-ID: <D6F8V34XKSZT.G6WIVYBYDYEF@gmail.com> (raw)
In-Reply-To: <20241218182106.78800-4-philmd@linaro.org>

On Thu Dec 19, 2024 at 4:21 AM AEST, Philippe Mathieu-Daudé wrote:
> Convert HPTE_VALID() macro as hpte_is_valid() method.
> Since sPAPR is in big endian configuration at reset,
> use the big endian LD/ST API to access the hash PTEs.

My knowlege of old platforms isn't great here, but I believe sPAPR
always has big-endian data structures in hardware and hypervisor
interfaces (which encompasses practically everything QEMU should be
concerned with). So patch is good, you could just reword the
changelog to make it clearer.

 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>
> ---
>  hw/ppc/spapr.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 4845bf3244b..b67ab1ee685 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1406,7 +1406,11 @@ static uint64_t *hpte_get(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(s, index)) & HPTE64_V_VALID;
> +}

With the previous change to hpte_get_ptr(), here we could have a new
uint64_t hpte_get(s, index) helper that calculates the pointer and does
the load?

Otherwise,

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

> +
>  #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))
> @@ -2204,7 +2208,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr,
>  
>          /* Consume invalid HPTEs */
>          while ((index < htabslots)
> -               && !HPTE_VALID(hpte_get(spapr->htab, index))) {
> +               && !hpte_is_valid(spapr->htab, index)) {
>              CLEAN_HPTE(hpte_get(spapr->htab, index));
>              index++;
>          }
> @@ -2212,7 +2216,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(spapr->htab, index))) {
> +               && hpte_is_valid(spapr->htab, index)) {
>              CLEAN_HPTE(hpte_get(spapr->htab, index));
>              index++;
>          }
> @@ -2262,7 +2266,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(spapr->htab, index))
> -               && HPTE_VALID(hpte_get(spapr->htab, index))) {
> +               && hpte_is_valid(spapr->htab, index)) {
>              CLEAN_HPTE(hpte_get(spapr->htab, index));
>              index++;
>              examined++;
> @@ -2272,7 +2276,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(spapr->htab, index))
> -               && !HPTE_VALID(hpte_get(spapr->htab, index))) {
> +               && !hpte_is_valid(spapr->htab, index)) {
>              CLEAN_HPTE(hpte_get(spapr->htab, index));
>              index++;
>              examined++;



  reply	other threads:[~2024-12-19  0:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 18:20 [PATCH v3 0/7] hw/ppc: Remove tswap() calls Philippe Mathieu-Daudé
2024-12-18 18:21 ` [PATCH v3 1/7] meson: Run some compiler checks using -Wno-unused-value Philippe Mathieu-Daudé
2024-12-19  0:37   ` Nicholas Piggin
2024-12-19 17:39     ` Philippe Mathieu-Daudé
2024-12-19 18:14       ` Richard Henderson
2024-12-18 18:21 ` [PATCH v3 2/7] hw/ppc/spapr: Convert HPTE() macro as hpte_get() method Philippe Mathieu-Daudé
2024-12-19  0:08   ` Nicholas Piggin
2024-12-19  6:31   ` Harsh Prateek Bora
2024-12-20 21:29     ` Philippe Mathieu-Daudé
2024-12-18 18:21 ` [PATCH v3 3/7] hw/ppc/spapr: Convert HPTE_VALID() macro as hpte_is_valid() method Philippe Mathieu-Daudé
2024-12-19  0:18   ` Nicholas Piggin [this message]
2024-12-18 18:21 ` [PATCH v3 4/7] hw/ppc/spapr: Convert HPTE_DIRTY() macro as hpte_is_dirty() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-19  6:52   ` Harsh Prateek Bora
2024-12-18 18:21 ` [PATCH v3 5/7] hw/ppc/spapr: Convert CLEAN_HPTE() macro as hpte_set_clean() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-19  6:56   ` Harsh Prateek Bora
2024-12-18 18:21 ` [PATCH v3 6/7] hw/ppc/spapr: Convert DIRTY_HPTE() macro as hpte_set_dirty() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-18 18:21 ` [PATCH v3 7/7] hw/ppc/epapr: Do not swap ePAPR magic value Philippe Mathieu-Daudé
2024-12-18 19:18   ` BALATON Zoltan
2024-12-19  0:29     ` Nicholas Piggin
2024-12-19  1:43       ` BALATON Zoltan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D6F8V34XKSZT.G6WIVYBYDYEF@gmail.com \
    --to=npiggin@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=berrange@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=harshpb@linux.ibm.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.