1 | Hi; here's the first target-arm pullreq for the 7.0 cycle. | 1 | Hi; this mostly contains the first slice of A64 decodetree |
---|---|---|---|
2 | patches, plus some other minor pieces. It also has the | ||
3 | enablement of MTE for KVM guests. | ||
2 | 4 | ||
3 | thanks | 5 | thanks |
4 | -- PMM | 6 | -- PMM |
5 | 7 | ||
6 | The following changes since commit 76b56fdfc9fa43ec6e5986aee33f108c6c6a511e: | 8 | The following changes since commit d27e7c359330ba7020bdbed7ed2316cb4cf6ffc1: |
7 | 9 | ||
8 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2021-12-14 12:46:18 -0800) | 10 | qapi/parser: Drop two bad type hints for now (2023-05-17 10:18:33 -0700) |
9 | 11 | ||
10 | are available in the Git repository at: | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20211215 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230518 |
13 | 15 | ||
14 | for you to fetch changes up to aed176558806674d030a8305d989d4e6a5073359: | 16 | for you to fetch changes up to 91608e2a44f36e79cb83f863b8a7bb57d2c98061: |
15 | 17 | ||
16 | tests/acpi: add expected blob for VIOT test on virt machine (2021-12-15 10:35:26 +0000) | 18 | docs: Convert u2f.txt to rST (2023-05-18 11:40:32 +0100) |
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | target-arm queue: | 21 | target-arm queue: |
20 | * ITS: error reporting cleanup | 22 | * Fix vd == vm overlap in sve_ldff1_z |
21 | * aspeed: improve documentation | 23 | * Add support for MTE with KVM guests |
22 | * Fix STM32F2XX USART data register readout | 24 | * Add RAZ/WI handling for DBGDTR[TX|RX] |
23 | * allow emulated GICv3 to be disabled in non-TCG builds | 25 | * Start of conversion of A64 decoder to decodetree |
24 | * fix exception priority for singlestep, misaligned PC, bp, etc | 26 | * Saturate L2CTLR_EL1 core count field rather than overflowing |
25 | * Correct calculation of tlb range invalidate length | 27 | * vexpress: Avoid trivial memory leak of 'flashalias' |
26 | * npcm7xx_emc: fix missing queue_flush | 28 | * sbsa-ref: switch default cpu core to Neoverse-N1 |
27 | * virt: Add VIOT ACPI table for virtio-iommu | 29 | * sbsa-ref: use Bochs graphics card instead of VGA |
28 | * target/i386: Use assert() to sanity-check b1 in SSE decode | 30 | * MAINTAINERS: Add Marcin Juszkiewicz to sbsa-ref reviewer list |
29 | * Don't include qemu-common unnecessarily | 31 | * docs: Convert u2f.txt to rST |
30 | 32 | ||
31 | ---------------------------------------------------------------- | 33 | ---------------------------------------------------------------- |
32 | Alex Bennée (1): | 34 | Alex Bennée (1): |
33 | hw/intc: clean-up error reporting for failed ITS cmd | 35 | target/arm: add RAZ/WI handling for DBGDTR[TX|RX] |
34 | 36 | ||
35 | Jean-Philippe Brucker (8): | 37 | Cornelia Huck (1): |
36 | hw/arm/virt-acpi-build: Add VIOT table for virtio-iommu | 38 | arm/kvm: add support for MTE |
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 | ||
44 | 39 | ||
45 | Joel Stanley (4): | 40 | Marcin Juszkiewicz (3): |
46 | docs: aspeed: Add new boards | 41 | sbsa-ref: switch default cpu core to Neoverse-N1 |
47 | docs: aspeed: Update OpenBMC image URL | 42 | Maintainers: add myself as reviewer for sbsa-ref |
48 | docs: aspeed: Give an example of booting a kernel | 43 | sbsa-ref: use Bochs graphics card instead of VGA |
49 | docs: aspeed: ADC is now modelled | ||
50 | 44 | ||
51 | Olivier Hériveaux (1): | 45 | Peter Maydell (14): |
52 | Fix STM32F2XX USART data register readout | 46 | target/arm: Create decodetree skeleton for A64 |
53 | 47 | target/arm: Pull calls to disas_sve() and disas_sme() out of legacy decoder | |
54 | Patrick Venture (1): | 48 | target/arm: Convert Extract instructions to decodetree |
55 | hw/net: npcm7xx_emc fix missing queue_flush | 49 | target/arm: Convert unconditional branch immediate to decodetree |
56 | 50 | target/arm: Convert CBZ, CBNZ to decodetree | |
57 | Peter Maydell (6): | 51 | target/arm: Convert TBZ, TBNZ to decodetree |
58 | target/i386: Use assert() to sanity-check b1 in SSE decode | 52 | target/arm: Convert conditional branch insns to decodetree |
59 | include/hw/i386: Don't include qemu-common.h in .h files | 53 | target/arm: Convert BR, BLR, RET to decodetree |
60 | target/hexagon/cpu.h: don't include qemu-common.h | 54 | target/arm: Convert BRA[AB]Z, BLR[AB]Z, RETA[AB] to decodetree |
61 | target/rx/cpu.h: Don't include qemu-common.h | 55 | target/arm: Convert BRAA, BRAB, BLRAA, BLRAB to decodetree |
62 | hw/arm: Don't include qemu-common.h unnecessarily | 56 | target/arm: Convert ERET, ERETAA, ERETAB to decodetree |
63 | target/arm: Correct calculation of tlb range invalidate length | 57 | target/arm: Saturate L2CTLR_EL1 core count field rather than overflowing |
64 | 58 | hw/arm/vexpress: Avoid trivial memory leak of 'flashalias' | |
65 | Philippe Mathieu-Daudé (2): | 59 | docs: Convert u2f.txt to rST |
66 | hw/intc/arm_gicv3: Extract gicv3_set_gicv3state from arm_gicv3_cpuif.c | ||
67 | hw/intc/arm_gicv3: Introduce CONFIG_ARM_GIC_TCG Kconfig selector | ||
68 | 60 | ||
69 | Richard Henderson (10): | 61 | Richard Henderson (10): |
70 | target/arm: Hoist pc_next to a local variable in aarch64_tr_translate_insn | 62 | target/arm: Fix vd == vm overlap in sve_ldff1_z |
71 | target/arm: Hoist pc_next to a local variable in arm_tr_translate_insn | 63 | target/arm: Split out disas_a64_legacy |
72 | target/arm: Hoist pc_next to a local variable in thumb_tr_translate_insn | 64 | target/arm: Convert PC-rel addressing to decodetree |
73 | target/arm: Split arm_pre_translate_insn | 65 | target/arm: Split gen_add_CC and gen_sub_CC |
74 | target/arm: Advance pc for arch single-step exception | 66 | target/arm: Convert Add/subtract (immediate) to decodetree |
75 | target/arm: Split compute_fsr_fsc out of arm_deliver_fault | 67 | target/arm: Convert Add/subtract (immediate with tags) to decodetree |
76 | target/arm: Take an exception if PC is misaligned | 68 | target/arm: Replace bitmask64 with MAKE_64BIT_MASK |
77 | target/arm: Assert thumb pc is aligned | 69 | target/arm: Convert Logical (immediate) to decodetree |
78 | target/arm: Suppress bp for exceptions with more priority | 70 | target/arm: Convert Move wide (immediate) to decodetree |
79 | tests/tcg: Add arm and aarch64 pc alignment tests | 71 | target/arm: Convert Bitfield to decodetree |
80 | 72 | ||
81 | docs/system/arm/aspeed.rst | 26 ++++++++++++---- | 73 | MAINTAINERS | 1 + |
82 | include/hw/i386/microvm.h | 1 - | 74 | docs/system/device-emulation.rst | 1 + |
83 | include/hw/i386/x86.h | 1 - | 75 | docs/system/devices/usb-u2f.rst | 93 +++ |
84 | target/arm/helper.h | 1 + | 76 | docs/system/devices/usb.rst | 2 +- |
85 | target/arm/syndrome.h | 5 +++ | 77 | docs/u2f.txt | 110 ---- |
86 | target/hexagon/cpu.h | 1 - | 78 | target/arm/cpu.h | 4 + |
87 | target/rx/cpu.h | 1 - | 79 | target/arm/kvm_arm.h | 19 + |
88 | hw/arm/boot.c | 1 - | 80 | target/arm/tcg/translate.h | 5 + |
89 | hw/arm/digic_boards.c | 1 - | 81 | target/arm/tcg/a64.decode | 152 +++++ |
90 | hw/arm/highbank.c | 1 - | 82 | hw/arm/sbsa-ref.c | 4 +- |
91 | hw/arm/npcm7xx_boards.c | 1 - | 83 | hw/arm/vexpress.c | 40 +- |
92 | hw/arm/sbsa-ref.c | 1 - | 84 | hw/arm/virt.c | 73 ++- |
93 | hw/arm/stm32f405_soc.c | 1 - | 85 | target/arm/cortex-regs.c | 11 +- |
94 | hw/arm/vexpress.c | 1 - | 86 | target/arm/cpu.c | 9 +- |
95 | hw/arm/virt-acpi-build.c | 7 +++++ | 87 | target/arm/debug_helper.c | 11 +- |
96 | hw/arm/virt.c | 21 ++++++------- | 88 | target/arm/kvm.c | 35 + |
97 | hw/char/stm32f2xx_usart.c | 3 +- | 89 | target/arm/kvm64.c | 5 + |
98 | hw/intc/arm_gicv3.c | 2 +- | 90 | target/arm/tcg/sve_helper.c | 6 + |
99 | hw/intc/arm_gicv3_cpuif.c | 10 +----- | 91 | target/arm/tcg/translate-a64.c | 1321 ++++++++++++++++---------------------- |
100 | hw/intc/arm_gicv3_cpuif_common.c | 22 +++++++++++++ | 92 | target/arm/tcg/meson.build | 1 + |
101 | hw/intc/arm_gicv3_its.c | 39 +++++++++++++++-------- | 93 | 20 files changed, 979 insertions(+), 924 deletions(-) |
102 | hw/net/npcm7xx_emc.c | 18 +++++------ | 94 | create mode 100644 docs/system/devices/usb-u2f.rst |
103 | hw/virtio/virtio-iommu-pci.c | 12 ++------ | 95 | delete mode 100644 docs/u2f.txt |
104 | linux-user/aarch64/cpu_loop.c | 46 ++++++++++++++++------------ | 96 | create mode 100644 target/arm/tcg/a64.decode |
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 | 97 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Move it to the supported list. | 3 | The world outside moves to newer and newer cpu cores. Let move SBSA |
4 | Reference Platform to something newer as well. | ||
4 | 5 | ||
5 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
6 | Message-id: 20211117065752.330632-5-joel@jms.id.au | 7 | Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> |
8 | Message-id: 20230506183417.1360427-1-marcin.juszkiewicz@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | docs/system/arm/aspeed.rst | 2 +- | 11 | hw/arm/sbsa-ref.c | 2 +- |
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | 13 | ||
12 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 14 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/docs/system/arm/aspeed.rst | 16 | --- a/hw/arm/sbsa-ref.c |
15 | +++ b/docs/system/arm/aspeed.rst | 17 | +++ b/hw/arm/sbsa-ref.c |
16 | @@ -XXX,XX +XXX,XX @@ Supported devices | 18 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) |
17 | * Front LEDs (PCA9552 on I2C bus) | 19 | |
18 | * LPC Peripheral Controller (a subset of subdevices are supported) | 20 | mc->init = sbsa_ref_init; |
19 | * Hash/Crypto Engine (HACE) - Hash support only. TODO: HMAC and RSA | 21 | mc->desc = "QEMU 'SBSA Reference' ARM Virtual Machine"; |
20 | + * ADC | 22 | - mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a57"); |
21 | 23 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("neoverse-n1"); | |
22 | 24 | mc->max_cpus = 512; | |
23 | Missing devices | 25 | mc->pci_allow_0_address = true; |
24 | --------------- | 26 | mc->minimum_page_bits = 12; |
25 | |||
26 | * Coprocessor support | ||
27 | - * ADC (out of tree implementation) | ||
28 | * PWM and Fan Controller | ||
29 | * Slave GPIO Controller | ||
30 | * Super I/O Controller | ||
31 | -- | 27 | -- |
32 | 2.25.1 | 28 | 2.34.1 |
33 | |||
34 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | If vd == vm, copy vm to scratch, so that we can pre-zero | ||
4 | the output and still access the gather indicies. | ||
5 | |||
6 | Cc: qemu-stable@nongnu.org | ||
7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1612 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20230504104232.1877774-1-richard.henderson@linaro.org | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | --- | 12 | --- |
7 | target/arm/translate.c | 16 ++++++++-------- | 13 | target/arm/tcg/sve_helper.c | 6 ++++++ |
8 | 1 file changed, 8 insertions(+), 8 deletions(-) | 14 | 1 file changed, 6 insertions(+) |
9 | 15 | ||
10 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c |
11 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/translate.c | 18 | --- a/target/arm/tcg/sve_helper.c |
13 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/tcg/sve_helper.c |
14 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 20 | @@ -XXX,XX +XXX,XX @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, |
15 | { | 21 | intptr_t reg_off; |
16 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 22 | SVEHostPage info; |
17 | CPUARMState *env = cpu->env_ptr; | 23 | target_ulong addr, in_page; |
18 | + uint32_t pc = dc->base.pc_next; | 24 | + ARMVectorReg scratch; |
19 | uint32_t insn; | 25 | |
20 | bool is_16bit; | 26 | /* Skip to the first true predicate. */ |
21 | 27 | reg_off = find_next_active(vg, 0, reg_max, esz); | |
22 | if (arm_pre_translate_insn(dc)) { | 28 | @@ -XXX,XX +XXX,XX @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, |
23 | - dc->base.pc_next += 2; | ||
24 | + dc->base.pc_next = pc + 2; | ||
25 | return; | 29 | return; |
26 | } | 30 | } |
27 | 31 | ||
28 | - dc->pc_curr = dc->base.pc_next; | 32 | + /* Protect against overlap between vd and vm. */ |
29 | - insn = arm_lduw_code(env, &dc->base, dc->base.pc_next, dc->sctlr_b); | 33 | + if (unlikely(vd == vm)) { |
30 | + dc->pc_curr = pc; | 34 | + vm = memcpy(&scratch, vm, reg_max); |
31 | + insn = arm_lduw_code(env, &dc->base, pc, dc->sctlr_b); | 35 | + } |
32 | is_16bit = thumb_insn_is_16bit(dc, dc->base.pc_next, insn); | 36 | + |
33 | - dc->base.pc_next += 2; | 37 | /* |
34 | + pc += 2; | 38 | * Probe the first element, allowing faults. |
35 | if (!is_16bit) { | 39 | */ |
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; | ||
45 | dc->insn = insn; | ||
46 | |||
47 | if (dc->pstate_il) { | ||
48 | -- | 40 | -- |
49 | 2.25.1 | 41 | 2.34.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The VIOT blob contains the following: | 3 | At Linaro I work on sbsa-ref, know direction it goes. |
4 | 4 | ||
5 | [000h 0000 4] Signature : "VIOT" [Virtual I/O Translation Table] | 5 | May not get code details each time. |
6 | [004h 0004 4] Table Length : 00000058 | ||
7 | [008h 0008 1] Revision : 00 | ||
8 | [009h 0009 1] Checksum : 66 | ||
9 | [00Ah 0010 6] Oem ID : "BOCHS " | ||
10 | [010h 0016 8] Oem Table ID : "BXPC " | ||
11 | [018h 0024 4] Oem Revision : 00000001 | ||
12 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | ||
13 | [020h 0032 4] Asl Compiler Revision : 00000001 | ||
14 | 6 | ||
15 | [024h 0036 2] Node count : 0002 | 7 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
16 | [026h 0038 2] Node offset : 0030 | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
17 | [028h 0040 8] Reserved : 0000000000000000 | 9 | Message-id: 20230515143753.365591-1-marcin.juszkiewicz@linaro.org |
18 | |||
19 | [030h 0048 1] Type : 03 [VirtIO-PCI IOMMU] | ||
20 | [031h 0049 1] Reserved : 00 | ||
21 | [032h 0050 2] Length : 0010 | ||
22 | |||
23 | [034h 0052 2] PCI Segment : 0000 | ||
24 | [036h 0054 2] PCI BDF number : 0008 | ||
25 | [038h 0056 8] Reserved : 0000000000000000 | ||
26 | |||
27 | [040h 0064 1] Type : 01 [PCI Range] | ||
28 | [041h 0065 1] Reserved : 00 | ||
29 | [042h 0066 2] Length : 0018 | ||
30 | |||
31 | [044h 0068 4] Endpoint start : 00000000 | ||
32 | [048h 0072 2] PCI Segment start : 0000 | ||
33 | [04Ah 0074 2] PCI Segment end : 0000 | ||
34 | [04Ch 0076 2] PCI BDF start : 0000 | ||
35 | [04Eh 0078 2] PCI BDF end : 00FF | ||
36 | [050h 0080 2] Output node : 0030 | ||
37 | [052h 0082 6] Reserved : 000000000000 | ||
38 | |||
39 | Acked-by: Ani Sinha <ani@anisinha.ca> | ||
40 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
41 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
42 | Message-id: 20211210170415.583179-9-jean-philippe@linaro.org | ||
43 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
44 | --- | 11 | --- |
45 | tests/qtest/bios-tables-test-allowed-diff.h | 1 - | 12 | MAINTAINERS | 1 + |
46 | tests/data/acpi/virt/VIOT | Bin 0 -> 88 bytes | 13 | 1 file changed, 1 insertion(+) |
47 | 2 files changed, 1 deletion(-) | ||
48 | 14 | ||
49 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | 15 | diff --git a/MAINTAINERS b/MAINTAINERS |
50 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | 17 | --- a/MAINTAINERS |
52 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | 18 | +++ b/MAINTAINERS |
53 | @@ -1,2 +1 @@ | 19 | @@ -XXX,XX +XXX,XX @@ SBSA-REF |
54 | /* List of comma-separated changed AML files to ignore */ | 20 | M: Radoslaw Biernacki <rad@semihalf.com> |
55 | -"tests/data/acpi/virt/VIOT", | 21 | M: Peter Maydell <peter.maydell@linaro.org> |
56 | diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/virt/VIOT | 22 | R: Leif Lindholm <quic_llindhol@quicinc.com> |
57 | index XXXXXXX..XXXXXXX 100644 | 23 | +R: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
58 | GIT binary patch | 24 | L: qemu-arm@nongnu.org |
59 | literal 88 | 25 | S: Maintained |
60 | zcmWIZ^bd((0D?3pe`k+i1*eDrX9XZ&1PX!JAexE60Hgv8m>C3sGzXN&z`)2L0cSHX | 26 | F: hw/arm/sbsa-ref.c |
61 | I{D-Rq0Q5fy0RR91 | ||
62 | |||
63 | literal 0 | ||
64 | HcmV?d00001 | ||
65 | |||
66 | -- | 27 | -- |
67 | 2.25.1 | 28 | 2.34.1 |
68 | 29 | ||
69 | 30 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | We do not support instantiating multiple IOMMUs. Before adding a | 3 | Extend the 'mte' property for the virt machine to cover KVM as |
4 | virtio-iommu, check that no other IOMMU is present. This will detect | 4 | well. For KVM, we don't allocate tag memory, but instead enable the |
5 | both "iommu=smmuv3" machine parameter and another virtio-iommu instance. | 5 | capability. |
6 | 6 | ||
7 | Fixes: 70e89132c9 ("hw/arm/virt: Add the virtio-iommu device tree mappings") | 7 | If MTE has been enabled, we need to disable migration, as we do not |
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 8 | yet have a way to migrate the tags as well. Therefore, MTE will stay |
9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | 9 | off with KVM unless requested explicitly. |
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | 10 | |
11 | Message-id: 20211210170415.583179-4-jean-philippe@linaro.org | 11 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20230428095533.21747-2-cohuck@redhat.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 16 | --- |
14 | hw/arm/virt.c | 5 +++++ | 17 | target/arm/cpu.h | 4 +++ |
15 | 1 file changed, 5 insertions(+) | 18 | target/arm/kvm_arm.h | 19 ++++++++++++ |
16 | 19 | hw/arm/virt.c | 73 +++++++++++++++++++++++++------------------- | |
20 | target/arm/cpu.c | 9 +++--- | ||
21 | target/arm/kvm.c | 35 +++++++++++++++++++++ | ||
22 | target/arm/kvm64.c | 5 +++ | ||
23 | 6 files changed, 109 insertions(+), 36 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/cpu.h | ||
28 | +++ b/target/arm/cpu.h | ||
29 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
30 | */ | ||
31 | uint32_t psci_conduit; | ||
32 | |||
33 | + /* CPU has Memory Tag Extension */ | ||
34 | + bool has_mte; | ||
35 | + | ||
36 | /* For v8M, initial value of the Secure VTOR */ | ||
37 | uint32_t init_svtor; | ||
38 | /* For v8M, initial value of the Non-secure VTOR */ | ||
39 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
40 | bool prop_pauth; | ||
41 | bool prop_pauth_impdef; | ||
42 | bool prop_lpa2; | ||
43 | + OnOffAuto prop_mte; | ||
44 | |||
45 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ | ||
46 | uint32_t dcz_blocksize; | ||
47 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/kvm_arm.h | ||
50 | +++ b/target/arm/kvm_arm.h | ||
51 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_pmu_supported(void); | ||
52 | */ | ||
53 | bool kvm_arm_sve_supported(void); | ||
54 | |||
55 | +/** | ||
56 | + * kvm_arm_mte_supported: | ||
57 | + * | ||
58 | + * Returns: true if KVM can enable MTE, and false otherwise. | ||
59 | + */ | ||
60 | +bool kvm_arm_mte_supported(void); | ||
61 | + | ||
62 | /** | ||
63 | * kvm_arm_get_max_vm_ipa_size: | ||
64 | * @ms: Machine state handle | ||
65 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa); | ||
66 | |||
67 | int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level); | ||
68 | |||
69 | +void kvm_arm_enable_mte(Object *cpuobj, Error **errp); | ||
70 | + | ||
71 | #else | ||
72 | |||
73 | /* | ||
74 | @@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_steal_time_supported(void) | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | +static inline bool kvm_arm_mte_supported(void) | ||
79 | +{ | ||
80 | + return false; | ||
81 | +} | ||
82 | + | ||
83 | /* | ||
84 | * These functions should never actually be called without KVM support. | ||
85 | */ | ||
86 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t kvm_arm_sve_get_vls(CPUState *cs) | ||
87 | g_assert_not_reached(); | ||
88 | } | ||
89 | |||
90 | +static inline void kvm_arm_enable_mte(Object *cpuobj, Error **errp) | ||
91 | +{ | ||
92 | + g_assert_not_reached(); | ||
93 | +} | ||
94 | + | ||
95 | #endif | ||
96 | |||
97 | static inline const char *gic_class_name(void) | ||
17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 98 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
18 | index XXXXXXX..XXXXXXX 100644 | 99 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/virt.c | 100 | --- a/hw/arm/virt.c |
20 | +++ b/hw/arm/virt.c | 101 | +++ b/hw/arm/virt.c |
21 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, | 102 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
22 | hwaddr db_start = 0, db_end = 0; | 103 | exit(1); |
23 | char *resv_prop_str; | 104 | } |
24 | 105 | ||
25 | + if (vms->iommu != VIRT_IOMMU_NONE) { | 106 | - if (vms->mte && (kvm_enabled() || hvf_enabled())) { |
26 | + error_setg(errp, "virt machine does not support multiple IOMMUs"); | 107 | + if (vms->mte && hvf_enabled()) { |
108 | error_report("mach-virt: %s does not support providing " | ||
109 | "MTE to the guest CPU", | ||
110 | current_accel_name()); | ||
111 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
112 | } | ||
113 | |||
114 | if (vms->mte) { | ||
115 | - /* Create the memory region only once, but link to all cpus. */ | ||
116 | - if (!tag_sysmem) { | ||
117 | - /* | ||
118 | - * The property exists only if MemTag is supported. | ||
119 | - * If it is, we must allocate the ram to back that up. | ||
120 | - */ | ||
121 | - if (!object_property_find(cpuobj, "tag-memory")) { | ||
122 | - error_report("MTE requested, but not supported " | ||
123 | - "by the guest CPU"); | ||
124 | + if (tcg_enabled()) { | ||
125 | + /* Create the memory region only once, but link to all cpus. */ | ||
126 | + if (!tag_sysmem) { | ||
127 | + /* | ||
128 | + * The property exists only if MemTag is supported. | ||
129 | + * If it is, we must allocate the ram to back that up. | ||
130 | + */ | ||
131 | + if (!object_property_find(cpuobj, "tag-memory")) { | ||
132 | + error_report("MTE requested, but not supported " | ||
133 | + "by the guest CPU"); | ||
134 | + exit(1); | ||
135 | + } | ||
136 | + | ||
137 | + tag_sysmem = g_new(MemoryRegion, 1); | ||
138 | + memory_region_init(tag_sysmem, OBJECT(machine), | ||
139 | + "tag-memory", UINT64_MAX / 32); | ||
140 | + | ||
141 | + if (vms->secure) { | ||
142 | + secure_tag_sysmem = g_new(MemoryRegion, 1); | ||
143 | + memory_region_init(secure_tag_sysmem, OBJECT(machine), | ||
144 | + "secure-tag-memory", | ||
145 | + UINT64_MAX / 32); | ||
146 | + | ||
147 | + /* As with ram, secure-tag takes precedence over tag. */ | ||
148 | + memory_region_add_subregion_overlap(secure_tag_sysmem, | ||
149 | + 0, tag_sysmem, -1); | ||
150 | + } | ||
151 | + } | ||
152 | + | ||
153 | + object_property_set_link(cpuobj, "tag-memory", | ||
154 | + OBJECT(tag_sysmem), &error_abort); | ||
155 | + if (vms->secure) { | ||
156 | + object_property_set_link(cpuobj, "secure-tag-memory", | ||
157 | + OBJECT(secure_tag_sysmem), | ||
158 | + &error_abort); | ||
159 | + } | ||
160 | + } else if (kvm_enabled()) { | ||
161 | + if (!kvm_arm_mte_supported()) { | ||
162 | + error_report("MTE requested, but not supported by KVM"); | ||
163 | exit(1); | ||
164 | } | ||
165 | - | ||
166 | - tag_sysmem = g_new(MemoryRegion, 1); | ||
167 | - memory_region_init(tag_sysmem, OBJECT(machine), | ||
168 | - "tag-memory", UINT64_MAX / 32); | ||
169 | - | ||
170 | - if (vms->secure) { | ||
171 | - secure_tag_sysmem = g_new(MemoryRegion, 1); | ||
172 | - memory_region_init(secure_tag_sysmem, OBJECT(machine), | ||
173 | - "secure-tag-memory", UINT64_MAX / 32); | ||
174 | - | ||
175 | - /* As with ram, secure-tag takes precedence over tag. */ | ||
176 | - memory_region_add_subregion_overlap(secure_tag_sysmem, 0, | ||
177 | - tag_sysmem, -1); | ||
178 | - } | ||
179 | - } | ||
180 | - | ||
181 | - object_property_set_link(cpuobj, "tag-memory", OBJECT(tag_sysmem), | ||
182 | - &error_abort); | ||
183 | - if (vms->secure) { | ||
184 | - object_property_set_link(cpuobj, "secure-tag-memory", | ||
185 | - OBJECT(secure_tag_sysmem), | ||
186 | - &error_abort); | ||
187 | + kvm_arm_enable_mte(cpuobj, &error_abort); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
192 | index XXXXXXX..XXXXXXX 100644 | ||
193 | --- a/target/arm/cpu.c | ||
194 | +++ b/target/arm/cpu.c | ||
195 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | ||
196 | qdev_prop_allow_set_link_before_realize, | ||
197 | OBJ_PROP_LINK_STRONG); | ||
198 | } | ||
199 | + cpu->has_mte = true; | ||
200 | } | ||
201 | #endif | ||
202 | } | ||
203 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
204 | } | ||
205 | if (cpu->tag_memory) { | ||
206 | error_setg(errp, | ||
207 | - "Cannot enable %s when guest CPUs has MTE enabled", | ||
208 | + "Cannot enable %s when guest CPUs has tag memory enabled", | ||
209 | current_accel_name()); | ||
210 | return; | ||
211 | } | ||
212 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
213 | } | ||
214 | |||
215 | #ifndef CONFIG_USER_ONLY | ||
216 | - if (cpu->tag_memory == NULL && cpu_isar_feature(aa64_mte, cpu)) { | ||
217 | + if (!cpu->has_mte && cpu_isar_feature(aa64_mte, cpu)) { | ||
218 | /* | ||
219 | - * Disable the MTE feature bits if we do not have tag-memory | ||
220 | - * provided by the machine. | ||
221 | + * Disable the MTE feature bits if we do not have the feature | ||
222 | + * setup by the machine. | ||
223 | */ | ||
224 | cpu->isar.id_aa64pfr1 = | ||
225 | FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); | ||
226 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
227 | index XXXXXXX..XXXXXXX 100644 | ||
228 | --- a/target/arm/kvm.c | ||
229 | +++ b/target/arm/kvm.c | ||
230 | @@ -XXX,XX +XXX,XX @@ | ||
231 | #include "hw/boards.h" | ||
232 | #include "hw/irq.h" | ||
233 | #include "qemu/log.h" | ||
234 | +#include "migration/blocker.h" | ||
235 | |||
236 | const KVMCapabilityInfo kvm_arch_required_capabilities[] = { | ||
237 | KVM_CAP_LAST_INFO | ||
238 | @@ -XXX,XX +XXX,XX @@ bool kvm_arch_cpu_check_are_resettable(void) | ||
239 | void kvm_arch_accel_class_init(ObjectClass *oc) | ||
240 | { | ||
241 | } | ||
242 | + | ||
243 | +void kvm_arm_enable_mte(Object *cpuobj, Error **errp) | ||
244 | +{ | ||
245 | + static bool tried_to_enable; | ||
246 | + static bool succeeded_to_enable; | ||
247 | + Error *mte_migration_blocker = NULL; | ||
248 | + int ret; | ||
249 | + | ||
250 | + if (!tried_to_enable) { | ||
251 | + /* | ||
252 | + * MTE on KVM is enabled on a per-VM basis (and retrying doesn't make | ||
253 | + * sense), and we only want a single migration blocker as well. | ||
254 | + */ | ||
255 | + tried_to_enable = true; | ||
256 | + | ||
257 | + ret = kvm_vm_enable_cap(kvm_state, KVM_CAP_ARM_MTE, 0); | ||
258 | + if (ret) { | ||
259 | + error_setg_errno(errp, -ret, "Failed to enable KVM_CAP_ARM_MTE"); | ||
27 | + return; | 260 | + return; |
28 | + } | 261 | + } |
29 | + | 262 | + |
30 | switch (vms->msi_controller) { | 263 | + /* TODO: add proper migration support with MTE enabled */ |
31 | case VIRT_MSI_CTRL_NONE: | 264 | + error_setg(&mte_migration_blocker, |
32 | return; | 265 | + "Live migration disabled due to MTE enabled"); |
266 | + if (migrate_add_blocker(mte_migration_blocker, errp)) { | ||
267 | + error_free(mte_migration_blocker); | ||
268 | + return; | ||
269 | + } | ||
270 | + succeeded_to_enable = true; | ||
271 | + } | ||
272 | + if (succeeded_to_enable) { | ||
273 | + object_property_set_bool(cpuobj, "has_mte", true, NULL); | ||
274 | + } | ||
275 | +} | ||
276 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
277 | index XXXXXXX..XXXXXXX 100644 | ||
278 | --- a/target/arm/kvm64.c | ||
279 | +++ b/target/arm/kvm64.c | ||
280 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_steal_time_supported(void) | ||
281 | return kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME); | ||
282 | } | ||
283 | |||
284 | +bool kvm_arm_mte_supported(void) | ||
285 | +{ | ||
286 | + return kvm_check_extension(kvm_state, KVM_CAP_ARM_MTE); | ||
287 | +} | ||
288 | + | ||
289 | QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1); | ||
290 | |||
291 | uint32_t kvm_arm_sve_get_vls(CPUState *cs) | ||
33 | -- | 292 | -- |
34 | 2.25.1 | 293 | 2.34.1 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Both single-step and pc alignment faults have priority over | 3 | The commit b3aa2f2128 (target/arm: provide stubs for more external |
4 | breakpoint exceptions. | 4 | debug registers) was added to handle HyperV's unconditional usage of |
5 | Debug Communications Channel. It turns out that Linux will similarly | ||
6 | break if you enable CONFIG_HVC_DCC "ARM JTAG DCC console". | ||
5 | 7 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Extend the registers we RAZ/WI set to avoid this. |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | |
10 | Cc: Anders Roxell <anders.roxell@linaro.org> | ||
11 | Cc: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> | ||
12 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20230516104420.407912-1-alex.bennee@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 16 | --- |
10 | target/arm/debug_helper.c | 23 +++++++++++++++++++++++ | 17 | target/arm/debug_helper.c | 11 +++++++++-- |
11 | 1 file changed, 23 insertions(+) | 18 | 1 file changed, 9 insertions(+), 2 deletions(-) |
12 | 19 | ||
13 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | 20 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/debug_helper.c | 22 | --- a/target/arm/debug_helper.c |
16 | +++ b/target/arm/debug_helper.c | 23 | +++ b/target/arm/debug_helper.c |
17 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_breakpoint(CPUState *cs) | 24 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
18 | { | 25 | .access = PL0_R, .accessfn = access_tdcc, |
19 | ARMCPU *cpu = ARM_CPU(cs); | 26 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
20 | CPUARMState *env = &cpu->env; | ||
21 | + target_ulong pc; | ||
22 | int n; | ||
23 | |||
24 | /* | 27 | /* |
25 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_breakpoint(CPUState *cs) | 28 | - * OSDTRRX_EL1/OSDTRTX_EL1 are used for save and restore of DBGDTRRX_EL0. |
26 | return false; | 29 | - * It is a component of the Debug Communications Channel, which is not implemented. |
27 | } | 30 | + * These registers belong to the Debug Communications Channel, |
28 | 31 | + * which is not implemented. However we implement RAZ/WI behaviour | |
29 | + /* | 32 | + * with trapping to prevent spurious SIGILLs if the guest OS does |
30 | + * Single-step exceptions have priority over breakpoint exceptions. | 33 | + * access them as the support cannot be probed for. |
31 | + * If single-step state is active-pending, suppress the bp. | 34 | */ |
32 | + */ | 35 | { .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, |
33 | + if (arm_singlestep_active(env) && !(env->pstate & PSTATE_SS)) { | 36 | .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2, |
34 | + return false; | 37 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
35 | + } | 38 | .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2, |
36 | + | 39 | .access = PL1_RW, .accessfn = access_tdcc, |
37 | + /* | 40 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
38 | + * PC alignment faults have priority over breakpoint exceptions. | 41 | + /* DBGDTRTX_EL0/DBGDTRRX_EL0 depend on direction */ |
39 | + */ | 42 | + { .name = "DBGDTR_EL0", .state = ARM_CP_STATE_BOTH, .cp = 14, |
40 | + pc = is_a64(env) ? env->pc : env->regs[15]; | 43 | + .opc0 = 2, .opc1 = 3, .crn = 0, .crm = 5, .opc2 = 0, |
41 | + if ((is_a64(env) || !env->thumb) && (pc & 3) != 0) { | 44 | + .access = PL0_RW, .accessfn = access_tdcc, |
42 | + return false; | 45 | + .type = ARM_CP_CONST, .resetvalue = 0 }, |
43 | + } | 46 | /* |
44 | + | 47 | * OSECCR_EL1 provides a mechanism for an operating system |
45 | + /* | 48 | * to access the contents of EDECCR. EDECCR is not implemented though, |
46 | + * Instruction aborts have priority over breakpoint exceptions. | ||
47 | + * TODO: We would need to look up the page for PC and verify that | ||
48 | + * it is present and executable. | ||
49 | + */ | ||
50 | + | ||
51 | for (n = 0; n < ARRAY_SIZE(env->cpu_breakpoint); n++) { | ||
52 | if (bp_wp_matches(cpu, n, false)) { | ||
53 | return true; | ||
54 | -- | 49 | -- |
55 | 2.25.1 | 50 | 2.34.1 |
56 | 51 | ||
57 | 52 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | To propagate errors to the caller of the pre_plug callback, use the | 3 | Bochs card is normal PCI Express card so it fits better in system with |
4 | object_poperty_set*() functions directly instead of the qdev_prop_set*() | 4 | PCI Express bus. VGA is simple legacy PCI card. |
5 | helpers. | ||
6 | 5 | ||
7 | Suggested-by: Igor Mammedov <imammedo@redhat.com> | 6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 7 | Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> |
9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | 8 | Message-id: 20230505120936.1097060-1-marcin.juszkiewicz@linaro.org |
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20211210170415.583179-5-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 | hw/arm/virt.c | 5 +++-- | 11 | hw/arm/sbsa-ref.c | 2 +- |
15 | 1 file changed, 3 insertions(+), 2 deletions(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
16 | 13 | ||
17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 14 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/virt.c | 16 | --- a/hw/arm/sbsa-ref.c |
20 | +++ b/hw/arm/virt.c | 17 | +++ b/hw/arm/sbsa-ref.c |
21 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, | 18 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms) |
22 | db_start, db_end, | 19 | } |
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); | ||
31 | } | 20 | } |
21 | |||
22 | - pci_create_simple(pci->bus, -1, "VGA"); | ||
23 | + pci_create_simple(pci->bus, -1, "bochs-display"); | ||
24 | |||
25 | create_smmu(sms, pci->bus); | ||
32 | } | 26 | } |
33 | -- | 27 | -- |
34 | 2.25.1 | 28 | 2.34.1 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Split out all of the decode stuff from aarch64_tr_translate_insn. | ||
4 | Call it disas_a64_legacy to indicate it will be replaced. | ||
5 | |||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20230512144106.3608981-2-peter.maydell@linaro.org | ||
10 | [PMM: Rebased] | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | --- | 13 | --- |
7 | target/arm/translate-a64.c | 7 ++++--- | 14 | target/arm/tcg/translate-a64.c | 82 ++++++++++++++++++---------------- |
8 | 1 file changed, 4 insertions(+), 3 deletions(-) | 15 | 1 file changed, 44 insertions(+), 38 deletions(-) |
9 | 16 | ||
10 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 17 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
11 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/translate-a64.c | 19 | --- a/target/arm/tcg/translate-a64.c |
13 | +++ b/target/arm/translate-a64.c | 20 | +++ b/target/arm/tcg/translate-a64.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) | ||
22 | return false; | ||
23 | } | ||
24 | |||
25 | +/* C3.1 A64 instruction index by encoding */ | ||
26 | +static void disas_a64_legacy(DisasContext *s, uint32_t insn) | ||
27 | +{ | ||
28 | + switch (extract32(insn, 25, 4)) { | ||
29 | + case 0x0: | ||
30 | + if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { | ||
31 | + unallocated_encoding(s); | ||
32 | + } | ||
33 | + break; | ||
34 | + case 0x1: case 0x3: /* UNALLOCATED */ | ||
35 | + unallocated_encoding(s); | ||
36 | + break; | ||
37 | + case 0x2: | ||
38 | + if (!disas_sve(s, insn)) { | ||
39 | + unallocated_encoding(s); | ||
40 | + } | ||
41 | + break; | ||
42 | + case 0x8: case 0x9: /* Data processing - immediate */ | ||
43 | + disas_data_proc_imm(s, insn); | ||
44 | + break; | ||
45 | + case 0xa: case 0xb: /* Branch, exception generation and system insns */ | ||
46 | + disas_b_exc_sys(s, insn); | ||
47 | + break; | ||
48 | + case 0x4: | ||
49 | + case 0x6: | ||
50 | + case 0xc: | ||
51 | + case 0xe: /* Loads and stores */ | ||
52 | + disas_ldst(s, insn); | ||
53 | + break; | ||
54 | + case 0x5: | ||
55 | + case 0xd: /* Data processing - register */ | ||
56 | + disas_data_proc_reg(s, insn); | ||
57 | + break; | ||
58 | + case 0x7: | ||
59 | + case 0xf: /* Data processing - SIMD and floating point */ | ||
60 | + disas_data_proc_simd_fp(s, insn); | ||
61 | + break; | ||
62 | + default: | ||
63 | + assert(FALSE); /* all 15 cases should be handled above */ | ||
64 | + break; | ||
65 | + } | ||
66 | +} | ||
67 | + | ||
68 | static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
69 | CPUState *cpu) | ||
70 | { | ||
14 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 71 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
15 | { | 72 | disas_sme_fa64(s, insn); |
16 | DisasContext *s = container_of(dcbase, DisasContext, base); | ||
17 | CPUARMState *env = cpu->env_ptr; | ||
18 | + uint64_t pc = s->base.pc_next; | ||
19 | uint32_t insn; | ||
20 | |||
21 | if (s->ss_active && !s->pstate_ss) { | ||
22 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
23 | return; | ||
24 | } | 73 | } |
25 | 74 | ||
26 | - s->pc_curr = s->base.pc_next; | 75 | - switch (extract32(insn, 25, 4)) { |
27 | - insn = arm_ldl_code(env, &s->base, s->base.pc_next, s->sctlr_b); | 76 | - case 0x0: |
28 | + s->pc_curr = pc; | 77 | - if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { |
29 | + insn = arm_ldl_code(env, &s->base, pc, s->sctlr_b); | 78 | - unallocated_encoding(s); |
30 | s->insn = insn; | 79 | - } |
31 | - s->base.pc_next += 4; | 80 | - break; |
32 | + s->base.pc_next = pc + 4; | 81 | - case 0x1: case 0x3: /* UNALLOCATED */ |
33 | 82 | - unallocated_encoding(s); | |
34 | s->fp_access_checked = false; | 83 | - break; |
35 | s->sve_access_checked = false; | 84 | - case 0x2: |
85 | - if (!disas_sve(s, insn)) { | ||
86 | - unallocated_encoding(s); | ||
87 | - } | ||
88 | - break; | ||
89 | - case 0x8: case 0x9: /* Data processing - immediate */ | ||
90 | - disas_data_proc_imm(s, insn); | ||
91 | - break; | ||
92 | - case 0xa: case 0xb: /* Branch, exception generation and system insns */ | ||
93 | - disas_b_exc_sys(s, insn); | ||
94 | - break; | ||
95 | - case 0x4: | ||
96 | - case 0x6: | ||
97 | - case 0xc: | ||
98 | - case 0xe: /* Loads and stores */ | ||
99 | - disas_ldst(s, insn); | ||
100 | - break; | ||
101 | - case 0x5: | ||
102 | - case 0xd: /* Data processing - register */ | ||
103 | - disas_data_proc_reg(s, insn); | ||
104 | - break; | ||
105 | - case 0x7: | ||
106 | - case 0xf: /* Data processing - SIMD and floating point */ | ||
107 | - disas_data_proc_simd_fp(s, insn); | ||
108 | - break; | ||
109 | - default: | ||
110 | - assert(FALSE); /* all 15 cases should be handled above */ | ||
111 | - break; | ||
112 | - } | ||
113 | + disas_a64_legacy(s, insn); | ||
114 | |||
115 | /* | ||
116 | * After execution of most insns, btype is reset to 0. | ||
36 | -- | 117 | -- |
37 | 2.25.1 | 118 | 2.34.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | The A64 translator uses a hand-written decoder for everything except |
---|---|---|---|
2 | SVE or SME. It's fairly well structured, but it's becoming obvious | ||
3 | that it's still more painful to add instructions to than the A32 | ||
4 | translator, because putting a new instruction into the right place in | ||
5 | a hand-written decoder is much harder than adding new instruction | ||
6 | patterns to a decodetree file. | ||
2 | 7 | ||
3 | gicv3_set_gicv3state() is used by arm_gicv3_common.c in | 8 | As the first step in conversion to decodetree, create the skeleton of |
4 | arm_gicv3_common_realize(). Since we want to restrict | 9 | the decodetree decoder; where it does not handle instructions we will |
5 | arm_gicv3_cpuif.c to TCG, extract gicv3_set_gicv3state() | 10 | fall back to the legacy decoder (which will be for everything at the |
6 | to a new file. Add this file to the meson 'specific' | 11 | moment, since there are no patterns in a64.decode). |
7 | source set, since it needs access to "cpu.h". | ||
8 | 12 | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20211115223619.2599282-2-philmd@redhat.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20230512144106.3608981-3-peter.maydell@linaro.org | ||
13 | --- | 16 | --- |
14 | hw/intc/arm_gicv3_cpuif.c | 10 +--------- | 17 | target/arm/tcg/a64.decode | 20 ++++++++++++++++++++ |
15 | hw/intc/arm_gicv3_cpuif_common.c | 22 ++++++++++++++++++++++ | 18 | target/arm/tcg/translate-a64.c | 18 +++++++++++------- |
16 | hw/intc/meson.build | 1 + | 19 | target/arm/tcg/meson.build | 1 + |
17 | 3 files changed, 24 insertions(+), 9 deletions(-) | 20 | 3 files changed, 32 insertions(+), 7 deletions(-) |
18 | create mode 100644 hw/intc/arm_gicv3_cpuif_common.c | 21 | create mode 100644 target/arm/tcg/a64.decode |
19 | 22 | ||
20 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 23 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
23 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | /* | ||
26 | - * ARM Generic Interrupt Controller v3 | ||
27 | + * ARM Generic Interrupt Controller v3 (emulation) | ||
28 | * | ||
29 | * Copyright (c) 2016 Linaro Limited | ||
30 | * Written by Peter Maydell | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | #include "hw/irq.h" | ||
33 | #include "cpu.h" | ||
34 | |||
35 | -void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) | ||
36 | -{ | ||
37 | - ARMCPU *arm_cpu = ARM_CPU(cpu); | ||
38 | - CPUARMState *env = &arm_cpu->env; | ||
39 | - | ||
40 | - env->gicv3state = (void *)s; | ||
41 | -}; | ||
42 | - | ||
43 | static GICv3CPUState *icc_cs_from_env(CPUARMState *env) | ||
44 | { | ||
45 | return env->gicv3state; | ||
46 | diff --git a/hw/intc/arm_gicv3_cpuif_common.c b/hw/intc/arm_gicv3_cpuif_common.c | ||
47 | new file mode 100644 | 24 | new file mode 100644 |
48 | index XXXXXXX..XXXXXXX | 25 | index XXXXXXX..XXXXXXX |
49 | --- /dev/null | 26 | --- /dev/null |
50 | +++ b/hw/intc/arm_gicv3_cpuif_common.c | 27 | +++ b/target/arm/tcg/a64.decode |
51 | @@ -XXX,XX +XXX,XX @@ | 28 | @@ -XXX,XX +XXX,XX @@ |
52 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | 29 | +# AArch64 A64 allowed instruction decoding |
30 | +# | ||
31 | +# Copyright (c) 2023 Linaro, Ltd | ||
32 | +# | ||
33 | +# This library is free software; you can redistribute it and/or | ||
34 | +# modify it under the terms of the GNU Lesser General Public | ||
35 | +# License as published by the Free Software Foundation; either | ||
36 | +# version 2.1 of the License, or (at your option) any later version. | ||
37 | +# | ||
38 | +# This library is distributed in the hope that it will be useful, | ||
39 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
40 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
41 | +# Lesser General Public License for more details. | ||
42 | +# | ||
43 | +# You should have received a copy of the GNU Lesser General Public | ||
44 | +# License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
45 | + | ||
46 | +# | ||
47 | +# This file is processed by scripts/decodetree.py | ||
48 | +# | ||
49 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/tcg/translate-a64.c | ||
52 | +++ b/target/arm/tcg/translate-a64.c | ||
53 | @@ -XXX,XX +XXX,XX @@ enum a64_shift_type { | ||
54 | A64_SHIFT_TYPE_ROR = 3 | ||
55 | }; | ||
56 | |||
53 | +/* | 57 | +/* |
54 | + * ARM Generic Interrupt Controller v3 | 58 | + * Include the generated decoders. |
55 | + * | ||
56 | + * Copyright (c) 2016 Linaro Limited | ||
57 | + * Written by Peter Maydell | ||
58 | + * | ||
59 | + * This code is licensed under the GPL, version 2 or (at your option) | ||
60 | + * any later version. | ||
61 | + */ | 59 | + */ |
62 | + | 60 | + |
63 | +#include "qemu/osdep.h" | 61 | +#include "decode-sme-fa64.c.inc" |
64 | +#include "gicv3_internal.h" | 62 | +#include "decode-a64.c.inc" |
65 | +#include "cpu.h" | ||
66 | + | 63 | + |
67 | +void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) | 64 | /* Table based decoder typedefs - used when the relevant bits for decode |
68 | +{ | 65 | * are too awkwardly scattered across the instruction (eg SIMD). |
69 | + ARMCPU *arm_cpu = ARM_CPU(cpu); | 66 | */ |
70 | + CPUARMState *env = &arm_cpu->env; | 67 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_simd_fp(DisasContext *s, uint32_t insn) |
68 | } | ||
69 | } | ||
70 | |||
71 | -/* | ||
72 | - * Include the generated SME FA64 decoder. | ||
73 | - */ | ||
74 | - | ||
75 | -#include "decode-sme-fa64.c.inc" | ||
76 | - | ||
77 | static bool trans_OK(DisasContext *s, arg_OK *a) | ||
78 | { | ||
79 | return true; | ||
80 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
81 | disas_sme_fa64(s, insn); | ||
82 | } | ||
83 | |||
84 | - disas_a64_legacy(s, insn); | ||
71 | + | 85 | + |
72 | + env->gicv3state = (void *)s; | 86 | + if (!disas_a64(s, insn)) { |
73 | +}; | 87 | + disas_a64_legacy(s, insn); |
74 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build | 88 | + } |
89 | |||
90 | /* | ||
91 | * After execution of most insns, btype is reset to 0. | ||
92 | diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build | ||
75 | index XXXXXXX..XXXXXXX 100644 | 93 | index XXXXXXX..XXXXXXX 100644 |
76 | --- a/hw/intc/meson.build | 94 | --- a/target/arm/tcg/meson.build |
77 | +++ b/hw/intc/meson.build | 95 | +++ b/target/arm/tcg/meson.build |
78 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-pmu-iomod-in | 96 | @@ -XXX,XX +XXX,XX @@ gen = [ |
79 | 97 | decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'), | |
80 | specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) | 98 | decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'), |
81 | specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) | 99 | decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']), |
82 | +specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) | 100 | + decodetree.process('a64.decode', extra_args: ['--static-decode=disas_a64']), |
83 | specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif.c')) | 101 | ] |
84 | specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c')) | 102 | |
85 | specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: files('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) | 103 | arm_ss.add(gen) |
86 | -- | 104 | -- |
87 | 2.25.1 | 105 | 2.34.1 |
88 | |||
89 | diff view generated by jsdifflib |
1 | The calculation of the length of TLB range invalidate operations | 1 | The SVE and SME decode is already done by decodetree. Pull the calls |
---|---|---|---|
2 | in tlbi_aa64_range_get_length() is incorrect in two ways: | 2 | to these decoders out of the legacy decoder. This doesn't change |
3 | * the NUM field is 5 bits, but we read only 4 bits | 3 | behaviour because all the patterns in sve.decode and sme.decode |
4 | * we miscalculate the page_shift value, because of an | 4 | already require the bits that the legacy decoder is decoding to have |
5 | off-by-one error: | 5 | the correct values. |
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 | ||
11 | 6 | ||
12 | Thanks to the bug report submitter Cha HyunSoo for identifying | ||
13 | both these errors. | ||
14 | |||
15 | Fixes: 84940ed82552d3c ("target/arm: Add support for FEAT_TLBIRANGE") | ||
16 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/734 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Message-id: 20230512144106.3608981-4-peter.maydell@linaro.org |
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Message-id: 20211130173257.1274194-1-peter.maydell@linaro.org | ||
22 | --- | 10 | --- |
23 | target/arm/helper.c | 6 +++--- | 11 | target/arm/tcg/translate-a64.c | 20 ++++---------------- |
24 | 1 file changed, 3 insertions(+), 3 deletions(-) | 12 | 1 file changed, 4 insertions(+), 16 deletions(-) |
25 | 13 | ||
26 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
27 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/helper.c | 16 | --- a/target/arm/tcg/translate-a64.c |
29 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/tcg/translate-a64.c |
30 | @@ -XXX,XX +XXX,XX @@ static uint64_t tlbi_aa64_range_get_length(CPUARMState *env, | 18 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) |
31 | uint64_t exponent; | 19 | static void disas_a64_legacy(DisasContext *s, uint32_t insn) |
32 | uint64_t length; | 20 | { |
33 | 21 | switch (extract32(insn, 25, 4)) { | |
34 | - num = extract64(value, 39, 4); | 22 | - case 0x0: |
35 | + num = extract64(value, 39, 5); | 23 | - if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { |
36 | scale = extract64(value, 44, 2); | 24 | - unallocated_encoding(s); |
37 | page_size_granule = extract64(value, 46, 2); | 25 | - } |
38 | 26 | - break; | |
39 | - page_shift = page_size_granule * 2 + 12; | 27 | - case 0x1: case 0x3: /* UNALLOCATED */ |
28 | - unallocated_encoding(s); | ||
29 | - break; | ||
30 | - case 0x2: | ||
31 | - if (!disas_sve(s, insn)) { | ||
32 | - unallocated_encoding(s); | ||
33 | - } | ||
34 | - break; | ||
35 | case 0x8: case 0x9: /* Data processing - immediate */ | ||
36 | disas_data_proc_imm(s, insn); | ||
37 | break; | ||
38 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_legacy(DisasContext *s, uint32_t insn) | ||
39 | disas_data_proc_simd_fp(s, insn); | ||
40 | break; | ||
41 | default: | ||
42 | - assert(FALSE); /* all 15 cases should be handled above */ | ||
43 | + unallocated_encoding(s); | ||
44 | break; | ||
45 | } | ||
46 | } | ||
47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
48 | disas_sme_fa64(s, insn); | ||
49 | } | ||
50 | |||
40 | - | 51 | - |
41 | if (page_size_granule == 0) { | 52 | - if (!disas_a64(s, insn)) { |
42 | qemu_log_mask(LOG_GUEST_ERROR, "Invalid page size granule %d\n", | 53 | + if (!disas_a64(s, insn) && |
43 | page_size_granule); | 54 | + !disas_sme(s, insn) && |
44 | return 0; | 55 | + !disas_sve(s, insn)) { |
56 | disas_a64_legacy(s, insn); | ||
45 | } | 57 | } |
46 | 58 | ||
47 | + page_shift = (page_size_granule - 1) * 2 + 12; | ||
48 | + | ||
49 | exponent = (5 * scale) + 1; | ||
50 | length = (num + 1) << (exponent + page_shift); | ||
51 | |||
52 | -- | 59 | -- |
53 | 2.25.1 | 60 | 2.34.1 |
54 | |||
55 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Create arm_check_ss_active and arm_check_kernelpage. | 3 | Convert the ADR and ADRP instructions. |
4 | |||
5 | Reverse the order of the tests. While it doesn't matter in practice, | ||
6 | because only user-only has a kernel page and user-only never sets | ||
7 | ss_active, ss_active has priority over execution exceptions and it | ||
8 | is best to keep them in the proper order. | ||
9 | 4 | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-5-peter.maydell@linaro.org | ||
9 | [PMM: Rebased] | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 12 | --- |
14 | target/arm/translate.c | 10 +++++++--- | 13 | target/arm/tcg/a64.decode | 13 ++++++++++++ |
15 | 1 file changed, 7 insertions(+), 3 deletions(-) | 14 | target/arm/tcg/translate-a64.c | 38 +++++++++++++--------------------- |
15 | 2 files changed, 27 insertions(+), 24 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 19 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/target/arm/translate.c | 20 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | 21 | @@ -XXX,XX +XXX,XX @@ |
22 | dc->insn_start = tcg_last_op(); | 22 | # |
23 | # This file is processed by scripts/decodetree.py | ||
24 | # | ||
25 | + | ||
26 | +&ri rd imm | ||
27 | + | ||
28 | + | ||
29 | +### Data Processing - Immediate | ||
30 | + | ||
31 | +# PC-rel addressing | ||
32 | + | ||
33 | +%imm_pcrel 5:s19 29:2 | ||
34 | +@pcrel . .. ..... ................... rd:5 &ri imm=%imm_pcrel | ||
35 | + | ||
36 | +ADR 0 .. 10000 ................... ..... @pcrel | ||
37 | +ADRP 1 .. 10000 ................... ..... @pcrel | ||
38 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/tcg/translate-a64.c | ||
41 | +++ b/target/arm/tcg/translate-a64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst(DisasContext *s, uint32_t insn) | ||
43 | } | ||
23 | } | 44 | } |
24 | 45 | ||
25 | -static bool arm_pre_translate_insn(DisasContext *dc) | 46 | -/* PC-rel. addressing |
26 | +static bool arm_check_kernelpage(DisasContext *dc) | 47 | - * 31 30 29 28 24 23 5 4 0 |
48 | - * +----+-------+-----------+-------------------+------+ | ||
49 | - * | op | immlo | 1 0 0 0 0 | immhi | Rd | | ||
50 | - * +----+-------+-----------+-------------------+------+ | ||
51 | +/* | ||
52 | + * PC-rel. addressing | ||
53 | */ | ||
54 | -static void disas_pc_rel_adr(DisasContext *s, uint32_t insn) | ||
55 | + | ||
56 | +static bool trans_ADR(DisasContext *s, arg_ri *a) | ||
27 | { | 57 | { |
28 | #ifdef CONFIG_USER_ONLY | 58 | - unsigned int page, rd; |
29 | /* Intercept jump to the magic kernel page. */ | 59 | - int64_t offset; |
30 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) | 60 | + gen_pc_plus_diff(s, cpu_reg(s, a->rd), a->imm); |
31 | return true; | 61 | + return true; |
32 | } | ||
33 | #endif | ||
34 | + return false; | ||
35 | +} | 62 | +} |
36 | 63 | ||
37 | +static bool arm_check_ss_active(DisasContext *dc) | 64 | - page = extract32(insn, 31, 1); |
65 | - /* SignExtend(immhi:immlo) -> offset */ | ||
66 | - offset = sextract64(insn, 5, 19); | ||
67 | - offset = offset << 2 | extract32(insn, 29, 2); | ||
68 | - rd = extract32(insn, 0, 5); | ||
69 | +static bool trans_ADRP(DisasContext *s, arg_ri *a) | ||
38 | +{ | 70 | +{ |
39 | if (dc->ss_active && !dc->pstate_ss) { | 71 | + int64_t offset = (int64_t)a->imm << 12; |
40 | /* Singlestep state is Active-pending. | 72 | |
41 | * If we're in this state at the start of a TB then either | 73 | - if (page) { |
42 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 74 | - /* ADRP (page based) */ |
43 | uint32_t pc = dc->base.pc_next; | 75 | - offset <<= 12; |
44 | unsigned int insn; | 76 | - /* The page offset is ok for CF_PCREL. */ |
45 | 77 | - offset -= s->pc_curr & 0xfff; | |
46 | - if (arm_pre_translate_insn(dc)) { | 78 | - } |
47 | + if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | 79 | - |
48 | dc->base.pc_next = pc + 4; | 80 | - gen_pc_plus_diff(s, cpu_reg(s, rd), offset); |
49 | return; | 81 | + /* The page offset is ok for CF_PCREL. */ |
50 | } | 82 | + offset -= s->pc_curr & 0xfff; |
51 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 83 | + gen_pc_plus_diff(s, cpu_reg(s, a->rd), offset); |
52 | uint32_t insn; | 84 | + return true; |
53 | bool is_16bit; | 85 | } |
54 | 86 | ||
55 | - if (arm_pre_translate_insn(dc)) { | 87 | /* |
56 | + if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | 88 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) |
57 | dc->base.pc_next = pc + 2; | 89 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) |
58 | return; | 90 | { |
59 | } | 91 | switch (extract32(insn, 23, 6)) { |
92 | - case 0x20: case 0x21: /* PC-rel. addressing */ | ||
93 | - disas_pc_rel_adr(s, insn); | ||
94 | - break; | ||
95 | case 0x22: /* Add/subtract (immediate) */ | ||
96 | disas_add_sub_imm(s, insn); | ||
97 | break; | ||
60 | -- | 98 | -- |
61 | 2.25.1 | 99 | 2.34.1 |
62 | |||
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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Split out specific 32-bit and 64-bit functions. |
4 | These carry the same signature as tcg_gen_add_i64, | ||
5 | and so will be easier to pass as callbacks. | ||
6 | |||
7 | Retain gen_add_CC and gen_sub_CC during conversion. | ||
8 | |||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 20230512144106.3608981-6-peter.maydell@linaro.org | ||
13 | [PMM: rebased] | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | --- | 16 | --- |
7 | tests/tcg/aarch64/pcalign-a64.c | 37 +++++++++++++++++++++++++ | 17 | target/arm/tcg/translate-a64.c | 149 +++++++++++++++++++-------------- |
8 | tests/tcg/arm/pcalign-a32.c | 46 +++++++++++++++++++++++++++++++ | 18 | 1 file changed, 84 insertions(+), 65 deletions(-) |
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 | ||
14 | 19 | ||
15 | diff --git a/tests/tcg/aarch64/pcalign-a64.c b/tests/tcg/aarch64/pcalign-a64.c | 20 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
16 | new file mode 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | index XXXXXXX..XXXXXXX | 22 | --- a/target/arm/tcg/translate-a64.c |
18 | --- /dev/null | 23 | +++ b/target/arm/tcg/translate-a64.c |
19 | +++ b/tests/tcg/aarch64/pcalign-a64.c | 24 | @@ -XXX,XX +XXX,XX @@ static inline void gen_logic_CC(int sf, TCGv_i64 result) |
20 | @@ -XXX,XX +XXX,XX @@ | 25 | } |
21 | +/* Test PC misalignment exception */ | 26 | |
27 | /* dest = T0 + T1; compute C, N, V and Z flags */ | ||
28 | +static void gen_add64_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | ||
29 | +{ | ||
30 | + TCGv_i64 result, flag, tmp; | ||
31 | + result = tcg_temp_new_i64(); | ||
32 | + flag = tcg_temp_new_i64(); | ||
33 | + tmp = tcg_temp_new_i64(); | ||
22 | + | 34 | + |
23 | +#include <assert.h> | 35 | + tcg_gen_movi_i64(tmp, 0); |
24 | +#include <signal.h> | 36 | + tcg_gen_add2_i64(result, flag, t0, tmp, t1, tmp); |
25 | +#include <stdlib.h> | ||
26 | +#include <stdio.h> | ||
27 | + | 37 | + |
28 | +static void *expected; | 38 | + tcg_gen_extrl_i64_i32(cpu_CF, flag); |
29 | + | 39 | + |
30 | +static void sigbus(int sig, siginfo_t *info, void *vuc) | 40 | + gen_set_NZ64(result); |
31 | +{ | 41 | + |
32 | + assert(info->si_code == BUS_ADRALN); | 42 | + tcg_gen_xor_i64(flag, result, t0); |
33 | + assert(info->si_addr == expected); | 43 | + tcg_gen_xor_i64(tmp, t0, t1); |
34 | + exit(EXIT_SUCCESS); | 44 | + tcg_gen_andc_i64(flag, flag, tmp); |
45 | + tcg_gen_extrh_i64_i32(cpu_VF, flag); | ||
46 | + | ||
47 | + tcg_gen_mov_i64(dest, result); | ||
35 | +} | 48 | +} |
36 | + | 49 | + |
37 | +int main() | 50 | +static void gen_add32_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) |
38 | +{ | 51 | +{ |
39 | + void *tmp; | 52 | + TCGv_i32 t0_32 = tcg_temp_new_i32(); |
53 | + TCGv_i32 t1_32 = tcg_temp_new_i32(); | ||
54 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
40 | + | 55 | + |
41 | + struct sigaction sa = { | 56 | + tcg_gen_movi_i32(tmp, 0); |
42 | + .sa_sigaction = sigbus, | 57 | + tcg_gen_extrl_i64_i32(t0_32, t0); |
43 | + .sa_flags = SA_SIGINFO | 58 | + tcg_gen_extrl_i64_i32(t1_32, t1); |
44 | + }; | 59 | + tcg_gen_add2_i32(cpu_NF, cpu_CF, t0_32, tmp, t1_32, tmp); |
45 | + | 60 | + tcg_gen_mov_i32(cpu_ZF, cpu_NF); |
46 | + if (sigaction(SIGBUS, &sa, NULL) < 0) { | 61 | + tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); |
47 | + perror("sigaction"); | 62 | + tcg_gen_xor_i32(tmp, t0_32, t1_32); |
48 | + return EXIT_FAILURE; | 63 | + tcg_gen_andc_i32(cpu_VF, cpu_VF, tmp); |
49 | + } | 64 | + tcg_gen_extu_i32_i64(dest, cpu_NF); |
50 | + | ||
51 | + asm volatile("adr %0, 1f + 1\n\t" | ||
52 | + "str %0, %1\n\t" | ||
53 | + "br %0\n" | ||
54 | + "1:" | ||
55 | + : "=&r"(tmp), "=m"(expected)); | ||
56 | + abort(); | ||
57 | +} | ||
58 | diff --git a/tests/tcg/arm/pcalign-a32.c b/tests/tcg/arm/pcalign-a32.c | ||
59 | new file mode 100644 | ||
60 | index XXXXXXX..XXXXXXX | ||
61 | --- /dev/null | ||
62 | +++ b/tests/tcg/arm/pcalign-a32.c | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | +/* Test PC misalignment exception */ | ||
65 | + | ||
66 | +#ifdef __thumb__ | ||
67 | +#error "This test must be compiled for ARM" | ||
68 | +#endif | ||
69 | + | ||
70 | +#include <assert.h> | ||
71 | +#include <signal.h> | ||
72 | +#include <stdlib.h> | ||
73 | +#include <stdio.h> | ||
74 | + | ||
75 | +static void *expected; | ||
76 | + | ||
77 | +static void sigbus(int sig, siginfo_t *info, void *vuc) | ||
78 | +{ | ||
79 | + assert(info->si_code == BUS_ADRALN); | ||
80 | + assert(info->si_addr == expected); | ||
81 | + exit(EXIT_SUCCESS); | ||
82 | +} | 65 | +} |
83 | + | 66 | + |
84 | +int main() | 67 | static void gen_add_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) |
68 | { | ||
69 | if (sf) { | ||
70 | - TCGv_i64 result, flag, tmp; | ||
71 | - result = tcg_temp_new_i64(); | ||
72 | - flag = tcg_temp_new_i64(); | ||
73 | - tmp = tcg_temp_new_i64(); | ||
74 | - | ||
75 | - tcg_gen_movi_i64(tmp, 0); | ||
76 | - tcg_gen_add2_i64(result, flag, t0, tmp, t1, tmp); | ||
77 | - | ||
78 | - tcg_gen_extrl_i64_i32(cpu_CF, flag); | ||
79 | - | ||
80 | - gen_set_NZ64(result); | ||
81 | - | ||
82 | - tcg_gen_xor_i64(flag, result, t0); | ||
83 | - tcg_gen_xor_i64(tmp, t0, t1); | ||
84 | - tcg_gen_andc_i64(flag, flag, tmp); | ||
85 | - tcg_gen_extrh_i64_i32(cpu_VF, flag); | ||
86 | - | ||
87 | - tcg_gen_mov_i64(dest, result); | ||
88 | + gen_add64_CC(dest, t0, t1); | ||
89 | } else { | ||
90 | - /* 32 bit arithmetic */ | ||
91 | - TCGv_i32 t0_32 = tcg_temp_new_i32(); | ||
92 | - TCGv_i32 t1_32 = tcg_temp_new_i32(); | ||
93 | - TCGv_i32 tmp = tcg_temp_new_i32(); | ||
94 | - | ||
95 | - tcg_gen_movi_i32(tmp, 0); | ||
96 | - tcg_gen_extrl_i64_i32(t0_32, t0); | ||
97 | - tcg_gen_extrl_i64_i32(t1_32, t1); | ||
98 | - tcg_gen_add2_i32(cpu_NF, cpu_CF, t0_32, tmp, t1_32, tmp); | ||
99 | - tcg_gen_mov_i32(cpu_ZF, cpu_NF); | ||
100 | - tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); | ||
101 | - tcg_gen_xor_i32(tmp, t0_32, t1_32); | ||
102 | - tcg_gen_andc_i32(cpu_VF, cpu_VF, tmp); | ||
103 | - tcg_gen_extu_i32_i64(dest, cpu_NF); | ||
104 | + gen_add32_CC(dest, t0, t1); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | /* dest = T0 - T1; compute C, N, V and Z flags */ | ||
109 | +static void gen_sub64_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | ||
85 | +{ | 110 | +{ |
86 | + void *tmp; | 111 | + /* 64 bit arithmetic */ |
112 | + TCGv_i64 result, flag, tmp; | ||
87 | + | 113 | + |
88 | + struct sigaction sa = { | 114 | + result = tcg_temp_new_i64(); |
89 | + .sa_sigaction = sigbus, | 115 | + flag = tcg_temp_new_i64(); |
90 | + .sa_flags = SA_SIGINFO | 116 | + tcg_gen_sub_i64(result, t0, t1); |
91 | + }; | ||
92 | + | 117 | + |
93 | + if (sigaction(SIGBUS, &sa, NULL) < 0) { | 118 | + gen_set_NZ64(result); |
94 | + perror("sigaction"); | ||
95 | + return EXIT_FAILURE; | ||
96 | + } | ||
97 | + | 119 | + |
98 | + asm volatile("adr %0, 1f + 2\n\t" | 120 | + tcg_gen_setcond_i64(TCG_COND_GEU, flag, t0, t1); |
99 | + "str %0, %1\n\t" | 121 | + tcg_gen_extrl_i64_i32(cpu_CF, flag); |
100 | + "bx %0\n" | ||
101 | + "1:" | ||
102 | + : "=&r"(tmp), "=m"(expected)); | ||
103 | + | 122 | + |
104 | + /* | 123 | + tcg_gen_xor_i64(flag, result, t0); |
105 | + * From v8, it is CONSTRAINED UNPREDICTABLE whether BXWritePC aligns | 124 | + tmp = tcg_temp_new_i64(); |
106 | + * the address or not. If so, we can legitimately fall through. | 125 | + tcg_gen_xor_i64(tmp, t0, t1); |
107 | + */ | 126 | + tcg_gen_and_i64(flag, flag, tmp); |
108 | + return EXIT_SUCCESS; | 127 | + tcg_gen_extrh_i64_i32(cpu_VF, flag); |
128 | + tcg_gen_mov_i64(dest, result); | ||
109 | +} | 129 | +} |
110 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/tests/tcg/aarch64/Makefile.target | ||
113 | +++ b/tests/tcg/aarch64/Makefile.target | ||
114 | @@ -XXX,XX +XXX,XX @@ VPATH += $(ARM_SRC) | ||
115 | AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 | ||
116 | VPATH += $(AARCH64_SRC) | ||
117 | |||
118 | -# Float-convert Tests | ||
119 | -AARCH64_TESTS=fcvt | ||
120 | +# Base architecture tests | ||
121 | +AARCH64_TESTS=fcvt pcalign-a64 | ||
122 | |||
123 | fcvt: LDFLAGS+=-lm | ||
124 | |||
125 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/tests/tcg/arm/Makefile.target | ||
128 | +++ b/tests/tcg/arm/Makefile.target | ||
129 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | ||
130 | $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") | ||
131 | $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) | ||
132 | |||
133 | +# PC alignment test | ||
134 | +ARM_TESTS += pcalign-a32 | ||
135 | +pcalign-a32: CFLAGS+=-marm | ||
136 | + | 130 | + |
137 | ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) | 131 | +static void gen_sub32_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) |
138 | 132 | +{ | |
139 | # Semihosting smoke test for linux-user | 133 | + /* 32 bit arithmetic */ |
134 | + TCGv_i32 t0_32 = tcg_temp_new_i32(); | ||
135 | + TCGv_i32 t1_32 = tcg_temp_new_i32(); | ||
136 | + TCGv_i32 tmp; | ||
137 | + | ||
138 | + tcg_gen_extrl_i64_i32(t0_32, t0); | ||
139 | + tcg_gen_extrl_i64_i32(t1_32, t1); | ||
140 | + tcg_gen_sub_i32(cpu_NF, t0_32, t1_32); | ||
141 | + tcg_gen_mov_i32(cpu_ZF, cpu_NF); | ||
142 | + tcg_gen_setcond_i32(TCG_COND_GEU, cpu_CF, t0_32, t1_32); | ||
143 | + tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); | ||
144 | + tmp = tcg_temp_new_i32(); | ||
145 | + tcg_gen_xor_i32(tmp, t0_32, t1_32); | ||
146 | + tcg_gen_and_i32(cpu_VF, cpu_VF, tmp); | ||
147 | + tcg_gen_extu_i32_i64(dest, cpu_NF); | ||
148 | +} | ||
149 | + | ||
150 | static void gen_sub_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | ||
151 | { | ||
152 | if (sf) { | ||
153 | - /* 64 bit arithmetic */ | ||
154 | - TCGv_i64 result, flag, tmp; | ||
155 | - | ||
156 | - result = tcg_temp_new_i64(); | ||
157 | - flag = tcg_temp_new_i64(); | ||
158 | - tcg_gen_sub_i64(result, t0, t1); | ||
159 | - | ||
160 | - gen_set_NZ64(result); | ||
161 | - | ||
162 | - tcg_gen_setcond_i64(TCG_COND_GEU, flag, t0, t1); | ||
163 | - tcg_gen_extrl_i64_i32(cpu_CF, flag); | ||
164 | - | ||
165 | - tcg_gen_xor_i64(flag, result, t0); | ||
166 | - tmp = tcg_temp_new_i64(); | ||
167 | - tcg_gen_xor_i64(tmp, t0, t1); | ||
168 | - tcg_gen_and_i64(flag, flag, tmp); | ||
169 | - tcg_gen_extrh_i64_i32(cpu_VF, flag); | ||
170 | - tcg_gen_mov_i64(dest, result); | ||
171 | + gen_sub64_CC(dest, t0, t1); | ||
172 | } else { | ||
173 | - /* 32 bit arithmetic */ | ||
174 | - TCGv_i32 t0_32 = tcg_temp_new_i32(); | ||
175 | - TCGv_i32 t1_32 = tcg_temp_new_i32(); | ||
176 | - TCGv_i32 tmp; | ||
177 | - | ||
178 | - tcg_gen_extrl_i64_i32(t0_32, t0); | ||
179 | - tcg_gen_extrl_i64_i32(t1_32, t1); | ||
180 | - tcg_gen_sub_i32(cpu_NF, t0_32, t1_32); | ||
181 | - tcg_gen_mov_i32(cpu_ZF, cpu_NF); | ||
182 | - tcg_gen_setcond_i32(TCG_COND_GEU, cpu_CF, t0_32, t1_32); | ||
183 | - tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); | ||
184 | - tmp = tcg_temp_new_i32(); | ||
185 | - tcg_gen_xor_i32(tmp, t0_32, t1_32); | ||
186 | - tcg_gen_and_i32(cpu_VF, cpu_VF, tmp); | ||
187 | - tcg_gen_extu_i32_i64(dest, cpu_NF); | ||
188 | + gen_sub32_CC(dest, t0, t1); | ||
189 | } | ||
190 | } | ||
191 | |||
140 | -- | 192 | -- |
141 | 2.25.1 | 193 | 2.34.1 |
142 | |||
143 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | For A64, any input to an indirect branch can cause this. | 3 | Convert the ADD and SUB (immediate) instructions. |
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. | ||
14 | 4 | ||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-7-peter.maydell@linaro.org | ||
9 | [PMM: Rebased; adjusted to use translate.h's TRANS macro] | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 12 | --- |
19 | target/arm/helper.h | 1 + | 13 | target/arm/tcg/translate.h | 5 +++ |
20 | target/arm/syndrome.h | 5 ++++ | 14 | target/arm/tcg/a64.decode | 17 ++++++++ |
21 | linux-user/aarch64/cpu_loop.c | 46 ++++++++++++++++++++--------------- | 15 | target/arm/tcg/translate-a64.c | 73 ++++++++++------------------------ |
22 | target/arm/tlb_helper.c | 18 ++++++++++++++ | 16 | 3 files changed, 42 insertions(+), 53 deletions(-) |
23 | target/arm/translate-a64.c | 15 ++++++++++++ | ||
24 | target/arm/translate.c | 22 ++++++++++++++++- | ||
25 | 6 files changed, 87 insertions(+), 20 deletions(-) | ||
26 | 17 | ||
27 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 18 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h |
28 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/helper.h | 20 | --- a/target/arm/tcg/translate.h |
30 | +++ b/target/arm/helper.h | 21 | +++ b/target/arm/tcg/translate.h |
31 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, | 22 | @@ -XXX,XX +XXX,XX @@ static inline int rsub_8(DisasContext *s, int x) |
32 | DEF_HELPER_2(exception_internal, void, env, i32) | 23 | return 8 - x; |
33 | DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32) | ||
34 | DEF_HELPER_2(exception_bkpt_insn, void, env, i32) | ||
35 | +DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl) | ||
36 | DEF_HELPER_1(setend, void, env) | ||
37 | DEF_HELPER_2(wfi, void, env, i32) | ||
38 | DEF_HELPER_1(wfe, void, env) | ||
39 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/syndrome.h | ||
42 | +++ b/target/arm/syndrome.h | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_illegalstate(void) | ||
44 | return (EC_ILLEGALSTATE << ARM_EL_EC_SHIFT) | ARM_EL_IL; | ||
45 | } | 24 | } |
46 | 25 | ||
47 | +static inline uint32_t syn_pcalignment(void) | 26 | +static inline int shl_12(DisasContext *s, int x) |
48 | +{ | 27 | +{ |
49 | + return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL; | 28 | + return x << 12; |
50 | +} | 29 | +} |
51 | + | 30 | + |
52 | #endif /* TARGET_ARM_SYNDROME_H */ | 31 | static inline int neon_3same_fp_size(DisasContext *s, int x) |
53 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c | 32 | { |
33 | /* Convert 0==fp32, 1==fp16 into a MO_* value */ | ||
34 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode | ||
54 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/linux-user/aarch64/cpu_loop.c | 36 | --- a/target/arm/tcg/a64.decode |
56 | +++ b/linux-user/aarch64/cpu_loop.c | 37 | +++ b/target/arm/tcg/a64.decode |
57 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | 38 | @@ -XXX,XX +XXX,XX @@ |
58 | break; | 39 | # |
59 | case EXCP_PREFETCH_ABORT: | 40 | |
60 | case EXCP_DATA_ABORT: | 41 | &ri rd imm |
61 | - /* We should only arrive here with EC in {DATAABORT, INSNABORT}. */ | 42 | +&rri_sf rd rn imm sf |
62 | ec = syn_get_ec(env->exception.syndrome); | 43 | |
63 | - assert(ec == EC_DATAABORT || ec == EC_INSNABORT); | 44 | |
64 | - | 45 | ### Data Processing - Immediate |
65 | - /* Both EC have the same format for FSC, or close enough. */ | 46 | @@ -XXX,XX +XXX,XX @@ |
66 | - fsc = extract32(env->exception.syndrome, 0, 6); | 47 | |
67 | - switch (fsc) { | 48 | ADR 0 .. 10000 ................... ..... @pcrel |
68 | - case 0x04 ... 0x07: /* Translation fault, level {0-3} */ | 49 | ADRP 1 .. 10000 ................... ..... @pcrel |
69 | - si_signo = TARGET_SIGSEGV; | 50 | + |
70 | - si_code = TARGET_SEGV_MAPERR; | 51 | +# Add/subtract (immediate) |
71 | + switch (ec) { | 52 | + |
72 | + case EC_DATAABORT: | 53 | +%imm12_sh12 10:12 !function=shl_12 |
73 | + case EC_INSNABORT: | 54 | +@addsub_imm sf:1 .. ...... . imm:12 rn:5 rd:5 |
74 | + /* Both EC have the same format for FSC, or close enough. */ | 55 | +@addsub_imm12 sf:1 .. ...... . ............ rn:5 rd:5 imm=%imm12_sh12 |
75 | + fsc = extract32(env->exception.syndrome, 0, 6); | 56 | + |
76 | + switch (fsc) { | 57 | +ADD_i . 00 100010 0 ............ ..... ..... @addsub_imm |
77 | + case 0x04 ... 0x07: /* Translation fault, level {0-3} */ | 58 | +ADD_i . 00 100010 1 ............ ..... ..... @addsub_imm12 |
78 | + si_signo = TARGET_SIGSEGV; | 59 | +ADDS_i . 01 100010 0 ............ ..... ..... @addsub_imm |
79 | + si_code = TARGET_SEGV_MAPERR; | 60 | +ADDS_i . 01 100010 1 ............ ..... ..... @addsub_imm12 |
80 | + break; | 61 | + |
81 | + case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ | 62 | +SUB_i . 10 100010 0 ............ ..... ..... @addsub_imm |
82 | + case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ | 63 | +SUB_i . 10 100010 1 ............ ..... ..... @addsub_imm12 |
83 | + si_signo = TARGET_SIGSEGV; | 64 | +SUBS_i . 11 100010 0 ............ ..... ..... @addsub_imm |
84 | + si_code = TARGET_SEGV_ACCERR; | 65 | +SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 |
85 | + break; | 66 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
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 | 67 | index XXXXXXX..XXXXXXX 100644 |
114 | --- a/target/arm/tlb_helper.c | 68 | --- a/target/arm/tcg/translate-a64.c |
115 | +++ b/target/arm/tlb_helper.c | 69 | +++ b/target/arm/tcg/translate-a64.c |
116 | @@ -XXX,XX +XXX,XX @@ | 70 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst(DisasContext *s, uint32_t insn) |
117 | #include "cpu.h" | 71 | } |
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 | } | 72 | } |
127 | 73 | ||
128 | +void helper_exception_pc_alignment(CPUARMState *env, target_ulong pc) | 74 | +typedef void ArithTwoOp(TCGv_i64, TCGv_i64, TCGv_i64); |
75 | + | ||
76 | +static bool gen_rri(DisasContext *s, arg_rri_sf *a, | ||
77 | + bool rd_sp, bool rn_sp, ArithTwoOp *fn) | ||
129 | +{ | 78 | +{ |
130 | + ARMMMUFaultInfo fi = { .type = ARMFault_Alignment }; | 79 | + TCGv_i64 tcg_rn = rn_sp ? cpu_reg_sp(s, a->rn) : cpu_reg(s, a->rn); |
131 | + int target_el = exception_target_el(env); | 80 | + TCGv_i64 tcg_rd = rd_sp ? cpu_reg_sp(s, a->rd) : cpu_reg(s, a->rd); |
132 | + int mmu_idx = cpu_mmu_index(env, true); | 81 | + TCGv_i64 tcg_imm = tcg_constant_i64(a->imm); |
133 | + uint32_t fsc; | ||
134 | + | 82 | + |
135 | + env->exception.vaddress = pc; | 83 | + fn(tcg_rd, tcg_rn, tcg_imm); |
136 | + | 84 | + if (!a->sf) { |
137 | + /* | 85 | + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); |
138 | + * Note that the fsc is not applicable to this exception, | 86 | + } |
139 | + * since any syndrome is pcalignment not insn_abort. | 87 | + return true; |
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 | +} | 88 | +} |
144 | + | 89 | + |
145 | #if !defined(CONFIG_USER_ONLY) | ||
146 | |||
147 | /* | 90 | /* |
148 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 91 | * PC-rel. addressing |
149 | index XXXXXXX..XXXXXXX 100644 | 92 | */ |
150 | --- a/target/arm/translate-a64.c | 93 | @@ -XXX,XX +XXX,XX @@ static bool trans_ADRP(DisasContext *s, arg_ri *a) |
151 | +++ b/target/arm/translate-a64.c | 94 | |
152 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 95 | /* |
153 | uint64_t pc = s->base.pc_next; | 96 | * Add/subtract (immediate) |
154 | uint32_t insn; | 97 | - * |
155 | 98 | - * 31 30 29 28 23 22 21 10 9 5 4 0 | |
156 | + /* Singlestep exceptions have the highest priority. */ | 99 | - * +--+--+--+-------------+--+-------------+-----+-----+ |
157 | if (s->ss_active && !s->pstate_ss) { | 100 | - * |sf|op| S| 1 0 0 0 1 0 |sh| imm12 | Rn | Rd | |
158 | /* Singlestep state is Active-pending. | 101 | - * +--+--+--+-------------+--+-------------+-----+-----+ |
159 | * If we're in this state at the start of a TB then either | 102 | - * |
160 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 103 | - * sf: 0 -> 32bit, 1 -> 64bit |
161 | return; | 104 | - * op: 0 -> add , 1 -> sub |
162 | } | 105 | - * S: 1 -> set flags |
163 | 106 | - * sh: 1 -> LSL imm by 12 | |
164 | + if (pc & 3) { | 107 | */ |
165 | + /* | 108 | -static void disas_add_sub_imm(DisasContext *s, uint32_t insn) |
166 | + * PC alignment fault. This has priority over the instruction abort | 109 | -{ |
167 | + * that we would receive from a translation fault via arm_ldl_code. | 110 | - int rd = extract32(insn, 0, 5); |
168 | + * This should only be possible after an indirect branch, at the | 111 | - int rn = extract32(insn, 5, 5); |
169 | + * start of the TB. | 112 | - uint64_t imm = extract32(insn, 10, 12); |
170 | + */ | 113 | - bool shift = extract32(insn, 22, 1); |
171 | + assert(s->base.num_insns == 1); | 114 | - bool setflags = extract32(insn, 29, 1); |
172 | + gen_helper_exception_pc_alignment(cpu_env, tcg_constant_tl(pc)); | 115 | - bool sub_op = extract32(insn, 30, 1); |
173 | + s->base.is_jmp = DISAS_NORETURN; | 116 | - bool is_64bit = extract32(insn, 31, 1); |
174 | + s->base.pc_next = QEMU_ALIGN_UP(pc, 4); | 117 | - |
175 | + return; | 118 | - TCGv_i64 tcg_rn = cpu_reg_sp(s, rn); |
176 | + } | 119 | - TCGv_i64 tcg_rd = setflags ? cpu_reg(s, rd) : cpu_reg_sp(s, rd); |
177 | + | 120 | - TCGv_i64 tcg_result; |
178 | s->pc_curr = pc; | 121 | - |
179 | insn = arm_ldl_code(env, &s->base, pc, s->sctlr_b); | 122 | - if (shift) { |
180 | s->insn = insn; | 123 | - imm <<= 12; |
181 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 124 | - } |
182 | index XXXXXXX..XXXXXXX 100644 | 125 | - |
183 | --- a/target/arm/translate.c | 126 | - tcg_result = tcg_temp_new_i64(); |
184 | +++ b/target/arm/translate.c | 127 | - if (!setflags) { |
185 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 128 | - if (sub_op) { |
186 | uint32_t pc = dc->base.pc_next; | 129 | - tcg_gen_subi_i64(tcg_result, tcg_rn, imm); |
187 | unsigned int insn; | 130 | - } else { |
188 | 131 | - tcg_gen_addi_i64(tcg_result, tcg_rn, imm); | |
189 | - if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | 132 | - } |
190 | + /* Singlestep exceptions have the highest priority. */ | 133 | - } else { |
191 | + if (arm_check_ss_active(dc)) { | 134 | - TCGv_i64 tcg_imm = tcg_constant_i64(imm); |
192 | + dc->base.pc_next = pc + 4; | 135 | - if (sub_op) { |
193 | + return; | 136 | - gen_sub_CC(is_64bit, tcg_result, tcg_rn, tcg_imm); |
194 | + } | 137 | - } else { |
195 | + | 138 | - gen_add_CC(is_64bit, tcg_result, tcg_rn, tcg_imm); |
196 | + if (pc & 3) { | 139 | - } |
197 | + /* | 140 | - } |
198 | + * PC alignment fault. This has priority over the instruction abort | 141 | - |
199 | + * that we would receive from a translation fault via arm_ldl_code | 142 | - if (is_64bit) { |
200 | + * (or the execution of the kernelpage entrypoint). This should only | 143 | - tcg_gen_mov_i64(tcg_rd, tcg_result); |
201 | + * be possible after an indirect branch, at the start of the TB. | 144 | - } else { |
202 | + */ | 145 | - tcg_gen_ext32u_i64(tcg_rd, tcg_result); |
203 | + assert(dc->base.num_insns == 1); | 146 | - } |
204 | + gen_helper_exception_pc_alignment(cpu_env, tcg_constant_tl(pc)); | 147 | -} |
205 | + dc->base.is_jmp = DISAS_NORETURN; | 148 | +TRANS(ADD_i, gen_rri, a, 1, 1, tcg_gen_add_i64) |
206 | + dc->base.pc_next = QEMU_ALIGN_UP(pc, 4); | 149 | +TRANS(SUB_i, gen_rri, a, 1, 1, tcg_gen_sub_i64) |
207 | + return; | 150 | +TRANS(ADDS_i, gen_rri, a, 0, 1, a->sf ? gen_add64_CC : gen_add32_CC) |
208 | + } | 151 | +TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_CC : gen_sub32_CC) |
209 | + | 152 | |
210 | + if (arm_check_kernelpage(dc)) { | 153 | /* |
211 | dc->base.pc_next = pc + 4; | 154 | * Add/subtract (immediate, with tags) |
212 | return; | 155 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) |
213 | } | 156 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) |
157 | { | ||
158 | switch (extract32(insn, 23, 6)) { | ||
159 | - case 0x22: /* Add/subtract (immediate) */ | ||
160 | - disas_add_sub_imm(s, insn); | ||
161 | - break; | ||
162 | case 0x23: /* Add/subtract (immediate, with tags) */ | ||
163 | disas_add_sub_imm_with_tags(s, insn); | ||
164 | break; | ||
214 | -- | 165 | -- |
215 | 2.25.1 | 166 | 2.34.1 |
216 | |||
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 size of the code covered by a TranslationBlock cannot be 0; | 3 | Convert the ADDG and SUBG (immediate) instructions. |
4 | this is checked via assert in tb_gen_code. | ||
5 | 4 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-8-peter.maydell@linaro.org | ||
9 | [PMM: Rebased; use TRANS_FEAT()] | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | target/arm/translate-a64.c | 1 + | 13 | target/arm/tcg/a64.decode | 8 +++++++ |
11 | 1 file changed, 1 insertion(+) | 14 | target/arm/tcg/translate-a64.c | 38 ++++++++++------------------------ |
15 | 2 files changed, 19 insertions(+), 27 deletions(-) | ||
12 | 16 | ||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 17 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a64.c | 19 | --- a/target/arm/tcg/a64.decode |
16 | +++ b/target/arm/translate-a64.c | 20 | +++ b/target/arm/tcg/a64.decode |
17 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 21 | @@ -XXX,XX +XXX,XX @@ SUB_i . 10 100010 0 ............ ..... ..... @addsub_imm |
18 | assert(s->base.num_insns == 1); | 22 | SUB_i . 10 100010 1 ............ ..... ..... @addsub_imm12 |
19 | gen_swstep_exception(s, 0, 0); | 23 | SUBS_i . 11 100010 0 ............ ..... ..... @addsub_imm |
20 | s->base.is_jmp = DISAS_NORETURN; | 24 | SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 |
21 | + s->base.pc_next = pc + 4; | 25 | + |
22 | return; | 26 | +# Add/subtract (immediate with tags) |
27 | + | ||
28 | +&rri_tag rd rn uimm6 uimm4 | ||
29 | +@addsub_imm_tag . .. ...... . uimm6:6 .. uimm4:4 rn:5 rd:5 &rri_tag | ||
30 | + | ||
31 | +ADDG_i 1 00 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag | ||
32 | +SUBG_i 1 10 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag | ||
33 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/tcg/translate-a64.c | ||
36 | +++ b/target/arm/tcg/translate-a64.c | ||
37 | @@ -XXX,XX +XXX,XX @@ TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_CC : gen_sub32_CC) | ||
38 | |||
39 | /* | ||
40 | * Add/subtract (immediate, with tags) | ||
41 | - * | ||
42 | - * 31 30 29 28 23 22 21 16 14 10 9 5 4 0 | ||
43 | - * +--+--+--+-------------+--+---------+--+-------+-----+-----+ | ||
44 | - * |sf|op| S| 1 0 0 0 1 1 |o2| uimm6 |o3| uimm4 | Rn | Rd | | ||
45 | - * +--+--+--+-------------+--+---------+--+-------+-----+-----+ | ||
46 | - * | ||
47 | - * op: 0 -> add, 1 -> sub | ||
48 | */ | ||
49 | -static void disas_add_sub_imm_with_tags(DisasContext *s, uint32_t insn) | ||
50 | + | ||
51 | +static bool gen_add_sub_imm_with_tags(DisasContext *s, arg_rri_tag *a, | ||
52 | + bool sub_op) | ||
53 | { | ||
54 | - int rd = extract32(insn, 0, 5); | ||
55 | - int rn = extract32(insn, 5, 5); | ||
56 | - int uimm4 = extract32(insn, 10, 4); | ||
57 | - int uimm6 = extract32(insn, 16, 6); | ||
58 | - bool sub_op = extract32(insn, 30, 1); | ||
59 | TCGv_i64 tcg_rn, tcg_rd; | ||
60 | int imm; | ||
61 | |||
62 | - /* Test all of sf=1, S=0, o2=0, o3=0. */ | ||
63 | - if ((insn & 0xa040c000u) != 0x80000000u || | ||
64 | - !dc_isar_feature(aa64_mte_insn_reg, s)) { | ||
65 | - unallocated_encoding(s); | ||
66 | - return; | ||
67 | - } | ||
68 | - | ||
69 | - imm = uimm6 << LOG2_TAG_GRANULE; | ||
70 | + imm = a->uimm6 << LOG2_TAG_GRANULE; | ||
71 | if (sub_op) { | ||
72 | imm = -imm; | ||
23 | } | 73 | } |
24 | 74 | ||
75 | - tcg_rn = cpu_reg_sp(s, rn); | ||
76 | - tcg_rd = cpu_reg_sp(s, rd); | ||
77 | + tcg_rn = cpu_reg_sp(s, a->rn); | ||
78 | + tcg_rd = cpu_reg_sp(s, a->rd); | ||
79 | |||
80 | if (s->ata) { | ||
81 | gen_helper_addsubg(tcg_rd, cpu_env, tcg_rn, | ||
82 | tcg_constant_i32(imm), | ||
83 | - tcg_constant_i32(uimm4)); | ||
84 | + tcg_constant_i32(a->uimm4)); | ||
85 | } else { | ||
86 | tcg_gen_addi_i64(tcg_rd, tcg_rn, imm); | ||
87 | gen_address_with_allocation_tag0(tcg_rd, tcg_rd); | ||
88 | } | ||
89 | + return true; | ||
90 | } | ||
91 | |||
92 | +TRANS_FEAT(ADDG_i, aa64_mte_insn_reg, gen_add_sub_imm_with_tags, a, false) | ||
93 | +TRANS_FEAT(SUBG_i, aa64_mte_insn_reg, gen_add_sub_imm_with_tags, a, true) | ||
94 | + | ||
95 | /* The input should be a value in the bottom e bits (with higher | ||
96 | * bits zero); returns that value replicated into every element | ||
97 | * of size e in a 64 bit integer. | ||
98 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) | ||
99 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) | ||
100 | { | ||
101 | switch (extract32(insn, 23, 6)) { | ||
102 | - case 0x23: /* Add/subtract (immediate, with tags) */ | ||
103 | - disas_add_sub_imm_with_tags(s, insn); | ||
104 | - break; | ||
105 | case 0x24: /* Logical (immediate) */ | ||
106 | disas_logic_imm(s, insn); | ||
107 | break; | ||
25 | -- | 108 | -- |
26 | 2.25.1 | 109 | 2.34.1 |
27 | |||
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 | We will reuse this section of arm_deliver_fault for | 3 | Use the bitops.h macro rather than rolling our own here. |
4 | raising pc alignment faults. | ||
5 | 4 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20230512144106.3608981-9-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | target/arm/tlb_helper.c | 45 +++++++++++++++++++++++++---------------- | 10 | target/arm/tcg/translate-a64.c | 11 ++--------- |
11 | 1 file changed, 28 insertions(+), 17 deletions(-) | 11 | 1 file changed, 2 insertions(+), 9 deletions(-) |
12 | 12 | ||
13 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | 13 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/tlb_helper.c | 15 | --- a/target/arm/tcg/translate-a64.c |
16 | +++ b/target/arm/tlb_helper.c | 16 | +++ b/target/arm/tcg/translate-a64.c |
17 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | 17 | @@ -XXX,XX +XXX,XX @@ static uint64_t bitfield_replicate(uint64_t mask, unsigned int e) |
18 | return syn; | 18 | return mask; |
19 | } | 19 | } |
20 | 20 | ||
21 | -static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | 21 | -/* Return a value with the bottom len bits set (where 0 < len <= 64) */ |
22 | - MMUAccessType access_type, | 22 | -static inline uint64_t bitmask64(unsigned int length) |
23 | - int mmu_idx, ARMMMUFaultInfo *fi) | 23 | -{ |
24 | +static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, | 24 | - assert(length > 0 && length <= 64); |
25 | + int target_el, int mmu_idx, uint32_t *ret_fsc) | 25 | - return ~0ULL >> (64 - length); |
26 | { | 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 | - | 27 | - |
33 | - target_el = exception_target_el(env); | 28 | /* Simplified variant of pseudocode DecodeBitMasks() for the case where we |
34 | - if (fi->stage2) { | 29 | * only require the wmask. Returns false if the imms/immr/immn are a reserved |
35 | - target_el = 2; | 30 | * value (ie should cause a guest UNDEF exception), and true if they are |
36 | - env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | 31 | @@ -XXX,XX +XXX,XX @@ bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn, |
37 | - if (arm_is_secure_below_el3(env) && fi->s1ns) { | 32 | /* Create the value of one element: s+1 set bits rotated |
38 | - env->cp15.hpfar_el2 |= HPFAR_NS; | 33 | * by r within the element (which is e bits wide)... |
39 | - } | 34 | */ |
40 | - } | 35 | - mask = bitmask64(s + 1); |
41 | - same_el = (arm_current_el(env) == target_el); | 36 | + mask = MAKE_64BIT_MASK(0, s + 1); |
42 | + uint32_t fsr, fsc; | 37 | if (r) { |
43 | 38 | mask = (mask >> r) | (mask << (e - r)); | |
44 | if (target_el == 2 || arm_el_is_aa64(env, target_el) || | 39 | - mask &= bitmask64(e); |
45 | arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | 40 | + mask &= MAKE_64BIT_MASK(0, e); |
46 | @@ -XXX,XX +XXX,XX @@ static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | ||
47 | fsc = 0x3f; | ||
48 | } | 41 | } |
49 | 42 | /* ...then replicate the element over the whole 64 bit value */ | |
50 | + *ret_fsc = fsc; | 43 | mask = bitfield_replicate(mask, e); |
51 | + return fsr; | ||
52 | +} | ||
53 | + | ||
54 | +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | ||
55 | + MMUAccessType access_type, | ||
56 | + int mmu_idx, ARMMMUFaultInfo *fi) | ||
57 | +{ | ||
58 | + CPUARMState *env = &cpu->env; | ||
59 | + int target_el; | ||
60 | + bool same_el; | ||
61 | + uint32_t syn, exc, fsr, fsc; | ||
62 | + | ||
63 | + target_el = exception_target_el(env); | ||
64 | + if (fi->stage2) { | ||
65 | + target_el = 2; | ||
66 | + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | ||
67 | + if (arm_is_secure_below_el3(env) && fi->s1ns) { | ||
68 | + env->cp15.hpfar_el2 |= HPFAR_NS; | ||
69 | + } | ||
70 | + } | ||
71 | + same_el = (arm_current_el(env) == target_el); | ||
72 | + | ||
73 | + fsr = compute_fsr_fsc(env, fi, target_el, mmu_idx, &fsc); | ||
74 | + | ||
75 | if (access_type == MMU_INST_FETCH) { | ||
76 | syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); | ||
77 | exc = EXCP_PREFETCH_ABORT; | ||
78 | -- | 44 | -- |
79 | 2.25.1 | 45 | 2.34.1 |
80 | |||
81 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | |||
3 | Convert the ADD, ORR, EOR, ANDS (immediate) instructions. | ||
2 | 4 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20230512144106.3608981-10-peter.maydell@linaro.org | ||
9 | [PMM: rebased] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | --- | 11 | --- |
7 | target/arm/translate.c | 9 +++++---- | 12 | target/arm/tcg/a64.decode | 15 ++++++ |
8 | 1 file changed, 5 insertions(+), 4 deletions(-) | 13 | target/arm/tcg/translate-a64.c | 94 +++++++++++----------------------- |
14 | 2 files changed, 44 insertions(+), 65 deletions(-) | ||
9 | 15 | ||
10 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
11 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/translate.c | 18 | --- a/target/arm/tcg/a64.decode |
13 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/tcg/a64.decode |
14 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 20 | @@ -XXX,XX +XXX,XX @@ SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 |
21 | |||
22 | ADDG_i 1 00 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag | ||
23 | SUBG_i 1 10 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag | ||
24 | + | ||
25 | +# Logical (immediate) | ||
26 | + | ||
27 | +&rri_log rd rn sf dbm | ||
28 | +@logic_imm_64 1 .. ...... dbm:13 rn:5 rd:5 &rri_log sf=1 | ||
29 | +@logic_imm_32 0 .. ...... 0 dbm:12 rn:5 rd:5 &rri_log sf=0 | ||
30 | + | ||
31 | +AND_i . 00 100100 . ...... ...... ..... ..... @logic_imm_64 | ||
32 | +AND_i . 00 100100 . ...... ...... ..... ..... @logic_imm_32 | ||
33 | +ORR_i . 01 100100 . ...... ...... ..... ..... @logic_imm_64 | ||
34 | +ORR_i . 01 100100 . ...... ...... ..... ..... @logic_imm_32 | ||
35 | +EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_64 | ||
36 | +EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_32 | ||
37 | +ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_64 | ||
38 | +ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_32 | ||
39 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/tcg/translate-a64.c | ||
42 | +++ b/target/arm/tcg/translate-a64.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static uint64_t bitfield_replicate(uint64_t mask, unsigned int e) | ||
44 | return mask; | ||
45 | } | ||
46 | |||
47 | -/* Simplified variant of pseudocode DecodeBitMasks() for the case where we | ||
48 | +/* | ||
49 | + * Logical (immediate) | ||
50 | + */ | ||
51 | + | ||
52 | +/* | ||
53 | + * Simplified variant of pseudocode DecodeBitMasks() for the case where we | ||
54 | * only require the wmask. Returns false if the imms/immr/immn are a reserved | ||
55 | * value (ie should cause a guest UNDEF exception), and true if they are | ||
56 | * valid, in which case the decoded bit pattern is written to result. | ||
57 | @@ -XXX,XX +XXX,XX @@ bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn, | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | -/* Logical (immediate) | ||
62 | - * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 | ||
63 | - * +----+-----+-------------+---+------+------+------+------+ | ||
64 | - * | sf | opc | 1 0 0 1 0 0 | N | immr | imms | Rn | Rd | | ||
65 | - * +----+-----+-------------+---+------+------+------+------+ | ||
66 | - */ | ||
67 | -static void disas_logic_imm(DisasContext *s, uint32_t insn) | ||
68 | +static bool gen_rri_log(DisasContext *s, arg_rri_log *a, bool set_cc, | ||
69 | + void (*fn)(TCGv_i64, TCGv_i64, int64_t)) | ||
15 | { | 70 | { |
16 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 71 | - unsigned int sf, opc, is_n, immr, imms, rn, rd; |
17 | CPUARMState *env = cpu->env_ptr; | 72 | TCGv_i64 tcg_rd, tcg_rn; |
18 | + uint32_t pc = dc->base.pc_next; | 73 | - uint64_t wmask; |
19 | unsigned int insn; | 74 | - bool is_and = false; |
20 | 75 | + uint64_t imm; | |
21 | if (arm_pre_translate_insn(dc)) { | 76 | |
22 | - dc->base.pc_next += 4; | 77 | - sf = extract32(insn, 31, 1); |
23 | + dc->base.pc_next = pc + 4; | 78 | - opc = extract32(insn, 29, 2); |
24 | return; | 79 | - is_n = extract32(insn, 22, 1); |
80 | - immr = extract32(insn, 16, 6); | ||
81 | - imms = extract32(insn, 10, 6); | ||
82 | - rn = extract32(insn, 5, 5); | ||
83 | - rd = extract32(insn, 0, 5); | ||
84 | - | ||
85 | - if (!sf && is_n) { | ||
86 | - unallocated_encoding(s); | ||
87 | - return; | ||
88 | + /* Some immediate field values are reserved. */ | ||
89 | + if (!logic_imm_decode_wmask(&imm, extract32(a->dbm, 12, 1), | ||
90 | + extract32(a->dbm, 0, 6), | ||
91 | + extract32(a->dbm, 6, 6))) { | ||
92 | + return false; | ||
93 | + } | ||
94 | + if (!a->sf) { | ||
95 | + imm &= 0xffffffffull; | ||
25 | } | 96 | } |
26 | 97 | ||
27 | - dc->pc_curr = dc->base.pc_next; | 98 | - if (opc == 0x3) { /* ANDS */ |
28 | - insn = arm_ldl_code(env, &dc->base, dc->base.pc_next, dc->sctlr_b); | 99 | - tcg_rd = cpu_reg(s, rd); |
29 | + dc->pc_curr = pc; | 100 | - } else { |
30 | + insn = arm_ldl_code(env, &dc->base, pc, dc->sctlr_b); | 101 | - tcg_rd = cpu_reg_sp(s, rd); |
31 | dc->insn = insn; | 102 | - } |
32 | - dc->base.pc_next += 4; | 103 | - tcg_rn = cpu_reg(s, rn); |
33 | + dc->base.pc_next = pc + 4; | 104 | + tcg_rd = set_cc ? cpu_reg(s, a->rd) : cpu_reg_sp(s, a->rd); |
34 | disas_arm_insn(dc, insn); | 105 | + tcg_rn = cpu_reg(s, a->rn); |
35 | 106 | ||
36 | arm_post_translate_insn(dc); | 107 | - if (!logic_imm_decode_wmask(&wmask, is_n, imms, immr)) { |
108 | - /* some immediate field values are reserved */ | ||
109 | - unallocated_encoding(s); | ||
110 | - return; | ||
111 | + fn(tcg_rd, tcg_rn, imm); | ||
112 | + if (set_cc) { | ||
113 | + gen_logic_CC(a->sf, tcg_rd); | ||
114 | } | ||
115 | - | ||
116 | - if (!sf) { | ||
117 | - wmask &= 0xffffffff; | ||
118 | - } | ||
119 | - | ||
120 | - switch (opc) { | ||
121 | - case 0x3: /* ANDS */ | ||
122 | - case 0x0: /* AND */ | ||
123 | - tcg_gen_andi_i64(tcg_rd, tcg_rn, wmask); | ||
124 | - is_and = true; | ||
125 | - break; | ||
126 | - case 0x1: /* ORR */ | ||
127 | - tcg_gen_ori_i64(tcg_rd, tcg_rn, wmask); | ||
128 | - break; | ||
129 | - case 0x2: /* EOR */ | ||
130 | - tcg_gen_xori_i64(tcg_rd, tcg_rn, wmask); | ||
131 | - break; | ||
132 | - default: | ||
133 | - assert(FALSE); /* must handle all above */ | ||
134 | - break; | ||
135 | - } | ||
136 | - | ||
137 | - if (!sf && !is_and) { | ||
138 | - /* zero extend final result; we know we can skip this for AND | ||
139 | - * since the immediate had the high 32 bits clear. | ||
140 | - */ | ||
141 | + if (!a->sf) { | ||
142 | tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
143 | } | ||
144 | - | ||
145 | - if (opc == 3) { /* ANDS */ | ||
146 | - gen_logic_CC(sf, tcg_rd); | ||
147 | - } | ||
148 | + return true; | ||
149 | } | ||
150 | |||
151 | +TRANS(AND_i, gen_rri_log, a, false, tcg_gen_andi_i64) | ||
152 | +TRANS(ORR_i, gen_rri_log, a, false, tcg_gen_ori_i64) | ||
153 | +TRANS(EOR_i, gen_rri_log, a, false, tcg_gen_xori_i64) | ||
154 | +TRANS(ANDS_i, gen_rri_log, a, true, tcg_gen_andi_i64) | ||
155 | + | ||
156 | /* | ||
157 | * Move wide (immediate) | ||
158 | * | ||
159 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) | ||
160 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) | ||
161 | { | ||
162 | switch (extract32(insn, 23, 6)) { | ||
163 | - case 0x24: /* Logical (immediate) */ | ||
164 | - disas_logic_imm(s, insn); | ||
165 | - break; | ||
166 | case 0x25: /* Move wide (immediate) */ | ||
167 | disas_movw_imm(s, insn); | ||
168 | break; | ||
37 | -- | 169 | -- |
38 | 2.25.1 | 170 | 2.34.1 |
39 | |||
40 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Misaligned thumb PC is architecturally impossible. | 3 | Convert the MON, MOVZ, MOVK instructions. |
4 | Assert is better than proceeding, in case we've missed | ||
5 | something somewhere. | ||
6 | 4 | ||
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> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-11-peter.maydell@linaro.org | ||
9 | [PMM: Rebased] | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | 12 | --- |
14 | target/arm/gdbstub.c | 9 +++++++-- | 13 | target/arm/tcg/a64.decode | 13 ++++++ |
15 | target/arm/machine.c | 10 ++++++++++ | 14 | target/arm/tcg/translate-a64.c | 73 ++++++++++++++-------------------- |
16 | target/arm/translate.c | 3 +++ | 15 | 2 files changed, 42 insertions(+), 44 deletions(-) |
17 | 3 files changed, 20 insertions(+), 2 deletions(-) | ||
18 | 16 | ||
19 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | 17 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
20 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/gdbstub.c | 19 | --- a/target/arm/tcg/a64.decode |
22 | +++ b/target/arm/gdbstub.c | 20 | +++ b/target/arm/tcg/a64.decode |
23 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | 21 | @@ -XXX,XX +XXX,XX @@ EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_64 |
24 | 22 | EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_32 | |
25 | tmp = ldl_p(mem_buf); | 23 | ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_64 |
26 | 24 | ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_32 | |
27 | - /* Mask out low bit of PC to workaround gdb bugs. This will probably | 25 | + |
28 | - cause problems if we ever implement the Jazelle DBX extensions. */ | 26 | +# Move wide (immediate) |
29 | + /* | 27 | + |
30 | + * Mask out low bits of PC to workaround gdb bugs. | 28 | +&movw rd sf imm hw |
31 | + * This avoids an assert in thumb_tr_translate_insn, because it is | 29 | +@movw_64 1 .. ...... hw:2 imm:16 rd:5 &movw sf=1 |
32 | + * architecturally impossible to misalign the pc. | 30 | +@movw_32 0 .. ...... 0 hw:1 imm:16 rd:5 &movw sf=0 |
33 | + * This will probably cause problems if we ever implement the | 31 | + |
34 | + * Jazelle DBX extensions. | 32 | +MOVN . 00 100101 .. ................ ..... @movw_64 |
35 | + */ | 33 | +MOVN . 00 100101 .. ................ ..... @movw_32 |
36 | if (n == 15) { | 34 | +MOVZ . 10 100101 .. ................ ..... @movw_64 |
37 | tmp &= ~1; | 35 | +MOVZ . 10 100101 .. ................ ..... @movw_32 |
36 | +MOVK . 11 100101 .. ................ ..... @movw_64 | ||
37 | +MOVK . 11 100101 .. ................ ..... @movw_32 | ||
38 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/tcg/translate-a64.c | ||
41 | +++ b/target/arm/tcg/translate-a64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ TRANS(ANDS_i, gen_rri_log, a, true, tcg_gen_andi_i64) | ||
43 | |||
44 | /* | ||
45 | * Move wide (immediate) | ||
46 | - * | ||
47 | - * 31 30 29 28 23 22 21 20 5 4 0 | ||
48 | - * +--+-----+-------------+-----+----------------+------+ | ||
49 | - * |sf| opc | 1 0 0 1 0 1 | hw | imm16 | Rd | | ||
50 | - * +--+-----+-------------+-----+----------------+------+ | ||
51 | - * | ||
52 | - * sf: 0 -> 32 bit, 1 -> 64 bit | ||
53 | - * opc: 00 -> N, 10 -> Z, 11 -> K | ||
54 | - * hw: shift/16 (0,16, and sf only 32, 48) | ||
55 | */ | ||
56 | -static void disas_movw_imm(DisasContext *s, uint32_t insn) | ||
57 | + | ||
58 | +static bool trans_MOVZ(DisasContext *s, arg_movw *a) | ||
59 | { | ||
60 | - int rd = extract32(insn, 0, 5); | ||
61 | - uint64_t imm = extract32(insn, 5, 16); | ||
62 | - int sf = extract32(insn, 31, 1); | ||
63 | - int opc = extract32(insn, 29, 2); | ||
64 | - int pos = extract32(insn, 21, 2) << 4; | ||
65 | - TCGv_i64 tcg_rd = cpu_reg(s, rd); | ||
66 | + int pos = a->hw << 4; | ||
67 | + tcg_gen_movi_i64(cpu_reg(s, a->rd), (uint64_t)a->imm << pos); | ||
68 | + return true; | ||
69 | +} | ||
70 | |||
71 | - if (!sf && (pos >= 32)) { | ||
72 | - unallocated_encoding(s); | ||
73 | - return; | ||
74 | - } | ||
75 | +static bool trans_MOVN(DisasContext *s, arg_movw *a) | ||
76 | +{ | ||
77 | + int pos = a->hw << 4; | ||
78 | + uint64_t imm = a->imm; | ||
79 | |||
80 | - switch (opc) { | ||
81 | - case 0: /* MOVN */ | ||
82 | - case 2: /* MOVZ */ | ||
83 | - imm <<= pos; | ||
84 | - if (opc == 0) { | ||
85 | - imm = ~imm; | ||
86 | - } | ||
87 | - if (!sf) { | ||
88 | - imm &= 0xffffffffu; | ||
89 | - } | ||
90 | - tcg_gen_movi_i64(tcg_rd, imm); | ||
91 | - break; | ||
92 | - case 3: /* MOVK */ | ||
93 | - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_constant_i64(imm), pos, 16); | ||
94 | - if (!sf) { | ||
95 | - tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
96 | - } | ||
97 | - break; | ||
98 | - default: | ||
99 | - unallocated_encoding(s); | ||
100 | - break; | ||
101 | + imm = ~(imm << pos); | ||
102 | + if (!a->sf) { | ||
103 | + imm = (uint32_t)imm; | ||
38 | } | 104 | } |
39 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 105 | + tcg_gen_movi_i64(cpu_reg(s, a->rd), imm); |
40 | index XXXXXXX..XXXXXXX 100644 | 106 | + return true; |
41 | --- a/target/arm/machine.c | 107 | +} |
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 | + | 108 | + |
48 | + /* | 109 | +static bool trans_MOVK(DisasContext *s, arg_movw *a) |
49 | + * Misaligned thumb pc is architecturally impossible. | 110 | +{ |
50 | + * We have an assert in thumb_tr_translate_insn to verify this. | 111 | + int pos = a->hw << 4; |
51 | + * Fail an incoming migrate to avoid this assert. | 112 | + TCGv_i64 tcg_rd, tcg_im; |
52 | + */ | 113 | + |
53 | + if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { | 114 | + tcg_rd = cpu_reg(s, a->rd); |
54 | + return -1; | 115 | + tcg_im = tcg_constant_i64(a->imm); |
116 | + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_im, pos, 16); | ||
117 | + if (!a->sf) { | ||
118 | + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
55 | + } | 119 | + } |
56 | + | 120 | + return true; |
57 | if (!kvm_enabled()) { | 121 | } |
58 | pmu_op_finish(&cpu->env); | 122 | |
59 | } | 123 | /* Bitfield |
60 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 124 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) |
61 | index XXXXXXX..XXXXXXX 100644 | 125 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) |
62 | --- a/target/arm/translate.c | 126 | { |
63 | +++ b/target/arm/translate.c | 127 | switch (extract32(insn, 23, 6)) { |
64 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 128 | - case 0x25: /* Move wide (immediate) */ |
65 | uint32_t insn; | 129 | - disas_movw_imm(s, insn); |
66 | bool is_16bit; | 130 | - break; |
67 | 131 | case 0x26: /* Bitfield */ | |
68 | + /* Misaligned thumb PC is architecturally impossible. */ | 132 | disas_bitfield(s, insn); |
69 | + assert((dc->base.pc_next & 1) == 0); | 133 | break; |
70 | + | ||
71 | if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | ||
72 | dc->base.pc_next = pc + 2; | ||
73 | return; | ||
74 | -- | 134 | -- |
75 | 2.25.1 | 135 | 2.34.1 |
76 | |||
77 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | While trying to debug a GIC ITS failure I saw some guest errors that | 3 | Convert the BFM, SBFM, UBFM instructions. |
4 | had poor formatting as well as leaving me confused as to what failed. | ||
5 | As most of the checks aren't possible without a valid dte split that | ||
6 | check apart and then check the other conditions in steps. This avoids | ||
7 | us relying on undefined data. | ||
8 | 4 | ||
9 | I still get a failure with the current kvm-unit-tests but at least I | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
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 | ||
19 | |||
20 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Message-id: 20211112170454.3158925-1-alex.bennee@linaro.org | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Cc: Shashi Mallela <shashi.mallela@linaro.org> | 8 | Message-id: 20230512144106.3608981-12-peter.maydell@linaro.org |
24 | Cc: Peter Maydell <peter.maydell@linaro.org> | 9 | [PMM: Rebased] |
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
26 | --- | 11 | --- |
27 | hw/intc/arm_gicv3_its.c | 39 +++++++++++++++++++++++++++------------ | 12 | target/arm/tcg/a64.decode | 13 +++ |
28 | 1 file changed, 27 insertions(+), 12 deletions(-) | 13 | target/arm/tcg/translate-a64.c | 144 ++++++++++++++++++--------------- |
14 | 2 files changed, 94 insertions(+), 63 deletions(-) | ||
29 | 15 | ||
30 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 16 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
31 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/intc/arm_gicv3_its.c | 18 | --- a/target/arm/tcg/a64.decode |
33 | +++ b/hw/intc/arm_gicv3_its.c | 19 | +++ b/target/arm/tcg/a64.decode |
34 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | 20 | @@ -XXX,XX +XXX,XX @@ MOVZ . 10 100101 .. ................ ..... @movw_64 |
35 | if (res != MEMTX_OK) { | 21 | MOVZ . 10 100101 .. ................ ..... @movw_32 |
36 | return result; | 22 | MOVK . 11 100101 .. ................ ..... @movw_64 |
23 | MOVK . 11 100101 .. ................ ..... @movw_32 | ||
24 | + | ||
25 | +# Bitfield | ||
26 | + | ||
27 | +&bitfield rd rn sf immr imms | ||
28 | +@bitfield_64 1 .. ...... 1 immr:6 imms:6 rn:5 rd:5 &bitfield sf=1 | ||
29 | +@bitfield_32 0 .. ...... 0 0 immr:5 0 imms:5 rn:5 rd:5 &bitfield sf=0 | ||
30 | + | ||
31 | +SBFM . 00 100110 . ...... ...... ..... ..... @bitfield_64 | ||
32 | +SBFM . 00 100110 . ...... ...... ..... ..... @bitfield_32 | ||
33 | +BFM . 01 100110 . ...... ...... ..... ..... @bitfield_64 | ||
34 | +BFM . 01 100110 . ...... ...... ..... ..... @bitfield_32 | ||
35 | +UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_64 | ||
36 | +UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 | ||
37 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/tcg/translate-a64.c | ||
40 | +++ b/target/arm/tcg/translate-a64.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVK(DisasContext *s, arg_movw *a) | ||
42 | return true; | ||
43 | } | ||
44 | |||
45 | -/* Bitfield | ||
46 | - * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 | ||
47 | - * +----+-----+-------------+---+------+------+------+------+ | ||
48 | - * | sf | opc | 1 0 0 1 1 0 | N | immr | imms | Rn | Rd | | ||
49 | - * +----+-----+-------------+---+------+------+------+------+ | ||
50 | +/* | ||
51 | + * Bitfield | ||
52 | */ | ||
53 | -static void disas_bitfield(DisasContext *s, uint32_t insn) | ||
54 | + | ||
55 | +static bool trans_SBFM(DisasContext *s, arg_SBFM *a) | ||
56 | { | ||
57 | - unsigned int sf, n, opc, ri, si, rn, rd, bitsize, pos, len; | ||
58 | - TCGv_i64 tcg_rd, tcg_tmp; | ||
59 | + TCGv_i64 tcg_rd = cpu_reg(s, a->rd); | ||
60 | + TCGv_i64 tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
61 | + unsigned int bitsize = a->sf ? 64 : 32; | ||
62 | + unsigned int ri = a->immr; | ||
63 | + unsigned int si = a->imms; | ||
64 | + unsigned int pos, len; | ||
65 | |||
66 | - sf = extract32(insn, 31, 1); | ||
67 | - opc = extract32(insn, 29, 2); | ||
68 | - n = extract32(insn, 22, 1); | ||
69 | - ri = extract32(insn, 16, 6); | ||
70 | - si = extract32(insn, 10, 6); | ||
71 | - rn = extract32(insn, 5, 5); | ||
72 | - rd = extract32(insn, 0, 5); | ||
73 | - bitsize = sf ? 64 : 32; | ||
74 | - | ||
75 | - if (sf != n || ri >= bitsize || si >= bitsize || opc > 2) { | ||
76 | - unallocated_encoding(s); | ||
77 | - return; | ||
78 | - } | ||
79 | - | ||
80 | - tcg_rd = cpu_reg(s, rd); | ||
81 | - | ||
82 | - /* Suppress the zero-extend for !sf. Since RI and SI are constrained | ||
83 | - to be smaller than bitsize, we'll never reference data outside the | ||
84 | - low 32-bits anyway. */ | ||
85 | - tcg_tmp = read_cpu_reg(s, rn, 1); | ||
86 | - | ||
87 | - /* Recognize simple(r) extractions. */ | ||
88 | if (si >= ri) { | ||
89 | /* Wd<s-r:0> = Wn<s:r> */ | ||
90 | len = (si - ri) + 1; | ||
91 | - if (opc == 0) { /* SBFM: ASR, SBFX, SXTB, SXTH, SXTW */ | ||
92 | - tcg_gen_sextract_i64(tcg_rd, tcg_tmp, ri, len); | ||
93 | - goto done; | ||
94 | - } else if (opc == 2) { /* UBFM: UBFX, LSR, UXTB, UXTH */ | ||
95 | - tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); | ||
96 | - return; | ||
97 | + tcg_gen_sextract_i64(tcg_rd, tcg_tmp, ri, len); | ||
98 | + if (!a->sf) { | ||
99 | + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
37 | } | 100 | } |
101 | - /* opc == 1, BFXIL fall through to deposit */ | ||
38 | + } else { | 102 | + } else { |
39 | + qemu_log_mask(LOG_GUEST_ERROR, | 103 | + /* Wd<32+s-r,32-r> = Wn<s:0> */ |
40 | + "%s: invalid command attributes: " | 104 | + len = si + 1; |
41 | + "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n", | 105 | + pos = (bitsize - ri) & (bitsize - 1); |
42 | + __func__, dte, devid, res); | 106 | + |
43 | + return result; | 107 | + if (len < ri) { |
108 | + /* | ||
109 | + * Sign extend the destination field from len to fill the | ||
110 | + * balance of the word. Let the deposit below insert all | ||
111 | + * of those sign bits. | ||
112 | + */ | ||
113 | + tcg_gen_sextract_i64(tcg_tmp, tcg_tmp, 0, len); | ||
114 | + len = ri; | ||
115 | + } | ||
116 | + | ||
117 | + /* | ||
118 | + * We start with zero, and we haven't modified any bits outside | ||
119 | + * bitsize, therefore no final zero-extension is unneeded for !sf. | ||
120 | + */ | ||
121 | + tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); | ||
122 | + } | ||
123 | + return true; | ||
124 | +} | ||
125 | + | ||
126 | +static bool trans_UBFM(DisasContext *s, arg_UBFM *a) | ||
127 | +{ | ||
128 | + TCGv_i64 tcg_rd = cpu_reg(s, a->rd); | ||
129 | + TCGv_i64 tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
130 | + unsigned int bitsize = a->sf ? 64 : 32; | ||
131 | + unsigned int ri = a->immr; | ||
132 | + unsigned int si = a->imms; | ||
133 | + unsigned int pos, len; | ||
134 | + | ||
135 | + tcg_rd = cpu_reg(s, a->rd); | ||
136 | + tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
137 | + | ||
138 | + if (si >= ri) { | ||
139 | + /* Wd<s-r:0> = Wn<s:r> */ | ||
140 | + len = (si - ri) + 1; | ||
141 | + tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); | ||
142 | + } else { | ||
143 | + /* Wd<32+s-r,32-r> = Wn<s:0> */ | ||
144 | + len = si + 1; | ||
145 | + pos = (bitsize - ri) & (bitsize - 1); | ||
146 | + tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); | ||
147 | + } | ||
148 | + return true; | ||
149 | +} | ||
150 | + | ||
151 | +static bool trans_BFM(DisasContext *s, arg_BFM *a) | ||
152 | +{ | ||
153 | + TCGv_i64 tcg_rd = cpu_reg(s, a->rd); | ||
154 | + TCGv_i64 tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
155 | + unsigned int bitsize = a->sf ? 64 : 32; | ||
156 | + unsigned int ri = a->immr; | ||
157 | + unsigned int si = a->imms; | ||
158 | + unsigned int pos, len; | ||
159 | + | ||
160 | + tcg_rd = cpu_reg(s, a->rd); | ||
161 | + tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
162 | + | ||
163 | + if (si >= ri) { | ||
164 | + /* Wd<s-r:0> = Wn<s:r> */ | ||
165 | tcg_gen_shri_i64(tcg_tmp, tcg_tmp, ri); | ||
166 | + len = (si - ri) + 1; | ||
167 | pos = 0; | ||
168 | } else { | ||
169 | - /* Handle the ri > si case with a deposit | ||
170 | - * Wd<32+s-r,32-r> = Wn<s:0> | ||
171 | - */ | ||
172 | + /* Wd<32+s-r,32-r> = Wn<s:0> */ | ||
173 | len = si + 1; | ||
174 | pos = (bitsize - ri) & (bitsize - 1); | ||
44 | } | 175 | } |
45 | 176 | ||
46 | - if ((devid > s->dt.maxids.max_devids) || !dte_valid || !ite_valid || | 177 | - if (opc == 0 && len < ri) { |
47 | - !cte_valid || (eventid > max_eventid)) { | 178 | - /* SBFM: sign extend the destination field from len to fill |
48 | + | 179 | - the balance of the word. Let the deposit below insert all |
49 | + /* | 180 | - of those sign bits. */ |
50 | + * In this implementation, in case of guest errors we ignore the | 181 | - tcg_gen_sextract_i64(tcg_tmp, tcg_tmp, 0, len); |
51 | + * command and move onto the next command in the queue. | 182 | - len = ri; |
52 | + */ | 183 | - } |
53 | + if (devid > s->dt.maxids.max_devids) { | 184 | - |
54 | qemu_log_mask(LOG_GUEST_ERROR, | 185 | - if (opc == 1) { /* BFM, BFXIL */ |
55 | - "%s: invalid command attributes " | 186 | - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); |
56 | - "devid %d or eventid %d or invalid dte %d or" | 187 | - } else { |
57 | - "invalid cte %d or invalid ite %d\n", | 188 | - /* SBFM or UBFM: We start with zero, and we haven't modified |
58 | - __func__, devid, eventid, dte_valid, cte_valid, | 189 | - any bits outside bitsize, therefore the zero-extension |
59 | - ite_valid); | 190 | - below is unneeded. */ |
60 | - /* | 191 | - tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); |
61 | - * in this implementation, in case of error | 192 | - return; |
62 | - * we ignore this command and move onto the next | 193 | - } |
63 | - * command in the queue | 194 | - |
64 | - */ | 195 | - done: |
65 | + "%s: invalid command attributes: devid %d>%d", | 196 | - if (!sf) { /* zero extend final result */ |
66 | + __func__, devid, s->dt.maxids.max_devids); | 197 | + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); |
67 | + | 198 | + if (!a->sf) { |
68 | + } else if (!dte_valid || !ite_valid || !cte_valid) { | 199 | tcg_gen_ext32u_i64(tcg_rd, tcg_rd); |
69 | + qemu_log_mask(LOG_GUEST_ERROR, | 200 | } |
70 | + "%s: invalid command attributes: " | 201 | + return true; |
71 | + "dte: %s, ite: %s, cte: %s\n", | 202 | } |
72 | + __func__, | 203 | |
73 | + dte_valid ? "valid" : "invalid", | 204 | /* Extract |
74 | + ite_valid ? "valid" : "invalid", | 205 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) |
75 | + cte_valid ? "valid" : "invalid"); | 206 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) |
76 | + } else if (eventid > max_eventid) { | 207 | { |
77 | + qemu_log_mask(LOG_GUEST_ERROR, | 208 | switch (extract32(insn, 23, 6)) { |
78 | + "%s: invalid command attributes: eventid %d > %d\n", | 209 | - case 0x26: /* Bitfield */ |
79 | + __func__, eventid, max_eventid); | 210 | - disas_bitfield(s, insn); |
80 | } else { | 211 | - break; |
81 | /* | 212 | case 0x27: /* Extract */ |
82 | * Current implementation only supports rdbase == procnum | 213 | disas_extract(s, insn); |
214 | break; | ||
83 | -- | 215 | -- |
84 | 2.25.1 | 216 | 2.34.1 |
85 | |||
86 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | Add X11, FP5280G2, G220A, Rainier and Fuji. Mention that Swift will be | ||
4 | removed in v7.0. | ||
5 | |||
6 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20211117065752.330632-2-joel@jms.id.au | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | docs/system/arm/aspeed.rst | 7 ++++++- | ||
12 | 1 file changed, 6 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/docs/system/arm/aspeed.rst | ||
17 | +++ b/docs/system/arm/aspeed.rst | ||
18 | @@ -XXX,XX +XXX,XX @@ AST2400 SoC based machines : | ||
19 | |||
20 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC | ||
21 | - ``quanta-q71l-bmc`` OpenBMC Quanta BMC | ||
22 | +- ``supermicrox11-bmc`` Supermicro X11 BMC | ||
23 | |||
24 | AST2500 SoC based machines : | ||
25 | |||
26 | @@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines : | ||
27 | - ``romulus-bmc`` OpenPOWER Romulus POWER9 BMC | ||
28 | - ``witherspoon-bmc`` OpenPOWER Witherspoon POWER9 BMC | ||
29 | - ``sonorapass-bmc`` OCP SonoraPass BMC | ||
30 | -- ``swift-bmc`` OpenPOWER Swift BMC POWER9 | ||
31 | +- ``swift-bmc`` OpenPOWER Swift BMC POWER9 (to be removed in v7.0) | ||
32 | +- ``fp5280g2-bmc`` Inspur FP5280G2 BMC | ||
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 | ----------------- | ||
44 | -- | ||
45 | 2.25.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the EXTR instruction to decodetree (this is the |
---|---|---|---|
2 | only one in the 'Extract" class). This is the last of | ||
3 | the dp-immediate insns in the legacy decoder, so we | ||
4 | can now remove disas_data_proc_imm(). | ||
2 | 5 | ||
3 | When a virtio-iommu is instantiated, describe it using the ACPI VIOT | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | table. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20230512144106.3608981-13-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/tcg/a64.decode | 7 +++ | ||
11 | target/arm/tcg/translate-a64.c | 94 +++++++++++----------------------- | ||
12 | 2 files changed, 36 insertions(+), 65 deletions(-) | ||
5 | 13 | ||
6 | Acked-by: Igor Mammedov <imammedo@redhat.com> | 14 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
9 | Message-id: 20211210170415.583179-2-jean-philippe@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/virt-acpi-build.c | 7 +++++++ | ||
13 | hw/arm/Kconfig | 1 + | ||
14 | 2 files changed, 8 insertions(+) | ||
15 | |||
16 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/virt-acpi-build.c | 16 | --- a/target/arm/tcg/a64.decode |
19 | +++ b/hw/arm/virt-acpi-build.c | 17 | +++ b/target/arm/tcg/a64.decode |
20 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ BFM . 01 100110 . ...... ...... ..... ..... @bitfield_64 |
21 | #include "kvm_arm.h" | 19 | BFM . 01 100110 . ...... ...... ..... ..... @bitfield_32 |
22 | #include "migration/vmstate.h" | 20 | UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_64 |
23 | #include "hw/acpi/ghes.h" | 21 | UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 |
24 | +#include "hw/acpi/viot.h" | 22 | + |
25 | 23 | +# Extract | |
26 | #define ARM_SPI_BASE 32 | 24 | + |
27 | 25 | +&extract rd rn rm imm sf | |
28 | @@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) | 26 | + |
27 | +EXTR 1 00 100111 1 0 rm:5 imm:6 rn:5 rd:5 &extract sf=1 | ||
28 | +EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 &extract sf=0 | ||
29 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/tcg/translate-a64.c | ||
32 | +++ b/target/arm/tcg/translate-a64.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static bool trans_BFM(DisasContext *s, arg_BFM *a) | ||
34 | return true; | ||
35 | } | ||
36 | |||
37 | -/* Extract | ||
38 | - * 31 30 29 28 23 22 21 20 16 15 10 9 5 4 0 | ||
39 | - * +----+------+-------------+---+----+------+--------+------+------+ | ||
40 | - * | sf | op21 | 1 0 0 1 1 1 | N | o0 | Rm | imms | Rn | Rd | | ||
41 | - * +----+------+-------------+---+----+------+--------+------+------+ | ||
42 | - */ | ||
43 | -static void disas_extract(DisasContext *s, uint32_t insn) | ||
44 | +static bool trans_EXTR(DisasContext *s, arg_extract *a) | ||
45 | { | ||
46 | - unsigned int sf, n, rm, imm, rn, rd, bitsize, op21, op0; | ||
47 | + TCGv_i64 tcg_rd, tcg_rm, tcg_rn; | ||
48 | |||
49 | - sf = extract32(insn, 31, 1); | ||
50 | - n = extract32(insn, 22, 1); | ||
51 | - rm = extract32(insn, 16, 5); | ||
52 | - imm = extract32(insn, 10, 6); | ||
53 | - rn = extract32(insn, 5, 5); | ||
54 | - rd = extract32(insn, 0, 5); | ||
55 | - op21 = extract32(insn, 29, 2); | ||
56 | - op0 = extract32(insn, 21, 1); | ||
57 | - bitsize = sf ? 64 : 32; | ||
58 | + tcg_rd = cpu_reg(s, a->rd); | ||
59 | |||
60 | - if (sf != n || op21 || op0 || imm >= bitsize) { | ||
61 | - unallocated_encoding(s); | ||
62 | - } else { | ||
63 | - TCGv_i64 tcg_rd, tcg_rm, tcg_rn; | ||
64 | - | ||
65 | - tcg_rd = cpu_reg(s, rd); | ||
66 | - | ||
67 | - if (unlikely(imm == 0)) { | ||
68 | - /* tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, | ||
69 | - * so an extract from bit 0 is a special case. | ||
70 | - */ | ||
71 | - if (sf) { | ||
72 | - tcg_gen_mov_i64(tcg_rd, cpu_reg(s, rm)); | ||
73 | - } else { | ||
74 | - tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rm)); | ||
75 | - } | ||
76 | + if (unlikely(a->imm == 0)) { | ||
77 | + /* | ||
78 | + * tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, | ||
79 | + * so an extract from bit 0 is a special case. | ||
80 | + */ | ||
81 | + if (a->sf) { | ||
82 | + tcg_gen_mov_i64(tcg_rd, cpu_reg(s, a->rm)); | ||
83 | } else { | ||
84 | - tcg_rm = cpu_reg(s, rm); | ||
85 | - tcg_rn = cpu_reg(s, rn); | ||
86 | + tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, a->rm)); | ||
87 | + } | ||
88 | + } else { | ||
89 | + tcg_rm = cpu_reg(s, a->rm); | ||
90 | + tcg_rn = cpu_reg(s, a->rn); | ||
91 | |||
92 | - if (sf) { | ||
93 | - /* Specialization to ROR happens in EXTRACT2. */ | ||
94 | - tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, imm); | ||
95 | + if (a->sf) { | ||
96 | + /* Specialization to ROR happens in EXTRACT2. */ | ||
97 | + tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, a->imm); | ||
98 | + } else { | ||
99 | + TCGv_i32 t0 = tcg_temp_new_i32(); | ||
100 | + | ||
101 | + tcg_gen_extrl_i64_i32(t0, tcg_rm); | ||
102 | + if (a->rm == a->rn) { | ||
103 | + tcg_gen_rotri_i32(t0, t0, a->imm); | ||
104 | } else { | ||
105 | - TCGv_i32 t0 = tcg_temp_new_i32(); | ||
106 | - | ||
107 | - tcg_gen_extrl_i64_i32(t0, tcg_rm); | ||
108 | - if (rm == rn) { | ||
109 | - tcg_gen_rotri_i32(t0, t0, imm); | ||
110 | - } else { | ||
111 | - TCGv_i32 t1 = tcg_temp_new_i32(); | ||
112 | - tcg_gen_extrl_i64_i32(t1, tcg_rn); | ||
113 | - tcg_gen_extract2_i32(t0, t0, t1, imm); | ||
114 | - } | ||
115 | - tcg_gen_extu_i32_i64(tcg_rd, t0); | ||
116 | + TCGv_i32 t1 = tcg_temp_new_i32(); | ||
117 | + tcg_gen_extrl_i64_i32(t1, tcg_rn); | ||
118 | + tcg_gen_extract2_i32(t0, t0, t1, a->imm); | ||
119 | } | ||
120 | + tcg_gen_extu_i32_i64(tcg_rd, t0); | ||
121 | } | ||
29 | } | 122 | } |
30 | #endif | 123 | -} |
31 | 124 | - | |
32 | + if (vms->iommu == VIRT_IOMMU_VIRTIO) { | 125 | -/* Data processing - immediate */ |
33 | + acpi_add_table(table_offsets, tables_blob); | 126 | -static void disas_data_proc_imm(DisasContext *s, uint32_t insn) |
34 | + build_viot(ms, tables_blob, tables->linker, vms->virtio_iommu_bdf, | 127 | -{ |
35 | + vms->oem_id, vms->oem_table_id); | 128 | - switch (extract32(insn, 23, 6)) { |
36 | + } | 129 | - case 0x27: /* Extract */ |
37 | + | 130 | - disas_extract(s, insn); |
38 | /* XSDT is pointed to by RSDP */ | 131 | - break; |
39 | xsdt = tables_blob->len; | 132 | - default: |
40 | build_xsdt(tables_blob, tables->linker, table_offsets, vms->oem_id, | 133 | - unallocated_encoding(s); |
41 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 134 | - break; |
42 | index XXXXXXX..XXXXXXX 100644 | 135 | - } |
43 | --- a/hw/arm/Kconfig | 136 | + return true; |
44 | +++ b/hw/arm/Kconfig | 137 | } |
45 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT | 138 | |
46 | select DIMM | 139 | /* Shift a TCGv src by TCGv shift_amount, put result in dst. |
47 | select ACPI_HW_REDUCED | 140 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) |
48 | select ACPI_APEI | 141 | static void disas_a64_legacy(DisasContext *s, uint32_t insn) |
49 | + select ACPI_VIOT | 142 | { |
50 | 143 | switch (extract32(insn, 25, 4)) { | |
51 | config CHEETAH | 144 | - case 0x8: case 0x9: /* Data processing - immediate */ |
52 | bool | 145 | - disas_data_proc_imm(s, insn); |
146 | - break; | ||
147 | case 0xa: case 0xb: /* Branch, exception generation and system insns */ | ||
148 | disas_b_exc_sys(s, insn); | ||
149 | break; | ||
53 | -- | 150 | -- |
54 | 2.25.1 | 151 | 2.34.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | The qemu-common.h header is not supposed to be included from any | 1 | Convert the unconditional branch immediate insns B and BL to |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | 2 | decodetree. |
3 | the start of it). | ||
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 | 3 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Message-id: 20230512144106.3608981-14-peter.maydell@linaro.org |
11 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | ||
12 | Message-id: 20211129200510.1233037-3-peter.maydell@linaro.org | ||
13 | --- | 7 | --- |
14 | target/hexagon/cpu.h | 1 - | 8 | target/arm/tcg/a64.decode | 9 +++++++++ |
15 | linux-user/hexagon/cpu_loop.c | 1 + | 9 | target/arm/tcg/translate-a64.c | 31 +++++++++++-------------------- |
16 | 2 files changed, 1 insertion(+), 1 deletion(-) | 10 | 2 files changed, 20 insertions(+), 20 deletions(-) |
17 | 11 | ||
18 | diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/hexagon/cpu.h | 14 | --- a/target/arm/tcg/a64.decode |
21 | +++ b/target/hexagon/cpu.h | 15 | +++ b/target/arm/tcg/a64.decode |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUHexagonState CPUHexagonState; | 16 | @@ -XXX,XX +XXX,XX @@ |
23 | 17 | ||
24 | #include "fpu/softfloat-types.h" | 18 | &ri rd imm |
25 | 19 | &rri_sf rd rn imm sf | |
26 | -#include "qemu-common.h" | 20 | +&i imm |
27 | #include "exec/cpu-defs.h" | 21 | |
28 | #include "hex_regs.h" | 22 | |
29 | #include "mmvec/mmvec.h" | 23 | ### Data Processing - Immediate |
30 | diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c | 24 | @@ -XXX,XX +XXX,XX @@ UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 |
25 | |||
26 | EXTR 1 00 100111 1 0 rm:5 imm:6 rn:5 rd:5 &extract sf=1 | ||
27 | EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 &extract sf=0 | ||
28 | + | ||
29 | +# Branches | ||
30 | + | ||
31 | +%imm26 0:s26 !function=times_4 | ||
32 | +@branch . ..... .......................... &i imm=%imm26 | ||
33 | + | ||
34 | +B 0 00101 .......................... @branch | ||
35 | +BL 1 00101 .......................... @branch | ||
36 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/linux-user/hexagon/cpu_loop.c | 38 | --- a/target/arm/tcg/translate-a64.c |
33 | +++ b/linux-user/hexagon/cpu_loop.c | 39 | +++ b/target/arm/tcg/translate-a64.c |
34 | @@ -XXX,XX +XXX,XX @@ | 40 | @@ -XXX,XX +XXX,XX @@ static inline AArch64DecodeFn *lookup_disas_fn(const AArch64DecodeTable *table, |
41 | * match up with those in the manual. | ||
35 | */ | 42 | */ |
36 | 43 | ||
37 | #include "qemu/osdep.h" | 44 | -/* Unconditional branch (immediate) |
38 | +#include "qemu-common.h" | 45 | - * 31 30 26 25 0 |
39 | #include "qemu.h" | 46 | - * +----+-----------+-------------------------------------+ |
40 | #include "user-internals.h" | 47 | - * | op | 0 0 1 0 1 | imm26 | |
41 | #include "cpu_loop-common.h" | 48 | - * +----+-----------+-------------------------------------+ |
49 | - */ | ||
50 | -static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) | ||
51 | +static bool trans_B(DisasContext *s, arg_i *a) | ||
52 | { | ||
53 | - int64_t diff = sextract32(insn, 0, 26) * 4; | ||
54 | - | ||
55 | - if (insn & (1U << 31)) { | ||
56 | - /* BL Branch with link */ | ||
57 | - gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); | ||
58 | - } | ||
59 | - | ||
60 | - /* B Branch / BL Branch with link */ | ||
61 | reset_btype(s); | ||
62 | - gen_goto_tb(s, 0, diff); | ||
63 | + gen_goto_tb(s, 0, a->imm); | ||
64 | + return true; | ||
65 | +} | ||
66 | + | ||
67 | +static bool trans_BL(DisasContext *s, arg_i *a) | ||
68 | +{ | ||
69 | + gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); | ||
70 | + reset_btype(s); | ||
71 | + gen_goto_tb(s, 0, a->imm); | ||
72 | + return true; | ||
73 | } | ||
74 | |||
75 | /* Compare and branch (immediate) | ||
76 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
77 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
78 | { | ||
79 | switch (extract32(insn, 25, 7)) { | ||
80 | - case 0x0a: case 0x0b: | ||
81 | - case 0x4a: case 0x4b: /* Unconditional branch (immediate) */ | ||
82 | - disas_uncond_b_imm(s, insn); | ||
83 | - break; | ||
84 | case 0x1a: case 0x5a: /* Compare & branch (immediate) */ | ||
85 | disas_comp_b_imm(s, insn); | ||
86 | break; | ||
42 | -- | 87 | -- |
43 | 2.25.1 | 88 | 2.34.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the compare-and-branch-immediate insns CBZ and CBNZ |
---|---|---|---|
2 | to decodetree. | ||
2 | 3 | ||
3 | virtio-iommu is now supported with ACPI VIOT as well as device tree. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Remove the restriction that prevents from instantiating a virtio-iommu | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | device under ACPI. | 6 | Message-id: 20230512144106.3608981-15-peter.maydell@linaro.org |
7 | --- | ||
8 | target/arm/tcg/a64.decode | 5 +++++ | ||
9 | target/arm/tcg/translate-a64.c | 26 ++++++-------------------- | ||
10 | 2 files changed, 11 insertions(+), 20 deletions(-) | ||
6 | 11 | ||
7 | Acked-by: Igor Mammedov <imammedo@redhat.com> | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
10 | Message-id: 20211210170415.583179-3-jean-philippe@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/arm/virt.c | 10 ++-------- | ||
14 | hw/virtio/virtio-iommu-pci.c | 12 ++---------- | ||
15 | 2 files changed, 4 insertions(+), 18 deletions(-) | ||
16 | |||
17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/virt.c | 14 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/hw/arm/virt.c | 15 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | 16 | @@ -XXX,XX +XXX,XX @@ EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 &extract sf=0 |
22 | MachineClass *mc = MACHINE_GET_CLASS(machine); | 17 | |
23 | 18 | B 0 00101 .......................... @branch | |
24 | if (device_is_dynamic_sysbus(mc, dev) || | 19 | BL 1 00101 .......................... @branch |
25 | - (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { | 20 | + |
26 | + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || | 21 | +%imm19 5:s19 !function=times_4 |
27 | + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { | 22 | +&cbz rt imm sf nz |
28 | return HOTPLUG_HANDLER(machine); | 23 | + |
29 | } | 24 | +CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=%imm19 |
30 | - if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { | 25 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
31 | - VirtMachineState *vms = VIRT_MACHINE(machine); | 26 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/tcg/translate-a64.c | ||
28 | +++ b/target/arm/tcg/translate-a64.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool trans_BL(DisasContext *s, arg_i *a) | ||
30 | return true; | ||
31 | } | ||
32 | |||
33 | -/* Compare and branch (immediate) | ||
34 | - * 31 30 25 24 23 5 4 0 | ||
35 | - * +----+-------------+----+---------------------+--------+ | ||
36 | - * | sf | 0 1 1 0 1 0 | op | imm19 | Rt | | ||
37 | - * +----+-------------+----+---------------------+--------+ | ||
38 | - */ | ||
39 | -static void disas_comp_b_imm(DisasContext *s, uint32_t insn) | ||
40 | + | ||
41 | +static bool trans_CBZ(DisasContext *s, arg_cbz *a) | ||
42 | { | ||
43 | - unsigned int sf, op, rt; | ||
44 | - int64_t diff; | ||
45 | DisasLabel match; | ||
46 | TCGv_i64 tcg_cmp; | ||
47 | |||
48 | - sf = extract32(insn, 31, 1); | ||
49 | - op = extract32(insn, 24, 1); /* 0: CBZ; 1: CBNZ */ | ||
50 | - rt = extract32(insn, 0, 5); | ||
51 | - diff = sextract32(insn, 5, 19) * 4; | ||
32 | - | 52 | - |
33 | - if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { | 53 | - tcg_cmp = read_cpu_reg(s, rt, sf); |
34 | - return HOTPLUG_HANDLER(machine); | 54 | + tcg_cmp = read_cpu_reg(s, a->rt, a->sf); |
35 | - } | 55 | reset_btype(s); |
36 | - } | 56 | |
37 | return NULL; | 57 | match = gen_disas_label(s); |
58 | - tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | ||
59 | + tcg_gen_brcondi_i64(a->nz ? TCG_COND_NE : TCG_COND_EQ, | ||
60 | tcg_cmp, 0, match.label); | ||
61 | gen_goto_tb(s, 0, 4); | ||
62 | set_disas_label(s, match); | ||
63 | - gen_goto_tb(s, 1, diff); | ||
64 | + gen_goto_tb(s, 1, a->imm); | ||
65 | + return true; | ||
38 | } | 66 | } |
39 | 67 | ||
40 | diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c | 68 | /* Test and branch (immediate) |
41 | index XXXXXXX..XXXXXXX 100644 | 69 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) |
42 | --- a/hw/virtio/virtio-iommu-pci.c | 70 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) |
43 | +++ b/hw/virtio/virtio-iommu-pci.c | 71 | { |
44 | @@ -XXX,XX +XXX,XX @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) | 72 | switch (extract32(insn, 25, 7)) { |
45 | VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); | 73 | - case 0x1a: case 0x5a: /* Compare & branch (immediate) */ |
46 | 74 | - disas_comp_b_imm(s, insn); | |
47 | if (!qdev_get_machine_hotplug_handler(DEVICE(vpci_dev))) { | 75 | - break; |
48 | - MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); | 76 | case 0x1b: case 0x5b: /* Test & branch (immediate) */ |
49 | - | 77 | disas_test_b_imm(s, insn); |
50 | - error_setg(errp, | 78 | break; |
51 | - "%s machine fails to create iommu-map device tree bindings", | ||
52 | - mc->name); | ||
53 | - error_append_hint(errp, | ||
54 | - "Check your machine implements a hotplug handler " | ||
55 | - "for the virtio-iommu-pci device\n"); | ||
56 | - error_append_hint(errp, "Check the guest is booted without FW or with " | ||
57 | - "-no-acpi\n"); | ||
58 | + error_setg(errp, "Check your machine implements a hotplug handler " | ||
59 | + "for the virtio-iommu-pci device"); | ||
60 | return; | ||
61 | } | ||
62 | for (int i = 0; i < s->nb_reserved_regions; i++) { | ||
63 | -- | 79 | -- |
64 | 2.25.1 | 80 | 2.34.1 |
65 | |||
66 | diff view generated by jsdifflib |
1 | The qemu-common.h header is not supposed to be included from any | 1 | Convert the test-and-branch-immediate insns TBZ and TBNZ |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | 2 | to decodetree. |
3 | the start of it). | ||
4 | |||
5 | Nothing actually relies on target/rx/cpu.h including it, so we can | ||
6 | just drop the include. | ||
7 | 3 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Message-id: 20230512144106.3608981-16-peter.maydell@linaro.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 | ||
14 | --- | 7 | --- |
15 | target/rx/cpu.h | 1 - | 8 | target/arm/tcg/a64.decode | 6 ++++++ |
16 | 1 file changed, 1 deletion(-) | 9 | target/arm/tcg/translate-a64.c | 25 +++++-------------------- |
10 | 2 files changed, 11 insertions(+), 20 deletions(-) | ||
17 | 11 | ||
18 | diff --git a/target/rx/cpu.h b/target/rx/cpu.h | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/rx/cpu.h | 14 | --- a/target/arm/tcg/a64.decode |
21 | +++ b/target/rx/cpu.h | 15 | +++ b/target/arm/tcg/a64.decode |
22 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ BL 1 00101 .......................... @branch |
23 | #define RX_CPU_H | 17 | &cbz rt imm sf nz |
24 | 18 | ||
25 | #include "qemu/bitops.h" | 19 | CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=%imm19 |
26 | -#include "qemu-common.h" | 20 | + |
27 | #include "hw/registerfields.h" | 21 | +%imm14 5:s14 !function=times_4 |
28 | #include "cpu-qom.h" | 22 | +%imm31_19 31:1 19:5 |
29 | 23 | +&tbz rt imm nz bitpos | |
24 | + | ||
25 | +TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=%imm14 bitpos=%imm31_19 | ||
26 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/tcg/translate-a64.c | ||
29 | +++ b/target/arm/tcg/translate-a64.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_CBZ(DisasContext *s, arg_cbz *a) | ||
31 | return true; | ||
32 | } | ||
33 | |||
34 | -/* Test and branch (immediate) | ||
35 | - * 31 30 25 24 23 19 18 5 4 0 | ||
36 | - * +----+-------------+----+-------+-------------+------+ | ||
37 | - * | b5 | 0 1 1 0 1 1 | op | b40 | imm14 | Rt | | ||
38 | - * +----+-------------+----+-------+-------------+------+ | ||
39 | - */ | ||
40 | -static void disas_test_b_imm(DisasContext *s, uint32_t insn) | ||
41 | +static bool trans_TBZ(DisasContext *s, arg_tbz *a) | ||
42 | { | ||
43 | - unsigned int bit_pos, op, rt; | ||
44 | - int64_t diff; | ||
45 | DisasLabel match; | ||
46 | TCGv_i64 tcg_cmp; | ||
47 | |||
48 | - bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); | ||
49 | - op = extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ | ||
50 | - diff = sextract32(insn, 5, 14) * 4; | ||
51 | - rt = extract32(insn, 0, 5); | ||
52 | - | ||
53 | tcg_cmp = tcg_temp_new_i64(); | ||
54 | - tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos)); | ||
55 | + tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, a->rt), 1ULL << a->bitpos); | ||
56 | |||
57 | reset_btype(s); | ||
58 | |||
59 | match = gen_disas_label(s); | ||
60 | - tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | ||
61 | + tcg_gen_brcondi_i64(a->nz ? TCG_COND_NE : TCG_COND_EQ, | ||
62 | tcg_cmp, 0, match.label); | ||
63 | gen_goto_tb(s, 0, 4); | ||
64 | set_disas_label(s, match); | ||
65 | - gen_goto_tb(s, 1, diff); | ||
66 | + gen_goto_tb(s, 1, a->imm); | ||
67 | + return true; | ||
68 | } | ||
69 | |||
70 | /* Conditional branch (immediate) | ||
71 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
72 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
73 | { | ||
74 | switch (extract32(insn, 25, 7)) { | ||
75 | - case 0x1b: case 0x5b: /* Test & branch (immediate) */ | ||
76 | - disas_test_b_imm(s, insn); | ||
77 | - break; | ||
78 | case 0x2a: /* Conditional branch (immediate) */ | ||
79 | disas_cond_b_imm(s, insn); | ||
80 | break; | ||
30 | -- | 81 | -- |
31 | 2.25.1 | 82 | 2.34.1 |
32 | |||
33 | diff view generated by jsdifflib |
1 | The qemu-common.h header is not supposed to be included from any | 1 | Convert the immediate conditional branch insn B.cond to |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | 2 | decodetree. |
3 | the start of it). | ||
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 | 3 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Message-id: 20230512144106.3608981-17-peter.maydell@linaro.org |
12 | Message-id: 20211129200510.1233037-2-peter.maydell@linaro.org | ||
13 | --- | 7 | --- |
14 | include/hw/i386/microvm.h | 1 - | 8 | target/arm/tcg/a64.decode | 2 ++ |
15 | include/hw/i386/x86.h | 1 - | 9 | target/arm/tcg/translate-a64.c | 30 ++++++------------------------ |
16 | 2 files changed, 2 deletions(-) | 10 | 2 files changed, 8 insertions(+), 24 deletions(-) |
17 | 11 | ||
18 | diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/i386/microvm.h | 14 | --- a/target/arm/tcg/a64.decode |
21 | +++ b/include/hw/i386/microvm.h | 15 | +++ b/target/arm/tcg/a64.decode |
22 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=%imm19 |
23 | #ifndef HW_I386_MICROVM_H | 17 | &tbz rt imm nz bitpos |
24 | #define HW_I386_MICROVM_H | 18 | |
25 | 19 | TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=%imm14 bitpos=%imm31_19 | |
26 | -#include "qemu-common.h" | 20 | + |
27 | #include "exec/hwaddr.h" | 21 | +B_cond 0101010 0 ................... 0 cond:4 imm=%imm19 |
28 | #include "qemu/notify.h" | 22 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
29 | |||
30 | diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/include/hw/i386/x86.h | 24 | --- a/target/arm/tcg/translate-a64.c |
33 | +++ b/include/hw/i386/x86.h | 25 | +++ b/target/arm/tcg/translate-a64.c |
34 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ static bool trans_TBZ(DisasContext *s, arg_tbz *a) |
35 | #ifndef HW_I386_X86_H | 27 | return true; |
36 | #define HW_I386_X86_H | 28 | } |
37 | 29 | ||
38 | -#include "qemu-common.h" | 30 | -/* Conditional branch (immediate) |
39 | #include "exec/hwaddr.h" | 31 | - * 31 25 24 23 5 4 3 0 |
40 | #include "qemu/notify.h" | 32 | - * +---------------+----+---------------------+----+------+ |
41 | 33 | - * | 0 1 0 1 0 1 0 | o1 | imm19 | o0 | cond | | |
34 | - * +---------------+----+---------------------+----+------+ | ||
35 | - */ | ||
36 | -static void disas_cond_b_imm(DisasContext *s, uint32_t insn) | ||
37 | +static bool trans_B_cond(DisasContext *s, arg_B_cond *a) | ||
38 | { | ||
39 | - unsigned int cond; | ||
40 | - int64_t diff; | ||
41 | - | ||
42 | - if ((insn & (1 << 4)) || (insn & (1 << 24))) { | ||
43 | - unallocated_encoding(s); | ||
44 | - return; | ||
45 | - } | ||
46 | - diff = sextract32(insn, 5, 19) * 4; | ||
47 | - cond = extract32(insn, 0, 4); | ||
48 | - | ||
49 | reset_btype(s); | ||
50 | - if (cond < 0x0e) { | ||
51 | + if (a->cond < 0x0e) { | ||
52 | /* genuinely conditional branches */ | ||
53 | DisasLabel match = gen_disas_label(s); | ||
54 | - arm_gen_test_cc(cond, match.label); | ||
55 | + arm_gen_test_cc(a->cond, match.label); | ||
56 | gen_goto_tb(s, 0, 4); | ||
57 | set_disas_label(s, match); | ||
58 | - gen_goto_tb(s, 1, diff); | ||
59 | + gen_goto_tb(s, 1, a->imm); | ||
60 | } else { | ||
61 | /* 0xe and 0xf are both "always" conditions */ | ||
62 | - gen_goto_tb(s, 0, diff); | ||
63 | + gen_goto_tb(s, 0, a->imm); | ||
64 | } | ||
65 | + return true; | ||
66 | } | ||
67 | |||
68 | /* HINT instruction group, including various allocated HINTs */ | ||
69 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
70 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
71 | { | ||
72 | switch (extract32(insn, 25, 7)) { | ||
73 | - case 0x2a: /* Conditional branch (immediate) */ | ||
74 | - disas_cond_b_imm(s, insn); | ||
75 | - break; | ||
76 | case 0x6a: /* Exception generation / System */ | ||
77 | if (insn & (1 << 24)) { | ||
78 | if (extract32(insn, 22, 2) == 0) { | ||
42 | -- | 79 | -- |
43 | 2.25.1 | 80 | 2.34.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | Convert the simple (non-pointer-auth) BR, BLR and RET insns |
---|---|---|---|
2 | to decodetree. | ||
2 | 3 | ||
3 | This is the latest URL for the OpenBMC CI. The old URL still works, but | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | redirects. | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20230512144106.3608981-18-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/tcg/a64.decode | 5 ++++ | ||
9 | target/arm/tcg/translate-a64.c | 55 ++++++++++++++++++++++++++++++---- | ||
10 | 2 files changed, 54 insertions(+), 6 deletions(-) | ||
5 | 11 | ||
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
7 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
8 | Message-id: 20211117065752.330632-3-joel@jms.id.au | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | docs/system/arm/aspeed.rst | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | 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/docs/system/arm/aspeed.rst | 14 | --- a/target/arm/tcg/a64.decode |
17 | +++ b/docs/system/arm/aspeed.rst | 15 | +++ b/target/arm/tcg/a64.decode |
18 | @@ -XXX,XX +XXX,XX @@ The Aspeed machines can be started using the ``-kernel`` option to | 16 | @@ -XXX,XX +XXX,XX @@ |
19 | load a Linux kernel or from a firmware. Images can be downloaded from | 17 | # This file is processed by scripts/decodetree.py |
20 | the OpenBMC jenkins : | 18 | # |
21 | 19 | ||
22 | - https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/distro=ubuntu,label=docker-builder | 20 | +&r rn |
23 | + https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/ | 21 | &ri rd imm |
24 | 22 | &rri_sf rd rn imm sf | |
25 | or directly from the OpenBMC GitHub release repository : | 23 | &i imm |
26 | 24 | @@ -XXX,XX +XXX,XX @@ CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=%imm19 | |
25 | TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=%imm14 bitpos=%imm31_19 | ||
26 | |||
27 | B_cond 0101010 0 ................... 0 cond:4 imm=%imm19 | ||
28 | + | ||
29 | +BR 1101011 0000 11111 000000 rn:5 00000 &r | ||
30 | +BLR 1101011 0001 11111 000000 rn:5 00000 &r | ||
31 | +RET 1101011 0010 11111 000000 rn:5 00000 &r | ||
32 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/tcg/translate-a64.c | ||
35 | +++ b/target/arm/tcg/translate-a64.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_B_cond(DisasContext *s, arg_B_cond *a) | ||
37 | return true; | ||
38 | } | ||
39 | |||
40 | +static void set_btype_for_br(DisasContext *s, int rn) | ||
41 | +{ | ||
42 | + if (dc_isar_feature(aa64_bti, s)) { | ||
43 | + /* BR to {x16,x17} or !guard -> 1, else 3. */ | ||
44 | + set_btype(s, rn == 16 || rn == 17 || !s->guarded_page ? 1 : 3); | ||
45 | + } | ||
46 | +} | ||
47 | + | ||
48 | +static void set_btype_for_blr(DisasContext *s) | ||
49 | +{ | ||
50 | + if (dc_isar_feature(aa64_bti, s)) { | ||
51 | + /* BLR sets BTYPE to 2, regardless of source guarded page. */ | ||
52 | + set_btype(s, 2); | ||
53 | + } | ||
54 | +} | ||
55 | + | ||
56 | +static bool trans_BR(DisasContext *s, arg_r *a) | ||
57 | +{ | ||
58 | + gen_a64_set_pc(s, cpu_reg(s, a->rn)); | ||
59 | + set_btype_for_br(s, a->rn); | ||
60 | + s->base.is_jmp = DISAS_JUMP; | ||
61 | + return true; | ||
62 | +} | ||
63 | + | ||
64 | +static bool trans_BLR(DisasContext *s, arg_r *a) | ||
65 | +{ | ||
66 | + TCGv_i64 dst = cpu_reg(s, a->rn); | ||
67 | + TCGv_i64 lr = cpu_reg(s, 30); | ||
68 | + if (dst == lr) { | ||
69 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
70 | + tcg_gen_mov_i64(tmp, dst); | ||
71 | + dst = tmp; | ||
72 | + } | ||
73 | + gen_pc_plus_diff(s, lr, curr_insn_len(s)); | ||
74 | + gen_a64_set_pc(s, dst); | ||
75 | + set_btype_for_blr(s); | ||
76 | + s->base.is_jmp = DISAS_JUMP; | ||
77 | + return true; | ||
78 | +} | ||
79 | + | ||
80 | +static bool trans_RET(DisasContext *s, arg_r *a) | ||
81 | +{ | ||
82 | + gen_a64_set_pc(s, cpu_reg(s, a->rn)); | ||
83 | + s->base.is_jmp = DISAS_JUMP; | ||
84 | + return true; | ||
85 | +} | ||
86 | + | ||
87 | /* HINT instruction group, including various allocated HINTs */ | ||
88 | static void handle_hint(DisasContext *s, uint32_t insn, | ||
89 | unsigned int op1, unsigned int op2, unsigned int crm) | ||
90 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
91 | btype_mod = opc; | ||
92 | switch (op3) { | ||
93 | case 0: | ||
94 | - /* BR, BLR, RET */ | ||
95 | - if (op4 != 0) { | ||
96 | - goto do_unallocated; | ||
97 | - } | ||
98 | - dst = cpu_reg(s, rn); | ||
99 | - break; | ||
100 | + /* BR, BLR, RET : handled in decodetree */ | ||
101 | + goto do_unallocated; | ||
102 | |||
103 | case 2: | ||
104 | case 3: | ||
27 | -- | 105 | -- |
28 | 2.25.1 | 106 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | A common use case for the ASPEED machine is to boot a Linux kernel. | ||
4 | Provide a full example command line. | ||
5 | |||
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
8 | Message-id: 20211117065752.330632-4-joel@jms.id.au | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | docs/system/arm/aspeed.rst | 15 ++++++++++++--- | ||
12 | 1 file changed, 12 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/docs/system/arm/aspeed.rst | ||
17 | +++ b/docs/system/arm/aspeed.rst | ||
18 | @@ -XXX,XX +XXX,XX @@ Missing devices | ||
19 | Boot options | ||
20 | ------------ | ||
21 | |||
22 | -The Aspeed machines can be started using the ``-kernel`` option to | ||
23 | -load a Linux kernel or from a firmware. Images can be downloaded from | ||
24 | -the OpenBMC jenkins : | ||
25 | +The Aspeed machines can be started using the ``-kernel`` and ``-dtb`` options | ||
26 | +to load a Linux kernel or from a firmware. Images can be downloaded from the | ||
27 | +OpenBMC jenkins : | ||
28 | |||
29 | https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/ | ||
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 | ||
47 | -- | ||
48 | 2.25.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Olivier Hériveaux <olivier.heriveaux@ledger.fr> | ||
2 | 1 | ||
3 | Fix issue where the data register may be overwritten by next character | ||
4 | reception before being read and returned. | ||
5 | |||
6 | Signed-off-by: Olivier Hériveaux <olivier.heriveaux@ledger.fr> | ||
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 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/char/stm32f2xx_usart.c | 3 ++- | ||
13 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/char/stm32f2xx_usart.c | ||
18 | +++ b/hw/char/stm32f2xx_usart.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr, | ||
20 | return retvalue; | ||
21 | case USART_DR: | ||
22 | DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr); | ||
23 | + retvalue = s->usart_dr & 0x3FF; | ||
24 | s->usart_sr &= ~USART_SR_RXNE; | ||
25 | qemu_chr_fe_accept_input(&s->chr); | ||
26 | qemu_set_irq(s->irq, 0); | ||
27 | - return s->usart_dr & 0x3FF; | ||
28 | + return retvalue; | ||
29 | case USART_BRR: | ||
30 | return s->usart_brr; | ||
31 | case USART_CR1: | ||
32 | -- | ||
33 | 2.25.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | The TYPE_ARM_GICV3 device is an emulated one. When using | ||
4 | KVM, it is recommended to use the TYPE_KVM_ARM_GICV3 device | ||
5 | (which uses in-kernel support). | ||
6 | |||
7 | When using --with-devices-FOO, it is possible to build a | ||
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> | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Message-id: 20211115223619.2599282-3-philmd@redhat.com | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | hw/intc/arm_gicv3.c | 2 +- | ||
22 | hw/intc/Kconfig | 5 +++++ | ||
23 | hw/intc/meson.build | 10 ++++++---- | ||
24 | 3 files changed, 12 insertions(+), 5 deletions(-) | ||
25 | |||
26 | diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/intc/arm_gicv3.c | ||
29 | +++ b/hw/intc/arm_gicv3.c | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | /* | ||
32 | - * ARM Generic Interrupt Controller v3 | ||
33 | + * ARM Generic Interrupt Controller v3 (emulation) | ||
34 | * | ||
35 | * Copyright (c) 2015 Huawei. | ||
36 | * Copyright (c) 2016 Linaro Limited | ||
37 | diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/intc/Kconfig | ||
40 | +++ b/hw/intc/Kconfig | ||
41 | @@ -XXX,XX +XXX,XX @@ config APIC | ||
42 | select MSI_NONBROKEN | ||
43 | select I8259 | ||
44 | |||
45 | +config ARM_GIC_TCG | ||
46 | + bool | ||
47 | + default y | ||
48 | + depends on ARM_GIC && TCG | ||
49 | + | ||
50 | config ARM_GIC_KVM | ||
51 | bool | ||
52 | default y | ||
53 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/intc/meson.build | ||
56 | +++ b/hw/intc/meson.build | ||
57 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARM_GIC', if_true: files( | ||
58 | 'arm_gic.c', | ||
59 | 'arm_gic_common.c', | ||
60 | 'arm_gicv2m.c', | ||
61 | - 'arm_gicv3.c', | ||
62 | 'arm_gicv3_common.c', | ||
63 | - 'arm_gicv3_dist.c', | ||
64 | 'arm_gicv3_its_common.c', | ||
65 | - 'arm_gicv3_redist.c', | ||
66 | +)) | ||
67 | +softmmu_ss.add(when: 'CONFIG_ARM_GIC_TCG', if_true: files( | ||
68 | + 'arm_gicv3.c', | ||
69 | + 'arm_gicv3_dist.c', | ||
70 | 'arm_gicv3_its.c', | ||
71 | + 'arm_gicv3_redist.c', | ||
72 | )) | ||
73 | softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_pic.c')) | ||
74 | softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true: files('heathrow_pic.c')) | ||
75 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-pmu-iomod-in | ||
76 | specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) | ||
77 | specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) | ||
78 | specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) | ||
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')) | ||
84 | -- | ||
85 | 2.25.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the single-register pointer-authentication variants of BR, |
---|---|---|---|
2 | BLR, RET to decodetree. (BRAA/BLRAA are in a different branch of | ||
3 | the legacy decoder and will be dealt with in the next commit.) | ||
2 | 4 | ||
3 | Add expected blobs of the VIOT and DSDT table for the VIOT test on the | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | q35 machine. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20230512144106.3608981-19-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/tcg/a64.decode | 7 ++ | ||
10 | target/arm/tcg/translate-a64.c | 132 +++++++++++++++++++-------------- | ||
11 | 2 files changed, 84 insertions(+), 55 deletions(-) | ||
5 | 12 | ||
6 | Since the test instantiates a virtio device and two PCIe expander | 13 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
7 | bridges, DSDT.viot has more blocks than the base DSDT. | 14 | index XXXXXXX..XXXXXXX 100644 |
8 | 15 | --- a/target/arm/tcg/a64.decode | |
9 | The VIOT table generated for the q35 test is: | 16 | +++ b/target/arm/tcg/a64.decode |
10 | 17 | @@ -XXX,XX +XXX,XX @@ B_cond 0101010 0 ................... 0 cond:4 imm=%imm19 | |
11 | [000h 0000 4] Signature : "VIOT" [Virtual I/O Translation Table] | 18 | BR 1101011 0000 11111 000000 rn:5 00000 &r |
12 | [004h 0004 4] Table Length : 00000070 | 19 | BLR 1101011 0001 11111 000000 rn:5 00000 &r |
13 | [008h 0008 1] Revision : 00 | 20 | RET 1101011 0010 11111 000000 rn:5 00000 &r |
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 | + | 21 | + |
102 | + If ((CDW3 != Local0)) | 22 | +&braz rn m |
103 | + { | 23 | +BRAZ 1101011 0000 11111 00001 m:1 rn:5 11111 &braz # BRAAZ, BRABZ |
104 | + CDW1 |= 0x10 | 24 | +BLRAZ 1101011 0001 11111 00001 m:1 rn:5 11111 &braz # BLRAAZ, BLRABZ |
105 | + } | ||
106 | + | 25 | + |
107 | + CDW3 = Local0 | 26 | +&reta m |
108 | + } | 27 | +RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, RETAB |
109 | + Else | 28 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
110 | + { | 29 | index XXXXXXX..XXXXXXX 100644 |
111 | + CDW1 |= 0x04 | 30 | --- a/target/arm/tcg/translate-a64.c |
112 | + } | 31 | +++ b/target/arm/tcg/translate-a64.c |
113 | + | 32 | @@ -XXX,XX +XXX,XX @@ static bool trans_RET(DisasContext *s, arg_r *a) |
114 | + Return (Arg3) | 33 | return true; |
115 | + } | 34 | } |
116 | + | 35 | |
117 | + Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table | 36 | +static TCGv_i64 auth_branch_target(DisasContext *s, TCGv_i64 dst, |
118 | + { | 37 | + TCGv_i64 modifier, bool use_key_a) |
119 | + Local0 = Package (0x80){} | 38 | +{ |
120 | + Local1 = Zero | 39 | + TCGv_i64 truedst; |
121 | + While ((Local1 < 0x80)) | 40 | + /* |
122 | + { | 41 | + * Return the branch target for a BRAA/RETA/etc, which is either |
123 | + Local2 = (Local1 >> 0x02) | 42 | + * just the destination dst, or that value with the pauth check |
124 | + Local3 = ((Local1 + Local2) & 0x03) | 43 | + * done and the code removed from the high bits. |
125 | + If ((Local3 == Zero)) | 44 | + */ |
126 | + { | 45 | + if (!s->pauth_active) { |
127 | + Local4 = Package (0x04) | 46 | + return dst; |
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 | + } | 47 | + } |
190 | + | 48 | + |
191 | + Scope (\_SB) | 49 | + truedst = tcg_temp_new_i64(); |
192 | + { | 50 | + if (use_key_a) { |
193 | + Device (PC20) | 51 | + gen_helper_autia(truedst, cpu_env, dst, modifier); |
194 | + { | 52 | + } else { |
195 | + Name (_UID, 0x20) // _UID: Unique ID | 53 | + gen_helper_autib(truedst, cpu_env, dst, modifier); |
196 | + Name (_BBN, 0x20) // _BBN: BIOS Bus Number | 54 | + } |
197 | + Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID | 55 | + return truedst; |
198 | + Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID | 56 | +} |
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 | + | 57 | + |
213 | + If ((CDW3 != Local0)) | 58 | +static bool trans_BRAZ(DisasContext *s, arg_braz *a) |
214 | + { | 59 | +{ |
215 | + CDW1 |= 0x10 | 60 | + TCGv_i64 dst; |
216 | + } | ||
217 | + | 61 | + |
218 | + CDW3 = Local0 | 62 | + if (!dc_isar_feature(aa64_pauth, s)) { |
219 | + } | 63 | + return false; |
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 | + } | 64 | + } |
301 | + | 65 | + |
302 | + Scope (\_SB) | 66 | + dst = auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), !a->m); |
303 | + { | 67 | + gen_a64_set_pc(s, dst); |
304 | + Device (PC10) | 68 | + set_btype_for_br(s, a->rn); |
305 | + { | 69 | + s->base.is_jmp = DISAS_JUMP; |
306 | + Name (_UID, 0x10) // _UID: Unique ID | 70 | + return true; |
307 | + Name (_BBN, 0x10) // _BBN: BIOS Bus Number | 71 | +} |
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 | + | 72 | + |
324 | + If ((CDW3 != Local0)) | 73 | +static bool trans_BLRAZ(DisasContext *s, arg_braz *a) |
325 | + { | 74 | +{ |
326 | + CDW1 |= 0x10 | 75 | + TCGv_i64 dst, lr; |
327 | + } | ||
328 | + | 76 | + |
329 | + CDW3 = Local0 | 77 | + if (!dc_isar_feature(aa64_pauth, s)) { |
330 | + } | 78 | + return false; |
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 | + } | 79 | + } |
412 | + | 80 | + |
413 | Scope (\_SB.PCI0) | 81 | + dst = auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), !a->m); |
414 | { | 82 | + lr = cpu_reg(s, 30); |
415 | Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | 83 | + if (dst == lr) { |
416 | @@ -XXX,XX +XXX,XX @@ | 84 | + TCGv_i64 tmp = tcg_temp_new_i64(); |
417 | WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | 85 | + tcg_gen_mov_i64(tmp, dst); |
418 | 0x0000, // Granularity | 86 | + dst = tmp; |
419 | 0x0000, // Range Minimum | 87 | + } |
420 | - 0x00FF, // Range Maximum | 88 | + gen_pc_plus_diff(s, lr, curr_insn_len(s)); |
421 | + 0x000F, // Range Maximum | 89 | + gen_a64_set_pc(s, dst); |
422 | 0x0000, // Translation Offset | 90 | + set_btype_for_blr(s); |
423 | - 0x0100, // Length | 91 | + s->base.is_jmp = DISAS_JUMP; |
424 | + 0x0010, // Length | 92 | + return true; |
425 | ,, ) | 93 | +} |
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 | + | 94 | + |
437 | + Device (S18) | 95 | +static bool trans_RETA(DisasContext *s, arg_reta *a) |
438 | + { | 96 | +{ |
439 | + Name (_ADR, 0x00030000) // _ADR: Address | 97 | + TCGv_i64 dst; |
440 | + } | ||
441 | + | 98 | + |
442 | + Device (S20) | 99 | + dst = auth_branch_target(s, cpu_reg(s, 30), cpu_X[31], !a->m); |
443 | + { | 100 | + gen_a64_set_pc(s, dst); |
444 | + Name (_ADR, 0x00040000) // _ADR: Address | 101 | + s->base.is_jmp = DISAS_JUMP; |
445 | + } | 102 | + return true; |
103 | +} | ||
446 | + | 104 | + |
447 | + Device (S28) | 105 | /* HINT instruction group, including various allocated HINTs */ |
448 | + { | 106 | static void handle_hint(DisasContext *s, uint32_t insn, |
449 | + Name (_ADR, 0x00050000) // _ADR: Address | 107 | unsigned int op1, unsigned int op2, unsigned int crm) |
450 | + } | 108 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) |
451 | + | 109 | } |
452 | Method (PCNT, 0, NotSerialized) | 110 | |
453 | { | 111 | switch (opc) { |
454 | } | 112 | - case 0: /* BR */ |
455 | 113 | - case 1: /* BLR */ | |
456 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 114 | - case 2: /* RET */ |
457 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | 115 | - btype_mod = opc; |
458 | Message-id: 20211210170415.583179-8-jean-philippe@linaro.org | 116 | - switch (op3) { |
459 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 117 | - case 0: |
460 | --- | 118 | - /* BR, BLR, RET : handled in decodetree */ |
461 | tests/qtest/bios-tables-test-allowed-diff.h | 2 -- | 119 | - goto do_unallocated; |
462 | tests/data/acpi/q35/DSDT.viot | Bin 0 -> 9398 bytes | 120 | - |
463 | tests/data/acpi/q35/VIOT.viot | Bin 0 -> 112 bytes | 121 | - case 2: |
464 | 3 files changed, 2 deletions(-) | 122 | - case 3: |
465 | 123 | - if (!dc_isar_feature(aa64_pauth, s)) { | |
466 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | 124 | - goto do_unallocated; |
467 | index XXXXXXX..XXXXXXX 100644 | 125 | - } |
468 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | 126 | - if (opc == 2) { |
469 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | 127 | - /* RETAA, RETAB */ |
470 | @@ -XXX,XX +XXX,XX @@ | 128 | - if (rn != 0x1f || op4 != 0x1f) { |
471 | /* List of comma-separated changed AML files to ignore */ | 129 | - goto do_unallocated; |
472 | "tests/data/acpi/virt/VIOT", | 130 | - } |
473 | -"tests/data/acpi/q35/DSDT.viot", | 131 | - rn = 30; |
474 | -"tests/data/acpi/q35/VIOT.viot", | 132 | - modifier = cpu_X[31]; |
475 | diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot | 133 | - } else { |
476 | index XXXXXXX..XXXXXXX 100644 | 134 | - /* BRAAZ, BRABZ, BLRAAZ, BLRABZ */ |
477 | GIT binary patch | 135 | - if (op4 != 0x1f) { |
478 | literal 9398 | 136 | - goto do_unallocated; |
479 | zcmeHNO>7&-8J*>iv|O&FB}G~Oi$yp||57BBoWHhc5OS9yDTx$CQgH$r;8Idr*-4Q_ | 137 | - } |
480 | z5(9Az1F`}niVsB-)<KW7p`g9Br(A2Gm-gmc1N78GFS!;)e2V(MnH_0{q<{#yMgn&C | 138 | - modifier = tcg_constant_i64(0); |
481 | zn|*J-d9yqFhO_H6z19~`FlPL*u<DkZ*}|)JH;X@mF-FI<cPg<fti9tEN*yB^i5czN | 139 | - } |
482 | zNq&q?!OZ;BE3B7{KWzJ-`Tn~f`9?Qj8~2^N8{Oc8J%57{==w%rS#;nOCp*nTr@iZ1 | 140 | - if (s->pauth_active) { |
483 | zb+?i;JLQUJ=O0?8*>S~D)a>NF1~WVB6^~_B#yhJ`H+JU@=6aXs`?Yv)J2h=N?drcS | 141 | - dst = tcg_temp_new_i64(); |
484 | zeLZ*n<<Bm^n}6`jfBx#u8&(W}1?)}iF9o#mZ~E2+zwdn7yK3AbIzKnxpZ>JRPm3~# | 142 | - if (op3 == 2) { |
485 | z&ICS{+_OayRW-l=Mtk=~uaS3o8z<_udd|(wqg`&JnVPfCe>BUOO`Su3e>pff_^UW% | 143 | - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); |
486 | z&JE^NO`)=Amg~iqRB1pPscP?(>#ZuY8GHCmlEvD$9g3%4Db~Dfz2SATnddvrR-Oe^ | 144 | - } else { |
487 | z;s;dJec!hnzi)ri^I6YN9vtkm{^TdUF8h7gX8-<Qe4p)GQ=)AtYx2VcwdLVAEXEjG | 145 | - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); |
488 | z^Mj|UHPqkj-LsWuzQem1>F3atdZn=zv3$#RmZzSHN+6-yyU#8cJb=YDilX&sl}vNm | 146 | - } |
489 | znkgAR^O<3kj4if>{ly5fwRfMWuC5=lrlvKPX~i#654Cp}R_d*JS$9laZ$ra6)<ns8 | 147 | - } else { |
490 | zFZy28G%xP(nit&F>LDi%G<tIc=TY=gl$jSD&Uv!Yat~XR46h%rI$!}a%!|xG7u8Zn | 148 | - dst = cpu_reg(s, rn); |
491 | zeY8_|n=K>xz_v_W8VX$W-Fg-qFWcT}7MCyz{%%{ia7hZ>Law-k6NOr}VI&_48U=2l | 149 | - } |
492 | zwqDKFE8eTwwozDdms#e?x?5a|v>&JF;2_v0L~z5n%BYU^52<*cWuD4|GYUm@1+?)) | 150 | - break; |
493 | zte^45>Rz)t*<T5V#={r>@t@{%?^i#W{i=HAZ*Dc9y59Va-+#P!jrGs;u38a{fLr`N | 151 | - |
494 | zvT@rUu>DljxJ?^&Z?-?vyJn3C>3D=qux{Y*bs5|5n)Qmi$TD^Zdn4GU$ocJS2Hh-< | 152 | - default: |
495 | z`xPI^^+v0nUVdjMos8k`WGl7hA`{03ju%<lrgAHSpd^DRf-*}_#Ly0mB!LSfVgWcQ | 153 | - goto do_unallocated; |
496 | z&T$@~G9)JI=hz5m0vkrel+Xy{Oh7pkAu-V!j*W7rY(bO}Q$nMH2`FbGB&N)QaV4<4 | 154 | - } |
497 | zo)~9JXiP9=;}NPl<C@MmXG&;XFlFNrsyfFsonxFSp<}vEgsRSQP3O3#b6nSnP}ON_ | 155 | - /* BLR also needs to load return address */ |
498 | zI!#Tdsp~|j>ckUB>FI=~GokB5sOq#dotCE4(sd$KbtW~PNlj-`*NIToiD#j5J#9^= | 156 | - if (opc == 1) { |
499 | zt?NXn>YUJYPG~wObe#xQos*i*NloXZt`niEb4t@WrRki~bs|)CI+{*L)9L6s5vn>< | 157 | - TCGv_i64 lr = cpu_reg(s, 30); |
500 | zn$DD_Go|Z9sOn5>I@6lYw5}7Os&iV?Ij!lO)^#FOb!If38BJ$K*NIToIiu;E(R9w} | 158 | - if (dst == lr) { |
501 | zIuWWmPiZ<&X*y5oIuWWmF_XaEC!a&Jn$B5WCqh-{X-(&8P3LJ{Cqh-{8P3dyPr@^t | 159 | - TCGv_i64 tmp = tcg_temp_new_i64(); |
502 | zSqL9?X9Uwd3W@23*s~h*tj0X6GZCuHa~kuU#yqDp5vt7d8uPryJg+kms?5hU=3^T3 | 160 | - tcg_gen_mov_i64(tmp, dst); |
503 | zF`bD}WnSP+=`t5MQ$FJ_2&Q~+BP6E0f^%BVIW6a$o)e+SX~IDBih-7z6{O~7YTy`& | 161 | - dst = tmp; |
504 | zLjy&Cv?7QikV#>n0>>@MV8oK`Gmun34-FKdlm-J8SZSaNlnhir4-FI{S|bfqV8e)V | 162 | - } |
505 | zss<{chX#reE#g=hsKAC%sF6d-Km}BWs!kZFsFpKfpbC@>6rprQGEjt4Ck#|zITHq| | 163 | - gen_pc_plus_diff(s, lr, curr_insn_len(s)); |
506 | zK*>M_l;<P^MJRQ`Kn0dFVW0|>3{*fllMEE0)CmI>Sk8ojDo`>|0p(0GP=xY&!axO< | 164 | - } |
507 | zGhv_#lnhirIg<<&q0|Wj6<E%MfhtfkPyyvkGEjt4Ck#|zITHq|K*>M_lrzad5lWpf | 165 | - gen_a64_set_pc(s, dst); |
508 | zP=V!47^ngz0~JutBm+e#b;3XemNQ|X3X}{~Ksl2P6rt1!0~J`#gn=qhGEf2KOfpb} | 166 | - break; |
509 | zQYQ>lU^x>8szAv=1(Y+%KoLrvFi?TzOc<yFB?A>u&LjgxD0RX>1(q{mpbC@>R6seC | 167 | + case 0: |
510 | z3>2Z%2?G^a&V+#~P%=;f<xDbAgi<FARA4z12C6{GKn0XD$v_cGoiI>=<xCi;0wn_# | 168 | + case 1: |
511 | zP|hR+MJRQ`Kn0dFVW0|>3{*fllMEE0)CmI>Sk8ojDo`>|0p(0GP=rz^3{+q_69%e4 | 169 | + case 2: |
512 | z$v_2^Gs!>^N}VuJf#pmXr~)Me6;RG314Srx!axxz28u{EP=u<1B2)}iVZuNaCK;&0 | 170 | + /* |
513 | zBm-5LFi?dF167!0pbC==RAItE6($T+VUmF=Ofpb~2?JG_Fi?d_2C6X0Kouqo6p_5T | 171 | + * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ: |
514 | zFi=FeV!SiSKoR0H$dH(_Z(*Q_WZ%L-5y`$K14StNmJAdjmWs}HV4<vU_xO+1efmLq | 172 | + * handled in decodetree |
515 | zZ;W>N_U)fP6Qy6Nw5mbt9Y(#emWSi66=>tq#xoh#Ue=0qyhxi8ZOUe5y0V7VfPUhp | 173 | + */ |
516 | zwX=;ymc+i5%sg9Ja~lZ&8oAV@mHc>&CHP9v4R(jhtT?un;O4e9#pno)Xkh7OWgK&a | 174 | + goto do_unallocated; |
517 | zyj=3Iv0OuoK_;5rOr5f(Kb~ZXDBO+V`OWYo#_C08imwChQxnjdd?wZLDou8aj;$SD | 175 | |
518 | zGDYiA3<$Tu<JnHL(KPOChi#zrR32t83}naR$+ym4P_h?z_5#|cW-nw$XD_sOtE62l | 176 | case 8: /* BRAA */ |
519 | zrD3@*)NVyiklt0&yF9%+klsBey&I<Y2E<!f(E8TuJte)z(|ZHyy<^gQVfx}=`q&B5 | 177 | case 9: /* BLRAA */ |
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 | -- | 178 | -- |
559 | 2.25.1 | 179 | 2.34.1 |
560 | |||
561 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the last four BR-with-pointer-auth insns to decodetree. |
---|---|---|---|
2 | The remaining cases in the outer switch in disas_uncond_b_reg() | ||
3 | all return early rather than leaving the case statement, so we | ||
4 | can delete the now-unused code at the end of that function. | ||
2 | 5 | ||
3 | Add two test cases for VIOT, one on the q35 machine and the other on | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | virt. To test complex topologies the q35 test has two PCIe buses that | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | bypass the IOMMU (and are therefore not described by VIOT), and two | 8 | Message-id: 20230512144106.3608981-20-peter.maydell@linaro.org |
6 | buses that are translated by virtio-iommu. | 9 | --- |
10 | target/arm/tcg/a64.decode | 4 ++ | ||
11 | target/arm/tcg/translate-a64.c | 97 ++++++++++++++-------------------- | ||
12 | 2 files changed, 43 insertions(+), 58 deletions(-) | ||
7 | 13 | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 14 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
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 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | tests/qtest/bios-tables-test.c | 38 ++++++++++++++++++++++++++++++++++ | ||
15 | 1 file changed, 38 insertions(+) | ||
16 | |||
17 | diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/qtest/bios-tables-test.c | 16 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/tests/qtest/bios-tables-test.c | 17 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static void test_acpi_virt_tcg(void) | 18 | @@ -XXX,XX +XXX,XX @@ BLRAZ 1101011 0001 11111 00001 m:1 rn:5 11111 &braz # BLRAAZ, BLRABZ |
22 | free_test_data(&data); | 19 | |
20 | &reta m | ||
21 | RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, RETAB | ||
22 | + | ||
23 | +&bra rn rm m | ||
24 | +BRA 1101011 1000 11111 00001 m:1 rn:5 rm:5 &bra # BRAA, BRAB | ||
25 | +BLRA 1101011 1001 11111 00001 m:1 rn:5 rm:5 &bra # BLRAA, BLRAB | ||
26 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/tcg/translate-a64.c | ||
29 | +++ b/target/arm/tcg/translate-a64.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_RETA(DisasContext *s, arg_reta *a) | ||
31 | return true; | ||
23 | } | 32 | } |
24 | 33 | ||
25 | +static void test_acpi_q35_viot(void) | 34 | +static bool trans_BRA(DisasContext *s, arg_bra *a) |
26 | +{ | 35 | +{ |
27 | + test_data data = { | 36 | + TCGv_i64 dst; |
28 | + .machine = MACHINE_Q35, | ||
29 | + .variant = ".viot", | ||
30 | + }; | ||
31 | + | 37 | + |
32 | + /* | 38 | + if (!dc_isar_feature(aa64_pauth, s)) { |
33 | + * To keep things interesting, two buses bypass the IOMMU. | 39 | + return false; |
34 | + * VIOT should only describes the other two buses. | 40 | + } |
35 | + */ | 41 | + dst = auth_branch_target(s, cpu_reg(s,a->rn), cpu_reg_sp(s, a->rm), !a->m); |
36 | + test_acpi_one("-machine default_bus_bypass_iommu=on " | 42 | + gen_a64_set_pc(s, dst); |
37 | + "-device virtio-iommu-pci " | 43 | + set_btype_for_br(s, a->rn); |
38 | + "-device pxb-pcie,bus_nr=0x10,id=pcie.100,bus=pcie.0 " | 44 | + s->base.is_jmp = DISAS_JUMP; |
39 | + "-device pxb-pcie,bus_nr=0x20,id=pcie.200,bus=pcie.0,bypass_iommu=on " | 45 | + return true; |
40 | + "-device pxb-pcie,bus_nr=0x30,id=pcie.300,bus=pcie.0", | ||
41 | + &data); | ||
42 | + free_test_data(&data); | ||
43 | +} | 46 | +} |
44 | + | 47 | + |
45 | +static void test_acpi_virt_viot(void) | 48 | +static bool trans_BLRA(DisasContext *s, arg_bra *a) |
46 | +{ | 49 | +{ |
47 | + test_data data = { | 50 | + TCGv_i64 dst, lr; |
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 | + }; | ||
55 | + | 51 | + |
56 | + test_acpi_one("-cpu cortex-a57 " | 52 | + if (!dc_isar_feature(aa64_pauth, s)) { |
57 | + "-device virtio-iommu-pci", &data); | 53 | + return false; |
58 | + free_test_data(&data); | 54 | + } |
55 | + dst = auth_branch_target(s, cpu_reg(s, a->rn), cpu_reg_sp(s, a->rm), !a->m); | ||
56 | + lr = cpu_reg(s, 30); | ||
57 | + if (dst == lr) { | ||
58 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
59 | + tcg_gen_mov_i64(tmp, dst); | ||
60 | + dst = tmp; | ||
61 | + } | ||
62 | + gen_pc_plus_diff(s, lr, curr_insn_len(s)); | ||
63 | + gen_a64_set_pc(s, dst); | ||
64 | + set_btype_for_blr(s); | ||
65 | + s->base.is_jmp = DISAS_JUMP; | ||
66 | + return true; | ||
59 | +} | 67 | +} |
60 | + | 68 | + |
61 | static void test_oem_fields(test_data *data) | 69 | /* HINT instruction group, including various allocated HINTs */ |
70 | static void handle_hint(DisasContext *s, uint32_t insn, | ||
71 | unsigned int op1, unsigned int op2, unsigned int crm) | ||
72 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
73 | static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
62 | { | 74 | { |
63 | int i; | 75 | unsigned int opc, op2, op3, rn, op4; |
64 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | 76 | - unsigned btype_mod = 2; /* 0: BR, 1: BLR, 2: other */ |
65 | qtest_add_func("acpi/q35/kvm/xapic", test_acpi_q35_kvm_xapic); | 77 | TCGv_i64 dst; |
66 | qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar); | 78 | TCGv_i64 modifier; |
67 | } | 79 | |
68 | + qtest_add_func("acpi/q35/viot", test_acpi_q35_viot); | 80 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) |
69 | } else if (strcmp(arch, "aarch64") == 0) { | 81 | case 0: |
70 | if (has_tcg) { | 82 | case 1: |
71 | qtest_add_func("acpi/virt", test_acpi_virt_tcg); | 83 | case 2: |
72 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | 84 | + case 8: |
73 | qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp); | 85 | + case 9: |
74 | qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb); | 86 | /* |
75 | qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt); | 87 | - * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ: |
76 | + qtest_add_func("acpi/virt/viot", test_acpi_virt_viot); | 88 | - * handled in decodetree |
77 | } | 89 | + * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ, |
90 | + * BRAA, BLRAA: handled in decodetree | ||
91 | */ | ||
92 | goto do_unallocated; | ||
93 | |||
94 | - case 8: /* BRAA */ | ||
95 | - case 9: /* BLRAA */ | ||
96 | - if (!dc_isar_feature(aa64_pauth, s)) { | ||
97 | - goto do_unallocated; | ||
98 | - } | ||
99 | - if ((op3 & ~1) != 2) { | ||
100 | - goto do_unallocated; | ||
101 | - } | ||
102 | - btype_mod = opc & 1; | ||
103 | - if (s->pauth_active) { | ||
104 | - dst = tcg_temp_new_i64(); | ||
105 | - modifier = cpu_reg_sp(s, op4); | ||
106 | - if (op3 == 2) { | ||
107 | - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
108 | - } else { | ||
109 | - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
110 | - } | ||
111 | - } else { | ||
112 | - dst = cpu_reg(s, rn); | ||
113 | - } | ||
114 | - /* BLRAA also needs to load return address */ | ||
115 | - if (opc == 9) { | ||
116 | - TCGv_i64 lr = cpu_reg(s, 30); | ||
117 | - if (dst == lr) { | ||
118 | - TCGv_i64 tmp = tcg_temp_new_i64(); | ||
119 | - tcg_gen_mov_i64(tmp, dst); | ||
120 | - dst = tmp; | ||
121 | - } | ||
122 | - gen_pc_plus_diff(s, lr, curr_insn_len(s)); | ||
123 | - } | ||
124 | - gen_a64_set_pc(s, dst); | ||
125 | - break; | ||
126 | - | ||
127 | case 4: /* ERET */ | ||
128 | if (s->current_el == 0) { | ||
129 | goto do_unallocated; | ||
130 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
131 | unallocated_encoding(s); | ||
132 | return; | ||
78 | } | 133 | } |
79 | ret = g_test_run(); | 134 | - |
135 | - switch (btype_mod) { | ||
136 | - case 0: /* BR */ | ||
137 | - if (dc_isar_feature(aa64_bti, s)) { | ||
138 | - /* BR to {x16,x17} or !guard -> 1, else 3. */ | ||
139 | - set_btype(s, rn == 16 || rn == 17 || !s->guarded_page ? 1 : 3); | ||
140 | - } | ||
141 | - break; | ||
142 | - | ||
143 | - case 1: /* BLR */ | ||
144 | - if (dc_isar_feature(aa64_bti, s)) { | ||
145 | - /* BLR sets BTYPE to 2, regardless of source guarded page. */ | ||
146 | - set_btype(s, 2); | ||
147 | - } | ||
148 | - break; | ||
149 | - | ||
150 | - default: /* RET or none of the above. */ | ||
151 | - /* BTYPE will be set to 0 by normal end-of-insn processing. */ | ||
152 | - break; | ||
153 | - } | ||
154 | - | ||
155 | - s->base.is_jmp = DISAS_JUMP; | ||
156 | } | ||
157 | |||
158 | /* Branches, exception generating and system instructions */ | ||
80 | -- | 159 | -- |
81 | 2.25.1 | 160 | 2.34.1 |
82 | |||
83 | diff view generated by jsdifflib |
1 | From: Patrick Venture <venture@google.com> | 1 | Convert the exception-return insns ERET, ERETA and ERETB to |
---|---|---|---|
2 | decodetree. These were the last insns left in the legacy | ||
3 | decoder function disas_uncond_reg_b(), which allows us to | ||
4 | remove it. | ||
2 | 5 | ||
3 | The rx_active boolean change to true should always trigger a try_read | 6 | The old decoder explicitly decoded the DRPS instruction, |
4 | call that flushes the queue. | 7 | only in order to call unallocated_encoding() on it, exactly |
8 | as would have happened if it hadn't decoded it. This is | ||
9 | because this insn always UNDEFs unless the CPU is in | ||
10 | halting-debug state, which we don't emulate. So we list | ||
11 | the pattern in a comment in a64.decode, but don't actively | ||
12 | decode it. | ||
5 | 13 | ||
6 | Signed-off-by: Patrick Venture <venture@google.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20211203221002.1719306-1-venture@google.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20230512144106.3608981-21-peter.maydell@linaro.org | ||
10 | --- | 17 | --- |
11 | hw/net/npcm7xx_emc.c | 18 ++++++++---------- | 18 | target/arm/tcg/a64.decode | 8 ++ |
12 | 1 file changed, 8 insertions(+), 10 deletions(-) | 19 | target/arm/tcg/translate-a64.c | 163 +++++++++++---------------------- |
20 | 2 files changed, 63 insertions(+), 108 deletions(-) | ||
13 | 21 | ||
14 | diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c | 22 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
15 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/net/npcm7xx_emc.c | 24 | --- a/target/arm/tcg/a64.decode |
17 | +++ b/hw/net/npcm7xx_emc.c | 25 | +++ b/target/arm/tcg/a64.decode |
18 | @@ -XXX,XX +XXX,XX @@ static void emc_halt_rx(NPCM7xxEMCState *emc, uint32_t mista_flag) | 26 | @@ -XXX,XX +XXX,XX @@ RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, RETAB |
19 | emc_set_mista(emc, mista_flag); | 27 | &bra rn rm m |
28 | BRA 1101011 1000 11111 00001 m:1 rn:5 rm:5 &bra # BRAA, BRAB | ||
29 | BLRA 1101011 1001 11111 00001 m:1 rn:5 rm:5 &bra # BLRAA, BLRAB | ||
30 | + | ||
31 | +ERET 1101011 0100 11111 000000 11111 00000 | ||
32 | +ERETA 1101011 0100 11111 00001 m:1 11111 11111 &reta # ERETAA, ERETAB | ||
33 | + | ||
34 | +# We don't need to decode DRPS because it always UNDEFs except when | ||
35 | +# the processor is in halting debug state (which we don't implement). | ||
36 | +# The pattern is listed here as documentation. | ||
37 | +# DRPS 1101011 0101 11111 000000 11111 00000 | ||
38 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/tcg/translate-a64.c | ||
41 | +++ b/target/arm/tcg/translate-a64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool trans_BLRA(DisasContext *s, arg_bra *a) | ||
43 | return true; | ||
20 | } | 44 | } |
21 | 45 | ||
22 | +static void emc_enable_rx_and_flush(NPCM7xxEMCState *emc) | 46 | +static bool trans_ERET(DisasContext *s, arg_ERET *a) |
23 | +{ | 47 | +{ |
24 | + emc->rx_active = true; | 48 | + TCGv_i64 dst; |
25 | + qemu_flush_queued_packets(qemu_get_queue(emc->nic)); | 49 | + |
50 | + if (s->current_el == 0) { | ||
51 | + return false; | ||
52 | + } | ||
53 | + if (s->fgt_eret) { | ||
54 | + gen_exception_insn_el(s, 0, EXCP_UDEF, 0, 2); | ||
55 | + return true; | ||
56 | + } | ||
57 | + dst = tcg_temp_new_i64(); | ||
58 | + tcg_gen_ld_i64(dst, cpu_env, | ||
59 | + offsetof(CPUARMState, elr_el[s->current_el])); | ||
60 | + | ||
61 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
62 | + gen_io_start(); | ||
63 | + } | ||
64 | + | ||
65 | + gen_helper_exception_return(cpu_env, dst); | ||
66 | + /* Must exit loop to check un-masked IRQs */ | ||
67 | + s->base.is_jmp = DISAS_EXIT; | ||
68 | + return true; | ||
26 | +} | 69 | +} |
27 | + | 70 | + |
28 | static void emc_set_next_tx_descriptor(NPCM7xxEMCState *emc, | 71 | +static bool trans_ERETA(DisasContext *s, arg_reta *a) |
29 | const NPCM7xxEMCTxDesc *tx_desc, | 72 | +{ |
30 | uint32_t desc_addr) | 73 | + TCGv_i64 dst; |
31 | @@ -XXX,XX +XXX,XX @@ static ssize_t emc_receive(NetClientState *nc, const uint8_t *buf, size_t len1) | 74 | + |
32 | return len; | 75 | + if (!dc_isar_feature(aa64_pauth, s)) { |
76 | + return false; | ||
77 | + } | ||
78 | + if (s->current_el == 0) { | ||
79 | + return false; | ||
80 | + } | ||
81 | + /* The FGT trap takes precedence over an auth trap. */ | ||
82 | + if (s->fgt_eret) { | ||
83 | + gen_exception_insn_el(s, 0, EXCP_UDEF, a->m ? 3 : 2, 2); | ||
84 | + return true; | ||
85 | + } | ||
86 | + dst = tcg_temp_new_i64(); | ||
87 | + tcg_gen_ld_i64(dst, cpu_env, | ||
88 | + offsetof(CPUARMState, elr_el[s->current_el])); | ||
89 | + | ||
90 | + dst = auth_branch_target(s, dst, cpu_X[31], !a->m); | ||
91 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
92 | + gen_io_start(); | ||
93 | + } | ||
94 | + | ||
95 | + gen_helper_exception_return(cpu_env, dst); | ||
96 | + /* Must exit loop to check un-masked IRQs */ | ||
97 | + s->base.is_jmp = DISAS_EXIT; | ||
98 | + return true; | ||
99 | +} | ||
100 | + | ||
101 | /* HINT instruction group, including various allocated HINTs */ | ||
102 | static void handle_hint(DisasContext *s, uint32_t insn, | ||
103 | unsigned int op1, unsigned int op2, unsigned int crm) | ||
104 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
105 | } | ||
33 | } | 106 | } |
34 | 107 | ||
35 | -static void emc_try_receive_next_packet(NPCM7xxEMCState *emc) | 108 | -/* Unconditional branch (register) |
109 | - * 31 25 24 21 20 16 15 10 9 5 4 0 | ||
110 | - * +---------------+-------+-------+-------+------+-------+ | ||
111 | - * | 1 1 0 1 0 1 1 | opc | op2 | op3 | Rn | op4 | | ||
112 | - * +---------------+-------+-------+-------+------+-------+ | ||
113 | - */ | ||
114 | -static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
36 | -{ | 115 | -{ |
37 | - if (emc_can_receive(qemu_get_queue(emc->nic))) { | 116 | - unsigned int opc, op2, op3, rn, op4; |
38 | - qemu_flush_queued_packets(qemu_get_queue(emc->nic)); | 117 | - TCGv_i64 dst; |
118 | - TCGv_i64 modifier; | ||
119 | - | ||
120 | - opc = extract32(insn, 21, 4); | ||
121 | - op2 = extract32(insn, 16, 5); | ||
122 | - op3 = extract32(insn, 10, 6); | ||
123 | - rn = extract32(insn, 5, 5); | ||
124 | - op4 = extract32(insn, 0, 5); | ||
125 | - | ||
126 | - if (op2 != 0x1f) { | ||
127 | - goto do_unallocated; | ||
128 | - } | ||
129 | - | ||
130 | - switch (opc) { | ||
131 | - case 0: | ||
132 | - case 1: | ||
133 | - case 2: | ||
134 | - case 8: | ||
135 | - case 9: | ||
136 | - /* | ||
137 | - * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ, | ||
138 | - * BRAA, BLRAA: handled in decodetree | ||
139 | - */ | ||
140 | - goto do_unallocated; | ||
141 | - | ||
142 | - case 4: /* ERET */ | ||
143 | - if (s->current_el == 0) { | ||
144 | - goto do_unallocated; | ||
145 | - } | ||
146 | - switch (op3) { | ||
147 | - case 0: /* ERET */ | ||
148 | - if (op4 != 0) { | ||
149 | - goto do_unallocated; | ||
150 | - } | ||
151 | - if (s->fgt_eret) { | ||
152 | - gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), 2); | ||
153 | - return; | ||
154 | - } | ||
155 | - dst = tcg_temp_new_i64(); | ||
156 | - tcg_gen_ld_i64(dst, cpu_env, | ||
157 | - offsetof(CPUARMState, elr_el[s->current_el])); | ||
158 | - break; | ||
159 | - | ||
160 | - case 2: /* ERETAA */ | ||
161 | - case 3: /* ERETAB */ | ||
162 | - if (!dc_isar_feature(aa64_pauth, s)) { | ||
163 | - goto do_unallocated; | ||
164 | - } | ||
165 | - if (rn != 0x1f || op4 != 0x1f) { | ||
166 | - goto do_unallocated; | ||
167 | - } | ||
168 | - /* The FGT trap takes precedence over an auth trap. */ | ||
169 | - if (s->fgt_eret) { | ||
170 | - gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), 2); | ||
171 | - return; | ||
172 | - } | ||
173 | - dst = tcg_temp_new_i64(); | ||
174 | - tcg_gen_ld_i64(dst, cpu_env, | ||
175 | - offsetof(CPUARMState, elr_el[s->current_el])); | ||
176 | - if (s->pauth_active) { | ||
177 | - modifier = cpu_X[31]; | ||
178 | - if (op3 == 2) { | ||
179 | - gen_helper_autia(dst, cpu_env, dst, modifier); | ||
180 | - } else { | ||
181 | - gen_helper_autib(dst, cpu_env, dst, modifier); | ||
182 | - } | ||
183 | - } | ||
184 | - break; | ||
185 | - | ||
186 | - default: | ||
187 | - goto do_unallocated; | ||
188 | - } | ||
189 | - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
190 | - gen_io_start(); | ||
191 | - } | ||
192 | - | ||
193 | - gen_helper_exception_return(cpu_env, dst); | ||
194 | - /* Must exit loop to check un-masked IRQs */ | ||
195 | - s->base.is_jmp = DISAS_EXIT; | ||
196 | - return; | ||
197 | - | ||
198 | - case 5: /* DRPS */ | ||
199 | - if (op3 != 0 || op4 != 0 || rn != 0x1f) { | ||
200 | - goto do_unallocated; | ||
201 | - } else { | ||
202 | - unallocated_encoding(s); | ||
203 | - } | ||
204 | - return; | ||
205 | - | ||
206 | - default: | ||
207 | - do_unallocated: | ||
208 | - unallocated_encoding(s); | ||
209 | - return; | ||
39 | - } | 210 | - } |
40 | -} | 211 | -} |
41 | - | 212 | - |
42 | static uint64_t npcm7xx_emc_read(void *opaque, hwaddr offset, unsigned size) | 213 | /* Branches, exception generating and system instructions */ |
214 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
43 | { | 215 | { |
44 | NPCM7xxEMCState *emc = opaque; | 216 | @@ -XXX,XX +XXX,XX @@ static void disas_b_exc_sys(DisasContext *s, uint32_t insn) |
45 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, | 217 | disas_exc(s, insn); |
46 | emc->regs[REG_MGSTA] |= REG_MGSTA_RXHA; | ||
47 | } | ||
48 | if (value & REG_MCMDR_RXON) { | ||
49 | - emc->rx_active = true; | ||
50 | + emc_enable_rx_and_flush(emc); | ||
51 | } else { | ||
52 | emc_halt_rx(emc, 0); | ||
53 | } | ||
54 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, | ||
55 | break; | ||
56 | case REG_RSDR: | ||
57 | if (emc->regs[REG_MCMDR] & REG_MCMDR_RXON) { | ||
58 | - emc->rx_active = true; | ||
59 | - emc_try_receive_next_packet(emc); | ||
60 | + emc_enable_rx_and_flush(emc); | ||
61 | } | 218 | } |
62 | break; | 219 | break; |
63 | case REG_MIIDA: | 220 | - case 0x6b: /* Unconditional branch (register) */ |
221 | - disas_uncond_b_reg(s, insn); | ||
222 | - break; | ||
223 | default: | ||
224 | unallocated_encoding(s); | ||
225 | break; | ||
64 | -- | 226 | -- |
65 | 2.25.1 | 227 | 2.34.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | In the SSE decode function gen_sse(), we combine a byte | 1 | The IMPDEF sysreg L2CTLR_EL1 found on the Cortex-A35, A53, A57, A72 |
---|---|---|---|
2 | 'b' and a value 'b1' which can be [0..3], and switch on them: | 2 | and which we (arguably dubiously) also provide in '-cpu max' has a |
3 | b |= (b1 << 8); | 3 | 2 bit field for the number of processors in the cluster. On real |
4 | switch (b) { | 4 | hardware this must be sufficient because it can only be configured |
5 | ... | 5 | with up to 4 CPUs in the cluster. However on QEMU if the board code |
6 | default: | 6 | does not explicitly configure the code into clusters with the right |
7 | unknown_op: | 7 | CPU count we default to "give the value assuming that all CPUs in |
8 | gen_unknown_opcode(env, s); | 8 | the system are in a single cluster", which might be too big to fit |
9 | return; | 9 | in the field. |
10 | } | ||
11 | 10 | ||
12 | In three cases inside this switch, we were then also checking for | 11 | Instead of just overflowing this 2-bit field, saturate to 3 (meaning |
13 | "if (b1 >= 2) { goto unknown_op; }". | 12 | "4 CPUs", so at least we don't overwrite other fields in the register. |
14 | However, this can never happen, because the 'case' values in each place | 13 | It's unlikely that any guest code really cares about the value in |
15 | are 0x0nn or 0x1nn and the switch will have directed the b1 == (2, 3) | 14 | this field; at least, if it does it probably also wants the system |
16 | cases to the default already. | 15 | to be more closely matching real hardware, i.e. not to have more |
16 | than 4 CPUs. | ||
17 | 17 | ||
18 | This check was added in commit c045af25a52e9 in 2010; the added code | 18 | This issue has been present since the L2CTLR was first added in |
19 | was unnecessary then as well, and was apparently intended only to | 19 | commit 377a44ec8f2fac5b back in 2014. It was only noticed because |
20 | ensure that we never accidentally ended up indexing off the end | 20 | Coverity complains (CID 1509227) that the shift might overflow 32 bits |
21 | of an sse_op_table with only 2 entries as a result of future bugs | 21 | and inadvertently sign extend into the top half of the 64 bit value. |
22 | in the decode logic. | ||
23 | 22 | ||
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> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 24 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
25 | Message-id: 20230512170223.3801643-2-peter.maydell@linaro.org | ||
30 | --- | 26 | --- |
31 | target/i386/tcg/translate.c | 12 +++--------- | 27 | target/arm/cortex-regs.c | 11 +++++++++-- |
32 | 1 file changed, 3 insertions(+), 9 deletions(-) | 28 | 1 file changed, 9 insertions(+), 2 deletions(-) |
33 | 29 | ||
34 | diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c | 30 | diff --git a/target/arm/cortex-regs.c b/target/arm/cortex-regs.c |
35 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/i386/tcg/translate.c | 32 | --- a/target/arm/cortex-regs.c |
37 | +++ b/target/i386/tcg/translate.c | 33 | +++ b/target/arm/cortex-regs.c |
38 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | 34 | @@ -XXX,XX +XXX,XX @@ static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
39 | case 0x171: /* shift xmm, im */ | 35 | { |
40 | case 0x172: | 36 | ARMCPU *cpu = env_archcpu(env); |
41 | case 0x173: | 37 | |
42 | - if (b1 >= 2) { | 38 | - /* Number of cores is in [25:24]; otherwise we RAZ */ |
43 | - goto unknown_op; | 39 | - return (cpu->core_count - 1) << 24; |
44 | - } | 40 | + /* |
45 | val = x86_ldub_code(env, s); | 41 | + * Number of cores is in [25:24]; otherwise we RAZ. |
46 | if (is_xmm) { | 42 | + * If the board didn't configure the CPUs into clusters, |
47 | tcg_gen_movi_tl(s->T0, val); | 43 | + * we default to "all CPUs in one cluster", which might be |
48 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | 44 | + * more than the 4 that the hardware permits and which is |
49 | offsetof(CPUX86State, mmx_t0.MMX_L(1))); | 45 | + * all you can report in this two-bit field. Saturate to |
50 | op1_offset = offsetof(CPUX86State,mmx_t0); | 46 | + * 0b11 (== 4 CPUs) rather than overflowing the field. |
51 | } | 47 | + */ |
52 | + assert(b1 < 2); | 48 | + return MIN(cpu->core_count - 1, 3) << 24; |
53 | sse_fn_epp = sse_op_table2[((b - 1) & 3) * 8 + | 49 | } |
54 | (((modrm >> 3)) & 7)][b1]; | 50 | |
55 | if (!sse_fn_epp) { | 51 | static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { |
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 | -- | 52 | -- |
81 | 2.25.1 | 53 | 2.34.1 |
82 | |||
83 | diff view generated by jsdifflib |
1 | A lot of C files in hw/arm include qemu-common.h when they don't | 1 | In the vexpress board code, we allocate a new MemoryRegion at the top |
---|---|---|---|
2 | need anything from it. Drop the include lines. | 2 | of vexpress_common_init() but only set it up and use it inside the |
3 | "if (map[VE_NORFLASHALIAS] != -1)" conditional, so we leak it if not. | ||
4 | This isn't a very interesting leak as it's a tiny amount of memory | ||
5 | once at startup, but it's easy to fix. | ||
3 | 6 | ||
4 | omap1.c, pxa2xx.c and strongarm.c retain the include because they | 7 | We could silence Coverity simply by moving the g_new() into the |
5 | use it for the prototype of qemu_get_timedate(). | 8 | if() block, but this use of g_new(MemoryRegion, 1) is a legacy from |
9 | when this board model was originally written; we wouldn't do that | ||
10 | if we wrote it today. The MemoryRegions are conceptually a part of | ||
11 | the board and must not go away until the whole board is done with | ||
12 | (at the end of the simulation), so they belong in its state struct. | ||
13 | |||
14 | This machine already has a VexpressMachineState struct that extends | ||
15 | MachineState, so statically put the MemoryRegions in there instead of | ||
16 | dynamically allocating them separately at runtime. | ||
17 | |||
18 | Spotted by Coverity (CID 1509083). | ||
6 | 19 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 22 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | 23 | Message-id: 20230512170223.3801643-3-peter.maydell@linaro.org |
11 | Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> | ||
12 | Message-id: 20211129200510.1233037-5-peter.maydell@linaro.org | ||
13 | --- | 24 | --- |
14 | hw/arm/boot.c | 1 - | 25 | hw/arm/vexpress.c | 40 ++++++++++++++++++++-------------------- |
15 | hw/arm/digic_boards.c | 1 - | 26 | 1 file changed, 20 insertions(+), 20 deletions(-) |
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(-) | ||
23 | 27 | ||
24 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/arm/boot.c | ||
27 | +++ b/hw/arm/boot.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | */ | ||
30 | |||
31 | #include "qemu/osdep.h" | ||
32 | -#include "qemu-common.h" | ||
33 | #include "qemu/datadir.h" | ||
34 | #include "qemu/error-report.h" | ||
35 | #include "qapi/error.h" | ||
36 | diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/hw/arm/digic_boards.c | ||
39 | +++ b/hw/arm/digic_boards.c | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | |||
42 | #include "qemu/osdep.h" | ||
43 | #include "qapi/error.h" | ||
44 | -#include "qemu-common.h" | ||
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 | 28 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c |
97 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
98 | --- a/hw/arm/vexpress.c | 30 | --- a/hw/arm/vexpress.c |
99 | +++ b/hw/arm/vexpress.c | 31 | +++ b/hw/arm/vexpress.c |
100 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ struct VexpressMachineClass { |
101 | 33 | ||
102 | #include "qemu/osdep.h" | 34 | struct VexpressMachineState { |
103 | #include "qapi/error.h" | 35 | MachineState parent; |
104 | -#include "qemu-common.h" | 36 | + MemoryRegion vram; |
105 | #include "qemu/datadir.h" | 37 | + MemoryRegion sram; |
106 | #include "cpu.h" | 38 | + MemoryRegion flashalias; |
107 | #include "hw/sysbus.h" | 39 | + MemoryRegion lowram; |
108 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 40 | + MemoryRegion a15sram; |
109 | index XXXXXXX..XXXXXXX 100644 | 41 | bool secure; |
110 | --- a/hw/arm/virt.c | 42 | bool virt; |
111 | +++ b/hw/arm/virt.c | 43 | }; |
112 | @@ -XXX,XX +XXX,XX @@ | 44 | @@ -XXX,XX +XXX,XX @@ struct VexpressMachineState { |
113 | */ | 45 | #define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15") |
114 | 46 | OBJECT_DECLARE_TYPE(VexpressMachineState, VexpressMachineClass, VEXPRESS_MACHINE) | |
115 | #include "qemu/osdep.h" | 47 | |
116 | -#include "qemu-common.h" | 48 | -typedef void DBoardInitFn(const VexpressMachineState *machine, |
117 | #include "qemu/datadir.h" | 49 | +typedef void DBoardInitFn(VexpressMachineState *machine, |
118 | #include "qemu/units.h" | 50 | ram_addr_t ram_size, |
119 | #include "qemu/option.h" | 51 | const char *cpu_type, |
52 | qemu_irq *pic); | ||
53 | @@ -XXX,XX +XXX,XX @@ static void init_cpus(MachineState *ms, const char *cpu_type, | ||
54 | } | ||
55 | } | ||
56 | |||
57 | -static void a9_daughterboard_init(const VexpressMachineState *vms, | ||
58 | +static void a9_daughterboard_init(VexpressMachineState *vms, | ||
59 | ram_addr_t ram_size, | ||
60 | const char *cpu_type, | ||
61 | qemu_irq *pic) | ||
62 | { | ||
63 | MachineState *machine = MACHINE(vms); | ||
64 | MemoryRegion *sysmem = get_system_memory(); | ||
65 | - MemoryRegion *lowram = g_new(MemoryRegion, 1); | ||
66 | ram_addr_t low_ram_size; | ||
67 | |||
68 | if (ram_size > 0x40000000) { | ||
69 | @@ -XXX,XX +XXX,XX @@ static void a9_daughterboard_init(const VexpressMachineState *vms, | ||
70 | * address space should in theory be remappable to various | ||
71 | * things including ROM or RAM; we always map the RAM there. | ||
72 | */ | ||
73 | - memory_region_init_alias(lowram, NULL, "vexpress.lowmem", machine->ram, | ||
74 | - 0, low_ram_size); | ||
75 | - memory_region_add_subregion(sysmem, 0x0, lowram); | ||
76 | + memory_region_init_alias(&vms->lowram, NULL, "vexpress.lowmem", | ||
77 | + machine->ram, 0, low_ram_size); | ||
78 | + memory_region_add_subregion(sysmem, 0x0, &vms->lowram); | ||
79 | memory_region_add_subregion(sysmem, 0x60000000, machine->ram); | ||
80 | |||
81 | /* 0x1e000000 A9MPCore (SCU) private memory region */ | ||
82 | @@ -XXX,XX +XXX,XX @@ static VEDBoardInfo a9_daughterboard = { | ||
83 | .init = a9_daughterboard_init, | ||
84 | }; | ||
85 | |||
86 | -static void a15_daughterboard_init(const VexpressMachineState *vms, | ||
87 | +static void a15_daughterboard_init(VexpressMachineState *vms, | ||
88 | ram_addr_t ram_size, | ||
89 | const char *cpu_type, | ||
90 | qemu_irq *pic) | ||
91 | { | ||
92 | MachineState *machine = MACHINE(vms); | ||
93 | MemoryRegion *sysmem = get_system_memory(); | ||
94 | - MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
95 | |||
96 | { | ||
97 | /* We have to use a separate 64 bit variable here to avoid the gcc | ||
98 | @@ -XXX,XX +XXX,XX @@ static void a15_daughterboard_init(const VexpressMachineState *vms, | ||
99 | /* 0x2b060000: SP805 watchdog: not modelled */ | ||
100 | /* 0x2b0a0000: PL341 dynamic memory controller: not modelled */ | ||
101 | /* 0x2e000000: system SRAM */ | ||
102 | - memory_region_init_ram(sram, NULL, "vexpress.a15sram", 0x10000, | ||
103 | + memory_region_init_ram(&vms->a15sram, NULL, "vexpress.a15sram", 0x10000, | ||
104 | &error_fatal); | ||
105 | - memory_region_add_subregion(sysmem, 0x2e000000, sram); | ||
106 | + memory_region_add_subregion(sysmem, 0x2e000000, &vms->a15sram); | ||
107 | |||
108 | /* 0x7ffb0000: DMA330 DMA controller: not modelled */ | ||
109 | /* 0x7ffd0000: PL354 static memory controller: not modelled */ | ||
110 | @@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine) | ||
111 | I2CBus *i2c; | ||
112 | ram_addr_t vram_size, sram_size; | ||
113 | MemoryRegion *sysmem = get_system_memory(); | ||
114 | - MemoryRegion *vram = g_new(MemoryRegion, 1); | ||
115 | - MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
116 | - MemoryRegion *flashalias = g_new(MemoryRegion, 1); | ||
117 | - MemoryRegion *flash0mem; | ||
118 | const hwaddr *map = daughterboard->motherboard_map; | ||
119 | int i; | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine) | ||
122 | |||
123 | if (map[VE_NORFLASHALIAS] != -1) { | ||
124 | /* Map flash 0 as an alias into low memory */ | ||
125 | + MemoryRegion *flash0mem; | ||
126 | flash0mem = sysbus_mmio_get_region(SYS_BUS_DEVICE(pflash0), 0); | ||
127 | - memory_region_init_alias(flashalias, NULL, "vexpress.flashalias", | ||
128 | + memory_region_init_alias(&vms->flashalias, NULL, "vexpress.flashalias", | ||
129 | flash0mem, 0, VEXPRESS_FLASH_SIZE); | ||
130 | - memory_region_add_subregion(sysmem, map[VE_NORFLASHALIAS], flashalias); | ||
131 | + memory_region_add_subregion(sysmem, map[VE_NORFLASHALIAS], &vms->flashalias); | ||
132 | } | ||
133 | |||
134 | dinfo = drive_get(IF_PFLASH, 0, 1); | ||
135 | ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo); | ||
136 | |||
137 | sram_size = 0x2000000; | ||
138 | - memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size, | ||
139 | + memory_region_init_ram(&vms->sram, NULL, "vexpress.sram", sram_size, | ||
140 | &error_fatal); | ||
141 | - memory_region_add_subregion(sysmem, map[VE_SRAM], sram); | ||
142 | + memory_region_add_subregion(sysmem, map[VE_SRAM], &vms->sram); | ||
143 | |||
144 | vram_size = 0x800000; | ||
145 | - memory_region_init_ram(vram, NULL, "vexpress.vram", vram_size, | ||
146 | + memory_region_init_ram(&vms->vram, NULL, "vexpress.vram", vram_size, | ||
147 | &error_fatal); | ||
148 | - memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram); | ||
149 | + memory_region_add_subregion(sysmem, map[VE_VIDEORAM], &vms->vram); | ||
150 | |||
151 | /* 0x4e000000 LAN9118 Ethernet */ | ||
152 | if (nd_table[0].used) { | ||
120 | -- | 153 | -- |
121 | 2.25.1 | 154 | 2.34.1 |
122 | 155 | ||
123 | 156 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the u2f.txt file to rST, and place it in the right place |
---|---|---|---|
2 | 2 | in our manual layout. The old text didn't fit very well into our | |
3 | Create empty data files and allow updates for the upcoming VIOT tests. | 3 | manual style, so the new version ends up looking like a rewrite, |
4 | 4 | although some of the original text is preserved: | |
5 | Acked-by: Igor Mammedov <imammedo@redhat.com> | 5 | |
6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 6 | * the 'building' section of the old file is removed, since we |
7 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | 7 | generally assume that users have already built QEMU |
8 | Message-id: 20211210170415.583179-6-jean-philippe@linaro.org | 8 | * some rather verbose text has been cut back |
9 | * document the passthrough device first, on the assumption | ||
10 | that's most likely to be of interest to users | ||
11 | * cut back on the duplication of text between sections | ||
12 | * format example command lines etc with rST | ||
13 | |||
14 | As it's a short document it seemed simplest to do this all | ||
15 | in one go rather than try to do a minimal syntactic conversion | ||
16 | and then clean up the wording and layout. | ||
17 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
20 | Message-id: 20230421163734.1152076-1-peter.maydell@linaro.org | ||
10 | --- | 21 | --- |
11 | tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ | 22 | docs/system/device-emulation.rst | 1 + |
12 | tests/data/acpi/q35/DSDT.viot | 0 | 23 | docs/system/devices/usb-u2f.rst | 93 ++++++++++++++++++++++++++ |
13 | tests/data/acpi/q35/VIOT.viot | 0 | 24 | docs/system/devices/usb.rst | 2 +- |
14 | tests/data/acpi/virt/VIOT | 0 | 25 | docs/u2f.txt | 110 ------------------------------- |
15 | 4 files changed, 3 insertions(+) | 26 | 4 files changed, 95 insertions(+), 111 deletions(-) |
16 | create mode 100644 tests/data/acpi/q35/DSDT.viot | 27 | create mode 100644 docs/system/devices/usb-u2f.rst |
17 | create mode 100644 tests/data/acpi/q35/VIOT.viot | 28 | delete mode 100644 docs/u2f.txt |
18 | create mode 100644 tests/data/acpi/virt/VIOT | 29 | |
19 | 30 | diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst | |
20 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | 32 | --- a/docs/system/device-emulation.rst |
23 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | 33 | +++ b/docs/system/device-emulation.rst |
24 | @@ -1 +1,4 @@ | 34 | @@ -XXX,XX +XXX,XX @@ Emulated Devices |
25 | /* List of comma-separated changed AML files to ignore */ | 35 | devices/virtio-pmem.rst |
26 | +"tests/data/acpi/virt/VIOT", | 36 | devices/vhost-user-rng.rst |
27 | +"tests/data/acpi/q35/DSDT.viot", | 37 | devices/canokey.rst |
28 | +"tests/data/acpi/q35/VIOT.viot", | 38 | + devices/usb-u2f.rst |
29 | diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot | 39 | devices/igb.rst |
40 | diff --git a/docs/system/devices/usb-u2f.rst b/docs/system/devices/usb-u2f.rst | ||
30 | new file mode 100644 | 41 | new file mode 100644 |
31 | index XXXXXXX..XXXXXXX | 42 | index XXXXXXX..XXXXXXX |
32 | diff --git a/tests/data/acpi/q35/VIOT.viot b/tests/data/acpi/q35/VIOT.viot | 43 | --- /dev/null |
33 | new file mode 100644 | 44 | +++ b/docs/system/devices/usb-u2f.rst |
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | +Universal Second Factor (U2F) USB Key Device | ||
47 | +============================================ | ||
48 | + | ||
49 | +U2F is an open authentication standard that enables relying parties | ||
50 | +exposed to the internet to offer a strong second factor option for end | ||
51 | +user authentication. | ||
52 | + | ||
53 | +The second factor is provided by a device implementing the U2F | ||
54 | +protocol. In case of a USB U2F security key, it is a USB HID device | ||
55 | +that implements the U2F protocol. | ||
56 | + | ||
57 | +QEMU supports both pass-through of a host U2F key device to a VM, | ||
58 | +and software emulation of a U2F key. | ||
59 | + | ||
60 | +``u2f-passthru`` | ||
61 | +---------------- | ||
62 | + | ||
63 | +The ``u2f-passthru`` device allows you to connect a real hardware | ||
64 | +U2F key on your host to a guest VM. All requests made from the guest | ||
65 | +are passed through to the physical security key connected to the | ||
66 | +host machine and vice versa. | ||
67 | + | ||
68 | +In addition, the dedicated pass-through allows you to share a single | ||
69 | +U2F security key with several guest VMs, which is not possible with a | ||
70 | +simple host device assignment pass-through. | ||
71 | + | ||
72 | +You can specify the host U2F key to use with the ``hidraw`` | ||
73 | +option, which takes the host path to a Linux ``/dev/hidrawN`` device: | ||
74 | + | ||
75 | +.. parsed-literal:: | ||
76 | + |qemu_system| -usb -device u2f-passthru,hidraw=/dev/hidraw0 | ||
77 | + | ||
78 | +If you don't specify the device, the ``u2f-passthru`` device will | ||
79 | +autoscan to take the first U2F device it finds on the host (this | ||
80 | +requires a working libudev): | ||
81 | + | ||
82 | +.. parsed-literal:: | ||
83 | + |qemu_system| -usb -device u2f-passthru | ||
84 | + | ||
85 | +``u2f-emulated`` | ||
86 | +---------------- | ||
87 | + | ||
88 | +``u2f-emulated`` is a completely software emulated U2F device. | ||
89 | +It uses `libu2f-emu <https://github.com/MattGorko/libu2f-emu>`__ | ||
90 | +for the U2F key emulation. libu2f-emu | ||
91 | +provides a complete implementation of the U2F protocol device part for | ||
92 | +all specified transports given by the FIDO Alliance. | ||
93 | + | ||
94 | +To work, an emulated U2F device must have four elements: | ||
95 | + | ||
96 | + * ec x509 certificate | ||
97 | + * ec private key | ||
98 | + * counter (four bytes value) | ||
99 | + * 48 bytes of entropy (random bits) | ||
100 | + | ||
101 | +To use this type of device, these have to be configured, and these | ||
102 | +four elements must be passed one way or another. | ||
103 | + | ||
104 | +Assuming that you have a working libu2f-emu installed on the host, | ||
105 | +there are three possible ways to configure the ``u2f-emulated`` device: | ||
106 | + | ||
107 | + * ephemeral | ||
108 | + * setup directory | ||
109 | + * manual | ||
110 | + | ||
111 | +Ephemeral is the simplest way to configure; it lets the device generate | ||
112 | +all the elements it needs for a single use of the lifetime of the device. | ||
113 | +It is the default if you do not pass any other options to the device. | ||
114 | + | ||
115 | +.. parsed-literal:: | ||
116 | + |qemu_system| -usb -device u2f-emulated | ||
117 | + | ||
118 | +You can pass the device the path of a setup directory on the host | ||
119 | +using the ``dir`` option; the directory must contain these four files: | ||
120 | + | ||
121 | + * ``certificate.pem``: ec x509 certificate | ||
122 | + * ``private-key.pem``: ec private key | ||
123 | + * ``counter``: counter value | ||
124 | + * ``entropy``: 48 bytes of entropy | ||
125 | + | ||
126 | +.. parsed-literal:: | ||
127 | + |qemu_system| -usb -device u2f-emulated,dir=$dir | ||
128 | + | ||
129 | +You can also manually pass the device the paths to each of these files, | ||
130 | +if you don't want them all to be in the same directory, using the options | ||
131 | + | ||
132 | + * ``cert`` | ||
133 | + * ``priv`` | ||
134 | + * ``counter`` | ||
135 | + * ``entropy`` | ||
136 | + | ||
137 | +.. parsed-literal:: | ||
138 | + |qemu_system| -usb -device u2f-emulated,cert=$DIR1/$FILE1,priv=$DIR2/$FILE2,counter=$DIR3/$FILE3,entropy=$DIR4/$FILE4 | ||
139 | diff --git a/docs/system/devices/usb.rst b/docs/system/devices/usb.rst | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/docs/system/devices/usb.rst | ||
142 | +++ b/docs/system/devices/usb.rst | ||
143 | @@ -XXX,XX +XXX,XX @@ option or the ``device_add`` monitor command. Available devices are: | ||
144 | USB audio device | ||
145 | |||
146 | ``u2f-{emulated,passthru}`` | ||
147 | - Universal Second Factor device | ||
148 | + :doc:`usb-u2f` | ||
149 | |||
150 | ``canokey`` | ||
151 | An Open-source Secure Key implementing FIDO2, OpenPGP, PIV and more. | ||
152 | diff --git a/docs/u2f.txt b/docs/u2f.txt | ||
153 | deleted file mode 100644 | ||
34 | index XXXXXXX..XXXXXXX | 154 | index XXXXXXX..XXXXXXX |
35 | diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/virt/VIOT | 155 | --- a/docs/u2f.txt |
36 | new file mode 100644 | 156 | +++ /dev/null |
37 | index XXXXXXX..XXXXXXX | 157 | @@ -XXX,XX +XXX,XX @@ |
158 | -QEMU U2F Key Device Documentation. | ||
159 | - | ||
160 | -Contents | ||
161 | -1. USB U2F key device | ||
162 | -2. Building | ||
163 | -3. Using u2f-emulated | ||
164 | -4. Using u2f-passthru | ||
165 | -5. Libu2f-emu | ||
166 | - | ||
167 | -1. USB U2F key device | ||
168 | - | ||
169 | -U2F is an open authentication standard that enables relying parties | ||
170 | -exposed to the internet to offer a strong second factor option for end | ||
171 | -user authentication. | ||
172 | - | ||
173 | -The standard brings many advantages to both parties, client and server, | ||
174 | -allowing to reduce over-reliance on passwords, it increases authentication | ||
175 | -security and simplifies passwords. | ||
176 | - | ||
177 | -The second factor is materialized by a device implementing the U2F | ||
178 | -protocol. In case of a USB U2F security key, it is a USB HID device | ||
179 | -that implements the U2F protocol. | ||
180 | - | ||
181 | -In QEMU, the USB U2F key device offers a dedicated support of U2F, allowing | ||
182 | -guest USB FIDO/U2F security keys operating in two possible modes: | ||
183 | -pass-through and emulated. | ||
184 | - | ||
185 | -The pass-through mode consists of passing all requests made from the guest | ||
186 | -to the physical security key connected to the host machine and vice versa. | ||
187 | -In addition, the dedicated pass-through allows to have a U2F security key | ||
188 | -shared on several guests which is not possible with a simple host device | ||
189 | -assignment pass-through. | ||
190 | - | ||
191 | -The emulated mode consists of completely emulating the behavior of an | ||
192 | -U2F device through software part. Libu2f-emu is used for that. | ||
193 | - | ||
194 | - | ||
195 | -2. Building | ||
196 | - | ||
197 | -To ensure the build of the u2f-emulated device variant which depends | ||
198 | -on libu2f-emu: configuring and building: | ||
199 | - | ||
200 | - ./configure --enable-u2f && make | ||
201 | - | ||
202 | -The pass-through mode is built by default on Linux. To take advantage | ||
203 | -of the autoscan option it provides, make sure you have a working libudev | ||
204 | -installed on the host. | ||
205 | - | ||
206 | - | ||
207 | -3. Using u2f-emulated | ||
208 | - | ||
209 | -To work, an emulated U2F device must have four elements: | ||
210 | - * ec x509 certificate | ||
211 | - * ec private key | ||
212 | - * counter (four bytes value) | ||
213 | - * 48 bytes of entropy (random bits) | ||
214 | - | ||
215 | -To use this type of device, this one has to be configured, and these | ||
216 | -four elements must be passed one way or another. | ||
217 | - | ||
218 | -Assuming that you have a working libu2f-emu installed on the host. | ||
219 | -There are three possible ways of configurations: | ||
220 | - * ephemeral | ||
221 | - * setup directory | ||
222 | - * manual | ||
223 | - | ||
224 | -Ephemeral is the simplest way to configure, it lets the device generate | ||
225 | -all the elements it needs for a single use of the lifetime of the device. | ||
226 | - | ||
227 | - qemu -usb -device u2f-emulated | ||
228 | - | ||
229 | -Setup directory allows to configure the device from a directory containing | ||
230 | -four files: | ||
231 | - * certificate.pem: ec x509 certificate | ||
232 | - * private-key.pem: ec private key | ||
233 | - * counter: counter value | ||
234 | - * entropy: 48 bytes of entropy | ||
235 | - | ||
236 | - qemu -usb -device u2f-emulated,dir=$dir | ||
237 | - | ||
238 | -Manual allows to configure the device more finely by specifying each | ||
239 | -of the elements necessary for the device: | ||
240 | - * cert | ||
241 | - * priv | ||
242 | - * counter | ||
243 | - * entropy | ||
244 | - | ||
245 | - qemu -usb -device u2f-emulated,cert=$DIR1/$FILE1,priv=$DIR2/$FILE2,counter=$DIR3/$FILE3,entropy=$DIR4/$FILE4 | ||
246 | - | ||
247 | - | ||
248 | -4. Using u2f-passthru | ||
249 | - | ||
250 | -On the host specify the u2f-passthru device with a suitable hidraw: | ||
251 | - | ||
252 | - qemu -usb -device u2f-passthru,hidraw=/dev/hidraw0 | ||
253 | - | ||
254 | -Alternately, the u2f-passthru device can autoscan to take the first | ||
255 | -U2F device it finds on the host (this requires a working libudev): | ||
256 | - | ||
257 | - qemu -usb -device u2f-passthru | ||
258 | - | ||
259 | - | ||
260 | -5. Libu2f-emu | ||
261 | - | ||
262 | -The u2f-emulated device uses libu2f-emu for the U2F key emulation. Libu2f-emu | ||
263 | -implements completely the U2F protocol device part for all specified | ||
264 | -transport given by the FIDO Alliance. | ||
265 | - | ||
266 | -For more information about libu2f-emu see this page: | ||
267 | -https://github.com/MattGorko/libu2f-emu. | ||
38 | -- | 268 | -- |
39 | 2.25.1 | 269 | 2.34.1 |
40 | |||
41 | diff view generated by jsdifflib |