1 | First arm pullreq of 4.2... | 1 | Hi; here's the first target-arm pullreq for the 7.0 cycle. |
---|---|---|---|
2 | 2 | ||
3 | thanks | 3 | thanks |
4 | -- PMM | 4 | -- PMM |
5 | 5 | ||
6 | The following changes since commit 27608c7c66bd923eb5e5faab80e795408cbe2b51: | 6 | The following changes since commit 76b56fdfc9fa43ec6e5986aee33f108c6c6a511e: |
7 | 7 | ||
8 | Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190814a' into staging (2019-08-16 12:00:18 +0100) | 8 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2021-12-14 12:46:18 -0800) |
9 | 9 | ||
10 | are available in the Git repository at: | 10 | are available in the Git repository at: |
11 | 11 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190816 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20211215 |
13 | 13 | ||
14 | for you to fetch changes up to 664b7e3b97d6376f3329986c465b3782458b0f8b: | 14 | for you to fetch changes up to aed176558806674d030a8305d989d4e6a5073359: |
15 | 15 | ||
16 | target/arm: Use tcg_gen_extrh_i64_i32 to extract the high word (2019-08-16 14:02:53 +0100) | 16 | tests/acpi: add expected blob for VIOT test on virt machine (2021-12-15 10:35:26 +0000) |
17 | 17 | ||
18 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
19 | target-arm queue: | 19 | target-arm queue: |
20 | * target/arm: generate a custom MIDR for -cpu max | 20 | * ITS: error reporting cleanup |
21 | * hw/misc/zynq_slcr: refactor to use standard register definition | 21 | * aspeed: improve documentation |
22 | * Set ENET_BD_BDU in I.MX FEC controller | 22 | * Fix STM32F2XX USART data register readout |
23 | * target/arm: Fix routing of singlestep exceptions | 23 | * allow emulated GICv3 to be disabled in non-TCG builds |
24 | * refactor a32/t32 decoder handling of PC | 24 | * fix exception priority for singlestep, misaligned PC, bp, etc |
25 | * minor optimisations/cleanups of some a32/t32 codegen | 25 | * Correct calculation of tlb range invalidate length |
26 | * target/arm/cpu64: Ensure kvm really supports aarch64=off | 26 | * npcm7xx_emc: fix missing queue_flush |
27 | * target/arm/cpu: Ensure we can use the pmu with kvm | 27 | * virt: Add VIOT ACPI table for virtio-iommu |
28 | * target/arm: Minor cleanups preparatory to KVM SVE support | 28 | * target/i386: Use assert() to sanity-check b1 in SSE decode |
29 | * Don't include qemu-common unnecessarily | ||
29 | 30 | ||
30 | ---------------------------------------------------------------- | 31 | ---------------------------------------------------------------- |
31 | Aaron Hill (1): | 32 | Alex Bennée (1): |
32 | Set ENET_BD_BDU in I.MX FEC controller | 33 | hw/intc: clean-up error reporting for failed ITS cmd |
33 | 34 | ||
34 | Alex Bennée (1): | 35 | Jean-Philippe Brucker (8): |
35 | target/arm: generate a custom MIDR for -cpu max | 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 | ||
36 | 44 | ||
37 | Andrew Jones (6): | 45 | Joel Stanley (4): |
38 | target/arm/cpu64: Ensure kvm really supports aarch64=off | 46 | docs: aspeed: Add new boards |
39 | target/arm/cpu: Ensure we can use the pmu with kvm | 47 | docs: aspeed: Update OpenBMC image URL |
40 | target/arm/helper: zcr: Add build bug next to value range assumption | 48 | docs: aspeed: Give an example of booting a kernel |
41 | target/arm/cpu: Use div-round-up to determine predicate register array size | 49 | docs: aspeed: ADC is now modelled |
42 | target/arm/kvm64: Fix error returns | ||
43 | target/arm/kvm64: Move the get/put of fpsimd registers out | ||
44 | 50 | ||
45 | Damien Hedde (1): | 51 | Olivier Hériveaux (1): |
46 | hw/misc/zynq_slcr: use standard register definition | 52 | Fix STM32F2XX USART data register readout |
47 | 53 | ||
48 | Peter Maydell (2): | 54 | Patrick Venture (1): |
49 | target/arm: Factor out 'generate singlestep exception' function | 55 | hw/net: npcm7xx_emc fix missing queue_flush |
50 | target/arm: Fix routing of singlestep exceptions | ||
51 | 56 | ||
52 | Richard Henderson (18): | 57 | Peter Maydell (6): |
53 | target/arm: Pass in pc to thumb_insn_is_16bit | 58 | target/i386: Use assert() to sanity-check b1 in SSE decode |
54 | target/arm: Introduce pc_curr | 59 | include/hw/i386: Don't include qemu-common.h in .h files |
55 | target/arm: Introduce read_pc | 60 | target/hexagon/cpu.h: don't include qemu-common.h |
56 | target/arm: Introduce add_reg_for_lit | 61 | target/rx/cpu.h: Don't include qemu-common.h |
57 | target/arm: Remove redundant s->pc & ~1 | 62 | hw/arm: Don't include qemu-common.h unnecessarily |
58 | target/arm: Replace s->pc with s->base.pc_next | 63 | target/arm: Correct calculation of tlb range invalidate length |
59 | target/arm: Replace offset with pc in gen_exception_insn | ||
60 | target/arm: Replace offset with pc in gen_exception_internal_insn | ||
61 | target/arm: Remove offset argument to gen_exception_bkpt_insn | ||
62 | target/arm: Use unallocated_encoding for aarch32 | ||
63 | target/arm: Remove helper_double_saturate | ||
64 | target/arm: Use tcg_gen_extract_i32 for shifter_out_im | ||
65 | target/arm: Use tcg_gen_deposit_i32 for PKHBT, PKHTB | ||
66 | target/arm: Remove redundant shift tests | ||
67 | target/arm: Use ror32 instead of open-coding the operation | ||
68 | target/arm: Use tcg_gen_rotri_i32 for gen_swap_half | ||
69 | target/arm: Simplify SMMLA, SMMLAR, SMMLS, SMMLSR | ||
70 | target/arm: Use tcg_gen_extrh_i64_i32 to extract the high word | ||
71 | 64 | ||
72 | target/arm/cpu.h | 13 +- | 65 | Philippe Mathieu-Daudé (2): |
73 | target/arm/helper.h | 1 - | 66 | hw/intc/arm_gicv3: Extract gicv3_set_gicv3state from arm_gicv3_cpuif.c |
74 | target/arm/kvm_arm.h | 28 ++ | 67 | hw/intc/arm_gicv3: Introduce CONFIG_ARM_GIC_TCG Kconfig selector |
75 | target/arm/translate-a64.h | 4 +- | ||
76 | target/arm/translate.h | 39 ++- | ||
77 | hw/misc/zynq_slcr.c | 450 ++++++++++++++++---------------- | ||
78 | hw/net/imx_fec.c | 4 + | ||
79 | target/arm/cpu.c | 30 ++- | ||
80 | target/arm/cpu64.c | 31 ++- | ||
81 | target/arm/helper.c | 7 + | ||
82 | target/arm/kvm.c | 7 + | ||
83 | target/arm/kvm64.c | 161 +++++++----- | ||
84 | target/arm/op_helper.c | 15 -- | ||
85 | target/arm/translate-a64.c | 130 ++++------ | ||
86 | target/arm/translate-vfp.inc.c | 45 +--- | ||
87 | target/arm/translate.c | 572 +++++++++++++++++------------------------ | ||
88 | 16 files changed, 771 insertions(+), 766 deletions(-) | ||
89 | 68 | ||
69 | Richard Henderson (10): | ||
70 | target/arm: Hoist pc_next to a local variable in aarch64_tr_translate_insn | ||
71 | target/arm: Hoist pc_next to a local variable in arm_tr_translate_insn | ||
72 | target/arm: Hoist pc_next to a local variable in thumb_tr_translate_insn | ||
73 | target/arm: Split arm_pre_translate_insn | ||
74 | target/arm: Advance pc for arch single-step exception | ||
75 | target/arm: Split compute_fsr_fsc out of arm_deliver_fault | ||
76 | target/arm: Take an exception if PC is misaligned | ||
77 | target/arm: Assert thumb pc is aligned | ||
78 | target/arm: Suppress bp for exceptions with more priority | ||
79 | tests/tcg: Add arm and aarch64 pc alignment tests | ||
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: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | While most features are now detected by probing the ID_* registers | 3 | While trying to debug a GIC ITS failure I saw some guest errors that |
4 | kernels can (and do) use MIDR_EL1 for working out of they have to | 4 | had poor formatting as well as leaving me confused as to what failed. |
5 | apply errata. This can trip up warnings in the kernel as it tries to | 5 | As most of the checks aren't possible without a valid dte split that |
6 | work out if it should apply workarounds to features that don't | 6 | check apart and then check the other conditions in steps. This avoids |
7 | actually exist in the reported CPU type. | 7 | us relying on undefined data. |
8 | 8 | ||
9 | Avoid this problem by synthesising our own MIDR value. | 9 | I still get a failure with the current kvm-unit-tests but at least I |
10 | know (partially) why now: | ||
11 | |||
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 | ||
10 | 19 | ||
11 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 20 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Message-id: 20211112170454.3158925-1-alex.bennee@linaro.org |
14 | Message-id: 20190726113950.7499-1-alex.bennee@linaro.org | 23 | Cc: Shashi Mallela <shashi.mallela@linaro.org> |
24 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 26 | --- |
17 | target/arm/cpu.h | 6 ++++++ | 27 | hw/intc/arm_gicv3_its.c | 39 +++++++++++++++++++++++++++------------ |
18 | target/arm/cpu64.c | 19 +++++++++++++++++++ | 28 | 1 file changed, 27 insertions(+), 12 deletions(-) |
19 | 2 files changed, 25 insertions(+) | ||
20 | 29 | ||
21 | 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 |
22 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.h | 32 | --- a/hw/intc/arm_gicv3_its.c |
24 | +++ b/target/arm/cpu.h | 33 | +++ b/hw/intc/arm_gicv3_its.c |
25 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_FPCCR, ASPEN, 31, 1) | 34 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, |
26 | /* | 35 | if (res != MEMTX_OK) { |
27 | * System register ID fields. | 36 | return result; |
28 | */ | 37 | } |
29 | +FIELD(MIDR_EL1, REVISION, 0, 4) | 38 | + } else { |
30 | +FIELD(MIDR_EL1, PARTNUM, 4, 12) | 39 | + qemu_log_mask(LOG_GUEST_ERROR, |
31 | +FIELD(MIDR_EL1, ARCHITECTURE, 16, 4) | 40 | + "%s: invalid command attributes: " |
32 | +FIELD(MIDR_EL1, VARIANT, 20, 4) | 41 | + "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n", |
33 | +FIELD(MIDR_EL1, IMPLEMENTER, 24, 8) | 42 | + __func__, dte, devid, res); |
43 | + return result; | ||
44 | } | ||
45 | |||
46 | - if ((devid > s->dt.maxids.max_devids) || !dte_valid || !ite_valid || | ||
47 | - !cte_valid || (eventid > max_eventid)) { | ||
34 | + | 48 | + |
35 | FIELD(ID_ISAR0, SWAP, 0, 4) | 49 | + /* |
36 | FIELD(ID_ISAR0, BITCOUNT, 4, 4) | 50 | + * In this implementation, in case of guest errors we ignore the |
37 | FIELD(ID_ISAR0, BITFIELD, 8, 4) | 51 | + * command and move onto the next command in the queue. |
38 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 52 | + */ |
39 | index XXXXXXX..XXXXXXX 100644 | 53 | + if (devid > s->dt.maxids.max_devids) { |
40 | --- a/target/arm/cpu64.c | 54 | qemu_log_mask(LOG_GUEST_ERROR, |
41 | +++ b/target/arm/cpu64.c | 55 | - "%s: invalid command attributes " |
42 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 56 | - "devid %d or eventid %d or invalid dte %d or" |
43 | uint32_t u; | 57 | - "invalid cte %d or invalid ite %d\n", |
44 | aarch64_a57_initfn(obj); | 58 | - __func__, devid, eventid, dte_valid, cte_valid, |
45 | 59 | - ite_valid); | |
46 | + /* | 60 | - /* |
47 | + * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real | 61 | - * in this implementation, in case of error |
48 | + * one and try to apply errata workarounds or use impdef features we | 62 | - * we ignore this command and move onto the next |
49 | + * don't provide. | 63 | - * command in the queue |
50 | + * An IMPLEMENTER field of 0 means "reserved for software use"; | 64 | - */ |
51 | + * ARCHITECTURE must be 0xf indicating "v7 or later, check ID registers | 65 | + "%s: invalid command attributes: devid %d>%d", |
52 | + * to see which features are present"; | 66 | + __func__, devid, s->dt.maxids.max_devids); |
53 | + * the VARIANT, PARTNUM and REVISION fields are all implementation | ||
54 | + * defined and we choose to define PARTNUM just in case guest | ||
55 | + * code needs to distinguish this QEMU CPU from other software | ||
56 | + * implementations, though this shouldn't be needed. | ||
57 | + */ | ||
58 | + t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0); | ||
59 | + t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); | ||
60 | + t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q'); | ||
61 | + t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0); | ||
62 | + t = FIELD_DP64(t, MIDR_EL1, REVISION, 0); | ||
63 | + cpu->midr = t; | ||
64 | + | 67 | + |
65 | t = cpu->isar.id_aa64isar0; | 68 | + } else if (!dte_valid || !ite_valid || !cte_valid) { |
66 | t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ | 69 | + qemu_log_mask(LOG_GUEST_ERROR, |
67 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); | 70 | + "%s: invalid command attributes: " |
71 | + "dte: %s, ite: %s, cte: %s\n", | ||
72 | + __func__, | ||
73 | + dte_valid ? "valid" : "invalid", | ||
74 | + ite_valid ? "valid" : "invalid", | ||
75 | + cte_valid ? "valid" : "invalid"); | ||
76 | + } else if (eventid > max_eventid) { | ||
77 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
78 | + "%s: invalid command attributes: eventid %d > %d\n", | ||
79 | + __func__, eventid, max_eventid); | ||
80 | } else { | ||
81 | /* | ||
82 | * Current implementation only supports rdbase == procnum | ||
68 | -- | 83 | -- |
69 | 2.20.1 | 84 | 2.25.1 |
70 | 85 | ||
71 | 86 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Extract is a compact combination of shift + and. | 3 | Add X11, FP5280G2, G220A, Rainier and Fuji. Mention that Swift will be |
4 | removed in v7.0. | ||
4 | 5 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Joel Stanley <joel@jms.id.au> |
6 | Message-id: 20190808202616.13782-2-richard.henderson@linaro.org | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 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 | target/arm/translate.c | 9 +-------- | 11 | docs/system/arm/aspeed.rst | 7 ++++++- |
11 | 1 file changed, 1 insertion(+), 8 deletions(-) | 12 | 1 file changed, 6 insertions(+), 1 deletion(-) |
12 | 13 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 16 | --- a/docs/system/arm/aspeed.rst |
16 | +++ b/target/arm/translate.c | 17 | +++ b/docs/system/arm/aspeed.rst |
17 | @@ -XXX,XX +XXX,XX @@ static void gen_sar(TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1) | 18 | @@ -XXX,XX +XXX,XX @@ AST2400 SoC based machines : |
18 | 19 | ||
19 | static void shifter_out_im(TCGv_i32 var, int shift) | 20 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC |
20 | { | 21 | - ``quanta-q71l-bmc`` OpenBMC Quanta BMC |
21 | - if (shift == 0) { | 22 | +- ``supermicrox11-bmc`` Supermicro X11 BMC |
22 | - tcg_gen_andi_i32(cpu_CF, var, 1); | 23 | |
23 | - } else { | 24 | AST2500 SoC based machines : |
24 | - tcg_gen_shri_i32(cpu_CF, var, shift); | 25 | |
25 | - if (shift != 31) { | 26 | @@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines : |
26 | - tcg_gen_andi_i32(cpu_CF, cpu_CF, 1); | 27 | - ``romulus-bmc`` OpenPOWER Romulus POWER9 BMC |
27 | - } | 28 | - ``witherspoon-bmc`` OpenPOWER Witherspoon POWER9 BMC |
28 | - } | 29 | - ``sonorapass-bmc`` OCP SonoraPass BMC |
29 | + tcg_gen_extract_i32(cpu_CF, var, shift, 1); | 30 | -- ``swift-bmc`` OpenPOWER Swift BMC POWER9 |
30 | } | 31 | +- ``swift-bmc`` OpenPOWER Swift BMC POWER9 (to be removed in v7.0) |
31 | 32 | +- ``fp5280g2-bmc`` Inspur FP5280G2 BMC | |
32 | /* Shift by immediate. Includes special handling for shift == 0. */ | 33 | +- ``g220a-bmc`` Bytedance G220A BMC |
34 | |||
35 | AST2600 SoC based machines : | ||
36 | |||
37 | - ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex-A7) | ||
38 | - ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC | ||
39 | +- ``rainier-bmc`` IBM Rainier POWER10 BMC | ||
40 | +- ``fuji-bmc`` Facebook Fuji BMC | ||
41 | |||
42 | Supported devices | ||
43 | ----------------- | ||
33 | -- | 44 | -- |
34 | 2.20.1 | 45 | 2.25.1 |
35 | 46 | ||
36 | 47 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Unlike the other more generic gen_exception{,_internal}_insn | 3 | This is the latest URL for the OpenBMC CI. The old URL still works, but |
4 | interfaces, breakpoints always refer to the current instruction. | 4 | redirects. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Joel Stanley <joel@jms.id.au> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Message-id: 20211117065752.330632-3-joel@jms.id.au |
9 | Message-id: 20190807045335.1361-10-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/translate-a64.c | 7 +++---- | 11 | docs/system/arm/aspeed.rst | 2 +- |
13 | target/arm/translate.c | 8 ++++---- | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 2 files changed, 7 insertions(+), 8 deletions(-) | ||
15 | 13 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 16 | --- a/docs/system/arm/aspeed.rst |
19 | +++ b/target/arm/translate-a64.c | 17 | +++ b/docs/system/arm/aspeed.rst |
20 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | 18 | @@ -XXX,XX +XXX,XX @@ The Aspeed machines can be started using the ``-kernel`` option to |
21 | s->base.is_jmp = DISAS_NORETURN; | 19 | load a Linux kernel or from a firmware. Images can be downloaded from |
22 | } | 20 | the OpenBMC jenkins : |
23 | 21 | ||
24 | -static void gen_exception_bkpt_insn(DisasContext *s, int offset, | 22 | - https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/distro=ubuntu,label=docker-builder |
25 | - uint32_t syndrome) | 23 | + https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/ |
26 | +static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syndrome) | 24 | |
27 | { | 25 | or directly from the OpenBMC GitHub release repository : |
28 | TCGv_i32 tcg_syn; | ||
29 | |||
30 | - gen_a64_set_pc_im(s->base.pc_next - offset); | ||
31 | + gen_a64_set_pc_im(s->pc_curr); | ||
32 | tcg_syn = tcg_const_i32(syndrome); | ||
33 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
34 | tcg_temp_free_i32(tcg_syn); | ||
35 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
36 | break; | ||
37 | } | ||
38 | /* BRK */ | ||
39 | - gen_exception_bkpt_insn(s, 4, syn_aa64_bkpt(imm16)); | ||
40 | + gen_exception_bkpt_insn(s, syn_aa64_bkpt(imm16)); | ||
41 | break; | ||
42 | case 2: | ||
43 | if (op2_ll != 0) { | ||
44 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/translate.c | ||
47 | +++ b/target/arm/translate.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, uint32_t pc, int excp, | ||
49 | s->base.is_jmp = DISAS_NORETURN; | ||
50 | } | ||
51 | |||
52 | -static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | ||
53 | +static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) | ||
54 | { | ||
55 | TCGv_i32 tcg_syn; | ||
56 | |||
57 | gen_set_condexec(s); | ||
58 | - gen_set_pc_im(s, s->base.pc_next - offset); | ||
59 | + gen_set_pc_im(s, s->pc_curr); | ||
60 | tcg_syn = tcg_const_i32(syn); | ||
61 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
62 | tcg_temp_free_i32(tcg_syn); | ||
63 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
64 | case 1: | ||
65 | /* bkpt */ | ||
66 | ARCH(5); | ||
67 | - gen_exception_bkpt_insn(s, 4, syn_aa32_bkpt(imm16, false)); | ||
68 | + gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm16, false)); | ||
69 | break; | ||
70 | case 2: | ||
71 | /* Hypervisor call (v7) */ | ||
72 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
73 | { | ||
74 | int imm8 = extract32(insn, 0, 8); | ||
75 | ARCH(5); | ||
76 | - gen_exception_bkpt_insn(s, 2, syn_aa32_bkpt(imm8, true)); | ||
77 | + gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm8, true)); | ||
78 | break; | ||
79 | } | ||
80 | 26 | ||
81 | -- | 27 | -- |
82 | 2.20.1 | 28 | 2.25.1 |
83 | 29 | ||
84 | 30 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Rotate is the more compact and obvious way to swap 16-bit | 3 | A common use case for the ASPEED machine is to boot a Linux kernel. |
4 | elements of a 32-bit word. | 4 | Provide a full example command line. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
7 | Message-id: 20190808202616.13782-6-richard.henderson@linaro.org | 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 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/translate.c | 6 +----- | 11 | docs/system/arm/aspeed.rst | 15 ++++++++++++--- |
12 | 1 file changed, 1 insertion(+), 5 deletions(-) | 12 | 1 file changed, 12 insertions(+), 3 deletions(-) |
13 | 13 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 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/target/arm/translate.c | 16 | --- a/docs/system/arm/aspeed.rst |
17 | +++ b/target/arm/translate.c | 17 | +++ b/docs/system/arm/aspeed.rst |
18 | @@ -XXX,XX +XXX,XX @@ static TCGv_i64 gen_muls_i64_i32(TCGv_i32 a, TCGv_i32 b) | 18 | @@ -XXX,XX +XXX,XX @@ Missing devices |
19 | /* Swap low and high halfwords. */ | 19 | Boot options |
20 | static void gen_swap_half(TCGv_i32 var) | 20 | ------------ |
21 | { | 21 | |
22 | - TCGv_i32 tmp = tcg_temp_new_i32(); | 22 | -The Aspeed machines can be started using the ``-kernel`` option to |
23 | - tcg_gen_shri_i32(tmp, var, 16); | 23 | -load a Linux kernel or from a firmware. Images can be downloaded from |
24 | - tcg_gen_shli_i32(var, var, 16); | 24 | -the OpenBMC jenkins : |
25 | - tcg_gen_or_i32(var, var, tmp); | 25 | +The Aspeed machines can be started using the ``-kernel`` and ``-dtb`` options |
26 | - tcg_temp_free_i32(tmp); | 26 | +to load a Linux kernel or from a firmware. Images can be downloaded from the |
27 | + tcg_gen_rotri_i32(var, var, 16); | 27 | +OpenBMC jenkins : |
28 | } | 28 | |
29 | 29 | https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/ | |
30 | /* Dual 16-bit add. Result placed in t0 and t1 is marked as dead. | 30 | |
31 | @@ -XXX,XX +XXX,XX @@ or directly from the OpenBMC GitHub release repository : | ||
32 | |||
33 | https://github.com/openbmc/openbmc/releases | ||
34 | |||
35 | +To boot a kernel directly from a Linux build tree: | ||
36 | + | ||
37 | +.. code-block:: bash | ||
38 | + | ||
39 | + $ qemu-system-arm -M ast2600-evb -nographic \ | ||
40 | + -kernel arch/arm/boot/zImage \ | ||
41 | + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ | ||
42 | + -initrd rootfs.cpio | ||
43 | + | ||
44 | The image should be attached as an MTD drive. Run : | ||
45 | |||
46 | .. code-block:: bash | ||
31 | -- | 47 | -- |
32 | 2.20.1 | 48 | 2.25.1 |
33 | 49 | ||
34 | 50 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Unless we're guaranteed to always increase ARM_MAX_VQ by a multiple of | 3 | Move it to the supported list. |
4 | four, then we should use DIV_ROUND_UP to ensure we get an appropriate | ||
5 | array size. | ||
6 | 4 | ||
7 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 5 | Signed-off-by: Joel Stanley <joel@jms.id.au> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Message-id: 20211117065752.330632-5-joel@jms.id.au |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | target/arm/cpu.h | 2 +- | 9 | docs/system/arm/aspeed.rst | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 11 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 12 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 14 | --- a/docs/system/arm/aspeed.rst |
17 | +++ b/target/arm/cpu.h | 15 | +++ b/docs/system/arm/aspeed.rst |
18 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVectorReg { | 16 | @@ -XXX,XX +XXX,XX @@ Supported devices |
19 | #ifdef TARGET_AARCH64 | 17 | * Front LEDs (PCA9552 on I2C bus) |
20 | /* In AArch32 mode, predicate registers do not exist at all. */ | 18 | * LPC Peripheral Controller (a subset of subdevices are supported) |
21 | typedef struct ARMPredicateReg { | 19 | * Hash/Crypto Engine (HACE) - Hash support only. TODO: HMAC and RSA |
22 | - uint64_t p[2 * ARM_MAX_VQ / 8] QEMU_ALIGNED(16); | 20 | + * ADC |
23 | + uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); | 21 | |
24 | } ARMPredicateReg; | 22 | |
25 | 23 | Missing devices | |
26 | /* In AArch32 mode, PAC keys do not exist at all. */ | 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 | ||
27 | -- | 31 | -- |
28 | 2.20.1 | 32 | 2.25.1 |
29 | 33 | ||
30 | 34 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Olivier Hériveaux <olivier.heriveaux@ledger.fr> |
---|---|---|---|
2 | 2 | ||
3 | The helper function is more documentary, and also already | 3 | Fix issue where the data register may be overwritten by next character |
4 | handles the case of rotate by zero. | 4 | reception before being read and returned. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Olivier Hériveaux <olivier.heriveaux@ledger.fr> |
7 | Message-id: 20190808202616.13782-5-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.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 | target/arm/translate.c | 7 ++----- | 12 | hw/char/stm32f2xx_usart.c | 3 ++- |
12 | 1 file changed, 2 insertions(+), 5 deletions(-) | 13 | 1 file changed, 2 insertions(+), 1 deletion(-) |
13 | 14 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.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/target/arm/translate.c | 17 | --- a/hw/char/stm32f2xx_usart.c |
17 | +++ b/target/arm/translate.c | 18 | +++ b/hw/char/stm32f2xx_usart.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 19 | @@ -XXX,XX +XXX,XX @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr, |
19 | /* CPSR = immediate */ | 20 | return retvalue; |
20 | val = insn & 0xff; | 21 | case USART_DR: |
21 | shift = ((insn >> 8) & 0xf) * 2; | 22 | DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr); |
22 | - if (shift) | 23 | + retvalue = s->usart_dr & 0x3FF; |
23 | - val = (val >> shift) | (val << (32 - shift)); | 24 | s->usart_sr &= ~USART_SR_RXNE; |
24 | + val = ror32(val, shift); | 25 | qemu_chr_fe_accept_input(&s->chr); |
25 | i = ((insn & (1 << 22)) != 0); | 26 | qemu_set_irq(s->irq, 0); |
26 | if (gen_set_psr_im(s, msr_mask(s, (insn >> 16) & 0xf, i), | 27 | - return s->usart_dr & 0x3FF; |
27 | i, val)) { | 28 | + return retvalue; |
28 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 29 | case USART_BRR: |
29 | /* immediate operand */ | 30 | return s->usart_brr; |
30 | val = insn & 0xff; | 31 | case USART_CR1: |
31 | shift = ((insn >> 8) & 0xf) * 2; | ||
32 | - if (shift) { | ||
33 | - val = (val >> shift) | (val << (32 - shift)); | ||
34 | - } | ||
35 | + val = ror32(val, shift); | ||
36 | tmp2 = tcg_temp_new_i32(); | ||
37 | tcg_gen_movi_i32(tmp2, val); | ||
38 | if (logic_cc && shift) { | ||
39 | -- | 32 | -- |
40 | 2.20.1 | 33 | 2.25.1 |
41 | 34 | ||
42 | 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 immediate shift generator functions already test for, | 3 | gicv3_set_gicv3state() is used by arm_gicv3_common.c in |
4 | and eliminate, the case of a shift by zero. | 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 | Message-id: 20190808202616.13782-4-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@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/translate.c | 19 +++++++------------ | 14 | hw/intc/arm_gicv3_cpuif.c | 10 +--------- |
12 | 1 file changed, 7 insertions(+), 12 deletions(-) | 15 | hw/intc/arm_gicv3_cpuif_common.c | 22 ++++++++++++++++++++++ |
16 | hw/intc/meson.build | 1 + | ||
17 | 3 files changed, 24 insertions(+), 9 deletions(-) | ||
18 | create mode 100644 hw/intc/arm_gicv3_cpuif_common.c | ||
13 | 19 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 20 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 22 | --- a/hw/intc/arm_gicv3_cpuif.c |
17 | +++ b/target/arm/translate.c | 23 | +++ b/hw/intc/arm_gicv3_cpuif.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 24 | @@ -XXX,XX +XXX,XX @@ |
19 | shift = (insn >> 10) & 3; | 25 | /* |
20 | /* ??? In many cases it's not necessary to do a | 26 | - * ARM Generic Interrupt Controller v3 |
21 | rotate, a shift is sufficient. */ | 27 | + * ARM Generic Interrupt Controller v3 (emulation) |
22 | - if (shift != 0) | 28 | * |
23 | - tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 29 | * Copyright (c) 2016 Linaro Limited |
24 | + tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 30 | * Written by Peter Maydell |
25 | op1 = (insn >> 20) & 7; | 31 | @@ -XXX,XX +XXX,XX @@ |
26 | switch (op1) { | 32 | #include "hw/irq.h" |
27 | case 0: gen_sxtb16(tmp); break; | 33 | #include "cpu.h" |
28 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 34 | |
29 | shift = (insn >> 4) & 3; | 35 | -void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) |
30 | /* ??? In many cases it's not necessary to do a | 36 | -{ |
31 | rotate, a shift is sufficient. */ | 37 | - ARMCPU *arm_cpu = ARM_CPU(cpu); |
32 | - if (shift != 0) | 38 | - CPUARMState *env = &arm_cpu->env; |
33 | - tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 39 | - |
34 | + tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 40 | - env->gicv3state = (void *)s; |
35 | op = (insn >> 20) & 7; | 41 | -}; |
36 | switch (op) { | 42 | - |
37 | case 0: gen_sxth(tmp); break; | 43 | static GICv3CPUState *icc_cs_from_env(CPUARMState *env) |
38 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 44 | { |
39 | case 7: | 45 | return env->gicv3state; |
40 | goto illegal_op; | 46 | diff --git a/hw/intc/arm_gicv3_cpuif_common.c b/hw/intc/arm_gicv3_cpuif_common.c |
41 | default: /* Saturate. */ | 47 | new file mode 100644 |
42 | - if (shift) { | 48 | index XXXXXXX..XXXXXXX |
43 | - if (op & 1) | 49 | --- /dev/null |
44 | - tcg_gen_sari_i32(tmp, tmp, shift); | 50 | +++ b/hw/intc/arm_gicv3_cpuif_common.c |
45 | - else | 51 | @@ -XXX,XX +XXX,XX @@ |
46 | - tcg_gen_shli_i32(tmp, tmp, shift); | 52 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
47 | + if (op & 1) { | 53 | +/* |
48 | + tcg_gen_sari_i32(tmp, tmp, shift); | 54 | + * ARM Generic Interrupt Controller v3 |
49 | + } else { | 55 | + * |
50 | + tcg_gen_shli_i32(tmp, tmp, shift); | 56 | + * Copyright (c) 2016 Linaro Limited |
51 | } | 57 | + * Written by Peter Maydell |
52 | tmp2 = tcg_const_i32(imm); | 58 | + * |
53 | if (op & 4) { | 59 | + * This code is licensed under the GPL, version 2 or (at your option) |
54 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 60 | + * any later version. |
55 | goto illegal_op; | 61 | + */ |
56 | } | 62 | + |
57 | tmp = load_reg(s, rm); | 63 | +#include "qemu/osdep.h" |
58 | - if (shift) { | 64 | +#include "gicv3_internal.h" |
59 | - tcg_gen_shli_i32(tmp, tmp, shift); | 65 | +#include "cpu.h" |
60 | - } | 66 | + |
61 | + tcg_gen_shli_i32(tmp, tmp, shift); | 67 | +void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) |
62 | tcg_gen_add_i32(addr, addr, tmp); | 68 | +{ |
63 | tcg_temp_free_i32(tmp); | 69 | + ARMCPU *arm_cpu = ARM_CPU(cpu); |
64 | break; | 70 | + CPUARMState *env = &arm_cpu->env; |
71 | + | ||
72 | + env->gicv3state = (void *)s; | ||
73 | +}; | ||
74 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/hw/intc/meson.build | ||
77 | +++ b/hw/intc/meson.build | ||
78 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-pmu-iomod-in | ||
79 | |||
80 | specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) | ||
81 | specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) | ||
82 | +specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) | ||
83 | specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif.c')) | ||
84 | specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c')) | ||
85 | specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: files('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) | ||
65 | -- | 86 | -- |
66 | 2.20.1 | 87 | 2.25.1 |
67 | 88 | ||
68 | 89 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Use deposit as the composit operation to merge the | 3 | The TYPE_ARM_GICV3 device is an emulated one. When using |
4 | bits from the two inputs. | 4 | KVM, it is recommended to use the TYPE_KVM_ARM_GICV3 device |
5 | (which uses in-kernel support). | ||
5 | 6 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | When using --with-devices-FOO, it is possible to build a |
7 | Message-id: 20190808202616.13782-3-richard.henderson@linaro.org | 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> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Message-id: 20211115223619.2599282-3-philmd@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 20 | --- |
11 | target/arm/translate.c | 26 ++++++++++---------------- | 21 | hw/intc/arm_gicv3.c | 2 +- |
12 | 1 file changed, 10 insertions(+), 16 deletions(-) | 22 | hw/intc/Kconfig | 5 +++++ |
23 | hw/intc/meson.build | 10 ++++++---- | ||
24 | 3 files changed, 12 insertions(+), 5 deletions(-) | ||
13 | 25 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 26 | diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c |
15 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 28 | --- a/hw/intc/arm_gicv3.c |
17 | +++ b/target/arm/translate.c | 29 | +++ b/hw/intc/arm_gicv3.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 30 | @@ -XXX,XX +XXX,XX @@ |
19 | shift = (insn >> 7) & 0x1f; | 31 | /* |
20 | if (insn & (1 << 6)) { | 32 | - * ARM Generic Interrupt Controller v3 |
21 | /* pkhtb */ | 33 | + * ARM Generic Interrupt Controller v3 (emulation) |
22 | - if (shift == 0) | 34 | * |
23 | + if (shift == 0) { | 35 | * Copyright (c) 2015 Huawei. |
24 | shift = 31; | 36 | * Copyright (c) 2016 Linaro Limited |
25 | + } | 37 | diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig |
26 | tcg_gen_sari_i32(tmp2, tmp2, shift); | 38 | index XXXXXXX..XXXXXXX 100644 |
27 | - tcg_gen_andi_i32(tmp, tmp, 0xffff0000); | 39 | --- a/hw/intc/Kconfig |
28 | - tcg_gen_ext16u_i32(tmp2, tmp2); | 40 | +++ b/hw/intc/Kconfig |
29 | + tcg_gen_deposit_i32(tmp, tmp, tmp2, 0, 16); | 41 | @@ -XXX,XX +XXX,XX @@ config APIC |
30 | } else { | 42 | select MSI_NONBROKEN |
31 | /* pkhbt */ | 43 | select I8259 |
32 | - if (shift) | 44 | |
33 | - tcg_gen_shli_i32(tmp2, tmp2, shift); | 45 | +config ARM_GIC_TCG |
34 | - tcg_gen_ext16u_i32(tmp, tmp); | 46 | + bool |
35 | - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); | 47 | + default y |
36 | + tcg_gen_shli_i32(tmp2, tmp2, shift); | 48 | + depends on ARM_GIC && TCG |
37 | + tcg_gen_deposit_i32(tmp, tmp2, tmp, 0, 16); | 49 | + |
38 | } | 50 | config ARM_GIC_KVM |
39 | - tcg_gen_or_i32(tmp, tmp, tmp2); | 51 | bool |
40 | tcg_temp_free_i32(tmp2); | 52 | default y |
41 | store_reg(s, rd, tmp); | 53 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build |
42 | } else if ((insn & 0x00200020) == 0x00200000) { | 54 | index XXXXXXX..XXXXXXX 100644 |
43 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 55 | --- a/hw/intc/meson.build |
44 | shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); | 56 | +++ b/hw/intc/meson.build |
45 | if (insn & (1 << 5)) { | 57 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARM_GIC', if_true: files( |
46 | /* pkhtb */ | 58 | 'arm_gic.c', |
47 | - if (shift == 0) | 59 | 'arm_gic_common.c', |
48 | + if (shift == 0) { | 60 | 'arm_gicv2m.c', |
49 | shift = 31; | 61 | - 'arm_gicv3.c', |
50 | + } | 62 | 'arm_gicv3_common.c', |
51 | tcg_gen_sari_i32(tmp2, tmp2, shift); | 63 | - 'arm_gicv3_dist.c', |
52 | - tcg_gen_andi_i32(tmp, tmp, 0xffff0000); | 64 | 'arm_gicv3_its_common.c', |
53 | - tcg_gen_ext16u_i32(tmp2, tmp2); | 65 | - 'arm_gicv3_redist.c', |
54 | + tcg_gen_deposit_i32(tmp, tmp, tmp2, 0, 16); | 66 | +)) |
55 | } else { | 67 | +softmmu_ss.add(when: 'CONFIG_ARM_GIC_TCG', if_true: files( |
56 | /* pkhbt */ | 68 | + 'arm_gicv3.c', |
57 | - if (shift) | 69 | + 'arm_gicv3_dist.c', |
58 | - tcg_gen_shli_i32(tmp2, tmp2, shift); | 70 | 'arm_gicv3_its.c', |
59 | - tcg_gen_ext16u_i32(tmp, tmp); | 71 | + 'arm_gicv3_redist.c', |
60 | - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); | 72 | )) |
61 | + tcg_gen_shli_i32(tmp2, tmp2, shift); | 73 | softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_pic.c')) |
62 | + tcg_gen_deposit_i32(tmp, tmp2, tmp, 0, 16); | 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 | - tcg_gen_or_i32(tmp, tmp, tmp2); | 76 | specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) |
65 | tcg_temp_free_i32(tmp2); | 77 | specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) |
66 | store_reg(s, rd, tmp); | 78 | specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) |
67 | } else { | 79 | -specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif.c')) |
80 | +specific_ss.add(when: 'CONFIG_ARM_GIC_TCG', if_true: files('arm_gicv3_cpuif.c')) | ||
81 | specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c')) | ||
82 | specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: files('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) | ||
83 | specific_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c')) | ||
68 | -- | 84 | -- |
69 | 2.20.1 | 85 | 2.25.1 |
70 | 86 | ||
71 | 87 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | |||
3 | The offset is variable depending on the instruction set. | ||
4 | Passing in the actual value is clearer in intent. | ||
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 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-9-richard.henderson@linaro.org | ||
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/translate-a64.c | 8 ++++---- | 7 | target/arm/translate-a64.c | 7 ++++--- |
13 | target/arm/translate.c | 8 ++++---- | 8 | 1 file changed, 4 insertions(+), 3 deletions(-) |
14 | 2 files changed, 8 insertions(+), 8 deletions(-) | ||
15 | 9 | ||
16 | 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 |
17 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 12 | --- a/target/arm/translate-a64.c |
19 | +++ b/target/arm/translate-a64.c | 13 | +++ b/target/arm/translate-a64.c |
20 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | 14 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
21 | tcg_temp_free_i32(tcg_excp); | ||
22 | } | ||
23 | |||
24 | -static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
25 | +static void gen_exception_internal_insn(DisasContext *s, uint64_t pc, int excp) | ||
26 | { | 15 | { |
27 | - gen_a64_set_pc_im(s->base.pc_next - offset); | 16 | DisasContext *s = container_of(dcbase, DisasContext, base); |
28 | + gen_a64_set_pc_im(pc); | 17 | CPUARMState *env = cpu->env_ptr; |
29 | gen_exception_internal(excp); | 18 | + uint64_t pc = s->base.pc_next; |
30 | s->base.is_jmp = DISAS_NORETURN; | 19 | uint32_t insn; |
31 | } | 20 | |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | 21 | if (s->ss_active && !s->pstate_ss) { |
33 | break; | 22 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
34 | } | ||
35 | #endif | ||
36 | - gen_exception_internal_insn(s, 0, EXCP_SEMIHOST); | ||
37 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | ||
38 | } else { | ||
39 | unsupported_encoding(s, insn); | ||
40 | } | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
42 | /* End the TB early; it likely won't be executed */ | ||
43 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
44 | } else { | ||
45 | - gen_exception_internal_insn(dc, 0, EXCP_DEBUG); | ||
46 | + gen_exception_internal_insn(dc, dc->base.pc_next, EXCP_DEBUG); | ||
47 | /* The address covered by the breakpoint must be | ||
48 | included in [tb->pc, tb->pc + tb->size) in order | ||
49 | to for it to be properly cleared -- thus we | ||
50 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/translate.c | ||
53 | +++ b/target/arm/translate.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | ||
55 | s->base.is_jmp = DISAS_SMC; | ||
56 | } | ||
57 | |||
58 | -static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
59 | +static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp) | ||
60 | { | ||
61 | gen_set_condexec(s); | ||
62 | - gen_set_pc_im(s, s->base.pc_next - offset); | ||
63 | + gen_set_pc_im(s, pc); | ||
64 | gen_exception_internal(excp); | ||
65 | s->base.is_jmp = DISAS_NORETURN; | ||
66 | } | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | ||
68 | s->current_el != 0 && | ||
69 | #endif | ||
70 | (imm == (s->thumb ? 0x3c : 0xf000))) { | ||
71 | - gen_exception_internal_insn(s, 0, EXCP_SEMIHOST); | ||
72 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | ||
73 | return; | 23 | return; |
74 | } | 24 | } |
75 | 25 | ||
76 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | 26 | - s->pc_curr = s->base.pc_next; |
77 | /* End the TB early; it's likely not going to be executed */ | 27 | - insn = arm_ldl_code(env, &s->base, s->base.pc_next, s->sctlr_b); |
78 | dc->base.is_jmp = DISAS_TOO_MANY; | 28 | + s->pc_curr = pc; |
79 | } else { | 29 | + insn = arm_ldl_code(env, &s->base, pc, s->sctlr_b); |
80 | - gen_exception_internal_insn(dc, 0, EXCP_DEBUG); | 30 | s->insn = insn; |
81 | + gen_exception_internal_insn(dc, dc->base.pc_next, EXCP_DEBUG); | 31 | - s->base.pc_next += 4; |
82 | /* The address covered by the breakpoint must be | 32 | + s->base.pc_next = pc + 4; |
83 | included in [tb->pc, tb->pc + tb->size) in order | 33 | |
84 | to for it to be properly cleared -- thus we | 34 | s->fp_access_checked = false; |
35 | s->sve_access_checked = false; | ||
85 | -- | 36 | -- |
86 | 2.20.1 | 37 | 2.25.1 |
87 | 38 | ||
88 | 39 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | |||
3 | We must update s->base.pc_next when we return from the translate_insn | ||
4 | hook to the main translator loop. By incrementing s->base.pc_next | ||
5 | immediately after reading the insn word, "pc_next" contains the address | ||
6 | of the next instruction throughout translation. | ||
7 | |||
8 | All remaining uses of s->pc are referencing the address of the next insn, | ||
9 | so this is now a simple global replacement. Remove the "s->pc" field. | ||
10 | 2 | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Message-id: 20190807045335.1361-7-richard.henderson@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 6 | --- |
17 | target/arm/translate.h | 1 - | 7 | target/arm/translate.c | 9 +++++---- |
18 | target/arm/translate-a64.c | 51 +++++++++--------- | 8 | 1 file changed, 5 insertions(+), 4 deletions(-) |
19 | target/arm/translate.c | 103 ++++++++++++++++++------------------- | ||
20 | 3 files changed, 72 insertions(+), 83 deletions(-) | ||
21 | 9 | ||
22 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/translate.h | ||
25 | +++ b/target/arm/translate.h | ||
26 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
27 | DisasContextBase base; | ||
28 | const ARMISARegisters *isar; | ||
29 | |||
30 | - target_ulong pc; | ||
31 | /* The address of the current instruction being translated. */ | ||
32 | target_ulong pc_curr; | ||
33 | target_ulong page_start; | ||
34 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/translate-a64.c | ||
37 | +++ b/target/arm/translate-a64.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | ||
39 | |||
40 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
41 | { | ||
42 | - gen_a64_set_pc_im(s->pc - offset); | ||
43 | + gen_a64_set_pc_im(s->base.pc_next - offset); | ||
44 | gen_exception_internal(excp); | ||
45 | s->base.is_jmp = DISAS_NORETURN; | ||
46 | } | ||
47 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
48 | static void gen_exception_insn(DisasContext *s, int offset, int excp, | ||
49 | uint32_t syndrome, uint32_t target_el) | ||
50 | { | ||
51 | - gen_a64_set_pc_im(s->pc - offset); | ||
52 | + gen_a64_set_pc_im(s->base.pc_next - offset); | ||
53 | gen_exception(excp, syndrome, target_el); | ||
54 | s->base.is_jmp = DISAS_NORETURN; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, | ||
57 | { | ||
58 | TCGv_i32 tcg_syn; | ||
59 | |||
60 | - gen_a64_set_pc_im(s->pc - offset); | ||
61 | + gen_a64_set_pc_im(s->base.pc_next - offset); | ||
62 | tcg_syn = tcg_const_i32(syndrome); | ||
63 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
64 | tcg_temp_free_i32(tcg_syn); | ||
65 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) | ||
66 | |||
67 | if (insn & (1U << 31)) { | ||
68 | /* BL Branch with link */ | ||
69 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
70 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | ||
71 | } | ||
72 | |||
73 | /* B Branch / BL Branch with link */ | ||
74 | @@ -XXX,XX +XXX,XX @@ static void disas_comp_b_imm(DisasContext *s, uint32_t insn) | ||
75 | tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | ||
76 | tcg_cmp, 0, label_match); | ||
77 | |||
78 | - gen_goto_tb(s, 0, s->pc); | ||
79 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
80 | gen_set_label(label_match); | ||
81 | gen_goto_tb(s, 1, addr); | ||
82 | } | ||
83 | @@ -XXX,XX +XXX,XX @@ static void disas_test_b_imm(DisasContext *s, uint32_t insn) | ||
84 | tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | ||
85 | tcg_cmp, 0, label_match); | ||
86 | tcg_temp_free_i64(tcg_cmp); | ||
87 | - gen_goto_tb(s, 0, s->pc); | ||
88 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
89 | gen_set_label(label_match); | ||
90 | gen_goto_tb(s, 1, addr); | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ static void disas_cond_b_imm(DisasContext *s, uint32_t insn) | ||
93 | /* genuinely conditional branches */ | ||
94 | TCGLabel *label_match = gen_new_label(); | ||
95 | arm_gen_test_cc(cond, label_match); | ||
96 | - gen_goto_tb(s, 0, s->pc); | ||
97 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
98 | gen_set_label(label_match); | ||
99 | gen_goto_tb(s, 1, addr); | ||
100 | } else { | ||
101 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | ||
102 | * any pending interrupts immediately. | ||
103 | */ | ||
104 | reset_btype(s); | ||
105 | - gen_goto_tb(s, 0, s->pc); | ||
106 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
107 | return; | ||
108 | |||
109 | case 7: /* SB */ | ||
110 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | ||
111 | * MB and end the TB instead. | ||
112 | */ | ||
113 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
114 | - gen_goto_tb(s, 0, s->pc); | ||
115 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
116 | return; | ||
117 | |||
118 | default: | ||
119 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
120 | gen_a64_set_pc(s, dst); | ||
121 | /* BLR also needs to load return address */ | ||
122 | if (opc == 1) { | ||
123 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
124 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | ||
125 | } | ||
126 | break; | ||
127 | |||
128 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
129 | gen_a64_set_pc(s, dst); | ||
130 | /* BLRAA also needs to load return address */ | ||
131 | if (opc == 9) { | ||
132 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
133 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | ||
134 | } | ||
135 | break; | ||
136 | |||
137 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
138 | { | ||
139 | uint32_t insn; | ||
140 | |||
141 | - s->pc_curr = s->pc; | ||
142 | - insn = arm_ldl_code(env, s->pc, s->sctlr_b); | ||
143 | + s->pc_curr = s->base.pc_next; | ||
144 | + insn = arm_ldl_code(env, s->base.pc_next, s->sctlr_b); | ||
145 | s->insn = insn; | ||
146 | - s->pc += 4; | ||
147 | + s->base.pc_next += 4; | ||
148 | |||
149 | s->fp_access_checked = false; | ||
150 | |||
151 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
152 | int bound, core_mmu_idx; | ||
153 | |||
154 | dc->isar = &arm_cpu->isar; | ||
155 | - dc->pc = dc->base.pc_first; | ||
156 | dc->condjmp = 0; | ||
157 | |||
158 | dc->aarch64 = 1; | ||
159 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | ||
160 | { | ||
161 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
162 | |||
163 | - tcg_gen_insn_start(dc->pc, 0, 0); | ||
164 | + tcg_gen_insn_start(dc->base.pc_next, 0, 0); | ||
165 | dc->insn_start = tcg_last_op(); | ||
166 | } | ||
167 | |||
168 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
169 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
170 | |||
171 | if (bp->flags & BP_CPU) { | ||
172 | - gen_a64_set_pc_im(dc->pc); | ||
173 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
174 | gen_helper_check_breakpoints(cpu_env); | ||
175 | /* End the TB early; it likely won't be executed */ | ||
176 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
177 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
178 | to for it to be properly cleared -- thus we | ||
179 | increment the PC here so that the logic setting | ||
180 | tb->size below does the right thing. */ | ||
181 | - dc->pc += 4; | ||
182 | + dc->base.pc_next += 4; | ||
183 | dc->base.is_jmp = DISAS_NORETURN; | ||
184 | } | ||
185 | |||
186 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
187 | disas_a64_insn(env, dc); | ||
188 | } | ||
189 | |||
190 | - dc->base.pc_next = dc->pc; | ||
191 | translator_loop_temp_check(&dc->base); | ||
192 | } | ||
193 | |||
194 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
195 | */ | ||
196 | switch (dc->base.is_jmp) { | ||
197 | default: | ||
198 | - gen_a64_set_pc_im(dc->pc); | ||
199 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
200 | /* fall through */ | ||
201 | case DISAS_EXIT: | ||
202 | case DISAS_JUMP: | ||
203 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
204 | switch (dc->base.is_jmp) { | ||
205 | case DISAS_NEXT: | ||
206 | case DISAS_TOO_MANY: | ||
207 | - gen_goto_tb(dc, 1, dc->pc); | ||
208 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
209 | break; | ||
210 | default: | ||
211 | case DISAS_UPDATE: | ||
212 | - gen_a64_set_pc_im(dc->pc); | ||
213 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
214 | /* fall through */ | ||
215 | case DISAS_EXIT: | ||
216 | tcg_gen_exit_tb(NULL, 0); | ||
217 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
218 | case DISAS_SWI: | ||
219 | break; | ||
220 | case DISAS_WFE: | ||
221 | - gen_a64_set_pc_im(dc->pc); | ||
222 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
223 | gen_helper_wfe(cpu_env); | ||
224 | break; | ||
225 | case DISAS_YIELD: | ||
226 | - gen_a64_set_pc_im(dc->pc); | ||
227 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
228 | gen_helper_yield(cpu_env); | ||
229 | break; | ||
230 | case DISAS_WFI: | ||
231 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
232 | */ | ||
233 | TCGv_i32 tmp = tcg_const_i32(4); | ||
234 | |||
235 | - gen_a64_set_pc_im(dc->pc); | ||
236 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
237 | gen_helper_wfi(cpu_env, tmp); | ||
238 | tcg_temp_free_i32(tmp); | ||
239 | /* The helper doesn't necessarily throw an exception, but we | ||
240 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | - | ||
245 | - /* Functions above can change dc->pc, so re-align db->pc_next */ | ||
246 | - dc->base.pc_next = dc->pc; | ||
247 | } | ||
248 | |||
249 | static void aarch64_tr_disas_log(const DisasContextBase *dcbase, | ||
250 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 10 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
251 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
252 | --- a/target/arm/translate.c | 12 | --- a/target/arm/translate.c |
253 | +++ b/target/arm/translate.c | 13 | +++ b/target/arm/translate.c |
254 | @@ -XXX,XX +XXX,XX @@ static inline void gen_blxns(DisasContext *s, int rm) | 14 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
255 | * We do however need to set the PC, because the blxns helper reads it. | ||
256 | * The blxns helper may throw an exception. | ||
257 | */ | ||
258 | - gen_set_pc_im(s, s->pc); | ||
259 | + gen_set_pc_im(s, s->base.pc_next); | ||
260 | gen_helper_v7m_blxns(cpu_env, var); | ||
261 | tcg_temp_free_i32(var); | ||
262 | s->base.is_jmp = DISAS_EXIT; | ||
263 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hvc(DisasContext *s, int imm16) | ||
264 | * for single stepping.) | ||
265 | */ | ||
266 | s->svc_imm = imm16; | ||
267 | - gen_set_pc_im(s, s->pc); | ||
268 | + gen_set_pc_im(s, s->base.pc_next); | ||
269 | s->base.is_jmp = DISAS_HVC; | ||
270 | } | ||
271 | |||
272 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | ||
273 | tmp = tcg_const_i32(syn_aa32_smc()); | ||
274 | gen_helper_pre_smc(cpu_env, tmp); | ||
275 | tcg_temp_free_i32(tmp); | ||
276 | - gen_set_pc_im(s, s->pc); | ||
277 | + gen_set_pc_im(s, s->base.pc_next); | ||
278 | s->base.is_jmp = DISAS_SMC; | ||
279 | } | ||
280 | |||
281 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
282 | { | ||
283 | gen_set_condexec(s); | ||
284 | - gen_set_pc_im(s, s->pc - offset); | ||
285 | + gen_set_pc_im(s, s->base.pc_next - offset); | ||
286 | gen_exception_internal(excp); | ||
287 | s->base.is_jmp = DISAS_NORETURN; | ||
288 | } | ||
289 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, int offset, int excp, | ||
290 | int syn, uint32_t target_el) | ||
291 | { | ||
292 | gen_set_condexec(s); | ||
293 | - gen_set_pc_im(s, s->pc - offset); | ||
294 | + gen_set_pc_im(s, s->base.pc_next - offset); | ||
295 | gen_exception(excp, syn, target_el); | ||
296 | s->base.is_jmp = DISAS_NORETURN; | ||
297 | } | ||
298 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | ||
299 | TCGv_i32 tcg_syn; | ||
300 | |||
301 | gen_set_condexec(s); | ||
302 | - gen_set_pc_im(s, s->pc - offset); | ||
303 | + gen_set_pc_im(s, s->base.pc_next - offset); | ||
304 | tcg_syn = tcg_const_i32(syn); | ||
305 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
306 | tcg_temp_free_i32(tcg_syn); | ||
307 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | ||
308 | /* Force a TB lookup after an instruction that changes the CPU state. */ | ||
309 | static inline void gen_lookup_tb(DisasContext *s) | ||
310 | { | ||
311 | - tcg_gen_movi_i32(cpu_R[15], s->pc); | ||
312 | + tcg_gen_movi_i32(cpu_R[15], s->base.pc_next); | ||
313 | s->base.is_jmp = DISAS_EXIT; | ||
314 | } | ||
315 | |||
316 | @@ -XXX,XX +XXX,XX @@ static inline bool use_goto_tb(DisasContext *s, target_ulong dest) | ||
317 | { | ||
318 | #ifndef CONFIG_USER_ONLY | ||
319 | return (s->base.tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) || | ||
320 | - ((s->pc - 1) & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK); | ||
321 | + ((s->base.pc_next - 1) & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK); | ||
322 | #else | ||
323 | return true; | ||
324 | #endif | ||
325 | @@ -XXX,XX +XXX,XX @@ static void gen_nop_hint(DisasContext *s, int val) | ||
326 | */ | ||
327 | case 1: /* yield */ | ||
328 | if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
329 | - gen_set_pc_im(s, s->pc); | ||
330 | + gen_set_pc_im(s, s->base.pc_next); | ||
331 | s->base.is_jmp = DISAS_YIELD; | ||
332 | } | ||
333 | break; | ||
334 | case 3: /* wfi */ | ||
335 | - gen_set_pc_im(s, s->pc); | ||
336 | + gen_set_pc_im(s, s->base.pc_next); | ||
337 | s->base.is_jmp = DISAS_WFI; | ||
338 | break; | ||
339 | case 2: /* wfe */ | ||
340 | if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
341 | - gen_set_pc_im(s, s->pc); | ||
342 | + gen_set_pc_im(s, s->base.pc_next); | ||
343 | s->base.is_jmp = DISAS_WFE; | ||
344 | } | ||
345 | break; | ||
346 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
347 | if (isread) { | ||
348 | return 1; | ||
349 | } | ||
350 | - gen_set_pc_im(s, s->pc); | ||
351 | + gen_set_pc_im(s, s->base.pc_next); | ||
352 | s->base.is_jmp = DISAS_WFI; | ||
353 | return 0; | ||
354 | default: | ||
355 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
356 | * self-modifying code correctly and also to take | ||
357 | * any pending interrupts immediately. | ||
358 | */ | ||
359 | - gen_goto_tb(s, 0, s->pc); | ||
360 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
361 | return; | ||
362 | case 7: /* sb */ | ||
363 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | ||
364 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
365 | * for TCG; MB and end the TB instead. | ||
366 | */ | ||
367 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
368 | - gen_goto_tb(s, 0, s->pc); | ||
369 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
370 | return; | ||
371 | default: | ||
372 | goto illegal_op; | ||
373 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
374 | int32_t offset; | ||
375 | |||
376 | tmp = tcg_temp_new_i32(); | ||
377 | - tcg_gen_movi_i32(tmp, s->pc); | ||
378 | + tcg_gen_movi_i32(tmp, s->base.pc_next); | ||
379 | store_reg(s, 14, tmp); | ||
380 | /* Sign-extend the 24-bit offset */ | ||
381 | offset = (((int32_t)insn) << 8) >> 8; | ||
382 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
383 | /* branch link/exchange thumb (blx) */ | ||
384 | tmp = load_reg(s, rm); | ||
385 | tmp2 = tcg_temp_new_i32(); | ||
386 | - tcg_gen_movi_i32(tmp2, s->pc); | ||
387 | + tcg_gen_movi_i32(tmp2, s->base.pc_next); | ||
388 | store_reg(s, 14, tmp2); | ||
389 | gen_bx(s, tmp); | ||
390 | break; | ||
391 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
392 | /* branch (and link) */ | ||
393 | if (insn & (1 << 24)) { | ||
394 | tmp = tcg_temp_new_i32(); | ||
395 | - tcg_gen_movi_i32(tmp, s->pc); | ||
396 | + tcg_gen_movi_i32(tmp, s->base.pc_next); | ||
397 | store_reg(s, 14, tmp); | ||
398 | } | ||
399 | offset = sextract32(insn << 2, 0, 26); | ||
400 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
401 | break; | ||
402 | case 0xf: | ||
403 | /* swi */ | ||
404 | - gen_set_pc_im(s, s->pc); | ||
405 | + gen_set_pc_im(s, s->base.pc_next); | ||
406 | s->svc_imm = extract32(insn, 0, 24); | ||
407 | s->base.is_jmp = DISAS_SWI; | ||
408 | break; | ||
409 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
410 | |||
411 | if (insn & (1 << 14)) { | ||
412 | /* Branch and link. */ | ||
413 | - tcg_gen_movi_i32(cpu_R[14], s->pc | 1); | ||
414 | + tcg_gen_movi_i32(cpu_R[14], s->base.pc_next | 1); | ||
415 | } | ||
416 | |||
417 | offset += read_pc(s); | ||
418 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
419 | * and also to take any pending interrupts | ||
420 | * immediately. | ||
421 | */ | ||
422 | - gen_goto_tb(s, 0, s->pc); | ||
423 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
424 | break; | ||
425 | case 7: /* sb */ | ||
426 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | ||
427 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
428 | * for TCG; MB and end the TB instead. | ||
429 | */ | ||
430 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
431 | - gen_goto_tb(s, 0, s->pc); | ||
432 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
433 | break; | ||
434 | default: | ||
435 | goto illegal_op; | ||
436 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
437 | /* BLX/BX */ | ||
438 | tmp = load_reg(s, rm); | ||
439 | if (link) { | ||
440 | - val = (uint32_t)s->pc | 1; | ||
441 | + val = (uint32_t)s->base.pc_next | 1; | ||
442 | tmp2 = tcg_temp_new_i32(); | ||
443 | tcg_gen_movi_i32(tmp2, val); | ||
444 | store_reg(s, 14, tmp2); | ||
445 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
446 | |||
447 | if (cond == 0xf) { | ||
448 | /* swi */ | ||
449 | - gen_set_pc_im(s, s->pc); | ||
450 | + gen_set_pc_im(s, s->base.pc_next); | ||
451 | s->svc_imm = extract32(insn, 0, 8); | ||
452 | s->base.is_jmp = DISAS_SWI; | ||
453 | break; | ||
454 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
455 | tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); | ||
456 | |||
457 | tmp2 = tcg_temp_new_i32(); | ||
458 | - tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
459 | + tcg_gen_movi_i32(tmp2, s->base.pc_next | 1); | ||
460 | store_reg(s, 14, tmp2); | ||
461 | gen_bx(s, tmp); | ||
462 | break; | ||
463 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
464 | tcg_gen_addi_i32(tmp, tmp, offset); | ||
465 | |||
466 | tmp2 = tcg_temp_new_i32(); | ||
467 | - tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
468 | + tcg_gen_movi_i32(tmp2, s->base.pc_next | 1); | ||
469 | store_reg(s, 14, tmp2); | ||
470 | gen_bx(s, tmp); | ||
471 | } else { | ||
472 | @@ -XXX,XX +XXX,XX @@ undef: | ||
473 | |||
474 | static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | ||
475 | { | ||
476 | - /* Return true if the insn at dc->pc might cross a page boundary. | ||
477 | + /* Return true if the insn at dc->base.pc_next might cross a page boundary. | ||
478 | * (False positives are OK, false negatives are not.) | ||
479 | * We know this is a Thumb insn, and our caller ensures we are | ||
480 | - * only called if dc->pc is less than 4 bytes from the page | ||
481 | + * only called if dc->base.pc_next is less than 4 bytes from the page | ||
482 | * boundary, so we cross the page if the first 16 bits indicate | ||
483 | * that this is a 32 bit insn. | ||
484 | */ | ||
485 | - uint16_t insn = arm_lduw_code(env, s->pc, s->sctlr_b); | ||
486 | + uint16_t insn = arm_lduw_code(env, s->base.pc_next, s->sctlr_b); | ||
487 | |||
488 | - return !thumb_insn_is_16bit(s, s->pc, insn); | ||
489 | + return !thumb_insn_is_16bit(s, s->base.pc_next, insn); | ||
490 | } | ||
491 | |||
492 | static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
493 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
494 | uint32_t condexec, core_mmu_idx; | ||
495 | |||
496 | dc->isar = &cpu->isar; | ||
497 | - dc->pc = dc->base.pc_first; | ||
498 | dc->condjmp = 0; | ||
499 | |||
500 | dc->aarch64 = 0; | ||
501 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | ||
502 | { | 15 | { |
503 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 16 | DisasContext *dc = container_of(dcbase, DisasContext, base); |
504 | 17 | CPUARMState *env = cpu->env_ptr; | |
505 | - tcg_gen_insn_start(dc->pc, | 18 | + uint32_t pc = dc->base.pc_next; |
506 | + tcg_gen_insn_start(dc->base.pc_next, | 19 | unsigned int insn; |
507 | (dc->condexec_cond << 4) | (dc->condexec_mask >> 1), | 20 | |
508 | 0); | 21 | if (arm_pre_translate_insn(dc)) { |
509 | dc->insn_start = tcg_last_op(); | 22 | - dc->base.pc_next += 4; |
510 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | 23 | + dc->base.pc_next = pc + 4; |
511 | |||
512 | if (bp->flags & BP_CPU) { | ||
513 | gen_set_condexec(dc); | ||
514 | - gen_set_pc_im(dc, dc->pc); | ||
515 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
516 | gen_helper_check_breakpoints(cpu_env); | ||
517 | /* End the TB early; it's likely not going to be executed */ | ||
518 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
519 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
520 | tb->size below does the right thing. */ | ||
521 | /* TODO: Advance PC by correct instruction length to | ||
522 | * avoid disassembler error messages */ | ||
523 | - dc->pc += 2; | ||
524 | + dc->base.pc_next += 2; | ||
525 | dc->base.is_jmp = DISAS_NORETURN; | ||
526 | } | ||
527 | |||
528 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) | ||
529 | { | ||
530 | #ifdef CONFIG_USER_ONLY | ||
531 | /* Intercept jump to the magic kernel page. */ | ||
532 | - if (dc->pc >= 0xffff0000) { | ||
533 | + if (dc->base.pc_next >= 0xffff0000) { | ||
534 | /* We always get here via a jump, so know we are not in a | ||
535 | conditional execution block. */ | ||
536 | gen_exception_internal(EXCP_KERNEL_TRAP); | ||
537 | @@ -XXX,XX +XXX,XX @@ static void arm_post_translate_insn(DisasContext *dc) | ||
538 | gen_set_label(dc->condlabel); | ||
539 | dc->condjmp = 0; | ||
540 | } | ||
541 | - dc->base.pc_next = dc->pc; | ||
542 | translator_loop_temp_check(&dc->base); | ||
543 | } | ||
544 | |||
545 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
546 | return; | 24 | return; |
547 | } | 25 | } |
548 | 26 | ||
549 | - dc->pc_curr = dc->pc; | 27 | - dc->pc_curr = dc->base.pc_next; |
550 | - insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); | 28 | - insn = arm_ldl_code(env, &dc->base, dc->base.pc_next, dc->sctlr_b); |
551 | + dc->pc_curr = dc->base.pc_next; | 29 | + dc->pc_curr = pc; |
552 | + insn = arm_ldl_code(env, dc->base.pc_next, dc->sctlr_b); | 30 | + insn = arm_ldl_code(env, &dc->base, pc, dc->sctlr_b); |
553 | dc->insn = insn; | 31 | dc->insn = insn; |
554 | - dc->pc += 4; | 32 | - dc->base.pc_next += 4; |
555 | + dc->base.pc_next += 4; | 33 | + dc->base.pc_next = pc + 4; |
556 | disas_arm_insn(dc, insn); | 34 | disas_arm_insn(dc, insn); |
557 | 35 | ||
558 | arm_post_translate_insn(dc); | 36 | arm_post_translate_insn(dc); |
559 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
560 | return; | ||
561 | } | ||
562 | |||
563 | - dc->pc_curr = dc->pc; | ||
564 | - insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
565 | - is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | ||
566 | - dc->pc += 2; | ||
567 | + dc->pc_curr = dc->base.pc_next; | ||
568 | + insn = arm_lduw_code(env, dc->base.pc_next, dc->sctlr_b); | ||
569 | + is_16bit = thumb_insn_is_16bit(dc, dc->base.pc_next, insn); | ||
570 | + dc->base.pc_next += 2; | ||
571 | if (!is_16bit) { | ||
572 | - uint32_t insn2 = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
573 | + uint32_t insn2 = arm_lduw_code(env, dc->base.pc_next, dc->sctlr_b); | ||
574 | |||
575 | insn = insn << 16 | insn2; | ||
576 | - dc->pc += 2; | ||
577 | + dc->base.pc_next += 2; | ||
578 | } | ||
579 | dc->insn = insn; | ||
580 | |||
581 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
582 | * but isn't very efficient). | ||
583 | */ | ||
584 | if (dc->base.is_jmp == DISAS_NEXT | ||
585 | - && (dc->pc - dc->page_start >= TARGET_PAGE_SIZE | ||
586 | - || (dc->pc - dc->page_start >= TARGET_PAGE_SIZE - 3 | ||
587 | + && (dc->base.pc_next - dc->page_start >= TARGET_PAGE_SIZE | ||
588 | + || (dc->base.pc_next - dc->page_start >= TARGET_PAGE_SIZE - 3 | ||
589 | && insn_crosses_page(env, dc)))) { | ||
590 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
591 | } | ||
592 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
593 | case DISAS_NEXT: | ||
594 | case DISAS_TOO_MANY: | ||
595 | case DISAS_UPDATE: | ||
596 | - gen_set_pc_im(dc, dc->pc); | ||
597 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
598 | /* fall through */ | ||
599 | default: | ||
600 | /* FIXME: Single stepping a WFI insn will not halt the CPU. */ | ||
601 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
602 | switch(dc->base.is_jmp) { | ||
603 | case DISAS_NEXT: | ||
604 | case DISAS_TOO_MANY: | ||
605 | - gen_goto_tb(dc, 1, dc->pc); | ||
606 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
607 | break; | ||
608 | case DISAS_JUMP: | ||
609 | gen_goto_ptr(); | ||
610 | break; | ||
611 | case DISAS_UPDATE: | ||
612 | - gen_set_pc_im(dc, dc->pc); | ||
613 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
614 | /* fall through */ | ||
615 | default: | ||
616 | /* indicate that the hash table must be used to find the next TB */ | ||
617 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
618 | gen_set_label(dc->condlabel); | ||
619 | gen_set_condexec(dc); | ||
620 | if (unlikely(is_singlestepping(dc))) { | ||
621 | - gen_set_pc_im(dc, dc->pc); | ||
622 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
623 | gen_singlestep_exception(dc); | ||
624 | } else { | ||
625 | - gen_goto_tb(dc, 1, dc->pc); | ||
626 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
627 | } | ||
628 | } | ||
629 | - | ||
630 | - /* Functions above can change dc->pc, so re-align db->pc_next */ | ||
631 | - dc->base.pc_next = dc->pc; | ||
632 | } | ||
633 | |||
634 | static void arm_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) | ||
635 | -- | 37 | -- |
636 | 2.20.1 | 38 | 2.25.1 |
637 | 39 | ||
638 | 40 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | |||
3 | Add a new field to retain the address of the instruction currently | ||
4 | being translated. The 32-bit uses are all within subroutines used | ||
5 | by a32 and t32. This will become less obvious when t16 support is | ||
6 | merged with a32+t32, and having a clear definition will help. | ||
7 | |||
8 | Convert aarch64 as well for consistency. Note that there is one | ||
9 | instance of a pre-assert fprintf that used the wrong value for the | ||
10 | address of the current instruction. | ||
11 | 2 | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Message-id: 20190807045335.1361-3-richard.henderson@linaro.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 6 | --- |
18 | target/arm/translate-a64.h | 2 +- | 7 | target/arm/translate.c | 16 ++++++++-------- |
19 | target/arm/translate.h | 2 ++ | 8 | 1 file changed, 8 insertions(+), 8 deletions(-) |
20 | target/arm/translate-a64.c | 21 +++++++++++---------- | ||
21 | target/arm/translate.c | 14 ++++++++------ | ||
22 | 4 files changed, 22 insertions(+), 17 deletions(-) | ||
23 | 9 | ||
24 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/translate-a64.h | ||
27 | +++ b/target/arm/translate-a64.h | ||
28 | @@ -XXX,XX +XXX,XX @@ void unallocated_encoding(DisasContext *s); | ||
29 | qemu_log_mask(LOG_UNIMP, \ | ||
30 | "%s:%d: unsupported instruction encoding 0x%08x " \ | ||
31 | "at pc=%016" PRIx64 "\n", \ | ||
32 | - __FILE__, __LINE__, insn, s->pc - 4); \ | ||
33 | + __FILE__, __LINE__, insn, s->pc_curr); \ | ||
34 | unallocated_encoding(s); \ | ||
35 | } while (0) | ||
36 | |||
37 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/translate.h | ||
40 | +++ b/target/arm/translate.h | ||
41 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
42 | const ARMISARegisters *isar; | ||
43 | |||
44 | target_ulong pc; | ||
45 | + /* The address of the current instruction being translated. */ | ||
46 | + target_ulong pc_curr; | ||
47 | target_ulong page_start; | ||
48 | uint32_t insn; | ||
49 | /* Nonzero if this instruction has been conditionally skipped. */ | ||
50 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/translate-a64.c | ||
53 | +++ b/target/arm/translate-a64.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline AArch64DecodeFn *lookup_disas_fn(const AArch64DecodeTable *table, | ||
55 | */ | ||
56 | static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) | ||
57 | { | ||
58 | - uint64_t addr = s->pc + sextract32(insn, 0, 26) * 4 - 4; | ||
59 | + uint64_t addr = s->pc_curr + sextract32(insn, 0, 26) * 4; | ||
60 | |||
61 | if (insn & (1U << 31)) { | ||
62 | /* BL Branch with link */ | ||
63 | @@ -XXX,XX +XXX,XX @@ static void disas_comp_b_imm(DisasContext *s, uint32_t insn) | ||
64 | sf = extract32(insn, 31, 1); | ||
65 | op = extract32(insn, 24, 1); /* 0: CBZ; 1: CBNZ */ | ||
66 | rt = extract32(insn, 0, 5); | ||
67 | - addr = s->pc + sextract32(insn, 5, 19) * 4 - 4; | ||
68 | + addr = s->pc_curr + sextract32(insn, 5, 19) * 4; | ||
69 | |||
70 | tcg_cmp = read_cpu_reg(s, rt, sf); | ||
71 | label_match = gen_new_label(); | ||
72 | @@ -XXX,XX +XXX,XX @@ static void disas_test_b_imm(DisasContext *s, uint32_t insn) | ||
73 | |||
74 | bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); | ||
75 | op = extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ | ||
76 | - addr = s->pc + sextract32(insn, 5, 14) * 4 - 4; | ||
77 | + addr = s->pc_curr + sextract32(insn, 5, 14) * 4; | ||
78 | rt = extract32(insn, 0, 5); | ||
79 | |||
80 | tcg_cmp = tcg_temp_new_i64(); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void disas_cond_b_imm(DisasContext *s, uint32_t insn) | ||
82 | unallocated_encoding(s); | ||
83 | return; | ||
84 | } | ||
85 | - addr = s->pc + sextract32(insn, 5, 19) * 4 - 4; | ||
86 | + addr = s->pc_curr + sextract32(insn, 5, 19) * 4; | ||
87 | cond = extract32(insn, 0, 4); | ||
88 | |||
89 | reset_btype(s); | ||
90 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
91 | TCGv_i32 tcg_syn, tcg_isread; | ||
92 | uint32_t syndrome; | ||
93 | |||
94 | - gen_a64_set_pc_im(s->pc - 4); | ||
95 | + gen_a64_set_pc_im(s->pc_curr); | ||
96 | tmpptr = tcg_const_ptr(ri); | ||
97 | syndrome = syn_aa64_sysregtrap(op0, op1, op2, crn, crm, rt, isread); | ||
98 | tcg_syn = tcg_const_i32(syndrome); | ||
99 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
100 | /* The pre HVC helper handles cases when HVC gets trapped | ||
101 | * as an undefined insn by runtime configuration. | ||
102 | */ | ||
103 | - gen_a64_set_pc_im(s->pc - 4); | ||
104 | + gen_a64_set_pc_im(s->pc_curr); | ||
105 | gen_helper_pre_hvc(cpu_env); | ||
106 | gen_ss_advance(s); | ||
107 | gen_exception_insn(s, 0, EXCP_HVC, syn_aa64_hvc(imm16), 2); | ||
108 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
109 | unallocated_encoding(s); | ||
110 | break; | ||
111 | } | ||
112 | - gen_a64_set_pc_im(s->pc - 4); | ||
113 | + gen_a64_set_pc_im(s->pc_curr); | ||
114 | tmp = tcg_const_i32(syn_aa64_smc(imm16)); | ||
115 | gen_helper_pre_smc(cpu_env, tmp); | ||
116 | tcg_temp_free_i32(tmp); | ||
117 | @@ -XXX,XX +XXX,XX @@ static void disas_ld_lit(DisasContext *s, uint32_t insn) | ||
118 | |||
119 | tcg_rt = cpu_reg(s, rt); | ||
120 | |||
121 | - clean_addr = tcg_const_i64((s->pc - 4) + imm); | ||
122 | + clean_addr = tcg_const_i64(s->pc_curr + imm); | ||
123 | if (is_vector) { | ||
124 | do_fp_ld(s, rt, clean_addr, size); | ||
125 | } else { | ||
126 | @@ -XXX,XX +XXX,XX @@ static void disas_pc_rel_adr(DisasContext *s, uint32_t insn) | ||
127 | offset = sextract64(insn, 5, 19); | ||
128 | offset = offset << 2 | extract32(insn, 29, 2); | ||
129 | rd = extract32(insn, 0, 5); | ||
130 | - base = s->pc - 4; | ||
131 | + base = s->pc_curr; | ||
132 | |||
133 | if (page) { | ||
134 | /* ADRP (page based) */ | ||
135 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) | ||
136 | break; | ||
137 | default: | ||
138 | fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n", | ||
139 | - __func__, insn, fpopcode, s->pc); | ||
140 | + __func__, insn, fpopcode, s->pc_curr); | ||
141 | g_assert_not_reached(); | ||
142 | } | ||
143 | |||
144 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
145 | { | ||
146 | uint32_t insn; | ||
147 | |||
148 | + s->pc_curr = s->pc; | ||
149 | insn = arm_ldl_code(env, s->pc, s->sctlr_b); | ||
150 | s->insn = insn; | ||
151 | s->pc += 4; | ||
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 10 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
153 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
154 | --- a/target/arm/translate.c | 12 | --- a/target/arm/translate.c |
155 | +++ b/target/arm/translate.c | 13 | +++ b/target/arm/translate.c |
156 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hvc(DisasContext *s, int imm16) | 14 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
157 | * as an undefined insn by runtime configuration (ie before | 15 | { |
158 | * the insn really executes). | 16 | DisasContext *dc = container_of(dcbase, DisasContext, base); |
159 | */ | 17 | CPUARMState *env = cpu->env_ptr; |
160 | - gen_set_pc_im(s, s->pc - 4); | 18 | + uint32_t pc = dc->base.pc_next; |
161 | + gen_set_pc_im(s, s->pc_curr); | 19 | uint32_t insn; |
162 | gen_helper_pre_hvc(cpu_env); | 20 | bool is_16bit; |
163 | /* Otherwise we will treat this as a real exception which | 21 | |
164 | * happens after execution of the insn. (The distinction matters | 22 | if (arm_pre_translate_insn(dc)) { |
165 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | 23 | - dc->base.pc_next += 2; |
166 | */ | 24 | + dc->base.pc_next = pc + 2; |
167 | TCGv_i32 tmp; | ||
168 | |||
169 | - gen_set_pc_im(s, s->pc - 4); | ||
170 | + gen_set_pc_im(s, s->pc_curr); | ||
171 | tmp = tcg_const_i32(syn_aa32_smc()); | ||
172 | gen_helper_pre_smc(cpu_env, tmp); | ||
173 | tcg_temp_free_i32(tmp); | ||
174 | @@ -XXX,XX +XXX,XX @@ static void gen_msr_banked(DisasContext *s, int r, int sysm, int rn) | ||
175 | |||
176 | /* Sync state because msr_banked() can raise exceptions */ | ||
177 | gen_set_condexec(s); | ||
178 | - gen_set_pc_im(s, s->pc - 4); | ||
179 | + gen_set_pc_im(s, s->pc_curr); | ||
180 | tcg_reg = load_reg(s, rn); | ||
181 | tcg_tgtmode = tcg_const_i32(tgtmode); | ||
182 | tcg_regno = tcg_const_i32(regno); | ||
183 | @@ -XXX,XX +XXX,XX @@ static void gen_mrs_banked(DisasContext *s, int r, int sysm, int rn) | ||
184 | |||
185 | /* Sync state because mrs_banked() can raise exceptions */ | ||
186 | gen_set_condexec(s); | ||
187 | - gen_set_pc_im(s, s->pc - 4); | ||
188 | + gen_set_pc_im(s, s->pc_curr); | ||
189 | tcg_reg = tcg_temp_new_i32(); | ||
190 | tcg_tgtmode = tcg_const_i32(tgtmode); | ||
191 | tcg_regno = tcg_const_i32(regno); | ||
192 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
193 | } | ||
194 | |||
195 | gen_set_condexec(s); | ||
196 | - gen_set_pc_im(s, s->pc - 4); | ||
197 | + gen_set_pc_im(s, s->pc_curr); | ||
198 | tmpptr = tcg_const_ptr(ri); | ||
199 | tcg_syn = tcg_const_i32(syndrome); | ||
200 | tcg_isread = tcg_const_i32(isread); | ||
201 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
202 | tmp = tcg_const_i32(mode); | ||
203 | /* get_r13_banked() will raise an exception if called from System mode */ | ||
204 | gen_set_condexec(s); | ||
205 | - gen_set_pc_im(s, s->pc - 4); | ||
206 | + gen_set_pc_im(s, s->pc_curr); | ||
207 | gen_helper_get_r13_banked(addr, cpu_env, tmp); | ||
208 | tcg_temp_free_i32(tmp); | ||
209 | switch (amode) { | ||
210 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
211 | return; | 25 | return; |
212 | } | 26 | } |
213 | 27 | ||
214 | + dc->pc_curr = dc->pc; | 28 | - dc->pc_curr = dc->base.pc_next; |
215 | insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); | 29 | - insn = arm_lduw_code(env, &dc->base, dc->base.pc_next, dc->sctlr_b); |
30 | + dc->pc_curr = pc; | ||
31 | + insn = arm_lduw_code(env, &dc->base, pc, dc->sctlr_b); | ||
32 | is_16bit = thumb_insn_is_16bit(dc, dc->base.pc_next, insn); | ||
33 | - dc->base.pc_next += 2; | ||
34 | + pc += 2; | ||
35 | if (!is_16bit) { | ||
36 | - uint32_t insn2 = arm_lduw_code(env, &dc->base, dc->base.pc_next, | ||
37 | - dc->sctlr_b); | ||
38 | - | ||
39 | + uint32_t insn2 = arm_lduw_code(env, &dc->base, pc, dc->sctlr_b); | ||
40 | insn = insn << 16 | insn2; | ||
41 | - dc->base.pc_next += 2; | ||
42 | + pc += 2; | ||
43 | } | ||
44 | + dc->base.pc_next = pc; | ||
216 | dc->insn = insn; | 45 | dc->insn = insn; |
217 | dc->pc += 4; | 46 | |
218 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 47 | if (dc->pstate_il) { |
219 | return; | ||
220 | } | ||
221 | |||
222 | + dc->pc_curr = dc->pc; | ||
223 | insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
224 | is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | ||
225 | dc->pc += 2; | ||
226 | -- | 48 | -- |
227 | 2.20.1 | 49 | 2.25.1 |
228 | 50 | ||
229 | 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 | All of the inputs to these instructions are 32-bits. Rather than | 3 | Create arm_check_ss_active and arm_check_kernelpage. |
4 | extend each input to 64-bits and then extract the high 32-bits of | 4 | |
5 | the output, use tcg_gen_muls2_i32 and other 32-bit generator functions. | 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. | ||
6 | 9 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20190808202616.13782-7-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/translate.c | 72 +++++++++++++++--------------------------- | 14 | target/arm/translate.c | 10 +++++++--- |
13 | 1 file changed, 26 insertions(+), 46 deletions(-) | 15 | 1 file changed, 7 insertions(+), 3 deletions(-) |
14 | 16 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 19 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate.c | 20 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ static void gen_revsh(TCGv_i32 var) | 21 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) |
20 | tcg_gen_ext16s_i32(var, var); | 22 | dc->insn_start = tcg_last_op(); |
21 | } | 23 | } |
22 | 24 | ||
23 | -/* Return (b << 32) + a. Mark inputs as dead */ | 25 | -static bool arm_pre_translate_insn(DisasContext *dc) |
24 | -static TCGv_i64 gen_addq_msw(TCGv_i64 a, TCGv_i32 b) | 26 | +static bool arm_check_kernelpage(DisasContext *dc) |
25 | -{ | ||
26 | - TCGv_i64 tmp64 = tcg_temp_new_i64(); | ||
27 | - | ||
28 | - tcg_gen_extu_i32_i64(tmp64, b); | ||
29 | - tcg_temp_free_i32(b); | ||
30 | - tcg_gen_shli_i64(tmp64, tmp64, 32); | ||
31 | - tcg_gen_add_i64(a, tmp64, a); | ||
32 | - | ||
33 | - tcg_temp_free_i64(tmp64); | ||
34 | - return a; | ||
35 | -} | ||
36 | - | ||
37 | -/* Return (b << 32) - a. Mark inputs as dead. */ | ||
38 | -static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv_i32 b) | ||
39 | -{ | ||
40 | - TCGv_i64 tmp64 = tcg_temp_new_i64(); | ||
41 | - | ||
42 | - tcg_gen_extu_i32_i64(tmp64, b); | ||
43 | - tcg_temp_free_i32(b); | ||
44 | - tcg_gen_shli_i64(tmp64, tmp64, 32); | ||
45 | - tcg_gen_sub_i64(a, tmp64, a); | ||
46 | - | ||
47 | - tcg_temp_free_i64(tmp64); | ||
48 | - return a; | ||
49 | -} | ||
50 | - | ||
51 | /* 32x32->64 multiply. Marks inputs as dead. */ | ||
52 | static TCGv_i64 gen_mulu_i64_i32(TCGv_i32 a, TCGv_i32 b) | ||
53 | { | 27 | { |
54 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 28 | #ifdef CONFIG_USER_ONLY |
55 | (SMMUL, SMMLA, SMMLS) */ | 29 | /* Intercept jump to the magic kernel page. */ |
56 | tmp = load_reg(s, rm); | 30 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) |
57 | tmp2 = load_reg(s, rs); | 31 | return true; |
58 | - tmp64 = gen_muls_i64_i32(tmp, tmp2); | 32 | } |
59 | + tcg_gen_muls2_i32(tmp2, tmp, tmp, tmp2); | 33 | #endif |
60 | 34 | + return false; | |
61 | if (rd != 15) { | 35 | +} |
62 | - tmp = load_reg(s, rd); | 36 | |
63 | + tmp3 = load_reg(s, rd); | 37 | +static bool arm_check_ss_active(DisasContext *dc) |
64 | if (insn & (1 << 6)) { | 38 | +{ |
65 | - tmp64 = gen_subq_msw(tmp64, tmp); | 39 | if (dc->ss_active && !dc->pstate_ss) { |
66 | + tcg_gen_sub_i32(tmp, tmp, tmp3); | 40 | /* Singlestep state is Active-pending. |
67 | } else { | 41 | * If we're in this state at the start of a TB then either |
68 | - tmp64 = gen_addq_msw(tmp64, tmp); | 42 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
69 | + tcg_gen_add_i32(tmp, tmp, tmp3); | 43 | uint32_t pc = dc->base.pc_next; |
70 | } | 44 | unsigned int insn; |
71 | + tcg_temp_free_i32(tmp3); | 45 | |
72 | } | 46 | - if (arm_pre_translate_insn(dc)) { |
73 | if (insn & (1 << 5)) { | 47 | + if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { |
74 | - tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); | 48 | dc->base.pc_next = pc + 4; |
75 | + /* | 49 | return; |
76 | + * Adding 0x80000000 to the 64-bit quantity | 50 | } |
77 | + * means that we have carry in to the high | 51 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
78 | + * word when the low word has the high bit set. | 52 | uint32_t insn; |
79 | + */ | 53 | bool is_16bit; |
80 | + tcg_gen_shri_i32(tmp2, tmp2, 31); | 54 | |
81 | + tcg_gen_add_i32(tmp, tmp, tmp2); | 55 | - if (arm_pre_translate_insn(dc)) { |
82 | } | 56 | + if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { |
83 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | 57 | dc->base.pc_next = pc + 2; |
84 | - tmp = tcg_temp_new_i32(); | 58 | return; |
85 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | 59 | } |
86 | - tcg_temp_free_i64(tmp64); | ||
87 | + tcg_temp_free_i32(tmp2); | ||
88 | store_reg(s, rn, tmp); | ||
89 | break; | ||
90 | case 0: | ||
91 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
92 | } | ||
93 | break; | ||
94 | case 5: case 6: /* 32 * 32 -> 32msb (SMMUL, SMMLA, SMMLS) */ | ||
95 | - tmp64 = gen_muls_i64_i32(tmp, tmp2); | ||
96 | + tcg_gen_muls2_i32(tmp2, tmp, tmp, tmp2); | ||
97 | if (rs != 15) { | ||
98 | - tmp = load_reg(s, rs); | ||
99 | + tmp3 = load_reg(s, rs); | ||
100 | if (insn & (1 << 20)) { | ||
101 | - tmp64 = gen_addq_msw(tmp64, tmp); | ||
102 | + tcg_gen_add_i32(tmp, tmp, tmp3); | ||
103 | } else { | ||
104 | - tmp64 = gen_subq_msw(tmp64, tmp); | ||
105 | + tcg_gen_sub_i32(tmp, tmp, tmp3); | ||
106 | } | ||
107 | + tcg_temp_free_i32(tmp3); | ||
108 | } | ||
109 | if (insn & (1 << 4)) { | ||
110 | - tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); | ||
111 | + /* | ||
112 | + * Adding 0x80000000 to the 64-bit quantity | ||
113 | + * means that we have carry in to the high | ||
114 | + * word when the low word has the high bit set. | ||
115 | + */ | ||
116 | + tcg_gen_shri_i32(tmp2, tmp2, 31); | ||
117 | + tcg_gen_add_i32(tmp, tmp, tmp2); | ||
118 | } | ||
119 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | ||
120 | - tmp = tcg_temp_new_i32(); | ||
121 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
122 | - tcg_temp_free_i64(tmp64); | ||
123 | + tcg_temp_free_i32(tmp2); | ||
124 | break; | ||
125 | case 7: /* Unsigned sum of absolute differences. */ | ||
126 | gen_helper_usad8(tmp, tmp, tmp2); | ||
127 | -- | 60 | -- |
128 | 2.20.1 | 61 | 2.25.1 |
129 | 62 | ||
130 | 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 | The offset is variable depending on the instruction set, whereas | 3 | The size of the code covered by a TranslationBlock cannot be 0; |
4 | we have stored values for the current pc and the next pc. Passing | 4 | this is checked via assert in tb_gen_code. |
5 | in the actual value is clearer in intent. | ||
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 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190807045335.1361-8-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 9 | --- |
13 | target/arm/translate-a64.c | 25 ++++++++++++++----------- | 10 | target/arm/translate-a64.c | 1 + |
14 | target/arm/translate-vfp.inc.c | 6 +++--- | 11 | 1 file changed, 1 insertion(+) |
15 | target/arm/translate.c | 31 ++++++++++++++++--------------- | ||
16 | 3 files changed, 33 insertions(+), 29 deletions(-) | ||
17 | 12 | ||
18 | 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 |
19 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/translate-a64.c | 15 | --- a/target/arm/translate-a64.c |
21 | +++ b/target/arm/translate-a64.c | 16 | +++ b/target/arm/translate-a64.c |
22 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 17 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
23 | s->base.is_jmp = DISAS_NORETURN; | 18 | assert(s->base.num_insns == 1); |
24 | } | 19 | gen_swstep_exception(s, 0, 0); |
25 | 20 | s->base.is_jmp = DISAS_NORETURN; | |
26 | -static void gen_exception_insn(DisasContext *s, int offset, int excp, | 21 | + s->base.pc_next = pc + 4; |
27 | +static void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | ||
28 | uint32_t syndrome, uint32_t target_el) | ||
29 | { | ||
30 | - gen_a64_set_pc_im(s->base.pc_next - offset); | ||
31 | + gen_a64_set_pc_im(pc); | ||
32 | gen_exception(excp, syndrome, target_el); | ||
33 | s->base.is_jmp = DISAS_NORETURN; | ||
34 | } | ||
35 | @@ -XXX,XX +XXX,XX @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) | ||
36 | void unallocated_encoding(DisasContext *s) | ||
37 | { | ||
38 | /* Unallocated and reserved encodings are uncategorized */ | ||
39 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
40 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
41 | default_exception_el(s)); | ||
42 | } | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s) | ||
45 | return true; | ||
46 | } | ||
47 | |||
48 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_fp_access_trap(1, 0xe, false), | ||
49 | - s->fp_excp_el); | ||
50 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
51 | + syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
52 | return false; | ||
53 | } | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s) | ||
56 | bool sve_access_check(DisasContext *s) | ||
57 | { | ||
58 | if (s->sve_excp_el) { | ||
59 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_sve_access_trap(), | ||
60 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_sve_access_trap(), | ||
61 | s->sve_excp_el); | ||
62 | return false; | ||
63 | } | ||
64 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
65 | switch (op2_ll) { | ||
66 | case 1: /* SVC */ | ||
67 | gen_ss_advance(s); | ||
68 | - gen_exception_insn(s, 0, EXCP_SWI, syn_aa64_svc(imm16), | ||
69 | - default_exception_el(s)); | ||
70 | + gen_exception_insn(s, s->base.pc_next, EXCP_SWI, | ||
71 | + syn_aa64_svc(imm16), default_exception_el(s)); | ||
72 | break; | ||
73 | case 2: /* HVC */ | ||
74 | if (s->current_el == 0) { | ||
75 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
76 | gen_a64_set_pc_im(s->pc_curr); | ||
77 | gen_helper_pre_hvc(cpu_env); | ||
78 | gen_ss_advance(s); | ||
79 | - gen_exception_insn(s, 0, EXCP_HVC, syn_aa64_hvc(imm16), 2); | ||
80 | + gen_exception_insn(s, s->base.pc_next, EXCP_HVC, | ||
81 | + syn_aa64_hvc(imm16), 2); | ||
82 | break; | ||
83 | case 3: /* SMC */ | ||
84 | if (s->current_el == 0) { | ||
85 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
86 | gen_helper_pre_smc(cpu_env, tmp); | ||
87 | tcg_temp_free_i32(tmp); | ||
88 | gen_ss_advance(s); | ||
89 | - gen_exception_insn(s, 0, EXCP_SMC, syn_aa64_smc(imm16), 3); | ||
90 | + gen_exception_insn(s, s->base.pc_next, EXCP_SMC, | ||
91 | + syn_aa64_smc(imm16), 3); | ||
92 | break; | ||
93 | default: | ||
94 | unallocated_encoding(s); | ||
95 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
96 | if (s->btype != 0 | ||
97 | && s->guarded_page | ||
98 | && !btype_destination_ok(insn, s->bt, s->btype)) { | ||
99 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_btitrap(s->btype), | ||
100 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
101 | + syn_btitrap(s->btype), | ||
102 | default_exception_el(s)); | ||
103 | return; | ||
104 | } | ||
105 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/translate-vfp.inc.c | ||
108 | +++ b/target/arm/translate-vfp.inc.c | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | ||
110 | { | ||
111 | if (s->fp_excp_el) { | ||
112 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
113 | - gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
114 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized(), | ||
115 | s->fp_excp_el); | ||
116 | } else { | ||
117 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
118 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
119 | syn_fp_access_trap(1, 0xe, false), | ||
120 | s->fp_excp_el); | ||
121 | } | ||
122 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | ||
123 | |||
124 | if (!s->vfp_enabled && !ignore_vfp_enabled) { | ||
125 | assert(!arm_dc_feature(s, ARM_FEATURE_M)); | ||
126 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
127 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
128 | default_exception_el(s)); | ||
129 | return false; | ||
130 | } | ||
131 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/translate.c | ||
134 | +++ b/target/arm/translate.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
136 | s->base.is_jmp = DISAS_NORETURN; | ||
137 | } | ||
138 | |||
139 | -static void gen_exception_insn(DisasContext *s, int offset, int excp, | ||
140 | +static void gen_exception_insn(DisasContext *s, uint32_t pc, int excp, | ||
141 | int syn, uint32_t target_el) | ||
142 | { | ||
143 | gen_set_condexec(s); | ||
144 | - gen_set_pc_im(s, s->base.pc_next - offset); | ||
145 | + gen_set_pc_im(s, pc); | ||
146 | gen_exception(excp, syn, target_el); | ||
147 | s->base.is_jmp = DISAS_NORETURN; | ||
148 | } | ||
149 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | ||
150 | return; | 22 | return; |
151 | } | 23 | } |
152 | 24 | ||
153 | - gen_exception_insn(s, s->thumb ? 2 : 4, EXCP_UDEF, syn_uncategorized(), | ||
154 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
155 | default_exception_el(s)); | ||
156 | } | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn, | ||
159 | |||
160 | undef: | ||
161 | /* If we get here then some access check did not pass */ | ||
162 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), exc_target); | ||
163 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
164 | + syn_uncategorized(), exc_target); | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
169 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
170 | */ | ||
171 | if (s->fp_excp_el) { | ||
172 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
173 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
174 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
175 | return 0; | ||
176 | } | ||
177 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
178 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
179 | */ | ||
180 | if (s->fp_excp_el) { | ||
181 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
182 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
183 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
184 | return 0; | ||
185 | } | ||
186 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
187 | } | ||
188 | |||
189 | if (s->fp_excp_el) { | ||
190 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
191 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
192 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
193 | return 0; | ||
194 | } | ||
195 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
196 | off_rm = vfp_reg_offset(0, rm); | ||
197 | } | ||
198 | if (s->fp_excp_el) { | ||
199 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
200 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
201 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
202 | return 0; | ||
203 | } | ||
204 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
205 | * For the UNPREDICTABLE cases we choose to UNDEF. | ||
206 | */ | ||
207 | if (s->current_el == 1 && !s->ns && mode == ARM_CPU_MODE_MON) { | ||
208 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), 3); | ||
209 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), 3); | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
214 | } | ||
215 | |||
216 | if (undef) { | ||
217 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
218 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
219 | default_exception_el(s)); | ||
220 | return; | ||
221 | } | ||
222 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
223 | * UsageFault exception. | ||
224 | */ | ||
225 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
226 | - gen_exception_insn(s, 4, EXCP_INVSTATE, syn_uncategorized(), | ||
227 | + gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
228 | default_exception_el(s)); | ||
229 | return; | ||
230 | } | ||
231 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
232 | break; | ||
233 | default: | ||
234 | illegal_op: | ||
235 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
236 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
237 | default_exception_el(s)); | ||
238 | break; | ||
239 | } | ||
240 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
241 | } | ||
242 | |||
243 | /* All other insns: NOCP */ | ||
244 | - gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
245 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized(), | ||
246 | default_exception_el(s)); | ||
247 | break; | ||
248 | } | ||
249 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
250 | } | ||
251 | return; | ||
252 | illegal_op: | ||
253 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
254 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
255 | default_exception_el(s)); | ||
256 | } | ||
257 | |||
258 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
259 | return; | ||
260 | illegal_op: | ||
261 | undef: | ||
262 | - gen_exception_insn(s, 2, EXCP_UDEF, syn_uncategorized(), | ||
263 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
264 | default_exception_el(s)); | ||
265 | } | ||
266 | |||
267 | -- | 25 | -- |
268 | 2.20.1 | 26 | 2.25.1 |
269 | 27 | ||
270 | 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 | Provide a common routine for the places that require ALIGN(PC, 4) | 3 | We will reuse this section of arm_deliver_fault for |
4 | as the base address as opposed to plain PC. The two are always | 4 | raising pc alignment faults. |
5 | the same for A32, but the difference is meaningful for thumb mode. | ||
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 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190807045335.1361-5-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 9 | --- |
13 | target/arm/translate-vfp.inc.c | 38 ++------ | 10 | target/arm/tlb_helper.c | 45 +++++++++++++++++++++++++---------------- |
14 | target/arm/translate.c | 166 +++++++++++++++------------------ | 11 | 1 file changed, 28 insertions(+), 17 deletions(-) |
15 | 2 files changed, 82 insertions(+), 122 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | 13 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate-vfp.inc.c | 15 | --- a/target/arm/tlb_helper.c |
20 | +++ b/target/arm/translate-vfp.inc.c | 16 | +++ b/target/arm/tlb_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | 17 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, |
22 | offset = -offset; | 18 | return syn; |
19 | } | ||
20 | |||
21 | -static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | ||
22 | - MMUAccessType access_type, | ||
23 | - int mmu_idx, ARMMMUFaultInfo *fi) | ||
24 | +static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, | ||
25 | + int target_el, int mmu_idx, uint32_t *ret_fsc) | ||
26 | { | ||
27 | - CPUARMState *env = &cpu->env; | ||
28 | - int target_el; | ||
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; | ||
23 | } | 48 | } |
24 | 49 | ||
25 | - if (s->thumb && a->rn == 15) { | 50 | + *ret_fsc = fsc; |
26 | - /* This is actually UNPREDICTABLE */ | 51 | + return fsr; |
27 | - addr = tcg_temp_new_i32(); | ||
28 | - tcg_gen_movi_i32(addr, s->pc & ~2); | ||
29 | - } else { | ||
30 | - addr = load_reg(s, a->rn); | ||
31 | - } | ||
32 | - tcg_gen_addi_i32(addr, addr, offset); | ||
33 | + /* For thumb, use of PC is UNPREDICTABLE. */ | ||
34 | + addr = add_reg_for_lit(s, a->rn, offset); | ||
35 | tmp = tcg_temp_new_i32(); | ||
36 | if (a->l) { | ||
37 | gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
39 | offset = -offset; | ||
40 | } | ||
41 | |||
42 | - if (s->thumb && a->rn == 15) { | ||
43 | - /* This is actually UNPREDICTABLE */ | ||
44 | - addr = tcg_temp_new_i32(); | ||
45 | - tcg_gen_movi_i32(addr, s->pc & ~2); | ||
46 | - } else { | ||
47 | - addr = load_reg(s, a->rn); | ||
48 | - } | ||
49 | - tcg_gen_addi_i32(addr, addr, offset); | ||
50 | + /* For thumb, use of PC is UNPREDICTABLE. */ | ||
51 | + addr = add_reg_for_lit(s, a->rn, offset); | ||
52 | tmp = tcg_temp_new_i64(); | ||
53 | if (a->l) { | ||
54 | gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | - if (s->thumb && a->rn == 15) { | ||
60 | - /* This is actually UNPREDICTABLE */ | ||
61 | - addr = tcg_temp_new_i32(); | ||
62 | - tcg_gen_movi_i32(addr, s->pc & ~2); | ||
63 | - } else { | ||
64 | - addr = load_reg(s, a->rn); | ||
65 | - } | ||
66 | + /* For thumb, use of PC is UNPREDICTABLE. */ | ||
67 | + addr = add_reg_for_lit(s, a->rn, 0); | ||
68 | if (a->p) { | ||
69 | /* pre-decrement */ | ||
70 | tcg_gen_addi_i32(addr, addr, -(a->imm << 2)); | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
72 | return true; | ||
73 | } | ||
74 | |||
75 | - if (s->thumb && a->rn == 15) { | ||
76 | - /* This is actually UNPREDICTABLE */ | ||
77 | - addr = tcg_temp_new_i32(); | ||
78 | - tcg_gen_movi_i32(addr, s->pc & ~2); | ||
79 | - } else { | ||
80 | - addr = load_reg(s, a->rn); | ||
81 | - } | ||
82 | + /* For thumb, use of PC is UNPREDICTABLE. */ | ||
83 | + addr = add_reg_for_lit(s, a->rn, 0); | ||
84 | if (a->p) { | ||
85 | /* pre-decrement */ | ||
86 | tcg_gen_addi_i32(addr, addr, -(a->imm << 2)); | ||
87 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/target/arm/translate.c | ||
90 | +++ b/target/arm/translate.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_reg(DisasContext *s, int reg) | ||
92 | return tmp; | ||
93 | } | ||
94 | |||
95 | +/* | ||
96 | + * Create a new temp, REG + OFS, except PC is ALIGN(PC, 4). | ||
97 | + * This is used for load/store for which use of PC implies (literal), | ||
98 | + * or ADD that implies ADR. | ||
99 | + */ | ||
100 | +static TCGv_i32 add_reg_for_lit(DisasContext *s, int reg, int ofs) | ||
101 | +{ | ||
102 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
103 | + | ||
104 | + if (reg == 15) { | ||
105 | + tcg_gen_movi_i32(tmp, (read_pc(s) & ~3) + ofs); | ||
106 | + } else { | ||
107 | + tcg_gen_addi_i32(tmp, cpu_R[reg], ofs); | ||
108 | + } | ||
109 | + return tmp; | ||
110 | +} | 52 | +} |
111 | + | 53 | + |
112 | /* Set a CPU register. The source must be a temporary and will be | 54 | +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, |
113 | marked as dead. */ | 55 | + MMUAccessType access_type, |
114 | static void store_reg(DisasContext *s, int reg, TCGv_i32 var) | 56 | + int mmu_idx, ARMMMUFaultInfo *fi) |
115 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 57 | +{ |
116 | */ | 58 | + CPUARMState *env = &cpu->env; |
117 | bool wback = extract32(insn, 21, 1); | 59 | + int target_el; |
118 | 60 | + bool same_el; | |
119 | - if (rn == 15) { | 61 | + uint32_t syn, exc, fsr, fsc; |
120 | - if (insn & (1 << 21)) { | ||
121 | - /* UNPREDICTABLE */ | ||
122 | - goto illegal_op; | ||
123 | - } | ||
124 | - addr = tcg_temp_new_i32(); | ||
125 | - tcg_gen_movi_i32(addr, s->pc & ~3); | ||
126 | - } else { | ||
127 | - addr = load_reg(s, rn); | ||
128 | + if (rn == 15 && (insn & (1 << 21))) { | ||
129 | + /* UNPREDICTABLE */ | ||
130 | + goto illegal_op; | ||
131 | } | ||
132 | + | 62 | + |
133 | + addr = add_reg_for_lit(s, rn, 0); | 63 | + target_el = exception_target_el(env); |
134 | offset = (insn & 0xff) * 4; | 64 | + if (fi->stage2) { |
135 | if ((insn & (1 << 23)) == 0) { | 65 | + target_el = 2; |
136 | offset = -offset; | 66 | + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; |
137 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 67 | + if (arm_is_secure_below_el3(env) && fi->s1ns) { |
138 | store_reg(s, rd, tmp); | 68 | + env->cp15.hpfar_el2 |= HPFAR_NS; |
139 | } else { | 69 | + } |
140 | /* Add/sub 12-bit immediate. */ | 70 | + } |
141 | - if (rn == 15) { | 71 | + same_el = (arm_current_el(env) == target_el); |
142 | - offset = s->pc & ~(uint32_t)3; | 72 | + |
143 | - if (insn & (1 << 23)) | 73 | + fsr = compute_fsr_fsc(env, fi, target_el, mmu_idx, &fsc); |
144 | - offset -= imm; | 74 | + |
145 | - else | 75 | if (access_type == MMU_INST_FETCH) { |
146 | - offset += imm; | 76 | syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); |
147 | - tmp = tcg_temp_new_i32(); | 77 | exc = EXCP_PREFETCH_ABORT; |
148 | - tcg_gen_movi_i32(tmp, offset); | ||
149 | - store_reg(s, rd, tmp); | ||
150 | + if (insn & (1 << 23)) { | ||
151 | + imm = -imm; | ||
152 | + } | ||
153 | + tmp = add_reg_for_lit(s, rn, imm); | ||
154 | + if (rn == 13 && rd == 13) { | ||
155 | + /* ADD SP, SP, imm or SUB SP, SP, imm */ | ||
156 | + store_sp_checked(s, tmp); | ||
157 | } else { | ||
158 | - tmp = load_reg(s, rn); | ||
159 | - if (insn & (1 << 23)) | ||
160 | - tcg_gen_subi_i32(tmp, tmp, imm); | ||
161 | - else | ||
162 | - tcg_gen_addi_i32(tmp, tmp, imm); | ||
163 | - if (rn == 13 && rd == 13) { | ||
164 | - /* ADD SP, SP, imm or SUB SP, SP, imm */ | ||
165 | - store_sp_checked(s, tmp); | ||
166 | - } else { | ||
167 | - store_reg(s, rd, tmp); | ||
168 | - } | ||
169 | + store_reg(s, rd, tmp); | ||
170 | } | ||
171 | } | ||
172 | } | ||
173 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
174 | } | ||
175 | } | ||
176 | memidx = get_mem_index(s); | ||
177 | - if (rn == 15) { | ||
178 | - addr = tcg_temp_new_i32(); | ||
179 | - /* PC relative. */ | ||
180 | - /* s->pc has already been incremented by 4. */ | ||
181 | - imm = s->pc & 0xfffffffc; | ||
182 | - if (insn & (1 << 23)) | ||
183 | - imm += insn & 0xfff; | ||
184 | - else | ||
185 | - imm -= insn & 0xfff; | ||
186 | - tcg_gen_movi_i32(addr, imm); | ||
187 | + imm = insn & 0xfff; | ||
188 | + if (insn & (1 << 23)) { | ||
189 | + /* PC relative or Positive offset. */ | ||
190 | + addr = add_reg_for_lit(s, rn, imm); | ||
191 | + } else if (rn == 15) { | ||
192 | + /* PC relative with negative offset. */ | ||
193 | + addr = add_reg_for_lit(s, rn, -imm); | ||
194 | } else { | ||
195 | addr = load_reg(s, rn); | ||
196 | - if (insn & (1 << 23)) { | ||
197 | - /* Positive offset. */ | ||
198 | - imm = insn & 0xfff; | ||
199 | - tcg_gen_addi_i32(addr, addr, imm); | ||
200 | - } else { | ||
201 | - imm = insn & 0xff; | ||
202 | - switch ((insn >> 8) & 0xf) { | ||
203 | - case 0x0: /* Shifted Register. */ | ||
204 | - shift = (insn >> 4) & 0xf; | ||
205 | - if (shift > 3) { | ||
206 | - tcg_temp_free_i32(addr); | ||
207 | - goto illegal_op; | ||
208 | - } | ||
209 | - tmp = load_reg(s, rm); | ||
210 | - if (shift) | ||
211 | - tcg_gen_shli_i32(tmp, tmp, shift); | ||
212 | - tcg_gen_add_i32(addr, addr, tmp); | ||
213 | - tcg_temp_free_i32(tmp); | ||
214 | - break; | ||
215 | - case 0xc: /* Negative offset. */ | ||
216 | - tcg_gen_addi_i32(addr, addr, -imm); | ||
217 | - break; | ||
218 | - case 0xe: /* User privilege. */ | ||
219 | - tcg_gen_addi_i32(addr, addr, imm); | ||
220 | - memidx = get_a32_user_mem_index(s); | ||
221 | - break; | ||
222 | - case 0x9: /* Post-decrement. */ | ||
223 | - imm = -imm; | ||
224 | - /* Fall through. */ | ||
225 | - case 0xb: /* Post-increment. */ | ||
226 | - postinc = 1; | ||
227 | - writeback = 1; | ||
228 | - break; | ||
229 | - case 0xd: /* Pre-decrement. */ | ||
230 | - imm = -imm; | ||
231 | - /* Fall through. */ | ||
232 | - case 0xf: /* Pre-increment. */ | ||
233 | - writeback = 1; | ||
234 | - break; | ||
235 | - default: | ||
236 | + imm = insn & 0xff; | ||
237 | + switch ((insn >> 8) & 0xf) { | ||
238 | + case 0x0: /* Shifted Register. */ | ||
239 | + shift = (insn >> 4) & 0xf; | ||
240 | + if (shift > 3) { | ||
241 | tcg_temp_free_i32(addr); | ||
242 | goto illegal_op; | ||
243 | } | ||
244 | + tmp = load_reg(s, rm); | ||
245 | + if (shift) { | ||
246 | + tcg_gen_shli_i32(tmp, tmp, shift); | ||
247 | + } | ||
248 | + tcg_gen_add_i32(addr, addr, tmp); | ||
249 | + tcg_temp_free_i32(tmp); | ||
250 | + break; | ||
251 | + case 0xc: /* Negative offset. */ | ||
252 | + tcg_gen_addi_i32(addr, addr, -imm); | ||
253 | + break; | ||
254 | + case 0xe: /* User privilege. */ | ||
255 | + tcg_gen_addi_i32(addr, addr, imm); | ||
256 | + memidx = get_a32_user_mem_index(s); | ||
257 | + break; | ||
258 | + case 0x9: /* Post-decrement. */ | ||
259 | + imm = -imm; | ||
260 | + /* Fall through. */ | ||
261 | + case 0xb: /* Post-increment. */ | ||
262 | + postinc = 1; | ||
263 | + writeback = 1; | ||
264 | + break; | ||
265 | + case 0xd: /* Pre-decrement. */ | ||
266 | + imm = -imm; | ||
267 | + /* Fall through. */ | ||
268 | + case 0xf: /* Pre-increment. */ | ||
269 | + writeback = 1; | ||
270 | + break; | ||
271 | + default: | ||
272 | + tcg_temp_free_i32(addr); | ||
273 | + goto illegal_op; | ||
274 | } | ||
275 | } | ||
276 | |||
277 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
278 | if (insn & (1 << 11)) { | ||
279 | rd = (insn >> 8) & 7; | ||
280 | /* load pc-relative. Bit 1 of PC is ignored. */ | ||
281 | - val = read_pc(s) + ((insn & 0xff) * 4); | ||
282 | - val &= ~(uint32_t)2; | ||
283 | - addr = tcg_temp_new_i32(); | ||
284 | - tcg_gen_movi_i32(addr, val); | ||
285 | + addr = add_reg_for_lit(s, 15, (insn & 0xff) * 4); | ||
286 | tmp = tcg_temp_new_i32(); | ||
287 | gen_aa32_ld32u_iss(s, tmp, addr, get_mem_index(s), | ||
288 | rd | ISSIs16Bit); | ||
289 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
290 | * - Add PC/SP (immediate) | ||
291 | */ | ||
292 | rd = (insn >> 8) & 7; | ||
293 | - if (insn & (1 << 11)) { | ||
294 | - /* SP */ | ||
295 | - tmp = load_reg(s, 13); | ||
296 | - } else { | ||
297 | - /* PC. bit 1 is ignored. */ | ||
298 | - tmp = tcg_temp_new_i32(); | ||
299 | - tcg_gen_movi_i32(tmp, read_pc(s) & ~(uint32_t)2); | ||
300 | - } | ||
301 | val = (insn & 0xff) * 4; | ||
302 | - tcg_gen_addi_i32(tmp, tmp, val); | ||
303 | + tmp = add_reg_for_lit(s, insn & (1 << 11) ? 13 : 15, val); | ||
304 | store_reg(s, rd, tmp); | ||
305 | break; | ||
306 | |||
307 | -- | 78 | -- |
308 | 2.20.1 | 79 | 2.25.1 |
309 | 80 | ||
310 | 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 | Replace x = double_saturate(y) with x = add_saturate(y, y). | 3 | For A64, any input to an indirect branch can cause this. |
4 | There is no need for a separate more specialized helper. | 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 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-12-richard.henderson@linaro.org | ||
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/helper.h | 1 - | 19 | target/arm/helper.h | 1 + |
13 | target/arm/op_helper.c | 15 --------------- | 20 | target/arm/syndrome.h | 5 ++++ |
14 | target/arm/translate.c | 4 ++-- | 21 | linux-user/aarch64/cpu_loop.c | 46 ++++++++++++++++++++--------------- |
15 | 3 files changed, 2 insertions(+), 18 deletions(-) | 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(-) | ||
16 | 26 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 27 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
18 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 29 | --- a/target/arm/helper.h |
20 | +++ b/target/arm/helper.h | 30 | +++ b/target/arm/helper.h |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(add_saturate, i32, env, i32, i32) | 31 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, |
22 | DEF_HELPER_3(sub_saturate, i32, env, i32, i32) | 32 | DEF_HELPER_2(exception_internal, void, env, i32) |
23 | DEF_HELPER_3(add_usaturate, i32, env, i32, i32) | 33 | DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32) |
24 | DEF_HELPER_3(sub_usaturate, i32, env, i32, i32) | 34 | DEF_HELPER_2(exception_bkpt_insn, void, env, i32) |
25 | -DEF_HELPER_2(double_saturate, i32, env, s32) | 35 | +DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl) |
26 | DEF_HELPER_FLAGS_2(sdiv, TCG_CALL_NO_RWG_SE, s32, s32, s32) | 36 | DEF_HELPER_1(setend, void, env) |
27 | DEF_HELPER_FLAGS_2(udiv, TCG_CALL_NO_RWG_SE, i32, i32, i32) | 37 | DEF_HELPER_2(wfi, void, env, i32) |
28 | DEF_HELPER_FLAGS_1(rbit, TCG_CALL_NO_RWG_SE, i32, i32) | 38 | DEF_HELPER_1(wfe, void, env) |
29 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | 39 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h |
30 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/op_helper.c | 41 | --- a/target/arm/syndrome.h |
32 | +++ b/target/arm/op_helper.c | 42 | +++ b/target/arm/syndrome.h |
33 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sub_saturate)(CPUARMState *env, uint32_t a, uint32_t b) | 43 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_illegalstate(void) |
34 | return res; | 44 | return (EC_ILLEGALSTATE << ARM_EL_EC_SHIFT) | ARM_EL_IL; |
35 | } | 45 | } |
36 | 46 | ||
37 | -uint32_t HELPER(double_saturate)(CPUARMState *env, int32_t val) | 47 | +static inline uint32_t syn_pcalignment(void) |
38 | -{ | 48 | +{ |
39 | - uint32_t res; | 49 | + return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL; |
40 | - if (val >= 0x40000000) { | 50 | +} |
41 | - res = ~SIGNBIT; | 51 | + |
42 | - env->QF = 1; | 52 | #endif /* TARGET_ARM_SYNDROME_H */ |
43 | - } else if (val <= (int32_t)0xc0000000) { | 53 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c |
44 | - res = SIGNBIT; | 54 | index XXXXXXX..XXXXXXX 100644 |
45 | - env->QF = 1; | 55 | --- a/linux-user/aarch64/cpu_loop.c |
46 | - } else { | 56 | +++ b/linux-user/aarch64/cpu_loop.c |
47 | - res = val << 1; | 57 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
48 | - } | 58 | break; |
49 | - return res; | 59 | case EXCP_PREFETCH_ABORT: |
50 | -} | 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); | ||
51 | - | 64 | - |
52 | uint32_t HELPER(add_usaturate)(CPUARMState *env, uint32_t a, uint32_t b) | 65 | - /* Both EC have the same format for FSC, or close enough. */ |
53 | { | 66 | - fsc = extract32(env->exception.syndrome, 0, 6); |
54 | uint32_t res = a + b; | 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 | /* | ||
148 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/target/arm/translate-a64.c | ||
151 | +++ b/target/arm/translate-a64.c | ||
152 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
153 | uint64_t pc = s->base.pc_next; | ||
154 | uint32_t insn; | ||
155 | |||
156 | + /* Singlestep exceptions have the highest priority. */ | ||
157 | if (s->ss_active && !s->pstate_ss) { | ||
158 | /* Singlestep state is Active-pending. | ||
159 | * If we're in this state at the start of a TB then either | ||
160 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | + if (pc & 3) { | ||
165 | + /* | ||
166 | + * PC alignment fault. This has priority over the instruction abort | ||
167 | + * that we would receive from a translation fault via arm_ldl_code. | ||
168 | + * This should only be possible after an indirect branch, at the | ||
169 | + * start of the TB. | ||
170 | + */ | ||
171 | + assert(s->base.num_insns == 1); | ||
172 | + gen_helper_exception_pc_alignment(cpu_env, tcg_constant_tl(pc)); | ||
173 | + s->base.is_jmp = DISAS_NORETURN; | ||
174 | + s->base.pc_next = QEMU_ALIGN_UP(pc, 4); | ||
175 | + return; | ||
176 | + } | ||
177 | + | ||
178 | s->pc_curr = pc; | ||
179 | insn = arm_ldl_code(env, &s->base, pc, s->sctlr_b); | ||
180 | s->insn = insn; | ||
55 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 181 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
56 | index XXXXXXX..XXXXXXX 100644 | 182 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/target/arm/translate.c | 183 | --- a/target/arm/translate.c |
58 | +++ b/target/arm/translate.c | 184 | +++ b/target/arm/translate.c |
59 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 185 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
60 | tmp = load_reg(s, rm); | 186 | uint32_t pc = dc->base.pc_next; |
61 | tmp2 = load_reg(s, rn); | 187 | unsigned int insn; |
62 | if (op1 & 2) | 188 | |
63 | - gen_helper_double_saturate(tmp2, cpu_env, tmp2); | 189 | - if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { |
64 | + gen_helper_add_saturate(tmp2, cpu_env, tmp2, tmp2); | 190 | + /* Singlestep exceptions have the highest priority. */ |
65 | if (op1 & 1) | 191 | + if (arm_check_ss_active(dc)) { |
66 | gen_helper_sub_saturate(tmp, cpu_env, tmp, tmp2); | 192 | + dc->base.pc_next = pc + 4; |
67 | else | 193 | + return; |
68 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 194 | + } |
69 | tmp = load_reg(s, rn); | 195 | + |
70 | tmp2 = load_reg(s, rm); | 196 | + if (pc & 3) { |
71 | if (op & 1) | 197 | + /* |
72 | - gen_helper_double_saturate(tmp, cpu_env, tmp); | 198 | + * PC alignment fault. This has priority over the instruction abort |
73 | + gen_helper_add_saturate(tmp, cpu_env, tmp, tmp); | 199 | + * that we would receive from a translation fault via arm_ldl_code |
74 | if (op & 2) | 200 | + * (or the execution of the kernelpage entrypoint). This should only |
75 | gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp); | 201 | + * be possible after an indirect branch, at the start of the TB. |
76 | else | 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; | ||
208 | + } | ||
209 | + | ||
210 | + if (arm_check_kernelpage(dc)) { | ||
211 | dc->base.pc_next = pc + 4; | ||
212 | return; | ||
213 | } | ||
77 | -- | 214 | -- |
78 | 2.20.1 | 215 | 2.25.1 |
79 | 216 | ||
80 | 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 | The thumb bit has already been removed from s->pc, and is always even. | 3 | Misaligned thumb PC is architecturally impossible. |
4 | Assert is better than proceeding, in case we've missed | ||
5 | something somewhere. | ||
4 | 6 | ||
7 | Expand a comment about aligning the pc in gdbstub. | ||
8 | Fail an incoming migrate if a thumb pc is misaligned. | ||
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190807045335.1361-6-richard.henderson@linaro.org | ||
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/translate.c | 10 +++++----- | 14 | target/arm/gdbstub.c | 9 +++++++-- |
12 | 1 file changed, 5 insertions(+), 5 deletions(-) | 15 | target/arm/machine.c | 10 ++++++++++ |
16 | target/arm/translate.c | 3 +++ | ||
17 | 3 files changed, 20 insertions(+), 2 deletions(-) | ||
13 | 18 | ||
19 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/gdbstub.c | ||
22 | +++ b/target/arm/gdbstub.c | ||
23 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | ||
24 | |||
25 | tmp = ldl_p(mem_buf); | ||
26 | |||
27 | - /* Mask out low bit of PC to workaround gdb bugs. This will probably | ||
28 | - cause problems if we ever implement the Jazelle DBX extensions. */ | ||
29 | + /* | ||
30 | + * Mask out low bits of PC to workaround gdb bugs. | ||
31 | + * This avoids an assert in thumb_tr_translate_insn, because it is | ||
32 | + * architecturally impossible to misalign the pc. | ||
33 | + * This will probably cause problems if we ever implement the | ||
34 | + * Jazelle DBX extensions. | ||
35 | + */ | ||
36 | if (n == 15) { | ||
37 | tmp &= ~1; | ||
38 | } | ||
39 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/machine.c | ||
42 | +++ b/target/arm/machine.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) | ||
44 | return -1; | ||
45 | } | ||
46 | } | ||
47 | + | ||
48 | + /* | ||
49 | + * Misaligned thumb pc is architecturally impossible. | ||
50 | + * We have an assert in thumb_tr_translate_insn to verify this. | ||
51 | + * Fail an incoming migrate to avoid this assert. | ||
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 | } | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 60 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
15 | index XXXXXXX..XXXXXXX 100644 | 61 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 62 | --- a/target/arm/translate.c |
17 | +++ b/target/arm/translate.c | 63 | +++ b/target/arm/translate.c |
18 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | 64 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
19 | /* Force a TB lookup after an instruction that changes the CPU state. */ | 65 | uint32_t insn; |
20 | static inline void gen_lookup_tb(DisasContext *s) | 66 | bool is_16bit; |
21 | { | 67 | |
22 | - tcg_gen_movi_i32(cpu_R[15], s->pc & ~1); | 68 | + /* Misaligned thumb PC is architecturally impossible. */ |
23 | + tcg_gen_movi_i32(cpu_R[15], s->pc); | 69 | + assert((dc->base.pc_next & 1) == 0); |
24 | s->base.is_jmp = DISAS_EXIT; | 70 | + |
25 | } | 71 | if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { |
26 | 72 | dc->base.pc_next = pc + 2; | |
27 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 73 | return; |
28 | * self-modifying code correctly and also to take | ||
29 | * any pending interrupts immediately. | ||
30 | */ | ||
31 | - gen_goto_tb(s, 0, s->pc & ~1); | ||
32 | + gen_goto_tb(s, 0, s->pc); | ||
33 | return; | ||
34 | case 7: /* sb */ | ||
35 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | ||
36 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
37 | * for TCG; MB and end the TB instead. | ||
38 | */ | ||
39 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
40 | - gen_goto_tb(s, 0, s->pc & ~1); | ||
41 | + gen_goto_tb(s, 0, s->pc); | ||
42 | return; | ||
43 | default: | ||
44 | goto illegal_op; | ||
45 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
46 | * and also to take any pending interrupts | ||
47 | * immediately. | ||
48 | */ | ||
49 | - gen_goto_tb(s, 0, s->pc & ~1); | ||
50 | + gen_goto_tb(s, 0, s->pc); | ||
51 | break; | ||
52 | case 7: /* sb */ | ||
53 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | ||
54 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
55 | * for TCG; MB and end the TB instead. | ||
56 | */ | ||
57 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
58 | - gen_goto_tb(s, 0, s->pc & ~1); | ||
59 | + gen_goto_tb(s, 0, s->pc); | ||
60 | break; | ||
61 | default: | ||
62 | goto illegal_op; | ||
63 | -- | 74 | -- |
64 | 2.20.1 | 75 | 2.25.1 |
65 | 76 | ||
66 | 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 | Promote this function from aarch64 to fully general use. | 3 | Both single-step and pc alignment faults have priority over |
4 | Use it to unify the code sequences for generating illegal | 4 | breakpoint exceptions. |
5 | opcode exceptions. | ||
6 | 5 | ||
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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190807045335.1361-11-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 9 | --- |
13 | target/arm/translate-a64.h | 2 -- | 10 | target/arm/debug_helper.c | 23 +++++++++++++++++++++++ |
14 | target/arm/translate.h | 2 ++ | 11 | 1 file changed, 23 insertions(+) |
15 | target/arm/translate-a64.c | 7 ------- | ||
16 | target/arm/translate-vfp.inc.c | 3 +-- | ||
17 | target/arm/translate.c | 22 ++++++++++++---------- | ||
18 | 5 files changed, 15 insertions(+), 21 deletions(-) | ||
19 | 12 | ||
20 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | 13 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/translate-a64.h | 15 | --- a/target/arm/debug_helper.c |
23 | +++ b/target/arm/translate-a64.h | 16 | +++ b/target/arm/debug_helper.c |
24 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_breakpoint(CPUState *cs) |
25 | #ifndef TARGET_ARM_TRANSLATE_A64_H | ||
26 | #define TARGET_ARM_TRANSLATE_A64_H | ||
27 | |||
28 | -void unallocated_encoding(DisasContext *s); | ||
29 | - | ||
30 | #define unsupported_encoding(s, insn) \ | ||
31 | do { \ | ||
32 | qemu_log_mask(LOG_UNIMP, \ | ||
33 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/translate.h | ||
36 | +++ b/target/arm/translate.h | ||
37 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasCompare { | ||
38 | bool value_global; | ||
39 | } DisasCompare; | ||
40 | |||
41 | +void unallocated_encoding(DisasContext *s); | ||
42 | + | ||
43 | /* Share the TCG temporaries common between 32 and 64 bit modes. */ | ||
44 | extern TCGv_i32 cpu_NF, cpu_ZF, cpu_CF, cpu_VF; | ||
45 | extern TCGv_i64 cpu_exclusive_addr; | ||
46 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/translate-a64.c | ||
49 | +++ b/target/arm/translate-a64.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) | ||
51 | } | ||
52 | } | ||
53 | |||
54 | -void unallocated_encoding(DisasContext *s) | ||
55 | -{ | ||
56 | - /* Unallocated and reserved encodings are uncategorized */ | ||
57 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
58 | - default_exception_el(s)); | ||
59 | -} | ||
60 | - | ||
61 | static void init_tmp_a64_array(DisasContext *s) | ||
62 | { | 18 | { |
63 | #ifdef CONFIG_DEBUG_TCG | 19 | ARMCPU *cpu = ARM_CPU(cs); |
64 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | 20 | CPUARMState *env = &cpu->env; |
65 | index XXXXXXX..XXXXXXX 100644 | 21 | + target_ulong pc; |
66 | --- a/target/arm/translate-vfp.inc.c | 22 | int n; |
67 | +++ b/target/arm/translate-vfp.inc.c | 23 | |
68 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | 24 | /* |
69 | 25 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_breakpoint(CPUState *cs) | |
70 | if (!s->vfp_enabled && !ignore_vfp_enabled) { | ||
71 | assert(!arm_dc_feature(s, ARM_FEATURE_M)); | ||
72 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
73 | - default_exception_el(s)); | ||
74 | + unallocated_encoding(s); | ||
75 | return false; | 26 | return false; |
76 | } | 27 | } |
77 | 28 | ||
78 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 29 | + /* |
79 | index XXXXXXX..XXXXXXX 100644 | 30 | + * Single-step exceptions have priority over breakpoint exceptions. |
80 | --- a/target/arm/translate.c | 31 | + * If single-step state is active-pending, suppress the bp. |
81 | +++ b/target/arm/translate.c | 32 | + */ |
82 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) | 33 | + if (arm_singlestep_active(env) && !(env->pstate & PSTATE_SS)) { |
83 | s->base.is_jmp = DISAS_NORETURN; | 34 | + return false; |
84 | } | 35 | + } |
85 | |||
86 | +void unallocated_encoding(DisasContext *s) | ||
87 | +{ | ||
88 | + /* Unallocated and reserved encodings are uncategorized */ | ||
89 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
90 | + default_exception_el(s)); | ||
91 | +} | ||
92 | + | 36 | + |
93 | /* Force a TB lookup after an instruction that changes the CPU state. */ | 37 | + /* |
94 | static inline void gen_lookup_tb(DisasContext *s) | 38 | + * PC alignment faults have priority over breakpoint exceptions. |
95 | { | 39 | + */ |
96 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | 40 | + pc = is_a64(env) ? env->pc : env->regs[15]; |
97 | return; | 41 | + if ((is_a64(env) || !env->thumb) && (pc & 3) != 0) { |
98 | } | 42 | + return false; |
99 | 43 | + } | |
100 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | 44 | + |
101 | - default_exception_el(s)); | 45 | + /* |
102 | + unallocated_encoding(s); | 46 | + * Instruction aborts have priority over breakpoint exceptions. |
103 | } | 47 | + * TODO: We would need to look up the page for PC and verify that |
104 | 48 | + * it is present and executable. | |
105 | static inline void gen_add_data_offset(DisasContext *s, unsigned int insn, | 49 | + */ |
106 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | 50 | + |
107 | } | 51 | for (n = 0; n < ARRAY_SIZE(env->cpu_breakpoint); n++) { |
108 | 52 | if (bp_wp_matches(cpu, n, false)) { | |
109 | if (undef) { | 53 | return true; |
110 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
111 | - default_exception_el(s)); | ||
112 | + unallocated_encoding(s); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
117 | break; | ||
118 | default: | ||
119 | illegal_op: | ||
120 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
121 | - default_exception_el(s)); | ||
122 | + unallocated_encoding(s); | ||
123 | break; | ||
124 | } | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | return; | ||
129 | illegal_op: | ||
130 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
131 | - default_exception_el(s)); | ||
132 | + unallocated_encoding(s); | ||
133 | } | ||
134 | |||
135 | static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
136 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
137 | return; | ||
138 | illegal_op: | ||
139 | undef: | ||
140 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
141 | - default_exception_el(s)); | ||
142 | + unallocated_encoding(s); | ||
143 | } | ||
144 | |||
145 | static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | ||
146 | -- | 54 | -- |
147 | 2.20.1 | 55 | 2.25.1 |
148 | 56 | ||
149 | 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 | We currently have 3 different ways of computing the architectural | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | value of "PC" as seen in the ARM ARM. | ||
5 | |||
6 | The value of s->pc has been incremented past the current insn, | ||
7 | but that is all. Thus for a32, PC = s->pc + 4; for t32, PC = s->pc; | ||
8 | for t16, PC = s->pc + 2. These differing computations make it | ||
9 | impossible at present to unify the various code paths. | ||
10 | |||
11 | With the newly introduced s->pc_curr, we can compute the correct | ||
12 | value for all cases, using the formula given in the ARM ARM. | ||
13 | |||
14 | This changes the behaviour for load_reg() and load_reg_var() | ||
15 | when called with reg==15 from a 32-bit Thumb instruction: | ||
16 | previously they would have returned the incorrect value | ||
17 | of pc_curr + 6, and now they will return the architecturally | ||
18 | correct value of PC, which is pc_curr + 4. This will not | ||
19 | affect well-behaved guest software, because all of the places | ||
20 | we call these functions from T32 code are instructions where | ||
21 | using r15 is UNPREDICTABLE. Using the architectural PC value | ||
22 | here is more consistent with the T16 and A32 behaviour. | ||
23 | |||
24 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
27 | Message-id: 20190807045335.1361-4-richard.henderson@linaro.org | ||
28 | [PMM: added commit message note about UNPREDICTABLE T32 cases] | ||
29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
30 | --- | 6 | --- |
31 | target/arm/translate.c | 59 ++++++++++++++++-------------------------- | 7 | tests/tcg/aarch64/pcalign-a64.c | 37 +++++++++++++++++++++++++ |
32 | 1 file changed, 23 insertions(+), 36 deletions(-) | 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 | ||
33 | 14 | ||
34 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/tests/tcg/aarch64/pcalign-a64.c b/tests/tcg/aarch64/pcalign-a64.c |
35 | index XXXXXXX..XXXXXXX 100644 | 16 | new file mode 100644 |
36 | --- a/target/arm/translate.c | 17 | index XXXXXXX..XXXXXXX |
37 | +++ b/target/arm/translate.c | 18 | --- /dev/null |
38 | @@ -XXX,XX +XXX,XX @@ static inline void store_cpu_offset(TCGv_i32 var, int offset) | 19 | +++ b/tests/tcg/aarch64/pcalign-a64.c |
39 | #define store_cpu_field(var, name) \ | 20 | @@ -XXX,XX +XXX,XX @@ |
40 | store_cpu_offset(var, offsetof(CPUARMState, name)) | 21 | +/* Test PC misalignment exception */ |
41 | 22 | + | |
42 | +/* The architectural value of PC. */ | 23 | +#include <assert.h> |
43 | +static uint32_t read_pc(DisasContext *s) | 24 | +#include <signal.h> |
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) | ||
44 | +{ | 31 | +{ |
45 | + return s->pc_curr + (s->thumb ? 4 : 8); | 32 | + assert(info->si_code == BUS_ADRALN); |
33 | + assert(info->si_addr == expected); | ||
34 | + exit(EXIT_SUCCESS); | ||
46 | +} | 35 | +} |
47 | + | 36 | + |
48 | /* Set a variable to the value of a CPU register. */ | 37 | +int main() |
49 | static void load_reg_var(DisasContext *s, TCGv_i32 var, int reg) | 38 | +{ |
50 | { | 39 | + void *tmp; |
51 | if (reg == 15) { | 40 | + |
52 | - uint32_t addr; | 41 | + struct sigaction sa = { |
53 | - /* normally, since we updated PC, we need only to add one insn */ | 42 | + .sa_sigaction = sigbus, |
54 | - if (s->thumb) | 43 | + .sa_flags = SA_SIGINFO |
55 | - addr = (long)s->pc + 2; | 44 | + }; |
56 | - else | 45 | + |
57 | - addr = (long)s->pc + 4; | 46 | + if (sigaction(SIGBUS, &sa, NULL) < 0) { |
58 | - tcg_gen_movi_i32(var, addr); | 47 | + perror("sigaction"); |
59 | + tcg_gen_movi_i32(var, read_pc(s)); | 48 | + return EXIT_FAILURE; |
60 | } else { | 49 | + } |
61 | tcg_gen_mov_i32(var, cpu_R[reg]); | 50 | + |
62 | } | 51 | + asm volatile("adr %0, 1f + 1\n\t" |
63 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 52 | + "str %0, %1\n\t" |
64 | /* branch link and change to thumb (blx <offset>) */ | 53 | + "br %0\n" |
65 | int32_t offset; | 54 | + "1:" |
66 | 55 | + : "=&r"(tmp), "=m"(expected)); | |
67 | - val = (uint32_t)s->pc; | 56 | + abort(); |
68 | tmp = tcg_temp_new_i32(); | 57 | +} |
69 | - tcg_gen_movi_i32(tmp, val); | 58 | diff --git a/tests/tcg/arm/pcalign-a32.c b/tests/tcg/arm/pcalign-a32.c |
70 | + tcg_gen_movi_i32(tmp, s->pc); | 59 | new file mode 100644 |
71 | store_reg(s, 14, tmp); | 60 | index XXXXXXX..XXXXXXX |
72 | /* Sign-extend the 24-bit offset */ | 61 | --- /dev/null |
73 | offset = (((int32_t)insn) << 8) >> 8; | 62 | +++ b/tests/tcg/arm/pcalign-a32.c |
74 | + val = read_pc(s); | 63 | @@ -XXX,XX +XXX,XX @@ |
75 | /* offset * 4 + bit24 * 2 + (thumb bit) */ | 64 | +/* Test PC misalignment exception */ |
76 | val += (offset << 2) | ((insn >> 23) & 2) | 1; | 65 | + |
77 | - /* pipeline offset */ | 66 | +#ifdef __thumb__ |
78 | - val += 4; | 67 | +#error "This test must be compiled for ARM" |
79 | /* protected by ARCH(5); above, near the start of uncond block */ | 68 | +#endif |
80 | gen_bx_im(s, val); | 69 | + |
81 | return; | 70 | +#include <assert.h> |
82 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 71 | +#include <signal.h> |
83 | } else { | 72 | +#include <stdlib.h> |
84 | /* store */ | 73 | +#include <stdio.h> |
85 | if (i == 15) { | 74 | + |
86 | - /* special case: r15 = PC + 8 */ | 75 | +static void *expected; |
87 | - val = (long)s->pc + 4; | 76 | + |
88 | tmp = tcg_temp_new_i32(); | 77 | +static void sigbus(int sig, siginfo_t *info, void *vuc) |
89 | - tcg_gen_movi_i32(tmp, val); | 78 | +{ |
90 | + tcg_gen_movi_i32(tmp, read_pc(s)); | 79 | + assert(info->si_code == BUS_ADRALN); |
91 | } else if (user) { | 80 | + assert(info->si_addr == expected); |
92 | tmp = tcg_temp_new_i32(); | 81 | + exit(EXIT_SUCCESS); |
93 | tmp2 = tcg_const_i32(i); | 82 | +} |
94 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 83 | + |
95 | int32_t offset; | 84 | +int main() |
96 | 85 | +{ | |
97 | /* branch (and link) */ | 86 | + void *tmp; |
98 | - val = (int32_t)s->pc; | 87 | + |
99 | if (insn & (1 << 24)) { | 88 | + struct sigaction sa = { |
100 | tmp = tcg_temp_new_i32(); | 89 | + .sa_sigaction = sigbus, |
101 | - tcg_gen_movi_i32(tmp, val); | 90 | + .sa_flags = SA_SIGINFO |
102 | + tcg_gen_movi_i32(tmp, s->pc); | 91 | + }; |
103 | store_reg(s, 14, tmp); | 92 | + |
104 | } | 93 | + if (sigaction(SIGBUS, &sa, NULL) < 0) { |
105 | offset = sextract32(insn << 2, 0, 26); | 94 | + perror("sigaction"); |
106 | - val += offset + 4; | 95 | + return EXIT_FAILURE; |
107 | - gen_jmp(s, val); | 96 | + } |
108 | + gen_jmp(s, read_pc(s) + offset); | 97 | + |
109 | } | 98 | + asm volatile("adr %0, 1f + 2\n\t" |
110 | break; | 99 | + "str %0, %1\n\t" |
111 | case 0xc: | 100 | + "bx %0\n" |
112 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 101 | + "1:" |
113 | tcg_temp_free_i32(addr); | 102 | + : "=&r"(tmp), "=m"(expected)); |
114 | } else if ((insn & (7 << 5)) == 0) { | 103 | + |
115 | /* Table Branch. */ | 104 | + /* |
116 | - if (rn == 15) { | 105 | + * From v8, it is CONSTRAINED UNPREDICTABLE whether BXWritePC aligns |
117 | - addr = tcg_temp_new_i32(); | 106 | + * the address or not. If so, we can legitimately fall through. |
118 | - tcg_gen_movi_i32(addr, s->pc); | 107 | + */ |
119 | - } else { | 108 | + return EXIT_SUCCESS; |
120 | - addr = load_reg(s, rn); | 109 | +} |
121 | - } | 110 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
122 | + addr = load_reg(s, rn); | 111 | index XXXXXXX..XXXXXXX 100644 |
123 | tmp = load_reg(s, rm); | 112 | --- a/tests/tcg/aarch64/Makefile.target |
124 | tcg_gen_add_i32(addr, addr, tmp); | 113 | +++ b/tests/tcg/aarch64/Makefile.target |
125 | if (insn & (1 << 4)) { | 114 | @@ -XXX,XX +XXX,XX @@ VPATH += $(ARM_SRC) |
126 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 115 | AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 |
127 | } | 116 | VPATH += $(AARCH64_SRC) |
128 | tcg_temp_free_i32(addr); | 117 | |
129 | tcg_gen_shli_i32(tmp, tmp, 1); | 118 | -# Float-convert Tests |
130 | - tcg_gen_addi_i32(tmp, tmp, s->pc); | 119 | -AARCH64_TESTS=fcvt |
131 | + tcg_gen_addi_i32(tmp, tmp, read_pc(s)); | 120 | +# Base architecture tests |
132 | store_reg(s, 15, tmp); | 121 | +AARCH64_TESTS=fcvt pcalign-a64 |
133 | } else { | 122 | |
134 | bool is_lasr = false; | 123 | fcvt: LDFLAGS+=-lm |
135 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 124 | |
136 | tcg_gen_movi_i32(cpu_R[14], s->pc | 1); | 125 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target |
137 | } | 126 | index XXXXXXX..XXXXXXX 100644 |
138 | 127 | --- a/tests/tcg/arm/Makefile.target | |
139 | - offset += s->pc; | 128 | +++ b/tests/tcg/arm/Makefile.target |
140 | + offset += read_pc(s); | 129 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt |
141 | if (insn & (1 << 12)) { | 130 | $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") |
142 | /* b/bl */ | 131 | $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) |
143 | gen_jmp(s, offset); | 132 | |
144 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 133 | +# PC alignment test |
145 | offset |= (insn & (1 << 11)) << 8; | 134 | +ARM_TESTS += pcalign-a32 |
146 | 135 | +pcalign-a32: CFLAGS+=-marm | |
147 | /* jump to the offset */ | 136 | + |
148 | - gen_jmp(s, s->pc + offset); | 137 | ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) |
149 | + gen_jmp(s, read_pc(s) + offset); | 138 | |
150 | } | 139 | # Semihosting smoke test for linux-user |
151 | } else { | ||
152 | /* | ||
153 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
154 | if (insn & (1 << 11)) { | ||
155 | rd = (insn >> 8) & 7; | ||
156 | /* load pc-relative. Bit 1 of PC is ignored. */ | ||
157 | - val = s->pc + 2 + ((insn & 0xff) * 4); | ||
158 | + val = read_pc(s) + ((insn & 0xff) * 4); | ||
159 | val &= ~(uint32_t)2; | ||
160 | addr = tcg_temp_new_i32(); | ||
161 | tcg_gen_movi_i32(addr, val); | ||
162 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
163 | } else { | ||
164 | /* PC. bit 1 is ignored. */ | ||
165 | tmp = tcg_temp_new_i32(); | ||
166 | - tcg_gen_movi_i32(tmp, (s->pc + 2) & ~(uint32_t)2); | ||
167 | + tcg_gen_movi_i32(tmp, read_pc(s) & ~(uint32_t)2); | ||
168 | } | ||
169 | val = (insn & 0xff) * 4; | ||
170 | tcg_gen_addi_i32(tmp, tmp, val); | ||
171 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
172 | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, s->condlabel); | ||
173 | tcg_temp_free_i32(tmp); | ||
174 | offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3; | ||
175 | - val = (uint32_t)s->pc + 2; | ||
176 | - val += offset; | ||
177 | - gen_jmp(s, val); | ||
178 | + gen_jmp(s, read_pc(s) + offset); | ||
179 | break; | ||
180 | |||
181 | case 15: /* IT, nop-hint. */ | ||
182 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
183 | arm_skip_unless(s, cond); | ||
184 | |||
185 | /* jump to the offset */ | ||
186 | - val = (uint32_t)s->pc + 2; | ||
187 | + val = read_pc(s); | ||
188 | offset = ((int32_t)insn << 24) >> 24; | ||
189 | val += offset << 1; | ||
190 | gen_jmp(s, val); | ||
191 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
192 | break; | ||
193 | } | ||
194 | /* unconditional branch */ | ||
195 | - val = (uint32_t)s->pc; | ||
196 | + val = read_pc(s); | ||
197 | offset = ((int32_t)insn << 21) >> 21; | ||
198 | - val += (offset << 1) + 2; | ||
199 | + val += offset << 1; | ||
200 | gen_jmp(s, val); | ||
201 | break; | ||
202 | |||
203 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
204 | /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix */ | ||
205 | uint32_t uoffset = ((int32_t)insn << 21) >> 9; | ||
206 | |||
207 | - tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + uoffset); | ||
208 | + tcg_gen_movi_i32(cpu_R[14], read_pc(s) + uoffset); | ||
209 | } | ||
210 | break; | ||
211 | } | ||
212 | -- | 140 | -- |
213 | 2.20.1 | 141 | 2.25.1 |
214 | 142 | ||
215 | 143 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
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 | } | ||
1 | 11 | ||
12 | In three cases inside this switch, we were then also checking for | ||
13 | "if (b1 >= 2) { goto unknown_op; }". | ||
14 | However, this can never happen, because the 'case' values in each place | ||
15 | are 0x0nn or 0x1nn and the switch will have directed the b1 == (2, 3) | ||
16 | cases to the default already. | ||
17 | |||
18 | This check was added in commit c045af25a52e9 in 2010; the added code | ||
19 | was unnecessary then as well, and was apparently intended only to | ||
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 | ||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
30 | --- | ||
31 | target/i386/tcg/translate.c | 12 +++--------- | ||
32 | 1 file changed, 3 insertions(+), 9 deletions(-) | ||
33 | |||
34 | diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/i386/tcg/translate.c | ||
37 | +++ b/target/i386/tcg/translate.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | ||
39 | case 0x171: /* shift xmm, im */ | ||
40 | case 0x172: | ||
41 | case 0x173: | ||
42 | - if (b1 >= 2) { | ||
43 | - goto unknown_op; | ||
44 | - } | ||
45 | val = x86_ldub_code(env, s); | ||
46 | if (is_xmm) { | ||
47 | tcg_gen_movi_tl(s->T0, val); | ||
48 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | ||
49 | offsetof(CPUX86State, mmx_t0.MMX_L(1))); | ||
50 | op1_offset = offsetof(CPUX86State,mmx_t0); | ||
51 | } | ||
52 | + assert(b1 < 2); | ||
53 | sse_fn_epp = sse_op_table2[((b - 1) & 3) * 8 + | ||
54 | (((modrm >> 3)) & 7)][b1]; | ||
55 | if (!sse_fn_epp) { | ||
56 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | ||
57 | rm = modrm & 7; | ||
58 | reg = ((modrm >> 3) & 7) | REX_R(s); | ||
59 | mod = (modrm >> 6) & 3; | ||
60 | - if (b1 >= 2) { | ||
61 | - goto unknown_op; | ||
62 | - } | ||
63 | |||
64 | + assert(b1 < 2); | ||
65 | sse_fn_epp = sse_op_table6[b].op[b1]; | ||
66 | if (!sse_fn_epp) { | ||
67 | goto unknown_op; | ||
68 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | ||
69 | rm = modrm & 7; | ||
70 | reg = ((modrm >> 3) & 7) | REX_R(s); | ||
71 | mod = (modrm >> 6) & 3; | ||
72 | - if (b1 >= 2) { | ||
73 | - goto unknown_op; | ||
74 | - } | ||
75 | |||
76 | + assert(b1 < 2); | ||
77 | sse_fn_eppi = sse_op_table7[b].op[b1]; | ||
78 | if (!sse_fn_eppi) { | ||
79 | goto unknown_op; | ||
80 | -- | ||
81 | 2.25.1 | ||
82 | |||
83 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
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). | ||
1 | 4 | ||
5 | include/hw/i386/x86.h and include/hw/i386/microvm.h break this rule. | ||
6 | In fact, the include is not required at all, so we can just drop it | ||
7 | from both files. | ||
8 | |||
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 | ||
13 | --- | ||
14 | include/hw/i386/microvm.h | 1 - | ||
15 | include/hw/i386/x86.h | 1 - | ||
16 | 2 files changed, 2 deletions(-) | ||
17 | |||
18 | diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/i386/microvm.h | ||
21 | +++ b/include/hw/i386/microvm.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #ifndef HW_I386_MICROVM_H | ||
24 | #define HW_I386_MICROVM_H | ||
25 | |||
26 | -#include "qemu-common.h" | ||
27 | #include "exec/hwaddr.h" | ||
28 | #include "qemu/notify.h" | ||
29 | |||
30 | diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/include/hw/i386/x86.h | ||
33 | +++ b/include/hw/i386/x86.h | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | #ifndef HW_I386_X86_H | ||
36 | #define HW_I386_X86_H | ||
37 | |||
38 | -#include "qemu-common.h" | ||
39 | #include "exec/hwaddr.h" | ||
40 | #include "qemu/notify.h" | ||
41 | |||
42 | -- | ||
43 | 2.25.1 | ||
44 | |||
45 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
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). | ||
1 | 4 | ||
5 | Move the include to linux-user/hexagon/cpu_loop.c, which needs it for | ||
6 | the declaration of cpu_exec_step_atomic(). | ||
7 | |||
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 | ||
13 | --- | ||
14 | target/hexagon/cpu.h | 1 - | ||
15 | linux-user/hexagon/cpu_loop.c | 1 + | ||
16 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/hexagon/cpu.h | ||
21 | +++ b/target/hexagon/cpu.h | ||
22 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUHexagonState CPUHexagonState; | ||
23 | |||
24 | #include "fpu/softfloat-types.h" | ||
25 | |||
26 | -#include "qemu-common.h" | ||
27 | #include "exec/cpu-defs.h" | ||
28 | #include "hex_regs.h" | ||
29 | #include "mmvec/mmvec.h" | ||
30 | diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/linux-user/hexagon/cpu_loop.c | ||
33 | +++ b/linux-user/hexagon/cpu_loop.c | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | */ | ||
36 | |||
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" | ||
42 | -- | ||
43 | 2.25.1 | ||
44 | |||
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 | Separate shift + extract low will result in one extra insn | 5 | Nothing actually relies on target/rx/cpu.h including it, so we can |
4 | for hosts like RISC-V, MIPS, and Sparc. | 6 | just drop the include. |
5 | 7 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190808202616.13782-8-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | 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 | ||
10 | --- | 14 | --- |
11 | target/arm/translate.c | 18 ++++++------------ | 15 | target/rx/cpu.h | 1 - |
12 | 1 file changed, 6 insertions(+), 12 deletions(-) | 16 | 1 file changed, 1 deletion(-) |
13 | 17 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 18 | diff --git a/target/rx/cpu.h b/target/rx/cpu.h |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 20 | --- a/target/rx/cpu.h |
17 | +++ b/target/arm/translate.c | 21 | +++ b/target/rx/cpu.h |
18 | @@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn) | 22 | @@ -XXX,XX +XXX,XX @@ |
19 | if (insn & ARM_CP_RW_BIT) { /* TMRRC */ | 23 | #define RX_CPU_H |
20 | iwmmxt_load_reg(cpu_V0, wrd); | 24 | |
21 | tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0); | 25 | #include "qemu/bitops.h" |
22 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | 26 | -#include "qemu-common.h" |
23 | - tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0); | 27 | #include "hw/registerfields.h" |
24 | + tcg_gen_extrh_i64_i32(cpu_R[rdhi], cpu_V0); | 28 | #include "cpu-qom.h" |
25 | } else { /* TMCRR */ | ||
26 | tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]); | ||
27 | iwmmxt_store_reg(cpu_V0, wrd); | ||
28 | @@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) | ||
29 | if (insn & ARM_CP_RW_BIT) { /* MRA */ | ||
30 | iwmmxt_load_reg(cpu_V0, acc); | ||
31 | tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0); | ||
32 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | ||
33 | - tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0); | ||
34 | + tcg_gen_extrh_i64_i32(cpu_R[rdhi], cpu_V0); | ||
35 | tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1); | ||
36 | } else { /* MAR */ | ||
37 | tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]); | ||
38 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
39 | gen_helper_neon_narrow_high_u16(tmp, cpu_V0); | ||
40 | break; | ||
41 | case 2: | ||
42 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | ||
43 | - tcg_gen_extrl_i64_i32(tmp, cpu_V0); | ||
44 | + tcg_gen_extrh_i64_i32(tmp, cpu_V0); | ||
45 | break; | ||
46 | default: abort(); | ||
47 | } | ||
48 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
49 | break; | ||
50 | case 2: | ||
51 | tcg_gen_addi_i64(cpu_V0, cpu_V0, 1u << 31); | ||
52 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | ||
53 | - tcg_gen_extrl_i64_i32(tmp, cpu_V0); | ||
54 | + tcg_gen_extrh_i64_i32(tmp, cpu_V0); | ||
55 | break; | ||
56 | default: abort(); | ||
57 | } | ||
58 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
59 | tmp = tcg_temp_new_i32(); | ||
60 | tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
61 | store_reg(s, rt, tmp); | ||
62 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | ||
63 | tmp = tcg_temp_new_i32(); | ||
64 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
65 | + tcg_gen_extrh_i64_i32(tmp, tmp64); | ||
66 | tcg_temp_free_i64(tmp64); | ||
67 | store_reg(s, rt2, tmp); | ||
68 | } else { | ||
69 | @@ -XXX,XX +XXX,XX @@ static void gen_storeq_reg(DisasContext *s, int rlow, int rhigh, TCGv_i64 val) | ||
70 | tcg_gen_extrl_i64_i32(tmp, val); | ||
71 | store_reg(s, rlow, tmp); | ||
72 | tmp = tcg_temp_new_i32(); | ||
73 | - tcg_gen_shri_i64(val, val, 32); | ||
74 | - tcg_gen_extrl_i64_i32(tmp, val); | ||
75 | + tcg_gen_extrh_i64_i32(tmp, val); | ||
76 | store_reg(s, rhigh, tmp); | ||
77 | } | ||
78 | 29 | ||
79 | -- | 30 | -- |
80 | 2.20.1 | 31 | 2.25.1 |
81 | 32 | ||
82 | 33 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.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 | A couple return -EINVAL's forgot their '-'s. | 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: Andrew Jones <drjones@redhat.com> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.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/kvm64.c | 4 ++-- | 14 | hw/arm/boot.c | 1 - |
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | 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/kvm64.c b/target/arm/kvm64.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/kvm64.c | 26 | --- a/hw/arm/boot.c |
16 | +++ b/target/arm/kvm64.c | 27 | +++ b/hw/arm/boot.c |
17 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | 28 | @@ -XXX,XX +XXX,XX @@ |
18 | write_cpustate_to_list(cpu, true); | 29 | */ |
19 | 30 | ||
20 | if (!write_list_to_kvmstate(cpu, level)) { | 31 | #include "qemu/osdep.h" |
21 | - return EINVAL; | 32 | -#include "qemu-common.h" |
22 | + return -EINVAL; | 33 | #include "qemu/datadir.h" |
23 | } | 34 | #include "qemu/error-report.h" |
24 | 35 | #include "qapi/error.h" | |
25 | kvm_arm_sync_mpstate_to_kvm(cpu); | 36 | diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c |
26 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | 37 | index XXXXXXX..XXXXXXX 100644 |
27 | } | 38 | --- a/hw/arm/digic_boards.c |
28 | 39 | +++ b/hw/arm/digic_boards.c | |
29 | if (!write_kvmstate_to_list(cpu)) { | 40 | @@ -XXX,XX +XXX,XX @@ |
30 | - return EINVAL; | 41 | |
31 | + return -EINVAL; | 42 | #include "qemu/osdep.h" |
32 | } | 43 | #include "qapi/error.h" |
33 | /* Note that it's OK to have registers which aren't in CPUState, | 44 | -#include "qemu-common.h" |
34 | * so we can ignore a failure return here. | 45 | #include "qemu/datadir.h" |
46 | #include "hw/boards.h" | ||
47 | #include "qemu/error-report.h" | ||
48 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/arm/highbank.c | ||
51 | +++ b/hw/arm/highbank.c | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | */ | ||
54 | |||
55 | #include "qemu/osdep.h" | ||
56 | -#include "qemu-common.h" | ||
57 | #include "qemu/datadir.h" | ||
58 | #include "qapi/error.h" | ||
59 | #include "hw/sysbus.h" | ||
60 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/arm/npcm7xx_boards.c | ||
63 | +++ b/hw/arm/npcm7xx_boards.c | ||
64 | @@ -XXX,XX +XXX,XX @@ | ||
65 | #include "hw/qdev-core.h" | ||
66 | #include "hw/qdev-properties.h" | ||
67 | #include "qapi/error.h" | ||
68 | -#include "qemu-common.h" | ||
69 | #include "qemu/datadir.h" | ||
70 | #include "qemu/units.h" | ||
71 | #include "sysemu/blockdev.h" | ||
72 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/hw/arm/sbsa-ref.c | ||
75 | +++ b/hw/arm/sbsa-ref.c | ||
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" | ||
35 | -- | 120 | -- |
36 | 2.20.1 | 121 | 2.25.1 |
37 | 122 | ||
38 | 123 | diff view generated by jsdifflib |
1 | When generating an architectural single-step exception we were | 1 | The calculation of the length of TLB range invalidate operations |
---|---|---|---|
2 | routing it to the "default exception level", which is to say | 2 | in tlbi_aa64_range_get_length() is incorrect in two ways: |
3 | the same exception level we execute at except that EL0 exceptions | 3 | * the NUM field is 5 bits, but we read only 4 bits |
4 | go to EL1. This is incorrect because the debug exception level | 4 | * we miscalculate the page_shift value, because of an |
5 | can be configured by the guest for situations such as single | 5 | off-by-one error: |
6 | stepping of EL0 and EL1 code by EL2. | 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 | ||
7 | 11 | ||
8 | We have to track the target debug exception level in the TB | 12 | Thanks to the bug report submitter Cha HyunSoo for identifying |
9 | flags, because it is dependent on CPU state like HCR_EL2.TGE | 13 | both these errors. |
10 | and MDCR_EL2.TDE. (That we were previously calling the | ||
11 | arm_debug_target_el() function to determine dc->ss_same_el | ||
12 | is itself a bug, though one that would only have manifested | ||
13 | as incorrect syndrome information.) Since we are out of TB | ||
14 | flag bits unless we want to expand into the cs_base field, | ||
15 | we share some bits with the M-profile only HANDLER and | ||
16 | STACKCHECK bits, since only A-profile has this singlestep. | ||
17 | 14 | ||
18 | Fixes: https://bugs.launchpad.net/qemu/+bug/1838913 | 15 | Fixes: 84940ed82552d3c ("target/arm: Add support for FEAT_TLBIRANGE") |
16 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/734 | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 19 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
21 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
22 | Message-id: 20190805130952.4415-3-peter.maydell@linaro.org | 21 | Message-id: 20211130173257.1274194-1-peter.maydell@linaro.org |
23 | --- | 22 | --- |
24 | target/arm/cpu.h | 5 +++++ | 23 | target/arm/helper.c | 6 +++--- |
25 | target/arm/translate.h | 15 +++++++++++---- | 24 | 1 file changed, 3 insertions(+), 3 deletions(-) |
26 | target/arm/helper.c | 6 ++++++ | ||
27 | target/arm/translate-a64.c | 2 +- | ||
28 | target/arm/translate.c | 4 +++- | ||
29 | 5 files changed, 26 insertions(+), 6 deletions(-) | ||
30 | 25 | ||
31 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/cpu.h | ||
34 | +++ b/target/arm/cpu.h | ||
35 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) | ||
36 | /* Target EL if we take a floating-point-disabled exception */ | ||
37 | FIELD(TBFLAG_ANY, FPEXC_EL, 24, 2) | ||
38 | FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | ||
39 | +/* | ||
40 | + * For A-profile only, target EL for debug exceptions. | ||
41 | + * Note that this overlaps with the M-profile-only HANDLER and STACKCHECK bits. | ||
42 | + */ | ||
43 | +FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 21, 2) | ||
44 | |||
45 | /* Bit usage when in AArch32 state: */ | ||
46 | FIELD(TBFLAG_A32, THUMB, 0, 1) | ||
47 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/translate.h | ||
50 | +++ b/target/arm/translate.h | ||
51 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
52 | uint32_t svc_imm; | ||
53 | int aarch64; | ||
54 | int current_el; | ||
55 | + /* Debug target exception level for single-step exceptions */ | ||
56 | + int debug_target_el; | ||
57 | GHashTable *cp_regs; | ||
58 | uint64_t features; /* CPU features bits */ | ||
59 | /* Because unallocated encodings generate different exception syndrome | ||
60 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
61 | * ie A64 LDX*, LDAX*, A32/T32 LDREX*, LDAEX*. | ||
62 | */ | ||
63 | bool is_ldex; | ||
64 | - /* True if a single-step exception will be taken to the current EL */ | ||
65 | - bool ss_same_el; | ||
66 | /* True if v8.3-PAuth is active. */ | ||
67 | bool pauth_active; | ||
68 | /* True with v8.5-BTI and SCTLR_ELx.BT* set. */ | ||
69 | @@ -XXX,XX +XXX,XX @@ static inline void gen_exception(int excp, uint32_t syndrome, | ||
70 | /* Generate an architectural singlestep exception */ | ||
71 | static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) | ||
72 | { | ||
73 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, isv, ex), | ||
74 | - default_exception_el(s)); | ||
75 | + bool same_el = (s->debug_target_el == s->current_el); | ||
76 | + | ||
77 | + /* | ||
78 | + * If singlestep is targeting a lower EL than the current one, | ||
79 | + * then s->ss_active must be false and we can never get here. | ||
80 | + */ | ||
81 | + assert(s->debug_target_el >= s->current_el); | ||
82 | + | ||
83 | + gen_exception(EXCP_UDEF, syn_swstep(same_el, isv, ex), s->debug_target_el); | ||
84 | } | ||
85 | |||
86 | /* | ||
87 | 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 |
88 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
89 | --- a/target/arm/helper.c | 28 | --- a/target/arm/helper.c |
90 | +++ b/target/arm/helper.c | 29 | +++ b/target/arm/helper.c |
91 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 30 | @@ -XXX,XX +XXX,XX @@ static uint64_t tlbi_aa64_range_get_length(CPUARMState *env, |
92 | } | 31 | uint64_t exponent; |
32 | uint64_t length; | ||
33 | |||
34 | - num = extract64(value, 39, 4); | ||
35 | + num = extract64(value, 39, 5); | ||
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; | ||
93 | } | 45 | } |
94 | 46 | ||
95 | + if (!arm_feature(env, ARM_FEATURE_M)) { | 47 | + page_shift = (page_size_granule - 1) * 2 + 12; |
96 | + int target_el = arm_debug_target_el(env); | ||
97 | + | 48 | + |
98 | + flags = FIELD_DP32(flags, TBFLAG_ANY, DEBUG_TARGET_EL, target_el); | 49 | exponent = (5 * scale) + 1; |
99 | + } | 50 | length = (num + 1) << (exponent + page_shift); |
100 | + | ||
101 | *pflags = flags; | ||
102 | *cs_base = 0; | ||
103 | } | ||
104 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | --- a/target/arm/translate-a64.c | ||
107 | +++ b/target/arm/translate-a64.c | ||
108 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
109 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | ||
110 | dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | ||
111 | dc->is_ldex = false; | ||
112 | - dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el); | ||
113 | + dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | ||
114 | |||
115 | /* Bound the number of insns to execute to those left on the page. */ | ||
116 | bound = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; | ||
117 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/target/arm/translate.c | ||
120 | +++ b/target/arm/translate.c | ||
121 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
122 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | ||
123 | dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | ||
124 | dc->is_ldex = false; | ||
125 | - dc->ss_same_el = false; /* Can't be true since EL_d must be AArch64 */ | ||
126 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
127 | + dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | ||
128 | + } | ||
129 | |||
130 | dc->page_start = dc->base.pc_first & TARGET_PAGE_MASK; | ||
131 | 51 | ||
132 | -- | 52 | -- |
133 | 2.20.1 | 53 | 2.25.1 |
134 | 54 | ||
135 | 55 | diff view generated by jsdifflib |
1 | Factor out code to 'generate a singlestep exception', which is | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | currently repeated in four places. | ||
3 | 2 | ||
4 | To do this we need to also pull the identical copies of the | 3 | The rx_active boolean change to true should always trigger a try_read |
5 | gen-exception() function out of translate-a64.c and translate.c | 4 | call that flushes the queue. |
6 | into translate.h. | ||
7 | 5 | ||
8 | (There is a bug in the code: we're taking the exception to the wrong | 6 | Signed-off-by: Patrick Venture <venture@google.com> |
9 | target EL. This will be simpler to fix if there's only one place to | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
10 | do it.) | 8 | Message-id: 20211203221002.1719306-1-venture@google.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/net/npcm7xx_emc.c | 18 ++++++++---------- | ||
12 | 1 file changed, 8 insertions(+), 10 deletions(-) | ||
11 | 13 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c |
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Message-id: 20190805130952.4415-2-peter.maydell@linaro.org | ||
16 | --- | ||
17 | target/arm/translate.h | 23 +++++++++++++++++++++++ | ||
18 | target/arm/translate-a64.c | 19 ++----------------- | ||
19 | target/arm/translate.c | 20 ++------------------ | ||
20 | 3 files changed, 27 insertions(+), 35 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate.h | 16 | --- a/hw/net/npcm7xx_emc.c |
25 | +++ b/target/arm/translate.h | 17 | +++ b/hw/net/npcm7xx_emc.c |
26 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void emc_halt_rx(NPCM7xxEMCState *emc, uint32_t mista_flag) |
27 | #define TARGET_ARM_TRANSLATE_H | 19 | emc_set_mista(emc, mista_flag); |
28 | |||
29 | #include "exec/translator.h" | ||
30 | +#include "internals.h" | ||
31 | |||
32 | |||
33 | /* internal defines */ | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline void gen_ss_advance(DisasContext *s) | ||
35 | } | ||
36 | } | 20 | } |
37 | 21 | ||
38 | +static inline void gen_exception(int excp, uint32_t syndrome, | 22 | +static void emc_enable_rx_and_flush(NPCM7xxEMCState *emc) |
39 | + uint32_t target_el) | ||
40 | +{ | 23 | +{ |
41 | + TCGv_i32 tcg_excp = tcg_const_i32(excp); | 24 | + emc->rx_active = true; |
42 | + TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | 25 | + qemu_flush_queued_packets(qemu_get_queue(emc->nic)); |
43 | + TCGv_i32 tcg_el = tcg_const_i32(target_el); | ||
44 | + | ||
45 | + gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
46 | + tcg_syn, tcg_el); | ||
47 | + | ||
48 | + tcg_temp_free_i32(tcg_el); | ||
49 | + tcg_temp_free_i32(tcg_syn); | ||
50 | + tcg_temp_free_i32(tcg_excp); | ||
51 | +} | 26 | +} |
52 | + | 27 | + |
53 | +/* Generate an architectural singlestep exception */ | 28 | static void emc_set_next_tx_descriptor(NPCM7xxEMCState *emc, |
54 | +static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) | 29 | const NPCM7xxEMCTxDesc *tx_desc, |
55 | +{ | 30 | uint32_t desc_addr) |
56 | + gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, isv, ex), | 31 | @@ -XXX,XX +XXX,XX @@ static ssize_t emc_receive(NetClientState *nc, const uint8_t *buf, size_t len1) |
57 | + default_exception_el(s)); | 32 | return len; |
58 | +} | ||
59 | + | ||
60 | /* | ||
61 | * Given a VFP floating point constant encoded into an 8 bit immediate in an | ||
62 | * instruction, expand it to the actual constant value of the specified | ||
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 @@ static void gen_exception_internal(int excp) | ||
68 | tcg_temp_free_i32(tcg_excp); | ||
69 | } | 33 | } |
70 | 34 | ||
71 | -static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) | 35 | -static void emc_try_receive_next_packet(NPCM7xxEMCState *emc) |
72 | -{ | 36 | -{ |
73 | - TCGv_i32 tcg_excp = tcg_const_i32(excp); | 37 | - if (emc_can_receive(qemu_get_queue(emc->nic))) { |
74 | - TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | 38 | - qemu_flush_queued_packets(qemu_get_queue(emc->nic)); |
75 | - TCGv_i32 tcg_el = tcg_const_i32(target_el); | 39 | - } |
76 | - | ||
77 | - gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
78 | - tcg_syn, tcg_el); | ||
79 | - tcg_temp_free_i32(tcg_el); | ||
80 | - tcg_temp_free_i32(tcg_syn); | ||
81 | - tcg_temp_free_i32(tcg_excp); | ||
82 | -} | 40 | -} |
83 | - | 41 | - |
84 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 42 | static uint64_t npcm7xx_emc_read(void *opaque, hwaddr offset, unsigned size) |
85 | { | 43 | { |
86 | gen_a64_set_pc_im(s->pc - offset); | 44 | NPCM7xxEMCState *emc = opaque; |
87 | @@ -XXX,XX +XXX,XX @@ static void gen_step_complete_exception(DisasContext *s) | 45 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, |
88 | * of the exception, and our syndrome information is always correct. | 46 | emc->regs[REG_MGSTA] |= REG_MGSTA_RXHA; |
89 | */ | 47 | } |
90 | gen_ss_advance(s); | 48 | if (value & REG_MCMDR_RXON) { |
91 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex), | 49 | - emc->rx_active = true; |
92 | - default_exception_el(s)); | 50 | + emc_enable_rx_and_flush(emc); |
93 | + gen_swstep_exception(s, 1, s->is_ldex); | 51 | } else { |
94 | s->base.is_jmp = DISAS_NORETURN; | 52 | emc_halt_rx(emc, 0); |
95 | } | 53 | } |
96 | 54 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, | |
97 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 55 | break; |
98 | * bits should be zero. | 56 | case REG_RSDR: |
99 | */ | 57 | if (emc->regs[REG_MCMDR] & REG_MCMDR_RXON) { |
100 | assert(dc->base.num_insns == 1); | 58 | - emc->rx_active = true; |
101 | - gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), | 59 | - emc_try_receive_next_packet(emc); |
102 | - default_exception_el(dc)); | 60 | + emc_enable_rx_and_flush(emc); |
103 | + gen_swstep_exception(dc, 0, 0); | 61 | } |
104 | dc->base.is_jmp = DISAS_NORETURN; | 62 | break; |
105 | } else { | 63 | case REG_MIIDA: |
106 | disas_a64_insn(env, dc); | ||
107 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/translate.c | ||
110 | +++ b/target/arm/translate.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | ||
112 | tcg_temp_free_i32(tcg_excp); | ||
113 | } | ||
114 | |||
115 | -static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) | ||
116 | -{ | ||
117 | - TCGv_i32 tcg_excp = tcg_const_i32(excp); | ||
118 | - TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | ||
119 | - TCGv_i32 tcg_el = tcg_const_i32(target_el); | ||
120 | - | ||
121 | - gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
122 | - tcg_syn, tcg_el); | ||
123 | - | ||
124 | - tcg_temp_free_i32(tcg_el); | ||
125 | - tcg_temp_free_i32(tcg_syn); | ||
126 | - tcg_temp_free_i32(tcg_excp); | ||
127 | -} | ||
128 | - | ||
129 | static void gen_step_complete_exception(DisasContext *s) | ||
130 | { | ||
131 | /* We just completed step of an insn. Move from Active-not-pending | ||
132 | @@ -XXX,XX +XXX,XX @@ static void gen_step_complete_exception(DisasContext *s) | ||
133 | * of the exception, and our syndrome information is always correct. | ||
134 | */ | ||
135 | gen_ss_advance(s); | ||
136 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex), | ||
137 | - default_exception_el(s)); | ||
138 | + gen_swstep_exception(s, 1, s->is_ldex); | ||
139 | s->base.is_jmp = DISAS_NORETURN; | ||
140 | } | ||
141 | |||
142 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) | ||
143 | * bits should be zero. | ||
144 | */ | ||
145 | assert(dc->base.num_insns == 1); | ||
146 | - gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), | ||
147 | - default_exception_el(dc)); | ||
148 | + gen_swstep_exception(dc, 0, 0); | ||
149 | dc->base.is_jmp = DISAS_NORETURN; | ||
150 | return true; | ||
151 | } | ||
152 | -- | 64 | -- |
153 | 2.20.1 | 65 | 2.25.1 |
154 | 66 | ||
155 | 67 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Move the getting/putting of the fpsimd registers out of | 3 | When a virtio-iommu is instantiated, describe it using the ACPI VIOT |
4 | kvm_arch_get/put_registers() into their own helper functions | 4 | table. |
5 | to prepare for alternatively getting/putting SVE registers. | ||
6 | 5 | ||
7 | No functional change. | 6 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
8 | |||
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
9 | Message-id: 20211210170415.583179-2-jean-philippe@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | target/arm/kvm64.c | 148 +++++++++++++++++++++++++++------------------ | 12 | hw/arm/virt-acpi-build.c | 7 +++++++ |
15 | 1 file changed, 88 insertions(+), 60 deletions(-) | 13 | hw/arm/Kconfig | 1 + |
14 | 2 files changed, 8 insertions(+) | ||
16 | 15 | ||
17 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 16 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/kvm64.c | 18 | --- a/hw/arm/virt-acpi-build.c |
20 | +++ b/target/arm/kvm64.c | 19 | +++ b/hw/arm/virt-acpi-build.c |
21 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_cpreg_level(uint64_t regidx) | 20 | @@ -XXX,XX +XXX,XX @@ |
22 | #define AARCH64_SIMD_CTRL_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U32 | \ | 21 | #include "kvm_arm.h" |
23 | KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) | 22 | #include "migration/vmstate.h" |
24 | 23 | #include "hw/acpi/ghes.h" | |
25 | +static int kvm_arch_put_fpsimd(CPUState *cs) | 24 | +#include "hw/acpi/viot.h" |
26 | +{ | 25 | |
27 | + ARMCPU *cpu = ARM_CPU(cs); | 26 | #define ARM_SPI_BASE 32 |
28 | + CPUARMState *env = &cpu->env; | 27 | |
29 | + struct kvm_one_reg reg; | 28 | @@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) |
30 | + uint32_t fpr; | 29 | } |
31 | + int i, ret; | 30 | #endif |
32 | + | 31 | |
33 | + for (i = 0; i < 32; i++) { | 32 | + if (vms->iommu == VIRT_IOMMU_VIRTIO) { |
34 | + uint64_t *q = aa64_vfp_qreg(env, i); | 33 | + acpi_add_table(table_offsets, tables_blob); |
35 | +#ifdef HOST_WORDS_BIGENDIAN | 34 | + build_viot(ms, tables_blob, tables->linker, vms->virtio_iommu_bdf, |
36 | + uint64_t fp_val[2] = { q[1], q[0] }; | 35 | + vms->oem_id, vms->oem_table_id); |
37 | + reg.addr = (uintptr_t)fp_val; | ||
38 | +#else | ||
39 | + reg.addr = (uintptr_t)q; | ||
40 | +#endif | ||
41 | + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
42 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
43 | + if (ret) { | ||
44 | + return ret; | ||
45 | + } | ||
46 | + } | 36 | + } |
47 | + | 37 | + |
48 | + reg.addr = (uintptr_t)(&fpr); | 38 | /* XSDT is pointed to by RSDP */ |
49 | + fpr = vfp_get_fpsr(env); | 39 | xsdt = tables_blob->len; |
50 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | 40 | build_xsdt(tables_blob, tables->linker, table_offsets, vms->oem_id, |
51 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | 41 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
52 | + if (ret) { | 42 | index XXXXXXX..XXXXXXX 100644 |
53 | + return ret; | 43 | --- a/hw/arm/Kconfig |
54 | + } | 44 | +++ b/hw/arm/Kconfig |
55 | + | 45 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT |
56 | + reg.addr = (uintptr_t)(&fpr); | 46 | select DIMM |
57 | + fpr = vfp_get_fpcr(env); | 47 | select ACPI_HW_REDUCED |
58 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | 48 | select ACPI_APEI |
59 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | 49 | + select ACPI_VIOT |
60 | + if (ret) { | 50 | |
61 | + return ret; | 51 | config CHEETAH |
62 | + } | 52 | bool |
63 | + | ||
64 | + return 0; | ||
65 | +} | ||
66 | + | ||
67 | int kvm_arch_put_registers(CPUState *cs, int level) | ||
68 | { | ||
69 | struct kvm_one_reg reg; | ||
70 | - uint32_t fpr; | ||
71 | uint64_t val; | ||
72 | - int i; | ||
73 | - int ret; | ||
74 | + int i, ret; | ||
75 | unsigned int el; | ||
76 | |||
77 | ARMCPU *cpu = ARM_CPU(cs); | ||
78 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
79 | } | ||
80 | } | ||
81 | |||
82 | - /* Advanced SIMD and FP registers. */ | ||
83 | - for (i = 0; i < 32; i++) { | ||
84 | - uint64_t *q = aa64_vfp_qreg(env, i); | ||
85 | -#ifdef HOST_WORDS_BIGENDIAN | ||
86 | - uint64_t fp_val[2] = { q[1], q[0] }; | ||
87 | - reg.addr = (uintptr_t)fp_val; | ||
88 | -#else | ||
89 | - reg.addr = (uintptr_t)q; | ||
90 | -#endif | ||
91 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
92 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
93 | - if (ret) { | ||
94 | - return ret; | ||
95 | - } | ||
96 | - } | ||
97 | - | ||
98 | - reg.addr = (uintptr_t)(&fpr); | ||
99 | - fpr = vfp_get_fpsr(env); | ||
100 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
101 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
102 | - if (ret) { | ||
103 | - return ret; | ||
104 | - } | ||
105 | - | ||
106 | - fpr = vfp_get_fpcr(env); | ||
107 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
108 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
109 | + ret = kvm_arch_put_fpsimd(cs); | ||
110 | if (ret) { | ||
111 | return ret; | ||
112 | } | ||
113 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | +static int kvm_arch_get_fpsimd(CPUState *cs) | ||
118 | +{ | ||
119 | + ARMCPU *cpu = ARM_CPU(cs); | ||
120 | + CPUARMState *env = &cpu->env; | ||
121 | + struct kvm_one_reg reg; | ||
122 | + uint32_t fpr; | ||
123 | + int i, ret; | ||
124 | + | ||
125 | + for (i = 0; i < 32; i++) { | ||
126 | + uint64_t *q = aa64_vfp_qreg(env, i); | ||
127 | + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
128 | + reg.addr = (uintptr_t)q; | ||
129 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
130 | + if (ret) { | ||
131 | + return ret; | ||
132 | + } else { | ||
133 | +#ifdef HOST_WORDS_BIGENDIAN | ||
134 | + uint64_t t; | ||
135 | + t = q[0], q[0] = q[1], q[1] = t; | ||
136 | +#endif | ||
137 | + } | ||
138 | + } | ||
139 | + | ||
140 | + reg.addr = (uintptr_t)(&fpr); | ||
141 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
142 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
143 | + if (ret) { | ||
144 | + return ret; | ||
145 | + } | ||
146 | + vfp_set_fpsr(env, fpr); | ||
147 | + | ||
148 | + reg.addr = (uintptr_t)(&fpr); | ||
149 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
150 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
151 | + if (ret) { | ||
152 | + return ret; | ||
153 | + } | ||
154 | + vfp_set_fpcr(env, fpr); | ||
155 | + | ||
156 | + return 0; | ||
157 | +} | ||
158 | + | ||
159 | int kvm_arch_get_registers(CPUState *cs) | ||
160 | { | ||
161 | struct kvm_one_reg reg; | ||
162 | uint64_t val; | ||
163 | - uint32_t fpr; | ||
164 | unsigned int el; | ||
165 | - int i; | ||
166 | - int ret; | ||
167 | + int i, ret; | ||
168 | |||
169 | ARMCPU *cpu = ARM_CPU(cs); | ||
170 | CPUARMState *env = &cpu->env; | ||
171 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
172 | env->spsr = env->banked_spsr[i]; | ||
173 | } | ||
174 | |||
175 | - /* Advanced SIMD and FP registers */ | ||
176 | - for (i = 0; i < 32; i++) { | ||
177 | - uint64_t *q = aa64_vfp_qreg(env, i); | ||
178 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
179 | - reg.addr = (uintptr_t)q; | ||
180 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
181 | - if (ret) { | ||
182 | - return ret; | ||
183 | - } else { | ||
184 | -#ifdef HOST_WORDS_BIGENDIAN | ||
185 | - uint64_t t; | ||
186 | - t = q[0], q[0] = q[1], q[1] = t; | ||
187 | -#endif | ||
188 | - } | ||
189 | - } | ||
190 | - | ||
191 | - reg.addr = (uintptr_t)(&fpr); | ||
192 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
193 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
194 | + ret = kvm_arch_get_fpsimd(cs); | ||
195 | if (ret) { | ||
196 | return ret; | ||
197 | } | ||
198 | - vfp_set_fpsr(env, fpr); | ||
199 | - | ||
200 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
201 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
202 | - if (ret) { | ||
203 | - return ret; | ||
204 | - } | ||
205 | - vfp_set_fpcr(env, fpr); | ||
206 | |||
207 | ret = kvm_get_vcpu_events(cpu); | ||
208 | if (ret) { | ||
209 | -- | 53 | -- |
210 | 2.20.1 | 54 | 2.25.1 |
211 | 55 | ||
212 | 56 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Replace the zynq_slcr registers enum and macros using the | 3 | virtio-iommu is now supported with ACPI VIOT as well as device tree. |
4 | hw/registerfields.h macros. | 4 | Remove the restriction that prevents from instantiating a virtio-iommu |
5 | device under ACPI. | ||
5 | 6 | ||
6 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | 7 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
9 | Message-id: 20190729145654.14644-30-damien.hedde@greensocs.com | 10 | Message-id: 20211210170415.583179-3-jean-philippe@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 12 | --- |
12 | hw/misc/zynq_slcr.c | 450 ++++++++++++++++++++++---------------------- | 13 | hw/arm/virt.c | 10 ++-------- |
13 | 1 file changed, 225 insertions(+), 225 deletions(-) | 14 | hw/virtio/virtio-iommu-pci.c | 12 ++---------- |
15 | 2 files changed, 4 insertions(+), 18 deletions(-) | ||
14 | 16 | ||
15 | diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c | 17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/misc/zynq_slcr.c | 19 | --- a/hw/arm/virt.c |
18 | +++ b/hw/misc/zynq_slcr.c | 20 | +++ b/hw/arm/virt.c |
19 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, |
20 | #include "sysemu/sysemu.h" | 22 | MachineClass *mc = MACHINE_GET_CLASS(machine); |
21 | #include "qemu/log.h" | 23 | |
22 | #include "qemu/module.h" | 24 | if (device_is_dynamic_sysbus(mc, dev) || |
23 | +#include "hw/registerfields.h" | 25 | - (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { |
24 | 26 | + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || | |
25 | #ifndef ZYNQ_SLCR_ERR_DEBUG | 27 | + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { |
26 | #define ZYNQ_SLCR_ERR_DEBUG 0 | 28 | return HOTPLUG_HANDLER(machine); |
27 | @@ -XXX,XX +XXX,XX @@ | 29 | } |
28 | #define XILINX_LOCK_KEY 0x767b | 30 | - if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { |
29 | #define XILINX_UNLOCK_KEY 0xdf0d | 31 | - VirtMachineState *vms = VIRT_MACHINE(machine); |
30 | |||
31 | -#define R_PSS_RST_CTRL_SOFT_RST 0x1 | ||
32 | +REG32(SCL, 0x000) | ||
33 | +REG32(LOCK, 0x004) | ||
34 | +REG32(UNLOCK, 0x008) | ||
35 | +REG32(LOCKSTA, 0x00c) | ||
36 | |||
37 | -enum { | ||
38 | - SCL = 0x000 / 4, | ||
39 | - LOCK, | ||
40 | - UNLOCK, | ||
41 | - LOCKSTA, | ||
42 | +REG32(ARM_PLL_CTRL, 0x100) | ||
43 | +REG32(DDR_PLL_CTRL, 0x104) | ||
44 | +REG32(IO_PLL_CTRL, 0x108) | ||
45 | +REG32(PLL_STATUS, 0x10c) | ||
46 | +REG32(ARM_PLL_CFG, 0x110) | ||
47 | +REG32(DDR_PLL_CFG, 0x114) | ||
48 | +REG32(IO_PLL_CFG, 0x118) | ||
49 | |||
50 | - ARM_PLL_CTRL = 0x100 / 4, | ||
51 | - DDR_PLL_CTRL, | ||
52 | - IO_PLL_CTRL, | ||
53 | - PLL_STATUS, | ||
54 | - ARM_PLL_CFG, | ||
55 | - DDR_PLL_CFG, | ||
56 | - IO_PLL_CFG, | ||
57 | - | 32 | - |
58 | - ARM_CLK_CTRL = 0x120 / 4, | 33 | - if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { |
59 | - DDR_CLK_CTRL, | 34 | - return HOTPLUG_HANDLER(machine); |
60 | - DCI_CLK_CTRL, | 35 | - } |
61 | - APER_CLK_CTRL, | 36 | - } |
62 | - USB0_CLK_CTRL, | 37 | return NULL; |
63 | - USB1_CLK_CTRL, | ||
64 | - GEM0_RCLK_CTRL, | ||
65 | - GEM1_RCLK_CTRL, | ||
66 | - GEM0_CLK_CTRL, | ||
67 | - GEM1_CLK_CTRL, | ||
68 | - SMC_CLK_CTRL, | ||
69 | - LQSPI_CLK_CTRL, | ||
70 | - SDIO_CLK_CTRL, | ||
71 | - UART_CLK_CTRL, | ||
72 | - SPI_CLK_CTRL, | ||
73 | - CAN_CLK_CTRL, | ||
74 | - CAN_MIOCLK_CTRL, | ||
75 | - DBG_CLK_CTRL, | ||
76 | - PCAP_CLK_CTRL, | ||
77 | - TOPSW_CLK_CTRL, | ||
78 | +REG32(ARM_CLK_CTRL, 0x120) | ||
79 | +REG32(DDR_CLK_CTRL, 0x124) | ||
80 | +REG32(DCI_CLK_CTRL, 0x128) | ||
81 | +REG32(APER_CLK_CTRL, 0x12c) | ||
82 | +REG32(USB0_CLK_CTRL, 0x130) | ||
83 | +REG32(USB1_CLK_CTRL, 0x134) | ||
84 | +REG32(GEM0_RCLK_CTRL, 0x138) | ||
85 | +REG32(GEM1_RCLK_CTRL, 0x13c) | ||
86 | +REG32(GEM0_CLK_CTRL, 0x140) | ||
87 | +REG32(GEM1_CLK_CTRL, 0x144) | ||
88 | +REG32(SMC_CLK_CTRL, 0x148) | ||
89 | +REG32(LQSPI_CLK_CTRL, 0x14c) | ||
90 | +REG32(SDIO_CLK_CTRL, 0x150) | ||
91 | +REG32(UART_CLK_CTRL, 0x154) | ||
92 | +REG32(SPI_CLK_CTRL, 0x158) | ||
93 | +REG32(CAN_CLK_CTRL, 0x15c) | ||
94 | +REG32(CAN_MIOCLK_CTRL, 0x160) | ||
95 | +REG32(DBG_CLK_CTRL, 0x164) | ||
96 | +REG32(PCAP_CLK_CTRL, 0x168) | ||
97 | +REG32(TOPSW_CLK_CTRL, 0x16c) | ||
98 | |||
99 | #define FPGA_CTRL_REGS(n, start) \ | ||
100 | - FPGA ## n ## _CLK_CTRL = (start) / 4, \ | ||
101 | - FPGA ## n ## _THR_CTRL, \ | ||
102 | - FPGA ## n ## _THR_CNT, \ | ||
103 | - FPGA ## n ## _THR_STA, | ||
104 | - FPGA_CTRL_REGS(0, 0x170) | ||
105 | - FPGA_CTRL_REGS(1, 0x180) | ||
106 | - FPGA_CTRL_REGS(2, 0x190) | ||
107 | - FPGA_CTRL_REGS(3, 0x1a0) | ||
108 | + REG32(FPGA ## n ## _CLK_CTRL, (start)) \ | ||
109 | + REG32(FPGA ## n ## _THR_CTRL, (start) + 0x4)\ | ||
110 | + REG32(FPGA ## n ## _THR_CNT, (start) + 0x8)\ | ||
111 | + REG32(FPGA ## n ## _THR_STA, (start) + 0xc) | ||
112 | +FPGA_CTRL_REGS(0, 0x170) | ||
113 | +FPGA_CTRL_REGS(1, 0x180) | ||
114 | +FPGA_CTRL_REGS(2, 0x190) | ||
115 | +FPGA_CTRL_REGS(3, 0x1a0) | ||
116 | |||
117 | - BANDGAP_TRIP = 0x1b8 / 4, | ||
118 | - PLL_PREDIVISOR = 0x1c0 / 4, | ||
119 | - CLK_621_TRUE, | ||
120 | +REG32(BANDGAP_TRIP, 0x1b8) | ||
121 | +REG32(PLL_PREDIVISOR, 0x1c0) | ||
122 | +REG32(CLK_621_TRUE, 0x1c4) | ||
123 | |||
124 | - PSS_RST_CTRL = 0x200 / 4, | ||
125 | - DDR_RST_CTRL, | ||
126 | - TOPSW_RESET_CTRL, | ||
127 | - DMAC_RST_CTRL, | ||
128 | - USB_RST_CTRL, | ||
129 | - GEM_RST_CTRL, | ||
130 | - SDIO_RST_CTRL, | ||
131 | - SPI_RST_CTRL, | ||
132 | - CAN_RST_CTRL, | ||
133 | - I2C_RST_CTRL, | ||
134 | - UART_RST_CTRL, | ||
135 | - GPIO_RST_CTRL, | ||
136 | - LQSPI_RST_CTRL, | ||
137 | - SMC_RST_CTRL, | ||
138 | - OCM_RST_CTRL, | ||
139 | - FPGA_RST_CTRL = 0x240 / 4, | ||
140 | - A9_CPU_RST_CTRL, | ||
141 | +REG32(PSS_RST_CTRL, 0x200) | ||
142 | + FIELD(PSS_RST_CTRL, SOFT_RST, 0, 1) | ||
143 | +REG32(DDR_RST_CTRL, 0x204) | ||
144 | +REG32(TOPSW_RESET_CTRL, 0x208) | ||
145 | +REG32(DMAC_RST_CTRL, 0x20c) | ||
146 | +REG32(USB_RST_CTRL, 0x210) | ||
147 | +REG32(GEM_RST_CTRL, 0x214) | ||
148 | +REG32(SDIO_RST_CTRL, 0x218) | ||
149 | +REG32(SPI_RST_CTRL, 0x21c) | ||
150 | +REG32(CAN_RST_CTRL, 0x220) | ||
151 | +REG32(I2C_RST_CTRL, 0x224) | ||
152 | +REG32(UART_RST_CTRL, 0x228) | ||
153 | +REG32(GPIO_RST_CTRL, 0x22c) | ||
154 | +REG32(LQSPI_RST_CTRL, 0x230) | ||
155 | +REG32(SMC_RST_CTRL, 0x234) | ||
156 | +REG32(OCM_RST_CTRL, 0x238) | ||
157 | +REG32(FPGA_RST_CTRL, 0x240) | ||
158 | +REG32(A9_CPU_RST_CTRL, 0x244) | ||
159 | |||
160 | - RS_AWDT_CTRL = 0x24c / 4, | ||
161 | - RST_REASON, | ||
162 | +REG32(RS_AWDT_CTRL, 0x24c) | ||
163 | +REG32(RST_REASON, 0x250) | ||
164 | |||
165 | - REBOOT_STATUS = 0x258 / 4, | ||
166 | - BOOT_MODE, | ||
167 | +REG32(REBOOT_STATUS, 0x258) | ||
168 | +REG32(BOOT_MODE, 0x25c) | ||
169 | |||
170 | - APU_CTRL = 0x300 / 4, | ||
171 | - WDT_CLK_SEL, | ||
172 | +REG32(APU_CTRL, 0x300) | ||
173 | +REG32(WDT_CLK_SEL, 0x304) | ||
174 | |||
175 | - TZ_DMA_NS = 0x440 / 4, | ||
176 | - TZ_DMA_IRQ_NS, | ||
177 | - TZ_DMA_PERIPH_NS, | ||
178 | +REG32(TZ_DMA_NS, 0x440) | ||
179 | +REG32(TZ_DMA_IRQ_NS, 0x444) | ||
180 | +REG32(TZ_DMA_PERIPH_NS, 0x448) | ||
181 | |||
182 | - PSS_IDCODE = 0x530 / 4, | ||
183 | +REG32(PSS_IDCODE, 0x530) | ||
184 | |||
185 | - DDR_URGENT = 0x600 / 4, | ||
186 | - DDR_CAL_START = 0x60c / 4, | ||
187 | - DDR_REF_START = 0x614 / 4, | ||
188 | - DDR_CMD_STA, | ||
189 | - DDR_URGENT_SEL, | ||
190 | - DDR_DFI_STATUS, | ||
191 | +REG32(DDR_URGENT, 0x600) | ||
192 | +REG32(DDR_CAL_START, 0x60c) | ||
193 | +REG32(DDR_REF_START, 0x614) | ||
194 | +REG32(DDR_CMD_STA, 0x618) | ||
195 | +REG32(DDR_URGENT_SEL, 0x61c) | ||
196 | +REG32(DDR_DFI_STATUS, 0x620) | ||
197 | |||
198 | - MIO = 0x700 / 4, | ||
199 | +REG32(MIO, 0x700) | ||
200 | #define MIO_LENGTH 54 | ||
201 | |||
202 | - MIO_LOOPBACK = 0x804 / 4, | ||
203 | - MIO_MST_TRI0, | ||
204 | - MIO_MST_TRI1, | ||
205 | +REG32(MIO_LOOPBACK, 0x804) | ||
206 | +REG32(MIO_MST_TRI0, 0x808) | ||
207 | +REG32(MIO_MST_TRI1, 0x80c) | ||
208 | |||
209 | - SD0_WP_CD_SEL = 0x830 / 4, | ||
210 | - SD1_WP_CD_SEL, | ||
211 | +REG32(SD0_WP_CD_SEL, 0x830) | ||
212 | +REG32(SD1_WP_CD_SEL, 0x834) | ||
213 | |||
214 | - LVL_SHFTR_EN = 0x900 / 4, | ||
215 | - OCM_CFG = 0x910 / 4, | ||
216 | +REG32(LVL_SHFTR_EN, 0x900) | ||
217 | +REG32(OCM_CFG, 0x910) | ||
218 | |||
219 | - CPU_RAM = 0xa00 / 4, | ||
220 | +REG32(CPU_RAM, 0xa00) | ||
221 | |||
222 | - IOU = 0xa30 / 4, | ||
223 | +REG32(IOU, 0xa30) | ||
224 | |||
225 | - DMAC_RAM = 0xa50 / 4, | ||
226 | +REG32(DMAC_RAM, 0xa50) | ||
227 | |||
228 | - AFI0 = 0xa60 / 4, | ||
229 | - AFI1 = AFI0 + 3, | ||
230 | - AFI2 = AFI1 + 3, | ||
231 | - AFI3 = AFI2 + 3, | ||
232 | +REG32(AFI0, 0xa60) | ||
233 | +REG32(AFI1, 0xa6c) | ||
234 | +REG32(AFI2, 0xa78) | ||
235 | +REG32(AFI3, 0xa84) | ||
236 | #define AFI_LENGTH 3 | ||
237 | |||
238 | - OCM = 0xa90 / 4, | ||
239 | +REG32(OCM, 0xa90) | ||
240 | |||
241 | - DEVCI_RAM = 0xaa0 / 4, | ||
242 | +REG32(DEVCI_RAM, 0xaa0) | ||
243 | |||
244 | - CSG_RAM = 0xab0 / 4, | ||
245 | +REG32(CSG_RAM, 0xab0) | ||
246 | |||
247 | - GPIOB_CTRL = 0xb00 / 4, | ||
248 | - GPIOB_CFG_CMOS18, | ||
249 | - GPIOB_CFG_CMOS25, | ||
250 | - GPIOB_CFG_CMOS33, | ||
251 | - GPIOB_CFG_HSTL = 0xb14 / 4, | ||
252 | - GPIOB_DRVR_BIAS_CTRL, | ||
253 | +REG32(GPIOB_CTRL, 0xb00) | ||
254 | +REG32(GPIOB_CFG_CMOS18, 0xb04) | ||
255 | +REG32(GPIOB_CFG_CMOS25, 0xb08) | ||
256 | +REG32(GPIOB_CFG_CMOS33, 0xb0c) | ||
257 | +REG32(GPIOB_CFG_HSTL, 0xb14) | ||
258 | +REG32(GPIOB_DRVR_BIAS_CTRL, 0xb18) | ||
259 | |||
260 | - DDRIOB = 0xb40 / 4, | ||
261 | +REG32(DDRIOB, 0xb40) | ||
262 | #define DDRIOB_LENGTH 14 | ||
263 | -}; | ||
264 | |||
265 | #define ZYNQ_SLCR_MMIO_SIZE 0x1000 | ||
266 | #define ZYNQ_SLCR_NUM_REGS (ZYNQ_SLCR_MMIO_SIZE / 4) | ||
267 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset(DeviceState *d) | ||
268 | |||
269 | DB_PRINT("RESET\n"); | ||
270 | |||
271 | - s->regs[LOCKSTA] = 1; | ||
272 | + s->regs[R_LOCKSTA] = 1; | ||
273 | /* 0x100 - 0x11C */ | ||
274 | - s->regs[ARM_PLL_CTRL] = 0x0001A008; | ||
275 | - s->regs[DDR_PLL_CTRL] = 0x0001A008; | ||
276 | - s->regs[IO_PLL_CTRL] = 0x0001A008; | ||
277 | - s->regs[PLL_STATUS] = 0x0000003F; | ||
278 | - s->regs[ARM_PLL_CFG] = 0x00014000; | ||
279 | - s->regs[DDR_PLL_CFG] = 0x00014000; | ||
280 | - s->regs[IO_PLL_CFG] = 0x00014000; | ||
281 | + s->regs[R_ARM_PLL_CTRL] = 0x0001A008; | ||
282 | + s->regs[R_DDR_PLL_CTRL] = 0x0001A008; | ||
283 | + s->regs[R_IO_PLL_CTRL] = 0x0001A008; | ||
284 | + s->regs[R_PLL_STATUS] = 0x0000003F; | ||
285 | + s->regs[R_ARM_PLL_CFG] = 0x00014000; | ||
286 | + s->regs[R_DDR_PLL_CFG] = 0x00014000; | ||
287 | + s->regs[R_IO_PLL_CFG] = 0x00014000; | ||
288 | |||
289 | /* 0x120 - 0x16C */ | ||
290 | - s->regs[ARM_CLK_CTRL] = 0x1F000400; | ||
291 | - s->regs[DDR_CLK_CTRL] = 0x18400003; | ||
292 | - s->regs[DCI_CLK_CTRL] = 0x01E03201; | ||
293 | - s->regs[APER_CLK_CTRL] = 0x01FFCCCD; | ||
294 | - s->regs[USB0_CLK_CTRL] = s->regs[USB1_CLK_CTRL] = 0x00101941; | ||
295 | - s->regs[GEM0_RCLK_CTRL] = s->regs[GEM1_RCLK_CTRL] = 0x00000001; | ||
296 | - s->regs[GEM0_CLK_CTRL] = s->regs[GEM1_CLK_CTRL] = 0x00003C01; | ||
297 | - s->regs[SMC_CLK_CTRL] = 0x00003C01; | ||
298 | - s->regs[LQSPI_CLK_CTRL] = 0x00002821; | ||
299 | - s->regs[SDIO_CLK_CTRL] = 0x00001E03; | ||
300 | - s->regs[UART_CLK_CTRL] = 0x00003F03; | ||
301 | - s->regs[SPI_CLK_CTRL] = 0x00003F03; | ||
302 | - s->regs[CAN_CLK_CTRL] = 0x00501903; | ||
303 | - s->regs[DBG_CLK_CTRL] = 0x00000F03; | ||
304 | - s->regs[PCAP_CLK_CTRL] = 0x00000F01; | ||
305 | + s->regs[R_ARM_CLK_CTRL] = 0x1F000400; | ||
306 | + s->regs[R_DDR_CLK_CTRL] = 0x18400003; | ||
307 | + s->regs[R_DCI_CLK_CTRL] = 0x01E03201; | ||
308 | + s->regs[R_APER_CLK_CTRL] = 0x01FFCCCD; | ||
309 | + s->regs[R_USB0_CLK_CTRL] = s->regs[R_USB1_CLK_CTRL] = 0x00101941; | ||
310 | + s->regs[R_GEM0_RCLK_CTRL] = s->regs[R_GEM1_RCLK_CTRL] = 0x00000001; | ||
311 | + s->regs[R_GEM0_CLK_CTRL] = s->regs[R_GEM1_CLK_CTRL] = 0x00003C01; | ||
312 | + s->regs[R_SMC_CLK_CTRL] = 0x00003C01; | ||
313 | + s->regs[R_LQSPI_CLK_CTRL] = 0x00002821; | ||
314 | + s->regs[R_SDIO_CLK_CTRL] = 0x00001E03; | ||
315 | + s->regs[R_UART_CLK_CTRL] = 0x00003F03; | ||
316 | + s->regs[R_SPI_CLK_CTRL] = 0x00003F03; | ||
317 | + s->regs[R_CAN_CLK_CTRL] = 0x00501903; | ||
318 | + s->regs[R_DBG_CLK_CTRL] = 0x00000F03; | ||
319 | + s->regs[R_PCAP_CLK_CTRL] = 0x00000F01; | ||
320 | |||
321 | /* 0x170 - 0x1AC */ | ||
322 | - s->regs[FPGA0_CLK_CTRL] = s->regs[FPGA1_CLK_CTRL] = s->regs[FPGA2_CLK_CTRL] | ||
323 | - = s->regs[FPGA3_CLK_CTRL] = 0x00101800; | ||
324 | - s->regs[FPGA0_THR_STA] = s->regs[FPGA1_THR_STA] = s->regs[FPGA2_THR_STA] | ||
325 | - = s->regs[FPGA3_THR_STA] = 0x00010000; | ||
326 | + s->regs[R_FPGA0_CLK_CTRL] = s->regs[R_FPGA1_CLK_CTRL] | ||
327 | + = s->regs[R_FPGA2_CLK_CTRL] | ||
328 | + = s->regs[R_FPGA3_CLK_CTRL] = 0x00101800; | ||
329 | + s->regs[R_FPGA0_THR_STA] = s->regs[R_FPGA1_THR_STA] | ||
330 | + = s->regs[R_FPGA2_THR_STA] | ||
331 | + = s->regs[R_FPGA3_THR_STA] = 0x00010000; | ||
332 | |||
333 | /* 0x1B0 - 0x1D8 */ | ||
334 | - s->regs[BANDGAP_TRIP] = 0x0000001F; | ||
335 | - s->regs[PLL_PREDIVISOR] = 0x00000001; | ||
336 | - s->regs[CLK_621_TRUE] = 0x00000001; | ||
337 | + s->regs[R_BANDGAP_TRIP] = 0x0000001F; | ||
338 | + s->regs[R_PLL_PREDIVISOR] = 0x00000001; | ||
339 | + s->regs[R_CLK_621_TRUE] = 0x00000001; | ||
340 | |||
341 | /* 0x200 - 0x25C */ | ||
342 | - s->regs[FPGA_RST_CTRL] = 0x01F33F0F; | ||
343 | - s->regs[RST_REASON] = 0x00000040; | ||
344 | + s->regs[R_FPGA_RST_CTRL] = 0x01F33F0F; | ||
345 | + s->regs[R_RST_REASON] = 0x00000040; | ||
346 | |||
347 | - s->regs[BOOT_MODE] = 0x00000001; | ||
348 | + s->regs[R_BOOT_MODE] = 0x00000001; | ||
349 | |||
350 | /* 0x700 - 0x7D4 */ | ||
351 | for (i = 0; i < 54; i++) { | ||
352 | - s->regs[MIO + i] = 0x00001601; | ||
353 | + s->regs[R_MIO + i] = 0x00001601; | ||
354 | } | ||
355 | for (i = 2; i <= 8; i++) { | ||
356 | - s->regs[MIO + i] = 0x00000601; | ||
357 | + s->regs[R_MIO + i] = 0x00000601; | ||
358 | } | ||
359 | |||
360 | - s->regs[MIO_MST_TRI0] = s->regs[MIO_MST_TRI1] = 0xFFFFFFFF; | ||
361 | + s->regs[R_MIO_MST_TRI0] = s->regs[R_MIO_MST_TRI1] = 0xFFFFFFFF; | ||
362 | |||
363 | - s->regs[CPU_RAM + 0] = s->regs[CPU_RAM + 1] = s->regs[CPU_RAM + 3] | ||
364 | - = s->regs[CPU_RAM + 4] = s->regs[CPU_RAM + 7] | ||
365 | - = 0x00010101; | ||
366 | - s->regs[CPU_RAM + 2] = s->regs[CPU_RAM + 5] = 0x01010101; | ||
367 | - s->regs[CPU_RAM + 6] = 0x00000001; | ||
368 | + s->regs[R_CPU_RAM + 0] = s->regs[R_CPU_RAM + 1] = s->regs[R_CPU_RAM + 3] | ||
369 | + = s->regs[R_CPU_RAM + 4] = s->regs[R_CPU_RAM + 7] | ||
370 | + = 0x00010101; | ||
371 | + s->regs[R_CPU_RAM + 2] = s->regs[R_CPU_RAM + 5] = 0x01010101; | ||
372 | + s->regs[R_CPU_RAM + 6] = 0x00000001; | ||
373 | |||
374 | - s->regs[IOU + 0] = s->regs[IOU + 1] = s->regs[IOU + 2] = s->regs[IOU + 3] | ||
375 | - = 0x09090909; | ||
376 | - s->regs[IOU + 4] = s->regs[IOU + 5] = 0x00090909; | ||
377 | - s->regs[IOU + 6] = 0x00000909; | ||
378 | + s->regs[R_IOU + 0] = s->regs[R_IOU + 1] = s->regs[R_IOU + 2] | ||
379 | + = s->regs[R_IOU + 3] = 0x09090909; | ||
380 | + s->regs[R_IOU + 4] = s->regs[R_IOU + 5] = 0x00090909; | ||
381 | + s->regs[R_IOU + 6] = 0x00000909; | ||
382 | |||
383 | - s->regs[DMAC_RAM] = 0x00000009; | ||
384 | + s->regs[R_DMAC_RAM] = 0x00000009; | ||
385 | |||
386 | - s->regs[AFI0 + 0] = s->regs[AFI0 + 1] = 0x09090909; | ||
387 | - s->regs[AFI1 + 0] = s->regs[AFI1 + 1] = 0x09090909; | ||
388 | - s->regs[AFI2 + 0] = s->regs[AFI2 + 1] = 0x09090909; | ||
389 | - s->regs[AFI3 + 0] = s->regs[AFI3 + 1] = 0x09090909; | ||
390 | - s->regs[AFI0 + 2] = s->regs[AFI1 + 2] = s->regs[AFI2 + 2] | ||
391 | - = s->regs[AFI3 + 2] = 0x00000909; | ||
392 | + s->regs[R_AFI0 + 0] = s->regs[R_AFI0 + 1] = 0x09090909; | ||
393 | + s->regs[R_AFI1 + 0] = s->regs[R_AFI1 + 1] = 0x09090909; | ||
394 | + s->regs[R_AFI2 + 0] = s->regs[R_AFI2 + 1] = 0x09090909; | ||
395 | + s->regs[R_AFI3 + 0] = s->regs[R_AFI3 + 1] = 0x09090909; | ||
396 | + s->regs[R_AFI0 + 2] = s->regs[R_AFI1 + 2] = s->regs[R_AFI2 + 2] | ||
397 | + = s->regs[R_AFI3 + 2] = 0x00000909; | ||
398 | |||
399 | - s->regs[OCM + 0] = 0x01010101; | ||
400 | - s->regs[OCM + 1] = s->regs[OCM + 2] = 0x09090909; | ||
401 | + s->regs[R_OCM + 0] = 0x01010101; | ||
402 | + s->regs[R_OCM + 1] = s->regs[R_OCM + 2] = 0x09090909; | ||
403 | |||
404 | - s->regs[DEVCI_RAM] = 0x00000909; | ||
405 | - s->regs[CSG_RAM] = 0x00000001; | ||
406 | + s->regs[R_DEVCI_RAM] = 0x00000909; | ||
407 | + s->regs[R_CSG_RAM] = 0x00000001; | ||
408 | |||
409 | - s->regs[DDRIOB + 0] = s->regs[DDRIOB + 1] = s->regs[DDRIOB + 2] | ||
410 | - = s->regs[DDRIOB + 3] = 0x00000e00; | ||
411 | - s->regs[DDRIOB + 4] = s->regs[DDRIOB + 5] = s->regs[DDRIOB + 6] | ||
412 | - = 0x00000e00; | ||
413 | - s->regs[DDRIOB + 12] = 0x00000021; | ||
414 | + s->regs[R_DDRIOB + 0] = s->regs[R_DDRIOB + 1] = s->regs[R_DDRIOB + 2] | ||
415 | + = s->regs[R_DDRIOB + 3] = 0x00000e00; | ||
416 | + s->regs[R_DDRIOB + 4] = s->regs[R_DDRIOB + 5] = s->regs[R_DDRIOB + 6] | ||
417 | + = 0x00000e00; | ||
418 | + s->regs[R_DDRIOB + 12] = 0x00000021; | ||
419 | } | 38 | } |
420 | 39 | ||
421 | 40 | diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c | |
422 | static bool zynq_slcr_check_offset(hwaddr offset, bool rnw) | 41 | index XXXXXXX..XXXXXXX 100644 |
423 | { | 42 | --- a/hw/virtio/virtio-iommu-pci.c |
424 | switch (offset) { | 43 | +++ b/hw/virtio/virtio-iommu-pci.c |
425 | - case LOCK: | 44 | @@ -XXX,XX +XXX,XX @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) |
426 | - case UNLOCK: | 45 | VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); |
427 | - case DDR_CAL_START: | 46 | |
428 | - case DDR_REF_START: | 47 | if (!qdev_get_machine_hotplug_handler(DEVICE(vpci_dev))) { |
429 | + case R_LOCK: | 48 | - MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); |
430 | + case R_UNLOCK: | 49 | - |
431 | + case R_DDR_CAL_START: | 50 | - error_setg(errp, |
432 | + case R_DDR_REF_START: | 51 | - "%s machine fails to create iommu-map device tree bindings", |
433 | return !rnw; /* Write only */ | 52 | - mc->name); |
434 | - case LOCKSTA: | 53 | - error_append_hint(errp, |
435 | - case FPGA0_THR_STA: | 54 | - "Check your machine implements a hotplug handler " |
436 | - case FPGA1_THR_STA: | 55 | - "for the virtio-iommu-pci device\n"); |
437 | - case FPGA2_THR_STA: | 56 | - error_append_hint(errp, "Check the guest is booted without FW or with " |
438 | - case FPGA3_THR_STA: | 57 | - "-no-acpi\n"); |
439 | - case BOOT_MODE: | 58 | + error_setg(errp, "Check your machine implements a hotplug handler " |
440 | - case PSS_IDCODE: | 59 | + "for the virtio-iommu-pci device"); |
441 | - case DDR_CMD_STA: | ||
442 | - case DDR_DFI_STATUS: | ||
443 | - case PLL_STATUS: | ||
444 | + case R_LOCKSTA: | ||
445 | + case R_FPGA0_THR_STA: | ||
446 | + case R_FPGA1_THR_STA: | ||
447 | + case R_FPGA2_THR_STA: | ||
448 | + case R_FPGA3_THR_STA: | ||
449 | + case R_BOOT_MODE: | ||
450 | + case R_PSS_IDCODE: | ||
451 | + case R_DDR_CMD_STA: | ||
452 | + case R_DDR_DFI_STATUS: | ||
453 | + case R_PLL_STATUS: | ||
454 | return rnw;/* read only */ | ||
455 | - case SCL: | ||
456 | - case ARM_PLL_CTRL ... IO_PLL_CTRL: | ||
457 | - case ARM_PLL_CFG ... IO_PLL_CFG: | ||
458 | - case ARM_CLK_CTRL ... TOPSW_CLK_CTRL: | ||
459 | - case FPGA0_CLK_CTRL ... FPGA0_THR_CNT: | ||
460 | - case FPGA1_CLK_CTRL ... FPGA1_THR_CNT: | ||
461 | - case FPGA2_CLK_CTRL ... FPGA2_THR_CNT: | ||
462 | - case FPGA3_CLK_CTRL ... FPGA3_THR_CNT: | ||
463 | - case BANDGAP_TRIP: | ||
464 | - case PLL_PREDIVISOR: | ||
465 | - case CLK_621_TRUE: | ||
466 | - case PSS_RST_CTRL ... A9_CPU_RST_CTRL: | ||
467 | - case RS_AWDT_CTRL: | ||
468 | - case RST_REASON: | ||
469 | - case REBOOT_STATUS: | ||
470 | - case APU_CTRL: | ||
471 | - case WDT_CLK_SEL: | ||
472 | - case TZ_DMA_NS ... TZ_DMA_PERIPH_NS: | ||
473 | - case DDR_URGENT: | ||
474 | - case DDR_URGENT_SEL: | ||
475 | - case MIO ... MIO + MIO_LENGTH - 1: | ||
476 | - case MIO_LOOPBACK ... MIO_MST_TRI1: | ||
477 | - case SD0_WP_CD_SEL: | ||
478 | - case SD1_WP_CD_SEL: | ||
479 | - case LVL_SHFTR_EN: | ||
480 | - case OCM_CFG: | ||
481 | - case CPU_RAM: | ||
482 | - case IOU: | ||
483 | - case DMAC_RAM: | ||
484 | - case AFI0 ... AFI3 + AFI_LENGTH - 1: | ||
485 | - case OCM: | ||
486 | - case DEVCI_RAM: | ||
487 | - case CSG_RAM: | ||
488 | - case GPIOB_CTRL ... GPIOB_CFG_CMOS33: | ||
489 | - case GPIOB_CFG_HSTL: | ||
490 | - case GPIOB_DRVR_BIAS_CTRL: | ||
491 | - case DDRIOB ... DDRIOB + DDRIOB_LENGTH - 1: | ||
492 | + case R_SCL: | ||
493 | + case R_ARM_PLL_CTRL ... R_IO_PLL_CTRL: | ||
494 | + case R_ARM_PLL_CFG ... R_IO_PLL_CFG: | ||
495 | + case R_ARM_CLK_CTRL ... R_TOPSW_CLK_CTRL: | ||
496 | + case R_FPGA0_CLK_CTRL ... R_FPGA0_THR_CNT: | ||
497 | + case R_FPGA1_CLK_CTRL ... R_FPGA1_THR_CNT: | ||
498 | + case R_FPGA2_CLK_CTRL ... R_FPGA2_THR_CNT: | ||
499 | + case R_FPGA3_CLK_CTRL ... R_FPGA3_THR_CNT: | ||
500 | + case R_BANDGAP_TRIP: | ||
501 | + case R_PLL_PREDIVISOR: | ||
502 | + case R_CLK_621_TRUE: | ||
503 | + case R_PSS_RST_CTRL ... R_A9_CPU_RST_CTRL: | ||
504 | + case R_RS_AWDT_CTRL: | ||
505 | + case R_RST_REASON: | ||
506 | + case R_REBOOT_STATUS: | ||
507 | + case R_APU_CTRL: | ||
508 | + case R_WDT_CLK_SEL: | ||
509 | + case R_TZ_DMA_NS ... R_TZ_DMA_PERIPH_NS: | ||
510 | + case R_DDR_URGENT: | ||
511 | + case R_DDR_URGENT_SEL: | ||
512 | + case R_MIO ... R_MIO + MIO_LENGTH - 1: | ||
513 | + case R_MIO_LOOPBACK ... R_MIO_MST_TRI1: | ||
514 | + case R_SD0_WP_CD_SEL: | ||
515 | + case R_SD1_WP_CD_SEL: | ||
516 | + case R_LVL_SHFTR_EN: | ||
517 | + case R_OCM_CFG: | ||
518 | + case R_CPU_RAM: | ||
519 | + case R_IOU: | ||
520 | + case R_DMAC_RAM: | ||
521 | + case R_AFI0 ... R_AFI3 + AFI_LENGTH - 1: | ||
522 | + case R_OCM: | ||
523 | + case R_DEVCI_RAM: | ||
524 | + case R_CSG_RAM: | ||
525 | + case R_GPIOB_CTRL ... R_GPIOB_CFG_CMOS33: | ||
526 | + case R_GPIOB_CFG_HSTL: | ||
527 | + case R_GPIOB_DRVR_BIAS_CTRL: | ||
528 | + case R_DDRIOB ... R_DDRIOB + DDRIOB_LENGTH - 1: | ||
529 | return true; | ||
530 | default: | ||
531 | return false; | ||
532 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
533 | } | ||
534 | |||
535 | switch (offset) { | ||
536 | - case SCL: | ||
537 | - s->regs[SCL] = val & 0x1; | ||
538 | + case R_SCL: | ||
539 | + s->regs[R_SCL] = val & 0x1; | ||
540 | return; | ||
541 | - case LOCK: | ||
542 | + case R_LOCK: | ||
543 | if ((val & 0xFFFF) == XILINX_LOCK_KEY) { | ||
544 | DB_PRINT("XILINX LOCK 0xF8000000 + 0x%x <= 0x%x\n", (int)offset, | ||
545 | (unsigned)val & 0xFFFF); | ||
546 | - s->regs[LOCKSTA] = 1; | ||
547 | + s->regs[R_LOCKSTA] = 1; | ||
548 | } else { | ||
549 | DB_PRINT("WRONG XILINX LOCK KEY 0xF8000000 + 0x%x <= 0x%x\n", | ||
550 | (int)offset, (unsigned)val & 0xFFFF); | ||
551 | } | ||
552 | return; | ||
553 | - case UNLOCK: | ||
554 | + case R_UNLOCK: | ||
555 | if ((val & 0xFFFF) == XILINX_UNLOCK_KEY) { | ||
556 | DB_PRINT("XILINX UNLOCK 0xF8000000 + 0x%x <= 0x%x\n", (int)offset, | ||
557 | (unsigned)val & 0xFFFF); | ||
558 | - s->regs[LOCKSTA] = 0; | ||
559 | + s->regs[R_LOCKSTA] = 0; | ||
560 | } else { | ||
561 | DB_PRINT("WRONG XILINX UNLOCK KEY 0xF8000000 + 0x%x <= 0x%x\n", | ||
562 | (int)offset, (unsigned)val & 0xFFFF); | ||
563 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
564 | return; | 60 | return; |
565 | } | 61 | } |
566 | 62 | for (int i = 0; i < s->nb_reserved_regions; i++) { | |
567 | - if (s->regs[LOCKSTA]) { | ||
568 | + if (s->regs[R_LOCKSTA]) { | ||
569 | qemu_log_mask(LOG_GUEST_ERROR, | ||
570 | "SCLR registers are locked. Unlock them first\n"); | ||
571 | return; | ||
572 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
573 | s->regs[offset] = val; | ||
574 | |||
575 | switch (offset) { | ||
576 | - case PSS_RST_CTRL: | ||
577 | - if (val & R_PSS_RST_CTRL_SOFT_RST) { | ||
578 | + case R_PSS_RST_CTRL: | ||
579 | + if (FIELD_EX32(val, PSS_RST_CTRL, SOFT_RST)) { | ||
580 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
581 | } | ||
582 | break; | ||
583 | -- | 63 | -- |
584 | 2.20.1 | 64 | 2.25.1 |
585 | 65 | ||
586 | 66 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We first convert the pmu property from a static property to one with | 3 | We do not support instantiating multiple IOMMUs. Before adding a |
4 | its own accessors. Then we use the set accessor to check if the PMU is | 4 | virtio-iommu, check that no other IOMMU is present. This will detect |
5 | supported when using KVM. Indeed a 32-bit KVM host does not support | 5 | both "iommu=smmuv3" machine parameter and another virtio-iommu instance. |
6 | the PMU, so this check will catch an attempt to use it at property-set | ||
7 | time. | ||
8 | 6 | ||
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 7 | Fixes: 70e89132c9 ("hw/arm/virt: Add the virtio-iommu device tree mappings") |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20211210170415.583179-4-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/kvm_arm.h | 14 ++++++++++++++ | 14 | hw/arm/virt.c | 5 +++++ |
14 | target/arm/cpu.c | 30 +++++++++++++++++++++++++----- | 15 | 1 file changed, 5 insertions(+) |
15 | target/arm/kvm.c | 7 +++++++ | ||
16 | 3 files changed, 46 insertions(+), 5 deletions(-) | ||
17 | 16 | ||
18 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/kvm_arm.h | 19 | --- a/hw/arm/virt.c |
21 | +++ b/target/arm/kvm_arm.h | 20 | +++ b/hw/arm/virt.c |
22 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); | 21 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, |
23 | */ | 22 | hwaddr db_start = 0, db_end = 0; |
24 | bool kvm_arm_aarch32_supported(CPUState *cs); | 23 | char *resv_prop_str; |
25 | 24 | ||
26 | +/** | 25 | + if (vms->iommu != VIRT_IOMMU_NONE) { |
27 | + * bool kvm_arm_pmu_supported: | 26 | + error_setg(errp, "virt machine does not support multiple IOMMUs"); |
28 | + * @cs: CPUState | ||
29 | + * | ||
30 | + * Returns: true if the KVM VCPU can enable its PMU | ||
31 | + * and false otherwise. | ||
32 | + */ | ||
33 | +bool kvm_arm_pmu_supported(CPUState *cs); | ||
34 | + | ||
35 | /** | ||
36 | * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the | ||
37 | * IPA address space supported by KVM | ||
38 | @@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_aarch32_supported(CPUState *cs) | ||
39 | return false; | ||
40 | } | ||
41 | |||
42 | +static inline bool kvm_arm_pmu_supported(CPUState *cs) | ||
43 | +{ | ||
44 | + return false; | ||
45 | +} | ||
46 | + | ||
47 | static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
48 | { | ||
49 | return -ENOENT; | ||
50 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/cpu.c | ||
53 | +++ b/target/arm/cpu.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_has_el3_property = | ||
55 | static Property arm_cpu_cfgend_property = | ||
56 | DEFINE_PROP_BOOL("cfgend", ARMCPU, cfgend, false); | ||
57 | |||
58 | -/* use property name "pmu" to match other archs and virt tools */ | ||
59 | -static Property arm_cpu_has_pmu_property = | ||
60 | - DEFINE_PROP_BOOL("pmu", ARMCPU, has_pmu, true); | ||
61 | - | ||
62 | static Property arm_cpu_has_vfp_property = | ||
63 | DEFINE_PROP_BOOL("vfp", ARMCPU, has_vfp, true); | ||
64 | |||
65 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pmsav7_dregion_property = | ||
66 | pmsav7_dregion, | ||
67 | qdev_prop_uint32, uint32_t); | ||
68 | |||
69 | +static bool arm_get_pmu(Object *obj, Error **errp) | ||
70 | +{ | ||
71 | + ARMCPU *cpu = ARM_CPU(obj); | ||
72 | + | ||
73 | + return cpu->has_pmu; | ||
74 | +} | ||
75 | + | ||
76 | +static void arm_set_pmu(Object *obj, bool value, Error **errp) | ||
77 | +{ | ||
78 | + ARMCPU *cpu = ARM_CPU(obj); | ||
79 | + | ||
80 | + if (value) { | ||
81 | + if (kvm_enabled() && !kvm_arm_pmu_supported(CPU(cpu))) { | ||
82 | + error_setg(errp, "'pmu' feature not supported by KVM on this host"); | ||
83 | + return; | 27 | + return; |
84 | + } | 28 | + } |
85 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
86 | + } else { | ||
87 | + unset_feature(&cpu->env, ARM_FEATURE_PMU); | ||
88 | + } | ||
89 | + cpu->has_pmu = value; | ||
90 | +} | ||
91 | + | 29 | + |
92 | static void arm_get_init_svtor(Object *obj, Visitor *v, const char *name, | 30 | switch (vms->msi_controller) { |
93 | void *opaque, Error **errp) | 31 | case VIRT_MSI_CTRL_NONE: |
94 | { | 32 | return; |
95 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | ||
96 | } | ||
97 | |||
98 | if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { | ||
99 | - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_pmu_property, | ||
100 | + cpu->has_pmu = true; | ||
101 | + object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu, | ||
102 | &error_abort); | ||
103 | } | ||
104 | |||
105 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/kvm.c | ||
108 | +++ b/target/arm/kvm.c | ||
109 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | ||
110 | env->features = arm_host_cpu_features.features; | ||
111 | } | ||
112 | |||
113 | +bool kvm_arm_pmu_supported(CPUState *cpu) | ||
114 | +{ | ||
115 | + KVMState *s = KVM_STATE(current_machine->accelerator); | ||
116 | + | ||
117 | + return kvm_check_extension(s, KVM_CAP_ARM_PMU_V3); | ||
118 | +} | ||
119 | + | ||
120 | int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
121 | { | ||
122 | KVMState *s = KVM_STATE(ms->accelerator); | ||
123 | -- | 33 | -- |
124 | 2.20.1 | 34 | 2.25.1 |
125 | 35 | ||
126 | 36 | 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 function is used in two different contexts, and it will be | 3 | To propagate errors to the caller of the pre_plug callback, use the |
4 | clearer if the function is given the address to which it applies. | 4 | object_poperty_set*() functions directly instead of the qdev_prop_set*() |
5 | helpers. | ||
5 | 6 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Suggested-by: Igor Mammedov <imammedo@redhat.com> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> |
9 | Message-id: 20190807045335.1361-2-richard.henderson@linaro.org | 10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
11 | Message-id: 20211210170415.583179-5-jean-philippe@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/translate.c | 14 +++++++------- | 14 | hw/arm/virt.c | 5 +++-- |
13 | 1 file changed, 7 insertions(+), 7 deletions(-) | 15 | 1 file changed, 3 insertions(+), 2 deletions(-) |
14 | 16 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 19 | --- a/hw/arm/virt.c |
18 | +++ b/target/arm/translate.c | 20 | +++ b/hw/arm/virt.c |
19 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 21 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, |
22 | db_start, db_end, | ||
23 | VIRTIO_IOMMU_RESV_MEM_T_MSI); | ||
24 | |||
25 | - qdev_prop_set_uint32(dev, "len-reserved-regions", 1); | ||
26 | - qdev_prop_set_string(dev, "reserved-regions[0]", resv_prop_str); | ||
27 | + object_property_set_uint(OBJECT(dev), "len-reserved-regions", 1, errp); | ||
28 | + object_property_set_str(OBJECT(dev), "reserved-regions[0]", | ||
29 | + resv_prop_str, errp); | ||
30 | g_free(resv_prop_str); | ||
20 | } | 31 | } |
21 | } | 32 | } |
22 | |||
23 | -static bool thumb_insn_is_16bit(DisasContext *s, uint32_t insn) | ||
24 | +static bool thumb_insn_is_16bit(DisasContext *s, uint32_t pc, uint32_t insn) | ||
25 | { | ||
26 | - /* Return true if this is a 16 bit instruction. We must be precise | ||
27 | - * about this (matching the decode). We assume that s->pc still | ||
28 | - * points to the first 16 bits of the insn. | ||
29 | + /* | ||
30 | + * Return true if this is a 16 bit instruction. We must be precise | ||
31 | + * about this (matching the decode). | ||
32 | */ | ||
33 | if ((insn >> 11) < 0x1d) { | ||
34 | /* Definitely a 16-bit instruction */ | ||
35 | @@ -XXX,XX +XXX,XX @@ static bool thumb_insn_is_16bit(DisasContext *s, uint32_t insn) | ||
36 | return false; | ||
37 | } | ||
38 | |||
39 | - if ((insn >> 11) == 0x1e && s->pc - s->page_start < TARGET_PAGE_SIZE - 3) { | ||
40 | + if ((insn >> 11) == 0x1e && pc - s->page_start < TARGET_PAGE_SIZE - 3) { | ||
41 | /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix, and the suffix | ||
42 | * is not on the next page; we merge this into a 32-bit | ||
43 | * insn. | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | ||
45 | */ | ||
46 | uint16_t insn = arm_lduw_code(env, s->pc, s->sctlr_b); | ||
47 | |||
48 | - return !thumb_insn_is_16bit(s, insn); | ||
49 | + return !thumb_insn_is_16bit(s, s->pc, insn); | ||
50 | } | ||
51 | |||
52 | static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
53 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
54 | } | ||
55 | |||
56 | insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
57 | - is_16bit = thumb_insn_is_16bit(dc, insn); | ||
58 | + is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | ||
59 | dc->pc += 2; | ||
60 | if (!is_16bit) { | ||
61 | uint32_t insn2 = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
62 | -- | 33 | -- |
63 | 2.20.1 | 34 | 2.25.1 |
64 | 35 | ||
65 | 36 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The current implementation of ZCR_ELx matches the architecture, only | 3 | Create empty data files and allow updates for the upcoming VIOT tests. |
4 | implementing the lower four bits, with the rest RAZ/WI. This puts | ||
5 | a strict limit on ARM_MAX_VQ of 16. Make sure we don't let ARM_MAX_VQ | ||
6 | grow without a corresponding update here. | ||
7 | 4 | ||
8 | Suggested-by: Dave Martin <Dave.Martin@arm.com> | 5 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
7 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
8 | Message-id: 20211210170415.583179-6-jean-philippe@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | target/arm/helper.c | 1 + | 11 | tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ |
15 | 1 file changed, 1 insertion(+) | 12 | tests/data/acpi/q35/DSDT.viot | 0 |
13 | tests/data/acpi/q35/VIOT.viot | 0 | ||
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 | ||
16 | 19 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 20 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 22 | --- a/tests/qtest/bios-tables-test-allowed-diff.h |
20 | +++ b/target/arm/helper.c | 23 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h |
21 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 24 | @@ -1 +1,4 @@ |
22 | int new_len; | 25 | /* List of comma-separated changed AML files to ignore */ |
23 | 26 | +"tests/data/acpi/virt/VIOT", | |
24 | /* Bits other than [3:0] are RAZ/WI. */ | 27 | +"tests/data/acpi/q35/DSDT.viot", |
25 | + QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16); | 28 | +"tests/data/acpi/q35/VIOT.viot", |
26 | raw_write(env, ri, value & 0xf); | 29 | diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot |
27 | 30 | new file mode 100644 | |
28 | /* | 31 | index XXXXXXX..XXXXXXX |
32 | diff --git a/tests/data/acpi/q35/VIOT.viot b/tests/data/acpi/q35/VIOT.viot | ||
33 | new file mode 100644 | ||
34 | index XXXXXXX..XXXXXXX | ||
35 | diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/virt/VIOT | ||
36 | new file mode 100644 | ||
37 | index XXXXXXX..XXXXXXX | ||
29 | -- | 38 | -- |
30 | 2.20.1 | 39 | 2.25.1 |
31 | 40 | ||
32 | 41 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | If -cpu <cpu>,aarch64=off is used then KVM must also be used, and it | 3 | Add two test cases for VIOT, one on the q35 machine and the other on |
4 | and the host must support running the vcpu in 32-bit mode. Also, if | 4 | virt. To test complex topologies the q35 test has two PCIe buses that |
5 | -cpu <cpu>,aarch64=on is used, then it doesn't matter if kvm is | 5 | bypass the IOMMU (and are therefore not described by VIOT), and two |
6 | enabled or not. | 6 | buses that are translated by virtio-iommu. |
7 | 7 | ||
8 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20211210170415.583179-7-jean-philippe@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/kvm_arm.h | 14 ++++++++++++++ | 14 | tests/qtest/bios-tables-test.c | 38 ++++++++++++++++++++++++++++++++++ |
13 | target/arm/cpu64.c | 12 ++++++------ | 15 | 1 file changed, 38 insertions(+) |
14 | target/arm/kvm64.c | 9 +++++++++ | ||
15 | 3 files changed, 29 insertions(+), 6 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.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/kvm_arm.h | 19 | --- a/tests/qtest/bios-tables-test.c |
20 | +++ b/target/arm/kvm_arm.h | 20 | +++ b/tests/qtest/bios-tables-test.c |
21 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); | 21 | @@ -XXX,XX +XXX,XX @@ static void test_acpi_virt_tcg(void) |
22 | */ | 22 | free_test_data(&data); |
23 | void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); | 23 | } |
24 | 24 | ||
25 | +/** | 25 | +static void test_acpi_q35_viot(void) |
26 | + * kvm_arm_aarch32_supported: | 26 | +{ |
27 | + * @cs: CPUState | 27 | + test_data data = { |
28 | + * | 28 | + .machine = MACHINE_Q35, |
29 | + * Returns: true if the KVM VCPU can enable AArch32 mode | 29 | + .variant = ".viot", |
30 | + * and false otherwise. | 30 | + }; |
31 | + */ | ||
32 | +bool kvm_arm_aarch32_supported(CPUState *cs); | ||
33 | + | 31 | + |
34 | /** | 32 | + /* |
35 | * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the | 33 | + * To keep things interesting, two buses bypass the IOMMU. |
36 | * IPA address space supported by KVM | 34 | + * VIOT should only describes the other two buses. |
37 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | 35 | + */ |
38 | cpu->host_cpu_probe_failed = true; | 36 | + test_acpi_one("-machine default_bus_bypass_iommu=on " |
39 | } | 37 | + "-device virtio-iommu-pci " |
40 | 38 | + "-device pxb-pcie,bus_nr=0x10,id=pcie.100,bus=pcie.0 " | |
41 | +static inline bool kvm_arm_aarch32_supported(CPUState *cs) | 39 | + "-device pxb-pcie,bus_nr=0x20,id=pcie.200,bus=pcie.0,bypass_iommu=on " |
42 | +{ | 40 | + "-device pxb-pcie,bus_nr=0x30,id=pcie.300,bus=pcie.0", |
43 | + return false; | 41 | + &data); |
42 | + free_test_data(&data); | ||
44 | +} | 43 | +} |
45 | + | 44 | + |
46 | static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | 45 | +static void test_acpi_virt_viot(void) |
47 | { | ||
48 | return -ENOENT; | ||
49 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/cpu64.c | ||
52 | +++ b/target/arm/cpu64.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp) | ||
54 | * restriction allows us to avoid fixing up functionality that assumes a | ||
55 | * uniform execution state like do_interrupt. | ||
56 | */ | ||
57 | - if (!kvm_enabled()) { | ||
58 | - error_setg(errp, "'aarch64' feature cannot be disabled " | ||
59 | - "unless KVM is enabled"); | ||
60 | - return; | ||
61 | - } | ||
62 | - | ||
63 | if (value == false) { | ||
64 | + if (!kvm_enabled() || !kvm_arm_aarch32_supported(CPU(cpu))) { | ||
65 | + error_setg(errp, "'aarch64' feature cannot be disabled " | ||
66 | + "unless KVM is enabled and 32-bit EL1 " | ||
67 | + "is supported"); | ||
68 | + return; | ||
69 | + } | ||
70 | unset_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
71 | } else { | ||
72 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
73 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/kvm64.c | ||
76 | +++ b/target/arm/kvm64.c | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | #include "exec/gdbstub.h" | ||
79 | #include "sysemu/sysemu.h" | ||
80 | #include "sysemu/kvm.h" | ||
81 | +#include "sysemu/kvm_int.h" | ||
82 | #include "kvm_arm.h" | ||
83 | +#include "hw/boards.h" | ||
84 | #include "internals.h" | ||
85 | |||
86 | static bool have_guest_debug; | ||
87 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
88 | return true; | ||
89 | } | ||
90 | |||
91 | +bool kvm_arm_aarch32_supported(CPUState *cpu) | ||
92 | +{ | 46 | +{ |
93 | + KVMState *s = KVM_STATE(current_machine->accelerator); | 47 | + test_data data = { |
48 | + .machine = "virt", | ||
49 | + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", | ||
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 | + }; | ||
94 | + | 55 | + |
95 | + return kvm_check_extension(s, KVM_CAP_ARM_EL1_32BIT); | 56 | + test_acpi_one("-cpu cortex-a57 " |
57 | + "-device virtio-iommu-pci", &data); | ||
58 | + free_test_data(&data); | ||
96 | +} | 59 | +} |
97 | + | 60 | + |
98 | #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 | 61 | static void test_oem_fields(test_data *data) |
99 | 62 | { | |
100 | int kvm_arch_init_vcpu(CPUState *cs) | 63 | int i; |
64 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | ||
65 | qtest_add_func("acpi/q35/kvm/xapic", test_acpi_q35_kvm_xapic); | ||
66 | qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar); | ||
67 | } | ||
68 | + qtest_add_func("acpi/q35/viot", test_acpi_q35_viot); | ||
69 | } else if (strcmp(arch, "aarch64") == 0) { | ||
70 | if (has_tcg) { | ||
71 | qtest_add_func("acpi/virt", test_acpi_virt_tcg); | ||
72 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | ||
73 | qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp); | ||
74 | qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb); | ||
75 | qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt); | ||
76 | + qtest_add_func("acpi/virt/viot", test_acpi_virt_viot); | ||
77 | } | ||
78 | } | ||
79 | ret = g_test_run(); | ||
101 | -- | 80 | -- |
102 | 2.20.1 | 81 | 2.25.1 |
103 | 82 | ||
104 | 83 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | |
2 | |||
3 | Add expected blobs of the VIOT and DSDT table for the VIOT test on the | ||
4 | q35 machine. | ||
5 | |||
6 | Since the test instantiates a virtio device and two PCIe expander | ||
7 | bridges, DSDT.viot has more blocks than the base DSDT. | ||
8 | |||
9 | The VIOT table generated for the q35 test is: | ||
10 | |||
11 | [000h 0000 4] Signature : "VIOT" [Virtual I/O Translation Table] | ||
12 | [004h 0004 4] Table Length : 00000070 | ||
13 | [008h 0008 1] Revision : 00 | ||
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 | ||
459 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
460 | --- | ||
461 | tests/qtest/bios-tables-test-allowed-diff.h | 2 -- | ||
462 | tests/data/acpi/q35/DSDT.viot | Bin 0 -> 9398 bytes | ||
463 | tests/data/acpi/q35/VIOT.viot | Bin 0 -> 112 bytes | ||
464 | 3 files changed, 2 deletions(-) | ||
465 | |||
466 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
467 | index XXXXXXX..XXXXXXX 100644 | ||
468 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | ||
469 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | ||
470 | @@ -XXX,XX +XXX,XX @@ | ||
471 | /* List of comma-separated changed AML files to ignore */ | ||
472 | "tests/data/acpi/virt/VIOT", | ||
473 | -"tests/data/acpi/q35/DSDT.viot", | ||
474 | -"tests/data/acpi/q35/VIOT.viot", | ||
475 | diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot | ||
476 | index XXXXXXX..XXXXXXX 100644 | ||
477 | GIT binary patch | ||
478 | literal 9398 | ||
479 | zcmeHNO>7&-8J*>iv|O&FB}G~Oi$yp||57BBoWHhc5OS9yDTx$CQgH$r;8Idr*-4Q_ | ||
480 | z5(9Az1F`}niVsB-)<KW7p`g9Br(A2Gm-gmc1N78GFS!;)e2V(MnH_0{q<{#yMgn&C | ||
481 | zn|*J-d9yqFhO_H6z19~`FlPL*u<DkZ*}|)JH;X@mF-FI<cPg<fti9tEN*yB^i5czN | ||
482 | zNq&q?!OZ;BE3B7{KWzJ-`Tn~f`9?Qj8~2^N8{Oc8J%57{==w%rS#;nOCp*nTr@iZ1 | ||
483 | zb+?i;JLQUJ=O0?8*>S~D)a>NF1~WVB6^~_B#yhJ`H+JU@=6aXs`?Yv)J2h=N?drcS | ||
484 | zeLZ*n<<Bm^n}6`jfBx#u8&(W}1?)}iF9o#mZ~E2+zwdn7yK3AbIzKnxpZ>JRPm3~# | ||
485 | z&ICS{+_OayRW-l=Mtk=~uaS3o8z<_udd|(wqg`&JnVPfCe>BUOO`Su3e>pff_^UW% | ||
486 | z&JE^NO`)=Amg~iqRB1pPscP?(>#ZuY8GHCmlEvD$9g3%4Db~Dfz2SATnddvrR-Oe^ | ||
487 | z;s;dJec!hnzi)ri^I6YN9vtkm{^TdUF8h7gX8-<Qe4p)GQ=)AtYx2VcwdLVAEXEjG | ||
488 | z^Mj|UHPqkj-LsWuzQem1>F3atdZn=zv3$#RmZzSHN+6-yyU#8cJb=YDilX&sl}vNm | ||
489 | znkgAR^O<3kj4if>{ly5fwRfMWuC5=lrlvKPX~i#654Cp}R_d*JS$9laZ$ra6)<ns8 | ||
490 | zFZy28G%xP(nit&F>LDi%G<tIc=TY=gl$jSD&Uv!Yat~XR46h%rI$!}a%!|xG7u8Zn | ||
491 | zeY8_|n=K>xz_v_W8VX$W-Fg-qFWcT}7MCyz{%%{ia7hZ>Law-k6NOr}VI&_48U=2l | ||
492 | zwqDKFE8eTwwozDdms#e?x?5a|v>&JF;2_v0L~z5n%BYU^52<*cWuD4|GYUm@1+?)) | ||
493 | zte^45>Rz)t*<T5V#={r>@t@{%?^i#W{i=HAZ*Dc9y59Va-+#P!jrGs;u38a{fLr`N | ||
494 | zvT@rUu>DljxJ?^&Z?-?vyJn3C>3D=qux{Y*bs5|5n)Qmi$TD^Zdn4GU$ocJS2Hh-< | ||
495 | z`xPI^^+v0nUVdjMos8k`WGl7hA`{03ju%<lrgAHSpd^DRf-*}_#Ly0mB!LSfVgWcQ | ||
496 | z&T$@~G9)JI=hz5m0vkrel+Xy{Oh7pkAu-V!j*W7rY(bO}Q$nMH2`FbGB&N)QaV4<4 | ||
497 | zo)~9JXiP9=;}NPl<C@MmXG&;XFlFNrsyfFsonxFSp<}vEgsRSQP3O3#b6nSnP}ON_ | ||
498 | zI!#Tdsp~|j>ckUB>FI=~GokB5sOq#dotCE4(sd$KbtW~PNlj-`*NIToiD#j5J#9^= | ||
499 | zt?NXn>YUJYPG~wObe#xQos*i*NloXZt`niEb4t@WrRki~bs|)CI+{*L)9L6s5vn>< | ||
500 | zn$DD_Go|Z9sOn5>I@6lYw5}7Os&iV?Ij!lO)^#FOb!If38BJ$K*NIToIiu;E(R9w} | ||
501 | zIuWWmPiZ<&X*y5oIuWWmF_XaEC!a&Jn$B5WCqh-{X-(&8P3LJ{Cqh-{8P3dyPr@^t | ||
502 | zSqL9?X9Uwd3W@23*s~h*tj0X6GZCuHa~kuU#yqDp5vt7d8uPryJg+kms?5hU=3^T3 | ||
503 | zF`bD}WnSP+=`t5MQ$FJ_2&Q~+BP6E0f^%BVIW6a$o)e+SX~IDBih-7z6{O~7YTy`& | ||
504 | zLjy&Cv?7QikV#>n0>>@MV8oK`Gmun34-FKdlm-J8SZSaNlnhir4-FI{S|bfqV8e)V | ||
505 | zss<{chX#reE#g=hsKAC%sF6d-Km}BWs!kZFsFpKfpbC@>6rprQGEjt4Ck#|zITHq| | ||
506 | zK*>M_l;<P^MJRQ`Kn0dFVW0|>3{*fllMEE0)CmI>Sk8ojDo`>|0p(0GP=xY&!axO< | ||
507 | zGhv_#lnhirIg<<&q0|Wj6<E%MfhtfkPyyvkGEjt4Ck#|zITHq|K*>M_lrzad5lWpf | ||
508 | zP=V!47^ngz0~JutBm+e#b;3XemNQ|X3X}{~Ksl2P6rt1!0~J`#gn=qhGEf2KOfpb} | ||
509 | zQYQ>lU^x>8szAv=1(Y+%KoLrvFi?TzOc<yFB?A>u&LjgxD0RX>1(q{mpbC@>R6seC | ||
510 | z3>2Z%2?G^a&V+#~P%=;f<xDbAgi<FARA4z12C6{GKn0XD$v_cGoiI>=<xCi;0wn_# | ||
511 | zP|hR+MJRQ`Kn0dFVW0|>3{*fllMEE0)CmI>Sk8ojDo`>|0p(0GP=rz^3{+q_69%e4 | ||
512 | z$v_2^Gs!>^N}VuJf#pmXr~)Me6;RG314Srx!axxz28u{EP=u<1B2)}iVZuNaCK;&0 | ||
513 | zBm-5LFi?dF167!0pbC==RAItE6($T+VUmF=Ofpb~2?JG_Fi?d_2C6X0Kouqo6p_5T | ||
514 | zFi=FeV!SiSKoR0H$dH(_Z(*Q_WZ%L-5y`$K14StNmJAdjmWs}HV4<vU_xO+1efmLq | ||
515 | zZ;W>N_U)fP6Qy6Nw5mbt9Y(#emWSi66=>tq#xoh#Ue=0qyhxi8ZOUe5y0V7VfPUhp | ||
516 | zwX=;ymc+i5%sg9Ja~lZ&8oAV@mHc>&CHP9v4R(jhtT?un;O4e9#pno)Xkh7OWgK&a | ||
517 | zyj=3Iv0OuoK_;5rOr5f(Kb~ZXDBO+V`OWYo#_C08imwChQxnjdd?wZLDou8aj;$SD | ||
518 | zGDYiA3<$Tu<JnHL(KPOChi#zrR32t83}naR$+ym4P_h?z_5#|cW-nw$XD_sOtE62l | ||
519 | zrD3@*)NVyiklt0&yF9%+klsBey&I<Y2E<!f(E8TuJte)z(|ZHyy<^gQVfx}=`q&B5 | ||
520 | z7nSryp1wGczIaUfVwiq$Fn#<4=@*ssi#+|}K>EdF(l3VTOM~ghPLRH&q%ZOGrGfON | ||
521 | zW73zx^yR_y<0nX8R??Sw`tm^f@-gYlNFSp|*<gA{q?Zp5Oe-+l#rmyYmKozi9y=P> | ||
522 | zVReJU*h=ZuVXiS$ohTbw-O#v9>(yZbGE|)?8(H1ZIKvV!jWa0>vy!3eMA^vdhQ>`s | ||
523 | zuMSg{q3T50$m)j1!HixV<}X9liL#N^4c*tL^y)CF8LCc{jjV3yKAqL8!%SzWI#H%q | ||
524 | z=bSrQ&)%JCRttF5g4Zf`6l?y@>PzD7MA^D>wBlcH6r1ucwJ<p0O%rZ?JzIY3-QdmZ | ||
525 | zzs|n>`a5r3e|z)wcUaqS>nqFQ-8x}eCF4u`OWUxqst-@1rSmUs%WmKP5e0dcb?e2N | ||
526 | z;Z|x*!);VwF|Yuhqs^khqOM!@u*jY!WYldISF(V6`BoNd&6Qfk3>X#SuD^7J>p_D= | ||
527 | zBPa51y^_n#=cpOt#Zf$ya$Ae9Mfz56n|<i!a=ELS@)%a{^NIH3SDuN<R~sah1km#P | ||
528 | zU@?*f%<rG=4W1wgfi;C?_n|W@%lm$&8YfvNOJodIg&IcIpIJQRHr<+ej11GQ6)&eF | ||
529 | z2Lam*jIH}#y0>KnY%4JQfOYS$*uU%f#@$U6`N8I3N-lV?5ErFCdv~xDmu2(wexld4 | ||
530 | z4v^;aVAT2k6GJ^m*FD(Wqc(Qg^)6a<?}h$zLoj}4;PP!+(O{@!a1y-hoAhF_7!z+6 | ||
531 | zslpAmNtYbjHrw-~#SPVk_FUf>-Obg6yV`8o$8_`PyJe_;bY5_EMBfBfWU!Q=*9HsG | ||
532 | z%_Cda{@_Krr!oHVhv9+y+T5qR8zZ2aZ>5r!$*|f$^U%yBUYfR&B!+EYy_PwL!BeUi | ||
533 | zJH^}r3r9Q+B)X@Z)fk=P13w&7x#wBtXTZ)g>WITPg5r&pQc!nmyrmk#S(>>b9xnNr | ||
534 | zx_b#v9Xv-Y><Wb%?S^0Xe&<)bbKl_=Z|3C$tf|F<bYzE*mfHB;uC)`q-?buaBe?l? | ||
535 | zcLTpK*k<49Z32`K?|nSBMFqxTK^_IE-li2fEGdK~(ZdoKBl6ab4a;Hler#`xvEXJG | ||
536 | zb?<E%EZExfX>jcOVhS*0rS~RS1dA#xhkv@Nct@#q?LyeKS<$uFec!bw>{@uu$gZ6a | ||
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 | |||
558 | -- | ||
559 | 2.25.1 | ||
560 | |||
561 | diff view generated by jsdifflib |
1 | From: Aaron Hill <aa1ronham@gmail.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This commit properly sets the ENET_BD_BDU flag once the emulated FEC controller | 3 | The VIOT blob contains the following: |
4 | has finished processing the last descriptor. This is done for both transmit | ||
5 | and receive descriptors. | ||
6 | 4 | ||
7 | This allows the QNX 7.0.0 BSP for the Sabrelite board (which can be | 5 | [000h 0000 4] Signature : "VIOT" [Virtual I/O Translation Table] |
8 | found at http://blackberry.qnx.com/en/developers/bsp) to properly | 6 | [004h 0004 4] Table Length : 00000058 |
9 | control the FEC. Without this patch, the BSP ethernet driver will never | 7 | [008h 0008 1] Revision : 00 |
10 | re-use FEC descriptors, as the unset ENET_BD_BDU flag will cause | 8 | [009h 0009 1] Checksum : 66 |
11 | it to believe that the descriptors are still in use by the NIC. | 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 | ||
12 | 14 | ||
13 | Note that Linux does not appear to use this field at all, and is | 15 | [024h 0036 2] Node count : 0002 |
14 | unaffected by this patch. | 16 | [026h 0038 2] Node offset : 0030 |
17 | [028h 0040 8] Reserved : 0000000000000000 | ||
15 | 18 | ||
16 | Without this patch, QNX will think that the NIC is still processing its | 19 | [030h 0048 1] Type : 03 [VirtIO-PCI IOMMU] |
17 | transaction descriptors, and won't send any more data over the network. | 20 | [031h 0049 1] Reserved : 00 |
21 | [032h 0050 2] Length : 0010 | ||
18 | 22 | ||
19 | For reference: | 23 | [034h 0052 2] PCI Segment : 0000 |
24 | [036h 0054 2] PCI BDF number : 0008 | ||
25 | [038h 0056 8] Reserved : 0000000000000000 | ||
20 | 26 | ||
21 | On page 1192 of the I.MX 6DQ reference manual revision (Rev. 5, 06/2018), | 27 | [040h 0064 1] Type : 01 [PCI Range] |
22 | which can be found at https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/i.mx-applications-processors/i.mx-6-processors/i.mx-6quad-processors-high-performance-3d-graphics-hd-video-arm-cortex-a9-core:i.MX6Q?&tab=Documentation_Tab&linkline=Application-Note | 28 | [041h 0065 1] Reserved : 00 |
29 | [042h 0066 2] Length : 0018 | ||
23 | 30 | ||
24 | the 'BDU' field is described as follows for the 'Enhanced transmit | 31 | [044h 0068 4] Endpoint start : 00000000 |
25 | buffer descriptor': | 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 | ||
26 | 38 | ||
27 | 'Last buffer descriptor update done. Indicates that the last BD data has been updated by | 39 | Acked-by: Ani Sinha <ani@anisinha.ca> |
28 | uDMA. This field is written by the user (=0) and uDMA (=1).' | 40 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
29 | 41 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | |
30 | The same description is used for the receive buffer descriptor. | 42 | Message-id: 20211210170415.583179-9-jean-philippe@linaro.org |
31 | |||
32 | Signed-off-by: Aaron Hill <aa1ronham@gmail.com> | ||
33 | Message-id: 20190805142417.10433-1-aaron.hill@alertinnovation.com | ||
34 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 43 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
36 | --- | 44 | --- |
37 | hw/net/imx_fec.c | 4 ++++ | 45 | tests/qtest/bios-tables-test-allowed-diff.h | 1 - |
38 | 1 file changed, 4 insertions(+) | 46 | tests/data/acpi/virt/VIOT | Bin 0 -> 88 bytes |
47 | 2 files changed, 1 deletion(-) | ||
39 | 48 | ||
40 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 49 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h |
41 | index XXXXXXX..XXXXXXX 100644 | 50 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/hw/net/imx_fec.c | 51 | --- a/tests/qtest/bios-tables-test-allowed-diff.h |
43 | +++ b/hw/net/imx_fec.c | 52 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h |
44 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) | 53 | @@ -1,2 +1 @@ |
45 | if (bd.option & ENET_BD_TX_INT) { | 54 | /* List of comma-separated changed AML files to ignore */ |
46 | s->regs[ENET_EIR] |= int_txf; | 55 | -"tests/data/acpi/virt/VIOT", |
47 | } | 56 | diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/virt/VIOT |
48 | + /* Indicate that we've updated the last buffer descriptor. */ | 57 | index XXXXXXX..XXXXXXX 100644 |
49 | + bd.last_buffer = ENET_BD_BDU; | 58 | GIT binary patch |
50 | } | 59 | literal 88 |
51 | if (bd.option & ENET_BD_TX_INT) { | 60 | zcmWIZ^bd((0D?3pe`k+i1*eDrX9XZ&1PX!JAexE60Hgv8m>C3sGzXN&z`)2L0cSHX |
52 | s->regs[ENET_EIR] |= int_txb; | 61 | I{D-Rq0Q5fy0RR91 |
53 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | 62 | |
54 | /* Last buffer in frame. */ | 63 | literal 0 |
55 | bd.flags |= flags | ENET_BD_L; | 64 | HcmV?d00001 |
56 | FEC_PRINTF("rx frame flags %04x\n", bd.flags); | 65 | |
57 | + /* Indicate that we've updated the last buffer descriptor. */ | ||
58 | + bd.last_buffer = ENET_BD_BDU; | ||
59 | if (bd.option & ENET_BD_RX_INT) { | ||
60 | s->regs[ENET_EIR] |= ENET_INT_RXF; | ||
61 | } | ||
62 | -- | 66 | -- |
63 | 2.20.1 | 67 | 2.25.1 |
64 | 68 | ||
65 | 69 | diff view generated by jsdifflib |