From: Alexander Graf <agraf@suse.de>
To: qemu-devel Developers <qemu-devel@nongnu.org>
Cc: Blue Swirl <blauwirbel@gmail.com>,
qemu-ppc@nongnu.org, Aurelien Jarno <aurelien@aurel32.net>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 47/58] Implement POWER7's CFAR in TCG
Date: Wed, 14 Sep 2011 10:43:11 +0200 [thread overview]
Message-ID: <1315989802-18753-48-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1315989802-18753-1-git-send-email-agraf@suse.de>
From: David Gibson <david@gibson.dropbear.id.au>
This patch implements support for the CFAR SPR on POWER7 (Come From
Address Register), which snapshots the PC value at the time of a branch or
an rfid. The latest powerpc-next kernel also catches it and can show it in
xmon or in the signal frames.
This works well enough to let recent kernels boot (which otherwise oops
on the CFAR access). It hasn't been tested enough to be confident that the
CFAR values are actually accurate, but one thing at a time.
Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
target-ppc/cpu.h | 8 ++++++++
target-ppc/translate.c | 28 ++++++++++++++++++++++++++++
target-ppc/translate_init.c | 23 ++++++++++++++++++++++-
3 files changed, 58 insertions(+), 1 deletions(-)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 32706df..3f4af22 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -555,6 +555,8 @@ enum {
/* Decrementer clock: RTC clock (POWER, 601) or bus clock */
POWERPC_FLAG_RTC_CLK = 0x00010000,
POWERPC_FLAG_BUS_CLK = 0x00020000,
+ /* Has CFAR */
+ POWERPC_FLAG_CFAR = 0x00040000,
};
/*****************************************************************************/
@@ -872,6 +874,10 @@ struct CPUPPCState {
target_ulong ctr;
/* condition register */
uint32_t crf[8];
+#if defined(TARGET_PPC64)
+ /* CFAR */
+ target_ulong cfar;
+#endif
/* XER */
target_ulong xer;
/* Reservation address */
@@ -1204,6 +1210,7 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp)
#define SPR_601_UDECR (0x006)
#define SPR_LR (0x008)
#define SPR_CTR (0x009)
+#define SPR_DSCR (0x011)
#define SPR_DSISR (0x012)
#define SPR_DAR (0x013) /* DAE for PowerPC 601 */
#define SPR_601_RTCU (0x014)
@@ -1212,6 +1219,7 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp)
#define SPR_SDR1 (0x019)
#define SPR_SRR0 (0x01A)
#define SPR_SRR1 (0x01B)
+#define SPR_CFAR (0x01C)
#define SPR_AMR (0x01D)
#define SPR_BOOKE_PID (0x030)
#define SPR_BOOKE_DECAR (0x036)
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 4277460..1e362fc 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -69,6 +69,9 @@ static TCGv cpu_nip;
static TCGv cpu_msr;
static TCGv cpu_ctr;
static TCGv cpu_lr;
+#if defined(TARGET_PPC64)
+static TCGv cpu_cfar;
+#endif
static TCGv cpu_xer;
static TCGv cpu_reserve;
static TCGv_i32 cpu_fpscr;
@@ -154,6 +157,11 @@ void ppc_translate_init(void)
cpu_lr = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, lr), "lr");
+#if defined(TARGET_PPC64)
+ cpu_cfar = tcg_global_mem_new(TCG_AREG0,
+ offsetof(CPUState, cfar), "cfar");
+#endif
+
cpu_xer = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, xer), "xer");
@@ -187,6 +195,7 @@ typedef struct DisasContext {
int le_mode;
#if defined(TARGET_PPC64)
int sf_mode;
+ int has_cfar;
#endif
int fpu_enabled;
int altivec_enabled;
@@ -3345,6 +3354,14 @@ static inline void gen_qemu_st32fiw(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
/* stfiwx */
GEN_STXF(stfiw, st32fiw, 0x17, 0x1E, PPC_FLOAT_STFIWX);
+static inline void gen_update_cfar(DisasContext *ctx, target_ulong nip)
+{
+#if defined(TARGET_PPC64)
+ if (ctx->has_cfar)
+ tcg_gen_movi_tl(cpu_cfar, nip);
+#endif
+}
+
/*** Branch ***/
static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
{
@@ -3407,6 +3424,7 @@ static void gen_b(DisasContext *ctx)
target = li;
if (LK(ctx->opcode))
gen_setlr(ctx, ctx->nip);
+ gen_update_cfar(ctx, ctx->nip);
gen_goto_tb(ctx, 0, target);
}
@@ -3469,6 +3487,7 @@ static inline void gen_bcond(DisasContext *ctx, int type)
}
tcg_temp_free_i32(temp);
}
+ gen_update_cfar(ctx, ctx->nip);
if (type == BCOND_IM) {
target_ulong li = (target_long)((int16_t)(BD(ctx->opcode)));
if (likely(AA(ctx->opcode) == 0)) {
@@ -3580,6 +3599,7 @@ static void gen_rfi(DisasContext *ctx)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
+ gen_update_cfar(ctx, ctx->nip);
gen_helper_rfi();
gen_sync_exception(ctx);
#endif
@@ -3596,6 +3616,7 @@ static void gen_rfid(DisasContext *ctx)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
+ gen_update_cfar(ctx, ctx->nip);
gen_helper_rfid();
gen_sync_exception(ctx);
#endif
@@ -9263,6 +9284,12 @@ void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
*/
}
+#if defined(TARGET_PPC64)
+ if (env->flags & POWERPC_FLAG_CFAR) {
+ cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar);
+ }
+#endif
+
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
@@ -9371,6 +9398,7 @@ static inline void gen_intermediate_code_internal(CPUState *env,
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_sf;
+ ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 9ea193d..211f3bd 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -129,6 +129,19 @@ static void spr_write_lr (void *opaque, int sprn, int gprn)
tcg_gen_mov_tl(cpu_lr, cpu_gpr[gprn]);
}
+/* CFAR */
+#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
+static void spr_read_cfar (void *opaque, int gprn, int sprn)
+{
+ tcg_gen_mov_tl(cpu_gpr[gprn], cpu_cfar);
+}
+
+static void spr_write_cfar (void *opaque, int sprn, int gprn)
+{
+ tcg_gen_mov_tl(cpu_cfar, cpu_gpr[gprn]);
+}
+#endif /* defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) */
+
/* CTR */
static void spr_read_ctr (void *opaque, int gprn, int sprn)
{
@@ -6489,7 +6502,7 @@ static void init_proc_970MP (CPUPPCState *env)
#define POWERPC_BFDM_POWER7 (bfd_mach_ppc64)
#define POWERPC_FLAG_POWER7 (POWERPC_FLAG_VRE | POWERPC_FLAG_SE | \
POWERPC_FLAG_BE | POWERPC_FLAG_PMM | \
- POWERPC_FLAG_BUS_CLK)
+ POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR)
#define check_pow_POWER7 check_pow_nocheck
static void init_proc_POWER7 (CPUPPCState *env)
@@ -6508,6 +6521,14 @@ static void init_proc_POWER7 (CPUPPCState *env)
&spr_read_purr, SPR_NOACCESS,
&spr_read_purr, SPR_NOACCESS,
0x00000000);
+ spr_register(env, SPR_CFAR, "SPR_CFAR",
+ SPR_NOACCESS, SPR_NOACCESS,
+ &spr_read_cfar, &spr_write_cfar,
+ 0x00000000);
+ spr_register(env, SPR_DSCR, "SPR_DSCR",
+ SPR_NOACCESS, SPR_NOACCESS,
+ &spr_read_generic, &spr_write_generic,
+ 0x00000000);
#endif /* !CONFIG_USER_ONLY */
/* Memory management */
/* XXX : not implemented */
--
1.6.0.2
next prev parent reply other threads:[~2011-09-14 8:43 UTC|newest]
Thread overview: 128+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-14 8:42 [Qemu-devel] [PULL 00/58] ppc patch queue 2011-09-14 Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 01/58] spapr: proper qdevification Alexander Graf
2011-09-15 3:14 ` David Gibson
2011-09-15 7:01 ` Paolo Bonzini
2011-09-16 3:06 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2011-09-16 10:41 ` Paolo Bonzini
2011-09-16 13:27 ` Thomas Huth
2011-09-16 13:28 ` Paolo Bonzini
2011-09-16 15:51 ` Benjamin Herrenschmidt
2011-09-19 6:55 ` Thomas Huth
2011-09-19 6:59 ` Paolo Bonzini
2011-09-16 14:08 ` David Gibson
2011-09-19 6:50 ` Paolo Bonzini
2011-09-14 8:42 ` [Qemu-devel] [PATCH 02/58] spapr: prepare for qdevification of irq Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 03/58] spapr: make irq customizable via qdev Alexander Graf
2011-09-15 3:15 ` David Gibson
2011-09-15 6:51 ` Paolo Bonzini
2011-09-14 8:42 ` [Qemu-devel] [PATCH 04/58] PPC: Move openpic to target specific code compilation Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 05/58] PPC: Add CPU local MMIO regions to MPIC Alexander Graf
2011-09-14 10:07 ` Peter Maydell
2011-09-14 10:11 ` Alexander Graf
2011-09-14 10:22 ` Jan Kiszka
2011-09-14 11:59 ` Avi Kivity
2011-09-14 8:42 ` [Qemu-devel] [PATCH 06/58] PPC: Extend MPIC MMIO range Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 07/58] PPC: Fix IPI support in MPIC Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 08/58] PPC: Set MPIC IDE for IPI to 0 Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 09/58] PPC: MPIC: Remove read functionality for WO registers Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 10/58] PPC: MPIC: Fix CI bit definitions Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 11/58] PPC: Bump MPIC up to 32 supported CPUs Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 12/58] PPC: E500: create multiple envs Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 13/58] PPC: E500: Generate IRQ lines for many CPUs Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 14/58] device tree: add nop_node Alexander Graf
2011-09-17 16:48 ` Blue Swirl
2011-09-19 11:22 ` Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 15/58] PPC: bamboo: Move host fdt copy to target Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 16/58] PPC: KVM: Add generic function to read host clockfreq Alexander Graf
2011-09-15 3:16 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2011-09-14 8:42 ` [Qemu-devel] [PATCH 17/58] PPC: E500: Use generic kvm function for freq Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 18/58] PPC: E500: Remove mpc8544_copy_soc_cell Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 19/58] PPC: bamboo: Use kvm api for freq and clock frequencies Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 20/58] PPC: KVM: Remove kvmppc_read_host_property Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 21/58] PPC: KVM: Add stubs for kvm helper functions Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 22/58] PPC: E500: Update freqs for all CPUs Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 23/58] PPC: E500: Remove unneeded CPU nodes Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 24/58] PPC: E500: Add PV spinning code Alexander Graf
2011-09-17 16:58 ` Blue Swirl
2011-09-17 17:15 ` Alexander Graf
2011-09-17 17:40 ` Blue Swirl
2011-09-19 11:35 ` Alexander Graf
2011-09-19 16:12 ` Scott Wood
2011-09-24 7:41 ` Blue Swirl
2011-09-24 8:03 ` Alexander Graf
2011-09-24 8:44 ` Blue Swirl
2011-09-24 10:00 ` Alexander Graf
2011-09-24 10:18 ` Blue Swirl
2011-09-26 23:19 ` Scott Wood
2011-09-27 15:50 ` Blue Swirl
2011-09-27 15:59 ` Alexander Graf
2011-09-27 16:53 ` Blue Swirl
2011-09-27 17:01 ` Richard Henderson
2011-09-27 17:17 ` Blue Swirl
2011-09-27 17:19 ` Richard Henderson
2011-09-27 17:23 ` Blue Swirl
2011-09-27 17:03 ` Alexander Graf
2011-09-27 17:20 ` Blue Swirl
2011-09-27 17:23 ` Alexander Graf
2011-09-27 19:05 ` Blue Swirl
2011-09-28 7:40 ` Alexander Graf
2011-09-27 17:58 ` Scott Wood
2011-09-27 18:47 ` Blue Swirl
2011-09-14 8:42 ` [Qemu-devel] [PATCH 25/58] PPC: E500: Update cpu-release-addr property in cpu nodes Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 26/58] device tree: add add_subnode command Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 27/58] device tree: dont fail operations Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 28/58] device tree: give dt more size Alexander Graf
2011-09-15 3:19 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2011-09-15 7:37 ` Alexander Graf
2011-09-15 11:03 ` David Gibson
2011-09-15 15:00 ` Alexander Graf
2011-09-16 1:49 ` David Gibson
2011-09-14 8:42 ` [Qemu-devel] [PATCH 29/58] MPC8544DS: Remove CPU nodes Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 30/58] MPC8544DS: Generate CPU nodes on init Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 31/58] PPC: E500: Bump CPU count to 15 Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 32/58] PPC: Add new target config for pseries Alexander Graf
2011-09-15 3:20 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2011-09-14 8:42 ` [Qemu-devel] [PATCH 33/58] KVM: update kernel headers Alexander Graf
2011-09-17 16:59 ` Blue Swirl
2011-09-17 17:17 ` Alexander Graf
2011-09-19 17:50 ` [Qemu-devel] [Qemu-ppc] " Scott Wood
2011-09-19 17:50 ` Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 34/58] PPC: Enable to use PAPR with PR style KVM Alexander Graf
2011-09-14 8:42 ` [Qemu-devel] [PATCH 35/58] PPC: SPAPR: Use KVM function for time info Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 36/58] pseries: Bugfixes for interrupt numbering in XICS code Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 37/58] pseries: Add a phandle to the xicp interrupt controller device tree node Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 38/58] pseries: interrupt controller should not have a 'reg' property Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 39/58] pseries: More complete WIMG validation in H_ENTER code Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 40/58] PPC: Fix sync instructions problem in SMP Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 41/58] pseries: Add real mode debugging hcalls Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 42/58] pseries: use macro for firmware filename Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 43/58] KVM: Update kernel headers Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 44/58] kvm: ppc: booke206: use MMU API Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 45/58] ppc: booke206: add "info tlb" support Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 46/58] ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages Alexander Graf
2011-09-14 8:43 ` Alexander Graf [this message]
2011-09-17 17:08 ` [Qemu-devel] [PATCH 47/58] Implement POWER7's CFAR in TCG Blue Swirl
2011-09-19 6:00 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2011-09-19 6:47 ` Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 48/58] pseries: Implement hcall-bulk hypervisor interface Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 49/58] vscsi: send the CHECK_CONDITION status down together with autosense data Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 50/58] pseries: Update SLOF firmware image Alexander Graf
2011-09-14 11:01 ` Peter Maydell
2011-09-14 12:24 ` Alexander Graf
2011-09-14 12:28 ` Peter Maydell
2011-09-14 12:59 ` Anthony Liguori
2011-09-14 20:17 ` Blue Swirl
2011-09-19 8:32 ` Alexander Graf
2011-09-20 3:40 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2011-09-24 12:45 ` Paolo Bonzini
2011-09-27 1:01 ` David Gibson
2011-09-27 6:39 ` Alexander Graf
2011-09-29 4:21 ` David Gibson
2011-09-14 8:43 ` [Qemu-devel] [PATCH 51/58] Gdbstub: handle read of fpscr Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 52/58] ppc405: use RAM_ADDR_FMT instead of %08lx Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 53/58] openpic: Unfold read_IRQreg Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 54/58] openpic: Unfold write_IRQreg Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 55/58] ppc: move ADB stuff from ppc_mac.h to adb.h Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 56/58] PPC: Fix via-cuda memory registration Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 57/58] PPC: Fix heathrow PIC to use little endian MMIO Alexander Graf
2011-09-14 8:43 ` [Qemu-devel] [PATCH 58/58] KVM: Update kernel headers Alexander Graf
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=1315989802-18753-48-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=david@gibson.dropbear.id.au \
--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).