Skip to content

Commit d9a4282

Browse files
committed
Merge tag 'pull-tcg-20250308' of https://gitlab.com/rth7680/qemu into staging
include/qemu: Tidy atomic128 headers. include/exec: Split out cpu-interrupt.h include/exec: Split many tlb_* declarations to cputlb.h include/accel/tcg: Split out getpc.h accel/tcg: system: Compile some files once linux-user/main: Allow setting tb-size # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmfMyz8dHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9D/Af/Vh5PMtYjL+Mw2NQn # Vmqbv+joiqswAxI8PmZZzEBJ06j4pCLXn+r/2nr+sEwLmrI4BI40Vxx5c5puftoZ # GDGGclskF/pId5TE96TCEr8AoJgeNSSv4WxbINFTZRsRP4voZFHpU6mTz6B0Nnq5 # GS/k6c7+VcYbHIPD0RcIWwBlQv11uUAcnaygkNSsy+theUseOzTPTN/XGfTprf/6 # 1sxlmtt6QcQ88bBJJbiNwqbjWGxANcSUspRo0sstpVr8ApkXNl7WSkWYRBhBa5oc # iu0tixdCIoqqcCJy9/YVyIkmmwWeRUkbQqBeKf0o5xPnhmO3kfeezvERSDvDViAH # K9BVBw== # =7vra # -----END PGP SIGNATURE----- # gpg: Signature made Sun 09 Mar 2025 06:57:03 HKT # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "[email protected]" # gpg: Good signature from "Richard Henderson <[email protected]>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * tag 'pull-tcg-20250308' of https://gitlab.com/rth7680/qemu: (23 commits) accel/tcg: Build tcg-runtime-gvec.c once accel/tcg: Build tcg-runtime.c once qemu/atomic128: Include missing 'qemu/atomic.h' header qemu/atomic: Rename atomic128-ldst.h headers using .h.inc suffix qemu/atomic: Rename atomic128-cas.h headers using .h.inc suffix accel/tcg: Split out getpc.h accel/tcg: Restrict GETPC_ADJ to 'tb-internal.h' accel/tcg: Build tcg-accel-ops-mttcg.c once accel/tcg: Build tcg-accel-ops-rr.c once accel/tcg: Build tcg-accel-ops-icount.c once accel/tcg: Build tcg-accel-ops.c once system: Build watchpoint.c once exec: Declare tlb_flush*() in 'exec/cputlb.h' exec: Declare tlb_hit*() in 'exec/cputlb.h' exec: Declare tlb_set_page() in 'exec/cputlb.h' exec: Declare tlb_set_page_with_attrs() in 'exec/cputlb.h' exec: Declare tlb_set_page_full() in 'exec/cputlb.h' exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h' accel/tcg: Compile watchpoint.c once include/exec: Split out exec/cpu-interrupt.h ... Signed-off-by: Stefan Hajnoczi <[email protected]>
2 parents ffbc5e6 + 9e20807 commit d9a4282

Some content is hidden

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

80 files changed

+550
-484
lines changed

accel/tcg/cputlb.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,29 @@ void tlb_set_page(CPUState *cpu, vaddr addr,
12011201
prot, mmu_idx, size);
12021202
}
12031203

1204+
/**
1205+
* tlb_hit_page: return true if page aligned @addr is a hit against the
1206+
* TLB entry @tlb_addr
1207+
*
1208+
* @addr: virtual address to test (must be page aligned)
1209+
* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value)
1210+
*/
1211+
static inline bool tlb_hit_page(uint64_t tlb_addr, vaddr addr)
1212+
{
1213+
return addr == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK));
1214+
}
1215+
1216+
/**
1217+
* tlb_hit: return true if @addr is a hit against the TLB entry @tlb_addr
1218+
*
1219+
* @addr: virtual address to test (need not be page aligned)
1220+
* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value)
1221+
*/
1222+
static inline bool tlb_hit(uint64_t tlb_addr, vaddr addr)
1223+
{
1224+
return tlb_hit_page(tlb_addr, addr & TARGET_PAGE_MASK);
1225+
}
1226+
12041227
/*
12051228
* Note: tlb_fill_align() can trigger a resize of the TLB.
12061229
* This means that all of the caller's prior references to the TLB table

accel/tcg/internal-common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,6 @@ void tcg_exec_unrealizefn(CPUState *cpu);
7272
/* current cflags for hashing/comparison */
7373
uint32_t curr_cflags(CPUState *cpu);
7474

75+
void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
76+
7577
#endif

accel/tcg/meson.build

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
common_ss.add(when: 'CONFIG_TCG', if_true: files(
22
'cpu-exec-common.c',
3+
'tcg-runtime.c',
4+
'tcg-runtime-gvec.c',
35
))
46
tcg_specific_ss = ss.source_set()
57
tcg_specific_ss.add(files(
68
'tcg-all.c',
79
'cpu-exec.c',
810
'tb-maint.c',
9-
'tcg-runtime-gvec.c',
10-
'tcg-runtime.c',
1111
'translate-all.c',
1212
'translator.c',
1313
))
@@ -20,14 +20,14 @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss)
2020

