1 | A mixed bag, all bug fixes or similar small stuff. | 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 | ||
3 | thanks | 4 | thanks |
4 | -- PMM | 5 | -- PMM |
5 | 6 | ||
7 | The following changes since commit c08ccd1b53f488ac86c1f65cf7623dc91acc249a: | ||
6 | 8 | ||
7 | The following changes since commit 19eb2d4e736dc895f31fbd6b520e514f10cc08e0: | 9 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210726' into staging (2021-07-27 08:35:01 +0100) |
8 | |||
9 | Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2019-05-07 10:43:32 +0100) | ||
10 | 10 | ||
11 | are available in the Git repository at: | 11 | are available in the Git repository at: |
12 | 12 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190507 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210727 |
14 | 14 | ||
15 | for you to fetch changes up to 63159601fb3e396b28da14cbb71e50ed3f5a0331: | 15 | for you to fetch changes up to e229a179a503f2aee43a76888cf12fbdfe8a3749: |
16 | 16 | ||
17 | target/arm: Stop using variable length array in dc_zva (2019-05-07 12:55:04 +0100) | 17 | hw: aspeed_gpio: Fix memory size (2021-07-27 11:00:00 +0100) |
18 | 18 | ||
19 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
20 | target-arm queue: | 20 | target-arm queue: |
21 | * Stop using variable length array in dc_zva | 21 | * hw/arm/smmuv3: Check 31st bit to see if CD is valid |
22 | * Implement M-profile XPSR GE bits | 22 | * qemu-options.hx: Fix formatting of -machine memory-backend option |
23 | * Don't enable ARMV7M_EXCP_DEBUG from reset | 23 | * hw: aspeed_gpio: Fix memory size |
24 | * armv7m_nvic: NS BFAR and BFSR are RAZ/WI if BFHFNMINS == 0 | 24 | * hw/arm/nseries: Display hexadecimal value with '0x' prefix |
25 | * armv7m_nvic: Check subpriority in nvic_recompute_state_secure() | 25 | * Add sve-default-vector-length cpu property |
26 | * fix various minor issues to allow building for Windows-on-ARM64 | 26 | * docs: Update path that mentions deprecated.rst |
27 | * aspeed: Set SDRAM size | 27 | * hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS |
28 | * Allow system registers for KVM guests to be changed by QEMU code | 28 | * hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING |
29 | * raspi: Diagnose requests for too much RAM | 29 | * hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts |
30 | * virt: Support firmware configuration with -blockdev | 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 | ||
31 | 33 | ||
32 | ---------------------------------------------------------------- | 34 | ---------------------------------------------------------------- |
33 | Cao Jiaxi (4): | 35 | Joe Komlodi (1): |
34 | QEMU_PACKED: Remove gcc_struct attribute in Windows non x86 targets | 36 | hw/arm/smmuv3: Check 31st bit to see if CD is valid |
35 | qga: Fix mingw compilation warnings on enum conversion | ||
36 | util/cacheinfo: Use uint64_t on LLP64 model to satisfy Windows ARM64 | ||
37 | osdep: Fix mingw compilation regarding stdio formats | ||
38 | 37 | ||
39 | Joel Stanley (1): | 38 | Joel Stanley (1): |
40 | arm: aspeed: Set SDRAM size | 39 | hw: aspeed_gpio: Fix memory size |
41 | 40 | ||
42 | Markus Armbruster (3): | 41 | Mao Zhongyi (1): |
43 | pc: Rearrange pc_system_firmware_init()'s legacy -drive loop | 42 | docs: Update path that mentions deprecated.rst |
44 | pflash_cfi01: New pflash_cfi01_legacy_drive() | ||
45 | hw/arm/virt: Support firmware configuration with -blockdev | ||
46 | 43 | ||
47 | Peter Maydell (7): | 44 | Peter Maydell (7): |
48 | hw/arm/raspi: Diagnose requests for too much RAM | 45 | qemu-options.hx: Fix formatting of -machine memory-backend option |
49 | arm: Allow system registers for KVM guests to be changed by QEMU code | 46 | target/arm: Enforce that M-profile SP low 2 bits are always zero |
50 | hw/arm/armv7m_nvic: Check subpriority in nvic_recompute_state_secure() | 47 | target/arm: Add missing 'return's after calling v7m_exception_taken() |
51 | hw/intc/armv7m_nvic: NS BFAR and BFSR are RAZ/WI if BFHFNMINS == 0 | 48 | target/arm: Report M-profile alignment faults correctly to the guest |
52 | hw/intc/armv7m_nvic: Don't enable ARMV7M_EXCP_DEBUG from reset | 49 | hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts |
53 | target/arm: Implement XPSR GE bits | 50 | hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING |
54 | target/arm: Stop using variable length array in dc_zva | 51 | hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS |
55 | 52 | ||
56 | contrib/libvhost-user/libvhost-user.h | 2 +- | 53 | Philippe Mathieu-Daudé (1): |
57 | include/hw/arm/aspeed.h | 1 + | 54 | hw/arm/nseries: Display hexadecimal value with '0x' prefix |
58 | include/hw/arm/virt.h | 2 + | ||
59 | include/hw/block/flash.h | 1 + | ||
60 | include/qemu/compiler.h | 2 +- | ||
61 | include/qemu/osdep.h | 10 +- | ||
62 | scripts/cocci-macro-file.h | 7 +- | ||
63 | target/arm/cpu.h | 13 ++- | ||
64 | hw/arm/aspeed.c | 8 ++ | ||
65 | hw/arm/raspi.c | 7 ++ | ||
66 | hw/arm/virt.c | 202 ++++++++++++++++++++++------------ | ||
67 | hw/block/pflash_cfi01.c | 28 +++++ | ||
68 | hw/i386/pc_sysfw.c | 18 +-- | ||
69 | hw/intc/armv7m_nvic.c | 40 ++++++- | ||
70 | qga/commands-win32.c | 2 +- | ||
71 | target/arm/helper.c | 47 +++++++- | ||
72 | target/arm/kvm.c | 8 ++ | ||
73 | target/arm/kvm32.c | 20 +--- | ||
74 | target/arm/kvm64.c | 2 + | ||
75 | target/arm/machine.c | 2 +- | ||
76 | util/cacheinfo.c | 2 +- | ||
77 | 21 files changed, 294 insertions(+), 130 deletions(-) | ||
78 | 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: Cao Jiaxi <driver1998@foxmail.com> | 1 | From: Joe Komlodi <joe.komlodi@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Windows ARM64 uses LLP64 model, which breaks current assumptions. | 3 | The bit to see if a CD is valid is the last bit of the first word of the CD. |
4 | 4 | ||
5 | Signed-off-by: Cao Jiaxi <driver1998@foxmail.com> | 5 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Message-id: 1626728232-134665-2-git-send-email-joe.komlodi@xilinx.com |
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20190503003707.10185-1-driver1998@foxmail.com | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 9 | --- |
13 | util/cacheinfo.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/util/cacheinfo.c b/util/cacheinfo.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/util/cacheinfo.c | 15 | --- a/hw/arm/smmuv3-internal.h |
19 | +++ b/util/cacheinfo.c | 16 | +++ b/hw/arm/smmuv3-internal.h |
20 | @@ -XXX,XX +XXX,XX @@ static void sys_cache_info(int *isize, int *dsize) | 17 | @@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste) |
21 | static void arch_cache_info(int *isize, int *dsize) | 18 | |
22 | { | 19 | /* CD fields */ |
23 | if (*isize == 0 || *dsize == 0) { | 20 | |
24 | - unsigned long ctr; | 21 | -#define CD_VALID(x) extract32((x)->word[0], 30, 1) |
25 | + uint64_t ctr; | 22 | +#define CD_VALID(x) extract32((x)->word[0], 31, 1) |
26 | 23 | #define CD_ASID(x) extract32((x)->word[1], 16, 16) | |
27 | /* The real cache geometry is in CCSIDR_EL1/CLIDR_EL1/CSSELR_EL1, | 24 | #define CD_TTB(x, sel) \ |
28 | but (at least under Linux) these are marked protected by the | 25 | ({ \ |
29 | -- | 26 | -- |
30 | 2.20.1 | 27 | 2.20.1 |
31 | 28 | ||
32 | 29 | diff view generated by jsdifflib |
1 | From: Cao Jiaxi <driver1998@foxmail.com> | 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 | I encountered the following compilation error on mingw: | 11 | Fix the formatting. |
4 | 12 | ||
5 | /mnt/d/qemu/include/qemu/osdep.h:97:9: error: '__USE_MINGW_ANSI_STDIO' macro redefined [-Werror,-Wmacro-redefined] | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | #define __USE_MINGW_ANSI_STDIO 1 | 14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> |
7 | ^ | 15 | Message-id: 20210719105257.3599-1-peter.maydell@linaro.org |
8 | /mnt/d/llvm-mingw/aarch64-w64-mingw32/include/_mingw.h:433:9: note: previous definition is here | 16 | --- |
9 | #define __USE_MINGW_ANSI_STDIO 0 /* was not defined so it should be 0 */ | 17 | qemu-options.hx | 30 +++++++++++++++++------------- |
18 | 1 file changed, 17 insertions(+), 13 deletions(-) | ||
10 | 19 | ||
11 | It turns out that __USE_MINGW_ANSI_STDIO must be set before any | 20 | diff --git a/qemu-options.hx b/qemu-options.hx |
12 | system headers are included, not just before stdio.h. | ||
13 | |||
14 | Signed-off-by: Cao Jiaxi <driver1998@foxmail.com> | ||
15 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
16 | Reviewed-by: Stefan Weil <sw@weilnetz.de> | ||
17 | Message-id: 20190503003719.10233-1-driver1998@foxmail.com | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | include/qemu/osdep.h | 10 +++++----- | ||
22 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
23 | |||
24 | diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/qemu/osdep.h | 22 | --- a/qemu-options.hx |
27 | +++ b/include/qemu/osdep.h | 23 | +++ b/qemu-options.hx |
28 | @@ -XXX,XX +XXX,XX @@ extern int daemon(int, int); | 24 | @@ -XXX,XX +XXX,XX @@ SRST |
29 | #endif | 25 | Enables or disables ACPI Heterogeneous Memory Attribute Table |
30 | #endif | 26 | (HMAT) support. The default is off. |
31 | 27 | ||
32 | +/* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */ | 28 | - ``memory-backend='id'`` |
33 | +#ifdef __MINGW32__ | 29 | + ``memory-backend='id'`` |
34 | +#define __USE_MINGW_ANSI_STDIO 1 | 30 | An alternative to legacy ``-mem-path`` and ``mem-prealloc`` options. |
35 | +#endif | 31 | Allows to use a memory backend as main RAM. |
32 | |||
33 | For example: | ||
34 | :: | ||
35 | - -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on | ||
36 | - -machine memory-backend=pc.ram | ||
37 | - -m 512M | ||
36 | + | 38 | + |
37 | #include <stdarg.h> | 39 | + -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on |
38 | #include <stddef.h> | 40 | + -machine memory-backend=pc.ram |
39 | #include <stdbool.h> | 41 | + -m 512M |
40 | #include <stdint.h> | 42 | |
41 | #include <sys/types.h> | 43 | Migration compatibility note: |
42 | #include <stdlib.h> | 44 | - a) as backend id one shall use value of 'default-ram-id', advertised by |
43 | - | 45 | - machine type (available via ``query-machines`` QMP command), if migration |
44 | -/* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */ | 46 | - to/from old QEMU (<5.0) is expected. |
45 | -#ifdef __MINGW32__ | 47 | - b) for machine types 4.0 and older, user shall |
46 | -#define __USE_MINGW_ANSI_STDIO 1 | 48 | - use ``x-use-canonical-path-for-ramblock-id=off`` backend option |
47 | -#endif | 49 | - if migration to/from old QEMU (<5.0) is expected. |
48 | #include <stdio.h> | 50 | + |
49 | 51 | + * as backend id one shall use value of 'default-ram-id', advertised by | |
50 | #include <string.h> | 52 | + machine type (available via ``query-machines`` QMP command), if migration |
53 | + to/from old QEMU (<5.0) is expected. | ||
54 | + * for machine types 4.0 and older, user shall | ||
55 | + use ``x-use-canonical-path-for-ramblock-id=off`` backend option | ||
56 | + if migration to/from old QEMU (<5.0) is expected. | ||
57 | + | ||
58 | For example: | ||
59 | :: | ||
60 | - -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off | ||
61 | - -machine memory-backend=pc.ram | ||
62 | - -m 512M | ||
63 | + | ||
64 | + -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off | ||
65 | + -machine memory-backend=pc.ram | ||
66 | + -m 512M | ||
67 | ERST | ||
68 | |||
69 | HXCOMM Deprecated by -machine | ||
51 | -- | 70 | -- |
52 | 2.20.1 | 71 | 2.20.1 |
53 | 72 | ||
54 | 73 | diff view generated by jsdifflib |
1 | From: Cao Jiaxi <driver1998@foxmail.com> | 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 win2qemu[] is supposed to be the conversion table to convert between | 5 | Implement this behaviour by masking out the low bits: |
4 | STORAGE_BUS_TYPE in Windows SDK and GuestDiskBusType in qga. | 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 | But it was incorrectly written that it forces to set a GuestDiskBusType | 10 | Note that all the direct uses of cpu_R[] in translate.c are in places |
7 | value to STORAGE_BUS_TYPE, which generates an enum conversion warning in clang. | 11 | where the register is definitely not r13 (usually because that has |
12 | been checked for as an UNDEFINED or UNPREDICTABLE case and handled as | ||
13 | UNDEF). | ||
8 | 14 | ||
9 | Suggested-by: Eric Blake <eblake@redhat.com> | 15 | All the other writes to regs[13] in C code are either: |
10 | Signed-off-by: Cao Jiaxi <driver1998@foxmail.com> | 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 | |||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 24 | Message-id: 20210723162146.5167-2-peter.maydell@linaro.org |
13 | Message-id: 20190503003650.10137-1-driver1998@foxmail.com | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | 25 | --- |
18 | qga/commands-win32.c | 2 +- | 26 | target/arm/gdbstub.c | 4 ++++ |
19 | 1 file changed, 1 insertion(+), 1 deletion(-) | 27 | target/arm/m_helper.c | 14 ++++++++------ |
28 | target/arm/translate.c | 3 +++ | ||
29 | 3 files changed, 15 insertions(+), 6 deletions(-) | ||
20 | 30 | ||
21 | diff --git a/qga/commands-win32.c b/qga/commands-win32.c | 31 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
22 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/qga/commands-win32.c | 33 | --- a/target/arm/gdbstub.c |
24 | +++ b/qga/commands-win32.c | 34 | +++ b/target/arm/gdbstub.c |
25 | @@ -XXX,XX +XXX,XX @@ void qmp_guest_file_flush(int64_t handle, Error **errp) | 35 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) |
26 | 36 | ||
27 | #ifdef CONFIG_QGA_NTDDSCSI | 37 | if (n < 16) { |
28 | 38 | /* Core integer register. */ | |
29 | -static STORAGE_BUS_TYPE win2qemu[] = { | 39 | + if (n == 13 && arm_feature(env, ARM_FEATURE_M)) { |
30 | +static GuestDiskBusType win2qemu[] = { | 40 | + /* M profile SP low bits are always 0 */ |
31 | [BusTypeUnknown] = GUEST_DISK_BUS_TYPE_UNKNOWN, | 41 | + tmp &= ~3; |
32 | [BusTypeScsi] = GUEST_DISK_BUS_TYPE_SCSI, | 42 | + } |
33 | [BusTypeAtapi] = GUEST_DISK_BUS_TYPE_IDE, | 43 | env->regs[n] = tmp; |
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); | ||
34 | -- | 110 | -- |
35 | 2.20.1 | 111 | 2.20.1 |
36 | 112 | ||
37 | 113 | diff view generated by jsdifflib |
1 | From: Cao Jiaxi <driver1998@foxmail.com> | 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 | gcc_struct is for x86 only, and it generates an warning on ARM64 Clang/MinGW targets. | 9 | In a couple of checks that are new in v8.1M, we forgot the "return" |
10 | statement, with the effect that if bad code in the guest tripped over | ||
11 | these checks we would set up to take a UsageFault exception but then | ||
12 | blunder on trying to also unstack and return from the original | ||
13 | exception, with the probable result that the guest would crash. | ||
4 | 14 | ||
5 | Signed-off-by: Cao Jiaxi <driver1998@foxmail.com> | 15 | Add the missing return statements. |
6 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 16 | |
7 | Message-id: 20190503003618.10089-1-driver1998@foxmail.com | ||
8 | [PMM: dropped the slirp change as slirp is now a submodule] | ||
9 | 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 | ||
10 | --- | 20 | --- |
11 | contrib/libvhost-user/libvhost-user.h | 2 +- | 21 | target/arm/m_helper.c | 2 ++ |
12 | include/qemu/compiler.h | 2 +- | 22 | 1 file changed, 2 insertions(+) |
13 | scripts/cocci-macro-file.h | 7 ++++++- | ||
14 | 3 files changed, 8 insertions(+), 3 deletions(-) | ||
15 | 23 | ||
16 | diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/libvhost-user.h | 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/contrib/libvhost-user/libvhost-user.h | 26 | --- a/target/arm/m_helper.c |
19 | +++ b/contrib/libvhost-user/libvhost-user.h | 27 | +++ b/target/arm/m_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct VhostUserInflight { | 28 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
21 | uint16_t queue_size; | 29 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
22 | } VhostUserInflight; | 30 | "stackframe: NSACR prevents clearing FPU registers\n"); |
23 | 31 | v7m_exception_taken(cpu, excret, true, false); | |
24 | -#if defined(_WIN32) | 32 | + return; |
25 | +#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) | 33 | } else if (!cpacr_pass) { |
26 | # define VU_PACKED __attribute__((gcc_struct, packed)) | 34 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, |
27 | #else | 35 | exc_secure); |
28 | # define VU_PACKED __attribute__((packed)) | 36 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
29 | diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h | 37 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
30 | index XXXXXXX..XXXXXXX 100644 | 38 | "stackframe: CPACR prevents clearing FPU registers\n"); |
31 | --- a/include/qemu/compiler.h | 39 | v7m_exception_taken(cpu, excret, true, false); |
32 | +++ b/include/qemu/compiler.h | 40 | + return; |
33 | @@ -XXX,XX +XXX,XX @@ | 41 | } |
34 | 42 | } | |
35 | #define QEMU_SENTINEL __attribute__((sentinel)) | 43 | /* Clear s0..s15, FPSCR and VPR */ |
36 | |||
37 | -#if defined(_WIN32) | ||
38 | +#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) | ||
39 | # define QEMU_PACKED __attribute__((gcc_struct, packed)) | ||
40 | #else | ||
41 | # define QEMU_PACKED __attribute__((packed)) | ||
42 | diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/scripts/cocci-macro-file.h | ||
45 | +++ b/scripts/cocci-macro-file.h | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | #define QEMU_NORETURN __attribute__ ((__noreturn__)) | ||
48 | #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | ||
49 | #define QEMU_SENTINEL __attribute__((sentinel)) | ||
50 | -#define QEMU_PACKED __attribute__((gcc_struct, packed)) | ||
51 | + | ||
52 | +#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) | ||
53 | +# define QEMU_PACKED __attribute__((gcc_struct, packed)) | ||
54 | +#else | ||
55 | +# define QEMU_PACKED __attribute__((packed)) | ||
56 | +#endif | ||
57 | |||
58 | #define cat(x,y) x ## y | ||
59 | #define cat2(x,y) cat(x,y) | ||
60 | -- | 44 | -- |
61 | 2.20.1 | 45 | 2.20.1 |
62 | 46 | ||
63 | 47 | diff view generated by jsdifflib |
1 | In the M-profile architecture, if the CPU implements the DSP extension | 1 | For M-profile, we weren't reporting alignment faults triggered by the |
---|---|---|---|
2 | then the XPSR has GE bits, in the same way as the A-profile CPSR. When | 2 | generic TCG code correctly to the guest. These get passed into |
3 | we added DSP extension support we forgot to add support for reading | 3 | arm_v7m_cpu_do_interrupt() as an EXCP_DATA_ABORT with an A-profile |
4 | and writing the GE bits, which are stored in env->GE. We did put in | 4 | style exception.fsr value of 1. We didn't check for this, and so |
5 | the code to add XPSR_GE to the mask of bits to update in the v7m_msr | 5 | they fell through into the default of "assume this is an MPU fault" |
6 | helper, but forgot it in v7m_mrs. We also must not allow the XPSR we | 6 | and were reported to the guest as a data access violation MPU fault. |
7 | pull off the stack on exception return to set the nonexistent GE bits. | 7 | |
8 | Correct these errors: | 8 | Report these alignment faults as UsageFaults which set the UNALIGNED |
9 | * read and write env->GE in xpsr_read() and xpsr_write() | 9 | bit in the UFSR. |
10 | * only set GE bits on exception return if DSP present | ||
11 | * read GE bits for MRS if DSP present | ||
12 | 10 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20190430131439.25251-5-peter.maydell@linaro.org | 13 | Message-id: 20210723162146.5167-4-peter.maydell@linaro.org |
16 | --- | 14 | --- |
17 | target/arm/cpu.h | 4 ++++ | 15 | target/arm/m_helper.c | 8 ++++++++ |
18 | target/arm/helper.c | 12 ++++++++++-- | 16 | 1 file changed, 8 insertions(+) |
19 | 2 files changed, 14 insertions(+), 2 deletions(-) | ||
20 | 17 | ||
21 | 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 |
22 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.h | 20 | --- a/target/arm/m_helper.c |
24 | +++ b/target/arm/cpu.h | 21 | +++ b/target/arm/m_helper.c |
25 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t xpsr_read(CPUARMState *env) | 22 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
26 | | (env->CF << 29) | ((env->VF & 0x80000000) >> 3) | (env->QF << 27) | 23 | env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; |
27 | | (env->thumb << 24) | ((env->condexec_bits & 3) << 25) | 24 | break; |
28 | | ((env->condexec_bits & 0xfc) << 8) | 25 | case EXCP_UNALIGNED: |
29 | + | (env->GE << 16) | 26 | + /* Unaligned faults reported by M-profile aware code */ |
30 | | env->v7m.exception; | 27 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); |
31 | } | 28 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
32 | 29 | break; | |
33 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 30 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
34 | if (mask & XPSR_Q) { | 31 | } |
35 | env->QF = ((val & XPSR_Q) != 0); | 32 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); |
36 | } | 33 | break; |
37 | + if (mask & XPSR_GE) { | 34 | + case 0x1: /* Alignment fault reported by generic code */ |
38 | + env->GE = (val & XPSR_GE) >> 16; | 35 | + qemu_log_mask(CPU_LOG_INT, |
39 | + } | 36 | + "...really UsageFault with UFSR.UNALIGNED\n"); |
40 | if (mask & XPSR_T) { | 37 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
41 | env->thumb = ((val & XPSR_T) != 0); | 38 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, |
42 | } | 39 | + env->v7m.secure); |
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 40 | + break; |
44 | index XXXXXXX..XXXXXXX 100644 | 41 | default: |
45 | --- a/target/arm/helper.c | 42 | /* |
46 | +++ b/target/arm/helper.c | 43 | * All other FSR values are either MPU faults or "can't happen |
47 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
48 | { | ||
49 | CPUARMState *env = &cpu->env; | ||
50 | uint32_t excret; | ||
51 | - uint32_t xpsr; | ||
52 | + uint32_t xpsr, xpsr_mask; | ||
53 | bool ufault = false; | ||
54 | bool sfault = false; | ||
55 | bool return_to_sp_process; | ||
56 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
57 | } | ||
58 | *frame_sp_p = frameptr; | ||
59 | } | ||
60 | + | ||
61 | + xpsr_mask = ~(XPSR_SPREALIGN | XPSR_SFPA); | ||
62 | + if (!arm_feature(env, ARM_FEATURE_THUMB_DSP)) { | ||
63 | + xpsr_mask &= ~XPSR_GE; | ||
64 | + } | ||
65 | /* This xpsr_write() will invalidate frame_sp_p as it may switch stack */ | ||
66 | - xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA)); | ||
67 | + xpsr_write(env, xpsr, xpsr_mask); | ||
68 | |||
69 | if (env->v7m.secure) { | ||
70 | bool sfpa = xpsr & XPSR_SFPA; | ||
71 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
72 | } | ||
73 | if (!(reg & 4)) { | ||
74 | mask |= XPSR_NZCV | XPSR_Q; /* APSR */ | ||
75 | + if (arm_feature(env, ARM_FEATURE_THUMB_DSP)) { | ||
76 | + mask |= XPSR_GE; | ||
77 | + } | ||
78 | } | ||
79 | /* EPSR reads as zero */ | ||
80 | return xpsr_read(env) & mask; | ||
81 | -- | 44 | -- |
82 | 2.20.1 | 45 | 2.20.1 |
83 | 46 | ||
84 | 47 | diff view generated by jsdifflib |
1 | The M-profile architecture specifies that the DebugMonitor exception | 1 | The ISCR.ISRPENDING bit is set when an external interrupt is pending. |
---|---|---|---|
2 | should be initially disabled, not enabled. It should be controlled | 2 | This is true whether that external interrupt is enabled or not. |
3 | by the DEMCR register's MON_EN bit, but we don't implement that | 3 | This means that we can't use 's->vectpending == 0' as a shortcut to |
4 | register yet (like most of the debug architecture for M-profile). | 4 | "ISRPENDING is zero", because s->vectpending indicates only the |
5 | highest priority pending enabled interrupt. | ||
5 | 6 | ||
6 | Note that BKPT instructions will still work, because they | 7 | Remove the incorrect optimization so that if there is no pending |
7 | will be escalated to HardFault. | 8 | enabled interrupt we fall through to scanning through the whole |
9 | interrupt array. | ||
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: 20190430131439.25251-4-peter.maydell@linaro.org | 13 | Message-id: 20210723162146.5167-5-peter.maydell@linaro.org |
12 | --- | 14 | --- |
13 | hw/intc/armv7m_nvic.c | 4 +++- | 15 | hw/intc/armv7m_nvic.c | 9 ++++----- |
14 | 1 file changed, 3 insertions(+), 1 deletion(-) | 16 | 1 file changed, 4 insertions(+), 5 deletions(-) |
15 | 17 | ||
16 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 18 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/intc/armv7m_nvic.c | 20 | --- a/hw/intc/armv7m_nvic.c |
19 | +++ b/hw/intc/armv7m_nvic.c | 21 | +++ b/hw/intc/armv7m_nvic.c |
20 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev) | 22 | @@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s) |
21 | * the System Handler Control register | 23 | { |
24 | int irq; | ||
25 | |||
26 | - /* We can shortcut if the highest priority pending interrupt | ||
27 | - * happens to be external or if there is nothing pending. | ||
28 | + /* | ||
29 | + * We can shortcut if the highest priority pending interrupt | ||
30 | + * happens to be external; if not we need to check the whole | ||
31 | + * vectors[] array. | ||
22 | */ | 32 | */ |
23 | s->vectors[ARMV7M_EXCP_SVC].enabled = 1; | 33 | if (s->vectpending > NVIC_FIRST_IRQ) { |
24 | - s->vectors[ARMV7M_EXCP_DEBUG].enabled = 1; | 34 | return true; |
25 | s->vectors[ARMV7M_EXCP_PENDSV].enabled = 1; | 35 | } |
26 | s->vectors[ARMV7M_EXCP_SYSTICK].enabled = 1; | 36 | - if (s->vectpending == 0) { |
27 | 37 | - return false; | |
28 | + /* DebugMonitor is enabled via DEMCR.MON_EN */ | 38 | - } |
29 | + s->vectors[ARMV7M_EXCP_DEBUG].enabled = 0; | 39 | |
30 | + | 40 | for (irq = NVIC_FIRST_IRQ; irq < s->num_irq; irq++) { |
31 | resetprio = arm_feature(&s->cpu->env, ARM_FEATURE_V8) ? -4 : -3; | 41 | if (s->vectors[irq].pending) { |
32 | s->vectors[ARMV7M_EXCP_RESET].prio = resetprio; | ||
33 | s->vectors[ARMV7M_EXCP_NMI].prio = -2; | ||
34 | -- | 42 | -- |
35 | 2.20.1 | 43 | 2.20.1 |
36 | 44 | ||
37 | 45 | diff view generated by jsdifflib |
1 | The non-secure versions of the BFAR and BFSR registers are | 1 | The VECTPENDING field in the ICSR is 9 bits wide, in bits [20:12] of |
---|---|---|---|
2 | supposed to be RAZ/WI if AICR.BFHFNMINS == 0; we were | 2 | the register. We were incorrectly masking it to 8 bits, so it would |
3 | incorrectly allowing NS code to access the real values. | 3 | report the wrong value if the pending exception was greater than 256. |
4 | Fix the bug. | ||
4 | 5 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190430131439.25251-3-peter.maydell@linaro.org | 8 | Message-id: 20210723162146.5167-6-peter.maydell@linaro.org |
8 | --- | 9 | --- |
9 | hw/intc/armv7m_nvic.c | 27 ++++++++++++++++++++++++--- | 10 | hw/intc/armv7m_nvic.c | 2 +- |
10 | 1 file changed, 24 insertions(+), 3 deletions(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | 12 | ||
12 | 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 |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/intc/armv7m_nvic.c | 15 | --- a/hw/intc/armv7m_nvic.c |
15 | +++ b/hw/intc/armv7m_nvic.c | 16 | +++ b/hw/intc/armv7m_nvic.c |
16 | @@ -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) |
17 | if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | 18 | /* VECTACTIVE */ |
18 | goto bad_offset; | 19 | val = cpu->env.v7m.exception; |
19 | } | 20 | /* VECTPENDING */ |
20 | + if (!attrs.secure && | 21 | - val |= (s->vectpending & 0xff) << 12; |
21 | + !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | 22 | + val |= (s->vectpending & 0x1ff) << 12; |
22 | + return 0; | 23 | /* ISRPENDING - set if any external IRQ is pending */ |
23 | + } | 24 | if (nvic_isrpending(s)) { |
24 | return cpu->env.v7m.bfar; | 25 | val |= (1 << 22); |
25 | case 0xd3c: /* Aux Fault Status. */ | ||
26 | /* TODO: Implement fault status registers. */ | ||
27 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
28 | if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
29 | goto bad_offset; | ||
30 | } | ||
31 | + if (!attrs.secure && | ||
32 | + !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
33 | + return; | ||
34 | + } | ||
35 | cpu->env.v7m.bfar = value; | ||
36 | return; | ||
37 | case 0xd3c: /* Aux Fault Status. */ | ||
38 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, | ||
39 | val = 0; | ||
40 | break; | ||
41 | }; | ||
42 | - /* The BFSR bits [15:8] are shared between security states | ||
43 | - * and we store them in the NS copy | ||
44 | + /* | ||
45 | + * The BFSR bits [15:8] are shared between security states | ||
46 | + * and we store them in the NS copy. They are RAZ/WI for | ||
47 | + * NS code if AIRCR.BFHFNMINS is 0. | ||
48 | */ | ||
49 | val = s->cpu->env.v7m.cfsr[attrs.secure]; | ||
50 | - val |= s->cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK; | ||
51 | + if (!attrs.secure && | ||
52 | + !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
53 | + val &= ~R_V7M_CFSR_BFSR_MASK; | ||
54 | + } else { | ||
55 | + val |= s->cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK; | ||
56 | + } | ||
57 | val = extract32(val, (offset - 0xd28) * 8, size * 8); | ||
58 | break; | ||
59 | case 0xfe0 ... 0xfff: /* ID. */ | ||
60 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, | ||
61 | */ | ||
62 | value <<= ((offset - 0xd28) * 8); | ||
63 | |||
64 | + if (!attrs.secure && | ||
65 | + !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
66 | + /* BFSR bits are RAZ/WI for NS if BFHFNMINS is set */ | ||
67 | + value &= ~R_V7M_CFSR_BFSR_MASK; | ||
68 | + } | ||
69 | + | ||
70 | s->cpu->env.v7m.cfsr[attrs.secure] &= ~value; | ||
71 | if (attrs.secure) { | ||
72 | /* The BFSR bits [15:8] are shared between security states | ||
73 | -- | 26 | -- |
74 | 2.20.1 | 27 | 2.20.1 |
75 | 28 | ||
76 | 29 | diff view generated by jsdifflib |
1 | Rule R_CQRV says that if two pending interrupts have the same | 1 | In Arm v8.1M the VECTPENDING field in the ICSR has new behaviour: if |
---|---|---|---|
2 | group priority then ties are broken by looking at the subpriority. | 2 | the register is accessed NonSecure and the highest priority pending |
3 | We had a comment describing this but had forgotten to actually | 3 | enabled exception (that would be returned in the VECTPENDING field) |
4 | implement the subpriority comparison. Correct the omission. | 4 | targets Secure, then the VECTPENDING field must read 1 rather than |
5 | 5 | the exception number of the pending exception. Implement this. | |
6 | (The further tie break rules of "lowest exception number" and | ||
7 | "secure before non-secure" are handled implicitly by the order | ||
8 | in which we iterate through the exceptions in the loops.) | ||
9 | 6 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20190430131439.25251-2-peter.maydell@linaro.org | 9 | Message-id: 20210723162146.5167-7-peter.maydell@linaro.org |
13 | --- | 10 | --- |
14 | hw/intc/armv7m_nvic.c | 9 +++++++-- | 11 | hw/intc/armv7m_nvic.c | 31 ++++++++++++++++++++++++------- |
15 | 1 file changed, 7 insertions(+), 2 deletions(-) | 12 | 1 file changed, 24 insertions(+), 7 deletions(-) |
16 | 13 | ||
17 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/armv7m_nvic.c | 16 | --- a/hw/intc/armv7m_nvic.c |
20 | +++ b/hw/intc/armv7m_nvic.c | 17 | +++ b/hw/intc/armv7m_nvic.c |
21 | @@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state_secure(NVICState *s) | 18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque) |
22 | int active_prio = NVIC_NOEXC_PRIO; | 19 | nvic_irq_update(s); |
23 | int pend_irq = 0; | 20 | } |
24 | bool pending_is_s_banked = false; | 21 | |
25 | + int pend_subprio = 0; | 22 | +static bool vectpending_targets_secure(NVICState *s) |
26 | 23 | +{ | |
27 | /* R_CQRV: precedence is by: | 24 | + /* Return true if s->vectpending targets Secure state */ |
28 | * - lowest group priority; if both the same then | 25 | + if (s->vectpending_is_s_banked) { |
29 | @@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state_secure(NVICState *s) | 26 | + return true; |
30 | for (i = 1; i < s->num_irq; i++) { | 27 | + } |
31 | for (bank = M_REG_S; bank >= M_REG_NS; bank--) { | 28 | + return !exc_is_banked(s->vectpending) && |
32 | VecInfo *vec; | 29 | + exc_targets_secure(s, s->vectpending); |
33 | - int prio; | 30 | +} |
34 | + int prio, subprio; | 31 | + |
35 | bool targets_secure; | 32 | void armv7m_nvic_get_pending_irq_info(void *opaque, |
36 | 33 | int *pirq, bool *ptargets_secure) | |
37 | if (bank == M_REG_S) { | 34 | { |
38 | @@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state_secure(NVICState *s) | 35 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque, |
39 | } | 36 | |
40 | 37 | assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq); | |
41 | prio = exc_group_prio(s, vec->prio, targets_secure); | 38 | |
42 | - if (vec->enabled && vec->pending && prio < pend_prio) { | 39 | - if (s->vectpending_is_s_banked) { |
43 | + subprio = vec->prio & ~nvic_gprio_mask(s, targets_secure); | 40 | - targets_secure = true; |
44 | + if (vec->enabled && vec->pending && | 41 | - } else { |
45 | + ((prio < pend_prio) || | 42 | - targets_secure = !exc_is_banked(pending) && |
46 | + (prio == pend_prio && prio >= 0 && subprio < pend_subprio))) { | 43 | - exc_targets_secure(s, pending); |
47 | pend_prio = prio; | 44 | - } |
48 | + pend_subprio = subprio; | 45 | + targets_secure = vectpending_targets_secure(s); |
49 | pend_irq = i; | 46 | |
50 | pending_is_s_banked = (bank == M_REG_S); | 47 | trace_nvic_get_pending_irq_info(pending, targets_secure); |
51 | } | 48 | |
49 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
50 | /* VECTACTIVE */ | ||
51 | val = cpu->env.v7m.exception; | ||
52 | /* VECTPENDING */ | ||
53 | - val |= (s->vectpending & 0x1ff) << 12; | ||
54 | + if (s->vectpending) { | ||
55 | + /* | ||
56 | + * From v8.1M VECTPENDING must read as 1 if accessed as | ||
57 | + * NonSecure and the highest priority pending and enabled | ||
58 | + * exception targets Secure. | ||
59 | + */ | ||
60 | + int vp = s->vectpending; | ||
61 | + if (!attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_V8_1M) && | ||
62 | + vectpending_targets_secure(s)) { | ||
63 | + vp = 1; | ||
64 | + } | ||
65 | + val |= (vp & 0x1ff) << 12; | ||
66 | + } | ||
67 | /* ISRPENDING - set if any external IRQ is pending */ | ||
68 | if (nvic_isrpending(s)) { | ||
69 | val |= (1 << 22); | ||
52 | -- | 70 | -- |
53 | 2.20.1 | 71 | 2.20.1 |
54 | 72 | ||
55 | 73 | diff view generated by jsdifflib |
1 | From: Markus Armbruster <armbru@redhat.com> | 1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> |
---|---|---|---|
2 | 2 | ||
3 | The ARM virt machines put firmware in flash memory. To configure it, | 3 | Missed in commit f3478392 "docs: Move deprecation, build |
4 | you use -drive if=pflash,unit=0,... and optionally -drive | 4 | and license info out of system/" |
5 | if=pflash,unit=1,... | ||
6 | 5 | ||
7 | Why two -drive? This permits setting up one part of the flash memory | 6 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> |
8 | read-only, and the other part read/write. It also makes upgrading | ||
9 | firmware on the host easier. Below the hood, we get two separate | ||
10 | flash devices, because we were too lazy to improve our flash device | ||
11 | models to support sector protection. | ||
12 | |||
13 | The problem at hand is to do the same with -blockdev somehow, as one | ||
14 | more step towards deprecating -drive. | ||
15 | |||
16 | We recently solved this problem for x86 PC machines, in commit | ||
17 | ebc29e1beab. See the commit message for design rationale. | ||
18 | |||
19 | This commit solves it for ARM virt basically the same way: new machine | ||
20 | properties pflash0, pflash1 forward to the onboard flash devices' | ||
21 | properties. Requires creating the onboard devices in the | ||
22 | .instance_init() method virt_instance_init(). The existing code to | ||
23 | pick up drives defined with -drive if=pflash is replaced by code to | ||
24 | desugar into the machine properties. | ||
25 | |||
26 | There are a few behavioral differences, though: | ||
27 | |||
28 | * The flash devices are always present (x86: only present if | ||
29 | configured) | ||
30 | |||
31 | * Flash base addresses and sizes are fixed (x86: sizes depend on | ||
32 | images, mapped back to back below a fixed address) | ||
33 | |||
34 | * -bios configures contents of first pflash (x86: -bios configures ROM | ||
35 | contents) | ||
36 | |||
37 | * -bios is rejected when first pflash is also configured with -machine | ||
38 | pflash0=... (x86: bios is silently ignored then) | ||
39 | |||
40 | * -machine pflash1=... does not require -machine pflash0=... (x86: it | ||
41 | does). | ||
42 | |||
43 | The actual code is a bit simpler than for x86 mostly due to the first | ||
44 | two differences. | ||
45 | |||
46 | Before the patch, all the action is in create_flash(), called from the | ||
47 | machine's .init() method machvirt_init(): | ||
48 | |||
49 | main() | ||
50 | machine_run_board_init() | ||
51 | machvirt_init() | ||
52 | create_flash() | ||
53 | create_one_flash() for flash[0] | ||
54 | create | ||
55 | configure | ||
56 | includes obeying -drive if=pflash,unit=0 | ||
57 | realize | ||
58 | map | ||
59 | fall back to -bios | ||
60 | create_one_flash() for flash[1] | ||
61 | create | ||
62 | configure | ||
63 | includes obeying -drive if=pflash,unit=1 | ||
64 | realize | ||
65 | map | ||
66 | update FDT | ||
67 | |||
68 | To make the machine properties work, we need to move device creation | ||
69 | to its .instance_init() method virt_instance_init(). | ||
70 | |||
71 | Another complication is machvirt_init()'s computation of | ||
72 | @firmware_loaded: it predicts what create_flash() will do. Instead of | ||
73 | predicting what create_flash()'s replacement virt_firmware_init() will | ||
74 | do, I decided to have virt_firmware_init() return what it did. | ||
75 | Requires calling it a bit earlier. | ||
76 | |||
77 | Resulting call tree: | ||
78 | |||
79 | main() | ||
80 | current_machine = object_new() | ||
81 | ... | ||
82 | virt_instance_init() | ||
83 | virt_flash_create() | ||
84 | virt_flash_create1() for flash[0] | ||
85 | create | ||
86 | configure: set defaults | ||
87 | become child of machine [NEW] | ||
88 | add machine prop pflash0 as alias for drive [NEW] | ||
89 | virt_flash_create1() for flash[1] | ||
90 | create | ||
91 | configure: set defaults | ||
92 | become child of machine [NEW] | ||
93 | add machine prop pflash1 as alias for drive [NEW] | ||
94 | for all machine props from the command line: machine_set_property() | ||
95 | ... | ||
96 | property_set_alias() for machine props pflash0, pflash1 | ||
97 | ... | ||
98 | set_drive() for cfi.pflash01 prop drive | ||
99 | this is how -machine pflash0=... etc set | ||
100 | machine_run_board_init(current_machine); | ||
101 | virt_firmware_init() | ||
102 | pflash_cfi01_legacy_drive() | ||
103 | legacy -drive if=pflash,unit=0 and =1 [NEW] | ||
104 | virt_flash_map() | ||
105 | virt_flash_map1() for flash[0] | ||
106 | configure: num-blocks | ||
107 | realize | ||
108 | map | ||
109 | virt_flash_map1() for flash[1] | ||
110 | configure: num-blocks | ||
111 | realize | ||
112 | map | ||
113 | fall back to -bios | ||
114 | virt_flash_fdt() | ||
115 | update FDT | ||
116 | |||
117 | You have László to thank for making me explain this in detail. | ||
118 | |||
119 | Signed-off-by: Markus Armbruster <armbru@redhat.com> | ||
120 | Acked-by: Laszlo Ersek <lersek@redhat.com> | ||
121 | Message-id: 20190416091348.26075-4-armbru@redhat.com | ||
122 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20210723065828.1336760-1-maozhongyi@cmss.chinamobile.com | ||
123 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
124 | --- | 10 | --- |
125 | include/hw/arm/virt.h | 2 + | 11 | configure | 2 +- |
126 | hw/arm/virt.c | 202 +++++++++++++++++++++++++++--------------- | 12 | target/i386/cpu.c | 2 +- |
127 | 2 files changed, 132 insertions(+), 72 deletions(-) | 13 | MAINTAINERS | 2 +- |
14 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
128 | 15 | ||
129 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 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 | ||
130 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
131 | --- a/include/hw/arm/virt.h | 31 | --- a/target/i386/cpu.c |
132 | +++ b/include/hw/arm/virt.h | 32 | +++ b/target/i386/cpu.c |
133 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ static const X86CPUDefinition builtin_x86_defs[] = { |
134 | #include "qemu/notify.h" | 34 | * none", but this is just for compatibility while libvirt isn't |
135 | #include "hw/boards.h" | 35 | * adapted to resolve CPU model versions before creating VMs. |
136 | #include "hw/arm/arm.h" | 36 | * See "Runnability guarantee of CPU models" at |
137 | +#include "hw/block/flash.h" | 37 | - * docs/system/deprecated.rst. |
138 | #include "sysemu/kvm.h" | 38 | + * docs/about/deprecated.rst. |
139 | #include "hw/intc/arm_gicv3_common.h" | 39 | */ |
140 | 40 | X86CPUVersion default_cpu_version = 1; | |
141 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 41 | |
142 | Notifier machine_done; | 42 | diff --git a/MAINTAINERS b/MAINTAINERS |
143 | DeviceState *platform_bus_dev; | ||
144 | FWCfgState *fw_cfg; | ||
145 | + PFlashCFI01 *flash[2]; | ||
146 | bool secure; | ||
147 | bool highmem; | ||
148 | bool highmem_ecam; | ||
149 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
151 | --- a/hw/arm/virt.c | 44 | --- a/MAINTAINERS |
152 | +++ b/hw/arm/virt.c | 45 | +++ b/MAINTAINERS |
153 | @@ -XXX,XX +XXX,XX @@ | 46 | @@ -XXX,XX +XXX,XX @@ F: contrib/gitdm/* |
154 | 47 | ||
155 | #include "qemu/osdep.h" | 48 | Incompatible changes |
156 | #include "qemu/units.h" | 49 | R: libvir-list@redhat.com |
157 | +#include "qemu/option.h" | 50 | -F: docs/system/deprecated.rst |
158 | #include "qapi/error.h" | 51 | +F: docs/about/deprecated.rst |
159 | #include "hw/sysbus.h" | 52 | |
160 | #include "hw/arm/arm.h" | 53 | Build System |
161 | @@ -XXX,XX +XXX,XX @@ static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic) | 54 | ------------ |
162 | } | ||
163 | } | ||
164 | |||
165 | -static void create_one_flash(const char *name, hwaddr flashbase, | ||
166 | - hwaddr flashsize, const char *file, | ||
167 | - MemoryRegion *sysmem) | ||
168 | +#define VIRT_FLASH_SECTOR_SIZE (256 * KiB) | ||
169 | + | ||
170 | +static PFlashCFI01 *virt_flash_create1(VirtMachineState *vms, | ||
171 | + const char *name, | ||
172 | + const char *alias_prop_name) | ||
173 | { | ||
174 | - /* Create and map a single flash device. We use the same | ||
175 | - * parameters as the flash devices on the Versatile Express board. | ||
176 | + /* | ||
177 | + * Create a single flash device. We use the same parameters as | ||
178 | + * the flash devices on the Versatile Express board. | ||
179 | */ | ||
180 | - DriveInfo *dinfo = drive_get_next(IF_PFLASH); | ||
181 | DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01); | ||
182 | - SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
183 | - const uint64_t sectorlength = 256 * 1024; | ||
184 | |||
185 | - if (dinfo) { | ||
186 | - qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo), | ||
187 | - &error_abort); | ||
188 | - } | ||
189 | - | ||
190 | - qdev_prop_set_uint32(dev, "num-blocks", flashsize / sectorlength); | ||
191 | - qdev_prop_set_uint64(dev, "sector-length", sectorlength); | ||
192 | + qdev_prop_set_uint64(dev, "sector-length", VIRT_FLASH_SECTOR_SIZE); | ||
193 | qdev_prop_set_uint8(dev, "width", 4); | ||
194 | qdev_prop_set_uint8(dev, "device-width", 2); | ||
195 | qdev_prop_set_bit(dev, "big-endian", false); | ||
196 | @@ -XXX,XX +XXX,XX @@ static void create_one_flash(const char *name, hwaddr flashbase, | ||
197 | qdev_prop_set_uint16(dev, "id2", 0x00); | ||
198 | qdev_prop_set_uint16(dev, "id3", 0x00); | ||
199 | qdev_prop_set_string(dev, "name", name); | ||
200 | - qdev_init_nofail(dev); | ||
201 | - | ||
202 | - memory_region_add_subregion(sysmem, flashbase, | ||
203 | - sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0)); | ||
204 | - | ||
205 | - if (file) { | ||
206 | - char *fn; | ||
207 | - int image_size; | ||
208 | - | ||
209 | - if (drive_get(IF_PFLASH, 0, 0)) { | ||
210 | - error_report("The contents of the first flash device may be " | ||
211 | - "specified with -bios or with -drive if=pflash... " | ||
212 | - "but you cannot use both options at once"); | ||
213 | - exit(1); | ||
214 | - } | ||
215 | - fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, file); | ||
216 | - if (!fn) { | ||
217 | - error_report("Could not find ROM image '%s'", file); | ||
218 | - exit(1); | ||
219 | - } | ||
220 | - image_size = load_image_mr(fn, sysbus_mmio_get_region(sbd, 0)); | ||
221 | - g_free(fn); | ||
222 | - if (image_size < 0) { | ||
223 | - error_report("Could not load ROM image '%s'", file); | ||
224 | - exit(1); | ||
225 | - } | ||
226 | - } | ||
227 | + object_property_add_child(OBJECT(vms), name, OBJECT(dev), | ||
228 | + &error_abort); | ||
229 | + object_property_add_alias(OBJECT(vms), alias_prop_name, | ||
230 | + OBJECT(dev), "drive", &error_abort); | ||
231 | + return PFLASH_CFI01(dev); | ||
232 | } | ||
233 | |||
234 | -static void create_flash(const VirtMachineState *vms, | ||
235 | - MemoryRegion *sysmem, | ||
236 | - MemoryRegion *secure_sysmem) | ||
237 | +static void virt_flash_create(VirtMachineState *vms) | ||
238 | { | ||
239 | - /* Create two flash devices to fill the VIRT_FLASH space in the memmap. | ||
240 | - * Any file passed via -bios goes in the first of these. | ||
241 | + vms->flash[0] = virt_flash_create1(vms, "virt.flash0", "pflash0"); | ||
242 | + vms->flash[1] = virt_flash_create1(vms, "virt.flash1", "pflash1"); | ||
243 | +} | ||
244 | + | ||
245 | +static void virt_flash_map1(PFlashCFI01 *flash, | ||
246 | + hwaddr base, hwaddr size, | ||
247 | + MemoryRegion *sysmem) | ||
248 | +{ | ||
249 | + DeviceState *dev = DEVICE(flash); | ||
250 | + | ||
251 | + assert(size % VIRT_FLASH_SECTOR_SIZE == 0); | ||
252 | + assert(size / VIRT_FLASH_SECTOR_SIZE <= UINT32_MAX); | ||
253 | + qdev_prop_set_uint32(dev, "num-blocks", size / VIRT_FLASH_SECTOR_SIZE); | ||
254 | + qdev_init_nofail(dev); | ||
255 | + | ||
256 | + memory_region_add_subregion(sysmem, base, | ||
257 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), | ||
258 | + 0)); | ||
259 | +} | ||
260 | + | ||
261 | +static void virt_flash_map(VirtMachineState *vms, | ||
262 | + MemoryRegion *sysmem, | ||
263 | + MemoryRegion *secure_sysmem) | ||
264 | +{ | ||
265 | + /* | ||
266 | + * Map two flash devices to fill the VIRT_FLASH space in the memmap. | ||
267 | * sysmem is the system memory space. secure_sysmem is the secure view | ||
268 | * of the system, and the first flash device should be made visible only | ||
269 | * there. The second flash device is visible to both secure and nonsecure. | ||
270 | @@ -XXX,XX +XXX,XX @@ static void create_flash(const VirtMachineState *vms, | ||
271 | */ | ||
272 | hwaddr flashsize = vms->memmap[VIRT_FLASH].size / 2; | ||
273 | hwaddr flashbase = vms->memmap[VIRT_FLASH].base; | ||
274 | - char *nodename; | ||
275 | |||
276 | - create_one_flash("virt.flash0", flashbase, flashsize, | ||
277 | - bios_name, secure_sysmem); | ||
278 | - create_one_flash("virt.flash1", flashbase + flashsize, flashsize, | ||
279 | - NULL, sysmem); | ||
280 | + virt_flash_map1(vms->flash[0], flashbase, flashsize, | ||
281 | + secure_sysmem); | ||
282 | + virt_flash_map1(vms->flash[1], flashbase + flashsize, flashsize, | ||
283 | + sysmem); | ||
284 | +} | ||
285 | + | ||
286 | +static void virt_flash_fdt(VirtMachineState *vms, | ||
287 | + MemoryRegion *sysmem, | ||
288 | + MemoryRegion *secure_sysmem) | ||
289 | +{ | ||
290 | + hwaddr flashsize = vms->memmap[VIRT_FLASH].size / 2; | ||
291 | + hwaddr flashbase = vms->memmap[VIRT_FLASH].base; | ||
292 | + char *nodename; | ||
293 | |||
294 | if (sysmem == secure_sysmem) { | ||
295 | /* Report both flash devices as a single node in the DT */ | ||
296 | @@ -XXX,XX +XXX,XX @@ static void create_flash(const VirtMachineState *vms, | ||
297 | qemu_fdt_setprop_cell(vms->fdt, nodename, "bank-width", 4); | ||
298 | g_free(nodename); | ||
299 | } else { | ||
300 | - /* Report the devices as separate nodes so we can mark one as | ||
301 | + /* | ||
302 | + * Report the devices as separate nodes so we can mark one as | ||
303 | * only visible to the secure world. | ||
304 | */ | ||
305 | nodename = g_strdup_printf("/secflash@%" PRIx64, flashbase); | ||
306 | @@ -XXX,XX +XXX,XX @@ static void create_flash(const VirtMachineState *vms, | ||
307 | } | ||
308 | } | ||
309 | |||
310 | +static bool virt_firmware_init(VirtMachineState *vms, | ||
311 | + MemoryRegion *sysmem, | ||
312 | + MemoryRegion *secure_sysmem) | ||
313 | +{ | ||
314 | + int i; | ||
315 | + BlockBackend *pflash_blk0; | ||
316 | + | ||
317 | + /* Map legacy -drive if=pflash to machine properties */ | ||
318 | + for (i = 0; i < ARRAY_SIZE(vms->flash); i++) { | ||
319 | + pflash_cfi01_legacy_drive(vms->flash[i], | ||
320 | + drive_get(IF_PFLASH, 0, i)); | ||
321 | + } | ||
322 | + | ||
323 | + virt_flash_map(vms, sysmem, secure_sysmem); | ||
324 | + | ||
325 | + pflash_blk0 = pflash_cfi01_get_blk(vms->flash[0]); | ||
326 | + | ||
327 | + if (bios_name) { | ||
328 | + char *fname; | ||
329 | + MemoryRegion *mr; | ||
330 | + int image_size; | ||
331 | + | ||
332 | + if (pflash_blk0) { | ||
333 | + error_report("The contents of the first flash device may be " | ||
334 | + "specified with -bios or with -drive if=pflash... " | ||
335 | + "but you cannot use both options at once"); | ||
336 | + exit(1); | ||
337 | + } | ||
338 | + | ||
339 | + /* Fall back to -bios */ | ||
340 | + | ||
341 | + fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); | ||
342 | + if (!fname) { | ||
343 | + error_report("Could not find ROM image '%s'", bios_name); | ||
344 | + exit(1); | ||
345 | + } | ||
346 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(vms->flash[0]), 0); | ||
347 | + image_size = load_image_mr(fname, mr); | ||
348 | + g_free(fname); | ||
349 | + if (image_size < 0) { | ||
350 | + error_report("Could not load ROM image '%s'", bios_name); | ||
351 | + exit(1); | ||
352 | + } | ||
353 | + } | ||
354 | + | ||
355 | + return pflash_blk0 || bios_name; | ||
356 | +} | ||
357 | + | ||
358 | static FWCfgState *create_fw_cfg(const VirtMachineState *vms, AddressSpace *as) | ||
359 | { | ||
360 | hwaddr base = vms->memmap[VIRT_FW_CFG].base; | ||
361 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
362 | MemoryRegion *secure_sysmem = NULL; | ||
363 | int n, virt_max_cpus; | ||
364 | MemoryRegion *ram = g_new(MemoryRegion, 1); | ||
365 | - bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0); | ||
366 | + bool firmware_loaded; | ||
367 | bool aarch64 = true; | ||
368 | |||
369 | /* | ||
370 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
371 | exit(1); | ||
372 | } | ||
373 | |||
374 | + if (vms->secure) { | ||
375 | + if (kvm_enabled()) { | ||
376 | + error_report("mach-virt: KVM does not support Security extensions"); | ||
377 | + exit(1); | ||
378 | + } | ||
379 | + | ||
380 | + /* | ||
381 | + * The Secure view of the world is the same as the NonSecure, | ||
382 | + * but with a few extra devices. Create it as a container region | ||
383 | + * containing the system memory at low priority; any secure-only | ||
384 | + * devices go in at higher priority and take precedence. | ||
385 | + */ | ||
386 | + secure_sysmem = g_new(MemoryRegion, 1); | ||
387 | + memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory", | ||
388 | + UINT64_MAX); | ||
389 | + memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1); | ||
390 | + } | ||
391 | + | ||
392 | + firmware_loaded = virt_firmware_init(vms, sysmem, | ||
393 | + secure_sysmem ?: sysmem); | ||
394 | + | ||
395 | /* If we have an EL3 boot ROM then the assumption is that it will | ||
396 | * implement PSCI itself, so disable QEMU's internal implementation | ||
397 | * so it doesn't get in the way. Instead of starting secondary | ||
398 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
399 | exit(1); | ||
400 | } | ||
401 | |||
402 | - if (vms->secure) { | ||
403 | - if (kvm_enabled()) { | ||
404 | - error_report("mach-virt: KVM does not support Security extensions"); | ||
405 | - exit(1); | ||
406 | - } | ||
407 | - | ||
408 | - /* The Secure view of the world is the same as the NonSecure, | ||
409 | - * but with a few extra devices. Create it as a container region | ||
410 | - * containing the system memory at low priority; any secure-only | ||
411 | - * devices go in at higher priority and take precedence. | ||
412 | - */ | ||
413 | - secure_sysmem = g_new(MemoryRegion, 1); | ||
414 | - memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory", | ||
415 | - UINT64_MAX); | ||
416 | - memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1); | ||
417 | - } | ||
418 | - | ||
419 | create_fdt(vms); | ||
420 | |||
421 | possible_cpus = mc->possible_cpu_arch_ids(machine); | ||
422 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
423 | &machine->device_memory->mr); | ||
424 | } | ||
425 | |||
426 | - create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); | ||
427 | + virt_flash_fdt(vms, sysmem, secure_sysmem); | ||
428 | |||
429 | create_gic(vms, pic); | ||
430 | |||
431 | @@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj) | ||
432 | NULL); | ||
433 | |||
434 | vms->irqmap = a15irqmap; | ||
435 | + | ||
436 | + virt_flash_create(vms); | ||
437 | } | ||
438 | |||
439 | static const TypeInfo virt_machine_info = { | ||
440 | -- | 55 | -- |
441 | 2.20.1 | 56 | 2.20.1 |
442 | 57 | ||
443 | 58 | diff view generated by jsdifflib |
1 | Currently the dc_zva helper function uses a variable length | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | array. In fact we know (as the comment above remarks) that | ||
3 | the length of this array is bounded because the architecture | ||
4 | limits the block size and QEMU limits the target page size. | ||
5 | Use a fixed array size and assert that we don't run off it. | ||
6 | 2 | ||
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. | ||
7 | |||
8 | Saturate the length to ARM_MAX_VQ instead of truncating to | ||
9 | the low 4 bits. | ||
10 | |||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20210723203344.968563-2-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20190503120448.13385-1-peter.maydell@linaro.org | ||
12 | --- | 15 | --- |
13 | target/arm/helper.c | 8 ++++++-- | 16 | target/arm/helper.c | 4 +++- |
14 | 1 file changed, 6 insertions(+), 2 deletions(-) | 17 | 1 file changed, 3 insertions(+), 1 deletion(-) |
15 | 18 | ||
16 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 19 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper.c | 21 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/helper.c | 22 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
21 | #include "qemu/osdep.h" | 24 | { |
22 | +#include "qemu/units.h" | 25 | uint32_t end_len; |
23 | #include "target/arm/idau.h" | 26 | |
24 | #include "trace.h" | 27 | - end_len = start_len &= 0xf; |
25 | #include "cpu.h" | 28 | + start_len = MIN(start_len, ARM_MAX_VQ - 1); |
26 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | 29 | + end_len = start_len; |
27 | * We know that in fact for any v8 CPU the page size is at least 4K | ||
28 | * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
29 | * 1K as an artefact of legacy v5 subpage support being present in the | ||
30 | - * same QEMU executable. | ||
31 | + * same QEMU executable. So in practice the hostaddr[] array has | ||
32 | + * two entries, given the current setting of TARGET_PAGE_BITS_MIN. | ||
33 | */ | ||
34 | int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | ||
35 | - void *hostaddr[maxidx]; | ||
36 | + void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
37 | int try, i; | ||
38 | unsigned mmu_idx = cpu_mmu_index(env, false); | ||
39 | TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
40 | |||
41 | + assert(maxidx <= ARRAY_SIZE(hostaddr)); | ||
42 | + | 30 | + |
43 | for (try = 0; try < 2; try++) { | 31 | if (!test_bit(start_len, cpu->sve_vq_map)) { |
44 | 32 | end_len = find_last_bit(cpu->sve_vq_map, start_len); | |
45 | for (i = 0; i < maxidx; i++) { | 33 | assert(end_len < start_len); |
46 | -- | 34 | -- |
47 | 2.20.1 | 35 | 2.20.1 |
48 | 36 | ||
49 | 37 | diff view generated by jsdifflib |
1 | At the moment the Arm implementations of kvm_arch_{get,put}_registers() | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | don't support having QEMU change the values of system registers | ||
3 | (aka coprocessor registers for AArch32). This is because although | ||
4 | kvm_arch_get_registers() calls write_list_to_cpustate() to | ||
5 | update the CPU state struct fields (so QEMU code can read the | ||
6 | values in the usual way), kvm_arch_put_registers() does not | ||
7 | call write_cpustate_to_list(), meaning that any changes to | ||
8 | the CPU state struct fields will not be passed back to KVM. | ||
9 | 2 | ||
10 | The rationale for this design is documented in a comment in the | 3 | Rename from sve_zcr_get_valid_len and make accessible |
11 | AArch32 kvm_arch_put_registers() -- writing the values in the | 4 | from outside of helper.c. |
12 | cpregs list into the CPU state struct is "lossy" because the | ||
13 | write of a register might not succeed, and so if we blindly | ||
14 | copy the CPU state values back again we will incorrectly | ||
15 | change register values for the guest. The assumption was that | ||
16 | no QEMU code would need to write to the registers. | ||
17 | 5 | ||
18 | However, when we implemented debug support for KVM guests, we | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
19 | broke that assumption: the code to handle "set the guest up | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
20 | to take a breakpoint exception" does so by updating various | 8 | Message-id: 20210723203344.968563-3-richard.henderson@linaro.org |
21 | guest registers including ESR_EL1. | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | ||
11 | target/arm/internals.h | 10 ++++++++++ | ||
12 | target/arm/helper.c | 4 ++-- | ||
13 | 2 files changed, 12 insertions(+), 2 deletions(-) | ||
22 | 14 | ||
23 | Support this by making kvm_arch_put_registers() synchronize | 15 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
24 | CPU state back into the list. We sync only those registers | ||
25 | where the initial write succeeds, which should be sufficient. | ||
26 | |||
27 | This commit is the same as commit 823e1b3818f9b10b824ddc which we | ||
28 | had to revert in commit 942f99c825fc94c8b1a4, except that the bug | ||
29 | which was preventing EDK2 guest firmware running has been fixed: | ||
30 | kvm_arm_reset_vcpu() now calls write_list_to_cpustate(). | ||
31 | |||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
33 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
34 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
35 | --- | ||
36 | target/arm/cpu.h | 9 ++++++++- | ||
37 | target/arm/helper.c | 27 +++++++++++++++++++++++++-- | ||
38 | target/arm/kvm.c | 8 ++++++++ | ||
39 | target/arm/kvm32.c | 20 ++------------------ | ||
40 | target/arm/kvm64.c | 2 ++ | ||
41 | target/arm/machine.c | 2 +- | ||
42 | 6 files changed, 46 insertions(+), 22 deletions(-) | ||
43 | |||
44 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
45 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/internals.h |
47 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/internals.h |
48 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu); | 19 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void); |
49 | /** | 20 | void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); |
50 | * write_cpustate_to_list: | 21 | #endif /* CONFIG_TCG */ |
51 | * @cpu: ARMCPU | 22 | |
52 | + * @kvm_sync: true if this is for syncing back to KVM | 23 | +/** |
53 | * | 24 | + * aarch64_sve_zcr_get_valid_len: |
54 | * For each register listed in the ARMCPU cpreg_indexes list, write | 25 | + * @cpu: cpu context |
55 | * its value from the ARMCPUState structure into the cpreg_values list. | 26 | + * @start_len: maximum len to consider |
56 | * This is used to copy info from TCG's working data structures into | ||
57 | * KVM or for outbound migration. | ||
58 | * | ||
59 | + * @kvm_sync is true if we are doing this in order to sync the | ||
60 | + * register state back to KVM. In this case we will only update | ||
61 | + * values in the list if the previous list->cpustate sync actually | ||
62 | + * successfully wrote the CPU state. Otherwise we will keep the value | ||
63 | + * that is in the list. | ||
64 | + * | 27 | + * |
65 | * Returns: true if all register values were read correctly, | 28 | + * Return the maximum supported sve vector length <= @start_len. |
66 | * false if some register was unknown or could not be read. | 29 | + * Note that both @start_len and the return value are in units |
67 | * Note that we do not stop early on failure -- we will attempt | 30 | + * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128. |
68 | * reading all registers in the list. | 31 | + */ |
69 | */ | 32 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len); |
70 | -bool write_cpustate_to_list(ARMCPU *cpu); | 33 | |
71 | +bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); | 34 | enum arm_fprounding { |
72 | 35 | FPROUNDING_TIEEVEN, | |
73 | #define ARM_CPUID_TI915T 0x54029152 | ||
74 | #define ARM_CPUID_TI925T 0x54029252 | ||
75 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 36 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
76 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
77 | --- a/target/arm/helper.c | 38 | --- a/target/arm/helper.c |
78 | +++ b/target/arm/helper.c | 39 | +++ b/target/arm/helper.c |
79 | @@ -XXX,XX +XXX,XX @@ static bool raw_accessors_invalid(const ARMCPRegInfo *ri) | 40 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
80 | return true; | 41 | return 0; |
81 | } | 42 | } |
82 | 43 | ||
83 | -bool write_cpustate_to_list(ARMCPU *cpu) | 44 | -static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
84 | +bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync) | 45 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
85 | { | 46 | { |
86 | /* Write the coprocessor state from cpu->env to the (index,value) list. */ | 47 | uint32_t end_len; |
87 | int i; | 48 | |
88 | @@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu) | 49 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) |
89 | for (i = 0; i < cpu->cpreg_array_len; i++) { | 50 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); |
90 | uint32_t regidx = kvm_to_cpreg_id(cpu->cpreg_indexes[i]); | ||
91 | const ARMCPRegInfo *ri; | ||
92 | + uint64_t newval; | ||
93 | |||
94 | ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
95 | if (!ri) { | ||
96 | @@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu) | ||
97 | if (ri->type & ARM_CP_NO_RAW) { | ||
98 | continue; | ||
99 | } | ||
100 | - cpu->cpreg_values[i] = read_raw_cp_reg(&cpu->env, ri); | ||
101 | + | ||
102 | + newval = read_raw_cp_reg(&cpu->env, ri); | ||
103 | + if (kvm_sync) { | ||
104 | + /* | ||
105 | + * Only sync if the previous list->cpustate sync succeeded. | ||
106 | + * Rather than tracking the success/failure state for every | ||
107 | + * item in the list, we just recheck "does the raw write we must | ||
108 | + * have made in write_list_to_cpustate() read back OK" here. | ||
109 | + */ | ||
110 | + uint64_t oldval = cpu->cpreg_values[i]; | ||
111 | + | ||
112 | + if (oldval == newval) { | ||
113 | + continue; | ||
114 | + } | ||
115 | + | ||
116 | + write_raw_cp_reg(&cpu->env, ri, oldval); | ||
117 | + if (read_raw_cp_reg(&cpu->env, ri) != oldval) { | ||
118 | + continue; | ||
119 | + } | ||
120 | + | ||
121 | + write_raw_cp_reg(&cpu->env, ri, newval); | ||
122 | + } | ||
123 | + cpu->cpreg_values[i] = newval; | ||
124 | } | 51 | } |
125 | return ok; | 52 | |
53 | - return sve_zcr_get_valid_len(cpu, zcr_len); | ||
54 | + return aarch64_sve_zcr_get_valid_len(cpu, zcr_len); | ||
126 | } | 55 | } |
127 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | 56 | |
128 | index XXXXXXX..XXXXXXX 100644 | 57 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
129 | --- a/target/arm/kvm.c | ||
130 | +++ b/target/arm/kvm.c | ||
131 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_reset_vcpu(ARMCPU *cpu) | ||
132 | fprintf(stderr, "write_kvmstate_to_list failed\n"); | ||
133 | abort(); | ||
134 | } | ||
135 | + /* | ||
136 | + * Sync the reset values also into the CPUState. This is necessary | ||
137 | + * because the next thing we do will be a kvm_arch_put_registers() | ||
138 | + * which will update the list values from the CPUState before copying | ||
139 | + * the list values back to KVM. It's OK to ignore failure returns here | ||
140 | + * for the same reason we do so in kvm_arch_get_registers(). | ||
141 | + */ | ||
142 | + write_list_to_cpustate(cpu); | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/target/arm/kvm32.c | ||
149 | +++ b/target/arm/kvm32.c | ||
150 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
151 | return ret; | ||
152 | } | ||
153 | |||
154 | - /* Note that we do not call write_cpustate_to_list() | ||
155 | - * here, so we are only writing the tuple list back to | ||
156 | - * KVM. This is safe because nothing can change the | ||
157 | - * CPUARMState cp15 fields (in particular gdb accesses cannot) | ||
158 | - * and so there are no changes to sync. In fact syncing would | ||
159 | - * be wrong at this point: for a constant register where TCG and | ||
160 | - * KVM disagree about its value, the preceding write_list_to_cpustate() | ||
161 | - * would not have had any effect on the CPUARMState value (since the | ||
162 | - * register is read-only), and a write_cpustate_to_list() here would | ||
163 | - * then try to write the TCG value back into KVM -- this would either | ||
164 | - * fail or incorrectly change the value the guest sees. | ||
165 | - * | ||
166 | - * If we ever want to allow the user to modify cp15 registers via | ||
167 | - * the gdb stub, we would need to be more clever here (for instance | ||
168 | - * tracking the set of registers kvm_arch_get_registers() successfully | ||
169 | - * managed to update the CPUARMState with, and only allowing those | ||
170 | - * to be written back up into the kernel). | ||
171 | - */ | ||
172 | + write_cpustate_to_list(cpu, true); | ||
173 | + | ||
174 | if (!write_list_to_kvmstate(cpu, level)) { | ||
175 | return EINVAL; | ||
176 | } | ||
177 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
178 | index XXXXXXX..XXXXXXX 100644 | ||
179 | --- a/target/arm/kvm64.c | ||
180 | +++ b/target/arm/kvm64.c | ||
181 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
182 | return ret; | ||
183 | } | ||
184 | |||
185 | + write_cpustate_to_list(cpu, true); | ||
186 | + | ||
187 | if (!write_list_to_kvmstate(cpu, level)) { | ||
188 | return EINVAL; | ||
189 | } | ||
190 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
191 | index XXXXXXX..XXXXXXX 100644 | ||
192 | --- a/target/arm/machine.c | ||
193 | +++ b/target/arm/machine.c | ||
194 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | ||
195 | abort(); | ||
196 | } | ||
197 | } else { | ||
198 | - if (!write_cpustate_to_list(cpu)) { | ||
199 | + if (!write_cpustate_to_list(cpu, false)) { | ||
200 | /* This should never fail. */ | ||
201 | abort(); | ||
202 | } | ||
203 | -- | 58 | -- |
204 | 2.20.1 | 59 | 2.20.1 |
205 | 60 | ||
206 | 61 | diff view generated by jsdifflib |
1 | From: Markus Armbruster <armbru@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Factored out of pc_system_firmware_init() so the next commit can reuse | 3 | Mirror the behavour of /proc/sys/abi/sve_default_vector_length |
4 | it in hw/arm/virt.c. | 4 | under the real linux kernel. We have no way of passing along |
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. | ||
5 | 7 | ||
6 | Signed-off-by: Markus Armbruster <armbru@redhat.com> | 8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/482 |
7 | Reviewed-by: Laszlo Ersek <lersek@redhat.com> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20190416091348.26075-3-armbru@redhat.com | 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 | --- | 15 | --- |
12 | include/hw/block/flash.h | 1 + | 16 | docs/system/arm/cpu-features.rst | 15 ++++++++ |
13 | hw/block/pflash_cfi01.c | 28 ++++++++++++++++++++++++++++ | 17 | target/arm/cpu.h | 5 +++ |
14 | hw/i386/pc_sysfw.c | 16 ++-------------- | 18 | target/arm/cpu.c | 14 ++++++-- |
15 | 3 files changed, 31 insertions(+), 14 deletions(-) | 19 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++ |
20 | 4 files changed, 92 insertions(+), 2 deletions(-) | ||
16 | 21 | ||
17 | diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h | 22 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst |
18 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/block/flash.h | 24 | --- a/docs/system/arm/cpu-features.rst |
20 | +++ b/include/hw/block/flash.h | 25 | +++ b/docs/system/arm/cpu-features.rst |
21 | @@ -XXX,XX +XXX,XX @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base, | 26 | @@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector |
22 | int be); | 27 | lengths is to explicitly enable each desired length. Therefore only |
23 | BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl); | 28 | example's (1), (4), and (6) exhibit recommended uses of the properties. |
24 | MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl); | 29 | |
25 | +void pflash_cfi01_legacy_drive(PFlashCFI01 *dev, DriveInfo *dinfo); | 30 | +SVE User-mode Default Vector Length Property |
26 | 31 | +-------------------------------------------- | |
27 | /* pflash_cfi02.c */ | 32 | + |
28 | 33 | +For qemu-aarch64, the cpu property ``sve-default-vector-length=N`` is | |
29 | diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c | 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. | ||
45 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/block/pflash_cfi01.c | 47 | --- a/target/arm/cpu.h |
32 | +++ b/hw/block/pflash_cfi01.c | 48 | +++ b/target/arm/cpu.h |
33 | @@ -XXX,XX +XXX,XX @@ | 49 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
34 | #include "qapi/error.h" | 50 | /* Used to set the maximum vector length the cpu will support. */ |
35 | #include "qemu/timer.h" | 51 | uint32_t sve_max_vq; |
36 | #include "qemu/bitops.h" | 52 | |
37 | +#include "qemu/error-report.h" | 53 | +#ifdef CONFIG_USER_ONLY |
38 | #include "qemu/host-utils.h" | 54 | + /* Used to set the default vector length at process start. */ |
39 | #include "qemu/log.h" | 55 | + uint32_t sve_default_vq; |
40 | +#include "qemu/option.h" | 56 | +#endif |
41 | #include "hw/sysbus.h" | 57 | + |
42 | +#include "sysemu/blockdev.h" | 58 | /* |
43 | #include "sysemu/sysemu.h" | 59 | * In sve_vq_map each set bit is a supported vector length of |
44 | #include "trace.h" | 60 | * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector |
45 | 61 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | |
46 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl) | 62 | index XXXXXXX..XXXXXXX 100644 |
47 | return &fl->mem; | 63 | --- a/target/arm/cpu.c |
64 | +++ b/target/arm/cpu.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | ||
66 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); | ||
67 | /* with reasonable vector length */ | ||
68 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
69 | - env->vfp.zcr_el[1] = MIN(cpu->sve_max_vq - 1, 3); | ||
70 | + env->vfp.zcr_el[1] = | ||
71 | + aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1); | ||
72 | } | ||
73 | /* | ||
74 | * Enable TBI0 but not TBI1. | ||
75 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | ||
76 | QLIST_INIT(&cpu->pre_el_change_hooks); | ||
77 | QLIST_INIT(&cpu->el_change_hooks); | ||
78 | |||
79 | -#ifndef CONFIG_USER_ONLY | ||
80 | +#ifdef CONFIG_USER_ONLY | ||
81 | +# ifdef TARGET_AARCH64 | ||
82 | + /* | ||
83 | + * The linux kernel defaults to 512-bit vectors, when sve is supported. | ||
84 | + * See documentation for /proc/sys/abi/sve_default_vector_length, and | ||
85 | + * our corresponding sve-default-vector-length cpu property. | ||
86 | + */ | ||
87 | + cpu->sve_default_vq = 4; | ||
88 | +# endif | ||
89 | +#else | ||
90 | /* Our inbound IRQ and FIQ lines */ | ||
91 | if (kvm_enabled()) { | ||
92 | /* VIRQ and VFIQ are unused with KVM but we add them to maintain | ||
93 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/cpu64.c | ||
96 | +++ b/target/arm/cpu64.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) | ||
98 | cpu->isar.id_aa64pfr0 = t; | ||
48 | } | 99 | } |
49 | 100 | ||
50 | +/* | 101 | +#ifdef CONFIG_USER_ONLY |
51 | + * Handle -drive if=pflash for machines that use properties. | 102 | +/* Mirror linux /proc/sys/abi/sve_default_vector_length. */ |
52 | + * If @dinfo is null, do nothing. | 103 | +static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, |
53 | + * Else if @fl's property "drive" is already set, fatal error. | 104 | + const char *name, void *opaque, |
54 | + * Else set it to the BlockBackend with @dinfo. | 105 | + Error **errp) |
55 | + */ | ||
56 | +void pflash_cfi01_legacy_drive(PFlashCFI01 *fl, DriveInfo *dinfo) | ||
57 | +{ | 106 | +{ |
58 | + Location loc; | 107 | + ARMCPU *cpu = ARM_CPU(obj); |
108 | + int32_t default_len, default_vq, remainder; | ||
59 | + | 109 | + |
60 | + if (!dinfo) { | 110 | + if (!visit_type_int32(v, name, &default_len, errp)) { |
61 | + return; | 111 | + return; |
62 | + } | 112 | + } |
63 | + | 113 | + |
64 | + loc_push_none(&loc); | 114 | + /* Undocumented, but the kernel allows -1 to indicate "maximum". */ |
65 | + qemu_opts_loc_restore(dinfo->opts); | 115 | + if (default_len == -1) { |
66 | + if (fl->blk) { | 116 | + cpu->sve_default_vq = ARM_MAX_VQ; |
67 | + error_report("clashes with -machine"); | 117 | + return; |
68 | + exit(1); | ||
69 | + } | 118 | + } |
70 | + qdev_prop_set_drive(DEVICE(fl), "drive", | 119 | + |
71 | + blk_by_legacy_dinfo(dinfo), &error_fatal); | 120 | + default_vq = default_len / 16; |
72 | + loc_pop(&loc); | 121 | + remainder = default_len % 16; |
122 | + | ||
123 | + /* | ||
124 | + * Note that the 512 max comes from include/uapi/asm/sve_context.h | ||
125 | + * and is the maximum architectural width of ZCR_ELx.LEN. | ||
126 | + */ | ||
127 | + if (remainder || default_vq < 1 || default_vq > 512) { | ||
128 | + error_setg(errp, "cannot set sve-default-vector-length"); | ||
129 | + if (remainder) { | ||
130 | + error_append_hint(errp, "Vector length not a multiple of 16\n"); | ||
131 | + } else if (default_vq < 1) { | ||
132 | + error_append_hint(errp, "Vector length smaller than 16\n"); | ||
133 | + } else { | ||
134 | + error_append_hint(errp, "Vector length larger than %d\n", | ||
135 | + 512 * 16); | ||
136 | + } | ||
137 | + return; | ||
138 | + } | ||
139 | + | ||
140 | + cpu->sve_default_vq = default_vq; | ||
73 | +} | 141 | +} |
74 | + | 142 | + |
75 | static void postload_update_cb(void *opaque, int running, RunState state) | 143 | +static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, |
144 | + const char *name, void *opaque, | ||
145 | + Error **errp) | ||
146 | +{ | ||
147 | + ARMCPU *cpu = ARM_CPU(obj); | ||
148 | + int32_t value = cpu->sve_default_vq * 16; | ||
149 | + | ||
150 | + visit_type_int32(v, name, &value, errp); | ||
151 | +} | ||
152 | +#endif | ||
153 | + | ||
154 | void aarch64_add_sve_properties(Object *obj) | ||
76 | { | 155 | { |
77 | PFlashCFI01 *pfl = opaque; | 156 | uint32_t vq; |
78 | diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c | 157 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) |
79 | index XXXXXXX..XXXXXXX 100644 | 158 | object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, |
80 | --- a/hw/i386/pc_sysfw.c | 159 | cpu_arm_set_sve_vq, NULL, NULL); |
81 | +++ b/hw/i386/pc_sysfw.c | ||
82 | @@ -XXX,XX +XXX,XX @@ void pc_system_firmware_init(PCMachineState *pcms, | ||
83 | { | ||
84 | PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); | ||
85 | int i; | ||
86 | - DriveInfo *pflash_drv; | ||
87 | BlockBackend *pflash_blk[ARRAY_SIZE(pcms->flash)]; | ||
88 | - Location loc; | ||
89 | |||
90 | if (!pcmc->pci_enabled) { | ||
91 | old_pc_system_rom_init(rom_memory, true); | ||
92 | @@ -XXX,XX +XXX,XX @@ void pc_system_firmware_init(PCMachineState *pcms, | ||
93 | |||
94 | /* Map legacy -drive if=pflash to machine properties */ | ||
95 | for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { | ||
96 | - pflash_drv = drive_get(IF_PFLASH, 0, i); | ||
97 | - if (pflash_drv) { | ||
98 | - loc_push_none(&loc); | ||
99 | - qemu_opts_loc_restore(pflash_drv->opts); | ||
100 | - if (pflash_cfi01_get_blk(pcms->flash[i])) { | ||
101 | - error_report("clashes with -machine"); | ||
102 | - exit(1); | ||
103 | - } | ||
104 | - qdev_prop_set_drive(DEVICE(pcms->flash[i]), "drive", | ||
105 | - blk_by_legacy_dinfo(pflash_drv), &error_fatal); | ||
106 | - loc_pop(&loc); | ||
107 | - } | ||
108 | + pflash_cfi01_legacy_drive(pcms->flash[i], | ||
109 | + drive_get(IF_PFLASH, 0, i)); | ||
110 | pflash_blk[i] = pflash_cfi01_get_blk(pcms->flash[i]); | ||
111 | } | 160 | } |
112 | 161 | + | |
162 | +#ifdef CONFIG_USER_ONLY | ||
163 | + /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
164 | + object_property_add(obj, "sve-default-vector-length", "int32", | ||
165 | + cpu_arm_get_sve_default_vec_len, | ||
166 | + cpu_arm_set_sve_default_vec_len, NULL, NULL); | ||
167 | +#endif | ||
168 | } | ||
169 | |||
170 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) | ||
113 | -- | 171 | -- |
114 | 2.20.1 | 172 | 2.20.1 |
115 | 173 | ||
116 | 174 | diff view generated by jsdifflib |
1 | From: Markus Armbruster <armbru@redhat.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The loop does two things: map legacy -drive to properties, and collect | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | all the backends for use after the loop. The next patch will factor | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | out the former for reuse in hw/arm/virt.c. To make that easier, | 5 | Message-id: 20210726150953.1218690-1-f4bug@amsat.org |
6 | rearrange the loop so it does the first thing first, and the second | ||
7 | thing second. | ||
8 | |||
9 | Signed-off-by: Markus Armbruster <armbru@redhat.com> | ||
10 | Reviewed-by: Laszlo Ersek <lersek@redhat.com> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20190416091348.26075-2-armbru@redhat.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 7 | --- |
15 | hw/i386/pc_sysfw.c | 24 +++++++++++------------- | 8 | hw/arm/nseries.c | 2 +- |
16 | 1 file changed, 11 insertions(+), 13 deletions(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
17 | 10 | ||
18 | diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c | 11 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
19 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/i386/pc_sysfw.c | 13 | --- a/hw/arm/nseries.c |
21 | +++ b/hw/i386/pc_sysfw.c | 14 | +++ b/hw/arm/nseries.c |
22 | @@ -XXX,XX +XXX,XX @@ void pc_system_firmware_init(PCMachineState *pcms, | 15 | @@ -XXX,XX +XXX,XX @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len) |
23 | 16 | default: | |
24 | /* Map legacy -drive if=pflash to machine properties */ | 17 | bad_cmd: |
25 | for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { | 18 | qemu_log_mask(LOG_GUEST_ERROR, |
26 | - pflash_blk[i] = pflash_cfi01_get_blk(pcms->flash[i]); | 19 | - "%s: unknown command %02x\n", __func__, s->cmd); |
27 | pflash_drv = drive_get(IF_PFLASH, 0, i); | 20 | + "%s: unknown command 0x%02x\n", __func__, s->cmd); |
28 | - if (!pflash_drv) { | 21 | break; |
29 | - continue; | ||
30 | + if (pflash_drv) { | ||
31 | + loc_push_none(&loc); | ||
32 | + qemu_opts_loc_restore(pflash_drv->opts); | ||
33 | + if (pflash_cfi01_get_blk(pcms->flash[i])) { | ||
34 | + error_report("clashes with -machine"); | ||
35 | + exit(1); | ||
36 | + } | ||
37 | + qdev_prop_set_drive(DEVICE(pcms->flash[i]), "drive", | ||
38 | + blk_by_legacy_dinfo(pflash_drv), &error_fatal); | ||
39 | + loc_pop(&loc); | ||
40 | } | ||
41 | - loc_push_none(&loc); | ||
42 | - qemu_opts_loc_restore(pflash_drv->opts); | ||
43 | - if (pflash_blk[i]) { | ||
44 | - error_report("clashes with -machine"); | ||
45 | - exit(1); | ||
46 | - } | ||
47 | - pflash_blk[i] = blk_by_legacy_dinfo(pflash_drv); | ||
48 | - qdev_prop_set_drive(DEVICE(pcms->flash[i]), | ||
49 | - "drive", pflash_blk[i], &error_fatal); | ||
50 | - loc_pop(&loc); | ||
51 | + pflash_blk[i] = pflash_cfi01_get_blk(pcms->flash[i]); | ||
52 | } | 22 | } |
53 | 23 | ||
54 | /* Reject gaps */ | ||
55 | -- | 24 | -- |
56 | 2.20.1 | 25 | 2.20.1 |
57 | 26 | ||
58 | 27 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The Raspberry Pi boards have a physical memory map which does | ||
2 | not allow for more than 1GB of RAM. Currently if the user tries | ||
3 | to ask for more then we fail in a confusing way: | ||
4 | 1 | ||
5 | $ qemu-system-aarch64 --machine raspi3 -m 8G | ||
6 | Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164: | ||
7 | qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t | ||
8 | Aborted (core dumped) | ||
9 | |||
10 | Catch this earlier and diagnose it with a more friendly message: | ||
11 | $ qemu-system-aarch64 --machine raspi3 -m 8G | ||
12 | qemu-system-aarch64: Requested ram size is too large for this machine: maximum is 1GB | ||
13 | |||
14 | Fixes: https://bugs.launchpad.net/qemu/+bug/1794187 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> | ||
19 | --- | ||
20 | hw/arm/raspi.c | 7 +++++++ | ||
21 | 1 file changed, 7 insertions(+) | ||
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 @@ | ||
28 | */ | ||
29 | |||
30 | #include "qemu/osdep.h" | ||
31 | +#include "qemu/units.h" | ||
32 | #include "qapi/error.h" | ||
33 | #include "qemu-common.h" | ||
34 | #include "cpu.h" | ||
35 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | ||
36 | BusState *bus; | ||
37 | DeviceState *carddev; | ||
38 | |||
39 | + if (machine->ram_size > 1 * GiB) { | ||
40 | + error_report("Requested ram size is too large for this machine: " | ||
41 | + "maximum is 1GB"); | ||
42 | + exit(1); | ||
43 | + } | ||
44 | + | ||
45 | object_initialize(&s->soc, sizeof(s->soc), | ||
46 | version == 3 ? TYPE_BCM2837 : TYPE_BCM2836); | ||
47 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), | ||
48 | -- | ||
49 | 2.20.1 | ||
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | We currently use Qemu's default of 128MB. As we know how much ram each | 3 | The macro used to calculate the maximum memory size of the MMIO region |
4 | machine ships with, make it easier on users by setting a default. | 4 | had a mistake, causing all GPIO models to create a mapping of 0x9D8. |
5 | The intent was to have it be 0x9D8 - 0x800. | ||
5 | 6 | ||
6 | It can still be overridden with -m on the command line. | 7 | This extra size doesn't matter on ast2400 and ast2500, which have a 4KB |
8 | region set aside for the GPIO controller. | ||
7 | 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") | ||
8 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 18 | Signed-off-by: Joel Stanley <joel@jms.id.au> |
9 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | 19 | Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
11 | Message-id: 20190503022958.1394-1-joel@jms.id.au | 21 | Message-id: 20210713065854.134634-2-joel@jms.id.au |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 22 | [PMM: fix autocorrect error in commit message] |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 24 | --- |
15 | include/hw/arm/aspeed.h | 1 + | 25 | hw/gpio/aspeed_gpio.c | 3 +-- |
16 | hw/arm/aspeed.c | 8 ++++++++ | 26 | 1 file changed, 1 insertion(+), 2 deletions(-) |
17 | 2 files changed, 9 insertions(+) | ||
18 | 27 | ||
19 | diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h | 28 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c |
20 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/hw/arm/aspeed.h | 30 | --- a/hw/gpio/aspeed_gpio.c |
22 | +++ b/include/hw/arm/aspeed.h | 31 | +++ b/hw/gpio/aspeed_gpio.c |
23 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedBoardConfig { | ||
24 | const char *spi_model; | ||
25 | uint32_t num_cs; | ||
26 | void (*i2c_init)(AspeedBoardState *bmc); | ||
27 | + uint32_t ram; | ||
28 | } AspeedBoardConfig; | ||
29 | |||
30 | #define TYPE_ASPEED_MACHINE MACHINE_TYPE_NAME("aspeed") | ||
31 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/arm/aspeed.c | ||
34 | +++ b/hw/arm/aspeed.c | ||
35 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ |
36 | #include "sysemu/block-backend.h" | 33 | #define GPIO_1_8V_MEM_SIZE 0x9D8 |
37 | #include "hw/loader.h" | 34 | #define GPIO_1_8V_REG_ARRAY_SIZE ((GPIO_1_8V_MEM_SIZE - \ |
38 | #include "qemu/error-report.h" | 35 | GPIO_1_8V_REG_OFFSET) >> 2) |
39 | +#include "qemu/units.h" | 36 | -#define GPIO_MAX_MEM_SIZE MAX(GPIO_3_6V_MEM_SIZE, GPIO_1_8V_MEM_SIZE) |
40 | 37 | ||
41 | static struct arm_boot_info aspeed_board_binfo = { | 38 | static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) |
42 | .board_id = -1, /* device-tree-only board */ | 39 | { |
43 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data) | 40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_realize(DeviceState *dev, Error **errp) |
44 | mc->no_floppy = 1; | 41 | } |
45 | mc->no_cdrom = 1; | 42 | |
46 | mc->no_parallel = 1; | 43 | memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s, |
47 | + if (board->ram) { | 44 | - TYPE_ASPEED_GPIO, GPIO_MAX_MEM_SIZE); |
48 | + mc->default_ram_size = board->ram; | 45 | + TYPE_ASPEED_GPIO, 0x800); |
49 | + } | 46 | |
50 | amc->board = board; | 47 | sysbus_init_mmio(sbd, &s->iomem); |
51 | } | 48 | } |
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | ||
54 | .spi_model = "mx25l25635e", | ||
55 | .num_cs = 1, | ||
56 | .i2c_init = palmetto_bmc_i2c_init, | ||
57 | + .ram = 256 * MiB, | ||
58 | }, { | ||
59 | .name = MACHINE_TYPE_NAME("ast2500-evb"), | ||
60 | .desc = "Aspeed AST2500 EVB (ARM1176)", | ||
61 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | ||
62 | .spi_model = "mx25l25635e", | ||
63 | .num_cs = 1, | ||
64 | .i2c_init = ast2500_evb_i2c_init, | ||
65 | + .ram = 512 * MiB, | ||
66 | }, { | ||
67 | .name = MACHINE_TYPE_NAME("romulus-bmc"), | ||
68 | .desc = "OpenPOWER Romulus BMC (ARM1176)", | ||
69 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | ||
70 | .spi_model = "mx66l1g45g", | ||
71 | .num_cs = 2, | ||
72 | .i2c_init = romulus_bmc_i2c_init, | ||
73 | + .ram = 512 * MiB, | ||
74 | }, { | ||
75 | .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | ||
76 | .desc = "OpenPOWER Witherspoon BMC (ARM1176)", | ||
77 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | ||
78 | .spi_model = "mx66l1g45g", | ||
79 | .num_cs = 2, | ||
80 | .i2c_init = witherspoon_bmc_i2c_init, | ||
81 | + .ram = 512 * MiB, | ||
82 | }, | ||
83 | }; | ||
84 | |||
85 | -- | 49 | -- |
86 | 2.20.1 | 50 | 2.20.1 |
87 | 51 | ||
88 | 52 | diff view generated by jsdifflib |