Skip to content

Commit 32a97c5

Browse files
committed
Merge tag 'pull-tcg-20250117' of https://gitlab.com/rth7680/qemu into staging
tcg: - Add TCGOP_TYPE, TCGOP_FLAGS. - Pass type and flags to tcg_op_supported, tcg_target_op_def. - Split out tcg-target-has.h and unexport from tcg.h. - Reorg constraint processing; constify TCGOpDef. - Make extract, sextract, deposit opcodes mandatory. - Merge ext{8,16,32}{s,u} opcodes into {s}extract. tcg/mips: Expand bswap unconditionally tcg/riscv: Use SRAIW, SRLIW for {s}extract_i64 tcg/riscv: Use BEXTI for single-bit extractions tcg/sparc64: Use SRA, SRL for {s}extract_i64 disas/riscv: Guard dec->cfg dereference for host disassemble util/cpuinfo-riscv: Detect Zbs accel/tcg: Call tcg_tb_insert() for one-insn TBs linux-user: Add missing /proc/cpuinfo fields for sparc # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmeKnzUdHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+Kvgf+LG9UjXlWF9GK923E # TllBL2rLf1OOdtTXWO15VcvGMoWDwB3tVBdhihdvXmnWju+WbfMk6mct5NhzsKn9 # LmuugMIZs+hMROj+bgMK8x47jRIh5N2rDYxcEgmyfIpYb2o9qvyqKecGVRlSJTCE # bmt5UFbvPThBb8upoMfq3F6evuMx0szBP7wrOwSR/VGpmzIr20UTEWo6I1ALp4uj # paFaysYol4em3dIhkiuV9cL7E0EIObaNa7l9RUci/BmTq+JaVxUnW1Y2i0PEwKwG # FJSfYTJk3wBgAVxC2zC2g3ZM7uKuecSXMpiFopTiuyQLp7Q61i9kCNvEq0qY5tdb # DaqR/g== # =cv4O # -----END PGP SIGNATURE----- # gpg: Signature made Fri 17 Jan 2025 13:19:33 EST # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * tag 'pull-tcg-20250117' of https://gitlab.com/rth7680/qemu: (68 commits) softfloat: Constify helpers returning float_status field accel/tcg: Call tcg_tb_insert() for one-insn TBs tcg: Document tb_lookup() and tcg_tb_lookup() linux-user: Add missing /proc/cpuinfo fields for sparc tcg/riscv: Use BEXTI for single-bit extractions util/cpuinfo-riscv: Detect Zbs tcg: Remove TCG_TARGET_HAS_deposit_{i32,i64} tcg: Remove TCG_TARGET_HAS_{s}extract_{i32,i64} tcg/tci: Remove assertions for deposit and extract tcg/tci: Provide TCG_TARGET_{s}extract_valid tcg/sparc64: Use SRA, SRL for {s}extract_i64 tcg/s390x: Fold the ext{8,16,32}[us] cases into {s}extract tcg/riscv: Use SRAIW, SRLIW for {s}extract_i64 tcg/riscv64: Fold the ext{8,16,32}[us] cases into {s}extract tcg/ppc: Fold the ext{8,16,32}[us] cases into {s}extract tcg/mips: Fold the ext{8,16,32}[us] cases into {s}extract tcg/loongarch64: Fold the ext{8,16,32}[us] cases into {s}extract tcg/arm: Add full [US]XT[BH] into {s}extract tcg/aarch64: Expand extract with offset 0 with andi tcg/aarch64: Provide TCG_TARGET_{s}extract_valid ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2 parents d6430c1 + db16498 commit 32a97c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2867
-2280
lines changed

accel/tcg/cpu-exec.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,20 @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, vaddr pc,
249249
return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp);
250250
}
251251

252-
/* Might cause an exception, so have a longjmp destination ready */
252+
/**
253+
* tb_lookup:
254+
* @cpu: CPU that will execute the returned translation block
255+
* @pc: guest PC
256+
* @cs_base: arch-specific value associated with translation block
257+
* @flags: arch-specific translation block flags
258+
* @cflags: CF_* flags
259+
*
260+
* Look up a translation block inside the QHT using @pc, @cs_base, @flags and
261+
* @cflags. Uses @cpu's tb_jmp_cache. Might cause an exception, so have a
262+
* longjmp destination ready.
263+
*
264+
* Returns: an existing translation block or NULL.
265+
*/
253266
static inline TranslationBlock *tb_lookup(CPUState *cpu, vaddr pc,
254267
uint64_t cs_base, uint32_t flags,
255268
uint32_t cflags)

