1
More arm patches (mostly the SDHCI ones from Philippe)
1
target-arm queue for rc1 -- these are all bug fixes.
2
2
3
thanks
3
thanks
4
-- PMM
4
-- PMM
5
5
6
The following changes since commit f521eeee3bd060b460c99e605472b7e03967db43:
6
The following changes since commit b9404bf592e7ba74180e1a54ed7a266ec6ee67f2:
7
7
8
Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20180115' into staging (2018-01-15 13:17:47 +0000)
8
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20190715' into staging (2019-07-15 12:22:07 +0100)
9
9
10
are available in the git repository at:
10
are available in the Git repository at:
11
11
12
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180116
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190715
13
13
14
for you to fetch changes up to 60765b6ceeb4998a0d4220b3a53f1f185061da77:
14
for you to fetch changes up to 51c9122e92b776a3f16af0b9282f1dc5012e2a19:
15
15
16
sdhci: add a 'dma' property to the sysbus devices (2018-01-16 13:28:21 +0000)
16
target/arm: NS BusFault on vector table fetch escalates to NS HardFault (2019-07-15 14:17:04 +0100)
17
17
18
----------------------------------------------------------------
18
----------------------------------------------------------------
19
target-arm queue:
19
target-arm queue:
20
* SDHCI: cleanups and minor bug fixes
20
* report ARMv8-A FP support for AArch32 -cpu max
21
* target/arm: minor refactor preparatory to fp16 support
21
* hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory
22
* omap_ssd, ssi-sd, pl181, milkymist-memcard: reset the SD
22
* hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[]
23
card on controller reset (fixes migration failures)
23
* hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO
24
* target/arm: Handle page table walk load failures correctly
24
* hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO
25
* hw/arm/virt: Add virt-2.12 machine type
25
* hw/arm/virt: Fix non-secure flash mode
26
* get_phys_addr_pmsav7: Support AP=0b111 for v7M
26
* pl031: Correctly migrate state when using -rtc clock=host
27
* hw/intc/armv7m: Support byte and halfword accesses to CFSR
27
* fix regression that meant arm926 and arm1026 lost VFP
28
double-precision support
29
* v8M: NS BusFault on vector table fetch escalates to NS HardFault
28
30
29
----------------------------------------------------------------
31
----------------------------------------------------------------
30
Andrey Smirnov (1):
32
Alex Bennée (1):
31
sdhci: Implement write method of ACMD12ERRSTS register
33
target/arm: report ARMv8-A FP support for AArch32 -cpu max
32
34
33
Peter Maydell (8):
35
David Engraf (1):
34
hw/intc/armv7m: Support byte and halfword accesses to CFSR
36
hw/arm/virt: Fix non-secure flash mode
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
37
43
Philippe Mathieu-Daudé (13):
38
Peter Maydell (3):
44
sdhci: clean up includes
39
pl031: Correctly migrate state when using -rtc clock=host
45
sdhci: remove dead code
40
target/arm: Set VFP-related MVFR0 fields for arm926 and arm1026
46
sdhci: use DEFINE_SDHCI_COMMON_PROPERTIES() for common sysbus/pci properties
41
target/arm: NS BusFault on vector table fetch escalates to NS HardFault
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
42
58
Richard Henderson (2):
43
Philippe Mathieu-Daudé (5):
59
target/arm: Split out vfp_expand_imm
44
hw/ssi/xilinx_spips: Convert lqspi_read() to read_with_attrs
60
target/arm: Add fp16 support to vfp_expand_imm
45
hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory
46
hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[]
47
hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO
48
hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO
61
49
62
hw/sd/sdhci-internal.h | 7 +-
50
include/hw/timer/pl031.h | 2 ++
63
include/hw/sd/sdhci.h | 19 +++-
51
hw/arm/virt.c | 2 +-
64
target/arm/internals.h | 10 ++
52
hw/core/machine.c | 1 +
65
hw/arm/virt.c | 19 +++-
53
hw/display/xlnx_dp.c | 15 +++++---
66
hw/intc/armv7m_nvic.c | 38 ++++---
54
hw/ssi/mss-spi.c | 8 ++++-
67
hw/sd/milkymist-memcard.c | 4 +
55
hw/ssi/xilinx_spips.c | 43 +++++++++++++++-------
68
hw/sd/omap_mmc.c | 14 ++-
56
hw/timer/pl031.c | 92 +++++++++++++++++++++++++++++++++++++++++++++---
69
hw/sd/pl181.c | 4 +
57
target/arm/cpu.c | 16 +++++++++
70
hw/sd/sdhci.c | 266 +++++++++++++++++++++++++++------------------
58
target/arm/m_helper.c | 21 ++++++++---
71
hw/sd/ssi-sd.c | 25 ++++-
59
9 files changed, 174 insertions(+), 26 deletions(-)
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
60
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Alex Bennée <alex.bennee@linaro.org>
2
2
3
Add a 'dma' property allowing machine creation to provide the address-space
3
When we converted to using feature bits in 602f6e42cfbf we missed out
4
SDHCI DMA operates on.
4
the fact (dp && arm_dc_feature(s, ARM_FEATURE_V8)) was supported for
5
-cpu max configurations. This caused a regression in the GCC test
6
suite. Fix this by setting the appropriate bits in mvfr1.FPHP to
7
report ARMv8-A with FP support (but not ARMv8.2-FP16).
5
8
6
[based on a patch from Alistair Francis <alistair.francis@xilinx.com>
9
Fixes: https://bugs.launchpad.net/qemu/+bug/1836078
7
from qemu/xilinx tag xilinx-v2016.1]
10
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180115182436.2066-15-f4bug@amsat.org
12
Message-id: 20190711103737.10017-1-alex.bennee@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
14
---
12
include/hw/sd/sdhci.h | 1 +
15
target/arm/cpu.c | 4 ++++
13
hw/sd/sdhci.c | 18 +++++++++++++++++-
16
1 file changed, 4 insertions(+)
14
2 files changed, 18 insertions(+), 1 deletion(-)
15
17
16
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
18
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/sd/sdhci.h
20
--- a/target/arm/cpu.c
19
+++ b/include/hw/sd/sdhci.h
21
+++ b/target/arm/cpu.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
22
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
21
SDBus sdbus;
23
t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);
22
MemoryRegion iomem;
24
cpu->isar.id_isar6 = t;
23
AddressSpace *dma_as;
25
24
+ MemoryRegion *dma_mr;
26
+ t = cpu->isar.mvfr1;
25
27
+ t = FIELD_DP32(t, MVFR1, FPHP, 2); /* v8.0 FP support */
26
QEMUTimer *insert_timer; /* timer for 'changing' sd card. */
28
+ cpu->isar.mvfr1 = t;
27
QEMUTimer *transfer_timer;
28
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
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
+
29
+
46
+ if (s->dma_mr) {
30
t = cpu->isar.mvfr2;
47
+ object_unparent(OBJECT(s->dma_mr));
31
t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
48
+ }
32
t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
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
--
33
--
79
2.7.4
34
2.20.1
80
35
81
36
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
In the next commit we will implement the write_with_attrs()
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
4
handler. To avoid using different APIs, convert the read()
5
Message-id: 20180115182436.2066-6-f4bug@amsat.org
5
handler first.
6
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
hw/sd/sdhci.c | 30 +++++++++++++++++++++---------
12
hw/ssi/xilinx_spips.c | 23 +++++++++++------------
9
1 file changed, 21 insertions(+), 9 deletions(-)
13
1 file changed, 11 insertions(+), 12 deletions(-)
10
14
11
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
15
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/sd/sdhci.c
17
--- a/hw/ssi/xilinx_spips.c
14
+++ b/hw/sd/sdhci.c
18
+++ b/hw/ssi/xilinx_spips.c
15
@@ -XXX,XX +XXX,XX @@ static void sdhci_uninitfn(SDHCIState *s)
19
@@ -XXX,XX +XXX,XX @@ static void lqspi_load_cache(void *opaque, hwaddr addr)
16
s->fifo_buffer = NULL;
20
}
17
}
21
}
18
22
19
+static void sdhci_common_realize(SDHCIState *s, Error **errp)
23
-static uint64_t
20
+{
24
-lqspi_read(void *opaque, hwaddr addr, unsigned int size)
21
+ s->buf_maxsz = sdhci_get_fifolen(s);
25
+static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value,
22
+ s->fifo_buffer = g_malloc0(s->buf_maxsz);
26
+ unsigned size, MemTxAttrs attrs)
27
{
28
- XilinxQSPIPS *q = opaque;
29
- uint32_t ret;
30
+ XilinxQSPIPS *q = XILINX_QSPIPS(opaque);
31
32
if (addr >= q->lqspi_cached_addr &&
33
addr <= q->lqspi_cached_addr + LQSPI_CACHE_SIZE - 4) {
34
uint8_t *retp = &q->lqspi_buf[addr - q->lqspi_cached_addr];
35
- ret = cpu_to_le32(*(uint32_t *)retp);
36
- DB_PRINT_L(1, "addr: %08x, data: %08x\n", (unsigned)addr,
37
- (unsigned)ret);
38
- return ret;
39
- } else {
40
- lqspi_load_cache(opaque, addr);
41
- return lqspi_read(opaque, addr, size);
42
+ *value = cpu_to_le32(*(uint32_t *)retp);
43
+ DB_PRINT_L(1, "addr: %08" HWADDR_PRIx ", data: %08" PRIx64 "\n",
44
+ addr, *value);
45
+ return MEMTX_OK;
46
}
23
+
47
+
24
+ memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci",
48
+ lqspi_load_cache(opaque, addr);
25
+ SDHC_REGISTERS_MAP_SIZE);
49
+ return lqspi_read(opaque, addr, value, size, attrs);
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;
40
+ }
41
+
42
dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */
43
dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
44
- sdhci_initfn(s);
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
}
50
}
52
51
53
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
52
static const MemoryRegionOps lqspi_ops = {
54
SDHCIState *s = SYSBUS_SDHCI(dev);
53
- .read = lqspi_read,
55
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
54
+ .read_with_attrs = lqspi_read,
56
55
.endianness = DEVICE_NATIVE_ENDIAN,
57
- s->buf_maxsz = sdhci_get_fifolen(s);
56
.valid = {
58
- s->fifo_buffer = g_malloc0(s->buf_maxsz);
57
.min_access_size = 1,
59
+ sdhci_common_realize(s, errp);
60
+ if (errp && *errp) {
61
+ return;
62
+ }
63
+
64
sysbus_init_irq(sbd, &s->irq);
65
- memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci",
66
- SDHC_REGISTERS_MAP_SIZE);
67
sysbus_init_mmio(sbd, &s->iomem);
68
}
69
70
--
58
--
71
2.7.4
59
2.20.1
72
60
73
61
diff view generated by jsdifflib
1
Instead of ignoring the response from address_space_ld*()
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
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
Lei Sun found while auditing the code that a CPU write would
7
decide the value of the ARMMMUFaultInfo ea bit based on a
4
trigger a NULL pointer dereference.
8
MemTxResult, we factor out that operation into a helper
9
function.
10
5
6
>From UG1085 datasheet [*] AXI writes in this region are ignored
7
and generates an AXI Slave Error (SLVERR).
8
9
Fix by implementing the write_with_attrs() handler.
10
Return MEMTX_ERROR when the region is accessed (this error maps
11
to an AXI slave error).
12
13
[*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf
14
15
Reported-by: Lei Sun <slei.casper@gmail.com>
16
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
17
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
18
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
20
---
13
target/arm/internals.h | 10 ++++++++++
21
hw/ssi/xilinx_spips.c | 16 ++++++++++++++++
14
target/arm/helper.c | 39 ++++++++++++++++++++++++++++++++++-----
22
1 file changed, 16 insertions(+)
15
target/arm/op_helper.c | 7 +------
16
3 files changed, 45 insertions(+), 11 deletions(-)
17
23
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
24
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
19
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/internals.h
26
--- a/hw/ssi/xilinx_spips.c
21
+++ b/target/arm/internals.h
27
+++ b/hw/ssi/xilinx_spips.c
22
@@ -XXX,XX +XXX,XX @@ static inline uint32_t arm_fi_to_lfsc(ARMMMUFaultInfo *fi)
28
@@ -XXX,XX +XXX,XX @@ static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value,
23
return fsc;
29
return lqspi_read(opaque, addr, value, size, attrs);
24
}
30
}
25
31
26
+static inline bool arm_extabort_type(MemTxResult result)
32
+static MemTxResult lqspi_write(void *opaque, hwaddr offset, uint64_t value,
33
+ unsigned size, MemTxAttrs attrs)
27
+{
34
+{
28
+ /* The EA bit in syndromes and fault status registers is an
35
+ /*
29
+ * IMPDEF classification of external aborts. ARM implementations
36
+ * From UG1085, Chapter 24 (Quad-SPI controllers):
30
+ * usually use this to indicate AXI bus Decode error (0) or
37
+ * - Writes are ignored
31
+ * Slave error (1); in QEMU we follow that.
38
+ * - AXI writes generate an external AXI slave error (SLVERR)
32
+ */
39
+ */
33
+ return result != MEMTX_DECODE_ERROR;
40
+ qemu_log_mask(LOG_GUEST_ERROR, "%s Unexpected %u-bit access to 0x%" PRIx64
41
+ " (value: 0x%" PRIx64 "\n",
42
+ __func__, size << 3, offset, value);
43
+
44
+ return MEMTX_ERROR;
34
+}
45
+}
35
+
46
+
36
/* Do a page table walk and add page to TLB if possible */
47
static const MemoryRegionOps lqspi_ops = {
37
bool arm_tlb_fill(CPUState *cpu, vaddr address,
48
.read_with_attrs = lqspi_read,
38
MMUAccessType access_type, int mmu_idx,
49
+ .write_with_attrs = lqspi_write,
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
50
.endianness = DEVICE_NATIVE_ENDIAN,
40
index XXXXXXX..XXXXXXX 100644
51
.valid = {
41
--- a/target/arm/helper.c
52
.min_access_size = 1,
42
+++ b/target/arm/helper.c
43
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
44
ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa,
45
&txattrs, &s2prot, &s2size, fi, NULL);
46
if (ret) {
47
+ assert(fi->type != ARMFault_None);
48
fi->s2addr = addr;
49
fi->stage2 = true;
50
fi->s1ptw = true;
51
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure,
52
ARMCPU *cpu = ARM_CPU(cs);
53
CPUARMState *env = &cpu->env;
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
}
64
if (regime_translation_big_endian(env, mmu_idx)) {
65
- return address_space_ldl_be(as, addr, attrs, NULL);
66
+ data = address_space_ldl_be(as, addr, attrs, &result);
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
}
78
79
static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,
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
--
53
--
177
2.7.4
54
2.20.1
178
55
179
56
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
While SysBus devices can use the get_system_memory() address space,
3
Both lqspi_read() and lqspi_load_cache() expect a 32-bit
4
PCI devices should use the bus master address space for DMA.
4
aligned address.
5
5
6
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
6
>From UG1085 datasheet [*] chapter on 'Quad-SPI Controller':
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Transfer Size Limitations
9
Message-id: 20180115182436.2066-14-f4bug@amsat.org
9
10
Because of the 32-bit wide TX, RX, and generic FIFO, all
11
APB/AXI transfers must be an integer multiple of 4-bytes.
12
Shorter transfers are not possible.
13
14
Set MemoryRegionOps.impl values to force 32-bit accesses,
15
this way we are sure we do not access the lqspi_buf[] array
16
out of bound.
17
18
[*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf
19
20
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
21
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
22
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
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/ssi/xilinx_spips.c | 4 ++++
13
hw/sd/sdhci.c | 29 +++++++++++++++--------------
26
1 file changed, 4 insertions(+)
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/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
17
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/sd/sdhci.h
30
--- a/hw/ssi/xilinx_spips.c
19
+++ b/include/hw/sd/sdhci.h
31
+++ b/hw/ssi/xilinx_spips.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
32
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps lqspi_ops = {
21
/*< public >*/
33
.read_with_attrs = lqspi_read,
22
SDBus sdbus;
34
.write_with_attrs = lqspi_write,
23
MemoryRegion iomem;
35
.endianness = DEVICE_NATIVE_ENDIAN,
24
+ AddressSpace *dma_as;
36
+ .impl = {
25
37
+ .min_access_size = 4,
26
QEMUTimer *insert_timer; /* timer for 'changing' sd card. */
38
+ .max_access_size = 4,
27
QEMUTimer *transfer_timer;
39
+ },
28
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
40
.valid = {
29
index XXXXXXX..XXXXXXX 100644
41
.min_access_size = 1,
30
--- a/hw/sd/sdhci.c
42
.max_access_size = 4
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
}
129
130
+ s->dma_as = &address_space_memory;
131
+
132
sysbus_init_irq(sbd, &s->irq);
133
sysbus_init_mmio(sbd, &s->iomem);
134
}
135
--
43
--
136
2.7.4
44
2.20.1
137
45
138
46
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
3
Reading the RX_DATA register when the RX_FIFO is empty triggers
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
an abort. This can be easily reproduced:
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
6
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
6
$ qemu-system-arm -M emcraft-sf2 -monitor stdio -S
7
Message-id: 20180115182436.2066-13-f4bug@amsat.org
7
QEMU 4.0.50 monitor - type 'help' for more information
8
(qemu) x 0x40001010
9
Aborted (core dumped)
10
11
(gdb) bt
12
#1 0x00007f035874f895 in abort () at /lib64/libc.so.6
13
#2 0x00005628686591ff in fifo8_pop (fifo=0x56286a9a4c68) at util/fifo8.c:66
14
#3 0x00005628683e0b8e in fifo32_pop (fifo=0x56286a9a4c68) at include/qemu/fifo32.h:137
15
#4 0x00005628683e0efb in spi_read (opaque=0x56286a9a4850, addr=4, size=4) at hw/ssi/mss-spi.c:168
16
#5 0x0000562867f96801 in memory_region_read_accessor (mr=0x56286a9a4b60, addr=16, value=0x7ffeecb0c5c8, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:439
17
#6 0x0000562867f96cdb in access_with_adjusted_size (addr=16, value=0x7ffeecb0c5c8, size=4, access_size_min=1, access_size_max=4, access_fn=0x562867f967c3 <memory_region_read_accessor>, mr=0x56286a9a4b60, attrs=...) at memory.c:569
18
#7 0x0000562867f99940 in memory_region_dispatch_read1 (mr=0x56286a9a4b60, addr=16, pval=0x7ffeecb0c5c8, size=4, attrs=...) at memory.c:1420
19
#8 0x0000562867f99a08 in memory_region_dispatch_read (mr=0x56286a9a4b60, addr=16, pval=0x7ffeecb0c5c8, size=4, attrs=...) at memory.c:1447
20
#9 0x0000562867f38721 in flatview_read_continue (fv=0x56286aec6360, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, addr1=16, l=4, mr=0x56286a9a4b60) at exec.c:3385
21
#10 0x0000562867f38874 in flatview_read (fv=0x56286aec6360, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4) at exec.c:3423
22
#11 0x0000562867f388ea in address_space_read_full (as=0x56286aa3e890, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4) at exec.c:3436
23
#12 0x0000562867f389c5 in address_space_rw (as=0x56286aa3e890, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, is_write=false) at exec.c:3466
24
#13 0x0000562867f3bdd7 in cpu_memory_rw_debug (cpu=0x56286aa19d00, addr=1073745936, buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, is_write=0) at exec.c:3976
25
#14 0x000056286811ed51 in memory_dump (mon=0x56286a8c32d0, count=1, format=120, wsize=4, addr=1073745936, is_physical=0) at monitor/misc.c:730
26
#15 0x000056286811eff1 in hmp_memory_dump (mon=0x56286a8c32d0, qdict=0x56286b15c400) at monitor/misc.c:785
27
#16 0x00005628684740ee in handle_hmp_command (mon=0x56286a8c32d0, cmdline=0x56286a8caeb2 "0x40001010") at monitor/hmp.c:1082
28
29
From the datasheet "Actel SmartFusion Microcontroller Subsystem
30
User's Guide" Rev.1, Table 13-3 "SPI Register Summary", this
31
register has a reset value of 0.
32
33
Check the FIFO is not empty before accessing it, else log an
34
error message.
35
36
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
37
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
38
Message-id: 20190709113715.7761-3-philmd@redhat.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
39
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
40
---
10
hw/sd/sdhci.c | 3 +++
41
hw/ssi/mss-spi.c | 8 +++++++-
11
1 file changed, 3 insertions(+)
42
1 file changed, 7 insertions(+), 1 deletion(-)
12
43
13
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
44
diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c
14
index XXXXXXX..XXXXXXX 100644
45
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/sd/sdhci.c
46
--- a/hw/ssi/mss-spi.c
16
+++ b/hw/sd/sdhci.c
47
+++ b/hw/ssi/mss-spi.c
17
@@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
48
@@ -XXX,XX +XXX,XX @@ spi_read(void *opaque, hwaddr addr, unsigned int size)
49
case R_SPI_RX:
50
s->regs[R_SPI_STATUS] &= ~S_RXFIFOFUL;
51
s->regs[R_SPI_STATUS] &= ~S_RXCHOVRF;
52
- ret = fifo32_pop(&s->rx_fifo);
53
+ if (fifo32_is_empty(&s->rx_fifo)) {
54
+ qemu_log_mask(LOG_GUEST_ERROR,
55
+ "%s: Reading empty RX_FIFO\n",
56
+ __func__);
57
+ } else {
58
+ ret = fifo32_pop(&s->rx_fifo);
59
+ }
60
if (fifo32_is_empty(&s->rx_fifo)) {
61
s->regs[R_SPI_STATUS] |= S_RXFIFOEMP;
18
}
62
}
19
sdhci_update_irq(s);
20
break;
21
+ case SDHC_ACMD12ERRSTS:
22
+ MASKED_WRITE(s->acmd12errsts, mask, value);
23
+ break;
24
25
case SDHC_CAPAB:
26
case SDHC_CAPAB + 4:
27
--
63
--
28
2.7.4
64
2.20.1
29
65
30
66
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
zero-initialize ADMADescr 'dscr' in sdhci_do_adma() to avoid:
3
In the previous commit we fixed a crash when the guest read a
4
register that pop from an empty FIFO.
5
By auditing the repository, we found another similar use with
6
an easy way to reproduce:
4
7
5
hw/sd/sdhci.c: In function ‘sdhci_do_adma’:
8
$ qemu-system-aarch64 -M xlnx-zcu102 -monitor stdio -S
6
hw/sd/sdhci.c:714:29: error: ‘dscr.addr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
9
QEMU 4.0.50 monitor - type 'help' for more information
7
trace_sdhci_adma("link", s->admasysaddr);
10
(qemu) xp/b 0xfd4a0134
8
^
11
Aborted (core dumped)
9
12
10
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
(gdb) bt
11
Acked-by: Alistair Francis <alistair.francis@xilinx.com>
14
#0 0x00007f6936dea57f in raise () at /lib64/libc.so.6
12
Message-id: 20180115182436.2066-9-f4bug@amsat.org
15
#1 0x00007f6936dd4895 in abort () at /lib64/libc.so.6
16
#2 0x0000561ad32975ec in xlnx_dp_aux_pop_rx_fifo (s=0x7f692babee70) at hw/display/xlnx_dp.c:431
17
#3 0x0000561ad3297dc0 in xlnx_dp_read (opaque=0x7f692babee70, offset=77, size=4) at hw/display/xlnx_dp.c:667
18
#4 0x0000561ad321b896 in memory_region_read_accessor (mr=0x7f692babf620, addr=308, value=0x7ffe05c1db88, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:439
19
#5 0x0000561ad321bd70 in access_with_adjusted_size (addr=308, value=0x7ffe05c1db88, size=1, access_size_min=4, access_size_max=4, access_fn=0x561ad321b858 <memory_region_read_accessor>, mr=0x7f692babf620, attrs=...) at memory.c:569
20
#6 0x0000561ad321e9d5 in memory_region_dispatch_read1 (mr=0x7f692babf620, addr=308, pval=0x7ffe05c1db88, size=1, attrs=...) at memory.c:1420
21
#7 0x0000561ad321ea9d in memory_region_dispatch_read (mr=0x7f692babf620, addr=308, pval=0x7ffe05c1db88, size=1, attrs=...) at memory.c:1447
22
#8 0x0000561ad31bd742 in flatview_read_continue (fv=0x561ad69c04f0, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1, addr1=308, l=1, mr=0x7f692babf620) at exec.c:3385
23
#9 0x0000561ad31bd895 in flatview_read (fv=0x561ad69c04f0, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1) at exec.c:3423
24
#10 0x0000561ad31bd90b in address_space_read_full (as=0x561ad5bb3020, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1) at exec.c:3436
25
#11 0x0000561ad33b1c42 in address_space_read (len=1, buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", attrs=..., addr=4249485620, as=0x561ad5bb3020) at include/exec/memory.h:2131
26
#12 0x0000561ad33b1c42 in memory_dump (mon=0x561ad59c4530, count=1, format=120, wsize=1, addr=4249485620, is_physical=1) at monitor/misc.c:723
27
#13 0x0000561ad33b1fc1 in hmp_physical_memory_dump (mon=0x561ad59c4530, qdict=0x561ad6c6fd00) at monitor/misc.c:795
28
#14 0x0000561ad37b4a9f in handle_hmp_command (mon=0x561ad59c4530, cmdline=0x561ad59d0f22 "/b 0x00000000fd4a0134") at monitor/hmp.c:1082
29
30
Fix by checking the FIFO is not empty before popping from it.
31
32
The datasheet is not clear about the reset value of this register,
33
we choose to return '0'.
34
35
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
36
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
37
Message-id: 20190709113715.7761-4-philmd@redhat.com
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
38
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
39
---
15
hw/sd/sdhci.c | 89 ++++++++++++++++++------------------------------------
40
hw/display/xlnx_dp.c | 15 +++++++++++----
16
hw/sd/trace-events | 14 +++++++++
41
1 file changed, 11 insertions(+), 4 deletions(-)
17
2 files changed, 44 insertions(+), 59 deletions(-)
18
42
19
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
43
diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c
20
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/sd/sdhci.c
45
--- a/hw/display/xlnx_dp.c
22
+++ b/hw/sd/sdhci.c
46
+++ b/hw/display/xlnx_dp.c
23
@@ -XXX,XX +XXX,XX @@
47
@@ -XXX,XX +XXX,XX @@ static uint8_t xlnx_dp_aux_pop_rx_fifo(XlnxDPState *s)
24
#include "sdhci-internal.h"
48
uint8_t ret;
25
#include "qapi/error.h"
49
26
#include "qemu/log.h"
50
if (fifo8_is_empty(&s->rx_fifo)) {
27
-
51
- DPRINTF("rx_fifo underflow..\n");
28
-/* host controller debug messages */
52
- abort();
29
-#ifndef SDHC_DEBUG
53
+ qemu_log_mask(LOG_GUEST_ERROR,
30
-#define SDHC_DEBUG 0
54
+ "%s: Reading empty RX_FIFO\n",
31
-#endif
55
+ __func__);
32
-
56
+ /*
33
-#define DPRINT_L1(fmt, args...) \
57
+ * The datasheet is not clear about the reset value, it seems
34
- do { \
58
+ * to be unspecified. We choose to return '0'.
35
- if (SDHC_DEBUG) { \
59
+ */
36
- fprintf(stderr, "QEMU SDHC: " fmt, ## args); \
60
+ ret = 0;
37
- } \
61
+ } else {
38
- } while (0)
62
+ ret = fifo8_pop(&s->rx_fifo);
39
-#define DPRINT_L2(fmt, args...) \
63
+ DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret);
40
- do { \
41
- if (SDHC_DEBUG > 1) { \
42
- fprintf(stderr, "QEMU SDHC: " fmt, ## args); \
43
- } \
44
- } while (0)
45
-#define ERRPRINT(fmt, args...) \
46
- do { \
47
- if (SDHC_DEBUG) { \
48
- fprintf(stderr, "QEMU SDHC ERROR: " fmt, ## args); \
49
- } \
50
- } while (0)
51
+#include "trace.h"
52
53
#define TYPE_SDHCI_BUS "sdhci-bus"
54
#define SDHCI_BUS(obj) OBJECT_CHECK(SDBus, (obj), TYPE_SDHCI_BUS)
55
@@ -XXX,XX +XXX,XX @@ static void sdhci_raise_insertion_irq(void *opaque)
56
static void sdhci_set_inserted(DeviceState *dev, bool level)
57
{
58
SDHCIState *s = (SDHCIState *)dev;
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
+ trace_sdhci_send_command(request.cmd, request.arg);
72
rlen = sdbus_do_command(&s->sdbus, &request, response);
73
74
if (s->cmdreg & SDHC_CMD_RESPONSE) {
75
@@ -XXX,XX +XXX,XX @@ static void sdhci_send_command(SDHCIState *s)
76
s->rspreg[0] = (response[0] << 24) | (response[1] << 16) |
77
(response[2] << 8) | response[3];
78
s->rspreg[1] = s->rspreg[2] = s->rspreg[3] = 0;
79
- DPRINT_L1("Response: RSPREG[31..0]=0x%08x\n", s->rspreg[0]);
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 {
94
- ERRPRINT("Timeout waiting for command response\n");
95
+ trace_sdhci_error("timeout waiting for command response");
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
}
64
}
116
65
- ret = fifo8_pop(&s->rx_fifo);
117
@@ -XXX,XX +XXX,XX @@ static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size)
66
- DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret);
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
}
258
break;
259
@@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
260
261
ret >>= (offset & 0x3) * 8;
262
ret &= (1ULL << (size * 8)) - 1;
263
- DPRINT_L2("read %ub: addr[0x%04x] -> %u(0x%x)\n", size, (int)offset, ret, ret);
264
+ trace_sdhci_access("rd", size << 3, offset, "->", ret, ret);
265
return ret;
67
return ret;
266
}
68
}
267
69
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;
271
}
272
- DPRINT_L2("write %ub: addr[0x%04x] <- %u(0x%x)\n",
273
- size, (int)offset, value >> shift, value >> shift);
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
--
70
--
304
2.7.4
71
2.20.1
305
72
306
73
diff view generated by jsdifflib
1
Add virt-2.12 machine type.
1
From: David Engraf <david.engraf@sysgo.com>
2
2
3
Using the whole 128 MiB flash in non-secure mode is not working because
4
virt_flash_fdt() expects the same address for secure_sysmem and sysmem.
5
This is not correctly handled by caller because it forwards NULL for
6
secure_sysmem in non-secure flash mode.
7
8
Fixed by using sysmem when secure_sysmem is NULL.
9
10
Signed-off-by: David Engraf <david.engraf@sysgo.com>
11
Message-id: 20190712075002.14326-1-david.engraf@sysgo.com
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
---
14
---
5
hw/arm/virt.c | 19 +++++++++++++++++--
15
hw/arm/virt.c | 2 +-
6
1 file changed, 17 insertions(+), 2 deletions(-)
16
1 file changed, 1 insertion(+), 1 deletion(-)
7
17
8
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
18
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
9
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
10
--- a/hw/arm/virt.c
20
--- a/hw/arm/virt.c
11
+++ b/hw/arm/virt.c
21
+++ b/hw/arm/virt.c
12
@@ -XXX,XX +XXX,XX @@ static void machvirt_machine_init(void)
22
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
13
}
23
&machine->device_memory->mr);
14
type_init(machvirt_machine_init);
24
}
15
25
16
-static void virt_2_11_instance_init(Object *obj)
26
- virt_flash_fdt(vms, sysmem, secure_sysmem);
17
+static void virt_2_12_instance_init(Object *obj)
27
+ virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
18
{
28
19
VirtMachineState *vms = VIRT_MACHINE(obj);
29
create_gic(vms, pic);
20
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
30
21
@@ -XXX,XX +XXX,XX @@ static void virt_2_11_instance_init(Object *obj)
22
vms->irqmap = a15irqmap;
23
}
24
25
+static void virt_machine_2_12_options(MachineClass *mc)
26
+{
27
+}
28
+DEFINE_VIRT_MACHINE_AS_LATEST(2, 12)
29
+
30
+#define VIRT_COMPAT_2_11 \
31
+ HW_COMPAT_2_11
32
+
33
+static void virt_2_11_instance_init(Object *obj)
34
+{
35
+ virt_2_12_instance_init(obj);
36
+}
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
--
31
--
49
2.7.4
32
2.20.1
50
33
51
34
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
The PL031 RTC tracks the difference between the guest RTC
2
2
and the host RTC using a tick_offset field. For migration,
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
however, we currently always migrate the offset between
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
4
the guest and the vm_clock, even if the RTC clock is not
5
Message-id: 20180115182436.2066-7-f4bug@amsat.org
5
the same as the vm_clock; this was an attempt to retain
6
migration backwards compatibility.
7
8
Unfortunately this results in the RTC behaving oddly across
9
a VM state save and restore -- since the VM clock stands still
10
across save-then-restore, regardless of how much real world
11
time has elapsed, the guest RTC ends up out of sync with the
12
host RTC in the restored VM.
13
14
Fix this by migrating the raw tick_offset. To retain migration
15
compatibility as far as possible, we have a new property
16
migrate-tick-offset; by default this is 'true' and we will
17
migrate the true tick offset in a new subsection; if the
18
incoming data has no subsection we fall back to the old
19
vm_clock-based offset information, so old->new migration
20
compatibility is preserved. For complete new->old migration
21
compatibility, the property is set to 'false' for 4.0 and
22
earlier machine types (this will only affect 'virt-4.0'
23
and below, as none of the other pl031-using machines are
24
versioned).
25
26
Reported-by: Russell King <rmk@armlinux.org.uk>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
29
Message-id: 20190709143912.28905-1-peter.maydell@linaro.org
7
---
30
---
8
hw/sd/sdhci.c | 22 ++++++++++++++++++++++
31
include/hw/timer/pl031.h | 2 +
9
1 file changed, 22 insertions(+)
32
hw/core/machine.c | 1 +
10
33
hw/timer/pl031.c | 92 ++++++++++++++++++++++++++++++++++++++--
11
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
34
3 files changed, 91 insertions(+), 4 deletions(-)
35
36
diff --git a/include/hw/timer/pl031.h b/include/hw/timer/pl031.h
12
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/sd/sdhci.c
38
--- a/include/hw/timer/pl031.h
14
+++ b/hw/sd/sdhci.c
39
+++ b/include/hw/timer/pl031.h
15
@@ -XXX,XX +XXX,XX @@
40
@@ -XXX,XX +XXX,XX @@ typedef struct PL031State {
16
#include "qemu/bitops.h"
41
*/
17
#include "hw/sd/sdhci.h"
42
uint32_t tick_offset_vmstate;
18
#include "sdhci-internal.h"
43
uint32_t tick_offset;
19
+#include "qapi/error.h"
44
+ bool tick_offset_migrated;
20
#include "qemu/log.h"
45
+ bool migrate_tick_offset;
21
46
22
/* host controller debug messages */
47
uint32_t mr;
23
@@ -XXX,XX +XXX,XX @@ static void sdhci_common_realize(SDHCIState *s, Error **errp)
48
uint32_t lr;
24
SDHC_REGISTERS_MAP_SIZE);
49
diff --git a/hw/core/machine.c b/hw/core/machine.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/core/machine.c
52
+++ b/hw/core/machine.c
53
@@ -XXX,XX +XXX,XX @@ GlobalProperty hw_compat_4_0[] = {
54
{ "virtio-gpu-pci", "edid", "false" },
55
{ "virtio-device", "use-started", "false" },
56
{ "virtio-balloon-device", "qemu-4-0-config-size", "true" },
57
+ { "pl031", "migrate-tick-offset", "false" },
58
};
59
const size_t hw_compat_4_0_len = G_N_ELEMENTS(hw_compat_4_0);
60
61
diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/timer/pl031.c
64
+++ b/hw/timer/pl031.c
65
@@ -XXX,XX +XXX,XX @@ static int pl031_pre_save(void *opaque)
66
{
67
PL031State *s = opaque;
68
69
- /* tick_offset is base_time - rtc_clock base time. Instead, we want to
70
- * store the base time relative to the QEMU_CLOCK_VIRTUAL for backwards-compatibility. */
71
+ /*
72
+ * The PL031 device model code uses the tick_offset field, which is
73
+ * the offset between what the guest RTC should read and what the
74
+ * QEMU rtc_clock reads:
75
+ * guest_rtc = rtc_clock + tick_offset
76
+ * and so
77
+ * tick_offset = guest_rtc - rtc_clock
78
+ *
79
+ * We want to migrate this offset, which sounds straightforward.
80
+ * Unfortunately older versions of QEMU migrated a conversion of this
81
+ * offset into an offset from the vm_clock. (This was in turn an
82
+ * attempt to be compatible with even older QEMU versions, but it
83
+ * has incorrect behaviour if the rtc_clock is not the same as the
84
+ * vm_clock.) So we put the actual tick_offset into a migration
85
+ * subsection, and the backwards-compatible time-relative-to-vm_clock
86
+ * in the main migration state.
87
+ *
88
+ * Calculate base time relative to QEMU_CLOCK_VIRTUAL:
89
+ */
90
int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
91
s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND;
92
93
return 0;
25
}
94
}
26
95
27
+static void sdhci_common_unrealize(SDHCIState *s, Error **errp)
96
+static int pl031_pre_load(void *opaque)
28
+{
97
+{
29
+ /* This function is expected to be called only once for each class:
98
+ PL031State *s = opaque;
30
+ * - SysBus: via DeviceClass->unrealize(),
99
+
31
+ * - PCI: via PCIDeviceClass->exit().
100
+ s->tick_offset_migrated = false;
32
+ * However to avoid double-free and/or use-after-free we still nullify
101
+ return 0;
33
+ * this variable (better safe than sorry!). */
34
+ g_free(s->fifo_buffer);
35
+ s->fifo_buffer = NULL;
36
+}
102
+}
37
+
103
+
38
static bool sdhci_pending_insert_vmstate_needed(void *opaque)
104
static int pl031_post_load(void *opaque, int version_id)
39
{
105
{
40
SDHCIState *s = opaque;
106
PL031State *s = opaque;
41
@@ -XXX,XX +XXX,XX @@ static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
107
42
static void sdhci_pci_exit(PCIDevice *dev)
108
- int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
43
{
109
- s->tick_offset = s->tick_offset_vmstate - delta / NANOSECONDS_PER_SECOND;
44
SDHCIState *s = PCI_SDHCI(dev);
110
+ /*
45
+
111
+ * If we got the tick_offset subsection, then we can just use
46
+ sdhci_common_unrealize(s, &error_abort);
112
+ * the value in that. Otherwise the source is an older QEMU and
47
sdhci_uninitfn(s);
113
+ * has given us the offset from the vm_clock; convert it back to
114
+ * an offset from the rtc_clock. This will cause time to incorrectly
115
+ * go backwards compared to the host RTC, but this is unavoidable.
116
+ */
117
+
118
+ if (!s->tick_offset_migrated) {
119
+ int64_t delta = qemu_clock_get_ns(rtc_clock) -
120
+ qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
121
+ s->tick_offset = s->tick_offset_vmstate -
122
+ delta / NANOSECONDS_PER_SECOND;
123
+ }
124
pl031_set_alarm(s);
125
return 0;
48
}
126
}
49
127
50
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
128
+static int pl031_tick_offset_post_load(void *opaque, int version_id)
51
sysbus_init_mmio(sbd, &s->iomem);
52
}
53
54
+static void sdhci_sysbus_unrealize(DeviceState *dev, Error **errp)
55
+{
129
+{
56
+ SDHCIState *s = SYSBUS_SDHCI(dev);
130
+ PL031State *s = opaque;
57
+
131
+
58
+ sdhci_common_unrealize(s, &error_abort);
132
+ s->tick_offset_migrated = true;
133
+ return 0;
59
+}
134
+}
60
+
135
+
61
static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)
136
+static bool pl031_tick_offset_needed(void *opaque)
137
+{
138
+ PL031State *s = opaque;
139
+
140
+ return s->migrate_tick_offset;
141
+}
142
+
143
+static const VMStateDescription vmstate_pl031_tick_offset = {
144
+ .name = "pl031/tick-offset",
145
+ .version_id = 1,
146
+ .minimum_version_id = 1,
147
+ .needed = pl031_tick_offset_needed,
148
+ .post_load = pl031_tick_offset_post_load,
149
+ .fields = (VMStateField[]) {
150
+ VMSTATE_UINT32(tick_offset, PL031State),
151
+ VMSTATE_END_OF_LIST()
152
+ }
153
+};
154
+
155
static const VMStateDescription vmstate_pl031 = {
156
.name = "pl031",
157
.version_id = 1,
158
.minimum_version_id = 1,
159
.pre_save = pl031_pre_save,
160
+ .pre_load = pl031_pre_load,
161
.post_load = pl031_post_load,
162
.fields = (VMStateField[]) {
163
VMSTATE_UINT32(tick_offset_vmstate, PL031State),
164
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl031 = {
165
VMSTATE_UINT32(im, PL031State),
166
VMSTATE_UINT32(is, PL031State),
167
VMSTATE_END_OF_LIST()
168
+ },
169
+ .subsections = (const VMStateDescription*[]) {
170
+ &vmstate_pl031_tick_offset,
171
+ NULL
172
}
173
};
174
175
+static Property pl031_properties[] = {
176
+ /*
177
+ * True to correctly migrate the tick offset of the RTC. False to
178
+ * obtain backward migration compatibility with older QEMU versions,
179
+ * at the expense of the guest RTC going backwards compared with the
180
+ * host RTC when the VM is saved/restored if using -rtc host.
181
+ * (Even if set to 'true' older QEMU can migrate forward to newer QEMU;
182
+ * 'false' also permits newer QEMU to migrate to older QEMU.)
183
+ */
184
+ DEFINE_PROP_BOOL("migrate-tick-offset",
185
+ PL031State, migrate_tick_offset, true),
186
+ DEFINE_PROP_END_OF_LIST()
187
+};
188
+
189
static void pl031_class_init(ObjectClass *klass, void *data)
62
{
190
{
63
DeviceClass *dc = DEVICE_CLASS(klass);
191
DeviceClass *dc = DEVICE_CLASS(klass);
64
192
65
dc->props = sdhci_sysbus_properties;
193
dc->vmsd = &vmstate_pl031;
66
dc->realize = sdhci_sysbus_realize;
194
+ dc->props = pl031_properties;
67
+ dc->unrealize = sdhci_sysbus_unrealize;
68
69
sdhci_common_class_init(klass, data);
70
}
195
}
196
197
static const TypeInfo pl031_info = {
71
--
198
--
72
2.7.4
199
2.20.1
73
200
74
201
diff view generated by jsdifflib
1
Since pl181 is still using the legacy SD card API, the SD
1
The ARMv5 architecture didn't specify detailed per-feature ID
2
card created by sd_init() is not plugged into any bus. This
2
registers. Now that we're using the MVFR0 register fields to
3
means that the controller has to reset it manually.
3
gate the existence of VFP instructions, we need to set up
4
the correct values in the cpu->isar structure so that we still
5
provide an FPU to the guest.
4
6
5
Failing to do this mostly didn't affect the guest since the
7
This fixes a regression in the arm926 and arm1026 CPUs, which
6
guest typically does a programmed SD card reset as part of
8
are the only ones that both have VFP and are ARMv5 or earlier.
7
its SD controller driver initialization, but meant that
9
This regression was introduced by the VFP refactoring, and more
8
migration failed because it's only in sd_reset() that we
10
specifically by commits 1120827fa182f0e76 and 266bd25c485597c,
9
set up the wpgrps_size field.
11
which accidentally disabled VFP short-vector support and
12
double-precision support on these CPUs.
10
13
11
Cc: qemu-stable@nongnu.org
14
Fixes: 1120827fa182f0e
12
Fixes: https://bugs.launchpad.net/qemu/+bug/1739378
15
Fixes: 266bd25c485597c
16
Fixes: https://bugs.launchpad.net/qemu/+bug/1836192
17
Reported-by: Christophe Lyon <christophe.lyon@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
16
Message-id: 1515506513-31961-2-git-send-email-peter.maydell@linaro.org
21
Tested-by: Christophe Lyon <christophe.lyon@linaro.org>
22
Message-id: 20190711131241.22231-1-peter.maydell@linaro.org
17
---
23
---
18
hw/sd/pl181.c | 4 ++++
24
target/arm/cpu.c | 12 ++++++++++++
19
1 file changed, 4 insertions(+)
25
1 file changed, 12 insertions(+)
20
26
21
diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c
27
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
22
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/sd/pl181.c
29
--- a/target/arm/cpu.c
24
+++ b/hw/sd/pl181.c
30
+++ b/target/arm/cpu.c
25
@@ -XXX,XX +XXX,XX @@ static void pl181_reset(DeviceState *d)
31
@@ -XXX,XX +XXX,XX @@ static void arm926_initfn(Object *obj)
26
32
* set the field to indicate Jazelle support within QEMU.
27
/* We can assume our GPIO outputs have been wired up now */
33
*/
28
sd_set_cb(s->card, s->cardstatus[0], s->cardstatus[1]);
34
cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
29
+ /* Since we're still using the legacy SD API the card is not plugged
35
+ /*
30
+ * into any bus, and we must reset it manually.
36
+ * Similarly, we need to set MVFR0 fields to enable double precision
37
+ * and short vector support even though ARMv5 doesn't have this register.
31
+ */
38
+ */
32
+ device_reset(DEVICE(s->card));
39
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
40
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
33
}
41
}
34
42
35
static void pl181_init(Object *obj)
43
static void arm946_initfn(Object *obj)
44
@@ -XXX,XX +XXX,XX @@ static void arm1026_initfn(Object *obj)
45
* set the field to indicate Jazelle support within QEMU.
46
*/
47
cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
48
+ /*
49
+ * Similarly, we need to set MVFR0 fields to enable double precision
50
+ * and short vector support even though ARMv5 doesn't have this register.
51
+ */
52
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
53
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
54
55
{
56
/* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
36
--
57
--
37
2.7.4
58
2.20.1
38
59
39
60
diff view generated by jsdifflib
1
The Configurable Fault Status Register for ARMv7M and v8M is
1
In the M-profile architecture, when we do a vector table fetch and it
2
supposed to be byte and halfword accessible, but we were only
2
fails, we need to report a HardFault. Whether this is a Secure HF or
3
implementing word accesses. Add support for the other access
3
a NonSecure HF depends on several things. If AIRCR.BFHFNMINS is 0
4
sizes, which are used by the Zephyr RTOS.
4
then HF is always Secure, because there is no NonSecure HardFault.
5
Otherwise, the answer depends on whether the 'underlying exception'
6
(MemManage, BusFault, SecureFault) targets Secure or NonSecure. (In
7
the pseudocode, this is handled in the Vector() function: the final
8
exc.isSecure is calculated by looking at the exc.isSecure from the
9
exception returned from the memory access, not the isSecure input
10
argument.)
11
12
We weren't doing this correctly, because we were looking at
13
the target security domain of the exception we were trying to
14
load the vector table entry for. This produces errors of two kinds:
15
* a load from the NS vector table which hits the "NS access
16
to S memory" SecureFault should end up as a Secure HardFault,
17
but we were raising an NS HardFault
18
* a load from the S vector table which causes a BusFault
19
should raise an NS HardFault if BFHFNMINS == 1 (because
20
in that case all BusFaults are NonSecure), but we were raising
21
a Secure HardFault
22
23
Correct the logic.
24
25
We also fix a comment error where we claimed that we might
26
be escalating MemManage to HardFault, and forgot about SecureFault.
27
(Vector loads can never hit MPU access faults, because they're
28
always aligned and always use the default address map.)
5
29
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reported-by: Andy Gross <andy.gross@linaro.org>
31
Message-id: 20190705094823.28905-1-peter.maydell@linaro.org
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 1512742372-31517-1-git-send-email-peter.maydell@linaro.org
10
---
32
---
11
hw/intc/armv7m_nvic.c | 38 ++++++++++++++++++++++----------------
33
target/arm/m_helper.c | 21 +++++++++++++++++----
12
1 file changed, 22 insertions(+), 16 deletions(-)
34
1 file changed, 17 insertions(+), 4 deletions(-)
13
35
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
36
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
15
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
38
--- a/target/arm/m_helper.c
17
+++ b/hw/intc/armv7m_nvic.c
39
+++ b/target/arm/m_helper.c
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
40
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
19
val |= (1 << 8);
41
if (sattrs.ns) {
42
attrs.secure = false;
43
} else if (!targets_secure) {
44
- /* NS access to S memory */
45
+ /*
46
+ * NS access to S memory: the underlying exception which we escalate
47
+ * to HardFault is SecureFault, which always targets Secure.
48
+ */
49
+ exc_secure = true;
50
goto load_fail;
20
}
51
}
21
return val;
52
}
22
- case 0xd28: /* Configurable Fault Status. */
53
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
23
- /* The BFSR bits [15:8] are shared between security states
54
vector_entry = address_space_ldl(arm_addressspace(cs, attrs), addr,
24
- * and we store them in the NS copy
55
attrs, &result);
25
- */
56
if (result != MEMTX_OK) {
26
- val = cpu->env.v7m.cfsr[attrs.secure];
57
+ /*
27
- val |= cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK;
58
+ * Underlying exception is BusFault: its target security state
28
- return val;
59
+ * depends on BFHFNMINS.
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
+ */
60
+ */
56
+ val = s->cpu->env.v7m.cfsr[attrs.secure];
61
+ exc_secure = !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK);
57
+ val |= s->cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK;
62
goto load_fail;
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
}
63
}
82
if (size == 4) {
64
*pvec = vector_entry;
83
nvic_writel(s, offset, value, attrs);
65
@@ -XXX,XX +XXX,XX @@ load_fail:
66
/*
67
* All vector table fetch fails are reported as HardFault, with
68
* HFSR.VECTTBL and .FORCED set. (FORCED is set because
69
- * technically the underlying exception is a MemManage or BusFault
70
+ * technically the underlying exception is a SecureFault or BusFault
71
* that is escalated to HardFault.) This is a terminal exception,
72
* so we will either take the HardFault immediately or else enter
73
* lockup (the latter case is handled in armv7m_nvic_set_pending_derived()).
74
+ * The HardFault is Secure if BFHFNMINS is 0 (meaning that all HFs are
75
+ * secure); otherwise it targets the same security state as the
76
+ * underlying exception.
77
*/
78
- exc_secure = targets_secure ||
79
- !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK);
80
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
81
+ exc_secure = true;
82
+ }
83
env->v7m.hfsr |= R_V7M_HFSR_VECTTBL_MASK | R_V7M_HFSR_FORCED_MASK;
84
armv7m_nvic_set_pending_derived(env->nvic, ARMV7M_EXCP_HARD, exc_secure);
85
return false;
84
--
86
--
85
2.7.4
87
2.20.1
86
88
87
89
diff view generated by jsdifflib
Deleted patch
1
For PMSAv7, the v7A/R Arm ARM defines that setting AP to 0b111
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
1
8
Reported-by: Andy Gross <andy.gross@linaro.org>
9
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
---
13
target/arm/helper.c | 14 ++++++++++++++
14
1 file changed, 14 insertions(+)
15
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper.c
19
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
21
case 6:
22
*prot |= PAGE_READ | PAGE_EXEC;
23
break;
24
+ case 7:
25
+ /* for v7M, same as 6; for R profile a reserved value */
26
+ if (arm_feature(env, ARM_FEATURE_M)) {
27
+ *prot |= PAGE_READ | PAGE_EXEC;
28
+ break;
29
+ }
30
+ /* fall through */
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
--
49
2.7.4
50
51
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
Since omap_mmc 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 would mean that
8
migration fails because it's only in sd_reset() that we
9
set up the wpgrps_size field.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Message-id: 1515506513-31961-5-git-send-email-peter.maydell@linaro.org
15
---
16
hw/sd/omap_mmc.c | 14 ++++++++++----
17
1 file changed, 10 insertions(+), 4 deletions(-)
18
19
diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/sd/omap_mmc.c
22
+++ b/hw/sd/omap_mmc.c
23
@@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host)
24
host->cdet_enable = 0;
25
qemu_set_irq(host->coverswitch, host->cdet_state);
26
host->clkdiv = 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. When omap_mmc is
30
+ * QOMified this must move into the QOM reset function.
31
+ */
32
+ device_reset(DEVICE(host->card));
33
}
34
35
static uint64_t omap_mmc_read(void *opaque, hwaddr offset,
36
@@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap_mmc_init(hwaddr base,
37
s->lines = 1;    /* TODO: needs to be settable per-board */
38
s->rev = 1;
39
40
- omap_mmc_reset(s);
41
-
42
memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, "omap.mmc", 0x800);
43
memory_region_add_subregion(sysmem, base, &s->iomem);
44
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
--
73
2.7.4
74
75
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
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-8-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/sd/sdhci.c | 7 ++++---
9
1 file changed, 4 insertions(+), 3 deletions(-)
10
11
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/sd/sdhci.c
14
+++ b/hw/sd/sdhci.c
15
@@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
16
ret = (SD_HOST_SPECv2_VERS << 16) | sdhci_slotint(s);
17
break;
18
default:
19
- ERRPRINT("bad %ub read: addr[0x%04x]\n", size, (int)offset);
20
+ qemu_log_mask(LOG_UNIMP, "SDHC rd_%ub @0x%02" HWADDR_PRIx " "
21
+ "not implemented\n", size, offset);
22
break;
23
}
24
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
--
37
2.7.4
38
39
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
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-11-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/sd/sdhci-internal.h | 2 +-
9
hw/sd/sdhci.c | 2 +-
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_ACMD12ERRSTS 0x3C
18
19
/* HWInit Capabilities Register 0x05E80080 */
20
-#define SDHC_CAPAREG 0x40
21
+#define SDHC_CAPAB 0x40
22
#define SDHC_CAN_DO_DMA 0x00400000
23
#define SDHC_CAN_DO_ADMA2 0x00080000
24
#define SDHC_CAN_DO_ADMA1 0x00100000
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 uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
30
case SDHC_ACMD12ERRSTS:
31
ret = s->acmd12errsts;
32
break;
33
- case SDHC_CAPAREG:
34
+ case SDHC_CAPAB:
35
ret = s->capareg;
36
break;
37
case SDHC_MAXCURR:
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
running qtests:
4
5
$ make check-qtest-arm
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
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>
15
---
16
include/hw/sd/sdhci.h | 4 ++--
17
hw/sd/sdhci.c | 23 +++++++++++++++++++----
18
2 files changed, 21 insertions(+), 6 deletions(-)
19
20
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/sd/sdhci.h
23
+++ b/include/hw/sd/sdhci.h
24
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
25
uint64_t admasysaddr; /* ADMA System Address Register */
26
27
/* Read-only registers */
28
- uint32_t capareg; /* Capabilities Register */
29
- uint32_t maxcurr; /* Maximum Current Capabilities Register */
30
+ uint64_t capareg; /* Capabilities Register */
31
+ uint64_t maxcurr; /* Maximum Current Capabilities Register */
32
33
uint8_t *fifo_buffer; /* SD host i/o FIFO buffer */
34
uint32_t buf_maxsz;
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 @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
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
--
86
2.7.4
87
88
diff view generated by jsdifflib