From: Richard Henderson <rth@twiddle.net>
To: "Lluís Vilanova" <vilanova@ac.upc.edu>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [PATCH v9 04/26] target: [tcg] Add generic translation framework
Date: Mon, 26 Jun 2017 19:39:28 -0700 [thread overview]
Message-ID: <171b9eb8-87c3-f70f-2a6a-f9dc2a0c5743@twiddle.net> (raw)
In-Reply-To: <149838119390.6497.17430428991952287717.stgit@frigg.lan>
On 06/25/2017 01:59 AM, Lluís Vilanova wrote:
> +static inline void translate_block_tcg_check(const DisasContextBase *db)
> +{
> + if (tcg_check_temp_count()) {
> + error_report("warning: TCG temporary leaks before "TARGET_FMT_lx,
> + db->pc_next);
> + }
> +}
> +
> +void translate_block(const TranslatorOps *ops, DisasContextBase *db,
> + CPUState *cpu, TCGv_env *tcg_cpu, TranslationBlock *tb)
tcg_cpu isn't the best name -- it doesn't reference a version of cpu. Of
course, you can always get at tcg_ctx.tcg_env, so there's no point in passing
it anyway.
> + /* Sanity-check ops */
> + if (ops->disas_insn == NULL) {
> + error_report("Missing ops->disas_insn");
> + abort();
> + }
Why? Surely an immediate crash by calling to null is just as easy to debug.
And, bikeshedding, perhaps translate_insn is a better name. On the first read
through I assumed this was related to the disassembly log.
> + while (true) {
> + CPUBreakpoint *bp;
> +
> + db->num_insns++;
> + if (ops->insn_start) {
> + ops->insn_start(db, cpu);
> + }
This *must* be defined. A target cannot skip emitting insn_start or unwinding
won't work.
> +
> + /* Early exit before breakpoint checks */
> + if (unlikely(db->is_jmp != DJ_NEXT)) {
> + break;
> + }
This must be done at the end of the loop, not at the beginning of the next
loop, after we've already emitted insn_start for the following insn.
That said, you already do have that check below, so what is this intended to do?
> + /* Pass breakpoint hits to target for further processing */
> + bp = NULL;
> + do {
> + bp = cpu_breakpoint_get(cpu, db->pc_next, bp);
> + if (unlikely(bp) && ops->breakpoint_check) {
> + BreakpointCheckType bp_check = ops->breakpoint_check(
Is there any point in any of these hooks being null?
An empty function in most cases, or here, one that returns BC_MISS.
> + db, cpu, bp);
> + if (bp_check == BC_HIT_INSN) {
> + /* Hit, keep translating */
> + /*
> + * TODO: if we're never going to have more than one BP in a
> + * single address, we can simply use a bool here.
> + */
> + break;
> + } else if (bp_check == BC_HIT_TB) {
> + goto done_generating;
> + } else {
> + error_report("Unexpected BreakpointCheckType %d", bp_check);
> + abort();
What happened to BC_MISS? And surely better structured as a switch with
default:
g_assert_not_reached();
rather than custom logging.
> +#ifdef DEBUG_DISAS
> + if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) &&
> + qemu_log_in_addr_range(db->pc_first)) {
> + int flags;
> + if (ops->disas_flags) {
> + flags = ops->disas_flags(db);
> + } else {
> + flags = 0;
> + }
> + qemu_log_lock();
> + qemu_log("----------------\n");
> + qemu_log("IN: %s\n", lookup_symbol(db->pc_first));
> + log_target_disas(cpu, db->pc_first, db->pc_next - db->pc_first, flags);
> + qemu_log("\n");
> + qemu_log_unlock();
I think the hook shouldn't be just the flags, but the whole call to
log_target_disas, at which point there isn't a reason to have a separate in a
hook for the flags. Consider the extra checks done for s390x and hppa.
r~
next prev parent reply other threads:[~2017-06-27 2:39 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-25 8:43 [Qemu-devel] [RFC PATCH v9 00/26] translate: [tcg] Generic translation framework Lluís Vilanova
2017-06-25 8:47 ` [Qemu-devel] [PATCH v9 01/26] Pass generic CPUState to gen_intermediate_code() Lluís Vilanova
2017-06-26 10:04 ` [Qemu-devel] [PATCH] fixup! " Alex Bennée
2017-06-26 12:37 ` Lluís Vilanova
2017-06-26 17:50 ` [Qemu-devel] [PATCH v9 01/26] " Emilio G. Cota
2017-06-25 8:51 ` [Qemu-devel] [PATCH v9 02/26] queue: Add macro for incremental traversal Lluís Vilanova
2017-06-25 8:55 ` [Qemu-devel] [PATCH v9 03/26] cpu-exec: Avoid global variables in icount-related functions Lluís Vilanova
2017-06-26 17:53 ` Emilio G. Cota
2017-06-25 8:59 ` [Qemu-devel] [PATCH v9 04/26] target: [tcg] Add generic translation framework Lluís Vilanova
2017-06-26 10:14 ` Alex Bennée
2017-06-26 12:50 ` Lluís Vilanova
2017-06-26 18:21 ` Peter Maydell
2017-06-27 3:22 ` Richard Henderson
2017-06-27 9:23 ` Peter Maydell
2017-06-27 2:47 ` Richard Henderson
2017-06-26 17:57 ` Emilio G. Cota
2017-06-26 18:12 ` Emilio G. Cota
2017-06-27 11:32 ` Lluís Vilanova
2017-06-27 2:39 ` Richard Henderson [this message]
2017-06-27 15:41 ` Lluís Vilanova
2017-06-25 9:03 ` [Qemu-devel] [PATCH v9 05/26] target: [tcg] Redefine DISAS_* onto the generic translation framework (DJ_*) Lluís Vilanova
2017-06-26 11:28 ` [Qemu-devel] [PATCH] maybe fixup! " Alex Bennée
2017-06-26 18:05 ` [Qemu-devel] [PATCH v9 05/26] " Emilio G. Cota
2017-06-25 9:07 ` [Qemu-devel] [PATCH v9 06/26] target: [tcg, i386] Port to DisasContextBase Lluís Vilanova
2017-06-26 18:14 ` Emilio G. Cota
2017-06-28 11:23 ` Lluís Vilanova
2017-06-29 21:50 ` Emilio G. Cota
2017-06-25 9:12 ` [Qemu-devel] [PATCH v9 07/26] target: [tcg, i386] Refactor init_disas_context Lluís Vilanova
2017-06-27 2:57 ` Richard Henderson
2017-06-27 6:07 ` Lluís Vilanova
2017-06-25 9:16 ` [Qemu-devel] [PATCH v9 08/26] target: [tcg, i386] Refactor init_globals Lluís Vilanova
2017-06-25 9:20 ` [Qemu-devel] [PATCH v9 09/26] target: [tcg, i386] Refactor insn_start Lluís Vilanova
2017-06-25 9:24 ` [Qemu-devel] [PATCH v9 10/26] target: [tcg, i386] Refactor breakpoint_check Lluís Vilanova
2017-06-25 9:28 ` [Qemu-devel] [PATCH v9 11/26] target: [tcg, i386] Refactor disas_insn Lluís Vilanova
2017-06-25 9:32 ` [Qemu-devel] [PATCH v9 12/26] target: [tcg,i386] Refactor tb_stop Lluís Vilanova
2017-06-25 9:36 ` [Qemu-devel] [PATCH v9 13/26] target: [tcg, i386] Refactor disas_flags Lluís Vilanova
2017-06-25 9:40 ` [Qemu-devel] [PATCH v9 14/26] target: [tcg, i386] Replace DISAS_* with DJ_* Lluís Vilanova
2017-06-25 9:48 ` [Qemu-devel] [PATCH v9 16/26] target: [tcg, arm] " Lluís Vilanova
2017-06-26 18:08 ` Emilio G. Cota
2017-06-25 9:52 ` [Qemu-devel] [PATCH v9 17/26] target: [tcg, arm] Port to DisasContextBase Lluís Vilanova
2017-06-25 9:56 ` [Qemu-devel] [PATCH v9 18/26] target: [tcg, arm] Port to init_disas_context Lluís Vilanova
2017-06-25 10:00 ` [Qemu-devel] [PATCH v9 19/26] target: [tcg, arm] Port to init_globals Lluís Vilanova
2017-06-25 10:04 ` [Qemu-devel] [PATCH v9 20/26] target: [tcg,arm] Port to tb_start Lluís Vilanova
2017-06-25 10:08 ` [Qemu-devel] [PATCH v9 21/26] target: [tcg, arm] Port to insn_start Lluís Vilanova
2017-06-26 11:31 ` Alex Bennée
2017-06-27 3:33 ` Richard Henderson
2017-06-28 11:48 ` Lluís Vilanova
2017-06-25 10:12 ` [Qemu-devel] [PATCH v9 22/26] target: [tcg, arm] Port to breakpoint_check Lluís Vilanova
2017-06-25 10:16 ` [Qemu-devel] [PATCH v9 23/26] target: [tcg, arm] Port to disas_insn Lluís Vilanova
2017-06-25 10:20 ` [Qemu-devel] [PATCH v9 24/26] target: [tcg,arm] Port to tb_stop Lluís Vilanova
2017-06-25 10:24 ` [Qemu-devel] [PATCH v9 25/26] target: [tcg, arm] Port to disas_flags Lluís Vilanova
2017-06-25 10:28 ` [Qemu-devel] [PATCH v9 26/26] target: [tcg, arm] Port to generic translation framework Lluís Vilanova
2017-06-27 3:47 ` Richard Henderson
2017-06-26 11:34 ` [Qemu-devel] [RFC PATCH v9 00/26] translate: [tcg] Generic " Alex Bennée
2017-06-26 13:02 ` Lluís Vilanova
2017-06-27 3:00 ` Eric Blake
2017-06-27 12:23 ` Lluís Vilanova
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=171b9eb8-87c3-f70f-2a6a-f9dc2a0c5743@twiddle.net \
--to=rth@twiddle.net \
--cc=alex.bennee@linaro.org \
--cc=crosthwaite.peter@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vilanova@ac.upc.edu \
/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).