accel/tcg/internal-target.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "exec/exec-all.h"
1313
#include "exec/translation-block.h"
1414
#include "tb-internal.h"
15+
#include "tcg-target-mo.h"
1516

1617
/*
1718
* Access to the various translations structures need to be serialised

accel/tcg/translate-all.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -531,23 +531,32 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
531531
tb_reset_jump(tb, 1);
532532
}
533533

534+
/*
535+
* Insert TB into the corresponding region tree before publishing it
536+
* through QHT. Otherwise rewinding happened in the TB might fail to
537+
* lookup itself using host PC.
538+
*/
539+
tcg_tb_insert(tb);
540+
534541
/*
535542
* If the TB is not associated with a physical RAM page then it must be
536-
* a temporary one-insn TB, and we have nothing left to do. Return early
537-
* before attempting to link to other TBs or add to the lookup table.
543+
* a temporary one-insn TB.
544+
*
545+
* Such TBs must be added to region trees in order to make sure that
546+
* restore_state_to_opc() - which on some architectures is not limited to
547+
* rewinding, but also affects exception handling! - is called when such a
548+
* TB causes an exception.
549+
*
550+
* At the same time, temporary one-insn TBs must be executed at most once,
551+
* because subsequent reads from, e.g., I/O memory may return different
552+
* values. So return early before attempting to link to other TBs or add
553+
* to the QHT.
538554
*/
539555
if (tb_page_addr0(tb) == -1) {
540556
assert_no_pages_locked();
541557
return tb;
542558
}
543559

