Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QEMU Morello #149

Merged
merged 208 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 204 commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
22d760b
Add sail parsing script and its output
LawrenceEsswood Dec 1, 2020
e83bb81
Add morello board hardware
LawrenceEsswood Jun 13, 2021
9425e1b
Add morello CPU type
LawrenceEsswood Dec 1, 2020
e764b4f
Add arm trickbox device
LawrenceEsswood Dec 1, 2020
8d49a0c
Add get_capreg_or_special
LawrenceEsswood Dec 1, 2020
bae7b97
Changes to CHERI common code to support AARCH64
LawrenceEsswood Dec 1, 2020
c04f3cb
Add a couple cap cursor modification helpers
LawrenceEsswood Dec 1, 2020
8f3b133
Fix otype sign related issues for AARCH64
LawrenceEsswood Dec 1, 2020
b173849
[Morello] DDC interposition depends on CCTLR_DDCBO
LawrenceEsswood Dec 1, 2020
0dce748
Update generate_get_ddc_checked_gpr_plus_offset for Morello
LawrenceEsswood Jun 12, 2021
b22dd0a
Add TCG implementations of some capability operations
LawrenceEsswood Dec 1, 2020
80bdaea
Add basic CHERI support to AARCH64
LawrenceEsswood Dec 1, 2020
d39d129
Add the morello config files
LawrenceEsswood Jun 12, 2021
2cc0ca8
Add load/store pair and GCx family of instructions to morello
LawrenceEsswood Dec 16, 2020
40c037c
Add load pair and branch and link instruction to morello.
LawrenceEsswood Mar 31, 2021
070246c
Fix sail parser missing instructions
LawrenceEsswood Jan 25, 2021
f1bb8a5
Add tcg condition to string function
LawrenceEsswood Jan 25, 2021
f89675c
Add sync TCG instruction
LawrenceEsswood Jan 25, 2021
762f204
Add static tracking of capability decompression
LawrenceEsswood Jan 25, 2021
52942ae
Give CapRegState a to string helper
LawrenceEsswood Jan 25, 2021
7d93b43
Make Morello specific changes to cheri utils
LawrenceEsswood Jan 25, 2021
f4aa315
Add another cap debug helper
LawrenceEsswood Jan 25, 2021
932f0a5
Lots more TCG helpers and Morello specific changes to setting offset …
LawrenceEsswood Jan 25, 2021
aae7292
Use the common tcg for setting merged registers to integers
arichardson Sep 27, 2021
9e0e48e
Pay attention to out of bounds exponants for bounds checks
LawrenceEsswood Jan 26, 2021
64ee927
build/ccseal/copytype TCG for morello
LawrenceEsswood Jan 26, 2021
a582a15
[Morello] Implement -cheri-debugger-on-unrepresentable
arichardson Jun 11, 2021
c8daf7b
Better tracing of changes to registers
LawrenceEsswood Jan 29, 2021
2fa1cab
Move some aarch helpers from internal to cpu.h
LawrenceEsswood Sep 28, 2021
102acf9
Add restricted mode CSRS. PL_ALL redundant.
LawrenceEsswood Jan 29, 2021
5135459
General bug fixes for morello instructions
LawrenceEsswood Jan 29, 2021
8ce3cfa
Fix sign related issues with atomic operations
LawrenceEsswood Feb 3, 2021
fef72e0
Add helpers to get certain fields without decompression
LawrenceEsswood Feb 3, 2021
4a92e3a
Allow atomics on Morello
LawrenceEsswood Feb 3, 2021
ce1b092
Add comments and some missing instructions to arm cheri decode
LawrenceEsswood Feb 9, 2021
eb84c62
Add some bit/byte packing functions
LawrenceEsswood Feb 11, 2021
026300d
64-bit memops should never have MO_SIGN
LawrenceEsswood Feb 11, 2021
8360c27
Too lazy to fix, adding comment
LawrenceEsswood Feb 11, 2021
cd7a9a9
Add tag set many. Slightly refactor getting / setting multiple tags w…
LawrenceEsswood Feb 11, 2021
8ac24d1
Remove some over-zelous asserts for morello
LawrenceEsswood Feb 11, 2021
12c61e6
Fix off by one on bounds check
LawrenceEsswood Sep 28, 2021
fca85b9
Add some missing gpr_reg_modified calls
LawrenceEsswood Feb 11, 2021
5f6f61b
Add CHERI MMU bits to morello
LawrenceEsswood Feb 11, 2021
b8becee
Add exclusives and multi-tag loads/stores to morello
LawrenceEsswood Feb 11, 2021
4d6daa0
TCG for bounds checking normal loads and stores
LawrenceEsswood Feb 15, 2021
bcdda49
Implement alignment and morello exceptions
LawrenceEsswood Sep 28, 2021
b760ad0
Fix some capability checking logic for atomic operations
LawrenceEsswood Mar 9, 2021
961590d
Always bounds check with length at least 1
LawrenceEsswood Mar 18, 2021
a3e2873
Fix DDC exception number on MIPS
LawrenceEsswood Mar 18, 2021
454fb5e
Remove defunct print
LawrenceEsswood Mar 18, 2021
97899b6
Assert too strict on AARCH64
LawrenceEsswood Mar 19, 2021
063e199
Fix usage of GETPC to only be at top level in helpers
LawrenceEsswood Mar 19, 2021
825af29
Define a separate aligned capability type
LawrenceEsswood Mar 23, 2021
8f7f9bc
Add script to annotate instruction traces with source lines
LawrenceEsswood May 7, 2021
1358ed6
Improve implementation of sync
LawrenceEsswood May 7, 2021
9aa3707
Add userspace logging console command and remove translation cache fl…
LawrenceEsswood May 7, 2021
115eebc
Add userspace logging to arm
LawrenceEsswood May 7, 2021
cc8a07b
Enabled CHERI tags and logging on arm virt board
LawrenceEsswood May 7, 2021
86c1d2b
Add debug assert for lazy capreg static optimisation
LawrenceEsswood May 7, 2021
3959c8c
Add some missing tcg tmp frees
LawrenceEsswood May 7, 2021
6fbaaa0
Fix some cursor sync issues
LawrenceEsswood May 7, 2021
5aa971a
Exceptions write to (and decompress) SP
LawrenceEsswood May 7, 2021
05735ca
Cheri-fy arm's TPID registers
LawrenceEsswood May 7, 2021
3777bf8
Do CHERI things for DC ZVA
LawrenceEsswood May 28, 2021
276ce4c
Fix morello board minimum page size
LawrenceEsswood Jun 4, 2021
7c58b8a
Restore state before CHERI exceptions on morello
LawrenceEsswood Jun 4, 2021
ea097bd
Add a pytest script to run the morello tests
arichardson Jun 10, 2021
8cf1bdd
Fix out-of-bounds access found by UBSAN
arichardson Jun 10, 2021
637c4cb
Fix TCG temporary leak in gen_cap_get_type_for_copytype
arichardson Jun 10, 2021
daf911a
Improve output for failed morello tests
arichardson Jun 11, 2021
6649020
disas/libvixl: Rename source files in preparation for update
arichardson Jun 11, 2021
16a22ef
Update disas/libvixl to https://github.com/Linaro/vixl/tree/morello
arichardson Jun 11, 2021
ede6426
[Morello] Forward PSTATE.C64 to the disassembler
arichardson Jun 11, 2021
b835d32
[Morello] Fix out-of-bounds access when translating RRLEN
arichardson Jun 12, 2021
f84e807
[Morello] Always use soft-TLB for tag reads/writes
LawrenceEsswood Jun 16, 2021
1710a81
Cache instructions should bounds check
LawrenceEsswood Jun 24, 2021
e414345
Fix C64 mode change for exception
LawrenceEsswood Jun 28, 2021
bca1c5b
Fix morello 2 stage CHERI mmu permission checks
LawrenceEsswood Jun 28, 2021
6e0f456
Implement unprivileged morello loads/stores
LawrenceEsswood Jun 28, 2021
1ea2a9e
Configure morello cpu features
LawrenceEsswood Jun 28, 2021
a76bcdb
[Morello] remove stray debug prints
LawrenceEsswood Jul 5, 2021
959efe2
[Morello] Allow capability read/write functions CSRs
LawrenceEsswood Jul 5, 2021
c695b86
sp is sometimes register 13
LawrenceEsswood Jul 7, 2021
13fe519
Add missing newline
LawrenceEsswood Jul 7, 2021
f8217d6
Use qemu_printf
LawrenceEsswood Jul 7, 2021
b4260b0
Fix double field initialisation
LawrenceEsswood Jul 7, 2021
3acf443
Fix comments and whitespace
LawrenceEsswood Jul 7, 2021
547427c
Add comment for cache maintenance instructions
LawrenceEsswood Jul 7, 2021
a659dab
[LD/ST]CT should also do sp_alignment checks
LawrenceEsswood Jul 15, 2021
10c317d
Fix off by one opc1 for CSCR_EL3
LawrenceEsswood Jul 15, 2021
a7f3a80
Cannot use set tag at EL0
LawrenceEsswood Jul 21, 2021
a00fabd
Add CCTLR_EL12 to arm
LawrenceEsswood Jul 21, 2021
64dbd48
Dont unseal untagged sentries
LawrenceEsswood Jul 22, 2021
c20989f
Generate trace for SCTAG
LawrenceEsswood Jul 22, 2021
9cbc241
Check SP alignment for LD|STCT in non C64 mode
LawrenceEsswood Jul 22, 2021
9d8eda5
Take PC alignment exceptions on AARCH64
LawrenceEsswood Jul 22, 2021
144975a
Fix CHERI MMU bits in stage 2 translation
LawrenceEsswood Jul 22, 2021
bfee4b2
Fix off by one in number of flags define
LawrenceEsswood Jul 22, 2021
4b6747e
Morello untags sealed capabilities just before branching to them
LawrenceEsswood Sep 28, 2021
6c91b94
Propagate a faulting address to pcc related faults
LawrenceEsswood Jul 22, 2021
57b728d
Exception return should also clear tag if capability is sealed
LawrenceEsswood Jul 22, 2021
fa3027c
Propagate address for non-bounds faults for PCC and DDC
LawrenceEsswood Jul 27, 2021
7e94526
TC TCPAC controls whether exceptions are enabled
LawrenceEsswood Jul 27, 2021
7a556e7
Print better register names when taking an exception
LawrenceEsswood Jul 27, 2021
dbdbed1
Exception offset depends on executive bit
LawrenceEsswood Jul 27, 2021
1ccd929
Fix tracing EL
LawrenceEsswood Jul 27, 2021
31b7939
Add better games for AARCH64 DBG registers
LawrenceEsswood Jul 27, 2021
4f2704c
Enable more breakpoints and watchpoints for morello
LawrenceEsswood Jul 27, 2021
f9f2c1c
Do not claim RAS is implemented on morello
LawrenceEsswood Jul 27, 2021
9d2b701
SPSel is RAZ/WI in restricted mode
LawrenceEsswood Jul 27, 2021
700f961
Capabilities enabled exceptions need to set pc properly
LawrenceEsswood Jul 28, 2021
78b15d5
Fix ignoring TGE when E2H enabled
LawrenceEsswood Jul 28, 2021
c5e1d23
capability access SYN should have IL bit in a64
LawrenceEsswood Jul 28, 2021
4fee445
Remove assert as behaviour is legal
LawrenceEsswood Jul 29, 2021
7474023
Make comment accurate
LawrenceEsswood Jul 29, 2021
e56117e
Capability return without access system registers untags
LawrenceEsswood Jul 29, 2021
463489a
Correct ESR for SP alignment faults
LawrenceEsswood Jul 29, 2021
196138c
MSR immediate also needs to respect CHERI SPSEL rules
LawrenceEsswood Jul 29, 2021
a2edffd
Move PC alignment faults to tb_start to fix alignment priority
LawrenceEsswood Jul 29, 2021
5f0077e
Fix lots of unallocated morello encodings
LawrenceEsswood Aug 2, 2021
ee720b8
Take MMU protection faults for capability CAS even when not storing
LawrenceEsswood Aug 3, 2021
025e5d2
Add DBGCLAIM CSRS to make testhappy
LawrenceEsswood Aug 3, 2021
b024587
Probe with correct sizes so watchpoints trigger correctly
LawrenceEsswood Aug 4, 2021
35a328c
Move some morello specific logic for capability jumps earlier
LawrenceEsswood Aug 4, 2021
662c3a6
Fix E2H related mistakes in FP enabled
LawrenceEsswood Aug 4, 2021
50d7b9f
Fix tag setting enabled
LawrenceEsswood Aug 5, 2021
fd5e1b9
CAP_NO_SEALING is 64bit, not the size of the type field
LawrenceEsswood Aug 5, 2021
e747591
Do representability checks for legacy branches
LawrenceEsswood Aug 6, 2021
6e64963
Only squash mutable permissions for tagged caps
LawrenceEsswood Aug 11, 2021
b052c06
Generate correct ESR for MMU faults due to tags
LawrenceEsswood Aug 12, 2021
1806445
Add an always trapping version of PAGE_LC_TRAP
LawrenceEsswood Aug 12, 2021
49512ff
Handle device memory correctly in conjunction with LC bit
LawrenceEsswood Aug 12, 2021
e110381
Fix cache maintenance instructions on morello
LawrenceEsswood Aug 13, 2021
fcd106d
CASL should not tag clear when compare fails
LawrenceEsswood Aug 13, 2021
764c928
Representability check post-index for simd structure load/store
LawrenceEsswood Aug 16, 2021
55d475b
Correctly set WnR bit for capability MMU faults
LawrenceEsswood Aug 16, 2021
818c573
Move TLB tag store faults into probe
LawrenceEsswood Aug 16, 2021
80fc470
Sort fault priority of atomic cap operations
LawrenceEsswood Aug 16, 2021
3bf6ecf
Force morello to be little endian
LawrenceEsswood Aug 20, 2021
f1752d5
Handle jumping to non-sentry caps properly
LawrenceEsswood Aug 20, 2021
9c7b6ee
Morello set bounds immediate is exact
LawrenceEsswood Aug 24, 2021
bdc90d5
Fix bounds setting on morello to do sign extention at correct point
LawrenceEsswood Aug 24, 2021
69d2c32
Fix access to sysregs requiring access sysreg permission
LawrenceEsswood Aug 25, 2021
e01a2ca
Force printf commit for first instruction in a translation block
LawrenceEsswood Aug 25, 2021
1ac2e6f
Fix cheri bounds check size for multiple loads
LawrenceEsswood Aug 25, 2021
d2e99ec
Expose symbol handling callback to arm boot
LawrenceEsswood Sep 16, 2021
624bd02
Fail Morello tests with a more useful error message when misconfigured
arichardson Sep 27, 2021
c0f3084
Fix incorrect max_size argument in gen_mov_cap_select()
arichardson Sep 27, 2021
3ac3625
Fix datasize in load/store exlusive pair
LawrenceEsswood Sep 20, 2021
c2d700b
CHERI bounds check needed on another cache op
LawrenceEsswood Sep 20, 2021
098e242
Fix cheri permission checks for double cap stores
LawrenceEsswood Sep 20, 2021
b77f192
Add TCG fast cap add for morello
LawrenceEsswood Sep 28, 2021
fb3fa4f
Respect exp and valid decode in more places in tcg
LawrenceEsswood Sep 28, 2021
45d0e15
Use CAP_CC() instead of hardcoding CC128
arichardson Sep 28, 2021
40a80bf
[Morello] Fix passing an invalid register number in BLR_BR_RET_CHKD
LawrenceEsswood Sep 28, 2021
058a405
Change a few assertions to be debug-only
arichardson Sep 29, 2021
e89f919
Make get_load_store_base_cap() always_inline
arichardson Sep 29, 2021
70c88aa
Fix passing argument to handle_sys which does not uses 33 different r…
LawrenceEsswood Sep 29, 2021
e09fed5
Add PL_NO_SYSREG to special registers
LawrenceEsswood Sep 29, 2021
e3a9404
Reduce diff to upstream by using g_assert_not_reached()
arichardson Sep 30, 2021
8238845
Avoid some large whitespace-only diffs to upstream
arichardson Sep 30, 2021
c9c8982
Don't provide the csetflags helper for Morello
arichardson Sep 30, 2021
d42eed8
Reduce clang-format diffs to upstream
arichardson Oct 1, 2021
8a5fa38
Drop duplicate call to cheri_tag_init() for morello board
arichardson Oct 1, 2021
d15cabc
Remove old TARGET_CHERI128 config from morello-softmmu.mak
jrtc27 Jul 22, 2021
f301871
Support GDB for Morello
jrtc27 Jul 23, 2021
1909e0d
Revert "Remove assert as behaviour is legal"
arichardson Oct 1, 2021
123995d
Rename TARGET_IS_MORELLO to TARGET_MORELLO
arichardson Oct 1, 2021
8cb9973
Fix some comments
LawrenceEsswood Oct 1, 2021
964f3a3
Branch and link bug has been fixed in ASL
LawrenceEsswood Oct 1, 2021
b90c3de
Use typedef not #define
LawrenceEsswood Oct 1, 2021
eea23b7
Add assert in store tags helper
LawrenceEsswood Oct 1, 2021
9063380
Dont assume CC128
LawrenceEsswood Oct 1, 2021
d019dff
Turn logical op into else branch
LawrenceEsswood Oct 1, 2021
9d8acd3
Slightly better comment / name for capability swap
LawrenceEsswood Oct 1, 2021
72b3685
Distinguish between signed and unsigned in tcg_cond_string
LawrenceEsswood Oct 1, 2021
234372b
Sensible ordering in list of masks
LawrenceEsswood Oct 1, 2021
7bc004a
Fix PAGE_C_BITS define to actually include all bits
LawrenceEsswood Oct 1, 2021
041d178
Use canonical bit inclusion pattern
LawrenceEsswood Oct 1, 2021
63ebb22
ifdef out dead code
LawrenceEsswood Oct 1, 2021
fb72c87
Neaten up defines
LawrenceEsswood Oct 1, 2021
cc88b09
Less crazy line brbreak
LawrenceEsswood Oct 1, 2021
7dd4d0e
Fix cpu get asid
LawrenceEsswood Oct 1, 2021
7a45afd
Revert type change in mte_check_zva
LawrenceEsswood Oct 1, 2021
172b5a6
Make the mpidr bit a property
LawrenceEsswood Oct 1, 2021
b11c0eb
Small whitespace fix
LawrenceEsswood Oct 5, 2021
95d446d
Inline return one for is_a64 for cheri arm
LawrenceEsswood Oct 5, 2021
79770bf
Pass PC to cpu_get_asid
LawrenceEsswood Oct 5, 2021
680db26
Make some more TCG work for 32-bit
LawrenceEsswood Oct 5, 2021
3dfb6e2
Remove stale comments
LawrenceEsswood Oct 5, 2021
4e2762f
Simplify some flow control
LawrenceEsswood Oct 5, 2021
d3a0255
Fix type of placeholder for RISCV target_get_gpr_global
LawrenceEsswood Oct 5, 2021
0da7537
Change asserts for cap_set_(un)sealed for AARCH64
LawrenceEsswood Oct 5, 2021
14ea14f
morello: Diff-reduce tables (and match style for new ones)
jrtc27 Oct 8, 2021
538b2e0
tcg: Diff-reduce GEN_ATOMIC_HELPER
jrtc27 Oct 8, 2021
c5619ba
morello: Fix up clang-format directives
jrtc27 Oct 8, 2021
061d269
Update clang-format config to be closer to upstream code style
arichardson Oct 5, 2021
7ed2846
Rename INSN_ARM_C64 to ARM_DIS_FLAG_C64
arichardson Oct 12, 2021
e4b608e
Reformat translate-a64.c with `IndentCaseBlocks: true`
arichardson Oct 12, 2021
2bc73a2
Simplify cap_is_unsealed()
arichardson Oct 12, 2021
d0f5750
Clean up Morello ifdefs in cap_set_sealed/cap_set_unsealed
arichardson Oct 12, 2021
592a9c3
Add a cap_unseal_reserved_otype() helper
arichardson Oct 12, 2021
3cbc78a
Cleanup cap_is_sealed_with_type()
arichardson Oct 12, 2021
d0ac758
Simplify assertions in cap_set_sealed() and cap_set_unsealed()
arichardson Oct 12, 2021
44a5bf3
Fix value of CC{64,128}_LAST_NONRESERVED_OTYPE
arichardson Oct 12, 2021
537ec7b
Stop using CAP_LAST_NONRESERVED_OTYPE
arichardson Oct 12, 2021
227d42e
[cheri-compressed-cap] Replace FIRST/LAST otype with MIN/MAX
arichardson Oct 12, 2021
771c788
[cheri-compressed-cap] Assert cap_pesbt_deposit_X arguments are in range
arichardson Oct 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
BasedOnStyle: LLVM
ColumnLimit: 80
IndentWidth: 4
UseTab: Never
BreakBeforeBraces: Linux
AlignConsecutiveMacros: Consecutive
AllowShortIfStatementsOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 80
SortIncludes: false
AllowShortLambdasOnASingleLine: Inline
AlwaysBreakBeforeMultilineStrings: false
BreakStringLiterals: true
IndentCaseLabels: false
IndentCaseBlocks: true
Cpp11BracedListStyle: false
PointerAlignment: Right
SortIncludes: false
7 changes: 4 additions & 3 deletions accel/tcg/cpu-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles,
TranslationBlock *orig_tb, bool ignore_icount)
{
TranslationBlock *tb;
uint32_t cflags = curr_cflags() | CF_NOCACHE;
uint32_t cflags = curr_cflags(cpu) | CF_NOCACHE;
int tb_exit;

if (ignore_icount) {
Expand Down Expand Up @@ -499,7 +499,8 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
if (replay_has_exception()
&& cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0) {
/* try to cause an exception pending in the log */
cpu_exec_nocache(cpu, 1, tb_find(cpu, NULL, 0, curr_cflags()), true);
cpu_exec_nocache(cpu, 1, tb_find(cpu, NULL, 0, curr_cflags(cpu)),
true);
}
#endif
if (cpu->exception_index < 0) {
Expand Down Expand Up @@ -783,7 +784,7 @@ int cpu_exec(CPUState *cpu)
have CF_INVALID set, -1 is a convenient invalid value that
does not require tcg headers for cpu_common_reset. */
if (cflags == -1) {
cflags = curr_cflags();
cflags = curr_cflags(cpu);
} else {
cpu->cflags_next_tb = -1;
}
Expand Down
17 changes: 11 additions & 6 deletions accel/tcg/cputlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,9 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr,
if (prot & PAGE_LC_TRAP) {
desc->iotlb[index].tagmem_read |= TLBENTRYCAP_FLAG_TRAP;
}
if (prot & PAGE_LC_TRAP_ANY) {
desc->iotlb[index].tagmem_read |= TLBENTRYCAP_FLAG_TRAP_ANY;
}
if (prot & PAGE_SC_CLEAR) {
desc->iotlb[index].tagmem_write |= TLBENTRYCAP_FLAG_CLEAR;
}
Expand Down Expand Up @@ -1454,8 +1457,9 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index,
#endif

#ifdef TARGET_CHERI
if (cap_write && (env_tlb(env)->d[mmu_idx].viotlb[vidx].tagmem_write ==
TLBENTRYCAP_INVALID_WRITE)) {
if (cap_write && ((env_tlb(env)->d[mmu_idx].viotlb[vidx].tagmem_write &
TLBENTRYCAP_INVALID_WRITE_MASK) ==
TLBENTRYCAP_INVALID_WRITE_VALUE)) {
continue;
}
#endif
Expand Down Expand Up @@ -1603,10 +1607,11 @@ probe_access_internal(CPUArchState *env, target_ulong addr, int fault_size,

#ifdef TARGET_CHERI
if (access_type == MMU_DATA_CAP_STORE &&
(env_tlb(env)
->d[mmu_idx]
.iotlb[tlb_index(env, mmu_idx, addr)]
.tagmem_write == TLBENTRYCAP_INVALID_WRITE))
((env_tlb(env)
->d[mmu_idx]
.iotlb[tlb_index(env, mmu_idx, addr)]
.tagmem_write &
TLBENTRYCAP_INVALID_WRITE_MASK) == TLBENTRYCAP_INVALID_WRITE_VALUE))
tag_write_invalid = true;
#endif

Expand Down
45 changes: 29 additions & 16 deletions accel/tcg/log_instr.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,12 @@ static void emit_text_start(CPUArchState *env, target_ulong pc)
cpu_log_instr_state_t *cpulog = get_cpu_log_state(env);

if (cpulog->loglevel == QEMU_LOG_INSTR_LOGLEVEL_USER) {
qemu_log("[%u:%u] Requested user-mode only instruction logging @ "
TARGET_FMT_lx " \n", env_cpu(env)->cpu_index,
cpu_get_asid(env), pc);
qemu_log("[%u:%u] Requested user-mode only instruction logging "
"@ " TARGET_FMT_lx " \n",
env_cpu(env)->cpu_index, cpu_get_asid(env, pc), pc);
} else {
qemu_log("[%u:%u] Requested instruction logging @ " TARGET_FMT_lx " \n",
env_cpu(env)->cpu_index, cpu_get_asid(env), pc);
env_cpu(env)->cpu_index, cpu_get_asid(env, pc), pc);
}
}

Expand All @@ -424,12 +424,12 @@ static void emit_text_stop(CPUArchState *env, target_ulong pc)
cpu_log_instr_state_t *cpulog = get_cpu_log_state(env);

if (cpulog->loglevel == QEMU_LOG_INSTR_LOGLEVEL_USER) {
qemu_log("[%u:%u] Disabled user-mode only instruction logging @ "
TARGET_FMT_lx " \n", env_cpu(env)->cpu_index,
cpu_get_asid(env), pc);
qemu_log("[%u:%u] Disabled user-mode only instruction logging "
"@ " TARGET_FMT_lx " \n",
env_cpu(env)->cpu_index, cpu_get_asid(env, pc), pc);
} else {
qemu_log("[%u:%u] Disabled instruction logging @ " TARGET_FMT_lx " \n",
env_cpu(env)->cpu_index, cpu_get_asid(env), pc);
env_cpu(env)->cpu_index, cpu_get_asid(env, pc), pc);
}
}