2121
specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
2222
'cputlb.c',
23-
'watchpoint.c',
24-
'tcg-accel-ops.c',
25-
'tcg-accel-ops-mttcg.c',
26-
'tcg-accel-ops-icount.c',
27-
'tcg-accel-ops-rr.c',
2823
))
2924

3025
system_ss.add(when: ['CONFIG_TCG'], if_true: files(
3126
'icount-common.c',
3227
'monitor.c',
28+
'tcg-accel-ops.c',
29+
'tcg-accel-ops-icount.c',
30+
'tcg-accel-ops-mttcg.c',
31+
'tcg-accel-ops-rr.c',
32+
'watchpoint.c',
3333
))

accel/tcg/tb-internal.h

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,44 @@
1313
#include "exec/exec-all.h"
1414
#include "exec/translation-block.h"
1515

16+
/*
17+
* The true return address will often point to a host insn that is part of
18+
* the next translated guest insn. Adjust the address backward to point to
19+
* the middle of the call insn. Subtracting one would do the job except for
20+
* several compressed mode architectures (arm, mips) which set the low bit
21+
* to indicate the compressed mode; subtracting two works around that. It
22+
* is also the case that there are no host isas that contain a call insn
23+
* smaller than 4 bytes, so we don't worry about special-casing this.
24+
*/
25+
#define GETPC_ADJ 2
26+
27+
#ifdef CONFIG_SOFTMMU
28+
29+
#define CPU_TLB_DYN_MIN_BITS 6
30+
#define CPU_TLB_DYN_DEFAULT_BITS 8
31+
32+
# if HOST_LONG_BITS == 32
33+
/* Make sure we do not require a double-word shift for the TLB load */
34+
# define CPU_TLB_DYN_MAX_BITS (32 - TARGET_PAGE_BITS)
35+
# else /* HOST_LONG_BITS == 64 */
36+
/*
37+
* Assuming TARGET_PAGE_BITS==12, with 2**22 entries we can cover 2**(22+12) ==
38+
* 2**34 == 16G of address space. This is roughly what one would expect a
39+
* TLB to cover in a modern (as of 2018) x86_64 CPU. For instance, Intel
40+
* Skylake's Level-2 STLB has 16 1G entries.
41+
* Also, make sure we do not size the TLB past the guest's address space.
42+
*/
43+
# ifdef TARGET_PAGE_BITS_VARY
44+
# define CPU_TLB_DYN_MAX_BITS \
45+
MIN(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS)
46+
# else
47+
# define CPU_TLB_DYN_MAX_BITS \
48+
MIN_CONST(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS)
49+
# endif
50+
# endif
51+
52+
#endif /* CONFIG_SOFTMMU */
53+
1654
#ifdef CONFIG_USER_ONLY
1755
#include "user/page-protection.h"
1856
/*
@@ -48,6 +86,4 @@ void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
4886

4987
bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
5088

51-
void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
52-
5389
#endif

accel/tcg/tcg-accel-ops-icount.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "system/cpu-timers.h"
2929
#include "qemu/main-loop.h"
3030
#include "qemu/guest-random.h"
31-
#include "exec/exec-all.h"
31+
#include "hw/core/cpu.h"
3232

3333
#include "tcg-accel-ops.h"
3434
#include "tcg-accel-ops-icount.h"

accel/tcg/tcg-accel-ops-mttcg.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "qemu/main-loop.h"
3131
#include "qemu/notify.h"
3232
#include "qemu/guest-random.h"
33-
#include "exec/exec-all.h"
3433
#include "hw/boards.h"
3534
#include "tcg/startup.h"
3635
#include "tcg-accel-ops.h"

accel/tcg/tcg-accel-ops-rr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "qemu/main-loop.h"
3232
#include "qemu/notify.h"
3333
#include "qemu/guest-random.h"
34-
#include "exec/exec-all.h"
34+
#include "exec/cpu-common.h"
3535
#include "tcg/startup.h"
3636
#include "tcg-accel-ops.h"
3737
#include "tcg-accel-ops-rr.h"

accel/tcg/tcg-accel-ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "qemu/main-loop.h"
3434
#include "qemu/guest-random.h"
3535
#include "qemu/timer.h"
36-
#include "exec/exec-all.h"
36+
#include "exec/cputlb.h"
3737
#include "exec/hwaddr.h"
3838
#include "exec/tb-flush.h"
3939
#include "exec/translation-block.h"

accel/tcg/tcg-runtime-gvec.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "qemu/osdep.h"
2121
#include "qemu/host-utils.h"
22-
#include "cpu.h"
2322
#include "exec/helper-proto-common.h"
2423
#include "tcg/tcg-gvec-desc.h"
2524

accel/tcg/tcg-runtime.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,9 @@
2323
*/
2424
#include "qemu/osdep.h"
2525
#include "qemu/host-utils.h"
26-
#include "cpu.h"
26+
#include "exec/cpu-common.h"
2727
#include "exec/helper-proto-common.h"
28-
#include "exec/cpu_ldst.h"
29-
#include "exec/exec-all.h"
30-
#include "disas/disas.h"
31-
#include "exec/log.h"
32-
#include "tcg/tcg.h"
28+
#include "accel/tcg/getpc.h"
3329

3430
#define HELPER_H "accel/tcg/tcg-runtime.h"
3531
#include "exec/helper-info.c.inc"

0 commit comments

Comments
 (0)