1 | The following changes since commit c88f1ffc19e38008a1c33ae039482a860aa7418c: | 1 | Two small bugfixes, plus most of RTH's refactoring of cpregs |
---|---|---|---|
2 | handling. | ||
2 | 3 | ||
3 | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2020-05-08 14:29:18 +0100) | 4 | -- PMM |
5 | |||
6 | The following changes since commit 1fba9dc71a170b3a05b9d3272dd8ecfe7f26e215: | ||
7 | |||
8 | Merge tag 'pull-request-2022-05-04' of https://gitlab.com/thuth/qemu into staging (2022-05-04 08:07:02 -0700) | ||
4 | 9 | ||
5 | are available in the Git repository at: | 10 | are available in the Git repository at: |
6 | 11 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200511 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220505 |
8 | 13 | ||
9 | for you to fetch changes up to 7e17d50ebd359ee5fa3d65d7fdc0fe0336d60694: | 14 | for you to fetch changes up to 99a50d1a67c602126fc2b3a4812d3000eba9bf34: |
10 | 15 | ||
11 | target/arm: Fix tcg_gen_gvec_dup_imm vs DUP (indexed) (2020-05-11 14:22:54 +0100) | 16 | target/arm: read access to performance counters from EL0 (2022-05-05 09:36:22 +0100) |
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | target-arm queue: | 19 | target-arm queue: |
15 | aspeed: Add boot stub for smp booting | 20 | * Enable read access to performance counters from EL0 |
16 | target/arm: Drop access_el3_aa32ns_aa64any() | 21 | * Enable SCTLR_EL1.BT0 for aarch64-linux-user |
17 | aspeed: Support AST2600A1 silicon revision | 22 | * Refactoring of cpreg handling |
18 | aspeed: sdmc: Implement AST2600 locking behaviour | ||
19 | nrf51: Tracing cleanups | ||
20 | target/arm: Improve handling of SVE loads and stores | ||
21 | target/arm: Don't show TCG-only CPUs in KVM-only QEMU builds | ||
22 | hw/arm/musicpal: Map the UART devices unconditionally | ||
23 | target/arm: Fix tcg_gen_gvec_dup_imm vs DUP (indexed) | ||
24 | target/arm: Use tcg_gen_gvec_5_ptr for sve FMLA/FCMLA | ||
25 | 23 | ||
26 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
27 | Edgar E. Iglesias (1): | 25 | Alex Zuepke (1): |
28 | target/arm: Drop access_el3_aa32ns_aa64any() | 26 | target/arm: read access to performance counters from EL0 |
29 | 27 | ||
30 | Joel Stanley (3): | 28 | Richard Henderson (22): |
31 | aspeed: Add boot stub for smp booting | 29 | target/arm: Enable SCTLR_EL1.BT0 for aarch64-linux-user |
32 | aspeed: Support AST2600A1 silicon revision | 30 | target/arm: Split out cpregs.h |
33 | aspeed: sdmc: Implement AST2600 locking behaviour | 31 | target/arm: Reorg CPAccessResult and access_check_cp_reg |
32 | target/arm: Replace sentinels with ARRAY_SIZE in cpregs.h | ||
33 | target/arm: Make some more cpreg data static const | ||
34 | target/arm: Reorg ARMCPRegInfo type field bits | ||
35 | target/arm: Avoid bare abort() or assert(0) | ||
36 | target/arm: Change cpreg access permissions to enum | ||
37 | target/arm: Name CPState type | ||
38 | target/arm: Name CPSecureState type | ||
39 | target/arm: Drop always-true test in define_arm_vh_e2h_redirects_aliases | ||
40 | target/arm: Store cpregs key in the hash table directly | ||
41 | target/arm: Merge allocation of the cpreg and its name | ||
42 | target/arm: Hoist computation of key in add_cpreg_to_hashtable | ||
43 | target/arm: Consolidate cpreg updates in add_cpreg_to_hashtable | ||
44 | target/arm: Use bool for is64 and ns in add_cpreg_to_hashtable | ||
45 | target/arm: Hoist isbanked computation in add_cpreg_to_hashtable | ||
46 | target/arm: Perform override check early in add_cpreg_to_hashtable | ||
47 | target/arm: Reformat comments in add_cpreg_to_hashtable | ||
48 | target/arm: Remove HOST_BIG_ENDIAN ifdef in add_cpreg_to_hashtable | ||
49 | target/arm: Add isar predicates for FEAT_Debugv8p2 | ||
50 | target/arm: Add isar_feature_{aa64,any}_ras | ||
34 | 51 | ||
35 | Philippe Mathieu-Daudé (8): | 52 | target/arm/cpregs.h | 453 ++++++++++++++++++++++++++++++++++++++ |
36 | hw/arm/nrf51: Add NRF51_PERIPHERAL_SIZE definition | 53 | target/arm/cpu.h | 393 +++------------------------------ |
37 | hw/timer/nrf51_timer: Display timer ID in trace events | 54 | hw/arm/pxa2xx.c | 2 +- |
38 | hw/timer/nrf51_timer: Add trace event of counter value update | 55 | hw/arm/pxa2xx_pic.c | 2 +- |
39 | target/arm/kvm: Inline set_feature() calls | 56 | hw/intc/arm_gicv3_cpuif.c | 6 +- |
40 | target/arm/cpu: Use ARRAY_SIZE() to iterate over ARMCPUInfo[] | 57 | hw/intc/arm_gicv3_kvm.c | 3 +- |
41 | target/arm/cpu: Restrict v8M IDAU interface to Aarch32 CPUs | 58 | target/arm/cpu.c | 25 +-- |
42 | target/arm: Restrict TCG cpus to TCG accel | 59 | target/arm/cpu64.c | 2 +- |
43 | hw/arm/musicpal: Map the UART devices unconditionally | 60 | target/arm/cpu_tcg.c | 5 +- |
44 | 61 | target/arm/gdbstub.c | 5 +- | |
45 | Richard Henderson (21): | 62 | target/arm/helper.c | 358 +++++++++++++----------------- |
46 | exec: Add block comments for watchpoint routines | 63 | target/arm/hvf/hvf.c | 2 +- |
47 | exec: Fix cpu_watchpoint_address_matches address length | 64 | target/arm/kvm-stub.c | 4 +- |
48 | accel/tcg: Add block comment for probe_access | 65 | target/arm/kvm.c | 4 +- |
49 | accel/tcg: Adjust probe_access call to page_check_range | 66 | target/arm/machine.c | 4 +- |
50 | accel/tcg: Add probe_access_flags | 67 | target/arm/op_helper.c | 57 ++--- |
51 | accel/tcg: Add endian-specific cpu_{ld, st}* operations | 68 | target/arm/translate-a64.c | 14 +- |
52 | target/arm: Use cpu_*_data_ra for sve_ldst_tlb_fn | 69 | target/arm/translate-neon.c | 2 +- |
53 | target/arm: Drop manual handling of set/clear_helper_retaddr | 70 | target/arm/translate.c | 13 +- |
54 | target/arm: Add sve infrastructure for page lookup | 71 | tests/tcg/aarch64/bti-3.c | 42 ++++ |
55 | target/arm: Adjust interface of sve_ld1_host_fn | 72 | tests/tcg/aarch64/Makefile.target | 6 +- |
56 | target/arm: Use SVEContLdSt in sve_ld1_r | 73 | 21 files changed, 738 insertions(+), 664 deletions(-) |
57 | target/arm: Handle watchpoints in sve_ld1_r | 74 | create mode 100644 target/arm/cpregs.h |
58 | target/arm: Use SVEContLdSt for multi-register contiguous loads | 75 | create mode 100644 tests/tcg/aarch64/bti-3.c |
59 | target/arm: Update contiguous first-fault and no-fault loads | ||
60 | target/arm: Use SVEContLdSt for contiguous stores | ||
61 | target/arm: Reuse sve_probe_page for gather first-fault loads | ||
62 | target/arm: Reuse sve_probe_page for scatter stores | ||
63 | target/arm: Reuse sve_probe_page for gather loads | ||
64 | target/arm: Remove sve_memopidx | ||
65 | target/arm: Use tcg_gen_gvec_5_ptr for sve FMLA/FCMLA | ||
66 | target/arm: Fix tcg_gen_gvec_dup_imm vs DUP (indexed) | ||
67 | |||
68 | Thomas Huth (1): | ||
69 | target/arm: Make set_feature() available for other files | ||
70 | |||
71 | docs/devel/loads-stores.rst | 39 +- | ||
72 | include/exec/cpu-all.h | 13 +- | ||
73 | include/exec/cpu_ldst.h | 283 +++-- | ||
74 | include/exec/exec-all.h | 39 + | ||
75 | include/hw/arm/nrf51.h | 3 +- | ||
76 | include/hw/core/cpu.h | 23 + | ||
77 | include/hw/i2c/microbit_i2c.h | 2 +- | ||
78 | include/hw/misc/aspeed_scu.h | 1 + | ||
79 | include/hw/timer/nrf51_timer.h | 1 + | ||
80 | target/arm/cpu.h | 10 + | ||
81 | target/arm/helper-sve.h | 45 +- | ||
82 | target/arm/internals.h | 5 - | ||
83 | accel/tcg/cputlb.c | 413 ++++--- | ||
84 | accel/tcg/user-exec.c | 256 ++++- | ||
85 | exec.c | 2 +- | ||
86 | hw/arm/aspeed.c | 73 +- | ||
87 | hw/arm/aspeed_ast2600.c | 6 +- | ||
88 | hw/arm/musicpal.c | 12 +- | ||
89 | hw/arm/nrf51_soc.c | 9 +- | ||
90 | hw/i2c/microbit_i2c.c | 2 +- | ||
91 | hw/misc/aspeed_scu.c | 11 +- | ||
92 | hw/misc/aspeed_sdmc.c | 55 +- | ||
93 | hw/timer/nrf51_timer.c | 14 +- | ||
94 | target/arm/cpu.c | 662 +---------- | ||
95 | target/arm/cpu64.c | 18 +- | ||
96 | target/arm/cpu_tcg.c | 664 +++++++++++ | ||
97 | target/arm/helper.c | 30 +- | ||
98 | target/arm/kvm32.c | 13 +- | ||
99 | target/arm/kvm64.c | 22 +- | ||
100 | target/arm/sve_helper.c | 2398 +++++++++++++++++++++------------------- | ||
101 | target/arm/translate-sve.c | 93 +- | ||
102 | hw/timer/trace-events | 5 +- | ||
103 | target/arm/Makefile.objs | 1 + | ||
104 | 33 files changed, 2975 insertions(+), 2248 deletions(-) | ||
105 | create mode 100644 target/arm/cpu_tcg.c | ||
106 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | This is a boot stub that is similar to the code u-boot runs, allowing | ||
4 | the kernel to boot the secondary CPU. | ||
5 | |||
6 | u-boot works as follows: | ||
7 | |||
8 | 1. Initialises the SMP mailbox area in the SCU at 0x1e6e2180 with default values | ||
9 | |||
10 | 2. Copies a stub named 'mailbox_insn' from flash to the SCU, just above the | ||
11 | mailbox area | ||
12 | |||
13 | 3. Sets AST_SMP_MBOX_FIELD_READY to a magic value to indicate the | ||
14 | secondary can begin execution from the stub | ||
15 | |||
16 | 4. The stub waits until the AST_SMP_MBOX_FIELD_GOSIGN register is set to | ||
17 | a magic value | ||
18 | |||
19 | 5. Jumps to the address in AST_SMP_MBOX_FIELD_ENTRY, starting Linux | ||
20 | |||
21 | Linux indicates it is ready by writing the address of its entrypoint | ||
22 | function to AST_SMP_MBOX_FIELD_ENTRY and the 'go' magic number to | ||
23 | AST_SMP_MBOX_FIELD_GOSIGN. The secondary CPU sees this at step 4 and | ||
24 | breaks out of it's loop. | ||
25 | |||
26 | To be compatible, a fixed qemu stub is loaded into the mailbox area. As | ||
27 | qemu can ensure the stub is loaded before execution starts, we do not | ||
28 | need to emulate the AST_SMP_MBOX_FIELD_READY behaviour of u-boot. The | ||
29 | secondary CPU's program counter points to the beginning of the stub, | ||
30 | allowing qemu to start secondaries at step four. | ||
31 | |||
32 | Reboot behaviour is preserved by resetting AST_SMP_MBOX_FIELD_GOSIGN | ||
33 | when the secondaries are reset. | ||
34 | |||
35 | This is only configured when the system is booted with -kernel and qemu | ||
36 | does not execute u-boot first. | ||
37 | |||
38 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
39 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
40 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
42 | --- | ||
43 | hw/arm/aspeed.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ | ||
44 | 1 file changed, 65 insertions(+) | ||
45 | |||
46 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/aspeed.c | ||
49 | +++ b/hw/arm/aspeed.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps max_ram_ops = { | ||
51 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
52 | }; | ||
53 | |||
54 | +#define AST_SMP_MAILBOX_BASE 0x1e6e2180 | ||
55 | +#define AST_SMP_MBOX_FIELD_ENTRY (AST_SMP_MAILBOX_BASE + 0x0) | ||
56 | +#define AST_SMP_MBOX_FIELD_GOSIGN (AST_SMP_MAILBOX_BASE + 0x4) | ||
57 | +#define AST_SMP_MBOX_FIELD_READY (AST_SMP_MAILBOX_BASE + 0x8) | ||
58 | +#define AST_SMP_MBOX_FIELD_POLLINSN (AST_SMP_MAILBOX_BASE + 0xc) | ||
59 | +#define AST_SMP_MBOX_CODE (AST_SMP_MAILBOX_BASE + 0x10) | ||
60 | +#define AST_SMP_MBOX_GOSIGN 0xabbaab00 | ||
61 | + | ||
62 | +static void aspeed_write_smpboot(ARMCPU *cpu, | ||
63 | + const struct arm_boot_info *info) | ||
64 | +{ | ||
65 | + static const uint32_t poll_mailbox_ready[] = { | ||
66 | + /* | ||
67 | + * r2 = per-cpu go sign value | ||
68 | + * r1 = AST_SMP_MBOX_FIELD_ENTRY | ||
69 | + * r0 = AST_SMP_MBOX_FIELD_GOSIGN | ||
70 | + */ | ||
71 | + 0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5 */ | ||
72 | + 0xe21000ff, /* ands r0, r0, #255 */ | ||
73 | + 0xe59f201c, /* ldr r2, [pc, #28] */ | ||
74 | + 0xe1822000, /* orr r2, r2, r0 */ | ||
75 | + | ||
76 | + 0xe59f1018, /* ldr r1, [pc, #24] */ | ||
77 | + 0xe59f0018, /* ldr r0, [pc, #24] */ | ||
78 | + | ||
79 | + 0xe320f002, /* wfe */ | ||
80 | + 0xe5904000, /* ldr r4, [r0] */ | ||
81 | + 0xe1520004, /* cmp r2, r4 */ | ||
82 | + 0x1afffffb, /* bne <wfe> */ | ||
83 | + 0xe591f000, /* ldr pc, [r1] */ | ||
84 | + AST_SMP_MBOX_GOSIGN, | ||
85 | + AST_SMP_MBOX_FIELD_ENTRY, | ||
86 | + AST_SMP_MBOX_FIELD_GOSIGN, | ||
87 | + }; | ||
88 | + | ||
89 | + rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready, | ||
90 | + sizeof(poll_mailbox_ready), | ||
91 | + info->smp_loader_start); | ||
92 | +} | ||
93 | + | ||
94 | +static void aspeed_reset_secondary(ARMCPU *cpu, | ||
95 | + const struct arm_boot_info *info) | ||
96 | +{ | ||
97 | + AddressSpace *as = arm_boot_address_space(cpu, info); | ||
98 | + CPUState *cs = CPU(cpu); | ||
99 | + | ||
100 | + /* info->smp_bootreg_addr */ | ||
101 | + address_space_stl_notdirty(as, AST_SMP_MBOX_FIELD_GOSIGN, 0, | ||
102 | + MEMTXATTRS_UNSPECIFIED, NULL); | ||
103 | + cpu_set_pc(cs, info->smp_loader_start); | ||
104 | +} | ||
105 | + | ||
106 | #define FIRMWARE_ADDR 0x0 | ||
107 | |||
108 | static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size, | ||
109 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine) | ||
110 | } | ||
111 | } | ||
112 | |||
113 | + if (machine->kernel_filename && bmc->soc.num_cpus > 1) { | ||
114 | + /* With no u-boot we must set up a boot stub for the secondary CPU */ | ||
115 | + MemoryRegion *smpboot = g_new(MemoryRegion, 1); | ||
116 | + memory_region_init_ram(smpboot, OBJECT(bmc), "aspeed.smpboot", | ||
117 | + 0x80, &error_abort); | ||
118 | + memory_region_add_subregion(get_system_memory(), | ||
119 | + AST_SMP_MAILBOX_BASE, smpboot); | ||
120 | + | ||
121 | + aspeed_board_binfo.write_secondary_boot = aspeed_write_smpboot; | ||
122 | + aspeed_board_binfo.secondary_cpu_reset_hook = aspeed_reset_secondary; | ||
123 | + aspeed_board_binfo.smp_loader_start = AST_SMP_MBOX_CODE; | ||
124 | + } | ||
125 | + | ||
126 | aspeed_board_binfo.ram_size = ram_size; | ||
127 | aspeed_board_binfo.loader_start = sc->memmap[ASPEED_SDRAM]; | ||
128 | aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus; | ||
129 | -- | ||
130 | 2.20.1 | ||
131 | |||
132 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | A KVM-only build won't be able to run TCG cpus. | 3 | This controls whether the PACI{A,B}SP instructions trap with BTYPE=3 |
4 | (indirect branch from register other than x16/x17). The linux kernel | ||
5 | sets this in bti_enable(). | ||
4 | 6 | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/998 |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200504172448.9402-6-philmd@redhat.com | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Message-id: 20220427042312.294300-1-richard.henderson@linaro.org | ||
11 | [PMM: remove stray change to makefile comment] | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 13 | --- |
10 | target/arm/cpu.c | 634 ------------------------------------- | 14 | target/arm/cpu.c | 2 ++ |
11 | target/arm/cpu_tcg.c | 664 +++++++++++++++++++++++++++++++++++++++ | 15 | tests/tcg/aarch64/bti-3.c | 42 +++++++++++++++++++++++++++++++ |
12 | target/arm/Makefile.objs | 1 + | 16 | tests/tcg/aarch64/Makefile.target | 6 ++--- |
13 | 3 files changed, 665 insertions(+), 634 deletions(-) | 17 | 3 files changed, 47 insertions(+), 3 deletions(-) |
14 | create mode 100644 target/arm/cpu_tcg.c | 18 | create mode 100644 tests/tcg/aarch64/bti-3.c |
15 | 19 | ||
16 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 20 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
17 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.c | 22 | --- a/target/arm/cpu.c |
19 | +++ b/target/arm/cpu.c | 23 | +++ b/target/arm/cpu.c |
20 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | 24 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
21 | return true; | 25 | /* Enable all PAC keys. */ |
22 | } | 26 | env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB | |
23 | 27 | SCTLR_EnDA | SCTLR_EnDB); | |
24 | -#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | 28 | + /* Trap on btype=3 for PACIxSP. */ |
25 | -static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | 29 | + env->cp15.sctlr_el[1] |= SCTLR_BT0; |
26 | -{ | 30 | /* and to the FP/Neon instructions */ |
27 | - CPUClass *cc = CPU_GET_CLASS(cs); | 31 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3); |
28 | - ARMCPU *cpu = ARM_CPU(cs); | 32 | /* and to the SVE instructions */ |
29 | - CPUARMState *env = &cpu->env; | 33 | diff --git a/tests/tcg/aarch64/bti-3.c b/tests/tcg/aarch64/bti-3.c |
30 | - bool ret = false; | ||
31 | - | ||
32 | - /* | ||
33 | - * ARMv7-M interrupt masking works differently than -A or -R. | ||
34 | - * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
35 | - * masking FIQ and IRQ interrupts, an exception is taken only | ||
36 | - * if it is higher priority than the current execution priority | ||
37 | - * (which depends on state like BASEPRI, FAULTMASK and the | ||
38 | - * currently active exception). | ||
39 | - */ | ||
40 | - if (interrupt_request & CPU_INTERRUPT_HARD | ||
41 | - && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
42 | - cs->exception_index = EXCP_IRQ; | ||
43 | - cc->do_interrupt(cs); | ||
44 | - ret = true; | ||
45 | - } | ||
46 | - return ret; | ||
47 | -} | ||
48 | -#endif | ||
49 | - | ||
50 | void arm_cpu_update_virq(ARMCPU *cpu) | ||
51 | { | ||
52 | /* | ||
53 | @@ -XXX,XX +XXX,XX @@ static ObjectClass *arm_cpu_class_by_name(const char *cpu_model) | ||
54 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
55 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
56 | |||
57 | -static void arm926_initfn(Object *obj) | ||
58 | -{ | ||
59 | - ARMCPU *cpu = ARM_CPU(obj); | ||
60 | - | ||
61 | - cpu->dtb_compatible = "arm,arm926"; | ||
62 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
63 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
64 | - set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); | ||
65 | - cpu->midr = 0x41069265; | ||
66 | - cpu->reset_fpsid = 0x41011090; | ||
67 | - cpu->ctr = 0x1dd20d2; | ||
68 | - cpu->reset_sctlr = 0x00090078; | ||
69 | - | ||
70 | - /* | ||
71 | - * ARMv5 does not have the ID_ISAR registers, but we can still | ||
72 | - * set the field to indicate Jazelle support within QEMU. | ||
73 | - */ | ||
74 | - cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | ||
75 | - /* | ||
76 | - * Similarly, we need to set MVFR0 fields to enable vfp and short vector | ||
77 | - * support even though ARMv5 doesn't have this register. | ||
78 | - */ | ||
79 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
80 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); | ||
81 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); | ||
82 | -} | ||
83 | - | ||
84 | -static void arm946_initfn(Object *obj) | ||
85 | -{ | ||
86 | - ARMCPU *cpu = ARM_CPU(obj); | ||
87 | - | ||
88 | - cpu->dtb_compatible = "arm,arm946"; | ||
89 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
90 | - set_feature(&cpu->env, ARM_FEATURE_PMSA); | ||
91 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
92 | - cpu->midr = 0x41059461; | ||
93 | - cpu->ctr = 0x0f004006; | ||
94 | - cpu->reset_sctlr = 0x00000078; | ||
95 | -} | ||
96 | - | ||
97 | -static void arm1026_initfn(Object *obj) | ||
98 | -{ | ||
99 | - ARMCPU *cpu = ARM_CPU(obj); | ||
100 | - | ||
101 | - cpu->dtb_compatible = "arm,arm1026"; | ||
102 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
103 | - set_feature(&cpu->env, ARM_FEATURE_AUXCR); | ||
104 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
105 | - set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); | ||
106 | - cpu->midr = 0x4106a262; | ||
107 | - cpu->reset_fpsid = 0x410110a0; | ||
108 | - cpu->ctr = 0x1dd20d2; | ||
109 | - cpu->reset_sctlr = 0x00090078; | ||
110 | - cpu->reset_auxcr = 1; | ||
111 | - | ||
112 | - /* | ||
113 | - * ARMv5 does not have the ID_ISAR registers, but we can still | ||
114 | - * set the field to indicate Jazelle support within QEMU. | ||
115 | - */ | ||
116 | - cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | ||
117 | - /* | ||
118 | - * Similarly, we need to set MVFR0 fields to enable vfp and short vector | ||
119 | - * support even though ARMv5 doesn't have this register. | ||
120 | - */ | ||
121 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
122 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); | ||
123 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); | ||
124 | - | ||
125 | - { | ||
126 | - /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */ | ||
127 | - ARMCPRegInfo ifar = { | ||
128 | - .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1, | ||
129 | - .access = PL1_RW, | ||
130 | - .fieldoffset = offsetof(CPUARMState, cp15.ifar_ns), | ||
131 | - .resetvalue = 0 | ||
132 | - }; | ||
133 | - define_one_arm_cp_reg(cpu, &ifar); | ||
134 | - } | ||
135 | -} | ||
136 | - | ||
137 | -static void arm1136_r2_initfn(Object *obj) | ||
138 | -{ | ||
139 | - ARMCPU *cpu = ARM_CPU(obj); | ||
140 | - /* | ||
141 | - * What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an | ||
142 | - * older core than plain "arm1136". In particular this does not | ||
143 | - * have the v6K features. | ||
144 | - * These ID register values are correct for 1136 but may be wrong | ||
145 | - * for 1136_r2 (in particular r0p2 does not actually implement most | ||
146 | - * of the ID registers). | ||
147 | - */ | ||
148 | - | ||
149 | - cpu->dtb_compatible = "arm,arm1136"; | ||
150 | - set_feature(&cpu->env, ARM_FEATURE_V6); | ||
151 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
152 | - set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); | ||
153 | - set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | ||
154 | - cpu->midr = 0x4107b362; | ||
155 | - cpu->reset_fpsid = 0x410120b4; | ||
156 | - cpu->isar.mvfr0 = 0x11111111; | ||
157 | - cpu->isar.mvfr1 = 0x00000000; | ||
158 | - cpu->ctr = 0x1dd20d2; | ||
159 | - cpu->reset_sctlr = 0x00050078; | ||
160 | - cpu->id_pfr0 = 0x111; | ||
161 | - cpu->id_pfr1 = 0x1; | ||
162 | - cpu->isar.id_dfr0 = 0x2; | ||
163 | - cpu->id_afr0 = 0x3; | ||
164 | - cpu->isar.id_mmfr0 = 0x01130003; | ||
165 | - cpu->isar.id_mmfr1 = 0x10030302; | ||
166 | - cpu->isar.id_mmfr2 = 0x01222110; | ||
167 | - cpu->isar.id_isar0 = 0x00140011; | ||
168 | - cpu->isar.id_isar1 = 0x12002111; | ||
169 | - cpu->isar.id_isar2 = 0x11231111; | ||
170 | - cpu->isar.id_isar3 = 0x01102131; | ||
171 | - cpu->isar.id_isar4 = 0x141; | ||
172 | - cpu->reset_auxcr = 7; | ||
173 | -} | ||
174 | - | ||
175 | -static void arm1136_initfn(Object *obj) | ||
176 | -{ | ||
177 | - ARMCPU *cpu = ARM_CPU(obj); | ||
178 | - | ||
179 | - cpu->dtb_compatible = "arm,arm1136"; | ||
180 | - set_feature(&cpu->env, ARM_FEATURE_V6K); | ||
181 | - set_feature(&cpu->env, ARM_FEATURE_V6); | ||
182 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
183 | - set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); | ||
184 | - set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | ||
185 | - cpu->midr = 0x4117b363; | ||
186 | - cpu->reset_fpsid = 0x410120b4; | ||
187 | - cpu->isar.mvfr0 = 0x11111111; | ||
188 | - cpu->isar.mvfr1 = 0x00000000; | ||
189 | - cpu->ctr = 0x1dd20d2; | ||
190 | - cpu->reset_sctlr = 0x00050078; | ||
191 | - cpu->id_pfr0 = 0x111; | ||
192 | - cpu->id_pfr1 = 0x1; | ||
193 | - cpu->isar.id_dfr0 = 0x2; | ||
194 | - cpu->id_afr0 = 0x3; | ||
195 | - cpu->isar.id_mmfr0 = 0x01130003; | ||
196 | - cpu->isar.id_mmfr1 = 0x10030302; | ||
197 | - cpu->isar.id_mmfr2 = 0x01222110; | ||
198 | - cpu->isar.id_isar0 = 0x00140011; | ||
199 | - cpu->isar.id_isar1 = 0x12002111; | ||
200 | - cpu->isar.id_isar2 = 0x11231111; | ||
201 | - cpu->isar.id_isar3 = 0x01102131; | ||
202 | - cpu->isar.id_isar4 = 0x141; | ||
203 | - cpu->reset_auxcr = 7; | ||
204 | -} | ||
205 | - | ||
206 | -static void arm1176_initfn(Object *obj) | ||
207 | -{ | ||
208 | - ARMCPU *cpu = ARM_CPU(obj); | ||
209 | - | ||
210 | - cpu->dtb_compatible = "arm,arm1176"; | ||
211 | - set_feature(&cpu->env, ARM_FEATURE_V6K); | ||
212 | - set_feature(&cpu->env, ARM_FEATURE_VAPA); | ||
213 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
214 | - set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); | ||
215 | - set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | ||
216 | - set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
217 | - cpu->midr = 0x410fb767; | ||
218 | - cpu->reset_fpsid = 0x410120b5; | ||
219 | - cpu->isar.mvfr0 = 0x11111111; | ||
220 | - cpu->isar.mvfr1 = 0x00000000; | ||
221 | - cpu->ctr = 0x1dd20d2; | ||
222 | - cpu->reset_sctlr = 0x00050078; | ||
223 | - cpu->id_pfr0 = 0x111; | ||
224 | - cpu->id_pfr1 = 0x11; | ||
225 | - cpu->isar.id_dfr0 = 0x33; | ||
226 | - cpu->id_afr0 = 0; | ||
227 | - cpu->isar.id_mmfr0 = 0x01130003; | ||
228 | - cpu->isar.id_mmfr1 = 0x10030302; | ||
229 | - cpu->isar.id_mmfr2 = 0x01222100; | ||
230 | - cpu->isar.id_isar0 = 0x0140011; | ||
231 | - cpu->isar.id_isar1 = 0x12002111; | ||
232 | - cpu->isar.id_isar2 = 0x11231121; | ||
233 | - cpu->isar.id_isar3 = 0x01102131; | ||
234 | - cpu->isar.id_isar4 = 0x01141; | ||
235 | - cpu->reset_auxcr = 7; | ||
236 | -} | ||
237 | - | ||
238 | -static void arm11mpcore_initfn(Object *obj) | ||
239 | -{ | ||
240 | - ARMCPU *cpu = ARM_CPU(obj); | ||
241 | - | ||
242 | - cpu->dtb_compatible = "arm,arm11mpcore"; | ||
243 | - set_feature(&cpu->env, ARM_FEATURE_V6K); | ||
244 | - set_feature(&cpu->env, ARM_FEATURE_VAPA); | ||
245 | - set_feature(&cpu->env, ARM_FEATURE_MPIDR); | ||
246 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
247 | - cpu->midr = 0x410fb022; | ||
248 | - cpu->reset_fpsid = 0x410120b4; | ||
249 | - cpu->isar.mvfr0 = 0x11111111; | ||
250 | - cpu->isar.mvfr1 = 0x00000000; | ||
251 | - cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */ | ||
252 | - cpu->id_pfr0 = 0x111; | ||
253 | - cpu->id_pfr1 = 0x1; | ||
254 | - cpu->isar.id_dfr0 = 0; | ||
255 | - cpu->id_afr0 = 0x2; | ||
256 | - cpu->isar.id_mmfr0 = 0x01100103; | ||
257 | - cpu->isar.id_mmfr1 = 0x10020302; | ||
258 | - cpu->isar.id_mmfr2 = 0x01222000; | ||
259 | - cpu->isar.id_isar0 = 0x00100011; | ||
260 | - cpu->isar.id_isar1 = 0x12002111; | ||
261 | - cpu->isar.id_isar2 = 0x11221011; | ||
262 | - cpu->isar.id_isar3 = 0x01102131; | ||
263 | - cpu->isar.id_isar4 = 0x141; | ||
264 | - cpu->reset_auxcr = 1; | ||
265 | -} | ||
266 | - | ||
267 | -static void cortex_m0_initfn(Object *obj) | ||
268 | -{ | ||
269 | - ARMCPU *cpu = ARM_CPU(obj); | ||
270 | - set_feature(&cpu->env, ARM_FEATURE_V6); | ||
271 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
272 | - | ||
273 | - cpu->midr = 0x410cc200; | ||
274 | -} | ||
275 | - | ||
276 | -static void cortex_m3_initfn(Object *obj) | ||
277 | -{ | ||
278 | - ARMCPU *cpu = ARM_CPU(obj); | ||
279 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
280 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
281 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
282 | - cpu->midr = 0x410fc231; | ||
283 | - cpu->pmsav7_dregion = 8; | ||
284 | - cpu->id_pfr0 = 0x00000030; | ||
285 | - cpu->id_pfr1 = 0x00000200; | ||
286 | - cpu->isar.id_dfr0 = 0x00100000; | ||
287 | - cpu->id_afr0 = 0x00000000; | ||
288 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
289 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
290 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
291 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
292 | - cpu->isar.id_isar0 = 0x01141110; | ||
293 | - cpu->isar.id_isar1 = 0x02111000; | ||
294 | - cpu->isar.id_isar2 = 0x21112231; | ||
295 | - cpu->isar.id_isar3 = 0x01111110; | ||
296 | - cpu->isar.id_isar4 = 0x01310102; | ||
297 | - cpu->isar.id_isar5 = 0x00000000; | ||
298 | - cpu->isar.id_isar6 = 0x00000000; | ||
299 | -} | ||
300 | - | ||
301 | -static void cortex_m4_initfn(Object *obj) | ||
302 | -{ | ||
303 | - ARMCPU *cpu = ARM_CPU(obj); | ||
304 | - | ||
305 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
306 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
307 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
308 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
309 | - cpu->midr = 0x410fc240; /* r0p0 */ | ||
310 | - cpu->pmsav7_dregion = 8; | ||
311 | - cpu->isar.mvfr0 = 0x10110021; | ||
312 | - cpu->isar.mvfr1 = 0x11000011; | ||
313 | - cpu->isar.mvfr2 = 0x00000000; | ||
314 | - cpu->id_pfr0 = 0x00000030; | ||
315 | - cpu->id_pfr1 = 0x00000200; | ||
316 | - cpu->isar.id_dfr0 = 0x00100000; | ||
317 | - cpu->id_afr0 = 0x00000000; | ||
318 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
319 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
320 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
321 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
322 | - cpu->isar.id_isar0 = 0x01141110; | ||
323 | - cpu->isar.id_isar1 = 0x02111000; | ||
324 | - cpu->isar.id_isar2 = 0x21112231; | ||
325 | - cpu->isar.id_isar3 = 0x01111110; | ||
326 | - cpu->isar.id_isar4 = 0x01310102; | ||
327 | - cpu->isar.id_isar5 = 0x00000000; | ||
328 | - cpu->isar.id_isar6 = 0x00000000; | ||
329 | -} | ||
330 | - | ||
331 | -static void cortex_m7_initfn(Object *obj) | ||
332 | -{ | ||
333 | - ARMCPU *cpu = ARM_CPU(obj); | ||
334 | - | ||
335 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
336 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
337 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
338 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
339 | - cpu->midr = 0x411fc272; /* r1p2 */ | ||
340 | - cpu->pmsav7_dregion = 8; | ||
341 | - cpu->isar.mvfr0 = 0x10110221; | ||
342 | - cpu->isar.mvfr1 = 0x12000011; | ||
343 | - cpu->isar.mvfr2 = 0x00000040; | ||
344 | - cpu->id_pfr0 = 0x00000030; | ||
345 | - cpu->id_pfr1 = 0x00000200; | ||
346 | - cpu->isar.id_dfr0 = 0x00100000; | ||
347 | - cpu->id_afr0 = 0x00000000; | ||
348 | - cpu->isar.id_mmfr0 = 0x00100030; | ||
349 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
350 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
351 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
352 | - cpu->isar.id_isar0 = 0x01101110; | ||
353 | - cpu->isar.id_isar1 = 0x02112000; | ||
354 | - cpu->isar.id_isar2 = 0x20232231; | ||
355 | - cpu->isar.id_isar3 = 0x01111131; | ||
356 | - cpu->isar.id_isar4 = 0x01310132; | ||
357 | - cpu->isar.id_isar5 = 0x00000000; | ||
358 | - cpu->isar.id_isar6 = 0x00000000; | ||
359 | -} | ||
360 | - | ||
361 | -static void cortex_m33_initfn(Object *obj) | ||
362 | -{ | ||
363 | - ARMCPU *cpu = ARM_CPU(obj); | ||
364 | - | ||
365 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
366 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
367 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
368 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
369 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
370 | - cpu->midr = 0x410fd213; /* r0p3 */ | ||
371 | - cpu->pmsav7_dregion = 16; | ||
372 | - cpu->sau_sregion = 8; | ||
373 | - cpu->isar.mvfr0 = 0x10110021; | ||
374 | - cpu->isar.mvfr1 = 0x11000011; | ||
375 | - cpu->isar.mvfr2 = 0x00000040; | ||
376 | - cpu->id_pfr0 = 0x00000030; | ||
377 | - cpu->id_pfr1 = 0x00000210; | ||
378 | - cpu->isar.id_dfr0 = 0x00200000; | ||
379 | - cpu->id_afr0 = 0x00000000; | ||
380 | - cpu->isar.id_mmfr0 = 0x00101F40; | ||
381 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
382 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
383 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
384 | - cpu->isar.id_isar0 = 0x01101110; | ||
385 | - cpu->isar.id_isar1 = 0x02212000; | ||
386 | - cpu->isar.id_isar2 = 0x20232232; | ||
387 | - cpu->isar.id_isar3 = 0x01111131; | ||
388 | - cpu->isar.id_isar4 = 0x01310132; | ||
389 | - cpu->isar.id_isar5 = 0x00000000; | ||
390 | - cpu->isar.id_isar6 = 0x00000000; | ||
391 | - cpu->clidr = 0x00000000; | ||
392 | - cpu->ctr = 0x8000c000; | ||
393 | -} | ||
394 | - | ||
395 | -static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
396 | -{ | ||
397 | - ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
398 | - CPUClass *cc = CPU_CLASS(oc); | ||
399 | - | ||
400 | - acc->info = data; | ||
401 | -#ifndef CONFIG_USER_ONLY | ||
402 | - cc->do_interrupt = arm_v7m_cpu_do_interrupt; | ||
403 | -#endif | ||
404 | - | ||
405 | - cc->cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt; | ||
406 | -} | ||
407 | - | ||
408 | -static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
409 | - /* Dummy the TCM region regs for the moment */ | ||
410 | - { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | ||
411 | - .access = PL1_RW, .type = ARM_CP_CONST }, | ||
412 | - { .name = "BTCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1, | ||
413 | - .access = PL1_RW, .type = ARM_CP_CONST }, | ||
414 | - { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5, | ||
415 | - .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP }, | ||
416 | - REGINFO_SENTINEL | ||
417 | -}; | ||
418 | - | ||
419 | -static void cortex_r5_initfn(Object *obj) | ||
420 | -{ | ||
421 | - ARMCPU *cpu = ARM_CPU(obj); | ||
422 | - | ||
423 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
424 | - set_feature(&cpu->env, ARM_FEATURE_V7MP); | ||
425 | - set_feature(&cpu->env, ARM_FEATURE_PMSA); | ||
426 | - set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
427 | - cpu->midr = 0x411fc153; /* r1p3 */ | ||
428 | - cpu->id_pfr0 = 0x0131; | ||
429 | - cpu->id_pfr1 = 0x001; | ||
430 | - cpu->isar.id_dfr0 = 0x010400; | ||
431 | - cpu->id_afr0 = 0x0; | ||
432 | - cpu->isar.id_mmfr0 = 0x0210030; | ||
433 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
434 | - cpu->isar.id_mmfr2 = 0x01200000; | ||
435 | - cpu->isar.id_mmfr3 = 0x0211; | ||
436 | - cpu->isar.id_isar0 = 0x02101111; | ||
437 | - cpu->isar.id_isar1 = 0x13112111; | ||
438 | - cpu->isar.id_isar2 = 0x21232141; | ||
439 | - cpu->isar.id_isar3 = 0x01112131; | ||
440 | - cpu->isar.id_isar4 = 0x0010142; | ||
441 | - cpu->isar.id_isar5 = 0x0; | ||
442 | - cpu->isar.id_isar6 = 0x0; | ||
443 | - cpu->mp_is_up = true; | ||
444 | - cpu->pmsav7_dregion = 16; | ||
445 | - define_arm_cp_regs(cpu, cortexr5_cp_reginfo); | ||
446 | -} | ||
447 | - | ||
448 | -static void cortex_r5f_initfn(Object *obj) | ||
449 | -{ | ||
450 | - ARMCPU *cpu = ARM_CPU(obj); | ||
451 | - | ||
452 | - cortex_r5_initfn(obj); | ||
453 | - cpu->isar.mvfr0 = 0x10110221; | ||
454 | - cpu->isar.mvfr1 = 0x00000011; | ||
455 | -} | ||
456 | - | ||
457 | static const ARMCPRegInfo cortexa8_cp_reginfo[] = { | ||
458 | { .name = "L2LOCKDOWN", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 0, | ||
459 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
460 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
461 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); | ||
462 | } | ||
463 | |||
464 | -static void ti925t_initfn(Object *obj) | ||
465 | -{ | ||
466 | - ARMCPU *cpu = ARM_CPU(obj); | ||
467 | - set_feature(&cpu->env, ARM_FEATURE_V4T); | ||
468 | - set_feature(&cpu->env, ARM_FEATURE_OMAPCP); | ||
469 | - cpu->midr = ARM_CPUID_TI925T; | ||
470 | - cpu->ctr = 0x5109149; | ||
471 | - cpu->reset_sctlr = 0x00000070; | ||
472 | -} | ||
473 | - | ||
474 | -static void sa1100_initfn(Object *obj) | ||
475 | -{ | ||
476 | - ARMCPU *cpu = ARM_CPU(obj); | ||
477 | - | ||
478 | - cpu->dtb_compatible = "intel,sa1100"; | ||
479 | - set_feature(&cpu->env, ARM_FEATURE_STRONGARM); | ||
480 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
481 | - cpu->midr = 0x4401A11B; | ||
482 | - cpu->reset_sctlr = 0x00000070; | ||
483 | -} | ||
484 | - | ||
485 | -static void sa1110_initfn(Object *obj) | ||
486 | -{ | ||
487 | - ARMCPU *cpu = ARM_CPU(obj); | ||
488 | - set_feature(&cpu->env, ARM_FEATURE_STRONGARM); | ||
489 | - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
490 | - cpu->midr = 0x6901B119; | ||
491 | - cpu->reset_sctlr = 0x00000070; | ||
492 | -} | ||
493 | - | ||
494 | -static void pxa250_initfn(Object *obj) | ||
495 | -{ | ||
496 | - ARMCPU *cpu = ARM_CPU(obj); | ||
497 | - | ||
498 | - cpu->dtb_compatible = "marvell,xscale"; | ||
499 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
500 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
501 | - cpu->midr = 0x69052100; | ||
502 | - cpu->ctr = 0xd172172; | ||
503 | - cpu->reset_sctlr = 0x00000078; | ||
504 | -} | ||
505 | - | ||
506 | -static void pxa255_initfn(Object *obj) | ||
507 | -{ | ||
508 | - ARMCPU *cpu = ARM_CPU(obj); | ||
509 | - | ||
510 | - cpu->dtb_compatible = "marvell,xscale"; | ||
511 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
512 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
513 | - cpu->midr = 0x69052d00; | ||
514 | - cpu->ctr = 0xd172172; | ||
515 | - cpu->reset_sctlr = 0x00000078; | ||
516 | -} | ||
517 | - | ||
518 | -static void pxa260_initfn(Object *obj) | ||
519 | -{ | ||
520 | - ARMCPU *cpu = ARM_CPU(obj); | ||
521 | - | ||
522 | - cpu->dtb_compatible = "marvell,xscale"; | ||
523 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
524 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
525 | - cpu->midr = 0x69052903; | ||
526 | - cpu->ctr = 0xd172172; | ||
527 | - cpu->reset_sctlr = 0x00000078; | ||
528 | -} | ||
529 | - | ||
530 | -static void pxa261_initfn(Object *obj) | ||
531 | -{ | ||
532 | - ARMCPU *cpu = ARM_CPU(obj); | ||
533 | - | ||
534 | - cpu->dtb_compatible = "marvell,xscale"; | ||
535 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
536 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
537 | - cpu->midr = 0x69052d05; | ||
538 | - cpu->ctr = 0xd172172; | ||
539 | - cpu->reset_sctlr = 0x00000078; | ||
540 | -} | ||
541 | - | ||
542 | -static void pxa262_initfn(Object *obj) | ||
543 | -{ | ||
544 | - ARMCPU *cpu = ARM_CPU(obj); | ||
545 | - | ||
546 | - cpu->dtb_compatible = "marvell,xscale"; | ||
547 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
548 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
549 | - cpu->midr = 0x69052d06; | ||
550 | - cpu->ctr = 0xd172172; | ||
551 | - cpu->reset_sctlr = 0x00000078; | ||
552 | -} | ||
553 | - | ||
554 | -static void pxa270a0_initfn(Object *obj) | ||
555 | -{ | ||
556 | - ARMCPU *cpu = ARM_CPU(obj); | ||
557 | - | ||
558 | - cpu->dtb_compatible = "marvell,xscale"; | ||
559 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
560 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
561 | - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
562 | - cpu->midr = 0x69054110; | ||
563 | - cpu->ctr = 0xd172172; | ||
564 | - cpu->reset_sctlr = 0x00000078; | ||
565 | -} | ||
566 | - | ||
567 | -static void pxa270a1_initfn(Object *obj) | ||
568 | -{ | ||
569 | - ARMCPU *cpu = ARM_CPU(obj); | ||
570 | - | ||
571 | - cpu->dtb_compatible = "marvell,xscale"; | ||
572 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
573 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
574 | - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
575 | - cpu->midr = 0x69054111; | ||
576 | - cpu->ctr = 0xd172172; | ||
577 | - cpu->reset_sctlr = 0x00000078; | ||
578 | -} | ||
579 | - | ||
580 | -static void pxa270b0_initfn(Object *obj) | ||
581 | -{ | ||
582 | - ARMCPU *cpu = ARM_CPU(obj); | ||
583 | - | ||
584 | - cpu->dtb_compatible = "marvell,xscale"; | ||
585 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
586 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
587 | - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
588 | - cpu->midr = 0x69054112; | ||
589 | - cpu->ctr = 0xd172172; | ||
590 | - cpu->reset_sctlr = 0x00000078; | ||
591 | -} | ||
592 | - | ||
593 | -static void pxa270b1_initfn(Object *obj) | ||
594 | -{ | ||
595 | - ARMCPU *cpu = ARM_CPU(obj); | ||
596 | - | ||
597 | - cpu->dtb_compatible = "marvell,xscale"; | ||
598 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
599 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
600 | - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
601 | - cpu->midr = 0x69054113; | ||
602 | - cpu->ctr = 0xd172172; | ||
603 | - cpu->reset_sctlr = 0x00000078; | ||
604 | -} | ||
605 | - | ||
606 | -static void pxa270c0_initfn(Object *obj) | ||
607 | -{ | ||
608 | - ARMCPU *cpu = ARM_CPU(obj); | ||
609 | - | ||
610 | - cpu->dtb_compatible = "marvell,xscale"; | ||
611 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
612 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
613 | - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
614 | - cpu->midr = 0x69054114; | ||
615 | - cpu->ctr = 0xd172172; | ||
616 | - cpu->reset_sctlr = 0x00000078; | ||
617 | -} | ||
618 | - | ||
619 | -static void pxa270c5_initfn(Object *obj) | ||
620 | -{ | ||
621 | - ARMCPU *cpu = ARM_CPU(obj); | ||
622 | - | ||
623 | - cpu->dtb_compatible = "marvell,xscale"; | ||
624 | - set_feature(&cpu->env, ARM_FEATURE_V5); | ||
625 | - set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
626 | - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
627 | - cpu->midr = 0x69054117; | ||
628 | - cpu->ctr = 0xd172172; | ||
629 | - cpu->reset_sctlr = 0x00000078; | ||
630 | -} | ||
631 | - | ||
632 | #ifndef TARGET_AARCH64 | ||
633 | /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); | ||
634 | * otherwise, a CPU with as many features enabled as our emulation supports. | ||
635 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
636 | |||
637 | static const ARMCPUInfo arm_cpus[] = { | ||
638 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
639 | - { .name = "arm926", .initfn = arm926_initfn }, | ||
640 | - { .name = "arm946", .initfn = arm946_initfn }, | ||
641 | - { .name = "arm1026", .initfn = arm1026_initfn }, | ||
642 | - /* | ||
643 | - * What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an | ||
644 | - * older core than plain "arm1136". In particular this does not | ||
645 | - * have the v6K features. | ||
646 | - */ | ||
647 | - { .name = "arm1136-r2", .initfn = arm1136_r2_initfn }, | ||
648 | - { .name = "arm1136", .initfn = arm1136_initfn }, | ||
649 | - { .name = "arm1176", .initfn = arm1176_initfn }, | ||
650 | - { .name = "arm11mpcore", .initfn = arm11mpcore_initfn }, | ||
651 | - { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
652 | - .class_init = arm_v7m_class_init }, | ||
653 | - { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
654 | - .class_init = arm_v7m_class_init }, | ||
655 | - { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
656 | - .class_init = arm_v7m_class_init }, | ||
657 | - { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
658 | - .class_init = arm_v7m_class_init }, | ||
659 | - { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
660 | - .class_init = arm_v7m_class_init }, | ||
661 | - { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | ||
662 | - { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, | ||
663 | { .name = "cortex-a7", .initfn = cortex_a7_initfn }, | ||
664 | { .name = "cortex-a8", .initfn = cortex_a8_initfn }, | ||
665 | { .name = "cortex-a9", .initfn = cortex_a9_initfn }, | ||
666 | { .name = "cortex-a15", .initfn = cortex_a15_initfn }, | ||
667 | - { .name = "ti925t", .initfn = ti925t_initfn }, | ||
668 | - { .name = "sa1100", .initfn = sa1100_initfn }, | ||
669 | - { .name = "sa1110", .initfn = sa1110_initfn }, | ||
670 | - { .name = "pxa250", .initfn = pxa250_initfn }, | ||
671 | - { .name = "pxa255", .initfn = pxa255_initfn }, | ||
672 | - { .name = "pxa260", .initfn = pxa260_initfn }, | ||
673 | - { .name = "pxa261", .initfn = pxa261_initfn }, | ||
674 | - { .name = "pxa262", .initfn = pxa262_initfn }, | ||
675 | - /* "pxa270" is an alias for "pxa270-a0" */ | ||
676 | - { .name = "pxa270", .initfn = pxa270a0_initfn }, | ||
677 | - { .name = "pxa270-a0", .initfn = pxa270a0_initfn }, | ||
678 | - { .name = "pxa270-a1", .initfn = pxa270a1_initfn }, | ||
679 | - { .name = "pxa270-b0", .initfn = pxa270b0_initfn }, | ||
680 | - { .name = "pxa270-b1", .initfn = pxa270b1_initfn }, | ||
681 | - { .name = "pxa270-c0", .initfn = pxa270c0_initfn }, | ||
682 | - { .name = "pxa270-c5", .initfn = pxa270c5_initfn }, | ||
683 | #ifndef TARGET_AARCH64 | ||
684 | { .name = "max", .initfn = arm_max_initfn }, | ||
685 | #endif | ||
686 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
687 | new file mode 100644 | 34 | new file mode 100644 |
688 | index XXXXXXX..XXXXXXX | 35 | index XXXXXXX..XXXXXXX |
689 | --- /dev/null | 36 | --- /dev/null |
690 | +++ b/target/arm/cpu_tcg.c | 37 | +++ b/tests/tcg/aarch64/bti-3.c |
691 | @@ -XXX,XX +XXX,XX @@ | 38 | @@ -XXX,XX +XXX,XX @@ |
692 | +/* | 39 | +/* |
693 | + * QEMU ARM TCG CPUs. | 40 | + * BTI vs PACIASP |
694 | + * | ||
695 | + * Copyright (c) 2012 SUSE LINUX Products GmbH | ||
696 | + * | ||
697 | + * This code is licensed under the GNU GPL v2 or later. | ||
698 | + * | ||
699 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
700 | + */ | 41 | + */ |
701 | + | 42 | + |
702 | +#include "qemu/osdep.h" | 43 | +#include "bti-crt.inc.c" |
703 | +#include "cpu.h" | ||
704 | +#include "internals.h" | ||
705 | + | 44 | + |
706 | +/* CPU models. These are not needed for the AArch64 linux-user build. */ | 45 | +static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc) |
707 | +#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
708 | + | ||
709 | +static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
710 | +{ | 46 | +{ |
711 | + CPUClass *cc = CPU_GET_CLASS(cs); | 47 | + uc->uc_mcontext.pc += 8; |
712 | + ARMCPU *cpu = ARM_CPU(cs); | 48 | + uc->uc_mcontext.pstate = 1; |
713 | + CPUARMState *env = &cpu->env; | ||
714 | + bool ret = false; | ||
715 | + | ||
716 | + /* | ||
717 | + * ARMv7-M interrupt masking works differently than -A or -R. | ||
718 | + * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
719 | + * masking FIQ and IRQ interrupts, an exception is taken only | ||
720 | + * if it is higher priority than the current execution priority | ||
721 | + * (which depends on state like BASEPRI, FAULTMASK and the | ||
722 | + * currently active exception). | ||
723 | + */ | ||
724 | + if (interrupt_request & CPU_INTERRUPT_HARD | ||
725 | + && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
726 | + cs->exception_index = EXCP_IRQ; | ||
727 | + cc->do_interrupt(cs); | ||
728 | + ret = true; | ||
729 | + } | ||
730 | + return ret; | ||
731 | +} | 49 | +} |
732 | + | 50 | + |
733 | +static void arm926_initfn(Object *obj) | 51 | +#define BTYPE_1() \ |
52 | + asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \ | ||
53 | + : "=r"(skipped) : : "x16", "x30") | ||
54 | + | ||
55 | +#define BTYPE_2() \ | ||
56 | + asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \ | ||
57 | + : "=r"(skipped) : : "x16", "x30") | ||
58 | + | ||
59 | +#define BTYPE_3() \ | ||
60 | + asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \ | ||
61 | + : "=r"(skipped) : : "x15", "x30") | ||
62 | + | ||
63 | +#define TEST(WHICH, EXPECT) \ | ||
64 | + do { WHICH(); fail += skipped ^ EXPECT; } while (0) | ||
65 | + | ||
66 | +int main() | ||
734 | +{ | 67 | +{ |
735 | + ARMCPU *cpu = ARM_CPU(obj); | 68 | + int fail = 0; |
69 | + int skipped; | ||
736 | + | 70 | + |
737 | + cpu->dtb_compatible = "arm,arm926"; | 71 | + /* Signal-like with SA_SIGINFO. */ |
738 | + set_feature(&cpu->env, ARM_FEATURE_V5); | 72 | + signal_info(SIGILL, skip2_sigill); |
739 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
740 | + set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); | ||
741 | + cpu->midr = 0x41069265; | ||
742 | + cpu->reset_fpsid = 0x41011090; | ||
743 | + cpu->ctr = 0x1dd20d2; | ||
744 | + cpu->reset_sctlr = 0x00090078; | ||
745 | + | 73 | + |
746 | + /* | 74 | + /* With SCTLR_EL1.BT0 set, PACIASP is not compatible with type=3. */ |
747 | + * ARMv5 does not have the ID_ISAR registers, but we can still | 75 | + TEST(BTYPE_1, 0); |
748 | + * set the field to indicate Jazelle support within QEMU. | 76 | + TEST(BTYPE_2, 0); |
749 | + */ | 77 | + TEST(BTYPE_3, 1); |
750 | + cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | 78 | + |
751 | + /* | 79 | + return fail; |
752 | + * Similarly, we need to set MVFR0 fields to enable vfp and short vector | ||
753 | + * support even though ARMv5 doesn't have this register. | ||
754 | + */ | ||
755 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
756 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); | ||
757 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); | ||
758 | +} | 80 | +} |
759 | + | 81 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
760 | +static void arm946_initfn(Object *obj) | ||
761 | +{ | ||
762 | + ARMCPU *cpu = ARM_CPU(obj); | ||
763 | + | ||
764 | + cpu->dtb_compatible = "arm,arm946"; | ||
765 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
766 | + set_feature(&cpu->env, ARM_FEATURE_PMSA); | ||
767 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
768 | + cpu->midr = 0x41059461; | ||
769 | + cpu->ctr = 0x0f004006; | ||
770 | + cpu->reset_sctlr = 0x00000078; | ||
771 | +} | ||
772 | + | ||
773 | +static void arm1026_initfn(Object *obj) | ||
774 | +{ | ||
775 | + ARMCPU *cpu = ARM_CPU(obj); | ||
776 | + | ||
777 | + cpu->dtb_compatible = "arm,arm1026"; | ||
778 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
779 | + set_feature(&cpu->env, ARM_FEATURE_AUXCR); | ||
780 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
781 | + set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); | ||
782 | + cpu->midr = 0x4106a262; | ||
783 | + cpu->reset_fpsid = 0x410110a0; | ||
784 | + cpu->ctr = 0x1dd20d2; | ||
785 | + cpu->reset_sctlr = 0x00090078; | ||
786 | + cpu->reset_auxcr = 1; | ||
787 | + | ||
788 | + /* | ||
789 | + * ARMv5 does not have the ID_ISAR registers, but we can still | ||
790 | + * set the field to indicate Jazelle support within QEMU. | ||
791 | + */ | ||
792 | + cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | ||
793 | + /* | ||
794 | + * Similarly, we need to set MVFR0 fields to enable vfp and short vector | ||
795 | + * support even though ARMv5 doesn't have this register. | ||
796 | + */ | ||
797 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
798 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); | ||
799 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); | ||
800 | + | ||
801 | + { | ||
802 | + /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */ | ||
803 | + ARMCPRegInfo ifar = { | ||
804 | + .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1, | ||
805 | + .access = PL1_RW, | ||
806 | + .fieldoffset = offsetof(CPUARMState, cp15.ifar_ns), | ||
807 | + .resetvalue = 0 | ||
808 | + }; | ||
809 | + define_one_arm_cp_reg(cpu, &ifar); | ||
810 | + } | ||
811 | +} | ||
812 | + | ||
813 | +static void arm1136_r2_initfn(Object *obj) | ||
814 | +{ | ||
815 | + ARMCPU *cpu = ARM_CPU(obj); | ||
816 | + /* | ||
817 | + * What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an | ||
818 | + * older core than plain "arm1136". In particular this does not | ||
819 | + * have the v6K features. | ||
820 | + * These ID register values are correct for 1136 but may be wrong | ||
821 | + * for 1136_r2 (in particular r0p2 does not actually implement most | ||
822 | + * of the ID registers). | ||
823 | + */ | ||
824 | + | ||
825 | + cpu->dtb_compatible = "arm,arm1136"; | ||
826 | + set_feature(&cpu->env, ARM_FEATURE_V6); | ||
827 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
828 | + set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); | ||
829 | + set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | ||
830 | + cpu->midr = 0x4107b362; | ||
831 | + cpu->reset_fpsid = 0x410120b4; | ||
832 | + cpu->isar.mvfr0 = 0x11111111; | ||
833 | + cpu->isar.mvfr1 = 0x00000000; | ||
834 | + cpu->ctr = 0x1dd20d2; | ||
835 | + cpu->reset_sctlr = 0x00050078; | ||
836 | + cpu->id_pfr0 = 0x111; | ||
837 | + cpu->id_pfr1 = 0x1; | ||
838 | + cpu->isar.id_dfr0 = 0x2; | ||
839 | + cpu->id_afr0 = 0x3; | ||
840 | + cpu->isar.id_mmfr0 = 0x01130003; | ||
841 | + cpu->isar.id_mmfr1 = 0x10030302; | ||
842 | + cpu->isar.id_mmfr2 = 0x01222110; | ||
843 | + cpu->isar.id_isar0 = 0x00140011; | ||
844 | + cpu->isar.id_isar1 = 0x12002111; | ||
845 | + cpu->isar.id_isar2 = 0x11231111; | ||
846 | + cpu->isar.id_isar3 = 0x01102131; | ||
847 | + cpu->isar.id_isar4 = 0x141; | ||
848 | + cpu->reset_auxcr = 7; | ||
849 | +} | ||
850 | + | ||
851 | +static void arm1136_initfn(Object *obj) | ||
852 | +{ | ||
853 | + ARMCPU *cpu = ARM_CPU(obj); | ||
854 | + | ||
855 | + cpu->dtb_compatible = "arm,arm1136"; | ||
856 | + set_feature(&cpu->env, ARM_FEATURE_V6K); | ||
857 | + set_feature(&cpu->env, ARM_FEATURE_V6); | ||
858 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
859 | + set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); | ||
860 | + set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | ||
861 | + cpu->midr = 0x4117b363; | ||
862 | + cpu->reset_fpsid = 0x410120b4; | ||
863 | + cpu->isar.mvfr0 = 0x11111111; | ||
864 | + cpu->isar.mvfr1 = 0x00000000; | ||
865 | + cpu->ctr = 0x1dd20d2; | ||
866 | + cpu->reset_sctlr = 0x00050078; | ||
867 | + cpu->id_pfr0 = 0x111; | ||
868 | + cpu->id_pfr1 = 0x1; | ||
869 | + cpu->isar.id_dfr0 = 0x2; | ||
870 | + cpu->id_afr0 = 0x3; | ||
871 | + cpu->isar.id_mmfr0 = 0x01130003; | ||
872 | + cpu->isar.id_mmfr1 = 0x10030302; | ||
873 | + cpu->isar.id_mmfr2 = 0x01222110; | ||
874 | + cpu->isar.id_isar0 = 0x00140011; | ||
875 | + cpu->isar.id_isar1 = 0x12002111; | ||
876 | + cpu->isar.id_isar2 = 0x11231111; | ||
877 | + cpu->isar.id_isar3 = 0x01102131; | ||
878 | + cpu->isar.id_isar4 = 0x141; | ||
879 | + cpu->reset_auxcr = 7; | ||
880 | +} | ||
881 | + | ||
882 | +static void arm1176_initfn(Object *obj) | ||
883 | +{ | ||
884 | + ARMCPU *cpu = ARM_CPU(obj); | ||
885 | + | ||
886 | + cpu->dtb_compatible = "arm,arm1176"; | ||
887 | + set_feature(&cpu->env, ARM_FEATURE_V6K); | ||
888 | + set_feature(&cpu->env, ARM_FEATURE_VAPA); | ||
889 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
890 | + set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); | ||
891 | + set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | ||
892 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
893 | + cpu->midr = 0x410fb767; | ||
894 | + cpu->reset_fpsid = 0x410120b5; | ||
895 | + cpu->isar.mvfr0 = 0x11111111; | ||
896 | + cpu->isar.mvfr1 = 0x00000000; | ||
897 | + cpu->ctr = 0x1dd20d2; | ||
898 | + cpu->reset_sctlr = 0x00050078; | ||
899 | + cpu->id_pfr0 = 0x111; | ||
900 | + cpu->id_pfr1 = 0x11; | ||
901 | + cpu->isar.id_dfr0 = 0x33; | ||
902 | + cpu->id_afr0 = 0; | ||
903 | + cpu->isar.id_mmfr0 = 0x01130003; | ||
904 | + cpu->isar.id_mmfr1 = 0x10030302; | ||
905 | + cpu->isar.id_mmfr2 = 0x01222100; | ||
906 | + cpu->isar.id_isar0 = 0x0140011; | ||
907 | + cpu->isar.id_isar1 = 0x12002111; | ||
908 | + cpu->isar.id_isar2 = 0x11231121; | ||
909 | + cpu->isar.id_isar3 = 0x01102131; | ||
910 | + cpu->isar.id_isar4 = 0x01141; | ||
911 | + cpu->reset_auxcr = 7; | ||
912 | +} | ||
913 | + | ||
914 | +static void arm11mpcore_initfn(Object *obj) | ||
915 | +{ | ||
916 | + ARMCPU *cpu = ARM_CPU(obj); | ||
917 | + | ||
918 | + cpu->dtb_compatible = "arm,arm11mpcore"; | ||
919 | + set_feature(&cpu->env, ARM_FEATURE_V6K); | ||
920 | + set_feature(&cpu->env, ARM_FEATURE_VAPA); | ||
921 | + set_feature(&cpu->env, ARM_FEATURE_MPIDR); | ||
922 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
923 | + cpu->midr = 0x410fb022; | ||
924 | + cpu->reset_fpsid = 0x410120b4; | ||
925 | + cpu->isar.mvfr0 = 0x11111111; | ||
926 | + cpu->isar.mvfr1 = 0x00000000; | ||
927 | + cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */ | ||
928 | + cpu->id_pfr0 = 0x111; | ||
929 | + cpu->id_pfr1 = 0x1; | ||
930 | + cpu->isar.id_dfr0 = 0; | ||
931 | + cpu->id_afr0 = 0x2; | ||
932 | + cpu->isar.id_mmfr0 = 0x01100103; | ||
933 | + cpu->isar.id_mmfr1 = 0x10020302; | ||
934 | + cpu->isar.id_mmfr2 = 0x01222000; | ||
935 | + cpu->isar.id_isar0 = 0x00100011; | ||
936 | + cpu->isar.id_isar1 = 0x12002111; | ||
937 | + cpu->isar.id_isar2 = 0x11221011; | ||
938 | + cpu->isar.id_isar3 = 0x01102131; | ||
939 | + cpu->isar.id_isar4 = 0x141; | ||
940 | + cpu->reset_auxcr = 1; | ||
941 | +} | ||
942 | + | ||
943 | +static void cortex_m0_initfn(Object *obj) | ||
944 | +{ | ||
945 | + ARMCPU *cpu = ARM_CPU(obj); | ||
946 | + set_feature(&cpu->env, ARM_FEATURE_V6); | ||
947 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
948 | + | ||
949 | + cpu->midr = 0x410cc200; | ||
950 | +} | ||
951 | + | ||
952 | +static void cortex_m3_initfn(Object *obj) | ||
953 | +{ | ||
954 | + ARMCPU *cpu = ARM_CPU(obj); | ||
955 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
956 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
957 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
958 | + cpu->midr = 0x410fc231; | ||
959 | + cpu->pmsav7_dregion = 8; | ||
960 | + cpu->id_pfr0 = 0x00000030; | ||
961 | + cpu->id_pfr1 = 0x00000200; | ||
962 | + cpu->isar.id_dfr0 = 0x00100000; | ||
963 | + cpu->id_afr0 = 0x00000000; | ||
964 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
965 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
966 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
967 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
968 | + cpu->isar.id_isar0 = 0x01141110; | ||
969 | + cpu->isar.id_isar1 = 0x02111000; | ||
970 | + cpu->isar.id_isar2 = 0x21112231; | ||
971 | + cpu->isar.id_isar3 = 0x01111110; | ||
972 | + cpu->isar.id_isar4 = 0x01310102; | ||
973 | + cpu->isar.id_isar5 = 0x00000000; | ||
974 | + cpu->isar.id_isar6 = 0x00000000; | ||
975 | +} | ||
976 | + | ||
977 | +static void cortex_m4_initfn(Object *obj) | ||
978 | +{ | ||
979 | + ARMCPU *cpu = ARM_CPU(obj); | ||
980 | + | ||
981 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
982 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
983 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
984 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
985 | + cpu->midr = 0x410fc240; /* r0p0 */ | ||
986 | + cpu->pmsav7_dregion = 8; | ||
987 | + cpu->isar.mvfr0 = 0x10110021; | ||
988 | + cpu->isar.mvfr1 = 0x11000011; | ||
989 | + cpu->isar.mvfr2 = 0x00000000; | ||
990 | + cpu->id_pfr0 = 0x00000030; | ||
991 | + cpu->id_pfr1 = 0x00000200; | ||
992 | + cpu->isar.id_dfr0 = 0x00100000; | ||
993 | + cpu->id_afr0 = 0x00000000; | ||
994 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
995 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
996 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
997 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
998 | + cpu->isar.id_isar0 = 0x01141110; | ||
999 | + cpu->isar.id_isar1 = 0x02111000; | ||
1000 | + cpu->isar.id_isar2 = 0x21112231; | ||
1001 | + cpu->isar.id_isar3 = 0x01111110; | ||
1002 | + cpu->isar.id_isar4 = 0x01310102; | ||
1003 | + cpu->isar.id_isar5 = 0x00000000; | ||
1004 | + cpu->isar.id_isar6 = 0x00000000; | ||
1005 | +} | ||
1006 | + | ||
1007 | +static void cortex_m7_initfn(Object *obj) | ||
1008 | +{ | ||
1009 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1010 | + | ||
1011 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
1012 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
1013 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
1014 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
1015 | + cpu->midr = 0x411fc272; /* r1p2 */ | ||
1016 | + cpu->pmsav7_dregion = 8; | ||
1017 | + cpu->isar.mvfr0 = 0x10110221; | ||
1018 | + cpu->isar.mvfr1 = 0x12000011; | ||
1019 | + cpu->isar.mvfr2 = 0x00000040; | ||
1020 | + cpu->id_pfr0 = 0x00000030; | ||
1021 | + cpu->id_pfr1 = 0x00000200; | ||
1022 | + cpu->isar.id_dfr0 = 0x00100000; | ||
1023 | + cpu->id_afr0 = 0x00000000; | ||
1024 | + cpu->isar.id_mmfr0 = 0x00100030; | ||
1025 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
1026 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
1027 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
1028 | + cpu->isar.id_isar0 = 0x01101110; | ||
1029 | + cpu->isar.id_isar1 = 0x02112000; | ||
1030 | + cpu->isar.id_isar2 = 0x20232231; | ||
1031 | + cpu->isar.id_isar3 = 0x01111131; | ||
1032 | + cpu->isar.id_isar4 = 0x01310132; | ||
1033 | + cpu->isar.id_isar5 = 0x00000000; | ||
1034 | + cpu->isar.id_isar6 = 0x00000000; | ||
1035 | +} | ||
1036 | + | ||
1037 | +static void cortex_m33_initfn(Object *obj) | ||
1038 | +{ | ||
1039 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1040 | + | ||
1041 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
1042 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
1043 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
1044 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
1045 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
1046 | + cpu->midr = 0x410fd213; /* r0p3 */ | ||
1047 | + cpu->pmsav7_dregion = 16; | ||
1048 | + cpu->sau_sregion = 8; | ||
1049 | + cpu->isar.mvfr0 = 0x10110021; | ||
1050 | + cpu->isar.mvfr1 = 0x11000011; | ||
1051 | + cpu->isar.mvfr2 = 0x00000040; | ||
1052 | + cpu->id_pfr0 = 0x00000030; | ||
1053 | + cpu->id_pfr1 = 0x00000210; | ||
1054 | + cpu->isar.id_dfr0 = 0x00200000; | ||
1055 | + cpu->id_afr0 = 0x00000000; | ||
1056 | + cpu->isar.id_mmfr0 = 0x00101F40; | ||
1057 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
1058 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
1059 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
1060 | + cpu->isar.id_isar0 = 0x01101110; | ||
1061 | + cpu->isar.id_isar1 = 0x02212000; | ||
1062 | + cpu->isar.id_isar2 = 0x20232232; | ||
1063 | + cpu->isar.id_isar3 = 0x01111131; | ||
1064 | + cpu->isar.id_isar4 = 0x01310132; | ||
1065 | + cpu->isar.id_isar5 = 0x00000000; | ||
1066 | + cpu->isar.id_isar6 = 0x00000000; | ||
1067 | + cpu->clidr = 0x00000000; | ||
1068 | + cpu->ctr = 0x8000c000; | ||
1069 | +} | ||
1070 | + | ||
1071 | +static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
1072 | + /* Dummy the TCM region regs for the moment */ | ||
1073 | + { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | ||
1074 | + .access = PL1_RW, .type = ARM_CP_CONST }, | ||
1075 | + { .name = "BTCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1, | ||
1076 | + .access = PL1_RW, .type = ARM_CP_CONST }, | ||
1077 | + { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5, | ||
1078 | + .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP }, | ||
1079 | + REGINFO_SENTINEL | ||
1080 | +}; | ||
1081 | + | ||
1082 | +static void cortex_r5_initfn(Object *obj) | ||
1083 | +{ | ||
1084 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1085 | + | ||
1086 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
1087 | + set_feature(&cpu->env, ARM_FEATURE_V7MP); | ||
1088 | + set_feature(&cpu->env, ARM_FEATURE_PMSA); | ||
1089 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
1090 | + cpu->midr = 0x411fc153; /* r1p3 */ | ||
1091 | + cpu->id_pfr0 = 0x0131; | ||
1092 | + cpu->id_pfr1 = 0x001; | ||
1093 | + cpu->isar.id_dfr0 = 0x010400; | ||
1094 | + cpu->id_afr0 = 0x0; | ||
1095 | + cpu->isar.id_mmfr0 = 0x0210030; | ||
1096 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
1097 | + cpu->isar.id_mmfr2 = 0x01200000; | ||
1098 | + cpu->isar.id_mmfr3 = 0x0211; | ||
1099 | + cpu->isar.id_isar0 = 0x02101111; | ||
1100 | + cpu->isar.id_isar1 = 0x13112111; | ||
1101 | + cpu->isar.id_isar2 = 0x21232141; | ||
1102 | + cpu->isar.id_isar3 = 0x01112131; | ||
1103 | + cpu->isar.id_isar4 = 0x0010142; | ||
1104 | + cpu->isar.id_isar5 = 0x0; | ||
1105 | + cpu->isar.id_isar6 = 0x0; | ||
1106 | + cpu->mp_is_up = true; | ||
1107 | + cpu->pmsav7_dregion = 16; | ||
1108 | + define_arm_cp_regs(cpu, cortexr5_cp_reginfo); | ||
1109 | +} | ||
1110 | + | ||
1111 | +static void cortex_r5f_initfn(Object *obj) | ||
1112 | +{ | ||
1113 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1114 | + | ||
1115 | + cortex_r5_initfn(obj); | ||
1116 | + cpu->isar.mvfr0 = 0x10110221; | ||
1117 | + cpu->isar.mvfr1 = 0x00000011; | ||
1118 | +} | ||
1119 | + | ||
1120 | +static void ti925t_initfn(Object *obj) | ||
1121 | +{ | ||
1122 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1123 | + set_feature(&cpu->env, ARM_FEATURE_V4T); | ||
1124 | + set_feature(&cpu->env, ARM_FEATURE_OMAPCP); | ||
1125 | + cpu->midr = ARM_CPUID_TI925T; | ||
1126 | + cpu->ctr = 0x5109149; | ||
1127 | + cpu->reset_sctlr = 0x00000070; | ||
1128 | +} | ||
1129 | + | ||
1130 | +static void sa1100_initfn(Object *obj) | ||
1131 | +{ | ||
1132 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1133 | + | ||
1134 | + cpu->dtb_compatible = "intel,sa1100"; | ||
1135 | + set_feature(&cpu->env, ARM_FEATURE_STRONGARM); | ||
1136 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
1137 | + cpu->midr = 0x4401A11B; | ||
1138 | + cpu->reset_sctlr = 0x00000070; | ||
1139 | +} | ||
1140 | + | ||
1141 | +static void sa1110_initfn(Object *obj) | ||
1142 | +{ | ||
1143 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1144 | + set_feature(&cpu->env, ARM_FEATURE_STRONGARM); | ||
1145 | + set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
1146 | + cpu->midr = 0x6901B119; | ||
1147 | + cpu->reset_sctlr = 0x00000070; | ||
1148 | +} | ||
1149 | + | ||
1150 | +static void pxa250_initfn(Object *obj) | ||
1151 | +{ | ||
1152 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1153 | + | ||
1154 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1155 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1156 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1157 | + cpu->midr = 0x69052100; | ||
1158 | + cpu->ctr = 0xd172172; | ||
1159 | + cpu->reset_sctlr = 0x00000078; | ||
1160 | +} | ||
1161 | + | ||
1162 | +static void pxa255_initfn(Object *obj) | ||
1163 | +{ | ||
1164 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1165 | + | ||
1166 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1167 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1168 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1169 | + cpu->midr = 0x69052d00; | ||
1170 | + cpu->ctr = 0xd172172; | ||
1171 | + cpu->reset_sctlr = 0x00000078; | ||
1172 | +} | ||
1173 | + | ||
1174 | +static void pxa260_initfn(Object *obj) | ||
1175 | +{ | ||
1176 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1177 | + | ||
1178 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1179 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1180 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1181 | + cpu->midr = 0x69052903; | ||
1182 | + cpu->ctr = 0xd172172; | ||
1183 | + cpu->reset_sctlr = 0x00000078; | ||
1184 | +} | ||
1185 | + | ||
1186 | +static void pxa261_initfn(Object *obj) | ||
1187 | +{ | ||
1188 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1189 | + | ||
1190 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1191 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1192 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1193 | + cpu->midr = 0x69052d05; | ||
1194 | + cpu->ctr = 0xd172172; | ||
1195 | + cpu->reset_sctlr = 0x00000078; | ||
1196 | +} | ||
1197 | + | ||
1198 | +static void pxa262_initfn(Object *obj) | ||
1199 | +{ | ||
1200 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1201 | + | ||
1202 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1203 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1204 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1205 | + cpu->midr = 0x69052d06; | ||
1206 | + cpu->ctr = 0xd172172; | ||
1207 | + cpu->reset_sctlr = 0x00000078; | ||
1208 | +} | ||
1209 | + | ||
1210 | +static void pxa270a0_initfn(Object *obj) | ||
1211 | +{ | ||
1212 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1213 | + | ||
1214 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1215 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1216 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1217 | + set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
1218 | + cpu->midr = 0x69054110; | ||
1219 | + cpu->ctr = 0xd172172; | ||
1220 | + cpu->reset_sctlr = 0x00000078; | ||
1221 | +} | ||
1222 | + | ||
1223 | +static void pxa270a1_initfn(Object *obj) | ||
1224 | +{ | ||
1225 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1226 | + | ||
1227 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1228 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1229 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1230 | + set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
1231 | + cpu->midr = 0x69054111; | ||
1232 | + cpu->ctr = 0xd172172; | ||
1233 | + cpu->reset_sctlr = 0x00000078; | ||
1234 | +} | ||
1235 | + | ||
1236 | +static void pxa270b0_initfn(Object *obj) | ||
1237 | +{ | ||
1238 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1239 | + | ||
1240 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1241 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1242 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1243 | + set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
1244 | + cpu->midr = 0x69054112; | ||
1245 | + cpu->ctr = 0xd172172; | ||
1246 | + cpu->reset_sctlr = 0x00000078; | ||
1247 | +} | ||
1248 | + | ||
1249 | +static void pxa270b1_initfn(Object *obj) | ||
1250 | +{ | ||
1251 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1252 | + | ||
1253 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1254 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1255 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1256 | + set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
1257 | + cpu->midr = 0x69054113; | ||
1258 | + cpu->ctr = 0xd172172; | ||
1259 | + cpu->reset_sctlr = 0x00000078; | ||
1260 | +} | ||
1261 | + | ||
1262 | +static void pxa270c0_initfn(Object *obj) | ||
1263 | +{ | ||
1264 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1265 | + | ||
1266 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1267 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1268 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1269 | + set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
1270 | + cpu->midr = 0x69054114; | ||
1271 | + cpu->ctr = 0xd172172; | ||
1272 | + cpu->reset_sctlr = 0x00000078; | ||
1273 | +} | ||
1274 | + | ||
1275 | +static void pxa270c5_initfn(Object *obj) | ||
1276 | +{ | ||
1277 | + ARMCPU *cpu = ARM_CPU(obj); | ||
1278 | + | ||
1279 | + cpu->dtb_compatible = "marvell,xscale"; | ||
1280 | + set_feature(&cpu->env, ARM_FEATURE_V5); | ||
1281 | + set_feature(&cpu->env, ARM_FEATURE_XSCALE); | ||
1282 | + set_feature(&cpu->env, ARM_FEATURE_IWMMXT); | ||
1283 | + cpu->midr = 0x69054117; | ||
1284 | + cpu->ctr = 0xd172172; | ||
1285 | + cpu->reset_sctlr = 0x00000078; | ||
1286 | +} | ||
1287 | + | ||
1288 | +static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
1289 | +{ | ||
1290 | + ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
1291 | + CPUClass *cc = CPU_CLASS(oc); | ||
1292 | + | ||
1293 | + acc->info = data; | ||
1294 | +#ifndef CONFIG_USER_ONLY | ||
1295 | + cc->do_interrupt = arm_v7m_cpu_do_interrupt; | ||
1296 | +#endif | ||
1297 | + | ||
1298 | + cc->cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt; | ||
1299 | +} | ||
1300 | + | ||
1301 | +static const ARMCPUInfo arm_tcg_cpus[] = { | ||
1302 | + { .name = "arm926", .initfn = arm926_initfn }, | ||
1303 | + { .name = "arm946", .initfn = arm946_initfn }, | ||
1304 | + { .name = "arm1026", .initfn = arm1026_initfn }, | ||
1305 | + /* | ||
1306 | + * What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an | ||
1307 | + * older core than plain "arm1136". In particular this does not | ||
1308 | + * have the v6K features. | ||
1309 | + */ | ||
1310 | + { .name = "arm1136-r2", .initfn = arm1136_r2_initfn }, | ||
1311 | + { .name = "arm1136", .initfn = arm1136_initfn }, | ||
1312 | + { .name = "arm1176", .initfn = arm1176_initfn }, | ||
1313 | + { .name = "arm11mpcore", .initfn = arm11mpcore_initfn }, | ||
1314 | + { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
1315 | + .class_init = arm_v7m_class_init }, | ||
1316 | + { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
1317 | + .class_init = arm_v7m_class_init }, | ||
1318 | + { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
1319 | + .class_init = arm_v7m_class_init }, | ||
1320 | + { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
1321 | + .class_init = arm_v7m_class_init }, | ||
1322 | + { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
1323 | + .class_init = arm_v7m_class_init }, | ||
1324 | + { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | ||
1325 | + { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, | ||
1326 | + { .name = "ti925t", .initfn = ti925t_initfn }, | ||
1327 | + { .name = "sa1100", .initfn = sa1100_initfn }, | ||
1328 | + { .name = "sa1110", .initfn = sa1110_initfn }, | ||
1329 | + { .name = "pxa250", .initfn = pxa250_initfn }, | ||
1330 | + { .name = "pxa255", .initfn = pxa255_initfn }, | ||
1331 | + { .name = "pxa260", .initfn = pxa260_initfn }, | ||
1332 | + { .name = "pxa261", .initfn = pxa261_initfn }, | ||
1333 | + { .name = "pxa262", .initfn = pxa262_initfn }, | ||
1334 | + /* "pxa270" is an alias for "pxa270-a0" */ | ||
1335 | + { .name = "pxa270", .initfn = pxa270a0_initfn }, | ||
1336 | + { .name = "pxa270-a0", .initfn = pxa270a0_initfn }, | ||
1337 | + { .name = "pxa270-a1", .initfn = pxa270a1_initfn }, | ||
1338 | + { .name = "pxa270-b0", .initfn = pxa270b0_initfn }, | ||
1339 | + { .name = "pxa270-b1", .initfn = pxa270b1_initfn }, | ||
1340 | + { .name = "pxa270-c0", .initfn = pxa270c0_initfn }, | ||
1341 | + { .name = "pxa270-c5", .initfn = pxa270c5_initfn }, | ||
1342 | +}; | ||
1343 | + | ||
1344 | +static void arm_tcg_cpu_register_types(void) | ||
1345 | +{ | ||
1346 | + size_t i; | ||
1347 | + | ||
1348 | + for (i = 0; i < ARRAY_SIZE(arm_tcg_cpus); ++i) { | ||
1349 | + arm_cpu_register(&arm_tcg_cpus[i]); | ||
1350 | + } | ||
1351 | +} | ||
1352 | + | ||
1353 | +type_init(arm_tcg_cpu_register_types) | ||
1354 | + | ||
1355 | +#endif /* !CONFIG_USER_ONLY || !TARGET_AARCH64 */ | ||
1356 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | ||
1357 | index XXXXXXX..XXXXXXX 100644 | 82 | index XXXXXXX..XXXXXXX 100644 |
1358 | --- a/target/arm/Makefile.objs | 83 | --- a/tests/tcg/aarch64/Makefile.target |
1359 | +++ b/target/arm/Makefile.objs | 84 | +++ b/tests/tcg/aarch64/Makefile.target |
1360 | @@ -XXX,XX +XXX,XX @@ obj-y += translate.o op_helper.o | 85 | @@ -XXX,XX +XXX,XX @@ endif |
1361 | obj-y += crypto_helper.o | 86 | # BTI Tests |
1362 | obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | 87 | # bti-1 tests the elf notes, so we require special compiler support. |
1363 | obj-y += m_helper.o | 88 | ifneq ($(CROSS_CC_HAS_ARMV8_BTI),) |
1364 | +obj-y += cpu_tcg.o | 89 | -AARCH64_TESTS += bti-1 |
1365 | 90 | -bti-1: CFLAGS += -mbranch-protection=standard | |
1366 | obj-$(CONFIG_SOFTMMU) += psci.o | 91 | -bti-1: LDFLAGS += -nostdlib |
1367 | 92 | +AARCH64_TESTS += bti-1 bti-3 | |
93 | +bti-1 bti-3: CFLAGS += -mbranch-protection=standard | ||
94 | +bti-1 bti-3: LDFLAGS += -nostdlib | ||
95 | endif | ||
96 | # bti-2 tests PROT_BTI, so no special compiler support required. | ||
97 | AARCH64_TESTS += bti-2 | ||
1368 | -- | 98 | -- |
1369 | 2.20.1 | 99 | 2.25.1 |
1370 | |||
1371 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Move the common set_feature() and unset_feature() functions | 3 | Move ARMCPRegInfo and all related declarations to a new |
4 | from cpu.c and cpu64.c to cpu.h. | 4 | internal header, out of the public cpu.h. |
5 | 5 | ||
6 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 9 | Message-id: 20220501055028.646596-2-richard.henderson@linaro.org |
10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20200504172448.9402-3-philmd@redhat.com | ||
12 | Message-ID: <20190921150420.30743-2-thuth@redhat.com> | ||
13 | [PMD: Split Thomas's patch in two: set_feature, cpu_register] | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 11 | --- |
17 | target/arm/cpu.h | 10 ++++++++++ | 12 | target/arm/cpregs.h | 413 +++++++++++++++++++++++++++++++++++++ |
18 | target/arm/cpu.c | 10 ---------- | 13 | target/arm/cpu.h | 368 --------------------------------- |
19 | target/arm/cpu64.c | 10 ---------- | 14 | hw/arm/pxa2xx.c | 1 + |
20 | 3 files changed, 10 insertions(+), 20 deletions(-) | 15 | hw/arm/pxa2xx_pic.c | 1 + |
16 | hw/intc/arm_gicv3_cpuif.c | 1 + | ||
17 | hw/intc/arm_gicv3_kvm.c | 2 + | ||
18 | target/arm/cpu.c | 1 + | ||
19 | target/arm/cpu64.c | 1 + | ||
20 | target/arm/cpu_tcg.c | 1 + | ||
21 | target/arm/gdbstub.c | 3 +- | ||
22 | target/arm/helper.c | 1 + | ||
23 | target/arm/op_helper.c | 1 + | ||
24 | target/arm/translate-a64.c | 4 +- | ||
25 | target/arm/translate.c | 3 +- | ||
26 | 14 files changed, 427 insertions(+), 374 deletions(-) | ||
27 | create mode 100644 target/arm/cpregs.h | ||
21 | 28 | ||
29 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
30 | new file mode 100644 | ||
31 | index XXXXXXX..XXXXXXX | ||
32 | --- /dev/null | ||
33 | +++ b/target/arm/cpregs.h | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | +/* | ||
36 | + * QEMU ARM CP Register access and descriptions | ||
37 | + * | ||
38 | + * Copyright (c) 2022 Linaro Ltd | ||
39 | + * | ||
40 | + * This program is free software; you can redistribute it and/or | ||
41 | + * modify it under the terms of the GNU General Public License | ||
42 | + * as published by the Free Software Foundation; either version 2 | ||
43 | + * of the License, or (at your option) any later version. | ||
44 | + * | ||
45 | + * This program is distributed in the hope that it will be useful, | ||
46 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
47 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
48 | + * GNU General Public License for more details. | ||
49 | + * | ||
50 | + * You should have received a copy of the GNU General Public License | ||
51 | + * along with this program; if not, see | ||
52 | + * <http://www.gnu.org/licenses/gpl-2.0.html> | ||
53 | + */ | ||
54 | + | ||
55 | +#ifndef TARGET_ARM_CPREGS_H | ||
56 | +#define TARGET_ARM_CPREGS_H | ||
57 | + | ||
58 | +/* | ||
59 | + * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | ||
60 | + * special-behaviour cp reg and bits [11..8] indicate what behaviour | ||
61 | + * it has. Otherwise it is a simple cp reg, where CONST indicates that | ||
62 | + * TCG can assume the value to be constant (ie load at translate time) | ||
63 | + * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | ||
64 | + * indicates that the TB should not be ended after a write to this register | ||
65 | + * (the default is that the TB ends after cp writes). OVERRIDE permits | ||
66 | + * a register definition to override a previous definition for the | ||
67 | + * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the | ||
68 | + * old must have the OVERRIDE bit set. | ||
69 | + * ALIAS indicates that this register is an alias view of some underlying | ||
70 | + * state which is also visible via another register, and that the other | ||
71 | + * register is handling migration and reset; registers marked ALIAS will not be | ||
72 | + * migrated but may have their state set by syncing of register state from KVM. | ||
73 | + * NO_RAW indicates that this register has no underlying state and does not | ||
74 | + * support raw access for state saving/loading; it will not be used for either | ||
75 | + * migration or KVM state synchronization. (Typically this is for "registers" | ||
76 | + * which are actually used as instructions for cache maintenance and so on.) | ||
77 | + * IO indicates that this register does I/O and therefore its accesses | ||
78 | + * need to be marked with gen_io_start() and also end the TB. In particular, | ||
79 | + * registers which implement clocks or timers require this. | ||
80 | + * RAISES_EXC is for when the read or write hook might raise an exception; | ||
81 | + * the generated code will synchronize the CPU state before calling the hook | ||
82 | + * so that it is safe for the hook to call raise_exception(). | ||
83 | + * NEWEL is for writes to registers that might change the exception | ||
84 | + * level - typically on older ARM chips. For those cases we need to | ||
85 | + * re-read the new el when recomputing the translation flags. | ||
86 | + */ | ||
87 | +#define ARM_CP_SPECIAL 0x0001 | ||
88 | +#define ARM_CP_CONST 0x0002 | ||
89 | +#define ARM_CP_64BIT 0x0004 | ||
90 | +#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
91 | +#define ARM_CP_OVERRIDE 0x0010 | ||
92 | +#define ARM_CP_ALIAS 0x0020 | ||
93 | +#define ARM_CP_IO 0x0040 | ||
94 | +#define ARM_CP_NO_RAW 0x0080 | ||
95 | +#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
96 | +#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
97 | +#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
98 | +#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
99 | +#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
100 | +#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
101 | +#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
102 | +#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
103 | +#define ARM_CP_FPU 0x1000 | ||
104 | +#define ARM_CP_SVE 0x2000 | ||
105 | +#define ARM_CP_NO_GDB 0x4000 | ||
106 | +#define ARM_CP_RAISES_EXC 0x8000 | ||
107 | +#define ARM_CP_NEWEL 0x10000 | ||
108 | +/* Used only as a terminator for ARMCPRegInfo lists */ | ||
109 | +#define ARM_CP_SENTINEL 0xfffff | ||
110 | +/* Mask of only the flag bits in a type field */ | ||
111 | +#define ARM_CP_FLAG_MASK 0x1f0ff | ||
112 | + | ||
113 | +/* | ||
114 | + * Valid values for ARMCPRegInfo state field, indicating which of | ||
115 | + * the AArch32 and AArch64 execution states this register is visible in. | ||
116 | + * If the reginfo doesn't explicitly specify then it is AArch32 only. | ||
117 | + * If the reginfo is declared to be visible in both states then a second | ||
118 | + * reginfo is synthesised for the AArch32 view of the AArch64 register, | ||
119 | + * such that the AArch32 view is the lower 32 bits of the AArch64 one. | ||
120 | + * Note that we rely on the values of these enums as we iterate through | ||
121 | + * the various states in some places. | ||
122 | + */ | ||
123 | +enum { | ||
124 | + ARM_CP_STATE_AA32 = 0, | ||
125 | + ARM_CP_STATE_AA64 = 1, | ||
126 | + ARM_CP_STATE_BOTH = 2, | ||
127 | +}; | ||
128 | + | ||
129 | +/* | ||
130 | + * ARM CP register secure state flags. These flags identify security state | ||
131 | + * attributes for a given CP register entry. | ||
132 | + * The existence of both or neither secure and non-secure flags indicates that | ||
133 | + * the register has both a secure and non-secure hash entry. A single one of | ||
134 | + * these flags causes the register to only be hashed for the specified | ||
135 | + * security state. | ||
136 | + * Although definitions may have any combination of the S/NS bits, each | ||
137 | + * registered entry will only have one to identify whether the entry is secure | ||
138 | + * or non-secure. | ||
139 | + */ | ||
140 | +enum { | ||
141 | + ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | ||
142 | + ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
143 | +}; | ||
144 | + | ||
145 | +/* | ||
146 | + * Return true if cptype is a valid type field. This is used to try to | ||
147 | + * catch errors where the sentinel has been accidentally left off the end | ||
148 | + * of a list of registers. | ||
149 | + */ | ||
150 | +static inline bool cptype_valid(int cptype) | ||
151 | +{ | ||
152 | + return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
153 | + || ((cptype & ARM_CP_SPECIAL) && | ||
154 | + ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
155 | +} | ||
156 | + | ||
157 | +/* | ||
158 | + * Access rights: | ||
159 | + * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
160 | + * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and | ||
161 | + * PL2 (hyp). The other level which has Read and Write bits is Secure PL1 | ||
162 | + * (ie any of the privileged modes in Secure state, or Monitor mode). | ||
163 | + * If a register is accessible in one privilege level it's always accessible | ||
164 | + * in higher privilege levels too. Since "Secure PL1" also follows this rule | ||
165 | + * (ie anything visible in PL2 is visible in S-PL1, some things are only | ||
166 | + * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the | ||
167 | + * terminology a little and call this PL3. | ||
168 | + * In AArch64 things are somewhat simpler as the PLx bits line up exactly | ||
169 | + * with the ELx exception levels. | ||
170 | + * | ||
171 | + * If access permissions for a register are more complex than can be | ||
172 | + * described with these bits, then use a laxer set of restrictions, and | ||
173 | + * do the more restrictive/complex check inside a helper function. | ||
174 | + */ | ||
175 | +#define PL3_R 0x80 | ||
176 | +#define PL3_W 0x40 | ||
177 | +#define PL2_R (0x20 | PL3_R) | ||
178 | +#define PL2_W (0x10 | PL3_W) | ||
179 | +#define PL1_R (0x08 | PL2_R) | ||
180 | +#define PL1_W (0x04 | PL2_W) | ||
181 | +#define PL0_R (0x02 | PL1_R) | ||
182 | +#define PL0_W (0x01 | PL1_W) | ||
183 | + | ||
184 | +/* | ||
185 | + * For user-mode some registers are accessible to EL0 via a kernel | ||
186 | + * trap-and-emulate ABI. In this case we define the read permissions | ||
187 | + * as actually being PL0_R. However some bits of any given register | ||
188 | + * may still be masked. | ||
189 | + */ | ||
190 | +#ifdef CONFIG_USER_ONLY | ||
191 | +#define PL0U_R PL0_R | ||
192 | +#else | ||
193 | +#define PL0U_R PL1_R | ||
194 | +#endif | ||
195 | + | ||
196 | +#define PL3_RW (PL3_R | PL3_W) | ||
197 | +#define PL2_RW (PL2_R | PL2_W) | ||
198 | +#define PL1_RW (PL1_R | PL1_W) | ||
199 | +#define PL0_RW (PL0_R | PL0_W) | ||
200 | + | ||
201 | +typedef enum CPAccessResult { | ||
202 | + /* Access is permitted */ | ||
203 | + CP_ACCESS_OK = 0, | ||
204 | + /* | ||
205 | + * Access fails due to a configurable trap or enable which would | ||
206 | + * result in a categorized exception syndrome giving information about | ||
207 | + * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
208 | + * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
209 | + * PL1 if in EL0, otherwise to the current EL). | ||
210 | + */ | ||
211 | + CP_ACCESS_TRAP = 1, | ||
212 | + /* | ||
213 | + * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
214 | + * Note that this is not a catch-all case -- the set of cases which may | ||
215 | + * result in this failure is specifically defined by the architecture. | ||
216 | + */ | ||
217 | + CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
218 | + /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
219 | + CP_ACCESS_TRAP_EL2 = 3, | ||
220 | + CP_ACCESS_TRAP_EL3 = 4, | ||
221 | + /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
222 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
223 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
224 | +} CPAccessResult; | ||
225 | + | ||
226 | +typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
227 | + | ||
228 | +/* | ||
229 | + * Access functions for coprocessor registers. These cannot fail and | ||
230 | + * may not raise exceptions. | ||
231 | + */ | ||
232 | +typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
233 | +typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
234 | + uint64_t value); | ||
235 | +/* Access permission check functions for coprocessor registers. */ | ||
236 | +typedef CPAccessResult CPAccessFn(CPUARMState *env, | ||
237 | + const ARMCPRegInfo *opaque, | ||
238 | + bool isread); | ||
239 | +/* Hook function for register reset */ | ||
240 | +typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
241 | + | ||
242 | +#define CP_ANY 0xff | ||
243 | + | ||
244 | +/* Definition of an ARM coprocessor register */ | ||
245 | +struct ARMCPRegInfo { | ||
246 | + /* Name of register (useful mainly for debugging, need not be unique) */ | ||
247 | + const char *name; | ||
248 | + /* | ||
249 | + * Location of register: coprocessor number and (crn,crm,opc1,opc2) | ||
250 | + * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a | ||
251 | + * 'wildcard' field -- any value of that field in the MRC/MCR insn | ||
252 | + * will be decoded to this register. The register read and write | ||
253 | + * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 | ||
254 | + * used by the program, so it is possible to register a wildcard and | ||
255 | + * then behave differently on read/write if necessary. | ||
256 | + * For 64 bit registers, only crm and opc1 are relevant; crn and opc2 | ||
257 | + * must both be zero. | ||
258 | + * For AArch64-visible registers, opc0 is also used. | ||
259 | + * Since there are no "coprocessors" in AArch64, cp is purely used as a | ||
260 | + * way to distinguish (for KVM's benefit) guest-visible system registers | ||
261 | + * from demuxed ones provided to preserve the "no side effects on | ||
262 | + * KVM register read/write from QEMU" semantics. cp==0x13 is guest | ||
263 | + * visible (to match KVM's encoding); cp==0 will be converted to | ||
264 | + * cp==0x13 when the ARMCPRegInfo is registered, for convenience. | ||
265 | + */ | ||
266 | + uint8_t cp; | ||
267 | + uint8_t crn; | ||
268 | + uint8_t crm; | ||
269 | + uint8_t opc0; | ||
270 | + uint8_t opc1; | ||
271 | + uint8_t opc2; | ||
272 | + /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
273 | + int state; | ||
274 | + /* Register type: ARM_CP_* bits/values */ | ||
275 | + int type; | ||
276 | + /* Access rights: PL*_[RW] */ | ||
277 | + int access; | ||
278 | + /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
279 | + int secure; | ||
280 | + /* | ||
281 | + * The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
282 | + * this register was defined: can be used to hand data through to the | ||
283 | + * register read/write functions, since they are passed the ARMCPRegInfo*. | ||
284 | + */ | ||
285 | + void *opaque; | ||
286 | + /* | ||
287 | + * Value of this register, if it is ARM_CP_CONST. Otherwise, if | ||
288 | + * fieldoffset is non-zero, the reset value of the register. | ||
289 | + */ | ||
290 | + uint64_t resetvalue; | ||
291 | + /* | ||
292 | + * Offset of the field in CPUARMState for this register. | ||
293 | + * This is not needed if either: | ||
294 | + * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs | ||
295 | + * 2. both readfn and writefn are specified | ||
296 | + */ | ||
297 | + ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ | ||
298 | + | ||
299 | + /* | ||
300 | + * Offsets of the secure and non-secure fields in CPUARMState for the | ||
301 | + * register if it is banked. These fields are only used during the static | ||
302 | + * registration of a register. During hashing the bank associated | ||
303 | + * with a given security state is copied to fieldoffset which is used from | ||
304 | + * there on out. | ||
305 | + * | ||
306 | + * It is expected that register definitions use either fieldoffset or | ||
307 | + * bank_fieldoffsets in the definition but not both. It is also expected | ||
308 | + * that both bank offsets are set when defining a banked register. This | ||
309 | + * use indicates that a register is banked. | ||
310 | + */ | ||
311 | + ptrdiff_t bank_fieldoffsets[2]; | ||
312 | + | ||
313 | + /* | ||
314 | + * Function for making any access checks for this register in addition to | ||
315 | + * those specified by the 'access' permissions bits. If NULL, no extra | ||
316 | + * checks required. The access check is performed at runtime, not at | ||
317 | + * translate time. | ||
318 | + */ | ||
319 | + CPAccessFn *accessfn; | ||
320 | + /* | ||
321 | + * Function for handling reads of this register. If NULL, then reads | ||
322 | + * will be done by loading from the offset into CPUARMState specified | ||
323 | + * by fieldoffset. | ||
324 | + */ | ||
325 | + CPReadFn *readfn; | ||
326 | + /* | ||
327 | + * Function for handling writes of this register. If NULL, then writes | ||
328 | + * will be done by writing to the offset into CPUARMState specified | ||
329 | + * by fieldoffset. | ||
330 | + */ | ||
331 | + CPWriteFn *writefn; | ||
332 | + /* | ||
333 | + * Function for doing a "raw" read; used when we need to copy | ||
334 | + * coprocessor state to the kernel for KVM or out for | ||
335 | + * migration. This only needs to be provided if there is also a | ||
336 | + * readfn and it has side effects (for instance clear-on-read bits). | ||
337 | + */ | ||
338 | + CPReadFn *raw_readfn; | ||
339 | + /* | ||
340 | + * Function for doing a "raw" write; used when we need to copy KVM | ||
341 | + * kernel coprocessor state into userspace, or for inbound | ||
342 | + * migration. This only needs to be provided if there is also a | ||
343 | + * writefn and it masks out "unwritable" bits or has write-one-to-clear | ||
344 | + * or similar behaviour. | ||
345 | + */ | ||
346 | + CPWriteFn *raw_writefn; | ||
347 | + /* | ||
348 | + * Function for resetting the register. If NULL, then reset will be done | ||
349 | + * by writing resetvalue to the field specified in fieldoffset. If | ||
350 | + * fieldoffset is 0 then no reset will be done. | ||
351 | + */ | ||
352 | + CPResetFn *resetfn; | ||
353 | + | ||
354 | + /* | ||
355 | + * "Original" writefn and readfn. | ||
356 | + * For ARMv8.1-VHE register aliases, we overwrite the read/write | ||
357 | + * accessor functions of various EL1/EL0 to perform the runtime | ||
358 | + * check for which sysreg should actually be modified, and then | ||
359 | + * forwards the operation. Before overwriting the accessors, | ||
360 | + * the original function is copied here, so that accesses that | ||
361 | + * really do go to the EL1/EL0 version proceed normally. | ||
362 | + * (The corresponding EL2 register is linked via opaque.) | ||
363 | + */ | ||
364 | + CPReadFn *orig_readfn; | ||
365 | + CPWriteFn *orig_writefn; | ||
366 | +}; | ||
367 | + | ||
368 | +/* | ||
369 | + * Macros which are lvalues for the field in CPUARMState for the | ||
370 | + * ARMCPRegInfo *ri. | ||
371 | + */ | ||
372 | +#define CPREG_FIELD32(env, ri) \ | ||
373 | + (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) | ||
374 | +#define CPREG_FIELD64(env, ri) \ | ||
375 | + (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
376 | + | ||
377 | +#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
378 | + | ||
379 | +void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
380 | + const ARMCPRegInfo *regs, void *opaque); | ||
381 | +void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
382 | + const ARMCPRegInfo *regs, void *opaque); | ||
383 | +static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
384 | +{ | ||
385 | + define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
386 | +} | ||
387 | +static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
388 | +{ | ||
389 | + define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
390 | +} | ||
391 | +const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
392 | + | ||
393 | +/* | ||
394 | + * Definition of an ARM co-processor register as viewed from | ||
395 | + * userspace. This is used for presenting sanitised versions of | ||
396 | + * registers to userspace when emulating the Linux AArch64 CPU | ||
397 | + * ID/feature ABI (advertised as HWCAP_CPUID). | ||
398 | + */ | ||
399 | +typedef struct ARMCPRegUserSpaceInfo { | ||
400 | + /* Name of register */ | ||
401 | + const char *name; | ||
402 | + | ||
403 | + /* Is the name actually a glob pattern */ | ||
404 | + bool is_glob; | ||
405 | + | ||
406 | + /* Only some bits are exported to user space */ | ||
407 | + uint64_t exported_bits; | ||
408 | + | ||
409 | + /* Fixed bits are applied after the mask */ | ||
410 | + uint64_t fixed_bits; | ||
411 | +} ARMCPRegUserSpaceInfo; | ||
412 | + | ||
413 | +#define REGUSERINFO_SENTINEL { .name = NULL } | ||
414 | + | ||
415 | +void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
416 | + | ||
417 | +/* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
418 | +void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
419 | + uint64_t value); | ||
420 | +/* CPReadFn that can be used for read-as-zero behaviour */ | ||
421 | +uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); | ||
422 | + | ||
423 | +/* | ||
424 | + * CPResetFn that does nothing, for use if no reset is required even | ||
425 | + * if fieldoffset is non zero. | ||
426 | + */ | ||
427 | +void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
428 | + | ||
429 | +/* | ||
430 | + * Return true if this reginfo struct's field in the cpu state struct | ||
431 | + * is 64 bits wide. | ||
432 | + */ | ||
433 | +static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) | ||
434 | +{ | ||
435 | + return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); | ||
436 | +} | ||
437 | + | ||
438 | +static inline bool cp_access_ok(int current_el, | ||
439 | + const ARMCPRegInfo *ri, int isread) | ||
440 | +{ | ||
441 | + return (ri->access >> ((current_el * 2) + isread)) & 1; | ||
442 | +} | ||
443 | + | ||
444 | +/* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
445 | +uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
446 | + | ||
447 | +#endif /* TARGET_ARM_CPREGS_H */ | ||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 448 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
23 | index XXXXXXX..XXXXXXX 100644 | 449 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/cpu.h | 450 | --- a/target/arm/cpu.h |
25 | +++ b/target/arm/cpu.h | 451 | +++ b/target/arm/cpu.h |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 452 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) |
27 | void *gicv3state; | 453 | return kvmid; |
28 | } CPUARMState; | 454 | } |
29 | 455 | ||
30 | +static inline void set_feature(CPUARMState *env, int feature) | 456 | -/* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a |
31 | +{ | 457 | - * special-behaviour cp reg and bits [11..8] indicate what behaviour |
32 | + env->features |= 1ULL << feature; | 458 | - * it has. Otherwise it is a simple cp reg, where CONST indicates that |
33 | +} | 459 | - * TCG can assume the value to be constant (ie load at translate time) |
34 | + | 460 | - * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END |
35 | +static inline void unset_feature(CPUARMState *env, int feature) | 461 | - * indicates that the TB should not be ended after a write to this register |
36 | +{ | 462 | - * (the default is that the TB ends after cp writes). OVERRIDE permits |
37 | + env->features &= ~(1ULL << feature); | 463 | - * a register definition to override a previous definition for the |
38 | +} | 464 | - * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the |
39 | + | 465 | - * old must have the OVERRIDE bit set. |
466 | - * ALIAS indicates that this register is an alias view of some underlying | ||
467 | - * state which is also visible via another register, and that the other | ||
468 | - * register is handling migration and reset; registers marked ALIAS will not be | ||
469 | - * migrated but may have their state set by syncing of register state from KVM. | ||
470 | - * NO_RAW indicates that this register has no underlying state and does not | ||
471 | - * support raw access for state saving/loading; it will not be used for either | ||
472 | - * migration or KVM state synchronization. (Typically this is for "registers" | ||
473 | - * which are actually used as instructions for cache maintenance and so on.) | ||
474 | - * IO indicates that this register does I/O and therefore its accesses | ||
475 | - * need to be marked with gen_io_start() and also end the TB. In particular, | ||
476 | - * registers which implement clocks or timers require this. | ||
477 | - * RAISES_EXC is for when the read or write hook might raise an exception; | ||
478 | - * the generated code will synchronize the CPU state before calling the hook | ||
479 | - * so that it is safe for the hook to call raise_exception(). | ||
480 | - * NEWEL is for writes to registers that might change the exception | ||
481 | - * level - typically on older ARM chips. For those cases we need to | ||
482 | - * re-read the new el when recomputing the translation flags. | ||
483 | - */ | ||
484 | -#define ARM_CP_SPECIAL 0x0001 | ||
485 | -#define ARM_CP_CONST 0x0002 | ||
486 | -#define ARM_CP_64BIT 0x0004 | ||
487 | -#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
488 | -#define ARM_CP_OVERRIDE 0x0010 | ||
489 | -#define ARM_CP_ALIAS 0x0020 | ||
490 | -#define ARM_CP_IO 0x0040 | ||
491 | -#define ARM_CP_NO_RAW 0x0080 | ||
492 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
493 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
494 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
495 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
496 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
497 | -#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
498 | -#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
499 | -#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
500 | -#define ARM_CP_FPU 0x1000 | ||
501 | -#define ARM_CP_SVE 0x2000 | ||
502 | -#define ARM_CP_NO_GDB 0x4000 | ||
503 | -#define ARM_CP_RAISES_EXC 0x8000 | ||
504 | -#define ARM_CP_NEWEL 0x10000 | ||
505 | -/* Used only as a terminator for ARMCPRegInfo lists */ | ||
506 | -#define ARM_CP_SENTINEL 0xfffff | ||
507 | -/* Mask of only the flag bits in a type field */ | ||
508 | -#define ARM_CP_FLAG_MASK 0x1f0ff | ||
509 | - | ||
510 | -/* Valid values for ARMCPRegInfo state field, indicating which of | ||
511 | - * the AArch32 and AArch64 execution states this register is visible in. | ||
512 | - * If the reginfo doesn't explicitly specify then it is AArch32 only. | ||
513 | - * If the reginfo is declared to be visible in both states then a second | ||
514 | - * reginfo is synthesised for the AArch32 view of the AArch64 register, | ||
515 | - * such that the AArch32 view is the lower 32 bits of the AArch64 one. | ||
516 | - * Note that we rely on the values of these enums as we iterate through | ||
517 | - * the various states in some places. | ||
518 | - */ | ||
519 | -enum { | ||
520 | - ARM_CP_STATE_AA32 = 0, | ||
521 | - ARM_CP_STATE_AA64 = 1, | ||
522 | - ARM_CP_STATE_BOTH = 2, | ||
523 | -}; | ||
524 | - | ||
525 | -/* ARM CP register secure state flags. These flags identify security state | ||
526 | - * attributes for a given CP register entry. | ||
527 | - * The existence of both or neither secure and non-secure flags indicates that | ||
528 | - * the register has both a secure and non-secure hash entry. A single one of | ||
529 | - * these flags causes the register to only be hashed for the specified | ||
530 | - * security state. | ||
531 | - * Although definitions may have any combination of the S/NS bits, each | ||
532 | - * registered entry will only have one to identify whether the entry is secure | ||
533 | - * or non-secure. | ||
534 | - */ | ||
535 | -enum { | ||
536 | - ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | ||
537 | - ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
538 | -}; | ||
539 | - | ||
540 | -/* Return true if cptype is a valid type field. This is used to try to | ||
541 | - * catch errors where the sentinel has been accidentally left off the end | ||
542 | - * of a list of registers. | ||
543 | - */ | ||
544 | -static inline bool cptype_valid(int cptype) | ||
545 | -{ | ||
546 | - return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
547 | - || ((cptype & ARM_CP_SPECIAL) && | ||
548 | - ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
549 | -} | ||
550 | - | ||
551 | -/* Access rights: | ||
552 | - * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
553 | - * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and | ||
554 | - * PL2 (hyp). The other level which has Read and Write bits is Secure PL1 | ||
555 | - * (ie any of the privileged modes in Secure state, or Monitor mode). | ||
556 | - * If a register is accessible in one privilege level it's always accessible | ||
557 | - * in higher privilege levels too. Since "Secure PL1" also follows this rule | ||
558 | - * (ie anything visible in PL2 is visible in S-PL1, some things are only | ||
559 | - * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the | ||
560 | - * terminology a little and call this PL3. | ||
561 | - * In AArch64 things are somewhat simpler as the PLx bits line up exactly | ||
562 | - * with the ELx exception levels. | ||
563 | - * | ||
564 | - * If access permissions for a register are more complex than can be | ||
565 | - * described with these bits, then use a laxer set of restrictions, and | ||
566 | - * do the more restrictive/complex check inside a helper function. | ||
567 | - */ | ||
568 | -#define PL3_R 0x80 | ||
569 | -#define PL3_W 0x40 | ||
570 | -#define PL2_R (0x20 | PL3_R) | ||
571 | -#define PL2_W (0x10 | PL3_W) | ||
572 | -#define PL1_R (0x08 | PL2_R) | ||
573 | -#define PL1_W (0x04 | PL2_W) | ||
574 | -#define PL0_R (0x02 | PL1_R) | ||
575 | -#define PL0_W (0x01 | PL1_W) | ||
576 | - | ||
577 | -/* | ||
578 | - * For user-mode some registers are accessible to EL0 via a kernel | ||
579 | - * trap-and-emulate ABI. In this case we define the read permissions | ||
580 | - * as actually being PL0_R. However some bits of any given register | ||
581 | - * may still be masked. | ||
582 | - */ | ||
583 | -#ifdef CONFIG_USER_ONLY | ||
584 | -#define PL0U_R PL0_R | ||
585 | -#else | ||
586 | -#define PL0U_R PL1_R | ||
587 | -#endif | ||
588 | - | ||
589 | -#define PL3_RW (PL3_R | PL3_W) | ||
590 | -#define PL2_RW (PL2_R | PL2_W) | ||
591 | -#define PL1_RW (PL1_R | PL1_W) | ||
592 | -#define PL0_RW (PL0_R | PL0_W) | ||
593 | - | ||
594 | /* Return the highest implemented Exception Level */ | ||
595 | static inline int arm_highest_el(CPUARMState *env) | ||
596 | { | ||
597 | @@ -XXX,XX +XXX,XX @@ static inline int arm_current_el(CPUARMState *env) | ||
598 | } | ||
599 | } | ||
600 | |||
601 | -typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
602 | - | ||
603 | -typedef enum CPAccessResult { | ||
604 | - /* Access is permitted */ | ||
605 | - CP_ACCESS_OK = 0, | ||
606 | - /* Access fails due to a configurable trap or enable which would | ||
607 | - * result in a categorized exception syndrome giving information about | ||
608 | - * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
609 | - * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
610 | - * PL1 if in EL0, otherwise to the current EL). | ||
611 | - */ | ||
612 | - CP_ACCESS_TRAP = 1, | ||
613 | - /* Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
614 | - * Note that this is not a catch-all case -- the set of cases which may | ||
615 | - * result in this failure is specifically defined by the architecture. | ||
616 | - */ | ||
617 | - CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
618 | - /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
619 | - CP_ACCESS_TRAP_EL2 = 3, | ||
620 | - CP_ACCESS_TRAP_EL3 = 4, | ||
621 | - /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
622 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
623 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
624 | -} CPAccessResult; | ||
625 | - | ||
626 | -/* Access functions for coprocessor registers. These cannot fail and | ||
627 | - * may not raise exceptions. | ||
628 | - */ | ||
629 | -typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
630 | -typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
631 | - uint64_t value); | ||
632 | -/* Access permission check functions for coprocessor registers. */ | ||
633 | -typedef CPAccessResult CPAccessFn(CPUARMState *env, | ||
634 | - const ARMCPRegInfo *opaque, | ||
635 | - bool isread); | ||
636 | -/* Hook function for register reset */ | ||
637 | -typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
638 | - | ||
639 | -#define CP_ANY 0xff | ||
640 | - | ||
641 | -/* Definition of an ARM coprocessor register */ | ||
642 | -struct ARMCPRegInfo { | ||
643 | - /* Name of register (useful mainly for debugging, need not be unique) */ | ||
644 | - const char *name; | ||
645 | - /* Location of register: coprocessor number and (crn,crm,opc1,opc2) | ||
646 | - * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a | ||
647 | - * 'wildcard' field -- any value of that field in the MRC/MCR insn | ||
648 | - * will be decoded to this register. The register read and write | ||
649 | - * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 | ||
650 | - * used by the program, so it is possible to register a wildcard and | ||
651 | - * then behave differently on read/write if necessary. | ||
652 | - * For 64 bit registers, only crm and opc1 are relevant; crn and opc2 | ||
653 | - * must both be zero. | ||
654 | - * For AArch64-visible registers, opc0 is also used. | ||
655 | - * Since there are no "coprocessors" in AArch64, cp is purely used as a | ||
656 | - * way to distinguish (for KVM's benefit) guest-visible system registers | ||
657 | - * from demuxed ones provided to preserve the "no side effects on | ||
658 | - * KVM register read/write from QEMU" semantics. cp==0x13 is guest | ||
659 | - * visible (to match KVM's encoding); cp==0 will be converted to | ||
660 | - * cp==0x13 when the ARMCPRegInfo is registered, for convenience. | ||
661 | - */ | ||
662 | - uint8_t cp; | ||
663 | - uint8_t crn; | ||
664 | - uint8_t crm; | ||
665 | - uint8_t opc0; | ||
666 | - uint8_t opc1; | ||
667 | - uint8_t opc2; | ||
668 | - /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
669 | - int state; | ||
670 | - /* Register type: ARM_CP_* bits/values */ | ||
671 | - int type; | ||
672 | - /* Access rights: PL*_[RW] */ | ||
673 | - int access; | ||
674 | - /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
675 | - int secure; | ||
676 | - /* The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
677 | - * this register was defined: can be used to hand data through to the | ||
678 | - * register read/write functions, since they are passed the ARMCPRegInfo*. | ||
679 | - */ | ||
680 | - void *opaque; | ||
681 | - /* Value of this register, if it is ARM_CP_CONST. Otherwise, if | ||
682 | - * fieldoffset is non-zero, the reset value of the register. | ||
683 | - */ | ||
684 | - uint64_t resetvalue; | ||
685 | - /* Offset of the field in CPUARMState for this register. | ||
686 | - * | ||
687 | - * This is not needed if either: | ||
688 | - * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs | ||
689 | - * 2. both readfn and writefn are specified | ||
690 | - */ | ||
691 | - ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ | ||
692 | - | ||
693 | - /* Offsets of the secure and non-secure fields in CPUARMState for the | ||
694 | - * register if it is banked. These fields are only used during the static | ||
695 | - * registration of a register. During hashing the bank associated | ||
696 | - * with a given security state is copied to fieldoffset which is used from | ||
697 | - * there on out. | ||
698 | - * | ||
699 | - * It is expected that register definitions use either fieldoffset or | ||
700 | - * bank_fieldoffsets in the definition but not both. It is also expected | ||
701 | - * that both bank offsets are set when defining a banked register. This | ||
702 | - * use indicates that a register is banked. | ||
703 | - */ | ||
704 | - ptrdiff_t bank_fieldoffsets[2]; | ||
705 | - | ||
706 | - /* Function for making any access checks for this register in addition to | ||
707 | - * those specified by the 'access' permissions bits. If NULL, no extra | ||
708 | - * checks required. The access check is performed at runtime, not at | ||
709 | - * translate time. | ||
710 | - */ | ||
711 | - CPAccessFn *accessfn; | ||
712 | - /* Function for handling reads of this register. If NULL, then reads | ||
713 | - * will be done by loading from the offset into CPUARMState specified | ||
714 | - * by fieldoffset. | ||
715 | - */ | ||
716 | - CPReadFn *readfn; | ||
717 | - /* Function for handling writes of this register. If NULL, then writes | ||
718 | - * will be done by writing to the offset into CPUARMState specified | ||
719 | - * by fieldoffset. | ||
720 | - */ | ||
721 | - CPWriteFn *writefn; | ||
722 | - /* Function for doing a "raw" read; used when we need to copy | ||
723 | - * coprocessor state to the kernel for KVM or out for | ||
724 | - * migration. This only needs to be provided if there is also a | ||
725 | - * readfn and it has side effects (for instance clear-on-read bits). | ||
726 | - */ | ||
727 | - CPReadFn *raw_readfn; | ||
728 | - /* Function for doing a "raw" write; used when we need to copy KVM | ||
729 | - * kernel coprocessor state into userspace, or for inbound | ||
730 | - * migration. This only needs to be provided if there is also a | ||
731 | - * writefn and it masks out "unwritable" bits or has write-one-to-clear | ||
732 | - * or similar behaviour. | ||
733 | - */ | ||
734 | - CPWriteFn *raw_writefn; | ||
735 | - /* Function for resetting the register. If NULL, then reset will be done | ||
736 | - * by writing resetvalue to the field specified in fieldoffset. If | ||
737 | - * fieldoffset is 0 then no reset will be done. | ||
738 | - */ | ||
739 | - CPResetFn *resetfn; | ||
740 | - | ||
741 | - /* | ||
742 | - * "Original" writefn and readfn. | ||
743 | - * For ARMv8.1-VHE register aliases, we overwrite the read/write | ||
744 | - * accessor functions of various EL1/EL0 to perform the runtime | ||
745 | - * check for which sysreg should actually be modified, and then | ||
746 | - * forwards the operation. Before overwriting the accessors, | ||
747 | - * the original function is copied here, so that accesses that | ||
748 | - * really do go to the EL1/EL0 version proceed normally. | ||
749 | - * (The corresponding EL2 register is linked via opaque.) | ||
750 | - */ | ||
751 | - CPReadFn *orig_readfn; | ||
752 | - CPWriteFn *orig_writefn; | ||
753 | -}; | ||
754 | - | ||
755 | -/* Macros which are lvalues for the field in CPUARMState for the | ||
756 | - * ARMCPRegInfo *ri. | ||
757 | - */ | ||
758 | -#define CPREG_FIELD32(env, ri) \ | ||
759 | - (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) | ||
760 | -#define CPREG_FIELD64(env, ri) \ | ||
761 | - (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
762 | - | ||
763 | -#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
764 | - | ||
765 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
766 | - const ARMCPRegInfo *regs, void *opaque); | ||
767 | -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
768 | - const ARMCPRegInfo *regs, void *opaque); | ||
769 | -static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
770 | -{ | ||
771 | - define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
772 | -} | ||
773 | -static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
774 | -{ | ||
775 | - define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
776 | -} | ||
777 | -const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
778 | - | ||
779 | -/* | ||
780 | - * Definition of an ARM co-processor register as viewed from | ||
781 | - * userspace. This is used for presenting sanitised versions of | ||
782 | - * registers to userspace when emulating the Linux AArch64 CPU | ||
783 | - * ID/feature ABI (advertised as HWCAP_CPUID). | ||
784 | - */ | ||
785 | -typedef struct ARMCPRegUserSpaceInfo { | ||
786 | - /* Name of register */ | ||
787 | - const char *name; | ||
788 | - | ||
789 | - /* Is the name actually a glob pattern */ | ||
790 | - bool is_glob; | ||
791 | - | ||
792 | - /* Only some bits are exported to user space */ | ||
793 | - uint64_t exported_bits; | ||
794 | - | ||
795 | - /* Fixed bits are applied after the mask */ | ||
796 | - uint64_t fixed_bits; | ||
797 | -} ARMCPRegUserSpaceInfo; | ||
798 | - | ||
799 | -#define REGUSERINFO_SENTINEL { .name = NULL } | ||
800 | - | ||
801 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
802 | - | ||
803 | -/* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
804 | -void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
805 | - uint64_t value); | ||
806 | -/* CPReadFn that can be used for read-as-zero behaviour */ | ||
807 | -uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); | ||
808 | - | ||
809 | -/* CPResetFn that does nothing, for use if no reset is required even | ||
810 | - * if fieldoffset is non zero. | ||
811 | - */ | ||
812 | -void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
813 | - | ||
814 | -/* Return true if this reginfo struct's field in the cpu state struct | ||
815 | - * is 64 bits wide. | ||
816 | - */ | ||
817 | -static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) | ||
818 | -{ | ||
819 | - return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); | ||
820 | -} | ||
821 | - | ||
822 | -static inline bool cp_access_ok(int current_el, | ||
823 | - const ARMCPRegInfo *ri, int isread) | ||
824 | -{ | ||
825 | - return (ri->access >> ((current_el * 2) + isread)) & 1; | ||
826 | -} | ||
827 | - | ||
828 | -/* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
829 | -uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
830 | - | ||
40 | /** | 831 | /** |
41 | * ARMELChangeHookFn: | 832 | * write_list_to_cpustate |
42 | * type of a function which can be registered via arm_register_el_change_hook() | 833 | * @cpu: ARMCPU |
834 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | ||
835 | index XXXXXXX..XXXXXXX 100644 | ||
836 | --- a/hw/arm/pxa2xx.c | ||
837 | +++ b/hw/arm/pxa2xx.c | ||
838 | @@ -XXX,XX +XXX,XX @@ | ||
839 | #include "qemu/cutils.h" | ||
840 | #include "qemu/log.h" | ||
841 | #include "qom/object.h" | ||
842 | +#include "target/arm/cpregs.h" | ||
843 | |||
844 | static struct { | ||
845 | hwaddr io_base; | ||
846 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c | ||
847 | index XXXXXXX..XXXXXXX 100644 | ||
848 | --- a/hw/arm/pxa2xx_pic.c | ||
849 | +++ b/hw/arm/pxa2xx_pic.c | ||
850 | @@ -XXX,XX +XXX,XX @@ | ||
851 | #include "hw/sysbus.h" | ||
852 | #include "migration/vmstate.h" | ||
853 | #include "qom/object.h" | ||
854 | +#include "target/arm/cpregs.h" | ||
855 | |||
856 | #define ICIP 0x00 /* Interrupt Controller IRQ Pending register */ | ||
857 | #define ICMR 0x04 /* Interrupt Controller Mask register */ | ||
858 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
859 | index XXXXXXX..XXXXXXX 100644 | ||
860 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
861 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
862 | @@ -XXX,XX +XXX,XX @@ | ||
863 | #include "gicv3_internal.h" | ||
864 | #include "hw/irq.h" | ||
865 | #include "cpu.h" | ||
866 | +#include "target/arm/cpregs.h" | ||
867 | |||
868 | /* | ||
869 | * Special case return value from hppvi_index(); must be larger than | ||
870 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
871 | index XXXXXXX..XXXXXXX 100644 | ||
872 | --- a/hw/intc/arm_gicv3_kvm.c | ||
873 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
874 | @@ -XXX,XX +XXX,XX @@ | ||
875 | #include "vgic_common.h" | ||
876 | #include "migration/blocker.h" | ||
877 | #include "qom/object.h" | ||
878 | +#include "target/arm/cpregs.h" | ||
879 | + | ||
880 | |||
881 | #ifdef DEBUG_GICV3_KVM | ||
882 | #define DPRINTF(fmt, ...) \ | ||
43 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 883 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
44 | index XXXXXXX..XXXXXXX 100644 | 884 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/target/arm/cpu.c | 885 | --- a/target/arm/cpu.c |
46 | +++ b/target/arm/cpu.c | 886 | +++ b/target/arm/cpu.c |
47 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_virtio_is_big_endian(CPUState *cs) | 887 | @@ -XXX,XX +XXX,XX @@ |
48 | 888 | #include "kvm_arm.h" | |
49 | #endif | 889 | #include "disas/capstone.h" |
50 | 890 | #include "fpu/softfloat.h" | |
51 | -static inline void set_feature(CPUARMState *env, int feature) | 891 | +#include "cpregs.h" |
52 | -{ | 892 | |
53 | - env->features |= 1ULL << feature; | 893 | static void arm_cpu_set_pc(CPUState *cs, vaddr value) |
54 | -} | ||
55 | - | ||
56 | -static inline void unset_feature(CPUARMState *env, int feature) | ||
57 | -{ | ||
58 | - env->features &= ~(1ULL << feature); | ||
59 | -} | ||
60 | - | ||
61 | static int | ||
62 | print_insn_thumb1(bfd_vma pc, disassemble_info *info) | ||
63 | { | 894 | { |
64 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 895 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
65 | index XXXXXXX..XXXXXXX 100644 | 896 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/target/arm/cpu64.c | 897 | --- a/target/arm/cpu64.c |
67 | +++ b/target/arm/cpu64.c | 898 | +++ b/target/arm/cpu64.c |
68 | @@ -XXX,XX +XXX,XX @@ | 899 | @@ -XXX,XX +XXX,XX @@ |
69 | #include "kvm_arm.h" | 900 | #include "hvf_arm.h" |
70 | #include "qapi/visitor.h" | 901 | #include "qapi/visitor.h" |
71 | 902 | #include "hw/qdev-properties.h" | |
72 | -static inline void set_feature(CPUARMState *env, int feature) | 903 | +#include "cpregs.h" |
73 | -{ | 904 | |
74 | - env->features |= 1ULL << feature; | 905 | |
75 | -} | ||
76 | - | ||
77 | -static inline void unset_feature(CPUARMState *env, int feature) | ||
78 | -{ | ||
79 | - env->features &= ~(1ULL << feature); | ||
80 | -} | ||
81 | - | ||
82 | #ifndef CONFIG_USER_ONLY | 906 | #ifndef CONFIG_USER_ONLY |
83 | static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 907 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
84 | { | 908 | index XXXXXXX..XXXXXXX 100644 |
909 | --- a/target/arm/cpu_tcg.c | ||
910 | +++ b/target/arm/cpu_tcg.c | ||
911 | @@ -XXX,XX +XXX,XX @@ | ||
912 | #if !defined(CONFIG_USER_ONLY) | ||
913 | #include "hw/boards.h" | ||
914 | #endif | ||
915 | +#include "cpregs.h" | ||
916 | |||
917 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
918 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
919 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
920 | index XXXXXXX..XXXXXXX 100644 | ||
921 | --- a/target/arm/gdbstub.c | ||
922 | +++ b/target/arm/gdbstub.c | ||
923 | @@ -XXX,XX +XXX,XX @@ | ||
924 | */ | ||
925 | #include "qemu/osdep.h" | ||
926 | #include "cpu.h" | ||
927 | -#include "internals.h" | ||
928 | #include "exec/gdbstub.h" | ||
929 | +#include "internals.h" | ||
930 | +#include "cpregs.h" | ||
931 | |||
932 | typedef struct RegisterSysregXmlParam { | ||
933 | CPUState *cs; | ||
934 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
935 | index XXXXXXX..XXXXXXX 100644 | ||
936 | --- a/target/arm/helper.c | ||
937 | +++ b/target/arm/helper.c | ||
938 | @@ -XXX,XX +XXX,XX @@ | ||
939 | #include "exec/cpu_ldst.h" | ||
940 | #include "semihosting/common-semi.h" | ||
941 | #endif | ||
942 | +#include "cpregs.h" | ||
943 | |||
944 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ | ||
945 | #define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */ | ||
946 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
947 | index XXXXXXX..XXXXXXX 100644 | ||
948 | --- a/target/arm/op_helper.c | ||
949 | +++ b/target/arm/op_helper.c | ||
950 | @@ -XXX,XX +XXX,XX @@ | ||
951 | #include "internals.h" | ||
952 | #include "exec/exec-all.h" | ||
953 | #include "exec/cpu_ldst.h" | ||
954 | +#include "cpregs.h" | ||
955 | |||
956 | #define SIGNBIT (uint32_t)0x80000000 | ||
957 | #define SIGNBIT64 ((uint64_t)1 << 63) | ||
958 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
959 | index XXXXXXX..XXXXXXX 100644 | ||
960 | --- a/target/arm/translate-a64.c | ||
961 | +++ b/target/arm/translate-a64.c | ||
962 | @@ -XXX,XX +XXX,XX @@ | ||
963 | #include "translate.h" | ||
964 | #include "internals.h" | ||
965 | #include "qemu/host-utils.h" | ||
966 | - | ||
967 | #include "semihosting/semihost.h" | ||
968 | #include "exec/gen-icount.h" | ||
969 | - | ||
970 | #include "exec/helper-proto.h" | ||
971 | #include "exec/helper-gen.h" | ||
972 | #include "exec/log.h" | ||
973 | - | ||
974 | +#include "cpregs.h" | ||
975 | #include "translate-a64.h" | ||
976 | #include "qemu/atomic128.h" | ||
977 | |||
978 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
979 | index XXXXXXX..XXXXXXX 100644 | ||
980 | --- a/target/arm/translate.c | ||
981 | +++ b/target/arm/translate.c | ||
982 | @@ -XXX,XX +XXX,XX @@ | ||
983 | #include "qemu/bitops.h" | ||
984 | #include "arm_ldst.h" | ||
985 | #include "semihosting/semihost.h" | ||
986 | - | ||
987 | #include "exec/helper-proto.h" | ||
988 | #include "exec/helper-gen.h" | ||
989 | - | ||
990 | #include "exec/log.h" | ||
991 | +#include "cpregs.h" | ||
992 | |||
993 | |||
994 | #define ENABLE_ARCH_4T arm_dc_feature(s, ARM_FEATURE_V4T) | ||
85 | -- | 995 | -- |
86 | 2.20.1 | 996 | 2.25.1 |
87 | 997 | ||
88 | 998 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Rearrange the values of the enumerators of CPAccessResult | ||
4 | so that we may directly extract the target el. For the two | ||
5 | special cases in access_check_cp_reg, use CPAccessResult. | ||
6 | |||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20200508154359.7494-14-richard.henderson@linaro.org | 10 | Message-id: 20220501055028.646596-3-richard.henderson@linaro.org |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 12 | --- |
8 | target/arm/sve_helper.c | 223 ++++++++++++++-------------------------- | 13 | target/arm/cpregs.h | 26 ++++++++++++-------- |
9 | 1 file changed, 79 insertions(+), 144 deletions(-) | 14 | target/arm/op_helper.c | 56 +++++++++++++++++++++--------------------- |
15 | 2 files changed, 44 insertions(+), 38 deletions(-) | ||
10 | 16 | ||
11 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 17 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/sve_helper.c | 19 | --- a/target/arm/cpregs.h |
14 | +++ b/target/arm/sve_helper.c | 20 | +++ b/target/arm/cpregs.h |
15 | @@ -XXX,XX +XXX,XX @@ static inline bool test_host_page(void *host) | 21 | @@ -XXX,XX +XXX,XX @@ static inline bool cptype_valid(int cptype) |
16 | } | 22 | typedef enum CPAccessResult { |
17 | 23 | /* Access is permitted */ | |
18 | /* | 24 | CP_ACCESS_OK = 0, |
19 | - * Common helper for all contiguous one-register predicated loads. | 25 | + |
20 | + * Common helper for all contiguous 1,2,3,4-register predicated stores. | 26 | + /* |
21 | */ | 27 | + * Combined with one of the following, the low 2 bits indicate the |
22 | static inline QEMU_ALWAYS_INLINE | 28 | + * target exception level. If 0, the exception is taken to the usual |
23 | -void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | 29 | + * target EL (EL1 or PL1 if in EL0, otherwise to the current EL). |
24 | +void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | 30 | + */ |
25 | uint32_t desc, const uintptr_t retaddr, | 31 | + CP_ACCESS_EL_MASK = 3, |
26 | - const int esz, const int msz, | 32 | + |
27 | + const int esz, const int msz, const int N, | 33 | /* |
28 | sve_ldst1_host_fn *host_fn, | 34 | * Access fails due to a configurable trap or enable which would |
29 | sve_ldst1_tlb_fn *tlb_fn) | 35 | * result in a categorized exception syndrome giving information about |
36 | * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
37 | - * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
38 | - * PL1 if in EL0, otherwise to the current EL). | ||
39 | + * 0xc or 0x18). | ||
40 | */ | ||
41 | - CP_ACCESS_TRAP = 1, | ||
42 | + CP_ACCESS_TRAP = (1 << 2), | ||
43 | + CP_ACCESS_TRAP_EL2 = CP_ACCESS_TRAP | 2, | ||
44 | + CP_ACCESS_TRAP_EL3 = CP_ACCESS_TRAP | 3, | ||
45 | + | ||
46 | /* | ||
47 | * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
48 | * Note that this is not a catch-all case -- the set of cases which may | ||
49 | * result in this failure is specifically defined by the architecture. | ||
50 | */ | ||
51 | - CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
52 | - /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
53 | - CP_ACCESS_TRAP_EL2 = 3, | ||
54 | - CP_ACCESS_TRAP_EL3 = 4, | ||
55 | - /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
56 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
57 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
58 | + CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2), | ||
59 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = CP_ACCESS_TRAP_UNCATEGORIZED | 2, | ||
60 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = CP_ACCESS_TRAP_UNCATEGORIZED | 3, | ||
61 | } CPAccessResult; | ||
62 | |||
63 | typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
64 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/op_helper.c | ||
67 | +++ b/target/arm/op_helper.c | ||
68 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
69 | uint32_t isread) | ||
30 | { | 70 | { |
31 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | 71 | const ARMCPRegInfo *ri = rip; |
32 | - void *vd = &env->vfp.zregs[rd]; | 72 | + CPAccessResult res = CP_ACCESS_OK; |
33 | const intptr_t reg_max = simd_oprsz(desc); | 73 | int target_el; |
34 | intptr_t reg_off, reg_last, mem_off; | 74 | |
35 | SVEContLdSt info; | 75 | if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14 |
36 | void *host; | 76 | && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) { |
37 | - int flags; | 77 | - raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); |
38 | + int flags, i; | 78 | + res = CP_ACCESS_TRAP; |
39 | 79 | + goto fail; | |
40 | /* Find the active elements. */ | 80 | } |
41 | - if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, 1 << msz)) { | 81 | |
42 | + if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, N << msz)) { | 82 | /* |
43 | /* The entire predicate was false; no load occurs. */ | 83 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, |
44 | - memset(vd, 0, reg_max); | 84 | mask &= ~((1 << 4) | (1 << 14)); |
45 | + for (i = 0; i < N; ++i) { | 85 | |
46 | + memset(&env->vfp.zregs[(rd + i) & 31], 0, reg_max); | 86 | if (env->cp15.hstr_el2 & mask) { |
47 | + } | 87 | - target_el = 2; |
88 | - goto exept; | ||
89 | + res = CP_ACCESS_TRAP_EL2; | ||
90 | + goto fail; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | - if (!ri->accessfn) { | ||
95 | + if (ri->accessfn) { | ||
96 | + res = ri->accessfn(env, ri, isread); | ||
97 | + } | ||
98 | + if (likely(res == CP_ACCESS_OK)) { | ||
48 | return; | 99 | return; |
49 | } | 100 | } |
50 | 101 | ||
51 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | 102 | - switch (ri->accessfn(env, ri, isread)) { |
52 | sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_LOAD, retaddr); | 103 | - case CP_ACCESS_OK: |
53 | 104 | - return; | |
54 | /* Handle watchpoints for all active elements. */ | 105 | + fail: |
55 | - sve_cont_ldst_watchpoints(&info, env, vg, addr, 1 << esz, 1 << msz, | 106 | + switch (res & ~CP_ACCESS_EL_MASK) { |
56 | + sve_cont_ldst_watchpoints(&info, env, vg, addr, 1 << esz, N << msz, | 107 | case CP_ACCESS_TRAP: |
57 | BP_MEM_READ, retaddr); | 108 | - target_el = exception_target_el(env); |
58 | 109 | - break; | |
59 | /* TODO: MTE check. */ | 110 | - case CP_ACCESS_TRAP_EL2: |
60 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | 111 | - /* Requesting a trap to EL2 when we're in EL3 is |
61 | * which for ARM will raise SyncExternal. Perform the load | 112 | - * a bug in the access function. |
62 | * into scratch memory to preserve register state until the end. | 113 | - */ |
63 | */ | 114 | - assert(arm_current_el(env) != 3); |
64 | - ARMVectorReg scratch; | 115 | - target_el = 2; |
65 | + ARMVectorReg scratch[4] = { }; | 116 | - break; |
66 | 117 | - case CP_ACCESS_TRAP_EL3: | |
67 | - memset(&scratch, 0, reg_max); | 118 | - target_el = 3; |
68 | mem_off = info.mem_off_first[0]; | 119 | break; |
69 | reg_off = info.reg_off_first[0]; | 120 | case CP_ACCESS_TRAP_UNCATEGORIZED: |
70 | reg_last = info.reg_off_last[1]; | 121 | - target_el = exception_target_el(env); |
71 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | 122 | - syndrome = syn_uncategorized(); |
72 | uint64_t pg = vg[reg_off >> 6]; | 123 | - break; |
73 | do { | 124 | - case CP_ACCESS_TRAP_UNCATEGORIZED_EL2: |
74 | if ((pg >> (reg_off & 63)) & 1) { | 125 | - target_el = 2; |
75 | - tlb_fn(env, &scratch, reg_off, addr + mem_off, retaddr); | 126 | - syndrome = syn_uncategorized(); |
76 | + for (i = 0; i < N; ++i) { | 127 | - break; |
77 | + tlb_fn(env, &scratch[i], reg_off, | 128 | - case CP_ACCESS_TRAP_UNCATEGORIZED_EL3: |
78 | + addr + mem_off + (i << msz), retaddr); | 129 | - target_el = 3; |
79 | + } | 130 | syndrome = syn_uncategorized(); |
80 | } | 131 | break; |
81 | reg_off += 1 << esz; | 132 | default: |
82 | - mem_off += 1 << msz; | 133 | g_assert_not_reached(); |
83 | + mem_off += N << msz; | ||
84 | } while (reg_off & 63); | ||
85 | } while (reg_off <= reg_last); | ||
86 | |||
87 | - memcpy(vd, &scratch, reg_max); | ||
88 | + for (i = 0; i < N; ++i) { | ||
89 | + memcpy(&env->vfp.zregs[(rd + i) & 31], &scratch[i], reg_max); | ||
90 | + } | ||
91 | return; | ||
92 | #endif | ||
93 | } | 134 | } |
94 | 135 | ||
95 | /* The entire operation is in RAM, on valid pages. */ | 136 | -exept: |
96 | 137 | + target_el = res & CP_ACCESS_EL_MASK; | |
97 | - memset(vd, 0, reg_max); | 138 | + switch (target_el) { |
98 | + for (i = 0; i < N; ++i) { | 139 | + case 0: |
99 | + memset(&env->vfp.zregs[(rd + i) & 31], 0, reg_max); | 140 | + target_el = exception_target_el(env); |
141 | + break; | ||
142 | + case 2: | ||
143 | + assert(arm_current_el(env) != 3); | ||
144 | + assert(arm_is_el2_enabled(env)); | ||
145 | + break; | ||
146 | + case 3: | ||
147 | + assert(arm_feature(env, ARM_FEATURE_EL3)); | ||
148 | + break; | ||
149 | + default: | ||
150 | + /* No "direct" traps to EL1 */ | ||
151 | + g_assert_not_reached(); | ||
100 | + } | 152 | + } |
101 | + | 153 | + |
102 | mem_off = info.mem_off_first[0]; | 154 | raise_exception(env, EXCP_UDEF, syndrome, target_el); |
103 | reg_off = info.reg_off_first[0]; | ||
104 | reg_last = info.reg_off_last[0]; | ||
105 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | ||
106 | uint64_t pg = vg[reg_off >> 6]; | ||
107 | do { | ||
108 | if ((pg >> (reg_off & 63)) & 1) { | ||
109 | - host_fn(vd, reg_off, host + mem_off); | ||
110 | + for (i = 0; i < N; ++i) { | ||
111 | + host_fn(&env->vfp.zregs[(rd + i) & 31], reg_off, | ||
112 | + host + mem_off + (i << msz)); | ||
113 | + } | ||
114 | } | ||
115 | reg_off += 1 << esz; | ||
116 | - mem_off += 1 << msz; | ||
117 | + mem_off += N << msz; | ||
118 | } while (reg_off <= reg_last && (reg_off & 63)); | ||
119 | } | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | ||
122 | */ | ||
123 | mem_off = info.mem_off_split; | ||
124 | if (unlikely(mem_off >= 0)) { | ||
125 | - tlb_fn(env, vd, info.reg_off_split, addr + mem_off, retaddr); | ||
126 | + reg_off = info.reg_off_split; | ||
127 | + for (i = 0; i < N; ++i) { | ||
128 | + tlb_fn(env, &env->vfp.zregs[(rd + i) & 31], reg_off, | ||
129 | + addr + mem_off + (i << msz), retaddr); | ||
130 | + } | ||
131 | } | ||
132 | |||
133 | mem_off = info.mem_off_first[1]; | ||
134 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | ||
135 | uint64_t pg = vg[reg_off >> 6]; | ||
136 | do { | ||
137 | if ((pg >> (reg_off & 63)) & 1) { | ||
138 | - host_fn(vd, reg_off, host + mem_off); | ||
139 | + for (i = 0; i < N; ++i) { | ||
140 | + host_fn(&env->vfp.zregs[(rd + i) & 31], reg_off, | ||
141 | + host + mem_off + (i << msz)); | ||
142 | + } | ||
143 | } | ||
144 | reg_off += 1 << esz; | ||
145 | - mem_off += 1 << msz; | ||
146 | + mem_off += N << msz; | ||
147 | } while (reg_off & 63); | ||
148 | } while (reg_off <= reg_last); | ||
149 | } | ||
150 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | ||
151 | void HELPER(sve_##NAME##_r)(CPUARMState *env, void *vg, \ | ||
152 | target_ulong addr, uint32_t desc) \ | ||
153 | { \ | ||
154 | - sve_ld1_r(env, vg, addr, desc, GETPC(), ESZ, 0, \ | ||
155 | + sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, MO_8, 1, \ | ||
156 | sve_##NAME##_host, sve_##NAME##_tlb); \ | ||
157 | } | 155 | } |
158 | 156 | ||
159 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_##NAME##_r)(CPUARMState *env, void *vg, \ | ||
160 | void HELPER(sve_##NAME##_le_r)(CPUARMState *env, void *vg, \ | ||
161 | target_ulong addr, uint32_t desc) \ | ||
162 | { \ | ||
163 | - sve_ld1_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, \ | ||
164 | + sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, 1, \ | ||
165 | sve_##NAME##_le_host, sve_##NAME##_le_tlb); \ | ||
166 | } \ | ||
167 | void HELPER(sve_##NAME##_be_r)(CPUARMState *env, void *vg, \ | ||
168 | target_ulong addr, uint32_t desc) \ | ||
169 | { \ | ||
170 | - sve_ld1_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, \ | ||
171 | + sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, 1, \ | ||
172 | sve_##NAME##_be_host, sve_##NAME##_be_tlb); \ | ||
173 | } | ||
174 | |||
175 | -DO_LD1_1(ld1bb, 0) | ||
176 | -DO_LD1_1(ld1bhu, 1) | ||
177 | -DO_LD1_1(ld1bhs, 1) | ||
178 | -DO_LD1_1(ld1bsu, 2) | ||
179 | -DO_LD1_1(ld1bss, 2) | ||
180 | -DO_LD1_1(ld1bdu, 3) | ||
181 | -DO_LD1_1(ld1bds, 3) | ||
182 | +DO_LD1_1(ld1bb, MO_8) | ||
183 | +DO_LD1_1(ld1bhu, MO_16) | ||
184 | +DO_LD1_1(ld1bhs, MO_16) | ||
185 | +DO_LD1_1(ld1bsu, MO_32) | ||
186 | +DO_LD1_1(ld1bss, MO_32) | ||
187 | +DO_LD1_1(ld1bdu, MO_64) | ||
188 | +DO_LD1_1(ld1bds, MO_64) | ||
189 | |||
190 | -DO_LD1_2(ld1hh, 1, 1) | ||
191 | -DO_LD1_2(ld1hsu, 2, 1) | ||
192 | -DO_LD1_2(ld1hss, 2, 1) | ||
193 | -DO_LD1_2(ld1hdu, 3, 1) | ||
194 | -DO_LD1_2(ld1hds, 3, 1) | ||
195 | +DO_LD1_2(ld1hh, MO_16, MO_16) | ||
196 | +DO_LD1_2(ld1hsu, MO_32, MO_16) | ||
197 | +DO_LD1_2(ld1hss, MO_32, MO_16) | ||
198 | +DO_LD1_2(ld1hdu, MO_64, MO_16) | ||
199 | +DO_LD1_2(ld1hds, MO_64, MO_16) | ||
200 | |||
201 | -DO_LD1_2(ld1ss, 2, 2) | ||
202 | -DO_LD1_2(ld1sdu, 3, 2) | ||
203 | -DO_LD1_2(ld1sds, 3, 2) | ||
204 | +DO_LD1_2(ld1ss, MO_32, MO_32) | ||
205 | +DO_LD1_2(ld1sdu, MO_64, MO_32) | ||
206 | +DO_LD1_2(ld1sds, MO_64, MO_32) | ||
207 | |||
208 | -DO_LD1_2(ld1dd, 3, 3) | ||
209 | +DO_LD1_2(ld1dd, MO_64, MO_64) | ||
210 | |||
211 | #undef DO_LD1_1 | ||
212 | #undef DO_LD1_2 | ||
213 | |||
214 | -/* | ||
215 | - * Common helpers for all contiguous 2,3,4-register predicated loads. | ||
216 | - */ | ||
217 | -static void sve_ld2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
218 | - uint32_t desc, int size, uintptr_t ra, | ||
219 | - sve_ldst1_tlb_fn *tlb_fn) | ||
220 | -{ | ||
221 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
222 | - intptr_t i, oprsz = simd_oprsz(desc); | ||
223 | - ARMVectorReg scratch[2] = { }; | ||
224 | - | ||
225 | - for (i = 0; i < oprsz; ) { | ||
226 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
227 | - do { | ||
228 | - if (pg & 1) { | ||
229 | - tlb_fn(env, &scratch[0], i, addr, ra); | ||
230 | - tlb_fn(env, &scratch[1], i, addr + size, ra); | ||
231 | - } | ||
232 | - i += size, pg >>= size; | ||
233 | - addr += 2 * size; | ||
234 | - } while (i & 15); | ||
235 | - } | ||
236 | - | ||
237 | - /* Wait until all exceptions have been raised to write back. */ | ||
238 | - memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); | ||
239 | - memcpy(&env->vfp.zregs[(rd + 1) & 31], &scratch[1], oprsz); | ||
240 | -} | ||
241 | - | ||
242 | -static void sve_ld3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
243 | - uint32_t desc, int size, uintptr_t ra, | ||
244 | - sve_ldst1_tlb_fn *tlb_fn) | ||
245 | -{ | ||
246 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
247 | - intptr_t i, oprsz = simd_oprsz(desc); | ||
248 | - ARMVectorReg scratch[3] = { }; | ||
249 | - | ||
250 | - for (i = 0; i < oprsz; ) { | ||
251 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
252 | - do { | ||
253 | - if (pg & 1) { | ||
254 | - tlb_fn(env, &scratch[0], i, addr, ra); | ||
255 | - tlb_fn(env, &scratch[1], i, addr + size, ra); | ||
256 | - tlb_fn(env, &scratch[2], i, addr + 2 * size, ra); | ||
257 | - } | ||
258 | - i += size, pg >>= size; | ||
259 | - addr += 3 * size; | ||
260 | - } while (i & 15); | ||
261 | - } | ||
262 | - | ||
263 | - /* Wait until all exceptions have been raised to write back. */ | ||
264 | - memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); | ||
265 | - memcpy(&env->vfp.zregs[(rd + 1) & 31], &scratch[1], oprsz); | ||
266 | - memcpy(&env->vfp.zregs[(rd + 2) & 31], &scratch[2], oprsz); | ||
267 | -} | ||
268 | - | ||
269 | -static void sve_ld4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
270 | - uint32_t desc, int size, uintptr_t ra, | ||
271 | - sve_ldst1_tlb_fn *tlb_fn) | ||
272 | -{ | ||
273 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
274 | - intptr_t i, oprsz = simd_oprsz(desc); | ||
275 | - ARMVectorReg scratch[4] = { }; | ||
276 | - | ||
277 | - for (i = 0; i < oprsz; ) { | ||
278 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
279 | - do { | ||
280 | - if (pg & 1) { | ||
281 | - tlb_fn(env, &scratch[0], i, addr, ra); | ||
282 | - tlb_fn(env, &scratch[1], i, addr + size, ra); | ||
283 | - tlb_fn(env, &scratch[2], i, addr + 2 * size, ra); | ||
284 | - tlb_fn(env, &scratch[3], i, addr + 3 * size, ra); | ||
285 | - } | ||
286 | - i += size, pg >>= size; | ||
287 | - addr += 4 * size; | ||
288 | - } while (i & 15); | ||
289 | - } | ||
290 | - | ||
291 | - /* Wait until all exceptions have been raised to write back. */ | ||
292 | - memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); | ||
293 | - memcpy(&env->vfp.zregs[(rd + 1) & 31], &scratch[1], oprsz); | ||
294 | - memcpy(&env->vfp.zregs[(rd + 2) & 31], &scratch[2], oprsz); | ||
295 | - memcpy(&env->vfp.zregs[(rd + 3) & 31], &scratch[3], oprsz); | ||
296 | -} | ||
297 | - | ||
298 | #define DO_LDN_1(N) \ | ||
299 | -void QEMU_FLATTEN HELPER(sve_ld##N##bb_r) \ | ||
300 | - (CPUARMState *env, void *vg, target_ulong addr, uint32_t desc) \ | ||
301 | -{ \ | ||
302 | - sve_ld##N##_r(env, vg, addr, desc, 1, GETPC(), sve_ld1bb_tlb); \ | ||
303 | +void HELPER(sve_ld##N##bb_r)(CPUARMState *env, void *vg, \ | ||
304 | + target_ulong addr, uint32_t desc) \ | ||
305 | +{ \ | ||
306 | + sve_ldN_r(env, vg, addr, desc, GETPC(), MO_8, MO_8, N, \ | ||
307 | + sve_ld1bb_host, sve_ld1bb_tlb); \ | ||
308 | } | ||
309 | |||
310 | -#define DO_LDN_2(N, SUFF, SIZE) \ | ||
311 | -void QEMU_FLATTEN HELPER(sve_ld##N##SUFF##_le_r) \ | ||
312 | - (CPUARMState *env, void *vg, target_ulong addr, uint32_t desc) \ | ||
313 | +#define DO_LDN_2(N, SUFF, ESZ) \ | ||
314 | +void HELPER(sve_ld##N##SUFF##_le_r)(CPUARMState *env, void *vg, \ | ||
315 | + target_ulong addr, uint32_t desc) \ | ||
316 | { \ | ||
317 | - sve_ld##N##_r(env, vg, addr, desc, SIZE, GETPC(), \ | ||
318 | - sve_ld1##SUFF##_le_tlb); \ | ||
319 | + sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, ESZ, N, \ | ||
320 | + sve_ld1##SUFF##_le_host, sve_ld1##SUFF##_le_tlb); \ | ||
321 | } \ | ||
322 | -void QEMU_FLATTEN HELPER(sve_ld##N##SUFF##_be_r) \ | ||
323 | - (CPUARMState *env, void *vg, target_ulong addr, uint32_t desc) \ | ||
324 | +void HELPER(sve_ld##N##SUFF##_be_r)(CPUARMState *env, void *vg, \ | ||
325 | + target_ulong addr, uint32_t desc) \ | ||
326 | { \ | ||
327 | - sve_ld##N##_r(env, vg, addr, desc, SIZE, GETPC(), \ | ||
328 | - sve_ld1##SUFF##_be_tlb); \ | ||
329 | + sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, ESZ, N, \ | ||
330 | + sve_ld1##SUFF##_be_host, sve_ld1##SUFF##_be_tlb); \ | ||
331 | } | ||
332 | |||
333 | DO_LDN_1(2) | ||
334 | DO_LDN_1(3) | ||
335 | DO_LDN_1(4) | ||
336 | |||
337 | -DO_LDN_2(2, hh, 2) | ||
338 | -DO_LDN_2(3, hh, 2) | ||
339 | -DO_LDN_2(4, hh, 2) | ||
340 | +DO_LDN_2(2, hh, MO_16) | ||
341 | +DO_LDN_2(3, hh, MO_16) | ||
342 | +DO_LDN_2(4, hh, MO_16) | ||
343 | |||
344 | -DO_LDN_2(2, ss, 4) | ||
345 | -DO_LDN_2(3, ss, 4) | ||
346 | -DO_LDN_2(4, ss, 4) | ||
347 | +DO_LDN_2(2, ss, MO_32) | ||
348 | +DO_LDN_2(3, ss, MO_32) | ||
349 | +DO_LDN_2(4, ss, MO_32) | ||
350 | |||
351 | -DO_LDN_2(2, dd, 8) | ||
352 | -DO_LDN_2(3, dd, 8) | ||
353 | -DO_LDN_2(4, dd, 8) | ||
354 | +DO_LDN_2(2, dd, MO_64) | ||
355 | +DO_LDN_2(3, dd, MO_64) | ||
356 | +DO_LDN_2(4, dd, MO_64) | ||
357 | |||
358 | #undef DO_LDN_1 | ||
359 | #undef DO_LDN_2 | ||
360 | -- | 157 | -- |
361 | 2.20.1 | 158 | 2.25.1 |
362 | 159 | ||
363 | 160 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | With sve_cont_ldst_pages, the differences between first-fault and no-fault | 3 | Remove a possible source of error by removing REGINFO_SENTINEL |
4 | are minimal, so unify the routines. With cpu_probe_watchpoint, we are able | 4 | and using ARRAY_SIZE (convinently hidden inside a macro) to |
5 | to make progress through pages with TLB_WATCHPOINT set when the watchpoint | 5 | find the end of the set of regs being registered or modified. |
6 | does not actually fire. | ||
7 | 6 | ||
7 | The space saved by not having the extra array element reduces | ||
8 | the executable's .data.rel.ro section by about 9k. | ||
9 | |||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200508154359.7494-15-richard.henderson@linaro.org | 13 | Message-id: 20220501055028.646596-4-richard.henderson@linaro.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 15 | --- |
13 | target/arm/sve_helper.c | 346 +++++++++++++++++++--------------------- | 16 | target/arm/cpregs.h | 53 +++++++++--------- |
14 | 1 file changed, 162 insertions(+), 184 deletions(-) | 17 | hw/arm/pxa2xx.c | 1 - |
18 | hw/arm/pxa2xx_pic.c | 1 - | ||
19 | hw/intc/arm_gicv3_cpuif.c | 5 -- | ||
20 | hw/intc/arm_gicv3_kvm.c | 1 - | ||
21 | target/arm/cpu64.c | 1 - | ||
22 | target/arm/cpu_tcg.c | 4 -- | ||
23 | target/arm/helper.c | 111 ++++++++------------------------------ | ||
24 | 8 files changed, 48 insertions(+), 129 deletions(-) | ||
15 | 25 | ||
16 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 26 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
17 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/sve_helper.c | 28 | --- a/target/arm/cpregs.h |
19 | +++ b/target/arm/sve_helper.c | 29 | +++ b/target/arm/cpregs.h |
20 | @@ -XXX,XX +XXX,XX @@ static intptr_t find_next_active(uint64_t *vg, intptr_t reg_off, | 30 | @@ -XXX,XX +XXX,XX @@ |
21 | return reg_off; | 31 | #define ARM_CP_NO_GDB 0x4000 |
22 | } | 32 | #define ARM_CP_RAISES_EXC 0x8000 |
33 | #define ARM_CP_NEWEL 0x10000 | ||
34 | -/* Used only as a terminator for ARMCPRegInfo lists */ | ||
35 | -#define ARM_CP_SENTINEL 0xfffff | ||
36 | /* Mask of only the flag bits in a type field */ | ||
37 | #define ARM_CP_FLAG_MASK 0x1f0ff | ||
38 | |||
39 | @@ -XXX,XX +XXX,XX @@ enum { | ||
40 | ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
41 | }; | ||
23 | 42 | ||
24 | -/* | 43 | -/* |
25 | - * Return the maximum offset <= @mem_max which is still within the page | 44 | - * Return true if cptype is a valid type field. This is used to try to |
26 | - * referenced by @base + @mem_off. | 45 | - * catch errors where the sentinel has been accidentally left off the end |
46 | - * of a list of registers. | ||
27 | - */ | 47 | - */ |
28 | -static intptr_t max_for_page(target_ulong base, intptr_t mem_off, | 48 | -static inline bool cptype_valid(int cptype) |
29 | - intptr_t mem_max) | ||
30 | -{ | 49 | -{ |
31 | - target_ulong addr = base + mem_off; | 50 | - return ((cptype & ~ARM_CP_FLAG_MASK) == 0) |
32 | - intptr_t split = -(intptr_t)(addr | TARGET_PAGE_MASK); | 51 | - || ((cptype & ARM_CP_SPECIAL) && |
33 | - return MIN(split, mem_max - mem_off) + mem_off; | 52 | - ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); |
34 | -} | 53 | -} |
35 | - | 54 | - |
36 | /* | 55 | /* |
37 | * Resolve the guest virtual address to info->host and info->flags. | 56 | * Access rights: |
38 | * If @nofault, return false if the page is invalid, otherwise | 57 | * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM |
39 | @@ -XXX,XX +XXX,XX @@ static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | 58 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { |
40 | #endif | 59 | #define CPREG_FIELD64(env, ri) \ |
60 | (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
61 | |||
62 | -#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
63 | +void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *reg, | ||
64 | + void *opaque); | ||
65 | |||
66 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
67 | - const ARMCPRegInfo *regs, void *opaque); | ||
68 | -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
69 | - const ARMCPRegInfo *regs, void *opaque); | ||
70 | -static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
71 | -{ | ||
72 | - define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
73 | -} | ||
74 | static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
75 | { | ||
76 | - define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
77 | + define_one_arm_cp_reg_with_opaque(cpu, regs, NULL); | ||
41 | } | 78 | } |
42 | 79 | + | |
43 | -/* | 80 | +void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, |
44 | - * The result of tlb_vaddr_to_host for user-only is just g2h(x), | 81 | + void *opaque, size_t len); |
45 | - * which is always non-null. Elide the useless test. | 82 | + |
46 | - */ | 83 | +#define define_arm_cp_regs_with_opaque(CPU, REGS, OPAQUE) \ |
47 | -static inline bool test_host_page(void *host) | 84 | + do { \ |
48 | -{ | 85 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ |
49 | -#ifdef CONFIG_USER_ONLY | 86 | + define_arm_cp_regs_with_opaque_len(CPU, REGS, OPAQUE, \ |
50 | - return true; | 87 | + ARRAY_SIZE(REGS)); \ |
51 | -#else | 88 | + } while (0) |
52 | - return likely(host != NULL); | 89 | + |
53 | -#endif | 90 | +#define define_arm_cp_regs(CPU, REGS) \ |
54 | -} | 91 | + define_arm_cp_regs_with_opaque(CPU, REGS, NULL) |
55 | - | 92 | + |
93 | const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
94 | |||
56 | /* | 95 | /* |
57 | * Common helper for all contiguous 1,2,3,4-register predicated stores. | 96 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMCPRegUserSpaceInfo { |
58 | */ | 97 | uint64_t fixed_bits; |
59 | @@ -XXX,XX +XXX,XX @@ static void record_fault(CPUARMState *env, uintptr_t i, uintptr_t oprsz) | 98 | } ARMCPRegUserSpaceInfo; |
60 | } | 99 | |
61 | 100 | -#define REGUSERINFO_SENTINEL { .name = NULL } | |
62 | /* | 101 | +void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
63 | - * Common helper for all contiguous first-fault loads. | 102 | + const ARMCPRegUserSpaceInfo *mods, |
64 | + * Common helper for all contiguous no-fault and first-fault loads. | 103 | + size_t mods_len); |
65 | */ | 104 | |
66 | -static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | 105 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); |
67 | - uint32_t desc, const uintptr_t retaddr, | 106 | +#define modify_arm_cp_regs(REGS, MODS) \ |
68 | - const int esz, const int msz, | 107 | + do { \ |
69 | - sve_ldst1_host_fn *host_fn, | 108 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ |
70 | - sve_ldst1_tlb_fn *tlb_fn) | 109 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(MODS) == 0); \ |
71 | +static inline QEMU_ALWAYS_INLINE | 110 | + modify_arm_cp_regs_with_len(REGS, ARRAY_SIZE(REGS), \ |
72 | +void sve_ldnfff1_r(CPUARMState *env, void *vg, const target_ulong addr, | 111 | + MODS, ARRAY_SIZE(MODS)); \ |
73 | + uint32_t desc, const uintptr_t retaddr, | 112 | + } while (0) |
74 | + const int esz, const int msz, const SVEContFault fault, | 113 | |
75 | + sve_ldst1_host_fn *host_fn, | 114 | /* CPWriteFn that can be used to implement writes-ignored behaviour */ |
76 | + sve_ldst1_tlb_fn *tlb_fn) | 115 | void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, |
77 | { | 116 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c |
78 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | 117 | index XXXXXXX..XXXXXXX 100644 |
79 | - const int mmu_idx = get_mmuidx(oi); | 118 | --- a/hw/arm/pxa2xx.c |
80 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | 119 | +++ b/hw/arm/pxa2xx.c |
81 | void *vd = &env->vfp.zregs[rd]; | 120 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_cp_reginfo[] = { |
82 | - const int diffsz = esz - msz; | 121 | { .name = "PWRMODE", .cp = 14, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 0, |
83 | const intptr_t reg_max = simd_oprsz(desc); | 122 | .access = PL1_RW, .type = ARM_CP_IO, |
84 | - const intptr_t mem_max = reg_max >> diffsz; | 123 | .readfn = arm_cp_read_zero, .writefn = pxa2xx_pwrmode_write }, |
85 | - intptr_t split, reg_off, mem_off, i; | 124 | - REGINFO_SENTINEL |
86 | + intptr_t reg_off, mem_off, reg_last; | 125 | }; |
87 | + SVEContLdSt info; | 126 | |
88 | + int flags; | 127 | static void pxa2xx_setup_cp14(PXA2xxState *s) |
89 | void *host; | 128 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c |
90 | 129 | index XXXXXXX..XXXXXXX 100644 | |
91 | - /* Skip to the first active element. */ | 130 | --- a/hw/arm/pxa2xx_pic.c |
92 | - reg_off = find_next_active(vg, 0, reg_max, esz); | 131 | +++ b/hw/arm/pxa2xx_pic.c |
93 | - if (unlikely(reg_off == reg_max)) { | 132 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_pic_cp_reginfo[] = { |
94 | + /* Find the active elements. */ | 133 | REGINFO_FOR_PIC_CP("ICLR2", 8), |
95 | + if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, 1 << msz)) { | 134 | REGINFO_FOR_PIC_CP("ICFP2", 9), |
96 | /* The entire predicate was false; no load occurs. */ | 135 | REGINFO_FOR_PIC_CP("ICPR2", 0xa), |
97 | memset(vd, 0, reg_max); | 136 | - REGINFO_SENTINEL |
98 | return; | 137 | }; |
138 | |||
139 | static const MemoryRegionOps pxa2xx_pic_ops = { | ||
140 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
143 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
145 | .readfn = icc_igrpen1_el3_read, | ||
146 | .writefn = icc_igrpen1_el3_write, | ||
147 | }, | ||
148 | - REGINFO_SENTINEL | ||
149 | }; | ||
150 | |||
151 | static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
152 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_hcr_reginfo[] = { | ||
153 | .readfn = ich_vmcr_read, | ||
154 | .writefn = ich_vmcr_write, | ||
155 | }, | ||
156 | - REGINFO_SENTINEL | ||
157 | }; | ||
158 | |||
159 | static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = { | ||
160 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = { | ||
161 | .readfn = ich_ap_read, | ||
162 | .writefn = ich_ap_write, | ||
163 | }, | ||
164 | - REGINFO_SENTINEL | ||
165 | }; | ||
166 | |||
167 | static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = { | ||
168 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = { | ||
169 | .readfn = ich_ap_read, | ||
170 | .writefn = ich_ap_write, | ||
171 | }, | ||
172 | - REGINFO_SENTINEL | ||
173 | }; | ||
174 | |||
175 | static void gicv3_cpuif_el_change_hook(ARMCPU *cpu, void *opaque) | ||
176 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
177 | .readfn = ich_lr_read, | ||
178 | .writefn = ich_lr_write, | ||
179 | }, | ||
180 | - REGINFO_SENTINEL | ||
181 | }; | ||
182 | define_arm_cp_regs(cpu, lr_regset); | ||
183 | } | ||
184 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
185 | index XXXXXXX..XXXXXXX 100644 | ||
186 | --- a/hw/intc/arm_gicv3_kvm.c | ||
187 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
188 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
189 | */ | ||
190 | .resetfn = arm_gicv3_icc_reset, | ||
191 | }, | ||
192 | - REGINFO_SENTINEL | ||
193 | }; | ||
194 | |||
195 | /** | ||
196 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
197 | index XXXXXXX..XXXXXXX 100644 | ||
198 | --- a/target/arm/cpu64.c | ||
199 | +++ b/target/arm/cpu64.c | ||
200 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | ||
201 | { .name = "L2MERRSR", | ||
202 | .cp = 15, .opc1 = 3, .crm = 15, | ||
203 | .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
204 | - REGINFO_SENTINEL | ||
205 | }; | ||
206 | |||
207 | static void aarch64_a57_initfn(Object *obj) | ||
208 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
209 | index XXXXXXX..XXXXXXX 100644 | ||
210 | --- a/target/arm/cpu_tcg.c | ||
211 | +++ b/target/arm/cpu_tcg.c | ||
212 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] = { | ||
213 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
214 | { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2, | ||
215 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
216 | - REGINFO_SENTINEL | ||
217 | }; | ||
218 | |||
219 | static void cortex_a8_initfn(Object *obj) | ||
220 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] = { | ||
221 | .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, | ||
222 | { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2, | ||
223 | .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, | ||
224 | - REGINFO_SENTINEL | ||
225 | }; | ||
226 | |||
227 | static void cortex_a9_initfn(Object *obj) | ||
228 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = { | ||
229 | #endif | ||
230 | { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3, | ||
231 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
232 | - REGINFO_SENTINEL | ||
233 | }; | ||
234 | |||
235 | static void cortex_a7_initfn(Object *obj) | ||
236 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
237 | .access = PL1_RW, .type = ARM_CP_CONST }, | ||
238 | { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5, | ||
239 | .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP }, | ||
240 | - REGINFO_SENTINEL | ||
241 | }; | ||
242 | |||
243 | static void cortex_r5_initfn(Object *obj) | ||
244 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
245 | index XXXXXXX..XXXXXXX 100644 | ||
246 | --- a/target/arm/helper.c | ||
247 | +++ b/target/arm/helper.c | ||
248 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = { | ||
249 | .secure = ARM_CP_SECSTATE_S, | ||
250 | .fieldoffset = offsetof(CPUARMState, cp15.contextidr_s), | ||
251 | .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, | ||
252 | - REGINFO_SENTINEL | ||
253 | }; | ||
254 | |||
255 | static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
256 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
257 | { .name = "CACHEMAINT", .cp = 15, .crn = 7, .crm = CP_ANY, | ||
258 | .opc1 = 0, .opc2 = CP_ANY, .access = PL1_W, | ||
259 | .type = ARM_CP_NOP | ARM_CP_OVERRIDE }, | ||
260 | - REGINFO_SENTINEL | ||
261 | }; | ||
262 | |||
263 | static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
264 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
265 | */ | ||
266 | { .name = "WFI_v5", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = 2, | ||
267 | .access = PL1_W, .type = ARM_CP_WFI }, | ||
268 | - REGINFO_SENTINEL | ||
269 | }; | ||
270 | |||
271 | static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
272 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
273 | .opc1 = 0, .opc2 = 0, .access = PL1_RW, .type = ARM_CP_NOP }, | ||
274 | { .name = "NMRR", .cp = 15, .crn = 10, .crm = 2, | ||
275 | .opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_NOP }, | ||
276 | - REGINFO_SENTINEL | ||
277 | }; | ||
278 | |||
279 | static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
280 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
281 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | ||
282 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | ||
283 | .resetfn = cpacr_reset, .writefn = cpacr_write, .readfn = cpacr_read }, | ||
284 | - REGINFO_SENTINEL | ||
285 | }; | ||
286 | |||
287 | typedef struct pm_event { | ||
288 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
289 | { .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, | ||
290 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
291 | .writefn = tlbimvaa_write }, | ||
292 | - REGINFO_SENTINEL | ||
293 | }; | ||
294 | |||
295 | static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
296 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
297 | { .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
298 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
299 | .writefn = tlbimvaa_is_write }, | ||
300 | - REGINFO_SENTINEL | ||
301 | }; | ||
302 | |||
303 | static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
304 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
305 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), | ||
306 | .writefn = pmovsset_write, | ||
307 | .raw_writefn = raw_write }, | ||
308 | - REGINFO_SENTINEL | ||
309 | }; | ||
310 | |||
311 | static void teecr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
312 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo t2ee_cp_reginfo[] = { | ||
313 | { .name = "TEEHBR", .cp = 14, .crn = 1, .crm = 0, .opc1 = 6, .opc2 = 0, | ||
314 | .access = PL0_RW, .fieldoffset = offsetof(CPUARMState, teehbr), | ||
315 | .accessfn = teehbr_access, .resetvalue = 0 }, | ||
316 | - REGINFO_SENTINEL | ||
317 | }; | ||
318 | |||
319 | static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
320 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
321 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidrprw_s), | ||
322 | offsetoflow32(CPUARMState, cp15.tpidrprw_ns) }, | ||
323 | .resetvalue = 0 }, | ||
324 | - REGINFO_SENTINEL | ||
325 | }; | ||
326 | |||
327 | #ifndef CONFIG_USER_ONLY | ||
328 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
329 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC].cval), | ||
330 | .writefn = gt_sec_cval_write, .raw_writefn = raw_write, | ||
331 | }, | ||
332 | - REGINFO_SENTINEL | ||
333 | }; | ||
334 | |||
335 | static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
336 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
337 | .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
338 | .readfn = gt_virt_cnt_read, | ||
339 | }, | ||
340 | - REGINFO_SENTINEL | ||
341 | }; | ||
342 | |||
343 | #endif | ||
344 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vapa_cp_reginfo[] = { | ||
345 | .access = PL1_W, .accessfn = ats_access, | ||
346 | .writefn = ats_write, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC }, | ||
347 | #endif | ||
348 | - REGINFO_SENTINEL | ||
349 | }; | ||
350 | |||
351 | /* Return basic MPU access permission bits. */ | ||
352 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav7_cp_reginfo[] = { | ||
353 | .fieldoffset = offsetof(CPUARMState, pmsav7.rnr[M_REG_NS]), | ||
354 | .writefn = pmsav7_rgnr_write, | ||
355 | .resetfn = arm_cp_reset_ignore }, | ||
356 | - REGINFO_SENTINEL | ||
357 | }; | ||
358 | |||
359 | static const ARMCPRegInfo pmsav5_cp_reginfo[] = { | ||
360 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav5_cp_reginfo[] = { | ||
361 | { .name = "946_PRBS7", .cp = 15, .crn = 6, .crm = 7, .opc1 = 0, | ||
362 | .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0, | ||
363 | .fieldoffset = offsetof(CPUARMState, cp15.c6_region[7]) }, | ||
364 | - REGINFO_SENTINEL | ||
365 | }; | ||
366 | |||
367 | static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
368 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { | ||
369 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
370 | .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), | ||
371 | .resetvalue = 0, }, | ||
372 | - REGINFO_SENTINEL | ||
373 | }; | ||
374 | |||
375 | static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
376 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
377 | /* No offsetoflow32 -- pass the entire TCR to writefn/raw_writefn. */ | ||
378 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.tcr_el[3]), | ||
379 | offsetof(CPUARMState, cp15.tcr_el[1])} }, | ||
380 | - REGINFO_SENTINEL | ||
381 | }; | ||
382 | |||
383 | /* Note that unlike TTBCR, writing to TTBCR2 does not require flushing | ||
384 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo omap_cp_reginfo[] = { | ||
385 | { .name = "C9", .cp = 15, .crn = 9, | ||
386 | .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_RW, | ||
387 | .type = ARM_CP_CONST | ARM_CP_OVERRIDE, .resetvalue = 0 }, | ||
388 | - REGINFO_SENTINEL | ||
389 | }; | ||
390 | |||
391 | static void xscale_cpar_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
392 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = { | ||
393 | { .name = "XSCALE_UNLOCK_DCACHE", | ||
394 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 2, .opc2 = 1, | ||
395 | .access = PL1_W, .type = ARM_CP_NOP }, | ||
396 | - REGINFO_SENTINEL | ||
397 | }; | ||
398 | |||
399 | static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
400 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
401 | .access = PL1_RW, | ||
402 | .type = ARM_CP_CONST | ARM_CP_NO_RAW | ARM_CP_OVERRIDE, | ||
403 | .resetvalue = 0 }, | ||
404 | - REGINFO_SENTINEL | ||
405 | }; | ||
406 | |||
407 | static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = { | ||
408 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = { | ||
409 | { .name = "CDSR", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 6, | ||
410 | .access = PL1_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
411 | .resetvalue = 0 }, | ||
412 | - REGINFO_SENTINEL | ||
413 | }; | ||
414 | |||
415 | static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
416 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
417 | .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
418 | { .name = "CIDCR", .cp = 15, .crm = 14, .opc1 = 0, | ||
419 | .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
420 | - REGINFO_SENTINEL | ||
421 | }; | ||
422 | |||
423 | static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
424 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
425 | { .name = "TCI_DCACHE", .cp = 15, .crn = 7, .crm = 14, .opc1 = 0, .opc2 = 3, | ||
426 | .access = PL0_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
427 | .resetvalue = (1 << 30) }, | ||
428 | - REGINFO_SENTINEL | ||
429 | }; | ||
430 | |||
431 | static const ARMCPRegInfo strongarm_cp_reginfo[] = { | ||
432 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo strongarm_cp_reginfo[] = { | ||
433 | .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, | ||
434 | .access = PL1_RW, .resetvalue = 0, | ||
435 | .type = ARM_CP_CONST | ARM_CP_OVERRIDE | ARM_CP_NO_RAW }, | ||
436 | - REGINFO_SENTINEL | ||
437 | }; | ||
438 | |||
439 | static uint64_t midr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
440 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { | ||
441 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
442 | offsetof(CPUARMState, cp15.ttbr1_ns) }, | ||
443 | .writefn = vmsa_ttbr_write, }, | ||
444 | - REGINFO_SENTINEL | ||
445 | }; | ||
446 | |||
447 | static uint64_t aa64_fpcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
448 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
449 | .access = PL1_RW, .accessfn = access_trap_aa32s_el1, | ||
450 | .writefn = sdcr_write, | ||
451 | .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, | ||
452 | - REGINFO_SENTINEL | ||
453 | }; | ||
454 | |||
455 | /* Used to describe the behaviour of EL2 regs when EL2 does not exist. */ | ||
456 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { | ||
457 | .type = ARM_CP_CONST, | ||
458 | .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2, | ||
459 | .access = PL2_RW, .resetvalue = 0 }, | ||
460 | - REGINFO_SENTINEL | ||
461 | }; | ||
462 | |||
463 | /* Ditto, but for registers which exist in ARMv8 but not v7 */ | ||
464 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | ||
465 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
466 | .access = PL2_RW, | ||
467 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
468 | - REGINFO_SENTINEL | ||
469 | }; | ||
470 | |||
471 | static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
472 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
473 | .cp = 15, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, | ||
474 | .access = PL2_RW, | ||
475 | .fieldoffset = offsetof(CPUARMState, cp15.hstr_el2) }, | ||
476 | - REGINFO_SENTINEL | ||
477 | }; | ||
478 | |||
479 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
480 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
481 | .access = PL2_RW, | ||
482 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), | ||
483 | .writefn = hcr_writehigh }, | ||
484 | - REGINFO_SENTINEL | ||
485 | }; | ||
486 | |||
487 | static CPAccessResult sel2_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
488 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_sec_cp_reginfo[] = { | ||
489 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 2, | ||
490 | .access = PL2_RW, .accessfn = sel2_access, | ||
491 | .fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) }, | ||
492 | - REGINFO_SENTINEL | ||
493 | }; | ||
494 | |||
495 | static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
496 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | ||
497 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 7, .opc2 = 5, | ||
498 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
499 | .writefn = tlbi_aa64_vae3_write }, | ||
500 | - REGINFO_SENTINEL | ||
501 | }; | ||
502 | |||
503 | #ifndef CONFIG_USER_ONLY | ||
504 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
505 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, | ||
506 | .access = PL1_RW, .accessfn = access_tda, | ||
507 | .type = ARM_CP_NOP }, | ||
508 | - REGINFO_SENTINEL | ||
509 | }; | ||
510 | |||
511 | static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
512 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
513 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
514 | { .name = "DBGDSAR", .cp = 14, .crm = 2, .opc1 = 0, | ||
515 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
516 | - REGINFO_SENTINEL | ||
517 | }; | ||
518 | |||
519 | /* Return the exception level to which exceptions should be taken | ||
520 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
521 | .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]), | ||
522 | .writefn = dbgbcr_write, .raw_writefn = raw_write | ||
523 | }, | ||
524 | - REGINFO_SENTINEL | ||
525 | }; | ||
526 | define_arm_cp_regs(cpu, dbgregs); | ||
99 | } | 527 | } |
100 | - mem_off = reg_off >> diffsz; | 528 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
101 | + reg_off = info.reg_off_first[0]; | 529 | .fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]), |
102 | 530 | .writefn = dbgwcr_write, .raw_writefn = raw_write | |
103 | - /* | 531 | }, |
104 | - * If the (remaining) load is entirely within a single page, then: | 532 | - REGINFO_SENTINEL |
105 | - * For softmmu, and the tlb hits, then no faults will occur; | 533 | }; |
106 | - * For user-only, either the first load will fault or none will. | 534 | define_arm_cp_regs(cpu, dbgregs); |
107 | - * We can thus perform the load directly to the destination and | 535 | } |
108 | - * Vd will be unmodified on any exception path. | 536 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
109 | - */ | 537 | .type = ARM_CP_IO, |
110 | - split = max_for_page(addr, mem_off, mem_max); | 538 | .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, |
111 | - if (likely(split == mem_max)) { | 539 | .raw_writefn = pmevtyper_rawwrite }, |
112 | - host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); | 540 | - REGINFO_SENTINEL |
113 | - if (test_host_page(host)) { | 541 | }; |
114 | - i = reg_off; | 542 | define_arm_cp_regs(cpu, pmev_regs); |
115 | - host -= mem_off; | 543 | g_free(pmevcntr_name); |
116 | - do { | 544 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
117 | - host_fn(vd, i, host + (i >> diffsz)); | 545 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5, |
118 | - i = find_next_active(vg, i + (1 << esz), reg_max, esz); | 546 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, |
119 | - } while (i < reg_max); | 547 | .resetvalue = extract64(cpu->pmceid1, 32, 32) }, |
120 | - /* After any fault, zero any leading inactive elements. */ | 548 | - REGINFO_SENTINEL |
121 | + /* Probe the page(s). */ | 549 | }; |
122 | + if (!sve_cont_ldst_pages(&info, fault, env, addr, MMU_DATA_LOAD, retaddr)) { | 550 | define_arm_cp_regs(cpu, v81_pmu_regs); |
123 | + /* Fault on first element. */ | 551 | } |
124 | + tcg_debug_assert(fault == FAULT_NO); | 552 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = { |
125 | + memset(vd, 0, reg_max); | 553 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, |
126 | + goto do_fault; | 554 | .access = PL1_R, .accessfn = access_lor_ns, |
127 | + } | 555 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
128 | + | 556 | - REGINFO_SENTINEL |
129 | + mem_off = info.mem_off_first[0]; | 557 | }; |
130 | + flags = info.page[0].flags; | 558 | |
131 | + | 559 | #ifdef TARGET_AARCH64 |
132 | + if (fault == FAULT_FIRST) { | 560 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = { |
133 | + /* | 561 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3, |
134 | + * Special handling of the first active element, | 562 | .access = PL1_RW, .accessfn = access_pauth, |
135 | + * if it crosses a page boundary or is MMIO. | 563 | .fieldoffset = offsetof(CPUARMState, keys.apib.hi) }, |
136 | + */ | 564 | - REGINFO_SENTINEL |
137 | + bool is_split = mem_off == info.mem_off_split; | 565 | }; |
138 | + /* TODO: MTE check. */ | 566 | |
139 | + if (unlikely(flags != 0) || unlikely(is_split)) { | 567 | static const ARMCPRegInfo tlbirange_reginfo[] = { |
140 | + /* | 568 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { |
141 | + * Use the slow path for cross-page handling. | 569 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 6, .opc2 = 5, |
142 | + * Might trap for MMIO or watchpoints. | 570 | .access = PL3_W, .type = ARM_CP_NO_RAW, |
143 | + */ | 571 | .writefn = tlbi_aa64_rvae3_write }, |
144 | + tlb_fn(env, vd, reg_off, addr + mem_off, retaddr); | 572 | - REGINFO_SENTINEL |
145 | + | 573 | }; |
146 | + /* After any fault, zero the other elements. */ | 574 | |
147 | swap_memzero(vd, reg_off); | 575 | static const ARMCPRegInfo tlbios_reginfo[] = { |
148 | - return; | 576 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { |
149 | + reg_off += 1 << esz; | 577 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 5, |
150 | + mem_off += 1 << msz; | 578 | .access = PL3_W, .type = ARM_CP_NO_RAW, |
151 | + swap_memzero(vd + reg_off, reg_max - reg_off); | 579 | .writefn = tlbi_aa64_vae3is_write }, |
152 | + | 580 | - REGINFO_SENTINEL |
153 | + if (is_split) { | 581 | }; |
154 | + goto second_page; | 582 | |
155 | + } | 583 | static uint64_t rndr_readfn(CPUARMState *env, const ARMCPRegInfo *ri) |
156 | + } else { | 584 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rndr_reginfo[] = { |
157 | + memset(vd, 0, reg_max); | 585 | .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END | ARM_CP_IO, |
158 | + } | 586 | .opc0 = 3, .opc1 = 3, .crn = 2, .crm = 4, .opc2 = 1, |
159 | + } else { | 587 | .access = PL0_R, .readfn = rndr_readfn }, |
160 | + memset(vd, 0, reg_max); | 588 | - REGINFO_SENTINEL |
161 | + if (unlikely(mem_off == info.mem_off_split)) { | 589 | }; |
162 | + /* The first active element crosses a page boundary. */ | 590 | |
163 | + flags |= info.page[1].flags; | 591 | #ifndef CONFIG_USER_ONLY |
164 | + if (unlikely(flags & TLB_MMIO)) { | 592 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpop_reg[] = { |
165 | + /* Some page is MMIO, see below. */ | 593 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, |
166 | + goto do_fault; | 594 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, |
167 | + } | 595 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, |
168 | + if (unlikely(flags & TLB_WATCHPOINT) && | 596 | - REGINFO_SENTINEL |
169 | + (cpu_watchpoint_address_matches | 597 | }; |
170 | + (env_cpu(env), addr + mem_off, 1 << msz) | 598 | |
171 | + & BP_MEM_READ)) { | 599 | static const ARMCPRegInfo dcpodp_reg[] = { |
172 | + /* Watchpoint hit, see below. */ | 600 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpodp_reg[] = { |
173 | + goto do_fault; | 601 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, |
174 | + } | 602 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, |
175 | + /* TODO: MTE check. */ | 603 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, |
176 | + /* | 604 | - REGINFO_SENTINEL |
177 | + * Use the slow path for cross-page handling. | 605 | }; |
178 | + * This is RAM, without a watchpoint, and will not trap. | 606 | #endif /*CONFIG_USER_ONLY*/ |
179 | + */ | 607 | |
180 | + tlb_fn(env, vd, reg_off, addr + mem_off, retaddr); | 608 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { |
181 | + goto second_page; | 609 | { .name = "DC_CIGDSW", .state = ARM_CP_STATE_AA64, |
610 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 6, | ||
611 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
612 | - REGINFO_SENTINEL | ||
613 | }; | ||
614 | |||
615 | static const ARMCPRegInfo mte_tco_ro_reginfo[] = { | ||
616 | { .name = "TCO", .state = ARM_CP_STATE_AA64, | ||
617 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, | ||
618 | .type = ARM_CP_CONST, .access = PL0_RW, }, | ||
619 | - REGINFO_SENTINEL | ||
620 | }; | ||
621 | |||
622 | static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
623 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
624 | .accessfn = aa64_zva_access, | ||
625 | #endif | ||
626 | }, | ||
627 | - REGINFO_SENTINEL | ||
628 | }; | ||
629 | |||
630 | #endif | ||
631 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo predinv_reginfo[] = { | ||
632 | { .name = "CPPRCTX", .state = ARM_CP_STATE_AA32, | ||
633 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7, | ||
634 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
635 | - REGINFO_SENTINEL | ||
636 | }; | ||
637 | |||
638 | static uint64_t ccsidr2_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
639 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ccsidr2_reginfo[] = { | ||
640 | .access = PL1_R, | ||
641 | .accessfn = access_aa64_tid2, | ||
642 | .readfn = ccsidr2_read, .type = ARM_CP_NO_RAW }, | ||
643 | - REGINFO_SENTINEL | ||
644 | }; | ||
645 | |||
646 | static CPAccessResult access_aa64_tid3(CPUARMState *env, const ARMCPRegInfo *ri, | ||
647 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = { | ||
648 | .cp = 14, .crn = 2, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
649 | .accessfn = access_joscr_jmcr, | ||
650 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
651 | - REGINFO_SENTINEL | ||
652 | }; | ||
653 | |||
654 | static const ARMCPRegInfo vhe_reginfo[] = { | ||
655 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { | ||
656 | .access = PL2_RW, .accessfn = e2h_access, | ||
657 | .writefn = gt_virt_cval_write, .raw_writefn = raw_write }, | ||
658 | #endif | ||
659 | - REGINFO_SENTINEL | ||
660 | }; | ||
661 | |||
662 | #ifndef CONFIG_USER_ONLY | ||
663 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1e1_reginfo[] = { | ||
664 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
665 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
666 | .writefn = ats_write64 }, | ||
667 | - REGINFO_SENTINEL | ||
668 | }; | ||
669 | |||
670 | static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
671 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
672 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
673 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
674 | .writefn = ats_write }, | ||
675 | - REGINFO_SENTINEL | ||
676 | }; | ||
677 | #endif | ||
678 | |||
679 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = { | ||
680 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3, | ||
681 | .access = PL2_RW, .type = ARM_CP_CONST, | ||
682 | .resetvalue = 0 }, | ||
683 | - REGINFO_SENTINEL | ||
684 | }; | ||
685 | |||
686 | void register_cp_regs_for_features(ARMCPU *cpu) | ||
687 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
688 | .access = PL1_R, .type = ARM_CP_CONST, | ||
689 | .accessfn = access_aa32_tid3, | ||
690 | .resetvalue = cpu->isar.id_isar6 }, | ||
691 | - REGINFO_SENTINEL | ||
692 | }; | ||
693 | define_arm_cp_regs(cpu, v6_idregs); | ||
694 | define_arm_cp_regs(cpu, v6_cp_reginfo); | ||
695 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
696 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7, | ||
697 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
698 | .resetvalue = cpu->pmceid1 }, | ||
699 | - REGINFO_SENTINEL | ||
700 | }; | ||
701 | #ifdef CONFIG_USER_ONLY | ||
702 | ARMCPRegUserSpaceInfo v8_user_idregs[] = { | ||
703 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
704 | .exported_bits = 0x000000f0ffffffff }, | ||
705 | { .name = "ID_AA64ISAR*_EL1_RESERVED", | ||
706 | .is_glob = true }, | ||
707 | - REGUSERINFO_SENTINEL | ||
708 | }; | ||
709 | modify_arm_cp_regs(v8_idregs, v8_user_idregs); | ||
710 | #endif | ||
711 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
712 | .access = PL2_RW, | ||
713 | .resetvalue = vmpidr_def, | ||
714 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
715 | - REGINFO_SENTINEL | ||
716 | }; | ||
717 | define_arm_cp_regs(cpu, vpidr_regs); | ||
718 | define_arm_cp_regs(cpu, el2_cp_reginfo); | ||
719 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
720 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
721 | .type = ARM_CP_NO_RAW, | ||
722 | .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, | ||
723 | - REGINFO_SENTINEL | ||
724 | }; | ||
725 | define_arm_cp_regs(cpu, vpidr_regs); | ||
726 | define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo); | ||
727 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
728 | .raw_writefn = raw_write, .writefn = sctlr_write, | ||
729 | .fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]), | ||
730 | .resetvalue = cpu->reset_sctlr }, | ||
731 | - REGINFO_SENTINEL | ||
732 | }; | ||
733 | |||
734 | define_arm_cp_regs(cpu, el3_regs); | ||
735 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
736 | { .name = "DUMMY", | ||
737 | .cp = 15, .crn = 0, .crm = 7, .opc1 = 0, .opc2 = CP_ANY, | ||
738 | .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
739 | - REGINFO_SENTINEL | ||
740 | }; | ||
741 | ARMCPRegInfo id_v8_midr_cp_reginfo[] = { | ||
742 | { .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
743 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
744 | .access = PL1_R, | ||
745 | .accessfn = access_aa64_tid1, | ||
746 | .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
747 | - REGINFO_SENTINEL | ||
748 | }; | ||
749 | ARMCPRegInfo id_cp_reginfo[] = { | ||
750 | /* These are common to v8 and pre-v8 */ | ||
751 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
752 | .access = PL1_R, | ||
753 | .accessfn = access_aa32_tid1, | ||
754 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
755 | - REGINFO_SENTINEL | ||
756 | }; | ||
757 | /* TLBTR is specific to VMSA */ | ||
758 | ARMCPRegInfo id_tlbtr_reginfo = { | ||
759 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
760 | { .name = "MIDR_EL1", | ||
761 | .exported_bits = 0x00000000ffffffff }, | ||
762 | { .name = "REVIDR_EL1" }, | ||
763 | - REGUSERINFO_SENTINEL | ||
764 | }; | ||
765 | modify_arm_cp_regs(id_v8_midr_cp_reginfo, id_v8_user_midr_cp_reginfo); | ||
766 | #endif | ||
767 | if (arm_feature(env, ARM_FEATURE_OMAPCP) || | ||
768 | arm_feature(env, ARM_FEATURE_STRONGARM)) { | ||
769 | - ARMCPRegInfo *r; | ||
770 | + size_t i; | ||
771 | /* Register the blanket "writes ignored" value first to cover the | ||
772 | * whole space. Then update the specific ID registers to allow write | ||
773 | * access, so that they ignore writes rather than causing them to | ||
774 | * UNDEF. | ||
775 | */ | ||
776 | define_one_arm_cp_reg(cpu, &crn0_wi_reginfo); | ||
777 | - for (r = id_pre_v8_midr_cp_reginfo; | ||
778 | - r->type != ARM_CP_SENTINEL; r++) { | ||
779 | - r->access = PL1_RW; | ||
780 | + for (i = 0; i < ARRAY_SIZE(id_pre_v8_midr_cp_reginfo); ++i) { | ||
781 | + id_pre_v8_midr_cp_reginfo[i].access = PL1_RW; | ||
782 | } | ||
783 | - for (r = id_cp_reginfo; r->type != ARM_CP_SENTINEL; r++) { | ||
784 | - r->access = PL1_RW; | ||
785 | + for (i = 0; i < ARRAY_SIZE(id_cp_reginfo); ++i) { | ||
786 | + id_cp_reginfo[i].access = PL1_RW; | ||
787 | } | ||
788 | id_mpuir_reginfo.access = PL1_RW; | ||
789 | id_tlbtr_reginfo.access = PL1_RW; | ||
790 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
791 | { .name = "MPIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
792 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 5, | ||
793 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, | ||
794 | - REGINFO_SENTINEL | ||
795 | }; | ||
796 | #ifdef CONFIG_USER_ONLY | ||
797 | ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { | ||
798 | { .name = "MPIDR_EL1", | ||
799 | .fixed_bits = 0x0000000080000000 }, | ||
800 | - REGUSERINFO_SENTINEL | ||
801 | }; | ||
802 | modify_arm_cp_regs(mpidr_cp_reginfo, mpidr_user_cp_reginfo); | ||
803 | #endif | ||
804 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
805 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 0, .opc2 = 1, | ||
806 | .access = PL3_RW, .type = ARM_CP_CONST, | ||
807 | .resetvalue = 0 }, | ||
808 | - REGINFO_SENTINEL | ||
809 | }; | ||
810 | define_arm_cp_regs(cpu, auxcr_reginfo); | ||
811 | if (cpu_isar_feature(aa32_ac2, cpu)) { | ||
812 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
813 | .type = ARM_CP_CONST, | ||
814 | .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 0, | ||
815 | .access = PL1_R, .resetvalue = cpu->reset_cbar }, | ||
816 | - REGINFO_SENTINEL | ||
817 | }; | ||
818 | /* We don't implement a r/w 64 bit CBAR currently */ | ||
819 | assert(arm_feature(env, ARM_FEATURE_CBAR_RO)); | ||
820 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
821 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s), | ||
822 | offsetof(CPUARMState, cp15.vbar_ns) }, | ||
823 | .resetvalue = 0 }, | ||
824 | - REGINFO_SENTINEL | ||
825 | }; | ||
826 | define_arm_cp_regs(cpu, vbar_cp_reginfo); | ||
827 | } | ||
828 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
829 | r->writefn); | ||
182 | } | 830 | } |
183 | } | 831 | } |
184 | 832 | - /* Bad type field probably means missing sentinel at end of reg list */ | |
185 | /* | 833 | - assert(cptype_valid(r->type)); |
186 | - * Perform one normal read, which will fault or not. | 834 | + |
187 | - * But it is likely to bring the page into the tlb. | 835 | for (crm = crmmin; crm <= crmmax; crm++) { |
188 | + * From this point on, all memory operations are MemSingleNF. | 836 | for (opc1 = opc1min; opc1 <= opc1max; opc1++) { |
189 | + * | 837 | for (opc2 = opc2min; opc2 <= opc2max; opc2++) { |
190 | + * Per the MemSingleNF pseudocode, a no-fault load from Device memory | 838 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
191 | + * must not actually hit the bus -- it returns (UNKNOWN, FAULT) instead. | 839 | } |
192 | + * | 840 | } |
193 | + * Unfortuately we do not have access to the memory attributes from the | 841 | |
194 | + * PTE to tell Device memory from Normal memory. So we make a mostly | 842 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, |
195 | + * correct check, and indicate (UNKNOWN, FAULT) for any MMIO. | 843 | - const ARMCPRegInfo *regs, void *opaque) |
196 | + * This gives the right answer for the common cases of "Normal memory, | 844 | +/* Define a whole list of registers */ |
197 | + * backed by host RAM" and "Device memory, backed by MMIO". | 845 | +void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, |
198 | + * The architecture allows us to suppress an NF load and return | 846 | + void *opaque, size_t len) |
199 | + * (UNKNOWN, FAULT) for any reason, so our behaviour for the corner | 847 | { |
200 | + * case of "Normal memory, backed by MMIO" is permitted. The case we | 848 | - /* Define a whole list of registers */ |
201 | + * get wrong is "Device memory, backed by host RAM", for which we | 849 | - const ARMCPRegInfo *r; |
202 | + * should return (UNKNOWN, FAULT) for but do not. | 850 | - for (r = regs; r->type != ARM_CP_SENTINEL; r++) { |
203 | + * | 851 | - define_one_arm_cp_reg_with_opaque(cpu, r, opaque); |
204 | + * Similarly, CPU_BP breakpoints would raise exceptions, and so | 852 | + size_t i; |
205 | + * return (UNKNOWN, FAULT). For simplicity, we consider gdb and | 853 | + for (i = 0; i < len; ++i) { |
206 | + * architectural breakpoints the same. | 854 | + define_one_arm_cp_reg_with_opaque(cpu, regs + i, opaque); |
207 | */ | 855 | } |
208 | - tlb_fn(env, vd, reg_off, addr + mem_off, retaddr); | 856 | } |
209 | + if (unlikely(flags & TLB_MMIO)) { | 857 | |
210 | + goto do_fault; | 858 | @@ -XXX,XX +XXX,XX @@ void define_arm_cp_regs_with_opaque(ARMCPU *cpu, |
211 | + } | 859 | * user-space cannot alter any values and dynamic values pertaining to |
212 | 860 | * execution state are hidden from user space view anyway. | |
213 | - /* After any fault, zero any leading predicated false elts. */ | 861 | */ |
214 | - swap_memzero(vd, reg_off); | 862 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods) |
215 | - mem_off += 1 << msz; | 863 | +void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
216 | - reg_off += 1 << esz; | 864 | + const ARMCPRegUserSpaceInfo *mods, |
217 | + reg_last = info.reg_off_last[0]; | 865 | + size_t mods_len) |
218 | + host = info.page[0].host; | 866 | { |
219 | 867 | - const ARMCPRegUserSpaceInfo *m; | |
220 | - /* Try again to read the balance of the page. */ | 868 | - ARMCPRegInfo *r; |
221 | - split = max_for_page(addr, mem_off - 1, mem_max); | ||
222 | - if (split >= (1 << msz)) { | ||
223 | - host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); | ||
224 | - if (host) { | ||
225 | - host -= mem_off; | ||
226 | - do { | ||
227 | + do { | ||
228 | + uint64_t pg = *(uint64_t *)(vg + (reg_off >> 3)); | ||
229 | + do { | ||
230 | + if ((pg >> (reg_off & 63)) & 1) { | ||
231 | + if (unlikely(flags & TLB_WATCHPOINT) && | ||
232 | + (cpu_watchpoint_address_matches | ||
233 | + (env_cpu(env), addr + mem_off, 1 << msz) | ||
234 | + & BP_MEM_READ)) { | ||
235 | + goto do_fault; | ||
236 | + } | ||
237 | + /* TODO: MTE check. */ | ||
238 | host_fn(vd, reg_off, host + mem_off); | ||
239 | - reg_off += 1 << esz; | ||
240 | - reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
241 | - mem_off = reg_off >> diffsz; | ||
242 | - } while (split - mem_off >= (1 << msz)); | ||
243 | - } | ||
244 | - } | ||
245 | - | 869 | - |
246 | - record_fault(env, reg_off, reg_max); | 870 | - for (m = mods; m->name; m++) { |
247 | -} | 871 | + for (size_t mi = 0; mi < mods_len; ++mi) { |
248 | - | 872 | + const ARMCPRegUserSpaceInfo *m = mods + mi; |
249 | -/* | 873 | GPatternSpec *pat = NULL; |
250 | - * Common helper for all contiguous no-fault loads. | ||
251 | - */ | ||
252 | -static void sve_ldnf1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
253 | - uint32_t desc, const int esz, const int msz, | ||
254 | - sve_ldst1_host_fn *host_fn) | ||
255 | -{ | ||
256 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
257 | - void *vd = &env->vfp.zregs[rd]; | ||
258 | - const int diffsz = esz - msz; | ||
259 | - const intptr_t reg_max = simd_oprsz(desc); | ||
260 | - const intptr_t mem_max = reg_max >> diffsz; | ||
261 | - const int mmu_idx = cpu_mmu_index(env, false); | ||
262 | - intptr_t split, reg_off, mem_off; | ||
263 | - void *host; | ||
264 | - | ||
265 | -#ifdef CONFIG_USER_ONLY | ||
266 | - host = tlb_vaddr_to_host(env, addr, MMU_DATA_LOAD, mmu_idx); | ||
267 | - if (likely(page_check_range(addr, mem_max, PAGE_READ) == 0)) { | ||
268 | - /* The entire operation is valid and will not fault. */ | ||
269 | - reg_off = 0; | ||
270 | - do { | ||
271 | - mem_off = reg_off >> diffsz; | ||
272 | - host_fn(vd, reg_off, host + mem_off); | ||
273 | + } | ||
274 | reg_off += 1 << esz; | ||
275 | - reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
276 | - } while (reg_off < reg_max); | ||
277 | - return; | ||
278 | - } | ||
279 | -#endif | ||
280 | + mem_off += 1 << msz; | ||
281 | + } while (reg_off <= reg_last && (reg_off & 63)); | ||
282 | + } while (reg_off <= reg_last); | ||
283 | |||
284 | - /* There will be no fault, so we may modify in advance. */ | ||
285 | - memset(vd, 0, reg_max); | ||
286 | - | ||
287 | - /* Skip to the first active element. */ | ||
288 | - reg_off = find_next_active(vg, 0, reg_max, esz); | ||
289 | - if (unlikely(reg_off == reg_max)) { | ||
290 | - /* The entire predicate was false; no load occurs. */ | ||
291 | - return; | ||
292 | - } | ||
293 | - mem_off = reg_off >> diffsz; | ||
294 | - | ||
295 | -#ifdef CONFIG_USER_ONLY | ||
296 | - if (page_check_range(addr + mem_off, 1 << msz, PAGE_READ) == 0) { | ||
297 | - /* At least one load is valid; take the rest of the page. */ | ||
298 | - split = max_for_page(addr, mem_off + (1 << msz) - 1, mem_max); | ||
299 | - do { | ||
300 | - host_fn(vd, reg_off, host + mem_off); | ||
301 | - reg_off += 1 << esz; | ||
302 | - reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
303 | - mem_off = reg_off >> diffsz; | ||
304 | - } while (split - mem_off >= (1 << msz)); | ||
305 | - } | ||
306 | -#else | ||
307 | /* | ||
308 | - * If the address is not in the TLB, we have no way to bring the | ||
309 | - * entry into the TLB without also risking a fault. Note that | ||
310 | - * the corollary is that we never load from an address not in RAM. | ||
311 | - * | ||
312 | - * This last is out of spec, in a weird corner case. | ||
313 | - * Per the MemNF/MemSingleNF pseudocode, a NF load from Device memory | ||
314 | - * must not actually hit the bus -- it returns UNKNOWN data instead. | ||
315 | - * But if you map non-RAM with Normal memory attributes and do a NF | ||
316 | - * load then it should access the bus. (Nobody ought actually do this | ||
317 | - * in the real world, obviously.) | ||
318 | - * | ||
319 | - * Then there are the annoying special cases with watchpoints... | ||
320 | - * TODO: Add a form of non-faulting loads using cc->tlb_fill(probe=true). | ||
321 | + * MemSingleNF is allowed to fail for any reason. We have special | ||
322 | + * code above to handle the first element crossing a page boundary. | ||
323 | + * As an implementation choice, decline to handle a cross-page element | ||
324 | + * in any other position. | ||
325 | */ | ||
326 | - host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); | ||
327 | - split = max_for_page(addr, mem_off, mem_max); | ||
328 | - if (host && split >= (1 << msz)) { | ||
329 | - host -= mem_off; | ||
330 | - do { | ||
331 | - host_fn(vd, reg_off, host + mem_off); | ||
332 | - reg_off += 1 << esz; | ||
333 | - reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
334 | - mem_off = reg_off >> diffsz; | ||
335 | - } while (split - mem_off >= (1 << msz)); | ||
336 | + reg_off = info.reg_off_split; | ||
337 | + if (reg_off >= 0) { | ||
338 | + goto do_fault; | ||
339 | } | ||
340 | -#endif | ||
341 | |||
342 | + second_page: | ||
343 | + reg_off = info.reg_off_first[1]; | ||
344 | + if (likely(reg_off < 0)) { | ||
345 | + /* No active elements on the second page. All done. */ | ||
346 | + return; | ||
347 | + } | ||
348 | + | 874 | + |
349 | + /* | 875 | if (m->is_glob) { |
350 | + * MemSingleNF is allowed to fail for any reason. As an implementation | 876 | pat = g_pattern_spec_new(m->name); |
351 | + * choice, decline to handle elements on the second page. This should | 877 | } |
352 | + * be low frequency as the guest walks through memory -- the next | 878 | - for (r = regs; r->type != ARM_CP_SENTINEL; r++) { |
353 | + * iteration of the guest's loop should be aligned on the page boundary, | 879 | + for (size_t ri = 0; ri < regs_len; ++ri) { |
354 | + * and then all following iterations will stay aligned. | 880 | + ARMCPRegInfo *r = regs + ri; |
355 | + */ | ||
356 | + | 881 | + |
357 | + do_fault: | 882 | if (pat && g_pattern_match_string(pat, r->name)) { |
358 | record_fault(env, reg_off, reg_max); | 883 | r->type = ARM_CP_CONST; |
359 | } | 884 | r->access = PL0U_R; |
360 | |||
361 | @@ -XXX,XX +XXX,XX @@ static void sve_ldnf1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
362 | void HELPER(sve_ldff1##PART##_r)(CPUARMState *env, void *vg, \ | ||
363 | target_ulong addr, uint32_t desc) \ | ||
364 | { \ | ||
365 | - sve_ldff1_r(env, vg, addr, desc, GETPC(), ESZ, 0, \ | ||
366 | - sve_ld1##PART##_host, sve_ld1##PART##_tlb); \ | ||
367 | + sve_ldnfff1_r(env, vg, addr, desc, GETPC(), ESZ, MO_8, FAULT_FIRST, \ | ||
368 | + sve_ld1##PART##_host, sve_ld1##PART##_tlb); \ | ||
369 | } \ | ||
370 | void HELPER(sve_ldnf1##PART##_r)(CPUARMState *env, void *vg, \ | ||
371 | target_ulong addr, uint32_t desc) \ | ||
372 | { \ | ||
373 | - sve_ldnf1_r(env, vg, addr, desc, ESZ, 0, sve_ld1##PART##_host); \ | ||
374 | + sve_ldnfff1_r(env, vg, addr, desc, GETPC(), ESZ, MO_8, FAULT_NO, \ | ||
375 | + sve_ld1##PART##_host, sve_ld1##PART##_tlb); \ | ||
376 | } | ||
377 | |||
378 | #define DO_LDFF1_LDNF1_2(PART, ESZ, MSZ) \ | ||
379 | void HELPER(sve_ldff1##PART##_le_r)(CPUARMState *env, void *vg, \ | ||
380 | target_ulong addr, uint32_t desc) \ | ||
381 | { \ | ||
382 | - sve_ldff1_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, \ | ||
383 | - sve_ld1##PART##_le_host, sve_ld1##PART##_le_tlb); \ | ||
384 | + sve_ldnfff1_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, FAULT_FIRST, \ | ||
385 | + sve_ld1##PART##_le_host, sve_ld1##PART##_le_tlb); \ | ||
386 | } \ | ||
387 | void HELPER(sve_ldnf1##PART##_le_r)(CPUARMState *env, void *vg, \ | ||
388 | target_ulong addr, uint32_t desc) \ | ||
389 | { \ | ||
390 | - sve_ldnf1_r(env, vg, addr, desc, ESZ, MSZ, sve_ld1##PART##_le_host); \ | ||
391 | + sve_ldnfff1_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, FAULT_NO, \ | ||
392 | + sve_ld1##PART##_le_host, sve_ld1##PART##_le_tlb); \ | ||
393 | } \ | ||
394 | void HELPER(sve_ldff1##PART##_be_r)(CPUARMState *env, void *vg, \ | ||
395 | target_ulong addr, uint32_t desc) \ | ||
396 | { \ | ||
397 | - sve_ldff1_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, \ | ||
398 | - sve_ld1##PART##_be_host, sve_ld1##PART##_be_tlb); \ | ||
399 | + sve_ldnfff1_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, FAULT_FIRST, \ | ||
400 | + sve_ld1##PART##_be_host, sve_ld1##PART##_be_tlb); \ | ||
401 | } \ | ||
402 | void HELPER(sve_ldnf1##PART##_be_r)(CPUARMState *env, void *vg, \ | ||
403 | target_ulong addr, uint32_t desc) \ | ||
404 | { \ | ||
405 | - sve_ldnf1_r(env, vg, addr, desc, ESZ, MSZ, sve_ld1##PART##_be_host); \ | ||
406 | + sve_ldnfff1_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, FAULT_NO, \ | ||
407 | + sve_ld1##PART##_be_host, sve_ld1##PART##_be_tlb); \ | ||
408 | } | ||
409 | |||
410 | -DO_LDFF1_LDNF1_1(bb, 0) | ||
411 | -DO_LDFF1_LDNF1_1(bhu, 1) | ||
412 | -DO_LDFF1_LDNF1_1(bhs, 1) | ||
413 | -DO_LDFF1_LDNF1_1(bsu, 2) | ||
414 | -DO_LDFF1_LDNF1_1(bss, 2) | ||
415 | -DO_LDFF1_LDNF1_1(bdu, 3) | ||
416 | -DO_LDFF1_LDNF1_1(bds, 3) | ||
417 | +DO_LDFF1_LDNF1_1(bb, MO_8) | ||
418 | +DO_LDFF1_LDNF1_1(bhu, MO_16) | ||
419 | +DO_LDFF1_LDNF1_1(bhs, MO_16) | ||
420 | +DO_LDFF1_LDNF1_1(bsu, MO_32) | ||
421 | +DO_LDFF1_LDNF1_1(bss, MO_32) | ||
422 | +DO_LDFF1_LDNF1_1(bdu, MO_64) | ||
423 | +DO_LDFF1_LDNF1_1(bds, MO_64) | ||
424 | |||
425 | -DO_LDFF1_LDNF1_2(hh, 1, 1) | ||
426 | -DO_LDFF1_LDNF1_2(hsu, 2, 1) | ||
427 | -DO_LDFF1_LDNF1_2(hss, 2, 1) | ||
428 | -DO_LDFF1_LDNF1_2(hdu, 3, 1) | ||
429 | -DO_LDFF1_LDNF1_2(hds, 3, 1) | ||
430 | +DO_LDFF1_LDNF1_2(hh, MO_16, MO_16) | ||
431 | +DO_LDFF1_LDNF1_2(hsu, MO_32, MO_16) | ||
432 | +DO_LDFF1_LDNF1_2(hss, MO_32, MO_16) | ||
433 | +DO_LDFF1_LDNF1_2(hdu, MO_64, MO_16) | ||
434 | +DO_LDFF1_LDNF1_2(hds, MO_64, MO_16) | ||
435 | |||
436 | -DO_LDFF1_LDNF1_2(ss, 2, 2) | ||
437 | -DO_LDFF1_LDNF1_2(sdu, 3, 2) | ||
438 | -DO_LDFF1_LDNF1_2(sds, 3, 2) | ||
439 | +DO_LDFF1_LDNF1_2(ss, MO_32, MO_32) | ||
440 | +DO_LDFF1_LDNF1_2(sdu, MO_64, MO_32) | ||
441 | +DO_LDFF1_LDNF1_2(sds, MO_64, MO_32) | ||
442 | |||
443 | -DO_LDFF1_LDNF1_2(dd, 3, 3) | ||
444 | +DO_LDFF1_LDNF1_2(dd, MO_64, MO_64) | ||
445 | |||
446 | #undef DO_LDFF1_LDNF1_1 | ||
447 | #undef DO_LDFF1_LDNF1_2 | ||
448 | -- | 885 | -- |
449 | 2.20.1 | 886 | 2.25.1 |
450 | 887 | ||
451 | 888 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This avoids the need for a separate set of helpers to implement | 3 | These particular data structures are not modified at runtime. |
4 | no-fault semantics, and will enable MTE in the future. | ||
5 | 4 | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200508154359.7494-17-richard.henderson@linaro.org | 8 | Message-id: 20220501055028.646596-5-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/sve_helper.c | 323 ++++++++++++++++------------------------ | 11 | target/arm/helper.c | 16 ++++++++-------- |
12 | 1 file changed, 127 insertions(+), 196 deletions(-) | 12 | 1 file changed, 8 insertions(+), 8 deletions(-) |
13 | 13 | ||
14 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/sve_helper.c | 16 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/sve_helper.c | 17 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ DO_LD1_ZPZ_D(dd_be, zd) | 18 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
19 | 19 | .resetvalue = cpu->pmceid1 }, | |
20 | /* First fault loads with a vector index. */ | 20 | }; |
21 | 21 | #ifdef CONFIG_USER_ONLY | |
22 | -/* Load one element into VD+REG_OFF from (ENV,VADDR) without faulting. | 22 | - ARMCPRegUserSpaceInfo v8_user_idregs[] = { |
23 | - * The controlling predicate is known to be true. Return true if the | 23 | + static const ARMCPRegUserSpaceInfo v8_user_idregs[] = { |
24 | - * load was successful. | 24 | { .name = "ID_AA64PFR0_EL1", |
25 | - */ | 25 | .exported_bits = 0x000f000f00ff0000, |
26 | -typedef bool sve_ld1_nf_fn(CPUARMState *env, void *vd, intptr_t reg_off, | 26 | .fixed_bits = 0x0000000000000011 }, |
27 | - target_ulong vaddr, int mmu_idx); | 27 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
28 | - | 28 | */ |
29 | -#ifdef CONFIG_SOFTMMU | 29 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
30 | -#define DO_LD_NF(NAME, H, TYPEE, TYPEM, HOST) \ | 30 | if (arm_feature(env, ARM_FEATURE_AARCH64)) { |
31 | -static bool sve_ld##NAME##_nf(CPUARMState *env, void *vd, intptr_t reg_off, \ | 31 | - ARMCPRegInfo nsacr = { |
32 | - target_ulong addr, int mmu_idx) \ | 32 | + static const ARMCPRegInfo nsacr = { |
33 | -{ \ | 33 | .name = "NSACR", .type = ARM_CP_CONST, |
34 | - target_ulong next_page = -(addr | TARGET_PAGE_MASK); \ | 34 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
35 | - if (likely(next_page - addr >= sizeof(TYPEM))) { \ | 35 | .access = PL1_RW, .accessfn = nsacr_access, |
36 | - void *host = tlb_vaddr_to_host(env, addr, MMU_DATA_LOAD, mmu_idx); \ | 36 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
37 | - if (likely(host)) { \ | 37 | }; |
38 | - TYPEM val = HOST(host); \ | 38 | define_one_arm_cp_reg(cpu, &nsacr); |
39 | - *(TYPEE *)(vd + H(reg_off)) = val; \ | 39 | } else { |
40 | - return true; \ | 40 | - ARMCPRegInfo nsacr = { |
41 | - } \ | 41 | + static const ARMCPRegInfo nsacr = { |
42 | - } \ | 42 | .name = "NSACR", |
43 | - return false; \ | 43 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
44 | -} | 44 | .access = PL3_RW | PL1_R, |
45 | -#else | 45 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
46 | -#define DO_LD_NF(NAME, H, TYPEE, TYPEM, HOST) \ | 46 | } |
47 | -static bool sve_ld##NAME##_nf(CPUARMState *env, void *vd, intptr_t reg_off, \ | 47 | } else { |
48 | - target_ulong addr, int mmu_idx) \ | 48 | if (arm_feature(env, ARM_FEATURE_V8)) { |
49 | -{ \ | 49 | - ARMCPRegInfo nsacr = { |
50 | - if (likely(page_check_range(addr, sizeof(TYPEM), PAGE_READ))) { \ | 50 | + static const ARMCPRegInfo nsacr = { |
51 | - TYPEM val = HOST(g2h(addr)); \ | 51 | .name = "NSACR", .type = ARM_CP_CONST, |
52 | - *(TYPEE *)(vd + H(reg_off)) = val; \ | 52 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
53 | - return true; \ | 53 | .access = PL1_R, |
54 | - } \ | 54 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
55 | - return false; \ | 55 | .access = PL1_R, .type = ARM_CP_CONST, |
56 | -} | 56 | .resetvalue = cpu->pmsav7_dregion << 8 |
57 | -#endif | 57 | }; |
58 | - | 58 | - ARMCPRegInfo crn0_wi_reginfo = { |
59 | -DO_LD_NF(bsu, H1_4, uint32_t, uint8_t, ldub_p) | 59 | + static const ARMCPRegInfo crn0_wi_reginfo = { |
60 | -DO_LD_NF(bss, H1_4, uint32_t, int8_t, ldsb_p) | 60 | .name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY, |
61 | -DO_LD_NF(bdu, , uint64_t, uint8_t, ldub_p) | 61 | .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W, |
62 | -DO_LD_NF(bds, , uint64_t, int8_t, ldsb_p) | 62 | .type = ARM_CP_NOP | ARM_CP_OVERRIDE |
63 | - | 63 | }; |
64 | -DO_LD_NF(hsu_le, H1_4, uint32_t, uint16_t, lduw_le_p) | 64 | #ifdef CONFIG_USER_ONLY |
65 | -DO_LD_NF(hss_le, H1_4, uint32_t, int16_t, ldsw_le_p) | 65 | - ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { |
66 | -DO_LD_NF(hsu_be, H1_4, uint32_t, uint16_t, lduw_be_p) | 66 | + static const ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { |
67 | -DO_LD_NF(hss_be, H1_4, uint32_t, int16_t, ldsw_be_p) | 67 | { .name = "MIDR_EL1", |
68 | -DO_LD_NF(hdu_le, , uint64_t, uint16_t, lduw_le_p) | 68 | .exported_bits = 0x00000000ffffffff }, |
69 | -DO_LD_NF(hds_le, , uint64_t, int16_t, ldsw_le_p) | 69 | { .name = "REVIDR_EL1" }, |
70 | -DO_LD_NF(hdu_be, , uint64_t, uint16_t, lduw_be_p) | 70 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
71 | -DO_LD_NF(hds_be, , uint64_t, int16_t, ldsw_be_p) | 71 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, |
72 | - | 72 | }; |
73 | -DO_LD_NF(ss_le, H1_4, uint32_t, uint32_t, ldl_le_p) | 73 | #ifdef CONFIG_USER_ONLY |
74 | -DO_LD_NF(ss_be, H1_4, uint32_t, uint32_t, ldl_be_p) | 74 | - ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { |
75 | -DO_LD_NF(sdu_le, , uint64_t, uint32_t, ldl_le_p) | 75 | + static const ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { |
76 | -DO_LD_NF(sds_le, , uint64_t, int32_t, ldl_le_p) | 76 | { .name = "MPIDR_EL1", |
77 | -DO_LD_NF(sdu_be, , uint64_t, uint32_t, ldl_be_p) | 77 | .fixed_bits = 0x0000000080000000 }, |
78 | -DO_LD_NF(sds_be, , uint64_t, int32_t, ldl_be_p) | 78 | }; |
79 | - | 79 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
80 | -DO_LD_NF(dd_le, , uint64_t, uint64_t, ldq_le_p) | ||
81 | -DO_LD_NF(dd_be, , uint64_t, uint64_t, ldq_be_p) | ||
82 | - | ||
83 | /* | ||
84 | - * Common helper for all gather first-faulting loads. | ||
85 | + * Common helpers for all gather first-faulting loads. | ||
86 | */ | ||
87 | -static inline void sve_ldff1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
88 | - target_ulong base, uint32_t desc, uintptr_t ra, | ||
89 | - zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn, | ||
90 | - sve_ld1_nf_fn *nonfault_fn) | ||
91 | + | ||
92 | +static inline QEMU_ALWAYS_INLINE | ||
93 | +void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
94 | + target_ulong base, uint32_t desc, uintptr_t retaddr, | ||
95 | + const int esz, const int msz, zreg_off_fn *off_fn, | ||
96 | + sve_ldst1_host_fn *host_fn, | ||
97 | + sve_ldst1_tlb_fn *tlb_fn) | ||
98 | { | ||
99 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
100 | - const int mmu_idx = get_mmuidx(oi); | ||
101 | + const int mmu_idx = cpu_mmu_index(env, false); | ||
102 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
103 | - intptr_t reg_off, reg_max = simd_oprsz(desc); | ||
104 | - target_ulong addr; | ||
105 | + const int esize = 1 << esz; | ||
106 | + const int msize = 1 << msz; | ||
107 | + const intptr_t reg_max = simd_oprsz(desc); | ||
108 | + intptr_t reg_off; | ||
109 | + SVEHostPage info; | ||
110 | + target_ulong addr, in_page; | ||
111 | |||
112 | /* Skip to the first true predicate. */ | ||
113 | - reg_off = find_next_active(vg, 0, reg_max, MO_32); | ||
114 | - if (likely(reg_off < reg_max)) { | ||
115 | - /* Perform one normal read, which will fault or not. */ | ||
116 | - addr = off_fn(vm, reg_off); | ||
117 | - addr = base + (addr << scale); | ||
118 | - tlb_fn(env, vd, reg_off, addr, ra); | ||
119 | - | ||
120 | - /* The rest of the reads will be non-faulting. */ | ||
121 | + reg_off = find_next_active(vg, 0, reg_max, esz); | ||
122 | + if (unlikely(reg_off >= reg_max)) { | ||
123 | + /* The entire predicate was false; no load occurs. */ | ||
124 | + memset(vd, 0, reg_max); | ||
125 | + return; | ||
126 | } | 80 | } |
127 | 81 | ||
128 | - /* After any fault, zero the leading predicated false elements. */ | 82 | if (arm_feature(env, ARM_FEATURE_VBAR)) { |
129 | + /* | 83 | - ARMCPRegInfo vbar_cp_reginfo[] = { |
130 | + * Probe the first element, allowing faults. | 84 | + static const ARMCPRegInfo vbar_cp_reginfo[] = { |
131 | + */ | 85 | { .name = "VBAR", .state = ARM_CP_STATE_BOTH, |
132 | + addr = base + (off_fn(vm, reg_off) << scale); | 86 | .opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, |
133 | + tlb_fn(env, vd, reg_off, addr, retaddr); | 87 | .access = PL1_RW, .writefn = vbar_write, |
134 | + | ||
135 | + /* After any fault, zero the other elements. */ | ||
136 | swap_memzero(vd, reg_off); | ||
137 | + reg_off += esize; | ||
138 | + swap_memzero(vd + reg_off, reg_max - reg_off); | ||
139 | |||
140 | - while (likely((reg_off += 4) < reg_max)) { | ||
141 | - uint64_t pg = *(uint64_t *)(vg + (reg_off >> 6) * 8); | ||
142 | - if (likely((pg >> (reg_off & 63)) & 1)) { | ||
143 | - addr = off_fn(vm, reg_off); | ||
144 | - addr = base + (addr << scale); | ||
145 | - if (!nonfault_fn(env, vd, reg_off, addr, mmu_idx)) { | ||
146 | - record_fault(env, reg_off, reg_max); | ||
147 | - break; | ||
148 | + /* | ||
149 | + * Probe the remaining elements, not allowing faults. | ||
150 | + */ | ||
151 | + while (reg_off < reg_max) { | ||
152 | + uint64_t pg = vg[reg_off >> 6]; | ||
153 | + do { | ||
154 | + if (likely((pg >> (reg_off & 63)) & 1)) { | ||
155 | + addr = base + (off_fn(vm, reg_off) << scale); | ||
156 | + in_page = -(addr | TARGET_PAGE_MASK); | ||
157 | + | ||
158 | + if (unlikely(in_page < msize)) { | ||
159 | + /* Stop if the element crosses a page boundary. */ | ||
160 | + goto fault; | ||
161 | + } | ||
162 | + | ||
163 | + sve_probe_page(&info, true, env, addr, 0, MMU_DATA_LOAD, | ||
164 | + mmu_idx, retaddr); | ||
165 | + if (unlikely(info.flags & (TLB_INVALID_MASK | TLB_MMIO))) { | ||
166 | + goto fault; | ||
167 | + } | ||
168 | + if (unlikely(info.flags & TLB_WATCHPOINT) && | ||
169 | + (cpu_watchpoint_address_matches | ||
170 | + (env_cpu(env), addr, msize) & BP_MEM_READ)) { | ||
171 | + goto fault; | ||
172 | + } | ||
173 | + /* TODO: MTE check. */ | ||
174 | + | ||
175 | + host_fn(vd, reg_off, info.host); | ||
176 | } | ||
177 | - } else { | ||
178 | - *(uint32_t *)(vd + H1_4(reg_off)) = 0; | ||
179 | - } | ||
180 | + reg_off += esize; | ||
181 | + } while (reg_off & 63); | ||
182 | } | ||
183 | + return; | ||
184 | + | ||
185 | + fault: | ||
186 | + record_fault(env, reg_off, reg_max); | ||
187 | } | ||
188 | |||
189 | -static inline void sve_ldff1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
190 | - target_ulong base, uint32_t desc, uintptr_t ra, | ||
191 | - zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn, | ||
192 | - sve_ld1_nf_fn *nonfault_fn) | ||
193 | -{ | ||
194 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
195 | - const int mmu_idx = get_mmuidx(oi); | ||
196 | - const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
197 | - intptr_t reg_off, reg_max = simd_oprsz(desc); | ||
198 | - target_ulong addr; | ||
199 | - | ||
200 | - /* Skip to the first true predicate. */ | ||
201 | - reg_off = find_next_active(vg, 0, reg_max, MO_64); | ||
202 | - if (likely(reg_off < reg_max)) { | ||
203 | - /* Perform one normal read, which will fault or not. */ | ||
204 | - addr = off_fn(vm, reg_off); | ||
205 | - addr = base + (addr << scale); | ||
206 | - tlb_fn(env, vd, reg_off, addr, ra); | ||
207 | - | ||
208 | - /* The rest of the reads will be non-faulting. */ | ||
209 | - } | ||
210 | - | ||
211 | - /* After any fault, zero the leading predicated false elements. */ | ||
212 | - swap_memzero(vd, reg_off); | ||
213 | - | ||
214 | - while (likely((reg_off += 8) < reg_max)) { | ||
215 | - uint8_t pg = *(uint8_t *)(vg + H1(reg_off >> 3)); | ||
216 | - if (likely(pg & 1)) { | ||
217 | - addr = off_fn(vm, reg_off); | ||
218 | - addr = base + (addr << scale); | ||
219 | - if (!nonfault_fn(env, vd, reg_off, addr, mmu_idx)) { | ||
220 | - record_fault(env, reg_off, reg_max); | ||
221 | - break; | ||
222 | - } | ||
223 | - } else { | ||
224 | - *(uint64_t *)(vd + reg_off) = 0; | ||
225 | - } | ||
226 | - } | ||
227 | +#define DO_LDFF1_ZPZ_S(MEM, OFS, MSZ) \ | ||
228 | +void HELPER(sve_ldff##MEM##_##OFS)(CPUARMState *env, void *vd, void *vg, \ | ||
229 | + void *vm, target_ulong base, uint32_t desc) \ | ||
230 | +{ \ | ||
231 | + sve_ldff1_z(env, vd, vg, vm, base, desc, GETPC(), MO_32, MSZ, \ | ||
232 | + off_##OFS##_s, sve_ld1##MEM##_host, sve_ld1##MEM##_tlb); \ | ||
233 | } | ||
234 | |||
235 | -#define DO_LDFF1_ZPZ_S(MEM, OFS) \ | ||
236 | -void HELPER(sve_ldff##MEM##_##OFS) \ | ||
237 | - (CPUARMState *env, void *vd, void *vg, void *vm, \ | ||
238 | - target_ulong base, uint32_t desc) \ | ||
239 | -{ \ | ||
240 | - sve_ldff1_zs(env, vd, vg, vm, base, desc, GETPC(), \ | ||
241 | - off_##OFS##_s, sve_ld1##MEM##_tlb, sve_ld##MEM##_nf); \ | ||
242 | +#define DO_LDFF1_ZPZ_D(MEM, OFS, MSZ) \ | ||
243 | +void HELPER(sve_ldff##MEM##_##OFS)(CPUARMState *env, void *vd, void *vg, \ | ||
244 | + void *vm, target_ulong base, uint32_t desc) \ | ||
245 | +{ \ | ||
246 | + sve_ldff1_z(env, vd, vg, vm, base, desc, GETPC(), MO_64, MSZ, \ | ||
247 | + off_##OFS##_d, sve_ld1##MEM##_host, sve_ld1##MEM##_tlb); \ | ||
248 | } | ||
249 | |||
250 | -#define DO_LDFF1_ZPZ_D(MEM, OFS) \ | ||
251 | -void HELPER(sve_ldff##MEM##_##OFS) \ | ||
252 | - (CPUARMState *env, void *vd, void *vg, void *vm, \ | ||
253 | - target_ulong base, uint32_t desc) \ | ||
254 | -{ \ | ||
255 | - sve_ldff1_zd(env, vd, vg, vm, base, desc, GETPC(), \ | ||
256 | - off_##OFS##_d, sve_ld1##MEM##_tlb, sve_ld##MEM##_nf); \ | ||
257 | -} | ||
258 | +DO_LDFF1_ZPZ_S(bsu, zsu, MO_8) | ||
259 | +DO_LDFF1_ZPZ_S(bsu, zss, MO_8) | ||
260 | +DO_LDFF1_ZPZ_D(bdu, zsu, MO_8) | ||
261 | +DO_LDFF1_ZPZ_D(bdu, zss, MO_8) | ||
262 | +DO_LDFF1_ZPZ_D(bdu, zd, MO_8) | ||
263 | |||
264 | -DO_LDFF1_ZPZ_S(bsu, zsu) | ||
265 | -DO_LDFF1_ZPZ_S(bsu, zss) | ||
266 | -DO_LDFF1_ZPZ_D(bdu, zsu) | ||
267 | -DO_LDFF1_ZPZ_D(bdu, zss) | ||
268 | -DO_LDFF1_ZPZ_D(bdu, zd) | ||
269 | +DO_LDFF1_ZPZ_S(bss, zsu, MO_8) | ||
270 | +DO_LDFF1_ZPZ_S(bss, zss, MO_8) | ||
271 | +DO_LDFF1_ZPZ_D(bds, zsu, MO_8) | ||
272 | +DO_LDFF1_ZPZ_D(bds, zss, MO_8) | ||
273 | +DO_LDFF1_ZPZ_D(bds, zd, MO_8) | ||
274 | |||
275 | -DO_LDFF1_ZPZ_S(bss, zsu) | ||
276 | -DO_LDFF1_ZPZ_S(bss, zss) | ||
277 | -DO_LDFF1_ZPZ_D(bds, zsu) | ||
278 | -DO_LDFF1_ZPZ_D(bds, zss) | ||
279 | -DO_LDFF1_ZPZ_D(bds, zd) | ||
280 | +DO_LDFF1_ZPZ_S(hsu_le, zsu, MO_16) | ||
281 | +DO_LDFF1_ZPZ_S(hsu_le, zss, MO_16) | ||
282 | +DO_LDFF1_ZPZ_D(hdu_le, zsu, MO_16) | ||
283 | +DO_LDFF1_ZPZ_D(hdu_le, zss, MO_16) | ||
284 | +DO_LDFF1_ZPZ_D(hdu_le, zd, MO_16) | ||
285 | |||
286 | -DO_LDFF1_ZPZ_S(hsu_le, zsu) | ||
287 | -DO_LDFF1_ZPZ_S(hsu_le, zss) | ||
288 | -DO_LDFF1_ZPZ_D(hdu_le, zsu) | ||
289 | -DO_LDFF1_ZPZ_D(hdu_le, zss) | ||
290 | -DO_LDFF1_ZPZ_D(hdu_le, zd) | ||
291 | +DO_LDFF1_ZPZ_S(hsu_be, zsu, MO_16) | ||
292 | +DO_LDFF1_ZPZ_S(hsu_be, zss, MO_16) | ||
293 | +DO_LDFF1_ZPZ_D(hdu_be, zsu, MO_16) | ||
294 | +DO_LDFF1_ZPZ_D(hdu_be, zss, MO_16) | ||
295 | +DO_LDFF1_ZPZ_D(hdu_be, zd, MO_16) | ||
296 | |||
297 | -DO_LDFF1_ZPZ_S(hsu_be, zsu) | ||
298 | -DO_LDFF1_ZPZ_S(hsu_be, zss) | ||
299 | -DO_LDFF1_ZPZ_D(hdu_be, zsu) | ||
300 | -DO_LDFF1_ZPZ_D(hdu_be, zss) | ||
301 | -DO_LDFF1_ZPZ_D(hdu_be, zd) | ||
302 | +DO_LDFF1_ZPZ_S(hss_le, zsu, MO_16) | ||
303 | +DO_LDFF1_ZPZ_S(hss_le, zss, MO_16) | ||
304 | +DO_LDFF1_ZPZ_D(hds_le, zsu, MO_16) | ||
305 | +DO_LDFF1_ZPZ_D(hds_le, zss, MO_16) | ||
306 | +DO_LDFF1_ZPZ_D(hds_le, zd, MO_16) | ||
307 | |||
308 | -DO_LDFF1_ZPZ_S(hss_le, zsu) | ||
309 | -DO_LDFF1_ZPZ_S(hss_le, zss) | ||
310 | -DO_LDFF1_ZPZ_D(hds_le, zsu) | ||
311 | -DO_LDFF1_ZPZ_D(hds_le, zss) | ||
312 | -DO_LDFF1_ZPZ_D(hds_le, zd) | ||
313 | +DO_LDFF1_ZPZ_S(hss_be, zsu, MO_16) | ||
314 | +DO_LDFF1_ZPZ_S(hss_be, zss, MO_16) | ||
315 | +DO_LDFF1_ZPZ_D(hds_be, zsu, MO_16) | ||
316 | +DO_LDFF1_ZPZ_D(hds_be, zss, MO_16) | ||
317 | +DO_LDFF1_ZPZ_D(hds_be, zd, MO_16) | ||
318 | |||
319 | -DO_LDFF1_ZPZ_S(hss_be, zsu) | ||
320 | -DO_LDFF1_ZPZ_S(hss_be, zss) | ||
321 | -DO_LDFF1_ZPZ_D(hds_be, zsu) | ||
322 | -DO_LDFF1_ZPZ_D(hds_be, zss) | ||
323 | -DO_LDFF1_ZPZ_D(hds_be, zd) | ||
324 | +DO_LDFF1_ZPZ_S(ss_le, zsu, MO_32) | ||
325 | +DO_LDFF1_ZPZ_S(ss_le, zss, MO_32) | ||
326 | +DO_LDFF1_ZPZ_D(sdu_le, zsu, MO_32) | ||
327 | +DO_LDFF1_ZPZ_D(sdu_le, zss, MO_32) | ||
328 | +DO_LDFF1_ZPZ_D(sdu_le, zd, MO_32) | ||
329 | |||
330 | -DO_LDFF1_ZPZ_S(ss_le, zsu) | ||
331 | -DO_LDFF1_ZPZ_S(ss_le, zss) | ||
332 | -DO_LDFF1_ZPZ_D(sdu_le, zsu) | ||
333 | -DO_LDFF1_ZPZ_D(sdu_le, zss) | ||
334 | -DO_LDFF1_ZPZ_D(sdu_le, zd) | ||
335 | +DO_LDFF1_ZPZ_S(ss_be, zsu, MO_32) | ||
336 | +DO_LDFF1_ZPZ_S(ss_be, zss, MO_32) | ||
337 | +DO_LDFF1_ZPZ_D(sdu_be, zsu, MO_32) | ||
338 | +DO_LDFF1_ZPZ_D(sdu_be, zss, MO_32) | ||
339 | +DO_LDFF1_ZPZ_D(sdu_be, zd, MO_32) | ||
340 | |||
341 | -DO_LDFF1_ZPZ_S(ss_be, zsu) | ||
342 | -DO_LDFF1_ZPZ_S(ss_be, zss) | ||
343 | -DO_LDFF1_ZPZ_D(sdu_be, zsu) | ||
344 | -DO_LDFF1_ZPZ_D(sdu_be, zss) | ||
345 | -DO_LDFF1_ZPZ_D(sdu_be, zd) | ||
346 | +DO_LDFF1_ZPZ_D(sds_le, zsu, MO_32) | ||
347 | +DO_LDFF1_ZPZ_D(sds_le, zss, MO_32) | ||
348 | +DO_LDFF1_ZPZ_D(sds_le, zd, MO_32) | ||
349 | |||
350 | -DO_LDFF1_ZPZ_D(sds_le, zsu) | ||
351 | -DO_LDFF1_ZPZ_D(sds_le, zss) | ||
352 | -DO_LDFF1_ZPZ_D(sds_le, zd) | ||
353 | +DO_LDFF1_ZPZ_D(sds_be, zsu, MO_32) | ||
354 | +DO_LDFF1_ZPZ_D(sds_be, zss, MO_32) | ||
355 | +DO_LDFF1_ZPZ_D(sds_be, zd, MO_32) | ||
356 | |||
357 | -DO_LDFF1_ZPZ_D(sds_be, zsu) | ||
358 | -DO_LDFF1_ZPZ_D(sds_be, zss) | ||
359 | -DO_LDFF1_ZPZ_D(sds_be, zd) | ||
360 | +DO_LDFF1_ZPZ_D(dd_le, zsu, MO_64) | ||
361 | +DO_LDFF1_ZPZ_D(dd_le, zss, MO_64) | ||
362 | +DO_LDFF1_ZPZ_D(dd_le, zd, MO_64) | ||
363 | |||
364 | -DO_LDFF1_ZPZ_D(dd_le, zsu) | ||
365 | -DO_LDFF1_ZPZ_D(dd_le, zss) | ||
366 | -DO_LDFF1_ZPZ_D(dd_le, zd) | ||
367 | - | ||
368 | -DO_LDFF1_ZPZ_D(dd_be, zsu) | ||
369 | -DO_LDFF1_ZPZ_D(dd_be, zss) | ||
370 | -DO_LDFF1_ZPZ_D(dd_be, zd) | ||
371 | +DO_LDFF1_ZPZ_D(dd_be, zsu, MO_64) | ||
372 | +DO_LDFF1_ZPZ_D(dd_be, zss, MO_64) | ||
373 | +DO_LDFF1_ZPZ_D(dd_be, zd, MO_64) | ||
374 | |||
375 | /* Stores with a vector index. */ | ||
376 | |||
377 | -- | 88 | -- |
378 | 2.20.1 | 89 | 2.25.1 |
379 | 90 | ||
380 | 91 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | First use of the new helper functions, so we can remove the | 3 | Instead of defining ARM_CP_FLAG_MASK to remove flags, |
4 | unused markup. No longer need a scratch for user-only, as | 4 | define ARM_CP_SPECIAL_MASK to isolate special cases. |
5 | we completely probe the page set before reading; system mode | 5 | Sort the specials to the low bits. Use an enum. |
6 | still requires a scratch for MMIO. | 6 | |
7 | 7 | Split the large comment block so as to document each | |
8 | value separately. | ||
9 | |||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Message-id: 20220501055028.646596-6-richard.henderson@linaro.org |
10 | Message-id: 20200508154359.7494-12-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 14 | --- |
13 | target/arm/sve_helper.c | 188 +++++++++++++++++++++------------------- | 15 | target/arm/cpregs.h | 130 +++++++++++++++++++++++-------------- |
14 | 1 file changed, 97 insertions(+), 91 deletions(-) | 16 | target/arm/cpu.c | 4 +- |
15 | 17 | target/arm/helper.c | 4 +- | |
16 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 18 | target/arm/translate-a64.c | 6 +- |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | target/arm/translate.c | 6 +- |
18 | --- a/target/arm/sve_helper.c | 20 | 5 files changed, 92 insertions(+), 58 deletions(-) |
19 | +++ b/target/arm/sve_helper.c | 21 | |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 22 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
21 | * final element on each page. Identify any single element that spans | 23 | index XXXXXXX..XXXXXXX 100644 |
22 | * the page boundary. Return true if there are any active elements. | 24 | --- a/target/arm/cpregs.h |
25 | +++ b/target/arm/cpregs.h | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | #define TARGET_ARM_CPREGS_H | ||
28 | |||
29 | /* | ||
30 | - * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | ||
31 | - * special-behaviour cp reg and bits [11..8] indicate what behaviour | ||
32 | - * it has. Otherwise it is a simple cp reg, where CONST indicates that | ||
33 | - * TCG can assume the value to be constant (ie load at translate time) | ||
34 | - * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | ||
35 | - * indicates that the TB should not be ended after a write to this register | ||
36 | - * (the default is that the TB ends after cp writes). OVERRIDE permits | ||
37 | - * a register definition to override a previous definition for the | ||
38 | - * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the | ||
39 | - * old must have the OVERRIDE bit set. | ||
40 | - * ALIAS indicates that this register is an alias view of some underlying | ||
41 | - * state which is also visible via another register, and that the other | ||
42 | - * register is handling migration and reset; registers marked ALIAS will not be | ||
43 | - * migrated but may have their state set by syncing of register state from KVM. | ||
44 | - * NO_RAW indicates that this register has no underlying state and does not | ||
45 | - * support raw access for state saving/loading; it will not be used for either | ||
46 | - * migration or KVM state synchronization. (Typically this is for "registers" | ||
47 | - * which are actually used as instructions for cache maintenance and so on.) | ||
48 | - * IO indicates that this register does I/O and therefore its accesses | ||
49 | - * need to be marked with gen_io_start() and also end the TB. In particular, | ||
50 | - * registers which implement clocks or timers require this. | ||
51 | - * RAISES_EXC is for when the read or write hook might raise an exception; | ||
52 | - * the generated code will synchronize the CPU state before calling the hook | ||
53 | - * so that it is safe for the hook to call raise_exception(). | ||
54 | - * NEWEL is for writes to registers that might change the exception | ||
55 | - * level - typically on older ARM chips. For those cases we need to | ||
56 | - * re-read the new el when recomputing the translation flags. | ||
57 | + * ARMCPRegInfo type field bits: | ||
23 | */ | 58 | */ |
24 | -static bool __attribute__((unused)) | 59 | -#define ARM_CP_SPECIAL 0x0001 |
25 | -sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, uint64_t *vg, | 60 | -#define ARM_CP_CONST 0x0002 |
26 | - intptr_t reg_max, int esz, int msize) | 61 | -#define ARM_CP_64BIT 0x0004 |
27 | +static bool sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, | 62 | -#define ARM_CP_SUPPRESS_TB_END 0x0008 |
28 | + uint64_t *vg, intptr_t reg_max, | 63 | -#define ARM_CP_OVERRIDE 0x0010 |
29 | + int esz, int msize) | 64 | -#define ARM_CP_ALIAS 0x0020 |
30 | { | 65 | -#define ARM_CP_IO 0x0040 |
31 | const int esize = 1 << esz; | 66 | -#define ARM_CP_NO_RAW 0x0080 |
32 | const uint64_t pg_mask = pred_esz_masks[esz]; | 67 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) |
33 | @@ -XXX,XX +XXX,XX @@ sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, uint64_t *vg, | 68 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) |
34 | * Control the generation of page faults with @fault. Return false if | 69 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) |
35 | * there is no work to do, which can only happen with @fault == FAULT_NO. | 70 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) |
36 | */ | 71 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) |
37 | -static bool __attribute__((unused)) | 72 | -#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) |
38 | -sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, CPUARMState *env, | 73 | -#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) |
39 | - target_ulong addr, MMUAccessType access_type, | 74 | -#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA |
40 | - uintptr_t retaddr) | 75 | -#define ARM_CP_FPU 0x1000 |
41 | +static bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, | 76 | -#define ARM_CP_SVE 0x2000 |
42 | + CPUARMState *env, target_ulong addr, | 77 | -#define ARM_CP_NO_GDB 0x4000 |
43 | + MMUAccessType access_type, uintptr_t retaddr) | 78 | -#define ARM_CP_RAISES_EXC 0x8000 |
44 | { | 79 | -#define ARM_CP_NEWEL 0x10000 |
45 | int mmu_idx = cpu_mmu_index(env, false); | 80 | -/* Mask of only the flag bits in a type field */ |
46 | int mem_off = info->mem_off_first[0]; | 81 | -#define ARM_CP_FLAG_MASK 0x1f0ff |
47 | @@ -XXX,XX +XXX,XX @@ static inline bool test_host_page(void *host) | 82 | +enum { |
83 | + /* | ||
84 | + * Register must be handled specially during translation. | ||
85 | + * The method is one of the values below: | ||
86 | + */ | ||
87 | + ARM_CP_SPECIAL_MASK = 0x000f, | ||
88 | + /* Special: no change to PE state: writes ignored, reads ignored. */ | ||
89 | + ARM_CP_NOP = 0x0001, | ||
90 | + /* Special: sysreg is WFI, for v5 and v6. */ | ||
91 | + ARM_CP_WFI = 0x0002, | ||
92 | + /* Special: sysreg is NZCV. */ | ||
93 | + ARM_CP_NZCV = 0x0003, | ||
94 | + /* Special: sysreg is CURRENTEL. */ | ||
95 | + ARM_CP_CURRENTEL = 0x0004, | ||
96 | + /* Special: sysreg is DC ZVA or similar. */ | ||
97 | + ARM_CP_DC_ZVA = 0x0005, | ||
98 | + ARM_CP_DC_GVA = 0x0006, | ||
99 | + ARM_CP_DC_GZVA = 0x0007, | ||
100 | + | ||
101 | + /* Flag: reads produce resetvalue; writes ignored. */ | ||
102 | + ARM_CP_CONST = 1 << 4, | ||
103 | + /* Flag: For ARM_CP_STATE_AA32, sysreg is 64-bit. */ | ||
104 | + ARM_CP_64BIT = 1 << 5, | ||
105 | + /* | ||
106 | + * Flag: TB should not be ended after a write to this register | ||
107 | + * (the default is that the TB ends after cp writes). | ||
108 | + */ | ||
109 | + ARM_CP_SUPPRESS_TB_END = 1 << 6, | ||
110 | + /* | ||
111 | + * Flag: Permit a register definition to override a previous definition | ||
112 | + * for the same (cp, is64, crn, crm, opc1, opc2) tuple: either the new | ||
113 | + * or the old must have the ARM_CP_OVERRIDE bit set. | ||
114 | + */ | ||
115 | + ARM_CP_OVERRIDE = 1 << 7, | ||
116 | + /* | ||
117 | + * Flag: Register is an alias view of some underlying state which is also | ||
118 | + * visible via another register, and that the other register is handling | ||
119 | + * migration and reset; registers marked ARM_CP_ALIAS will not be migrated | ||
120 | + * but may have their state set by syncing of register state from KVM. | ||
121 | + */ | ||
122 | + ARM_CP_ALIAS = 1 << 8, | ||
123 | + /* | ||
124 | + * Flag: Register does I/O and therefore its accesses need to be marked | ||
125 | + * with gen_io_start() and also end the TB. In particular, registers which | ||
126 | + * implement clocks or timers require this. | ||
127 | + */ | ||
128 | + ARM_CP_IO = 1 << 9, | ||
129 | + /* | ||
130 | + * Flag: Register has no underlying state and does not support raw access | ||
131 | + * for state saving/loading; it will not be used for either migration or | ||
132 | + * KVM state synchronization. Typically this is for "registers" which are | ||
133 | + * actually used as instructions for cache maintenance and so on. | ||
134 | + */ | ||
135 | + ARM_CP_NO_RAW = 1 << 10, | ||
136 | + /* | ||
137 | + * Flag: The read or write hook might raise an exception; the generated | ||
138 | + * code will synchronize the CPU state before calling the hook so that it | ||
139 | + * is safe for the hook to call raise_exception(). | ||
140 | + */ | ||
141 | + ARM_CP_RAISES_EXC = 1 << 11, | ||
142 | + /* | ||
143 | + * Flag: Writes to the sysreg might change the exception level - typically | ||
144 | + * on older ARM chips. For those cases we need to re-read the new el when | ||
145 | + * recomputing the translation flags. | ||
146 | + */ | ||
147 | + ARM_CP_NEWEL = 1 << 12, | ||
148 | + /* | ||
149 | + * Flag: Access check for this sysreg is identical to accessing FPU state | ||
150 | + * from an instruction: use translation fp_access_check(). | ||
151 | + */ | ||
152 | + ARM_CP_FPU = 1 << 13, | ||
153 | + /* | ||
154 | + * Flag: Access check for this sysreg is identical to accessing SVE state | ||
155 | + * from an instruction: use translation sve_access_check(). | ||
156 | + */ | ||
157 | + ARM_CP_SVE = 1 << 14, | ||
158 | + /* Flag: Do not expose in gdb sysreg xml. */ | ||
159 | + ARM_CP_NO_GDB = 1 << 15, | ||
160 | +}; | ||
161 | |||
48 | /* | 162 | /* |
49 | * Common helper for all contiguous one-register predicated loads. | 163 | * Valid values for ARMCPRegInfo state field, indicating which of |
50 | */ | 164 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
51 | -static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | 165 | index XXXXXXX..XXXXXXX 100644 |
52 | - uint32_t desc, const uintptr_t retaddr, | 166 | --- a/target/arm/cpu.c |
53 | - const int esz, const int msz, | 167 | +++ b/target/arm/cpu.c |
54 | - sve_ldst1_host_fn *host_fn, | 168 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) |
55 | - sve_ldst1_tlb_fn *tlb_fn) | 169 | ARMCPRegInfo *ri = value; |
56 | +static inline QEMU_ALWAYS_INLINE | 170 | ARMCPU *cpu = opaque; |
57 | +void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | 171 | |
58 | + uint32_t desc, const uintptr_t retaddr, | 172 | - if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS)) { |
59 | + const int esz, const int msz, | 173 | + if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS)) { |
60 | + sve_ldst1_host_fn *host_fn, | 174 | return; |
61 | + sve_ldst1_tlb_fn *tlb_fn) | 175 | } |
62 | { | 176 | |
63 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | 177 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque) |
64 | - const int mmu_idx = get_mmuidx(oi); | 178 | ARMCPU *cpu = opaque; |
65 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | 179 | uint64_t oldvalue, newvalue; |
66 | void *vd = &env->vfp.zregs[rd]; | 180 | |
67 | - const int diffsz = esz - msz; | 181 | - if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS | ARM_CP_NO_RAW)) { |
68 | const intptr_t reg_max = simd_oprsz(desc); | 182 | + if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS | ARM_CP_NO_RAW)) { |
69 | - const intptr_t mem_max = reg_max >> diffsz; | 183 | return; |
70 | - ARMVectorReg scratch; | 184 | } |
71 | + intptr_t reg_off, reg_last, mem_off; | 185 | |
72 | + SVEContLdSt info; | 186 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
73 | void *host; | 187 | index XXXXXXX..XXXXXXX 100644 |
74 | - intptr_t split, reg_off, mem_off; | 188 | --- a/target/arm/helper.c |
75 | + int flags; | 189 | +++ b/target/arm/helper.c |
76 | 190 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | |
77 | - /* Find the first active element. */ | 191 | * multiple times. Special registers (ie NOP/WFI) are |
78 | - reg_off = find_next_active(vg, 0, reg_max, esz); | 192 | * never migratable and not even raw-accessible. |
79 | - if (unlikely(reg_off == reg_max)) { | 193 | */ |
80 | + /* Find the active elements. */ | 194 | - if ((r->type & ARM_CP_SPECIAL)) { |
81 | + if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, 1 << msz)) { | 195 | + if (r->type & ARM_CP_SPECIAL_MASK) { |
82 | /* The entire predicate was false; no load occurs. */ | 196 | r2->type |= ARM_CP_NO_RAW; |
83 | memset(vd, 0, reg_max); | 197 | } |
84 | return; | 198 | if (((r->crm == CP_ANY) && crm != 0) || |
85 | } | 199 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
86 | - mem_off = reg_off >> diffsz; | 200 | /* Check that the register definition has enough info to handle |
87 | 201 | * reads and writes if they are permitted. | |
88 | - /* | 202 | */ |
89 | - * If the (remaining) load is entirely within a single page, then: | 203 | - if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) { |
90 | - * For softmmu, and the tlb hits, then no faults will occur; | 204 | + if (!(r->type & (ARM_CP_SPECIAL_MASK | ARM_CP_CONST))) { |
91 | - * For user-only, either the first load will fault or none will. | 205 | if (r->access & PL3_R) { |
92 | - * We can thus perform the load directly to the destination and | 206 | assert((r->fieldoffset || |
93 | - * Vd will be unmodified on any exception path. | 207 | (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1])) || |
94 | - */ | 208 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
95 | - split = max_for_page(addr, mem_off, mem_max); | 209 | index XXXXXXX..XXXXXXX 100644 |
96 | - if (likely(split == mem_max)) { | 210 | --- a/target/arm/translate-a64.c |
97 | - host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); | 211 | +++ b/target/arm/translate-a64.c |
98 | - if (test_host_page(host)) { | 212 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, |
99 | - intptr_t i = reg_off; | 213 | } |
100 | - host -= mem_off; | 214 | |
101 | - do { | 215 | /* Handle special cases first */ |
102 | - host_fn(vd, i, host + (i >> diffsz)); | 216 | - switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { |
103 | - i = find_next_active(vg, i + (1 << esz), reg_max, esz); | 217 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { |
104 | - } while (i < reg_max); | 218 | + case 0: |
105 | - /* After having taken any fault, zero leading inactive elements. */ | 219 | + break; |
106 | - swap_memzero(vd, reg_off); | 220 | case ARM_CP_NOP: |
107 | - return; | 221 | return; |
108 | - } | 222 | case ARM_CP_NZCV: |
109 | - } | 223 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, |
110 | + /* Probe the page(s). Exit with exception for any invalid page. */ | 224 | } |
111 | + sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_LOAD, retaddr); | 225 | return; |
112 | 226 | default: | |
113 | - /* | 227 | - break; |
114 | - * Perform the predicated read into a temporary, thus ensuring | ||
115 | - * if the load of the last element faults, Vd is not modified. | ||
116 | - */ | ||
117 | + flags = info.page[0].flags | info.page[1].flags; | ||
118 | + if (unlikely(flags != 0)) { | ||
119 | #ifdef CONFIG_USER_ONLY | ||
120 | - swap_memzero(&scratch, reg_off); | ||
121 | - host = g2h(addr); | ||
122 | - do { | ||
123 | - host_fn(&scratch, reg_off, host + (reg_off >> diffsz)); | ||
124 | - reg_off += 1 << esz; | ||
125 | - reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
126 | - } while (reg_off < reg_max); | ||
127 | + g_assert_not_reached(); | 228 | + g_assert_not_reached(); |
128 | #else | 229 | } |
129 | - memset(&scratch, 0, reg_max); | 230 | if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) { |
130 | - goto start; | 231 | return; |
131 | - while (1) { | 232 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
132 | - reg_off = find_next_active(vg, reg_off, reg_max, esz); | 233 | index XXXXXXX..XXXXXXX 100644 |
133 | - if (reg_off >= reg_max) { | 234 | --- a/target/arm/translate.c |
235 | +++ b/target/arm/translate.c | ||
236 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
237 | } | ||
238 | |||
239 | /* Handle special cases first */ | ||
240 | - switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { | ||
241 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { | ||
242 | + case 0: | ||
243 | + break; | ||
244 | case ARM_CP_NOP: | ||
245 | return; | ||
246 | case ARM_CP_WFI: | ||
247 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
248 | s->base.is_jmp = DISAS_WFI; | ||
249 | return; | ||
250 | default: | ||
134 | - break; | 251 | - break; |
135 | - } | 252 | + g_assert_not_reached(); |
136 | - mem_off = reg_off >> diffsz; | ||
137 | - split = max_for_page(addr, mem_off, mem_max); | ||
138 | + /* | ||
139 | + * At least one page includes MMIO (or watchpoints). | ||
140 | + * Any bus operation can fail with cpu_transaction_failed, | ||
141 | + * which for ARM will raise SyncExternal. Perform the load | ||
142 | + * into scratch memory to preserve register state until the end. | ||
143 | + */ | ||
144 | + ARMVectorReg scratch; | ||
145 | |||
146 | - start: | ||
147 | - if (split - mem_off >= (1 << msz)) { | ||
148 | - /* At least one whole element on this page. */ | ||
149 | - host = tlb_vaddr_to_host(env, addr + mem_off, | ||
150 | - MMU_DATA_LOAD, mmu_idx); | ||
151 | - if (host) { | ||
152 | - host -= mem_off; | ||
153 | - do { | ||
154 | - host_fn(&scratch, reg_off, host + mem_off); | ||
155 | - reg_off += 1 << esz; | ||
156 | - reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
157 | - mem_off = reg_off >> diffsz; | ||
158 | - } while (split - mem_off >= (1 << msz)); | ||
159 | - continue; | ||
160 | + memset(&scratch, 0, reg_max); | ||
161 | + mem_off = info.mem_off_first[0]; | ||
162 | + reg_off = info.reg_off_first[0]; | ||
163 | + reg_last = info.reg_off_last[1]; | ||
164 | + if (reg_last < 0) { | ||
165 | + reg_last = info.reg_off_split; | ||
166 | + if (reg_last < 0) { | ||
167 | + reg_last = info.reg_off_last[0]; | ||
168 | } | ||
169 | } | 253 | } |
170 | 254 | ||
171 | - /* | 255 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { |
172 | - * Perform one normal read. This may fault, longjmping out to the | ||
173 | - * main loop in order to raise an exception. It may succeed, and | ||
174 | - * as a side-effect load the TLB entry for the next round. Finally, | ||
175 | - * in the extremely unlikely case we're performing this operation | ||
176 | - * on I/O memory, it may succeed but not bring in the TLB entry. | ||
177 | - * But even then we have still made forward progress. | ||
178 | - */ | ||
179 | - tlb_fn(env, &scratch, reg_off, addr + mem_off, retaddr); | ||
180 | - reg_off += 1 << esz; | ||
181 | - } | ||
182 | -#endif | ||
183 | + do { | ||
184 | + uint64_t pg = vg[reg_off >> 6]; | ||
185 | + do { | ||
186 | + if ((pg >> (reg_off & 63)) & 1) { | ||
187 | + tlb_fn(env, &scratch, reg_off, addr + mem_off, retaddr); | ||
188 | + } | ||
189 | + reg_off += 1 << esz; | ||
190 | + mem_off += 1 << msz; | ||
191 | + } while (reg_off & 63); | ||
192 | + } while (reg_off <= reg_last); | ||
193 | |||
194 | - memcpy(vd, &scratch, reg_max); | ||
195 | + memcpy(vd, &scratch, reg_max); | ||
196 | + return; | ||
197 | +#endif | ||
198 | + } | ||
199 | + | ||
200 | + /* The entire operation is in RAM, on valid pages. */ | ||
201 | + | ||
202 | + memset(vd, 0, reg_max); | ||
203 | + mem_off = info.mem_off_first[0]; | ||
204 | + reg_off = info.reg_off_first[0]; | ||
205 | + reg_last = info.reg_off_last[0]; | ||
206 | + host = info.page[0].host; | ||
207 | + | ||
208 | + while (reg_off <= reg_last) { | ||
209 | + uint64_t pg = vg[reg_off >> 6]; | ||
210 | + do { | ||
211 | + if ((pg >> (reg_off & 63)) & 1) { | ||
212 | + host_fn(vd, reg_off, host + mem_off); | ||
213 | + } | ||
214 | + reg_off += 1 << esz; | ||
215 | + mem_off += 1 << msz; | ||
216 | + } while (reg_off <= reg_last && (reg_off & 63)); | ||
217 | + } | ||
218 | + | ||
219 | + /* | ||
220 | + * Use the slow path to manage the cross-page misalignment. | ||
221 | + * But we know this is RAM and cannot trap. | ||
222 | + */ | ||
223 | + mem_off = info.mem_off_split; | ||
224 | + if (unlikely(mem_off >= 0)) { | ||
225 | + tlb_fn(env, vd, info.reg_off_split, addr + mem_off, retaddr); | ||
226 | + } | ||
227 | + | ||
228 | + mem_off = info.mem_off_first[1]; | ||
229 | + if (unlikely(mem_off >= 0)) { | ||
230 | + reg_off = info.reg_off_first[1]; | ||
231 | + reg_last = info.reg_off_last[1]; | ||
232 | + host = info.page[1].host; | ||
233 | + | ||
234 | + do { | ||
235 | + uint64_t pg = vg[reg_off >> 6]; | ||
236 | + do { | ||
237 | + if ((pg >> (reg_off & 63)) & 1) { | ||
238 | + host_fn(vd, reg_off, host + mem_off); | ||
239 | + } | ||
240 | + reg_off += 1 << esz; | ||
241 | + mem_off += 1 << msz; | ||
242 | + } while (reg_off & 63); | ||
243 | + } while (reg_off <= reg_last); | ||
244 | + } | ||
245 | } | ||
246 | |||
247 | #define DO_LD1_1(NAME, ESZ) \ | ||
248 | -- | 256 | -- |
249 | 2.20.1 | 257 | 2.25.1 |
250 | |||
251 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Follow the model set up for contiguous loads. This handles | 3 | Standardize on g_assert_not_reached() for "should not happen". |
4 | watchpoints correctly for contiguous stores, recognizing the | 4 | Retain abort() when preceeded by fprintf or error_report. |
5 | exception before any changes to memory. | ||
6 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20220501055028.646596-7-richard.henderson@linaro.org |
9 | Message-id: 20200508154359.7494-16-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/sve_helper.c | 285 ++++++++++++++++++++++------------------ | 11 | target/arm/helper.c | 7 +++---- |
13 | 1 file changed, 159 insertions(+), 126 deletions(-) | 12 | target/arm/hvf/hvf.c | 2 +- |
13 | target/arm/kvm-stub.c | 4 ++-- | ||
14 | target/arm/kvm.c | 4 ++-- | ||
15 | target/arm/machine.c | 4 ++-- | ||
16 | target/arm/translate-a64.c | 4 ++-- | ||
17 | target/arm/translate-neon.c | 2 +- | ||
18 | target/arm/translate.c | 4 ++-- | ||
19 | 8 files changed, 15 insertions(+), 16 deletions(-) | ||
14 | 20 | ||
15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 21 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/sve_helper.c | 23 | --- a/target/arm/helper.c |
18 | +++ b/target/arm/sve_helper.c | 24 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ | 25 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
20 | *(TYPEE *)(vd + H(reg_off)) = val; \ | 26 | break; |
27 | default: | ||
28 | /* broken reginfo with out-of-range opc1 */ | ||
29 | - assert(false); | ||
30 | - break; | ||
31 | + g_assert_not_reached(); | ||
32 | } | ||
33 | /* assert our permissions are not too lax (stricter is fine) */ | ||
34 | assert((r->access & ~mask) == 0); | ||
35 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
36 | break; | ||
37 | default: | ||
38 | /* Never happens, but compiler isn't smart enough to tell. */ | ||
39 | - abort(); | ||
40 | + g_assert_not_reached(); | ||
41 | } | ||
42 | } | ||
43 | *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
45 | break; | ||
46 | default: | ||
47 | /* Never happens, but compiler isn't smart enough to tell. */ | ||
48 | - abort(); | ||
49 | + g_assert_not_reached(); | ||
50 | } | ||
51 | } | ||
52 | if (domain_prot == 3) { | ||
53 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/hvf/hvf.c | ||
56 | +++ b/target/arm/hvf/hvf.c | ||
57 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
58 | /* we got kicked, no exit to process */ | ||
59 | return 0; | ||
60 | default: | ||
61 | - assert(0); | ||
62 | + g_assert_not_reached(); | ||
63 | } | ||
64 | |||
65 | hvf_sync_vtimer(cpu); | ||
66 | diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/kvm-stub.c | ||
69 | +++ b/target/arm/kvm-stub.c | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | |||
72 | bool write_kvmstate_to_list(ARMCPU *cpu) | ||
73 | { | ||
74 | - abort(); | ||
75 | + g_assert_not_reached(); | ||
21 | } | 76 | } |
22 | 77 | ||
23 | +#define DO_ST_HOST(NAME, H, TYPEE, TYPEM, HOST) \ | 78 | bool write_list_to_kvmstate(ARMCPU *cpu, int level) |
24 | +static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ | ||
25 | +{ HOST(host, (TYPEM)*(TYPEE *)(vd + H(reg_off))); } | ||
26 | + | ||
27 | #define DO_LD_TLB(NAME, H, TYPEE, TYPEM, TLB) \ | ||
28 | static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ | ||
29 | target_ulong addr, uintptr_t ra) \ | ||
30 | @@ -XXX,XX +XXX,XX @@ DO_LD_PRIM_1(ld1bdu, , uint64_t, uint8_t) | ||
31 | DO_LD_PRIM_1(ld1bds, , uint64_t, int8_t) | ||
32 | |||
33 | #define DO_ST_PRIM_1(NAME, H, TE, TM) \ | ||
34 | + DO_ST_HOST(st1##NAME, H, TE, TM, stb_p) \ | ||
35 | DO_ST_TLB(st1##NAME, H, TE, TM, cpu_stb_data_ra) | ||
36 | |||
37 | DO_ST_PRIM_1(bb, H1, uint8_t, uint8_t) | ||
38 | @@ -XXX,XX +XXX,XX @@ DO_ST_PRIM_1(bd, , uint64_t, uint8_t) | ||
39 | DO_LD_TLB(ld1##NAME##_le, H, TE, TM, cpu_##LD##_le_data_ra) | ||
40 | |||
41 | #define DO_ST_PRIM_2(NAME, H, TE, TM, ST) \ | ||
42 | + DO_ST_HOST(st1##NAME##_be, H, TE, TM, ST##_be_p) \ | ||
43 | + DO_ST_HOST(st1##NAME##_le, H, TE, TM, ST##_le_p) \ | ||
44 | DO_ST_TLB(st1##NAME##_be, H, TE, TM, cpu_##ST##_be_data_ra) \ | ||
45 | DO_ST_TLB(st1##NAME##_le, H, TE, TM, cpu_##ST##_le_data_ra) | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ DO_LDFF1_LDNF1_2(dd, MO_64, MO_64) | ||
48 | #undef DO_LDFF1_LDNF1_2 | ||
49 | |||
50 | /* | ||
51 | - * Common helpers for all contiguous 1,2,3,4-register predicated stores. | ||
52 | + * Common helper for all contiguous 1,2,3,4-register predicated stores. | ||
53 | */ | ||
54 | -static void sve_st1_r(CPUARMState *env, void *vg, target_ulong addr, | ||
55 | - uint32_t desc, const uintptr_t ra, | ||
56 | - const int esize, const int msize, | ||
57 | - sve_ldst1_tlb_fn *tlb_fn) | ||
58 | + | ||
59 | +static inline QEMU_ALWAYS_INLINE | ||
60 | +void sve_stN_r(CPUARMState *env, uint64_t *vg, target_ulong addr, uint32_t desc, | ||
61 | + const uintptr_t retaddr, const int esz, | ||
62 | + const int msz, const int N, | ||
63 | + sve_ldst1_host_fn *host_fn, | ||
64 | + sve_ldst1_tlb_fn *tlb_fn) | ||
65 | { | 79 | { |
66 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | 80 | - abort(); |
67 | - intptr_t i, oprsz = simd_oprsz(desc); | 81 | + g_assert_not_reached(); |
68 | - void *vd = &env->vfp.zregs[rd]; | 82 | } |
69 | + const intptr_t reg_max = simd_oprsz(desc); | 83 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
70 | + intptr_t reg_off, reg_last, mem_off; | 84 | index XXXXXXX..XXXXXXX 100644 |
71 | + SVEContLdSt info; | 85 | --- a/target/arm/kvm.c |
72 | + void *host; | 86 | +++ b/target/arm/kvm.c |
73 | + int i, flags; | 87 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu) |
74 | 88 | ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); | |
75 | - for (i = 0; i < oprsz; ) { | 89 | break; |
76 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | 90 | default: |
77 | - do { | 91 | - abort(); |
78 | - if (pg & 1) { | 92 | + g_assert_not_reached(); |
79 | - tlb_fn(env, vd, i, addr, ra); | 93 | } |
80 | + /* Find the active elements. */ | 94 | if (ret) { |
81 | + if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, N << msz)) { | 95 | ok = false; |
82 | + /* The entire predicate was false; no store occurs. */ | 96 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) |
83 | + return; | 97 | r.addr = (uintptr_t)(cpu->cpreg_values + i); |
84 | + } | 98 | break; |
85 | + | 99 | default: |
86 | + /* Probe the page(s). Exit with exception for any invalid page. */ | 100 | - abort(); |
87 | + sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_STORE, retaddr); | 101 | + g_assert_not_reached(); |
88 | + | 102 | } |
89 | + /* Handle watchpoints for all active elements. */ | 103 | ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r); |
90 | + sve_cont_ldst_watchpoints(&info, env, vg, addr, 1 << esz, N << msz, | 104 | if (ret) { |
91 | + BP_MEM_WRITE, retaddr); | 105 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
92 | + | 106 | index XXXXXXX..XXXXXXX 100644 |
93 | + /* TODO: MTE check. */ | 107 | --- a/target/arm/machine.c |
94 | + | 108 | +++ b/target/arm/machine.c |
95 | + flags = info.page[0].flags | info.page[1].flags; | 109 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) |
96 | + if (unlikely(flags != 0)) { | 110 | if (kvm_enabled()) { |
97 | +#ifdef CONFIG_USER_ONLY | 111 | if (!write_kvmstate_to_list(cpu)) { |
112 | /* This should never fail */ | ||
113 | - abort(); | ||
114 | + g_assert_not_reached(); | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | ||
119 | } else { | ||
120 | if (!write_cpustate_to_list(cpu, false)) { | ||
121 | /* This should never fail. */ | ||
122 | - abort(); | ||
123 | + g_assert_not_reached(); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
128 | index XXXXXXX..XXXXXXX 100644 | ||
129 | --- a/target/arm/translate-a64.c | ||
130 | +++ b/target/arm/translate-a64.c | ||
131 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) | ||
132 | gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst); | ||
133 | break; | ||
134 | default: | ||
135 | - abort(); | ||
98 | + g_assert_not_reached(); | 136 | + g_assert_not_reached(); |
99 | +#else | 137 | } |
100 | + /* | 138 | |
101 | + * At least one page includes MMIO. | 139 | write_fp_sreg(s, rd, tcg_res); |
102 | + * Any bus operation can fail with cpu_transaction_failed, | 140 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_fcvt(DisasContext *s, int opcode, |
103 | + * which for ARM will raise SyncExternal. We cannot avoid | 141 | break; |
104 | + * this fault and will leave with the store incomplete. | 142 | } |
105 | + */ | 143 | default: |
106 | + mem_off = info.mem_off_first[0]; | 144 | - abort(); |
107 | + reg_off = info.reg_off_first[0]; | 145 | + g_assert_not_reached(); |
108 | + reg_last = info.reg_off_last[1]; | ||
109 | + if (reg_last < 0) { | ||
110 | + reg_last = info.reg_off_split; | ||
111 | + if (reg_last < 0) { | ||
112 | + reg_last = info.reg_off_last[0]; | ||
113 | } | ||
114 | - i += esize, pg >>= esize; | ||
115 | - addr += msize; | ||
116 | - } while (i & 15); | ||
117 | + } | ||
118 | + | ||
119 | + do { | ||
120 | + uint64_t pg = vg[reg_off >> 6]; | ||
121 | + do { | ||
122 | + if ((pg >> (reg_off & 63)) & 1) { | ||
123 | + for (i = 0; i < N; ++i) { | ||
124 | + tlb_fn(env, &env->vfp.zregs[(rd + i) & 31], reg_off, | ||
125 | + addr + mem_off + (i << msz), retaddr); | ||
126 | + } | ||
127 | + } | ||
128 | + reg_off += 1 << esz; | ||
129 | + mem_off += N << msz; | ||
130 | + } while (reg_off & 63); | ||
131 | + } while (reg_off <= reg_last); | ||
132 | + return; | ||
133 | +#endif | ||
134 | + } | ||
135 | + | ||
136 | + mem_off = info.mem_off_first[0]; | ||
137 | + reg_off = info.reg_off_first[0]; | ||
138 | + reg_last = info.reg_off_last[0]; | ||
139 | + host = info.page[0].host; | ||
140 | + | ||
141 | + while (reg_off <= reg_last) { | ||
142 | + uint64_t pg = vg[reg_off >> 6]; | ||
143 | + do { | ||
144 | + if ((pg >> (reg_off & 63)) & 1) { | ||
145 | + for (i = 0; i < N; ++i) { | ||
146 | + host_fn(&env->vfp.zregs[(rd + i) & 31], reg_off, | ||
147 | + host + mem_off + (i << msz)); | ||
148 | + } | ||
149 | + } | ||
150 | + reg_off += 1 << esz; | ||
151 | + mem_off += N << msz; | ||
152 | + } while (reg_off <= reg_last && (reg_off & 63)); | ||
153 | + } | ||
154 | + | ||
155 | + /* | ||
156 | + * Use the slow path to manage the cross-page misalignment. | ||
157 | + * But we know this is RAM and cannot trap. | ||
158 | + */ | ||
159 | + mem_off = info.mem_off_split; | ||
160 | + if (unlikely(mem_off >= 0)) { | ||
161 | + reg_off = info.reg_off_split; | ||
162 | + for (i = 0; i < N; ++i) { | ||
163 | + tlb_fn(env, &env->vfp.zregs[(rd + i) & 31], reg_off, | ||
164 | + addr + mem_off + (i << msz), retaddr); | ||
165 | + } | ||
166 | + } | ||
167 | + | ||
168 | + mem_off = info.mem_off_first[1]; | ||
169 | + if (unlikely(mem_off >= 0)) { | ||
170 | + reg_off = info.reg_off_first[1]; | ||
171 | + reg_last = info.reg_off_last[1]; | ||
172 | + host = info.page[1].host; | ||
173 | + | ||
174 | + do { | ||
175 | + uint64_t pg = vg[reg_off >> 6]; | ||
176 | + do { | ||
177 | + if ((pg >> (reg_off & 63)) & 1) { | ||
178 | + for (i = 0; i < N; ++i) { | ||
179 | + host_fn(&env->vfp.zregs[(rd + i) & 31], reg_off, | ||
180 | + host + mem_off + (i << msz)); | ||
181 | + } | ||
182 | + } | ||
183 | + reg_off += 1 << esz; | ||
184 | + mem_off += N << msz; | ||
185 | + } while (reg_off & 63); | ||
186 | + } while (reg_off <= reg_last); | ||
187 | } | 146 | } |
188 | } | 147 | } |
189 | 148 | ||
190 | -static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, | 149 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c |
191 | - uint32_t desc, const uintptr_t ra, | 150 | index XXXXXXX..XXXXXXX 100644 |
192 | - const int esize, const int msize, | 151 | --- a/target/arm/translate-neon.c |
193 | - sve_ldst1_tlb_fn *tlb_fn) | 152 | +++ b/target/arm/translate-neon.c |
194 | -{ | 153 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) |
195 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | 154 | } |
196 | - intptr_t i, oprsz = simd_oprsz(desc); | 155 | break; |
197 | - void *d1 = &env->vfp.zregs[rd]; | 156 | default: |
198 | - void *d2 = &env->vfp.zregs[(rd + 1) & 31]; | 157 | - abort(); |
199 | - | 158 | + g_assert_not_reached(); |
200 | - for (i = 0; i < oprsz; ) { | 159 | } |
201 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | 160 | if ((vd + a->stride * (nregs - 1)) > 31) { |
202 | - do { | 161 | /* |
203 | - if (pg & 1) { | 162 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
204 | - tlb_fn(env, d1, i, addr, ra); | 163 | index XXXXXXX..XXXXXXX 100644 |
205 | - tlb_fn(env, d2, i, addr + msize, ra); | 164 | --- a/target/arm/translate.c |
206 | - } | 165 | +++ b/target/arm/translate.c |
207 | - i += esize, pg >>= esize; | 166 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, |
208 | - addr += 2 * msize; | 167 | offset = 4; |
209 | - } while (i & 15); | 168 | break; |
210 | - } | 169 | default: |
211 | -} | 170 | - abort(); |
212 | - | 171 | + g_assert_not_reached(); |
213 | -static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, | 172 | } |
214 | - uint32_t desc, const uintptr_t ra, | 173 | tcg_gen_addi_i32(addr, addr, offset); |
215 | - const int esize, const int msize, | 174 | tmp = load_reg(s, 14); |
216 | - sve_ldst1_tlb_fn *tlb_fn) | 175 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, |
217 | -{ | 176 | offset = 0; |
218 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | 177 | break; |
219 | - intptr_t i, oprsz = simd_oprsz(desc); | 178 | default: |
220 | - void *d1 = &env->vfp.zregs[rd]; | 179 | - abort(); |
221 | - void *d2 = &env->vfp.zregs[(rd + 1) & 31]; | 180 | + g_assert_not_reached(); |
222 | - void *d3 = &env->vfp.zregs[(rd + 2) & 31]; | 181 | } |
223 | - | 182 | tcg_gen_addi_i32(addr, addr, offset); |
224 | - for (i = 0; i < oprsz; ) { | 183 | gen_helper_set_r13_banked(cpu_env, tcg_constant_i32(mode), addr); |
225 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
226 | - do { | ||
227 | - if (pg & 1) { | ||
228 | - tlb_fn(env, d1, i, addr, ra); | ||
229 | - tlb_fn(env, d2, i, addr + msize, ra); | ||
230 | - tlb_fn(env, d3, i, addr + 2 * msize, ra); | ||
231 | - } | ||
232 | - i += esize, pg >>= esize; | ||
233 | - addr += 3 * msize; | ||
234 | - } while (i & 15); | ||
235 | - } | ||
236 | -} | ||
237 | - | ||
238 | -static void sve_st4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
239 | - uint32_t desc, const uintptr_t ra, | ||
240 | - const int esize, const int msize, | ||
241 | - sve_ldst1_tlb_fn *tlb_fn) | ||
242 | -{ | ||
243 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
244 | - intptr_t i, oprsz = simd_oprsz(desc); | ||
245 | - void *d1 = &env->vfp.zregs[rd]; | ||
246 | - void *d2 = &env->vfp.zregs[(rd + 1) & 31]; | ||
247 | - void *d3 = &env->vfp.zregs[(rd + 2) & 31]; | ||
248 | - void *d4 = &env->vfp.zregs[(rd + 3) & 31]; | ||
249 | - | ||
250 | - for (i = 0; i < oprsz; ) { | ||
251 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
252 | - do { | ||
253 | - if (pg & 1) { | ||
254 | - tlb_fn(env, d1, i, addr, ra); | ||
255 | - tlb_fn(env, d2, i, addr + msize, ra); | ||
256 | - tlb_fn(env, d3, i, addr + 2 * msize, ra); | ||
257 | - tlb_fn(env, d4, i, addr + 3 * msize, ra); | ||
258 | - } | ||
259 | - i += esize, pg >>= esize; | ||
260 | - addr += 4 * msize; | ||
261 | - } while (i & 15); | ||
262 | - } | ||
263 | -} | ||
264 | - | ||
265 | -#define DO_STN_1(N, NAME, ESIZE) \ | ||
266 | -void QEMU_FLATTEN HELPER(sve_st##N##NAME##_r) \ | ||
267 | - (CPUARMState *env, void *vg, target_ulong addr, uint32_t desc) \ | ||
268 | +#define DO_STN_1(N, NAME, ESZ) \ | ||
269 | +void HELPER(sve_st##N##NAME##_r)(CPUARMState *env, void *vg, \ | ||
270 | + target_ulong addr, uint32_t desc) \ | ||
271 | { \ | ||
272 | - sve_st##N##_r(env, vg, addr, desc, GETPC(), ESIZE, 1, \ | ||
273 | - sve_st1##NAME##_tlb); \ | ||
274 | + sve_stN_r(env, vg, addr, desc, GETPC(), ESZ, MO_8, N, \ | ||
275 | + sve_st1##NAME##_host, sve_st1##NAME##_tlb); \ | ||
276 | } | ||
277 | |||
278 | -#define DO_STN_2(N, NAME, ESIZE, MSIZE) \ | ||
279 | -void QEMU_FLATTEN HELPER(sve_st##N##NAME##_le_r) \ | ||
280 | - (CPUARMState *env, void *vg, target_ulong addr, uint32_t desc) \ | ||
281 | +#define DO_STN_2(N, NAME, ESZ, MSZ) \ | ||
282 | +void HELPER(sve_st##N##NAME##_le_r)(CPUARMState *env, void *vg, \ | ||
283 | + target_ulong addr, uint32_t desc) \ | ||
284 | { \ | ||
285 | - sve_st##N##_r(env, vg, addr, desc, GETPC(), ESIZE, MSIZE, \ | ||
286 | - sve_st1##NAME##_le_tlb); \ | ||
287 | + sve_stN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, N, \ | ||
288 | + sve_st1##NAME##_le_host, sve_st1##NAME##_le_tlb); \ | ||
289 | } \ | ||
290 | -void QEMU_FLATTEN HELPER(sve_st##N##NAME##_be_r) \ | ||
291 | - (CPUARMState *env, void *vg, target_ulong addr, uint32_t desc) \ | ||
292 | +void HELPER(sve_st##N##NAME##_be_r)(CPUARMState *env, void *vg, \ | ||
293 | + target_ulong addr, uint32_t desc) \ | ||
294 | { \ | ||
295 | - sve_st##N##_r(env, vg, addr, desc, GETPC(), ESIZE, MSIZE, \ | ||
296 | - sve_st1##NAME##_be_tlb); \ | ||
297 | + sve_stN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, N, \ | ||
298 | + sve_st1##NAME##_be_host, sve_st1##NAME##_be_tlb); \ | ||
299 | } | ||
300 | |||
301 | -DO_STN_1(1, bb, 1) | ||
302 | -DO_STN_1(1, bh, 2) | ||
303 | -DO_STN_1(1, bs, 4) | ||
304 | -DO_STN_1(1, bd, 8) | ||
305 | -DO_STN_1(2, bb, 1) | ||
306 | -DO_STN_1(3, bb, 1) | ||
307 | -DO_STN_1(4, bb, 1) | ||
308 | +DO_STN_1(1, bb, MO_8) | ||
309 | +DO_STN_1(1, bh, MO_16) | ||
310 | +DO_STN_1(1, bs, MO_32) | ||
311 | +DO_STN_1(1, bd, MO_64) | ||
312 | +DO_STN_1(2, bb, MO_8) | ||
313 | +DO_STN_1(3, bb, MO_8) | ||
314 | +DO_STN_1(4, bb, MO_8) | ||
315 | |||
316 | -DO_STN_2(1, hh, 2, 2) | ||
317 | -DO_STN_2(1, hs, 4, 2) | ||
318 | -DO_STN_2(1, hd, 8, 2) | ||
319 | -DO_STN_2(2, hh, 2, 2) | ||
320 | -DO_STN_2(3, hh, 2, 2) | ||
321 | -DO_STN_2(4, hh, 2, 2) | ||
322 | +DO_STN_2(1, hh, MO_16, MO_16) | ||
323 | +DO_STN_2(1, hs, MO_32, MO_16) | ||
324 | +DO_STN_2(1, hd, MO_64, MO_16) | ||
325 | +DO_STN_2(2, hh, MO_16, MO_16) | ||
326 | +DO_STN_2(3, hh, MO_16, MO_16) | ||
327 | +DO_STN_2(4, hh, MO_16, MO_16) | ||
328 | |||
329 | -DO_STN_2(1, ss, 4, 4) | ||
330 | -DO_STN_2(1, sd, 8, 4) | ||
331 | -DO_STN_2(2, ss, 4, 4) | ||
332 | -DO_STN_2(3, ss, 4, 4) | ||
333 | -DO_STN_2(4, ss, 4, 4) | ||
334 | +DO_STN_2(1, ss, MO_32, MO_32) | ||
335 | +DO_STN_2(1, sd, MO_64, MO_32) | ||
336 | +DO_STN_2(2, ss, MO_32, MO_32) | ||
337 | +DO_STN_2(3, ss, MO_32, MO_32) | ||
338 | +DO_STN_2(4, ss, MO_32, MO_32) | ||
339 | |||
340 | -DO_STN_2(1, dd, 8, 8) | ||
341 | -DO_STN_2(2, dd, 8, 8) | ||
342 | -DO_STN_2(3, dd, 8, 8) | ||
343 | -DO_STN_2(4, dd, 8, 8) | ||
344 | +DO_STN_2(1, dd, MO_64, MO_64) | ||
345 | +DO_STN_2(2, dd, MO_64, MO_64) | ||
346 | +DO_STN_2(3, dd, MO_64, MO_64) | ||
347 | +DO_STN_2(4, dd, MO_64, MO_64) | ||
348 | |||
349 | #undef DO_STN_1 | ||
350 | #undef DO_STN_2 | ||
351 | -- | 184 | -- |
352 | 2.20.1 | 185 | 2.25.1 |
353 | |||
354 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | None of the sve helpers use TCGMemOpIdx any longer, so we can | 3 | Create a typedef as well, and use it in ARMCPRegInfo. |
4 | stop passing it. | 4 | This won't be perfect for debugging, but it'll nicely |
5 | display the most common cases. | ||
5 | 6 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200508154359.7494-20-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-8-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/internals.h | 5 ----- | 12 | target/arm/cpregs.h | 44 +++++++++++++++++++++++--------------------- |
12 | target/arm/sve_helper.c | 14 +++++++------- | 13 | target/arm/helper.c | 2 +- |
13 | target/arm/translate-sve.c | 17 +++-------------- | 14 | 2 files changed, 24 insertions(+), 22 deletions(-) |
14 | 3 files changed, 10 insertions(+), 26 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/internals.h | 18 | --- a/target/arm/cpregs.h |
19 | +++ b/target/arm/internals.h | 19 | +++ b/target/arm/cpregs.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline int arm_num_ctx_cmps(ARMCPU *cpu) | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
21 | } | 21 | * described with these bits, then use a laxer set of restrictions, and |
22 | } | 22 | * do the more restrictive/complex check inside a helper function. |
23 | 23 | */ | |
24 | -/* Note make_memop_idx reserves 4 bits for mmu_idx, and MO_BSWAP is bit 3. | 24 | -#define PL3_R 0x80 |
25 | - * Thus a TCGMemOpIdx, without any MO_ALIGN bits, fits in 8 bits. | 25 | -#define PL3_W 0x40 |
26 | -#define PL2_R (0x20 | PL3_R) | ||
27 | -#define PL2_W (0x10 | PL3_W) | ||
28 | -#define PL1_R (0x08 | PL2_R) | ||
29 | -#define PL1_W (0x04 | PL2_W) | ||
30 | -#define PL0_R (0x02 | PL1_R) | ||
31 | -#define PL0_W (0x01 | PL1_W) | ||
32 | +typedef enum { | ||
33 | + PL3_R = 0x80, | ||
34 | + PL3_W = 0x40, | ||
35 | + PL2_R = 0x20 | PL3_R, | ||
36 | + PL2_W = 0x10 | PL3_W, | ||
37 | + PL1_R = 0x08 | PL2_R, | ||
38 | + PL1_W = 0x04 | PL2_W, | ||
39 | + PL0_R = 0x02 | PL1_R, | ||
40 | + PL0_W = 0x01 | PL1_W, | ||
41 | |||
42 | -/* | ||
43 | - * For user-mode some registers are accessible to EL0 via a kernel | ||
44 | - * trap-and-emulate ABI. In this case we define the read permissions | ||
45 | - * as actually being PL0_R. However some bits of any given register | ||
46 | - * may still be masked. | ||
26 | - */ | 47 | - */ |
27 | -#define MEMOPIDX_SHIFT 8 | 48 | + /* |
28 | - | 49 | + * For user-mode some registers are accessible to EL0 via a kernel |
29 | /** | 50 | + * trap-and-emulate ABI. In this case we define the read permissions |
30 | * v7m_using_psp: Return true if using process stack pointer | 51 | + * as actually being PL0_R. However some bits of any given register |
31 | * Return true if the CPU is currently using the process stack | 52 | + * may still be masked. |
32 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 53 | + */ |
54 | #ifdef CONFIG_USER_ONLY | ||
55 | -#define PL0U_R PL0_R | ||
56 | + PL0U_R = PL0_R, | ||
57 | #else | ||
58 | -#define PL0U_R PL1_R | ||
59 | + PL0U_R = PL1_R, | ||
60 | #endif | ||
61 | |||
62 | -#define PL3_RW (PL3_R | PL3_W) | ||
63 | -#define PL2_RW (PL2_R | PL2_W) | ||
64 | -#define PL1_RW (PL1_R | PL1_W) | ||
65 | -#define PL0_RW (PL0_R | PL0_W) | ||
66 | + PL3_RW = PL3_R | PL3_W, | ||
67 | + PL2_RW = PL2_R | PL2_W, | ||
68 | + PL1_RW = PL1_R | PL1_W, | ||
69 | + PL0_RW = PL0_R | PL0_W, | ||
70 | +} CPAccessRights; | ||
71 | |||
72 | typedef enum CPAccessResult { | ||
73 | /* Access is permitted */ | ||
74 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
75 | /* Register type: ARM_CP_* bits/values */ | ||
76 | int type; | ||
77 | /* Access rights: PL*_[RW] */ | ||
78 | - int access; | ||
79 | + CPAccessRights access; | ||
80 | /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
81 | int secure; | ||
82 | /* | ||
83 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 84 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/sve_helper.c | 85 | --- a/target/arm/helper.c |
35 | +++ b/target/arm/sve_helper.c | 86 | +++ b/target/arm/helper.c |
36 | @@ -XXX,XX +XXX,XX @@ void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | 87 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
37 | sve_ldst1_host_fn *host_fn, | 88 | * to encompass the generic architectural permission check. |
38 | sve_ldst1_tlb_fn *tlb_fn) | ||
39 | { | ||
40 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
41 | + const unsigned rd = simd_data(desc); | ||
42 | const intptr_t reg_max = simd_oprsz(desc); | ||
43 | intptr_t reg_off, reg_last, mem_off; | ||
44 | SVEContLdSt info; | ||
45 | @@ -XXX,XX +XXX,XX @@ void sve_ldnfff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
46 | sve_ldst1_host_fn *host_fn, | ||
47 | sve_ldst1_tlb_fn *tlb_fn) | ||
48 | { | ||
49 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
50 | + const unsigned rd = simd_data(desc); | ||
51 | void *vd = &env->vfp.zregs[rd]; | ||
52 | const intptr_t reg_max = simd_oprsz(desc); | ||
53 | intptr_t reg_off, mem_off, reg_last; | ||
54 | @@ -XXX,XX +XXX,XX @@ void sve_stN_r(CPUARMState *env, uint64_t *vg, target_ulong addr, uint32_t desc, | ||
55 | sve_ldst1_host_fn *host_fn, | ||
56 | sve_ldst1_tlb_fn *tlb_fn) | ||
57 | { | ||
58 | - const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
59 | + const unsigned rd = simd_data(desc); | ||
60 | const intptr_t reg_max = simd_oprsz(desc); | ||
61 | intptr_t reg_off, reg_last, mem_off; | ||
62 | SVEContLdSt info; | ||
63 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
64 | sve_ldst1_host_fn *host_fn, | ||
65 | sve_ldst1_tlb_fn *tlb_fn) | ||
66 | { | ||
67 | - const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
68 | const int mmu_idx = cpu_mmu_index(env, false); | ||
69 | const intptr_t reg_max = simd_oprsz(desc); | ||
70 | + const int scale = simd_data(desc); | ||
71 | ARMVectorReg scratch; | ||
72 | intptr_t reg_off; | ||
73 | SVEHostPage info, info2; | ||
74 | @@ -XXX,XX +XXX,XX @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
75 | sve_ldst1_tlb_fn *tlb_fn) | ||
76 | { | ||
77 | const int mmu_idx = cpu_mmu_index(env, false); | ||
78 | - const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
79 | + const intptr_t reg_max = simd_oprsz(desc); | ||
80 | + const int scale = simd_data(desc); | ||
81 | const int esize = 1 << esz; | ||
82 | const int msize = 1 << msz; | ||
83 | - const intptr_t reg_max = simd_oprsz(desc); | ||
84 | intptr_t reg_off; | ||
85 | SVEHostPage info; | ||
86 | target_ulong addr, in_page; | ||
87 | @@ -XXX,XX +XXX,XX @@ void sve_st1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
88 | sve_ldst1_host_fn *host_fn, | ||
89 | sve_ldst1_tlb_fn *tlb_fn) | ||
90 | { | ||
91 | - const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
92 | const int mmu_idx = cpu_mmu_index(env, false); | ||
93 | const intptr_t reg_max = simd_oprsz(desc); | ||
94 | + const int scale = simd_data(desc); | ||
95 | void *host[ARM_MAX_VQ * 4]; | ||
96 | intptr_t reg_off, i; | ||
97 | SVEHostPage info, info2; | ||
98 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/translate-sve.c | ||
101 | +++ b/target/arm/translate-sve.c | ||
102 | @@ -XXX,XX +XXX,XX @@ static const uint8_t dtype_esz[16] = { | ||
103 | 3, 2, 1, 3 | ||
104 | }; | ||
105 | |||
106 | -static TCGMemOpIdx sve_memopidx(DisasContext *s, int dtype) | ||
107 | -{ | ||
108 | - return make_memop_idx(s->be_data | dtype_mop[dtype], get_mem_index(s)); | ||
109 | -} | ||
110 | - | ||
111 | static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
112 | int dtype, gen_helper_gvec_mem *fn) | ||
113 | { | ||
114 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
115 | * registers as pointers, so encode the regno into the data field. | ||
116 | * For consistency, do this even for LD1. | ||
117 | */ | 89 | */ |
118 | - desc = sve_memopidx(s, dtype); | 90 | if (r->state != ARM_CP_STATE_AA32) { |
119 | - desc |= zt << MEMOPIDX_SHIFT; | 91 | - int mask = 0; |
120 | - desc = simd_desc(vsz, vsz, desc); | 92 | + CPAccessRights mask; |
121 | + desc = simd_desc(vsz, vsz, zt); | 93 | switch (r->opc1) { |
122 | t_desc = tcg_const_i32(desc); | 94 | case 0: |
123 | t_pg = tcg_temp_new_ptr(); | 95 | /* min_EL EL1, but some accessible to EL0 via kernel ABI */ |
124 | |||
125 | @@ -XXX,XX +XXX,XX @@ static void do_ldrq(DisasContext *s, int zt, int pg, TCGv_i64 addr, int msz) | ||
126 | int desc, poff; | ||
127 | |||
128 | /* Load the first quadword using the normal predicated load helpers. */ | ||
129 | - desc = sve_memopidx(s, msz_dtype(s, msz)); | ||
130 | - desc |= zt << MEMOPIDX_SHIFT; | ||
131 | - desc = simd_desc(16, 16, desc); | ||
132 | + desc = simd_desc(16, 16, zt); | ||
133 | t_desc = tcg_const_i32(desc); | ||
134 | |||
135 | poff = pred_full_reg_offset(s, pg); | ||
136 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpz(DisasContext *s, int zt, int pg, int zm, | ||
137 | TCGv_i32 t_desc; | ||
138 | int desc; | ||
139 | |||
140 | - desc = sve_memopidx(s, msz_dtype(s, msz)); | ||
141 | - desc |= scale << MEMOPIDX_SHIFT; | ||
142 | - desc = simd_desc(vsz, vsz, desc); | ||
143 | + desc = simd_desc(vsz, vsz, scale); | ||
144 | t_desc = tcg_const_i32(desc); | ||
145 | |||
146 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg)); | ||
147 | -- | 96 | -- |
148 | 2.20.1 | 97 | 2.25.1 |
149 | |||
150 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Give this enum a name and use in ARMCPRegInfo, | ||
4 | add_cpreg_to_hashtable and define_one_arm_cp_reg_with_opaque. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20200508154359.7494-19-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-9-richard.henderson@linaro.org |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | target/arm/sve_helper.c | 208 +++++++++++++++++++++------------------- | 12 | target/arm/cpregs.h | 6 +++--- |
9 | 1 file changed, 109 insertions(+), 99 deletions(-) | 13 | target/arm/helper.c | 6 ++++-- |
14 | 2 files changed, 7 insertions(+), 5 deletions(-) | ||
10 | 15 | ||
11 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
12 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/sve_helper.c | 18 | --- a/target/arm/cpregs.h |
14 | +++ b/target/arm/sve_helper.c | 19 | +++ b/target/arm/cpregs.h |
15 | @@ -XXX,XX +XXX,XX @@ static target_ulong off_zd_d(void *reg, intptr_t reg_ofs) | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
16 | return *(uint64_t *)(reg + reg_ofs); | 21 | * Note that we rely on the values of these enums as we iterate through |
22 | * the various states in some places. | ||
23 | */ | ||
24 | -enum { | ||
25 | +typedef enum { | ||
26 | ARM_CP_STATE_AA32 = 0, | ||
27 | ARM_CP_STATE_AA64 = 1, | ||
28 | ARM_CP_STATE_BOTH = 2, | ||
29 | -}; | ||
30 | +} CPState; | ||
31 | |||
32 | /* | ||
33 | * ARM CP register secure state flags. These flags identify security state | ||
34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
35 | uint8_t opc1; | ||
36 | uint8_t opc2; | ||
37 | /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
38 | - int state; | ||
39 | + CPState state; | ||
40 | /* Register type: ARM_CP_* bits/values */ | ||
41 | int type; | ||
42 | /* Access rights: PL*_[RW] */ | ||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper.c | ||
46 | +++ b/target/arm/helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) | ||
17 | } | 48 | } |
18 | 49 | ||
19 | -static void sve_ld1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | 50 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
20 | - target_ulong base, uint32_t desc, uintptr_t ra, | 51 | - void *opaque, int state, int secstate, |
21 | - zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn) | 52 | + void *opaque, CPState state, int secstate, |
22 | +static inline QEMU_ALWAYS_INLINE | 53 | int crm, int opc1, int opc2, |
23 | +void sve_ld1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | 54 | const char *name) |
24 | + target_ulong base, uint32_t desc, uintptr_t retaddr, | ||
25 | + int esize, int msize, zreg_off_fn *off_fn, | ||
26 | + sve_ldst1_host_fn *host_fn, | ||
27 | + sve_ldst1_tlb_fn *tlb_fn) | ||
28 | { | 55 | { |
29 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | 56 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
30 | - intptr_t i, oprsz = simd_oprsz(desc); | 57 | * bits; the ARM_CP_64BIT* flag applies only to the AArch32 view of |
31 | - ARMVectorReg scratch = { }; | 58 | * the register, if any. |
32 | + const int mmu_idx = cpu_mmu_index(env, false); | 59 | */ |
33 | + const intptr_t reg_max = simd_oprsz(desc); | 60 | - int crm, opc1, opc2, state; |
34 | + ARMVectorReg scratch; | 61 | + int crm, opc1, opc2; |
35 | + intptr_t reg_off; | 62 | int crmmin = (r->crm == CP_ANY) ? 0 : r->crm; |
36 | + SVEHostPage info, info2; | 63 | int crmmax = (r->crm == CP_ANY) ? 15 : r->crm; |
37 | 64 | int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1; | |
38 | - for (i = 0; i < oprsz; ) { | 65 | int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1; |
39 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | 66 | int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2; |
40 | + memset(&scratch, 0, reg_max); | 67 | int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2; |
41 | + reg_off = 0; | 68 | + CPState state; |
42 | + do { | ||
43 | + uint64_t pg = vg[reg_off >> 6]; | ||
44 | do { | ||
45 | if (likely(pg & 1)) { | ||
46 | - target_ulong off = off_fn(vm, i); | ||
47 | - tlb_fn(env, &scratch, i, base + (off << scale), ra); | ||
48 | + target_ulong addr = base + (off_fn(vm, reg_off) << scale); | ||
49 | + target_ulong in_page = -(addr | TARGET_PAGE_MASK); | ||
50 | + | 69 | + |
51 | + sve_probe_page(&info, false, env, addr, 0, MMU_DATA_LOAD, | 70 | /* 64 bit registers have only CRm and Opc1 fields */ |
52 | + mmu_idx, retaddr); | 71 | assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn))); |
53 | + | 72 | /* op0 only exists in the AArch64 encodings */ |
54 | + if (likely(in_page >= msize)) { | ||
55 | + if (unlikely(info.flags & TLB_WATCHPOINT)) { | ||
56 | + cpu_check_watchpoint(env_cpu(env), addr, msize, | ||
57 | + info.attrs, BP_MEM_READ, retaddr); | ||
58 | + } | ||
59 | + /* TODO: MTE check */ | ||
60 | + host_fn(&scratch, reg_off, info.host); | ||
61 | + } else { | ||
62 | + /* Element crosses the page boundary. */ | ||
63 | + sve_probe_page(&info2, false, env, addr + in_page, 0, | ||
64 | + MMU_DATA_LOAD, mmu_idx, retaddr); | ||
65 | + if (unlikely((info.flags | info2.flags) & TLB_WATCHPOINT)) { | ||
66 | + cpu_check_watchpoint(env_cpu(env), addr, | ||
67 | + msize, info.attrs, | ||
68 | + BP_MEM_READ, retaddr); | ||
69 | + } | ||
70 | + /* TODO: MTE check */ | ||
71 | + tlb_fn(env, &scratch, reg_off, addr, retaddr); | ||
72 | + } | ||
73 | } | ||
74 | - i += 4, pg >>= 4; | ||
75 | - } while (i & 15); | ||
76 | - } | ||
77 | + reg_off += esize; | ||
78 | + pg >>= esize; | ||
79 | + } while (reg_off & 63); | ||
80 | + } while (reg_off < reg_max); | ||
81 | |||
82 | /* Wait until all exceptions have been raised to write back. */ | ||
83 | - memcpy(vd, &scratch, oprsz); | ||
84 | + memcpy(vd, &scratch, reg_max); | ||
85 | } | ||
86 | |||
87 | -static void sve_ld1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
88 | - target_ulong base, uint32_t desc, uintptr_t ra, | ||
89 | - zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn) | ||
90 | -{ | ||
91 | - const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
92 | - intptr_t i, oprsz = simd_oprsz(desc) / 8; | ||
93 | - ARMVectorReg scratch = { }; | ||
94 | - | ||
95 | - for (i = 0; i < oprsz; i++) { | ||
96 | - uint8_t pg = *(uint8_t *)(vg + H1(i)); | ||
97 | - if (likely(pg & 1)) { | ||
98 | - target_ulong off = off_fn(vm, i * 8); | ||
99 | - tlb_fn(env, &scratch, i * 8, base + (off << scale), ra); | ||
100 | - } | ||
101 | - } | ||
102 | - | ||
103 | - /* Wait until all exceptions have been raised to write back. */ | ||
104 | - memcpy(vd, &scratch, oprsz * 8); | ||
105 | +#define DO_LD1_ZPZ_S(MEM, OFS, MSZ) \ | ||
106 | +void HELPER(sve_ld##MEM##_##OFS)(CPUARMState *env, void *vd, void *vg, \ | ||
107 | + void *vm, target_ulong base, uint32_t desc) \ | ||
108 | +{ \ | ||
109 | + sve_ld1_z(env, vd, vg, vm, base, desc, GETPC(), 4, 1 << MSZ, \ | ||
110 | + off_##OFS##_s, sve_ld1##MEM##_host, sve_ld1##MEM##_tlb); \ | ||
111 | } | ||
112 | |||
113 | -#define DO_LD1_ZPZ_S(MEM, OFS) \ | ||
114 | -void QEMU_FLATTEN HELPER(sve_ld##MEM##_##OFS) \ | ||
115 | - (CPUARMState *env, void *vd, void *vg, void *vm, \ | ||
116 | - target_ulong base, uint32_t desc) \ | ||
117 | -{ \ | ||
118 | - sve_ld1_zs(env, vd, vg, vm, base, desc, GETPC(), \ | ||
119 | - off_##OFS##_s, sve_ld1##MEM##_tlb); \ | ||
120 | +#define DO_LD1_ZPZ_D(MEM, OFS, MSZ) \ | ||
121 | +void HELPER(sve_ld##MEM##_##OFS)(CPUARMState *env, void *vd, void *vg, \ | ||
122 | + void *vm, target_ulong base, uint32_t desc) \ | ||
123 | +{ \ | ||
124 | + sve_ld1_z(env, vd, vg, vm, base, desc, GETPC(), 8, 1 << MSZ, \ | ||
125 | + off_##OFS##_d, sve_ld1##MEM##_host, sve_ld1##MEM##_tlb); \ | ||
126 | } | ||
127 | |||
128 | -#define DO_LD1_ZPZ_D(MEM, OFS) \ | ||
129 | -void QEMU_FLATTEN HELPER(sve_ld##MEM##_##OFS) \ | ||
130 | - (CPUARMState *env, void *vd, void *vg, void *vm, \ | ||
131 | - target_ulong base, uint32_t desc) \ | ||
132 | -{ \ | ||
133 | - sve_ld1_zd(env, vd, vg, vm, base, desc, GETPC(), \ | ||
134 | - off_##OFS##_d, sve_ld1##MEM##_tlb); \ | ||
135 | -} | ||
136 | +DO_LD1_ZPZ_S(bsu, zsu, MO_8) | ||
137 | +DO_LD1_ZPZ_S(bsu, zss, MO_8) | ||
138 | +DO_LD1_ZPZ_D(bdu, zsu, MO_8) | ||
139 | +DO_LD1_ZPZ_D(bdu, zss, MO_8) | ||
140 | +DO_LD1_ZPZ_D(bdu, zd, MO_8) | ||
141 | |||
142 | -DO_LD1_ZPZ_S(bsu, zsu) | ||
143 | -DO_LD1_ZPZ_S(bsu, zss) | ||
144 | -DO_LD1_ZPZ_D(bdu, zsu) | ||
145 | -DO_LD1_ZPZ_D(bdu, zss) | ||
146 | -DO_LD1_ZPZ_D(bdu, zd) | ||
147 | +DO_LD1_ZPZ_S(bss, zsu, MO_8) | ||
148 | +DO_LD1_ZPZ_S(bss, zss, MO_8) | ||
149 | +DO_LD1_ZPZ_D(bds, zsu, MO_8) | ||
150 | +DO_LD1_ZPZ_D(bds, zss, MO_8) | ||
151 | +DO_LD1_ZPZ_D(bds, zd, MO_8) | ||
152 | |||
153 | -DO_LD1_ZPZ_S(bss, zsu) | ||
154 | -DO_LD1_ZPZ_S(bss, zss) | ||
155 | -DO_LD1_ZPZ_D(bds, zsu) | ||
156 | -DO_LD1_ZPZ_D(bds, zss) | ||
157 | -DO_LD1_ZPZ_D(bds, zd) | ||
158 | +DO_LD1_ZPZ_S(hsu_le, zsu, MO_16) | ||
159 | +DO_LD1_ZPZ_S(hsu_le, zss, MO_16) | ||
160 | +DO_LD1_ZPZ_D(hdu_le, zsu, MO_16) | ||
161 | +DO_LD1_ZPZ_D(hdu_le, zss, MO_16) | ||
162 | +DO_LD1_ZPZ_D(hdu_le, zd, MO_16) | ||
163 | |||
164 | -DO_LD1_ZPZ_S(hsu_le, zsu) | ||
165 | -DO_LD1_ZPZ_S(hsu_le, zss) | ||
166 | -DO_LD1_ZPZ_D(hdu_le, zsu) | ||
167 | -DO_LD1_ZPZ_D(hdu_le, zss) | ||
168 | -DO_LD1_ZPZ_D(hdu_le, zd) | ||
169 | +DO_LD1_ZPZ_S(hsu_be, zsu, MO_16) | ||
170 | +DO_LD1_ZPZ_S(hsu_be, zss, MO_16) | ||
171 | +DO_LD1_ZPZ_D(hdu_be, zsu, MO_16) | ||
172 | +DO_LD1_ZPZ_D(hdu_be, zss, MO_16) | ||
173 | +DO_LD1_ZPZ_D(hdu_be, zd, MO_16) | ||
174 | |||
175 | -DO_LD1_ZPZ_S(hsu_be, zsu) | ||
176 | -DO_LD1_ZPZ_S(hsu_be, zss) | ||
177 | -DO_LD1_ZPZ_D(hdu_be, zsu) | ||
178 | -DO_LD1_ZPZ_D(hdu_be, zss) | ||
179 | -DO_LD1_ZPZ_D(hdu_be, zd) | ||
180 | +DO_LD1_ZPZ_S(hss_le, zsu, MO_16) | ||
181 | +DO_LD1_ZPZ_S(hss_le, zss, MO_16) | ||
182 | +DO_LD1_ZPZ_D(hds_le, zsu, MO_16) | ||
183 | +DO_LD1_ZPZ_D(hds_le, zss, MO_16) | ||
184 | +DO_LD1_ZPZ_D(hds_le, zd, MO_16) | ||
185 | |||
186 | -DO_LD1_ZPZ_S(hss_le, zsu) | ||
187 | -DO_LD1_ZPZ_S(hss_le, zss) | ||
188 | -DO_LD1_ZPZ_D(hds_le, zsu) | ||
189 | -DO_LD1_ZPZ_D(hds_le, zss) | ||
190 | -DO_LD1_ZPZ_D(hds_le, zd) | ||
191 | +DO_LD1_ZPZ_S(hss_be, zsu, MO_16) | ||
192 | +DO_LD1_ZPZ_S(hss_be, zss, MO_16) | ||
193 | +DO_LD1_ZPZ_D(hds_be, zsu, MO_16) | ||
194 | +DO_LD1_ZPZ_D(hds_be, zss, MO_16) | ||
195 | +DO_LD1_ZPZ_D(hds_be, zd, MO_16) | ||
196 | |||
197 | -DO_LD1_ZPZ_S(hss_be, zsu) | ||
198 | -DO_LD1_ZPZ_S(hss_be, zss) | ||
199 | -DO_LD1_ZPZ_D(hds_be, zsu) | ||
200 | -DO_LD1_ZPZ_D(hds_be, zss) | ||
201 | -DO_LD1_ZPZ_D(hds_be, zd) | ||
202 | +DO_LD1_ZPZ_S(ss_le, zsu, MO_32) | ||
203 | +DO_LD1_ZPZ_S(ss_le, zss, MO_32) | ||
204 | +DO_LD1_ZPZ_D(sdu_le, zsu, MO_32) | ||
205 | +DO_LD1_ZPZ_D(sdu_le, zss, MO_32) | ||
206 | +DO_LD1_ZPZ_D(sdu_le, zd, MO_32) | ||
207 | |||
208 | -DO_LD1_ZPZ_S(ss_le, zsu) | ||
209 | -DO_LD1_ZPZ_S(ss_le, zss) | ||
210 | -DO_LD1_ZPZ_D(sdu_le, zsu) | ||
211 | -DO_LD1_ZPZ_D(sdu_le, zss) | ||
212 | -DO_LD1_ZPZ_D(sdu_le, zd) | ||
213 | +DO_LD1_ZPZ_S(ss_be, zsu, MO_32) | ||
214 | +DO_LD1_ZPZ_S(ss_be, zss, MO_32) | ||
215 | +DO_LD1_ZPZ_D(sdu_be, zsu, MO_32) | ||
216 | +DO_LD1_ZPZ_D(sdu_be, zss, MO_32) | ||
217 | +DO_LD1_ZPZ_D(sdu_be, zd, MO_32) | ||
218 | |||
219 | -DO_LD1_ZPZ_S(ss_be, zsu) | ||
220 | -DO_LD1_ZPZ_S(ss_be, zss) | ||
221 | -DO_LD1_ZPZ_D(sdu_be, zsu) | ||
222 | -DO_LD1_ZPZ_D(sdu_be, zss) | ||
223 | -DO_LD1_ZPZ_D(sdu_be, zd) | ||
224 | +DO_LD1_ZPZ_D(sds_le, zsu, MO_32) | ||
225 | +DO_LD1_ZPZ_D(sds_le, zss, MO_32) | ||
226 | +DO_LD1_ZPZ_D(sds_le, zd, MO_32) | ||
227 | |||
228 | -DO_LD1_ZPZ_D(sds_le, zsu) | ||
229 | -DO_LD1_ZPZ_D(sds_le, zss) | ||
230 | -DO_LD1_ZPZ_D(sds_le, zd) | ||
231 | +DO_LD1_ZPZ_D(sds_be, zsu, MO_32) | ||
232 | +DO_LD1_ZPZ_D(sds_be, zss, MO_32) | ||
233 | +DO_LD1_ZPZ_D(sds_be, zd, MO_32) | ||
234 | |||
235 | -DO_LD1_ZPZ_D(sds_be, zsu) | ||
236 | -DO_LD1_ZPZ_D(sds_be, zss) | ||
237 | -DO_LD1_ZPZ_D(sds_be, zd) | ||
238 | +DO_LD1_ZPZ_D(dd_le, zsu, MO_64) | ||
239 | +DO_LD1_ZPZ_D(dd_le, zss, MO_64) | ||
240 | +DO_LD1_ZPZ_D(dd_le, zd, MO_64) | ||
241 | |||
242 | -DO_LD1_ZPZ_D(dd_le, zsu) | ||
243 | -DO_LD1_ZPZ_D(dd_le, zss) | ||
244 | -DO_LD1_ZPZ_D(dd_le, zd) | ||
245 | - | ||
246 | -DO_LD1_ZPZ_D(dd_be, zsu) | ||
247 | -DO_LD1_ZPZ_D(dd_be, zss) | ||
248 | -DO_LD1_ZPZ_D(dd_be, zd) | ||
249 | +DO_LD1_ZPZ_D(dd_be, zsu, MO_64) | ||
250 | +DO_LD1_ZPZ_D(dd_be, zss, MO_64) | ||
251 | +DO_LD1_ZPZ_D(dd_be, zd, MO_64) | ||
252 | |||
253 | #undef DO_LD1_ZPZ_S | ||
254 | #undef DO_LD1_ZPZ_D | ||
255 | -- | 73 | -- |
256 | 2.20.1 | 74 | 2.25.1 |
257 | 75 | ||
258 | 76 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use the "normal" memory access functions, rather than the | 3 | Give this enum a name and use in ARMCPRegInfo and add_cpreg_to_hashtable. |
4 | softmmu internal helper functions directly. | 4 | Add the enumerator ARM_CP_SECSTATE_BOTH to clarify how 0 |
5 | 5 | is handled in define_one_arm_cp_reg_with_opaque. | |
6 | Since fb901c905dc3, cpu_mem_index is now a simple extract | ||
7 | from env->hflags and not a large computation. Which means | ||
8 | that it's now more work to pass around this value than it | ||
9 | is to recompute it. | ||
10 | |||
11 | This only adjusts the primitives, and does not clean up | ||
12 | all of the uses within sve_helper.c. | ||
13 | 6 | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
16 | Message-id: 20200508154359.7494-8-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-10-richard.henderson@linaro.org |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 11 | --- |
19 | target/arm/sve_helper.c | 221 ++++++++++++++++------------------------ | 12 | target/arm/cpregs.h | 7 ++++--- |
20 | 1 file changed, 86 insertions(+), 135 deletions(-) | 13 | target/arm/helper.c | 7 +++++-- |
14 | 2 files changed, 9 insertions(+), 5 deletions(-) | ||
21 | 15 | ||
22 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
23 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/sve_helper.c | 18 | --- a/target/arm/cpregs.h |
25 | +++ b/target/arm/sve_helper.c | 19 | +++ b/target/arm/cpregs.h |
26 | @@ -XXX,XX +XXX,XX @@ typedef intptr_t sve_ld1_host_fn(void *vd, void *vg, void *host, | 20 | @@ -XXX,XX +XXX,XX @@ typedef enum { |
27 | * Load one element into @vd + @reg_off from (@env, @vaddr, @ra). | 21 | * registered entry will only have one to identify whether the entry is secure |
28 | * The controlling predicate is known to be true. | 22 | * or non-secure. |
29 | */ | 23 | */ |
30 | -typedef void sve_ld1_tlb_fn(CPUARMState *env, void *vd, intptr_t reg_off, | 24 | -enum { |
31 | - target_ulong vaddr, TCGMemOpIdx oi, uintptr_t ra); | 25 | +typedef enum { |
32 | -typedef sve_ld1_tlb_fn sve_st1_tlb_fn; | 26 | + ARM_CP_SECSTATE_BOTH = 0, /* define one cpreg for each secstate */ |
33 | +typedef void sve_ldst1_tlb_fn(CPUARMState *env, void *vd, intptr_t reg_off, | 27 | ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ |
34 | + target_ulong vaddr, uintptr_t retaddr); | 28 | ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ |
29 | -}; | ||
30 | +} CPSecureState; | ||
35 | 31 | ||
36 | /* | 32 | /* |
37 | * Generate the above primitives. | 33 | * Access rights: |
38 | @@ -XXX,XX +XXX,XX @@ static intptr_t sve_##NAME##_host(void *vd, void *vg, void *host, \ | 34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { |
39 | return mem_off; \ | 35 | /* Access rights: PL*_[RW] */ |
36 | CPAccessRights access; | ||
37 | /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
38 | - int secure; | ||
39 | + CPSecureState secure; | ||
40 | /* | ||
41 | * The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
42 | * this register was defined: can be used to hand data through to the | ||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper.c | ||
46 | +++ b/target/arm/helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) | ||
40 | } | 48 | } |
41 | 49 | ||
42 | -#ifdef CONFIG_SOFTMMU | 50 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
43 | -#define DO_LD_TLB(NAME, H, TYPEE, TYPEM, HOST, MOEND, TLB) \ | 51 | - void *opaque, CPState state, int secstate, |
44 | +#define DO_LD_TLB(NAME, H, TYPEE, TYPEM, TLB) \ | 52 | + void *opaque, CPState state, |
45 | static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ | 53 | + CPSecureState secstate, |
46 | - target_ulong addr, TCGMemOpIdx oi, uintptr_t ra) \ | 54 | int crm, int opc1, int opc2, |
47 | + target_ulong addr, uintptr_t ra) \ | 55 | const char *name) |
48 | { \ | ||
49 | - TYPEM val = TLB(env, addr, oi, ra); \ | ||
50 | - *(TYPEE *)(vd + H(reg_off)) = val; \ | ||
51 | + *(TYPEE *)(vd + H(reg_off)) = (TYPEM)TLB(env, addr, ra); \ | ||
52 | } | ||
53 | -#else | ||
54 | -#define DO_LD_TLB(NAME, H, TYPEE, TYPEM, HOST, MOEND, TLB) \ | ||
55 | + | ||
56 | +#define DO_ST_TLB(NAME, H, TYPEE, TYPEM, TLB) \ | ||
57 | static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ | ||
58 | - target_ulong addr, TCGMemOpIdx oi, uintptr_t ra) \ | ||
59 | + target_ulong addr, uintptr_t ra) \ | ||
60 | { \ | ||
61 | - TYPEM val = HOST(g2h(addr)); \ | ||
62 | - *(TYPEE *)(vd + H(reg_off)) = val; \ | ||
63 | + TLB(env, addr, (TYPEM)*(TYPEE *)(vd + H(reg_off)), ra); \ | ||
64 | } | ||
65 | -#endif | ||
66 | |||
67 | #define DO_LD_PRIM_1(NAME, H, TE, TM) \ | ||
68 | DO_LD_HOST(NAME, H, TE, TM, ldub_p) \ | ||
69 | - DO_LD_TLB(NAME, H, TE, TM, ldub_p, 0, helper_ret_ldub_mmu) | ||
70 | + DO_LD_TLB(NAME, H, TE, TM, cpu_ldub_data_ra) | ||
71 | |||
72 | DO_LD_PRIM_1(ld1bb, H1, uint8_t, uint8_t) | ||
73 | DO_LD_PRIM_1(ld1bhu, H1_2, uint16_t, uint8_t) | ||
74 | @@ -XXX,XX +XXX,XX @@ DO_LD_PRIM_1(ld1bss, H1_4, uint32_t, int8_t) | ||
75 | DO_LD_PRIM_1(ld1bdu, , uint64_t, uint8_t) | ||
76 | DO_LD_PRIM_1(ld1bds, , uint64_t, int8_t) | ||
77 | |||
78 | -#define DO_LD_PRIM_2(NAME, end, MOEND, H, TE, TM, PH, PT) \ | ||
79 | - DO_LD_HOST(NAME##_##end, H, TE, TM, PH##_##end##_p) \ | ||
80 | - DO_LD_TLB(NAME##_##end, H, TE, TM, PH##_##end##_p, \ | ||
81 | - MOEND, helper_##end##_##PT##_mmu) | ||
82 | +#define DO_ST_PRIM_1(NAME, H, TE, TM) \ | ||
83 | + DO_ST_TLB(st1##NAME, H, TE, TM, cpu_stb_data_ra) | ||
84 | |||
85 | -DO_LD_PRIM_2(ld1hh, le, MO_LE, H1_2, uint16_t, uint16_t, lduw, lduw) | ||
86 | -DO_LD_PRIM_2(ld1hsu, le, MO_LE, H1_4, uint32_t, uint16_t, lduw, lduw) | ||
87 | -DO_LD_PRIM_2(ld1hss, le, MO_LE, H1_4, uint32_t, int16_t, lduw, lduw) | ||
88 | -DO_LD_PRIM_2(ld1hdu, le, MO_LE, , uint64_t, uint16_t, lduw, lduw) | ||
89 | -DO_LD_PRIM_2(ld1hds, le, MO_LE, , uint64_t, int16_t, lduw, lduw) | ||
90 | +DO_ST_PRIM_1(bb, H1, uint8_t, uint8_t) | ||
91 | +DO_ST_PRIM_1(bh, H1_2, uint16_t, uint8_t) | ||
92 | +DO_ST_PRIM_1(bs, H1_4, uint32_t, uint8_t) | ||
93 | +DO_ST_PRIM_1(bd, , uint64_t, uint8_t) | ||
94 | |||
95 | -DO_LD_PRIM_2(ld1ss, le, MO_LE, H1_4, uint32_t, uint32_t, ldl, ldul) | ||
96 | -DO_LD_PRIM_2(ld1sdu, le, MO_LE, , uint64_t, uint32_t, ldl, ldul) | ||
97 | -DO_LD_PRIM_2(ld1sds, le, MO_LE, , uint64_t, int32_t, ldl, ldul) | ||
98 | +#define DO_LD_PRIM_2(NAME, H, TE, TM, LD) \ | ||
99 | + DO_LD_HOST(ld1##NAME##_be, H, TE, TM, LD##_be_p) \ | ||
100 | + DO_LD_HOST(ld1##NAME##_le, H, TE, TM, LD##_le_p) \ | ||
101 | + DO_LD_TLB(ld1##NAME##_be, H, TE, TM, cpu_##LD##_be_data_ra) \ | ||
102 | + DO_LD_TLB(ld1##NAME##_le, H, TE, TM, cpu_##LD##_le_data_ra) | ||
103 | |||
104 | -DO_LD_PRIM_2(ld1dd, le, MO_LE, , uint64_t, uint64_t, ldq, ldq) | ||
105 | +#define DO_ST_PRIM_2(NAME, H, TE, TM, ST) \ | ||
106 | + DO_ST_TLB(st1##NAME##_be, H, TE, TM, cpu_##ST##_be_data_ra) \ | ||
107 | + DO_ST_TLB(st1##NAME##_le, H, TE, TM, cpu_##ST##_le_data_ra) | ||
108 | |||
109 | -DO_LD_PRIM_2(ld1hh, be, MO_BE, H1_2, uint16_t, uint16_t, lduw, lduw) | ||
110 | -DO_LD_PRIM_2(ld1hsu, be, MO_BE, H1_4, uint32_t, uint16_t, lduw, lduw) | ||
111 | -DO_LD_PRIM_2(ld1hss, be, MO_BE, H1_4, uint32_t, int16_t, lduw, lduw) | ||
112 | -DO_LD_PRIM_2(ld1hdu, be, MO_BE, , uint64_t, uint16_t, lduw, lduw) | ||
113 | -DO_LD_PRIM_2(ld1hds, be, MO_BE, , uint64_t, int16_t, lduw, lduw) | ||
114 | +DO_LD_PRIM_2(hh, H1_2, uint16_t, uint16_t, lduw) | ||
115 | +DO_LD_PRIM_2(hsu, H1_4, uint32_t, uint16_t, lduw) | ||
116 | +DO_LD_PRIM_2(hss, H1_4, uint32_t, int16_t, lduw) | ||
117 | +DO_LD_PRIM_2(hdu, , uint64_t, uint16_t, lduw) | ||
118 | +DO_LD_PRIM_2(hds, , uint64_t, int16_t, lduw) | ||
119 | |||
120 | -DO_LD_PRIM_2(ld1ss, be, MO_BE, H1_4, uint32_t, uint32_t, ldl, ldul) | ||
121 | -DO_LD_PRIM_2(ld1sdu, be, MO_BE, , uint64_t, uint32_t, ldl, ldul) | ||
122 | -DO_LD_PRIM_2(ld1sds, be, MO_BE, , uint64_t, int32_t, ldl, ldul) | ||
123 | +DO_ST_PRIM_2(hh, H1_2, uint16_t, uint16_t, stw) | ||
124 | +DO_ST_PRIM_2(hs, H1_4, uint32_t, uint16_t, stw) | ||
125 | +DO_ST_PRIM_2(hd, , uint64_t, uint16_t, stw) | ||
126 | |||
127 | -DO_LD_PRIM_2(ld1dd, be, MO_BE, , uint64_t, uint64_t, ldq, ldq) | ||
128 | +DO_LD_PRIM_2(ss, H1_4, uint32_t, uint32_t, ldl) | ||
129 | +DO_LD_PRIM_2(sdu, , uint64_t, uint32_t, ldl) | ||
130 | +DO_LD_PRIM_2(sds, , uint64_t, int32_t, ldl) | ||
131 | + | ||
132 | +DO_ST_PRIM_2(ss, H1_4, uint32_t, uint32_t, stl) | ||
133 | +DO_ST_PRIM_2(sd, , uint64_t, uint32_t, stl) | ||
134 | + | ||
135 | +DO_LD_PRIM_2(dd, , uint64_t, uint64_t, ldq) | ||
136 | +DO_ST_PRIM_2(dd, , uint64_t, uint64_t, stq) | ||
137 | |||
138 | #undef DO_LD_TLB | ||
139 | +#undef DO_ST_TLB | ||
140 | #undef DO_LD_HOST | ||
141 | #undef DO_LD_PRIM_1 | ||
142 | +#undef DO_ST_PRIM_1 | ||
143 | #undef DO_LD_PRIM_2 | ||
144 | +#undef DO_ST_PRIM_2 | ||
145 | |||
146 | /* | ||
147 | * Skip through a sequence of inactive elements in the guarding predicate @vg, | ||
148 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
149 | uint32_t desc, const uintptr_t retaddr, | ||
150 | const int esz, const int msz, | ||
151 | sve_ld1_host_fn *host_fn, | ||
152 | - sve_ld1_tlb_fn *tlb_fn) | ||
153 | + sve_ldst1_tlb_fn *tlb_fn) | ||
154 | { | 56 | { |
155 | const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | 57 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
156 | const int mmu_idx = get_mmuidx(oi); | 58 | r->secure, crm, opc1, opc2, |
157 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | 59 | r->name); |
158 | * on I/O memory, it may succeed but not bring in the TLB entry. | 60 | break; |
159 | * But even then we have still made forward progress. | 61 | - default: |
160 | */ | 62 | + case ARM_CP_SECSTATE_BOTH: |
161 | - tlb_fn(env, &scratch, reg_off, addr + mem_off, oi, retaddr); | 63 | name = g_strdup_printf("%s_S", r->name); |
162 | + tlb_fn(env, &scratch, reg_off, addr + mem_off, retaddr); | 64 | add_cpreg_to_hashtable(cpu, r, opaque, state, |
163 | reg_off += 1 << esz; | 65 | ARM_CP_SECSTATE_S, |
164 | } | 66 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
165 | #endif | 67 | ARM_CP_SECSTATE_NS, |
166 | @@ -XXX,XX +XXX,XX @@ DO_LD1_2(ld1dd, 3, 3) | 68 | crm, opc1, opc2, r->name); |
167 | */ | 69 | break; |
168 | static void sve_ld2_r(CPUARMState *env, void *vg, target_ulong addr, | 70 | + default: |
169 | uint32_t desc, int size, uintptr_t ra, | 71 | + g_assert_not_reached(); |
170 | - sve_ld1_tlb_fn *tlb_fn) | 72 | } |
171 | + sve_ldst1_tlb_fn *tlb_fn) | 73 | } else { |
172 | { | 74 | /* AArch64 registers get mapped to non-secure instance |
173 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
174 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
175 | intptr_t i, oprsz = simd_oprsz(desc); | ||
176 | ARMVectorReg scratch[2] = { }; | ||
177 | @@ -XXX,XX +XXX,XX @@ static void sve_ld2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
178 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
179 | do { | ||
180 | if (pg & 1) { | ||
181 | - tlb_fn(env, &scratch[0], i, addr, oi, ra); | ||
182 | - tlb_fn(env, &scratch[1], i, addr + size, oi, ra); | ||
183 | + tlb_fn(env, &scratch[0], i, addr, ra); | ||
184 | + tlb_fn(env, &scratch[1], i, addr + size, ra); | ||
185 | } | ||
186 | i += size, pg >>= size; | ||
187 | addr += 2 * size; | ||
188 | @@ -XXX,XX +XXX,XX @@ static void sve_ld2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
189 | |||
190 | static void sve_ld3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
191 | uint32_t desc, int size, uintptr_t ra, | ||
192 | - sve_ld1_tlb_fn *tlb_fn) | ||
193 | + sve_ldst1_tlb_fn *tlb_fn) | ||
194 | { | ||
195 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
196 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
197 | intptr_t i, oprsz = simd_oprsz(desc); | ||
198 | ARMVectorReg scratch[3] = { }; | ||
199 | @@ -XXX,XX +XXX,XX @@ static void sve_ld3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
200 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
201 | do { | ||
202 | if (pg & 1) { | ||
203 | - tlb_fn(env, &scratch[0], i, addr, oi, ra); | ||
204 | - tlb_fn(env, &scratch[1], i, addr + size, oi, ra); | ||
205 | - tlb_fn(env, &scratch[2], i, addr + 2 * size, oi, ra); | ||
206 | + tlb_fn(env, &scratch[0], i, addr, ra); | ||
207 | + tlb_fn(env, &scratch[1], i, addr + size, ra); | ||
208 | + tlb_fn(env, &scratch[2], i, addr + 2 * size, ra); | ||
209 | } | ||
210 | i += size, pg >>= size; | ||
211 | addr += 3 * size; | ||
212 | @@ -XXX,XX +XXX,XX @@ static void sve_ld3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
213 | |||
214 | static void sve_ld4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
215 | uint32_t desc, int size, uintptr_t ra, | ||
216 | - sve_ld1_tlb_fn *tlb_fn) | ||
217 | + sve_ldst1_tlb_fn *tlb_fn) | ||
218 | { | ||
219 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
220 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
221 | intptr_t i, oprsz = simd_oprsz(desc); | ||
222 | ARMVectorReg scratch[4] = { }; | ||
223 | @@ -XXX,XX +XXX,XX @@ static void sve_ld4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
224 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
225 | do { | ||
226 | if (pg & 1) { | ||
227 | - tlb_fn(env, &scratch[0], i, addr, oi, ra); | ||
228 | - tlb_fn(env, &scratch[1], i, addr + size, oi, ra); | ||
229 | - tlb_fn(env, &scratch[2], i, addr + 2 * size, oi, ra); | ||
230 | - tlb_fn(env, &scratch[3], i, addr + 3 * size, oi, ra); | ||
231 | + tlb_fn(env, &scratch[0], i, addr, ra); | ||
232 | + tlb_fn(env, &scratch[1], i, addr + size, ra); | ||
233 | + tlb_fn(env, &scratch[2], i, addr + 2 * size, ra); | ||
234 | + tlb_fn(env, &scratch[3], i, addr + 3 * size, ra); | ||
235 | } | ||
236 | i += size, pg >>= size; | ||
237 | addr += 4 * size; | ||
238 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
239 | uint32_t desc, const uintptr_t retaddr, | ||
240 | const int esz, const int msz, | ||
241 | sve_ld1_host_fn *host_fn, | ||
242 | - sve_ld1_tlb_fn *tlb_fn) | ||
243 | + sve_ldst1_tlb_fn *tlb_fn) | ||
244 | { | ||
245 | const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
246 | const int mmu_idx = get_mmuidx(oi); | ||
247 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
248 | * Perform one normal read, which will fault or not. | ||
249 | * But it is likely to bring the page into the tlb. | ||
250 | */ | ||
251 | - tlb_fn(env, vd, reg_off, addr + mem_off, oi, retaddr); | ||
252 | + tlb_fn(env, vd, reg_off, addr + mem_off, retaddr); | ||
253 | |||
254 | /* After any fault, zero any leading predicated false elts. */ | ||
255 | swap_memzero(vd, reg_off); | ||
256 | @@ -XXX,XX +XXX,XX @@ DO_LDFF1_LDNF1_2(dd, 3, 3) | ||
257 | #undef DO_LDFF1_LDNF1_1 | ||
258 | #undef DO_LDFF1_LDNF1_2 | ||
259 | |||
260 | -/* | ||
261 | - * Store contiguous data, protected by a governing predicate. | ||
262 | - */ | ||
263 | - | ||
264 | -#ifdef CONFIG_SOFTMMU | ||
265 | -#define DO_ST_TLB(NAME, H, TYPEM, HOST, MOEND, TLB) \ | ||
266 | -static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ | ||
267 | - target_ulong addr, TCGMemOpIdx oi, uintptr_t ra) \ | ||
268 | -{ \ | ||
269 | - TLB(env, addr, *(TYPEM *)(vd + H(reg_off)), oi, ra); \ | ||
270 | -} | ||
271 | -#else | ||
272 | -#define DO_ST_TLB(NAME, H, TYPEM, HOST, MOEND, TLB) \ | ||
273 | -static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ | ||
274 | - target_ulong addr, TCGMemOpIdx oi, uintptr_t ra) \ | ||
275 | -{ \ | ||
276 | - HOST(g2h(addr), *(TYPEM *)(vd + H(reg_off))); \ | ||
277 | -} | ||
278 | -#endif | ||
279 | - | ||
280 | -DO_ST_TLB(st1bb, H1, uint8_t, stb_p, 0, helper_ret_stb_mmu) | ||
281 | -DO_ST_TLB(st1bh, H1_2, uint16_t, stb_p, 0, helper_ret_stb_mmu) | ||
282 | -DO_ST_TLB(st1bs, H1_4, uint32_t, stb_p, 0, helper_ret_stb_mmu) | ||
283 | -DO_ST_TLB(st1bd, , uint64_t, stb_p, 0, helper_ret_stb_mmu) | ||
284 | - | ||
285 | -DO_ST_TLB(st1hh_le, H1_2, uint16_t, stw_le_p, MO_LE, helper_le_stw_mmu) | ||
286 | -DO_ST_TLB(st1hs_le, H1_4, uint32_t, stw_le_p, MO_LE, helper_le_stw_mmu) | ||
287 | -DO_ST_TLB(st1hd_le, , uint64_t, stw_le_p, MO_LE, helper_le_stw_mmu) | ||
288 | - | ||
289 | -DO_ST_TLB(st1ss_le, H1_4, uint32_t, stl_le_p, MO_LE, helper_le_stl_mmu) | ||
290 | -DO_ST_TLB(st1sd_le, , uint64_t, stl_le_p, MO_LE, helper_le_stl_mmu) | ||
291 | - | ||
292 | -DO_ST_TLB(st1dd_le, , uint64_t, stq_le_p, MO_LE, helper_le_stq_mmu) | ||
293 | - | ||
294 | -DO_ST_TLB(st1hh_be, H1_2, uint16_t, stw_be_p, MO_BE, helper_be_stw_mmu) | ||
295 | -DO_ST_TLB(st1hs_be, H1_4, uint32_t, stw_be_p, MO_BE, helper_be_stw_mmu) | ||
296 | -DO_ST_TLB(st1hd_be, , uint64_t, stw_be_p, MO_BE, helper_be_stw_mmu) | ||
297 | - | ||
298 | -DO_ST_TLB(st1ss_be, H1_4, uint32_t, stl_be_p, MO_BE, helper_be_stl_mmu) | ||
299 | -DO_ST_TLB(st1sd_be, , uint64_t, stl_be_p, MO_BE, helper_be_stl_mmu) | ||
300 | - | ||
301 | -DO_ST_TLB(st1dd_be, , uint64_t, stq_be_p, MO_BE, helper_be_stq_mmu) | ||
302 | - | ||
303 | -#undef DO_ST_TLB | ||
304 | - | ||
305 | /* | ||
306 | * Common helpers for all contiguous 1,2,3,4-register predicated stores. | ||
307 | */ | ||
308 | static void sve_st1_r(CPUARMState *env, void *vg, target_ulong addr, | ||
309 | uint32_t desc, const uintptr_t ra, | ||
310 | const int esize, const int msize, | ||
311 | - sve_st1_tlb_fn *tlb_fn) | ||
312 | + sve_ldst1_tlb_fn *tlb_fn) | ||
313 | { | ||
314 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
315 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
316 | intptr_t i, oprsz = simd_oprsz(desc); | ||
317 | void *vd = &env->vfp.zregs[rd]; | ||
318 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_r(CPUARMState *env, void *vg, target_ulong addr, | ||
319 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
320 | do { | ||
321 | if (pg & 1) { | ||
322 | - tlb_fn(env, vd, i, addr, oi, ra); | ||
323 | + tlb_fn(env, vd, i, addr, ra); | ||
324 | } | ||
325 | i += esize, pg >>= esize; | ||
326 | addr += msize; | ||
327 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_r(CPUARMState *env, void *vg, target_ulong addr, | ||
328 | static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
329 | uint32_t desc, const uintptr_t ra, | ||
330 | const int esize, const int msize, | ||
331 | - sve_st1_tlb_fn *tlb_fn) | ||
332 | + sve_ldst1_tlb_fn *tlb_fn) | ||
333 | { | ||
334 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
335 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
336 | intptr_t i, oprsz = simd_oprsz(desc); | ||
337 | void *d1 = &env->vfp.zregs[rd]; | ||
338 | @@ -XXX,XX +XXX,XX @@ static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
339 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
340 | do { | ||
341 | if (pg & 1) { | ||
342 | - tlb_fn(env, d1, i, addr, oi, ra); | ||
343 | - tlb_fn(env, d2, i, addr + msize, oi, ra); | ||
344 | + tlb_fn(env, d1, i, addr, ra); | ||
345 | + tlb_fn(env, d2, i, addr + msize, ra); | ||
346 | } | ||
347 | i += esize, pg >>= esize; | ||
348 | addr += 2 * msize; | ||
349 | @@ -XXX,XX +XXX,XX @@ static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
350 | static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
351 | uint32_t desc, const uintptr_t ra, | ||
352 | const int esize, const int msize, | ||
353 | - sve_st1_tlb_fn *tlb_fn) | ||
354 | + sve_ldst1_tlb_fn *tlb_fn) | ||
355 | { | ||
356 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
357 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
358 | intptr_t i, oprsz = simd_oprsz(desc); | ||
359 | void *d1 = &env->vfp.zregs[rd]; | ||
360 | @@ -XXX,XX +XXX,XX @@ static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
361 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
362 | do { | ||
363 | if (pg & 1) { | ||
364 | - tlb_fn(env, d1, i, addr, oi, ra); | ||
365 | - tlb_fn(env, d2, i, addr + msize, oi, ra); | ||
366 | - tlb_fn(env, d3, i, addr + 2 * msize, oi, ra); | ||
367 | + tlb_fn(env, d1, i, addr, ra); | ||
368 | + tlb_fn(env, d2, i, addr + msize, ra); | ||
369 | + tlb_fn(env, d3, i, addr + 2 * msize, ra); | ||
370 | } | ||
371 | i += esize, pg >>= esize; | ||
372 | addr += 3 * msize; | ||
373 | @@ -XXX,XX +XXX,XX @@ static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
374 | static void sve_st4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
375 | uint32_t desc, const uintptr_t ra, | ||
376 | const int esize, const int msize, | ||
377 | - sve_st1_tlb_fn *tlb_fn) | ||
378 | + sve_ldst1_tlb_fn *tlb_fn) | ||
379 | { | ||
380 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
381 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
382 | intptr_t i, oprsz = simd_oprsz(desc); | ||
383 | void *d1 = &env->vfp.zregs[rd]; | ||
384 | @@ -XXX,XX +XXX,XX @@ static void sve_st4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
385 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
386 | do { | ||
387 | if (pg & 1) { | ||
388 | - tlb_fn(env, d1, i, addr, oi, ra); | ||
389 | - tlb_fn(env, d2, i, addr + msize, oi, ra); | ||
390 | - tlb_fn(env, d3, i, addr + 2 * msize, oi, ra); | ||
391 | - tlb_fn(env, d4, i, addr + 3 * msize, oi, ra); | ||
392 | + tlb_fn(env, d1, i, addr, ra); | ||
393 | + tlb_fn(env, d2, i, addr + msize, ra); | ||
394 | + tlb_fn(env, d3, i, addr + 2 * msize, ra); | ||
395 | + tlb_fn(env, d4, i, addr + 3 * msize, ra); | ||
396 | } | ||
397 | i += esize, pg >>= esize; | ||
398 | addr += 4 * msize; | ||
399 | @@ -XXX,XX +XXX,XX @@ static target_ulong off_zd_d(void *reg, intptr_t reg_ofs) | ||
400 | |||
401 | static void sve_ld1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
402 | target_ulong base, uint32_t desc, uintptr_t ra, | ||
403 | - zreg_off_fn *off_fn, sve_ld1_tlb_fn *tlb_fn) | ||
404 | + zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn) | ||
405 | { | ||
406 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
407 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
408 | intptr_t i, oprsz = simd_oprsz(desc); | ||
409 | ARMVectorReg scratch = { }; | ||
410 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
411 | do { | ||
412 | if (likely(pg & 1)) { | ||
413 | target_ulong off = off_fn(vm, i); | ||
414 | - tlb_fn(env, &scratch, i, base + (off << scale), oi, ra); | ||
415 | + tlb_fn(env, &scratch, i, base + (off << scale), ra); | ||
416 | } | ||
417 | i += 4, pg >>= 4; | ||
418 | } while (i & 15); | ||
419 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
420 | |||
421 | static void sve_ld1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
422 | target_ulong base, uint32_t desc, uintptr_t ra, | ||
423 | - zreg_off_fn *off_fn, sve_ld1_tlb_fn *tlb_fn) | ||
424 | + zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn) | ||
425 | { | ||
426 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
427 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
428 | intptr_t i, oprsz = simd_oprsz(desc) / 8; | ||
429 | ARMVectorReg scratch = { }; | ||
430 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
431 | uint8_t pg = *(uint8_t *)(vg + H1(i)); | ||
432 | if (likely(pg & 1)) { | ||
433 | target_ulong off = off_fn(vm, i * 8); | ||
434 | - tlb_fn(env, &scratch, i * 8, base + (off << scale), oi, ra); | ||
435 | + tlb_fn(env, &scratch, i * 8, base + (off << scale), ra); | ||
436 | } | ||
437 | } | ||
438 | clear_helper_retaddr(); | ||
439 | @@ -XXX,XX +XXX,XX @@ DO_LD_NF(dd_be, , uint64_t, uint64_t, ldq_be_p) | ||
440 | */ | ||
441 | static inline void sve_ldff1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
442 | target_ulong base, uint32_t desc, uintptr_t ra, | ||
443 | - zreg_off_fn *off_fn, sve_ld1_tlb_fn *tlb_fn, | ||
444 | + zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn, | ||
445 | sve_ld1_nf_fn *nonfault_fn) | ||
446 | { | ||
447 | const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
448 | @@ -XXX,XX +XXX,XX @@ static inline void sve_ldff1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
449 | set_helper_retaddr(ra); | ||
450 | addr = off_fn(vm, reg_off); | ||
451 | addr = base + (addr << scale); | ||
452 | - tlb_fn(env, vd, reg_off, addr, oi, ra); | ||
453 | + tlb_fn(env, vd, reg_off, addr, ra); | ||
454 | |||
455 | /* The rest of the reads will be non-faulting. */ | ||
456 | clear_helper_retaddr(); | ||
457 | @@ -XXX,XX +XXX,XX @@ static inline void sve_ldff1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
458 | |||
459 | static inline void sve_ldff1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
460 | target_ulong base, uint32_t desc, uintptr_t ra, | ||
461 | - zreg_off_fn *off_fn, sve_ld1_tlb_fn *tlb_fn, | ||
462 | + zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn, | ||
463 | sve_ld1_nf_fn *nonfault_fn) | ||
464 | { | ||
465 | const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
466 | @@ -XXX,XX +XXX,XX @@ static inline void sve_ldff1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
467 | set_helper_retaddr(ra); | ||
468 | addr = off_fn(vm, reg_off); | ||
469 | addr = base + (addr << scale); | ||
470 | - tlb_fn(env, vd, reg_off, addr, oi, ra); | ||
471 | + tlb_fn(env, vd, reg_off, addr, ra); | ||
472 | |||
473 | /* The rest of the reads will be non-faulting. */ | ||
474 | clear_helper_retaddr(); | ||
475 | @@ -XXX,XX +XXX,XX @@ DO_LDFF1_ZPZ_D(dd_be, zd) | ||
476 | |||
477 | static void sve_st1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
478 | target_ulong base, uint32_t desc, uintptr_t ra, | ||
479 | - zreg_off_fn *off_fn, sve_ld1_tlb_fn *tlb_fn) | ||
480 | + zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn) | ||
481 | { | ||
482 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
483 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
484 | intptr_t i, oprsz = simd_oprsz(desc); | ||
485 | |||
486 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
487 | do { | ||
488 | if (likely(pg & 1)) { | ||
489 | target_ulong off = off_fn(vm, i); | ||
490 | - tlb_fn(env, vd, i, base + (off << scale), oi, ra); | ||
491 | + tlb_fn(env, vd, i, base + (off << scale), ra); | ||
492 | } | ||
493 | i += 4, pg >>= 4; | ||
494 | } while (i & 15); | ||
495 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
496 | |||
497 | static void sve_st1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
498 | target_ulong base, uint32_t desc, uintptr_t ra, | ||
499 | - zreg_off_fn *off_fn, sve_ld1_tlb_fn *tlb_fn) | ||
500 | + zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn) | ||
501 | { | ||
502 | - const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
503 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
504 | intptr_t i, oprsz = simd_oprsz(desc) / 8; | ||
505 | |||
506 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
507 | uint8_t pg = *(uint8_t *)(vg + H1(i)); | ||
508 | if (likely(pg & 1)) { | ||
509 | target_ulong off = off_fn(vm, i * 8); | ||
510 | - tlb_fn(env, vd, i * 8, base + (off << scale), oi, ra); | ||
511 | + tlb_fn(env, vd, i * 8, base + (off << scale), ra); | ||
512 | } | ||
513 | } | ||
514 | clear_helper_retaddr(); | ||
515 | -- | 75 | -- |
516 | 2.20.1 | 76 | 2.25.1 |
517 | |||
518 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | DUP (indexed) can duplicate 128-bit elements, so using esz | 3 | The new_key field is always non-zero -- drop the if. |
4 | unconditionally can assert in tcg_gen_gvec_dup_imm. | ||
5 | 4 | ||
6 | Fixes: 8711e71f9cbb | ||
7 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 7 | Message-id: 20220501055028.646596-11-richard.henderson@linaro.org |
11 | Message-id: 20200507172352.15418-5-richard.henderson@linaro.org | 8 | [PMM: reinstated dropped PL3_RW mask] |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | target/arm/translate-sve.c | 6 +++++- | 11 | target/arm/helper.c | 23 +++++++++++------------ |
15 | 1 file changed, 5 insertions(+), 1 deletion(-) | 12 | 1 file changed, 11 insertions(+), 12 deletions(-) |
16 | 13 | ||
17 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate-sve.c | 16 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/translate-sve.c | 17 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool trans_DUP_x(DisasContext *s, arg_DUP_x *a) | 18 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) |
22 | unsigned nofs = vec_reg_offset(s, a->rn, index, esz); | 19 | |
23 | tcg_gen_gvec_dup_mem(esz, dofs, nofs, vsz, vsz); | 20 | for (i = 0; i < ARRAY_SIZE(aliases); i++) { |
24 | } else { | 21 | const struct E2HAlias *a = &aliases[i]; |
25 | - tcg_gen_gvec_dup_imm(esz, dofs, vsz, vsz, 0); | 22 | - ARMCPRegInfo *src_reg, *dst_reg; |
26 | + /* | 23 | + ARMCPRegInfo *src_reg, *dst_reg, *new_reg; |
27 | + * While dup_mem handles 128-bit elements, dup_imm does not. | 24 | + uint32_t *new_key; |
28 | + * Thankfully element size doesn't matter for splatting zero. | 25 | + bool ok; |
29 | + */ | 26 | |
30 | + tcg_gen_gvec_dup_imm(MO_64, dofs, vsz, vsz, 0); | 27 | if (a->feature && !a->feature(&cpu->isar)) { |
31 | } | 28 | continue; |
32 | } | 29 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) |
33 | return true; | 30 | g_assert(src_reg->opaque == NULL); |
31 | |||
32 | /* Create alias before redirection so we dup the right data. */ | ||
33 | - if (a->new_key) { | ||
34 | - ARMCPRegInfo *new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | ||
35 | - uint32_t *new_key = g_memdup(&a->new_key, sizeof(uint32_t)); | ||
36 | - bool ok; | ||
37 | + new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | ||
38 | + new_key = g_memdup(&a->new_key, sizeof(uint32_t)); | ||
39 | |||
40 | - new_reg->name = a->new_name; | ||
41 | - new_reg->type |= ARM_CP_ALIAS; | ||
42 | - /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
43 | - new_reg->access &= PL2_RW | PL3_RW; | ||
44 | + new_reg->name = a->new_name; | ||
45 | + new_reg->type |= ARM_CP_ALIAS; | ||
46 | + /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
47 | + new_reg->access &= PL2_RW | PL3_RW; | ||
48 | |||
49 | - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
50 | - g_assert(ok); | ||
51 | - } | ||
52 | + ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
53 | + g_assert(ok); | ||
54 | |||
55 | src_reg->opaque = dst_reg; | ||
56 | src_reg->orig_readfn = src_reg->readfn ?: raw_read; | ||
34 | -- | 57 | -- |
35 | 2.20.1 | 58 | 2.25.1 |
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use ARRAY_SIZE() to iterate over ARMCPUInfo[]. | 3 | Cast the uint32_t key into a gpointer directly, which |
4 | allows us to avoid allocating storage for each key. | ||
4 | 5 | ||
5 | Since on the aarch64-linux-user build, arm_cpus[] is empty, add | 6 | Use g_hash_table_lookup when we already have a gpointer |
6 | the cpu_count variable and only iterate when it is non-zero. | 7 | (e.g. for callbacks like count_cpreg), or when using |
8 | get_arm_cp_reginfo would require casting away const. | ||
7 | 9 | ||
8 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | Message-id: 20220501055028.646596-12-richard.henderson@linaro.org |
11 | Message-id: 20200504172448.9402-4-philmd@redhat.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 14 | --- |
14 | target/arm/cpu.c | 16 +++++++++------- | 15 | target/arm/cpu.c | 4 ++-- |
15 | target/arm/cpu64.c | 8 +++----- | 16 | target/arm/gdbstub.c | 2 +- |
16 | 2 files changed, 12 insertions(+), 12 deletions(-) | 17 | target/arm/helper.c | 41 ++++++++++++++++++----------------------- |
18 | 3 files changed, 21 insertions(+), 26 deletions(-) | ||
17 | 19 | ||
18 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 20 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/cpu.c | 22 | --- a/target/arm/cpu.c |
21 | +++ b/target/arm/cpu.c | 23 | +++ b/target/arm/cpu.c |
22 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { | 24 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) |
23 | { .name = "any", .initfn = arm_max_initfn }, | 25 | ARMCPU *cpu = ARM_CPU(obj); |
24 | #endif | 26 | |
25 | #endif | 27 | cpu_set_cpustate_pointers(cpu); |
26 | - { .name = NULL } | 28 | - cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, |
27 | }; | 29 | - g_free, cpreg_hashtable_data_destroy); |
28 | 30 | + cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, | |
29 | static Property arm_cpu_properties[] = { | 31 | + NULL, cpreg_hashtable_data_destroy); |
30 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo idau_interface_type_info = { | 32 | |
31 | 33 | QLIST_INIT(&cpu->pre_el_change_hooks); | |
32 | static void arm_cpu_register_types(void) | 34 | QLIST_INIT(&cpu->el_change_hooks); |
35 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/gdbstub.c | ||
38 | +++ b/target/arm/gdbstub.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, | ||
40 | static void arm_register_sysreg_for_xml(gpointer key, gpointer value, | ||
41 | gpointer p) | ||
33 | { | 42 | { |
34 | - const ARMCPUInfo *info = arm_cpus; | 43 | - uint32_t ri_key = *(uint32_t *)key; |
35 | + const size_t cpu_count = ARRAY_SIZE(arm_cpus); | 44 | + uint32_t ri_key = (uintptr_t)key; |
36 | 45 | ARMCPRegInfo *ri = value; | |
37 | type_register_static(&arm_cpu_type_info); | 46 | RegisterSysregXmlParam *param = (RegisterSysregXmlParam *)p; |
38 | type_register_static(&idau_interface_type_info); | 47 | GString *s = param->s; |
39 | 48 | diff --git a/target/arm/helper.c b/target/arm/helper.c | |
40 | - while (info->name) { | 49 | index XXXXXXX..XXXXXXX 100644 |
41 | - arm_cpu_register(info); | 50 | --- a/target/arm/helper.c |
42 | - info++; | 51 | +++ b/target/arm/helper.c |
43 | - } | 52 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu) |
53 | static void add_cpreg_to_list(gpointer key, gpointer opaque) | ||
54 | { | ||
55 | ARMCPU *cpu = opaque; | ||
56 | - uint64_t regidx; | ||
57 | - const ARMCPRegInfo *ri; | ||
44 | - | 58 | - |
45 | #ifdef CONFIG_KVM | 59 | - regidx = *(uint32_t *)key; |
46 | type_register_static(&host_arm_cpu_type_info); | 60 | - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); |
47 | #endif | 61 | + uint32_t regidx = (uintptr_t)key; |
48 | + | 62 | + const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); |
49 | + if (cpu_count) { | 63 | |
50 | + size_t i; | 64 | if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { |
51 | + | 65 | cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx); |
52 | + for (i = 0; i < cpu_count; ++i) { | 66 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_list(gpointer key, gpointer opaque) |
53 | + arm_cpu_register(&arm_cpus[i]); | 67 | static void count_cpreg(gpointer key, gpointer opaque) |
54 | + } | 68 | { |
55 | + } | 69 | ARMCPU *cpu = opaque; |
70 | - uint64_t regidx; | ||
71 | const ARMCPRegInfo *ri; | ||
72 | |||
73 | - regidx = *(uint32_t *)key; | ||
74 | - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
75 | + ri = g_hash_table_lookup(cpu->cp_regs, key); | ||
76 | |||
77 | if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { | ||
78 | cpu->cpreg_array_len++; | ||
79 | @@ -XXX,XX +XXX,XX @@ static void count_cpreg(gpointer key, gpointer opaque) | ||
80 | |||
81 | static gint cpreg_key_compare(gconstpointer a, gconstpointer b) | ||
82 | { | ||
83 | - uint64_t aidx = cpreg_to_kvm_id(*(uint32_t *)a); | ||
84 | - uint64_t bidx = cpreg_to_kvm_id(*(uint32_t *)b); | ||
85 | + uint64_t aidx = cpreg_to_kvm_id((uintptr_t)a); | ||
86 | + uint64_t bidx = cpreg_to_kvm_id((uintptr_t)b); | ||
87 | |||
88 | if (aidx > bidx) { | ||
89 | return 1; | ||
90 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
91 | for (i = 0; i < ARRAY_SIZE(aliases); i++) { | ||
92 | const struct E2HAlias *a = &aliases[i]; | ||
93 | ARMCPRegInfo *src_reg, *dst_reg, *new_reg; | ||
94 | - uint32_t *new_key; | ||
95 | bool ok; | ||
96 | |||
97 | if (a->feature && !a->feature(&cpu->isar)) { | ||
98 | continue; | ||
99 | } | ||
100 | |||
101 | - src_reg = g_hash_table_lookup(cpu->cp_regs, &a->src_key); | ||
102 | - dst_reg = g_hash_table_lookup(cpu->cp_regs, &a->dst_key); | ||
103 | + src_reg = g_hash_table_lookup(cpu->cp_regs, | ||
104 | + (gpointer)(uintptr_t)a->src_key); | ||
105 | + dst_reg = g_hash_table_lookup(cpu->cp_regs, | ||
106 | + (gpointer)(uintptr_t)a->dst_key); | ||
107 | g_assert(src_reg != NULL); | ||
108 | g_assert(dst_reg != NULL); | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
111 | |||
112 | /* Create alias before redirection so we dup the right data. */ | ||
113 | new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | ||
114 | - new_key = g_memdup(&a->new_key, sizeof(uint32_t)); | ||
115 | |||
116 | new_reg->name = a->new_name; | ||
117 | new_reg->type |= ARM_CP_ALIAS; | ||
118 | /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
119 | new_reg->access &= PL2_RW | PL3_RW; | ||
120 | |||
121 | - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
122 | + ok = g_hash_table_insert(cpu->cp_regs, | ||
123 | + (gpointer)(uintptr_t)a->new_key, new_reg); | ||
124 | g_assert(ok); | ||
125 | |||
126 | src_reg->opaque = dst_reg; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
128 | /* Private utility function for define_one_arm_cp_reg_with_opaque(): | ||
129 | * add a single reginfo struct to the hash table. | ||
130 | */ | ||
131 | - uint32_t *key = g_new(uint32_t, 1); | ||
132 | + uint32_t key; | ||
133 | ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); | ||
134 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; | ||
135 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; | ||
136 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
137 | if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { | ||
138 | r2->cp = CP_REG_ARM64_SYSREG_CP; | ||
139 | } | ||
140 | - *key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
141 | - r2->opc0, opc1, opc2); | ||
142 | + key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
143 | + r2->opc0, opc1, opc2); | ||
144 | } else { | ||
145 | - *key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
146 | + key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
147 | } | ||
148 | if (opaque) { | ||
149 | r2->opaque = opaque; | ||
150 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
151 | * requested. | ||
152 | */ | ||
153 | if (!(r->type & ARM_CP_OVERRIDE)) { | ||
154 | - ARMCPRegInfo *oldreg; | ||
155 | - oldreg = g_hash_table_lookup(cpu->cp_regs, key); | ||
156 | + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); | ||
157 | if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { | ||
158 | fprintf(stderr, "Register redefined: cp=%d %d bit " | ||
159 | "crn=%d crm=%d opc1=%d opc2=%d, " | ||
160 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
161 | g_assert_not_reached(); | ||
162 | } | ||
163 | } | ||
164 | - g_hash_table_insert(cpu->cp_regs, key, r2); | ||
165 | + g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); | ||
56 | } | 166 | } |
57 | 167 | ||
58 | type_init(arm_cpu_register_types) | 168 | |
59 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 169 | @@ -XXX,XX +XXX,XX @@ void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
60 | index XXXXXXX..XXXXXXX 100644 | 170 | |
61 | --- a/target/arm/cpu64.c | 171 | const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp) |
62 | +++ b/target/arm/cpu64.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { | ||
64 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, | ||
65 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | ||
66 | { .name = "max", .initfn = aarch64_max_initfn }, | ||
67 | - { .name = NULL } | ||
68 | }; | ||
69 | |||
70 | static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp) | ||
71 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aarch64_cpu_type_info = { | ||
72 | |||
73 | static void aarch64_cpu_register_types(void) | ||
74 | { | 172 | { |
75 | - const ARMCPUInfo *info = aarch64_cpus; | 173 | - return g_hash_table_lookup(cpregs, &encoded_cp); |
76 | + size_t i; | 174 | + return g_hash_table_lookup(cpregs, (gpointer)(uintptr_t)encoded_cp); |
77 | |||
78 | type_register_static(&aarch64_cpu_type_info); | ||
79 | |||
80 | - while (info->name) { | ||
81 | - aarch64_cpu_register(info); | ||
82 | - info++; | ||
83 | + for (i = 0; i < ARRAY_SIZE(aarch64_cpus); ++i) { | ||
84 | + aarch64_cpu_register(&aarch64_cpus[i]); | ||
85 | } | ||
86 | } | 175 | } |
87 | 176 | ||
177 | void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
88 | -- | 178 | -- |
89 | 2.20.1 | 179 | 2.25.1 |
90 | |||
91 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | As IDAU is a v8M feature, restrict it to the Aarch32 CPUs. | 3 | Simplify freeing cp_regs hash table entries by using a single |
4 | allocation for the entire value. | ||
4 | 5 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | This fixes a theoretical bug if we were to ever free the entire |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | hash table, because we've been installing string literal constants |
7 | Message-id: 20200504172448.9402-5-philmd@redhat.com | 8 | into the cpreg structure in define_arm_vh_e2h_redirects_aliases. |
9 | However, at present we only free entries created for AArch32 | ||
10 | wildcard cpregs which get overwritten by more specific cpregs, | ||
11 | so this bug is never exposed. | ||
12 | |||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Message-id: 20220501055028.646596-13-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 17 | --- |
10 | target/arm/cpu.c | 2 +- | 18 | target/arm/cpu.c | 16 +--------------- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 19 | target/arm/helper.c | 10 ++++++++-- |
20 | 2 files changed, 9 insertions(+), 17 deletions(-) | ||
12 | 21 | ||
13 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 22 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.c | 24 | --- a/target/arm/cpu.c |
16 | +++ b/target/arm/cpu.c | 25 | +++ b/target/arm/cpu.c |
17 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_register_types(void) | 26 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) |
18 | const size_t cpu_count = ARRAY_SIZE(arm_cpus); | 27 | return (Aff1 << ARM_AFF1_SHIFT) | Aff0; |
19 | 28 | } | |
20 | type_register_static(&arm_cpu_type_info); | 29 | |
21 | - type_register_static(&idau_interface_type_info); | 30 | -static void cpreg_hashtable_data_destroy(gpointer data) |
22 | 31 | -{ | |
23 | #ifdef CONFIG_KVM | 32 | - /* |
24 | type_register_static(&host_arm_cpu_type_info); | 33 | - * Destroy function for cpu->cp_regs hashtable data entries. |
25 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_register_types(void) | 34 | - * We must free the name string because it was g_strdup()ed in |
26 | if (cpu_count) { | 35 | - * add_cpreg_to_hashtable(). It's OK to cast away the 'const' |
27 | size_t i; | 36 | - * from r->name because we know we definitely allocated it. |
28 | 37 | - */ | |
29 | + type_register_static(&idau_interface_type_info); | 38 | - ARMCPRegInfo *r = data; |
30 | for (i = 0; i < cpu_count; ++i) { | 39 | - |
31 | arm_cpu_register(&arm_cpus[i]); | 40 | - g_free((void *)r->name); |
32 | } | 41 | - g_free(r); |
42 | -} | ||
43 | - | ||
44 | static void arm_cpu_initfn(Object *obj) | ||
45 | { | ||
46 | ARMCPU *cpu = ARM_CPU(obj); | ||
47 | |||
48 | cpu_set_cpustate_pointers(cpu); | ||
49 | cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, | ||
50 | - NULL, cpreg_hashtable_data_destroy); | ||
51 | + NULL, g_free); | ||
52 | |||
53 | QLIST_INIT(&cpu->pre_el_change_hooks); | ||
54 | QLIST_INIT(&cpu->el_change_hooks); | ||
55 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/helper.c | ||
58 | +++ b/target/arm/helper.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
60 | * add a single reginfo struct to the hash table. | ||
61 | */ | ||
62 | uint32_t key; | ||
63 | - ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); | ||
64 | + ARMCPRegInfo *r2; | ||
65 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; | ||
66 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; | ||
67 | + size_t name_len; | ||
68 | + | ||
69 | + /* Combine cpreg and name into one allocation. */ | ||
70 | + name_len = strlen(name) + 1; | ||
71 | + r2 = g_malloc(sizeof(*r2) + name_len); | ||
72 | + *r2 = *r; | ||
73 | + r2->name = memcpy(r2 + 1, name, name_len); | ||
74 | |||
75 | - r2->name = g_strdup(name); | ||
76 | /* Reset the secure state to the specific incoming state. This is | ||
77 | * necessary as the register may have been defined with both states. | ||
78 | */ | ||
33 | -- | 79 | -- |
34 | 2.20.1 | 80 | 2.25.1 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Handle all of the watchpoints for active elements all at once, | 3 | Move the computation of key to the top of the function. |
4 | before we've modified the vector register. This removes the | 4 | Hoist the resolution of cp as well, as an input to the |
5 | TLB_WATCHPOINT bit from page[].flags, which means that we can | 5 | computation of key. |
6 | use the normal fast path via RAM. | ||
7 | 6 | ||
7 | This will be required by a subsequent patch. | ||
8 | |||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Message-id: 20220501055028.646596-14-richard.henderson@linaro.org |
10 | Message-id: 20200508154359.7494-13-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 13 | --- |
13 | target/arm/sve_helper.c | 72 ++++++++++++++++++++++++++++++++++++++++- | 14 | target/arm/helper.c | 49 +++++++++++++++++++++++++-------------------- |
14 | 1 file changed, 71 insertions(+), 1 deletion(-) | 15 | 1 file changed, 27 insertions(+), 22 deletions(-) |
15 | 16 | ||
16 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/sve_helper.c | 19 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/sve_helper.c | 20 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, | 21 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
21 | return have_work; | 22 | ARMCPRegInfo *r2; |
22 | } | 23 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
23 | 24 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; | |
24 | +static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | 25 | + int cp = r->cp; |
25 | + uint64_t *vg, target_ulong addr, | 26 | size_t name_len; |
26 | + int esize, int msize, int wp_access, | 27 | |
27 | + uintptr_t retaddr) | 28 | + switch (state) { |
28 | +{ | 29 | + case ARM_CP_STATE_AA32: |
29 | +#ifndef CONFIG_USER_ONLY | 30 | + /* We assume it is a cp15 register if the .cp field is left unset. */ |
30 | + intptr_t mem_off, reg_off, reg_last; | 31 | + if (cp == 0 && r->state == ARM_CP_STATE_BOTH) { |
31 | + int flags0 = info->page[0].flags; | 32 | + cp = 15; |
32 | + int flags1 = info->page[1].flags; | 33 | + } |
33 | + | 34 | + key = ENCODE_CP_REG(cp, is64, ns, r->crn, crm, opc1, opc2); |
34 | + if (likely(!((flags0 | flags1) & TLB_WATCHPOINT))) { | 35 | + break; |
35 | + return; | 36 | + case ARM_CP_STATE_AA64: |
37 | + /* | ||
38 | + * To allow abbreviation of ARMCPRegInfo definitions, we treat | ||
39 | + * cp == 0 as equivalent to the value for "standard guest-visible | ||
40 | + * sysreg". STATE_BOTH definitions are also always "standard sysreg" | ||
41 | + * in their AArch64 view (the .cp value may be non-zero for the | ||
42 | + * benefit of the AArch32 view). | ||
43 | + */ | ||
44 | + if (cp == 0 || r->state == ARM_CP_STATE_BOTH) { | ||
45 | + cp = CP_REG_ARM64_SYSREG_CP; | ||
46 | + } | ||
47 | + key = ENCODE_AA64_CP_REG(cp, r->crn, crm, r->opc0, opc1, opc2); | ||
48 | + break; | ||
49 | + default: | ||
50 | + g_assert_not_reached(); | ||
36 | + } | 51 | + } |
37 | + | 52 | + |
38 | + /* Indicate that watchpoints are handled. */ | 53 | /* Combine cpreg and name into one allocation. */ |
39 | + info->page[0].flags = flags0 & ~TLB_WATCHPOINT; | 54 | name_len = strlen(name) + 1; |
40 | + info->page[1].flags = flags1 & ~TLB_WATCHPOINT; | 55 | r2 = g_malloc(sizeof(*r2) + name_len); |
41 | + | 56 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
42 | + if (flags0 & TLB_WATCHPOINT) { | 57 | } |
43 | + mem_off = info->mem_off_first[0]; | 58 | |
44 | + reg_off = info->reg_off_first[0]; | 59 | if (r->state == ARM_CP_STATE_BOTH) { |
45 | + reg_last = info->reg_off_last[0]; | 60 | - /* We assume it is a cp15 register if the .cp field is left unset. |
46 | + | 61 | - */ |
47 | + while (reg_off <= reg_last) { | 62 | - if (r2->cp == 0) { |
48 | + uint64_t pg = vg[reg_off >> 6]; | 63 | - r2->cp = 15; |
49 | + do { | 64 | - } |
50 | + if ((pg >> (reg_off & 63)) & 1) { | 65 | - |
51 | + cpu_check_watchpoint(env_cpu(env), addr + mem_off, | 66 | #if HOST_BIG_ENDIAN |
52 | + msize, info->page[0].attrs, | 67 | if (r2->fieldoffset) { |
53 | + wp_access, retaddr); | 68 | r2->fieldoffset += sizeof(uint32_t); |
54 | + } | 69 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
55 | + reg_off += esize; | 70 | #endif |
56 | + mem_off += msize; | 71 | } |
57 | + } while (reg_off <= reg_last && (reg_off & 63)); | 72 | } |
58 | + } | 73 | - if (state == ARM_CP_STATE_AA64) { |
59 | + } | 74 | - /* To allow abbreviation of ARMCPRegInfo |
60 | + | 75 | - * definitions, we treat cp == 0 as equivalent to |
61 | + mem_off = info->mem_off_split; | 76 | - * the value for "standard guest-visible sysreg". |
62 | + if (mem_off >= 0) { | 77 | - * STATE_BOTH definitions are also always "standard |
63 | + cpu_check_watchpoint(env_cpu(env), addr + mem_off, msize, | 78 | - * sysreg" in their AArch64 view (the .cp value may |
64 | + info->page[0].attrs, wp_access, retaddr); | 79 | - * be non-zero for the benefit of the AArch32 view). |
65 | + } | 80 | - */ |
66 | + | 81 | - if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { |
67 | + mem_off = info->mem_off_first[1]; | 82 | - r2->cp = CP_REG_ARM64_SYSREG_CP; |
68 | + if ((flags1 & TLB_WATCHPOINT) && mem_off >= 0) { | 83 | - } |
69 | + reg_off = info->reg_off_first[1]; | 84 | - key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, |
70 | + reg_last = info->reg_off_last[1]; | 85 | - r2->opc0, opc1, opc2); |
71 | + | 86 | - } else { |
72 | + do { | 87 | - key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); |
73 | + uint64_t pg = vg[reg_off >> 6]; | 88 | - } |
74 | + do { | 89 | if (opaque) { |
75 | + if ((pg >> (reg_off & 63)) & 1) { | 90 | r2->opaque = opaque; |
76 | + cpu_check_watchpoint(env_cpu(env), addr + mem_off, | 91 | } |
77 | + msize, info->page[1].attrs, | 92 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
78 | + wp_access, retaddr); | 93 | /* Make sure reginfo passed to helpers for wildcarded regs |
79 | + } | 94 | * has the correct crm/opc1/opc2 for this reg, not CP_ANY: |
80 | + reg_off += esize; | 95 | */ |
81 | + mem_off += msize; | 96 | + r2->cp = cp; |
82 | + } while (reg_off & 63); | 97 | r2->crm = crm; |
83 | + } while (reg_off <= reg_last); | 98 | r2->opc1 = opc1; |
84 | + } | 99 | r2->opc2 = opc2; |
85 | +#endif | ||
86 | +} | ||
87 | + | ||
88 | /* | ||
89 | * The result of tlb_vaddr_to_host for user-only is just g2h(x), | ||
90 | * which is always non-null. Elide the useless test. | ||
91 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | ||
92 | /* Probe the page(s). Exit with exception for any invalid page. */ | ||
93 | sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_LOAD, retaddr); | ||
94 | |||
95 | + /* Handle watchpoints for all active elements. */ | ||
96 | + sve_cont_ldst_watchpoints(&info, env, vg, addr, 1 << esz, 1 << msz, | ||
97 | + BP_MEM_READ, retaddr); | ||
98 | + | ||
99 | + /* TODO: MTE check. */ | ||
100 | + | ||
101 | flags = info.page[0].flags | info.page[1].flags; | ||
102 | if (unlikely(flags != 0)) { | ||
103 | #ifdef CONFIG_USER_ONLY | ||
104 | g_assert_not_reached(); | ||
105 | #else | ||
106 | /* | ||
107 | - * At least one page includes MMIO (or watchpoints). | ||
108 | + * At least one page includes MMIO. | ||
109 | * Any bus operation can fail with cpu_transaction_failed, | ||
110 | * which for ARM will raise SyncExternal. Perform the load | ||
111 | * into scratch memory to preserve register state until the end. | ||
112 | -- | 100 | -- |
113 | 2.20.1 | 101 | 2.25.1 |
114 | |||
115 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The only caller of cpu_watchpoint_address_matches passes | 3 | Put most of the value writeback to the same place, |
4 | TARGET_PAGE_SIZE, so the bug is not currently visible. | 4 | and improve the comment that goes with them. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20220501055028.646596-15-richard.henderson@linaro.org |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 20200508154359.7494-3-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | exec.c | 2 +- | 11 | target/arm/helper.c | 28 ++++++++++++---------------- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 12 insertions(+), 16 deletions(-) |
14 | 13 | ||
15 | diff --git a/exec.c b/exec.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/exec.c | 16 | --- a/target/arm/helper.c |
18 | +++ b/exec.c | 17 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len) | 18 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
20 | int ret = 0; | 19 | *r2 = *r; |
21 | 20 | r2->name = memcpy(r2 + 1, name, name_len); | |
22 | QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { | 21 | |
23 | - if (watchpoint_address_matches(wp, addr, TARGET_PAGE_SIZE)) { | 22 | - /* Reset the secure state to the specific incoming state. This is |
24 | + if (watchpoint_address_matches(wp, addr, len)) { | 23 | - * necessary as the register may have been defined with both states. |
25 | ret |= wp->flags; | 24 | + /* |
25 | + * Update fields to match the instantiation, overwiting wildcards | ||
26 | + * such as CP_ANY, ARM_CP_STATE_BOTH, or ARM_CP_SECSTATE_BOTH. | ||
27 | */ | ||
28 | + r2->cp = cp; | ||
29 | + r2->crm = crm; | ||
30 | + r2->opc1 = opc1; | ||
31 | + r2->opc2 = opc2; | ||
32 | + r2->state = state; | ||
33 | r2->secure = secstate; | ||
34 | + if (opaque) { | ||
35 | + r2->opaque = opaque; | ||
36 | + } | ||
37 | |||
38 | if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { | ||
39 | /* Register is banked (using both entries in array). | ||
40 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
41 | #endif | ||
26 | } | 42 | } |
27 | } | 43 | } |
44 | - if (opaque) { | ||
45 | - r2->opaque = opaque; | ||
46 | - } | ||
47 | - /* reginfo passed to helpers is correct for the actual access, | ||
48 | - * and is never ARM_CP_STATE_BOTH: | ||
49 | - */ | ||
50 | - r2->state = state; | ||
51 | - /* Make sure reginfo passed to helpers for wildcarded regs | ||
52 | - * has the correct crm/opc1/opc2 for this reg, not CP_ANY: | ||
53 | - */ | ||
54 | - r2->cp = cp; | ||
55 | - r2->crm = crm; | ||
56 | - r2->opc1 = opc1; | ||
57 | - r2->opc2 = opc2; | ||
58 | + | ||
59 | /* By convention, for wildcarded registers only the first | ||
60 | * entry is used for migration; the others are marked as | ||
61 | * ALIAS so we don't try to transfer the register | ||
28 | -- | 62 | -- |
29 | 2.20.1 | 63 | 2.25.1 |
30 | |||
31 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Bool is a more appropriate type for these variables. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Message-id: 20220501055028.646596-16-richard.henderson@linaro.org |
5 | Message-id: 20200508154359.7494-2-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | include/hw/core/cpu.h | 23 +++++++++++++++++++++++ | 10 | target/arm/helper.c | 4 ++-- |
9 | 1 file changed, 23 insertions(+) | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
10 | 12 | ||
11 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/hw/core/cpu.h | 15 | --- a/target/arm/helper.c |
14 | +++ b/include/hw/core/cpu.h | 16 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, | 17 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
16 | vaddr len, int flags); | 18 | */ |
17 | void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint); | 19 | uint32_t key; |
18 | void cpu_watchpoint_remove_all(CPUState *cpu, int mask); | 20 | ARMCPRegInfo *r2; |
19 | + | 21 | - int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
20 | +/** | 22 | - int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; |
21 | + * cpu_check_watchpoint: | 23 | + bool is64 = r->type & ARM_CP_64BIT; |
22 | + * @cpu: cpu context | 24 | + bool ns = secstate & ARM_CP_SECSTATE_NS; |
23 | + * @addr: guest virtual address | 25 | int cp = r->cp; |
24 | + * @len: access length | 26 | size_t name_len; |
25 | + * @attrs: memory access attributes | ||
26 | + * @flags: watchpoint access type | ||
27 | + * @ra: unwind return address | ||
28 | + * | ||
29 | + * Check for a watchpoint hit in [addr, addr+len) of the type | ||
30 | + * specified by @flags. Exit via exception with a hit. | ||
31 | + */ | ||
32 | void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
33 | MemTxAttrs attrs, int flags, uintptr_t ra); | ||
34 | + | ||
35 | +/** | ||
36 | + * cpu_watchpoint_address_matches: | ||
37 | + * @cpu: cpu context | ||
38 | + * @addr: guest virtual address | ||
39 | + * @len: access length | ||
40 | + * | ||
41 | + * Return the watchpoint flags that apply to [addr, addr+len). | ||
42 | + * If no watchpoint is registered for the range, the result is 0. | ||
43 | + */ | ||
44 | int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len); | ||
45 | #endif | ||
46 | 27 | ||
47 | -- | 28 | -- |
48 | 2.20.1 | 29 | 2.25.1 |
49 | |||
50 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We have validated that addr+size does not cross a page boundary. | 3 | Computing isbanked only once makes the code |
4 | Therefore we need to validate exactly one page. We can achieve | 4 | a bit easier to read. |
5 | that passing any value 1 <= x <= size to page_check_range. | ||
6 | |||
7 | Passing 1 will simplify the next patch. | ||
8 | 5 | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200508154359.7494-5-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20220501055028.646596-17-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | accel/tcg/user-exec.c | 2 +- | 11 | target/arm/helper.c | 6 ++++-- |
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 4 insertions(+), 2 deletions(-) |
16 | 13 | ||
17 | diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/accel/tcg/user-exec.c | 16 | --- a/target/arm/helper.c |
20 | +++ b/accel/tcg/user-exec.c | 17 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, | 18 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
22 | g_assert_not_reached(); | 19 | bool is64 = r->type & ARM_CP_64BIT; |
20 | bool ns = secstate & ARM_CP_SECSTATE_NS; | ||
21 | int cp = r->cp; | ||
22 | + bool isbanked; | ||
23 | size_t name_len; | ||
24 | |||
25 | switch (state) { | ||
26 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
27 | r2->opaque = opaque; | ||
23 | } | 28 | } |
24 | 29 | ||
25 | - if (!guest_addr_valid(addr) || page_check_range(addr, size, flags) < 0) { | 30 | - if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { |
26 | + if (!guest_addr_valid(addr) || page_check_range(addr, 1, flags) < 0) { | 31 | + isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; |
27 | CPUState *cpu = env_cpu(env); | 32 | + if (isbanked) { |
28 | CPUClass *cc = CPU_GET_CLASS(cpu); | 33 | /* Register is banked (using both entries in array). |
29 | cc->tlb_fill(cpu, addr, size, access_type, MMU_USER_IDX, false, | 34 | * Overwriting fieldoffset as the array is only used to define |
35 | * banked registers but later only fieldoffset is used. | ||
36 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
37 | } | ||
38 | |||
39 | if (state == ARM_CP_STATE_AA32) { | ||
40 | - if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { | ||
41 | + if (isbanked) { | ||
42 | /* If the register is banked then we don't need to migrate or | ||
43 | * reset the 32-bit instance in certain cases: | ||
44 | * | ||
30 | -- | 45 | -- |
31 | 2.20.1 | 46 | 2.25.1 |
32 | |||
33 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This new interface will allow targets to probe for a page | 3 | Perform the override check early, so that it is still done |
4 | and then handle watchpoints themselves. This will be most | 4 | even when we decide to discard an unreachable cpreg. |
5 | useful for vector predicated memory operations, where one | 5 | |
6 | page lookup can be used for many operations, and one test | 6 | Use assert not printf+abort. |
7 | can avoid many watchpoint checks. | ||
8 | 7 | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200508154359.7494-6-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Message-id: 20220501055028.646596-18-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 12 | --- |
14 | include/exec/cpu-all.h | 13 ++- | 13 | target/arm/helper.c | 22 ++++++++-------------- |
15 | include/exec/exec-all.h | 22 +++++ | 14 | 1 file changed, 8 insertions(+), 14 deletions(-) |
16 | accel/tcg/cputlb.c | 177 ++++++++++++++++++++-------------------- | ||
17 | accel/tcg/user-exec.c | 43 ++++++++-- | ||
18 | 4 files changed, 158 insertions(+), 97 deletions(-) | ||
19 | 15 | ||
20 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/cpu-all.h | 18 | --- a/target/arm/helper.c |
23 | +++ b/include/exec/cpu-all.h | 19 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ CPUArchState *cpu_copy(CPUArchState *env); | 20 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
25 | | CPU_INTERRUPT_TGT_EXT_3 \ | ||
26 | | CPU_INTERRUPT_TGT_EXT_4) | ||
27 | |||
28 | -#if !defined(CONFIG_USER_ONLY) | ||
29 | +#ifdef CONFIG_USER_ONLY | ||
30 | + | ||
31 | +/* | ||
32 | + * Allow some level of source compatibility with softmmu. We do not | ||
33 | + * support any of the more exotic features, so only invalid pages may | ||
34 | + * be signaled by probe_access_flags(). | ||
35 | + */ | ||
36 | +#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS_MIN - 1)) | ||
37 | +#define TLB_MMIO 0 | ||
38 | +#define TLB_WATCHPOINT 0 | ||
39 | + | ||
40 | +#else | ||
41 | |||
42 | /* | ||
43 | * Flags stored in the low bits of the TLB virtual address. | ||
44 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/include/exec/exec-all.h | ||
47 | +++ b/include/exec/exec-all.h | ||
48 | @@ -XXX,XX +XXX,XX @@ static inline void *probe_read(CPUArchState *env, target_ulong addr, int size, | ||
49 | return probe_access(env, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); | ||
50 | } | ||
51 | |||
52 | +/** | ||
53 | + * probe_access_flags: | ||
54 | + * @env: CPUArchState | ||
55 | + * @addr: guest virtual address to look up | ||
56 | + * @access_type: read, write or execute permission | ||
57 | + * @mmu_idx: MMU index to use for lookup | ||
58 | + * @nonfault: suppress the fault | ||
59 | + * @phost: return value for host address | ||
60 | + * @retaddr: return address for unwinding | ||
61 | + * | ||
62 | + * Similar to probe_access, loosely returning the TLB_FLAGS_MASK for | ||
63 | + * the page, and storing the host address for RAM in @phost. | ||
64 | + * | ||
65 | + * If @nonfault is set, do not raise an exception but return TLB_INVALID_MASK. | ||
66 | + * Do not handle watchpoints, but include TLB_WATCHPOINT in the returned flags. | ||
67 | + * Do handle clean pages, so exclude TLB_NOTDIRY from the returned flags. | ||
68 | + * For simplicity, all "mmio-like" flags are folded to TLB_MMIO. | ||
69 | + */ | ||
70 | +int probe_access_flags(CPUArchState *env, target_ulong addr, | ||
71 | + MMUAccessType access_type, int mmu_idx, | ||
72 | + bool nonfault, void **phost, uintptr_t retaddr); | ||
73 | + | ||
74 | #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ | ||
75 | |||
76 | /* Estimated block size for TB allocation. */ | ||
77 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/accel/tcg/cputlb.c | ||
80 | +++ b/accel/tcg/cputlb.c | ||
81 | @@ -XXX,XX +XXX,XX @@ static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size, | ||
82 | } | ||
83 | } | ||
84 | |||
85 | -/* | ||
86 | - * Probe for whether the specified guest access is permitted. If it is not | ||
87 | - * permitted then an exception will be taken in the same way as if this | ||
88 | - * were a real access (and we will not return). | ||
89 | - * If the size is 0 or the page requires I/O access, returns NULL; otherwise, | ||
90 | - * returns the address of the host page similar to tlb_vaddr_to_host(). | ||
91 | - */ | ||
92 | -void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
93 | - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) | ||
94 | +static int probe_access_internal(CPUArchState *env, target_ulong addr, | ||
95 | + int fault_size, MMUAccessType access_type, | ||
96 | + int mmu_idx, bool nonfault, | ||
97 | + void **phost, uintptr_t retaddr) | ||
98 | { | ||
99 | uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
100 | CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); | ||
101 | - target_ulong tlb_addr; | ||
102 | - size_t elt_ofs; | ||
103 | - int wp_access; | ||
104 | - | ||
105 | - g_assert(-(addr | TARGET_PAGE_MASK) >= size); | ||
106 | - | ||
107 | - switch (access_type) { | ||
108 | - case MMU_DATA_LOAD: | ||
109 | - elt_ofs = offsetof(CPUTLBEntry, addr_read); | ||
110 | - wp_access = BP_MEM_READ; | ||
111 | - break; | ||
112 | - case MMU_DATA_STORE: | ||
113 | - elt_ofs = offsetof(CPUTLBEntry, addr_write); | ||
114 | - wp_access = BP_MEM_WRITE; | ||
115 | - break; | ||
116 | - case MMU_INST_FETCH: | ||
117 | - elt_ofs = offsetof(CPUTLBEntry, addr_code); | ||
118 | - wp_access = BP_MEM_READ; | ||
119 | - break; | ||
120 | - default: | ||
121 | - g_assert_not_reached(); | ||
122 | - } | ||
123 | - tlb_addr = tlb_read_ofs(entry, elt_ofs); | ||
124 | - | ||
125 | - if (unlikely(!tlb_hit(tlb_addr, addr))) { | ||
126 | - if (!victim_tlb_hit(env, mmu_idx, index, elt_ofs, | ||
127 | - addr & TARGET_PAGE_MASK)) { | ||
128 | - tlb_fill(env_cpu(env), addr, size, access_type, mmu_idx, retaddr); | ||
129 | - /* TLB resize via tlb_fill may have moved the entry. */ | ||
130 | - index = tlb_index(env, mmu_idx, addr); | ||
131 | - entry = tlb_entry(env, mmu_idx, addr); | ||
132 | - } | ||
133 | - tlb_addr = tlb_read_ofs(entry, elt_ofs); | ||
134 | - } | ||
135 | - | ||
136 | - if (!size) { | ||
137 | - return NULL; | ||
138 | - } | ||
139 | - | ||
140 | - if (unlikely(tlb_addr & TLB_FLAGS_MASK)) { | ||
141 | - CPUIOTLBEntry *iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
142 | - | ||
143 | - /* Reject I/O access, or other required slow-path. */ | ||
144 | - if (tlb_addr & (TLB_MMIO | TLB_BSWAP | TLB_DISCARD_WRITE)) { | ||
145 | - return NULL; | ||
146 | - } | ||
147 | - | ||
148 | - /* Handle watchpoints. */ | ||
149 | - if (tlb_addr & TLB_WATCHPOINT) { | ||
150 | - cpu_check_watchpoint(env_cpu(env), addr, size, | ||
151 | - iotlbentry->attrs, wp_access, retaddr); | ||
152 | - } | ||
153 | - | ||
154 | - /* Handle clean RAM pages. */ | ||
155 | - if (tlb_addr & TLB_NOTDIRTY) { | ||
156 | - notdirty_write(env_cpu(env), addr, size, iotlbentry, retaddr); | ||
157 | - } | ||
158 | - } | ||
159 | - | ||
160 | - return (void *)((uintptr_t)addr + entry->addend); | ||
161 | -} | ||
162 | - | ||
163 | -void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, | ||
164 | - MMUAccessType access_type, int mmu_idx) | ||
165 | -{ | ||
166 | - CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); | ||
167 | - target_ulong tlb_addr, page; | ||
168 | + target_ulong tlb_addr, page_addr; | ||
169 | size_t elt_ofs; | ||
170 | + int flags; | ||
171 | |||
172 | switch (access_type) { | ||
173 | case MMU_DATA_LOAD: | ||
174 | @@ -XXX,XX +XXX,XX @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, | ||
175 | default: | ||
176 | g_assert_not_reached(); | 21 | g_assert_not_reached(); |
177 | } | 22 | } |
178 | - | 23 | |
179 | - page = addr & TARGET_PAGE_MASK; | 24 | + /* Overriding of an existing definition must be explicitly requested. */ |
180 | tlb_addr = tlb_read_ofs(entry, elt_ofs); | 25 | + if (!(r->type & ARM_CP_OVERRIDE)) { |
181 | 26 | + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); | |
182 | - if (!tlb_hit_page(tlb_addr, page)) { | 27 | + if (oldreg) { |
183 | - uintptr_t index = tlb_index(env, mmu_idx, addr); | 28 | + assert(oldreg->type & ARM_CP_OVERRIDE); |
184 | - | ||
185 | - if (!victim_tlb_hit(env, mmu_idx, index, elt_ofs, page)) { | ||
186 | + page_addr = addr & TARGET_PAGE_MASK; | ||
187 | + if (!tlb_hit_page(tlb_addr, page_addr)) { | ||
188 | + if (!victim_tlb_hit(env, mmu_idx, index, elt_ofs, page_addr)) { | ||
189 | CPUState *cs = env_cpu(env); | ||
190 | CPUClass *cc = CPU_GET_CLASS(cs); | ||
191 | |||
192 | - if (!cc->tlb_fill(cs, addr, 0, access_type, mmu_idx, true, 0)) { | ||
193 | + if (!cc->tlb_fill(cs, addr, fault_size, access_type, | ||
194 | + mmu_idx, nonfault, retaddr)) { | ||
195 | /* Non-faulting page table read failed. */ | ||
196 | - return NULL; | ||
197 | + *phost = NULL; | ||
198 | + return TLB_INVALID_MASK; | ||
199 | } | ||
200 | |||
201 | /* TLB resize via tlb_fill may have moved the entry. */ | ||
202 | @@ -XXX,XX +XXX,XX @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, | ||
203 | } | ||
204 | tlb_addr = tlb_read_ofs(entry, elt_ofs); | ||
205 | } | ||
206 | + flags = tlb_addr & TLB_FLAGS_MASK; | ||
207 | |||
208 | - if (tlb_addr & ~TARGET_PAGE_MASK) { | ||
209 | - /* IO access */ | ||
210 | + /* Fold all "mmio-like" bits into TLB_MMIO. This is not RAM. */ | ||
211 | + if (unlikely(flags & ~(TLB_WATCHPOINT | TLB_NOTDIRTY))) { | ||
212 | + *phost = NULL; | ||
213 | + return TLB_MMIO; | ||
214 | + } | ||
215 | + | ||
216 | + /* Everything else is RAM. */ | ||
217 | + *phost = (void *)((uintptr_t)addr + entry->addend); | ||
218 | + return flags; | ||
219 | +} | ||
220 | + | ||
221 | +int probe_access_flags(CPUArchState *env, target_ulong addr, | ||
222 | + MMUAccessType access_type, int mmu_idx, | ||
223 | + bool nonfault, void **phost, uintptr_t retaddr) | ||
224 | +{ | ||
225 | + int flags; | ||
226 | + | ||
227 | + flags = probe_access_internal(env, addr, 0, access_type, mmu_idx, | ||
228 | + nonfault, phost, retaddr); | ||
229 | + | ||
230 | + /* Handle clean RAM pages. */ | ||
231 | + if (unlikely(flags & TLB_NOTDIRTY)) { | ||
232 | + uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
233 | + CPUIOTLBEntry *iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
234 | + | ||
235 | + notdirty_write(env_cpu(env), addr, 1, iotlbentry, retaddr); | ||
236 | + flags &= ~TLB_NOTDIRTY; | ||
237 | + } | ||
238 | + | ||
239 | + return flags; | ||
240 | +} | ||
241 | + | ||
242 | +void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
243 | + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) | ||
244 | +{ | ||
245 | + void *host; | ||
246 | + int flags; | ||
247 | + | ||
248 | + g_assert(-(addr | TARGET_PAGE_MASK) >= size); | ||
249 | + | ||
250 | + flags = probe_access_internal(env, addr, size, access_type, mmu_idx, | ||
251 | + false, &host, retaddr); | ||
252 | + | ||
253 | + /* Per the interface, size == 0 merely faults the access. */ | ||
254 | + if (size == 0) { | ||
255 | return NULL; | ||
256 | } | ||
257 | |||
258 | - return (void *)((uintptr_t)addr + entry->addend); | ||
259 | + if (unlikely(flags & (TLB_NOTDIRTY | TLB_WATCHPOINT))) { | ||
260 | + uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
261 | + CPUIOTLBEntry *iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
262 | + | ||
263 | + /* Handle watchpoints. */ | ||
264 | + if (flags & TLB_WATCHPOINT) { | ||
265 | + int wp_access = (access_type == MMU_DATA_STORE | ||
266 | + ? BP_MEM_WRITE : BP_MEM_READ); | ||
267 | + cpu_check_watchpoint(env_cpu(env), addr, size, | ||
268 | + iotlbentry->attrs, wp_access, retaddr); | ||
269 | + } | ||
270 | + | ||
271 | + /* Handle clean RAM pages. */ | ||
272 | + if (flags & TLB_NOTDIRTY) { | ||
273 | + notdirty_write(env_cpu(env), addr, 1, iotlbentry, retaddr); | ||
274 | + } | 29 | + } |
275 | + } | 30 | + } |
276 | + | 31 | + |
277 | + return host; | 32 | /* Combine cpreg and name into one allocation. */ |
33 | name_len = strlen(name) + 1; | ||
34 | r2 = g_malloc(sizeof(*r2) + name_len); | ||
35 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
36 | assert(!raw_accessors_invalid(r2)); | ||
37 | } | ||
38 | |||
39 | - /* Overriding of an existing definition must be explicitly | ||
40 | - * requested. | ||
41 | - */ | ||
42 | - if (!(r->type & ARM_CP_OVERRIDE)) { | ||
43 | - const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); | ||
44 | - if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { | ||
45 | - fprintf(stderr, "Register redefined: cp=%d %d bit " | ||
46 | - "crn=%d crm=%d opc1=%d opc2=%d, " | ||
47 | - "was %s, now %s\n", r2->cp, 32 + 32 * is64, | ||
48 | - r2->crn, r2->crm, r2->opc1, r2->opc2, | ||
49 | - oldreg->name, r2->name); | ||
50 | - g_assert_not_reached(); | ||
51 | - } | ||
52 | - } | ||
53 | g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); | ||
278 | } | 54 | } |
279 | 55 | ||
280 | +void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, | ||
281 | + MMUAccessType access_type, int mmu_idx) | ||
282 | +{ | ||
283 | + void *host; | ||
284 | + int flags; | ||
285 | + | ||
286 | + flags = probe_access_internal(env, addr, 0, access_type, | ||
287 | + mmu_idx, true, &host, 0); | ||
288 | + | ||
289 | + /* No combination of flags are expected by the caller. */ | ||
290 | + return flags ? NULL : host; | ||
291 | +} | ||
292 | |||
293 | #ifdef CONFIG_PLUGIN | ||
294 | /* | ||
295 | diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c | ||
296 | index XXXXXXX..XXXXXXX 100644 | ||
297 | --- a/accel/tcg/user-exec.c | ||
298 | +++ b/accel/tcg/user-exec.c | ||
299 | @@ -XXX,XX +XXX,XX @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, | ||
300 | g_assert_not_reached(); | ||
301 | } | ||
302 | |||
303 | -void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
304 | - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) | ||
305 | +static int probe_access_internal(CPUArchState *env, target_ulong addr, | ||
306 | + int fault_size, MMUAccessType access_type, | ||
307 | + bool nonfault, uintptr_t ra) | ||
308 | { | ||
309 | int flags; | ||
310 | |||
311 | - g_assert(-(addr | TARGET_PAGE_MASK) >= size); | ||
312 | - | ||
313 | switch (access_type) { | ||
314 | case MMU_DATA_STORE: | ||
315 | flags = PAGE_WRITE; | ||
316 | @@ -XXX,XX +XXX,XX @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
317 | } | ||
318 | |||
319 | if (!guest_addr_valid(addr) || page_check_range(addr, 1, flags) < 0) { | ||
320 | - CPUState *cpu = env_cpu(env); | ||
321 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
322 | - cc->tlb_fill(cpu, addr, size, access_type, MMU_USER_IDX, false, | ||
323 | - retaddr); | ||
324 | - g_assert_not_reached(); | ||
325 | + if (nonfault) { | ||
326 | + return TLB_INVALID_MASK; | ||
327 | + } else { | ||
328 | + CPUState *cpu = env_cpu(env); | ||
329 | + CPUClass *cc = CPU_GET_CLASS(cpu); | ||
330 | + cc->tlb_fill(cpu, addr, fault_size, access_type, | ||
331 | + MMU_USER_IDX, false, ra); | ||
332 | + g_assert_not_reached(); | ||
333 | + } | ||
334 | } | ||
335 | + return 0; | ||
336 | +} | ||
337 | + | ||
338 | +int probe_access_flags(CPUArchState *env, target_ulong addr, | ||
339 | + MMUAccessType access_type, int mmu_idx, | ||
340 | + bool nonfault, void **phost, uintptr_t ra) | ||
341 | +{ | ||
342 | + int flags; | ||
343 | + | ||
344 | + flags = probe_access_internal(env, addr, 0, access_type, nonfault, ra); | ||
345 | + *phost = flags ? NULL : g2h(addr); | ||
346 | + return flags; | ||
347 | +} | ||
348 | + | ||
349 | +void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
350 | + MMUAccessType access_type, int mmu_idx, uintptr_t ra) | ||
351 | +{ | ||
352 | + int flags; | ||
353 | + | ||
354 | + g_assert(-(addr | TARGET_PAGE_MASK) >= size); | ||
355 | + flags = probe_access_internal(env, addr, size, access_type, false, ra); | ||
356 | + g_assert(flags == 0); | ||
357 | |||
358 | return size ? g2h(addr) : NULL; | ||
359 | } | ||
360 | -- | 56 | -- |
361 | 2.20.1 | 57 | 2.25.1 |
362 | |||
363 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Since we converted back to cpu_*_data_ra, we do not need to | 3 | Put the block comments into the current coding style. |
4 | do this ourselves. | ||
5 | 4 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Message-id: 20220501055028.646596-19-richard.henderson@linaro.org |
8 | Message-id: 20200508154359.7494-9-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 9 | --- |
11 | target/arm/sve_helper.c | 38 -------------------------------------- | 10 | target/arm/helper.c | 24 +++++++++++++++--------- |
12 | 1 file changed, 38 deletions(-) | 11 | 1 file changed, 15 insertions(+), 9 deletions(-) |
13 | 12 | ||
14 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/sve_helper.c | 15 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/sve_helper.c | 16 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static intptr_t max_for_page(target_ulong base, intptr_t mem_off, | 17 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) |
19 | return MIN(split, mem_max - mem_off) + mem_off; | 18 | return cpu_list; |
20 | } | 19 | } |
21 | 20 | ||
22 | -#ifndef CONFIG_USER_ONLY | 21 | +/* |
23 | -/* These are normally defined only for CONFIG_USER_ONLY in <exec/cpu_ldst.h> */ | 22 | + * Private utility function for define_one_arm_cp_reg_with_opaque(): |
24 | -static inline void set_helper_retaddr(uintptr_t ra) { } | 23 | + * add a single reginfo struct to the hash table. |
25 | -static inline void clear_helper_retaddr(void) { } | 24 | + */ |
26 | -#endif | 25 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
27 | - | 26 | void *opaque, CPState state, |
28 | /* | 27 | CPSecureState secstate, |
29 | * The result of tlb_vaddr_to_host for user-only is just g2h(x), | 28 | int crm, int opc1, int opc2, |
30 | * which is always non-null. Elide the useless test. | 29 | const char *name) |
31 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | 30 | { |
32 | return; | 31 | - /* Private utility function for define_one_arm_cp_reg_with_opaque(): |
33 | } | 32 | - * add a single reginfo struct to the hash table. |
34 | mem_off = reg_off >> diffsz; | 33 | - */ |
35 | - set_helper_retaddr(retaddr); | 34 | uint32_t key; |
36 | 35 | ARMCPRegInfo *r2; | |
37 | /* | 36 | bool is64 = r->type & ARM_CP_64BIT; |
38 | * If the (remaining) load is entirely within a single page, then: | 37 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
39 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | 38 | |
40 | if (test_host_page(host)) { | 39 | isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; |
41 | mem_off = host_fn(vd, vg, host - mem_off, mem_off, mem_max); | 40 | if (isbanked) { |
42 | tcg_debug_assert(mem_off == mem_max); | 41 | - /* Register is banked (using both entries in array). |
43 | - clear_helper_retaddr(); | 42 | + /* |
44 | /* After having taken any fault, zero leading inactive elements. */ | 43 | + * Register is banked (using both entries in array). |
45 | swap_memzero(vd, reg_off); | 44 | * Overwriting fieldoffset as the array is only used to define |
46 | return; | 45 | * banked registers but later only fieldoffset is used. |
47 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | 46 | */ |
48 | } | 47 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
49 | #endif | 48 | |
50 | 49 | if (state == ARM_CP_STATE_AA32) { | |
51 | - clear_helper_retaddr(); | 50 | if (isbanked) { |
52 | memcpy(vd, &scratch, reg_max); | 51 | - /* If the register is banked then we don't need to migrate or |
53 | } | 52 | + /* |
54 | 53 | + * If the register is banked then we don't need to migrate or | |
55 | @@ -XXX,XX +XXX,XX @@ static void sve_ld2_r(CPUARMState *env, void *vg, target_ulong addr, | 54 | * reset the 32-bit instance in certain cases: |
56 | intptr_t i, oprsz = simd_oprsz(desc); | 55 | * |
57 | ARMVectorReg scratch[2] = { }; | 56 | * 1) If the register has both 32-bit and 64-bit instances then we |
58 | 57 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | |
59 | - set_helper_retaddr(ra); | 58 | r2->type |= ARM_CP_ALIAS; |
60 | for (i = 0; i < oprsz; ) { | 59 | } |
61 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | 60 | } else if ((secstate != r->secure) && !ns) { |
62 | do { | 61 | - /* The register is not banked so we only want to allow migration of |
63 | @@ -XXX,XX +XXX,XX @@ static void sve_ld2_r(CPUARMState *env, void *vg, target_ulong addr, | 62 | - * the non-secure instance. |
64 | addr += 2 * size; | 63 | + /* |
65 | } while (i & 15); | 64 | + * The register is not banked so we only want to allow migration |
66 | } | 65 | + * of the non-secure instance. |
67 | - clear_helper_retaddr(); | 66 | */ |
68 | 67 | r2->type |= ARM_CP_ALIAS; | |
69 | /* Wait until all exceptions have been raised to write back. */ | 68 | } |
70 | memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); | 69 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
71 | @@ -XXX,XX +XXX,XX @@ static void sve_ld3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
72 | intptr_t i, oprsz = simd_oprsz(desc); | ||
73 | ARMVectorReg scratch[3] = { }; | ||
74 | |||
75 | - set_helper_retaddr(ra); | ||
76 | for (i = 0; i < oprsz; ) { | ||
77 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
78 | do { | ||
79 | @@ -XXX,XX +XXX,XX @@ static void sve_ld3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
80 | addr += 3 * size; | ||
81 | } while (i & 15); | ||
82 | } | ||
83 | - clear_helper_retaddr(); | ||
84 | |||
85 | /* Wait until all exceptions have been raised to write back. */ | ||
86 | memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); | ||
87 | @@ -XXX,XX +XXX,XX @@ static void sve_ld4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
88 | intptr_t i, oprsz = simd_oprsz(desc); | ||
89 | ARMVectorReg scratch[4] = { }; | ||
90 | |||
91 | - set_helper_retaddr(ra); | ||
92 | for (i = 0; i < oprsz; ) { | ||
93 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
94 | do { | ||
95 | @@ -XXX,XX +XXX,XX @@ static void sve_ld4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
96 | addr += 4 * size; | ||
97 | } while (i & 15); | ||
98 | } | ||
99 | - clear_helper_retaddr(); | ||
100 | |||
101 | /* Wait until all exceptions have been raised to write back. */ | ||
102 | memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); | ||
103 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
104 | return; | ||
105 | } | ||
106 | mem_off = reg_off >> diffsz; | ||
107 | - set_helper_retaddr(retaddr); | ||
108 | |||
109 | /* | ||
110 | * If the (remaining) load is entirely within a single page, then: | ||
111 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
112 | if (test_host_page(host)) { | ||
113 | mem_off = host_fn(vd, vg, host - mem_off, mem_off, mem_max); | ||
114 | tcg_debug_assert(mem_off == mem_max); | ||
115 | - clear_helper_retaddr(); | ||
116 | /* After any fault, zero any leading inactive elements. */ | ||
117 | swap_memzero(vd, reg_off); | ||
118 | return; | ||
119 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
120 | } | ||
121 | #endif | ||
122 | |||
123 | - clear_helper_retaddr(); | ||
124 | record_fault(env, reg_off, reg_max); | ||
125 | } | ||
126 | |||
127 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_r(CPUARMState *env, void *vg, target_ulong addr, | ||
128 | intptr_t i, oprsz = simd_oprsz(desc); | ||
129 | void *vd = &env->vfp.zregs[rd]; | ||
130 | |||
131 | - set_helper_retaddr(ra); | ||
132 | for (i = 0; i < oprsz; ) { | ||
133 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
134 | do { | ||
135 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_r(CPUARMState *env, void *vg, target_ulong addr, | ||
136 | addr += msize; | ||
137 | } while (i & 15); | ||
138 | } | ||
139 | - clear_helper_retaddr(); | ||
140 | } | ||
141 | |||
142 | static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
143 | @@ -XXX,XX +XXX,XX @@ static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
144 | void *d1 = &env->vfp.zregs[rd]; | ||
145 | void *d2 = &env->vfp.zregs[(rd + 1) & 31]; | ||
146 | |||
147 | - set_helper_retaddr(ra); | ||
148 | for (i = 0; i < oprsz; ) { | ||
149 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
150 | do { | ||
151 | @@ -XXX,XX +XXX,XX @@ static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, | ||
152 | addr += 2 * msize; | ||
153 | } while (i & 15); | ||
154 | } | ||
155 | - clear_helper_retaddr(); | ||
156 | } | ||
157 | |||
158 | static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
159 | @@ -XXX,XX +XXX,XX @@ static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
160 | void *d2 = &env->vfp.zregs[(rd + 1) & 31]; | ||
161 | void *d3 = &env->vfp.zregs[(rd + 2) & 31]; | ||
162 | |||
163 | - set_helper_retaddr(ra); | ||
164 | for (i = 0; i < oprsz; ) { | ||
165 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
166 | do { | ||
167 | @@ -XXX,XX +XXX,XX @@ static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, | ||
168 | addr += 3 * msize; | ||
169 | } while (i & 15); | ||
170 | } | ||
171 | - clear_helper_retaddr(); | ||
172 | } | ||
173 | |||
174 | static void sve_st4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
175 | @@ -XXX,XX +XXX,XX @@ static void sve_st4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
176 | void *d3 = &env->vfp.zregs[(rd + 2) & 31]; | ||
177 | void *d4 = &env->vfp.zregs[(rd + 3) & 31]; | ||
178 | |||
179 | - set_helper_retaddr(ra); | ||
180 | for (i = 0; i < oprsz; ) { | ||
181 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
182 | do { | ||
183 | @@ -XXX,XX +XXX,XX @@ static void sve_st4_r(CPUARMState *env, void *vg, target_ulong addr, | ||
184 | addr += 4 * msize; | ||
185 | } while (i & 15); | ||
186 | } | ||
187 | - clear_helper_retaddr(); | ||
188 | } | ||
189 | |||
190 | #define DO_STN_1(N, NAME, ESIZE) \ | ||
191 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
192 | intptr_t i, oprsz = simd_oprsz(desc); | ||
193 | ARMVectorReg scratch = { }; | ||
194 | |||
195 | - set_helper_retaddr(ra); | ||
196 | for (i = 0; i < oprsz; ) { | ||
197 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
198 | do { | ||
199 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
200 | i += 4, pg >>= 4; | ||
201 | } while (i & 15); | ||
202 | } | ||
203 | - clear_helper_retaddr(); | ||
204 | |||
205 | /* Wait until all exceptions have been raised to write back. */ | ||
206 | memcpy(vd, &scratch, oprsz); | ||
207 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
208 | intptr_t i, oprsz = simd_oprsz(desc) / 8; | ||
209 | ARMVectorReg scratch = { }; | ||
210 | |||
211 | - set_helper_retaddr(ra); | ||
212 | for (i = 0; i < oprsz; i++) { | ||
213 | uint8_t pg = *(uint8_t *)(vg + H1(i)); | ||
214 | if (likely(pg & 1)) { | ||
215 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
216 | tlb_fn(env, &scratch, i * 8, base + (off << scale), ra); | ||
217 | } | 70 | } |
218 | } | 71 | } |
219 | - clear_helper_retaddr(); | 72 | |
220 | 73 | - /* By convention, for wildcarded registers only the first | |
221 | /* Wait until all exceptions have been raised to write back. */ | 74 | + /* |
222 | memcpy(vd, &scratch, oprsz * 8); | 75 | + * By convention, for wildcarded registers only the first |
223 | @@ -XXX,XX +XXX,XX @@ static inline void sve_ldff1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | 76 | * entry is used for migration; the others are marked as |
224 | reg_off = find_next_active(vg, 0, reg_max, MO_32); | 77 | * ALIAS so we don't try to transfer the register |
225 | if (likely(reg_off < reg_max)) { | 78 | * multiple times. Special registers (ie NOP/WFI) are |
226 | /* Perform one normal read, which will fault or not. */ | 79 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
227 | - set_helper_retaddr(ra); | 80 | r2->type |= ARM_CP_ALIAS | ARM_CP_NO_GDB; |
228 | addr = off_fn(vm, reg_off); | ||
229 | addr = base + (addr << scale); | ||
230 | tlb_fn(env, vd, reg_off, addr, ra); | ||
231 | |||
232 | /* The rest of the reads will be non-faulting. */ | ||
233 | - clear_helper_retaddr(); | ||
234 | } | 81 | } |
235 | 82 | ||
236 | /* After any fault, zero the leading predicated false elements. */ | 83 | - /* Check that raw accesses are either forbidden or handled. Note that |
237 | @@ -XXX,XX +XXX,XX @@ static inline void sve_ldff1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | 84 | + /* |
238 | reg_off = find_next_active(vg, 0, reg_max, MO_64); | 85 | + * Check that raw accesses are either forbidden or handled. Note that |
239 | if (likely(reg_off < reg_max)) { | 86 | * we can't assert this earlier because the setup of fieldoffset for |
240 | /* Perform one normal read, which will fault or not. */ | 87 | * banked registers has to be done first. |
241 | - set_helper_retaddr(ra); | 88 | */ |
242 | addr = off_fn(vm, reg_off); | ||
243 | addr = base + (addr << scale); | ||
244 | tlb_fn(env, vd, reg_off, addr, ra); | ||
245 | |||
246 | /* The rest of the reads will be non-faulting. */ | ||
247 | - clear_helper_retaddr(); | ||
248 | } | ||
249 | |||
250 | /* After any fault, zero the leading predicated false elements. */ | ||
251 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
252 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
253 | intptr_t i, oprsz = simd_oprsz(desc); | ||
254 | |||
255 | - set_helper_retaddr(ra); | ||
256 | for (i = 0; i < oprsz; ) { | ||
257 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
258 | do { | ||
259 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
260 | i += 4, pg >>= 4; | ||
261 | } while (i & 15); | ||
262 | } | ||
263 | - clear_helper_retaddr(); | ||
264 | } | ||
265 | |||
266 | static void sve_st1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
267 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
268 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
269 | intptr_t i, oprsz = simd_oprsz(desc) / 8; | ||
270 | |||
271 | - set_helper_retaddr(ra); | ||
272 | for (i = 0; i < oprsz; i++) { | ||
273 | uint8_t pg = *(uint8_t *)(vg + H1(i)); | ||
274 | if (likely(pg & 1)) { | ||
275 | @@ -XXX,XX +XXX,XX @@ static void sve_st1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
276 | tlb_fn(env, vd, i * 8, base + (off << scale), ra); | ||
277 | } | ||
278 | } | ||
279 | - clear_helper_retaddr(); | ||
280 | } | ||
281 | |||
282 | #define DO_ST1_ZPZ_S(MEM, OFS) \ | ||
283 | -- | 89 | -- |
284 | 2.20.1 | 90 | 2.25.1 |
285 | |||
286 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The current interface includes a loop; change it to load a | 3 | Since e03b56863d2bc, our host endian indicator is unconditionally |
4 | single element. We will then be able to use the function | 4 | set, which means that we can use a normal C condition. |
5 | for ld{2,3,4} where individual vector elements are not adjacent. | ||
6 | 5 | ||
7 | Replace each call with the simplest possible loop over active | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | elements. | ||
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20220501055028.646596-20-richard.henderson@linaro.org |
12 | Message-id: 20200508154359.7494-11-richard.henderson@linaro.org | 9 | [PMM: quote correct git hash in commit message] |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 11 | --- |
15 | target/arm/sve_helper.c | 124 ++++++++++++++++++++-------------------- | 12 | target/arm/helper.c | 9 +++------ |
16 | 1 file changed, 63 insertions(+), 61 deletions(-) | 13 | 1 file changed, 3 insertions(+), 6 deletions(-) |
17 | 14 | ||
18 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/sve_helper.c | 17 | --- a/target/arm/helper.c |
21 | +++ b/target/arm/sve_helper.c | 18 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_fcmla_zpzzz_d)(CPUARMState *env, void *vg, uint32_t desc) | 19 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
23 | */ | 20 | r2->type |= ARM_CP_ALIAS; |
24 | |||
25 | /* | ||
26 | - * Load elements into @vd, controlled by @vg, from @host + @mem_ofs. | ||
27 | - * Memory is valid through @host + @mem_max. The register element | ||
28 | - * indices are inferred from @mem_ofs, as modified by the types for | ||
29 | - * which the helper is built. Return the @mem_ofs of the first element | ||
30 | - * not loaded (which is @mem_max if they are all loaded). | ||
31 | - * | ||
32 | - * For softmmu, we have fully validated the guest page. For user-only, | ||
33 | - * we cannot fully validate without taking the mmap lock, but since we | ||
34 | - * know the access is within one host page, if any access is valid they | ||
35 | - * all must be valid. However, when @vg is all false, it may be that | ||
36 | - * no access is valid. | ||
37 | + * Load one element into @vd + @reg_off from @host. | ||
38 | + * The controlling predicate is known to be true. | ||
39 | */ | ||
40 | -typedef intptr_t sve_ld1_host_fn(void *vd, void *vg, void *host, | ||
41 | - intptr_t mem_ofs, intptr_t mem_max); | ||
42 | +typedef void sve_ldst1_host_fn(void *vd, intptr_t reg_off, void *host); | ||
43 | |||
44 | /* | ||
45 | * Load one element into @vd + @reg_off from (@env, @vaddr, @ra). | ||
46 | @@ -XXX,XX +XXX,XX @@ typedef void sve_ldst1_tlb_fn(CPUARMState *env, void *vd, intptr_t reg_off, | ||
47 | */ | ||
48 | |||
49 | #define DO_LD_HOST(NAME, H, TYPEE, TYPEM, HOST) \ | ||
50 | -static intptr_t sve_##NAME##_host(void *vd, void *vg, void *host, \ | ||
51 | - intptr_t mem_off, const intptr_t mem_max) \ | ||
52 | -{ \ | ||
53 | - intptr_t reg_off = mem_off * (sizeof(TYPEE) / sizeof(TYPEM)); \ | ||
54 | - uint64_t *pg = vg; \ | ||
55 | - while (mem_off + sizeof(TYPEM) <= mem_max) { \ | ||
56 | - TYPEM val = 0; \ | ||
57 | - if (likely((pg[reg_off >> 6] >> (reg_off & 63)) & 1)) { \ | ||
58 | - val = HOST(host + mem_off); \ | ||
59 | - } \ | ||
60 | - *(TYPEE *)(vd + H(reg_off)) = val; \ | ||
61 | - mem_off += sizeof(TYPEM), reg_off += sizeof(TYPEE); \ | ||
62 | - } \ | ||
63 | - return mem_off; \ | ||
64 | +static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ | ||
65 | +{ \ | ||
66 | + TYPEM val = HOST(host); \ | ||
67 | + *(TYPEE *)(vd + H(reg_off)) = val; \ | ||
68 | } | ||
69 | |||
70 | #define DO_LD_TLB(NAME, H, TYPEE, TYPEM, TLB) \ | ||
71 | @@ -XXX,XX +XXX,XX @@ static inline bool test_host_page(void *host) | ||
72 | static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
73 | uint32_t desc, const uintptr_t retaddr, | ||
74 | const int esz, const int msz, | ||
75 | - sve_ld1_host_fn *host_fn, | ||
76 | + sve_ldst1_host_fn *host_fn, | ||
77 | sve_ldst1_tlb_fn *tlb_fn) | ||
78 | { | ||
79 | const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | ||
80 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
81 | if (likely(split == mem_max)) { | ||
82 | host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); | ||
83 | if (test_host_page(host)) { | ||
84 | - mem_off = host_fn(vd, vg, host - mem_off, mem_off, mem_max); | ||
85 | - tcg_debug_assert(mem_off == mem_max); | ||
86 | + intptr_t i = reg_off; | ||
87 | + host -= mem_off; | ||
88 | + do { | ||
89 | + host_fn(vd, i, host + (i >> diffsz)); | ||
90 | + i = find_next_active(vg, i + (1 << esz), reg_max, esz); | ||
91 | + } while (i < reg_max); | ||
92 | /* After having taken any fault, zero leading inactive elements. */ | ||
93 | swap_memzero(vd, reg_off); | ||
94 | return; | ||
95 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
96 | */ | ||
97 | #ifdef CONFIG_USER_ONLY | ||
98 | swap_memzero(&scratch, reg_off); | ||
99 | - host_fn(&scratch, vg, g2h(addr), mem_off, mem_max); | ||
100 | + host = g2h(addr); | ||
101 | + do { | ||
102 | + host_fn(&scratch, reg_off, host + (reg_off >> diffsz)); | ||
103 | + reg_off += 1 << esz; | ||
104 | + reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
105 | + } while (reg_off < reg_max); | ||
106 | #else | ||
107 | memset(&scratch, 0, reg_max); | ||
108 | goto start; | ||
109 | @@ -XXX,XX +XXX,XX @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
110 | host = tlb_vaddr_to_host(env, addr + mem_off, | ||
111 | MMU_DATA_LOAD, mmu_idx); | ||
112 | if (host) { | ||
113 | - mem_off = host_fn(&scratch, vg, host - mem_off, | ||
114 | - mem_off, split); | ||
115 | - reg_off = mem_off << diffsz; | ||
116 | + host -= mem_off; | ||
117 | + do { | ||
118 | + host_fn(&scratch, reg_off, host + mem_off); | ||
119 | + reg_off += 1 << esz; | ||
120 | + reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
121 | + mem_off = reg_off >> diffsz; | ||
122 | + } while (split - mem_off >= (1 << msz)); | ||
123 | continue; | ||
124 | } | ||
125 | } | 21 | } |
126 | @@ -XXX,XX +XXX,XX @@ static void record_fault(CPUARMState *env, uintptr_t i, uintptr_t oprsz) | 22 | |
127 | static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | 23 | - if (r->state == ARM_CP_STATE_BOTH) { |
128 | uint32_t desc, const uintptr_t retaddr, | 24 | -#if HOST_BIG_ENDIAN |
129 | const int esz, const int msz, | 25 | - if (r2->fieldoffset) { |
130 | - sve_ld1_host_fn *host_fn, | 26 | - r2->fieldoffset += sizeof(uint32_t); |
131 | + sve_ldst1_host_fn *host_fn, | 27 | - } |
132 | sve_ldst1_tlb_fn *tlb_fn) | 28 | -#endif |
133 | { | 29 | + if (HOST_BIG_ENDIAN && |
134 | const TCGMemOpIdx oi = extract32(desc, SIMD_DATA_SHIFT, MEMOPIDX_SHIFT); | 30 | + r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { |
135 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | 31 | + r2->fieldoffset += sizeof(uint32_t); |
136 | const int diffsz = esz - msz; | ||
137 | const intptr_t reg_max = simd_oprsz(desc); | ||
138 | const intptr_t mem_max = reg_max >> diffsz; | ||
139 | - intptr_t split, reg_off, mem_off; | ||
140 | + intptr_t split, reg_off, mem_off, i; | ||
141 | void *host; | ||
142 | |||
143 | /* Skip to the first active element. */ | ||
144 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
145 | if (likely(split == mem_max)) { | ||
146 | host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); | ||
147 | if (test_host_page(host)) { | ||
148 | - mem_off = host_fn(vd, vg, host - mem_off, mem_off, mem_max); | ||
149 | - tcg_debug_assert(mem_off == mem_max); | ||
150 | + i = reg_off; | ||
151 | + host -= mem_off; | ||
152 | + do { | ||
153 | + host_fn(vd, i, host + (i >> diffsz)); | ||
154 | + i = find_next_active(vg, i + (1 << esz), reg_max, esz); | ||
155 | + } while (i < reg_max); | ||
156 | /* After any fault, zero any leading inactive elements. */ | ||
157 | swap_memzero(vd, reg_off); | ||
158 | return; | ||
159 | } | 32 | } |
160 | } | 33 | } |
161 | 34 | ||
162 | -#ifdef CONFIG_USER_ONLY | ||
163 | - /* | ||
164 | - * The page(s) containing this first element at ADDR+MEM_OFF must | ||
165 | - * be valid. Considering that this first element may be misaligned | ||
166 | - * and cross a page boundary itself, take the rest of the page from | ||
167 | - * the last byte of the element. | ||
168 | - */ | ||
169 | - split = max_for_page(addr, mem_off + (1 << msz) - 1, mem_max); | ||
170 | - mem_off = host_fn(vd, vg, g2h(addr), mem_off, split); | ||
171 | - | ||
172 | - /* After any fault, zero any leading inactive elements. */ | ||
173 | - swap_memzero(vd, reg_off); | ||
174 | - reg_off = mem_off << diffsz; | ||
175 | -#else | ||
176 | /* | ||
177 | * Perform one normal read, which will fault or not. | ||
178 | * But it is likely to bring the page into the tlb. | ||
179 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
180 | if (split >= (1 << msz)) { | ||
181 | host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); | ||
182 | if (host) { | ||
183 | - mem_off = host_fn(vd, vg, host - mem_off, mem_off, split); | ||
184 | - reg_off = mem_off << diffsz; | ||
185 | + host -= mem_off; | ||
186 | + do { | ||
187 | + host_fn(vd, reg_off, host + mem_off); | ||
188 | + reg_off += 1 << esz; | ||
189 | + reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
190 | + mem_off = reg_off >> diffsz; | ||
191 | + } while (split - mem_off >= (1 << msz)); | ||
192 | } | ||
193 | } | ||
194 | -#endif | ||
195 | |||
196 | record_fault(env, reg_off, reg_max); | ||
197 | } | ||
198 | @@ -XXX,XX +XXX,XX @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
199 | */ | ||
200 | static void sve_ldnf1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
201 | uint32_t desc, const int esz, const int msz, | ||
202 | - sve_ld1_host_fn *host_fn) | ||
203 | + sve_ldst1_host_fn *host_fn) | ||
204 | { | ||
205 | const unsigned rd = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 5); | ||
206 | void *vd = &env->vfp.zregs[rd]; | ||
207 | @@ -XXX,XX +XXX,XX @@ static void sve_ldnf1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
208 | host = tlb_vaddr_to_host(env, addr, MMU_DATA_LOAD, mmu_idx); | ||
209 | if (likely(page_check_range(addr, mem_max, PAGE_READ) == 0)) { | ||
210 | /* The entire operation is valid and will not fault. */ | ||
211 | - host_fn(vd, vg, host, 0, mem_max); | ||
212 | + reg_off = 0; | ||
213 | + do { | ||
214 | + mem_off = reg_off >> diffsz; | ||
215 | + host_fn(vd, reg_off, host + mem_off); | ||
216 | + reg_off += 1 << esz; | ||
217 | + reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
218 | + } while (reg_off < reg_max); | ||
219 | return; | ||
220 | } | ||
221 | #endif | ||
222 | @@ -XXX,XX +XXX,XX @@ static void sve_ldnf1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
223 | if (page_check_range(addr + mem_off, 1 << msz, PAGE_READ) == 0) { | ||
224 | /* At least one load is valid; take the rest of the page. */ | ||
225 | split = max_for_page(addr, mem_off + (1 << msz) - 1, mem_max); | ||
226 | - mem_off = host_fn(vd, vg, host, mem_off, split); | ||
227 | - reg_off = mem_off << diffsz; | ||
228 | + do { | ||
229 | + host_fn(vd, reg_off, host + mem_off); | ||
230 | + reg_off += 1 << esz; | ||
231 | + reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
232 | + mem_off = reg_off >> diffsz; | ||
233 | + } while (split - mem_off >= (1 << msz)); | ||
234 | } | ||
235 | #else | ||
236 | /* | ||
237 | @@ -XXX,XX +XXX,XX @@ static void sve_ldnf1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
238 | host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); | ||
239 | split = max_for_page(addr, mem_off, mem_max); | ||
240 | if (host && split >= (1 << msz)) { | ||
241 | - mem_off = host_fn(vd, vg, host - mem_off, mem_off, split); | ||
242 | - reg_off = mem_off << diffsz; | ||
243 | + host -= mem_off; | ||
244 | + do { | ||
245 | + host_fn(vd, reg_off, host + mem_off); | ||
246 | + reg_off += 1 << esz; | ||
247 | + reg_off = find_next_active(vg, reg_off, reg_max, esz); | ||
248 | + mem_off = reg_off >> diffsz; | ||
249 | + } while (split - mem_off >= (1 << msz)); | ||
250 | } | ||
251 | #endif | ||
252 | |||
253 | -- | 35 | -- |
254 | 2.20.1 | 36 | 2.25.1 |
255 | |||
256 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | |||
3 | We currently have target-endian versions of these operations, | ||
4 | but no easy way to force a specific endianness. This can be | ||
5 | helpful if the target has endian-specific operations, or a mode | ||
6 | that swaps endianness. | ||
7 | 2 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200508154359.7494-7-richard.henderson@linaro.org | 5 | Message-id: 20220501055028.646596-24-richard.henderson@linaro.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | docs/devel/loads-stores.rst | 39 +++-- | 8 | target/arm/cpu.h | 15 +++++++++++++++ |
14 | include/exec/cpu_ldst.h | 283 +++++++++++++++++++++++++++--------- | 9 | 1 file changed, 15 insertions(+) |
15 | accel/tcg/cputlb.c | 236 ++++++++++++++++++++++-------- | ||
16 | accel/tcg/user-exec.c | 211 ++++++++++++++++++++++----- | ||
17 | 4 files changed, 587 insertions(+), 182 deletions(-) | ||
18 | 10 | ||
19 | diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/docs/devel/loads-stores.rst | 13 | --- a/target/arm/cpu.h |
22 | +++ b/docs/devel/loads-stores.rst | 14 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ function, which is a return address into the generated code. | 15 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id) |
24 | 16 | return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0; | |
25 | Function names follow the pattern: | ||
26 | |||
27 | -load: ``cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmuidx, retaddr)`` | ||
28 | +load: ``cpu_ld{sign}{size}{end}_mmuidx_ra(env, ptr, mmuidx, retaddr)`` | ||
29 | |||
30 | -store: ``cpu_st{size}_mmuidx_ra(env, ptr, val, mmuidx, retaddr)`` | ||
31 | +store: ``cpu_st{size}{end}_mmuidx_ra(env, ptr, val, mmuidx, retaddr)`` | ||
32 | |||
33 | ``sign`` | ||
34 | - (empty) : for 32 or 64 bit sizes | ||
35 | @@ -XXX,XX +XXX,XX @@ store: ``cpu_st{size}_mmuidx_ra(env, ptr, val, mmuidx, retaddr)`` | ||
36 | - ``l`` : 32 bits | ||
37 | - ``q`` : 64 bits | ||
38 | |||
39 | +``end`` | ||
40 | + - (empty) : for target endian, or 8 bit sizes | ||
41 | + - ``_be`` : big endian | ||
42 | + - ``_le`` : little endian | ||
43 | + | ||
44 | Regexes for git grep: | ||
45 | - - ``\<cpu_ld[us]\?[bwlq]_mmuidx_ra\>`` | ||
46 | - - ``\<cpu_st[bwlq]_mmuidx_ra\>`` | ||
47 | + - ``\<cpu_ld[us]\?[bwlq](_[bl]e)\?_mmuidx_ra\>`` | ||
48 | + - ``\<cpu_st[bwlq](_[bl]e)\?_mmuidx_ra\>`` | ||
49 | |||
50 | ``cpu_{ld,st}*_data_ra`` | ||
51 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
52 | @@ -XXX,XX +XXX,XX @@ be performed with a context other than the default. | ||
53 | |||
54 | Function names follow the pattern: | ||
55 | |||
56 | -load: ``cpu_ld{sign}{size}_data_ra(env, ptr, ra)`` | ||
57 | +load: ``cpu_ld{sign}{size}{end}_data_ra(env, ptr, ra)`` | ||
58 | |||
59 | -store: ``cpu_st{size}_data_ra(env, ptr, val, ra)`` | ||
60 | +store: ``cpu_st{size}{end}_data_ra(env, ptr, val, ra)`` | ||
61 | |||
62 | ``sign`` | ||
63 | - (empty) : for 32 or 64 bit sizes | ||
64 | @@ -XXX,XX +XXX,XX @@ store: ``cpu_st{size}_data_ra(env, ptr, val, ra)`` | ||
65 | - ``l`` : 32 bits | ||
66 | - ``q`` : 64 bits | ||
67 | |||
68 | +``end`` | ||
69 | + - (empty) : for target endian, or 8 bit sizes | ||
70 | + - ``_be`` : big endian | ||
71 | + - ``_le`` : little endian | ||
72 | + | ||
73 | Regexes for git grep: | ||
74 | - - ``\<cpu_ld[us]\?[bwlq]_data_ra\>`` | ||
75 | - - ``\<cpu_st[bwlq]_data_ra\>`` | ||
76 | + - ``\<cpu_ld[us]\?[bwlq](_[bl]e)\?_data_ra\>`` | ||
77 | + - ``\<cpu_st[bwlq](_[bl]e)\?_data_ra\>`` | ||
78 | |||
79 | ``cpu_{ld,st}*_data`` | ||
80 | ~~~~~~~~~~~~~~~~~~~~~ | ||
81 | @@ -XXX,XX +XXX,XX @@ the CPU state anyway. | ||
82 | |||
83 | Function names follow the pattern: | ||
84 | |||
85 | -load: ``cpu_ld{sign}{size}_data(env, ptr)`` | ||
86 | +load: ``cpu_ld{sign}{size}{end}_data(env, ptr)`` | ||
87 | |||
88 | -store: ``cpu_st{size}_data(env, ptr, val)`` | ||
89 | +store: ``cpu_st{size}{end}_data(env, ptr, val)`` | ||
90 | |||
91 | ``sign`` | ||
92 | - (empty) : for 32 or 64 bit sizes | ||
93 | @@ -XXX,XX +XXX,XX @@ store: ``cpu_st{size}_data(env, ptr, val)`` | ||
94 | - ``l`` : 32 bits | ||
95 | - ``q`` : 64 bits | ||
96 | |||
97 | +``end`` | ||
98 | + - (empty) : for target endian, or 8 bit sizes | ||
99 | + - ``_be`` : big endian | ||
100 | + - ``_le`` : little endian | ||
101 | + | ||
102 | Regexes for git grep | ||
103 | - - ``\<cpu_ld[us]\?[bwlq]_data\>`` | ||
104 | - - ``\<cpu_st[bwlq]_data\+\>`` | ||
105 | + - ``\<cpu_ld[us]\?[bwlq](_[bl]e)\?_data\>`` | ||
106 | + - ``\<cpu_st[bwlq](_[bl]e)\?_data\+\>`` | ||
107 | |||
108 | ``cpu_ld*_code`` | ||
109 | ~~~~~~~~~~~~~~~~ | ||
110 | diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/include/exec/cpu_ldst.h | ||
113 | +++ b/include/exec/cpu_ldst.h | ||
114 | @@ -XXX,XX +XXX,XX @@ | ||
115 | * | ||
116 | * The syntax for the accessors is: | ||
117 | * | ||
118 | - * load: cpu_ld{sign}{size}_{mmusuffix}(env, ptr) | ||
119 | - * cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr) | ||
120 | - * cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmu_idx, retaddr) | ||
121 | + * load: cpu_ld{sign}{size}{end}_{mmusuffix}(env, ptr) | ||
122 | + * cpu_ld{sign}{size}{end}_{mmusuffix}_ra(env, ptr, retaddr) | ||
123 | + * cpu_ld{sign}{size}{end}_mmuidx_ra(env, ptr, mmu_idx, retaddr) | ||
124 | * | ||
125 | - * store: cpu_st{size}_{mmusuffix}(env, ptr, val) | ||
126 | - * cpu_st{size}_{mmusuffix}_ra(env, ptr, val, retaddr) | ||
127 | - * cpu_st{size}_mmuidx_ra(env, ptr, val, mmu_idx, retaddr) | ||
128 | + * store: cpu_st{size}{end}_{mmusuffix}(env, ptr, val) | ||
129 | + * cpu_st{size}{end}_{mmusuffix}_ra(env, ptr, val, retaddr) | ||
130 | + * cpu_st{size}{end}_mmuidx_ra(env, ptr, val, mmu_idx, retaddr) | ||
131 | * | ||
132 | * sign is: | ||
133 | * (empty): for 32 and 64 bit sizes | ||
134 | @@ -XXX,XX +XXX,XX @@ | ||
135 | * l: 32 bits | ||
136 | * q: 64 bits | ||
137 | * | ||
138 | + * end is: | ||
139 | + * (empty): for target native endian, or for 8 bit access | ||
140 | + * _be: for forced big endian | ||
141 | + * _le: for forced little endian | ||
142 | + * | ||
143 | * mmusuffix is one of the generic suffixes "data" or "code", or "mmuidx". | ||
144 | * The "mmuidx" suffix carries an extra mmu_idx argument that specifies | ||
145 | * the index to use; the "data" and "code" suffixes take the index from | ||
146 | @@ -XXX,XX +XXX,XX @@ typedef target_ulong abi_ptr; | ||
147 | #endif | ||
148 | |||
149 | uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr); | ||
150 | -uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr); | ||
151 | -uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr); | ||
152 | -uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr); | ||
153 | int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr); | ||
154 | -int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr); | ||
155 | |||
156 | -uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr); | ||
157 | -uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr); | ||
158 | -uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr); | ||
159 | -uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr); | ||
160 | -int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr); | ||
161 | -int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr); | ||
162 | +uint32_t cpu_lduw_be_data(CPUArchState *env, abi_ptr ptr); | ||
163 | +int cpu_ldsw_be_data(CPUArchState *env, abi_ptr ptr); | ||
164 | +uint32_t cpu_ldl_be_data(CPUArchState *env, abi_ptr ptr); | ||
165 | +uint64_t cpu_ldq_be_data(CPUArchState *env, abi_ptr ptr); | ||
166 | + | ||
167 | +uint32_t cpu_lduw_le_data(CPUArchState *env, abi_ptr ptr); | ||
168 | +int cpu_ldsw_le_data(CPUArchState *env, abi_ptr ptr); | ||
169 | +uint32_t cpu_ldl_le_data(CPUArchState *env, abi_ptr ptr); | ||
170 | +uint64_t cpu_ldq_le_data(CPUArchState *env, abi_ptr ptr); | ||
171 | + | ||
172 | +uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
173 | +int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
174 | + | ||
175 | +uint32_t cpu_lduw_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
176 | +int cpu_ldsw_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
177 | +uint32_t cpu_ldl_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
178 | +uint64_t cpu_ldq_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
179 | + | ||
180 | +uint32_t cpu_lduw_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
181 | +int cpu_ldsw_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
182 | +uint32_t cpu_ldl_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
183 | +uint64_t cpu_ldq_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t ra); | ||
184 | |||
185 | void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val); | ||
186 | -void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val); | ||
187 | -void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val); | ||
188 | -void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val); | ||
189 | + | ||
190 | +void cpu_stw_be_data(CPUArchState *env, abi_ptr ptr, uint32_t val); | ||
191 | +void cpu_stl_be_data(CPUArchState *env, abi_ptr ptr, uint32_t val); | ||
192 | +void cpu_stq_be_data(CPUArchState *env, abi_ptr ptr, uint64_t val); | ||
193 | + | ||
194 | +void cpu_stw_le_data(CPUArchState *env, abi_ptr ptr, uint32_t val); | ||
195 | +void cpu_stl_le_data(CPUArchState *env, abi_ptr ptr, uint32_t val); | ||
196 | +void cpu_stq_le_data(CPUArchState *env, abi_ptr ptr, uint64_t val); | ||
197 | |||
198 | void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr, | ||
199 | - uint32_t val, uintptr_t retaddr); | ||
200 | -void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr, | ||
201 | - uint32_t val, uintptr_t retaddr); | ||
202 | -void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr, | ||
203 | - uint32_t val, uintptr_t retaddr); | ||
204 | -void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr, | ||
205 | - uint64_t val, uintptr_t retaddr); | ||
206 | + uint32_t val, uintptr_t ra); | ||
207 | + | ||
208 | +void cpu_stw_be_data_ra(CPUArchState *env, abi_ptr ptr, | ||
209 | + uint32_t val, uintptr_t ra); | ||
210 | +void cpu_stl_be_data_ra(CPUArchState *env, abi_ptr ptr, | ||
211 | + uint32_t val, uintptr_t ra); | ||
212 | +void cpu_stq_be_data_ra(CPUArchState *env, abi_ptr ptr, | ||
213 | + uint64_t val, uintptr_t ra); | ||
214 | + | ||
215 | +void cpu_stw_le_data_ra(CPUArchState *env, abi_ptr ptr, | ||
216 | + uint32_t val, uintptr_t ra); | ||
217 | +void cpu_stl_le_data_ra(CPUArchState *env, abi_ptr ptr, | ||
218 | + uint32_t val, uintptr_t ra); | ||
219 | +void cpu_stq_le_data_ra(CPUArchState *env, abi_ptr ptr, | ||
220 | + uint64_t val, uintptr_t ra); | ||
221 | |||
222 | #if defined(CONFIG_USER_ONLY) | ||
223 | |||
224 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
225 | return cpu_ldub_data_ra(env, addr, ra); | ||
226 | } | 17 | } |
227 | 18 | ||
228 | -static inline uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr, | 19 | +static inline bool isar_feature_aa32_debugv8p2(const ARMISARegisters *id) |
229 | - int mmu_idx, uintptr_t ra) | 20 | +{ |
230 | -{ | 21 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 8; |
231 | - return cpu_lduw_data_ra(env, addr, ra); | ||
232 | -} | ||
233 | - | ||
234 | -static inline uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
235 | - int mmu_idx, uintptr_t ra) | ||
236 | -{ | ||
237 | - return cpu_ldl_data_ra(env, addr, ra); | ||
238 | -} | ||
239 | - | ||
240 | -static inline uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
241 | - int mmu_idx, uintptr_t ra) | ||
242 | -{ | ||
243 | - return cpu_ldq_data_ra(env, addr, ra); | ||
244 | -} | ||
245 | - | ||
246 | static inline int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
247 | int mmu_idx, uintptr_t ra) | ||
248 | { | ||
249 | return cpu_ldsb_data_ra(env, addr, ra); | ||
250 | } | ||
251 | |||
252 | -static inline int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
253 | - int mmu_idx, uintptr_t ra) | ||
254 | +static inline uint32_t cpu_lduw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
255 | + int mmu_idx, uintptr_t ra) | ||
256 | { | ||
257 | - return cpu_ldsw_data_ra(env, addr, ra); | ||
258 | + return cpu_lduw_be_data_ra(env, addr, ra); | ||
259 | +} | 22 | +} |
260 | + | 23 | + |
261 | +static inline int cpu_ldsw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | 24 | /* |
262 | + int mmu_idx, uintptr_t ra) | 25 | * 64-bit feature tests via id registers. |
26 | */ | ||
27 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | ||
28 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | ||
29 | } | ||
30 | |||
31 | +static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id) | ||
263 | +{ | 32 | +{ |
264 | + return cpu_ldsw_be_data_ra(env, addr, ra); | 33 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8; |
265 | +} | 34 | +} |
266 | + | 35 | + |
267 | +static inline uint32_t cpu_ldl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | 36 | static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id) |
268 | + int mmu_idx, uintptr_t ra) | 37 | { |
38 | return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0; | ||
39 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id) | ||
40 | return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id); | ||
41 | } | ||
42 | |||
43 | +static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) | ||
269 | +{ | 44 | +{ |
270 | + return cpu_ldl_be_data_ra(env, addr, ra); | 45 | + return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); |
271 | +} | 46 | +} |
272 | + | 47 | + |
273 | +static inline uint64_t cpu_ldq_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
274 | + int mmu_idx, uintptr_t ra) | ||
275 | +{ | ||
276 | + return cpu_ldq_be_data_ra(env, addr, ra); | ||
277 | +} | ||
278 | + | ||
279 | +static inline uint32_t cpu_lduw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
280 | + int mmu_idx, uintptr_t ra) | ||
281 | +{ | ||
282 | + return cpu_lduw_le_data_ra(env, addr, ra); | ||
283 | +} | ||
284 | + | ||
285 | +static inline int cpu_ldsw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
286 | + int mmu_idx, uintptr_t ra) | ||
287 | +{ | ||
288 | + return cpu_ldsw_le_data_ra(env, addr, ra); | ||
289 | +} | ||
290 | + | ||
291 | +static inline uint32_t cpu_ldl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
292 | + int mmu_idx, uintptr_t ra) | ||
293 | +{ | ||
294 | + return cpu_ldl_le_data_ra(env, addr, ra); | ||
295 | +} | ||
296 | + | ||
297 | +static inline uint64_t cpu_ldq_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
298 | + int mmu_idx, uintptr_t ra) | ||
299 | +{ | ||
300 | + return cpu_ldq_le_data_ra(env, addr, ra); | ||
301 | } | ||
302 | |||
303 | static inline void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
304 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
305 | cpu_stb_data_ra(env, addr, val, ra); | ||
306 | } | ||
307 | |||
308 | -static inline void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
309 | - uint32_t val, int mmu_idx, uintptr_t ra) | ||
310 | +static inline void cpu_stw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
311 | + uint32_t val, int mmu_idx, | ||
312 | + uintptr_t ra) | ||
313 | { | ||
314 | - cpu_stw_data_ra(env, addr, val, ra); | ||
315 | + cpu_stw_be_data_ra(env, addr, val, ra); | ||
316 | } | ||
317 | |||
318 | -static inline void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
319 | - uint32_t val, int mmu_idx, uintptr_t ra) | ||
320 | +static inline void cpu_stl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
321 | + uint32_t val, int mmu_idx, | ||
322 | + uintptr_t ra) | ||
323 | { | ||
324 | - cpu_stl_data_ra(env, addr, val, ra); | ||
325 | + cpu_stl_be_data_ra(env, addr, val, ra); | ||
326 | } | ||
327 | |||
328 | -static inline void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
329 | - uint64_t val, int mmu_idx, uintptr_t ra) | ||
330 | +static inline void cpu_stq_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
331 | + uint64_t val, int mmu_idx, | ||
332 | + uintptr_t ra) | ||
333 | { | ||
334 | - cpu_stq_data_ra(env, addr, val, ra); | ||
335 | + cpu_stq_be_data_ra(env, addr, val, ra); | ||
336 | +} | ||
337 | + | ||
338 | +static inline void cpu_stw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
339 | + uint32_t val, int mmu_idx, | ||
340 | + uintptr_t ra) | ||
341 | +{ | ||
342 | + cpu_stw_le_data_ra(env, addr, val, ra); | ||
343 | +} | ||
344 | + | ||
345 | +static inline void cpu_stl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
346 | + uint32_t val, int mmu_idx, | ||
347 | + uintptr_t ra) | ||
348 | +{ | ||
349 | + cpu_stl_le_data_ra(env, addr, val, ra); | ||
350 | +} | ||
351 | + | ||
352 | +static inline void cpu_stq_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
353 | + uint64_t val, int mmu_idx, | ||
354 | + uintptr_t ra) | ||
355 | +{ | ||
356 | + cpu_stq_le_data_ra(env, addr, val, ra); | ||
357 | } | ||
358 | |||
359 | #else | ||
360 | @@ -XXX,XX +XXX,XX @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx, | ||
361 | |||
362 | uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
363 | int mmu_idx, uintptr_t ra); | ||
364 | -uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
365 | - int mmu_idx, uintptr_t ra); | ||
366 | -uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
367 | - int mmu_idx, uintptr_t ra); | ||
368 | -uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
369 | - int mmu_idx, uintptr_t ra); | ||
370 | - | ||
371 | int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
372 | int mmu_idx, uintptr_t ra); | ||
373 | -int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
374 | - int mmu_idx, uintptr_t ra); | ||
375 | + | ||
376 | +uint32_t cpu_lduw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
377 | + int mmu_idx, uintptr_t ra); | ||
378 | +int cpu_ldsw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
379 | + int mmu_idx, uintptr_t ra); | ||
380 | +uint32_t cpu_ldl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
381 | + int mmu_idx, uintptr_t ra); | ||
382 | +uint64_t cpu_ldq_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
383 | + int mmu_idx, uintptr_t ra); | ||
384 | + | ||
385 | +uint32_t cpu_lduw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
386 | + int mmu_idx, uintptr_t ra); | ||
387 | +int cpu_ldsw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
388 | + int mmu_idx, uintptr_t ra); | ||
389 | +uint32_t cpu_ldl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
390 | + int mmu_idx, uintptr_t ra); | ||
391 | +uint64_t cpu_ldq_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
392 | + int mmu_idx, uintptr_t ra); | ||
393 | |||
394 | void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val, | ||
395 | int mmu_idx, uintptr_t retaddr); | ||
396 | -void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val, | ||
397 | - int mmu_idx, uintptr_t retaddr); | ||
398 | -void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val, | ||
399 | - int mmu_idx, uintptr_t retaddr); | ||
400 | -void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val, | ||
401 | - int mmu_idx, uintptr_t retaddr); | ||
402 | + | ||
403 | +void cpu_stw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val, | ||
404 | + int mmu_idx, uintptr_t retaddr); | ||
405 | +void cpu_stl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val, | ||
406 | + int mmu_idx, uintptr_t retaddr); | ||
407 | +void cpu_stq_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val, | ||
408 | + int mmu_idx, uintptr_t retaddr); | ||
409 | + | ||
410 | +void cpu_stw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val, | ||
411 | + int mmu_idx, uintptr_t retaddr); | ||
412 | +void cpu_stl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val, | ||
413 | + int mmu_idx, uintptr_t retaddr); | ||
414 | +void cpu_stq_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val, | ||
415 | + int mmu_idx, uintptr_t retaddr); | ||
416 | |||
417 | #endif /* defined(CONFIG_USER_ONLY) */ | ||
418 | |||
419 | +#ifdef TARGET_WORDS_BIGENDIAN | ||
420 | +# define cpu_lduw_data cpu_lduw_be_data | ||
421 | +# define cpu_ldsw_data cpu_ldsw_be_data | ||
422 | +# define cpu_ldl_data cpu_ldl_be_data | ||
423 | +# define cpu_ldq_data cpu_ldq_be_data | ||
424 | +# define cpu_lduw_data_ra cpu_lduw_be_data_ra | ||
425 | +# define cpu_ldsw_data_ra cpu_ldsw_be_data_ra | ||
426 | +# define cpu_ldl_data_ra cpu_ldl_be_data_ra | ||
427 | +# define cpu_ldq_data_ra cpu_ldq_be_data_ra | ||
428 | +# define cpu_lduw_mmuidx_ra cpu_lduw_be_mmuidx_ra | ||
429 | +# define cpu_ldsw_mmuidx_ra cpu_ldsw_be_mmuidx_ra | ||
430 | +# define cpu_ldl_mmuidx_ra cpu_ldl_be_mmuidx_ra | ||
431 | +# define cpu_ldq_mmuidx_ra cpu_ldq_be_mmuidx_ra | ||
432 | +# define cpu_stw_data cpu_stw_be_data | ||
433 | +# define cpu_stl_data cpu_stl_be_data | ||
434 | +# define cpu_stq_data cpu_stq_be_data | ||
435 | +# define cpu_stw_data_ra cpu_stw_be_data_ra | ||
436 | +# define cpu_stl_data_ra cpu_stl_be_data_ra | ||
437 | +# define cpu_stq_data_ra cpu_stq_be_data_ra | ||
438 | +# define cpu_stw_mmuidx_ra cpu_stw_be_mmuidx_ra | ||
439 | +# define cpu_stl_mmuidx_ra cpu_stl_be_mmuidx_ra | ||
440 | +# define cpu_stq_mmuidx_ra cpu_stq_be_mmuidx_ra | ||
441 | +#else | ||
442 | +# define cpu_lduw_data cpu_lduw_le_data | ||
443 | +# define cpu_ldsw_data cpu_ldsw_le_data | ||
444 | +# define cpu_ldl_data cpu_ldl_le_data | ||
445 | +# define cpu_ldq_data cpu_ldq_le_data | ||
446 | +# define cpu_lduw_data_ra cpu_lduw_le_data_ra | ||
447 | +# define cpu_ldsw_data_ra cpu_ldsw_le_data_ra | ||
448 | +# define cpu_ldl_data_ra cpu_ldl_le_data_ra | ||
449 | +# define cpu_ldq_data_ra cpu_ldq_le_data_ra | ||
450 | +# define cpu_lduw_mmuidx_ra cpu_lduw_le_mmuidx_ra | ||
451 | +# define cpu_ldsw_mmuidx_ra cpu_ldsw_le_mmuidx_ra | ||
452 | +# define cpu_ldl_mmuidx_ra cpu_ldl_le_mmuidx_ra | ||
453 | +# define cpu_ldq_mmuidx_ra cpu_ldq_le_mmuidx_ra | ||
454 | +# define cpu_stw_data cpu_stw_le_data | ||
455 | +# define cpu_stl_data cpu_stl_le_data | ||
456 | +# define cpu_stq_data cpu_stq_le_data | ||
457 | +# define cpu_stw_data_ra cpu_stw_le_data_ra | ||
458 | +# define cpu_stl_data_ra cpu_stl_le_data_ra | ||
459 | +# define cpu_stq_data_ra cpu_stq_le_data_ra | ||
460 | +# define cpu_stw_mmuidx_ra cpu_stw_le_mmuidx_ra | ||
461 | +# define cpu_stl_mmuidx_ra cpu_stl_le_mmuidx_ra | ||
462 | +# define cpu_stq_mmuidx_ra cpu_stq_le_mmuidx_ra | ||
463 | +#endif | ||
464 | + | ||
465 | uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr); | ||
466 | uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr); | ||
467 | uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr); | ||
468 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
469 | index XXXXXXX..XXXXXXX 100644 | ||
470 | --- a/accel/tcg/cputlb.c | ||
471 | +++ b/accel/tcg/cputlb.c | ||
472 | @@ -XXX,XX +XXX,XX @@ int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
473 | full_ldub_mmu); | ||
474 | } | ||
475 | |||
476 | -uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
477 | - int mmu_idx, uintptr_t ra) | ||
478 | +uint32_t cpu_lduw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
479 | + int mmu_idx, uintptr_t ra) | ||
480 | { | ||
481 | - return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUW, | ||
482 | - MO_TE == MO_LE | ||
483 | - ? full_le_lduw_mmu : full_be_lduw_mmu); | ||
484 | + return cpu_load_helper(env, addr, mmu_idx, ra, MO_BEUW, full_be_lduw_mmu); | ||
485 | } | ||
486 | |||
487 | -int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
488 | - int mmu_idx, uintptr_t ra) | ||
489 | +int cpu_ldsw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
490 | + int mmu_idx, uintptr_t ra) | ||
491 | { | ||
492 | - return (int16_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_TESW, | ||
493 | - MO_TE == MO_LE | ||
494 | - ? full_le_lduw_mmu : full_be_lduw_mmu); | ||
495 | + return (int16_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_BESW, | ||
496 | + full_be_lduw_mmu); | ||
497 | } | ||
498 | |||
499 | -uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
500 | - int mmu_idx, uintptr_t ra) | ||
501 | +uint32_t cpu_ldl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
502 | + int mmu_idx, uintptr_t ra) | ||
503 | { | ||
504 | - return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUL, | ||
505 | - MO_TE == MO_LE | ||
506 | - ? full_le_ldul_mmu : full_be_ldul_mmu); | ||
507 | + return cpu_load_helper(env, addr, mmu_idx, ra, MO_BEUL, full_be_ldul_mmu); | ||
508 | } | ||
509 | |||
510 | -uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
511 | - int mmu_idx, uintptr_t ra) | ||
512 | +uint64_t cpu_ldq_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
513 | + int mmu_idx, uintptr_t ra) | ||
514 | { | ||
515 | - return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEQ, | ||
516 | - MO_TE == MO_LE | ||
517 | - ? helper_le_ldq_mmu : helper_be_ldq_mmu); | ||
518 | + return cpu_load_helper(env, addr, mmu_idx, ra, MO_BEQ, helper_be_ldq_mmu); | ||
519 | +} | ||
520 | + | ||
521 | +uint32_t cpu_lduw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
522 | + int mmu_idx, uintptr_t ra) | ||
523 | +{ | ||
524 | + return cpu_load_helper(env, addr, mmu_idx, ra, MO_LEUW, full_le_lduw_mmu); | ||
525 | +} | ||
526 | + | ||
527 | +int cpu_ldsw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
528 | + int mmu_idx, uintptr_t ra) | ||
529 | +{ | ||
530 | + return (int16_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_LESW, | ||
531 | + full_le_lduw_mmu); | ||
532 | +} | ||
533 | + | ||
534 | +uint32_t cpu_ldl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
535 | + int mmu_idx, uintptr_t ra) | ||
536 | +{ | ||
537 | + return cpu_load_helper(env, addr, mmu_idx, ra, MO_LEUL, full_le_ldul_mmu); | ||
538 | +} | ||
539 | + | ||
540 | +uint64_t cpu_ldq_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, | ||
541 | + int mmu_idx, uintptr_t ra) | ||
542 | +{ | ||
543 | + return cpu_load_helper(env, addr, mmu_idx, ra, MO_LEQ, helper_le_ldq_mmu); | ||
544 | } | ||
545 | |||
546 | uint32_t cpu_ldub_data_ra(CPUArchState *env, target_ulong ptr, | ||
547 | @@ -XXX,XX +XXX,XX @@ int cpu_ldsb_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr) | ||
548 | return cpu_ldsb_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
549 | } | ||
550 | |||
551 | -uint32_t cpu_lduw_data_ra(CPUArchState *env, target_ulong ptr, | ||
552 | - uintptr_t retaddr) | ||
553 | +uint32_t cpu_lduw_be_data_ra(CPUArchState *env, target_ulong ptr, | ||
554 | + uintptr_t retaddr) | ||
555 | { | ||
556 | - return cpu_lduw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
557 | + return cpu_lduw_be_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
558 | } | ||
559 | |||
560 | -int cpu_ldsw_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr) | ||
561 | +int cpu_ldsw_be_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr) | ||
562 | { | ||
563 | - return cpu_ldsw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
564 | + return cpu_ldsw_be_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
565 | } | ||
566 | |||
567 | -uint32_t cpu_ldl_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr) | ||
568 | +uint32_t cpu_ldl_be_data_ra(CPUArchState *env, target_ulong ptr, | ||
569 | + uintptr_t retaddr) | ||
570 | { | ||
571 | - return cpu_ldl_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
572 | + return cpu_ldl_be_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
573 | } | ||
574 | |||
575 | -uint64_t cpu_ldq_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr) | ||
576 | +uint64_t cpu_ldq_be_data_ra(CPUArchState *env, target_ulong ptr, | ||
577 | + uintptr_t retaddr) | ||
578 | { | ||
579 | - return cpu_ldq_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
580 | + return cpu_ldq_be_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
581 | +} | ||
582 | + | ||
583 | +uint32_t cpu_lduw_le_data_ra(CPUArchState *env, target_ulong ptr, | ||
584 | + uintptr_t retaddr) | ||
585 | +{ | ||
586 | + return cpu_lduw_le_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
587 | +} | ||
588 | + | ||
589 | +int cpu_ldsw_le_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr) | ||
590 | +{ | ||
591 | + return cpu_ldsw_le_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
592 | +} | ||
593 | + | ||
594 | +uint32_t cpu_ldl_le_data_ra(CPUArchState *env, target_ulong ptr, | ||
595 | + uintptr_t retaddr) | ||
596 | +{ | ||
597 | + return cpu_ldl_le_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
598 | +} | ||
599 | + | ||
600 | +uint64_t cpu_ldq_le_data_ra(CPUArchState *env, target_ulong ptr, | ||
601 | + uintptr_t retaddr) | ||
602 | +{ | ||
603 | + return cpu_ldq_le_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr); | ||
604 | } | ||
605 | |||
606 | uint32_t cpu_ldub_data(CPUArchState *env, target_ulong ptr) | ||
607 | @@ -XXX,XX +XXX,XX @@ int cpu_ldsb_data(CPUArchState *env, target_ulong ptr) | ||
608 | return cpu_ldsb_data_ra(env, ptr, 0); | ||
609 | } | ||
610 | |||
611 | -uint32_t cpu_lduw_data(CPUArchState *env, target_ulong ptr) | ||
612 | +uint32_t cpu_lduw_be_data(CPUArchState *env, target_ulong ptr) | ||
613 | { | ||
614 | - return cpu_lduw_data_ra(env, ptr, 0); | ||
615 | + return cpu_lduw_be_data_ra(env, ptr, 0); | ||
616 | } | ||
617 | |||
618 | -int cpu_ldsw_data(CPUArchState *env, target_ulong ptr) | ||
619 | +int cpu_ldsw_be_data(CPUArchState *env, target_ulong ptr) | ||
620 | { | ||
621 | - return cpu_ldsw_data_ra(env, ptr, 0); | ||
622 | + return cpu_ldsw_be_data_ra(env, ptr, 0); | ||
623 | } | ||
624 | |||
625 | -uint32_t cpu_ldl_data(CPUArchState *env, target_ulong ptr) | ||
626 | +uint32_t cpu_ldl_be_data(CPUArchState *env, target_ulong ptr) | ||
627 | { | ||
628 | - return cpu_ldl_data_ra(env, ptr, 0); | ||
629 | + return cpu_ldl_be_data_ra(env, ptr, 0); | ||
630 | } | ||
631 | |||
632 | -uint64_t cpu_ldq_data(CPUArchState *env, target_ulong ptr) | ||
633 | +uint64_t cpu_ldq_be_data(CPUArchState *env, target_ulong ptr) | ||
634 | { | ||
635 | - return cpu_ldq_data_ra(env, ptr, 0); | ||
636 | + return cpu_ldq_be_data_ra(env, ptr, 0); | ||
637 | +} | ||
638 | + | ||
639 | +uint32_t cpu_lduw_le_data(CPUArchState *env, target_ulong ptr) | ||
640 | +{ | ||
641 | + return cpu_lduw_le_data_ra(env, ptr, 0); | ||
642 | +} | ||
643 | + | ||
644 | +int cpu_ldsw_le_data(CPUArchState *env, target_ulong ptr) | ||
645 | +{ | ||
646 | + return cpu_ldsw_le_data_ra(env, ptr, 0); | ||
647 | +} | ||
648 | + | ||
649 | +uint32_t cpu_ldl_le_data(CPUArchState *env, target_ulong ptr) | ||
650 | +{ | ||
651 | + return cpu_ldl_le_data_ra(env, ptr, 0); | ||
652 | +} | ||
653 | + | ||
654 | +uint64_t cpu_ldq_le_data(CPUArchState *env, target_ulong ptr) | ||
655 | +{ | ||
656 | + return cpu_ldq_le_data_ra(env, ptr, 0); | ||
657 | } | ||
658 | |||
659 | /* | 48 | /* |
660 | @@ -XXX,XX +XXX,XX @@ void cpu_stb_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val, | 49 | * Forward to the above feature tests given an ARMCPU pointer. |
661 | cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_UB); | 50 | */ |
662 | } | ||
663 | |||
664 | -void cpu_stw_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val, | ||
665 | - int mmu_idx, uintptr_t retaddr) | ||
666 | +void cpu_stw_be_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val, | ||
667 | + int mmu_idx, uintptr_t retaddr) | ||
668 | { | ||
669 | - cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUW); | ||
670 | + cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_BEUW); | ||
671 | } | ||
672 | |||
673 | -void cpu_stl_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val, | ||
674 | - int mmu_idx, uintptr_t retaddr) | ||
675 | +void cpu_stl_be_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val, | ||
676 | + int mmu_idx, uintptr_t retaddr) | ||
677 | { | ||
678 | - cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUL); | ||
679 | + cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_BEUL); | ||
680 | } | ||
681 | |||
682 | -void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val, | ||
683 | - int mmu_idx, uintptr_t retaddr) | ||
684 | +void cpu_stq_be_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val, | ||
685 | + int mmu_idx, uintptr_t retaddr) | ||
686 | { | ||
687 | - cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ); | ||
688 | + cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_BEQ); | ||
689 | +} | ||
690 | + | ||
691 | +void cpu_stw_le_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val, | ||
692 | + int mmu_idx, uintptr_t retaddr) | ||
693 | +{ | ||
694 | + cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_LEUW); | ||
695 | +} | ||
696 | + | ||
697 | +void cpu_stl_le_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val, | ||
698 | + int mmu_idx, uintptr_t retaddr) | ||
699 | +{ | ||
700 | + cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_LEUL); | ||
701 | +} | ||
702 | + | ||
703 | +void cpu_stq_le_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val, | ||
704 | + int mmu_idx, uintptr_t retaddr) | ||
705 | +{ | ||
706 | + cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_LEQ); | ||
707 | } | ||
708 | |||
709 | void cpu_stb_data_ra(CPUArchState *env, target_ulong ptr, | ||
710 | @@ -XXX,XX +XXX,XX @@ void cpu_stb_data_ra(CPUArchState *env, target_ulong ptr, | ||
711 | cpu_stb_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
712 | } | ||
713 | |||
714 | -void cpu_stw_data_ra(CPUArchState *env, target_ulong ptr, | ||
715 | - uint32_t val, uintptr_t retaddr) | ||
716 | +void cpu_stw_be_data_ra(CPUArchState *env, target_ulong ptr, | ||
717 | + uint32_t val, uintptr_t retaddr) | ||
718 | { | ||
719 | - cpu_stw_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
720 | + cpu_stw_be_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
721 | } | ||
722 | |||
723 | -void cpu_stl_data_ra(CPUArchState *env, target_ulong ptr, | ||
724 | - uint32_t val, uintptr_t retaddr) | ||
725 | +void cpu_stl_be_data_ra(CPUArchState *env, target_ulong ptr, | ||
726 | + uint32_t val, uintptr_t retaddr) | ||
727 | { | ||
728 | - cpu_stl_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
729 | + cpu_stl_be_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
730 | } | ||
731 | |||
732 | -void cpu_stq_data_ra(CPUArchState *env, target_ulong ptr, | ||
733 | - uint64_t val, uintptr_t retaddr) | ||
734 | +void cpu_stq_be_data_ra(CPUArchState *env, target_ulong ptr, | ||
735 | + uint64_t val, uintptr_t retaddr) | ||
736 | { | ||
737 | - cpu_stq_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
738 | + cpu_stq_be_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
739 | +} | ||
740 | + | ||
741 | +void cpu_stw_le_data_ra(CPUArchState *env, target_ulong ptr, | ||
742 | + uint32_t val, uintptr_t retaddr) | ||
743 | +{ | ||
744 | + cpu_stw_le_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
745 | +} | ||
746 | + | ||
747 | +void cpu_stl_le_data_ra(CPUArchState *env, target_ulong ptr, | ||
748 | + uint32_t val, uintptr_t retaddr) | ||
749 | +{ | ||
750 | + cpu_stl_le_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
751 | +} | ||
752 | + | ||
753 | +void cpu_stq_le_data_ra(CPUArchState *env, target_ulong ptr, | ||
754 | + uint64_t val, uintptr_t retaddr) | ||
755 | +{ | ||
756 | + cpu_stq_le_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr); | ||
757 | } | ||
758 | |||
759 | void cpu_stb_data(CPUArchState *env, target_ulong ptr, uint32_t val) | ||
760 | @@ -XXX,XX +XXX,XX @@ void cpu_stb_data(CPUArchState *env, target_ulong ptr, uint32_t val) | ||
761 | cpu_stb_data_ra(env, ptr, val, 0); | ||
762 | } | ||
763 | |||
764 | -void cpu_stw_data(CPUArchState *env, target_ulong ptr, uint32_t val) | ||
765 | +void cpu_stw_be_data(CPUArchState *env, target_ulong ptr, uint32_t val) | ||
766 | { | ||
767 | - cpu_stw_data_ra(env, ptr, val, 0); | ||
768 | + cpu_stw_be_data_ra(env, ptr, val, 0); | ||
769 | } | ||
770 | |||
771 | -void cpu_stl_data(CPUArchState *env, target_ulong ptr, uint32_t val) | ||
772 | +void cpu_stl_be_data(CPUArchState *env, target_ulong ptr, uint32_t val) | ||
773 | { | ||
774 | - cpu_stl_data_ra(env, ptr, val, 0); | ||
775 | + cpu_stl_be_data_ra(env, ptr, val, 0); | ||
776 | } | ||
777 | |||
778 | -void cpu_stq_data(CPUArchState *env, target_ulong ptr, uint64_t val) | ||
779 | +void cpu_stq_be_data(CPUArchState *env, target_ulong ptr, uint64_t val) | ||
780 | { | ||
781 | - cpu_stq_data_ra(env, ptr, val, 0); | ||
782 | + cpu_stq_be_data_ra(env, ptr, val, 0); | ||
783 | +} | ||
784 | + | ||
785 | +void cpu_stw_le_data(CPUArchState *env, target_ulong ptr, uint32_t val) | ||
786 | +{ | ||
787 | + cpu_stw_le_data_ra(env, ptr, val, 0); | ||
788 | +} | ||
789 | + | ||
790 | +void cpu_stl_le_data(CPUArchState *env, target_ulong ptr, uint32_t val) | ||
791 | +{ | ||
792 | + cpu_stl_le_data_ra(env, ptr, val, 0); | ||
793 | +} | ||
794 | + | ||
795 | +void cpu_stq_le_data(CPUArchState *env, target_ulong ptr, uint64_t val) | ||
796 | +{ | ||
797 | + cpu_stq_le_data_ra(env, ptr, val, 0); | ||
798 | } | ||
799 | |||
800 | /* First set of helpers allows passing in of OI and RETADDR. This makes | ||
801 | diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c | ||
802 | index XXXXXXX..XXXXXXX 100644 | ||
803 | --- a/accel/tcg/user-exec.c | ||
804 | +++ b/accel/tcg/user-exec.c | ||
805 | @@ -XXX,XX +XXX,XX @@ int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr) | ||
806 | return ret; | ||
807 | } | ||
808 | |||
809 | -uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr) | ||
810 | +uint32_t cpu_lduw_be_data(CPUArchState *env, abi_ptr ptr) | ||
811 | { | ||
812 | uint32_t ret; | ||
813 | - uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, false); | ||
814 | + uint16_t meminfo = trace_mem_get_info(MO_BEUW, MMU_USER_IDX, false); | ||
815 | |||
816 | trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
817 | - ret = lduw_p(g2h(ptr)); | ||
818 | + ret = lduw_be_p(g2h(ptr)); | ||
819 | qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
820 | return ret; | ||
821 | } | ||
822 | |||
823 | -int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr) | ||
824 | +int cpu_ldsw_be_data(CPUArchState *env, abi_ptr ptr) | ||
825 | { | ||
826 | int ret; | ||
827 | - uint16_t meminfo = trace_mem_get_info(MO_TESW, MMU_USER_IDX, false); | ||
828 | + uint16_t meminfo = trace_mem_get_info(MO_BESW, MMU_USER_IDX, false); | ||
829 | |||
830 | trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
831 | - ret = ldsw_p(g2h(ptr)); | ||
832 | + ret = ldsw_be_p(g2h(ptr)); | ||
833 | qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
834 | return ret; | ||
835 | } | ||
836 | |||
837 | -uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr) | ||
838 | +uint32_t cpu_ldl_be_data(CPUArchState *env, abi_ptr ptr) | ||
839 | { | ||
840 | uint32_t ret; | ||
841 | - uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, false); | ||
842 | + uint16_t meminfo = trace_mem_get_info(MO_BEUL, MMU_USER_IDX, false); | ||
843 | |||
844 | trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
845 | - ret = ldl_p(g2h(ptr)); | ||
846 | + ret = ldl_be_p(g2h(ptr)); | ||
847 | qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
848 | return ret; | ||
849 | } | ||
850 | |||
851 | -uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr) | ||
852 | +uint64_t cpu_ldq_be_data(CPUArchState *env, abi_ptr ptr) | ||
853 | { | ||
854 | uint64_t ret; | ||
855 | - uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, false); | ||
856 | + uint16_t meminfo = trace_mem_get_info(MO_BEQ, MMU_USER_IDX, false); | ||
857 | |||
858 | trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
859 | - ret = ldq_p(g2h(ptr)); | ||
860 | + ret = ldq_be_p(g2h(ptr)); | ||
861 | + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
862 | + return ret; | ||
863 | +} | ||
864 | + | ||
865 | +uint32_t cpu_lduw_le_data(CPUArchState *env, abi_ptr ptr) | ||
866 | +{ | ||
867 | + uint32_t ret; | ||
868 | + uint16_t meminfo = trace_mem_get_info(MO_LEUW, MMU_USER_IDX, false); | ||
869 | + | ||
870 | + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
871 | + ret = lduw_le_p(g2h(ptr)); | ||
872 | + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
873 | + return ret; | ||
874 | +} | ||
875 | + | ||
876 | +int cpu_ldsw_le_data(CPUArchState *env, abi_ptr ptr) | ||
877 | +{ | ||
878 | + int ret; | ||
879 | + uint16_t meminfo = trace_mem_get_info(MO_LESW, MMU_USER_IDX, false); | ||
880 | + | ||
881 | + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
882 | + ret = ldsw_le_p(g2h(ptr)); | ||
883 | + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
884 | + return ret; | ||
885 | +} | ||
886 | + | ||
887 | +uint32_t cpu_ldl_le_data(CPUArchState *env, abi_ptr ptr) | ||
888 | +{ | ||
889 | + uint32_t ret; | ||
890 | + uint16_t meminfo = trace_mem_get_info(MO_LEUL, MMU_USER_IDX, false); | ||
891 | + | ||
892 | + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
893 | + ret = ldl_le_p(g2h(ptr)); | ||
894 | + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
895 | + return ret; | ||
896 | +} | ||
897 | + | ||
898 | +uint64_t cpu_ldq_le_data(CPUArchState *env, abi_ptr ptr) | ||
899 | +{ | ||
900 | + uint64_t ret; | ||
901 | + uint16_t meminfo = trace_mem_get_info(MO_LEQ, MMU_USER_IDX, false); | ||
902 | + | ||
903 | + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
904 | + ret = ldq_le_p(g2h(ptr)); | ||
905 | qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
906 | return ret; | ||
907 | } | ||
908 | @@ -XXX,XX +XXX,XX @@ int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
909 | return ret; | ||
910 | } | ||
911 | |||
912 | -uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
913 | +uint32_t cpu_lduw_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
914 | { | ||
915 | uint32_t ret; | ||
916 | |||
917 | set_helper_retaddr(retaddr); | ||
918 | - ret = cpu_lduw_data(env, ptr); | ||
919 | + ret = cpu_lduw_be_data(env, ptr); | ||
920 | clear_helper_retaddr(); | ||
921 | return ret; | ||
922 | } | ||
923 | |||
924 | -int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
925 | +int cpu_ldsw_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
926 | { | ||
927 | int ret; | ||
928 | |||
929 | set_helper_retaddr(retaddr); | ||
930 | - ret = cpu_ldsw_data(env, ptr); | ||
931 | + ret = cpu_ldsw_be_data(env, ptr); | ||
932 | clear_helper_retaddr(); | ||
933 | return ret; | ||
934 | } | ||
935 | |||
936 | -uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
937 | +uint32_t cpu_ldl_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
938 | { | ||
939 | uint32_t ret; | ||
940 | |||
941 | set_helper_retaddr(retaddr); | ||
942 | - ret = cpu_ldl_data(env, ptr); | ||
943 | + ret = cpu_ldl_be_data(env, ptr); | ||
944 | clear_helper_retaddr(); | ||
945 | return ret; | ||
946 | } | ||
947 | |||
948 | -uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
949 | +uint64_t cpu_ldq_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
950 | { | ||
951 | uint64_t ret; | ||
952 | |||
953 | set_helper_retaddr(retaddr); | ||
954 | - ret = cpu_ldq_data(env, ptr); | ||
955 | + ret = cpu_ldq_be_data(env, ptr); | ||
956 | + clear_helper_retaddr(); | ||
957 | + return ret; | ||
958 | +} | ||
959 | + | ||
960 | +uint32_t cpu_lduw_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
961 | +{ | ||
962 | + uint32_t ret; | ||
963 | + | ||
964 | + set_helper_retaddr(retaddr); | ||
965 | + ret = cpu_lduw_le_data(env, ptr); | ||
966 | + clear_helper_retaddr(); | ||
967 | + return ret; | ||
968 | +} | ||
969 | + | ||
970 | +int cpu_ldsw_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
971 | +{ | ||
972 | + int ret; | ||
973 | + | ||
974 | + set_helper_retaddr(retaddr); | ||
975 | + ret = cpu_ldsw_le_data(env, ptr); | ||
976 | + clear_helper_retaddr(); | ||
977 | + return ret; | ||
978 | +} | ||
979 | + | ||
980 | +uint32_t cpu_ldl_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
981 | +{ | ||
982 | + uint32_t ret; | ||
983 | + | ||
984 | + set_helper_retaddr(retaddr); | ||
985 | + ret = cpu_ldl_le_data(env, ptr); | ||
986 | + clear_helper_retaddr(); | ||
987 | + return ret; | ||
988 | +} | ||
989 | + | ||
990 | +uint64_t cpu_ldq_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr) | ||
991 | +{ | ||
992 | + uint64_t ret; | ||
993 | + | ||
994 | + set_helper_retaddr(retaddr); | ||
995 | + ret = cpu_ldq_le_data(env, ptr); | ||
996 | clear_helper_retaddr(); | ||
997 | return ret; | ||
998 | } | ||
999 | @@ -XXX,XX +XXX,XX @@ void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val) | ||
1000 | qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
1001 | } | ||
1002 | |||
1003 | -void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val) | ||
1004 | +void cpu_stw_be_data(CPUArchState *env, abi_ptr ptr, uint32_t val) | ||
1005 | { | ||
1006 | - uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, true); | ||
1007 | + uint16_t meminfo = trace_mem_get_info(MO_BEUW, MMU_USER_IDX, true); | ||
1008 | |||
1009 | trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
1010 | - stw_p(g2h(ptr), val); | ||
1011 | + stw_be_p(g2h(ptr), val); | ||
1012 | qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
1013 | } | ||
1014 | |||
1015 | -void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val) | ||
1016 | +void cpu_stl_be_data(CPUArchState *env, abi_ptr ptr, uint32_t val) | ||
1017 | { | ||
1018 | - uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, true); | ||
1019 | + uint16_t meminfo = trace_mem_get_info(MO_BEUL, MMU_USER_IDX, true); | ||
1020 | |||
1021 | trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
1022 | - stl_p(g2h(ptr), val); | ||
1023 | + stl_be_p(g2h(ptr), val); | ||
1024 | qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
1025 | } | ||
1026 | |||
1027 | -void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val) | ||
1028 | +void cpu_stq_be_data(CPUArchState *env, abi_ptr ptr, uint64_t val) | ||
1029 | { | ||
1030 | - uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, true); | ||
1031 | + uint16_t meminfo = trace_mem_get_info(MO_BEQ, MMU_USER_IDX, true); | ||
1032 | |||
1033 | trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
1034 | - stq_p(g2h(ptr), val); | ||
1035 | + stq_be_p(g2h(ptr), val); | ||
1036 | + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
1037 | +} | ||
1038 | + | ||
1039 | +void cpu_stw_le_data(CPUArchState *env, abi_ptr ptr, uint32_t val) | ||
1040 | +{ | ||
1041 | + uint16_t meminfo = trace_mem_get_info(MO_LEUW, MMU_USER_IDX, true); | ||
1042 | + | ||
1043 | + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
1044 | + stw_le_p(g2h(ptr), val); | ||
1045 | + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
1046 | +} | ||
1047 | + | ||
1048 | +void cpu_stl_le_data(CPUArchState *env, abi_ptr ptr, uint32_t val) | ||
1049 | +{ | ||
1050 | + uint16_t meminfo = trace_mem_get_info(MO_LEUL, MMU_USER_IDX, true); | ||
1051 | + | ||
1052 | + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
1053 | + stl_le_p(g2h(ptr), val); | ||
1054 | + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
1055 | +} | ||
1056 | + | ||
1057 | +void cpu_stq_le_data(CPUArchState *env, abi_ptr ptr, uint64_t val) | ||
1058 | +{ | ||
1059 | + uint16_t meminfo = trace_mem_get_info(MO_LEQ, MMU_USER_IDX, true); | ||
1060 | + | ||
1061 | + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); | ||
1062 | + stq_le_p(g2h(ptr), val); | ||
1063 | qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); | ||
1064 | } | ||
1065 | |||
1066 | @@ -XXX,XX +XXX,XX @@ void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1067 | clear_helper_retaddr(); | ||
1068 | } | ||
1069 | |||
1070 | -void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1071 | - uint32_t val, uintptr_t retaddr) | ||
1072 | +void cpu_stw_be_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1073 | + uint32_t val, uintptr_t retaddr) | ||
1074 | { | ||
1075 | set_helper_retaddr(retaddr); | ||
1076 | - cpu_stw_data(env, ptr, val); | ||
1077 | + cpu_stw_be_data(env, ptr, val); | ||
1078 | clear_helper_retaddr(); | ||
1079 | } | ||
1080 | |||
1081 | -void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1082 | - uint32_t val, uintptr_t retaddr) | ||
1083 | +void cpu_stl_be_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1084 | + uint32_t val, uintptr_t retaddr) | ||
1085 | { | ||
1086 | set_helper_retaddr(retaddr); | ||
1087 | - cpu_stl_data(env, ptr, val); | ||
1088 | + cpu_stl_be_data(env, ptr, val); | ||
1089 | clear_helper_retaddr(); | ||
1090 | } | ||
1091 | |||
1092 | -void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1093 | - uint64_t val, uintptr_t retaddr) | ||
1094 | +void cpu_stq_be_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1095 | + uint64_t val, uintptr_t retaddr) | ||
1096 | { | ||
1097 | set_helper_retaddr(retaddr); | ||
1098 | - cpu_stq_data(env, ptr, val); | ||
1099 | + cpu_stq_be_data(env, ptr, val); | ||
1100 | + clear_helper_retaddr(); | ||
1101 | +} | ||
1102 | + | ||
1103 | +void cpu_stw_le_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1104 | + uint32_t val, uintptr_t retaddr) | ||
1105 | +{ | ||
1106 | + set_helper_retaddr(retaddr); | ||
1107 | + cpu_stw_le_data(env, ptr, val); | ||
1108 | + clear_helper_retaddr(); | ||
1109 | +} | ||
1110 | + | ||
1111 | +void cpu_stl_le_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1112 | + uint32_t val, uintptr_t retaddr) | ||
1113 | +{ | ||
1114 | + set_helper_retaddr(retaddr); | ||
1115 | + cpu_stl_le_data(env, ptr, val); | ||
1116 | + clear_helper_retaddr(); | ||
1117 | +} | ||
1118 | + | ||
1119 | +void cpu_stq_le_data_ra(CPUArchState *env, abi_ptr ptr, | ||
1120 | + uint64_t val, uintptr_t retaddr) | ||
1121 | +{ | ||
1122 | + set_helper_retaddr(retaddr); | ||
1123 | + cpu_stq_le_data(env, ptr, val); | ||
1124 | clear_helper_retaddr(); | ||
1125 | } | ||
1126 | |||
1127 | -- | 51 | -- |
1128 | 2.20.1 | 52 | 2.25.1 |
1129 | |||
1130 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | For contiguous predicated memory operations, we want to | 3 | Add the aa64 predicate for detecting RAS support from id registers. |
4 | minimize the number of tlb lookups performed. We have | 4 | We already have the aa32 version from the M-profile work. |
5 | open-coded this for sve_ld1_r, but for correctness with | 5 | Add the 'any' predicate for testing both aa64 and aa32. |
6 | MTE we will need this for all of the memory operations. | ||
7 | |||
8 | Create a structure that holds the bounds of active elements, | ||
9 | and metadata for two pages. Add routines to find those | ||
10 | active elements, lookup the pages, and run watchpoints | ||
11 | for those pages. | ||
12 | |||
13 | Temporarily mark the functions unused to avoid Werror. | ||
14 | 6 | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20200508154359.7494-10-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-34-richard.henderson@linaro.org |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 11 | --- |
20 | target/arm/sve_helper.c | 263 +++++++++++++++++++++++++++++++++++++++- | 12 | target/arm/cpu.h | 10 ++++++++++ |
21 | 1 file changed, 261 insertions(+), 2 deletions(-) | 13 | 1 file changed, 10 insertions(+) |
22 | 14 | ||
23 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
24 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/sve_helper.c | 17 | --- a/target/arm/cpu.h |
26 | +++ b/target/arm/sve_helper.c | 18 | +++ b/target/arm/cpu.h |
27 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_cpy_z_d)(void *vd, void *vg, uint64_t val, uint32_t desc) | 19 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id) |
28 | } | 20 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2; |
29 | } | 21 | } |
30 | 22 | ||
31 | -/* Big-endian hosts need to frob the byte indicies. If the copy | 23 | +static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) |
32 | +/* Big-endian hosts need to frob the byte indices. If the copy | ||
33 | * happens to be 8-byte aligned, then no frobbing necessary. | ||
34 | */ | ||
35 | static void swap_memmove(void *vd, void *vs, size_t n) | ||
36 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_fcmla_zpzzz_d)(CPUARMState *env, void *vg, uint32_t desc) | ||
37 | /* | ||
38 | * Load elements into @vd, controlled by @vg, from @host + @mem_ofs. | ||
39 | * Memory is valid through @host + @mem_max. The register element | ||
40 | - * indicies are inferred from @mem_ofs, as modified by the types for | ||
41 | + * indices are inferred from @mem_ofs, as modified by the types for | ||
42 | * which the helper is built. Return the @mem_ofs of the first element | ||
43 | * not loaded (which is @mem_max if they are all loaded). | ||
44 | * | ||
45 | @@ -XXX,XX +XXX,XX @@ static intptr_t max_for_page(target_ulong base, intptr_t mem_off, | ||
46 | return MIN(split, mem_max - mem_off) + mem_off; | ||
47 | } | ||
48 | |||
49 | +/* | ||
50 | + * Resolve the guest virtual address to info->host and info->flags. | ||
51 | + * If @nofault, return false if the page is invalid, otherwise | ||
52 | + * exit via page fault exception. | ||
53 | + */ | ||
54 | + | ||
55 | +typedef struct { | ||
56 | + void *host; | ||
57 | + int flags; | ||
58 | + MemTxAttrs attrs; | ||
59 | +} SVEHostPage; | ||
60 | + | ||
61 | +static bool sve_probe_page(SVEHostPage *info, bool nofault, | ||
62 | + CPUARMState *env, target_ulong addr, | ||
63 | + int mem_off, MMUAccessType access_type, | ||
64 | + int mmu_idx, uintptr_t retaddr) | ||
65 | +{ | 24 | +{ |
66 | + int flags; | 25 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0; |
67 | + | ||
68 | + addr += mem_off; | ||
69 | + flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault, | ||
70 | + &info->host, retaddr); | ||
71 | + info->flags = flags; | ||
72 | + | ||
73 | + if (flags & TLB_INVALID_MASK) { | ||
74 | + g_assert(nofault); | ||
75 | + return false; | ||
76 | + } | ||
77 | + | ||
78 | + /* Ensure that info->host[] is relative to addr, not addr + mem_off. */ | ||
79 | + info->host -= mem_off; | ||
80 | + | ||
81 | +#ifdef CONFIG_USER_ONLY | ||
82 | + memset(&info->attrs, 0, sizeof(info->attrs)); | ||
83 | +#else | ||
84 | + /* | ||
85 | + * Find the iotlbentry for addr and return the transaction attributes. | ||
86 | + * This *must* be present in the TLB because we just found the mapping. | ||
87 | + */ | ||
88 | + { | ||
89 | + uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
90 | + | ||
91 | +# ifdef CONFIG_DEBUG_TCG | ||
92 | + CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); | ||
93 | + target_ulong comparator = (access_type == MMU_DATA_LOAD | ||
94 | + ? entry->addr_read | ||
95 | + : tlb_addr_write(entry)); | ||
96 | + g_assert(tlb_hit(comparator, addr)); | ||
97 | +# endif | ||
98 | + | ||
99 | + CPUIOTLBEntry *iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
100 | + info->attrs = iotlbentry->attrs; | ||
101 | + } | ||
102 | +#endif | ||
103 | + | ||
104 | + return true; | ||
105 | +} | 26 | +} |
106 | + | 27 | + |
107 | + | 28 | static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) |
108 | +/* | 29 | { |
109 | + * Analyse contiguous data, protected by a governing predicate. | 30 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; |
110 | + */ | 31 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) |
111 | + | 32 | return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); |
112 | +typedef enum { | 33 | } |
113 | + FAULT_NO, | 34 | |
114 | + FAULT_FIRST, | 35 | +static inline bool isar_feature_any_ras(const ARMISARegisters *id) |
115 | + FAULT_ALL, | ||
116 | +} SVEContFault; | ||
117 | + | ||
118 | +typedef struct { | ||
119 | + /* | ||
120 | + * First and last element wholly contained within the two pages. | ||
121 | + * mem_off_first[0] and reg_off_first[0] are always set >= 0. | ||
122 | + * reg_off_last[0] may be < 0 if the first element crosses pages. | ||
123 | + * All of mem_off_first[1], reg_off_first[1] and reg_off_last[1] | ||
124 | + * are set >= 0 only if there are complete elements on a second page. | ||
125 | + * | ||
126 | + * The reg_off_* offsets are relative to the internal vector register. | ||
127 | + * The mem_off_first offset is relative to the memory address; the | ||
128 | + * two offsets are different when a load operation extends, a store | ||
129 | + * operation truncates, or for multi-register operations. | ||
130 | + */ | ||
131 | + int16_t mem_off_first[2]; | ||
132 | + int16_t reg_off_first[2]; | ||
133 | + int16_t reg_off_last[2]; | ||
134 | + | ||
135 | + /* | ||
136 | + * One element that is misaligned and spans both pages, | ||
137 | + * or -1 if there is no such active element. | ||
138 | + */ | ||
139 | + int16_t mem_off_split; | ||
140 | + int16_t reg_off_split; | ||
141 | + | ||
142 | + /* | ||
143 | + * The byte offset at which the entire operation crosses a page boundary. | ||
144 | + * Set >= 0 if and only if the entire operation spans two pages. | ||
145 | + */ | ||
146 | + int16_t page_split; | ||
147 | + | ||
148 | + /* TLB data for the two pages. */ | ||
149 | + SVEHostPage page[2]; | ||
150 | +} SVEContLdSt; | ||
151 | + | ||
152 | +/* | ||
153 | + * Find first active element on each page, and a loose bound for the | ||
154 | + * final element on each page. Identify any single element that spans | ||
155 | + * the page boundary. Return true if there are any active elements. | ||
156 | + */ | ||
157 | +static bool __attribute__((unused)) | ||
158 | +sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, uint64_t *vg, | ||
159 | + intptr_t reg_max, int esz, int msize) | ||
160 | +{ | 36 | +{ |
161 | + const int esize = 1 << esz; | 37 | + return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id); |
162 | + const uint64_t pg_mask = pred_esz_masks[esz]; | ||
163 | + intptr_t reg_off_first = -1, reg_off_last = -1, reg_off_split; | ||
164 | + intptr_t mem_off_last, mem_off_split; | ||
165 | + intptr_t page_split, elt_split; | ||
166 | + intptr_t i; | ||
167 | + | ||
168 | + /* Set all of the element indices to -1, and the TLB data to 0. */ | ||
169 | + memset(info, -1, offsetof(SVEContLdSt, page)); | ||
170 | + memset(info->page, 0, sizeof(info->page)); | ||
171 | + | ||
172 | + /* Gross scan over the entire predicate to find bounds. */ | ||
173 | + i = 0; | ||
174 | + do { | ||
175 | + uint64_t pg = vg[i] & pg_mask; | ||
176 | + if (pg) { | ||
177 | + reg_off_last = i * 64 + 63 - clz64(pg); | ||
178 | + if (reg_off_first < 0) { | ||
179 | + reg_off_first = i * 64 + ctz64(pg); | ||
180 | + } | ||
181 | + } | ||
182 | + } while (++i * 64 < reg_max); | ||
183 | + | ||
184 | + if (unlikely(reg_off_first < 0)) { | ||
185 | + /* No active elements, no pages touched. */ | ||
186 | + return false; | ||
187 | + } | ||
188 | + tcg_debug_assert(reg_off_last >= 0 && reg_off_last < reg_max); | ||
189 | + | ||
190 | + info->reg_off_first[0] = reg_off_first; | ||
191 | + info->mem_off_first[0] = (reg_off_first >> esz) * msize; | ||
192 | + mem_off_last = (reg_off_last >> esz) * msize; | ||
193 | + | ||
194 | + page_split = -(addr | TARGET_PAGE_MASK); | ||
195 | + if (likely(mem_off_last + msize <= page_split)) { | ||
196 | + /* The entire operation fits within a single page. */ | ||
197 | + info->reg_off_last[0] = reg_off_last; | ||
198 | + return true; | ||
199 | + } | ||
200 | + | ||
201 | + info->page_split = page_split; | ||
202 | + elt_split = page_split / msize; | ||
203 | + reg_off_split = elt_split << esz; | ||
204 | + mem_off_split = elt_split * msize; | ||
205 | + | ||
206 | + /* | ||
207 | + * This is the last full element on the first page, but it is not | ||
208 | + * necessarily active. If there is no full element, i.e. the first | ||
209 | + * active element is the one that's split, this value remains -1. | ||
210 | + * It is useful as iteration bounds. | ||
211 | + */ | ||
212 | + if (elt_split != 0) { | ||
213 | + info->reg_off_last[0] = reg_off_split - esize; | ||
214 | + } | ||
215 | + | ||
216 | + /* Determine if an unaligned element spans the pages. */ | ||
217 | + if (page_split % msize != 0) { | ||
218 | + /* It is helpful to know if the split element is active. */ | ||
219 | + if ((vg[reg_off_split >> 6] >> (reg_off_split & 63)) & 1) { | ||
220 | + info->reg_off_split = reg_off_split; | ||
221 | + info->mem_off_split = mem_off_split; | ||
222 | + | ||
223 | + if (reg_off_split == reg_off_last) { | ||
224 | + /* The page crossing element is last. */ | ||
225 | + return true; | ||
226 | + } | ||
227 | + } | ||
228 | + reg_off_split += esize; | ||
229 | + mem_off_split += msize; | ||
230 | + } | ||
231 | + | ||
232 | + /* | ||
233 | + * We do want the first active element on the second page, because | ||
234 | + * this may affect the address reported in an exception. | ||
235 | + */ | ||
236 | + reg_off_split = find_next_active(vg, reg_off_split, reg_max, esz); | ||
237 | + tcg_debug_assert(reg_off_split <= reg_off_last); | ||
238 | + info->reg_off_first[1] = reg_off_split; | ||
239 | + info->mem_off_first[1] = (reg_off_split >> esz) * msize; | ||
240 | + info->reg_off_last[1] = reg_off_last; | ||
241 | + return true; | ||
242 | +} | ||
243 | + | ||
244 | +/* | ||
245 | + * Resolve the guest virtual addresses to info->page[]. | ||
246 | + * Control the generation of page faults with @fault. Return false if | ||
247 | + * there is no work to do, which can only happen with @fault == FAULT_NO. | ||
248 | + */ | ||
249 | +static bool __attribute__((unused)) | ||
250 | +sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, CPUARMState *env, | ||
251 | + target_ulong addr, MMUAccessType access_type, | ||
252 | + uintptr_t retaddr) | ||
253 | +{ | ||
254 | + int mmu_idx = cpu_mmu_index(env, false); | ||
255 | + int mem_off = info->mem_off_first[0]; | ||
256 | + bool nofault = fault == FAULT_NO; | ||
257 | + bool have_work = true; | ||
258 | + | ||
259 | + if (!sve_probe_page(&info->page[0], nofault, env, addr, mem_off, | ||
260 | + access_type, mmu_idx, retaddr)) { | ||
261 | + /* No work to be done. */ | ||
262 | + return false; | ||
263 | + } | ||
264 | + | ||
265 | + if (likely(info->page_split < 0)) { | ||
266 | + /* The entire operation was on the one page. */ | ||
267 | + return true; | ||
268 | + } | ||
269 | + | ||
270 | + /* | ||
271 | + * If the second page is invalid, then we want the fault address to be | ||
272 | + * the first byte on that page which is accessed. | ||
273 | + */ | ||
274 | + if (info->mem_off_split >= 0) { | ||
275 | + /* | ||
276 | + * There is an element split across the pages. The fault address | ||
277 | + * should be the first byte of the second page. | ||
278 | + */ | ||
279 | + mem_off = info->page_split; | ||
280 | + /* | ||
281 | + * If the split element is also the first active element | ||
282 | + * of the vector, then: For first-fault we should continue | ||
283 | + * to generate faults for the second page. For no-fault, | ||
284 | + * we have work only if the second page is valid. | ||
285 | + */ | ||
286 | + if (info->mem_off_first[0] < info->mem_off_split) { | ||
287 | + nofault = FAULT_FIRST; | ||
288 | + have_work = false; | ||
289 | + } | ||
290 | + } else { | ||
291 | + /* | ||
292 | + * There is no element split across the pages. The fault address | ||
293 | + * should be the first active element on the second page. | ||
294 | + */ | ||
295 | + mem_off = info->mem_off_first[1]; | ||
296 | + /* | ||
297 | + * There must have been one active element on the first page, | ||
298 | + * so we're out of first-fault territory. | ||
299 | + */ | ||
300 | + nofault = fault != FAULT_ALL; | ||
301 | + } | ||
302 | + | ||
303 | + have_work |= sve_probe_page(&info->page[1], nofault, env, addr, mem_off, | ||
304 | + access_type, mmu_idx, retaddr); | ||
305 | + return have_work; | ||
306 | +} | 38 | +} |
307 | + | 39 | + |
308 | /* | 40 | /* |
309 | * The result of tlb_vaddr_to_host for user-only is just g2h(x), | 41 | * Forward to the above feature tests given an ARMCPU pointer. |
310 | * which is always non-null. Elide the useless test. | 42 | */ |
311 | -- | 43 | -- |
312 | 2.20.1 | 44 | 2.25.1 |
313 | |||
314 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Alex Zuepke <alex.zuepke@tum.de> |
---|---|---|---|
2 | 2 | ||
3 | Calling access_el3_aa32ns() works for AArch32 only cores | 3 | The ARMv8 manual defines that PMUSERENR_EL0.ER enables read-access |
4 | but it does not handle 32-bit EL2 on top of 64-bit EL3 | 4 | to both PMXEVCNTR_EL0 and PMEVCNTR<n>_EL0 registers, however, |
5 | for mixed 32/64-bit cores. | 5 | we only use it for PMXEVCNTR_EL0. Extend to PMEVCNTR<n>_EL0 as well. |
6 | 6 | ||
7 | Merge access_el3_aa32ns_aa64any() into access_el3_aa32ns() | 7 | Signed-off-by: Alex Zuepke <alex.zuepke@tum.de> |
8 | and only use the latter. | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | 9 | Message-id: 20220428132717.84190-1-alex.zuepke@tum.de | |
10 | Fixes: 68e9c2fe65 ("target-arm: Add VTCR_EL2") | ||
11 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
12 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
13 | Message-id: 20200505141729.31930-2-edgar.iglesias@gmail.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 11 | --- |
17 | target/arm/helper.c | 30 +++++++----------------------- | 12 | target/arm/helper.c | 4 ++-- |
18 | 1 file changed, 7 insertions(+), 23 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
19 | 14 | ||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
23 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ void init_cpreg_list(ARMCPU *cpu) | 19 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
25 | } | 20 | .crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, |
26 | 21 | .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | |
27 | /* | 22 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, |
28 | - * Some registers are not accessible if EL3.NS=0 and EL3 is using AArch32 but | 23 | - .accessfn = pmreg_access }, |
29 | - * they are accessible when EL3 is using AArch64 regardless of EL3.NS. | 24 | + .accessfn = pmreg_access_xevcntr }, |
30 | - * | 25 | { .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64, |
31 | - * access_el3_aa32ns: Used to check AArch32 register views. | 26 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)), |
32 | - * access_el3_aa32ns_aa64any: Used to check both AArch32/64 register views. | 27 | - .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, |
33 | + * Some registers are not accessible from AArch32 EL3 if SCR.NS == 0. | 28 | + .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access_xevcntr, |
34 | */ | 29 | .type = ARM_CP_IO, |
35 | static CPAccessResult access_el3_aa32ns(CPUARMState *env, | 30 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, |
36 | const ARMCPRegInfo *ri, | 31 | .raw_readfn = pmevcntr_rawread, |
37 | bool isread) | ||
38 | { | ||
39 | - bool secure = arm_is_secure_below_el3(env); | ||
40 | - | ||
41 | - assert(!arm_el_is_aa64(env, 3)); | ||
42 | - if (secure) { | ||
43 | + if (!is_a64(env) && arm_current_el(env) == 3 && | ||
44 | + arm_is_secure_below_el3(env)) { | ||
45 | return CP_ACCESS_TRAP_UNCATEGORIZED; | ||
46 | } | ||
47 | return CP_ACCESS_OK; | ||
48 | } | ||
49 | |||
50 | -static CPAccessResult access_el3_aa32ns_aa64any(CPUARMState *env, | ||
51 | - const ARMCPRegInfo *ri, | ||
52 | - bool isread) | ||
53 | -{ | ||
54 | - if (!arm_el_is_aa64(env, 3)) { | ||
55 | - return access_el3_aa32ns(env, ri, isread); | ||
56 | - } | ||
57 | - return CP_ACCESS_OK; | ||
58 | -} | ||
59 | - | ||
60 | /* Some secure-only AArch32 registers trap to EL3 if used from | ||
61 | * Secure EL1 (but are just ordinary UNDEF in other non-EL3 contexts). | ||
62 | * Note that an access from Secure EL1 can only happen if EL3 is AArch64. | ||
63 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { | ||
64 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
65 | { .name = "VTCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
66 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 2, | ||
67 | - .access = PL2_RW, .accessfn = access_el3_aa32ns_aa64any, | ||
68 | + .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
69 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
70 | { .name = "VTTBR", .state = ARM_CP_STATE_AA32, | ||
71 | .cp = 15, .opc1 = 6, .crm = 2, | ||
72 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { | ||
73 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
74 | { .name = "HPFAR_EL2", .state = ARM_CP_STATE_BOTH, | ||
75 | .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4, | ||
76 | - .access = PL2_RW, .accessfn = access_el3_aa32ns_aa64any, | ||
77 | + .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
78 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | { .name = "HSTR_EL2", .state = ARM_CP_STATE_BOTH, | ||
80 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, | ||
81 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
82 | ARMCPRegInfo vpidr_regs[] = { | ||
83 | { .name = "VPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
84 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
85 | - .access = PL2_RW, .accessfn = access_el3_aa32ns_aa64any, | ||
86 | + .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
87 | .type = ARM_CP_CONST, .resetvalue = cpu->midr, | ||
88 | .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, | ||
89 | { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
90 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
91 | - .access = PL2_RW, .accessfn = access_el3_aa32ns_aa64any, | ||
92 | + .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
93 | .type = ARM_CP_NO_RAW, | ||
94 | .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, | ||
95 | REGINFO_SENTINEL | ||
96 | -- | 32 | -- |
97 | 2.20.1 | 33 | 2.25.1 |
98 | |||
99 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | There are minimal differences from Qemu's point of view between the A0 | ||
4 | and A1 silicon revisions. | ||
5 | |||
6 | As the A1 exercises different code paths in u-boot it is desirable to | ||
7 | emulate that instead. | ||
8 | |||
9 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
10 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
11 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Message-id: 20200504093703.261135-1-joel@jms.id.au | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | include/hw/misc/aspeed_scu.h | 1 + | ||
16 | hw/arm/aspeed.c | 8 ++++---- | ||
17 | hw/arm/aspeed_ast2600.c | 6 +++--- | ||
18 | hw/misc/aspeed_scu.c | 11 +++++------ | ||
19 | 4 files changed, 13 insertions(+), 13 deletions(-) | ||
20 | |||
21 | diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/misc/aspeed_scu.h | ||
24 | +++ b/include/hw/misc/aspeed_scu.h | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSCUState { | ||
26 | #define AST2500_A0_SILICON_REV 0x04000303U | ||
27 | #define AST2500_A1_SILICON_REV 0x04010303U | ||
28 | #define AST2600_A0_SILICON_REV 0x05000303U | ||
29 | +#define AST2600_A1_SILICON_REV 0x05010303U | ||
30 | |||
31 | #define ASPEED_IS_AST2500(si_rev) ((((si_rev) >> 24) & 0xff) == 0x04) | ||
32 | |||
33 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/hw/arm/aspeed.c | ||
36 | +++ b/hw/arm/aspeed.c | ||
37 | @@ -XXX,XX +XXX,XX @@ struct AspeedBoardState { | ||
38 | |||
39 | /* Tacoma hardware value */ | ||
40 | #define TACOMA_BMC_HW_STRAP1 0x00000000 | ||
41 | -#define TACOMA_BMC_HW_STRAP2 0x00000000 | ||
42 | +#define TACOMA_BMC_HW_STRAP2 0x00000040 | ||
43 | |||
44 | /* | ||
45 | * The max ram region is for firmwares that scan the address space | ||
46 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | ||
47 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
48 | |||
49 | mc->desc = "Aspeed AST2600 EVB (Cortex A7)"; | ||
50 | - amc->soc_name = "ast2600-a0"; | ||
51 | + amc->soc_name = "ast2600-a1"; | ||
52 | amc->hw_strap1 = AST2600_EVB_HW_STRAP1; | ||
53 | amc->hw_strap2 = AST2600_EVB_HW_STRAP2; | ||
54 | amc->fmc_model = "w25q512jv"; | ||
55 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data) | ||
56 | MachineClass *mc = MACHINE_CLASS(oc); | ||
57 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
58 | |||
59 | - mc->desc = "Aspeed AST2600 EVB (Cortex A7)"; | ||
60 | - amc->soc_name = "ast2600-a0"; | ||
61 | + mc->desc = "OpenPOWER Tacoma BMC (Cortex A7)"; | ||
62 | + amc->soc_name = "ast2600-a1"; | ||
63 | amc->hw_strap1 = TACOMA_BMC_HW_STRAP1; | ||
64 | amc->hw_strap2 = TACOMA_BMC_HW_STRAP2; | ||
65 | amc->fmc_model = "mx66l1g45g"; | ||
66 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/arm/aspeed_ast2600.c | ||
69 | +++ b/hw/arm/aspeed_ast2600.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) | ||
71 | |||
72 | dc->realize = aspeed_soc_ast2600_realize; | ||
73 | |||
74 | - sc->name = "ast2600-a0"; | ||
75 | + sc->name = "ast2600-a1"; | ||
76 | sc->cpu_type = ARM_CPU_TYPE_NAME("cortex-a7"); | ||
77 | - sc->silicon_rev = AST2600_A0_SILICON_REV; | ||
78 | + sc->silicon_rev = AST2600_A1_SILICON_REV; | ||
79 | sc->sram_size = 0x10000; | ||
80 | sc->spis_num = 2; | ||
81 | sc->ehcis_num = 2; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) | ||
83 | } | ||
84 | |||
85 | static const TypeInfo aspeed_soc_ast2600_type_info = { | ||
86 | - .name = "ast2600-a0", | ||
87 | + .name = "ast2600-a1", | ||
88 | .parent = TYPE_ASPEED_SOC, | ||
89 | .instance_size = sizeof(AspeedSoCState), | ||
90 | .instance_init = aspeed_soc_ast2600_init, | ||
91 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/hw/misc/aspeed_scu.c | ||
94 | +++ b/hw/misc/aspeed_scu.c | ||
95 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_silicon_revs[] = { | ||
96 | AST2500_A0_SILICON_REV, | ||
97 | AST2500_A1_SILICON_REV, | ||
98 | AST2600_A0_SILICON_REV, | ||
99 | + AST2600_A1_SILICON_REV, | ||
100 | }; | ||
101 | |||
102 | bool is_supported_silicon_rev(uint32_t silicon_rev) | ||
103 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_ast2600_scu_ops = { | ||
104 | .valid.unaligned = false, | ||
105 | }; | ||
106 | |||
107 | -static const uint32_t ast2600_a0_resets[ASPEED_AST2600_SCU_NR_REGS] = { | ||
108 | - [AST2600_SILICON_REV] = AST2600_SILICON_REV, | ||
109 | - [AST2600_SILICON_REV2] = AST2600_SILICON_REV, | ||
110 | - [AST2600_SYS_RST_CTRL] = 0xF7CFFEDC | 0x100, | ||
111 | +static const uint32_t ast2600_a1_resets[ASPEED_AST2600_SCU_NR_REGS] = { | ||
112 | + [AST2600_SYS_RST_CTRL] = 0xF7C3FED8, | ||
113 | [AST2600_SYS_RST_CTRL2] = 0xFFFFFFFC, | ||
114 | - [AST2600_CLK_STOP_CTRL] = 0xEFF43E8B, | ||
115 | + [AST2600_CLK_STOP_CTRL] = 0xFFFF7F8A, | ||
116 | [AST2600_CLK_STOP_CTRL2] = 0xFFF0FFF0, | ||
117 | [AST2600_SDRAM_HANDSHAKE] = 0x00000040, /* SoC completed DRAM init */ | ||
118 | [AST2600_HPLL_PARAM] = 0x1000405F, | ||
119 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_scu_class_init(ObjectClass *klass, void *data) | ||
120 | |||
121 | dc->desc = "ASPEED 2600 System Control Unit"; | ||
122 | dc->reset = aspeed_ast2600_scu_reset; | ||
123 | - asc->resets = ast2600_a0_resets; | ||
124 | + asc->resets = ast2600_a1_resets; | ||
125 | asc->calc_hpll = aspeed_2500_scu_calc_hpll; /* No change since AST2500 */ | ||
126 | asc->apb_divider = 4; | ||
127 | asc->nr_regs = ASPEED_AST2600_SCU_NR_REGS; | ||
128 | -- | ||
129 | 2.20.1 | ||
130 | |||
131 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | The AST2600 handles this differently with the extra 'hardlock' state, so | ||
4 | move the testing to the soc specific class' write callback. | ||
5 | |||
6 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20200505090136.341426-1-joel@jms.id.au | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/misc/aspeed_sdmc.c | 55 +++++++++++++++++++++++++++++++++++-------- | ||
12 | 1 file changed, 45 insertions(+), 10 deletions(-) | ||
13 | |||
14 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/misc/aspeed_sdmc.c | ||
17 | +++ b/hw/misc/aspeed_sdmc.c | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | /* Protection Key Register */ | ||
21 | #define R_PROT (0x00 / 4) | ||
22 | +#define PROT_UNLOCKED 0x01 | ||
23 | +#define PROT_HARDLOCKED 0x10 /* AST2600 */ | ||
24 | +#define PROT_SOFTLOCKED 0x00 | ||
25 | + | ||
26 | #define PROT_KEY_UNLOCK 0xFC600309 | ||
27 | +#define PROT_KEY_HARDLOCK 0xDEADDEAD /* AST2600 */ | ||
28 | |||
29 | /* Configuration Register */ | ||
30 | #define R_CONF (0x04 / 4) | ||
31 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data, | ||
32 | return; | ||
33 | } | ||
34 | |||
35 | - if (addr == R_PROT) { | ||
36 | - s->regs[addr] = (data == PROT_KEY_UNLOCK) ? 1 : 0; | ||
37 | - return; | ||
38 | - } | ||
39 | - | ||
40 | - if (!s->regs[R_PROT]) { | ||
41 | - qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__); | ||
42 | - return; | ||
43 | - } | ||
44 | - | ||
45 | asc->write(s, addr, data); | ||
46 | } | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2400_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data) | ||
49 | static void aspeed_2400_sdmc_write(AspeedSDMCState *s, uint32_t reg, | ||
50 | uint32_t data) | ||
51 | { | ||
52 | + if (reg == R_PROT) { | ||
53 | + s->regs[reg] = (data == PROT_KEY_UNLOCK) ? PROT_UNLOCKED : PROT_SOFTLOCKED; | ||
54 | + return; | ||
55 | + } | ||
56 | + | ||
57 | + if (!s->regs[R_PROT]) { | ||
58 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__); | ||
59 | + return; | ||
60 | + } | ||
61 | + | ||
62 | switch (reg) { | ||
63 | case R_CONF: | ||
64 | data = aspeed_2400_sdmc_compute_conf(s, data); | ||
65 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2500_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data) | ||
66 | static void aspeed_2500_sdmc_write(AspeedSDMCState *s, uint32_t reg, | ||
67 | uint32_t data) | ||
68 | { | ||
69 | + if (reg == R_PROT) { | ||
70 | + s->regs[reg] = (data == PROT_KEY_UNLOCK) ? PROT_UNLOCKED : PROT_SOFTLOCKED; | ||
71 | + return; | ||
72 | + } | ||
73 | + | ||
74 | + if (!s->regs[R_PROT]) { | ||
75 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__); | ||
76 | + return; | ||
77 | + } | ||
78 | + | ||
79 | switch (reg) { | ||
80 | case R_CONF: | ||
81 | data = aspeed_2500_sdmc_compute_conf(s, data); | ||
82 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2600_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data) | ||
83 | static void aspeed_2600_sdmc_write(AspeedSDMCState *s, uint32_t reg, | ||
84 | uint32_t data) | ||
85 | { | ||
86 | + if (s->regs[R_PROT] == PROT_HARDLOCKED) { | ||
87 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked until system reset!\n", | ||
88 | + __func__); | ||
89 | + return; | ||
90 | + } | ||
91 | + | ||
92 | + if (reg != R_PROT && s->regs[R_PROT] == PROT_SOFTLOCKED) { | ||
93 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__); | ||
94 | + return; | ||
95 | + } | ||
96 | + | ||
97 | switch (reg) { | ||
98 | + case R_PROT: | ||
99 | + if (data == PROT_KEY_UNLOCK) { | ||
100 | + data = PROT_UNLOCKED; | ||
101 | + } else if (data == PROT_KEY_HARDLOCK) { | ||
102 | + data = PROT_HARDLOCKED; | ||
103 | + } else { | ||
104 | + data = PROT_SOFTLOCKED; | ||
105 | + } | ||
106 | + break; | ||
107 | case R_CONF: | ||
108 | data = aspeed_2600_sdmc_compute_conf(s, data); | ||
109 | break; | ||
110 | -- | ||
111 | 2.20.1 | ||
112 | |||
113 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | On the NRF51 series, all peripherals have a fixed I/O size | ||
4 | of 4KiB. Define NRF51_PERIPHERAL_SIZE and use it. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200504072822.18799-2-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/nrf51.h | 3 +-- | ||
12 | include/hw/i2c/microbit_i2c.h | 2 +- | ||
13 | hw/arm/nrf51_soc.c | 4 ++-- | ||
14 | hw/i2c/microbit_i2c.c | 2 +- | ||
15 | hw/timer/nrf51_timer.c | 2 +- | ||
16 | 5 files changed, 6 insertions(+), 7 deletions(-) | ||
17 | |||
18 | diff --git a/include/hw/arm/nrf51.h b/include/hw/arm/nrf51.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/arm/nrf51.h | ||
21 | +++ b/include/hw/arm/nrf51.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #define NRF51_IOMEM_BASE 0x40000000 | ||
24 | #define NRF51_IOMEM_SIZE 0x20000000 | ||
25 | |||
26 | +#define NRF51_PERIPHERAL_SIZE 0x00001000 | ||
27 | #define NRF51_UART_BASE 0x40002000 | ||
28 | #define NRF51_TWI_BASE 0x40003000 | ||
29 | -#define NRF51_TWI_SIZE 0x00001000 | ||
30 | #define NRF51_TIMER_BASE 0x40008000 | ||
31 | -#define NRF51_TIMER_SIZE 0x00001000 | ||
32 | #define NRF51_RNG_BASE 0x4000D000 | ||
33 | #define NRF51_NVMC_BASE 0x4001E000 | ||
34 | #define NRF51_GPIO_BASE 0x50000000 | ||
35 | diff --git a/include/hw/i2c/microbit_i2c.h b/include/hw/i2c/microbit_i2c.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/include/hw/i2c/microbit_i2c.h | ||
38 | +++ b/include/hw/i2c/microbit_i2c.h | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | #define MICROBIT_I2C(obj) \ | ||
41 | OBJECT_CHECK(MicrobitI2CState, (obj), TYPE_MICROBIT_I2C) | ||
42 | |||
43 | -#define MICROBIT_I2C_NREGS (NRF51_TWI_SIZE / sizeof(uint32_t)) | ||
44 | +#define MICROBIT_I2C_NREGS (NRF51_PERIPHERAL_SIZE / sizeof(uint32_t)) | ||
45 | |||
46 | typedef struct { | ||
47 | SysBusDevice parent_obj; | ||
48 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/arm/nrf51_soc.c | ||
51 | +++ b/hw/arm/nrf51_soc.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
53 | return; | ||
54 | } | ||
55 | |||
56 | - base_addr = NRF51_TIMER_BASE + i * NRF51_TIMER_SIZE; | ||
57 | + base_addr = NRF51_TIMER_BASE + i * NRF51_PERIPHERAL_SIZE; | ||
58 | |||
59 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->timer[i]), 0, base_addr); | ||
60 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timer[i]), 0, | ||
61 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
62 | |||
63 | /* STUB Peripherals */ | ||
64 | memory_region_init_io(&s->clock, OBJECT(dev_soc), &clock_ops, NULL, | ||
65 | - "nrf51_soc.clock", 0x1000); | ||
66 | + "nrf51_soc.clock", NRF51_PERIPHERAL_SIZE); | ||
67 | memory_region_add_subregion_overlap(&s->container, | ||
68 | NRF51_IOMEM_BASE, &s->clock, -1); | ||
69 | |||
70 | diff --git a/hw/i2c/microbit_i2c.c b/hw/i2c/microbit_i2c.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/hw/i2c/microbit_i2c.c | ||
73 | +++ b/hw/i2c/microbit_i2c.c | ||
74 | @@ -XXX,XX +XXX,XX @@ static void microbit_i2c_realize(DeviceState *dev, Error **errp) | ||
75 | MicrobitI2CState *s = MICROBIT_I2C(dev); | ||
76 | |||
77 | memory_region_init_io(&s->iomem, OBJECT(s), µbit_i2c_ops, s, | ||
78 | - "microbit.twi", NRF51_TWI_SIZE); | ||
79 | + "microbit.twi", NRF51_PERIPHERAL_SIZE); | ||
80 | sysbus_init_mmio(sbd, &s->iomem); | ||
81 | } | ||
82 | |||
83 | diff --git a/hw/timer/nrf51_timer.c b/hw/timer/nrf51_timer.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/hw/timer/nrf51_timer.c | ||
86 | +++ b/hw/timer/nrf51_timer.c | ||
87 | @@ -XXX,XX +XXX,XX @@ static void nrf51_timer_init(Object *obj) | ||
88 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
89 | |||
90 | memory_region_init_io(&s->iomem, obj, &rng_ops, s, | ||
91 | - TYPE_NRF51_TIMER, NRF51_TIMER_SIZE); | ||
92 | + TYPE_NRF51_TIMER, NRF51_PERIPHERAL_SIZE); | ||
93 | sysbus_init_mmio(sbd, &s->iomem); | ||
94 | sysbus_init_irq(sbd, &s->irq); | ||
95 | |||
96 | -- | ||
97 | 2.20.1 | ||
98 | |||
99 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | The NRF51 series SoC have 3 timer peripherals, each having | ||
4 | 4 counters. To help differentiate which peripheral is accessed, | ||
5 | display the timer ID in the trace events. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200504072822.18799-4-f4bug@amsat.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/timer/nrf51_timer.h | 1 + | ||
13 | hw/arm/nrf51_soc.c | 5 +++++ | ||
14 | hw/timer/nrf51_timer.c | 11 +++++++++-- | ||
15 | hw/timer/trace-events | 4 ++-- | ||
16 | 4 files changed, 17 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/include/hw/timer/nrf51_timer.h b/include/hw/timer/nrf51_timer.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/timer/nrf51_timer.h | ||
21 | +++ b/include/hw/timer/nrf51_timer.h | ||
22 | @@ -XXX,XX +XXX,XX @@ typedef struct NRF51TimerState { | ||
23 | MemoryRegion iomem; | ||
24 | qemu_irq irq; | ||
25 | |||
26 | + uint8_t id; | ||
27 | QEMUTimer timer; | ||
28 | int64_t timer_start_ns; | ||
29 | int64_t update_counter_ns; | ||
30 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/hw/arm/nrf51_soc.c | ||
33 | +++ b/hw/arm/nrf51_soc.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
35 | |||
36 | /* TIMER */ | ||
37 | for (i = 0; i < NRF51_NUM_TIMERS; i++) { | ||
38 | + object_property_set_uint(OBJECT(&s->timer[i]), i, "id", &err); | ||
39 | + if (err) { | ||
40 | + error_propagate(errp, err); | ||
41 | + return; | ||
42 | + } | ||
43 | object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err); | ||
44 | if (err) { | ||
45 | error_propagate(errp, err); | ||
46 | diff --git a/hw/timer/nrf51_timer.c b/hw/timer/nrf51_timer.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/timer/nrf51_timer.c | ||
49 | +++ b/hw/timer/nrf51_timer.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | #include "hw/arm/nrf51.h" | ||
52 | #include "hw/irq.h" | ||
53 | #include "hw/timer/nrf51_timer.h" | ||
54 | +#include "hw/qdev-properties.h" | ||
55 | #include "migration/vmstate.h" | ||
56 | #include "trace.h" | ||
57 | |||
58 | @@ -XXX,XX +XXX,XX @@ static uint64_t nrf51_timer_read(void *opaque, hwaddr offset, unsigned int size) | ||
59 | __func__, offset); | ||
60 | } | ||
61 | |||
62 | - trace_nrf51_timer_read(offset, r, size); | ||
63 | + trace_nrf51_timer_read(s->id, offset, r, size); | ||
64 | |||
65 | return r; | ||
66 | } | ||
67 | @@ -XXX,XX +XXX,XX @@ static void nrf51_timer_write(void *opaque, hwaddr offset, | ||
68 | uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
69 | size_t idx; | ||
70 | |||
71 | - trace_nrf51_timer_write(offset, value, size); | ||
72 | + trace_nrf51_timer_write(s->id, offset, value, size); | ||
73 | |||
74 | switch (offset) { | ||
75 | case NRF51_TIMER_TASK_START: | ||
76 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_nrf51_timer = { | ||
77 | } | ||
78 | }; | ||
79 | |||
80 | +static Property nrf51_timer_properties[] = { | ||
81 | + DEFINE_PROP_UINT8("id", NRF51TimerState, id, 0), | ||
82 | + DEFINE_PROP_END_OF_LIST(), | ||
83 | +}; | ||
84 | + | ||
85 | static void nrf51_timer_class_init(ObjectClass *klass, void *data) | ||
86 | { | ||
87 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
88 | |||
89 | dc->reset = nrf51_timer_reset; | ||
90 | dc->vmsd = &vmstate_nrf51_timer; | ||
91 | + device_class_set_props(dc, nrf51_timer_properties); | ||
92 | } | ||
93 | |||
94 | static const TypeInfo nrf51_timer_info = { | ||
95 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/hw/timer/trace-events | ||
98 | +++ b/hw/timer/trace-events | ||
99 | @@ -XXX,XX +XXX,XX @@ cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK | ||
100 | cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" | ||
101 | |||
102 | # nrf51_timer.c | ||
103 | -nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" | ||
104 | -nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" | ||
105 | +nrf51_timer_read(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size) "timer %u read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" | ||
106 | +nrf51_timer_write(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size) "timer %u write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" | ||
107 | |||
108 | # bcm2835_systmr.c | ||
109 | bcm2835_systmr_irq(bool enable) "timer irq state %u" | ||
110 | -- | ||
111 | 2.20.1 | ||
112 | |||
113 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Add trace event to display timer's counter value updates. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200504072822.18799-5-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/timer/nrf51_timer.c | 1 + | ||
11 | hw/timer/trace-events | 1 + | ||
12 | 2 files changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/hw/timer/nrf51_timer.c b/hw/timer/nrf51_timer.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/timer/nrf51_timer.c | ||
17 | +++ b/hw/timer/nrf51_timer.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void nrf51_timer_write(void *opaque, hwaddr offset, | ||
19 | |||
20 | idx = (offset - NRF51_TIMER_TASK_CAPTURE_0) / 4; | ||
21 | s->cc[idx] = s->counter; | ||
22 | + trace_nrf51_timer_set_count(s->id, idx, s->counter); | ||
23 | } | ||
24 | break; | ||
25 | case NRF51_TIMER_EVENT_COMPARE_0 ... NRF51_TIMER_EVENT_COMPARE_3: | ||
26 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/timer/trace-events | ||
29 | +++ b/hw/timer/trace-events | ||
30 | @@ -XXX,XX +XXX,XX @@ cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" | ||
31 | # nrf51_timer.c | ||
32 | nrf51_timer_read(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size) "timer %u read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" | ||
33 | nrf51_timer_write(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size) "timer %u write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" | ||
34 | +nrf51_timer_set_count(uint8_t timer_id, uint8_t counter_id, uint32_t value) "timer %u counter %u count 0x%" PRIx32 | ||
35 | |||
36 | # bcm2835_systmr.c | ||
37 | bcm2835_systmr_irq(bool enable) "timer irq state %u" | ||
38 | -- | ||
39 | 2.20.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20200508154359.7494-4-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/exec/exec-all.h | 17 +++++++++++++++++ | ||
9 | 1 file changed, 17 insertions(+) | ||
10 | |||
11 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/include/exec/exec-all.h | ||
14 | +++ b/include/exec/exec-all.h | ||
15 | @@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
16 | { | ||
17 | } | ||
18 | #endif | ||
19 | +/** | ||
20 | + * probe_access: | ||
21 | + * @env: CPUArchState | ||
22 | + * @addr: guest virtual address to look up | ||
23 | + * @size: size of the access | ||
24 | + * @access_type: read, write or execute permission | ||
25 | + * @mmu_idx: MMU index to use for lookup | ||
26 | + * @retaddr: return address for unwinding | ||
27 | + * | ||
28 | + * Look up the guest virtual address @addr. Raise an exception if the | ||
29 | + * page does not satisfy @access_type. Raise an exception if the | ||
30 | + * access (@addr, @size) hits a watchpoint. For writes, mark a clean | ||
31 | + * page as dirty. | ||
32 | + * | ||
33 | + * Finally, return the host address for a page that is backed by RAM, | ||
34 | + * or NULL if the page requires I/O. | ||
35 | + */ | ||
36 | void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
37 | MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); | ||
38 | |||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20200508154359.7494-18-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/sve_helper.c | 182 ++++++++++++++++++++++++---------------- | ||
9 | 1 file changed, 111 insertions(+), 71 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/sve_helper.c | ||
14 | +++ b/target/arm/sve_helper.c | ||
15 | @@ -XXX,XX +XXX,XX @@ DO_LDFF1_ZPZ_D(dd_be, zd, MO_64) | ||
16 | |||
17 | /* Stores with a vector index. */ | ||
18 | |||
19 | -static void sve_st1_zs(CPUARMState *env, void *vd, void *vg, void *vm, | ||
20 | - target_ulong base, uint32_t desc, uintptr_t ra, | ||
21 | - zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn) | ||
22 | +static inline QEMU_ALWAYS_INLINE | ||
23 | +void sve_st1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
24 | + target_ulong base, uint32_t desc, uintptr_t retaddr, | ||
25 | + int esize, int msize, zreg_off_fn *off_fn, | ||
26 | + sve_ldst1_host_fn *host_fn, | ||
27 | + sve_ldst1_tlb_fn *tlb_fn) | ||
28 | { | ||
29 | const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
30 | - intptr_t i, oprsz = simd_oprsz(desc); | ||
31 | + const int mmu_idx = cpu_mmu_index(env, false); | ||
32 | + const intptr_t reg_max = simd_oprsz(desc); | ||
33 | + void *host[ARM_MAX_VQ * 4]; | ||
34 | + intptr_t reg_off, i; | ||
35 | + SVEHostPage info, info2; | ||
36 | |||
37 | - for (i = 0; i < oprsz; ) { | ||
38 | - uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); | ||
39 | + /* | ||
40 | + * Probe all of the elements for host addresses and flags. | ||
41 | + */ | ||
42 | + i = reg_off = 0; | ||
43 | + do { | ||
44 | + uint64_t pg = vg[reg_off >> 6]; | ||
45 | do { | ||
46 | - if (likely(pg & 1)) { | ||
47 | - target_ulong off = off_fn(vm, i); | ||
48 | - tlb_fn(env, vd, i, base + (off << scale), ra); | ||
49 | + target_ulong addr = base + (off_fn(vm, reg_off) << scale); | ||
50 | + target_ulong in_page = -(addr | TARGET_PAGE_MASK); | ||
51 | + | ||
52 | + host[i] = NULL; | ||
53 | + if (likely((pg >> (reg_off & 63)) & 1)) { | ||
54 | + if (likely(in_page >= msize)) { | ||
55 | + sve_probe_page(&info, false, env, addr, 0, MMU_DATA_STORE, | ||
56 | + mmu_idx, retaddr); | ||
57 | + host[i] = info.host; | ||
58 | + } else { | ||
59 | + /* | ||
60 | + * Element crosses the page boundary. | ||
61 | + * Probe both pages, but do not record the host address, | ||
62 | + * so that we use the slow path. | ||
63 | + */ | ||
64 | + sve_probe_page(&info, false, env, addr, 0, | ||
65 | + MMU_DATA_STORE, mmu_idx, retaddr); | ||
66 | + sve_probe_page(&info2, false, env, addr + in_page, 0, | ||
67 | + MMU_DATA_STORE, mmu_idx, retaddr); | ||
68 | + info.flags |= info2.flags; | ||
69 | + } | ||
70 | + | ||
71 | + if (unlikely(info.flags & TLB_WATCHPOINT)) { | ||
72 | + cpu_check_watchpoint(env_cpu(env), addr, msize, | ||
73 | + info.attrs, BP_MEM_WRITE, retaddr); | ||
74 | + } | ||
75 | + /* TODO: MTE check. */ | ||
76 | } | ||
77 | - i += 4, pg >>= 4; | ||
78 | - } while (i & 15); | ||
79 | - } | ||
80 | -} | ||
81 | + i += 1; | ||
82 | + reg_off += esize; | ||
83 | + } while (reg_off & 63); | ||
84 | + } while (reg_off < reg_max); | ||
85 | |||
86 | -static void sve_st1_zd(CPUARMState *env, void *vd, void *vg, void *vm, | ||
87 | - target_ulong base, uint32_t desc, uintptr_t ra, | ||
88 | - zreg_off_fn *off_fn, sve_ldst1_tlb_fn *tlb_fn) | ||
89 | -{ | ||
90 | - const int scale = extract32(desc, SIMD_DATA_SHIFT + MEMOPIDX_SHIFT, 2); | ||
91 | - intptr_t i, oprsz = simd_oprsz(desc) / 8; | ||
92 | - | ||
93 | - for (i = 0; i < oprsz; i++) { | ||
94 | - uint8_t pg = *(uint8_t *)(vg + H1(i)); | ||
95 | - if (likely(pg & 1)) { | ||
96 | - target_ulong off = off_fn(vm, i * 8); | ||
97 | - tlb_fn(env, vd, i * 8, base + (off << scale), ra); | ||
98 | + /* | ||
99 | + * Now that we have recognized all exceptions except SyncExternal | ||
100 | + * (from TLB_MMIO), which we cannot avoid, perform all of the stores. | ||
101 | + * | ||
102 | + * Note for the common case of an element in RAM, not crossing a page | ||
103 | + * boundary, we have stored the host address in host[]. This doubles | ||
104 | + * as a first-level check against the predicate, since only enabled | ||
105 | + * elements have non-null host addresses. | ||
106 | + */ | ||
107 | + i = reg_off = 0; | ||
108 | + do { | ||
109 | + void *h = host[i]; | ||
110 | + if (likely(h != NULL)) { | ||
111 | + host_fn(vd, reg_off, h); | ||
112 | + } else if ((vg[reg_off >> 6] >> (reg_off & 63)) & 1) { | ||
113 | + target_ulong addr = base + (off_fn(vm, reg_off) << scale); | ||
114 | + tlb_fn(env, vd, reg_off, addr, retaddr); | ||
115 | } | ||
116 | - } | ||
117 | + i += 1; | ||
118 | + reg_off += esize; | ||
119 | + } while (reg_off < reg_max); | ||
120 | } | ||
121 | |||
122 | -#define DO_ST1_ZPZ_S(MEM, OFS) \ | ||
123 | -void QEMU_FLATTEN HELPER(sve_st##MEM##_##OFS) \ | ||
124 | - (CPUARMState *env, void *vd, void *vg, void *vm, \ | ||
125 | - target_ulong base, uint32_t desc) \ | ||
126 | -{ \ | ||
127 | - sve_st1_zs(env, vd, vg, vm, base, desc, GETPC(), \ | ||
128 | - off_##OFS##_s, sve_st1##MEM##_tlb); \ | ||
129 | +#define DO_ST1_ZPZ_S(MEM, OFS, MSZ) \ | ||
130 | +void HELPER(sve_st##MEM##_##OFS)(CPUARMState *env, void *vd, void *vg, \ | ||
131 | + void *vm, target_ulong base, uint32_t desc) \ | ||
132 | +{ \ | ||
133 | + sve_st1_z(env, vd, vg, vm, base, desc, GETPC(), 4, 1 << MSZ, \ | ||
134 | + off_##OFS##_s, sve_st1##MEM##_host, sve_st1##MEM##_tlb); \ | ||
135 | } | ||
136 | |||
137 | -#define DO_ST1_ZPZ_D(MEM, OFS) \ | ||
138 | -void QEMU_FLATTEN HELPER(sve_st##MEM##_##OFS) \ | ||
139 | - (CPUARMState *env, void *vd, void *vg, void *vm, \ | ||
140 | - target_ulong base, uint32_t desc) \ | ||
141 | -{ \ | ||
142 | - sve_st1_zd(env, vd, vg, vm, base, desc, GETPC(), \ | ||
143 | - off_##OFS##_d, sve_st1##MEM##_tlb); \ | ||
144 | +#define DO_ST1_ZPZ_D(MEM, OFS, MSZ) \ | ||
145 | +void HELPER(sve_st##MEM##_##OFS)(CPUARMState *env, void *vd, void *vg, \ | ||
146 | + void *vm, target_ulong base, uint32_t desc) \ | ||
147 | +{ \ | ||
148 | + sve_st1_z(env, vd, vg, vm, base, desc, GETPC(), 8, 1 << MSZ, \ | ||
149 | + off_##OFS##_d, sve_st1##MEM##_host, sve_st1##MEM##_tlb); \ | ||
150 | } | ||
151 | |||
152 | -DO_ST1_ZPZ_S(bs, zsu) | ||
153 | -DO_ST1_ZPZ_S(hs_le, zsu) | ||
154 | -DO_ST1_ZPZ_S(hs_be, zsu) | ||
155 | -DO_ST1_ZPZ_S(ss_le, zsu) | ||
156 | -DO_ST1_ZPZ_S(ss_be, zsu) | ||
157 | +DO_ST1_ZPZ_S(bs, zsu, MO_8) | ||
158 | +DO_ST1_ZPZ_S(hs_le, zsu, MO_16) | ||
159 | +DO_ST1_ZPZ_S(hs_be, zsu, MO_16) | ||
160 | +DO_ST1_ZPZ_S(ss_le, zsu, MO_32) | ||
161 | +DO_ST1_ZPZ_S(ss_be, zsu, MO_32) | ||
162 | |||
163 | -DO_ST1_ZPZ_S(bs, zss) | ||
164 | -DO_ST1_ZPZ_S(hs_le, zss) | ||
165 | -DO_ST1_ZPZ_S(hs_be, zss) | ||
166 | -DO_ST1_ZPZ_S(ss_le, zss) | ||
167 | -DO_ST1_ZPZ_S(ss_be, zss) | ||
168 | +DO_ST1_ZPZ_S(bs, zss, MO_8) | ||
169 | +DO_ST1_ZPZ_S(hs_le, zss, MO_16) | ||
170 | +DO_ST1_ZPZ_S(hs_be, zss, MO_16) | ||
171 | +DO_ST1_ZPZ_S(ss_le, zss, MO_32) | ||
172 | +DO_ST1_ZPZ_S(ss_be, zss, MO_32) | ||
173 | |||
174 | -DO_ST1_ZPZ_D(bd, zsu) | ||
175 | -DO_ST1_ZPZ_D(hd_le, zsu) | ||
176 | -DO_ST1_ZPZ_D(hd_be, zsu) | ||
177 | -DO_ST1_ZPZ_D(sd_le, zsu) | ||
178 | -DO_ST1_ZPZ_D(sd_be, zsu) | ||
179 | -DO_ST1_ZPZ_D(dd_le, zsu) | ||
180 | -DO_ST1_ZPZ_D(dd_be, zsu) | ||
181 | +DO_ST1_ZPZ_D(bd, zsu, MO_8) | ||
182 | +DO_ST1_ZPZ_D(hd_le, zsu, MO_16) | ||
183 | +DO_ST1_ZPZ_D(hd_be, zsu, MO_16) | ||
184 | +DO_ST1_ZPZ_D(sd_le, zsu, MO_32) | ||
185 | +DO_ST1_ZPZ_D(sd_be, zsu, MO_32) | ||
186 | +DO_ST1_ZPZ_D(dd_le, zsu, MO_64) | ||
187 | +DO_ST1_ZPZ_D(dd_be, zsu, MO_64) | ||
188 | |||
189 | -DO_ST1_ZPZ_D(bd, zss) | ||
190 | -DO_ST1_ZPZ_D(hd_le, zss) | ||
191 | -DO_ST1_ZPZ_D(hd_be, zss) | ||
192 | -DO_ST1_ZPZ_D(sd_le, zss) | ||
193 | -DO_ST1_ZPZ_D(sd_be, zss) | ||
194 | -DO_ST1_ZPZ_D(dd_le, zss) | ||
195 | -DO_ST1_ZPZ_D(dd_be, zss) | ||
196 | +DO_ST1_ZPZ_D(bd, zss, MO_8) | ||
197 | +DO_ST1_ZPZ_D(hd_le, zss, MO_16) | ||
198 | +DO_ST1_ZPZ_D(hd_be, zss, MO_16) | ||
199 | +DO_ST1_ZPZ_D(sd_le, zss, MO_32) | ||
200 | +DO_ST1_ZPZ_D(sd_be, zss, MO_32) | ||
201 | +DO_ST1_ZPZ_D(dd_le, zss, MO_64) | ||
202 | +DO_ST1_ZPZ_D(dd_be, zss, MO_64) | ||
203 | |||
204 | -DO_ST1_ZPZ_D(bd, zd) | ||
205 | -DO_ST1_ZPZ_D(hd_le, zd) | ||
206 | -DO_ST1_ZPZ_D(hd_be, zd) | ||
207 | -DO_ST1_ZPZ_D(sd_le, zd) | ||
208 | -DO_ST1_ZPZ_D(sd_be, zd) | ||
209 | -DO_ST1_ZPZ_D(dd_le, zd) | ||
210 | -DO_ST1_ZPZ_D(dd_be, zd) | ||
211 | +DO_ST1_ZPZ_D(bd, zd, MO_8) | ||
212 | +DO_ST1_ZPZ_D(hd_le, zd, MO_16) | ||
213 | +DO_ST1_ZPZ_D(hd_be, zd, MO_16) | ||
214 | +DO_ST1_ZPZ_D(sd_le, zd, MO_32) | ||
215 | +DO_ST1_ZPZ_D(sd_be, zd, MO_32) | ||
216 | +DO_ST1_ZPZ_D(dd_le, zd, MO_64) | ||
217 | +DO_ST1_ZPZ_D(dd_be, zd, MO_64) | ||
218 | |||
219 | #undef DO_ST1_ZPZ_S | ||
220 | #undef DO_ST1_ZPZ_D | ||
221 | -- | ||
222 | 2.20.1 | ||
223 | |||
224 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | We want to move the inlined declarations of set_feature() | ||
4 | from cpu*.c to cpu.h. To avoid clashing with the KVM | ||
5 | declarations, inline the few KVM calls. | ||
6 | |||
7 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20200504172448.9402-2-philmd@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/kvm32.c | 13 ++++--------- | ||
13 | target/arm/kvm64.c | 22 ++++++---------------- | ||
14 | 2 files changed, 10 insertions(+), 25 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/kvm32.c | ||
19 | +++ b/target/arm/kvm32.c | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "internals.h" | ||
22 | #include "qemu/log.h" | ||
23 | |||
24 | -static inline void set_feature(uint64_t *features, int feature) | ||
25 | -{ | ||
26 | - *features |= 1ULL << feature; | ||
27 | -} | ||
28 | - | ||
29 | static int read_sys_reg32(int fd, uint32_t *pret, uint64_t id) | ||
30 | { | ||
31 | struct kvm_one_reg idreg = { .id = id, .addr = (uintptr_t)pret }; | ||
32 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
33 | * timers; this in turn implies most of the other feature | ||
34 | * bits, but a few must be tested. | ||
35 | */ | ||
36 | - set_feature(&features, ARM_FEATURE_V7VE); | ||
37 | - set_feature(&features, ARM_FEATURE_GENERIC_TIMER); | ||
38 | + features |= 1ULL << ARM_FEATURE_V7VE; | ||
39 | + features |= 1ULL << ARM_FEATURE_GENERIC_TIMER; | ||
40 | |||
41 | if (extract32(id_pfr0, 12, 4) == 1) { | ||
42 | - set_feature(&features, ARM_FEATURE_THUMB2EE); | ||
43 | + features |= 1ULL << ARM_FEATURE_THUMB2EE; | ||
44 | } | ||
45 | if (extract32(ahcf->isar.mvfr1, 12, 4) == 1) { | ||
46 | - set_feature(&features, ARM_FEATURE_NEON); | ||
47 | + features |= 1ULL << ARM_FEATURE_NEON; | ||
48 | } | ||
49 | |||
50 | ahcf->features = features; | ||
51 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/kvm64.c | ||
54 | +++ b/target/arm/kvm64.c | ||
55 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq) | ||
56 | } | ||
57 | } | ||
58 | |||
59 | -static inline void set_feature(uint64_t *features, int feature) | ||
60 | -{ | ||
61 | - *features |= 1ULL << feature; | ||
62 | -} | ||
63 | - | ||
64 | -static inline void unset_feature(uint64_t *features, int feature) | ||
65 | -{ | ||
66 | - *features &= ~(1ULL << feature); | ||
67 | -} | ||
68 | - | ||
69 | static int read_sys_reg32(int fd, uint32_t *pret, uint64_t id) | ||
70 | { | ||
71 | uint64_t ret; | ||
72 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
73 | * with VFPv4+Neon; this in turn implies most of the other | ||
74 | * feature bits. | ||
75 | */ | ||
76 | - set_feature(&features, ARM_FEATURE_V8); | ||
77 | - set_feature(&features, ARM_FEATURE_NEON); | ||
78 | - set_feature(&features, ARM_FEATURE_AARCH64); | ||
79 | - set_feature(&features, ARM_FEATURE_PMU); | ||
80 | - set_feature(&features, ARM_FEATURE_GENERIC_TIMER); | ||
81 | + features |= 1ULL << ARM_FEATURE_V8; | ||
82 | + features |= 1ULL << ARM_FEATURE_NEON; | ||
83 | + features |= 1ULL << ARM_FEATURE_AARCH64; | ||
84 | + features |= 1ULL << ARM_FEATURE_PMU; | ||
85 | + features |= 1ULL << ARM_FEATURE_GENERIC_TIMER; | ||
86 | |||
87 | ahcf->features = features; | ||
88 | |||
89 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
90 | if (cpu->has_pmu) { | ||
91 | cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; | ||
92 | } else { | ||
93 | - unset_feature(&env->features, ARM_FEATURE_PMU); | ||
94 | + env->features &= ~(1ULL << ARM_FEATURE_PMU); | ||
95 | } | ||
96 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
97 | assert(kvm_arm_sve_supported(cs)); | ||
98 | -- | ||
99 | 2.20.1 | ||
100 | |||
101 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | I can't find proper documentation or datasheet, but it is likely | ||
4 | a MMIO mapped serial device mapped in the 0x80000000..0x8000ffff | ||
5 | range belongs to the SoC address space, thus is always mapped in | ||
6 | the memory bus. | ||
7 | Map the devices on the bus regardless a chardev is attached to it. | ||
8 | |||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Reviewed-by: Jan Kiszka <jan.kiszka@web.de> | ||
11 | Message-id: 20200505095945.23146-1-f4bug@amsat.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/musicpal.c | 12 ++++-------- | ||
15 | 1 file changed, 4 insertions(+), 8 deletions(-) | ||
16 | |||
17 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/musicpal.c | ||
20 | +++ b/hw/arm/musicpal.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine) | ||
22 | pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ], | ||
23 | pic[MP_TIMER4_IRQ], NULL); | ||
24 | |||
25 | - if (serial_hd(0)) { | ||
26 | - serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ], | ||
27 | - 1825000, serial_hd(0), DEVICE_NATIVE_ENDIAN); | ||
28 | - } | ||
29 | - if (serial_hd(1)) { | ||
30 | - serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ], | ||
31 | - 1825000, serial_hd(1), DEVICE_NATIVE_ENDIAN); | ||
32 | - } | ||
33 | + serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ], | ||
34 | + 1825000, serial_hd(0), DEVICE_NATIVE_ENDIAN); | ||
35 | + serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ], | ||
36 | + 1825000, serial_hd(1), DEVICE_NATIVE_ENDIAN); | ||
37 | |||
38 | /* Register flash */ | ||
39 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
40 | -- | ||
41 | 2.20.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Now that we can pass 7 parameters, do not encode register | ||
4 | operands within simd_data. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200507172352.15418-2-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper-sve.h | 45 +++++++---- | ||
13 | target/arm/sve_helper.c | 157 ++++++++++++++----------------------- | ||
14 | target/arm/translate-sve.c | 70 ++++++----------- | ||
15 | 3 files changed, 114 insertions(+), 158 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper-sve.h | ||
20 | +++ b/target/arm/helper-sve.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_6(sve_fcadd_s, TCG_CALL_NO_RWG, | ||
22 | DEF_HELPER_FLAGS_6(sve_fcadd_d, TCG_CALL_NO_RWG, | ||
23 | void, ptr, ptr, ptr, ptr, ptr, i32) | ||
24 | |||
25 | -DEF_HELPER_FLAGS_3(sve_fmla_zpzzz_h, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
26 | -DEF_HELPER_FLAGS_3(sve_fmla_zpzzz_s, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
27 | -DEF_HELPER_FLAGS_3(sve_fmla_zpzzz_d, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_7(sve_fmla_zpzzz_h, TCG_CALL_NO_RWG, | ||
29 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_7(sve_fmla_zpzzz_s, TCG_CALL_NO_RWG, | ||
31 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_7(sve_fmla_zpzzz_d, TCG_CALL_NO_RWG, | ||
33 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
34 | |||
35 | -DEF_HELPER_FLAGS_3(sve_fmls_zpzzz_h, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
36 | -DEF_HELPER_FLAGS_3(sve_fmls_zpzzz_s, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
37 | -DEF_HELPER_FLAGS_3(sve_fmls_zpzzz_d, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_7(sve_fmls_zpzzz_h, TCG_CALL_NO_RWG, | ||
39 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_7(sve_fmls_zpzzz_s, TCG_CALL_NO_RWG, | ||
41 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
42 | +DEF_HELPER_FLAGS_7(sve_fmls_zpzzz_d, TCG_CALL_NO_RWG, | ||
43 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
44 | |||
45 | -DEF_HELPER_FLAGS_3(sve_fnmla_zpzzz_h, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
46 | -DEF_HELPER_FLAGS_3(sve_fnmla_zpzzz_s, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
47 | -DEF_HELPER_FLAGS_3(sve_fnmla_zpzzz_d, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
48 | +DEF_HELPER_FLAGS_7(sve_fnmla_zpzzz_h, TCG_CALL_NO_RWG, | ||
49 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
50 | +DEF_HELPER_FLAGS_7(sve_fnmla_zpzzz_s, TCG_CALL_NO_RWG, | ||
51 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_7(sve_fnmla_zpzzz_d, TCG_CALL_NO_RWG, | ||
53 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
54 | |||
55 | -DEF_HELPER_FLAGS_3(sve_fnmls_zpzzz_h, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
56 | -DEF_HELPER_FLAGS_3(sve_fnmls_zpzzz_s, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
57 | -DEF_HELPER_FLAGS_3(sve_fnmls_zpzzz_d, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
58 | +DEF_HELPER_FLAGS_7(sve_fnmls_zpzzz_h, TCG_CALL_NO_RWG, | ||
59 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
60 | +DEF_HELPER_FLAGS_7(sve_fnmls_zpzzz_s, TCG_CALL_NO_RWG, | ||
61 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
62 | +DEF_HELPER_FLAGS_7(sve_fnmls_zpzzz_d, TCG_CALL_NO_RWG, | ||
63 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
64 | |||
65 | -DEF_HELPER_FLAGS_3(sve_fcmla_zpzzz_h, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
66 | -DEF_HELPER_FLAGS_3(sve_fcmla_zpzzz_s, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
67 | -DEF_HELPER_FLAGS_3(sve_fcmla_zpzzz_d, TCG_CALL_NO_RWG, void, env, ptr, i32) | ||
68 | +DEF_HELPER_FLAGS_7(sve_fcmla_zpzzz_h, TCG_CALL_NO_RWG, | ||
69 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
70 | +DEF_HELPER_FLAGS_7(sve_fcmla_zpzzz_s, TCG_CALL_NO_RWG, | ||
71 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
72 | +DEF_HELPER_FLAGS_7(sve_fcmla_zpzzz_d, TCG_CALL_NO_RWG, | ||
73 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
74 | |||
75 | DEF_HELPER_FLAGS_5(sve_ftmad_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) | ||
76 | DEF_HELPER_FLAGS_5(sve_ftmad_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) | ||
77 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/sve_helper.c | ||
80 | +++ b/target/arm/sve_helper.c | ||
81 | @@ -XXX,XX +XXX,XX @@ DO_ZPZ_FP(sve_ucvt_dd, uint64_t, , uint64_to_float64) | ||
82 | |||
83 | #undef DO_ZPZ_FP | ||
84 | |||
85 | -/* 4-operand predicated multiply-add. This requires 7 operands to pass | ||
86 | - * "properly", so we need to encode some of the registers into DESC. | ||
87 | - */ | ||
88 | -QEMU_BUILD_BUG_ON(SIMD_DATA_SHIFT + 20 > 32); | ||
89 | - | ||
90 | -static void do_fmla_zpzzz_h(CPUARMState *env, void *vg, uint32_t desc, | ||
91 | +static void do_fmla_zpzzz_h(void *vd, void *vn, void *vm, void *va, void *vg, | ||
92 | + float_status *status, uint32_t desc, | ||
93 | uint16_t neg1, uint16_t neg3) | ||
94 | { | ||
95 | intptr_t i = simd_oprsz(desc); | ||
96 | - unsigned rd = extract32(desc, SIMD_DATA_SHIFT, 5); | ||
97 | - unsigned rn = extract32(desc, SIMD_DATA_SHIFT + 5, 5); | ||
98 | - unsigned rm = extract32(desc, SIMD_DATA_SHIFT + 10, 5); | ||
99 | - unsigned ra = extract32(desc, SIMD_DATA_SHIFT + 15, 5); | ||
100 | - void *vd = &env->vfp.zregs[rd]; | ||
101 | - void *vn = &env->vfp.zregs[rn]; | ||
102 | - void *vm = &env->vfp.zregs[rm]; | ||
103 | - void *va = &env->vfp.zregs[ra]; | ||
104 | uint64_t *g = vg; | ||
105 | |||
106 | do { | ||
107 | @@ -XXX,XX +XXX,XX @@ static void do_fmla_zpzzz_h(CPUARMState *env, void *vg, uint32_t desc, | ||
108 | e1 = *(uint16_t *)(vn + H1_2(i)) ^ neg1; | ||
109 | e2 = *(uint16_t *)(vm + H1_2(i)); | ||
110 | e3 = *(uint16_t *)(va + H1_2(i)) ^ neg3; | ||
111 | - r = float16_muladd(e1, e2, e3, 0, &env->vfp.fp_status_f16); | ||
112 | + r = float16_muladd(e1, e2, e3, 0, status); | ||
113 | *(uint16_t *)(vd + H1_2(i)) = r; | ||
114 | } | ||
115 | } while (i & 63); | ||
116 | } while (i != 0); | ||
117 | } | ||
118 | |||
119 | -void HELPER(sve_fmla_zpzzz_h)(CPUARMState *env, void *vg, uint32_t desc) | ||
120 | +void HELPER(sve_fmla_zpzzz_h)(void *vd, void *vn, void *vm, void *va, | ||
121 | + void *vg, void *status, uint32_t desc) | ||
122 | { | ||
123 | - do_fmla_zpzzz_h(env, vg, desc, 0, 0); | ||
124 | + do_fmla_zpzzz_h(vd, vn, vm, va, vg, status, desc, 0, 0); | ||
125 | } | ||
126 | |||
127 | -void HELPER(sve_fmls_zpzzz_h)(CPUARMState *env, void *vg, uint32_t desc) | ||
128 | +void HELPER(sve_fmls_zpzzz_h)(void *vd, void *vn, void *vm, void *va, | ||
129 | + void *vg, void *status, uint32_t desc) | ||
130 | { | ||
131 | - do_fmla_zpzzz_h(env, vg, desc, 0x8000, 0); | ||
132 | + do_fmla_zpzzz_h(vd, vn, vm, va, vg, status, desc, 0x8000, 0); | ||
133 | } | ||
134 | |||
135 | -void HELPER(sve_fnmla_zpzzz_h)(CPUARMState *env, void *vg, uint32_t desc) | ||
136 | +void HELPER(sve_fnmla_zpzzz_h)(void *vd, void *vn, void *vm, void *va, | ||
137 | + void *vg, void *status, uint32_t desc) | ||
138 | { | ||
139 | - do_fmla_zpzzz_h(env, vg, desc, 0x8000, 0x8000); | ||
140 | + do_fmla_zpzzz_h(vd, vn, vm, va, vg, status, desc, 0x8000, 0x8000); | ||
141 | } | ||
142 | |||
143 | -void HELPER(sve_fnmls_zpzzz_h)(CPUARMState *env, void *vg, uint32_t desc) | ||
144 | +void HELPER(sve_fnmls_zpzzz_h)(void *vd, void *vn, void *vm, void *va, | ||
145 | + void *vg, void *status, uint32_t desc) | ||
146 | { | ||
147 | - do_fmla_zpzzz_h(env, vg, desc, 0, 0x8000); | ||
148 | + do_fmla_zpzzz_h(vd, vn, vm, va, vg, status, desc, 0, 0x8000); | ||
149 | } | ||
150 | |||
151 | -static void do_fmla_zpzzz_s(CPUARMState *env, void *vg, uint32_t desc, | ||
152 | +static void do_fmla_zpzzz_s(void *vd, void *vn, void *vm, void *va, void *vg, | ||
153 | + float_status *status, uint32_t desc, | ||
154 | uint32_t neg1, uint32_t neg3) | ||
155 | { | ||
156 | intptr_t i = simd_oprsz(desc); | ||
157 | - unsigned rd = extract32(desc, SIMD_DATA_SHIFT, 5); | ||
158 | - unsigned rn = extract32(desc, SIMD_DATA_SHIFT + 5, 5); | ||
159 | - unsigned rm = extract32(desc, SIMD_DATA_SHIFT + 10, 5); | ||
160 | - unsigned ra = extract32(desc, SIMD_DATA_SHIFT + 15, 5); | ||
161 | - void *vd = &env->vfp.zregs[rd]; | ||
162 | - void *vn = &env->vfp.zregs[rn]; | ||
163 | - void *vm = &env->vfp.zregs[rm]; | ||
164 | - void *va = &env->vfp.zregs[ra]; | ||
165 | uint64_t *g = vg; | ||
166 | |||
167 | do { | ||
168 | @@ -XXX,XX +XXX,XX @@ static void do_fmla_zpzzz_s(CPUARMState *env, void *vg, uint32_t desc, | ||
169 | e1 = *(uint32_t *)(vn + H1_4(i)) ^ neg1; | ||
170 | e2 = *(uint32_t *)(vm + H1_4(i)); | ||
171 | e3 = *(uint32_t *)(va + H1_4(i)) ^ neg3; | ||
172 | - r = float32_muladd(e1, e2, e3, 0, &env->vfp.fp_status); | ||
173 | + r = float32_muladd(e1, e2, e3, 0, status); | ||
174 | *(uint32_t *)(vd + H1_4(i)) = r; | ||
175 | } | ||
176 | } while (i & 63); | ||
177 | } while (i != 0); | ||
178 | } | ||
179 | |||
180 | -void HELPER(sve_fmla_zpzzz_s)(CPUARMState *env, void *vg, uint32_t desc) | ||
181 | +void HELPER(sve_fmla_zpzzz_s)(void *vd, void *vn, void *vm, void *va, | ||
182 | + void *vg, void *status, uint32_t desc) | ||
183 | { | ||
184 | - do_fmla_zpzzz_s(env, vg, desc, 0, 0); | ||
185 | + do_fmla_zpzzz_s(vd, vn, vm, va, vg, status, desc, 0, 0); | ||
186 | } | ||
187 | |||
188 | -void HELPER(sve_fmls_zpzzz_s)(CPUARMState *env, void *vg, uint32_t desc) | ||
189 | +void HELPER(sve_fmls_zpzzz_s)(void *vd, void *vn, void *vm, void *va, | ||
190 | + void *vg, void *status, uint32_t desc) | ||
191 | { | ||
192 | - do_fmla_zpzzz_s(env, vg, desc, 0x80000000, 0); | ||
193 | + do_fmla_zpzzz_s(vd, vn, vm, va, vg, status, desc, 0x80000000, 0); | ||
194 | } | ||
195 | |||
196 | -void HELPER(sve_fnmla_zpzzz_s)(CPUARMState *env, void *vg, uint32_t desc) | ||
197 | +void HELPER(sve_fnmla_zpzzz_s)(void *vd, void *vn, void *vm, void *va, | ||
198 | + void *vg, void *status, uint32_t desc) | ||
199 | { | ||
200 | - do_fmla_zpzzz_s(env, vg, desc, 0x80000000, 0x80000000); | ||
201 | + do_fmla_zpzzz_s(vd, vn, vm, va, vg, status, desc, 0x80000000, 0x80000000); | ||
202 | } | ||
203 | |||
204 | -void HELPER(sve_fnmls_zpzzz_s)(CPUARMState *env, void *vg, uint32_t desc) | ||
205 | +void HELPER(sve_fnmls_zpzzz_s)(void *vd, void *vn, void *vm, void *va, | ||
206 | + void *vg, void *status, uint32_t desc) | ||
207 | { | ||
208 | - do_fmla_zpzzz_s(env, vg, desc, 0, 0x80000000); | ||
209 | + do_fmla_zpzzz_s(vd, vn, vm, va, vg, status, desc, 0, 0x80000000); | ||
210 | } | ||
211 | |||
212 | -static void do_fmla_zpzzz_d(CPUARMState *env, void *vg, uint32_t desc, | ||
213 | +static void do_fmla_zpzzz_d(void *vd, void *vn, void *vm, void *va, void *vg, | ||
214 | + float_status *status, uint32_t desc, | ||
215 | uint64_t neg1, uint64_t neg3) | ||
216 | { | ||
217 | intptr_t i = simd_oprsz(desc); | ||
218 | - unsigned rd = extract32(desc, SIMD_DATA_SHIFT, 5); | ||
219 | - unsigned rn = extract32(desc, SIMD_DATA_SHIFT + 5, 5); | ||
220 | - unsigned rm = extract32(desc, SIMD_DATA_SHIFT + 10, 5); | ||
221 | - unsigned ra = extract32(desc, SIMD_DATA_SHIFT + 15, 5); | ||
222 | - void *vd = &env->vfp.zregs[rd]; | ||
223 | - void *vn = &env->vfp.zregs[rn]; | ||
224 | - void *vm = &env->vfp.zregs[rm]; | ||
225 | - void *va = &env->vfp.zregs[ra]; | ||
226 | uint64_t *g = vg; | ||
227 | |||
228 | do { | ||
229 | @@ -XXX,XX +XXX,XX @@ static void do_fmla_zpzzz_d(CPUARMState *env, void *vg, uint32_t desc, | ||
230 | e1 = *(uint64_t *)(vn + i) ^ neg1; | ||
231 | e2 = *(uint64_t *)(vm + i); | ||
232 | e3 = *(uint64_t *)(va + i) ^ neg3; | ||
233 | - r = float64_muladd(e1, e2, e3, 0, &env->vfp.fp_status); | ||
234 | + r = float64_muladd(e1, e2, e3, 0, status); | ||
235 | *(uint64_t *)(vd + i) = r; | ||
236 | } | ||
237 | } while (i & 63); | ||
238 | } while (i != 0); | ||
239 | } | ||
240 | |||
241 | -void HELPER(sve_fmla_zpzzz_d)(CPUARMState *env, void *vg, uint32_t desc) | ||
242 | +void HELPER(sve_fmla_zpzzz_d)(void *vd, void *vn, void *vm, void *va, | ||
243 | + void *vg, void *status, uint32_t desc) | ||
244 | { | ||
245 | - do_fmla_zpzzz_d(env, vg, desc, 0, 0); | ||
246 | + do_fmla_zpzzz_d(vd, vn, vm, va, vg, status, desc, 0, 0); | ||
247 | } | ||
248 | |||
249 | -void HELPER(sve_fmls_zpzzz_d)(CPUARMState *env, void *vg, uint32_t desc) | ||
250 | +void HELPER(sve_fmls_zpzzz_d)(void *vd, void *vn, void *vm, void *va, | ||
251 | + void *vg, void *status, uint32_t desc) | ||
252 | { | ||
253 | - do_fmla_zpzzz_d(env, vg, desc, INT64_MIN, 0); | ||
254 | + do_fmla_zpzzz_d(vd, vn, vm, va, vg, status, desc, INT64_MIN, 0); | ||
255 | } | ||
256 | |||
257 | -void HELPER(sve_fnmla_zpzzz_d)(CPUARMState *env, void *vg, uint32_t desc) | ||
258 | +void HELPER(sve_fnmla_zpzzz_d)(void *vd, void *vn, void *vm, void *va, | ||
259 | + void *vg, void *status, uint32_t desc) | ||
260 | { | ||
261 | - do_fmla_zpzzz_d(env, vg, desc, INT64_MIN, INT64_MIN); | ||
262 | + do_fmla_zpzzz_d(vd, vn, vm, va, vg, status, desc, INT64_MIN, INT64_MIN); | ||
263 | } | ||
264 | |||
265 | -void HELPER(sve_fnmls_zpzzz_d)(CPUARMState *env, void *vg, uint32_t desc) | ||
266 | +void HELPER(sve_fnmls_zpzzz_d)(void *vd, void *vn, void *vm, void *va, | ||
267 | + void *vg, void *status, uint32_t desc) | ||
268 | { | ||
269 | - do_fmla_zpzzz_d(env, vg, desc, 0, INT64_MIN); | ||
270 | + do_fmla_zpzzz_d(vd, vn, vm, va, vg, status, desc, 0, INT64_MIN); | ||
271 | } | ||
272 | |||
273 | /* Two operand floating-point comparison controlled by a predicate. | ||
274 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_fcadd_d)(void *vd, void *vn, void *vm, void *vg, | ||
275 | * FP Complex Multiply | ||
276 | */ | ||
277 | |||
278 | -QEMU_BUILD_BUG_ON(SIMD_DATA_SHIFT + 22 > 32); | ||
279 | - | ||
280 | -void HELPER(sve_fcmla_zpzzz_h)(CPUARMState *env, void *vg, uint32_t desc) | ||
281 | +void HELPER(sve_fcmla_zpzzz_h)(void *vd, void *vn, void *vm, void *va, | ||
282 | + void *vg, void *status, uint32_t desc) | ||
283 | { | ||
284 | intptr_t j, i = simd_oprsz(desc); | ||
285 | - unsigned rd = extract32(desc, SIMD_DATA_SHIFT, 5); | ||
286 | - unsigned rn = extract32(desc, SIMD_DATA_SHIFT + 5, 5); | ||
287 | - unsigned rm = extract32(desc, SIMD_DATA_SHIFT + 10, 5); | ||
288 | - unsigned ra = extract32(desc, SIMD_DATA_SHIFT + 15, 5); | ||
289 | - unsigned rot = extract32(desc, SIMD_DATA_SHIFT + 20, 2); | ||
290 | + unsigned rot = simd_data(desc); | ||
291 | bool flip = rot & 1; | ||
292 | float16 neg_imag, neg_real; | ||
293 | - void *vd = &env->vfp.zregs[rd]; | ||
294 | - void *vn = &env->vfp.zregs[rn]; | ||
295 | - void *vm = &env->vfp.zregs[rm]; | ||
296 | - void *va = &env->vfp.zregs[ra]; | ||
297 | uint64_t *g = vg; | ||
298 | |||
299 | neg_imag = float16_set_sign(0, (rot & 2) != 0); | ||
300 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_fcmla_zpzzz_h)(CPUARMState *env, void *vg, uint32_t desc) | ||
301 | |||
302 | if (likely((pg >> (i & 63)) & 1)) { | ||
303 | d = *(float16 *)(va + H1_2(i)); | ||
304 | - d = float16_muladd(e2, e1, d, 0, &env->vfp.fp_status_f16); | ||
305 | + d = float16_muladd(e2, e1, d, 0, status); | ||
306 | *(float16 *)(vd + H1_2(i)) = d; | ||
307 | } | ||
308 | if (likely((pg >> (j & 63)) & 1)) { | ||
309 | d = *(float16 *)(va + H1_2(j)); | ||
310 | - d = float16_muladd(e4, e3, d, 0, &env->vfp.fp_status_f16); | ||
311 | + d = float16_muladd(e4, e3, d, 0, status); | ||
312 | *(float16 *)(vd + H1_2(j)) = d; | ||
313 | } | ||
314 | } while (i & 63); | ||
315 | } while (i != 0); | ||
316 | } | ||
317 | |||
318 | -void HELPER(sve_fcmla_zpzzz_s)(CPUARMState *env, void *vg, uint32_t desc) | ||
319 | +void HELPER(sve_fcmla_zpzzz_s)(void *vd, void *vn, void *vm, void *va, | ||
320 | + void *vg, void *status, uint32_t desc) | ||
321 | { | ||
322 | intptr_t j, i = simd_oprsz(desc); | ||
323 | - unsigned rd = extract32(desc, SIMD_DATA_SHIFT, 5); | ||
324 | - unsigned rn = extract32(desc, SIMD_DATA_SHIFT + 5, 5); | ||
325 | - unsigned rm = extract32(desc, SIMD_DATA_SHIFT + 10, 5); | ||
326 | - unsigned ra = extract32(desc, SIMD_DATA_SHIFT + 15, 5); | ||
327 | - unsigned rot = extract32(desc, SIMD_DATA_SHIFT + 20, 2); | ||
328 | + unsigned rot = simd_data(desc); | ||
329 | bool flip = rot & 1; | ||
330 | float32 neg_imag, neg_real; | ||
331 | - void *vd = &env->vfp.zregs[rd]; | ||
332 | - void *vn = &env->vfp.zregs[rn]; | ||
333 | - void *vm = &env->vfp.zregs[rm]; | ||
334 | - void *va = &env->vfp.zregs[ra]; | ||
335 | uint64_t *g = vg; | ||
336 | |||
337 | neg_imag = float32_set_sign(0, (rot & 2) != 0); | ||
338 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_fcmla_zpzzz_s)(CPUARMState *env, void *vg, uint32_t desc) | ||
339 | |||
340 | if (likely((pg >> (i & 63)) & 1)) { | ||
341 | d = *(float32 *)(va + H1_2(i)); | ||
342 | - d = float32_muladd(e2, e1, d, 0, &env->vfp.fp_status); | ||
343 | + d = float32_muladd(e2, e1, d, 0, status); | ||
344 | *(float32 *)(vd + H1_2(i)) = d; | ||
345 | } | ||
346 | if (likely((pg >> (j & 63)) & 1)) { | ||
347 | d = *(float32 *)(va + H1_2(j)); | ||
348 | - d = float32_muladd(e4, e3, d, 0, &env->vfp.fp_status); | ||
349 | + d = float32_muladd(e4, e3, d, 0, status); | ||
350 | *(float32 *)(vd + H1_2(j)) = d; | ||
351 | } | ||
352 | } while (i & 63); | ||
353 | } while (i != 0); | ||
354 | } | ||
355 | |||
356 | -void HELPER(sve_fcmla_zpzzz_d)(CPUARMState *env, void *vg, uint32_t desc) | ||
357 | +void HELPER(sve_fcmla_zpzzz_d)(void *vd, void *vn, void *vm, void *va, | ||
358 | + void *vg, void *status, uint32_t desc) | ||
359 | { | ||
360 | intptr_t j, i = simd_oprsz(desc); | ||
361 | - unsigned rd = extract32(desc, SIMD_DATA_SHIFT, 5); | ||
362 | - unsigned rn = extract32(desc, SIMD_DATA_SHIFT + 5, 5); | ||
363 | - unsigned rm = extract32(desc, SIMD_DATA_SHIFT + 10, 5); | ||
364 | - unsigned ra = extract32(desc, SIMD_DATA_SHIFT + 15, 5); | ||
365 | - unsigned rot = extract32(desc, SIMD_DATA_SHIFT + 20, 2); | ||
366 | + unsigned rot = simd_data(desc); | ||
367 | bool flip = rot & 1; | ||
368 | float64 neg_imag, neg_real; | ||
369 | - void *vd = &env->vfp.zregs[rd]; | ||
370 | - void *vn = &env->vfp.zregs[rn]; | ||
371 | - void *vm = &env->vfp.zregs[rm]; | ||
372 | - void *va = &env->vfp.zregs[ra]; | ||
373 | uint64_t *g = vg; | ||
374 | |||
375 | neg_imag = float64_set_sign(0, (rot & 2) != 0); | ||
376 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_fcmla_zpzzz_d)(CPUARMState *env, void *vg, uint32_t desc) | ||
377 | |||
378 | if (likely((pg >> (i & 63)) & 1)) { | ||
379 | d = *(float64 *)(va + H1_2(i)); | ||
380 | - d = float64_muladd(e2, e1, d, 0, &env->vfp.fp_status); | ||
381 | + d = float64_muladd(e2, e1, d, 0, status); | ||
382 | *(float64 *)(vd + H1_2(i)) = d; | ||
383 | } | ||
384 | if (likely((pg >> (j & 63)) & 1)) { | ||
385 | d = *(float64 *)(va + H1_2(j)); | ||
386 | - d = float64_muladd(e4, e3, d, 0, &env->vfp.fp_status); | ||
387 | + d = float64_muladd(e4, e3, d, 0, status); | ||
388 | *(float64 *)(vd + H1_2(j)) = d; | ||
389 | } | ||
390 | } while (i & 63); | ||
391 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
392 | index XXXXXXX..XXXXXXX 100644 | ||
393 | --- a/target/arm/translate-sve.c | ||
394 | +++ b/target/arm/translate-sve.c | ||
395 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCADD(DisasContext *s, arg_FCADD *a) | ||
396 | return true; | ||
397 | } | ||
398 | |||
399 | -typedef void gen_helper_sve_fmla(TCGv_env, TCGv_ptr, TCGv_i32); | ||
400 | - | ||
401 | -static bool do_fmla(DisasContext *s, arg_rprrr_esz *a, gen_helper_sve_fmla *fn) | ||
402 | +static bool do_fmla(DisasContext *s, arg_rprrr_esz *a, | ||
403 | + gen_helper_gvec_5_ptr *fn) | ||
404 | { | ||
405 | - if (fn == NULL) { | ||
406 | + if (a->esz == 0) { | ||
407 | return false; | ||
408 | } | ||
409 | - if (!sve_access_check(s)) { | ||
410 | - return true; | ||
411 | + if (sve_access_check(s)) { | ||
412 | + unsigned vsz = vec_full_reg_size(s); | ||
413 | + TCGv_ptr status = get_fpstatus_ptr(a->esz == MO_16); | ||
414 | + tcg_gen_gvec_5_ptr(vec_full_reg_offset(s, a->rd), | ||
415 | + vec_full_reg_offset(s, a->rn), | ||
416 | + vec_full_reg_offset(s, a->rm), | ||
417 | + vec_full_reg_offset(s, a->ra), | ||
418 | + pred_full_reg_offset(s, a->pg), | ||
419 | + status, vsz, vsz, 0, fn); | ||
420 | + tcg_temp_free_ptr(status); | ||
421 | } | ||
422 | - | ||
423 | - unsigned vsz = vec_full_reg_size(s); | ||
424 | - unsigned desc; | ||
425 | - TCGv_i32 t_desc; | ||
426 | - TCGv_ptr pg = tcg_temp_new_ptr(); | ||
427 | - | ||
428 | - /* We would need 7 operands to pass these arguments "properly". | ||
429 | - * So we encode all the register numbers into the descriptor. | ||
430 | - */ | ||
431 | - desc = deposit32(a->rd, 5, 5, a->rn); | ||
432 | - desc = deposit32(desc, 10, 5, a->rm); | ||
433 | - desc = deposit32(desc, 15, 5, a->ra); | ||
434 | - desc = simd_desc(vsz, vsz, desc); | ||
435 | - | ||
436 | - t_desc = tcg_const_i32(desc); | ||
437 | - tcg_gen_addi_ptr(pg, cpu_env, pred_full_reg_offset(s, a->pg)); | ||
438 | - fn(cpu_env, pg, t_desc); | ||
439 | - tcg_temp_free_i32(t_desc); | ||
440 | - tcg_temp_free_ptr(pg); | ||
441 | return true; | ||
442 | } | ||
443 | |||
444 | #define DO_FMLA(NAME, name) \ | ||
445 | static bool trans_##NAME(DisasContext *s, arg_rprrr_esz *a) \ | ||
446 | { \ | ||
447 | - static gen_helper_sve_fmla * const fns[4] = { \ | ||
448 | + static gen_helper_gvec_5_ptr * const fns[4] = { \ | ||
449 | NULL, gen_helper_sve_##name##_h, \ | ||
450 | gen_helper_sve_##name##_s, gen_helper_sve_##name##_d \ | ||
451 | }; \ | ||
452 | @@ -XXX,XX +XXX,XX @@ DO_FMLA(FNMLS_zpzzz, fnmls_zpzzz) | ||
453 | |||
454 | static bool trans_FCMLA_zpzzz(DisasContext *s, arg_FCMLA_zpzzz *a) | ||
455 | { | ||
456 | - static gen_helper_sve_fmla * const fns[3] = { | ||
457 | + static gen_helper_gvec_5_ptr * const fns[4] = { | ||
458 | + NULL, | ||
459 | gen_helper_sve_fcmla_zpzzz_h, | ||
460 | gen_helper_sve_fcmla_zpzzz_s, | ||
461 | gen_helper_sve_fcmla_zpzzz_d, | ||
462 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCMLA_zpzzz(DisasContext *s, arg_FCMLA_zpzzz *a) | ||
463 | } | ||
464 | if (sve_access_check(s)) { | ||
465 | unsigned vsz = vec_full_reg_size(s); | ||
466 | - unsigned desc; | ||
467 | - TCGv_i32 t_desc; | ||
468 | - TCGv_ptr pg = tcg_temp_new_ptr(); | ||
469 | - | ||
470 | - /* We would need 7 operands to pass these arguments "properly". | ||
471 | - * So we encode all the register numbers into the descriptor. | ||
472 | - */ | ||
473 | - desc = deposit32(a->rd, 5, 5, a->rn); | ||
474 | - desc = deposit32(desc, 10, 5, a->rm); | ||
475 | - desc = deposit32(desc, 15, 5, a->ra); | ||
476 | - desc = deposit32(desc, 20, 2, a->rot); | ||
477 | - desc = sextract32(desc, 0, 22); | ||
478 | - desc = simd_desc(vsz, vsz, desc); | ||
479 | - | ||
480 | - t_desc = tcg_const_i32(desc); | ||
481 | - tcg_gen_addi_ptr(pg, cpu_env, pred_full_reg_offset(s, a->pg)); | ||
482 | - fns[a->esz - 1](cpu_env, pg, t_desc); | ||
483 | - tcg_temp_free_i32(t_desc); | ||
484 | - tcg_temp_free_ptr(pg); | ||
485 | + TCGv_ptr status = get_fpstatus_ptr(a->esz == MO_16); | ||
486 | + tcg_gen_gvec_5_ptr(vec_full_reg_offset(s, a->rd), | ||
487 | + vec_full_reg_offset(s, a->rn), | ||
488 | + vec_full_reg_offset(s, a->rm), | ||
489 | + vec_full_reg_offset(s, a->ra), | ||
490 | + pred_full_reg_offset(s, a->pg), | ||
491 | + status, vsz, vsz, a->rot, fns[a->esz]); | ||
492 | + tcg_temp_free_ptr(status); | ||
493 | } | ||
494 | return true; | ||
495 | } | ||
496 | -- | ||
497 | 2.20.1 | ||
498 | |||
499 | diff view generated by jsdifflib |