544-
/*
545-
* Insert TB into the corresponding region tree before publishing it
546-
* through QHT. Otherwise rewinding happened in the TB might fail to
547-
* lookup itself using host PC.
548-
*/
549-
tcg_tb_insert(tb);
550-
551560
/*
552561
* No explicit memory barrier is required -- tb_link_page() makes the
553562
* TB visible in a consistent state.

disas/riscv.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
26112611
break;
26122612
case 2: op = rv_op_c_li; break;
26132613
case 3:
2614-
if (dec->cfg->ext_zcmop) {
2614+
if (dec->cfg && dec->cfg->ext_zcmop) {
26152615
if ((((inst >> 2) & 0b111111) == 0b100000) &&
26162616
(((inst >> 11) & 0b11) == 0b0)) {
26172617
unsigned int cmop_code = 0;
@@ -2712,7 +2712,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
27122712
op = rv_op_c_sqsp;
27132713
} else {
27142714
op = rv_op_c_fsdsp;
2715-
if (dec->cfg->ext_zcmp && ((inst >> 12) & 0b01)) {
2715+
if (dec->cfg && dec->cfg->ext_zcmp && ((inst >> 12) & 0b01)) {
27162716
switch ((inst >> 8) & 0b01111) {
27172717
case 8:
27182718
if (((inst >> 4) & 0b01111) >= 4) {
@@ -2738,7 +2738,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
27382738
} else {
27392739
switch ((inst >> 10) & 0b011) {
27402740
case 0:
2741-
if (!dec->cfg->ext_zcmt) {
2741+
if (dec->cfg && !dec->cfg->ext_zcmt) {
27422742
break;
27432743
}
27442744
if (((inst >> 2) & 0xFF) >= 32) {
@@ -2748,7 +2748,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
27482748
}
27492749
break;
27502750
case 3:
2751-
if (!dec->cfg->ext_zcmp) {
2751+
if (dec->cfg && !dec->cfg->ext_zcmp) {
27522752
break;
27532753
}
27542754
switch ((inst >> 5) & 0b011) {
@@ -2956,7 +2956,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
29562956
break;
29572957
case 5:
29582958
op = rv_op_auipc;
2959-
if (dec->cfg->ext_zicfilp &&
2959+
if (dec->cfg && dec->cfg->ext_zicfilp &&
29602960
(((inst >> 7) & 0b11111) == 0b00000)) {
29612961
op = rv_op_lpad;
29622962
}
@@ -4058,7 +4058,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
40584058
case 2: op = rv_op_csrrs; break;
40594059
case 3: op = rv_op_csrrc; break;
40604060
case 4:
4061-
if (dec->cfg->ext_zimop) {
4061+
if (dec->cfg && dec->cfg->ext_zimop) {
40624062
int imm_mop5, imm_mop3, reg_num;
40634063
if ((extract32(inst, 22, 10) & 0b1011001111)
40644064
== 0b1000000111) {
@@ -5112,28 +5112,28 @@ static GString *format_inst(size_t tab, rv_decode *dec)
51125112
g_string_append(buf, rv_ireg_name_sym[dec->rs2]);
51135113
break;
51145114
case '3':
5115-
if (dec->cfg->ext_zfinx) {
5115+
if (dec->cfg && dec->cfg->ext_zfinx) {
51165116
g_string_append(buf, rv_ireg_name_sym[dec->rd]);
51175117
} else {
51185118
g_string_append(buf, rv_freg_name_sym[dec->rd]);
51195119
}
51205120
break;
51215121
case '4':
5122-
if (dec->cfg->ext_zfinx) {
5122+
if (dec->cfg && dec->cfg->ext_zfinx) {
51235123
g_string_append(buf, rv_ireg_name_sym[dec->rs1]);
51245124
} else {
51255125
g_string_append(buf, rv_freg_name_sym[dec->rs1]);
51265126
}
51275127
break;
51285128
case '5':
5129-
if (dec->cfg->ext_zfinx) {
5129+
if (dec->cfg && dec->cfg->ext_zfinx) {
51305130
g_string_append(buf, rv_ireg_name_sym[dec->rs2]);
51315131
} else {
51325132
g_string_append(buf, rv_freg_name_sym[dec->rs2]);
51335133
}
51345134
break;
51355135
case '6':
5136-
if (dec->cfg->ext_zfinx) {
5136+
if (dec->cfg && dec->cfg->ext_zfinx) {
51375137
g_string_append(buf, rv_ireg_name_sym[dec->rs3]);
51385138
} else {
51395139
g_string_append(buf, rv_freg_name_sym[dec->rs3]);
@@ -5439,7 +5439,8 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
54395439
const rv_opcode_data *opcode_data = decoders[i].opcode_data;
54405440
void (*decode_func)(rv_decode *, rv_isa) = decoders[i].decode_func;
54415441

5442-
if (guard_func(cfg)) {
5442+
/* always_true_p don't dereference cfg */
5443+
if (((i == 0) || cfg) && guard_func(cfg)) {
54435444
dec.opcode_data = opcode_data;
54445445
decode_func(&dec, isa);
54455446
if (dec.op != rv_op_illegal)

docs/devel/tcg-ops.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,9 @@ QEMU specific operations
712712
Host vector operations
713713
----------------------
714714

715-
All of the vector ops have two parameters, ``TCGOP_VECL`` & ``TCGOP_VECE``.
716-
The former specifies the length of the vector in log2 64-bit units; the
717-
latter specifies the length of the element (if applicable) in log2 8-bit units.
718-
E.g. VECL = 1 -> 64 << 1 -> v128, and VECE = 2 -> 1 << 2 -> i32.
715+
All of the vector ops have two parameters, ``TCGOP_TYPE`` & ``TCGOP_VECE``.
716+
The former specifies the length of the vector as a TCGType; the latter
717+
specifies the length of the element (if applicable) in log2 8-bit units.
719718

720719
.. list-table::
721720

@@ -729,7 +728,7 @@ E.g. VECL = 1 -> 64 << 1 -> v128, and VECE = 2 -> 1 << 2 -> i32.
729728

730729
* - dup_vec *v0*, *r1*
731730

732-
- | Duplicate the low N bits of *r1* into VECL/VECE copies across *v0*.
731+
- | Duplicate the low N bits of *r1* into TYPE/VECE copies across *v0*.
733732

734733
* - dupi_vec *v0*, *c*
735734

@@ -738,7 +737,7 @@ E.g. VECL = 1 -> 64 << 1 -> v128, and VECE = 2 -> 1 << 2 -> i32.
738737
739738
* - dup2_vec *v0*, *r1*, *r2*
740739

741-
- | Duplicate *r2*:*r1* into VECL/64 copies across *v0*. This opcode is
740+
- | Duplicate *r2*:*r1* into TYPE/64 copies across *v0*. This opcode is
742741
only present for 32-bit hosts.
743742

744743
* - add_vec *v0*, *v1*, *v2*
@@ -810,7 +809,7 @@ E.g. VECL = 1 -> 64 << 1 -> v128, and VECE = 2 -> 1 << 2 -> i32.
810809

811810
.. code-block:: c
812811
813-
for (i = 0; i < VECL/VECE; ++i) {
812+
for (i = 0; i < TYPE/VECE; ++i) {
814813
v0[i] = v1[i] << s2;
815814
}
816815
@@ -832,7 +831,7 @@ E.g. VECL = 1 -> 64 << 1 -> v128, and VECE = 2 -> 1 << 2 -> i32.
832831

833832
.. code-block:: c
834833
835-
for (i = 0; i < VECL/VECE; ++i) {
834+
for (i = 0; i < TYPE/VECE; ++i) {
836835
v0[i] = v1[i] << v2[i];
837836
}
838837

host/include/riscv/host/cpuinfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#define CPUINFO_ALWAYS (1u << 0) /* so cpuinfo is nonzero */
1010
#define CPUINFO_ZBA (1u << 1)
1111
#define CPUINFO_ZBB (1u << 2)
12-
#define CPUINFO_ZICOND (1u << 3)
13-
#define CPUINFO_ZVE64X (1u << 4)
12+
#define CPUINFO_ZBS (1u << 3)
13+
#define CPUINFO_ZICOND (1u << 4)
14+
#define CPUINFO_ZVE64X (1u << 5)
1415

1516
/* Initialized with a constructor. */
1617
extern unsigned cpuinfo;

include/fpu/softfloat-helpers.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,58 +124,61 @@ static inline void set_no_signaling_nans(bool val, float_status *status)
124124
status->no_signaling_nans = val;
125125
}
126126

127-
static inline bool get_float_detect_tininess(float_status *status)
127+
static inline bool get_float_detect_tininess(const float_status *status)
128128
{
129129
return status->tininess_before_rounding;
130130
}
131131

132-
static inline FloatRoundMode get_float_rounding_mode(float_status *status)
132+
static inline FloatRoundMode get_float_rounding_mode(const float_status *status)
133133
{
134134
return status->float_rounding_mode;
135135
}
136136

137-
static inline int get_float_exception_flags(float_status *status)
137+
static inline int get_float_exception_flags(const float_status *status)
138138
{
139139
return status->float_exception_flags;
140140
}
141141

142142
static inline FloatX80RoundPrec
143-
get_floatx80_rounding_precision(float_status *status)
143+
get_floatx80_rounding_precision(const float_status *status)
144144
{
145145
return status->floatx80_rounding_precision;
146146
}
147147

148-
static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status)
148+
static inline Float2NaNPropRule
149+
get_float_2nan_prop_rule(const float_status *status)
149150
{
150151
return status->float_2nan_prop_rule;
151152
}
152153

153-
static inline Float3NaNPropRule get_float_3nan_prop_rule(float_status *status)
154+
static inline Float3NaNPropRule
155+
get_float_3nan_prop_rule(const float_status *status)
154156
{
155157
return status->float_3nan_prop_rule;
156158
}
157159

158-
static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status)
160+
static inline FloatInfZeroNaNRule
161+
get_float_infzeronan_rule(const float_status *status)
159162
{
160163
return status->float_infzeronan_rule;
161164
}
162165

163-
static inline uint8_t get_float_default_nan_pattern(float_status *status)
166+
static inline uint8_t get_float_default_nan_pattern(const float_status *status)
164167
{
165168
return status->default_nan_pattern;
166169
}
167170

168-
static inline bool get_flush_to_zero(float_status *status)
171+
static inline bool get_flush_to_zero(const float_status *status)
169172
{
170173
return status->flush_to_zero;
171174
}
172175

173-
static inline bool get_flush_inputs_to_zero(float_status *status)
176+
static inline bool get_flush_inputs_to_zero(const float_status *status)
174177
{
175178
return status->flush_inputs_to_zero;
176179
}
177180

178-
static inline bool get_default_nan_mode(float_status *status)
181+
static inline bool get_default_nan_mode(const float_status *status)
179182
{
180183
return status->default_nan_mode;
181184
}

0 commit comments

Comments
 (0)