Expand Down Expand Up @@ -646,8 +646,6 @@ static void do_cpu_loglevel_switch(CPUState *cpu, run_on_cpu_data data)
qemu_log_instr_loglevel_t next_level = data.host_int;
bool next_level_active;

log_assert(qemu_loglevel_mask(CPU_LOG_INSTR));
LawrenceEsswood marked this conversation as resolved.
Show resolved Hide resolved

/* Decide whether we have to pause/resume logging */
switch (next_level) {
case QEMU_LOG_INSTR_LOGLEVEL_NONE:
Expand Down Expand Up @@ -679,7 +677,10 @@ static void do_cpu_loglevel_switch(CPUState *cpu, run_on_cpu_data data)
/* Check if this was a no-op */
if (next_level == prev_level && prev_level_active == next_level_active)
return;
tb_flush(cpu);

/* Flushing all translations makes things incredibly slow. Instead,
* we put whether tracing is currently enabled into cflags */

/* Emit start/stop events */
if (prev_level_active) {
if (cpulog->starting) {
Expand Down Expand Up @@ -739,18 +740,26 @@ static void do_global_loglevel_switch(CPUState *cpu, run_on_cpu_data data)
* the current TB is finished. If we clear the global flag immediately
* we will end up emitting stale instructions.
*/
void qemu_log_instr_global_switch(bool request_stop)
int qemu_log_instr_global_switch(int log_flags)
{
CPUState *cpu;
qemu_log_instr_loglevel_t level;

level = (request_stop) ? QEMU_LOG_INSTR_LOGLEVEL_NONE :
QEMU_LOG_INSTR_LOGLEVEL_ALL;
if (log_flags & CPU_LOG_INSTR_U) {
level = QEMU_LOG_INSTR_LOGLEVEL_USER;
log_flags |= CPU_LOG_INSTR;
} else if (log_flags & CPU_LOG_INSTR) {
level = QEMU_LOG_INSTR_LOGLEVEL_ALL;
} else {
level = QEMU_LOG_INSTR_LOGLEVEL_NONE;
}

CPU_FOREACH(cpu) {
async_safe_run_on_cpu(cpu, do_global_loglevel_switch,
RUN_ON_CPU_HOST_INT(level));
}

return log_flags;
}

/*
Expand Down Expand Up @@ -817,7 +826,10 @@ void qemu_log_instr_init(CPUState *cpu)
}

/* If we are starting with instruction logging enabled, switch it on now */
if (qemu_loglevel_mask(CPU_LOG_INSTR))
if (qemu_loglevel_mask(CPU_LOG_INSTR_U))
do_cpu_loglevel_switch(
cpu, RUN_ON_CPU_HOST_INT(QEMU_LOG_INSTR_LOGLEVEL_USER));
else if (qemu_loglevel_mask(CPU_LOG_INSTR))
do_cpu_loglevel_switch(cpu,
RUN_ON_CPU_HOST_INT(QEMU_LOG_INSTR_LOGLEVEL_ALL));
}
Expand Down Expand Up @@ -941,7 +953,8 @@ void qemu_log_instr_reg(CPUArchState *env, const char *reg_name, target_ulong va
void helper_qemu_log_instr_reg(CPUArchState *env, const void *reg_name,
target_ulong value)
{
qemu_log_instr_reg(env, (const char *)reg_name, value);
if (qemu_log_instr_check_enabled(env))
qemu_log_instr_reg(env, (const char *)reg_name, value);
}

#ifdef TARGET_CHERI
Expand Down
2 changes: 1 addition & 1 deletion accel/tcg/tcg-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env)
uint32_t flags;

tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &cs_top, &cheri_flags, &flags,
curr_cflags());
curr_cflags(cpu));
if (tb == NULL) {
return tcg_code_gen_epilogue;
}
Expand Down
7 changes: 7 additions & 0 deletions accel/tcg/tcg-runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,17 @@ GEN_ATOMIC_HELPERS(xchg)
// of DDC and raise an exception otherwise. Tag+usealed+load/store perms must
// have been checked before.
DEF_HELPER_3(ddc_check_bounds, void, env, tl, tl)
#ifdef TARGET_AARCH64
DEF_HELPER_3(ddc_check_bounds_store, void, env, tl, tl)
#endif
/* Same but relative to PCC */
DEF_HELPER_3(pcc_check_bounds, void, env, tl, tl)
/* Clear tags due to a store. Only call this after the store succeeded. */
DEF_HELPER_3(cheri_invalidate_tags, void, env, cap_checked_ptr, memop_idx)
/* Clear tags due to a store, last argument is whether the store succeeded. */
DEF_HELPER_4(cheri_invalidate_tags_condition, void, env, cap_checked_ptr,
memop_idx, i32)

