1 | target-arm queue. This has the "plumb txattrs through various | 1 | The following changes since commit eae587e8e3694b1aceab23239493fb4c7e1a80f5: |
---|---|---|---|
2 | bits of exec.c" patches, and a collection of bug fixes from | ||
3 | various people. | ||
4 | 2 | ||
5 | thanks | 3 | Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-09-13' into staging (2021-09-13 11:00:30 +0100) |
6 | -- PMM | ||
7 | |||
8 | |||
9 | |||
10 | The following changes since commit a3ac12fba028df90f7b3dbec924995c126c41022: | ||
11 | |||
12 | Merge remote-tracking branch 'remotes/ehabkost/tags/numa-next-pull-request' into staging (2018-05-31 11:12:36 +0100) | ||
13 | 4 | ||
14 | are available in the Git repository at: | 5 | are available in the Git repository at: |
15 | 6 | ||
16 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180531 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210913 |
17 | 8 | ||
18 | for you to fetch changes up to 49d1dca0520ea71bc21867fab6647f474fcf857b: | 9 | for you to fetch changes up to 9a2b2ecf4d25a3943918c95d2db4508b304161b5: |
19 | 10 | ||
20 | KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice (2018-05-31 14:52:53 +0100) | 11 | hw/arm/mps2.c: Mark internal-only I2C buses as 'full' (2021-09-13 17:09:28 +0100) |
21 | 12 | ||
22 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
23 | target-arm queue: | 14 | target-arm queue: |
24 | * target/arm: Honour FPCR.FZ in FRECPX | 15 | * mark MPS2/MPS3 board-internal i2c buses as 'full' so that command |
25 | * MAINTAINERS: Add entries for newer MPS2 boards and devices | 16 | line user-created devices are not plugged into them |
26 | * hw/intc/arm_gicv3: Fix APxR<n> register dispatching | 17 | * Take an exception if PSTATE.IL is set |
27 | * arm_gicv3_kvm: fix bug in writing zero bits back to the in-kernel | 18 | * Support an emulated ITS in the virt board |
28 | GIC state | 19 | * Add support for kudo-bmc board |
29 | * tcg: Fix helper function vs host abi for float16 | 20 | * Probe for KVM_CAP_ARM_VM_IPA_SIZE when creating scratch VM |
30 | * arm: fix qemu crash on startup with -bios option | 21 | * cadence_uart: Fix clock handling issues that prevented |
31 | * arm: fix malloc type mismatch | 22 | u-boot from running |
32 | * xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors | ||
33 | * Correct CPACR reset value for v7 cores | ||
34 | * memory.h: Improve IOMMU related documentation | ||
35 | * exec: Plumb transaction attributes through various functions in | ||
36 | preparation for allowing IOMMUs to see them | ||
37 | * vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY | ||
38 | * ARM: ACPI: Fix use-after-free due to memory realloc | ||
39 | * KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice | ||
40 | 23 | ||
41 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
42 | Francisco Iglesias (1): | 25 | Bin Meng (6): |
43 | xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors | 26 | hw/misc: zynq_slcr: Correctly compute output clocks in the reset exit phase |
27 | hw/char: cadence_uart: Disable transmit when input clock is disabled | ||
28 | hw/char: cadence_uart: Move clock/reset check to uart_can_receive() | ||
29 | hw/char: cadence_uart: Convert to memop_with_attrs() ops | ||
30 | hw/char: cadence_uart: Ignore access when unclocked or in reset for uart_{read, write}() | ||
31 | hw/char: cadence_uart: Log a guest error when device is unclocked or in reset | ||
44 | 32 | ||
45 | Igor Mammedov (1): | 33 | Chris Rauer (1): |
46 | arm: fix qemu crash on startup with -bios option | 34 | hw/arm: Add support for kudo-bmc board. |
47 | 35 | ||
48 | Jan Kiszka (1): | 36 | Marc Zyngier (1): |
49 | hw/intc/arm_gicv3: Fix APxR<n> register dispatching | 37 | hw/arm/virt: KVM: Probe for KVM_CAP_ARM_VM_IPA_SIZE when creating scratch VM |
50 | 38 | ||
51 | Paolo Bonzini (1): | 39 | Peter Maydell (5): |
52 | arm: fix malloc type mismatch | 40 | target/arm: Take an exception if PSTATE.IL is set |
53 | 41 | qdev: Support marking individual buses as 'full' | |
54 | Peter Maydell (17): | 42 | hw/arm/mps2-tz.c: Add extra data parameter to MakeDevFn |
55 | target/arm: Honour FPCR.FZ in FRECPX | 43 | hw/arm/mps2-tz.c: Mark internal-only I2C buses as 'full' |
56 | MAINTAINERS: Add entries for newer MPS2 boards and devices | 44 | hw/arm/mps2.c: Mark internal-only I2C buses as 'full' |
57 | Correct CPACR reset value for v7 cores | ||
58 | memory.h: Improve IOMMU related documentation | ||
59 | Make tb_invalidate_phys_addr() take a MemTxAttrs argument | ||
60 | Make address_space_translate{, _cached}() take a MemTxAttrs argument | ||
61 | Make address_space_map() take a MemTxAttrs argument | ||
62 | Make address_space_access_valid() take a MemTxAttrs argument | ||
63 | Make flatview_extend_translation() take a MemTxAttrs argument | ||
64 | Make memory_region_access_valid() take a MemTxAttrs argument | ||
65 | Make MemoryRegion valid.accepts callback take a MemTxAttrs argument | ||
66 | Make flatview_access_valid() take a MemTxAttrs argument | ||
67 | Make flatview_translate() take a MemTxAttrs argument | ||
68 | Make address_space_get_iotlb_entry() take a MemTxAttrs argument | ||
69 | Make flatview_do_translate() take a MemTxAttrs argument | ||
70 | Make address_space_translate_iommu take a MemTxAttrs argument | ||
71 | vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY | ||
72 | 45 | ||
73 | Richard Henderson (1): | 46 | Richard Henderson (1): |
74 | tcg: Fix helper function vs host abi for float16 | 47 | target/arm: Merge disas_a64_insn into aarch64_tr_translate_insn |
75 | 48 | ||
76 | Shannon Zhao (3): | 49 | Shashi Mallela (9): |
77 | arm_gicv3_kvm: increase clroffset accordingly | 50 | hw/intc: GICv3 ITS initial framework |
78 | ARM: ACPI: Fix use-after-free due to memory realloc | 51 | hw/intc: GICv3 ITS register definitions added |
79 | KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice | 52 | hw/intc: GICv3 ITS command queue framework |
53 | hw/intc: GICv3 ITS Command processing | ||
54 | hw/intc: GICv3 ITS Feature enablement | ||
55 | hw/intc: GICv3 redistributor ITS processing | ||
56 | tests/data/acpi/virt: Add IORT files for ITS | ||
57 | hw/arm/virt: add ITS support in virt GIC | ||
58 | tests/data/acpi/virt: Update IORT files for ITS | ||
80 | 59 | ||
81 | include/exec/exec-all.h | 5 +- | 60 | docs/system/arm/nuvoton.rst | 1 + |
82 | include/exec/helper-head.h | 2 +- | 61 | hw/intc/gicv3_internal.h | 188 ++++- |
83 | include/exec/memory-internal.h | 3 +- | 62 | include/hw/arm/virt.h | 2 + |
84 | include/exec/memory.h | 128 +++++++++++++++++++++++++++++++++++------ | 63 | include/hw/intc/arm_gicv3_common.h | 13 + |
85 | include/migration/vmstate.h | 3 + | 64 | include/hw/intc/arm_gicv3_its_common.h | 32 +- |
86 | include/sysemu/dma.h | 6 +- | 65 | include/hw/qdev-core.h | 24 + |
87 | accel/tcg/translate-all.c | 4 +- | 66 | target/arm/cpu.h | 1 + |
88 | exec.c | 95 ++++++++++++++++++------------ | 67 | target/arm/kvm_arm.h | 4 +- |
89 | hw/arm/boot.c | 18 +++--- | 68 | target/arm/syndrome.h | 5 + |
90 | hw/arm/virt-acpi-build.c | 20 +++++-- | 69 | target/arm/translate.h | 2 + |
91 | hw/dma/xlnx-zdma.c | 10 +++- | 70 | hw/arm/mps2-tz.c | 92 ++- |
92 | hw/hppa/dino.c | 3 +- | 71 | hw/arm/mps2.c | 12 +- |
93 | hw/intc/arm_gic_kvm.c | 1 - | 72 | hw/arm/npcm7xx_boards.c | 34 + |
94 | hw/intc/arm_gicv3_cpuif.c | 12 ++-- | 73 | hw/arm/virt.c | 29 +- |
95 | hw/intc/arm_gicv3_kvm.c | 2 +- | 74 | hw/char/cadence_uart.c | 61 +- |
96 | hw/nvram/fw_cfg.c | 12 ++-- | 75 | hw/intc/arm_gicv3.c | 14 + |
97 | hw/s390x/s390-pci-inst.c | 3 +- | 76 | hw/intc/arm_gicv3_common.c | 13 + |
98 | hw/scsi/esp.c | 3 +- | 77 | hw/intc/arm_gicv3_cpuif.c | 7 +- |
99 | hw/vfio/common.c | 3 +- | 78 | hw/intc/arm_gicv3_dist.c | 5 +- |
100 | hw/virtio/vhost.c | 3 +- | 79 | hw/intc/arm_gicv3_its.c | 1322 ++++++++++++++++++++++++++++++++ |
101 | hw/xen/xen_pt_msi.c | 3 +- | 80 | hw/intc/arm_gicv3_its_common.c | 7 +- |
102 | memory.c | 12 ++-- | 81 | hw/intc/arm_gicv3_its_kvm.c | 2 +- |
103 | memory_ldst.inc.c | 18 +++--- | 82 | hw/intc/arm_gicv3_redist.c | 153 +++- |
104 | target/arm/gdbstub.c | 3 +- | 83 | hw/misc/zynq_slcr.c | 31 +- |
105 | target/arm/helper-a64.c | 41 +++++++------ | 84 | softmmu/qdev-monitor.c | 7 +- |
106 | target/arm/helper.c | 90 ++++++++++++++++------------- | 85 | target/arm/helper-a64.c | 1 + |
107 | target/ppc/mmu-hash64.c | 3 +- | 86 | target/arm/helper.c | 8 + |
108 | target/riscv/helper.c | 2 +- | 87 | target/arm/kvm.c | 7 +- |
109 | target/s390x/diag.c | 6 +- | 88 | target/arm/translate-a64.c | 255 +++--- |
110 | target/s390x/excp_helper.c | 3 +- | 89 | target/arm/translate.c | 21 + |
111 | target/s390x/mmu_helper.c | 3 +- | 90 | hw/intc/meson.build | 1 + |
112 | target/s390x/sigp.c | 3 +- | 91 | tests/data/acpi/virt/IORT | Bin 0 -> 124 bytes |
113 | target/xtensa/op_helper.c | 3 +- | 92 | tests/data/acpi/virt/IORT.memhp | Bin 0 -> 124 bytes |
114 | MAINTAINERS | 9 ++- | 93 | tests/data/acpi/virt/IORT.numamem | Bin 0 -> 124 bytes |
115 | 34 files changed, 353 insertions(+), 182 deletions(-) | 94 | tests/data/acpi/virt/IORT.pxb | Bin 0 -> 124 bytes |
95 | 35 files changed, 2144 insertions(+), 210 deletions(-) | ||
96 | create mode 100644 hw/intc/arm_gicv3_its.c | ||
97 | create mode 100644 tests/data/acpi/virt/IORT | ||
98 | create mode 100644 tests/data/acpi/virt/IORT.memhp | ||
99 | create mode 100644 tests/data/acpi/virt/IORT.numamem | ||
100 | create mode 100644 tests/data/acpi/virt/IORT.pxb | ||
116 | 101 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Bin Meng <bmeng.cn@gmail.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_do_translate(). | ||
3 | 2 | ||
3 | As of today, when booting upstream U-Boot for Xilinx Zynq, the UART | ||
4 | does not receive anything. Debugging shows that the UART input clock | ||
5 | frequency is zero which prevents the UART from receiving anything as | ||
6 | per the logic in uart_receive(). | ||
7 | |||
8 | From zynq_slcr_reset_exit() comment, it intends to compute output | ||
9 | clocks according to ps_clk and registers. zynq_slcr_compute_clocks() | ||
10 | is called to accomplish the task, inside which device_is_in_reset() | ||
11 | is called to actually make the attempt in vain. | ||
12 | |||
13 | Rework reset_hold() and reset_exit() so that in the reset exit phase, | ||
14 | the logic can really compute output clocks in reset_exit(). | ||
15 | |||
16 | With this change, upstream U-Boot boots properly again with: | ||
17 | |||
18 | $ qemu-system-arm -M xilinx-zynq-a9 -m 1G -display none -serial null -serial stdio \ | ||
19 | -device loader,file=u-boot-dtb.bin,addr=0x4000000,cpu-num=0 | ||
20 | |||
21 | Fixes: 38867cb7ec90 ("hw/misc/zynq_slcr: add clock generation for uarts") | ||
22 | Signed-off-by: Bin Meng <bmeng.cn@gmail.com> | ||
23 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
24 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
25 | Message-id: 20210901124521.30599-2-bmeng.cn@gmail.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180521140402.23318-13-peter.maydell@linaro.org | ||
8 | --- | 27 | --- |
9 | exec.c | 9 ++++++--- | 28 | hw/misc/zynq_slcr.c | 31 ++++++++++++++++++------------- |
10 | 1 file changed, 6 insertions(+), 3 deletions(-) | 29 | 1 file changed, 18 insertions(+), 13 deletions(-) |
11 | 30 | ||
12 | diff --git a/exec.c b/exec.c | 31 | diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c |
13 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/exec.c | 33 | --- a/hw/misc/zynq_slcr.c |
15 | +++ b/exec.c | 34 | +++ b/hw/misc/zynq_slcr.c |
16 | @@ -XXX,XX +XXX,XX @@ unassigned: | 35 | @@ -XXX,XX +XXX,XX @@ static uint64_t zynq_slcr_compute_clock(const uint64_t periods[], |
17 | * @is_write: whether the translation operation is for write | 36 | zynq_slcr_compute_clock((plls), (state)->regs[reg], \ |
18 | * @is_mmio: whether this can be MMIO, set true if it can | 37 | reg ## _ ## enable_field ## _SHIFT) |
19 | * @target_as: the address space targeted by the IOMMU | 38 | |
20 | + * @attrs: memory transaction attributes | 39 | +static void zynq_slcr_compute_clocks_internal(ZynqSLCRState *s, uint64_t ps_clk) |
21 | * | 40 | +{ |
22 | * This function is called from RCU critical section | 41 | + uint64_t io_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTRL]); |
23 | */ | 42 | + uint64_t arm_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_CTRL]); |
24 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | 43 | + uint64_t ddr_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_CTRL]); |
25 | hwaddr *page_mask_out, | 44 | + |
26 | bool is_write, | 45 | + uint64_t uart_mux[4] = {io_pll, io_pll, arm_pll, ddr_pll}; |
27 | bool is_mmio, | 46 | + |
28 | - AddressSpace **target_as) | 47 | + /* compute uartX reference clocks */ |
29 | + AddressSpace **target_as, | 48 | + clock_set(s->uart0_ref_clk, |
30 | + MemTxAttrs attrs) | 49 | + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0)); |
31 | { | 50 | + clock_set(s->uart1_ref_clk, |
32 | MemoryRegionSection *section; | 51 | + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1)); |
33 | IOMMUMemoryRegion *iommu_mr; | 52 | +} |
34 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 53 | + |
35 | * but page mask. | 54 | /** |
36 | */ | 55 | * Compute and set the ouputs clocks periods. |
37 | section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat, | 56 | * But do not propagate them further. Connected clocks |
38 | - NULL, &page_mask, is_write, false, &as); | 57 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_compute_clocks(ZynqSLCRState *s) |
39 | + NULL, &page_mask, is_write, false, &as, | 58 | ps_clk = 0; |
40 | + attrs); | 59 | } |
41 | 60 | ||
42 | /* Illegal translation */ | 61 | - uint64_t io_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTRL]); |
43 | if (section.mr == &io_mem_unassigned) { | 62 | - uint64_t arm_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_CTRL]); |
44 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, | 63 | - uint64_t ddr_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_CTRL]); |
45 | 64 | - | |
46 | /* This can be MMIO, so setup MMIO bit. */ | 65 | - uint64_t uart_mux[4] = {io_pll, io_pll, arm_pll, ddr_pll}; |
47 | section = flatview_do_translate(fv, addr, xlat, plen, NULL, | 66 | - |
48 | - is_write, true, &as); | 67 | - /* compute uartX reference clocks */ |
49 | + is_write, true, &as, attrs); | 68 | - clock_set(s->uart0_ref_clk, |
50 | mr = section.mr; | 69 | - ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0)); |
51 | 70 | - clock_set(s->uart1_ref_clk, | |
52 | if (xen_enabled() && memory_access_is_direct(mr, is_write)) { | 71 | - ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1)); |
72 | + zynq_slcr_compute_clocks_internal(s, ps_clk); | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset_hold(Object *obj) | ||
77 | ZynqSLCRState *s = ZYNQ_SLCR(obj); | ||
78 | |||
79 | /* will disable all output clocks */ | ||
80 | - zynq_slcr_compute_clocks(s); | ||
81 | + zynq_slcr_compute_clocks_internal(s, 0); | ||
82 | zynq_slcr_propagate_clocks(s); | ||
83 | } | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset_exit(Object *obj) | ||
86 | ZynqSLCRState *s = ZYNQ_SLCR(obj); | ||
87 | |||
88 | /* will compute output clocks according to ps_clk and registers */ | ||
89 | - zynq_slcr_compute_clocks(s); | ||
90 | + zynq_slcr_compute_clocks_internal(s, clock_get(s->ps_clk)); | ||
91 | zynq_slcr_propagate_clocks(s); | ||
92 | } | ||
93 | |||
53 | -- | 94 | -- |
54 | 2.17.1 | 95 | 2.20.1 |
55 | 96 | ||
56 | 97 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Bin Meng <bmeng.cn@gmail.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to memory_region_access_valid(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
6 | The callsite in flatview_access_valid() is part of a recursive | 3 | At present when input clock is disabled, any character transmitted |
7 | loop flatview_access_valid() -> memory_region_access_valid() -> | 4 | to tx fifo can still show on the serial line, which is wrong. |
8 | subpage_accepts() -> flatview_access_valid(); we make it pass | ||
9 | MEMTXATTRS_UNSPECIFIED for now, until the next several commits | ||
10 | have plumbed an attrs parameter through the rest of the loop | ||
11 | and we can add an attrs parameter to flatview_access_valid(). | ||
12 | 5 | ||
6 | Fixes: b636db306e06 ("hw/char/cadence_uart: add clock support") | ||
7 | Signed-off-by: Bin Meng <bmeng.cn@gmail.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
10 | Message-id: 20210901124521.30599-3-bmeng.cn@gmail.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20180521140402.23318-8-peter.maydell@linaro.org | ||
17 | --- | 12 | --- |
18 | include/exec/memory-internal.h | 3 ++- | 13 | hw/char/cadence_uart.c | 5 +++++ |
19 | exec.c | 4 +++- | 14 | 1 file changed, 5 insertions(+) |
20 | hw/s390x/s390-pci-inst.c | 3 ++- | ||
21 | memory.c | 7 ++++--- | ||
22 | 4 files changed, 11 insertions(+), 6 deletions(-) | ||
23 | 15 | ||
24 | diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h | 16 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c |
25 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/exec/memory-internal.h | 18 | --- a/hw/char/cadence_uart.c |
27 | +++ b/include/exec/memory-internal.h | 19 | +++ b/hw/char/cadence_uart.c |
28 | @@ -XXX,XX +XXX,XX @@ void flatview_unref(FlatView *view); | 20 | @@ -XXX,XX +XXX,XX @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond, |
29 | extern const MemoryRegionOps unassigned_mem_ops; | 21 | static void uart_write_tx_fifo(CadenceUARTState *s, const uint8_t *buf, |
30 | 22 | int size) | |
31 | bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr, | ||
32 | - unsigned size, bool is_write); | ||
33 | + unsigned size, bool is_write, | ||
34 | + MemTxAttrs attrs); | ||
35 | |||
36 | void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); | ||
37 | AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); | ||
38 | diff --git a/exec.c b/exec.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/exec.c | ||
41 | +++ b/exec.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | ||
43 | mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
44 | if (!memory_access_is_direct(mr, is_write)) { | ||
45 | l = memory_access_size(mr, l, addr); | ||
46 | - if (!memory_region_access_valid(mr, xlat, l, is_write)) { | ||
47 | + /* When our callers all have attrs we'll pass them through here */ | ||
48 | + if (!memory_region_access_valid(mr, xlat, l, is_write, | ||
49 | + MEMTXATTRS_UNSPECIFIED)) { | ||
50 | return false; | ||
51 | } | ||
52 | } | ||
53 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/s390x/s390-pci-inst.c | ||
56 | +++ b/hw/s390x/s390-pci-inst.c | ||
57 | @@ -XXX,XX +XXX,XX @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr, | ||
58 | mr = s390_get_subregion(mr, offset, len); | ||
59 | offset -= mr->addr; | ||
60 | |||
61 | - if (!memory_region_access_valid(mr, offset, len, true)) { | ||
62 | + if (!memory_region_access_valid(mr, offset, len, true, | ||
63 | + MEMTXATTRS_UNSPECIFIED)) { | ||
64 | s390_program_interrupt(env, PGM_OPERAND, 6, ra); | ||
65 | return 0; | ||
66 | } | ||
67 | diff --git a/memory.c b/memory.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/memory.c | ||
70 | +++ b/memory.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ram_device_mem_ops = { | ||
72 | bool memory_region_access_valid(MemoryRegion *mr, | ||
73 | hwaddr addr, | ||
74 | unsigned size, | ||
75 | - bool is_write) | ||
76 | + bool is_write, | ||
77 | + MemTxAttrs attrs) | ||
78 | { | 23 | { |
79 | int access_size_min, access_size_max; | 24 | + /* ignore characters when unclocked or in reset */ |
80 | int access_size, i; | 25 | + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
81 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr, | 26 | + return; |
82 | { | 27 | + } |
83 | MemTxResult r; | 28 | + |
84 | 29 | if ((s->r[R_CR] & UART_CR_TX_DIS) || !(s->r[R_CR] & UART_CR_TX_EN)) { | |
85 | - if (!memory_region_access_valid(mr, addr, size, false)) { | 30 | return; |
86 | + if (!memory_region_access_valid(mr, addr, size, false, attrs)) { | ||
87 | *pval = unassigned_mem_read(mr, addr, size); | ||
88 | return MEMTX_DECODE_ERROR; | ||
89 | } | ||
90 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, | ||
91 | unsigned size, | ||
92 | MemTxAttrs attrs) | ||
93 | { | ||
94 | - if (!memory_region_access_valid(mr, addr, size, true)) { | ||
95 | + if (!memory_region_access_valid(mr, addr, size, true, attrs)) { | ||
96 | unassigned_mem_write(mr, addr, data, size); | ||
97 | return MEMTX_DECODE_ERROR; | ||
98 | } | 31 | } |
99 | -- | 32 | -- |
100 | 2.17.1 | 33 | 2.20.1 |
101 | 34 | ||
102 | 35 | diff view generated by jsdifflib |
1 | From: Igor Mammedov <imammedo@redhat.com> | 1 | From: Bin Meng <bmeng.cn@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | When QEMU is started with following CLI | 3 | Currently the clock/reset check is done in uart_receive(), but we |
4 | -machine virt,gic-version=3,accel=kvm -cpu host -bios AAVMF_CODE.fd | 4 | can move the check to uart_can_receive() which is earlier. |
5 | it crashes with abort at | ||
6 | accel/kvm/kvm-all.c:2164: | ||
7 | KVM_SET_DEVICE_ATTR failed: Group 6 attr 0x000000000000c665: Invalid argument | ||
8 | 5 | ||
9 | Which is caused by implicit dependency of kvm_arm_gicv3_reset() on | 6 | Signed-off-by: Bin Meng <bmeng.cn@gmail.com> |
10 | arm_gicv3_icc_reset() where the later is called by CPU reset | 7 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
11 | reset callback. | 8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
12 | 9 | Message-id: 20210901124521.30599-4-bmeng.cn@gmail.com | |
13 | However commit: | ||
14 | 3b77f6c arm/boot: split load_dtb() from arm_load_kernel() | ||
15 | broke CPU reset callback registration in case | ||
16 | |||
17 | arm_load_kernel() | ||
18 | ... | ||
19 | if (!info->kernel_filename || info->firmware_loaded) | ||
20 | |||
21 | branch is taken, i.e. it's sufficient to provide a firmware | ||
22 | or do not provide kernel on CLI to skip cpu reset callback | ||
23 | registration, where before offending commit the callback | ||
24 | has been registered unconditionally. | ||
25 | |||
26 | Fix it by registering the callback right at the beginning of | ||
27 | arm_load_kernel() unconditionally instead of doing it at the end. | ||
28 | |||
29 | NOTE: | ||
30 | we probably should eliminate that dependency anyways as well as | ||
31 | separate arch CPU reset parts from arm_load_kernel() into CPU | ||
32 | itself, but that refactoring that I probably would have to do | ||
33 | anyways later for CPU hotplug to work. | ||
34 | |||
35 | Reported-by: Auger Eric <eric.auger@redhat.com> | ||
36 | Signed-off-by: Igor Mammedov <imammedo@redhat.com> | ||
37 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
38 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
39 | Message-id: 1527070950-208350-1-git-send-email-imammedo@redhat.com | ||
40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
42 | --- | 11 | --- |
43 | hw/arm/boot.c | 18 +++++++++--------- | 12 | hw/char/cadence_uart.c | 17 ++++++++++------- |
44 | 1 file changed, 9 insertions(+), 9 deletions(-) | 13 | 1 file changed, 10 insertions(+), 7 deletions(-) |
45 | 14 | ||
46 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 15 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c |
47 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/arm/boot.c | 17 | --- a/hw/char/cadence_uart.c |
49 | +++ b/hw/arm/boot.c | 18 | +++ b/hw/char/cadence_uart.c |
50 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | 19 | @@ -XXX,XX +XXX,XX @@ static void uart_parameters_setup(CadenceUARTState *s) |
51 | static const ARMInsnFixup *primary_loader; | 20 | static int uart_can_receive(void *opaque) |
52 | AddressSpace *as = arm_boot_address_space(cpu, info); | 21 | { |
53 | 22 | CadenceUARTState *s = opaque; | |
54 | + /* CPU objects (unlike devices) are not automatically reset on system | 23 | - int ret = MAX(CADENCE_UART_RX_FIFO_SIZE, CADENCE_UART_TX_FIFO_SIZE); |
55 | + * reset, so we must always register a handler to do so. If we're | 24 | - uint32_t ch_mode = s->r[R_MR] & UART_MR_CHMODE; |
56 | + * actually loading a kernel, the handler is also responsible for | 25 | + int ret; |
57 | + * arranging that we start it correctly. | 26 | + uint32_t ch_mode; |
58 | + */ | 27 | + |
59 | + for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | 28 | + /* ignore characters when unclocked or in reset */ |
60 | + qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); | 29 | + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
30 | + return 0; | ||
61 | + } | 31 | + } |
62 | + | 32 | + |
63 | /* The board code is not supposed to set secure_board_setup unless | 33 | + ret = MAX(CADENCE_UART_RX_FIFO_SIZE, CADENCE_UART_TX_FIFO_SIZE); |
64 | * running its code in secure mode is actually possible, and KVM | 34 | + ch_mode = s->r[R_MR] & UART_MR_CHMODE; |
65 | * doesn't support secure. | 35 | |
66 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | 36 | if (ch_mode == NORMAL_MODE || ch_mode == ECHO_MODE) { |
67 | ARM_CPU(cs)->env.boot_info = info; | 37 | ret = MIN(ret, CADENCE_UART_RX_FIFO_SIZE - s->rx_count); |
68 | } | 38 | @@ -XXX,XX +XXX,XX @@ static void uart_receive(void *opaque, const uint8_t *buf, int size) |
69 | 39 | CadenceUARTState *s = opaque; | |
70 | - /* CPU objects (unlike devices) are not automatically reset on system | 40 | uint32_t ch_mode = s->r[R_MR] & UART_MR_CHMODE; |
71 | - * reset, so we must always register a handler to do so. If we're | 41 | |
72 | - * actually loading a kernel, the handler is also responsible for | 42 | - /* ignore characters when unclocked or in reset */ |
73 | - * arranging that we start it correctly. | 43 | - if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
74 | - */ | 44 | - return; |
75 | - for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | ||
76 | - qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); | ||
77 | - } | 45 | - } |
78 | - | 46 | - |
79 | if (!info->skip_dtb_autoload && have_dtb(info)) { | 47 | if (ch_mode == NORMAL_MODE || ch_mode == ECHO_MODE) { |
80 | if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as) < 0) { | 48 | uart_write_rx_fifo(opaque, buf, size); |
81 | exit(1); | 49 | } |
82 | -- | 50 | -- |
83 | 2.17.1 | 51 | 2.20.1 |
84 | 52 | ||
85 | 53 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Bin Meng <bmeng.cn@gmail.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_translate(); all its | ||
3 | callers now have attrs available. | ||
4 | 2 | ||
3 | This converts uart_read() and uart_write() to memop_with_attrs() ops. | ||
4 | |||
5 | Signed-off-by: Bin Meng <bmeng.cn@gmail.com> | ||
6 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20210901124521.30599-5-bmeng.cn@gmail.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180521140402.23318-11-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | include/exec/memory.h | 7 ++++--- | 11 | hw/char/cadence_uart.c | 26 +++++++++++++++----------- |
11 | exec.c | 17 +++++++++-------- | 12 | 1 file changed, 15 insertions(+), 11 deletions(-) |
12 | 2 files changed, 13 insertions(+), 11 deletions(-) | ||
13 | 13 | ||
14 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 14 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/memory.h | 16 | --- a/hw/char/cadence_uart.c |
17 | +++ b/include/exec/memory.h | 17 | +++ b/hw/char/cadence_uart.c |
18 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 18 | @@ -XXX,XX +XXX,XX @@ static void uart_read_rx_fifo(CadenceUARTState *s, uint32_t *c) |
19 | */ | 19 | uart_update_status(s); |
20 | MemoryRegion *flatview_translate(FlatView *fv, | 20 | } |
21 | hwaddr addr, hwaddr *xlat, | 21 | |
22 | - hwaddr *len, bool is_write); | 22 | -static void uart_write(void *opaque, hwaddr offset, |
23 | + hwaddr *len, bool is_write, | 23 | - uint64_t value, unsigned size) |
24 | + MemTxAttrs attrs); | 24 | +static MemTxResult uart_write(void *opaque, hwaddr offset, |
25 | 25 | + uint64_t value, unsigned size, MemTxAttrs attrs) | |
26 | static inline MemoryRegion *address_space_translate(AddressSpace *as, | ||
27 | hwaddr addr, hwaddr *xlat, | ||
28 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as, | ||
29 | MemTxAttrs attrs) | ||
30 | { | 26 | { |
31 | return flatview_translate(address_space_to_flatview(as), | 27 | CadenceUARTState *s = opaque; |
32 | - addr, xlat, len, is_write); | 28 | |
33 | + addr, xlat, len, is_write, attrs); | 29 | DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value); |
30 | offset >>= 2; | ||
31 | if (offset >= CADENCE_UART_R_MAX) { | ||
32 | - return; | ||
33 | + return MEMTX_DECODE_ERROR; | ||
34 | } | ||
35 | switch (offset) { | ||
36 | case R_IER: /* ier (wts imr) */ | ||
37 | @@ -XXX,XX +XXX,XX @@ static void uart_write(void *opaque, hwaddr offset, | ||
38 | break; | ||
39 | } | ||
40 | uart_update_status(s); | ||
41 | + | ||
42 | + return MEMTX_OK; | ||
34 | } | 43 | } |
35 | 44 | ||
36 | /* address_space_access_valid: check for validity of accessing an address | 45 | -static uint64_t uart_read(void *opaque, hwaddr offset, |
37 | @@ -XXX,XX +XXX,XX @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr, | 46 | - unsigned size) |
38 | rcu_read_lock(); | 47 | +static MemTxResult uart_read(void *opaque, hwaddr offset, |
39 | fv = address_space_to_flatview(as); | 48 | + uint64_t *value, unsigned size, MemTxAttrs attrs) |
40 | l = len; | ||
41 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | ||
42 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | ||
43 | if (len == l && memory_access_is_direct(mr, false)) { | ||
44 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
45 | memcpy(buf, ptr, len); | ||
46 | diff --git a/exec.c b/exec.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/exec.c | ||
49 | +++ b/exec.c | ||
50 | @@ -XXX,XX +XXX,XX @@ iotlb_fail: | ||
51 | |||
52 | /* Called from RCU critical section */ | ||
53 | MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, | ||
54 | - hwaddr *plen, bool is_write) | ||
55 | + hwaddr *plen, bool is_write, | ||
56 | + MemTxAttrs attrs) | ||
57 | { | 49 | { |
58 | MemoryRegion *mr; | 50 | CadenceUARTState *s = opaque; |
59 | MemoryRegionSection section; | 51 | uint32_t c = 0; |
60 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, | 52 | |
61 | } | 53 | offset >>= 2; |
62 | 54 | if (offset >= CADENCE_UART_R_MAX) { | |
63 | l = len; | 55 | - c = 0; |
64 | - mr = flatview_translate(fv, addr, &addr1, &l, true); | 56 | - } else if (offset == R_TX_RX) { |
65 | + mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); | 57 | + return MEMTX_DECODE_ERROR; |
58 | + } | ||
59 | + if (offset == R_TX_RX) { | ||
60 | uart_read_rx_fifo(s, &c); | ||
61 | } else { | ||
62 | - c = s->r[offset]; | ||
63 | + c = s->r[offset]; | ||
66 | } | 64 | } |
67 | 65 | ||
68 | return result; | 66 | DB_PRINT(" offset:%x data:%08x\n", (unsigned)(offset << 2), (unsigned)c); |
69 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | 67 | - return c; |
70 | MemTxResult result = MEMTX_OK; | 68 | + *value = c; |
71 | 69 | + return MEMTX_OK; | |
72 | l = len; | ||
73 | - mr = flatview_translate(fv, addr, &addr1, &l, true); | ||
74 | + mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); | ||
75 | result = flatview_write_continue(fv, addr, attrs, buf, len, | ||
76 | addr1, l, mr); | ||
77 | |||
78 | @@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, | ||
79 | } | ||
80 | |||
81 | l = len; | ||
82 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | ||
83 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | ||
84 | } | ||
85 | |||
86 | return result; | ||
87 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | ||
88 | MemoryRegion *mr; | ||
89 | |||
90 | l = len; | ||
91 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | ||
92 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | ||
93 | return flatview_read_continue(fv, addr, attrs, buf, len, | ||
94 | addr1, l, mr); | ||
95 | } | 70 | } |
96 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 71 | |
97 | 72 | static const MemoryRegionOps uart_ops = { | |
98 | while (len > 0) { | 73 | - .read = uart_read, |
99 | l = len; | 74 | - .write = uart_write, |
100 | - mr = flatview_translate(fv, addr, &xlat, &l, is_write); | 75 | + .read_with_attrs = uart_read, |
101 | + mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs); | 76 | + .write_with_attrs = uart_write, |
102 | if (!memory_access_is_direct(mr, is_write)) { | 77 | .endianness = DEVICE_NATIVE_ENDIAN, |
103 | l = memory_access_size(mr, l, addr); | 78 | }; |
104 | if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) { | 79 | |
105 | @@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr, | ||
106 | |||
107 | len = target_len; | ||
108 | this_mr = flatview_translate(fv, addr, &xlat, | ||
109 | - &len, is_write); | ||
110 | + &len, is_write, attrs); | ||
111 | if (this_mr != mr || xlat != base + done) { | ||
112 | return done; | ||
113 | } | ||
114 | @@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as, | ||
115 | l = len; | ||
116 | rcu_read_lock(); | ||
117 | fv = address_space_to_flatview(as); | ||
118 | - mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
119 | + mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs); | ||
120 | |||
121 | if (!memory_access_is_direct(mr, is_write)) { | ||
122 | if (atomic_xchg(&bounce.in_use, true)) { | ||
123 | -- | 80 | -- |
124 | 2.17.1 | 81 | 2.20.1 |
125 | 82 | ||
126 | 83 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Bin Meng <bmeng.cn@gmail.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_extend_translation(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Read or write to uart registers when unclocked or in reset should be | ||
4 | ignored. Add the check there, and as a result of this, the check in | ||
5 | uart_write_tx_fifo() is now unnecessary. | ||
6 | |||
7 | Signed-off-by: Bin Meng <bmeng.cn@gmail.com> | ||
8 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20210901124521.30599-6-bmeng.cn@gmail.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-7-peter.maydell@linaro.org | ||
10 | --- | 12 | --- |
11 | exec.c | 15 ++++++++++----- | 13 | hw/char/cadence_uart.c | 15 ++++++++++----- |
12 | 1 file changed, 10 insertions(+), 5 deletions(-) | 14 | 1 file changed, 10 insertions(+), 5 deletions(-) |
13 | 15 | ||
14 | diff --git a/exec.c b/exec.c | 16 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/exec.c | 18 | --- a/hw/char/cadence_uart.c |
17 | +++ b/exec.c | 19 | +++ b/hw/char/cadence_uart.c |
18 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 20 | @@ -XXX,XX +XXX,XX @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond, |
19 | 21 | static void uart_write_tx_fifo(CadenceUARTState *s, const uint8_t *buf, | |
20 | static hwaddr | 22 | int size) |
21 | flatview_extend_translation(FlatView *fv, hwaddr addr, | ||
22 | - hwaddr target_len, | ||
23 | - MemoryRegion *mr, hwaddr base, hwaddr len, | ||
24 | - bool is_write) | ||
25 | + hwaddr target_len, | ||
26 | + MemoryRegion *mr, hwaddr base, hwaddr len, | ||
27 | + bool is_write, MemTxAttrs attrs) | ||
28 | { | 23 | { |
29 | hwaddr done = 0; | 24 | - /* ignore characters when unclocked or in reset */ |
30 | hwaddr xlat; | 25 | - if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
31 | @@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as, | 26 | - return; |
32 | 27 | - } | |
33 | memory_region_ref(mr); | 28 | - |
34 | *plen = flatview_extend_translation(fv, addr, len, mr, xlat, | 29 | if ((s->r[R_CR] & UART_CR_TX_DIS) || !(s->r[R_CR] & UART_CR_TX_EN)) { |
35 | - l, is_write); | 30 | return; |
36 | + l, is_write, attrs); | 31 | } |
37 | ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true); | 32 | @@ -XXX,XX +XXX,XX @@ static MemTxResult uart_write(void *opaque, hwaddr offset, |
38 | rcu_read_unlock(); | 33 | { |
39 | 34 | CadenceUARTState *s = opaque; | |
40 | @@ -XXX,XX +XXX,XX @@ int64_t address_space_cache_init(MemoryRegionCache *cache, | 35 | |
41 | mr = cache->mrs.mr; | 36 | + /* ignore access when unclocked or in reset */ |
42 | memory_region_ref(mr); | 37 | + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
43 | if (memory_access_is_direct(mr, is_write)) { | 38 | + return MEMTX_ERROR; |
44 | + /* We don't care about the memory attributes here as we're only | 39 | + } |
45 | + * doing this if we found actual RAM, which behaves the same | 40 | + |
46 | + * regardless of attributes; so UNSPECIFIED is fine. | 41 | DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value); |
47 | + */ | 42 | offset >>= 2; |
48 | l = flatview_extend_translation(cache->fv, addr, len, mr, | 43 | if (offset >= CADENCE_UART_R_MAX) { |
49 | - cache->xlat, l, is_write); | 44 | @@ -XXX,XX +XXX,XX @@ static MemTxResult uart_read(void *opaque, hwaddr offset, |
50 | + cache->xlat, l, is_write, | 45 | CadenceUARTState *s = opaque; |
51 | + MEMTXATTRS_UNSPECIFIED); | 46 | uint32_t c = 0; |
52 | cache->ptr = qemu_ram_ptr_length(mr->ram_block, cache->xlat, &l, true); | 47 | |
53 | } else { | 48 | + /* ignore access when unclocked or in reset */ |
54 | cache->ptr = NULL; | 49 | + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
50 | + return MEMTX_ERROR; | ||
51 | + } | ||
52 | + | ||
53 | offset >>= 2; | ||
54 | if (offset >= CADENCE_UART_R_MAX) { | ||
55 | return MEMTX_DECODE_ERROR; | ||
55 | -- | 56 | -- |
56 | 2.17.1 | 57 | 2.20.1 |
57 | 58 | ||
58 | 59 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Bin Meng <bmeng.cn@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | acpi_data_push uses g_array_set_size to resize the memory size. If there | 3 | We've got SW that expects FSBL (Bootlooader) to setup clocks and |
4 | is no enough contiguous memory, the address will be changed. So previous | 4 | resets. It's quite common that users run that SW on QEMU without |
5 | pointer could not be used any more. It must update the pointer and use | 5 | FSBL (FSBL typically requires the Xilinx tools installed). That's |
6 | the new one. | 6 | fine, since users can stil use -device loader to enable clocks etc. |
7 | 7 | ||
8 | Also, previous codes wrongly use le32 conversion of iort->node_offset | 8 | To help folks understand what's going, a log (guest-error) message |
9 | for subsequent computations that will result incorrect value if host is | 9 | would be helpful here. In particular with the serial port since |
10 | not litlle endian. So use the non-converted one instead. | 10 | things will go very quiet if they get things wrong. |
11 | 11 | ||
12 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 12 | Suggested-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
13 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 13 | Signed-off-by: Bin Meng <bmeng.cn@gmail.com> |
14 | Message-id: 1527663951-14552-1-git-send-email-zhaoshenglong@huawei.com | 14 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Message-id: 20210901124521.30599-7-bmeng.cn@gmail.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 18 | --- |
17 | hw/arm/virt-acpi-build.c | 20 +++++++++++++++----- | 19 | hw/char/cadence_uart.c | 8 ++++++++ |
18 | 1 file changed, 15 insertions(+), 5 deletions(-) | 20 | 1 file changed, 8 insertions(+) |
19 | 21 | ||
20 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 22 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c |
21 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/virt-acpi-build.c | 24 | --- a/hw/char/cadence_uart.c |
23 | +++ b/hw/arm/virt-acpi-build.c | 25 | +++ b/hw/char/cadence_uart.c |
24 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 26 | @@ -XXX,XX +XXX,XX @@ static int uart_can_receive(void *opaque) |
25 | AcpiIortItsGroup *its; | 27 | |
26 | AcpiIortTable *iort; | 28 | /* ignore characters when unclocked or in reset */ |
27 | AcpiIortSmmu3 *smmu; | 29 | if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
28 | - size_t node_size, iort_length, smmu_offset = 0; | 30 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: uart is unclocked or in reset\n", |
29 | + size_t node_size, iort_node_offset, iort_length, smmu_offset = 0; | 31 | + __func__); |
30 | AcpiIortRC *rc; | 32 | return 0; |
31 | |||
32 | iort = acpi_data_push(table_data, sizeof(*iort)); | ||
33 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
34 | |||
35 | iort_length = sizeof(*iort); | ||
36 | iort->node_count = cpu_to_le32(nb_nodes); | ||
37 | - iort->node_offset = cpu_to_le32(sizeof(*iort)); | ||
38 | + /* | ||
39 | + * Use a copy in case table_data->data moves during acpi_data_push | ||
40 | + * operations. | ||
41 | + */ | ||
42 | + iort_node_offset = sizeof(*iort); | ||
43 | + iort->node_offset = cpu_to_le32(iort_node_offset); | ||
44 | |||
45 | /* ITS group node */ | ||
46 | node_size = sizeof(*its) + sizeof(uint32_t); | ||
47 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
48 | int irq = vms->irqmap[VIRT_SMMU]; | ||
49 | |||
50 | /* SMMUv3 node */ | ||
51 | - smmu_offset = iort->node_offset + node_size; | ||
52 | + smmu_offset = iort_node_offset + node_size; | ||
53 | node_size = sizeof(*smmu) + sizeof(*idmap); | ||
54 | iort_length += node_size; | ||
55 | smmu = acpi_data_push(table_data, node_size); | ||
56 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
57 | idmap->id_count = cpu_to_le32(0xFFFF); | ||
58 | idmap->output_base = 0; | ||
59 | /* output IORT node is the ITS group node (the first node) */ | ||
60 | - idmap->output_reference = cpu_to_le32(iort->node_offset); | ||
61 | + idmap->output_reference = cpu_to_le32(iort_node_offset); | ||
62 | } | 33 | } |
63 | 34 | ||
64 | /* Root Complex Node */ | 35 | @@ -XXX,XX +XXX,XX @@ static void uart_event(void *opaque, QEMUChrEvent event) |
65 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 36 | |
66 | idmap->output_reference = cpu_to_le32(smmu_offset); | 37 | /* ignore characters when unclocked or in reset */ |
67 | } else { | 38 | if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
68 | /* output IORT node is the ITS group node (the first node) */ | 39 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: uart is unclocked or in reset\n", |
69 | - idmap->output_reference = cpu_to_le32(iort->node_offset); | 40 | + __func__); |
70 | + idmap->output_reference = cpu_to_le32(iort_node_offset); | 41 | return; |
71 | } | 42 | } |
72 | 43 | ||
73 | + /* | 44 | @@ -XXX,XX +XXX,XX @@ static MemTxResult uart_write(void *opaque, hwaddr offset, |
74 | + * Update the pointer address in case table_data->data moves during above | 45 | |
75 | + * acpi_data_push operations. | 46 | /* ignore access when unclocked or in reset */ |
76 | + */ | 47 | if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { |
77 | + iort = (AcpiIortTable *)(table_data->data + iort_start); | 48 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: uart is unclocked or in reset\n", |
78 | iort->length = cpu_to_le32(iort_length); | 49 | + __func__); |
79 | 50 | return MEMTX_ERROR; | |
80 | build_header(linker, table_data, (void *)(table_data->data + iort_start), | 51 | } |
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static MemTxResult uart_read(void *opaque, hwaddr offset, | ||
54 | |||
55 | /* ignore access when unclocked or in reset */ | ||
56 | if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { | ||
57 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: uart is unclocked or in reset\n", | ||
58 | + __func__); | ||
59 | return MEMTX_ERROR; | ||
60 | } | ||
61 | |||
81 | -- | 62 | -- |
82 | 2.17.1 | 63 | 2.20.1 |
83 | 64 | ||
84 | 65 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Marc Zyngier <maz@kernel.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_map(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Although we probe for the IPA limits imposed by KVM (and the hardware) | ||
4 | when computing the memory map, we still use the old style '0' when | ||
5 | creating a scratch VM in kvm_arm_create_scratch_host_vcpu(). | ||
6 | |||
7 | On systems that are severely IPA challenged (such as the Apple M1), | ||
8 | this results in a failure as KVM cannot use the default 40bit that | ||
9 | '0' represents. | ||
10 | |||
11 | Instead, probe for the extension and use the reported IPA limit | ||
12 | if available. | ||
13 | |||
14 | Cc: Andrew Jones <drjones@redhat.com> | ||
15 | Cc: Eric Auger <eric.auger@redhat.com> | ||
16 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
18 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
19 | Message-id: 20210822144441.1290891-2-maz@kernel.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-5-peter.maydell@linaro.org | ||
10 | --- | 21 | --- |
11 | include/exec/memory.h | 3 ++- | 22 | target/arm/kvm.c | 7 ++++++- |
12 | include/sysemu/dma.h | 3 ++- | 23 | 1 file changed, 6 insertions(+), 1 deletion(-) |
13 | exec.c | 6 ++++-- | ||
14 | target/ppc/mmu-hash64.c | 3 ++- | ||
15 | 4 files changed, 10 insertions(+), 5 deletions(-) | ||
16 | 24 | ||
17 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 25 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
18 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/memory.h | 27 | --- a/target/arm/kvm.c |
20 | +++ b/include/exec/memory.h | 28 | +++ b/target/arm/kvm.c |
21 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_ | 29 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, |
22 | * @addr: address within that address space | 30 | struct kvm_vcpu_init *init) |
23 | * @plen: pointer to length of buffer; updated on return | ||
24 | * @is_write: indicates the transfer direction | ||
25 | + * @attrs: memory attributes | ||
26 | */ | ||
27 | void *address_space_map(AddressSpace *as, hwaddr addr, | ||
28 | - hwaddr *plen, bool is_write); | ||
29 | + hwaddr *plen, bool is_write, MemTxAttrs attrs); | ||
30 | |||
31 | /* address_space_unmap: Unmaps a memory region previously mapped by address_space_map() | ||
32 | * | ||
33 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/include/sysemu/dma.h | ||
36 | +++ b/include/sysemu/dma.h | ||
37 | @@ -XXX,XX +XXX,XX @@ static inline void *dma_memory_map(AddressSpace *as, | ||
38 | hwaddr xlen = *len; | ||
39 | void *p; | ||
40 | |||
41 | - p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE); | ||
42 | + p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE, | ||
43 | + MEMTXATTRS_UNSPECIFIED); | ||
44 | *len = xlen; | ||
45 | return p; | ||
46 | } | ||
47 | diff --git a/exec.c b/exec.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/exec.c | ||
50 | +++ b/exec.c | ||
51 | @@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr, | ||
52 | void *address_space_map(AddressSpace *as, | ||
53 | hwaddr addr, | ||
54 | hwaddr *plen, | ||
55 | - bool is_write) | ||
56 | + bool is_write, | ||
57 | + MemTxAttrs attrs) | ||
58 | { | 31 | { |
59 | hwaddr len = *plen; | 32 | int ret = 0, kvmfd = -1, vmfd = -1, cpufd = -1; |
60 | hwaddr l, xlat; | 33 | + int max_vm_pa_size; |
61 | @@ -XXX,XX +XXX,XX @@ void *cpu_physical_memory_map(hwaddr addr, | 34 | |
62 | hwaddr *plen, | 35 | kvmfd = qemu_open_old("/dev/kvm", O_RDWR); |
63 | int is_write) | 36 | if (kvmfd < 0) { |
64 | { | 37 | goto err; |
65 | - return address_space_map(&address_space_memory, addr, plen, is_write); | ||
66 | + return address_space_map(&address_space_memory, addr, plen, is_write, | ||
67 | + MEMTXATTRS_UNSPECIFIED); | ||
68 | } | ||
69 | |||
70 | void cpu_physical_memory_unmap(void *buffer, hwaddr len, | ||
71 | diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/ppc/mmu-hash64.c | ||
74 | +++ b/target/ppc/mmu-hash64.c | ||
75 | @@ -XXX,XX +XXX,XX @@ const ppc_hash_pte64_t *ppc_hash64_map_hptes(PowerPCCPU *cpu, | ||
76 | return NULL; | ||
77 | } | 38 | } |
78 | 39 | - vmfd = ioctl(kvmfd, KVM_CREATE_VM, 0); | |
79 | - hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false); | 40 | + max_vm_pa_size = ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_VM_IPA_SIZE); |
80 | + hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false, | 41 | + if (max_vm_pa_size < 0) { |
81 | + MEMTXATTRS_UNSPECIFIED); | 42 | + max_vm_pa_size = 0; |
82 | if (plen < (n * HASH_PTE_SIZE_64)) { | 43 | + } |
83 | hw_error("%s: Unable to map all requested HPTEs\n", __func__); | 44 | + vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size); |
45 | if (vmfd < 0) { | ||
46 | goto err; | ||
84 | } | 47 | } |
85 | -- | 48 | -- |
86 | 2.17.1 | 49 | 2.20.1 |
87 | 50 | ||
88 | 51 | diff view generated by jsdifflib |
1 | In commit f0aff255700 we made cpacr_write() enforce that some CPACR | 1 | From: Chris Rauer <crauer@google.com> |
---|---|---|---|
2 | bits are RAZ/WI and some are RAO/WI for ARMv7 cores. Unfortunately | ||
3 | we forgot to also update the register's reset value. The effect | ||
4 | was that (a) a guest that read CPACR on reset would not see ones in | ||
5 | the RAO bits, and (b) if you did a migration before the guest did | ||
6 | a write to the CPACR then the migration would fail because the | ||
7 | destination would enforce the RAO bits and then complain that they | ||
8 | didn't match the zero value from the source. | ||
9 | 2 | ||
10 | Implement reset for the CPACR using a custom reset function | 3 | kudo-bmc is a board supported by OpenBMC. |
11 | that just calls cpacr_write(), to avoid having to duplicate | 4 | https://github.com/openbmc/openbmc/tree/master/meta-fii/meta-kudo |
12 | the logic for which bits are RAO. | ||
13 | 5 | ||
14 | This bug would affect migration for TCG CPUs which are ARMv7 | 6 | Since v1: |
15 | with VFP but without one of Neon or VFPv3. | 7 | - hyphenated Cortex-A9 |
16 | 8 | ||
17 | Reported-by: Cédric Le Goater <clg@kaod.org> | 9 | Tested: Booted kudo firmware. |
10 | Signed-off-by: Chris Rauer <crauer@google.com> | ||
11 | Reviewed-by: Patrick Venture <venture@google.com> | ||
12 | Message-id: 20210907223234.1165705-1-crauer@google.com | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
20 | Message-id: 20180522173713.26282-1-peter.maydell@linaro.org | ||
21 | --- | 14 | --- |
22 | target/arm/helper.c | 10 +++++++++- | 15 | docs/system/arm/nuvoton.rst | 1 + |
23 | 1 file changed, 9 insertions(+), 1 deletion(-) | 16 | hw/arm/npcm7xx_boards.c | 34 ++++++++++++++++++++++++++++++++++ |
17 | 2 files changed, 35 insertions(+) | ||
24 | 18 | ||
25 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 19 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
26 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.c | 21 | --- a/docs/system/arm/nuvoton.rst |
28 | +++ b/target/arm/helper.c | 22 | +++ b/docs/system/arm/nuvoton.rst |
29 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 23 | @@ -XXX,XX +XXX,XX @@ Hyperscale applications. The following machines are based on this chip : |
30 | env->cp15.cpacr_el1 = value; | 24 | |
25 | - ``quanta-gbs-bmc`` Quanta GBS server BMC | ||
26 | - ``quanta-gsj`` Quanta GSJ server BMC | ||
27 | +- ``kudo-bmc`` Fii USA Kudo server BMC | ||
28 | |||
29 | There are also two more SoCs, NPCM710 and NPCM705, which are single-core | ||
30 | variants of NPCM750 and NPCM730, respectively. These are currently not | ||
31 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/arm/npcm7xx_boards.c | ||
34 | +++ b/hw/arm/npcm7xx_boards.c | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | #define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7 | ||
37 | #define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff | ||
38 | #define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff | ||
39 | +#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff | ||
40 | |||
41 | static const char npcm7xx_default_bootrom[] = "npcm7xx_bootrom.bin"; | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static void quanta_gbs_init(MachineState *machine) | ||
44 | npcm7xx_load_kernel(machine, soc); | ||
31 | } | 45 | } |
32 | 46 | ||
33 | +static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri) | 47 | +static void kudo_bmc_init(MachineState *machine) |
34 | +{ | 48 | +{ |
35 | + /* Call cpacr_write() so that we reset with the correct RAO bits set | 49 | + NPCM7xxState *soc; |
36 | + * for our CPU features. | 50 | + |
37 | + */ | 51 | + soc = npcm7xx_create_soc(machine, KUDO_BMC_POWER_ON_STRAPS); |
38 | + cpacr_write(env, ri, 0); | 52 | + npcm7xx_connect_dram(soc, machine->ram); |
53 | + qdev_realize(DEVICE(soc), NULL, &error_fatal); | ||
54 | + | ||
55 | + npcm7xx_load_bootrom(machine, soc); | ||
56 | + npcm7xx_connect_flash(&soc->fiu[0], 0, "mx66u51235f", | ||
57 | + drive_get(IF_MTD, 0, 0)); | ||
58 | + npcm7xx_connect_flash(&soc->fiu[1], 0, "mx66u51235f", | ||
59 | + drive_get(IF_MTD, 3, 0)); | ||
60 | + | ||
61 | + npcm7xx_load_kernel(machine, soc); | ||
39 | +} | 62 | +} |
40 | + | 63 | + |
41 | static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | 64 | static void npcm7xx_set_soc_type(NPCM7xxMachineClass *nmc, const char *type) |
42 | bool isread) | ||
43 | { | 65 | { |
44 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | 66 | NPCM7xxClass *sc = NPCM7XX_CLASS(object_class_by_name(type)); |
45 | { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, | 67 | @@ -XXX,XX +XXX,XX @@ static void gbs_bmc_machine_class_init(ObjectClass *oc, void *data) |
46 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | 68 | mc->default_ram_size = 1 * GiB; |
47 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | 69 | } |
48 | - .resetvalue = 0, .writefn = cpacr_write }, | 70 | |
49 | + .resetfn = cpacr_reset, .writefn = cpacr_write }, | 71 | +static void kudo_bmc_machine_class_init(ObjectClass *oc, void *data) |
50 | REGINFO_SENTINEL | 72 | +{ |
73 | + NPCM7xxMachineClass *nmc = NPCM7XX_MACHINE_CLASS(oc); | ||
74 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
75 | + | ||
76 | + npcm7xx_set_soc_type(nmc, TYPE_NPCM730); | ||
77 | + | ||
78 | + mc->desc = "Kudo BMC (Cortex-A9)"; | ||
79 | + mc->init = kudo_bmc_init; | ||
80 | + mc->default_ram_size = 1 * GiB; | ||
81 | +}; | ||
82 | + | ||
83 | static const TypeInfo npcm7xx_machine_types[] = { | ||
84 | { | ||
85 | .name = TYPE_NPCM7XX_MACHINE, | ||
86 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo npcm7xx_machine_types[] = { | ||
87 | .name = MACHINE_TYPE_NAME("quanta-gbs-bmc"), | ||
88 | .parent = TYPE_NPCM7XX_MACHINE, | ||
89 | .class_init = gbs_bmc_machine_class_init, | ||
90 | + }, { | ||
91 | + .name = MACHINE_TYPE_NAME("kudo-bmc"), | ||
92 | + .parent = TYPE_NPCM7XX_MACHINE, | ||
93 | + .class_init = kudo_bmc_machine_class_init, | ||
94 | }, | ||
51 | }; | 95 | }; |
52 | 96 | ||
53 | -- | 97 | -- |
54 | 2.17.1 | 98 | 2.20.1 |
55 | 99 | ||
56 | 100 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_get_iotlb_entry(). | ||
3 | 2 | ||
3 | Added register definitions relevant to ITS,implemented overall | ||
4 | ITS device framework with stubs for ITS control and translater | ||
5 | regions read/write,extended ITS common to handle mmio init between | ||
6 | existing kvm device and newer qemu device. | ||
7 | |||
8 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Tested-by: Neil Armstrong <narmstrong@baylibre.com> | ||
12 | Message-id: 20210910143951.92242-2-shashi.mallela@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180521140402.23318-12-peter.maydell@linaro.org | ||
8 | --- | 14 | --- |
9 | include/exec/memory.h | 2 +- | 15 | hw/intc/gicv3_internal.h | 96 +++++++++- |
10 | exec.c | 2 +- | 16 | include/hw/intc/arm_gicv3_its_common.h | 9 +- |
11 | hw/virtio/vhost.c | 3 ++- | 17 | hw/intc/arm_gicv3_its.c | 241 +++++++++++++++++++++++++ |
12 | 3 files changed, 4 insertions(+), 3 deletions(-) | 18 | hw/intc/arm_gicv3_its_common.c | 7 +- |
19 | hw/intc/arm_gicv3_its_kvm.c | 2 +- | ||
20 | hw/intc/meson.build | 1 + | ||
21 | 6 files changed, 342 insertions(+), 14 deletions(-) | ||
22 | create mode 100644 hw/intc/arm_gicv3_its.c | ||
13 | 23 | ||
14 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 24 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h |
15 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/memory.h | 26 | --- a/hw/intc/gicv3_internal.h |
17 | +++ b/include/exec/memory.h | 27 | +++ b/hw/intc/gicv3_internal.h |
18 | @@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache); | 28 | @@ -XXX,XX +XXX,XX @@ |
19 | * entry. Should be called from an RCU critical section. | 29 | #ifndef QEMU_ARM_GICV3_INTERNAL_H |
30 | #define QEMU_ARM_GICV3_INTERNAL_H | ||
31 | |||
32 | +#include "hw/registerfields.h" | ||
33 | #include "hw/intc/arm_gicv3_common.h" | ||
34 | |||
35 | /* Distributor registers, as offsets from the distributor base address */ | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | #define GICD_CTLR_E1NWF (1U << 7) | ||
38 | #define GICD_CTLR_RWP (1U << 31) | ||
39 | |||
40 | +/* 16 bits EventId */ | ||
41 | +#define GICD_TYPER_IDBITS 0xf | ||
42 | + | ||
43 | /* | ||
44 | * Redistributor frame offsets from RD_base | ||
20 | */ | 45 | */ |
21 | IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 46 | @@ -XXX,XX +XXX,XX @@ |
22 | - bool is_write); | 47 | #define GICR_WAKER_ProcessorSleep (1U << 1) |
23 | + bool is_write, MemTxAttrs attrs); | 48 | #define GICR_WAKER_ChildrenAsleep (1U << 2) |
24 | 49 | ||
25 | /* address_space_translate: translate an address range into an address space | 50 | -#define GICR_PROPBASER_OUTER_CACHEABILITY_MASK (7ULL << 56) |
26 | * into a MemoryRegion and an address range into that section. Should be | 51 | -#define GICR_PROPBASER_ADDR_MASK (0xfffffffffULL << 12) |
27 | diff --git a/exec.c b/exec.c | 52 | -#define GICR_PROPBASER_SHAREABILITY_MASK (3U << 10) |
53 | -#define GICR_PROPBASER_CACHEABILITY_MASK (7U << 7) | ||
54 | -#define GICR_PROPBASER_IDBITS_MASK (0x1f) | ||
55 | +FIELD(GICR_PROPBASER, IDBITS, 0, 5) | ||
56 | +FIELD(GICR_PROPBASER, INNERCACHE, 7, 3) | ||
57 | +FIELD(GICR_PROPBASER, SHAREABILITY, 10, 2) | ||
58 | +FIELD(GICR_PROPBASER, PHYADDR, 12, 40) | ||
59 | +FIELD(GICR_PROPBASER, OUTERCACHE, 56, 3) | ||
60 | |||
61 | -#define GICR_PENDBASER_PTZ (1ULL << 62) | ||
62 | -#define GICR_PENDBASER_OUTER_CACHEABILITY_MASK (7ULL << 56) | ||
63 | -#define GICR_PENDBASER_ADDR_MASK (0xffffffffULL << 16) | ||
64 | -#define GICR_PENDBASER_SHAREABILITY_MASK (3U << 10) | ||
65 | -#define GICR_PENDBASER_CACHEABILITY_MASK (7U << 7) | ||
66 | +FIELD(GICR_PENDBASER, INNERCACHE, 7, 3) | ||
67 | +FIELD(GICR_PENDBASER, SHAREABILITY, 10, 2) | ||
68 | +FIELD(GICR_PENDBASER, PHYADDR, 16, 36) | ||
69 | +FIELD(GICR_PENDBASER, OUTERCACHE, 56, 3) | ||
70 | +FIELD(GICR_PENDBASER, PTZ, 62, 1) | ||
71 | |||
72 | #define ICC_CTLR_EL1_CBPR (1U << 0) | ||
73 | #define ICC_CTLR_EL1_EOIMODE (1U << 1) | ||
74 | @@ -XXX,XX +XXX,XX @@ | ||
75 | #define ICH_VTR_EL2_PREBITS_SHIFT 26 | ||
76 | #define ICH_VTR_EL2_PRIBITS_SHIFT 29 | ||
77 | |||
78 | +/* ITS Registers */ | ||
79 | + | ||
80 | +FIELD(GITS_BASER, SIZE, 0, 8) | ||
81 | +FIELD(GITS_BASER, PAGESIZE, 8, 2) | ||
82 | +FIELD(GITS_BASER, SHAREABILITY, 10, 2) | ||
83 | +FIELD(GITS_BASER, PHYADDR, 12, 36) | ||
84 | +FIELD(GITS_BASER, PHYADDRL_64K, 16, 32) | ||
85 | +FIELD(GITS_BASER, PHYADDRH_64K, 12, 4) | ||
86 | +FIELD(GITS_BASER, ENTRYSIZE, 48, 5) | ||
87 | +FIELD(GITS_BASER, OUTERCACHE, 53, 3) | ||
88 | +FIELD(GITS_BASER, TYPE, 56, 3) | ||
89 | +FIELD(GITS_BASER, INNERCACHE, 59, 3) | ||
90 | +FIELD(GITS_BASER, INDIRECT, 62, 1) | ||
91 | +FIELD(GITS_BASER, VALID, 63, 1) | ||
92 | + | ||
93 | +FIELD(GITS_CTLR, QUIESCENT, 31, 1) | ||
94 | + | ||
95 | +FIELD(GITS_TYPER, PHYSICAL, 0, 1) | ||
96 | +FIELD(GITS_TYPER, ITT_ENTRY_SIZE, 4, 4) | ||
97 | +FIELD(GITS_TYPER, IDBITS, 8, 5) | ||
98 | +FIELD(GITS_TYPER, DEVBITS, 13, 5) | ||
99 | +FIELD(GITS_TYPER, SEIS, 18, 1) | ||
100 | +FIELD(GITS_TYPER, PTA, 19, 1) | ||
101 | +FIELD(GITS_TYPER, CIDBITS, 32, 4) | ||
102 | +FIELD(GITS_TYPER, CIL, 36, 1) | ||
103 | + | ||
104 | +#define GITS_BASER_PAGESIZE_4K 0 | ||
105 | +#define GITS_BASER_PAGESIZE_16K 1 | ||
106 | +#define GITS_BASER_PAGESIZE_64K 2 | ||
107 | + | ||
108 | +#define GITS_BASER_TYPE_DEVICE 1ULL | ||
109 | +#define GITS_BASER_TYPE_COLLECTION 4ULL | ||
110 | + | ||
111 | +/** | ||
112 | + * Default features advertised by this version of ITS | ||
113 | + */ | ||
114 | +/* Physical LPIs supported */ | ||
115 | +#define GITS_TYPE_PHYSICAL (1U << 0) | ||
116 | + | ||
117 | +/* | ||
118 | + * 12 bytes Interrupt translation Table Entry size | ||
119 | + * as per Table 5.3 in GICv3 spec | ||
120 | + * ITE Lower 8 Bytes | ||
121 | + * Bits: | 49 ... 26 | 25 ... 2 | 1 | 0 | | ||
122 | + * Values: | 1023 | IntNum | IntType | Valid | | ||
123 | + * ITE Higher 4 Bytes | ||
124 | + * Bits: | 31 ... 16 | 15 ...0 | | ||
125 | + * Values: | vPEID | ICID | | ||
126 | + */ | ||
127 | +#define ITS_ITT_ENTRY_SIZE 0xC | ||
128 | + | ||
129 | +/* 16 bits EventId */ | ||
130 | +#define ITS_IDBITS GICD_TYPER_IDBITS | ||
131 | + | ||
132 | +/* 16 bits DeviceId */ | ||
133 | +#define ITS_DEVBITS 0xF | ||
134 | + | ||
135 | +/* 16 bits CollectionId */ | ||
136 | +#define ITS_CIDBITS 0xF | ||
137 | + | ||
138 | +/* | ||
139 | + * 8 bytes Device Table Entry size | ||
140 | + * Valid = 1 bit,ITTAddr = 44 bits,Size = 5 bits | ||
141 | + */ | ||
142 | +#define GITS_DTE_SIZE (0x8ULL) | ||
143 | + | ||
144 | +/* | ||
145 | + * 8 bytes Collection Table Entry size | ||
146 | + * Valid = 1 bit,RDBase = 36 bits(considering max RDBASE) | ||
147 | + */ | ||
148 | +#define GITS_CTE_SIZE (0x8ULL) | ||
149 | + | ||
150 | /* Special interrupt IDs */ | ||
151 | #define INTID_SECURE 1020 | ||
152 | #define INTID_NONSECURE 1021 | ||
153 | diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_gicv3_its_common.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | 154 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/exec.c | 155 | --- a/include/hw/intc/arm_gicv3_its_common.h |
30 | +++ b/exec.c | 156 | +++ b/include/hw/intc/arm_gicv3_its_common.h |
31 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | 157 | @@ -XXX,XX +XXX,XX @@ |
32 | 158 | #include "hw/intc/arm_gicv3_common.h" | |
33 | /* Called from RCU critical section */ | 159 | #include "qom/object.h" |
34 | IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 160 | |
35 | - bool is_write) | 161 | +#define TYPE_ARM_GICV3_ITS "arm-gicv3-its" |
36 | + bool is_write, MemTxAttrs attrs) | 162 | + |
163 | #define ITS_CONTROL_SIZE 0x10000 | ||
164 | #define ITS_TRANS_SIZE 0x10000 | ||
165 | #define ITS_SIZE (ITS_CONTROL_SIZE + ITS_TRANS_SIZE) | ||
166 | |||
167 | #define GITS_CTLR 0x0 | ||
168 | #define GITS_IIDR 0x4 | ||
169 | +#define GITS_TYPER 0x8 | ||
170 | #define GITS_CBASER 0x80 | ||
171 | #define GITS_CWRITER 0x88 | ||
172 | #define GITS_CREADR 0x90 | ||
173 | #define GITS_BASER 0x100 | ||
174 | |||
175 | +#define GITS_TRANSLATER 0x0040 | ||
176 | + | ||
177 | struct GICv3ITSState { | ||
178 | SysBusDevice parent_obj; | ||
179 | |||
180 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSState { | ||
181 | /* Registers */ | ||
182 | uint32_t ctlr; | ||
183 | uint32_t iidr; | ||
184 | + uint64_t typer; | ||
185 | uint64_t cbaser; | ||
186 | uint64_t cwriter; | ||
187 | uint64_t creadr; | ||
188 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSState { | ||
189 | |||
190 | typedef struct GICv3ITSState GICv3ITSState; | ||
191 | |||
192 | -void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops); | ||
193 | +void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops, | ||
194 | + const MemoryRegionOps *tops); | ||
195 | |||
196 | #define TYPE_ARM_GICV3_ITS_COMMON "arm-gicv3-its-common" | ||
197 | typedef struct GICv3ITSCommonClass GICv3ITSCommonClass; | ||
198 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
199 | new file mode 100644 | ||
200 | index XXXXXXX..XXXXXXX | ||
201 | --- /dev/null | ||
202 | +++ b/hw/intc/arm_gicv3_its.c | ||
203 | @@ -XXX,XX +XXX,XX @@ | ||
204 | +/* | ||
205 | + * ITS emulation for a GICv3-based system | ||
206 | + * | ||
207 | + * Copyright Linaro.org 2021 | ||
208 | + * | ||
209 | + * Authors: | ||
210 | + * Shashi Mallela <shashi.mallela@linaro.org> | ||
211 | + * | ||
212 | + * This work is licensed under the terms of the GNU GPL, version 2 or (at your | ||
213 | + * option) any later version. See the COPYING file in the top-level directory. | ||
214 | + * | ||
215 | + */ | ||
216 | + | ||
217 | +#include "qemu/osdep.h" | ||
218 | +#include "qemu/log.h" | ||
219 | +#include "hw/qdev-properties.h" | ||
220 | +#include "hw/intc/arm_gicv3_its_common.h" | ||
221 | +#include "gicv3_internal.h" | ||
222 | +#include "qom/object.h" | ||
223 | +#include "qapi/error.h" | ||
224 | + | ||
225 | +typedef struct GICv3ITSClass GICv3ITSClass; | ||
226 | +/* This is reusing the GICv3ITSState typedef from ARM_GICV3_ITS_COMMON */ | ||
227 | +DECLARE_OBJ_CHECKERS(GICv3ITSState, GICv3ITSClass, | ||
228 | + ARM_GICV3_ITS, TYPE_ARM_GICV3_ITS) | ||
229 | + | ||
230 | +struct GICv3ITSClass { | ||
231 | + GICv3ITSCommonClass parent_class; | ||
232 | + void (*parent_reset)(DeviceState *dev); | ||
233 | +}; | ||
234 | + | ||
235 | +static MemTxResult gicv3_its_translation_write(void *opaque, hwaddr offset, | ||
236 | + uint64_t data, unsigned size, | ||
237 | + MemTxAttrs attrs) | ||
238 | +{ | ||
239 | + return MEMTX_OK; | ||
240 | +} | ||
241 | + | ||
242 | +static bool its_writel(GICv3ITSState *s, hwaddr offset, | ||
243 | + uint64_t value, MemTxAttrs attrs) | ||
244 | +{ | ||
245 | + bool result = true; | ||
246 | + | ||
247 | + return result; | ||
248 | +} | ||
249 | + | ||
250 | +static bool its_readl(GICv3ITSState *s, hwaddr offset, | ||
251 | + uint64_t *data, MemTxAttrs attrs) | ||
252 | +{ | ||
253 | + bool result = true; | ||
254 | + | ||
255 | + return result; | ||
256 | +} | ||
257 | + | ||
258 | +static bool its_writell(GICv3ITSState *s, hwaddr offset, | ||
259 | + uint64_t value, MemTxAttrs attrs) | ||
260 | +{ | ||
261 | + bool result = true; | ||
262 | + | ||
263 | + return result; | ||
264 | +} | ||
265 | + | ||
266 | +static bool its_readll(GICv3ITSState *s, hwaddr offset, | ||
267 | + uint64_t *data, MemTxAttrs attrs) | ||
268 | +{ | ||
269 | + bool result = true; | ||
270 | + | ||
271 | + return result; | ||
272 | +} | ||
273 | + | ||
274 | +static MemTxResult gicv3_its_read(void *opaque, hwaddr offset, uint64_t *data, | ||
275 | + unsigned size, MemTxAttrs attrs) | ||
276 | +{ | ||
277 | + GICv3ITSState *s = (GICv3ITSState *)opaque; | ||
278 | + bool result; | ||
279 | + | ||
280 | + switch (size) { | ||
281 | + case 4: | ||
282 | + result = its_readl(s, offset, data, attrs); | ||
283 | + break; | ||
284 | + case 8: | ||
285 | + result = its_readll(s, offset, data, attrs); | ||
286 | + break; | ||
287 | + default: | ||
288 | + result = false; | ||
289 | + break; | ||
290 | + } | ||
291 | + | ||
292 | + if (!result) { | ||
293 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
294 | + "%s: invalid guest read at offset " TARGET_FMT_plx | ||
295 | + "size %u\n", __func__, offset, size); | ||
296 | + /* | ||
297 | + * The spec requires that reserved registers are RAZ/WI; | ||
298 | + * so use false returns from leaf functions as a way to | ||
299 | + * trigger the guest-error logging but don't return it to | ||
300 | + * the caller, or we'll cause a spurious guest data abort. | ||
301 | + */ | ||
302 | + *data = 0; | ||
303 | + } | ||
304 | + return MEMTX_OK; | ||
305 | +} | ||
306 | + | ||
307 | +static MemTxResult gicv3_its_write(void *opaque, hwaddr offset, uint64_t data, | ||
308 | + unsigned size, MemTxAttrs attrs) | ||
309 | +{ | ||
310 | + GICv3ITSState *s = (GICv3ITSState *)opaque; | ||
311 | + bool result; | ||
312 | + | ||
313 | + switch (size) { | ||
314 | + case 4: | ||
315 | + result = its_writel(s, offset, data, attrs); | ||
316 | + break; | ||
317 | + case 8: | ||
318 | + result = its_writell(s, offset, data, attrs); | ||
319 | + break; | ||
320 | + default: | ||
321 | + result = false; | ||
322 | + break; | ||
323 | + } | ||
324 | + | ||
325 | + if (!result) { | ||
326 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
327 | + "%s: invalid guest write at offset " TARGET_FMT_plx | ||
328 | + "size %u\n", __func__, offset, size); | ||
329 | + /* | ||
330 | + * The spec requires that reserved registers are RAZ/WI; | ||
331 | + * so use false returns from leaf functions as a way to | ||
332 | + * trigger the guest-error logging but don't return it to | ||
333 | + * the caller, or we'll cause a spurious guest data abort. | ||
334 | + */ | ||
335 | + } | ||
336 | + return MEMTX_OK; | ||
337 | +} | ||
338 | + | ||
339 | +static const MemoryRegionOps gicv3_its_control_ops = { | ||
340 | + .read_with_attrs = gicv3_its_read, | ||
341 | + .write_with_attrs = gicv3_its_write, | ||
342 | + .valid.min_access_size = 4, | ||
343 | + .valid.max_access_size = 8, | ||
344 | + .impl.min_access_size = 4, | ||
345 | + .impl.max_access_size = 8, | ||
346 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
347 | +}; | ||
348 | + | ||
349 | +static const MemoryRegionOps gicv3_its_translation_ops = { | ||
350 | + .write_with_attrs = gicv3_its_translation_write, | ||
351 | + .valid.min_access_size = 2, | ||
352 | + .valid.max_access_size = 4, | ||
353 | + .impl.min_access_size = 2, | ||
354 | + .impl.max_access_size = 4, | ||
355 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
356 | +}; | ||
357 | + | ||
358 | +static void gicv3_arm_its_realize(DeviceState *dev, Error **errp) | ||
359 | +{ | ||
360 | + GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | ||
361 | + int i; | ||
362 | + | ||
363 | + for (i = 0; i < s->gicv3->num_cpu; i++) { | ||
364 | + if (!(s->gicv3->cpu[i].gicr_typer & GICR_TYPER_PLPIS)) { | ||
365 | + error_setg(errp, "Physical LPI not supported by CPU %d", i); | ||
366 | + return; | ||
367 | + } | ||
368 | + } | ||
369 | + | ||
370 | + gicv3_its_init_mmio(s, &gicv3_its_control_ops, &gicv3_its_translation_ops); | ||
371 | + | ||
372 | + /* set the ITS default features supported */ | ||
373 | + s->typer = FIELD_DP64(s->typer, GITS_TYPER, PHYSICAL, | ||
374 | + GITS_TYPE_PHYSICAL); | ||
375 | + s->typer = FIELD_DP64(s->typer, GITS_TYPER, ITT_ENTRY_SIZE, | ||
376 | + ITS_ITT_ENTRY_SIZE - 1); | ||
377 | + s->typer = FIELD_DP64(s->typer, GITS_TYPER, IDBITS, ITS_IDBITS); | ||
378 | + s->typer = FIELD_DP64(s->typer, GITS_TYPER, DEVBITS, ITS_DEVBITS); | ||
379 | + s->typer = FIELD_DP64(s->typer, GITS_TYPER, CIL, 1); | ||
380 | + s->typer = FIELD_DP64(s->typer, GITS_TYPER, CIDBITS, ITS_CIDBITS); | ||
381 | +} | ||
382 | + | ||
383 | +static void gicv3_its_reset(DeviceState *dev) | ||
384 | +{ | ||
385 | + GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | ||
386 | + GICv3ITSClass *c = ARM_GICV3_ITS_GET_CLASS(s); | ||
387 | + | ||
388 | + c->parent_reset(dev); | ||
389 | + | ||
390 | + /* Quiescent bit reset to 1 */ | ||
391 | + s->ctlr = FIELD_DP32(s->ctlr, GITS_CTLR, QUIESCENT, 1); | ||
392 | + | ||
393 | + /* | ||
394 | + * setting GITS_BASER0.Type = 0b001 (Device) | ||
395 | + * GITS_BASER1.Type = 0b100 (Collection Table) | ||
396 | + * GITS_BASER<n>.Type,where n = 3 to 7 are 0b00 (Unimplemented) | ||
397 | + * GITS_BASER<0,1>.Page_Size = 64KB | ||
398 | + * and default translation table entry size to 16 bytes | ||
399 | + */ | ||
400 | + s->baser[0] = FIELD_DP64(s->baser[0], GITS_BASER, TYPE, | ||
401 | + GITS_BASER_TYPE_DEVICE); | ||
402 | + s->baser[0] = FIELD_DP64(s->baser[0], GITS_BASER, PAGESIZE, | ||
403 | + GITS_BASER_PAGESIZE_64K); | ||
404 | + s->baser[0] = FIELD_DP64(s->baser[0], GITS_BASER, ENTRYSIZE, | ||
405 | + GITS_DTE_SIZE - 1); | ||
406 | + | ||
407 | + s->baser[1] = FIELD_DP64(s->baser[1], GITS_BASER, TYPE, | ||
408 | + GITS_BASER_TYPE_COLLECTION); | ||
409 | + s->baser[1] = FIELD_DP64(s->baser[1], GITS_BASER, PAGESIZE, | ||
410 | + GITS_BASER_PAGESIZE_64K); | ||
411 | + s->baser[1] = FIELD_DP64(s->baser[1], GITS_BASER, ENTRYSIZE, | ||
412 | + GITS_CTE_SIZE - 1); | ||
413 | +} | ||
414 | + | ||
415 | +static Property gicv3_its_props[] = { | ||
416 | + DEFINE_PROP_LINK("parent-gicv3", GICv3ITSState, gicv3, "arm-gicv3", | ||
417 | + GICv3State *), | ||
418 | + DEFINE_PROP_END_OF_LIST(), | ||
419 | +}; | ||
420 | + | ||
421 | +static void gicv3_its_class_init(ObjectClass *klass, void *data) | ||
422 | +{ | ||
423 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
424 | + GICv3ITSClass *ic = ARM_GICV3_ITS_CLASS(klass); | ||
425 | + | ||
426 | + dc->realize = gicv3_arm_its_realize; | ||
427 | + device_class_set_props(dc, gicv3_its_props); | ||
428 | + device_class_set_parent_reset(dc, gicv3_its_reset, &ic->parent_reset); | ||
429 | +} | ||
430 | + | ||
431 | +static const TypeInfo gicv3_its_info = { | ||
432 | + .name = TYPE_ARM_GICV3_ITS, | ||
433 | + .parent = TYPE_ARM_GICV3_ITS_COMMON, | ||
434 | + .instance_size = sizeof(GICv3ITSState), | ||
435 | + .class_init = gicv3_its_class_init, | ||
436 | + .class_size = sizeof(GICv3ITSClass), | ||
437 | +}; | ||
438 | + | ||
439 | +static void gicv3_its_register_types(void) | ||
440 | +{ | ||
441 | + type_register_static(&gicv3_its_info); | ||
442 | +} | ||
443 | + | ||
444 | +type_init(gicv3_its_register_types) | ||
445 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | ||
446 | index XXXXXXX..XXXXXXX 100644 | ||
447 | --- a/hw/intc/arm_gicv3_its_common.c | ||
448 | +++ b/hw/intc/arm_gicv3_its_common.c | ||
449 | @@ -XXX,XX +XXX,XX @@ static int gicv3_its_post_load(void *opaque, int version_id) | ||
450 | |||
451 | static const VMStateDescription vmstate_its = { | ||
452 | .name = "arm_gicv3_its", | ||
453 | + .version_id = 1, | ||
454 | + .minimum_version_id = 1, | ||
455 | .pre_save = gicv3_its_pre_save, | ||
456 | .post_load = gicv3_its_post_load, | ||
457 | .priority = MIG_PRI_GICV3_ITS, | ||
458 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps gicv3_its_trans_ops = { | ||
459 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
460 | }; | ||
461 | |||
462 | -void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops) | ||
463 | +void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops, | ||
464 | + const MemoryRegionOps *tops) | ||
37 | { | 465 | { |
38 | MemoryRegionSection section; | 466 | SysBusDevice *sbd = SYS_BUS_DEVICE(s); |
39 | hwaddr xlat, page_mask; | 467 | |
40 | diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c | 468 | memory_region_init_io(&s->iomem_its_cntrl, OBJECT(s), ops, s, |
469 | "control", ITS_CONTROL_SIZE); | ||
470 | memory_region_init_io(&s->iomem_its_translation, OBJECT(s), | ||
471 | - &gicv3_its_trans_ops, s, | ||
472 | + tops ? tops : &gicv3_its_trans_ops, s, | ||
473 | "translation", ITS_TRANS_SIZE); | ||
474 | |||
475 | /* Our two regions are always adjacent, therefore we now combine them | ||
476 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | 477 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/hw/virtio/vhost.c | 478 | --- a/hw/intc/arm_gicv3_its_kvm.c |
43 | +++ b/hw/virtio/vhost.c | 479 | +++ b/hw/intc/arm_gicv3_its_kvm.c |
44 | @@ -XXX,XX +XXX,XX @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write) | 480 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) |
45 | trace_vhost_iotlb_miss(dev, 1); | 481 | kvm_arm_register_device(&s->iomem_its_cntrl, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, |
46 | 482 | KVM_VGIC_ITS_ADDR_TYPE, s->dev_fd, 0); | |
47 | iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as, | 483 | |
48 | - iova, write); | 484 | - gicv3_its_init_mmio(s, NULL); |
49 | + iova, write, | 485 | + gicv3_its_init_mmio(s, NULL, NULL); |
50 | + MEMTXATTRS_UNSPECIFIED); | 486 | |
51 | if (iotlb.target_as != NULL) { | 487 | if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, |
52 | ret = vhost_memory_region_lookup(dev, iotlb.translated_addr, | 488 | GITS_CTLR)) { |
53 | &uaddr, &len); | 489 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build |
490 | index XXXXXXX..XXXXXXX 100644 | ||
491 | --- a/hw/intc/meson.build | ||
492 | +++ b/hw/intc/meson.build | ||
493 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARM_GIC', if_true: files( | ||
494 | 'arm_gicv3_dist.c', | ||
495 | 'arm_gicv3_its_common.c', | ||
496 | 'arm_gicv3_redist.c', | ||
497 | + 'arm_gicv3_its.c', | ||
498 | )) | ||
499 | softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_pic.c')) | ||
500 | softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true: files('heathrow_pic.c')) | ||
54 | -- | 501 | -- |
55 | 2.17.1 | 502 | 2.20.1 |
56 | 503 | ||
57 | 504 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to the MemoryRegion valid.accepts | ||
3 | callback. We'll need this for subpage_accepts(). | ||
4 | 2 | ||
5 | We could take the approach we used with the read and write | 3 | Defined descriptors for ITS device table,collection table and ITS |
6 | callbacks and add new a new _with_attrs version, but since there | 4 | command queue entities.Implemented register read/write functions, |
7 | are so few implementations of the accepts hook we just change | 5 | extract ITS table parameters and command queue parameters,extended |
8 | them all. | 6 | gicv3 common to capture qemu address space(which host the ITS table |
7 | platform memories required for subsequent ITS processing) and | ||
8 | initialize the same in ITS device. | ||
9 | 9 | ||
10 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Tested-by: Neil Armstrong <narmstrong@baylibre.com> | ||
14 | Message-id: 20210910143951.92242-3-shashi.mallela@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20180521140402.23318-9-peter.maydell@linaro.org | ||
14 | --- | 16 | --- |
15 | include/exec/memory.h | 3 ++- | 17 | hw/intc/gicv3_internal.h | 29 ++ |
16 | exec.c | 9 ++++++--- | 18 | include/hw/intc/arm_gicv3_common.h | 3 + |
17 | hw/hppa/dino.c | 3 ++- | 19 | include/hw/intc/arm_gicv3_its_common.h | 23 ++ |
18 | hw/nvram/fw_cfg.c | 12 ++++++++---- | 20 | hw/intc/arm_gicv3_its.c | 376 +++++++++++++++++++++++++ |
19 | hw/scsi/esp.c | 3 ++- | 21 | 4 files changed, 431 insertions(+) |
20 | hw/xen/xen_pt_msi.c | 3 ++- | ||
21 | memory.c | 5 +++-- | ||
22 | 7 files changed, 25 insertions(+), 13 deletions(-) | ||
23 | 22 | ||
24 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 23 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h |
25 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/exec/memory.h | 25 | --- a/hw/intc/gicv3_internal.h |
27 | +++ b/include/exec/memory.h | 26 | +++ b/hw/intc/gicv3_internal.h |
28 | @@ -XXX,XX +XXX,XX @@ struct MemoryRegionOps { | 27 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_BASER, INNERCACHE, 59, 3) |
29 | * as a machine check exception). | 28 | FIELD(GITS_BASER, INDIRECT, 62, 1) |
30 | */ | 29 | FIELD(GITS_BASER, VALID, 63, 1) |
31 | bool (*accepts)(void *opaque, hwaddr addr, | 30 | |
32 | - unsigned size, bool is_write); | 31 | +FIELD(GITS_CBASER, SIZE, 0, 8) |
33 | + unsigned size, bool is_write, | 32 | +FIELD(GITS_CBASER, SHAREABILITY, 10, 2) |
34 | + MemTxAttrs attrs); | 33 | +FIELD(GITS_CBASER, PHYADDR, 12, 40) |
35 | } valid; | 34 | +FIELD(GITS_CBASER, OUTERCACHE, 53, 3) |
36 | /* Internal implementation constraints: */ | 35 | +FIELD(GITS_CBASER, INNERCACHE, 59, 3) |
37 | struct { | 36 | +FIELD(GITS_CBASER, VALID, 63, 1) |
38 | diff --git a/exec.c b/exec.c | 37 | + |
38 | +FIELD(GITS_CREADR, STALLED, 0, 1) | ||
39 | +FIELD(GITS_CREADR, OFFSET, 5, 15) | ||
40 | + | ||
41 | +FIELD(GITS_CWRITER, RETRY, 0, 1) | ||
42 | +FIELD(GITS_CWRITER, OFFSET, 5, 15) | ||
43 | + | ||
44 | +FIELD(GITS_CTLR, ENABLED, 0, 1) | ||
45 | FIELD(GITS_CTLR, QUIESCENT, 31, 1) | ||
46 | |||
47 | FIELD(GITS_TYPER, PHYSICAL, 0, 1) | ||
48 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, PTA, 19, 1) | ||
49 | FIELD(GITS_TYPER, CIDBITS, 32, 4) | ||
50 | FIELD(GITS_TYPER, CIL, 36, 1) | ||
51 | |||
52 | +#define GITS_IDREGS 0xFFD0 | ||
53 | + | ||
54 | +#define ITS_CTLR_ENABLED (1U) /* ITS Enabled */ | ||
55 | + | ||
56 | +#define GITS_BASER_RO_MASK (R_GITS_BASER_ENTRYSIZE_MASK | \ | ||
57 | + R_GITS_BASER_TYPE_MASK) | ||
58 | + | ||
59 | #define GITS_BASER_PAGESIZE_4K 0 | ||
60 | #define GITS_BASER_PAGESIZE_16K 1 | ||
61 | #define GITS_BASER_PAGESIZE_64K 2 | ||
62 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
63 | #define GITS_BASER_TYPE_DEVICE 1ULL | ||
64 | #define GITS_BASER_TYPE_COLLECTION 4ULL | ||
65 | |||
66 | +#define GITS_PAGE_SIZE_4K 0x1000 | ||
67 | +#define GITS_PAGE_SIZE_16K 0x4000 | ||
68 | +#define GITS_PAGE_SIZE_64K 0x10000 | ||
69 | + | ||
70 | +#define L1TABLE_ENTRY_SIZE 8 | ||
71 | + | ||
72 | +#define GITS_CMDQ_ENTRY_SIZE 32 | ||
73 | + | ||
74 | /** | ||
75 | * Default features advertised by this version of ITS | ||
76 | */ | ||
77 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | 78 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/exec.c | 79 | --- a/include/hw/intc/arm_gicv3_common.h |
41 | +++ b/exec.c | 80 | +++ b/include/hw/intc/arm_gicv3_common.h |
42 | @@ -XXX,XX +XXX,XX @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr, | 81 | @@ -XXX,XX +XXX,XX @@ struct GICv3State { |
82 | int dev_fd; /* kvm device fd if backed by kvm vgic support */ | ||
83 | Error *migration_blocker; | ||
84 | |||
85 | + MemoryRegion *dma; | ||
86 | + AddressSpace dma_as; | ||
87 | + | ||
88 | /* Distributor */ | ||
89 | |||
90 | /* for a GIC with the security extensions the NS banked version of this | ||
91 | diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_gicv3_its_common.h | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/include/hw/intc/arm_gicv3_its_common.h | ||
94 | +++ b/include/hw/intc/arm_gicv3_its_common.h | ||
95 | @@ -XXX,XX +XXX,XX @@ | ||
96 | |||
97 | #define GITS_TRANSLATER 0x0040 | ||
98 | |||
99 | +typedef struct { | ||
100 | + bool valid; | ||
101 | + bool indirect; | ||
102 | + uint16_t entry_sz; | ||
103 | + uint32_t page_sz; | ||
104 | + uint32_t max_entries; | ||
105 | + union { | ||
106 | + uint32_t max_devids; | ||
107 | + uint32_t max_collids; | ||
108 | + } maxids; | ||
109 | + uint64_t base_addr; | ||
110 | +} TableDesc; | ||
111 | + | ||
112 | +typedef struct { | ||
113 | + bool valid; | ||
114 | + uint32_t max_entries; | ||
115 | + uint64_t base_addr; | ||
116 | +} CmdQDesc; | ||
117 | + | ||
118 | struct GICv3ITSState { | ||
119 | SysBusDevice parent_obj; | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSState { | ||
122 | uint64_t creadr; | ||
123 | uint64_t baser[8]; | ||
124 | |||
125 | + TableDesc dt; | ||
126 | + TableDesc ct; | ||
127 | + CmdQDesc cq; | ||
128 | + | ||
129 | Error *migration_blocker; | ||
130 | }; | ||
131 | |||
132 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/hw/intc/arm_gicv3_its.c | ||
135 | +++ b/hw/intc/arm_gicv3_its.c | ||
136 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSClass { | ||
137 | void (*parent_reset)(DeviceState *dev); | ||
138 | }; | ||
139 | |||
140 | +static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) | ||
141 | +{ | ||
142 | + uint64_t result = 0; | ||
143 | + | ||
144 | + switch (page_sz) { | ||
145 | + case GITS_PAGE_SIZE_4K: | ||
146 | + case GITS_PAGE_SIZE_16K: | ||
147 | + result = FIELD_EX64(value, GITS_BASER, PHYADDR) << 12; | ||
148 | + break; | ||
149 | + | ||
150 | + case GITS_PAGE_SIZE_64K: | ||
151 | + result = FIELD_EX64(value, GITS_BASER, PHYADDRL_64K) << 16; | ||
152 | + result |= FIELD_EX64(value, GITS_BASER, PHYADDRH_64K) << 48; | ||
153 | + break; | ||
154 | + | ||
155 | + default: | ||
156 | + break; | ||
157 | + } | ||
158 | + return result; | ||
159 | +} | ||
160 | + | ||
161 | +/* | ||
162 | + * This function extracts the ITS Device and Collection table specific | ||
163 | + * parameters (like base_addr, size etc) from GITS_BASER register. | ||
164 | + * It is called during ITS enable and also during post_load migration | ||
165 | + */ | ||
166 | +static void extract_table_params(GICv3ITSState *s) | ||
167 | +{ | ||
168 | + uint16_t num_pages = 0; | ||
169 | + uint8_t page_sz_type; | ||
170 | + uint8_t type; | ||
171 | + uint32_t page_sz = 0; | ||
172 | + uint64_t value; | ||
173 | + | ||
174 | + for (int i = 0; i < 8; i++) { | ||
175 | + value = s->baser[i]; | ||
176 | + | ||
177 | + if (!value) { | ||
178 | + continue; | ||
179 | + } | ||
180 | + | ||
181 | + page_sz_type = FIELD_EX64(value, GITS_BASER, PAGESIZE); | ||
182 | + | ||
183 | + switch (page_sz_type) { | ||
184 | + case 0: | ||
185 | + page_sz = GITS_PAGE_SIZE_4K; | ||
186 | + break; | ||
187 | + | ||
188 | + case 1: | ||
189 | + page_sz = GITS_PAGE_SIZE_16K; | ||
190 | + break; | ||
191 | + | ||
192 | + case 2: | ||
193 | + case 3: | ||
194 | + page_sz = GITS_PAGE_SIZE_64K; | ||
195 | + break; | ||
196 | + | ||
197 | + default: | ||
198 | + g_assert_not_reached(); | ||
199 | + } | ||
200 | + | ||
201 | + num_pages = FIELD_EX64(value, GITS_BASER, SIZE) + 1; | ||
202 | + | ||
203 | + type = FIELD_EX64(value, GITS_BASER, TYPE); | ||
204 | + | ||
205 | + switch (type) { | ||
206 | + | ||
207 | + case GITS_BASER_TYPE_DEVICE: | ||
208 | + memset(&s->dt, 0 , sizeof(s->dt)); | ||
209 | + s->dt.valid = FIELD_EX64(value, GITS_BASER, VALID); | ||
210 | + | ||
211 | + if (!s->dt.valid) { | ||
212 | + return; | ||
213 | + } | ||
214 | + | ||
215 | + s->dt.page_sz = page_sz; | ||
216 | + s->dt.indirect = FIELD_EX64(value, GITS_BASER, INDIRECT); | ||
217 | + s->dt.entry_sz = FIELD_EX64(value, GITS_BASER, ENTRYSIZE); | ||
218 | + | ||
219 | + if (!s->dt.indirect) { | ||
220 | + s->dt.max_entries = (num_pages * page_sz) / s->dt.entry_sz; | ||
221 | + } else { | ||
222 | + s->dt.max_entries = (((num_pages * page_sz) / | ||
223 | + L1TABLE_ENTRY_SIZE) * | ||
224 | + (page_sz / s->dt.entry_sz)); | ||
225 | + } | ||
226 | + | ||
227 | + s->dt.maxids.max_devids = (1UL << (FIELD_EX64(s->typer, GITS_TYPER, | ||
228 | + DEVBITS) + 1)); | ||
229 | + | ||
230 | + s->dt.base_addr = baser_base_addr(value, page_sz); | ||
231 | + | ||
232 | + break; | ||
233 | + | ||
234 | + case GITS_BASER_TYPE_COLLECTION: | ||
235 | + memset(&s->ct, 0 , sizeof(s->ct)); | ||
236 | + s->ct.valid = FIELD_EX64(value, GITS_BASER, VALID); | ||
237 | + | ||
238 | + /* | ||
239 | + * GITS_TYPER.HCC is 0 for this implementation | ||
240 | + * hence writes are discarded if ct.valid is 0 | ||
241 | + */ | ||
242 | + if (!s->ct.valid) { | ||
243 | + return; | ||
244 | + } | ||
245 | + | ||
246 | + s->ct.page_sz = page_sz; | ||
247 | + s->ct.indirect = FIELD_EX64(value, GITS_BASER, INDIRECT); | ||
248 | + s->ct.entry_sz = FIELD_EX64(value, GITS_BASER, ENTRYSIZE); | ||
249 | + | ||
250 | + if (!s->ct.indirect) { | ||
251 | + s->ct.max_entries = (num_pages * page_sz) / s->ct.entry_sz; | ||
252 | + } else { | ||
253 | + s->ct.max_entries = (((num_pages * page_sz) / | ||
254 | + L1TABLE_ENTRY_SIZE) * | ||
255 | + (page_sz / s->ct.entry_sz)); | ||
256 | + } | ||
257 | + | ||
258 | + if (FIELD_EX64(s->typer, GITS_TYPER, CIL)) { | ||
259 | + s->ct.maxids.max_collids = (1UL << (FIELD_EX64(s->typer, | ||
260 | + GITS_TYPER, CIDBITS) + 1)); | ||
261 | + } else { | ||
262 | + /* 16-bit CollectionId supported when CIL == 0 */ | ||
263 | + s->ct.maxids.max_collids = (1UL << 16); | ||
264 | + } | ||
265 | + | ||
266 | + s->ct.base_addr = baser_base_addr(value, page_sz); | ||
267 | + | ||
268 | + break; | ||
269 | + | ||
270 | + default: | ||
271 | + break; | ||
272 | + } | ||
273 | + } | ||
274 | +} | ||
275 | + | ||
276 | +static void extract_cmdq_params(GICv3ITSState *s) | ||
277 | +{ | ||
278 | + uint16_t num_pages = 0; | ||
279 | + uint64_t value = s->cbaser; | ||
280 | + | ||
281 | + num_pages = FIELD_EX64(value, GITS_CBASER, SIZE) + 1; | ||
282 | + | ||
283 | + memset(&s->cq, 0 , sizeof(s->cq)); | ||
284 | + s->cq.valid = FIELD_EX64(value, GITS_CBASER, VALID); | ||
285 | + | ||
286 | + if (s->cq.valid) { | ||
287 | + s->cq.max_entries = (num_pages * GITS_PAGE_SIZE_4K) / | ||
288 | + GITS_CMDQ_ENTRY_SIZE; | ||
289 | + s->cq.base_addr = FIELD_EX64(value, GITS_CBASER, PHYADDR); | ||
290 | + s->cq.base_addr <<= R_GITS_CBASER_PHYADDR_SHIFT; | ||
291 | + } | ||
292 | +} | ||
293 | + | ||
294 | static MemTxResult gicv3_its_translation_write(void *opaque, hwaddr offset, | ||
295 | uint64_t data, unsigned size, | ||
296 | MemTxAttrs attrs) | ||
297 | @@ -XXX,XX +XXX,XX @@ static bool its_writel(GICv3ITSState *s, hwaddr offset, | ||
298 | uint64_t value, MemTxAttrs attrs) | ||
299 | { | ||
300 | bool result = true; | ||
301 | + int index; | ||
302 | |||
303 | + switch (offset) { | ||
304 | + case GITS_CTLR: | ||
305 | + s->ctlr |= (value & ~(s->ctlr)); | ||
306 | + | ||
307 | + if (s->ctlr & ITS_CTLR_ENABLED) { | ||
308 | + extract_table_params(s); | ||
309 | + extract_cmdq_params(s); | ||
310 | + s->creadr = 0; | ||
311 | + } | ||
312 | + break; | ||
313 | + case GITS_CBASER: | ||
314 | + /* | ||
315 | + * IMPDEF choice:- GITS_CBASER register becomes RO if ITS is | ||
316 | + * already enabled | ||
317 | + */ | ||
318 | + if (!(s->ctlr & ITS_CTLR_ENABLED)) { | ||
319 | + s->cbaser = deposit64(s->cbaser, 0, 32, value); | ||
320 | + s->creadr = 0; | ||
321 | + s->cwriter = s->creadr; | ||
322 | + } | ||
323 | + break; | ||
324 | + case GITS_CBASER + 4: | ||
325 | + /* | ||
326 | + * IMPDEF choice:- GITS_CBASER register becomes RO if ITS is | ||
327 | + * already enabled | ||
328 | + */ | ||
329 | + if (!(s->ctlr & ITS_CTLR_ENABLED)) { | ||
330 | + s->cbaser = deposit64(s->cbaser, 32, 32, value); | ||
331 | + s->creadr = 0; | ||
332 | + s->cwriter = s->creadr; | ||
333 | + } | ||
334 | + break; | ||
335 | + case GITS_CWRITER: | ||
336 | + s->cwriter = deposit64(s->cwriter, 0, 32, | ||
337 | + (value & ~R_GITS_CWRITER_RETRY_MASK)); | ||
338 | + break; | ||
339 | + case GITS_CWRITER + 4: | ||
340 | + s->cwriter = deposit64(s->cwriter, 32, 32, value); | ||
341 | + break; | ||
342 | + case GITS_CREADR: | ||
343 | + if (s->gicv3->gicd_ctlr & GICD_CTLR_DS) { | ||
344 | + s->creadr = deposit64(s->creadr, 0, 32, | ||
345 | + (value & ~R_GITS_CREADR_STALLED_MASK)); | ||
346 | + } else { | ||
347 | + /* RO register, ignore the write */ | ||
348 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
349 | + "%s: invalid guest write to RO register at offset " | ||
350 | + TARGET_FMT_plx "\n", __func__, offset); | ||
351 | + } | ||
352 | + break; | ||
353 | + case GITS_CREADR + 4: | ||
354 | + if (s->gicv3->gicd_ctlr & GICD_CTLR_DS) { | ||
355 | + s->creadr = deposit64(s->creadr, 32, 32, value); | ||
356 | + } else { | ||
357 | + /* RO register, ignore the write */ | ||
358 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
359 | + "%s: invalid guest write to RO register at offset " | ||
360 | + TARGET_FMT_plx "\n", __func__, offset); | ||
361 | + } | ||
362 | + break; | ||
363 | + case GITS_BASER ... GITS_BASER + 0x3f: | ||
364 | + /* | ||
365 | + * IMPDEF choice:- GITS_BASERn register becomes RO if ITS is | ||
366 | + * already enabled | ||
367 | + */ | ||
368 | + if (!(s->ctlr & ITS_CTLR_ENABLED)) { | ||
369 | + index = (offset - GITS_BASER) / 8; | ||
370 | + | ||
371 | + if (offset & 7) { | ||
372 | + value <<= 32; | ||
373 | + value &= ~GITS_BASER_RO_MASK; | ||
374 | + s->baser[index] &= GITS_BASER_RO_MASK | MAKE_64BIT_MASK(0, 32); | ||
375 | + s->baser[index] |= value; | ||
376 | + } else { | ||
377 | + value &= ~GITS_BASER_RO_MASK; | ||
378 | + s->baser[index] &= GITS_BASER_RO_MASK | MAKE_64BIT_MASK(32, 32); | ||
379 | + s->baser[index] |= value; | ||
380 | + } | ||
381 | + } | ||
382 | + break; | ||
383 | + case GITS_IIDR: | ||
384 | + case GITS_IDREGS ... GITS_IDREGS + 0x2f: | ||
385 | + /* RO registers, ignore the write */ | ||
386 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
387 | + "%s: invalid guest write to RO register at offset " | ||
388 | + TARGET_FMT_plx "\n", __func__, offset); | ||
389 | + break; | ||
390 | + default: | ||
391 | + result = false; | ||
392 | + break; | ||
393 | + } | ||
394 | return result; | ||
43 | } | 395 | } |
44 | 396 | ||
45 | static bool notdirty_mem_accepts(void *opaque, hwaddr addr, | 397 | @@ -XXX,XX +XXX,XX @@ static bool its_readl(GICv3ITSState *s, hwaddr offset, |
46 | - unsigned size, bool is_write) | 398 | uint64_t *data, MemTxAttrs attrs) |
47 | + unsigned size, bool is_write, | ||
48 | + MemTxAttrs attrs) | ||
49 | { | 399 | { |
50 | return is_write; | 400 | bool result = true; |
401 | + int index; | ||
402 | |||
403 | + switch (offset) { | ||
404 | + case GITS_CTLR: | ||
405 | + *data = s->ctlr; | ||
406 | + break; | ||
407 | + case GITS_IIDR: | ||
408 | + *data = gicv3_iidr(); | ||
409 | + break; | ||
410 | + case GITS_IDREGS ... GITS_IDREGS + 0x2f: | ||
411 | + /* ID registers */ | ||
412 | + *data = gicv3_idreg(offset - GITS_IDREGS); | ||
413 | + break; | ||
414 | + case GITS_TYPER: | ||
415 | + *data = extract64(s->typer, 0, 32); | ||
416 | + break; | ||
417 | + case GITS_TYPER + 4: | ||
418 | + *data = extract64(s->typer, 32, 32); | ||
419 | + break; | ||
420 | + case GITS_CBASER: | ||
421 | + *data = extract64(s->cbaser, 0, 32); | ||
422 | + break; | ||
423 | + case GITS_CBASER + 4: | ||
424 | + *data = extract64(s->cbaser, 32, 32); | ||
425 | + break; | ||
426 | + case GITS_CREADR: | ||
427 | + *data = extract64(s->creadr, 0, 32); | ||
428 | + break; | ||
429 | + case GITS_CREADR + 4: | ||
430 | + *data = extract64(s->creadr, 32, 32); | ||
431 | + break; | ||
432 | + case GITS_CWRITER: | ||
433 | + *data = extract64(s->cwriter, 0, 32); | ||
434 | + break; | ||
435 | + case GITS_CWRITER + 4: | ||
436 | + *data = extract64(s->cwriter, 32, 32); | ||
437 | + break; | ||
438 | + case GITS_BASER ... GITS_BASER + 0x3f: | ||
439 | + index = (offset - GITS_BASER) / 8; | ||
440 | + if (offset & 7) { | ||
441 | + *data = extract64(s->baser[index], 32, 32); | ||
442 | + } else { | ||
443 | + *data = extract64(s->baser[index], 0, 32); | ||
444 | + } | ||
445 | + break; | ||
446 | + default: | ||
447 | + result = false; | ||
448 | + break; | ||
449 | + } | ||
450 | return result; | ||
51 | } | 451 | } |
52 | @@ -XXX,XX +XXX,XX @@ static MemTxResult subpage_write(void *opaque, hwaddr addr, | 452 | |
453 | @@ -XXX,XX +XXX,XX @@ static bool its_writell(GICv3ITSState *s, hwaddr offset, | ||
454 | uint64_t value, MemTxAttrs attrs) | ||
455 | { | ||
456 | bool result = true; | ||
457 | + int index; | ||
458 | |||
459 | + switch (offset) { | ||
460 | + case GITS_BASER ... GITS_BASER + 0x3f: | ||
461 | + /* | ||
462 | + * IMPDEF choice:- GITS_BASERn register becomes RO if ITS is | ||
463 | + * already enabled | ||
464 | + */ | ||
465 | + if (!(s->ctlr & ITS_CTLR_ENABLED)) { | ||
466 | + index = (offset - GITS_BASER) / 8; | ||
467 | + s->baser[index] &= GITS_BASER_RO_MASK; | ||
468 | + s->baser[index] |= (value & ~GITS_BASER_RO_MASK); | ||
469 | + } | ||
470 | + break; | ||
471 | + case GITS_CBASER: | ||
472 | + /* | ||
473 | + * IMPDEF choice:- GITS_CBASER register becomes RO if ITS is | ||
474 | + * already enabled | ||
475 | + */ | ||
476 | + if (!(s->ctlr & ITS_CTLR_ENABLED)) { | ||
477 | + s->cbaser = value; | ||
478 | + s->creadr = 0; | ||
479 | + s->cwriter = s->creadr; | ||
480 | + } | ||
481 | + break; | ||
482 | + case GITS_CWRITER: | ||
483 | + s->cwriter = value & ~R_GITS_CWRITER_RETRY_MASK; | ||
484 | + break; | ||
485 | + case GITS_CREADR: | ||
486 | + if (s->gicv3->gicd_ctlr & GICD_CTLR_DS) { | ||
487 | + s->creadr = value & ~R_GITS_CREADR_STALLED_MASK; | ||
488 | + } else { | ||
489 | + /* RO register, ignore the write */ | ||
490 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
491 | + "%s: invalid guest write to RO register at offset " | ||
492 | + TARGET_FMT_plx "\n", __func__, offset); | ||
493 | + } | ||
494 | + break; | ||
495 | + case GITS_TYPER: | ||
496 | + /* RO registers, ignore the write */ | ||
497 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
498 | + "%s: invalid guest write to RO register at offset " | ||
499 | + TARGET_FMT_plx "\n", __func__, offset); | ||
500 | + break; | ||
501 | + default: | ||
502 | + result = false; | ||
503 | + break; | ||
504 | + } | ||
505 | return result; | ||
53 | } | 506 | } |
54 | 507 | ||
55 | static bool subpage_accepts(void *opaque, hwaddr addr, | 508 | @@ -XXX,XX +XXX,XX @@ static bool its_readll(GICv3ITSState *s, hwaddr offset, |
56 | - unsigned len, bool is_write) | 509 | uint64_t *data, MemTxAttrs attrs) |
57 | + unsigned len, bool is_write, | ||
58 | + MemTxAttrs attrs) | ||
59 | { | 510 | { |
60 | subpage_t *subpage = opaque; | 511 | bool result = true; |
61 | #if defined(DEBUG_SUBPAGE) | 512 | + int index; |
62 | @@ -XXX,XX +XXX,XX @@ static void readonly_mem_write(void *opaque, hwaddr addr, | 513 | |
514 | + switch (offset) { | ||
515 | + case GITS_TYPER: | ||
516 | + *data = s->typer; | ||
517 | + break; | ||
518 | + case GITS_BASER ... GITS_BASER + 0x3f: | ||
519 | + index = (offset - GITS_BASER) / 8; | ||
520 | + *data = s->baser[index]; | ||
521 | + break; | ||
522 | + case GITS_CBASER: | ||
523 | + *data = s->cbaser; | ||
524 | + break; | ||
525 | + case GITS_CREADR: | ||
526 | + *data = s->creadr; | ||
527 | + break; | ||
528 | + case GITS_CWRITER: | ||
529 | + *data = s->cwriter; | ||
530 | + break; | ||
531 | + default: | ||
532 | + result = false; | ||
533 | + break; | ||
534 | + } | ||
535 | return result; | ||
63 | } | 536 | } |
64 | 537 | ||
65 | static bool readonly_mem_accepts(void *opaque, hwaddr addr, | 538 | @@ -XXX,XX +XXX,XX @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp) |
66 | - unsigned size, bool is_write) | 539 | |
67 | + unsigned size, bool is_write, | 540 | gicv3_its_init_mmio(s, &gicv3_its_control_ops, &gicv3_its_translation_ops); |
68 | + MemTxAttrs attrs) | 541 | |
542 | + address_space_init(&s->gicv3->dma_as, s->gicv3->dma, | ||
543 | + "gicv3-its-sysmem"); | ||
544 | + | ||
545 | /* set the ITS default features supported */ | ||
546 | s->typer = FIELD_DP64(s->typer, GITS_TYPER, PHYSICAL, | ||
547 | GITS_TYPE_PHYSICAL); | ||
548 | @@ -XXX,XX +XXX,XX @@ static void gicv3_its_reset(DeviceState *dev) | ||
549 | GITS_CTE_SIZE - 1); | ||
550 | } | ||
551 | |||
552 | +static void gicv3_its_post_load(GICv3ITSState *s) | ||
553 | +{ | ||
554 | + if (s->ctlr & ITS_CTLR_ENABLED) { | ||
555 | + extract_table_params(s); | ||
556 | + extract_cmdq_params(s); | ||
557 | + } | ||
558 | +} | ||
559 | + | ||
560 | static Property gicv3_its_props[] = { | ||
561 | DEFINE_PROP_LINK("parent-gicv3", GICv3ITSState, gicv3, "arm-gicv3", | ||
562 | GICv3State *), | ||
563 | @@ -XXX,XX +XXX,XX @@ static void gicv3_its_class_init(ObjectClass *klass, void *data) | ||
69 | { | 564 | { |
70 | return is_write; | 565 | DeviceClass *dc = DEVICE_CLASS(klass); |
566 | GICv3ITSClass *ic = ARM_GICV3_ITS_CLASS(klass); | ||
567 | + GICv3ITSCommonClass *icc = ARM_GICV3_ITS_COMMON_CLASS(klass); | ||
568 | |||
569 | dc->realize = gicv3_arm_its_realize; | ||
570 | device_class_set_props(dc, gicv3_its_props); | ||
571 | device_class_set_parent_reset(dc, gicv3_its_reset, &ic->parent_reset); | ||
572 | + icc->post_load = gicv3_its_post_load; | ||
71 | } | 573 | } |
72 | diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c | 574 | |
73 | index XXXXXXX..XXXXXXX 100644 | 575 | static const TypeInfo gicv3_its_info = { |
74 | --- a/hw/hppa/dino.c | ||
75 | +++ b/hw/hppa/dino.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static void gsc_to_pci_forwarding(DinoState *s) | ||
77 | } | ||
78 | |||
79 | static bool dino_chip_mem_valid(void *opaque, hwaddr addr, | ||
80 | - unsigned size, bool is_write) | ||
81 | + unsigned size, bool is_write, | ||
82 | + MemTxAttrs attrs) | ||
83 | { | ||
84 | switch (addr) { | ||
85 | case DINO_IAR0: | ||
86 | diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/nvram/fw_cfg.c | ||
89 | +++ b/hw/nvram/fw_cfg.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_dma_mem_write(void *opaque, hwaddr addr, | ||
91 | } | ||
92 | |||
93 | static bool fw_cfg_dma_mem_valid(void *opaque, hwaddr addr, | ||
94 | - unsigned size, bool is_write) | ||
95 | + unsigned size, bool is_write, | ||
96 | + MemTxAttrs attrs) | ||
97 | { | ||
98 | return !is_write || ((size == 4 && (addr == 0 || addr == 4)) || | ||
99 | (size == 8 && addr == 0)); | ||
100 | } | ||
101 | |||
102 | static bool fw_cfg_data_mem_valid(void *opaque, hwaddr addr, | ||
103 | - unsigned size, bool is_write) | ||
104 | + unsigned size, bool is_write, | ||
105 | + MemTxAttrs attrs) | ||
106 | { | ||
107 | return addr == 0; | ||
108 | } | ||
109 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_ctl_mem_write(void *opaque, hwaddr addr, | ||
110 | } | ||
111 | |||
112 | static bool fw_cfg_ctl_mem_valid(void *opaque, hwaddr addr, | ||
113 | - unsigned size, bool is_write) | ||
114 | + unsigned size, bool is_write, | ||
115 | + MemTxAttrs attrs) | ||
116 | { | ||
117 | return is_write && size == 2; | ||
118 | } | ||
119 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_comb_write(void *opaque, hwaddr addr, | ||
120 | } | ||
121 | |||
122 | static bool fw_cfg_comb_valid(void *opaque, hwaddr addr, | ||
123 | - unsigned size, bool is_write) | ||
124 | + unsigned size, bool is_write, | ||
125 | + MemTxAttrs attrs) | ||
126 | { | ||
127 | return (size == 1) || (is_write && size == 2); | ||
128 | } | ||
129 | diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/hw/scsi/esp.c | ||
132 | +++ b/hw/scsi/esp.c | ||
133 | @@ -XXX,XX +XXX,XX @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) | ||
134 | } | ||
135 | |||
136 | static bool esp_mem_accepts(void *opaque, hwaddr addr, | ||
137 | - unsigned size, bool is_write) | ||
138 | + unsigned size, bool is_write, | ||
139 | + MemTxAttrs attrs) | ||
140 | { | ||
141 | return (size == 1) || (is_write && size == 4); | ||
142 | } | ||
143 | diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c | ||
144 | index XXXXXXX..XXXXXXX 100644 | ||
145 | --- a/hw/xen/xen_pt_msi.c | ||
146 | +++ b/hw/xen/xen_pt_msi.c | ||
147 | @@ -XXX,XX +XXX,XX @@ static uint64_t pci_msix_read(void *opaque, hwaddr addr, | ||
148 | } | ||
149 | |||
150 | static bool pci_msix_accepts(void *opaque, hwaddr addr, | ||
151 | - unsigned size, bool is_write) | ||
152 | + unsigned size, bool is_write, | ||
153 | + MemTxAttrs attrs) | ||
154 | { | ||
155 | return !(addr & (size - 1)); | ||
156 | } | ||
157 | diff --git a/memory.c b/memory.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/memory.c | ||
160 | +++ b/memory.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static void unassigned_mem_write(void *opaque, hwaddr addr, | ||
162 | } | ||
163 | |||
164 | static bool unassigned_mem_accepts(void *opaque, hwaddr addr, | ||
165 | - unsigned size, bool is_write) | ||
166 | + unsigned size, bool is_write, | ||
167 | + MemTxAttrs attrs) | ||
168 | { | ||
169 | return false; | ||
170 | } | ||
171 | @@ -XXX,XX +XXX,XX @@ bool memory_region_access_valid(MemoryRegion *mr, | ||
172 | access_size = MAX(MIN(size, access_size_max), access_size_min); | ||
173 | for (i = 0; i < size; i += access_size) { | ||
174 | if (!mr->ops->valid.accepts(mr->opaque, addr + i, access_size, | ||
175 | - is_write)) { | ||
176 | + is_write, attrs)) { | ||
177 | return false; | ||
178 | } | ||
179 | } | ||
180 | -- | 576 | -- |
181 | 2.17.1 | 577 | 2.20.1 |
182 | 578 | ||
183 | 579 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | kvm_irqchip_create called by kvm_init will call kvm_init_irq_routing to | 3 | Added functionality to trigger ITS command queue processing on |
4 | initialize global capability variables. If we call kvm_init_irq_routing in | 4 | write to CWRITE register and process each command queue entry to |
5 | GIC realize function, previous allocated memory will leak. | 5 | identify the command type and handle commands like MAPD,MAPC,SYNC. |
6 | 6 | ||
7 | Fix this by deleting the unnecessary call. | 7 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> |
8 | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | |
9 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | ||
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
11 | Message-id: 1527750994-14360-1-git-send-email-zhaoshenglong@huawei.com | 10 | Tested-by: Neil Armstrong <narmstrong@baylibre.com> |
11 | Message-id: 20210910143951.92242-4-shashi.mallela@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 13 | --- |
14 | hw/intc/arm_gic_kvm.c | 1 - | 14 | hw/intc/gicv3_internal.h | 40 +++++ |
15 | hw/intc/arm_gicv3_kvm.c | 1 - | 15 | hw/intc/arm_gicv3_its.c | 319 +++++++++++++++++++++++++++++++++++++++ |
16 | 2 files changed, 2 deletions(-) | 16 | 2 files changed, 359 insertions(+) |
17 | 17 | ||
18 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c | 18 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h |
19 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/intc/arm_gic_kvm.c | 20 | --- a/hw/intc/gicv3_internal.h |
21 | +++ b/hw/intc/arm_gic_kvm.c | 21 | +++ b/hw/intc/gicv3_internal.h |
22 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) | 22 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) |
23 | 23 | #define L1TABLE_ENTRY_SIZE 8 | |
24 | if (kvm_has_gsi_routing()) { | 24 | |
25 | /* set up irq routing */ | 25 | #define GITS_CMDQ_ENTRY_SIZE 32 |
26 | - kvm_init_irq_routing(kvm_state); | 26 | +#define NUM_BYTES_IN_DW 8 |
27 | for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { | 27 | + |
28 | kvm_irqchip_add_irq_route(kvm_state, i, 0, i); | 28 | +#define CMD_MASK 0xff |
29 | + | ||
30 | +/* ITS Commands */ | ||
31 | +#define GITS_CMD_CLEAR 0x04 | ||
32 | +#define GITS_CMD_DISCARD 0x0F | ||
33 | +#define GITS_CMD_INT 0x03 | ||
34 | +#define GITS_CMD_MAPC 0x09 | ||
35 | +#define GITS_CMD_MAPD 0x08 | ||
36 | +#define GITS_CMD_MAPI 0x0B | ||
37 | +#define GITS_CMD_MAPTI 0x0A | ||
38 | +#define GITS_CMD_INV 0x0C | ||
39 | +#define GITS_CMD_INVALL 0x0D | ||
40 | +#define GITS_CMD_SYNC 0x05 | ||
41 | + | ||
42 | +/* MAPC command fields */ | ||
43 | +#define ICID_LENGTH 16 | ||
44 | +#define ICID_MASK ((1U << ICID_LENGTH) - 1) | ||
45 | +FIELD(MAPC, RDBASE, 16, 32) | ||
46 | + | ||
47 | +#define RDBASE_PROCNUM_LENGTH 16 | ||
48 | +#define RDBASE_PROCNUM_MASK ((1ULL << RDBASE_PROCNUM_LENGTH) - 1) | ||
49 | + | ||
50 | +/* MAPD command fields */ | ||
51 | +#define ITTADDR_LENGTH 44 | ||
52 | +#define ITTADDR_SHIFT 8 | ||
53 | +#define ITTADDR_MASK MAKE_64BIT_MASK(ITTADDR_SHIFT, ITTADDR_LENGTH) | ||
54 | +#define SIZE_MASK 0x1f | ||
55 | + | ||
56 | +#define DEVID_SHIFT 32 | ||
57 | +#define DEVID_MASK MAKE_64BIT_MASK(32, 32) | ||
58 | + | ||
59 | +#define VALID_SHIFT 63 | ||
60 | +#define CMD_FIELD_VALID_MASK (1ULL << VALID_SHIFT) | ||
61 | +#define L2_TABLE_VALID_MASK CMD_FIELD_VALID_MASK | ||
62 | +#define TABLE_ENTRY_VALID_MASK (1ULL << 0) | ||
63 | |||
64 | /** | ||
65 | * Default features advertised by this version of ITS | ||
66 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
67 | * Valid = 1 bit,ITTAddr = 44 bits,Size = 5 bits | ||
68 | */ | ||
69 | #define GITS_DTE_SIZE (0x8ULL) | ||
70 | +#define GITS_DTE_ITTADDR_SHIFT 6 | ||
71 | +#define GITS_DTE_ITTADDR_MASK MAKE_64BIT_MASK(GITS_DTE_ITTADDR_SHIFT, \ | ||
72 | + ITTADDR_LENGTH) | ||
73 | |||
74 | /* | ||
75 | * 8 bytes Collection Table Entry size | ||
76 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/hw/intc/arm_gicv3_its.c | ||
79 | +++ b/hw/intc/arm_gicv3_its.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) | ||
81 | return result; | ||
82 | } | ||
83 | |||
84 | +static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid, | ||
85 | + uint64_t rdbase) | ||
86 | +{ | ||
87 | + AddressSpace *as = &s->gicv3->dma_as; | ||
88 | + uint64_t value; | ||
89 | + uint64_t l2t_addr; | ||
90 | + bool valid_l2t; | ||
91 | + uint32_t l2t_id; | ||
92 | + uint32_t max_l2_entries; | ||
93 | + uint64_t cte = 0; | ||
94 | + MemTxResult res = MEMTX_OK; | ||
95 | + | ||
96 | + if (!s->ct.valid) { | ||
97 | + return true; | ||
98 | + } | ||
99 | + | ||
100 | + if (valid) { | ||
101 | + /* add mapping entry to collection table */ | ||
102 | + cte = (valid & TABLE_ENTRY_VALID_MASK) | (rdbase << 1ULL); | ||
103 | + } | ||
104 | + | ||
105 | + /* | ||
106 | + * The specification defines the format of level 1 entries of a | ||
107 | + * 2-level table, but the format of level 2 entries and the format | ||
108 | + * of flat-mapped tables is IMPDEF. | ||
109 | + */ | ||
110 | + if (s->ct.indirect) { | ||
111 | + l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE); | ||
112 | + | ||
113 | + value = address_space_ldq_le(as, | ||
114 | + s->ct.base_addr + | ||
115 | + (l2t_id * L1TABLE_ENTRY_SIZE), | ||
116 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
117 | + | ||
118 | + if (res != MEMTX_OK) { | ||
119 | + return false; | ||
120 | + } | ||
121 | + | ||
122 | + valid_l2t = (value & L2_TABLE_VALID_MASK) != 0; | ||
123 | + | ||
124 | + if (valid_l2t) { | ||
125 | + max_l2_entries = s->ct.page_sz / s->ct.entry_sz; | ||
126 | + | ||
127 | + l2t_addr = value & ((1ULL << 51) - 1); | ||
128 | + | ||
129 | + address_space_stq_le(as, l2t_addr + | ||
130 | + ((icid % max_l2_entries) * GITS_CTE_SIZE), | ||
131 | + cte, MEMTXATTRS_UNSPECIFIED, &res); | ||
132 | + } | ||
133 | + } else { | ||
134 | + /* Flat level table */ | ||
135 | + address_space_stq_le(as, s->ct.base_addr + (icid * GITS_CTE_SIZE), | ||
136 | + cte, MEMTXATTRS_UNSPECIFIED, &res); | ||
137 | + } | ||
138 | + if (res != MEMTX_OK) { | ||
139 | + return false; | ||
140 | + } else { | ||
141 | + return true; | ||
142 | + } | ||
143 | +} | ||
144 | + | ||
145 | +static bool process_mapc(GICv3ITSState *s, uint32_t offset) | ||
146 | +{ | ||
147 | + AddressSpace *as = &s->gicv3->dma_as; | ||
148 | + uint16_t icid; | ||
149 | + uint64_t rdbase; | ||
150 | + bool valid; | ||
151 | + MemTxResult res = MEMTX_OK; | ||
152 | + bool result = false; | ||
153 | + uint64_t value; | ||
154 | + | ||
155 | + offset += NUM_BYTES_IN_DW; | ||
156 | + offset += NUM_BYTES_IN_DW; | ||
157 | + | ||
158 | + value = address_space_ldq_le(as, s->cq.base_addr + offset, | ||
159 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
160 | + | ||
161 | + if (res != MEMTX_OK) { | ||
162 | + return result; | ||
163 | + } | ||
164 | + | ||
165 | + icid = value & ICID_MASK; | ||
166 | + | ||
167 | + rdbase = (value & R_MAPC_RDBASE_MASK) >> R_MAPC_RDBASE_SHIFT; | ||
168 | + rdbase &= RDBASE_PROCNUM_MASK; | ||
169 | + | ||
170 | + valid = (value & CMD_FIELD_VALID_MASK); | ||
171 | + | ||
172 | + if ((icid > s->ct.maxids.max_collids) || (rdbase > s->gicv3->num_cpu)) { | ||
173 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
174 | + "ITS MAPC: invalid collection table attributes " | ||
175 | + "icid %d rdbase %lu\n", icid, rdbase); | ||
176 | + /* | ||
177 | + * in this implementation, in case of error | ||
178 | + * we ignore this command and move onto the next | ||
179 | + * command in the queue | ||
180 | + */ | ||
181 | + } else { | ||
182 | + result = update_cte(s, icid, valid, rdbase); | ||
183 | + } | ||
184 | + | ||
185 | + return result; | ||
186 | +} | ||
187 | + | ||
188 | +static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid, | ||
189 | + uint8_t size, uint64_t itt_addr) | ||
190 | +{ | ||
191 | + AddressSpace *as = &s->gicv3->dma_as; | ||
192 | + uint64_t value; | ||
193 | + uint64_t l2t_addr; | ||
194 | + bool valid_l2t; | ||
195 | + uint32_t l2t_id; | ||
196 | + uint32_t max_l2_entries; | ||
197 | + uint64_t dte = 0; | ||
198 | + MemTxResult res = MEMTX_OK; | ||
199 | + | ||
200 | + if (s->dt.valid) { | ||
201 | + if (valid) { | ||
202 | + /* add mapping entry to device table */ | ||
203 | + dte = (valid & TABLE_ENTRY_VALID_MASK) | | ||
204 | + ((size & SIZE_MASK) << 1U) | | ||
205 | + (itt_addr << GITS_DTE_ITTADDR_SHIFT); | ||
206 | + } | ||
207 | + } else { | ||
208 | + return true; | ||
209 | + } | ||
210 | + | ||
211 | + /* | ||
212 | + * The specification defines the format of level 1 entries of a | ||
213 | + * 2-level table, but the format of level 2 entries and the format | ||
214 | + * of flat-mapped tables is IMPDEF. | ||
215 | + */ | ||
216 | + if (s->dt.indirect) { | ||
217 | + l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE); | ||
218 | + | ||
219 | + value = address_space_ldq_le(as, | ||
220 | + s->dt.base_addr + | ||
221 | + (l2t_id * L1TABLE_ENTRY_SIZE), | ||
222 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
223 | + | ||
224 | + if (res != MEMTX_OK) { | ||
225 | + return false; | ||
226 | + } | ||
227 | + | ||
228 | + valid_l2t = (value & L2_TABLE_VALID_MASK) != 0; | ||
229 | + | ||
230 | + if (valid_l2t) { | ||
231 | + max_l2_entries = s->dt.page_sz / s->dt.entry_sz; | ||
232 | + | ||
233 | + l2t_addr = value & ((1ULL << 51) - 1); | ||
234 | + | ||
235 | + address_space_stq_le(as, l2t_addr + | ||
236 | + ((devid % max_l2_entries) * GITS_DTE_SIZE), | ||
237 | + dte, MEMTXATTRS_UNSPECIFIED, &res); | ||
238 | + } | ||
239 | + } else { | ||
240 | + /* Flat level table */ | ||
241 | + address_space_stq_le(as, s->dt.base_addr + (devid * GITS_DTE_SIZE), | ||
242 | + dte, MEMTXATTRS_UNSPECIFIED, &res); | ||
243 | + } | ||
244 | + if (res != MEMTX_OK) { | ||
245 | + return false; | ||
246 | + } else { | ||
247 | + return true; | ||
248 | + } | ||
249 | +} | ||
250 | + | ||
251 | +static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset) | ||
252 | +{ | ||
253 | + AddressSpace *as = &s->gicv3->dma_as; | ||
254 | + uint32_t devid; | ||
255 | + uint8_t size; | ||
256 | + uint64_t itt_addr; | ||
257 | + bool valid; | ||
258 | + MemTxResult res = MEMTX_OK; | ||
259 | + bool result = false; | ||
260 | + | ||
261 | + devid = ((value & DEVID_MASK) >> DEVID_SHIFT); | ||
262 | + | ||
263 | + offset += NUM_BYTES_IN_DW; | ||
264 | + value = address_space_ldq_le(as, s->cq.base_addr + offset, | ||
265 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
266 | + | ||
267 | + if (res != MEMTX_OK) { | ||
268 | + return result; | ||
269 | + } | ||
270 | + | ||
271 | + size = (value & SIZE_MASK); | ||
272 | + | ||
273 | + offset += NUM_BYTES_IN_DW; | ||
274 | + value = address_space_ldq_le(as, s->cq.base_addr + offset, | ||
275 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
276 | + | ||
277 | + if (res != MEMTX_OK) { | ||
278 | + return result; | ||
279 | + } | ||
280 | + | ||
281 | + itt_addr = (value & ITTADDR_MASK) >> ITTADDR_SHIFT; | ||
282 | + | ||
283 | + valid = (value & CMD_FIELD_VALID_MASK); | ||
284 | + | ||
285 | + if ((devid > s->dt.maxids.max_devids) || | ||
286 | + (size > FIELD_EX64(s->typer, GITS_TYPER, IDBITS))) { | ||
287 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
288 | + "ITS MAPD: invalid device table attributes " | ||
289 | + "devid %d or size %d\n", devid, size); | ||
290 | + /* | ||
291 | + * in this implementation, in case of error | ||
292 | + * we ignore this command and move onto the next | ||
293 | + * command in the queue | ||
294 | + */ | ||
295 | + } else { | ||
296 | + result = update_dte(s, devid, valid, size, itt_addr); | ||
297 | + } | ||
298 | + | ||
299 | + return result; | ||
300 | +} | ||
301 | + | ||
302 | +/* | ||
303 | + * Current implementation blocks until all | ||
304 | + * commands are processed | ||
305 | + */ | ||
306 | +static void process_cmdq(GICv3ITSState *s) | ||
307 | +{ | ||
308 | + uint32_t wr_offset = 0; | ||
309 | + uint32_t rd_offset = 0; | ||
310 | + uint32_t cq_offset = 0; | ||
311 | + uint64_t data; | ||
312 | + AddressSpace *as = &s->gicv3->dma_as; | ||
313 | + MemTxResult res = MEMTX_OK; | ||
314 | + bool result = true; | ||
315 | + uint8_t cmd; | ||
316 | + | ||
317 | + if (!(s->ctlr & ITS_CTLR_ENABLED)) { | ||
318 | + return; | ||
319 | + } | ||
320 | + | ||
321 | + wr_offset = FIELD_EX64(s->cwriter, GITS_CWRITER, OFFSET); | ||
322 | + | ||
323 | + if (wr_offset > s->cq.max_entries) { | ||
324 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
325 | + "%s: invalid write offset " | ||
326 | + "%d\n", __func__, wr_offset); | ||
327 | + return; | ||
328 | + } | ||
329 | + | ||
330 | + rd_offset = FIELD_EX64(s->creadr, GITS_CREADR, OFFSET); | ||
331 | + | ||
332 | + if (rd_offset > s->cq.max_entries) { | ||
333 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
334 | + "%s: invalid read offset " | ||
335 | + "%d\n", __func__, rd_offset); | ||
336 | + return; | ||
337 | + } | ||
338 | + | ||
339 | + while (wr_offset != rd_offset) { | ||
340 | + cq_offset = (rd_offset * GITS_CMDQ_ENTRY_SIZE); | ||
341 | + data = address_space_ldq_le(as, s->cq.base_addr + cq_offset, | ||
342 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
343 | + if (res != MEMTX_OK) { | ||
344 | + result = false; | ||
345 | + } | ||
346 | + cmd = (data & CMD_MASK); | ||
347 | + | ||
348 | + switch (cmd) { | ||
349 | + case GITS_CMD_INT: | ||
350 | + break; | ||
351 | + case GITS_CMD_CLEAR: | ||
352 | + break; | ||
353 | + case GITS_CMD_SYNC: | ||
354 | + /* | ||
355 | + * Current implementation makes a blocking synchronous call | ||
356 | + * for every command issued earlier, hence the internal state | ||
357 | + * is already consistent by the time SYNC command is executed. | ||
358 | + * Hence no further processing is required for SYNC command. | ||
359 | + */ | ||
360 | + break; | ||
361 | + case GITS_CMD_MAPD: | ||
362 | + result = process_mapd(s, data, cq_offset); | ||
363 | + break; | ||
364 | + case GITS_CMD_MAPC: | ||
365 | + result = process_mapc(s, cq_offset); | ||
366 | + break; | ||
367 | + case GITS_CMD_MAPTI: | ||
368 | + break; | ||
369 | + case GITS_CMD_MAPI: | ||
370 | + break; | ||
371 | + case GITS_CMD_DISCARD: | ||
372 | + break; | ||
373 | + case GITS_CMD_INV: | ||
374 | + case GITS_CMD_INVALL: | ||
375 | + break; | ||
376 | + default: | ||
377 | + break; | ||
378 | + } | ||
379 | + if (result) { | ||
380 | + rd_offset++; | ||
381 | + rd_offset %= s->cq.max_entries; | ||
382 | + s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, OFFSET, rd_offset); | ||
383 | + } else { | ||
384 | + /* | ||
385 | + * in this implementation, in case of dma read/write error | ||
386 | + * we stall the command processing | ||
387 | + */ | ||
388 | + s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1); | ||
389 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
390 | + "%s: %x cmd processing failed\n", __func__, cmd); | ||
391 | + break; | ||
392 | + } | ||
393 | + } | ||
394 | +} | ||
395 | + | ||
396 | /* | ||
397 | * This function extracts the ITS Device and Collection table specific | ||
398 | * parameters (like base_addr, size etc) from GITS_BASER register. | ||
399 | @@ -XXX,XX +XXX,XX @@ static bool its_writel(GICv3ITSState *s, hwaddr offset, | ||
400 | extract_table_params(s); | ||
401 | extract_cmdq_params(s); | ||
402 | s->creadr = 0; | ||
403 | + process_cmdq(s); | ||
29 | } | 404 | } |
30 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 405 | break; |
31 | index XXXXXXX..XXXXXXX 100644 | 406 | case GITS_CBASER: |
32 | --- a/hw/intc/arm_gicv3_kvm.c | 407 | @@ -XXX,XX +XXX,XX @@ static bool its_writel(GICv3ITSState *s, hwaddr offset, |
33 | +++ b/hw/intc/arm_gicv3_kvm.c | 408 | case GITS_CWRITER: |
34 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | 409 | s->cwriter = deposit64(s->cwriter, 0, 32, |
35 | 410 | (value & ~R_GITS_CWRITER_RETRY_MASK)); | |
36 | if (kvm_has_gsi_routing()) { | 411 | + if (s->cwriter != s->creadr) { |
37 | /* set up irq routing */ | 412 | + process_cmdq(s); |
38 | - kvm_init_irq_routing(kvm_state); | 413 | + } |
39 | for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { | 414 | break; |
40 | kvm_irqchip_add_irq_route(kvm_state, i, 0, i); | 415 | case GITS_CWRITER + 4: |
41 | } | 416 | s->cwriter = deposit64(s->cwriter, 32, 32, value); |
417 | @@ -XXX,XX +XXX,XX @@ static bool its_writell(GICv3ITSState *s, hwaddr offset, | ||
418 | break; | ||
419 | case GITS_CWRITER: | ||
420 | s->cwriter = value & ~R_GITS_CWRITER_RETRY_MASK; | ||
421 | + if (s->cwriter != s->creadr) { | ||
422 | + process_cmdq(s); | ||
423 | + } | ||
424 | break; | ||
425 | case GITS_CREADR: | ||
426 | if (s->gicv3->gicd_ctlr & GICD_CTLR_DS) { | ||
42 | -- | 427 | -- |
43 | 2.17.1 | 428 | 2.20.1 |
44 | 429 | ||
45 | 430 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_access_valid(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Added ITS command queue handling for MAPTI,MAPI commands,handled ITS | ||
4 | translation which triggers an LPI via INT command as well as write | ||
5 | to GITS_TRANSLATER register,defined enum to differentiate between ITS | ||
6 | command interrupt trigger and GITS_TRANSLATER based interrupt trigger. | ||
7 | Each of these commands make use of other functionalities implemented to | ||
8 | get device table entry,collection table entry or interrupt translation | ||
9 | table entry required for their processing. | ||
10 | |||
11 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20210910143951.92242-5-shashi.mallela@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-6-peter.maydell@linaro.org | ||
10 | --- | 15 | --- |
11 | include/exec/memory.h | 4 +++- | 16 | hw/intc/gicv3_internal.h | 12 + |
12 | include/sysemu/dma.h | 3 ++- | 17 | include/hw/intc/arm_gicv3_common.h | 2 + |
13 | exec.c | 3 ++- | 18 | hw/intc/arm_gicv3_its.c | 365 ++++++++++++++++++++++++++++- |
14 | target/s390x/diag.c | 6 ++++-- | 19 | 3 files changed, 378 insertions(+), 1 deletion(-) |
15 | target/s390x/excp_helper.c | 3 ++- | ||
16 | target/s390x/mmu_helper.c | 3 ++- | ||
17 | target/s390x/sigp.c | 3 ++- | ||
18 | 7 files changed, 17 insertions(+), 8 deletions(-) | ||
19 | 20 | ||
20 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 21 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h |
21 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/memory.h | 23 | --- a/hw/intc/gicv3_internal.h |
23 | +++ b/include/exec/memory.h | 24 | +++ b/hw/intc/gicv3_internal.h |
24 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as, | 25 | @@ -XXX,XX +XXX,XX @@ FIELD(MAPC, RDBASE, 16, 32) |
25 | * @addr: address within that address space | 26 | #define ITTADDR_MASK MAKE_64BIT_MASK(ITTADDR_SHIFT, ITTADDR_LENGTH) |
26 | * @len: length of the area to be checked | 27 | #define SIZE_MASK 0x1f |
27 | * @is_write: indicates the transfer direction | 28 | |
28 | + * @attrs: memory attributes | 29 | +/* MAPI command fields */ |
30 | +#define EVENTID_MASK ((1ULL << 32) - 1) | ||
31 | + | ||
32 | +/* MAPTI command fields */ | ||
33 | +#define pINTID_SHIFT 32 | ||
34 | +#define pINTID_MASK MAKE_64BIT_MASK(32, 32) | ||
35 | + | ||
36 | #define DEVID_SHIFT 32 | ||
37 | #define DEVID_MASK MAKE_64BIT_MASK(32, 32) | ||
38 | |||
39 | @@ -XXX,XX +XXX,XX @@ FIELD(MAPC, RDBASE, 16, 32) | ||
40 | * Values: | vPEID | ICID | | ||
29 | */ | 41 | */ |
30 | -bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write); | 42 | #define ITS_ITT_ENTRY_SIZE 0xC |
31 | +bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, | 43 | +#define ITE_ENTRY_INTTYPE_SHIFT 1 |
32 | + bool is_write, MemTxAttrs attrs); | 44 | +#define ITE_ENTRY_INTID_SHIFT 2 |
33 | 45 | +#define ITE_ENTRY_INTID_MASK MAKE_64BIT_MASK(2, 24) | |
34 | /* address_space_map: map a physical memory region into a host virtual address | 46 | +#define ITE_ENTRY_INTSP_SHIFT 26 |
35 | * | 47 | +#define ITE_ENTRY_ICID_MASK MAKE_64BIT_MASK(0, 16) |
36 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | 48 | |
49 | /* 16 bits EventId */ | ||
50 | #define ITS_IDBITS GICD_TYPER_IDBITS | ||
51 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/include/sysemu/dma.h | 53 | --- a/include/hw/intc/arm_gicv3_common.h |
39 | +++ b/include/sysemu/dma.h | 54 | +++ b/include/hw/intc/arm_gicv3_common.h |
40 | @@ -XXX,XX +XXX,XX @@ static inline bool dma_memory_valid(AddressSpace *as, | 55 | @@ -XXX,XX +XXX,XX @@ |
41 | DMADirection dir) | 56 | #define GICV3_MAXIRQ 1020 |
57 | #define GICV3_MAXSPI (GICV3_MAXIRQ - GIC_INTERNAL) | ||
58 | |||
59 | +#define GICV3_LPI_INTID_START 8192 | ||
60 | + | ||
61 | #define GICV3_REDIST_SIZE 0x20000 | ||
62 | |||
63 | /* Number of SGI target-list bits */ | ||
64 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/hw/intc/arm_gicv3_its.c | ||
67 | +++ b/hw/intc/arm_gicv3_its.c | ||
68 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSClass { | ||
69 | void (*parent_reset)(DeviceState *dev); | ||
70 | }; | ||
71 | |||
72 | +/* | ||
73 | + * This is an internal enum used to distinguish between LPI triggered | ||
74 | + * via command queue and LPI triggered via gits_translater write. | ||
75 | + */ | ||
76 | +typedef enum ItsCmdType { | ||
77 | + NONE = 0, /* internal indication for GITS_TRANSLATER write */ | ||
78 | + CLEAR = 1, | ||
79 | + DISCARD = 2, | ||
80 | + INT = 3, | ||
81 | +} ItsCmdType; | ||
82 | + | ||
83 | +typedef struct { | ||
84 | + uint32_t iteh; | ||
85 | + uint64_t itel; | ||
86 | +} IteEntry; | ||
87 | + | ||
88 | static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) | ||
42 | { | 89 | { |
43 | return address_space_access_valid(as, addr, len, | 90 | uint64_t result = 0; |
44 | - dir == DMA_DIRECTION_FROM_DEVICE); | 91 | @@ -XXX,XX +XXX,XX @@ static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) |
45 | + dir == DMA_DIRECTION_FROM_DEVICE, | 92 | return result; |
46 | + MEMTXATTRS_UNSPECIFIED); | ||
47 | } | 93 | } |
48 | 94 | ||
49 | static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, | 95 | +static bool get_cte(GICv3ITSState *s, uint16_t icid, uint64_t *cte, |
50 | diff --git a/exec.c b/exec.c | 96 | + MemTxResult *res) |
51 | index XXXXXXX..XXXXXXX 100644 | 97 | +{ |
52 | --- a/exec.c | 98 | + AddressSpace *as = &s->gicv3->dma_as; |
53 | +++ b/exec.c | 99 | + uint64_t l2t_addr; |
54 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 100 | + uint64_t value; |
101 | + bool valid_l2t; | ||
102 | + uint32_t l2t_id; | ||
103 | + uint32_t max_l2_entries; | ||
104 | + | ||
105 | + if (s->ct.indirect) { | ||
106 | + l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE); | ||
107 | + | ||
108 | + value = address_space_ldq_le(as, | ||
109 | + s->ct.base_addr + | ||
110 | + (l2t_id * L1TABLE_ENTRY_SIZE), | ||
111 | + MEMTXATTRS_UNSPECIFIED, res); | ||
112 | + | ||
113 | + if (*res == MEMTX_OK) { | ||
114 | + valid_l2t = (value & L2_TABLE_VALID_MASK) != 0; | ||
115 | + | ||
116 | + if (valid_l2t) { | ||
117 | + max_l2_entries = s->ct.page_sz / s->ct.entry_sz; | ||
118 | + | ||
119 | + l2t_addr = value & ((1ULL << 51) - 1); | ||
120 | + | ||
121 | + *cte = address_space_ldq_le(as, l2t_addr + | ||
122 | + ((icid % max_l2_entries) * GITS_CTE_SIZE), | ||
123 | + MEMTXATTRS_UNSPECIFIED, res); | ||
124 | + } | ||
125 | + } | ||
126 | + } else { | ||
127 | + /* Flat level table */ | ||
128 | + *cte = address_space_ldq_le(as, s->ct.base_addr + | ||
129 | + (icid * GITS_CTE_SIZE), | ||
130 | + MEMTXATTRS_UNSPECIFIED, res); | ||
131 | + } | ||
132 | + | ||
133 | + return (*cte & TABLE_ENTRY_VALID_MASK) != 0; | ||
134 | +} | ||
135 | + | ||
136 | +static bool update_ite(GICv3ITSState *s, uint32_t eventid, uint64_t dte, | ||
137 | + IteEntry ite) | ||
138 | +{ | ||
139 | + AddressSpace *as = &s->gicv3->dma_as; | ||
140 | + uint64_t itt_addr; | ||
141 | + MemTxResult res = MEMTX_OK; | ||
142 | + | ||
143 | + itt_addr = (dte & GITS_DTE_ITTADDR_MASK) >> GITS_DTE_ITTADDR_SHIFT; | ||
144 | + itt_addr <<= ITTADDR_SHIFT; /* 256 byte aligned */ | ||
145 | + | ||
146 | + address_space_stq_le(as, itt_addr + (eventid * (sizeof(uint64_t) + | ||
147 | + sizeof(uint32_t))), ite.itel, MEMTXATTRS_UNSPECIFIED, | ||
148 | + &res); | ||
149 | + | ||
150 | + if (res == MEMTX_OK) { | ||
151 | + address_space_stl_le(as, itt_addr + (eventid * (sizeof(uint64_t) + | ||
152 | + sizeof(uint32_t))) + sizeof(uint32_t), ite.iteh, | ||
153 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
154 | + } | ||
155 | + if (res != MEMTX_OK) { | ||
156 | + return false; | ||
157 | + } else { | ||
158 | + return true; | ||
159 | + } | ||
160 | +} | ||
161 | + | ||
162 | +static bool get_ite(GICv3ITSState *s, uint32_t eventid, uint64_t dte, | ||
163 | + uint16_t *icid, uint32_t *pIntid, MemTxResult *res) | ||
164 | +{ | ||
165 | + AddressSpace *as = &s->gicv3->dma_as; | ||
166 | + uint64_t itt_addr; | ||
167 | + bool status = false; | ||
168 | + IteEntry ite = {}; | ||
169 | + | ||
170 | + itt_addr = (dte & GITS_DTE_ITTADDR_MASK) >> GITS_DTE_ITTADDR_SHIFT; | ||
171 | + itt_addr <<= ITTADDR_SHIFT; /* 256 byte aligned */ | ||
172 | + | ||
173 | + ite.itel = address_space_ldq_le(as, itt_addr + | ||
174 | + (eventid * (sizeof(uint64_t) + | ||
175 | + sizeof(uint32_t))), MEMTXATTRS_UNSPECIFIED, | ||
176 | + res); | ||
177 | + | ||
178 | + if (*res == MEMTX_OK) { | ||
179 | + ite.iteh = address_space_ldl_le(as, itt_addr + | ||
180 | + (eventid * (sizeof(uint64_t) + | ||
181 | + sizeof(uint32_t))) + sizeof(uint32_t), | ||
182 | + MEMTXATTRS_UNSPECIFIED, res); | ||
183 | + | ||
184 | + if (*res == MEMTX_OK) { | ||
185 | + if (ite.itel & TABLE_ENTRY_VALID_MASK) { | ||
186 | + if ((ite.itel >> ITE_ENTRY_INTTYPE_SHIFT) & | ||
187 | + GITS_TYPE_PHYSICAL) { | ||
188 | + *pIntid = (ite.itel & ITE_ENTRY_INTID_MASK) >> | ||
189 | + ITE_ENTRY_INTID_SHIFT; | ||
190 | + *icid = ite.iteh & ITE_ENTRY_ICID_MASK; | ||
191 | + status = true; | ||
192 | + } | ||
193 | + } | ||
194 | + } | ||
195 | + } | ||
196 | + return status; | ||
197 | +} | ||
198 | + | ||
199 | +static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res) | ||
200 | +{ | ||
201 | + AddressSpace *as = &s->gicv3->dma_as; | ||
202 | + uint64_t l2t_addr; | ||
203 | + uint64_t value; | ||
204 | + bool valid_l2t; | ||
205 | + uint32_t l2t_id; | ||
206 | + uint32_t max_l2_entries; | ||
207 | + | ||
208 | + if (s->dt.indirect) { | ||
209 | + l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE); | ||
210 | + | ||
211 | + value = address_space_ldq_le(as, | ||
212 | + s->dt.base_addr + | ||
213 | + (l2t_id * L1TABLE_ENTRY_SIZE), | ||
214 | + MEMTXATTRS_UNSPECIFIED, res); | ||
215 | + | ||
216 | + if (*res == MEMTX_OK) { | ||
217 | + valid_l2t = (value & L2_TABLE_VALID_MASK) != 0; | ||
218 | + | ||
219 | + if (valid_l2t) { | ||
220 | + max_l2_entries = s->dt.page_sz / s->dt.entry_sz; | ||
221 | + | ||
222 | + l2t_addr = value & ((1ULL << 51) - 1); | ||
223 | + | ||
224 | + value = address_space_ldq_le(as, l2t_addr + | ||
225 | + ((devid % max_l2_entries) * GITS_DTE_SIZE), | ||
226 | + MEMTXATTRS_UNSPECIFIED, res); | ||
227 | + } | ||
228 | + } | ||
229 | + } else { | ||
230 | + /* Flat level table */ | ||
231 | + value = address_space_ldq_le(as, s->dt.base_addr + | ||
232 | + (devid * GITS_DTE_SIZE), | ||
233 | + MEMTXATTRS_UNSPECIFIED, res); | ||
234 | + } | ||
235 | + | ||
236 | + return value; | ||
237 | +} | ||
238 | + | ||
239 | +/* | ||
240 | + * This function handles the processing of following commands based on | ||
241 | + * the ItsCmdType parameter passed:- | ||
242 | + * 1. triggering of lpi interrupt translation via ITS INT command | ||
243 | + * 2. triggering of lpi interrupt translation via gits_translater register | ||
244 | + * 3. handling of ITS CLEAR command | ||
245 | + * 4. handling of ITS DISCARD command | ||
246 | + */ | ||
247 | +static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | ||
248 | + ItsCmdType cmd) | ||
249 | +{ | ||
250 | + AddressSpace *as = &s->gicv3->dma_as; | ||
251 | + uint32_t devid, eventid; | ||
252 | + MemTxResult res = MEMTX_OK; | ||
253 | + bool dte_valid; | ||
254 | + uint64_t dte = 0; | ||
255 | + uint32_t max_eventid; | ||
256 | + uint16_t icid = 0; | ||
257 | + uint32_t pIntid = 0; | ||
258 | + bool ite_valid = false; | ||
259 | + uint64_t cte = 0; | ||
260 | + bool cte_valid = false; | ||
261 | + bool result = false; | ||
262 | + | ||
263 | + if (cmd == NONE) { | ||
264 | + devid = offset; | ||
265 | + } else { | ||
266 | + devid = ((value & DEVID_MASK) >> DEVID_SHIFT); | ||
267 | + | ||
268 | + offset += NUM_BYTES_IN_DW; | ||
269 | + value = address_space_ldq_le(as, s->cq.base_addr + offset, | ||
270 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
271 | + } | ||
272 | + | ||
273 | + if (res != MEMTX_OK) { | ||
274 | + return result; | ||
275 | + } | ||
276 | + | ||
277 | + eventid = (value & EVENTID_MASK); | ||
278 | + | ||
279 | + dte = get_dte(s, devid, &res); | ||
280 | + | ||
281 | + if (res != MEMTX_OK) { | ||
282 | + return result; | ||
283 | + } | ||
284 | + dte_valid = dte & TABLE_ENTRY_VALID_MASK; | ||
285 | + | ||
286 | + if (dte_valid) { | ||
287 | + max_eventid = (1UL << (((dte >> 1U) & SIZE_MASK) + 1)); | ||
288 | + | ||
289 | + ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res); | ||
290 | + | ||
291 | + if (res != MEMTX_OK) { | ||
292 | + return result; | ||
293 | + } | ||
294 | + | ||
295 | + if (ite_valid) { | ||
296 | + cte_valid = get_cte(s, icid, &cte, &res); | ||
297 | + } | ||
298 | + | ||
299 | + if (res != MEMTX_OK) { | ||
300 | + return result; | ||
301 | + } | ||
302 | + } | ||
303 | + | ||
304 | + if ((devid > s->dt.maxids.max_devids) || !dte_valid || !ite_valid || | ||
305 | + !cte_valid || (eventid > max_eventid)) { | ||
306 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
307 | + "%s: invalid command attributes " | ||
308 | + "devid %d or eventid %d or invalid dte %d or" | ||
309 | + "invalid cte %d or invalid ite %d\n", | ||
310 | + __func__, devid, eventid, dte_valid, cte_valid, | ||
311 | + ite_valid); | ||
312 | + /* | ||
313 | + * in this implementation, in case of error | ||
314 | + * we ignore this command and move onto the next | ||
315 | + * command in the queue | ||
316 | + */ | ||
317 | + } else { | ||
318 | + /* | ||
319 | + * Current implementation only supports rdbase == procnum | ||
320 | + * Hence rdbase physical address is ignored | ||
321 | + */ | ||
322 | + if (cmd == DISCARD) { | ||
323 | + IteEntry ite = {}; | ||
324 | + /* remove mapping from interrupt translation table */ | ||
325 | + result = update_ite(s, eventid, dte, ite); | ||
326 | + } | ||
327 | + } | ||
328 | + | ||
329 | + return result; | ||
330 | +} | ||
331 | + | ||
332 | +static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, | ||
333 | + bool ignore_pInt) | ||
334 | +{ | ||
335 | + AddressSpace *as = &s->gicv3->dma_as; | ||
336 | + uint32_t devid, eventid; | ||
337 | + uint32_t pIntid = 0; | ||
338 | + uint32_t max_eventid, max_Intid; | ||
339 | + bool dte_valid; | ||
340 | + MemTxResult res = MEMTX_OK; | ||
341 | + uint16_t icid = 0; | ||
342 | + uint64_t dte = 0; | ||
343 | + IteEntry ite; | ||
344 | + uint32_t int_spurious = INTID_SPURIOUS; | ||
345 | + bool result = false; | ||
346 | + | ||
347 | + devid = ((value & DEVID_MASK) >> DEVID_SHIFT); | ||
348 | + offset += NUM_BYTES_IN_DW; | ||
349 | + value = address_space_ldq_le(as, s->cq.base_addr + offset, | ||
350 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
351 | + | ||
352 | + if (res != MEMTX_OK) { | ||
353 | + return result; | ||
354 | + } | ||
355 | + | ||
356 | + eventid = (value & EVENTID_MASK); | ||
357 | + | ||
358 | + if (!ignore_pInt) { | ||
359 | + pIntid = ((value & pINTID_MASK) >> pINTID_SHIFT); | ||
360 | + } | ||
361 | + | ||
362 | + offset += NUM_BYTES_IN_DW; | ||
363 | + value = address_space_ldq_le(as, s->cq.base_addr + offset, | ||
364 | + MEMTXATTRS_UNSPECIFIED, &res); | ||
365 | + | ||
366 | + if (res != MEMTX_OK) { | ||
367 | + return result; | ||
368 | + } | ||
369 | + | ||
370 | + icid = value & ICID_MASK; | ||
371 | + | ||
372 | + dte = get_dte(s, devid, &res); | ||
373 | + | ||
374 | + if (res != MEMTX_OK) { | ||
375 | + return result; | ||
376 | + } | ||
377 | + dte_valid = dte & TABLE_ENTRY_VALID_MASK; | ||
378 | + | ||
379 | + max_eventid = (1UL << (((dte >> 1U) & SIZE_MASK) + 1)); | ||
380 | + | ||
381 | + if (!ignore_pInt) { | ||
382 | + max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1; | ||
383 | + } | ||
384 | + | ||
385 | + if ((devid > s->dt.maxids.max_devids) || (icid > s->ct.maxids.max_collids) | ||
386 | + || !dte_valid || (eventid > max_eventid) || | ||
387 | + (!ignore_pInt && (((pIntid < GICV3_LPI_INTID_START) || | ||
388 | + (pIntid > max_Intid)) && (pIntid != INTID_SPURIOUS)))) { | ||
389 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
390 | + "%s: invalid command attributes " | ||
391 | + "devid %d or icid %d or eventid %d or pIntid %d or" | ||
392 | + "unmapped dte %d\n", __func__, devid, icid, eventid, | ||
393 | + pIntid, dte_valid); | ||
394 | + /* | ||
395 | + * in this implementation, in case of error | ||
396 | + * we ignore this command and move onto the next | ||
397 | + * command in the queue | ||
398 | + */ | ||
399 | + } else { | ||
400 | + /* add ite entry to interrupt translation table */ | ||
401 | + ite.itel = (dte_valid & TABLE_ENTRY_VALID_MASK) | | ||
402 | + (GITS_TYPE_PHYSICAL << ITE_ENTRY_INTTYPE_SHIFT); | ||
403 | + | ||
404 | + if (ignore_pInt) { | ||
405 | + ite.itel |= (eventid << ITE_ENTRY_INTID_SHIFT); | ||
406 | + } else { | ||
407 | + ite.itel |= (pIntid << ITE_ENTRY_INTID_SHIFT); | ||
408 | + } | ||
409 | + ite.itel |= (int_spurious << ITE_ENTRY_INTSP_SHIFT); | ||
410 | + ite.iteh = icid; | ||
411 | + | ||
412 | + result = update_ite(s, eventid, dte, ite); | ||
413 | + } | ||
414 | + | ||
415 | + return result; | ||
416 | +} | ||
417 | + | ||
418 | static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid, | ||
419 | uint64_t rdbase) | ||
420 | { | ||
421 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
422 | |||
423 | switch (cmd) { | ||
424 | case GITS_CMD_INT: | ||
425 | + res = process_its_cmd(s, data, cq_offset, INT); | ||
426 | break; | ||
427 | case GITS_CMD_CLEAR: | ||
428 | + res = process_its_cmd(s, data, cq_offset, CLEAR); | ||
429 | break; | ||
430 | case GITS_CMD_SYNC: | ||
431 | /* | ||
432 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
433 | result = process_mapc(s, cq_offset); | ||
434 | break; | ||
435 | case GITS_CMD_MAPTI: | ||
436 | + result = process_mapti(s, data, cq_offset, false); | ||
437 | break; | ||
438 | case GITS_CMD_MAPI: | ||
439 | + result = process_mapti(s, data, cq_offset, true); | ||
440 | break; | ||
441 | case GITS_CMD_DISCARD: | ||
442 | + result = process_its_cmd(s, data, cq_offset, DISCARD); | ||
443 | break; | ||
444 | case GITS_CMD_INV: | ||
445 | case GITS_CMD_INVALL: | ||
446 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicv3_its_translation_write(void *opaque, hwaddr offset, | ||
447 | uint64_t data, unsigned size, | ||
448 | MemTxAttrs attrs) | ||
449 | { | ||
450 | - return MEMTX_OK; | ||
451 | + GICv3ITSState *s = (GICv3ITSState *)opaque; | ||
452 | + bool result = true; | ||
453 | + uint32_t devid = 0; | ||
454 | + | ||
455 | + switch (offset) { | ||
456 | + case GITS_TRANSLATER: | ||
457 | + if (s->ctlr & ITS_CTLR_ENABLED) { | ||
458 | + devid = attrs.requester_id; | ||
459 | + result = process_its_cmd(s, data, devid, NONE); | ||
460 | + } | ||
461 | + break; | ||
462 | + default: | ||
463 | + break; | ||
464 | + } | ||
465 | + | ||
466 | + if (result) { | ||
467 | + return MEMTX_OK; | ||
468 | + } else { | ||
469 | + return MEMTX_ERROR; | ||
470 | + } | ||
55 | } | 471 | } |
56 | 472 | ||
57 | bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 473 | static bool its_writel(GICv3ITSState *s, hwaddr offset, |
58 | - int len, bool is_write) | ||
59 | + int len, bool is_write, | ||
60 | + MemTxAttrs attrs) | ||
61 | { | ||
62 | FlatView *fv; | ||
63 | bool result; | ||
64 | diff --git a/target/s390x/diag.c b/target/s390x/diag.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/s390x/diag.c | ||
67 | +++ b/target/s390x/diag.c | ||
68 | @@ -XXX,XX +XXX,XX @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) | ||
69 | return; | ||
70 | } | ||
71 | if (!address_space_access_valid(&address_space_memory, addr, | ||
72 | - sizeof(IplParameterBlock), false)) { | ||
73 | + sizeof(IplParameterBlock), false, | ||
74 | + MEMTXATTRS_UNSPECIFIED)) { | ||
75 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | ||
76 | return; | ||
77 | } | ||
78 | @@ -XXX,XX +XXX,XX @@ out: | ||
79 | return; | ||
80 | } | ||
81 | if (!address_space_access_valid(&address_space_memory, addr, | ||
82 | - sizeof(IplParameterBlock), true)) { | ||
83 | + sizeof(IplParameterBlock), true, | ||
84 | + MEMTXATTRS_UNSPECIFIED)) { | ||
85 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | ||
86 | return; | ||
87 | } | ||
88 | diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/s390x/excp_helper.c | ||
91 | +++ b/target/s390x/excp_helper.c | ||
92 | @@ -XXX,XX +XXX,XX @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size, | ||
93 | |||
94 | /* check out of RAM access */ | ||
95 | if (!address_space_access_valid(&address_space_memory, raddr, | ||
96 | - TARGET_PAGE_SIZE, rw)) { | ||
97 | + TARGET_PAGE_SIZE, rw, | ||
98 | + MEMTXATTRS_UNSPECIFIED)) { | ||
99 | DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__, | ||
100 | (uint64_t)raddr, (uint64_t)ram_size); | ||
101 | trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO); | ||
102 | diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/s390x/mmu_helper.c | ||
105 | +++ b/target/s390x/mmu_helper.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages, | ||
107 | return ret; | ||
108 | } | ||
109 | if (!address_space_access_valid(&address_space_memory, pages[i], | ||
110 | - TARGET_PAGE_SIZE, is_write)) { | ||
111 | + TARGET_PAGE_SIZE, is_write, | ||
112 | + MEMTXATTRS_UNSPECIFIED)) { | ||
113 | trigger_access_exception(env, PGM_ADDRESSING, ILEN_AUTO, 0); | ||
114 | return -EFAULT; | ||
115 | } | ||
116 | diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/target/s390x/sigp.c | ||
119 | +++ b/target/s390x/sigp.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg) | ||
121 | cpu_synchronize_state(cs); | ||
122 | |||
123 | if (!address_space_access_valid(&address_space_memory, addr, | ||
124 | - sizeof(struct LowCore), false)) { | ||
125 | + sizeof(struct LowCore), false, | ||
126 | + MEMTXATTRS_UNSPECIFIED)) { | ||
127 | set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); | ||
128 | return; | ||
129 | } | ||
130 | -- | 474 | -- |
131 | 2.17.1 | 475 | 2.20.1 |
132 | 476 | ||
133 | 477 | diff view generated by jsdifflib |
1 | From: Francisco Iglesias <frasse.iglesias@gmail.com> | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Coverity found that the string return by 'object_get_canonical_path' was not | 3 | Added properties to enable ITS feature and define qemu system |
4 | being freed at two locations in the model (CID 1391294 and CID 1391293) and | 4 | address space memory in gicv3 common,setup distributor and |
5 | also that a memset was being called with a value greater than the max of a byte | 5 | redistributor registers to indicate LPI support. |
6 | on the second argument (CID 1391286). This patch corrects this by adding the | ||
7 | freeing of the strings and also changing to memset to zero instead on | ||
8 | descriptor unaligned errors. | ||
9 | 6 | ||
10 | Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 7 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> |
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20180528184859.3530-1-frasse.iglesias@gmail.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Tested-by: Neil Armstrong <narmstrong@baylibre.com> | ||
10 | Message-id: 20210910143951.92242-6-shashi.mallela@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 12 | --- |
17 | hw/dma/xlnx-zdma.c | 10 +++++++--- | 13 | hw/intc/gicv3_internal.h | 2 ++ |
18 | 1 file changed, 7 insertions(+), 3 deletions(-) | 14 | include/hw/intc/arm_gicv3_common.h | 1 + |
15 | hw/intc/arm_gicv3_common.c | 12 ++++++++++++ | ||
16 | hw/intc/arm_gicv3_dist.c | 5 ++++- | ||
17 | hw/intc/arm_gicv3_redist.c | 12 +++++++++--- | ||
18 | 5 files changed, 28 insertions(+), 4 deletions(-) | ||
19 | 19 | ||
20 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c | 20 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/dma/xlnx-zdma.c | 22 | --- a/hw/intc/gicv3_internal.h |
23 | +++ b/hw/dma/xlnx-zdma.c | 23 | +++ b/hw/intc/gicv3_internal.h |
24 | @@ -XXX,XX +XXX,XX @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf) | 24 | @@ -XXX,XX +XXX,XX @@ |
25 | qemu_log_mask(LOG_GUEST_ERROR, | 25 | #define GICD_CTLR_E1NWF (1U << 7) |
26 | "zdma: unaligned descriptor at %" PRIx64, | 26 | #define GICD_CTLR_RWP (1U << 31) |
27 | addr); | 27 | |
28 | - memset(buf, 0xdeadbeef, sizeof(XlnxZDMADescr)); | 28 | +#define GICD_TYPER_LPIS_SHIFT 17 |
29 | + memset(buf, 0x0, sizeof(XlnxZDMADescr)); | 29 | + |
30 | s->error = true; | 30 | /* 16 bits EventId */ |
31 | return false; | 31 | #define GICD_TYPER_IDBITS 0xf |
32 | |||
33 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/include/hw/intc/arm_gicv3_common.h | ||
36 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
37 | @@ -XXX,XX +XXX,XX @@ struct GICv3State { | ||
38 | uint32_t num_cpu; | ||
39 | uint32_t num_irq; | ||
40 | uint32_t revision; | ||
41 | + bool lpi_enable; | ||
42 | bool security_extn; | ||
43 | bool irq_reset_nonsecure; | ||
44 | bool gicd_no_migration_shift_bug; | ||
45 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/intc/arm_gicv3_common.c | ||
48 | +++ b/hw/intc/arm_gicv3_common.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | ||
50 | return; | ||
32 | } | 51 | } |
33 | @@ -XXX,XX +XXX,XX @@ static uint64_t zdma_read(void *opaque, hwaddr addr, unsigned size) | 52 | |
34 | RegisterInfo *r = &s->regs_info[addr / 4]; | 53 | + if (s->lpi_enable && !s->dma) { |
35 | 54 | + error_setg(errp, "Redist-ITS: Guest 'sysmem' reference link not set"); | |
36 | if (!r->data) { | 55 | + return; |
37 | + gchar *path = object_get_canonical_path(OBJECT(s)); | 56 | + } |
38 | qemu_log("%s: Decode error: read from %" HWADDR_PRIx "\n", | 57 | + |
39 | - object_get_canonical_path(OBJECT(s)), | 58 | s->cpu = g_new0(GICv3CPUState, s->num_cpu); |
40 | + path, | 59 | |
41 | addr); | 60 | for (i = 0; i < s->num_cpu; i++) { |
42 | + g_free(path); | 61 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) |
43 | ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true); | 62 | (1 << 24) | |
44 | zdma_ch_imr_update_irq(s); | 63 | (i << 8) | |
45 | return 0; | 64 | (last << 4); |
46 | @@ -XXX,XX +XXX,XX @@ static void zdma_write(void *opaque, hwaddr addr, uint64_t value, | 65 | + |
47 | RegisterInfo *r = &s->regs_info[addr / 4]; | 66 | + if (s->lpi_enable) { |
48 | 67 | + s->cpu[i].gicr_typer |= GICR_TYPER_PLPIS; | |
49 | if (!r->data) { | 68 | + } |
50 | + gchar *path = object_get_canonical_path(OBJECT(s)); | 69 | } |
51 | qemu_log("%s: Decode error: write to %" HWADDR_PRIx "=%" PRIx64 "\n", | 70 | } |
52 | - object_get_canonical_path(OBJECT(s)), | 71 | |
53 | + path, | 72 | @@ -XXX,XX +XXX,XX @@ static Property arm_gicv3_common_properties[] = { |
54 | addr, value); | 73 | DEFINE_PROP_UINT32("num-cpu", GICv3State, num_cpu, 1), |
55 | + g_free(path); | 74 | DEFINE_PROP_UINT32("num-irq", GICv3State, num_irq, 32), |
56 | ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true); | 75 | DEFINE_PROP_UINT32("revision", GICv3State, revision, 3), |
57 | zdma_ch_imr_update_irq(s); | 76 | + DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0), |
58 | return; | 77 | DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0), |
78 | DEFINE_PROP_ARRAY("redist-region-count", GICv3State, nb_redist_regions, | ||
79 | redist_region_count, qdev_prop_uint32, uint32_t), | ||
80 | + DEFINE_PROP_LINK("sysmem", GICv3State, dma, TYPE_MEMORY_REGION, | ||
81 | + MemoryRegion *), | ||
82 | DEFINE_PROP_END_OF_LIST(), | ||
83 | }; | ||
84 | |||
85 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/hw/intc/arm_gicv3_dist.c | ||
88 | +++ b/hw/intc/arm_gicv3_dist.c | ||
89 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
90 | * A3V == 1 (non-zero values of Affinity level 3 supported) | ||
91 | * IDbits == 0xf (we support 16-bit interrupt identifiers) | ||
92 | * DVIS == 0 (Direct virtual LPI injection not supported) | ||
93 | - * LPIS == 0 (LPIs not supported) | ||
94 | + * LPIS == 1 (LPIs are supported if affinity routing is enabled) | ||
95 | + * num_LPIs == 0b00000 (bits [15:11],Number of LPIs as indicated | ||
96 | + * by GICD_TYPER.IDbits) | ||
97 | * MBIS == 0 (message-based SPIs not supported) | ||
98 | * SecurityExtn == 1 if security extns supported | ||
99 | * CPUNumber == 0 since for us ARE is always 1 | ||
100 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
101 | bool sec_extn = !(s->gicd_ctlr & GICD_CTLR_DS); | ||
102 | |||
103 | *data = (1 << 25) | (1 << 24) | (sec_extn << 10) | | ||
104 | + (s->lpi_enable << GICD_TYPER_LPIS_SHIFT) | | ||
105 | (0xf << 19) | itlinesnumber; | ||
106 | return true; | ||
107 | } | ||
108 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/hw/intc/arm_gicv3_redist.c | ||
111 | +++ b/hw/intc/arm_gicv3_redist.c | ||
112 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset, | ||
113 | case GICR_CTLR: | ||
114 | /* For our implementation, GICR_TYPER.DPGS is 0 and so all | ||
115 | * the DPG bits are RAZ/WI. We don't do anything asynchronously, | ||
116 | - * so UWP and RWP are RAZ/WI. And GICR_TYPER.LPIS is 0 (we don't | ||
117 | - * implement LPIs) so Enable_LPIs is RES0. So there are no writable | ||
118 | - * bits for us. | ||
119 | + * so UWP and RWP are RAZ/WI. GICR_TYPER.LPIS is 1 (we | ||
120 | + * implement LPIs) so Enable_LPIs is programmable. | ||
121 | */ | ||
122 | + if (cs->gicr_typer & GICR_TYPER_PLPIS) { | ||
123 | + if (value & GICR_CTLR_ENABLE_LPIS) { | ||
124 | + cs->gicr_ctlr |= GICR_CTLR_ENABLE_LPIS; | ||
125 | + } else { | ||
126 | + cs->gicr_ctlr &= ~GICR_CTLR_ENABLE_LPIS; | ||
127 | + } | ||
128 | + } | ||
129 | return MEMTX_OK; | ||
130 | case GICR_STATUSR: | ||
131 | /* RAZ/WI for our implementation */ | ||
59 | -- | 132 | -- |
60 | 2.17.1 | 133 | 2.20.1 |
61 | 134 | ||
62 | 135 | diff view generated by jsdifflib |
1 | From: Jan Kiszka <jan.kiszka@siemens.com> | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There was a nasty flip in identifying which register group an access is | 3 | Implemented lpi processing at redistributor to get lpi config info |
4 | targeting. The issue caused spuriously raised priorities of the guest | 4 | from lpi configuration table,determine priority,set pending state in |
5 | when handing CPUs over in the Jailhouse hypervisor. | 5 | lpi pending table and forward the lpi to cpuif.Added logic to invoke |
6 | 6 | redistributor lpi processing with translated LPI which set/clear LPI | |
7 | Cc: qemu-stable@nongnu.org | 7 | from ITS device as part of ITS INT,CLEAR,DISCARD command and |
8 | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> | 8 | GITS_TRANSLATER processing. |
9 | Message-id: 28b927d3-da58-bce4-cc13-bfec7f9b1cb9@siemens.com | 9 | |
10 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> | ||
11 | Tested-by: Neil Armstrong <narmstrong@baylibre.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Message-id: 20210910143951.92242-7-shashi.mallela@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 15 | --- |
13 | hw/intc/arm_gicv3_cpuif.c | 12 ++++++------ | 16 | hw/intc/gicv3_internal.h | 9 ++ |
14 | 1 file changed, 6 insertions(+), 6 deletions(-) | 17 | include/hw/intc/arm_gicv3_common.h | 7 ++ |
15 | 18 | hw/intc/arm_gicv3.c | 14 +++ | |
19 | hw/intc/arm_gicv3_common.c | 1 + | ||
20 | hw/intc/arm_gicv3_cpuif.c | 7 +- | ||
21 | hw/intc/arm_gicv3_its.c | 23 +++++ | ||
22 | hw/intc/arm_gicv3_redist.c | 141 +++++++++++++++++++++++++++++ | ||
23 | 7 files changed, 200 insertions(+), 2 deletions(-) | ||
24 | |||
25 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/intc/gicv3_internal.h | ||
28 | +++ b/hw/intc/gicv3_internal.h | ||
29 | @@ -XXX,XX +XXX,XX @@ FIELD(GICR_PENDBASER, PHYADDR, 16, 36) | ||
30 | FIELD(GICR_PENDBASER, OUTERCACHE, 56, 3) | ||
31 | FIELD(GICR_PENDBASER, PTZ, 62, 1) | ||
32 | |||
33 | +#define GICR_PROPBASER_IDBITS_THRESHOLD 0xd | ||
34 | + | ||
35 | #define ICC_CTLR_EL1_CBPR (1U << 0) | ||
36 | #define ICC_CTLR_EL1_EOIMODE (1U << 1) | ||
37 | #define ICC_CTLR_EL1_PMHE (1U << 6) | ||
38 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
39 | |||
40 | #define L1TABLE_ENTRY_SIZE 8 | ||
41 | |||
42 | +#define LPI_CTE_ENABLED TABLE_ENTRY_VALID_MASK | ||
43 | +#define LPI_PRIORITY_MASK 0xfc | ||
44 | + | ||
45 | #define GITS_CMDQ_ENTRY_SIZE 32 | ||
46 | #define NUM_BYTES_IN_DW 8 | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ FIELD(MAPC, RDBASE, 16, 32) | ||
49 | * Valid = 1 bit,RDBase = 36 bits(considering max RDBASE) | ||
50 | */ | ||
51 | #define GITS_CTE_SIZE (0x8ULL) | ||
52 | +#define GITS_CTE_RDBASE_PROCNUM_MASK MAKE_64BIT_MASK(1, RDBASE_PROCNUM_LENGTH) | ||
53 | |||
54 | /* Special interrupt IDs */ | ||
55 | #define INTID_SECURE 1020 | ||
56 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, | ||
57 | unsigned size, MemTxAttrs attrs); | ||
58 | void gicv3_dist_set_irq(GICv3State *s, int irq, int level); | ||
59 | void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level); | ||
60 | +void gicv3_redist_process_lpi(GICv3CPUState *cs, int irq, int level); | ||
61 | +void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level); | ||
62 | +void gicv3_redist_update_lpi(GICv3CPUState *cs); | ||
63 | void gicv3_redist_send_sgi(GICv3CPUState *cs, int grp, int irq, bool ns); | ||
64 | void gicv3_init_cpuif(GICv3State *s); | ||
65 | |||
66 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/include/hw/intc/arm_gicv3_common.h | ||
69 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
70 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | ||
71 | * real state above; it doesn't need to be migrated. | ||
72 | */ | ||
73 | PendingIrq hppi; | ||
74 | + | ||
75 | + /* | ||
76 | + * Cached information recalculated from LPI tables | ||
77 | + * in guest memory | ||
78 | + */ | ||
79 | + PendingIrq hpplpi; | ||
80 | + | ||
81 | /* This is temporary working state, to avoid a malloc in gicv3_update() */ | ||
82 | bool seenbetter; | ||
83 | }; | ||
84 | diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/hw/intc/arm_gicv3.c | ||
87 | +++ b/hw/intc/arm_gicv3.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs) | ||
89 | cs->hppi.grp = gicv3_irq_group(cs->gic, cs, cs->hppi.irq); | ||
90 | } | ||
91 | |||
92 | + if ((cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) && cs->gic->lpi_enable && | ||
93 | + (cs->hpplpi.prio != 0xff)) { | ||
94 | + if (irqbetter(cs, cs->hpplpi.irq, cs->hpplpi.prio)) { | ||
95 | + cs->hppi.irq = cs->hpplpi.irq; | ||
96 | + cs->hppi.prio = cs->hpplpi.prio; | ||
97 | + cs->hppi.grp = cs->hpplpi.grp; | ||
98 | + seenbetter = true; | ||
99 | + } | ||
100 | + } | ||
101 | + | ||
102 | /* If the best interrupt we just found would preempt whatever | ||
103 | * was the previous best interrupt before this update, then | ||
104 | * we know it's definitely the best one now. | ||
105 | @@ -XXX,XX +XXX,XX @@ static void gicv3_set_irq(void *opaque, int irq, int level) | ||
106 | |||
107 | static void arm_gicv3_post_load(GICv3State *s) | ||
108 | { | ||
109 | + int i; | ||
110 | /* Recalculate our cached idea of the current highest priority | ||
111 | * pending interrupt, but don't set IRQ or FIQ lines. | ||
112 | */ | ||
113 | + for (i = 0; i < s->num_cpu; i++) { | ||
114 | + gicv3_redist_update_lpi(&s->cpu[i]); | ||
115 | + } | ||
116 | gicv3_full_update_noirqset(s); | ||
117 | /* Repopulate the cache of GICv3CPUState pointers for target CPUs */ | ||
118 | gicv3_cache_all_target_cpustates(s); | ||
119 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/hw/intc/arm_gicv3_common.c | ||
122 | +++ b/hw/intc/arm_gicv3_common.c | ||
123 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_reset(DeviceState *dev) | ||
124 | memset(cs->gicr_ipriorityr, 0, sizeof(cs->gicr_ipriorityr)); | ||
125 | |||
126 | cs->hppi.prio = 0xff; | ||
127 | + cs->hpplpi.prio = 0xff; | ||
128 | |||
129 | /* State in the CPU interface must *not* be reset here, because it | ||
130 | * is part of the CPU's reset domain, not the GIC device's. | ||
16 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 131 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
17 | index XXXXXXX..XXXXXXX 100644 | 132 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/intc/arm_gicv3_cpuif.c | 133 | --- a/hw/intc/arm_gicv3_cpuif.c |
19 | +++ b/hw/intc/arm_gicv3_cpuif.c | 134 | +++ b/hw/intc/arm_gicv3_cpuif.c |
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | 135 | @@ -XXX,XX +XXX,XX @@ static void icc_activate_irq(GICv3CPUState *cs, int irq) |
136 | cs->gicr_iactiver0 = deposit32(cs->gicr_iactiver0, irq, 1, 1); | ||
137 | cs->gicr_ipendr0 = deposit32(cs->gicr_ipendr0, irq, 1, 0); | ||
138 | gicv3_redist_update(cs); | ||
139 | - } else { | ||
140 | + } else if (irq < GICV3_LPI_INTID_START) { | ||
141 | gicv3_gicd_active_set(cs->gic, irq); | ||
142 | gicv3_gicd_pending_clear(cs->gic, irq); | ||
143 | gicv3_update(cs->gic, irq, 1); | ||
144 | + } else { | ||
145 | + gicv3_redist_lpi_pending(cs, irq, 0); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | @@ -XXX,XX +XXX,XX @@ static void icc_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
150 | trace_gicv3_icc_eoir_write(is_eoir0 ? 0 : 1, | ||
151 | gicv3_redist_affid(cs), value); | ||
152 | |||
153 | - if (irq >= cs->gic->num_irq) { | ||
154 | + if ((irq >= cs->gic->num_irq) && | ||
155 | + !(cs->gic->lpi_enable && (irq >= GICV3_LPI_INTID_START))) { | ||
156 | /* This handles two cases: | ||
157 | * 1. If software writes the ID of a spurious interrupt [ie 1020-1023] | ||
158 | * to the GICC_EOIR, the GIC ignores that write. | ||
159 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/hw/intc/arm_gicv3_its.c | ||
162 | +++ b/hw/intc/arm_gicv3_its.c | ||
163 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | ||
164 | uint64_t cte = 0; | ||
165 | bool cte_valid = false; | ||
166 | bool result = false; | ||
167 | + uint64_t rdbase; | ||
168 | |||
169 | if (cmd == NONE) { | ||
170 | devid = offset; | ||
171 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | ||
172 | * Current implementation only supports rdbase == procnum | ||
173 | * Hence rdbase physical address is ignored | ||
174 | */ | ||
175 | + rdbase = (cte & GITS_CTE_RDBASE_PROCNUM_MASK) >> 1U; | ||
176 | + | ||
177 | + if (rdbase > s->gicv3->num_cpu) { | ||
178 | + return result; | ||
179 | + } | ||
180 | + | ||
181 | + if ((cmd == CLEAR) || (cmd == DISCARD)) { | ||
182 | + gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0); | ||
183 | + } else { | ||
184 | + gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1); | ||
185 | + } | ||
186 | + | ||
187 | if (cmd == DISCARD) { | ||
188 | IteEntry ite = {}; | ||
189 | /* remove mapping from interrupt translation table */ | ||
190 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
191 | MemTxResult res = MEMTX_OK; | ||
192 | bool result = true; | ||
193 | uint8_t cmd; | ||
194 | + int i; | ||
195 | |||
196 | if (!(s->ctlr & ITS_CTLR_ENABLED)) { | ||
197 | return; | ||
198 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
199 | break; | ||
200 | case GITS_CMD_INV: | ||
201 | case GITS_CMD_INVALL: | ||
202 | + /* | ||
203 | + * Current implementation doesn't cache any ITS tables, | ||
204 | + * but the calculated lpi priority information. We only | ||
205 | + * need to trigger lpi priority re-calculation to be in | ||
206 | + * sync with LPI config table or pending table changes. | ||
207 | + */ | ||
208 | + for (i = 0; i < s->gicv3->num_cpu; i++) { | ||
209 | + gicv3_redist_update_lpi(&s->gicv3->cpu[i]); | ||
210 | + } | ||
211 | break; | ||
212 | default: | ||
213 | break; | ||
214 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
215 | index XXXXXXX..XXXXXXX 100644 | ||
216 | --- a/hw/intc/arm_gicv3_redist.c | ||
217 | +++ b/hw/intc/arm_gicv3_redist.c | ||
218 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset, | ||
219 | if (cs->gicr_typer & GICR_TYPER_PLPIS) { | ||
220 | if (value & GICR_CTLR_ENABLE_LPIS) { | ||
221 | cs->gicr_ctlr |= GICR_CTLR_ENABLE_LPIS; | ||
222 | + /* Check for any pending interr in pending table */ | ||
223 | + gicv3_redist_update_lpi(cs); | ||
224 | + gicv3_redist_update(cs); | ||
225 | } else { | ||
226 | cs->gicr_ctlr &= ~GICR_CTLR_ENABLE_LPIS; | ||
227 | } | ||
228 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, | ||
229 | return r; | ||
230 | } | ||
231 | |||
232 | +static void gicv3_redist_check_lpi_priority(GICv3CPUState *cs, int irq) | ||
233 | +{ | ||
234 | + AddressSpace *as = &cs->gic->dma_as; | ||
235 | + uint64_t lpict_baddr; | ||
236 | + uint8_t lpite; | ||
237 | + uint8_t prio; | ||
238 | + | ||
239 | + lpict_baddr = cs->gicr_propbaser & R_GICR_PROPBASER_PHYADDR_MASK; | ||
240 | + | ||
241 | + address_space_read(as, lpict_baddr + ((irq - GICV3_LPI_INTID_START) * | ||
242 | + sizeof(lpite)), MEMTXATTRS_UNSPECIFIED, &lpite, | ||
243 | + sizeof(lpite)); | ||
244 | + | ||
245 | + if (!(lpite & LPI_CTE_ENABLED)) { | ||
246 | + return; | ||
247 | + } | ||
248 | + | ||
249 | + if (cs->gic->gicd_ctlr & GICD_CTLR_DS) { | ||
250 | + prio = lpite & LPI_PRIORITY_MASK; | ||
251 | + } else { | ||
252 | + prio = ((lpite & LPI_PRIORITY_MASK) >> 1) | 0x80; | ||
253 | + } | ||
254 | + | ||
255 | + if ((prio < cs->hpplpi.prio) || | ||
256 | + ((prio == cs->hpplpi.prio) && (irq <= cs->hpplpi.irq))) { | ||
257 | + cs->hpplpi.irq = irq; | ||
258 | + cs->hpplpi.prio = prio; | ||
259 | + /* LPIs are always non-secure Grp1 interrupts */ | ||
260 | + cs->hpplpi.grp = GICV3_G1NS; | ||
261 | + } | ||
262 | +} | ||
263 | + | ||
264 | +void gicv3_redist_update_lpi(GICv3CPUState *cs) | ||
265 | +{ | ||
266 | + /* | ||
267 | + * This function scans the LPI pending table and for each pending | ||
268 | + * LPI, reads the corresponding entry from LPI configuration table | ||
269 | + * to extract the priority info and determine if the current LPI | ||
270 | + * priority is lower than the last computed high priority lpi interrupt. | ||
271 | + * If yes, replace current LPI as the new high priority lpi interrupt. | ||
272 | + */ | ||
273 | + AddressSpace *as = &cs->gic->dma_as; | ||
274 | + uint64_t lpipt_baddr; | ||
275 | + uint32_t pendt_size = 0; | ||
276 | + uint8_t pend; | ||
277 | + int i, bit; | ||
278 | + uint64_t idbits; | ||
279 | + | ||
280 | + idbits = MIN(FIELD_EX64(cs->gicr_propbaser, GICR_PROPBASER, IDBITS), | ||
281 | + GICD_TYPER_IDBITS); | ||
282 | + | ||
283 | + if (!(cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) || !cs->gicr_propbaser || | ||
284 | + !cs->gicr_pendbaser) { | ||
285 | + return; | ||
286 | + } | ||
287 | + | ||
288 | + cs->hpplpi.prio = 0xff; | ||
289 | + | ||
290 | + lpipt_baddr = cs->gicr_pendbaser & R_GICR_PENDBASER_PHYADDR_MASK; | ||
291 | + | ||
292 | + /* Determine the highest priority pending interrupt among LPIs */ | ||
293 | + pendt_size = (1ULL << (idbits + 1)); | ||
294 | + | ||
295 | + for (i = GICV3_LPI_INTID_START / 8; i < pendt_size / 8; i++) { | ||
296 | + address_space_read(as, lpipt_baddr + i, MEMTXATTRS_UNSPECIFIED, &pend, | ||
297 | + sizeof(pend)); | ||
298 | + | ||
299 | + while (pend) { | ||
300 | + bit = ctz32(pend); | ||
301 | + gicv3_redist_check_lpi_priority(cs, i * 8 + bit); | ||
302 | + pend &= ~(1 << bit); | ||
303 | + } | ||
304 | + } | ||
305 | +} | ||
306 | + | ||
307 | +void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level) | ||
308 | +{ | ||
309 | + /* | ||
310 | + * This function updates the pending bit in lpi pending table for | ||
311 | + * the irq being activated or deactivated. | ||
312 | + */ | ||
313 | + AddressSpace *as = &cs->gic->dma_as; | ||
314 | + uint64_t lpipt_baddr; | ||
315 | + bool ispend = false; | ||
316 | + uint8_t pend; | ||
317 | + | ||
318 | + /* | ||
319 | + * get the bit value corresponding to this irq in the | ||
320 | + * lpi pending table | ||
321 | + */ | ||
322 | + lpipt_baddr = cs->gicr_pendbaser & R_GICR_PENDBASER_PHYADDR_MASK; | ||
323 | + | ||
324 | + address_space_read(as, lpipt_baddr + ((irq / 8) * sizeof(pend)), | ||
325 | + MEMTXATTRS_UNSPECIFIED, &pend, sizeof(pend)); | ||
326 | + | ||
327 | + ispend = extract32(pend, irq % 8, 1); | ||
328 | + | ||
329 | + /* no change in the value of pending bit, return */ | ||
330 | + if (ispend == level) { | ||
331 | + return; | ||
332 | + } | ||
333 | + pend = deposit32(pend, irq % 8, 1, level ? 1 : 0); | ||
334 | + | ||
335 | + address_space_write(as, lpipt_baddr + ((irq / 8) * sizeof(pend)), | ||
336 | + MEMTXATTRS_UNSPECIFIED, &pend, sizeof(pend)); | ||
337 | + | ||
338 | + /* | ||
339 | + * check if this LPI is better than the current hpplpi, if yes | ||
340 | + * just set hpplpi.prio and .irq without doing a full rescan | ||
341 | + */ | ||
342 | + if (level) { | ||
343 | + gicv3_redist_check_lpi_priority(cs, irq); | ||
344 | + } else { | ||
345 | + if (irq == cs->hpplpi.irq) { | ||
346 | + gicv3_redist_update_lpi(cs); | ||
347 | + } | ||
348 | + } | ||
349 | +} | ||
350 | + | ||
351 | +void gicv3_redist_process_lpi(GICv3CPUState *cs, int irq, int level) | ||
352 | +{ | ||
353 | + uint64_t idbits; | ||
354 | + | ||
355 | + idbits = MIN(FIELD_EX64(cs->gicr_propbaser, GICR_PROPBASER, IDBITS), | ||
356 | + GICD_TYPER_IDBITS); | ||
357 | + | ||
358 | + if (!(cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) || !cs->gicr_propbaser || | ||
359 | + !cs->gicr_pendbaser || (irq > (1ULL << (idbits + 1)) - 1) || | ||
360 | + irq < GICV3_LPI_INTID_START) { | ||
361 | + return; | ||
362 | + } | ||
363 | + | ||
364 | + /* set/clear the pending bit for this irq */ | ||
365 | + gicv3_redist_lpi_pending(cs, irq, level); | ||
366 | + | ||
367 | + gicv3_redist_update(cs); | ||
368 | +} | ||
369 | + | ||
370 | void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level) | ||
21 | { | 371 | { |
22 | GICv3CPUState *cs = icc_cs_from_env(env); | 372 | /* Update redistributor state for a change in an external PPI input line */ |
23 | int regno = ri->opc2 & 3; | ||
24 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
25 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
26 | uint64_t value = cs->ich_apr[grp][regno]; | ||
27 | |||
28 | trace_gicv3_icv_ap_read(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
29 | @@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
30 | { | ||
31 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
32 | int regno = ri->opc2 & 3; | ||
33 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
34 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
35 | |||
36 | trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
39 | uint64_t value; | ||
40 | |||
41 | int regno = ri->opc2 & 3; | ||
42 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; | ||
43 | + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; | ||
44 | |||
45 | if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { | ||
46 | return icv_ap_read(env, ri); | ||
47 | @@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
48 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
49 | |||
50 | int regno = ri->opc2 & 3; | ||
51 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; | ||
52 | + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; | ||
53 | |||
54 | if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { | ||
55 | icv_ap_write(env, ri, value); | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
57 | { | ||
58 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
59 | int regno = ri->opc2 & 3; | ||
60 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
61 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
62 | uint64_t value; | ||
63 | |||
64 | value = cs->ich_apr[grp][regno]; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
66 | { | ||
67 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
68 | int regno = ri->opc2 & 3; | ||
69 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
70 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
71 | |||
72 | trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
73 | |||
74 | -- | 373 | -- |
75 | 2.17.1 | 374 | 2.20.1 |
76 | 375 | ||
77 | 376 | diff view generated by jsdifflib |
1 | From: Paolo Bonzini <pbonzini@redhat.com> | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | cpregs_keys is an uint32_t* so the allocation should use uint32_t. | 3 | Added expected IORT files applicable with latest GICv3 |
4 | g_new is even better because it is type-safe. | 4 | ITS changes.Temporarily differences in these files are |
5 | okay. | ||
5 | 6 | ||
6 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | 7 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> |
8 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 10 | Message-id: 20210910143951.92242-8-shashi.mallela@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | target/arm/gdbstub.c | 3 +-- | 13 | tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ |
12 | 1 file changed, 1 insertion(+), 2 deletions(-) | 14 | tests/data/acpi/virt/IORT | 0 |
15 | tests/data/acpi/virt/IORT.memhp | 0 | ||
16 | tests/data/acpi/virt/IORT.numamem | 0 | ||
17 | tests/data/acpi/virt/IORT.pxb | 0 | ||
18 | 5 files changed, 4 insertions(+) | ||
19 | create mode 100644 tests/data/acpi/virt/IORT | ||
20 | create mode 100644 tests/data/acpi/virt/IORT.memhp | ||
21 | create mode 100644 tests/data/acpi/virt/IORT.numamem | ||
22 | create mode 100644 tests/data/acpi/virt/IORT.pxb | ||
13 | 23 | ||
14 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | 24 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h |
15 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/gdbstub.c | 26 | --- a/tests/qtest/bios-tables-test-allowed-diff.h |
17 | +++ b/target/arm/gdbstub.c | 27 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h |
18 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_xml(CPUState *cs) | 28 | @@ -1 +1,5 @@ |
19 | RegisterSysregXmlParam param = {cs, s}; | 29 | /* List of comma-separated changed AML files to ignore */ |
20 | 30 | +"tests/data/acpi/virt/IORT", | |
21 | cpu->dyn_xml.num_cpregs = 0; | 31 | +"tests/data/acpi/virt/IORT.memhp", |
22 | - cpu->dyn_xml.cpregs_keys = g_malloc(sizeof(uint32_t *) * | 32 | +"tests/data/acpi/virt/IORT.numamem", |
23 | - g_hash_table_size(cpu->cp_regs)); | 33 | +"tests/data/acpi/virt/IORT.pxb", |
24 | + cpu->dyn_xml.cpregs_keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); | 34 | diff --git a/tests/data/acpi/virt/IORT b/tests/data/acpi/virt/IORT |
25 | g_string_printf(s, "<?xml version=\"1.0\"?>"); | 35 | new file mode 100644 |
26 | g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); | 36 | index XXXXXXX..XXXXXXX |
27 | g_string_append_printf(s, "<feature name=\"org.qemu.gdb.arm.sys.regs\">"); | 37 | diff --git a/tests/data/acpi/virt/IORT.memhp b/tests/data/acpi/virt/IORT.memhp |
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | diff --git a/tests/data/acpi/virt/IORT.numamem b/tests/data/acpi/virt/IORT.numamem | ||
41 | new file mode 100644 | ||
42 | index XXXXXXX..XXXXXXX | ||
43 | diff --git a/tests/data/acpi/virt/IORT.pxb b/tests/data/acpi/virt/IORT.pxb | ||
44 | new file mode 100644 | ||
45 | index XXXXXXX..XXXXXXX | ||
28 | -- | 46 | -- |
29 | 2.17.1 | 47 | 2.20.1 |
30 | 48 | ||
31 | 49 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_access_valid(). | ||
3 | Its callers now all have an attrs value to hand, so we can | ||
4 | correct our earlier temporary use of MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Included creation of ITS as part of virt platform GIC | ||
4 | initialization. This Emulated ITS model now co-exists with kvm | ||
5 | ITS and is enabled in absence of kvm irq kernel support in a | ||
6 | platform. | ||
7 | |||
8 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20210910143951.92242-9-shashi.mallela@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-10-peter.maydell@linaro.org | ||
10 | --- | 12 | --- |
11 | exec.c | 12 +++++------- | 13 | include/hw/arm/virt.h | 2 ++ |
12 | 1 file changed, 5 insertions(+), 7 deletions(-) | 14 | target/arm/kvm_arm.h | 4 ++-- |
15 | hw/arm/virt.c | 29 +++++++++++++++++++++++++++-- | ||
16 | 3 files changed, 31 insertions(+), 4 deletions(-) | ||
13 | 17 | ||
14 | diff --git a/exec.c b/exec.c | 18 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/exec.c | 20 | --- a/include/hw/arm/virt.h |
17 | +++ b/exec.c | 21 | +++ b/include/hw/arm/virt.h |
18 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | 22 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineClass { |
19 | static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | 23 | MachineClass parent; |
20 | const uint8_t *buf, int len); | 24 | bool disallow_affinity_adjustment; |
21 | static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 25 | bool no_its; |
22 | - bool is_write); | 26 | + bool no_tcg_its; |
23 | + bool is_write, MemTxAttrs attrs); | 27 | bool no_pmu; |
24 | 28 | bool claim_edge_triggered_timers; | |
25 | static MemTxResult subpage_read(void *opaque, hwaddr addr, uint64_t *data, | 29 | bool smbios_old_sys_ver; |
26 | unsigned len, MemTxAttrs attrs) | 30 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { |
27 | @@ -XXX,XX +XXX,XX @@ static bool subpage_accepts(void *opaque, hwaddr addr, | 31 | bool highmem; |
28 | #endif | 32 | bool highmem_ecam; |
29 | 33 | bool its; | |
30 | return flatview_access_valid(subpage->fv, addr + subpage->base, | 34 | + bool tcg_its; |
31 | - len, is_write); | 35 | bool virt; |
32 | + len, is_write, attrs); | 36 | bool ras; |
37 | bool mte; | ||
38 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/kvm_arm.h | ||
41 | +++ b/target/arm/kvm_arm.h | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline const char *its_class_name(void) | ||
43 | /* KVM implementation requires this capability */ | ||
44 | return kvm_direct_msi_enabled() ? "arm-its-kvm" : NULL; | ||
45 | } else { | ||
46 | - /* Software emulation is not implemented yet */ | ||
47 | - return NULL; | ||
48 | + /* Software emulation based model */ | ||
49 | + return "arm-gicv3-its"; | ||
50 | } | ||
33 | } | 51 | } |
34 | 52 | ||
35 | static const MemoryRegionOps subpage_ops = { | 53 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
36 | @@ -XXX,XX +XXX,XX @@ static void cpu_notify_map_clients(void) | 54 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/hw/arm/virt.c | ||
56 | +++ b/hw/arm/virt.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void create_its(VirtMachineState *vms) | ||
58 | const char *itsclass = its_class_name(); | ||
59 | DeviceState *dev; | ||
60 | |||
61 | + if (!strcmp(itsclass, "arm-gicv3-its")) { | ||
62 | + if (!vms->tcg_its) { | ||
63 | + itsclass = NULL; | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | if (!itsclass) { | ||
68 | /* Do nothing if not supported */ | ||
69 | return; | ||
70 | @@ -XXX,XX +XXX,XX @@ static void create_v2m(VirtMachineState *vms) | ||
71 | vms->msi_controller = VIRT_MSI_CTRL_GICV2M; | ||
37 | } | 72 | } |
38 | 73 | ||
39 | static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 74 | -static void create_gic(VirtMachineState *vms) |
40 | - bool is_write) | 75 | +static void create_gic(VirtMachineState *vms, MemoryRegion *mem) |
41 | + bool is_write, MemTxAttrs attrs) | ||
42 | { | 76 | { |
43 | MemoryRegion *mr; | 77 | MachineState *ms = MACHINE(vms); |
44 | hwaddr l, xlat; | 78 | /* We create a standalone GIC */ |
45 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 79 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms) |
46 | mr = flatview_translate(fv, addr, &xlat, &l, is_write); | 80 | nb_redist_regions); |
47 | if (!memory_access_is_direct(mr, is_write)) { | 81 | qdev_prop_set_uint32(vms->gic, "redist-region-count[0]", redist0_count); |
48 | l = memory_access_size(mr, l, addr); | 82 | |
49 | - /* When our callers all have attrs we'll pass them through here */ | 83 | + if (!kvm_irqchip_in_kernel()) { |
50 | - if (!memory_region_access_valid(mr, xlat, l, is_write, | 84 | + if (vms->tcg_its) { |
51 | - MEMTXATTRS_UNSPECIFIED)) { | 85 | + object_property_set_link(OBJECT(vms->gic), "sysmem", |
52 | + if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) { | 86 | + OBJECT(mem), &error_fatal); |
53 | return false; | 87 | + qdev_prop_set_bit(vms->gic, "has-lpi", true); |
54 | } | 88 | + } |
55 | } | 89 | + } |
56 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 90 | + |
57 | 91 | if (nb_redist_regions == 2) { | |
58 | rcu_read_lock(); | 92 | uint32_t redist1_capacity = |
59 | fv = address_space_to_flatview(as); | 93 | vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE; |
60 | - result = flatview_access_valid(fv, addr, len, is_write); | 94 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
61 | + result = flatview_access_valid(fv, addr, len, is_write, attrs); | 95 | |
62 | rcu_read_unlock(); | 96 | virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); |
63 | return result; | 97 | |
98 | - create_gic(vms); | ||
99 | + create_gic(vms, sysmem); | ||
100 | |||
101 | virt_cpu_post_init(vms, sysmem); | ||
102 | |||
103 | @@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj) | ||
104 | } else { | ||
105 | /* Default allows ITS instantiation */ | ||
106 | vms->its = true; | ||
107 | + | ||
108 | + if (vmc->no_tcg_its) { | ||
109 | + vms->tcg_its = false; | ||
110 | + } else { | ||
111 | + vms->tcg_its = true; | ||
112 | + } | ||
113 | } | ||
114 | |||
115 | /* Default disallows iommu instantiation */ | ||
116 | @@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(6, 2) | ||
117 | |||
118 | static void virt_machine_6_1_options(MachineClass *mc) | ||
119 | { | ||
120 | + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); | ||
121 | + | ||
122 | virt_machine_6_2_options(mc); | ||
123 | compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); | ||
124 | + | ||
125 | + /* qemu ITS was introduced with 6.2 */ | ||
126 | + vmc->no_tcg_its = true; | ||
64 | } | 127 | } |
128 | DEFINE_VIRT_MACHINE(6, 1) | ||
129 | |||
65 | -- | 130 | -- |
66 | 2.17.1 | 131 | 2.20.1 |
67 | 132 | ||
68 | 133 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Shashi Mallela <shashi.mallela@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | It forgot to increase clroffset during the loop. So it only clear the | 3 | Updated expected IORT files applicable with latest GICv3 |
4 | first 4 bytes. | 4 | ITS changes. |
5 | 5 | ||
6 | Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920 | 6 | Full diff of new file disassembly: |
7 | Cc: qemu-stable@nongnu.org | 7 | |
8 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 8 | /* |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 9 | * Intel ACPI Component Architecture |
10 | Message-id: 1527047633-12368-1-git-send-email-zhaoshenglong@huawei.com | 10 | * AML/ASL+ Disassembler version 20180629 (64-bit version) |
11 | * Copyright (c) 2000 - 2018 Intel Corporation | ||
12 | * | ||
13 | * Disassembly of tests/data/acpi/virt/IORT.pxb, Tue Jun 29 17:35:38 2021 | ||
14 | * | ||
15 | * ACPI Data Table [IORT] | ||
16 | * | ||
17 | * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue | ||
18 | */ | ||
19 | |||
20 | [000h 0000 4] Signature : "IORT" [IO Remapping Table] | ||
21 | [004h 0004 4] Table Length : 0000007C | ||
22 | [008h 0008 1] Revision : 00 | ||
23 | [009h 0009 1] Checksum : 07 | ||
24 | [00Ah 0010 6] Oem ID : "BOCHS " | ||
25 | [010h 0016 8] Oem Table ID : "BXPC " | ||
26 | [018h 0024 4] Oem Revision : 00000001 | ||
27 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | ||
28 | [020h 0032 4] Asl Compiler Revision : 00000001 | ||
29 | |||
30 | [024h 0036 4] Node Count : 00000002 | ||
31 | [028h 0040 4] Node Offset : 00000030 | ||
32 | [02Ch 0044 4] Reserved : 00000000 | ||
33 | |||
34 | [030h 0048 1] Type : 00 | ||
35 | [031h 0049 2] Length : 0018 | ||
36 | [033h 0051 1] Revision : 00 | ||
37 | [034h 0052 4] Reserved : 00000000 | ||
38 | [038h 0056 4] Mapping Count : 00000000 | ||
39 | [03Ch 0060 4] Mapping Offset : 00000000 | ||
40 | |||
41 | [040h 0064 4] ItsCount : 00000001 | ||
42 | [044h 0068 4] Identifiers : 00000000 | ||
43 | |||
44 | [048h 0072 1] Type : 02 | ||
45 | [049h 0073 2] Length : 0034 | ||
46 | [04Bh 0075 1] Revision : 00 | ||
47 | [04Ch 0076 4] Reserved : 00000000 | ||
48 | [050h 0080 4] Mapping Count : 00000001 | ||
49 | [054h 0084 4] Mapping Offset : 00000020 | ||
50 | |||
51 | [058h 0088 8] Memory Properties : [IORT Memory Access Properties] | ||
52 | [058h 0088 4] Cache Coherency : 00000001 | ||
53 | [05Ch 0092 1] Hints (decoded below) : 00 | ||
54 | Transient : 0 | ||
55 | Write Allocate : 0 | ||
56 | Read Allocate : 0 | ||
57 | Override : 0 | ||
58 | [05Dh 0093 2] Reserved : 0000 | ||
59 | [05Fh 0095 1] Memory Flags (decoded below) : 03 | ||
60 | Coherency : 1 | ||
61 | Device Attribute : 1 | ||
62 | [060h 0096 4] ATS Attribute : 00000000 | ||
63 | [064h 0100 4] PCI Segment Number : 00000000 | ||
64 | [068h 0104 1] Memory Size Limit : 00 | ||
65 | [069h 0105 3] Reserved : 000000 | ||
66 | |||
67 | [068h 0104 4] Input base : 00000000 | ||
68 | [06Ch 0108 4] ID Count : 0000FFFF | ||
69 | [070h 0112 4] Output Base : 00000000 | ||
70 | [074h 0116 4] Output Reference : 00000030 | ||
71 | [078h 0120 4] Flags (decoded below) : 00000000 | ||
72 | Single Mapping : 0 | ||
73 | |||
74 | Raw Table Data: Length 124 (0x7C) | ||
75 | |||
76 | 0000: 49 4F 52 54 7C 00 00 00 00 07 42 4F 43 48 53 20 // IORT|.....BOCHS | ||
77 | 0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC | ||
78 | 0020: 01 00 00 00 02 00 00 00 30 00 00 00 00 00 00 00 // ........0....... | ||
79 | 0030: 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
80 | 0040: 01 00 00 00 00 00 00 00 02 34 00 00 00 00 00 00 // .........4...... | ||
81 | 0050: 01 00 00 00 20 00 00 00 01 00 00 00 00 00 00 03 // .... ........... | ||
82 | 0060: 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 // ................ | ||
83 | 0070: 00 00 00 00 30 00 00 00 00 00 00 00 // ....0....... | ||
84 | |||
85 | Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> | ||
86 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 87 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
88 | Message-id: 20210910143951.92242-10-shashi.mallela@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 89 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 90 | --- |
14 | hw/intc/arm_gicv3_kvm.c | 1 + | 91 | tests/qtest/bios-tables-test-allowed-diff.h | 4 ---- |
15 | 1 file changed, 1 insertion(+) | 92 | tests/data/acpi/virt/IORT | Bin 0 -> 124 bytes |
93 | tests/data/acpi/virt/IORT.memhp | Bin 0 -> 124 bytes | ||
94 | tests/data/acpi/virt/IORT.numamem | Bin 0 -> 124 bytes | ||
95 | tests/data/acpi/virt/IORT.pxb | Bin 0 -> 124 bytes | ||
96 | 5 files changed, 4 deletions(-) | ||
16 | 97 | ||
17 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 98 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h |
18 | index XXXXXXX..XXXXXXX 100644 | 99 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/arm_gicv3_kvm.c | 100 | --- a/tests/qtest/bios-tables-test-allowed-diff.h |
20 | +++ b/hw/intc/arm_gicv3_kvm.c | 101 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h |
21 | @@ -XXX,XX +XXX,XX @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset, | 102 | @@ -1,5 +1 @@ |
22 | if (clroffset != 0) { | 103 | /* List of comma-separated changed AML files to ignore */ |
23 | reg = 0; | 104 | -"tests/data/acpi/virt/IORT", |
24 | kvm_gicd_access(s, clroffset, ®, true); | 105 | -"tests/data/acpi/virt/IORT.memhp", |
25 | + clroffset += 4; | 106 | -"tests/data/acpi/virt/IORT.numamem", |
26 | } | 107 | -"tests/data/acpi/virt/IORT.pxb", |
27 | reg = *gic_bmp_ptr32(bmp, irq); | 108 | diff --git a/tests/data/acpi/virt/IORT b/tests/data/acpi/virt/IORT |
28 | kvm_gicd_access(s, offset, ®, true); | 109 | index XXXXXXX..XXXXXXX 100644 |
110 | GIT binary patch | ||
111 | literal 124 | ||
112 | zcmebD4+^Pa00MR=e`k+i1*eDrX9XZ&1PX!JAesq?4S*O7Bw!2(4Uz`|CKCt^;wu0# | ||
113 | QRGb+i3L*dhhtM#y0PN=p0RR91 | ||
114 | |||
115 | literal 0 | ||
116 | HcmV?d00001 | ||
117 | |||
118 | diff --git a/tests/data/acpi/virt/IORT.memhp b/tests/data/acpi/virt/IORT.memhp | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | GIT binary patch | ||
121 | literal 124 | ||
122 | zcmebD4+^Pa00MR=e`k+i1*eDrX9XZ&1PX!JAesq?4S*O7Bw!2(4Uz`|CKCt^;wu0# | ||
123 | QRGb+i3L*dhhtM#y0PN=p0RR91 | ||
124 | |||
125 | literal 0 | ||
126 | HcmV?d00001 | ||
127 | |||
128 | diff --git a/tests/data/acpi/virt/IORT.numamem b/tests/data/acpi/virt/IORT.numamem | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | GIT binary patch | ||
131 | literal 124 | ||
132 | zcmebD4+^Pa00MR=e`k+i1*eDrX9XZ&1PX!JAesq?4S*O7Bw!2(4Uz`|CKCt^;wu0# | ||
133 | QRGb+i3L*dhhtM#y0PN=p0RR91 | ||
134 | |||
135 | literal 0 | ||
136 | HcmV?d00001 | ||
137 | |||
138 | diff --git a/tests/data/acpi/virt/IORT.pxb b/tests/data/acpi/virt/IORT.pxb | ||
139 | index XXXXXXX..XXXXXXX 100644 | ||
140 | GIT binary patch | ||
141 | literal 124 | ||
142 | zcmebD4+^Pa00MR=e`k+i1*eDrX9XZ&1PX!JAesq?4S*O7Bw!2(4Uz`|CKCt^;wu0# | ||
143 | QRGb+i3L*dhhtM#y0PN=p0RR91 | ||
144 | |||
145 | literal 0 | ||
146 | HcmV?d00001 | ||
147 | |||
29 | -- | 148 | -- |
30 | 2.17.1 | 149 | 2.20.1 |
31 | 150 | ||
32 | 151 | diff view generated by jsdifflib |
1 | The FRECPX instructions should (like most other floating point operations) | 1 | In v8A, the PSTATE.IL bit is set for various kinds of illegal |
---|---|---|---|
2 | honour the FPCR.FZ bit which specifies whether input denormals should | 2 | exception return or mode-change attempts. We already set PSTATE.IL |
3 | be flushed to zero (or FZ16 for the half-precision version). | 3 | (or its AArch32 equivalent CPSR.IL) in all those cases, but we |
4 | We forgot to implement this, which doesn't affect the results (since | 4 | weren't implementing the part of the behaviour where attempting to |
5 | the calculation doesn't actually care about the mantissa bits) but did | 5 | execute an instruction with PSTATE.IL takes an immediate exception |
6 | mean we were failing to set the FPSR.IDC bit. | 6 | with an appropriate syndrome value. |
7 | |||
8 | Add a new TB flags bit tracking PSTATE.IL/CPSR.IL, and generate code | ||
9 | to take an exception instead of whatever the instruction would have | ||
10 | been. | ||
11 | |||
12 | PSTATE.IL and CPSR.IL change only on exception entry, attempted | ||
13 | exception exit, and various AArch32 mode changes via cpsr_write(). | ||
14 | These places generally already rebuild the hflags, so the only place | ||
15 | we need an extra rebuild_hflags call is in the illegal-return | ||
16 | codepath of the AArch64 exception_return helper. | ||
7 | 17 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20180521172712.19930-1-peter.maydell@linaro.org | 21 | Message-id: 20210821195958.41312-2-richard.henderson@linaro.org |
22 | Message-Id: <20210817162118.24319-1-peter.maydell@linaro.org> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | [rth: Added missing returns; set IL bit in syndrome] | ||
25 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | 26 | --- |
12 | target/arm/helper-a64.c | 6 ++++++ | 27 | target/arm/cpu.h | 1 + |
13 | 1 file changed, 6 insertions(+) | 28 | target/arm/syndrome.h | 5 +++++ |
29 | target/arm/translate.h | 2 ++ | ||
30 | target/arm/helper-a64.c | 1 + | ||
31 | target/arm/helper.c | 8 ++++++++ | ||
32 | target/arm/translate-a64.c | 11 +++++++++++ | ||
33 | target/arm/translate.c | 21 +++++++++++++++++++++ | ||
34 | 7 files changed, 49 insertions(+) | ||
14 | 35 | ||
36 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/cpu.h | ||
39 | +++ b/target/arm/cpu.h | ||
40 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) | ||
41 | FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 10, 2) | ||
42 | /* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */ | ||
43 | FIELD(TBFLAG_ANY, ALIGN_MEM, 12, 1) | ||
44 | +FIELD(TBFLAG_ANY, PSTATE__IL, 13, 1) | ||
45 | |||
46 | /* | ||
47 | * Bit usage when in AArch32 state, both A- and M-profile. | ||
48 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/syndrome.h | ||
51 | +++ b/target/arm/syndrome.h | ||
52 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_wfx(int cv, int cond, int ti, bool is_16bit) | ||
53 | (cv << 24) | (cond << 20) | ti; | ||
54 | } | ||
55 | |||
56 | +static inline uint32_t syn_illegalstate(void) | ||
57 | +{ | ||
58 | + return (EC_ILLEGALSTATE << ARM_EL_EC_SHIFT) | ARM_EL_IL; | ||
59 | +} | ||
60 | + | ||
61 | #endif /* TARGET_ARM_SYNDROME_H */ | ||
62 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/arm/translate.h | ||
65 | +++ b/target/arm/translate.h | ||
66 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
67 | bool hstr_active; | ||
68 | /* True if memory operations require alignment */ | ||
69 | bool align_mem; | ||
70 | + /* True if PSTATE.IL is set */ | ||
71 | + bool pstate_il; | ||
72 | /* | ||
73 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. | ||
74 | * < 0, set by the current instruction. | ||
15 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 75 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c |
16 | index XXXXXXX..XXXXXXX 100644 | 76 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-a64.c | 77 | --- a/target/arm/helper-a64.c |
18 | +++ b/target/arm/helper-a64.c | 78 | +++ b/target/arm/helper-a64.c |
19 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(frecpx_f16)(float16 a, void *fpstp) | 79 | @@ -XXX,XX +XXX,XX @@ illegal_return: |
20 | return nan; | 80 | if (!arm_singlestep_active(env)) { |
81 | env->pstate &= ~PSTATE_SS; | ||
21 | } | 82 | } |
22 | 83 | + helper_rebuild_hflags_a64(env, cur_el); | |
23 | + a = float16_squash_input_denormal(a, fpst); | 84 | qemu_log_mask(LOG_GUEST_ERROR, "Illegal exception return at EL%d: " |
85 | "resuming execution at 0x%" PRIx64 "\n", cur_el, env->pc); | ||
86 | } | ||
87 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/target/arm/helper.c | ||
90 | +++ b/target/arm/helper.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
92 | DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1); | ||
93 | } | ||
94 | |||
95 | + if (env->uncached_cpsr & CPSR_IL) { | ||
96 | + DP_TBFLAG_ANY(flags, PSTATE__IL, 1); | ||
97 | + } | ||
24 | + | 98 | + |
25 | val16 = float16_val(a); | 99 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); |
26 | sbit = 0x8000 & val16; | 100 | } |
27 | exp = extract32(val16, 10, 5); | 101 | |
28 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) | 102 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, |
29 | return nan; | 103 | } |
30 | } | 104 | } |
31 | 105 | ||
32 | + a = float32_squash_input_denormal(a, fpst); | 106 | + if (env->pstate & PSTATE_IL) { |
107 | + DP_TBFLAG_ANY(flags, PSTATE__IL, 1); | ||
108 | + } | ||
33 | + | 109 | + |
34 | val32 = float32_val(a); | 110 | if (cpu_isar_feature(aa64_mte, env_archcpu(env))) { |
35 | sbit = 0x80000000ULL & val32; | 111 | /* |
36 | exp = extract32(val32, 23, 8); | 112 | * Set MTE_ACTIVE if any access may be Checked, and leave clear |
37 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) | 113 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
38 | return nan; | 114 | index XXXXXXX..XXXXXXX 100644 |
115 | --- a/target/arm/translate-a64.c | ||
116 | +++ b/target/arm/translate-a64.c | ||
117 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
118 | s->fp_access_checked = false; | ||
119 | s->sve_access_checked = false; | ||
120 | |||
121 | + if (s->pstate_il) { | ||
122 | + /* | ||
123 | + * Illegal execution state. This has priority over BTI | ||
124 | + * exceptions, but comes after instruction abort exceptions. | ||
125 | + */ | ||
126 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
127 | + syn_illegalstate(), default_exception_el(s)); | ||
128 | + return; | ||
129 | + } | ||
130 | + | ||
131 | if (dc_isar_feature(aa64_bti, s)) { | ||
132 | if (s->base.num_insns == 1) { | ||
133 | /* | ||
134 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
135 | #endif | ||
136 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | ||
137 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | ||
138 | + dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); | ||
139 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | ||
140 | dc->sve_len = (EX_TBFLAG_A64(tb_flags, ZCR_LEN) + 1) * 16; | ||
141 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | ||
142 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/target/arm/translate.c | ||
145 | +++ b/target/arm/translate.c | ||
146 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
147 | return; | ||
39 | } | 148 | } |
40 | 149 | ||
41 | + a = float64_squash_input_denormal(a, fpst); | 150 | + if (s->pstate_il) { |
151 | + /* | ||
152 | + * Illegal execution state. This has priority over BTI | ||
153 | + * exceptions, but comes after instruction abort exceptions. | ||
154 | + */ | ||
155 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
156 | + syn_illegalstate(), default_exception_el(s)); | ||
157 | + return; | ||
158 | + } | ||
42 | + | 159 | + |
43 | val64 = float64_val(a); | 160 | if (cond == 0xf) { |
44 | sbit = 0x8000000000000000ULL & val64; | 161 | /* In ARMv3 and v4 the NV condition is UNPREDICTABLE; we |
45 | exp = extract64(float64_val(a), 52, 11); | 162 | * choose to UNDEF. In ARMv5 and above the space is used |
163 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
164 | #endif | ||
165 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | ||
166 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | ||
167 | + dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); | ||
168 | |||
169 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
170 | dc->vfp_enabled = 1; | ||
171 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
172 | } | ||
173 | dc->insn = insn; | ||
174 | |||
175 | + if (dc->pstate_il) { | ||
176 | + /* | ||
177 | + * Illegal execution state. This has priority over BTI | ||
178 | + * exceptions, but comes after instruction abort exceptions. | ||
179 | + */ | ||
180 | + gen_exception_insn(dc, dc->pc_curr, EXCP_UDEF, | ||
181 | + syn_illegalstate(), default_exception_el(dc)); | ||
182 | + return; | ||
183 | + } | ||
184 | + | ||
185 | if (dc->eci) { | ||
186 | /* | ||
187 | * For M-profile continuable instructions, ECI/ICI handling | ||
46 | -- | 188 | -- |
47 | 2.17.1 | 189 | 2.20.1 |
48 | 190 | ||
49 | 191 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Add entries to MAINTAINERS to cover the newer MPS2 boards and | ||
2 | the new devices they use. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20180518153157.14899-1-peter.maydell@linaro.org | ||
6 | --- | ||
7 | MAINTAINERS | 9 +++++++-- | ||
8 | 1 file changed, 7 insertions(+), 2 deletions(-) | ||
9 | |||
10 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/MAINTAINERS | ||
13 | +++ b/MAINTAINERS | ||
14 | @@ -XXX,XX +XXX,XX @@ F: hw/timer/cmsdk-apb-timer.c | ||
15 | F: include/hw/timer/cmsdk-apb-timer.h | ||
16 | F: hw/char/cmsdk-apb-uart.c | ||
17 | F: include/hw/char/cmsdk-apb-uart.h | ||
18 | +F: hw/misc/tz-ppc.c | ||
19 | +F: include/hw/misc/tz-ppc.h | ||
20 | |||
21 | ARM cores | ||
22 | M: Peter Maydell <peter.maydell@linaro.org> | ||
23 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
24 | L: qemu-arm@nongnu.org | ||
25 | S: Maintained | ||
26 | F: hw/arm/mps2.c | ||
27 | -F: hw/misc/mps2-scc.c | ||
28 | -F: include/hw/misc/mps2-scc.h | ||
29 | +F: hw/arm/mps2-tz.c | ||
30 | +F: hw/misc/mps2-*.c | ||
31 | +F: include/hw/misc/mps2-*.h | ||
32 | +F: hw/arm/iotkit.c | ||
33 | +F: include/hw/arm/iotkit.h | ||
34 | |||
35 | Musicpal | ||
36 | M: Jan Kiszka <jan.kiszka@web.de> | ||
37 | -- | ||
38 | 2.17.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 | Depending on the host abi, float16, aka uint16_t, values are | 3 | It is confusing to have different exits from translation |
4 | passed and returned either zero-extended in the host register | 4 | for various conditions in separate functions. |
5 | or with garbage at the top of the host register. | 5 | |
6 | 6 | Merge disas_a64_insn into its only caller. Standardize | |
7 | The tcg code generator has so far been assuming garbage, as that | 7 | on the "s" name for the DisasContext, as the code from |
8 | matches the x86 abi, but this is incorrect for other host abis. | 8 | disas_a64_insn had more instances. |
9 | Further, target/arm has so far been assuming zero-extended results, | 9 | |
10 | so that it may store the 16-bit value into a 32-bit slot with the | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | high 16-bits already clear. | ||
12 | |||
13 | Rectify both problems by mapping "f16" in the helper definition | ||
14 | to uint32_t instead of (a typedef for) uint16_t. This forces | ||
15 | the host compiler to assume garbage in the upper 16 bits on input | ||
16 | and to zero-extend the result on output. | ||
17 | |||
18 | Cc: qemu-stable@nongnu.org | ||
19 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Message-id: 20210821195958.41312-3-richard.henderson@linaro.org |
21 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
22 | Message-id: 20180522175629.24932-1-richard.henderson@linaro.org | ||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | --- | 14 | --- |
26 | include/exec/helper-head.h | 2 +- | 15 | target/arm/translate-a64.c | 224 ++++++++++++++++++------------------- |
27 | target/arm/helper-a64.c | 35 +++++++++-------- | 16 | 1 file changed, 109 insertions(+), 115 deletions(-) |
28 | target/arm/helper.c | 80 +++++++++++++++++++------------------- | 17 | |
29 | 3 files changed, 59 insertions(+), 58 deletions(-) | 18 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
30 | |||
31 | diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/exec/helper-head.h | 20 | --- a/target/arm/translate-a64.c |
34 | +++ b/include/exec/helper-head.h | 21 | +++ b/target/arm/translate-a64.c |
35 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) |
36 | #define dh_ctype_int int | 23 | return false; |
37 | #define dh_ctype_i64 uint64_t | ||
38 | #define dh_ctype_s64 int64_t | ||
39 | -#define dh_ctype_f16 float16 | ||
40 | +#define dh_ctype_f16 uint32_t | ||
41 | #define dh_ctype_f32 float32 | ||
42 | #define dh_ctype_f64 float64 | ||
43 | #define dh_ctype_ptr void * | ||
44 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/helper-a64.c | ||
47 | +++ b/target/arm/helper-a64.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res) | ||
49 | return flags; | ||
50 | } | 24 | } |
51 | 25 | ||
52 | -uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status) | 26 | -/* C3.1 A64 instruction index by encoding */ |
53 | +uint64_t HELPER(vfp_cmph_a64)(uint32_t x, uint32_t y, void *fp_status) | 27 | -static void disas_a64_insn(CPUARMState *env, DisasContext *s) |
28 | -{ | ||
29 | - uint32_t insn; | ||
30 | - | ||
31 | - s->pc_curr = s->base.pc_next; | ||
32 | - insn = arm_ldl_code(env, s->base.pc_next, s->sctlr_b); | ||
33 | - s->insn = insn; | ||
34 | - s->base.pc_next += 4; | ||
35 | - | ||
36 | - s->fp_access_checked = false; | ||
37 | - s->sve_access_checked = false; | ||
38 | - | ||
39 | - if (s->pstate_il) { | ||
40 | - /* | ||
41 | - * Illegal execution state. This has priority over BTI | ||
42 | - * exceptions, but comes after instruction abort exceptions. | ||
43 | - */ | ||
44 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
45 | - syn_illegalstate(), default_exception_el(s)); | ||
46 | - return; | ||
47 | - } | ||
48 | - | ||
49 | - if (dc_isar_feature(aa64_bti, s)) { | ||
50 | - if (s->base.num_insns == 1) { | ||
51 | - /* | ||
52 | - * At the first insn of the TB, compute s->guarded_page. | ||
53 | - * We delayed computing this until successfully reading | ||
54 | - * the first insn of the TB, above. This (mostly) ensures | ||
55 | - * that the softmmu tlb entry has been populated, and the | ||
56 | - * page table GP bit is available. | ||
57 | - * | ||
58 | - * Note that we need to compute this even if btype == 0, | ||
59 | - * because this value is used for BR instructions later | ||
60 | - * where ENV is not available. | ||
61 | - */ | ||
62 | - s->guarded_page = is_guarded_page(env, s); | ||
63 | - | ||
64 | - /* First insn can have btype set to non-zero. */ | ||
65 | - tcg_debug_assert(s->btype >= 0); | ||
66 | - | ||
67 | - /* | ||
68 | - * Note that the Branch Target Exception has fairly high | ||
69 | - * priority -- below debugging exceptions but above most | ||
70 | - * everything else. This allows us to handle this now | ||
71 | - * instead of waiting until the insn is otherwise decoded. | ||
72 | - */ | ||
73 | - if (s->btype != 0 | ||
74 | - && s->guarded_page | ||
75 | - && !btype_destination_ok(insn, s->bt, s->btype)) { | ||
76 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
77 | - syn_btitrap(s->btype), | ||
78 | - default_exception_el(s)); | ||
79 | - return; | ||
80 | - } | ||
81 | - } else { | ||
82 | - /* Not the first insn: btype must be 0. */ | ||
83 | - tcg_debug_assert(s->btype == 0); | ||
84 | - } | ||
85 | - } | ||
86 | - | ||
87 | - switch (extract32(insn, 25, 4)) { | ||
88 | - case 0x0: case 0x1: case 0x3: /* UNALLOCATED */ | ||
89 | - unallocated_encoding(s); | ||
90 | - break; | ||
91 | - case 0x2: | ||
92 | - if (!dc_isar_feature(aa64_sve, s) || !disas_sve(s, insn)) { | ||
93 | - unallocated_encoding(s); | ||
94 | - } | ||
95 | - break; | ||
96 | - case 0x8: case 0x9: /* Data processing - immediate */ | ||
97 | - disas_data_proc_imm(s, insn); | ||
98 | - break; | ||
99 | - case 0xa: case 0xb: /* Branch, exception generation and system insns */ | ||
100 | - disas_b_exc_sys(s, insn); | ||
101 | - break; | ||
102 | - case 0x4: | ||
103 | - case 0x6: | ||
104 | - case 0xc: | ||
105 | - case 0xe: /* Loads and stores */ | ||
106 | - disas_ldst(s, insn); | ||
107 | - break; | ||
108 | - case 0x5: | ||
109 | - case 0xd: /* Data processing - register */ | ||
110 | - disas_data_proc_reg(s, insn); | ||
111 | - break; | ||
112 | - case 0x7: | ||
113 | - case 0xf: /* Data processing - SIMD and floating point */ | ||
114 | - disas_data_proc_simd_fp(s, insn); | ||
115 | - break; | ||
116 | - default: | ||
117 | - assert(FALSE); /* all 15 cases should be handled above */ | ||
118 | - break; | ||
119 | - } | ||
120 | - | ||
121 | - /* if we allocated any temporaries, free them here */ | ||
122 | - free_tmp_a64(s); | ||
123 | - | ||
124 | - /* | ||
125 | - * After execution of most insns, btype is reset to 0. | ||
126 | - * Note that we set btype == -1 when the insn sets btype. | ||
127 | - */ | ||
128 | - if (s->btype > 0 && s->base.is_jmp != DISAS_NORETURN) { | ||
129 | - reset_btype(s); | ||
130 | - } | ||
131 | -} | ||
132 | - | ||
133 | static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
134 | CPUState *cpu) | ||
54 | { | 135 | { |
55 | return float_rel_to_flags(float16_compare_quiet(x, y, fp_status)); | 136 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) |
137 | |||
138 | static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
139 | { | ||
140 | - DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
141 | + DisasContext *s = container_of(dcbase, DisasContext, base); | ||
142 | CPUARMState *env = cpu->env_ptr; | ||
143 | + uint32_t insn; | ||
144 | |||
145 | - if (dc->ss_active && !dc->pstate_ss) { | ||
146 | + if (s->ss_active && !s->pstate_ss) { | ||
147 | /* Singlestep state is Active-pending. | ||
148 | * If we're in this state at the start of a TB then either | ||
149 | * a) we just took an exception to an EL which is being debugged | ||
150 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
151 | * "did not step an insn" case, and so the syndrome ISV and EX | ||
152 | * bits should be zero. | ||
153 | */ | ||
154 | - assert(dc->base.num_insns == 1); | ||
155 | - gen_swstep_exception(dc, 0, 0); | ||
156 | - dc->base.is_jmp = DISAS_NORETURN; | ||
157 | - } else { | ||
158 | - disas_a64_insn(env, dc); | ||
159 | + assert(s->base.num_insns == 1); | ||
160 | + gen_swstep_exception(s, 0, 0); | ||
161 | + s->base.is_jmp = DISAS_NORETURN; | ||
162 | + return; | ||
163 | } | ||
164 | |||
165 | - translator_loop_temp_check(&dc->base); | ||
166 | + s->pc_curr = s->base.pc_next; | ||
167 | + insn = arm_ldl_code(env, s->base.pc_next, s->sctlr_b); | ||
168 | + s->insn = insn; | ||
169 | + s->base.pc_next += 4; | ||
170 | + | ||
171 | + s->fp_access_checked = false; | ||
172 | + s->sve_access_checked = false; | ||
173 | + | ||
174 | + if (s->pstate_il) { | ||
175 | + /* | ||
176 | + * Illegal execution state. This has priority over BTI | ||
177 | + * exceptions, but comes after instruction abort exceptions. | ||
178 | + */ | ||
179 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
180 | + syn_illegalstate(), default_exception_el(s)); | ||
181 | + return; | ||
182 | + } | ||
183 | + | ||
184 | + if (dc_isar_feature(aa64_bti, s)) { | ||
185 | + if (s->base.num_insns == 1) { | ||
186 | + /* | ||
187 | + * At the first insn of the TB, compute s->guarded_page. | ||
188 | + * We delayed computing this until successfully reading | ||
189 | + * the first insn of the TB, above. This (mostly) ensures | ||
190 | + * that the softmmu tlb entry has been populated, and the | ||
191 | + * page table GP bit is available. | ||
192 | + * | ||
193 | + * Note that we need to compute this even if btype == 0, | ||
194 | + * because this value is used for BR instructions later | ||
195 | + * where ENV is not available. | ||
196 | + */ | ||
197 | + s->guarded_page = is_guarded_page(env, s); | ||
198 | + | ||
199 | + /* First insn can have btype set to non-zero. */ | ||
200 | + tcg_debug_assert(s->btype >= 0); | ||
201 | + | ||
202 | + /* | ||
203 | + * Note that the Branch Target Exception has fairly high | ||
204 | + * priority -- below debugging exceptions but above most | ||
205 | + * everything else. This allows us to handle this now | ||
206 | + * instead of waiting until the insn is otherwise decoded. | ||
207 | + */ | ||
208 | + if (s->btype != 0 | ||
209 | + && s->guarded_page | ||
210 | + && !btype_destination_ok(insn, s->bt, s->btype)) { | ||
211 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
212 | + syn_btitrap(s->btype), | ||
213 | + default_exception_el(s)); | ||
214 | + return; | ||
215 | + } | ||
216 | + } else { | ||
217 | + /* Not the first insn: btype must be 0. */ | ||
218 | + tcg_debug_assert(s->btype == 0); | ||
219 | + } | ||
220 | + } | ||
221 | + | ||
222 | + switch (extract32(insn, 25, 4)) { | ||
223 | + case 0x0: case 0x1: case 0x3: /* UNALLOCATED */ | ||
224 | + unallocated_encoding(s); | ||
225 | + break; | ||
226 | + case 0x2: | ||
227 | + if (!dc_isar_feature(aa64_sve, s) || !disas_sve(s, insn)) { | ||
228 | + unallocated_encoding(s); | ||
229 | + } | ||
230 | + break; | ||
231 | + case 0x8: case 0x9: /* Data processing - immediate */ | ||
232 | + disas_data_proc_imm(s, insn); | ||
233 | + break; | ||
234 | + case 0xa: case 0xb: /* Branch, exception generation and system insns */ | ||
235 | + disas_b_exc_sys(s, insn); | ||
236 | + break; | ||
237 | + case 0x4: | ||
238 | + case 0x6: | ||
239 | + case 0xc: | ||
240 | + case 0xe: /* Loads and stores */ | ||
241 | + disas_ldst(s, insn); | ||
242 | + break; | ||
243 | + case 0x5: | ||
244 | + case 0xd: /* Data processing - register */ | ||
245 | + disas_data_proc_reg(s, insn); | ||
246 | + break; | ||
247 | + case 0x7: | ||
248 | + case 0xf: /* Data processing - SIMD and floating point */ | ||
249 | + disas_data_proc_simd_fp(s, insn); | ||
250 | + break; | ||
251 | + default: | ||
252 | + assert(FALSE); /* all 15 cases should be handled above */ | ||
253 | + break; | ||
254 | + } | ||
255 | + | ||
256 | + /* if we allocated any temporaries, free them here */ | ||
257 | + free_tmp_a64(s); | ||
258 | + | ||
259 | + /* | ||
260 | + * After execution of most insns, btype is reset to 0. | ||
261 | + * Note that we set btype == -1 when the insn sets btype. | ||
262 | + */ | ||
263 | + if (s->btype > 0 && s->base.is_jmp != DISAS_NORETURN) { | ||
264 | + reset_btype(s); | ||
265 | + } | ||
266 | + | ||
267 | + translator_loop_temp_check(&s->base); | ||
56 | } | 268 | } |
57 | 269 | ||
58 | -uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status) | 270 | static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) |
59 | +uint64_t HELPER(vfp_cmpeh_a64)(uint32_t x, uint32_t y, void *fp_status) | ||
60 | { | ||
61 | return float_rel_to_flags(float16_compare(x, y, fp_status)); | ||
62 | } | ||
63 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp) | ||
64 | #define float64_three make_float64(0x4008000000000000ULL) | ||
65 | #define float64_one_point_five make_float64(0x3FF8000000000000ULL) | ||
66 | |||
67 | -float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp) | ||
68 | +uint32_t HELPER(recpsf_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
69 | { | ||
70 | float_status *fpst = fpstp; | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp) | ||
73 | return float64_muladd(a, b, float64_two, 0, fpst); | ||
74 | } | ||
75 | |||
76 | -float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp) | ||
77 | +uint32_t HELPER(rsqrtsf_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
78 | { | ||
79 | float_status *fpst = fpstp; | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a) | ||
82 | } | ||
83 | |||
84 | /* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */ | ||
85 | -float16 HELPER(frecpx_f16)(float16 a, void *fpstp) | ||
86 | +uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) | ||
87 | { | ||
88 | float_status *fpst = fpstp; | ||
89 | uint16_t val16, sbit; | ||
90 | @@ -XXX,XX +XXX,XX @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, | ||
91 | #define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix)) | ||
92 | |||
93 | #define ADVSIMD_HALFOP(name) \ | ||
94 | -float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \ | ||
95 | +uint32_t ADVSIMD_HELPER(name, h)(uint32_t a, uint32_t b, void *fpstp) \ | ||
96 | { \ | ||
97 | float_status *fpst = fpstp; \ | ||
98 | return float16_ ## name(a, b, fpst); \ | ||
99 | @@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(mulx) | ||
100 | ADVSIMD_TWOHALFOP(mulx) | ||
101 | |||
102 | /* fused multiply-accumulate */ | ||
103 | -float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) | ||
104 | +uint32_t HELPER(advsimd_muladdh)(uint32_t a, uint32_t b, uint32_t c, | ||
105 | + void *fpstp) | ||
106 | { | ||
107 | float_status *fpst = fpstp; | ||
108 | return float16_muladd(a, b, c, 0, fpst); | ||
109 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b, | ||
110 | |||
111 | #define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0 | ||
112 | |||
113 | -uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp) | ||
114 | +uint32_t HELPER(advsimd_ceq_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
115 | { | ||
116 | float_status *fpst = fpstp; | ||
117 | int compare = float16_compare_quiet(a, b, fpst); | ||
118 | return ADVSIMD_CMPRES(compare == float_relation_equal); | ||
119 | } | ||
120 | |||
121 | -uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) | ||
122 | +uint32_t HELPER(advsimd_cge_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
123 | { | ||
124 | float_status *fpst = fpstp; | ||
125 | int compare = float16_compare(a, b, fpst); | ||
126 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) | ||
127 | compare == float_relation_equal); | ||
128 | } | ||
129 | |||
130 | -uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp) | ||
131 | +uint32_t HELPER(advsimd_cgt_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
132 | { | ||
133 | float_status *fpst = fpstp; | ||
134 | int compare = float16_compare(a, b, fpst); | ||
135 | return ADVSIMD_CMPRES(compare == float_relation_greater); | ||
136 | } | ||
137 | |||
138 | -uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) | ||
139 | +uint32_t HELPER(advsimd_acge_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
140 | { | ||
141 | float_status *fpst = fpstp; | ||
142 | float16 f0 = float16_abs(a); | ||
143 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) | ||
144 | compare == float_relation_equal); | ||
145 | } | ||
146 | |||
147 | -uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) | ||
148 | +uint32_t HELPER(advsimd_acgt_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
149 | { | ||
150 | float_status *fpst = fpstp; | ||
151 | float16 f0 = float16_abs(a); | ||
152 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) | ||
153 | } | ||
154 | |||
155 | /* round to integral */ | ||
156 | -float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status) | ||
157 | +uint32_t HELPER(advsimd_rinth_exact)(uint32_t x, void *fp_status) | ||
158 | { | ||
159 | return float16_round_to_int(x, fp_status); | ||
160 | } | ||
161 | |||
162 | -float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) | ||
163 | +uint32_t HELPER(advsimd_rinth)(uint32_t x, void *fp_status) | ||
164 | { | ||
165 | int old_flags = get_float_exception_flags(fp_status), new_flags; | ||
166 | float16 ret; | ||
167 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) | ||
168 | * setting the mode appropriately before calling the helper. | ||
169 | */ | ||
170 | |||
171 | -uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) | ||
172 | +uint32_t HELPER(advsimd_f16tosinth)(uint32_t a, void *fpstp) | ||
173 | { | ||
174 | float_status *fpst = fpstp; | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) | ||
177 | return float16_to_int16(a, fpst); | ||
178 | } | ||
179 | |||
180 | -uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) | ||
181 | +uint32_t HELPER(advsimd_f16touinth)(uint32_t a, void *fpstp) | ||
182 | { | ||
183 | float_status *fpst = fpstp; | ||
184 | |||
185 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) | ||
186 | * Square Root and Reciprocal square root | ||
187 | */ | ||
188 | |||
189 | -float16 HELPER(sqrt_f16)(float16 a, void *fpstp) | ||
190 | +uint32_t HELPER(sqrt_f16)(uint32_t a, void *fpstp) | ||
191 | { | ||
192 | float_status *s = fpstp; | ||
193 | |||
194 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
195 | index XXXXXXX..XXXXXXX 100644 | ||
196 | --- a/target/arm/helper.c | ||
197 | +++ b/target/arm/helper.c | ||
198 | @@ -XXX,XX +XXX,XX @@ DO_VFP_cmp(d, float64) | ||
199 | |||
200 | /* Integer to float and float to integer conversions */ | ||
201 | |||
202 | -#define CONV_ITOF(name, fsz, sign) \ | ||
203 | - float##fsz HELPER(name)(uint32_t x, void *fpstp) \ | ||
204 | -{ \ | ||
205 | - float_status *fpst = fpstp; \ | ||
206 | - return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
207 | +#define CONV_ITOF(name, ftype, fsz, sign) \ | ||
208 | +ftype HELPER(name)(uint32_t x, void *fpstp) \ | ||
209 | +{ \ | ||
210 | + float_status *fpst = fpstp; \ | ||
211 | + return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
212 | } | ||
213 | |||
214 | -#define CONV_FTOI(name, fsz, sign, round) \ | ||
215 | -uint32_t HELPER(name)(float##fsz x, void *fpstp) \ | ||
216 | -{ \ | ||
217 | - float_status *fpst = fpstp; \ | ||
218 | - if (float##fsz##_is_any_nan(x)) { \ | ||
219 | - float_raise(float_flag_invalid, fpst); \ | ||
220 | - return 0; \ | ||
221 | - } \ | ||
222 | - return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
223 | +#define CONV_FTOI(name, ftype, fsz, sign, round) \ | ||
224 | +uint32_t HELPER(name)(ftype x, void *fpstp) \ | ||
225 | +{ \ | ||
226 | + float_status *fpst = fpstp; \ | ||
227 | + if (float##fsz##_is_any_nan(x)) { \ | ||
228 | + float_raise(float_flag_invalid, fpst); \ | ||
229 | + return 0; \ | ||
230 | + } \ | ||
231 | + return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
232 | } | ||
233 | |||
234 | -#define FLOAT_CONVS(name, p, fsz, sign) \ | ||
235 | -CONV_ITOF(vfp_##name##to##p, fsz, sign) \ | ||
236 | -CONV_FTOI(vfp_to##name##p, fsz, sign, ) \ | ||
237 | -CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero) | ||
238 | +#define FLOAT_CONVS(name, p, ftype, fsz, sign) \ | ||
239 | + CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \ | ||
240 | + CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \ | ||
241 | + CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero) | ||
242 | |||
243 | -FLOAT_CONVS(si, h, 16, ) | ||
244 | -FLOAT_CONVS(si, s, 32, ) | ||
245 | -FLOAT_CONVS(si, d, 64, ) | ||
246 | -FLOAT_CONVS(ui, h, 16, u) | ||
247 | -FLOAT_CONVS(ui, s, 32, u) | ||
248 | -FLOAT_CONVS(ui, d, 64, u) | ||
249 | +FLOAT_CONVS(si, h, uint32_t, 16, ) | ||
250 | +FLOAT_CONVS(si, s, float32, 32, ) | ||
251 | +FLOAT_CONVS(si, d, float64, 64, ) | ||
252 | +FLOAT_CONVS(ui, h, uint32_t, 16, u) | ||
253 | +FLOAT_CONVS(ui, s, float32, 32, u) | ||
254 | +FLOAT_CONVS(ui, d, float64, 64, u) | ||
255 | |||
256 | #undef CONV_ITOF | ||
257 | #undef CONV_FTOI | ||
258 | @@ -XXX,XX +XXX,XX @@ static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) | ||
259 | return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst); | ||
260 | } | ||
261 | |||
262 | -float16 HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
263 | +uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
264 | { | ||
265 | return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst); | ||
266 | } | ||
267 | |||
268 | -float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
269 | +uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
270 | { | ||
271 | return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); | ||
272 | } | ||
273 | |||
274 | -float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
275 | +uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
276 | { | ||
277 | return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst); | ||
278 | } | ||
279 | |||
280 | -float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
281 | +uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
282 | { | ||
283 | return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst); | ||
284 | } | ||
285 | @@ -XXX,XX +XXX,XX @@ static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) | ||
286 | } | ||
287 | } | ||
288 | |||
289 | -uint32_t HELPER(vfp_toshh)(float16 x, uint32_t shift, void *fpst) | ||
290 | +uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) | ||
291 | { | ||
292 | return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst); | ||
293 | } | ||
294 | |||
295 | -uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) | ||
296 | +uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) | ||
297 | { | ||
298 | return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); | ||
299 | } | ||
300 | |||
301 | -uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst) | ||
302 | +uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) | ||
303 | { | ||
304 | return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); | ||
305 | } | ||
306 | |||
307 | -uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst) | ||
308 | +uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) | ||
309 | { | ||
310 | return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); | ||
311 | } | ||
312 | |||
313 | -uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst) | ||
314 | +uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) | ||
315 | { | ||
316 | return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); | ||
317 | } | ||
318 | |||
319 | -uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst) | ||
320 | +uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) | ||
321 | { | ||
322 | return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); | ||
323 | } | ||
324 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) | ||
325 | } | ||
326 | |||
327 | /* Half precision conversions. */ | ||
328 | -float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
329 | +float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
330 | { | ||
331 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
332 | * it would affect flushing input denormals. | ||
333 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
334 | return r; | ||
335 | } | ||
336 | |||
337 | -float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
338 | +uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
339 | { | ||
340 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
341 | * it would affect flushing output denormals. | ||
342 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
343 | return r; | ||
344 | } | ||
345 | |||
346 | -float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
347 | +float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
348 | { | ||
349 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
350 | * it would affect flushing input denormals. | ||
351 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
352 | return r; | ||
353 | } | ||
354 | |||
355 | -float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
356 | +uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
357 | { | ||
358 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
359 | * it would affect flushing output denormals. | ||
360 | @@ -XXX,XX +XXX,XX @@ static bool round_to_inf(float_status *fpst, bool sign_bit) | ||
361 | g_assert_not_reached(); | ||
362 | } | ||
363 | |||
364 | -float16 HELPER(recpe_f16)(float16 input, void *fpstp) | ||
365 | +uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) | ||
366 | { | ||
367 | float_status *fpst = fpstp; | ||
368 | float16 f16 = float16_squash_input_denormal(input, fpst); | ||
369 | @@ -XXX,XX +XXX,XX @@ static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) | ||
370 | return extract64(estimate, 0, 8) << 44; | ||
371 | } | ||
372 | |||
373 | -float16 HELPER(rsqrte_f16)(float16 input, void *fpstp) | ||
374 | +uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
375 | { | ||
376 | float_status *s = fpstp; | ||
377 | float16 f16 = float16_squash_input_denormal(input, s); | ||
378 | -- | 271 | -- |
379 | 2.17.1 | 272 | 2.20.1 |
380 | 273 | ||
381 | 274 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | By default, QEMU will allow devices to be plugged into a bus up to |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_translate_iommu(). | 2 | the bus class's device count limit. If the user creates a device on |
3 | the command line or via the monitor and doesn't explicitly specify | ||
4 | the bus to plug it in, QEMU will plug it into the first non-full bus | ||
5 | that it finds. | ||
6 | |||
7 | This is fine in most cases, but some machines have multiple buses of | ||
8 | a given type, some of which are dedicated to on-board devices and | ||
9 | some of which have an externally exposed connector for user-pluggable | ||
10 | devices. One example is I2C buses. | ||
11 | |||
12 | Provide a new function qbus_mark_full() so that a machine model can | ||
13 | mark this kind of "internal only" bus as 'full' after it has created | ||
14 | all the devices that should be plugged into that bus. The "find a | ||
15 | non-full bus" algorithm will then skip the internal-only bus when | ||
16 | looking for a place to plug in user-created devices. | ||
3 | 17 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180521140402.23318-14-peter.maydell@linaro.org | 20 | Message-id: 20210903151435.22379-2-peter.maydell@linaro.org |
8 | --- | 21 | --- |
9 | exec.c | 8 +++++--- | 22 | include/hw/qdev-core.h | 24 ++++++++++++++++++++++++ |
10 | 1 file changed, 5 insertions(+), 3 deletions(-) | 23 | softmmu/qdev-monitor.c | 7 ++++++- |
24 | 2 files changed, 30 insertions(+), 1 deletion(-) | ||
11 | 25 | ||
12 | diff --git a/exec.c b/exec.c | 26 | diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h |
13 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/exec.c | 28 | --- a/include/hw/qdev-core.h |
15 | +++ b/exec.c | 29 | +++ b/include/hw/qdev-core.h |
16 | @@ -XXX,XX +XXX,XX @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x | 30 | @@ -XXX,XX +XXX,XX @@ struct BusState { |
17 | * @is_write: whether the translation operation is for write | 31 | HotplugHandler *hotplug_handler; |
18 | * @is_mmio: whether this can be MMIO, set true if it can | 32 | int max_index; |
19 | * @target_as: the address space targeted by the IOMMU | 33 | bool realized; |
20 | + * @attrs: transaction attributes | 34 | + bool full; |
21 | * | 35 | int num_children; |
22 | * This function is called from RCU critical section. It is the common | 36 | |
23 | * part of flatview_do_translate and address_space_translate_cached. | 37 | /* |
24 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion *iomm | 38 | @@ -XXX,XX +XXX,XX @@ static inline bool qbus_is_hotpluggable(BusState *bus) |
25 | hwaddr *page_mask_out, | 39 | return bus->hotplug_handler; |
26 | bool is_write, | 40 | } |
27 | bool is_mmio, | 41 | |
28 | - AddressSpace **target_as) | 42 | +/** |
29 | + AddressSpace **target_as, | 43 | + * qbus_mark_full: Mark this bus as full, so no more devices can be attached |
30 | + MemTxAttrs attrs) | 44 | + * @bus: Bus to mark as full |
45 | + * | ||
46 | + * By default, QEMU will allow devices to be plugged into a bus up | ||
47 | + * to the bus class's device count limit. Calling this function | ||
48 | + * marks a particular bus as full, so that no more devices can be | ||
49 | + * plugged into it. In particular this means that the bus will not | ||
50 | + * be considered as a candidate for plugging in devices created by | ||
51 | + * the user on the commandline or via the monitor. | ||
52 | + * If a machine has multiple buses of a given type, such as I2C, | ||
53 | + * where some of those buses in the real hardware are used only for | ||
54 | + * internal devices and some are exposed via expansion ports, you | ||
55 | + * can use this function to mark the internal-only buses as full | ||
56 | + * after you have created all their internal devices. Then user | ||
57 | + * created devices will appear on the expansion-port bus where | ||
58 | + * guest software expects them. | ||
59 | + */ | ||
60 | +static inline void qbus_mark_full(BusState *bus) | ||
61 | +{ | ||
62 | + bus->full = true; | ||
63 | +} | ||
64 | + | ||
65 | void device_listener_register(DeviceListener *listener); | ||
66 | void device_listener_unregister(DeviceListener *listener); | ||
67 | |||
68 | diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/softmmu/qdev-monitor.c | ||
71 | +++ b/softmmu/qdev-monitor.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem) | ||
73 | |||
74 | static inline bool qbus_is_full(BusState *bus) | ||
31 | { | 75 | { |
32 | MemoryRegionSection *section; | 76 | - BusClass *bus_class = BUS_GET_CLASS(bus); |
33 | hwaddr page_mask = (hwaddr)-1; | 77 | + BusClass *bus_class; |
34 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | 78 | + |
35 | return address_space_translate_iommu(iommu_mr, xlat, | 79 | + if (bus->full) { |
36 | plen_out, page_mask_out, | 80 | + return true; |
37 | is_write, is_mmio, | 81 | + } |
38 | - target_as); | 82 | + bus_class = BUS_GET_CLASS(bus); |
39 | + target_as, attrs); | 83 | return bus_class->max_dev && bus->num_children >= bus_class->max_dev; |
40 | } | ||
41 | if (page_mask_out) { | ||
42 | /* Not behind an IOMMU, use default page size. */ | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate_cached( | ||
44 | |||
45 | section = address_space_translate_iommu(iommu_mr, xlat, plen, | ||
46 | NULL, is_write, true, | ||
47 | - &target_as); | ||
48 | + &target_as, attrs); | ||
49 | return section.mr; | ||
50 | } | 84 | } |
51 | 85 | ||
52 | -- | 86 | -- |
53 | 2.17.1 | 87 | 2.20.1 |
54 | 88 | ||
55 | 89 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | The mps2-tz boards use a data-driven structure to create the devices |
---|---|---|---|
2 | add MemTxAttrs as an argument to tb_invalidate_phys_addr(). | 2 | that sit behind peripheral protection controllers. Currently the |
3 | Its callers either have an attrs value to hand, or don't care | 3 | functions which create these devices are passed an 'opaque' pointer |
4 | and can use MEMTXATTRS_UNSPECIFIED. | 4 | which is always the address within the machine struct of the device |
5 | to create, and some "all devices need this" information like irqs and | ||
6 | addresses. | ||
7 | |||
8 | If a specific device needs more information than this, it is | ||
9 | currently not possible to pass that through from the PPCInfo | ||
10 | data structure. Add support for passing an extra data parameter, | ||
11 | so that we can more flexibly handle the needs of specific | ||
12 | device types. To provide some type-safety we make this extra | ||
13 | parameter a pointer to a union (which initially has no members). | ||
14 | |||
15 | In particular, we would like to be able to indicate which of the | ||
16 | i2c controllers are for on-board devices only and which are | ||
17 | connected to the external 'shield' expansion port; a subsequent | ||
18 | patch will use this mechanism for that purpose. | ||
5 | 19 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 22 | Message-id: 20210903151435.22379-3-peter.maydell@linaro.org |
9 | Message-id: 20180521140402.23318-3-peter.maydell@linaro.org | ||
10 | --- | 23 | --- |
11 | include/exec/exec-all.h | 5 +++-- | 24 | hw/arm/mps2-tz.c | 35 ++++++++++++++++++++++------------- |
12 | accel/tcg/translate-all.c | 2 +- | 25 | 1 file changed, 22 insertions(+), 13 deletions(-) |
13 | exec.c | 2 +- | ||
14 | target/xtensa/op_helper.c | 3 ++- | ||
15 | 4 files changed, 7 insertions(+), 5 deletions(-) | ||
16 | 26 | ||
17 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 27 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c |
18 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/exec-all.h | 29 | --- a/hw/arm/mps2-tz.c |
20 | +++ b/include/exec/exec-all.h | 30 | +++ b/hw/arm/mps2-tz.c |
21 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | 31 | @@ -XXX,XX +XXX,XX @@ static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno) |
22 | void tlb_set_page(CPUState *cpu, target_ulong vaddr, | ||
23 | hwaddr paddr, int prot, | ||
24 | int mmu_idx, target_ulong size); | ||
25 | -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr); | ||
26 | +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs); | ||
27 | void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | ||
28 | uintptr_t retaddr); | ||
29 | #else | ||
30 | @@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
31 | uint16_t idxmap) | ||
32 | { | ||
33 | } | ||
34 | -static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) | ||
35 | +static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, | ||
36 | + MemTxAttrs attrs) | ||
37 | { | ||
38 | } | ||
39 | #endif | ||
40 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/accel/tcg/translate-all.c | ||
43 | +++ b/accel/tcg/translate-all.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr) | ||
45 | } | ||
46 | |||
47 | #if !defined(CONFIG_USER_ONLY) | ||
48 | -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) | ||
49 | +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) | ||
50 | { | ||
51 | ram_addr_t ram_addr; | ||
52 | MemoryRegion *mr; | ||
53 | diff --git a/exec.c b/exec.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/exec.c | ||
56 | +++ b/exec.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) | ||
58 | if (phys != -1) { | ||
59 | /* Locks grabbed by tb_invalidate_phys_addr */ | ||
60 | tb_invalidate_phys_addr(cpu->cpu_ases[asidx].as, | ||
61 | - phys | (pc & ~TARGET_PAGE_MASK)); | ||
62 | + phys | (pc & ~TARGET_PAGE_MASK), attrs); | ||
63 | } | 32 | } |
64 | } | 33 | } |
65 | #endif | 34 | |
66 | diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c | 35 | +/* Union describing the device-specific extra data we pass to the devfn. */ |
67 | index XXXXXXX..XXXXXXX 100644 | 36 | +typedef union PPCExtraData { |
68 | --- a/target/xtensa/op_helper.c | 37 | +} PPCExtraData; |
69 | +++ b/target/xtensa/op_helper.c | 38 | + |
70 | @@ -XXX,XX +XXX,XX @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr) | 39 | /* Most of the devices in the AN505 FPGA image sit behind |
71 | int ret = xtensa_get_physical_addr(env, false, vaddr, 2, 0, | 40 | * Peripheral Protection Controllers. These data structures |
72 | &paddr, &page_size, &access); | 41 | * define the layout of which devices sit behind which PPCs. |
73 | if (ret == 0) { | 42 | @@ -XXX,XX +XXX,XX @@ static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno) |
74 | - tb_invalidate_phys_addr(&address_space_memory, paddr); | 43 | */ |
75 | + tb_invalidate_phys_addr(&address_space_memory, paddr, | 44 | typedef MemoryRegion *MakeDevFn(MPS2TZMachineState *mms, void *opaque, |
76 | + MEMTXATTRS_UNSPECIFIED); | 45 | const char *name, hwaddr size, |
77 | } | 46 | - const int *irqs); |
78 | } | 47 | + const int *irqs, |
79 | 48 | + const PPCExtraData *extradata); | |
49 | |||
50 | typedef struct PPCPortInfo { | ||
51 | const char *name; | ||
52 | @@ -XXX,XX +XXX,XX @@ typedef struct PPCPortInfo { | ||
53 | hwaddr addr; | ||
54 | hwaddr size; | ||
55 | int irqs[3]; /* currently no device needs more IRQ lines than this */ | ||
56 | + PPCExtraData extradata; /* to pass device-specific info to the devfn */ | ||
57 | } PPCPortInfo; | ||
58 | |||
59 | typedef struct PPCInfo { | ||
60 | @@ -XXX,XX +XXX,XX @@ typedef struct PPCInfo { | ||
61 | static MemoryRegion *make_unimp_dev(MPS2TZMachineState *mms, | ||
62 | void *opaque, | ||
63 | const char *name, hwaddr size, | ||
64 | - const int *irqs) | ||
65 | + const int *irqs, | ||
66 | + const PPCExtraData *extradata) | ||
67 | { | ||
68 | /* Initialize, configure and realize a TYPE_UNIMPLEMENTED_DEVICE, | ||
69 | * and return a pointer to its MemoryRegion. | ||
70 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_unimp_dev(MPS2TZMachineState *mms, | ||
71 | |||
72 | static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
73 | const char *name, hwaddr size, | ||
74 | - const int *irqs) | ||
75 | + const int *irqs, const PPCExtraData *extradata) | ||
76 | { | ||
77 | /* The irq[] array is tx, rx, combined, in that order */ | ||
78 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
79 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
80 | |||
81 | static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | ||
82 | const char *name, hwaddr size, | ||
83 | - const int *irqs) | ||
84 | + const int *irqs, const PPCExtraData *extradata) | ||
85 | { | ||
86 | MPS2SCC *scc = opaque; | ||
87 | DeviceState *sccdev; | ||
88 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | ||
89 | |||
90 | static MemoryRegion *make_fpgaio(MPS2TZMachineState *mms, void *opaque, | ||
91 | const char *name, hwaddr size, | ||
92 | - const int *irqs) | ||
93 | + const int *irqs, const PPCExtraData *extradata) | ||
94 | { | ||
95 | MPS2FPGAIO *fpgaio = opaque; | ||
96 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
97 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_fpgaio(MPS2TZMachineState *mms, void *opaque, | ||
98 | |||
99 | static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | ||
100 | const char *name, hwaddr size, | ||
101 | - const int *irqs) | ||
102 | + const int *irqs, | ||
103 | + const PPCExtraData *extradata) | ||
104 | { | ||
105 | SysBusDevice *s; | ||
106 | NICInfo *nd = &nd_table[0]; | ||
107 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | ||
108 | |||
109 | static MemoryRegion *make_eth_usb(MPS2TZMachineState *mms, void *opaque, | ||
110 | const char *name, hwaddr size, | ||
111 | - const int *irqs) | ||
112 | + const int *irqs, | ||
113 | + const PPCExtraData *extradata) | ||
114 | { | ||
115 | /* | ||
116 | * The AN524 makes the ethernet and USB share a PPC port. | ||
117 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_usb(MPS2TZMachineState *mms, void *opaque, | ||
118 | |||
119 | static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque, | ||
120 | const char *name, hwaddr size, | ||
121 | - const int *irqs) | ||
122 | + const int *irqs, const PPCExtraData *extradata) | ||
123 | { | ||
124 | TZMPC *mpc = opaque; | ||
125 | int i = mpc - &mms->mpc[0]; | ||
126 | @@ -XXX,XX +XXX,XX @@ static void remap_irq_fn(void *opaque, int n, int level) | ||
127 | |||
128 | static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque, | ||
129 | const char *name, hwaddr size, | ||
130 | - const int *irqs) | ||
131 | + const int *irqs, const PPCExtraData *extradata) | ||
132 | { | ||
133 | /* The irq[] array is DMACINTR, DMACINTERR, DMACINTTC, in that order */ | ||
134 | PL080State *dma = opaque; | ||
135 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque, | ||
136 | |||
137 | static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque, | ||
138 | const char *name, hwaddr size, | ||
139 | - const int *irqs) | ||
140 | + const int *irqs, const PPCExtraData *extradata) | ||
141 | { | ||
142 | /* | ||
143 | * The AN505 has five PL022 SPI controllers. | ||
144 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque, | ||
145 | |||
146 | static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque, | ||
147 | const char *name, hwaddr size, | ||
148 | - const int *irqs) | ||
149 | + const int *irqs, const PPCExtraData *extradata) | ||
150 | { | ||
151 | ArmSbconI2CState *i2c = opaque; | ||
152 | SysBusDevice *s; | ||
153 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque, | ||
154 | |||
155 | static MemoryRegion *make_rtc(MPS2TZMachineState *mms, void *opaque, | ||
156 | const char *name, hwaddr size, | ||
157 | - const int *irqs) | ||
158 | + const int *irqs, const PPCExtraData *extradata) | ||
159 | { | ||
160 | PL031State *pl031 = opaque; | ||
161 | SysBusDevice *s; | ||
162 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
163 | } | ||
164 | |||
165 | mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size, | ||
166 | - pinfo->irqs); | ||
167 | + pinfo->irqs, &pinfo->extradata); | ||
168 | portname = g_strdup_printf("port[%d]", port); | ||
169 | object_property_set_link(OBJECT(ppc), portname, OBJECT(mr), | ||
170 | &error_fatal); | ||
80 | -- | 171 | -- |
81 | 2.17.1 | 172 | 2.20.1 |
82 | 173 | ||
83 | 174 | diff view generated by jsdifflib |
1 | Add more detail to the documentation for memory_region_init_iommu() | 1 | The various MPS2 boards have multiple I2C buses: typically a bus |
---|---|---|---|
2 | and other IOMMU-related functions and data structures. | 2 | dedicated to the audio configuration, one for the LCD touchscreen |
3 | controller, one for a DDR4 EEPROM, and two which are connected to the | ||
4 | external Shield expansion connector. Mark the buses which are used | ||
5 | only for board-internal devices as 'full' so that if the user creates | ||
6 | i2c devices on the commandline without specifying a bus name then | ||
7 | they will be connected to the I2C controller used for the Shield | ||
8 | connector, where guest software will expect them. | ||
3 | 9 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 12 | Message-id: 20210903151435.22379-4-peter.maydell@linaro.org |
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Message-id: 20180521140402.23318-2-peter.maydell@linaro.org | ||
9 | --- | 13 | --- |
10 | include/exec/memory.h | 105 ++++++++++++++++++++++++++++++++++++++---- | 14 | hw/arm/mps2-tz.c | 57 ++++++++++++++++++++++++++++++++++++------------ |
11 | 1 file changed, 95 insertions(+), 10 deletions(-) | 15 | 1 file changed, 43 insertions(+), 14 deletions(-) |
12 | 16 | ||
13 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 17 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/exec/memory.h | 19 | --- a/hw/arm/mps2-tz.c |
16 | +++ b/include/exec/memory.h | 20 | +++ b/hw/arm/mps2-tz.c |
17 | @@ -XXX,XX +XXX,XX @@ enum IOMMUMemoryRegionAttr { | 21 | @@ -XXX,XX +XXX,XX @@ static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno) |
18 | IOMMU_ATTR_SPAPR_TCE_FD | 22 | |
19 | }; | 23 | /* Union describing the device-specific extra data we pass to the devfn. */ |
20 | 24 | typedef union PPCExtraData { | |
21 | +/** | 25 | + bool i2c_internal; |
22 | + * IOMMUMemoryRegionClass: | 26 | } PPCExtraData; |
23 | + * | 27 | |
24 | + * All IOMMU implementations need to subclass TYPE_IOMMU_MEMORY_REGION | 28 | /* Most of the devices in the AN505 FPGA image sit behind |
25 | + * and provide an implementation of at least the @translate method here | 29 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque, |
26 | + * to handle requests to the memory region. Other methods are optional. | 30 | object_initialize_child(OBJECT(mms), name, i2c, TYPE_ARM_SBCON_I2C); |
27 | + * | 31 | s = SYS_BUS_DEVICE(i2c); |
28 | + * The IOMMU implementation must use the IOMMU notifier infrastructure | 32 | sysbus_realize(s, &error_fatal); |
29 | + * to report whenever mappings are changed, by calling | 33 | + |
30 | + * memory_region_notify_iommu() (or, if necessary, by calling | 34 | + /* |
31 | + * memory_region_notify_one() for each registered notifier). | 35 | + * If this is an internal-use-only i2c bus, mark it full |
32 | + */ | 36 | + * so that user-created i2c devices are not plugged into it. |
33 | typedef struct IOMMUMemoryRegionClass { | 37 | + * If we implement models of any on-board i2c devices that |
34 | /* private */ | 38 | + * plug in to one of the internal-use-only buses, then we will |
35 | struct DeviceClass parent_class; | 39 | + * need to create and plugging those in here before we mark the |
36 | 40 | + * bus as full. | |
37 | /* | ||
38 | - * Return a TLB entry that contains a given address. Flag should | ||
39 | - * be the access permission of this translation operation. We can | ||
40 | - * set flag to IOMMU_NONE to mean that we don't need any | ||
41 | - * read/write permission checks, like, when for region replay. | ||
42 | + * Return a TLB entry that contains a given address. | ||
43 | + * | ||
44 | + * The IOMMUAccessFlags indicated via @flag are optional and may | ||
45 | + * be specified as IOMMU_NONE to indicate that the caller needs | ||
46 | + * the full translation information for both reads and writes. If | ||
47 | + * the access flags are specified then the IOMMU implementation | ||
48 | + * may use this as an optimization, to stop doing a page table | ||
49 | + * walk as soon as it knows that the requested permissions are not | ||
50 | + * allowed. If IOMMU_NONE is passed then the IOMMU must do the | ||
51 | + * full page table walk and report the permissions in the returned | ||
52 | + * IOMMUTLBEntry. (Note that this implies that an IOMMU may not | ||
53 | + * return different mappings for reads and writes.) | ||
54 | + * | ||
55 | + * The returned information remains valid while the caller is | ||
56 | + * holding the big QEMU lock or is inside an RCU critical section; | ||
57 | + * if the caller wishes to cache the mapping beyond that it must | ||
58 | + * register an IOMMU notifier so it can invalidate its cached | ||
59 | + * information when the IOMMU mapping changes. | ||
60 | + * | ||
61 | + * @iommu: the IOMMUMemoryRegion | ||
62 | + * @hwaddr: address to be translated within the memory region | ||
63 | + * @flag: requested access permissions | ||
64 | */ | ||
65 | IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr, | ||
66 | IOMMUAccessFlags flag); | ||
67 | - /* Returns minimum supported page size */ | ||
68 | + /* Returns minimum supported page size in bytes. | ||
69 | + * If this method is not provided then the minimum is assumed to | ||
70 | + * be TARGET_PAGE_SIZE. | ||
71 | + * | ||
72 | + * @iommu: the IOMMUMemoryRegion | ||
73 | + */ | 41 | + */ |
74 | uint64_t (*get_min_page_size)(IOMMUMemoryRegion *iommu); | 42 | + if (extradata->i2c_internal) { |
75 | - /* Called when IOMMU Notifier flag changed */ | 43 | + BusState *qbus = qdev_get_child_bus(DEVICE(i2c), "i2c"); |
76 | + /* Called when IOMMU Notifier flag changes (ie when the set of | 44 | + qbus_mark_full(qbus); |
77 | + * events which IOMMU users are requesting notification for changes). | 45 | + } |
78 | + * Optional method -- need not be provided if the IOMMU does not | 46 | + |
79 | + * need to know exactly which events must be notified. | 47 | return sysbus_mmio_get_region(s, 0); |
80 | + * | 48 | } |
81 | + * @iommu: the IOMMUMemoryRegion | 49 | |
82 | + * @old_flags: events which previously needed to be notified | 50 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
83 | + * @new_flags: events which now need to be notified | 51 | { "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000, { 36, 37, 44 } }, |
84 | + */ | 52 | { "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000, { 38, 39, 45 } }, |
85 | void (*notify_flag_changed)(IOMMUMemoryRegion *iommu, | 53 | { "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000, { 40, 41, 46 } }, |
86 | IOMMUNotifierFlag old_flags, | 54 | - { "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000 }, |
87 | IOMMUNotifierFlag new_flags); | 55 | - { "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000 }, |
88 | - /* Set this up to provide customized IOMMU replay function */ | 56 | - { "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000 }, |
89 | + /* Called to handle memory_region_iommu_replay(). | 57 | - { "i2c3", make_i2c, &mms->i2c[3], 0x4020d000, 0x1000 }, |
90 | + * | 58 | + { "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000, {}, |
91 | + * The default implementation of memory_region_iommu_replay() is to | 59 | + { .i2c_internal = true /* touchscreen */ } }, |
92 | + * call the IOMMU translate method for every page in the address space | 60 | + { "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000, {}, |
93 | + * with flag == IOMMU_NONE and then call the notifier if translate | 61 | + { .i2c_internal = true /* audio conf */ } }, |
94 | + * returns a valid mapping. If this method is implemented then it | 62 | + { "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000, {}, |
95 | + * overrides the default behaviour, and must provide the full semantics | 63 | + { .i2c_internal = false /* shield 0 */ } }, |
96 | + * of memory_region_iommu_replay(), by calling @notifier for every | 64 | + { "i2c3", make_i2c, &mms->i2c[3], 0x4020d000, 0x1000, {}, |
97 | + * translation present in the IOMMU. | 65 | + { .i2c_internal = false /* shield 1 */ } }, |
98 | + * | 66 | }, |
99 | + * Optional method -- an IOMMU only needs to provide this method | 67 | }, { |
100 | + * if the default is inefficient or produces undesirable side effects. | 68 | .name = "apb_ppcexp2", |
101 | + * | 69 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
102 | + * Note: this is not related to record-and-replay functionality. | 70 | }, { |
103 | + */ | 71 | .name = "apb_ppcexp1", |
104 | void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier); | 72 | .ports = { |
105 | 73 | - { "i2c0", make_i2c, &mms->i2c[0], 0x41200000, 0x1000 }, | |
106 | - /* Get IOMMU misc attributes */ | 74 | - { "i2c1", make_i2c, &mms->i2c[1], 0x41201000, 0x1000 }, |
107 | - int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr, | 75 | + { "i2c0", make_i2c, &mms->i2c[0], 0x41200000, 0x1000, {}, |
108 | + /* Get IOMMU misc attributes. This is an optional method that | 76 | + { .i2c_internal = true /* touchscreen */ } }, |
109 | + * can be used to allow users of the IOMMU to get implementation-specific | 77 | + { "i2c1", make_i2c, &mms->i2c[1], 0x41201000, 0x1000, {}, |
110 | + * information. The IOMMU implements this method to handle calls | 78 | + { .i2c_internal = true /* audio conf */ } }, |
111 | + * by IOMMU users to memory_region_iommu_get_attr() by filling in | 79 | { "spi0", make_spi, &mms->spi[0], 0x41202000, 0x1000, { 52 } }, |
112 | + * the arbitrary data pointer for any IOMMUMemoryRegionAttr values that | 80 | { "spi1", make_spi, &mms->spi[1], 0x41203000, 0x1000, { 53 } }, |
113 | + * the IOMMU supports. If the method is unimplemented then | 81 | { "spi2", make_spi, &mms->spi[2], 0x41204000, 0x1000, { 54 } }, |
114 | + * memory_region_iommu_get_attr() will always return -EINVAL. | 82 | - { "i2c2", make_i2c, &mms->i2c[2], 0x41205000, 0x1000 }, |
115 | + * | 83 | - { "i2c3", make_i2c, &mms->i2c[3], 0x41206000, 0x1000 }, |
116 | + * @iommu: the IOMMUMemoryRegion | 84 | + { "i2c2", make_i2c, &mms->i2c[2], 0x41205000, 0x1000, {}, |
117 | + * @attr: attribute being queried | 85 | + { .i2c_internal = false /* shield 0 */ } }, |
118 | + * @data: memory to fill in with the attribute data | 86 | + { "i2c3", make_i2c, &mms->i2c[3], 0x41206000, 0x1000, {}, |
119 | + * | 87 | + { .i2c_internal = false /* shield 1 */ } }, |
120 | + * Returns 0 on success, or a negative errno; in particular | 88 | { /* port 7 reserved */ }, |
121 | + * returns -EINVAL for unrecognized or unimplemented attribute types. | 89 | - { "i2c4", make_i2c, &mms->i2c[4], 0x41208000, 0x1000 }, |
122 | + */ | 90 | + { "i2c4", make_i2c, &mms->i2c[4], 0x41208000, 0x1000, {}, |
123 | + int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr attr, | 91 | + { .i2c_internal = true /* DDR4 EEPROM */ } }, |
124 | void *data); | 92 | }, |
125 | } IOMMUMemoryRegionClass; | 93 | }, { |
126 | 94 | .name = "apb_ppcexp2", | |
127 | @@ -XXX,XX +XXX,XX @@ static inline void memory_region_init_reservation(MemoryRegion *mr, | 95 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
128 | * An IOMMU region translates addresses and forwards accesses to a target | 96 | }, { |
129 | * memory region. | 97 | .name = "apb_ppcexp1", |
130 | * | 98 | .ports = { |
131 | + * The IOMMU implementation must define a subclass of TYPE_IOMMU_MEMORY_REGION. | 99 | - { "i2c0", make_i2c, &mms->i2c[0], 0x49200000, 0x1000 }, |
132 | + * @_iommu_mr should be a pointer to enough memory for an instance of | 100 | - { "i2c1", make_i2c, &mms->i2c[1], 0x49201000, 0x1000 }, |
133 | + * that subclass, @instance_size is the size of that subclass, and | 101 | + { "i2c0", make_i2c, &mms->i2c[0], 0x49200000, 0x1000, {}, |
134 | + * @mrtypename is its name. This function will initialize @_iommu_mr as an | 102 | + { .i2c_internal = true /* touchscreen */ } }, |
135 | + * instance of the subclass, and its methods will then be called to handle | 103 | + { "i2c1", make_i2c, &mms->i2c[1], 0x49201000, 0x1000, {}, |
136 | + * accesses to the memory region. See the documentation of | 104 | + { .i2c_internal = true /* audio conf */ } }, |
137 | + * #IOMMUMemoryRegionClass for further details. | 105 | { "spi0", make_spi, &mms->spi[0], 0x49202000, 0x1000, { 53 } }, |
138 | + * | 106 | { "spi1", make_spi, &mms->spi[1], 0x49203000, 0x1000, { 54 } }, |
139 | * @_iommu_mr: the #IOMMUMemoryRegion to be initialized | 107 | { "spi2", make_spi, &mms->spi[2], 0x49204000, 0x1000, { 55 } }, |
140 | * @instance_size: the IOMMUMemoryRegion subclass instance size | 108 | - { "i2c2", make_i2c, &mms->i2c[2], 0x49205000, 0x1000 }, |
141 | * @mrtypename: the type name of the #IOMMUMemoryRegion | 109 | - { "i2c3", make_i2c, &mms->i2c[3], 0x49206000, 0x1000 }, |
142 | @@ -XXX,XX +XXX,XX @@ void memory_region_register_iommu_notifier(MemoryRegion *mr, | 110 | + { "i2c2", make_i2c, &mms->i2c[2], 0x49205000, 0x1000, {}, |
143 | * a notifier with the minimum page granularity returned by | 111 | + { .i2c_internal = false /* shield 0 */ } }, |
144 | * mr->iommu_ops->get_page_size(). | 112 | + { "i2c3", make_i2c, &mms->i2c[3], 0x49206000, 0x1000, {}, |
145 | * | 113 | + { .i2c_internal = false /* shield 1 */ } }, |
146 | + * Note: this is not related to record-and-replay functionality. | 114 | { /* port 7 reserved */ }, |
147 | + * | 115 | - { "i2c4", make_i2c, &mms->i2c[4], 0x49208000, 0x1000 }, |
148 | * @iommu_mr: the memory region to observe | 116 | + { "i2c4", make_i2c, &mms->i2c[4], 0x49208000, 0x1000, {}, |
149 | * @n: the notifier to which to replay iommu mappings | 117 | + { .i2c_internal = true /* DDR4 EEPROM */ } }, |
150 | */ | 118 | }, |
151 | @@ -XXX,XX +XXX,XX @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n); | 119 | }, { |
152 | * memory_region_iommu_replay_all: replay existing IOMMU translations | 120 | .name = "apb_ppcexp2", |
153 | * to all the notifiers registered. | ||
154 | * | ||
155 | + * Note: this is not related to record-and-replay functionality. | ||
156 | + * | ||
157 | * @iommu_mr: the memory region to observe | ||
158 | */ | ||
159 | void memory_region_iommu_replay_all(IOMMUMemoryRegion *iommu_mr); | ||
160 | @@ -XXX,XX +XXX,XX @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr, | ||
161 | * memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is | ||
162 | * defined on the IOMMU. | ||
163 | * | ||
164 | - * Returns 0 if succeded, error code otherwise. | ||
165 | + * Returns 0 on success, or a negative errno otherwise. In particular, | ||
166 | + * -EINVAL indicates that the IOMMU does not support the requested | ||
167 | + * attribute. | ||
168 | * | ||
169 | * @iommu_mr: the memory region | ||
170 | * @attr: the requested attribute | ||
171 | -- | 121 | -- |
172 | 2.17.1 | 122 | 2.20.1 |
173 | 123 | ||
174 | 124 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | ||
2 | add MemTxAttrs as an argument to address_space_translate() | ||
3 | and address_space_translate_cached(). Callers either have an | ||
4 | attrs value to hand, or don't care and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-4-peter.maydell@linaro.org | ||
10 | --- | ||
11 | include/exec/memory.h | 4 +++- | ||
12 | accel/tcg/translate-all.c | 2 +- | ||
13 | exec.c | 14 +++++++++----- | ||
14 | hw/vfio/common.c | 3 ++- | ||
15 | memory_ldst.inc.c | 18 +++++++++--------- | ||
16 | target/riscv/helper.c | 2 +- | ||
17 | 6 files changed, 25 insertions(+), 18 deletions(-) | ||
18 | |||
19 | diff --git a/include/exec/memory.h b/include/exec/memory.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/exec/memory.h | ||
22 | +++ b/include/exec/memory.h | ||
23 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | ||
24 | * #MemoryRegion. | ||
25 | * @len: pointer to length | ||
26 | * @is_write: indicates the transfer direction | ||
27 | + * @attrs: memory attributes | ||
28 | */ | ||
29 | MemoryRegion *flatview_translate(FlatView *fv, | ||
30 | hwaddr addr, hwaddr *xlat, | ||
31 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, | ||
32 | |||
33 | static inline MemoryRegion *address_space_translate(AddressSpace *as, | ||
34 | hwaddr addr, hwaddr *xlat, | ||
35 | - hwaddr *len, bool is_write) | ||
36 | + hwaddr *len, bool is_write, | ||
37 | + MemTxAttrs attrs) | ||
38 | { | ||
39 | return flatview_translate(address_space_to_flatview(as), | ||
40 | addr, xlat, len, is_write); | ||
41 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/accel/tcg/translate-all.c | ||
44 | +++ b/accel/tcg/translate-all.c | ||
45 | @@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) | ||
46 | hwaddr l = 1; | ||
47 | |||
48 | rcu_read_lock(); | ||
49 | - mr = address_space_translate(as, addr, &addr, &l, false); | ||
50 | + mr = address_space_translate(as, addr, &addr, &l, false, attrs); | ||
51 | if (!(memory_region_is_ram(mr) | ||
52 | || memory_region_is_romd(mr))) { | ||
53 | rcu_read_unlock(); | ||
54 | diff --git a/exec.c b/exec.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/exec.c | ||
57 | +++ b/exec.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as, | ||
59 | rcu_read_lock(); | ||
60 | while (len > 0) { | ||
61 | l = len; | ||
62 | - mr = address_space_translate(as, addr, &addr1, &l, true); | ||
63 | + mr = address_space_translate(as, addr, &addr1, &l, true, | ||
64 | + MEMTXATTRS_UNSPECIFIED); | ||
65 | |||
66 | if (!(memory_region_is_ram(mr) || | ||
67 | memory_region_is_romd(mr))) { | ||
68 | @@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache) | ||
69 | */ | ||
70 | static inline MemoryRegion *address_space_translate_cached( | ||
71 | MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat, | ||
72 | - hwaddr *plen, bool is_write) | ||
73 | + hwaddr *plen, bool is_write, MemTxAttrs attrs) | ||
74 | { | ||
75 | MemoryRegionSection section; | ||
76 | MemoryRegion *mr; | ||
77 | @@ -XXX,XX +XXX,XX @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, | ||
78 | MemoryRegion *mr; | ||
79 | |||
80 | l = len; | ||
81 | - mr = address_space_translate_cached(cache, addr, &addr1, &l, false); | ||
82 | + mr = address_space_translate_cached(cache, addr, &addr1, &l, false, | ||
83 | + MEMTXATTRS_UNSPECIFIED); | ||
84 | flatview_read_continue(cache->fv, | ||
85 | addr, MEMTXATTRS_UNSPECIFIED, buf, len, | ||
86 | addr1, l, mr); | ||
87 | @@ -XXX,XX +XXX,XX @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, | ||
88 | MemoryRegion *mr; | ||
89 | |||
90 | l = len; | ||
91 | - mr = address_space_translate_cached(cache, addr, &addr1, &l, true); | ||
92 | + mr = address_space_translate_cached(cache, addr, &addr1, &l, true, | ||
93 | + MEMTXATTRS_UNSPECIFIED); | ||
94 | flatview_write_continue(cache->fv, | ||
95 | addr, MEMTXATTRS_UNSPECIFIED, buf, len, | ||
96 | addr1, l, mr); | ||
97 | @@ -XXX,XX +XXX,XX @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) | ||
98 | |||
99 | rcu_read_lock(); | ||
100 | mr = address_space_translate(&address_space_memory, | ||
101 | - phys_addr, &phys_addr, &l, false); | ||
102 | + phys_addr, &phys_addr, &l, false, | ||
103 | + MEMTXATTRS_UNSPECIFIED); | ||
104 | |||
105 | res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr)); | ||
106 | rcu_read_unlock(); | ||
107 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/hw/vfio/common.c | ||
110 | +++ b/hw/vfio/common.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, | ||
112 | */ | ||
113 | mr = address_space_translate(&address_space_memory, | ||
114 | iotlb->translated_addr, | ||
115 | - &xlat, &len, writable); | ||
116 | + &xlat, &len, writable, | ||
117 | + MEMTXATTRS_UNSPECIFIED); | ||
118 | if (!memory_region_is_ram(mr)) { | ||
119 | error_report("iommu map to non memory area %"HWADDR_PRIx"", | ||
120 | xlat); | ||
121 | diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/memory_ldst.inc.c | ||
124 | +++ b/memory_ldst.inc.c | ||
125 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, | ||
126 | bool release_lock = false; | ||
127 | |||
128 | RCU_READ_LOCK(); | ||
129 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
130 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
131 | if (l < 4 || !IS_DIRECT(mr, false)) { | ||
132 | release_lock |= prepare_mmio_access(mr); | ||
133 | |||
134 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, | ||
135 | bool release_lock = false; | ||
136 | |||
137 | RCU_READ_LOCK(); | ||
138 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
139 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
140 | if (l < 8 || !IS_DIRECT(mr, false)) { | ||
141 | release_lock |= prepare_mmio_access(mr); | ||
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, | ||
144 | bool release_lock = false; | ||
145 | |||
146 | RCU_READ_LOCK(); | ||
147 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
148 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
149 | if (!IS_DIRECT(mr, false)) { | ||
150 | release_lock |= prepare_mmio_access(mr); | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, | ||
153 | bool release_lock = false; | ||
154 | |||
155 | RCU_READ_LOCK(); | ||
156 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
157 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
158 | if (l < 2 || !IS_DIRECT(mr, false)) { | ||
159 | release_lock |= prepare_mmio_access(mr); | ||
160 | |||
161 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL, | ||
162 | bool release_lock = false; | ||
163 | |||
164 | RCU_READ_LOCK(); | ||
165 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
166 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
167 | if (l < 4 || !IS_DIRECT(mr, true)) { | ||
168 | release_lock |= prepare_mmio_access(mr); | ||
169 | |||
170 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL, | ||
171 | bool release_lock = false; | ||
172 | |||
173 | RCU_READ_LOCK(); | ||
174 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
175 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
176 | if (l < 4 || !IS_DIRECT(mr, true)) { | ||
177 | release_lock |= prepare_mmio_access(mr); | ||
178 | |||
179 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL, | ||
180 | bool release_lock = false; | ||
181 | |||
182 | RCU_READ_LOCK(); | ||
183 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
184 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
185 | if (!IS_DIRECT(mr, true)) { | ||
186 | release_lock |= prepare_mmio_access(mr); | ||
187 | r = memory_region_dispatch_write(mr, addr1, val, 1, attrs); | ||
188 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL, | ||
189 | bool release_lock = false; | ||
190 | |||
191 | RCU_READ_LOCK(); | ||
192 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
193 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
194 | if (l < 2 || !IS_DIRECT(mr, true)) { | ||
195 | release_lock |= prepare_mmio_access(mr); | ||
196 | |||
197 | @@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, | ||
198 | bool release_lock = false; | ||
199 | |||
200 | RCU_READ_LOCK(); | ||
201 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
202 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
203 | if (l < 8 || !IS_DIRECT(mr, true)) { | ||
204 | release_lock |= prepare_mmio_access(mr); | ||
205 | |||
206 | diff --git a/target/riscv/helper.c b/target/riscv/helper.c | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/target/riscv/helper.c | ||
209 | +++ b/target/riscv/helper.c | ||
210 | @@ -XXX,XX +XXX,XX @@ restart: | ||
211 | MemoryRegion *mr; | ||
212 | hwaddr l = sizeof(target_ulong), addr1; | ||
213 | mr = address_space_translate(cs->as, pte_addr, | ||
214 | - &addr1, &l, false); | ||
215 | + &addr1, &l, false, MEMTXATTRS_UNSPECIFIED); | ||
216 | if (memory_access_is_direct(mr, true)) { | ||
217 | target_ulong *pte_pa = | ||
218 | qemu_map_ram_ptr(mr->ram_block, addr1); | ||
219 | -- | ||
220 | 2.17.1 | ||
221 | |||
222 | diff view generated by jsdifflib |
1 | Provide a VMSTATE_BOOL_SUB_ARRAY to go with VMSTATE_UINT8_SUB_ARRAY | 1 | The various MPS2 boards implemented in mps2.c have multiple I2C |
---|---|---|---|
2 | and friends. | 2 | buses: a bus dedicated to the audio configuration, one for the LCD |
3 | touchscreen controller, and two which are connected to the external | ||
4 | Shield expansion connector. Mark the buses which are used only for | ||
5 | board-internal devices as 'full' so that if the user creates i2c | ||
6 | devices on the commandline without specifying a bus name then they | ||
7 | will be connected to the I2C controller used for the Shield | ||
8 | connector, where guest software will expect them. | ||
3 | 9 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20180521140402.23318-23-peter.maydell@linaro.org | 12 | Message-id: 20210903151435.22379-5-peter.maydell@linaro.org |
7 | --- | 13 | --- |
8 | include/migration/vmstate.h | 3 +++ | 14 | hw/arm/mps2.c | 12 +++++++++++- |
9 | 1 file changed, 3 insertions(+) | 15 | 1 file changed, 11 insertions(+), 1 deletion(-) |
10 | 16 | ||
11 | diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h | 17 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/migration/vmstate.h | 19 | --- a/hw/arm/mps2.c |
14 | +++ b/include/migration/vmstate.h | 20 | +++ b/hw/arm/mps2.c |
15 | @@ -XXX,XX +XXX,XX @@ extern const VMStateInfo vmstate_info_qtailq; | 21 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
16 | #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ | 22 | 0x40023000, /* Audio */ |
17 | VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) | 23 | 0x40029000, /* Shield0 */ |
18 | 24 | 0x4002a000}; /* Shield1 */ | |
19 | +#define VMSTATE_BOOL_SUB_ARRAY(_f, _s, _start, _num) \ | 25 | - sysbus_create_simple(TYPE_ARM_SBCON_I2C, i2cbase[i], NULL); |
20 | + VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_bool, bool) | 26 | + DeviceState *dev; |
21 | + | 27 | + |
22 | #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ | 28 | + dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, i2cbase[i], NULL); |
23 | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) | 29 | + if (i < 2) { |
30 | + /* | ||
31 | + * internal-only bus: mark it full to avoid user-created | ||
32 | + * i2c devices being plugged into it. | ||
33 | + */ | ||
34 | + BusState *qbus = qdev_get_child_bus(dev, "i2c"); | ||
35 | + qbus_mark_full(qbus); | ||
36 | + } | ||
37 | } | ||
38 | create_unimplemented_device("i2s", 0x40024000, 0x400); | ||
24 | 39 | ||
25 | -- | 40 | -- |
26 | 2.17.1 | 41 | 2.20.1 |
27 | 42 | ||
28 | 43 | diff view generated by jsdifflib |