1 | More accumulated patches from during the freeze... | 1 | target-arm queue: mostly patches from me this time round. |
---|---|---|---|
2 | Nothing too exciting. | ||
2 | 3 | ||
3 | The following changes since commit c83fcfaf8a54d0d034bd0edf7bbb3b0d16669be9: | 4 | -- PMM |
4 | 5 | ||
5 | Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-08-26' into staging (2021-08-26 13:42:34 +0100) | 6 | The following changes since commit 78ac2eebbab9150edf5d0d00e3648f5ebb599001: |
7 | |||
8 | Merge tag 'artist-cursor-fix-final-pull-request' of https://github.com/hdeller/qemu-hppa into staging (2022-05-18 09:32:15 -0700) | ||
6 | 9 | ||
7 | are available in the Git repository at: | 10 | are available in the Git repository at: |
8 | 11 | ||
9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210826 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220519 |
10 | 13 | ||
11 | for you to fetch changes up to d2e6f370138a7f32bc28b20dcd55374b7a638f39: | 14 | for you to fetch changes up to fab8ad39fb75a0d9f097db67b2a334444754e88e: |
12 | 15 | ||
13 | hw/arm/xlnx-zynqmp: Add unimplemented APU mmio (2021-08-26 17:02:01 +0100) | 16 | target/arm: Use FIELD definitions for CPACR, CPTR_ELx (2022-05-19 18:34:10 +0100) |
14 | 17 | ||
15 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
16 | target-arm queue: | 19 | target-arm queue: |
17 | * hw/dma/xlnx-zdma, xlnx_csu_dma: Require 'dma' link property to be set | 20 | * Implement FEAT_S2FWB |
18 | * hw/arm/Kconfig: no need to enable ACPI_MEMORY_HOTPLUG/ACPI_NVDIMM explicitly | 21 | * Implement FEAT_IDST |
19 | * target/arm/cpu: Introduce sve_vq_supported bitmap | 22 | * Drop unsupported_encoding() macro |
20 | * docs/specs: Convert ACPI spec docs to rST | 23 | * hw/intc/arm_gicv3: Use correct number of priority bits for the CPU |
21 | * arch_init: Clean up and refactoring | 24 | * Fix aarch64 debug register names |
22 | * hw/core/loader: In gunzip(), check index is in range before use, not after | 25 | * hw/adc/zynq-xadc: Use qemu_irq typedef |
23 | * softmmu/physmem.c: Remove unneeded NULL check in qemu_ram_alloc_from_fd() | 26 | * target/arm/helper.c: Delete stray obsolete comment |
24 | * softmmu/physmem.c: Check return value from realpath() | 27 | * Make number of counters in PMCR follow the CPU |
25 | * Zero-initialize sockaddr_in structs | 28 | * hw/arm/virt: Fix dtb nits |
26 | * raspi: Use error_fatal for SoC realize errors, not error_abort | 29 | * ptimer: Rename PTIMER_POLICY_DEFAULT to PTIMER_POLICY_LEGACY |
27 | * target/arm: Avoid assertion trying to use KVM and multiple ASes | 30 | * target/arm: Fix PAuth keys access checks for disabled SEL2 |
28 | * target/arm: Implement HSTR.TTEE | 31 | * Enable FEAT_HCX for -cpu max |
29 | * target/arm: Implement HSTR.TJDBX | 32 | * Use FIELD definitions for CPACR, CPTR_ELx |
30 | * target/arm: Do hflags rebuild in cpsr_write() | ||
31 | * hw/arm/xlnx-versal, xlnx-zynqmp: Add unimplemented APU mmio | ||
32 | 33 | ||
33 | ---------------------------------------------------------------- | 34 | ---------------------------------------------------------------- |
34 | Andrew Jones (4): | 35 | Chris Howard (1): |
35 | target/arm/cpu: Introduce sve_vq_supported bitmap | 36 | Fix aarch64 debug register names. |
36 | target/arm/kvm64: Ensure sve vls map is completely clear | ||
37 | target/arm/cpu64: Replace kvm_supported with sve_vq_supported | ||
38 | target/arm/cpu64: Validate sve vector lengths are supported | ||
39 | 37 | ||
40 | Ani Sinha (1): | 38 | Florian Lugou (1): |
41 | hw/arm/Kconfig: no need to enable ACPI_MEMORY_HOTPLUG/ACPI_NVDIMM explicitly | 39 | target/arm: Fix PAuth keys access checks for disabled SEL2 |
42 | 40 | ||
43 | Peter Maydell (26): | 41 | Peter Maydell (17): |
44 | docs/specs/acpu_cpu_hotplug: Convert to rST | 42 | target/arm: Postpone interpretation of stage 2 descriptor attribute bits |
45 | docs/specs/acpi_mem_hotplug: Convert to rST | 43 | target/arm: Factor out FWB=0 specific part of combine_cacheattrs() |
46 | docs/specs/acpi_pci_hotplug: Convert to rST | 44 | target/arm: Implement FEAT_S2FWB |
47 | docs/specs/acpi_nvdimm: Convert to rST | 45 | target/arm: Enable FEAT_S2FWB for -cpu max |
48 | MAINTAINERS: Add ACPI specs documents to ACPI and NVDIMM sections | 46 | target/arm: Implement FEAT_IDST |
49 | softmmu: Use accel_find("xen") instead of xen_available() | 47 | target/arm: Drop unsupported_encoding() macro |
50 | monitor: Use accel_find("kvm") instead of kvm_available() | 48 | hw/intc/arm_gicv3_cpuif: Handle CPUs that don't specify GICv3 parameters |
51 | softmmu/arch_init.c: Trim down include list | 49 | hw/intc/arm_gicv3: report correct PRIbits field in ICV_CTLR_EL1 |
52 | meson.build: Define QEMU_ARCH in config-target.h | 50 | hw/intc/arm_gicv3_kvm.c: Stop using GIC_MIN_BPR constant |
53 | arch_init.h: Add QEMU_ARCH_HEXAGON | 51 | hw/intc/arm_gicv3: Support configurable number of physical priority bits |
54 | arch_init.h: Move QEMU_ARCH_VIRTIO_* to qdev-monitor.c | 52 | hw/intc/arm_gicv3: Use correct number of priority bits for the CPU |
55 | arch_init.h: Don't include arch_init.h unnecessarily | 53 | hw/intc/arm_gicv3: Provide ich_num_aprs() |
56 | stubs: Remove unused arch_type.c stub | 54 | target/arm/helper.c: Delete stray obsolete comment |
57 | hw/core/loader: In gunzip(), check index is in range before use, not after | 55 | target/arm: Make number of counters in PMCR follow the CPU |
58 | softmmu/physmem.c: Remove unneeded NULL check in qemu_ram_alloc_from_fd() | 56 | hw/arm/virt: Fix incorrect non-secure flash dtb node name |
59 | softmmu/physmem.c: Check return value from realpath() | 57 | hw/arm/virt: Drop #size-cells and #address-cells from gpio-keys dtb node |
60 | net: Zero sockaddr_in in parse_host_port() | 58 | ptimer: Rename PTIMER_POLICY_DEFAULT to PTIMER_POLICY_LEGACY |
61 | gdbstub: Zero-initialize sockaddr structs | ||
62 | tests/qtest/ipmi-bt-test: Zero-initialize sockaddr struct | ||
63 | tests/tcg/multiarch/linux-test: Zero-initialize sockaddr structs | ||
64 | raspi: Use error_fatal for SoC realize errors, not error_abort | ||
65 | target/arm: Avoid assertion trying to use KVM and multiple ASes | ||
66 | hw/arm/virt: Delete EL3 error checksnow provided in CPU realize | ||
67 | target/arm: Implement HSTR.TTEE | ||
68 | target/arm: Implement HSTR.TJDBX | ||
69 | target/arm: Do hflags rebuild in cpsr_write() | ||
70 | 59 | ||
71 | Philippe Mathieu-Daudé (4): | 60 | Philippe Mathieu-Daudé (1): |
72 | hw/arm/xlnx-zynqmp: Realize qspi controller *after* qspi_dma | 61 | hw/adc/zynq-xadc: Use qemu_irq typedef |
73 | hw/dma/xlnx_csu_dma: Run trivial checks early in realize() | ||
74 | hw/dma/xlnx_csu_dma: Always expect 'dma' link property to be set | ||
75 | hw/dma/xlnx-zdma Always expect 'dma' link property to be set | ||
76 | 62 | ||
77 | Tong Ho (2): | 63 | Richard Henderson (2): |
78 | hw/arm/xlnx-versal: Add unimplemented APU mmio | 64 | target/arm: Enable FEAT_HCX for -cpu max |
79 | hw/arm/xlnx-zynqmp: Add unimplemented APU mmio | 65 | target/arm: Use FIELD definitions for CPACR, CPTR_ELx |
80 | 66 | ||
81 | docs/specs/acpi_cpu_hotplug.rst | 235 +++++++++++++++++++++ | 67 | docs/system/arm/emulation.rst | 2 + |
82 | docs/specs/acpi_cpu_hotplug.txt | 160 -------------- | 68 | include/hw/adc/zynq-xadc.h | 3 +- |
83 | docs/specs/acpi_mem_hotplug.rst | 128 +++++++++++ | 69 | include/hw/intc/arm_gicv3_common.h | 8 +- |
84 | docs/specs/acpi_mem_hotplug.txt | 94 --------- | 70 | include/hw/ptimer.h | 16 +- |
85 | docs/specs/acpi_nvdimm.rst | 228 ++++++++++++++++++++ | 71 | target/arm/cpregs.h | 24 +++ |
86 | docs/specs/acpi_nvdimm.txt | 188 ----------------- | 72 | target/arm/cpu.h | 76 +++++++- |
87 | .../{acpi_pci_hotplug.txt => acpi_pci_hotplug.rst} | 37 ++-- | 73 | target/arm/internals.h | 11 +- |
88 | docs/specs/index.rst | 4 + | 74 | target/arm/translate-a64.h | 9 - |
89 | meson.build | 2 + | 75 | hw/adc/zynq-xadc.c | 4 +- |
90 | include/hw/arm/xlnx-versal.h | 2 + | 76 | hw/arm/boot.c | 2 +- |
91 | include/hw/arm/xlnx-zynqmp.h | 7 + | 77 | hw/arm/musicpal.c | 2 +- |
92 | include/hw/dma/xlnx-zdma.h | 2 +- | 78 | hw/arm/virt.c | 4 +- |
93 | include/hw/dma/xlnx_csu_dma.h | 2 +- | 79 | hw/core/machine.c | 4 +- |
94 | include/sysemu/arch_init.h | 15 +- | 80 | hw/dma/xilinx_axidma.c | 2 +- |
95 | target/arm/cpu.h | 17 +- | 81 | hw/dma/xlnx_csu_dma.c | 2 +- |
96 | target/arm/helper.h | 2 + | 82 | hw/intc/arm_gicv3_common.c | 5 + |
97 | target/arm/syndrome.h | 7 + | 83 | hw/intc/arm_gicv3_cpuif.c | 225 +++++++++++++++++------- |
98 | blockdev.c | 1 - | 84 | hw/intc/arm_gicv3_kvm.c | 16 +- |
99 | gdbstub.c | 4 +- | 85 | hw/m68k/mcf5206.c | 2 +- |
100 | hw/arm/raspi.c | 2 +- | 86 | hw/m68k/mcf5208.c | 2 +- |
101 | hw/arm/virt.c | 5 - | 87 | hw/net/can/xlnx-zynqmp-can.c | 2 +- |
102 | hw/arm/xlnx-versal.c | 4 + | 88 | hw/net/fsl_etsec/etsec.c | 2 +- |
103 | hw/arm/xlnx-zynqmp.c | 86 ++++++-- | 89 | hw/net/lan9118.c | 2 +- |
104 | hw/core/loader.c | 35 ++- | 90 | hw/rtc/exynos4210_rtc.c | 4 +- |
105 | hw/dma/xlnx-zdma.c | 24 +-- | 91 | hw/timer/allwinner-a10-pit.c | 2 +- |
106 | hw/dma/xlnx_csu_dma.c | 31 ++- | 92 | hw/timer/altera_timer.c | 2 +- |
107 | hw/i386/pc.c | 1 - | 93 | hw/timer/arm_timer.c | 2 +- |
108 | hw/i386/pc_piix.c | 1 - | 94 | hw/timer/digic-timer.c | 2 +- |
109 | hw/i386/pc_q35.c | 1 - | 95 | hw/timer/etraxfs_timer.c | 6 +- |
110 | hw/mips/jazz.c | 1 - | 96 | hw/timer/exynos4210_mct.c | 6 +- |
111 | hw/mips/malta.c | 1 - | 97 | hw/timer/exynos4210_pwm.c | 2 +- |
112 | hw/ppc/prep.c | 1 - | 98 | hw/timer/grlib_gptimer.c | 2 +- |
113 | hw/riscv/sifive_e.c | 1 - | 99 | hw/timer/imx_epit.c | 4 +- |
114 | hw/riscv/sifive_u.c | 1 - | 100 | hw/timer/imx_gpt.c | 2 +- |
115 | hw/riscv/spike.c | 1 - | 101 | hw/timer/mss-timer.c | 2 +- |
116 | hw/riscv/virt.c | 1 - | 102 | hw/timer/sh_timer.c | 2 +- |
117 | linux-user/arm/signal.c | 2 - | 103 | hw/timer/slavio_timer.c | 2 +- |
118 | monitor/qmp-cmds.c | 3 +- | 104 | hw/timer/xilinx_timer.c | 2 +- |
119 | net/net.c | 2 + | 105 | target/arm/cpu.c | 11 +- |
120 | softmmu/arch_init.c | 66 ------ | 106 | target/arm/cpu64.c | 30 ++++ |
121 | softmmu/physmem.c | 5 +- | 107 | target/arm/cpu_tcg.c | 6 + |
122 | softmmu/qdev-monitor.c | 9 + | 108 | target/arm/helper.c | 348 ++++++++++++++++++++++++++++--------- |
123 | softmmu/vl.c | 6 +- | 109 | target/arm/kvm64.c | 12 ++ |
124 | stubs/arch_type.c | 4 - | 110 | target/arm/op_helper.c | 9 + |
125 | target/arm/cpu.c | 23 ++ | 111 | target/arm/translate-a64.c | 36 +++- |
126 | target/arm/cpu64.c | 118 +++++------ | 112 | tests/unit/ptimer-test.c | 6 +- |
127 | target/arm/helper.c | 40 +++- | 113 | 46 files changed, 697 insertions(+), 228 deletions(-) |
128 | target/arm/kvm64.c | 2 +- | ||
129 | target/arm/op_helper.c | 16 ++ | ||
130 | target/arm/translate.c | 12 ++ | ||
131 | target/ppc/cpu_init.c | 1 - | ||
132 | target/s390x/cpu-sysemu.c | 1 - | ||
133 | tests/qtest/ipmi-bt-test.c | 2 +- | ||
134 | tests/tcg/multiarch/linux-test.c | 4 +- | ||
135 | MAINTAINERS | 5 + | ||
136 | hw/arm/Kconfig | 2 - | ||
137 | stubs/meson.build | 1 - | ||
138 | 57 files changed, 949 insertions(+), 707 deletions(-) | ||
139 | create mode 100644 docs/specs/acpi_cpu_hotplug.rst | ||
140 | delete mode 100644 docs/specs/acpi_cpu_hotplug.txt | ||
141 | create mode 100644 docs/specs/acpi_mem_hotplug.rst | ||
142 | delete mode 100644 docs/specs/acpi_mem_hotplug.txt | ||
143 | create mode 100644 docs/specs/acpi_nvdimm.rst | ||
144 | delete mode 100644 docs/specs/acpi_nvdimm.txt | ||
145 | rename docs/specs/{acpi_pci_hotplug.txt => acpi_pci_hotplug.rst} (51%) | ||
146 | delete mode 100644 stubs/arch_type.c | ||
147 | 114 | diff view generated by jsdifflib |
1 | From: Tong Ho <tong.ho@xilinx.com> | 1 | In the original Arm v8 two-stage translation, both stage 1 and stage |
---|---|---|---|
2 | 2 specify memory attributes (memory type, cacheability, | ||
3 | shareability); these are then combined to produce the overall memory | ||
4 | attributes for the whole stage 1+2 access. In QEMU we implement this | ||
5 | by having get_phys_addr() fill in an ARMCacheAttrs struct, and we | ||
6 | convert both the stage 1 and stage 2 attribute bit formats to the | ||
7 | same encoding (an 8-bit attribute value matching the MAIR_EL1 fields, | ||
8 | plus a 2-bit shareability value). | ||
2 | 9 | ||
3 | Add unimplemented APU mmio region to xlnx-zynqmp for booting | 10 | The new FEAT_S2FWB feature allows the guest to enable a different |
4 | bare-metal guests built with standalone bsp, which access the | 11 | interpretation of the attribute bits in the stage 2 descriptors. |
5 | region from one of the following places: | 12 | These bits can now be used to control details of how the stage 1 and |
6 | https://github.com/Xilinx/embeddedsw/blob/release-2020.2/lib/bsp/standalone/src/arm/ARMv8/64bit/armclang/boot.S#L139 | 13 | 2 attributes should be combined (for instance they can say "always |
7 | https://github.com/Xilinx/embeddedsw/blob/release-2020.2/lib/bsp/standalone/src/arm/ARMv8/64bit/gcc/boot.S#L183 | 14 | use the stage 1 attributes" or "ignore the stage 1 attributes and |
15 | always be Device memory"). This means we need to pass the raw bit | ||
16 | information for stage 2 down to the function which combines the stage | ||
17 | 1 and stage 2 information. | ||
8 | 18 | ||
9 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | 19 | Add a field to ARMCacheAttrs that indicates whether the attrs field |
10 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 20 | should be interpreted as MAIR format, or as the raw stage 2 attribute |
11 | Signed-off-by: Tong Ho <tong.ho@xilinx.com> | 21 | bits from the descriptor, and store the appropriate values when |
12 | Message-id: 20210823173818.201259-3-tong.ho@xilinx.com | 22 | filling in cacheattrs. |
23 | |||
24 | We only need to interpret the attrs field in a few places: | ||
25 | * in do_ats_write(), where we know to expect a MAIR value | ||
26 | (there is no ATS instruction to do a stage-2-only walk) | ||
27 | * in S1_ptw_translate(), where we want to know whether the | ||
28 | combined S1 + S2 attributes indicate Device memory that | ||
29 | should provoke a fault | ||
30 | * in combine_cacheattrs(), which does the S1 + S2 combining | ||
31 | Update those places accordingly. | ||
32 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 33 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
34 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
35 | Message-id: 20220505183950.2781801-2-peter.maydell@linaro.org | ||
14 | --- | 36 | --- |
15 | include/hw/arm/xlnx-zynqmp.h | 7 +++++++ | 37 | target/arm/internals.h | 7 ++++++- |
16 | hw/arm/xlnx-zynqmp.c | 32 ++++++++++++++++++++++++++++++++ | 38 | target/arm/helper.c | 42 ++++++++++++++++++++++++++++++++++++------ |
17 | 2 files changed, 39 insertions(+) | 39 | 2 files changed, 42 insertions(+), 7 deletions(-) |
18 | 40 | ||
19 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h | 41 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
20 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/hw/arm/xlnx-zynqmp.h | 43 | --- a/target/arm/internals.h |
22 | +++ b/include/hw/arm/xlnx-zynqmp.h | 44 | +++ b/target/arm/internals.h |
23 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) | 45 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
24 | #define XLNX_ZYNQMP_MAX_RAM_SIZE (XLNX_ZYNQMP_MAX_LOW_RAM_SIZE + \ | 46 | |
25 | XLNX_ZYNQMP_MAX_HIGH_RAM_SIZE) | 47 | /* Cacheability and shareability attributes for a memory access */ |
26 | 48 | typedef struct ARMCacheAttrs { | |
27 | +/* | 49 | - unsigned int attrs:8; /* as in the MAIR register encoding */ |
28 | + * Unimplemented mmio regions needed to boot some images. | 50 | + /* |
29 | + */ | 51 | + * If is_s2_format is true, attrs is the S2 descriptor bits [5:2] |
30 | +#define XLNX_ZYNQMP_NUM_UNIMP_AREAS 1 | 52 | + * Otherwise, attrs is the same as the MAIR_EL1 8-bit format |
53 | + */ | ||
54 | + unsigned int attrs:8; | ||
55 | unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */ | ||
56 | + bool is_s2_format:1; | ||
57 | } ARMCacheAttrs; | ||
58 | |||
59 | bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
60 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/helper.c | ||
63 | +++ b/target/arm/helper.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | ||
65 | ret = get_phys_addr(env, value, access_type, mmu_idx, &phys_addr, &attrs, | ||
66 | &prot, &page_size, &fi, &cacheattrs); | ||
67 | |||
68 | + /* | ||
69 | + * ATS operations only do S1 or S1+S2 translations, so we never | ||
70 | + * have to deal with the ARMCacheAttrs format for S2 only. | ||
71 | + */ | ||
72 | + assert(!cacheattrs.is_s2_format); | ||
31 | + | 73 | + |
32 | struct XlnxZynqMPState { | 74 | if (ret) { |
33 | /*< private >*/ | 75 | /* |
34 | DeviceState parent_obj; | 76 | * Some kinds of translation fault must cause exceptions rather |
35 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { | 77 | @@ -XXX,XX +XXX,XX @@ static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, |
36 | MemoryRegion *ddr_ram; | 78 | return true; |
37 | MemoryRegion ddr_ram_low, ddr_ram_high; | ||
38 | |||
39 | + MemoryRegion mr_unimp[XLNX_ZYNQMP_NUM_UNIMP_AREAS]; | ||
40 | + | ||
41 | CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS]; | ||
42 | CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS]; | ||
43 | XlnxZynqMPCANState can[XLNX_ZYNQMP_NUM_CAN]; | ||
44 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/xlnx-zynqmp.c | ||
47 | +++ b/hw/arm/xlnx-zynqmp.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | #include "qemu/module.h" | ||
50 | #include "hw/arm/xlnx-zynqmp.h" | ||
51 | #include "hw/intc/arm_gic_common.h" | ||
52 | +#include "hw/misc/unimp.h" | ||
53 | #include "hw/boards.h" | ||
54 | #include "sysemu/kvm.h" | ||
55 | #include "sysemu/sysemu.h" | ||
56 | @@ -XXX,XX +XXX,XX @@ | ||
57 | #define DPDMA_ADDR 0xfd4c0000 | ||
58 | #define DPDMA_IRQ 116 | ||
59 | |||
60 | +#define APU_ADDR 0xfd5c0000 | ||
61 | +#define APU_SIZE 0x100 | ||
62 | + | ||
63 | #define IPI_ADDR 0xFF300000 | ||
64 | #define IPI_IRQ 64 | ||
65 | |||
66 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s, | ||
67 | qdev_realize(DEVICE(&s->rpu_cluster), NULL, &error_fatal); | ||
68 | } | 79 | } |
69 | 80 | ||
70 | +static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s) | 81 | +static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) |
71 | +{ | 82 | +{ |
72 | + static const struct UnimpInfo { | 83 | + /* |
73 | + const char *name; | 84 | + * For an S1 page table walk, the stage 1 attributes are always |
74 | + hwaddr base; | 85 | + * some form of "this is Normal memory". The combined S1+S2 |
75 | + hwaddr size; | 86 | + * attributes are therefore only Device if stage 2 specifies Device. |
76 | + } unimp_areas[ARRAY_SIZE(s->mr_unimp)] = { | 87 | + * With HCR_EL2.FWB == 0 this is when descriptor bits [5:4] are 0b00, |
77 | + { .name = "apu", APU_ADDR, APU_SIZE }, | 88 | + * ie when cacheattrs.attrs bits [3:2] are 0b00. |
78 | + }; | 89 | + */ |
79 | + unsigned int nr; | 90 | + assert(cacheattrs.is_s2_format); |
80 | + | 91 | + return (cacheattrs.attrs & 0xc) == 0; |
81 | + for (nr = 0; nr < ARRAY_SIZE(unimp_areas); nr++) { | ||
82 | + const struct UnimpInfo *info = &unimp_areas[nr]; | ||
83 | + DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE); | ||
84 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
85 | + | ||
86 | + assert(info->name && info->base && info->size > 0); | ||
87 | + qdev_prop_set_string(dev, "name", info->name); | ||
88 | + qdev_prop_set_uint64(dev, "size", info->size); | ||
89 | + object_property_add_child(OBJECT(s), info->name, OBJECT(dev)); | ||
90 | + | ||
91 | + sysbus_realize_and_unref(sbd, &error_fatal); | ||
92 | + sysbus_mmio_map(sbd, 0, info->base); | ||
93 | + } | ||
94 | +} | 92 | +} |
95 | + | 93 | + |
96 | static void xlnx_zynqmp_init(Object *obj) | 94 | /* Translate a S1 pagetable walk through S2 if needed. */ |
95 | static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
96 | hwaddr addr, bool *is_secure, | ||
97 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
98 | return ~0; | ||
99 | } | ||
100 | if ((arm_hcr_el2_eff(env) & HCR_PTW) && | ||
101 | - (cacheattrs.attrs & 0xf0) == 0) { | ||
102 | + ptw_attrs_are_device(env, cacheattrs)) { | ||
103 | /* | ||
104 | * PTW set and S1 walk touched S2 Device memory: | ||
105 | * generate Permission fault. | ||
106 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
107 | } | ||
108 | |||
109 | if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
110 | - cacheattrs->attrs = convert_stage2_attrs(env, extract32(attrs, 0, 4)); | ||
111 | + cacheattrs->is_s2_format = true; | ||
112 | + cacheattrs->attrs = extract32(attrs, 0, 4); | ||
113 | } else { | ||
114 | /* Index into MAIR registers for cache attributes */ | ||
115 | uint8_t attrindx = extract32(attrs, 0, 3); | ||
116 | uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; | ||
117 | assert(attrindx <= 7); | ||
118 | + cacheattrs->is_s2_format = false; | ||
119 | cacheattrs->attrs = extract64(mair, attrindx * 8, 8); | ||
120 | } | ||
121 | |||
122 | @@ -XXX,XX +XXX,XX @@ static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2) | ||
123 | /* Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 | ||
124 | * and CombineS1S2Desc() | ||
125 | * | ||
126 | + * @env: CPUARMState | ||
127 | * @s1: Attributes from stage 1 walk | ||
128 | * @s2: Attributes from stage 2 walk | ||
129 | */ | ||
130 | -static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
131 | +static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
132 | + ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
97 | { | 133 | { |
98 | MachineState *ms = MACHINE(qdev_get_machine()); | 134 | uint8_t s1lo, s2lo, s1hi, s2hi; |
99 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | 135 | ARMCacheAttrs ret; |
100 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, RTC_ADDR); | 136 | bool tagged = false; |
101 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, gic_spi[RTC_IRQ]); | 137 | + uint8_t s2_mair_attrs; |
102 | |||
103 | + xlnx_zynqmp_create_unimp_mmio(s); | ||
104 | + | 138 | + |
105 | for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) { | 139 | + assert(s2.is_s2_format && !s1.is_s2_format); |
106 | if (!object_property_set_uint(OBJECT(&s->gdma[i]), "bus-width", 128, | 140 | + ret.is_s2_format = false; |
107 | errp)) { | 141 | + |
142 | + s2_mair_attrs = convert_stage2_attrs(env, s2.attrs); | ||
143 | |||
144 | if (s1.attrs == 0xf0) { | ||
145 | tagged = true; | ||
146 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
147 | } | ||
148 | |||
149 | s1lo = extract32(s1.attrs, 0, 4); | ||
150 | - s2lo = extract32(s2.attrs, 0, 4); | ||
151 | + s2lo = extract32(s2_mair_attrs, 0, 4); | ||
152 | s1hi = extract32(s1.attrs, 4, 4); | ||
153 | - s2hi = extract32(s2.attrs, 4, 4); | ||
154 | + s2hi = extract32(s2_mair_attrs, 4, 4); | ||
155 | |||
156 | /* Combine shareability attributes (table D4-43) */ | ||
157 | if (s1.shareability == 2 || s2.shareability == 2) { | ||
158 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
159 | } | ||
160 | cacheattrs->shareability = 0; | ||
161 | } | ||
162 | - *cacheattrs = combine_cacheattrs(*cacheattrs, cacheattrs2); | ||
163 | + *cacheattrs = combine_cacheattrs(env, *cacheattrs, cacheattrs2); | ||
164 | |||
165 | /* Check if IPA translates to secure or non-secure PA space. */ | ||
166 | if (arm_is_secure_below_el3(env)) { | ||
167 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
168 | /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ | ||
169 | hcr = arm_hcr_el2_eff(env); | ||
170 | cacheattrs->shareability = 0; | ||
171 | + cacheattrs->is_s2_format = false; | ||
172 | if (hcr & HCR_DC) { | ||
173 | if (hcr & HCR_DCT) { | ||
174 | memattr = 0xf0; /* Tagged, Normal, WB, RWA */ | ||
108 | -- | 175 | -- |
109 | 2.20.1 | 176 | 2.25.1 |
110 | |||
111 | diff view generated by jsdifflib |
1 | arch_init.c does very little but has a long list of #include lines. | 1 | Factor out the part of combine_cacheattrs() that is specific to |
---|---|---|---|
2 | Remove all the unnecessary ones. | 2 | handling HCR_EL2.FWB == 0. This is the part where we combine the |
3 | memory type and cacheability attributes. | ||
4 | |||
5 | The "force Outer Shareable for Device or Normal Inner-NC Outer-NC" | ||
6 | logic remains in combine_cacheattrs() because it holds regardless | ||
7 | (this is the equivalent of the pseudocode EffectiveShareability() | ||
8 | function). | ||
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 | Message-id: 20210730105947.28215-4-peter.maydell@linaro.org | 12 | Message-id: 20220505183950.2781801-3-peter.maydell@linaro.org |
7 | --- | 13 | --- |
8 | softmmu/arch_init.c | 7 ------- | 14 | target/arm/helper.c | 88 +++++++++++++++++++++++++-------------------- |
9 | 1 file changed, 7 deletions(-) | 15 | 1 file changed, 50 insertions(+), 38 deletions(-) |
10 | 16 | ||
11 | diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/softmmu/arch_init.c | 19 | --- a/target/arm/helper.c |
14 | +++ b/softmmu/arch_init.c | 20 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2) |
16 | */ | 22 | } |
17 | #include "qemu/osdep.h" | 23 | } |
18 | #include "sysemu/arch_init.h" | 24 | |
19 | -#include "hw/pci/pci.h" | 25 | +/* |
20 | -#include "hw/audio/soundhw.h" | 26 | + * Combine the memory type and cacheability attributes of |
21 | -#include "qapi/error.h" | 27 | + * s1 and s2 for the HCR_EL2.FWB == 0 case, returning the |
22 | -#include "qemu/config-file.h" | 28 | + * combined attributes in MAIR_EL1 format. |
23 | -#include "qemu/error-report.h" | 29 | + */ |
24 | -#include "hw/acpi/acpi.h" | 30 | +static uint8_t combined_attrs_nofwb(CPUARMState *env, |
25 | -#include "qemu/help_option.h" | 31 | + ARMCacheAttrs s1, ARMCacheAttrs s2) |
26 | 32 | +{ | |
27 | #ifdef TARGET_SPARC | 33 | + uint8_t s1lo, s2lo, s1hi, s2hi, s2_mair_attrs, ret_attrs; |
28 | int graphic_width = 1024; | 34 | + |
35 | + s2_mair_attrs = convert_stage2_attrs(env, s2.attrs); | ||
36 | + | ||
37 | + s1lo = extract32(s1.attrs, 0, 4); | ||
38 | + s2lo = extract32(s2_mair_attrs, 0, 4); | ||
39 | + s1hi = extract32(s1.attrs, 4, 4); | ||
40 | + s2hi = extract32(s2_mair_attrs, 4, 4); | ||
41 | + | ||
42 | + /* Combine memory type and cacheability attributes */ | ||
43 | + if (s1hi == 0 || s2hi == 0) { | ||
44 | + /* Device has precedence over normal */ | ||
45 | + if (s1lo == 0 || s2lo == 0) { | ||
46 | + /* nGnRnE has precedence over anything */ | ||
47 | + ret_attrs = 0; | ||
48 | + } else if (s1lo == 4 || s2lo == 4) { | ||
49 | + /* non-Reordering has precedence over Reordering */ | ||
50 | + ret_attrs = 4; /* nGnRE */ | ||
51 | + } else if (s1lo == 8 || s2lo == 8) { | ||
52 | + /* non-Gathering has precedence over Gathering */ | ||
53 | + ret_attrs = 8; /* nGRE */ | ||
54 | + } else { | ||
55 | + ret_attrs = 0xc; /* GRE */ | ||
56 | + } | ||
57 | + } else { /* Normal memory */ | ||
58 | + /* Outer/inner cacheability combine independently */ | ||
59 | + ret_attrs = combine_cacheattr_nibble(s1hi, s2hi) << 4 | ||
60 | + | combine_cacheattr_nibble(s1lo, s2lo); | ||
61 | + } | ||
62 | + return ret_attrs; | ||
63 | +} | ||
64 | + | ||
65 | /* Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 | ||
66 | * and CombineS1S2Desc() | ||
67 | * | ||
68 | @@ -XXX,XX +XXX,XX @@ static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2) | ||
69 | static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
70 | ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
71 | { | ||
72 | - uint8_t s1lo, s2lo, s1hi, s2hi; | ||
73 | ARMCacheAttrs ret; | ||
74 | bool tagged = false; | ||
75 | - uint8_t s2_mair_attrs; | ||
76 | |||
77 | assert(s2.is_s2_format && !s1.is_s2_format); | ||
78 | ret.is_s2_format = false; | ||
79 | |||
80 | - s2_mair_attrs = convert_stage2_attrs(env, s2.attrs); | ||
81 | - | ||
82 | if (s1.attrs == 0xf0) { | ||
83 | tagged = true; | ||
84 | s1.attrs = 0xff; | ||
85 | } | ||
86 | |||
87 | - s1lo = extract32(s1.attrs, 0, 4); | ||
88 | - s2lo = extract32(s2_mair_attrs, 0, 4); | ||
89 | - s1hi = extract32(s1.attrs, 4, 4); | ||
90 | - s2hi = extract32(s2_mair_attrs, 4, 4); | ||
91 | - | ||
92 | /* Combine shareability attributes (table D4-43) */ | ||
93 | if (s1.shareability == 2 || s2.shareability == 2) { | ||
94 | /* if either are outer-shareable, the result is outer-shareable */ | ||
95 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
96 | } | ||
97 | |||
98 | /* Combine memory type and cacheability attributes */ | ||
99 | - if (s1hi == 0 || s2hi == 0) { | ||
100 | - /* Device has precedence over normal */ | ||
101 | - if (s1lo == 0 || s2lo == 0) { | ||
102 | - /* nGnRnE has precedence over anything */ | ||
103 | - ret.attrs = 0; | ||
104 | - } else if (s1lo == 4 || s2lo == 4) { | ||
105 | - /* non-Reordering has precedence over Reordering */ | ||
106 | - ret.attrs = 4; /* nGnRE */ | ||
107 | - } else if (s1lo == 8 || s2lo == 8) { | ||
108 | - /* non-Gathering has precedence over Gathering */ | ||
109 | - ret.attrs = 8; /* nGRE */ | ||
110 | - } else { | ||
111 | - ret.attrs = 0xc; /* GRE */ | ||
112 | - } | ||
113 | + ret.attrs = combined_attrs_nofwb(env, s1, s2); | ||
114 | |||
115 | - /* Any location for which the resultant memory type is any | ||
116 | - * type of Device memory is always treated as Outer Shareable. | ||
117 | - */ | ||
118 | + /* | ||
119 | + * Any location for which the resultant memory type is any | ||
120 | + * type of Device memory is always treated as Outer Shareable. | ||
121 | + * Any location for which the resultant memory type is Normal | ||
122 | + * Inner Non-cacheable, Outer Non-cacheable is always treated | ||
123 | + * as Outer Shareable. | ||
124 | + * TODO: FEAT_XS adds another value (0x40) also meaning iNCoNC | ||
125 | + */ | ||
126 | + if ((ret.attrs & 0xf0) == 0 || ret.attrs == 0x44) { | ||
127 | ret.shareability = 2; | ||
128 | - } else { /* Normal memory */ | ||
129 | - /* Outer/inner cacheability combine independently */ | ||
130 | - ret.attrs = combine_cacheattr_nibble(s1hi, s2hi) << 4 | ||
131 | - | combine_cacheattr_nibble(s1lo, s2lo); | ||
132 | - | ||
133 | - if (ret.attrs == 0x44) { | ||
134 | - /* Any location for which the resultant memory type is Normal | ||
135 | - * Inner Non-cacheable, Outer Non-cacheable is always treated | ||
136 | - * as Outer Shareable. | ||
137 | - */ | ||
138 | - ret.shareability = 2; | ||
139 | - } | ||
140 | } | ||
141 | |||
142 | /* TODO: CombineS1S2Desc does not consider transient, only WB, RWA. */ | ||
29 | -- | 143 | -- |
30 | 2.20.1 | 144 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | In v7, the HSTR register has a TTEE bit which allows EL0/EL1 accesses | 1 | Implement the handling of FEAT_S2FWB; the meat of this is in the new |
---|---|---|---|
2 | to the Thumb2EE TEECR and TEEHBR registers to be trapped to the | 2 | combined_attrs_fwb() function which combines S1 and S2 attributes |
3 | hypervisor. Implement these traps. | 3 | when HCR_EL2.FWB is set. |
4 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20210816180305.20137-2-peter.maydell@linaro.org | 7 | Message-id: 20220505183950.2781801-4-peter.maydell@linaro.org |
8 | --- | 8 | --- |
9 | target/arm/cpu.h | 2 ++ | 9 | target/arm/cpu.h | 5 +++ |
10 | target/arm/helper.c | 18 ++++++++++++++++-- | 10 | target/arm/helper.c | 84 +++++++++++++++++++++++++++++++++++++++++++-- |
11 | 2 files changed, 18 insertions(+), 2 deletions(-) | 11 | 2 files changed, 86 insertions(+), 3 deletions(-) |
12 | 12 | ||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.h | 15 | --- a/target/arm/cpu.h |
16 | +++ b/target/arm/cpu.h | 16 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 17 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_st(const ARMISARegisters *id) |
18 | #define SCR_ENSCXT (1U << 25) | 18 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, ST) != 0; |
19 | #define SCR_ATA (1U << 26) | 19 | } |
20 | 20 | ||
21 | +#define HSTR_TTEE (1 << 16) | 21 | +static inline bool isar_feature_aa64_fwb(const ARMISARegisters *id) |
22 | +{ | ||
23 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, FWB) != 0; | ||
24 | +} | ||
22 | + | 25 | + |
23 | /* Return the current FPSCR value. */ | 26 | static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) |
24 | uint32_t vfp_get_fpscr(CPUARMState *env); | 27 | { |
25 | void vfp_set_fpscr(CPUARMState *env, uint32_t val); | 28 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; |
26 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 29 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
27 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/helper.c | 31 | --- a/target/arm/helper.c |
29 | +++ b/target/arm/helper.c | 32 | +++ b/target/arm/helper.c |
30 | @@ -XXX,XX +XXX,XX @@ static void teecr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 33 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) |
31 | env->teecr = value; | 34 | if (cpu_isar_feature(aa64_scxtnum, cpu)) { |
35 | valid_mask |= HCR_ENSCXT; | ||
36 | } | ||
37 | + if (cpu_isar_feature(aa64_fwb, cpu)) { | ||
38 | + valid_mask |= HCR_FWB; | ||
39 | + } | ||
40 | } | ||
41 | |||
42 | /* Clear RES0 bits. */ | ||
43 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
44 | * HCR_PTW forbids certain page-table setups | ||
45 | * HCR_DC disables stage1 and enables stage2 translation | ||
46 | * HCR_DCT enables tagging on (disabled) stage1 translation | ||
47 | + * HCR_FWB changes the interpretation of stage2 descriptor bits | ||
48 | */ | ||
49 | - if ((env->cp15.hcr_el2 ^ value) & (HCR_VM | HCR_PTW | HCR_DC | HCR_DCT)) { | ||
50 | + if ((env->cp15.hcr_el2 ^ value) & | ||
51 | + (HCR_VM | HCR_PTW | HCR_DC | HCR_DCT | HCR_FWB)) { | ||
52 | tlb_flush(CPU(cpu)); | ||
53 | } | ||
54 | env->cp15.hcr_el2 = value; | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) | ||
56 | * attributes are therefore only Device if stage 2 specifies Device. | ||
57 | * With HCR_EL2.FWB == 0 this is when descriptor bits [5:4] are 0b00, | ||
58 | * ie when cacheattrs.attrs bits [3:2] are 0b00. | ||
59 | + * With HCR_EL2.FWB == 1 this is when descriptor bit [4] is 0, ie | ||
60 | + * when cacheattrs.attrs bit [2] is 0. | ||
61 | */ | ||
62 | assert(cacheattrs.is_s2_format); | ||
63 | - return (cacheattrs.attrs & 0xc) == 0; | ||
64 | + if (arm_hcr_el2_eff(env) & HCR_FWB) { | ||
65 | + return (cacheattrs.attrs & 0x4) == 0; | ||
66 | + } else { | ||
67 | + return (cacheattrs.attrs & 0xc) == 0; | ||
68 | + } | ||
32 | } | 69 | } |
33 | 70 | ||
34 | +static CPAccessResult teecr_access(CPUARMState *env, const ARMCPRegInfo *ri, | 71 | /* Translate a S1 pagetable walk through S2 if needed. */ |
35 | + bool isread) | 72 | @@ -XXX,XX +XXX,XX @@ static uint8_t combined_attrs_nofwb(CPUARMState *env, |
73 | return ret_attrs; | ||
74 | } | ||
75 | |||
76 | +static uint8_t force_cacheattr_nibble_wb(uint8_t attr) | ||
36 | +{ | 77 | +{ |
37 | + /* | 78 | + /* |
38 | + * HSTR.TTEE only exists in v7A, not v8A, but v8A doesn't have T2EE | 79 | + * Given the 4 bits specifying the outer or inner cacheability |
39 | + * at all, so we don't need to check whether we're v8A. | 80 | + * in MAIR format, return a value specifying Normal Write-Back, |
81 | + * with the allocation and transient hints taken from the input | ||
82 | + * if the input specified some kind of cacheable attribute. | ||
40 | + */ | 83 | + */ |
41 | + if (arm_current_el(env) < 2 && !arm_is_secure_below_el3(env) && | 84 | + if (attr == 0 || attr == 4) { |
42 | + (env->cp15.hstr_el2 & HSTR_TTEE)) { | 85 | + /* |
43 | + return CP_ACCESS_TRAP_EL2; | 86 | + * 0 == an UNPREDICTABLE encoding |
87 | + * 4 == Non-cacheable | ||
88 | + * Either way, force Write-Back RW allocate non-transient | ||
89 | + */ | ||
90 | + return 0xf; | ||
44 | + } | 91 | + } |
45 | + return CP_ACCESS_OK; | 92 | + /* Change WriteThrough to WriteBack, keep allocation and transient hints */ |
93 | + return attr | 4; | ||
46 | +} | 94 | +} |
47 | + | 95 | + |
48 | static CPAccessResult teehbr_access(CPUARMState *env, const ARMCPRegInfo *ri, | 96 | +/* |
49 | bool isread) | 97 | + * Combine the memory type and cacheability attributes of |
50 | { | 98 | + * s1 and s2 for the HCR_EL2.FWB == 1 case, returning the |
51 | if (arm_current_el(env) == 0 && (env->teecr & 1)) { | 99 | + * combined attributes in MAIR_EL1 format. |
52 | return CP_ACCESS_TRAP; | 100 | + */ |
101 | +static uint8_t combined_attrs_fwb(CPUARMState *env, | ||
102 | + ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
103 | +{ | ||
104 | + switch (s2.attrs) { | ||
105 | + case 7: | ||
106 | + /* Use stage 1 attributes */ | ||
107 | + return s1.attrs; | ||
108 | + case 6: | ||
109 | + /* | ||
110 | + * Force Normal Write-Back. Note that if S1 is Normal cacheable | ||
111 | + * then we take the allocation hints from it; otherwise it is | ||
112 | + * RW allocate, non-transient. | ||
113 | + */ | ||
114 | + if ((s1.attrs & 0xf0) == 0) { | ||
115 | + /* S1 is Device */ | ||
116 | + return 0xff; | ||
117 | + } | ||
118 | + /* Need to check the Inner and Outer nibbles separately */ | ||
119 | + return force_cacheattr_nibble_wb(s1.attrs & 0xf) | | ||
120 | + force_cacheattr_nibble_wb(s1.attrs >> 4) << 4; | ||
121 | + case 5: | ||
122 | + /* If S1 attrs are Device, use them; otherwise Normal Non-cacheable */ | ||
123 | + if ((s1.attrs & 0xf0) == 0) { | ||
124 | + return s1.attrs; | ||
125 | + } | ||
126 | + return 0x44; | ||
127 | + case 0 ... 3: | ||
128 | + /* Force Device, of subtype specified by S2 */ | ||
129 | + return s2.attrs << 2; | ||
130 | + default: | ||
131 | + /* | ||
132 | + * RESERVED values (including RES0 descriptor bit [5] being nonzero); | ||
133 | + * arbitrarily force Device. | ||
134 | + */ | ||
135 | + return 0; | ||
136 | + } | ||
137 | +} | ||
138 | + | ||
139 | /* Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 | ||
140 | * and CombineS1S2Desc() | ||
141 | * | ||
142 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
53 | } | 143 | } |
54 | - return CP_ACCESS_OK; | 144 | |
55 | + return teecr_access(env, ri, isread); | 145 | /* Combine memory type and cacheability attributes */ |
56 | } | 146 | - ret.attrs = combined_attrs_nofwb(env, s1, s2); |
57 | 147 | + if (arm_hcr_el2_eff(env) & HCR_FWB) { | |
58 | static const ARMCPRegInfo t2ee_cp_reginfo[] = { | 148 | + ret.attrs = combined_attrs_fwb(env, s1, s2); |
59 | { .name = "TEECR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 6, .opc2 = 0, | 149 | + } else { |
60 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, teecr), | 150 | + ret.attrs = combined_attrs_nofwb(env, s1, s2); |
61 | .resetvalue = 0, | 151 | + } |
62 | - .writefn = teecr_write }, | 152 | |
63 | + .writefn = teecr_write, .accessfn = teecr_access }, | 153 | /* |
64 | { .name = "TEEHBR", .cp = 14, .crn = 1, .crm = 0, .opc1 = 6, .opc2 = 0, | 154 | * Any location for which the resultant memory type is any |
65 | .access = PL0_RW, .fieldoffset = offsetof(CPUARMState, teehbr), | ||
66 | .accessfn = teehbr_access, .resetvalue = 0 }, | ||
67 | -- | 155 | -- |
68 | 2.20.1 | 156 | 2.25.1 |
69 | |||
70 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Enable the FEAT_S2FWB for -cpu max. Since FEAT_S2FWB requires that |
---|---|---|---|
2 | CLIDR_EL1.{LoUU,LoUIS} are zero, we explicitly squash these (the | ||
3 | inherited CLIDR_EL1 value from the Cortex-A57 has them as 1). | ||
2 | 4 | ||
3 | Future CPU types may specify which vector lengths are supported. | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | We can apply nearly the same logic to validate those lengths | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | as we do for KVM's supported vector lengths. We merge the code | 7 | Message-id: 20220505183950.2781801-5-peter.maydell@linaro.org |
6 | where we can, but unfortunately can't completely merge it because | 8 | --- |
7 | KVM requires all vector lengths, power-of-two or not, smaller than | 9 | docs/system/arm/emulation.rst | 1 + |
8 | the maximum enabled length to also be enabled. The architecture | 10 | target/arm/cpu64.c | 11 +++++++++++ |
9 | only requires all the power-of-two lengths, though, so TCG will | 11 | 2 files changed, 12 insertions(+) |
10 | only enforce that. | ||
11 | 12 | ||
12 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 13 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | Message-id: 20210823160647.34028-5-drjones@redhat.com | 15 | --- a/docs/system/arm/emulation.rst |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | +++ b/docs/system/arm/emulation.rst |
16 | --- | 17 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
17 | target/arm/cpu64.c | 101 ++++++++++++++++++++------------------------- | 18 | - FEAT_RAS (Reliability, availability, and serviceability) |
18 | 1 file changed, 45 insertions(+), 56 deletions(-) | 19 | - FEAT_RDM (Advanced SIMD rounding double multiply accumulate instructions) |
19 | 20 | - FEAT_RNG (Random number generator) | |
21 | +- FEAT_S2FWB (Stage 2 forced Write-Back) | ||
22 | - FEAT_SB (Speculation Barrier) | ||
23 | - FEAT_SEL2 (Secure EL2) | ||
24 | - FEAT_SHA1 (SHA1 instructions) | ||
20 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 25 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
21 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu64.c | 27 | --- a/target/arm/cpu64.c |
23 | +++ b/target/arm/cpu64.c | 28 | +++ b/target/arm/cpu64.c |
24 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | 29 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
25 | break; | 30 | { |
26 | } | 31 | ARMCPU *cpu = ARM_CPU(obj); |
27 | } | 32 | uint64_t t; |
28 | - max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | 33 | + uint32_t u; |
29 | - bitmap_andnot(cpu->sve_vq_map, cpu->sve_vq_supported, | 34 | |
30 | - cpu->sve_vq_init, max_vq); | 35 | if (kvm_enabled() || hvf_enabled()) { |
31 | - if (max_vq == 0 || bitmap_empty(cpu->sve_vq_map, max_vq)) { | 36 | /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ |
32 | - error_setg(errp, "cannot disable sve%d", vq * 128); | 37 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
33 | - error_append_hint(errp, "Disabling sve%d results in all " | 38 | t = FIELD_DP64(t, MIDR_EL1, REVISION, 0); |
34 | - "vector lengths being disabled.\n", | 39 | cpu->midr = t; |
35 | - vq * 128); | 40 | |
36 | - error_append_hint(errp, "With SVE enabled, at least one " | 41 | + /* |
37 | - "vector length must be enabled.\n"); | 42 | + * We're going to set FEAT_S2FWB, which mandates that CLIDR_EL1.{LoUU,LoUIS} |
38 | - return; | 43 | + * are zero. |
39 | - } | 44 | + */ |
40 | } else { | 45 | + u = cpu->clidr; |
41 | /* Disabling a power-of-two disables all larger lengths. */ | 46 | + u = FIELD_DP32(u, CLIDR_EL1, LOUIS, 0); |
42 | - if (test_bit(0, cpu->sve_vq_init)) { | 47 | + u = FIELD_DP32(u, CLIDR_EL1, LOUU, 0); |
43 | - error_setg(errp, "cannot disable sve128"); | 48 | + cpu->clidr = u; |
44 | - error_append_hint(errp, "Disabling sve128 results in all " | ||
45 | - "vector lengths being disabled.\n"); | ||
46 | - error_append_hint(errp, "With SVE enabled, at least one " | ||
47 | - "vector length must be enabled.\n"); | ||
48 | - return; | ||
49 | - } | ||
50 | - for (vq = 2; vq <= ARM_MAX_VQ; vq <<= 1) { | ||
51 | + for (vq = 1; vq <= ARM_MAX_VQ; vq <<= 1) { | ||
52 | if (test_bit(vq - 1, cpu->sve_vq_init)) { | ||
53 | break; | ||
54 | } | ||
55 | } | ||
56 | - max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | ||
57 | - bitmap_complement(cpu->sve_vq_map, cpu->sve_vq_init, max_vq); | ||
58 | + } | ||
59 | + | 49 | + |
60 | + max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | 50 | t = cpu->isar.id_aa64isar0; |
61 | + bitmap_andnot(cpu->sve_vq_map, cpu->sve_vq_supported, | 51 | t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ |
62 | + cpu->sve_vq_init, max_vq); | 52 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ |
63 | + if (max_vq == 0 || bitmap_empty(cpu->sve_vq_map, max_vq)) { | 53 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
64 | + error_setg(errp, "cannot disable sve%d", vq * 128); | 54 | t = FIELD_DP64(t, ID_AA64MMFR2, IESB, 1); /* FEAT_IESB */ |
65 | + error_append_hint(errp, "Disabling sve%d results in all " | 55 | t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ |
66 | + "vector lengths being disabled.\n", | 56 | t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */ |
67 | + vq * 128); | 57 | + t = FIELD_DP64(t, ID_AA64MMFR2, FWB, 1); /* FEAT_S2FWB */ |
68 | + error_append_hint(errp, "With SVE enabled, at least one " | 58 | t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ |
69 | + "vector length must be enabled.\n"); | 59 | t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ |
70 | + return; | 60 | cpu->isar.id_aa64mmfr2 = t; |
71 | } | ||
72 | |||
73 | max_vq = find_last_bit(cpu->sve_vq_map, max_vq) + 1; | ||
74 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
75 | assert(max_vq != 0); | ||
76 | bitmap_clear(cpu->sve_vq_map, max_vq, ARM_MAX_VQ - max_vq); | ||
77 | |||
78 | - if (kvm_enabled()) { | ||
79 | - /* Ensure the set of lengths matches what KVM supports. */ | ||
80 | - bitmap_xor(tmp, cpu->sve_vq_map, cpu->sve_vq_supported, max_vq); | ||
81 | - if (!bitmap_empty(tmp, max_vq)) { | ||
82 | - vq = find_last_bit(tmp, max_vq) + 1; | ||
83 | - if (test_bit(vq - 1, cpu->sve_vq_map)) { | ||
84 | - if (cpu->sve_max_vq) { | ||
85 | - error_setg(errp, "cannot set sve-max-vq=%d", | ||
86 | - cpu->sve_max_vq); | ||
87 | - error_append_hint(errp, "This KVM host does not support " | ||
88 | - "the vector length %d-bits.\n", | ||
89 | - vq * 128); | ||
90 | - error_append_hint(errp, "It may not be possible to use " | ||
91 | - "sve-max-vq with this KVM host. Try " | ||
92 | - "using only sve<N> properties.\n"); | ||
93 | - } else { | ||
94 | - error_setg(errp, "cannot enable sve%d", vq * 128); | ||
95 | - error_append_hint(errp, "This KVM host does not support " | ||
96 | - "the vector length %d-bits.\n", | ||
97 | - vq * 128); | ||
98 | - } | ||
99 | + /* Ensure the set of lengths matches what is supported. */ | ||
100 | + bitmap_xor(tmp, cpu->sve_vq_map, cpu->sve_vq_supported, max_vq); | ||
101 | + if (!bitmap_empty(tmp, max_vq)) { | ||
102 | + vq = find_last_bit(tmp, max_vq) + 1; | ||
103 | + if (test_bit(vq - 1, cpu->sve_vq_map)) { | ||
104 | + if (cpu->sve_max_vq) { | ||
105 | + error_setg(errp, "cannot set sve-max-vq=%d", cpu->sve_max_vq); | ||
106 | + error_append_hint(errp, "This CPU does not support " | ||
107 | + "the vector length %d-bits.\n", vq * 128); | ||
108 | + error_append_hint(errp, "It may not be possible to use " | ||
109 | + "sve-max-vq with this CPU. Try " | ||
110 | + "using only sve<N> properties.\n"); | ||
111 | } else { | ||
112 | + error_setg(errp, "cannot enable sve%d", vq * 128); | ||
113 | + error_append_hint(errp, "This CPU does not support " | ||
114 | + "the vector length %d-bits.\n", vq * 128); | ||
115 | + } | ||
116 | + return; | ||
117 | + } else { | ||
118 | + if (kvm_enabled()) { | ||
119 | error_setg(errp, "cannot disable sve%d", vq * 128); | ||
120 | error_append_hint(errp, "The KVM host requires all " | ||
121 | "supported vector lengths smaller " | ||
122 | "than %d bits to also be enabled.\n", | ||
123 | max_vq * 128); | ||
124 | - } | ||
125 | - return; | ||
126 | - } | ||
127 | - } else { | ||
128 | - /* Ensure all required powers-of-two are enabled. */ | ||
129 | - for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
130 | - if (!test_bit(vq - 1, cpu->sve_vq_map)) { | ||
131 | - error_setg(errp, "cannot disable sve%d", vq * 128); | ||
132 | - error_append_hint(errp, "sve%d is required as it " | ||
133 | - "is a power-of-two length smaller than " | ||
134 | - "the maximum, sve%d\n", | ||
135 | - vq * 128, max_vq * 128); | ||
136 | return; | ||
137 | + } else { | ||
138 | + /* Ensure all required powers-of-two are enabled. */ | ||
139 | + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
140 | + if (!test_bit(vq - 1, cpu->sve_vq_map)) { | ||
141 | + error_setg(errp, "cannot disable sve%d", vq * 128); | ||
142 | + error_append_hint(errp, "sve%d is required as it " | ||
143 | + "is a power-of-two length smaller " | ||
144 | + "than the maximum, sve%d\n", | ||
145 | + vq * 128, max_vq * 128); | ||
146 | + return; | ||
147 | + } | ||
148 | + } | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | -- | 61 | -- |
153 | 2.20.1 | 62 | 2.25.1 |
154 | |||
155 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | The Armv8.4 feature FEAT_IDST specifies that exceptions generated by |
---|---|---|---|
2 | read accesses to the feature ID space should report a syndrome code | ||
3 | of 0x18 (EC_SYSTEMREGISTERTRAP) rather than 0x00 (EC_UNCATEGORIZED). | ||
4 | The feature ID space is defined to be: | ||
5 | op0 == 3, op1 == {0,1,3}, CRn == 0, CRm == {0-7}, op2 == {0-7} | ||
2 | 6 | ||
3 | Allow CPUs that support SVE to specify which SVE vector lengths they | 7 | In our implementation we might return the EC_UNCATEGORIZED syndrome |
4 | support by setting them in this bitmap. Currently only the 'max' and | 8 | value for a system register access in four cases: |
5 | 'host' CPU types supports SVE and 'host' requires KVM which obtains | 9 | * no reginfo struct in the hashtable |
6 | its supported bitmap from the host. So, we only need to initialize the | 10 | * cp_access_ok() fails (ie ri->access doesn't permit the access) |
7 | bitmap for 'max' with TCG. And, since 'max' should support all SVE | 11 | * ri->accessfn returns CP_ACCESS_TRAP_UNCATEGORIZED at runtime |
8 | vector lengths we simply fill the bitmap. Future CPU types may have | 12 | * ri->type includes ARM_CP_RAISES_EXC, and the readfn raises |
9 | less trivial maps though. | 13 | an UNDEF exception at runtime |
10 | 14 | ||
11 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 15 | We have very few regdefs that set ARM_CP_RAISES_EXC, and none of |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 16 | them are in the feature ID space. (In the unlikely event that any |
17 | are added in future they would need to take care of setting the | ||
18 | correct syndrome themselves.) This patch deals with the other | ||
19 | three cases, and enables FEAT_IDST for AArch64 -cpu max. | ||
20 | |||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20210823160647.34028-2-drjones@redhat.com | 23 | Message-id: 20220509155457.3560724-1-peter.maydell@linaro.org |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | 24 | --- |
17 | target/arm/cpu.h | 4 ++++ | 25 | docs/system/arm/emulation.rst | 1 + |
18 | target/arm/cpu64.c | 2 ++ | 26 | target/arm/cpregs.h | 24 ++++++++++++++++++++++++ |
19 | 2 files changed, 6 insertions(+) | 27 | target/arm/cpu.h | 5 +++++ |
28 | target/arm/cpu64.c | 1 + | ||
29 | target/arm/op_helper.c | 9 +++++++++ | ||
30 | target/arm/translate-a64.c | 28 ++++++++++++++++++++++++++-- | ||
31 | 6 files changed, 66 insertions(+), 2 deletions(-) | ||
20 | 32 | ||
33 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/docs/system/arm/emulation.rst | ||
36 | +++ b/docs/system/arm/emulation.rst | ||
37 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | ||
38 | - FEAT_FlagM2 (Enhancements to flag manipulation instructions) | ||
39 | - FEAT_HPDS (Hierarchical permission disables) | ||
40 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) | ||
41 | +- FEAT_IDST (ID space trap handling) | ||
42 | - FEAT_IESB (Implicit error synchronization event) | ||
43 | - FEAT_JSCVT (JavaScript conversion instructions) | ||
44 | - FEAT_LOR (Limited ordering regions) | ||
45 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/cpregs.h | ||
48 | +++ b/target/arm/cpregs.h | ||
49 | @@ -XXX,XX +XXX,XX @@ static inline bool cp_access_ok(int current_el, | ||
50 | /* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
51 | uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
52 | |||
53 | +/* | ||
54 | + * Return true if the cp register encoding is in the "feature ID space" as | ||
55 | + * defined by FEAT_IDST (and thus should be reported with ER_ELx.EC | ||
56 | + * as EC_SYSTEMREGISTERTRAP rather than EC_UNCATEGORIZED). | ||
57 | + */ | ||
58 | +static inline bool arm_cpreg_encoding_in_idspace(uint8_t opc0, uint8_t opc1, | ||
59 | + uint8_t opc2, | ||
60 | + uint8_t crn, uint8_t crm) | ||
61 | +{ | ||
62 | + return opc0 == 3 && (opc1 == 0 || opc1 == 1 || opc1 == 3) && | ||
63 | + crn == 0 && crm < 8; | ||
64 | +} | ||
65 | + | ||
66 | +/* | ||
67 | + * As arm_cpreg_encoding_in_idspace(), but take the encoding from an | ||
68 | + * ARMCPRegInfo. | ||
69 | + */ | ||
70 | +static inline bool arm_cpreg_in_idspace(const ARMCPRegInfo *ri) | ||
71 | +{ | ||
72 | + return ri->state == ARM_CP_STATE_AA64 && | ||
73 | + arm_cpreg_encoding_in_idspace(ri->opc0, ri->opc1, ri->opc2, | ||
74 | + ri->crn, ri->crm); | ||
75 | +} | ||
76 | + | ||
77 | #endif /* TARGET_ARM_CPREGS_H */ | ||
21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 78 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
22 | index XXXXXXX..XXXXXXX 100644 | 79 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.h | 80 | --- a/target/arm/cpu.h |
24 | +++ b/target/arm/cpu.h | 81 | +++ b/target/arm/cpu.h |
25 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 82 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fwb(const ARMISARegisters *id) |
26 | * While processing properties during initialization, corresponding | 83 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, FWB) != 0; |
27 | * sve_vq_init bits are set for bits in sve_vq_map that have been | 84 | } |
28 | * set by properties. | 85 | |
29 | + * | 86 | +static inline bool isar_feature_aa64_ids(const ARMISARegisters *id) |
30 | + * Bits set in sve_vq_supported represent valid vector lengths for | 87 | +{ |
31 | + * the CPU type. | 88 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, IDS) != 0; |
32 | */ | 89 | +} |
33 | DECLARE_BITMAP(sve_vq_map, ARM_MAX_VQ); | 90 | + |
34 | DECLARE_BITMAP(sve_vq_init, ARM_MAX_VQ); | 91 | static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) |
35 | + DECLARE_BITMAP(sve_vq_supported, ARM_MAX_VQ); | 92 | { |
36 | 93 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; | |
37 | /* Generic timer counter frequency, in Hz */ | ||
38 | uint64_t gt_cntfrq_hz; | ||
39 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 94 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
40 | index XXXXXXX..XXXXXXX 100644 | 95 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/cpu64.c | 96 | --- a/target/arm/cpu64.c |
42 | +++ b/target/arm/cpu64.c | 97 | +++ b/target/arm/cpu64.c |
43 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 98 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
44 | /* Default to PAUTH on, with the architected algorithm. */ | 99 | t = FIELD_DP64(t, ID_AA64MMFR2, IESB, 1); /* FEAT_IESB */ |
45 | qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property); | 100 | t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ |
46 | qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property); | 101 | t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */ |
102 | + t = FIELD_DP64(t, ID_AA64MMFR2, IDS, 1); /* FEAT_IDST */ | ||
103 | t = FIELD_DP64(t, ID_AA64MMFR2, FWB, 1); /* FEAT_S2FWB */ | ||
104 | t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
105 | t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ | ||
106 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/op_helper.c | ||
109 | +++ b/target/arm/op_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t tgtmode, uint32_t regno) | ||
111 | void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
112 | uint32_t isread) | ||
113 | { | ||
114 | + ARMCPU *cpu = env_archcpu(env); | ||
115 | const ARMCPRegInfo *ri = rip; | ||
116 | CPAccessResult res = CP_ACCESS_OK; | ||
117 | int target_el; | ||
118 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
119 | case CP_ACCESS_TRAP: | ||
120 | break; | ||
121 | case CP_ACCESS_TRAP_UNCATEGORIZED: | ||
122 | + if (cpu_isar_feature(aa64_ids, cpu) && isread && | ||
123 | + arm_cpreg_in_idspace(ri)) { | ||
124 | + /* | ||
125 | + * FEAT_IDST says this should be reported as EC_SYSTEMREGISTERTRAP, | ||
126 | + * not EC_UNCATEGORIZED | ||
127 | + */ | ||
128 | + break; | ||
129 | + } | ||
130 | syndrome = syn_uncategorized(); | ||
131 | break; | ||
132 | default: | ||
133 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/target/arm/translate-a64.c | ||
136 | +++ b/target/arm/translate-a64.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static void gen_set_nzcv(TCGv_i64 tcg_rt) | ||
138 | tcg_temp_free_i32(nzcv); | ||
139 | } | ||
140 | |||
141 | +static void gen_sysreg_undef(DisasContext *s, bool isread, | ||
142 | + uint8_t op0, uint8_t op1, uint8_t op2, | ||
143 | + uint8_t crn, uint8_t crm, uint8_t rt) | ||
144 | +{ | ||
145 | + /* | ||
146 | + * Generate code to emit an UNDEF with correct syndrome | ||
147 | + * information for a failed system register access. | ||
148 | + * This is EC_UNCATEGORIZED (ie a standard UNDEF) in most cases, | ||
149 | + * but if FEAT_IDST is implemented then read accesses to registers | ||
150 | + * in the feature ID space are reported with the EC_SYSTEMREGISTERTRAP | ||
151 | + * syndrome. | ||
152 | + */ | ||
153 | + uint32_t syndrome; | ||
47 | + | 154 | + |
48 | + bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ); | 155 | + if (isread && dc_isar_feature(aa64_ids, s) && |
156 | + arm_cpreg_encoding_in_idspace(op0, op1, op2, crn, crm)) { | ||
157 | + syndrome = syn_aa64_sysregtrap(op0, op1, op2, crn, crm, rt, isread); | ||
158 | + } else { | ||
159 | + syndrome = syn_uncategorized(); | ||
160 | + } | ||
161 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syndrome, | ||
162 | + default_exception_el(s)); | ||
163 | +} | ||
164 | + | ||
165 | /* MRS - move from system register | ||
166 | * MSR (register) - move to system register | ||
167 | * SYS | ||
168 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
169 | qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch64 " | ||
170 | "system register op0:%d op1:%d crn:%d crm:%d op2:%d\n", | ||
171 | isread ? "read" : "write", op0, op1, crn, crm, op2); | ||
172 | - unallocated_encoding(s); | ||
173 | + gen_sysreg_undef(s, isread, op0, op1, op2, crn, crm, rt); | ||
174 | return; | ||
49 | } | 175 | } |
50 | 176 | ||
51 | aarch64_add_sve_properties(obj); | 177 | /* Check access permissions */ |
178 | if (!cp_access_ok(s->current_el, ri, isread)) { | ||
179 | - unallocated_encoding(s); | ||
180 | + gen_sysreg_undef(s, isread, op0, op1, op2, crn, crm, rt); | ||
181 | return; | ||
182 | } | ||
183 | |||
52 | -- | 184 | -- |
53 | 2.20.1 | 185 | 2.25.1 |
54 | |||
55 | diff view generated by jsdifflib |
1 | When Hexagon was added we forgot to add it to the QEMU_ARCH_* | 1 | The unsupported_encoding() macro logs a LOG_UNIMP message and then |
---|---|---|---|
2 | enumeration. This doesn't cause a visible effect because at the | 2 | generates code to raise the usual exception for an unallocated |
3 | moment Hexagon is linux-user only and the QEMU_ARCH_* constants are | 3 | encoding. Back when we were still implementing the A64 decoder this |
4 | only used in softmmu, but we might as well add it in, since it's the | 4 | was helpful for flagging up when guest code was using something we |
5 | only architecture currently missing from the list. | 5 | hadn't yet implemented. Now we completely cover the A64 instruction |
6 | set it is barely used. The only remaining uses are for five | ||
7 | instructions whose semantics are "UNDEF, unless being run under | ||
8 | external halting debug": | ||
9 | * HLT (when not being used for semihosting) | ||
10 | * DCPSR1, DCPS2, DCPS3 | ||
11 | * DRPS | ||
12 | |||
13 | QEMU doesn't implement external halting debug, so for us the UNDEF is | ||
14 | the architecturally correct behaviour (because it's not possible to | ||
15 | execute these instructions with halting debug enabled). The | ||
16 | LOG_UNIMP doesn't serve a useful purpose; replace these uses of | ||
17 | unsupported_encoding() with unallocated_encoding(), and delete the | ||
18 | macro. | ||
6 | 19 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 21 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | 23 | Message-id: 20220509160443.3561604-1-peter.maydell@linaro.org |
11 | Message-id: 20210730105947.28215-6-peter.maydell@linaro.org | ||
12 | --- | 24 | --- |
13 | include/sysemu/arch_init.h | 1 + | 25 | target/arm/translate-a64.h | 9 --------- |
14 | 1 file changed, 1 insertion(+) | 26 | target/arm/translate-a64.c | 8 ++++---- |
27 | 2 files changed, 4 insertions(+), 13 deletions(-) | ||
15 | 28 | ||
16 | diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h | 29 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h |
17 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/sysemu/arch_init.h | 31 | --- a/target/arm/translate-a64.h |
19 | +++ b/include/sysemu/arch_init.h | 32 | +++ b/target/arm/translate-a64.h |
20 | @@ -XXX,XX +XXX,XX @@ enum { | 33 | @@ -XXX,XX +XXX,XX @@ |
21 | QEMU_ARCH_RISCV = (1 << 19), | 34 | #ifndef TARGET_ARM_TRANSLATE_A64_H |
22 | QEMU_ARCH_RX = (1 << 20), | 35 | #define TARGET_ARM_TRANSLATE_A64_H |
23 | QEMU_ARCH_AVR = (1 << 21), | 36 | |
24 | + QEMU_ARCH_HEXAGON = (1 << 22), | 37 | -#define unsupported_encoding(s, insn) \ |
25 | 38 | - do { \ | |
26 | QEMU_ARCH_NONE = (1 << 31), | 39 | - qemu_log_mask(LOG_UNIMP, \ |
27 | }; | 40 | - "%s:%d: unsupported instruction encoding 0x%08x " \ |
41 | - "at pc=%016" PRIx64 "\n", \ | ||
42 | - __FILE__, __LINE__, insn, s->pc_curr); \ | ||
43 | - unallocated_encoding(s); \ | ||
44 | - } while (0) | ||
45 | - | ||
46 | TCGv_i64 new_tmp_a64(DisasContext *s); | ||
47 | TCGv_i64 new_tmp_a64_local(DisasContext *s); | ||
48 | TCGv_i64 new_tmp_a64_zero(DisasContext *s); | ||
49 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/translate-a64.c | ||
52 | +++ b/target/arm/translate-a64.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
54 | * with our 32-bit semihosting). | ||
55 | */ | ||
56 | if (s->current_el == 0) { | ||
57 | - unsupported_encoding(s, insn); | ||
58 | + unallocated_encoding(s); | ||
59 | break; | ||
60 | } | ||
61 | #endif | ||
62 | gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); | ||
63 | } else { | ||
64 | - unsupported_encoding(s, insn); | ||
65 | + unallocated_encoding(s); | ||
66 | } | ||
67 | break; | ||
68 | case 5: | ||
69 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
70 | break; | ||
71 | } | ||
72 | /* DCPS1, DCPS2, DCPS3 */ | ||
73 | - unsupported_encoding(s, insn); | ||
74 | + unallocated_encoding(s); | ||
75 | break; | ||
76 | default: | ||
77 | unallocated_encoding(s); | ||
78 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
79 | if (op3 != 0 || op4 != 0 || rn != 0x1f) { | ||
80 | goto do_unallocated; | ||
81 | } else { | ||
82 | - unsupported_encoding(s, insn); | ||
83 | + unallocated_encoding(s); | ||
84 | } | ||
85 | return; | ||
86 | |||
28 | -- | 87 | -- |
29 | 2.20.1 | 88 | 2.25.1 |
30 | 89 | ||
31 | 90 | diff view generated by jsdifflib |
1 | The QEMU_ARCH_VIRTIO_* defines are used only in one file, | 1 | We allow a GICv3 to be connected to any CPU, but we don't do anything |
---|---|---|---|
2 | qdev-monitor.c. Move them to that file. | 2 | to handle the case where the CPU type doesn't in hardware have a |
3 | GICv3 CPU interface and so the various GIC configuration fields | ||
4 | (gic_num_lrs, vprebits, vpribits) are not specified. | ||
5 | |||
6 | The current behaviour is that we will add the EL1 CPU interface | ||
7 | registers, but will not put in the EL2 CPU interface registers, even | ||
8 | if the CPU has EL2, which will leave the GIC in a broken state and | ||
9 | probably result in the guest crashing as it tries to set it up. This | ||
10 | only affects the virt board when using the cortex-a15 or cortex-a7 | ||
11 | CPU types (both 32-bit) with -machine gic-version=3 (or 'max') | ||
12 | and -machine virtualization=on. | ||
13 | |||
14 | Instead of failing to set up the EL2 registers, if the CPU doesn't | ||
15 | define the GIC configuration set it to a reasonable default, matching | ||
16 | the standard configuration for most Arm CPUs. | ||
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: Richard Henderson <richard.henderson@linaro.org> | 19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 20 | Message-id: 20220512151457.3899052-2-peter.maydell@linaro.org |
7 | Message-id: 20210730105947.28215-7-peter.maydell@linaro.org | ||
8 | --- | 21 | --- |
9 | include/sysemu/arch_init.h | 9 --------- | 22 | hw/intc/arm_gicv3_cpuif.c | 18 +++++++++++++----- |
10 | softmmu/qdev-monitor.c | 9 +++++++++ | 23 | 1 file changed, 13 insertions(+), 5 deletions(-) |
11 | 2 files changed, 9 insertions(+), 9 deletions(-) | ||
12 | 24 | ||
13 | diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h | 25 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
14 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/sysemu/arch_init.h | 27 | --- a/hw/intc/arm_gicv3_cpuif.c |
16 | +++ b/include/sysemu/arch_init.h | 28 | +++ b/hw/intc/arm_gicv3_cpuif.c |
17 | @@ -XXX,XX +XXX,XX @@ enum { | 29 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) |
18 | 30 | ARMCPU *cpu = ARM_CPU(qemu_get_cpu(i)); | |
19 | extern const uint32_t arch_type; | 31 | GICv3CPUState *cs = &s->cpu[i]; |
20 | 32 | ||
21 | -/* default virtio transport per architecture */ | 33 | + /* |
22 | -#define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \ | 34 | + * If the CPU doesn't define a GICv3 configuration, probably because |
23 | - QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \ | 35 | + * in real hardware it doesn't have one, then we use default values |
24 | - QEMU_ARCH_MIPS | QEMU_ARCH_PPC | \ | 36 | + * matching the one used by most Arm CPUs. This applies to: |
25 | - QEMU_ARCH_RISCV | QEMU_ARCH_SH4 | \ | 37 | + * cpu->gic_num_lrs |
26 | - QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA) | 38 | + * cpu->gic_vpribits |
27 | -#define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X) | 39 | + * cpu->gic_vprebits |
28 | -#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K) | 40 | + */ |
29 | - | ||
30 | #endif | ||
31 | diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/softmmu/qdev-monitor.c | ||
34 | +++ b/softmmu/qdev-monitor.c | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct QDevAlias | ||
36 | uint32_t arch_mask; | ||
37 | } QDevAlias; | ||
38 | |||
39 | +/* default virtio transport per architecture */ | ||
40 | +#define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \ | ||
41 | + QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \ | ||
42 | + QEMU_ARCH_MIPS | QEMU_ARCH_PPC | \ | ||
43 | + QEMU_ARCH_RISCV | QEMU_ARCH_SH4 | \ | ||
44 | + QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA) | ||
45 | +#define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X) | ||
46 | +#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K) | ||
47 | + | 41 | + |
48 | /* Please keep this table sorted by typename. */ | 42 | /* Note that we can't just use the GICv3CPUState as an opaque pointer |
49 | static const QDevAlias qdev_alias_table[] = { | 43 | * in define_arm_cp_regs_with_opaque(), because when we're called back |
50 | { "AC97", "ac97" }, /* -soundhw name */ | 44 | * it might be with code translated by CPU 0 but run by CPU 1, in |
45 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
46 | * get back to the GICv3CPUState from the CPUARMState. | ||
47 | */ | ||
48 | define_arm_cp_regs(cpu, gicv3_cpuif_reginfo); | ||
49 | - if (arm_feature(&cpu->env, ARM_FEATURE_EL2) | ||
50 | - && cpu->gic_num_lrs) { | ||
51 | + if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) { | ||
52 | int j; | ||
53 | |||
54 | - cs->num_list_regs = cpu->gic_num_lrs; | ||
55 | - cs->vpribits = cpu->gic_vpribits; | ||
56 | - cs->vprebits = cpu->gic_vprebits; | ||
57 | + cs->num_list_regs = cpu->gic_num_lrs ?: 4; | ||
58 | + cs->vpribits = cpu->gic_vpribits ?: 5; | ||
59 | + cs->vprebits = cpu->gic_vprebits ?: 5; | ||
60 | |||
61 | /* Check against architectural constraints: getting these | ||
62 | * wrong would be a bug in the CPU code defining these, | ||
51 | -- | 63 | -- |
52 | 2.20.1 | 64 | 2.25.1 |
53 | |||
54 | diff view generated by jsdifflib |
1 | Zero-initialize the sockaddr_in struct that we're about to fill in | 1 | As noted in the comment, the PRIbits field in ICV_CTLR_EL1 is |
---|---|---|---|
2 | and pass to bind(), to ensure we don't leave possible | 2 | supposed to match the ICH_VTR_EL2 PRIbits setting; that is, it is the |
3 | implementation-defined extension fields as uninitialized garbage. | 3 | virtual priority bit setting, not the physical priority bit setting. |
4 | (For QEMU currently we always implement 8 bits of physical priority, | ||
5 | so the PRIbits field was previously 7, since it is defined to be | ||
6 | "priority bits - 1".) | ||
4 | 7 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Corey Minyard <cminyard@mvista.com> | 10 | Message-id: 20220512151457.3899052-3-peter.maydell@linaro.org |
8 | Acked-by: Thomas Huth <thuth@redhat.com> | 11 | Message-id: 20220506162129.2896966-2-peter.maydell@linaro.org |
9 | Message-id: 20210813150506.7768-4-peter.maydell@linaro.org | ||
10 | --- | 12 | --- |
11 | tests/qtest/ipmi-bt-test.c | 2 +- | 13 | hw/intc/arm_gicv3_cpuif.c | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 15 | ||
14 | diff --git a/tests/qtest/ipmi-bt-test.c b/tests/qtest/ipmi-bt-test.c | 16 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tests/qtest/ipmi-bt-test.c | 18 | --- a/hw/intc/arm_gicv3_cpuif.c |
17 | +++ b/tests/qtest/ipmi-bt-test.c | 19 | +++ b/hw/intc/arm_gicv3_cpuif.c |
18 | @@ -XXX,XX +XXX,XX @@ static void test_enable_irq(void) | 20 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
19 | */ | 21 | * should match the ones reported in ich_vtr_read(). |
20 | static void open_socket(void) | 22 | */ |
21 | { | 23 | value = ICC_CTLR_EL1_A3V | (1 << ICC_CTLR_EL1_IDBITS_SHIFT) | |
22 | - struct sockaddr_in myaddr; | 24 | - (7 << ICC_CTLR_EL1_PRIBITS_SHIFT); |
23 | + struct sockaddr_in myaddr = {}; | 25 | + ((cs->vpribits - 1) << ICC_CTLR_EL1_PRIBITS_SHIFT); |
24 | socklen_t addrlen; | 26 | |
25 | 27 | if (cs->ich_vmcr_el2 & ICH_VMCR_EL2_VEOIM) { | |
26 | myaddr.sin_family = AF_INET; | 28 | value |= ICC_CTLR_EL1_EOIMODE; |
27 | -- | 29 | -- |
28 | 2.20.1 | 30 | 2.25.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | The kvm_available() function reports whether KVM support was | 1 | The GIC_MIN_BPR constant defines the minimum BPR value that the TCG |
---|---|---|---|
2 | compiled into the QEMU binary; it returns the value of the | 2 | emulated GICv3 supports. We're currently using this also as the |
3 | CONFIG_KVM define. | 3 | value we reset the KVM GICv3 ICC_BPR registers to, but this is only |
4 | right by accident. | ||
4 | 5 | ||
5 | The only place in the codebase where we use this function is | 6 | We want to make the emulated GICv3 use a configurable number of |
6 | in qmp_query_kvm(). Now that accelerators are based on QOM | 7 | priority bits, which means that GIC_MIN_BPR will no longer be a |
7 | classes we can instead use accel_find("kvm") and remove the | 8 | constant. Replace the uses in the KVM reset code with literal 0, |
8 | kvm_available() function. | 9 | plus a constant explaining why this is reasonable. |
9 | 10 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20210730105947.28215-3-peter.maydell@linaro.org | 13 | Message-id: 20220512151457.3899052-4-peter.maydell@linaro.org |
14 | Message-id: 20220506162129.2896966-3-peter.maydell@linaro.org | ||
13 | --- | 15 | --- |
14 | include/sysemu/arch_init.h | 2 -- | 16 | hw/intc/arm_gicv3_kvm.c | 16 +++++++++++++--- |
15 | monitor/qmp-cmds.c | 2 +- | 17 | 1 file changed, 13 insertions(+), 3 deletions(-) |
16 | softmmu/arch_init.c | 9 --------- | ||
17 | 3 files changed, 1 insertion(+), 12 deletions(-) | ||
18 | 18 | ||
19 | diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h | 19 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c |
20 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/sysemu/arch_init.h | 21 | --- a/hw/intc/arm_gicv3_kvm.c |
22 | +++ b/include/sysemu/arch_init.h | 22 | +++ b/hw/intc/arm_gicv3_kvm.c |
23 | @@ -XXX,XX +XXX,XX @@ enum { | 23 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) |
24 | 24 | s = c->gic; | |
25 | extern const uint32_t arch_type; | 25 | |
26 | 26 | c->icc_pmr_el1 = 0; | |
27 | -int kvm_available(void); | 27 | - c->icc_bpr[GICV3_G0] = GIC_MIN_BPR; |
28 | - | 28 | - c->icc_bpr[GICV3_G1] = GIC_MIN_BPR; |
29 | /* default virtio transport per architecture */ | 29 | - c->icc_bpr[GICV3_G1NS] = GIC_MIN_BPR; |
30 | #define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \ | 30 | + /* |
31 | QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \ | 31 | + * Architecturally the reset value of the ICC_BPR registers |
32 | diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c | 32 | + * is UNKNOWN. We set them all to 0 here; when the kernel |
33 | index XXXXXXX..XXXXXXX 100644 | 33 | + * uses these values to program the ICH_VMCR_EL2 fields that |
34 | --- a/monitor/qmp-cmds.c | 34 | + * determine the guest-visible ICC_BPR register values, the |
35 | +++ b/monitor/qmp-cmds.c | 35 | + * hardware's "writing a value less than the minimum sets |
36 | @@ -XXX,XX +XXX,XX @@ KvmInfo *qmp_query_kvm(Error **errp) | 36 | + * the field to the minimum value" behaviour will result in |
37 | KvmInfo *info = g_malloc0(sizeof(*info)); | 37 | + * them effectively resetting to the correct minimum value |
38 | 38 | + * for the host GIC. | |
39 | info->enabled = kvm_enabled(); | 39 | + */ |
40 | - info->present = kvm_available(); | 40 | + c->icc_bpr[GICV3_G0] = 0; |
41 | + info->present = accel_find("kvm"); | 41 | + c->icc_bpr[GICV3_G1] = 0; |
42 | 42 | + c->icc_bpr[GICV3_G1NS] = 0; | |
43 | return info; | 43 | |
44 | } | 44 | c->icc_sre_el1 = 0x7; |
45 | diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c | 45 | memset(c->icc_apr, 0, sizeof(c->icc_apr)); |
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/softmmu/arch_init.c | ||
48 | +++ b/softmmu/arch_init.c | ||
49 | @@ -XXX,XX +XXX,XX @@ int graphic_depth = 32; | ||
50 | #endif | ||
51 | |||
52 | const uint32_t arch_type = QEMU_ARCH; | ||
53 | - | ||
54 | -int kvm_available(void) | ||
55 | -{ | ||
56 | -#ifdef CONFIG_KVM | ||
57 | - return 1; | ||
58 | -#else | ||
59 | - return 0; | ||
60 | -#endif | ||
61 | -} | ||
62 | -- | 46 | -- |
63 | 2.20.1 | 47 | 2.25.1 |
64 | |||
65 | diff view generated by jsdifflib |
1 | Zero-initialize sockaddr_in and sockaddr_un structs that we're about | 1 | The GICv3 code has always supported a configurable number of virtual |
---|---|---|---|
2 | to fill in and pass to bind() or connect(), to ensure we don't leave | 2 | priority and preemption bits, but our implementation currently |
3 | possible implementation-defined extension fields as uninitialized | 3 | hardcodes the number of physical priority bits at 8. This is not |
4 | garbage. | 4 | what most hardware implementations provide; for instance the |
5 | Cortex-A53 provides only 5 bits of physical priority. | ||
6 | |||
7 | Make the number of physical priority/preemption bits driven by fields | ||
8 | in the GICv3CPUState, the way that we already do for virtual | ||
9 | priority/preemption bits. We set cs->pribits to 8, so there is no | ||
10 | behavioural change in this commit. A following commit will add the | ||
11 | machinery for CPUs to set this to the correct value for their | ||
12 | implementation. | ||
13 | |||
14 | Note that changing the number of priority bits would be a migration | ||
15 | compatibility break, because the semantics of the icc_apr[][] array | ||
16 | changes. | ||
5 | 17 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | 19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210813150506.7768-3-peter.maydell@linaro.org | 20 | Message-id: 20220512151457.3899052-5-peter.maydell@linaro.org |
21 | Message-id: 20220506162129.2896966-4-peter.maydell@linaro.org | ||
9 | --- | 22 | --- |
10 | gdbstub.c | 4 ++-- | 23 | include/hw/intc/arm_gicv3_common.h | 7 +- |
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | 24 | hw/intc/arm_gicv3_cpuif.c | 182 ++++++++++++++++++++--------- |
25 | 2 files changed, 130 insertions(+), 59 deletions(-) | ||
12 | 26 | ||
13 | diff --git a/gdbstub.c b/gdbstub.c | 27 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h |
14 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/gdbstub.c | 29 | --- a/include/hw/intc/arm_gicv3_common.h |
16 | +++ b/gdbstub.c | 30 | +++ b/include/hw/intc/arm_gicv3_common.h |
17 | @@ -XXX,XX +XXX,XX @@ static bool gdb_accept_socket(int gdb_fd) | 31 | @@ -XXX,XX +XXX,XX @@ |
18 | 32 | /* Maximum number of list registers (architectural limit) */ | |
19 | static int gdbserver_open_socket(const char *path) | 33 | #define GICV3_LR_MAX 16 |
34 | |||
35 | -/* Minimum BPR for Secure, or when security not enabled */ | ||
36 | -#define GIC_MIN_BPR 0 | ||
37 | -/* Minimum BPR for Nonsecure when security is enabled */ | ||
38 | -#define GIC_MIN_BPR_NS (GIC_MIN_BPR + 1) | ||
39 | - | ||
40 | /* For some distributor fields we want to model the array of 32-bit | ||
41 | * register values which hold various bitmaps corresponding to enabled, | ||
42 | * pending, etc bits. These macros and functions facilitate that; the | ||
43 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | ||
44 | int num_list_regs; | ||
45 | int vpribits; /* number of virtual priority bits */ | ||
46 | int vprebits; /* number of virtual preemption bits */ | ||
47 | + int pribits; /* number of physical priority bits */ | ||
48 | + int prebits; /* number of physical preemption bits */ | ||
49 | |||
50 | /* Current highest priority pending interrupt for this CPU. | ||
51 | * This is cached information that can be recalculated from the | ||
52 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
55 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
57 | return intid; | ||
58 | } | ||
59 | |||
60 | +static uint32_t icc_fullprio_mask(GICv3CPUState *cs) | ||
61 | +{ | ||
62 | + /* | ||
63 | + * Return a mask word which clears the unimplemented priority bits | ||
64 | + * from a priority value for a physical interrupt. (Not to be confused | ||
65 | + * with the group priority, whose mask depends on the value of BPR | ||
66 | + * for the interrupt group.) | ||
67 | + */ | ||
68 | + return ~0U << (8 - cs->pribits); | ||
69 | +} | ||
70 | + | ||
71 | +static inline int icc_min_bpr(GICv3CPUState *cs) | ||
72 | +{ | ||
73 | + /* The minimum BPR for the physical interface. */ | ||
74 | + return 7 - cs->prebits; | ||
75 | +} | ||
76 | + | ||
77 | +static inline int icc_min_bpr_ns(GICv3CPUState *cs) | ||
78 | +{ | ||
79 | + return icc_min_bpr(cs) + 1; | ||
80 | +} | ||
81 | + | ||
82 | +static inline int icc_num_aprs(GICv3CPUState *cs) | ||
83 | +{ | ||
84 | + /* Return the number of APR registers (1, 2, or 4) */ | ||
85 | + int aprmax = 1 << MAX(cs->prebits - 5, 0); | ||
86 | + assert(aprmax <= ARRAY_SIZE(cs->icc_apr[0])); | ||
87 | + return aprmax; | ||
88 | +} | ||
89 | + | ||
90 | static int icc_highest_active_prio(GICv3CPUState *cs) | ||
20 | { | 91 | { |
21 | - struct sockaddr_un sockaddr; | 92 | /* Calculate the current running priority based on the set bits |
22 | + struct sockaddr_un sockaddr = {}; | 93 | @@ -XXX,XX +XXX,XX @@ static int icc_highest_active_prio(GICv3CPUState *cs) |
23 | int fd, ret; | 94 | */ |
24 | 95 | int i; | |
25 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 96 | |
26 | @@ -XXX,XX +XXX,XX @@ static int gdbserver_open_socket(const char *path) | 97 | - for (i = 0; i < ARRAY_SIZE(cs->icc_apr[0]); i++) { |
27 | 98 | + for (i = 0; i < icc_num_aprs(cs); i++) { | |
28 | static bool gdb_accept_tcp(int gdb_fd) | 99 | uint32_t apr = cs->icc_apr[GICV3_G0][i] | |
100 | cs->icc_apr[GICV3_G1][i] | cs->icc_apr[GICV3_G1NS][i]; | ||
101 | |||
102 | if (!apr) { | ||
103 | continue; | ||
104 | } | ||
105 | - return (i * 32 + ctz32(apr)) << (GIC_MIN_BPR + 1); | ||
106 | + return (i * 32 + ctz32(apr)) << (icc_min_bpr(cs) + 1); | ||
107 | } | ||
108 | /* No current active interrupts: return idle priority */ | ||
109 | return 0xff; | ||
110 | @@ -XXX,XX +XXX,XX @@ static void icc_pmr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
111 | |||
112 | trace_gicv3_icc_pmr_write(gicv3_redist_affid(cs), value); | ||
113 | |||
114 | - value &= 0xff; | ||
115 | + value &= icc_fullprio_mask(cs); | ||
116 | |||
117 | if (arm_feature(env, ARM_FEATURE_EL3) && !arm_is_secure(env) && | ||
118 | (env->cp15.scr_el3 & SCR_FIQ)) { | ||
119 | @@ -XXX,XX +XXX,XX @@ static void icc_activate_irq(GICv3CPUState *cs, int irq) | ||
120 | */ | ||
121 | uint32_t mask = icc_gprio_mask(cs, cs->hppi.grp); | ||
122 | int prio = cs->hppi.prio & mask; | ||
123 | - int aprbit = prio >> 1; | ||
124 | + int aprbit = prio >> (8 - cs->prebits); | ||
125 | int regno = aprbit / 32; | ||
126 | int regbit = aprbit % 32; | ||
127 | |||
128 | @@ -XXX,XX +XXX,XX @@ static void icc_drop_prio(GICv3CPUState *cs, int grp) | ||
129 | */ | ||
130 | int i; | ||
131 | |||
132 | - for (i = 0; i < ARRAY_SIZE(cs->icc_apr[grp]); i++) { | ||
133 | + for (i = 0; i < icc_num_aprs(cs); i++) { | ||
134 | uint64_t *papr = &cs->icc_apr[grp][i]; | ||
135 | |||
136 | if (!*papr) { | ||
137 | @@ -XXX,XX +XXX,XX @@ static void icc_bpr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | - minval = (grp == GICV3_G1NS) ? GIC_MIN_BPR_NS : GIC_MIN_BPR; | ||
142 | + minval = (grp == GICV3_G1NS) ? icc_min_bpr_ns(cs) : icc_min_bpr(cs); | ||
143 | if (value < minval) { | ||
144 | value = minval; | ||
145 | } | ||
146 | @@ -XXX,XX +XXX,XX @@ static void icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) | ||
147 | |||
148 | cs->icc_ctlr_el1[GICV3_S] = ICC_CTLR_EL1_A3V | | ||
149 | (1 << ICC_CTLR_EL1_IDBITS_SHIFT) | | ||
150 | - (7 << ICC_CTLR_EL1_PRIBITS_SHIFT); | ||
151 | + ((cs->pribits - 1) << ICC_CTLR_EL1_PRIBITS_SHIFT); | ||
152 | cs->icc_ctlr_el1[GICV3_NS] = ICC_CTLR_EL1_A3V | | ||
153 | (1 << ICC_CTLR_EL1_IDBITS_SHIFT) | | ||
154 | - (7 << ICC_CTLR_EL1_PRIBITS_SHIFT); | ||
155 | + ((cs->pribits - 1) << ICC_CTLR_EL1_PRIBITS_SHIFT); | ||
156 | cs->icc_pmr_el1 = 0; | ||
157 | - cs->icc_bpr[GICV3_G0] = GIC_MIN_BPR; | ||
158 | - cs->icc_bpr[GICV3_G1] = GIC_MIN_BPR; | ||
159 | - cs->icc_bpr[GICV3_G1NS] = GIC_MIN_BPR_NS; | ||
160 | + cs->icc_bpr[GICV3_G0] = icc_min_bpr(cs); | ||
161 | + cs->icc_bpr[GICV3_G1] = icc_min_bpr(cs); | ||
162 | + cs->icc_bpr[GICV3_G1NS] = icc_min_bpr_ns(cs); | ||
163 | memset(cs->icc_apr, 0, sizeof(cs->icc_apr)); | ||
164 | memset(cs->icc_igrpen, 0, sizeof(cs->icc_igrpen)); | ||
165 | cs->icc_ctlr_el3 = ICC_CTLR_EL3_NDS | ICC_CTLR_EL3_A3V | | ||
166 | (1 << ICC_CTLR_EL3_IDBITS_SHIFT) | | ||
167 | - (7 << ICC_CTLR_EL3_PRIBITS_SHIFT); | ||
168 | + ((cs->pribits - 1) << ICC_CTLR_EL3_PRIBITS_SHIFT); | ||
169 | |||
170 | memset(cs->ich_apr, 0, sizeof(cs->ich_apr)); | ||
171 | cs->ich_hcr_el2 = 0; | ||
172 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
173 | .readfn = icc_ap_read, | ||
174 | .writefn = icc_ap_write, | ||
175 | }, | ||
176 | - { .name = "ICC_AP0R1_EL1", .state = ARM_CP_STATE_BOTH, | ||
177 | - .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 8, .opc2 = 5, | ||
178 | - .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
179 | - .access = PL1_RW, .accessfn = gicv3_fiq_access, | ||
180 | - .readfn = icc_ap_read, | ||
181 | - .writefn = icc_ap_write, | ||
182 | - }, | ||
183 | - { .name = "ICC_AP0R2_EL1", .state = ARM_CP_STATE_BOTH, | ||
184 | - .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 8, .opc2 = 6, | ||
185 | - .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
186 | - .access = PL1_RW, .accessfn = gicv3_fiq_access, | ||
187 | - .readfn = icc_ap_read, | ||
188 | - .writefn = icc_ap_write, | ||
189 | - }, | ||
190 | - { .name = "ICC_AP0R3_EL1", .state = ARM_CP_STATE_BOTH, | ||
191 | - .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 8, .opc2 = 7, | ||
192 | - .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
193 | - .access = PL1_RW, .accessfn = gicv3_fiq_access, | ||
194 | - .readfn = icc_ap_read, | ||
195 | - .writefn = icc_ap_write, | ||
196 | - }, | ||
197 | /* All the ICC_AP1R*_EL1 registers are banked */ | ||
198 | { .name = "ICC_AP1R0_EL1", .state = ARM_CP_STATE_BOTH, | ||
199 | .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 0, | ||
200 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
201 | .readfn = icc_ap_read, | ||
202 | .writefn = icc_ap_write, | ||
203 | }, | ||
204 | - { .name = "ICC_AP1R1_EL1", .state = ARM_CP_STATE_BOTH, | ||
205 | - .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 1, | ||
206 | - .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
207 | - .access = PL1_RW, .accessfn = gicv3_irq_access, | ||
208 | - .readfn = icc_ap_read, | ||
209 | - .writefn = icc_ap_write, | ||
210 | - }, | ||
211 | - { .name = "ICC_AP1R2_EL1", .state = ARM_CP_STATE_BOTH, | ||
212 | - .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 2, | ||
213 | - .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
214 | - .access = PL1_RW, .accessfn = gicv3_irq_access, | ||
215 | - .readfn = icc_ap_read, | ||
216 | - .writefn = icc_ap_write, | ||
217 | - }, | ||
218 | - { .name = "ICC_AP1R3_EL1", .state = ARM_CP_STATE_BOTH, | ||
219 | - .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 3, | ||
220 | - .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
221 | - .access = PL1_RW, .accessfn = gicv3_irq_access, | ||
222 | - .readfn = icc_ap_read, | ||
223 | - .writefn = icc_ap_write, | ||
224 | - }, | ||
225 | { .name = "ICC_DIR_EL1", .state = ARM_CP_STATE_BOTH, | ||
226 | .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 11, .opc2 = 1, | ||
227 | .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
228 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
229 | }, | ||
230 | }; | ||
231 | |||
232 | +static const ARMCPRegInfo gicv3_cpuif_icc_apxr1_reginfo[] = { | ||
233 | + { .name = "ICC_AP0R1_EL1", .state = ARM_CP_STATE_BOTH, | ||
234 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 8, .opc2 = 5, | ||
235 | + .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
236 | + .access = PL1_RW, .accessfn = gicv3_fiq_access, | ||
237 | + .readfn = icc_ap_read, | ||
238 | + .writefn = icc_ap_write, | ||
239 | + }, | ||
240 | + { .name = "ICC_AP1R1_EL1", .state = ARM_CP_STATE_BOTH, | ||
241 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 1, | ||
242 | + .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
243 | + .access = PL1_RW, .accessfn = gicv3_irq_access, | ||
244 | + .readfn = icc_ap_read, | ||
245 | + .writefn = icc_ap_write, | ||
246 | + }, | ||
247 | +}; | ||
248 | + | ||
249 | +static const ARMCPRegInfo gicv3_cpuif_icc_apxr23_reginfo[] = { | ||
250 | + { .name = "ICC_AP0R2_EL1", .state = ARM_CP_STATE_BOTH, | ||
251 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 8, .opc2 = 6, | ||
252 | + .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
253 | + .access = PL1_RW, .accessfn = gicv3_fiq_access, | ||
254 | + .readfn = icc_ap_read, | ||
255 | + .writefn = icc_ap_write, | ||
256 | + }, | ||
257 | + { .name = "ICC_AP0R3_EL1", .state = ARM_CP_STATE_BOTH, | ||
258 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 8, .opc2 = 7, | ||
259 | + .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
260 | + .access = PL1_RW, .accessfn = gicv3_fiq_access, | ||
261 | + .readfn = icc_ap_read, | ||
262 | + .writefn = icc_ap_write, | ||
263 | + }, | ||
264 | + { .name = "ICC_AP1R2_EL1", .state = ARM_CP_STATE_BOTH, | ||
265 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 2, | ||
266 | + .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
267 | + .access = PL1_RW, .accessfn = gicv3_irq_access, | ||
268 | + .readfn = icc_ap_read, | ||
269 | + .writefn = icc_ap_write, | ||
270 | + }, | ||
271 | + { .name = "ICC_AP1R3_EL1", .state = ARM_CP_STATE_BOTH, | ||
272 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 3, | ||
273 | + .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
274 | + .access = PL1_RW, .accessfn = gicv3_irq_access, | ||
275 | + .readfn = icc_ap_read, | ||
276 | + .writefn = icc_ap_write, | ||
277 | + }, | ||
278 | +}; | ||
279 | + | ||
280 | static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
29 | { | 281 | { |
30 | - struct sockaddr_in sockaddr; | 282 | GICv3CPUState *cs = icc_cs_from_env(env); |
31 | + struct sockaddr_in sockaddr = {}; | 283 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) |
32 | socklen_t len; | 284 | * get back to the GICv3CPUState from the CPUARMState. |
33 | int fd; | 285 | */ |
286 | define_arm_cp_regs(cpu, gicv3_cpuif_reginfo); | ||
287 | + | ||
288 | + /* | ||
289 | + * For the moment, retain the existing behaviour of 8 priority bits; | ||
290 | + * in a following commit we will take this from the CPU state, | ||
291 | + * as we do for the virtual priority bits. | ||
292 | + */ | ||
293 | + cs->pribits = 8; | ||
294 | + /* | ||
295 | + * The GICv3 has separate ID register fields for virtual priority | ||
296 | + * and preemption bit values, but only a single ID register field | ||
297 | + * for the physical priority bits. The preemption bit count is | ||
298 | + * always the same as the priority bit count, except that 8 bits | ||
299 | + * of priority means 7 preemption bits. We precalculate the | ||
300 | + * preemption bits because it simplifies the code and makes the | ||
301 | + * parallels between the virtual and physical bits of the GIC | ||
302 | + * a bit clearer. | ||
303 | + */ | ||
304 | + cs->prebits = cs->pribits; | ||
305 | + if (cs->prebits == 8) { | ||
306 | + cs->prebits--; | ||
307 | + } | ||
308 | + /* | ||
309 | + * Check that CPU code defining pribits didn't violate | ||
310 | + * architectural constraints our implementation relies on. | ||
311 | + */ | ||
312 | + g_assert(cs->pribits >= 4 && cs->pribits <= 8); | ||
313 | + | ||
314 | + /* | ||
315 | + * gicv3_cpuif_reginfo[] defines ICC_AP*R0_EL1; add definitions | ||
316 | + * for ICC_AP*R{1,2,3}_EL1 if the prebits value requires them. | ||
317 | + */ | ||
318 | + if (cs->prebits >= 6) { | ||
319 | + define_arm_cp_regs(cpu, gicv3_cpuif_icc_apxr1_reginfo); | ||
320 | + } | ||
321 | + if (cs->prebits == 7) { | ||
322 | + define_arm_cp_regs(cpu, gicv3_cpuif_icc_apxr23_reginfo); | ||
323 | + } | ||
324 | + | ||
325 | if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) { | ||
326 | int j; | ||
34 | 327 | ||
35 | -- | 328 | -- |
36 | 2.20.1 | 329 | 2.25.1 |
37 | |||
38 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Make the GICv3 set its number of bits of physical priority from the |
---|---|---|---|
2 | implementation-specific value provided in the CPU state struct, in | ||
3 | the same way we already do for virtual priority bits. Because this | ||
4 | would be a migration compatibility break, we provide a property | ||
5 | force-8-bit-prio which is enabled for 7.0 and earlier versioned board | ||
6 | models to retain the legacy "always use 8 bits" behaviour. | ||
2 | 7 | ||
3 | Now that we have an ARMCPU member sve_vq_supported we no longer | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | need the local kvm_supported bitmap for KVM's supported vector | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | lengths. | 10 | Message-id: 20220512151457.3899052-6-peter.maydell@linaro.org |
11 | Message-id: 20220506162129.2896966-5-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/intc/arm_gicv3_common.h | 1 + | ||
14 | target/arm/cpu.h | 1 + | ||
15 | hw/core/machine.c | 4 +++- | ||
16 | hw/intc/arm_gicv3_common.c | 5 +++++ | ||
17 | hw/intc/arm_gicv3_cpuif.c | 15 +++++++++++---- | ||
18 | target/arm/cpu64.c | 6 ++++++ | ||
19 | 6 files changed, 27 insertions(+), 5 deletions(-) | ||
6 | 20 | ||
7 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 21 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 22 | index XXXXXXX..XXXXXXX 100644 |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 23 | --- a/include/hw/intc/arm_gicv3_common.h |
10 | Message-id: 20210823160647.34028-4-drjones@redhat.com | 24 | +++ b/include/hw/intc/arm_gicv3_common.h |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | @@ -XXX,XX +XXX,XX @@ struct GICv3State { |
12 | --- | 26 | uint32_t revision; |
13 | target/arm/cpu64.c | 19 +++++++++++-------- | 27 | bool lpi_enable; |
14 | 1 file changed, 11 insertions(+), 8 deletions(-) | 28 | bool security_extn; |
15 | 29 | + bool force_8bit_prio; | |
30 | bool irq_reset_nonsecure; | ||
31 | bool gicd_no_migration_shift_bug; | ||
32 | |||
33 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/cpu.h | ||
36 | +++ b/target/arm/cpu.h | ||
37 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
38 | int gic_num_lrs; /* number of list registers */ | ||
39 | int gic_vpribits; /* number of virtual priority bits */ | ||
40 | int gic_vprebits; /* number of virtual preemption bits */ | ||
41 | + int gic_pribits; /* number of physical priority bits */ | ||
42 | |||
43 | /* Whether the cfgend input is high (i.e. this CPU should reset into | ||
44 | * big-endian mode). This setting isn't used directly: instead it modifies | ||
45 | diff --git a/hw/core/machine.c b/hw/core/machine.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/core/machine.c | ||
48 | +++ b/hw/core/machine.c | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | #include "hw/virtio/virtio-pci.h" | ||
51 | #include "qom/object_interfaces.h" | ||
52 | |||
53 | -GlobalProperty hw_compat_7_0[] = {}; | ||
54 | +GlobalProperty hw_compat_7_0[] = { | ||
55 | + { "arm-gicv3-common", "force-8-bit-prio", "on" }, | ||
56 | +}; | ||
57 | const size_t hw_compat_7_0_len = G_N_ELEMENTS(hw_compat_7_0); | ||
58 | |||
59 | GlobalProperty hw_compat_6_2[] = { | ||
60 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/intc/arm_gicv3_common.c | ||
63 | +++ b/hw/intc/arm_gicv3_common.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static Property arm_gicv3_common_properties[] = { | ||
65 | DEFINE_PROP_UINT32("revision", GICv3State, revision, 3), | ||
66 | DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0), | ||
67 | DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0), | ||
68 | + /* | ||
69 | + * Compatibility property: force 8 bits of physical priority, even | ||
70 | + * if the CPU being emulated should have fewer. | ||
71 | + */ | ||
72 | + DEFINE_PROP_BOOL("force-8-bit-prio", GICv3State, force_8bit_prio, 0), | ||
73 | DEFINE_PROP_ARRAY("redist-region-count", GICv3State, nb_redist_regions, | ||
74 | redist_region_count, qdev_prop_uint32, uint32_t), | ||
75 | DEFINE_PROP_LINK("sysmem", GICv3State, dma, TYPE_MEMORY_REGION, | ||
76 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
79 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
80 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
81 | * cpu->gic_num_lrs | ||
82 | * cpu->gic_vpribits | ||
83 | * cpu->gic_vprebits | ||
84 | + * cpu->gic_pribits | ||
85 | */ | ||
86 | |||
87 | /* Note that we can't just use the GICv3CPUState as an opaque pointer | ||
88 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
89 | define_arm_cp_regs(cpu, gicv3_cpuif_reginfo); | ||
90 | |||
91 | /* | ||
92 | - * For the moment, retain the existing behaviour of 8 priority bits; | ||
93 | - * in a following commit we will take this from the CPU state, | ||
94 | - * as we do for the virtual priority bits. | ||
95 | + * The CPU implementation specifies the number of supported | ||
96 | + * bits of physical priority. For backwards compatibility | ||
97 | + * of migration, we have a compat property that forces use | ||
98 | + * of 8 priority bits regardless of what the CPU really has. | ||
99 | */ | ||
100 | - cs->pribits = 8; | ||
101 | + if (s->force_8bit_prio) { | ||
102 | + cs->pribits = 8; | ||
103 | + } else { | ||
104 | + cs->pribits = cpu->gic_pribits ?: 5; | ||
105 | + } | ||
106 | + | ||
107 | /* | ||
108 | * The GICv3 has separate ID register fields for virtual priority | ||
109 | * and preemption bit values, but only a single ID register field | ||
16 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 110 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 111 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu64.c | 112 | --- a/target/arm/cpu64.c |
19 | +++ b/target/arm/cpu64.c | 113 | +++ b/target/arm/cpu64.c |
20 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | 114 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) |
21 | * any of the above. Finally, if SVE is not disabled, then at least one | 115 | cpu->gic_num_lrs = 4; |
22 | * vector length must be enabled. | 116 | cpu->gic_vpribits = 5; |
23 | */ | 117 | cpu->gic_vprebits = 5; |
24 | - DECLARE_BITMAP(kvm_supported, ARM_MAX_VQ); | 118 | + cpu->gic_pribits = 5; |
25 | DECLARE_BITMAP(tmp, ARM_MAX_VQ); | 119 | define_cortex_a72_a57_a53_cp_reginfo(cpu); |
26 | uint32_t vq, max_vq = 0; | 120 | } |
27 | 121 | ||
28 | - /* Collect the set of vector lengths supported by KVM. */ | 122 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) |
29 | - bitmap_zero(kvm_supported, ARM_MAX_VQ); | 123 | cpu->gic_num_lrs = 4; |
30 | + /* | 124 | cpu->gic_vpribits = 5; |
31 | + * CPU models specify a set of supported vector lengths which are | 125 | cpu->gic_vprebits = 5; |
32 | + * enabled by default. Attempting to enable any vector length not set | 126 | + cpu->gic_pribits = 5; |
33 | + * in the supported bitmap results in an error. When KVM is enabled we | 127 | define_cortex_a72_a57_a53_cp_reginfo(cpu); |
34 | + * fetch the supported bitmap from the host. | 128 | } |
35 | + */ | 129 | |
36 | if (kvm_enabled() && kvm_arm_sve_supported()) { | 130 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) |
37 | - kvm_arm_sve_get_vls(CPU(cpu), kvm_supported); | 131 | cpu->gic_num_lrs = 4; |
38 | + kvm_arm_sve_get_vls(CPU(cpu), cpu->sve_vq_supported); | 132 | cpu->gic_vpribits = 5; |
39 | } else if (kvm_enabled()) { | 133 | cpu->gic_vprebits = 5; |
40 | assert(!cpu_isar_feature(aa64_sve, cpu)); | 134 | + cpu->gic_pribits = 5; |
41 | } | 135 | define_cortex_a72_a57_a53_cp_reginfo(cpu); |
42 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | 136 | } |
43 | * For KVM we have to automatically enable all supported unitialized | 137 | |
44 | * lengths, even when the smaller lengths are not all powers-of-two. | 138 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a76_initfn(Object *obj) |
45 | */ | 139 | cpu->gic_num_lrs = 4; |
46 | - bitmap_andnot(tmp, kvm_supported, cpu->sve_vq_init, max_vq); | 140 | cpu->gic_vpribits = 5; |
47 | + bitmap_andnot(tmp, cpu->sve_vq_supported, cpu->sve_vq_init, max_vq); | 141 | cpu->gic_vprebits = 5; |
48 | bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); | 142 | + cpu->gic_pribits = 5; |
49 | } else { | 143 | |
50 | /* Propagate enabled bits down through required powers-of-two. */ | 144 | /* From B5.1 AdvSIMD AArch64 register summary */ |
51 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | 145 | cpu->isar.mvfr0 = 0x10110222; |
52 | /* Disabling a supported length disables all larger lengths. */ | 146 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n1_initfn(Object *obj) |
53 | for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | 147 | cpu->gic_num_lrs = 4; |
54 | if (test_bit(vq - 1, cpu->sve_vq_init) && | 148 | cpu->gic_vpribits = 5; |
55 | - test_bit(vq - 1, kvm_supported)) { | 149 | cpu->gic_vprebits = 5; |
56 | + test_bit(vq - 1, cpu->sve_vq_supported)) { | 150 | + cpu->gic_pribits = 5; |
57 | break; | 151 | |
58 | } | 152 | /* From B5.1 AdvSIMD AArch64 register summary */ |
59 | } | 153 | cpu->isar.mvfr0 = 0x10110222; |
60 | max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | 154 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) |
61 | - bitmap_andnot(cpu->sve_vq_map, kvm_supported, | 155 | cpu->gic_num_lrs = 4; |
62 | + bitmap_andnot(cpu->sve_vq_map, cpu->sve_vq_supported, | 156 | cpu->gic_vpribits = 5; |
63 | cpu->sve_vq_init, max_vq); | 157 | cpu->gic_vprebits = 5; |
64 | if (max_vq == 0 || bitmap_empty(cpu->sve_vq_map, max_vq)) { | 158 | + cpu->gic_pribits = 5; |
65 | error_setg(errp, "cannot disable sve%d", vq * 128); | 159 | |
66 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | 160 | /* Suppport of A64FX's vector length are 128,256 and 512bit only */ |
67 | 161 | aarch64_add_sve_properties(obj); | |
68 | if (kvm_enabled()) { | ||
69 | /* Ensure the set of lengths matches what KVM supports. */ | ||
70 | - bitmap_xor(tmp, cpu->sve_vq_map, kvm_supported, max_vq); | ||
71 | + bitmap_xor(tmp, cpu->sve_vq_map, cpu->sve_vq_supported, max_vq); | ||
72 | if (!bitmap_empty(tmp, max_vq)) { | ||
73 | vq = find_last_bit(tmp, max_vq) + 1; | ||
74 | if (test_bit(vq - 1, cpu->sve_vq_map)) { | ||
75 | -- | 162 | -- |
76 | 2.20.1 | 163 | 2.25.1 |
77 | |||
78 | diff view generated by jsdifflib |
1 | The xen_available() function is used only to produce an error | 1 | We previously open-coded the expression for the number of virtual APR |
---|---|---|---|
2 | for some Xen-specific command line options in QEMU binaries where | 2 | registers and the assertion that it was not going to cause us to |
3 | Xen support was not compiled in: it just returns the value of | 3 | overflow the cs->ich_apr[] array. Factor this out into a new |
4 | the CONFIG_XEN define. | 4 | ich_num_aprs() function, for consistency with the icc_num_aprs() |
5 | 5 | function we just added for the physical APR handling. | |
6 | Now that accelerators are QOM classes, we can check for | ||
7 | "does this binary have Xen compiled in" with accel_find("xen"), | ||
8 | and drop the xen_available() function. | ||
9 | 6 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20210730105947.28215-2-peter.maydell@linaro.org | 9 | Message-id: 20220512151457.3899052-7-peter.maydell@linaro.org |
10 | Message-id: 20220506162129.2896966-6-peter.maydell@linaro.org | ||
13 | --- | 11 | --- |
14 | include/sysemu/arch_init.h | 1 - | 12 | hw/intc/arm_gicv3_cpuif.c | 16 ++++++++++------ |
15 | softmmu/arch_init.c | 9 --------- | 13 | 1 file changed, 10 insertions(+), 6 deletions(-) |
16 | softmmu/vl.c | 6 +++--- | ||
17 | 3 files changed, 3 insertions(+), 13 deletions(-) | ||
18 | 14 | ||
19 | diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h | 15 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/sysemu/arch_init.h | 17 | --- a/hw/intc/arm_gicv3_cpuif.c |
22 | +++ b/include/sysemu/arch_init.h | 18 | +++ b/hw/intc/arm_gicv3_cpuif.c |
23 | @@ -XXX,XX +XXX,XX @@ enum { | 19 | @@ -XXX,XX +XXX,XX @@ static inline int icv_min_vbpr(GICv3CPUState *cs) |
24 | extern const uint32_t arch_type; | 20 | return 7 - cs->vprebits; |
25 | |||
26 | int kvm_available(void); | ||
27 | -int xen_available(void); | ||
28 | |||
29 | /* default virtio transport per architecture */ | ||
30 | #define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \ | ||
31 | diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/softmmu/arch_init.c | ||
34 | +++ b/softmmu/arch_init.c | ||
35 | @@ -XXX,XX +XXX,XX @@ int kvm_available(void) | ||
36 | return 0; | ||
37 | #endif | ||
38 | } | 21 | } |
22 | |||
23 | +static inline int ich_num_aprs(GICv3CPUState *cs) | ||
24 | +{ | ||
25 | + /* Return the number of virtual APR registers (1, 2, or 4) */ | ||
26 | + int aprmax = 1 << (cs->vprebits - 5); | ||
27 | + assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0])); | ||
28 | + return aprmax; | ||
29 | +} | ||
30 | + | ||
31 | /* Simple accessor functions for LR fields */ | ||
32 | static uint32_t ich_lr_vintid(uint64_t lr) | ||
33 | { | ||
34 | @@ -XXX,XX +XXX,XX @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs) | ||
35 | * in the ICH Active Priority Registers. | ||
36 | */ | ||
37 | int i; | ||
38 | - int aprmax = 1 << (cs->vprebits - 5); | ||
39 | - | 39 | - |
40 | -int xen_available(void) | 40 | - assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0])); |
41 | -{ | 41 | + int aprmax = ich_num_aprs(cs); |
42 | -#ifdef CONFIG_XEN | 42 | |
43 | - return 1; | 43 | for (i = 0; i < aprmax; i++) { |
44 | -#else | 44 | uint32_t apr = cs->ich_apr[GICV3_G0][i] | |
45 | - return 0; | 45 | @@ -XXX,XX +XXX,XX @@ static int icv_drop_prio(GICv3CPUState *cs) |
46 | -#endif | 46 | * 32 bits are actually relevant. |
47 | -} | 47 | */ |
48 | diff --git a/softmmu/vl.c b/softmmu/vl.c | 48 | int i; |
49 | index XXXXXXX..XXXXXXX 100644 | 49 | - int aprmax = 1 << (cs->vprebits - 5); |
50 | --- a/softmmu/vl.c | 50 | - |
51 | +++ b/softmmu/vl.c | 51 | - assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0])); |
52 | @@ -XXX,XX +XXX,XX @@ void qemu_init(int argc, char **argv, char **envp) | 52 | + int aprmax = ich_num_aprs(cs); |
53 | has_defaults = 0; | 53 | |
54 | break; | 54 | for (i = 0; i < aprmax; i++) { |
55 | case QEMU_OPTION_xen_domid: | 55 | uint64_t *papr0 = &cs->ich_apr[GICV3_G0][i]; |
56 | - if (!(xen_available())) { | ||
57 | + if (!(accel_find("xen"))) { | ||
58 | error_report("Option not supported for this target"); | ||
59 | exit(1); | ||
60 | } | ||
61 | xen_domid = atoi(optarg); | ||
62 | break; | ||
63 | case QEMU_OPTION_xen_attach: | ||
64 | - if (!(xen_available())) { | ||
65 | + if (!(accel_find("xen"))) { | ||
66 | error_report("Option not supported for this target"); | ||
67 | exit(1); | ||
68 | } | ||
69 | xen_mode = XEN_ATTACH; | ||
70 | break; | ||
71 | case QEMU_OPTION_xen_domid_restrict: | ||
72 | - if (!(xen_available())) { | ||
73 | + if (!(accel_find("xen"))) { | ||
74 | error_report("Option not supported for this target"); | ||
75 | exit(1); | ||
76 | } | ||
77 | -- | 56 | -- |
78 | 2.20.1 | 57 | 2.25.1 |
79 | |||
80 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Chris Howard <cvz185@web.de> |
---|---|---|---|
2 | 2 | ||
3 | If we link QOM object (a) as a property of QOM object (b), | 3 | Give all the debug registers their correct names including the |
4 | we must set the property *before* (b) is realized. | 4 | index, rather than having multiple registers all with the |
5 | same name string, which is confusing when viewed over the | ||
6 | gdbstub interface. | ||
5 | 7 | ||
6 | Move QSPI realization *after* QSPI DMA. | 8 | Signed-off-by: CHRIS HOWARD <cvz185@web.de> |
7 | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 10 | Message-id: 4127D8CA-D54A-47C7-A039-0DB7361E30C0@web.de |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 11 | [PMM: expanded commit message] |
10 | Message-id: 20210819163422.2863447-2-philmd@redhat.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 13 | --- |
13 | hw/arm/xlnx-zynqmp.c | 42 ++++++++++++++++++++---------------------- | 14 | target/arm/helper.c | 16 ++++++++++++---- |
14 | 1 file changed, 20 insertions(+), 22 deletions(-) | 15 | 1 file changed, 12 insertions(+), 4 deletions(-) |
15 | 16 | ||
16 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/xlnx-zynqmp.c | 19 | --- a/target/arm/helper.c |
19 | +++ b/hw/arm/xlnx-zynqmp.c | 20 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | 21 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
21 | g_free(bus_name); | ||
22 | } | 22 | } |
23 | 23 | ||
24 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi), errp)) { | 24 | for (i = 0; i < brps; i++) { |
25 | - return; | 25 | + char *dbgbvr_el1_name = g_strdup_printf("DBGBVR%d_EL1", i); |
26 | - } | 26 | + char *dbgbcr_el1_name = g_strdup_printf("DBGBCR%d_EL1", i); |
27 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 0, QSPI_ADDR); | 27 | ARMCPRegInfo dbgregs[] = { |
28 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 1, LQSPI_ADDR); | 28 | - { .name = "DBGBVR", .state = ARM_CP_STATE_BOTH, |
29 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi), 0, gic_spi[QSPI_IRQ]); | 29 | + { .name = dbgbvr_el1_name, .state = ARM_CP_STATE_BOTH, |
30 | - | 30 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4, |
31 | - for (i = 0; i < XLNX_ZYNQMP_NUM_QSPI_BUS; i++) { | 31 | .access = PL1_RW, .accessfn = access_tda, |
32 | - gchar *bus_name; | 32 | .fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[i]), |
33 | - gchar *target_bus; | 33 | .writefn = dbgbvr_write, .raw_writefn = raw_write |
34 | - | 34 | }, |
35 | - /* Alias controller SPI bus to the SoC itself */ | 35 | - { .name = "DBGBCR", .state = ARM_CP_STATE_BOTH, |
36 | - bus_name = g_strdup_printf("qspi%d", i); | 36 | + { .name = dbgbcr_el1_name, .state = ARM_CP_STATE_BOTH, |
37 | - target_bus = g_strdup_printf("spi%d", i); | 37 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 5, |
38 | - object_property_add_alias(OBJECT(s), bus_name, | 38 | .access = PL1_RW, .accessfn = access_tda, |
39 | - OBJECT(&s->qspi), target_bus); | 39 | .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]), |
40 | - g_free(bus_name); | 40 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
41 | - g_free(target_bus); | 41 | }, |
42 | - } | 42 | }; |
43 | - | 43 | define_arm_cp_regs(cpu, dbgregs); |
44 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->dp), errp)) { | 44 | + g_free(dbgbvr_el1_name); |
45 | return; | 45 | + g_free(dbgbcr_el1_name); |
46 | } | 46 | } |
47 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | 47 | |
48 | 48 | for (i = 0; i < wrps; i++) { | |
49 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi_dma), 0, QSPI_DMA_ADDR); | 49 | + char *dbgwvr_el1_name = g_strdup_printf("DBGWVR%d_EL1", i); |
50 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi_dma), 0, gic_spi[QSPI_IRQ]); | 50 | + char *dbgwcr_el1_name = g_strdup_printf("DBGWCR%d_EL1", i); |
51 | - object_property_set_link(OBJECT(&s->qspi), "stream-connected-dma", | 51 | ARMCPRegInfo dbgregs[] = { |
52 | - OBJECT(&s->qspi_dma), errp); | 52 | - { .name = "DBGWVR", .state = ARM_CP_STATE_BOTH, |
53 | + | 53 | + { .name = dbgwvr_el1_name, .state = ARM_CP_STATE_BOTH, |
54 | + if (!object_property_set_link(OBJECT(&s->qspi), "stream-connected-dma", | 54 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6, |
55 | + OBJECT(&s->qspi_dma), errp)) { | 55 | .access = PL1_RW, .accessfn = access_tda, |
56 | + return; | 56 | .fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[i]), |
57 | + } | 57 | .writefn = dbgwvr_write, .raw_writefn = raw_write |
58 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi), errp)) { | 58 | }, |
59 | + return; | 59 | - { .name = "DBGWCR", .state = ARM_CP_STATE_BOTH, |
60 | + } | 60 | + { .name = dbgwcr_el1_name, .state = ARM_CP_STATE_BOTH, |
61 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 0, QSPI_ADDR); | 61 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 7, |
62 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 1, LQSPI_ADDR); | 62 | .access = PL1_RW, .accessfn = access_tda, |
63 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi), 0, gic_spi[QSPI_IRQ]); | 63 | .fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]), |
64 | + | 64 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
65 | + for (i = 0; i < XLNX_ZYNQMP_NUM_QSPI_BUS; i++) { | 65 | }, |
66 | + g_autofree gchar *bus_name = g_strdup_printf("qspi%d", i); | 66 | }; |
67 | + g_autofree gchar *target_bus = g_strdup_printf("spi%d", i); | 67 | define_arm_cp_regs(cpu, dbgregs); |
68 | + | 68 | + g_free(dbgwvr_el1_name); |
69 | + /* Alias controller SPI bus to the SoC itself */ | 69 | + g_free(dbgwcr_el1_name); |
70 | + object_property_add_alias(OBJECT(s), bus_name, | 70 | } |
71 | + OBJECT(&s->qspi), target_bus); | ||
72 | + } | ||
73 | } | 71 | } |
74 | 72 | ||
75 | static Property xlnx_zynqmp_props[] = { | ||
76 | -- | 73 | -- |
77 | 2.20.1 | 74 | 2.25.1 |
78 | |||
79 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Simplify by always passing a MemoryRegion property to the device. | 3 | Except hw/core/irq.c which implements the forward-declared opaque |
4 | Doing so we can move the AddressSpace field to the device struct, | 4 | qemu_irq structure, hw/adc/zynq-xadc.{c,h} are the only files not |
5 | removing need for heap allocation. | 5 | using the typedef. Fix this single exception. |
6 | 6 | ||
7 | Update the Xilinx ZynqMP / Versal SoC models to pass the default | 7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | system memory instead of a NULL value. | 8 | Reviewed-by: Bernhard Beschow <shentey@gmail.com> |
9 | 9 | Message-id: 20220509202035.50335-1-philippe.mathieu.daude@gmail.com | |
10 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20210819163422.2863447-5-philmd@redhat.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 11 | --- |
16 | include/hw/dma/xlnx-zdma.h | 2 +- | 12 | include/hw/adc/zynq-xadc.h | 3 +-- |
17 | hw/arm/xlnx-versal.c | 2 ++ | 13 | hw/adc/zynq-xadc.c | 4 ++-- |
18 | hw/arm/xlnx-zynqmp.c | 8 ++++++++ | 14 | 2 files changed, 3 insertions(+), 4 deletions(-) |
19 | hw/dma/xlnx-zdma.c | 24 ++++++++++++------------ | ||
20 | 4 files changed, 23 insertions(+), 13 deletions(-) | ||
21 | 15 | ||
22 | diff --git a/include/hw/dma/xlnx-zdma.h b/include/hw/dma/xlnx-zdma.h | 16 | diff --git a/include/hw/adc/zynq-xadc.h b/include/hw/adc/zynq-xadc.h |
23 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/dma/xlnx-zdma.h | 18 | --- a/include/hw/adc/zynq-xadc.h |
25 | +++ b/include/hw/dma/xlnx-zdma.h | 19 | +++ b/include/hw/adc/zynq-xadc.h |
26 | @@ -XXX,XX +XXX,XX @@ struct XlnxZDMA { | 20 | @@ -XXX,XX +XXX,XX @@ struct ZynqXADCState { |
27 | MemoryRegion iomem; | 21 | uint16_t xadc_dfifo[ZYNQ_XADC_FIFO_DEPTH]; |
28 | MemTxAttrs attr; | 22 | uint16_t xadc_dfifo_entries; |
29 | MemoryRegion *dma_mr; | 23 | |
30 | - AddressSpace *dma_as; | 24 | - struct IRQState *qemu_irq; |
31 | + AddressSpace dma_as; | 25 | - |
32 | qemu_irq irq_zdma_ch_imr; | 26 | + qemu_irq irq; |
33 | 27 | }; | |
34 | struct { | 28 | |
35 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 29 | #endif /* ZYNQ_XADC_H */ |
30 | diff --git a/hw/adc/zynq-xadc.c b/hw/adc/zynq-xadc.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/arm/xlnx-versal.c | 32 | --- a/hw/adc/zynq-xadc.c |
38 | +++ b/hw/arm/xlnx-versal.c | 33 | +++ b/hw/adc/zynq-xadc.c |
39 | @@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic) | 34 | @@ -XXX,XX +XXX,XX @@ static void zynq_xadc_update_ints(ZynqXADCState *s) |
40 | TYPE_XLNX_ZDMA); | 35 | s->regs[INT_STS] |= INT_DFIFO_GTH; |
41 | dev = DEVICE(&s->lpd.iou.adma[i]); | ||
42 | object_property_set_int(OBJECT(dev), "bus-width", 128, &error_abort); | ||
43 | + object_property_set_link(OBJECT(dev), "dma", | ||
44 | + OBJECT(get_system_memory()), &error_fatal); | ||
45 | sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); | ||
46 | |||
47 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
48 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/arm/xlnx-zynqmp.c | ||
51 | +++ b/hw/arm/xlnx-zynqmp.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
53 | errp)) { | ||
54 | return; | ||
55 | } | ||
56 | + if (!object_property_set_link(OBJECT(&s->gdma[i]), "dma", | ||
57 | + OBJECT(system_memory), errp)) { | ||
58 | + return; | ||
59 | + } | ||
60 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->gdma[i]), errp)) { | ||
61 | return; | ||
62 | } | ||
63 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
64 | } | 36 | } |
65 | 37 | ||
66 | for (i = 0; i < XLNX_ZYNQMP_NUM_ADMA_CH; i++) { | 38 | - qemu_set_irq(s->qemu_irq, !!(s->regs[INT_STS] & ~s->regs[INT_MASK])); |
67 | + if (!object_property_set_link(OBJECT(&s->adma[i]), "dma", | 39 | + qemu_set_irq(s->irq, !!(s->regs[INT_STS] & ~s->regs[INT_MASK])); |
68 | + OBJECT(system_memory), errp)) { | ||
69 | + return; | ||
70 | + } | ||
71 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->adma[i]), errp)) { | ||
72 | return; | ||
73 | } | ||
74 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/hw/dma/xlnx-zdma.c | ||
77 | +++ b/hw/dma/xlnx-zdma.c | ||
78 | @@ -XXX,XX +XXX,XX @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, | ||
79 | return false; | ||
80 | } | ||
81 | |||
82 | - descr->addr = address_space_ldq_le(s->dma_as, addr, s->attr, NULL); | ||
83 | - descr->size = address_space_ldl_le(s->dma_as, addr + 8, s->attr, NULL); | ||
84 | - descr->attr = address_space_ldl_le(s->dma_as, addr + 12, s->attr, NULL); | ||
85 | + descr->addr = address_space_ldq_le(&s->dma_as, addr, s->attr, NULL); | ||
86 | + descr->size = address_space_ldl_le(&s->dma_as, addr + 8, s->attr, NULL); | ||
87 | + descr->attr = address_space_ldl_le(&s->dma_as, addr + 12, s->attr, NULL); | ||
88 | return true; | ||
89 | } | 40 | } |
90 | 41 | ||
91 | @@ -XXX,XX +XXX,XX @@ static void zdma_update_descr_addr(XlnxZDMA *s, bool type, | 42 | static void zynq_xadc_reset(DeviceState *d) |
92 | } else { | 43 | @@ -XXX,XX +XXX,XX @@ static void zynq_xadc_init(Object *obj) |
93 | addr = zdma_get_regaddr64(s, basereg); | 44 | memory_region_init_io(&s->iomem, obj, &xadc_ops, s, "zynq-xadc", |
94 | addr += sizeof(s->dsc_dst); | 45 | ZYNQ_XADC_MMIO_SIZE); |
95 | - next = address_space_ldq_le(s->dma_as, addr, s->attr, NULL); | 46 | sysbus_init_mmio(sbd, &s->iomem); |
96 | + next = address_space_ldq_le(&s->dma_as, addr, s->attr, NULL); | 47 | - sysbus_init_irq(sbd, &s->qemu_irq); |
97 | } | 48 | + sysbus_init_irq(sbd, &s->irq); |
98 | |||
99 | zdma_put_regaddr64(s, basereg, next); | ||
100 | @@ -XXX,XX +XXX,XX @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len) | ||
101 | } | ||
102 | } | ||
103 | |||
104 | - address_space_write(s->dma_as, s->dsc_dst.addr, s->attr, buf, dlen); | ||
105 | + address_space_write(&s->dma_as, s->dsc_dst.addr, s->attr, buf, dlen); | ||
106 | if (burst_type == AXI_BURST_INCR) { | ||
107 | s->dsc_dst.addr += dlen; | ||
108 | } | ||
109 | @@ -XXX,XX +XXX,XX @@ static void zdma_process_descr(XlnxZDMA *s) | ||
110 | len = s->cfg.bus_width / 8; | ||
111 | } | ||
112 | } else { | ||
113 | - address_space_read(s->dma_as, src_addr, s->attr, s->buf, len); | ||
114 | + address_space_read(&s->dma_as, src_addr, s->attr, s->buf, len); | ||
115 | if (burst_type == AXI_BURST_INCR) { | ||
116 | src_addr += len; | ||
117 | } | ||
118 | @@ -XXX,XX +XXX,XX @@ static void zdma_realize(DeviceState *dev, Error **errp) | ||
119 | XlnxZDMA *s = XLNX_ZDMA(dev); | ||
120 | unsigned int i; | ||
121 | |||
122 | + if (!s->dma_mr) { | ||
123 | + error_setg(errp, TYPE_XLNX_ZDMA " 'dma' link not set"); | ||
124 | + return; | ||
125 | + } | ||
126 | + address_space_init(&s->dma_as, s->dma_mr, "zdma-dma"); | ||
127 | + | ||
128 | for (i = 0; i < ARRAY_SIZE(zdma_regs_info); ++i) { | ||
129 | RegisterInfo *r = &s->regs_info[zdma_regs_info[i].addr / 4]; | ||
130 | |||
131 | @@ -XXX,XX +XXX,XX @@ static void zdma_realize(DeviceState *dev, Error **errp) | ||
132 | }; | ||
133 | } | ||
134 | |||
135 | - if (s->dma_mr) { | ||
136 | - s->dma_as = g_malloc0(sizeof(AddressSpace)); | ||
137 | - address_space_init(s->dma_as, s->dma_mr, NULL); | ||
138 | - } else { | ||
139 | - s->dma_as = &address_space_memory; | ||
140 | - } | ||
141 | s->attr = MEMTXATTRS_UNSPECIFIED; | ||
142 | } | 49 | } |
143 | 50 | ||
51 | static const VMStateDescription vmstate_zynq_xadc = { | ||
144 | -- | 52 | -- |
145 | 2.20.1 | 53 | 2.25.1 |
146 | 54 | ||
147 | 55 | diff view generated by jsdifflib |
1 | In the alignment check added to qemu_ram_alloc_from_fd() in commit | 1 | In commit 88ce6c6ee85d we switched from directly fishing the number |
---|---|---|---|
2 | ce317be98db0dfdfa, the condition includes a check that 'mr' is not | 2 | of breakpoints and watchpoints out of the ID register fields to |
3 | NULL. This check is unnecessary because we can assume that the | 3 | abstracting out functions to do this job, but we forgot to delete the |
4 | caller always passes us a valid MemoryRegion, and indeed later in the | 4 | now-obsolete comment in define_debug_regs() about the relation |
5 | function we assume mr is not NULL when we pass it to file_ram_alloc() | 5 | between the ID field value and the actual number of breakpoints and |
6 | as new_block->mr. Remove it. | 6 | watchpoints. Delete the obsolete comment. |
7 | 7 | ||
8 | Fixes: Coverity 1459867 | 8 | Reported-by: CHRIS HOWARD <cvz185@web.de> |
9 | Fixes: ce317be98d ("exec: fetch the alignment of Linux devdax pmem character device nodes") | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Jingqi Liu <jingqi.liu@intel.com> | 10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
12 | Message-id: 20210812150624.29139-1-peter.maydell@linaro.org | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20220513131801.4082712-1-peter.maydell@linaro.org | ||
13 | --- | 13 | --- |
14 | softmmu/physmem.c | 2 +- | 14 | target/arm/helper.c | 1 - |
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | 15 | 1 file changed, 1 deletion(-) |
16 | 16 | ||
17 | diff --git a/softmmu/physmem.c b/softmmu/physmem.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/softmmu/physmem.c | 19 | --- a/target/arm/helper.c |
20 | +++ b/softmmu/physmem.c | 20 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, | 21 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
22 | define_one_arm_cp_reg(cpu, &dbgdidr); | ||
22 | } | 23 | } |
23 | 24 | ||
24 | file_align = get_file_align(fd); | 25 | - /* Note that all these register fields hold "number of Xs minus 1". */ |
25 | - if (file_align > 0 && mr && file_align > mr->align) { | 26 | brps = arm_num_brps(cpu); |
26 | + if (file_align > 0 && file_align > mr->align) { | 27 | wrps = arm_num_wrps(cpu); |
27 | error_setg(errp, "backing store align 0x%" PRIx64 | 28 | ctx_cmps = arm_num_ctx_cmps(cpu); |
28 | " is larger than 'align' option 0x%" PRIx64, | ||
29 | file_align, mr->align); | ||
30 | -- | 29 | -- |
31 | 2.20.1 | 30 | 2.25.1 |
32 | 31 | ||
33 | 32 | diff view generated by jsdifflib |
1 | Currently we rely on all the callsites of cpsr_write() to rebuild the | 1 | Currently we give all the v7-and-up CPUs a PMU with 4 counters. This |
---|---|---|---|
2 | cached hflags if they change one of the CPSR bits which we use as a | 2 | means that we don't provide the 6 counters that are required by the |
3 | TB flag and cache in hflags. This is a bit awkward when we want to | 3 | Arm BSA (Base System Architecture) specification if the CPU supports |
4 | change the set of CPSR bits that we cache, because it means we need | 4 | the Virtualization extensions. |
5 | to re-audit all the cpsr_write() callsites to see which flags they | 5 | |
6 | are writing and whether they now need to rebuild the hflags. | 6 | Instead of having a single PMCR_NUM_COUNTERS, make each CPU type |
7 | 7 | specify the PMCR reset value (obtained from the appropriate TRM), and | |
8 | Switch instead to making cpsr_write() call arm_rebuild_hflags() | 8 | use the 'N' field of that value to define the number of counters |
9 | itself if one of the bits being changed is a cached bit. | 9 | provided. |
10 | 10 | ||
11 | We don't do the rebuild for the CPSRWriteRaw write type, because that | 11 | This means that we now supply 6 counters instead of 4 for: |
12 | kind of write is generally doing something special anyway. For the | 12 | Cortex-A9, Cortex-A15, Cortex-A53, Cortex-A57, Cortex-A72, |
13 | CPSRWriteRaw callsites in the KVM code and inbound migration we | 13 | Cortex-A76, Neoverse-N1, '-cpu max' |
14 | definitely don't want to recalculate the hflags; the callsites in | 14 | This CPU goes from 4 to 8 counters: |
15 | boot.c and arm-powerctl.c have to do a rebuild-hflags call themselves | 15 | A64FX |
16 | anyway because of other CPU state changes they make. | 16 | These CPUs remain with 4 counters: |
17 | 17 | Cortex-A7, Cortex-A8 | |
18 | This allows us to drop explicit arm_rebuild_hflags() calls in a | 18 | This CPU goes down from 4 to 3 counters: |
19 | couple of places where the only reason we needed to call it was the | 19 | Cortex-R5 |
20 | CPSR write. | 20 | |
21 | 21 | Note that because we now use the PMCR reset value of the specific | |
22 | This fixes a bug where we were incorrectly failing to rebuild hflags | 22 | implementation, we no longer set the LC bit out of reset. This has |
23 | in the code path for a gdbstub write to CPSR, which meant that you | 23 | an UNKNOWN value out of reset for all cores with any AArch32 support, |
24 | could make QEMU assert by breaking into a running guest, altering the | 24 | so guest software should be setting it anyway if it wants it. |
25 | CPSR to change the value of, for example, CPSR.E, and then | 25 | |
26 | continuing. | 26 | This change was originally landed in commit f7fb73b8cdd3f7 (during |
27 | the 6.0 release cycle) but was then reverted by commit | ||
28 | 21c2dd77a6aa517 before that release because it did not work with KVM. | ||
29 | This version fixes that by creating the scratch vCPU in | ||
30 | kvm_arm_get_host_cpu_features() with the KVM_ARM_VCPU_PMU_V3 feature | ||
31 | if KVM supports it, and then only asking KVM for the PMCR_EL0 value | ||
32 | if the vCPU has a PMU. | ||
27 | 33 | ||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 34 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 35 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
30 | Message-id: 20210817201843.3829-1-peter.maydell@linaro.org | 36 | [PMM: Added the correct value for a64fx] |
37 | Message-id: 20220513122852.4063586-1-peter.maydell@linaro.org | ||
31 | --- | 38 | --- |
32 | target/arm/cpu.h | 10 ++++++++-- | 39 | target/arm/cpu.h | 1 + |
33 | linux-user/arm/signal.c | 2 -- | 40 | target/arm/internals.h | 4 +++- |
34 | target/arm/helper.c | 5 +++++ | 41 | target/arm/cpu64.c | 11 +++++++++++ |
35 | 3 files changed, 13 insertions(+), 4 deletions(-) | 42 | target/arm/cpu_tcg.c | 6 ++++++ |
43 | target/arm/helper.c | 25 ++++++++++++++----------- | ||
44 | target/arm/kvm64.c | 12 ++++++++++++ | ||
45 | 6 files changed, 47 insertions(+), 12 deletions(-) | ||
36 | 46 | ||
37 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 47 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
38 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/cpu.h | 49 | --- a/target/arm/cpu.h |
40 | +++ b/target/arm/cpu.h | 50 | +++ b/target/arm/cpu.h |
41 | @@ -XXX,XX +XXX,XX @@ uint32_t cpsr_read(CPUARMState *env); | 51 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
42 | typedef enum CPSRWriteType { | 52 | uint64_t id_aa64dfr0; |
43 | CPSRWriteByInstr = 0, /* from guest MSR or CPS */ | 53 | uint64_t id_aa64dfr1; |
44 | CPSRWriteExceptionReturn = 1, /* from guest exception return insn */ | 54 | uint64_t id_aa64zfr0; |
45 | - CPSRWriteRaw = 2, /* trust values, do not switch reg banks */ | 55 | + uint64_t reset_pmcr_el0; |
46 | + CPSRWriteRaw = 2, | 56 | } isar; |
47 | + /* trust values, no reg bank switch, no hflags rebuild */ | 57 | uint64_t midr; |
48 | CPSRWriteByGDBStub = 3, /* from the GDB stub */ | 58 | uint32_t revidr; |
49 | } CPSRWriteType; | 59 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
50 | 60 | index XXXXXXX..XXXXXXX 100644 | |
51 | -/* Set the CPSR. Note that some bits of mask must be all-set or all-clear.*/ | 61 | --- a/target/arm/internals.h |
52 | +/* | 62 | +++ b/target/arm/internals.h |
53 | + * Set the CPSR. Note that some bits of mask must be all-set or all-clear. | 63 | @@ -XXX,XX +XXX,XX @@ enum MVEECIState { |
54 | + * This will do an arm_rebuild_hflags() if any of the bits in @mask | 64 | |
55 | + * correspond to TB flags bits cached in the hflags, unless @write_type | 65 | static inline uint32_t pmu_num_counters(CPUARMState *env) |
56 | + * is CPSRWriteRaw. | 66 | { |
57 | + */ | 67 | - return (env->cp15.c9_pmcr & PMCRN_MASK) >> PMCRN_SHIFT; |
58 | void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | 68 | + ARMCPU *cpu = env_archcpu(env); |
59 | CPSRWriteType write_type); | 69 | + |
60 | 70 | + return (cpu->isar.reset_pmcr_el0 & PMCRN_MASK) >> PMCRN_SHIFT; | |
61 | diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c | 71 | } |
62 | index XXXXXXX..XXXXXXX 100644 | 72 | |
63 | --- a/linux-user/arm/signal.c | 73 | /* Bits allowed to be set/cleared for PMCNTEN* and PMINTEN* */ |
64 | +++ b/linux-user/arm/signal.c | 74 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
65 | @@ -XXX,XX +XXX,XX @@ setup_return(CPUARMState *env, struct target_sigaction *ka, | 75 | index XXXXXXX..XXXXXXX 100644 |
66 | env->regs[14] = retcode; | 76 | --- a/target/arm/cpu64.c |
67 | env->regs[15] = handler & (thumb ? ~1 : ~3); | 77 | +++ b/target/arm/cpu64.c |
68 | cpsr_write(env, cpsr, CPSR_IT | CPSR_T | CPSR_E, CPSRWriteByInstr); | 78 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) |
69 | - arm_rebuild_hflags(env); | 79 | cpu->isar.id_aa64isar0 = 0x00011120; |
70 | 80 | cpu->isar.id_aa64mmfr0 = 0x00001124; | |
71 | return 0; | 81 | cpu->isar.dbgdidr = 0x3516d000; |
72 | } | 82 | + cpu->isar.reset_pmcr_el0 = 0x41013000; |
73 | @@ -XXX,XX +XXX,XX @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) | 83 | cpu->clidr = 0x0a200023; |
74 | __get_user(env->regs[15], &sc->arm_pc); | 84 | cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ |
75 | __get_user(cpsr, &sc->arm_cpsr); | 85 | cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ |
76 | cpsr_write(env, cpsr, CPSR_USER | CPSR_EXEC, CPSRWriteByInstr); | 86 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) |
77 | - arm_rebuild_hflags(env); | 87 | cpu->isar.id_aa64isar0 = 0x00011120; |
78 | 88 | cpu->isar.id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */ | |
79 | err |= !valid_user_regs(env); | 89 | cpu->isar.dbgdidr = 0x3516d000; |
80 | 90 | + cpu->isar.reset_pmcr_el0 = 0x41033000; | |
91 | cpu->clidr = 0x0a200023; | ||
92 | cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ | ||
93 | cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */ | ||
94 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
95 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
96 | cpu->isar.id_aa64mmfr0 = 0x00001124; | ||
97 | cpu->isar.dbgdidr = 0x3516d000; | ||
98 | + cpu->isar.reset_pmcr_el0 = 0x41023000; | ||
99 | cpu->clidr = 0x0a200023; | ||
100 | cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | ||
101 | cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ | ||
102 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a76_initfn(Object *obj) | ||
103 | cpu->isar.mvfr0 = 0x10110222; | ||
104 | cpu->isar.mvfr1 = 0x13211111; | ||
105 | cpu->isar.mvfr2 = 0x00000043; | ||
106 | + | ||
107 | + /* From D5.1 AArch64 PMU register summary */ | ||
108 | + cpu->isar.reset_pmcr_el0 = 0x410b3000; | ||
109 | } | ||
110 | |||
111 | static void aarch64_neoverse_n1_initfn(Object *obj) | ||
112 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n1_initfn(Object *obj) | ||
113 | cpu->isar.mvfr0 = 0x10110222; | ||
114 | cpu->isar.mvfr1 = 0x13211111; | ||
115 | cpu->isar.mvfr2 = 0x00000043; | ||
116 | + | ||
117 | + /* From D5.1 AArch64 PMU register summary */ | ||
118 | + cpu->isar.reset_pmcr_el0 = 0x410c3000; | ||
119 | } | ||
120 | |||
121 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
122 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) | ||
123 | set_bit(1, cpu->sve_vq_supported); /* 256bit */ | ||
124 | set_bit(3, cpu->sve_vq_supported); /* 512bit */ | ||
125 | |||
126 | + cpu->isar.reset_pmcr_el0 = 0x46014040; | ||
127 | + | ||
128 | /* TODO: Add A64FX specific HPC extension registers */ | ||
129 | } | ||
130 | |||
131 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/cpu_tcg.c | ||
134 | +++ b/target/arm/cpu_tcg.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | ||
136 | cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */ | ||
137 | cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */ | ||
138 | cpu->reset_auxcr = 2; | ||
139 | + cpu->isar.reset_pmcr_el0 = 0x41002000; | ||
140 | define_arm_cp_regs(cpu, cortexa8_cp_reginfo); | ||
141 | } | ||
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
144 | cpu->clidr = (1 << 27) | (1 << 24) | 3; | ||
145 | cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */ | ||
146 | cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */ | ||
147 | + cpu->isar.reset_pmcr_el0 = 0x41093000; | ||
148 | define_arm_cp_regs(cpu, cortexa9_cp_reginfo); | ||
149 | } | ||
150 | |||
151 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
152 | cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ | ||
153 | cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ | ||
154 | cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ | ||
155 | + cpu->isar.reset_pmcr_el0 = 0x41072000; | ||
156 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */ | ||
157 | } | ||
158 | |||
159 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
160 | cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ | ||
161 | cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ | ||
162 | cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ | ||
163 | + cpu->isar.reset_pmcr_el0 = 0x410F3000; | ||
164 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); | ||
165 | } | ||
166 | |||
167 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | ||
168 | cpu->isar.id_isar6 = 0x0; | ||
169 | cpu->mp_is_up = true; | ||
170 | cpu->pmsav7_dregion = 16; | ||
171 | + cpu->isar.reset_pmcr_el0 = 0x41151800; | ||
172 | define_arm_cp_regs(cpu, cortexr5_cp_reginfo); | ||
173 | } | ||
174 | |||
175 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
176 | cpu->isar.id_isar5 = 0x00011121; | ||
177 | cpu->isar.id_isar6 = 0; | ||
178 | cpu->isar.dbgdidr = 0x3516d000; | ||
179 | + cpu->isar.reset_pmcr_el0 = 0x41013000; | ||
180 | cpu->clidr = 0x0a200023; | ||
181 | cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | ||
182 | cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ | ||
81 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 183 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
82 | index XXXXXXX..XXXXXXX 100644 | 184 | index XXXXXXX..XXXXXXX 100644 |
83 | --- a/target/arm/helper.c | 185 | --- a/target/arm/helper.c |
84 | +++ b/target/arm/helper.c | 186 | +++ b/target/arm/helper.c |
85 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | 187 | @@ -XXX,XX +XXX,XX @@ |
86 | CPSRWriteType write_type) | 188 | #include "cpregs.h" |
87 | { | 189 | |
88 | uint32_t changed_daif; | 190 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ |
89 | + bool rebuild_hflags = (write_type != CPSRWriteRaw) && | 191 | -#define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */ |
90 | + (mask & (CPSR_M | CPSR_E | CPSR_IL)); | 192 | |
91 | 193 | #ifndef CONFIG_USER_ONLY | |
92 | if (mask & CPSR_NZCV) { | 194 | |
93 | env->ZF = (~val) & CPSR_Z; | 195 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { |
94 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | 196 | .resetvalue = 0, |
197 | .writefn = gt_hyp_ctl_write, .raw_writefn = raw_write }, | ||
198 | #endif | ||
199 | - /* The only field of MDCR_EL2 that has a defined architectural reset value | ||
200 | - * is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N. | ||
201 | - */ | ||
202 | - { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
203 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1, | ||
204 | - .access = PL2_RW, .resetvalue = PMCR_NUM_COUNTERS, | ||
205 | - .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2), }, | ||
206 | { .name = "HPFAR", .state = ARM_CP_STATE_AA32, | ||
207 | .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4, | ||
208 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
209 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
210 | * field as main ID register, and we implement four counters in | ||
211 | * addition to the cycle count register. | ||
212 | */ | ||
213 | - unsigned int i, pmcrn = PMCR_NUM_COUNTERS; | ||
214 | + unsigned int i, pmcrn = pmu_num_counters(&cpu->env); | ||
215 | ARMCPRegInfo pmcr = { | ||
216 | .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, | ||
217 | .access = PL0_RW, | ||
218 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
219 | .access = PL0_RW, .accessfn = pmreg_access, | ||
220 | .type = ARM_CP_IO, | ||
221 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), | ||
222 | - .resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT) | | ||
223 | - PMCRLC, | ||
224 | + .resetvalue = cpu->isar.reset_pmcr_el0, | ||
225 | .writefn = pmcr_write, .raw_writefn = raw_write, | ||
226 | }; | ||
227 | + | ||
228 | define_one_arm_cp_reg(cpu, &pmcr); | ||
229 | define_one_arm_cp_reg(cpu, &pmcr64); | ||
230 | for (i = 0; i < pmcrn; i++) { | ||
231 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
232 | .type = ARM_CP_EL3_NO_EL2_C_NZ, | ||
233 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
234 | }; | ||
235 | + /* | ||
236 | + * The only field of MDCR_EL2 that has a defined architectural reset | ||
237 | + * value is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N. | ||
238 | + */ | ||
239 | + ARMCPRegInfo mdcr_el2 = { | ||
240 | + .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
241 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1, | ||
242 | + .access = PL2_RW, .resetvalue = pmu_num_counters(env), | ||
243 | + .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2), | ||
244 | + }; | ||
245 | + define_one_arm_cp_reg(cpu, &mdcr_el2); | ||
246 | define_arm_cp_regs(cpu, vpidr_regs); | ||
247 | define_arm_cp_regs(cpu, el2_cp_reginfo); | ||
248 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
249 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
250 | index XXXXXXX..XXXXXXX 100644 | ||
251 | --- a/target/arm/kvm64.c | ||
252 | +++ b/target/arm/kvm64.c | ||
253 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
254 | */ | ||
255 | int fdarray[3]; | ||
256 | bool sve_supported; | ||
257 | + bool pmu_supported = false; | ||
258 | uint64_t features = 0; | ||
259 | uint64_t t; | ||
260 | int err; | ||
261 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
262 | 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); | ||
95 | } | 263 | } |
96 | mask &= ~CACHED_CPSR_BITS; | 264 | |
97 | env->uncached_cpsr = (env->uncached_cpsr & ~mask) | (val & mask); | 265 | + if (kvm_arm_pmu_supported()) { |
98 | + if (rebuild_hflags) { | 266 | + init.features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; |
99 | + arm_rebuild_hflags(env); | 267 | + pmu_supported = true; |
100 | + } | 268 | + } |
101 | } | 269 | + |
102 | 270 | if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { | |
103 | /* Sign/zero extend */ | 271 | return false; |
272 | } | ||
273 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
274 | dbgdidr |= (1 << 15); /* RES1 bit */ | ||
275 | ahcf->isar.dbgdidr = dbgdidr; | ||
276 | } | ||
277 | + | ||
278 | + if (pmu_supported) { | ||
279 | + /* PMCR_EL0 is only accessible if the vCPU has feature PMU_V3 */ | ||
280 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0, | ||
281 | + ARM64_SYS_REG(3, 3, 9, 12, 0)); | ||
282 | + } | ||
283 | } | ||
284 | |||
285 | sve_supported = ioctl(fdarray[0], KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE) > 0; | ||
104 | -- | 286 | -- |
105 | 2.20.1 | 287 | 2.25.1 |
106 | |||
107 | diff view generated by jsdifflib |
1 | The SoC realize can fail for legitimate reasons, because it propagates | 1 | In the virt board with secure=on we put two nodes in the dtb |
---|---|---|---|
2 | errors up from CPU realize, which in turn can be provoked by user | 2 | for flash devices: one for the secure-only flash, and one |
3 | error in setting commandline options. Use error_fatal so we report | 3 | for the non-secure flash. We get the reg properties for these |
4 | the error message to the user and exit, rather than asserting | 4 | correct, but in the DT node name, which by convention includes |
5 | via error_abort. | 5 | the base address of devices, we used the wrong address. Fix it. |
6 | |||
7 | Spotted by dtc, which will complain | ||
8 | Warning (unique_unit_address): /flash@0: duplicate unit-address (also used in node /secflash@0) | ||
9 | if you dump the dtb from QEMU with -machine dumpdtb=file.dtb | ||
10 | and then decompile it with dtc. | ||
6 | 11 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 14 | Message-id: 20220513131316.4081539-2-peter.maydell@linaro.org |
10 | Message-id: 20210816135842.25302-2-peter.maydell@linaro.org | ||
11 | --- | 15 | --- |
12 | hw/arm/raspi.c | 2 +- | 16 | hw/arm/virt.c | 2 +- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 17 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 18 | ||
15 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 19 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
16 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/raspi.c | 21 | --- a/hw/arm/virt.c |
18 | +++ b/hw/arm/raspi.c | 22 | +++ b/hw/arm/virt.c |
19 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) | 23 | @@ -XXX,XX +XXX,XX @@ static void virt_flash_fdt(VirtMachineState *vms, |
20 | object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine->ram)); | 24 | qemu_fdt_setprop_string(ms->fdt, nodename, "secure-status", "okay"); |
21 | object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev, | 25 | g_free(nodename); |
22 | &error_abort); | 26 | |
23 | - qdev_realize(DEVICE(&s->soc), NULL, &error_abort); | 27 | - nodename = g_strdup_printf("/flash@%" PRIx64, flashbase); |
24 | + qdev_realize(DEVICE(&s->soc), NULL, &error_fatal); | 28 | + nodename = g_strdup_printf("/flash@%" PRIx64, flashbase + flashsize); |
25 | 29 | qemu_fdt_add_subnode(ms->fdt, nodename); | |
26 | /* Create and plug in the SD cards */ | 30 | qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", "cfi-flash"); |
27 | di = drive_get_next(IF_SD); | 31 | qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", |
28 | -- | 32 | -- |
29 | 2.20.1 | 33 | 2.25.1 |
30 | |||
31 | diff view generated by jsdifflib |
1 | Now that the CPU realize function will fail cleanly if we ask for EL3 | 1 | The virt board generates a gpio-keys node in the dtb, but it |
---|---|---|---|
2 | when KVM is enabled, we don't need to check for errors explicitly in | 2 | incorrectly gives this node #size-cells and #address-cells |
3 | the virt board code. The reported message is slightly different; | 3 | properties. If you dump the dtb with 'machine dumpdtb=file.dtb' |
4 | it is now: | 4 | and run it through dtc, dtc will warn about this: |
5 | qemu-system-aarch64: Cannot enable KVM when guest CPU has EL3 enabled | ||
6 | instead of: | ||
7 | qemu-system-aarch64: mach-virt: KVM does not support Security extensions | ||
8 | 5 | ||
9 | We don't delete the MTE check because there the logic is more | 6 | Warning (avoid_unnecessary_addr_size): /gpio-keys: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property |
10 | complex; deleting the check would work but makes the error message | 7 | |
11 | less helpful, as it would read: | 8 | Remove the bogus properties. |
12 | qemu-system-aarch64: MTE requested, but not supported by the guest CPU | ||
13 | instead of: | ||
14 | qemu-system-aarch64: mach-virt: KVM does not support providing MTE to the guest CPU | ||
15 | 9 | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Message-id: 20220513131316.4081539-3-peter.maydell@linaro.org |
19 | Message-id: 20210816135842.25302-4-peter.maydell@linaro.org | ||
20 | --- | 13 | --- |
21 | hw/arm/virt.c | 5 ----- | 14 | hw/arm/virt.c | 2 -- |
22 | 1 file changed, 5 deletions(-) | 15 | 1 file changed, 2 deletions(-) |
23 | 16 | ||
24 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
25 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/arm/virt.c | 19 | --- a/hw/arm/virt.c |
27 | +++ b/hw/arm/virt.c | 20 | +++ b/hw/arm/virt.c |
28 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 21 | @@ -XXX,XX +XXX,XX @@ static void create_gpio_keys(char *fdt, DeviceState *pl061_dev, |
29 | } | 22 | |
30 | 23 | qemu_fdt_add_subnode(fdt, "/gpio-keys"); | |
31 | if (vms->secure) { | 24 | qemu_fdt_setprop_string(fdt, "/gpio-keys", "compatible", "gpio-keys"); |
32 | - if (kvm_enabled()) { | 25 | - qemu_fdt_setprop_cell(fdt, "/gpio-keys", "#size-cells", 0); |
33 | - error_report("mach-virt: KVM does not support Security extensions"); | 26 | - qemu_fdt_setprop_cell(fdt, "/gpio-keys", "#address-cells", 1); |
34 | - exit(1); | 27 | |
35 | - } | 28 | qemu_fdt_add_subnode(fdt, "/gpio-keys/poweroff"); |
36 | - | 29 | qemu_fdt_setprop_string(fdt, "/gpio-keys/poweroff", |
37 | /* | ||
38 | * The Secure view of the world is the same as the NonSecure, | ||
39 | * but with a few extra devices. Create it as a container region | ||
40 | -- | 30 | -- |
41 | 2.20.1 | 31 | 2.25.1 |
42 | |||
43 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | The traditional ptimer behaviour includes a collection of weird edge |
---|---|---|---|
2 | case behaviours. In 2016 we improved the ptimer implementation to | ||
3 | fix these and generally make the behaviour more flexible, with | ||
4 | ptimers opting in to the new behaviour by passing an appropriate set | ||
5 | of policy flags to ptimer_init(). For backwards-compatibility, we | ||
6 | defined PTIMER_POLICY_DEFAULT (which sets no flags) to give the old | ||
7 | weird behaviour. | ||
2 | 8 | ||
3 | If some property are not set, we'll return indicating a failure, | 9 | This turns out to be a poor choice of name, because people writing |
4 | so it is pointless to allocate / initialize some fields too early. | 10 | new devices which use ptimers are misled into thinking that the |
5 | Move the trivial checks earlier in realize(). | 11 | default is probably a sensible choice of flags, when in fact it is |
12 | almost always not what you want. Rename PTIMER_POLICY_DEFAULT to | ||
13 | PTIMER_POLICY_LEGACY and beef up the comment to more clearly say that | ||
14 | new devices should not be using it. | ||
6 | 15 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 16 | The code-change part of this commit was produced by |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 17 | sed -i -e 's/PTIMER_POLICY_DEFAULT/PTIMER_POLICY_LEGACY/g' $(git grep -l PTIMER_POLICY_DEFAULT) |
9 | Message-id: 20210819163422.2863447-3-philmd@redhat.com | 18 | with the exception of a test name string change in |
19 | tests/unit/ptimer-test.c which was added manually. | ||
20 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20220516103058.162280-1-peter.maydell@linaro.org | ||
11 | --- | 25 | --- |
12 | hw/dma/xlnx_csu_dma.c | 10 +++++----- | 26 | include/hw/ptimer.h | 16 ++++++++++++---- |
13 | 1 file changed, 5 insertions(+), 5 deletions(-) | 27 | hw/arm/musicpal.c | 2 +- |
28 | hw/dma/xilinx_axidma.c | 2 +- | ||
29 | hw/dma/xlnx_csu_dma.c | 2 +- | ||
30 | hw/m68k/mcf5206.c | 2 +- | ||
31 | hw/m68k/mcf5208.c | 2 +- | ||
32 | hw/net/can/xlnx-zynqmp-can.c | 2 +- | ||
33 | hw/net/fsl_etsec/etsec.c | 2 +- | ||
34 | hw/net/lan9118.c | 2 +- | ||
35 | hw/rtc/exynos4210_rtc.c | 4 ++-- | ||
36 | hw/timer/allwinner-a10-pit.c | 2 +- | ||
37 | hw/timer/altera_timer.c | 2 +- | ||
38 | hw/timer/arm_timer.c | 2 +- | ||
39 | hw/timer/digic-timer.c | 2 +- | ||
40 | hw/timer/etraxfs_timer.c | 6 +++--- | ||
41 | hw/timer/exynos4210_mct.c | 6 +++--- | ||
42 | hw/timer/exynos4210_pwm.c | 2 +- | ||
43 | hw/timer/grlib_gptimer.c | 2 +- | ||
44 | hw/timer/imx_epit.c | 4 ++-- | ||
45 | hw/timer/imx_gpt.c | 2 +- | ||
46 | hw/timer/mss-timer.c | 2 +- | ||
47 | hw/timer/sh_timer.c | 2 +- | ||
48 | hw/timer/slavio_timer.c | 2 +- | ||
49 | hw/timer/xilinx_timer.c | 2 +- | ||
50 | tests/unit/ptimer-test.c | 6 +++--- | ||
51 | 25 files changed, 44 insertions(+), 36 deletions(-) | ||
14 | 52 | ||
53 | diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/include/hw/ptimer.h | ||
56 | +++ b/include/hw/ptimer.h | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | * to stderr when the guest attempts to enable the timer. | ||
59 | */ | ||
60 | |||
61 | -/* The default ptimer policy retains backward compatibility with the legacy | ||
62 | - * timers. Custom policies are adjusting the default one. Consider providing | ||
63 | - * a correct policy for your timer. | ||
64 | +/* | ||
65 | + * The 'legacy' ptimer policy retains backward compatibility with the | ||
66 | + * traditional ptimer behaviour from before policy flags were introduced. | ||
67 | + * It has several weird behaviours which don't match typical hardware | ||
68 | + * timer behaviour. For a new device using ptimers, you should not | ||
69 | + * use PTIMER_POLICY_LEGACY, but instead check the actual behaviour | ||
70 | + * that you need and specify the right set of policy flags to get that. | ||
71 | + * | ||
72 | + * If you are overhauling an existing device that uses PTIMER_POLICY_LEGACY | ||
73 | + * and are in a position to check or test the real hardware behaviour, | ||
74 | + * consider updating it to specify the right policy flags. | ||
75 | * | ||
76 | * The rough edges of the default policy: | ||
77 | * - Starting to run with a period = 0 emits error message and stops the | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | * since the last period, effectively restarting the timer with a | ||
80 | * counter = counter value at the moment of change (.i.e. one less). | ||
81 | */ | ||
82 | -#define PTIMER_POLICY_DEFAULT 0 | ||
83 | +#define PTIMER_POLICY_LEGACY 0 | ||
84 | |||
85 | /* Periodic timer counter stays with "0" for a one period before wrapping | ||
86 | * around. */ | ||
87 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/arm/musicpal.c | ||
90 | +++ b/hw/arm/musicpal.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static void mv88w8618_timer_init(SysBusDevice *dev, mv88w8618_timer_state *s, | ||
92 | sysbus_init_irq(dev, &s->irq); | ||
93 | s->freq = freq; | ||
94 | |||
95 | - s->ptimer = ptimer_init(mv88w8618_timer_tick, s, PTIMER_POLICY_DEFAULT); | ||
96 | + s->ptimer = ptimer_init(mv88w8618_timer_tick, s, PTIMER_POLICY_LEGACY); | ||
97 | } | ||
98 | |||
99 | static uint64_t mv88w8618_pit_read(void *opaque, hwaddr offset, | ||
100 | diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/hw/dma/xilinx_axidma.c | ||
103 | +++ b/hw/dma/xilinx_axidma.c | ||
104 | @@ -XXX,XX +XXX,XX @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp) | ||
105 | |||
106 | st->dma = s; | ||
107 | st->nr = i; | ||
108 | - st->ptimer = ptimer_init(timer_hit, st, PTIMER_POLICY_DEFAULT); | ||
109 | + st->ptimer = ptimer_init(timer_hit, st, PTIMER_POLICY_LEGACY); | ||
110 | ptimer_transaction_begin(st->ptimer); | ||
111 | ptimer_set_freq(st->ptimer, s->freqhz); | ||
112 | ptimer_transaction_commit(st->ptimer); | ||
15 | diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c | 113 | diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c |
16 | index XXXXXXX..XXXXXXX 100644 | 114 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/dma/xlnx_csu_dma.c | 115 | --- a/hw/dma/xlnx_csu_dma.c |
18 | +++ b/hw/dma/xlnx_csu_dma.c | 116 | +++ b/hw/dma/xlnx_csu_dma.c |
19 | @@ -XXX,XX +XXX,XX @@ static void xlnx_csu_dma_realize(DeviceState *dev, Error **errp) | 117 | @@ -XXX,XX +XXX,XX @@ static void xlnx_csu_dma_realize(DeviceState *dev, Error **errp) |
20 | XlnxCSUDMA *s = XLNX_CSU_DMA(dev); | ||
21 | RegisterInfoArray *reg_array; | ||
22 | |||
23 | + if (!s->is_dst && !s->tx_dev) { | ||
24 | + error_setg(errp, "zynqmp.csu-dma: Stream not connected"); | ||
25 | + return; | ||
26 | + } | ||
27 | + | ||
28 | reg_array = | ||
29 | register_init_block32(dev, xlnx_csu_dma_regs_info[!!s->is_dst], | ||
30 | XLNX_CSU_DMA_R_MAX, | ||
31 | @@ -XXX,XX +XXX,XX @@ static void xlnx_csu_dma_realize(DeviceState *dev, Error **errp) | ||
32 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
33 | sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); | 118 | sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); |
34 | 119 | ||
35 | - if (!s->is_dst && !s->tx_dev) { | ||
36 | - error_setg(errp, "zynqmp.csu-dma: Stream not connected"); | ||
37 | - return; | ||
38 | - } | ||
39 | - | ||
40 | s->src_timer = ptimer_init(xlnx_csu_dma_src_timeout_hit, | 120 | s->src_timer = ptimer_init(xlnx_csu_dma_src_timeout_hit, |
41 | s, PTIMER_POLICY_DEFAULT); | 121 | - s, PTIMER_POLICY_DEFAULT); |
42 | 122 | + s, PTIMER_POLICY_LEGACY); | |
123 | |||
124 | s->attr = MEMTXATTRS_UNSPECIFIED; | ||
125 | |||
126 | diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/hw/m68k/mcf5206.c | ||
129 | +++ b/hw/m68k/mcf5206.c | ||
130 | @@ -XXX,XX +XXX,XX @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq) | ||
131 | m5206_timer_state *s; | ||
132 | |||
133 | s = g_new0(m5206_timer_state, 1); | ||
134 | - s->timer = ptimer_init(m5206_timer_trigger, s, PTIMER_POLICY_DEFAULT); | ||
135 | + s->timer = ptimer_init(m5206_timer_trigger, s, PTIMER_POLICY_LEGACY); | ||
136 | s->irq = irq; | ||
137 | m5206_timer_reset(s); | ||
138 | return s; | ||
139 | diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/hw/m68k/mcf5208.c | ||
142 | +++ b/hw/m68k/mcf5208.c | ||
143 | @@ -XXX,XX +XXX,XX @@ static void mcf5208_sys_init(MemoryRegion *address_space, qemu_irq *pic) | ||
144 | /* Timers. */ | ||
145 | for (i = 0; i < 2; i++) { | ||
146 | s = g_new0(m5208_timer_state, 1); | ||
147 | - s->timer = ptimer_init(m5208_timer_trigger, s, PTIMER_POLICY_DEFAULT); | ||
148 | + s->timer = ptimer_init(m5208_timer_trigger, s, PTIMER_POLICY_LEGACY); | ||
149 | memory_region_init_io(&s->iomem, NULL, &m5208_timer_ops, s, | ||
150 | "m5208-timer", 0x00004000); | ||
151 | memory_region_add_subregion(address_space, 0xfc080000 + 0x4000 * i, | ||
152 | diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/hw/net/can/xlnx-zynqmp-can.c | ||
155 | +++ b/hw/net/can/xlnx-zynqmp-can.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_can_realize(DeviceState *dev, Error **errp) | ||
157 | |||
158 | /* Allocate a new timer. */ | ||
159 | s->can_timer = ptimer_init(xlnx_zynqmp_can_ptimer_cb, s, | ||
160 | - PTIMER_POLICY_DEFAULT); | ||
161 | + PTIMER_POLICY_LEGACY); | ||
162 | |||
163 | ptimer_transaction_begin(s->can_timer); | ||
164 | |||
165 | diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c | ||
166 | index XXXXXXX..XXXXXXX 100644 | ||
167 | --- a/hw/net/fsl_etsec/etsec.c | ||
168 | +++ b/hw/net/fsl_etsec/etsec.c | ||
169 | @@ -XXX,XX +XXX,XX @@ static void etsec_realize(DeviceState *dev, Error **errp) | ||
170 | object_get_typename(OBJECT(dev)), dev->id, etsec); | ||
171 | qemu_format_nic_info_str(qemu_get_queue(etsec->nic), etsec->conf.macaddr.a); | ||
172 | |||
173 | - etsec->ptimer = ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_DEFAULT); | ||
174 | + etsec->ptimer = ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_LEGACY); | ||
175 | ptimer_transaction_begin(etsec->ptimer); | ||
176 | ptimer_set_freq(etsec->ptimer, 100); | ||
177 | ptimer_transaction_commit(etsec->ptimer); | ||
178 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c | ||
179 | index XXXXXXX..XXXXXXX 100644 | ||
180 | --- a/hw/net/lan9118.c | ||
181 | +++ b/hw/net/lan9118.c | ||
182 | @@ -XXX,XX +XXX,XX @@ static void lan9118_realize(DeviceState *dev, Error **errp) | ||
183 | s->pmt_ctrl = 1; | ||
184 | s->txp = &s->tx_packet; | ||
185 | |||
186 | - s->timer = ptimer_init(lan9118_tick, s, PTIMER_POLICY_DEFAULT); | ||
187 | + s->timer = ptimer_init(lan9118_tick, s, PTIMER_POLICY_LEGACY); | ||
188 | ptimer_transaction_begin(s->timer); | ||
189 | ptimer_set_freq(s->timer, 10000); | ||
190 | ptimer_set_limit(s->timer, 0xffff, 1); | ||
191 | diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c | ||
192 | index XXXXXXX..XXXXXXX 100644 | ||
193 | --- a/hw/rtc/exynos4210_rtc.c | ||
194 | +++ b/hw/rtc/exynos4210_rtc.c | ||
195 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj) | ||
196 | Exynos4210RTCState *s = EXYNOS4210_RTC(obj); | ||
197 | SysBusDevice *dev = SYS_BUS_DEVICE(obj); | ||
198 | |||
199 | - s->ptimer = ptimer_init(exynos4210_rtc_tick, s, PTIMER_POLICY_DEFAULT); | ||
200 | + s->ptimer = ptimer_init(exynos4210_rtc_tick, s, PTIMER_POLICY_LEGACY); | ||
201 | ptimer_transaction_begin(s->ptimer); | ||
202 | ptimer_set_freq(s->ptimer, RTC_BASE_FREQ); | ||
203 | exynos4210_rtc_update_freq(s, 0); | ||
204 | ptimer_transaction_commit(s->ptimer); | ||
205 | |||
206 | s->ptimer_1Hz = ptimer_init(exynos4210_rtc_1Hz_tick, | ||
207 | - s, PTIMER_POLICY_DEFAULT); | ||
208 | + s, PTIMER_POLICY_LEGACY); | ||
209 | ptimer_transaction_begin(s->ptimer_1Hz); | ||
210 | ptimer_set_freq(s->ptimer_1Hz, RTC_BASE_FREQ); | ||
211 | ptimer_transaction_commit(s->ptimer_1Hz); | ||
212 | diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c | ||
213 | index XXXXXXX..XXXXXXX 100644 | ||
214 | --- a/hw/timer/allwinner-a10-pit.c | ||
215 | +++ b/hw/timer/allwinner-a10-pit.c | ||
216 | @@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj) | ||
217 | |||
218 | tc->container = s; | ||
219 | tc->index = i; | ||
220 | - s->timer[i] = ptimer_init(a10_pit_timer_cb, tc, PTIMER_POLICY_DEFAULT); | ||
221 | + s->timer[i] = ptimer_init(a10_pit_timer_cb, tc, PTIMER_POLICY_LEGACY); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | diff --git a/hw/timer/altera_timer.c b/hw/timer/altera_timer.c | ||
226 | index XXXXXXX..XXXXXXX 100644 | ||
227 | --- a/hw/timer/altera_timer.c | ||
228 | +++ b/hw/timer/altera_timer.c | ||
229 | @@ -XXX,XX +XXX,XX @@ static void altera_timer_realize(DeviceState *dev, Error **errp) | ||
230 | return; | ||
231 | } | ||
232 | |||
233 | - t->ptimer = ptimer_init(timer_hit, t, PTIMER_POLICY_DEFAULT); | ||
234 | + t->ptimer = ptimer_init(timer_hit, t, PTIMER_POLICY_LEGACY); | ||
235 | ptimer_transaction_begin(t->ptimer); | ||
236 | ptimer_set_freq(t->ptimer, t->freq_hz); | ||
237 | ptimer_transaction_commit(t->ptimer); | ||
238 | diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c | ||
239 | index XXXXXXX..XXXXXXX 100644 | ||
240 | --- a/hw/timer/arm_timer.c | ||
241 | +++ b/hw/timer/arm_timer.c | ||
242 | @@ -XXX,XX +XXX,XX @@ static arm_timer_state *arm_timer_init(uint32_t freq) | ||
243 | s->freq = freq; | ||
244 | s->control = TIMER_CTRL_IE; | ||
245 | |||
246 | - s->timer = ptimer_init(arm_timer_tick, s, PTIMER_POLICY_DEFAULT); | ||
247 | + s->timer = ptimer_init(arm_timer_tick, s, PTIMER_POLICY_LEGACY); | ||
248 | vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_arm_timer, s); | ||
249 | return s; | ||
250 | } | ||
251 | diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c | ||
252 | index XXXXXXX..XXXXXXX 100644 | ||
253 | --- a/hw/timer/digic-timer.c | ||
254 | +++ b/hw/timer/digic-timer.c | ||
255 | @@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj) | ||
256 | { | ||
257 | DigicTimerState *s = DIGIC_TIMER(obj); | ||
258 | |||
259 | - s->ptimer = ptimer_init(digic_timer_tick, NULL, PTIMER_POLICY_DEFAULT); | ||
260 | + s->ptimer = ptimer_init(digic_timer_tick, NULL, PTIMER_POLICY_LEGACY); | ||
261 | |||
262 | /* | ||
263 | * FIXME: there is no documentation on Digic timer | ||
264 | diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c | ||
265 | index XXXXXXX..XXXXXXX 100644 | ||
266 | --- a/hw/timer/etraxfs_timer.c | ||
267 | +++ b/hw/timer/etraxfs_timer.c | ||
268 | @@ -XXX,XX +XXX,XX @@ static void etraxfs_timer_realize(DeviceState *dev, Error **errp) | ||
269 | ETRAXTimerState *t = ETRAX_TIMER(dev); | ||
270 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
271 | |||
272 | - t->ptimer_t0 = ptimer_init(timer0_hit, t, PTIMER_POLICY_DEFAULT); | ||
273 | - t->ptimer_t1 = ptimer_init(timer1_hit, t, PTIMER_POLICY_DEFAULT); | ||
274 | - t->ptimer_wd = ptimer_init(watchdog_hit, t, PTIMER_POLICY_DEFAULT); | ||
275 | + t->ptimer_t0 = ptimer_init(timer0_hit, t, PTIMER_POLICY_LEGACY); | ||
276 | + t->ptimer_t1 = ptimer_init(timer1_hit, t, PTIMER_POLICY_LEGACY); | ||
277 | + t->ptimer_wd = ptimer_init(watchdog_hit, t, PTIMER_POLICY_LEGACY); | ||
278 | |||
279 | sysbus_init_irq(sbd, &t->irq); | ||
280 | sysbus_init_irq(sbd, &t->nmi); | ||
281 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | ||
282 | index XXXXXXX..XXXXXXX 100644 | ||
283 | --- a/hw/timer/exynos4210_mct.c | ||
284 | +++ b/hw/timer/exynos4210_mct.c | ||
285 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj) | ||
286 | |||
287 | /* Global timer */ | ||
288 | s->g_timer.ptimer_frc = ptimer_init(exynos4210_gfrc_event, s, | ||
289 | - PTIMER_POLICY_DEFAULT); | ||
290 | + PTIMER_POLICY_LEGACY); | ||
291 | memset(&s->g_timer.reg, 0, sizeof(struct gregs)); | ||
292 | |||
293 | /* Local timers */ | ||
294 | for (i = 0; i < 2; i++) { | ||
295 | s->l_timer[i].tick_timer.ptimer_tick = | ||
296 | ptimer_init(exynos4210_ltick_event, &s->l_timer[i], | ||
297 | - PTIMER_POLICY_DEFAULT); | ||
298 | + PTIMER_POLICY_LEGACY); | ||
299 | s->l_timer[i].ptimer_frc = | ||
300 | ptimer_init(exynos4210_lfrc_event, &s->l_timer[i], | ||
301 | - PTIMER_POLICY_DEFAULT); | ||
302 | + PTIMER_POLICY_LEGACY); | ||
303 | s->l_timer[i].id = i; | ||
304 | } | ||
305 | |||
306 | diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c | ||
307 | index XXXXXXX..XXXXXXX 100644 | ||
308 | --- a/hw/timer/exynos4210_pwm.c | ||
309 | +++ b/hw/timer/exynos4210_pwm.c | ||
310 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj) | ||
311 | sysbus_init_irq(dev, &s->timer[i].irq); | ||
312 | s->timer[i].ptimer = ptimer_init(exynos4210_pwm_tick, | ||
313 | &s->timer[i], | ||
314 | - PTIMER_POLICY_DEFAULT); | ||
315 | + PTIMER_POLICY_LEGACY); | ||
316 | s->timer[i].id = i; | ||
317 | s->timer[i].parent = s; | ||
318 | } | ||
319 | diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c | ||
320 | index XXXXXXX..XXXXXXX 100644 | ||
321 | --- a/hw/timer/grlib_gptimer.c | ||
322 | +++ b/hw/timer/grlib_gptimer.c | ||
323 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_realize(DeviceState *dev, Error **errp) | ||
324 | |||
325 | timer->unit = unit; | ||
326 | timer->ptimer = ptimer_init(grlib_gptimer_hit, timer, | ||
327 | - PTIMER_POLICY_DEFAULT); | ||
328 | + PTIMER_POLICY_LEGACY); | ||
329 | timer->id = i; | ||
330 | |||
331 | /* One IRQ line for each timer */ | ||
332 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c | ||
333 | index XXXXXXX..XXXXXXX 100644 | ||
334 | --- a/hw/timer/imx_epit.c | ||
335 | +++ b/hw/timer/imx_epit.c | ||
336 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_realize(DeviceState *dev, Error **errp) | ||
337 | 0x00001000); | ||
338 | sysbus_init_mmio(sbd, &s->iomem); | ||
339 | |||
340 | - s->timer_reload = ptimer_init(imx_epit_reload, s, PTIMER_POLICY_DEFAULT); | ||
341 | + s->timer_reload = ptimer_init(imx_epit_reload, s, PTIMER_POLICY_LEGACY); | ||
342 | |||
343 | - s->timer_cmp = ptimer_init(imx_epit_cmp, s, PTIMER_POLICY_DEFAULT); | ||
344 | + s->timer_cmp = ptimer_init(imx_epit_cmp, s, PTIMER_POLICY_LEGACY); | ||
345 | } | ||
346 | |||
347 | static void imx_epit_class_init(ObjectClass *klass, void *data) | ||
348 | diff --git a/hw/timer/imx_gpt.c b/hw/timer/imx_gpt.c | ||
349 | index XXXXXXX..XXXXXXX 100644 | ||
350 | --- a/hw/timer/imx_gpt.c | ||
351 | +++ b/hw/timer/imx_gpt.c | ||
352 | @@ -XXX,XX +XXX,XX @@ static void imx_gpt_realize(DeviceState *dev, Error **errp) | ||
353 | 0x00001000); | ||
354 | sysbus_init_mmio(sbd, &s->iomem); | ||
355 | |||
356 | - s->timer = ptimer_init(imx_gpt_timeout, s, PTIMER_POLICY_DEFAULT); | ||
357 | + s->timer = ptimer_init(imx_gpt_timeout, s, PTIMER_POLICY_LEGACY); | ||
358 | } | ||
359 | |||
360 | static void imx_gpt_class_init(ObjectClass *klass, void *data) | ||
361 | diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c | ||
362 | index XXXXXXX..XXXXXXX 100644 | ||
363 | --- a/hw/timer/mss-timer.c | ||
364 | +++ b/hw/timer/mss-timer.c | ||
365 | @@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj) | ||
366 | for (i = 0; i < NUM_TIMERS; i++) { | ||
367 | struct Msf2Timer *st = &t->timers[i]; | ||
368 | |||
369 | - st->ptimer = ptimer_init(timer_hit, st, PTIMER_POLICY_DEFAULT); | ||
370 | + st->ptimer = ptimer_init(timer_hit, st, PTIMER_POLICY_LEGACY); | ||
371 | ptimer_transaction_begin(st->ptimer); | ||
372 | ptimer_set_freq(st->ptimer, t->freq_hz); | ||
373 | ptimer_transaction_commit(st->ptimer); | ||
374 | diff --git a/hw/timer/sh_timer.c b/hw/timer/sh_timer.c | ||
375 | index XXXXXXX..XXXXXXX 100644 | ||
376 | --- a/hw/timer/sh_timer.c | ||
377 | +++ b/hw/timer/sh_timer.c | ||
378 | @@ -XXX,XX +XXX,XX @@ static void *sh_timer_init(uint32_t freq, int feat, qemu_irq irq) | ||
379 | s->enabled = 0; | ||
380 | s->irq = irq; | ||
381 | |||
382 | - s->timer = ptimer_init(sh_timer_tick, s, PTIMER_POLICY_DEFAULT); | ||
383 | + s->timer = ptimer_init(sh_timer_tick, s, PTIMER_POLICY_LEGACY); | ||
384 | |||
385 | sh_timer_write(s, OFFSET_TCOR >> 2, s->tcor); | ||
386 | sh_timer_write(s, OFFSET_TCNT >> 2, s->tcnt); | ||
387 | diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c | ||
388 | index XXXXXXX..XXXXXXX 100644 | ||
389 | --- a/hw/timer/slavio_timer.c | ||
390 | +++ b/hw/timer/slavio_timer.c | ||
391 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_init(Object *obj) | ||
392 | tc->timer_index = i; | ||
393 | |||
394 | s->cputimer[i].timer = ptimer_init(slavio_timer_irq, tc, | ||
395 | - PTIMER_POLICY_DEFAULT); | ||
396 | + PTIMER_POLICY_LEGACY); | ||
397 | ptimer_transaction_begin(s->cputimer[i].timer); | ||
398 | ptimer_set_period(s->cputimer[i].timer, TIMER_PERIOD); | ||
399 | ptimer_transaction_commit(s->cputimer[i].timer); | ||
400 | diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c | ||
401 | index XXXXXXX..XXXXXXX 100644 | ||
402 | --- a/hw/timer/xilinx_timer.c | ||
403 | +++ b/hw/timer/xilinx_timer.c | ||
404 | @@ -XXX,XX +XXX,XX @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp) | ||
405 | |||
406 | xt->parent = t; | ||
407 | xt->nr = i; | ||
408 | - xt->ptimer = ptimer_init(timer_hit, xt, PTIMER_POLICY_DEFAULT); | ||
409 | + xt->ptimer = ptimer_init(timer_hit, xt, PTIMER_POLICY_LEGACY); | ||
410 | ptimer_transaction_begin(xt->ptimer); | ||
411 | ptimer_set_freq(xt->ptimer, t->freq_hz); | ||
412 | ptimer_transaction_commit(xt->ptimer); | ||
413 | diff --git a/tests/unit/ptimer-test.c b/tests/unit/ptimer-test.c | ||
414 | index XXXXXXX..XXXXXXX 100644 | ||
415 | --- a/tests/unit/ptimer-test.c | ||
416 | +++ b/tests/unit/ptimer-test.c | ||
417 | @@ -XXX,XX +XXX,XX @@ static void add_ptimer_tests(uint8_t policy) | ||
418 | char policy_name[256] = ""; | ||
419 | char *tmp; | ||
420 | |||
421 | - if (policy == PTIMER_POLICY_DEFAULT) { | ||
422 | - g_sprintf(policy_name, "default"); | ||
423 | + if (policy == PTIMER_POLICY_LEGACY) { | ||
424 | + g_sprintf(policy_name, "legacy"); | ||
425 | } | ||
426 | |||
427 | if (policy & PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD) { | ||
428 | @@ -XXX,XX +XXX,XX @@ static void add_ptimer_tests(uint8_t policy) | ||
429 | static void add_all_ptimer_policies_comb_tests(void) | ||
430 | { | ||
431 | int last_policy = PTIMER_POLICY_TRIGGER_ONLY_ON_DECREMENT; | ||
432 | - int policy = PTIMER_POLICY_DEFAULT; | ||
433 | + int policy = PTIMER_POLICY_LEGACY; | ||
434 | |||
435 | for (; policy < (last_policy << 1); policy++) { | ||
436 | if ((policy & PTIMER_POLICY_TRIGGER_ONLY_ON_DECREMENT) && | ||
43 | -- | 437 | -- |
44 | 2.20.1 | 438 | 2.25.1 |
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Simplify by always passing a MemoryRegion property to the device. | ||
4 | Doing so we can move the AddressSpace field to the device struct, | ||
5 | removing need for heap allocation. | ||
6 | |||
7 | Update the Xilinx ZynqMP SoC model to pass the default system | ||
8 | memory instead of a NULL value. | ||
9 | |||
10 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20210819163422.2863447-4-philmd@redhat.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/dma/xlnx_csu_dma.h | 2 +- | ||
17 | hw/arm/xlnx-zynqmp.c | 4 ++++ | ||
18 | hw/dma/xlnx_csu_dma.c | 21 ++++++++++----------- | ||
19 | 3 files changed, 15 insertions(+), 12 deletions(-) | ||
20 | |||
21 | diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/dma/xlnx_csu_dma.h | ||
24 | +++ b/include/hw/dma/xlnx_csu_dma.h | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef struct XlnxCSUDMA { | ||
26 | MemoryRegion iomem; | ||
27 | MemTxAttrs attr; | ||
28 | MemoryRegion *dma_mr; | ||
29 | - AddressSpace *dma_as; | ||
30 | + AddressSpace dma_as; | ||
31 | qemu_irq irq; | ||
32 | StreamSink *tx_dev; /* Used as generic StreamSink */ | ||
33 | ptimer_state *src_timer; | ||
34 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/arm/xlnx-zynqmp.c | ||
37 | +++ b/hw/arm/xlnx-zynqmp.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
39 | gic_spi[adma_ch_intr[i]]); | ||
40 | } | ||
41 | |||
42 | + if (!object_property_set_link(OBJECT(&s->qspi_dma), "dma", | ||
43 | + OBJECT(system_memory), errp)) { | ||
44 | + return; | ||
45 | + } | ||
46 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi_dma), errp)) { | ||
47 | return; | ||
48 | } | ||
49 | diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/dma/xlnx_csu_dma.c | ||
52 | +++ b/hw/dma/xlnx_csu_dma.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static uint32_t xlnx_csu_dma_read(XlnxCSUDMA *s, uint8_t *buf, uint32_t len) | ||
54 | for (i = 0; i < len && (result == MEMTX_OK); i += s->width) { | ||
55 | uint32_t mlen = MIN(len - i, s->width); | ||
56 | |||
57 | - result = address_space_rw(s->dma_as, addr, s->attr, | ||
58 | + result = address_space_rw(&s->dma_as, addr, s->attr, | ||
59 | buf + i, mlen, false); | ||
60 | } | ||
61 | } else { | ||
62 | - result = address_space_rw(s->dma_as, addr, s->attr, buf, len, false); | ||
63 | + result = address_space_rw(&s->dma_as, addr, s->attr, buf, len, false); | ||
64 | } | ||
65 | |||
66 | if (result == MEMTX_OK) { | ||
67 | @@ -XXX,XX +XXX,XX @@ static uint32_t xlnx_csu_dma_write(XlnxCSUDMA *s, uint8_t *buf, uint32_t len) | ||
68 | for (i = 0; i < len && (result == MEMTX_OK); i += s->width) { | ||
69 | uint32_t mlen = MIN(len - i, s->width); | ||
70 | |||
71 | - result = address_space_rw(s->dma_as, addr, s->attr, | ||
72 | + result = address_space_rw(&s->dma_as, addr, s->attr, | ||
73 | buf, mlen, true); | ||
74 | buf += mlen; | ||
75 | } | ||
76 | } else { | ||
77 | - result = address_space_rw(s->dma_as, addr, s->attr, buf, len, true); | ||
78 | + result = address_space_rw(&s->dma_as, addr, s->attr, buf, len, true); | ||
79 | } | ||
80 | |||
81 | if (result != MEMTX_OK) { | ||
82 | @@ -XXX,XX +XXX,XX @@ static void xlnx_csu_dma_realize(DeviceState *dev, Error **errp) | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | + if (!s->dma_mr) { | ||
87 | + error_setg(errp, TYPE_XLNX_CSU_DMA " 'dma' link not set"); | ||
88 | + return; | ||
89 | + } | ||
90 | + address_space_init(&s->dma_as, s->dma_mr, "csu-dma"); | ||
91 | + | ||
92 | reg_array = | ||
93 | register_init_block32(dev, xlnx_csu_dma_regs_info[!!s->is_dst], | ||
94 | XLNX_CSU_DMA_R_MAX, | ||
95 | @@ -XXX,XX +XXX,XX @@ static void xlnx_csu_dma_realize(DeviceState *dev, Error **errp) | ||
96 | s->src_timer = ptimer_init(xlnx_csu_dma_src_timeout_hit, | ||
97 | s, PTIMER_POLICY_DEFAULT); | ||
98 | |||
99 | - if (s->dma_mr) { | ||
100 | - s->dma_as = g_malloc0(sizeof(AddressSpace)); | ||
101 | - address_space_init(s->dma_as, s->dma_mr, NULL); | ||
102 | - } else { | ||
103 | - s->dma_as = &address_space_memory; | ||
104 | - } | ||
105 | - | ||
106 | s->attr = MEMTXATTRS_UNSPECIFIED; | ||
107 | |||
108 | s->r_size_last_word = 0; | ||
109 | -- | ||
110 | 2.20.1 | ||
111 | |||
112 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ani Sinha <ani@anisinha.ca> | ||
2 | 1 | ||
3 | Since commit | ||
4 | 36b79e3219d ("hw/acpi/Kconfig: Add missing Kconfig dependencies (build error)"), | ||
5 | ACPI_MEMORY_HOTPLUG and ACPI_NVDIMM is implicitly turned on when | ||
6 | ACPI_HW_REDUCED is selected. ACPI_HW_REDUCED is already enabled. No need to | ||
7 | turn on ACPI_MEMORY_HOTPLUG or ACPI_NVDIMM explicitly. This is a minor cleanup. | ||
8 | |||
9 | Signed-off-by: Ani Sinha <ani@anisinha.ca> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20210819162637.518507-1-ani@anisinha.ca | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/Kconfig | 2 -- | ||
15 | 1 file changed, 2 deletions(-) | ||
16 | |||
17 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/Kconfig | ||
20 | +++ b/hw/arm/Kconfig | ||
21 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT | ||
22 | select ACPI_PCI | ||
23 | select MEM_DEVICE | ||
24 | select DIMM | ||
25 | - select ACPI_MEMORY_HOTPLUG | ||
26 | select ACPI_HW_REDUCED | ||
27 | - select ACPI_NVDIMM | ||
28 | select ACPI_APEI | ||
29 | |||
30 | config CHEETAH | ||
31 | -- | ||
32 | 2.20.1 | ||
33 | |||
34 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Florian Lugou <florian.lugou@provenrun.com> |
---|---|---|---|
2 | 2 | ||
3 | bitmap_clear() only clears the given range. While the given | 3 | As per the description of the HCR_EL2.APK field in the ARMv8 ARM, |
4 | range should be sufficient in this case we might as well be | 4 | Pointer Authentication keys accesses should only be trapped to Secure |
5 | 100% sure all bits are zeroed by using bitmap_zero(). | 5 | EL2 if it is enabled. |
6 | 6 | ||
7 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 7 | Signed-off-by: Florian Lugou <florian.lugou@provenrun.com> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20210823160647.34028-3-drjones@redhat.com | 9 | Message-id: 20220517145242.1215271-1-florian.lugou@provenrun.com |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | target/arm/kvm64.c | 2 +- | 12 | target/arm/helper.c | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 14 | ||
16 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/kvm64.c | 17 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/kvm64.c | 18 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) | 19 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_pauth(CPUARMState *env, const ARMCPRegInfo *ri, |
21 | uint32_t vq = 0; | 20 | int el = arm_current_el(env); |
22 | int i, j; | 21 | |
23 | 22 | if (el < 2 && | |
24 | - bitmap_clear(map, 0, ARM_MAX_VQ); | 23 | - arm_feature(env, ARM_FEATURE_EL2) && |
25 | + bitmap_zero(map, ARM_MAX_VQ); | 24 | + arm_is_el2_enabled(env) && |
26 | 25 | !(arm_hcr_el2_eff(env) & HCR_APK)) { | |
27 | /* | 26 | return CP_ACCESS_TRAP_EL2; |
28 | * KVM ensures all host CPUs support the same set of vector lengths. | 27 | } |
29 | -- | 28 | -- |
30 | 2.20.1 | 29 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Do a basic conversion of the acpi_cpu_hotplug spec document to rST. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
5 | Message-id: 20210727170414.3368-2-peter.maydell@linaro.org | ||
6 | --- | ||
7 | docs/specs/acpi_cpu_hotplug.rst | 235 ++++++++++++++++++++++++++++++++ | ||
8 | docs/specs/acpi_cpu_hotplug.txt | 160 ---------------------- | ||
9 | docs/specs/index.rst | 1 + | ||
10 | 3 files changed, 236 insertions(+), 160 deletions(-) | ||
11 | create mode 100644 docs/specs/acpi_cpu_hotplug.rst | ||
12 | delete mode 100644 docs/specs/acpi_cpu_hotplug.txt | ||
13 | |||
14 | diff --git a/docs/specs/acpi_cpu_hotplug.rst b/docs/specs/acpi_cpu_hotplug.rst | ||
15 | new file mode 100644 | ||
16 | index XXXXXXX..XXXXXXX | ||
17 | --- /dev/null | ||
18 | +++ b/docs/specs/acpi_cpu_hotplug.rst | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | +QEMU<->ACPI BIOS CPU hotplug interface | ||
21 | +====================================== | ||
22 | + | ||
23 | +QEMU supports CPU hotplug via ACPI. This document | ||
24 | +describes the interface between QEMU and the ACPI BIOS. | ||
25 | + | ||
26 | +ACPI BIOS GPE.2 handler is dedicated for notifying OS about CPU hot-add | ||
27 | +and hot-remove events. | ||
28 | + | ||
29 | + | ||
30 | +Legacy ACPI CPU hotplug interface registers | ||
31 | +------------------------------------------- | ||
32 | + | ||
33 | +CPU present bitmap for: | ||
34 | + | ||
35 | +- ICH9-LPC (IO port 0x0cd8-0xcf7, 1-byte access) | ||
36 | +- PIIX-PM (IO port 0xaf00-0xaf1f, 1-byte access) | ||
37 | +- One bit per CPU. Bit position reflects corresponding CPU APIC ID. Read-only. | ||
38 | +- The first DWORD in bitmap is used in write mode to switch from legacy | ||
39 | + to modern CPU hotplug interface, write 0 into it to do switch. | ||
40 | + | ||
41 | +QEMU sets corresponding CPU bit on hot-add event and issues SCI | ||
42 | +with GPE.2 event set. CPU present map is read by ACPI BIOS GPE.2 handler | ||
43 | +to notify OS about CPU hot-add events. CPU hot-remove isn't supported. | ||
44 | + | ||
45 | + | ||
46 | +Modern ACPI CPU hotplug interface registers | ||
47 | +------------------------------------------- | ||
48 | + | ||
49 | +Register block base address: | ||
50 | + | ||
51 | +- ICH9-LPC IO port 0x0cd8 | ||
52 | +- PIIX-PM IO port 0xaf00 | ||
53 | + | ||
54 | +Register block size: | ||
55 | + | ||
56 | +- ACPI_CPU_HOTPLUG_REG_LEN = 12 | ||
57 | + | ||
58 | +All accesses to registers described below, imply little-endian byte order. | ||
59 | + | ||
60 | +Reserved registers behavior: | ||
61 | + | ||
62 | +- write accesses are ignored | ||
63 | +- read accesses return all bits set to 0. | ||
64 | + | ||
65 | +The last stored value in 'CPU selector' must refer to a possible CPU, otherwise | ||
66 | + | ||
67 | +- reads from any register return 0 | ||
68 | +- writes to any other register are ignored until valid value is stored into it | ||
69 | + | ||
70 | +On QEMU start, 'CPU selector' is initialized to a valid value, on reset it | ||
71 | +keeps the current value. | ||
72 | + | ||
73 | +Read access behavior | ||
74 | +^^^^^^^^^^^^^^^^^^^^ | ||
75 | + | ||
76 | +offset [0x0-0x3] | ||
77 | + Command data 2: (DWORD access) | ||
78 | + | ||
79 | + If value last stored in 'Command field' is: | ||
80 | + | ||
81 | + 0: | ||
82 | + reads as 0x0 | ||
83 | + 3: | ||
84 | + upper 32 bits of architecture specific CPU ID value | ||
85 | + other values: | ||
86 | + reserved | ||
87 | + | ||
88 | +offset [0x4] | ||
89 | + CPU device status fields: (1 byte access) | ||
90 | + | ||
91 | + bits: | ||
92 | + | ||
93 | + 0: | ||
94 | + Device is enabled and may be used by guest | ||
95 | + 1: | ||
96 | + Device insert event, used to distinguish device for which | ||
97 | + no device check event to OSPM was issued. | ||
98 | + It's valid only when bit 0 is set. | ||
99 | + 2: | ||
100 | + Device remove event, used to distinguish device for which | ||
101 | + no device eject request to OSPM was issued. Firmware must | ||
102 | + ignore this bit. | ||
103 | + 3: | ||
104 | + reserved and should be ignored by OSPM | ||
105 | + 4: | ||
106 | + if set to 1, OSPM requests firmware to perform device eject. | ||
107 | + 5-7: | ||
108 | + reserved and should be ignored by OSPM | ||
109 | + | ||
110 | +offset [0x5-0x7] | ||
111 | + reserved | ||
112 | + | ||
113 | +offset [0x8] | ||
114 | + Command data: (DWORD access) | ||
115 | + | ||
116 | + If value last stored in 'Command field' is one of: | ||
117 | + | ||
118 | + 0: | ||
119 | + contains 'CPU selector' value of a CPU with pending event[s] | ||
120 | + 3: | ||
121 | + lower 32 bits of architecture specific CPU ID value | ||
122 | + (in x86 case: APIC ID) | ||
123 | + otherwise: | ||
124 | + contains 0 | ||
125 | + | ||
126 | +Write access behavior | ||
127 | +^^^^^^^^^^^^^^^^^^^^^ | ||
128 | + | ||
129 | +offset [0x0-0x3] | ||
130 | + CPU selector: (DWORD access) | ||
131 | + | ||
132 | + Selects active CPU device. All following accesses to other | ||
133 | + registers will read/store data from/to selected CPU. | ||
134 | + Valid values: [0 .. max_cpus) | ||
135 | + | ||
136 | +offset [0x4] | ||
137 | + CPU device control fields: (1 byte access) | ||
138 | + | ||
139 | + bits: | ||
140 | + | ||
141 | + 0: | ||
142 | + reserved, OSPM must clear it before writing to register. | ||
143 | + 1: | ||
144 | + if set to 1 clears device insert event, set by OSPM | ||
145 | + after it has emitted device check event for the | ||
146 | + selected CPU device | ||
147 | + 2: | ||
148 | + if set to 1 clears device remove event, set by OSPM | ||
149 | + after it has emitted device eject request for the | ||
150 | + selected CPU device. | ||
151 | + 3: | ||
152 | + if set to 1 initiates device eject, set by OSPM when it | ||
153 | + triggers CPU device removal and calls _EJ0 method or by firmware | ||
154 | + when bit #4 is set. In case bit #4 were set, it's cleared as | ||
155 | + part of device eject. | ||
156 | + 4: | ||
157 | + if set to 1, OSPM hands over device eject to firmware. | ||
158 | + Firmware shall issue device eject request as described above | ||
159 | + (bit #3) and OSPM should not touch device eject bit (#3) in case | ||
160 | + it's asked firmware to perform CPU device eject. | ||
161 | + 5-7: | ||
162 | + reserved, OSPM must clear them before writing to register | ||
163 | + | ||
164 | +offset[0x5] | ||
165 | + Command field: (1 byte access) | ||
166 | + | ||
167 | + value: | ||
168 | + | ||
169 | + 0: | ||
170 | + selects a CPU device with inserting/removing events and | ||
171 | + following reads from 'Command data' register return | ||
172 | + selected CPU ('CPU selector' value). | ||
173 | + If no CPU with events found, the current 'CPU selector' doesn't | ||
174 | + change and corresponding insert/remove event flags are not modified. | ||
175 | + | ||
176 | + 1: | ||
177 | + following writes to 'Command data' register set OST event | ||
178 | + register in QEMU | ||
179 | + 2: | ||
180 | + following writes to 'Command data' register set OST status | ||
181 | + register in QEMU | ||
182 | + 3: | ||
183 | + following reads from 'Command data' and 'Command data 2' return | ||
184 | + architecture specific CPU ID value for currently selected CPU. | ||
185 | + other values: | ||
186 | + reserved | ||
187 | + | ||
188 | +offset [0x6-0x7] | ||
189 | + reserved | ||
190 | + | ||
191 | +offset [0x8] | ||
192 | + Command data: (DWORD access) | ||
193 | + | ||
194 | + If last stored 'Command field' value is: | ||
195 | + | ||
196 | + 1: | ||
197 | + stores value into OST event register | ||
198 | + 2: | ||
199 | + stores value into OST status register, triggers | ||
200 | + ACPI_DEVICE_OST QMP event from QEMU to external applications | ||
201 | + with current values of OST event and status registers. | ||
202 | + other values: | ||
203 | + reserved | ||
204 | + | ||
205 | +Typical usecases | ||
206 | +---------------- | ||
207 | + | ||
208 | +(x86) Detecting and enabling modern CPU hotplug interface | ||
209 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
210 | + | ||
211 | +QEMU starts with legacy CPU hotplug interface enabled. Detecting and | ||
212 | +switching to modern interface is based on the 2 legacy CPU hotplug features: | ||
213 | + | ||
214 | +#. Writes into CPU bitmap are ignored. | ||
215 | +#. CPU bitmap always has bit #0 set, corresponding to boot CPU. | ||
216 | + | ||
217 | +Use following steps to detect and enable modern CPU hotplug interface: | ||
218 | + | ||
219 | +#. Store 0x0 to the 'CPU selector' register, attempting to switch to modern mode | ||
220 | +#. Store 0x0 to the 'CPU selector' register, to ensure valid selector value | ||
221 | +#. Store 0x0 to the 'Command field' register | ||
222 | +#. Read the 'Command data 2' register. | ||
223 | + If read value is 0x0, the modern interface is enabled. | ||
224 | + Otherwise legacy or no CPU hotplug interface available | ||
225 | + | ||
226 | +Get a cpu with pending event | ||
227 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
228 | + | ||
229 | +#. Store 0x0 to the 'CPU selector' register. | ||
230 | +#. Store 0x0 to the 'Command field' register. | ||
231 | +#. Read the 'CPU device status fields' register. | ||
232 | +#. If both bit #1 and bit #2 are clear in the value read, there is no CPU | ||
233 | + with a pending event and selected CPU remains unchanged. | ||
234 | +#. Otherwise, read the 'Command data' register. The value read is the | ||
235 | + selector of the CPU with the pending event (which is already selected). | ||
236 | + | ||
237 | +Enumerate CPUs present/non present CPUs | ||
238 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
239 | + | ||
240 | +#. Set the present CPU count to 0. | ||
241 | +#. Set the iterator to 0. | ||
242 | +#. Store 0x0 to the 'CPU selector' register, to ensure that it's in | ||
243 | + a valid state and that access to other registers won't be ignored. | ||
244 | +#. Store 0x0 to the 'Command field' register to make 'Command data' | ||
245 | + register return 'CPU selector' value of selected CPU | ||
246 | +#. Read the 'CPU device status fields' register. | ||
247 | +#. If bit #0 is set, increment the present CPU count. | ||
248 | +#. Increment the iterator. | ||
249 | +#. Store the iterator to the 'CPU selector' register. | ||
250 | +#. Read the 'Command data' register. | ||
251 | +#. If the value read is not zero, goto 05. | ||
252 | +#. Otherwise store 0x0 to the 'CPU selector' register, to put it | ||
253 | + into a valid state and exit. | ||
254 | + The iterator at this point equals "max_cpus". | ||
255 | diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt | ||
256 | deleted file mode 100644 | ||
257 | index XXXXXXX..XXXXXXX | ||
258 | --- a/docs/specs/acpi_cpu_hotplug.txt | ||
259 | +++ /dev/null | ||
260 | @@ -XXX,XX +XXX,XX @@ | ||
261 | -QEMU<->ACPI BIOS CPU hotplug interface | ||
262 | --------------------------------------- | ||
263 | - | ||
264 | -QEMU supports CPU hotplug via ACPI. This document | ||
265 | -describes the interface between QEMU and the ACPI BIOS. | ||
266 | - | ||
267 | -ACPI BIOS GPE.2 handler is dedicated for notifying OS about CPU hot-add | ||
268 | -and hot-remove events. | ||
269 | - | ||
270 | -============================================ | ||
271 | -Legacy ACPI CPU hotplug interface registers: | ||
272 | --------------------------------------------- | ||
273 | -CPU present bitmap for: | ||
274 | - ICH9-LPC (IO port 0x0cd8-0xcf7, 1-byte access) | ||
275 | - PIIX-PM (IO port 0xaf00-0xaf1f, 1-byte access) | ||
276 | - One bit per CPU. Bit position reflects corresponding CPU APIC ID. Read-only. | ||
277 | - The first DWORD in bitmap is used in write mode to switch from legacy | ||
278 | - to modern CPU hotplug interface, write 0 into it to do switch. | ||
279 | ---------------------------------------------------------------- | ||
280 | -QEMU sets corresponding CPU bit on hot-add event and issues SCI | ||
281 | -with GPE.2 event set. CPU present map is read by ACPI BIOS GPE.2 handler | ||
282 | -to notify OS about CPU hot-add events. CPU hot-remove isn't supported. | ||
283 | - | ||
284 | -===================================== | ||
285 | -Modern ACPI CPU hotplug interface registers: | ||
286 | -------------------------------------- | ||
287 | -Register block base address: | ||
288 | - ICH9-LPC IO port 0x0cd8 | ||
289 | - PIIX-PM IO port 0xaf00 | ||
290 | -Register block size: | ||
291 | - ACPI_CPU_HOTPLUG_REG_LEN = 12 | ||
292 | - | ||
293 | -All accesses to registers described below, imply little-endian byte order. | ||
294 | - | ||
295 | -Reserved resisters behavior: | ||
296 | - - write accesses are ignored | ||
297 | - - read accesses return all bits set to 0. | ||
298 | - | ||
299 | -The last stored value in 'CPU selector' must refer to a possible CPU, otherwise | ||
300 | - - reads from any register return 0 | ||
301 | - - writes to any other register are ignored until valid value is stored into it | ||
302 | -On QEMU start, 'CPU selector' is initialized to a valid value, on reset it | ||
303 | -keeps the current value. | ||
304 | - | ||
305 | -read access: | ||
306 | - offset: | ||
307 | - [0x0-0x3] Command data 2: (DWORD access) | ||
308 | - if value last stored in 'Command field': | ||
309 | - 0: reads as 0x0 | ||
310 | - 3: upper 32 bits of architecture specific CPU ID value | ||
311 | - other values: reserved | ||
312 | - [0x4] CPU device status fields: (1 byte access) | ||
313 | - bits: | ||
314 | - 0: Device is enabled and may be used by guest | ||
315 | - 1: Device insert event, used to distinguish device for which | ||
316 | - no device check event to OSPM was issued. | ||
317 | - It's valid only when bit 0 is set. | ||
318 | - 2: Device remove event, used to distinguish device for which | ||
319 | - no device eject request to OSPM was issued. Firmware must | ||
320 | - ignore this bit. | ||
321 | - 3: reserved and should be ignored by OSPM | ||
322 | - 4: if set to 1, OSPM requests firmware to perform device eject. | ||
323 | - 5-7: reserved and should be ignored by OSPM | ||
324 | - [0x5-0x7] reserved | ||
325 | - [0x8] Command data: (DWORD access) | ||
326 | - contains 0 unless value last stored in 'Command field' is one of: | ||
327 | - 0: contains 'CPU selector' value of a CPU with pending event[s] | ||
328 | - 3: lower 32 bits of architecture specific CPU ID value | ||
329 | - (in x86 case: APIC ID) | ||
330 | - | ||
331 | -write access: | ||
332 | - offset: | ||
333 | - [0x0-0x3] CPU selector: (DWORD access) | ||
334 | - selects active CPU device. All following accesses to other | ||
335 | - registers will read/store data from/to selected CPU. | ||
336 | - Valid values: [0 .. max_cpus) | ||
337 | - [0x4] CPU device control fields: (1 byte access) | ||
338 | - bits: | ||
339 | - 0: reserved, OSPM must clear it before writing to register. | ||
340 | - 1: if set to 1 clears device insert event, set by OSPM | ||
341 | - after it has emitted device check event for the | ||
342 | - selected CPU device | ||
343 | - 2: if set to 1 clears device remove event, set by OSPM | ||
344 | - after it has emitted device eject request for the | ||
345 | - selected CPU device. | ||
346 | - 3: if set to 1 initiates device eject, set by OSPM when it | ||
347 | - triggers CPU device removal and calls _EJ0 method or by firmware | ||
348 | - when bit #4 is set. In case bit #4 were set, it's cleared as | ||
349 | - part of device eject. | ||
350 | - 4: if set to 1, OSPM hands over device eject to firmware. | ||
351 | - Firmware shall issue device eject request as described above | ||
352 | - (bit #3) and OSPM should not touch device eject bit (#3) in case | ||
353 | - it's asked firmware to perform CPU device eject. | ||
354 | - 5-7: reserved, OSPM must clear them before writing to register | ||
355 | - [0x5] Command field: (1 byte access) | ||
356 | - value: | ||
357 | - 0: selects a CPU device with inserting/removing events and | ||
358 | - following reads from 'Command data' register return | ||
359 | - selected CPU ('CPU selector' value). | ||
360 | - If no CPU with events found, the current 'CPU selector' doesn't | ||
361 | - change and corresponding insert/remove event flags are not modified. | ||
362 | - 1: following writes to 'Command data' register set OST event | ||
363 | - register in QEMU | ||
364 | - 2: following writes to 'Command data' register set OST status | ||
365 | - register in QEMU | ||
366 | - 3: following reads from 'Command data' and 'Command data 2' return | ||
367 | - architecture specific CPU ID value for currently selected CPU. | ||
368 | - other values: reserved | ||
369 | - [0x6-0x7] reserved | ||
370 | - [0x8] Command data: (DWORD access) | ||
371 | - if last stored 'Command field' value: | ||
372 | - 1: stores value into OST event register | ||
373 | - 2: stores value into OST status register, triggers | ||
374 | - ACPI_DEVICE_OST QMP event from QEMU to external applications | ||
375 | - with current values of OST event and status registers. | ||
376 | - other values: reserved | ||
377 | - | ||
378 | -Typical usecases: | ||
379 | - - (x86) Detecting and enabling modern CPU hotplug interface. | ||
380 | - QEMU starts with legacy CPU hotplug interface enabled. Detecting and | ||
381 | - switching to modern interface is based on the 2 legacy CPU hotplug features: | ||
382 | - 1. Writes into CPU bitmap are ignored. | ||
383 | - 2. CPU bitmap always has bit#0 set, corresponding to boot CPU. | ||
384 | - | ||
385 | - Use following steps to detect and enable modern CPU hotplug interface: | ||
386 | - 1. Store 0x0 to the 'CPU selector' register, | ||
387 | - attempting to switch to modern mode | ||
388 | - 2. Store 0x0 to the 'CPU selector' register, | ||
389 | - to ensure valid selector value | ||
390 | - 3. Store 0x0 to the 'Command field' register, | ||
391 | - 4. Read the 'Command data 2' register. | ||
392 | - If read value is 0x0, the modern interface is enabled. | ||
393 | - Otherwise legacy or no CPU hotplug interface available | ||
394 | - | ||
395 | - - Get a cpu with pending event | ||
396 | - 1. Store 0x0 to the 'CPU selector' register. | ||
397 | - 2. Store 0x0 to the 'Command field' register. | ||
398 | - 3. Read the 'CPU device status fields' register. | ||
399 | - 4. If both bit#1 and bit#2 are clear in the value read, there is no CPU | ||
400 | - with a pending event and selected CPU remains unchanged. | ||
401 | - 5. Otherwise, read the 'Command data' register. The value read is the | ||
402 | - selector of the CPU with the pending event (which is already | ||
403 | - selected). | ||
404 | - | ||
405 | - - Enumerate CPUs present/non present CPUs | ||
406 | - 01. Set the present CPU count to 0. | ||
407 | - 02. Set the iterator to 0. | ||
408 | - 03. Store 0x0 to the 'CPU selector' register, to ensure that it's in | ||
409 | - a valid state and that access to other registers won't be ignored. | ||
410 | - 04. Store 0x0 to the 'Command field' register to make 'Command data' | ||
411 | - register return 'CPU selector' value of selected CPU | ||
412 | - 05. Read the 'CPU device status fields' register. | ||
413 | - 06. If bit#0 is set, increment the present CPU count. | ||
414 | - 07. Increment the iterator. | ||
415 | - 08. Store the iterator to the 'CPU selector' register. | ||
416 | - 09. Read the 'Command data' register. | ||
417 | - 10. If the value read is not zero, goto 05. | ||
418 | - 11. Otherwise store 0x0 to the 'CPU selector' register, to put it | ||
419 | - into a valid state and exit. | ||
420 | - The iterator at this point equals "max_cpus". | ||
421 | diff --git a/docs/specs/index.rst b/docs/specs/index.rst | ||
422 | index XXXXXXX..XXXXXXX 100644 | ||
423 | --- a/docs/specs/index.rst | ||
424 | +++ b/docs/specs/index.rst | ||
425 | @@ -XXX,XX +XXX,XX @@ guest hardware that is specific to QEMU. | ||
426 | acpi_hw_reduced_hotplug | ||
427 | tpm | ||
428 | acpi_hest_ghes | ||
429 | + acpi_cpu_hotplug | ||
430 | -- | ||
431 | 2.20.1 | ||
432 | |||
433 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the acpi memory hotplug spec to rST. | ||
2 | 1 | ||
3 | Note that this includes converting a lot of weird whitespace | ||
4 | characters to plain old spaces (the rST parser does not like | ||
5 | whatever the old ones were). | ||
6 | |||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
9 | Message-id: 20210727170414.3368-3-peter.maydell@linaro.org | ||
10 | --- | ||
11 | docs/specs/acpi_mem_hotplug.rst | 128 ++++++++++++++++++++++++++++++++ | ||
12 | docs/specs/acpi_mem_hotplug.txt | 94 ----------------------- | ||
13 | docs/specs/index.rst | 1 + | ||
14 | 3 files changed, 129 insertions(+), 94 deletions(-) | ||
15 | create mode 100644 docs/specs/acpi_mem_hotplug.rst | ||
16 | delete mode 100644 docs/specs/acpi_mem_hotplug.txt | ||
17 | |||
18 | diff --git a/docs/specs/acpi_mem_hotplug.rst b/docs/specs/acpi_mem_hotplug.rst | ||
19 | new file mode 100644 | ||
20 | index XXXXXXX..XXXXXXX | ||
21 | --- /dev/null | ||
22 | +++ b/docs/specs/acpi_mem_hotplug.rst | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | +QEMU<->ACPI BIOS memory hotplug interface | ||
25 | +========================================= | ||
26 | + | ||
27 | +ACPI BIOS GPE.3 handler is dedicated for notifying OS about memory hot-add | ||
28 | +and hot-remove events. | ||
29 | + | ||
30 | +Memory hot-plug interface (IO port 0xa00-0xa17, 1-4 byte access) | ||
31 | +---------------------------------------------------------------- | ||
32 | + | ||
33 | +Read access behavior | ||
34 | +^^^^^^^^^^^^^^^^^^^^ | ||
35 | + | ||
36 | +[0x0-0x3] | ||
37 | + Lo part of memory device phys address | ||
38 | +[0x4-0x7] | ||
39 | + Hi part of memory device phys address | ||
40 | +[0x8-0xb] | ||
41 | + Lo part of memory device size in bytes | ||
42 | +[0xc-0xf] | ||
43 | + Hi part of memory device size in bytes | ||
44 | +[0x10-0x13] | ||
45 | + Memory device proximity domain | ||
46 | +[0x14] | ||
47 | + Memory device status fields | ||
48 | + | ||
49 | + bits: | ||
50 | + | ||
51 | + 0: | ||
52 | + Device is enabled and may be used by guest | ||
53 | + 1: | ||
54 | + Device insert event, used to distinguish device for which | ||
55 | + no device check event to OSPM was issued. | ||
56 | + It's valid only when bit 1 is set. | ||
57 | + 2: | ||
58 | + Device remove event, used to distinguish device for which | ||
59 | + no device eject request to OSPM was issued. | ||
60 | + 3-7: | ||
61 | + reserved and should be ignored by OSPM | ||
62 | + | ||
63 | +[0x15-0x17] | ||
64 | + reserved | ||
65 | + | ||
66 | +Write access behavior | ||
67 | +^^^^^^^^^^^^^^^^^^^^^ | ||
68 | + | ||
69 | + | ||
70 | +[0x0-0x3] | ||
71 | + Memory device slot selector, selects active memory device. | ||
72 | + All following accesses to other registers in 0xa00-0xa17 | ||
73 | + region will read/store data from/to selected memory device. | ||
74 | +[0x4-0x7] | ||
75 | + OST event code reported by OSPM | ||
76 | +[0x8-0xb] | ||
77 | + OST status code reported by OSPM | ||
78 | +[0xc-0x13] | ||
79 | + reserved, writes into it are ignored | ||
80 | +[0x14] | ||
81 | + Memory device control fields | ||
82 | + | ||
83 | + bits: | ||
84 | + | ||
85 | + 0: | ||
86 | + reserved, OSPM must clear it before writing to register. | ||
87 | + Due to BUG in versions prior 2.4 that field isn't cleared | ||
88 | + when other fields are written. Keep it reserved and don't | ||
89 | + try to reuse it. | ||
90 | + 1: | ||
91 | + if set to 1 clears device insert event, set by OSPM | ||
92 | + after it has emitted device check event for the | ||
93 | + selected memory device | ||
94 | + 2: | ||
95 | + if set to 1 clears device remove event, set by OSPM | ||
96 | + after it has emitted device eject request for the | ||
97 | + selected memory device | ||
98 | + 3: | ||
99 | + if set to 1 initiates device eject, set by OSPM when it | ||
100 | + triggers memory device removal and calls _EJ0 method | ||
101 | + 4-7: | ||
102 | + reserved, OSPM must clear them before writing to register | ||
103 | + | ||
104 | +Selecting memory device slot beyond present range has no effect on platform: | ||
105 | + | ||
106 | +- write accesses to memory hot-plug registers not documented above are ignored | ||
107 | +- read accesses to memory hot-plug registers not documented above return | ||
108 | + all bits set to 1. | ||
109 | + | ||
110 | +Memory hot remove process diagram | ||
111 | +--------------------------------- | ||
112 | + | ||
113 | +:: | ||
114 | + | ||
115 | + +-------------+ +-----------------------+ +------------------+ | ||
116 | + | 1. QEMU | | 2. QEMU | |3. QEMU | | ||
117 | + | device_del +---->+ device unplug request +----->+Send SCI to guest,| | ||
118 | + | | | cb | |return control to | | ||
119 | + | | | | |management | | ||
120 | + +-------------+ +-----------------------+ +------------------+ | ||
121 | + | ||
122 | + +---------------------------------------------------------------------+ | ||
123 | + | ||
124 | + +---------------------+ +-------------------------+ | ||
125 | + | OSPM: | remove event | OSPM: | | ||
126 | + | send Eject Request, | | Scan memory devices | | ||
127 | + | clear remove event +<-------------+ for event flags | | ||
128 | + | | | | | ||
129 | + +---------------------+ +-------------------------+ | ||
130 | + | | ||
131 | + | | ||
132 | + +---------v--------+ +-----------------------+ | ||
133 | + | Guest OS: | success | OSPM: | | ||
134 | + | process Ejection +----------->+ Execute _EJ0 method, | | ||
135 | + | request | | set eject bit in flags| | ||
136 | + +------------------+ +-----------------------+ | ||
137 | + |failure | | ||
138 | + v v | ||
139 | + +------------------------+ +-----------------------+ | ||
140 | + | OSPM: | | QEMU: | | ||
141 | + | set OST event & status | | call device unplug cb | | ||
142 | + | fields | | | | ||
143 | + +------------------------+ +-----------------------+ | ||
144 | + | | | ||
145 | + v v | ||
146 | + +------------------+ +-------------------+ | ||
147 | + |QEMU: | |QEMU: | | ||
148 | + |Send OST QMP event| |Send device deleted| | ||
149 | + | | |QMP event | | ||
150 | + +------------------+ | | | ||
151 | + +-------------------+ | ||
152 | diff --git a/docs/specs/acpi_mem_hotplug.txt b/docs/specs/acpi_mem_hotplug.txt | ||
153 | deleted file mode 100644 | ||
154 | index XXXXXXX..XXXXXXX | ||
155 | --- a/docs/specs/acpi_mem_hotplug.txt | ||
156 | +++ /dev/null | ||
157 | @@ -XXX,XX +XXX,XX @@ | ||
158 | -QEMU<->ACPI BIOS memory hotplug interface | ||
159 | --------------------------------------- | ||
160 | - | ||
161 | -ACPI BIOS GPE.3 handler is dedicated for notifying OS about memory hot-add | ||
162 | -and hot-remove events. | ||
163 | - | ||
164 | -Memory hot-plug interface (IO port 0xa00-0xa17, 1-4 byte access): | ||
165 | ---------------------------------------------------------------- | ||
166 | -0xa00: | ||
167 | - read access: | ||
168 | - [0x0-0x3] Lo part of memory device phys address | ||
169 | - [0x4-0x7] Hi part of memory device phys address | ||
170 | - [0x8-0xb] Lo part of memory device size in bytes | ||
171 | - [0xc-0xf] Hi part of memory device size in bytes | ||
172 | - [0x10-0x13] Memory device proximity domain | ||
173 | - [0x14] Memory device status fields | ||
174 | - bits: | ||
175 | - 0: Device is enabled and may be used by guest | ||
176 | - 1: Device insert event, used to distinguish device for which | ||
177 | - no device check event to OSPM was issued. | ||
178 | - It's valid only when bit 1 is set. | ||
179 | - 2: Device remove event, used to distinguish device for which | ||
180 | - no device eject request to OSPM was issued. | ||
181 | - 3-7: reserved and should be ignored by OSPM | ||
182 | - [0x15-0x17] reserved | ||
183 | - | ||
184 | - write access: | ||
185 | - [0x0-0x3] Memory device slot selector, selects active memory device. | ||
186 | - All following accesses to other registers in 0xa00-0xa17 | ||
187 | - region will read/store data from/to selected memory device. | ||
188 | - [0x4-0x7] OST event code reported by OSPM | ||
189 | - [0x8-0xb] OST status code reported by OSPM | ||
190 | - [0xc-0x13] reserved, writes into it are ignored | ||
191 | - [0x14] Memory device control fields | ||
192 | - bits: | ||
193 | - 0: reserved, OSPM must clear it before writing to register. | ||
194 | - Due to BUG in versions prior 2.4 that field isn't cleared | ||
195 | - when other fields are written. Keep it reserved and don't | ||
196 | - try to reuse it. | ||
197 | - 1: if set to 1 clears device insert event, set by OSPM | ||
198 | - after it has emitted device check event for the | ||
199 | - selected memory device | ||
200 | - 2: if set to 1 clears device remove event, set by OSPM | ||
201 | - after it has emitted device eject request for the | ||
202 | - selected memory device | ||
203 | - 3: if set to 1 initiates device eject, set by OSPM when it | ||
204 | - triggers memory device removal and calls _EJ0 method | ||
205 | - 4-7: reserved, OSPM must clear them before writing to register | ||
206 | - | ||
207 | -Selecting memory device slot beyond present range has no effect on platform: | ||
208 | - - write accesses to memory hot-plug registers not documented above are | ||
209 | - ignored | ||
210 | - - read accesses to memory hot-plug registers not documented above return | ||
211 | - all bits set to 1. | ||
212 | - | ||
213 | -Memory hot remove process diagram: | ||
214 | ----------------------------------- | ||
215 | - +-------------+ +-----------------------+ +------------------+ | ||
216 | - | 1. QEMU | | 2. QEMU | |3. QEMU | | ||
217 | - | device_del +---->+ device unplug request +----->+Send SCI to guest,| | ||
218 | - | | | cb | |return control to | | ||
219 | - +-------------+ +-----------------------+ |management | | ||
220 | - +------------------+ | ||
221 | - | ||
222 | - +---------------------------------------------------------------------+ | ||
223 | - | ||
224 | - +---------------------+ +-------------------------+ | ||
225 | - | OSPM: | remove event | OSPM: | | ||
226 | - | send Eject Request, | | Scan memory devices | | ||
227 | - | clear remove event +<-------------+ for event flags | | ||
228 | - | | | | | ||
229 | - +---------------------+ +-------------------------+ | ||
230 | - | | ||
231 | - | | ||
232 | - +---------v--------+ +-----------------------+ | ||
233 | - | Guest OS: | success | OSPM: | | ||
234 | - | process Ejection +----------->+ Execute _EJ0 method, | | ||
235 | - | request | | set eject bit in flags| | ||
236 | - +------------------+ +-----------------------+ | ||
237 | - |failure | | ||
238 | - v v | ||
239 | - +------------------------+ +-----------------------+ | ||
240 | - | OSPM: | | QEMU: | | ||
241 | - | set OST event & status | | call device unplug cb | | ||
242 | - | fields | | | | ||
243 | - +------------------------+ +-----------------------+ | ||
244 | - | | | ||
245 | - v v | ||
246 | - +------------------+ +-------------------+ | ||
247 | - |QEMU: | |QEMU: | | ||
248 | - |Send OST QMP event| |Send device deleted| | ||
249 | - | | |QMP event | | ||
250 | - +------------------+ | | | ||
251 | - +-------------------+ | ||
252 | diff --git a/docs/specs/index.rst b/docs/specs/index.rst | ||
253 | index XXXXXXX..XXXXXXX 100644 | ||
254 | --- a/docs/specs/index.rst | ||
255 | +++ b/docs/specs/index.rst | ||
256 | @@ -XXX,XX +XXX,XX @@ guest hardware that is specific to QEMU. | ||
257 | tpm | ||
258 | acpi_hest_ghes | ||
259 | acpi_cpu_hotplug | ||
260 | + acpi_mem_hotplug | ||
261 | -- | ||
262 | 2.20.1 | ||
263 | |||
264 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the PCI hotplug spec document to rST. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
5 | --- | ||
6 | ...i_pci_hotplug.txt => acpi_pci_hotplug.rst} | 37 ++++++++++--------- | ||
7 | docs/specs/index.rst | 1 + | ||
8 | 2 files changed, 21 insertions(+), 17 deletions(-) | ||
9 | rename docs/specs/{acpi_pci_hotplug.txt => acpi_pci_hotplug.rst} (51%) | ||
10 | |||
11 | diff --git a/docs/specs/acpi_pci_hotplug.txt b/docs/specs/acpi_pci_hotplug.rst | ||
12 | similarity index 51% | ||
13 | rename from docs/specs/acpi_pci_hotplug.txt | ||
14 | rename to docs/specs/acpi_pci_hotplug.rst | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/docs/specs/acpi_pci_hotplug.txt | ||
17 | +++ b/docs/specs/acpi_pci_hotplug.rst | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | QEMU<->ACPI BIOS PCI hotplug interface | ||
20 | --------------------------------------- | ||
21 | +====================================== | ||
22 | |||
23 | QEMU supports PCI hotplug via ACPI, for PCI bus 0. This document | ||
24 | describes the interface between QEMU and the ACPI BIOS. | ||
25 | |||
26 | -ACPI GPE block (IO ports 0xafe0-0xafe3, byte access): | ||
27 | ------------------------------------------ | ||
28 | +ACPI GPE block (IO ports 0xafe0-0xafe3, byte access) | ||
29 | +---------------------------------------------------- | ||
30 | |||
31 | Generic ACPI GPE block. Bit 1 (GPE.1) used to notify PCI hotplug/eject | ||
32 | event to ACPI BIOS, via SCI interrupt. | ||
33 | |||
34 | -PCI slot injection notification pending (IO port 0xae00-0xae03, 4-byte access): | ||
35 | ---------------------------------------------------------------- | ||
36 | +PCI slot injection notification pending (IO port 0xae00-0xae03, 4-byte access) | ||
37 | +------------------------------------------------------------------------------ | ||
38 | + | ||
39 | Slot injection notification pending. One bit per slot. | ||
40 | |||
41 | Read by ACPI BIOS GPE.1 handler to notify OS of injection | ||
42 | events. Read-only. | ||
43 | |||
44 | -PCI slot removal notification (IO port 0xae04-0xae07, 4-byte access): | ||
45 | ------------------------------------------------------ | ||
46 | +PCI slot removal notification (IO port 0xae04-0xae07, 4-byte access) | ||
47 | +-------------------------------------------------------------------- | ||
48 | + | ||
49 | Slot removal notification pending. One bit per slot. | ||
50 | |||
51 | Read by ACPI BIOS GPE.1 handler to notify OS of removal | ||
52 | events. Read-only. | ||
53 | |||
54 | -PCI device eject (IO port 0xae08-0xae0b, 4-byte access): | ||
55 | ----------------------------------------- | ||
56 | +PCI device eject (IO port 0xae08-0xae0b, 4-byte access) | ||
57 | +------------------------------------------------------- | ||
58 | |||
59 | Write: Used by ACPI BIOS _EJ0 method to request device removal. | ||
60 | One bit per slot. | ||
61 | |||
62 | Read: Hotplug features register. Used by platform to identify features | ||
63 | available. Current base feature set (no bits set): | ||
64 | - - Read-only "up" register @0xae00, 4-byte access, bit per slot | ||
65 | - - Read-only "down" register @0xae04, 4-byte access, bit per slot | ||
66 | - - Read/write "eject" register @0xae08, 4-byte access, | ||
67 | - write: bit per slot eject, read: hotplug feature set | ||
68 | - - Read-only hotplug capable register @0xae0c, 4-byte access, bit per slot | ||
69 | |||
70 | -PCI removability status (IO port 0xae0c-0xae0f, 4-byte access): | ||
71 | ------------------------------------------------ | ||
72 | +- Read-only "up" register @0xae00, 4-byte access, bit per slot | ||
73 | +- Read-only "down" register @0xae04, 4-byte access, bit per slot | ||
74 | +- Read/write "eject" register @0xae08, 4-byte access, | ||
75 | + write: bit per slot eject, read: hotplug feature set | ||
76 | +- Read-only hotplug capable register @0xae0c, 4-byte access, bit per slot | ||
77 | + | ||
78 | +PCI removability status (IO port 0xae0c-0xae0f, 4-byte access) | ||
79 | +-------------------------------------------------------------- | ||
80 | |||
81 | Used by ACPI BIOS _RMV method to indicate removability status to OS. One | ||
82 | -bit per slot. Read-only | ||
83 | +bit per slot. Read-only. | ||
84 | diff --git a/docs/specs/index.rst b/docs/specs/index.rst | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/docs/specs/index.rst | ||
87 | +++ b/docs/specs/index.rst | ||
88 | @@ -XXX,XX +XXX,XX @@ guest hardware that is specific to QEMU. | ||
89 | acpi_hest_ghes | ||
90 | acpi_cpu_hotplug | ||
91 | acpi_mem_hotplug | ||
92 | + acpi_pci_hotplug | ||
93 | -- | ||
94 | 2.20.1 | ||
95 | |||
96 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the ACPI NVDIMM spec document to rST. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
5 | Message-id: 20210727170414.3368-5-peter.maydell@linaro.org | ||
6 | --- | ||
7 | docs/specs/acpi_nvdimm.rst | 228 +++++++++++++++++++++++++++++++++++++ | ||
8 | docs/specs/acpi_nvdimm.txt | 188 ------------------------------ | ||
9 | docs/specs/index.rst | 1 + | ||
10 | 3 files changed, 229 insertions(+), 188 deletions(-) | ||
11 | create mode 100644 docs/specs/acpi_nvdimm.rst | ||
12 | delete mode 100644 docs/specs/acpi_nvdimm.txt | ||
13 | |||
14 | diff --git a/docs/specs/acpi_nvdimm.rst b/docs/specs/acpi_nvdimm.rst | ||
15 | new file mode 100644 | ||
16 | index XXXXXXX..XXXXXXX | ||
17 | --- /dev/null | ||
18 | +++ b/docs/specs/acpi_nvdimm.rst | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | +QEMU<->ACPI BIOS NVDIMM interface | ||
21 | +================================= | ||
22 | + | ||
23 | +QEMU supports NVDIMM via ACPI. This document describes the basic concepts of | ||
24 | +NVDIMM ACPI and the interface between QEMU and the ACPI BIOS. | ||
25 | + | ||
26 | +NVDIMM ACPI Background | ||
27 | +---------------------- | ||
28 | + | ||
29 | +NVDIMM is introduced in ACPI 6.0 which defines an NVDIMM root device under | ||
30 | +_SB scope with a _HID of "ACPI0012". For each NVDIMM present or intended | ||
31 | +to be supported by platform, platform firmware also exposes an ACPI | ||
32 | +Namespace Device under the root device. | ||
33 | + | ||
34 | +The NVDIMM child devices under the NVDIMM root device are defined with _ADR | ||
35 | +corresponding to the NFIT device handle. The NVDIMM root device and the | ||
36 | +NVDIMM devices can have device specific methods (_DSM) to provide additional | ||
37 | +functions specific to a particular NVDIMM implementation. | ||
38 | + | ||
39 | +This is an example from ACPI 6.0, a platform contains one NVDIMM:: | ||
40 | + | ||
41 | + Scope (\_SB){ | ||
42 | + Device (NVDR) // Root device | ||
43 | + { | ||
44 | + Name (_HID, "ACPI0012") | ||
45 | + Method (_STA) {...} | ||
46 | + Method (_FIT) {...} | ||
47 | + Method (_DSM, ...) {...} | ||
48 | + Device (NVD) | ||
49 | + { | ||
50 | + Name(_ADR, h) //where h is NFIT Device Handle for this NVDIMM | ||
51 | + Method (_DSM, ...) {...} | ||
52 | + } | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | +Methods supported on both NVDIMM root device and NVDIMM device | ||
57 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
58 | + | ||
59 | +_DSM (Device Specific Method) | ||
60 | + It is a control method that enables devices to provide device specific | ||
61 | + control functions that are consumed by the device driver. | ||
62 | + The NVDIMM DSM specification can be found at | ||
63 | + http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf | ||
64 | + | ||
65 | + Arguments: | ||
66 | + | ||
67 | + Arg0 | ||
68 | + A Buffer containing a UUID (16 Bytes) | ||
69 | + Arg1 | ||
70 | + An Integer containing the Revision ID (4 Bytes) | ||
71 | + Arg2 | ||
72 | + An Integer containing the Function Index (4 Bytes) | ||
73 | + Arg3 | ||
74 | + A package containing parameters for the function specified by the | ||
75 | + UUID, Revision ID, and Function Index | ||
76 | + | ||
77 | + Return Value: | ||
78 | + | ||
79 | + If Function Index = 0, a Buffer containing a function index bitfield. | ||
80 | + Otherwise, the return value and type depends on the UUID, revision ID | ||
81 | + and function index which are described in the DSM specification. | ||
82 | + | ||
83 | +Methods on NVDIMM ROOT Device | ||
84 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
85 | + | ||
86 | +_FIT(Firmware Interface Table) | ||
87 | + It evaluates to a buffer returning data in the format of a series of NFIT | ||
88 | + Type Structure. | ||
89 | + | ||
90 | + Arguments: None | ||
91 | + | ||
92 | + Return Value: | ||
93 | + A Buffer containing a list of NFIT Type structure entries. | ||
94 | + | ||
95 | + The detailed definition of the structure can be found at ACPI 6.0: 5.2.25 | ||
96 | + NVDIMM Firmware Interface Table (NFIT). | ||
97 | + | ||
98 | +QEMU NVDIMM Implementation | ||
99 | +-------------------------- | ||
100 | + | ||
101 | +QEMU uses 4 bytes IO Port starting from 0x0a18 and a RAM-based memory page | ||
102 | +for NVDIMM ACPI. | ||
103 | + | ||
104 | +Memory: | ||
105 | + QEMU uses BIOS Linker/loader feature to ask BIOS to allocate a memory | ||
106 | + page and dynamically patch its address into an int32 object named "MEMA" | ||
107 | + in ACPI. | ||
108 | + | ||
109 | + This page is RAM-based and it is used to transfer data between _DSM | ||
110 | + method and QEMU. If ACPI has control, this pages is owned by ACPI which | ||
111 | + writes _DSM input data to it, otherwise, it is owned by QEMU which | ||
112 | + emulates _DSM access and writes the output data to it. | ||
113 | + | ||
114 | + ACPI writes _DSM Input Data (based on the offset in the page): | ||
115 | + | ||
116 | + [0x0 - 0x3] | ||
117 | + 4 bytes, NVDIMM Device Handle. | ||
118 | + | ||
119 | + The handle is completely QEMU internal thing, the values in | ||
120 | + range [1, 0xFFFF] indicate nvdimm device. Other values are | ||
121 | + reserved for other purposes. | ||
122 | + | ||
123 | + Reserved handles: | ||
124 | + | ||
125 | + - 0 is reserved for nvdimm root device named NVDR. | ||
126 | + - 0x10000 is reserved for QEMU internal DSM function called on | ||
127 | + the root device. | ||
128 | + | ||
129 | + [0x4 - 0x7] | ||
130 | + 4 bytes, Revision ID, that is the Arg1 of _DSM method. | ||
131 | + | ||
132 | + [0x8 - 0xB] | ||
133 | + 4 bytes. Function Index, that is the Arg2 of _DSM method. | ||
134 | + | ||
135 | + [0xC - 0xFFF] | ||
136 | + 4084 bytes, the Arg3 of _DSM method. | ||
137 | + | ||
138 | + QEMU writes Output Data (based on the offset in the page): | ||
139 | + | ||
140 | + [0x0 - 0x3] | ||
141 | + 4 bytes, the length of result | ||
142 | + | ||
143 | + [0x4 - 0xFFF] | ||
144 | + 4092 bytes, the DSM result filled by QEMU | ||
145 | + | ||
146 | +IO Port 0x0a18 - 0xa1b: | ||
147 | + ACPI writes the address of the memory page allocated by BIOS to this | ||
148 | + port then QEMU gets the control and fills the result in the memory page. | ||
149 | + | ||
150 | + Write Access: | ||
151 | + | ||
152 | + [0x0a18 - 0xa1b] | ||
153 | + 4 bytes, the address of the memory page allocated by BIOS. | ||
154 | + | ||
155 | +_DSM process diagram | ||
156 | +-------------------- | ||
157 | + | ||
158 | +"MEMA" indicates the address of memory page allocated by BIOS. | ||
159 | + | ||
160 | +:: | ||
161 | + | ||
162 | + +----------------------+ +-----------------------+ | ||
163 | + | 1. OSPM | | 2. OSPM | | ||
164 | + | save _DSM input data | | write "MEMA" to | Exit to QEMU | ||
165 | + | to the page +----->| IO port 0x0a18 +------------+ | ||
166 | + | indicated by "MEMA" | | | | | ||
167 | + +----------------------+ +-----------------------+ | | ||
168 | + | | ||
169 | + v | ||
170 | + +--------------------+ +-----------+ +------------------+--------+ | ||
171 | + | 5 QEMU | | 4 QEMU | | 3. QEMU | | ||
172 | + | write _DSM result | | emulate | | get _DSM input data from | | ||
173 | + | to the page +<------+ _DSM +<-----+ the page indicated by the | | ||
174 | + | | | | | value from the IO port | | ||
175 | + +--------+-----------+ +-----------+ +---------------------------+ | ||
176 | + | | ||
177 | + | Enter Guest | ||
178 | + | | ||
179 | + v | ||
180 | + +--------------------------+ +--------------+ | ||
181 | + | 6 OSPM | | 7 OSPM | | ||
182 | + | result size is returned | | _DSM return | | ||
183 | + | by reading DSM +----->+ | | ||
184 | + | result from the page | | | | ||
185 | + +--------------------------+ +--------------+ | ||
186 | + | ||
187 | +NVDIMM hotplug | ||
188 | +-------------- | ||
189 | + | ||
190 | +ACPI BIOS GPE.4 handler is dedicated for notifying OS about nvdimm device | ||
191 | +hot-add event. | ||
192 | + | ||
193 | +QEMU internal use only _DSM functions | ||
194 | +------------------------------------- | ||
195 | + | ||
196 | +Read FIT | ||
197 | +^^^^^^^^ | ||
198 | + | ||
199 | +_FIT method uses _DSM method to fetch NFIT structures blob from QEMU | ||
200 | +in 1 page sized increments which are then concatenated and returned | ||
201 | +as _FIT method result. | ||
202 | + | ||
203 | +Input parameters: | ||
204 | + | ||
205 | +Arg0 | ||
206 | + UUID {set to 648B9CF2-CDA1-4312-8AD9-49C4AF32BD62} | ||
207 | +Arg1 | ||
208 | + Revision ID (set to 1) | ||
209 | +Arg2 | ||
210 | + Function Index, 0x1 | ||
211 | +Arg3 | ||
212 | + A package containing a buffer whose layout is as follows: | ||
213 | + | ||
214 | + +----------+--------+--------+-------------------------------------------+ | ||
215 | + | Field | Length | Offset | Description | | ||
216 | + +----------+--------+--------+-------------------------------------------+ | ||
217 | + | offset | 4 | 0 | offset in QEMU's NFIT structures blob to | | ||
218 | + | | | | read from | | ||
219 | + +----------+--------+--------+-------------------------------------------+ | ||
220 | + | ||
221 | +Output layout in the dsm memory page: | ||
222 | + | ||
223 | + +----------+--------+--------+-------------------------------------------+ | ||
224 | + | Field | Length | Offset | Description | | ||
225 | + +----------+--------+--------+-------------------------------------------+ | ||
226 | + | length | 4 | 0 | length of entire returned data | | ||
227 | + | | | | (including this header) | | ||
228 | + +----------+--------+--------+-------------------------------------------+ | ||
229 | + | | | | return status codes | | ||
230 | + | | | | | | ||
231 | + | | | | - 0x0 - success | | ||
232 | + | | | | - 0x100 - error caused by NFIT update | | ||
233 | + | status | 4 | 4 | while read by _FIT wasn't completed | | ||
234 | + | | | | - other codes follow Chapter 3 in | | ||
235 | + | | | | DSM Spec Rev1 | | ||
236 | + +----------+--------+--------+-------------------------------------------+ | ||
237 | + | fit data | Varies | 8 | contains FIT data. This field is present | | ||
238 | + | | | | if status field is 0. | | ||
239 | + +----------+--------+--------+-------------------------------------------+ | ||
240 | + | ||
241 | +The FIT offset is maintained by the OSPM itself, current offset plus | ||
242 | +the size of the fit data returned by the function is the next offset | ||
243 | +OSPM should read. When all FIT data has been read out, zero fit data | ||
244 | +size is returned. | ||
245 | + | ||
246 | +If it returns status code 0x100, OSPM should restart to read FIT (read | ||
247 | +from offset 0 again). | ||
248 | diff --git a/docs/specs/acpi_nvdimm.txt b/docs/specs/acpi_nvdimm.txt | ||
249 | deleted file mode 100644 | ||
250 | index XXXXXXX..XXXXXXX | ||
251 | --- a/docs/specs/acpi_nvdimm.txt | ||
252 | +++ /dev/null | ||
253 | @@ -XXX,XX +XXX,XX @@ | ||
254 | -QEMU<->ACPI BIOS NVDIMM interface | ||
255 | ---------------------------------- | ||
256 | - | ||
257 | -QEMU supports NVDIMM via ACPI. This document describes the basic concepts of | ||
258 | -NVDIMM ACPI and the interface between QEMU and the ACPI BIOS. | ||
259 | - | ||
260 | -NVDIMM ACPI Background | ||
261 | ----------------------- | ||
262 | -NVDIMM is introduced in ACPI 6.0 which defines an NVDIMM root device under | ||
263 | -_SB scope with a _HID of “ACPI0012”. For each NVDIMM present or intended | ||
264 | -to be supported by platform, platform firmware also exposes an ACPI | ||
265 | -Namespace Device under the root device. | ||
266 | - | ||
267 | -The NVDIMM child devices under the NVDIMM root device are defined with _ADR | ||
268 | -corresponding to the NFIT device handle. The NVDIMM root device and the | ||
269 | -NVDIMM devices can have device specific methods (_DSM) to provide additional | ||
270 | -functions specific to a particular NVDIMM implementation. | ||
271 | - | ||
272 | -This is an example from ACPI 6.0, a platform contains one NVDIMM: | ||
273 | - | ||
274 | -Scope (\_SB){ | ||
275 | - Device (NVDR) // Root device | ||
276 | - { | ||
277 | - Name (_HID, “ACPI0012”) | ||
278 | - Method (_STA) {...} | ||
279 | - Method (_FIT) {...} | ||
280 | - Method (_DSM, ...) {...} | ||
281 | - Device (NVD) | ||
282 | - { | ||
283 | - Name(_ADR, h) //where h is NFIT Device Handle for this NVDIMM | ||
284 | - Method (_DSM, ...) {...} | ||
285 | - } | ||
286 | - } | ||
287 | -} | ||
288 | - | ||
289 | -Method supported on both NVDIMM root device and NVDIMM device | ||
290 | -_DSM (Device Specific Method) | ||
291 | - It is a control method that enables devices to provide device specific | ||
292 | - control functions that are consumed by the device driver. | ||
293 | - The NVDIMM DSM specification can be found at: | ||
294 | - http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf | ||
295 | - | ||
296 | - Arguments: | ||
297 | - Arg0 – A Buffer containing a UUID (16 Bytes) | ||
298 | - Arg1 – An Integer containing the Revision ID (4 Bytes) | ||
299 | - Arg2 – An Integer containing the Function Index (4 Bytes) | ||
300 | - Arg3 – A package containing parameters for the function specified by the | ||
301 | - UUID, Revision ID, and Function Index | ||
302 | - | ||
303 | - Return Value: | ||
304 | - If Function Index = 0, a Buffer containing a function index bitfield. | ||
305 | - Otherwise, the return value and type depends on the UUID, revision ID | ||
306 | - and function index which are described in the DSM specification. | ||
307 | - | ||
308 | -Methods on NVDIMM ROOT Device | ||
309 | -_FIT(Firmware Interface Table) | ||
310 | - It evaluates to a buffer returning data in the format of a series of NFIT | ||
311 | - Type Structure. | ||
312 | - | ||
313 | - Arguments: None | ||
314 | - | ||
315 | - Return Value: | ||
316 | - A Buffer containing a list of NFIT Type structure entries. | ||
317 | - | ||
318 | - The detailed definition of the structure can be found at ACPI 6.0: 5.2.25 | ||
319 | - NVDIMM Firmware Interface Table (NFIT). | ||
320 | - | ||
321 | -QEMU NVDIMM Implementation | ||
322 | -========================== | ||
323 | -QEMU uses 4 bytes IO Port starting from 0x0a18 and a RAM-based memory page | ||
324 | -for NVDIMM ACPI. | ||
325 | - | ||
326 | -Memory: | ||
327 | - QEMU uses BIOS Linker/loader feature to ask BIOS to allocate a memory | ||
328 | - page and dynamically patch its address into an int32 object named "MEMA" | ||
329 | - in ACPI. | ||
330 | - | ||
331 | - This page is RAM-based and it is used to transfer data between _DSM | ||
332 | - method and QEMU. If ACPI has control, this pages is owned by ACPI which | ||
333 | - writes _DSM input data to it, otherwise, it is owned by QEMU which | ||
334 | - emulates _DSM access and writes the output data to it. | ||
335 | - | ||
336 | - ACPI writes _DSM Input Data (based on the offset in the page): | ||
337 | - [0x0 - 0x3]: 4 bytes, NVDIMM Device Handle. | ||
338 | - | ||
339 | - The handle is completely QEMU internal thing, the values in | ||
340 | - range [1, 0xFFFF] indicate nvdimm device. Other values are | ||
341 | - reserved for other purposes. | ||
342 | - | ||
343 | - Reserved handles: | ||
344 | - 0 is reserved for nvdimm root device named NVDR. | ||
345 | - 0x10000 is reserved for QEMU internal DSM function called on | ||
346 | - the root device. | ||
347 | - | ||
348 | - [0x4 - 0x7]: 4 bytes, Revision ID, that is the Arg1 of _DSM method. | ||
349 | - [0x8 - 0xB]: 4 bytes. Function Index, that is the Arg2 of _DSM method. | ||
350 | - [0xC - 0xFFF]: 4084 bytes, the Arg3 of _DSM method. | ||
351 | - | ||
352 | - QEMU Writes Output Data (based on the offset in the page): | ||
353 | - [0x0 - 0x3]: 4 bytes, the length of result | ||
354 | - [0x4 - 0xFFF]: 4092 bytes, the DSM result filled by QEMU | ||
355 | - | ||
356 | -IO Port 0x0a18 - 0xa1b: | ||
357 | - ACPI writes the address of the memory page allocated by BIOS to this | ||
358 | - port then QEMU gets the control and fills the result in the memory page. | ||
359 | - | ||
360 | - write Access: | ||
361 | - [0x0a18 - 0xa1b]: 4 bytes, the address of the memory page allocated | ||
362 | - by BIOS. | ||
363 | - | ||
364 | -_DSM process diagram: | ||
365 | ---------------------- | ||
366 | -"MEMA" indicates the address of memory page allocated by BIOS. | ||
367 | - | ||
368 | - +----------------------+ +-----------------------+ | ||
369 | - | 1. OSPM | | 2. OSPM | | ||
370 | - | save _DSM input data | | write "MEMA" to | Exit to QEMU | ||
371 | - | to the page +----->| IO port 0x0a18 +------------+ | ||
372 | - | indicated by "MEMA" | | | | | ||
373 | - +----------------------+ +-----------------------+ | | ||
374 | - | | ||
375 | - v | ||
376 | - +------------- ----+ +-----------+ +------------------+--------+ | ||
377 | - | 5 QEMU | | 4 QEMU | | 3. QEMU | | ||
378 | - | write _DSM result | | emulate | | get _DSM input data from | | ||
379 | - | to the page +<------+ _DSM +<-----+ the page indicated by the | | ||
380 | - | | | | | value from the IO port | | ||
381 | - +--------+-----------+ +-----------+ +---------------------------+ | ||
382 | - | | ||
383 | - | Enter Guest | ||
384 | - | | ||
385 | - v | ||
386 | - +--------------------------+ +--------------+ | ||
387 | - | 6 OSPM | | 7 OSPM | | ||
388 | - | result size is returned | | _DSM return | | ||
389 | - | by reading DSM +----->+ | | ||
390 | - | result from the page | | | | ||
391 | - +--------------------------+ +--------------+ | ||
392 | - | ||
393 | -NVDIMM hotplug | ||
394 | --------------- | ||
395 | -ACPI BIOS GPE.4 handler is dedicated for notifying OS about nvdimm device | ||
396 | -hot-add event. | ||
397 | - | ||
398 | -QEMU internal use only _DSM function | ||
399 | ------------------------------------- | ||
400 | -1) Read FIT | ||
401 | - _FIT method uses _DSM method to fetch NFIT structures blob from QEMU | ||
402 | - in 1 page sized increments which are then concatenated and returned | ||
403 | - as _FIT method result. | ||
404 | - | ||
405 | - Input parameters: | ||
406 | - Arg0 – UUID {set to 648B9CF2-CDA1-4312-8AD9-49C4AF32BD62} | ||
407 | - Arg1 – Revision ID (set to 1) | ||
408 | - Arg2 - Function Index, 0x1 | ||
409 | - Arg3 - A package containing a buffer whose layout is as follows: | ||
410 | - | ||
411 | - +----------+--------+--------+-------------------------------------------+ | ||
412 | - | Field | Length | Offset | Description | | ||
413 | - +----------+--------+--------+-------------------------------------------+ | ||
414 | - | offset | 4 | 0 | offset in QEMU's NFIT structures blob to | | ||
415 | - | | | | read from | | ||
416 | - +----------+--------+--------+-------------------------------------------+ | ||
417 | - | ||
418 | - Output layout in the dsm memory page: | ||
419 | - +----------+--------+--------+-------------------------------------------+ | ||
420 | - | Field | Length | Offset | Description | | ||
421 | - +----------+--------+--------+-------------------------------------------+ | ||
422 | - | length | 4 | 0 | length of entire returned data | | ||
423 | - | | | | (including this header) | | ||
424 | - +----------+-----------------+-------------------------------------------+ | ||
425 | - | | | | return status codes | | ||
426 | - | | | | 0x0 - success | | ||
427 | - | | | | 0x100 - error caused by NFIT update while | | ||
428 | - | status | 4 | 4 | read by _FIT wasn't completed, other | | ||
429 | - | | | | codes follow Chapter 3 in DSM Spec Rev1 | | ||
430 | - +----------+-----------------+-------------------------------------------+ | ||
431 | - | fit data | Varies | 8 | contains FIT data, this field is present | | ||
432 | - | | | | if status field is 0; | | ||
433 | - +----------+--------+--------+-------------------------------------------+ | ||
434 | - | ||
435 | - The FIT offset is maintained by the OSPM itself, current offset plus | ||
436 | - the size of the fit data returned by the function is the next offset | ||
437 | - OSPM should read. When all FIT data has been read out, zero fit data | ||
438 | - size is returned. | ||
439 | - | ||
440 | - If it returns status code 0x100, OSPM should restart to read FIT (read | ||
441 | - from offset 0 again). | ||
442 | diff --git a/docs/specs/index.rst b/docs/specs/index.rst | ||
443 | index XXXXXXX..XXXXXXX 100644 | ||
444 | --- a/docs/specs/index.rst | ||
445 | +++ b/docs/specs/index.rst | ||
446 | @@ -XXX,XX +XXX,XX @@ guest hardware that is specific to QEMU. | ||
447 | acpi_cpu_hotplug | ||
448 | acpi_mem_hotplug | ||
449 | acpi_pci_hotplug | ||
450 | + acpi_nvdimm | ||
451 | -- | ||
452 | 2.20.1 | ||
453 | |||
454 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Add entries for the ACPI specs documents in docs/specs to | ||
2 | appropriate sections of MAINTAINERS. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
6 | Message-id: 20210727170414.3368-6-peter.maydell@linaro.org | ||
7 | --- | ||
8 | MAINTAINERS | 5 +++++ | ||
9 | 1 file changed, 5 insertions(+) | ||
10 | |||
11 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/MAINTAINERS | ||
14 | +++ b/MAINTAINERS | ||
15 | @@ -XXX,XX +XXX,XX @@ F: qapi/acpi.json | ||
16 | F: tests/qtest/bios-tables-test* | ||
17 | F: tests/qtest/acpi-utils.[hc] | ||
18 | F: tests/data/acpi/ | ||
19 | +F: docs/specs/acpi_cpu_hotplug.rst | ||
20 | +F: docs/specs/acpi_mem_hotplug.rst | ||
21 | +F: docs/specs/acpi_pci_hotplug.rst | ||
22 | +F: docs/specs/acpi_hw_reduced_hotplug.rst | ||
23 | |||
24 | ACPI/HEST/GHES | ||
25 | R: Dongjiu Geng <gengdongjiu1@gmail.com> | ||
26 | @@ -XXX,XX +XXX,XX @@ F: hw/acpi/nvdimm.c | ||
27 | F: hw/mem/nvdimm.c | ||
28 | F: include/hw/mem/nvdimm.h | ||
29 | F: docs/nvdimm.txt | ||
30 | +F: docs/specs/acpi_nvdimm.rst | ||
31 | |||
32 | e1000x | ||
33 | M: Dmitry Fleytman <dmitry.fleytman@gmail.com> | ||
34 | -- | ||
35 | 2.20.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of using an ifdef ladder in arch_init.c (which we then have | ||
2 | to manually update every time we add or remove a target | ||
3 | architecture), have meson.build put "#define QEMU_ARCH QEMU_ARCH_FOO" | ||
4 | in the config-target.h file. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210730105947.28215-5-peter.maydell@linaro.org | ||
10 | --- | ||
11 | meson.build | 2 ++ | ||
12 | softmmu/arch_init.c | 41 ----------------------------------------- | ||
13 | 2 files changed, 2 insertions(+), 41 deletions(-) | ||
14 | |||
15 | diff --git a/meson.build b/meson.build | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/meson.build | ||
18 | +++ b/meson.build | ||
19 | @@ -XXX,XX +XXX,XX @@ foreach target : target_dirs | ||
20 | config_target_data.set(k, v) | ||
21 | endif | ||
22 | endforeach | ||
23 | + config_target_data.set('QEMU_ARCH', | ||
24 | + 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper()) | ||
25 | config_target_h += {target: configure_file(output: target + '-config-target.h', | ||
26 | configuration: config_target_data)} | ||
27 | |||
28 | diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/softmmu/arch_init.c | ||
31 | +++ b/softmmu/arch_init.c | ||
32 | @@ -XXX,XX +XXX,XX @@ int graphic_height = 600; | ||
33 | int graphic_depth = 32; | ||
34 | #endif | ||
35 | |||
36 | - | ||
37 | -#if defined(TARGET_ALPHA) | ||
38 | -#define QEMU_ARCH QEMU_ARCH_ALPHA | ||
39 | -#elif defined(TARGET_ARM) | ||
40 | -#define QEMU_ARCH QEMU_ARCH_ARM | ||
41 | -#elif defined(TARGET_CRIS) | ||
42 | -#define QEMU_ARCH QEMU_ARCH_CRIS | ||
43 | -#elif defined(TARGET_HPPA) | ||
44 | -#define QEMU_ARCH QEMU_ARCH_HPPA | ||
45 | -#elif defined(TARGET_I386) | ||
46 | -#define QEMU_ARCH QEMU_ARCH_I386 | ||
47 | -#elif defined(TARGET_M68K) | ||
48 | -#define QEMU_ARCH QEMU_ARCH_M68K | ||
49 | -#elif defined(TARGET_MICROBLAZE) | ||
50 | -#define QEMU_ARCH QEMU_ARCH_MICROBLAZE | ||
51 | -#elif defined(TARGET_MIPS) | ||
52 | -#define QEMU_ARCH QEMU_ARCH_MIPS | ||
53 | -#elif defined(TARGET_NIOS2) | ||
54 | -#define QEMU_ARCH QEMU_ARCH_NIOS2 | ||
55 | -#elif defined(TARGET_OPENRISC) | ||
56 | -#define QEMU_ARCH QEMU_ARCH_OPENRISC | ||
57 | -#elif defined(TARGET_PPC) | ||
58 | -#define QEMU_ARCH QEMU_ARCH_PPC | ||
59 | -#elif defined(TARGET_RISCV) | ||
60 | -#define QEMU_ARCH QEMU_ARCH_RISCV | ||
61 | -#elif defined(TARGET_RX) | ||
62 | -#define QEMU_ARCH QEMU_ARCH_RX | ||
63 | -#elif defined(TARGET_S390X) | ||
64 | -#define QEMU_ARCH QEMU_ARCH_S390X | ||
65 | -#elif defined(TARGET_SH4) | ||
66 | -#define QEMU_ARCH QEMU_ARCH_SH4 | ||
67 | -#elif defined(TARGET_SPARC) | ||
68 | -#define QEMU_ARCH QEMU_ARCH_SPARC | ||
69 | -#elif defined(TARGET_TRICORE) | ||
70 | -#define QEMU_ARCH QEMU_ARCH_TRICORE | ||
71 | -#elif defined(TARGET_XTENSA) | ||
72 | -#define QEMU_ARCH QEMU_ARCH_XTENSA | ||
73 | -#elif defined(TARGET_AVR) | ||
74 | -#define QEMU_ARCH QEMU_ARCH_AVR | ||
75 | -#endif | ||
76 | - | ||
77 | const uint32_t arch_type = QEMU_ARCH; | ||
78 | -- | ||
79 | 2.20.1 | ||
80 | |||
81 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | arch_init.h only defines the QEMU_ARCH_* enumeration and the | ||
2 | arch_type global. Don't include it in files that don't use those. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20210730105947.28215-8-peter.maydell@linaro.org | ||
9 | --- | ||
10 | blockdev.c | 1 - | ||
11 | hw/i386/pc.c | 1 - | ||
12 | hw/i386/pc_piix.c | 1 - | ||
13 | hw/i386/pc_q35.c | 1 - | ||
14 | hw/mips/jazz.c | 1 - | ||
15 | hw/mips/malta.c | 1 - | ||
16 | hw/ppc/prep.c | 1 - | ||
17 | hw/riscv/sifive_e.c | 1 - | ||
18 | hw/riscv/sifive_u.c | 1 - | ||
19 | hw/riscv/spike.c | 1 - | ||
20 | hw/riscv/virt.c | 1 - | ||
21 | monitor/qmp-cmds.c | 1 - | ||
22 | target/ppc/cpu_init.c | 1 - | ||
23 | target/s390x/cpu-sysemu.c | 1 - | ||
24 | 14 files changed, 14 deletions(-) | ||
25 | |||
26 | diff --git a/blockdev.c b/blockdev.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/blockdev.c | ||
29 | +++ b/blockdev.c | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | #include "sysemu/iothread.h" | ||
32 | #include "block/block_int.h" | ||
33 | #include "block/trace.h" | ||
34 | -#include "sysemu/arch_init.h" | ||
35 | #include "sysemu/runstate.h" | ||
36 | #include "sysemu/replay.h" | ||
37 | #include "qemu/cutils.h" | ||
38 | diff --git a/hw/i386/pc.c b/hw/i386/pc.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/i386/pc.c | ||
41 | +++ b/hw/i386/pc.c | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #include "hw/xen/start_info.h" | ||
44 | #include "ui/qemu-spice.h" | ||
45 | #include "exec/memory.h" | ||
46 | -#include "sysemu/arch_init.h" | ||
47 | #include "qemu/bitmap.h" | ||
48 | #include "qemu/config-file.h" | ||
49 | #include "qemu/error-report.h" | ||
50 | diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/i386/pc_piix.c | ||
53 | +++ b/hw/i386/pc_piix.c | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | #include "sysemu/kvm.h" | ||
56 | #include "hw/kvm/clock.h" | ||
57 | #include "hw/sysbus.h" | ||
58 | -#include "sysemu/arch_init.h" | ||
59 | #include "hw/i2c/smbus_eeprom.h" | ||
60 | #include "hw/xen/xen-x86.h" | ||
61 | #include "exec/memory.h" | ||
62 | diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/i386/pc_q35.c | ||
65 | +++ b/hw/i386/pc_q35.c | ||
66 | @@ -XXX,XX +XXX,XX @@ | ||
67 | #include "qemu/osdep.h" | ||
68 | #include "qemu/units.h" | ||
69 | #include "hw/loader.h" | ||
70 | -#include "sysemu/arch_init.h" | ||
71 | #include "hw/i2c/smbus_eeprom.h" | ||
72 | #include "hw/rtc/mc146818rtc.h" | ||
73 | #include "sysemu/kvm.h" | ||
74 | diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/hw/mips/jazz.c | ||
77 | +++ b/hw/mips/jazz.c | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | #include "hw/isa/isa.h" | ||
80 | #include "hw/block/fdc.h" | ||
81 | #include "sysemu/sysemu.h" | ||
82 | -#include "sysemu/arch_init.h" | ||
83 | #include "hw/boards.h" | ||
84 | #include "net/net.h" | ||
85 | #include "hw/scsi/esp.h" | ||
86 | diff --git a/hw/mips/malta.c b/hw/mips/malta.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/mips/malta.c | ||
89 | +++ b/hw/mips/malta.c | ||
90 | @@ -XXX,XX +XXX,XX @@ | ||
91 | #include "hw/mips/mips.h" | ||
92 | #include "hw/mips/cpudevs.h" | ||
93 | #include "hw/pci/pci.h" | ||
94 | -#include "sysemu/arch_init.h" | ||
95 | #include "qemu/log.h" | ||
96 | #include "hw/mips/bios.h" | ||
97 | #include "hw/ide.h" | ||
98 | diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/hw/ppc/prep.c | ||
101 | +++ b/hw/ppc/prep.c | ||
102 | @@ -XXX,XX +XXX,XX @@ | ||
103 | #include "hw/rtc/mc146818rtc.h" | ||
104 | #include "hw/isa/pc87312.h" | ||
105 | #include "hw/qdev-properties.h" | ||
106 | -#include "sysemu/arch_init.h" | ||
107 | #include "sysemu/kvm.h" | ||
108 | #include "sysemu/reset.h" | ||
109 | #include "trace.h" | ||
110 | diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/hw/riscv/sifive_e.c | ||
113 | +++ b/hw/riscv/sifive_e.c | ||
114 | @@ -XXX,XX +XXX,XX @@ | ||
115 | #include "hw/intc/sifive_plic.h" | ||
116 | #include "hw/misc/sifive_e_prci.h" | ||
117 | #include "chardev/char.h" | ||
118 | -#include "sysemu/arch_init.h" | ||
119 | #include "sysemu/sysemu.h" | ||
120 | |||
121 | static const MemMapEntry sifive_e_memmap[] = { | ||
122 | diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/hw/riscv/sifive_u.c | ||
125 | +++ b/hw/riscv/sifive_u.c | ||
126 | @@ -XXX,XX +XXX,XX @@ | ||
127 | #include "hw/intc/sifive_plic.h" | ||
128 | #include "chardev/char.h" | ||
129 | #include "net/eth.h" | ||
130 | -#include "sysemu/arch_init.h" | ||
131 | #include "sysemu/device_tree.h" | ||
132 | #include "sysemu/runstate.h" | ||
133 | #include "sysemu/sysemu.h" | ||
134 | diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c | ||
135 | index XXXXXXX..XXXXXXX 100644 | ||
136 | --- a/hw/riscv/spike.c | ||
137 | +++ b/hw/riscv/spike.c | ||
138 | @@ -XXX,XX +XXX,XX @@ | ||
139 | #include "hw/char/riscv_htif.h" | ||
140 | #include "hw/intc/sifive_clint.h" | ||
141 | #include "chardev/char.h" | ||
142 | -#include "sysemu/arch_init.h" | ||
143 | #include "sysemu/device_tree.h" | ||
144 | #include "sysemu/sysemu.h" | ||
145 | |||
146 | diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/hw/riscv/virt.c | ||
149 | +++ b/hw/riscv/virt.c | ||
150 | @@ -XXX,XX +XXX,XX @@ | ||
151 | #include "hw/intc/sifive_plic.h" | ||
152 | #include "hw/misc/sifive_test.h" | ||
153 | #include "chardev/char.h" | ||
154 | -#include "sysemu/arch_init.h" | ||
155 | #include "sysemu/device_tree.h" | ||
156 | #include "sysemu/sysemu.h" | ||
157 | #include "hw/pci/pci.h" | ||
158 | diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/monitor/qmp-cmds.c | ||
161 | +++ b/monitor/qmp-cmds.c | ||
162 | @@ -XXX,XX +XXX,XX @@ | ||
163 | #include "sysemu/kvm.h" | ||
164 | #include "sysemu/runstate.h" | ||
165 | #include "sysemu/runstate-action.h" | ||
166 | -#include "sysemu/arch_init.h" | ||
167 | #include "sysemu/blockdev.h" | ||
168 | #include "sysemu/block-backend.h" | ||
169 | #include "qapi/error.h" | ||
170 | diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/target/ppc/cpu_init.c | ||
173 | +++ b/target/ppc/cpu_init.c | ||
174 | @@ -XXX,XX +XXX,XX @@ | ||
175 | #include "disas/dis-asm.h" | ||
176 | #include "exec/gdbstub.h" | ||
177 | #include "kvm_ppc.h" | ||
178 | -#include "sysemu/arch_init.h" | ||
179 | #include "sysemu/cpus.h" | ||
180 | #include "sysemu/hw_accel.h" | ||
181 | #include "sysemu/tcg.h" | ||
182 | diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c | ||
183 | index XXXXXXX..XXXXXXX 100644 | ||
184 | --- a/target/s390x/cpu-sysemu.c | ||
185 | +++ b/target/s390x/cpu-sysemu.c | ||
186 | @@ -XXX,XX +XXX,XX @@ | ||
187 | |||
188 | #include "hw/s390x/pv.h" | ||
189 | #include "hw/boards.h" | ||
190 | -#include "sysemu/arch_init.h" | ||
191 | #include "sysemu/sysemu.h" | ||
192 | #include "sysemu/tcg.h" | ||
193 | #include "hw/core/sysemu-cpu-ops.h" | ||
194 | -- | ||
195 | 2.20.1 | ||
196 | |||
197 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We added a stub for the arch_type global in commit 5964ed56d9a1 so | ||
2 | that we could compile blockdev.c into the tools. However, in commit | ||
3 | 9db1d3a2be9bf we removed the only use of arch_type from blockdev.c. | ||
4 | The stub is therefore no longer needed, and we can delete it again, | ||
5 | together with the QEMU_ARCH_NONE value that only the stub was using. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210730105947.28215-9-peter.maydell@linaro.org | ||
11 | --- | ||
12 | include/sysemu/arch_init.h | 2 -- | ||
13 | stubs/arch_type.c | 4 ---- | ||
14 | stubs/meson.build | 1 - | ||
15 | 3 files changed, 7 deletions(-) | ||
16 | delete mode 100644 stubs/arch_type.c | ||
17 | |||
18 | diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/sysemu/arch_init.h | ||
21 | +++ b/include/sysemu/arch_init.h | ||
22 | @@ -XXX,XX +XXX,XX @@ enum { | ||
23 | QEMU_ARCH_RX = (1 << 20), | ||
24 | QEMU_ARCH_AVR = (1 << 21), | ||
25 | QEMU_ARCH_HEXAGON = (1 << 22), | ||
26 | - | ||
27 | - QEMU_ARCH_NONE = (1 << 31), | ||
28 | }; | ||
29 | |||
30 | extern const uint32_t arch_type; | ||
31 | diff --git a/stubs/arch_type.c b/stubs/arch_type.c | ||
32 | deleted file mode 100644 | ||
33 | index XXXXXXX..XXXXXXX | ||
34 | --- a/stubs/arch_type.c | ||
35 | +++ /dev/null | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | -#include "qemu/osdep.h" | ||
38 | -#include "sysemu/arch_init.h" | ||
39 | - | ||
40 | -const uint32_t arch_type = QEMU_ARCH_NONE; | ||
41 | diff --git a/stubs/meson.build b/stubs/meson.build | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/stubs/meson.build | ||
44 | +++ b/stubs/meson.build | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | -stub_ss.add(files('arch_type.c')) | ||
47 | stub_ss.add(files('bdrv-next-monitor-owned.c')) | ||
48 | stub_ss.add(files('blk-commit-all.c')) | ||
49 | stub_ss.add(files('blk-exp-close-all.c')) | ||
50 | -- | ||
51 | 2.20.1 | ||
52 | |||
53 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The gunzip() function reads various fields from a passed in source | ||
2 | buffer in order to skip a header before passing the actual compressed | ||
3 | data to the zlib inflate() function. It does check whether the | ||
4 | passed in buffer is too small, but unfortunately it checks that only | ||
5 | after reading bytes from the src buffer, so it could read off the end | ||
6 | of the buffer. | ||
7 | 1 | ||
8 | You can see this with valgrind: | ||
9 | |||
10 | $ printf "%b" '\x1f\x8b' > /tmp/image | ||
11 | $ valgrind qemu-system-aarch64 -display none -M virt -cpu max -kernel /tmp/image | ||
12 | [...] | ||
13 | ==19224== Invalid read of size 1 | ||
14 | ==19224== at 0x67302E: gunzip (loader.c:558) | ||
15 | ==19224== by 0x673907: load_image_gzipped_buffer (loader.c:788) | ||
16 | ==19224== by 0xA18032: load_aarch64_image (boot.c:932) | ||
17 | ==19224== by 0xA18489: arm_setup_direct_kernel_boot (boot.c:1063) | ||
18 | ==19224== by 0xA18D90: arm_load_kernel (boot.c:1317) | ||
19 | ==19224== by 0x9F3651: machvirt_init (virt.c:2114) | ||
20 | ==19224== by 0x794B7A: machine_run_board_init (machine.c:1272) | ||
21 | ==19224== by 0xD5CAD3: qemu_init_board (vl.c:2618) | ||
22 | ==19224== by 0xD5CCA6: qmp_x_exit_preconfig (vl.c:2692) | ||
23 | ==19224== by 0xD5F32E: qemu_init (vl.c:3713) | ||
24 | ==19224== by 0x5ADDB1: main (main.c:49) | ||
25 | ==19224== Address 0x3802a873 is 0 bytes after a block of size 3 alloc'd | ||
26 | ==19224== at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) | ||
27 | ==19224== by 0x61E7657: g_file_get_contents (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4) | ||
28 | ==19224== by 0x673895: load_image_gzipped_buffer (loader.c:771) | ||
29 | ==19224== by 0xA18032: load_aarch64_image (boot.c:932) | ||
30 | ==19224== by 0xA18489: arm_setup_direct_kernel_boot (boot.c:1063) | ||
31 | ==19224== by 0xA18D90: arm_load_kernel (boot.c:1317) | ||
32 | ==19224== by 0x9F3651: machvirt_init (virt.c:2114) | ||
33 | ==19224== by 0x794B7A: machine_run_board_init (machine.c:1272) | ||
34 | ==19224== by 0xD5CAD3: qemu_init_board (vl.c:2618) | ||
35 | ==19224== by 0xD5CCA6: qmp_x_exit_preconfig (vl.c:2692) | ||
36 | ==19224== by 0xD5F32E: qemu_init (vl.c:3713) | ||
37 | ==19224== by 0x5ADDB1: main (main.c:49) | ||
38 | |||
39 | Check that we have enough bytes of data to read the header bytes that | ||
40 | we read before we read them. | ||
41 | |||
42 | Fixes: Coverity 1458997 | ||
43 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
44 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
45 | Message-id: 20210812141803.20913-1-peter.maydell@linaro.org | ||
46 | --- | ||
47 | hw/core/loader.c | 35 +++++++++++++++++++++++++---------- | ||
48 | 1 file changed, 25 insertions(+), 10 deletions(-) | ||
49 | |||
50 | diff --git a/hw/core/loader.c b/hw/core/loader.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/core/loader.c | ||
53 | +++ b/hw/core/loader.c | ||
54 | @@ -XXX,XX +XXX,XX @@ ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen) | ||
55 | |||
56 | /* skip header */ | ||
57 | i = 10; | ||
58 | + if (srclen < 4) { | ||
59 | + goto toosmall; | ||
60 | + } | ||
61 | flags = src[3]; | ||
62 | if (src[2] != DEFLATED || (flags & RESERVED) != 0) { | ||
63 | puts ("Error: Bad gzipped data\n"); | ||
64 | return -1; | ||
65 | } | ||
66 | - if ((flags & EXTRA_FIELD) != 0) | ||
67 | + if ((flags & EXTRA_FIELD) != 0) { | ||
68 | + if (srclen < 12) { | ||
69 | + goto toosmall; | ||
70 | + } | ||
71 | i = 12 + src[10] + (src[11] << 8); | ||
72 | - if ((flags & ORIG_NAME) != 0) | ||
73 | - while (src[i++] != 0) | ||
74 | - ; | ||
75 | - if ((flags & COMMENT) != 0) | ||
76 | - while (src[i++] != 0) | ||
77 | - ; | ||
78 | - if ((flags & HEAD_CRC) != 0) | ||
79 | + } | ||
80 | + if ((flags & ORIG_NAME) != 0) { | ||
81 | + while (i < srclen && src[i++] != 0) { | ||
82 | + /* do nothing */ | ||
83 | + } | ||
84 | + } | ||
85 | + if ((flags & COMMENT) != 0) { | ||
86 | + while (i < srclen && src[i++] != 0) { | ||
87 | + /* do nothing */ | ||
88 | + } | ||
89 | + } | ||
90 | + if ((flags & HEAD_CRC) != 0) { | ||
91 | i += 2; | ||
92 | + } | ||
93 | if (i >= srclen) { | ||
94 | - puts ("Error: gunzip out of data in header\n"); | ||
95 | - return -1; | ||
96 | + goto toosmall; | ||
97 | } | ||
98 | |||
99 | s.zalloc = zalloc; | ||
100 | @@ -XXX,XX +XXX,XX @@ ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen) | ||
101 | inflateEnd(&s); | ||
102 | |||
103 | return dstbytes; | ||
104 | + | ||
105 | +toosmall: | ||
106 | + puts("Error: gunzip out of data in header\n"); | ||
107 | + return -1; | ||
108 | } | ||
109 | |||
110 | /* Load a U-Boot image. */ | ||
111 | -- | ||
112 | 2.20.1 | ||
113 | |||
114 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The realpath() function can return NULL on error, so we need to check | ||
2 | for it to avoid crashing when we try to strstr() into it. | ||
3 | This can happen if we run out of memory, or if /sys/ is not mounted, | ||
4 | among other situations. | ||
5 | 1 | ||
6 | Fixes: Coverity 1459913, 1460474 | ||
7 | Fixes: ce317be98db0 ("exec: fetch the alignment of Linux devdax pmem character device nodes") | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Jingqi Liu <jingqi.liu@intel.com> | ||
10 | Message-id: 20210812151525.31456-1-peter.maydell@linaro.org | ||
11 | --- | ||
12 | softmmu/physmem.c | 3 +++ | ||
13 | 1 file changed, 3 insertions(+) | ||
14 | |||
15 | diff --git a/softmmu/physmem.c b/softmmu/physmem.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/softmmu/physmem.c | ||
18 | +++ b/softmmu/physmem.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static int64_t get_file_align(int fd) | ||
20 | path = g_strdup_printf("/sys/dev/char/%d:%d", | ||
21 | major(st.st_rdev), minor(st.st_rdev)); | ||
22 | rpath = realpath(path, NULL); | ||
23 | + if (!rpath) { | ||
24 | + return -errno; | ||
25 | + } | ||
26 | |||
27 | rc = daxctl_new(&ctx); | ||
28 | if (rc) { | ||
29 | -- | ||
30 | 2.20.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We don't currently zero-initialize the 'struct sockaddr_in' that | ||
2 | parse_host_port() fills in, so any fields we don't explicitly | ||
3 | initialize might be left as random garbage. POSIX states that | ||
4 | implementations may define extensions in sockaddr_in, and that those | ||
5 | extensions must not trigger if zero-initialized. So not zero | ||
6 | initializing might result in inadvertently triggering an impdef | ||
7 | extension. | ||
8 | 1 | ||
9 | memset() the sockaddr_in before we start to fill it in. | ||
10 | |||
11 | Fixes: Coverity CID 1005338 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
14 | Message-id: 20210813150506.7768-2-peter.maydell@linaro.org | ||
15 | --- | ||
16 | net/net.c | 2 ++ | ||
17 | 1 file changed, 2 insertions(+) | ||
18 | |||
19 | diff --git a/net/net.c b/net/net.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/net/net.c | ||
22 | +++ b/net/net.c | ||
23 | @@ -XXX,XX +XXX,XX @@ int parse_host_port(struct sockaddr_in *saddr, const char *str, | ||
24 | const char *addr, *p, *r; | ||
25 | int port, ret = 0; | ||
26 | |||
27 | + memset(saddr, 0, sizeof(*saddr)); | ||
28 | + | ||
29 | substrings = g_strsplit(str, ":", 2); | ||
30 | if (!substrings || !substrings[0] || !substrings[1]) { | ||
31 | error_setg(errp, "host address '%s' doesn't contain ':' " | ||
32 | -- | ||
33 | 2.20.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Zero-initialize sockaddr_in and sockaddr_un structs that we're about | ||
2 | to fill in and pass to bind() or connect(), to ensure we don't leave | ||
3 | possible implementation-defined extension fields as uninitialized | ||
4 | garbage. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
8 | Message-id: 20210813150506.7768-5-peter.maydell@linaro.org | ||
9 | --- | ||
10 | tests/tcg/multiarch/linux-test.c | 4 ++-- | ||
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/tcg/multiarch/linux-test.c | ||
16 | +++ b/tests/tcg/multiarch/linux-test.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void test_time(void) | ||
18 | static int server_socket(void) | ||
19 | { | ||
20 | int val, fd; | ||
21 | - struct sockaddr_in sockaddr; | ||
22 | + struct sockaddr_in sockaddr = {}; | ||
23 | |||
24 | /* server socket */ | ||
25 | fd = chk_error(socket(PF_INET, SOCK_STREAM, 0)); | ||
26 | @@ -XXX,XX +XXX,XX @@ static int server_socket(void) | ||
27 | static int client_socket(uint16_t port) | ||
28 | { | ||
29 | int fd; | ||
30 | - struct sockaddr_in sockaddr; | ||
31 | + struct sockaddr_in sockaddr = {}; | ||
32 | |||
33 | /* server socket */ | ||
34 | fd = chk_error(socket(PF_INET, SOCK_STREAM, 0)); | ||
35 | -- | ||
36 | 2.20.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
1 | In v7A, the HSTR register has a TJDBX bit which traps NS EL0/EL1 | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | access to the JOSCR and JMCR trivial Jazelle registers, and also BXJ. | ||
3 | Implement these traps. In v8A this HSTR bit doesn't exist, so don't | ||
4 | trap for v8A CPUs. | ||
5 | 2 | ||
3 | This feature adds a new register, HCRX_EL2, which controls | ||
4 | many of the newer AArch64 features. So far the register is | ||
5 | effectively RES0, because none of the new features are done. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220517054850.177016-2-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210816180305.20137-3-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | target/arm/cpu.h | 1 + | 12 | target/arm/cpu.h | 20 ++++++++++++++++++ |
11 | target/arm/helper.h | 2 ++ | 13 | target/arm/cpu64.c | 1 + |
12 | target/arm/syndrome.h | 7 +++++++ | 14 | target/arm/helper.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ |
13 | target/arm/helper.c | 17 +++++++++++++++++ | 15 | 3 files changed, 71 insertions(+) |
14 | target/arm/op_helper.c | 16 ++++++++++++++++ | ||
15 | target/arm/translate.c | 12 ++++++++++++ | ||
16 | 6 files changed, 55 insertions(+) | ||
17 | 16 | ||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/cpu.h | 19 | --- a/target/arm/cpu.h |
21 | +++ b/target/arm/cpu.h | 20 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
22 | uint32_t pmsav5_data_ap; /* PMSAv5 MPU data access permissions */ | ||
23 | uint32_t pmsav5_insn_ap; /* PMSAv5 MPU insn access permissions */ | ||
24 | uint64_t hcr_el2; /* Hypervisor configuration register */ | ||
25 | + uint64_t hcrx_el2; /* Extended Hypervisor configuration register */ | ||
26 | uint64_t scr_el3; /* Secure configuration register. */ | ||
27 | union { /* Fault status registers. */ | ||
28 | struct { | ||
22 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 29 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) |
23 | #define SCR_ATA (1U << 26) | 30 | #define HCR_TWEDEN (1ULL << 59) |
24 | 31 | #define HCR_TWEDEL MAKE_64BIT_MASK(60, 4) | |
25 | #define HSTR_TTEE (1 << 16) | 32 | |
26 | +#define HSTR_TJDBX (1 << 17) | 33 | +#define HCRX_ENAS0 (1ULL << 0) |
27 | 34 | +#define HCRX_ENALS (1ULL << 1) | |
28 | /* Return the current FPSCR value. */ | 35 | +#define HCRX_ENASR (1ULL << 2) |
29 | uint32_t vfp_get_fpscr(CPUARMState *env); | 36 | +#define HCRX_FNXS (1ULL << 3) |
30 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 37 | +#define HCRX_FGTNXS (1ULL << 4) |
31 | index XXXXXXX..XXXXXXX 100644 | 38 | +#define HCRX_SMPME (1ULL << 5) |
32 | --- a/target/arm/helper.h | 39 | +#define HCRX_TALLINT (1ULL << 6) |
33 | +++ b/target/arm/helper.h | 40 | +#define HCRX_VINMI (1ULL << 7) |
34 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v7m_vlldm, void, env, i32) | 41 | +#define HCRX_VFNMI (1ULL << 8) |
35 | 42 | +#define HCRX_CMOW (1ULL << 9) | |
36 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | 43 | +#define HCRX_MCE2 (1ULL << 10) |
37 | 44 | +#define HCRX_MSCEN (1ULL << 11) | |
38 | +DEF_HELPER_FLAGS_2(check_bxj_trap, TCG_CALL_NO_WG, void, env, i32) | ||
39 | + | 45 | + |
40 | DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | 46 | #define HPFAR_NS (1ULL << 63) |
41 | DEF_HELPER_3(set_cp_reg, void, env, ptr, i32) | 47 | |
42 | DEF_HELPER_2(get_cp_reg, i32, env, ptr) | 48 | #define SCR_NS (1U << 0) |
43 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h | 49 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_is_el2_enabled(CPUARMState *env) |
44 | index XXXXXXX..XXXXXXX 100644 | 50 | * Not included here is HCR_RW. |
45 | --- a/target/arm/syndrome.h | 51 | */ |
46 | +++ b/target/arm/syndrome.h | 52 | uint64_t arm_hcr_el2_eff(CPUARMState *env); |
47 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | 53 | +uint64_t arm_hcrx_el2_eff(CPUARMState *env); |
48 | EC_ADVSIMDFPACCESSTRAP = 0x07, | 54 | |
49 | EC_FPIDTRAP = 0x08, | 55 | /* Return true if the specified exception level is running in AArch64 state. */ |
50 | EC_PACTRAP = 0x09, | 56 | static inline bool arm_el_is_aa64(CPUARMState *env, int el) |
51 | + EC_BXJTRAP = 0x0a, | 57 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ats1e1(const ARMISARegisters *id) |
52 | EC_CP14RRTTRAP = 0x0c, | 58 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 2; |
53 | EC_BTITRAP = 0x0d, | ||
54 | EC_ILLEGALSTATE = 0x0e, | ||
55 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_btitrap(int btype) | ||
56 | return (EC_BTITRAP << ARM_EL_EC_SHIFT) | btype; | ||
57 | } | 59 | } |
58 | 60 | ||
59 | +static inline uint32_t syn_bxjtrap(int cv, int cond, int rm) | 61 | +static inline bool isar_feature_aa64_hcx(const ARMISARegisters *id) |
60 | +{ | 62 | +{ |
61 | + return (EC_BXJTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL | | 63 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HCX) != 0; |
62 | + (cv << 24) | (cond << 20) | rm; | ||
63 | +} | 64 | +} |
64 | + | 65 | + |
65 | static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) | 66 | static inline bool isar_feature_aa64_uao(const ARMISARegisters *id) |
66 | { | 67 | { |
67 | return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT) | 68 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, UAO) != 0; |
69 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/cpu64.c | ||
72 | +++ b/target/arm/cpu64.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
74 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ | ||
75 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* FEAT_PAN2 */ | ||
76 | t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ | ||
77 | + t = FIELD_DP64(t, ID_AA64MMFR1, HCX, 1); /* FEAT_HCX */ | ||
78 | cpu->isar.id_aa64mmfr1 = t; | ||
79 | |||
80 | t = cpu->isar.id_aa64mmfr2; | ||
68 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 81 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
69 | index XXXXXXX..XXXXXXX 100644 | 82 | index XXXXXXX..XXXXXXX 100644 |
70 | --- a/target/arm/helper.c | 83 | --- a/target/arm/helper.c |
71 | +++ b/target/arm/helper.c | 84 | +++ b/target/arm/helper.c |
72 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_jazelle(CPUARMState *env, const ARMCPRegInfo *ri, | 85 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff(CPUARMState *env) |
73 | return CP_ACCESS_OK; | 86 | return ret; |
74 | } | 87 | } |
75 | 88 | ||
76 | +static CPAccessResult access_joscr_jmcr(CPUARMState *env, | 89 | +static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri, |
77 | + const ARMCPRegInfo *ri, bool isread) | 90 | + uint64_t value) |
78 | +{ | 91 | +{ |
79 | + /* | 92 | + uint64_t valid_mask = 0; |
80 | + * HSTR.TJDBX traps JOSCR and JMCR accesses, but it exists only | 93 | + |
81 | + * in v7A, not in v8A. | 94 | + /* No features adding bits to HCRX are implemented. */ |
82 | + */ | 95 | + |
83 | + if (!arm_feature(env, ARM_FEATURE_V8) && | 96 | + /* Clear RES0 bits. */ |
84 | + arm_current_el(env) < 2 && !arm_is_secure_below_el3(env) && | 97 | + env->cp15.hcrx_el2 = value & valid_mask; |
85 | + (env->cp15.hstr_el2 & HSTR_TJDBX)) { | 98 | +} |
86 | + return CP_ACCESS_TRAP_EL2; | 99 | + |
100 | +static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri, | ||
101 | + bool isread) | ||
102 | +{ | ||
103 | + if (arm_current_el(env) < 3 | ||
104 | + && arm_feature(env, ARM_FEATURE_EL3) | ||
105 | + && !(env->cp15.scr_el3 & SCR_HXEN)) { | ||
106 | + return CP_ACCESS_TRAP_EL3; | ||
87 | + } | 107 | + } |
88 | + return CP_ACCESS_OK; | 108 | + return CP_ACCESS_OK; |
89 | +} | 109 | +} |
90 | + | 110 | + |
91 | static const ARMCPRegInfo jazelle_regs[] = { | 111 | +static const ARMCPRegInfo hcrx_el2_reginfo = { |
92 | { .name = "JIDR", | 112 | + .name = "HCRX_EL2", .state = ARM_CP_STATE_AA64, |
93 | .cp = 14, .crn = 0, .crm = 0, .opc1 = 7, .opc2 = 0, | 113 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 2, |
94 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = { | 114 | + .access = PL2_RW, .writefn = hcrx_write, .accessfn = access_hxen, |
95 | .type = ARM_CP_CONST, .resetvalue = 0 }, | 115 | + .fieldoffset = offsetof(CPUARMState, cp15.hcrx_el2), |
96 | { .name = "JOSCR", | 116 | +}; |
97 | .cp = 14, .crn = 1, .crm = 0, .opc1 = 7, .opc2 = 0, | 117 | + |
98 | + .accessfn = access_joscr_jmcr, | 118 | +/* Return the effective value of HCRX_EL2. */ |
99 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 119 | +uint64_t arm_hcrx_el2_eff(CPUARMState *env) |
100 | { .name = "JMCR", | ||
101 | .cp = 14, .crn = 2, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
102 | + .accessfn = access_joscr_jmcr, | ||
103 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
104 | REGINFO_SENTINEL | ||
105 | }; | ||
106 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/op_helper.c | ||
109 | +++ b/target/arm/op_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ void HELPER(setend)(CPUARMState *env) | ||
111 | arm_rebuild_hflags(env); | ||
112 | } | ||
113 | |||
114 | +void HELPER(check_bxj_trap)(CPUARMState *env, uint32_t rm) | ||
115 | +{ | 120 | +{ |
116 | + /* | 121 | + /* |
117 | + * Only called if in NS EL0 or EL1 for a BXJ for a v7A CPU; | 122 | + * The bits in this register behave as 0 for all purposes other than |
118 | + * check if HSTR.TJDBX means we need to trap to EL2. | 123 | + * direct reads of the register if: |
124 | + * - EL2 is not enabled in the current security state, | ||
125 | + * - SCR_EL3.HXEn is 0. | ||
119 | + */ | 126 | + */ |
120 | + if (env->cp15.hstr_el2 & HSTR_TJDBX) { | 127 | + if (!arm_is_el2_enabled(env) |
121 | + /* | 128 | + || (arm_feature(env, ARM_FEATURE_EL3) |
122 | + * We know the condition code check passed, so take the IMPDEF | 129 | + && !(env->cp15.scr_el3 & SCR_HXEN))) { |
123 | + * choice to always report CV=1 COND 0xe | 130 | + return 0; |
124 | + */ | ||
125 | + uint32_t syn = syn_bxjtrap(1, 0xe, rm); | ||
126 | + raise_exception_ra(env, EXCP_HYP_TRAP, syn, 2, GETPC()); | ||
127 | + } | 131 | + } |
132 | + return env->cp15.hcrx_el2; | ||
128 | +} | 133 | +} |
129 | + | 134 | + |
130 | #ifndef CONFIG_USER_ONLY | 135 | static void cptr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, |
131 | /* Function checks whether WFx (WFI/WFE) instructions are set up to be trapped. | 136 | uint64_t value) |
132 | * The function returns the target EL (1-3) if the instruction is to be trapped; | 137 | { |
133 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 138 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
134 | index XXXXXXX..XXXXXXX 100644 | 139 | define_arm_cp_regs(cpu, zcr_reginfo); |
135 | --- a/target/arm/translate.c | ||
136 | +++ b/target/arm/translate.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static bool trans_BXJ(DisasContext *s, arg_BXJ *a) | ||
138 | if (!ENABLE_ARCH_5J || arm_dc_feature(s, ARM_FEATURE_M)) { | ||
139 | return false; | ||
140 | } | 140 | } |
141 | + /* | 141 | |
142 | + * v7A allows BXJ to be trapped via HSTR.TJDBX. We don't waste a | 142 | + if (cpu_isar_feature(aa64_hcx, cpu)) { |
143 | + * TBFLAGS bit on a basically-never-happens case, so call a helper | 143 | + define_one_arm_cp_reg(cpu, &hcrx_el2_reginfo); |
144 | + * function to check for the trap and raise the exception if needed | ||
145 | + * (passing it the register number for the syndrome value). | ||
146 | + * v8A doesn't have this HSTR bit. | ||
147 | + */ | ||
148 | + if (!arm_dc_feature(s, ARM_FEATURE_V8) && | ||
149 | + arm_dc_feature(s, ARM_FEATURE_EL2) && | ||
150 | + s->current_el < 2 && s->ns) { | ||
151 | + gen_helper_check_bxj_trap(cpu_env, tcg_constant_i32(a->rm)); | ||
152 | + } | 144 | + } |
153 | /* Trivial implementation equivalent to bx. */ | 145 | + |
154 | gen_bx(s, load_reg(s, a->rm)); | 146 | #ifdef TARGET_AARCH64 |
155 | return true; | 147 | if (cpu_isar_feature(aa64_pauth, cpu)) { |
148 | define_arm_cp_regs(cpu, pauth_reginfo); | ||
156 | -- | 149 | -- |
157 | 2.20.1 | 150 | 2.25.1 |
158 | |||
159 | diff view generated by jsdifflib |
1 | KVM cannot support multiple address spaces per CPU; if you try to | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | create more than one then cpu_address_space_init() will assert. | ||
3 | 2 | ||
4 | In the Arm CPU realize function, detect the configurations which | 3 | We had a few CPTR_* bits defined, but missed quite a few. |
5 | would cause us to need more than one AS, and cleanly fail the | 4 | Complete all of the fields up to ARMv9.2. |
6 | realize rather than blundering on into the assertion. This | 5 | Use FIELD_EX64 instead of manual extract32. |
7 | turns this: | ||
8 | $ qemu-system-aarch64 -enable-kvm -display none -cpu max -machine raspi3b | ||
9 | qemu-system-aarch64: ../../softmmu/physmem.c:747: cpu_address_space_init: Assertion `asidx == 0 || !kvm_enabled()' failed. | ||
10 | Aborted | ||
11 | 6 | ||
12 | into: | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | $ qemu-system-aarch64 -enable-kvm -display none -machine raspi3b | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
14 | qemu-system-aarch64: Cannot enable KVM when guest CPU has EL3 enabled | 9 | Message-id: 20220517054850.177016-3-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 44 +++++++++++++++++++++++++++++++----- | ||
13 | hw/arm/boot.c | 2 +- | ||
14 | target/arm/cpu.c | 11 ++++++--- | ||
15 | target/arm/helper.c | 54 ++++++++++++++++++++++----------------------- | ||
16 | 4 files changed, 75 insertions(+), 36 deletions(-) | ||
15 | 17 | ||
16 | and this: | 18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | $ qemu-system-aarch64 -enable-kvm -display none -machine mps3-an524 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | qemu-system-aarch64: ../../softmmu/physmem.c:747: cpu_address_space_init: Assertion `asidx == 0 || !kvm_enabled()' failed. | 20 | --- a/target/arm/cpu.h |
19 | Aborted | 21 | +++ b/target/arm/cpu.h |
20 | 22 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | |
21 | into: | 23 | #define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */ |
22 | $ qemu-system-aarch64 -enable-kvm -display none -machine mps3-an524 | 24 | #define SCTLR_TIDCP (1ULL << 63) /* FEAT_TIDCP1 */ |
23 | qemu-system-aarch64: Cannot enable KVM when using an M-profile guest CPU | 25 | |
24 | 26 | -#define CPTR_TCPAC (1U << 31) | |
25 | Fixes: https://gitlab.com/qemu-project/qemu/-/issues/528 | 27 | -#define CPTR_TTA (1U << 20) |
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | -#define CPTR_TFP (1U << 10) |
27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 29 | -#define CPTR_TZ (1U << 8) /* CPTR_EL2 */ |
28 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 30 | -#define CPTR_EZ (1U << 8) /* CPTR_EL3 */ |
29 | Message-id: 20210816135842.25302-3-peter.maydell@linaro.org | 31 | +/* Bit definitions for CPACR (AArch32 only) */ |
30 | --- | 32 | +FIELD(CPACR, CP10, 20, 2) |
31 | target/arm/cpu.c | 23 +++++++++++++++++++++++ | 33 | +FIELD(CPACR, CP11, 22, 2) |
32 | 1 file changed, 23 insertions(+) | 34 | +FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ |
33 | 35 | +FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ | |
36 | +FIELD(CPACR, ASEDIS, 31, 1) | ||
37 | + | ||
38 | +/* Bit definitions for CPACR_EL1 (AArch64 only) */ | ||
39 | +FIELD(CPACR_EL1, ZEN, 16, 2) | ||
40 | +FIELD(CPACR_EL1, FPEN, 20, 2) | ||
41 | +FIELD(CPACR_EL1, SMEN, 24, 2) | ||
42 | +FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ | ||
43 | + | ||
44 | +/* Bit definitions for HCPTR (AArch32 only) */ | ||
45 | +FIELD(HCPTR, TCP10, 10, 1) | ||
46 | +FIELD(HCPTR, TCP11, 11, 1) | ||
47 | +FIELD(HCPTR, TASE, 15, 1) | ||
48 | +FIELD(HCPTR, TTA, 20, 1) | ||
49 | +FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ | ||
50 | +FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ | ||
51 | + | ||
52 | +/* Bit definitions for CPTR_EL2 (AArch64 only) */ | ||
53 | +FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ | ||
54 | +FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ | ||
55 | +FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ | ||
56 | +FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ | ||
57 | +FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ | ||
58 | +FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ | ||
59 | +FIELD(CPTR_EL2, TTA, 28, 1) | ||
60 | +FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ | ||
61 | +FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ | ||
62 | + | ||
63 | +/* Bit definitions for CPTR_EL3 (AArch64 only) */ | ||
64 | +FIELD(CPTR_EL3, EZ, 8, 1) | ||
65 | +FIELD(CPTR_EL3, TFP, 10, 1) | ||
66 | +FIELD(CPTR_EL3, ESM, 12, 1) | ||
67 | +FIELD(CPTR_EL3, TTA, 20, 1) | ||
68 | +FIELD(CPTR_EL3, TAM, 30, 1) | ||
69 | +FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
70 | |||
71 | #define MDCR_EPMAD (1U << 21) | ||
72 | #define MDCR_EDAD (1U << 20) | ||
73 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/hw/arm/boot.c | ||
76 | +++ b/hw/arm/boot.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | ||
78 | env->cp15.scr_el3 |= SCR_ATA; | ||
79 | } | ||
80 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
81 | - env->cp15.cptr_el[3] |= CPTR_EZ; | ||
82 | + env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK; | ||
83 | } | ||
84 | /* AArch64 kernels never boot in secure mode */ | ||
85 | assert(!info->secure_boot); | ||
34 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 86 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
35 | index XXXXXXX..XXXXXXX 100644 | 87 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/cpu.c | 88 | --- a/target/arm/cpu.c |
37 | +++ b/target/arm/cpu.c | 89 | +++ b/target/arm/cpu.c |
38 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 90 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
39 | } | 91 | /* Trap on btype=3 for PACIxSP. */ |
40 | } | 92 | env->cp15.sctlr_el[1] |= SCTLR_BT0; |
41 | 93 | /* and to the FP/Neon instructions */ | |
42 | + if (kvm_enabled()) { | 94 | - env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3); |
43 | + /* | 95 | + env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
44 | + * Catch all the cases which might cause us to create more than one | 96 | + CPACR_EL1, FPEN, 3); |
45 | + * address space for the CPU (otherwise we will assert() later in | 97 | /* and to the SVE instructions */ |
46 | + * cpu_address_space_init()). | 98 | - env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); |
47 | + */ | 99 | + env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
48 | + if (arm_feature(env, ARM_FEATURE_M)) { | 100 | + CPACR_EL1, ZEN, 3); |
49 | + error_setg(errp, | 101 | /* with reasonable vector length */ |
50 | + "Cannot enable KVM when using an M-profile guest CPU"); | 102 | if (cpu_isar_feature(aa64_sve, cpu)) { |
51 | + return; | 103 | env->vfp.zcr_el[1] = |
52 | + } | 104 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
53 | + if (cpu->has_el3) { | 105 | } else { |
54 | + error_setg(errp, | 106 | #if defined(CONFIG_USER_ONLY) |
55 | + "Cannot enable KVM when guest CPU has EL3 enabled"); | 107 | /* Userspace expects access to cp10 and cp11 for FP/Neon */ |
56 | + return; | 108 | - env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 4, 0xf); |
57 | + } | 109 | + env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
58 | + if (cpu->tag_memory) { | 110 | + CPACR, CP10, 3); |
59 | + error_setg(errp, | 111 | + env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
60 | + "Cannot enable KVM when guest CPUs has MTE enabled"); | 112 | + CPACR, CP11, 3); |
61 | + return; | 113 | #endif |
62 | + } | 114 | } |
63 | + } | 115 | |
64 | + | 116 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
65 | { | 117 | index XXXXXXX..XXXXXXX 100644 |
66 | uint64_t scale; | 118 | --- a/target/arm/helper.c |
67 | 119 | +++ b/target/arm/helper.c | |
120 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
121 | */ | ||
122 | if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { | ||
123 | /* VFP coprocessor: cp10 & cp11 [23:20] */ | ||
124 | - mask |= (1 << 31) | (1 << 30) | (0xf << 20); | ||
125 | + mask |= R_CPACR_ASEDIS_MASK | | ||
126 | + R_CPACR_D32DIS_MASK | | ||
127 | + R_CPACR_CP11_MASK | | ||
128 | + R_CPACR_CP10_MASK; | ||
129 | |||
130 | if (!arm_feature(env, ARM_FEATURE_NEON)) { | ||
131 | /* ASEDIS [31] bit is RAO/WI */ | ||
132 | - value |= (1 << 31); | ||
133 | + value |= R_CPACR_ASEDIS_MASK; | ||
134 | } | ||
135 | |||
136 | /* VFPv3 and upwards with NEON implement 32 double precision | ||
137 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
138 | */ | ||
139 | if (!cpu_isar_feature(aa32_simd_r32, env_archcpu(env))) { | ||
140 | /* D32DIS [30] is RAO/WI if D16-31 are not implemented. */ | ||
141 | - value |= (1 << 30); | ||
142 | + value |= R_CPACR_D32DIS_MASK; | ||
143 | } | ||
144 | } | ||
145 | value &= mask; | ||
146 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
147 | */ | ||
148 | if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && | ||
149 | !arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) { | ||
150 | - value &= ~(0xf << 20); | ||
151 | - value |= env->cp15.cpacr_el1 & (0xf << 20); | ||
152 | + mask = R_CPACR_CP11_MASK | R_CPACR_CP10_MASK; | ||
153 | + value = (value & ~mask) | (env->cp15.cpacr_el1 & mask); | ||
154 | } | ||
155 | |||
156 | env->cp15.cpacr_el1 = value; | ||
157 | @@ -XXX,XX +XXX,XX @@ static uint64_t cpacr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
158 | |||
159 | if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && | ||
160 | !arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) { | ||
161 | - value &= ~(0xf << 20); | ||
162 | + value = ~(R_CPACR_CP11_MASK | R_CPACR_CP10_MASK); | ||
163 | } | ||
164 | return value; | ||
165 | } | ||
166 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
167 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
168 | /* Check if CPACR accesses are to be trapped to EL2 */ | ||
169 | if (arm_current_el(env) == 1 && arm_is_el2_enabled(env) && | ||
170 | - (env->cp15.cptr_el[2] & CPTR_TCPAC)) { | ||
171 | + FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TCPAC)) { | ||
172 | return CP_ACCESS_TRAP_EL2; | ||
173 | /* Check if CPACR accesses are to be trapped to EL3 */ | ||
174 | } else if (arm_current_el(env) < 3 && | ||
175 | - (env->cp15.cptr_el[3] & CPTR_TCPAC)) { | ||
176 | + FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, TCPAC)) { | ||
177 | return CP_ACCESS_TRAP_EL3; | ||
178 | } | ||
179 | } | ||
180 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult cptr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
181 | bool isread) | ||
182 | { | ||
183 | /* Check if CPTR accesses are set to trap to EL3 */ | ||
184 | - if (arm_current_el(env) == 2 && (env->cp15.cptr_el[3] & CPTR_TCPAC)) { | ||
185 | + if (arm_current_el(env) == 2 && | ||
186 | + FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, TCPAC)) { | ||
187 | return CP_ACCESS_TRAP_EL3; | ||
188 | } | ||
189 | |||
190 | @@ -XXX,XX +XXX,XX @@ static void cptr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
191 | */ | ||
192 | if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && | ||
193 | !arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) { | ||
194 | - value &= ~(0x3 << 10); | ||
195 | - value |= env->cp15.cptr_el[2] & (0x3 << 10); | ||
196 | + uint64_t mask = R_HCPTR_TCP11_MASK | R_HCPTR_TCP10_MASK; | ||
197 | + value = (value & ~mask) | (env->cp15.cptr_el[2] & mask); | ||
198 | } | ||
199 | env->cp15.cptr_el[2] = value; | ||
200 | } | ||
201 | @@ -XXX,XX +XXX,XX @@ static uint64_t cptr_el2_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
202 | |||
203 | if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && | ||
204 | !arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) { | ||
205 | - value |= 0x3 << 10; | ||
206 | + value |= R_HCPTR_TCP11_MASK | R_HCPTR_TCP10_MASK; | ||
207 | } | ||
208 | return value; | ||
209 | } | ||
210 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
211 | uint64_t hcr_el2 = arm_hcr_el2_eff(env); | ||
212 | |||
213 | if (el <= 1 && (hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
214 | - /* Check CPACR.ZEN. */ | ||
215 | - switch (extract32(env->cp15.cpacr_el1, 16, 2)) { | ||
216 | + switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, ZEN)) { | ||
217 | case 1: | ||
218 | if (el != 0) { | ||
219 | break; | ||
220 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
221 | } | ||
222 | |||
223 | /* Check CPACR.FPEN. */ | ||
224 | - switch (extract32(env->cp15.cpacr_el1, 20, 2)) { | ||
225 | + switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, FPEN)) { | ||
226 | case 1: | ||
227 | if (el != 0) { | ||
228 | break; | ||
229 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
230 | */ | ||
231 | if (el <= 2) { | ||
232 | if (hcr_el2 & HCR_E2H) { | ||
233 | - /* Check CPTR_EL2.ZEN. */ | ||
234 | - switch (extract32(env->cp15.cptr_el[2], 16, 2)) { | ||
235 | + switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, ZEN)) { | ||
236 | case 1: | ||
237 | if (el != 0 || !(hcr_el2 & HCR_TGE)) { | ||
238 | break; | ||
239 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
240 | return 2; | ||
241 | } | ||
242 | |||
243 | - /* Check CPTR_EL2.FPEN. */ | ||
244 | - switch (extract32(env->cp15.cptr_el[2], 20, 2)) { | ||
245 | + switch (FIELD_EX32(env->cp15.cptr_el[2], CPTR_EL2, FPEN)) { | ||
246 | case 1: | ||
247 | if (el == 2 || !(hcr_el2 & HCR_TGE)) { | ||
248 | break; | ||
249 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
250 | return 0; | ||
251 | } | ||
252 | } else if (arm_is_el2_enabled(env)) { | ||
253 | - if (env->cp15.cptr_el[2] & CPTR_TZ) { | ||
254 | + if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TZ)) { | ||
255 | return 2; | ||
256 | } | ||
257 | - if (env->cp15.cptr_el[2] & CPTR_TFP) { | ||
258 | + if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TFP)) { | ||
259 | return 0; | ||
260 | } | ||
261 | } | ||
262 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
263 | |||
264 | /* CPTR_EL3. Since EZ is negative we must check for EL3. */ | ||
265 | if (arm_feature(env, ARM_FEATURE_EL3) | ||
266 | - && !(env->cp15.cptr_el[3] & CPTR_EZ)) { | ||
267 | + && !FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, EZ)) { | ||
268 | return 3; | ||
269 | } | ||
270 | #endif | ||
271 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | ||
272 | * This register is ignored if E2H+TGE are both set. | ||
273 | */ | ||
274 | if ((hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
275 | - int fpen = extract32(env->cp15.cpacr_el1, 20, 2); | ||
276 | + int fpen = FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, FPEN); | ||
277 | |||
278 | switch (fpen) { | ||
279 | case 0: | ||
280 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | ||
281 | */ | ||
282 | if (cur_el <= 2) { | ||
283 | if (hcr_el2 & HCR_E2H) { | ||
284 | - /* Check CPTR_EL2.FPEN. */ | ||
285 | - switch (extract32(env->cp15.cptr_el[2], 20, 2)) { | ||
286 | + switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, FPEN)) { | ||
287 | case 1: | ||
288 | if (cur_el != 0 || !(hcr_el2 & HCR_TGE)) { | ||
289 | break; | ||
290 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | ||
291 | return 2; | ||
292 | } | ||
293 | } else if (arm_is_el2_enabled(env)) { | ||
294 | - if (env->cp15.cptr_el[2] & CPTR_TFP) { | ||
295 | + if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TFP)) { | ||
296 | return 2; | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | |||
301 | /* CPTR_EL3 : present in v8 */ | ||
302 | - if (env->cp15.cptr_el[3] & CPTR_TFP) { | ||
303 | + if (FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, TFP)) { | ||
304 | /* Trap all FP ops to EL3 */ | ||
305 | return 3; | ||
306 | } | ||
68 | -- | 307 | -- |
69 | 2.20.1 | 308 | 2.25.1 |
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tong Ho <tong.ho@xilinx.com> | ||
2 | 1 | ||
3 | Add unimplemented APU mmio region to xlnx-versal for booting | ||
4 | bare-metal guests built with standalone bsp, which access the | ||
5 | region from one of the following places: | ||
6 | https://github.com/Xilinx/embeddedsw/blob/release-2020.2/lib/bsp/standalone/src/arm/ARMv8/64bit/armclang/boot.S#L139 | ||
7 | https://github.com/Xilinx/embeddedsw/blob/release-2020.2/lib/bsp/standalone/src/arm/ARMv8/64bit/gcc/boot.S#L183 | ||
8 | |||
9 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
11 | Signed-off-by: Tong Ho <tong.ho@xilinx.com> | ||
12 | Message-id: 20210823173818.201259-2-tong.ho@xilinx.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | include/hw/arm/xlnx-versal.h | 2 ++ | ||
16 | hw/arm/xlnx-versal.c | 2 ++ | ||
17 | 2 files changed, 4 insertions(+) | ||
18 | |||
19 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/hw/arm/xlnx-versal.h | ||
22 | +++ b/include/hw/arm/xlnx-versal.h | ||
23 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
24 | #define MM_IOU_SCNTRS_SIZE 0x10000 | ||
25 | #define MM_FPD_CRF 0xfd1a0000U | ||
26 | #define MM_FPD_CRF_SIZE 0x140000 | ||
27 | +#define MM_FPD_FPD_APU 0xfd5c0000 | ||
28 | +#define MM_FPD_FPD_APU_SIZE 0x100 | ||
29 | |||
30 | #define MM_PMC_SD0 0xf1040000U | ||
31 | #define MM_PMC_SD0_SIZE 0x10000 | ||
32 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/arm/xlnx-versal.c | ||
35 | +++ b/hw/arm/xlnx-versal.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void versal_unimp(Versal *s) | ||
37 | MM_CRL, MM_CRL_SIZE); | ||
38 | versal_unimp_area(s, "crf", &s->mr_ps, | ||
39 | MM_FPD_CRF, MM_FPD_CRF_SIZE); | ||
40 | + versal_unimp_area(s, "apu", &s->mr_ps, | ||
41 | + MM_FPD_FPD_APU, MM_FPD_FPD_APU_SIZE); | ||
42 | versal_unimp_area(s, "crp", &s->mr_ps, | ||
43 | MM_PMC_CRP, MM_PMC_CRP_SIZE); | ||
44 | versal_unimp_area(s, "iou-scntr", &s->mr_ps, | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |