1
ARM queue for 2.10 soft freeze...
1
target-arm queue. This has the "plumb txattrs through various
2
bits of exec.c" patches, and a collection of bug fixes from
3
various people.
2
4
3
thanks
5
thanks
4
-- PMM
6
-- PMM
5
7
6
The following changes since commit 6632f6ff96f0537fc34cdc00c760656fc62e23c5:
7
8
8
Merge remote-tracking branch 'remotes/famz/tags/block-and-testing-pull-request' into staging (2017-07-17 11:46:36 +0100)
9
9
10
are available in the git repository at:
10
The following changes since commit a3ac12fba028df90f7b3dbec924995c126c41022:
11
11
12
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170717
12
Merge remote-tracking branch 'remotes/ehabkost/tags/numa-next-pull-request' into staging (2018-05-31 11:12:36 +0100)
13
13
14
for you to fetch changes up to e5a6a6e64e82a132cebef023d867085b0a2993d7:
14
are available in the Git repository at:
15
15
16
MAINTAINERS: Add entries for MPS2 board (2017-07-17 13:36:09 +0100)
16
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180531
17
18
for you to fetch changes up to 49d1dca0520ea71bc21867fab6647f474fcf857b:
19
20
KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice (2018-05-31 14:52:53 +0100)
17
21
18
----------------------------------------------------------------
22
----------------------------------------------------------------
19
target-arm queue:
23
target-arm queue:
20
* new model of the ARM MPS2/MPS2+ FPGA based development board
24
* target/arm: Honour FPCR.FZ in FRECPX
21
* clean up DISAS_* exit conditions and fix various regressions
25
* MAINTAINERS: Add entries for newer MPS2 boards and devices
22
since commits e75449a346 8a6b28c7b5 (in particular including
26
* hw/intc/arm_gicv3: Fix APxR<n> register dispatching
23
ones which broke OP-TEE guests)
27
* arm_gicv3_kvm: fix bug in writing zero bits back to the in-kernel
24
* make Cortex-M3 and M4 correctly default to 8 PMSA regions
28
GIC state
29
* tcg: Fix helper function vs host abi for float16
30
* arm: fix qemu crash on startup with -bios option
31
* arm: fix malloc type mismatch
32
* xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors
33
* Correct CPACR reset value for v7 cores
34
* memory.h: Improve IOMMU related documentation
35
* exec: Plumb transaction attributes through various functions in
36
preparation for allowing IOMMUs to see them
37
* vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY
38
* ARM: ACPI: Fix use-after-free due to memory realloc
39
* KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice
25
40
26
----------------------------------------------------------------
41
----------------------------------------------------------------
27
Alex Bennée (6):
42
Francisco Iglesias (1):
28
include/exec/exec-all: document common exit conditions
43
xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors
29
target/arm/translate: make DISAS_UPDATE match declared semantics
30
target/arm/translate.h: expand comment on DISAS_EXIT
31
target/arm/translate: ensure gen_goto_tb sets exit flags
32
target/arm: use gen_goto_tb for ISB handling
33
target/arm: use DISAS_EXIT for eret handling
34
44
35
Peter Maydell (12):
45
Igor Mammedov (1):
36
qdev-properties.h: Explicitly set the default value for arraylen properties
46
arm: fix qemu crash on startup with -bios option
37
qdev: support properties which don't set a default value
38
target/arm: Make Cortex-M3 and M4 default to 8 PMSA regions
39
hw/arm/mps2: Implement skeleton mps2-an385 and mps2-an511 board models
40
hw/char/cmsdk-apb-uart.c: Implement CMSDK APB UART
41
hw/arm/mps2: Add UARTs
42
hw/char/cmsdk-apb-timer: Implement CMSDK APB timer device
43
hw/arm/mps2: Add timers
44
hw/misc/mps2_scc: Implement MPS2 Serial Communication Controller
45
hw/arm/mps2: Add SCC
46
hw/arm/mps2: Add ethernet
47
MAINTAINERS: Add entries for MPS2 board
48
47
49
hw/arm/Makefile.objs | 1 +
48
Jan Kiszka (1):
50
hw/char/Makefile.objs | 1 +
49
hw/intc/arm_gicv3: Fix APxR<n> register dispatching
51
hw/misc/Makefile.objs | 1 +
52
hw/timer/Makefile.objs | 1 +
53
include/exec/exec-all.h | 29 ++-
54
include/hw/char/cmsdk-apb-uart.h | 78 +++++++
55
include/hw/misc/mps2-scc.h | 43 ++++
56
include/hw/qdev-core.h | 10 +
57
include/hw/qdev-properties.h | 21 ++
58
include/hw/timer/cmsdk-apb-timer.h | 59 ++++++
59
target/arm/translate.h | 5 +-
60
hw/arm/mps2.c | 385 +++++++++++++++++++++++++++++++++++
61
hw/char/cmsdk-apb-uart.c | 403 +++++++++++++++++++++++++++++++++++++
62
hw/core/qdev.c | 2 +-
63
hw/misc/mps2-scc.c | 310 ++++++++++++++++++++++++++++
64
hw/timer/cmsdk-apb-timer.c | 253 +++++++++++++++++++++++
65
target/arm/cpu.c | 12 +-
66
target/arm/translate-a64.c | 19 +-
67
target/arm/translate.c | 22 +-
68
MAINTAINERS | 14 +-
69
default-configs/arm-softmmu.mak | 6 +
70
hw/char/trace-events | 9 +
71
hw/misc/trace-events | 8 +
72
hw/timer/trace-events | 5 +
73
24 files changed, 1673 insertions(+), 24 deletions(-)
74
create mode 100644 include/hw/char/cmsdk-apb-uart.h
75
create mode 100644 include/hw/misc/mps2-scc.h
76
create mode 100644 include/hw/timer/cmsdk-apb-timer.h
77
create mode 100644 hw/arm/mps2.c
78
create mode 100644 hw/char/cmsdk-apb-uart.c
79
create mode 100644 hw/misc/mps2-scc.c
80
create mode 100644 hw/timer/cmsdk-apb-timer.c
81
50
51
Paolo Bonzini (1):
52
arm: fix malloc type mismatch
53
54
Peter Maydell (17):
55
target/arm: Honour FPCR.FZ in FRECPX
56
MAINTAINERS: Add entries for newer MPS2 boards and devices
57
Correct CPACR reset value for v7 cores
58
memory.h: Improve IOMMU related documentation
59
Make tb_invalidate_phys_addr() take a MemTxAttrs argument
60
Make address_space_translate{, _cached}() take a MemTxAttrs argument
61
Make address_space_map() take a MemTxAttrs argument
62
Make address_space_access_valid() take a MemTxAttrs argument
63
Make flatview_extend_translation() take a MemTxAttrs argument
64
Make memory_region_access_valid() take a MemTxAttrs argument
65
Make MemoryRegion valid.accepts callback take a MemTxAttrs argument
66
Make flatview_access_valid() take a MemTxAttrs argument
67
Make flatview_translate() take a MemTxAttrs argument
68
Make address_space_get_iotlb_entry() take a MemTxAttrs argument
69
Make flatview_do_translate() take a MemTxAttrs argument
70
Make address_space_translate_iommu take a MemTxAttrs argument
71
vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY
72
73
Richard Henderson (1):
74
tcg: Fix helper function vs host abi for float16
75
76
Shannon Zhao (3):
77
arm_gicv3_kvm: increase clroffset accordingly
78
ARM: ACPI: Fix use-after-free due to memory realloc
79
KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice
80
81
include/exec/exec-all.h | 5 +-
82
include/exec/helper-head.h | 2 +-
83
include/exec/memory-internal.h | 3 +-
84
include/exec/memory.h | 128 +++++++++++++++++++++++++++++++++++------
85
include/migration/vmstate.h | 3 +
86
include/sysemu/dma.h | 6 +-
87
accel/tcg/translate-all.c | 4 +-
88
exec.c | 95 ++++++++++++++++++------------
89
hw/arm/boot.c | 18 +++---
90
hw/arm/virt-acpi-build.c | 20 +++++--
91
hw/dma/xlnx-zdma.c | 10 +++-
92
hw/hppa/dino.c | 3 +-
93
hw/intc/arm_gic_kvm.c | 1 -
94
hw/intc/arm_gicv3_cpuif.c | 12 ++--
95
hw/intc/arm_gicv3_kvm.c | 2 +-
96
hw/nvram/fw_cfg.c | 12 ++--
97
hw/s390x/s390-pci-inst.c | 3 +-
98
hw/scsi/esp.c | 3 +-
99
hw/vfio/common.c | 3 +-
100
hw/virtio/vhost.c | 3 +-
101
hw/xen/xen_pt_msi.c | 3 +-
102
memory.c | 12 ++--
103
memory_ldst.inc.c | 18 +++---
104
target/arm/gdbstub.c | 3 +-
105
target/arm/helper-a64.c | 41 +++++++------
106
target/arm/helper.c | 90 ++++++++++++++++-------------
107
target/ppc/mmu-hash64.c | 3 +-
108
target/riscv/helper.c | 2 +-
109
target/s390x/diag.c | 6 +-
110
target/s390x/excp_helper.c | 3 +-
111
target/s390x/mmu_helper.c | 3 +-
112
target/s390x/sigp.c | 3 +-
113
target/xtensa/op_helper.c | 3 +-
114
MAINTAINERS | 9 ++-
115
34 files changed, 353 insertions(+), 182 deletions(-)
116
diff view generated by jsdifflib
New patch
1
The FRECPX instructions should (like most other floating point operations)
2
honour the FPCR.FZ bit which specifies whether input denormals should
3
be flushed to zero (or FZ16 for the half-precision version).
4
We forgot to implement this, which doesn't affect the results (since
5
the calculation doesn't actually care about the mantissa bits) but did
6
mean we were failing to set the FPSR.IDC bit.
1
7
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180521172712.19930-1-peter.maydell@linaro.org
11
---
12
target/arm/helper-a64.c | 6 ++++++
13
1 file changed, 6 insertions(+)
14
15
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper-a64.c
18
+++ b/target/arm/helper-a64.c
19
@@ -XXX,XX +XXX,XX @@ float16 HELPER(frecpx_f16)(float16 a, void *fpstp)
20
return nan;
21
}
22
23
+ a = float16_squash_input_denormal(a, fpst);
24
+
25
val16 = float16_val(a);
26
sbit = 0x8000 & val16;
27
exp = extract32(val16, 10, 5);
28
@@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp)
29
return nan;
30
}
31
32
+ a = float32_squash_input_denormal(a, fpst);
33
+
34
val32 = float32_val(a);
35
sbit = 0x80000000ULL & val32;
36
exp = extract32(val32, 23, 8);
37
@@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp)
38
return nan;
39
}
40
41
+ a = float64_squash_input_denormal(a, fpst);
42
+
43
val64 = float64_val(a);
44
sbit = 0x8000000000000000ULL & val64;
45
exp = extract64(float64_val(a), 52, 11);
46
--
47
2.17.1
48
49
diff view generated by jsdifflib
1
Add entries to the MAINTAINERS file for the new MPS2
1
Add entries to MAINTAINERS to cover the newer MPS2 boards and
2
board and devices.
2
the new devices they use.
3
4
Since the CMSDK devices are not specific to the MPS2 board,
5
extend the existing 'PrimeCell' section to cover CMSDK
6
devices as well; in both cases these are devices implemented
7
by ARM and provided as RTL that may be used in multiple
8
SoCs and boards.
9
3
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 1500029487-14822-10-git-send-email-peter.maydell@linaro.org
5
Message-id: 20180518153157.14899-1-peter.maydell@linaro.org
12
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
---
6
---
15
MAINTAINERS | 14 +++++++++++++-
7
MAINTAINERS | 9 +++++++--
16
1 file changed, 13 insertions(+), 1 deletion(-)
8
1 file changed, 7 insertions(+), 2 deletions(-)
17
9
18
diff --git a/MAINTAINERS b/MAINTAINERS
10
diff --git a/MAINTAINERS b/MAINTAINERS
19
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
20
--- a/MAINTAINERS
12
--- a/MAINTAINERS
21
+++ b/MAINTAINERS
13
+++ b/MAINTAINERS
22
@@ -XXX,XX +XXX,XX @@ F: hw/*/allwinner*
14
@@ -XXX,XX +XXX,XX @@ F: hw/timer/cmsdk-apb-timer.c
23
F: include/hw/*/allwinner*
15
F: include/hw/timer/cmsdk-apb-timer.h
24
F: hw/arm/cubieboard.c
16
F: hw/char/cmsdk-apb-uart.c
25
17
F: include/hw/char/cmsdk-apb-uart.h
26
-ARM PrimeCell
18
+F: hw/misc/tz-ppc.c
27
+ARM PrimeCell and CMSDK devices
19
+F: include/hw/misc/tz-ppc.h
20
21
ARM cores
28
M: Peter Maydell <peter.maydell@linaro.org>
22
M: Peter Maydell <peter.maydell@linaro.org>
23
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
29
L: qemu-arm@nongnu.org
24
L: qemu-arm@nongnu.org
30
S: Maintained
25
S: Maintained
31
@@ -XXX,XX +XXX,XX @@ F: hw/intc/pl190.c
26
F: hw/arm/mps2.c
32
F: hw/sd/pl181.c
27
-F: hw/misc/mps2-scc.c
33
F: hw/timer/pl031.c
28
-F: include/hw/misc/mps2-scc.h
34
F: include/hw/arm/primecell.h
29
+F: hw/arm/mps2-tz.c
35
+F: hw/timer/cmsdk-apb-timer.c
30
+F: hw/misc/mps2-*.c
36
+F: include/hw/timer/cmsdk-apb-timer.h
31
+F: include/hw/misc/mps2-*.h
37
+F: hw/char/cmsdk-apb-uart.c
32
+F: hw/arm/iotkit.c
38
+F: include/hw/char/cmsdk-apb-uart.h
33
+F: include/hw/arm/iotkit.h
39
34
40
ARM cores
41
M: Peter Maydell <peter.maydell@linaro.org>
42
@@ -XXX,XX +XXX,XX @@ S: Maintained
43
F: hw/arm/integratorcp.c
44
F: hw/misc/arm_integrator_debug.c
45
46
+MPS2
47
+M: Peter Maydell <peter.maydell@linaro.org>
48
+L: qemu-arm@nongnu.org
49
+S: Maintained
50
+F: hw/arm/mps2.c
51
+F: hw/misc/mps2-scc.c
52
+F: include/hw/misc/mps2-scc.h
53
+
54
Musicpal
35
Musicpal
55
M: Jan Kiszka <jan.kiszka@web.de>
36
M: Jan Kiszka <jan.kiszka@web.de>
56
L: qemu-arm@nongnu.org
57
--
37
--
58
2.7.4
38
2.17.1
59
39
60
40
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Jan Kiszka <jan.kiszka@siemens.com>
2
2
3
We already have an exit condition, DISAS_UPDATE which will exit the
3
There was a nasty flip in identifying which register group an access is
4
run-loop. Expand on the difference with DISAS_EXIT in the comments.
4
targeting. The issue caused spuriously raised priorities of the guest
5
when handing CPUs over in the Jailhouse hypervisor.
5
6
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
Cc: qemu-stable@nongnu.org
7
Reviewed-by: Richard Henderson <rth@twiddle.net>
8
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8
Message-id: 20170713141928.25419-4-alex.bennee@linaro.org
9
Message-id: 28b927d3-da58-bce4-cc13-bfec7f9b1cb9@siemens.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
target/arm/translate.h | 5 ++++-
13
hw/intc/arm_gicv3_cpuif.c | 12 ++++++------
12
1 file changed, 4 insertions(+), 1 deletion(-)
14
1 file changed, 6 insertions(+), 6 deletions(-)
13
15
14
diff --git a/target/arm/translate.h b/target/arm/translate.h
16
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.h
18
--- a/hw/intc/arm_gicv3_cpuif.c
17
+++ b/target/arm/translate.h
19
+++ b/hw/intc/arm_gicv3_cpuif.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)
20
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
19
*/
21
{
20
#define DISAS_BX_EXCRET 11
22
GICv3CPUState *cs = icc_cs_from_env(env);
21
/* For instructions which want an immediate exit to the main loop,
23
int regno = ri->opc2 & 3;
22
- * as opposed to attempting to use lookup_and_goto_ptr.
24
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS;
23
+ * as opposed to attempting to use lookup_and_goto_ptr. Unlike
25
+ int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0;
24
+ * DISAS_UPDATE this doesn't write the PC on exiting the translation
26
uint64_t value = cs->ich_apr[grp][regno];
25
+ * loop so you need to ensure something (gen_a64_set_pc_im or runtime
27
26
+ * helper) has done so before we reach return from cpu_tb_exec.
28
trace_gicv3_icv_ap_read(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
27
*/
29
@@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
28
#define DISAS_EXIT 12
30
{
31
GICv3CPUState *cs = icc_cs_from_env(env);
32
int regno = ri->opc2 & 3;
33
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS;
34
+ int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0;
35
36
trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
37
38
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
39
uint64_t value;
40
41
int regno = ri->opc2 & 3;
42
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1;
43
+ int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0;
44
45
if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) {
46
return icv_ap_read(env, ri);
47
@@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
48
GICv3CPUState *cs = icc_cs_from_env(env);
49
50
int regno = ri->opc2 & 3;
51
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1;
52
+ int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0;
53
54
if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) {
55
icv_ap_write(env, ri, value);
56
@@ -XXX,XX +XXX,XX @@ static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
57
{
58
GICv3CPUState *cs = icc_cs_from_env(env);
59
int regno = ri->opc2 & 3;
60
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS;
61
+ int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0;
62
uint64_t value;
63
64
value = cs->ich_apr[grp][regno];
65
@@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
66
{
67
GICv3CPUState *cs = icc_cs_from_env(env);
68
int regno = ri->opc2 & 3;
69
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS;
70
+ int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0;
71
72
trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
29
73
30
--
74
--
31
2.7.4
75
2.17.1
32
76
33
77
diff view generated by jsdifflib
New patch
1
From: Shannon Zhao <zhaoshenglong@huawei.com>
1
2
3
It forgot to increase clroffset during the loop. So it only clear the
4
first 4 bytes.
5
6
Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920
7
Cc: qemu-stable@nongnu.org
8
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
9
Reviewed-by: Eric Auger <eric.auger@redhat.com>
10
Message-id: 1527047633-12368-1-git-send-email-zhaoshenglong@huawei.com
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/intc/arm_gicv3_kvm.c | 1 +
15
1 file changed, 1 insertion(+)
16
17
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/intc/arm_gicv3_kvm.c
20
+++ b/hw/intc/arm_gicv3_kvm.c
21
@@ -XXX,XX +XXX,XX @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset,
22
if (clroffset != 0) {
23
reg = 0;
24
kvm_gicd_access(s, clroffset, &reg, true);
25
+ clroffset += 4;
26
}
27
reg = *gic_bmp_ptr32(bmp, irq);
28
kvm_gicd_access(s, offset, &reg, true);
29
--
30
2.17.1
31
32
diff view generated by jsdifflib
New patch
1
1
From: Richard Henderson <richard.henderson@linaro.org>
2
3
Depending on the host abi, float16, aka uint16_t, values are
4
passed and returned either zero-extended in the host register
5
or with garbage at the top of the host register.
6
7
The tcg code generator has so far been assuming garbage, as that
8
matches the x86 abi, but this is incorrect for other host abis.
9
Further, target/arm has so far been assuming zero-extended results,
10
so that it may store the 16-bit value into a 32-bit slot with the
11
high 16-bits already clear.
12
13
Rectify both problems by mapping "f16" in the helper definition
14
to uint32_t instead of (a typedef for) uint16_t. This forces
15
the host compiler to assume garbage in the upper 16 bits on input
16
and to zero-extend the result on output.
17
18
Cc: qemu-stable@nongnu.org
19
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
20
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com>
22
Message-id: 20180522175629.24932-1-richard.henderson@linaro.org
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
---
26
include/exec/helper-head.h | 2 +-
27
target/arm/helper-a64.c | 35 +++++++++--------
28
target/arm/helper.c | 80 +++++++++++++++++++-------------------
29
3 files changed, 59 insertions(+), 58 deletions(-)
30
31
diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h
32
index XXXXXXX..XXXXXXX 100644
33
--- a/include/exec/helper-head.h
34
+++ b/include/exec/helper-head.h
35
@@ -XXX,XX +XXX,XX @@
36
#define dh_ctype_int int
37
#define dh_ctype_i64 uint64_t
38
#define dh_ctype_s64 int64_t
39
-#define dh_ctype_f16 float16
40
+#define dh_ctype_f16 uint32_t
41
#define dh_ctype_f32 float32
42
#define dh_ctype_f64 float64
43
#define dh_ctype_ptr void *
44
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/helper-a64.c
47
+++ b/target/arm/helper-a64.c
48
@@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res)
49
return flags;
50
}
51
52
-uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status)
53
+uint64_t HELPER(vfp_cmph_a64)(uint32_t x, uint32_t y, void *fp_status)
54
{
55
return float_rel_to_flags(float16_compare_quiet(x, y, fp_status));
56
}
57
58
-uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status)
59
+uint64_t HELPER(vfp_cmpeh_a64)(uint32_t x, uint32_t y, void *fp_status)
60
{
61
return float_rel_to_flags(float16_compare(x, y, fp_status));
62
}
63
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp)
64
#define float64_three make_float64(0x4008000000000000ULL)
65
#define float64_one_point_five make_float64(0x3FF8000000000000ULL)
66
67
-float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp)
68
+uint32_t HELPER(recpsf_f16)(uint32_t a, uint32_t b, void *fpstp)
69
{
70
float_status *fpst = fpstp;
71
72
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp)
73
return float64_muladd(a, b, float64_two, 0, fpst);
74
}
75
76
-float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp)
77
+uint32_t HELPER(rsqrtsf_f16)(uint32_t a, uint32_t b, void *fpstp)
78
{
79
float_status *fpst = fpstp;
80
81
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a)
82
}
83
84
/* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */
85
-float16 HELPER(frecpx_f16)(float16 a, void *fpstp)
86
+uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp)
87
{
88
float_status *fpst = fpstp;
89
uint16_t val16, sbit;
90
@@ -XXX,XX +XXX,XX @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr,
91
#define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix))
92
93
#define ADVSIMD_HALFOP(name) \
94
-float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \
95
+uint32_t ADVSIMD_HELPER(name, h)(uint32_t a, uint32_t b, void *fpstp) \
96
{ \
97
float_status *fpst = fpstp; \
98
return float16_ ## name(a, b, fpst); \
99
@@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(mulx)
100
ADVSIMD_TWOHALFOP(mulx)
101
102
/* fused multiply-accumulate */
103
-float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp)
104
+uint32_t HELPER(advsimd_muladdh)(uint32_t a, uint32_t b, uint32_t c,
105
+ void *fpstp)
106
{
107
float_status *fpst = fpstp;
108
return float16_muladd(a, b, c, 0, fpst);
109
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b,
110
111
#define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0
112
113
-uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp)
114
+uint32_t HELPER(advsimd_ceq_f16)(uint32_t a, uint32_t b, void *fpstp)
115
{
116
float_status *fpst = fpstp;
117
int compare = float16_compare_quiet(a, b, fpst);
118
return ADVSIMD_CMPRES(compare == float_relation_equal);
119
}
120
121
-uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp)
122
+uint32_t HELPER(advsimd_cge_f16)(uint32_t a, uint32_t b, void *fpstp)
123
{
124
float_status *fpst = fpstp;
125
int compare = float16_compare(a, b, fpst);
126
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp)
127
compare == float_relation_equal);
128
}
129
130
-uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp)
131
+uint32_t HELPER(advsimd_cgt_f16)(uint32_t a, uint32_t b, void *fpstp)
132
{
133
float_status *fpst = fpstp;
134
int compare = float16_compare(a, b, fpst);
135
return ADVSIMD_CMPRES(compare == float_relation_greater);
136
}
137
138
-uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp)
139
+uint32_t HELPER(advsimd_acge_f16)(uint32_t a, uint32_t b, void *fpstp)
140
{
141
float_status *fpst = fpstp;
142
float16 f0 = float16_abs(a);
143
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp)
144
compare == float_relation_equal);
145
}
146
147
-uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp)
148
+uint32_t HELPER(advsimd_acgt_f16)(uint32_t a, uint32_t b, void *fpstp)
149
{
150
float_status *fpst = fpstp;
151
float16 f0 = float16_abs(a);
152
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp)
153
}
154
155
/* round to integral */
156
-float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status)
157
+uint32_t HELPER(advsimd_rinth_exact)(uint32_t x, void *fp_status)
158
{
159
return float16_round_to_int(x, fp_status);
160
}
161
162
-float16 HELPER(advsimd_rinth)(float16 x, void *fp_status)
163
+uint32_t HELPER(advsimd_rinth)(uint32_t x, void *fp_status)
164
{
165
int old_flags = get_float_exception_flags(fp_status), new_flags;
166
float16 ret;
167
@@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status)
168
* setting the mode appropriately before calling the helper.
169
*/
170
171
-uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp)
172
+uint32_t HELPER(advsimd_f16tosinth)(uint32_t a, void *fpstp)
173
{
174
float_status *fpst = fpstp;
175
176
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp)
177
return float16_to_int16(a, fpst);
178
}
179
180
-uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp)
181
+uint32_t HELPER(advsimd_f16touinth)(uint32_t a, void *fpstp)
182
{
183
float_status *fpst = fpstp;
184
185
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp)
186
* Square Root and Reciprocal square root
187
*/
188
189
-float16 HELPER(sqrt_f16)(float16 a, void *fpstp)
190
+uint32_t HELPER(sqrt_f16)(uint32_t a, void *fpstp)
191
{
192
float_status *s = fpstp;
193
194
diff --git a/target/arm/helper.c b/target/arm/helper.c
195
index XXXXXXX..XXXXXXX 100644
196
--- a/target/arm/helper.c
197
+++ b/target/arm/helper.c
198
@@ -XXX,XX +XXX,XX @@ DO_VFP_cmp(d, float64)
199
200
/* Integer to float and float to integer conversions */
201
202
-#define CONV_ITOF(name, fsz, sign) \
203
- float##fsz HELPER(name)(uint32_t x, void *fpstp) \
204
-{ \
205
- float_status *fpst = fpstp; \
206
- return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \
207
+#define CONV_ITOF(name, ftype, fsz, sign) \
208
+ftype HELPER(name)(uint32_t x, void *fpstp) \
209
+{ \
210
+ float_status *fpst = fpstp; \
211
+ return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \
212
}
213
214
-#define CONV_FTOI(name, fsz, sign, round) \
215
-uint32_t HELPER(name)(float##fsz x, void *fpstp) \
216
-{ \
217
- float_status *fpst = fpstp; \
218
- if (float##fsz##_is_any_nan(x)) { \
219
- float_raise(float_flag_invalid, fpst); \
220
- return 0; \
221
- } \
222
- return float##fsz##_to_##sign##int32##round(x, fpst); \
223
+#define CONV_FTOI(name, ftype, fsz, sign, round) \
224
+uint32_t HELPER(name)(ftype x, void *fpstp) \
225
+{ \
226
+ float_status *fpst = fpstp; \
227
+ if (float##fsz##_is_any_nan(x)) { \
228
+ float_raise(float_flag_invalid, fpst); \
229
+ return 0; \
230
+ } \
231
+ return float##fsz##_to_##sign##int32##round(x, fpst); \
232
}
233
234
-#define FLOAT_CONVS(name, p, fsz, sign) \
235
-CONV_ITOF(vfp_##name##to##p, fsz, sign) \
236
-CONV_FTOI(vfp_to##name##p, fsz, sign, ) \
237
-CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero)
238
+#define FLOAT_CONVS(name, p, ftype, fsz, sign) \
239
+ CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \
240
+ CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \
241
+ CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero)
242
243
-FLOAT_CONVS(si, h, 16, )
244
-FLOAT_CONVS(si, s, 32, )
245
-FLOAT_CONVS(si, d, 64, )
246
-FLOAT_CONVS(ui, h, 16, u)
247
-FLOAT_CONVS(ui, s, 32, u)
248
-FLOAT_CONVS(ui, d, 64, u)
249
+FLOAT_CONVS(si, h, uint32_t, 16, )
250
+FLOAT_CONVS(si, s, float32, 32, )
251
+FLOAT_CONVS(si, d, float64, 64, )
252
+FLOAT_CONVS(ui, h, uint32_t, 16, u)
253
+FLOAT_CONVS(ui, s, float32, 32, u)
254
+FLOAT_CONVS(ui, d, float64, 64, u)
255
256
#undef CONV_ITOF
257
#undef CONV_FTOI
258
@@ -XXX,XX +XXX,XX @@ static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst)
259
return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst);
260
}
261
262
-float16 HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst)
263
+uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst)
264
{
265
return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst);
266
}
267
268
-float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst)
269
+uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst)
270
{
271
return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst);
272
}
273
274
-float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst)
275
+uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst)
276
{
277
return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst);
278
}
279
280
-float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
281
+uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
282
{
283
return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst);
284
}
285
@@ -XXX,XX +XXX,XX @@ static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst)
286
}
287
}
288
289
-uint32_t HELPER(vfp_toshh)(float16 x, uint32_t shift, void *fpst)
290
+uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst)
291
{
292
return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst);
293
}
294
295
-uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst)
296
+uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst)
297
{
298
return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst);
299
}
300
301
-uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst)
302
+uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst)
303
{
304
return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst);
305
}
306
307
-uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst)
308
+uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst)
309
{
310
return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst);
311
}
312
313
-uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst)
314
+uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst)
315
{
316
return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst);
317
}
318
319
-uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst)
320
+uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst)
321
{
322
return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst);
323
}
324
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env)
325
}
326
327
/* Half precision conversions. */
328
-float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode)
329
+float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode)
330
{
331
/* Squash FZ16 to 0 for the duration of conversion. In this case,
332
* it would affect flushing input denormals.
333
@@ -XXX,XX +XXX,XX @@ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode)
334
return r;
335
}
336
337
-float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode)
338
+uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode)
339
{
340
/* Squash FZ16 to 0 for the duration of conversion. In this case,
341
* it would affect flushing output denormals.
342
@@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode)
343
return r;
344
}
345
346
-float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode)
347
+float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode)
348
{
349
/* Squash FZ16 to 0 for the duration of conversion. In this case,
350
* it would affect flushing input denormals.
351
@@ -XXX,XX +XXX,XX @@ float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode)
352
return r;
353
}
354
355
-float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode)
356
+uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode)
357
{
358
/* Squash FZ16 to 0 for the duration of conversion. In this case,
359
* it would affect flushing output denormals.
360
@@ -XXX,XX +XXX,XX @@ static bool round_to_inf(float_status *fpst, bool sign_bit)
361
g_assert_not_reached();
362
}
363
364
-float16 HELPER(recpe_f16)(float16 input, void *fpstp)
365
+uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp)
366
{
367
float_status *fpst = fpstp;
368
float16 f16 = float16_squash_input_denormal(input, fpst);
369
@@ -XXX,XX +XXX,XX @@ static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac)
370
return extract64(estimate, 0, 8) << 44;
371
}
372
373
-float16 HELPER(rsqrte_f16)(float16 input, void *fpstp)
374
+uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp)
375
{
376
float_status *s = fpstp;
377
float16 f16 = float16_squash_input_denormal(input, s);
378
--
379
2.17.1
380
381
diff view generated by jsdifflib
New patch
1
From: Igor Mammedov <imammedo@redhat.com>
1
2
3
When QEMU is started with following CLI
4
-machine virt,gic-version=3,accel=kvm -cpu host -bios AAVMF_CODE.fd
5
it crashes with abort at
6
accel/kvm/kvm-all.c:2164:
7
KVM_SET_DEVICE_ATTR failed: Group 6 attr 0x000000000000c665: Invalid argument
8
9
Which is caused by implicit dependency of kvm_arm_gicv3_reset() on
10
arm_gicv3_icc_reset() where the later is called by CPU reset
11
reset callback.
12
13
However commit:
14
3b77f6c arm/boot: split load_dtb() from arm_load_kernel()
15
broke CPU reset callback registration in case
16
17
arm_load_kernel()
18
...
19
if (!info->kernel_filename || info->firmware_loaded)
20
21
branch is taken, i.e. it's sufficient to provide a firmware
22
or do not provide kernel on CLI to skip cpu reset callback
23
registration, where before offending commit the callback
24
has been registered unconditionally.
25
26
Fix it by registering the callback right at the beginning of
27
arm_load_kernel() unconditionally instead of doing it at the end.
28
29
NOTE:
30
we probably should eliminate that dependency anyways as well as
31
separate arch CPU reset parts from arm_load_kernel() into CPU
32
itself, but that refactoring that I probably would have to do
33
anyways later for CPU hotplug to work.
34
35
Reported-by: Auger Eric <eric.auger@redhat.com>
36
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
37
Reviewed-by: Eric Auger <eric.auger@redhat.com>
38
Tested-by: Eric Auger <eric.auger@redhat.com>
39
Message-id: 1527070950-208350-1-git-send-email-imammedo@redhat.com
40
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
41
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
---
43
hw/arm/boot.c | 18 +++++++++---------
44
1 file changed, 9 insertions(+), 9 deletions(-)
45
46
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/boot.c
49
+++ b/hw/arm/boot.c
50
@@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
51
static const ARMInsnFixup *primary_loader;
52
AddressSpace *as = arm_boot_address_space(cpu, info);
53
54
+ /* CPU objects (unlike devices) are not automatically reset on system
55
+ * reset, so we must always register a handler to do so. If we're
56
+ * actually loading a kernel, the handler is also responsible for
57
+ * arranging that we start it correctly.
58
+ */
59
+ for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) {
60
+ qemu_register_reset(do_cpu_reset, ARM_CPU(cs));
61
+ }
62
+
63
/* The board code is not supposed to set secure_board_setup unless
64
* running its code in secure mode is actually possible, and KVM
65
* doesn't support secure.
66
@@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
67
ARM_CPU(cs)->env.boot_info = info;
68
}
69
70
- /* CPU objects (unlike devices) are not automatically reset on system
71
- * reset, so we must always register a handler to do so. If we're
72
- * actually loading a kernel, the handler is also responsible for
73
- * arranging that we start it correctly.
74
- */
75
- for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) {
76
- qemu_register_reset(do_cpu_reset, ARM_CPU(cs));
77
- }
78
-
79
if (!info->skip_dtb_autoload && have_dtb(info)) {
80
if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as) < 0) {
81
exit(1);
82
--
83
2.17.1
84
85
diff view generated by jsdifflib
New patch
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
2
3
cpregs_keys is an uint32_t* so the allocation should use uint32_t.
4
g_new is even better because it is type-safe.
5
6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/gdbstub.c | 3 +--
12
1 file changed, 1 insertion(+), 2 deletions(-)
13
14
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/gdbstub.c
17
+++ b/target/arm/gdbstub.c
18
@@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_xml(CPUState *cs)
19
RegisterSysregXmlParam param = {cs, s};
20
21
cpu->dyn_xml.num_cpregs = 0;
22
- cpu->dyn_xml.cpregs_keys = g_malloc(sizeof(uint32_t *) *
23
- g_hash_table_size(cpu->cp_regs));
24
+ cpu->dyn_xml.cpregs_keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs));
25
g_string_printf(s, "<?xml version=\"1.0\"?>");
26
g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">");
27
g_string_append_printf(s, "<feature name=\"org.qemu.gdb.arm.sys.regs\">");
28
--
29
2.17.1
30
31
diff view generated by jsdifflib
New patch
1
From: Francisco Iglesias <frasse.iglesias@gmail.com>
1
2
3
Coverity found that the string return by 'object_get_canonical_path' was not
4
being freed at two locations in the model (CID 1391294 and CID 1391293) and
5
also that a memset was being called with a value greater than the max of a byte
6
on the second argument (CID 1391286). This patch corrects this by adding the
7
freeing of the strings and also changing to memset to zero instead on
8
descriptor unaligned errors.
9
10
Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com>
11
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20180528184859.3530-1-frasse.iglesias@gmail.com
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
hw/dma/xlnx-zdma.c | 10 +++++++---
18
1 file changed, 7 insertions(+), 3 deletions(-)
19
20
diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/dma/xlnx-zdma.c
23
+++ b/hw/dma/xlnx-zdma.c
24
@@ -XXX,XX +XXX,XX @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf)
25
qemu_log_mask(LOG_GUEST_ERROR,
26
"zdma: unaligned descriptor at %" PRIx64,
27
addr);
28
- memset(buf, 0xdeadbeef, sizeof(XlnxZDMADescr));
29
+ memset(buf, 0x0, sizeof(XlnxZDMADescr));
30
s->error = true;
31
return false;
32
}
33
@@ -XXX,XX +XXX,XX @@ static uint64_t zdma_read(void *opaque, hwaddr addr, unsigned size)
34
RegisterInfo *r = &s->regs_info[addr / 4];
35
36
if (!r->data) {
37
+ gchar *path = object_get_canonical_path(OBJECT(s));
38
qemu_log("%s: Decode error: read from %" HWADDR_PRIx "\n",
39
- object_get_canonical_path(OBJECT(s)),
40
+ path,
41
addr);
42
+ g_free(path);
43
ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true);
44
zdma_ch_imr_update_irq(s);
45
return 0;
46
@@ -XXX,XX +XXX,XX @@ static void zdma_write(void *opaque, hwaddr addr, uint64_t value,
47
RegisterInfo *r = &s->regs_info[addr / 4];
48
49
if (!r->data) {
50
+ gchar *path = object_get_canonical_path(OBJECT(s));
51
qemu_log("%s: Decode error: write to %" HWADDR_PRIx "=%" PRIx64 "\n",
52
- object_get_canonical_path(OBJECT(s)),
53
+ path,
54
addr, value);
55
+ g_free(path);
56
ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true);
57
zdma_ch_imr_update_irq(s);
58
return;
59
--
60
2.17.1
61
62
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
In commit f0aff255700 we made cpacr_write() enforce that some CPACR
2
bits are RAZ/WI and some are RAO/WI for ARMv7 cores. Unfortunately
3
we forgot to also update the register's reset value. The effect
4
was that (a) a guest that read CPACR on reset would not see ones in
5
the RAO bits, and (b) if you did a migration before the guest did
6
a write to the CPACR then the migration would fail because the
7
destination would enforce the RAO bits and then complain that they
8
didn't match the zero value from the source.
2
9
3
As the gen_goto_tb function can do both static and dynamic jumps it
10
Implement reset for the CPACR using a custom reset function
4
should also set the is_jmp field. This matches the behaviour of the
11
that just calls cpacr_write(), to avoid having to duplicate
5
a64 code.
12
the logic for which bits are RAO.
6
13
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
14
This bug would affect migration for TCG CPUs which are ARMv7
8
Reviewed-by: Richard Henderson <rth@twiddle.net>
15
with VFP but without one of Neon or VFPv3.
9
Message-id: 20170713141928.25419-5-alex.bennee@linaro.org
16
10
[tweak to multiline comment formatting]
17
Reported-by: Cédric Le Goater <clg@kaod.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Tested-by: Cédric Le Goater <clg@kaod.org>
20
Message-id: 20180522173713.26282-1-peter.maydell@linaro.org
12
---
21
---
13
target/arm/translate.c | 6 +++++-
22
target/arm/helper.c | 10 +++++++++-
14
1 file changed, 5 insertions(+), 1 deletion(-)
23
1 file changed, 9 insertions(+), 1 deletion(-)
15
24
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
25
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
27
--- a/target/arm/helper.c
19
+++ b/target/arm/translate.c
28
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ static void gen_goto_ptr(void)
29
@@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri,
21
tcg_temp_free(addr);
30
env->cp15.cpacr_el1 = value;
22
}
31
}
23
32
24
+/* This will end the TB but doesn't guarantee we'll return to
33
+static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri)
25
+ * cpu_loop_exec. Any live exit_requests will be processed as we
34
+{
26
+ * enter the next TB.
35
+ /* Call cpacr_write() so that we reset with the correct RAO bits set
27
+ */
36
+ * for our CPU features.
28
static void gen_goto_tb(DisasContext *s, int n, target_ulong dest)
37
+ */
38
+ cpacr_write(env, ri, 0);
39
+}
40
+
41
static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
42
bool isread)
29
{
43
{
30
if (use_goto_tb(s, dest)) {
44
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = {
31
@@ -XXX,XX +XXX,XX @@ static void gen_goto_tb(DisasContext *s, int n, target_ulong dest)
45
{ .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3,
32
gen_set_pc_im(s, dest);
46
.crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access,
33
gen_goto_ptr();
47
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1),
34
}
48
- .resetvalue = 0, .writefn = cpacr_write },
35
+ s->is_jmp = DISAS_TB_JUMP;
49
+ .resetfn = cpacr_reset, .writefn = cpacr_write },
36
}
50
REGINFO_SENTINEL
37
51
};
38
static inline void gen_jmp (DisasContext *s, uint32_t dest)
39
@@ -XXX,XX +XXX,XX @@ static inline void gen_jmp (DisasContext *s, uint32_t dest)
40
gen_bx_im(s, dest);
41
} else {
42
gen_goto_tb(s, 0, dest);
43
- s->is_jmp = DISAS_TB_JUMP;
44
}
45
}
46
52
47
--
53
--
48
2.7.4
54
2.17.1
49
55
50
56
diff view generated by jsdifflib
1
Implement a model of the Serial Communication Controller (SCC) found
1
Add more detail to the documentation for memory_region_init_iommu()
2
in MPS2 FPGA images.
2
and other IOMMU-related functions and data structures.
3
4
The primary purpose of this device is to communicate with the
5
Motherboard Configuration Controller (MCC) which is located on
6
the MPS board itself, outside the FPGA image. This is used
7
for programming the MPS clock generators. The SCC also has
8
some basic ID registers and an output for the board LEDs.
9
3
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 1500029487-14822-7-git-send-email-peter.maydell@linaro.org
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Message-id: 20180521140402.23318-2-peter.maydell@linaro.org
13
---
9
---
14
hw/misc/Makefile.objs | 1 +
10
include/exec/memory.h | 105 ++++++++++++++++++++++++++++++++++++++----
15
include/hw/misc/mps2-scc.h | 43 ++++++
11
1 file changed, 95 insertions(+), 10 deletions(-)
16
hw/misc/mps2-scc.c | 310 ++++++++++++++++++++++++++++++++++++++++
17
default-configs/arm-softmmu.mak | 2 +
18
hw/misc/trace-events | 8 ++
19
5 files changed, 364 insertions(+)
20
create mode 100644 include/hw/misc/mps2-scc.h
21
create mode 100644 hw/misc/mps2-scc.c
22
12
23
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
13
diff --git a/include/exec/memory.h b/include/exec/memory.h
24
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/misc/Makefile.objs
15
--- a/include/exec/memory.h
26
+++ b/hw/misc/Makefile.objs
16
+++ b/include/exec/memory.h
27
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_STM32F2XX_SYSCFG) += stm32f2xx_syscfg.o
17
@@ -XXX,XX +XXX,XX @@ enum IOMMUMemoryRegionAttr {
28
obj-$(CONFIG_MIPS_CPS) += mips_cmgcr.o
18
IOMMU_ATTR_SPAPR_TCE_FD
29
obj-$(CONFIG_MIPS_CPS) += mips_cpc.o
19
};
30
obj-$(CONFIG_MIPS_ITU) += mips_itu.o
20
31
+obj-$(CONFIG_MPS2_SCC) += mps2-scc.o
21
+/**
32
22
+ * IOMMUMemoryRegionClass:
33
obj-$(CONFIG_PVPANIC) += pvpanic.o
34
obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
35
diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h
36
new file mode 100644
37
index XXXXXXX..XXXXXXX
38
--- /dev/null
39
+++ b/include/hw/misc/mps2-scc.h
40
@@ -XXX,XX +XXX,XX @@
41
+/*
42
+ * ARM MPS2 SCC emulation
43
+ *
23
+ *
44
+ * Copyright (c) 2017 Linaro Limited
24
+ * All IOMMU implementations need to subclass TYPE_IOMMU_MEMORY_REGION
45
+ * Written by Peter Maydell
25
+ * and provide an implementation of at least the @translate method here
26
+ * to handle requests to the memory region. Other methods are optional.
46
+ *
27
+ *
47
+ * This program is free software; you can redistribute it and/or modify
28
+ * The IOMMU implementation must use the IOMMU notifier infrastructure
48
+ * it under the terms of the GNU General Public License version 2 or
29
+ * to report whenever mappings are changed, by calling
49
+ * (at your option) any later version.
30
+ * memory_region_notify_iommu() (or, if necessary, by calling
31
+ * memory_region_notify_one() for each registered notifier).
50
+ */
32
+ */
51
+
33
typedef struct IOMMUMemoryRegionClass {
52
+#ifndef MPS2_SCC_H
34
/* private */
53
+#define MPS2_SCC_H
35
struct DeviceClass parent_class;
54
+
36
55
+#include "hw/sysbus.h"
37
/*
56
+
38
- * Return a TLB entry that contains a given address. Flag should
57
+#define TYPE_MPS2_SCC "mps2-scc"
39
- * be the access permission of this translation operation. We can
58
+#define MPS2_SCC(obj) OBJECT_CHECK(MPS2SCC, (obj), TYPE_MPS2_SCC)
40
- * set flag to IOMMU_NONE to mean that we don't need any
59
+
41
- * read/write permission checks, like, when for region replay.
60
+#define NUM_OSCCLK 3
42
+ * Return a TLB entry that contains a given address.
61
+
43
+ *
62
+typedef struct {
44
+ * The IOMMUAccessFlags indicated via @flag are optional and may
63
+ /*< private >*/
45
+ * be specified as IOMMU_NONE to indicate that the caller needs
64
+ SysBusDevice parent_obj;
46
+ * the full translation information for both reads and writes. If
65
+
47
+ * the access flags are specified then the IOMMU implementation
66
+ /*< public >*/
48
+ * may use this as an optimization, to stop doing a page table
67
+ MemoryRegion iomem;
49
+ * walk as soon as it knows that the requested permissions are not
68
+
50
+ * allowed. If IOMMU_NONE is passed then the IOMMU must do the
69
+ uint32_t cfg0;
51
+ * full page table walk and report the permissions in the returned
70
+ uint32_t cfg1;
52
+ * IOMMUTLBEntry. (Note that this implies that an IOMMU may not
71
+ uint32_t cfg4;
53
+ * return different mappings for reads and writes.)
72
+ uint32_t cfgdata_rtn;
54
+ *
73
+ uint32_t cfgdata_out;
55
+ * The returned information remains valid while the caller is
74
+ uint32_t cfgctrl;
56
+ * holding the big QEMU lock or is inside an RCU critical section;
75
+ uint32_t cfgstat;
57
+ * if the caller wishes to cache the mapping beyond that it must
76
+ uint32_t dll;
58
+ * register an IOMMU notifier so it can invalidate its cached
77
+ uint32_t aid;
59
+ * information when the IOMMU mapping changes.
78
+ uint32_t id;
60
+ *
79
+ uint32_t oscclk[NUM_OSCCLK];
61
+ * @iommu: the IOMMUMemoryRegion
80
+ uint32_t oscclk_reset[NUM_OSCCLK];
62
+ * @hwaddr: address to be translated within the memory region
81
+} MPS2SCC;
63
+ * @flag: requested access permissions
82
+
64
*/
83
+#endif
65
IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr,
84
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
66
IOMMUAccessFlags flag);
85
new file mode 100644
67
- /* Returns minimum supported page size */
86
index XXXXXXX..XXXXXXX
68
+ /* Returns minimum supported page size in bytes.
87
--- /dev/null
69
+ * If this method is not provided then the minimum is assumed to
88
+++ b/hw/misc/mps2-scc.c
70
+ * be TARGET_PAGE_SIZE.
89
@@ -XXX,XX +XXX,XX @@
71
+ *
90
+/*
72
+ * @iommu: the IOMMUMemoryRegion
91
+ * ARM MPS2 SCC emulation
73
+ */
74
uint64_t (*get_min_page_size)(IOMMUMemoryRegion *iommu);
75
- /* Called when IOMMU Notifier flag changed */
76
+ /* Called when IOMMU Notifier flag changes (ie when the set of
77
+ * events which IOMMU users are requesting notification for changes).
78
+ * Optional method -- need not be provided if the IOMMU does not
79
+ * need to know exactly which events must be notified.
80
+ *
81
+ * @iommu: the IOMMUMemoryRegion
82
+ * @old_flags: events which previously needed to be notified
83
+ * @new_flags: events which now need to be notified
84
+ */
85
void (*notify_flag_changed)(IOMMUMemoryRegion *iommu,
86
IOMMUNotifierFlag old_flags,
87
IOMMUNotifierFlag new_flags);
88
- /* Set this up to provide customized IOMMU replay function */
89
+ /* Called to handle memory_region_iommu_replay().
90
+ *
91
+ * The default implementation of memory_region_iommu_replay() is to
92
+ * call the IOMMU translate method for every page in the address space
93
+ * with flag == IOMMU_NONE and then call the notifier if translate
94
+ * returns a valid mapping. If this method is implemented then it
95
+ * overrides the default behaviour, and must provide the full semantics
96
+ * of memory_region_iommu_replay(), by calling @notifier for every
97
+ * translation present in the IOMMU.
98
+ *
99
+ * Optional method -- an IOMMU only needs to provide this method
100
+ * if the default is inefficient or produces undesirable side effects.
101
+ *
102
+ * Note: this is not related to record-and-replay functionality.
103
+ */
104
void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier);
105
106
- /* Get IOMMU misc attributes */
107
- int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr,
108
+ /* Get IOMMU misc attributes. This is an optional method that
109
+ * can be used to allow users of the IOMMU to get implementation-specific
110
+ * information. The IOMMU implements this method to handle calls
111
+ * by IOMMU users to memory_region_iommu_get_attr() by filling in
112
+ * the arbitrary data pointer for any IOMMUMemoryRegionAttr values that
113
+ * the IOMMU supports. If the method is unimplemented then
114
+ * memory_region_iommu_get_attr() will always return -EINVAL.
115
+ *
116
+ * @iommu: the IOMMUMemoryRegion
117
+ * @attr: attribute being queried
118
+ * @data: memory to fill in with the attribute data
119
+ *
120
+ * Returns 0 on success, or a negative errno; in particular
121
+ * returns -EINVAL for unrecognized or unimplemented attribute types.
122
+ */
123
+ int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr attr,
124
void *data);
125
} IOMMUMemoryRegionClass;
126
127
@@ -XXX,XX +XXX,XX @@ static inline void memory_region_init_reservation(MemoryRegion *mr,
128
* An IOMMU region translates addresses and forwards accesses to a target
129
* memory region.
130
*
131
+ * The IOMMU implementation must define a subclass of TYPE_IOMMU_MEMORY_REGION.
132
+ * @_iommu_mr should be a pointer to enough memory for an instance of
133
+ * that subclass, @instance_size is the size of that subclass, and
134
+ * @mrtypename is its name. This function will initialize @_iommu_mr as an
135
+ * instance of the subclass, and its methods will then be called to handle
136
+ * accesses to the memory region. See the documentation of
137
+ * #IOMMUMemoryRegionClass for further details.
92
+ *
138
+ *
93
+ * Copyright (c) 2017 Linaro Limited
139
* @_iommu_mr: the #IOMMUMemoryRegion to be initialized
94
+ * Written by Peter Maydell
140
* @instance_size: the IOMMUMemoryRegion subclass instance size
141
* @mrtypename: the type name of the #IOMMUMemoryRegion
142
@@ -XXX,XX +XXX,XX @@ void memory_region_register_iommu_notifier(MemoryRegion *mr,
143
* a notifier with the minimum page granularity returned by
144
* mr->iommu_ops->get_page_size().
145
*
146
+ * Note: this is not related to record-and-replay functionality.
95
+ *
147
+ *
96
+ * This program is free software; you can redistribute it and/or modify
148
* @iommu_mr: the memory region to observe
97
+ * it under the terms of the GNU General Public License version 2 or
149
* @n: the notifier to which to replay iommu mappings
98
+ * (at your option) any later version.
150
*/
99
+ */
151
@@ -XXX,XX +XXX,XX @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n);
100
+
152
* memory_region_iommu_replay_all: replay existing IOMMU translations
101
+/* This is a model of the SCC (Serial Communication Controller)
153
* to all the notifiers registered.
102
+ * found in the FPGA images of MPS2 development boards.
154
*
155
+ * Note: this is not related to record-and-replay functionality.
103
+ *
156
+ *
104
+ * Documentation of it can be found in the MPS2 TRM:
157
* @iommu_mr: the memory region to observe
105
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.100112_0100_03_en/index.html
158
*/
106
+ * and also in the Application Notes documenting individual FPGA images.
159
void memory_region_iommu_replay_all(IOMMUMemoryRegion *iommu_mr);
107
+ */
160
@@ -XXX,XX +XXX,XX @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr,
108
+
161
* memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is
109
+#include "qemu/osdep.h"
162
* defined on the IOMMU.
110
+#include "qemu/log.h"
163
*
111
+#include "qapi/error.h"
164
- * Returns 0 if succeded, error code otherwise.
112
+#include "trace.h"
165
+ * Returns 0 on success, or a negative errno otherwise. In particular,
113
+#include "hw/sysbus.h"
166
+ * -EINVAL indicates that the IOMMU does not support the requested
114
+#include "hw/registerfields.h"
167
+ * attribute.
115
+#include "hw/misc/mps2-scc.h"
168
*
116
+
169
* @iommu_mr: the memory region
117
+REG32(CFG0, 0)
170
* @attr: the requested attribute
118
+REG32(CFG1, 4)
119
+REG32(CFG3, 0xc)
120
+REG32(CFG4, 0x10)
121
+REG32(CFGDATA_RTN, 0xa0)
122
+REG32(CFGDATA_OUT, 0xa4)
123
+REG32(CFGCTRL, 0xa8)
124
+ FIELD(CFGCTRL, DEVICE, 0, 12)
125
+ FIELD(CFGCTRL, RES1, 12, 8)
126
+ FIELD(CFGCTRL, FUNCTION, 20, 6)
127
+ FIELD(CFGCTRL, RES2, 26, 4)
128
+ FIELD(CFGCTRL, WRITE, 30, 1)
129
+ FIELD(CFGCTRL, START, 31, 1)
130
+REG32(CFGSTAT, 0xac)
131
+ FIELD(CFGSTAT, DONE, 0, 1)
132
+ FIELD(CFGSTAT, ERROR, 1, 1)
133
+REG32(DLL, 0x100)
134
+REG32(AID, 0xFF8)
135
+REG32(ID, 0xFFC)
136
+
137
+/* Handle a write via the SYS_CFG channel to the specified function/device.
138
+ * Return false on error (reported to guest via SYS_CFGCTRL ERROR bit).
139
+ */
140
+static bool scc_cfg_write(MPS2SCC *s, unsigned function,
141
+ unsigned device, uint32_t value)
142
+{
143
+ trace_mps2_scc_cfg_write(function, device, value);
144
+
145
+ if (function != 1 || device >= NUM_OSCCLK) {
146
+ qemu_log_mask(LOG_GUEST_ERROR,
147
+ "MPS2 SCC config write: bad function %d device %d\n",
148
+ function, device);
149
+ return false;
150
+ }
151
+
152
+ s->oscclk[device] = value;
153
+ return true;
154
+}
155
+
156
+/* Handle a read via the SYS_CFG channel to the specified function/device.
157
+ * Return false on error (reported to guest via SYS_CFGCTRL ERROR bit),
158
+ * or set *value on success.
159
+ */
160
+static bool scc_cfg_read(MPS2SCC *s, unsigned function,
161
+ unsigned device, uint32_t *value)
162
+{
163
+ if (function != 1 || device >= NUM_OSCCLK) {
164
+ qemu_log_mask(LOG_GUEST_ERROR,
165
+ "MPS2 SCC config read: bad function %d device %d\n",
166
+ function, device);
167
+ return false;
168
+ }
169
+
170
+ *value = s->oscclk[device];
171
+
172
+ trace_mps2_scc_cfg_read(function, device, *value);
173
+ return true;
174
+}
175
+
176
+static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size)
177
+{
178
+ MPS2SCC *s = MPS2_SCC(opaque);
179
+ uint64_t r;
180
+
181
+ switch (offset) {
182
+ case A_CFG0:
183
+ r = s->cfg0;
184
+ break;
185
+ case A_CFG1:
186
+ r = s->cfg1;
187
+ break;
188
+ case A_CFG3:
189
+ /* These are user-settable DIP switches on the board. We don't
190
+ * model that, so just return zeroes.
191
+ */
192
+ r = 0;
193
+ break;
194
+ case A_CFG4:
195
+ r = s->cfg4;
196
+ break;
197
+ case A_CFGDATA_RTN:
198
+ r = s->cfgdata_rtn;
199
+ break;
200
+ case A_CFGDATA_OUT:
201
+ r = s->cfgdata_out;
202
+ break;
203
+ case A_CFGCTRL:
204
+ r = s->cfgctrl;
205
+ break;
206
+ case A_CFGSTAT:
207
+ r = s->cfgstat;
208
+ break;
209
+ case A_DLL:
210
+ r = s->dll;
211
+ break;
212
+ case A_AID:
213
+ r = s->aid;
214
+ break;
215
+ case A_ID:
216
+ r = s->id;
217
+ break;
218
+ default:
219
+ qemu_log_mask(LOG_GUEST_ERROR,
220
+ "MPS2 SCC read: bad offset %x\n", (int) offset);
221
+ r = 0;
222
+ break;
223
+ }
224
+
225
+ trace_mps2_scc_read(offset, r, size);
226
+ return r;
227
+}
228
+
229
+static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value,
230
+ unsigned size)
231
+{
232
+ MPS2SCC *s = MPS2_SCC(opaque);
233
+
234
+ trace_mps2_scc_write(offset, value, size);
235
+
236
+ switch (offset) {
237
+ case A_CFG0:
238
+ /* TODO on some boards bit 0 controls RAM remapping */
239
+ s->cfg0 = value;
240
+ break;
241
+ case A_CFG1:
242
+ /* CFG1 bits [7:0] control the board LEDs. We don't currently have
243
+ * a mechanism for displaying this graphically, so use a trace event.
244
+ */
245
+ trace_mps2_scc_leds(value & 0x80 ? '*' : '.',
246
+ value & 0x40 ? '*' : '.',
247
+ value & 0x20 ? '*' : '.',
248
+ value & 0x10 ? '*' : '.',
249
+ value & 0x08 ? '*' : '.',
250
+ value & 0x04 ? '*' : '.',
251
+ value & 0x02 ? '*' : '.',
252
+ value & 0x01 ? '*' : '.');
253
+ s->cfg1 = value;
254
+ break;
255
+ case A_CFGDATA_OUT:
256
+ s->cfgdata_out = value;
257
+ break;
258
+ case A_CFGCTRL:
259
+ /* Writing to CFGCTRL clears SYS_CFGSTAT */
260
+ s->cfgstat = 0;
261
+ s->cfgctrl = value & ~(R_CFGCTRL_RES1_MASK |
262
+ R_CFGCTRL_RES2_MASK |
263
+ R_CFGCTRL_START_MASK);
264
+
265
+ if (value & R_CFGCTRL_START_MASK) {
266
+ /* Start bit set -- do a read or write (instantaneously) */
267
+ int device = extract32(s->cfgctrl, R_CFGCTRL_DEVICE_SHIFT,
268
+ R_CFGCTRL_DEVICE_LENGTH);
269
+ int function = extract32(s->cfgctrl, R_CFGCTRL_FUNCTION_SHIFT,
270
+ R_CFGCTRL_FUNCTION_LENGTH);
271
+
272
+ s->cfgstat = R_CFGSTAT_DONE_MASK;
273
+ if (s->cfgctrl & R_CFGCTRL_WRITE_MASK) {
274
+ if (!scc_cfg_write(s, function, device, s->cfgdata_out)) {
275
+ s->cfgstat |= R_CFGSTAT_ERROR_MASK;
276
+ }
277
+ } else {
278
+ uint32_t result;
279
+ if (!scc_cfg_read(s, function, device, &result)) {
280
+ s->cfgstat |= R_CFGSTAT_ERROR_MASK;
281
+ } else {
282
+ s->cfgdata_rtn = result;
283
+ }
284
+ }
285
+ }
286
+ break;
287
+ case A_DLL:
288
+ /* DLL stands for Digital Locked Loop.
289
+ * Bits [31:24] (DLL_LOCK_MASK) are writable, and indicate a
290
+ * mask of which of the DLL_LOCKED bits [16:23] should be ORed
291
+ * together to determine the ALL_UNMASKED_DLLS_LOCKED bit [0].
292
+ * For QEMU, our DLLs are always locked, so we can leave bit 0
293
+ * as 1 always and don't need to recalculate it.
294
+ */
295
+ s->dll = deposit32(s->dll, 24, 8, extract32(value, 24, 8));
296
+ break;
297
+ default:
298
+ qemu_log_mask(LOG_GUEST_ERROR,
299
+ "MPS2 SCC write: bad offset 0x%x\n", (int) offset);
300
+ break;
301
+ }
302
+}
303
+
304
+static const MemoryRegionOps mps2_scc_ops = {
305
+ .read = mps2_scc_read,
306
+ .write = mps2_scc_write,
307
+ .endianness = DEVICE_LITTLE_ENDIAN,
308
+};
309
+
310
+static void mps2_scc_reset(DeviceState *dev)
311
+{
312
+ MPS2SCC *s = MPS2_SCC(dev);
313
+ int i;
314
+
315
+ trace_mps2_scc_reset();
316
+ s->cfg0 = 0;
317
+ s->cfg1 = 0;
318
+ s->cfgdata_rtn = 0;
319
+ s->cfgdata_out = 0;
320
+ s->cfgctrl = 0x100000;
321
+ s->cfgstat = 0;
322
+ s->dll = 0xffff0001;
323
+ for (i = 0; i < NUM_OSCCLK; i++) {
324
+ s->oscclk[i] = s->oscclk_reset[i];
325
+ }
326
+}
327
+
328
+static void mps2_scc_init(Object *obj)
329
+{
330
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
331
+ MPS2SCC *s = MPS2_SCC(obj);
332
+
333
+ memory_region_init_io(&s->iomem, obj, &mps2_scc_ops, s, "mps2-scc", 0x1000);
334
+ sysbus_init_mmio(sbd, &s->iomem);
335
+}
336
+
337
+static void mps2_scc_realize(DeviceState *dev, Error **errp)
338
+{
339
+}
340
+
341
+static const VMStateDescription mps2_scc_vmstate = {
342
+ .name = "mps2-scc",
343
+ .version_id = 1,
344
+ .minimum_version_id = 1,
345
+ .fields = (VMStateField[]) {
346
+ VMSTATE_UINT32(cfg0, MPS2SCC),
347
+ VMSTATE_UINT32(cfg1, MPS2SCC),
348
+ VMSTATE_UINT32(cfgdata_rtn, MPS2SCC),
349
+ VMSTATE_UINT32(cfgdata_out, MPS2SCC),
350
+ VMSTATE_UINT32(cfgctrl, MPS2SCC),
351
+ VMSTATE_UINT32(cfgstat, MPS2SCC),
352
+ VMSTATE_UINT32(dll, MPS2SCC),
353
+ VMSTATE_UINT32_ARRAY(oscclk, MPS2SCC, NUM_OSCCLK),
354
+ VMSTATE_END_OF_LIST()
355
+ }
356
+};
357
+
358
+static Property mps2_scc_properties[] = {
359
+ /* Values for various read-only ID registers (which are specific
360
+ * to the board model or FPGA image)
361
+ */
362
+ DEFINE_PROP_UINT32("scc-cfg4", MPS2SCC, aid, 0),
363
+ DEFINE_PROP_UINT32("scc-aid", MPS2SCC, aid, 0),
364
+ DEFINE_PROP_UINT32("scc-id", MPS2SCC, aid, 0),
365
+ /* These are the initial settings for the source clocks on the board.
366
+ * In hardware they can be configured via a config file read by the
367
+ * motherboard configuration controller to suit the FPGA image.
368
+ * These default values are used by most of the standard FPGA images.
369
+ */
370
+ DEFINE_PROP_UINT32("oscclk0", MPS2SCC, oscclk_reset[0], 50000000),
371
+ DEFINE_PROP_UINT32("oscclk1", MPS2SCC, oscclk_reset[1], 24576000),
372
+ DEFINE_PROP_UINT32("oscclk2", MPS2SCC, oscclk_reset[2], 25000000),
373
+ DEFINE_PROP_END_OF_LIST(),
374
+};
375
+
376
+static void mps2_scc_class_init(ObjectClass *klass, void *data)
377
+{
378
+ DeviceClass *dc = DEVICE_CLASS(klass);
379
+
380
+ dc->realize = mps2_scc_realize;
381
+ dc->vmsd = &mps2_scc_vmstate;
382
+ dc->reset = mps2_scc_reset;
383
+ dc->props = mps2_scc_properties;
384
+}
385
+
386
+static const TypeInfo mps2_scc_info = {
387
+ .name = TYPE_MPS2_SCC,
388
+ .parent = TYPE_SYS_BUS_DEVICE,
389
+ .instance_size = sizeof(MPS2SCC),
390
+ .instance_init = mps2_scc_init,
391
+ .class_init = mps2_scc_class_init,
392
+};
393
+
394
+static void mps2_scc_register_types(void)
395
+{
396
+ type_register_static(&mps2_scc_info);
397
+}
398
+
399
+type_init(mps2_scc_register_types);
400
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
401
index XXXXXXX..XXXXXXX 100644
402
--- a/default-configs/arm-softmmu.mak
403
+++ b/default-configs/arm-softmmu.mak
404
@@ -XXX,XX +XXX,XX @@ CONFIG_STM32F205_SOC=y
405
CONFIG_CMSDK_APB_TIMER=y
406
CONFIG_CMSDK_APB_UART=y
407
408
+CONFIG_MPS2_SCC=y
409
+
410
CONFIG_VERSATILE_PCI=y
411
CONFIG_VERSATILE_I2C=y
412
413
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
414
index XXXXXXX..XXXXXXX 100644
415
--- a/hw/misc/trace-events
416
+++ b/hw/misc/trace-events
417
@@ -XXX,XX +XXX,XX @@ milkymist_pfpu_pulse_irq(void) "Pulse IRQ"
418
419
# hw/misc/aspeed_scu.c
420
aspeed_scu_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32
421
+
422
+# hw/misc/mps2_scc.c
423
+mps2_scc_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
424
+mps2_scc_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
425
+mps2_scc_reset(void) "MPS2 SCC: reset"
426
+mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, char led1, char led0) "MPS2 SCC LEDs: %c%c%c%c%c%c%c%c"
427
+mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config write: function %d device %d data 0x%" PRIx32
428
+mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config read: function %d device %d data 0x%" PRIx32
429
--
171
--
430
2.7.4
172
2.17.1
431
173
432
174
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
add MemTxAttrs as an argument to tb_invalidate_phys_addr().
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
2
5
3
As a precursor to later patches attempt to come up with a more
4
concrete wording for what each of the common exit cases would be.
5
6
CC: Emilio G. Cota <cota@braap.org>
7
CC: Richard Henderson <rth@twiddle.net>
8
CC: Lluís Vilanova <vilanova@ac.upc.edu>
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Richard Henderson <rth@twiddle.net>
11
Message-id: 20170713141928.25419-2-alex.bennee@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Message-id: 20180521140402.23318-3-peter.maydell@linaro.org
13
---
10
---
14
include/exec/exec-all.h | 29 ++++++++++++++++++++++++++---
11
include/exec/exec-all.h | 5 +++--
15
1 file changed, 26 insertions(+), 3 deletions(-)
12
accel/tcg/translate-all.c | 2 +-
13
exec.c | 2 +-
14
target/xtensa/op_helper.c | 3 ++-
15
4 files changed, 7 insertions(+), 5 deletions(-)
16
16
17
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
17
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
18
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/exec/exec-all.h
19
--- a/include/exec/exec-all.h
20
+++ b/include/exec/exec-all.h
20
+++ b/include/exec/exec-all.h
21
@@ -XXX,XX +XXX,XX @@ typedef abi_ulong tb_page_addr_t;
21
@@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr,
22
typedef ram_addr_t tb_page_addr_t;
22
void tlb_set_page(CPUState *cpu, target_ulong vaddr,
23
hwaddr paddr, int prot,
24
int mmu_idx, target_ulong size);
25
-void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr);
26
+void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs);
27
void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx,
28
uintptr_t retaddr);
29
#else
30
@@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu,
31
uint16_t idxmap)
32
{
33
}
34
-static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr)
35
+static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr,
36
+ MemTxAttrs attrs)
37
{
38
}
23
#endif
39
#endif
24
40
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
25
-/* is_jmp field values */
41
index XXXXXXX..XXXXXXX 100644
26
+/* DisasContext is_jmp field values
42
--- a/accel/tcg/translate-all.c
27
+ *
43
+++ b/accel/tcg/translate-all.c
28
+ * is_jmp starts as DISAS_NEXT. The translator will keep processing
44
@@ -XXX,XX +XXX,XX @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr)
29
+ * instructions until an exit condition is reached. If we reach the
45
}
30
+ * exit condition and is_jmp is still DISAS_NEXT (because of some
46
31
+ * other condition) we simply "jump" to the next address.
47
#if !defined(CONFIG_USER_ONLY)
32
+ * The remaining exit cases are:
48
-void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr)
33
+ *
49
+void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs)
34
+ * DISAS_JUMP - Only the PC was modified dynamically (e.g computed)
50
{
35
+ * DISAS_TB_JUMP - Only the PC was modified statically (e.g. branch)
51
ram_addr_t ram_addr;
36
+ *
52
MemoryRegion *mr;
37
+ * In these cases as long as the PC is updated we can chain to the
53
diff --git a/exec.c b/exec.c
38
+ * next TB either by exiting the loop or looking up the next TB via
54
index XXXXXXX..XXXXXXX 100644
39
+ * the loookup helper.
55
--- a/exec.c
40
+ *
56
+++ b/exec.c
41
+ * DISAS_UPDATE - CPU State was modified dynamically
57
@@ -XXX,XX +XXX,XX @@ static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
42
+ *
58
if (phys != -1) {
43
+ * This covers any other CPU state which necessities us exiting the
59
/* Locks grabbed by tb_invalidate_phys_addr */
44
+ * TCG code to the main run-loop. Typically this includes anything
60
tb_invalidate_phys_addr(cpu->cpu_ases[asidx].as,
45
+ * that might change the interrupt state.
61
- phys | (pc & ~TARGET_PAGE_MASK));
46
+ *
62
+ phys | (pc & ~TARGET_PAGE_MASK), attrs);
47
+ * Individual translators may define additional exit cases to deal
63
}
48
+ * with per-target special conditions.
64
}
49
+ */
65
#endif
50
#define DISAS_NEXT 0 /* next instruction can be analyzed */
66
diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c
51
#define DISAS_JUMP 1 /* only pc was modified dynamically */
67
index XXXXXXX..XXXXXXX 100644
52
-#define DISAS_UPDATE 2 /* cpu state was modified dynamically */
68
--- a/target/xtensa/op_helper.c
53
-#define DISAS_TB_JUMP 3 /* only pc was modified statically */
69
+++ b/target/xtensa/op_helper.c
54
+#define DISAS_TB_JUMP 2 /* only pc was modified statically */
70
@@ -XXX,XX +XXX,XX @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr)
55
+#define DISAS_UPDATE 3 /* cpu state was modified dynamically */
71
int ret = xtensa_get_physical_addr(env, false, vaddr, 2, 0,
56
72
&paddr, &page_size, &access);
57
#include "qemu/log.h"
73
if (ret == 0) {
74
- tb_invalidate_phys_addr(&address_space_memory, paddr);
75
+ tb_invalidate_phys_addr(&address_space_memory, paddr,
76
+ MEMTXATTRS_UNSPECIFIED);
77
}
78
}
58
79
59
--
80
--
60
2.7.4
81
2.17.1
61
82
62
83
diff view generated by jsdifflib
New patch
1
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
add MemTxAttrs as an argument to address_space_translate()
3
and address_space_translate_cached(). Callers either have an
4
attrs value to hand, or don't care and can use MEMTXATTRS_UNSPECIFIED.
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-4-peter.maydell@linaro.org
10
---
11
include/exec/memory.h | 4 +++-
12
accel/tcg/translate-all.c | 2 +-
13
exec.c | 14 +++++++++-----
14
hw/vfio/common.c | 3 ++-
15
memory_ldst.inc.c | 18 +++++++++---------
16
target/riscv/helper.c | 2 +-
17
6 files changed, 25 insertions(+), 18 deletions(-)
18
19
diff --git a/include/exec/memory.h b/include/exec/memory.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/exec/memory.h
22
+++ b/include/exec/memory.h
23
@@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
24
* #MemoryRegion.
25
* @len: pointer to length
26
* @is_write: indicates the transfer direction
27
+ * @attrs: memory attributes
28
*/
29
MemoryRegion *flatview_translate(FlatView *fv,
30
hwaddr addr, hwaddr *xlat,
31
@@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv,
32
33
static inline MemoryRegion *address_space_translate(AddressSpace *as,
34
hwaddr addr, hwaddr *xlat,
35
- hwaddr *len, bool is_write)
36
+ hwaddr *len, bool is_write,
37
+ MemTxAttrs attrs)
38
{
39
return flatview_translate(address_space_to_flatview(as),
40
addr, xlat, len, is_write);
41
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/accel/tcg/translate-all.c
44
+++ b/accel/tcg/translate-all.c
45
@@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs)
46
hwaddr l = 1;
47
48
rcu_read_lock();
49
- mr = address_space_translate(as, addr, &addr, &l, false);
50
+ mr = address_space_translate(as, addr, &addr, &l, false, attrs);
51
if (!(memory_region_is_ram(mr)
52
|| memory_region_is_romd(mr))) {
53
rcu_read_unlock();
54
diff --git a/exec.c b/exec.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/exec.c
57
+++ b/exec.c
58
@@ -XXX,XX +XXX,XX @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as,
59
rcu_read_lock();
60
while (len > 0) {
61
l = len;
62
- mr = address_space_translate(as, addr, &addr1, &l, true);
63
+ mr = address_space_translate(as, addr, &addr1, &l, true,
64
+ MEMTXATTRS_UNSPECIFIED);
65
66
if (!(memory_region_is_ram(mr) ||
67
memory_region_is_romd(mr))) {
68
@@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache)
69
*/
70
static inline MemoryRegion *address_space_translate_cached(
71
MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat,
72
- hwaddr *plen, bool is_write)
73
+ hwaddr *plen, bool is_write, MemTxAttrs attrs)
74
{
75
MemoryRegionSection section;
76
MemoryRegion *mr;
77
@@ -XXX,XX +XXX,XX @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr,
78
MemoryRegion *mr;
79
80
l = len;
81
- mr = address_space_translate_cached(cache, addr, &addr1, &l, false);
82
+ mr = address_space_translate_cached(cache, addr, &addr1, &l, false,
83
+ MEMTXATTRS_UNSPECIFIED);
84
flatview_read_continue(cache->fv,
85
addr, MEMTXATTRS_UNSPECIFIED, buf, len,
86
addr1, l, mr);
87
@@ -XXX,XX +XXX,XX @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,
88
MemoryRegion *mr;
89
90
l = len;
91
- mr = address_space_translate_cached(cache, addr, &addr1, &l, true);
92
+ mr = address_space_translate_cached(cache, addr, &addr1, &l, true,
93
+ MEMTXATTRS_UNSPECIFIED);
94
flatview_write_continue(cache->fv,
95
addr, MEMTXATTRS_UNSPECIFIED, buf, len,
96
addr1, l, mr);
97
@@ -XXX,XX +XXX,XX @@ bool cpu_physical_memory_is_io(hwaddr phys_addr)
98
99
rcu_read_lock();
100
mr = address_space_translate(&address_space_memory,
101
- phys_addr, &phys_addr, &l, false);
102
+ phys_addr, &phys_addr, &l, false,
103
+ MEMTXATTRS_UNSPECIFIED);
104
105
res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr));
106
rcu_read_unlock();
107
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
108
index XXXXXXX..XXXXXXX 100644
109
--- a/hw/vfio/common.c
110
+++ b/hw/vfio/common.c
111
@@ -XXX,XX +XXX,XX @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr,
112
*/
113
mr = address_space_translate(&address_space_memory,
114
iotlb->translated_addr,
115
- &xlat, &len, writable);
116
+ &xlat, &len, writable,
117
+ MEMTXATTRS_UNSPECIFIED);
118
if (!memory_region_is_ram(mr)) {
119
error_report("iommu map to non memory area %"HWADDR_PRIx"",
120
xlat);
121
diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/memory_ldst.inc.c
124
+++ b/memory_ldst.inc.c
125
@@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL,
126
bool release_lock = false;
127
128
RCU_READ_LOCK();
129
- mr = TRANSLATE(addr, &addr1, &l, false);
130
+ mr = TRANSLATE(addr, &addr1, &l, false, attrs);
131
if (l < 4 || !IS_DIRECT(mr, false)) {
132
release_lock |= prepare_mmio_access(mr);
133
134
@@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL,
135
bool release_lock = false;
136
137
RCU_READ_LOCK();
138
- mr = TRANSLATE(addr, &addr1, &l, false);
139
+ mr = TRANSLATE(addr, &addr1, &l, false, attrs);
140
if (l < 8 || !IS_DIRECT(mr, false)) {
141
release_lock |= prepare_mmio_access(mr);
142
143
@@ -XXX,XX +XXX,XX @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL,
144
bool release_lock = false;
145
146
RCU_READ_LOCK();
147
- mr = TRANSLATE(addr, &addr1, &l, false);
148
+ mr = TRANSLATE(addr, &addr1, &l, false, attrs);
149
if (!IS_DIRECT(mr, false)) {
150
release_lock |= prepare_mmio_access(mr);
151
152
@@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL,
153
bool release_lock = false;
154
155
RCU_READ_LOCK();
156
- mr = TRANSLATE(addr, &addr1, &l, false);
157
+ mr = TRANSLATE(addr, &addr1, &l, false, attrs);
158
if (l < 2 || !IS_DIRECT(mr, false)) {
159
release_lock |= prepare_mmio_access(mr);
160
161
@@ -XXX,XX +XXX,XX @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL,
162
bool release_lock = false;
163
164
RCU_READ_LOCK();
165
- mr = TRANSLATE(addr, &addr1, &l, true);
166
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
167
if (l < 4 || !IS_DIRECT(mr, true)) {
168
release_lock |= prepare_mmio_access(mr);
169
170
@@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL,
171
bool release_lock = false;
172
173
RCU_READ_LOCK();
174
- mr = TRANSLATE(addr, &addr1, &l, true);
175
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
176
if (l < 4 || !IS_DIRECT(mr, true)) {
177
release_lock |= prepare_mmio_access(mr);
178
179
@@ -XXX,XX +XXX,XX @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL,
180
bool release_lock = false;
181
182
RCU_READ_LOCK();
183
- mr = TRANSLATE(addr, &addr1, &l, true);
184
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
185
if (!IS_DIRECT(mr, true)) {
186
release_lock |= prepare_mmio_access(mr);
187
r = memory_region_dispatch_write(mr, addr1, val, 1, attrs);
188
@@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL,
189
bool release_lock = false;
190
191
RCU_READ_LOCK();
192
- mr = TRANSLATE(addr, &addr1, &l, true);
193
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
194
if (l < 2 || !IS_DIRECT(mr, true)) {
195
release_lock |= prepare_mmio_access(mr);
196
197
@@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL,
198
bool release_lock = false;
199
200
RCU_READ_LOCK();
201
- mr = TRANSLATE(addr, &addr1, &l, true);
202
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
203
if (l < 8 || !IS_DIRECT(mr, true)) {
204
release_lock |= prepare_mmio_access(mr);
205
206
diff --git a/target/riscv/helper.c b/target/riscv/helper.c
207
index XXXXXXX..XXXXXXX 100644
208
--- a/target/riscv/helper.c
209
+++ b/target/riscv/helper.c
210
@@ -XXX,XX +XXX,XX @@ restart:
211
MemoryRegion *mr;
212
hwaddr l = sizeof(target_ulong), addr1;
213
mr = address_space_translate(cs->as, pte_addr,
214
- &addr1, &l, false);
215
+ &addr1, &l, false, MEMTXATTRS_UNSPECIFIED);
216
if (memory_access_is_direct(mr, true)) {
217
target_ulong *pte_pa =
218
qemu_map_ram_ptr(mr->ram_block, addr1);
219
--
220
2.17.1
221
222
diff view generated by jsdifflib
1
Add the CMSDK APB timers to the MPS2 board.
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
add MemTxAttrs as an argument to address_space_map().
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
2
5
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Message-id: 1500029487-14822-6-git-send-email-peter.maydell@linaro.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-5-peter.maydell@linaro.org
6
---
10
---
7
hw/arm/mps2.c | 4 ++++
11
include/exec/memory.h | 3 ++-
8
1 file changed, 4 insertions(+)
12
include/sysemu/dma.h | 3 ++-
13
exec.c | 6 ++++--
14
target/ppc/mmu-hash64.c | 3 ++-
15
4 files changed, 10 insertions(+), 5 deletions(-)
9
16
10
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
17
diff --git a/include/exec/memory.h b/include/exec/memory.h
11
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/arm/mps2.c
19
--- a/include/exec/memory.h
13
+++ b/hw/arm/mps2.c
20
+++ b/include/exec/memory.h
14
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_
15
#include "sysemu/sysemu.h"
22
* @addr: address within that address space
16
#include "hw/misc/unimp.h"
23
* @plen: pointer to length of buffer; updated on return
17
#include "hw/char/cmsdk-apb-uart.h"
24
* @is_write: indicates the transfer direction
18
+#include "hw/timer/cmsdk-apb-timer.h"
25
+ * @attrs: memory attributes
19
26
*/
20
typedef enum MPS2FPGAType {
27
void *address_space_map(AddressSpace *as, hwaddr addr,
21
FPGA_AN385,
28
- hwaddr *plen, bool is_write);
22
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
29
+ hwaddr *plen, bool is_write, MemTxAttrs attrs);
23
g_assert_not_reached();
30
31
/* address_space_unmap: Unmaps a memory region previously mapped by address_space_map()
32
*
33
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
34
index XXXXXXX..XXXXXXX 100644
35
--- a/include/sysemu/dma.h
36
+++ b/include/sysemu/dma.h
37
@@ -XXX,XX +XXX,XX @@ static inline void *dma_memory_map(AddressSpace *as,
38
hwaddr xlen = *len;
39
void *p;
40
41
- p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE);
42
+ p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE,
43
+ MEMTXATTRS_UNSPECIFIED);
44
*len = xlen;
45
return p;
46
}
47
diff --git a/exec.c b/exec.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/exec.c
50
+++ b/exec.c
51
@@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr,
52
void *address_space_map(AddressSpace *as,
53
hwaddr addr,
54
hwaddr *plen,
55
- bool is_write)
56
+ bool is_write,
57
+ MemTxAttrs attrs)
58
{
59
hwaddr len = *plen;
60
hwaddr l, xlat;
61
@@ -XXX,XX +XXX,XX @@ void *cpu_physical_memory_map(hwaddr addr,
62
hwaddr *plen,
63
int is_write)
64
{
65
- return address_space_map(&address_space_memory, addr, plen, is_write);
66
+ return address_space_map(&address_space_memory, addr, plen, is_write,
67
+ MEMTXATTRS_UNSPECIFIED);
68
}
69
70
void cpu_physical_memory_unmap(void *buffer, hwaddr len,
71
diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/target/ppc/mmu-hash64.c
74
+++ b/target/ppc/mmu-hash64.c
75
@@ -XXX,XX +XXX,XX @@ const ppc_hash_pte64_t *ppc_hash64_map_hptes(PowerPCCPU *cpu,
76
return NULL;
24
}
77
}
25
78
26
+ cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
79
- hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false);
27
+ cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
80
+ hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false,
28
+
81
+ MEMTXATTRS_UNSPECIFIED);
29
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
82
if (plen < (n * HASH_PTE_SIZE_64)) {
30
83
hw_error("%s: Unable to map all requested HPTEs\n", __func__);
31
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
84
}
32
--
85
--
33
2.7.4
86
2.17.1
34
87
35
88
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
add MemTxAttrs as an argument to address_space_access_valid().
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
2
5
3
Previously DISAS_JUMP did ensure this but with the optimisation of
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
8a6b28c7 (optimize indirect branches) we might not leave the loop.
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
This means if any pending interrupts are cleared by changing IRQ flags
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
we might never get around to servicing them. You usually notice this
9
Message-id: 20180521140402.23318-6-peter.maydell@linaro.org
7
by seeing the lookup_tb_ptr() helper gainfully chaining TBs together
10
---
8
while cpu->interrupt_request remains high and the exit_request has not
11
include/exec/memory.h | 4 +++-
9
been set.
12
include/sysemu/dma.h | 3 ++-
13
exec.c | 3 ++-
14
target/s390x/diag.c | 6 ++++--
15
target/s390x/excp_helper.c | 3 ++-
16
target/s390x/mmu_helper.c | 3 ++-
17
target/s390x/sigp.c | 3 ++-
18
7 files changed, 17 insertions(+), 8 deletions(-)
10
19
11
This breaks amongst other things the OPTEE test suite which executes
20
diff --git a/include/exec/memory.h b/include/exec/memory.h
12
an eret from the secure world after a non-secure world IRQ has gone
13
pending which then never gets serviced.
14
15
Instead of using the previously implied semantics of DISAS_JUMP we use
16
DISAS_EXIT which will always exit the run-loop.
17
18
CC: Etienne Carriere <etienne.carriere@linaro.org>
19
CC: Joakim Bech <joakim.bech@linaro.org>
20
CC: Jaroslaw Pelczar <j.pelczar@samsung.com>
21
CC: Peter Maydell <peter.maydell@linaro.org>
22
CC: Emilio G. Cota <cota@braap.org>
23
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
24
Reviewed-by: Richard Henderson <rth@twiddle.net>
25
Message-id: 20170713141928.25419-7-alex.bennee@linaro.org
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
---
28
target/arm/translate-a64.c | 3 ++-
29
target/arm/translate.c | 6 ++++--
30
2 files changed, 6 insertions(+), 3 deletions(-)
31
32
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
33
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/translate-a64.c
22
--- a/include/exec/memory.h
35
+++ b/target/arm/translate-a64.c
23
+++ b/include/exec/memory.h
36
@@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
24
@@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as,
25
* @addr: address within that address space
26
* @len: length of the area to be checked
27
* @is_write: indicates the transfer direction
28
+ * @attrs: memory attributes
29
*/
30
-bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write);
31
+bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len,
32
+ bool is_write, MemTxAttrs attrs);
33
34
/* address_space_map: map a physical memory region into a host virtual address
35
*
36
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
37
index XXXXXXX..XXXXXXX 100644
38
--- a/include/sysemu/dma.h
39
+++ b/include/sysemu/dma.h
40
@@ -XXX,XX +XXX,XX @@ static inline bool dma_memory_valid(AddressSpace *as,
41
DMADirection dir)
42
{
43
return address_space_access_valid(as, addr, len,
44
- dir == DMA_DIRECTION_FROM_DEVICE);
45
+ dir == DMA_DIRECTION_FROM_DEVICE,
46
+ MEMTXATTRS_UNSPECIFIED);
47
}
48
49
static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr,
50
diff --git a/exec.c b/exec.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/exec.c
53
+++ b/exec.c
54
@@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
55
}
56
57
bool address_space_access_valid(AddressSpace *as, hwaddr addr,
58
- int len, bool is_write)
59
+ int len, bool is_write,
60
+ MemTxAttrs attrs)
61
{
62
FlatView *fv;
63
bool result;
64
diff --git a/target/s390x/diag.c b/target/s390x/diag.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/s390x/diag.c
67
+++ b/target/s390x/diag.c
68
@@ -XXX,XX +XXX,XX @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)
37
return;
69
return;
38
}
70
}
39
gen_helper_exception_return(cpu_env);
71
if (!address_space_access_valid(&address_space_memory, addr,
40
- s->is_jmp = DISAS_JUMP;
72
- sizeof(IplParameterBlock), false)) {
41
+ /* Must exit loop to check un-masked IRQs */
73
+ sizeof(IplParameterBlock), false,
42
+ s->is_jmp = DISAS_EXIT;
74
+ MEMTXATTRS_UNSPECIFIED)) {
75
s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra);
76
return;
77
}
78
@@ -XXX,XX +XXX,XX @@ out:
79
return;
80
}
81
if (!address_space_access_valid(&address_space_memory, addr,
82
- sizeof(IplParameterBlock), true)) {
83
+ sizeof(IplParameterBlock), true,
84
+ MEMTXATTRS_UNSPECIFIED)) {
85
s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra);
86
return;
87
}
88
diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c
89
index XXXXXXX..XXXXXXX 100644
90
--- a/target/s390x/excp_helper.c
91
+++ b/target/s390x/excp_helper.c
92
@@ -XXX,XX +XXX,XX @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size,
93
94
/* check out of RAM access */
95
if (!address_space_access_valid(&address_space_memory, raddr,
96
- TARGET_PAGE_SIZE, rw)) {
97
+ TARGET_PAGE_SIZE, rw,
98
+ MEMTXATTRS_UNSPECIFIED)) {
99
DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__,
100
(uint64_t)raddr, (uint64_t)ram_size);
101
trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
102
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/target/s390x/mmu_helper.c
105
+++ b/target/s390x/mmu_helper.c
106
@@ -XXX,XX +XXX,XX @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
107
return ret;
108
}
109
if (!address_space_access_valid(&address_space_memory, pages[i],
110
- TARGET_PAGE_SIZE, is_write)) {
111
+ TARGET_PAGE_SIZE, is_write,
112
+ MEMTXATTRS_UNSPECIFIED)) {
113
trigger_access_exception(env, PGM_ADDRESSING, ILEN_AUTO, 0);
114
return -EFAULT;
115
}
116
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/target/s390x/sigp.c
119
+++ b/target/s390x/sigp.c
120
@@ -XXX,XX +XXX,XX @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg)
121
cpu_synchronize_state(cs);
122
123
if (!address_space_access_valid(&address_space_memory, addr,
124
- sizeof(struct LowCore), false)) {
125
+ sizeof(struct LowCore), false,
126
+ MEMTXATTRS_UNSPECIFIED)) {
127
set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER);
43
return;
128
return;
44
case 5: /* DRPS */
129
}
45
if (rn != 0x1f) {
46
diff --git a/target/arm/translate.c b/target/arm/translate.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/translate.c
49
+++ b/target/arm/translate.c
50
@@ -XXX,XX +XXX,XX @@ static void gen_rfe(DisasContext *s, TCGv_i32 pc, TCGv_i32 cpsr)
51
*/
52
gen_helper_cpsr_write_eret(cpu_env, cpsr);
53
tcg_temp_free_i32(cpsr);
54
- s->is_jmp = DISAS_JUMP;
55
+ /* Must exit loop to check un-masked IRQs */
56
+ s->is_jmp = DISAS_EXIT;
57
}
58
59
/* Generate an old-style exception return. Marks pc as dead. */
60
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
61
tmp = load_cpu_field(spsr);
62
gen_helper_cpsr_write_eret(cpu_env, tmp);
63
tcg_temp_free_i32(tmp);
64
- s->is_jmp = DISAS_JUMP;
65
+ /* Must exit loop to check un-masked IRQs */
66
+ s->is_jmp = DISAS_EXIT;
67
}
68
}
69
break;
70
--
130
--
71
2.7.4
131
2.17.1
72
132
73
133
diff view generated by jsdifflib
1
The MPS2 FPGA images support ethernet via a LAN9220. We use
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
QEMU's LAN9118 model, which is software compatible except
2
add MemTxAttrs as an argument to flatview_extend_translation().
3
that it is missing the checksum-offload feature.
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
4
5
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 1500029487-14822-9-git-send-email-peter.maydell@linaro.org
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-7-peter.maydell@linaro.org
9
---
10
---
10
hw/arm/mps2.c | 10 +++++++++-
11
exec.c | 15 ++++++++++-----
11
1 file changed, 9 insertions(+), 1 deletion(-)
12
1 file changed, 10 insertions(+), 5 deletions(-)
12
13
13
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
14
diff --git a/exec.c b/exec.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/mps2.c
16
--- a/exec.c
16
+++ b/hw/arm/mps2.c
17
+++ b/exec.c
17
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr,
18
#include "hw/char/cmsdk-apb-uart.h"
19
19
#include "hw/timer/cmsdk-apb-timer.h"
20
static hwaddr
20
#include "hw/misc/mps2-scc.h"
21
flatview_extend_translation(FlatView *fv, hwaddr addr,
21
+#include "hw/devices.h"
22
- hwaddr target_len,
22
+#include "net/net.h"
23
- MemoryRegion *mr, hwaddr base, hwaddr len,
23
24
- bool is_write)
24
typedef enum MPS2FPGAType {
25
+ hwaddr target_len,
25
FPGA_AN385,
26
+ MemoryRegion *mr, hwaddr base, hwaddr len,
26
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
27
+ bool is_write, MemTxAttrs attrs)
27
create_unimplemented_device("Extra peripheral region @0x40020000",
28
{
28
0x40020000, 0x00010000);
29
hwaddr done = 0;
29
create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000);
30
hwaddr xlat;
30
- create_unimplemented_device("Ethernet", 0x40200000, 0x00100000);
31
@@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as,
31
create_unimplemented_device("VGA", 0x41000000, 0x0200000);
32
32
33
memory_region_ref(mr);
33
switch (mmc->fpga_type) {
34
*plen = flatview_extend_translation(fv, addr, len, mr, xlat,
34
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
35
- l, is_write);
35
&error_fatal);
36
+ l, is_write, attrs);
36
sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
37
ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true);
37
38
rcu_read_unlock();
38
+ /* In hardware this is a LAN9220; the LAN9118 is software compatible
39
39
+ * except that it doesn't support the checksum-offload feature.
40
@@ -XXX,XX +XXX,XX @@ int64_t address_space_cache_init(MemoryRegionCache *cache,
40
+ */
41
mr = cache->mrs.mr;
41
+ lan9118_init(&nd_table[0], 0x40200000,
42
memory_region_ref(mr);
42
+ qdev_get_gpio_in(armv7m,
43
if (memory_access_is_direct(mr, is_write)) {
43
+ mmc->fpga_type == FPGA_AN385 ? 13 : 47));
44
+ /* We don't care about the memory attributes here as we're only
44
+
45
+ * doing this if we found actual RAM, which behaves the same
45
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
46
+ * regardless of attributes; so UNSPECIFIED is fine.
46
47
+ */
47
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
48
l = flatview_extend_translation(cache->fv, addr, len, mr,
49
- cache->xlat, l, is_write);
50
+ cache->xlat, l, is_write,
51
+ MEMTXATTRS_UNSPECIFIED);
52
cache->ptr = qemu_ram_ptr_length(mr->ram_block, cache->xlat, &l, true);
53
} else {
54
cache->ptr = NULL;
48
--
55
--
49
2.7.4
56
2.17.1
50
57
51
58
diff view generated by jsdifflib
1
Implement a model of the simple timer device found in the CMSDK.
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
add MemTxAttrs as an argument to memory_region_access_valid().
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
5
6
The callsite in flatview_access_valid() is part of a recursive
7
loop flatview_access_valid() -> memory_region_access_valid() ->
8
subpage_accepts() -> flatview_access_valid(); we make it pass
9
MEMTXATTRS_UNSPECIFIED for now, until the next several commits
10
have plumbed an attrs parameter through the rest of the loop
11
and we can add an attrs parameter to flatview_access_valid().
2
12
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Message-id: 1500029487-14822-5-git-send-email-peter.maydell@linaro.org
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 20180521140402.23318-8-peter.maydell@linaro.org
6
---
17
---
7
hw/timer/Makefile.objs | 1 +
18
include/exec/memory-internal.h | 3 ++-
8
include/hw/timer/cmsdk-apb-timer.h | 59 +++++++++
19
exec.c | 4 +++-
9
hw/timer/cmsdk-apb-timer.c | 253 +++++++++++++++++++++++++++++++++++++
20
hw/s390x/s390-pci-inst.c | 3 ++-
10
default-configs/arm-softmmu.mak | 1 +
21
memory.c | 7 ++++---
11
hw/timer/trace-events | 5 +
22
4 files changed, 11 insertions(+), 6 deletions(-)
12
5 files changed, 319 insertions(+)
13
create mode 100644 include/hw/timer/cmsdk-apb-timer.h
14
create mode 100644 hw/timer/cmsdk-apb-timer.c
15
23
16
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
24
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
17
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/timer/Makefile.objs
26
--- a/include/exec/memory-internal.h
19
+++ b/hw/timer/Makefile.objs
27
+++ b/include/exec/memory-internal.h
20
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
28
@@ -XXX,XX +XXX,XX @@ void flatview_unref(FlatView *view);
21
common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
29
extern const MemoryRegionOps unassigned_mem_ops;
22
30
23
common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
31
bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr,
24
+common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
32
- unsigned size, bool is_write);
25
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
33
+ unsigned size, bool is_write,
26
new file mode 100644
34
+ MemTxAttrs attrs);
27
index XXXXXXX..XXXXXXX
35
28
--- /dev/null
36
void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section);
29
+++ b/include/hw/timer/cmsdk-apb-timer.h
37
AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv);
30
@@ -XXX,XX +XXX,XX @@
38
diff --git a/exec.c b/exec.c
31
+/*
32
+ * ARM CMSDK APB timer emulation
33
+ *
34
+ * Copyright (c) 2017 Linaro Limited
35
+ * Written by Peter Maydell
36
+ *
37
+ * This program is free software; you can redistribute it and/or modify
38
+ * it under the terms of the GNU General Public License version 2 or
39
+ * (at your option) any later version.
40
+ */
41
+
42
+#ifndef CMSDK_APB_TIMER_H
43
+#define CMSDK_APB_TIMER_H
44
+
45
+#include "hw/sysbus.h"
46
+#include "hw/ptimer.h"
47
+
48
+#define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer"
49
+#define CMSDK_APB_TIMER(obj) OBJECT_CHECK(CMSDKAPBTIMER, (obj), \
50
+ TYPE_CMSDK_APB_TIMER)
51
+
52
+typedef struct {
53
+ /*< private >*/
54
+ SysBusDevice parent_obj;
55
+
56
+ /*< public >*/
57
+ MemoryRegion iomem;
58
+ qemu_irq timerint;
59
+ uint32_t pclk_frq;
60
+ struct ptimer_state *timer;
61
+
62
+ uint32_t ctrl;
63
+ uint32_t value;
64
+ uint32_t reload;
65
+ uint32_t intstatus;
66
+} CMSDKAPBTIMER;
67
+
68
+/**
69
+ * cmsdk_apb_timer_create - convenience function to create TYPE_CMSDK_APB_TIMER
70
+ * @addr: location in system memory to map registers
71
+ * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate)
72
+ */
73
+static inline DeviceState *cmsdk_apb_timer_create(hwaddr addr,
74
+ qemu_irq timerint,
75
+ uint32_t pclk_frq)
76
+{
77
+ DeviceState *dev;
78
+ SysBusDevice *s;
79
+
80
+ dev = qdev_create(NULL, TYPE_CMSDK_APB_TIMER);
81
+ s = SYS_BUS_DEVICE(dev);
82
+ qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq);
83
+ qdev_init_nofail(dev);
84
+ sysbus_mmio_map(s, 0, addr);
85
+ sysbus_connect_irq(s, 0, timerint);
86
+ return dev;
87
+}
88
+
89
+#endif
90
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
91
new file mode 100644
92
index XXXXXXX..XXXXXXX
93
--- /dev/null
94
+++ b/hw/timer/cmsdk-apb-timer.c
95
@@ -XXX,XX +XXX,XX @@
96
+/*
97
+ * ARM CMSDK APB timer emulation
98
+ *
99
+ * Copyright (c) 2017 Linaro Limited
100
+ * Written by Peter Maydell
101
+ *
102
+ * This program is free software; you can redistribute it and/or modify
103
+ * it under the terms of the GNU General Public License version 2 or
104
+ * (at your option) any later version.
105
+ */
106
+
107
+/* This is a model of the "APB timer" which is part of the Cortex-M
108
+ * System Design Kit (CMSDK) and documented in the Cortex-M System
109
+ * Design Kit Technical Reference Manual (ARM DDI0479C):
110
+ * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
111
+ *
112
+ * The hardware has an EXTIN input wire, which can be configured
113
+ * by the guest to act either as a 'timer enable' (timer does not run
114
+ * when EXTIN is low), or as a 'timer clock' (timer runs at frequency
115
+ * of EXTIN clock, not PCLK frequency). We don't model this.
116
+ *
117
+ * The documentation is not very clear about the exact behaviour;
118
+ * we choose to implement that the interrupt is triggered when
119
+ * the counter goes from 1 to 0, that the counter then holds at 0
120
+ * for one clock cycle before reloading from the RELOAD register,
121
+ * and that if the RELOAD register is 0 this does not cause an
122
+ * interrupt (as there is no further 1->0 transition).
123
+ */
124
+
125
+#include "qemu/osdep.h"
126
+#include "qemu/log.h"
127
+#include "qemu/main-loop.h"
128
+#include "qapi/error.h"
129
+#include "trace.h"
130
+#include "hw/sysbus.h"
131
+#include "hw/registerfields.h"
132
+#include "hw/timer/cmsdk-apb-timer.h"
133
+
134
+REG32(CTRL, 0)
135
+ FIELD(CTRL, EN, 0, 1)
136
+ FIELD(CTRL, SELEXTEN, 1, 1)
137
+ FIELD(CTRL, SELEXTCLK, 2, 1)
138
+ FIELD(CTRL, IRQEN, 3, 1)
139
+REG32(VALUE, 4)
140
+REG32(RELOAD, 8)
141
+REG32(INTSTATUS, 0xc)
142
+ FIELD(INTSTATUS, IRQ, 0, 1)
143
+REG32(PID4, 0xFD0)
144
+REG32(PID5, 0xFD4)
145
+REG32(PID6, 0xFD8)
146
+REG32(PID7, 0xFDC)
147
+REG32(PID0, 0xFE0)
148
+REG32(PID1, 0xFE4)
149
+REG32(PID2, 0xFE8)
150
+REG32(PID3, 0xFEC)
151
+REG32(CID0, 0xFF0)
152
+REG32(CID1, 0xFF4)
153
+REG32(CID2, 0xFF8)
154
+REG32(CID3, 0xFFC)
155
+
156
+/* PID/CID values */
157
+static const int timer_id[] = {
158
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
159
+ 0x22, 0xb8, 0x1b, 0x00, /* PID0..PID3 */
160
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
161
+};
162
+
163
+static void cmsdk_apb_timer_update(CMSDKAPBTIMER *s)
164
+{
165
+ qemu_set_irq(s->timerint, !!(s->intstatus & R_INTSTATUS_IRQ_MASK));
166
+}
167
+
168
+static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size)
169
+{
170
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
171
+ uint64_t r;
172
+
173
+ switch (offset) {
174
+ case A_CTRL:
175
+ r = s->ctrl;
176
+ break;
177
+ case A_VALUE:
178
+ r = ptimer_get_count(s->timer);
179
+ break;
180
+ case A_RELOAD:
181
+ r = ptimer_get_limit(s->timer);
182
+ break;
183
+ case A_INTSTATUS:
184
+ r = s->intstatus;
185
+ break;
186
+ case A_PID4 ... A_CID3:
187
+ r = timer_id[(offset - A_PID4) / 4];
188
+ break;
189
+ default:
190
+ qemu_log_mask(LOG_GUEST_ERROR,
191
+ "CMSDK APB timer read: bad offset %x\n", (int) offset);
192
+ r = 0;
193
+ break;
194
+ }
195
+ trace_cmsdk_apb_timer_read(offset, r, size);
196
+ return r;
197
+}
198
+
199
+static void cmsdk_apb_timer_write(void *opaque, hwaddr offset, uint64_t value,
200
+ unsigned size)
201
+{
202
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
203
+
204
+ trace_cmsdk_apb_timer_write(offset, value, size);
205
+
206
+ switch (offset) {
207
+ case A_CTRL:
208
+ if (value & 6) {
209
+ /* Bits [1] and [2] enable using EXTIN as either clock or
210
+ * an enable line. We don't model this.
211
+ */
212
+ qemu_log_mask(LOG_UNIMP,
213
+ "CMSDK APB timer: EXTIN input not supported\n");
214
+ }
215
+ s->ctrl = value & 0xf;
216
+ if (s->ctrl & R_CTRL_EN_MASK) {
217
+ ptimer_run(s->timer, 0);
218
+ } else {
219
+ ptimer_stop(s->timer);
220
+ }
221
+ break;
222
+ case A_RELOAD:
223
+ /* Writing to reload also sets the current timer value */
224
+ ptimer_set_limit(s->timer, value, 1);
225
+ break;
226
+ case A_VALUE:
227
+ ptimer_set_count(s->timer, value);
228
+ break;
229
+ case A_INTSTATUS:
230
+ /* Just one bit, which is W1C. */
231
+ value &= 1;
232
+ s->intstatus &= ~value;
233
+ cmsdk_apb_timer_update(s);
234
+ break;
235
+ case A_PID4 ... A_CID3:
236
+ qemu_log_mask(LOG_GUEST_ERROR,
237
+ "CMSDK APB timer write: write to RO offset 0x%x\n",
238
+ (int)offset);
239
+ break;
240
+ default:
241
+ qemu_log_mask(LOG_GUEST_ERROR,
242
+ "CMSDK APB timer write: bad offset 0x%x\n", (int) offset);
243
+ break;
244
+ }
245
+}
246
+
247
+static const MemoryRegionOps cmsdk_apb_timer_ops = {
248
+ .read = cmsdk_apb_timer_read,
249
+ .write = cmsdk_apb_timer_write,
250
+ .endianness = DEVICE_LITTLE_ENDIAN,
251
+};
252
+
253
+static void cmsdk_apb_timer_tick(void *opaque)
254
+{
255
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
256
+
257
+ if (s->ctrl & R_CTRL_IRQEN_MASK) {
258
+ s->intstatus |= R_INTSTATUS_IRQ_MASK;
259
+ cmsdk_apb_timer_update(s);
260
+ }
261
+}
262
+
263
+static void cmsdk_apb_timer_reset(DeviceState *dev)
264
+{
265
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
266
+
267
+ trace_cmsdk_apb_timer_reset();
268
+ s->ctrl = 0;
269
+ s->intstatus = 0;
270
+ ptimer_stop(s->timer);
271
+ /* Set the limit and the count */
272
+ ptimer_set_limit(s->timer, 0, 1);
273
+}
274
+
275
+static void cmsdk_apb_timer_init(Object *obj)
276
+{
277
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
278
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(obj);
279
+
280
+ memory_region_init_io(&s->iomem, obj, &cmsdk_apb_timer_ops,
281
+ s, "cmsdk-apb-timer", 0x1000);
282
+ sysbus_init_mmio(sbd, &s->iomem);
283
+ sysbus_init_irq(sbd, &s->timerint);
284
+}
285
+
286
+static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
287
+{
288
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
289
+ QEMUBH *bh;
290
+
291
+ if (s->pclk_frq == 0) {
292
+ error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
293
+ return;
294
+ }
295
+
296
+ bh = qemu_bh_new(cmsdk_apb_timer_tick, s);
297
+ s->timer = ptimer_init(bh,
298
+ PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD |
299
+ PTIMER_POLICY_NO_IMMEDIATE_TRIGGER |
300
+ PTIMER_POLICY_NO_IMMEDIATE_RELOAD |
301
+ PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
302
+
303
+ ptimer_set_freq(s->timer, s->pclk_frq);
304
+}
305
+
306
+static const VMStateDescription cmsdk_apb_timer_vmstate = {
307
+ .name = "cmsdk-apb-timer",
308
+ .version_id = 1,
309
+ .minimum_version_id = 1,
310
+ .fields = (VMStateField[]) {
311
+ VMSTATE_PTIMER(timer, CMSDKAPBTIMER),
312
+ VMSTATE_UINT32(ctrl, CMSDKAPBTIMER),
313
+ VMSTATE_UINT32(value, CMSDKAPBTIMER),
314
+ VMSTATE_UINT32(reload, CMSDKAPBTIMER),
315
+ VMSTATE_UINT32(intstatus, CMSDKAPBTIMER),
316
+ VMSTATE_END_OF_LIST()
317
+ }
318
+};
319
+
320
+static Property cmsdk_apb_timer_properties[] = {
321
+ DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTIMER, pclk_frq, 0),
322
+ DEFINE_PROP_END_OF_LIST(),
323
+};
324
+
325
+static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)
326
+{
327
+ DeviceClass *dc = DEVICE_CLASS(klass);
328
+
329
+ dc->realize = cmsdk_apb_timer_realize;
330
+ dc->vmsd = &cmsdk_apb_timer_vmstate;
331
+ dc->reset = cmsdk_apb_timer_reset;
332
+ dc->props = cmsdk_apb_timer_properties;
333
+}
334
+
335
+static const TypeInfo cmsdk_apb_timer_info = {
336
+ .name = TYPE_CMSDK_APB_TIMER,
337
+ .parent = TYPE_SYS_BUS_DEVICE,
338
+ .instance_size = sizeof(CMSDKAPBTIMER),
339
+ .instance_init = cmsdk_apb_timer_init,
340
+ .class_init = cmsdk_apb_timer_class_init,
341
+};
342
+
343
+static void cmsdk_apb_timer_register_types(void)
344
+{
345
+ type_register_static(&cmsdk_apb_timer_info);
346
+}
347
+
348
+type_init(cmsdk_apb_timer_register_types);
349
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
350
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
351
--- a/default-configs/arm-softmmu.mak
40
--- a/exec.c
352
+++ b/default-configs/arm-softmmu.mak
41
+++ b/exec.c
353
@@ -XXX,XX +XXX,XX @@ CONFIG_STM32F2XX_ADC=y
42
@@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
354
CONFIG_STM32F2XX_SPI=y
43
mr = flatview_translate(fv, addr, &xlat, &l, is_write);
355
CONFIG_STM32F205_SOC=y
44
if (!memory_access_is_direct(mr, is_write)) {
356
45
l = memory_access_size(mr, l, addr);
357
+CONFIG_CMSDK_APB_TIMER=y
46
- if (!memory_region_access_valid(mr, xlat, l, is_write)) {
358
CONFIG_CMSDK_APB_UART=y
47
+ /* When our callers all have attrs we'll pass them through here */
359
48
+ if (!memory_region_access_valid(mr, xlat, l, is_write,
360
CONFIG_VERSATILE_PCI=y
49
+ MEMTXATTRS_UNSPECIFIED)) {
361
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
50
return false;
51
}
52
}
53
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
362
index XXXXXXX..XXXXXXX 100644
54
index XXXXXXX..XXXXXXX 100644
363
--- a/hw/timer/trace-events
55
--- a/hw/s390x/s390-pci-inst.c
364
+++ b/hw/timer/trace-events
56
+++ b/hw/s390x/s390-pci-inst.c
365
@@ -XXX,XX +XXX,XX @@ systick_reload(void) "systick reload"
57
@@ -XXX,XX +XXX,XX @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
366
systick_timer_tick(void) "systick reload"
58
mr = s390_get_subregion(mr, offset, len);
367
systick_read(uint64_t addr, uint32_t value, unsigned size) "systick read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
59
offset -= mr->addr;
368
systick_write(uint64_t addr, uint32_t value, unsigned size) "systick write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
60
369
+
61
- if (!memory_region_access_valid(mr, offset, len, true)) {
370
+# hw/char/cmsdk_apb_timer.c
62
+ if (!memory_region_access_valid(mr, offset, len, true,
371
+cmsdk_apb_timer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB timer read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
63
+ MEMTXATTRS_UNSPECIFIED)) {
372
+cmsdk_apb_timer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB timer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
64
s390_program_interrupt(env, PGM_OPERAND, 6, ra);
373
+cmsdk_apb_timer_reset(void) "CMSDK APB timer: reset"
65
return 0;
66
}
67
diff --git a/memory.c b/memory.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/memory.c
70
+++ b/memory.c
71
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ram_device_mem_ops = {
72
bool memory_region_access_valid(MemoryRegion *mr,
73
hwaddr addr,
74
unsigned size,
75
- bool is_write)
76
+ bool is_write,
77
+ MemTxAttrs attrs)
78
{
79
int access_size_min, access_size_max;
80
int access_size, i;
81
@@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr,
82
{
83
MemTxResult r;
84
85
- if (!memory_region_access_valid(mr, addr, size, false)) {
86
+ if (!memory_region_access_valid(mr, addr, size, false, attrs)) {
87
*pval = unassigned_mem_read(mr, addr, size);
88
return MEMTX_DECODE_ERROR;
89
}
90
@@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr,
91
unsigned size,
92
MemTxAttrs attrs)
93
{
94
- if (!memory_region_access_valid(mr, addr, size, true)) {
95
+ if (!memory_region_access_valid(mr, addr, size, true, attrs)) {
96
unassigned_mem_write(mr, addr, data, size);
97
return MEMTX_DECODE_ERROR;
98
}
374
--
99
--
375
2.7.4
100
2.17.1
376
101
377
102
diff view generated by jsdifflib
1
In DEFINE_PROP_ARRAY, because we use a PropertyInfo (qdev_prop_arraylen)
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
which has a .set_default_value member we will set the field to a default
2
add MemTxAttrs as an argument to the MemoryRegion valid.accepts
3
value. That default value will be zero, by the C rule that struct
3
callback. We'll need this for subpage_accepts().
4
initialization sets unmentioned members to zero if at least one member
4
5
is initialized. However it's clearer to state it explicitly.
5
We could take the approach we used with the read and write
6
callbacks and add new a new _with_attrs version, but since there
7
are so few implementations of the accepts hook we just change
8
them all.
6
9
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Message-id: 1499788408-10096-2-git-send-email-peter.maydell@linaro.org
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20180521140402.23318-9-peter.maydell@linaro.org
10
---
14
---
11
include/hw/qdev-properties.h | 1 +
15
include/exec/memory.h | 3 ++-
12
1 file changed, 1 insertion(+)
16
exec.c | 9 ++++++---
17
hw/hppa/dino.c | 3 ++-
18
hw/nvram/fw_cfg.c | 12 ++++++++----
19
hw/scsi/esp.c | 3 ++-
20
hw/xen/xen_pt_msi.c | 3 ++-
21
memory.c | 5 +++--
22
7 files changed, 25 insertions(+), 13 deletions(-)
13
23
14
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
24
diff --git a/include/exec/memory.h b/include/exec/memory.h
15
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/qdev-properties.h
26
--- a/include/exec/memory.h
17
+++ b/include/hw/qdev-properties.h
27
+++ b/include/exec/memory.h
18
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
28
@@ -XXX,XX +XXX,XX @@ struct MemoryRegionOps {
19
_arrayfield, _arrayprop, _arraytype) { \
29
* as a machine check exception).
20
.name = (PROP_ARRAY_LEN_PREFIX _name), \
30
*/
21
.info = &(qdev_prop_arraylen), \
31
bool (*accepts)(void *opaque, hwaddr addr,
22
+ .defval.u = 0, \
32
- unsigned size, bool is_write);
23
.offset = offsetof(_state, _field) \
33
+ unsigned size, bool is_write,
24
+ type_check(uint32_t, typeof_field(_state, _field)), \
34
+ MemTxAttrs attrs);
25
.arrayinfo = &(_arrayprop), \
35
} valid;
36
/* Internal implementation constraints: */
37
struct {
38
diff --git a/exec.c b/exec.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/exec.c
41
+++ b/exec.c
42
@@ -XXX,XX +XXX,XX @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
43
}
44
45
static bool notdirty_mem_accepts(void *opaque, hwaddr addr,
46
- unsigned size, bool is_write)
47
+ unsigned size, bool is_write,
48
+ MemTxAttrs attrs)
49
{
50
return is_write;
51
}
52
@@ -XXX,XX +XXX,XX @@ static MemTxResult subpage_write(void *opaque, hwaddr addr,
53
}
54
55
static bool subpage_accepts(void *opaque, hwaddr addr,
56
- unsigned len, bool is_write)
57
+ unsigned len, bool is_write,
58
+ MemTxAttrs attrs)
59
{
60
subpage_t *subpage = opaque;
61
#if defined(DEBUG_SUBPAGE)
62
@@ -XXX,XX +XXX,XX @@ static void readonly_mem_write(void *opaque, hwaddr addr,
63
}
64
65
static bool readonly_mem_accepts(void *opaque, hwaddr addr,
66
- unsigned size, bool is_write)
67
+ unsigned size, bool is_write,
68
+ MemTxAttrs attrs)
69
{
70
return is_write;
71
}
72
diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/hw/hppa/dino.c
75
+++ b/hw/hppa/dino.c
76
@@ -XXX,XX +XXX,XX @@ static void gsc_to_pci_forwarding(DinoState *s)
77
}
78
79
static bool dino_chip_mem_valid(void *opaque, hwaddr addr,
80
- unsigned size, bool is_write)
81
+ unsigned size, bool is_write,
82
+ MemTxAttrs attrs)
83
{
84
switch (addr) {
85
case DINO_IAR0:
86
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/hw/nvram/fw_cfg.c
89
+++ b/hw/nvram/fw_cfg.c
90
@@ -XXX,XX +XXX,XX @@ static void fw_cfg_dma_mem_write(void *opaque, hwaddr addr,
91
}
92
93
static bool fw_cfg_dma_mem_valid(void *opaque, hwaddr addr,
94
- unsigned size, bool is_write)
95
+ unsigned size, bool is_write,
96
+ MemTxAttrs attrs)
97
{
98
return !is_write || ((size == 4 && (addr == 0 || addr == 4)) ||
99
(size == 8 && addr == 0));
100
}
101
102
static bool fw_cfg_data_mem_valid(void *opaque, hwaddr addr,
103
- unsigned size, bool is_write)
104
+ unsigned size, bool is_write,
105
+ MemTxAttrs attrs)
106
{
107
return addr == 0;
108
}
109
@@ -XXX,XX +XXX,XX @@ static void fw_cfg_ctl_mem_write(void *opaque, hwaddr addr,
110
}
111
112
static bool fw_cfg_ctl_mem_valid(void *opaque, hwaddr addr,
113
- unsigned size, bool is_write)
114
+ unsigned size, bool is_write,
115
+ MemTxAttrs attrs)
116
{
117
return is_write && size == 2;
118
}
119
@@ -XXX,XX +XXX,XX @@ static void fw_cfg_comb_write(void *opaque, hwaddr addr,
120
}
121
122
static bool fw_cfg_comb_valid(void *opaque, hwaddr addr,
123
- unsigned size, bool is_write)
124
+ unsigned size, bool is_write,
125
+ MemTxAttrs attrs)
126
{
127
return (size == 1) || (is_write && size == 2);
128
}
129
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
130
index XXXXXXX..XXXXXXX 100644
131
--- a/hw/scsi/esp.c
132
+++ b/hw/scsi/esp.c
133
@@ -XXX,XX +XXX,XX @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val)
134
}
135
136
static bool esp_mem_accepts(void *opaque, hwaddr addr,
137
- unsigned size, bool is_write)
138
+ unsigned size, bool is_write,
139
+ MemTxAttrs attrs)
140
{
141
return (size == 1) || (is_write && size == 4);
142
}
143
diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c
144
index XXXXXXX..XXXXXXX 100644
145
--- a/hw/xen/xen_pt_msi.c
146
+++ b/hw/xen/xen_pt_msi.c
147
@@ -XXX,XX +XXX,XX @@ static uint64_t pci_msix_read(void *opaque, hwaddr addr,
148
}
149
150
static bool pci_msix_accepts(void *opaque, hwaddr addr,
151
- unsigned size, bool is_write)
152
+ unsigned size, bool is_write,
153
+ MemTxAttrs attrs)
154
{
155
return !(addr & (size - 1));
156
}
157
diff --git a/memory.c b/memory.c
158
index XXXXXXX..XXXXXXX 100644
159
--- a/memory.c
160
+++ b/memory.c
161
@@ -XXX,XX +XXX,XX @@ static void unassigned_mem_write(void *opaque, hwaddr addr,
162
}
163
164
static bool unassigned_mem_accepts(void *opaque, hwaddr addr,
165
- unsigned size, bool is_write)
166
+ unsigned size, bool is_write,
167
+ MemTxAttrs attrs)
168
{
169
return false;
170
}
171
@@ -XXX,XX +XXX,XX @@ bool memory_region_access_valid(MemoryRegion *mr,
172
access_size = MAX(MIN(size, access_size_max), access_size_min);
173
for (i = 0; i < size; i += access_size) {
174
if (!mr->ops->valid.accepts(mr->opaque, addr + i, access_size,
175
- is_write)) {
176
+ is_write, attrs)) {
177
return false;
178
}
179
}
26
--
180
--
27
2.7.4
181
2.17.1
28
182
29
183
diff view generated by jsdifflib
1
Add the SCC to the MPS2 board models.
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
add MemTxAttrs as an argument to flatview_access_valid().
3
Its callers now all have an attrs value to hand, so we can
4
correct our earlier temporary use of MEMTXATTRS_UNSPECIFIED.
2
5
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Message-id: 1500029487-14822-8-git-send-email-peter.maydell@linaro.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-10-peter.maydell@linaro.org
6
---
10
---
7
hw/arm/mps2.c | 17 ++++++++++++++++-
11
exec.c | 12 +++++-------
8
1 file changed, 16 insertions(+), 1 deletion(-)
12
1 file changed, 5 insertions(+), 7 deletions(-)
9
13
10
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
14
diff --git a/exec.c b/exec.c
11
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/arm/mps2.c
16
--- a/exec.c
13
+++ b/hw/arm/mps2.c
17
+++ b/exec.c
14
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
15
#include "hw/misc/unimp.h"
19
static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
16
#include "hw/char/cmsdk-apb-uart.h"
20
const uint8_t *buf, int len);
17
#include "hw/timer/cmsdk-apb-timer.h"
21
static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
18
+#include "hw/misc/mps2-scc.h"
22
- bool is_write);
19
23
+ bool is_write, MemTxAttrs attrs);
20
typedef enum MPS2FPGAType {
24
21
FPGA_AN385,
25
static MemTxResult subpage_read(void *opaque, hwaddr addr, uint64_t *data,
22
@@ -XXX,XX +XXX,XX @@ typedef struct {
26
unsigned len, MemTxAttrs attrs)
23
MachineClass parent;
27
@@ -XXX,XX +XXX,XX @@ static bool subpage_accepts(void *opaque, hwaddr addr,
24
MPS2FPGAType fpga_type;
28
#endif
25
const char *cpu_model;
29
26
+ uint32_t scc_id;
30
return flatview_access_valid(subpage->fv, addr + subpage->base,
27
} MPS2MachineClass;
31
- len, is_write);
28
32
+ len, is_write, attrs);
29
typedef struct {
30
@@ -XXX,XX +XXX,XX @@ typedef struct {
31
MemoryRegion blockram_m2;
32
MemoryRegion blockram_m3;
33
MemoryRegion sram;
34
+ MPS2SCC scc;
35
} MPS2MachineState;
36
37
#define TYPE_MPS2_MACHINE "mps2"
38
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
39
MPS2MachineState *mms = MPS2_MACHINE(machine);
40
MPS2MachineClass *mmc = MPS2_MACHINE_GET_CLASS(machine);
41
MemoryRegion *system_memory = get_system_memory();
42
- DeviceState *armv7m;
43
+ DeviceState *armv7m, *sccdev;
44
45
if (!machine->cpu_model) {
46
machine->cpu_model = mmc->cpu_model;
47
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
48
cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
49
cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
50
51
+ object_initialize(&mms->scc, sizeof(mms->scc), TYPE_MPS2_SCC);
52
+ sccdev = DEVICE(&mms->scc);
53
+ qdev_set_parent_bus(armv7m, sysbus_get_default());
54
+ qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
55
+ qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008);
56
+ qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
57
+ object_property_set_bool(OBJECT(&mms->scc), true, "realized",
58
+ &error_fatal);
59
+ sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
60
+
61
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
62
63
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
64
@@ -XXX,XX +XXX,XX @@ static void mps2_an385_class_init(ObjectClass *oc, void *data)
65
mc->desc = "ARM MPS2 with AN385 FPGA image for Cortex-M3";
66
mmc->fpga_type = FPGA_AN385;
67
mmc->cpu_model = "cortex-m3";
68
+ mmc->scc_id = 0x41040000 | (385 << 4);
69
}
33
}
70
34
71
static void mps2_an511_class_init(ObjectClass *oc, void *data)
35
static const MemoryRegionOps subpage_ops = {
72
@@ -XXX,XX +XXX,XX @@ static void mps2_an511_class_init(ObjectClass *oc, void *data)
36
@@ -XXX,XX +XXX,XX @@ static void cpu_notify_map_clients(void)
73
mc->desc = "ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3";
74
mmc->fpga_type = FPGA_AN511;
75
mmc->cpu_model = "cortex-m3";
76
+ mmc->scc_id = 0x4104000 | (511 << 4);
77
}
37
}
78
38
79
static const TypeInfo mps2_info = {
39
static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
40
- bool is_write)
41
+ bool is_write, MemTxAttrs attrs)
42
{
43
MemoryRegion *mr;
44
hwaddr l, xlat;
45
@@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
46
mr = flatview_translate(fv, addr, &xlat, &l, is_write);
47
if (!memory_access_is_direct(mr, is_write)) {
48
l = memory_access_size(mr, l, addr);
49
- /* When our callers all have attrs we'll pass them through here */
50
- if (!memory_region_access_valid(mr, xlat, l, is_write,
51
- MEMTXATTRS_UNSPECIFIED)) {
52
+ if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) {
53
return false;
54
}
55
}
56
@@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr,
57
58
rcu_read_lock();
59
fv = address_space_to_flatview(as);
60
- result = flatview_access_valid(fv, addr, len, is_write);
61
+ result = flatview_access_valid(fv, addr, len, is_write, attrs);
62
rcu_read_unlock();
63
return result;
64
}
80
--
65
--
81
2.7.4
66
2.17.1
82
67
83
68
diff view generated by jsdifflib
1
In some situations it's useful to have a qdev property which doesn't
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
automatically set its default value when qdev_property_add_static is
2
add MemTxAttrs as an argument to flatview_translate(); all its
3
called (for instance when the default value is not constant).
3
callers now have attrs available.
4
4
5
Support this by adding a flag to the Property struct indicating
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
whether to set the default value. This replaces the existing test
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
for whether the PropertyInfo set_default_value function pointer is
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
NULL, and we set the .set_default field to true for all those cases
8
Message-id: 20180521140402.23318-11-peter.maydell@linaro.org
9
of struct Property which use a PropertyInfo with a non-NULL
9
---
10
set_default_value, so behaviour remains the same as before.
10
include/exec/memory.h | 7 ++++---
11
exec.c | 17 +++++++++--------
12
2 files changed, 13 insertions(+), 11 deletions(-)
11
13
12
This gives us the semantics of:
14
diff --git a/include/exec/memory.h b/include/exec/memory.h
13
* if .set_default is true, then .info->set_default_value must
14
be not NULL, and .defval is used as the the default value of
15
the property
16
* otherwise, the property system does not set any default, and
17
the field will retain whatever initial value it was given by
18
the device's .instance_init method
19
20
We define two new macros DEFINE_PROP_SIGNED_NODEFAULT and
21
DEFINE_PROP_UNSIGNED_NODEFAULT, to cover the most plausible use cases
22
of wanting to set an integer property with no default value.
23
24
Suggested-by: Markus Armbruster <armbru@redhat.com>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
27
Reviewed-by: Markus Armbruster <armbru@redhat.com>
28
Message-id: 1499788408-10096-3-git-send-email-peter.maydell@linaro.org
29
---
30
include/hw/qdev-core.h | 10 ++++++++++
31
include/hw/qdev-properties.h | 20 ++++++++++++++++++++
32
hw/core/qdev.c | 2 +-
33
3 files changed, 31 insertions(+), 1 deletion(-)
34
35
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
36
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
37
--- a/include/hw/qdev-core.h
16
--- a/include/exec/memory.h
38
+++ b/include/hw/qdev-core.h
17
+++ b/include/exec/memory.h
39
@@ -XXX,XX +XXX,XX @@ struct BusState {
18
@@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
40
QLIST_ENTRY(BusState) sibling;
19
*/
41
};
20
MemoryRegion *flatview_translate(FlatView *fv,
42
21
hwaddr addr, hwaddr *xlat,
43
+/**
22
- hwaddr *len, bool is_write);
44
+ * Property:
23
+ hwaddr *len, bool is_write,
45
+ * @set_default: true if the default value should be set from @defval,
24
+ MemTxAttrs attrs);
46
+ * in which case @info->set_default_value must not be NULL
25
47
+ * (if false then no default value is set by the property system
26
static inline MemoryRegion *address_space_translate(AddressSpace *as,
48
+ * and the field retains whatever value it was given by instance_init).
27
hwaddr addr, hwaddr *xlat,
49
+ * @defval: default value for the property. This is used only if @set_default
28
@@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as,
50
+ * is true.
29
MemTxAttrs attrs)
51
+ */
30
{
52
struct Property {
31
return flatview_translate(address_space_to_flatview(as),
53
const char *name;
32
- addr, xlat, len, is_write);
54
const PropertyInfo *info;
33
+ addr, xlat, len, is_write, attrs);
55
ptrdiff_t offset;
34
}
56
uint8_t bitnr;
35
57
+ bool set_default;
36
/* address_space_access_valid: check for validity of accessing an address
58
union {
37
@@ -XXX,XX +XXX,XX @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr,
59
int64_t i;
38
rcu_read_lock();
60
uint64_t u;
39
fv = address_space_to_flatview(as);
61
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
40
l = len;
41
- mr = flatview_translate(fv, addr, &addr1, &l, false);
42
+ mr = flatview_translate(fv, addr, &addr1, &l, false, attrs);
43
if (len == l && memory_access_is_direct(mr, false)) {
44
ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
45
memcpy(buf, ptr, len);
46
diff --git a/exec.c b/exec.c
62
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
63
--- a/include/hw/qdev-properties.h
48
--- a/exec.c
64
+++ b/include/hw/qdev-properties.h
49
+++ b/exec.c
65
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
50
@@ -XXX,XX +XXX,XX @@ iotlb_fail:
66
.info = &(_prop), \
51
67
.offset = offsetof(_state, _field) \
52
/* Called from RCU critical section */
68
+ type_check(_type,typeof_field(_state, _field)), \
53
MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
69
+ .set_default = true, \
54
- hwaddr *plen, bool is_write)
70
.defval.i = (_type)_defval, \
55
+ hwaddr *plen, bool is_write,
56
+ MemTxAttrs attrs)
57
{
58
MemoryRegion *mr;
59
MemoryRegionSection section;
60
@@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr,
71
}
61
}
72
62
73
+#define DEFINE_PROP_SIGNED_NODEFAULT(_name, _state, _field, _prop, _type) { \
63
l = len;
74
+ .name = (_name), \
64
- mr = flatview_translate(fv, addr, &addr1, &l, true);
75
+ .info = &(_prop), \
65
+ mr = flatview_translate(fv, addr, &addr1, &l, true, attrs);
76
+ .offset = offsetof(_state, _field) \
66
}
77
+ + type_check(_type, typeof_field(_state, _field)), \
67
78
+ }
68
return result;
79
+
69
@@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
80
#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
70
MemTxResult result = MEMTX_OK;
81
.name = (_name), \
71
82
.info = &(qdev_prop_bit), \
72
l = len;
83
.bitnr = (_bit), \
73
- mr = flatview_translate(fv, addr, &addr1, &l, true);
84
.offset = offsetof(_state, _field) \
74
+ mr = flatview_translate(fv, addr, &addr1, &l, true, attrs);
85
+ type_check(uint32_t,typeof_field(_state, _field)), \
75
result = flatview_write_continue(fv, addr, attrs, buf, len,
86
+ .set_default = true, \
76
addr1, l, mr);
87
.defval.u = (bool)_defval, \
77
78
@@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
88
}
79
}
89
80
90
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
81
l = len;
91
.info = &(_prop), \
82
- mr = flatview_translate(fv, addr, &addr1, &l, false);
92
.offset = offsetof(_state, _field) \
83
+ mr = flatview_translate(fv, addr, &addr1, &l, false, attrs);
93
+ type_check(_type, typeof_field(_state, _field)), \
84
}
94
+ .set_default = true, \
85
95
.defval.u = (_type)_defval, \
86
return result;
87
@@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
88
MemoryRegion *mr;
89
90
l = len;
91
- mr = flatview_translate(fv, addr, &addr1, &l, false);
92
+ mr = flatview_translate(fv, addr, &addr1, &l, false, attrs);
93
return flatview_read_continue(fv, addr, attrs, buf, len,
94
addr1, l, mr);
95
}
96
@@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
97
98
while (len > 0) {
99
l = len;
100
- mr = flatview_translate(fv, addr, &xlat, &l, is_write);
101
+ mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs);
102
if (!memory_access_is_direct(mr, is_write)) {
103
l = memory_access_size(mr, l, addr);
104
if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) {
105
@@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr,
106
107
len = target_len;
108
this_mr = flatview_translate(fv, addr, &xlat,
109
- &len, is_write);
110
+ &len, is_write, attrs);
111
if (this_mr != mr || xlat != base + done) {
112
return done;
96
}
113
}
97
114
@@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as,
98
+#define DEFINE_PROP_UNSIGNED_NODEFAULT(_name, _state, _field, _prop, _type) { \
115
l = len;
99
+ .name = (_name), \
116
rcu_read_lock();
100
+ .info = &(_prop), \
117
fv = address_space_to_flatview(as);
101
+ .offset = offsetof(_state, _field) \
118
- mr = flatview_translate(fv, addr, &xlat, &l, is_write);
102
+ + type_check(_type, typeof_field(_state, _field)), \
119
+ mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs);
103
+ }
120
104
+
121
if (!memory_access_is_direct(mr, is_write)) {
105
#define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \
122
if (atomic_xchg(&bounce.in_use, true)) {
106
.name = (_name), \
107
.info = &(qdev_prop_bit64), \
108
.bitnr = (_bit), \
109
.offset = offsetof(_state, _field) \
110
+ type_check(uint64_t, typeof_field(_state, _field)), \
111
+ .set_default = true, \
112
.defval.u = (bool)_defval, \
113
}
114
115
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
116
.info = &(qdev_prop_bool), \
117
.offset = offsetof(_state, _field) \
118
+ type_check(bool, typeof_field(_state, _field)), \
119
+ .set_default = true, \
120
.defval.u = (bool)_defval, \
121
}
122
123
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
124
_arrayfield, _arrayprop, _arraytype) { \
125
.name = (PROP_ARRAY_LEN_PREFIX _name), \
126
.info = &(qdev_prop_arraylen), \
127
+ .set_default = true, \
128
.defval.u = 0, \
129
.offset = offsetof(_state, _field) \
130
+ type_check(uint32_t, typeof_field(_state, _field)), \
131
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
132
index XXXXXXX..XXXXXXX 100644
133
--- a/hw/core/qdev.c
134
+++ b/hw/core/qdev.c
135
@@ -XXX,XX +XXX,XX @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
136
prop->info->description,
137
&error_abort);
138
139
- if (prop->info->set_default_value) {
140
+ if (prop->set_default) {
141
prop->info->set_default_value(obj, prop);
142
}
143
}
144
--
123
--
145
2.7.4
124
2.17.1
146
125
147
126
diff view generated by jsdifflib
1
Implement a model of the simple "APB UART" provided in
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
the Cortex-M System Design Kit (CMSDK).
2
add MemTxAttrs as an argument to address_space_get_iotlb_entry().
3
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 1500029487-14822-3-git-send-email-peter.maydell@linaro.org
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180521140402.23318-12-peter.maydell@linaro.org
7
---
8
---
8
hw/char/Makefile.objs | 1 +
9
include/exec/memory.h | 2 +-
9
include/hw/char/cmsdk-apb-uart.h | 78 ++++++++
10
exec.c | 2 +-
10
hw/char/cmsdk-apb-uart.c | 403 +++++++++++++++++++++++++++++++++++++++
11
hw/virtio/vhost.c | 3 ++-
11
default-configs/arm-softmmu.mak | 2 +
12
3 files changed, 4 insertions(+), 3 deletions(-)
12
hw/char/trace-events | 9 +
13
5 files changed, 493 insertions(+)
14
create mode 100644 include/hw/char/cmsdk-apb-uart.h
15
create mode 100644 hw/char/cmsdk-apb-uart.c
16
13
17
diff --git a/hw/char/Makefile.objs b/hw/char/Makefile.objs
14
diff --git a/include/exec/memory.h b/include/exec/memory.h
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/char/Makefile.objs
16
--- a/include/exec/memory.h
20
+++ b/hw/char/Makefile.objs
17
+++ b/include/exec/memory.h
21
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_DIGIC) += digic-uart.o
18
@@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache);
22
obj-$(CONFIG_STM32F2XX_USART) += stm32f2xx_usart.o
19
* entry. Should be called from an RCU critical section.
23
obj-$(CONFIG_RASPI) += bcm2835_aux.o
20
*/
24
21
IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
25
+common-obj-$(CONFIG_CMSDK_APB_UART) += cmsdk-apb-uart.o
22
- bool is_write);
26
common-obj-$(CONFIG_ETRAXFS) += etraxfs_ser.o
23
+ bool is_write, MemTxAttrs attrs);
27
common-obj-$(CONFIG_ISA_DEBUG) += debugcon.o
24
28
common-obj-$(CONFIG_GRLIB) += grlib_apbuart.o
25
/* address_space_translate: translate an address range into an address space
29
diff --git a/include/hw/char/cmsdk-apb-uart.h b/include/hw/char/cmsdk-apb-uart.h
26
* into a MemoryRegion and an address range into that section. Should be
30
new file mode 100644
27
diff --git a/exec.c b/exec.c
31
index XXXXXXX..XXXXXXX
32
--- /dev/null
33
+++ b/include/hw/char/cmsdk-apb-uart.h
34
@@ -XXX,XX +XXX,XX @@
35
+/*
36
+ * ARM CMSDK APB UART emulation
37
+ *
38
+ * Copyright (c) 2017 Linaro Limited
39
+ * Written by Peter Maydell
40
+ *
41
+ * This program is free software; you can redistribute it and/or modify
42
+ * it under the terms of the GNU General Public License version 2 or
43
+ * (at your option) any later version.
44
+ */
45
+
46
+#ifndef CMSDK_APB_UART_H
47
+#define CMSDK_APB_UART_H
48
+
49
+#include "hw/sysbus.h"
50
+#include "chardev/char-fe.h"
51
+
52
+#define TYPE_CMSDK_APB_UART "cmsdk-apb-uart"
53
+#define CMSDK_APB_UART(obj) OBJECT_CHECK(CMSDKAPBUART, (obj), \
54
+ TYPE_CMSDK_APB_UART)
55
+
56
+typedef struct {
57
+ /*< private >*/
58
+ SysBusDevice parent_obj;
59
+
60
+ /*< public >*/
61
+ MemoryRegion iomem;
62
+ CharBackend chr;
63
+ qemu_irq txint;
64
+ qemu_irq rxint;
65
+ qemu_irq txovrint;
66
+ qemu_irq rxovrint;
67
+ qemu_irq uartint;
68
+ guint watch_tag;
69
+ uint32_t pclk_frq;
70
+
71
+ uint32_t state;
72
+ uint32_t ctrl;
73
+ uint32_t intstatus;
74
+ uint32_t bauddiv;
75
+ /* This UART has no FIFO, only a 1-character buffer for each of Tx and Rx */
76
+ uint8_t txbuf;
77
+ uint8_t rxbuf;
78
+} CMSDKAPBUART;
79
+
80
+/**
81
+ * cmsdk_apb_uart_create - convenience function to create TYPE_CMSDK_APB_UART
82
+ * @addr: location in system memory to map registers
83
+ * @chr: Chardev backend to connect UART to, or NULL if no backend
84
+ * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate)
85
+ */
86
+static inline DeviceState *cmsdk_apb_uart_create(hwaddr addr,
87
+ qemu_irq txint,
88
+ qemu_irq rxint,
89
+ qemu_irq txovrint,
90
+ qemu_irq rxovrint,
91
+ qemu_irq uartint,
92
+ Chardev *chr,
93
+ uint32_t pclk_frq)
94
+{
95
+ DeviceState *dev;
96
+ SysBusDevice *s;
97
+
98
+ dev = qdev_create(NULL, TYPE_CMSDK_APB_UART);
99
+ s = SYS_BUS_DEVICE(dev);
100
+ qdev_prop_set_chr(dev, "chardev", chr);
101
+ qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq);
102
+ qdev_init_nofail(dev);
103
+ sysbus_mmio_map(s, 0, addr);
104
+ sysbus_connect_irq(s, 0, txint);
105
+ sysbus_connect_irq(s, 1, rxint);
106
+ sysbus_connect_irq(s, 2, txovrint);
107
+ sysbus_connect_irq(s, 3, rxovrint);
108
+ sysbus_connect_irq(s, 4, uartint);
109
+ return dev;
110
+}
111
+
112
+#endif
113
diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c
114
new file mode 100644
115
index XXXXXXX..XXXXXXX
116
--- /dev/null
117
+++ b/hw/char/cmsdk-apb-uart.c
118
@@ -XXX,XX +XXX,XX @@
119
+/*
120
+ * ARM CMSDK APB UART emulation
121
+ *
122
+ * Copyright (c) 2017 Linaro Limited
123
+ * Written by Peter Maydell
124
+ *
125
+ * This program is free software; you can redistribute it and/or modify
126
+ * it under the terms of the GNU General Public License version 2 or
127
+ * (at your option) any later version.
128
+ */
129
+
130
+/* This is a model of the "APB UART" which is part of the Cortex-M
131
+ * System Design Kit (CMSDK) and documented in the Cortex-M System
132
+ * Design Kit Technical Reference Manual (ARM DDI0479C):
133
+ * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
134
+ */
135
+
136
+#include "qemu/osdep.h"
137
+#include "qemu/log.h"
138
+#include "qapi/error.h"
139
+#include "trace.h"
140
+#include "hw/sysbus.h"
141
+#include "hw/registerfields.h"
142
+#include "chardev/char-fe.h"
143
+#include "chardev/char-serial.h"
144
+#include "hw/char/cmsdk-apb-uart.h"
145
+
146
+REG32(DATA, 0)
147
+REG32(STATE, 4)
148
+ FIELD(STATE, TXFULL, 0, 1)
149
+ FIELD(STATE, RXFULL, 1, 1)
150
+ FIELD(STATE, TXOVERRUN, 2, 1)
151
+ FIELD(STATE, RXOVERRUN, 3, 1)
152
+REG32(CTRL, 8)
153
+ FIELD(CTRL, TX_EN, 0, 1)
154
+ FIELD(CTRL, RX_EN, 1, 1)
155
+ FIELD(CTRL, TX_INTEN, 2, 1)
156
+ FIELD(CTRL, RX_INTEN, 3, 1)
157
+ FIELD(CTRL, TXO_INTEN, 4, 1)
158
+ FIELD(CTRL, RXO_INTEN, 5, 1)
159
+ FIELD(CTRL, HSTEST, 6, 1)
160
+REG32(INTSTATUS, 0xc)
161
+ FIELD(INTSTATUS, TX, 0, 1)
162
+ FIELD(INTSTATUS, RX, 1, 1)
163
+ FIELD(INTSTATUS, TXO, 2, 1)
164
+ FIELD(INTSTATUS, RXO, 3, 1)
165
+REG32(BAUDDIV, 0x10)
166
+REG32(PID4, 0xFD0)
167
+REG32(PID5, 0xFD4)
168
+REG32(PID6, 0xFD8)
169
+REG32(PID7, 0xFDC)
170
+REG32(PID0, 0xFE0)
171
+REG32(PID1, 0xFE4)
172
+REG32(PID2, 0xFE8)
173
+REG32(PID3, 0xFEC)
174
+REG32(CID0, 0xFF0)
175
+REG32(CID1, 0xFF4)
176
+REG32(CID2, 0xFF8)
177
+REG32(CID3, 0xFFC)
178
+
179
+/* PID/CID values */
180
+static const int uart_id[] = {
181
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
182
+ 0x21, 0xb8, 0x1b, 0x00, /* PID0..PID3 */
183
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
184
+};
185
+
186
+static bool uart_baudrate_ok(CMSDKAPBUART *s)
187
+{
188
+ /* The minimum permitted bauddiv setting is 16, so we just ignore
189
+ * settings below that (usually this means the device has just
190
+ * been reset and not yet programmed).
191
+ */
192
+ return s->bauddiv >= 16 && s->bauddiv <= s->pclk_frq;
193
+}
194
+
195
+static void uart_update_parameters(CMSDKAPBUART *s)
196
+{
197
+ QEMUSerialSetParams ssp;
198
+
199
+ /* This UART is always 8N1 but the baud rate is programmable. */
200
+ if (!uart_baudrate_ok(s)) {
201
+ return;
202
+ }
203
+
204
+ ssp.data_bits = 8;
205
+ ssp.parity = 'N';
206
+ ssp.stop_bits = 1;
207
+ ssp.speed = s->pclk_frq / s->bauddiv;
208
+ qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
209
+ trace_cmsdk_apb_uart_set_params(ssp.speed);
210
+}
211
+
212
+static void cmsdk_apb_uart_update(CMSDKAPBUART *s)
213
+{
214
+ /* update outbound irqs, including handling the way the rxo and txo
215
+ * interrupt status bits are just logical AND of the overrun bit in
216
+ * STATE and the overrun interrupt enable bit in CTRL.
217
+ */
218
+ uint32_t omask = (R_INTSTATUS_RXO_MASK | R_INTSTATUS_TXO_MASK);
219
+ s->intstatus &= ~omask;
220
+ s->intstatus |= (s->state & (s->ctrl >> 2) & omask);
221
+
222
+ qemu_set_irq(s->txint, !!(s->intstatus & R_INTSTATUS_TX_MASK));
223
+ qemu_set_irq(s->rxint, !!(s->intstatus & R_INTSTATUS_RX_MASK));
224
+ qemu_set_irq(s->txovrint, !!(s->intstatus & R_INTSTATUS_TXO_MASK));
225
+ qemu_set_irq(s->rxovrint, !!(s->intstatus & R_INTSTATUS_RXO_MASK));
226
+ qemu_set_irq(s->uartint, !!(s->intstatus));
227
+}
228
+
229
+static int uart_can_receive(void *opaque)
230
+{
231
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
232
+
233
+ /* We can take a char if RX is enabled and the buffer is empty */
234
+ if (s->ctrl & R_CTRL_RX_EN_MASK && !(s->state & R_STATE_RXFULL_MASK)) {
235
+ return 1;
236
+ }
237
+ return 0;
238
+}
239
+
240
+static void uart_receive(void *opaque, const uint8_t *buf, int size)
241
+{
242
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
243
+
244
+ trace_cmsdk_apb_uart_receive(*buf);
245
+
246
+ /* In fact uart_can_receive() ensures that we can't be
247
+ * called unless RX is enabled and the buffer is empty,
248
+ * but we include this logic as documentation of what the
249
+ * hardware does if a character arrives in these circumstances.
250
+ */
251
+ if (!(s->ctrl & R_CTRL_RX_EN_MASK)) {
252
+ /* Just drop the character on the floor */
253
+ return;
254
+ }
255
+
256
+ if (s->state & R_STATE_RXFULL_MASK) {
257
+ s->state |= R_STATE_RXOVERRUN_MASK;
258
+ }
259
+
260
+ s->rxbuf = *buf;
261
+ s->state |= R_STATE_RXFULL_MASK;
262
+ if (s->ctrl & R_CTRL_RX_INTEN_MASK) {
263
+ s->intstatus |= R_INTSTATUS_RX_MASK;
264
+ }
265
+ cmsdk_apb_uart_update(s);
266
+}
267
+
268
+static uint64_t uart_read(void *opaque, hwaddr offset, unsigned size)
269
+{
270
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
271
+ uint64_t r;
272
+
273
+ switch (offset) {
274
+ case A_DATA:
275
+ r = s->rxbuf;
276
+ s->state &= ~R_STATE_RXFULL_MASK;
277
+ cmsdk_apb_uart_update(s);
278
+ break;
279
+ case A_STATE:
280
+ r = s->state;
281
+ break;
282
+ case A_CTRL:
283
+ r = s->ctrl;
284
+ break;
285
+ case A_INTSTATUS:
286
+ r = s->intstatus;
287
+ break;
288
+ case A_BAUDDIV:
289
+ r = s->bauddiv;
290
+ break;
291
+ case A_PID4 ... A_CID3:
292
+ r = uart_id[(offset - A_PID4) / 4];
293
+ break;
294
+ default:
295
+ qemu_log_mask(LOG_GUEST_ERROR,
296
+ "CMSDK APB UART read: bad offset %x\n", (int) offset);
297
+ r = 0;
298
+ break;
299
+ }
300
+ trace_cmsdk_apb_uart_read(offset, r, size);
301
+ return r;
302
+}
303
+
304
+/* Try to send tx data, and arrange to be called back later if
305
+ * we can't (ie the char backend is busy/blocking).
306
+ */
307
+static gboolean uart_transmit(GIOChannel *chan, GIOCondition cond, void *opaque)
308
+{
309
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
310
+ int ret;
311
+
312
+ s->watch_tag = 0;
313
+
314
+ if (!(s->ctrl & R_CTRL_TX_EN_MASK) || !(s->state & R_STATE_TXFULL_MASK)) {
315
+ return FALSE;
316
+ }
317
+
318
+ ret = qemu_chr_fe_write(&s->chr, &s->txbuf, 1);
319
+ if (ret <= 0) {
320
+ s->watch_tag = qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP,
321
+ uart_transmit, s);
322
+ if (!s->watch_tag) {
323
+ /* Most common reason to be here is "no chardev backend":
324
+ * just insta-drain the buffer, so the serial output
325
+ * goes into a void, rather than blocking the guest.
326
+ */
327
+ goto buffer_drained;
328
+ }
329
+ /* Transmit pending */
330
+ trace_cmsdk_apb_uart_tx_pending();
331
+ return FALSE;
332
+ }
333
+
334
+buffer_drained:
335
+ /* Character successfully sent */
336
+ trace_cmsdk_apb_uart_tx(s->txbuf);
337
+ s->state &= ~R_STATE_TXFULL_MASK;
338
+ /* Going from TXFULL set to clear triggers the tx interrupt */
339
+ if (s->ctrl & R_CTRL_TX_INTEN_MASK) {
340
+ s->intstatus |= R_INTSTATUS_TX_MASK;
341
+ }
342
+ cmsdk_apb_uart_update(s);
343
+ return FALSE;
344
+}
345
+
346
+static void uart_cancel_transmit(CMSDKAPBUART *s)
347
+{
348
+ if (s->watch_tag) {
349
+ g_source_remove(s->watch_tag);
350
+ s->watch_tag = 0;
351
+ }
352
+}
353
+
354
+static void uart_write(void *opaque, hwaddr offset, uint64_t value,
355
+ unsigned size)
356
+{
357
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
358
+
359
+ trace_cmsdk_apb_uart_write(offset, value, size);
360
+
361
+ switch (offset) {
362
+ case A_DATA:
363
+ s->txbuf = value;
364
+ if (s->state & R_STATE_TXFULL_MASK) {
365
+ /* Buffer already full -- note the overrun and let the
366
+ * existing pending transmit callback handle the new char.
367
+ */
368
+ s->state |= R_STATE_TXOVERRUN_MASK;
369
+ cmsdk_apb_uart_update(s);
370
+ } else {
371
+ s->state |= R_STATE_TXFULL_MASK;
372
+ uart_transmit(NULL, G_IO_OUT, s);
373
+ }
374
+ break;
375
+ case A_STATE:
376
+ /* Bits 0 and 1 are read only; bits 2 and 3 are W1C */
377
+ s->state &= ~(value &
378
+ (R_STATE_TXOVERRUN_MASK | R_STATE_RXOVERRUN_MASK));
379
+ cmsdk_apb_uart_update(s);
380
+ break;
381
+ case A_CTRL:
382
+ s->ctrl = value & 0x7f;
383
+ if ((s->ctrl & R_CTRL_TX_EN_MASK) && !uart_baudrate_ok(s)) {
384
+ qemu_log_mask(LOG_GUEST_ERROR,
385
+ "CMSDK APB UART: Tx enabled with invalid baudrate\n");
386
+ }
387
+ cmsdk_apb_uart_update(s);
388
+ break;
389
+ case A_INTSTATUS:
390
+ /* All bits are W1C. Clearing the overrun interrupt bits really
391
+ * clears the overrun status bits in the STATE register (which
392
+ * is then reflected into the intstatus value by the update function).
393
+ */
394
+ s->state &= ~(value & (R_INTSTATUS_TXO_MASK | R_INTSTATUS_RXO_MASK));
395
+ cmsdk_apb_uart_update(s);
396
+ break;
397
+ case A_BAUDDIV:
398
+ s->bauddiv = value & 0xFFFFF;
399
+ uart_update_parameters(s);
400
+ break;
401
+ case A_PID4 ... A_CID3:
402
+ qemu_log_mask(LOG_GUEST_ERROR,
403
+ "CMSDK APB UART write: write to RO offset 0x%x\n",
404
+ (int)offset);
405
+ break;
406
+ default:
407
+ qemu_log_mask(LOG_GUEST_ERROR,
408
+ "CMSDK APB UART write: bad offset 0x%x\n", (int) offset);
409
+ break;
410
+ }
411
+}
412
+
413
+static const MemoryRegionOps uart_ops = {
414
+ .read = uart_read,
415
+ .write = uart_write,
416
+ .endianness = DEVICE_LITTLE_ENDIAN,
417
+};
418
+
419
+static void cmsdk_apb_uart_reset(DeviceState *dev)
420
+{
421
+ CMSDKAPBUART *s = CMSDK_APB_UART(dev);
422
+
423
+ trace_cmsdk_apb_uart_reset();
424
+ uart_cancel_transmit(s);
425
+ s->state = 0;
426
+ s->ctrl = 0;
427
+ s->intstatus = 0;
428
+ s->bauddiv = 0;
429
+ s->txbuf = 0;
430
+ s->rxbuf = 0;
431
+}
432
+
433
+static void cmsdk_apb_uart_init(Object *obj)
434
+{
435
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
436
+ CMSDKAPBUART *s = CMSDK_APB_UART(obj);
437
+
438
+ memory_region_init_io(&s->iomem, obj, &uart_ops, s, "uart", 0x1000);
439
+ sysbus_init_mmio(sbd, &s->iomem);
440
+ sysbus_init_irq(sbd, &s->txint);
441
+ sysbus_init_irq(sbd, &s->rxint);
442
+ sysbus_init_irq(sbd, &s->txovrint);
443
+ sysbus_init_irq(sbd, &s->rxovrint);
444
+ sysbus_init_irq(sbd, &s->uartint);
445
+}
446
+
447
+static void cmsdk_apb_uart_realize(DeviceState *dev, Error **errp)
448
+{
449
+ CMSDKAPBUART *s = CMSDK_APB_UART(dev);
450
+
451
+ if (s->pclk_frq == 0) {
452
+ error_setg(errp, "CMSDK APB UART: pclk-frq property must be set");
453
+ return;
454
+ }
455
+
456
+ /* This UART has no flow control, so we do not need to register
457
+ * an event handler to deal with CHR_EVENT_BREAK.
458
+ */
459
+ qemu_chr_fe_set_handlers(&s->chr, uart_can_receive, uart_receive,
460
+ NULL, s, NULL, true);
461
+}
462
+
463
+static int cmsdk_apb_uart_post_load(void *opaque, int version_id)
464
+{
465
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
466
+
467
+ /* If we have a pending character, arrange to resend it. */
468
+ if (s->state & R_STATE_TXFULL_MASK) {
469
+ s->watch_tag = qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP,
470
+ uart_transmit, s);
471
+ }
472
+ uart_update_parameters(s);
473
+ return 0;
474
+}
475
+
476
+static const VMStateDescription cmsdk_apb_uart_vmstate = {
477
+ .name = "cmsdk-apb-uart",
478
+ .version_id = 1,
479
+ .minimum_version_id = 1,
480
+ .post_load = cmsdk_apb_uart_post_load,
481
+ .fields = (VMStateField[]) {
482
+ VMSTATE_UINT32(state, CMSDKAPBUART),
483
+ VMSTATE_UINT32(ctrl, CMSDKAPBUART),
484
+ VMSTATE_UINT32(intstatus, CMSDKAPBUART),
485
+ VMSTATE_UINT32(bauddiv, CMSDKAPBUART),
486
+ VMSTATE_UINT8(txbuf, CMSDKAPBUART),
487
+ VMSTATE_UINT8(rxbuf, CMSDKAPBUART),
488
+ VMSTATE_END_OF_LIST()
489
+ }
490
+};
491
+
492
+static Property cmsdk_apb_uart_properties[] = {
493
+ DEFINE_PROP_CHR("chardev", CMSDKAPBUART, chr),
494
+ DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBUART, pclk_frq, 0),
495
+ DEFINE_PROP_END_OF_LIST(),
496
+};
497
+
498
+static void cmsdk_apb_uart_class_init(ObjectClass *klass, void *data)
499
+{
500
+ DeviceClass *dc = DEVICE_CLASS(klass);
501
+
502
+ dc->realize = cmsdk_apb_uart_realize;
503
+ dc->vmsd = &cmsdk_apb_uart_vmstate;
504
+ dc->reset = cmsdk_apb_uart_reset;
505
+ dc->props = cmsdk_apb_uart_properties;
506
+}
507
+
508
+static const TypeInfo cmsdk_apb_uart_info = {
509
+ .name = TYPE_CMSDK_APB_UART,
510
+ .parent = TYPE_SYS_BUS_DEVICE,
511
+ .instance_size = sizeof(CMSDKAPBUART),
512
+ .instance_init = cmsdk_apb_uart_init,
513
+ .class_init = cmsdk_apb_uart_class_init,
514
+};
515
+
516
+static void cmsdk_apb_uart_register_types(void)
517
+{
518
+ type_register_static(&cmsdk_apb_uart_info);
519
+}
520
+
521
+type_init(cmsdk_apb_uart_register_types);
522
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
523
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
524
--- a/default-configs/arm-softmmu.mak
29
--- a/exec.c
525
+++ b/default-configs/arm-softmmu.mak
30
+++ b/exec.c
526
@@ -XXX,XX +XXX,XX @@ CONFIG_STM32F2XX_ADC=y
31
@@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
527
CONFIG_STM32F2XX_SPI=y
32
528
CONFIG_STM32F205_SOC=y
33
/* Called from RCU critical section */
529
34
IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
530
+CONFIG_CMSDK_APB_UART=y
35
- bool is_write)
531
+
36
+ bool is_write, MemTxAttrs attrs)
532
CONFIG_VERSATILE_PCI=y
37
{
533
CONFIG_VERSATILE_I2C=y
38
MemoryRegionSection section;
534
39
hwaddr xlat, page_mask;
535
diff --git a/hw/char/trace-events b/hw/char/trace-events
40
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
536
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
537
--- a/hw/char/trace-events
42
--- a/hw/virtio/vhost.c
538
+++ b/hw/char/trace-events
43
+++ b/hw/virtio/vhost.c
539
@@ -XXX,XX +XXX,XX @@ pl011_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
44
@@ -XXX,XX +XXX,XX @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write)
540
pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR %08x read_count %d returning %d"
45
trace_vhost_iotlb_miss(dev, 1);
541
pl011_put_fifo(uint32_t c, int read_count) "new char 0x%x read_count now %d"
46
542
pl011_put_fifo_full(void) "FIFO now full, RXFF set"
47
iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
543
+
48
- iova, write);
544
+# hw/char/cmsdk_apb_uart.c
49
+ iova, write,
545
+cmsdk_apb_uart_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB UART read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
50
+ MEMTXATTRS_UNSPECIFIED);
546
+cmsdk_apb_uart_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB UART write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
51
if (iotlb.target_as != NULL) {
547
+cmsdk_apb_uart_reset(void) "CMSDK APB UART: reset"
52
ret = vhost_memory_region_lookup(dev, iotlb.translated_addr,
548
+cmsdk_apb_uart_receive(uint8_t c) "CMSDK APB UART: got character 0x%x from backend"
53
&uaddr, &len);
549
+cmsdk_apb_uart_tx_pending(void) "CMSDK APB UART: character send to backend pending"
550
+cmsdk_apb_uart_tx(uint8_t c) "CMSDK APB UART: character 0x%x sent to backend"
551
+cmsdk_apb_uart_set_params(int speed) "CMSDK APB UART: params set to %d 8N1"
552
--
54
--
553
2.7.4
55
2.17.1
554
56
555
57
diff view generated by jsdifflib
1
Model the ARM MPS2/MPS2+ FPGA based development board.
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
2
add MemTxAttrs as an argument to flatview_do_translate().
3
The MPS2 and MPS2+ dev boards are FPGA based (the 2+ has a bigger
4
FPGA but is otherwise the same as the 2). Since the CPU itself
5
and most of the devices are in the FPGA, the details of the board
6
as seen by the guest depend significantly on the FPGA image.
7
8
We model the following FPGA images:
9
"mps2_an385" -- Cortex-M3 as documented in ARM Application Note AN385
10
"mps2_an511" -- Cortex-M3 'DesignStart' as documented in AN511
11
12
They are fairly similar but differ in the details for some
13
peripherals.
14
3
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Message-id: 1500029487-14822-2-git-send-email-peter.maydell@linaro.org
17
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180521140402.23318-13-peter.maydell@linaro.org
18
---
8
---
19
hw/arm/Makefile.objs | 1 +
9
exec.c | 9 ++++++---
20
hw/arm/mps2.c | 270 ++++++++++++++++++++++++++++++++++++++++
10
1 file changed, 6 insertions(+), 3 deletions(-)
21
default-configs/arm-softmmu.mak | 1 +
22
3 files changed, 272 insertions(+)
23
create mode 100644 hw/arm/mps2.c
24
11
25
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
12
diff --git a/exec.c b/exec.c
26
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/arm/Makefile.objs
14
--- a/exec.c
28
+++ b/hw/arm/Makefile.objs
15
+++ b/exec.c
29
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
16
@@ -XXX,XX +XXX,XX @@ unassigned:
30
obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
17
* @is_write: whether the translation operation is for write
31
obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
18
* @is_mmio: whether this can be MMIO, set true if it can
32
obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o
19
* @target_as: the address space targeted by the IOMMU
33
+obj-$(CONFIG_MPS2) += mps2.o
20
+ * @attrs: memory transaction attributes
34
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
21
*
35
new file mode 100644
22
* This function is called from RCU critical section
36
index XXXXXXX..XXXXXXX
23
*/
37
--- /dev/null
24
@@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
38
+++ b/hw/arm/mps2.c
25
hwaddr *page_mask_out,
39
@@ -XXX,XX +XXX,XX @@
26
bool is_write,
40
+/*
27
bool is_mmio,
41
+ * ARM V2M MPS2 board emulation.
28
- AddressSpace **target_as)
42
+ *
29
+ AddressSpace **target_as,
43
+ * Copyright (c) 2017 Linaro Limited
30
+ MemTxAttrs attrs)
44
+ * Written by Peter Maydell
31
{
45
+ *
32
MemoryRegionSection *section;
46
+ * This program is free software; you can redistribute it and/or modify
33
IOMMUMemoryRegion *iommu_mr;
47
+ * it under the terms of the GNU General Public License version 2 or
34
@@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
48
+ * (at your option) any later version.
35
* but page mask.
49
+ */
36
*/
50
+
37
section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat,
51
+/* The MPS2 and MPS2+ dev boards are FPGA based (the 2+ has a bigger
38
- NULL, &page_mask, is_write, false, &as);
52
+ * FPGA but is otherwise the same as the 2). Since the CPU itself
39
+ NULL, &page_mask, is_write, false, &as,
53
+ * and most of the devices are in the FPGA, the details of the board
40
+ attrs);
54
+ * as seen by the guest depend significantly on the FPGA image.
41
55
+ * We model the following FPGA images:
42
/* Illegal translation */
56
+ * "mps2-an385" -- Cortex-M3 as documented in ARM Application Note AN385
43
if (section.mr == &io_mem_unassigned) {
57
+ * "mps2-an511" -- Cortex-M3 'DesignStart' as documented in AN511
44
@@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
58
+ *
45
59
+ * Links to the TRM for the board itself and to the various Application
46
/* This can be MMIO, so setup MMIO bit. */
60
+ * Notes which document the FPGA images can be found here:
47
section = flatview_do_translate(fv, addr, xlat, plen, NULL,
61
+ * https://developer.arm.com/products/system-design/development-boards/cortex-m-prototyping-system
48
- is_write, true, &as);
62
+ */
49
+ is_write, true, &as, attrs);
63
+
50
mr = section.mr;
64
+#include "qemu/osdep.h"
51
65
+#include "qapi/error.h"
52
if (xen_enabled() && memory_access_is_direct(mr, is_write)) {
66
+#include "qemu/error-report.h"
67
+#include "hw/arm/arm.h"
68
+#include "hw/arm/armv7m.h"
69
+#include "hw/boards.h"
70
+#include "exec/address-spaces.h"
71
+#include "hw/misc/unimp.h"
72
+
73
+typedef enum MPS2FPGAType {
74
+ FPGA_AN385,
75
+ FPGA_AN511,
76
+} MPS2FPGAType;
77
+
78
+typedef struct {
79
+ MachineClass parent;
80
+ MPS2FPGAType fpga_type;
81
+ const char *cpu_model;
82
+} MPS2MachineClass;
83
+
84
+typedef struct {
85
+ MachineState parent;
86
+
87
+ ARMv7MState armv7m;
88
+ MemoryRegion psram;
89
+ MemoryRegion ssram1;
90
+ MemoryRegion ssram1_m;
91
+ MemoryRegion ssram23;
92
+ MemoryRegion ssram23_m;
93
+ MemoryRegion blockram;
94
+ MemoryRegion blockram_m1;
95
+ MemoryRegion blockram_m2;
96
+ MemoryRegion blockram_m3;
97
+ MemoryRegion sram;
98
+} MPS2MachineState;
99
+
100
+#define TYPE_MPS2_MACHINE "mps2"
101
+#define TYPE_MPS2_AN385_MACHINE MACHINE_TYPE_NAME("mps2-an385")
102
+#define TYPE_MPS2_AN511_MACHINE MACHINE_TYPE_NAME("mps2-an511")
103
+
104
+#define MPS2_MACHINE(obj) \
105
+ OBJECT_CHECK(MPS2MachineState, obj, TYPE_MPS2_MACHINE)
106
+#define MPS2_MACHINE_GET_CLASS(obj) \
107
+ OBJECT_GET_CLASS(MPS2MachineClass, obj, TYPE_MPS2_MACHINE)
108
+#define MPS2_MACHINE_CLASS(klass) \
109
+ OBJECT_CLASS_CHECK(MPS2MachineClass, klass, TYPE_MPS2_MACHINE)
110
+
111
+/* Main SYSCLK frequency in Hz */
112
+#define SYSCLK_FRQ 25000000
113
+
114
+/* Initialize the auxiliary RAM region @mr and map it into
115
+ * the memory map at @base.
116
+ */
117
+static void make_ram(MemoryRegion *mr, const char *name,
118
+ hwaddr base, hwaddr size)
119
+{
120
+ memory_region_init_ram(mr, NULL, name, size, &error_fatal);
121
+ memory_region_add_subregion(get_system_memory(), base, mr);
122
+}
123
+
124
+/* Create an alias of an entire original MemoryRegion @orig
125
+ * located at @base in the memory map.
126
+ */
127
+static void make_ram_alias(MemoryRegion *mr, const char *name,
128
+ MemoryRegion *orig, hwaddr base)
129
+{
130
+ memory_region_init_alias(mr, NULL, name, orig, 0,
131
+ memory_region_size(orig));
132
+ memory_region_add_subregion(get_system_memory(), base, mr);
133
+}
134
+
135
+static void mps2_common_init(MachineState *machine)
136
+{
137
+ MPS2MachineState *mms = MPS2_MACHINE(machine);
138
+ MPS2MachineClass *mmc = MPS2_MACHINE_GET_CLASS(machine);
139
+ MemoryRegion *system_memory = get_system_memory();
140
+ DeviceState *armv7m;
141
+
142
+ if (!machine->cpu_model) {
143
+ machine->cpu_model = mmc->cpu_model;
144
+ }
145
+
146
+ if (strcmp(machine->cpu_model, mmc->cpu_model) != 0) {
147
+ error_report("This board can only be used with CPU %s", mmc->cpu_model);
148
+ exit(1);
149
+ }
150
+
151
+ /* The FPGA images have an odd combination of different RAMs,
152
+ * because in hardware they are different implementations and
153
+ * connected to different buses, giving varying performance/size
154
+ * tradeoffs. For QEMU they're all just RAM, though. We arbitrarily
155
+ * call the 16MB our "system memory", as it's the largest lump.
156
+ *
157
+ * Common to both boards:
158
+ * 0x21000000..0x21ffffff : PSRAM (16MB)
159
+ * AN385 only:
160
+ * 0x00000000 .. 0x003fffff : ZBT SSRAM1
161
+ * 0x00400000 .. 0x007fffff : mirror of ZBT SSRAM1
162
+ * 0x20000000 .. 0x203fffff : ZBT SSRAM 2&3
163
+ * 0x20400000 .. 0x207fffff : mirror of ZBT SSRAM 2&3
164
+ * 0x01000000 .. 0x01003fff : block RAM (16K)
165
+ * 0x01004000 .. 0x01007fff : mirror of above
166
+ * 0x01008000 .. 0x0100bfff : mirror of above
167
+ * 0x0100c000 .. 0x0100ffff : mirror of above
168
+ * AN511 only:
169
+ * 0x00000000 .. 0x0003ffff : FPGA block RAM
170
+ * 0x00400000 .. 0x007fffff : ZBT SSRAM1
171
+ * 0x20000000 .. 0x2001ffff : SRAM
172
+ * 0x20400000 .. 0x207fffff : ZBT SSRAM 2&3
173
+ *
174
+ * The AN385 has a feature where the lowest 16K can be mapped
175
+ * either to the bottom of the ZBT SSRAM1 or to the block RAM.
176
+ * This is of no use for QEMU so we don't implement it (as if
177
+ * zbt_boot_ctrl is always zero).
178
+ */
179
+ memory_region_allocate_system_memory(&mms->psram,
180
+ NULL, "mps.ram", 0x1000000);
181
+ memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);
182
+
183
+ switch (mmc->fpga_type) {
184
+ case FPGA_AN385:
185
+ make_ram(&mms->ssram1, "mps.ssram1", 0x0, 0x400000);
186
+ make_ram_alias(&mms->ssram1_m, "mps.ssram1_m", &mms->ssram1, 0x400000);
187
+ make_ram(&mms->ssram23, "mps.ssram23", 0x20000000, 0x400000);
188
+ make_ram_alias(&mms->ssram23_m, "mps.ssram23_m",
189
+ &mms->ssram23, 0x20400000);
190
+ make_ram(&mms->blockram, "mps.blockram", 0x01000000, 0x4000);
191
+ make_ram_alias(&mms->blockram_m1, "mps.blockram_m1",
192
+ &mms->blockram, 0x01004000);
193
+ make_ram_alias(&mms->blockram_m2, "mps.blockram_m2",
194
+ &mms->blockram, 0x01008000);
195
+ make_ram_alias(&mms->blockram_m3, "mps.blockram_m3",
196
+ &mms->blockram, 0x0100c000);
197
+ break;
198
+ case FPGA_AN511:
199
+ make_ram(&mms->blockram, "mps.blockram", 0x0, 0x40000);
200
+ make_ram(&mms->ssram1, "mps.ssram1", 0x00400000, 0x00800000);
201
+ make_ram(&mms->sram, "mps.sram", 0x20000000, 0x20000);
202
+ make_ram(&mms->ssram23, "mps.ssram23", 0x20400000, 0x400000);
203
+ break;
204
+ default:
205
+ g_assert_not_reached();
206
+ }
207
+
208
+ object_initialize(&mms->armv7m, sizeof(mms->armv7m), TYPE_ARMV7M);
209
+ armv7m = DEVICE(&mms->armv7m);
210
+ qdev_set_parent_bus(armv7m, sysbus_get_default());
211
+ switch (mmc->fpga_type) {
212
+ case FPGA_AN385:
213
+ qdev_prop_set_uint32(armv7m, "num-irq", 32);
214
+ break;
215
+ case FPGA_AN511:
216
+ qdev_prop_set_uint32(armv7m, "num-irq", 64);
217
+ break;
218
+ default:
219
+ g_assert_not_reached();
220
+ }
221
+ qdev_prop_set_string(armv7m, "cpu-model", machine->cpu_model);
222
+ object_property_set_link(OBJECT(&mms->armv7m), OBJECT(system_memory),
223
+ "memory", &error_abort);
224
+ object_property_set_bool(OBJECT(&mms->armv7m), true, "realized",
225
+ &error_fatal);
226
+
227
+ create_unimplemented_device("zbtsmram mirror", 0x00400000, 0x00400000);
228
+ create_unimplemented_device("RESERVED 1", 0x00800000, 0x00800000);
229
+ create_unimplemented_device("Block RAM", 0x01000000, 0x00010000);
230
+ create_unimplemented_device("RESERVED 2", 0x01010000, 0x1EFF0000);
231
+ create_unimplemented_device("RESERVED 3", 0x20800000, 0x00800000);
232
+ create_unimplemented_device("PSRAM", 0x21000000, 0x01000000);
233
+ /* These three ranges all cover multiple devices; we may implement
234
+ * some of them below (in which case the real device takes precedence
235
+ * over the unimplemented-region mapping).
236
+ */
237
+ create_unimplemented_device("CMSDK APB peripheral region @0x40000000",
238
+ 0x40000000, 0x00010000);
239
+ create_unimplemented_device("CMSDK peripheral region @0x40010000",
240
+ 0x40010000, 0x00010000);
241
+ create_unimplemented_device("Extra peripheral region @0x40020000",
242
+ 0x40020000, 0x00010000);
243
+ create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000);
244
+ create_unimplemented_device("Ethernet", 0x40200000, 0x00100000);
245
+ create_unimplemented_device("VGA", 0x41000000, 0x0200000);
246
+
247
+ system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
248
+
249
+ armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
250
+ 0x400000);
251
+}
252
+
253
+static void mps2_class_init(ObjectClass *oc, void *data)
254
+{
255
+ MachineClass *mc = MACHINE_CLASS(oc);
256
+
257
+ mc->init = mps2_common_init;
258
+ mc->max_cpus = 1;
259
+}
260
+
261
+static void mps2_an385_class_init(ObjectClass *oc, void *data)
262
+{
263
+ MachineClass *mc = MACHINE_CLASS(oc);
264
+ MPS2MachineClass *mmc = MPS2_MACHINE_CLASS(oc);
265
+
266
+ mc->desc = "ARM MPS2 with AN385 FPGA image for Cortex-M3";
267
+ mmc->fpga_type = FPGA_AN385;
268
+ mmc->cpu_model = "cortex-m3";
269
+}
270
+
271
+static void mps2_an511_class_init(ObjectClass *oc, void *data)
272
+{
273
+ MachineClass *mc = MACHINE_CLASS(oc);
274
+ MPS2MachineClass *mmc = MPS2_MACHINE_CLASS(oc);
275
+
276
+ mc->desc = "ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3";
277
+ mmc->fpga_type = FPGA_AN511;
278
+ mmc->cpu_model = "cortex-m3";
279
+}
280
+
281
+static const TypeInfo mps2_info = {
282
+ .name = TYPE_MPS2_MACHINE,
283
+ .parent = TYPE_MACHINE,
284
+ .abstract = true,
285
+ .instance_size = sizeof(MPS2MachineState),
286
+ .class_size = sizeof(MPS2MachineClass),
287
+ .class_init = mps2_class_init,
288
+};
289
+
290
+static const TypeInfo mps2_an385_info = {
291
+ .name = TYPE_MPS2_AN385_MACHINE,
292
+ .parent = TYPE_MPS2_MACHINE,
293
+ .class_init = mps2_an385_class_init,
294
+};
295
+
296
+static const TypeInfo mps2_an511_info = {
297
+ .name = TYPE_MPS2_AN511_MACHINE,
298
+ .parent = TYPE_MPS2_MACHINE,
299
+ .class_init = mps2_an511_class_init,
300
+};
301
+
302
+static void mps2_machine_init(void)
303
+{
304
+ type_register_static(&mps2_info);
305
+ type_register_static(&mps2_an385_info);
306
+ type_register_static(&mps2_an511_info);
307
+}
308
+
309
+type_init(mps2_machine_init);
310
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
311
index XXXXXXX..XXXXXXX 100644
312
--- a/default-configs/arm-softmmu.mak
313
+++ b/default-configs/arm-softmmu.mak
314
@@ -XXX,XX +XXX,XX @@ CONFIG_ONENAND=y
315
CONFIG_TUSB6010=y
316
CONFIG_IMX=y
317
CONFIG_MAINSTONE=y
318
+CONFIG_MPS2=y
319
CONFIG_NSERIES=y
320
CONFIG_RASPI=y
321
CONFIG_REALVIEW=y
322
--
53
--
323
2.7.4
54
2.17.1
324
55
325
56
diff view generated by jsdifflib
1
Add the UARTs to the MPS2 board models.
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
2
add MemTxAttrs as an argument to address_space_translate_iommu().
3
Unfortunately the details of the wiring of the interrupts through
4
various OR gates differ between AN511 and AN385 so this can't
5
be purely a data-driven difference.
6
3
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Message-id: 1500029487-14822-4-git-send-email-peter.maydell@linaro.org
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180521140402.23318-14-peter.maydell@linaro.org
10
---
8
---
11
hw/arm/mps2.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
9
exec.c | 8 +++++---
12
hw/char/cmsdk-apb-uart.c | 2 +-
10
1 file changed, 5 insertions(+), 3 deletions(-)
13
2 files changed, 89 insertions(+), 1 deletion(-)
14
11
15
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
12
diff --git a/exec.c b/exec.c
16
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/mps2.c
14
--- a/exec.c
18
+++ b/hw/arm/mps2.c
15
+++ b/exec.c
19
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
20
#include "qemu/error-report.h"
17
* @is_write: whether the translation operation is for write
21
#include "hw/arm/arm.h"
18
* @is_mmio: whether this can be MMIO, set true if it can
22
#include "hw/arm/armv7m.h"
19
* @target_as: the address space targeted by the IOMMU
23
+#include "hw/or-irq.h"
20
+ * @attrs: transaction attributes
24
#include "hw/boards.h"
21
*
25
#include "exec/address-spaces.h"
22
* This function is called from RCU critical section. It is the common
26
+#include "sysemu/sysemu.h"
23
* part of flatview_do_translate and address_space_translate_cached.
27
#include "hw/misc/unimp.h"
24
@@ -XXX,XX +XXX,XX @@ static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion *iomm
28
+#include "hw/char/cmsdk-apb-uart.h"
25
hwaddr *page_mask_out,
29
26
bool is_write,
30
typedef enum MPS2FPGAType {
27
bool is_mmio,
31
FPGA_AN385,
28
- AddressSpace **target_as)
32
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
29
+ AddressSpace **target_as,
33
create_unimplemented_device("Ethernet", 0x40200000, 0x00100000);
30
+ MemTxAttrs attrs)
34
create_unimplemented_device("VGA", 0x41000000, 0x0200000);
31
{
35
32
MemoryRegionSection *section;
36
+ switch (mmc->fpga_type) {
33
hwaddr page_mask = (hwaddr)-1;
37
+ case FPGA_AN385:
34
@@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
38
+ {
35
return address_space_translate_iommu(iommu_mr, xlat,
39
+ /* The overflow IRQs for UARTs 0, 1 and 2 are ORed together.
36
plen_out, page_mask_out,
40
+ * Overflow for UARTs 4 and 5 doesn't trigger any interrupt.
37
is_write, is_mmio,
41
+ */
38
- target_as);
42
+ Object *orgate;
39
+ target_as, attrs);
43
+ DeviceState *orgate_dev;
40
}
44
+ int i;
41
if (page_mask_out) {
45
+
42
/* Not behind an IOMMU, use default page size. */
46
+ orgate = object_new(TYPE_OR_IRQ);
43
@@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate_cached(
47
+ object_property_set_int(orgate, 6, "num-lines", &error_fatal);
44
48
+ object_property_set_bool(orgate, true, "realized", &error_fatal);
45
section = address_space_translate_iommu(iommu_mr, xlat, plen,
49
+ orgate_dev = DEVICE(orgate);
46
NULL, is_write, true,
50
+ qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
47
- &target_as);
51
+
48
+ &target_as, attrs);
52
+ for (i = 0; i < 5; i++) {
49
return section.mr;
53
+ static const hwaddr uartbase[] = {0x40004000, 0x40005000,
54
+ 0x40006000, 0x40007000,
55
+ 0x40009000};
56
+ Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL;
57
+ /* RX irq number; TX irq is always one greater */
58
+ static const int uartirq[] = {0, 2, 4, 18, 20};
59
+ qemu_irq txovrint = NULL, rxovrint = NULL;
60
+
61
+ if (i < 3) {
62
+ txovrint = qdev_get_gpio_in(orgate_dev, i * 2);
63
+ rxovrint = qdev_get_gpio_in(orgate_dev, i * 2 + 1);
64
+ }
65
+
66
+ cmsdk_apb_uart_create(uartbase[i],
67
+ qdev_get_gpio_in(armv7m, uartirq[i] + 1),
68
+ qdev_get_gpio_in(armv7m, uartirq[i]),
69
+ txovrint, rxovrint,
70
+ NULL,
71
+ uartchr, SYSCLK_FRQ);
72
+ }
73
+ break;
74
+ }
75
+ case FPGA_AN511:
76
+ {
77
+ /* The overflow IRQs for all UARTs are ORed together.
78
+ * Tx and Rx IRQs for each UART are ORed together.
79
+ */
80
+ Object *orgate;
81
+ DeviceState *orgate_dev;
82
+ int i;
83
+
84
+ orgate = object_new(TYPE_OR_IRQ);
85
+ object_property_set_int(orgate, 10, "num-lines", &error_fatal);
86
+ object_property_set_bool(orgate, true, "realized", &error_fatal);
87
+ orgate_dev = DEVICE(orgate);
88
+ qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
89
+
90
+ for (i = 0; i < 5; i++) {
91
+ /* system irq numbers for the combined tx/rx for each UART */
92
+ static const int uart_txrx_irqno[] = {0, 2, 45, 46, 56};
93
+ static const hwaddr uartbase[] = {0x40004000, 0x40005000,
94
+ 0x4002c000, 0x4002d000,
95
+ 0x4002e000};
96
+ Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL;
97
+ Object *txrx_orgate;
98
+ DeviceState *txrx_orgate_dev;
99
+
100
+ txrx_orgate = object_new(TYPE_OR_IRQ);
101
+ object_property_set_int(txrx_orgate, 2, "num-lines", &error_fatal);
102
+ object_property_set_bool(txrx_orgate, true, "realized",
103
+ &error_fatal);
104
+ txrx_orgate_dev = DEVICE(txrx_orgate);
105
+ qdev_connect_gpio_out(txrx_orgate_dev, 0,
106
+ qdev_get_gpio_in(armv7m, uart_txrx_irqno[i]));
107
+ cmsdk_apb_uart_create(uartbase[i],
108
+ qdev_get_gpio_in(txrx_orgate_dev, 0),
109
+ qdev_get_gpio_in(txrx_orgate_dev, 1),
110
+ qdev_get_gpio_in(orgate_dev, 0),
111
+ qdev_get_gpio_in(orgate_dev, 1),
112
+ NULL,
113
+ uartchr, SYSCLK_FRQ);
114
+ }
115
+ break;
116
+ }
117
+ default:
118
+ g_assert_not_reached();
119
+ }
120
+
121
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
122
123
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
124
diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c
125
index XXXXXXX..XXXXXXX 100644
126
--- a/hw/char/cmsdk-apb-uart.c
127
+++ b/hw/char/cmsdk-apb-uart.c
128
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_uart_realize(DeviceState *dev, Error **errp)
129
* an event handler to deal with CHR_EVENT_BREAK.
130
*/
131
qemu_chr_fe_set_handlers(&s->chr, uart_can_receive, uart_receive,
132
- NULL, s, NULL, true);
133
+ NULL, NULL, s, NULL, true);
134
}
50
}
135
51
136
static int cmsdk_apb_uart_post_load(void *opaque, int version_id)
137
--
52
--
138
2.7.4
53
2.17.1
139
54
140
55
diff view generated by jsdifflib
1
The Cortex-M3 and M4 CPUs always have 8 PMSA MPU regions (this isn't
1
Provide a VMSTATE_BOOL_SUB_ARRAY to go with VMSTATE_UINT8_SUB_ARRAY
2
a configurable option for the hardware). Make the default value of
2
and friends.
3
the pmsav7-dregion property be set per-cpu, so we don't need to have
4
every user of these CPUs set it manually. (The existing default of
5
16 is correct for the other PMSAv7 core, the Cortex-R5.)
6
7
This fixes a bug where we were creating the M3 and M4 with
8
too many regions; most guest software would not notice or
9
care, though, since it would just not use the registers
10
associated with the unexpected extra regions.
11
3
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
14
Message-id: 1499788408-10096-4-git-send-email-peter.maydell@linaro.org
6
Message-id: 20180521140402.23318-23-peter.maydell@linaro.org
15
---
7
---
16
target/arm/cpu.c | 12 +++++++++++-
8
include/migration/vmstate.h | 3 +++
17
1 file changed, 11 insertions(+), 1 deletion(-)
9
1 file changed, 3 insertions(+)
18
10
19
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
11
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
20
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.c
13
--- a/include/migration/vmstate.h
22
+++ b/target/arm/cpu.c
14
+++ b/include/migration/vmstate.h
23
@@ -XXX,XX +XXX,XX @@ static Property arm_cpu_has_pmu_property =
15
@@ -XXX,XX +XXX,XX @@ extern const VMStateInfo vmstate_info_qtailq;
24
static Property arm_cpu_has_mpu_property =
16
#define VMSTATE_BOOL_ARRAY(_f, _s, _n) \
25
DEFINE_PROP_BOOL("has-mpu", ARMCPU, has_mpu, true);
17
VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
26
18
27
+/* This is like DEFINE_PROP_UINT32 but it doesn't set the default value,
19
+#define VMSTATE_BOOL_SUB_ARRAY(_f, _s, _start, _num) \
28
+ * because the CPU initfn will have already set cpu->pmsav7_dregion to
20
+ VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_bool, bool)
29
+ * the right value for that particular CPU type, and we don't want
21
+
30
+ * to override that with an incorrect constant value.
22
#define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
31
+ */
23
VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
32
static Property arm_cpu_pmsav7_dregion_property =
33
- DEFINE_PROP_UINT32("pmsav7-dregion", ARMCPU, pmsav7_dregion, 16);
34
+ DEFINE_PROP_UNSIGNED_NODEFAULT("pmsav7-dregion", ARMCPU,
35
+ pmsav7_dregion,
36
+ qdev_prop_uint32, uint32_t);
37
38
static void arm_cpu_post_init(Object *obj)
39
{
40
@@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj)
41
set_feature(&cpu->env, ARM_FEATURE_V7);
42
set_feature(&cpu->env, ARM_FEATURE_M);
43
cpu->midr = 0x410fc231;
44
+ cpu->pmsav7_dregion = 8;
45
}
46
47
static void cortex_m4_initfn(Object *obj)
48
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
49
set_feature(&cpu->env, ARM_FEATURE_M);
50
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
51
cpu->midr = 0x410fc240; /* r0p0 */
52
+ cpu->pmsav7_dregion = 8;
53
}
54
static void arm_v7m_class_init(ObjectClass *oc, void *data)
55
{
56
@@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj)
57
cpu->id_isar4 = 0x0010142;
58
cpu->id_isar5 = 0x0;
59
cpu->mp_is_up = true;
60
+ cpu->pmsav7_dregion = 16;
61
define_arm_cp_regs(cpu, cortexr5_cp_reginfo);
62
}
63
24
64
--
25
--
65
2.7.4
26
2.17.1
66
27
67
28
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Shannon Zhao <zhaoshenglong@huawei.com>
2
2
3
DISAS_UPDATE should be used when the wider CPU state other than just
3
acpi_data_push uses g_array_set_size to resize the memory size. If there
4
the PC has been updated and we should therefore exit the TCG runtime
4
is no enough contiguous memory, the address will be changed. So previous
5
and return to the main execution loop rather assuming DISAS_JUMP would
5
pointer could not be used any more. It must update the pointer and use
6
do that.
6
the new one.
7
7
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Also, previous codes wrongly use le32 conversion of iort->node_offset
9
Reviewed-by: Richard Henderson <rth@twiddle.net>
9
for subsequent computations that will result incorrect value if host is
10
Message-id: 20170713141928.25419-3-alex.bennee@linaro.org
10
not litlle endian. So use the non-converted one instead.
11
12
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
13
Reviewed-by: Eric Auger <eric.auger@redhat.com>
14
Message-id: 1527663951-14552-1-git-send-email-zhaoshenglong@huawei.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
16
---
13
target/arm/translate-a64.c | 14 +++++++-------
17
hw/arm/virt-acpi-build.c | 20 +++++++++++++++-----
14
target/arm/translate.c | 6 +++---
18
1 file changed, 15 insertions(+), 5 deletions(-)
15
2 files changed, 10 insertions(+), 10 deletions(-)
16
19
17
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
20
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
18
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/translate-a64.c
22
--- a/hw/arm/virt-acpi-build.c
20
+++ b/target/arm/translate-a64.c
23
+++ b/hw/arm/virt-acpi-build.c
21
@@ -XXX,XX +XXX,XX @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb)
24
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
22
case DISAS_NEXT:
25
AcpiIortItsGroup *its;
23
gen_goto_tb(dc, 1, dc->pc);
26
AcpiIortTable *iort;
24
break;
27
AcpiIortSmmu3 *smmu;
25
- default:
28
- size_t node_size, iort_length, smmu_offset = 0;
26
- case DISAS_UPDATE:
29
+ size_t node_size, iort_node_offset, iort_length, smmu_offset = 0;
27
- gen_a64_set_pc_im(dc->pc);
30
AcpiIortRC *rc;
28
- /* fall through */
31
29
case DISAS_JUMP:
32
iort = acpi_data_push(table_data, sizeof(*iort));
30
tcg_gen_lookup_and_goto_ptr(cpu_pc);
33
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
31
break;
34
32
- case DISAS_EXIT:
35
iort_length = sizeof(*iort);
33
- tcg_gen_exit_tb(0);
36
iort->node_count = cpu_to_le32(nb_nodes);
34
- break;
37
- iort->node_offset = cpu_to_le32(sizeof(*iort));
35
case DISAS_TB_JUMP:
38
+ /*
36
case DISAS_EXC:
39
+ * Use a copy in case table_data->data moves during acpi_data_push
37
case DISAS_SWI:
40
+ * operations.
38
@@ -XXX,XX +XXX,XX @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb)
41
+ */
39
*/
42
+ iort_node_offset = sizeof(*iort);
40
tcg_gen_exit_tb(0);
43
+ iort->node_offset = cpu_to_le32(iort_node_offset);
41
break;
44
42
+ case DISAS_UPDATE:
45
/* ITS group node */
43
+ gen_a64_set_pc_im(dc->pc);
46
node_size = sizeof(*its) + sizeof(uint32_t);
44
+ /* fall through */
47
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
45
+ case DISAS_EXIT:
48
int irq = vms->irqmap[VIRT_SMMU];
46
+ default:
49
47
+ tcg_gen_exit_tb(0);
50
/* SMMUv3 node */
48
+ break;
51
- smmu_offset = iort->node_offset + node_size;
49
}
52
+ smmu_offset = iort_node_offset + node_size;
53
node_size = sizeof(*smmu) + sizeof(*idmap);
54
iort_length += node_size;
55
smmu = acpi_data_push(table_data, node_size);
56
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
57
idmap->id_count = cpu_to_le32(0xFFFF);
58
idmap->output_base = 0;
59
/* output IORT node is the ITS group node (the first node) */
60
- idmap->output_reference = cpu_to_le32(iort->node_offset);
61
+ idmap->output_reference = cpu_to_le32(iort_node_offset);
50
}
62
}
51
63
52
diff --git a/target/arm/translate.c b/target/arm/translate.c
64
/* Root Complex Node */
53
index XXXXXXX..XXXXXXX 100644
65
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
54
--- a/target/arm/translate.c
66
idmap->output_reference = cpu_to_le32(smmu_offset);
55
+++ b/target/arm/translate.c
67
} else {
56
@@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
68
/* output IORT node is the ITS group node (the first node) */
57
case DISAS_NEXT:
69
- idmap->output_reference = cpu_to_le32(iort->node_offset);
58
gen_goto_tb(dc, 1, dc->pc);
70
+ idmap->output_reference = cpu_to_le32(iort_node_offset);
59
break;
71
}
60
- case DISAS_UPDATE:
72
61
- gen_set_pc_im(dc, dc->pc);
73
+ /*
62
- /* fall through */
74
+ * Update the pointer address in case table_data->data moves during above
63
case DISAS_JUMP:
75
+ * acpi_data_push operations.
64
gen_goto_ptr();
76
+ */
65
break;
77
+ iort = (AcpiIortTable *)(table_data->data + iort_start);
66
+ case DISAS_UPDATE:
78
iort->length = cpu_to_le32(iort_length);
67
+ gen_set_pc_im(dc, dc->pc);
79
68
+ /* fall through */
80
build_header(linker, table_data, (void *)(table_data->data + iort_start),
69
default:
70
/* indicate that the hash table must be used to find the next TB */
71
tcg_gen_exit_tb(0);
72
--
81
--
73
2.7.4
82
2.17.1
74
83
75
84
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Shannon Zhao <zhaoshenglong@huawei.com>
2
2
3
While an ISB will ensure any raised IRQs happen on the next
3
kvm_irqchip_create called by kvm_init will call kvm_init_irq_routing to
4
instruction it doesn't cause any to get raised by itself. We can
4
initialize global capability variables. If we call kvm_init_irq_routing in
5
therefore use a simple tb exit for ISB instructions and rely on the
5
GIC realize function, previous allocated memory will leak.
6
exit_request check at the top of each TB to deal with exiting if
7
needed.
8
6
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
Fix this by deleting the unnecessary call.
10
Reviewed-by: Richard Henderson <rth@twiddle.net>
8
11
Message-id: 20170713141928.25419-6-alex.bennee@linaro.org
9
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
10
Reviewed-by: Eric Auger <eric.auger@redhat.com>
11
Message-id: 1527750994-14360-1-git-send-email-zhaoshenglong@huawei.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
13
---
14
target/arm/translate-a64.c | 2 +-
14
hw/intc/arm_gic_kvm.c | 1 -
15
target/arm/translate.c | 4 ++--
15
hw/intc/arm_gicv3_kvm.c | 1 -
16
2 files changed, 3 insertions(+), 3 deletions(-)
16
2 files changed, 2 deletions(-)
17
17
18
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
18
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
19
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate-a64.c
20
--- a/hw/intc/arm_gic_kvm.c
21
+++ b/target/arm/translate-a64.c
21
+++ b/hw/intc/arm_gic_kvm.c
22
@@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn,
22
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
23
* a self-modified code correctly and also to take
23
24
* any pending interrupts immediately.
24
if (kvm_has_gsi_routing()) {
25
*/
25
/* set up irq routing */
26
- s->is_jmp = DISAS_UPDATE;
26
- kvm_init_irq_routing(kvm_state);
27
+ gen_goto_tb(s, 0, s->pc);
27
for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) {
28
return;
28
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
29
default:
29
}
30
unallocated_encoding(s);
30
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
31
diff --git a/target/arm/translate.c b/target/arm/translate.c
32
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/translate.c
32
--- a/hw/intc/arm_gicv3_kvm.c
34
+++ b/target/arm/translate.c
33
+++ b/hw/intc/arm_gicv3_kvm.c
35
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
34
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
36
* self-modifying code correctly and also to take
35
37
* any pending interrupts immediately.
36
if (kvm_has_gsi_routing()) {
38
*/
37
/* set up irq routing */
39
- gen_lookup_tb(s);
38
- kvm_init_irq_routing(kvm_state);
40
+ gen_goto_tb(s, 0, s->pc & ~1);
39
for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) {
41
return;
40
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
42
default:
41
}
43
goto illegal_op;
44
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
45
* and also to take any pending interrupts
46
* immediately.
47
*/
48
- gen_lookup_tb(s);
49
+ gen_goto_tb(s, 0, s->pc & ~1);
50
break;
51
default:
52
goto illegal_op;
53
--
42
--
54
2.7.4
43
2.17.1
55
44
56
45
diff view generated by jsdifflib