1 | Nothing very exciting this time around... | 1 | arm pullreq for rc1. All minor bugfixes, except for the sve-default-vector-length |
---|---|---|---|
2 | patches, which are somewhere between a bugfix and a new feature. | ||
2 | 3 | ||
4 | thanks | ||
3 | -- PMM | 5 | -- PMM |
4 | 6 | ||
5 | The following changes since commit 37a712a0f969ca2df7f01182409a6c4825cebfb5: | 7 | The following changes since commit c08ccd1b53f488ac86c1f65cf7623dc91acc249a: |
6 | 8 | ||
7 | Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging (2020-10-01 12:23:19 +0100) | 9 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210726' into staging (2021-07-27 08:35:01 +0100) |
8 | 10 | ||
9 | are available in the Git repository at: | 11 | are available in the Git repository at: |
10 | 12 | ||
11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201001 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210727 |
12 | 14 | ||
13 | for you to fetch changes up to cdfaa57dcb53ba012439765a1462247dfda8595d: | 15 | for you to fetch changes up to e229a179a503f2aee43a76888cf12fbdfe8a3749: |
14 | 16 | ||
15 | hw/arm/raspi: Remove use of the 'version' value in the board code (2020-10-01 15:31:01 +0100) | 17 | hw: aspeed_gpio: Fix memory size (2021-07-27 11:00:00 +0100) |
16 | 18 | ||
17 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
18 | target-arm queue: | 20 | target-arm queue: |
19 | * Make isar_feature_aa32_fp16_arith() handle M-profile | 21 | * hw/arm/smmuv3: Check 31st bit to see if CD is valid |
20 | * Fix SVE splice | 22 | * qemu-options.hx: Fix formatting of -machine memory-backend option |
21 | * Fix SVE LDR/STR | 23 | * hw: aspeed_gpio: Fix memory size |
22 | * Remove ignore_memory_transaction_failures on the raspi2 | 24 | * hw/arm/nseries: Display hexadecimal value with '0x' prefix |
23 | * raspi: Various cleanup/refactoring | 25 | * Add sve-default-vector-length cpu property |
26 | * docs: Update path that mentions deprecated.rst | ||
27 | * hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS | ||
28 | * hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING | ||
29 | * hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | ||
30 | * target/arm: Report M-profile alignment faults correctly to the guest | ||
31 | * target/arm: Add missing 'return's after calling v7m_exception_taken() | ||
32 | * target/arm: Enforce that M-profile SP low 2 bits are always zero | ||
24 | 33 | ||
25 | ---------------------------------------------------------------- | 34 | ---------------------------------------------------------------- |
26 | Peter Maydell (5): | 35 | Joe Komlodi (1): |
27 | target/arm: Replace ARM_FEATURE_PXN with ID_MMFR0.VMSA check | 36 | hw/arm/smmuv3: Check 31st bit to see if CD is valid |
28 | target/arm: Move id_pfr0, id_pfr1 into ARMISARegisters | ||
29 | hw/intc/armv7m_nvic: Only show ID register values for Main Extension CPUs | ||
30 | target/arm: Add ID register values for Cortex-M0 | ||
31 | target/arm: Make isar_feature_aa32_fp16_arith() handle M-profile | ||
32 | 37 | ||
33 | Philippe Mathieu-Daudé (11): | 38 | Joel Stanley (1): |
34 | hw/arm/raspi: Define various blocks base addresses | 39 | hw: aspeed_gpio: Fix memory size |
35 | hw/arm/bcm2835: Add more unimplemented peripherals | ||
36 | hw/arm/raspi: Remove ignore_memory_transaction_failures on the raspi2 | ||
37 | hw/arm/raspi: Display the board revision in the machine description | ||
38 | hw/arm/raspi: Load the firmware on the first core | ||
39 | hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState | ||
40 | hw/arm/raspi: Avoid using TypeInfo::class_data pointer | ||
41 | hw/arm/raspi: Use more specific machine names | ||
42 | hw/arm/raspi: Introduce RaspiProcessorId enum | ||
43 | hw/arm/raspi: Use RaspiProcessorId to set the firmware load address | ||
44 | hw/arm/raspi: Remove use of the 'version' value in the board code | ||
45 | 40 | ||
46 | Richard Henderson (2): | 41 | Mao Zhongyi (1): |
47 | target/arm: Fix sve ldr/str | 42 | docs: Update path that mentions deprecated.rst |
48 | target/arm: Fix SVE splice | ||
49 | 43 | ||
50 | include/hw/arm/bcm2835_peripherals.h | 2 + | 44 | Peter Maydell (7): |
51 | include/hw/arm/raspi_platform.h | 51 ++++++++++-- | 45 | qemu-options.hx: Fix formatting of -machine memory-backend option |
52 | target/arm/cpu.h | 50 +++++++++-- | 46 | target/arm: Enforce that M-profile SP low 2 bits are always zero |
53 | hw/arm/bcm2835_peripherals.c | 2 + | 47 | target/arm: Add missing 'return's after calling v7m_exception_taken() |
54 | hw/arm/raspi.c | 155 +++++++++++++++++++---------------- | 48 | target/arm: Report M-profile alignment faults correctly to the guest |
55 | hw/intc/armv7m_nvic.c | 46 ++++++++++- | 49 | hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts |
56 | target/arm/cpu.c | 21 +++-- | 50 | hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING |
57 | target/arm/cpu64.c | 12 +-- | 51 | hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS |
58 | target/arm/cpu_tcg.c | 60 ++++++++++---- | ||
59 | target/arm/helper.c | 9 +- | ||
60 | target/arm/kvm64.c | 4 + | ||
61 | target/arm/translate-sve.c | 6 +- | ||
62 | 12 files changed, 286 insertions(+), 132 deletions(-) | ||
63 | 52 | ||
53 | Philippe Mathieu-Daudé (1): | ||
54 | hw/arm/nseries: Display hexadecimal value with '0x' prefix | ||
55 | |||
56 | Richard Henderson (3): | ||
57 | target/arm: Correctly bound length in sve_zcr_get_valid_len | ||
58 | target/arm: Export aarch64_sve_zcr_get_valid_len | ||
59 | target/arm: Add sve-default-vector-length cpu property | ||
60 | |||
61 | docs/system/arm/cpu-features.rst | 15 ++++++++++ | ||
62 | configure | 2 +- | ||
63 | hw/arm/smmuv3-internal.h | 2 +- | ||
64 | target/arm/cpu.h | 5 ++++ | ||
65 | target/arm/internals.h | 10 +++++++ | ||
66 | hw/arm/nseries.c | 2 +- | ||
67 | hw/gpio/aspeed_gpio.c | 3 +- | ||
68 | hw/intc/armv7m_nvic.c | 40 +++++++++++++++++++-------- | ||
69 | target/arm/cpu.c | 14 ++++++++-- | ||
70 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++++++++++ | ||
71 | target/arm/gdbstub.c | 4 +++ | ||
72 | target/arm/helper.c | 8 ++++-- | ||
73 | target/arm/m_helper.c | 24 ++++++++++++---- | ||
74 | target/arm/translate.c | 3 ++ | ||
75 | target/i386/cpu.c | 2 +- | ||
76 | MAINTAINERS | 2 +- | ||
77 | qemu-options.hx | 30 +++++++++++--------- | ||
78 | 17 files changed, 183 insertions(+), 43 deletions(-) | ||
79 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joe Komlodi <joe.komlodi@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | While converting to gen_gvec_ool_zzzp, we lost passing | 3 | The bit to see if a CD is valid is the last bit of the first word of the CD. |
4 | a->esz as the data argument to the function. | ||
5 | 4 | ||
6 | Fixes: 36cbb7a8e71 | 5 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> |
7 | Cc: qemu-stable@nongnu.org | 6 | Message-id: 1626728232-134665-2-git-send-email-joe.komlodi@xilinx.com |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200918000500.2690937-1-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 9 | --- |
13 | target/arm/translate-sve.c | 2 +- | 10 | hw/arm/smmuv3-internal.h | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 12 | ||
16 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 13 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-sve.c | 15 | --- a/hw/arm/smmuv3-internal.h |
19 | +++ b/target/arm/translate-sve.c | 16 | +++ b/hw/arm/smmuv3-internal.h |
20 | @@ -XXX,XX +XXX,XX @@ static bool trans_SPLICE(DisasContext *s, arg_rprr_esz *a) | 17 | @@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste) |
21 | { | 18 | |
22 | if (sve_access_check(s)) { | 19 | /* CD fields */ |
23 | gen_gvec_ool_zzzp(s, gen_helper_sve_splice, | 20 | |
24 | - a->rd, a->rn, a->rm, a->pg, 0); | 21 | -#define CD_VALID(x) extract32((x)->word[0], 30, 1) |
25 | + a->rd, a->rn, a->rm, a->pg, a->esz); | 22 | +#define CD_VALID(x) extract32((x)->word[0], 31, 1) |
26 | } | 23 | #define CD_ASID(x) extract32((x)->word[1], 16, 16) |
27 | return true; | 24 | #define CD_TTB(x, sel) \ |
28 | } | 25 | ({ \ |
29 | -- | 26 | -- |
30 | 2.20.1 | 27 | 2.20.1 |
31 | 28 | ||
32 | 29 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | The documentation of the -machine memory-backend has some minor |
---|---|---|---|
2 | formatting errors: | ||
3 | * Misindentation of the initial line meant that the whole option | ||
4 | section is incorrectly indented in the HTML output compared to | ||
5 | the other -machine options | ||
6 | * The examples weren't indented, which meant that they were formatted | ||
7 | as plain run-on text including outputting the "::" as text. | ||
8 | * The a) b) list has no rst-format markup so it is rendered as | ||
9 | a single run-on paragraph | ||
2 | 10 | ||
3 | We expected the 'version' ID to match the board processor ID, | 11 | Fix the formatting. |
4 | but this is not always true (for example boards with revision | ||
5 | id 0xa02042/0xa22042 are Raspberry Pi 2 with a BCM2837 SoC). | ||
6 | This was not important because we were not modelling them, but | ||
7 | since the recent refactor now allow to model these boards, it | ||
8 | is safer to check the processor id directly. Remove the version | ||
9 | check. | ||
10 | 12 | ||
11 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20200924111808.77168-9-f4bug@amsat.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Message-id: 20210719105257.3599-1-peter.maydell@linaro.org | ||
16 | --- | 16 | --- |
17 | hw/arm/raspi.c | 29 +++++++++++++---------------- | 17 | qemu-options.hx | 30 +++++++++++++++++------------- |
18 | 1 file changed, 13 insertions(+), 16 deletions(-) | 18 | 1 file changed, 17 insertions(+), 13 deletions(-) |
19 | 19 | ||
20 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 20 | diff --git a/qemu-options.hx b/qemu-options.hx |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/raspi.c | 22 | --- a/qemu-options.hx |
23 | +++ b/hw/arm/raspi.c | 23 | +++ b/qemu-options.hx |
24 | @@ -XXX,XX +XXX,XX @@ static RaspiProcessorId board_processor_id(uint32_t board_rev) | 24 | @@ -XXX,XX +XXX,XX @@ SRST |
25 | return proc_id; | 25 | Enables or disables ACPI Heterogeneous Memory Attribute Table |
26 | } | 26 | (HMAT) support. The default is off. |
27 | 27 | ||
28 | -static int board_version(uint32_t board_rev) | 28 | - ``memory-backend='id'`` |
29 | -{ | 29 | + ``memory-backend='id'`` |
30 | - return board_processor_id(board_rev) + 1; | 30 | An alternative to legacy ``-mem-path`` and ``mem-prealloc`` options. |
31 | -} | 31 | Allows to use a memory backend as main RAM. |
32 | - | 32 | |
33 | static const char *board_soc_type(uint32_t board_rev) | 33 | For example: |
34 | { | 34 | :: |
35 | return soc_property[board_processor_id(board_rev)].type; | 35 | - -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on |
36 | @@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) | 36 | - -machine memory-backend=pc.ram |
37 | cpu_set_pc(cs, info->smp_loader_start); | 37 | - -m 512M |
38 | } | 38 | + |
39 | 39 | + -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on | |
40 | -static void setup_boot(MachineState *machine, int version, size_t ram_size) | 40 | + -machine memory-backend=pc.ram |
41 | +static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, | 41 | + -m 512M |
42 | + size_t ram_size) | 42 | |
43 | { | 43 | Migration compatibility note: |
44 | RaspiMachineState *s = RASPI_MACHINE(machine); | 44 | - a) as backend id one shall use value of 'default-ram-id', advertised by |
45 | int r; | 45 | - machine type (available via ``query-machines`` QMP command), if migration |
46 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | 46 | - to/from old QEMU (<5.0) is expected. |
47 | s->binfo.ram_size = ram_size; | 47 | - b) for machine types 4.0 and older, user shall |
48 | s->binfo.nb_cpus = machine->smp.cpus; | 48 | - use ``x-use-canonical-path-for-ramblock-id=off`` backend option |
49 | 49 | - if migration to/from old QEMU (<5.0) is expected. | |
50 | - if (version <= 2) { | 50 | + |
51 | - /* The rpi1 and 2 require some custom setup code to run in Secure | 51 | + * as backend id one shall use value of 'default-ram-id', advertised by |
52 | - * mode before booting a kernel (to set up the SMC vectors so | 52 | + machine type (available via ``query-machines`` QMP command), if migration |
53 | - * that we get a no-op SMC; this is used by Linux to call the | 53 | + to/from old QEMU (<5.0) is expected. |
54 | + if (processor_id <= PROCESSOR_ID_BCM2836) { | 54 | + * for machine types 4.0 and older, user shall |
55 | + /* | 55 | + use ``x-use-canonical-path-for-ramblock-id=off`` backend option |
56 | + * The BCM2835 and BCM2836 require some custom setup code to run | 56 | + if migration to/from old QEMU (<5.0) is expected. |
57 | + * in Secure mode before booting a kernel (to set up the SMC vectors | 57 | + |
58 | + * so that we get a no-op SMC; this is used by Linux to call the | 58 | For example: |
59 | * firmware for some cache maintenance operations. | 59 | :: |
60 | - * The rpi3 doesn't need this. | 60 | - -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off |
61 | + * The BCM2837 doesn't need this. | 61 | - -machine memory-backend=pc.ram |
62 | */ | 62 | - -m 512M |
63 | s->binfo.board_setup_addr = BOARDSETUP_ADDR; | 63 | + |
64 | s->binfo.write_board_setup = write_board_setup; | 64 | + -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off |
65 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | 65 | + -machine memory-backend=pc.ram |
66 | s->binfo.secure_boot = true; | 66 | + -m 512M |
67 | } | 67 | ERST |
68 | 68 | ||
69 | - /* Pi2 and Pi3 requires SMP setup */ | 69 | HXCOMM Deprecated by -machine |
70 | - if (version >= 2) { | ||
71 | + /* BCM2836 and BCM2837 requires SMP setup */ | ||
72 | + if (processor_id >= PROCESSOR_ID_BCM2836) { | ||
73 | s->binfo.smp_loader_start = SMPBOOT_ADDR; | ||
74 | - if (version == 2) { | ||
75 | + if (processor_id == PROCESSOR_ID_BCM2836) { | ||
76 | s->binfo.write_secondary_boot = write_smpboot; | ||
77 | } else { | ||
78 | s->binfo.write_secondary_boot = write_smpboot64; | ||
79 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) | ||
80 | RaspiMachineClass *mc = RASPI_MACHINE_GET_CLASS(machine); | ||
81 | RaspiMachineState *s = RASPI_MACHINE(machine); | ||
82 | uint32_t board_rev = mc->board_rev; | ||
83 | - int version = board_version(board_rev); | ||
84 | uint64_t ram_size = board_ram_size(board_rev); | ||
85 | uint32_t vcram_size; | ||
86 | DriveInfo *di; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) | ||
88 | |||
89 | vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size", | ||
90 | &error_abort); | ||
91 | - setup_boot(machine, version, machine->ram_size - vcram_size); | ||
92 | + setup_boot(machine, board_processor_id(mc->board_rev), | ||
93 | + machine->ram_size - vcram_size); | ||
94 | } | ||
95 | |||
96 | static void raspi_machine_class_common_init(MachineClass *mc, | ||
97 | -- | 70 | -- |
98 | 2.20.1 | 71 | 2.20.1 |
99 | 72 | ||
100 | 73 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | For M-profile, unlike A-profile, the low 2 bits of SP are defined to be |
---|---|---|---|
2 | RES0H, which is to say that they must be hardwired to zero so that | ||
3 | guest attempts to write non-zero values to them are ignored. | ||
2 | 4 | ||
3 | The firmware load address depends on the SoC ("processor id") used, | 5 | Implement this behaviour by masking out the low bits: |
4 | not on the version of the board. | 6 | * for writes to r13 by the gdbstub |
7 | * for writes to any of the various flavours of SP via MSR | ||
8 | * for writes to r13 via store_reg() in generated code | ||
5 | 9 | ||
6 | Suggested-by: Luc Michel <luc.michel@greensocs.com> | 10 | Note that all the direct uses of cpu_R[] in translate.c are in places |
7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 11 | where the register is definitely not r13 (usually because that has |
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | been checked for as an UNDEFINED or UNPREDICTABLE case and handled as |
9 | Message-id: 20200924111808.77168-8-f4bug@amsat.org | 13 | UNDEF). |
14 | |||
15 | All the other writes to regs[13] in C code are either: | ||
16 | * A-profile only code | ||
17 | * writes of values we can guarantee to be aligned, such as | ||
18 | - writes of previous-SP-value plus or minus a 4-aligned constant | ||
19 | - writes of the value in an SP limit register (which we already | ||
20 | enforce to be aligned) | ||
21 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20210723162146.5167-2-peter.maydell@linaro.org | ||
11 | --- | 25 | --- |
12 | hw/arm/raspi.c | 3 ++- | 26 | target/arm/gdbstub.c | 4 ++++ |
13 | 1 file changed, 2 insertions(+), 1 deletion(-) | 27 | target/arm/m_helper.c | 14 ++++++++------ |
28 | target/arm/translate.c | 3 +++ | ||
29 | 3 files changed, 15 insertions(+), 6 deletions(-) | ||
14 | 30 | ||
15 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 31 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
16 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/raspi.c | 33 | --- a/target/arm/gdbstub.c |
18 | +++ b/hw/arm/raspi.c | 34 | +++ b/target/arm/gdbstub.c |
19 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | 35 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) |
20 | * the normal Linux boot process | 36 | |
21 | */ | 37 | if (n < 16) { |
22 | if (machine->firmware) { | 38 | /* Core integer register. */ |
23 | - hwaddr firmware_addr = version == 3 ? FIRMWARE_ADDR_3 : FIRMWARE_ADDR_2; | 39 | + if (n == 13 && arm_feature(env, ARM_FEATURE_M)) { |
24 | + hwaddr firmware_addr = processor_id <= PROCESSOR_ID_BCM2836 | 40 | + /* M profile SP low bits are always 0 */ |
25 | + ? FIRMWARE_ADDR_2 : FIRMWARE_ADDR_3; | 41 | + tmp &= ~3; |
26 | /* load the firmware image (typically kernel.img) */ | 42 | + } |
27 | r = load_image_targphys(machine->firmware, firmware_addr, | 43 | env->regs[n] = tmp; |
28 | ram_size - firmware_addr); | 44 | return 4; |
45 | } | ||
46 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/m_helper.c | ||
49 | +++ b/target/arm/m_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
51 | if (!env->v7m.secure) { | ||
52 | return; | ||
53 | } | ||
54 | - env->v7m.other_ss_msp = val; | ||
55 | + env->v7m.other_ss_msp = val & ~3; | ||
56 | return; | ||
57 | case 0x89: /* PSP_NS */ | ||
58 | if (!env->v7m.secure) { | ||
59 | return; | ||
60 | } | ||
61 | - env->v7m.other_ss_psp = val; | ||
62 | + env->v7m.other_ss_psp = val & ~3; | ||
63 | return; | ||
64 | case 0x8a: /* MSPLIM_NS */ | ||
65 | if (!env->v7m.secure) { | ||
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
67 | |||
68 | limit = is_psp ? env->v7m.psplim[false] : env->v7m.msplim[false]; | ||
69 | |||
70 | + val &= ~0x3; | ||
71 | + | ||
72 | if (val < limit) { | ||
73 | raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); | ||
74 | } | ||
75 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
76 | break; | ||
77 | case 8: /* MSP */ | ||
78 | if (v7m_using_psp(env)) { | ||
79 | - env->v7m.other_sp = val; | ||
80 | + env->v7m.other_sp = val & ~3; | ||
81 | } else { | ||
82 | - env->regs[13] = val; | ||
83 | + env->regs[13] = val & ~3; | ||
84 | } | ||
85 | break; | ||
86 | case 9: /* PSP */ | ||
87 | if (v7m_using_psp(env)) { | ||
88 | - env->regs[13] = val; | ||
89 | + env->regs[13] = val & ~3; | ||
90 | } else { | ||
91 | - env->v7m.other_sp = val; | ||
92 | + env->v7m.other_sp = val & ~3; | ||
93 | } | ||
94 | break; | ||
95 | case 10: /* MSPLIM */ | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ void store_reg(DisasContext *s, int reg, TCGv_i32 var) | ||
101 | */ | ||
102 | tcg_gen_andi_i32(var, var, s->thumb ? ~1 : ~3); | ||
103 | s->base.is_jmp = DISAS_JUMP; | ||
104 | + } else if (reg == 13 && arm_dc_feature(s, ARM_FEATURE_M)) { | ||
105 | + /* For M-profile SP bits [1:0] are always zero */ | ||
106 | + tcg_gen_andi_i32(var, var, ~3); | ||
107 | } | ||
108 | tcg_gen_mov_i32(cpu_R[reg], var); | ||
109 | tcg_temp_free_i32(var); | ||
29 | -- | 110 | -- |
30 | 2.20.1 | 111 | 2.20.1 |
31 | 112 | ||
32 | 113 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | In do_v7m_exception_exit(), we perform various checks as part of |
---|---|---|---|
2 | performing the exception return. If one of these checks fails, the | ||
3 | architecture requires that we take an appropriate exception on the | ||
4 | existing stackframe. We implement this by calling | ||
5 | v7m_exception_taken() to set up to take the new exception, and then | ||
6 | immediately returning from do_v7m_exception_exit() without proceeding | ||
7 | any further with the unstack-and-exception-return process. | ||
2 | 8 | ||
3 | As we only support a reduced set of the REV_CODE_PROCESSOR id | 9 | In a couple of checks that are new in v8.1M, we forgot the "return" |
4 | encoded in the board revision, define the PROCESSOR_ID values | 10 | statement, with the effect that if bad code in the guest tripped over |
5 | as an enum. We can simplify the board_soc_type and cores_count | 11 | these checks we would set up to take a UsageFault exception but then |
6 | methods. | 12 | blunder on trying to also unstack and return from the original |
13 | exception, with the probable result that the guest would crash. | ||
7 | 14 | ||
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 15 | Add the missing return statements. |
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 16 | |
10 | Message-id: 20200924111808.77168-7-f4bug@amsat.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20210723162146.5167-3-peter.maydell@linaro.org | ||
12 | --- | 20 | --- |
13 | hw/arm/raspi.c | 45 +++++++++++++++++++++------------------------ | 21 | target/arm/m_helper.c | 2 ++ |
14 | 1 file changed, 21 insertions(+), 24 deletions(-) | 22 | 1 file changed, 2 insertions(+) |
15 | 23 | ||
16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 24 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/raspi.c | 26 | --- a/target/arm/m_helper.c |
19 | +++ b/hw/arm/raspi.c | 27 | +++ b/target/arm/m_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ FIELD(REV_CODE, MANUFACTURER, 16, 4); | 28 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
21 | FIELD(REV_CODE, MEMORY_SIZE, 20, 3); | 29 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
22 | FIELD(REV_CODE, STYLE, 23, 1); | 30 | "stackframe: NSACR prevents clearing FPU registers\n"); |
23 | 31 | v7m_exception_taken(cpu, excret, true, false); | |
24 | +typedef enum RaspiProcessorId { | 32 | + return; |
25 | + PROCESSOR_ID_BCM2836 = 1, | 33 | } else if (!cpacr_pass) { |
26 | + PROCESSOR_ID_BCM2837 = 2, | 34 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, |
27 | +} RaspiProcessorId; | 35 | exc_secure); |
28 | + | 36 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
29 | +static const struct { | 37 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
30 | + const char *type; | 38 | "stackframe: CPACR prevents clearing FPU registers\n"); |
31 | + int cores_count; | 39 | v7m_exception_taken(cpu, excret, true, false); |
32 | +} soc_property[] = { | 40 | + return; |
33 | + [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS}, | 41 | } |
34 | + [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS}, | 42 | } |
35 | +}; | 43 | /* Clear s0..s15, FPSCR and VPR */ |
36 | + | ||
37 | static uint64_t board_ram_size(uint32_t board_rev) | ||
38 | { | ||
39 | assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ | ||
40 | return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE); | ||
41 | } | ||
42 | |||
43 | -static int board_processor_id(uint32_t board_rev) | ||
44 | +static RaspiProcessorId board_processor_id(uint32_t board_rev) | ||
45 | { | ||
46 | + int proc_id = FIELD_EX32(board_rev, REV_CODE, PROCESSOR); | ||
47 | + | ||
48 | assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ | ||
49 | - return FIELD_EX32(board_rev, REV_CODE, PROCESSOR); | ||
50 | + assert(proc_id < ARRAY_SIZE(soc_property) && soc_property[proc_id].type); | ||
51 | + | ||
52 | + return proc_id; | ||
53 | } | ||
54 | |||
55 | static int board_version(uint32_t board_rev) | ||
56 | @@ -XXX,XX +XXX,XX @@ static int board_version(uint32_t board_rev) | ||
57 | |||
58 | static const char *board_soc_type(uint32_t board_rev) | ||
59 | { | ||
60 | - static const char *soc_types[] = { | ||
61 | - NULL, TYPE_BCM2836, TYPE_BCM2837, | ||
62 | - }; | ||
63 | - int proc_id = board_processor_id(board_rev); | ||
64 | - | ||
65 | - if (proc_id >= ARRAY_SIZE(soc_types) || !soc_types[proc_id]) { | ||
66 | - error_report("Unsupported processor id '%d' (board revision: 0x%x)", | ||
67 | - proc_id, board_rev); | ||
68 | - exit(1); | ||
69 | - } | ||
70 | - return soc_types[proc_id]; | ||
71 | + return soc_property[board_processor_id(board_rev)].type; | ||
72 | } | ||
73 | |||
74 | static int cores_count(uint32_t board_rev) | ||
75 | { | ||
76 | - static const int soc_cores_count[] = { | ||
77 | - 0, BCM283X_NCPUS, BCM283X_NCPUS, | ||
78 | - }; | ||
79 | - int proc_id = board_processor_id(board_rev); | ||
80 | - | ||
81 | - if (proc_id >= ARRAY_SIZE(soc_cores_count) || !soc_cores_count[proc_id]) { | ||
82 | - error_report("Unsupported processor id '%d' (board revision: 0x%x)", | ||
83 | - proc_id, board_rev); | ||
84 | - exit(1); | ||
85 | - } | ||
86 | - return soc_cores_count[proc_id]; | ||
87 | + return soc_property[board_processor_id(board_rev)].cores_count; | ||
88 | } | ||
89 | |||
90 | static const char *board_type(uint32_t board_rev) | ||
91 | -- | 44 | -- |
92 | 2.20.1 | 45 | 2.20.1 |
93 | 46 | ||
94 | 47 | diff view generated by jsdifflib |
1 | The M-profile definition of the MVFR1 ID register differs slightly | 1 | For M-profile, we weren't reporting alignment faults triggered by the |
---|---|---|---|
2 | from the A-profile one, and in particular the check for "does the CPU | 2 | generic TCG code correctly to the guest. These get passed into |
3 | support fp16 arithmetic" is not the same. | 3 | arm_v7m_cpu_do_interrupt() as an EXCP_DATA_ABORT with an A-profile |
4 | style exception.fsr value of 1. We didn't check for this, and so | ||
5 | they fell through into the default of "assume this is an MPU fault" | ||
6 | and were reported to the guest as a data access violation MPU fault. | ||
4 | 7 | ||
5 | We don't currently implement any M-profile CPUs with fp16 arithmetic, | 8 | Report these alignment faults as UsageFaults which set the UNALIGNED |
6 | so this is not yet a visible bug, but correcting the logic now | 9 | bit in the UFSR. |
7 | disarms this beartrap for when we eventually do. | ||
8 | 10 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20200910173855.4068-6-peter.maydell@linaro.org | 13 | Message-id: 20210723162146.5167-4-peter.maydell@linaro.org |
12 | --- | 14 | --- |
13 | target/arm/cpu.h | 31 ++++++++++++++++++++++++++----- | 15 | target/arm/m_helper.c | 8 ++++++++ |
14 | 1 file changed, 26 insertions(+), 5 deletions(-) | 16 | 1 file changed, 8 insertions(+) |
15 | 17 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 20 | --- a/target/arm/m_helper.c |
19 | +++ b/target/arm/cpu.h | 21 | +++ b/target/arm/m_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_MMFR4, LSM, 20, 4) | 22 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
21 | FIELD(ID_MMFR4, CCIDX, 24, 4) | 23 | env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; |
22 | FIELD(ID_MMFR4, EVT, 28, 4) | 24 | break; |
23 | 25 | case EXCP_UNALIGNED: | |
24 | +FIELD(ID_PFR1, PROGMOD, 0, 4) | 26 | + /* Unaligned faults reported by M-profile aware code */ |
25 | +FIELD(ID_PFR1, SECURITY, 4, 4) | 27 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); |
26 | +FIELD(ID_PFR1, MPROGMOD, 8, 4) | 28 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
27 | +FIELD(ID_PFR1, VIRTUALIZATION, 12, 4) | 29 | break; |
28 | +FIELD(ID_PFR1, GENTIMER, 16, 4) | 30 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
29 | +FIELD(ID_PFR1, SEC_FRAC, 20, 4) | 31 | } |
30 | +FIELD(ID_PFR1, VIRT_FRAC, 24, 4) | 32 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); |
31 | +FIELD(ID_PFR1, GIC, 28, 4) | 33 | break; |
32 | + | 34 | + case 0x1: /* Alignment fault reported by generic code */ |
33 | FIELD(ID_AA64ISAR0, AES, 4, 4) | 35 | + qemu_log_mask(CPU_LOG_INT, |
34 | FIELD(ID_AA64ISAR0, SHA1, 8, 4) | 36 | + "...really UsageFault with UFSR.UNALIGNED\n"); |
35 | FIELD(ID_AA64ISAR0, SHA2, 12, 4) | 37 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
36 | @@ -XXX,XX +XXX,XX @@ FIELD(MVFR0, FPROUND, 28, 4) | 38 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, |
37 | 39 | + env->v7m.secure); | |
38 | FIELD(MVFR1, FPFTZ, 0, 4) | 40 | + break; |
39 | FIELD(MVFR1, FPDNAN, 4, 4) | 41 | default: |
40 | -FIELD(MVFR1, SIMDLS, 8, 4) | 42 | /* |
41 | -FIELD(MVFR1, SIMDINT, 12, 4) | 43 | * All other FSR values are either MPU faults or "can't happen |
42 | -FIELD(MVFR1, SIMDSP, 16, 4) | ||
43 | -FIELD(MVFR1, SIMDHP, 20, 4) | ||
44 | +FIELD(MVFR1, SIMDLS, 8, 4) /* A-profile only */ | ||
45 | +FIELD(MVFR1, SIMDINT, 12, 4) /* A-profile only */ | ||
46 | +FIELD(MVFR1, SIMDSP, 16, 4) /* A-profile only */ | ||
47 | +FIELD(MVFR1, SIMDHP, 20, 4) /* A-profile only */ | ||
48 | +FIELD(MVFR1, MVE, 8, 4) /* M-profile only */ | ||
49 | +FIELD(MVFR1, FP16, 20, 4) /* M-profile only */ | ||
50 | FIELD(MVFR1, FPHP, 24, 4) | ||
51 | FIELD(MVFR1, SIMDFMAC, 28, 4) | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) | ||
54 | return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; | ||
55 | } | ||
56 | |||
57 | +static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id) | ||
58 | +{ | ||
59 | + return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0; | ||
60 | +} | ||
61 | + | ||
62 | static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | ||
63 | { | ||
64 | - return FIELD_EX32(id->mvfr1, MVFR1, FPHP) >= 3; | ||
65 | + /* Sadly this is encoded differently for A-profile and M-profile */ | ||
66 | + if (isar_feature_aa32_mprofile(id)) { | ||
67 | + return FIELD_EX32(id->mvfr1, MVFR1, FP16) > 0; | ||
68 | + } else { | ||
69 | + return FIELD_EX32(id->mvfr1, MVFR1, FPHP) >= 3; | ||
70 | + } | ||
71 | } | ||
72 | |||
73 | static inline bool isar_feature_aa32_vfp_simd(const ARMISARegisters *id) | ||
74 | -- | 44 | -- |
75 | 2.20.1 | 45 | 2.20.1 |
76 | 46 | ||
77 | 47 | diff view generated by jsdifflib |
1 | Give the Cortex-M0 ID register values corresponding to its | 1 | The ISCR.ISRPENDING bit is set when an external interrupt is pending. |
---|---|---|---|
2 | implemented behaviour. These will not be guest-visible but will be | 2 | This is true whether that external interrupt is enabled or not. |
3 | used to govern the behaviour of QEMU's emulation. We use the same | 3 | This means that we can't use 's->vectpending == 0' as a shortcut to |
4 | values that the Cortex-M3 does. | 4 | "ISRPENDING is zero", because s->vectpending indicates only the |
5 | highest priority pending enabled interrupt. | ||
6 | |||
7 | Remove the incorrect optimization so that if there is no pending | ||
8 | enabled interrupt we fall through to scanning through the whole | ||
9 | interrupt array. | ||
5 | 10 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200910173855.4068-5-peter.maydell@linaro.org | 13 | Message-id: 20210723162146.5167-5-peter.maydell@linaro.org |
9 | --- | 14 | --- |
10 | target/arm/cpu_tcg.c | 24 ++++++++++++++++++++++++ | 15 | hw/intc/armv7m_nvic.c | 9 ++++----- |
11 | 1 file changed, 24 insertions(+) | 16 | 1 file changed, 4 insertions(+), 5 deletions(-) |
12 | 17 | ||
13 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 18 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
14 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu_tcg.c | 20 | --- a/hw/intc/armv7m_nvic.c |
16 | +++ b/target/arm/cpu_tcg.c | 21 | +++ b/hw/intc/armv7m_nvic.c |
17 | @@ -XXX,XX +XXX,XX @@ static void cortex_m0_initfn(Object *obj) | 22 | @@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s) |
18 | set_feature(&cpu->env, ARM_FEATURE_M); | 23 | { |
19 | 24 | int irq; | |
20 | cpu->midr = 0x410cc200; | 25 | |
21 | + | 26 | - /* We can shortcut if the highest priority pending interrupt |
27 | - * happens to be external or if there is nothing pending. | ||
22 | + /* | 28 | + /* |
23 | + * These ID register values are not guest visible, because | 29 | + * We can shortcut if the highest priority pending interrupt |
24 | + * we do not implement the Main Extension. They must be set | 30 | + * happens to be external; if not we need to check the whole |
25 | + * to values corresponding to the Cortex-M0's implemented | 31 | + * vectors[] array. |
26 | + * features, because QEMU generally controls its emulation | 32 | */ |
27 | + * by looking at ID register fields. We use the same values as | 33 | if (s->vectpending > NVIC_FIRST_IRQ) { |
28 | + * for the M3. | 34 | return true; |
29 | + */ | 35 | } |
30 | + cpu->isar.id_pfr0 = 0x00000030; | 36 | - if (s->vectpending == 0) { |
31 | + cpu->isar.id_pfr1 = 0x00000200; | 37 | - return false; |
32 | + cpu->isar.id_dfr0 = 0x00100000; | 38 | - } |
33 | + cpu->id_afr0 = 0x00000000; | 39 | |
34 | + cpu->isar.id_mmfr0 = 0x00000030; | 40 | for (irq = NVIC_FIRST_IRQ; irq < s->num_irq; irq++) { |
35 | + cpu->isar.id_mmfr1 = 0x00000000; | 41 | if (s->vectors[irq].pending) { |
36 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
37 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
38 | + cpu->isar.id_isar0 = 0x01141110; | ||
39 | + cpu->isar.id_isar1 = 0x02111000; | ||
40 | + cpu->isar.id_isar2 = 0x21112231; | ||
41 | + cpu->isar.id_isar3 = 0x01111110; | ||
42 | + cpu->isar.id_isar4 = 0x01310102; | ||
43 | + cpu->isar.id_isar5 = 0x00000000; | ||
44 | + cpu->isar.id_isar6 = 0x00000000; | ||
45 | } | ||
46 | |||
47 | static void cortex_m3_initfn(Object *obj) | ||
48 | -- | 42 | -- |
49 | 2.20.1 | 43 | 2.20.1 |
50 | 44 | ||
51 | 45 | diff view generated by jsdifflib |
1 | M-profile CPUs only implement the ID registers as guest-visible if | 1 | The VECTPENDING field in the ICSR is 9 bits wide, in bits [20:12] of |
---|---|---|---|
2 | the CPU implements the Main Extension (all our current CPUs except | 2 | the register. We were incorrectly masking it to 8 bits, so it would |
3 | the Cortex-M0 do). | 3 | report the wrong value if the pending exception was greater than 256. |
4 | 4 | Fix the bug. | |
5 | Currently we handle this by having the Cortex-M0 leave the ID | ||
6 | register values in the ARMCPU struct as zero, but this conflicts with | ||
7 | our design decision to make QEMU behaviour be keyed off ID register | ||
8 | fields wherever possible. | ||
9 | |||
10 | Explicitly code the ID registers in the NVIC to return 0 if the Main | ||
11 | Extension is not implemented, so we can make the M0 model set the | ||
12 | ARMCPU struct fields to obtain the correct behaviour without those | ||
13 | values becoming guest-visible. | ||
14 | 5 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20200910173855.4068-4-peter.maydell@linaro.org | 8 | Message-id: 20210723162146.5167-6-peter.maydell@linaro.org |
18 | --- | 9 | --- |
19 | hw/intc/armv7m_nvic.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | 10 | hw/intc/armv7m_nvic.c | 2 +- |
20 | 1 file changed, 42 insertions(+) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
21 | 12 | ||
22 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 13 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
23 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/intc/armv7m_nvic.c | 15 | --- a/hw/intc/armv7m_nvic.c |
25 | +++ b/hw/intc/armv7m_nvic.c | 16 | +++ b/hw/intc/armv7m_nvic.c |
26 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 17 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
27 | "Aux Fault status registers unimplemented\n"); | 18 | /* VECTACTIVE */ |
28 | return 0; | 19 | val = cpu->env.v7m.exception; |
29 | case 0xd40: /* PFR0. */ | 20 | /* VECTPENDING */ |
30 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | 21 | - val |= (s->vectpending & 0xff) << 12; |
31 | + goto bad_offset; | 22 | + val |= (s->vectpending & 0x1ff) << 12; |
32 | + } | 23 | /* ISRPENDING - set if any external IRQ is pending */ |
33 | return cpu->isar.id_pfr0; | 24 | if (nvic_isrpending(s)) { |
34 | case 0xd44: /* PFR1. */ | 25 | val |= (1 << 22); |
35 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
36 | + goto bad_offset; | ||
37 | + } | ||
38 | return cpu->isar.id_pfr1; | ||
39 | case 0xd48: /* DFR0. */ | ||
40 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
41 | + goto bad_offset; | ||
42 | + } | ||
43 | return cpu->isar.id_dfr0; | ||
44 | case 0xd4c: /* AFR0. */ | ||
45 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
46 | + goto bad_offset; | ||
47 | + } | ||
48 | return cpu->id_afr0; | ||
49 | case 0xd50: /* MMFR0. */ | ||
50 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
51 | + goto bad_offset; | ||
52 | + } | ||
53 | return cpu->isar.id_mmfr0; | ||
54 | case 0xd54: /* MMFR1. */ | ||
55 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
56 | + goto bad_offset; | ||
57 | + } | ||
58 | return cpu->isar.id_mmfr1; | ||
59 | case 0xd58: /* MMFR2. */ | ||
60 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
61 | + goto bad_offset; | ||
62 | + } | ||
63 | return cpu->isar.id_mmfr2; | ||
64 | case 0xd5c: /* MMFR3. */ | ||
65 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
66 | + goto bad_offset; | ||
67 | + } | ||
68 | return cpu->isar.id_mmfr3; | ||
69 | case 0xd60: /* ISAR0. */ | ||
70 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
71 | + goto bad_offset; | ||
72 | + } | ||
73 | return cpu->isar.id_isar0; | ||
74 | case 0xd64: /* ISAR1. */ | ||
75 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
76 | + goto bad_offset; | ||
77 | + } | ||
78 | return cpu->isar.id_isar1; | ||
79 | case 0xd68: /* ISAR2. */ | ||
80 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
81 | + goto bad_offset; | ||
82 | + } | ||
83 | return cpu->isar.id_isar2; | ||
84 | case 0xd6c: /* ISAR3. */ | ||
85 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
86 | + goto bad_offset; | ||
87 | + } | ||
88 | return cpu->isar.id_isar3; | ||
89 | case 0xd70: /* ISAR4. */ | ||
90 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
91 | + goto bad_offset; | ||
92 | + } | ||
93 | return cpu->isar.id_isar4; | ||
94 | case 0xd74: /* ISAR5. */ | ||
95 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
96 | + goto bad_offset; | ||
97 | + } | ||
98 | return cpu->isar.id_isar5; | ||
99 | case 0xd78: /* CLIDR */ | ||
100 | return cpu->clidr; | ||
101 | -- | 26 | -- |
102 | 2.20.1 | 27 | 2.20.1 |
103 | 28 | ||
104 | 29 | diff view generated by jsdifflib |
1 | The ARM_FEATURE_PXN bit indicates whether the CPU supports the PXN | 1 | In Arm v8.1M the VECTPENDING field in the ICSR has new behaviour: if |
---|---|---|---|
2 | bit in short-descriptor translation table format descriptors. This | 2 | the register is accessed NonSecure and the highest priority pending |
3 | is indicated by ID_MMFR0.VMSA being at least 0b0100. Replace the | 3 | enabled exception (that would be returned in the VECTPENDING field) |
4 | feature bit with an ID register check, in line with our preference | 4 | targets Secure, then the VECTPENDING field must read 1 rather than |
5 | for ID register checks over feature bits. | 5 | the exception number of the pending exception. Implement this. |
6 | 6 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20200910173855.4068-2-peter.maydell@linaro.org | 9 | Message-id: 20210723162146.5167-7-peter.maydell@linaro.org |
10 | --- | 10 | --- |
11 | target/arm/cpu.h | 15 ++++++++++++++- | 11 | hw/intc/armv7m_nvic.c | 31 ++++++++++++++++++++++++------- |
12 | target/arm/cpu.c | 1 - | 12 | 1 file changed, 24 insertions(+), 7 deletions(-) |
13 | target/arm/helper.c | 5 +++-- | ||
14 | 3 files changed, 17 insertions(+), 4 deletions(-) | ||
15 | 13 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 16 | --- a/hw/intc/armv7m_nvic.c |
19 | +++ b/target/arm/cpu.h | 17 | +++ b/hw/intc/armv7m_nvic.c |
20 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_ISAR6, FHM, 8, 4) | 18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque) |
21 | FIELD(ID_ISAR6, SB, 12, 4) | 19 | nvic_irq_update(s); |
22 | FIELD(ID_ISAR6, SPECRES, 16, 4) | ||
23 | |||
24 | +FIELD(ID_MMFR0, VMSA, 0, 4) | ||
25 | +FIELD(ID_MMFR0, PMSA, 4, 4) | ||
26 | +FIELD(ID_MMFR0, OUTERSHR, 8, 4) | ||
27 | +FIELD(ID_MMFR0, SHARELVL, 12, 4) | ||
28 | +FIELD(ID_MMFR0, TCM, 16, 4) | ||
29 | +FIELD(ID_MMFR0, AUXREG, 20, 4) | ||
30 | +FIELD(ID_MMFR0, FCSE, 24, 4) | ||
31 | +FIELD(ID_MMFR0, INNERSHR, 28, 4) | ||
32 | + | ||
33 | FIELD(ID_MMFR3, CMAINTVA, 0, 4) | ||
34 | FIELD(ID_MMFR3, CMAINTSW, 4, 4) | ||
35 | FIELD(ID_MMFR3, BPMAINT, 8, 4) | ||
36 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | ||
37 | ARM_FEATURE_CACHE_DIRTY_REG, /* 1136/1176 cache dirty status register */ | ||
38 | ARM_FEATURE_CACHE_BLOCK_OPS, /* v6 optional cache block operations */ | ||
39 | ARM_FEATURE_MPIDR, /* has cp15 MPIDR */ | ||
40 | - ARM_FEATURE_PXN, /* has Privileged Execute Never bit */ | ||
41 | ARM_FEATURE_LPAE, /* has Large Physical Address Extension */ | ||
42 | ARM_FEATURE_V8, | ||
43 | ARM_FEATURE_AARCH64, /* supports 64 bit mode */ | ||
44 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id) | ||
45 | return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 4; | ||
46 | } | 20 | } |
47 | 21 | ||
48 | +static inline bool isar_feature_aa32_pxn(const ARMISARegisters *id) | 22 | +static bool vectpending_targets_secure(NVICState *s) |
49 | +{ | 23 | +{ |
50 | + return FIELD_EX32(id->id_mmfr0, ID_MMFR0, VMSA) >= 4; | 24 | + /* Return true if s->vectpending targets Secure state */ |
25 | + if (s->vectpending_is_s_banked) { | ||
26 | + return true; | ||
27 | + } | ||
28 | + return !exc_is_banked(s->vectpending) && | ||
29 | + exc_targets_secure(s, s->vectpending); | ||
51 | +} | 30 | +} |
52 | + | 31 | + |
53 | static inline bool isar_feature_aa32_pan(const ARMISARegisters *id) | 32 | void armv7m_nvic_get_pending_irq_info(void *opaque, |
33 | int *pirq, bool *ptargets_secure) | ||
54 | { | 34 | { |
55 | return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) != 0; | 35 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque, |
56 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 36 | |
57 | index XXXXXXX..XXXXXXX 100644 | 37 | assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq); |
58 | --- a/target/arm/cpu.c | 38 | |
59 | +++ b/target/arm/cpu.c | 39 | - if (s->vectpending_is_s_banked) { |
60 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 40 | - targets_secure = true; |
61 | } | 41 | - } else { |
62 | if (arm_feature(env, ARM_FEATURE_LPAE)) { | 42 | - targets_secure = !exc_is_banked(pending) && |
63 | set_feature(env, ARM_FEATURE_V7MP); | 43 | - exc_targets_secure(s, pending); |
64 | - set_feature(env, ARM_FEATURE_PXN); | 44 | - } |
65 | } | 45 | + targets_secure = vectpending_targets_secure(s); |
66 | if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | 46 | |
67 | set_feature(env, ARM_FEATURE_CBAR); | 47 | trace_nvic_get_pending_irq_info(pending, targets_secure); |
68 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 48 | |
69 | index XXXXXXX..XXXXXXX 100644 | 49 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
70 | --- a/target/arm/helper.c | 50 | /* VECTACTIVE */ |
71 | +++ b/target/arm/helper.c | 51 | val = cpu->env.v7m.exception; |
72 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 52 | /* VECTPENDING */ |
73 | target_ulong *page_size, ARMMMUFaultInfo *fi) | 53 | - val |= (s->vectpending & 0x1ff) << 12; |
74 | { | 54 | + if (s->vectpending) { |
75 | CPUState *cs = env_cpu(env); | 55 | + /* |
76 | + ARMCPU *cpu = env_archcpu(env); | 56 | + * From v8.1M VECTPENDING must read as 1 if accessed as |
77 | int level = 1; | 57 | + * NonSecure and the highest priority pending and enabled |
78 | uint32_t table; | 58 | + * exception targets Secure. |
79 | uint32_t desc; | 59 | + */ |
80 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 60 | + int vp = s->vectpending; |
81 | goto do_fault; | 61 | + if (!attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_V8_1M) && |
82 | } | 62 | + vectpending_targets_secure(s)) { |
83 | type = (desc & 3); | 63 | + vp = 1; |
84 | - if (type == 0 || (type == 3 && !arm_feature(env, ARM_FEATURE_PXN))) { | 64 | + } |
85 | + if (type == 0 || (type == 3 && !cpu_isar_feature(aa32_pxn, cpu))) { | 65 | + val |= (vp & 0x1ff) << 12; |
86 | /* Section translation fault, or attempt to use the encoding | 66 | + } |
87 | * which is Reserved on implementations without PXN. | 67 | /* ISRPENDING - set if any external IRQ is pending */ |
88 | */ | 68 | if (nvic_isrpending(s)) { |
89 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 69 | val |= (1 << 22); |
90 | pxn = desc & 1; | ||
91 | ns = extract32(desc, 19, 1); | ||
92 | } else { | ||
93 | - if (arm_feature(env, ARM_FEATURE_PXN)) { | ||
94 | + if (cpu_isar_feature(aa32_pxn, cpu)) { | ||
95 | pxn = (desc >> 2) & 1; | ||
96 | } | ||
97 | ns = extract32(desc, 3, 1); | ||
98 | -- | 70 | -- |
99 | 2.20.1 | 71 | 2.20.1 |
100 | 72 | ||
101 | 73 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> |
---|---|---|---|
2 | 2 | ||
3 | Now that we can instantiate different machines based on their | 3 | Missed in commit f3478392 "docs: Move deprecation, build |
4 | board_rev register value, we can have various raspi2 and raspi3. | 4 | and license info out of system/" |
5 | 5 | ||
6 | In commit fc78a990ec103 we corrected the machine description. | 6 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> |
7 | Correct the machine names too. For backward compatibility, add | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | an alias to the previous generic name. | 8 | Message-id: 20210723065828.1336760-1-maozhongyi@cmss.chinamobile.com |
9 | |||
10 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Message-id: 20200924111808.77168-6-f4bug@amsat.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | hw/arm/raspi.c | 6 ++++-- | 11 | configure | 2 +- |
16 | 1 file changed, 4 insertions(+), 2 deletions(-) | 12 | target/i386/cpu.c | 2 +- |
13 | MAINTAINERS | 2 +- | ||
14 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
17 | 15 | ||
18 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 16 | diff --git a/configure b/configure |
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/configure | ||
19 | +++ b/configure | ||
20 | @@ -XXX,XX +XXX,XX @@ fi | ||
21 | |||
22 | if test -n "${deprecated_features}"; then | ||
23 | echo "Warning, deprecated features enabled." | ||
24 | - echo "Please see docs/system/deprecated.rst" | ||
25 | + echo "Please see docs/about/deprecated.rst" | ||
26 | echo " features: ${deprecated_features}" | ||
27 | fi | ||
28 | |||
29 | diff --git a/target/i386/cpu.c b/target/i386/cpu.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/raspi.c | 31 | --- a/target/i386/cpu.c |
21 | +++ b/hw/arm/raspi.c | 32 | +++ b/target/i386/cpu.c |
22 | @@ -XXX,XX +XXX,XX @@ static void raspi2b_machine_class_init(ObjectClass *oc, void *data) | 33 | @@ -XXX,XX +XXX,XX @@ static const X86CPUDefinition builtin_x86_defs[] = { |
23 | MachineClass *mc = MACHINE_CLASS(oc); | 34 | * none", but this is just for compatibility while libvirt isn't |
24 | RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | 35 | * adapted to resolve CPU model versions before creating VMs. |
25 | 36 | * See "Runnability guarantee of CPU models" at | |
26 | + mc->alias = "raspi2"; | 37 | - * docs/system/deprecated.rst. |
27 | rmc->board_rev = 0xa21041; | 38 | + * docs/about/deprecated.rst. |
28 | raspi_machine_class_common_init(mc, rmc->board_rev); | 39 | */ |
29 | }; | 40 | X86CPUVersion default_cpu_version = 1; |
30 | @@ -XXX,XX +XXX,XX @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data) | 41 | |
31 | MachineClass *mc = MACHINE_CLASS(oc); | 42 | diff --git a/MAINTAINERS b/MAINTAINERS |
32 | RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | 43 | index XXXXXXX..XXXXXXX 100644 |
33 | 44 | --- a/MAINTAINERS | |
34 | + mc->alias = "raspi3"; | 45 | +++ b/MAINTAINERS |
35 | rmc->board_rev = 0xa02082; | 46 | @@ -XXX,XX +XXX,XX @@ F: contrib/gitdm/* |
36 | raspi_machine_class_common_init(mc, rmc->board_rev); | 47 | |
37 | }; | 48 | Incompatible changes |
38 | @@ -XXX,XX +XXX,XX @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data) | 49 | R: libvir-list@redhat.com |
39 | 50 | -F: docs/system/deprecated.rst | |
40 | static const TypeInfo raspi_machine_types[] = { | 51 | +F: docs/about/deprecated.rst |
41 | { | 52 | |
42 | - .name = MACHINE_TYPE_NAME("raspi2"), | 53 | Build System |
43 | + .name = MACHINE_TYPE_NAME("raspi2b"), | 54 | ------------ |
44 | .parent = TYPE_RASPI_MACHINE, | ||
45 | .class_init = raspi2b_machine_class_init, | ||
46 | #ifdef TARGET_AARCH64 | ||
47 | }, { | ||
48 | - .name = MACHINE_TYPE_NAME("raspi3"), | ||
49 | + .name = MACHINE_TYPE_NAME("raspi3b"), | ||
50 | .parent = TYPE_RASPI_MACHINE, | ||
51 | .class_init = raspi3b_machine_class_init, | ||
52 | #endif | ||
53 | -- | 55 | -- |
54 | 2.20.1 | 56 | 2.20.1 |
55 | 57 | ||
56 | 58 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The mte update missed a bit when producing clean addresses. | 3 | Currently, our only caller is sve_zcr_len_for_el, which has |
4 | already masked the length extracted from ZCR_ELx, so the | ||
5 | masking done here is a nop. But we will shortly have uses | ||
6 | from other locations, where the length will be unmasked. | ||
4 | 7 | ||
5 | Fixes: b2aa8879b88 | 8 | Saturate the length to ARM_MAX_VQ instead of truncating to |
9 | the low 4 bits. | ||
10 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200916014102.2446323-1-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Message-id: 20210723203344.968563-2-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 15 | --- |
11 | target/arm/translate-sve.c | 4 ++-- | 16 | target/arm/helper.c | 4 +++- |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 17 | 1 file changed, 3 insertions(+), 1 deletion(-) |
13 | 18 | ||
14 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 19 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-sve.c | 21 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/translate-sve.c | 22 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | 23 | @@ -XXX,XX +XXX,XX @@ static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
19 | for (i = 0; i < len_align; i += 8) { | 24 | { |
20 | tcg_gen_qemu_ld_i64(t0, clean_addr, midx, MO_LEQ); | 25 | uint32_t end_len; |
21 | tcg_gen_st_i64(t0, cpu_env, vofs + i); | 26 | |
22 | - tcg_gen_addi_i64(clean_addr, cpu_reg_sp(s, rn), 8); | 27 | - end_len = start_len &= 0xf; |
23 | + tcg_gen_addi_i64(clean_addr, clean_addr, 8); | 28 | + start_len = MIN(start_len, ARM_MAX_VQ - 1); |
24 | } | 29 | + end_len = start_len; |
25 | tcg_temp_free_i64(t0); | 30 | + |
26 | } else { | 31 | if (!test_bit(start_len, cpu->sve_vq_map)) { |
27 | @@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | 32 | end_len = find_last_bit(cpu->sve_vq_map, start_len); |
28 | for (i = 0; i < len_align; i += 8) { | 33 | assert(end_len < start_len); |
29 | tcg_gen_ld_i64(t0, cpu_env, vofs + i); | ||
30 | tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEQ); | ||
31 | - tcg_gen_addi_i64(clean_addr, cpu_reg_sp(s, rn), 8); | ||
32 | + tcg_gen_addi_i64(clean_addr, clean_addr, 8); | ||
33 | } | ||
34 | tcg_temp_free_i64(t0); | ||
35 | } else { | ||
36 | -- | 34 | -- |
37 | 2.20.1 | 35 | 2.20.1 |
38 | 36 | ||
39 | 37 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The arm_boot_info structure belong to the machine, | 3 | Rename from sve_zcr_get_valid_len and make accessible |
4 | move it to RaspiMachineState. | 4 | from outside of helper.c. |
5 | 5 | ||
6 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20200924111808.77168-4-f4bug@amsat.org | 8 | Message-id: 20210723203344.968563-3-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | hw/arm/raspi.c | 30 +++++++++++++++--------------- | 11 | target/arm/internals.h | 10 ++++++++++ |
12 | 1 file changed, 15 insertions(+), 15 deletions(-) | 12 | target/arm/helper.c | 4 ++-- |
13 | 2 files changed, 12 insertions(+), 2 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 15 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/raspi.c | 17 | --- a/target/arm/internals.h |
17 | +++ b/hw/arm/raspi.c | 18 | +++ b/target/arm/internals.h |
18 | @@ -XXX,XX +XXX,XX @@ struct RaspiMachineState { | 19 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void); |
19 | MachineState parent_obj; | 20 | void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); |
20 | /*< public >*/ | 21 | #endif /* CONFIG_TCG */ |
21 | BCM283XState soc; | 22 | |
22 | + struct arm_boot_info binfo; | 23 | +/** |
23 | }; | 24 | + * aarch64_sve_zcr_get_valid_len: |
24 | typedef struct RaspiMachineState RaspiMachineState; | 25 | + * @cpu: cpu context |
25 | 26 | + * @start_len: maximum len to consider | |
26 | @@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) | 27 | + * |
27 | static void setup_boot(MachineState *machine, int version, size_t ram_size) | 28 | + * Return the maximum supported sve vector length <= @start_len. |
29 | + * Note that both @start_len and the return value are in units | ||
30 | + * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128. | ||
31 | + */ | ||
32 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len); | ||
33 | |||
34 | enum arm_fprounding { | ||
35 | FPROUNDING_TIEEVEN, | ||
36 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/helper.c | ||
39 | +++ b/target/arm/helper.c | ||
40 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | -static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | ||
45 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | ||
28 | { | 46 | { |
29 | RaspiMachineState *s = RASPI_MACHINE(machine); | 47 | uint32_t end_len; |
30 | - static struct arm_boot_info binfo; | 48 | |
31 | int r; | 49 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) |
32 | 50 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | |
33 | - binfo.board_id = MACH_TYPE_BCM2708; | ||
34 | - binfo.ram_size = ram_size; | ||
35 | - binfo.nb_cpus = machine->smp.cpus; | ||
36 | + s->binfo.board_id = MACH_TYPE_BCM2708; | ||
37 | + s->binfo.ram_size = ram_size; | ||
38 | + s->binfo.nb_cpus = machine->smp.cpus; | ||
39 | |||
40 | if (version <= 2) { | ||
41 | /* The rpi1 and 2 require some custom setup code to run in Secure | ||
42 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
43 | * firmware for some cache maintenance operations. | ||
44 | * The rpi3 doesn't need this. | ||
45 | */ | ||
46 | - binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
47 | - binfo.write_board_setup = write_board_setup; | ||
48 | - binfo.secure_board_setup = true; | ||
49 | - binfo.secure_boot = true; | ||
50 | + s->binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
51 | + s->binfo.write_board_setup = write_board_setup; | ||
52 | + s->binfo.secure_board_setup = true; | ||
53 | + s->binfo.secure_boot = true; | ||
54 | } | 51 | } |
55 | 52 | ||
56 | /* Pi2 and Pi3 requires SMP setup */ | 53 | - return sve_zcr_get_valid_len(cpu, zcr_len); |
57 | if (version >= 2) { | 54 | + return aarch64_sve_zcr_get_valid_len(cpu, zcr_len); |
58 | - binfo.smp_loader_start = SMPBOOT_ADDR; | ||
59 | + s->binfo.smp_loader_start = SMPBOOT_ADDR; | ||
60 | if (version == 2) { | ||
61 | - binfo.write_secondary_boot = write_smpboot; | ||
62 | + s->binfo.write_secondary_boot = write_smpboot; | ||
63 | } else { | ||
64 | - binfo.write_secondary_boot = write_smpboot64; | ||
65 | + s->binfo.write_secondary_boot = write_smpboot64; | ||
66 | } | ||
67 | - binfo.secondary_cpu_reset_hook = reset_secondary; | ||
68 | + s->binfo.secondary_cpu_reset_hook = reset_secondary; | ||
69 | } | ||
70 | |||
71 | /* If the user specified a "firmware" image (e.g. UEFI), we bypass | ||
72 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
73 | exit(1); | ||
74 | } | ||
75 | |||
76 | - binfo.entry = firmware_addr; | ||
77 | - binfo.firmware_loaded = true; | ||
78 | + s->binfo.entry = firmware_addr; | ||
79 | + s->binfo.firmware_loaded = true; | ||
80 | } | ||
81 | |||
82 | - arm_load_kernel(&s->soc.cpu[0].core, machine, &binfo); | ||
83 | + arm_load_kernel(&s->soc.cpu[0].core, machine, &s->binfo); | ||
84 | } | 55 | } |
85 | 56 | ||
86 | static void raspi_machine_init(MachineState *machine) | 57 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
87 | -- | 58 | -- |
88 | 2.20.1 | 59 | 2.20.1 |
89 | 60 | ||
90 | 61 | diff view generated by jsdifflib |
1 | Move the id_pfr0 and id_pfr1 fields into the ARMISARegisters | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | sub-struct. We're going to want id_pfr1 for an isar_features | ||
3 | check, and moving both at the same time avoids an odd | ||
4 | inconsistency. | ||
5 | 2 | ||
6 | Changes other than the ones to cpu.h and kvm64.c made | 3 | Mirror the behavour of /proc/sys/abi/sve_default_vector_length |
7 | automatically with: | 4 | under the real linux kernel. We have no way of passing along |
8 | perl -p -i -e 's/cpu->id_pfr/cpu->isar.id_pfr/' target/arm/*.c hw/intc/armv7m_nvic.c | 5 | a real default across exec like the kernel can, but this is a |
6 | decent way of adjusting the startup vector length of a process. | ||
9 | 7 | ||
8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/482 | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20210723203344.968563-4-richard.henderson@linaro.org | ||
12 | [PMM: tweaked docs formatting, document -1 special-case, | ||
13 | added fixup patch from RTH mentioning QEMU's maximum veclen.] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20200910173855.4068-3-peter.maydell@linaro.org | ||
13 | --- | 15 | --- |
14 | target/arm/cpu.h | 4 ++-- | 16 | docs/system/arm/cpu-features.rst | 15 ++++++++ |
15 | hw/intc/armv7m_nvic.c | 4 ++-- | 17 | target/arm/cpu.h | 5 +++ |
16 | target/arm/cpu.c | 20 ++++++++++---------- | 18 | target/arm/cpu.c | 14 ++++++-- |
17 | target/arm/cpu64.c | 12 ++++++------ | 19 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++ |
18 | target/arm/cpu_tcg.c | 36 ++++++++++++++++++------------------ | 20 | 4 files changed, 92 insertions(+), 2 deletions(-) |
19 | target/arm/helper.c | 4 ++-- | ||
20 | target/arm/kvm64.c | 4 ++++ | ||
21 | 7 files changed, 44 insertions(+), 40 deletions(-) | ||
22 | 21 | ||
22 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/docs/system/arm/cpu-features.rst | ||
25 | +++ b/docs/system/arm/cpu-features.rst | ||
26 | @@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector | ||
27 | lengths is to explicitly enable each desired length. Therefore only | ||
28 | example's (1), (4), and (6) exhibit recommended uses of the properties. | ||
29 | |||
30 | +SVE User-mode Default Vector Length Property | ||
31 | +-------------------------------------------- | ||
32 | + | ||
33 | +For qemu-aarch64, the cpu property ``sve-default-vector-length=N`` is | ||
34 | +defined to mirror the Linux kernel parameter file | ||
35 | +``/proc/sys/abi/sve_default_vector_length``. The default length, ``N``, | ||
36 | +is in units of bytes and must be between 16 and 8192. | ||
37 | +If not specified, the default vector length is 64. | ||
38 | + | ||
39 | +If the default length is larger than the maximum vector length enabled, | ||
40 | +the actual vector length will be reduced. Note that the maximum vector | ||
41 | +length supported by QEMU is 256. | ||
42 | + | ||
43 | +If this property is set to ``-1`` then the default vector length | ||
44 | +is set to the maximum possible length. | ||
23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 45 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
24 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/cpu.h | 47 | --- a/target/arm/cpu.h |
26 | +++ b/target/arm/cpu.h | 48 | +++ b/target/arm/cpu.h |
27 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 49 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
28 | uint32_t id_mmfr2; | 50 | /* Used to set the maximum vector length the cpu will support. */ |
29 | uint32_t id_mmfr3; | 51 | uint32_t sve_max_vq; |
30 | uint32_t id_mmfr4; | 52 | |
31 | + uint32_t id_pfr0; | 53 | +#ifdef CONFIG_USER_ONLY |
32 | + uint32_t id_pfr1; | 54 | + /* Used to set the default vector length at process start. */ |
33 | uint32_t mvfr0; | 55 | + uint32_t sve_default_vq; |
34 | uint32_t mvfr1; | 56 | +#endif |
35 | uint32_t mvfr2; | 57 | + |
36 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 58 | /* |
37 | uint32_t reset_fpsid; | 59 | * In sve_vq_map each set bit is a supported vector length of |
38 | uint32_t ctr; | 60 | * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector |
39 | uint32_t reset_sctlr; | ||
40 | - uint32_t id_pfr0; | ||
41 | - uint32_t id_pfr1; | ||
42 | uint64_t pmceid0; | ||
43 | uint64_t pmceid1; | ||
44 | uint32_t id_afr0; | ||
45 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/intc/armv7m_nvic.c | ||
48 | +++ b/hw/intc/armv7m_nvic.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
50 | "Aux Fault status registers unimplemented\n"); | ||
51 | return 0; | ||
52 | case 0xd40: /* PFR0. */ | ||
53 | - return cpu->id_pfr0; | ||
54 | + return cpu->isar.id_pfr0; | ||
55 | case 0xd44: /* PFR1. */ | ||
56 | - return cpu->id_pfr1; | ||
57 | + return cpu->isar.id_pfr1; | ||
58 | case 0xd48: /* DFR0. */ | ||
59 | return cpu->isar.id_dfr0; | ||
60 | case 0xd4c: /* AFR0. */ | ||
61 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 61 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
62 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
63 | --- a/target/arm/cpu.c | 63 | --- a/target/arm/cpu.c |
64 | +++ b/target/arm/cpu.c | 64 | +++ b/target/arm/cpu.c |
65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
66 | /* Disable the security extension feature bits in the processor feature | 66 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); |
67 | * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. | 67 | /* with reasonable vector length */ |
68 | */ | 68 | if (cpu_isar_feature(aa64_sve, cpu)) { |
69 | - cpu->id_pfr1 &= ~0xf0; | 69 | - env->vfp.zcr_el[1] = MIN(cpu->sve_max_vq - 1, 3); |
70 | + cpu->isar.id_pfr1 &= ~0xf0; | 70 | + env->vfp.zcr_el[1] = |
71 | cpu->isar.id_aa64pfr0 &= ~0xf000; | 71 | + aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1); |
72 | } | 72 | } |
73 | 73 | /* | |
74 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 74 | * Enable TBI0 but not TBI1. |
75 | * id_aa64pfr0_el1[11:8]. | 75 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) |
76 | */ | 76 | QLIST_INIT(&cpu->pre_el_change_hooks); |
77 | cpu->isar.id_aa64pfr0 &= ~0xf00; | 77 | QLIST_INIT(&cpu->el_change_hooks); |
78 | - cpu->id_pfr1 &= ~0xf000; | 78 | |
79 | + cpu->isar.id_pfr1 &= ~0xf000; | 79 | -#ifndef CONFIG_USER_ONLY |
80 | } | 80 | +#ifdef CONFIG_USER_ONLY |
81 | 81 | +# ifdef TARGET_AARCH64 | |
82 | #ifndef CONFIG_USER_ONLY | 82 | + /* |
83 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | 83 | + * The linux kernel defaults to 512-bit vectors, when sve is supported. |
84 | cpu->isar.mvfr1 = 0x00011111; | 84 | + * See documentation for /proc/sys/abi/sve_default_vector_length, and |
85 | cpu->ctr = 0x82048004; | 85 | + * our corresponding sve-default-vector-length cpu property. |
86 | cpu->reset_sctlr = 0x00c50078; | 86 | + */ |
87 | - cpu->id_pfr0 = 0x1031; | 87 | + cpu->sve_default_vq = 4; |
88 | - cpu->id_pfr1 = 0x11; | 88 | +# endif |
89 | + cpu->isar.id_pfr0 = 0x1031; | 89 | +#else |
90 | + cpu->isar.id_pfr1 = 0x11; | 90 | /* Our inbound IRQ and FIQ lines */ |
91 | cpu->isar.id_dfr0 = 0x400; | 91 | if (kvm_enabled()) { |
92 | cpu->id_afr0 = 0; | 92 | /* VIRQ and VFIQ are unused with KVM but we add them to maintain |
93 | cpu->isar.id_mmfr0 = 0x31100003; | ||
94 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
95 | cpu->isar.mvfr1 = 0x01111111; | ||
96 | cpu->ctr = 0x80038003; | ||
97 | cpu->reset_sctlr = 0x00c50078; | ||
98 | - cpu->id_pfr0 = 0x1031; | ||
99 | - cpu->id_pfr1 = 0x11; | ||
100 | + cpu->isar.id_pfr0 = 0x1031; | ||
101 | + cpu->isar.id_pfr1 = 0x11; | ||
102 | cpu->isar.id_dfr0 = 0x000; | ||
103 | cpu->id_afr0 = 0; | ||
104 | cpu->isar.id_mmfr0 = 0x00100103; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
106 | cpu->isar.mvfr1 = 0x11111111; | ||
107 | cpu->ctr = 0x84448003; | ||
108 | cpu->reset_sctlr = 0x00c50078; | ||
109 | - cpu->id_pfr0 = 0x00001131; | ||
110 | - cpu->id_pfr1 = 0x00011011; | ||
111 | + cpu->isar.id_pfr0 = 0x00001131; | ||
112 | + cpu->isar.id_pfr1 = 0x00011011; | ||
113 | cpu->isar.id_dfr0 = 0x02010555; | ||
114 | cpu->id_afr0 = 0x00000000; | ||
115 | cpu->isar.id_mmfr0 = 0x10101105; | ||
116 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
117 | cpu->isar.mvfr1 = 0x11111111; | ||
118 | cpu->ctr = 0x8444c004; | ||
119 | cpu->reset_sctlr = 0x00c50078; | ||
120 | - cpu->id_pfr0 = 0x00001131; | ||
121 | - cpu->id_pfr1 = 0x00011011; | ||
122 | + cpu->isar.id_pfr0 = 0x00001131; | ||
123 | + cpu->isar.id_pfr1 = 0x00011011; | ||
124 | cpu->isar.id_dfr0 = 0x02010555; | ||
125 | cpu->id_afr0 = 0x00000000; | ||
126 | cpu->isar.id_mmfr0 = 0x10201105; | ||
127 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 93 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
128 | index XXXXXXX..XXXXXXX 100644 | 94 | index XXXXXXX..XXXXXXX 100644 |
129 | --- a/target/arm/cpu64.c | 95 | --- a/target/arm/cpu64.c |
130 | +++ b/target/arm/cpu64.c | 96 | +++ b/target/arm/cpu64.c |
131 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | 97 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) |
132 | cpu->isar.mvfr2 = 0x00000043; | 98 | cpu->isar.id_aa64pfr0 = t; |
133 | cpu->ctr = 0x8444c004; | 99 | } |
134 | cpu->reset_sctlr = 0x00c50838; | 100 | |
135 | - cpu->id_pfr0 = 0x00000131; | 101 | +#ifdef CONFIG_USER_ONLY |
136 | - cpu->id_pfr1 = 0x00011011; | 102 | +/* Mirror linux /proc/sys/abi/sve_default_vector_length. */ |
137 | + cpu->isar.id_pfr0 = 0x00000131; | 103 | +static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, |
138 | + cpu->isar.id_pfr1 = 0x00011011; | 104 | + const char *name, void *opaque, |
139 | cpu->isar.id_dfr0 = 0x03010066; | 105 | + Error **errp) |
140 | cpu->id_afr0 = 0x00000000; | 106 | +{ |
141 | cpu->isar.id_mmfr0 = 0x10101105; | 107 | + ARMCPU *cpu = ARM_CPU(obj); |
142 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | 108 | + int32_t default_len, default_vq, remainder; |
143 | cpu->isar.mvfr2 = 0x00000043; | 109 | + |
144 | cpu->ctr = 0x84448004; /* L1Ip = VIPT */ | 110 | + if (!visit_type_int32(v, name, &default_len, errp)) { |
145 | cpu->reset_sctlr = 0x00c50838; | 111 | + return; |
146 | - cpu->id_pfr0 = 0x00000131; | 112 | + } |
147 | - cpu->id_pfr1 = 0x00011011; | 113 | + |
148 | + cpu->isar.id_pfr0 = 0x00000131; | 114 | + /* Undocumented, but the kernel allows -1 to indicate "maximum". */ |
149 | + cpu->isar.id_pfr1 = 0x00011011; | 115 | + if (default_len == -1) { |
150 | cpu->isar.id_dfr0 = 0x03010066; | 116 | + cpu->sve_default_vq = ARM_MAX_VQ; |
151 | cpu->id_afr0 = 0x00000000; | 117 | + return; |
152 | cpu->isar.id_mmfr0 = 0x10101105; | 118 | + } |
153 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | 119 | + |
154 | cpu->isar.mvfr2 = 0x00000043; | 120 | + default_vq = default_len / 16; |
155 | cpu->ctr = 0x8444c004; | 121 | + remainder = default_len % 16; |
156 | cpu->reset_sctlr = 0x00c50838; | 122 | + |
157 | - cpu->id_pfr0 = 0x00000131; | 123 | + /* |
158 | - cpu->id_pfr1 = 0x00011011; | 124 | + * Note that the 512 max comes from include/uapi/asm/sve_context.h |
159 | + cpu->isar.id_pfr0 = 0x00000131; | 125 | + * and is the maximum architectural width of ZCR_ELx.LEN. |
160 | + cpu->isar.id_pfr1 = 0x00011011; | 126 | + */ |
161 | cpu->isar.id_dfr0 = 0x03010066; | 127 | + if (remainder || default_vq < 1 || default_vq > 512) { |
162 | cpu->id_afr0 = 0x00000000; | 128 | + error_setg(errp, "cannot set sve-default-vector-length"); |
163 | cpu->isar.id_mmfr0 = 0x10201105; | 129 | + if (remainder) { |
164 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 130 | + error_append_hint(errp, "Vector length not a multiple of 16\n"); |
165 | index XXXXXXX..XXXXXXX 100644 | 131 | + } else if (default_vq < 1) { |
166 | --- a/target/arm/cpu_tcg.c | 132 | + error_append_hint(errp, "Vector length smaller than 16\n"); |
167 | +++ b/target/arm/cpu_tcg.c | 133 | + } else { |
168 | @@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj) | 134 | + error_append_hint(errp, "Vector length larger than %d\n", |
169 | cpu->isar.mvfr1 = 0x00000000; | 135 | + 512 * 16); |
170 | cpu->ctr = 0x1dd20d2; | 136 | + } |
171 | cpu->reset_sctlr = 0x00050078; | 137 | + return; |
172 | - cpu->id_pfr0 = 0x111; | 138 | + } |
173 | - cpu->id_pfr1 = 0x1; | 139 | + |
174 | + cpu->isar.id_pfr0 = 0x111; | 140 | + cpu->sve_default_vq = default_vq; |
175 | + cpu->isar.id_pfr1 = 0x1; | 141 | +} |
176 | cpu->isar.id_dfr0 = 0x2; | 142 | + |
177 | cpu->id_afr0 = 0x3; | 143 | +static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, |
178 | cpu->isar.id_mmfr0 = 0x01130003; | 144 | + const char *name, void *opaque, |
179 | @@ -XXX,XX +XXX,XX @@ static void arm1136_initfn(Object *obj) | 145 | + Error **errp) |
180 | cpu->isar.mvfr1 = 0x00000000; | 146 | +{ |
181 | cpu->ctr = 0x1dd20d2; | 147 | + ARMCPU *cpu = ARM_CPU(obj); |
182 | cpu->reset_sctlr = 0x00050078; | 148 | + int32_t value = cpu->sve_default_vq * 16; |
183 | - cpu->id_pfr0 = 0x111; | 149 | + |
184 | - cpu->id_pfr1 = 0x1; | 150 | + visit_type_int32(v, name, &value, errp); |
185 | + cpu->isar.id_pfr0 = 0x111; | 151 | +} |
186 | + cpu->isar.id_pfr1 = 0x1; | 152 | +#endif |
187 | cpu->isar.id_dfr0 = 0x2; | 153 | + |
188 | cpu->id_afr0 = 0x3; | 154 | void aarch64_add_sve_properties(Object *obj) |
189 | cpu->isar.id_mmfr0 = 0x01130003; | ||
190 | @@ -XXX,XX +XXX,XX @@ static void arm1176_initfn(Object *obj) | ||
191 | cpu->isar.mvfr1 = 0x00000000; | ||
192 | cpu->ctr = 0x1dd20d2; | ||
193 | cpu->reset_sctlr = 0x00050078; | ||
194 | - cpu->id_pfr0 = 0x111; | ||
195 | - cpu->id_pfr1 = 0x11; | ||
196 | + cpu->isar.id_pfr0 = 0x111; | ||
197 | + cpu->isar.id_pfr1 = 0x11; | ||
198 | cpu->isar.id_dfr0 = 0x33; | ||
199 | cpu->id_afr0 = 0; | ||
200 | cpu->isar.id_mmfr0 = 0x01130003; | ||
201 | @@ -XXX,XX +XXX,XX @@ static void arm11mpcore_initfn(Object *obj) | ||
202 | cpu->isar.mvfr0 = 0x11111111; | ||
203 | cpu->isar.mvfr1 = 0x00000000; | ||
204 | cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */ | ||
205 | - cpu->id_pfr0 = 0x111; | ||
206 | - cpu->id_pfr1 = 0x1; | ||
207 | + cpu->isar.id_pfr0 = 0x111; | ||
208 | + cpu->isar.id_pfr1 = 0x1; | ||
209 | cpu->isar.id_dfr0 = 0; | ||
210 | cpu->id_afr0 = 0x2; | ||
211 | cpu->isar.id_mmfr0 = 0x01100103; | ||
212 | @@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj) | ||
213 | set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
214 | cpu->midr = 0x410fc231; | ||
215 | cpu->pmsav7_dregion = 8; | ||
216 | - cpu->id_pfr0 = 0x00000030; | ||
217 | - cpu->id_pfr1 = 0x00000200; | ||
218 | + cpu->isar.id_pfr0 = 0x00000030; | ||
219 | + cpu->isar.id_pfr1 = 0x00000200; | ||
220 | cpu->isar.id_dfr0 = 0x00100000; | ||
221 | cpu->id_afr0 = 0x00000000; | ||
222 | cpu->isar.id_mmfr0 = 0x00000030; | ||
223 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | ||
224 | cpu->isar.mvfr0 = 0x10110021; | ||
225 | cpu->isar.mvfr1 = 0x11000011; | ||
226 | cpu->isar.mvfr2 = 0x00000000; | ||
227 | - cpu->id_pfr0 = 0x00000030; | ||
228 | - cpu->id_pfr1 = 0x00000200; | ||
229 | + cpu->isar.id_pfr0 = 0x00000030; | ||
230 | + cpu->isar.id_pfr1 = 0x00000200; | ||
231 | cpu->isar.id_dfr0 = 0x00100000; | ||
232 | cpu->id_afr0 = 0x00000000; | ||
233 | cpu->isar.id_mmfr0 = 0x00000030; | ||
234 | @@ -XXX,XX +XXX,XX @@ static void cortex_m7_initfn(Object *obj) | ||
235 | cpu->isar.mvfr0 = 0x10110221; | ||
236 | cpu->isar.mvfr1 = 0x12000011; | ||
237 | cpu->isar.mvfr2 = 0x00000040; | ||
238 | - cpu->id_pfr0 = 0x00000030; | ||
239 | - cpu->id_pfr1 = 0x00000200; | ||
240 | + cpu->isar.id_pfr0 = 0x00000030; | ||
241 | + cpu->isar.id_pfr1 = 0x00000200; | ||
242 | cpu->isar.id_dfr0 = 0x00100000; | ||
243 | cpu->id_afr0 = 0x00000000; | ||
244 | cpu->isar.id_mmfr0 = 0x00100030; | ||
245 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | ||
246 | cpu->isar.mvfr0 = 0x10110021; | ||
247 | cpu->isar.mvfr1 = 0x11000011; | ||
248 | cpu->isar.mvfr2 = 0x00000040; | ||
249 | - cpu->id_pfr0 = 0x00000030; | ||
250 | - cpu->id_pfr1 = 0x00000210; | ||
251 | + cpu->isar.id_pfr0 = 0x00000030; | ||
252 | + cpu->isar.id_pfr1 = 0x00000210; | ||
253 | cpu->isar.id_dfr0 = 0x00200000; | ||
254 | cpu->id_afr0 = 0x00000000; | ||
255 | cpu->isar.id_mmfr0 = 0x00101F40; | ||
256 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | ||
257 | set_feature(&cpu->env, ARM_FEATURE_PMSA); | ||
258 | set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
259 | cpu->midr = 0x411fc153; /* r1p3 */ | ||
260 | - cpu->id_pfr0 = 0x0131; | ||
261 | - cpu->id_pfr1 = 0x001; | ||
262 | + cpu->isar.id_pfr0 = 0x0131; | ||
263 | + cpu->isar.id_pfr1 = 0x001; | ||
264 | cpu->isar.id_dfr0 = 0x010400; | ||
265 | cpu->id_afr0 = 0x0; | ||
266 | cpu->isar.id_mmfr0 = 0x0210030; | ||
267 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
268 | index XXXXXXX..XXXXXXX 100644 | ||
269 | --- a/target/arm/helper.c | ||
270 | +++ b/target/arm/helper.c | ||
271 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
272 | static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
273 | { | 155 | { |
274 | ARMCPU *cpu = env_archcpu(env); | 156 | uint32_t vq; |
275 | - uint64_t pfr1 = cpu->id_pfr1; | 157 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) |
276 | + uint64_t pfr1 = cpu->isar.id_pfr1; | 158 | object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, |
277 | 159 | cpu_arm_set_sve_vq, NULL, NULL); | |
278 | if (env->gicv3state) { | 160 | } |
279 | pfr1 |= 1 << 28; | 161 | + |
280 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 162 | +#ifdef CONFIG_USER_ONLY |
281 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 0, | 163 | + /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ |
282 | .access = PL1_R, .type = ARM_CP_CONST, | 164 | + object_property_add(obj, "sve-default-vector-length", "int32", |
283 | .accessfn = access_aa32_tid3, | 165 | + cpu_arm_get_sve_default_vec_len, |
284 | - .resetvalue = cpu->id_pfr0 }, | 166 | + cpu_arm_set_sve_default_vec_len, NULL, NULL); |
285 | + .resetvalue = cpu->isar.id_pfr0 }, | 167 | +#endif |
286 | /* ID_PFR1 is not a plain ARM_CP_CONST because we don't know | 168 | } |
287 | * the value of the GIC field until after we define these regs. | 169 | |
288 | */ | 170 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) |
289 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
290 | index XXXXXXX..XXXXXXX 100644 | ||
291 | --- a/target/arm/kvm64.c | ||
292 | +++ b/target/arm/kvm64.c | ||
293 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
294 | * than skipping the reads and leaving 0, as we must avoid | ||
295 | * considering the values in every case. | ||
296 | */ | ||
297 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0, | ||
298 | + ARM64_SYS_REG(3, 0, 0, 1, 0)); | ||
299 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, | ||
300 | + ARM64_SYS_REG(3, 0, 0, 1, 1)); | ||
301 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, | ||
302 | ARM64_SYS_REG(3, 0, 0, 1, 2)); | ||
303 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, | ||
304 | -- | 171 | -- |
305 | 2.20.1 | 172 | 2.20.1 |
306 | 173 | ||
307 | 174 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | The Raspberry firmware is closed-source. While running it, it | ||
4 | accesses various I/O registers. Logging these accesses as UNIMP | ||
5 | (unimplemented) help to understand what the firmware is doing | ||
6 | (ideally we want it able to boot a Linux kernel). | ||
7 | |||
8 | Document various blocks we might use later. | ||
9 | |||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
13 | Message-id: 20200921034729.432931-2-f4bug@amsat.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/arm/raspi_platform.h | 51 +++++++++++++++++++++++++++------ | ||
17 | 1 file changed, 43 insertions(+), 8 deletions(-) | ||
18 | |||
19 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/hw/arm/raspi_platform.h | ||
22 | +++ b/include/hw/arm/raspi_platform.h | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
27 | + * | ||
28 | + * Various undocumented addresses and names come from Herman Hermitage's VC4 | ||
29 | + * documentation: | ||
30 | + * https://github.com/hermanhermitage/videocoreiv/wiki/MMIO-Register-map | ||
31 | */ | ||
32 | |||
33 | #ifndef HW_ARM_RASPI_PLATFORM_H | ||
34 | #define HW_ARM_RASPI_PLATFORM_H | ||
35 | |||
36 | #define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */ | ||
37 | -#define IC0_OFFSET 0x2000 | ||
38 | +#define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */ | ||
39 | +#define INTE_OFFSET 0x2000 /* VC Interrupt controller */ | ||
40 | #define ST_OFFSET 0x3000 /* System Timer */ | ||
41 | +#define TXP_OFFSET 0x4000 /* Transposer */ | ||
42 | +#define JPEG_OFFSET 0x5000 | ||
43 | #define MPHI_OFFSET 0x6000 /* Message-based Parallel Host Intf. */ | ||
44 | #define DMA_OFFSET 0x7000 /* DMA controller, channels 0-14 */ | ||
45 | -#define ARM_OFFSET 0xB000 /* BCM2708 ARM control block */ | ||
46 | +#define ARBA_OFFSET 0x9000 | ||
47 | +#define BRDG_OFFSET 0xa000 | ||
48 | +#define ARM_OFFSET 0xB000 /* ARM control block */ | ||
49 | #define ARMCTRL_OFFSET (ARM_OFFSET + 0x000) | ||
50 | #define ARMCTRL_IC_OFFSET (ARM_OFFSET + 0x200) /* Interrupt controller */ | ||
51 | -#define ARMCTRL_TIMER0_1_OFFSET (ARM_OFFSET + 0x400) /* Timer 0 and 1 */ | ||
52 | +#define ARMCTRL_TIMER0_1_OFFSET (ARM_OFFSET + 0x400) /* Timer 0 and 1 (SP804) */ | ||
53 | #define ARMCTRL_0_SBM_OFFSET (ARM_OFFSET + 0x800) /* User 0 (ARM) Semaphores | ||
54 | * Doorbells & Mailboxes */ | ||
55 | #define CPRMAN_OFFSET 0x100000 /* Power Management, Watchdog */ | ||
56 | @@ -XXX,XX +XXX,XX @@ | ||
57 | #define AVS_OFFSET 0x103000 /* Audio Video Standard */ | ||
58 | #define RNG_OFFSET 0x104000 | ||
59 | #define GPIO_OFFSET 0x200000 | ||
60 | -#define UART0_OFFSET 0x201000 | ||
61 | -#define MMCI0_OFFSET 0x202000 | ||
62 | -#define I2S_OFFSET 0x203000 | ||
63 | -#define SPI0_OFFSET 0x204000 | ||
64 | +#define UART0_OFFSET 0x201000 /* PL011 */ | ||
65 | +#define MMCI0_OFFSET 0x202000 /* Legacy MMC */ | ||
66 | +#define I2S_OFFSET 0x203000 /* PCM */ | ||
67 | +#define SPI0_OFFSET 0x204000 /* SPI master */ | ||
68 | #define BSC0_OFFSET 0x205000 /* BSC0 I2C/TWI */ | ||
69 | +#define PIXV0_OFFSET 0x206000 | ||
70 | +#define PIXV1_OFFSET 0x207000 | ||
71 | +#define DPI_OFFSET 0x208000 | ||
72 | +#define DSI0_OFFSET 0x209000 /* Display Serial Interface */ | ||
73 | +#define PWM_OFFSET 0x20c000 | ||
74 | +#define PERM_OFFSET 0x20d000 | ||
75 | +#define TEC_OFFSET 0x20e000 | ||
76 | #define OTP_OFFSET 0x20f000 | ||
77 | +#define SLIM_OFFSET 0x210000 /* SLIMbus */ | ||
78 | +#define CPG_OFFSET 0x211000 | ||
79 | #define THERMAL_OFFSET 0x212000 | ||
80 | -#define BSC_SL_OFFSET 0x214000 /* SPI slave */ | ||
81 | +#define AVSP_OFFSET 0x213000 | ||
82 | +#define BSC_SL_OFFSET 0x214000 /* SPI slave (bootrom) */ | ||
83 | #define AUX_OFFSET 0x215000 /* AUX: UART1/SPI1/SPI2 */ | ||
84 | #define EMMC1_OFFSET 0x300000 | ||
85 | +#define EMMC2_OFFSET 0x340000 | ||
86 | +#define HVS_OFFSET 0x400000 | ||
87 | #define SMI_OFFSET 0x600000 | ||
88 | +#define DSI1_OFFSET 0x700000 | ||
89 | +#define UCAM_OFFSET 0x800000 | ||
90 | +#define CMI_OFFSET 0x802000 | ||
91 | #define BSC1_OFFSET 0x804000 /* BSC1 I2C/TWI */ | ||
92 | #define BSC2_OFFSET 0x805000 /* BSC2 I2C/TWI */ | ||
93 | +#define VECA_OFFSET 0x806000 | ||
94 | +#define PIXV2_OFFSET 0x807000 | ||
95 | +#define HDMI_OFFSET 0x808000 | ||
96 | +#define HDCP_OFFSET 0x809000 | ||
97 | +#define ARBR0_OFFSET 0x80a000 | ||
98 | #define DBUS_OFFSET 0x900000 | ||
99 | #define AVE0_OFFSET 0x910000 | ||
100 | #define USB_OTG_OFFSET 0x980000 /* DTC_OTG USB controller */ | ||
101 | +#define V3D_OFFSET 0xc00000 | ||
102 | #define SDRAMC_OFFSET 0xe00000 | ||
103 | +#define L2CC_OFFSET 0xe01000 /* Level 2 Cache controller */ | ||
104 | +#define L1CC_OFFSET 0xe02000 /* Level 1 Cache controller */ | ||
105 | +#define ARBR1_OFFSET 0xe04000 | ||
106 | #define DMA15_OFFSET 0xE05000 /* DMA controller, channel 15 */ | ||
107 | +#define DCRC_OFFSET 0xe07000 | ||
108 | +#define AXIP_OFFSET 0xe08000 | ||
109 | |||
110 | /* GPU interrupts */ | ||
111 | #define INTERRUPT_TIMER0 0 | ||
112 | -- | ||
113 | 2.20.1 | ||
114 | |||
115 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The bcm2835-v3d is used since Linux 4.7, see commit | ||
4 | 49ac67e0c39c ("ARM: bcm2835: Add VC4 to the device tree"), | ||
5 | and the bcm2835-txp since Linux 4.19, see commit | ||
6 | b7dd29b401f5 ("ARM: dts: bcm283x: Add Transposer block"). | ||
7 | |||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200921034729.432931-3-f4bug@amsat.org | 5 | Message-id: 20210726150953.1218690-1-f4bug@amsat.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | include/hw/arm/bcm2835_peripherals.h | 2 ++ | 8 | hw/arm/nseries.c | 2 +- |
14 | hw/arm/bcm2835_peripherals.c | 2 ++ | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 2 files changed, 4 insertions(+) | ||
16 | 10 | ||
17 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 11 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
18 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/bcm2835_peripherals.h | 13 | --- a/hw/arm/nseries.c |
20 | +++ b/include/hw/arm/bcm2835_peripherals.h | 14 | +++ b/hw/arm/nseries.c |
21 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { | 15 | @@ -XXX,XX +XXX,XX @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len) |
22 | 16 | default: | |
23 | BCM2835SystemTimerState systmr; | 17 | bad_cmd: |
24 | BCM2835MphiState mphi; | 18 | qemu_log_mask(LOG_GUEST_ERROR, |
25 | + UnimplementedDeviceState txp; | 19 | - "%s: unknown command %02x\n", __func__, s->cmd); |
26 | UnimplementedDeviceState armtmr; | 20 | + "%s: unknown command 0x%02x\n", __func__, s->cmd); |
27 | UnimplementedDeviceState cprman; | 21 | break; |
28 | UnimplementedDeviceState a2w; | 22 | } |
29 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { | ||
30 | UnimplementedDeviceState otp; | ||
31 | UnimplementedDeviceState dbus; | ||
32 | UnimplementedDeviceState ave0; | ||
33 | + UnimplementedDeviceState v3d; | ||
34 | UnimplementedDeviceState bscsl; | ||
35 | UnimplementedDeviceState smi; | ||
36 | DWC2State dwc2; | ||
37 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/arm/bcm2835_peripherals.c | ||
40 | +++ b/hw/arm/bcm2835_peripherals.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
42 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
43 | INTERRUPT_USB)); | ||
44 | |||
45 | + create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000); | ||
46 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
47 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | ||
48 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | ||
49 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
50 | create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80); | ||
51 | create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000); | ||
52 | create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000); | ||
53 | + create_unimp(s, &s->v3d, "bcm2835-v3d", V3D_OFFSET, 0x1000); | ||
54 | create_unimp(s, &s->sdramc, "bcm2835-sdramc", SDRAMC_OFFSET, 0x100); | ||
55 | } | ||
56 | 23 | ||
57 | -- | 24 | -- |
58 | 2.20.1 | 25 | 2.20.1 |
59 | 26 | ||
60 | 27 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Commit 1c3db49d39 added the raspi3, which uses the same peripherals | ||
4 | than the raspi2 (but with different ARM cores). The raspi3 was | ||
5 | introduced without the ignore_memory_transaction_failures flag. | ||
6 | Almost 2 years later, the machine is usable running U-Boot and | ||
7 | Linux. | ||
8 | In commit 00cbd5bd74 we mapped a lot of unimplemented devices, | ||
9 | commit d442d95f added thermal block and commit 0e5bbd7406 the | ||
10 | system timer. | ||
11 | As we are happy with the raspi3, let's remove this flag on the | ||
12 | raspi2. | ||
13 | |||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
16 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Message-id: 20200921034729.432931-4-f4bug@amsat.org | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | hw/arm/raspi.c | 3 --- | ||
21 | 1 file changed, 3 deletions(-) | ||
22 | |||
23 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/hw/arm/raspi.c | ||
26 | +++ b/hw/arm/raspi.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data) | ||
28 | mc->default_cpus = mc->min_cpus = mc->max_cpus = cores_count(board_rev); | ||
29 | mc->default_ram_size = board_ram_size(board_rev); | ||
30 | mc->default_ram_id = "ram"; | ||
31 | - if (board_version(board_rev) == 2) { | ||
32 | - mc->ignore_memory_transaction_failures = true; | ||
33 | - } | ||
34 | }; | ||
35 | |||
36 | static const TypeInfo raspi_machine_types[] = { | ||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Display the board revision in the machine description. | ||
4 | |||
5 | Before: | ||
6 | |||
7 | $ qemu-system-aarch64 -M help | fgrep raspi | ||
8 | raspi2 Raspberry Pi 2B | ||
9 | raspi3 Raspberry Pi 3B | ||
10 | |||
11 | After: | ||
12 | |||
13 | raspi2 Raspberry Pi 2B (revision 1.1) | ||
14 | raspi3 Raspberry Pi 3B (revision 1.2) | ||
15 | |||
16 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
17 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Message-id: 20200924111808.77168-2-f4bug@amsat.org | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | hw/arm/raspi.c | 4 +++- | ||
22 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
23 | |||
24 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/arm/raspi.c | ||
27 | +++ b/hw/arm/raspi.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data) | ||
29 | uint32_t board_rev = (uint32_t)(uintptr_t)data; | ||
30 | |||
31 | rmc->board_rev = board_rev; | ||
32 | - mc->desc = g_strdup_printf("Raspberry Pi %s", board_type(board_rev)); | ||
33 | + mc->desc = g_strdup_printf("Raspberry Pi %s (revision 1.%u)", | ||
34 | + board_type(board_rev), | ||
35 | + FIELD_EX32(board_rev, REV_CODE, REVISION)); | ||
36 | mc->init = raspi_machine_init; | ||
37 | mc->block_default_type = IF_SD; | ||
38 | mc->no_parallel = 1; | ||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | The 'first_cpu' is more a QEMU accelerator-related concept | 3 | The macro used to calculate the maximum memory size of the MMIO region |
4 | than a variable the machine requires to use. | 4 | had a mistake, causing all GPIO models to create a mapping of 0x9D8. |
5 | Since the machine is aware of its CPUs, directly use the | 5 | The intent was to have it be 0x9D8 - 0x800. |
6 | first one to load the firmware. | ||
7 | 6 | ||
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 7 | This extra size doesn't matter on ast2400 and ast2500, which have a 4KB |
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | region set aside for the GPIO controller. |
10 | Message-id: 20200924111808.77168-3-f4bug@amsat.org | 9 | |
10 | On the ast2600 the 3.3V and 1.8V GPIO controllers are 2KB apart, so the | ||
11 | regions would overlap. Worse was the 1.8V controller would map over the | ||
12 | top of the following peripheral, which happens to be the RTC. | ||
13 | |||
14 | The mmio region used by each device is a maximum of 2KB, so avoid the | ||
15 | calculations and hard code this as the maximum. | ||
16 | |||
17 | Fixes: 36d737ee82b2 ("hw/gpio: Add in AST2600 specific implementation") | ||
18 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
19 | Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
21 | Message-id: 20210713065854.134634-2-joel@jms.id.au | ||
22 | [PMM: fix autocorrect error in commit message] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 24 | --- |
13 | hw/arm/raspi.c | 3 ++- | 25 | hw/gpio/aspeed_gpio.c | 3 +-- |
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | 26 | 1 file changed, 1 insertion(+), 2 deletions(-) |
15 | 27 | ||
16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 28 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c |
17 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/raspi.c | 30 | --- a/hw/gpio/aspeed_gpio.c |
19 | +++ b/hw/arm/raspi.c | 31 | +++ b/hw/gpio/aspeed_gpio.c |
20 | @@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) | 32 | @@ -XXX,XX +XXX,XX @@ |
21 | 33 | #define GPIO_1_8V_MEM_SIZE 0x9D8 | |
22 | static void setup_boot(MachineState *machine, int version, size_t ram_size) | 34 | #define GPIO_1_8V_REG_ARRAY_SIZE ((GPIO_1_8V_MEM_SIZE - \ |
35 | GPIO_1_8V_REG_OFFSET) >> 2) | ||
36 | -#define GPIO_MAX_MEM_SIZE MAX(GPIO_3_6V_MEM_SIZE, GPIO_1_8V_MEM_SIZE) | ||
37 | |||
38 | static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) | ||
23 | { | 39 | { |
24 | + RaspiMachineState *s = RASPI_MACHINE(machine); | 40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_realize(DeviceState *dev, Error **errp) |
25 | static struct arm_boot_info binfo; | ||
26 | int r; | ||
27 | |||
28 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
29 | binfo.firmware_loaded = true; | ||
30 | } | 41 | } |
31 | 42 | ||
32 | - arm_load_kernel(ARM_CPU(first_cpu), machine, &binfo); | 43 | memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s, |
33 | + arm_load_kernel(&s->soc.cpu[0].core, machine, &binfo); | 44 | - TYPE_ASPEED_GPIO, GPIO_MAX_MEM_SIZE); |
45 | + TYPE_ASPEED_GPIO, 0x800); | ||
46 | |||
47 | sysbus_init_mmio(sbd, &s->iomem); | ||
34 | } | 48 | } |
35 | |||
36 | static void raspi_machine_init(MachineState *machine) | ||
37 | -- | 49 | -- |
38 | 2.20.1 | 50 | 2.20.1 |
39 | 51 | ||
40 | 52 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Using class_data pointer to create a MachineClass is not | ||
4 | the recommended way anymore. The correct way is to open-code | ||
5 | the MachineClass::fields in the class_init() method. | ||
6 | |||
7 | We can not use TYPE_RASPI_MACHINE::class_base_init() because | ||
8 | it is called *before* each machine class_init(), therefore the | ||
9 | board_rev field is not populated. We have to manually call | ||
10 | raspi_machine_class_common_init() for each machine. | ||
11 | |||
12 | This partly reverts commit a03bde3674e. | ||
13 | |||
14 | Suggested-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
17 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Message-id: 20200924111808.77168-5-f4bug@amsat.org | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | hw/arm/raspi.c | 34 ++++++++++++++++++++++++---------- | ||
22 | 1 file changed, 24 insertions(+), 10 deletions(-) | ||
23 | |||
24 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/arm/raspi.c | ||
27 | +++ b/hw/arm/raspi.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) | ||
29 | setup_boot(machine, version, machine->ram_size - vcram_size); | ||
30 | } | ||
31 | |||
32 | -static void raspi_machine_class_init(ObjectClass *oc, void *data) | ||
33 | +static void raspi_machine_class_common_init(MachineClass *mc, | ||
34 | + uint32_t board_rev) | ||
35 | { | ||
36 | - MachineClass *mc = MACHINE_CLASS(oc); | ||
37 | - RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
38 | - uint32_t board_rev = (uint32_t)(uintptr_t)data; | ||
39 | - | ||
40 | - rmc->board_rev = board_rev; | ||
41 | mc->desc = g_strdup_printf("Raspberry Pi %s (revision 1.%u)", | ||
42 | board_type(board_rev), | ||
43 | FIELD_EX32(board_rev, REV_CODE, REVISION)); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data) | ||
45 | mc->default_ram_id = "ram"; | ||
46 | }; | ||
47 | |||
48 | +static void raspi2b_machine_class_init(ObjectClass *oc, void *data) | ||
49 | +{ | ||
50 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
51 | + RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
52 | + | ||
53 | + rmc->board_rev = 0xa21041; | ||
54 | + raspi_machine_class_common_init(mc, rmc->board_rev); | ||
55 | +}; | ||
56 | + | ||
57 | +#ifdef TARGET_AARCH64 | ||
58 | +static void raspi3b_machine_class_init(ObjectClass *oc, void *data) | ||
59 | +{ | ||
60 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
61 | + RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
62 | + | ||
63 | + rmc->board_rev = 0xa02082; | ||
64 | + raspi_machine_class_common_init(mc, rmc->board_rev); | ||
65 | +}; | ||
66 | +#endif /* TARGET_AARCH64 */ | ||
67 | + | ||
68 | static const TypeInfo raspi_machine_types[] = { | ||
69 | { | ||
70 | .name = MACHINE_TYPE_NAME("raspi2"), | ||
71 | .parent = TYPE_RASPI_MACHINE, | ||
72 | - .class_init = raspi_machine_class_init, | ||
73 | - .class_data = (void *)0xa21041, | ||
74 | + .class_init = raspi2b_machine_class_init, | ||
75 | #ifdef TARGET_AARCH64 | ||
76 | }, { | ||
77 | .name = MACHINE_TYPE_NAME("raspi3"), | ||
78 | .parent = TYPE_RASPI_MACHINE, | ||
79 | - .class_init = raspi_machine_class_init, | ||
80 | - .class_data = (void *)0xa02082, | ||
81 | + .class_init = raspi3b_machine_class_init, | ||
82 | #endif | ||
83 | }, { | ||
84 | .name = TYPE_RASPI_MACHINE, | ||
85 | -- | ||
86 | 2.20.1 | ||
87 | |||
88 | diff view generated by jsdifflib |