From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Cc: Alexander Graf <agraf@suse.de>,
Aurelien Jarno <aurelien@aurel32.net>,
Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH 09/15] target-s390x: PER successful-branching event support
Date: Sat, 13 Jun 2015 00:45:57 +0200 [thread overview]
Message-ID: <1434149163-16639-10-git-send-email-aurelien@aurel32.net> (raw)
In-Reply-To: <1434149163-16639-1-git-send-email-aurelien@aurel32.net>
For the PER successful-branching event support, we can't rely on any
QEMU infrastucture. We therefore call an helper in all places where
a branch can be taken. We have to pay attention to the branch to next
case, as it's still a taken branch.
We don't need to care about the cases using goto_tb, as we have disabled
them in the previous patch.
Cc: Alexander Graf <agraf@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-s390x/helper.h | 1 +
target-s390x/misc_helper.c | 11 +++++++++++
target-s390x/translate.c | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
diff --git a/target-s390x/helper.h b/target-s390x/helper.h
index 37bd4d7..8d89cff 100644
--- a/target-s390x/helper.h
+++ b/target-s390x/helper.h
@@ -117,4 +117,5 @@ DEF_HELPER_FLAGS_2(lurag, TCG_CALL_NO_WG, i64, env, i64)
DEF_HELPER_FLAGS_3(stura, TCG_CALL_NO_WG, void, env, i64, i64)
DEF_HELPER_FLAGS_3(sturg, TCG_CALL_NO_WG, void, env, i64, i64)
DEF_HELPER_1(per_check_exception, void, env)
+DEF_HELPER_FLAGS_3(per_branch, TCG_CALL_NO_RWG, void, env, i64, i64)
#endif
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index d19ae91..8972929 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -508,4 +508,15 @@ void HELPER(per_check_exception)(CPUS390XState *env)
cpu_loop_exit(cs);
}
}
+
+void HELPER(per_branch)(CPUS390XState *env, uint64_t from, uint64_t to)
+{
+ if ((env->cregs[9] & PER_CR9_EVENT_BRANCH)) {
+ if (!(env->cregs[9] & PER_CR9_CONTROL_BRANCH_ADDRESS)
+ || get_per_in_range(env, to)) {
+ env->per_address = from;
+ env->per_perc_atmid = PER_CODE_EVENT_BRANCH | get_per_atmid(env);
+ }
+ }
+}
#endif
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index ff2c4bb..897486c 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -249,6 +249,38 @@ static void update_psw_addr(DisasContext *s)
tcg_gen_movi_i64(psw_addr, s->pc);
}
+static void per_branch(DisasContext *s, bool to_next)
+{
+#ifndef CONFIG_USER_ONLY
+ if (s->tb->flags & FLAG_MASK_PER) {
+ TCGv_i64 pc = tcg_const_i64(s->pc);
+ TCGv_i64 next_pc = to_next ? tcg_const_i64(s->next_pc) : psw_addr;
+ gen_helper_per_branch(cpu_env, pc, next_pc);
+ if (to_next) {
+ tcg_temp_free_i64(next_pc);
+ }
+ tcg_temp_free_i64(pc);
+ }
+#endif
+}
+
+static void per_branch_cond(DisasContext *s, TCGCond cond,
+ TCGv_i64 arg1, TCGv_i64 arg2)
+{
+#ifndef CONFIG_USER_ONLY
+ if (s->tb->flags & FLAG_MASK_PER) {
+ TCGLabel *lab = gen_new_label();
+ tcg_gen_brcond_i64(tcg_invert_cond(cond), arg1, arg2, lab);
+
+ TCGv_i64 pc = tcg_const_i64(s->pc);
+ gen_helper_per_branch(cpu_env, pc, psw_addr);
+ tcg_temp_free_i64(pc);
+
+ gen_set_label(lab);
+ }
+#endif
+}
+
static void update_cc_op(DisasContext *s)
{
if (s->cc_op != CC_OP_DYNAMIC && s->cc_op != CC_OP_STATIC) {
@@ -1182,6 +1214,7 @@ static void help_l2_shift(DisasContext *s, DisasFields *f,
static ExitStatus help_goto_direct(DisasContext *s, uint64_t dest)
{
if (dest == s->next_pc) {
+ per_branch(s, true);
return NO_EXIT;
}
if (use_goto_tb(s, dest)) {
@@ -1192,6 +1225,7 @@ static ExitStatus help_goto_direct(DisasContext *s, uint64_t dest)
return EXIT_GOTO_TB;
} else {
tcg_gen_movi_i64(psw_addr, dest);
+ per_branch(s, false);
return EXIT_PC_UPDATED;
}
}
@@ -1211,6 +1245,7 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c,
if (is_imm) {
if (dest == s->next_pc) {
/* Branch to next. */
+ per_branch(s, true);
ret = NO_EXIT;
goto egress;
}
@@ -1226,6 +1261,7 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c,
}
if (c->cond == TCG_COND_ALWAYS) {
tcg_gen_mov_i64(psw_addr, cdest);
+ per_branch(s, false);
ret = EXIT_PC_UPDATED;
goto egress;
}
@@ -1296,6 +1332,7 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c,
if (c->is_64) {
tcg_gen_movcond_i64(c->cond, psw_addr, c->u.s64.a, c->u.s64.b,
cdest, next);
+ per_branch_cond(s, c->cond, c->u.s64.a, c->u.s64.b);
} else {
TCGv_i32 t0 = tcg_temp_new_i32();
TCGv_i64 t1 = tcg_temp_new_i64();
@@ -1304,6 +1341,7 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c,
tcg_gen_extu_i32_i64(t1, t0);
tcg_temp_free_i32(t0);
tcg_gen_movcond_i64(TCG_COND_NE, psw_addr, t1, z, cdest, next);
+ per_branch_cond(s, TCG_COND_NE, t1, z);
tcg_temp_free_i64(t1);
tcg_temp_free_i64(z);
}
@@ -1436,6 +1474,7 @@ static ExitStatus op_bas(DisasContext *s, DisasOps *o)
tcg_gen_movi_i64(o->out, pc_to_link_info(s, s->next_pc));
if (!TCGV_IS_UNUSED_I64(o->in2)) {
tcg_gen_mov_i64(psw_addr, o->in2);
+ per_branch(s, false);
return EXIT_PC_UPDATED;
} else {
return NO_EXIT;
--
2.1.4
next prev parent reply other threads:[~2015-06-12 22:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-12 22:45 [Qemu-devel] [PATCH 00/15] target-s390x: add Program-Event Recording feature Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 01/15] softmmu: provide tlb_vaddr_to_host function for user mode Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 02/15] target-s390x: function to adjust the length wrt page boundary Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 03/15] target-s390x: mvc_fast_memset: access memory through softmmu Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 04/15] target-s390x: mvc_fast_memmove: " Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 05/15] target-s390x: add PER related constants Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 06/15] target-s390x: add get_per_atmid function Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 07/15] target-s390x: add get_per_in_range function Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 08/15] target-s390x: basic PER event handling Aurelien Jarno
2015-06-12 22:45 ` Aurelien Jarno [this message]
2015-06-12 22:45 ` [Qemu-devel] [PATCH 10/15] target-s390x: PER instruction-fetch event support Aurelien Jarno
2015-06-12 22:45 ` [Qemu-devel] [PATCH 11/15] translate-all: fix watchpoints if retranslation not possible Aurelien Jarno
2015-06-12 22:46 ` [Qemu-devel] [PATCH 12/15] target-s390x: PER storage-alteration event support Aurelien Jarno
2015-06-12 22:46 ` [Qemu-devel] [PATCH 13/15] target-s390x: PER store-using-real-address " Aurelien Jarno
2015-06-12 22:46 ` [Qemu-devel] [PATCH 14/15] target-s390x: PER instruction-fetch nullification " Aurelien Jarno
2015-06-12 22:46 ` [Qemu-devel] [PATCH 15/15] target-s390x: PER: add Breaking-Event-Address register Aurelien Jarno
2015-06-16 16:44 ` Alexander Graf
2015-06-16 17:44 ` Aurelien Jarno
2015-06-16 17:50 ` Alexander Graf
2015-06-16 17:55 ` [Qemu-devel] [PATCH 00/15] target-s390x: add Program-Event Recording feature 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=1434149163-16639-10-git-send-email-aurelien@aurel32.net \
--to=aurelien@aurel32.net \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).