[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v11 04/29] target: [tcg] Add generic translation
From: |
Emilio G. Cota |
Subject: |
Re: [Qemu-devel] [PATCH v11 04/29] target: [tcg] Add generic translation framework |
Date: |
Thu, 29 Jun 2017 20:02:40 -0400 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Wed, Jun 28, 2017 at 15:32:48 +0300, Lluís Vilanova wrote:
> Signed-off-by: Lluís Vilanova <address@hidden>
> ---
> accel/tcg/Makefile.objs | 1
> accel/tcg/translator.c | 153
> +++++++++++++++++++++++++++++++++++++++++++++
> include/exec/gen-icount.h | 2 -
> include/exec/translator.h | 104 +++++++++++++++++++++++++++++++
(snip)
> +/**
> + * BreakpointCheckType:
> + * @BC_MISS: No hit
> + * @BC_HIT_INSN: Hit, but continue translating TB
> + * @BC_HIT_TB: Hit, stop translating TB
> + *
> + * How to react to a breakpoint. A hit means no more breakpoints will be
> checked
> + * for the current instruction.
> + *
> + * Not all breakpoints associated to an address are necessarily raised by
> + * targets (e.g., due to conditions encoded in their flags), so tey can
> decide
s/tey/they/
> + * that a breakpoint missed the address (@BP_MISS).
> + */
> +typedef enum BreakpointCheckType {
> + BC_MISS,
> + BC_HIT_INSN,
> + BC_HIT_TB,
> +} BreakpointCheckType;
> +
> /**
> * DisasJumpType:
> * @DISAS_NEXT: Next instruction in program order.
> @@ -33,6 +65,78 @@ typedef enum DisasJumpType {
> DISAS_TARGET_9,
> DISAS_TARGET_10,
> DISAS_TARGET_11,
> + DISAS_TARGET_12,
> + DISAS_TARGET_13,
> + DISAS_TARGET_14,
> } DisasJumpType;
>
> +/**
> + * DisasContextBase:
> + * @tb: Translation block for this disassembly.
> + * @pc_first: Address of first guest instruction in this TB.
> + * @pc_next: Address of next guest instruction in this TB (current during
> + * disassembly).
> + * @is_jmp: What instruction to disassemble next.
> + * @num_insns: Number of translated instructions (including current).
> + * @singlestep_enabled: "Hardware" single stepping enabled.
> + *
> + * Architecture-agnostic disassembly context.
> + */
> +typedef struct DisasContextBase {
> + TranslationBlock *tb;
> + target_ulong pc_first;
> + target_ulong pc_next;
> + DisasJumpType is_jmp;
> + unsigned int num_insns;
> + bool singlestep_enabled;
> +} DisasContextBase;
> +
> +/**
> + * TranslatorOps:
> + * @init_disas_context: Initialize a DisasContext struct (DisasContextBase
> has
> + * already been initialized).
> + * @init_globals: Initialize global variables.
> + * @tb_start: Start translating a new TB.
> + * @insn_start: Start translating a new instruction.
> + * @breakpoint_check: Check if a breakpoint did hit. When called, the
> breakpoint
> + * has already been checked to match the PC.
> + * @disas_insn: Disassemble one instruction an return the PC for the next
s/disas_insn/translate_insn/
s/an return/and return/
> + * one. Can set db->is_jmp to DJ_TARGET or above to stop
s/DJ_TARGET/DISAS_TARGET/
> + * translation.
> + * @tb_stop: Stop translating a TB.
> + * @disas_flags: Get flags argument for log_target_disas().
s/disas_flags/disas_log/
> + *
> + * Target-specific operations for the generic translator loop.
> + */
> +typedef struct TranslatorOps {
> + void (*init_disas_context)(DisasContextBase *db, CPUState *cpu);
> + void (*init_globals)(DisasContextBase *db, CPUState *cpu);
> + void (*tb_start)(DisasContextBase *db, CPUState *cpu);
> + void (*insn_start)(DisasContextBase *db, CPUState *cpu);
> + BreakpointCheckType (*breakpoint_check)(DisasContextBase *db, CPUState
> *cpu,
> + const CPUBreakpoint *bp);
> + target_ulong (*translate_insn)(DisasContextBase *db, CPUState *cpu);
> + void (*tb_stop)(DisasContextBase *db, CPUState *cpu);
> + void (*disas_log)(const DisasContextBase *db, CPUState *cpu);
> +} TranslatorOps;
> +
> +/**
> + * translate_block:
> + * @ops: Target-specific operations.
> + * @db: Disassembly context.
> + * @cpu: Target vCPU.
> + * @tb: Translation block.
> + *
> + * Generic translator loop.
> + *
> + * Translation will stop in the following cases (in order):
> + * - When set by #TranslatorOps::insn_start.
> + * - When set by #TranslatorOps::translate_insn.
> + * - When the TCG operation buffer is full.
> + * - When single-stepping is enabled (system-wide or on the current vCPU).
> + * - When too many instructions have been translated.
> + */
> +void translate_block(const TranslatorOps *ops, DisasContextBase *db,
> + CPUState *cpu, TranslationBlock *tb);
I'd rather avoid "block" here. Some alternatives:
- tb_translate()
- translate_tb()
- translate()
- translator_gen()
- translator_loop()
E.
- [Qemu-devel] [PATCH v11 00/29] translate: [tcg] Generic translation framework, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 01/29] Pass generic CPUState to gen_intermediate_code(), Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 02/29] cpu-exec: Avoid global variables in icount-related functions, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 03/29] target: [tcg] Use a generic enum for DISAS_ values, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 04/29] target: [tcg] Add generic translation framework, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 05/29] target/i386: [tcg] Port to DisasContextBase, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 06/29] target/i386: [tcg] Refactor init_disas_context, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 07/29] target/i386: [tcg] Refactor init_globals, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 08/29] target/i386: [tcg] Refactor insn_start, Lluís Vilanova, 2017/06/28
- [Qemu-devel] [PATCH v11 09/29] target/i386: [tcg] Refactor breakpoint_check, Lluís Vilanova, 2017/06/28