#endif

DEF_HELPER_FLAGS_3(gvec_mov, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
Expand Down
6 changes: 3 additions & 3 deletions accel/tcg/translate-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,
if (current_tb_modified) {
page_collection_unlock(pages);
/* Force execution of one insn next time. */
cpu->cflags_next_tb = 1 | curr_cflags();
cpu->cflags_next_tb = 1 | curr_cflags(cpu);
mmap_unlock();
cpu_loop_exit_noexc(cpu);
}
Expand Down Expand Up @@ -2366,7 +2366,7 @@ static bool tb_invalidate_phys_page(tb_page_addr_t addr, uintptr_t pc)
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb_modified) {
/* Force execution of one insn next time. */
cpu->cflags_next_tb = 1 | curr_cflags();
cpu->cflags_next_tb = 1 | curr_cflags(cpu);
return true;
}
#endif
Expand Down Expand Up @@ -2454,7 +2454,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
#endif

/* Generate a new TB executing the I/O insn. */
cpu->cflags_next_tb = curr_cflags() | CF_LAST_IO | n;
cpu->cflags_next_tb = curr_cflags(cpu) | CF_LAST_IO | n;

if (tb_cflags(tb) & CF_NOCACHE) {
if (tb->orig_tb) {
Expand Down
14 changes: 8 additions & 6 deletions accel/tcg/translator.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ static void qemu_log_gen_printf_reset(DisasContextBase *base)
}

/* Should only be called in a place it cannot be skipped by a branch! */
static void qemu_log_gen_printf_flush(DisasContextBase *base, bool force_flush)
static void qemu_log_gen_printf_flush(DisasContextBase *base, bool flush_early,
bool force_flush)
{
#ifdef CONFIG_TCG_LOG_INSTR
if ((base->printf_used_ptr != 0) &&
(force_flush ||
(base->printf_used_ptr >= (QEMU_LOG_PRINTF_FLUSH_BARRIER)))) {
if (force_flush || ((base->printf_used_ptr != 0) &&
(flush_early || (base->printf_used_ptr >=
(QEMU_LOG_PRINTF_FLUSH_BARRIER))))) {
gen_helper_qemu_log_printf_dump(cpu_env);
qemu_log_gen_printf_reset(base);
}
Expand Down Expand Up @@ -86,6 +87,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
cheri_debug_assert(db->pcc_top ==
cap_get_top(cheri_get_recent_pcc(cpu->env_ptr)));
db->cheri_flags = tb->cheri_flags;
disas_capreg_reset_all(db);
// TODO: verify cheri_flags are correct?
#endif
ops->init_disas_context(db, cpu);
Expand Down Expand Up @@ -141,7 +143,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
* TODO: As long as the string stays around, we could delay this
* till the end of a BB.
*/
qemu_log_gen_printf_flush(db, true);
qemu_log_gen_printf_flush(db, true, db->num_insns == 1);
gen_helper_qemu_log_instr_commit(cpu_env);
}
#endif
Expand Down Expand Up @@ -209,7 +211,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
#ifdef CONFIG_TCG_LOG_INSTR
/* Commit previous instruction */
if (unlikely(log_instr_enabled)) {
qemu_log_gen_printf_flush(db, true);
qemu_log_gen_printf_flush(db, true, db->num_insns == 1);
}
#endif

Expand Down
4 changes: 4 additions & 0 deletions default-configs/devices/morello-softmmu.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Default configuration for morello-softmmu

include aarch64-softmmu.mak
CONFIG_MORELLO=y
11 changes: 11 additions & 0 deletions default-configs/targets/morello-softmmu.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Default configuration for morello-softmmu

INCLUDE_WORKAROUND=aarch64-softmmu.mak
#
# CHERI-specific settings:
#
# Same as aarch64-softmmu.mak but with the extra aarch64-cheri.xml
TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/aarch64-cheri.xml
TARGET_CHERI=y
TARGET_MORELLO=y
TARGET_SUPPORTS_MTTCG=n
20 changes: 11 additions & 9 deletions disas/arm-a64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ extern "C" {
#include "disas/dis-asm.h"
}

#include "vixl/a64/disasm-a64.h"
#include "vixl/aarch64/disasm-aarch64.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll note that, if we cared, we could upstream using a newer version of vixl, which would make our diff to use the Morello branch smaller. I wonder though if we should have a separate libvixl-morello that we point at so that we don't get any conflicts in the vixl source itself, and just need to change the build system plus this file (which would collapse to only adding the ISA option were upstream to update).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be nice, but I find submitting patches using git send-email rather awkward.


using namespace vixl;
using namespace vixl::aarch64;

class QEMUDisassembler;

static Decoder *vixl_decoder = NULL;
static Disassembler *vixl_disasm = NULL;
static QEMUDisassembler *vixl_disasm = NULL;

/* We don't use libvixl's PrintDisassembler because its output
* is a little unhelpful (trailing newlines, for example).
Expand All @@ -49,8 +51,8 @@ class QEMUDisassembler : public Disassembler {

protected:
virtual void ProcessOutput(const Instruction *instr) {
printf_(stream_, "%08" PRIx32 " %s",
instr->InstructionBits(), GetOutput());
printf_(stream_, "%08" PRIx32 " %s", instr->GetInstructionBits(),
GetOutput());
}

private:
Expand Down Expand Up @@ -91,13 +93,13 @@ int print_insn_arm_a64(uint64_t addr, disassemble_info *info)
vixl_init();
}

((QEMUDisassembler *)vixl_disasm)->SetPrintf(info->fprintf_func);
((QEMUDisassembler *)vixl_disasm)->SetStream(info->stream);
vixl_disasm->SetPrintf(info->fprintf_func);
vixl_disasm->SetStream(info->stream);

instrval = bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24;
instr = reinterpret_cast<const Instruction *>(&instrval);
vixl_disasm->MapCodeAddress(addr, instr);
vixl_decoder->Decode(instr);

vixl_decoder->Decode(instr,
info->flags & ARM_DIS_FLAG_C64 ? ISA::C64 : ISA::A64);
return INSN_SIZE;
}
2 changes: 2 additions & 0 deletions disas/libvixl/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DisableFormat: true
SortIncludes: false
12 changes: 7 additions & 5 deletions disas/libvixl/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
libvixl_ss.add(files(
'vixl/a64/decoder-a64.cc',
'vixl/a64/disasm-a64.cc',
'vixl/a64/instructions-a64.cc',
'vixl/compiler-intrinsics.cc',
'vixl/utils.cc',
'vixl/aarch64/cpu-features-auditor-aarch64.cc',
'vixl/aarch64/decoder-aarch64.cc',
'vixl/aarch64/disasm-aarch64.cc',
'vixl/aarch64/instructions-aarch64.cc',
'vixl/compiler-intrinsics-vixl.cc',
'vixl/cpu-features.cc',
'vixl/utils-vixl.cc',
))
Loading