From: Chinmay Rath <rathc@linux.vnet.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>, qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org,
Daniel Henrique Barboza <danielhb413@gmail.com>,
Chinmay Rath <rathc@linux.ibm.com>
Subject: Re: [PATCH 3/3] target/ppc: Add ISA v3.1 variants of sync instruction
Date: Tue, 7 May 2024 12:39:03 +0530 [thread overview]
Message-ID: <2bd50388-2bb0-42c5-a2ce-8c243c2051dd@linux.vnet.ibm.com> (raw)
In-Reply-To: <20240501130435.941189-4-npiggin@gmail.com>
On 5/1/24 18:34, Nicholas Piggin wrote:
> POWER10 adds a new field to sync for store-store syncs, and some
> new variants of the existing syncs that include persistent memory.
>
> Implement the store-store syncs and plwsync/phwsync.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Chinmay Rath <rathc@linux.ibm.com>
> ---
> target/ppc/insn32.decode | 6 ++--
> target/ppc/translate/misc-impl.c.inc | 41 ++++++++++++++++++++--------
> 2 files changed, 32 insertions(+), 15 deletions(-)
>
> diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
> index 6b89804b15..a180380750 100644
> --- a/target/ppc/insn32.decode
> +++ b/target/ppc/insn32.decode
> @@ -1001,7 +1001,7 @@ MSGSYNC 011111 ----- ----- ----- 1101110110 -
>
> # Memory Barrier Instructions
>
> -&X_sync l
> -@X_sync ...... ... l:2 ..... ..... .......... . &X_sync
> -SYNC 011111 --- .. ----- ----- 1001010110 - @X_sync
> +&X_sync l sc
> +@X_sync ...... .. l:3 ... sc:2 ..... .......... . &X_sync
> +SYNC 011111 -- ... --- .. ----- 1001010110 - @X_sync
> EIEIO 011111 ----- ----- ----- 1101010110 -
> diff --git a/target/ppc/translate/misc-impl.c.inc b/target/ppc/translate/misc-impl.c.inc
> index 9226467f81..3467b49d0d 100644
> --- a/target/ppc/translate/misc-impl.c.inc
> +++ b/target/ppc/translate/misc-impl.c.inc
> @@ -25,6 +25,7 @@ static bool trans_SYNC(DisasContext *ctx, arg_X_sync *a)
> {
> TCGBar bar = TCG_MO_ALL;
> uint32_t l = a->l;
> + uint32_t sc = a->sc;
>
> /*
> * BookE uses the msync mnemonic. This means hwsync, except in the
> @@ -46,20 +47,36 @@ static bool trans_SYNC(DisasContext *ctx, arg_X_sync *a)
> gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
> }
>
> - if ((l == 1) && (ctx->insns_flags2 & PPC2_MEM_LWSYNC)) {
> - bar = TCG_MO_LD_LD | TCG_MO_LD_ST | TCG_MO_ST_ST;
> - }
> -
> /*
> - * We may need to check for a pending TLB flush.
> - *
> - * We do this on ptesync (l == 2) on ppc64 and any sync on ppc32.
> - *
> - * Additionally, this can only happen in kernel mode however so
> - * check MSR_PR as well.
> + * In ISA v3.1, the L field grew one bit. Mask that out to ignore it in
> + * older processors. It also added the SC field, zero this to ignore
> + * it too.
> */
> - if (((l == 2) || !(ctx->insns_flags & PPC_64B)) && !ctx->pr) {
> - gen_check_tlb_flush(ctx, true);
> + if (!(ctx->insns_flags2 & PPC2_ISA310)) {
> + l &= 0x3;
> + sc = 0;
> + }
> +
> + if (sc) {
> + /* Store syncs [stsync, stcisync, stncisync]. These ignore L. */
> + bar = TCG_MO_ST_ST;
> + } else {
> + if (((l == 1) && (ctx->insns_flags2 & PPC2_MEM_LWSYNC)) || (l == 5)) {
> + /* lwsync, or plwsync on POWER10 and later */
> + bar = TCG_MO_LD_LD | TCG_MO_LD_ST | TCG_MO_ST_ST;
> + }
> +
> + /*
> + * We may need to check for a pending TLB flush.
> + *
> + * We do this on ptesync (l == 2) on ppc64 and any sync on ppc32.
> + *
> + * Additionally, this can only happen in kernel mode however so
> + * check MSR_PR as well.
> + */
> + if (((l == 2) || !(ctx->insns_flags & PPC_64B)) && !ctx->pr) {
> + gen_check_tlb_flush(ctx, true);
> + }
> }
>
> tcg_gen_mb(bar | TCG_BAR_SC);
prev parent reply other threads:[~2024-05-07 7:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-01 13:04 [PATCH 0/3] target/ppc: Fixes and updates for sync instructions Nicholas Piggin
2024-05-01 13:04 ` [PATCH 1/3] target/ppc: Move sync instructions to decodetree Nicholas Piggin
2024-05-07 6:41 ` Chinmay Rath
2024-05-01 13:04 ` [PATCH 2/3] target/ppc: Fix embedded memory barriers Nicholas Piggin
2024-05-07 7:24 ` Chinmay Rath
2024-05-01 13:04 ` [PATCH 3/3] target/ppc: Add ISA v3.1 variants of sync instruction Nicholas Piggin
2024-05-07 7:09 ` Chinmay Rath [this message]
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=2bd50388-2bb0-42c5-a2ce-8c243c2051dd@linux.vnet.ibm.com \
--to=rathc@linux.vnet.ibm.com \
--cc=danielhb413@gmail.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rathc@linux.ibm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).