From: "Nicholas Piggin" <npiggin@gmail.com>
To: "dan tan" <dantan@linux.vnet.ibm.com>, <qemu-devel@nongnu.org>
Cc: <danielhb413@gmail.com>, <clg@kaod.org>, <qemu-ppc@nongnu.org>
Subject: Re: [PATCH] ppc/pnv: Add PowerPC Special Purpose Registers
Date: Thu, 18 Jan 2024 12:23:49 +1000 [thread overview]
Message-ID: <CYHH429YYHUZ.2JYDWW2L6TA8F@wheely> (raw)
In-Reply-To: <20240117223429.2295-1-dantan@linux.vnet.ibm.com>
On Thu Jan 18, 2024 at 8:34 AM AEST, dan tan wrote:
> The handling of the following two registers are added -
> DAWR1 (0x0bd, 189) - Data Address Watchpoint 1
> DAWRX1 (0x0b5, 181) - Data Address Watchpoint Extension 1
>
> Signed-off-by: dan tan <dantan@linux.vnet.ibm.com>
Small nit, but there's some extra whitespace on the left here and in
Subject header which is normally not required.
> ---
> target/ppc/cpu.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
> target/ppc/cpu.h | 6 ++++++
> target/ppc/cpu_init.c | 10 ++++++++++
> target/ppc/excp_helper.c | 11 ++++++++++-
> target/ppc/helper.h | 2 ++
> target/ppc/machine.c | 1 +
> target/ppc/misc_helper.c | 10 ++++++++++
> target/ppc/spr_common.h | 2 ++
> target/ppc/translate.c | 12 ++++++++++++
> 9 files changed, 104 insertions(+), 1 deletion(-)
>
> diff --git a/target/ppc/cpu.c b/target/ppc/cpu.c
> index e3ad8e0..8a77328 100644
> --- a/target/ppc/cpu.c
> +++ b/target/ppc/cpu.c
> @@ -188,6 +188,57 @@ void ppc_store_dawrx0(CPUPPCState *env, uint32_t val)
> env->spr[SPR_DAWRX0] = val;
> ppc_update_daw0(env);
> }
> +
> +void ppc_update_daw1(CPUPPCState *env)
> +{
> + CPUState *cs = env_cpu(env);
> + target_ulong deaw = env->spr[SPR_DAWR1] & PPC_BITMASK(0, 60);
> + uint32_t dawrx = env->spr[SPR_DAWRX1];
> + int mrd = extract32(dawrx, PPC_BIT_NR(48), 54 - 48);
> + bool dw = extract32(dawrx, PPC_BIT_NR(57), 1);
> + bool dr = extract32(dawrx, PPC_BIT_NR(58), 1);
> + bool hv = extract32(dawrx, PPC_BIT_NR(61), 1);
> + bool sv = extract32(dawrx, PPC_BIT_NR(62), 1);
> + bool pr = extract32(dawrx, PPC_BIT_NR(62), 1);
> + vaddr len;
> + int flags;
> +
> + if (env->dawr1_watchpoint) {
> + cpu_watchpoint_remove_by_ref(cs, env->dawr1_watchpoint);
> + env->dawr1_watchpoint = NULL;
> + }
> +
> + if (!dr && !dw) {
> + return;
> + }
> +
> + if (!hv && !sv && !pr) {
> + return;
> + }
> +
> + len = (mrd + 1) * 8;
> + flags = BP_CPU | BP_STOP_BEFORE_ACCESS;
> + if (dr) {
> + flags |= BP_MEM_READ;
> + }
> + if (dw) {
> + flags |= BP_MEM_WRITE;
> + }
> +
> + cpu_watchpoint_insert(cs, deaw, len, flags, &env->dawr1_watchpoint);
> +}
I would say this is just beyond the point where we should share
code with daw0. You could make a function that takes DAWR(x) SPR
numbers or values, and a pointer to the watchpoint to use.
> +
> +void ppc_store_dawr1(CPUPPCState *env, target_ulong val)
> +{
> + env->spr[SPR_DAWR1] = val;
> + ppc_update_daw1(env);
> +}
> +
> +void ppc_store_dawrx1(CPUPPCState *env, uint32_t val)
> +{
> + env->spr[SPR_DAWRX1] = val;
> + ppc_update_daw1(env);
> +}
> #endif
> #endif
>
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index f8101ff..ab34fc7 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1237,6 +1237,7 @@ struct CPUArchState {
> ppc_slb_t slb[MAX_SLB_ENTRIES]; /* PowerPC 64 SLB area */
> struct CPUBreakpoint *ciabr_breakpoint;
> struct CPUWatchpoint *dawr0_watchpoint;
> + struct CPUWatchpoint *dawr1_watchpoint;
> #endif
> target_ulong sr[32]; /* segment registers */
> uint32_t nb_BATs; /* number of BATs */
> @@ -1552,6 +1553,9 @@ void ppc_store_ciabr(CPUPPCState *env, target_ulong value);
> void ppc_update_daw0(CPUPPCState *env);
> void ppc_store_dawr0(CPUPPCState *env, target_ulong value);
> void ppc_store_dawrx0(CPUPPCState *env, uint32_t value);
> +void ppc_update_daw1(CPUPPCState *env);
> +void ppc_store_dawr1(CPUPPCState *env, target_ulong value);
> +void ppc_store_dawrx1(CPUPPCState *env, uint32_t value);
> #endif /* !defined(CONFIG_USER_ONLY) */
> void ppc_store_msr(CPUPPCState *env, target_ulong value);
>
> @@ -1737,9 +1741,11 @@ void ppc_compat_add_property(Object *obj, const char *name,
> #define SPR_PSPB (0x09F)
> #define SPR_DPDES (0x0B0)
> #define SPR_DAWR0 (0x0B4)
> +#define SPR_DAWR1 (0x0B5)
> #define SPR_RPR (0x0BA)
> #define SPR_CIABR (0x0BB)
> #define SPR_DAWRX0 (0x0BC)
> +#define SPR_DAWRX1 (0x0BD)
> #define SPR_HFSCR (0x0BE)
> #define SPR_VRSAVE (0x100)
> #define SPR_USPRG0 (0x100)
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index 40fe14a..d75c359 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -5119,11 +5119,21 @@ static void register_book3s_207_dbg_sprs(CPUPPCState *env)
> SPR_NOACCESS, SPR_NOACCESS,
> &spr_read_generic, &spr_write_dawr0,
> KVM_REG_PPC_DAWR, 0x00000000);
> + spr_register_kvm_hv(env, SPR_DAWR1, "DAWR1",
> + SPR_NOACCESS, SPR_NOACCESS,
> + SPR_NOACCESS, SPR_NOACCESS,
> + &spr_read_generic, &spr_write_dawr1,
> + KVM_REG_PPC_DAWR, 0x00000000);
> spr_register_kvm_hv(env, SPR_DAWRX0, "DAWRX0",
> SPR_NOACCESS, SPR_NOACCESS,
> SPR_NOACCESS, SPR_NOACCESS,
> &spr_read_generic, &spr_write_dawrx0,
> KVM_REG_PPC_DAWRX, 0x00000000);
> + spr_register_kvm_hv(env, SPR_DAWRX1, "DAWRX1",
> + SPR_NOACCESS, SPR_NOACCESS,
> + SPR_NOACCESS, SPR_NOACCESS,
> + &spr_read_generic, &spr_write_dawrx1,
> + KVM_REG_PPC_DAWRX, 0x00000000);
These are new for POWER10, no? This is adding them for P8/9 too.
Thanks,
Nick
next prev parent reply other threads:[~2024-01-18 2:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 22:34 [PATCH] ppc/pnv: Add PowerPC Special Purpose Registers dan tan
2024-01-17 22:34 ` [PATCH] ppc/pnv: Add PowerPC Special Purpose Registers (SPRs): dan tan
2024-01-18 2:27 ` Nicholas Piggin
2024-01-18 2:23 ` Nicholas Piggin [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-02-05 5:49 [PATCH] ppc/pnv: Add PowerPC Special Purpose Registers dan tan
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=CYHH429YYHUZ.2JYDWW2L6TA8F@wheely \
--to=npiggin@gmail.com \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=dantan@linux.vnet.ibm.com \
--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 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).