1 | A largish pull request: the big things are Richard's PAuth work | 1 | Hi; here's the first target-arm pullreq for the 7.0 cycle. |
---|---|---|---|
2 | and Aaron's PMU emulation improvements. | ||
3 | 2 | ||
4 | thanks | 3 | thanks |
5 | -- PMM | 4 | -- PMM |
6 | 5 | ||
6 | The following changes since commit 76b56fdfc9fa43ec6e5986aee33f108c6c6a511e: | ||
7 | 7 | ||
8 | The following changes since commit 681d61362d3f766a00806b89d6581869041f73cb: | 8 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2021-12-14 12:46:18 -0800) |
9 | |||
10 | Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into staging (2019-01-17 12:48:42 +0000) | ||
11 | 9 | ||
12 | are available in the Git repository at: | 10 | are available in the Git repository at: |
13 | 11 | ||
14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190118 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20211215 |
15 | 13 | ||
16 | for you to fetch changes up to 2a0ed2804e2c77a1c4e255f05ab739618e05c85d: | 14 | for you to fetch changes up to aed176558806674d030a8305d989d4e6a5073359: |
17 | 15 | ||
18 | tests/libqtest: Introduce qtest_init_with_serial() (2019-01-18 14:17:38 +0000) | 16 | tests/acpi: add expected blob for VIOT test on virt machine (2021-12-15 10:35:26 +0000) |
19 | 17 | ||
20 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
21 | target-arm queue: | 19 | target-arm queue: |
22 | * hw/char/stm32f2xx_usart: Do not update data register when device is disabled | 20 | * ITS: error reporting cleanup |
23 | * hw/arm/virt-acpi-build: Set COHACC override flag in IORT SMMUv3 node | 21 | * aspeed: improve documentation |
24 | * target/arm: Allow Aarch32 exception return to switch from Mon->Hyp | 22 | * Fix STM32F2XX USART data register readout |
25 | * ftgmac100: implement the new MDIO interface on Aspeed SoC | 23 | * allow emulated GICv3 to be disabled in non-TCG builds |
26 | * implement the ARMv8.3-PAuth extension | 24 | * fix exception priority for singlestep, misaligned PC, bp, etc |
27 | * improve emulation of the ARM PMU | 25 | * Correct calculation of tlb range invalidate length |
26 | * npcm7xx_emc: fix missing queue_flush | ||
27 | * virt: Add VIOT ACPI table for virtio-iommu | ||
28 | * target/i386: Use assert() to sanity-check b1 in SSE decode | ||
29 | * Don't include qemu-common unnecessarily | ||
28 | 30 | ||
29 | ---------------------------------------------------------------- | 31 | ---------------------------------------------------------------- |
30 | Aaron Lindsay (13): | 32 | Alex Bennée (1): |
31 | migration: Add post_save function to VMStateDescription | 33 | hw/intc: clean-up error reporting for failed ITS cmd |
32 | target/arm: Reorganize PMCCNTR accesses | ||
33 | target/arm: Swap PMU values before/after migrations | ||
34 | target/arm: Filter cycle counter based on PMCCFILTR_EL0 | ||
35 | target/arm: Allow AArch32 access for PMCCFILTR | ||
36 | target/arm: Implement PMOVSSET | ||
37 | target/arm: Define FIELDs for ID_DFR0 | ||
38 | target/arm: Make PMCEID[01]_EL0 64 bit registers, add PMCEID[23] | ||
39 | target/arm: Add array for supported PMU events, generate PMCEID[01]_EL0 | ||
40 | target/arm: Finish implementation of PM[X]EVCNTR and PM[X]EVTYPER | ||
41 | target/arm: PMU: Add instruction and cycle events | ||
42 | target/arm: PMU: Set PMCR.N to 4 | ||
43 | target/arm: Implement PMSWINC | ||
44 | 34 | ||
45 | Alexander Graf (1): | 35 | Jean-Philippe Brucker (8): |
46 | target/arm: Allow Aarch32 exception return to switch from Mon->Hyp | 36 | hw/arm/virt-acpi-build: Add VIOT table for virtio-iommu |
37 | hw/arm/virt: Remove device tree restriction for virtio-iommu | ||
38 | hw/arm/virt: Reject instantiation of multiple IOMMUs | ||
39 | hw/arm/virt: Use object_property_set instead of qdev_prop_set | ||
40 | tests/acpi: allow updates of VIOT expected data files | ||
41 | tests/acpi: add test case for VIOT | ||
42 | tests/acpi: add expected blobs for VIOT test on q35 machine | ||
43 | tests/acpi: add expected blob for VIOT test on virt machine | ||
47 | 44 | ||
48 | Cédric Le Goater (1): | 45 | Joel Stanley (4): |
49 | ftgmac100: implement the new MDIO interface on Aspeed SoC | 46 | docs: aspeed: Add new boards |
47 | docs: aspeed: Update OpenBMC image URL | ||
48 | docs: aspeed: Give an example of booting a kernel | ||
49 | docs: aspeed: ADC is now modelled | ||
50 | 50 | ||
51 | Eric Auger (1): | 51 | Olivier Hériveaux (1): |
52 | hw/arm/virt-acpi-build: Set COHACC override flag in IORT SMMUv3 node | 52 | Fix STM32F2XX USART data register readout |
53 | 53 | ||
54 | Julia Suvorova (1): | 54 | Patrick Venture (1): |
55 | tests/libqtest: Introduce qtest_init_with_serial() | 55 | hw/net: npcm7xx_emc fix missing queue_flush |
56 | 56 | ||
57 | Philippe Mathieu-Daudé (1): | 57 | Peter Maydell (6): |
58 | hw/char/stm32f2xx_usart: Do not update data register when device is disabled | 58 | target/i386: Use assert() to sanity-check b1 in SSE decode |
59 | include/hw/i386: Don't include qemu-common.h in .h files | ||
60 | target/hexagon/cpu.h: don't include qemu-common.h | ||
61 | target/rx/cpu.h: Don't include qemu-common.h | ||
62 | hw/arm: Don't include qemu-common.h unnecessarily | ||
63 | target/arm: Correct calculation of tlb range invalidate length | ||
59 | 64 | ||
60 | Richard Henderson (31): | 65 | Philippe Mathieu-Daudé (2): |
61 | target/arm: Add state for the ARMv8.3-PAuth extension | 66 | hw/intc/arm_gicv3: Extract gicv3_set_gicv3state from arm_gicv3_cpuif.c |
62 | target/arm: Add SCTLR bits through ARMv8.5 | 67 | hw/intc/arm_gicv3: Introduce CONFIG_ARM_GIC_TCG Kconfig selector |
63 | target/arm: Add PAuth active bit to tbflags | ||
64 | target/arm: Introduce raise_exception_ra | ||
65 | target/arm: Add PAuth helpers | ||
66 | target/arm: Decode PAuth within system hint space | ||
67 | target/arm: Rearrange decode in disas_data_proc_1src | ||
68 | target/arm: Decode PAuth within disas_data_proc_1src | ||
69 | target/arm: Decode PAuth within disas_data_proc_2src | ||
70 | target/arm: Move helper_exception_return to helper-a64.c | ||
71 | target/arm: Add new_pc argument to helper_exception_return | ||
72 | target/arm: Rearrange decode in disas_uncond_b_reg | ||
73 | target/arm: Decode PAuth within disas_uncond_b_reg | ||
74 | target/arm: Decode Load/store register (pac) | ||
75 | target/arm: Move cpu_mmu_index out of line | ||
76 | target/arm: Introduce arm_mmu_idx | ||
77 | target/arm: Introduce arm_stage1_mmu_idx | ||
78 | target/arm: Create ARMVAParameters and helpers | ||
79 | target/arm: Merge TBFLAG_AA_TB{0, 1} to TBII | ||
80 | target/arm: Export aa64_va_parameters to internals.h | ||
81 | target/arm: Add aa64_va_parameters_both | ||
82 | target/arm: Decode TBID from TCR | ||
83 | target/arm: Reuse aa64_va_parameters for setting tbflags | ||
84 | target/arm: Implement pauth_strip | ||
85 | target/arm: Implement pauth_auth | ||
86 | target/arm: Implement pauth_addpac | ||
87 | target/arm: Implement pauth_computepac | ||
88 | target/arm: Add PAuth system registers | ||
89 | target/arm: Enable PAuth for -cpu max | ||
90 | target/arm: Enable PAuth for user-only | ||
91 | target/arm: Tidy TBI handling in gen_a64_set_pc | ||
92 | 68 | ||
93 | target/arm/Makefile.objs | 1 + | 69 | Richard Henderson (10): |
94 | include/hw/acpi/acpi-defs.h | 2 + | 70 | target/arm: Hoist pc_next to a local variable in aarch64_tr_translate_insn |
95 | include/migration/vmstate.h | 1 + | 71 | target/arm: Hoist pc_next to a local variable in arm_tr_translate_insn |
96 | target/arm/cpu.h | 244 +++++---- | 72 | target/arm: Hoist pc_next to a local variable in thumb_tr_translate_insn |
97 | target/arm/helper-a64.h | 14 + | 73 | target/arm: Split arm_pre_translate_insn |
98 | target/arm/helper.h | 1 - | 74 | target/arm: Advance pc for arch single-step exception |
99 | target/arm/internals.h | 77 +++ | 75 | target/arm: Split compute_fsr_fsc out of arm_deliver_fault |
100 | target/arm/translate.h | 5 +- | 76 | target/arm: Take an exception if PC is misaligned |
101 | tests/libqtest.h | 11 + | 77 | target/arm: Assert thumb pc is aligned |
102 | hw/arm/virt-acpi-build.c | 1 + | 78 | target/arm: Suppress bp for exceptions with more priority |
103 | hw/char/stm32f2xx_usart.c | 3 +- | 79 | tests/tcg: Add arm and aarch64 pc alignment tests |
104 | hw/net/ftgmac100.c | 80 ++- | ||
105 | migration/vmstate.c | 13 +- | ||
106 | target/arm/cpu.c | 19 +- | ||
107 | target/arm/cpu64.c | 68 ++- | ||
108 | target/arm/helper-a64.c | 155 ++++++ | ||
109 | target/arm/helper.c | 1222 +++++++++++++++++++++++++++++++++---------- | ||
110 | target/arm/machine.c | 24 + | ||
111 | target/arm/op_helper.c | 174 +----- | ||
112 | target/arm/pauth_helper.c | 497 ++++++++++++++++++ | ||
113 | target/arm/translate-a64.c | 537 ++++++++++++++++--- | ||
114 | tests/libqtest.c | 26 + | ||
115 | docs/devel/migration.rst | 9 +- | ||
116 | 23 files changed, 2552 insertions(+), 632 deletions(-) | ||
117 | create mode 100644 target/arm/pauth_helper.c | ||
118 | 80 | ||
81 | docs/system/arm/aspeed.rst | 26 ++++++++++++---- | ||
82 | include/hw/i386/microvm.h | 1 - | ||
83 | include/hw/i386/x86.h | 1 - | ||
84 | target/arm/helper.h | 1 + | ||
85 | target/arm/syndrome.h | 5 +++ | ||
86 | target/hexagon/cpu.h | 1 - | ||
87 | target/rx/cpu.h | 1 - | ||
88 | hw/arm/boot.c | 1 - | ||
89 | hw/arm/digic_boards.c | 1 - | ||
90 | hw/arm/highbank.c | 1 - | ||
91 | hw/arm/npcm7xx_boards.c | 1 - | ||
92 | hw/arm/sbsa-ref.c | 1 - | ||
93 | hw/arm/stm32f405_soc.c | 1 - | ||
94 | hw/arm/vexpress.c | 1 - | ||
95 | hw/arm/virt-acpi-build.c | 7 +++++ | ||
96 | hw/arm/virt.c | 21 ++++++------- | ||
97 | hw/char/stm32f2xx_usart.c | 3 +- | ||
98 | hw/intc/arm_gicv3.c | 2 +- | ||
99 | hw/intc/arm_gicv3_cpuif.c | 10 +----- | ||
100 | hw/intc/arm_gicv3_cpuif_common.c | 22 +++++++++++++ | ||
101 | hw/intc/arm_gicv3_its.c | 39 +++++++++++++++-------- | ||
102 | hw/net/npcm7xx_emc.c | 18 +++++------ | ||
103 | hw/virtio/virtio-iommu-pci.c | 12 ++------ | ||
104 | linux-user/aarch64/cpu_loop.c | 46 ++++++++++++++++------------ | ||
105 | linux-user/hexagon/cpu_loop.c | 1 + | ||
106 | target/arm/debug_helper.c | 23 ++++++++++++++ | ||
107 | target/arm/gdbstub.c | 9 ++++-- | ||
108 | target/arm/helper.c | 6 ++-- | ||
109 | target/arm/machine.c | 10 ++++++ | ||
110 | target/arm/tlb_helper.c | 63 ++++++++++++++++++++++++++++---------- | ||
111 | target/arm/translate-a64.c | 23 ++++++++++++-- | ||
112 | target/arm/translate.c | 58 ++++++++++++++++++++++++++--------- | ||
113 | target/i386/tcg/translate.c | 12 ++------ | ||
114 | tests/qtest/bios-tables-test.c | 38 +++++++++++++++++++++++ | ||
115 | tests/tcg/aarch64/pcalign-a64.c | 37 ++++++++++++++++++++++ | ||
116 | tests/tcg/arm/pcalign-a32.c | 46 ++++++++++++++++++++++++++++ | ||
117 | hw/arm/Kconfig | 1 + | ||
118 | hw/intc/Kconfig | 5 +++ | ||
119 | hw/intc/meson.build | 11 ++++--- | ||
120 | tests/data/acpi/q35/DSDT.viot | Bin 0 -> 9398 bytes | ||
121 | tests/data/acpi/q35/VIOT.viot | Bin 0 -> 112 bytes | ||
122 | tests/data/acpi/virt/VIOT | Bin 0 -> 88 bytes | ||
123 | tests/tcg/aarch64/Makefile.target | 4 +-- | ||
124 | tests/tcg/arm/Makefile.target | 4 +++ | ||
125 | 44 files changed, 429 insertions(+), 145 deletions(-) | ||
126 | create mode 100644 hw/intc/arm_gicv3_cpuif_common.c | ||
127 | create mode 100644 tests/tcg/aarch64/pcalign-a64.c | ||
128 | create mode 100644 tests/tcg/arm/pcalign-a32.c | ||
129 | create mode 100644 tests/data/acpi/q35/DSDT.viot | ||
130 | create mode 100644 tests/data/acpi/q35/VIOT.viot | ||
131 | create mode 100644 tests/data/acpi/virt/VIOT | ||
132 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add arrays to hold the registers, the definitions themselves, access | 3 | While trying to debug a GIC ITS failure I saw some guest errors that |
4 | functions, and logic to reset counters when PMCR.P is set. Update | 4 | had poor formatting as well as leaving me confused as to what failed. |
5 | filtering code to support counters other than PMCCNTR. Support migration | 5 | As most of the checks aren't possible without a valid dte split that |
6 | with raw read/write functions. | 6 | check apart and then check the other conditions in steps. This avoids |
7 | us relying on undefined data. | ||
7 | 8 | ||
8 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 9 | I still get a failure with the current kvm-unit-tests but at least I |
9 | Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com> | 10 | know (partially) why now: |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | |
11 | Message-id: 20181211151945.29137-11-aaron@os.amperecomputing.com | 12 | Exception return from AArch64 EL1 to AArch64 EL1 PC 0x40080588 |
13 | PASS: gicv3: its-trigger: inv/invall: dev2/eventid=20 now triggers an LPI | ||
14 | ITS: MAPD devid=2 size = 0x8 itt=0x40430000 valid=0 | ||
15 | INT dev_id=2 event_id=20 | ||
16 | process_its_cmd: invalid command attributes: invalid dte: 0 for 2 (MEM_TX: 0) | ||
17 | PASS: gicv3: its-trigger: mapd valid=false: no LPI after device unmap | ||
18 | SUMMARY: 6 tests, 1 unexpected failures | ||
19 | |||
20 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Message-id: 20211112170454.3158925-1-alex.bennee@linaro.org | ||
23 | Cc: Shashi Mallela <shashi.mallela@linaro.org> | ||
24 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 26 | --- |
14 | target/arm/cpu.h | 3 + | 27 | hw/intc/arm_gicv3_its.c | 39 +++++++++++++++++++++++++++------------ |
15 | target/arm/helper.c | 296 +++++++++++++++++++++++++++++++++++++++++--- | 28 | 1 file changed, 27 insertions(+), 12 deletions(-) |
16 | 2 files changed, 282 insertions(+), 17 deletions(-) | ||
17 | 29 | ||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 30 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c |
19 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/cpu.h | 32 | --- a/hw/intc/arm_gicv3_its.c |
21 | +++ b/target/arm/cpu.h | 33 | +++ b/hw/intc/arm_gicv3_its.c |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 34 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, |
23 | * pmccntr_op_finish. | 35 | if (res != MEMTX_OK) { |
24 | */ | 36 | return result; |
25 | uint64_t c15_ccnt_delta; | 37 | } |
26 | + uint64_t c14_pmevcntr[31]; | 38 | + } else { |
27 | + uint64_t c14_pmevcntr_delta[31]; | 39 | + qemu_log_mask(LOG_GUEST_ERROR, |
28 | + uint64_t c14_pmevtyper[31]; | 40 | + "%s: invalid command attributes: " |
29 | uint64_t pmccfiltr_el0; /* Performance Monitor Filter Register */ | 41 | + "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n", |
30 | uint64_t vpidr_el2; /* Virtualization Processor ID Register */ | 42 | + __func__, dte, devid, res); |
31 | uint64_t vmpidr_el2; /* Virtualization Multiprocessor ID Register */ | 43 | + return result; |
32 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/helper.c | ||
35 | +++ b/target/arm/helper.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
37 | #define PMCRDP 0x10 | ||
38 | #define PMCRD 0x8 | ||
39 | #define PMCRC 0x4 | ||
40 | +#define PMCRP 0x2 | ||
41 | #define PMCRE 0x1 | ||
42 | |||
43 | #define PMXEVTYPER_P 0x80000000 | ||
44 | @@ -XXX,XX +XXX,XX @@ uint64_t get_pmceid(CPUARMState *env, unsigned which) | ||
45 | return pmceid; | ||
46 | } | ||
47 | |||
48 | +/* | ||
49 | + * Check at runtime whether a PMU event is supported for the current machine | ||
50 | + */ | ||
51 | +static bool event_supported(uint16_t number) | ||
52 | +{ | ||
53 | + if (number > MAX_EVENT_ID) { | ||
54 | + return false; | ||
55 | + } | ||
56 | + return supported_event_map[number] != UNSUPPORTED_EVENT; | ||
57 | +} | ||
58 | + | ||
59 | static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
60 | bool isread) | ||
61 | { | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) | ||
63 | prohibited = env->cp15.c9_pmcr & PMCRDP; | ||
64 | } | 44 | } |
65 | 45 | ||
66 | - /* TODO Remove assert, set filter to correct PMEVTYPER */ | 46 | - if ((devid > s->dt.maxids.max_devids) || !dte_valid || !ite_valid || |
67 | - assert(counter == 31); | 47 | - !cte_valid || (eventid > max_eventid)) { |
68 | - filter = env->cp15.pmccfiltr_el0; | ||
69 | + if (counter == 31) { | ||
70 | + filter = env->cp15.pmccfiltr_el0; | ||
71 | + } else { | ||
72 | + filter = env->cp15.c14_pmevtyper[counter]; | ||
73 | + } | ||
74 | |||
75 | p = filter & PMXEVTYPER_P; | ||
76 | u = filter & PMXEVTYPER_U; | ||
77 | @@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) | ||
78 | filtered = m != p; | ||
79 | } | ||
80 | |||
81 | + if (counter != 31) { | ||
82 | + /* | ||
83 | + * If not checking PMCCNTR, ensure the counter is setup to an event we | ||
84 | + * support | ||
85 | + */ | ||
86 | + uint16_t event = filter & PMXEVTYPER_EVTCOUNT; | ||
87 | + if (!event_supported(event)) { | ||
88 | + return false; | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | return enabled && !prohibited && !filtered; | ||
93 | } | ||
94 | |||
95 | @@ -XXX,XX +XXX,XX @@ void pmccntr_op_finish(CPUARMState *env) | ||
96 | } | ||
97 | } | ||
98 | |||
99 | +static void pmevcntr_op_start(CPUARMState *env, uint8_t counter) | ||
100 | +{ | ||
101 | + | ||
102 | + uint16_t event = env->cp15.c14_pmevtyper[counter] & PMXEVTYPER_EVTCOUNT; | ||
103 | + uint64_t count = 0; | ||
104 | + if (event_supported(event)) { | ||
105 | + uint16_t event_idx = supported_event_map[event]; | ||
106 | + count = pm_events[event_idx].get_count(env); | ||
107 | + } | ||
108 | + | ||
109 | + if (pmu_counter_enabled(env, counter)) { | ||
110 | + env->cp15.c14_pmevcntr[counter] = | ||
111 | + count - env->cp15.c14_pmevcntr_delta[counter]; | ||
112 | + } | ||
113 | + env->cp15.c14_pmevcntr_delta[counter] = count; | ||
114 | +} | ||
115 | + | ||
116 | +static void pmevcntr_op_finish(CPUARMState *env, uint8_t counter) | ||
117 | +{ | ||
118 | + if (pmu_counter_enabled(env, counter)) { | ||
119 | + env->cp15.c14_pmevcntr_delta[counter] -= | ||
120 | + env->cp15.c14_pmevcntr[counter]; | ||
121 | + } | ||
122 | +} | ||
123 | + | ||
124 | void pmu_op_start(CPUARMState *env) | ||
125 | { | ||
126 | + unsigned int i; | ||
127 | pmccntr_op_start(env); | ||
128 | + for (i = 0; i < pmu_num_counters(env); i++) { | ||
129 | + pmevcntr_op_start(env, i); | ||
130 | + } | ||
131 | } | ||
132 | |||
133 | void pmu_op_finish(CPUARMState *env) | ||
134 | { | ||
135 | + unsigned int i; | ||
136 | pmccntr_op_finish(env); | ||
137 | + for (i = 0; i < pmu_num_counters(env); i++) { | ||
138 | + pmevcntr_op_finish(env, i); | ||
139 | + } | ||
140 | } | ||
141 | |||
142 | void pmu_pre_el_change(ARMCPU *cpu, void *ignored) | ||
143 | @@ -XXX,XX +XXX,XX @@ static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
144 | env->cp15.c15_ccnt = 0; | ||
145 | } | ||
146 | |||
147 | + if (value & PMCRP) { | ||
148 | + unsigned int i; | ||
149 | + for (i = 0; i < pmu_num_counters(env); i++) { | ||
150 | + env->cp15.c14_pmevcntr[i] = 0; | ||
151 | + } | ||
152 | + } | ||
153 | + | ||
154 | /* only the DP, X, D and E bits are writable */ | ||
155 | env->cp15.c9_pmcr &= ~0x39; | ||
156 | env->cp15.c9_pmcr |= (value & 0x39); | ||
157 | @@ -XXX,XX +XXX,XX @@ void pmccntr_op_finish(CPUARMState *env) | ||
158 | { | ||
159 | } | ||
160 | |||
161 | +void pmevcntr_op_start(CPUARMState *env, uint8_t i) | ||
162 | +{ | ||
163 | +} | ||
164 | + | ||
165 | +void pmevcntr_op_finish(CPUARMState *env, uint8_t i) | ||
166 | +{ | ||
167 | +} | ||
168 | + | ||
169 | void pmu_op_start(CPUARMState *env) | ||
170 | { | ||
171 | } | ||
172 | @@ -XXX,XX +XXX,XX @@ static void pmovsset_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
173 | env->cp15.c9_pmovsr |= value; | ||
174 | } | ||
175 | |||
176 | -static void pmxevtyper_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
177 | - uint64_t value) | ||
178 | +static void pmevtyper_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
179 | + uint64_t value, const uint8_t counter) | ||
180 | { | ||
181 | + if (counter == 31) { | ||
182 | + pmccfiltr_write(env, ri, value); | ||
183 | + } else if (counter < pmu_num_counters(env)) { | ||
184 | + pmevcntr_op_start(env, counter); | ||
185 | + | ||
186 | + /* | ||
187 | + * If this counter's event type is changing, store the current | ||
188 | + * underlying count for the new type in c14_pmevcntr_delta[counter] so | ||
189 | + * pmevcntr_op_finish has the correct baseline when it converts back to | ||
190 | + * a delta. | ||
191 | + */ | ||
192 | + uint16_t old_event = env->cp15.c14_pmevtyper[counter] & | ||
193 | + PMXEVTYPER_EVTCOUNT; | ||
194 | + uint16_t new_event = value & PMXEVTYPER_EVTCOUNT; | ||
195 | + if (old_event != new_event) { | ||
196 | + uint64_t count = 0; | ||
197 | + if (event_supported(new_event)) { | ||
198 | + uint16_t event_idx = supported_event_map[new_event]; | ||
199 | + count = pm_events[event_idx].get_count(env); | ||
200 | + } | ||
201 | + env->cp15.c14_pmevcntr_delta[counter] = count; | ||
202 | + } | ||
203 | + | ||
204 | + env->cp15.c14_pmevtyper[counter] = value & PMXEVTYPER_MASK; | ||
205 | + pmevcntr_op_finish(env, counter); | ||
206 | + } | ||
207 | /* Attempts to access PMXEVTYPER are CONSTRAINED UNPREDICTABLE when | ||
208 | * PMSELR value is equal to or greater than the number of implemented | ||
209 | * counters, but not equal to 0x1f. We opt to behave as a RAZ/WI. | ||
210 | */ | ||
211 | - if (env->cp15.c9_pmselr == 0x1f) { | ||
212 | - pmccfiltr_write(env, ri, value); | ||
213 | +} | ||
214 | + | ||
215 | +static uint64_t pmevtyper_read(CPUARMState *env, const ARMCPRegInfo *ri, | ||
216 | + const uint8_t counter) | ||
217 | +{ | ||
218 | + if (counter == 31) { | ||
219 | + return env->cp15.pmccfiltr_el0; | ||
220 | + } else if (counter < pmu_num_counters(env)) { | ||
221 | + return env->cp15.c14_pmevtyper[counter]; | ||
222 | + } else { | ||
223 | + /* | ||
224 | + * We opt to behave as a RAZ/WI when attempts to access PMXEVTYPER | ||
225 | + * are CONSTRAINED UNPREDICTABLE. See comments in pmevtyper_write(). | ||
226 | + */ | ||
227 | + return 0; | ||
228 | } | ||
229 | } | ||
230 | |||
231 | +static void pmevtyper_writefn(CPUARMState *env, const ARMCPRegInfo *ri, | ||
232 | + uint64_t value) | ||
233 | +{ | ||
234 | + uint8_t counter = ((ri->crm & 3) << 3) | (ri->opc2 & 7); | ||
235 | + pmevtyper_write(env, ri, value, counter); | ||
236 | +} | ||
237 | + | ||
238 | +static void pmevtyper_rawwrite(CPUARMState *env, const ARMCPRegInfo *ri, | ||
239 | + uint64_t value) | ||
240 | +{ | ||
241 | + uint8_t counter = ((ri->crm & 3) << 3) | (ri->opc2 & 7); | ||
242 | + env->cp15.c14_pmevtyper[counter] = value; | ||
243 | + | 48 | + |
244 | + /* | 49 | + /* |
245 | + * pmevtyper_rawwrite is called between a pair of pmu_op_start and | 50 | + * In this implementation, in case of guest errors we ignore the |
246 | + * pmu_op_finish calls when loading saved state for a migration. Because | 51 | + * command and move onto the next command in the queue. |
247 | + * we're potentially updating the type of event here, the value written to | ||
248 | + * c14_pmevcntr_delta by the preceeding pmu_op_start call may be for a | ||
249 | + * different counter type. Therefore, we need to set this value to the | ||
250 | + * current count for the counter type we're writing so that pmu_op_finish | ||
251 | + * has the correct count for its calculation. | ||
252 | + */ | 52 | + */ |
253 | + uint16_t event = value & PMXEVTYPER_EVTCOUNT; | 53 | + if (devid > s->dt.maxids.max_devids) { |
254 | + if (event_supported(event)) { | 54 | qemu_log_mask(LOG_GUEST_ERROR, |
255 | + uint16_t event_idx = supported_event_map[event]; | 55 | - "%s: invalid command attributes " |
256 | + env->cp15.c14_pmevcntr_delta[counter] = | 56 | - "devid %d or eventid %d or invalid dte %d or" |
257 | + pm_events[event_idx].get_count(env); | 57 | - "invalid cte %d or invalid ite %d\n", |
258 | + } | 58 | - __func__, devid, eventid, dte_valid, cte_valid, |
259 | +} | 59 | - ite_valid); |
60 | - /* | ||
61 | - * in this implementation, in case of error | ||
62 | - * we ignore this command and move onto the next | ||
63 | - * command in the queue | ||
64 | - */ | ||
65 | + "%s: invalid command attributes: devid %d>%d", | ||
66 | + __func__, devid, s->dt.maxids.max_devids); | ||
260 | + | 67 | + |
261 | +static uint64_t pmevtyper_readfn(CPUARMState *env, const ARMCPRegInfo *ri) | 68 | + } else if (!dte_valid || !ite_valid || !cte_valid) { |
262 | +{ | 69 | + qemu_log_mask(LOG_GUEST_ERROR, |
263 | + uint8_t counter = ((ri->crm & 3) << 3) | (ri->opc2 & 7); | 70 | + "%s: invalid command attributes: " |
264 | + return pmevtyper_read(env, ri, counter); | 71 | + "dte: %s, ite: %s, cte: %s\n", |
265 | +} | 72 | + __func__, |
266 | + | 73 | + dte_valid ? "valid" : "invalid", |
267 | +static void pmxevtyper_write(CPUARMState *env, const ARMCPRegInfo *ri, | 74 | + ite_valid ? "valid" : "invalid", |
268 | + uint64_t value) | 75 | + cte_valid ? "valid" : "invalid"); |
269 | +{ | 76 | + } else if (eventid > max_eventid) { |
270 | + pmevtyper_write(env, ri, value, env->cp15.c9_pmselr & 31); | 77 | + qemu_log_mask(LOG_GUEST_ERROR, |
271 | +} | 78 | + "%s: invalid command attributes: eventid %d > %d\n", |
272 | + | 79 | + __func__, eventid, max_eventid); |
273 | static uint64_t pmxevtyper_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
274 | { | ||
275 | - /* We opt to behave as a RAZ/WI when attempts to access PMXEVTYPER | ||
276 | - * are CONSTRAINED UNPREDICTABLE. See comments in pmxevtyper_write(). | ||
277 | + return pmevtyper_read(env, ri, env->cp15.c9_pmselr & 31); | ||
278 | +} | ||
279 | + | ||
280 | +static void pmevcntr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
281 | + uint64_t value, uint8_t counter) | ||
282 | +{ | ||
283 | + if (counter < pmu_num_counters(env)) { | ||
284 | + pmevcntr_op_start(env, counter); | ||
285 | + env->cp15.c14_pmevcntr[counter] = value; | ||
286 | + pmevcntr_op_finish(env, counter); | ||
287 | + } | ||
288 | + /* | ||
289 | + * We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR | ||
290 | + * are CONSTRAINED UNPREDICTABLE. | ||
291 | */ | ||
292 | - if (env->cp15.c9_pmselr == 0x1f) { | ||
293 | - return env->cp15.pmccfiltr_el0; | ||
294 | +} | ||
295 | + | ||
296 | +static uint64_t pmevcntr_read(CPUARMState *env, const ARMCPRegInfo *ri, | ||
297 | + uint8_t counter) | ||
298 | +{ | ||
299 | + if (counter < pmu_num_counters(env)) { | ||
300 | + uint64_t ret; | ||
301 | + pmevcntr_op_start(env, counter); | ||
302 | + ret = env->cp15.c14_pmevcntr[counter]; | ||
303 | + pmevcntr_op_finish(env, counter); | ||
304 | + return ret; | ||
305 | } else { | 80 | } else { |
306 | + /* We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR | 81 | /* |
307 | + * are CONSTRAINED UNPREDICTABLE. */ | 82 | * Current implementation only supports rdbase == procnum |
308 | return 0; | ||
309 | } | ||
310 | } | ||
311 | |||
312 | +static void pmevcntr_writefn(CPUARMState *env, const ARMCPRegInfo *ri, | ||
313 | + uint64_t value) | ||
314 | +{ | ||
315 | + uint8_t counter = ((ri->crm & 3) << 3) | (ri->opc2 & 7); | ||
316 | + pmevcntr_write(env, ri, value, counter); | ||
317 | +} | ||
318 | + | ||
319 | +static uint64_t pmevcntr_readfn(CPUARMState *env, const ARMCPRegInfo *ri) | ||
320 | +{ | ||
321 | + uint8_t counter = ((ri->crm & 3) << 3) | (ri->opc2 & 7); | ||
322 | + return pmevcntr_read(env, ri, counter); | ||
323 | +} | ||
324 | + | ||
325 | +static void pmevcntr_rawwrite(CPUARMState *env, const ARMCPRegInfo *ri, | ||
326 | + uint64_t value) | ||
327 | +{ | ||
328 | + uint8_t counter = ((ri->crm & 3) << 3) | (ri->opc2 & 7); | ||
329 | + assert(counter < pmu_num_counters(env)); | ||
330 | + env->cp15.c14_pmevcntr[counter] = value; | ||
331 | + pmevcntr_write(env, ri, value, counter); | ||
332 | +} | ||
333 | + | ||
334 | +static uint64_t pmevcntr_rawread(CPUARMState *env, const ARMCPRegInfo *ri) | ||
335 | +{ | ||
336 | + uint8_t counter = ((ri->crm & 3) << 3) | (ri->opc2 & 7); | ||
337 | + assert(counter < pmu_num_counters(env)); | ||
338 | + return env->cp15.c14_pmevcntr[counter]; | ||
339 | +} | ||
340 | + | ||
341 | +static void pmxevcntr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
342 | + uint64_t value) | ||
343 | +{ | ||
344 | + pmevcntr_write(env, ri, value, env->cp15.c9_pmselr & 31); | ||
345 | +} | ||
346 | + | ||
347 | +static uint64_t pmxevcntr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
348 | +{ | ||
349 | + return pmevcntr_read(env, ri, env->cp15.c9_pmselr & 31); | ||
350 | +} | ||
351 | + | ||
352 | static void pmuserenr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
353 | uint64_t value) | ||
354 | { | ||
355 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
356 | .fieldoffset = offsetof(CPUARMState, cp15.pmccfiltr_el0), | ||
357 | .resetvalue = 0, }, | ||
358 | { .name = "PMXEVTYPER", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 1, | ||
359 | - .access = PL0_RW, .type = ARM_CP_NO_RAW, .accessfn = pmreg_access, | ||
360 | + .access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
361 | + .accessfn = pmreg_access, | ||
362 | .writefn = pmxevtyper_write, .readfn = pmxevtyper_read }, | ||
363 | { .name = "PMXEVTYPER_EL0", .state = ARM_CP_STATE_AA64, | ||
364 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 1, | ||
365 | - .access = PL0_RW, .type = ARM_CP_NO_RAW, .accessfn = pmreg_access, | ||
366 | + .access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
367 | + .accessfn = pmreg_access, | ||
368 | .writefn = pmxevtyper_write, .readfn = pmxevtyper_read }, | ||
369 | - /* Unimplemented, RAZ/WI. */ | ||
370 | { .name = "PMXEVCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 2, | ||
371 | - .access = PL0_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
372 | - .accessfn = pmreg_access_xevcntr }, | ||
373 | + .access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
374 | + .accessfn = pmreg_access_xevcntr, | ||
375 | + .writefn = pmxevcntr_write, .readfn = pmxevcntr_read }, | ||
376 | + { .name = "PMXEVCNTR_EL0", .state = ARM_CP_STATE_AA64, | ||
377 | + .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 2, | ||
378 | + .access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
379 | + .accessfn = pmreg_access_xevcntr, | ||
380 | + .writefn = pmxevcntr_write, .readfn = pmxevcntr_read }, | ||
381 | { .name = "PMUSERENR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 0, | ||
382 | .access = PL0_R | PL1_RW, .accessfn = access_tpm, | ||
383 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmuserenr), | ||
384 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
385 | #endif | ||
386 | /* The only field of MDCR_EL2 that has a defined architectural reset value | ||
387 | * is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N; but we | ||
388 | - * don't impelment any PMU event counters, so using zero as a reset | ||
389 | + * don't implement any PMU event counters, so using zero as a reset | ||
390 | * value for MDCR_EL2 is okay | ||
391 | */ | ||
392 | { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
393 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
394 | * field as main ID register, and we implement only the cycle | ||
395 | * count register. | ||
396 | */ | ||
397 | + unsigned int i, pmcrn = 0; | ||
398 | #ifndef CONFIG_USER_ONLY | ||
399 | ARMCPRegInfo pmcr = { | ||
400 | .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, | ||
401 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
402 | }; | ||
403 | define_one_arm_cp_reg(cpu, &pmcr); | ||
404 | define_one_arm_cp_reg(cpu, &pmcr64); | ||
405 | + for (i = 0; i < pmcrn; i++) { | ||
406 | + char *pmevcntr_name = g_strdup_printf("PMEVCNTR%d", i); | ||
407 | + char *pmevcntr_el0_name = g_strdup_printf("PMEVCNTR%d_EL0", i); | ||
408 | + char *pmevtyper_name = g_strdup_printf("PMEVTYPER%d", i); | ||
409 | + char *pmevtyper_el0_name = g_strdup_printf("PMEVTYPER%d_EL0", i); | ||
410 | + ARMCPRegInfo pmev_regs[] = { | ||
411 | + { .name = pmevcntr_name, .cp = 15, .crn = 15, | ||
412 | + .crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, | ||
413 | + .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
414 | + .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | ||
415 | + .accessfn = pmreg_access }, | ||
416 | + { .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64, | ||
417 | + .opc0 = 3, .opc1 = 3, .crn = 15, .crm = 8 | (3 & (i >> 3)), | ||
418 | + .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, | ||
419 | + .type = ARM_CP_IO, | ||
420 | + .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | ||
421 | + .raw_readfn = pmevcntr_rawread, | ||
422 | + .raw_writefn = pmevcntr_rawwrite }, | ||
423 | + { .name = pmevtyper_name, .cp = 15, .crn = 15, | ||
424 | + .crm = 12 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, | ||
425 | + .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
426 | + .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
427 | + .accessfn = pmreg_access }, | ||
428 | + { .name = pmevtyper_el0_name, .state = ARM_CP_STATE_AA64, | ||
429 | + .opc0 = 3, .opc1 = 3, .crn = 15, .crm = 12 | (3 & (i >> 3)), | ||
430 | + .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, | ||
431 | + .type = ARM_CP_IO, | ||
432 | + .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
433 | + .raw_writefn = pmevtyper_rawwrite }, | ||
434 | + REGINFO_SENTINEL | ||
435 | + }; | ||
436 | + define_arm_cp_regs(cpu, pmev_regs); | ||
437 | + g_free(pmevcntr_name); | ||
438 | + g_free(pmevcntr_el0_name); | ||
439 | + g_free(pmevtyper_name); | ||
440 | + g_free(pmevtyper_el0_name); | ||
441 | + } | ||
442 | #endif | ||
443 | ARMCPRegInfo clidr = { | ||
444 | .name = "CLIDR", .state = ARM_CP_STATE_BOTH, | ||
445 | -- | 83 | -- |
446 | 2.20.1 | 84 | 2.25.1 |
447 | 85 | ||
448 | 86 | diff view generated by jsdifflib |
1 | From: Julia Suvorova <jusual@mail.ru> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Run qtest with a socket that connects QEMU chardev and test code. | 3 | Add X11, FP5280G2, G220A, Rainier and Fuji. Mention that Swift will be |
4 | removed in v7.0. | ||
4 | 5 | ||
5 | Signed-off-by: Julia Suvorova <jusual@mail.ru> | 6 | Signed-off-by: Joel Stanley <joel@jms.id.au> |
6 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
7 | Message-id: 20190117161640.5496-2-jusual@mail.ru | 8 | Message-id: 20211117065752.330632-2-joel@jms.id.au |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | tests/libqtest.h | 11 +++++++++++ | 11 | docs/system/arm/aspeed.rst | 7 ++++++- |
11 | tests/libqtest.c | 26 ++++++++++++++++++++++++++ | 12 | 1 file changed, 6 insertions(+), 1 deletion(-) |
12 | 2 files changed, 37 insertions(+) | ||
13 | 13 | ||
14 | diff --git a/tests/libqtest.h b/tests/libqtest.h | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tests/libqtest.h | 16 | --- a/docs/system/arm/aspeed.rst |
17 | +++ b/tests/libqtest.h | 17 | +++ b/docs/system/arm/aspeed.rst |
18 | @@ -XXX,XX +XXX,XX @@ QTestState *qtest_init(const char *extra_args); | 18 | @@ -XXX,XX +XXX,XX @@ AST2400 SoC based machines : |
19 | */ | 19 | |
20 | QTestState *qtest_init_without_qmp_handshake(const char *extra_args); | 20 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC |
21 | 21 | - ``quanta-q71l-bmc`` OpenBMC Quanta BMC | |
22 | +/** | 22 | +- ``supermicrox11-bmc`` Supermicro X11 BMC |
23 | + * qtest_init_with_serial: | 23 | |
24 | + * @extra_args: other arguments to pass to QEMU. CAUTION: these | 24 | AST2500 SoC based machines : |
25 | + * arguments are subject to word splitting and shell evaluation. | 25 | |
26 | + * @sock_fd: pointer to store the socket file descriptor for | 26 | @@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines : |
27 | + * connection with serial. | 27 | - ``romulus-bmc`` OpenPOWER Romulus POWER9 BMC |
28 | + * | 28 | - ``witherspoon-bmc`` OpenPOWER Witherspoon POWER9 BMC |
29 | + * Returns: #QTestState instance. | 29 | - ``sonorapass-bmc`` OCP SonoraPass BMC |
30 | + */ | 30 | -- ``swift-bmc`` OpenPOWER Swift BMC POWER9 |
31 | +QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd); | 31 | +- ``swift-bmc`` OpenPOWER Swift BMC POWER9 (to be removed in v7.0) |
32 | + | 32 | +- ``fp5280g2-bmc`` Inspur FP5280G2 BMC |
33 | /** | 33 | +- ``g220a-bmc`` Bytedance G220A BMC |
34 | * qtest_quit: | 34 | |
35 | * @s: #QTestState instance to operate on. | 35 | AST2600 SoC based machines : |
36 | diff --git a/tests/libqtest.c b/tests/libqtest.c | 36 | |
37 | index XXXXXXX..XXXXXXX 100644 | 37 | - ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex-A7) |
38 | --- a/tests/libqtest.c | 38 | - ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC |
39 | +++ b/tests/libqtest.c | 39 | +- ``rainier-bmc`` IBM Rainier POWER10 BMC |
40 | @@ -XXX,XX +XXX,XX @@ QTestState *qtest_initf(const char *fmt, ...) | 40 | +- ``fuji-bmc`` Facebook Fuji BMC |
41 | return s; | 41 | |
42 | } | 42 | Supported devices |
43 | 43 | ----------------- | |
44 | +QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd) | ||
45 | +{ | ||
46 | + int sock_fd_init; | ||
47 | + char *sock_path, sock_dir[] = "/tmp/qtest-serial-XXXXXX"; | ||
48 | + QTestState *qts; | ||
49 | + | ||
50 | + g_assert(mkdtemp(sock_dir)); | ||
51 | + sock_path = g_strdup_printf("%s/sock", sock_dir); | ||
52 | + | ||
53 | + sock_fd_init = init_socket(sock_path); | ||
54 | + | ||
55 | + qts = qtest_initf("-chardev socket,id=s0,path=%s,nowait " | ||
56 | + "-serial chardev:s0 %s", | ||
57 | + sock_path, extra_args); | ||
58 | + | ||
59 | + *sock_fd = socket_accept(sock_fd_init); | ||
60 | + | ||
61 | + unlink(sock_path); | ||
62 | + g_free(sock_path); | ||
63 | + rmdir(sock_dir); | ||
64 | + | ||
65 | + g_assert(*sock_fd >= 0); | ||
66 | + | ||
67 | + return qts; | ||
68 | +} | ||
69 | + | ||
70 | void qtest_quit(QTestState *s) | ||
71 | { | ||
72 | g_hook_destroy_link(&abrt_hooks, g_hook_find_data(&abrt_hooks, TRUE, s)); | ||
73 | -- | 44 | -- |
74 | 2.20.1 | 45 | 2.25.1 |
75 | 46 | ||
76 | 47 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 3 | This is the latest URL for the OpenBMC CI. The old URL still works, but |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | redirects. |
5 | Message-id: 20181211151945.29137-14-aaron@os.amperecomputing.com | 5 | |
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
8 | Message-id: 20211117065752.330632-3-joel@jms.id.au | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | target/arm/helper.c | 39 +++++++++++++++++++++++++++++++++++++-- | 11 | docs/system/arm/aspeed.rst | 2 +- |
9 | 1 file changed, 37 insertions(+), 2 deletions(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 13 | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/helper.c | 16 | --- a/docs/system/arm/aspeed.rst |
14 | +++ b/target/arm/helper.c | 17 | +++ b/docs/system/arm/aspeed.rst |
15 | @@ -XXX,XX +XXX,XX @@ static bool event_always_supported(CPUARMState *env) | 18 | @@ -XXX,XX +XXX,XX @@ The Aspeed machines can be started using the ``-kernel`` option to |
16 | return true; | 19 | load a Linux kernel or from a firmware. Images can be downloaded from |
17 | } | 20 | the OpenBMC jenkins : |
18 | 21 | ||
19 | +static uint64_t swinc_get_count(CPUARMState *env) | 22 | - https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/distro=ubuntu,label=docker-builder |
20 | +{ | 23 | + https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/ |
21 | + /* | 24 | |
22 | + * SW_INCR events are written directly to the pmevcntr's by writes to | 25 | or directly from the OpenBMC GitHub release repository : |
23 | + * PMSWINC, so there is no underlying count maintained by the PMU itself | 26 | |
24 | + */ | ||
25 | + return 0; | ||
26 | +} | ||
27 | + | ||
28 | /* | ||
29 | * Return the underlying cycle count for the PMU cycle counters. If we're in | ||
30 | * usermode, simply return 0. | ||
31 | @@ -XXX,XX +XXX,XX @@ static uint64_t instructions_get_count(CPUARMState *env) | ||
32 | #endif | ||
33 | |||
34 | static const pm_event pm_events[] = { | ||
35 | + { .number = 0x000, /* SW_INCR */ | ||
36 | + .supported = event_always_supported, | ||
37 | + .get_count = swinc_get_count, | ||
38 | + }, | ||
39 | #ifndef CONFIG_USER_ONLY | ||
40 | { .number = 0x008, /* INST_RETIRED, Instruction architecturally executed */ | ||
41 | .supported = instructions_supported, | ||
42 | @@ -XXX,XX +XXX,XX @@ static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
43 | pmu_op_finish(env); | ||
44 | } | ||
45 | |||
46 | +static void pmswinc_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
47 | + uint64_t value) | ||
48 | +{ | ||
49 | + unsigned int i; | ||
50 | + for (i = 0; i < pmu_num_counters(env); i++) { | ||
51 | + /* Increment a counter's count iff: */ | ||
52 | + if ((value & (1 << i)) && /* counter's bit is set */ | ||
53 | + /* counter is enabled and not filtered */ | ||
54 | + pmu_counter_enabled(env, i) && | ||
55 | + /* counter is SW_INCR */ | ||
56 | + (env->cp15.c14_pmevtyper[i] & PMXEVTYPER_EVTCOUNT) == 0x0) { | ||
57 | + pmevcntr_op_start(env, i); | ||
58 | + env->cp15.c14_pmevcntr[i]++; | ||
59 | + pmevcntr_op_finish(env, i); | ||
60 | + } | ||
61 | + } | ||
62 | +} | ||
63 | + | ||
64 | static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
65 | { | ||
66 | uint64_t ret; | ||
67 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
68 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), | ||
69 | .writefn = pmovsr_write, | ||
70 | .raw_writefn = raw_write }, | ||
71 | - /* Unimplemented so WI. */ | ||
72 | { .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4, | ||
73 | - .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NOP }, | ||
74 | + .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NO_RAW, | ||
75 | + .writefn = pmswinc_write }, | ||
76 | + { .name = "PMSWINC_EL0", .state = ARM_CP_STATE_AA64, | ||
77 | + .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 4, | ||
78 | + .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NO_RAW, | ||
79 | + .writefn = pmswinc_write }, | ||
80 | { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, | ||
81 | .access = PL0_RW, .type = ARM_CP_ALIAS, | ||
82 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr), | ||
83 | -- | 27 | -- |
84 | 2.20.1 | 28 | 2.25.1 |
85 | 29 | ||
86 | 30 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | This both advertises that we support four counters and enables them | 3 | A common use case for the ASPEED machine is to boot a Linux kernel. |
4 | because the pmu_num_counters() reads this value from PMCR. | 4 | Provide a full example command line. |
5 | 5 | ||
6 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
7 | Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com> | 7 | Signed-off-by: Joel Stanley <joel@jms.id.au> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20211117065752.330632-4-joel@jms.id.au |
9 | Message-id: 20181211151945.29137-13-aaron@os.amperecomputing.com | ||
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/helper.c | 10 +++++----- | 11 | docs/system/arm/aspeed.rst | 15 ++++++++++++--- |
13 | 1 file changed, 5 insertions(+), 5 deletions(-) | 12 | 1 file changed, 12 insertions(+), 3 deletions(-) |
14 | 13 | ||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.c | 16 | --- a/docs/system/arm/aspeed.rst |
18 | +++ b/target/arm/helper.c | 17 | +++ b/docs/system/arm/aspeed.rst |
19 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 18 | @@ -XXX,XX +XXX,XX @@ Missing devices |
20 | .access = PL1_W, .type = ARM_CP_NOP }, | 19 | Boot options |
21 | /* Performance monitors are implementation defined in v7, | 20 | ------------ |
22 | * but with an ARM recommended set of registers, which we | 21 | |
23 | - * follow (although we don't actually implement any counters) | 22 | -The Aspeed machines can be started using the ``-kernel`` option to |
24 | + * follow. | 23 | -load a Linux kernel or from a firmware. Images can be downloaded from |
25 | * | 24 | -the OpenBMC jenkins : |
26 | * Performance registers fall into three categories: | 25 | +The Aspeed machines can be started using the ``-kernel`` and ``-dtb`` options |
27 | * (a) always UNDEF in PL0, RW in PL1 (PMINTENSET, PMINTENCLR) | 26 | +to load a Linux kernel or from a firmware. Images can be downloaded from the |
28 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 27 | +OpenBMC jenkins : |
29 | } | 28 | |
30 | if (arm_feature(env, ARM_FEATURE_V7)) { | 29 | https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/ |
31 | /* v7 performance monitor control register: same implementor | 30 | |
32 | - * field as main ID register, and we implement only the cycle | 31 | @@ -XXX,XX +XXX,XX @@ or directly from the OpenBMC GitHub release repository : |
33 | - * count register. | 32 | |
34 | + * field as main ID register, and we implement four counters in | 33 | https://github.com/openbmc/openbmc/releases |
35 | + * addition to the cycle count register. | 34 | |
36 | */ | 35 | +To boot a kernel directly from a Linux build tree: |
37 | - unsigned int i, pmcrn = 0; | 36 | + |
38 | + unsigned int i, pmcrn = 4; | 37 | +.. code-block:: bash |
39 | ARMCPRegInfo pmcr = { | 38 | + |
40 | .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, | 39 | + $ qemu-system-arm -M ast2600-evb -nographic \ |
41 | .access = PL0_RW, | 40 | + -kernel arch/arm/boot/zImage \ |
42 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 41 | + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ |
43 | .access = PL0_RW, .accessfn = pmreg_access, | 42 | + -initrd rootfs.cpio |
44 | .type = ARM_CP_IO, | 43 | + |
45 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), | 44 | The image should be attached as an MTD drive. Run : |
46 | - .resetvalue = cpu->midr & 0xff000000, | 45 | |
47 | + .resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT), | 46 | .. code-block:: bash |
48 | .writefn = pmcr_write, .raw_writefn = raw_write, | ||
49 | }; | ||
50 | define_one_arm_cp_reg(cpu, &pmcr); | ||
51 | -- | 47 | -- |
52 | 2.20.1 | 48 | 2.25.1 |
53 | 49 | ||
54 | 50 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@suse.de> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | In U-boot, we switch from S-SVC -> Mon -> Hyp mode when we want to | 3 | Move it to the supported list. |
4 | enter Hyp mode. The change into Hyp mode is done by doing an | ||
5 | exception return from Mon. This doesn't work with current QEMU. | ||
6 | 4 | ||
7 | The problem is that in bad_mode_switch() we refuse to allow | 5 | Signed-off-by: Joel Stanley <joel@jms.id.au> |
8 | the change of mode. | 6 | Message-id: 20211117065752.330632-5-joel@jms.id.au |
9 | |||
10 | Note that bad_mode_switch() is used to do validation for two situations: | ||
11 | |||
12 | (1) changes to mode by instructions writing to CPSR.M | ||
13 | (ie not exception take/return) -- this corresponds to the | ||
14 | Armv8 Arm ARM pseudocode Arch32.WriteModeByInstr | ||
15 | (2) changes to mode by exception return | ||
16 | |||
17 | Attempting to enter or leave Hyp mode via case (1) is forbidden in | ||
18 | v8 and UNPREDICTABLE in v7, and QEMU is correct to disallow it | ||
19 | there. However, we're already doing that check at the top of the | ||
20 | bad_mode_switch() function, so if that passes then we should allow | ||
21 | the case (2) exception return mode changes to switch into Hyp mode. | ||
22 | |||
23 | We want to test whether we're trying to return to the nonexistent | ||
24 | "secure Hyp" mode, so we need to look at arm_is_secure_below_el3() | ||
25 | rather than arm_is_secure(), since the latter is always true if | ||
26 | we're in Mon (EL3). | ||
27 | |||
28 | Signed-off-by: Alexander Graf <agraf@suse.de> | ||
29 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
30 | Message-id: 20190109152430.32359-1-agraf@suse.de | ||
31 | [PMM: rewrote commit message] | ||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
33 | --- | 8 | --- |
34 | target/arm/helper.c | 2 +- | 9 | docs/system/arm/aspeed.rst | 2 +- |
35 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
36 | 11 | ||
37 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 12 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
38 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/helper.c | 14 | --- a/docs/system/arm/aspeed.rst |
40 | +++ b/target/arm/helper.c | 15 | +++ b/docs/system/arm/aspeed.rst |
41 | @@ -XXX,XX +XXX,XX @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type) | 16 | @@ -XXX,XX +XXX,XX @@ Supported devices |
42 | return 0; | 17 | * Front LEDs (PCA9552 on I2C bus) |
43 | case ARM_CPU_MODE_HYP: | 18 | * LPC Peripheral Controller (a subset of subdevices are supported) |
44 | return !arm_feature(env, ARM_FEATURE_EL2) | 19 | * Hash/Crypto Engine (HACE) - Hash support only. TODO: HMAC and RSA |
45 | - || arm_current_el(env) < 2 || arm_is_secure(env); | 20 | + * ADC |
46 | + || arm_current_el(env) < 2 || arm_is_secure_below_el3(env); | 21 | |
47 | case ARM_CPU_MODE_MON: | 22 | |
48 | return arm_current_el(env) < 3; | 23 | Missing devices |
49 | default: | 24 | --------------- |
25 | |||
26 | * Coprocessor support | ||
27 | - * ADC (out of tree implementation) | ||
28 | * PWM and Fan Controller | ||
29 | * Slave GPIO Controller | ||
30 | * Super I/O Controller | ||
50 | -- | 31 | -- |
51 | 2.20.1 | 32 | 2.25.1 |
52 | 33 | ||
53 | 34 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Olivier Hériveaux <olivier.heriveaux@ledger.fr> |
---|---|---|---|
2 | 2 | ||
3 | When the device is disabled, the internal circuitry keeps the data | 3 | Fix issue where the data register may be overwritten by next character |
4 | register loaded and doesn't update it. | 4 | reception before being read and returned. |
5 | 5 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Signed-off-by: Olivier Hériveaux <olivier.heriveaux@ledger.fr> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | Message-id: 20190104182057.8778-1-philmd@redhat.com | 9 | Message-id: 20211128120723.4053-1-olivier.heriveaux@ledger.fr |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | hw/char/stm32f2xx_usart.c | 3 +-- | 12 | hw/char/stm32f2xx_usart.c | 3 ++- |
12 | 1 file changed, 1 insertion(+), 2 deletions(-) | 13 | 1 file changed, 2 insertions(+), 1 deletion(-) |
13 | 14 | ||
14 | diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c | 15 | diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/char/stm32f2xx_usart.c | 17 | --- a/hw/char/stm32f2xx_usart.c |
17 | +++ b/hw/char/stm32f2xx_usart.c | 18 | +++ b/hw/char/stm32f2xx_usart.c |
18 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size) | 19 | @@ -XXX,XX +XXX,XX @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr, |
19 | { | 20 | return retvalue; |
20 | STM32F2XXUsartState *s = opaque; | 21 | case USART_DR: |
21 | 22 | DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr); | |
22 | - s->usart_dr = *buf; | 23 | + retvalue = s->usart_dr & 0x3FF; |
23 | - | 24 | s->usart_sr &= ~USART_SR_RXNE; |
24 | if (!(s->usart_cr1 & USART_CR1_UE && s->usart_cr1 & USART_CR1_RE)) { | 25 | qemu_chr_fe_accept_input(&s->chr); |
25 | /* USART not enabled - drop the chars */ | 26 | qemu_set_irq(s->irq, 0); |
26 | DB_PRINT("Dropping the chars\n"); | 27 | - return s->usart_dr & 0x3FF; |
27 | return; | 28 | + return retvalue; |
28 | } | 29 | case USART_BRR: |
29 | 30 | return s->usart_brr; | |
30 | + s->usart_dr = *buf; | 31 | case USART_CR1: |
31 | s->usart_sr |= USART_SR_RXNE; | ||
32 | |||
33 | if (s->usart_cr1 & USART_CR1_RXNEIE) { | ||
34 | -- | 32 | -- |
35 | 2.20.1 | 33 | 2.25.1 |
36 | 34 | ||
37 | 35 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | The cryptographic internals are stubbed out for now, | 3 | gicv3_set_gicv3state() is used by arm_gicv3_common.c in |
4 | but the enable and trap bits are checked. | 4 | arm_gicv3_common_realize(). Since we want to restrict |
5 | arm_gicv3_cpuif.c to TCG, extract gicv3_set_gicv3state() | ||
6 | to a new file. Add this file to the meson 'specific' | ||
7 | source set, since it needs access to "cpu.h". | ||
5 | 8 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20190108223129.5570-6-richard.henderson@linaro.org | 11 | Message-id: 20211115223619.2599282-2-philmd@redhat.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | target/arm/Makefile.objs | 1 + | 14 | hw/intc/arm_gicv3_cpuif.c | 10 +--------- |
12 | target/arm/helper-a64.h | 12 +++ | 15 | hw/intc/arm_gicv3_cpuif_common.c | 22 ++++++++++++++++++++++ |
13 | target/arm/internals.h | 6 ++ | 16 | hw/intc/meson.build | 1 + |
14 | target/arm/pauth_helper.c | 186 ++++++++++++++++++++++++++++++++++++++ | 17 | 3 files changed, 24 insertions(+), 9 deletions(-) |
15 | 4 files changed, 205 insertions(+) | 18 | create mode 100644 hw/intc/arm_gicv3_cpuif_common.c |
16 | create mode 100644 target/arm/pauth_helper.c | ||
17 | 19 | ||
18 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 20 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/Makefile.objs | 22 | --- a/hw/intc/arm_gicv3_cpuif.c |
21 | +++ b/target/arm/Makefile.objs | 23 | +++ b/hw/intc/arm_gicv3_cpuif.c |
22 | @@ -XXX,XX +XXX,XX @@ obj-y += translate.o op_helper.o helper.o cpu.o | 24 | @@ -XXX,XX +XXX,XX @@ |
23 | obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o | 25 | /* |
24 | obj-y += gdbstub.o | 26 | - * ARM Generic Interrupt Controller v3 |
25 | obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o | 27 | + * ARM Generic Interrupt Controller v3 (emulation) |
26 | +obj-$(TARGET_AARCH64) += pauth_helper.o | 28 | * |
27 | obj-y += crypto_helper.o | 29 | * Copyright (c) 2016 Linaro Limited |
28 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | 30 | * Written by Peter Maydell |
29 | 31 | @@ -XXX,XX +XXX,XX @@ | |
30 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | 32 | #include "hw/irq.h" |
31 | index XXXXXXX..XXXXXXX 100644 | 33 | #include "cpu.h" |
32 | --- a/target/arm/helper-a64.h | 34 | |
33 | +++ b/target/arm/helper-a64.h | 35 | -void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) |
34 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(advsimd_rinth, f16, f16, ptr) | 36 | -{ |
35 | DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) | 37 | - ARMCPU *arm_cpu = ARM_CPU(cpu); |
36 | DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) | 38 | - CPUARMState *env = &arm_cpu->env; |
37 | DEF_HELPER_2(sqrt_f16, f16, f16, ptr) | 39 | - |
38 | + | 40 | - env->gicv3state = (void *)s; |
39 | +DEF_HELPER_FLAGS_3(pacia, TCG_CALL_NO_WG, i64, env, i64, i64) | 41 | -}; |
40 | +DEF_HELPER_FLAGS_3(pacib, TCG_CALL_NO_WG, i64, env, i64, i64) | 42 | - |
41 | +DEF_HELPER_FLAGS_3(pacda, TCG_CALL_NO_WG, i64, env, i64, i64) | 43 | static GICv3CPUState *icc_cs_from_env(CPUARMState *env) |
42 | +DEF_HELPER_FLAGS_3(pacdb, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
43 | +DEF_HELPER_FLAGS_3(pacga, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
44 | +DEF_HELPER_FLAGS_3(autia, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
45 | +DEF_HELPER_FLAGS_3(autib, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
46 | +DEF_HELPER_FLAGS_3(autda, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
47 | +DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
48 | +DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) | ||
49 | +DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) | ||
50 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/internals.h | ||
53 | +++ b/target/arm/internals.h | ||
54 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | ||
55 | EC_CP14DTTRAP = 0x06, | ||
56 | EC_ADVSIMDFPACCESSTRAP = 0x07, | ||
57 | EC_FPIDTRAP = 0x08, | ||
58 | + EC_PACTRAP = 0x09, | ||
59 | EC_CP14RRTTRAP = 0x0c, | ||
60 | EC_ILLEGALSTATE = 0x0e, | ||
61 | EC_AA32_SVC = 0x11, | ||
62 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_sve_access_trap(void) | ||
63 | return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT; | ||
64 | } | ||
65 | |||
66 | +static inline uint32_t syn_pactrap(void) | ||
67 | +{ | ||
68 | + return EC_PACTRAP << ARM_EL_EC_SHIFT; | ||
69 | +} | ||
70 | + | ||
71 | static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) | ||
72 | { | 44 | { |
73 | return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT) | 45 | return env->gicv3state; |
74 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | 46 | diff --git a/hw/intc/arm_gicv3_cpuif_common.c b/hw/intc/arm_gicv3_cpuif_common.c |
75 | new file mode 100644 | 47 | new file mode 100644 |
76 | index XXXXXXX..XXXXXXX | 48 | index XXXXXXX..XXXXXXX |
77 | --- /dev/null | 49 | --- /dev/null |
78 | +++ b/target/arm/pauth_helper.c | 50 | +++ b/hw/intc/arm_gicv3_cpuif_common.c |
79 | @@ -XXX,XX +XXX,XX @@ | 51 | @@ -XXX,XX +XXX,XX @@ |
52 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
80 | +/* | 53 | +/* |
81 | + * ARM v8.3-PAuth Operations | 54 | + * ARM Generic Interrupt Controller v3 |
82 | + * | 55 | + * |
83 | + * Copyright (c) 2019 Linaro, Ltd. | 56 | + * Copyright (c) 2016 Linaro Limited |
57 | + * Written by Peter Maydell | ||
84 | + * | 58 | + * |
85 | + * This library is free software; you can redistribute it and/or | 59 | + * This code is licensed under the GPL, version 2 or (at your option) |
86 | + * modify it under the terms of the GNU Lesser General Public | 60 | + * any later version. |
87 | + * License as published by the Free Software Foundation; either | ||
88 | + * version 2 of the License, or (at your option) any later version. | ||
89 | + * | ||
90 | + * This library is distributed in the hope that it will be useful, | ||
91 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
92 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
93 | + * Lesser General Public License for more details. | ||
94 | + * | ||
95 | + * You should have received a copy of the GNU Lesser General Public | ||
96 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
97 | + */ | 61 | + */ |
98 | + | 62 | + |
99 | +#include "qemu/osdep.h" | 63 | +#include "qemu/osdep.h" |
64 | +#include "gicv3_internal.h" | ||
100 | +#include "cpu.h" | 65 | +#include "cpu.h" |
101 | +#include "internals.h" | ||
102 | +#include "exec/exec-all.h" | ||
103 | +#include "exec/cpu_ldst.h" | ||
104 | +#include "exec/helper-proto.h" | ||
105 | +#include "tcg/tcg-gvec-desc.h" | ||
106 | + | 66 | + |
67 | +void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) | ||
68 | +{ | ||
69 | + ARMCPU *arm_cpu = ARM_CPU(cpu); | ||
70 | + CPUARMState *env = &arm_cpu->env; | ||
107 | + | 71 | + |
108 | +static uint64_t pauth_computepac(uint64_t data, uint64_t modifier, | 72 | + env->gicv3state = (void *)s; |
109 | + ARMPACKey key) | 73 | +}; |
110 | +{ | 74 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build |
111 | + g_assert_not_reached(); /* FIXME */ | 75 | index XXXXXXX..XXXXXXX 100644 |
112 | +} | 76 | --- a/hw/intc/meson.build |
113 | + | 77 | +++ b/hw/intc/meson.build |
114 | +static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | 78 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-pmu-iomod-in |
115 | + ARMPACKey *key, bool data) | 79 | |
116 | +{ | 80 | specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) |
117 | + g_assert_not_reached(); /* FIXME */ | 81 | specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) |
118 | +} | 82 | +specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) |
119 | + | 83 | specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif.c')) |
120 | +static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, | 84 | specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c')) |
121 | + ARMPACKey *key, bool data, int keynumber) | 85 | specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: files('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) |
122 | +{ | ||
123 | + g_assert_not_reached(); /* FIXME */ | ||
124 | +} | ||
125 | + | ||
126 | +static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data) | ||
127 | +{ | ||
128 | + g_assert_not_reached(); /* FIXME */ | ||
129 | +} | ||
130 | + | ||
131 | +static void QEMU_NORETURN pauth_trap(CPUARMState *env, int target_el, | ||
132 | + uintptr_t ra) | ||
133 | +{ | ||
134 | + raise_exception_ra(env, EXCP_UDEF, syn_pactrap(), target_el, ra); | ||
135 | +} | ||
136 | + | ||
137 | +static void pauth_check_trap(CPUARMState *env, int el, uintptr_t ra) | ||
138 | +{ | ||
139 | + if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { | ||
140 | + uint64_t hcr = arm_hcr_el2_eff(env); | ||
141 | + bool trap = !(hcr & HCR_API); | ||
142 | + /* FIXME: ARMv8.1-VHE: trap only applies to EL1&0 regime. */ | ||
143 | + /* FIXME: ARMv8.3-NV: HCR_NV trap takes precedence for ERETA[AB]. */ | ||
144 | + if (trap) { | ||
145 | + pauth_trap(env, 2, ra); | ||
146 | + } | ||
147 | + } | ||
148 | + if (el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { | ||
149 | + if (!(env->cp15.scr_el3 & SCR_API)) { | ||
150 | + pauth_trap(env, 3, ra); | ||
151 | + } | ||
152 | + } | ||
153 | +} | ||
154 | + | ||
155 | +static bool pauth_key_enabled(CPUARMState *env, int el, uint32_t bit) | ||
156 | +{ | ||
157 | + uint32_t sctlr; | ||
158 | + if (el == 0) { | ||
159 | + /* FIXME: ARMv8.1-VHE S2 translation regime. */ | ||
160 | + sctlr = env->cp15.sctlr_el[1]; | ||
161 | + } else { | ||
162 | + sctlr = env->cp15.sctlr_el[el]; | ||
163 | + } | ||
164 | + return (sctlr & bit) != 0; | ||
165 | +} | ||
166 | + | ||
167 | +uint64_t HELPER(pacia)(CPUARMState *env, uint64_t x, uint64_t y) | ||
168 | +{ | ||
169 | + int el = arm_current_el(env); | ||
170 | + if (!pauth_key_enabled(env, el, SCTLR_EnIA)) { | ||
171 | + return x; | ||
172 | + } | ||
173 | + pauth_check_trap(env, el, GETPC()); | ||
174 | + return pauth_addpac(env, x, y, &env->apia_key, false); | ||
175 | +} | ||
176 | + | ||
177 | +uint64_t HELPER(pacib)(CPUARMState *env, uint64_t x, uint64_t y) | ||
178 | +{ | ||
179 | + int el = arm_current_el(env); | ||
180 | + if (!pauth_key_enabled(env, el, SCTLR_EnIB)) { | ||
181 | + return x; | ||
182 | + } | ||
183 | + pauth_check_trap(env, el, GETPC()); | ||
184 | + return pauth_addpac(env, x, y, &env->apib_key, false); | ||
185 | +} | ||
186 | + | ||
187 | +uint64_t HELPER(pacda)(CPUARMState *env, uint64_t x, uint64_t y) | ||
188 | +{ | ||
189 | + int el = arm_current_el(env); | ||
190 | + if (!pauth_key_enabled(env, el, SCTLR_EnDA)) { | ||
191 | + return x; | ||
192 | + } | ||
193 | + pauth_check_trap(env, el, GETPC()); | ||
194 | + return pauth_addpac(env, x, y, &env->apda_key, true); | ||
195 | +} | ||
196 | + | ||
197 | +uint64_t HELPER(pacdb)(CPUARMState *env, uint64_t x, uint64_t y) | ||
198 | +{ | ||
199 | + int el = arm_current_el(env); | ||
200 | + if (!pauth_key_enabled(env, el, SCTLR_EnDB)) { | ||
201 | + return x; | ||
202 | + } | ||
203 | + pauth_check_trap(env, el, GETPC()); | ||
204 | + return pauth_addpac(env, x, y, &env->apdb_key, true); | ||
205 | +} | ||
206 | + | ||
207 | +uint64_t HELPER(pacga)(CPUARMState *env, uint64_t x, uint64_t y) | ||
208 | +{ | ||
209 | + uint64_t pac; | ||
210 | + | ||
211 | + pauth_check_trap(env, arm_current_el(env), GETPC()); | ||
212 | + pac = pauth_computepac(x, y, env->apga_key); | ||
213 | + | ||
214 | + return pac & 0xffffffff00000000ull; | ||
215 | +} | ||
216 | + | ||
217 | +uint64_t HELPER(autia)(CPUARMState *env, uint64_t x, uint64_t y) | ||
218 | +{ | ||
219 | + int el = arm_current_el(env); | ||
220 | + if (!pauth_key_enabled(env, el, SCTLR_EnIA)) { | ||
221 | + return x; | ||
222 | + } | ||
223 | + pauth_check_trap(env, el, GETPC()); | ||
224 | + return pauth_auth(env, x, y, &env->apia_key, false, 0); | ||
225 | +} | ||
226 | + | ||
227 | +uint64_t HELPER(autib)(CPUARMState *env, uint64_t x, uint64_t y) | ||
228 | +{ | ||
229 | + int el = arm_current_el(env); | ||
230 | + if (!pauth_key_enabled(env, el, SCTLR_EnIB)) { | ||
231 | + return x; | ||
232 | + } | ||
233 | + pauth_check_trap(env, el, GETPC()); | ||
234 | + return pauth_auth(env, x, y, &env->apib_key, false, 1); | ||
235 | +} | ||
236 | + | ||
237 | +uint64_t HELPER(autda)(CPUARMState *env, uint64_t x, uint64_t y) | ||
238 | +{ | ||
239 | + int el = arm_current_el(env); | ||
240 | + if (!pauth_key_enabled(env, el, SCTLR_EnDA)) { | ||
241 | + return x; | ||
242 | + } | ||
243 | + pauth_check_trap(env, el, GETPC()); | ||
244 | + return pauth_auth(env, x, y, &env->apda_key, true, 0); | ||
245 | +} | ||
246 | + | ||
247 | +uint64_t HELPER(autdb)(CPUARMState *env, uint64_t x, uint64_t y) | ||
248 | +{ | ||
249 | + int el = arm_current_el(env); | ||
250 | + if (!pauth_key_enabled(env, el, SCTLR_EnDB)) { | ||
251 | + return x; | ||
252 | + } | ||
253 | + pauth_check_trap(env, el, GETPC()); | ||
254 | + return pauth_auth(env, x, y, &env->apdb_key, true, 1); | ||
255 | +} | ||
256 | + | ||
257 | +uint64_t HELPER(xpaci)(CPUARMState *env, uint64_t a) | ||
258 | +{ | ||
259 | + return pauth_strip(env, a, false); | ||
260 | +} | ||
261 | + | ||
262 | +uint64_t HELPER(xpacd)(CPUARMState *env, uint64_t a) | ||
263 | +{ | ||
264 | + return pauth_strip(env, a, true); | ||
265 | +} | ||
266 | -- | 86 | -- |
267 | 2.20.1 | 87 | 2.25.1 |
268 | 88 | ||
269 | 89 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | The instruction event is only enabled when icount is used, cycles are | 3 | The TYPE_ARM_GICV3 device is an emulated one. When using |
4 | always supported. Always defining get_cycle_count (but altering its | 4 | KVM, it is recommended to use the TYPE_KVM_ARM_GICV3 device |
5 | behavior depending on CONFIG_USER_ONLY) allows us to remove some | 5 | (which uses in-kernel support). |
6 | CONFIG_USER_ONLY #defines throughout the rest of the code. | ||
7 | 6 | ||
8 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 7 | When using --with-devices-FOO, it is possible to build a |
9 | Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com> | 8 | binary with a specific set of devices. When this binary is |
9 | restricted to KVM accelerator, the TYPE_ARM_GICV3 device is | ||
10 | irrelevant, and it is desirable to remove it from the binary. | ||
11 | |||
12 | Therefore introduce the CONFIG_ARM_GIC_TCG Kconfig selector | ||
13 | which select the files required to have the TYPE_ARM_GICV3 | ||
14 | device, but also allowing to de-select this device. | ||
15 | |||
16 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20181211151945.29137-12-aaron@os.amperecomputing.com | 18 | Message-id: 20211115223619.2599282-3-philmd@redhat.com |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 20 | --- |
14 | target/arm/helper.c | 90 ++++++++++++++++++++++----------------------- | 21 | hw/intc/arm_gicv3.c | 2 +- |
15 | 1 file changed, 44 insertions(+), 46 deletions(-) | 22 | hw/intc/Kconfig | 5 +++++ |
23 | hw/intc/meson.build | 10 ++++++---- | ||
24 | 3 files changed, 12 insertions(+), 5 deletions(-) | ||
16 | 25 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 26 | diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c |
18 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 28 | --- a/hw/intc/arm_gicv3.c |
20 | +++ b/target/arm/helper.c | 29 | +++ b/hw/intc/arm_gicv3.c |
21 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ |
22 | #include "arm_ldst.h" | 31 | /* |
23 | #include <zlib.h> /* For crc32 */ | 32 | - * ARM Generic Interrupt Controller v3 |
24 | #include "exec/semihost.h" | 33 | + * ARM Generic Interrupt Controller v3 (emulation) |
25 | +#include "sysemu/cpus.h" | 34 | * |
26 | #include "sysemu/kvm.h" | 35 | * Copyright (c) 2015 Huawei. |
27 | #include "fpu/softfloat.h" | 36 | * Copyright (c) 2016 Linaro Limited |
28 | #include "qemu/range.h" | 37 | diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct pm_event { | 38 | index XXXXXXX..XXXXXXX 100644 |
30 | uint64_t (*get_count)(CPUARMState *); | 39 | --- a/hw/intc/Kconfig |
31 | } pm_event; | 40 | +++ b/hw/intc/Kconfig |
32 | 41 | @@ -XXX,XX +XXX,XX @@ config APIC | |
33 | +static bool event_always_supported(CPUARMState *env) | 42 | select MSI_NONBROKEN |
34 | +{ | 43 | select I8259 |
35 | + return true; | 44 | |
36 | +} | 45 | +config ARM_GIC_TCG |
46 | + bool | ||
47 | + default y | ||
48 | + depends on ARM_GIC && TCG | ||
37 | + | 49 | + |
38 | +/* | 50 | config ARM_GIC_KVM |
39 | + * Return the underlying cycle count for the PMU cycle counters. If we're in | 51 | bool |
40 | + * usermode, simply return 0. | 52 | default y |
41 | + */ | 53 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build |
42 | +static uint64_t cycles_get_count(CPUARMState *env) | 54 | index XXXXXXX..XXXXXXX 100644 |
43 | +{ | 55 | --- a/hw/intc/meson.build |
44 | +#ifndef CONFIG_USER_ONLY | 56 | +++ b/hw/intc/meson.build |
45 | + return muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), | 57 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARM_GIC', if_true: files( |
46 | + ARM_CPU_FREQ, NANOSECONDS_PER_SECOND); | 58 | 'arm_gic.c', |
47 | +#else | 59 | 'arm_gic_common.c', |
48 | + return cpu_get_host_ticks(); | 60 | 'arm_gicv2m.c', |
49 | +#endif | 61 | - 'arm_gicv3.c', |
50 | +} | 62 | 'arm_gicv3_common.c', |
51 | + | 63 | - 'arm_gicv3_dist.c', |
52 | +#ifndef CONFIG_USER_ONLY | 64 | 'arm_gicv3_its_common.c', |
53 | +static bool instructions_supported(CPUARMState *env) | 65 | - 'arm_gicv3_redist.c', |
54 | +{ | 66 | +)) |
55 | + return use_icount == 1 /* Precise instruction counting */; | 67 | +softmmu_ss.add(when: 'CONFIG_ARM_GIC_TCG', if_true: files( |
56 | +} | 68 | + 'arm_gicv3.c', |
57 | + | 69 | + 'arm_gicv3_dist.c', |
58 | +static uint64_t instructions_get_count(CPUARMState *env) | 70 | 'arm_gicv3_its.c', |
59 | +{ | 71 | + 'arm_gicv3_redist.c', |
60 | + return (uint64_t)cpu_get_icount_raw(); | 72 | )) |
61 | +} | 73 | softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_pic.c')) |
62 | +#endif | 74 | softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true: files('heathrow_pic.c')) |
63 | + | 75 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-pmu-iomod-in |
64 | static const pm_event pm_events[] = { | 76 | specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) |
65 | +#ifndef CONFIG_USER_ONLY | 77 | specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) |
66 | + { .number = 0x008, /* INST_RETIRED, Instruction architecturally executed */ | 78 | specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) |
67 | + .supported = instructions_supported, | 79 | -specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif.c')) |
68 | + .get_count = instructions_get_count, | 80 | +specific_ss.add(when: 'CONFIG_ARM_GIC_TCG', if_true: files('arm_gicv3_cpuif.c')) |
69 | + }, | 81 | specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c')) |
70 | + { .number = 0x011, /* CPU_CYCLES, Cycle */ | 82 | specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: files('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) |
71 | + .supported = event_always_supported, | 83 | specific_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c')) |
72 | + .get_count = cycles_get_count, | ||
73 | + } | ||
74 | +#endif | ||
75 | }; | ||
76 | |||
77 | /* | ||
78 | @@ -XXX,XX +XXX,XX @@ static const pm_event pm_events[] = { | ||
79 | * should first be updated to something sparse instead of the current | ||
80 | * supported_event_map[] array. | ||
81 | */ | ||
82 | -#define MAX_EVENT_ID 0x0 | ||
83 | +#define MAX_EVENT_ID 0x11 | ||
84 | #define UNSUPPORTED_EVENT UINT16_MAX | ||
85 | static uint16_t supported_event_map[MAX_EVENT_ID + 1]; | ||
86 | |||
87 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult pmreg_access_swinc(CPUARMState *env, | ||
88 | return pmreg_access(env, ri, isread); | ||
89 | } | ||
90 | |||
91 | -#ifndef CONFIG_USER_ONLY | ||
92 | - | ||
93 | static CPAccessResult pmreg_access_selr(CPUARMState *env, | ||
94 | const ARMCPRegInfo *ri, | ||
95 | bool isread) | ||
96 | @@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) | ||
97 | */ | ||
98 | void pmccntr_op_start(CPUARMState *env) | ||
99 | { | ||
100 | - uint64_t cycles = 0; | ||
101 | - cycles = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), | ||
102 | - ARM_CPU_FREQ, NANOSECONDS_PER_SECOND); | ||
103 | + uint64_t cycles = cycles_get_count(env); | ||
104 | |||
105 | if (pmu_counter_enabled(env, 31)) { | ||
106 | uint64_t eff_cycles = cycles; | ||
107 | @@ -XXX,XX +XXX,XX @@ static void pmccntr_write32(CPUARMState *env, const ARMCPRegInfo *ri, | ||
108 | pmccntr_write(env, ri, deposit64(cur_val, 0, 32, value)); | ||
109 | } | ||
110 | |||
111 | -#else /* CONFIG_USER_ONLY */ | ||
112 | - | ||
113 | -void pmccntr_op_start(CPUARMState *env) | ||
114 | -{ | ||
115 | -} | ||
116 | - | ||
117 | -void pmccntr_op_finish(CPUARMState *env) | ||
118 | -{ | ||
119 | -} | ||
120 | - | ||
121 | -void pmevcntr_op_start(CPUARMState *env, uint8_t i) | ||
122 | -{ | ||
123 | -} | ||
124 | - | ||
125 | -void pmevcntr_op_finish(CPUARMState *env, uint8_t i) | ||
126 | -{ | ||
127 | -} | ||
128 | - | ||
129 | -void pmu_op_start(CPUARMState *env) | ||
130 | -{ | ||
131 | -} | ||
132 | - | ||
133 | -void pmu_op_finish(CPUARMState *env) | ||
134 | -{ | ||
135 | -} | ||
136 | - | ||
137 | -void pmu_pre_el_change(ARMCPU *cpu, void *ignored) | ||
138 | -{ | ||
139 | -} | ||
140 | - | ||
141 | -void pmu_post_el_change(ARMCPU *cpu, void *ignored) | ||
142 | -{ | ||
143 | -} | ||
144 | - | ||
145 | -#endif | ||
146 | - | ||
147 | static void pmccfiltr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
148 | uint64_t value) | ||
149 | { | ||
150 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
151 | /* Unimplemented so WI. */ | ||
152 | { .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4, | ||
153 | .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NOP }, | ||
154 | -#ifndef CONFIG_USER_ONLY | ||
155 | { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, | ||
156 | .access = PL0_RW, .type = ARM_CP_ALIAS, | ||
157 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr), | ||
158 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
159 | .fieldoffset = offsetof(CPUARMState, cp15.c15_ccnt), | ||
160 | .readfn = pmccntr_read, .writefn = pmccntr_write, | ||
161 | .raw_readfn = raw_read, .raw_writefn = raw_write, }, | ||
162 | -#endif | ||
163 | { .name = "PMCCFILTR", .cp = 15, .opc1 = 0, .crn = 14, .crm = 15, .opc2 = 7, | ||
164 | .writefn = pmccfiltr_write_a32, .readfn = pmccfiltr_read_a32, | ||
165 | .access = PL0_RW, .accessfn = pmreg_access, | ||
166 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
167 | * count register. | ||
168 | */ | ||
169 | unsigned int i, pmcrn = 0; | ||
170 | -#ifndef CONFIG_USER_ONLY | ||
171 | ARMCPRegInfo pmcr = { | ||
172 | .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, | ||
173 | .access = PL0_RW, | ||
174 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
175 | g_free(pmevtyper_name); | ||
176 | g_free(pmevtyper_el0_name); | ||
177 | } | ||
178 | -#endif | ||
179 | ARMCPRegInfo clidr = { | ||
180 | .name = "CLIDR", .state = ARM_CP_STATE_BOTH, | ||
181 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1, | ||
182 | -- | 84 | -- |
183 | 2.20.1 | 85 | 2.25.1 |
184 | 86 | ||
185 | 87 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Now properly signals unallocated for REV64 with SF=0. | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Allows for the opcode2 field to be decoded shortly. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190108223129.5570-8-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 6 | --- |
11 | target/arm/translate-a64.c | 31 ++++++++++++++++++++++--------- | 7 | target/arm/translate-a64.c | 7 ++++--- |
12 | 1 file changed, 22 insertions(+), 9 deletions(-) | 8 | 1 file changed, 4 insertions(+), 3 deletions(-) |
13 | 9 | ||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 10 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
15 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-a64.c | 12 | --- a/target/arm/translate-a64.c |
17 | +++ b/target/arm/translate-a64.c | 13 | +++ b/target/arm/translate-a64.c |
18 | @@ -XXX,XX +XXX,XX @@ static void handle_rev16(DisasContext *s, unsigned int sf, | 14 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
19 | */ | ||
20 | static void disas_data_proc_1src(DisasContext *s, uint32_t insn) | ||
21 | { | 15 | { |
22 | - unsigned int sf, opcode, rn, rd; | 16 | DisasContext *s = container_of(dcbase, DisasContext, base); |
23 | + unsigned int sf, opcode, opcode2, rn, rd; | 17 | CPUARMState *env = cpu->env_ptr; |
24 | 18 | + uint64_t pc = s->base.pc_next; | |
25 | - if (extract32(insn, 29, 1) || extract32(insn, 16, 5)) { | 19 | uint32_t insn; |
26 | + if (extract32(insn, 29, 1)) { | 20 | |
27 | unallocated_encoding(s); | 21 | if (s->ss_active && !s->pstate_ss) { |
22 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
28 | return; | 23 | return; |
29 | } | 24 | } |
30 | 25 | ||
31 | sf = extract32(insn, 31, 1); | 26 | - s->pc_curr = s->base.pc_next; |
32 | opcode = extract32(insn, 10, 6); | 27 | - insn = arm_ldl_code(env, &s->base, s->base.pc_next, s->sctlr_b); |
33 | + opcode2 = extract32(insn, 16, 5); | 28 | + s->pc_curr = pc; |
34 | rn = extract32(insn, 5, 5); | 29 | + insn = arm_ldl_code(env, &s->base, pc, s->sctlr_b); |
35 | rd = extract32(insn, 0, 5); | 30 | s->insn = insn; |
36 | 31 | - s->base.pc_next += 4; | |
37 | - switch (opcode) { | 32 | + s->base.pc_next = pc + 4; |
38 | - case 0: /* RBIT */ | 33 | |
39 | +#define MAP(SF, O2, O1) ((SF) | (O1 << 1) | (O2 << 7)) | 34 | s->fp_access_checked = false; |
40 | + | 35 | s->sve_access_checked = false; |
41 | + switch (MAP(sf, opcode2, opcode)) { | ||
42 | + case MAP(0, 0x00, 0x00): /* RBIT */ | ||
43 | + case MAP(1, 0x00, 0x00): | ||
44 | handle_rbit(s, sf, rn, rd); | ||
45 | break; | ||
46 | - case 1: /* REV16 */ | ||
47 | + case MAP(0, 0x00, 0x01): /* REV16 */ | ||
48 | + case MAP(1, 0x00, 0x01): | ||
49 | handle_rev16(s, sf, rn, rd); | ||
50 | break; | ||
51 | - case 2: /* REV32 */ | ||
52 | + case MAP(0, 0x00, 0x02): /* REV/REV32 */ | ||
53 | + case MAP(1, 0x00, 0x02): | ||
54 | handle_rev32(s, sf, rn, rd); | ||
55 | break; | ||
56 | - case 3: /* REV64 */ | ||
57 | + case MAP(1, 0x00, 0x03): /* REV64 */ | ||
58 | handle_rev64(s, sf, rn, rd); | ||
59 | break; | ||
60 | - case 4: /* CLZ */ | ||
61 | + case MAP(0, 0x00, 0x04): /* CLZ */ | ||
62 | + case MAP(1, 0x00, 0x04): | ||
63 | handle_clz(s, sf, rn, rd); | ||
64 | break; | ||
65 | - case 5: /* CLS */ | ||
66 | + case MAP(0, 0x00, 0x05): /* CLS */ | ||
67 | + case MAP(1, 0x00, 0x05): | ||
68 | handle_cls(s, sf, rn, rd); | ||
69 | break; | ||
70 | + default: | ||
71 | + unallocated_encoding(s); | ||
72 | + break; | ||
73 | } | ||
74 | + | ||
75 | +#undef MAP | ||
76 | } | ||
77 | |||
78 | static void handle_div(DisasContext *s, bool is_signed, unsigned int sf, | ||
79 | -- | 36 | -- |
80 | 2.20.1 | 37 | 2.25.1 |
81 | 38 | ||
82 | 39 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | |||
3 | Use TBID in aa64_va_parameters depending on the data parameter. | ||
4 | This automatically updates all existing users of the function. | ||
5 | 2 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20190108223129.5570-23-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 6 | --- |
11 | target/arm/internals.h | 1 + | 7 | target/arm/translate.c | 9 +++++---- |
12 | target/arm/helper.c | 14 +++++++++++--- | 8 | 1 file changed, 5 insertions(+), 4 deletions(-) |
13 | 2 files changed, 12 insertions(+), 3 deletions(-) | ||
14 | 9 | ||
15 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 10 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/internals.h | 12 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/internals.h | 13 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVAParameters { | 14 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
20 | unsigned tsz : 8; | ||
21 | unsigned select : 1; | ||
22 | bool tbi : 1; | ||
23 | + bool tbid : 1; | ||
24 | bool epd : 1; | ||
25 | bool hpd : 1; | ||
26 | bool using16k : 1; | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/helper.c | ||
30 | +++ b/target/arm/helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
32 | { | 15 | { |
33 | uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | 16 | DisasContext *dc = container_of(dcbase, DisasContext, base); |
34 | uint32_t el = regime_el(env, mmu_idx); | 17 | CPUARMState *env = cpu->env_ptr; |
35 | - bool tbi, epd, hpd, using16k, using64k; | 18 | + uint32_t pc = dc->base.pc_next; |
36 | + bool tbi, tbid, epd, hpd, using16k, using64k; | 19 | unsigned int insn; |
37 | int select, tsz; | 20 | |
38 | 21 | if (arm_pre_translate_insn(dc)) { | |
39 | /* | 22 | - dc->base.pc_next += 4; |
40 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | 23 | + dc->base.pc_next = pc + 4; |
41 | using16k = extract32(tcr, 15, 1); | 24 | return; |
42 | if (mmu_idx == ARMMMUIdx_S2NS) { | ||
43 | /* VTCR_EL2 */ | ||
44 | - tbi = hpd = false; | ||
45 | + tbi = tbid = hpd = false; | ||
46 | } else { | ||
47 | tbi = extract32(tcr, 20, 1); | ||
48 | hpd = extract32(tcr, 24, 1); | ||
49 | + tbid = extract32(tcr, 29, 1); | ||
50 | } | ||
51 | epd = false; | ||
52 | } else if (!select) { | ||
53 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
54 | using16k = extract32(tcr, 15, 1); | ||
55 | tbi = extract64(tcr, 37, 1); | ||
56 | hpd = extract64(tcr, 41, 1); | ||
57 | + tbid = extract64(tcr, 51, 1); | ||
58 | } else { | ||
59 | int tg = extract32(tcr, 30, 2); | ||
60 | using16k = tg == 1; | ||
61 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
62 | epd = extract32(tcr, 23, 1); | ||
63 | tbi = extract64(tcr, 38, 1); | ||
64 | hpd = extract64(tcr, 42, 1); | ||
65 | + tbid = extract64(tcr, 52, 1); | ||
66 | } | 25 | } |
67 | tsz = MIN(tsz, 39); /* TODO: ARMv8.4-TTST */ | 26 | |
68 | tsz = MAX(tsz, 16); /* TODO: ARMv8.2-LVA */ | 27 | - dc->pc_curr = dc->base.pc_next; |
69 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | 28 | - insn = arm_ldl_code(env, &dc->base, dc->base.pc_next, dc->sctlr_b); |
70 | .tsz = tsz, | 29 | + dc->pc_curr = pc; |
71 | .select = select, | 30 | + insn = arm_ldl_code(env, &dc->base, pc, dc->sctlr_b); |
72 | .tbi = tbi, | 31 | dc->insn = insn; |
73 | + .tbid = tbid, | 32 | - dc->base.pc_next += 4; |
74 | .epd = epd, | 33 | + dc->base.pc_next = pc + 4; |
75 | .hpd = hpd, | 34 | disas_arm_insn(dc, insn); |
76 | .using16k = using16k, | 35 | |
77 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | 36 | arm_post_translate_insn(dc); |
78 | ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
79 | ARMMMUIdx mmu_idx, bool data) | ||
80 | { | ||
81 | - return aa64_va_parameters_both(env, va, mmu_idx); | ||
82 | + ARMVAParameters ret = aa64_va_parameters_both(env, va, mmu_idx); | ||
83 | + | ||
84 | + /* Present TBI as a composite with TBID. */ | ||
85 | + ret.tbi &= (data || !ret.tbid); | ||
86 | + return ret; | ||
87 | } | ||
88 | |||
89 | static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
90 | -- | 37 | -- |
91 | 2.20.1 | 38 | 2.25.1 |
92 | 39 | ||
93 | 40 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | |||
3 | This is the main crypto routine, an implementation of QARMA. | ||
4 | This matches, as much as possible, ARM pseudocode. | ||
5 | 2 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20190108223129.5570-28-richard.henderson@linaro.org | ||
9 | [PMM: fixed minor checkpatch nits] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 6 | --- |
12 | target/arm/pauth_helper.c | 242 +++++++++++++++++++++++++++++++++++++- | 7 | target/arm/translate.c | 16 ++++++++-------- |
13 | 1 file changed, 241 insertions(+), 1 deletion(-) | 8 | 1 file changed, 8 insertions(+), 8 deletions(-) |
14 | 9 | ||
15 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | 10 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/pauth_helper.c | 12 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/pauth_helper.c | 13 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ | 14 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
20 | #include "tcg/tcg-gvec-desc.h" | ||
21 | |||
22 | |||
23 | +static uint64_t pac_cell_shuffle(uint64_t i) | ||
24 | +{ | ||
25 | + uint64_t o = 0; | ||
26 | + | ||
27 | + o |= extract64(i, 52, 4); | ||
28 | + o |= extract64(i, 24, 4) << 4; | ||
29 | + o |= extract64(i, 44, 4) << 8; | ||
30 | + o |= extract64(i, 0, 4) << 12; | ||
31 | + | ||
32 | + o |= extract64(i, 28, 4) << 16; | ||
33 | + o |= extract64(i, 48, 4) << 20; | ||
34 | + o |= extract64(i, 4, 4) << 24; | ||
35 | + o |= extract64(i, 40, 4) << 28; | ||
36 | + | ||
37 | + o |= extract64(i, 32, 4) << 32; | ||
38 | + o |= extract64(i, 12, 4) << 36; | ||
39 | + o |= extract64(i, 56, 4) << 40; | ||
40 | + o |= extract64(i, 20, 4) << 44; | ||
41 | + | ||
42 | + o |= extract64(i, 8, 4) << 48; | ||
43 | + o |= extract64(i, 36, 4) << 52; | ||
44 | + o |= extract64(i, 16, 4) << 56; | ||
45 | + o |= extract64(i, 60, 4) << 60; | ||
46 | + | ||
47 | + return o; | ||
48 | +} | ||
49 | + | ||
50 | +static uint64_t pac_cell_inv_shuffle(uint64_t i) | ||
51 | +{ | ||
52 | + uint64_t o = 0; | ||
53 | + | ||
54 | + o |= extract64(i, 12, 4); | ||
55 | + o |= extract64(i, 24, 4) << 4; | ||
56 | + o |= extract64(i, 48, 4) << 8; | ||
57 | + o |= extract64(i, 36, 4) << 12; | ||
58 | + | ||
59 | + o |= extract64(i, 56, 4) << 16; | ||
60 | + o |= extract64(i, 44, 4) << 20; | ||
61 | + o |= extract64(i, 4, 4) << 24; | ||
62 | + o |= extract64(i, 16, 4) << 28; | ||
63 | + | ||
64 | + o |= i & MAKE_64BIT_MASK(32, 4); | ||
65 | + o |= extract64(i, 52, 4) << 36; | ||
66 | + o |= extract64(i, 28, 4) << 40; | ||
67 | + o |= extract64(i, 8, 4) << 44; | ||
68 | + | ||
69 | + o |= extract64(i, 20, 4) << 48; | ||
70 | + o |= extract64(i, 0, 4) << 52; | ||
71 | + o |= extract64(i, 40, 4) << 56; | ||
72 | + o |= i & MAKE_64BIT_MASK(60, 4); | ||
73 | + | ||
74 | + return o; | ||
75 | +} | ||
76 | + | ||
77 | +static uint64_t pac_sub(uint64_t i) | ||
78 | +{ | ||
79 | + static const uint8_t sub[16] = { | ||
80 | + 0xb, 0x6, 0x8, 0xf, 0xc, 0x0, 0x9, 0xe, | ||
81 | + 0x3, 0x7, 0x4, 0x5, 0xd, 0x2, 0x1, 0xa, | ||
82 | + }; | ||
83 | + uint64_t o = 0; | ||
84 | + int b; | ||
85 | + | ||
86 | + for (b = 0; b < 64; b += 16) { | ||
87 | + o |= (uint64_t)sub[(i >> b) & 0xf] << b; | ||
88 | + } | ||
89 | + return o; | ||
90 | +} | ||
91 | + | ||
92 | +static uint64_t pac_inv_sub(uint64_t i) | ||
93 | +{ | ||
94 | + static const uint8_t inv_sub[16] = { | ||
95 | + 0x5, 0xe, 0xd, 0x8, 0xa, 0xb, 0x1, 0x9, | ||
96 | + 0x2, 0x6, 0xf, 0x0, 0x4, 0xc, 0x7, 0x3, | ||
97 | + }; | ||
98 | + uint64_t o = 0; | ||
99 | + int b; | ||
100 | + | ||
101 | + for (b = 0; b < 64; b += 16) { | ||
102 | + o |= (uint64_t)inv_sub[(i >> b) & 0xf] << b; | ||
103 | + } | ||
104 | + return o; | ||
105 | +} | ||
106 | + | ||
107 | +static int rot_cell(int cell, int n) | ||
108 | +{ | ||
109 | + /* 4-bit rotate left by n. */ | ||
110 | + cell |= cell << 4; | ||
111 | + return extract32(cell, 4 - n, 4); | ||
112 | +} | ||
113 | + | ||
114 | +static uint64_t pac_mult(uint64_t i) | ||
115 | +{ | ||
116 | + uint64_t o = 0; | ||
117 | + int b; | ||
118 | + | ||
119 | + for (b = 0; b < 4 * 4; b += 4) { | ||
120 | + int i0, i4, i8, ic, t0, t1, t2, t3; | ||
121 | + | ||
122 | + i0 = extract64(i, b, 4); | ||
123 | + i4 = extract64(i, b + 4 * 4, 4); | ||
124 | + i8 = extract64(i, b + 8 * 4, 4); | ||
125 | + ic = extract64(i, b + 12 * 4, 4); | ||
126 | + | ||
127 | + t0 = rot_cell(i8, 1) ^ rot_cell(i4, 2) ^ rot_cell(i0, 1); | ||
128 | + t1 = rot_cell(ic, 1) ^ rot_cell(i4, 1) ^ rot_cell(i0, 2); | ||
129 | + t2 = rot_cell(ic, 2) ^ rot_cell(i8, 1) ^ rot_cell(i0, 1); | ||
130 | + t3 = rot_cell(ic, 1) ^ rot_cell(i8, 2) ^ rot_cell(i4, 1); | ||
131 | + | ||
132 | + o |= (uint64_t)t3 << b; | ||
133 | + o |= (uint64_t)t2 << (b + 4 * 4); | ||
134 | + o |= (uint64_t)t1 << (b + 8 * 4); | ||
135 | + o |= (uint64_t)t0 << (b + 12 * 4); | ||
136 | + } | ||
137 | + return o; | ||
138 | +} | ||
139 | + | ||
140 | +static uint64_t tweak_cell_rot(uint64_t cell) | ||
141 | +{ | ||
142 | + return (cell >> 1) | (((cell ^ (cell >> 1)) & 1) << 3); | ||
143 | +} | ||
144 | + | ||
145 | +static uint64_t tweak_shuffle(uint64_t i) | ||
146 | +{ | ||
147 | + uint64_t o = 0; | ||
148 | + | ||
149 | + o |= extract64(i, 16, 4) << 0; | ||
150 | + o |= extract64(i, 20, 4) << 4; | ||
151 | + o |= tweak_cell_rot(extract64(i, 24, 4)) << 8; | ||
152 | + o |= extract64(i, 28, 4) << 12; | ||
153 | + | ||
154 | + o |= tweak_cell_rot(extract64(i, 44, 4)) << 16; | ||
155 | + o |= extract64(i, 8, 4) << 20; | ||
156 | + o |= extract64(i, 12, 4) << 24; | ||
157 | + o |= tweak_cell_rot(extract64(i, 32, 4)) << 28; | ||
158 | + | ||
159 | + o |= extract64(i, 48, 4) << 32; | ||
160 | + o |= extract64(i, 52, 4) << 36; | ||
161 | + o |= extract64(i, 56, 4) << 40; | ||
162 | + o |= tweak_cell_rot(extract64(i, 60, 4)) << 44; | ||
163 | + | ||
164 | + o |= tweak_cell_rot(extract64(i, 0, 4)) << 48; | ||
165 | + o |= extract64(i, 4, 4) << 52; | ||
166 | + o |= tweak_cell_rot(extract64(i, 40, 4)) << 56; | ||
167 | + o |= tweak_cell_rot(extract64(i, 36, 4)) << 60; | ||
168 | + | ||
169 | + return o; | ||
170 | +} | ||
171 | + | ||
172 | +static uint64_t tweak_cell_inv_rot(uint64_t cell) | ||
173 | +{ | ||
174 | + return ((cell << 1) & 0xf) | ((cell & 1) ^ (cell >> 3)); | ||
175 | +} | ||
176 | + | ||
177 | +static uint64_t tweak_inv_shuffle(uint64_t i) | ||
178 | +{ | ||
179 | + uint64_t o = 0; | ||
180 | + | ||
181 | + o |= tweak_cell_inv_rot(extract64(i, 48, 4)); | ||
182 | + o |= extract64(i, 52, 4) << 4; | ||
183 | + o |= extract64(i, 20, 4) << 8; | ||
184 | + o |= extract64(i, 24, 4) << 12; | ||
185 | + | ||
186 | + o |= extract64(i, 0, 4) << 16; | ||
187 | + o |= extract64(i, 4, 4) << 20; | ||
188 | + o |= tweak_cell_inv_rot(extract64(i, 8, 4)) << 24; | ||
189 | + o |= extract64(i, 12, 4) << 28; | ||
190 | + | ||
191 | + o |= tweak_cell_inv_rot(extract64(i, 28, 4)) << 32; | ||
192 | + o |= tweak_cell_inv_rot(extract64(i, 60, 4)) << 36; | ||
193 | + o |= tweak_cell_inv_rot(extract64(i, 56, 4)) << 40; | ||
194 | + o |= tweak_cell_inv_rot(extract64(i, 16, 4)) << 44; | ||
195 | + | ||
196 | + o |= extract64(i, 32, 4) << 48; | ||
197 | + o |= extract64(i, 36, 4) << 52; | ||
198 | + o |= extract64(i, 40, 4) << 56; | ||
199 | + o |= tweak_cell_inv_rot(extract64(i, 44, 4)) << 60; | ||
200 | + | ||
201 | + return o; | ||
202 | +} | ||
203 | + | ||
204 | static uint64_t pauth_computepac(uint64_t data, uint64_t modifier, | ||
205 | ARMPACKey key) | ||
206 | { | 15 | { |
207 | - g_assert_not_reached(); /* FIXME */ | 16 | DisasContext *dc = container_of(dcbase, DisasContext, base); |
208 | + static const uint64_t RC[5] = { | 17 | CPUARMState *env = cpu->env_ptr; |
209 | + 0x0000000000000000ull, | 18 | + uint32_t pc = dc->base.pc_next; |
210 | + 0x13198A2E03707344ull, | 19 | uint32_t insn; |
211 | + 0xA4093822299F31D0ull, | 20 | bool is_16bit; |
212 | + 0x082EFA98EC4E6C89ull, | 21 | |
213 | + 0x452821E638D01377ull, | 22 | if (arm_pre_translate_insn(dc)) { |
214 | + }; | 23 | - dc->base.pc_next += 2; |
215 | + const uint64_t alpha = 0xC0AC29B7C97C50DDull; | 24 | + dc->base.pc_next = pc + 2; |
216 | + /* | 25 | return; |
217 | + * Note that in the ARM pseudocode, key0 contains bits <127:64> | 26 | } |
218 | + * and key1 contains bits <63:0> of the 128-bit key. | 27 | |
219 | + */ | 28 | - dc->pc_curr = dc->base.pc_next; |
220 | + uint64_t key0 = key.hi, key1 = key.lo; | 29 | - insn = arm_lduw_code(env, &dc->base, dc->base.pc_next, dc->sctlr_b); |
221 | + uint64_t workingval, runningmod, roundkey, modk0; | 30 | + dc->pc_curr = pc; |
222 | + int i; | 31 | + insn = arm_lduw_code(env, &dc->base, pc, dc->sctlr_b); |
223 | + | 32 | is_16bit = thumb_insn_is_16bit(dc, dc->base.pc_next, insn); |
224 | + modk0 = (key0 << 63) | ((key0 >> 1) ^ (key0 >> 63)); | 33 | - dc->base.pc_next += 2; |
225 | + runningmod = modifier; | 34 | + pc += 2; |
226 | + workingval = data ^ key0; | 35 | if (!is_16bit) { |
227 | + | 36 | - uint32_t insn2 = arm_lduw_code(env, &dc->base, dc->base.pc_next, |
228 | + for (i = 0; i <= 4; ++i) { | 37 | - dc->sctlr_b); |
229 | + roundkey = key1 ^ runningmod; | 38 | - |
230 | + workingval ^= roundkey; | 39 | + uint32_t insn2 = arm_lduw_code(env, &dc->base, pc, dc->sctlr_b); |
231 | + workingval ^= RC[i]; | 40 | insn = insn << 16 | insn2; |
232 | + if (i > 0) { | 41 | - dc->base.pc_next += 2; |
233 | + workingval = pac_cell_shuffle(workingval); | 42 | + pc += 2; |
234 | + workingval = pac_mult(workingval); | 43 | } |
235 | + } | 44 | + dc->base.pc_next = pc; |
236 | + workingval = pac_sub(workingval); | 45 | dc->insn = insn; |
237 | + runningmod = tweak_shuffle(runningmod); | 46 | |
238 | + } | 47 | if (dc->pstate_il) { |
239 | + roundkey = modk0 ^ runningmod; | ||
240 | + workingval ^= roundkey; | ||
241 | + workingval = pac_cell_shuffle(workingval); | ||
242 | + workingval = pac_mult(workingval); | ||
243 | + workingval = pac_sub(workingval); | ||
244 | + workingval = pac_cell_shuffle(workingval); | ||
245 | + workingval = pac_mult(workingval); | ||
246 | + workingval ^= key1; | ||
247 | + workingval = pac_cell_inv_shuffle(workingval); | ||
248 | + workingval = pac_inv_sub(workingval); | ||
249 | + workingval = pac_mult(workingval); | ||
250 | + workingval = pac_cell_inv_shuffle(workingval); | ||
251 | + workingval ^= key0; | ||
252 | + workingval ^= runningmod; | ||
253 | + for (i = 0; i <= 4; ++i) { | ||
254 | + workingval = pac_inv_sub(workingval); | ||
255 | + if (i < 4) { | ||
256 | + workingval = pac_mult(workingval); | ||
257 | + workingval = pac_cell_inv_shuffle(workingval); | ||
258 | + } | ||
259 | + runningmod = tweak_inv_shuffle(runningmod); | ||
260 | + roundkey = key1 ^ runningmod; | ||
261 | + workingval ^= RC[4 - i]; | ||
262 | + workingval ^= roundkey; | ||
263 | + workingval ^= alpha; | ||
264 | + } | ||
265 | + workingval ^= modk0; | ||
266 | + | ||
267 | + return workingval; | ||
268 | } | ||
269 | |||
270 | static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | ||
271 | -- | 48 | -- |
272 | 2.20.1 | 49 | 2.25.1 |
273 | 50 | ||
274 | 51 | 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 will want to check TBI for I and D simultaneously. | 3 | Create arm_check_ss_active and arm_check_kernelpage. |
4 | |||
5 | Reverse the order of the tests. While it doesn't matter in practice, | ||
6 | because only user-only has a kernel page and user-only never sets | ||
7 | ss_active, ss_active has priority over execution exceptions and it | ||
8 | is best to keep them in the proper order. | ||
4 | 9 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20190108223129.5570-22-richard.henderson@linaro.org | ||
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/internals.h | 15 ++++++++++++--- | 14 | target/arm/translate.c | 10 +++++++--- |
11 | target/arm/helper.c | 10 ++++++++-- | 15 | 1 file changed, 7 insertions(+), 3 deletions(-) |
12 | 2 files changed, 20 insertions(+), 5 deletions(-) | ||
13 | 16 | ||
14 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 17 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/internals.h | 19 | --- a/target/arm/translate.c |
17 | +++ b/target/arm/internals.h | 20 | +++ b/target/arm/translate.c |
18 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVAParameters { | 21 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) |
19 | } ARMVAParameters; | 22 | dc->insn_start = tcg_last_op(); |
20 | 23 | } | |
24 | |||
25 | -static bool arm_pre_translate_insn(DisasContext *dc) | ||
26 | +static bool arm_check_kernelpage(DisasContext *dc) | ||
27 | { | ||
21 | #ifdef CONFIG_USER_ONLY | 28 | #ifdef CONFIG_USER_ONLY |
22 | -static inline ARMVAParameters aa64_va_parameters(CPUARMState *env, | 29 | /* Intercept jump to the magic kernel page. */ |
23 | - uint64_t va, | 30 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) |
24 | - ARMMMUIdx mmu_idx, bool data) | 31 | return true; |
25 | +static inline ARMVAParameters aa64_va_parameters_both(CPUARMState *env, | 32 | } |
26 | + uint64_t va, | 33 | #endif |
27 | + ARMMMUIdx mmu_idx) | 34 | + return false; |
28 | { | 35 | +} |
29 | return (ARMVAParameters) { | 36 | |
30 | /* 48-bit address space */ | 37 | +static bool arm_check_ss_active(DisasContext *dc) |
31 | @@ -XXX,XX +XXX,XX @@ static inline ARMVAParameters aa64_va_parameters(CPUARMState *env, | ||
32 | .tbi = false, | ||
33 | }; | ||
34 | } | ||
35 | + | ||
36 | +static inline ARMVAParameters aa64_va_parameters(CPUARMState *env, | ||
37 | + uint64_t va, | ||
38 | + ARMMMUIdx mmu_idx, bool data) | ||
39 | +{ | 38 | +{ |
40 | + return aa64_va_parameters_both(env, va, mmu_idx); | 39 | if (dc->ss_active && !dc->pstate_ss) { |
41 | +} | 40 | /* Singlestep state is Active-pending. |
42 | #else | 41 | * If we're in this state at the start of a TB then either |
43 | +ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | 42 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
44 | + ARMMMUIdx mmu_idx); | 43 | uint32_t pc = dc->base.pc_next; |
45 | ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | 44 | unsigned int insn; |
46 | ARMMMUIdx mmu_idx, bool data); | 45 | |
47 | #endif | 46 | - if (arm_pre_translate_insn(dc)) { |
48 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 47 | + if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { |
49 | index XXXXXXX..XXXXXXX 100644 | 48 | dc->base.pc_next = pc + 4; |
50 | --- a/target/arm/helper.c | 49 | return; |
51 | +++ b/target/arm/helper.c | 50 | } |
52 | @@ -XXX,XX +XXX,XX @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) | 51 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
53 | return (hiattr << 6) | (hihint << 4) | (loattr << 2) | lohint; | 52 | uint32_t insn; |
54 | } | 53 | bool is_16bit; |
55 | 54 | ||
56 | -ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | 55 | - if (arm_pre_translate_insn(dc)) { |
57 | - ARMMMUIdx mmu_idx, bool data) | 56 | + if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { |
58 | +ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | 57 | dc->base.pc_next = pc + 2; |
59 | + ARMMMUIdx mmu_idx) | 58 | return; |
60 | { | 59 | } |
61 | uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | ||
62 | uint32_t el = regime_el(env, mmu_idx); | ||
63 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
64 | }; | ||
65 | } | ||
66 | |||
67 | +ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
68 | + ARMMMUIdx mmu_idx, bool data) | ||
69 | +{ | ||
70 | + return aa64_va_parameters_both(env, va, mmu_idx); | ||
71 | +} | ||
72 | + | ||
73 | static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
74 | ARMMMUIdx mmu_idx) | ||
75 | { | ||
76 | -- | 60 | -- |
77 | 2.20.1 | 61 | 2.25.1 |
78 | 62 | ||
79 | 63 | 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 will enable PAuth decode in a subsequent patch. | 3 | The size of the code covered by a TranslationBlock cannot be 0; |
4 | this is checked via assert in tb_gen_code. | ||
4 | 5 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 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 | Message-id: 20190108223129.5570-13-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | target/arm/translate-a64.c | 47 +++++++++++++++++++++++++++++--------- | 10 | target/arm/translate-a64.c | 1 + |
11 | 1 file changed, 36 insertions(+), 11 deletions(-) | 11 | 1 file changed, 1 insertion(+) |
12 | 12 | ||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a64.c | 15 | --- a/target/arm/translate-a64.c |
16 | +++ b/target/arm/translate-a64.c | 16 | +++ b/target/arm/translate-a64.c |
17 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
18 | rn = extract32(insn, 5, 5); | 18 | assert(s->base.num_insns == 1); |
19 | op4 = extract32(insn, 0, 5); | 19 | gen_swstep_exception(s, 0, 0); |
20 | 20 | s->base.is_jmp = DISAS_NORETURN; | |
21 | - if (op4 != 0x0 || op3 != 0x0 || op2 != 0x1f) { | 21 | + s->base.pc_next = pc + 4; |
22 | - unallocated_encoding(s); | ||
23 | - return; | ||
24 | + if (op2 != 0x1f) { | ||
25 | + goto do_unallocated; | ||
26 | } | ||
27 | |||
28 | switch (opc) { | ||
29 | case 0: /* BR */ | ||
30 | case 1: /* BLR */ | ||
31 | case 2: /* RET */ | ||
32 | - gen_a64_set_pc(s, cpu_reg(s, rn)); | ||
33 | + switch (op3) { | ||
34 | + case 0: | ||
35 | + if (op4 != 0) { | ||
36 | + goto do_unallocated; | ||
37 | + } | ||
38 | + dst = cpu_reg(s, rn); | ||
39 | + break; | ||
40 | + | ||
41 | + default: | ||
42 | + goto do_unallocated; | ||
43 | + } | ||
44 | + | ||
45 | + gen_a64_set_pc(s, dst); | ||
46 | /* BLR also needs to load return address */ | ||
47 | if (opc == 1) { | ||
48 | tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
49 | } | ||
50 | break; | ||
51 | + | ||
52 | case 4: /* ERET */ | ||
53 | if (s->current_el == 0) { | ||
54 | - unallocated_encoding(s); | ||
55 | - return; | ||
56 | + goto do_unallocated; | ||
57 | + } | ||
58 | + switch (op3) { | ||
59 | + case 0: | ||
60 | + if (op4 != 0) { | ||
61 | + goto do_unallocated; | ||
62 | + } | ||
63 | + dst = tcg_temp_new_i64(); | ||
64 | + tcg_gen_ld_i64(dst, cpu_env, | ||
65 | + offsetof(CPUARMState, elr_el[s->current_el])); | ||
66 | + break; | ||
67 | + | ||
68 | + default: | ||
69 | + goto do_unallocated; | ||
70 | } | ||
71 | if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
72 | gen_io_start(); | ||
73 | } | ||
74 | - dst = tcg_temp_new_i64(); | ||
75 | - tcg_gen_ld_i64(dst, cpu_env, | ||
76 | - offsetof(CPUARMState, elr_el[s->current_el])); | ||
77 | + | ||
78 | gen_helper_exception_return(cpu_env, dst); | ||
79 | tcg_temp_free_i64(dst); | ||
80 | if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
81 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
82 | /* Must exit loop to check un-masked IRQs */ | ||
83 | s->base.is_jmp = DISAS_EXIT; | ||
84 | return; | ||
85 | + | ||
86 | case 5: /* DRPS */ | ||
87 | - if (rn != 0x1f) { | ||
88 | - unallocated_encoding(s); | ||
89 | + if (op3 != 0 || op4 != 0 || rn != 0x1f) { | ||
90 | + goto do_unallocated; | ||
91 | } else { | ||
92 | unsupported_encoding(s, insn); | ||
93 | } | ||
94 | return; | ||
95 | + | ||
96 | default: | ||
97 | + do_unallocated: | ||
98 | unallocated_encoding(s); | ||
99 | return; | 22 | return; |
100 | } | 23 | } |
24 | |||
101 | -- | 25 | -- |
102 | 2.20.1 | 26 | 2.25.1 |
103 | 27 | ||
104 | 28 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add 4 attributes that controls the EL1 enable bits, as we may not | 3 | We will reuse this section of arm_deliver_fault for |
4 | always want to turn on pointer authentication with -cpu max. | 4 | raising pc alignment faults. |
5 | However, by default they are enabled. | ||
6 | 5 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20190108223129.5570-31-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | target/arm/cpu.c | 3 +++ | 10 | target/arm/tlb_helper.c | 45 +++++++++++++++++++++++++---------------- |
13 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ | 11 | 1 file changed, 28 insertions(+), 17 deletions(-) |
14 | 2 files changed, 63 insertions(+) | ||
15 | 12 | ||
16 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 13 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.c | 15 | --- a/target/arm/tlb_helper.c |
19 | +++ b/target/arm/cpu.c | 16 | +++ b/target/arm/tlb_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | 17 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, |
21 | env->pstate = PSTATE_MODE_EL0t; | 18 | return syn; |
22 | /* Userspace expects access to DC ZVA, CTL_EL0 and the cache ops */ | ||
23 | env->cp15.sctlr_el[1] |= SCTLR_UCT | SCTLR_UCI | SCTLR_DZE; | ||
24 | + /* Enable all PAC instructions */ | ||
25 | + env->cp15.hcr_el2 |= HCR_API; | ||
26 | + env->cp15.scr_el3 |= SCR_API; | ||
27 | /* and to the FP/Neon instructions */ | ||
28 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3); | ||
29 | /* and to the SVE instructions */ | ||
30 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/cpu64.c | ||
33 | +++ b/target/arm/cpu64.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
35 | error_propagate(errp, err); | ||
36 | } | 19 | } |
37 | 20 | ||
38 | +#ifdef CONFIG_USER_ONLY | 21 | -static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, |
39 | +static void cpu_max_get_packey(Object *obj, Visitor *v, const char *name, | 22 | - MMUAccessType access_type, |
40 | + void *opaque, Error **errp) | 23 | - int mmu_idx, ARMMMUFaultInfo *fi) |
41 | +{ | 24 | +static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, |
42 | + ARMCPU *cpu = ARM_CPU(obj); | 25 | + int target_el, int mmu_idx, uint32_t *ret_fsc) |
43 | + const uint64_t *bit = opaque; | 26 | { |
44 | + bool enabled = (cpu->env.cp15.sctlr_el[1] & *bit) != 0; | 27 | - CPUARMState *env = &cpu->env; |
45 | + | 28 | - int target_el; |
46 | + visit_type_bool(v, name, &enabled, errp); | 29 | - bool same_el; |
30 | - uint32_t syn, exc, fsr, fsc; | ||
31 | ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); | ||
32 | - | ||
33 | - target_el = exception_target_el(env); | ||
34 | - if (fi->stage2) { | ||
35 | - target_el = 2; | ||
36 | - env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | ||
37 | - if (arm_is_secure_below_el3(env) && fi->s1ns) { | ||
38 | - env->cp15.hpfar_el2 |= HPFAR_NS; | ||
39 | - } | ||
40 | - } | ||
41 | - same_el = (arm_current_el(env) == target_el); | ||
42 | + uint32_t fsr, fsc; | ||
43 | |||
44 | if (target_el == 2 || arm_el_is_aa64(env, target_el) || | ||
45 | arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | ||
46 | @@ -XXX,XX +XXX,XX @@ static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | ||
47 | fsc = 0x3f; | ||
48 | } | ||
49 | |||
50 | + *ret_fsc = fsc; | ||
51 | + return fsr; | ||
47 | +} | 52 | +} |
48 | + | 53 | + |
49 | +static void cpu_max_set_packey(Object *obj, Visitor *v, const char *name, | 54 | +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, |
50 | + void *opaque, Error **errp) | 55 | + MMUAccessType access_type, |
56 | + int mmu_idx, ARMMMUFaultInfo *fi) | ||
51 | +{ | 57 | +{ |
52 | + ARMCPU *cpu = ARM_CPU(obj); | 58 | + CPUARMState *env = &cpu->env; |
53 | + Error *err = NULL; | 59 | + int target_el; |
54 | + const uint64_t *bit = opaque; | 60 | + bool same_el; |
55 | + bool enabled; | 61 | + uint32_t syn, exc, fsr, fsc; |
56 | + | 62 | + |
57 | + visit_type_bool(v, name, &enabled, errp); | 63 | + target_el = exception_target_el(env); |
58 | + | 64 | + if (fi->stage2) { |
59 | + if (!err) { | 65 | + target_el = 2; |
60 | + if (enabled) { | 66 | + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; |
61 | + cpu->env.cp15.sctlr_el[1] |= *bit; | 67 | + if (arm_is_secure_below_el3(env) && fi->s1ns) { |
62 | + } else { | 68 | + env->cp15.hpfar_el2 |= HPFAR_NS; |
63 | + cpu->env.cp15.sctlr_el[1] &= ~*bit; | ||
64 | + } | 69 | + } |
65 | + } | 70 | + } |
66 | + error_propagate(errp, err); | 71 | + same_el = (arm_current_el(env) == target_el); |
67 | +} | ||
68 | +#endif | ||
69 | + | 72 | + |
70 | /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); | 73 | + fsr = compute_fsr_fsc(env, fi, target_el, mmu_idx, &fsc); |
71 | * otherwise, a CPU with as many features enabled as our emulation supports. | ||
72 | * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; | ||
73 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
74 | */ | ||
75 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
76 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
77 | + | 74 | + |
78 | + /* | 75 | if (access_type == MMU_INST_FETCH) { |
79 | + * Note that Linux will enable enable all of the keys at once. | 76 | syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); |
80 | + * But doing it this way will allow experimentation beyond that. | 77 | exc = EXCP_PREFETCH_ABORT; |
81 | + */ | ||
82 | + { | ||
83 | + static const uint64_t apia_bit = SCTLR_EnIA; | ||
84 | + static const uint64_t apib_bit = SCTLR_EnIB; | ||
85 | + static const uint64_t apda_bit = SCTLR_EnDA; | ||
86 | + static const uint64_t apdb_bit = SCTLR_EnDB; | ||
87 | + | ||
88 | + object_property_add(obj, "apia", "bool", cpu_max_get_packey, | ||
89 | + cpu_max_set_packey, NULL, | ||
90 | + (void *)&apia_bit, &error_fatal); | ||
91 | + object_property_add(obj, "apib", "bool", cpu_max_get_packey, | ||
92 | + cpu_max_set_packey, NULL, | ||
93 | + (void *)&apib_bit, &error_fatal); | ||
94 | + object_property_add(obj, "apda", "bool", cpu_max_get_packey, | ||
95 | + cpu_max_set_packey, NULL, | ||
96 | + (void *)&apda_bit, &error_fatal); | ||
97 | + object_property_add(obj, "apdb", "bool", cpu_max_get_packey, | ||
98 | + cpu_max_set_packey, NULL, | ||
99 | + (void *)&apdb_bit, &error_fatal); | ||
100 | + | ||
101 | + /* Enable all PAC keys by default. */ | ||
102 | + cpu->env.cp15.sctlr_el[1] |= SCTLR_EnIA | SCTLR_EnIB; | ||
103 | + cpu->env.cp15.sctlr_el[1] |= SCTLR_EnDA | SCTLR_EnDB; | ||
104 | + } | ||
105 | #endif | ||
106 | |||
107 | cpu->sve_max_vq = ARM_MAX_VQ; | ||
108 | -- | 78 | -- |
109 | 2.20.1 | 79 | 2.25.1 |
110 | 80 | ||
111 | 81 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Not that there are any stores involved, but why argue with ARM's | 3 | For A64, any input to an indirect branch can cause this. |
4 | naming convention. | 4 | |
5 | For A32, many indirect branch paths force the branch to be aligned, | ||
6 | but BXWritePC does not. This includes the BX instruction but also | ||
7 | other interworking changes to PC. Prior to v8, this case is UNDEFINED. | ||
8 | With v8, this is CONSTRAINED UNPREDICTABLE and may either raise an | ||
9 | exception or force align the PC. | ||
10 | |||
11 | We choose to raise an exception because we have the infrastructure, | ||
12 | it makes the generated code for gen_bx simpler, and it has the | ||
13 | possibility of catching more guest bugs. | ||
5 | 14 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20190108223129.5570-15-richard.henderson@linaro.org | ||
9 | [fixed trivial comment nit] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 18 | --- |
12 | target/arm/translate-a64.c | 61 ++++++++++++++++++++++++++++++++++++++ | 19 | target/arm/helper.h | 1 + |
13 | 1 file changed, 61 insertions(+) | 20 | target/arm/syndrome.h | 5 ++++ |
14 | 21 | linux-user/aarch64/cpu_loop.c | 46 ++++++++++++++++++++--------------- | |
22 | target/arm/tlb_helper.c | 18 ++++++++++++++ | ||
23 | target/arm/translate-a64.c | 15 ++++++++++++ | ||
24 | target/arm/translate.c | 22 ++++++++++++++++- | ||
25 | 6 files changed, 87 insertions(+), 20 deletions(-) | ||
26 | |||
27 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/helper.h | ||
30 | +++ b/target/arm/helper.h | ||
31 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, | ||
32 | DEF_HELPER_2(exception_internal, void, env, i32) | ||
33 | DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32) | ||
34 | DEF_HELPER_2(exception_bkpt_insn, void, env, i32) | ||
35 | +DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl) | ||
36 | DEF_HELPER_1(setend, void, env) | ||
37 | DEF_HELPER_2(wfi, void, env, i32) | ||
38 | DEF_HELPER_1(wfe, void, env) | ||
39 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/syndrome.h | ||
42 | +++ b/target/arm/syndrome.h | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_illegalstate(void) | ||
44 | return (EC_ILLEGALSTATE << ARM_EL_EC_SHIFT) | ARM_EL_IL; | ||
45 | } | ||
46 | |||
47 | +static inline uint32_t syn_pcalignment(void) | ||
48 | +{ | ||
49 | + return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL; | ||
50 | +} | ||
51 | + | ||
52 | #endif /* TARGET_ARM_SYNDROME_H */ | ||
53 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/linux-user/aarch64/cpu_loop.c | ||
56 | +++ b/linux-user/aarch64/cpu_loop.c | ||
57 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | ||
58 | break; | ||
59 | case EXCP_PREFETCH_ABORT: | ||
60 | case EXCP_DATA_ABORT: | ||
61 | - /* We should only arrive here with EC in {DATAABORT, INSNABORT}. */ | ||
62 | ec = syn_get_ec(env->exception.syndrome); | ||
63 | - assert(ec == EC_DATAABORT || ec == EC_INSNABORT); | ||
64 | - | ||
65 | - /* Both EC have the same format for FSC, or close enough. */ | ||
66 | - fsc = extract32(env->exception.syndrome, 0, 6); | ||
67 | - switch (fsc) { | ||
68 | - case 0x04 ... 0x07: /* Translation fault, level {0-3} */ | ||
69 | - si_signo = TARGET_SIGSEGV; | ||
70 | - si_code = TARGET_SEGV_MAPERR; | ||
71 | + switch (ec) { | ||
72 | + case EC_DATAABORT: | ||
73 | + case EC_INSNABORT: | ||
74 | + /* Both EC have the same format for FSC, or close enough. */ | ||
75 | + fsc = extract32(env->exception.syndrome, 0, 6); | ||
76 | + switch (fsc) { | ||
77 | + case 0x04 ... 0x07: /* Translation fault, level {0-3} */ | ||
78 | + si_signo = TARGET_SIGSEGV; | ||
79 | + si_code = TARGET_SEGV_MAPERR; | ||
80 | + break; | ||
81 | + case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ | ||
82 | + case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ | ||
83 | + si_signo = TARGET_SIGSEGV; | ||
84 | + si_code = TARGET_SEGV_ACCERR; | ||
85 | + break; | ||
86 | + case 0x11: /* Synchronous Tag Check Fault */ | ||
87 | + si_signo = TARGET_SIGSEGV; | ||
88 | + si_code = TARGET_SEGV_MTESERR; | ||
89 | + break; | ||
90 | + case 0x21: /* Alignment fault */ | ||
91 | + si_signo = TARGET_SIGBUS; | ||
92 | + si_code = TARGET_BUS_ADRALN; | ||
93 | + break; | ||
94 | + default: | ||
95 | + g_assert_not_reached(); | ||
96 | + } | ||
97 | break; | ||
98 | - case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ | ||
99 | - case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ | ||
100 | - si_signo = TARGET_SIGSEGV; | ||
101 | - si_code = TARGET_SEGV_ACCERR; | ||
102 | - break; | ||
103 | - case 0x11: /* Synchronous Tag Check Fault */ | ||
104 | - si_signo = TARGET_SIGSEGV; | ||
105 | - si_code = TARGET_SEGV_MTESERR; | ||
106 | - break; | ||
107 | - case 0x21: /* Alignment fault */ | ||
108 | + case EC_PCALIGNMENT: | ||
109 | si_signo = TARGET_SIGBUS; | ||
110 | si_code = TARGET_BUS_ADRALN; | ||
111 | break; | ||
112 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/target/arm/tlb_helper.c | ||
115 | +++ b/target/arm/tlb_helper.c | ||
116 | @@ -XXX,XX +XXX,XX @@ | ||
117 | #include "cpu.h" | ||
118 | #include "internals.h" | ||
119 | #include "exec/exec-all.h" | ||
120 | +#include "exec/helper-proto.h" | ||
121 | |||
122 | static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
123 | unsigned int target_el, | ||
124 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
125 | arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
126 | } | ||
127 | |||
128 | +void helper_exception_pc_alignment(CPUARMState *env, target_ulong pc) | ||
129 | +{ | ||
130 | + ARMMMUFaultInfo fi = { .type = ARMFault_Alignment }; | ||
131 | + int target_el = exception_target_el(env); | ||
132 | + int mmu_idx = cpu_mmu_index(env, true); | ||
133 | + uint32_t fsc; | ||
134 | + | ||
135 | + env->exception.vaddress = pc; | ||
136 | + | ||
137 | + /* | ||
138 | + * Note that the fsc is not applicable to this exception, | ||
139 | + * since any syndrome is pcalignment not insn_abort. | ||
140 | + */ | ||
141 | + env->exception.fsr = compute_fsr_fsc(env, &fi, target_el, mmu_idx, &fsc); | ||
142 | + raise_exception(env, EXCP_PREFETCH_ABORT, syn_pcalignment(), target_el); | ||
143 | +} | ||
144 | + | ||
145 | #if !defined(CONFIG_USER_ONLY) | ||
146 | |||
147 | /* | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 148 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
16 | index XXXXXXX..XXXXXXX 100644 | 149 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 150 | --- a/target/arm/translate-a64.c |
18 | +++ b/target/arm/translate-a64.c | 151 | +++ b/target/arm/translate-a64.c |
19 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 152 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
20 | s->be_data | size | MO_ALIGN); | 153 | uint64_t pc = s->base.pc_next; |
21 | } | 154 | uint32_t insn; |
22 | 155 | ||
23 | +/* | 156 | + /* Singlestep exceptions have the highest priority. */ |
24 | + * PAC memory operations | 157 | if (s->ss_active && !s->pstate_ss) { |
25 | + * | 158 | /* Singlestep state is Active-pending. |
26 | + * 31 30 27 26 24 22 21 12 11 10 5 0 | 159 | * If we're in this state at the start of a TB then either |
27 | + * +------+-------+---+-----+-----+---+--------+---+---+----+-----+ | 160 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
28 | + * | size | 1 1 1 | V | 0 0 | M S | 1 | imm9 | W | 1 | Rn | Rt | | 161 | return; |
29 | + * +------+-------+---+-----+-----+---+--------+---+---+----+-----+ | 162 | } |
30 | + * | 163 | |
31 | + * Rt: the result register | 164 | + if (pc & 3) { |
32 | + * Rn: base address or SP | 165 | + /* |
33 | + * V: vector flag (always 0 as of v8.3) | 166 | + * PC alignment fault. This has priority over the instruction abort |
34 | + * M: clear for key DA, set for key DB | 167 | + * that we would receive from a translation fault via arm_ldl_code. |
35 | + * W: pre-indexing flag | 168 | + * This should only be possible after an indirect branch, at the |
36 | + * S: sign for imm9. | 169 | + * start of the TB. |
37 | + */ | 170 | + */ |
38 | +static void disas_ldst_pac(DisasContext *s, uint32_t insn, | 171 | + assert(s->base.num_insns == 1); |
39 | + int size, int rt, bool is_vector) | 172 | + gen_helper_exception_pc_alignment(cpu_env, tcg_constant_tl(pc)); |
40 | +{ | 173 | + s->base.is_jmp = DISAS_NORETURN; |
41 | + int rn = extract32(insn, 5, 5); | 174 | + s->base.pc_next = QEMU_ALIGN_UP(pc, 4); |
42 | + bool is_wback = extract32(insn, 11, 1); | ||
43 | + bool use_key_a = !extract32(insn, 23, 1); | ||
44 | + int offset; | ||
45 | + TCGv_i64 tcg_addr, tcg_rt; | ||
46 | + | ||
47 | + if (size != 3 || is_vector || !dc_isar_feature(aa64_pauth, s)) { | ||
48 | + unallocated_encoding(s); | ||
49 | + return; | 175 | + return; |
50 | + } | 176 | + } |
51 | + | 177 | + |
52 | + if (rn == 31) { | 178 | s->pc_curr = pc; |
53 | + gen_check_sp_alignment(s); | 179 | insn = arm_ldl_code(env, &s->base, pc, s->sctlr_b); |
180 | s->insn = insn; | ||
181 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
182 | index XXXXXXX..XXXXXXX 100644 | ||
183 | --- a/target/arm/translate.c | ||
184 | +++ b/target/arm/translate.c | ||
185 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
186 | uint32_t pc = dc->base.pc_next; | ||
187 | unsigned int insn; | ||
188 | |||
189 | - if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | ||
190 | + /* Singlestep exceptions have the highest priority. */ | ||
191 | + if (arm_check_ss_active(dc)) { | ||
192 | + dc->base.pc_next = pc + 4; | ||
193 | + return; | ||
54 | + } | 194 | + } |
55 | + tcg_addr = read_cpu_reg_sp(s, rn, 1); | 195 | + |
56 | + | 196 | + if (pc & 3) { |
57 | + if (s->pauth_active) { | 197 | + /* |
58 | + if (use_key_a) { | 198 | + * PC alignment fault. This has priority over the instruction abort |
59 | + gen_helper_autda(tcg_addr, cpu_env, tcg_addr, cpu_X[31]); | 199 | + * that we would receive from a translation fault via arm_ldl_code |
60 | + } else { | 200 | + * (or the execution of the kernelpage entrypoint). This should only |
61 | + gen_helper_autdb(tcg_addr, cpu_env, tcg_addr, cpu_X[31]); | 201 | + * be possible after an indirect branch, at the start of the TB. |
62 | + } | 202 | + */ |
203 | + assert(dc->base.num_insns == 1); | ||
204 | + gen_helper_exception_pc_alignment(cpu_env, tcg_constant_tl(pc)); | ||
205 | + dc->base.is_jmp = DISAS_NORETURN; | ||
206 | + dc->base.pc_next = QEMU_ALIGN_UP(pc, 4); | ||
207 | + return; | ||
63 | + } | 208 | + } |
64 | + | 209 | + |
65 | + /* Form the 10-bit signed, scaled offset. */ | 210 | + if (arm_check_kernelpage(dc)) { |
66 | + offset = (extract32(insn, 22, 1) << 9) | extract32(insn, 12, 9); | 211 | dc->base.pc_next = pc + 4; |
67 | + offset = sextract32(offset << size, 0, 10 + size); | 212 | return; |
68 | + tcg_gen_addi_i64(tcg_addr, tcg_addr, offset); | 213 | } |
69 | + | ||
70 | + tcg_rt = cpu_reg(s, rt); | ||
71 | + | ||
72 | + do_gpr_ld(s, tcg_rt, tcg_addr, size, /* is_signed */ false, | ||
73 | + /* extend */ false, /* iss_valid */ !is_wback, | ||
74 | + /* iss_srt */ rt, /* iss_sf */ true, /* iss_ar */ false); | ||
75 | + | ||
76 | + if (is_wback) { | ||
77 | + tcg_gen_mov_i64(cpu_reg_sp(s, rn), tcg_addr); | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | /* Load/store register (all forms) */ | ||
82 | static void disas_ldst_reg(DisasContext *s, uint32_t insn) | ||
83 | { | ||
84 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn) | ||
85 | case 2: | ||
86 | disas_ldst_reg_roffset(s, insn, opc, size, rt, is_vector); | ||
87 | return; | ||
88 | + default: | ||
89 | + disas_ldst_pac(s, insn, size, rt, is_vector); | ||
90 | + return; | ||
91 | } | ||
92 | break; | ||
93 | case 1: | ||
94 | -- | 214 | -- |
95 | 2.20.1 | 215 | 2.25.1 |
96 | 216 | ||
97 | 217 | 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 can perform this with fewer operations. | 3 | Misaligned thumb PC is architecturally impossible. |
4 | Assert is better than proceeding, in case we've missed | ||
5 | something somewhere. | ||
6 | |||
7 | Expand a comment about aligning the pc in gdbstub. | ||
8 | Fail an incoming migrate if a thumb pc is misaligned. | ||
4 | 9 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190108223129.5570-32-richard.henderson@linaro.org | ||
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/translate-a64.c | 62 +++++++++++++------------------------- | 14 | target/arm/gdbstub.c | 9 +++++++-- |
11 | 1 file changed, 21 insertions(+), 41 deletions(-) | 15 | target/arm/machine.c | 10 ++++++++++ |
16 | target/arm/translate.c | 3 +++ | ||
17 | 3 files changed, 20 insertions(+), 2 deletions(-) | ||
12 | 18 | ||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 19 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
14 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a64.c | 21 | --- a/target/arm/gdbstub.c |
16 | +++ b/target/arm/translate-a64.c | 22 | +++ b/target/arm/gdbstub.c |
17 | @@ -XXX,XX +XXX,XX @@ void gen_a64_set_pc_im(uint64_t val) | 23 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) |
18 | /* Load the PC from a generic TCG variable. | 24 | |
19 | * | 25 | tmp = ldl_p(mem_buf); |
20 | * If address tagging is enabled via the TCR TBI bits, then loading | 26 | |
21 | - * an address into the PC will clear out any tag in the it: | 27 | - /* Mask out low bit of PC to workaround gdb bugs. This will probably |
22 | + * an address into the PC will clear out any tag in it: | 28 | - cause problems if we ever implement the Jazelle DBX extensions. */ |
23 | * + for EL2 and EL3 there is only one TBI bit, and if it is set | 29 | + /* |
24 | * then the address is zero-extended, clearing bits [63:56] | 30 | + * Mask out low bits of PC to workaround gdb bugs. |
25 | * + for EL0 and EL1, TBI0 controls addresses with bit 55 == 0 | 31 | + * This avoids an assert in thumb_tr_translate_insn, because it is |
26 | @@ -XXX,XX +XXX,XX @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src) | 32 | + * architecturally impossible to misalign the pc. |
27 | int tbi = s->tbii; | 33 | + * This will probably cause problems if we ever implement the |
28 | 34 | + * Jazelle DBX extensions. | |
29 | if (s->current_el <= 1) { | 35 | + */ |
30 | - /* Test if NEITHER or BOTH TBI values are set. If so, no need to | 36 | if (n == 15) { |
31 | - * examine bit 55 of address, can just generate code. | 37 | tmp &= ~1; |
32 | - * If mixed, then test via generated code | 38 | } |
33 | - */ | 39 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
34 | - if (tbi == 3) { | 40 | index XXXXXXX..XXXXXXX 100644 |
35 | - TCGv_i64 tmp_reg = tcg_temp_new_i64(); | 41 | --- a/target/arm/machine.c |
36 | - /* Both bits set, sign extension from bit 55 into [63:56] will | 42 | +++ b/target/arm/machine.c |
37 | - * cover both cases | 43 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
38 | - */ | 44 | return -1; |
39 | - tcg_gen_shli_i64(tmp_reg, src, 8); | ||
40 | - tcg_gen_sari_i64(cpu_pc, tmp_reg, 8); | ||
41 | - tcg_temp_free_i64(tmp_reg); | ||
42 | - } else if (tbi == 0) { | ||
43 | - /* Neither bit set, just load it as-is */ | ||
44 | - tcg_gen_mov_i64(cpu_pc, src); | ||
45 | - } else { | ||
46 | - TCGv_i64 tcg_tmpval = tcg_temp_new_i64(); | ||
47 | - TCGv_i64 tcg_bit55 = tcg_temp_new_i64(); | ||
48 | - TCGv_i64 tcg_zero = tcg_const_i64(0); | ||
49 | + if (tbi != 0) { | ||
50 | + /* Sign-extend from bit 55. */ | ||
51 | + tcg_gen_sextract_i64(cpu_pc, src, 0, 56); | ||
52 | |||
53 | - tcg_gen_andi_i64(tcg_bit55, src, (1ull << 55)); | ||
54 | + if (tbi != 3) { | ||
55 | + TCGv_i64 tcg_zero = tcg_const_i64(0); | ||
56 | |||
57 | - if (tbi == 1) { | ||
58 | - /* tbi0==1, tbi1==0, so 0-fill upper byte if bit 55 = 0 */ | ||
59 | - tcg_gen_andi_i64(tcg_tmpval, src, | ||
60 | - 0x00FFFFFFFFFFFFFFull); | ||
61 | - tcg_gen_movcond_i64(TCG_COND_EQ, cpu_pc, tcg_bit55, tcg_zero, | ||
62 | - tcg_tmpval, src); | ||
63 | - } else { | ||
64 | - /* tbi0==0, tbi1==1, so 1-fill upper byte if bit 55 = 1 */ | ||
65 | - tcg_gen_ori_i64(tcg_tmpval, src, | ||
66 | - 0xFF00000000000000ull); | ||
67 | - tcg_gen_movcond_i64(TCG_COND_NE, cpu_pc, tcg_bit55, tcg_zero, | ||
68 | - tcg_tmpval, src); | ||
69 | + /* | ||
70 | + * The two TBI bits differ. | ||
71 | + * If tbi0, then !tbi1: only use the extension if positive. | ||
72 | + * if !tbi0, then tbi1: only use the extension if negative. | ||
73 | + */ | ||
74 | + tcg_gen_movcond_i64(tbi == 1 ? TCG_COND_GE : TCG_COND_LT, | ||
75 | + cpu_pc, cpu_pc, tcg_zero, cpu_pc, src); | ||
76 | + tcg_temp_free_i64(tcg_zero); | ||
77 | } | ||
78 | - tcg_temp_free_i64(tcg_zero); | ||
79 | - tcg_temp_free_i64(tcg_bit55); | ||
80 | - tcg_temp_free_i64(tcg_tmpval); | ||
81 | + return; | ||
82 | } | ||
83 | - } else { /* EL > 1 */ | ||
84 | + } else { | ||
85 | if (tbi != 0) { | ||
86 | /* Force tag byte to all zero */ | ||
87 | - tcg_gen_andi_i64(cpu_pc, src, 0x00FFFFFFFFFFFFFFull); | ||
88 | - } else { | ||
89 | - /* Load unmodified address */ | ||
90 | - tcg_gen_mov_i64(cpu_pc, src); | ||
91 | + tcg_gen_extract_i64(cpu_pc, src, 0, 56); | ||
92 | + return; | ||
93 | } | 45 | } |
94 | } | 46 | } |
95 | + | 47 | + |
96 | + /* Load unmodified address */ | 48 | + /* |
97 | + tcg_gen_mov_i64(cpu_pc, src); | 49 | + * Misaligned thumb pc is architecturally impossible. |
98 | } | 50 | + * We have an assert in thumb_tr_translate_insn to verify this. |
99 | 51 | + * Fail an incoming migrate to avoid this assert. | |
100 | typedef struct DisasCompare64 { | 52 | + */ |
53 | + if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { | ||
54 | + return -1; | ||
55 | + } | ||
56 | + | ||
57 | if (!kvm_enabled()) { | ||
58 | pmu_op_finish(&cpu->env); | ||
59 | } | ||
60 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/translate.c | ||
63 | +++ b/target/arm/translate.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
65 | uint32_t insn; | ||
66 | bool is_16bit; | ||
67 | |||
68 | + /* Misaligned thumb PC is architecturally impossible. */ | ||
69 | + assert((dc->base.pc_next & 1) == 0); | ||
70 | + | ||
71 | if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | ||
72 | dc->base.pc_next = pc + 2; | ||
73 | return; | ||
101 | -- | 74 | -- |
102 | 2.20.1 | 75 | 2.25.1 |
103 | 76 | ||
104 | 77 | 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 is not really functional yet, because the crypto is not yet | 3 | Both single-step and pc alignment faults have priority over |
4 | implemented. This, however follows the AddPAC pseudo function. | 4 | breakpoint exceptions. |
5 | 5 | ||
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: 20190108223129.5570-27-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/pauth_helper.c | 42 ++++++++++++++++++++++++++++++++++++++- | 10 | target/arm/debug_helper.c | 23 +++++++++++++++++++++++ |
12 | 1 file changed, 41 insertions(+), 1 deletion(-) | 11 | 1 file changed, 23 insertions(+) |
13 | 12 | ||
14 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | 13 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/pauth_helper.c | 15 | --- a/target/arm/debug_helper.c |
17 | +++ b/target/arm/pauth_helper.c | 16 | +++ b/target/arm/debug_helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_computepac(uint64_t data, uint64_t modifier, | 17 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_breakpoint(CPUState *cs) |
19 | static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | ||
20 | ARMPACKey *key, bool data) | ||
21 | { | 18 | { |
22 | - g_assert_not_reached(); /* FIXME */ | 19 | ARMCPU *cpu = ARM_CPU(cs); |
23 | + ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); | 20 | CPUARMState *env = &cpu->env; |
24 | + ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); | 21 | + target_ulong pc; |
25 | + uint64_t pac, ext_ptr, ext, test; | 22 | int n; |
26 | + int bot_bit, top_bit; | 23 | |
27 | + | 24 | /* |
28 | + /* If tagged pointers are in use, use ptr<55>, otherwise ptr<63>. */ | 25 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_breakpoint(CPUState *cs) |
29 | + if (param.tbi) { | 26 | return false; |
30 | + ext = sextract64(ptr, 55, 1); | 27 | } |
31 | + } else { | 28 | |
32 | + ext = sextract64(ptr, 63, 1); | ||
33 | + } | ||
34 | + | ||
35 | + /* Build a pointer with known good extension bits. */ | ||
36 | + top_bit = 64 - 8 * param.tbi; | ||
37 | + bot_bit = 64 - param.tsz; | ||
38 | + ext_ptr = deposit64(ptr, bot_bit, top_bit - bot_bit, ext); | ||
39 | + | ||
40 | + pac = pauth_computepac(ext_ptr, modifier, *key); | ||
41 | + | ||
42 | + /* | 29 | + /* |
43 | + * Check if the ptr has good extension bits and corrupt the | 30 | + * Single-step exceptions have priority over breakpoint exceptions. |
44 | + * pointer authentication code if not. | 31 | + * If single-step state is active-pending, suppress the bp. |
45 | + */ | 32 | + */ |
46 | + test = sextract64(ptr, bot_bit, top_bit - bot_bit); | 33 | + if (arm_singlestep_active(env) && !(env->pstate & PSTATE_SS)) { |
47 | + if (test != 0 && test != -1) { | 34 | + return false; |
48 | + pac ^= MAKE_64BIT_MASK(top_bit - 1, 1); | ||
49 | + } | 35 | + } |
50 | + | 36 | + |
51 | + /* | 37 | + /* |
52 | + * Preserve the determination between upper and lower at bit 55, | 38 | + * PC alignment faults have priority over breakpoint exceptions. |
53 | + * and insert pointer authentication code. | ||
54 | + */ | 39 | + */ |
55 | + if (param.tbi) { | 40 | + pc = is_a64(env) ? env->pc : env->regs[15]; |
56 | + ptr &= ~MAKE_64BIT_MASK(bot_bit, 55 - bot_bit + 1); | 41 | + if ((is_a64(env) || !env->thumb) && (pc & 3) != 0) { |
57 | + pac &= MAKE_64BIT_MASK(bot_bit, 54 - bot_bit + 1); | 42 | + return false; |
58 | + } else { | ||
59 | + ptr &= MAKE_64BIT_MASK(0, bot_bit); | ||
60 | + pac &= ~(MAKE_64BIT_MASK(55, 1) | MAKE_64BIT_MASK(0, bot_bit)); | ||
61 | + } | 43 | + } |
62 | + ext &= MAKE_64BIT_MASK(55, 1); | 44 | + |
63 | + return pac | ext | ptr; | 45 | + /* |
64 | } | 46 | + * Instruction aborts have priority over breakpoint exceptions. |
65 | 47 | + * TODO: We would need to look up the page for PC and verify that | |
66 | static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) | 48 | + * it is present and executable. |
49 | + */ | ||
50 | + | ||
51 | for (n = 0; n < ARRAY_SIZE(env->cpu_breakpoint); n++) { | ||
52 | if (bp_wp_matches(cpu, n, false)) { | ||
53 | return true; | ||
67 | -- | 54 | -- |
68 | 2.20.1 | 55 | 2.25.1 |
69 | 56 | ||
70 | 57 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20190108223129.5570-29-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 6 | --- |
8 | target/arm/helper.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ | 7 | tests/tcg/aarch64/pcalign-a64.c | 37 +++++++++++++++++++++++++ |
9 | 1 file changed, 70 insertions(+) | 8 | tests/tcg/arm/pcalign-a32.c | 46 +++++++++++++++++++++++++++++++ |
9 | tests/tcg/aarch64/Makefile.target | 4 +-- | ||
10 | tests/tcg/arm/Makefile.target | 4 +++ | ||
11 | 4 files changed, 89 insertions(+), 2 deletions(-) | ||
12 | create mode 100644 tests/tcg/aarch64/pcalign-a64.c | ||
13 | create mode 100644 tests/tcg/arm/pcalign-a32.c | ||
10 | 14 | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/tests/tcg/aarch64/pcalign-a64.c b/tests/tcg/aarch64/pcalign-a64.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | new file mode 100644 |
13 | --- a/target/arm/helper.c | 17 | index XXXXXXX..XXXXXXX |
14 | +++ b/target/arm/helper.c | 18 | --- /dev/null |
15 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_other(CPUARMState *env, | 19 | +++ b/tests/tcg/aarch64/pcalign-a64.c |
16 | return access_lor_ns(env); | 20 | @@ -XXX,XX +XXX,XX @@ |
17 | } | 21 | +/* Test PC misalignment exception */ |
18 | 22 | + | |
19 | +#ifdef TARGET_AARCH64 | 23 | +#include <assert.h> |
20 | +static CPAccessResult access_pauth(CPUARMState *env, const ARMCPRegInfo *ri, | 24 | +#include <signal.h> |
21 | + bool isread) | 25 | +#include <stdlib.h> |
26 | +#include <stdio.h> | ||
27 | + | ||
28 | +static void *expected; | ||
29 | + | ||
30 | +static void sigbus(int sig, siginfo_t *info, void *vuc) | ||
22 | +{ | 31 | +{ |
23 | + int el = arm_current_el(env); | 32 | + assert(info->si_code == BUS_ADRALN); |
24 | + | 33 | + assert(info->si_addr == expected); |
25 | + if (el < 2 && | 34 | + exit(EXIT_SUCCESS); |
26 | + arm_feature(env, ARM_FEATURE_EL2) && | ||
27 | + !(arm_hcr_el2_eff(env) & HCR_APK)) { | ||
28 | + return CP_ACCESS_TRAP_EL2; | ||
29 | + } | ||
30 | + if (el < 3 && | ||
31 | + arm_feature(env, ARM_FEATURE_EL3) && | ||
32 | + !(env->cp15.scr_el3 & SCR_APK)) { | ||
33 | + return CP_ACCESS_TRAP_EL3; | ||
34 | + } | ||
35 | + return CP_ACCESS_OK; | ||
36 | +} | 35 | +} |
37 | + | 36 | + |
38 | +static const ARMCPRegInfo pauth_reginfo[] = { | 37 | +int main() |
39 | + { .name = "APDAKEYLO_EL1", .state = ARM_CP_STATE_AA64, | 38 | +{ |
40 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 0, | 39 | + void *tmp; |
41 | + .access = PL1_RW, .accessfn = access_pauth, | 40 | + |
42 | + .fieldoffset = offsetof(CPUARMState, apda_key.lo) }, | 41 | + struct sigaction sa = { |
43 | + { .name = "APDAKEYHI_EL1", .state = ARM_CP_STATE_AA64, | 42 | + .sa_sigaction = sigbus, |
44 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 1, | 43 | + .sa_flags = SA_SIGINFO |
45 | + .access = PL1_RW, .accessfn = access_pauth, | 44 | + }; |
46 | + .fieldoffset = offsetof(CPUARMState, apda_key.hi) }, | 45 | + |
47 | + { .name = "APDBKEYLO_EL1", .state = ARM_CP_STATE_AA64, | 46 | + if (sigaction(SIGBUS, &sa, NULL) < 0) { |
48 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 2, | 47 | + perror("sigaction"); |
49 | + .access = PL1_RW, .accessfn = access_pauth, | 48 | + return EXIT_FAILURE; |
50 | + .fieldoffset = offsetof(CPUARMState, apdb_key.lo) }, | 49 | + } |
51 | + { .name = "APDBKEYHI_EL1", .state = ARM_CP_STATE_AA64, | 50 | + |
52 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 3, | 51 | + asm volatile("adr %0, 1f + 1\n\t" |
53 | + .access = PL1_RW, .accessfn = access_pauth, | 52 | + "str %0, %1\n\t" |
54 | + .fieldoffset = offsetof(CPUARMState, apdb_key.hi) }, | 53 | + "br %0\n" |
55 | + { .name = "APGAKEYLO_EL1", .state = ARM_CP_STATE_AA64, | 54 | + "1:" |
56 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 0, | 55 | + : "=&r"(tmp), "=m"(expected)); |
57 | + .access = PL1_RW, .accessfn = access_pauth, | 56 | + abort(); |
58 | + .fieldoffset = offsetof(CPUARMState, apga_key.lo) }, | 57 | +} |
59 | + { .name = "APGAKEYHI_EL1", .state = ARM_CP_STATE_AA64, | 58 | diff --git a/tests/tcg/arm/pcalign-a32.c b/tests/tcg/arm/pcalign-a32.c |
60 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 1, | 59 | new file mode 100644 |
61 | + .access = PL1_RW, .accessfn = access_pauth, | 60 | index XXXXXXX..XXXXXXX |
62 | + .fieldoffset = offsetof(CPUARMState, apga_key.hi) }, | 61 | --- /dev/null |
63 | + { .name = "APIAKEYLO_EL1", .state = ARM_CP_STATE_AA64, | 62 | +++ b/tests/tcg/arm/pcalign-a32.c |
64 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 0, | 63 | @@ -XXX,XX +XXX,XX @@ |
65 | + .access = PL1_RW, .accessfn = access_pauth, | 64 | +/* Test PC misalignment exception */ |
66 | + .fieldoffset = offsetof(CPUARMState, apia_key.lo) }, | 65 | + |
67 | + { .name = "APIAKEYHI_EL1", .state = ARM_CP_STATE_AA64, | 66 | +#ifdef __thumb__ |
68 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 1, | 67 | +#error "This test must be compiled for ARM" |
69 | + .access = PL1_RW, .accessfn = access_pauth, | ||
70 | + .fieldoffset = offsetof(CPUARMState, apia_key.hi) }, | ||
71 | + { .name = "APIBKEYLO_EL1", .state = ARM_CP_STATE_AA64, | ||
72 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 2, | ||
73 | + .access = PL1_RW, .accessfn = access_pauth, | ||
74 | + .fieldoffset = offsetof(CPUARMState, apib_key.lo) }, | ||
75 | + { .name = "APIBKEYHI_EL1", .state = ARM_CP_STATE_AA64, | ||
76 | + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3, | ||
77 | + .access = PL1_RW, .accessfn = access_pauth, | ||
78 | + .fieldoffset = offsetof(CPUARMState, apib_key.hi) }, | ||
79 | + REGINFO_SENTINEL | ||
80 | +}; | ||
81 | +#endif | 68 | +#endif |
82 | + | 69 | + |
83 | void register_cp_regs_for_features(ARMCPU *cpu) | 70 | +#include <assert.h> |
84 | { | 71 | +#include <signal.h> |
85 | /* Register all the coprocessor registers based on feature bits */ | 72 | +#include <stdlib.h> |
86 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 73 | +#include <stdio.h> |
87 | define_one_arm_cp_reg(cpu, &zcr_el3_reginfo); | ||
88 | } | ||
89 | } | ||
90 | + | 74 | + |
91 | +#ifdef TARGET_AARCH64 | 75 | +static void *expected; |
92 | + if (cpu_isar_feature(aa64_pauth, cpu)) { | 76 | + |
93 | + define_arm_cp_regs(cpu, pauth_reginfo); | 77 | +static void sigbus(int sig, siginfo_t *info, void *vuc) |
78 | +{ | ||
79 | + assert(info->si_code == BUS_ADRALN); | ||
80 | + assert(info->si_addr == expected); | ||
81 | + exit(EXIT_SUCCESS); | ||
82 | +} | ||
83 | + | ||
84 | +int main() | ||
85 | +{ | ||
86 | + void *tmp; | ||
87 | + | ||
88 | + struct sigaction sa = { | ||
89 | + .sa_sigaction = sigbus, | ||
90 | + .sa_flags = SA_SIGINFO | ||
91 | + }; | ||
92 | + | ||
93 | + if (sigaction(SIGBUS, &sa, NULL) < 0) { | ||
94 | + perror("sigaction"); | ||
95 | + return EXIT_FAILURE; | ||
94 | + } | 96 | + } |
95 | +#endif | 97 | + |
96 | } | 98 | + asm volatile("adr %0, 1f + 2\n\t" |
97 | 99 | + "str %0, %1\n\t" | |
98 | void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | 100 | + "bx %0\n" |
101 | + "1:" | ||
102 | + : "=&r"(tmp), "=m"(expected)); | ||
103 | + | ||
104 | + /* | ||
105 | + * From v8, it is CONSTRAINED UNPREDICTABLE whether BXWritePC aligns | ||
106 | + * the address or not. If so, we can legitimately fall through. | ||
107 | + */ | ||
108 | + return EXIT_SUCCESS; | ||
109 | +} | ||
110 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/tests/tcg/aarch64/Makefile.target | ||
113 | +++ b/tests/tcg/aarch64/Makefile.target | ||
114 | @@ -XXX,XX +XXX,XX @@ VPATH += $(ARM_SRC) | ||
115 | AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 | ||
116 | VPATH += $(AARCH64_SRC) | ||
117 | |||
118 | -# Float-convert Tests | ||
119 | -AARCH64_TESTS=fcvt | ||
120 | +# Base architecture tests | ||
121 | +AARCH64_TESTS=fcvt pcalign-a64 | ||
122 | |||
123 | fcvt: LDFLAGS+=-lm | ||
124 | |||
125 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/tests/tcg/arm/Makefile.target | ||
128 | +++ b/tests/tcg/arm/Makefile.target | ||
129 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | ||
130 | $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") | ||
131 | $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) | ||
132 | |||
133 | +# PC alignment test | ||
134 | +ARM_TESTS += pcalign-a32 | ||
135 | +pcalign-a32: CFLAGS+=-marm | ||
136 | + | ||
137 | ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) | ||
138 | |||
139 | # Semihosting smoke test for linux-user | ||
99 | -- | 140 | -- |
100 | 2.20.1 | 141 | 2.25.1 |
101 | 142 | ||
102 | 143 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | In the SSE decode function gen_sse(), we combine a byte |
---|---|---|---|
2 | 'b' and a value 'b1' which can be [0..3], and switch on them: | ||
3 | b |= (b1 << 8); | ||
4 | switch (b) { | ||
5 | ... | ||
6 | default: | ||
7 | unknown_op: | ||
8 | gen_unknown_opcode(env, s); | ||
9 | return; | ||
10 | } | ||
2 | 11 | ||
3 | This commit doesn't add any supported events, but provides the framework | 12 | In three cases inside this switch, we were then also checking for |
4 | for adding them. We store the pm_event structs in a simple array, and | 13 | "if (b1 >= 2) { goto unknown_op; }". |
5 | provide the mapping from the event numbers to array indexes in the | 14 | However, this can never happen, because the 'case' values in each place |
6 | supported_event_map array. Because the value of PMCEID[01] depends upon | 15 | are 0x0nn or 0x1nn and the switch will have directed the b1 == (2, 3) |
7 | which events are supported at runtime, generate it dynamically. | 16 | cases to the default already. |
8 | 17 | ||
9 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 18 | This check was added in commit c045af25a52e9 in 2010; the added code |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 19 | was unnecessary then as well, and was apparently intended only to |
11 | Message-id: 20181211151945.29137-10-aaron@os.amperecomputing.com | 20 | ensure that we never accidentally ended up indexing off the end |
21 | of an sse_op_table with only 2 entries as a result of future bugs | ||
22 | in the decode logic. | ||
23 | |||
24 | Change the checks to assert() instead, and make sure they're always | ||
25 | immediately before the array access they are protecting. | ||
26 | |||
27 | Fixes: Coverity CID 1460207 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | --- | 30 | --- |
14 | target/arm/cpu.h | 10 ++++++++ | 31 | target/i386/tcg/translate.c | 12 +++--------- |
15 | target/arm/cpu.c | 19 +++++++++------ | 32 | 1 file changed, 3 insertions(+), 9 deletions(-) |
16 | target/arm/cpu64.c | 4 ---- | ||
17 | target/arm/helper.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ | ||
18 | 4 files changed, 79 insertions(+), 11 deletions(-) | ||
19 | 33 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 34 | diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c |
21 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 36 | --- a/target/i386/tcg/translate.c |
23 | +++ b/target/arm/cpu.h | 37 | +++ b/target/i386/tcg/translate.c |
24 | @@ -XXX,XX +XXX,XX @@ void pmu_op_finish(CPUARMState *env); | 38 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, |
25 | void pmu_pre_el_change(ARMCPU *cpu, void *ignored); | 39 | case 0x171: /* shift xmm, im */ |
26 | void pmu_post_el_change(ARMCPU *cpu, void *ignored); | 40 | case 0x172: |
27 | 41 | case 0x173: | |
28 | +/* | 42 | - if (b1 >= 2) { |
29 | + * get_pmceid | 43 | - goto unknown_op; |
30 | + * @env: CPUARMState | 44 | - } |
31 | + * @which: which PMCEID register to return (0 or 1) | 45 | val = x86_ldub_code(env, s); |
32 | + * | 46 | if (is_xmm) { |
33 | + * Return the PMCEID[01]_EL0 register values corresponding to the counters | 47 | tcg_gen_movi_tl(s->T0, val); |
34 | + * which are supported given the current configuration | 48 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, |
35 | + */ | 49 | offsetof(CPUX86State, mmx_t0.MMX_L(1))); |
36 | +uint64_t get_pmceid(CPUARMState *env, unsigned which); | 50 | op1_offset = offsetof(CPUX86State,mmx_t0); |
37 | + | 51 | } |
38 | /* SCTLR bit meanings. Several bits have been reused in newer | 52 | + assert(b1 < 2); |
39 | * versions of the architecture; in that case we define constants | 53 | sse_fn_epp = sse_op_table2[((b - 1) & 3) * 8 + |
40 | * for both old and new bit meanings. Code which tests against those | 54 | (((modrm >> 3)) & 7)][b1]; |
41 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 55 | if (!sse_fn_epp) { |
42 | index XXXXXXX..XXXXXXX 100644 | 56 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, |
43 | --- a/target/arm/cpu.c | 57 | rm = modrm & 7; |
44 | +++ b/target/arm/cpu.c | 58 | reg = ((modrm >> 3) & 7) | REX_R(s); |
45 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 59 | mod = (modrm >> 6) & 3; |
46 | 60 | - if (b1 >= 2) { | |
47 | if (!cpu->has_pmu) { | 61 | - goto unknown_op; |
48 | unset_feature(env, ARM_FEATURE_PMU); | 62 | - } |
49 | + } | 63 | |
50 | + if (arm_feature(env, ARM_FEATURE_PMU)) { | 64 | + assert(b1 < 2); |
51 | + cpu->pmceid0 = get_pmceid(&cpu->env, 0); | 65 | sse_fn_epp = sse_op_table6[b].op[b1]; |
52 | + cpu->pmceid1 = get_pmceid(&cpu->env, 1); | 66 | if (!sse_fn_epp) { |
53 | + | 67 | goto unknown_op; |
54 | + if (!kvm_enabled()) { | 68 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, |
55 | + arm_register_pre_el_change_hook(cpu, &pmu_pre_el_change, 0); | 69 | rm = modrm & 7; |
56 | + arm_register_el_change_hook(cpu, &pmu_post_el_change, 0); | 70 | reg = ((modrm >> 3) & 7) | REX_R(s); |
57 | + } | 71 | mod = (modrm >> 6) & 3; |
58 | + } else { | 72 | - if (b1 >= 2) { |
59 | cpu->id_aa64dfr0 &= ~0xf00; | 73 | - goto unknown_op; |
60 | - } else if (!kvm_enabled()) { | 74 | - } |
61 | - arm_register_pre_el_change_hook(cpu, &pmu_pre_el_change, 0); | 75 | |
62 | - arm_register_el_change_hook(cpu, &pmu_post_el_change, 0); | 76 | + assert(b1 < 2); |
63 | + cpu->pmceid0 = 0; | 77 | sse_fn_eppi = sse_op_table7[b].op[b1]; |
64 | + cpu->pmceid1 = 0; | 78 | if (!sse_fn_eppi) { |
65 | } | 79 | goto unknown_op; |
66 | |||
67 | if (!arm_feature(env, ARM_FEATURE_EL2)) { | ||
68 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
69 | cpu->id_pfr0 = 0x00001131; | ||
70 | cpu->id_pfr1 = 0x00011011; | ||
71 | cpu->id_dfr0 = 0x02010555; | ||
72 | - cpu->pmceid0 = 0x00000000; | ||
73 | - cpu->pmceid1 = 0x00000000; | ||
74 | cpu->id_afr0 = 0x00000000; | ||
75 | cpu->id_mmfr0 = 0x10101105; | ||
76 | cpu->id_mmfr1 = 0x40000000; | ||
77 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
78 | cpu->id_pfr0 = 0x00001131; | ||
79 | cpu->id_pfr1 = 0x00011011; | ||
80 | cpu->id_dfr0 = 0x02010555; | ||
81 | - cpu->pmceid0 = 0x0000000; | ||
82 | - cpu->pmceid1 = 0x00000000; | ||
83 | cpu->id_afr0 = 0x00000000; | ||
84 | cpu->id_mmfr0 = 0x10201105; | ||
85 | cpu->id_mmfr1 = 0x20000000; | ||
86 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/arm/cpu64.c | ||
89 | +++ b/target/arm/cpu64.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
91 | cpu->isar.id_isar6 = 0; | ||
92 | cpu->isar.id_aa64pfr0 = 0x00002222; | ||
93 | cpu->id_aa64dfr0 = 0x10305106; | ||
94 | - cpu->pmceid0 = 0x00000000; | ||
95 | - cpu->pmceid1 = 0x00000000; | ||
96 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
97 | cpu->isar.id_aa64mmfr0 = 0x00001124; | ||
98 | cpu->dbgdidr = 0x3516d000; | ||
99 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
100 | cpu->isar.id_isar5 = 0x00011121; | ||
101 | cpu->isar.id_aa64pfr0 = 0x00002222; | ||
102 | cpu->id_aa64dfr0 = 0x10305106; | ||
103 | - cpu->pmceid0 = 0x00000000; | ||
104 | - cpu->pmceid1 = 0x00000000; | ||
105 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
106 | cpu->isar.id_aa64mmfr0 = 0x00001124; | ||
107 | cpu->dbgdidr = 0x3516d000; | ||
108 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/target/arm/helper.c | ||
111 | +++ b/target/arm/helper.c | ||
112 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t pmu_counter_mask(CPUARMState *env) | ||
113 | return (1 << 31) | ((1 << pmu_num_counters(env)) - 1); | ||
114 | } | ||
115 | |||
116 | +typedef struct pm_event { | ||
117 | + uint16_t number; /* PMEVTYPER.evtCount is 16 bits wide */ | ||
118 | + /* If the event is supported on this CPU (used to generate PMCEID[01]) */ | ||
119 | + bool (*supported)(CPUARMState *); | ||
120 | + /* | ||
121 | + * Retrieve the current count of the underlying event. The programmed | ||
122 | + * counters hold a difference from the return value from this function | ||
123 | + */ | ||
124 | + uint64_t (*get_count)(CPUARMState *); | ||
125 | +} pm_event; | ||
126 | + | ||
127 | +static const pm_event pm_events[] = { | ||
128 | +}; | ||
129 | + | ||
130 | +/* | ||
131 | + * Note: Before increasing MAX_EVENT_ID beyond 0x3f into the 0x40xx range of | ||
132 | + * events (i.e. the statistical profiling extension), this implementation | ||
133 | + * should first be updated to something sparse instead of the current | ||
134 | + * supported_event_map[] array. | ||
135 | + */ | ||
136 | +#define MAX_EVENT_ID 0x0 | ||
137 | +#define UNSUPPORTED_EVENT UINT16_MAX | ||
138 | +static uint16_t supported_event_map[MAX_EVENT_ID + 1]; | ||
139 | + | ||
140 | +/* | ||
141 | + * Called upon initialization to build PMCEID0_EL0 or PMCEID1_EL0 (indicated by | ||
142 | + * 'which'). We also use it to build a map of ARM event numbers to indices in | ||
143 | + * our pm_events array. | ||
144 | + * | ||
145 | + * Note: Events in the 0x40XX range are not currently supported. | ||
146 | + */ | ||
147 | +uint64_t get_pmceid(CPUARMState *env, unsigned which) | ||
148 | +{ | ||
149 | + uint64_t pmceid = 0; | ||
150 | + unsigned int i; | ||
151 | + | ||
152 | + assert(which <= 1); | ||
153 | + | ||
154 | + for (i = 0; i < ARRAY_SIZE(supported_event_map); i++) { | ||
155 | + supported_event_map[i] = UNSUPPORTED_EVENT; | ||
156 | + } | ||
157 | + | ||
158 | + for (i = 0; i < ARRAY_SIZE(pm_events); i++) { | ||
159 | + const pm_event *cnt = &pm_events[i]; | ||
160 | + assert(cnt->number <= MAX_EVENT_ID); | ||
161 | + /* We do not currently support events in the 0x40xx range */ | ||
162 | + assert(cnt->number <= 0x3f); | ||
163 | + | ||
164 | + if ((cnt->number & 0x20) == (which << 6) && | ||
165 | + cnt->supported(env)) { | ||
166 | + pmceid |= (1 << (cnt->number & 0x1f)); | ||
167 | + supported_event_map[cnt->number] = i; | ||
168 | + } | ||
169 | + } | ||
170 | + return pmceid; | ||
171 | +} | ||
172 | + | ||
173 | static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
174 | bool isread) | ||
175 | { | ||
176 | -- | 80 | -- |
177 | 2.20.1 | 81 | 2.25.1 |
178 | 82 | ||
179 | 83 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | The qemu-common.h header is not supposed to be included from any |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | ||
3 | the start of it). | ||
2 | 4 | ||
3 | Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com> | 5 | include/hw/i386/x86.h and include/hw/i386/microvm.h break this rule. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | In fact, the include is not required at all, so we can just drop it |
5 | Message-id: 20181211151945.29137-9-aaron@os.amperecomputing.com | 7 | from both files. |
8 | |||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Message-id: 20211129200510.1233037-2-peter.maydell@linaro.org | ||
7 | --- | 13 | --- |
8 | target/arm/cpu.h | 4 ++-- | 14 | include/hw/i386/microvm.h | 1 - |
9 | target/arm/helper.c | 19 +++++++++++++++++-- | 15 | include/hw/i386/x86.h | 1 - |
10 | 2 files changed, 19 insertions(+), 4 deletions(-) | 16 | 2 files changed, 2 deletions(-) |
11 | 17 | ||
12 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h |
13 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/cpu.h | 20 | --- a/include/hw/i386/microvm.h |
15 | +++ b/target/arm/cpu.h | 21 | +++ b/include/hw/i386/microvm.h |
16 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 22 | @@ -XXX,XX +XXX,XX @@ |
17 | uint32_t id_pfr0; | 23 | #ifndef HW_I386_MICROVM_H |
18 | uint32_t id_pfr1; | 24 | #define HW_I386_MICROVM_H |
19 | uint32_t id_dfr0; | 25 | |
20 | - uint32_t pmceid0; | 26 | -#include "qemu-common.h" |
21 | - uint32_t pmceid1; | 27 | #include "exec/hwaddr.h" |
22 | + uint64_t pmceid0; | 28 | #include "qemu/notify.h" |
23 | + uint64_t pmceid1; | 29 | |
24 | uint32_t id_afr0; | 30 | diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h |
25 | uint32_t id_mmfr0; | ||
26 | uint32_t id_mmfr1; | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/helper.c | 32 | --- a/include/hw/i386/x86.h |
30 | +++ b/target/arm/helper.c | 33 | +++ b/include/hw/i386/x86.h |
31 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 34 | @@ -XXX,XX +XXX,XX @@ |
32 | } else { | 35 | #ifndef HW_I386_X86_H |
33 | define_arm_cp_regs(cpu, not_v7_cp_reginfo); | 36 | #define HW_I386_X86_H |
34 | } | 37 | |
35 | + if (FIELD_EX32(cpu->id_dfr0, ID_DFR0, PERFMON) >= 4 && | 38 | -#include "qemu-common.h" |
36 | + FIELD_EX32(cpu->id_dfr0, ID_DFR0, PERFMON) != 0xf) { | 39 | #include "exec/hwaddr.h" |
37 | + ARMCPRegInfo v81_pmu_regs[] = { | 40 | #include "qemu/notify.h" |
38 | + { .name = "PMCEID2", .state = ARM_CP_STATE_AA32, | 41 | |
39 | + .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 4, | ||
40 | + .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
41 | + .resetvalue = extract64(cpu->pmceid0, 32, 32) }, | ||
42 | + { .name = "PMCEID3", .state = ARM_CP_STATE_AA32, | ||
43 | + .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5, | ||
44 | + .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
45 | + .resetvalue = extract64(cpu->pmceid1, 32, 32) }, | ||
46 | + REGINFO_SENTINEL | ||
47 | + }; | ||
48 | + define_arm_cp_regs(cpu, v81_pmu_regs); | ||
49 | + } | ||
50 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
51 | /* AArch64 ID registers, which all have impdef reset values. | ||
52 | * Note that within the ID register ranges the unused slots | ||
53 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
54 | { .name = "PMCEID0", .state = ARM_CP_STATE_AA32, | ||
55 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 6, | ||
56 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
57 | - .resetvalue = cpu->pmceid0 }, | ||
58 | + .resetvalue = extract64(cpu->pmceid0, 0, 32) }, | ||
59 | { .name = "PMCEID0_EL0", .state = ARM_CP_STATE_AA64, | ||
60 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 6, | ||
61 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
62 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
63 | { .name = "PMCEID1", .state = ARM_CP_STATE_AA32, | ||
64 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 7, | ||
65 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
66 | - .resetvalue = cpu->pmceid1 }, | ||
67 | + .resetvalue = extract64(cpu->pmceid1, 0, 32) }, | ||
68 | { .name = "PMCEID1_EL0", .state = ARM_CP_STATE_AA64, | ||
69 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7, | ||
70 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
71 | -- | 42 | -- |
72 | 2.20.1 | 43 | 2.25.1 |
73 | 44 | ||
74 | 45 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | The qemu-common.h header is not supposed to be included from any |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | ||
3 | the start of it). | ||
2 | 4 | ||
3 | This is immediately necessary for the PMUv3 implementation to check | 5 | Move the include to linux-user/hexagon/cpu_loop.c, which needs it for |
4 | ID_DFR0.PerfMon to enable/disable specific features, but defines the | 6 | the declaration of cpu_exec_step_atomic(). |
5 | full complement of fields for possible future use elsewhere. | ||
6 | 7 | ||
7 | Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20181211151945.29137-8-aaron@os.amperecomputing.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | ||
12 | Message-id: 20211129200510.1233037-3-peter.maydell@linaro.org | ||
11 | --- | 13 | --- |
12 | target/arm/cpu.h | 9 +++++++++ | 14 | target/hexagon/cpu.h | 1 - |
13 | 1 file changed, 9 insertions(+) | 15 | linux-user/hexagon/cpu_loop.c | 1 + |
16 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
14 | 17 | ||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/cpu.h | 20 | --- a/target/hexagon/cpu.h |
18 | +++ b/target/arm/cpu.h | 21 | +++ b/target/hexagon/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64MMFR1, PAN, 20, 4) | 22 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUHexagonState CPUHexagonState; |
20 | FIELD(ID_AA64MMFR1, SPECSEI, 24, 4) | 23 | |
21 | FIELD(ID_AA64MMFR1, XNX, 28, 4) | 24 | #include "fpu/softfloat-types.h" |
22 | 25 | ||
23 | +FIELD(ID_DFR0, COPDBG, 0, 4) | 26 | -#include "qemu-common.h" |
24 | +FIELD(ID_DFR0, COPSDBG, 4, 4) | 27 | #include "exec/cpu-defs.h" |
25 | +FIELD(ID_DFR0, MMAPDBG, 8, 4) | 28 | #include "hex_regs.h" |
26 | +FIELD(ID_DFR0, COPTRC, 12, 4) | 29 | #include "mmvec/mmvec.h" |
27 | +FIELD(ID_DFR0, MMAPTRC, 16, 4) | 30 | diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c |
28 | +FIELD(ID_DFR0, MPROFDBG, 20, 4) | 31 | index XXXXXXX..XXXXXXX 100644 |
29 | +FIELD(ID_DFR0, PERFMON, 24, 4) | 32 | --- a/linux-user/hexagon/cpu_loop.c |
30 | +FIELD(ID_DFR0, TRACEFILT, 28, 4) | 33 | +++ b/linux-user/hexagon/cpu_loop.c |
31 | + | 34 | @@ -XXX,XX +XXX,XX @@ |
32 | QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK); | 35 | */ |
33 | 36 | ||
34 | /* If adding a feature bit which corresponds to a Linux ELF | 37 | #include "qemu/osdep.h" |
38 | +#include "qemu-common.h" | ||
39 | #include "qemu.h" | ||
40 | #include "user-internals.h" | ||
41 | #include "cpu_loop-common.h" | ||
35 | -- | 42 | -- |
36 | 2.20.1 | 43 | 2.25.1 |
37 | 44 | ||
38 | 45 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The qemu-common.h header is not supposed to be included from any |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | ||
3 | the start of it). | ||
2 | 4 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Nothing actually relies on target/rx/cpu.h including it, so we can |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | just drop the include. |
5 | Message-id: 20190108223129.5570-7-richard.henderson@linaro.org | 7 | |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | ||
12 | Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> | ||
13 | Message-id: 20211129200510.1233037-4-peter.maydell@linaro.org | ||
7 | --- | 14 | --- |
8 | target/arm/translate-a64.c | 93 +++++++++++++++++++++++++++++++++----- | 15 | target/rx/cpu.h | 1 - |
9 | 1 file changed, 81 insertions(+), 12 deletions(-) | 16 | 1 file changed, 1 deletion(-) |
10 | 17 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 18 | diff --git a/target/rx/cpu.h b/target/rx/cpu.h |
12 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 20 | --- a/target/rx/cpu.h |
14 | +++ b/target/arm/translate-a64.c | 21 | +++ b/target/rx/cpu.h |
15 | @@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn, | 22 | @@ -XXX,XX +XXX,XX @@ |
16 | } | 23 | #define RX_CPU_H |
17 | 24 | ||
18 | switch (selector) { | 25 | #include "qemu/bitops.h" |
19 | - case 0: /* NOP */ | 26 | -#include "qemu-common.h" |
20 | - return; | 27 | #include "hw/registerfields.h" |
21 | - case 3: /* WFI */ | 28 | #include "cpu-qom.h" |
22 | + case 0b00000: /* NOP */ | ||
23 | + break; | ||
24 | + case 0b00011: /* WFI */ | ||
25 | s->base.is_jmp = DISAS_WFI; | ||
26 | - return; | ||
27 | + break; | ||
28 | + case 0b00001: /* YIELD */ | ||
29 | /* When running in MTTCG we don't generate jumps to the yield and | ||
30 | * WFE helpers as it won't affect the scheduling of other vCPUs. | ||
31 | * If we wanted to more completely model WFE/SEV so we don't busy | ||
32 | * spin unnecessarily we would need to do something more involved. | ||
33 | */ | ||
34 | - case 1: /* YIELD */ | ||
35 | if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
36 | s->base.is_jmp = DISAS_YIELD; | ||
37 | } | ||
38 | - return; | ||
39 | - case 2: /* WFE */ | ||
40 | + break; | ||
41 | + case 0b00010: /* WFE */ | ||
42 | if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
43 | s->base.is_jmp = DISAS_WFE; | ||
44 | } | ||
45 | - return; | ||
46 | - case 4: /* SEV */ | ||
47 | - case 5: /* SEVL */ | ||
48 | + break; | ||
49 | + case 0b00100: /* SEV */ | ||
50 | + case 0b00101: /* SEVL */ | ||
51 | /* we treat all as NOP at least for now */ | ||
52 | - return; | ||
53 | + break; | ||
54 | + case 0b00111: /* XPACLRI */ | ||
55 | + if (s->pauth_active) { | ||
56 | + gen_helper_xpaci(cpu_X[30], cpu_env, cpu_X[30]); | ||
57 | + } | ||
58 | + break; | ||
59 | + case 0b01000: /* PACIA1716 */ | ||
60 | + if (s->pauth_active) { | ||
61 | + gen_helper_pacia(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
62 | + } | ||
63 | + break; | ||
64 | + case 0b01010: /* PACIB1716 */ | ||
65 | + if (s->pauth_active) { | ||
66 | + gen_helper_pacib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
67 | + } | ||
68 | + break; | ||
69 | + case 0b01100: /* AUTIA1716 */ | ||
70 | + if (s->pauth_active) { | ||
71 | + gen_helper_autia(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
72 | + } | ||
73 | + break; | ||
74 | + case 0b01110: /* AUTIB1716 */ | ||
75 | + if (s->pauth_active) { | ||
76 | + gen_helper_autib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
77 | + } | ||
78 | + break; | ||
79 | + case 0b11000: /* PACIAZ */ | ||
80 | + if (s->pauth_active) { | ||
81 | + gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], | ||
82 | + new_tmp_a64_zero(s)); | ||
83 | + } | ||
84 | + break; | ||
85 | + case 0b11001: /* PACIASP */ | ||
86 | + if (s->pauth_active) { | ||
87 | + gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
88 | + } | ||
89 | + break; | ||
90 | + case 0b11010: /* PACIBZ */ | ||
91 | + if (s->pauth_active) { | ||
92 | + gen_helper_pacib(cpu_X[30], cpu_env, cpu_X[30], | ||
93 | + new_tmp_a64_zero(s)); | ||
94 | + } | ||
95 | + break; | ||
96 | + case 0b11011: /* PACIBSP */ | ||
97 | + if (s->pauth_active) { | ||
98 | + gen_helper_pacib(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
99 | + } | ||
100 | + break; | ||
101 | + case 0b11100: /* AUTIAZ */ | ||
102 | + if (s->pauth_active) { | ||
103 | + gen_helper_autia(cpu_X[30], cpu_env, cpu_X[30], | ||
104 | + new_tmp_a64_zero(s)); | ||
105 | + } | ||
106 | + break; | ||
107 | + case 0b11101: /* AUTIASP */ | ||
108 | + if (s->pauth_active) { | ||
109 | + gen_helper_autia(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
110 | + } | ||
111 | + break; | ||
112 | + case 0b11110: /* AUTIBZ */ | ||
113 | + if (s->pauth_active) { | ||
114 | + gen_helper_autib(cpu_X[30], cpu_env, cpu_X[30], | ||
115 | + new_tmp_a64_zero(s)); | ||
116 | + } | ||
117 | + break; | ||
118 | + case 0b11111: /* AUTIBSP */ | ||
119 | + if (s->pauth_active) { | ||
120 | + gen_helper_autib(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
121 | + } | ||
122 | + break; | ||
123 | default: | ||
124 | /* default specified as NOP equivalent */ | ||
125 | - return; | ||
126 | + break; | ||
127 | } | ||
128 | } | ||
129 | 29 | ||
130 | -- | 30 | -- |
131 | 2.20.1 | 31 | 2.25.1 |
132 | 32 | ||
133 | 33 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | A lot of C files in hw/arm include qemu-common.h when they don't |
---|---|---|---|
2 | need anything from it. Drop the include lines. | ||
2 | 3 | ||
3 | Add an array for PMOVSSET so we only define it for v7ve+ platforms | 4 | omap1.c, pxa2xx.c and strongarm.c retain the include because they |
5 | use it for the prototype of qemu_get_timedate(). | ||
4 | 6 | ||
5 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20181211151945.29137-7-aaron@os.amperecomputing.com | 9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> |
11 | Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> | ||
12 | Message-id: 20211129200510.1233037-5-peter.maydell@linaro.org | ||
9 | --- | 13 | --- |
10 | target/arm/helper.c | 28 ++++++++++++++++++++++++++++ | 14 | hw/arm/boot.c | 1 - |
11 | 1 file changed, 28 insertions(+) | 15 | hw/arm/digic_boards.c | 1 - |
16 | hw/arm/highbank.c | 1 - | ||
17 | hw/arm/npcm7xx_boards.c | 1 - | ||
18 | hw/arm/sbsa-ref.c | 1 - | ||
19 | hw/arm/stm32f405_soc.c | 1 - | ||
20 | hw/arm/vexpress.c | 1 - | ||
21 | hw/arm/virt.c | 1 - | ||
22 | 8 files changed, 8 deletions(-) | ||
12 | 23 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 24 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c |
14 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 26 | --- a/hw/arm/boot.c |
16 | +++ b/target/arm/helper.c | 27 | +++ b/hw/arm/boot.c |
17 | @@ -XXX,XX +XXX,XX @@ static void pmovsr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 28 | @@ -XXX,XX +XXX,XX @@ |
18 | env->cp15.c9_pmovsr &= ~value; | 29 | */ |
19 | } | 30 | |
20 | 31 | #include "qemu/osdep.h" | |
21 | +static void pmovsset_write(CPUARMState *env, const ARMCPRegInfo *ri, | 32 | -#include "qemu-common.h" |
22 | + uint64_t value) | 33 | #include "qemu/datadir.h" |
23 | +{ | 34 | #include "qemu/error-report.h" |
24 | + value &= pmu_counter_mask(env); | 35 | #include "qapi/error.h" |
25 | + env->cp15.c9_pmovsr |= value; | 36 | diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c |
26 | +} | 37 | index XXXXXXX..XXXXXXX 100644 |
27 | + | 38 | --- a/hw/arm/digic_boards.c |
28 | static void pmxevtyper_write(CPUARMState *env, const ARMCPRegInfo *ri, | 39 | +++ b/hw/arm/digic_boards.c |
29 | uint64_t value) | 40 | @@ -XXX,XX +XXX,XX @@ |
30 | { | 41 | |
31 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7mp_cp_reginfo[] = { | 42 | #include "qemu/osdep.h" |
32 | REGINFO_SENTINEL | 43 | #include "qapi/error.h" |
33 | }; | 44 | -#include "qemu-common.h" |
34 | 45 | #include "qemu/datadir.h" | |
35 | +static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | 46 | #include "hw/boards.h" |
36 | + /* PMOVSSET is not implemented in v7 before v7ve */ | 47 | #include "qemu/error-report.h" |
37 | + { .name = "PMOVSSET", .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 3, | 48 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c |
38 | + .access = PL0_RW, .accessfn = pmreg_access, | 49 | index XXXXXXX..XXXXXXX 100644 |
39 | + .type = ARM_CP_ALIAS, | 50 | --- a/hw/arm/highbank.c |
40 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmovsr), | 51 | +++ b/hw/arm/highbank.c |
41 | + .writefn = pmovsset_write, | 52 | @@ -XXX,XX +XXX,XX @@ |
42 | + .raw_writefn = raw_write }, | 53 | */ |
43 | + { .name = "PMOVSSET_EL0", .state = ARM_CP_STATE_AA64, | 54 | |
44 | + .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 14, .opc2 = 3, | 55 | #include "qemu/osdep.h" |
45 | + .access = PL0_RW, .accessfn = pmreg_access, | 56 | -#include "qemu-common.h" |
46 | + .type = ARM_CP_ALIAS, | 57 | #include "qemu/datadir.h" |
47 | + .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), | 58 | #include "qapi/error.h" |
48 | + .writefn = pmovsset_write, | 59 | #include "hw/sysbus.h" |
49 | + .raw_writefn = raw_write }, | 60 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c |
50 | + REGINFO_SENTINEL | 61 | index XXXXXXX..XXXXXXX 100644 |
51 | +}; | 62 | --- a/hw/arm/npcm7xx_boards.c |
52 | + | 63 | +++ b/hw/arm/npcm7xx_boards.c |
53 | static void teecr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 64 | @@ -XXX,XX +XXX,XX @@ |
54 | uint64_t value) | 65 | #include "hw/qdev-core.h" |
55 | { | 66 | #include "hw/qdev-properties.h" |
56 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 67 | #include "qapi/error.h" |
57 | !arm_feature(env, ARM_FEATURE_PMSA)) { | 68 | -#include "qemu-common.h" |
58 | define_arm_cp_regs(cpu, v7mp_cp_reginfo); | 69 | #include "qemu/datadir.h" |
59 | } | 70 | #include "qemu/units.h" |
60 | + if (arm_feature(env, ARM_FEATURE_V7VE)) { | 71 | #include "sysemu/blockdev.h" |
61 | + define_arm_cp_regs(cpu, pmovsset_cp_reginfo); | 72 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
62 | + } | 73 | index XXXXXXX..XXXXXXX 100644 |
63 | if (arm_feature(env, ARM_FEATURE_V7)) { | 74 | --- a/hw/arm/sbsa-ref.c |
64 | /* v7 performance monitor control register: same implementor | 75 | +++ b/hw/arm/sbsa-ref.c |
65 | * field as main ID register, and we implement only the cycle | 76 | @@ -XXX,XX +XXX,XX @@ |
77 | */ | ||
78 | |||
79 | #include "qemu/osdep.h" | ||
80 | -#include "qemu-common.h" | ||
81 | #include "qemu/datadir.h" | ||
82 | #include "qapi/error.h" | ||
83 | #include "qemu/error-report.h" | ||
84 | diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/hw/arm/stm32f405_soc.c | ||
87 | +++ b/hw/arm/stm32f405_soc.c | ||
88 | @@ -XXX,XX +XXX,XX @@ | ||
89 | |||
90 | #include "qemu/osdep.h" | ||
91 | #include "qapi/error.h" | ||
92 | -#include "qemu-common.h" | ||
93 | #include "exec/address-spaces.h" | ||
94 | #include "sysemu/sysemu.h" | ||
95 | #include "hw/arm/stm32f405_soc.h" | ||
96 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/hw/arm/vexpress.c | ||
99 | +++ b/hw/arm/vexpress.c | ||
100 | @@ -XXX,XX +XXX,XX @@ | ||
101 | |||
102 | #include "qemu/osdep.h" | ||
103 | #include "qapi/error.h" | ||
104 | -#include "qemu-common.h" | ||
105 | #include "qemu/datadir.h" | ||
106 | #include "cpu.h" | ||
107 | #include "hw/sysbus.h" | ||
108 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/hw/arm/virt.c | ||
111 | +++ b/hw/arm/virt.c | ||
112 | @@ -XXX,XX +XXX,XX @@ | ||
113 | */ | ||
114 | |||
115 | #include "qemu/osdep.h" | ||
116 | -#include "qemu-common.h" | ||
117 | #include "qemu/datadir.h" | ||
118 | #include "qemu/units.h" | ||
119 | #include "qemu/option.h" | ||
66 | -- | 120 | -- |
67 | 2.20.1 | 121 | 2.25.1 |
68 | 122 | ||
69 | 123 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | The calculation of the length of TLB range invalidate operations |
---|---|---|---|
2 | in tlbi_aa64_range_get_length() is incorrect in two ways: | ||
3 | * the NUM field is 5 bits, but we read only 4 bits | ||
4 | * we miscalculate the page_shift value, because of an | ||
5 | off-by-one error: | ||
6 | TG 0b00 is invalid | ||
7 | TG 0b01 is 4K granule size == 4096 == 2^12 | ||
8 | TG 0b10 is 16K granule size == 16384 == 2^14 | ||
9 | TG 0b11 is 64K granule size == 65536 == 2^16 | ||
10 | so page_shift should be (TG - 1) * 2 + 12 | ||
2 | 11 | ||
3 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 12 | Thanks to the bug report submitter Cha HyunSoo for identifying |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | both these errors. |
14 | |||
15 | Fixes: 84940ed82552d3c ("target/arm: Add support for FEAT_TLBIRANGE") | ||
16 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/734 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20181211151945.29137-6-aaron@os.amperecomputing.com | 19 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
21 | Message-id: 20211130173257.1274194-1-peter.maydell@linaro.org | ||
8 | --- | 22 | --- |
9 | target/arm/helper.c | 27 ++++++++++++++++++++++++++- | 23 | target/arm/helper.c | 6 +++--- |
10 | 1 file changed, 26 insertions(+), 1 deletion(-) | 24 | 1 file changed, 3 insertions(+), 3 deletions(-) |
11 | 25 | ||
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 26 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.c | 28 | --- a/target/arm/helper.c |
15 | +++ b/target/arm/helper.c | 29 | +++ b/target/arm/helper.c |
16 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | 30 | @@ -XXX,XX +XXX,XX @@ static uint64_t tlbi_aa64_range_get_length(CPUARMState *env, |
17 | PMXEVTYPER_M | PMXEVTYPER_MT | \ | 31 | uint64_t exponent; |
18 | PMXEVTYPER_EVTCOUNT) | 32 | uint64_t length; |
19 | 33 | ||
20 | +#define PMCCFILTR 0xf8000000 | 34 | - num = extract64(value, 39, 4); |
21 | +#define PMCCFILTR_M PMXEVTYPER_M | 35 | + num = extract64(value, 39, 5); |
22 | +#define PMCCFILTR_EL0 (PMCCFILTR | PMCCFILTR_M) | 36 | scale = extract64(value, 44, 2); |
37 | page_size_granule = extract64(value, 46, 2); | ||
38 | |||
39 | - page_shift = page_size_granule * 2 + 12; | ||
40 | - | ||
41 | if (page_size_granule == 0) { | ||
42 | qemu_log_mask(LOG_GUEST_ERROR, "Invalid page size granule %d\n", | ||
43 | page_size_granule); | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | + page_shift = (page_size_granule - 1) * 2 + 12; | ||
23 | + | 48 | + |
24 | static inline uint32_t pmu_num_counters(CPUARMState *env) | 49 | exponent = (5 * scale) + 1; |
25 | { | 50 | length = (num + 1) << (exponent + page_shift); |
26 | return (env->cp15.c9_pmcr & PMCRN_MASK) >> PMCRN_SHIFT; | 51 | |
27 | @@ -XXX,XX +XXX,XX @@ static void pmccfiltr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
28 | uint64_t value) | ||
29 | { | ||
30 | pmccntr_op_start(env); | ||
31 | - env->cp15.pmccfiltr_el0 = value & 0xfc000000; | ||
32 | + env->cp15.pmccfiltr_el0 = value & PMCCFILTR_EL0; | ||
33 | pmccntr_op_finish(env); | ||
34 | } | ||
35 | |||
36 | +static void pmccfiltr_write_a32(CPUARMState *env, const ARMCPRegInfo *ri, | ||
37 | + uint64_t value) | ||
38 | +{ | ||
39 | + pmccntr_op_start(env); | ||
40 | + /* M is not accessible from AArch32 */ | ||
41 | + env->cp15.pmccfiltr_el0 = (env->cp15.pmccfiltr_el0 & PMCCFILTR_M) | | ||
42 | + (value & PMCCFILTR); | ||
43 | + pmccntr_op_finish(env); | ||
44 | +} | ||
45 | + | ||
46 | +static uint64_t pmccfiltr_read_a32(CPUARMState *env, const ARMCPRegInfo *ri) | ||
47 | +{ | ||
48 | + /* M is not visible in AArch32 */ | ||
49 | + return env->cp15.pmccfiltr_el0 & PMCCFILTR; | ||
50 | +} | ||
51 | + | ||
52 | static void pmcntenset_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
53 | uint64_t value) | ||
54 | { | ||
55 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
56 | .readfn = pmccntr_read, .writefn = pmccntr_write, | ||
57 | .raw_readfn = raw_read, .raw_writefn = raw_write, }, | ||
58 | #endif | ||
59 | + { .name = "PMCCFILTR", .cp = 15, .opc1 = 0, .crn = 14, .crm = 15, .opc2 = 7, | ||
60 | + .writefn = pmccfiltr_write_a32, .readfn = pmccfiltr_read_a32, | ||
61 | + .access = PL0_RW, .accessfn = pmreg_access, | ||
62 | + .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
63 | + .resetvalue = 0, }, | ||
64 | { .name = "PMCCFILTR_EL0", .state = ARM_CP_STATE_AA64, | ||
65 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 15, .opc2 = 7, | ||
66 | .writefn = pmccfiltr_write, .raw_writefn = raw_write, | ||
67 | -- | 52 | -- |
68 | 2.20.1 | 53 | 2.25.1 |
69 | 54 | ||
70 | 55 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | 2 | ||
3 | This function is only used by AArch64. Code movement only. | 3 | The rx_active boolean change to true should always trigger a try_read |
4 | call that flushes the queue. | ||
4 | 5 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Patrick Venture <venture@google.com> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | Message-id: 20190108223129.5570-11-richard.henderson@linaro.org | 8 | Message-id: 20211203221002.1719306-1-venture@google.com |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/helper-a64.h | 2 + | 11 | hw/net/npcm7xx_emc.c | 18 ++++++++---------- |
11 | target/arm/helper.h | 1 - | 12 | 1 file changed, 8 insertions(+), 10 deletions(-) |
12 | target/arm/helper-a64.c | 155 ++++++++++++++++++++++++++++++++++++++++ | ||
13 | target/arm/op_helper.c | 155 ---------------------------------------- | ||
14 | 4 files changed, 157 insertions(+), 156 deletions(-) | ||
15 | 13 | ||
16 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | 14 | diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-a64.h | 16 | --- a/hw/net/npcm7xx_emc.c |
19 | +++ b/target/arm/helper-a64.h | 17 | +++ b/hw/net/npcm7xx_emc.c |
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) | 18 | @@ -XXX,XX +XXX,XX @@ static void emc_halt_rx(NPCM7xxEMCState *emc, uint32_t mista_flag) |
21 | DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) | 19 | emc_set_mista(emc, mista_flag); |
22 | DEF_HELPER_2(sqrt_f16, f16, f16, ptr) | ||
23 | |||
24 | +DEF_HELPER_1(exception_return, void, env) | ||
25 | + | ||
26 | DEF_HELPER_FLAGS_3(pacia, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
27 | DEF_HELPER_FLAGS_3(pacib, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
28 | DEF_HELPER_FLAGS_3(pacda, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
29 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/helper.h | ||
32 | +++ b/target/arm/helper.h | ||
33 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(get_cp_reg64, i64, env, ptr) | ||
34 | |||
35 | DEF_HELPER_3(msr_i_pstate, void, env, i32, i32) | ||
36 | DEF_HELPER_1(clear_pstate_ss, void, env) | ||
37 | -DEF_HELPER_1(exception_return, void, env) | ||
38 | |||
39 | DEF_HELPER_2(get_r13_banked, i32, env, i32) | ||
40 | DEF_HELPER_3(set_r13_banked, void, env, i32, i32) | ||
41 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/helper-a64.c | ||
44 | +++ b/target/arm/helper-a64.c | ||
45 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(uint32_t a, void *fpstp) | ||
46 | return float16_to_uint16(a, fpst); | ||
47 | } | 20 | } |
48 | 21 | ||
49 | +static int el_from_spsr(uint32_t spsr) | 22 | +static void emc_enable_rx_and_flush(NPCM7xxEMCState *emc) |
50 | +{ | 23 | +{ |
51 | + /* Return the exception level that this SPSR is requesting a return to, | 24 | + emc->rx_active = true; |
52 | + * or -1 if it is invalid (an illegal return) | 25 | + qemu_flush_queued_packets(qemu_get_queue(emc->nic)); |
53 | + */ | ||
54 | + if (spsr & PSTATE_nRW) { | ||
55 | + switch (spsr & CPSR_M) { | ||
56 | + case ARM_CPU_MODE_USR: | ||
57 | + return 0; | ||
58 | + case ARM_CPU_MODE_HYP: | ||
59 | + return 2; | ||
60 | + case ARM_CPU_MODE_FIQ: | ||
61 | + case ARM_CPU_MODE_IRQ: | ||
62 | + case ARM_CPU_MODE_SVC: | ||
63 | + case ARM_CPU_MODE_ABT: | ||
64 | + case ARM_CPU_MODE_UND: | ||
65 | + case ARM_CPU_MODE_SYS: | ||
66 | + return 1; | ||
67 | + case ARM_CPU_MODE_MON: | ||
68 | + /* Returning to Mon from AArch64 is never possible, | ||
69 | + * so this is an illegal return. | ||
70 | + */ | ||
71 | + default: | ||
72 | + return -1; | ||
73 | + } | ||
74 | + } else { | ||
75 | + if (extract32(spsr, 1, 1)) { | ||
76 | + /* Return with reserved M[1] bit set */ | ||
77 | + return -1; | ||
78 | + } | ||
79 | + if (extract32(spsr, 0, 4) == 1) { | ||
80 | + /* return to EL0 with M[0] bit set */ | ||
81 | + return -1; | ||
82 | + } | ||
83 | + return extract32(spsr, 2, 2); | ||
84 | + } | ||
85 | +} | 26 | +} |
86 | + | 27 | + |
87 | +void HELPER(exception_return)(CPUARMState *env) | 28 | static void emc_set_next_tx_descriptor(NPCM7xxEMCState *emc, |
88 | +{ | 29 | const NPCM7xxEMCTxDesc *tx_desc, |
89 | + int cur_el = arm_current_el(env); | 30 | uint32_t desc_addr) |
90 | + unsigned int spsr_idx = aarch64_banked_spsr_index(cur_el); | 31 | @@ -XXX,XX +XXX,XX @@ static ssize_t emc_receive(NetClientState *nc, const uint8_t *buf, size_t len1) |
91 | + uint32_t spsr = env->banked_spsr[spsr_idx]; | 32 | return len; |
92 | + int new_el; | ||
93 | + bool return_to_aa64 = (spsr & PSTATE_nRW) == 0; | ||
94 | + | ||
95 | + aarch64_save_sp(env, cur_el); | ||
96 | + | ||
97 | + arm_clear_exclusive(env); | ||
98 | + | ||
99 | + /* We must squash the PSTATE.SS bit to zero unless both of the | ||
100 | + * following hold: | ||
101 | + * 1. debug exceptions are currently disabled | ||
102 | + * 2. singlestep will be active in the EL we return to | ||
103 | + * We check 1 here and 2 after we've done the pstate/cpsr write() to | ||
104 | + * transition to the EL we're going to. | ||
105 | + */ | ||
106 | + if (arm_generate_debug_exceptions(env)) { | ||
107 | + spsr &= ~PSTATE_SS; | ||
108 | + } | ||
109 | + | ||
110 | + new_el = el_from_spsr(spsr); | ||
111 | + if (new_el == -1) { | ||
112 | + goto illegal_return; | ||
113 | + } | ||
114 | + if (new_el > cur_el | ||
115 | + || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) { | ||
116 | + /* Disallow return to an EL which is unimplemented or higher | ||
117 | + * than the current one. | ||
118 | + */ | ||
119 | + goto illegal_return; | ||
120 | + } | ||
121 | + | ||
122 | + if (new_el != 0 && arm_el_is_aa64(env, new_el) != return_to_aa64) { | ||
123 | + /* Return to an EL which is configured for a different register width */ | ||
124 | + goto illegal_return; | ||
125 | + } | ||
126 | + | ||
127 | + if (new_el == 2 && arm_is_secure_below_el3(env)) { | ||
128 | + /* Return to the non-existent secure-EL2 */ | ||
129 | + goto illegal_return; | ||
130 | + } | ||
131 | + | ||
132 | + if (new_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) { | ||
133 | + goto illegal_return; | ||
134 | + } | ||
135 | + | ||
136 | + qemu_mutex_lock_iothread(); | ||
137 | + arm_call_pre_el_change_hook(arm_env_get_cpu(env)); | ||
138 | + qemu_mutex_unlock_iothread(); | ||
139 | + | ||
140 | + if (!return_to_aa64) { | ||
141 | + env->aarch64 = 0; | ||
142 | + /* We do a raw CPSR write because aarch64_sync_64_to_32() | ||
143 | + * will sort the register banks out for us, and we've already | ||
144 | + * caught all the bad-mode cases in el_from_spsr(). | ||
145 | + */ | ||
146 | + cpsr_write(env, spsr, ~0, CPSRWriteRaw); | ||
147 | + if (!arm_singlestep_active(env)) { | ||
148 | + env->uncached_cpsr &= ~PSTATE_SS; | ||
149 | + } | ||
150 | + aarch64_sync_64_to_32(env); | ||
151 | + | ||
152 | + if (spsr & CPSR_T) { | ||
153 | + env->regs[15] = env->elr_el[cur_el] & ~0x1; | ||
154 | + } else { | ||
155 | + env->regs[15] = env->elr_el[cur_el] & ~0x3; | ||
156 | + } | ||
157 | + qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | ||
158 | + "AArch32 EL%d PC 0x%" PRIx32 "\n", | ||
159 | + cur_el, new_el, env->regs[15]); | ||
160 | + } else { | ||
161 | + env->aarch64 = 1; | ||
162 | + pstate_write(env, spsr); | ||
163 | + if (!arm_singlestep_active(env)) { | ||
164 | + env->pstate &= ~PSTATE_SS; | ||
165 | + } | ||
166 | + aarch64_restore_sp(env, new_el); | ||
167 | + env->pc = env->elr_el[cur_el]; | ||
168 | + qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | ||
169 | + "AArch64 EL%d PC 0x%" PRIx64 "\n", | ||
170 | + cur_el, new_el, env->pc); | ||
171 | + } | ||
172 | + /* | ||
173 | + * Note that cur_el can never be 0. If new_el is 0, then | ||
174 | + * el0_a64 is return_to_aa64, else el0_a64 is ignored. | ||
175 | + */ | ||
176 | + aarch64_sve_change_el(env, cur_el, new_el, return_to_aa64); | ||
177 | + | ||
178 | + qemu_mutex_lock_iothread(); | ||
179 | + arm_call_el_change_hook(arm_env_get_cpu(env)); | ||
180 | + qemu_mutex_unlock_iothread(); | ||
181 | + | ||
182 | + return; | ||
183 | + | ||
184 | +illegal_return: | ||
185 | + /* Illegal return events of various kinds have architecturally | ||
186 | + * mandated behaviour: | ||
187 | + * restore NZCV and DAIF from SPSR_ELx | ||
188 | + * set PSTATE.IL | ||
189 | + * restore PC from ELR_ELx | ||
190 | + * no change to exception level, execution state or stack pointer | ||
191 | + */ | ||
192 | + env->pstate |= PSTATE_IL; | ||
193 | + env->pc = env->elr_el[cur_el]; | ||
194 | + spsr &= PSTATE_NZCV | PSTATE_DAIF; | ||
195 | + spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF); | ||
196 | + pstate_write(env, spsr); | ||
197 | + if (!arm_singlestep_active(env)) { | ||
198 | + env->pstate &= ~PSTATE_SS; | ||
199 | + } | ||
200 | + qemu_log_mask(LOG_GUEST_ERROR, "Illegal exception return at EL%d: " | ||
201 | + "resuming execution at 0x%" PRIx64 "\n", cur_el, env->pc); | ||
202 | +} | ||
203 | + | ||
204 | /* | ||
205 | * Square Root and Reciprocal square root | ||
206 | */ | ||
207 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
208 | index XXXXXXX..XXXXXXX 100644 | ||
209 | --- a/target/arm/op_helper.c | ||
210 | +++ b/target/arm/op_helper.c | ||
211 | @@ -XXX,XX +XXX,XX @@ void HELPER(pre_smc)(CPUARMState *env, uint32_t syndrome) | ||
212 | } | ||
213 | } | 33 | } |
214 | 34 | ||
215 | -static int el_from_spsr(uint32_t spsr) | 35 | -static void emc_try_receive_next_packet(NPCM7xxEMCState *emc) |
216 | -{ | 36 | -{ |
217 | - /* Return the exception level that this SPSR is requesting a return to, | 37 | - if (emc_can_receive(qemu_get_queue(emc->nic))) { |
218 | - * or -1 if it is invalid (an illegal return) | 38 | - qemu_flush_queued_packets(qemu_get_queue(emc->nic)); |
219 | - */ | ||
220 | - if (spsr & PSTATE_nRW) { | ||
221 | - switch (spsr & CPSR_M) { | ||
222 | - case ARM_CPU_MODE_USR: | ||
223 | - return 0; | ||
224 | - case ARM_CPU_MODE_HYP: | ||
225 | - return 2; | ||
226 | - case ARM_CPU_MODE_FIQ: | ||
227 | - case ARM_CPU_MODE_IRQ: | ||
228 | - case ARM_CPU_MODE_SVC: | ||
229 | - case ARM_CPU_MODE_ABT: | ||
230 | - case ARM_CPU_MODE_UND: | ||
231 | - case ARM_CPU_MODE_SYS: | ||
232 | - return 1; | ||
233 | - case ARM_CPU_MODE_MON: | ||
234 | - /* Returning to Mon from AArch64 is never possible, | ||
235 | - * so this is an illegal return. | ||
236 | - */ | ||
237 | - default: | ||
238 | - return -1; | ||
239 | - } | ||
240 | - } else { | ||
241 | - if (extract32(spsr, 1, 1)) { | ||
242 | - /* Return with reserved M[1] bit set */ | ||
243 | - return -1; | ||
244 | - } | ||
245 | - if (extract32(spsr, 0, 4) == 1) { | ||
246 | - /* return to EL0 with M[0] bit set */ | ||
247 | - return -1; | ||
248 | - } | ||
249 | - return extract32(spsr, 2, 2); | ||
250 | - } | 39 | - } |
251 | -} | 40 | -} |
252 | - | 41 | - |
253 | -void HELPER(exception_return)(CPUARMState *env) | 42 | static uint64_t npcm7xx_emc_read(void *opaque, hwaddr offset, unsigned size) |
254 | -{ | ||
255 | - int cur_el = arm_current_el(env); | ||
256 | - unsigned int spsr_idx = aarch64_banked_spsr_index(cur_el); | ||
257 | - uint32_t spsr = env->banked_spsr[spsr_idx]; | ||
258 | - int new_el; | ||
259 | - bool return_to_aa64 = (spsr & PSTATE_nRW) == 0; | ||
260 | - | ||
261 | - aarch64_save_sp(env, cur_el); | ||
262 | - | ||
263 | - arm_clear_exclusive(env); | ||
264 | - | ||
265 | - /* We must squash the PSTATE.SS bit to zero unless both of the | ||
266 | - * following hold: | ||
267 | - * 1. debug exceptions are currently disabled | ||
268 | - * 2. singlestep will be active in the EL we return to | ||
269 | - * We check 1 here and 2 after we've done the pstate/cpsr write() to | ||
270 | - * transition to the EL we're going to. | ||
271 | - */ | ||
272 | - if (arm_generate_debug_exceptions(env)) { | ||
273 | - spsr &= ~PSTATE_SS; | ||
274 | - } | ||
275 | - | ||
276 | - new_el = el_from_spsr(spsr); | ||
277 | - if (new_el == -1) { | ||
278 | - goto illegal_return; | ||
279 | - } | ||
280 | - if (new_el > cur_el | ||
281 | - || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) { | ||
282 | - /* Disallow return to an EL which is unimplemented or higher | ||
283 | - * than the current one. | ||
284 | - */ | ||
285 | - goto illegal_return; | ||
286 | - } | ||
287 | - | ||
288 | - if (new_el != 0 && arm_el_is_aa64(env, new_el) != return_to_aa64) { | ||
289 | - /* Return to an EL which is configured for a different register width */ | ||
290 | - goto illegal_return; | ||
291 | - } | ||
292 | - | ||
293 | - if (new_el == 2 && arm_is_secure_below_el3(env)) { | ||
294 | - /* Return to the non-existent secure-EL2 */ | ||
295 | - goto illegal_return; | ||
296 | - } | ||
297 | - | ||
298 | - if (new_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) { | ||
299 | - goto illegal_return; | ||
300 | - } | ||
301 | - | ||
302 | - qemu_mutex_lock_iothread(); | ||
303 | - arm_call_pre_el_change_hook(arm_env_get_cpu(env)); | ||
304 | - qemu_mutex_unlock_iothread(); | ||
305 | - | ||
306 | - if (!return_to_aa64) { | ||
307 | - env->aarch64 = 0; | ||
308 | - /* We do a raw CPSR write because aarch64_sync_64_to_32() | ||
309 | - * will sort the register banks out for us, and we've already | ||
310 | - * caught all the bad-mode cases in el_from_spsr(). | ||
311 | - */ | ||
312 | - cpsr_write(env, spsr, ~0, CPSRWriteRaw); | ||
313 | - if (!arm_singlestep_active(env)) { | ||
314 | - env->uncached_cpsr &= ~PSTATE_SS; | ||
315 | - } | ||
316 | - aarch64_sync_64_to_32(env); | ||
317 | - | ||
318 | - if (spsr & CPSR_T) { | ||
319 | - env->regs[15] = env->elr_el[cur_el] & ~0x1; | ||
320 | - } else { | ||
321 | - env->regs[15] = env->elr_el[cur_el] & ~0x3; | ||
322 | - } | ||
323 | - qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | ||
324 | - "AArch32 EL%d PC 0x%" PRIx32 "\n", | ||
325 | - cur_el, new_el, env->regs[15]); | ||
326 | - } else { | ||
327 | - env->aarch64 = 1; | ||
328 | - pstate_write(env, spsr); | ||
329 | - if (!arm_singlestep_active(env)) { | ||
330 | - env->pstate &= ~PSTATE_SS; | ||
331 | - } | ||
332 | - aarch64_restore_sp(env, new_el); | ||
333 | - env->pc = env->elr_el[cur_el]; | ||
334 | - qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | ||
335 | - "AArch64 EL%d PC 0x%" PRIx64 "\n", | ||
336 | - cur_el, new_el, env->pc); | ||
337 | - } | ||
338 | - /* | ||
339 | - * Note that cur_el can never be 0. If new_el is 0, then | ||
340 | - * el0_a64 is return_to_aa64, else el0_a64 is ignored. | ||
341 | - */ | ||
342 | - aarch64_sve_change_el(env, cur_el, new_el, return_to_aa64); | ||
343 | - | ||
344 | - qemu_mutex_lock_iothread(); | ||
345 | - arm_call_el_change_hook(arm_env_get_cpu(env)); | ||
346 | - qemu_mutex_unlock_iothread(); | ||
347 | - | ||
348 | - return; | ||
349 | - | ||
350 | -illegal_return: | ||
351 | - /* Illegal return events of various kinds have architecturally | ||
352 | - * mandated behaviour: | ||
353 | - * restore NZCV and DAIF from SPSR_ELx | ||
354 | - * set PSTATE.IL | ||
355 | - * restore PC from ELR_ELx | ||
356 | - * no change to exception level, execution state or stack pointer | ||
357 | - */ | ||
358 | - env->pstate |= PSTATE_IL; | ||
359 | - env->pc = env->elr_el[cur_el]; | ||
360 | - spsr &= PSTATE_NZCV | PSTATE_DAIF; | ||
361 | - spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF); | ||
362 | - pstate_write(env, spsr); | ||
363 | - if (!arm_singlestep_active(env)) { | ||
364 | - env->pstate &= ~PSTATE_SS; | ||
365 | - } | ||
366 | - qemu_log_mask(LOG_GUEST_ERROR, "Illegal exception return at EL%d: " | ||
367 | - "resuming execution at 0x%" PRIx64 "\n", cur_el, env->pc); | ||
368 | -} | ||
369 | - | ||
370 | /* Return true if the linked breakpoint entry lbn passes its checks */ | ||
371 | static bool linked_bp_matches(ARMCPU *cpu, int lbn) | ||
372 | { | 43 | { |
44 | NPCM7xxEMCState *emc = opaque; | ||
45 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, | ||
46 | emc->regs[REG_MGSTA] |= REG_MGSTA_RXHA; | ||
47 | } | ||
48 | if (value & REG_MCMDR_RXON) { | ||
49 | - emc->rx_active = true; | ||
50 | + emc_enable_rx_and_flush(emc); | ||
51 | } else { | ||
52 | emc_halt_rx(emc, 0); | ||
53 | } | ||
54 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, | ||
55 | break; | ||
56 | case REG_RSDR: | ||
57 | if (emc->regs[REG_MCMDR] & REG_MCMDR_RXON) { | ||
58 | - emc->rx_active = true; | ||
59 | - emc_try_receive_next_packet(emc); | ||
60 | + emc_enable_rx_and_flush(emc); | ||
61 | } | ||
62 | break; | ||
63 | case REG_MIIDA: | ||
373 | -- | 64 | -- |
374 | 2.20.1 | 65 | 2.25.1 |
375 | 66 | ||
376 | 67 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Let's report IO-coherent access is supported for translation | 3 | When a virtio-iommu is instantiated, describe it using the ACPI VIOT |
4 | table walks, descriptor fetches and queues by setting the COHACC | 4 | table. |
5 | override flag. Without that, we observe wrong command opcodes. | ||
6 | The DT description also advertises the dma coherency. | ||
7 | 5 | ||
8 | Fixes a703b4f6c1ee ("hw/arm/virt-acpi-build: Add smmuv3 node in IORT table") | 6 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
9 | 7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | |
10 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 8 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
11 | Reported-by: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> | 9 | Message-id: 20211210170415.583179-2-jean-philippe@linaro.org |
12 | Tested-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> | ||
13 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
14 | Message-id: 20190107101041.765-1-eric.auger@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 | include/hw/acpi/acpi-defs.h | 2 ++ | 12 | hw/arm/virt-acpi-build.c | 7 +++++++ |
18 | hw/arm/virt-acpi-build.c | 1 + | 13 | hw/arm/Kconfig | 1 + |
19 | 2 files changed, 3 insertions(+) | 14 | 2 files changed, 8 insertions(+) |
20 | 15 | ||
21 | diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/acpi/acpi-defs.h | ||
24 | +++ b/include/hw/acpi/acpi-defs.h | ||
25 | @@ -XXX,XX +XXX,XX @@ struct AcpiIortItsGroup { | ||
26 | } QEMU_PACKED; | ||
27 | typedef struct AcpiIortItsGroup AcpiIortItsGroup; | ||
28 | |||
29 | +#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE 1 | ||
30 | + | ||
31 | struct AcpiIortSmmu3 { | ||
32 | ACPI_IORT_NODE_HEADER_DEF | ||
33 | uint64_t base_address; | ||
34 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 16 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c |
35 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/hw/arm/virt-acpi-build.c | 18 | --- a/hw/arm/virt-acpi-build.c |
37 | +++ b/hw/arm/virt-acpi-build.c | 19 | +++ b/hw/arm/virt-acpi-build.c |
38 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 20 | @@ -XXX,XX +XXX,XX @@ |
39 | smmu->mapping_count = cpu_to_le32(1); | 21 | #include "kvm_arm.h" |
40 | smmu->mapping_offset = cpu_to_le32(sizeof(*smmu)); | 22 | #include "migration/vmstate.h" |
41 | smmu->base_address = cpu_to_le64(vms->memmap[VIRT_SMMU].base); | 23 | #include "hw/acpi/ghes.h" |
42 | + smmu->flags = cpu_to_le32(ACPI_IORT_SMMU_V3_COHACC_OVERRIDE); | 24 | +#include "hw/acpi/viot.h" |
43 | smmu->event_gsiv = cpu_to_le32(irq); | 25 | |
44 | smmu->pri_gsiv = cpu_to_le32(irq + 1); | 26 | #define ARM_SPI_BASE 32 |
45 | smmu->gerr_gsiv = cpu_to_le32(irq + 2); | 27 | |
28 | @@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) | ||
29 | } | ||
30 | #endif | ||
31 | |||
32 | + if (vms->iommu == VIRT_IOMMU_VIRTIO) { | ||
33 | + acpi_add_table(table_offsets, tables_blob); | ||
34 | + build_viot(ms, tables_blob, tables->linker, vms->virtio_iommu_bdf, | ||
35 | + vms->oem_id, vms->oem_table_id); | ||
36 | + } | ||
37 | + | ||
38 | /* XSDT is pointed to by RSDP */ | ||
39 | xsdt = tables_blob->len; | ||
40 | build_xsdt(tables_blob, tables->linker, table_offsets, vms->oem_id, | ||
41 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/arm/Kconfig | ||
44 | +++ b/hw/arm/Kconfig | ||
45 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT | ||
46 | select DIMM | ||
47 | select ACPI_HW_REDUCED | ||
48 | select ACPI_APEI | ||
49 | + select ACPI_VIOT | ||
50 | |||
51 | config CHEETAH | ||
52 | bool | ||
46 | -- | 53 | -- |
47 | 2.20.1 | 54 | 2.25.1 |
48 | 55 | ||
49 | 56 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This is not really functional yet, because the crypto is not yet | 3 | virtio-iommu is now supported with ACPI VIOT as well as device tree. |
4 | implemented. This, however follows the Auth pseudo function. | 4 | Remove the restriction that prevents from instantiating a virtio-iommu |
5 | device under ACPI. | ||
5 | 6 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
8 | Message-id: 20190108223129.5570-26-richard.henderson@linaro.org | 9 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
10 | Message-id: 20211210170415.583179-3-jean-philippe@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | target/arm/pauth_helper.c | 21 ++++++++++++++++++++- | 13 | hw/arm/virt.c | 10 ++-------- |
12 | 1 file changed, 20 insertions(+), 1 deletion(-) | 14 | hw/virtio/virtio-iommu-pci.c | 12 ++---------- |
15 | 2 files changed, 4 insertions(+), 18 deletions(-) | ||
13 | 16 | ||
14 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | 17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/pauth_helper.c | 19 | --- a/hw/arm/virt.c |
17 | +++ b/target/arm/pauth_helper.c | 20 | +++ b/hw/arm/virt.c |
18 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) | 21 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, |
19 | static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, | 22 | MachineClass *mc = MACHINE_GET_CLASS(machine); |
20 | ARMPACKey *key, bool data, int keynumber) | 23 | |
21 | { | 24 | if (device_is_dynamic_sysbus(mc, dev) || |
22 | - g_assert_not_reached(); /* FIXME */ | 25 | - (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { |
23 | + ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); | 26 | + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || |
24 | + ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); | 27 | + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { |
25 | + int bot_bit, top_bit; | 28 | return HOTPLUG_HANDLER(machine); |
26 | + uint64_t pac, orig_ptr, test; | 29 | } |
27 | + | 30 | - if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { |
28 | + orig_ptr = pauth_original_ptr(ptr, param); | 31 | - VirtMachineState *vms = VIRT_MACHINE(machine); |
29 | + pac = pauth_computepac(orig_ptr, modifier, *key); | 32 | - |
30 | + bot_bit = 64 - param.tsz; | 33 | - if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { |
31 | + top_bit = 64 - 8 * param.tbi; | 34 | - return HOTPLUG_HANDLER(machine); |
32 | + | 35 | - } |
33 | + test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); | 36 | - } |
34 | + if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { | 37 | return NULL; |
35 | + int error_code = (keynumber << 1) | (keynumber ^ 1); | ||
36 | + if (param.tbi) { | ||
37 | + return deposit64(ptr, 53, 2, error_code); | ||
38 | + } else { | ||
39 | + return deposit64(ptr, 61, 2, error_code); | ||
40 | + } | ||
41 | + } | ||
42 | + return orig_ptr; | ||
43 | } | 38 | } |
44 | 39 | ||
45 | static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data) | 40 | diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c |
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/virtio/virtio-iommu-pci.c | ||
43 | +++ b/hw/virtio/virtio-iommu-pci.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) | ||
45 | VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); | ||
46 | |||
47 | if (!qdev_get_machine_hotplug_handler(DEVICE(vpci_dev))) { | ||
48 | - MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); | ||
49 | - | ||
50 | - error_setg(errp, | ||
51 | - "%s machine fails to create iommu-map device tree bindings", | ||
52 | - mc->name); | ||
53 | - error_append_hint(errp, | ||
54 | - "Check your machine implements a hotplug handler " | ||
55 | - "for the virtio-iommu-pci device\n"); | ||
56 | - error_append_hint(errp, "Check the guest is booted without FW or with " | ||
57 | - "-no-acpi\n"); | ||
58 | + error_setg(errp, "Check your machine implements a hotplug handler " | ||
59 | + "for the virtio-iommu-pci device"); | ||
60 | return; | ||
61 | } | ||
62 | for (int i = 0; i < s->nb_reserved_regions; i++) { | ||
46 | -- | 63 | -- |
47 | 2.20.1 | 64 | 2.25.1 |
48 | 65 | ||
49 | 66 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | pmccntr_read and pmccntr_write contained duplicate code that was already | 3 | We do not support instantiating multiple IOMMUs. Before adding a |
4 | being handled by pmccntr_sync. Consolidate the duplicated code into two | 4 | virtio-iommu, check that no other IOMMU is present. This will detect |
5 | functions: pmccntr_op_start and pmccntr_op_finish. Add a companion to | 5 | both "iommu=smmuv3" machine parameter and another virtio-iommu instance. |
6 | c15_ccnt in CPUARMState so that we can simultaneously save both the | ||
7 | architectural register value and the last underlying cycle count - this | ||
8 | ensures time isn't lost and will also allow us to access the 'old' | ||
9 | architectural register value in order to detect overflows in later | ||
10 | patches. | ||
11 | 6 | ||
12 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 7 | Fixes: 70e89132c9 ("hw/arm/virt: Add the virtio-iommu device tree mappings") |
13 | Signed-off-by: Aaron Lindsay <aclindsa@gmail.com> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> |
15 | Message-id: 20181211151945.29137-3-aaron@os.amperecomputing.com | 10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
11 | Message-id: 20211210170415.583179-4-jean-philippe@linaro.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 13 | --- |
18 | target/arm/cpu.h | 37 +++++++++++--- | 14 | hw/arm/virt.c | 5 +++++ |
19 | target/arm/helper.c | 118 ++++++++++++++++++++++++++------------------ | 15 | 1 file changed, 5 insertions(+) |
20 | 2 files changed, 100 insertions(+), 55 deletions(-) | ||
21 | 16 | ||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
23 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/cpu.h | 19 | --- a/hw/arm/virt.c |
25 | +++ b/target/arm/cpu.h | 20 | +++ b/hw/arm/virt.c |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 21 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, |
27 | uint64_t oslsr_el1; /* OS Lock Status */ | 22 | hwaddr db_start = 0, db_end = 0; |
28 | uint64_t mdcr_el2; | 23 | char *resv_prop_str; |
29 | uint64_t mdcr_el3; | 24 | |
30 | - /* If the counter is enabled, this stores the last time the counter | 25 | + if (vms->iommu != VIRT_IOMMU_NONE) { |
31 | - * was reset. Otherwise it stores the counter value | 26 | + error_setg(errp, "virt machine does not support multiple IOMMUs"); |
32 | + /* Stores the architectural value of the counter *the last time it was | 27 | + return; |
33 | + * updated* by pmccntr_op_start. Accesses should always be surrounded | ||
34 | + * by pmccntr_op_start/pmccntr_op_finish to guarantee the latest | ||
35 | + * architecturally-correct value is being read/set. | ||
36 | */ | ||
37 | uint64_t c15_ccnt; | ||
38 | + /* Stores the delta between the architectural value and the underlying | ||
39 | + * cycle count during normal operation. It is used to update c15_ccnt | ||
40 | + * to be the correct architectural value before accesses. During | ||
41 | + * accesses, c15_ccnt_delta contains the underlying count being used | ||
42 | + * for the access, after which it reverts to the delta value in | ||
43 | + * pmccntr_op_finish. | ||
44 | + */ | ||
45 | + uint64_t c15_ccnt_delta; | ||
46 | uint64_t pmccfiltr_el0; /* Performance Monitor Filter Register */ | ||
47 | uint64_t vpidr_el2; /* Virtualization Processor ID Register */ | ||
48 | uint64_t vmpidr_el2; /* Virtualization Multiprocessor ID Register */ | ||
49 | @@ -XXX,XX +XXX,XX @@ int cpu_arm_signal_handler(int host_signum, void *pinfo, | ||
50 | void *puc); | ||
51 | |||
52 | /** | ||
53 | - * pmccntr_sync | ||
54 | + * pmccntr_op_start/finish | ||
55 | * @env: CPUARMState | ||
56 | * | ||
57 | - * Synchronises the counter in the PMCCNTR. This must always be called twice, | ||
58 | - * once before any action that might affect the timer and again afterwards. | ||
59 | - * The function is used to swap the state of the register if required. | ||
60 | - * This only happens when not in user mode (!CONFIG_USER_ONLY) | ||
61 | + * Convert the counter in the PMCCNTR between its delta form (the typical mode | ||
62 | + * when it's enabled) and the guest-visible value. These two calls must always | ||
63 | + * surround any action which might affect the counter. | ||
64 | */ | ||
65 | -void pmccntr_sync(CPUARMState *env); | ||
66 | +void pmccntr_op_start(CPUARMState *env); | ||
67 | +void pmccntr_op_finish(CPUARMState *env); | ||
68 | + | ||
69 | +/** | ||
70 | + * pmu_op_start/finish | ||
71 | + * @env: CPUARMState | ||
72 | + * | ||
73 | + * Convert all PMU counters between their delta form (the typical mode when | ||
74 | + * they are enabled) and the guest-visible values. These two calls must | ||
75 | + * surround any action which might affect the counters. | ||
76 | + */ | ||
77 | +void pmu_op_start(CPUARMState *env); | ||
78 | +void pmu_op_finish(CPUARMState *env); | ||
79 | |||
80 | /* SCTLR bit meanings. Several bits have been reused in newer | ||
81 | * versions of the architecture; in that case we define constants | ||
82 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/target/arm/helper.c | ||
85 | +++ b/target/arm/helper.c | ||
86 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_ccnt_enabled(CPUARMState *env) | ||
87 | |||
88 | return true; | ||
89 | } | ||
90 | - | ||
91 | -void pmccntr_sync(CPUARMState *env) | ||
92 | +/* | ||
93 | + * Ensure c15_ccnt is the guest-visible count so that operations such as | ||
94 | + * enabling/disabling the counter or filtering, modifying the count itself, | ||
95 | + * etc. can be done logically. This is essentially a no-op if the counter is | ||
96 | + * not enabled at the time of the call. | ||
97 | + */ | ||
98 | +void pmccntr_op_start(CPUARMState *env) | ||
99 | { | ||
100 | - uint64_t temp_ticks; | ||
101 | - | ||
102 | - temp_ticks = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), | ||
103 | + uint64_t cycles = 0; | ||
104 | + cycles = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), | ||
105 | ARM_CPU_FREQ, NANOSECONDS_PER_SECOND); | ||
106 | |||
107 | - if (env->cp15.c9_pmcr & PMCRD) { | ||
108 | - /* Increment once every 64 processor clock cycles */ | ||
109 | - temp_ticks /= 64; | ||
110 | - } | ||
111 | - | ||
112 | if (arm_ccnt_enabled(env)) { | ||
113 | - env->cp15.c15_ccnt = temp_ticks - env->cp15.c15_ccnt; | ||
114 | + uint64_t eff_cycles = cycles; | ||
115 | + if (env->cp15.c9_pmcr & PMCRD) { | ||
116 | + /* Increment once every 64 processor clock cycles */ | ||
117 | + eff_cycles /= 64; | ||
118 | + } | 28 | + } |
119 | + | 29 | + |
120 | + env->cp15.c15_ccnt = eff_cycles - env->cp15.c15_ccnt_delta; | 30 | switch (vms->msi_controller) { |
121 | } | 31 | case VIRT_MSI_CTRL_NONE: |
122 | + env->cp15.c15_ccnt_delta = cycles; | 32 | return; |
123 | +} | ||
124 | + | ||
125 | +/* | ||
126 | + * If PMCCNTR is enabled, recalculate the delta between the clock and the | ||
127 | + * guest-visible count. A call to pmccntr_op_finish should follow every call to | ||
128 | + * pmccntr_op_start. | ||
129 | + */ | ||
130 | +void pmccntr_op_finish(CPUARMState *env) | ||
131 | +{ | ||
132 | + if (arm_ccnt_enabled(env)) { | ||
133 | + uint64_t prev_cycles = env->cp15.c15_ccnt_delta; | ||
134 | + | ||
135 | + if (env->cp15.c9_pmcr & PMCRD) { | ||
136 | + /* Increment once every 64 processor clock cycles */ | ||
137 | + prev_cycles /= 64; | ||
138 | + } | ||
139 | + | ||
140 | + env->cp15.c15_ccnt_delta = prev_cycles - env->cp15.c15_ccnt; | ||
141 | + } | ||
142 | +} | ||
143 | + | ||
144 | +void pmu_op_start(CPUARMState *env) | ||
145 | +{ | ||
146 | + pmccntr_op_start(env); | ||
147 | +} | ||
148 | + | ||
149 | +void pmu_op_finish(CPUARMState *env) | ||
150 | +{ | ||
151 | + pmccntr_op_finish(env); | ||
152 | } | ||
153 | |||
154 | static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
155 | uint64_t value) | ||
156 | { | ||
157 | - pmccntr_sync(env); | ||
158 | + pmu_op_start(env); | ||
159 | |||
160 | if (value & PMCRC) { | ||
161 | /* The counter has been reset */ | ||
162 | @@ -XXX,XX +XXX,XX @@ static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
163 | env->cp15.c9_pmcr &= ~0x39; | ||
164 | env->cp15.c9_pmcr |= (value & 0x39); | ||
165 | |||
166 | - pmccntr_sync(env); | ||
167 | + pmu_op_finish(env); | ||
168 | } | ||
169 | |||
170 | static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
171 | { | ||
172 | - uint64_t total_ticks; | ||
173 | - | ||
174 | - if (!arm_ccnt_enabled(env)) { | ||
175 | - /* Counter is disabled, do not change value */ | ||
176 | - return env->cp15.c15_ccnt; | ||
177 | - } | ||
178 | - | ||
179 | - total_ticks = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), | ||
180 | - ARM_CPU_FREQ, NANOSECONDS_PER_SECOND); | ||
181 | - | ||
182 | - if (env->cp15.c9_pmcr & PMCRD) { | ||
183 | - /* Increment once every 64 processor clock cycles */ | ||
184 | - total_ticks /= 64; | ||
185 | - } | ||
186 | - return total_ticks - env->cp15.c15_ccnt; | ||
187 | + uint64_t ret; | ||
188 | + pmccntr_op_start(env); | ||
189 | + ret = env->cp15.c15_ccnt; | ||
190 | + pmccntr_op_finish(env); | ||
191 | + return ret; | ||
192 | } | ||
193 | |||
194 | static void pmselr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
195 | @@ -XXX,XX +XXX,XX @@ static void pmselr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
196 | static void pmccntr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
197 | uint64_t value) | ||
198 | { | ||
199 | - uint64_t total_ticks; | ||
200 | - | ||
201 | - if (!arm_ccnt_enabled(env)) { | ||
202 | - /* Counter is disabled, set the absolute value */ | ||
203 | - env->cp15.c15_ccnt = value; | ||
204 | - return; | ||
205 | - } | ||
206 | - | ||
207 | - total_ticks = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), | ||
208 | - ARM_CPU_FREQ, NANOSECONDS_PER_SECOND); | ||
209 | - | ||
210 | - if (env->cp15.c9_pmcr & PMCRD) { | ||
211 | - /* Increment once every 64 processor clock cycles */ | ||
212 | - total_ticks /= 64; | ||
213 | - } | ||
214 | - env->cp15.c15_ccnt = total_ticks - value; | ||
215 | + pmccntr_op_start(env); | ||
216 | + env->cp15.c15_ccnt = value; | ||
217 | + pmccntr_op_finish(env); | ||
218 | } | ||
219 | |||
220 | static void pmccntr_write32(CPUARMState *env, const ARMCPRegInfo *ri, | ||
221 | @@ -XXX,XX +XXX,XX @@ static void pmccntr_write32(CPUARMState *env, const ARMCPRegInfo *ri, | ||
222 | |||
223 | #else /* CONFIG_USER_ONLY */ | ||
224 | |||
225 | -void pmccntr_sync(CPUARMState *env) | ||
226 | +void pmccntr_op_start(CPUARMState *env) | ||
227 | +{ | ||
228 | +} | ||
229 | + | ||
230 | +void pmccntr_op_finish(CPUARMState *env) | ||
231 | +{ | ||
232 | +} | ||
233 | + | ||
234 | +void pmu_op_start(CPUARMState *env) | ||
235 | +{ | ||
236 | +} | ||
237 | + | ||
238 | +void pmu_op_finish(CPUARMState *env) | ||
239 | { | ||
240 | } | ||
241 | |||
242 | @@ -XXX,XX +XXX,XX @@ void pmccntr_sync(CPUARMState *env) | ||
243 | static void pmccfiltr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
244 | uint64_t value) | ||
245 | { | ||
246 | - pmccntr_sync(env); | ||
247 | + pmccntr_op_start(env); | ||
248 | env->cp15.pmccfiltr_el0 = value & 0xfc000000; | ||
249 | - pmccntr_sync(env); | ||
250 | + pmccntr_op_finish(env); | ||
251 | } | ||
252 | |||
253 | static void pmcntenset_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
254 | -- | 33 | -- |
255 | 2.20.1 | 34 | 2.25.1 |
256 | 35 | ||
257 | 36 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The PHY behind the MAC of an Aspeed SoC can be controlled using two | 3 | To propagate errors to the caller of the pre_plug callback, use the |
4 | different MDC/MDIO interfaces. The same registers PHYCR (MAC60) and | 4 | object_poperty_set*() functions directly instead of the qdev_prop_set*() |
5 | PHYDATA (MAC64) are involved but they have a different layout. | 5 | helpers. |
6 | 6 | ||
7 | BIT31 of the Feature Register (MAC40) controls which MDC/MDIO | 7 | Suggested-by: Igor Mammedov <imammedo@redhat.com> |
8 | interface is active. | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
9 | 9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | |
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
11 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | 11 | Message-id: 20211210170415.583179-5-jean-philippe@linaro.org |
12 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
13 | Message-id: 20190111125759.31577-1-clg@kaod.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 13 | --- |
16 | hw/net/ftgmac100.c | 80 +++++++++++++++++++++++++++++++++++++++------- | 14 | hw/arm/virt.c | 5 +++-- |
17 | 1 file changed, 68 insertions(+), 12 deletions(-) | 15 | 1 file changed, 3 insertions(+), 2 deletions(-) |
18 | 16 | ||
19 | diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c | 17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
20 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/net/ftgmac100.c | 19 | --- a/hw/arm/virt.c |
22 | +++ b/hw/net/ftgmac100.c | 20 | +++ b/hw/arm/virt.c |
23 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, |
24 | #define FTGMAC100_PHYDATA_MIIWDATA(x) ((x) & 0xffff) | 22 | db_start, db_end, |
25 | #define FTGMAC100_PHYDATA_MIIRDATA(x) (((x) >> 16) & 0xffff) | 23 | VIRTIO_IOMMU_RESV_MEM_T_MSI); |
26 | 24 | ||
27 | +/* | 25 | - qdev_prop_set_uint32(dev, "len-reserved-regions", 1); |
28 | + * PHY control register - New MDC/MDIO interface | 26 | - qdev_prop_set_string(dev, "reserved-regions[0]", resv_prop_str); |
29 | + */ | 27 | + object_property_set_uint(OBJECT(dev), "len-reserved-regions", 1, errp); |
30 | +#define FTGMAC100_PHYCR_NEW_DATA(x) (((x) >> 16) & 0xffff) | 28 | + object_property_set_str(OBJECT(dev), "reserved-regions[0]", |
31 | +#define FTGMAC100_PHYCR_NEW_FIRE (1 << 15) | 29 | + resv_prop_str, errp); |
32 | +#define FTGMAC100_PHYCR_NEW_ST_22 (1 << 12) | 30 | g_free(resv_prop_str); |
33 | +#define FTGMAC100_PHYCR_NEW_OP(x) (((x) >> 10) & 3) | ||
34 | +#define FTGMAC100_PHYCR_NEW_OP_WRITE 0x1 | ||
35 | +#define FTGMAC100_PHYCR_NEW_OP_READ 0x2 | ||
36 | +#define FTGMAC100_PHYCR_NEW_DEV(x) (((x) >> 5) & 0x1f) | ||
37 | +#define FTGMAC100_PHYCR_NEW_REG(x) ((x) & 0x1f) | ||
38 | + | ||
39 | /* | ||
40 | * Feature Register | ||
41 | */ | ||
42 | @@ -XXX,XX +XXX,XX @@ static void phy_reset(FTGMAC100State *s) | ||
43 | s->phy_int = 0; | ||
44 | } | ||
45 | |||
46 | -static uint32_t do_phy_read(FTGMAC100State *s, int reg) | ||
47 | +static uint16_t do_phy_read(FTGMAC100State *s, uint8_t reg) | ||
48 | { | ||
49 | - uint32_t val; | ||
50 | + uint16_t val; | ||
51 | |||
52 | switch (reg) { | ||
53 | case MII_BMCR: /* Basic Control */ | ||
54 | @@ -XXX,XX +XXX,XX @@ static uint32_t do_phy_read(FTGMAC100State *s, int reg) | ||
55 | MII_BMCR_FD | MII_BMCR_CTST) | ||
56 | #define MII_ANAR_MASK 0x2d7f | ||
57 | |||
58 | -static void do_phy_write(FTGMAC100State *s, int reg, uint32_t val) | ||
59 | +static void do_phy_write(FTGMAC100State *s, uint8_t reg, uint16_t val) | ||
60 | { | ||
61 | switch (reg) { | ||
62 | case MII_BMCR: /* Basic Control */ | ||
63 | @@ -XXX,XX +XXX,XX @@ static void do_phy_write(FTGMAC100State *s, int reg, uint32_t val) | ||
64 | } | 31 | } |
65 | } | 32 | } |
66 | |||
67 | +static void do_phy_new_ctl(FTGMAC100State *s) | ||
68 | +{ | ||
69 | + uint8_t reg; | ||
70 | + uint16_t data; | ||
71 | + | ||
72 | + if (!(s->phycr & FTGMAC100_PHYCR_NEW_ST_22)) { | ||
73 | + qemu_log_mask(LOG_UNIMP, "%s: unsupported ST code\n", __func__); | ||
74 | + return; | ||
75 | + } | ||
76 | + | ||
77 | + /* Nothing to do */ | ||
78 | + if (!(s->phycr & FTGMAC100_PHYCR_NEW_FIRE)) { | ||
79 | + return; | ||
80 | + } | ||
81 | + | ||
82 | + reg = FTGMAC100_PHYCR_NEW_REG(s->phycr); | ||
83 | + data = FTGMAC100_PHYCR_NEW_DATA(s->phycr); | ||
84 | + | ||
85 | + switch (FTGMAC100_PHYCR_NEW_OP(s->phycr)) { | ||
86 | + case FTGMAC100_PHYCR_NEW_OP_WRITE: | ||
87 | + do_phy_write(s, reg, data); | ||
88 | + break; | ||
89 | + case FTGMAC100_PHYCR_NEW_OP_READ: | ||
90 | + s->phydata = do_phy_read(s, reg) & 0xffff; | ||
91 | + break; | ||
92 | + default: | ||
93 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid OP code %08x\n", | ||
94 | + __func__, s->phycr); | ||
95 | + } | ||
96 | + | ||
97 | + s->phycr &= ~FTGMAC100_PHYCR_NEW_FIRE; | ||
98 | +} | ||
99 | + | ||
100 | +static void do_phy_ctl(FTGMAC100State *s) | ||
101 | +{ | ||
102 | + uint8_t reg = FTGMAC100_PHYCR_REG(s->phycr); | ||
103 | + | ||
104 | + if (s->phycr & FTGMAC100_PHYCR_MIIWR) { | ||
105 | + do_phy_write(s, reg, s->phydata & 0xffff); | ||
106 | + s->phycr &= ~FTGMAC100_PHYCR_MIIWR; | ||
107 | + } else if (s->phycr & FTGMAC100_PHYCR_MIIRD) { | ||
108 | + s->phydata = do_phy_read(s, reg) << 16; | ||
109 | + s->phycr &= ~FTGMAC100_PHYCR_MIIRD; | ||
110 | + } else { | ||
111 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no OP code %08x\n", | ||
112 | + __func__, s->phycr); | ||
113 | + } | ||
114 | +} | ||
115 | + | ||
116 | static int ftgmac100_read_bd(FTGMAC100Desc *bd, dma_addr_t addr) | ||
117 | { | ||
118 | if (dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd))) { | ||
119 | @@ -XXX,XX +XXX,XX @@ static void ftgmac100_write(void *opaque, hwaddr addr, | ||
120 | uint64_t value, unsigned size) | ||
121 | { | ||
122 | FTGMAC100State *s = FTGMAC100(opaque); | ||
123 | - int reg; | ||
124 | |||
125 | switch (addr & 0xff) { | ||
126 | case FTGMAC100_ISR: /* Interrupt status */ | ||
127 | @@ -XXX,XX +XXX,XX @@ static void ftgmac100_write(void *opaque, hwaddr addr, | ||
128 | break; | ||
129 | |||
130 | case FTGMAC100_PHYCR: /* PHY Device control */ | ||
131 | - reg = FTGMAC100_PHYCR_REG(value); | ||
132 | s->phycr = value; | ||
133 | - if (value & FTGMAC100_PHYCR_MIIWR) { | ||
134 | - do_phy_write(s, reg, s->phydata & 0xffff); | ||
135 | - s->phycr &= ~FTGMAC100_PHYCR_MIIWR; | ||
136 | + if (s->revr & FTGMAC100_REVR_NEW_MDIO_INTERFACE) { | ||
137 | + do_phy_new_ctl(s); | ||
138 | } else { | ||
139 | - s->phydata = do_phy_read(s, reg) << 16; | ||
140 | - s->phycr &= ~FTGMAC100_PHYCR_MIIRD; | ||
141 | + do_phy_ctl(s); | ||
142 | } | ||
143 | break; | ||
144 | case FTGMAC100_PHYDATA: | ||
145 | @@ -XXX,XX +XXX,XX @@ static void ftgmac100_write(void *opaque, hwaddr addr, | ||
146 | s->dblac = value; | ||
147 | break; | ||
148 | case FTGMAC100_REVR: /* Feature Register */ | ||
149 | - /* TODO: Only Old MDIO interface is supported */ | ||
150 | - s->revr = value & ~FTGMAC100_REVR_NEW_MDIO_INTERFACE; | ||
151 | + s->revr = value; | ||
152 | break; | ||
153 | case FTGMAC100_FEAR1: /* Feature Register 1 */ | ||
154 | s->fear1 = value; | ||
155 | -- | 33 | -- |
156 | 2.20.1 | 34 | 2.25.1 |
157 | 35 | ||
158 | 36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Add storage space for the 5 encryption keys. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190108223129.5570-2-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/cpu.h | 30 +++++++++++++++++++++++++++++- | ||
11 | 1 file changed, 29 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/cpu.h | ||
16 | +++ b/target/arm/cpu.h | ||
17 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVectorReg { | ||
18 | uint64_t d[2 * ARM_MAX_VQ] QEMU_ALIGNED(16); | ||
19 | } ARMVectorReg; | ||
20 | |||
21 | -/* In AArch32 mode, predicate registers do not exist at all. */ | ||
22 | #ifdef TARGET_AARCH64 | ||
23 | +/* In AArch32 mode, predicate registers do not exist at all. */ | ||
24 | typedef struct ARMPredicateReg { | ||
25 | uint64_t p[2 * ARM_MAX_VQ / 8] QEMU_ALIGNED(16); | ||
26 | } ARMPredicateReg; | ||
27 | + | ||
28 | +/* In AArch32 mode, PAC keys do not exist at all. */ | ||
29 | +typedef struct ARMPACKey { | ||
30 | + uint64_t lo, hi; | ||
31 | +} ARMPACKey; | ||
32 | #endif | ||
33 | |||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | ||
36 | uint32_t cregs[16]; | ||
37 | } iwmmxt; | ||
38 | |||
39 | +#ifdef TARGET_AARCH64 | ||
40 | + ARMPACKey apia_key; | ||
41 | + ARMPACKey apib_key; | ||
42 | + ARMPACKey apda_key; | ||
43 | + ARMPACKey apdb_key; | ||
44 | + ARMPACKey apga_key; | ||
45 | +#endif | ||
46 | + | ||
47 | #if defined(CONFIG_USER_ONLY) | ||
48 | /* For usermode syscall translation. */ | ||
49 | int eabi; | ||
50 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) | ||
51 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; | ||
52 | } | ||
53 | |||
54 | +static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) | ||
55 | +{ | ||
56 | + /* | ||
57 | + * Note that while QEMU will only implement the architected algorithm | ||
58 | + * QARMA, and thus APA+GPA, the host cpu for kvm may use implementation | ||
59 | + * defined algorithms, and thus API+GPI, and this predicate controls | ||
60 | + * migration of the 128-bit keys. | ||
61 | + */ | ||
62 | + return (id->id_aa64isar1 & | ||
63 | + (FIELD_DP64(0, ID_AA64ISAR1, APA, -1) | | ||
64 | + FIELD_DP64(0, ID_AA64ISAR1, API, -1) | | ||
65 | + FIELD_DP64(0, ID_AA64ISAR1, GPA, -1) | | ||
66 | + FIELD_DP64(0, ID_AA64ISAR1, GPI, -1))) != 0; | ||
67 | +} | ||
68 | + | ||
69 | static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | ||
70 | { | ||
71 | /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | ||
72 | -- | ||
73 | 2.20.1 | ||
74 | |||
75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Post v8.4 bits taken from SysReg_v85_xml-00bet8. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190108223129.5570-3-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/cpu.h | 45 +++++++++++++++++++++++++++++++++------------ | ||
11 | 1 file changed, 33 insertions(+), 12 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/cpu.h | ||
16 | +++ b/target/arm/cpu.h | ||
17 | @@ -XXX,XX +XXX,XX @@ void pmccntr_sync(CPUARMState *env); | ||
18 | #define SCTLR_A (1U << 1) | ||
19 | #define SCTLR_C (1U << 2) | ||
20 | #define SCTLR_W (1U << 3) /* up to v6; RAO in v7 */ | ||
21 | -#define SCTLR_SA (1U << 3) | ||
22 | +#define SCTLR_nTLSMD_32 (1U << 3) /* v8.2-LSMAOC, AArch32 only */ | ||
23 | +#define SCTLR_SA (1U << 3) /* AArch64 only */ | ||
24 | #define SCTLR_P (1U << 4) /* up to v5; RAO in v6 and v7 */ | ||
25 | +#define SCTLR_LSMAOE_32 (1U << 4) /* v8.2-LSMAOC, AArch32 only */ | ||
26 | #define SCTLR_SA0 (1U << 4) /* v8 onward, AArch64 only */ | ||
27 | #define SCTLR_D (1U << 5) /* up to v5; RAO in v6 */ | ||
28 | #define SCTLR_CP15BEN (1U << 5) /* v7 onward */ | ||
29 | #define SCTLR_L (1U << 6) /* up to v5; RAO in v6 and v7; RAZ in v8 */ | ||
30 | +#define SCTLR_nAA (1U << 6) /* when v8.4-LSE is implemented */ | ||
31 | #define SCTLR_B (1U << 7) /* up to v6; RAZ in v7 */ | ||
32 | #define SCTLR_ITD (1U << 7) /* v8 onward */ | ||
33 | #define SCTLR_S (1U << 8) /* up to v6; RAZ in v7 */ | ||
34 | @@ -XXX,XX +XXX,XX @@ void pmccntr_sync(CPUARMState *env); | ||
35 | #define SCTLR_R (1U << 9) /* up to v6; RAZ in v7 */ | ||
36 | #define SCTLR_UMA (1U << 9) /* v8 onward, AArch64 only */ | ||
37 | #define SCTLR_F (1U << 10) /* up to v6 */ | ||
38 | -#define SCTLR_SW (1U << 10) /* v7 onward */ | ||
39 | -#define SCTLR_Z (1U << 11) | ||
40 | +#define SCTLR_SW (1U << 10) /* v7, RES0 in v8 */ | ||
41 | +#define SCTLR_Z (1U << 11) /* in v7, RES1 in v8 */ | ||
42 | +#define SCTLR_EOS (1U << 11) /* v8.5-ExS */ | ||
43 | #define SCTLR_I (1U << 12) | ||
44 | -#define SCTLR_V (1U << 13) | ||
45 | +#define SCTLR_V (1U << 13) /* AArch32 only */ | ||
46 | +#define SCTLR_EnDB (1U << 13) /* v8.3, AArch64 only */ | ||
47 | #define SCTLR_RR (1U << 14) /* up to v7 */ | ||
48 | #define SCTLR_DZE (1U << 14) /* v8 onward, AArch64 only */ | ||
49 | #define SCTLR_L4 (1U << 15) /* up to v6; RAZ in v7 */ | ||
50 | #define SCTLR_UCT (1U << 15) /* v8 onward, AArch64 only */ | ||
51 | #define SCTLR_DT (1U << 16) /* up to ??, RAO in v6 and v7 */ | ||
52 | #define SCTLR_nTWI (1U << 16) /* v8 onward */ | ||
53 | -#define SCTLR_HA (1U << 17) | ||
54 | +#define SCTLR_HA (1U << 17) /* up to v7, RES0 in v8 */ | ||
55 | #define SCTLR_BR (1U << 17) /* PMSA only */ | ||
56 | #define SCTLR_IT (1U << 18) /* up to ??, RAO in v6 and v7 */ | ||
57 | #define SCTLR_nTWE (1U << 18) /* v8 onward */ | ||
58 | #define SCTLR_WXN (1U << 19) | ||
59 | #define SCTLR_ST (1U << 20) /* up to ??, RAZ in v6 */ | ||
60 | -#define SCTLR_UWXN (1U << 20) /* v7 onward */ | ||
61 | -#define SCTLR_FI (1U << 21) | ||
62 | -#define SCTLR_U (1U << 22) | ||
63 | +#define SCTLR_UWXN (1U << 20) /* v7 onward, AArch32 only */ | ||
64 | +#define SCTLR_FI (1U << 21) /* up to v7, v8 RES0 */ | ||
65 | +#define SCTLR_IESB (1U << 21) /* v8.2-IESB, AArch64 only */ | ||
66 | +#define SCTLR_U (1U << 22) /* up to v6, RAO in v7 */ | ||
67 | +#define SCTLR_EIS (1U << 22) /* v8.5-ExS */ | ||
68 | #define SCTLR_XP (1U << 23) /* up to v6; v7 onward RAO */ | ||
69 | +#define SCTLR_SPAN (1U << 23) /* v8.1-PAN */ | ||
70 | #define SCTLR_VE (1U << 24) /* up to v7 */ | ||
71 | #define SCTLR_E0E (1U << 24) /* v8 onward, AArch64 only */ | ||
72 | #define SCTLR_EE (1U << 25) | ||
73 | #define SCTLR_L2 (1U << 26) /* up to v6, RAZ in v7 */ | ||
74 | #define SCTLR_UCI (1U << 26) /* v8 onward, AArch64 only */ | ||
75 | -#define SCTLR_NMFI (1U << 27) | ||
76 | -#define SCTLR_TRE (1U << 28) | ||
77 | -#define SCTLR_AFE (1U << 29) | ||
78 | -#define SCTLR_TE (1U << 30) | ||
79 | +#define SCTLR_NMFI (1U << 27) /* up to v7, RAZ in v7VE and v8 */ | ||
80 | +#define SCTLR_EnDA (1U << 27) /* v8.3, AArch64 only */ | ||
81 | +#define SCTLR_TRE (1U << 28) /* AArch32 only */ | ||
82 | +#define SCTLR_nTLSMD_64 (1U << 28) /* v8.2-LSMAOC, AArch64 only */ | ||
83 | +#define SCTLR_AFE (1U << 29) /* AArch32 only */ | ||
84 | +#define SCTLR_LSMAOE_64 (1U << 29) /* v8.2-LSMAOC, AArch64 only */ | ||
85 | +#define SCTLR_TE (1U << 30) /* AArch32 only */ | ||
86 | +#define SCTLR_EnIB (1U << 30) /* v8.3, AArch64 only */ | ||
87 | +#define SCTLR_EnIA (1U << 31) /* v8.3, AArch64 only */ | ||
88 | +#define SCTLR_BT0 (1ULL << 35) /* v8.5-BTI */ | ||
89 | +#define SCTLR_BT1 (1ULL << 36) /* v8.5-BTI */ | ||
90 | +#define SCTLR_ITFSB (1ULL << 37) /* v8.5-MemTag */ | ||
91 | +#define SCTLR_TCF0 (3ULL << 38) /* v8.5-MemTag */ | ||
92 | +#define SCTLR_TCF (3ULL << 40) /* v8.5-MemTag */ | ||
93 | +#define SCTLR_ATA0 (1ULL << 42) /* v8.5-MemTag */ | ||
94 | +#define SCTLR_ATA (1ULL << 43) /* v8.5-MemTag */ | ||
95 | +#define SCTLR_DSSBS (1ULL << 44) /* v8.5 */ | ||
96 | |||
97 | #define CPTR_TCPAC (1U << 31) | ||
98 | #define CPTR_TTA (1U << 20) | ||
99 | -- | ||
100 | 2.20.1 | ||
101 | |||
102 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | There are 5 bits of state that could be added, but to save | ||
4 | space within tbflags, add only a single enable bit. | ||
5 | Helpers will determine the rest of the state at runtime. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190108223129.5570-4-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 1 + | ||
13 | target/arm/translate.h | 2 ++ | ||
14 | target/arm/helper.c | 19 +++++++++++++++++++ | ||
15 | target/arm/translate-a64.c | 1 + | ||
16 | 4 files changed, 23 insertions(+) | ||
17 | |||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu.h | ||
21 | +++ b/target/arm/cpu.h | ||
22 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, TBI0, 0, 1) | ||
23 | FIELD(TBFLAG_A64, TBI1, 1, 1) | ||
24 | FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) | ||
25 | FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) | ||
26 | +FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) | ||
27 | |||
28 | static inline bool bswap_code(bool sctlr_b) | ||
29 | { | ||
30 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate.h | ||
33 | +++ b/target/arm/translate.h | ||
34 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
35 | bool is_ldex; | ||
36 | /* True if a single-step exception will be taken to the current EL */ | ||
37 | bool ss_same_el; | ||
38 | + /* True if v8.3-PAuth is active. */ | ||
39 | + bool pauth_active; | ||
40 | /* Bottom two bits of XScale c15_cpar coprocessor access control reg */ | ||
41 | int c15_cpar; | ||
42 | /* TCG op of the current insn_start. */ | ||
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 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
48 | flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); | ||
49 | flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); | ||
50 | } | ||
51 | + | ||
52 | + if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
53 | + /* | ||
54 | + * In order to save space in flags, we record only whether | ||
55 | + * pauth is "inactive", meaning all insns are implemented as | ||
56 | + * a nop, or "active" when some action must be performed. | ||
57 | + * The decision of which action to take is left to a helper. | ||
58 | + */ | ||
59 | + uint64_t sctlr; | ||
60 | + if (current_el == 0) { | ||
61 | + /* FIXME: ARMv8.1-VHE S2 translation regime. */ | ||
62 | + sctlr = env->cp15.sctlr_el[1]; | ||
63 | + } else { | ||
64 | + sctlr = env->cp15.sctlr_el[current_el]; | ||
65 | + } | ||
66 | + if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { | ||
67 | + flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); | ||
68 | + } | ||
69 | + } | ||
70 | } else { | ||
71 | *pc = env->regs[15]; | ||
72 | flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); | ||
73 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/translate-a64.c | ||
76 | +++ b/target/arm/translate-a64.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
78 | dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL); | ||
79 | dc->sve_excp_el = FIELD_EX32(tb_flags, TBFLAG_A64, SVEEXC_EL); | ||
80 | dc->sve_len = (FIELD_EX32(tb_flags, TBFLAG_A64, ZCR_LEN) + 1) * 16; | ||
81 | + dc->pauth_active = FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE); | ||
82 | dc->vec_len = 0; | ||
83 | dc->vec_stride = 0; | ||
84 | dc->cp_regs = arm_cpu->cp_regs; | ||
85 | -- | ||
86 | 2.20.1 | ||
87 | |||
88 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This path uses cpu_loop_exit_restore to unwind current processor state. | ||
4 | |||
5 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20190108223129.5570-5-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/internals.h | 7 +++++++ | ||
12 | target/arm/op_helper.c | 19 +++++++++++++++++-- | ||
13 | 2 files changed, 24 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/internals.h | ||
18 | +++ b/target/arm/internals.h | ||
19 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_EXCRET, RES1, 7, 25) /* including the must-be-1 prefix */ | ||
20 | void QEMU_NORETURN raise_exception(CPUARMState *env, uint32_t excp, | ||
21 | uint32_t syndrome, uint32_t target_el); | ||
22 | |||
23 | +/* | ||
24 | + * Similarly, but also use unwinding to restore cpu state. | ||
25 | + */ | ||
26 | +void QEMU_NORETURN raise_exception_ra(CPUARMState *env, uint32_t excp, | ||
27 | + uint32_t syndrome, uint32_t target_el, | ||
28 | + uintptr_t ra); | ||
29 | + | ||
30 | /* | ||
31 | * For AArch64, map a given EL to an index in the banked_spsr array. | ||
32 | * Note that this mapping and the AArch32 mapping defined in bank_number() | ||
33 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/op_helper.c | ||
36 | +++ b/target/arm/op_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | #define SIGNBIT (uint32_t)0x80000000 | ||
39 | #define SIGNBIT64 ((uint64_t)1 << 63) | ||
40 | |||
41 | -void raise_exception(CPUARMState *env, uint32_t excp, | ||
42 | - uint32_t syndrome, uint32_t target_el) | ||
43 | +static CPUState *do_raise_exception(CPUARMState *env, uint32_t excp, | ||
44 | + uint32_t syndrome, uint32_t target_el) | ||
45 | { | ||
46 | CPUState *cs = CPU(arm_env_get_cpu(env)); | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ void raise_exception(CPUARMState *env, uint32_t excp, | ||
49 | cs->exception_index = excp; | ||
50 | env->exception.syndrome = syndrome; | ||
51 | env->exception.target_el = target_el; | ||
52 | + | ||
53 | + return cs; | ||
54 | +} | ||
55 | + | ||
56 | +void raise_exception(CPUARMState *env, uint32_t excp, | ||
57 | + uint32_t syndrome, uint32_t target_el) | ||
58 | +{ | ||
59 | + CPUState *cs = do_raise_exception(env, excp, syndrome, target_el); | ||
60 | cpu_loop_exit(cs); | ||
61 | } | ||
62 | |||
63 | +void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome, | ||
64 | + uint32_t target_el, uintptr_t ra) | ||
65 | +{ | ||
66 | + CPUState *cs = do_raise_exception(env, excp, syndrome, target_el); | ||
67 | + cpu_loop_exit_restore(cs, ra); | ||
68 | +} | ||
69 | + | ||
70 | static int exception_target_el(CPUARMState *env) | ||
71 | { | ||
72 | int target_el = MAX(1, arm_current_el(env)); | ||
73 | -- | ||
74 | 2.20.1 | ||
75 | |||
76 | 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: 20190108223129.5570-9-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-a64.c | 146 +++++++++++++++++++++++++++++++++++++ | ||
9 | 1 file changed, 146 insertions(+) | ||
10 | |||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-a64.c | ||
14 | +++ b/target/arm/translate-a64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void handle_rev16(DisasContext *s, unsigned int sf, | ||
16 | static void disas_data_proc_1src(DisasContext *s, uint32_t insn) | ||
17 | { | ||
18 | unsigned int sf, opcode, opcode2, rn, rd; | ||
19 | + TCGv_i64 tcg_rd; | ||
20 | |||
21 | if (extract32(insn, 29, 1)) { | ||
22 | unallocated_encoding(s); | ||
23 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_1src(DisasContext *s, uint32_t insn) | ||
24 | case MAP(1, 0x00, 0x05): | ||
25 | handle_cls(s, sf, rn, rd); | ||
26 | break; | ||
27 | + case MAP(1, 0x01, 0x00): /* PACIA */ | ||
28 | + if (s->pauth_active) { | ||
29 | + tcg_rd = cpu_reg(s, rd); | ||
30 | + gen_helper_pacia(tcg_rd, cpu_env, tcg_rd, cpu_reg_sp(s, rn)); | ||
31 | + } else if (!dc_isar_feature(aa64_pauth, s)) { | ||
32 | + goto do_unallocated; | ||
33 | + } | ||
34 | + break; | ||
35 | + case MAP(1, 0x01, 0x01): /* PACIB */ | ||
36 | + if (s->pauth_active) { | ||
37 | + tcg_rd = cpu_reg(s, rd); | ||
38 | + gen_helper_pacib(tcg_rd, cpu_env, tcg_rd, cpu_reg_sp(s, rn)); | ||
39 | + } else if (!dc_isar_feature(aa64_pauth, s)) { | ||
40 | + goto do_unallocated; | ||
41 | + } | ||
42 | + break; | ||
43 | + case MAP(1, 0x01, 0x02): /* PACDA */ | ||
44 | + if (s->pauth_active) { | ||
45 | + tcg_rd = cpu_reg(s, rd); | ||
46 | + gen_helper_pacda(tcg_rd, cpu_env, tcg_rd, cpu_reg_sp(s, rn)); | ||
47 | + } else if (!dc_isar_feature(aa64_pauth, s)) { | ||
48 | + goto do_unallocated; | ||
49 | + } | ||
50 | + break; | ||
51 | + case MAP(1, 0x01, 0x03): /* PACDB */ | ||
52 | + if (s->pauth_active) { | ||
53 | + tcg_rd = cpu_reg(s, rd); | ||
54 | + gen_helper_pacdb(tcg_rd, cpu_env, tcg_rd, cpu_reg_sp(s, rn)); | ||
55 | + } else if (!dc_isar_feature(aa64_pauth, s)) { | ||
56 | + goto do_unallocated; | ||
57 | + } | ||
58 | + break; | ||
59 | + case MAP(1, 0x01, 0x04): /* AUTIA */ | ||
60 | + if (s->pauth_active) { | ||
61 | + tcg_rd = cpu_reg(s, rd); | ||
62 | + gen_helper_autia(tcg_rd, cpu_env, tcg_rd, cpu_reg_sp(s, rn)); | ||
63 | + } else if (!dc_isar_feature(aa64_pauth, s)) { | ||
64 | + goto do_unallocated; | ||
65 | + } | ||
66 | + break; | ||
67 | + case MAP(1, 0x01, 0x05): /* AUTIB */ | ||
68 | + if (s->pauth_active) { | ||
69 | + tcg_rd = cpu_reg(s, rd); | ||
70 | + gen_helper_autib(tcg_rd, cpu_env, tcg_rd, cpu_reg_sp(s, rn)); | ||
71 | + } else if (!dc_isar_feature(aa64_pauth, s)) { | ||
72 | + goto do_unallocated; | ||
73 | + } | ||
74 | + break; | ||
75 | + case MAP(1, 0x01, 0x06): /* AUTDA */ | ||
76 | + if (s->pauth_active) { | ||
77 | + tcg_rd = cpu_reg(s, rd); | ||
78 | + gen_helper_autda(tcg_rd, cpu_env, tcg_rd, cpu_reg_sp(s, rn)); | ||
79 | + } else if (!dc_isar_feature(aa64_pauth, s)) { | ||
80 | + goto do_unallocated; | ||
81 | + } | ||
82 | + break; | ||
83 | + case MAP(1, 0x01, 0x07): /* AUTDB */ | ||
84 | + if (s->pauth_active) { | ||
85 | + tcg_rd = cpu_reg(s, rd); | ||
86 | + gen_helper_autdb(tcg_rd, cpu_env, tcg_rd, cpu_reg_sp(s, rn)); | ||
87 | + } else if (!dc_isar_feature(aa64_pauth, s)) { | ||
88 | + goto do_unallocated; | ||
89 | + } | ||
90 | + break; | ||
91 | + case MAP(1, 0x01, 0x08): /* PACIZA */ | ||
92 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
93 | + goto do_unallocated; | ||
94 | + } else if (s->pauth_active) { | ||
95 | + tcg_rd = cpu_reg(s, rd); | ||
96 | + gen_helper_pacia(tcg_rd, cpu_env, tcg_rd, new_tmp_a64_zero(s)); | ||
97 | + } | ||
98 | + break; | ||
99 | + case MAP(1, 0x01, 0x09): /* PACIZB */ | ||
100 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
101 | + goto do_unallocated; | ||
102 | + } else if (s->pauth_active) { | ||
103 | + tcg_rd = cpu_reg(s, rd); | ||
104 | + gen_helper_pacib(tcg_rd, cpu_env, tcg_rd, new_tmp_a64_zero(s)); | ||
105 | + } | ||
106 | + break; | ||
107 | + case MAP(1, 0x01, 0x0a): /* PACDZA */ | ||
108 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
109 | + goto do_unallocated; | ||
110 | + } else if (s->pauth_active) { | ||
111 | + tcg_rd = cpu_reg(s, rd); | ||
112 | + gen_helper_pacda(tcg_rd, cpu_env, tcg_rd, new_tmp_a64_zero(s)); | ||
113 | + } | ||
114 | + break; | ||
115 | + case MAP(1, 0x01, 0x0b): /* PACDZB */ | ||
116 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
117 | + goto do_unallocated; | ||
118 | + } else if (s->pauth_active) { | ||
119 | + tcg_rd = cpu_reg(s, rd); | ||
120 | + gen_helper_pacdb(tcg_rd, cpu_env, tcg_rd, new_tmp_a64_zero(s)); | ||
121 | + } | ||
122 | + break; | ||
123 | + case MAP(1, 0x01, 0x0c): /* AUTIZA */ | ||
124 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
125 | + goto do_unallocated; | ||
126 | + } else if (s->pauth_active) { | ||
127 | + tcg_rd = cpu_reg(s, rd); | ||
128 | + gen_helper_autia(tcg_rd, cpu_env, tcg_rd, new_tmp_a64_zero(s)); | ||
129 | + } | ||
130 | + break; | ||
131 | + case MAP(1, 0x01, 0x0d): /* AUTIZB */ | ||
132 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
133 | + goto do_unallocated; | ||
134 | + } else if (s->pauth_active) { | ||
135 | + tcg_rd = cpu_reg(s, rd); | ||
136 | + gen_helper_autib(tcg_rd, cpu_env, tcg_rd, new_tmp_a64_zero(s)); | ||
137 | + } | ||
138 | + break; | ||
139 | + case MAP(1, 0x01, 0x0e): /* AUTDZA */ | ||
140 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
141 | + goto do_unallocated; | ||
142 | + } else if (s->pauth_active) { | ||
143 | + tcg_rd = cpu_reg(s, rd); | ||
144 | + gen_helper_autda(tcg_rd, cpu_env, tcg_rd, new_tmp_a64_zero(s)); | ||
145 | + } | ||
146 | + break; | ||
147 | + case MAP(1, 0x01, 0x0f): /* AUTDZB */ | ||
148 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
149 | + goto do_unallocated; | ||
150 | + } else if (s->pauth_active) { | ||
151 | + tcg_rd = cpu_reg(s, rd); | ||
152 | + gen_helper_autdb(tcg_rd, cpu_env, tcg_rd, new_tmp_a64_zero(s)); | ||
153 | + } | ||
154 | + break; | ||
155 | + case MAP(1, 0x01, 0x10): /* XPACI */ | ||
156 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
157 | + goto do_unallocated; | ||
158 | + } else if (s->pauth_active) { | ||
159 | + tcg_rd = cpu_reg(s, rd); | ||
160 | + gen_helper_xpaci(tcg_rd, cpu_env, tcg_rd); | ||
161 | + } | ||
162 | + break; | ||
163 | + case MAP(1, 0x01, 0x11): /* XPACD */ | ||
164 | + if (!dc_isar_feature(aa64_pauth, s) || rn != 31) { | ||
165 | + goto do_unallocated; | ||
166 | + } else if (s->pauth_active) { | ||
167 | + tcg_rd = cpu_reg(s, rd); | ||
168 | + gen_helper_xpacd(tcg_rd, cpu_env, tcg_rd); | ||
169 | + } | ||
170 | + break; | ||
171 | default: | ||
172 | + do_unallocated: | ||
173 | unallocated_encoding(s); | ||
174 | break; | ||
175 | } | ||
176 | -- | ||
177 | 2.20.1 | ||
178 | |||
179 | 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: 20190108223129.5570-10-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-a64.c | 8 ++++++++ | ||
9 | 1 file changed, 8 insertions(+) | ||
10 | |||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-a64.c | ||
14 | +++ b/target/arm/translate-a64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn) | ||
16 | case 11: /* RORV */ | ||
17 | handle_shift_reg(s, A64_SHIFT_TYPE_ROR, sf, rm, rn, rd); | ||
18 | break; | ||
19 | + case 12: /* PACGA */ | ||
20 | + if (sf == 0 || !dc_isar_feature(aa64_pauth, s)) { | ||
21 | + goto do_unallocated; | ||
22 | + } | ||
23 | + gen_helper_pacga(cpu_reg(s, rd), cpu_env, | ||
24 | + cpu_reg(s, rn), cpu_reg_sp(s, rm)); | ||
25 | + break; | ||
26 | case 16: | ||
27 | case 17: | ||
28 | case 18: | ||
29 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn) | ||
30 | break; | ||
31 | } | ||
32 | default: | ||
33 | + do_unallocated: | ||
34 | unallocated_encoding(s); | ||
35 | break; | ||
36 | } | ||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | 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: 20190108223129.5570-12-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-a64.h | 2 +- | ||
9 | target/arm/helper-a64.c | 10 +++++----- | ||
10 | target/arm/translate-a64.c | 7 ++++++- | ||
11 | 3 files changed, 12 insertions(+), 7 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-a64.h | ||
16 | +++ b/target/arm/helper-a64.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) | ||
18 | DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) | ||
19 | DEF_HELPER_2(sqrt_f16, f16, f16, ptr) | ||
20 | |||
21 | -DEF_HELPER_1(exception_return, void, env) | ||
22 | +DEF_HELPER_2(exception_return, void, env, i64) | ||
23 | |||
24 | DEF_HELPER_FLAGS_3(pacia, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
25 | DEF_HELPER_FLAGS_3(pacib, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
26 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/helper-a64.c | ||
29 | +++ b/target/arm/helper-a64.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static int el_from_spsr(uint32_t spsr) | ||
31 | } | ||
32 | } | ||
33 | |||
34 | -void HELPER(exception_return)(CPUARMState *env) | ||
35 | +void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | ||
36 | { | ||
37 | int cur_el = arm_current_el(env); | ||
38 | unsigned int spsr_idx = aarch64_banked_spsr_index(cur_el); | ||
39 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env) | ||
40 | aarch64_sync_64_to_32(env); | ||
41 | |||
42 | if (spsr & CPSR_T) { | ||
43 | - env->regs[15] = env->elr_el[cur_el] & ~0x1; | ||
44 | + env->regs[15] = new_pc & ~0x1; | ||
45 | } else { | ||
46 | - env->regs[15] = env->elr_el[cur_el] & ~0x3; | ||
47 | + env->regs[15] = new_pc & ~0x3; | ||
48 | } | ||
49 | qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | ||
50 | "AArch32 EL%d PC 0x%" PRIx32 "\n", | ||
51 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env) | ||
52 | env->pstate &= ~PSTATE_SS; | ||
53 | } | ||
54 | aarch64_restore_sp(env, new_el); | ||
55 | - env->pc = env->elr_el[cur_el]; | ||
56 | + env->pc = new_pc; | ||
57 | qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | ||
58 | "AArch64 EL%d PC 0x%" PRIx64 "\n", | ||
59 | cur_el, new_el, env->pc); | ||
60 | @@ -XXX,XX +XXX,XX @@ illegal_return: | ||
61 | * no change to exception level, execution state or stack pointer | ||
62 | */ | ||
63 | env->pstate |= PSTATE_IL; | ||
64 | - env->pc = env->elr_el[cur_el]; | ||
65 | + env->pc = new_pc; | ||
66 | spsr &= PSTATE_NZCV | PSTATE_DAIF; | ||
67 | spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF); | ||
68 | pstate_write(env, spsr); | ||
69 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/translate-a64.c | ||
72 | +++ b/target/arm/translate-a64.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
74 | static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
75 | { | ||
76 | unsigned int opc, op2, op3, rn, op4; | ||
77 | + TCGv_i64 dst; | ||
78 | |||
79 | opc = extract32(insn, 21, 4); | ||
80 | op2 = extract32(insn, 16, 5); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
82 | if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
83 | gen_io_start(); | ||
84 | } | ||
85 | - gen_helper_exception_return(cpu_env); | ||
86 | + dst = tcg_temp_new_i64(); | ||
87 | + tcg_gen_ld_i64(dst, cpu_env, | ||
88 | + offsetof(CPUARMState, elr_el[s->current_el])); | ||
89 | + gen_helper_exception_return(cpu_env, dst); | ||
90 | + tcg_temp_free_i64(dst); | ||
91 | if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
92 | gen_io_end(); | ||
93 | } | ||
94 | -- | ||
95 | 2.20.1 | ||
96 | |||
97 | 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: 20190108223129.5570-14-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-a64.c | 82 +++++++++++++++++++++++++++++++++++++- | ||
9 | 1 file changed, 81 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-a64.c | ||
14 | +++ b/target/arm/translate-a64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
16 | { | ||
17 | unsigned int opc, op2, op3, rn, op4; | ||
18 | TCGv_i64 dst; | ||
19 | + TCGv_i64 modifier; | ||
20 | |||
21 | opc = extract32(insn, 21, 4); | ||
22 | op2 = extract32(insn, 16, 5); | ||
23 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
24 | case 2: /* RET */ | ||
25 | switch (op3) { | ||
26 | case 0: | ||
27 | + /* BR, BLR, RET */ | ||
28 | if (op4 != 0) { | ||
29 | goto do_unallocated; | ||
30 | } | ||
31 | dst = cpu_reg(s, rn); | ||
32 | break; | ||
33 | |||
34 | + case 2: | ||
35 | + case 3: | ||
36 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
37 | + goto do_unallocated; | ||
38 | + } | ||
39 | + if (opc == 2) { | ||
40 | + /* RETAA, RETAB */ | ||
41 | + if (rn != 0x1f || op4 != 0x1f) { | ||
42 | + goto do_unallocated; | ||
43 | + } | ||
44 | + rn = 30; | ||
45 | + modifier = cpu_X[31]; | ||
46 | + } else { | ||
47 | + /* BRAAZ, BRABZ, BLRAAZ, BLRABZ */ | ||
48 | + if (op4 != 0x1f) { | ||
49 | + goto do_unallocated; | ||
50 | + } | ||
51 | + modifier = new_tmp_a64_zero(s); | ||
52 | + } | ||
53 | + if (s->pauth_active) { | ||
54 | + dst = new_tmp_a64(s); | ||
55 | + if (op3 == 2) { | ||
56 | + gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
57 | + } else { | ||
58 | + gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
59 | + } | ||
60 | + } else { | ||
61 | + dst = cpu_reg(s, rn); | ||
62 | + } | ||
63 | + break; | ||
64 | + | ||
65 | default: | ||
66 | goto do_unallocated; | ||
67 | } | ||
68 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
69 | } | ||
70 | break; | ||
71 | |||
72 | + case 8: /* BRAA */ | ||
73 | + case 9: /* BLRAA */ | ||
74 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
75 | + goto do_unallocated; | ||
76 | + } | ||
77 | + if (op3 != 2 || op3 != 3) { | ||
78 | + goto do_unallocated; | ||
79 | + } | ||
80 | + if (s->pauth_active) { | ||
81 | + dst = new_tmp_a64(s); | ||
82 | + modifier = cpu_reg_sp(s, op4); | ||
83 | + if (op3 == 2) { | ||
84 | + gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
85 | + } else { | ||
86 | + gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
87 | + } | ||
88 | + } else { | ||
89 | + dst = cpu_reg(s, rn); | ||
90 | + } | ||
91 | + gen_a64_set_pc(s, dst); | ||
92 | + /* BLRAA also needs to load return address */ | ||
93 | + if (opc == 9) { | ||
94 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
95 | + } | ||
96 | + break; | ||
97 | + | ||
98 | case 4: /* ERET */ | ||
99 | if (s->current_el == 0) { | ||
100 | goto do_unallocated; | ||
101 | } | ||
102 | switch (op3) { | ||
103 | - case 0: | ||
104 | + case 0: /* ERET */ | ||
105 | if (op4 != 0) { | ||
106 | goto do_unallocated; | ||
107 | } | ||
108 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
109 | offsetof(CPUARMState, elr_el[s->current_el])); | ||
110 | break; | ||
111 | |||
112 | + case 2: /* ERETAA */ | ||
113 | + case 3: /* ERETAB */ | ||
114 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
115 | + goto do_unallocated; | ||
116 | + } | ||
117 | + if (rn != 0x1f || op4 != 0x1f) { | ||
118 | + goto do_unallocated; | ||
119 | + } | ||
120 | + dst = tcg_temp_new_i64(); | ||
121 | + tcg_gen_ld_i64(dst, cpu_env, | ||
122 | + offsetof(CPUARMState, elr_el[s->current_el])); | ||
123 | + if (s->pauth_active) { | ||
124 | + modifier = cpu_X[31]; | ||
125 | + if (op3 == 2) { | ||
126 | + gen_helper_autia(dst, cpu_env, dst, modifier); | ||
127 | + } else { | ||
128 | + gen_helper_autib(dst, cpu_env, dst, modifier); | ||
129 | + } | ||
130 | + } | ||
131 | + break; | ||
132 | + | ||
133 | default: | ||
134 | goto do_unallocated; | ||
135 | } | ||
136 | -- | ||
137 | 2.20.1 | ||
138 | |||
139 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This function is, or will shortly become, too big to inline. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190108223129.5570-16-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/cpu.h | 48 +++++---------------------------------------- | ||
11 | target/arm/helper.c | 44 +++++++++++++++++++++++++++++++++++++++++ | ||
12 | 2 files changed, 49 insertions(+), 43 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpu.h | ||
17 | +++ b/target/arm/cpu.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) | ||
19 | } | ||
20 | |||
21 | /* Return the MMU index for a v7M CPU in the specified security and | ||
22 | - * privilege state | ||
23 | + * privilege state. | ||
24 | */ | ||
25 | -static inline ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
26 | - bool secstate, | ||
27 | - bool priv) | ||
28 | -{ | ||
29 | - ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; | ||
30 | - | ||
31 | - if (priv) { | ||
32 | - mmu_idx |= ARM_MMU_IDX_M_PRIV; | ||
33 | - } | ||
34 | - | ||
35 | - if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) { | ||
36 | - mmu_idx |= ARM_MMU_IDX_M_NEGPRI; | ||
37 | - } | ||
38 | - | ||
39 | - if (secstate) { | ||
40 | - mmu_idx |= ARM_MMU_IDX_M_S; | ||
41 | - } | ||
42 | - | ||
43 | - return mmu_idx; | ||
44 | -} | ||
45 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
46 | + bool secstate, bool priv); | ||
47 | |||
48 | /* Return the MMU index for a v7M CPU in the specified security state */ | ||
49 | -static inline ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, | ||
50 | - bool secstate) | ||
51 | -{ | ||
52 | - bool priv = arm_current_el(env) != 0; | ||
53 | - | ||
54 | - return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | ||
55 | -} | ||
56 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); | ||
57 | |||
58 | /* Determine the current mmu_idx to use for normal loads/stores */ | ||
59 | -static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
60 | -{ | ||
61 | - int el = arm_current_el(env); | ||
62 | - | ||
63 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
64 | - ARMMMUIdx mmu_idx = arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure); | ||
65 | - | ||
66 | - return arm_to_core_mmu_idx(mmu_idx); | ||
67 | - } | ||
68 | - | ||
69 | - if (el < 2 && arm_is_secure_below_el3(env)) { | ||
70 | - return arm_to_core_mmu_idx(ARMMMUIdx_S1SE0 + el); | ||
71 | - } | ||
72 | - return el; | ||
73 | -} | ||
74 | +int cpu_mmu_index(CPUARMState *env, bool ifetch); | ||
75 | |||
76 | /* Indexes used when registering address spaces with cpu_address_space_init */ | ||
77 | typedef enum ARMASIdx { | ||
78 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/target/arm/helper.c | ||
81 | +++ b/target/arm/helper.c | ||
82 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | ||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
87 | + bool secstate, bool priv) | ||
88 | +{ | ||
89 | + ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; | ||
90 | + | ||
91 | + if (priv) { | ||
92 | + mmu_idx |= ARM_MMU_IDX_M_PRIV; | ||
93 | + } | ||
94 | + | ||
95 | + if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) { | ||
96 | + mmu_idx |= ARM_MMU_IDX_M_NEGPRI; | ||
97 | + } | ||
98 | + | ||
99 | + if (secstate) { | ||
100 | + mmu_idx |= ARM_MMU_IDX_M_S; | ||
101 | + } | ||
102 | + | ||
103 | + return mmu_idx; | ||
104 | +} | ||
105 | + | ||
106 | +/* Return the MMU index for a v7M CPU in the specified security state */ | ||
107 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
108 | +{ | ||
109 | + bool priv = arm_current_el(env) != 0; | ||
110 | + | ||
111 | + return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | ||
112 | +} | ||
113 | + | ||
114 | +int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
115 | +{ | ||
116 | + int el = arm_current_el(env); | ||
117 | + | ||
118 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
119 | + ARMMMUIdx mmu_idx = arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure); | ||
120 | + | ||
121 | + return arm_to_core_mmu_idx(mmu_idx); | ||
122 | + } | ||
123 | + | ||
124 | + if (el < 2 && arm_is_secure_below_el3(env)) { | ||
125 | + return arm_to_core_mmu_idx(ARMMMUIdx_S1SE0 + el); | ||
126 | + } | ||
127 | + return el; | ||
128 | +} | ||
129 | + | ||
130 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
131 | target_ulong *cs_base, uint32_t *pflags) | ||
132 | { | ||
133 | -- | ||
134 | 2.20.1 | ||
135 | |||
136 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | The pattern | ||
4 | |||
5 | ARMMMUIdx mmu_idx = core_to_arm_mmu_idx(env, cpu_mmu_index(env, false)); | ||
6 | |||
7 | is computing the full ARMMMUIdx, stripping off the ARM bits, | ||
8 | and then putting them back. | ||
9 | |||
10 | Avoid the extra two steps with the appropriate helper function. | ||
11 | |||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20190108223129.5570-17-richard.henderson@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/cpu.h | 9 ++++++++- | ||
18 | target/arm/internals.h | 8 ++++++++ | ||
19 | target/arm/helper.c | 27 ++++++++++++++++----------- | ||
20 | 3 files changed, 32 insertions(+), 12 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/cpu.h | ||
25 | +++ b/target/arm/cpu.h | ||
26 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
27 | /* Return the MMU index for a v7M CPU in the specified security state */ | ||
28 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); | ||
29 | |||
30 | -/* Determine the current mmu_idx to use for normal loads/stores */ | ||
31 | +/** | ||
32 | + * cpu_mmu_index: | ||
33 | + * @env: The cpu environment | ||
34 | + * @ifetch: True for code access, false for data access. | ||
35 | + * | ||
36 | + * Return the core mmu index for the current translation regime. | ||
37 | + * This function is used by generic TCG code paths. | ||
38 | + */ | ||
39 | int cpu_mmu_index(CPUARMState *env, bool ifetch); | ||
40 | |||
41 | /* Indexes used when registering address spaces with cpu_address_space_init */ | ||
42 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/internals.h | ||
45 | +++ b/target/arm/internals.h | ||
46 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu); | ||
47 | */ | ||
48 | void arm_cpu_update_vfiq(ARMCPU *cpu); | ||
49 | |||
50 | +/** | ||
51 | + * arm_mmu_idx: | ||
52 | + * @env: The cpu environment | ||
53 | + * | ||
54 | + * Return the full ARMMMUIdx for the current translation regime. | ||
55 | + */ | ||
56 | +ARMMMUIdx arm_mmu_idx(CPUARMState *env); | ||
57 | + | ||
58 | #endif | ||
59 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/helper.c | ||
62 | +++ b/target/arm/helper.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
64 | limit = env->v7m.msplim[M_REG_S]; | ||
65 | } | ||
66 | } else { | ||
67 | - mmu_idx = core_to_arm_mmu_idx(env, cpu_mmu_index(env, false)); | ||
68 | + mmu_idx = arm_mmu_idx(env); | ||
69 | frame_sp_p = &env->regs[13]; | ||
70 | limit = v7m_sp_limit(env); | ||
71 | } | ||
72 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
73 | CPUARMState *env = &cpu->env; | ||
74 | uint32_t xpsr = xpsr_read(env); | ||
75 | uint32_t frameptr = env->regs[13]; | ||
76 | - ARMMMUIdx mmu_idx = core_to_arm_mmu_idx(env, cpu_mmu_index(env, false)); | ||
77 | + ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
78 | |||
79 | /* Align stack pointer if the guest wants that */ | ||
80 | if ((frameptr & 4) && | ||
81 | @@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, | ||
82 | int prot; | ||
83 | bool ret; | ||
84 | ARMMMUFaultInfo fi = {}; | ||
85 | - ARMMMUIdx mmu_idx = core_to_arm_mmu_idx(env, cpu_mmu_index(env, false)); | ||
86 | + ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
87 | |||
88 | *attrs = (MemTxAttrs) {}; | ||
89 | |||
90 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
91 | return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | ||
92 | } | ||
93 | |||
94 | -int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
95 | +ARMMMUIdx arm_mmu_idx(CPUARMState *env) | ||
96 | { | ||
97 | - int el = arm_current_el(env); | ||
98 | + int el; | ||
99 | |||
100 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
101 | - ARMMMUIdx mmu_idx = arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure); | ||
102 | - | ||
103 | - return arm_to_core_mmu_idx(mmu_idx); | ||
104 | + return arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure); | ||
105 | } | ||
106 | |||
107 | + el = arm_current_el(env); | ||
108 | if (el < 2 && arm_is_secure_below_el3(env)) { | ||
109 | - return arm_to_core_mmu_idx(ARMMMUIdx_S1SE0 + el); | ||
110 | + return ARMMMUIdx_S1SE0 + el; | ||
111 | + } else { | ||
112 | + return ARMMMUIdx_S12NSE0 + el; | ||
113 | } | ||
114 | - return el; | ||
115 | +} | ||
116 | + | ||
117 | +int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
118 | +{ | ||
119 | + return arm_to_core_mmu_idx(arm_mmu_idx(env)); | ||
120 | } | ||
121 | |||
122 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
123 | target_ulong *cs_base, uint32_t *pflags) | ||
124 | { | ||
125 | - ARMMMUIdx mmu_idx = core_to_arm_mmu_idx(env, cpu_mmu_index(env, false)); | ||
126 | + ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
127 | int current_el = arm_current_el(env); | ||
128 | int fp_el = fp_exception_el(env, current_el); | ||
129 | uint32_t flags = 0; | ||
130 | -- | ||
131 | 2.20.1 | ||
132 | |||
133 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | While we could expose stage_1_mmu_idx, the combination is | ||
4 | probably going to be more useful. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190108223129.5570-18-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/internals.h | 15 +++++++++++++++ | ||
12 | target/arm/helper.c | 7 +++++++ | ||
13 | 2 files changed, 22 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/internals.h | ||
18 | +++ b/target/arm/internals.h | ||
19 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu); | ||
20 | */ | ||
21 | ARMMMUIdx arm_mmu_idx(CPUARMState *env); | ||
22 | |||
23 | +/** | ||
24 | + * arm_stage1_mmu_idx: | ||
25 | + * @env: The cpu environment | ||
26 | + * | ||
27 | + * Return the ARMMMUIdx for the stage1 traversal for the current regime. | ||
28 | + */ | ||
29 | +#ifdef CONFIG_USER_ONLY | ||
30 | +static inline ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | ||
31 | +{ | ||
32 | + return ARMMMUIdx_S1NSE0; | ||
33 | +} | ||
34 | +#else | ||
35 | +ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env); | ||
36 | +#endif | ||
37 | + | ||
38 | #endif | ||
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/helper.c | ||
42 | +++ b/target/arm/helper.c | ||
43 | @@ -XXX,XX +XXX,XX @@ int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
44 | return arm_to_core_mmu_idx(arm_mmu_idx(env)); | ||
45 | } | ||
46 | |||
47 | +#ifndef CONFIG_USER_ONLY | ||
48 | +ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | ||
49 | +{ | ||
50 | + return stage_1_mmu_idx(arm_mmu_idx(env)); | ||
51 | +} | ||
52 | +#endif | ||
53 | + | ||
54 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
55 | target_ulong *cs_base, uint32_t *pflags) | ||
56 | { | ||
57 | -- | ||
58 | 2.20.1 | ||
59 | |||
60 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Rename arm_ccnt_enabled to pmu_counter_enabled, and add logic to only | 3 | Create empty data files and allow updates for the upcoming VIOT tests. |
4 | return 'true' if the specified counter is enabled and neither prohibited | ||
5 | or filtered. | ||
6 | 4 | ||
7 | Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> | 5 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
8 | Signed-off-by: Aaron Lindsay <aclindsa@gmail.com> | 6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20211210170415.583179-6-jean-philippe@linaro.org |
11 | Message-id: 20181211151945.29137-5-aaron@os.amperecomputing.com | ||
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/cpu.h | 10 ++++- | 11 | tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ |
15 | target/arm/cpu.c | 3 ++ | 12 | tests/data/acpi/q35/DSDT.viot | 0 |
16 | target/arm/helper.c | 96 +++++++++++++++++++++++++++++++++++++++++---- | 13 | tests/data/acpi/q35/VIOT.viot | 0 |
17 | 3 files changed, 101 insertions(+), 8 deletions(-) | 14 | tests/data/acpi/virt/VIOT | 0 |
15 | 4 files changed, 3 insertions(+) | ||
16 | create mode 100644 tests/data/acpi/q35/DSDT.viot | ||
17 | create mode 100644 tests/data/acpi/q35/VIOT.viot | ||
18 | create mode 100644 tests/data/acpi/virt/VIOT | ||
18 | 19 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 20 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h |
20 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 22 | --- a/tests/qtest/bios-tables-test-allowed-diff.h |
22 | +++ b/target/arm/cpu.h | 23 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h |
23 | @@ -XXX,XX +XXX,XX @@ void pmccntr_op_finish(CPUARMState *env); | 24 | @@ -1 +1,4 @@ |
24 | void pmu_op_start(CPUARMState *env); | 25 | /* List of comma-separated changed AML files to ignore */ |
25 | void pmu_op_finish(CPUARMState *env); | 26 | +"tests/data/acpi/virt/VIOT", |
26 | 27 | +"tests/data/acpi/q35/DSDT.viot", | |
27 | +/** | 28 | +"tests/data/acpi/q35/VIOT.viot", |
28 | + * Functions to register as EL change hooks for PMU mode filtering | 29 | diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot |
29 | + */ | 30 | new file mode 100644 |
30 | +void pmu_pre_el_change(ARMCPU *cpu, void *ignored); | 31 | index XXXXXXX..XXXXXXX |
31 | +void pmu_post_el_change(ARMCPU *cpu, void *ignored); | 32 | diff --git a/tests/data/acpi/q35/VIOT.viot b/tests/data/acpi/q35/VIOT.viot |
32 | + | 33 | new file mode 100644 |
33 | /* SCTLR bit meanings. Several bits have been reused in newer | 34 | index XXXXXXX..XXXXXXX |
34 | * versions of the architecture; in that case we define constants | 35 | diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/virt/VIOT |
35 | * for both old and new bit meanings. Code which tests against those | 36 | new file mode 100644 |
36 | @@ -XXX,XX +XXX,XX @@ void pmu_op_finish(CPUARMState *env); | 37 | index XXXXXXX..XXXXXXX |
37 | |||
38 | #define MDCR_EPMAD (1U << 21) | ||
39 | #define MDCR_EDAD (1U << 20) | ||
40 | -#define MDCR_SPME (1U << 17) | ||
41 | +#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ | ||
42 | +#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ | ||
43 | #define MDCR_SDD (1U << 16) | ||
44 | #define MDCR_SPD (3U << 14) | ||
45 | #define MDCR_TDRA (1U << 11) | ||
46 | @@ -XXX,XX +XXX,XX @@ void pmu_op_finish(CPUARMState *env); | ||
47 | #define MDCR_HPME (1U << 7) | ||
48 | #define MDCR_TPM (1U << 6) | ||
49 | #define MDCR_TPMCR (1U << 5) | ||
50 | +#define MDCR_HPMN (0x1fU) | ||
51 | |||
52 | /* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ | ||
53 | #define SDCR_VALID_MASK (MDCR_EPMAD | MDCR_EDAD | MDCR_SPME | MDCR_SPD) | ||
54 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/cpu.c | ||
57 | +++ b/target/arm/cpu.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
59 | if (!cpu->has_pmu) { | ||
60 | unset_feature(env, ARM_FEATURE_PMU); | ||
61 | cpu->id_aa64dfr0 &= ~0xf00; | ||
62 | + } else if (!kvm_enabled()) { | ||
63 | + arm_register_pre_el_change_hook(cpu, &pmu_pre_el_change, 0); | ||
64 | + arm_register_el_change_hook(cpu, &pmu_post_el_change, 0); | ||
65 | } | ||
66 | |||
67 | if (!arm_feature(env, ARM_FEATURE_EL2)) { | ||
68 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/helper.c | ||
71 | +++ b/target/arm/helper.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
73 | /* Definitions for the PMU registers */ | ||
74 | #define PMCRN_MASK 0xf800 | ||
75 | #define PMCRN_SHIFT 11 | ||
76 | +#define PMCRDP 0x10 | ||
77 | #define PMCRD 0x8 | ||
78 | #define PMCRC 0x4 | ||
79 | #define PMCRE 0x1 | ||
80 | |||
81 | +#define PMXEVTYPER_P 0x80000000 | ||
82 | +#define PMXEVTYPER_U 0x40000000 | ||
83 | +#define PMXEVTYPER_NSK 0x20000000 | ||
84 | +#define PMXEVTYPER_NSU 0x10000000 | ||
85 | +#define PMXEVTYPER_NSH 0x08000000 | ||
86 | +#define PMXEVTYPER_M 0x04000000 | ||
87 | +#define PMXEVTYPER_MT 0x02000000 | ||
88 | +#define PMXEVTYPER_EVTCOUNT 0x0000ffff | ||
89 | +#define PMXEVTYPER_MASK (PMXEVTYPER_P | PMXEVTYPER_U | PMXEVTYPER_NSK | \ | ||
90 | + PMXEVTYPER_NSU | PMXEVTYPER_NSH | \ | ||
91 | + PMXEVTYPER_M | PMXEVTYPER_MT | \ | ||
92 | + PMXEVTYPER_EVTCOUNT) | ||
93 | + | ||
94 | static inline uint32_t pmu_num_counters(CPUARMState *env) | ||
95 | { | ||
96 | return (env->cp15.c9_pmcr & PMCRN_MASK) >> PMCRN_SHIFT; | ||
97 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult pmreg_access_ccntr(CPUARMState *env, | ||
98 | return pmreg_access(env, ri, isread); | ||
99 | } | ||
100 | |||
101 | -static inline bool arm_ccnt_enabled(CPUARMState *env) | ||
102 | +/* Returns true if the counter (pass 31 for PMCCNTR) should count events using | ||
103 | + * the current EL, security state, and register configuration. | ||
104 | + */ | ||
105 | +static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) | ||
106 | { | ||
107 | - /* This does not support checking PMCCFILTR_EL0 register */ | ||
108 | + uint64_t filter; | ||
109 | + bool e, p, u, nsk, nsu, nsh, m; | ||
110 | + bool enabled, prohibited, filtered; | ||
111 | + bool secure = arm_is_secure(env); | ||
112 | + int el = arm_current_el(env); | ||
113 | + uint8_t hpmn = env->cp15.mdcr_el2 & MDCR_HPMN; | ||
114 | |||
115 | - if (!(env->cp15.c9_pmcr & PMCRE) || !(env->cp15.c9_pmcnten & (1 << 31))) { | ||
116 | - return false; | ||
117 | + if (!arm_feature(env, ARM_FEATURE_EL2) || | ||
118 | + (counter < hpmn || counter == 31)) { | ||
119 | + e = env->cp15.c9_pmcr & PMCRE; | ||
120 | + } else { | ||
121 | + e = env->cp15.mdcr_el2 & MDCR_HPME; | ||
122 | + } | ||
123 | + enabled = e && (env->cp15.c9_pmcnten & (1 << counter)); | ||
124 | + | ||
125 | + if (!secure) { | ||
126 | + if (el == 2 && (counter < hpmn || counter == 31)) { | ||
127 | + prohibited = env->cp15.mdcr_el2 & MDCR_HPMD; | ||
128 | + } else { | ||
129 | + prohibited = false; | ||
130 | + } | ||
131 | + } else { | ||
132 | + prohibited = arm_feature(env, ARM_FEATURE_EL3) && | ||
133 | + (env->cp15.mdcr_el3 & MDCR_SPME); | ||
134 | } | ||
135 | |||
136 | - return true; | ||
137 | + if (prohibited && counter == 31) { | ||
138 | + prohibited = env->cp15.c9_pmcr & PMCRDP; | ||
139 | + } | ||
140 | + | ||
141 | + /* TODO Remove assert, set filter to correct PMEVTYPER */ | ||
142 | + assert(counter == 31); | ||
143 | + filter = env->cp15.pmccfiltr_el0; | ||
144 | + | ||
145 | + p = filter & PMXEVTYPER_P; | ||
146 | + u = filter & PMXEVTYPER_U; | ||
147 | + nsk = arm_feature(env, ARM_FEATURE_EL3) && (filter & PMXEVTYPER_NSK); | ||
148 | + nsu = arm_feature(env, ARM_FEATURE_EL3) && (filter & PMXEVTYPER_NSU); | ||
149 | + nsh = arm_feature(env, ARM_FEATURE_EL2) && (filter & PMXEVTYPER_NSH); | ||
150 | + m = arm_el_is_aa64(env, 1) && | ||
151 | + arm_feature(env, ARM_FEATURE_EL3) && (filter & PMXEVTYPER_M); | ||
152 | + | ||
153 | + if (el == 0) { | ||
154 | + filtered = secure ? u : u != nsu; | ||
155 | + } else if (el == 1) { | ||
156 | + filtered = secure ? p : p != nsk; | ||
157 | + } else if (el == 2) { | ||
158 | + filtered = !nsh; | ||
159 | + } else { /* EL3 */ | ||
160 | + filtered = m != p; | ||
161 | + } | ||
162 | + | ||
163 | + return enabled && !prohibited && !filtered; | ||
164 | } | ||
165 | + | ||
166 | /* | ||
167 | * Ensure c15_ccnt is the guest-visible count so that operations such as | ||
168 | * enabling/disabling the counter or filtering, modifying the count itself, | ||
169 | @@ -XXX,XX +XXX,XX @@ void pmccntr_op_start(CPUARMState *env) | ||
170 | cycles = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), | ||
171 | ARM_CPU_FREQ, NANOSECONDS_PER_SECOND); | ||
172 | |||
173 | - if (arm_ccnt_enabled(env)) { | ||
174 | + if (pmu_counter_enabled(env, 31)) { | ||
175 | uint64_t eff_cycles = cycles; | ||
176 | if (env->cp15.c9_pmcr & PMCRD) { | ||
177 | /* Increment once every 64 processor clock cycles */ | ||
178 | @@ -XXX,XX +XXX,XX @@ void pmccntr_op_start(CPUARMState *env) | ||
179 | */ | ||
180 | void pmccntr_op_finish(CPUARMState *env) | ||
181 | { | ||
182 | - if (arm_ccnt_enabled(env)) { | ||
183 | + if (pmu_counter_enabled(env, 31)) { | ||
184 | uint64_t prev_cycles = env->cp15.c15_ccnt_delta; | ||
185 | |||
186 | if (env->cp15.c9_pmcr & PMCRD) { | ||
187 | @@ -XXX,XX +XXX,XX @@ void pmu_op_finish(CPUARMState *env) | ||
188 | pmccntr_op_finish(env); | ||
189 | } | ||
190 | |||
191 | +void pmu_pre_el_change(ARMCPU *cpu, void *ignored) | ||
192 | +{ | ||
193 | + pmu_op_start(&cpu->env); | ||
194 | +} | ||
195 | + | ||
196 | +void pmu_post_el_change(ARMCPU *cpu, void *ignored) | ||
197 | +{ | ||
198 | + pmu_op_finish(&cpu->env); | ||
199 | +} | ||
200 | + | ||
201 | static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
202 | uint64_t value) | ||
203 | { | ||
204 | @@ -XXX,XX +XXX,XX @@ void pmu_op_finish(CPUARMState *env) | ||
205 | { | ||
206 | } | ||
207 | |||
208 | +void pmu_pre_el_change(ARMCPU *cpu, void *ignored) | ||
209 | +{ | ||
210 | +} | ||
211 | + | ||
212 | +void pmu_post_el_change(ARMCPU *cpu, void *ignored) | ||
213 | +{ | ||
214 | +} | ||
215 | + | ||
216 | #endif | ||
217 | |||
218 | static void pmccfiltr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
219 | -- | 38 | -- |
220 | 2.20.1 | 39 | 2.25.1 |
221 | 40 | ||
222 | 41 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Split out functions to extract the virtual address parameters. | 3 | Add two test cases for VIOT, one on the q35 machine and the other on |
4 | Let the functions choose T0 or T1 address space half, if present. | 4 | virt. To test complex topologies the q35 test has two PCIe buses that |
5 | Extract (most of) the control bits that vary between EL or Tx. | 5 | bypass the IOMMU (and are therefore not described by VIOT), and two |
6 | buses that are translated by virtio-iommu. | ||
6 | 7 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> |
9 | Message-id: 20190108223129.5570-19-richard.henderson@linaro.org | 10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
10 | [PMM: fixed minor checkpatch comment nits] | 11 | Message-id: 20211210170415.583179-7-jean-philippe@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/internals.h | 14 +++ | 14 | tests/qtest/bios-tables-test.c | 38 ++++++++++++++++++++++++++++++++++ |
14 | target/arm/helper.c | 278 ++++++++++++++++++++++------------------- | 15 | 1 file changed, 38 insertions(+) |
15 | 2 files changed, 164 insertions(+), 128 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 17 | diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/internals.h | 19 | --- a/tests/qtest/bios-tables-test.c |
20 | +++ b/target/arm/internals.h | 20 | +++ b/tests/qtest/bios-tables-test.c |
21 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | 21 | @@ -XXX,XX +XXX,XX @@ static void test_acpi_virt_tcg(void) |
22 | ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env); | 22 | free_test_data(&data); |
23 | #endif | ||
24 | |||
25 | +/* | ||
26 | + * Parameters of a given virtual address, as extracted from the | ||
27 | + * translation control register (TCR) for a given regime. | ||
28 | + */ | ||
29 | +typedef struct ARMVAParameters { | ||
30 | + unsigned tsz : 8; | ||
31 | + unsigned select : 1; | ||
32 | + bool tbi : 1; | ||
33 | + bool epd : 1; | ||
34 | + bool hpd : 1; | ||
35 | + bool using16k : 1; | ||
36 | + bool using64k : 1; | ||
37 | +} ARMVAParameters; | ||
38 | + | ||
39 | #endif | ||
40 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/helper.c | ||
43 | +++ b/target/arm/helper.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) | ||
45 | return (hiattr << 6) | (hihint << 4) | (loattr << 2) | lohint; | ||
46 | } | 23 | } |
47 | 24 | ||
48 | +static ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | 25 | +static void test_acpi_q35_viot(void) |
49 | + ARMMMUIdx mmu_idx, bool data) | ||
50 | +{ | 26 | +{ |
51 | + uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | 27 | + test_data data = { |
52 | + uint32_t el = regime_el(env, mmu_idx); | 28 | + .machine = MACHINE_Q35, |
53 | + bool tbi, epd, hpd, using16k, using64k; | 29 | + .variant = ".viot", |
54 | + int select, tsz; | 30 | + }; |
55 | + | 31 | + |
56 | + /* | 32 | + /* |
57 | + * Bit 55 is always between the two regions, and is canonical for | 33 | + * To keep things interesting, two buses bypass the IOMMU. |
58 | + * determining if address tagging is enabled. | 34 | + * VIOT should only describes the other two buses. |
59 | + */ | 35 | + */ |
60 | + select = extract64(va, 55, 1); | 36 | + test_acpi_one("-machine default_bus_bypass_iommu=on " |
61 | + | 37 | + "-device virtio-iommu-pci " |
62 | + if (el > 1) { | 38 | + "-device pxb-pcie,bus_nr=0x10,id=pcie.100,bus=pcie.0 " |
63 | + tsz = extract32(tcr, 0, 6); | 39 | + "-device pxb-pcie,bus_nr=0x20,id=pcie.200,bus=pcie.0,bypass_iommu=on " |
64 | + using64k = extract32(tcr, 14, 1); | 40 | + "-device pxb-pcie,bus_nr=0x30,id=pcie.300,bus=pcie.0", |
65 | + using16k = extract32(tcr, 15, 1); | 41 | + &data); |
66 | + if (mmu_idx == ARMMMUIdx_S2NS) { | 42 | + free_test_data(&data); |
67 | + /* VTCR_EL2 */ | ||
68 | + tbi = hpd = false; | ||
69 | + } else { | ||
70 | + tbi = extract32(tcr, 20, 1); | ||
71 | + hpd = extract32(tcr, 24, 1); | ||
72 | + } | ||
73 | + epd = false; | ||
74 | + } else if (!select) { | ||
75 | + tsz = extract32(tcr, 0, 6); | ||
76 | + epd = extract32(tcr, 7, 1); | ||
77 | + using64k = extract32(tcr, 14, 1); | ||
78 | + using16k = extract32(tcr, 15, 1); | ||
79 | + tbi = extract64(tcr, 37, 1); | ||
80 | + hpd = extract64(tcr, 41, 1); | ||
81 | + } else { | ||
82 | + int tg = extract32(tcr, 30, 2); | ||
83 | + using16k = tg == 1; | ||
84 | + using64k = tg == 3; | ||
85 | + tsz = extract32(tcr, 16, 6); | ||
86 | + epd = extract32(tcr, 23, 1); | ||
87 | + tbi = extract64(tcr, 38, 1); | ||
88 | + hpd = extract64(tcr, 42, 1); | ||
89 | + } | ||
90 | + tsz = MIN(tsz, 39); /* TODO: ARMv8.4-TTST */ | ||
91 | + tsz = MAX(tsz, 16); /* TODO: ARMv8.2-LVA */ | ||
92 | + | ||
93 | + return (ARMVAParameters) { | ||
94 | + .tsz = tsz, | ||
95 | + .select = select, | ||
96 | + .tbi = tbi, | ||
97 | + .epd = epd, | ||
98 | + .hpd = hpd, | ||
99 | + .using16k = using16k, | ||
100 | + .using64k = using64k, | ||
101 | + }; | ||
102 | +} | 43 | +} |
103 | + | 44 | + |
104 | +static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | 45 | +static void test_acpi_virt_viot(void) |
105 | + ARMMMUIdx mmu_idx) | ||
106 | +{ | 46 | +{ |
107 | + uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | 47 | + test_data data = { |
108 | + uint32_t el = regime_el(env, mmu_idx); | 48 | + .machine = "virt", |
109 | + int select, tsz; | 49 | + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", |
110 | + bool epd, hpd; | 50 | + .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", |
51 | + .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", | ||
52 | + .ram_start = 0x40000000ULL, | ||
53 | + .scan_len = 128ULL * 1024 * 1024, | ||
54 | + }; | ||
111 | + | 55 | + |
112 | + if (mmu_idx == ARMMMUIdx_S2NS) { | 56 | + test_acpi_one("-cpu cortex-a57 " |
113 | + /* VTCR */ | 57 | + "-device virtio-iommu-pci", &data); |
114 | + bool sext = extract32(tcr, 4, 1); | 58 | + free_test_data(&data); |
115 | + bool sign = extract32(tcr, 3, 1); | ||
116 | + | ||
117 | + /* | ||
118 | + * If the sign-extend bit is not the same as t0sz[3], the result | ||
119 | + * is unpredictable. Flag this as a guest error. | ||
120 | + */ | ||
121 | + if (sign != sext) { | ||
122 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
123 | + "AArch32: VTCR.S / VTCR.T0SZ[3] mismatch\n"); | ||
124 | + } | ||
125 | + tsz = sextract32(tcr, 0, 4) + 8; | ||
126 | + select = 0; | ||
127 | + hpd = false; | ||
128 | + epd = false; | ||
129 | + } else if (el == 2) { | ||
130 | + /* HTCR */ | ||
131 | + tsz = extract32(tcr, 0, 3); | ||
132 | + select = 0; | ||
133 | + hpd = extract64(tcr, 24, 1); | ||
134 | + epd = false; | ||
135 | + } else { | ||
136 | + int t0sz = extract32(tcr, 0, 3); | ||
137 | + int t1sz = extract32(tcr, 16, 3); | ||
138 | + | ||
139 | + if (t1sz == 0) { | ||
140 | + select = va > (0xffffffffu >> t0sz); | ||
141 | + } else { | ||
142 | + /* Note that we will detect errors later. */ | ||
143 | + select = va >= ~(0xffffffffu >> t1sz); | ||
144 | + } | ||
145 | + if (!select) { | ||
146 | + tsz = t0sz; | ||
147 | + epd = extract32(tcr, 7, 1); | ||
148 | + hpd = extract64(tcr, 41, 1); | ||
149 | + } else { | ||
150 | + tsz = t1sz; | ||
151 | + epd = extract32(tcr, 23, 1); | ||
152 | + hpd = extract64(tcr, 42, 1); | ||
153 | + } | ||
154 | + /* For aarch32, hpd0 is not enabled without t2e as well. */ | ||
155 | + hpd &= extract32(tcr, 6, 1); | ||
156 | + } | ||
157 | + | ||
158 | + return (ARMVAParameters) { | ||
159 | + .tsz = tsz, | ||
160 | + .select = select, | ||
161 | + .epd = epd, | ||
162 | + .hpd = hpd, | ||
163 | + }; | ||
164 | +} | 59 | +} |
165 | + | 60 | + |
166 | static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | 61 | static void test_oem_fields(test_data *data) |
167 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 62 | { |
168 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | 63 | int i; |
169 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | 64 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) |
170 | /* Read an LPAE long-descriptor translation table. */ | 65 | qtest_add_func("acpi/q35/kvm/xapic", test_acpi_q35_kvm_xapic); |
171 | ARMFaultType fault_type = ARMFault_Translation; | 66 | qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar); |
172 | uint32_t level; | 67 | } |
173 | - uint32_t epd = 0; | 68 | + qtest_add_func("acpi/q35/viot", test_acpi_q35_viot); |
174 | - int32_t t0sz, t1sz; | 69 | } else if (strcmp(arch, "aarch64") == 0) { |
175 | - uint32_t tg; | 70 | if (has_tcg) { |
176 | + ARMVAParameters param; | 71 | qtest_add_func("acpi/virt", test_acpi_virt_tcg); |
177 | uint64_t ttbr; | 72 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) |
178 | - int ttbr_select; | 73 | qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp); |
179 | hwaddr descaddr, indexmask, indexmask_grainsize; | 74 | qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb); |
180 | uint32_t tableattrs; | 75 | qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt); |
181 | - target_ulong page_size; | 76 | + qtest_add_func("acpi/virt/viot", test_acpi_virt_viot); |
182 | + target_ulong page_size, top_bits; | 77 | } |
183 | uint32_t attrs; | ||
184 | - int32_t stride = 9; | ||
185 | - int32_t addrsize; | ||
186 | - int inputsize; | ||
187 | - int32_t tbi = 0; | ||
188 | + int32_t stride; | ||
189 | + int addrsize, inputsize; | ||
190 | TCR *tcr = regime_tcr(env, mmu_idx); | ||
191 | int ap, ns, xn, pxn; | ||
192 | uint32_t el = regime_el(env, mmu_idx); | ||
193 | - bool ttbr1_valid = true; | ||
194 | + bool ttbr1_valid; | ||
195 | uint64_t descaddrmask; | ||
196 | bool aarch64 = arm_el_is_aa64(env, el); | ||
197 | - bool hpd = false; | ||
198 | |||
199 | /* TODO: | ||
200 | * This code does not handle the different format TCR for VTCR_EL2. | ||
201 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
202 | * support for those page table walks. | ||
203 | */ | ||
204 | if (aarch64) { | ||
205 | + param = aa64_va_parameters(env, address, mmu_idx, | ||
206 | + access_type != MMU_INST_FETCH); | ||
207 | level = 0; | ||
208 | - addrsize = 64; | ||
209 | - if (el > 1) { | ||
210 | - if (mmu_idx != ARMMMUIdx_S2NS) { | ||
211 | - tbi = extract64(tcr->raw_tcr, 20, 1); | ||
212 | - } | ||
213 | - } else { | ||
214 | - if (extract64(address, 55, 1)) { | ||
215 | - tbi = extract64(tcr->raw_tcr, 38, 1); | ||
216 | - } else { | ||
217 | - tbi = extract64(tcr->raw_tcr, 37, 1); | ||
218 | - } | ||
219 | - } | ||
220 | - tbi *= 8; | ||
221 | - | ||
222 | /* If we are in 64-bit EL2 or EL3 then there is no TTBR1, so mark it | ||
223 | * invalid. | ||
224 | */ | ||
225 | - if (el > 1) { | ||
226 | - ttbr1_valid = false; | ||
227 | - } | ||
228 | + ttbr1_valid = (el < 2); | ||
229 | + addrsize = 64 - 8 * param.tbi; | ||
230 | + inputsize = 64 - param.tsz; | ||
231 | } else { | ||
232 | + param = aa32_va_parameters(env, address, mmu_idx); | ||
233 | level = 1; | ||
234 | - addrsize = 32; | ||
235 | /* There is no TTBR1 for EL2 */ | ||
236 | - if (el == 2) { | ||
237 | - ttbr1_valid = false; | ||
238 | - } | ||
239 | + ttbr1_valid = (el != 2); | ||
240 | + addrsize = (mmu_idx == ARMMMUIdx_S2NS ? 40 : 32); | ||
241 | + inputsize = addrsize - param.tsz; | ||
242 | } | 78 | } |
243 | 79 | ret = g_test_run(); | |
244 | - /* Determine whether this address is in the region controlled by | ||
245 | - * TTBR0 or TTBR1 (or if it is in neither region and should fault). | ||
246 | - * This is a Non-secure PL0/1 stage 1 translation, so controlled by | ||
247 | - * TTBCR/TTBR0/TTBR1 in accordance with ARM ARM DDI0406C table B-32: | ||
248 | + /* | ||
249 | + * We determined the region when collecting the parameters, but we | ||
250 | + * have not yet validated that the address is valid for the region. | ||
251 | + * Extract the top bits and verify that they all match select. | ||
252 | */ | ||
253 | - if (aarch64) { | ||
254 | - /* AArch64 translation. */ | ||
255 | - t0sz = extract32(tcr->raw_tcr, 0, 6); | ||
256 | - t0sz = MIN(t0sz, 39); | ||
257 | - t0sz = MAX(t0sz, 16); | ||
258 | - } else if (mmu_idx != ARMMMUIdx_S2NS) { | ||
259 | - /* AArch32 stage 1 translation. */ | ||
260 | - t0sz = extract32(tcr->raw_tcr, 0, 3); | ||
261 | - } else { | ||
262 | - /* AArch32 stage 2 translation. */ | ||
263 | - bool sext = extract32(tcr->raw_tcr, 4, 1); | ||
264 | - bool sign = extract32(tcr->raw_tcr, 3, 1); | ||
265 | - /* Address size is 40-bit for a stage 2 translation, | ||
266 | - * and t0sz can be negative (from -8 to 7), | ||
267 | - * so we need to adjust it to use the TTBR selecting logic below. | ||
268 | - */ | ||
269 | - addrsize = 40; | ||
270 | - t0sz = sextract32(tcr->raw_tcr, 0, 4) + 8; | ||
271 | - | ||
272 | - /* If the sign-extend bit is not the same as t0sz[3], the result | ||
273 | - * is unpredictable. Flag this as a guest error. */ | ||
274 | - if (sign != sext) { | ||
275 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
276 | - "AArch32: VTCR.S / VTCR.T0SZ[3] mismatch\n"); | ||
277 | - } | ||
278 | - } | ||
279 | - t1sz = extract32(tcr->raw_tcr, 16, 6); | ||
280 | - if (aarch64) { | ||
281 | - t1sz = MIN(t1sz, 39); | ||
282 | - t1sz = MAX(t1sz, 16); | ||
283 | - } | ||
284 | - if (t0sz && !extract64(address, addrsize - t0sz, t0sz - tbi)) { | ||
285 | - /* there is a ttbr0 region and we are in it (high bits all zero) */ | ||
286 | - ttbr_select = 0; | ||
287 | - } else if (ttbr1_valid && t1sz && | ||
288 | - !extract64(~address, addrsize - t1sz, t1sz - tbi)) { | ||
289 | - /* there is a ttbr1 region and we are in it (high bits all one) */ | ||
290 | - ttbr_select = 1; | ||
291 | - } else if (!t0sz) { | ||
292 | - /* ttbr0 region is "everything not in the ttbr1 region" */ | ||
293 | - ttbr_select = 0; | ||
294 | - } else if (!t1sz && ttbr1_valid) { | ||
295 | - /* ttbr1 region is "everything not in the ttbr0 region" */ | ||
296 | - ttbr_select = 1; | ||
297 | - } else { | ||
298 | - /* in the gap between the two regions, this is a Translation fault */ | ||
299 | + top_bits = sextract64(address, inputsize, addrsize - inputsize); | ||
300 | + if (-top_bits != param.select || (param.select && !ttbr1_valid)) { | ||
301 | + /* In the gap between the two regions, this is a Translation fault */ | ||
302 | fault_type = ARMFault_Translation; | ||
303 | goto do_fault; | ||
304 | } | ||
305 | |||
306 | + if (param.using64k) { | ||
307 | + stride = 13; | ||
308 | + } else if (param.using16k) { | ||
309 | + stride = 11; | ||
310 | + } else { | ||
311 | + stride = 9; | ||
312 | + } | ||
313 | + | ||
314 | /* Note that QEMU ignores shareability and cacheability attributes, | ||
315 | * so we don't need to do anything with the SH, ORGN, IRGN fields | ||
316 | * in the TTBCR. Similarly, TTBCR:A1 selects whether we get the | ||
317 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
318 | * implement any ASID-like capability so we can ignore it (instead | ||
319 | * we will always flush the TLB any time the ASID is changed). | ||
320 | */ | ||
321 | - if (ttbr_select == 0) { | ||
322 | - ttbr = regime_ttbr(env, mmu_idx, 0); | ||
323 | - if (el < 2) { | ||
324 | - epd = extract32(tcr->raw_tcr, 7, 1); | ||
325 | - } | ||
326 | - inputsize = addrsize - t0sz; | ||
327 | - | ||
328 | - tg = extract32(tcr->raw_tcr, 14, 2); | ||
329 | - if (tg == 1) { /* 64KB pages */ | ||
330 | - stride = 13; | ||
331 | - } | ||
332 | - if (tg == 2) { /* 16KB pages */ | ||
333 | - stride = 11; | ||
334 | - } | ||
335 | - if (aarch64 && el > 1) { | ||
336 | - hpd = extract64(tcr->raw_tcr, 24, 1); | ||
337 | - } else { | ||
338 | - hpd = extract64(tcr->raw_tcr, 41, 1); | ||
339 | - } | ||
340 | - if (!aarch64) { | ||
341 | - /* For aarch32, hpd0 is not enabled without t2e as well. */ | ||
342 | - hpd &= extract64(tcr->raw_tcr, 6, 1); | ||
343 | - } | ||
344 | - } else { | ||
345 | - /* We should only be here if TTBR1 is valid */ | ||
346 | - assert(ttbr1_valid); | ||
347 | - | ||
348 | - ttbr = regime_ttbr(env, mmu_idx, 1); | ||
349 | - epd = extract32(tcr->raw_tcr, 23, 1); | ||
350 | - inputsize = addrsize - t1sz; | ||
351 | - | ||
352 | - tg = extract32(tcr->raw_tcr, 30, 2); | ||
353 | - if (tg == 3) { /* 64KB pages */ | ||
354 | - stride = 13; | ||
355 | - } | ||
356 | - if (tg == 1) { /* 16KB pages */ | ||
357 | - stride = 11; | ||
358 | - } | ||
359 | - hpd = extract64(tcr->raw_tcr, 42, 1); | ||
360 | - if (!aarch64) { | ||
361 | - /* For aarch32, hpd1 is not enabled without t2e as well. */ | ||
362 | - hpd &= extract64(tcr->raw_tcr, 6, 1); | ||
363 | - } | ||
364 | - } | ||
365 | + ttbr = regime_ttbr(env, mmu_idx, param.select); | ||
366 | |||
367 | /* Here we should have set up all the parameters for the translation: | ||
368 | * inputsize, ttbr, epd, stride, tbi | ||
369 | */ | ||
370 | |||
371 | - if (epd) { | ||
372 | + if (param.epd) { | ||
373 | /* Translation table walk disabled => Translation fault on TLB miss | ||
374 | * Note: This is always 0 on 64-bit EL2 and EL3. | ||
375 | */ | ||
376 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
377 | } | ||
378 | /* Merge in attributes from table descriptors */ | ||
379 | attrs |= nstable << 3; /* NS */ | ||
380 | - if (hpd) { | ||
381 | + if (param.hpd) { | ||
382 | /* HPD disables all the table attributes except NSTable. */ | ||
383 | break; | ||
384 | } | ||
385 | -- | 80 | -- |
386 | 2.20.1 | 81 | 2.25.1 |
387 | 82 | ||
388 | 83 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | We will shortly want to talk about TBI as it relates to data. | ||
4 | Passing around a pair of variables is less convenient than a | ||
5 | single variable. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20190108223129.5570-20-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 3 +-- | ||
13 | target/arm/translate.h | 3 +-- | ||
14 | target/arm/helper.c | 5 ++--- | ||
15 | target/arm/translate-a64.c | 13 +++++++------ | ||
16 | 4 files changed, 11 insertions(+), 13 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu.h | ||
21 | +++ b/target/arm/cpu.h | ||
22 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, HANDLER, 21, 1) | ||
23 | FIELD(TBFLAG_A32, STACKCHECK, 22, 1) | ||
24 | |||
25 | /* Bit usage when in AArch64 state */ | ||
26 | -FIELD(TBFLAG_A64, TBI0, 0, 1) | ||
27 | -FIELD(TBFLAG_A64, TBI1, 1, 1) | ||
28 | +FIELD(TBFLAG_A64, TBII, 0, 2) | ||
29 | FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) | ||
30 | FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) | ||
31 | FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) | ||
32 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/translate.h | ||
35 | +++ b/target/arm/translate.h | ||
36 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
37 | int user; | ||
38 | #endif | ||
39 | ARMMMUIdx mmu_idx; /* MMU index to use for normal loads/stores */ | ||
40 | - bool tbi0; /* TBI0 for EL0/1 or TBI for EL2/3 */ | ||
41 | - bool tbi1; /* TBI1 for EL0/1, not used for EL2/3 */ | ||
42 | + uint8_t tbii; /* TBI1|TBI0 for EL0/1 or TBI for EL2/3 */ | ||
43 | bool ns; /* Use non-secure CPREG bank on access */ | ||
44 | int fp_excp_el; /* FP exception EL or 0 if enabled */ | ||
45 | int sve_excp_el; /* SVE exception EL or 0 if enabled */ | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/helper.c | ||
49 | +++ b/target/arm/helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
51 | *pc = env->pc; | ||
52 | flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); | ||
53 | /* Get control bits for tagged addresses */ | ||
54 | - flags = FIELD_DP32(flags, TBFLAG_A64, TBI0, | ||
55 | + flags = FIELD_DP32(flags, TBFLAG_A64, TBII, | ||
56 | + (arm_regime_tbi1(env, mmu_idx) << 1) | | ||
57 | arm_regime_tbi0(env, mmu_idx)); | ||
58 | - flags = FIELD_DP32(flags, TBFLAG_A64, TBI1, | ||
59 | - arm_regime_tbi1(env, mmu_idx)); | ||
60 | |||
61 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
62 | int sve_el = sve_exception_el(env, current_el); | ||
63 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/translate-a64.c | ||
66 | +++ b/target/arm/translate-a64.c | ||
67 | @@ -XXX,XX +XXX,XX @@ void gen_a64_set_pc_im(uint64_t val) | ||
68 | */ | ||
69 | static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src) | ||
70 | { | ||
71 | + /* Note that TBII is TBI1:TBI0. */ | ||
72 | + int tbi = s->tbii; | ||
73 | |||
74 | if (s->current_el <= 1) { | ||
75 | /* Test if NEITHER or BOTH TBI values are set. If so, no need to | ||
76 | * examine bit 55 of address, can just generate code. | ||
77 | * If mixed, then test via generated code | ||
78 | */ | ||
79 | - if (s->tbi0 && s->tbi1) { | ||
80 | + if (tbi == 3) { | ||
81 | TCGv_i64 tmp_reg = tcg_temp_new_i64(); | ||
82 | /* Both bits set, sign extension from bit 55 into [63:56] will | ||
83 | * cover both cases | ||
84 | @@ -XXX,XX +XXX,XX @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src) | ||
85 | tcg_gen_shli_i64(tmp_reg, src, 8); | ||
86 | tcg_gen_sari_i64(cpu_pc, tmp_reg, 8); | ||
87 | tcg_temp_free_i64(tmp_reg); | ||
88 | - } else if (!s->tbi0 && !s->tbi1) { | ||
89 | + } else if (tbi == 0) { | ||
90 | /* Neither bit set, just load it as-is */ | ||
91 | tcg_gen_mov_i64(cpu_pc, src); | ||
92 | } else { | ||
93 | @@ -XXX,XX +XXX,XX @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src) | ||
94 | |||
95 | tcg_gen_andi_i64(tcg_bit55, src, (1ull << 55)); | ||
96 | |||
97 | - if (s->tbi0) { | ||
98 | + if (tbi == 1) { | ||
99 | /* tbi0==1, tbi1==0, so 0-fill upper byte if bit 55 = 0 */ | ||
100 | tcg_gen_andi_i64(tcg_tmpval, src, | ||
101 | 0x00FFFFFFFFFFFFFFull); | ||
102 | @@ -XXX,XX +XXX,XX @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src) | ||
103 | tcg_temp_free_i64(tcg_tmpval); | ||
104 | } | ||
105 | } else { /* EL > 1 */ | ||
106 | - if (s->tbi0) { | ||
107 | + if (tbi != 0) { | ||
108 | /* Force tag byte to all zero */ | ||
109 | tcg_gen_andi_i64(cpu_pc, src, 0x00FFFFFFFFFFFFFFull); | ||
110 | } else { | ||
111 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
112 | dc->condexec_cond = 0; | ||
113 | core_mmu_idx = FIELD_EX32(tb_flags, TBFLAG_ANY, MMUIDX); | ||
114 | dc->mmu_idx = core_to_arm_mmu_idx(env, core_mmu_idx); | ||
115 | - dc->tbi0 = FIELD_EX32(tb_flags, TBFLAG_A64, TBI0); | ||
116 | - dc->tbi1 = FIELD_EX32(tb_flags, TBFLAG_A64, TBI1); | ||
117 | + dc->tbii = FIELD_EX32(tb_flags, TBFLAG_A64, TBII); | ||
118 | dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); | ||
119 | #if !defined(CONFIG_USER_ONLY) | ||
120 | dc->user = (dc->current_el == 0); | ||
121 | -- | ||
122 | 2.20.1 | ||
123 | |||
124 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | We need to reuse this from helper-a64.c. Provide a stub | ||
4 | definition for CONFIG_USER_ONLY. This matches the stub | ||
5 | definitions that we removed for arm_regime_tbi{0,1} before. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190108223129.5570-21-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/internals.h | 17 +++++++++++++++++ | ||
13 | target/arm/helper.c | 4 ++-- | ||
14 | 2 files changed, 19 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/internals.h | ||
19 | +++ b/target/arm/internals.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVAParameters { | ||
21 | bool using64k : 1; | ||
22 | } ARMVAParameters; | ||
23 | |||
24 | +#ifdef CONFIG_USER_ONLY | ||
25 | +static inline ARMVAParameters aa64_va_parameters(CPUARMState *env, | ||
26 | + uint64_t va, | ||
27 | + ARMMMUIdx mmu_idx, bool data) | ||
28 | +{ | ||
29 | + return (ARMVAParameters) { | ||
30 | + /* 48-bit address space */ | ||
31 | + .tsz = 16, | ||
32 | + /* We can't handle tagged addresses properly in user-only mode */ | ||
33 | + .tbi = false, | ||
34 | + }; | ||
35 | +} | ||
36 | +#else | ||
37 | +ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
38 | + ARMMMUIdx mmu_idx, bool data); | ||
39 | +#endif | ||
40 | + | ||
41 | #endif | ||
42 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/helper.c | ||
45 | +++ b/target/arm/helper.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) | ||
47 | return (hiattr << 6) | (hihint << 4) | (loattr << 2) | lohint; | ||
48 | } | ||
49 | |||
50 | -static ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
51 | - ARMMMUIdx mmu_idx, bool data) | ||
52 | +ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
53 | + ARMMMUIdx mmu_idx, bool data) | ||
54 | { | ||
55 | uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | ||
56 | uint32_t el = regime_el(env, mmu_idx); | ||
57 | -- | ||
58 | 2.20.1 | ||
59 | |||
60 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | The arm_regime_tbi{0,1} functions are replacable with the new function | ||
4 | by giving the lowest and highest address. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190108223129.5570-24-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 35 ----------------------- | ||
12 | target/arm/helper.c | 70 ++++++++++++++++----------------------------- | ||
13 | 2 files changed, 24 insertions(+), 81 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_cpu_bswap_data(CPUARMState *env) | ||
20 | } | ||
21 | #endif | ||
22 | |||
23 | -#ifndef CONFIG_USER_ONLY | ||
24 | -/** | ||
25 | - * arm_regime_tbi0: | ||
26 | - * @env: CPUARMState | ||
27 | - * @mmu_idx: MMU index indicating required translation regime | ||
28 | - * | ||
29 | - * Extracts the TBI0 value from the appropriate TCR for the current EL | ||
30 | - * | ||
31 | - * Returns: the TBI0 value. | ||
32 | - */ | ||
33 | -uint32_t arm_regime_tbi0(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
34 | - | ||
35 | -/** | ||
36 | - * arm_regime_tbi1: | ||
37 | - * @env: CPUARMState | ||
38 | - * @mmu_idx: MMU index indicating required translation regime | ||
39 | - * | ||
40 | - * Extracts the TBI1 value from the appropriate TCR for the current EL | ||
41 | - * | ||
42 | - * Returns: the TBI1 value. | ||
43 | - */ | ||
44 | -uint32_t arm_regime_tbi1(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
45 | -#else | ||
46 | -/* We can't handle tagged addresses properly in user-only mode */ | ||
47 | -static inline uint32_t arm_regime_tbi0(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
48 | -{ | ||
49 | - return 0; | ||
50 | -} | ||
51 | - | ||
52 | -static inline uint32_t arm_regime_tbi1(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
53 | -{ | ||
54 | - return 0; | ||
55 | -} | ||
56 | -#endif | ||
57 | - | ||
58 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
59 | target_ulong *cs_base, uint32_t *flags); | ||
60 | |||
61 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/helper.c | ||
64 | +++ b/target/arm/helper.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) | ||
66 | return mmu_idx; | ||
67 | } | ||
68 | |||
69 | -/* Returns TBI0 value for current regime el */ | ||
70 | -uint32_t arm_regime_tbi0(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
71 | -{ | ||
72 | - TCR *tcr; | ||
73 | - uint32_t el; | ||
74 | - | ||
75 | - /* For EL0 and EL1, TBI is controlled by stage 1's TCR, so convert | ||
76 | - * a stage 1+2 mmu index into the appropriate stage 1 mmu index. | ||
77 | - */ | ||
78 | - mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
79 | - | ||
80 | - tcr = regime_tcr(env, mmu_idx); | ||
81 | - el = regime_el(env, mmu_idx); | ||
82 | - | ||
83 | - if (el > 1) { | ||
84 | - return extract64(tcr->raw_tcr, 20, 1); | ||
85 | - } else { | ||
86 | - return extract64(tcr->raw_tcr, 37, 1); | ||
87 | - } | ||
88 | -} | ||
89 | - | ||
90 | -/* Returns TBI1 value for current regime el */ | ||
91 | -uint32_t arm_regime_tbi1(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
92 | -{ | ||
93 | - TCR *tcr; | ||
94 | - uint32_t el; | ||
95 | - | ||
96 | - /* For EL0 and EL1, TBI is controlled by stage 1's TCR, so convert | ||
97 | - * a stage 1+2 mmu index into the appropriate stage 1 mmu index. | ||
98 | - */ | ||
99 | - mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
100 | - | ||
101 | - tcr = regime_tcr(env, mmu_idx); | ||
102 | - el = regime_el(env, mmu_idx); | ||
103 | - | ||
104 | - if (el > 1) { | ||
105 | - return 0; | ||
106 | - } else { | ||
107 | - return extract64(tcr->raw_tcr, 38, 1); | ||
108 | - } | ||
109 | -} | ||
110 | - | ||
111 | /* Return the TTBR associated with this translation regime */ | ||
112 | static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
113 | int ttbrn) | ||
114 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
115 | |||
116 | *pc = env->pc; | ||
117 | flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); | ||
118 | - /* Get control bits for tagged addresses */ | ||
119 | - flags = FIELD_DP32(flags, TBFLAG_A64, TBII, | ||
120 | - (arm_regime_tbi1(env, mmu_idx) << 1) | | ||
121 | - arm_regime_tbi0(env, mmu_idx)); | ||
122 | + | ||
123 | +#ifndef CONFIG_USER_ONLY | ||
124 | + /* | ||
125 | + * Get control bits for tagged addresses. Note that the | ||
126 | + * translator only uses this for instruction addresses. | ||
127 | + */ | ||
128 | + { | ||
129 | + ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); | ||
130 | + ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); | ||
131 | + int tbii, tbid; | ||
132 | + | ||
133 | + /* FIXME: ARMv8.1-VHE S2 translation regime. */ | ||
134 | + if (regime_el(env, stage1) < 2) { | ||
135 | + ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); | ||
136 | + tbid = (p1.tbi << 1) | p0.tbi; | ||
137 | + tbii = tbid & ~((p1.tbid << 1) | p0.tbid); | ||
138 | + } else { | ||
139 | + tbid = p0.tbi; | ||
140 | + tbii = tbid & !p0.tbid; | ||
141 | + } | ||
142 | + | ||
143 | + flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); | ||
144 | + } | ||
145 | +#endif | ||
146 | |||
147 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
148 | int sve_el = sve_exception_el(env, current_el); | ||
149 | -- | ||
150 | 2.20.1 | ||
151 | |||
152 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Stripping out the authentication data does not require any crypto, | ||
4 | it merely requires the virtual address parameters. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190108223129.5570-25-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/pauth_helper.c | 14 +++++++++++++- | ||
12 | 1 file changed, 13 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/pauth_helper.c | ||
17 | +++ b/target/arm/pauth_helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | ||
19 | g_assert_not_reached(); /* FIXME */ | ||
20 | } | ||
21 | |||
22 | +static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) | ||
23 | +{ | ||
24 | + uint64_t extfield = -param.select; | ||
25 | + int bot_pac_bit = 64 - param.tsz; | ||
26 | + int top_pac_bit = 64 - 8 * param.tbi; | ||
27 | + | ||
28 | + return deposit64(ptr, bot_pac_bit, top_pac_bit - bot_pac_bit, extfield); | ||
29 | +} | ||
30 | + | ||
31 | static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, | ||
32 | ARMPACKey *key, bool data, int keynumber) | ||
33 | { | ||
34 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, | ||
35 | |||
36 | static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data) | ||
37 | { | ||
38 | - g_assert_not_reached(); /* FIXME */ | ||
39 | + ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); | ||
40 | + ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); | ||
41 | + | ||
42 | + return pauth_original_ptr(ptr, param); | ||
43 | } | ||
44 | |||
45 | static void QEMU_NORETURN pauth_trap(CPUARMState *env, int target_el, | ||
46 | -- | ||
47 | 2.20.1 | ||
48 | |||
49 | 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: 20190108223129.5570-30-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/cpu64.c | 4 ++++ | ||
9 | 1 file changed, 4 insertions(+) | ||
10 | |||
11 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/cpu64.c | ||
14 | +++ b/target/arm/cpu64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
16 | |||
17 | t = cpu->isar.id_aa64isar1; | ||
18 | t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | ||
19 | + t = FIELD_DP64(t, ID_AA64ISAR1, APA, 1); /* PAuth, architected only */ | ||
20 | + t = FIELD_DP64(t, ID_AA64ISAR1, API, 0); | ||
21 | + t = FIELD_DP64(t, ID_AA64ISAR1, GPA, 1); | ||
22 | + t = FIELD_DP64(t, ID_AA64ISAR1, GPI, 0); | ||
23 | cpu->isar.id_aa64isar1 = t; | ||
24 | |||
25 | t = cpu->isar.id_aa64pfr0; | ||
26 | -- | ||
27 | 2.20.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Because of the PMU's design, many register accesses have side effects | 3 | Add expected blobs of the VIOT and DSDT table for the VIOT test on the |
4 | which are inter-related, meaning that the normal method of saving CP | 4 | q35 machine. |
5 | registers can result in inconsistent state. These side-effects are | 5 | |
6 | largely handled in pmu_op_start/finish functions which can be called | 6 | Since the test instantiates a virtio device and two PCIe expander |
7 | before and after the state is saved/restored. By doing this and adding | 7 | bridges, DSDT.viot has more blocks than the base DSDT. |
8 | raw read/write functions for the affected registers, we avoid | 8 | |
9 | migration-related inconsistencies. | 9 | The VIOT table generated for the q35 test is: |
10 | 10 | ||
11 | Signed-off-by: Aaron Lindsay <aclindsa@gmail.com> | 11 | [000h 0000 4] Signature : "VIOT" [Virtual I/O Translation Table] |
12 | Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com> | 12 | [004h 0004 4] Table Length : 00000070 |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | [008h 0008 1] Revision : 00 |
14 | Message-id: 20181211151945.29137-4-aaron@os.amperecomputing.com | 14 | [009h 0009 1] Checksum : 3D |
15 | [00Ah 0010 6] Oem ID : "BOCHS " | ||
16 | [010h 0016 8] Oem Table ID : "BXPC " | ||
17 | [018h 0024 4] Oem Revision : 00000001 | ||
18 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | ||
19 | [020h 0032 4] Asl Compiler Revision : 00000001 | ||
20 | |||
21 | [024h 0036 2] Node count : 0003 | ||
22 | [026h 0038 2] Node offset : 0030 | ||
23 | [028h 0040 8] Reserved : 0000000000000000 | ||
24 | |||
25 | [030h 0048 1] Type : 03 [VirtIO-PCI IOMMU] | ||
26 | [031h 0049 1] Reserved : 00 | ||
27 | [032h 0050 2] Length : 0010 | ||
28 | |||
29 | [034h 0052 2] PCI Segment : 0000 | ||
30 | [036h 0054 2] PCI BDF number : 0010 | ||
31 | [038h 0056 8] Reserved : 0000000000000000 | ||
32 | |||
33 | [040h 0064 1] Type : 01 [PCI Range] | ||
34 | [041h 0065 1] Reserved : 00 | ||
35 | [042h 0066 2] Length : 0018 | ||
36 | |||
37 | [044h 0068 4] Endpoint start : 00003000 | ||
38 | [048h 0072 2] PCI Segment start : 0000 | ||
39 | [04Ah 0074 2] PCI Segment end : 0000 | ||
40 | [04Ch 0076 2] PCI BDF start : 3000 | ||
41 | [04Eh 0078 2] PCI BDF end : 30FF | ||
42 | [050h 0080 2] Output node : 0030 | ||
43 | [052h 0082 6] Reserved : 000000000000 | ||
44 | |||
45 | [058h 0088 1] Type : 01 [PCI Range] | ||
46 | [059h 0089 1] Reserved : 00 | ||
47 | [05Ah 0090 2] Length : 0018 | ||
48 | |||
49 | [05Ch 0092 4] Endpoint start : 00001000 | ||
50 | [060h 0096 2] PCI Segment start : 0000 | ||
51 | [062h 0098 2] PCI Segment end : 0000 | ||
52 | [064h 0100 2] PCI BDF start : 1000 | ||
53 | [066h 0102 2] PCI BDF end : 10FF | ||
54 | [068h 0104 2] Output node : 0030 | ||
55 | [06Ah 0106 6] Reserved : 000000000000 | ||
56 | |||
57 | And the DSDT diff is: | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | * | ||
61 | * Disassembling to symbolic ASL+ operators | ||
62 | * | ||
63 | - * Disassembly of tests/data/acpi/q35/DSDT, Fri Dec 10 15:03:08 2021 | ||
64 | + * Disassembly of /tmp/aml-H9Y5D1, Fri Dec 10 15:02:27 2021 | ||
65 | * | ||
66 | * Original Table Header: | ||
67 | * Signature "DSDT" | ||
68 | - * Length 0x00002061 (8289) | ||
69 | + * Length 0x000024B6 (9398) | ||
70 | * Revision 0x01 **** 32-bit table (V1), no 64-bit math support | ||
71 | - * Checksum 0xFA | ||
72 | + * Checksum 0xA7 | ||
73 | * OEM ID "BOCHS " | ||
74 | * OEM Table ID "BXPC " | ||
75 | * OEM Revision 0x00000001 (1) | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | } | ||
78 | } | ||
79 | |||
80 | + Scope (\_SB) | ||
81 | + { | ||
82 | + Device (PC30) | ||
83 | + { | ||
84 | + Name (_UID, 0x30) // _UID: Unique ID | ||
85 | + Name (_BBN, 0x30) // _BBN: BIOS Bus Number | ||
86 | + Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID | ||
87 | + Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID | ||
88 | + Method (_OSC, 4, NotSerialized) // _OSC: Operating System Capabilities | ||
89 | + { | ||
90 | + CreateDWordField (Arg3, Zero, CDW1) | ||
91 | + If ((Arg0 == ToUUID ("33db4d5b-1ff7-401c-9657-7441c03dd766") /* PCI Host Bridge Device */)) | ||
92 | + { | ||
93 | + CreateDWordField (Arg3, 0x04, CDW2) | ||
94 | + CreateDWordField (Arg3, 0x08, CDW3) | ||
95 | + Local0 = CDW3 /* \_SB_.PC30._OSC.CDW3 */ | ||
96 | + Local0 &= 0x1F | ||
97 | + If ((Arg1 != One)) | ||
98 | + { | ||
99 | + CDW1 |= 0x08 | ||
100 | + } | ||
101 | + | ||
102 | + If ((CDW3 != Local0)) | ||
103 | + { | ||
104 | + CDW1 |= 0x10 | ||
105 | + } | ||
106 | + | ||
107 | + CDW3 = Local0 | ||
108 | + } | ||
109 | + Else | ||
110 | + { | ||
111 | + CDW1 |= 0x04 | ||
112 | + } | ||
113 | + | ||
114 | + Return (Arg3) | ||
115 | + } | ||
116 | + | ||
117 | + Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table | ||
118 | + { | ||
119 | + Local0 = Package (0x80){} | ||
120 | + Local1 = Zero | ||
121 | + While ((Local1 < 0x80)) | ||
122 | + { | ||
123 | + Local2 = (Local1 >> 0x02) | ||
124 | + Local3 = ((Local1 + Local2) & 0x03) | ||
125 | + If ((Local3 == Zero)) | ||
126 | + { | ||
127 | + Local4 = Package (0x04) | ||
128 | + { | ||
129 | + Zero, | ||
130 | + Zero, | ||
131 | + LNKD, | ||
132 | + Zero | ||
133 | + } | ||
134 | + } | ||
135 | + | ||
136 | + If ((Local3 == One)) | ||
137 | + { | ||
138 | + Local4 = Package (0x04) | ||
139 | + { | ||
140 | + Zero, | ||
141 | + Zero, | ||
142 | + LNKA, | ||
143 | + Zero | ||
144 | + } | ||
145 | + } | ||
146 | + | ||
147 | + If ((Local3 == 0x02)) | ||
148 | + { | ||
149 | + Local4 = Package (0x04) | ||
150 | + { | ||
151 | + Zero, | ||
152 | + Zero, | ||
153 | + LNKB, | ||
154 | + Zero | ||
155 | + } | ||
156 | + } | ||
157 | + | ||
158 | + If ((Local3 == 0x03)) | ||
159 | + { | ||
160 | + Local4 = Package (0x04) | ||
161 | + { | ||
162 | + Zero, | ||
163 | + Zero, | ||
164 | + LNKC, | ||
165 | + Zero | ||
166 | + } | ||
167 | + } | ||
168 | + | ||
169 | + Local4 [Zero] = ((Local2 << 0x10) | 0xFFFF) | ||
170 | + Local4 [One] = (Local1 & 0x03) | ||
171 | + Local0 [Local1] = Local4 | ||
172 | + Local1++ | ||
173 | + } | ||
174 | + | ||
175 | + Return (Local0) | ||
176 | + } | ||
177 | + | ||
178 | + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | ||
179 | + { | ||
180 | + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
181 | + 0x0000, // Granularity | ||
182 | + 0x0030, // Range Minimum | ||
183 | + 0x0030, // Range Maximum | ||
184 | + 0x0000, // Translation Offset | ||
185 | + 0x0001, // Length | ||
186 | + ,, ) | ||
187 | + }) | ||
188 | + } | ||
189 | + } | ||
190 | + | ||
191 | + Scope (\_SB) | ||
192 | + { | ||
193 | + Device (PC20) | ||
194 | + { | ||
195 | + Name (_UID, 0x20) // _UID: Unique ID | ||
196 | + Name (_BBN, 0x20) // _BBN: BIOS Bus Number | ||
197 | + Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID | ||
198 | + Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID | ||
199 | + Method (_OSC, 4, NotSerialized) // _OSC: Operating System Capabilities | ||
200 | + { | ||
201 | + CreateDWordField (Arg3, Zero, CDW1) | ||
202 | + If ((Arg0 == ToUUID ("33db4d5b-1ff7-401c-9657-7441c03dd766") /* PCI Host Bridge Device */)) | ||
203 | + { | ||
204 | + CreateDWordField (Arg3, 0x04, CDW2) | ||
205 | + CreateDWordField (Arg3, 0x08, CDW3) | ||
206 | + Local0 = CDW3 /* \_SB_.PC20._OSC.CDW3 */ | ||
207 | + Local0 &= 0x1F | ||
208 | + If ((Arg1 != One)) | ||
209 | + { | ||
210 | + CDW1 |= 0x08 | ||
211 | + } | ||
212 | + | ||
213 | + If ((CDW3 != Local0)) | ||
214 | + { | ||
215 | + CDW1 |= 0x10 | ||
216 | + } | ||
217 | + | ||
218 | + CDW3 = Local0 | ||
219 | + } | ||
220 | + Else | ||
221 | + { | ||
222 | + CDW1 |= 0x04 | ||
223 | + } | ||
224 | + | ||
225 | + Return (Arg3) | ||
226 | + } | ||
227 | + | ||
228 | + Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table | ||
229 | + { | ||
230 | + Local0 = Package (0x80){} | ||
231 | + Local1 = Zero | ||
232 | + While ((Local1 < 0x80)) | ||
233 | + { | ||
234 | + Local2 = (Local1 >> 0x02) | ||
235 | + Local3 = ((Local1 + Local2) & 0x03) | ||
236 | + If ((Local3 == Zero)) | ||
237 | + { | ||
238 | + Local4 = Package (0x04) | ||
239 | + { | ||
240 | + Zero, | ||
241 | + Zero, | ||
242 | + LNKD, | ||
243 | + Zero | ||
244 | + } | ||
245 | + } | ||
246 | + | ||
247 | + If ((Local3 == One)) | ||
248 | + { | ||
249 | + Local4 = Package (0x04) | ||
250 | + { | ||
251 | + Zero, | ||
252 | + Zero, | ||
253 | + LNKA, | ||
254 | + Zero | ||
255 | + } | ||
256 | + } | ||
257 | + | ||
258 | + If ((Local3 == 0x02)) | ||
259 | + { | ||
260 | + Local4 = Package (0x04) | ||
261 | + { | ||
262 | + Zero, | ||
263 | + Zero, | ||
264 | + LNKB, | ||
265 | + Zero | ||
266 | + } | ||
267 | + } | ||
268 | + | ||
269 | + If ((Local3 == 0x03)) | ||
270 | + { | ||
271 | + Local4 = Package (0x04) | ||
272 | + { | ||
273 | + Zero, | ||
274 | + Zero, | ||
275 | + LNKC, | ||
276 | + Zero | ||
277 | + } | ||
278 | + } | ||
279 | + | ||
280 | + Local4 [Zero] = ((Local2 << 0x10) | 0xFFFF) | ||
281 | + Local4 [One] = (Local1 & 0x03) | ||
282 | + Local0 [Local1] = Local4 | ||
283 | + Local1++ | ||
284 | + } | ||
285 | + | ||
286 | + Return (Local0) | ||
287 | + } | ||
288 | + | ||
289 | + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | ||
290 | + { | ||
291 | + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
292 | + 0x0000, // Granularity | ||
293 | + 0x0020, // Range Minimum | ||
294 | + 0x0020, // Range Maximum | ||
295 | + 0x0000, // Translation Offset | ||
296 | + 0x0001, // Length | ||
297 | + ,, ) | ||
298 | + }) | ||
299 | + } | ||
300 | + } | ||
301 | + | ||
302 | + Scope (\_SB) | ||
303 | + { | ||
304 | + Device (PC10) | ||
305 | + { | ||
306 | + Name (_UID, 0x10) // _UID: Unique ID | ||
307 | + Name (_BBN, 0x10) // _BBN: BIOS Bus Number | ||
308 | + Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID | ||
309 | + Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID | ||
310 | + Method (_OSC, 4, NotSerialized) // _OSC: Operating System Capabilities | ||
311 | + { | ||
312 | + CreateDWordField (Arg3, Zero, CDW1) | ||
313 | + If ((Arg0 == ToUUID ("33db4d5b-1ff7-401c-9657-7441c03dd766") /* PCI Host Bridge Device */)) | ||
314 | + { | ||
315 | + CreateDWordField (Arg3, 0x04, CDW2) | ||
316 | + CreateDWordField (Arg3, 0x08, CDW3) | ||
317 | + Local0 = CDW3 /* \_SB_.PC10._OSC.CDW3 */ | ||
318 | + Local0 &= 0x1F | ||
319 | + If ((Arg1 != One)) | ||
320 | + { | ||
321 | + CDW1 |= 0x08 | ||
322 | + } | ||
323 | + | ||
324 | + If ((CDW3 != Local0)) | ||
325 | + { | ||
326 | + CDW1 |= 0x10 | ||
327 | + } | ||
328 | + | ||
329 | + CDW3 = Local0 | ||
330 | + } | ||
331 | + Else | ||
332 | + { | ||
333 | + CDW1 |= 0x04 | ||
334 | + } | ||
335 | + | ||
336 | + Return (Arg3) | ||
337 | + } | ||
338 | + | ||
339 | + Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table | ||
340 | + { | ||
341 | + Local0 = Package (0x80){} | ||
342 | + Local1 = Zero | ||
343 | + While ((Local1 < 0x80)) | ||
344 | + { | ||
345 | + Local2 = (Local1 >> 0x02) | ||
346 | + Local3 = ((Local1 + Local2) & 0x03) | ||
347 | + If ((Local3 == Zero)) | ||
348 | + { | ||
349 | + Local4 = Package (0x04) | ||
350 | + { | ||
351 | + Zero, | ||
352 | + Zero, | ||
353 | + LNKD, | ||
354 | + Zero | ||
355 | + } | ||
356 | + } | ||
357 | + | ||
358 | + If ((Local3 == One)) | ||
359 | + { | ||
360 | + Local4 = Package (0x04) | ||
361 | + { | ||
362 | + Zero, | ||
363 | + Zero, | ||
364 | + LNKA, | ||
365 | + Zero | ||
366 | + } | ||
367 | + } | ||
368 | + | ||
369 | + If ((Local3 == 0x02)) | ||
370 | + { | ||
371 | + Local4 = Package (0x04) | ||
372 | + { | ||
373 | + Zero, | ||
374 | + Zero, | ||
375 | + LNKB, | ||
376 | + Zero | ||
377 | + } | ||
378 | + } | ||
379 | + | ||
380 | + If ((Local3 == 0x03)) | ||
381 | + { | ||
382 | + Local4 = Package (0x04) | ||
383 | + { | ||
384 | + Zero, | ||
385 | + Zero, | ||
386 | + LNKC, | ||
387 | + Zero | ||
388 | + } | ||
389 | + } | ||
390 | + | ||
391 | + Local4 [Zero] = ((Local2 << 0x10) | 0xFFFF) | ||
392 | + Local4 [One] = (Local1 & 0x03) | ||
393 | + Local0 [Local1] = Local4 | ||
394 | + Local1++ | ||
395 | + } | ||
396 | + | ||
397 | + Return (Local0) | ||
398 | + } | ||
399 | + | ||
400 | + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | ||
401 | + { | ||
402 | + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
403 | + 0x0000, // Granularity | ||
404 | + 0x0010, // Range Minimum | ||
405 | + 0x0010, // Range Maximum | ||
406 | + 0x0000, // Translation Offset | ||
407 | + 0x0001, // Length | ||
408 | + ,, ) | ||
409 | + }) | ||
410 | + } | ||
411 | + } | ||
412 | + | ||
413 | Scope (\_SB.PCI0) | ||
414 | { | ||
415 | Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | ||
416 | @@ -XXX,XX +XXX,XX @@ | ||
417 | WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
418 | 0x0000, // Granularity | ||
419 | 0x0000, // Range Minimum | ||
420 | - 0x00FF, // Range Maximum | ||
421 | + 0x000F, // Range Maximum | ||
422 | 0x0000, // Translation Offset | ||
423 | - 0x0100, // Length | ||
424 | + 0x0010, // Length | ||
425 | ,, ) | ||
426 | IO (Decode16, | ||
427 | 0x0CF8, // Range Minimum | ||
428 | @@ -XXX,XX +XXX,XX @@ | ||
429 | } | ||
430 | } | ||
431 | |||
432 | + Device (S10) | ||
433 | + { | ||
434 | + Name (_ADR, 0x00020000) // _ADR: Address | ||
435 | + } | ||
436 | + | ||
437 | + Device (S18) | ||
438 | + { | ||
439 | + Name (_ADR, 0x00030000) // _ADR: Address | ||
440 | + } | ||
441 | + | ||
442 | + Device (S20) | ||
443 | + { | ||
444 | + Name (_ADR, 0x00040000) // _ADR: Address | ||
445 | + } | ||
446 | + | ||
447 | + Device (S28) | ||
448 | + { | ||
449 | + Name (_ADR, 0x00050000) // _ADR: Address | ||
450 | + } | ||
451 | + | ||
452 | Method (PCNT, 0, NotSerialized) | ||
453 | { | ||
454 | } | ||
455 | |||
456 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
457 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
458 | Message-id: 20211210170415.583179-8-jean-philippe@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 459 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 460 | --- |
17 | target/arm/helper.c | 6 ++++-- | 461 | tests/qtest/bios-tables-test-allowed-diff.h | 2 -- |
18 | target/arm/machine.c | 24 ++++++++++++++++++++++++ | 462 | tests/data/acpi/q35/DSDT.viot | Bin 0 -> 9398 bytes |
19 | 2 files changed, 28 insertions(+), 2 deletions(-) | 463 | tests/data/acpi/q35/VIOT.viot | Bin 0 -> 112 bytes |
20 | 464 | 3 files changed, 2 deletions(-) | |
21 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 465 | |
466 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | 467 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/helper.c | 468 | --- a/tests/qtest/bios-tables-test-allowed-diff.h |
24 | +++ b/target/arm/helper.c | 469 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h |
25 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 470 | @@ -XXX,XX +XXX,XX @@ |
26 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 0, | 471 | /* List of comma-separated changed AML files to ignore */ |
27 | .access = PL0_RW, .accessfn = pmreg_access_ccntr, | 472 | "tests/data/acpi/virt/VIOT", |
28 | .type = ARM_CP_IO, | 473 | -"tests/data/acpi/q35/DSDT.viot", |
29 | - .readfn = pmccntr_read, .writefn = pmccntr_write, }, | 474 | -"tests/data/acpi/q35/VIOT.viot", |
30 | + .fieldoffset = offsetof(CPUARMState, cp15.c15_ccnt), | 475 | diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot |
31 | + .readfn = pmccntr_read, .writefn = pmccntr_write, | ||
32 | + .raw_readfn = raw_read, .raw_writefn = raw_write, }, | ||
33 | #endif | ||
34 | { .name = "PMCCFILTR_EL0", .state = ARM_CP_STATE_AA64, | ||
35 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 15, .opc2 = 7, | ||
36 | - .writefn = pmccfiltr_write, | ||
37 | + .writefn = pmccfiltr_write, .raw_writefn = raw_write, | ||
38 | .access = PL0_RW, .accessfn = pmreg_access, | ||
39 | .type = ARM_CP_IO, | ||
40 | .fieldoffset = offsetof(CPUARMState, cp15.pmccfiltr_el0), | ||
41 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | 476 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/target/arm/machine.c | 477 | GIT binary patch |
44 | +++ b/target/arm/machine.c | 478 | literal 9398 |
45 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | 479 | zcmeHNO>7&-8J*>iv|O&FB}G~Oi$yp||57BBoWHhc5OS9yDTx$CQgH$r;8Idr*-4Q_ |
46 | { | 480 | z5(9Az1F`}niVsB-)<KW7p`g9Br(A2Gm-gmc1N78GFS!;)e2V(MnH_0{q<{#yMgn&C |
47 | ARMCPU *cpu = opaque; | 481 | zn|*J-d9yqFhO_H6z19~`FlPL*u<DkZ*}|)JH;X@mF-FI<cPg<fti9tEN*yB^i5czN |
48 | 482 | zNq&q?!OZ;BE3B7{KWzJ-`Tn~f`9?Qj8~2^N8{Oc8J%57{==w%rS#;nOCp*nTr@iZ1 | |
49 | + if (!kvm_enabled()) { | 483 | zb+?i;JLQUJ=O0?8*>S~D)a>NF1~WVB6^~_B#yhJ`H+JU@=6aXs`?Yv)J2h=N?drcS |
50 | + pmu_op_start(&cpu->env); | 484 | zeLZ*n<<Bm^n}6`jfBx#u8&(W}1?)}iF9o#mZ~E2+zwdn7yK3AbIzKnxpZ>JRPm3~# |
51 | + } | 485 | z&ICS{+_OayRW-l=Mtk=~uaS3o8z<_udd|(wqg`&JnVPfCe>BUOO`Su3e>pff_^UW% |
52 | + | 486 | z&JE^NO`)=Amg~iqRB1pPscP?(>#ZuY8GHCmlEvD$9g3%4Db~Dfz2SATnddvrR-Oe^ |
53 | if (kvm_enabled()) { | 487 | z;s;dJec!hnzi)ri^I6YN9vtkm{^TdUF8h7gX8-<Qe4p)GQ=)AtYx2VcwdLVAEXEjG |
54 | if (!write_kvmstate_to_list(cpu)) { | 488 | z^Mj|UHPqkj-LsWuzQem1>F3atdZn=zv3$#RmZzSHN+6-yyU#8cJb=YDilX&sl}vNm |
55 | /* This should never fail */ | 489 | znkgAR^O<3kj4if>{ly5fwRfMWuC5=lrlvKPX~i#654Cp}R_d*JS$9laZ$ra6)<ns8 |
56 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | 490 | zFZy28G%xP(nit&F>LDi%G<tIc=TY=gl$jSD&Uv!Yat~XR46h%rI$!}a%!|xG7u8Zn |
57 | return 0; | 491 | zeY8_|n=K>xz_v_W8VX$W-Fg-qFWcT}7MCyz{%%{ia7hZ>Law-k6NOr}VI&_48U=2l |
58 | } | 492 | zwqDKFE8eTwwozDdms#e?x?5a|v>&JF;2_v0L~z5n%BYU^52<*cWuD4|GYUm@1+?)) |
59 | 493 | zte^45>Rz)t*<T5V#={r>@t@{%?^i#W{i=HAZ*Dc9y59Va-+#P!jrGs;u38a{fLr`N | |
60 | +static int cpu_post_save(void *opaque) | 494 | zvT@rUu>DljxJ?^&Z?-?vyJn3C>3D=qux{Y*bs5|5n)Qmi$TD^Zdn4GU$ocJS2Hh-< |
61 | +{ | 495 | z`xPI^^+v0nUVdjMos8k`WGl7hA`{03ju%<lrgAHSpd^DRf-*}_#Ly0mB!LSfVgWcQ |
62 | + ARMCPU *cpu = opaque; | 496 | z&T$@~G9)JI=hz5m0vkrel+Xy{Oh7pkAu-V!j*W7rY(bO}Q$nMH2`FbGB&N)QaV4<4 |
63 | + | 497 | zo)~9JXiP9=;}NPl<C@MmXG&;XFlFNrsyfFsonxFSp<}vEgsRSQP3O3#b6nSnP}ON_ |
64 | + if (!kvm_enabled()) { | 498 | zI!#Tdsp~|j>ckUB>FI=~GokB5sOq#dotCE4(sd$KbtW~PNlj-`*NIToiD#j5J#9^= |
65 | + pmu_op_finish(&cpu->env); | 499 | zt?NXn>YUJYPG~wObe#xQos*i*NloXZt`niEb4t@WrRki~bs|)CI+{*L)9L6s5vn>< |
66 | + } | 500 | zn$DD_Go|Z9sOn5>I@6lYw5}7Os&iV?Ij!lO)^#FOb!If38BJ$K*NIToIiu;E(R9w} |
67 | + | 501 | zIuWWmPiZ<&X*y5oIuWWmF_XaEC!a&Jn$B5WCqh-{X-(&8P3LJ{Cqh-{8P3dyPr@^t |
68 | + return 0; | 502 | zSqL9?X9Uwd3W@23*s~h*tj0X6GZCuHa~kuU#yqDp5vt7d8uPryJg+kms?5hU=3^T3 |
69 | +} | 503 | zF`bD}WnSP+=`t5MQ$FJ_2&Q~+BP6E0f^%BVIW6a$o)e+SX~IDBih-7z6{O~7YTy`& |
70 | + | 504 | zLjy&Cv?7QikV#>n0>>@MV8oK`Gmun34-FKdlm-J8SZSaNlnhir4-FI{S|bfqV8e)V |
71 | static int cpu_pre_load(void *opaque) | 505 | zss<{chX#reE#g=hsKAC%sF6d-Km}BWs!kZFsFpKfpbC@>6rprQGEjt4Ck#|zITHq| |
72 | { | 506 | zK*>M_l;<P^MJRQ`Kn0dFVW0|>3{*fllMEE0)CmI>Sk8ojDo`>|0p(0GP=xY&!axO< |
73 | ARMCPU *cpu = opaque; | 507 | zGhv_#lnhirIg<<&q0|Wj6<E%MfhtfkPyyvkGEjt4Ck#|zITHq|K*>M_lrzad5lWpf |
74 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_load(void *opaque) | 508 | zP=V!47^ngz0~JutBm+e#b;3XemNQ|X3X}{~Ksl2P6rt1!0~J`#gn=qhGEf2KOfpb} |
75 | */ | 509 | zQYQ>lU^x>8szAv=1(Y+%KoLrvFi?TzOc<yFB?A>u&LjgxD0RX>1(q{mpbC@>R6seC |
76 | env->irq_line_state = UINT32_MAX; | 510 | z3>2Z%2?G^a&V+#~P%=;f<xDbAgi<FARA4z12C6{GKn0XD$v_cGoiI>=<xCi;0wn_# |
77 | 511 | zP|hR+MJRQ`Kn0dFVW0|>3{*fllMEE0)CmI>Sk8ojDo`>|0p(0GP=rz^3{+q_69%e4 | |
78 | + if (!kvm_enabled()) { | 512 | z$v_2^Gs!>^N}VuJf#pmXr~)Me6;RG314Srx!axxz28u{EP=u<1B2)}iVZuNaCK;&0 |
79 | + pmu_op_start(&cpu->env); | 513 | zBm-5LFi?dF167!0pbC==RAItE6($T+VUmF=Ofpb~2?JG_Fi?d_2C6X0Kouqo6p_5T |
80 | + } | 514 | zFi=FeV!SiSKoR0H$dH(_Z(*Q_WZ%L-5y`$K14StNmJAdjmWs}HV4<vU_xO+1efmLq |
81 | + | 515 | zZ;W>N_U)fP6Qy6Nw5mbt9Y(#emWSi66=>tq#xoh#Ue=0qyhxi8ZOUe5y0V7VfPUhp |
82 | return 0; | 516 | zwX=;ymc+i5%sg9Ja~lZ&8oAV@mHc>&CHP9v4R(jhtT?un;O4e9#pno)Xkh7OWgK&a |
83 | } | 517 | zyj=3Iv0OuoK_;5rOr5f(Kb~ZXDBO+V`OWYo#_C08imwChQxnjdd?wZLDou8aj;$SD |
84 | 518 | zGDYiA3<$Tu<JnHL(KPOChi#zrR32t83}naR$+ym4P_h?z_5#|cW-nw$XD_sOtE62l | |
85 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) | 519 | zrD3@*)NVyiklt0&yF9%+klsBey&I<Y2E<!f(E8TuJte)z(|ZHyy<^gQVfx}=`q&B5 |
86 | hw_breakpoint_update_all(cpu); | 520 | z7nSryp1wGczIaUfVwiq$Fn#<4=@*ssi#+|}K>EdF(l3VTOM~ghPLRH&q%ZOGrGfON |
87 | hw_watchpoint_update_all(cpu); | 521 | zW73zx^yR_y<0nX8R??Sw`tm^f@-gYlNFSp|*<gA{q?Zp5Oe-+l#rmyYmKozi9y=P> |
88 | 522 | zVReJU*h=ZuVXiS$ohTbw-O#v9>(yZbGE|)?8(H1ZIKvV!jWa0>vy!3eMA^vdhQ>`s | |
89 | + if (!kvm_enabled()) { | 523 | zuMSg{q3T50$m)j1!HixV<}X9liL#N^4c*tL^y)CF8LCc{jjV3yKAqL8!%SzWI#H%q |
90 | + pmu_op_finish(&cpu->env); | 524 | z=bSrQ&)%JCRttF5g4Zf`6l?y@>PzD7MA^D>wBlcH6r1ucwJ<p0O%rZ?JzIY3-QdmZ |
91 | + } | 525 | zzs|n>`a5r3e|z)wcUaqS>nqFQ-8x}eCF4u`OWUxqst-@1rSmUs%WmKP5e0dcb?e2N |
92 | + | 526 | z;Z|x*!);VwF|Yuhqs^khqOM!@u*jY!WYldISF(V6`BoNd&6Qfk3>X#SuD^7J>p_D= |
93 | return 0; | 527 | zBPa51y^_n#=cpOt#Zf$ya$Ae9Mfz56n|<i!a=ELS@)%a{^NIH3SDuN<R~sah1km#P |
94 | } | 528 | zU@?*f%<rG=4W1wgfi;C?_n|W@%lm$&8YfvNOJodIg&IcIpIJQRHr<+ej11GQ6)&eF |
95 | 529 | z2Lam*jIH}#y0>KnY%4JQfOYS$*uU%f#@$U6`N8I3N-lV?5ErFCdv~xDmu2(wexld4 | |
96 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = { | 530 | z4v^;aVAT2k6GJ^m*FD(Wqc(Qg^)6a<?}h$zLoj}4;PP!+(O{@!a1y-hoAhF_7!z+6 |
97 | .version_id = 22, | 531 | zslpAmNtYbjHrw-~#SPVk_FUf>-Obg6yV`8o$8_`PyJe_;bY5_EMBfBfWU!Q=*9HsG |
98 | .minimum_version_id = 22, | 532 | z%_Cda{@_Krr!oHVhv9+y+T5qR8zZ2aZ>5r!$*|f$^U%yBUYfR&B!+EYy_PwL!BeUi |
99 | .pre_save = cpu_pre_save, | 533 | zJH^}r3r9Q+B)X@Z)fk=P13w&7x#wBtXTZ)g>WITPg5r&pQc!nmyrmk#S(>>b9xnNr |
100 | + .post_save = cpu_post_save, | 534 | zx_b#v9Xv-Y><Wb%?S^0Xe&<)bbKl_=Z|3C$tf|F<bYzE*mfHB;uC)`q-?buaBe?l? |
101 | .pre_load = cpu_pre_load, | 535 | zcLTpK*k<49Z32`K?|nSBMFqxTK^_IE-li2fEGdK~(ZdoKBl6ab4a;Hler#`xvEXJG |
102 | .post_load = cpu_post_load, | 536 | zb?<E%EZExfX>jcOVhS*0rS~RS1dA#xhkv@Nct@#q?LyeKS<$uFec!bw>{@uu$gZ6a |
103 | .fields = (VMStateField[]) { | 537 | zyVen1i{1BKd%~`D7|m$;U0a<I*3I7%^N%N%lGYdU_GS!gaR8T$NA@GzFi~z`l7hdl |
538 | zarZy6590|88pi(1zq;V(>38zM0sT&<zX;R5$1w3;`_JMG`;&I&0Y23DMx1%@(w(R9 | ||
539 | z4M$j;D5J+Gy%fijRQsctzFKf&cv|BAz#YLq3CZJWDdtL4u1u1|mkdcUp7|sxJC+?Y | ||
540 | z_@@s`v3j}Q7*z>6X~cwUxUL8G1KT)_XTp!KAbs;vCp{K3&~_X@+ew=-D}v`2MbFV0 | ||
541 | zQsVsL=rXi-pI*G|iiz;VTCutgUs)hDzV1+4?8KcoP3xROf<M%qC6lgVdpFt4<-|uM | ||
542 | z=#rl_b1#YjSIl6Toj2z_hOZcKupkdE(LozC(fN=FY(x|sk)ym|;Rq2E1xJWD%Z!ol | ||
543 | Gu>S+TT-130 | ||
544 | |||
545 | literal 0 | ||
546 | HcmV?d00001 | ||
547 | |||
548 | diff --git a/tests/data/acpi/q35/VIOT.viot b/tests/data/acpi/q35/VIOT.viot | ||
549 | index XXXXXXX..XXXXXXX 100644 | ||
550 | GIT binary patch | ||
551 | literal 112 | ||
552 | zcmWIZ^baXu00LVle`k+i1*eDrX9XZ&1PX!JAex!M0Hgv8m>C3sGzdcgBZCA3T-xBj | ||
553 | Q0Zb)W9Hva*zW_`e0M!8s0RR91 | ||
554 | |||
555 | literal 0 | ||
556 | HcmV?d00001 | ||
557 | |||
104 | -- | 558 | -- |
105 | 2.20.1 | 559 | 2.25.1 |
106 | 560 | ||
107 | 561 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay <aaron@os.amperecomputing.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In some cases it may be helpful to modify state before saving it for | 3 | The VIOT blob contains the following: |
4 | migration, and then modify the state back after it has been saved. The | ||
5 | existing pre_save function provides half of this functionality. This | ||
6 | patch adds a post_save function to provide the second half. | ||
7 | 4 | ||
8 | Signed-off-by: Aaron Lindsay <aclindsa@gmail.com> | 5 | [000h 0000 4] Signature : "VIOT" [Virtual I/O Translation Table] |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | [004h 0004 4] Table Length : 00000058 |
10 | Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> | 7 | [008h 0008 1] Revision : 00 |
11 | Message-id: 20181211151945.29137-2-aaron@os.amperecomputing.com | 8 | [009h 0009 1] Checksum : 66 |
9 | [00Ah 0010 6] Oem ID : "BOCHS " | ||
10 | [010h 0016 8] Oem Table ID : "BXPC " | ||
11 | [018h 0024 4] Oem Revision : 00000001 | ||
12 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | ||
13 | [020h 0032 4] Asl Compiler Revision : 00000001 | ||
14 | |||
15 | [024h 0036 2] Node count : 0002 | ||
16 | [026h 0038 2] Node offset : 0030 | ||
17 | [028h 0040 8] Reserved : 0000000000000000 | ||
18 | |||
19 | [030h 0048 1] Type : 03 [VirtIO-PCI IOMMU] | ||
20 | [031h 0049 1] Reserved : 00 | ||
21 | [032h 0050 2] Length : 0010 | ||
22 | |||
23 | [034h 0052 2] PCI Segment : 0000 | ||
24 | [036h 0054 2] PCI BDF number : 0008 | ||
25 | [038h 0056 8] Reserved : 0000000000000000 | ||
26 | |||
27 | [040h 0064 1] Type : 01 [PCI Range] | ||
28 | [041h 0065 1] Reserved : 00 | ||
29 | [042h 0066 2] Length : 0018 | ||
30 | |||
31 | [044h 0068 4] Endpoint start : 00000000 | ||
32 | [048h 0072 2] PCI Segment start : 0000 | ||
33 | [04Ah 0074 2] PCI Segment end : 0000 | ||
34 | [04Ch 0076 2] PCI BDF start : 0000 | ||
35 | [04Eh 0078 2] PCI BDF end : 00FF | ||
36 | [050h 0080 2] Output node : 0030 | ||
37 | [052h 0082 6] Reserved : 000000000000 | ||
38 | |||
39 | Acked-by: Ani Sinha <ani@anisinha.ca> | ||
40 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
41 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
42 | Message-id: 20211210170415.583179-9-jean-philippe@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 43 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 44 | --- |
14 | include/migration/vmstate.h | 1 + | 45 | tests/qtest/bios-tables-test-allowed-diff.h | 1 - |
15 | migration/vmstate.c | 13 ++++++++++++- | 46 | tests/data/acpi/virt/VIOT | Bin 0 -> 88 bytes |
16 | docs/devel/migration.rst | 9 +++++++-- | 47 | 2 files changed, 1 deletion(-) |
17 | 3 files changed, 20 insertions(+), 3 deletions(-) | ||
18 | 48 | ||
19 | diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h | 49 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h |
20 | index XXXXXXX..XXXXXXX 100644 | 50 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/migration/vmstate.h | 51 | --- a/tests/qtest/bios-tables-test-allowed-diff.h |
22 | +++ b/include/migration/vmstate.h | 52 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h |
23 | @@ -XXX,XX +XXX,XX @@ struct VMStateDescription { | 53 | @@ -1,2 +1 @@ |
24 | int (*pre_load)(void *opaque); | 54 | /* List of comma-separated changed AML files to ignore */ |
25 | int (*post_load)(void *opaque, int version_id); | 55 | -"tests/data/acpi/virt/VIOT", |
26 | int (*pre_save)(void *opaque); | 56 | diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/virt/VIOT |
27 | + int (*post_save)(void *opaque); | ||
28 | bool (*needed)(void *opaque); | ||
29 | const VMStateField *fields; | ||
30 | const VMStateDescription **subsections; | ||
31 | diff --git a/migration/vmstate.c b/migration/vmstate.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 57 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/migration/vmstate.c | 58 | GIT binary patch |
34 | +++ b/migration/vmstate.c | 59 | literal 88 |
35 | @@ -XXX,XX +XXX,XX @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, | 60 | zcmWIZ^bd((0D?3pe`k+i1*eDrX9XZ&1PX!JAexE60Hgv8m>C3sGzXN&z`)2L0cSHX |
36 | if (ret) { | 61 | I{D-Rq0Q5fy0RR91 |
37 | error_report("Save of field %s/%s failed", | 62 | |
38 | vmsd->name, field->name); | 63 | literal 0 |
39 | + if (vmsd->post_save) { | 64 | HcmV?d00001 |
40 | + vmsd->post_save(opaque); | 65 | |
41 | + } | ||
42 | return ret; | ||
43 | } | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, | ||
46 | json_end_array(vmdesc); | ||
47 | } | ||
48 | |||
49 | - return vmstate_subsection_save(f, vmsd, opaque, vmdesc); | ||
50 | + ret = vmstate_subsection_save(f, vmsd, opaque, vmdesc); | ||
51 | + | ||
52 | + if (vmsd->post_save) { | ||
53 | + int ps_ret = vmsd->post_save(opaque); | ||
54 | + if (!ret) { | ||
55 | + ret = ps_ret; | ||
56 | + } | ||
57 | + } | ||
58 | + return ret; | ||
59 | } | ||
60 | |||
61 | static const VMStateDescription * | ||
62 | diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/docs/devel/migration.rst | ||
65 | +++ b/docs/devel/migration.rst | ||
66 | @@ -XXX,XX +XXX,XX @@ The functions to do that are inside a vmstate definition, and are called: | ||
67 | |||
68 | This function is called before we save the state of one device. | ||
69 | |||
70 | -Example: You can look at hpet.c, that uses the three function to | ||
71 | -massage the state that is transferred. | ||
72 | +- ``int (*post_save)(void *opaque);`` | ||
73 | + | ||
74 | + This function is called after we save the state of one device | ||
75 | + (even upon failure, unless the call to pre_save returned an error). | ||
76 | + | ||
77 | +Example: You can look at hpet.c, that uses the first three functions | ||
78 | +to massage the state that is transferred. | ||
79 | |||
80 | The ``VMSTATE_WITH_TMP`` macro may be useful when the migration | ||
81 | data doesn't match the stored device data well; it allows an | ||
82 | -- | 66 | -- |
83 | 2.20.1 | 67 | 2.25.1 |
84 | 68 | ||
85 | 69 | diff view generated by jsdifflib |