1 | More arm patches (mostly the SDHCI ones from Philippe) | 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 | ||
6 | The following changes since commit f521eeee3bd060b460c99e605472b7e03967db43: | 7 | The following changes since commit c08ccd1b53f488ac86c1f65cf7623dc91acc249a: |
7 | 8 | ||
8 | Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20180115' into staging (2018-01-15 13:17:47 +0000) | 9 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210726' into staging (2021-07-27 08:35:01 +0100) |
9 | 10 | ||
10 | are available in the git repository at: | 11 | are available in the Git repository at: |
11 | 12 | ||
12 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180116 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210727 |
13 | 14 | ||
14 | for you to fetch changes up to 60765b6ceeb4998a0d4220b3a53f1f185061da77: | 15 | for you to fetch changes up to e229a179a503f2aee43a76888cf12fbdfe8a3749: |
15 | 16 | ||
16 | sdhci: add a 'dma' property to the sysbus devices (2018-01-16 13:28:21 +0000) | 17 | hw: aspeed_gpio: Fix memory size (2021-07-27 11:00:00 +0100) |
17 | 18 | ||
18 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
19 | target-arm queue: | 20 | target-arm queue: |
20 | * SDHCI: cleanups and minor bug fixes | 21 | * hw/arm/smmuv3: Check 31st bit to see if CD is valid |
21 | * target/arm: minor refactor preparatory to fp16 support | 22 | * qemu-options.hx: Fix formatting of -machine memory-backend option |
22 | * omap_ssd, ssi-sd, pl181, milkymist-memcard: reset the SD | 23 | * hw: aspeed_gpio: Fix memory size |
23 | card on controller reset (fixes migration failures) | 24 | * hw/arm/nseries: Display hexadecimal value with '0x' prefix |
24 | * target/arm: Handle page table walk load failures correctly | 25 | * Add sve-default-vector-length cpu property |
25 | * hw/arm/virt: Add virt-2.12 machine type | 26 | * docs: Update path that mentions deprecated.rst |
26 | * get_phys_addr_pmsav7: Support AP=0b111 for v7M | 27 | * hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS |
27 | * hw/intc/armv7m: Support byte and halfword accesses to CFSR | 28 | * hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING |
29 | * hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | ||
30 | * target/arm: Report M-profile alignment faults correctly to the guest | ||
31 | * target/arm: Add missing 'return's after calling v7m_exception_taken() | ||
32 | * target/arm: Enforce that M-profile SP low 2 bits are always zero | ||
28 | 33 | ||
29 | ---------------------------------------------------------------- | 34 | ---------------------------------------------------------------- |
30 | Andrey Smirnov (1): | 35 | Joe Komlodi (1): |
31 | sdhci: Implement write method of ACMD12ERRSTS register | 36 | hw/arm/smmuv3: Check 31st bit to see if CD is valid |
32 | 37 | ||
33 | Peter Maydell (8): | 38 | Joel Stanley (1): |
34 | hw/intc/armv7m: Support byte and halfword accesses to CFSR | 39 | hw: aspeed_gpio: Fix memory size |
35 | get_phys_addr_pmsav7: Support AP=0b111 for v7M | ||
36 | hw/arm/virt: Add virt-2.12 machine type | ||
37 | target/arm: Handle page table walk load failures correctly | ||
38 | hw/sd/pl181: Reset SD card on controller reset | ||
39 | hw/sd/milkymist-memcard: Reset SD card on controller reset | ||
40 | hw/sd/ssi-sd: Reset SD card on controller reset | ||
41 | hw/sd/omap_mmc: Reset SD card on controller reset | ||
42 | 40 | ||
43 | Philippe Mathieu-Daudé (13): | 41 | Mao Zhongyi (1): |
44 | sdhci: clean up includes | 42 | docs: Update path that mentions deprecated.rst |
45 | sdhci: remove dead code | ||
46 | sdhci: use DEFINE_SDHCI_COMMON_PROPERTIES() for common sysbus/pci properties | ||
47 | sdhci: refactor common sysbus/pci class_init() into sdhci_common_class_init() | ||
48 | sdhci: refactor common sysbus/pci realize() into sdhci_common_realize() | ||
49 | sdhci: refactor common sysbus/pci unrealize() into sdhci_common_unrealize() | ||
50 | sdhci: use qemu_log_mask(UNIMP) instead of fprintf() | ||
51 | sdhci: convert the DPRINT() calls into trace events | ||
52 | sdhci: move MASK_TRNMOD with other SDHC_TRN* defines in "sd-internal.h" | ||
53 | sdhci: rename the SDHC_CAPAB register | ||
54 | sdhci: fix CAPAB/MAXCURR registers, both are 64bit and read-only | ||
55 | sdhci: fix the PCI device, using the PCI address space for DMA | ||
56 | sdhci: add a 'dma' property to the sysbus devices | ||
57 | 43 | ||
58 | Richard Henderson (2): | 44 | Peter Maydell (7): |
59 | target/arm: Split out vfp_expand_imm | 45 | qemu-options.hx: Fix formatting of -machine memory-backend option |
60 | target/arm: Add fp16 support to vfp_expand_imm | 46 | target/arm: Enforce that M-profile SP low 2 bits are always zero |
47 | target/arm: Add missing 'return's after calling v7m_exception_taken() | ||
48 | target/arm: Report M-profile alignment faults correctly to the guest | ||
49 | hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | ||
50 | hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING | ||
51 | hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS | ||
61 | 52 | ||
62 | hw/sd/sdhci-internal.h | 7 +- | 53 | Philippe Mathieu-Daudé (1): |
63 | include/hw/sd/sdhci.h | 19 +++- | 54 | hw/arm/nseries: Display hexadecimal value with '0x' prefix |
64 | target/arm/internals.h | 10 ++ | ||
65 | hw/arm/virt.c | 19 +++- | ||
66 | hw/intc/armv7m_nvic.c | 38 ++++--- | ||
67 | hw/sd/milkymist-memcard.c | 4 + | ||
68 | hw/sd/omap_mmc.c | 14 ++- | ||
69 | hw/sd/pl181.c | 4 + | ||
70 | hw/sd/sdhci.c | 266 +++++++++++++++++++++++++++------------------ | ||
71 | hw/sd/ssi-sd.c | 25 ++++- | ||
72 | target/arm/helper.c | 53 ++++++++- | ||
73 | target/arm/op_helper.c | 7 +- | ||
74 | target/arm/translate-a64.c | 49 ++++++--- | ||
75 | hw/sd/trace-events | 14 +++ | ||
76 | 14 files changed, 362 insertions(+), 167 deletions(-) | ||
77 | 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: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Joe Komlodi <joe.komlodi@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Add a 'dma' property allowing machine creation to provide the address-space | 3 | The bit to see if a CD is valid is the last bit of the first word of the CD. |
4 | SDHCI DMA operates on. | ||
5 | 4 | ||
6 | [based on a patch from Alistair Francis <alistair.francis@xilinx.com> | 5 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> |
7 | from qemu/xilinx tag xilinx-v2016.1] | 6 | Message-id: 1626728232-134665-2-git-send-email-joe.komlodi@xilinx.com |
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20180115182436.2066-15-f4bug@amsat.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | include/hw/sd/sdhci.h | 1 + | 10 | hw/arm/smmuv3-internal.h | 2 +- |
13 | hw/sd/sdhci.c | 18 +++++++++++++++++- | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 2 files changed, 18 insertions(+), 1 deletion(-) | ||
15 | 12 | ||
16 | diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h | 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/include/hw/sd/sdhci.h | 15 | --- a/hw/arm/smmuv3-internal.h |
19 | +++ b/include/hw/sd/sdhci.h | 16 | +++ b/hw/arm/smmuv3-internal.h |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState { | 17 | @@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste) |
21 | SDBus sdbus; | 18 | |
22 | MemoryRegion iomem; | 19 | /* CD fields */ |
23 | AddressSpace *dma_as; | 20 | |
24 | + MemoryRegion *dma_mr; | 21 | -#define CD_VALID(x) extract32((x)->word[0], 30, 1) |
25 | 22 | +#define CD_VALID(x) extract32((x)->word[0], 31, 1) | |
26 | QEMUTimer *insert_timer; /* timer for 'changing' sd card. */ | 23 | #define CD_ASID(x) extract32((x)->word[1], 16, 16) |
27 | QEMUTimer *transfer_timer; | 24 | #define CD_TTB(x, sel) \ |
28 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 25 | ({ \ |
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/sd/sdhci.c | ||
31 | +++ b/hw/sd/sdhci.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static Property sdhci_sysbus_properties[] = { | ||
33 | DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState), | ||
34 | DEFINE_PROP_BOOL("pending-insert-quirk", SDHCIState, pending_insert_quirk, | ||
35 | false), | ||
36 | + DEFINE_PROP_LINK("dma", SDHCIState, | ||
37 | + dma_mr, TYPE_MEMORY_REGION, MemoryRegion *), | ||
38 | DEFINE_PROP_END_OF_LIST(), | ||
39 | }; | ||
40 | |||
41 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_init(Object *obj) | ||
42 | static void sdhci_sysbus_finalize(Object *obj) | ||
43 | { | ||
44 | SDHCIState *s = SYSBUS_SDHCI(obj); | ||
45 | + | ||
46 | + if (s->dma_mr) { | ||
47 | + object_unparent(OBJECT(s->dma_mr)); | ||
48 | + } | ||
49 | + | ||
50 | sdhci_uninitfn(s); | ||
51 | } | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) | ||
54 | return; | ||
55 | } | ||
56 | |||
57 | - s->dma_as = &address_space_memory; | ||
58 | + if (s->dma_mr) { | ||
59 | + address_space_init(s->dma_as, s->dma_mr, "sdhci-dma"); | ||
60 | + } else { | ||
61 | + /* use system_memory() if property "dma" not set */ | ||
62 | + s->dma_as = &address_space_memory; | ||
63 | + } | ||
64 | |||
65 | sysbus_init_irq(sbd, &s->irq); | ||
66 | sysbus_init_mmio(sbd, &s->iomem); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_unrealize(DeviceState *dev, Error **errp) | ||
68 | SDHCIState *s = SYSBUS_SDHCI(dev); | ||
69 | |||
70 | sdhci_common_unrealize(s, &error_abort); | ||
71 | + | ||
72 | + if (s->dma_mr) { | ||
73 | + address_space_destroy(s->dma_as); | ||
74 | + } | ||
75 | } | ||
76 | |||
77 | static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) | ||
78 | -- | 26 | -- |
79 | 2.7.4 | 27 | 2.20.1 |
80 | 28 | ||
81 | 29 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.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 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | 11 | Fix the formatting. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Message-id: 20180115182436.2066-13-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Message-id: 20210719105257.3599-1-peter.maydell@linaro.org | ||
9 | --- | 16 | --- |
10 | hw/sd/sdhci.c | 3 +++ | 17 | qemu-options.hx | 30 +++++++++++++++++------------- |
11 | 1 file changed, 3 insertions(+) | 18 | 1 file changed, 17 insertions(+), 13 deletions(-) |
12 | 19 | ||
13 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 20 | diff --git a/qemu-options.hx b/qemu-options.hx |
14 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sdhci.c | 22 | --- a/qemu-options.hx |
16 | +++ b/hw/sd/sdhci.c | 23 | +++ b/qemu-options.hx |
17 | @@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) | 24 | @@ -XXX,XX +XXX,XX @@ SRST |
18 | } | 25 | Enables or disables ACPI Heterogeneous Memory Attribute Table |
19 | sdhci_update_irq(s); | 26 | (HMAT) support. The default is off. |
20 | break; | 27 | |
21 | + case SDHC_ACMD12ERRSTS: | 28 | - ``memory-backend='id'`` |
22 | + MASKED_WRITE(s->acmd12errsts, mask, value); | 29 | + ``memory-backend='id'`` |
23 | + break; | 30 | An alternative to legacy ``-mem-path`` and ``mem-prealloc`` options. |
24 | 31 | Allows to use a memory backend as main RAM. | |
25 | case SDHC_CAPAB: | 32 | |
26 | case SDHC_CAPAB + 4: | 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 | ||
38 | + | ||
39 | + -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on | ||
40 | + -machine memory-backend=pc.ram | ||
41 | + -m 512M | ||
42 | |||
43 | Migration compatibility note: | ||
44 | - a) as backend id one shall use value of 'default-ram-id', advertised by | ||
45 | - machine type (available via ``query-machines`` QMP command), if migration | ||
46 | - to/from old QEMU (<5.0) is expected. | ||
47 | - b) for machine types 4.0 and older, user shall | ||
48 | - use ``x-use-canonical-path-for-ramblock-id=off`` backend option | ||
49 | - if migration to/from old QEMU (<5.0) is expected. | ||
50 | + | ||
51 | + * as backend id one shall use value of 'default-ram-id', advertised by | ||
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 | ||
27 | -- | 70 | -- |
28 | 2.7.4 | 71 | 2.20.1 |
29 | 72 | ||
30 | 73 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | For M-profile, unlike A-profile, the low 2 bits of SP are defined to be |
---|---|---|---|
2 | RES0H, which is to say that they must be hardwired to zero so that | ||
3 | guest attempts to write non-zero values to them are ignored. | ||
2 | 4 | ||
3 | zero-initialize ADMADescr 'dscr' in sdhci_do_adma() to avoid: | 5 | Implement this behaviour by masking out the low bits: |
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 | ||
4 | 9 | ||
5 | hw/sd/sdhci.c: In function ‘sdhci_do_adma’: | 10 | Note that all the direct uses of cpu_R[] in translate.c are in places |
6 | hw/sd/sdhci.c:714:29: error: ‘dscr.addr’ may be used uninitialized in this function [-Werror=maybe-uninitialized] | 11 | where the register is definitely not r13 (usually because that has |
7 | trace_sdhci_adma("link", s->admasysaddr); | 12 | been checked for as an UNDEFINED or UNPREDICTABLE case and handled as |
8 | ^ | 13 | UNDEF). |
9 | 14 | ||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 15 | All the other writes to regs[13] in C code are either: |
11 | Acked-by: Alistair Francis <alistair.francis@xilinx.com> | 16 | * A-profile only code |
12 | Message-id: 20180115182436.2066-9-f4bug@amsat.org | 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 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20210723162146.5167-2-peter.maydell@linaro.org | ||
14 | --- | 25 | --- |
15 | hw/sd/sdhci.c | 89 ++++++++++++++++++------------------------------------ | 26 | target/arm/gdbstub.c | 4 ++++ |
16 | hw/sd/trace-events | 14 +++++++++ | 27 | target/arm/m_helper.c | 14 ++++++++------ |
17 | 2 files changed, 44 insertions(+), 59 deletions(-) | 28 | target/arm/translate.c | 3 +++ |
29 | 3 files changed, 15 insertions(+), 6 deletions(-) | ||
18 | 30 | ||
19 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 31 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
20 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/sd/sdhci.c | 33 | --- a/target/arm/gdbstub.c |
22 | +++ b/hw/sd/sdhci.c | 34 | +++ b/target/arm/gdbstub.c |
23 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) |
24 | #include "sdhci-internal.h" | 36 | |
25 | #include "qapi/error.h" | 37 | if (n < 16) { |
26 | #include "qemu/log.h" | 38 | /* Core integer register. */ |
27 | - | 39 | + if (n == 13 && arm_feature(env, ARM_FEATURE_M)) { |
28 | -/* host controller debug messages */ | 40 | + /* M profile SP low bits are always 0 */ |
29 | -#ifndef SDHC_DEBUG | 41 | + tmp &= ~3; |
30 | -#define SDHC_DEBUG 0 | 42 | + } |
31 | -#endif | 43 | env->regs[n] = tmp; |
32 | - | 44 | return 4; |
33 | -#define DPRINT_L1(fmt, args...) \ | 45 | } |
34 | - do { \ | 46 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
35 | - if (SDHC_DEBUG) { \ | 47 | index XXXXXXX..XXXXXXX 100644 |
36 | - fprintf(stderr, "QEMU SDHC: " fmt, ## args); \ | 48 | --- a/target/arm/m_helper.c |
37 | - } \ | 49 | +++ b/target/arm/m_helper.c |
38 | - } while (0) | 50 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) |
39 | -#define DPRINT_L2(fmt, args...) \ | 51 | if (!env->v7m.secure) { |
40 | - do { \ | 52 | return; |
41 | - if (SDHC_DEBUG > 1) { \ | 53 | } |
42 | - fprintf(stderr, "QEMU SDHC: " fmt, ## args); \ | 54 | - env->v7m.other_ss_msp = val; |
43 | - } \ | 55 | + env->v7m.other_ss_msp = val & ~3; |
44 | - } while (0) | 56 | return; |
45 | -#define ERRPRINT(fmt, args...) \ | 57 | case 0x89: /* PSP_NS */ |
46 | - do { \ | 58 | if (!env->v7m.secure) { |
47 | - if (SDHC_DEBUG) { \ | 59 | return; |
48 | - fprintf(stderr, "QEMU SDHC ERROR: " fmt, ## args); \ | 60 | } |
49 | - } \ | 61 | - env->v7m.other_ss_psp = val; |
50 | - } while (0) | 62 | + env->v7m.other_ss_psp = val & ~3; |
51 | +#include "trace.h" | 63 | return; |
52 | 64 | case 0x8a: /* MSPLIM_NS */ | |
53 | #define TYPE_SDHCI_BUS "sdhci-bus" | 65 | if (!env->v7m.secure) { |
54 | #define SDHCI_BUS(obj) OBJECT_CHECK(SDBus, (obj), TYPE_SDHCI_BUS) | 66 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) |
55 | @@ -XXX,XX +XXX,XX @@ static void sdhci_raise_insertion_irq(void *opaque) | 67 | |
56 | static void sdhci_set_inserted(DeviceState *dev, bool level) | 68 | limit = is_psp ? env->v7m.psplim[false] : env->v7m.msplim[false]; |
57 | { | 69 | |
58 | SDHCIState *s = (SDHCIState *)dev; | 70 | + val &= ~0x3; |
59 | - DPRINT_L1("Card state changed: %s!\n", level ? "insert" : "eject"); | ||
60 | |||
61 | + trace_sdhci_set_inserted(level ? "insert" : "eject"); | ||
62 | if ((s->norintsts & SDHC_NIS_REMOVE) && level) { | ||
63 | /* Give target some time to notice card ejection */ | ||
64 | timer_mod(s->insert_timer, | ||
65 | @@ -XXX,XX +XXX,XX @@ static void sdhci_send_command(SDHCIState *s) | ||
66 | s->acmd12errsts = 0; | ||
67 | request.cmd = s->cmdreg >> 8; | ||
68 | request.arg = s->argument; | ||
69 | - DPRINT_L1("sending CMD%u ARG[0x%08x]\n", request.cmd, request.arg); | ||
70 | + | 71 | + |
71 | + trace_sdhci_send_command(request.cmd, request.arg); | 72 | if (val < limit) { |
72 | rlen = sdbus_do_command(&s->sdbus, &request, response); | 73 | raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); |
73 | 74 | } | |
74 | if (s->cmdreg & SDHC_CMD_RESPONSE) { | 75 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) |
75 | @@ -XXX,XX +XXX,XX @@ static void sdhci_send_command(SDHCIState *s) | 76 | break; |
76 | s->rspreg[0] = (response[0] << 24) | (response[1] << 16) | | 77 | case 8: /* MSP */ |
77 | (response[2] << 8) | response[3]; | 78 | if (v7m_using_psp(env)) { |
78 | s->rspreg[1] = s->rspreg[2] = s->rspreg[3] = 0; | 79 | - env->v7m.other_sp = val; |
79 | - DPRINT_L1("Response: RSPREG[31..0]=0x%08x\n", s->rspreg[0]); | 80 | + env->v7m.other_sp = val & ~3; |
80 | + trace_sdhci_response4(s->rspreg[0]); | ||
81 | } else if (rlen == 16) { | ||
82 | s->rspreg[0] = (response[11] << 24) | (response[12] << 16) | | ||
83 | (response[13] << 8) | response[14]; | ||
84 | @@ -XXX,XX +XXX,XX @@ static void sdhci_send_command(SDHCIState *s) | ||
85 | (response[5] << 8) | response[6]; | ||
86 | s->rspreg[3] = (response[0] << 16) | (response[1] << 8) | | ||
87 | response[2]; | ||
88 | - DPRINT_L1("Response received:\n RSPREG[127..96]=0x%08x, RSPREG[95.." | ||
89 | - "64]=0x%08x,\n RSPREG[63..32]=0x%08x, RSPREG[31..0]=0x%08x\n", | ||
90 | - s->rspreg[3], s->rspreg[2], s->rspreg[1], s->rspreg[0]); | ||
91 | + trace_sdhci_response16(s->rspreg[3], s->rspreg[2], | ||
92 | + s->rspreg[1], s->rspreg[0]); | ||
93 | } else { | 81 | } else { |
94 | - ERRPRINT("Timeout waiting for command response\n"); | 82 | - env->regs[13] = val; |
95 | + trace_sdhci_error("timeout waiting for command response"); | 83 | + env->regs[13] = val & ~3; |
96 | if (s->errintstsen & SDHC_EISEN_CMDTIMEOUT) { | ||
97 | s->errintsts |= SDHC_EIS_CMDTIMEOUT; | ||
98 | s->norintsts |= SDHC_NIS_ERR; | ||
99 | @@ -XXX,XX +XXX,XX @@ static void sdhci_end_transfer(SDHCIState *s) | ||
100 | |||
101 | request.cmd = 0x0C; | ||
102 | request.arg = 0; | ||
103 | - DPRINT_L1("Automatically issue CMD%d %08x\n", request.cmd, request.arg); | ||
104 | + trace_sdhci_end_transfer(request.cmd, request.arg); | ||
105 | sdbus_do_command(&s->sdbus, &request, response); | ||
106 | /* Auto CMD12 response goes to the upper Response register */ | ||
107 | s->rspreg[3] = (response[0] << 24) | (response[1] << 16) | | ||
108 | @@ -XXX,XX +XXX,XX @@ static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size) | ||
109 | |||
110 | /* first check that a valid data exists in host controller input buffer */ | ||
111 | if ((s->prnsts & SDHC_DATA_AVAILABLE) == 0) { | ||
112 | - ERRPRINT("Trying to read from empty buffer\n"); | ||
113 | + trace_sdhci_error("read from empty buffer"); | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | @@ -XXX,XX +XXX,XX @@ static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size) | ||
118 | s->data_count++; | ||
119 | /* check if we've read all valid data (blksize bytes) from buffer */ | ||
120 | if ((s->data_count) >= (s->blksize & 0x0fff)) { | ||
121 | - DPRINT_L2("All %u bytes of data have been read from input buffer\n", | ||
122 | - s->data_count); | ||
123 | + trace_sdhci_read_dataport(s->data_count); | ||
124 | s->prnsts &= ~SDHC_DATA_AVAILABLE; /* no more data in a buffer */ | ||
125 | s->data_count = 0; /* next buff read must start at position [0] */ | ||
126 | |||
127 | @@ -XXX,XX +XXX,XX @@ static void sdhci_write_dataport(SDHCIState *s, uint32_t value, unsigned size) | ||
128 | |||
129 | /* Check that there is free space left in a buffer */ | ||
130 | if (!(s->prnsts & SDHC_SPACE_AVAILABLE)) { | ||
131 | - ERRPRINT("Can't write to data buffer: buffer full\n"); | ||
132 | + trace_sdhci_error("Can't write to data buffer: buffer full"); | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | @@ -XXX,XX +XXX,XX @@ static void sdhci_write_dataport(SDHCIState *s, uint32_t value, unsigned size) | ||
137 | s->data_count++; | ||
138 | value >>= 8; | ||
139 | if (s->data_count >= (s->blksize & 0x0fff)) { | ||
140 | - DPRINT_L2("write buffer filled with %u bytes of data\n", | ||
141 | - s->data_count); | ||
142 | + trace_sdhci_write_dataport(s->data_count); | ||
143 | s->data_count = 0; | ||
144 | s->prnsts &= ~SDHC_SPACE_AVAILABLE; | ||
145 | if (s->prnsts & SDHC_DOING_WRITE) { | ||
146 | @@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s) | ||
147 | { | ||
148 | unsigned int n, begin, length; | ||
149 | const uint16_t block_size = s->blksize & 0x0fff; | ||
150 | - ADMADescr dscr; | ||
151 | + ADMADescr dscr = {}; | ||
152 | int i; | ||
153 | |||
154 | for (i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { | ||
155 | s->admaerr &= ~SDHC_ADMAERR_LENGTH_MISMATCH; | ||
156 | |||
157 | get_adma_description(s, &dscr); | ||
158 | - DPRINT_L2("ADMA loop: addr=" TARGET_FMT_plx ", len=%d, attr=%x\n", | ||
159 | - dscr.addr, dscr.length, dscr.attr); | ||
160 | + trace_sdhci_adma_loop(dscr.addr, dscr.length, dscr.attr); | ||
161 | |||
162 | if ((dscr.attr & SDHC_ADMA_ATTR_VALID) == 0) { | ||
163 | /* Indicate that error occurred in ST_FDS state */ | ||
164 | @@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s) | ||
165 | break; | ||
166 | case SDHC_ADMA_ATTR_ACT_LINK: /* link to next descriptor table */ | ||
167 | s->admasysaddr = dscr.addr; | ||
168 | - DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n", | ||
169 | - s->admasysaddr); | ||
170 | + trace_sdhci_adma("link", s->admasysaddr); | ||
171 | break; | ||
172 | default: | ||
173 | s->admasysaddr += dscr.incr; | ||
174 | @@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s) | ||
175 | } | ||
176 | |||
177 | if (dscr.attr & SDHC_ADMA_ATTR_INT) { | ||
178 | - DPRINT_L1("ADMA interrupt: admasysaddr=0x%" PRIx64 "\n", | ||
179 | - s->admasysaddr); | ||
180 | + trace_sdhci_adma("interrupt", s->admasysaddr); | ||
181 | if (s->norintstsen & SDHC_NISEN_DMA) { | ||
182 | s->norintsts |= SDHC_NIS_DMA; | ||
183 | } | ||
184 | @@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s) | ||
185 | /* ADMA transfer terminates if blkcnt == 0 or by END attribute */ | ||
186 | if (((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && | ||
187 | (s->blkcnt == 0)) || (dscr.attr & SDHC_ADMA_ATTR_END)) { | ||
188 | - DPRINT_L2("ADMA transfer completed\n"); | ||
189 | + trace_sdhci_adma_transfer_completed(); | ||
190 | if (length || ((dscr.attr & SDHC_ADMA_ATTR_END) && | ||
191 | (s->trnmod & SDHC_TRNS_BLK_CNT_EN) && | ||
192 | s->blkcnt != 0)) { | ||
193 | - ERRPRINT("SD/MMC host ADMA length mismatch\n"); | ||
194 | + trace_sdhci_error("SD/MMC host ADMA length mismatch"); | ||
195 | s->admaerr |= SDHC_ADMAERR_LENGTH_MISMATCH | | ||
196 | SDHC_ADMAERR_STATE_ST_TFR; | ||
197 | if (s->errintstsen & SDHC_EISEN_ADMAERR) { | ||
198 | - ERRPRINT("Set ADMA error flag\n"); | ||
199 | + trace_sdhci_error("Set ADMA error flag"); | ||
200 | s->errintsts |= SDHC_EIS_ADMAERR; | ||
201 | s->norintsts |= SDHC_NIS_ERR; | ||
202 | } | ||
203 | @@ -XXX,XX +XXX,XX @@ static void sdhci_data_transfer(void *opaque) | ||
204 | break; | ||
205 | case SDHC_CTRL_ADMA1_32: | ||
206 | if (!(s->capareg & SDHC_CAN_DO_ADMA1)) { | ||
207 | - ERRPRINT("ADMA1 not supported\n"); | ||
208 | + trace_sdhci_error("ADMA1 not supported"); | ||
209 | break; | ||
210 | } | ||
211 | |||
212 | @@ -XXX,XX +XXX,XX @@ static void sdhci_data_transfer(void *opaque) | ||
213 | break; | ||
214 | case SDHC_CTRL_ADMA2_32: | ||
215 | if (!(s->capareg & SDHC_CAN_DO_ADMA2)) { | ||
216 | - ERRPRINT("ADMA2 not supported\n"); | ||
217 | + trace_sdhci_error("ADMA2 not supported"); | ||
218 | break; | ||
219 | } | ||
220 | |||
221 | @@ -XXX,XX +XXX,XX @@ static void sdhci_data_transfer(void *opaque) | ||
222 | case SDHC_CTRL_ADMA2_64: | ||
223 | if (!(s->capareg & SDHC_CAN_DO_ADMA2) || | ||
224 | !(s->capareg & SDHC_64_BIT_BUS_SUPPORT)) { | ||
225 | - ERRPRINT("64 bit ADMA not supported\n"); | ||
226 | + trace_sdhci_error("64 bit ADMA not supported"); | ||
227 | break; | ||
228 | } | ||
229 | |||
230 | sdhci_do_adma(s); | ||
231 | break; | ||
232 | default: | ||
233 | - ERRPRINT("Unsupported DMA type\n"); | ||
234 | + trace_sdhci_error("Unsupported DMA type"); | ||
235 | break; | ||
236 | } | ||
237 | } else { | ||
238 | @@ -XXX,XX +XXX,XX @@ static inline bool | ||
239 | sdhci_buff_access_is_sequential(SDHCIState *s, unsigned byte_num) | ||
240 | { | ||
241 | if ((s->data_count & 0x3) != byte_num) { | ||
242 | - ERRPRINT("Non-sequential access to Buffer Data Port register" | ||
243 | - "is prohibited\n"); | ||
244 | + trace_sdhci_error("Non-sequential access to Buffer Data Port register" | ||
245 | + "is prohibited\n"); | ||
246 | return false; | ||
247 | } | ||
248 | return true; | ||
249 | @@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size) | ||
250 | case SDHC_BDATA: | ||
251 | if (sdhci_buff_access_is_sequential(s, offset - SDHC_BDATA)) { | ||
252 | ret = sdhci_read_dataport(s, size); | ||
253 | - DPRINT_L2("read %ub: addr[0x%04x] -> %u(0x%x)\n", size, (int)offset, | ||
254 | - ret, ret); | ||
255 | + trace_sdhci_access("rd", size << 3, offset, "->", ret, ret); | ||
256 | return ret; | ||
257 | } | 84 | } |
258 | break; | 85 | break; |
259 | @@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size) | 86 | case 9: /* PSP */ |
260 | 87 | if (v7m_using_psp(env)) { | |
261 | ret >>= (offset & 0x3) * 8; | 88 | - env->regs[13] = val; |
262 | ret &= (1ULL << (size * 8)) - 1; | 89 | + env->regs[13] = val & ~3; |
263 | - DPRINT_L2("read %ub: addr[0x%04x] -> %u(0x%x)\n", size, (int)offset, ret, ret); | 90 | } else { |
264 | + trace_sdhci_access("rd", size << 3, offset, "->", ret, ret); | 91 | - env->v7m.other_sp = val; |
265 | return ret; | 92 | + env->v7m.other_sp = val & ~3; |
266 | } | 93 | } |
267 | |||
268 | @@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) | ||
269 | "not implemented\n", size, offset, value >> shift); | ||
270 | break; | 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); | ||
271 | } | 107 | } |
272 | - DPRINT_L2("write %ub: addr[0x%04x] <- %u(0x%x)\n", | 108 | tcg_gen_mov_i32(cpu_R[reg], var); |
273 | - size, (int)offset, value >> shift, value >> shift); | 109 | tcg_temp_free_i32(var); |
274 | + trace_sdhci_access("wr", size << 3, offset, "<-", | ||
275 | + value >> shift, value >> shift); | ||
276 | } | ||
277 | |||
278 | static const MemoryRegionOps sdhci_mmio_ops = { | ||
279 | diff --git a/hw/sd/trace-events b/hw/sd/trace-events | ||
280 | index XXXXXXX..XXXXXXX 100644 | ||
281 | --- a/hw/sd/trace-events | ||
282 | +++ b/hw/sd/trace-events | ||
283 | @@ -XXX,XX +XXX,XX @@ | ||
284 | # See docs/devel/tracing.txt for syntax documentation. | ||
285 | |||
286 | +# hw/sd/sdhci.c | ||
287 | +sdhci_set_inserted(const char *level) "card state changed: %s" | ||
288 | +sdhci_send_command(uint8_t cmd, uint32_t arg) "CMD%02u ARG[0x%08x]" | ||
289 | +sdhci_error(const char *msg) "%s" | ||
290 | +sdhci_response4(uint32_t r0) "RSPREG[31..0]=0x%08x" | ||
291 | +sdhci_response16(uint32_t r3, uint32_t r2, uint32_t r1, uint32_t r0) "RSPREG[127..96]=0x%08x, RSPREG[95..64]=0x%08x, RSPREG[63..32]=0x%08x, RSPREG[31..0]=0x%08x" | ||
292 | +sdhci_end_transfer(uint8_t cmd, uint32_t arg) "Automatically issue CMD%02u 0x%08x" | ||
293 | +sdhci_adma(const char *desc, uint32_t sysad) "%s: admasysaddr=0x%" PRIx32 | ||
294 | +sdhci_adma_loop(uint64_t addr, uint16_t length, uint8_t attr) "addr=0x%08" PRIx64 ", len=%d, attr=0x%x" | ||
295 | +sdhci_adma_transfer_completed(void) "" | ||
296 | +sdhci_access(const char *access, unsigned int size, uint64_t offset, const char *dir, uint64_t val, uint64_t val2) "%s%u: addr[0x%04" PRIx64 "] %s 0x%08" PRIx64 " (%" PRIu64 ")" | ||
297 | +sdhci_read_dataport(uint16_t data_count) "all %u bytes of data have been read from input buffer" | ||
298 | +sdhci_write_dataport(uint16_t data_count) "write buffer filled with %u bytes of data" | ||
299 | + | ||
300 | # hw/sd/milkymist-memcard.c | ||
301 | milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
302 | milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
303 | -- | 110 | -- |
304 | 2.7.4 | 111 | 2.20.1 |
305 | 112 | ||
306 | 113 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | In do_v7m_exception_exit(), we perform various checks as part of |
---|---|---|---|
2 | performing the exception return. If one of these checks fails, the | ||
3 | architecture requires that we take an appropriate exception on the | ||
4 | existing stackframe. We implement this by calling | ||
5 | v7m_exception_taken() to set up to take the new exception, and then | ||
6 | immediately returning from do_v7m_exception_exit() without proceeding | ||
7 | any further with the unstack-and-exception-return process. | ||
2 | 8 | ||
3 | running qtests: | 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 | $ make check-qtest-arm | 15 | Add the missing return statements. |
6 | GTESTER check-qtest-arm | ||
7 | SDHC rd_4b @0x44 not implemented | ||
8 | SDHC wr_4b @0x40 <- 0x89abcdef not implemented | ||
9 | SDHC wr_4b @0x44 <- 0x01234567 not implemented | ||
10 | 16 | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
13 | Message-id: 20180115182436.2066-12-f4bug@amsat.org | ||
14 | 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 | ||
15 | --- | 20 | --- |
16 | include/hw/sd/sdhci.h | 4 ++-- | 21 | target/arm/m_helper.c | 2 ++ |
17 | hw/sd/sdhci.c | 23 +++++++++++++++++++---- | 22 | 1 file changed, 2 insertions(+) |
18 | 2 files changed, 21 insertions(+), 6 deletions(-) | ||
19 | 23 | ||
20 | diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h | 24 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/sd/sdhci.h | 26 | --- a/target/arm/m_helper.c |
23 | +++ b/include/hw/sd/sdhci.h | 27 | +++ b/target/arm/m_helper.c |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState { | 28 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
25 | uint64_t admasysaddr; /* ADMA System Address Register */ | 29 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
26 | 30 | "stackframe: NSACR prevents clearing FPU registers\n"); | |
27 | /* Read-only registers */ | 31 | v7m_exception_taken(cpu, excret, true, false); |
28 | - uint32_t capareg; /* Capabilities Register */ | 32 | + return; |
29 | - uint32_t maxcurr; /* Maximum Current Capabilities Register */ | 33 | } else if (!cpacr_pass) { |
30 | + uint64_t capareg; /* Capabilities Register */ | 34 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, |
31 | + uint64_t maxcurr; /* Maximum Current Capabilities Register */ | 35 | exc_secure); |
32 | 36 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | |
33 | uint8_t *fifo_buffer; /* SD host i/o FIFO buffer */ | 37 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
34 | uint32_t buf_maxsz; | 38 | "stackframe: CPACR prevents clearing FPU registers\n"); |
35 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 39 | v7m_exception_taken(cpu, excret, true, false); |
36 | index XXXXXXX..XXXXXXX 100644 | 40 | + return; |
37 | --- a/hw/sd/sdhci.c | 41 | } |
38 | +++ b/hw/sd/sdhci.c | 42 | } |
39 | @@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size) | 43 | /* Clear s0..s15, FPSCR and VPR */ |
40 | ret = s->acmd12errsts; | ||
41 | break; | ||
42 | case SDHC_CAPAB: | ||
43 | - ret = s->capareg; | ||
44 | + ret = (uint32_t)s->capareg; | ||
45 | + break; | ||
46 | + case SDHC_CAPAB + 4: | ||
47 | + ret = (uint32_t)(s->capareg >> 32); | ||
48 | break; | ||
49 | case SDHC_MAXCURR: | ||
50 | - ret = s->maxcurr; | ||
51 | + ret = (uint32_t)s->maxcurr; | ||
52 | + break; | ||
53 | + case SDHC_MAXCURR + 4: | ||
54 | + ret = (uint32_t)(s->maxcurr >> 32); | ||
55 | break; | ||
56 | case SDHC_ADMAERR: | ||
57 | ret = s->admaerr; | ||
58 | @@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) | ||
59 | } | ||
60 | sdhci_update_irq(s); | ||
61 | break; | ||
62 | + | ||
63 | + case SDHC_CAPAB: | ||
64 | + case SDHC_CAPAB + 4: | ||
65 | + case SDHC_MAXCURR: | ||
66 | + case SDHC_MAXCURR + 4: | ||
67 | + qemu_log_mask(LOG_GUEST_ERROR, "SDHC wr_%ub @0x%02" HWADDR_PRIx | ||
68 | + " <- 0x%08x read-only\n", size, offset, value >> shift); | ||
69 | + break; | ||
70 | + | ||
71 | default: | ||
72 | qemu_log_mask(LOG_UNIMP, "SDHC wr_%ub @0x%02" HWADDR_PRIx " <- 0x%08x " | ||
73 | "not implemented\n", size, offset, value >> shift); | ||
74 | @@ -XXX,XX +XXX,XX @@ static inline unsigned int sdhci_get_fifolen(SDHCIState *s) | ||
75 | #define DEFINE_SDHCI_COMMON_PROPERTIES(_state) \ | ||
76 | /* Capabilities registers provide information on supported features | ||
77 | * of this specific host controller implementation */ \ | ||
78 | - DEFINE_PROP_UINT32("capareg", _state, capareg, SDHC_CAPAB_REG_DEFAULT), \ | ||
79 | - DEFINE_PROP_UINT32("maxcurr", _state, maxcurr, 0) | ||
80 | + DEFINE_PROP_UINT64("capareg", _state, capareg, SDHC_CAPAB_REG_DEFAULT), \ | ||
81 | + DEFINE_PROP_UINT64("maxcurr", _state, maxcurr, 0) | ||
82 | |||
83 | static void sdhci_initfn(SDHCIState *s) | ||
84 | { | ||
85 | -- | 44 | -- |
86 | 2.7.4 | 45 | 2.20.1 |
87 | 46 | ||
88 | 47 | diff view generated by jsdifflib |
1 | Since omap_mmc is still using the legacy SD card API, the SD | 1 | For M-profile, we weren't reporting alignment faults triggered by the |
---|---|---|---|
2 | card created by sd_init() is not plugged into any bus. This | 2 | generic TCG code correctly to the guest. These get passed into |
3 | means that the controller has to reset it manually. | 3 | arm_v7m_cpu_do_interrupt() as an EXCP_DATA_ABORT with an A-profile |
4 | style exception.fsr value of 1. We didn't check for this, and so | ||
5 | they fell through into the default of "assume this is an MPU fault" | ||
6 | and were reported to the guest as a data access violation MPU fault. | ||
4 | 7 | ||
5 | Failing to do this mostly didn't affect the guest since the | 8 | Report these alignment faults as UsageFaults which set the UNALIGNED |
6 | guest typically does a programmed SD card reset as part of | 9 | bit in the UFSR. |
7 | its SD controller driver initialization, but would mean that | ||
8 | migration fails because it's only in sd_reset() that we | ||
9 | set up the wpgrps_size field. | ||
10 | 10 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | Message-id: 20210723162146.5167-4-peter.maydell@linaro.org |
14 | Message-id: 1515506513-31961-5-git-send-email-peter.maydell@linaro.org | ||
15 | --- | 14 | --- |
16 | hw/sd/omap_mmc.c | 14 ++++++++++---- | 15 | target/arm/m_helper.c | 8 ++++++++ |
17 | 1 file changed, 10 insertions(+), 4 deletions(-) | 16 | 1 file changed, 8 insertions(+) |
18 | 17 | ||
19 | diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c | 18 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
20 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/sd/omap_mmc.c | 20 | --- a/target/arm/m_helper.c |
22 | +++ b/hw/sd/omap_mmc.c | 21 | +++ b/target/arm/m_helper.c |
23 | @@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host) | 22 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
24 | host->cdet_enable = 0; | 23 | env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; |
25 | qemu_set_irq(host->coverswitch, host->cdet_state); | 24 | break; |
26 | host->clkdiv = 0; | 25 | case EXCP_UNALIGNED: |
27 | + | 26 | + /* Unaligned faults reported by M-profile aware code */ |
28 | + /* Since we're still using the legacy SD API the card is not plugged | 27 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); |
29 | + * into any bus, and we must reset it manually. When omap_mmc is | 28 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
30 | + * QOMified this must move into the QOM reset function. | 29 | break; |
31 | + */ | 30 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
32 | + device_reset(DEVICE(host->card)); | 31 | } |
33 | } | 32 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); |
34 | 33 | break; | |
35 | static uint64_t omap_mmc_read(void *opaque, hwaddr offset, | 34 | + case 0x1: /* Alignment fault reported by generic code */ |
36 | @@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap_mmc_init(hwaddr base, | 35 | + qemu_log_mask(CPU_LOG_INT, |
37 | s->lines = 1; /* TODO: needs to be settable per-board */ | 36 | + "...really UsageFault with UFSR.UNALIGNED\n"); |
38 | s->rev = 1; | 37 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
39 | 38 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | |
40 | - omap_mmc_reset(s); | 39 | + env->v7m.secure); |
41 | - | 40 | + break; |
42 | memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, "omap.mmc", 0x800); | 41 | default: |
43 | memory_region_add_subregion(sysmem, base, &s->iomem); | 42 | /* |
44 | 43 | * All other FSR values are either MPU faults or "can't happen | |
45 | @@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap_mmc_init(hwaddr base, | ||
46 | exit(1); | ||
47 | } | ||
48 | |||
49 | + omap_mmc_reset(s); | ||
50 | + | ||
51 | return s; | ||
52 | } | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, | ||
55 | s->lines = 4; | ||
56 | s->rev = 2; | ||
57 | |||
58 | - omap_mmc_reset(s); | ||
59 | - | ||
60 | memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, "omap.mmc", | ||
61 | omap_l4_region_size(ta, 0)); | ||
62 | omap_l4_attach(ta, 0, &s->iomem); | ||
63 | @@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, | ||
64 | s->cdet = qemu_allocate_irq(omap_mmc_cover_cb, s, 0); | ||
65 | sd_set_cb(s->card, NULL, s->cdet); | ||
66 | |||
67 | + omap_mmc_reset(s); | ||
68 | + | ||
69 | return s; | ||
70 | } | ||
71 | |||
72 | -- | 44 | -- |
73 | 2.7.4 | 45 | 2.20.1 |
74 | 46 | ||
75 | 47 | diff view generated by jsdifflib |
1 | Add virt-2.12 machine type. | 1 | The ISCR.ISRPENDING bit is set when an external interrupt is pending. |
---|---|---|---|
2 | This is true whether that external interrupt is enabled or not. | ||
3 | This means that we can't use 's->vectpending == 0' as a shortcut to | ||
4 | "ISRPENDING is zero", because s->vectpending indicates only the | ||
5 | highest priority pending enabled interrupt. | ||
6 | |||
7 | Remove the incorrect optimization so that if there is no pending | ||
8 | enabled interrupt we fall through to scanning through the whole | ||
9 | interrupt array. | ||
2 | 10 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210723162146.5167-5-peter.maydell@linaro.org | ||
4 | --- | 14 | --- |
5 | hw/arm/virt.c | 19 +++++++++++++++++-- | 15 | hw/intc/armv7m_nvic.c | 9 ++++----- |
6 | 1 file changed, 17 insertions(+), 2 deletions(-) | 16 | 1 file changed, 4 insertions(+), 5 deletions(-) |
7 | 17 | ||
8 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 18 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
9 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
10 | --- a/hw/arm/virt.c | 20 | --- a/hw/intc/armv7m_nvic.c |
11 | +++ b/hw/arm/virt.c | 21 | +++ b/hw/intc/armv7m_nvic.c |
12 | @@ -XXX,XX +XXX,XX @@ static void machvirt_machine_init(void) | 22 | @@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s) |
13 | } | ||
14 | type_init(machvirt_machine_init); | ||
15 | |||
16 | -static void virt_2_11_instance_init(Object *obj) | ||
17 | +static void virt_2_12_instance_init(Object *obj) | ||
18 | { | 23 | { |
19 | VirtMachineState *vms = VIRT_MACHINE(obj); | 24 | int irq; |
20 | VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); | 25 | |
21 | @@ -XXX,XX +XXX,XX @@ static void virt_2_11_instance_init(Object *obj) | 26 | - /* We can shortcut if the highest priority pending interrupt |
22 | vms->irqmap = a15irqmap; | 27 | - * happens to be external or if there is nothing pending. |
23 | } | 28 | + /* |
24 | 29 | + * We can shortcut if the highest priority pending interrupt | |
25 | +static void virt_machine_2_12_options(MachineClass *mc) | 30 | + * happens to be external; if not we need to check the whole |
26 | +{ | 31 | + * vectors[] array. |
27 | +} | 32 | */ |
28 | +DEFINE_VIRT_MACHINE_AS_LATEST(2, 12) | 33 | if (s->vectpending > NVIC_FIRST_IRQ) { |
29 | + | 34 | return true; |
30 | +#define VIRT_COMPAT_2_11 \ | 35 | } |
31 | + HW_COMPAT_2_11 | 36 | - if (s->vectpending == 0) { |
32 | + | 37 | - return false; |
33 | +static void virt_2_11_instance_init(Object *obj) | 38 | - } |
34 | +{ | 39 | |
35 | + virt_2_12_instance_init(obj); | 40 | for (irq = NVIC_FIRST_IRQ; irq < s->num_irq; irq++) { |
36 | +} | 41 | if (s->vectors[irq].pending) { |
37 | + | ||
38 | static void virt_machine_2_11_options(MachineClass *mc) | ||
39 | { | ||
40 | + virt_machine_2_12_options(mc); | ||
41 | + SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_11); | ||
42 | } | ||
43 | -DEFINE_VIRT_MACHINE_AS_LATEST(2, 11) | ||
44 | +DEFINE_VIRT_MACHINE(2, 11) | ||
45 | |||
46 | #define VIRT_COMPAT_2_10 \ | ||
47 | HW_COMPAT_2_10 | ||
48 | -- | 42 | -- |
49 | 2.7.4 | 43 | 2.20.1 |
50 | 44 | ||
51 | 45 | diff view generated by jsdifflib |
1 | The Configurable Fault Status Register for ARMv7M and v8M is | 1 | The VECTPENDING field in the ICSR is 9 bits wide, in bits [20:12] of |
---|---|---|---|
2 | supposed to be byte and halfword accessible, but we were only | 2 | the register. We were incorrectly masking it to 8 bits, so it would |
3 | implementing word accesses. Add support for the other access | 3 | report the wrong value if the pending exception was greater than 256. |
4 | sizes, which are used by the Zephyr RTOS. | 4 | Fix the bug. |
5 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reported-by: Andy Gross <andy.gross@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Message-id: 20210723162146.5167-6-peter.maydell@linaro.org |
9 | Message-id: 1512742372-31517-1-git-send-email-peter.maydell@linaro.org | ||
10 | --- | 9 | --- |
11 | hw/intc/armv7m_nvic.c | 38 ++++++++++++++++++++++---------------- | 10 | hw/intc/armv7m_nvic.c | 2 +- |
12 | 1 file changed, 22 insertions(+), 16 deletions(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 12 | ||
14 | 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 |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/armv7m_nvic.c | 15 | --- a/hw/intc/armv7m_nvic.c |
17 | +++ b/hw/intc/armv7m_nvic.c | 16 | +++ b/hw/intc/armv7m_nvic.c |
18 | @@ -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) |
19 | val |= (1 << 8); | 18 | /* VECTACTIVE */ |
20 | } | 19 | val = cpu->env.v7m.exception; |
21 | return val; | 20 | /* VECTPENDING */ |
22 | - case 0xd28: /* Configurable Fault Status. */ | 21 | - val |= (s->vectpending & 0xff) << 12; |
23 | - /* The BFSR bits [15:8] are shared between security states | 22 | + val |= (s->vectpending & 0x1ff) << 12; |
24 | - * and we store them in the NS copy | 23 | /* ISRPENDING - set if any external IRQ is pending */ |
25 | - */ | 24 | if (nvic_isrpending(s)) { |
26 | - val = cpu->env.v7m.cfsr[attrs.secure]; | 25 | val |= (1 << 22); |
27 | - val |= cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK; | ||
28 | - return val; | ||
29 | case 0xd2c: /* Hard Fault Status. */ | ||
30 | return cpu->env.v7m.hfsr; | ||
31 | case 0xd30: /* Debug Fault Status. */ | ||
32 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
33 | s->vectors[ARMV7M_EXCP_DEBUG].active = (value & (1 << 8)) != 0; | ||
34 | nvic_irq_update(s); | ||
35 | break; | ||
36 | - case 0xd28: /* Configurable Fault Status. */ | ||
37 | - cpu->env.v7m.cfsr[attrs.secure] &= ~value; /* W1C */ | ||
38 | - if (attrs.secure) { | ||
39 | - /* The BFSR bits [15:8] are shared between security states | ||
40 | - * and we store them in the NS copy. | ||
41 | - */ | ||
42 | - cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK); | ||
43 | - } | ||
44 | - break; | ||
45 | case 0xd2c: /* Hard Fault Status. */ | ||
46 | cpu->env.v7m.hfsr &= ~value; /* W1C */ | ||
47 | break; | ||
48 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, | ||
49 | val = deposit32(val, i * 8, 8, get_prio(s, hdlidx, sbank)); | ||
50 | } | ||
51 | break; | ||
52 | + case 0xd28 ... 0xd2b: /* Configurable Fault Status (CFSR) */ | ||
53 | + /* The BFSR bits [15:8] are shared between security states | ||
54 | + * and we store them in the NS copy | ||
55 | + */ | ||
56 | + val = s->cpu->env.v7m.cfsr[attrs.secure]; | ||
57 | + val |= s->cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK; | ||
58 | + val = extract32(val, (offset - 0xd28) * 8, size * 8); | ||
59 | + break; | ||
60 | case 0xfe0 ... 0xfff: /* ID. */ | ||
61 | if (offset & 3) { | ||
62 | val = 0; | ||
63 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, | ||
64 | } | ||
65 | nvic_irq_update(s); | ||
66 | return MEMTX_OK; | ||
67 | + case 0xd28 ... 0xd2b: /* Configurable Fault Status (CFSR) */ | ||
68 | + /* All bits are W1C, so construct 32 bit value with 0s in | ||
69 | + * the parts not written by the access size | ||
70 | + */ | ||
71 | + value <<= ((offset - 0xd28) * 8); | ||
72 | + | ||
73 | + s->cpu->env.v7m.cfsr[attrs.secure] &= ~value; | ||
74 | + if (attrs.secure) { | ||
75 | + /* The BFSR bits [15:8] are shared between security states | ||
76 | + * and we store them in the NS copy. | ||
77 | + */ | ||
78 | + s->cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK); | ||
79 | + } | ||
80 | + return MEMTX_OK; | ||
81 | } | ||
82 | if (size == 4) { | ||
83 | nvic_writel(s, offset, value, attrs); | ||
84 | -- | 26 | -- |
85 | 2.7.4 | 27 | 2.20.1 |
86 | 28 | ||
87 | 29 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | In Arm v8.1M the VECTPENDING field in the ICSR has new behaviour: if |
---|---|---|---|
2 | the register is accessed NonSecure and the highest priority pending | ||
3 | enabled exception (that would be returned in the VECTPENDING field) | ||
4 | targets Secure, then the VECTPENDING field must read 1 rather than | ||
5 | the exception number of the pending exception. Implement this. | ||
2 | 6 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180115182436.2066-7-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210723162146.5167-7-peter.maydell@linaro.org | ||
7 | --- | 10 | --- |
8 | hw/sd/sdhci.c | 22 ++++++++++++++++++++++ | 11 | hw/intc/armv7m_nvic.c | 31 ++++++++++++++++++++++++------- |
9 | 1 file changed, 22 insertions(+) | 12 | 1 file changed, 24 insertions(+), 7 deletions(-) |
10 | 13 | ||
11 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sdhci.c | 16 | --- a/hw/intc/armv7m_nvic.c |
14 | +++ b/hw/sd/sdhci.c | 17 | +++ b/hw/intc/armv7m_nvic.c |
15 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque) |
16 | #include "qemu/bitops.h" | 19 | nvic_irq_update(s); |
17 | #include "hw/sd/sdhci.h" | ||
18 | #include "sdhci-internal.h" | ||
19 | +#include "qapi/error.h" | ||
20 | #include "qemu/log.h" | ||
21 | |||
22 | /* host controller debug messages */ | ||
23 | @@ -XXX,XX +XXX,XX @@ static void sdhci_common_realize(SDHCIState *s, Error **errp) | ||
24 | SDHC_REGISTERS_MAP_SIZE); | ||
25 | } | 20 | } |
26 | 21 | ||
27 | +static void sdhci_common_unrealize(SDHCIState *s, Error **errp) | 22 | +static bool vectpending_targets_secure(NVICState *s) |
28 | +{ | 23 | +{ |
29 | + /* This function is expected to be called only once for each class: | 24 | + /* Return true if s->vectpending targets Secure state */ |
30 | + * - SysBus: via DeviceClass->unrealize(), | 25 | + if (s->vectpending_is_s_banked) { |
31 | + * - PCI: via PCIDeviceClass->exit(). | 26 | + return true; |
32 | + * However to avoid double-free and/or use-after-free we still nullify | 27 | + } |
33 | + * this variable (better safe than sorry!). */ | 28 | + return !exc_is_banked(s->vectpending) && |
34 | + g_free(s->fifo_buffer); | 29 | + exc_targets_secure(s, s->vectpending); |
35 | + s->fifo_buffer = NULL; | ||
36 | +} | 30 | +} |
37 | + | 31 | + |
38 | static bool sdhci_pending_insert_vmstate_needed(void *opaque) | 32 | void armv7m_nvic_get_pending_irq_info(void *opaque, |
33 | int *pirq, bool *ptargets_secure) | ||
39 | { | 34 | { |
40 | SDHCIState *s = opaque; | 35 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque, |
41 | @@ -XXX,XX +XXX,XX @@ static void sdhci_pci_realize(PCIDevice *dev, Error **errp) | 36 | |
42 | static void sdhci_pci_exit(PCIDevice *dev) | 37 | assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq); |
43 | { | 38 | |
44 | SDHCIState *s = PCI_SDHCI(dev); | 39 | - if (s->vectpending_is_s_banked) { |
45 | + | 40 | - targets_secure = true; |
46 | + sdhci_common_unrealize(s, &error_abort); | 41 | - } else { |
47 | sdhci_uninitfn(s); | 42 | - targets_secure = !exc_is_banked(pending) && |
48 | } | 43 | - exc_targets_secure(s, pending); |
49 | 44 | - } | |
50 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) | 45 | + targets_secure = vectpending_targets_secure(s); |
51 | sysbus_init_mmio(sbd, &s->iomem); | 46 | |
52 | } | 47 | trace_nvic_get_pending_irq_info(pending, targets_secure); |
53 | 48 | ||
54 | +static void sdhci_sysbus_unrealize(DeviceState *dev, Error **errp) | 49 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
55 | +{ | 50 | /* VECTACTIVE */ |
56 | + SDHCIState *s = SYSBUS_SDHCI(dev); | 51 | val = cpu->env.v7m.exception; |
57 | + | 52 | /* VECTPENDING */ |
58 | + sdhci_common_unrealize(s, &error_abort); | 53 | - val |= (s->vectpending & 0x1ff) << 12; |
59 | +} | 54 | + if (s->vectpending) { |
60 | + | 55 | + /* |
61 | static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) | 56 | + * From v8.1M VECTPENDING must read as 1 if accessed as |
62 | { | 57 | + * NonSecure and the highest priority pending and enabled |
63 | DeviceClass *dc = DEVICE_CLASS(klass); | 58 | + * exception targets Secure. |
64 | 59 | + */ | |
65 | dc->props = sdhci_sysbus_properties; | 60 | + int vp = s->vectpending; |
66 | dc->realize = sdhci_sysbus_realize; | 61 | + if (!attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_V8_1M) && |
67 | + dc->unrealize = sdhci_sysbus_unrealize; | 62 | + vectpending_targets_secure(s)) { |
68 | 63 | + vp = 1; | |
69 | sdhci_common_class_init(klass, data); | 64 | + } |
70 | } | 65 | + val |= (vp & 0x1ff) << 12; |
66 | + } | ||
67 | /* ISRPENDING - set if any external IRQ is pending */ | ||
68 | if (nvic_isrpending(s)) { | ||
69 | val |= (1 << 22); | ||
71 | -- | 70 | -- |
72 | 2.7.4 | 71 | 2.20.1 |
73 | 72 | ||
74 | 73 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Missed in commit f3478392 "docs: Move deprecation, build |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | and license info out of system/" |
5 | Message-id: 20180115182436.2066-11-f4bug@amsat.org | 5 | |
6 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20210723065828.1336760-1-maozhongyi@cmss.chinamobile.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | hw/sd/sdhci-internal.h | 2 +- | 11 | configure | 2 +- |
9 | hw/sd/sdhci.c | 2 +- | 12 | target/i386/cpu.c | 2 +- |
10 | 2 files changed, 2 insertions(+), 2 deletions(-) | 13 | MAINTAINERS | 2 +- |
14 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
11 | 15 | ||
12 | diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.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 | ||
13 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/sd/sdhci-internal.h | 31 | --- a/target/i386/cpu.c |
15 | +++ b/hw/sd/sdhci-internal.h | 32 | +++ b/target/i386/cpu.c |
16 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ static const X86CPUDefinition builtin_x86_defs[] = { |
17 | #define SDHC_ACMD12ERRSTS 0x3C | 34 | * none", but this is just for compatibility while libvirt isn't |
18 | 35 | * adapted to resolve CPU model versions before creating VMs. | |
19 | /* HWInit Capabilities Register 0x05E80080 */ | 36 | * See "Runnability guarantee of CPU models" at |
20 | -#define SDHC_CAPAREG 0x40 | 37 | - * docs/system/deprecated.rst. |
21 | +#define SDHC_CAPAB 0x40 | 38 | + * docs/about/deprecated.rst. |
22 | #define SDHC_CAN_DO_DMA 0x00400000 | 39 | */ |
23 | #define SDHC_CAN_DO_ADMA2 0x00080000 | 40 | X86CPUVersion default_cpu_version = 1; |
24 | #define SDHC_CAN_DO_ADMA1 0x00100000 | 41 | |
25 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 42 | diff --git a/MAINTAINERS b/MAINTAINERS |
26 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/sd/sdhci.c | 44 | --- a/MAINTAINERS |
28 | +++ b/hw/sd/sdhci.c | 45 | +++ b/MAINTAINERS |
29 | @@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size) | 46 | @@ -XXX,XX +XXX,XX @@ F: contrib/gitdm/* |
30 | case SDHC_ACMD12ERRSTS: | 47 | |
31 | ret = s->acmd12errsts; | 48 | Incompatible changes |
32 | break; | 49 | R: libvir-list@redhat.com |
33 | - case SDHC_CAPAREG: | 50 | -F: docs/system/deprecated.rst |
34 | + case SDHC_CAPAB: | 51 | +F: docs/about/deprecated.rst |
35 | ret = s->capareg; | 52 | |
36 | break; | 53 | Build System |
37 | case SDHC_MAXCURR: | 54 | ------------ |
38 | -- | 55 | -- |
39 | 2.7.4 | 56 | 2.20.1 |
40 | 57 | ||
41 | 58 | diff view generated by jsdifflib |
1 | For PMSAv7, the v7A/R Arm ARM defines that setting AP to 0b111 | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | is an UNPREDICTABLE reserved combination. However, for v7M | ||
3 | this value is documented as having the same behaviour as 0b110: | ||
4 | read-only for both privileged and unprivileged. Accept this | ||
5 | value on an M profile core rather than treating it as a guest | ||
6 | error and a no-access page. | ||
7 | 2 | ||
8 | Reported-by: Andy Gross <andy.gross@linaro.org> | 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 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 1512742402-31669-1-git-send-email-peter.maydell@linaro.org | ||
12 | --- | 15 | --- |
13 | target/arm/helper.c | 14 ++++++++++++++ | 16 | target/arm/helper.c | 4 +++- |
14 | 1 file changed, 14 insertions(+) | 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 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | 23 | @@ -XXX,XX +XXX,XX @@ static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
21 | case 6: | 24 | { |
22 | *prot |= PAGE_READ | PAGE_EXEC; | 25 | uint32_t end_len; |
23 | break; | 26 | |
24 | + case 7: | 27 | - end_len = start_len &= 0xf; |
25 | + /* for v7M, same as 6; for R profile a reserved value */ | 28 | + start_len = MIN(start_len, ARM_MAX_VQ - 1); |
26 | + if (arm_feature(env, ARM_FEATURE_M)) { | 29 | + end_len = start_len; |
27 | + *prot |= PAGE_READ | PAGE_EXEC; | 30 | + |
28 | + break; | 31 | if (!test_bit(start_len, cpu->sve_vq_map)) { |
29 | + } | 32 | end_len = find_last_bit(cpu->sve_vq_map, start_len); |
30 | + /* fall through */ | 33 | assert(end_len < start_len); |
31 | default: | ||
32 | qemu_log_mask(LOG_GUEST_ERROR, | ||
33 | "DRACR[%d]: Bad value for AP bits: 0x%" | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
35 | case 6: | ||
36 | *prot |= PAGE_READ | PAGE_EXEC; | ||
37 | break; | ||
38 | + case 7: | ||
39 | + /* for v7M, same as 6; for R profile a reserved value */ | ||
40 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
41 | + *prot |= PAGE_READ | PAGE_EXEC; | ||
42 | + break; | ||
43 | + } | ||
44 | + /* fall through */ | ||
45 | default: | ||
46 | qemu_log_mask(LOG_GUEST_ERROR, | ||
47 | "DRACR[%d]: Bad value for AP bits: 0x%" | ||
48 | -- | 34 | -- |
49 | 2.7.4 | 35 | 2.20.1 |
50 | 36 | ||
51 | 37 | diff view generated by jsdifflib |
1 | Instead of ignoring the response from address_space_ld*() | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | (indicating an attempt to read a page table descriptor from | ||
3 | an invalid physical address), use it to report the failure | ||
4 | correctly. | ||
5 | 2 | ||
6 | Since this is another couple of locations where we need to | 3 | Rename from sve_zcr_get_valid_len and make accessible |
7 | decide the value of the ARMMMUFaultInfo ea bit based on a | 4 | from outside of helper.c. |
8 | MemTxResult, we factor out that operation into a helper | ||
9 | function. | ||
10 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20210723203344.968563-3-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | target/arm/internals.h | 10 ++++++++++ | 11 | target/arm/internals.h | 10 ++++++++++ |
14 | target/arm/helper.c | 39 ++++++++++++++++++++++++++++++++++----- | 12 | target/arm/helper.c | 4 ++-- |
15 | target/arm/op_helper.c | 7 +------ | 13 | 2 files changed, 12 insertions(+), 2 deletions(-) |
16 | 3 files changed, 45 insertions(+), 11 deletions(-) | ||
17 | 14 | ||
18 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 15 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/internals.h | 17 | --- a/target/arm/internals.h |
21 | +++ b/target/arm/internals.h | 18 | +++ b/target/arm/internals.h |
22 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t arm_fi_to_lfsc(ARMMMUFaultInfo *fi) | 19 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void); |
23 | return fsc; | 20 | void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); |
24 | } | 21 | #endif /* CONFIG_TCG */ |
25 | 22 | ||
26 | +static inline bool arm_extabort_type(MemTxResult result) | 23 | +/** |
27 | +{ | 24 | + * aarch64_sve_zcr_get_valid_len: |
28 | + /* The EA bit in syndromes and fault status registers is an | 25 | + * @cpu: cpu context |
29 | + * IMPDEF classification of external aborts. ARM implementations | 26 | + * @start_len: maximum len to consider |
30 | + * usually use this to indicate AXI bus Decode error (0) or | 27 | + * |
31 | + * Slave error (1); in QEMU we follow that. | 28 | + * Return the maximum supported sve vector length <= @start_len. |
32 | + */ | 29 | + * Note that both @start_len and the return value are in units |
33 | + return result != MEMTX_DECODE_ERROR; | 30 | + * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128. |
34 | +} | 31 | + */ |
35 | + | 32 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len); |
36 | /* Do a page table walk and add page to TLB if possible */ | 33 | |
37 | bool arm_tlb_fill(CPUState *cpu, vaddr address, | 34 | enum arm_fprounding { |
38 | MMUAccessType access_type, int mmu_idx, | 35 | FPROUNDING_TIEEVEN, |
39 | 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 |
40 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/helper.c | 38 | --- a/target/arm/helper.c |
42 | +++ b/target/arm/helper.c | 39 | +++ b/target/arm/helper.c |
43 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | 40 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
44 | ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa, | 41 | return 0; |
45 | &txattrs, &s2prot, &s2size, fi, NULL); | 42 | } |
46 | if (ret) { | 43 | |
47 | + assert(fi->type != ARMFault_None); | 44 | -static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
48 | fi->s2addr = addr; | 45 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
49 | fi->stage2 = true; | 46 | { |
50 | fi->s1ptw = true; | 47 | uint32_t end_len; |
51 | @@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | 48 | |
52 | ARMCPU *cpu = ARM_CPU(cs); | 49 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) |
53 | CPUARMState *env = &cpu->env; | 50 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); |
54 | MemTxAttrs attrs = {}; | ||
55 | + MemTxResult result = MEMTX_OK; | ||
56 | AddressSpace *as; | ||
57 | + uint32_t data; | ||
58 | |||
59 | attrs.secure = is_secure; | ||
60 | as = arm_addressspace(cs, attrs); | ||
61 | @@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
62 | return 0; | ||
63 | } | 51 | } |
64 | if (regime_translation_big_endian(env, mmu_idx)) { | 52 | |
65 | - return address_space_ldl_be(as, addr, attrs, NULL); | 53 | - return sve_zcr_get_valid_len(cpu, zcr_len); |
66 | + data = address_space_ldl_be(as, addr, attrs, &result); | 54 | + return aarch64_sve_zcr_get_valid_len(cpu, zcr_len); |
67 | } else { | ||
68 | - return address_space_ldl_le(as, addr, attrs, NULL); | ||
69 | + data = address_space_ldl_le(as, addr, attrs, &result); | ||
70 | } | ||
71 | + if (result == MEMTX_OK) { | ||
72 | + return data; | ||
73 | + } | ||
74 | + fi->type = ARMFault_SyncExternalOnWalk; | ||
75 | + fi->ea = arm_extabort_type(result); | ||
76 | + return 0; | ||
77 | } | 55 | } |
78 | 56 | ||
79 | static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | 57 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
80 | @@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
81 | ARMCPU *cpu = ARM_CPU(cs); | ||
82 | CPUARMState *env = &cpu->env; | ||
83 | MemTxAttrs attrs = {}; | ||
84 | + MemTxResult result = MEMTX_OK; | ||
85 | AddressSpace *as; | ||
86 | + uint32_t data; | ||
87 | |||
88 | attrs.secure = is_secure; | ||
89 | as = arm_addressspace(cs, attrs); | ||
90 | @@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
91 | return 0; | ||
92 | } | ||
93 | if (regime_translation_big_endian(env, mmu_idx)) { | ||
94 | - return address_space_ldq_be(as, addr, attrs, NULL); | ||
95 | + data = address_space_ldq_be(as, addr, attrs, &result); | ||
96 | } else { | ||
97 | - return address_space_ldq_le(as, addr, attrs, NULL); | ||
98 | + data = address_space_ldq_le(as, addr, attrs, &result); | ||
99 | + } | ||
100 | + if (result == MEMTX_OK) { | ||
101 | + return data; | ||
102 | } | ||
103 | + fi->type = ARMFault_SyncExternalOnWalk; | ||
104 | + fi->ea = arm_extabort_type(result); | ||
105 | + return 0; | ||
106 | } | ||
107 | |||
108 | static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
110 | } | ||
111 | desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
112 | mmu_idx, fi); | ||
113 | + if (fi->type != ARMFault_None) { | ||
114 | + goto do_fault; | ||
115 | + } | ||
116 | type = (desc & 3); | ||
117 | domain = (desc >> 5) & 0x0f; | ||
118 | if (regime_el(env, mmu_idx) == 1) { | ||
119 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
120 | } | ||
121 | desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
122 | mmu_idx, fi); | ||
123 | + if (fi->type != ARMFault_None) { | ||
124 | + goto do_fault; | ||
125 | + } | ||
126 | switch (desc & 3) { | ||
127 | case 0: /* Page translation fault. */ | ||
128 | fi->type = ARMFault_Translation; | ||
129 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
130 | } | ||
131 | desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
132 | mmu_idx, fi); | ||
133 | + if (fi->type != ARMFault_None) { | ||
134 | + goto do_fault; | ||
135 | + } | ||
136 | type = (desc & 3); | ||
137 | if (type == 0 || (type == 3 && !arm_feature(env, ARM_FEATURE_PXN))) { | ||
138 | /* Section translation fault, or attempt to use the encoding | ||
139 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
140 | table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); | ||
141 | desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
142 | mmu_idx, fi); | ||
143 | + if (fi->type != ARMFault_None) { | ||
144 | + goto do_fault; | ||
145 | + } | ||
146 | ap = ((desc >> 4) & 3) | ((desc >> 7) & 4); | ||
147 | switch (desc & 3) { | ||
148 | case 0: /* Page translation fault. */ | ||
149 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
150 | descaddr &= ~7ULL; | ||
151 | nstable = extract32(tableattrs, 4, 1); | ||
152 | descriptor = arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fi); | ||
153 | - if (fi->s1ptw) { | ||
154 | + if (fi->type != ARMFault_None) { | ||
155 | goto do_fault; | ||
156 | } | ||
157 | |||
158 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/target/arm/op_helper.c | ||
161 | +++ b/target/arm/op_helper.c | ||
162 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, | ||
163 | /* now we have a real cpu fault */ | ||
164 | cpu_restore_state(cs, retaddr); | ||
165 | |||
166 | - /* The EA bit in syndromes and fault status registers is an | ||
167 | - * IMPDEF classification of external aborts. ARM implementations | ||
168 | - * usually use this to indicate AXI bus Decode error (0) or | ||
169 | - * Slave error (1); in QEMU we follow that. | ||
170 | - */ | ||
171 | - fi.ea = (response != MEMTX_DECODE_ERROR); | ||
172 | + fi.ea = arm_extabort_type(response); | ||
173 | fi.type = ARMFault_SyncExternal; | ||
174 | deliver_fault(cpu, addr, access_type, mmu_idx, &fi); | ||
175 | } | ||
176 | -- | 58 | -- |
177 | 2.7.4 | 59 | 2.20.1 |
178 | 60 | ||
179 | 61 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Since pl181 is still using the legacy SD card API, the SD | ||
2 | card created by sd_init() is not plugged into any bus. This | ||
3 | means that the controller has to reset it manually. | ||
4 | 1 | ||
5 | Failing to do this mostly didn't affect the guest since the | ||
6 | guest typically does a programmed SD card reset as part of | ||
7 | its SD controller driver initialization, but meant that | ||
8 | migration failed because it's only in sd_reset() that we | ||
9 | set up the wpgrps_size field. | ||
10 | |||
11 | Cc: qemu-stable@nongnu.org | ||
12 | Fixes: https://bugs.launchpad.net/qemu/+bug/1739378 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Message-id: 1515506513-31961-2-git-send-email-peter.maydell@linaro.org | ||
17 | --- | ||
18 | hw/sd/pl181.c | 4 ++++ | ||
19 | 1 file changed, 4 insertions(+) | ||
20 | |||
21 | diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/sd/pl181.c | ||
24 | +++ b/hw/sd/pl181.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void pl181_reset(DeviceState *d) | ||
26 | |||
27 | /* We can assume our GPIO outputs have been wired up now */ | ||
28 | sd_set_cb(s->card, s->cardstatus[0], s->cardstatus[1]); | ||
29 | + /* Since we're still using the legacy SD API the card is not plugged | ||
30 | + * into any bus, and we must reset it manually. | ||
31 | + */ | ||
32 | + device_reset(DEVICE(s->card)); | ||
33 | } | ||
34 | |||
35 | static void pl181_init(Object *obj) | ||
36 | -- | ||
37 | 2.7.4 | ||
38 | |||
39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Since milkymist-memcard is still using the legacy SD card API, | ||
2 | the SD card created by sd_init() is not plugged into any bus. | ||
3 | This means that the controller has to reset it manually. | ||
4 | 1 | ||
5 | Failing to do this mostly didn't affect the guest since the | ||
6 | guest typically does a programmed SD card reset as part of | ||
7 | its SD controller driver initialization, but meant that | ||
8 | migration failed because it's only in sd_reset() that we | ||
9 | set up the wpgrps_size field. | ||
10 | |||
11 | Cc: qemu-stable@nongnu.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 1515506513-31961-3-git-send-email-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/sd/milkymist-memcard.c | 4 ++++ | ||
18 | 1 file changed, 4 insertions(+) | ||
19 | |||
20 | diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/sd/milkymist-memcard.c | ||
23 | +++ b/hw/sd/milkymist-memcard.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void milkymist_memcard_reset(DeviceState *d) | ||
25 | for (i = 0; i < R_MAX; i++) { | ||
26 | s->regs[i] = 0; | ||
27 | } | ||
28 | + /* Since we're still using the legacy SD API the card is not plugged | ||
29 | + * into any bus, and we must reset it manually. | ||
30 | + */ | ||
31 | + device_reset(DEVICE(s->card)); | ||
32 | } | ||
33 | |||
34 | static int milkymist_memcard_init(SysBusDevice *dev) | ||
35 | -- | ||
36 | 2.7.4 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Since ssi-sd is still using the legacy SD card API, the SD | ||
2 | card created by sd_init() is not plugged into any bus. This | ||
3 | means that the controller has to reset it manually. | ||
4 | 1 | ||
5 | Failing to do this mostly didn't affect the guest since the | ||
6 | guest typically does a programmed SD card reset as part of | ||
7 | its SD controller driver initialization, but meant that | ||
8 | migration failed because it's only in sd_reset() that we | ||
9 | set up the wpgrps_size field. | ||
10 | |||
11 | In the case of sd-ssi, we have to implement an entire | ||
12 | reset function since there wasn't one previously, and | ||
13 | that requires a QOM cast macro that got omitted when this | ||
14 | device was QOMified. | ||
15 | |||
16 | Cc: qemu-stable@nongnu.org | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
19 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Message-id: 1515506513-31961-4-git-send-email-peter.maydell@linaro.org | ||
21 | --- | ||
22 | hw/sd/ssi-sd.c | 25 +++++++++++++++++++++++-- | ||
23 | 1 file changed, 23 insertions(+), 2 deletions(-) | ||
24 | |||
25 | diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/sd/ssi-sd.c | ||
28 | +++ b/hw/sd/ssi-sd.c | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
30 | SDState *sd; | ||
31 | } ssi_sd_state; | ||
32 | |||
33 | +#define TYPE_SSI_SD "ssi-sd" | ||
34 | +#define SSI_SD(obj) OBJECT_CHECK(ssi_sd_state, (obj), TYPE_SSI_SD) | ||
35 | + | ||
36 | /* State word bits. */ | ||
37 | #define SSI_SDR_LOCKED 0x0001 | ||
38 | #define SSI_SDR_WP_ERASE 0x0002 | ||
39 | @@ -XXX,XX +XXX,XX @@ static void ssi_sd_realize(SSISlave *d, Error **errp) | ||
40 | ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d); | ||
41 | DriveInfo *dinfo; | ||
42 | |||
43 | - s->mode = SSI_SD_CMD; | ||
44 | /* FIXME use a qdev drive property instead of drive_get_next() */ | ||
45 | dinfo = drive_get_next(IF_SD); | ||
46 | s->sd = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, true); | ||
47 | @@ -XXX,XX +XXX,XX @@ static void ssi_sd_realize(SSISlave *d, Error **errp) | ||
48 | } | ||
49 | } | ||
50 | |||
51 | +static void ssi_sd_reset(DeviceState *dev) | ||
52 | +{ | ||
53 | + ssi_sd_state *s = SSI_SD(dev); | ||
54 | + | ||
55 | + s->mode = SSI_SD_CMD; | ||
56 | + s->cmd = 0; | ||
57 | + memset(s->cmdarg, 0, sizeof(s->cmdarg)); | ||
58 | + memset(s->response, 0, sizeof(s->response)); | ||
59 | + s->arglen = 0; | ||
60 | + s->response_pos = 0; | ||
61 | + s->stopping = 0; | ||
62 | + | ||
63 | + /* Since we're still using the legacy SD API the card is not plugged | ||
64 | + * into any bus, and we must reset it manually. | ||
65 | + */ | ||
66 | + device_reset(DEVICE(s->sd)); | ||
67 | +} | ||
68 | + | ||
69 | static void ssi_sd_class_init(ObjectClass *klass, void *data) | ||
70 | { | ||
71 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
72 | @@ -XXX,XX +XXX,XX @@ static void ssi_sd_class_init(ObjectClass *klass, void *data) | ||
73 | k->transfer = ssi_sd_transfer; | ||
74 | k->cs_polarity = SSI_CS_LOW; | ||
75 | dc->vmsd = &vmstate_ssi_sd; | ||
76 | + dc->reset = ssi_sd_reset; | ||
77 | } | ||
78 | |||
79 | static const TypeInfo ssi_sd_info = { | ||
80 | - .name = "ssi-sd", | ||
81 | + .name = TYPE_SSI_SD, | ||
82 | .parent = TYPE_SSI_SLAVE, | ||
83 | .instance_size = sizeof(ssi_sd_state), | ||
84 | .class_init = ssi_sd_class_init, | ||
85 | -- | ||
86 | 2.7.4 | ||
87 | |||
88 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20180110063337.21538-2-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-a64.c | 44 ++++++++++++++++++++++++++++---------------- | ||
9 | 1 file changed, 28 insertions(+), 16 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-a64.c | ||
14 | +++ b/target/arm/translate-a64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | +/* The imm8 encodes the sign bit, enough bits to represent an exponent in | ||
20 | + * the range 01....1xx to 10....0xx, and the most significant 4 bits of | ||
21 | + * the mantissa; see VFPExpandImm() in the v8 ARM ARM. | ||
22 | + */ | ||
23 | +static uint64_t vfp_expand_imm(int size, uint8_t imm8) | ||
24 | +{ | ||
25 | + uint64_t imm; | ||
26 | + | ||
27 | + switch (size) { | ||
28 | + case MO_64: | ||
29 | + imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) | | ||
30 | + (extract32(imm8, 6, 1) ? 0x3fc0 : 0x4000) | | ||
31 | + extract32(imm8, 0, 6); | ||
32 | + imm <<= 48; | ||
33 | + break; | ||
34 | + case MO_32: | ||
35 | + imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) | | ||
36 | + (extract32(imm8, 6, 1) ? 0x3e00 : 0x4000) | | ||
37 | + (extract32(imm8, 0, 6) << 3); | ||
38 | + imm <<= 16; | ||
39 | + break; | ||
40 | + default: | ||
41 | + g_assert_not_reached(); | ||
42 | + } | ||
43 | + return imm; | ||
44 | +} | ||
45 | + | ||
46 | /* Floating point immediate | ||
47 | * 31 30 29 28 24 23 22 21 20 13 12 10 9 5 4 0 | ||
48 | * +---+---+---+-----------+------+---+------------+-------+------+------+ | ||
49 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) | ||
50 | return; | ||
51 | } | ||
52 | |||
53 | - /* The imm8 encodes the sign bit, enough bits to represent | ||
54 | - * an exponent in the range 01....1xx to 10....0xx, | ||
55 | - * and the most significant 4 bits of the mantissa; see | ||
56 | - * VFPExpandImm() in the v8 ARM ARM. | ||
57 | - */ | ||
58 | - if (is_double) { | ||
59 | - imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) | | ||
60 | - (extract32(imm8, 6, 1) ? 0x3fc0 : 0x4000) | | ||
61 | - extract32(imm8, 0, 6); | ||
62 | - imm <<= 48; | ||
63 | - } else { | ||
64 | - imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) | | ||
65 | - (extract32(imm8, 6, 1) ? 0x3e00 : 0x4000) | | ||
66 | - (extract32(imm8, 0, 6) << 3); | ||
67 | - imm <<= 16; | ||
68 | - } | ||
69 | + imm = vfp_expand_imm(MO_32 + is_double, imm8); | ||
70 | |||
71 | tcg_res = tcg_const_i64(imm); | ||
72 | write_fp_dreg(s, rd, tcg_res); | ||
73 | -- | ||
74 | 2.7.4 | ||
75 | |||
76 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20180110063337.21538-3-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-a64.c | 5 +++++ | ||
9 | 1 file changed, 5 insertions(+) | ||
10 | |||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-a64.c | ||
14 | +++ b/target/arm/translate-a64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static uint64_t vfp_expand_imm(int size, uint8_t imm8) | ||
16 | (extract32(imm8, 0, 6) << 3); | ||
17 | imm <<= 16; | ||
18 | break; | ||
19 | + case MO_16: | ||
20 | + imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) | | ||
21 | + (extract32(imm8, 6, 1) ? 0x3000 : 0x4000) | | ||
22 | + (extract32(imm8, 0, 6) << 6); | ||
23 | + break; | ||
24 | default: | ||
25 | g_assert_not_reached(); | ||
26 | } | ||
27 | -- | ||
28 | 2.7.4 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180115182436.2066-2-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/sd/sdhci-internal.h | 4 ---- | ||
9 | include/hw/sd/sdhci.h | 7 ++++++- | ||
10 | hw/sd/sdhci.c | 1 + | ||
11 | 3 files changed, 7 insertions(+), 5 deletions(-) | ||
12 | |||
13 | diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/sdhci-internal.h | ||
16 | +++ b/hw/sd/sdhci-internal.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | #ifndef SDHCI_INTERNAL_H | ||
19 | #define SDHCI_INTERNAL_H | ||
20 | |||
21 | -#include "hw/sd/sdhci.h" | ||
22 | - | ||
23 | /* R/W SDMA System Address register 0x0 */ | ||
24 | #define SDHC_SYSAD 0x00 | ||
25 | |||
26 | @@ -XXX,XX +XXX,XX @@ enum { | ||
27 | sdhc_gap_write = 2 /* SDHC stopped at block gap during write operation */ | ||
28 | }; | ||
29 | |||
30 | -extern const VMStateDescription sdhci_vmstate; | ||
31 | - | ||
32 | #endif | ||
33 | diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/include/hw/sd/sdhci.h | ||
36 | +++ b/include/hw/sd/sdhci.h | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | #define SDHCI_H | ||
39 | |||
40 | #include "qemu-common.h" | ||
41 | -#include "hw/block/block.h" | ||
42 | #include "hw/pci/pci.h" | ||
43 | #include "hw/sysbus.h" | ||
44 | #include "hw/sd/sd.h" | ||
45 | |||
46 | /* SD/MMC host controller state */ | ||
47 | typedef struct SDHCIState { | ||
48 | + /*< private >*/ | ||
49 | union { | ||
50 | PCIDevice pcidev; | ||
51 | SysBusDevice busdev; | ||
52 | }; | ||
53 | + | ||
54 | + /*< public >*/ | ||
55 | SDBus sdbus; | ||
56 | MemoryRegion iomem; | ||
57 | |||
58 | @@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState { | ||
59 | qemu_irq ro_cb; | ||
60 | qemu_irq irq; | ||
61 | |||
62 | + /* Registers cleared on reset */ | ||
63 | uint32_t sdmasysad; /* SDMA System Address register */ | ||
64 | uint16_t blksize; /* Host DMA Buff Boundary and Transfer BlkSize Reg */ | ||
65 | uint16_t blkcnt; /* Blocks count for current transfer */ | ||
66 | @@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState { | ||
67 | uint16_t acmd12errsts; /* Auto CMD12 error status register */ | ||
68 | uint64_t admasysaddr; /* ADMA System Address Register */ | ||
69 | |||
70 | + /* Read-only registers */ | ||
71 | uint32_t capareg; /* Capabilities Register */ | ||
72 | uint32_t maxcurr; /* Maximum Current Capabilities Register */ | ||
73 | + | ||
74 | uint8_t *fifo_buffer; /* SD host i/o FIFO buffer */ | ||
75 | uint32_t buf_maxsz; | ||
76 | uint16_t data_count; /* current element in FIFO buffer */ | ||
77 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/sd/sdhci.c | ||
80 | +++ b/hw/sd/sdhci.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "sysemu/dma.h" | ||
83 | #include "qemu/timer.h" | ||
84 | #include "qemu/bitops.h" | ||
85 | +#include "hw/sd/sdhci.h" | ||
86 | #include "sdhci-internal.h" | ||
87 | #include "qemu/log.h" | ||
88 | |||
89 | -- | ||
90 | 2.7.4 | ||
91 | |||
92 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180115182436.2066-3-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/sd/sdhci.h | 2 -- | ||
9 | hw/sd/sdhci.c | 2 -- | ||
10 | 2 files changed, 4 deletions(-) | ||
11 | |||
12 | diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/sd/sdhci.h | ||
15 | +++ b/include/hw/sd/sdhci.h | ||
16 | @@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState { | ||
17 | |||
18 | QEMUTimer *insert_timer; /* timer for 'changing' sd card. */ | ||
19 | QEMUTimer *transfer_timer; | ||
20 | - qemu_irq eject_cb; | ||
21 | - qemu_irq ro_cb; | ||
22 | qemu_irq irq; | ||
23 | |||
24 | /* Registers cleared on reset */ | ||
25 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/sd/sdhci.c | ||
28 | +++ b/hw/sd/sdhci.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static void sdhci_uninitfn(SDHCIState *s) | ||
30 | timer_free(s->insert_timer); | ||
31 | timer_del(s->transfer_timer); | ||
32 | timer_free(s->transfer_timer); | ||
33 | - qemu_free_irq(s->eject_cb); | ||
34 | - qemu_free_irq(s->ro_cb); | ||
35 | |||
36 | g_free(s->fifo_buffer); | ||
37 | s->fifo_buffer = NULL; | ||
38 | -- | ||
39 | 2.7.4 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Add common/sysbus/pci/sdbus comments to have clearer code blocks separation. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20180115182436.2066-4-f4bug@amsat.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | include/hw/sd/sdhci.h | 4 +++- | ||
11 | hw/sd/sdhci.c | 25 +++++++++++++++++-------- | ||
12 | 2 files changed, 20 insertions(+), 9 deletions(-) | ||
13 | |||
14 | diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/sd/sdhci.h | ||
17 | +++ b/include/hw/sd/sdhci.h | ||
18 | @@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState { | ||
19 | uint32_t buf_maxsz; | ||
20 | uint16_t data_count; /* current element in FIFO buffer */ | ||
21 | uint8_t stopped_state;/* Current SDHC state */ | ||
22 | - bool pending_insert_quirk;/* Quirk for Raspberry Pi card insert int */ | ||
23 | bool pending_insert_state; | ||
24 | /* Buffer Data Port Register - virtual access point to R and W buffers */ | ||
25 | /* Software Reset Register - always reads as 0 */ | ||
26 | /* Force Event Auto CMD12 Error Interrupt Reg - write only */ | ||
27 | /* Force Event Error Interrupt Register- write only */ | ||
28 | /* RO Host Controller Version Register always reads as 0x2401 */ | ||
29 | + | ||
30 | + /* Configurable properties */ | ||
31 | + bool pending_insert_quirk; /* Quirk for Raspberry Pi card insert int */ | ||
32 | } SDHCIState; | ||
33 | |||
34 | #define TYPE_PCI_SDHCI "sdhci-pci" | ||
35 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/sd/sdhci.c | ||
38 | +++ b/hw/sd/sdhci.c | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | */ | ||
41 | |||
42 | #include "qemu/osdep.h" | ||
43 | +#include "qapi/error.h" | ||
44 | #include "hw/hw.h" | ||
45 | #include "sysemu/block-backend.h" | ||
46 | #include "sysemu/blockdev.h" | ||
47 | @@ -XXX,XX +XXX,XX @@ static inline unsigned int sdhci_get_fifolen(SDHCIState *s) | ||
48 | } | ||
49 | } | ||
50 | |||
51 | +/* --- qdev common --- */ | ||
52 | + | ||
53 | +#define DEFINE_SDHCI_COMMON_PROPERTIES(_state) \ | ||
54 | + /* Capabilities registers provide information on supported features | ||
55 | + * of this specific host controller implementation */ \ | ||
56 | + DEFINE_PROP_UINT32("capareg", _state, capareg, SDHC_CAPAB_REG_DEFAULT), \ | ||
57 | + DEFINE_PROP_UINT32("maxcurr", _state, maxcurr, 0) | ||
58 | + | ||
59 | static void sdhci_initfn(SDHCIState *s) | ||
60 | { | ||
61 | qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), | ||
62 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription sdhci_vmstate = { | ||
63 | }, | ||
64 | }; | ||
65 | |||
66 | -/* Capabilities registers provide information on supported features of this | ||
67 | - * specific host controller implementation */ | ||
68 | +/* --- qdev PCI --- */ | ||
69 | + | ||
70 | static Property sdhci_pci_properties[] = { | ||
71 | - DEFINE_PROP_UINT32("capareg", SDHCIState, capareg, | ||
72 | - SDHC_CAPAB_REG_DEFAULT), | ||
73 | - DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0), | ||
74 | + DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState), | ||
75 | DEFINE_PROP_END_OF_LIST(), | ||
76 | }; | ||
77 | |||
78 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo sdhci_pci_info = { | ||
79 | }, | ||
80 | }; | ||
81 | |||
82 | +/* --- qdev SysBus --- */ | ||
83 | + | ||
84 | static Property sdhci_sysbus_properties[] = { | ||
85 | - DEFINE_PROP_UINT32("capareg", SDHCIState, capareg, | ||
86 | - SDHC_CAPAB_REG_DEFAULT), | ||
87 | - DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0), | ||
88 | + DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState), | ||
89 | DEFINE_PROP_BOOL("pending-insert-quirk", SDHCIState, pending_insert_quirk, | ||
90 | false), | ||
91 | DEFINE_PROP_END_OF_LIST(), | ||
92 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo sdhci_sysbus_info = { | ||
93 | .class_init = sdhci_sysbus_class_init, | ||
94 | }; | ||
95 | |||
96 | +/* --- qdev bus master --- */ | ||
97 | + | ||
98 | static void sdhci_bus_class_init(ObjectClass *klass, void *data) | ||
99 | { | ||
100 | SDBusClass *sbc = SD_BUS_CLASS(klass); | ||
101 | -- | ||
102 | 2.7.4 | ||
103 | |||
104 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Now both inherited classes appear as DEVICE_CATEGORY_STORAGE. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Message-id: 20180115182436.2066-5-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/sd/sdhci.c | 18 +++++++++++++----- | ||
11 | 1 file changed, 13 insertions(+), 5 deletions(-) | ||
12 | |||
13 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/sdhci.c | ||
16 | +++ b/hw/sd/sdhci.c | ||
17 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription sdhci_vmstate = { | ||
18 | }, | ||
19 | }; | ||
20 | |||
21 | +static void sdhci_common_class_init(ObjectClass *klass, void *data) | ||
22 | +{ | ||
23 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
24 | + | ||
25 | + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); | ||
26 | + dc->vmsd = &sdhci_vmstate; | ||
27 | + dc->reset = sdhci_poweron_reset; | ||
28 | +} | ||
29 | + | ||
30 | /* --- qdev PCI --- */ | ||
31 | |||
32 | static Property sdhci_pci_properties[] = { | ||
33 | @@ -XXX,XX +XXX,XX @@ static void sdhci_pci_class_init(ObjectClass *klass, void *data) | ||
34 | k->vendor_id = PCI_VENDOR_ID_REDHAT; | ||
35 | k->device_id = PCI_DEVICE_ID_REDHAT_SDHCI; | ||
36 | k->class_id = PCI_CLASS_SYSTEM_SDHCI; | ||
37 | - set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); | ||
38 | - dc->vmsd = &sdhci_vmstate; | ||
39 | dc->props = sdhci_pci_properties; | ||
40 | - dc->reset = sdhci_poweron_reset; | ||
41 | + | ||
42 | + sdhci_common_class_init(klass, data); | ||
43 | } | ||
44 | |||
45 | static const TypeInfo sdhci_pci_info = { | ||
46 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) | ||
47 | { | ||
48 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
49 | |||
50 | - dc->vmsd = &sdhci_vmstate; | ||
51 | dc->props = sdhci_sysbus_properties; | ||
52 | dc->realize = sdhci_sysbus_realize; | ||
53 | - dc->reset = sdhci_poweron_reset; | ||
54 | + | ||
55 | + sdhci_common_class_init(klass, data); | ||
56 | } | ||
57 | |||
58 | static const TypeInfo sdhci_sysbus_info = { | ||
59 | -- | ||
60 | 2.7.4 | ||
61 | |||
62 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Mirror the behavour of /proc/sys/abi/sve_default_vector_length |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | under the real linux kernel. We have no way of passing along |
5 | Message-id: 20180115182436.2066-6-f4bug@amsat.org | 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. | ||
7 | |||
8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/482 | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20210723203344.968563-4-richard.henderson@linaro.org | ||
12 | [PMM: tweaked docs formatting, document -1 special-case, | ||
13 | added fixup patch from RTH mentioning QEMU's maximum veclen.] | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 15 | --- |
8 | hw/sd/sdhci.c | 30 +++++++++++++++++++++--------- | 16 | docs/system/arm/cpu-features.rst | 15 ++++++++ |
9 | 1 file changed, 21 insertions(+), 9 deletions(-) | 17 | target/arm/cpu.h | 5 +++ |
18 | target/arm/cpu.c | 14 ++++++-- | ||
19 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++ | ||
20 | 4 files changed, 92 insertions(+), 2 deletions(-) | ||
10 | 21 | ||
11 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 22 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst |
12 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sdhci.c | 24 | --- a/docs/system/arm/cpu-features.rst |
14 | +++ b/hw/sd/sdhci.c | 25 | +++ b/docs/system/arm/cpu-features.rst |
15 | @@ -XXX,XX +XXX,XX @@ static void sdhci_uninitfn(SDHCIState *s) | 26 | @@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector |
16 | s->fifo_buffer = NULL; | 27 | lengths is to explicitly enable each desired length. Therefore only |
28 | example's (1), (4), and (6) exhibit recommended uses of the properties. | ||
29 | |||
30 | +SVE User-mode Default Vector Length Property | ||
31 | +-------------------------------------------- | ||
32 | + | ||
33 | +For qemu-aarch64, the cpu property ``sve-default-vector-length=N`` is | ||
34 | +defined to mirror the Linux kernel parameter file | ||
35 | +``/proc/sys/abi/sve_default_vector_length``. The default length, ``N``, | ||
36 | +is in units of bytes and must be between 16 and 8192. | ||
37 | +If not specified, the default vector length is 64. | ||
38 | + | ||
39 | +If the default length is larger than the maximum vector length enabled, | ||
40 | +the actual vector length will be reduced. Note that the maximum vector | ||
41 | +length supported by QEMU is 256. | ||
42 | + | ||
43 | +If this property is set to ``-1`` then the default vector length | ||
44 | +is set to the maximum possible length. | ||
45 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/cpu.h | ||
48 | +++ b/target/arm/cpu.h | ||
49 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
50 | /* Used to set the maximum vector length the cpu will support. */ | ||
51 | uint32_t sve_max_vq; | ||
52 | |||
53 | +#ifdef CONFIG_USER_ONLY | ||
54 | + /* Used to set the default vector length at process start. */ | ||
55 | + uint32_t sve_default_vq; | ||
56 | +#endif | ||
57 | + | ||
58 | /* | ||
59 | * In sve_vq_map each set bit is a supported vector length of | ||
60 | * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector | ||
61 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
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; | ||
17 | } | 99 | } |
18 | 100 | ||
19 | +static void sdhci_common_realize(SDHCIState *s, Error **errp) | 101 | +#ifdef CONFIG_USER_ONLY |
102 | +/* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
103 | +static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
104 | + const char *name, void *opaque, | ||
105 | + Error **errp) | ||
20 | +{ | 106 | +{ |
21 | + s->buf_maxsz = sdhci_get_fifolen(s); | 107 | + ARMCPU *cpu = ARM_CPU(obj); |
22 | + s->fifo_buffer = g_malloc0(s->buf_maxsz); | 108 | + int32_t default_len, default_vq, remainder; |
23 | + | 109 | + |
24 | + memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci", | 110 | + if (!visit_type_int32(v, name, &default_len, errp)) { |
25 | + SDHC_REGISTERS_MAP_SIZE); | ||
26 | +} | ||
27 | + | ||
28 | static bool sdhci_pending_insert_vmstate_needed(void *opaque) | ||
29 | { | ||
30 | SDHCIState *s = opaque; | ||
31 | @@ -XXX,XX +XXX,XX @@ static Property sdhci_pci_properties[] = { | ||
32 | static void sdhci_pci_realize(PCIDevice *dev, Error **errp) | ||
33 | { | ||
34 | SDHCIState *s = PCI_SDHCI(dev); | ||
35 | + | ||
36 | + sdhci_initfn(s); | ||
37 | + sdhci_common_realize(s, errp); | ||
38 | + if (errp && *errp) { | ||
39 | + return; | 111 | + return; |
40 | + } | 112 | + } |
41 | + | 113 | + |
42 | dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */ | 114 | + /* Undocumented, but the kernel allows -1 to indicate "maximum". */ |
43 | dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */ | 115 | + if (default_len == -1) { |
44 | - sdhci_initfn(s); | 116 | + cpu->sve_default_vq = ARM_MAX_VQ; |
45 | - s->buf_maxsz = sdhci_get_fifolen(s); | ||
46 | - s->fifo_buffer = g_malloc0(s->buf_maxsz); | ||
47 | s->irq = pci_allocate_irq(dev); | ||
48 | - memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci", | ||
49 | - SDHC_REGISTERS_MAP_SIZE); | ||
50 | pci_register_bar(dev, 0, 0, &s->iomem); | ||
51 | } | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) | ||
54 | SDHCIState *s = SYSBUS_SDHCI(dev); | ||
55 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
56 | |||
57 | - s->buf_maxsz = sdhci_get_fifolen(s); | ||
58 | - s->fifo_buffer = g_malloc0(s->buf_maxsz); | ||
59 | + sdhci_common_realize(s, errp); | ||
60 | + if (errp && *errp) { | ||
61 | + return; | 117 | + return; |
62 | + } | 118 | + } |
63 | + | 119 | + |
64 | sysbus_init_irq(sbd, &s->irq); | 120 | + default_vq = default_len / 16; |
65 | - memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci", | 121 | + remainder = default_len % 16; |
66 | - SDHC_REGISTERS_MAP_SIZE); | 122 | + |
67 | sysbus_init_mmio(sbd, &s->iomem); | 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; | ||
141 | +} | ||
142 | + | ||
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) | ||
155 | { | ||
156 | uint32_t vq; | ||
157 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) | ||
158 | object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
159 | cpu_arm_set_sve_vq, NULL, NULL); | ||
160 | } | ||
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 | ||
68 | } | 168 | } |
69 | 169 | ||
170 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) | ||
70 | -- | 171 | -- |
71 | 2.7.4 | 172 | 2.20.1 |
72 | 173 | ||
73 | 174 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20180115182436.2066-8-f4bug@amsat.org | 5 | Message-id: 20210726150953.1218690-1-f4bug@amsat.org |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 7 | --- |
8 | hw/sd/sdhci.c | 7 ++++--- | 8 | hw/arm/nseries.c | 2 +- |
9 | 1 file changed, 4 insertions(+), 3 deletions(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 10 | ||
11 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 11 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sdhci.c | 13 | --- a/hw/arm/nseries.c |
14 | +++ b/hw/sd/sdhci.c | 14 | +++ b/hw/arm/nseries.c |
15 | @@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size) | 15 | @@ -XXX,XX +XXX,XX @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len) |
16 | ret = (SD_HOST_SPECv2_VERS << 16) | sdhci_slotint(s); | ||
17 | break; | ||
18 | default: | 16 | default: |
19 | - ERRPRINT("bad %ub read: addr[0x%04x]\n", size, (int)offset); | 17 | bad_cmd: |
20 | + qemu_log_mask(LOG_UNIMP, "SDHC rd_%ub @0x%02" HWADDR_PRIx " " | 18 | qemu_log_mask(LOG_GUEST_ERROR, |
21 | + "not implemented\n", size, offset); | 19 | - "%s: unknown command %02x\n", __func__, s->cmd); |
20 | + "%s: unknown command 0x%02x\n", __func__, s->cmd); | ||
22 | break; | 21 | break; |
23 | } | 22 | } |
24 | 23 | ||
25 | @@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) | ||
26 | sdhci_update_irq(s); | ||
27 | break; | ||
28 | default: | ||
29 | - ERRPRINT("bad %ub write offset: addr[0x%04x] <- %u(0x%x)\n", | ||
30 | - size, (int)offset, value >> shift, value >> shift); | ||
31 | + qemu_log_mask(LOG_UNIMP, "SDHC wr_%ub @0x%02" HWADDR_PRIx " <- 0x%08x " | ||
32 | + "not implemented\n", size, offset, value >> shift); | ||
33 | break; | ||
34 | } | ||
35 | DPRINT_L2("write %ub: addr[0x%04x] <- %u(0x%x)\n", | ||
36 | -- | 24 | -- |
37 | 2.7.4 | 25 | 2.20.1 |
38 | 26 | ||
39 | 27 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180115182436.2066-10-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/sd/sdhci-internal.h | 1 + | ||
9 | hw/sd/sdhci.c | 3 +-- | ||
10 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/sd/sdhci-internal.h | ||
15 | +++ b/hw/sd/sdhci-internal.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | #define SDHC_TRNS_ACMD12 0x0004 | ||
18 | #define SDHC_TRNS_READ 0x0010 | ||
19 | #define SDHC_TRNS_MULTI 0x0020 | ||
20 | +#define SDHC_TRNMOD_MASK 0x0037 | ||
21 | |||
22 | /* R/W Command Register 0x0 */ | ||
23 | #define SDHC_CMDREG 0x0E | ||
24 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/sd/sdhci.c | ||
27 | +++ b/hw/sd/sdhci.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | (SDHC_CAPAB_BASECLKFREQ << 8) | (SDHC_CAPAB_TOUNIT << 7) | \ | ||
30 | (SDHC_CAPAB_TOCLKFREQ)) | ||
31 | |||
32 | -#define MASK_TRNMOD 0x0037 | ||
33 | #define MASKED_WRITE(reg, mask, val) (reg = (reg & (mask)) | (val)) | ||
34 | |||
35 | static uint8_t sdhci_slotint(SDHCIState *s) | ||
36 | @@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) | ||
37 | if (!(s->capareg & SDHC_CAN_DO_DMA)) { | ||
38 | value &= ~SDHC_TRNS_DMA; | ||
39 | } | ||
40 | - MASKED_WRITE(s->trnmod, mask, value & MASK_TRNMOD); | ||
41 | + MASKED_WRITE(s->trnmod, mask, value & SDHC_TRNMOD_MASK); | ||
42 | MASKED_WRITE(s->cmdreg, mask >> 16, value >> 16); | ||
43 | |||
44 | /* Writing to the upper byte of CMDREG triggers SD command generation */ | ||
45 | -- | ||
46 | 2.7.4 | ||
47 | |||
48 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | While SysBus devices can use the get_system_memory() address space, | 3 | The macro used to calculate the maximum memory size of the MMIO region |
4 | PCI devices should use the bus master address space for DMA. | 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 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | 7 | This extra size doesn't matter on ast2400 and ast2500, which have a 4KB |
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | region set aside for the GPIO controller. |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | |
9 | Message-id: 20180115182436.2066-14-f4bug@amsat.org | 10 | On the ast2600 the 3.3V and 1.8V GPIO controllers are 2KB apart, so the |
11 | regions would overlap. Worse was the 1.8V controller would map over the | ||
12 | top of the following peripheral, which happens to be the RTC. | ||
13 | |||
14 | The mmio region used by each device is a maximum of 2KB, so avoid the | ||
15 | calculations and hard code this as the maximum. | ||
16 | |||
17 | Fixes: 36d737ee82b2 ("hw/gpio: Add in AST2600 specific implementation") | ||
18 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
19 | Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
21 | Message-id: 20210713065854.134634-2-joel@jms.id.au | ||
22 | [PMM: fix autocorrect error in commit message] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 24 | --- |
12 | include/hw/sd/sdhci.h | 1 + | 25 | hw/gpio/aspeed_gpio.c | 3 +-- |
13 | hw/sd/sdhci.c | 29 +++++++++++++++-------------- | 26 | 1 file changed, 1 insertion(+), 2 deletions(-) |
14 | 2 files changed, 16 insertions(+), 14 deletions(-) | ||
15 | 27 | ||
16 | diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h | 28 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c |
17 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/sd/sdhci.h | 30 | --- a/hw/gpio/aspeed_gpio.c |
19 | +++ b/include/hw/sd/sdhci.h | 31 | +++ b/hw/gpio/aspeed_gpio.c |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState { | 32 | @@ -XXX,XX +XXX,XX @@ |
21 | /*< public >*/ | 33 | #define GPIO_1_8V_MEM_SIZE 0x9D8 |
22 | SDBus sdbus; | 34 | #define GPIO_1_8V_REG_ARRAY_SIZE ((GPIO_1_8V_MEM_SIZE - \ |
23 | MemoryRegion iomem; | 35 | GPIO_1_8V_REG_OFFSET) >> 2) |
24 | + AddressSpace *dma_as; | 36 | -#define GPIO_MAX_MEM_SIZE MAX(GPIO_3_6V_MEM_SIZE, GPIO_1_8V_MEM_SIZE) |
25 | 37 | ||
26 | QEMUTimer *insert_timer; /* timer for 'changing' sd card. */ | 38 | static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) |
27 | QEMUTimer *transfer_timer; | 39 | { |
28 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | 40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_realize(DeviceState *dev, Error **errp) |
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/sd/sdhci.c | ||
31 | +++ b/hw/sd/sdhci.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) | ||
33 | s->blkcnt--; | ||
34 | } | ||
35 | } | ||
36 | - dma_memory_write(&address_space_memory, s->sdmasysad, | ||
37 | + dma_memory_write(s->dma_as, s->sdmasysad, | ||
38 | &s->fifo_buffer[begin], s->data_count - begin); | ||
39 | s->sdmasysad += s->data_count - begin; | ||
40 | if (s->data_count == block_size) { | ||
41 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) | ||
42 | s->data_count = block_size; | ||
43 | boundary_count -= block_size - begin; | ||
44 | } | ||
45 | - dma_memory_read(&address_space_memory, s->sdmasysad, | ||
46 | + dma_memory_read(s->dma_as, s->sdmasysad, | ||
47 | &s->fifo_buffer[begin], s->data_count - begin); | ||
48 | s->sdmasysad += s->data_count - begin; | ||
49 | if (s->data_count == block_size) { | ||
50 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sdma_transfer_single_block(SDHCIState *s) | ||
51 | for (n = 0; n < datacnt; n++) { | ||
52 | s->fifo_buffer[n] = sdbus_read_data(&s->sdbus); | ||
53 | } | ||
54 | - dma_memory_write(&address_space_memory, s->sdmasysad, s->fifo_buffer, | ||
55 | - datacnt); | ||
56 | + dma_memory_write(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt); | ||
57 | } else { | ||
58 | - dma_memory_read(&address_space_memory, s->sdmasysad, s->fifo_buffer, | ||
59 | - datacnt); | ||
60 | + dma_memory_read(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt); | ||
61 | for (n = 0; n < datacnt; n++) { | ||
62 | sdbus_write_data(&s->sdbus, s->fifo_buffer[n]); | ||
63 | } | ||
64 | @@ -XXX,XX +XXX,XX @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr) | ||
65 | hwaddr entry_addr = (hwaddr)s->admasysaddr; | ||
66 | switch (SDHC_DMA_TYPE(s->hostctl)) { | ||
67 | case SDHC_CTRL_ADMA2_32: | ||
68 | - dma_memory_read(&address_space_memory, entry_addr, (uint8_t *)&adma2, | ||
69 | + dma_memory_read(s->dma_as, entry_addr, (uint8_t *)&adma2, | ||
70 | sizeof(adma2)); | ||
71 | adma2 = le64_to_cpu(adma2); | ||
72 | /* The spec does not specify endianness of descriptor table. | ||
73 | @@ -XXX,XX +XXX,XX @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr) | ||
74 | dscr->incr = 8; | ||
75 | break; | ||
76 | case SDHC_CTRL_ADMA1_32: | ||
77 | - dma_memory_read(&address_space_memory, entry_addr, (uint8_t *)&adma1, | ||
78 | + dma_memory_read(s->dma_as, entry_addr, (uint8_t *)&adma1, | ||
79 | sizeof(adma1)); | ||
80 | adma1 = le32_to_cpu(adma1); | ||
81 | dscr->addr = (hwaddr)(adma1 & 0xFFFFF000); | ||
82 | @@ -XXX,XX +XXX,XX @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr) | ||
83 | } | ||
84 | break; | ||
85 | case SDHC_CTRL_ADMA2_64: | ||
86 | - dma_memory_read(&address_space_memory, entry_addr, | ||
87 | + dma_memory_read(s->dma_as, entry_addr, | ||
88 | (uint8_t *)(&dscr->attr), 1); | ||
89 | - dma_memory_read(&address_space_memory, entry_addr + 2, | ||
90 | + dma_memory_read(s->dma_as, entry_addr + 2, | ||
91 | (uint8_t *)(&dscr->length), 2); | ||
92 | dscr->length = le16_to_cpu(dscr->length); | ||
93 | - dma_memory_read(&address_space_memory, entry_addr + 4, | ||
94 | + dma_memory_read(s->dma_as, entry_addr + 4, | ||
95 | (uint8_t *)(&dscr->addr), 8); | ||
96 | dscr->attr = le64_to_cpu(dscr->attr); | ||
97 | dscr->attr &= 0xfffffff8; | ||
98 | @@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s) | ||
99 | s->data_count = block_size; | ||
100 | length -= block_size - begin; | ||
101 | } | ||
102 | - dma_memory_write(&address_space_memory, dscr.addr, | ||
103 | + dma_memory_write(s->dma_as, dscr.addr, | ||
104 | &s->fifo_buffer[begin], | ||
105 | s->data_count - begin); | ||
106 | dscr.addr += s->data_count - begin; | ||
107 | @@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s) | ||
108 | s->data_count = block_size; | ||
109 | length -= block_size - begin; | ||
110 | } | ||
111 | - dma_memory_read(&address_space_memory, dscr.addr, | ||
112 | + dma_memory_read(s->dma_as, dscr.addr, | ||
113 | &s->fifo_buffer[begin], | ||
114 | s->data_count - begin); | ||
115 | dscr.addr += s->data_count - begin; | ||
116 | @@ -XXX,XX +XXX,XX @@ static void sdhci_pci_realize(PCIDevice *dev, Error **errp) | ||
117 | dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */ | ||
118 | dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */ | ||
119 | s->irq = pci_allocate_irq(dev); | ||
120 | - pci_register_bar(dev, 0, 0, &s->iomem); | ||
121 | + s->dma_as = pci_get_address_space(dev); | ||
122 | + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->iomem); | ||
123 | } | ||
124 | |||
125 | static void sdhci_pci_exit(PCIDevice *dev) | ||
126 | @@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) | ||
127 | return; | ||
128 | } | 41 | } |
129 | 42 | ||
130 | + s->dma_as = &address_space_memory; | 43 | memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s, |
131 | + | 44 | - TYPE_ASPEED_GPIO, GPIO_MAX_MEM_SIZE); |
132 | sysbus_init_irq(sbd, &s->irq); | 45 | + TYPE_ASPEED_GPIO, 0x800); |
46 | |||
133 | sysbus_init_mmio(sbd, &s->iomem); | 47 | sysbus_init_mmio(sbd, &s->iomem); |
134 | } | 48 | } |
135 | -- | 49 | -- |
136 | 2.7.4 | 50 | 2.20.1 |
137 | 51 | ||
138 | 52 | diff view generated by jsdifflib |