1
First pullreq for arm of the 4.1 series, since I'm back from
1
target-arm queue. The big thing here is the landing of the 3-phase
2
holiday now. This is mostly my M-profile FPU series and Philippe's
2
reset patches...
3
devices.h cleanup. I have a pile of other patchsets to work through
4
in my to-review folder, but 42 patches is definitely quite
5
big enough to send now...
6
3
7
thanks
8
-- PMM
4
-- PMM
9
5
10
The following changes since commit 413a99a92c13ec408dcf2adaa87918dc81e890c8:
6
The following changes since commit 204aa60b37c23a89e690d418f49787d274303ca7:
11
7
12
Add Nios II semihosting support. (2019-04-29 16:09:51 +0100)
8
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-jan-29-2020' into staging (2020-01-30 14:18:45 +0000)
13
9
14
are available in the Git repository at:
10
are available in the Git repository at:
15
11
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190429
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200130
17
13
18
for you to fetch changes up to 437cc27ddfded3bbab6afd5ac1761e0e195edba7:
14
for you to fetch changes up to dea101a1ae9968c9fec6ab0291489dad7c49f36f:
19
15
20
hw/devices: Move SMSC 91C111 declaration into a new header (2019-04-29 17:57:21 +0100)
16
target/arm/cpu: Add the kvm-no-adjvtime CPU property (2020-01-30 16:02:06 +0000)
21
17
22
----------------------------------------------------------------
18
----------------------------------------------------------------
23
target-arm queue:
19
target-arm queue:
24
* remove "bag of random stuff" hw/devices.h header
20
* hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
25
* implement FPU for Cortex-M and enable it for Cortex-M4 and -M33
21
* target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr
26
* hw/dma: Compile the bcm2835_dma device as common object
22
* aspeed: some minor bugfixes
27
* configure: Remove --source-path option
23
* aspeed: add eMMC controller model for AST2600 SoC
28
* hw/ssi/xilinx_spips: Avoid variable length array
24
* hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus'
29
* hw/arm/smmuv3: Remove SMMUNotifierNode
25
* New 3-phase reset API for device models
26
* hw/intc/arm_gicv3_kvm: Stop wrongly programming GICR_PENDBASER.PTZ bit
27
* Arm KVM: stop/restart the guest counter when the VM is stopped and started
30
28
31
----------------------------------------------------------------
29
----------------------------------------------------------------
32
Eric Auger (1):
30
Andrew Jeffery (2):
33
hw/arm/smmuv3: Remove SMMUNotifierNode
31
hw/sd: Configure number of slots exposed by the ASPEED SDHCI model
32
hw/arm: ast2600: Wire up the eMMC controller
34
33
35
Peter Maydell (28):
34
Andrew Jones (6):
36
hw/ssi/xilinx_spips: Avoid variable length array
35
target/arm/kvm: trivial: Clean up header documentation
37
configure: Remove --source-path option
36
hw/arm/virt: Add missing 5.0 options call to 4.2 options
38
target/arm: Make sure M-profile FPSCR RES0 bits are not settable
37
target/arm/kvm64: kvm64 cpus have timer registers
39
hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers
38
tests/arm-cpu-features: Check feature default values
40
target/arm: Implement dummy versions of M-profile FP-related registers
39
target/arm/kvm: Implement virtual time adjustment
41
target/arm: Disable most VFP sysregs for M-profile
40
target/arm/cpu: Add the kvm-no-adjvtime CPU property
42
target/arm: Honour M-profile FP enable bits
43
target/arm: Decode FP instructions for M profile
44
target/arm: Clear CONTROL_S.SFPA in SG insn if FPU present
45
target/arm: Handle SFPA and FPCA bits in reads and writes of CONTROL
46
target/arm/helper: don't return early for STKOF faults during stacking
47
target/arm: Handle floating point registers in exception entry
48
target/arm: Implement v7m_update_fpccr()
49
target/arm: Clear CONTROL.SFPA in BXNS and BLXNS
50
target/arm: Clean excReturn bits when tail chaining
51
target/arm: Allow for floating point in callee stack integrity check
52
target/arm: Handle floating point registers in exception return
53
target/arm: Move NS TBFLAG from bit 19 to bit 6
54
target/arm: Overlap VECSTRIDE and XSCALE_CPAR TB flags
55
target/arm: Set FPCCR.S when executing M-profile floating point insns
56
target/arm: Activate M-profile floating point context when FPCCR.ASPEN is set
57
target/arm: New helper function arm_v7m_mmu_idx_all()
58
target/arm: New function armv7m_nvic_set_pending_lazyfp()
59
target/arm: Add lazy-FP-stacking support to v7m_stack_write()
60
target/arm: Implement M-profile lazy FP state preservation
61
target/arm: Implement VLSTM for v7M CPUs with an FPU
62
target/arm: Implement VLLDM for v7M CPUs with an FPU
63
target/arm: Enable FPU for Cortex-M4 and Cortex-M33
64
41
65
Philippe Mathieu-Daudé (13):
42
Cédric Le Goater (2):
66
hw/dma: Compile the bcm2835_dma device as common object
43
ftgmac100: check RX and TX buffer alignment
67
hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded string
44
hw/arm/aspeed: add a 'execute-in-place' property to boot directly from CE0
68
hw/arm/nseries: Use TYPE_TMP105 instead of hardcoded string
69
hw/display/tc6393xb: Remove unused functions
70
hw/devices: Move TC6393XB declarations into a new header
71
hw/devices: Move Blizzard declarations into a new header
72
hw/devices: Move CBus declarations into a new header
73
hw/devices: Move Gamepad declarations into a new header
74
hw/devices: Move TI touchscreen declarations into a new header
75
hw/devices: Move LAN9118 declarations into a new header
76
hw/net/ne2000-isa: Add guards to the header
77
hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded string
78
hw/devices: Move SMSC 91C111 declaration into a new header
79
45
80
configure | 10 +-
46
Damien Hedde (11):
81
hw/dma/Makefile.objs | 2 +-
47
add device_legacy_reset function to prepare for reset api change
82
include/hw/arm/omap.h | 6 +-
48
hw/core/qdev: add trace events to help with resettable transition
83
include/hw/arm/smmu-common.h | 8 +-
49
hw/core: create Resettable QOM interface
84
include/hw/devices.h | 62 ---
50
hw/core: add Resettable support to BusClass and DeviceClass
85
include/hw/display/blizzard.h | 22 ++
51
hw/core/resettable: add support for changing parent
86
include/hw/display/tc6393xb.h | 24 ++
52
hw/core/qdev: handle parent bus change regarding resettable
87
include/hw/input/gamepad.h | 19 +
53
hw/core/qdev: update hotplug reset regarding resettable
88
include/hw/input/tsc2xxx.h | 36 ++
54
hw/core: deprecate old reset functions and introduce new ones
89
include/hw/misc/cbus.h | 32 ++
55
docs/devel/reset.rst: add doc about Resettable interface
90
include/hw/net/lan9118.h | 21 +
56
vl: replace deprecated qbus_reset_all registration
91
include/hw/net/ne2000-isa.h | 6 +
57
hw/s390x/ipl: replace deprecated qdev_reset_all registration
92
include/hw/net/smc91c111.h | 19 +
93
include/qemu/typedefs.h | 1 -
94
target/arm/cpu.h | 95 ++++-
95
target/arm/helper.h | 5 +
96
target/arm/translate.h | 3 +
97
hw/arm/aspeed.c | 13 +-
98
hw/arm/exynos4_boards.c | 3 +-
99
hw/arm/gumstix.c | 2 +-
100
hw/arm/integratorcp.c | 2 +-
101
hw/arm/kzm.c | 2 +-
102
hw/arm/mainstone.c | 2 +-
103
hw/arm/mps2-tz.c | 3 +-
104
hw/arm/mps2.c | 2 +-
105
hw/arm/nseries.c | 7 +-
106
hw/arm/palm.c | 2 +-
107
hw/arm/realview.c | 3 +-
108
hw/arm/smmu-common.c | 6 +-
109
hw/arm/smmuv3.c | 28 +-
110
hw/arm/stellaris.c | 2 +-
111
hw/arm/tosa.c | 2 +-
112
hw/arm/versatilepb.c | 2 +-
113
hw/arm/vexpress.c | 2 +-
114
hw/display/blizzard.c | 2 +-
115
hw/display/tc6393xb.c | 18 +-
116
hw/input/stellaris_input.c | 2 +-
117
hw/input/tsc2005.c | 2 +-
118
hw/input/tsc210x.c | 4 +-
119
hw/intc/armv7m_nvic.c | 261 +++++++++++++
120
hw/misc/cbus.c | 2 +-
121
hw/net/lan9118.c | 3 +-
122
hw/net/smc91c111.c | 2 +-
123
hw/ssi/xilinx_spips.c | 6 +-
124
target/arm/cpu.c | 20 +
125
target/arm/helper.c | 873 +++++++++++++++++++++++++++++++++++++++---
126
target/arm/machine.c | 16 +
127
target/arm/translate.c | 150 +++++++-
128
target/arm/vfp_helper.c | 8 +
129
MAINTAINERS | 7 +
130
50 files changed, 1595 insertions(+), 235 deletions(-)
131
delete mode 100644 include/hw/devices.h
132
create mode 100644 include/hw/display/blizzard.h
133
create mode 100644 include/hw/display/tc6393xb.h
134
create mode 100644 include/hw/input/gamepad.h
135
create mode 100644 include/hw/input/tsc2xxx.h
136
create mode 100644 include/hw/misc/cbus.h
137
create mode 100644 include/hw/net/lan9118.h
138
create mode 100644 include/hw/net/smc91c111.h
139
58
59
Joel Stanley (1):
60
misc/pca9552: Add qom set and get
61
62
Peter Maydell (2):
63
hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
64
target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr
65
66
Philippe Mathieu-Daudé (1):
67
hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus'
68
69
Zenghui Yu (1):
70
hw/intc/arm_gicv3_kvm: Stop wrongly programming GICR_PENDBASER.PTZ bit
71
72
hw/core/Makefile.objs | 1 +
73
tests/Makefile.include | 1 +
74
include/hw/arm/aspeed.h | 2 +
75
include/hw/arm/aspeed_soc.h | 2 +
76
include/hw/arm/virt.h | 1 +
77
include/hw/qdev-core.h | 58 +++++++-
78
include/hw/resettable.h | 247 +++++++++++++++++++++++++++++++++
79
include/hw/sd/aspeed_sdhci.h | 1 +
80
target/arm/cpu.h | 7 +
81
target/arm/kvm_arm.h | 95 ++++++++++---
82
hw/arm/aspeed.c | 72 ++++++++--
83
hw/arm/aspeed_ast2600.c | 31 ++++-
84
hw/arm/aspeed_soc.c | 2 +
85
hw/arm/raspi.c | 2 -
86
hw/arm/virt.c | 9 ++
87
hw/audio/intel-hda.c | 2 +-
88
hw/core/bus.c | 102 ++++++++++++++
89
hw/core/or-irq.c | 2 +-
90
hw/core/qdev.c | 160 ++++++++++++++++++++--
91
hw/core/resettable.c | 301 +++++++++++++++++++++++++++++++++++++++++
92
hw/hyperv/hyperv.c | 2 +-
93
hw/i386/microvm.c | 2 +-
94
hw/i386/pc.c | 2 +-
95
hw/ide/microdrive.c | 8 +-
96
hw/intc/arm_gicv3_kvm.c | 11 +-
97
hw/intc/spapr_xive.c | 2 +-
98
hw/misc/pca9552.c | 90 ++++++++++++
99
hw/net/ftgmac100.c | 13 ++
100
hw/ppc/pnv_psi.c | 4 +-
101
hw/ppc/spapr_pci.c | 2 +-
102
hw/ppc/spapr_vio.c | 2 +-
103
hw/s390x/ipl.c | 10 +-
104
hw/s390x/s390-pci-inst.c | 2 +-
105
hw/scsi/vmw_pvscsi.c | 2 +-
106
hw/sd/aspeed_sdhci.c | 11 +-
107
hw/sd/omap_mmc.c | 2 +-
108
hw/sd/pl181.c | 2 +-
109
target/arm/arm-semi.c | 9 ++
110
target/arm/cpu.c | 2 +
111
target/arm/cpu64.c | 1 +
112
target/arm/kvm.c | 120 ++++++++++++++++
113
target/arm/kvm32.c | 3 +
114
target/arm/kvm64.c | 4 +
115
target/arm/machine.c | 7 +
116
target/arm/monitor.c | 1 +
117
tests/qtest/arm-cpu-features.c | 41 ++++--
118
vl.c | 10 +-
119
docs/arm-cpu-features.rst | 37 ++++-
120
docs/devel/index.rst | 1 +
121
docs/devel/reset.rst | 289 +++++++++++++++++++++++++++++++++++++++
122
hw/core/trace-events | 27 ++++
123
51 files changed, 1727 insertions(+), 90 deletions(-)
124
create mode 100644 include/hw/resettable.h
125
create mode 100644 hw/core/resettable.c
126
create mode 100644 docs/devel/reset.rst
127
diff view generated by jsdifflib
1
Currently the code in v7m_push_stack() which detects a violation
1
The num-lines property of the TYPE_OR_GATE device sets the number
2
of the v8M stack limit simply returns early if it does so. This
2
of input lines it has. An assert() in or_irq_realize() restricts
3
is OK for the current integer-only code, but won't work for the
3
this to the maximum supported by the implementation. However we
4
floating point handling we're about to add. We need to continue
4
got the condition in the assert wrong: it should be using <=,
5
executing the rest of the function so that we check for other
5
because num-lines == MAX_OR_LINES is permitted, and means that
6
exceptions like not having permission to use the FPU and so
6
all entries from 0 to MAX_OR_LINES-1 in the s->levels[] array
7
that we correctly set the FPCCR state if we are doing lazy
7
are used.
8
stacking. Refactor to avoid the early return.
9
8
9
We didn't notice this previously because no user has so far
10
needed that many input lines.
11
12
Reported-by: Guenter Roeck <linux@roeck-us.net>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: 20190416125744.27770-10-peter.maydell@linaro.org
15
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
16
Message-id: 20200120142235.10432-1-peter.maydell@linaro.org
13
---
17
---
14
target/arm/helper.c | 23 ++++++++++++++++++-----
18
hw/core/or-irq.c | 2 +-
15
1 file changed, 18 insertions(+), 5 deletions(-)
19
1 file changed, 1 insertion(+), 1 deletion(-)
16
20
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
diff --git a/hw/core/or-irq.c b/hw/core/or-irq.c
18
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
23
--- a/hw/core/or-irq.c
20
+++ b/target/arm/helper.c
24
+++ b/hw/core/or-irq.c
21
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
25
@@ -XXX,XX +XXX,XX @@ static void or_irq_realize(DeviceState *dev, Error **errp)
22
* should ignore further stack faults trying to process
26
{
23
* that derived exception.)
27
qemu_or_irq *s = OR_IRQ(dev);
24
*/
28
25
- bool stacked_ok;
29
- assert(s->num_lines < MAX_OR_LINES);
26
+ bool stacked_ok = true, limitviol = false;
30
+ assert(s->num_lines <= MAX_OR_LINES);
27
CPUARMState *env = &cpu->env;
31
28
uint32_t xpsr = xpsr_read(env);
32
qdev_init_gpio_in(dev, or_irq_handler, s->num_lines);
29
uint32_t frameptr = env->regs[13];
30
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
31
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
32
env->v7m.secure);
33
env->regs[13] = limit;
34
- return true;
35
+ /*
36
+ * We won't try to perform any further memory accesses but
37
+ * we must continue through the following code to check for
38
+ * permission faults during FPU state preservation, and we
39
+ * must update FPCCR if lazy stacking is enabled.
40
+ */
41
+ limitviol = true;
42
+ stacked_ok = false;
43
}
44
}
45
46
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
47
* (which may be taken in preference to the one we started with
48
* if it has higher priority).
49
*/
50
- stacked_ok =
51
+ stacked_ok = stacked_ok &&
52
v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) &&
53
v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) &&
54
v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) &&
55
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
56
v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
57
v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
58
59
- /* Update SP regardless of whether any of the stack accesses failed. */
60
- env->regs[13] = frameptr;
61
+ /*
62
+ * If we broke a stack limit then SP was already updated earlier;
63
+ * otherwise we update SP regardless of whether any of the stack
64
+ * accesses failed or we took some other kind of fault.
65
+ */
66
+ if (!limitviol) {
67
+ env->regs[13] = frameptr;
68
+ }
69
70
return !stacked_ok;
71
}
33
}
72
--
34
--
73
2.20.1
35
2.20.1
74
36
75
37
diff view generated by jsdifflib
1
Like AArch64, M-profile floating point has no FPEXC enable
1
The guest can use the semihosting API to open a handle
2
bit to gate floating point; so always set the VFPEN TB flag.
2
corresponding to QEMU's own stdin, stdout, or stderr.
3
3
When the guest closes this handle, we should not
4
M-profile also has CPACR and NSACR similar to A-profile;
4
close the underlying host stdin/stdout/stderr
5
they behave slightly differently:
5
the way we would do if the handle corresponded to
6
* the CPACR is banked between Secure and Non-Secure
6
a host fd we'd opened on behalf of the guest in SYS_OPEN.
7
* if the NSACR forces a trap then this is taken to
8
the Secure state, not the Non-Secure state
9
10
Honour the CPACR and NSACR settings. The NSACR handling
11
requires us to borrow the exception.target_el field
12
(usually meaningless for M profile) to distinguish the
13
NOCP UsageFault taken to Secure state from the more
14
usual fault taken to the current security state.
15
7
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
18
Message-id: 20190416125744.27770-6-peter.maydell@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20200124172954.28481-1-peter.maydell@linaro.org
19
---
12
---
20
target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++---
13
target/arm/arm-semi.c | 9 +++++++++
21
target/arm/translate.c | 10 ++++++--
14
1 file changed, 9 insertions(+)
22
2 files changed, 60 insertions(+), 5 deletions(-)
23
15
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
25
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/helper.c
18
--- a/target/arm/arm-semi.c
27
+++ b/target/arm/helper.c
19
+++ b/target/arm/arm-semi.c
28
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
20
@@ -XXX,XX +XXX,XX @@ static uint32_t host_closefn(ARMCPU *cpu, GuestFD *gf)
29
return target_el;
30
}
31
32
+/*
33
+ * Return true if the v7M CPACR permits access to the FPU for the specified
34
+ * security state and privilege level.
35
+ */
36
+static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
37
+{
38
+ switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
39
+ case 0:
40
+ case 2: /* UNPREDICTABLE: we treat like 0 */
41
+ return false;
42
+ case 1:
43
+ return is_priv;
44
+ case 3:
45
+ return true;
46
+ default:
47
+ g_assert_not_reached();
48
+ }
49
+}
50
+
51
static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
52
ARMMMUIdx mmu_idx, bool ignfault)
53
{
21
{
54
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
22
CPUARMState *env = &cpu->env;
55
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
23
56
break;
24
+ /*
57
case EXCP_NOCP:
25
+ * Only close the underlying host fd if it's one we opened on behalf
58
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
26
+ * of the guest in SYS_OPEN.
59
- env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
27
+ */
60
+ {
28
+ if (gf->hostfd == STDIN_FILENO ||
61
+ /*
29
+ gf->hostfd == STDOUT_FILENO ||
62
+ * NOCP might be directed to something other than the current
30
+ gf->hostfd == STDERR_FILENO) {
63
+ * security state if this fault is because of NSACR; we indicate
64
+ * the target security state using exception.target_el.
65
+ */
66
+ int target_secstate;
67
+
68
+ if (env->exception.target_el == 3) {
69
+ target_secstate = M_REG_S;
70
+ } else {
71
+ target_secstate = env->v7m.secure;
72
+ }
73
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, target_secstate);
74
+ env->v7m.cfsr[target_secstate] |= R_V7M_CFSR_NOCP_MASK;
75
break;
76
+ }
77
case EXCP_INVSTATE:
78
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
79
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;
80
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
81
return 0;
82
}
83
84
+ if (arm_feature(env, ARM_FEATURE_M)) {
85
+ /* CPACR can cause a NOCP UsageFault taken to current security state */
86
+ if (!v7m_cpacr_pass(env, env->v7m.secure, cur_el != 0)) {
87
+ return 1;
88
+ }
89
+
90
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) && !env->v7m.secure) {
91
+ if (!extract32(env->v7m.nsacr, 10, 1)) {
92
+ /* FP insns cause a NOCP UsageFault taken to Secure */
93
+ return 3;
94
+ }
95
+ }
96
+
97
+ return 0;
31
+ return 0;
98
+ }
32
+ }
99
+
33
return set_swi_errno(env, close(gf->hostfd));
100
/* The CPACR controls traps to EL1, or PL1 if we're 32 bit:
34
}
101
* 0, 2 : trap EL0 and EL1/PL1 accesses
102
* 1 : trap only EL0 accesses
103
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
104
flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env));
105
flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env));
106
if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30)
107
- || arm_el_is_aa64(env, 1)) {
108
+ || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) {
109
flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1);
110
}
111
flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar);
112
diff --git a/target/arm/translate.c b/target/arm/translate.c
113
index XXXXXXX..XXXXXXX 100644
114
--- a/target/arm/translate.c
115
+++ b/target/arm/translate.c
116
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
117
* for attempts to execute invalid vfp/neon encodings with FP disabled.
118
*/
119
if (s->fp_excp_el) {
120
- gen_exception_insn(s, 4, EXCP_UDEF,
121
- syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
122
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
123
+ gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
124
+ s->fp_excp_el);
125
+ } else {
126
+ gen_exception_insn(s, 4, EXCP_UDEF,
127
+ syn_fp_access_trap(1, 0xe, false),
128
+ s->fp_excp_el);
129
+ }
130
return 0;
131
}
132
35
133
--
36
--
134
2.20.1
37
2.20.1
135
38
136
39
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Andrew Jeffery <andrew@aj.id.au>
2
2
3
No code used the tc6393xb_gpio_in_get() and tc6393xb_gpio_out_set()
3
The AST2600 includes a second cut-down version of the SD/MMC controller
4
functions since their introduction in commit 88d2c950b002. Time to
4
found in the AST2500, named the eMMC controller. It's cut down in the
5
remove them.
5
sense that it only supports one slot rather than two, but it brings the
6
total number of slots supported by the AST2600 to three.
6
7
7
Suggested-by: Markus Armbruster <armbru@redhat.com>
8
The existing code assumed that the SD controller always provided two
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
slots. Rework the SDHCI object to expose the number of slots as a
9
Message-id: 20190412165416.7977-4-philmd@redhat.com
10
property to be set by the SoC configuration.
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
12
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Signed-off-by: Cédric Le Goater <clg@kaod.org>
16
Message-id: 20200114103433.30534-2-clg@kaod.org
17
[PMM: fixed up to use device_class_set_props()]
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
19
---
13
include/hw/devices.h | 3 ---
20
include/hw/sd/aspeed_sdhci.h | 1 +
14
hw/display/tc6393xb.c | 16 ----------------
21
hw/arm/aspeed.c | 2 +-
15
2 files changed, 19 deletions(-)
22
hw/arm/aspeed_ast2600.c | 2 ++
23
hw/arm/aspeed_soc.c | 2 ++
24
hw/sd/aspeed_sdhci.c | 11 +++++++++--
25
5 files changed, 15 insertions(+), 3 deletions(-)
16
26
17
diff --git a/include/hw/devices.h b/include/hw/devices.h
27
diff --git a/include/hw/sd/aspeed_sdhci.h b/include/hw/sd/aspeed_sdhci.h
18
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/devices.h
29
--- a/include/hw/sd/aspeed_sdhci.h
20
+++ b/include/hw/devices.h
30
+++ b/include/hw/sd/aspeed_sdhci.h
21
@@ -XXX,XX +XXX,XX @@ void retu_key_event(void *retu, int state);
31
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSDHCIState {
22
typedef struct TC6393xbState TC6393xbState;
32
SysBusDevice parent;
23
TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
33
24
uint32_t base, qemu_irq irq);
34
SDHCIState slots[ASPEED_SDHCI_NUM_SLOTS];
25
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
35
+ uint8_t num_slots;
26
- qemu_irq handler);
36
27
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s);
37
MemoryRegion iomem;
28
qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
38
qemu_irq irq;
29
39
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
30
#endif
31
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
32
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/display/tc6393xb.c
41
--- a/hw/arm/aspeed.c
34
+++ b/hw/display/tc6393xb.c
42
+++ b/hw/arm/aspeed.c
35
@@ -XXX,XX +XXX,XX @@ struct TC6393xbState {
43
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
36
blanked : 1;
44
amc->i2c_init(bmc);
45
}
46
47
- for (i = 0; i < ARRAY_SIZE(bmc->soc.sdhci.slots); i++) {
48
+ for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
49
SDHCIState *sdhci = &bmc->soc.sdhci.slots[i];
50
DriveInfo *dinfo = drive_get_next(IF_SD);
51
BlockBackend *blk;
52
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/hw/arm/aspeed_ast2600.c
55
+++ b/hw/arm/aspeed_ast2600.c
56
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
57
sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
58
TYPE_ASPEED_SDHCI);
59
60
+ object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
61
+
62
/* Init sd card slot class here so that they're under the correct parent */
63
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
64
sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
65
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/hw/arm/aspeed_soc.c
68
+++ b/hw/arm/aspeed_soc.c
69
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
70
sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
71
TYPE_ASPEED_SDHCI);
72
73
+ object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
74
+
75
/* Init sd card slot class here so that they're under the correct parent */
76
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
77
sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
78
diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/sd/aspeed_sdhci.c
81
+++ b/hw/sd/aspeed_sdhci.c
82
@@ -XXX,XX +XXX,XX @@
83
#include "qapi/error.h"
84
#include "hw/irq.h"
85
#include "migration/vmstate.h"
86
+#include "hw/qdev-properties.h"
87
88
#define ASPEED_SDHCI_INFO 0x00
89
#define ASPEED_SDHCI_INFO_RESET 0x00030000
90
@@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_realize(DeviceState *dev, Error **errp)
91
92
/* Create input irqs for the slots */
93
qdev_init_gpio_in_named_with_opaque(DEVICE(sbd), aspeed_sdhci_set_irq,
94
- sdhci, NULL, ASPEED_SDHCI_NUM_SLOTS);
95
+ sdhci, NULL, sdhci->num_slots);
96
97
sysbus_init_irq(sbd, &sdhci->irq);
98
memory_region_init_io(&sdhci->iomem, OBJECT(sdhci), &aspeed_sdhci_ops,
99
sdhci, TYPE_ASPEED_SDHCI, 0x1000);
100
sysbus_init_mmio(sbd, &sdhci->iomem);
101
102
- for (int i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
103
+ for (int i = 0; i < sdhci->num_slots; ++i) {
104
Object *sdhci_slot = OBJECT(&sdhci->slots[i]);
105
SysBusDevice *sbd_slot = SYS_BUS_DEVICE(&sdhci->slots[i]);
106
107
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_sdhci = {
108
},
37
};
109
};
38
110
39
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s)
111
+static Property aspeed_sdhci_properties[] = {
40
-{
112
+ DEFINE_PROP_UINT8("num-slots", AspeedSDHCIState, num_slots, 0),
41
- return s->gpio_in;
113
+ DEFINE_PROP_END_OF_LIST(),
42
-}
114
+};
43
-
115
+
44
static void tc6393xb_gpio_set(void *opaque, int line, int level)
116
static void aspeed_sdhci_class_init(ObjectClass *classp, void *data)
45
{
117
{
46
// TC6393xbState *s = opaque;
118
DeviceClass *dc = DEVICE_CLASS(classp);
47
@@ -XXX,XX +XXX,XX @@ static void tc6393xb_gpio_set(void *opaque, int line, int level)
119
@@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_class_init(ObjectClass *classp, void *data)
48
// FIXME: how does the chip reflect the GPIO input level change?
120
dc->realize = aspeed_sdhci_realize;
121
dc->reset = aspeed_sdhci_reset;
122
dc->vmsd = &vmstate_aspeed_sdhci;
123
+ device_class_set_props(dc, aspeed_sdhci_properties);
49
}
124
}
50
125
51
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
126
static TypeInfo aspeed_sdhci_info = {
52
- qemu_irq handler)
53
-{
54
- if (line >= TC6393XB_GPIOS) {
55
- fprintf(stderr, "TC6393xb: no GPIO pin %d\n", line);
56
- return;
57
- }
58
-
59
- s->handler[line] = handler;
60
-}
61
-
62
static void tc6393xb_gpio_handler_update(TC6393xbState *s)
63
{
64
uint32_t level, diff;
65
--
127
--
66
2.20.1
128
2.20.1
67
129
68
130
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Andrew Jeffery <andrew@aj.id.au>
2
2
3
The SMMUNotifierNode struct is not necessary and brings extra
3
Initialise another SDHCI model instance for the AST2600's eMMC
4
complexity so let's remove it. We now directly track the SMMUDevices
4
controller and use the SDHCI's num_slots value introduced previously to
5
which have registered IOMMU MR notifiers.
5
determine whether we should create an SD card instance for the new slot.
6
6
7
This is inspired from the same transformation on intel-iommu
7
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
8
done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
("intel-iommu: remove IntelIOMMUNotifierNode")
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
Signed-off-by: Eric Auger <eric.auger@redhat.com>
11
Message-id: 20200114103433.30534-3-clg@kaod.org
12
Reviewed-by: Peter Xu <peterx@redhat.com>
12
[ clg : - removed ternary operator from sdhci_attach_drive()
13
Message-id: 20190409160219.19026-1-eric.auger@redhat.com
13
- renamed SDHCI objects with a '-controller' prefix ]
14
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
---
16
include/hw/arm/smmu-common.h | 8 ++------
17
include/hw/arm/aspeed_soc.h | 2 ++
17
hw/arm/smmu-common.c | 6 +++---
18
hw/arm/aspeed.c | 26 +++++++++++++++++---------
18
hw/arm/smmuv3.c | 28 +++++++---------------------
19
hw/arm/aspeed_ast2600.c | 29 ++++++++++++++++++++++++++---
19
3 files changed, 12 insertions(+), 30 deletions(-)
20
3 files changed, 45 insertions(+), 12 deletions(-)
20
21
21
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
22
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
22
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/smmu-common.h
24
--- a/include/hw/arm/aspeed_soc.h
24
+++ b/include/hw/arm/smmu-common.h
25
+++ b/include/hw/arm/aspeed_soc.h
25
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUDevice {
26
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
26
AddressSpace as;
27
AspeedGPIOState gpio;
27
uint32_t cfg_cache_hits;
28
AspeedGPIOState gpio_1_8v;
28
uint32_t cfg_cache_misses;
29
AspeedSDHCIState sdhci;
29
+ QLIST_ENTRY(SMMUDevice) next;
30
+ AspeedSDHCIState emmc;
30
} SMMUDevice;
31
} AspeedSoCState;
31
32
32
-typedef struct SMMUNotifierNode {
33
#define TYPE_ASPEED_SOC "aspeed-soc"
33
- SMMUDevice *sdev;
34
@@ -XXX,XX +XXX,XX @@ enum {
34
- QLIST_ENTRY(SMMUNotifierNode) next;
35
ASPEED_MII4,
35
-} SMMUNotifierNode;
36
ASPEED_SDRAM,
36
-
37
ASPEED_XDMA,
37
typedef struct SMMUPciBus {
38
+ ASPEED_EMMC,
38
PCIBus *bus;
39
};
39
SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */
40
40
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUState {
41
#endif /* ASPEED_SOC_H */
41
GHashTable *iotlb;
42
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
42
SMMUPciBus *smmu_pcibus_by_bus_num[SMMU_PCI_BUS_MAX];
43
PCIBus *pci_bus;
44
- QLIST_HEAD(, SMMUNotifierNode) notifiers_list;
45
+ QLIST_HEAD(, SMMUDevice) devices_with_notifiers;
46
uint8_t bus_num;
47
PCIBus *primary_bus;
48
} SMMUState;
49
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
50
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/arm/smmu-common.c
44
--- a/hw/arm/aspeed.c
52
+++ b/hw/arm/smmu-common.c
45
+++ b/hw/arm/aspeed.c
53
@@ -XXX,XX +XXX,XX @@ inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr)
46
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
54
/* Unmap all notifiers of all mr's */
55
void smmu_inv_notifiers_all(SMMUState *s)
56
{
57
- SMMUNotifierNode *node;
58
+ SMMUDevice *sdev;
59
60
- QLIST_FOREACH(node, &s->notifiers_list, next) {
61
- smmu_inv_notifiers_mr(&node->sdev->iommu);
62
+ QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
63
+ smmu_inv_notifiers_mr(&sdev->iommu);
64
}
47
}
65
}
48
}
66
49
67
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
50
+static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
51
+{
52
+ DeviceState *card;
53
+
54
+ card = qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
55
+ TYPE_SD_CARD);
56
+ if (dinfo) {
57
+ qdev_prop_set_drive(card, "drive", blk_by_legacy_dinfo(dinfo),
58
+ &error_fatal);
59
+ }
60
+ object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
61
+}
62
+
63
static void aspeed_machine_init(MachineState *machine)
64
{
65
AspeedBoardState *bmc;
66
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
67
}
68
69
for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
70
- SDHCIState *sdhci = &bmc->soc.sdhci.slots[i];
71
- DriveInfo *dinfo = drive_get_next(IF_SD);
72
- BlockBackend *blk;
73
- DeviceState *card;
74
+ sdhci_attach_drive(&bmc->soc.sdhci.slots[i], drive_get_next(IF_SD));
75
+ }
76
77
- blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
78
- card = qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
79
- TYPE_SD_CARD);
80
- qdev_prop_set_drive(card, "drive", blk, &error_fatal);
81
- object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
82
+ if (bmc->soc.emmc.num_slots) {
83
+ sdhci_attach_drive(&bmc->soc.emmc.slots[0], drive_get_next(IF_SD));
84
}
85
86
arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
87
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
68
index XXXXXXX..XXXXXXX 100644
88
index XXXXXXX..XXXXXXX 100644
69
--- a/hw/arm/smmuv3.c
89
--- a/hw/arm/aspeed_ast2600.c
70
+++ b/hw/arm/smmuv3.c
90
+++ b/hw/arm/aspeed_ast2600.c
71
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
91
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
72
/* invalidate an asid/iova tuple in all mr's */
92
[ASPEED_ADC] = 0x1E6E9000,
73
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova)
93
[ASPEED_VIDEO] = 0x1E700000,
74
{
94
[ASPEED_SDHCI] = 0x1E740000,
75
- SMMUNotifierNode *node;
95
+ [ASPEED_EMMC] = 0x1E750000,
76
+ SMMUDevice *sdev;
96
[ASPEED_GPIO] = 0x1E780000,
77
97
[ASPEED_GPIO_1_8V] = 0x1E780800,
78
- QLIST_FOREACH(node, &s->notifiers_list, next) {
98
[ASPEED_RTC] = 0x1E781000,
79
- IOMMUMemoryRegion *mr = &node->sdev->iommu;
99
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
80
+ QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
100
81
+ IOMMUMemoryRegion *mr = &sdev->iommu;
101
#define ASPEED_SOC_AST2600_MAX_IRQ 128
82
IOMMUNotifier *n;
102
83
103
+/* Shared Peripheral Interrupt values below are offset by -32 from datasheet */
84
trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova);
104
static const int aspeed_soc_ast2600_irqmap[] = {
85
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
105
[ASPEED_UART1] = 47,
86
SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu);
106
[ASPEED_UART2] = 48,
87
SMMUv3State *s3 = sdev->smmu;
107
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
88
SMMUState *s = &(s3->smmu_state);
108
[ASPEED_ADC] = 78,
89
- SMMUNotifierNode *node = NULL;
109
[ASPEED_XDMA] = 6,
90
- SMMUNotifierNode *next_node = NULL;
110
[ASPEED_SDHCI] = 43,
91
111
+ [ASPEED_EMMC] = 15,
92
if (new & IOMMU_NOTIFIER_MAP) {
112
[ASPEED_GPIO] = 40,
93
int bus_num = pci_bus_num(sdev->bus);
113
[ASPEED_GPIO_1_8V] = 11,
94
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
114
[ASPEED_RTC] = 13,
95
115
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
96
if (old == IOMMU_NOTIFIER_NONE) {
116
sysbus_init_child_obj(obj, "gpio_1_8v", OBJECT(&s->gpio_1_8v),
97
trace_smmuv3_notify_flag_add(iommu->parent_obj.name);
117
sizeof(s->gpio_1_8v), typename);
98
- node = g_malloc0(sizeof(*node));
118
99
- node->sdev = sdev;
119
- sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
100
- QLIST_INSERT_HEAD(&s->notifiers_list, node, next);
120
- TYPE_ASPEED_SDHCI);
101
- return;
121
+ sysbus_init_child_obj(obj, "sd-controller", OBJECT(&s->sdhci),
102
- }
122
+ sizeof(s->sdhci), TYPE_ASPEED_SDHCI);
103
-
123
104
- /* update notifier node with new flags */
124
object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
105
- QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {
125
106
- if (node->sdev == sdev) {
126
/* Init sd card slot class here so that they're under the correct parent */
107
- if (new == IOMMU_NOTIFIER_NONE) {
127
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
108
- trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
128
- sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
109
- QLIST_REMOVE(node, next);
129
+ sysbus_init_child_obj(obj, "sd-controller.sdhci[*]",
110
- g_free(node);
130
+ OBJECT(&s->sdhci.slots[i]),
111
- }
131
sizeof(s->sdhci.slots[i]), TYPE_SYSBUS_SDHCI);
112
- return;
113
- }
114
+ QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next);
115
+ } else if (new == IOMMU_NOTIFIER_NONE) {
116
+ trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
117
+ QLIST_REMOVE(sdev, next);
118
}
132
}
133
+
134
+ sysbus_init_child_obj(obj, "emmc-controller", OBJECT(&s->emmc),
135
+ sizeof(s->emmc), TYPE_ASPEED_SDHCI);
136
+
137
+ object_property_set_int(OBJECT(&s->emmc), 1, "num-slots", &error_abort);
138
+
139
+ sysbus_init_child_obj(obj, "emmc-controller.sdhci",
140
+ OBJECT(&s->emmc.slots[0]), sizeof(s->emmc.slots[0]),
141
+ TYPE_SYSBUS_SDHCI);
119
}
142
}
120
143
144
/*
145
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
146
sc->memmap[ASPEED_SDHCI]);
147
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0,
148
aspeed_soc_get_irq(s, ASPEED_SDHCI));
149
+
150
+ /* eMMC */
151
+ object_property_set_bool(OBJECT(&s->emmc), true, "realized", &err);
152
+ if (err) {
153
+ error_propagate(errp, err);
154
+ return;
155
+ }
156
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_EMMC]);
157
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0,
158
+ aspeed_soc_get_irq(s, ASPEED_EMMC));
159
}
160
161
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
121
--
162
--
122
2.20.1
163
2.20.1
123
164
124
165
diff view generated by jsdifflib
Deleted patch
1
In the stripe8() function we use a variable length array; however
2
we know that the maximum length required is MAX_NUM_BUSSES. Use
3
a fixed-length array and an assert instead.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
10
Message-id: 20190328152635.2794-1-peter.maydell@linaro.org
11
---
12
hw/ssi/xilinx_spips.c | 6 ++++--
13
1 file changed, 4 insertions(+), 2 deletions(-)
14
15
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/ssi/xilinx_spips.c
18
+++ b/hw/ssi/xilinx_spips.c
19
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d)
20
21
static inline void stripe8(uint8_t *x, int num, bool dir)
22
{
23
- uint8_t r[num];
24
- memset(r, 0, sizeof(uint8_t) * num);
25
+ uint8_t r[MAX_NUM_BUSSES];
26
int idx[2] = {0, 0};
27
int bit[2] = {0, 7};
28
int d = dir;
29
30
+ assert(num <= MAX_NUM_BUSSES);
31
+ memset(r, 0, sizeof(uint8_t) * num);
32
+
33
for (idx[0] = 0; idx[0] < num; ++idx[0]) {
34
for (bit[0] = 7; bit[0] >= 0; bit[0]--) {
35
r[idx[!d]] |= x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0;
36
--
37
2.20.1
38
39
diff view generated by jsdifflib
Deleted patch
1
Normally configure identifies the source path by looking
2
at the location where the configure script itself exists.
3
We also provide a --source-path option which lets the user
4
manually override this.
5
1
6
There isn't really an obvious use case for the --source-path
7
option, and in commit 927128222b0a91f56c13a in 2017 we
8
accidentally added some logic that looks at $source_path
9
before the command line option that overrides it has been
10
processed.
11
12
The fact that nobody complained suggests that there isn't
13
any use of this option and we aren't testing it either;
14
remove it. This allows us to move the "make $source_path
15
absolute" logic up so that there is no window in the script
16
where $source_path is set but not yet absolute.
17
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20
Message-id: 20190318134019.23729-1-peter.maydell@linaro.org
21
---
22
configure | 10 ++--------
23
1 file changed, 2 insertions(+), 8 deletions(-)
24
25
diff --git a/configure b/configure
26
index XXXXXXX..XXXXXXX 100755
27
--- a/configure
28
+++ b/configure
29
@@ -XXX,XX +XXX,XX @@ ld_has() {
30
31
# default parameters
32
source_path=$(dirname "$0")
33
+# make source path absolute
34
+source_path=$(cd "$source_path"; pwd)
35
cpu=""
36
iasl="iasl"
37
interp_prefix="/usr/gnemul/qemu-%M"
38
@@ -XXX,XX +XXX,XX @@ for opt do
39
;;
40
--cxx=*) CXX="$optarg"
41
;;
42
- --source-path=*) source_path="$optarg"
43
- ;;
44
--cpu=*) cpu="$optarg"
45
;;
46
--extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
47
@@ -XXX,XX +XXX,XX @@ if test "$debug_info" = "yes"; then
48
LDFLAGS="-g $LDFLAGS"
49
fi
50
51
-# make source path absolute
52
-source_path=$(cd "$source_path"; pwd)
53
-
54
# running configure in the source tree?
55
# we know that's the case if configure is there.
56
if test -f "./configure"; then
57
@@ -XXX,XX +XXX,XX @@ for opt do
58
;;
59
--interp-prefix=*) interp_prefix="$optarg"
60
;;
61
- --source-path=*)
62
- ;;
63
--cross-prefix=*)
64
;;
65
--cc=*)
66
@@ -XXX,XX +XXX,XX @@ $(echo Available targets: $default_target_list | \
67
--target-list-exclude=LIST exclude a set of targets from the default target-list
68
69
Advanced options (experts only):
70
- --source-path=PATH path of source code [$source_path]
71
--cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
72
--cc=CC use C compiler CC [$cc]
73
--iasl=IASL use ACPI compiler IASL [$iasl]
74
--
75
2.20.1
76
77
diff view generated by jsdifflib
Deleted patch
1
Enforce that for M-profile various FPSCR bits which are RES0 there
2
but have defined meanings on A-profile are never settable. This
3
ensures that M-profile code can't enable the A-profile behaviour
4
(notably vector length/stride handling) by accident.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-2-peter.maydell@linaro.org
9
---
10
target/arm/vfp_helper.c | 8 ++++++++
11
1 file changed, 8 insertions(+)
12
13
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/vfp_helper.c
16
+++ b/target/arm/vfp_helper.c
17
@@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
18
val &= ~FPCR_FZ16;
19
}
20
21
+ if (arm_feature(env, ARM_FEATURE_M)) {
22
+ /*
23
+ * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
24
+ * and also for the trapped-exception-handling bits IxE.
25
+ */
26
+ val &= 0xf7c0009f;
27
+ }
28
+
29
/*
30
* We don't implement trapped exception handling, so the
31
* trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
32
--
33
2.20.1
34
35
diff view generated by jsdifflib
Deleted patch
1
For M-profile the MVFR* ID registers are memory mapped, in the
2
range we implement via the NVIC. Allow them to be read.
3
(If the CPU has no FPU, these registers are defined to be RAZ.)
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190416125744.27770-3-peter.maydell@linaro.org
8
---
9
hw/intc/armv7m_nvic.c | 6 ++++++
10
1 file changed, 6 insertions(+)
11
12
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/intc/armv7m_nvic.c
15
+++ b/hw/intc/armv7m_nvic.c
16
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
17
return 0;
18
}
19
return cpu->env.v7m.sfar;
20
+ case 0xf40: /* MVFR0 */
21
+ return cpu->isar.mvfr0;
22
+ case 0xf44: /* MVFR1 */
23
+ return cpu->isar.mvfr1;
24
+ case 0xf48: /* MVFR2 */
25
+ return cpu->isar.mvfr2;
26
default:
27
bad_offset:
28
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
29
--
30
2.20.1
31
32
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Cédric Le Goater <clg@kaod.org>
2
2
3
This commit finally deletes "hw/devices.h".
3
These buffers should be aligned on 16 bytes.
4
4
5
Reviewed-by: Markus Armbruster <armbru@redhat.com>
5
Ignore invalid RX and TX buffer addresses and log an error. All
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
incoming and outgoing traffic will be dropped because no valid RX or
7
Message-id: 20190412165416.7977-13-philmd@redhat.com
7
TX descriptors will be available.
8
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
Message-id: 20200114103433.30534-4-clg@kaod.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
13
---
10
include/hw/devices.h | 11 -----------
14
hw/net/ftgmac100.c | 13 +++++++++++++
11
include/hw/net/smc91c111.h | 19 +++++++++++++++++++
15
1 file changed, 13 insertions(+)
12
hw/arm/gumstix.c | 2 +-
13
hw/arm/integratorcp.c | 2 +-
14
hw/arm/mainstone.c | 2 +-
15
hw/arm/realview.c | 2 +-
16
hw/arm/versatilepb.c | 2 +-
17
hw/net/smc91c111.c | 2 +-
18
8 files changed, 25 insertions(+), 17 deletions(-)
19
delete mode 100644 include/hw/devices.h
20
create mode 100644 include/hw/net/smc91c111.h
21
16
22
diff --git a/include/hw/devices.h b/include/hw/devices.h
17
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
23
deleted file mode 100644
18
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX
19
--- a/hw/net/ftgmac100.c
25
--- a/include/hw/devices.h
20
+++ b/hw/net/ftgmac100.c
26
+++ /dev/null
21
@@ -XXX,XX +XXX,XX @@ typedef struct {
27
@@ -XXX,XX +XXX,XX @@
22
uint32_t des3;
28
-#ifndef QEMU_DEVICES_H
23
} FTGMAC100Desc;
29
-#define QEMU_DEVICES_H
24
30
-
25
+#define FTGMAC100_DESC_ALIGNMENT 16
31
-/* Devices that have nowhere better to go. */
32
-
33
-#include "hw/hw.h"
34
-
35
-/* smc91c111.c */
36
-void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
37
-
38
-#endif
39
diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h
40
new file mode 100644
41
index XXXXXXX..XXXXXXX
42
--- /dev/null
43
+++ b/include/hw/net/smc91c111.h
44
@@ -XXX,XX +XXX,XX @@
45
+/*
46
+ * SMSC 91C111 Ethernet interface emulation
47
+ *
48
+ * Copyright (c) 2005 CodeSourcery, LLC.
49
+ * Written by Paul Brook
50
+ *
51
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
52
+ * See the COPYING file in the top-level directory.
53
+ */
54
+
26
+
55
+#ifndef HW_NET_SMC91C111_H
27
/*
56
+#define HW_NET_SMC91C111_H
28
* Specific RTL8211E MII Registers
29
*/
30
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_write(void *opaque, hwaddr addr,
31
s->itc = value;
32
break;
33
case FTGMAC100_RXR_BADR: /* Ring buffer address */
34
+ if (!QEMU_IS_ALIGNED(value, FTGMAC100_DESC_ALIGNMENT)) {
35
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad RX buffer alignment 0x%"
36
+ HWADDR_PRIx "\n", __func__, value);
37
+ return;
38
+ }
57
+
39
+
58
+#include "hw/irq.h"
40
s->rx_ring = value;
59
+#include "net/net.h"
41
s->rx_descriptor = s->rx_ring;
60
+
42
break;
61
+void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
43
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_write(void *opaque, hwaddr addr,
62
+
44
break;
63
+#endif
45
64
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
46
case FTGMAC100_NPTXR_BADR: /* Transmit buffer address */
65
index XXXXXXX..XXXXXXX 100644
47
+ if (!QEMU_IS_ALIGNED(value, FTGMAC100_DESC_ALIGNMENT)) {
66
--- a/hw/arm/gumstix.c
48
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad TX buffer alignment 0x%"
67
+++ b/hw/arm/gumstix.c
49
+ HWADDR_PRIx "\n", __func__, value);
68
@@ -XXX,XX +XXX,XX @@
50
+ return;
69
#include "hw/arm/pxa.h"
51
+ }
70
#include "net/net.h"
52
s->tx_ring = value;
71
#include "hw/block/flash.h"
53
s->tx_descriptor = s->tx_ring;
72
-#include "hw/devices.h"
54
break;
73
+#include "hw/net/smc91c111.h"
74
#include "hw/boards.h"
75
#include "exec/address-spaces.h"
76
#include "sysemu/qtest.h"
77
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/arm/integratorcp.c
80
+++ b/hw/arm/integratorcp.c
81
@@ -XXX,XX +XXX,XX @@
82
#include "qemu-common.h"
83
#include "cpu.h"
84
#include "hw/sysbus.h"
85
-#include "hw/devices.h"
86
#include "hw/boards.h"
87
#include "hw/arm/arm.h"
88
#include "hw/misc/arm_integrator_debug.h"
89
+#include "hw/net/smc91c111.h"
90
#include "net/net.h"
91
#include "exec/address-spaces.h"
92
#include "sysemu/sysemu.h"
93
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/hw/arm/mainstone.c
96
+++ b/hw/arm/mainstone.c
97
@@ -XXX,XX +XXX,XX @@
98
#include "hw/arm/pxa.h"
99
#include "hw/arm/arm.h"
100
#include "net/net.h"
101
-#include "hw/devices.h"
102
+#include "hw/net/smc91c111.h"
103
#include "hw/boards.h"
104
#include "hw/block/flash.h"
105
#include "hw/sysbus.h"
106
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/hw/arm/realview.c
109
+++ b/hw/arm/realview.c
110
@@ -XXX,XX +XXX,XX @@
111
#include "hw/sysbus.h"
112
#include "hw/arm/arm.h"
113
#include "hw/arm/primecell.h"
114
-#include "hw/devices.h"
115
#include "hw/net/lan9118.h"
116
+#include "hw/net/smc91c111.h"
117
#include "hw/pci/pci.h"
118
#include "net/net.h"
119
#include "sysemu/sysemu.h"
120
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
121
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/arm/versatilepb.c
123
+++ b/hw/arm/versatilepb.c
124
@@ -XXX,XX +XXX,XX @@
125
#include "cpu.h"
126
#include "hw/sysbus.h"
127
#include "hw/arm/arm.h"
128
-#include "hw/devices.h"
129
+#include "hw/net/smc91c111.h"
130
#include "net/net.h"
131
#include "sysemu/sysemu.h"
132
#include "hw/pci/pci.h"
133
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
134
index XXXXXXX..XXXXXXX 100644
135
--- a/hw/net/smc91c111.c
136
+++ b/hw/net/smc91c111.c
137
@@ -XXX,XX +XXX,XX @@
138
#include "qemu/osdep.h"
139
#include "hw/sysbus.h"
140
#include "net/net.h"
141
-#include "hw/devices.h"
142
+#include "hw/net/smc91c111.h"
143
#include "qemu/log.h"
144
/* For crc32 */
145
#include <zlib.h>
146
--
55
--
147
2.20.1
56
2.20.1
148
57
149
58
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Cédric Le Goater <clg@kaod.org>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
The overhead for the OpenBMC firmware images using the a custom U-Boot
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
4
is around 2 seconds, which is fine, but with a U-Boot from mainline,
5
Reviewed-by: Markus Armbruster <armbru@redhat.com>
5
it takes an extra 50 seconds or so to reach Linux. A quick survey on
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
the number of reads performed on the flash memory region gives the
7
Message-id: 20190412165416.7977-2-philmd@redhat.com
7
following figures :
8
9
OpenBMC U-Boot 922478 (~ 3.5 MBytes)
10
Mainline U-Boot 20569977 (~ 80 MBytes)
11
12
QEMU must be trashing the TCG TBs and reloading text very often. Some
13
addresses are read more than 250.000 times. Until we find a solution
14
to improve boot time, execution from MMIO is not activated by default.
15
16
Setting this option also breaks migration compatibility.
17
18
Signed-off-by: Cédric Le Goater <clg@kaod.org>
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
21
Message-id: 20200114103433.30534-5-clg@kaod.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
23
---
10
hw/arm/aspeed.c | 13 +++++++++----
24
include/hw/arm/aspeed.h | 2 ++
11
1 file changed, 9 insertions(+), 4 deletions(-)
25
hw/arm/aspeed.c | 44 ++++++++++++++++++++++++++++++++++++-----
26
2 files changed, 41 insertions(+), 5 deletions(-)
12
27
28
diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
29
index XXXXXXX..XXXXXXX 100644
30
--- a/include/hw/arm/aspeed.h
31
+++ b/include/hw/arm/aspeed.h
32
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedBoardState AspeedBoardState;
33
34
typedef struct AspeedMachine {
35
MachineState parent_obj;
36
+
37
+ bool mmio_exec;
38
} AspeedMachine;
39
40
#define ASPEED_MACHINE_CLASS(klass) \
13
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
41
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
14
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/aspeed.c
43
--- a/hw/arm/aspeed.c
16
+++ b/hw/arm/aspeed.c
44
+++ b/hw/arm/aspeed.c
17
@@ -XXX,XX +XXX,XX @@
45
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
18
#include "hw/arm/aspeed_soc.h"
46
* SoC and 128MB for the AST2500 SoC, which is twice as big as
19
#include "hw/boards.h"
47
* needed by the flash modules of the Aspeed machines.
20
#include "hw/i2c/smbus_eeprom.h"
48
*/
21
+#include "hw/misc/pca9552.h"
49
- memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
22
+#include "hw/misc/tmp105.h"
50
- fl->size, &error_abort);
23
#include "qemu/log.h"
51
- memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
24
#include "sysemu/block-backend.h"
52
- boot_rom);
25
#include "hw/loader.h"
53
- write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort);
26
@@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
54
+ if (ASPEED_MACHINE(machine)->mmio_exec) {
27
eeprom_buf);
55
+ memory_region_init_alias(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
28
56
+ &fl->mmio, 0, fl->size);
29
/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
57
+ memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
30
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
58
+ boot_rom);
31
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7),
59
+ } else {
32
+ TYPE_TMP105, 0x4d);
60
+ memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
33
61
+ fl->size, &error_abort);
34
/* The AST2500 EVB does not have an RTC. Let's pretend that one is
62
+ memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
35
* plugged on the I2C bus header */
63
+ boot_rom);
64
+ write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort);
65
+ }
66
}
67
68
aspeed_board_binfo.ram_size = ram_size;
36
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
69
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
37
AspeedSoCState *soc = &bmc->soc;
70
/* Bus 11: TODO ucd90160@64 */
38
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
39
40
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
41
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552,
42
+ 0x60);
43
44
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
45
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
46
47
/* The Witherspoon expects a TMP275 but a TMP105 is compatible */
48
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
49
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105,
50
+ 0x4a);
51
52
/* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
53
* good enough */
54
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
55
56
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
57
eeprom_buf);
58
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552",
59
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552,
60
0x60);
61
}
71
}
62
72
73
+static bool aspeed_get_mmio_exec(Object *obj, Error **errp)
74
+{
75
+ return ASPEED_MACHINE(obj)->mmio_exec;
76
+}
77
+
78
+static void aspeed_set_mmio_exec(Object *obj, bool value, Error **errp)
79
+{
80
+ ASPEED_MACHINE(obj)->mmio_exec = value;
81
+}
82
+
83
+static void aspeed_machine_instance_init(Object *obj)
84
+{
85
+ ASPEED_MACHINE(obj)->mmio_exec = false;
86
+}
87
+
88
+static void aspeed_machine_class_props_init(ObjectClass *oc)
89
+{
90
+ object_class_property_add_bool(oc, "execute-in-place",
91
+ aspeed_get_mmio_exec,
92
+ aspeed_set_mmio_exec, &error_abort);
93
+ object_class_property_set_description(oc, "execute-in-place",
94
+ "boot directly from CE0 flash device", &error_abort);
95
+}
96
+
97
static void aspeed_machine_class_init(ObjectClass *oc, void *data)
98
{
99
MachineClass *mc = MACHINE_CLASS(oc);
100
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data)
101
mc->no_floppy = 1;
102
mc->no_cdrom = 1;
103
mc->no_parallel = 1;
104
+
105
+ aspeed_machine_class_props_init(oc);
106
}
107
108
static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
109
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = {
110
.name = TYPE_ASPEED_MACHINE,
111
.parent = TYPE_MACHINE,
112
.instance_size = sizeof(AspeedMachine),
113
+ .instance_init = aspeed_machine_instance_init,
114
.class_size = sizeof(AspeedMachineClass),
115
.class_init = aspeed_machine_class_init,
116
.abstract = true,
63
--
117
--
64
2.20.1
118
2.20.1
65
119
66
120
diff view generated by jsdifflib
1
Implement the VLLDM instruction for v7M for the FPU present cas.
1
From: Joel Stanley <joel@jms.id.au>
2
2
3
Following the pattern of the work recently done with the ASPEED GPIO
4
model, this adds support for inspecting and modifying the PCA9552 LEDs
5
from the monitor.
6
7
(qemu) qom-set /machine/unattached/device[17] led0 on
8
(qemu) qom-set /machine/unattached/device[17] led0 off
9
(qemu) qom-set /machine/unattached/device[17] led0 pwm0
10
(qemu) qom-set /machine/unattached/device[17] led0 pwm1
11
12
Signed-off-by: Joel Stanley <joel@jms.id.au>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
Message-id: 20200114103433.30534-6-clg@kaod.org
15
[clg: - removed the "qom-get" examples from the commit log
16
- merged memory leak fixes from Joel ]
17
Signed-off-by: Cédric Le Goater <clg@kaod.org>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-26-peter.maydell@linaro.org
6
---
20
---
7
target/arm/helper.h | 1 +
21
hw/misc/pca9552.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++
8
target/arm/helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++
22
1 file changed, 90 insertions(+)
9
target/arm/translate.c | 2 +-
10
3 files changed, 56 insertions(+), 1 deletion(-)
11
23
12
diff --git a/target/arm/helper.h b/target/arm/helper.h
24
diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c
13
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.h
26
--- a/hw/misc/pca9552.c
15
+++ b/target/arm/helper.h
27
+++ b/hw/misc/pca9552.c
16
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
28
@@ -XXX,XX +XXX,XX @@
17
DEF_HELPER_1(v7m_preserve_fp_state, void, env)
29
#include "hw/misc/pca9552.h"
18
30
#include "hw/misc/pca9552_regs.h"
19
DEF_HELPER_2(v7m_vlstm, void, env, i32)
31
#include "migration/vmstate.h"
20
+DEF_HELPER_2(v7m_vlldm, void, env, i32)
32
+#include "qapi/error.h"
21
33
+#include "qapi/visitor.h"
22
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
34
23
35
#define PCA9552_LED_ON 0x0
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
36
#define PCA9552_LED_OFF 0x1
25
index XXXXXXX..XXXXXXX 100644
37
#define PCA9552_LED_PWM0 0x2
26
--- a/target/arm/helper.c
38
#define PCA9552_LED_PWM1 0x3
27
+++ b/target/arm/helper.c
39
28
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
40
+static const char *led_state[] = {"on", "off", "pwm0", "pwm1"};
29
g_assert_not_reached();
41
+
42
static uint8_t pca9552_pin_get_config(PCA9552State *s, int pin)
43
{
44
uint8_t reg = PCA9552_LS0 + (pin / 4);
45
@@ -XXX,XX +XXX,XX @@ static int pca9552_event(I2CSlave *i2c, enum i2c_event event)
46
return 0;
30
}
47
}
31
48
32
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
49
+static void pca9552_get_led(Object *obj, Visitor *v, const char *name,
50
+ void *opaque, Error **errp)
33
+{
51
+{
34
+ /* translate.c should never generate calls here in user-only mode */
52
+ PCA9552State *s = PCA9552(obj);
35
+ g_assert_not_reached();
53
+ int led, rc, reg;
54
+ uint8_t state;
55
+
56
+ rc = sscanf(name, "led%2d", &led);
57
+ if (rc != 1) {
58
+ error_setg(errp, "%s: error reading %s", __func__, name);
59
+ return;
60
+ }
61
+ if (led < 0 || led > s->nr_leds) {
62
+ error_setg(errp, "%s invalid led %s", __func__, name);
63
+ return;
64
+ }
65
+ /*
66
+ * Get the LSx register as the qom interface should expose the device
67
+ * state, not the modeled 'input line' behaviour which would come from
68
+ * reading the INPUTx reg
69
+ */
70
+ reg = PCA9552_LS0 + led / 4;
71
+ state = (pca9552_read(s, reg) >> (led % 8)) & 0x3;
72
+ visit_type_str(v, name, (char **)&led_state[state], errp);
36
+}
73
+}
37
+
74
+
38
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
75
+/*
39
{
76
+ * Return an LED selector register value based on an existing one, with
40
/* The TT instructions can be used by unprivileged code, but in
77
+ * the appropriate 2-bit state value set for the given LED number (0-3).
41
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
78
+ */
42
env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
79
+static inline uint8_t pca955x_ledsel(uint8_t oldval, int led_num, int state)
43
}
44
45
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
46
+{
80
+{
47
+ /* fptr is the value of Rn, the frame pointer we load the FP regs from */
81
+ return (oldval & (~(0x3 << (led_num << 1)))) |
48
+ assert(env->v7m.secure);
82
+ ((state & 0x3) << (led_num << 1));
83
+}
49
+
84
+
50
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
85
+static void pca9552_set_led(Object *obj, Visitor *v, const char *name,
86
+ void *opaque, Error **errp)
87
+{
88
+ PCA9552State *s = PCA9552(obj);
89
+ Error *local_err = NULL;
90
+ int led, rc, reg, val;
91
+ uint8_t state;
92
+ char *state_str;
93
+
94
+ visit_type_str(v, name, &state_str, &local_err);
95
+ if (local_err) {
96
+ error_propagate(errp, local_err);
97
+ return;
98
+ }
99
+ rc = sscanf(name, "led%2d", &led);
100
+ if (rc != 1) {
101
+ error_setg(errp, "%s: error reading %s", __func__, name);
102
+ return;
103
+ }
104
+ if (led < 0 || led > s->nr_leds) {
105
+ error_setg(errp, "%s invalid led %s", __func__, name);
51
+ return;
106
+ return;
52
+ }
107
+ }
53
+
108
+
54
+ /* Check access to the coprocessor is permitted */
109
+ for (state = 0; state < ARRAY_SIZE(led_state); state++) {
55
+ if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) {
110
+ if (!strcmp(state_str, led_state[state])) {
56
+ raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC());
111
+ break;
112
+ }
113
+ }
114
+ if (state >= ARRAY_SIZE(led_state)) {
115
+ error_setg(errp, "%s invalid led state %s", __func__, state_str);
116
+ return;
57
+ }
117
+ }
58
+
118
+
59
+ if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) {
119
+ reg = PCA9552_LS0 + led / 4;
60
+ /* State in FP is still valid */
120
+ val = pca9552_read(s, reg);
61
+ env->v7m.fpccr[M_REG_S] &= ~R_V7M_FPCCR_LSPACT_MASK;
121
+ val = pca955x_ledsel(val, led % 4, state);
62
+ } else {
122
+ pca9552_write(s, reg, val);
63
+ bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK;
64
+ int i;
65
+ uint32_t fpscr;
66
+
67
+ if (fptr & 7) {
68
+ raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC());
69
+ }
70
+
71
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
72
+ uint32_t slo, shi;
73
+ uint64_t dn;
74
+ uint32_t faddr = fptr + 4 * i;
75
+
76
+ if (i >= 16) {
77
+ faddr += 8; /* skip the slot for the FPSCR */
78
+ }
79
+
80
+ slo = cpu_ldl_data(env, faddr);
81
+ shi = cpu_ldl_data(env, faddr + 4);
82
+
83
+ dn = (uint64_t) shi << 32 | slo;
84
+ *aa32_vfp_dreg(env, i / 2) = dn;
85
+ }
86
+ fpscr = cpu_ldl_data(env, fptr + 0x40);
87
+ vfp_set_fpscr(env, fpscr);
88
+ }
89
+
90
+ env->v7m.control[M_REG_S] |= R_V7M_CONTROL_FPCA_MASK;
91
+}
123
+}
92
+
124
+
93
static bool v7m_push_stack(ARMCPU *cpu)
125
static const VMStateDescription pca9552_vmstate = {
126
.name = "PCA9552",
127
.version_id = 0,
128
@@ -XXX,XX +XXX,XX @@ static void pca9552_reset(DeviceState *dev)
129
static void pca9552_initfn(Object *obj)
94
{
130
{
95
/* Do the "set up stack frame" part of exception entry,
131
PCA9552State *s = PCA9552(obj);
96
diff --git a/target/arm/translate.c b/target/arm/translate.c
132
+ int led;
97
index XXXXXXX..XXXXXXX 100644
133
98
--- a/target/arm/translate.c
134
/* If support for the other PCA955X devices are implemented, these
99
+++ b/target/arm/translate.c
135
* constant values might be part of class structure describing the
100
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
136
@@ -XXX,XX +XXX,XX @@ static void pca9552_initfn(Object *obj)
101
TCGv_i32 fptr = load_reg(s, rn);
137
*/
102
138
s->max_reg = PCA9552_LS3;
103
if (extract32(insn, 20, 1)) {
139
s->nr_leds = 16;
104
- /* VLLDM */
140
+
105
+ gen_helper_v7m_vlldm(cpu_env, fptr);
141
+ for (led = 0; led < s->nr_leds; led++) {
106
} else {
142
+ char *name;
107
gen_helper_v7m_vlstm(cpu_env, fptr);
143
+
108
}
144
+ name = g_strdup_printf("led%d", led);
145
+ object_property_add(obj, name, "bool", pca9552_get_led, pca9552_set_led,
146
+ NULL, NULL, NULL);
147
+ g_free(name);
148
+ }
149
}
150
151
static void pca9552_class_init(ObjectClass *klass, void *data)
109
--
152
--
110
2.20.1
153
2.20.1
111
154
112
155
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Since we enabled parallel TCG code generation for softmmu (see
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
commit 3468b59 "tcg: enable multiple TCG contexts in softmmu")
5
Message-id: 20190412165416.7977-12-philmd@redhat.com
5
and its subsequent fix (commit 72649619 "add .min_cpus and
6
.default_cpus fields to machine_class"), the raspi machines are
7
restricted to always use their 4 cores:
8
9
See in hw/arm/raspi2 (with BCM283X_NCPUS set to 4):
10
11
222 static void raspi2_machine_init(MachineClass *mc)
12
223 {
13
224 mc->desc = "Raspberry Pi 2";
14
230 mc->max_cpus = BCM283X_NCPUS;
15
231 mc->min_cpus = BCM283X_NCPUS;
16
232 mc->default_cpus = BCM283X_NCPUS;
17
235 };
18
236 DEFINE_MACHINE("raspi2", raspi2_machine_init)
19
20
We can no longer use the -smp option, as we get:
21
22
$ qemu-system-arm -M raspi2 -smp 1
23
qemu-system-arm: Invalid SMP CPUs 1. The min CPUs supported by machine 'raspi2' is 4
24
25
Since we can not set the TYPE_BCM283x SOC "enabled-cpus" with -smp,
26
remove the unuseful code.
27
28
We can achieve the same by using the '-global bcm2836.enabled-cpus=1'
29
option.
30
31
Reported-by: Laurent Bonnans <laurent.bonnans@here.com>
32
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
33
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
34
Message-id: 20200120235159.18510-2-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
36
---
8
include/hw/net/lan9118.h | 2 ++
37
hw/arm/raspi.c | 2 --
9
hw/arm/exynos4_boards.c | 3 ++-
38
1 file changed, 2 deletions(-)
10
hw/arm/mps2-tz.c | 3 ++-
11
hw/net/lan9118.c | 1 -
12
4 files changed, 6 insertions(+), 3 deletions(-)
13
39
14
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
40
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
15
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/net/lan9118.h
42
--- a/hw/arm/raspi.c
17
+++ b/include/hw/net/lan9118.h
43
+++ b/hw/arm/raspi.c
18
@@ -XXX,XX +XXX,XX @@
44
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
19
#include "hw/irq.h"
45
/* Setup the SOC */
20
#include "net/net.h"
46
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
21
47
&error_abort);
22
+#define TYPE_LAN9118 "lan9118"
48
- object_property_set_int(OBJECT(&s->soc), machine->smp.cpus, "enabled-cpus",
23
+
49
- &error_abort);
24
void lan9118_init(NICInfo *, uint32_t, qemu_irq);
50
int board_rev = version == 3 ? 0xa02082 : 0xa21041;
25
51
object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev",
26
#endif
52
&error_abort);
27
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/arm/exynos4_boards.c
30
+++ b/hw/arm/exynos4_boards.c
31
@@ -XXX,XX +XXX,XX @@
32
#include "hw/arm/arm.h"
33
#include "exec/address-spaces.h"
34
#include "hw/arm/exynos4210.h"
35
+#include "hw/net/lan9118.h"
36
#include "hw/boards.h"
37
38
#undef DEBUG
39
@@ -XXX,XX +XXX,XX @@ static void lan9215_init(uint32_t base, qemu_irq irq)
40
/* This should be a 9215 but the 9118 is close enough */
41
if (nd_table[0].used) {
42
qemu_check_nic_model(&nd_table[0], "lan9118");
43
- dev = qdev_create(NULL, "lan9118");
44
+ dev = qdev_create(NULL, TYPE_LAN9118);
45
qdev_set_nic_properties(dev, &nd_table[0]);
46
qdev_prop_set_uint32(dev, "mode_16bit", 1);
47
qdev_init_nofail(dev);
48
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/arm/mps2-tz.c
51
+++ b/hw/arm/mps2-tz.c
52
@@ -XXX,XX +XXX,XX @@
53
#include "hw/arm/armsse.h"
54
#include "hw/dma/pl080.h"
55
#include "hw/ssi/pl022.h"
56
+#include "hw/net/lan9118.h"
57
#include "net/net.h"
58
#include "hw/core/split-irq.h"
59
60
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque,
61
* except that it doesn't support the checksum-offload feature.
62
*/
63
qemu_check_nic_model(nd, "lan9118");
64
- mms->lan9118 = qdev_create(NULL, "lan9118");
65
+ mms->lan9118 = qdev_create(NULL, TYPE_LAN9118);
66
qdev_set_nic_properties(mms->lan9118, nd);
67
qdev_init_nofail(mms->lan9118);
68
69
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/hw/net/lan9118.c
72
+++ b/hw/net/lan9118.c
73
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118_packet = {
74
}
75
};
76
77
-#define TYPE_LAN9118 "lan9118"
78
#define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118)
79
80
typedef struct {
81
--
53
--
82
2.20.1
54
2.20.1
83
55
84
56
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
Provide a temporary device_legacy_reset function doing what
4
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
device_reset does to prepare for the transition with Resettable
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
API.
6
Message-id: 20190412165416.7977-11-philmd@redhat.com
6
7
All occurrence of device_reset in the code tree are also replaced
8
by device_legacy_reset.
9
10
The new resettable API has different prototype and semantics
11
(resetting child buses as well as the specified device). Subsequent
12
commits will make the changeover for each call site individually; once
13
that is complete device_legacy_reset() will be removed.
14
15
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Acked-by: David Gibson <david@gibson.dropbear.id.au>
19
Acked-by: Cornelia Huck <cohuck@redhat.com>
20
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
21
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
Message-id: 20200123132823.1117486-2-damien.hedde@greensocs.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
24
---
9
include/hw/net/ne2000-isa.h | 6 ++++++
25
include/hw/qdev-core.h | 4 ++--
10
1 file changed, 6 insertions(+)
26
hw/audio/intel-hda.c | 2 +-
11
27
hw/core/qdev.c | 6 +++---
12
diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h
28
hw/hyperv/hyperv.c | 2 +-
13
index XXXXXXX..XXXXXXX 100644
29
hw/i386/microvm.c | 2 +-
14
--- a/include/hw/net/ne2000-isa.h
30
hw/i386/pc.c | 2 +-
15
+++ b/include/hw/net/ne2000-isa.h
31
hw/ide/microdrive.c | 8 ++++----
16
@@ -XXX,XX +XXX,XX @@
32
hw/intc/spapr_xive.c | 2 +-
17
* This work is licensed under the terms of the GNU GPL, version 2 or later.
33
hw/ppc/pnv_psi.c | 4 ++--
18
* See the COPYING file in the top-level directory.
34
hw/ppc/spapr_pci.c | 2 +-
35
hw/ppc/spapr_vio.c | 2 +-
36
hw/s390x/s390-pci-inst.c | 2 +-
37
hw/scsi/vmw_pvscsi.c | 2 +-
38
hw/sd/omap_mmc.c | 2 +-
39
hw/sd/pl181.c | 2 +-
40
15 files changed, 22 insertions(+), 22 deletions(-)
41
42
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
43
index XXXXXXX..XXXXXXX 100644
44
--- a/include/hw/qdev-core.h
45
+++ b/include/hw/qdev-core.h
46
@@ -XXX,XX +XXX,XX @@ char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev);
47
void qdev_machine_init(void);
48
49
/**
50
- * @device_reset
51
+ * device_legacy_reset:
52
*
53
* Reset a single device (by calling the reset method).
19
*/
54
*/
20
+
55
-void device_reset(DeviceState *dev);
21
+#ifndef HW_NET_NE2K_ISA_H
56
+void device_legacy_reset(DeviceState *dev);
22
+#define HW_NET_NE2K_ISA_H
57
23
+
58
void device_class_set_props(DeviceClass *dc, Property *props);
24
#include "hw/hw.h"
59
25
#include "hw/qdev.h"
60
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
26
#include "hw/isa/isa.h"
61
index XXXXXXX..XXXXXXX 100644
27
@@ -XXX,XX +XXX,XX @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq,
62
--- a/hw/audio/intel-hda.c
28
}
63
+++ b/hw/audio/intel-hda.c
29
return d;
64
@@ -XXX,XX +XXX,XX @@ static void intel_hda_reset(DeviceState *dev)
30
}
65
QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) {
31
+
66
DeviceState *qdev = kid->child;
32
+#endif
67
cdev = HDA_CODEC_DEVICE(qdev);
68
- device_reset(DEVICE(cdev));
69
+ device_legacy_reset(DEVICE(cdev));
70
d->state_sts |= (1 << cdev->cad);
71
}
72
intel_hda_update_irq(d);
73
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/hw/core/qdev.c
76
+++ b/hw/core/qdev.c
77
@@ -XXX,XX +XXX,XX @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
78
79
static int qdev_reset_one(DeviceState *dev, void *opaque)
80
{
81
- device_reset(dev);
82
+ device_legacy_reset(dev);
83
84
return 0;
85
}
86
@@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp)
87
}
88
}
89
if (dev->hotplugged) {
90
- device_reset(dev);
91
+ device_legacy_reset(dev);
92
}
93
dev->pending_deleted_event = false;
94
95
@@ -XXX,XX +XXX,XX @@ void device_class_set_parent_unrealize(DeviceClass *dc,
96
dc->unrealize = dev_unrealize;
97
}
98
99
-void device_reset(DeviceState *dev)
100
+void device_legacy_reset(DeviceState *dev)
101
{
102
DeviceClass *klass = DEVICE_GET_CLASS(dev);
103
104
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
105
index XXXXXXX..XXXXXXX 100644
106
--- a/hw/hyperv/hyperv.c
107
+++ b/hw/hyperv/hyperv.c
108
@@ -XXX,XX +XXX,XX @@ void hyperv_synic_reset(CPUState *cs)
109
SynICState *synic = get_synic(cs);
110
111
if (synic) {
112
- device_reset(DEVICE(synic));
113
+ device_legacy_reset(DEVICE(synic));
114
}
115
}
116
117
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
118
index XXXXXXX..XXXXXXX 100644
119
--- a/hw/i386/microvm.c
120
+++ b/hw/i386/microvm.c
121
@@ -XXX,XX +XXX,XX @@ static void microvm_machine_reset(MachineState *machine)
122
cpu = X86_CPU(cs);
123
124
if (cpu->apic_state) {
125
- device_reset(cpu->apic_state);
126
+ device_legacy_reset(cpu->apic_state);
127
}
128
}
129
}
130
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
131
index XXXXXXX..XXXXXXX 100644
132
--- a/hw/i386/pc.c
133
+++ b/hw/i386/pc.c
134
@@ -XXX,XX +XXX,XX @@ static void pc_machine_reset(MachineState *machine)
135
cpu = X86_CPU(cs);
136
137
if (cpu->apic_state) {
138
- device_reset(cpu->apic_state);
139
+ device_legacy_reset(cpu->apic_state);
140
}
141
}
142
}
143
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
144
index XXXXXXX..XXXXXXX 100644
145
--- a/hw/ide/microdrive.c
146
+++ b/hw/ide/microdrive.c
147
@@ -XXX,XX +XXX,XX @@ static void md_attr_write(PCMCIACardState *card, uint32_t at, uint8_t value)
148
case 0x00:    /* Configuration Option Register */
149
s->opt = value & 0xcf;
150
if (value & OPT_SRESET) {
151
- device_reset(DEVICE(s));
152
+ device_legacy_reset(DEVICE(s));
153
}
154
md_interrupt_update(s);
155
break;
156
@@ -XXX,XX +XXX,XX @@ static void md_common_write(PCMCIACardState *card, uint32_t at, uint16_t value)
157
case 0xe:    /* Device Control */
158
s->ctrl = value;
159
if (value & CTRL_SRST) {
160
- device_reset(DEVICE(s));
161
+ device_legacy_reset(DEVICE(s));
162
}
163
md_interrupt_update(s);
164
break;
165
@@ -XXX,XX +XXX,XX @@ static int dscm1xxxx_attach(PCMCIACardState *card)
166
md->attr_base = pcc->cis[0x74] | (pcc->cis[0x76] << 8);
167
md->io_base = 0x0;
168
169
- device_reset(DEVICE(md));
170
+ device_legacy_reset(DEVICE(md));
171
md_interrupt_update(md);
172
173
return 0;
174
@@ -XXX,XX +XXX,XX @@ static int dscm1xxxx_detach(PCMCIACardState *card)
175
{
176
MicroDriveState *md = MICRODRIVE(card);
177
178
- device_reset(DEVICE(md));
179
+ device_legacy_reset(DEVICE(md));
180
return 0;
181
}
182
183
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
184
index XXXXXXX..XXXXXXX 100644
185
--- a/hw/intc/spapr_xive.c
186
+++ b/hw/intc/spapr_xive.c
187
@@ -XXX,XX +XXX,XX @@ static target_ulong h_int_reset(PowerPCCPU *cpu,
188
return H_PARAMETER;
189
}
190
191
- device_reset(DEVICE(xive));
192
+ device_legacy_reset(DEVICE(xive));
193
194
if (kvm_irqchip_in_kernel()) {
195
Error *local_err = NULL;
196
diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
197
index XXXXXXX..XXXXXXX 100644
198
--- a/hw/ppc/pnv_psi.c
199
+++ b/hw/ppc/pnv_psi.c
200
@@ -XXX,XX +XXX,XX @@ static void pnv_psi_reset(DeviceState *dev)
201
202
static void pnv_psi_reset_handler(void *dev)
203
{
204
- device_reset(DEVICE(dev));
205
+ device_legacy_reset(DEVICE(dev));
206
}
207
208
static void pnv_psi_realize(DeviceState *dev, Error **errp)
209
@@ -XXX,XX +XXX,XX @@ static void pnv_psi_p9_mmio_write(void *opaque, hwaddr addr,
210
break;
211
case PSIHB9_INTERRUPT_CONTROL:
212
if (val & PSIHB9_IRQ_RESET) {
213
- device_reset(DEVICE(&psi9->source));
214
+ device_legacy_reset(DEVICE(&psi9->source));
215
}
216
psi->regs[reg] = val;
217
break;
218
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
219
index XXXXXXX..XXXXXXX 100644
220
--- a/hw/ppc/spapr_pci.c
221
+++ b/hw/ppc/spapr_pci.c
222
@@ -XXX,XX +XXX,XX @@ static int spapr_phb_children_reset(Object *child, void *opaque)
223
DeviceState *dev = (DeviceState *) object_dynamic_cast(child, TYPE_DEVICE);
224
225
if (dev) {
226
- device_reset(dev);
227
+ device_legacy_reset(dev);
228
}
229
230
return 0;
231
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
232
index XXXXXXX..XXXXXXX 100644
233
--- a/hw/ppc/spapr_vio.c
234
+++ b/hw/ppc/spapr_vio.c
235
@@ -XXX,XX +XXX,XX @@ int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq)
236
static void spapr_vio_quiesce_one(SpaprVioDevice *dev)
237
{
238
if (dev->tcet) {
239
- device_reset(DEVICE(dev->tcet));
240
+ device_legacy_reset(DEVICE(dev->tcet));
241
}
242
free_crq(dev);
243
}
244
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
245
index XXXXXXX..XXXXXXX 100644
246
--- a/hw/s390x/s390-pci-inst.c
247
+++ b/hw/s390x/s390-pci-inst.c
248
@@ -XXX,XX +XXX,XX @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra)
249
stw_p(&ressetpci->hdr.rsp, CLP_RC_SETPCIFN_FHOP);
250
goto out;
251
}
252
- device_reset(DEVICE(pbdev));
253
+ device_legacy_reset(DEVICE(pbdev));
254
pbdev->fh &= ~FH_MASK_ENABLE;
255
pbdev->state = ZPCI_FS_DISABLED;
256
stl_p(&ressetpci->fh, pbdev->fh);
257
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
258
index XXXXXXX..XXXXXXX 100644
259
--- a/hw/scsi/vmw_pvscsi.c
260
+++ b/hw/scsi/vmw_pvscsi.c
261
@@ -XXX,XX +XXX,XX @@ pvscsi_on_cmd_reset_device(PVSCSIState *s)
262
263
if (sdev != NULL) {
264
s->resetting++;
265
- device_reset(&sdev->qdev);
266
+ device_legacy_reset(&sdev->qdev);
267
s->resetting--;
268
return PVSCSI_COMMAND_PROCESSING_SUCCEEDED;
269
}
270
diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c
271
index XXXXXXX..XXXXXXX 100644
272
--- a/hw/sd/omap_mmc.c
273
+++ b/hw/sd/omap_mmc.c
274
@@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host)
275
* into any bus, and we must reset it manually. When omap_mmc is
276
* QOMified this must move into the QOM reset function.
277
*/
278
- device_reset(DEVICE(host->card));
279
+ device_legacy_reset(DEVICE(host->card));
280
}
281
282
static uint64_t omap_mmc_read(void *opaque, hwaddr offset,
283
diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c
284
index XXXXXXX..XXXXXXX 100644
285
--- a/hw/sd/pl181.c
286
+++ b/hw/sd/pl181.c
287
@@ -XXX,XX +XXX,XX @@ static void pl181_reset(DeviceState *d)
288
/* Since we're still using the legacy SD API the card is not plugged
289
* into any bus, and we must reset it manually.
290
*/
291
- device_reset(DEVICE(s->card));
292
+ device_legacy_reset(DEVICE(s->card));
293
}
294
295
static void pl181_init(Object *obj)
33
--
296
--
34
2.20.1
297
2.20.1
35
298
36
299
diff view generated by jsdifflib
1
Implement the code which updates the FPCCR register on an
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
exception entry where we are going to use lazy FP stacking.
3
We have to defer to the NVIC to determine whether the
4
various exceptions are currently ready or not.
5
2
3
Adds trace events to reset procedure and when updating the parent
4
bus of a device.
5
6
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
10
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20200123132823.1117486-3-damien.hedde@greensocs.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20190416125744.27770-12-peter.maydell@linaro.org
8
---
13
---
9
target/arm/cpu.h | 14 +++++++++
14
hw/core/qdev.c | 29 ++++++++++++++++++++++++++---
10
hw/intc/armv7m_nvic.c | 34 ++++++++++++++++++++++
15
hw/core/trace-events | 9 +++++++++
11
target/arm/helper.c | 67 ++++++++++++++++++++++++++++++++++++++++++-
16
2 files changed, 35 insertions(+), 3 deletions(-)
12
3 files changed, 114 insertions(+), 1 deletion(-)
13
17
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
18
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
15
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
20
--- a/hw/core/qdev.c
17
+++ b/target/arm/cpu.h
21
+++ b/hw/core/qdev.c
18
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque);
22
@@ -XXX,XX +XXX,XX @@
19
* (Ignoring -1, this is the same as the RETTOBASE value before completion.)
23
#include "hw/boards.h"
20
*/
24
#include "hw/sysbus.h"
21
int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
25
#include "migration/vmstate.h"
22
+/**
26
+#include "trace.h"
23
+ * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
27
24
+ * @opaque: the NVIC
28
bool qdev_hotplug = false;
25
+ * @irq: the exception number to mark pending
29
static bool qdev_hot_added = false;
26
+ * @secure: false for non-banked exceptions or for the nonsecure
30
@@ -XXX,XX +XXX,XX @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
27
+ * version of a banked exception, true for the secure version of a banked
31
bool replugging = dev->parent_bus != NULL;
28
+ * exception.
32
29
+ *
33
if (replugging) {
30
+ * Return whether an exception is "ready", i.e. whether the exception is
34
- /* Keep a reference to the device while it's not plugged into
31
+ * enabled and is configured at a priority which would allow it to
35
+ trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)),
32
+ * interrupt the current execution priority. This controls whether the
36
+ dev->parent_bus, object_get_typename(OBJECT(dev->parent_bus)),
33
+ * RDY bit for it in the FPCCR is set.
37
+ OBJECT(bus), object_get_typename(OBJECT(bus)));
34
+ */
38
+ /*
35
+bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure);
39
+ * Keep a reference to the device while it's not plugged into
36
/**
40
* any bus, to avoid it potentially evaporating when it is
37
* armv7m_nvic_raw_execution_priority: return the raw execution priority
41
* dereffed in bus_remove_child().
38
* @opaque: the NVIC
42
*/
39
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
43
@@ -XXX,XX +XXX,XX @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
40
index XXXXXXX..XXXXXXX 100644
44
return hotplug_ctrl;
41
--- a/hw/intc/armv7m_nvic.c
42
+++ b/hw/intc/armv7m_nvic.c
43
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
44
return ret;
45
}
45
}
46
46
47
+bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
47
+static int qdev_prereset(DeviceState *dev, void *opaque)
48
+{
48
+{
49
+ /*
49
+ trace_qdev_reset_tree(dev, object_get_typename(OBJECT(dev)));
50
+ * Return whether an exception is "ready", i.e. it is enabled and is
50
+ return 0;
51
+ * configured at a priority which would allow it to interrupt the
52
+ * current execution priority.
53
+ *
54
+ * irq and secure have the same semantics as for armv7m_nvic_set_pending():
55
+ * for non-banked exceptions secure is always false; for banked exceptions
56
+ * it indicates which of the exceptions is required.
57
+ */
58
+ NVICState *s = (NVICState *)opaque;
59
+ bool banked = exc_is_banked(irq);
60
+ VecInfo *vec;
61
+ int running = nvic_exec_prio(s);
62
+
63
+ assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
64
+ assert(!secure || banked);
65
+
66
+ /*
67
+ * HardFault is an odd special case: we always check against -1,
68
+ * even if we're secure and HardFault has priority -3; we never
69
+ * need to check for enabled state.
70
+ */
71
+ if (irq == ARMV7M_EXCP_HARD) {
72
+ return running > -1;
73
+ }
74
+
75
+ vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq];
76
+
77
+ return vec->enabled &&
78
+ exc_group_prio(s, vec->prio, secure) < running;
79
+}
51
+}
80
+
52
+
81
/* callback when external interrupt line is changed */
53
+static int qbus_prereset(BusState *bus, void *opaque)
82
static void set_irq_level(void *opaque, int n, int level)
83
{
84
diff --git a/target/arm/helper.c b/target/arm/helper.c
85
index XXXXXXX..XXXXXXX 100644
86
--- a/target/arm/helper.c
87
+++ b/target/arm/helper.c
88
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
89
env->thumb = addr & 1;
90
}
91
92
+static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
93
+ bool apply_splim)
94
+{
54
+{
95
+ /*
55
+ trace_qbus_reset_tree(bus, object_get_typename(OBJECT(bus)));
96
+ * Like the pseudocode UpdateFPCCR: save state in FPCAR and FPCCR
56
+ return 0;
97
+ * that we will need later in order to do lazy FP reg stacking.
98
+ */
99
+ bool is_secure = env->v7m.secure;
100
+ void *nvic = env->nvic;
101
+ /*
102
+ * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits
103
+ * are banked and we want to update the bit in the bank for the
104
+ * current security state; and in one case we want to specifically
105
+ * update the NS banked version of a bit even if we are secure.
106
+ */
107
+ uint32_t *fpccr_s = &env->v7m.fpccr[M_REG_S];
108
+ uint32_t *fpccr_ns = &env->v7m.fpccr[M_REG_NS];
109
+ uint32_t *fpccr = &env->v7m.fpccr[is_secure];
110
+ bool hfrdy, bfrdy, mmrdy, ns_ufrdy, s_ufrdy, sfrdy, monrdy;
111
+
112
+ env->v7m.fpcar[is_secure] = frameptr & ~0x7;
113
+
114
+ if (apply_splim && arm_feature(env, ARM_FEATURE_V8)) {
115
+ bool splimviol;
116
+ uint32_t splim = v7m_sp_limit(env);
117
+ bool ign = armv7m_nvic_neg_prio_requested(nvic, is_secure) &&
118
+ (env->v7m.ccr[is_secure] & R_V7M_CCR_STKOFHFNMIGN_MASK);
119
+
120
+ splimviol = !ign && frameptr < splim;
121
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, SPLIMVIOL, splimviol);
122
+ }
123
+
124
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, LSPACT, 1);
125
+
126
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, S, is_secure);
127
+
128
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, USER, arm_current_el(env) == 0);
129
+
130
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, THREAD,
131
+ !arm_v7m_is_handler_mode(env));
132
+
133
+ hfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_HARD, false);
134
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, HFRDY, hfrdy);
135
+
136
+ bfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_BUS, false);
137
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, BFRDY, bfrdy);
138
+
139
+ mmrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_MEM, is_secure);
140
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, MMRDY, mmrdy);
141
+
142
+ ns_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, false);
143
+ *fpccr_ns = FIELD_DP32(*fpccr_ns, V7M_FPCCR, UFRDY, ns_ufrdy);
144
+
145
+ monrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_DEBUG, false);
146
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, MONRDY, monrdy);
147
+
148
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
149
+ s_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, true);
150
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, UFRDY, s_ufrdy);
151
+
152
+ sfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_SECURE, false);
153
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, SFRDY, sfrdy);
154
+ }
155
+}
57
+}
156
+
58
+
157
static bool v7m_push_stack(ARMCPU *cpu)
59
static int qdev_reset_one(DeviceState *dev, void *opaque)
158
{
60
{
159
/* Do the "set up stack frame" part of exception entry,
61
device_legacy_reset(dev);
160
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
62
@@ -XXX,XX +XXX,XX @@ static int qdev_reset_one(DeviceState *dev, void *opaque)
161
}
63
static int qbus_reset_one(BusState *bus, void *opaque)
162
} else {
64
{
163
/* Lazy stacking enabled, save necessary info to stack later */
65
BusClass *bc = BUS_GET_CLASS(bus);
164
- /* TODO : equivalent of UpdateFPCCR() pseudocode */
66
+ trace_qbus_reset(bus, object_get_typename(OBJECT(bus)));
165
+ v7m_update_fpccr(env, frameptr + 0x20, true);
67
if (bc->reset) {
166
}
68
bc->reset(bus);
167
}
168
}
69
}
70
@@ -XXX,XX +XXX,XX @@ static int qbus_reset_one(BusState *bus, void *opaque)
71
72
void qdev_reset_all(DeviceState *dev)
73
{
74
- qdev_walk_children(dev, NULL, NULL, qdev_reset_one, qbus_reset_one, NULL);
75
+ trace_qdev_reset_all(dev, object_get_typename(OBJECT(dev)));
76
+ qdev_walk_children(dev, qdev_prereset, qbus_prereset,
77
+ qdev_reset_one, qbus_reset_one, NULL);
78
}
79
80
void qdev_reset_all_fn(void *opaque)
81
@@ -XXX,XX +XXX,XX @@ void qdev_reset_all_fn(void *opaque)
82
83
void qbus_reset_all(BusState *bus)
84
{
85
- qbus_walk_children(bus, NULL, NULL, qdev_reset_one, qbus_reset_one, NULL);
86
+ trace_qbus_reset_all(bus, object_get_typename(OBJECT(bus)));
87
+ qbus_walk_children(bus, qdev_prereset, qbus_prereset,
88
+ qdev_reset_one, qbus_reset_one, NULL);
89
}
90
91
void qbus_reset_all_fn(void *opaque)
92
@@ -XXX,XX +XXX,XX @@ void device_legacy_reset(DeviceState *dev)
93
{
94
DeviceClass *klass = DEVICE_GET_CLASS(dev);
95
96
+ trace_qdev_reset(dev, object_get_typename(OBJECT(dev)));
97
if (klass->reset) {
98
klass->reset(dev);
99
}
100
diff --git a/hw/core/trace-events b/hw/core/trace-events
101
index XXXXXXX..XXXXXXX 100644
102
--- a/hw/core/trace-events
103
+++ b/hw/core/trace-events
104
@@ -XXX,XX +XXX,XX @@
105
# loader.c
106
loader_write_rom(const char *name, uint64_t gpa, uint64_t size, bool isrom) "%s: @0x%"PRIx64" size=0x%"PRIx64" ROM=%d"
107
+
108
+# qdev.c
109
+qdev_reset(void *obj, const char *objtype) "obj=%p(%s)"
110
+qdev_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
111
+qdev_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
112
+qbus_reset(void *obj, const char *objtype) "obj=%p(%s)"
113
+qbus_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
114
+qbus_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
115
+qdev_update_parent_bus(void *obj, const char *objtype, void *oldp, const char *oldptype, void *newp, const char *newptype) "obj=%p(%s) old_parent=%p(%s) new_parent=%p(%s)"
169
--
116
--
170
2.20.1
117
2.20.1
171
118
172
119
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
This commit defines an interface allowing multi-phase reset. This aims
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
to solve a problem of the actual single-phase reset (built in
5
Message-id: 20190412165416.7977-10-philmd@redhat.com
5
DeviceClass and BusClass): reset behavior is dependent on the order
6
in which reset handlers are called. In particular doing external
7
side-effect (like setting an qemu_irq) is problematic because receiving
8
object may not be reset yet.
9
10
The Resettable interface divides the reset in 3 well defined phases.
11
To reset an object tree, all 1st phases are executed then all 2nd then
12
all 3rd. See the comments in include/hw/resettable.h for a more complete
13
description. The interface defines 3 phases to let the future
14
possibility of holding an object into reset for some time.
15
16
The qdev/qbus reset in DeviceClass and BusClass will be modified in
17
following commits to use this interface. A mechanism is provided
18
to allow executing a transitional reset handler in place of the 2nd
19
phase which is executed in children-then-parent order inside a tree.
20
This will allow to transition devices and buses smoothly while
21
keeping the exact current qdev/qbus reset behavior for now.
22
23
Documentation will be added in a following commit.
24
25
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
27
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
28
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
29
Message-id: 20200123132823.1117486-4-damien.hedde@greensocs.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
31
---
8
include/hw/devices.h | 3 ---
32
hw/core/Makefile.objs | 1 +
9
include/hw/net/lan9118.h | 19 +++++++++++++++++++
33
include/hw/resettable.h | 211 +++++++++++++++++++++++++++++++++++
10
hw/arm/kzm.c | 2 +-
34
hw/core/resettable.c | 238 ++++++++++++++++++++++++++++++++++++++++
11
hw/arm/mps2.c | 2 +-
35
hw/core/trace-events | 17 +++
12
hw/arm/realview.c | 1 +
36
4 files changed, 467 insertions(+)
13
hw/arm/vexpress.c | 2 +-
37
create mode 100644 include/hw/resettable.h
14
hw/net/lan9118.c | 2 +-
38
create mode 100644 hw/core/resettable.c
15
7 files changed, 24 insertions(+), 7 deletions(-)
39
16
create mode 100644 include/hw/net/lan9118.h
40
diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
17
18
diff --git a/include/hw/devices.h b/include/hw/devices.h
19
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/devices.h
42
--- a/hw/core/Makefile.objs
21
+++ b/include/hw/devices.h
43
+++ b/hw/core/Makefile.objs
22
@@ -XXX,XX +XXX,XX @@
44
@@ -XXX,XX +XXX,XX @@
23
/* smc91c111.c */
45
common-obj-y += qdev.o qdev-properties.o
24
void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
46
common-obj-y += bus.o
25
47
common-obj-y += cpu.o
26
-/* lan9118.c */
48
+common-obj-y += resettable.o
27
-void lan9118_init(NICInfo *, uint32_t, qemu_irq);
49
common-obj-y += hotplug.o
28
-
50
common-obj-y += vmstate-if.o
29
#endif
51
# irq.o needed for qdev GPIO handling:
30
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
52
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
31
new file mode 100644
53
new file mode 100644
32
index XXXXXXX..XXXXXXX
54
index XXXXXXX..XXXXXXX
33
--- /dev/null
55
--- /dev/null
34
+++ b/include/hw/net/lan9118.h
56
+++ b/include/hw/resettable.h
35
@@ -XXX,XX +XXX,XX @@
57
@@ -XXX,XX +XXX,XX @@
36
+/*
58
+/*
37
+ * SMSC LAN9118 Ethernet interface emulation
59
+ * Resettable interface header.
38
+ *
60
+ *
39
+ * Copyright (c) 2009 CodeSourcery, LLC.
61
+ * Copyright (c) 2019 GreenSocs SAS
40
+ * Written by Paul Brook
62
+ *
63
+ * Authors:
64
+ * Damien Hedde
41
+ *
65
+ *
42
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
66
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
43
+ * See the COPYING file in the top-level directory.
67
+ * See the COPYING file in the top-level directory.
44
+ */
68
+ */
45
+
69
+
46
+#ifndef HW_NET_LAN9118_H
70
+#ifndef HW_RESETTABLE_H
47
+#define HW_NET_LAN9118_H
71
+#define HW_RESETTABLE_H
48
+
72
+
49
+#include "hw/irq.h"
73
+#include "qom/object.h"
50
+#include "net/net.h"
74
+
51
+
75
+#define TYPE_RESETTABLE_INTERFACE "resettable"
52
+void lan9118_init(NICInfo *, uint32_t, qemu_irq);
76
+
77
+#define RESETTABLE_CLASS(class) \
78
+ OBJECT_CLASS_CHECK(ResettableClass, (class), TYPE_RESETTABLE_INTERFACE)
79
+
80
+#define RESETTABLE_GET_CLASS(obj) \
81
+ OBJECT_GET_CLASS(ResettableClass, (obj), TYPE_RESETTABLE_INTERFACE)
82
+
83
+typedef struct ResettableState ResettableState;
84
+
85
+/**
86
+ * ResetType:
87
+ * Types of reset.
88
+ *
89
+ * + Cold: reset resulting from a power cycle of the object.
90
+ *
91
+ * TODO: Support has to be added to handle more types. In particular,
92
+ * ResettableState structure needs to be expanded.
93
+ */
94
+typedef enum ResetType {
95
+ RESET_TYPE_COLD,
96
+} ResetType;
97
+
98
+/*
99
+ * ResettableClass:
100
+ * Interface for resettable objects.
101
+ *
102
+ * See docs/devel/reset.rst for more detailed information about how QEMU models
103
+ * reset. This whole API must only be used when holding the iothread mutex.
104
+ *
105
+ * All objects which can be reset must implement this interface;
106
+ * it is usually provided by a base class such as DeviceClass or BusClass.
107
+ * Every Resettable object must maintain some state tracking the
108
+ * progress of a reset operation by providing a ResettableState structure.
109
+ * The functions defined in this module take care of updating the
110
+ * state of the reset.
111
+ * The base class implementation of the interface provides this
112
+ * state and implements the associated method: get_state.
113
+ *
114
+ * Concrete object implementations (typically specific devices
115
+ * such as a UART model) should provide the functions
116
+ * for the phases.enter, phases.hold and phases.exit methods, which
117
+ * they can set in their class init function, either directly or
118
+ * by calling resettable_class_set_parent_phases().
119
+ * The phase methods are guaranteed to only only ever be called once
120
+ * for any reset event, in the order 'enter', 'hold', 'exit'.
121
+ * An object will always move quickly from 'enter' to 'hold'
122
+ * but might remain in 'hold' for an arbitrary period of time
123
+ * before eventually reset is deasserted and the 'exit' phase is called.
124
+ * Object implementations should be prepared for functions handling
125
+ * inbound connections from other devices (such as qemu_irq handler
126
+ * functions) to be called at any point during reset after their
127
+ * 'enter' method has been called.
128
+ *
129
+ * Users of a resettable object should not call these methods
130
+ * directly, but instead use the function resettable_reset().
131
+ *
132
+ * @phases.enter: This phase is called when the object enters reset. It
133
+ * should reset local state of the object, but it must not do anything that
134
+ * has a side-effect on other objects, such as raising or lowering a qemu_irq
135
+ * line or reading or writing guest memory. It takes the reset's type as
136
+ * argument.
137
+ *
138
+ * @phases.hold: This phase is called for entry into reset, once every object
139
+ * in the system which is being reset has had its @phases.enter method called.
140
+ * At this point devices can do actions that affect other objects.
141
+ *
142
+ * @phases.exit: This phase is called when the object leaves the reset state.
143
+ * Actions affecting other objects are permitted.
144
+ *
145
+ * @get_state: Mandatory method which must return a pointer to a
146
+ * ResettableState.
147
+ *
148
+ * @get_transitional_function: transitional method to handle Resettable objects
149
+ * not yet fully moved to this interface. It will be removed as soon as it is
150
+ * not needed anymore. This method is optional and may return a pointer to a
151
+ * function to be used instead of the phases. If the method exists and returns
152
+ * a non-NULL function pointer then that function is executed as a replacement
153
+ * of the 'hold' phase method taking the object as argument. The two other phase
154
+ * methods are not executed.
155
+ *
156
+ * @child_foreach: Executes a given callback on every Resettable child. Child
157
+ * in this context means a child in the qbus tree, so the children of a qbus
158
+ * are the devices on it, and the children of a device are all the buses it
159
+ * owns. This is not the same as the QOM object hierarchy. The function takes
160
+ * additional opaque and ResetType arguments which must be passed unmodified to
161
+ * the callback.
162
+ */
163
+typedef void (*ResettableEnterPhase)(Object *obj, ResetType type);
164
+typedef void (*ResettableHoldPhase)(Object *obj);
165
+typedef void (*ResettableExitPhase)(Object *obj);
166
+typedef ResettableState * (*ResettableGetState)(Object *obj);
167
+typedef void (*ResettableTrFunction)(Object *obj);
168
+typedef ResettableTrFunction (*ResettableGetTrFunction)(Object *obj);
169
+typedef void (*ResettableChildCallback)(Object *, void *opaque,
170
+ ResetType type);
171
+typedef void (*ResettableChildForeach)(Object *obj,
172
+ ResettableChildCallback cb,
173
+ void *opaque, ResetType type);
174
+typedef struct ResettablePhases {
175
+ ResettableEnterPhase enter;
176
+ ResettableHoldPhase hold;
177
+ ResettableExitPhase exit;
178
+} ResettablePhases;
179
+typedef struct ResettableClass {
180
+ InterfaceClass parent_class;
181
+
182
+ /* Phase methods */
183
+ ResettablePhases phases;
184
+
185
+ /* State access method */
186
+ ResettableGetState get_state;
187
+
188
+ /* Transitional method for legacy reset compatibility */
189
+ ResettableGetTrFunction get_transitional_function;
190
+
191
+ /* Hierarchy handling method */
192
+ ResettableChildForeach child_foreach;
193
+} ResettableClass;
194
+
195
+/**
196
+ * ResettableState:
197
+ * Structure holding reset related state. The fields should not be accessed
198
+ * directly; the definition is here to allow further inclusion into other
199
+ * objects.
200
+ *
201
+ * @count: Number of reset level the object is into. It is incremented when
202
+ * the reset operation starts and decremented when it finishes.
203
+ * @hold_phase_pending: flag which indicates that we need to invoke the 'hold'
204
+ * phase handler for this object.
205
+ * @exit_phase_in_progress: true if we are currently in the exit phase
206
+ */
207
+struct ResettableState {
208
+ unsigned count;
209
+ bool hold_phase_pending;
210
+ bool exit_phase_in_progress;
211
+};
212
+
213
+/**
214
+ * resettable_reset:
215
+ * Trigger a reset on an object @obj of type @type. @obj must implement
216
+ * Resettable interface.
217
+ *
218
+ * Calling this function is equivalent to calling @resettable_assert_reset()
219
+ * then @resettable_release_reset().
220
+ */
221
+void resettable_reset(Object *obj, ResetType type);
222
+
223
+/**
224
+ * resettable_assert_reset:
225
+ * Put an object @obj into reset. @obj must implement Resettable interface.
226
+ *
227
+ * @resettable_release_reset() must eventually be called after this call.
228
+ * There must be one call to @resettable_release_reset() per call of
229
+ * @resettable_assert_reset(), with the same type argument.
230
+ *
231
+ * NOTE: Until support for migration is added, the @resettable_release_reset()
232
+ * must not be delayed. It must occur just after @resettable_assert_reset() so
233
+ * that migration cannot be triggered in between. Prefer using
234
+ * @resettable_reset() for now.
235
+ */
236
+void resettable_assert_reset(Object *obj, ResetType type);
237
+
238
+/**
239
+ * resettable_release_reset:
240
+ * Release the object @obj from reset. @obj must implement Resettable interface.
241
+ *
242
+ * See @resettable_assert_reset() description for details.
243
+ */
244
+void resettable_release_reset(Object *obj, ResetType type);
245
+
246
+/**
247
+ * resettable_is_in_reset:
248
+ * Return true if @obj is under reset.
249
+ *
250
+ * @obj must implement Resettable interface.
251
+ */
252
+bool resettable_is_in_reset(Object *obj);
253
+
254
+/**
255
+ * resettable_class_set_parent_phases:
256
+ *
257
+ * Save @rc current reset phases into @parent_phases and override @rc phases
258
+ * by the given new methods (@enter, @hold and @exit).
259
+ * Each phase is overridden only if the new one is not NULL allowing to
260
+ * override a subset of phases.
261
+ */
262
+void resettable_class_set_parent_phases(ResettableClass *rc,
263
+ ResettableEnterPhase enter,
264
+ ResettableHoldPhase hold,
265
+ ResettableExitPhase exit,
266
+ ResettablePhases *parent_phases);
53
+
267
+
54
+#endif
268
+#endif
55
diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c
269
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
270
new file mode 100644
271
index XXXXXXX..XXXXXXX
272
--- /dev/null
273
+++ b/hw/core/resettable.c
274
@@ -XXX,XX +XXX,XX @@
275
+/*
276
+ * Resettable interface.
277
+ *
278
+ * Copyright (c) 2019 GreenSocs SAS
279
+ *
280
+ * Authors:
281
+ * Damien Hedde
282
+ *
283
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
284
+ * See the COPYING file in the top-level directory.
285
+ */
286
+
287
+#include "qemu/osdep.h"
288
+#include "qemu/module.h"
289
+#include "hw/resettable.h"
290
+#include "trace.h"
291
+
292
+/**
293
+ * resettable_phase_enter/hold/exit:
294
+ * Function executing a phase recursively in a resettable object and its
295
+ * children.
296
+ */
297
+static void resettable_phase_enter(Object *obj, void *opaque, ResetType type);
298
+static void resettable_phase_hold(Object *obj, void *opaque, ResetType type);
299
+static void resettable_phase_exit(Object *obj, void *opaque, ResetType type);
300
+
301
+/**
302
+ * enter_phase_in_progress:
303
+ * True if we are currently in reset enter phase.
304
+ *
305
+ * Note: This flag is only used to guarantee (using asserts) that the reset
306
+ * API is used correctly. We can use a global variable because we rely on the
307
+ * iothread mutex to ensure only one reset operation is in a progress at a
308
+ * given time.
309
+ */
310
+static bool enter_phase_in_progress;
311
+
312
+void resettable_reset(Object *obj, ResetType type)
313
+{
314
+ trace_resettable_reset(obj, type);
315
+ resettable_assert_reset(obj, type);
316
+ resettable_release_reset(obj, type);
317
+}
318
+
319
+void resettable_assert_reset(Object *obj, ResetType type)
320
+{
321
+ /* TODO: change this assert when adding support for other reset types */
322
+ assert(type == RESET_TYPE_COLD);
323
+ trace_resettable_reset_assert_begin(obj, type);
324
+ assert(!enter_phase_in_progress);
325
+
326
+ enter_phase_in_progress = true;
327
+ resettable_phase_enter(obj, NULL, type);
328
+ enter_phase_in_progress = false;
329
+
330
+ resettable_phase_hold(obj, NULL, type);
331
+
332
+ trace_resettable_reset_assert_end(obj);
333
+}
334
+
335
+void resettable_release_reset(Object *obj, ResetType type)
336
+{
337
+ /* TODO: change this assert when adding support for other reset types */
338
+ assert(type == RESET_TYPE_COLD);
339
+ trace_resettable_reset_release_begin(obj, type);
340
+ assert(!enter_phase_in_progress);
341
+
342
+ resettable_phase_exit(obj, NULL, type);
343
+
344
+ trace_resettable_reset_release_end(obj);
345
+}
346
+
347
+bool resettable_is_in_reset(Object *obj)
348
+{
349
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
350
+ ResettableState *s = rc->get_state(obj);
351
+
352
+ return s->count > 0;
353
+}
354
+
355
+/**
356
+ * resettable_child_foreach:
357
+ * helper to avoid checking the existence of the method.
358
+ */
359
+static void resettable_child_foreach(ResettableClass *rc, Object *obj,
360
+ ResettableChildCallback cb,
361
+ void *opaque, ResetType type)
362
+{
363
+ if (rc->child_foreach) {
364
+ rc->child_foreach(obj, cb, opaque, type);
365
+ }
366
+}
367
+
368
+/**
369
+ * resettable_get_tr_func:
370
+ * helper to fetch transitional reset callback if any.
371
+ */
372
+static ResettableTrFunction resettable_get_tr_func(ResettableClass *rc,
373
+ Object *obj)
374
+{
375
+ ResettableTrFunction tr_func = NULL;
376
+ if (rc->get_transitional_function) {
377
+ tr_func = rc->get_transitional_function(obj);
378
+ }
379
+ return tr_func;
380
+}
381
+
382
+static void resettable_phase_enter(Object *obj, void *opaque, ResetType type)
383
+{
384
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
385
+ ResettableState *s = rc->get_state(obj);
386
+ const char *obj_typename = object_get_typename(obj);
387
+ bool action_needed = false;
388
+
389
+ /* exit phase has to finish properly before entering back in reset */
390
+ assert(!s->exit_phase_in_progress);
391
+
392
+ trace_resettable_phase_enter_begin(obj, obj_typename, s->count, type);
393
+
394
+ /* Only take action if we really enter reset for the 1st time. */
395
+ /*
396
+ * TODO: if adding more ResetType support, some additional checks
397
+ * are probably needed here.
398
+ */
399
+ if (s->count++ == 0) {
400
+ action_needed = true;
401
+ }
402
+ /*
403
+ * We limit the count to an arbitrary "big" value. The value is big
404
+ * enough not to be triggered normally.
405
+ * The assert will stop an infinite loop if there is a cycle in the
406
+ * reset tree. The loop goes through resettable_foreach_child below
407
+ * which at some point will call us again.
408
+ */
409
+ assert(s->count <= 50);
410
+
411
+ /*
412
+ * handle the children even if action_needed is at false so that
413
+ * child counts are incremented too
414
+ */
415
+ resettable_child_foreach(rc, obj, resettable_phase_enter, NULL, type);
416
+
417
+ /* execute enter phase for the object if needed */
418
+ if (action_needed) {
419
+ trace_resettable_phase_enter_exec(obj, obj_typename, type,
420
+ !!rc->phases.enter);
421
+ if (rc->phases.enter && !resettable_get_tr_func(rc, obj)) {
422
+ rc->phases.enter(obj, type);
423
+ }
424
+ s->hold_phase_pending = true;
425
+ }
426
+ trace_resettable_phase_enter_end(obj, obj_typename, s->count);
427
+}
428
+
429
+static void resettable_phase_hold(Object *obj, void *opaque, ResetType type)
430
+{
431
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
432
+ ResettableState *s = rc->get_state(obj);
433
+ const char *obj_typename = object_get_typename(obj);
434
+
435
+ /* exit phase has to finish properly before entering back in reset */
436
+ assert(!s->exit_phase_in_progress);
437
+
438
+ trace_resettable_phase_hold_begin(obj, obj_typename, s->count, type);
439
+
440
+ /* handle children first */
441
+ resettable_child_foreach(rc, obj, resettable_phase_hold, NULL, type);
442
+
443
+ /* exec hold phase */
444
+ if (s->hold_phase_pending) {
445
+ s->hold_phase_pending = false;
446
+ ResettableTrFunction tr_func = resettable_get_tr_func(rc, obj);
447
+ trace_resettable_phase_hold_exec(obj, obj_typename, !!rc->phases.hold);
448
+ if (tr_func) {
449
+ trace_resettable_transitional_function(obj, obj_typename);
450
+ tr_func(obj);
451
+ } else if (rc->phases.hold) {
452
+ rc->phases.hold(obj);
453
+ }
454
+ }
455
+ trace_resettable_phase_hold_end(obj, obj_typename, s->count);
456
+}
457
+
458
+static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
459
+{
460
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
461
+ ResettableState *s = rc->get_state(obj);
462
+ const char *obj_typename = object_get_typename(obj);
463
+
464
+ assert(!s->exit_phase_in_progress);
465
+ trace_resettable_phase_exit_begin(obj, obj_typename, s->count, type);
466
+
467
+ /* exit_phase_in_progress ensures this phase is 'atomic' */
468
+ s->exit_phase_in_progress = true;
469
+ resettable_child_foreach(rc, obj, resettable_phase_exit, NULL, type);
470
+
471
+ assert(s->count > 0);
472
+ if (s->count == 1) {
473
+ trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
474
+ if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
475
+ rc->phases.exit(obj);
476
+ }
477
+ s->count = 0;
478
+ }
479
+ s->exit_phase_in_progress = false;
480
+ trace_resettable_phase_exit_end(obj, obj_typename, s->count);
481
+}
482
+
483
+void resettable_class_set_parent_phases(ResettableClass *rc,
484
+ ResettableEnterPhase enter,
485
+ ResettableHoldPhase hold,
486
+ ResettableExitPhase exit,
487
+ ResettablePhases *parent_phases)
488
+{
489
+ *parent_phases = rc->phases;
490
+ if (enter) {
491
+ rc->phases.enter = enter;
492
+ }
493
+ if (hold) {
494
+ rc->phases.hold = hold;
495
+ }
496
+ if (exit) {
497
+ rc->phases.exit = exit;
498
+ }
499
+}
500
+
501
+static const TypeInfo resettable_interface_info = {
502
+ .name = TYPE_RESETTABLE_INTERFACE,
503
+ .parent = TYPE_INTERFACE,
504
+ .class_size = sizeof(ResettableClass),
505
+};
506
+
507
+static void reset_register_types(void)
508
+{
509
+ type_register_static(&resettable_interface_info);
510
+}
511
+
512
+type_init(reset_register_types)
513
diff --git a/hw/core/trace-events b/hw/core/trace-events
56
index XXXXXXX..XXXXXXX 100644
514
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/arm/kzm.c
515
--- a/hw/core/trace-events
58
+++ b/hw/arm/kzm.c
516
+++ b/hw/core/trace-events
59
@@ -XXX,XX +XXX,XX @@
517
@@ -XXX,XX +XXX,XX @@ qbus_reset(void *obj, const char *objtype) "obj=%p(%s)"
60
#include "qemu/error-report.h"
518
qbus_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
61
#include "exec/address-spaces.h"
519
qbus_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
62
#include "net/net.h"
520
qdev_update_parent_bus(void *obj, const char *objtype, void *oldp, const char *oldptype, void *newp, const char *newptype) "obj=%p(%s) old_parent=%p(%s) new_parent=%p(%s)"
63
-#include "hw/devices.h"
521
+
64
+#include "hw/net/lan9118.h"
522
+# resettable.c
65
#include "hw/char/serial.h"
523
+resettable_reset(void *obj, int cold) "obj=%p cold=%d"
66
#include "sysemu/qtest.h"
524
+resettable_reset_assert_begin(void *obj, int cold) "obj=%p cold=%d"
67
525
+resettable_reset_assert_end(void *obj) "obj=%p"
68
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
526
+resettable_reset_release_begin(void *obj, int cold) "obj=%p cold=%d"
69
index XXXXXXX..XXXXXXX 100644
527
+resettable_reset_release_end(void *obj) "obj=%p"
70
--- a/hw/arm/mps2.c
528
+resettable_phase_enter_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
71
+++ b/hw/arm/mps2.c
529
+resettable_phase_enter_exec(void *obj, const char *objtype, int type, int has_method) "obj=%p(%s) type=%d method=%d"
72
@@ -XXX,XX +XXX,XX @@
530
+resettable_phase_enter_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
73
#include "hw/timer/cmsdk-apb-timer.h"
531
+resettable_phase_hold_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
74
#include "hw/timer/cmsdk-apb-dualtimer.h"
532
+resettable_phase_hold_exec(void *obj, const char *objtype, int has_method) "obj=%p(%s) method=%d"
75
#include "hw/misc/mps2-scc.h"
533
+resettable_phase_hold_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
76
-#include "hw/devices.h"
534
+resettable_phase_exit_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
77
+#include "hw/net/lan9118.h"
535
+resettable_phase_exit_exec(void *obj, const char *objtype, int has_method) "obj=%p(%s) method=%d"
78
#include "net/net.h"
536
+resettable_phase_exit_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
79
537
+resettable_transitional_function(void *obj, const char *objtype) "obj=%p(%s)"
80
typedef enum MPS2FPGAType {
81
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/arm/realview.c
84
+++ b/hw/arm/realview.c
85
@@ -XXX,XX +XXX,XX @@
86
#include "hw/arm/arm.h"
87
#include "hw/arm/primecell.h"
88
#include "hw/devices.h"
89
+#include "hw/net/lan9118.h"
90
#include "hw/pci/pci.h"
91
#include "net/net.h"
92
#include "sysemu/sysemu.h"
93
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/hw/arm/vexpress.c
96
+++ b/hw/arm/vexpress.c
97
@@ -XXX,XX +XXX,XX @@
98
#include "hw/sysbus.h"
99
#include "hw/arm/arm.h"
100
#include "hw/arm/primecell.h"
101
-#include "hw/devices.h"
102
+#include "hw/net/lan9118.h"
103
#include "hw/i2c/i2c.h"
104
#include "net/net.h"
105
#include "sysemu/sysemu.h"
106
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/hw/net/lan9118.c
109
+++ b/hw/net/lan9118.c
110
@@ -XXX,XX +XXX,XX @@
111
#include "hw/sysbus.h"
112
#include "net/net.h"
113
#include "net/eth.h"
114
-#include "hw/devices.h"
115
+#include "hw/net/lan9118.h"
116
#include "sysemu/sysemu.h"
117
#include "hw/ptimer.h"
118
#include "qemu/log.h"
119
--
538
--
120
2.20.1
539
2.20.1
121
540
122
541
diff view generated by jsdifflib
1
The M-profile floating point support has three associated config
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
registers: FPCAR, FPCCR and FPDSCR. It also makes the registers
2
3
CPACR and NSACR have behaviour other than reads-as-zero.
3
This commit adds support of Resettable interface to buses and devices:
4
Add support for all of these as simple reads-as-written registers.
4
+ ResettableState structure is added in the Bus/Device state
5
We will hook up actual functionality later.
5
+ Resettable methods are implemented.
6
6
+ device/bus_is_in_reset function defined
7
The main complexity here is handling the FPCCR register, which
7
8
has a mix of banked and unbanked bits.
8
This commit allows to transition the objects to the new
9
9
multi-phase interface without changing the reset behavior at all.
10
Note that we don't share storage with the A-profile
10
Object single reset method can be split into the 3 different phases
11
cpu->cp15.nsacr and cpu->cp15.cpacr_el1, though the behaviour
11
but the 3 phases are still executed in a row for a given object.
12
is quite similar, for two reasons:
12
From the qdev/qbus reset api point of view, nothing is changed.
13
* the M profile CPACR is banked between security states
13
qdev_reset_all() and qbus_reset_all() are not modified as well as
14
* it preserves the invariant that M profile uses no state
14
device_legacy_reset().
15
inside the cp15 substruct
15
16
16
Transition of an object must be done from parent class to child class.
17
Care has been taken to allow the transition of a parent class
18
without requiring the child classes to be transitioned at the same
19
time. Note that SysBus and SysBusDevice class do not need any transition
20
because they do not override the legacy reset method.
21
22
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
23
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
26
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
27
Message-id: 20200123132823.1117486-5-damien.hedde@greensocs.com
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20190416125744.27770-4-peter.maydell@linaro.org
20
---
29
---
21
target/arm/cpu.h | 34 ++++++++++++
30
tests/Makefile.include | 1 +
22
hw/intc/armv7m_nvic.c | 125 ++++++++++++++++++++++++++++++++++++++++++
31
include/hw/qdev-core.h | 27 ++++++++++++
23
target/arm/cpu.c | 5 ++
32
hw/core/bus.c | 97 ++++++++++++++++++++++++++++++++++++++++++
24
target/arm/machine.c | 16 ++++++
33
hw/core/qdev.c | 93 ++++++++++++++++++++++++++++++++++++++++
25
4 files changed, 180 insertions(+)
34
4 files changed, 218 insertions(+)
26
35
27
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
36
diff --git a/tests/Makefile.include b/tests/Makefile.include
28
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu.h
38
--- a/tests/Makefile.include
30
+++ b/target/arm/cpu.h
39
+++ b/tests/Makefile.include
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
40
@@ -XXX,XX +XXX,XX @@ tests/fp/%:
32
uint32_t scr[M_REG_NUM_BANKS];
41
tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
33
uint32_t msplim[M_REG_NUM_BANKS];
42
    hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\
34
uint32_t psplim[M_REG_NUM_BANKS];
43
    hw/core/bus.o \
35
+ uint32_t fpcar[M_REG_NUM_BANKS];
44
+    hw/core/resettable.o \
36
+ uint32_t fpccr[M_REG_NUM_BANKS];
45
    hw/core/irq.o \
37
+ uint32_t fpdscr[M_REG_NUM_BANKS];
46
    hw/core/fw-path-provider.o \
38
+ uint32_t cpacr[M_REG_NUM_BANKS];
47
    hw/core/reset.o \
39
+ uint32_t nsacr;
48
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
40
} v7m;
49
index XXXXXXX..XXXXXXX 100644
41
50
--- a/include/hw/qdev-core.h
42
/* Information associated with an exception about to be taken:
51
+++ b/include/hw/qdev-core.h
43
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_CSSELR, LEVEL, 1, 3)
52
@@ -XXX,XX +XXX,XX @@
53
#include "qemu/bitmap.h"
54
#include "qom/object.h"
55
#include "hw/hotplug.h"
56
+#include "hw/resettable.h"
57
58
enum {
59
DEV_NVECTORS_UNSPECIFIED = -1,
60
@@ -XXX,XX +XXX,XX @@ typedef struct DeviceClass {
61
bool hotpluggable;
62
63
/* callbacks */
64
+ /*
65
+ * Reset method here is deprecated and replaced by methods in the
66
+ * resettable class interface to implement a multi-phase reset.
67
+ * TODO: remove once every reset callback is unused
68
+ */
69
DeviceReset reset;
70
DeviceRealize realize;
71
DeviceUnrealize unrealize;
72
@@ -XXX,XX +XXX,XX @@ struct NamedGPIOList {
73
/**
74
* DeviceState:
75
* @realized: Indicates whether the device has been fully constructed.
76
+ * @reset: ResettableState for the device; handled by Resettable interface.
77
*
78
* This structure should not be accessed directly. We declare it here
79
* so that it can be embedded in individual device state structures.
80
@@ -XXX,XX +XXX,XX @@ struct DeviceState {
81
int num_child_bus;
82
int instance_id_alias;
83
int alias_required_for_version;
84
+ ResettableState reset;
85
};
86
87
struct DeviceListener {
88
@@ -XXX,XX +XXX,XX @@ typedef struct BusChild {
89
/**
90
* BusState:
91
* @hotplug_handler: link to a hotplug handler associated with bus.
92
+ * @reset: ResettableState for the bus; handled by Resettable interface.
44
*/
93
*/
45
FIELD(V7M_CSSELR, INDEX, 0, 4)
94
struct BusState {
46
95
Object obj;
47
+/* v7M FPCCR bits */
96
@@ -XXX,XX +XXX,XX @@ struct BusState {
48
+FIELD(V7M_FPCCR, LSPACT, 0, 1)
97
int num_children;
49
+FIELD(V7M_FPCCR, USER, 1, 1)
98
QTAILQ_HEAD(, BusChild) children;
50
+FIELD(V7M_FPCCR, S, 2, 1)
99
QLIST_ENTRY(BusState) sibling;
51
+FIELD(V7M_FPCCR, THREAD, 3, 1)
100
+ ResettableState reset;
52
+FIELD(V7M_FPCCR, HFRDY, 4, 1)
101
};
53
+FIELD(V7M_FPCCR, MMRDY, 5, 1)
102
54
+FIELD(V7M_FPCCR, BFRDY, 6, 1)
103
/**
55
+FIELD(V7M_FPCCR, SFRDY, 7, 1)
104
@@ -XXX,XX +XXX,XX @@ void qdev_reset_all_fn(void *opaque);
56
+FIELD(V7M_FPCCR, MONRDY, 8, 1)
105
void qbus_reset_all(BusState *bus);
57
+FIELD(V7M_FPCCR, SPLIMVIOL, 9, 1)
106
void qbus_reset_all_fn(void *opaque);
58
+FIELD(V7M_FPCCR, UFRDY, 10, 1)
107
59
+FIELD(V7M_FPCCR, RES0, 11, 15)
108
+/**
60
+FIELD(V7M_FPCCR, TS, 26, 1)
109
+ * device_is_in_reset:
61
+FIELD(V7M_FPCCR, CLRONRETS, 27, 1)
110
+ * Return true if the device @dev is currently being reset.
62
+FIELD(V7M_FPCCR, CLRONRET, 28, 1)
111
+ */
63
+FIELD(V7M_FPCCR, LSPENS, 29, 1)
112
+bool device_is_in_reset(DeviceState *dev);
64
+FIELD(V7M_FPCCR, LSPEN, 30, 1)
113
+
65
+FIELD(V7M_FPCCR, ASPEN, 31, 1)
114
+/**
66
+/* These bits are banked. Others are non-banked and live in the M_REG_S bank */
115
+ * bus_is_in_reset:
67
+#define R_V7M_FPCCR_BANKED_MASK \
116
+ * Return true if the bus @bus is currently being reset.
68
+ (R_V7M_FPCCR_LSPACT_MASK | \
117
+ */
69
+ R_V7M_FPCCR_USER_MASK | \
118
+bool bus_is_in_reset(BusState *bus);
70
+ R_V7M_FPCCR_THREAD_MASK | \
119
+
71
+ R_V7M_FPCCR_MMRDY_MASK | \
120
/* This should go away once we get rid of the NULL bus hack */
72
+ R_V7M_FPCCR_SPLIMVIOL_MASK | \
121
BusState *sysbus_get_default(void);
73
+ R_V7M_FPCCR_UFRDY_MASK | \
122
74
+ R_V7M_FPCCR_ASPEN_MASK)
123
@@ -XXX,XX +XXX,XX @@ void device_legacy_reset(DeviceState *dev);
75
+
124
76
/*
125
void device_class_set_props(DeviceClass *dc, Property *props);
77
* System register ID fields.
126
78
*/
127
+/**
79
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
128
+ * device_class_set_parent_reset:
129
+ * TODO: remove the function when DeviceClass's reset method
130
+ * is not used anymore.
131
+ */
132
void device_class_set_parent_reset(DeviceClass *dc,
133
DeviceReset dev_reset,
134
DeviceReset *parent_reset);
135
diff --git a/hw/core/bus.c b/hw/core/bus.c
80
index XXXXXXX..XXXXXXX 100644
136
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/intc/armv7m_nvic.c
137
--- a/hw/core/bus.c
82
+++ b/hw/intc/armv7m_nvic.c
138
+++ b/hw/core/bus.c
83
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
139
@@ -XXX,XX +XXX,XX @@ int qbus_walk_children(BusState *bus,
84
}
140
return 0;
85
case 0xd84: /* CSSELR */
141
}
86
return cpu->env.v7m.csselr[attrs.secure];
142
87
+ case 0xd88: /* CPACR */
143
+bool bus_is_in_reset(BusState *bus)
88
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
144
+{
89
+ return 0;
145
+ return resettable_is_in_reset(OBJECT(bus));
90
+ }
146
+}
91
+ return cpu->env.v7m.cpacr[attrs.secure];
147
+
92
+ case 0xd8c: /* NSACR */
148
+static ResettableState *bus_get_reset_state(Object *obj)
93
+ if (!attrs.secure || !arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
149
+{
94
+ return 0;
150
+ BusState *bus = BUS(obj);
95
+ }
151
+ return &bus->reset;
96
+ return cpu->env.v7m.nsacr;
152
+}
97
/* TODO: Implement debug registers. */
153
+
98
case 0xd90: /* MPU_TYPE */
154
+static void bus_reset_child_foreach(Object *obj, ResettableChildCallback cb,
99
/* Unified MPU; if the MPU is not present this value is zero */
155
+ void *opaque, ResetType type)
100
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
156
+{
101
return 0;
157
+ BusState *bus = BUS(obj);
102
}
158
+ BusChild *kid;
103
return cpu->env.v7m.sfar;
159
+
104
+ case 0xf34: /* FPCCR */
160
+ QTAILQ_FOREACH(kid, &bus->children, sibling) {
105
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
161
+ cb(OBJECT(kid->child), opaque, type);
106
+ return 0;
162
+ }
107
+ }
163
+}
108
+ if (attrs.secure) {
164
+
109
+ return cpu->env.v7m.fpccr[M_REG_S];
165
static void qbus_realize(BusState *bus, DeviceState *parent, const char *name)
110
+ } else {
166
{
111
+ /*
167
const char *typename = object_get_typename(OBJECT(bus));
112
+ * NS can read LSPEN, CLRONRET and MONRDY. It can read
168
@@ -XXX,XX +XXX,XX @@ static char *default_bus_get_fw_dev_path(DeviceState *dev)
113
+ * BFRDY and HFRDY if AIRCR.BFHFNMINS != 0;
169
return g_strdup(object_get_typename(OBJECT(dev)));
114
+ * other non-banked bits RAZ.
170
}
115
+ * TODO: MONRDY should RAZ/WI if DEMCR.SDME is set.
171
116
+ */
172
+/**
117
+ uint32_t value = cpu->env.v7m.fpccr[M_REG_S];
173
+ * bus_phases_reset:
118
+ uint32_t mask = R_V7M_FPCCR_LSPEN_MASK |
174
+ * Transition reset method for buses to allow moving
119
+ R_V7M_FPCCR_CLRONRET_MASK |
175
+ * smoothly from legacy reset method to multi-phases
120
+ R_V7M_FPCCR_MONRDY_MASK;
176
+ */
121
+
177
+static void bus_phases_reset(BusState *bus)
122
+ if (s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
178
+{
123
+ mask |= R_V7M_FPCCR_BFRDY_MASK | R_V7M_FPCCR_HFRDY_MASK;
179
+ ResettableClass *rc = RESETTABLE_GET_CLASS(bus);
124
+ }
180
+
125
+
181
+ if (rc->phases.enter) {
126
+ value &= mask;
182
+ rc->phases.enter(OBJECT(bus), RESET_TYPE_COLD);
127
+
183
+ }
128
+ value |= cpu->env.v7m.fpccr[M_REG_NS];
184
+ if (rc->phases.hold) {
129
+ return value;
185
+ rc->phases.hold(OBJECT(bus));
130
+ }
186
+ }
131
+ case 0xf38: /* FPCAR */
187
+ if (rc->phases.exit) {
132
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
188
+ rc->phases.exit(OBJECT(bus));
133
+ return 0;
189
+ }
134
+ }
190
+}
135
+ return cpu->env.v7m.fpcar[attrs.secure];
191
+
136
+ case 0xf3c: /* FPDSCR */
192
+static void bus_transitional_reset(Object *obj)
137
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
193
+{
138
+ return 0;
194
+ BusClass *bc = BUS_GET_CLASS(obj);
139
+ }
195
+
140
+ return cpu->env.v7m.fpdscr[attrs.secure];
196
+ /*
141
case 0xf40: /* MVFR0 */
197
+ * This will call either @bus_phases_reset (for multi-phases transitioned
142
return cpu->isar.mvfr0;
198
+ * buses) or a bus's specific method for not-yet transitioned buses.
143
case 0xf44: /* MVFR1 */
199
+ * In both case, it does not reset children.
144
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
200
+ */
145
cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK;
201
+ if (bc->reset) {
146
}
202
+ bc->reset(BUS(obj));
147
break;
203
+ }
148
+ case 0xd88: /* CPACR */
204
+}
149
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
205
+
150
+ /* We implement only the Floating Point extension's CP10/CP11 */
206
+/**
151
+ cpu->env.v7m.cpacr[attrs.secure] = value & (0xf << 20);
207
+ * bus_get_transitional_reset:
152
+ }
208
+ * check if the bus's class is ready for multi-phase
153
+ break;
209
+ */
154
+ case 0xd8c: /* NSACR */
210
+static ResettableTrFunction bus_get_transitional_reset(Object *obj)
155
+ if (attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
211
+{
156
+ /* We implement only the Floating Point extension's CP10/CP11 */
212
+ BusClass *dc = BUS_GET_CLASS(obj);
157
+ cpu->env.v7m.nsacr = value & (3 << 10);
213
+ if (dc->reset != bus_phases_reset) {
158
+ }
214
+ /*
159
+ break;
215
+ * dc->reset has been overridden by a subclass,
160
case 0xd90: /* MPU_TYPE */
216
+ * the bus is not ready for multi phase yet.
161
return; /* RO */
217
+ */
162
case 0xd94: /* MPU_CTRL */
218
+ return bus_transitional_reset;
163
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
219
+ }
164
}
220
+ return NULL;
165
break;
221
+}
166
}
222
+
167
+ case 0xf34: /* FPCCR */
223
static void bus_class_init(ObjectClass *class, void *data)
168
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
224
{
169
+ /* Not all bits here are banked. */
225
BusClass *bc = BUS_CLASS(class);
170
+ uint32_t fpccr_s;
226
+ ResettableClass *rc = RESETTABLE_CLASS(class);
171
+
227
172
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
228
class->unparent = bus_unparent;
173
+ /* Don't allow setting of bits not present in v7M */
229
bc->get_fw_dev_path = default_bus_get_fw_dev_path;
174
+ value &= (R_V7M_FPCCR_LSPACT_MASK |
230
+
175
+ R_V7M_FPCCR_USER_MASK |
231
+ rc->get_state = bus_get_reset_state;
176
+ R_V7M_FPCCR_THREAD_MASK |
232
+ rc->child_foreach = bus_reset_child_foreach;
177
+ R_V7M_FPCCR_HFRDY_MASK |
233
+
178
+ R_V7M_FPCCR_MMRDY_MASK |
234
+ /*
179
+ R_V7M_FPCCR_BFRDY_MASK |
235
+ * @bus_phases_reset is put as the default reset method below, allowing
180
+ R_V7M_FPCCR_MONRDY_MASK |
236
+ * to do the multi-phase transition from base classes to leaf classes. It
181
+ R_V7M_FPCCR_LSPEN_MASK |
237
+ * allows a legacy-reset Bus class to extend a multi-phases-reset
182
+ R_V7M_FPCCR_ASPEN_MASK);
238
+ * Bus class for the following reason:
183
+ }
239
+ * + If a base class B has been moved to multi-phase, then it does not
184
+ value &= ~R_V7M_FPCCR_RES0_MASK;
240
+ * override this default reset method and may have defined phase methods.
185
+
241
+ * + A child class C (extending class B) which uses
186
+ if (!attrs.secure) {
242
+ * bus_class_set_parent_reset() (or similar means) to override the
187
+ /* Some non-banked bits are configurably writable by NS */
243
+ * reset method will still work as expected. @bus_phases_reset function
188
+ fpccr_s = cpu->env.v7m.fpccr[M_REG_S];
244
+ * will be registered as the parent reset method and effectively call
189
+ if (!(fpccr_s & R_V7M_FPCCR_LSPENS_MASK)) {
245
+ * parent reset phases.
190
+ uint32_t lspen = FIELD_EX32(value, V7M_FPCCR, LSPEN);
246
+ */
191
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, LSPEN, lspen);
247
+ bc->reset = bus_phases_reset;
192
+ }
248
+ rc->get_transitional_function = bus_get_transitional_reset;
193
+ if (!(fpccr_s & R_V7M_FPCCR_CLRONRETS_MASK)) {
249
}
194
+ uint32_t cor = FIELD_EX32(value, V7M_FPCCR, CLRONRET);
250
195
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, CLRONRET, cor);
251
static void qbus_finalize(Object *obj)
196
+ }
252
@@ -XXX,XX +XXX,XX @@ static const TypeInfo bus_info = {
197
+ if ((s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
253
.instance_init = qbus_initfn,
198
+ uint32_t hfrdy = FIELD_EX32(value, V7M_FPCCR, HFRDY);
254
.instance_finalize = qbus_finalize,
199
+ uint32_t bfrdy = FIELD_EX32(value, V7M_FPCCR, BFRDY);
255
.class_init = bus_class_init,
200
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, HFRDY, hfrdy);
256
+ .interfaces = (InterfaceInfo[]) {
201
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, BFRDY, bfrdy);
257
+ { TYPE_RESETTABLE_INTERFACE },
202
+ }
258
+ { }
203
+ /* TODO MONRDY should RAZ/WI if DEMCR.SDME is set */
259
+ },
204
+ {
260
};
205
+ uint32_t monrdy = FIELD_EX32(value, V7M_FPCCR, MONRDY);
261
206
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, MONRDY, monrdy);
262
static void bus_register_types(void)
207
+ }
263
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
208
+
209
+ /*
210
+ * All other non-banked bits are RAZ/WI from NS; write
211
+ * just the banked bits to fpccr[M_REG_NS].
212
+ */
213
+ value &= R_V7M_FPCCR_BANKED_MASK;
214
+ cpu->env.v7m.fpccr[M_REG_NS] = value;
215
+ } else {
216
+ fpccr_s = value;
217
+ }
218
+ cpu->env.v7m.fpccr[M_REG_S] = fpccr_s;
219
+ }
220
+ break;
221
+ case 0xf38: /* FPCAR */
222
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
223
+ value &= ~7;
224
+ cpu->env.v7m.fpcar[attrs.secure] = value;
225
+ }
226
+ break;
227
+ case 0xf3c: /* FPDSCR */
228
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
229
+ value &= 0x07c00000;
230
+ cpu->env.v7m.fpdscr[attrs.secure] = value;
231
+ }
232
+ break;
233
case 0xf50: /* ICIALLU */
234
case 0xf58: /* ICIMVAU */
235
case 0xf5c: /* DCIMVAC */
236
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
237
index XXXXXXX..XXXXXXX 100644
264
index XXXXXXX..XXXXXXX 100644
238
--- a/target/arm/cpu.c
265
--- a/hw/core/qdev.c
239
+++ b/target/arm/cpu.c
266
+++ b/hw/core/qdev.c
240
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s)
267
@@ -XXX,XX +XXX,XX @@ void qbus_reset_all_fn(void *opaque)
241
env->v7m.ccr[M_REG_S] |= R_V7M_CCR_UNALIGN_TRP_MASK;
268
qbus_reset_all(bus);
242
}
269
}
243
270
244
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
271
+bool device_is_in_reset(DeviceState *dev)
245
+ env->v7m.fpccr[M_REG_NS] = R_V7M_FPCCR_ASPEN_MASK;
272
+{
246
+ env->v7m.fpccr[M_REG_S] = R_V7M_FPCCR_ASPEN_MASK |
273
+ return resettable_is_in_reset(OBJECT(dev));
247
+ R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK;
274
+}
248
+ }
275
+
249
/* Unlike A/R profile, M profile defines the reset LR value */
276
+static ResettableState *device_get_reset_state(Object *obj)
250
env->regs[14] = 0xffffffff;
277
+{
251
278
+ DeviceState *dev = DEVICE(obj);
252
diff --git a/target/arm/machine.c b/target/arm/machine.c
279
+ return &dev->reset;
253
index XXXXXXX..XXXXXXX 100644
280
+}
254
--- a/target/arm/machine.c
281
+
255
+++ b/target/arm/machine.c
282
+static void device_reset_child_foreach(Object *obj, ResettableChildCallback cb,
256
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_v8m = {
283
+ void *opaque, ResetType type)
257
}
284
+{
258
};
285
+ DeviceState *dev = DEVICE(obj);
259
286
+ BusState *bus;
260
+static const VMStateDescription vmstate_m_fp = {
287
+
261
+ .name = "cpu/m/fp",
288
+ QLIST_FOREACH(bus, &dev->child_bus, sibling) {
262
+ .version_id = 1,
289
+ cb(OBJECT(bus), opaque, type);
263
+ .minimum_version_id = 1,
290
+ }
264
+ .needed = vfp_needed,
291
+}
265
+ .fields = (VMStateField[]) {
292
+
266
+ VMSTATE_UINT32_ARRAY(env.v7m.fpcar, ARMCPU, M_REG_NUM_BANKS),
293
/* can be used as ->unplug() callback for the simple cases */
267
+ VMSTATE_UINT32_ARRAY(env.v7m.fpccr, ARMCPU, M_REG_NUM_BANKS),
294
void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
268
+ VMSTATE_UINT32_ARRAY(env.v7m.fpdscr, ARMCPU, M_REG_NUM_BANKS),
295
DeviceState *dev, Error **errp)
269
+ VMSTATE_UINT32_ARRAY(env.v7m.cpacr, ARMCPU, M_REG_NUM_BANKS),
296
@@ -XXX,XX +XXX,XX @@ device_vmstate_if_get_id(VMStateIf *obj)
270
+ VMSTATE_UINT32(env.v7m.nsacr, ARMCPU),
297
return qdev_get_dev_path(dev);
271
+ VMSTATE_END_OF_LIST()
298
}
272
+ }
299
273
+};
300
+/**
274
+
301
+ * device_phases_reset:
275
static const VMStateDescription vmstate_m = {
302
+ * Transition reset method for devices to allow moving
276
.name = "cpu/m",
303
+ * smoothly from legacy reset method to multi-phases
277
.version_id = 4,
304
+ */
278
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
305
+static void device_phases_reset(DeviceState *dev)
279
&vmstate_m_scr,
306
+{
280
&vmstate_m_other_sp,
307
+ ResettableClass *rc = RESETTABLE_GET_CLASS(dev);
281
&vmstate_m_v8m,
308
+
282
+ &vmstate_m_fp,
309
+ if (rc->phases.enter) {
283
NULL
310
+ rc->phases.enter(OBJECT(dev), RESET_TYPE_COLD);
311
+ }
312
+ if (rc->phases.hold) {
313
+ rc->phases.hold(OBJECT(dev));
314
+ }
315
+ if (rc->phases.exit) {
316
+ rc->phases.exit(OBJECT(dev));
317
+ }
318
+}
319
+
320
+static void device_transitional_reset(Object *obj)
321
+{
322
+ DeviceClass *dc = DEVICE_GET_CLASS(obj);
323
+
324
+ /*
325
+ * This will call either @device_phases_reset (for multi-phases transitioned
326
+ * devices) or a device's specific method for not-yet transitioned devices.
327
+ * In both case, it does not reset children.
328
+ */
329
+ if (dc->reset) {
330
+ dc->reset(DEVICE(obj));
331
+ }
332
+}
333
+
334
+/**
335
+ * device_get_transitional_reset:
336
+ * check if the device's class is ready for multi-phase
337
+ */
338
+static ResettableTrFunction device_get_transitional_reset(Object *obj)
339
+{
340
+ DeviceClass *dc = DEVICE_GET_CLASS(obj);
341
+ if (dc->reset != device_phases_reset) {
342
+ /*
343
+ * dc->reset has been overridden by a subclass,
344
+ * the device is not ready for multi phase yet.
345
+ */
346
+ return device_transitional_reset;
347
+ }
348
+ return NULL;
349
+}
350
+
351
static void device_class_init(ObjectClass *class, void *data)
352
{
353
DeviceClass *dc = DEVICE_CLASS(class);
354
VMStateIfClass *vc = VMSTATE_IF_CLASS(class);
355
+ ResettableClass *rc = RESETTABLE_CLASS(class);
356
357
class->unparent = device_unparent;
358
359
@@ -XXX,XX +XXX,XX @@ static void device_class_init(ObjectClass *class, void *data)
360
dc->hotpluggable = true;
361
dc->user_creatable = true;
362
vc->get_id = device_vmstate_if_get_id;
363
+ rc->get_state = device_get_reset_state;
364
+ rc->child_foreach = device_reset_child_foreach;
365
+
366
+ /*
367
+ * @device_phases_reset is put as the default reset method below, allowing
368
+ * to do the multi-phase transition from base classes to leaf classes. It
369
+ * allows a legacy-reset Device class to extend a multi-phases-reset
370
+ * Device class for the following reason:
371
+ * + If a base class B has been moved to multi-phase, then it does not
372
+ * override this default reset method and may have defined phase methods.
373
+ * + A child class C (extending class B) which uses
374
+ * device_class_set_parent_reset() (or similar means) to override the
375
+ * reset method will still work as expected. @device_phases_reset function
376
+ * will be registered as the parent reset method and effectively call
377
+ * parent reset phases.
378
+ */
379
+ dc->reset = device_phases_reset;
380
+ rc->get_transitional_function = device_get_transitional_reset;
381
382
object_class_property_add_bool(class, "realized",
383
device_get_realized, device_set_realized,
384
@@ -XXX,XX +XXX,XX @@ static const TypeInfo device_type_info = {
385
.class_size = sizeof(DeviceClass),
386
.interfaces = (InterfaceInfo[]) {
387
{ TYPE_VMSTATE_IF },
388
+ { TYPE_RESETTABLE_INTERFACE },
389
{ }
284
}
390
}
285
};
391
};
286
--
392
--
287
2.20.1
393
2.20.1
288
394
289
395
diff view generated by jsdifflib
Deleted patch
1
The only "system register" that M-profile floating point exposes
2
via the VMRS/VMRS instructions is FPSCR, and it does not have
3
the odd special case for rd==15. Add a check to ensure we only
4
expose FPSCR.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-5-peter.maydell@linaro.org
9
---
10
target/arm/translate.c | 19 +++++++++++++++++--
11
1 file changed, 17 insertions(+), 2 deletions(-)
12
13
diff --git a/target/arm/translate.c b/target/arm/translate.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate.c
16
+++ b/target/arm/translate.c
17
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
18
}
19
}
20
} else { /* !dp */
21
+ bool is_sysreg;
22
+
23
if ((insn & 0x6f) != 0x00)
24
return 1;
25
rn = VFP_SREG_N(insn);
26
+
27
+ is_sysreg = extract32(insn, 21, 1);
28
+
29
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
30
+ /*
31
+ * The only M-profile VFP vmrs/vmsr sysreg is FPSCR.
32
+ * Writes to R15 are UNPREDICTABLE; we choose to undef.
33
+ */
34
+ if (is_sysreg && (rd == 15 || (rn >> 1) != ARM_VFP_FPSCR)) {
35
+ return 1;
36
+ }
37
+ }
38
+
39
if (insn & ARM_CP_RW_BIT) {
40
/* vfp->arm */
41
- if (insn & (1 << 21)) {
42
+ if (is_sysreg) {
43
/* system register */
44
rn >>= 1;
45
46
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
47
}
48
} else {
49
/* arm->vfp */
50
- if (insn & (1 << 21)) {
51
+ if (is_sysreg) {
52
rn >>= 1;
53
/* system register */
54
switch (rn) {
55
--
56
2.20.1
57
58
diff view generated by jsdifflib
Deleted patch
1
Correct the decode of the M-profile "coprocessor and
2
floating-point instructions" space:
3
* op0 == 0b11 is always unallocated
4
* if the CPU has an FPU then all insns with op1 == 0b101
5
are floating point and go to disas_vfp_insn()
6
1
7
For the moment we leave VLLDM and VLSTM as NOPs; in
8
a later commit we will fill in the proper implementation
9
for the case where an FPU is present.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20190416125744.27770-7-peter.maydell@linaro.org
14
---
15
target/arm/translate.c | 26 ++++++++++++++++++++++----
16
1 file changed, 22 insertions(+), 4 deletions(-)
17
18
diff --git a/target/arm/translate.c b/target/arm/translate.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate.c
21
+++ b/target/arm/translate.c
22
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
23
case 6: case 7: case 14: case 15:
24
/* Coprocessor. */
25
if (arm_dc_feature(s, ARM_FEATURE_M)) {
26
- /* We don't currently implement M profile FP support,
27
- * so this entire space should give a NOCP fault, with
28
- * the exception of the v8M VLLDM and VLSTM insns, which
29
- * must be NOPs in Secure state and UNDEF in Nonsecure state.
30
+ /* 0b111x_11xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx */
31
+ if (extract32(insn, 24, 2) == 3) {
32
+ goto illegal_op; /* op0 = 0b11 : unallocated */
33
+ }
34
+
35
+ /*
36
+ * Decode VLLDM and VLSTM first: these are nonstandard because:
37
+ * * if there is no FPU then these insns must NOP in
38
+ * Secure state and UNDEF in Nonsecure state
39
+ * * if there is an FPU then these insns do not have
40
+ * the usual behaviour that disas_vfp_insn() provides of
41
+ * being controlled by CPACR/NSACR enable bits or the
42
+ * lazy-stacking logic.
43
*/
44
if (arm_dc_feature(s, ARM_FEATURE_V8) &&
45
(insn & 0xffa00f00) == 0xec200a00) {
46
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
47
/* Just NOP since FP support is not implemented */
48
break;
49
}
50
+ if (arm_dc_feature(s, ARM_FEATURE_VFP) &&
51
+ ((insn >> 8) & 0xe) == 10) {
52
+ /* FP, and the CPU supports it */
53
+ if (disas_vfp_insn(s, insn)) {
54
+ goto illegal_op;
55
+ }
56
+ break;
57
+ }
58
+
59
/* All other insns: NOCP */
60
gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
61
default_exception_el(s));
62
--
63
2.20.1
64
65
diff view generated by jsdifflib
1
The M-profile architecture floating point system supports
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
lazy FP state preservation, where FP registers are not
3
pushed to the stack when an exception occurs but are instead
4
only saved if and when the first FP instruction in the exception
5
handler is executed. Implement this in QEMU, corresponding
6
to the check of LSPACT in the pseudocode ExecuteFPCheck().
7
2
3
Add a function resettable_change_parent() to do the required
4
plumbing when changing the parent a of Resettable object.
5
6
We need to make sure that the reset state of the object remains
7
coherent with the reset state of the new parent.
8
9
We make the 2 following hypothesis:
10
+ when an object is put in a parent under reset, the object goes in
11
reset.
12
+ when an object is removed from a parent under reset, the object
13
leaves reset.
14
15
The added function avoids any glitch if both old and new parent are
16
already in reset.
17
18
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
21
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
Message-id: 20200123132823.1117486-6-damien.hedde@greensocs.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20190416125744.27770-24-peter.maydell@linaro.org
11
---
24
---
12
target/arm/cpu.h | 3 ++
25
include/hw/resettable.h | 16 +++++++++++
13
target/arm/helper.h | 2 +
26
hw/core/resettable.c | 62 +++++++++++++++++++++++++++++++++++++++--
14
target/arm/translate.h | 1 +
27
hw/core/trace-events | 1 +
15
target/arm/helper.c | 112 +++++++++++++++++++++++++++++++++++++++++
28
3 files changed, 77 insertions(+), 2 deletions(-)
16
target/arm/translate.c | 22 ++++++++
17
5 files changed, 140 insertions(+)
18
29
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
30
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
20
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.h
32
--- a/include/hw/resettable.h
22
+++ b/target/arm/cpu.h
33
+++ b/include/hw/resettable.h
23
@@ -XXX,XX +XXX,XX @@
34
@@ -XXX,XX +XXX,XX @@ void resettable_release_reset(Object *obj, ResetType type);
24
#define EXCP_NOCP 17 /* v7M NOCP UsageFault */
35
*/
25
#define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */
36
bool resettable_is_in_reset(Object *obj);
26
#define EXCP_STKOF 19 /* v8M STKOF UsageFault */
37
27
+#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */
38
+/**
28
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
39
+ * resettable_change_parent:
29
40
+ * Indicate that the parent of Ressettable @obj is changing from @oldp to @newp.
30
#define ARMV7M_EXCP_RESET 1
41
+ * All 3 objects must implement resettable interface. @oldp or @newp may be
31
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
42
+ * NULL.
32
FIELD(TBFLAG_A32, VFPEN, 7, 1)
43
+ *
33
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
44
+ * This function will adapt the reset state of @obj so that it is coherent
34
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
45
+ * with the reset state of @newp. It may trigger @resettable_assert_reset()
35
+/* For M profile only, set if FPCCR.LSPACT is set */
46
+ * or @resettable_release_reset(). It will do such things only if the reset
36
+FIELD(TBFLAG_A32, LSPACT, 18, 1)
47
+ * state of @newp and @oldp are different.
37
/* For M profile only, set if we must create a new FP context */
48
+ *
38
FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1)
49
+ * When using this function during reset, it must only be called during
39
/* For M profile only, set if FPCCR.S does not match current security state */
50
+ * a hold phase method. Calling this during enter or exit phase is an error.
40
diff --git a/target/arm/helper.h b/target/arm/helper.h
51
+ */
52
+void resettable_change_parent(Object *obj, Object *newp, Object *oldp);
53
+
54
/**
55
* resettable_class_set_parent_phases:
56
*
57
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
41
index XXXXXXX..XXXXXXX 100644
58
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/helper.h
59
--- a/hw/core/resettable.c
43
+++ b/target/arm/helper.h
60
+++ b/hw/core/resettable.c
44
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v7m_blxns, void, env, i32)
61
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type);
45
62
* enter_phase_in_progress:
46
DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
63
* True if we are currently in reset enter phase.
47
64
*
48
+DEF_HELPER_1(v7m_preserve_fp_state, void, env)
65
- * Note: This flag is only used to guarantee (using asserts) that the reset
49
+
66
- * API is used correctly. We can use a global variable because we rely on the
50
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
67
+ * exit_phase_in_progress:
51
68
+ * count the number of exit phase we are in.
52
DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
69
+ *
53
diff --git a/target/arm/translate.h b/target/arm/translate.h
70
+ * Note: These flags are only used to guarantee (using asserts) that the reset
54
index XXXXXXX..XXXXXXX 100644
71
+ * API is used correctly. We can use global variables because we rely on the
55
--- a/target/arm/translate.h
72
* iothread mutex to ensure only one reset operation is in a progress at a
56
+++ b/target/arm/translate.h
73
* given time.
57
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
74
*/
58
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
75
static bool enter_phase_in_progress;
59
bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
76
+static unsigned exit_phase_in_progress;
60
bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */
77
61
+ bool v7m_lspact; /* FPCCR.LSPACT set */
78
void resettable_reset(Object *obj, ResetType type)
62
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
79
{
63
* so that top level loop can generate correct syndrome information.
80
@@ -XXX,XX +XXX,XX @@ void resettable_release_reset(Object *obj, ResetType type)
64
*/
81
trace_resettable_reset_release_begin(obj, type);
65
diff --git a/target/arm/helper.c b/target/arm/helper.c
82
assert(!enter_phase_in_progress);
66
index XXXXXXX..XXXXXXX 100644
83
67
--- a/target/arm/helper.c
84
+ exit_phase_in_progress += 1;
68
+++ b/target/arm/helper.c
85
resettable_phase_exit(obj, NULL, type);
69
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
86
+ exit_phase_in_progress -= 1;
70
g_assert_not_reached();
87
88
trace_resettable_reset_release_end(obj);
71
}
89
}
72
90
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
73
+void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
91
trace_resettable_phase_exit_end(obj, obj_typename, s->count);
92
}
93
94
+/*
95
+ * resettable_get_count:
96
+ * Get the count of the Resettable object @obj. Return 0 if @obj is NULL.
97
+ */
98
+static unsigned resettable_get_count(Object *obj)
74
+{
99
+{
75
+ /* translate.c should never generate calls here in user-only mode */
100
+ if (obj) {
76
+ g_assert_not_reached();
101
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
102
+ return rc->get_state(obj)->count;
103
+ }
104
+ return 0;
77
+}
105
+}
78
+
106
+
79
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
107
+void resettable_change_parent(Object *obj, Object *newp, Object *oldp)
80
{
81
/* The TT instructions can be used by unprivileged code, but in
82
@@ -XXX,XX +XXX,XX @@ pend_fault:
83
return false;
84
}
85
86
+void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
87
+{
108
+{
88
+ /*
109
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
89
+ * Preserve FP state (because LSPACT was set and we are about
110
+ ResettableState *s = rc->get_state(obj);
90
+ * to execute an FP instruction). This corresponds to the
111
+ unsigned newp_count = resettable_get_count(newp);
91
+ * PreserveFPState() pseudocode.
112
+ unsigned oldp_count = resettable_get_count(oldp);
92
+ * We may throw an exception if the stacking fails.
93
+ */
94
+ ARMCPU *cpu = arm_env_get_cpu(env);
95
+ bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
96
+ bool negpri = !(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_HFRDY_MASK);
97
+ bool is_priv = !(env->v7m.fpccr[is_secure] & R_V7M_FPCCR_USER_MASK);
98
+ bool splimviol = env->v7m.fpccr[is_secure] & R_V7M_FPCCR_SPLIMVIOL_MASK;
99
+ uint32_t fpcar = env->v7m.fpcar[is_secure];
100
+ bool stacked_ok = true;
101
+ bool ts = is_secure && (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK);
102
+ bool take_exception;
103
+
104
+ /* Take the iothread lock as we are going to touch the NVIC */
105
+ qemu_mutex_lock_iothread();
106
+
107
+ /* Check the background context had access to the FPU */
108
+ if (!v7m_cpacr_pass(env, is_secure, is_priv)) {
109
+ armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, is_secure);
110
+ env->v7m.cfsr[is_secure] |= R_V7M_CFSR_NOCP_MASK;
111
+ stacked_ok = false;
112
+ } else if (!is_secure && !extract32(env->v7m.nsacr, 10, 1)) {
113
+ armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S);
114
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK;
115
+ stacked_ok = false;
116
+ }
117
+
118
+ if (!splimviol && stacked_ok) {
119
+ /* We only stack if the stack limit wasn't violated */
120
+ int i;
121
+ ARMMMUIdx mmu_idx;
122
+
123
+ mmu_idx = arm_v7m_mmu_idx_all(env, is_secure, is_priv, negpri);
124
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
125
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
126
+ uint32_t faddr = fpcar + 4 * i;
127
+ uint32_t slo = extract64(dn, 0, 32);
128
+ uint32_t shi = extract64(dn, 32, 32);
129
+
130
+ if (i >= 16) {
131
+ faddr += 8; /* skip the slot for the FPSCR */
132
+ }
133
+ stacked_ok = stacked_ok &&
134
+ v7m_stack_write(cpu, faddr, slo, mmu_idx, STACK_LAZYFP) &&
135
+ v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, STACK_LAZYFP);
136
+ }
137
+
138
+ stacked_ok = stacked_ok &&
139
+ v7m_stack_write(cpu, fpcar + 0x40,
140
+ vfp_get_fpscr(env), mmu_idx, STACK_LAZYFP);
141
+ }
142
+
113
+
143
+ /*
114
+ /*
144
+ * We definitely pended an exception, but it's possible that it
115
+ * Ensure we do not change parent when in enter or exit phase.
145
+ * might not be able to be taken now. If its priority permits us
116
+ * During these phases, the reset subtree being updated is partly in reset
146
+ * to take it now, then we must not update the LSPACT or FP regs,
117
+ * and partly not in reset (it depends on the actual position in
147
+ * but instead jump out to take the exception immediately.
118
+ * resettable_child_foreach()s). We are not able to tell in which part is a
148
+ * If it's just pending and won't be taken until the current
119
+ * leaving or arriving device. Thus we cannot set the reset count of the
149
+ * handler exits, then we do update LSPACT and the FP regs.
120
+ * moving device to the proper value.
150
+ */
121
+ */
151
+ take_exception = !stacked_ok &&
122
+ assert(!enter_phase_in_progress && !exit_phase_in_progress);
152
+ armv7m_nvic_can_take_pending_exception(env->nvic);
123
+ trace_resettable_change_parent(obj, oldp, oldp_count, newp, newp_count);
153
+
124
+
154
+ qemu_mutex_unlock_iothread();
125
+ /*
155
+
126
+ * At most one of the two 'for' loops will be executed below
156
+ if (take_exception) {
127
+ * in order to cope with the difference between the two counts.
157
+ raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC());
128
+ */
158
+ }
129
+ /* if newp is more reset than oldp */
159
+
130
+ for (unsigned i = oldp_count; i < newp_count; i++) {
160
+ env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK;
131
+ resettable_assert_reset(obj, RESET_TYPE_COLD);
161
+
162
+ if (ts) {
163
+ /* Clear s0 to s31 and the FPSCR */
164
+ int i;
165
+
166
+ for (i = 0; i < 32; i += 2) {
167
+ *aa32_vfp_dreg(env, i / 2) = 0;
168
+ }
169
+ vfp_set_fpscr(env, 0);
170
+ }
132
+ }
171
+ /*
133
+ /*
172
+ * Otherwise s0 to s15 and FPSCR are UNKNOWN; we choose to leave them
134
+ * if obj is leaving a bus under reset, we need to ensure
173
+ * unchanged.
135
+ * hold phase is not pending.
174
+ */
136
+ */
137
+ if (oldp_count && s->hold_phase_pending) {
138
+ resettable_phase_hold(obj, NULL, RESET_TYPE_COLD);
139
+ }
140
+ /* if oldp is more reset than newp */
141
+ for (unsigned i = newp_count; i < oldp_count; i++) {
142
+ resettable_release_reset(obj, RESET_TYPE_COLD);
143
+ }
175
+}
144
+}
176
+
145
+
177
/* Write to v7M CONTROL.SPSEL bit for the specified security bank.
146
void resettable_class_set_parent_phases(ResettableClass *rc,
178
* This may change the current stack pointer between Main and Process
147
ResettableEnterPhase enter,
179
* stack pointers if it is done for the CONTROL register for the current
148
ResettableHoldPhase hold,
180
@@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx)
149
diff --git a/hw/core/trace-events b/hw/core/trace-events
181
[EXCP_NOCP] = "v7M NOCP UsageFault",
182
[EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
183
[EXCP_STKOF] = "v8M STKOF UsageFault",
184
+ [EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
185
};
186
187
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
188
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
189
return;
190
}
191
break;
192
+ case EXCP_LAZYFP:
193
+ /*
194
+ * We already pended the specific exception in the NVIC in the
195
+ * v7m_preserve_fp_state() helper function.
196
+ */
197
+ break;
198
default:
199
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
200
return; /* Never happens. Keep compiler happy. */
201
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
202
flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1);
203
}
204
205
+ if (arm_feature(env, ARM_FEATURE_M)) {
206
+ bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
207
+
208
+ if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) {
209
+ flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1);
210
+ }
211
+ }
212
+
213
*pflags = flags;
214
*cs_base = 0;
215
}
216
diff --git a/target/arm/translate.c b/target/arm/translate.c
217
index XXXXXXX..XXXXXXX 100644
150
index XXXXXXX..XXXXXXX 100644
218
--- a/target/arm/translate.c
151
--- a/hw/core/trace-events
219
+++ b/target/arm/translate.c
152
+++ b/hw/core/trace-events
220
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
153
@@ -XXX,XX +XXX,XX @@ resettable_reset_assert_begin(void *obj, int cold) "obj=%p cold=%d"
221
if (arm_dc_feature(s, ARM_FEATURE_M)) {
154
resettable_reset_assert_end(void *obj) "obj=%p"
222
/* Handle M-profile lazy FP state mechanics */
155
resettable_reset_release_begin(void *obj, int cold) "obj=%p cold=%d"
223
156
resettable_reset_release_end(void *obj) "obj=%p"
224
+ /* Trigger lazy-state preservation if necessary */
157
+resettable_change_parent(void *obj, void *o, unsigned oc, void *n, unsigned nc) "obj=%p from=%p(%d) to=%p(%d)"
225
+ if (s->v7m_lspact) {
158
resettable_phase_enter_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
226
+ /*
159
resettable_phase_enter_exec(void *obj, const char *objtype, int type, int has_method) "obj=%p(%s) type=%d method=%d"
227
+ * Lazy state saving affects external memory and also the NVIC,
160
resettable_phase_enter_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
228
+ * so we must mark it as an IO operation for icount.
229
+ */
230
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
231
+ gen_io_start();
232
+ }
233
+ gen_helper_v7m_preserve_fp_state(cpu_env);
234
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
235
+ gen_io_end();
236
+ }
237
+ /*
238
+ * If the preserve_fp_state helper doesn't throw an exception
239
+ * then it will clear LSPACT; we don't need to repeat this for
240
+ * any further FP insns in this TB.
241
+ */
242
+ s->v7m_lspact = false;
243
+ }
244
+
245
/* Update ownership of FP context: set FPCCR.S to match current state */
246
if (s->v8m_fpccr_s_wrong) {
247
TCGv_i32 tmp;
248
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
249
dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
250
dc->v7m_new_fp_ctxt_needed =
251
FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED);
252
+ dc->v7m_lspact = FIELD_EX32(tb_flags, TBFLAG_A32, LSPACT);
253
dc->cp_regs = cpu->cp_regs;
254
dc->features = env->features;
255
256
--
161
--
257
2.20.1
162
2.20.1
258
163
259
164
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
2
3
Since uWireSlave is only used in this new header, there is no
3
In qdev_set_parent_bus(), when changing the parent bus of a
4
need to expose it via "qemu/typedefs.h".
4
realized device, if the source and destination buses are not in the
5
same reset state, some adaptations are required. This patch adds
6
needed call to resettable_change_parent() to make sure a device reset
7
state stays coherent with its parent bus.
5
8
6
Reviewed-by: Markus Armbruster <armbru@redhat.com>
9
The addition is a no-op if:
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
1. the device being parented is not realized.
8
Message-id: 20190412165416.7977-9-philmd@redhat.com
11
2. the device is realized, but both buses are not under reset.
12
13
Case 2 means that as long as qdev_set_parent_bus() is called
14
during the machine realization procedure (which is before the
15
machine reset so nothing is in reset), it is a no op.
16
17
There are 52 call sites of qdev_set_parent_bus(). All but one fall
18
into the no-op case:
19
+ 29 trivial calls related to virtio (in hw/{s390x,display,virtio}/
20
{vhost,virtio}-xxx.c) to set a vdev(or vgpu) composing device
21
parent bus just before realizing the same vdev(vgpu).
22
+ hw/core/qdev.c: when creating a device in qdev_try_create()
23
+ hw/core/sysbus.c: when initializing a device in the sysbus
24
+ hw/i386/amd_iommu.c: before realizing AMDVIState/pci
25
+ hw/isa/piix4.c: before realizing PIIX4State/rtc
26
+ hw/misc/auxbus.c: when creating an AUXBus
27
+ hw/misc/auxbus.c: when creating an AUXBus child
28
+ hw/misc/macio/macio.c: when initializing a MACIOState child
29
+ hw/misc/macio/macio.c: before realizing NewWorldMacIOState/pmu
30
+ hw/misc/macio/macio.c: before realizing NewWorldMacIOState/cuda
31
+ hw/net/virtio-net.c: Used for migration when using the failover
32
mechanism to migration a vfio-pci/net. It is
33
a no-op because at this point the device is
34
already on the bus.
35
+ hw/pci-host/designware.c: before realizing DesignwarePCIEHost/root
36
+ hw/pci-host/gpex.c: before realizing GPEXHost/root
37
+ hw/pci-host/prep.c: when initialiazing PREPPCIState/pci_dev
38
+ hw/pci-host/q35.c: before realizing Q35PCIHost/mch
39
+ hw/pci-host/versatile.c: when initializing PCIVPBState/pci_dev
40
+ hw/pci-host/xilinx-pcie.c: before realizing XilinxPCIEHost/root
41
+ hw/s390x/event-facility.c: when creating SCLPEventFacility/
42
TYPE_SCLP_QUIESCE
43
+ hw/s390x/event-facility.c: ditto with SCLPEventFacility/
44
TYPE_SCLP_CPU_HOTPLUG
45
+ hw/s390x/sclp.c: Not trivial because it is called on a SLCPDevice
46
just after realizing it. Ok because at this point the destination
47
bus (sysbus) is not in reset; the realize step is before the
48
machine reset.
49
+ hw/sd/core.c: Not OK. Used in sdbus_reparent_card(). See below.
50
+ hw/ssi/ssi.c: Used to put spi slave on spi bus and connect the cs
51
line in ssi_auto_connect_slave(). Ok because this function is only
52
used in realize step in hw/ssi/aspeed_smc.ci, hw/ssi/imx_spi.c,
53
hw/ssi/mss-spi.c, hw/ssi/xilinx_spi.c and hw/ssi/xilinx_spips.c.
54
+ hw/xen/xen-legacy-backend.c: when creating a XenLegacyDevice device
55
+ qdev-monitor.c: in device hotplug creation procedure before realize
56
57
Note that this commit alone will have no effect, right now there is no
58
use of resettable API to reset anything. So a bus will never be tagged
59
as in-reset by this same API.
60
61
The one place where side-effect will occurs is in hw/sd/core.c in
62
sdbus_reparent_card(). This function is only used in the raspi machines,
63
including during the sysbus reset procedure. This case will be
64
carrefully handled when doing the multiple phase reset transition.
65
66
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
67
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
68
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
69
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
70
Message-id: 20200123132823.1117486-7-damien.hedde@greensocs.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
71
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
72
---
11
include/hw/arm/omap.h | 6 +-----
73
hw/core/qdev.c | 16 +++++++++++-----
12
include/hw/devices.h | 15 ---------------
74
1 file changed, 11 insertions(+), 5 deletions(-)
13
include/hw/input/tsc2xxx.h | 36 ++++++++++++++++++++++++++++++++++++
14
include/qemu/typedefs.h | 1 -
15
hw/arm/nseries.c | 2 +-
16
hw/arm/palm.c | 2 +-
17
hw/input/tsc2005.c | 2 +-
18
hw/input/tsc210x.c | 4 ++--
19
MAINTAINERS | 2 ++
20
9 files changed, 44 insertions(+), 26 deletions(-)
21
create mode 100644 include/hw/input/tsc2xxx.h
22
75
23
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
76
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
24
index XXXXXXX..XXXXXXX 100644
77
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/arm/omap.h
78
--- a/hw/core/qdev.c
26
+++ b/include/hw/arm/omap.h
79
+++ b/hw/core/qdev.c
27
@@ -XXX,XX +XXX,XX @@
80
@@ -XXX,XX +XXX,XX @@ static void bus_add_child(BusState *bus, DeviceState *child)
28
#include "exec/memory.h"
81
29
# define hw_omap_h        "omap.h"
82
void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
30
#include "hw/irq.h"
83
{
31
+#include "hw/input/tsc2xxx.h"
84
- bool replugging = dev->parent_bus != NULL;
32
#include "target/arm/cpu-qom.h"
85
+ BusState *old_parent_bus = dev->parent_bus;
33
#include "qemu/log.h"
86
34
87
- if (replugging) {
35
@@ -XXX,XX +XXX,XX @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s);
88
+ if (old_parent_bus) {
36
void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler);
89
trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)),
37
void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down);
90
- dev->parent_bus, object_get_typename(OBJECT(dev->parent_bus)),
38
91
+ old_parent_bus, object_get_typename(OBJECT(old_parent_bus)),
39
-struct uWireSlave {
92
OBJECT(bus), object_get_typename(OBJECT(bus)));
40
- uint16_t (*receive)(void *opaque);
93
/*
41
- void (*send)(void *opaque, uint16_t data);
94
* Keep a reference to the device while it's not plugged into
42
- void *opaque;
95
* any bus, to avoid it potentially evaporating when it is
43
-};
96
* dereffed in bus_remove_child().
44
struct omap_uwire_s;
97
+ * Also keep the ref of the parent bus until the end, so that
45
void omap_uwire_attach(struct omap_uwire_s *s,
98
+ * we can safely call resettable_change_parent() below.
46
uWireSlave *slave, int chipselect);
99
*/
47
diff --git a/include/hw/devices.h b/include/hw/devices.h
100
object_ref(OBJECT(dev));
48
index XXXXXXX..XXXXXXX 100644
101
bus_remove_child(dev->parent_bus, dev);
49
--- a/include/hw/devices.h
102
- object_unref(OBJECT(dev->parent_bus));
50
+++ b/include/hw/devices.h
103
}
51
@@ -XXX,XX +XXX,XX @@
104
dev->parent_bus = bus;
52
/* Devices that have nowhere better to go. */
105
object_ref(OBJECT(bus));
53
106
bus_add_child(bus, dev);
54
#include "hw/hw.h"
107
- if (replugging) {
55
-#include "ui/console.h"
108
+ if (dev->realized) {
56
109
+ resettable_change_parent(OBJECT(dev), OBJECT(bus),
57
/* smc91c111.c */
110
+ OBJECT(old_parent_bus));
58
void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
111
+ }
59
@@ -XXX,XX +XXX,XX @@ void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
112
+ if (old_parent_bus) {
60
/* lan9118.c */
113
+ object_unref(OBJECT(old_parent_bus));
61
void lan9118_init(NICInfo *, uint32_t, qemu_irq);
114
object_unref(OBJECT(dev));
62
115
}
63
-/* tsc210x.c */
116
}
64
-uWireSlave *tsc2102_init(qemu_irq pint);
65
-uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
66
-I2SCodec *tsc210x_codec(uWireSlave *chip);
67
-uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
68
-void tsc210x_set_transform(uWireSlave *chip,
69
- MouseTransformInfo *info);
70
-void tsc210x_key_event(uWireSlave *chip, int key, int down);
71
-
72
-/* tsc2005.c */
73
-void *tsc2005_init(qemu_irq pintdav);
74
-uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
75
-void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
76
-
77
#endif
78
diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h
79
new file mode 100644
80
index XXXXXXX..XXXXXXX
81
--- /dev/null
82
+++ b/include/hw/input/tsc2xxx.h
83
@@ -XXX,XX +XXX,XX @@
84
+/*
85
+ * TI touchscreen controller
86
+ *
87
+ * Copyright (c) 2006 Andrzej Zaborowski
88
+ * Copyright (C) 2008 Nokia Corporation
89
+ *
90
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
91
+ * See the COPYING file in the top-level directory.
92
+ */
93
+
94
+#ifndef HW_INPUT_TSC2XXX_H
95
+#define HW_INPUT_TSC2XXX_H
96
+
97
+#include "hw/irq.h"
98
+#include "ui/console.h"
99
+
100
+typedef struct uWireSlave {
101
+ uint16_t (*receive)(void *opaque);
102
+ void (*send)(void *opaque, uint16_t data);
103
+ void *opaque;
104
+} uWireSlave;
105
+
106
+/* tsc210x.c */
107
+uWireSlave *tsc2102_init(qemu_irq pint);
108
+uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
109
+I2SCodec *tsc210x_codec(uWireSlave *chip);
110
+uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
111
+void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info);
112
+void tsc210x_key_event(uWireSlave *chip, int key, int down);
113
+
114
+/* tsc2005.c */
115
+void *tsc2005_init(qemu_irq pintdav);
116
+uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
117
+void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
118
+
119
+#endif
120
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
121
index XXXXXXX..XXXXXXX 100644
122
--- a/include/qemu/typedefs.h
123
+++ b/include/qemu/typedefs.h
124
@@ -XXX,XX +XXX,XX @@ typedef struct RAMBlock RAMBlock;
125
typedef struct Range Range;
126
typedef struct SHPCDevice SHPCDevice;
127
typedef struct SSIBus SSIBus;
128
-typedef struct uWireSlave uWireSlave;
129
typedef struct VirtIODevice VirtIODevice;
130
typedef struct Visitor Visitor;
131
typedef void SaveStateHandler(QEMUFile *f, void *opaque);
132
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
133
index XXXXXXX..XXXXXXX 100644
134
--- a/hw/arm/nseries.c
135
+++ b/hw/arm/nseries.c
136
@@ -XXX,XX +XXX,XX @@
137
#include "ui/console.h"
138
#include "hw/boards.h"
139
#include "hw/i2c/i2c.h"
140
-#include "hw/devices.h"
141
#include "hw/display/blizzard.h"
142
+#include "hw/input/tsc2xxx.h"
143
#include "hw/misc/cbus.h"
144
#include "hw/misc/tmp105.h"
145
#include "hw/block/flash.h"
146
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
147
index XXXXXXX..XXXXXXX 100644
148
--- a/hw/arm/palm.c
149
+++ b/hw/arm/palm.c
150
@@ -XXX,XX +XXX,XX @@
151
#include "hw/arm/omap.h"
152
#include "hw/boards.h"
153
#include "hw/arm/arm.h"
154
-#include "hw/devices.h"
155
+#include "hw/input/tsc2xxx.h"
156
#include "hw/loader.h"
157
#include "exec/address-spaces.h"
158
#include "cpu.h"
159
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
160
index XXXXXXX..XXXXXXX 100644
161
--- a/hw/input/tsc2005.c
162
+++ b/hw/input/tsc2005.c
163
@@ -XXX,XX +XXX,XX @@
164
#include "hw/hw.h"
165
#include "qemu/timer.h"
166
#include "ui/console.h"
167
-#include "hw/devices.h"
168
+#include "hw/input/tsc2xxx.h"
169
#include "trace.h"
170
171
#define TSC_CUT_RESOLUTION(value, p)    ((value) >> (16 - (p ? 12 : 10)))
172
diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
173
index XXXXXXX..XXXXXXX 100644
174
--- a/hw/input/tsc210x.c
175
+++ b/hw/input/tsc210x.c
176
@@ -XXX,XX +XXX,XX @@
177
#include "audio/audio.h"
178
#include "qemu/timer.h"
179
#include "ui/console.h"
180
-#include "hw/arm/omap.h"    /* For I2SCodec and uWireSlave */
181
-#include "hw/devices.h"
182
+#include "hw/arm/omap.h" /* For I2SCodec */
183
+#include "hw/input/tsc2xxx.h"
184
185
#define TSC_DATA_REGISTERS_PAGE        0x0
186
#define TSC_CONTROL_REGISTERS_PAGE    0x1
187
diff --git a/MAINTAINERS b/MAINTAINERS
188
index XXXXXXX..XXXXXXX 100644
189
--- a/MAINTAINERS
190
+++ b/MAINTAINERS
191
@@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c
192
F: hw/misc/cbus.c
193
F: hw/timer/twl92230.c
194
F: include/hw/display/blizzard.h
195
+F: include/hw/input/tsc2xxx.h
196
F: include/hw/misc/cbus.h
197
198
Palm
199
@@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org
200
S: Odd Fixes
201
F: hw/arm/palm.c
202
F: hw/input/tsc210x.c
203
+F: include/hw/input/tsc2xxx.h
204
205
Raspberry Pi
206
M: Peter Maydell <peter.maydell@linaro.org>
207
--
117
--
208
2.20.1
118
2.20.1
209
119
210
120
diff view generated by jsdifflib
1
Handle floating point registers in exception return.
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
This corresponds to pseudocode functions ValidateExceptionReturn(),
3
ExceptionReturn(), PopStack() and ConsumeExcStackFrame().
4
2
3
This commit make use of the resettable API to reset the device being
4
hotplugged when it is realized. Also it ensures it is put in a reset
5
state coherent with the parent it is plugged into.
6
7
Note that there is a difference in the reset. Instead of resetting
8
only the hotplugged device, we reset also its subtree (switch to
9
resettable API). This is not expected to be a problem because
10
sub-buses are just realized too. If a hotplugged device has any
11
sub-buses it is logical to reset them too at this point.
12
13
The recently added should_be_hidden and PCI's partially_hotplugged
14
mechanisms do not interfere with realize operation:
15
+ In the should_be_hidden use case, device creation is
16
delayed.
17
+ The partially_hotplugged mechanism prevents a device to be
18
unplugged and unrealized from qdev POV and unrealized.
19
20
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
23
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
24
Message-id: 20200123132823.1117486-8-damien.hedde@greensocs.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190416125744.27770-16-peter.maydell@linaro.org
8
---
26
---
9
target/arm/helper.c | 142 +++++++++++++++++++++++++++++++++++++++++++-
27
include/hw/resettable.h | 11 +++++++++++
10
1 file changed, 141 insertions(+), 1 deletion(-)
28
hw/core/qdev.c | 15 ++++++++++++++-
29
2 files changed, 25 insertions(+), 1 deletion(-)
11
30
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
31
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
13
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
33
--- a/include/hw/resettable.h
15
+++ b/target/arm/helper.c
34
+++ b/include/hw/resettable.h
16
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
35
@@ -XXX,XX +XXX,XX @@ struct ResettableState {
17
bool rettobase = false;
36
bool exit_phase_in_progress;
18
bool exc_secure = false;
37
};
19
bool return_to_secure;
38
20
+ bool ftype;
39
+/**
21
+ bool restore_s16_s31;
40
+ * resettable_state_clear:
22
41
+ * Clear the state. It puts the state to the initial (zeroed) state required
23
/* If we're not in Handler mode then jumps to magic exception-exit
42
+ * to reuse an object. Typically used in realize step of base classes
24
* addresses don't have magic behaviour. However for the v8M
43
+ * implementing the interface.
25
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
44
+ */
26
excret);
45
+static inline void resettable_state_clear(ResettableState *state)
27
}
46
+{
28
47
+ memset(state, 0, sizeof(ResettableState));
29
+ ftype = excret & R_V7M_EXCRET_FTYPE_MASK;
48
+}
30
+
49
+
31
+ if (!arm_feature(env, ARM_FEATURE_VFP) && !ftype) {
50
/**
32
+ qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero FTYPE in exception "
51
* resettable_reset:
33
+ "exit PC value 0x%" PRIx32 " is UNPREDICTABLE "
52
* Trigger a reset on an object @obj of type @type. @obj must implement
34
+ "if FPU not present\n",
53
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
35
+ excret);
54
index XXXXXXX..XXXXXXX 100644
36
+ ftype = true;
55
--- a/hw/core/qdev.c
37
+ }
56
+++ b/hw/core/qdev.c
38
+
57
@@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp)
39
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
40
/* EXC_RETURN.ES validation check (R_SMFL). We must do this before
41
* we pick which FAULTMASK to clear.
42
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
43
*/
44
write_v7m_control_spsel_for_secstate(env, return_to_sp_process, exc_secure);
45
46
+ /*
47
+ * Clear scratch FP values left in caller saved registers; this
48
+ * must happen before any kind of tail chaining.
49
+ */
50
+ if ((env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_CLRONRET_MASK) &&
51
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) {
52
+ if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) {
53
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
54
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
55
+ qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing "
56
+ "stackframe: error during lazy state deactivation\n");
57
+ v7m_exception_taken(cpu, excret, true, false);
58
+ return;
59
+ } else {
60
+ /* Clear s0..s15 and FPSCR */
61
+ int i;
62
+
63
+ for (i = 0; i < 16; i += 2) {
64
+ *aa32_vfp_dreg(env, i / 2) = 0;
65
+ }
66
+ vfp_set_fpscr(env, 0);
67
+ }
68
+ }
69
+
70
if (sfault) {
71
env->v7m.sfsr |= R_V7M_SFSR_INVER_MASK;
72
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
73
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
74
}
58
}
75
}
59
}
76
60
77
+ if (!ftype) {
61
+ /*
78
+ /* FP present and we need to handle it */
62
+ * Clear the reset state, in case the object was previously unrealized
79
+ if (!return_to_secure &&
63
+ * with a dirty state.
80
+ (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK)) {
64
+ */
81
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
65
+ resettable_state_clear(&dev->reset);
82
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
83
+ qemu_log_mask(CPU_LOG_INT,
84
+ "...taking SecureFault on existing stackframe: "
85
+ "Secure LSPACT set but exception return is "
86
+ "not to secure state\n");
87
+ v7m_exception_taken(cpu, excret, true, false);
88
+ return;
89
+ }
90
+
66
+
91
+ restore_s16_s31 = return_to_secure &&
67
QLIST_FOREACH(bus, &dev->child_bus, sibling) {
92
+ (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK);
68
object_property_set_bool(OBJECT(bus), true, "realized",
93
+
69
&local_err);
94
+ if (env->v7m.fpccr[return_to_secure] & R_V7M_FPCCR_LSPACT_MASK) {
70
@@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp)
95
+ /* State in FPU is still valid, just clear LSPACT */
71
}
96
+ env->v7m.fpccr[return_to_secure] &= ~R_V7M_FPCCR_LSPACT_MASK;
72
}
97
+ } else {
73
if (dev->hotplugged) {
98
+ int i;
74
- device_legacy_reset(dev);
99
+ uint32_t fpscr;
75
+ /*
100
+ bool cpacr_pass, nsacr_pass;
76
+ * Reset the device, as well as its subtree which, at this point,
101
+
77
+ * should be realized too.
102
+ cpacr_pass = v7m_cpacr_pass(env, return_to_secure,
78
+ */
103
+ return_to_priv);
79
+ resettable_assert_reset(OBJECT(dev), RESET_TYPE_COLD);
104
+ nsacr_pass = return_to_secure ||
80
+ resettable_change_parent(OBJECT(dev), OBJECT(dev->parent_bus),
105
+ extract32(env->v7m.nsacr, 10, 1);
81
+ NULL);
106
+
82
+ resettable_release_reset(OBJECT(dev), RESET_TYPE_COLD);
107
+ if (!cpacr_pass) {
83
}
108
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
84
dev->pending_deleted_event = false;
109
+ return_to_secure);
85
110
+ env->v7m.cfsr[return_to_secure] |= R_V7M_CFSR_NOCP_MASK;
111
+ qemu_log_mask(CPU_LOG_INT,
112
+ "...taking UsageFault on existing "
113
+ "stackframe: CPACR.CP10 prevents unstacking "
114
+ "FP regs\n");
115
+ v7m_exception_taken(cpu, excret, true, false);
116
+ return;
117
+ } else if (!nsacr_pass) {
118
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true);
119
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_INVPC_MASK;
120
+ qemu_log_mask(CPU_LOG_INT,
121
+ "...taking Secure UsageFault on existing "
122
+ "stackframe: NSACR.CP10 prevents unstacking "
123
+ "FP regs\n");
124
+ v7m_exception_taken(cpu, excret, true, false);
125
+ return;
126
+ }
127
+
128
+ for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) {
129
+ uint32_t slo, shi;
130
+ uint64_t dn;
131
+ uint32_t faddr = frameptr + 0x20 + 4 * i;
132
+
133
+ if (i >= 16) {
134
+ faddr += 8; /* Skip the slot for the FPSCR */
135
+ }
136
+
137
+ pop_ok = pop_ok &&
138
+ v7m_stack_read(cpu, &slo, faddr, mmu_idx) &&
139
+ v7m_stack_read(cpu, &shi, faddr + 4, mmu_idx);
140
+
141
+ if (!pop_ok) {
142
+ break;
143
+ }
144
+
145
+ dn = (uint64_t)shi << 32 | slo;
146
+ *aa32_vfp_dreg(env, i / 2) = dn;
147
+ }
148
+ pop_ok = pop_ok &&
149
+ v7m_stack_read(cpu, &fpscr, frameptr + 0x60, mmu_idx);
150
+ if (pop_ok) {
151
+ vfp_set_fpscr(env, fpscr);
152
+ }
153
+ if (!pop_ok) {
154
+ /*
155
+ * These regs are 0 if security extension present;
156
+ * otherwise merely UNKNOWN. We zero always.
157
+ */
158
+ for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) {
159
+ *aa32_vfp_dreg(env, i / 2) = 0;
160
+ }
161
+ vfp_set_fpscr(env, 0);
162
+ }
163
+ }
164
+ }
165
+ env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S],
166
+ V7M_CONTROL, FPCA, !ftype);
167
+
168
/* Commit to consuming the stack frame */
169
frameptr += 0x20;
170
+ if (!ftype) {
171
+ frameptr += 0x48;
172
+ if (restore_s16_s31) {
173
+ frameptr += 0x40;
174
+ }
175
+ }
176
/* Undo stack alignment (the SPREALIGN bit indicates that the original
177
* pre-exception SP was not 8-aligned and we added a padding word to
178
* align it, so we undo this by ORing in the bit that increases it
179
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
180
*frame_sp_p = frameptr;
181
}
182
/* This xpsr_write() will invalidate frame_sp_p as it may switch stack */
183
- xpsr_write(env, xpsr, ~XPSR_SPREALIGN);
184
+ xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA));
185
+
186
+ if (env->v7m.secure) {
187
+ bool sfpa = xpsr & XPSR_SFPA;
188
+
189
+ env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S],
190
+ V7M_CONTROL, SFPA, sfpa);
191
+ }
192
193
/* The restored xPSR exception field will be zero if we're
194
* resuming in Thread mode. If that doesn't match what the
195
--
86
--
196
2.20.1
87
2.20.1
197
88
198
89
diff view generated by jsdifflib
1
Implement the VLSTM instruction for v7M for the FPU present case.
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
2
3
Deprecate device_legacy_reset(), qdev_reset_all() and
4
qbus_reset_all() to be replaced by new functions
5
device_cold_reset() and bus_cold_reset() which uses resettable API.
6
7
Also introduce resettable_cold_reset_fn() which may be used as a
8
replacement for qdev_reset_all_fn and qbus_reset_all_fn().
9
10
Following patches will be needed to look at legacy reset call sites
11
and switch to resettable api. The legacy functions will be removed
12
when unused.
13
14
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
19
Message-id: 20200123132823.1117486-9-damien.hedde@greensocs.com
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-25-peter.maydell@linaro.org
6
---
21
---
7
target/arm/cpu.h | 2 +
22
include/hw/qdev-core.h | 27 +++++++++++++++++++++++++++
8
target/arm/helper.h | 2 +
23
include/hw/resettable.h | 9 +++++++++
9
target/arm/helper.c | 84 ++++++++++++++++++++++++++++++++++++++++++
24
hw/core/bus.c | 5 +++++
10
target/arm/translate.c | 15 +++++++-
25
hw/core/qdev.c | 5 +++++
11
4 files changed, 102 insertions(+), 1 deletion(-)
26
hw/core/resettable.c | 5 +++++
27
5 files changed, 51 insertions(+)
12
28
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
29
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
14
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
31
--- a/include/hw/qdev-core.h
16
+++ b/target/arm/cpu.h
32
+++ b/include/hw/qdev-core.h
17
@@ -XXX,XX +XXX,XX @@
33
@@ -XXX,XX +XXX,XX @@ int qdev_walk_children(DeviceState *dev,
18
#define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */
34
qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
19
#define EXCP_STKOF 19 /* v8M STKOF UsageFault */
35
void *opaque);
20
#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */
36
21
+#define EXCP_LSERR 21 /* v8M LSERR SecureFault */
37
+/**
22
+#define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */
38
+ * @qdev_reset_all:
23
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
39
+ * Reset @dev. See @qbus_reset_all() for more details.
24
40
+ *
25
#define ARMV7M_EXCP_RESET 1
41
+ * Note: This function is deprecated and will be removed when it becomes unused.
26
diff --git a/target/arm/helper.h b/target/arm/helper.h
42
+ * Please use device_cold_reset() now.
43
+ */
44
void qdev_reset_all(DeviceState *dev);
45
void qdev_reset_all_fn(void *opaque);
46
47
@@ -XXX,XX +XXX,XX @@ void qdev_reset_all_fn(void *opaque);
48
* hard reset means that qbus_reset_all will reset all state of the device.
49
* For PCI devices, for example, this will include the base address registers
50
* or configuration space.
51
+ *
52
+ * Note: This function is deprecated and will be removed when it becomes unused.
53
+ * Please use bus_cold_reset() now.
54
*/
55
void qbus_reset_all(BusState *bus);
56
void qbus_reset_all_fn(void *opaque);
57
58
+/**
59
+ * device_cold_reset:
60
+ * Reset device @dev and perform a recursive processing using the resettable
61
+ * interface. It triggers a RESET_TYPE_COLD.
62
+ */
63
+void device_cold_reset(DeviceState *dev);
64
+
65
+/**
66
+ * bus_cold_reset:
67
+ *
68
+ * Reset bus @bus and perform a recursive processing using the resettable
69
+ * interface. It triggers a RESET_TYPE_COLD.
70
+ */
71
+void bus_cold_reset(BusState *bus);
72
+
73
/**
74
* device_is_in_reset:
75
* Return true if the device @dev is currently being reset.
76
@@ -XXX,XX +XXX,XX @@ void qdev_machine_init(void);
77
* device_legacy_reset:
78
*
79
* Reset a single device (by calling the reset method).
80
+ * Note: This function is deprecated and will be removed when it becomes unused.
81
+ * Please use device_cold_reset() now.
82
*/
83
void device_legacy_reset(DeviceState *dev);
84
85
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
27
index XXXXXXX..XXXXXXX 100644
86
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/helper.h
87
--- a/include/hw/resettable.h
29
+++ b/target/arm/helper.h
88
+++ b/include/hw/resettable.h
30
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
89
@@ -XXX,XX +XXX,XX @@ bool resettable_is_in_reset(Object *obj);
31
90
*/
32
DEF_HELPER_1(v7m_preserve_fp_state, void, env)
91
void resettable_change_parent(Object *obj, Object *newp, Object *oldp);
33
92
34
+DEF_HELPER_2(v7m_vlstm, void, env, i32)
93
+/**
94
+ * resettable_cold_reset_fn:
95
+ * Helper to call resettable_reset((Object *) opaque, RESET_TYPE_COLD).
96
+ *
97
+ * This function is typically useful to register a reset handler with
98
+ * qemu_register_reset.
99
+ */
100
+void resettable_cold_reset_fn(void *opaque);
35
+
101
+
36
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
102
/**
37
103
* resettable_class_set_parent_phases:
38
DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
104
*
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
105
diff --git a/hw/core/bus.c b/hw/core/bus.c
40
index XXXXXXX..XXXXXXX 100644
106
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/helper.c
107
--- a/hw/core/bus.c
42
+++ b/target/arm/helper.c
108
+++ b/hw/core/bus.c
43
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
109
@@ -XXX,XX +XXX,XX @@ int qbus_walk_children(BusState *bus,
44
g_assert_not_reached();
110
return 0;
45
}
111
}
46
112
47
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
113
+void bus_cold_reset(BusState *bus)
48
+{
114
+{
49
+ /* translate.c should never generate calls here in user-only mode */
115
+ resettable_reset(OBJECT(bus), RESET_TYPE_COLD);
50
+ g_assert_not_reached();
51
+}
116
+}
52
+
117
+
53
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
118
bool bus_is_in_reset(BusState *bus)
54
{
119
{
55
/* The TT instructions can be used by unprivileged code, but in
120
return resettable_is_in_reset(OBJECT(bus));
56
@@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
121
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/hw/core/qdev.c
124
+++ b/hw/core/qdev.c
125
@@ -XXX,XX +XXX,XX @@ void qbus_reset_all_fn(void *opaque)
126
qbus_reset_all(bus);
127
}
128
129
+void device_cold_reset(DeviceState *dev)
130
+{
131
+ resettable_reset(OBJECT(dev), RESET_TYPE_COLD);
132
+}
133
+
134
bool device_is_in_reset(DeviceState *dev)
135
{
136
return resettable_is_in_reset(OBJECT(dev));
137
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
138
index XXXXXXX..XXXXXXX 100644
139
--- a/hw/core/resettable.c
140
+++ b/hw/core/resettable.c
141
@@ -XXX,XX +XXX,XX @@ void resettable_change_parent(Object *obj, Object *newp, Object *oldp)
57
}
142
}
58
}
143
}
59
144
60
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
145
+void resettable_cold_reset_fn(void *opaque)
61
+{
146
+{
62
+ /* fptr is the value of Rn, the frame pointer we store the FP regs to */
147
+ resettable_reset((Object *) opaque, RESET_TYPE_COLD);
63
+ bool s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
64
+ bool lspact = env->v7m.fpccr[s] & R_V7M_FPCCR_LSPACT_MASK;
65
+
66
+ assert(env->v7m.secure);
67
+
68
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
69
+ return;
70
+ }
71
+
72
+ /* Check access to the coprocessor is permitted */
73
+ if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) {
74
+ raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC());
75
+ }
76
+
77
+ if (lspact) {
78
+ /* LSPACT should not be active when there is active FP state */
79
+ raise_exception_ra(env, EXCP_LSERR, 0, 1, GETPC());
80
+ }
81
+
82
+ if (fptr & 7) {
83
+ raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC());
84
+ }
85
+
86
+ /*
87
+ * Note that we do not use v7m_stack_write() here, because the
88
+ * accesses should not set the FSR bits for stacking errors if they
89
+ * fail. (In pseudocode terms, they are AccType_NORMAL, not AccType_STACK
90
+ * or AccType_LAZYFP). Faults in cpu_stl_data() will throw exceptions
91
+ * and longjmp out.
92
+ */
93
+ if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) {
94
+ bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK;
95
+ int i;
96
+
97
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
98
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
99
+ uint32_t faddr = fptr + 4 * i;
100
+ uint32_t slo = extract64(dn, 0, 32);
101
+ uint32_t shi = extract64(dn, 32, 32);
102
+
103
+ if (i >= 16) {
104
+ faddr += 8; /* skip the slot for the FPSCR */
105
+ }
106
+ cpu_stl_data(env, faddr, slo);
107
+ cpu_stl_data(env, faddr + 4, shi);
108
+ }
109
+ cpu_stl_data(env, fptr + 0x40, vfp_get_fpscr(env));
110
+
111
+ /*
112
+ * If TS is 0 then s0 to s15 and FPSCR are UNKNOWN; we choose to
113
+ * leave them unchanged, matching our choice in v7m_preserve_fp_state.
114
+ */
115
+ if (ts) {
116
+ for (i = 0; i < 32; i += 2) {
117
+ *aa32_vfp_dreg(env, i / 2) = 0;
118
+ }
119
+ vfp_set_fpscr(env, 0);
120
+ }
121
+ } else {
122
+ v7m_update_fpccr(env, fptr, false);
123
+ }
124
+
125
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
126
+}
148
+}
127
+
149
+
128
static bool v7m_push_stack(ARMCPU *cpu)
150
void resettable_class_set_parent_phases(ResettableClass *rc,
129
{
151
ResettableEnterPhase enter,
130
/* Do the "set up stack frame" part of exception entry,
152
ResettableHoldPhase hold,
131
@@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx)
132
[EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
133
[EXCP_STKOF] = "v8M STKOF UsageFault",
134
[EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
135
+ [EXCP_LSERR] = "v8M LSERR UsageFault",
136
+ [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault",
137
};
138
139
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
140
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
141
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
142
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_STKOF_MASK;
143
break;
144
+ case EXCP_LSERR:
145
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
146
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
147
+ break;
148
+ case EXCP_UNALIGNED:
149
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
150
+ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK;
151
+ break;
152
case EXCP_SWI:
153
/* The PC already points to the next instruction. */
154
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);
155
diff --git a/target/arm/translate.c b/target/arm/translate.c
156
index XXXXXXX..XXXXXXX 100644
157
--- a/target/arm/translate.c
158
+++ b/target/arm/translate.c
159
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
160
if (!s->v8m_secure || (insn & 0x0040f0ff)) {
161
goto illegal_op;
162
}
163
- /* Just NOP since FP support is not implemented */
164
+
165
+ if (arm_dc_feature(s, ARM_FEATURE_VFP)) {
166
+ TCGv_i32 fptr = load_reg(s, rn);
167
+
168
+ if (extract32(insn, 20, 1)) {
169
+ /* VLLDM */
170
+ } else {
171
+ gen_helper_v7m_vlstm(cpu_env, fptr);
172
+ }
173
+ tcg_temp_free_i32(fptr);
174
+
175
+ /* End the TB, because we have updated FP control bits */
176
+ s->base.is_jmp = DISAS_UPDATE;
177
+ }
178
break;
179
}
180
if (arm_dc_feature(s, ARM_FEATURE_VFP) &&
181
--
153
--
182
2.20.1
154
2.20.1
183
155
184
156
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20190412165416.7977-8-philmd@redhat.com
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200123132823.1117486-10-damien.hedde@greensocs.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
---
8
include/hw/devices.h | 3 ---
9
docs/devel/index.rst | 1 +
9
include/hw/input/gamepad.h | 19 +++++++++++++++++++
10
docs/devel/reset.rst | 289 +++++++++++++++++++++++++++++++++++++++++++
10
hw/arm/stellaris.c | 2 +-
11
2 files changed, 290 insertions(+)
11
hw/input/stellaris_input.c | 2 +-
12
create mode 100644 docs/devel/reset.rst
12
MAINTAINERS | 1 +
13
5 files changed, 22 insertions(+), 5 deletions(-)
14
create mode 100644 include/hw/input/gamepad.h
15
13
16
diff --git a/include/hw/devices.h b/include/hw/devices.h
14
diff --git a/docs/devel/index.rst b/docs/devel/index.rst
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/devices.h
16
--- a/docs/devel/index.rst
19
+++ b/include/hw/devices.h
17
+++ b/docs/devel/index.rst
20
@@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav);
18
@@ -XXX,XX +XXX,XX @@ Contents:
21
uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
19
tcg
22
void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
20
tcg-plugins
23
21
bitops
24
-/* stellaris_input.c */
22
+ reset
25
-void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
23
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
26
-
27
#endif
28
diff --git a/include/hw/input/gamepad.h b/include/hw/input/gamepad.h
29
new file mode 100644
24
new file mode 100644
30
index XXXXXXX..XXXXXXX
25
index XXXXXXX..XXXXXXX
31
--- /dev/null
26
--- /dev/null
32
+++ b/include/hw/input/gamepad.h
27
+++ b/docs/devel/reset.rst
33
@@ -XXX,XX +XXX,XX @@
28
@@ -XXX,XX +XXX,XX @@
34
+/*
29
+
35
+ * Gamepad style buttons connected to IRQ/GPIO lines
30
+=======================================
36
+ *
31
+Reset in QEMU: the Resettable interface
37
+ * Copyright (c) 2007 CodeSourcery.
32
+=======================================
38
+ * Written by Paul Brook
33
+
39
+ *
34
+The reset of qemu objects is handled using the resettable interface declared
40
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
35
+in ``include/hw/resettable.h``.
41
+ * See the COPYING file in the top-level directory.
36
+
42
+ */
37
+This interface allows objects to be grouped (on a tree basis); so that the
43
+
38
+whole group can be reset consistently. Each individual member object does not
44
+#ifndef HW_INPUT_GAMEPAD_H
39
+have to care about others; in particular, problems of order (which object is
45
+#define HW_INPUT_GAMEPAD_H
40
+reset first) are addressed.
46
+
41
+
47
+#include "hw/irq.h"
42
+As of now DeviceClass and BusClass implement this interface.
48
+
43
+
49
+/* stellaris_input.c */
44
+
50
+void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
45
+Triggering reset
51
+
46
+----------------
52
+#endif
47
+
53
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
48
+This section documents the APIs which "users" of a resettable object should use
54
index XXXXXXX..XXXXXXX 100644
49
+to control it. All resettable control functions must be called while holding
55
--- a/hw/arm/stellaris.c
50
+the iothread lock.
56
+++ b/hw/arm/stellaris.c
51
+
57
@@ -XXX,XX +XXX,XX @@
52
+You can apply a reset to an object using ``resettable_assert_reset()``. You need
58
#include "hw/sysbus.h"
53
+to call ``resettable_release_reset()`` to release the object from reset. To
59
#include "hw/ssi/ssi.h"
54
+instantly reset an object, without keeping it in reset state, just call
60
#include "hw/arm/arm.h"
55
+``resettable_reset()``. These functions take two parameters: a pointer to the
61
-#include "hw/devices.h"
56
+object to reset and a reset type.
62
#include "qemu/timer.h"
57
+
63
#include "hw/i2c/i2c.h"
58
+Several types of reset will be supported. For now only cold reset is defined;
64
#include "net/net.h"
59
+others may be added later. The Resettable interface handles reset types with an
65
@@ -XXX,XX +XXX,XX @@
60
+enum:
66
#include "sysemu/sysemu.h"
61
+
67
#include "hw/arm/armv7m.h"
62
+``RESET_TYPE_COLD``
68
#include "hw/char/pl011.h"
63
+ Cold reset is supported by every resettable object. In QEMU, it means we reset
69
+#include "hw/input/gamepad.h"
64
+ to the initial state corresponding to the start of QEMU; this might differ
70
#include "hw/watchdog/cmsdk-apb-watchdog.h"
65
+ from what is a real hardware cold reset. It differs from other resets (like
71
#include "hw/misc/unimp.h"
66
+ warm or bus resets) which may keep certain parts untouched.
72
#include "cpu.h"
67
+
73
diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
68
+Calling ``resettable_reset()`` is equivalent to calling
74
index XXXXXXX..XXXXXXX 100644
69
+``resettable_assert_reset()`` then ``resettable_release_reset()``. It is
75
--- a/hw/input/stellaris_input.c
70
+possible to interleave multiple calls to these three functions. There may
76
+++ b/hw/input/stellaris_input.c
71
+be several reset sources/controllers of a given object. The interface handles
77
@@ -XXX,XX +XXX,XX @@
72
+everything and the different reset controllers do not need to know anything
78
*/
73
+about each others. The object will leave reset state only when each other
79
#include "qemu/osdep.h"
74
+controllers end their reset operation. This point is handled internally by
80
#include "hw/hw.h"
75
+maintaining a count of in-progress resets; it is crucial to call
81
-#include "hw/devices.h"
76
+``resettable_release_reset()`` one time and only one time per
82
+#include "hw/input/gamepad.h"
77
+``resettable_assert_reset()`` call.
83
#include "ui/console.h"
78
+
84
79
+For now migration of a device or bus in reset is not supported. Care must be
85
typedef struct {
80
+taken not to delay ``resettable_release_reset()`` after its
86
diff --git a/MAINTAINERS b/MAINTAINERS
81
+``resettable_assert_reset()`` counterpart.
87
index XXXXXXX..XXXXXXX 100644
82
+
88
--- a/MAINTAINERS
83
+Note that, since resettable is an interface, the API takes a simple Object as
89
+++ b/MAINTAINERS
84
+parameter. Still, it is a programming error to call a resettable function on a
90
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
85
+non-resettable object and it will trigger a run time assert error. Since most
91
L: qemu-arm@nongnu.org
86
+calls to resettable interface are done through base class functions, such an
92
S: Maintained
87
+error is not likely to happen.
93
F: hw/*/stellaris*
88
+
94
+F: include/hw/input/gamepad.h
89
+For Devices and Buses, the following helper functions exist:
95
90
+
96
Versatile Express
91
+- ``device_cold_reset()``
97
M: Peter Maydell <peter.maydell@linaro.org>
92
+- ``bus_cold_reset()``
93
+
94
+These are simple wrappers around resettable_reset() function; they only cast the
95
+Device or Bus into an Object and pass the cold reset type. When possible
96
+prefer to use these functions instead of ``resettable_reset()``.
97
+
98
+Device and bus functions co-exist because there can be semantic differences
99
+between resetting a bus and resetting the controller bridge which owns it.
100
+For example, consider a SCSI controller. Resetting the controller puts all
101
+its registers back to what reset state was as well as reset everything on the
102
+SCSI bus, whereas resetting just the SCSI bus only resets everything that's on
103
+it but not the controller.
104
+
105
+
106
+Multi-phase mechanism
107
+---------------------
108
+
109
+This section documents the internals of the resettable interface.
110
+
111
+The resettable interface uses a multi-phase system to relieve objects and
112
+machines from reset ordering problems. To address this, the reset operation
113
+of an object is split into three well defined phases.
114
+
115
+When resetting several objects (for example the whole machine at simulation
116
+startup), all first phases of all objects are executed, then all second phases
117
+and then all third phases.
118
+
119
+The three phases are:
120
+
121
+1. The **enter** phase is executed when the object enters reset. It resets only
122
+ local state of the object; it must not do anything that has a side-effect
123
+ on other objects, such as raising or lowering a qemu_irq line or reading or
124
+ writing guest memory.
125
+
126
+2. The **hold** phase is executed for entry into reset, once every object in the
127
+ group which is being reset has had its *enter* phase executed. At this point
128
+ devices can do actions that affect other objects.
129
+
130
+3. The **exit** phase is executed when the object leaves the reset state.
131
+ Actions affecting other objects are permitted.
132
+
133
+As said in previous section, the interface maintains a count of reset. This
134
+count is used to ensure phases are executed only when required. *enter* and
135
+*hold* phases are executed only when asserting reset for the first time
136
+(if an object is already in reset state when calling
137
+``resettable_assert_reset()`` or ``resettable_reset()``, they are not
138
+executed).
139
+The *exit* phase is executed only when the last reset operation ends. Therefore
140
+the object does not need to care how many of reset controllers it has and how
141
+many of them have started a reset.
142
+
143
+
144
+Handling reset in a resettable object
145
+-------------------------------------
146
+
147
+This section documents the APIs that an implementation of a resettable object
148
+must provide and what functions it has access to. It is intended for people
149
+who want to implement or convert a class which has the resettable interface;
150
+for example when specializing an existing device or bus.
151
+
152
+Methods to implement
153
+....................
154
+
155
+Three methods should be defined or left empty. Each method corresponds to a
156
+phase of the reset; they are name ``phases.enter()``, ``phases.hold()`` and
157
+``phases.exit()``. They all take the object as parameter. The *enter* method
158
+also take the reset type as second parameter.
159
+
160
+When extending an existing class, these methods may need to be extended too.
161
+The ``resettable_class_set_parent_phases()`` class function may be used to
162
+backup parent class methods.
163
+
164
+Here follows an example to implement reset for a Device which sets an IO while
165
+in reset.
166
+
167
+::
168
+
169
+ static void mydev_reset_enter(Object *obj, ResetType type)
170
+ {
171
+ MyDevClass *myclass = MYDEV_GET_CLASS(obj);
172
+ MyDevState *mydev = MYDEV(obj);
173
+ /* call parent class enter phase */
174
+ if (myclass->parent_phases.enter) {
175
+ myclass->parent_phases.enter(obj, type);
176
+ }
177
+ /* initialize local state only */
178
+ mydev->var = 0;
179
+ }
180
+
181
+ static void mydev_reset_hold(Object *obj)
182
+ {
183
+ MyDevClass *myclass = MYDEV_GET_CLASS(obj);
184
+ MyDevState *mydev = MYDEV(obj);
185
+ /* call parent class hold phase */
186
+ if (myclass->parent_phases.hold) {
187
+ myclass->parent_phases.hold(obj);
188
+ }
189
+ /* set an IO */
190
+ qemu_set_irq(mydev->irq, 1);
191
+ }
192
+
193
+ static void mydev_reset_exit(Object *obj)
194
+ {
195
+ MyDevClass *myclass = MYDEV_GET_CLASS(obj);
196
+ MyDevState *mydev = MYDEV(obj);
197
+ /* call parent class exit phase */
198
+ if (myclass->parent_phases.exit) {
199
+ myclass->parent_phases.exit(obj);
200
+ }
201
+ /* clear an IO */
202
+ qemu_set_irq(mydev->irq, 0);
203
+ }
204
+
205
+ typedef struct MyDevClass {
206
+ MyParentClass parent_class;
207
+ /* to store eventual parent reset methods */
208
+ ResettablePhases parent_phases;
209
+ } MyDevClass;
210
+
211
+ static void mydev_class_init(ObjectClass *class, void *data)
212
+ {
213
+ MyDevClass *myclass = MYDEV_CLASS(class);
214
+ ResettableClass *rc = RESETTABLE_CLASS(class);
215
+ resettable_class_set_parent_reset_phases(rc,
216
+ mydev_reset_enter,
217
+ mydev_reset_hold,
218
+ mydev_reset_exit,
219
+ &myclass->parent_phases);
220
+ }
221
+
222
+In the above example, we override all three phases. It is possible to override
223
+only some of them by passing NULL instead of a function pointer to
224
+``resettable_class_set_parent_reset_phases()``. For example, the following will
225
+only override the *enter* phase and leave *hold* and *exit* untouched::
226
+
227
+ resettable_class_set_parent_reset_phases(rc, mydev_reset_enter,
228
+ NULL, NULL,
229
+ &myclass->parent_phases);
230
+
231
+This is equivalent to providing a trivial implementation of the hold and exit
232
+phases which does nothing but call the parent class's implementation of the
233
+phase.
234
+
235
+Polling the reset state
236
+.......................
237
+
238
+Resettable interface provides the ``resettable_is_in_reset()`` function.
239
+This function returns true if the object parameter is currently under reset.
240
+
241
+An object is under reset from the beginning of the *init* phase to the end of
242
+the *exit* phase. During all three phases, the function will return that the
243
+object is in reset.
244
+
245
+This function may be used if the object behavior has to be adapted
246
+while in reset state. For example if a device has an irq input,
247
+it will probably need to ignore it while in reset; then it can for
248
+example check the reset state at the beginning of the irq callback.
249
+
250
+Note that until migration of the reset state is supported, an object
251
+should not be left in reset. So apart from being currently executing
252
+one of the reset phases, the only cases when this function will return
253
+true is if an external interaction (like changing an io) is made during
254
+*hold* or *exit* phase of another object in the same reset group.
255
+
256
+Helpers ``device_is_in_reset()`` and ``bus_is_in_reset()`` are also provided
257
+for devices and buses and should be preferred.
258
+
259
+
260
+Base class handling of reset
261
+----------------------------
262
+
263
+This section documents parts of the reset mechanism that you only need to know
264
+about if you are extending it to work with a new base class other than
265
+DeviceClass or BusClass, or maintaining the existing code in those classes. Most
266
+people can ignore it.
267
+
268
+Methods to implement
269
+....................
270
+
271
+There are two other methods that need to exist in a class implementing the
272
+interface: ``get_state()`` and ``child_foreach()``.
273
+
274
+``get_state()`` is simple. *resettable* is an interface and, as a consequence,
275
+does not have any class state structure. But in order to factorize the code, we
276
+need one. This method must return a pointer to ``ResettableState`` structure.
277
+The structure must be allocated by the base class; preferably it should be
278
+located inside the object instance structure.
279
+
280
+``child_foreach()`` is more complex. It should execute the given callback on
281
+every reset child of the given resettable object. All children must be
282
+resettable too. Additional parameters (a reset type and an opaque pointer) must
283
+be passed to the callback too.
284
+
285
+In ``DeviceClass`` and ``BusClass`` the ``ResettableState`` is located
286
+``DeviceState`` and ``BusState`` structure. ``child_foreach()`` is implemented
287
+to follow the bus hierarchy; for a bus, it calls the function on every child
288
+device; for a device, it calls the function on every bus child. When we reset
289
+the main system bus, we reset the whole machine bus tree.
290
+
291
+Changing a resettable parent
292
+............................
293
+
294
+One thing which should be taken care of by the base class is handling reset
295
+hierarchy changes.
296
+
297
+The reset hierarchy is supposed to be static and built during machine creation.
298
+But there are actually some exceptions. To cope with this, the resettable API
299
+provides ``resettable_change_parent()``. This function allows to set, update or
300
+remove the parent of a resettable object after machine creation is done. As
301
+parameters, it takes the object being moved, the old parent if any and the new
302
+parent if any.
303
+
304
+This function can be used at any time when not in a reset operation. During
305
+a reset operation it must be used only in *hold* phase. Using it in *enter* or
306
+*exit* phase is an error.
307
+Also it should not be used during machine creation, although it is harmless to
308
+do so: the function is a no-op as long as old and new parent are NULL or not
309
+in reset.
310
+
311
+There is currently 2 cases where this function is used:
312
+
313
+1. *device hotplug*; it means a new device is introduced on a live bus.
314
+
315
+2. *hot bus change*; it means an existing live device is added, moved or
316
+ removed in the bus hierarchy. At the moment, it occurs only in the raspi
317
+ machines for changing the sdbus used by sd card.
98
--
318
--
99
2.20.1
319
2.20.1
100
320
101
321
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
Replace deprecated qbus_reset_all by resettable_cold_reset_fn for
4
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
the sysbus reset registration.
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
6
Message-id: 20190412165416.7977-7-philmd@redhat.com
6
Apart for the raspi machines, this does not impact the behavior
7
because:
8
+ at this point resettable just calls the old reset methods of devices
9
and buses in the same order as qdev/qbus.
10
+ resettable handlers registered with qemu_register_reset are
11
serialized; there is no interleaving.
12
+ eventual explicit calls to legacy reset API (device_reset or
13
qdev/qbus_reset) inside this reset handler will not be masked out
14
by resettable mechanism; they do not go through resettable api.
15
16
For the raspi machines, during the sysbus reset the sd-card is not
17
reset twice anymore but only once. This is a consequence of switching
18
both sysbus reset and changing parent to resettable; it detects the
19
second reset is not needed. This has no impact on the state after
20
reset; the sd-card reset method only reset local state and query
21
information from the block backend.
22
23
The raspi reset change can be observed by using the following command
24
(reset will occurs, then do Ctrl-C to end qemu; no firmware is
25
given here).
26
qemu-system-aarch64 -M raspi3 \
27
-trace resettable_phase_hold_exec \
28
-trace qdev_update_parent_bus \
29
-trace resettable_change_parent \
30
-trace qdev_reset -trace qbus_reset
31
32
Before the patch, the qdev/qbus_reset traces show when reset method are
33
called. After the patch, the resettable_phase_hold_exec show when reset
34
method are called.
35
36
The traced reset order of the raspi3 is listed below. I've added empty
37
lines and the tree structure.
38
39
+->bcm2835-peripherals reset
40
|
41
| +->sd-card reset
42
| +->sd-bus reset
43
+->bcm2835_gpio reset
44
| -> dev_update_parent_bus (move the sd-card on the sdhci-bus)
45
| -> resettable_change_parent
46
|
47
+->bcm2835-dma reset
48
|
49
| +->bcm2835-sdhost-bus reset
50
+->bcm2835-sdhost reset
51
|
52
| +->sd-card (reset ONLY BEFORE BEFORE THE PATCH)
53
| +->sdhci-bus reset
54
+->generic-sdhci reset
55
|
56
+->bcm2835-rng reset
57
+->bcm2835-property reset
58
+->bcm2835-fb reset
59
+->bcm2835-mbox reset
60
+->bcm2835-aux reset
61
+->pl011 reset
62
+->bcm2835-ic reset
63
+->bcm2836-control reset
64
System reset
65
66
In both case, the sd-card is reset (being on bcm2835_gpio/sd-bus) then moved
67
to generic-sdhci/sdhci-bus by the bcm2835_gpio reset method.
68
69
Before the patch, it is then reset again being part of generic-sdhci/sdhci-bus.
70
After the patch, it considered again for reset but its reset method is not
71
called because it is already flagged as reset.
72
73
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
74
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
75
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
76
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
77
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
78
Message-id: 20200123132823.1117486-11-damien.hedde@greensocs.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
79
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
80
---
9
include/hw/devices.h | 14 --------------
81
vl.c | 10 +++++++++-
10
include/hw/misc/cbus.h | 32 ++++++++++++++++++++++++++++++++
82
1 file changed, 9 insertions(+), 1 deletion(-)
11
hw/arm/nseries.c | 1 +
12
hw/misc/cbus.c | 2 +-
13
MAINTAINERS | 1 +
14
5 files changed, 35 insertions(+), 15 deletions(-)
15
create mode 100644 include/hw/misc/cbus.h
16
83
17
diff --git a/include/hw/devices.h b/include/hw/devices.h
84
diff --git a/vl.c b/vl.c
18
index XXXXXXX..XXXXXXX 100644
85
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/devices.h
86
--- a/vl.c
20
+++ b/include/hw/devices.h
87
+++ b/vl.c
21
@@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
88
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
22
/* stellaris_input.c */
89
23
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
90
/* TODO: once all bus devices are qdevified, this should be done
24
91
* when bus is created by qdev.c */
25
-/* cbus.c */
92
- qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
26
-typedef struct {
93
+ /*
27
- qemu_irq clk;
94
+ * TODO: If we had a main 'reset container' that the whole system
28
- qemu_irq dat;
95
+ * lived in, we could reset that using the multi-phase reset
29
- qemu_irq sel;
96
+ * APIs. For the moment, we just reset the sysbus, which will cause
30
-} CBus;
97
+ * all devices hanging off it (and all their child buses, recursively)
31
-CBus *cbus_init(qemu_irq dat_out);
98
+ * to be reset. Note that this will *not* reset any Device objects
32
-void cbus_attach(CBus *bus, void *slave_opaque);
99
+ * which are not attached to some part of the qbus tree!
33
-
100
+ */
34
-void *retu_init(qemu_irq irq, int vilma);
101
+ qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default());
35
-void *tahvo_init(qemu_irq irq, int betty);
102
qemu_run_machine_init_done_notifiers();
36
-
103
37
-void retu_key_event(void *retu, int state);
104
if (rom_check_and_register_reset() != 0) {
38
-
39
#endif
40
diff --git a/include/hw/misc/cbus.h b/include/hw/misc/cbus.h
41
new file mode 100644
42
index XXXXXXX..XXXXXXX
43
--- /dev/null
44
+++ b/include/hw/misc/cbus.h
45
@@ -XXX,XX +XXX,XX @@
46
+/*
47
+ * CBUS three-pin bus and the Retu / Betty / Tahvo / Vilma / Avilma /
48
+ * Hinku / Vinku / Ahne / Pihi chips used in various Nokia platforms.
49
+ * Based on reverse-engineering of a linux driver.
50
+ *
51
+ * Copyright (C) 2008 Nokia Corporation
52
+ * Written by Andrzej Zaborowski
53
+ *
54
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
55
+ * See the COPYING file in the top-level directory.
56
+ */
57
+
58
+#ifndef HW_MISC_CBUS_H
59
+#define HW_MISC_CBUS_H
60
+
61
+#include "hw/irq.h"
62
+
63
+typedef struct {
64
+ qemu_irq clk;
65
+ qemu_irq dat;
66
+ qemu_irq sel;
67
+} CBus;
68
+
69
+CBus *cbus_init(qemu_irq dat_out);
70
+void cbus_attach(CBus *bus, void *slave_opaque);
71
+
72
+void *retu_init(qemu_irq irq, int vilma);
73
+void *tahvo_init(qemu_irq irq, int betty);
74
+
75
+void retu_key_event(void *retu, int state);
76
+
77
+#endif
78
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/arm/nseries.c
81
+++ b/hw/arm/nseries.c
82
@@ -XXX,XX +XXX,XX @@
83
#include "hw/i2c/i2c.h"
84
#include "hw/devices.h"
85
#include "hw/display/blizzard.h"
86
+#include "hw/misc/cbus.h"
87
#include "hw/misc/tmp105.h"
88
#include "hw/block/flash.h"
89
#include "hw/hw.h"
90
diff --git a/hw/misc/cbus.c b/hw/misc/cbus.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/hw/misc/cbus.c
93
+++ b/hw/misc/cbus.c
94
@@ -XXX,XX +XXX,XX @@
95
#include "qemu/osdep.h"
96
#include "hw/hw.h"
97
#include "hw/irq.h"
98
-#include "hw/devices.h"
99
+#include "hw/misc/cbus.h"
100
#include "sysemu/sysemu.h"
101
102
//#define DEBUG
103
diff --git a/MAINTAINERS b/MAINTAINERS
104
index XXXXXXX..XXXXXXX 100644
105
--- a/MAINTAINERS
106
+++ b/MAINTAINERS
107
@@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c
108
F: hw/misc/cbus.c
109
F: hw/timer/twl92230.c
110
F: include/hw/display/blizzard.h
111
+F: include/hw/misc/cbus.h
112
113
Palm
114
M: Andrzej Zaborowski <balrogg@gmail.com>
115
--
105
--
116
2.20.1
106
2.20.1
117
107
118
108
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
2
3
Add an entries the Blizzard device in MAINTAINERS.
3
Replace deprecated qdev_reset_all by resettable_cold_reset_fn for
4
the ipl registration in the main reset handlers.
4
5
5
Reviewed-by: Thomas Huth <thuth@redhat.com>
6
This does not impact the behavior for the following reasons:
6
Reviewed-by: Markus Armbruster <armbru@redhat.com>
7
+ at this point resettable just call the old reset methods of devices
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
and buses in the same order than qdev/qbus.
8
Message-id: 20190412165416.7977-6-philmd@redhat.com
9
+ resettable handlers registered with qemu_register_reset are
10
serialized; there is no interleaving.
11
+ eventual explicit calls to legacy reset API (device_reset or
12
qdev/qbus_reset) inside this reset handler will not be masked out
13
by resettable mechanism; they do not go through resettable api.
14
15
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20200123132823.1117486-12-damien.hedde@greensocs.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
22
---
11
include/hw/devices.h | 7 -------
23
hw/s390x/ipl.c | 10 +++++++++-
12
include/hw/display/blizzard.h | 22 ++++++++++++++++++++++
24
1 file changed, 9 insertions(+), 1 deletion(-)
13
hw/arm/nseries.c | 1 +
14
hw/display/blizzard.c | 2 +-
15
MAINTAINERS | 2 ++
16
5 files changed, 26 insertions(+), 8 deletions(-)
17
create mode 100644 include/hw/display/blizzard.h
18
25
19
diff --git a/include/hw/devices.h b/include/hw/devices.h
26
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
20
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/devices.h
28
--- a/hw/s390x/ipl.c
22
+++ b/include/hw/devices.h
29
+++ b/hw/s390x/ipl.c
23
@@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
30
@@ -XXX,XX +XXX,XX @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
24
/* stellaris_input.c */
31
*/
25
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
32
ipl->compat_start_addr = ipl->start_addr;
26
33
ipl->compat_bios_start_addr = ipl->bios_start_addr;
27
-/* blizzard.c */
34
- qemu_register_reset(qdev_reset_all_fn, dev);
28
-void *s1d13745_init(qemu_irq gpio_int);
35
+ /*
29
-void s1d13745_write(void *opaque, int dc, uint16_t value);
36
+ * Because this Device is not on any bus in the qbus tree (it is
30
-void s1d13745_write_block(void *opaque, int dc,
37
+ * not a sysbus device and it's not on some other bus like a PCI
31
- void *buf, size_t len, int pitch);
38
+ * bus) it will not be automatically reset by the 'reset the
32
-uint16_t s1d13745_read(void *opaque, int dc);
39
+ * sysbus' hook registered by vl.c like most devices. So we must
33
-
40
+ * manually register a reset hook for it.
34
/* cbus.c */
41
+ * TODO: there should be a better way to do this.
35
typedef struct {
42
+ */
36
qemu_irq clk;
43
+ qemu_register_reset(resettable_cold_reset_fn, dev);
37
diff --git a/include/hw/display/blizzard.h b/include/hw/display/blizzard.h
44
error:
38
new file mode 100644
45
error_propagate(errp, err);
39
index XXXXXXX..XXXXXXX
46
}
40
--- /dev/null
41
+++ b/include/hw/display/blizzard.h
42
@@ -XXX,XX +XXX,XX @@
43
+/*
44
+ * Epson S1D13744/S1D13745 (Blizzard/Hailstorm/Tornado) LCD/TV controller.
45
+ *
46
+ * Copyright (C) 2008 Nokia Corporation
47
+ * Written by Andrzej Zaborowski
48
+ *
49
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
50
+ * See the COPYING file in the top-level directory.
51
+ */
52
+
53
+#ifndef HW_DISPLAY_BLIZZARD_H
54
+#define HW_DISPLAY_BLIZZARD_H
55
+
56
+#include "hw/irq.h"
57
+
58
+void *s1d13745_init(qemu_irq gpio_int);
59
+void s1d13745_write(void *opaque, int dc, uint16_t value);
60
+void s1d13745_write_block(void *opaque, int dc,
61
+ void *buf, size_t len, int pitch);
62
+uint16_t s1d13745_read(void *opaque, int dc);
63
+
64
+#endif
65
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/hw/arm/nseries.c
68
+++ b/hw/arm/nseries.c
69
@@ -XXX,XX +XXX,XX @@
70
#include "hw/boards.h"
71
#include "hw/i2c/i2c.h"
72
#include "hw/devices.h"
73
+#include "hw/display/blizzard.h"
74
#include "hw/misc/tmp105.h"
75
#include "hw/block/flash.h"
76
#include "hw/hw.h"
77
diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/display/blizzard.c
80
+++ b/hw/display/blizzard.c
81
@@ -XXX,XX +XXX,XX @@
82
#include "qemu/osdep.h"
83
#include "qemu-common.h"
84
#include "ui/console.h"
85
-#include "hw/devices.h"
86
+#include "hw/display/blizzard.h"
87
#include "ui/pixel_ops.h"
88
89
typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
90
diff --git a/MAINTAINERS b/MAINTAINERS
91
index XXXXXXX..XXXXXXX 100644
92
--- a/MAINTAINERS
93
+++ b/MAINTAINERS
94
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
95
L: qemu-arm@nongnu.org
96
S: Odd Fixes
97
F: hw/arm/nseries.c
98
+F: hw/display/blizzard.c
99
F: hw/input/lm832x.c
100
F: hw/input/tsc2005.c
101
F: hw/misc/cbus.c
102
F: hw/timer/twl92230.c
103
+F: include/hw/display/blizzard.h
104
105
Palm
106
M: Andrzej Zaborowski <balrogg@gmail.com>
107
--
47
--
108
2.20.1
48
2.20.1
109
49
110
50
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Zenghui Yu <yuzenghui@huawei.com>
2
2
3
Suggested-by: Markus Armbruster <armbru@redhat.com>
3
If LPIs are disabled, KVM will just ignore the GICR_PENDBASER.PTZ bit when
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
restoring GICR_CTLR. Setting PTZ here makes littlt sense in "reduce GIC
5
Message-id: 20190412165416.7977-3-philmd@redhat.com
5
initialization time".
6
7
And what's worse, PTZ is generally programmed by guest to indicate to the
8
Redistributor whether the LPI Pending table is zero when enabling LPIs.
9
If migration is triggered when the PTZ has just been cleared by guest (and
10
before enabling LPIs), we will see PTZ==1 on the destination side, which
11
is not as expected. Let's just drop this hackish userspace behavior.
12
13
Also take this chance to refine the comment a bit.
14
15
Fixes: 367b9f527bec ("hw/intc/arm_gicv3_kvm: Implement get/put functions")
16
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
17
Message-id: 20200119133051.642-1-yuzenghui@huawei.com
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
20
---
9
hw/arm/nseries.c | 3 ++-
21
hw/intc/arm_gicv3_kvm.c | 11 ++++-------
10
1 file changed, 2 insertions(+), 1 deletion(-)
22
1 file changed, 4 insertions(+), 7 deletions(-)
11
23
12
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
24
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
13
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/arm/nseries.c
26
--- a/hw/intc/arm_gicv3_kvm.c
15
+++ b/hw/arm/nseries.c
27
+++ b/hw/intc/arm_gicv3_kvm.c
16
@@ -XXX,XX +XXX,XX @@
28
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_put(GICv3State *s)
17
#include "hw/boards.h"
29
kvm_gicd_access(s, GICD_CTLR, &reg, true);
18
#include "hw/i2c/i2c.h"
30
19
#include "hw/devices.h"
31
if (redist_typer & GICR_TYPER_PLPIS) {
20
+#include "hw/misc/tmp105.h"
32
- /* Set base addresses before LPIs are enabled by GICR_CTLR write */
21
#include "hw/block/flash.h"
33
+ /*
22
#include "hw/hw.h"
34
+ * Restore base addresses before LPIs are potentially enabled by
23
#include "hw/bt.h"
35
+ * GICR_CTLR write
24
@@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s)
36
+ */
25
qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier);
37
for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
26
38
GICv3CPUState *c = &s->cpu[ncpu];
27
/* Attach a TMP105 PM chip (A0 wired to ground) */
39
28
- dev = i2c_create_slave(i2c, "tmp105", N8X0_TMP105_ADDR);
40
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_put(GICv3State *s)
29
+ dev = i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR);
41
kvm_gicr_access(s, GICR_PROPBASER + 4, ncpu, &regh, true);
30
qdev_connect_gpio_out(dev, 0, tmp_irq);
42
31
}
43
reg64 = c->gicr_pendbaser;
32
44
- if (!(c->gicr_ctlr & GICR_CTLR_ENABLE_LPIS)) {
45
- /* Setting PTZ is advised if LPIs are disabled, to reduce
46
- * GIC initialization time.
47
- */
48
- reg64 |= GICR_PENDBASER_PTZ;
49
- }
50
regl = (uint32_t)reg64;
51
kvm_gicr_access(s, GICR_PENDBASER, ncpu, &regl, true);
52
regh = (uint32_t)(reg64 >> 32);
33
--
53
--
34
2.20.1
54
2.20.1
35
55
36
56
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Andrew Jones <drjones@redhat.com>
2
2
3
This device is used by both ARM (BCM2836, for raspi2) and AArch64
3
Signed-off-by: Andrew Jones <drjones@redhat.com>
4
(BCM2837, for raspi3) targets, and is not CPU-specific.
4
Message-id: 20200120101023.16030-2-drjones@redhat.com
5
Move it to common object, so we build it once for all targets.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20190427133028.12874-1-philmd@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
7
---
12
hw/dma/Makefile.objs | 2 +-
8
target/arm/kvm_arm.h | 46 ++++++++++++++++++++++++++------------------
13
1 file changed, 1 insertion(+), 1 deletion(-)
9
1 file changed, 27 insertions(+), 19 deletions(-)
14
10
15
diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs
11
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/dma/Makefile.objs
13
--- a/target/arm/kvm_arm.h
18
+++ b/hw/dma/Makefile.objs
14
+++ b/target/arm/kvm_arm.h
19
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zdma.o
15
@@ -XXX,XX +XXX,XX @@
20
16
int kvm_arm_vcpu_init(CPUState *cs);
21
obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o
17
22
obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o
18
/**
23
-obj-$(CONFIG_RASPI) += bcm2835_dma.o
19
- * kvm_arm_vcpu_finalize
24
+common-obj-$(CONFIG_RASPI) += bcm2835_dma.o
20
+ * kvm_arm_vcpu_finalize:
21
* @cs: CPUState
22
- * @feature: int
23
+ * @feature: feature to finalize
24
*
25
* Finalizes the configuration of the specified VCPU feature by
26
* invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring
27
@@ -XXX,XX +XXX,XX @@ void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
28
int kvm_arm_init_cpreg_list(ARMCPU *cpu);
29
30
/**
31
- * kvm_arm_reg_syncs_via_cpreg_list
32
- * regidx: KVM register index
33
+ * kvm_arm_reg_syncs_via_cpreg_list:
34
+ * @regidx: KVM register index
35
*
36
* Return true if this KVM register should be synchronized via the
37
* cpreg list of arbitrary system registers, false if it is synchronized
38
@@ -XXX,XX +XXX,XX @@ int kvm_arm_init_cpreg_list(ARMCPU *cpu);
39
bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx);
40
41
/**
42
- * kvm_arm_cpreg_level
43
- * regidx: KVM register index
44
+ * kvm_arm_cpreg_level:
45
+ * @regidx: KVM register index
46
*
47
* Return the level of this coprocessor/system register. Return value is
48
* either KVM_PUT_RUNTIME_STATE, KVM_PUT_RESET_STATE, or KVM_PUT_FULL_STATE.
49
@@ -XXX,XX +XXX,XX @@ void kvm_arm_init_serror_injection(CPUState *cs);
50
* @cpu: ARMCPU
51
*
52
* Get VCPU related state from kvm.
53
+ *
54
+ * Returns: 0 if success else < 0 error code
55
*/
56
int kvm_get_vcpu_events(ARMCPU *cpu);
57
58
@@ -XXX,XX +XXX,XX @@ int kvm_get_vcpu_events(ARMCPU *cpu);
59
* @cpu: ARMCPU
60
*
61
* Put VCPU related state to kvm.
62
+ *
63
+ * Returns: 0 if success else < 0 error code
64
*/
65
int kvm_put_vcpu_events(ARMCPU *cpu);
66
67
@@ -XXX,XX +XXX,XX @@ typedef struct ARMHostCPUFeatures {
68
69
/**
70
* kvm_arm_get_host_cpu_features:
71
- * @ahcc: ARMHostCPUClass to fill in
72
+ * @ahcf: ARMHostCPUClass to fill in
73
*
74
* Probe the capabilities of the host kernel's preferred CPU and fill
75
* in the ARMHostCPUClass struct accordingly.
76
+ *
77
+ * Returns true on success and false otherwise.
78
*/
79
bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf);
80
81
@@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);
82
bool kvm_arm_aarch32_supported(CPUState *cs);
83
84
/**
85
- * bool kvm_arm_pmu_supported:
86
+ * kvm_arm_pmu_supported:
87
* @cs: CPUState
88
*
89
* Returns: true if the KVM VCPU can enable its PMU
90
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_aarch32_supported(CPUState *cs);
91
bool kvm_arm_pmu_supported(CPUState *cs);
92
93
/**
94
- * bool kvm_arm_sve_supported:
95
+ * kvm_arm_sve_supported:
96
* @cs: CPUState
97
*
98
* Returns true if the KVM VCPU can enable SVE and false otherwise.
99
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_pmu_supported(CPUState *cs);
100
bool kvm_arm_sve_supported(CPUState *cs);
101
102
/**
103
- * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the
104
- * IPA address space supported by KVM
105
- *
106
+ * kvm_arm_get_max_vm_ipa_size:
107
* @ms: Machine state handle
108
+ *
109
+ * Returns the number of bits in the IPA address space supported by KVM
110
*/
111
int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
112
113
/**
114
- * kvm_arm_sync_mpstate_to_kvm
115
+ * kvm_arm_sync_mpstate_to_kvm:
116
* @cpu: ARMCPU
117
*
118
* If supported set the KVM MP_STATE based on QEMU's model.
119
+ *
120
+ * Returns 0 on success and -1 on failure.
121
*/
122
int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu);
123
124
/**
125
- * kvm_arm_sync_mpstate_to_qemu
126
+ * kvm_arm_sync_mpstate_to_qemu:
127
* @cpu: ARMCPU
128
*
129
* If supported get the MP_STATE from KVM and store in QEMU's model.
130
+ *
131
+ * Returns 0 on success and aborts on failure.
132
*/
133
int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu);
134
135
@@ -XXX,XX +XXX,XX @@ int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
136
137
static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
138
{
139
- /* This should never actually be called in the "not KVM" case,
140
+ /*
141
+ * This should never actually be called in the "not KVM" case,
142
* but set up the fields to indicate an error anyway.
143
*/
144
cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
145
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit);
146
*
147
* Return: TRUE if any hardware breakpoints in use.
148
*/
149
-
150
bool kvm_arm_hw_debug_active(CPUState *cs);
151
152
/**
153
* kvm_arm_copy_hw_debug_data:
154
- *
155
* @ptr: kvm_guest_debug_arch structure
156
*
157
* Copy the architecture specific debug registers into the
158
* kvm_guest_debug ioctl structure.
159
*/
160
struct kvm_guest_debug_arch;
161
-
162
void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr);
163
164
/**
165
- * its_class_name
166
+ * its_class_name:
167
*
168
* Return the ITS class name to use depending on whether KVM acceleration
169
* and KVM CAP_SIGNAL_MSI are supported
25
--
170
--
26
2.20.1
171
2.20.1
27
172
28
173
diff view generated by jsdifflib
1
If the floating point extension is present, then the SG instruction
1
From: Andrew Jones <drjones@redhat.com>
2
must clear the CONTROL_S.SFPA bit. Implement this.
3
2
4
(On a no-FPU system the bit will always be zero, so we don't need
3
Signed-off-by: Andrew Jones <drjones@redhat.com>
5
to make the clearing of the bit conditional on ARM_FEATURE_VFP.)
4
Message-id: 20200120101023.16030-3-drjones@redhat.com
6
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-8-peter.maydell@linaro.org
10
---
7
---
11
target/arm/helper.c | 1 +
8
hw/arm/virt.c | 1 +
12
1 file changed, 1 insertion(+)
9
1 file changed, 1 insertion(+)
13
10
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
11
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
15
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
13
--- a/hw/arm/virt.c
17
+++ b/target/arm/helper.c
14
+++ b/hw/arm/virt.c
18
@@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu)
15
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 0)
19
qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32
16
20
", executing it\n", env->regs[15]);
17
static void virt_machine_4_2_options(MachineClass *mc)
21
env->regs[14] &= ~1;
18
{
22
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
19
+ virt_machine_5_0_options(mc);
23
switch_v7m_security_state(env, true);
20
compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
24
xpsr_write(env, 0, XPSR_IT);
21
}
25
env->regs[15] += 4;
22
DEFINE_VIRT_MACHINE(4, 2)
26
--
23
--
27
2.20.1
24
2.20.1
28
25
29
26
diff view generated by jsdifflib
Deleted patch
1
The M-profile CONTROL register has two bits -- SFPA and FPCA --
2
which relate to floating-point support, and should be RES0 otherwise.
3
Handle them correctly in the MSR/MRS register access code.
4
Neither is banked between security states, so they are stored
5
in v7m.control[M_REG_S] regardless of current security state.
6
1
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-9-peter.maydell@linaro.org
10
---
11
target/arm/helper.c | 57 ++++++++++++++++++++++++++++++++++++++-------
12
1 file changed, 49 insertions(+), 8 deletions(-)
13
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
19
return xpsr_read(env) & mask;
20
break;
21
case 20: /* CONTROL */
22
- return env->v7m.control[env->v7m.secure];
23
+ {
24
+ uint32_t value = env->v7m.control[env->v7m.secure];
25
+ if (!env->v7m.secure) {
26
+ /* SFPA is RAZ/WI from NS; FPCA is stored in the M_REG_S bank */
27
+ value |= env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK;
28
+ }
29
+ return value;
30
+ }
31
case 0x94: /* CONTROL_NS */
32
/* We have to handle this here because unprivileged Secure code
33
* can read the NS CONTROL register.
34
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
35
if (!env->v7m.secure) {
36
return 0;
37
}
38
- return env->v7m.control[M_REG_NS];
39
+ return env->v7m.control[M_REG_NS] |
40
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK);
41
}
42
43
if (el == 0) {
44
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
45
*/
46
uint32_t mask = extract32(maskreg, 8, 4);
47
uint32_t reg = extract32(maskreg, 0, 8);
48
+ int cur_el = arm_current_el(env);
49
50
- if (arm_current_el(env) == 0 && reg > 7) {
51
- /* only xPSR sub-fields may be written by unprivileged */
52
+ if (cur_el == 0 && reg > 7 && reg != 20) {
53
+ /*
54
+ * only xPSR sub-fields and CONTROL.SFPA may be written by
55
+ * unprivileged code
56
+ */
57
return;
58
}
59
60
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
61
env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK;
62
env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK;
63
}
64
+ /*
65
+ * SFPA is RAZ/WI from NS. FPCA is RO if NSACR.CP10 == 0,
66
+ * RES0 if the FPU is not present, and is stored in the S bank
67
+ */
68
+ if (arm_feature(env, ARM_FEATURE_VFP) &&
69
+ extract32(env->v7m.nsacr, 10, 1)) {
70
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
71
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK;
72
+ }
73
return;
74
case 0x98: /* SP_NS */
75
{
76
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
77
env->v7m.faultmask[env->v7m.secure] = val & 1;
78
break;
79
case 20: /* CONTROL */
80
- /* Writing to the SPSEL bit only has an effect if we are in
81
+ /*
82
+ * Writing to the SPSEL bit only has an effect if we are in
83
* thread mode; other bits can be updated by any privileged code.
84
* write_v7m_control_spsel() deals with updating the SPSEL bit in
85
* env->v7m.control, so we only need update the others.
86
* For v7M, we must just ignore explicit writes to SPSEL in handler
87
* mode; for v8M the write is permitted but will have no effect.
88
+ * All these bits are writes-ignored from non-privileged code,
89
+ * except for SFPA.
90
*/
91
- if (arm_feature(env, ARM_FEATURE_V8) ||
92
- !arm_v7m_is_handler_mode(env)) {
93
+ if (cur_el > 0 && (arm_feature(env, ARM_FEATURE_V8) ||
94
+ !arm_v7m_is_handler_mode(env))) {
95
write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
96
}
97
- if (arm_feature(env, ARM_FEATURE_M_MAIN)) {
98
+ if (cur_el > 0 && arm_feature(env, ARM_FEATURE_M_MAIN)) {
99
env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK;
100
env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK;
101
}
102
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
103
+ /*
104
+ * SFPA is RAZ/WI from NS or if no FPU.
105
+ * FPCA is RO if NSACR.CP10 == 0, RES0 if the FPU is not present.
106
+ * Both are stored in the S bank.
107
+ */
108
+ if (env->v7m.secure) {
109
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
110
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_SFPA_MASK;
111
+ }
112
+ if (cur_el > 0 &&
113
+ (env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_SECURITY) ||
114
+ extract32(env->v7m.nsacr, 10, 1))) {
115
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
116
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK;
117
+ }
118
+ }
119
break;
120
default:
121
bad_reg:
122
--
123
2.20.1
124
125
diff view generated by jsdifflib
Deleted patch
1
Handle floating point registers in exception entry.
2
This corresponds to the FP-specific parts of the pseudocode
3
functions ActivateException() and PushStack().
4
1
5
We defer the code corresponding to UpdateFPCCR() to a later patch.
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-11-peter.maydell@linaro.org
10
---
11
target/arm/helper.c | 98 +++++++++++++++++++++++++++++++++++++++++++--
12
1 file changed, 95 insertions(+), 3 deletions(-)
13
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
19
switch_v7m_security_state(env, targets_secure);
20
write_v7m_control_spsel(env, 0);
21
arm_clear_exclusive(env);
22
+ /* Clear SFPA and FPCA (has no effect if no FPU) */
23
+ env->v7m.control[M_REG_S] &=
24
+ ~(R_V7M_CONTROL_FPCA_MASK | R_V7M_CONTROL_SFPA_MASK);
25
/* Clear IT bits */
26
env->condexec_bits = 0;
27
env->regs[14] = lr;
28
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
29
uint32_t xpsr = xpsr_read(env);
30
uint32_t frameptr = env->regs[13];
31
ARMMMUIdx mmu_idx = arm_mmu_idx(env);
32
+ uint32_t framesize;
33
+ bool nsacr_cp10 = extract32(env->v7m.nsacr, 10, 1);
34
+
35
+ if ((env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) &&
36
+ (env->v7m.secure || nsacr_cp10)) {
37
+ if (env->v7m.secure &&
38
+ env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK) {
39
+ framesize = 0xa8;
40
+ } else {
41
+ framesize = 0x68;
42
+ }
43
+ } else {
44
+ framesize = 0x20;
45
+ }
46
47
/* Align stack pointer if the guest wants that */
48
if ((frameptr & 4) &&
49
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
50
xpsr |= XPSR_SPREALIGN;
51
}
52
53
- frameptr -= 0x20;
54
+ xpsr &= ~XPSR_SFPA;
55
+ if (env->v7m.secure &&
56
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
57
+ xpsr |= XPSR_SFPA;
58
+ }
59
+
60
+ frameptr -= framesize;
61
62
if (arm_feature(env, ARM_FEATURE_V8)) {
63
uint32_t limit = v7m_sp_limit(env);
64
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
65
v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
66
v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
67
68
+ if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) {
69
+ /* FPU is active, try to save its registers */
70
+ bool fpccr_s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
71
+ bool lspact = env->v7m.fpccr[fpccr_s] & R_V7M_FPCCR_LSPACT_MASK;
72
+
73
+ if (lspact && arm_feature(env, ARM_FEATURE_M_SECURITY)) {
74
+ qemu_log_mask(CPU_LOG_INT,
75
+ "...SecureFault because LSPACT and FPCA both set\n");
76
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
77
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
78
+ } else if (!env->v7m.secure && !nsacr_cp10) {
79
+ qemu_log_mask(CPU_LOG_INT,
80
+ "...Secure UsageFault with CFSR.NOCP because "
81
+ "NSACR.CP10 prevents stacking FP regs\n");
82
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S);
83
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK;
84
+ } else {
85
+ if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) {
86
+ /* Lazy stacking disabled, save registers now */
87
+ int i;
88
+ bool cpacr_pass = v7m_cpacr_pass(env, env->v7m.secure,
89
+ arm_current_el(env) != 0);
90
+
91
+ if (stacked_ok && !cpacr_pass) {
92
+ /*
93
+ * Take UsageFault if CPACR forbids access. The pseudocode
94
+ * here does a full CheckCPEnabled() but we know the NSACR
95
+ * check can never fail as we have already handled that.
96
+ */
97
+ qemu_log_mask(CPU_LOG_INT,
98
+ "...UsageFault with CFSR.NOCP because "
99
+ "CPACR.CP10 prevents stacking FP regs\n");
100
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
101
+ env->v7m.secure);
102
+ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
103
+ stacked_ok = false;
104
+ }
105
+
106
+ for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
107
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
108
+ uint32_t faddr = frameptr + 0x20 + 4 * i;
109
+ uint32_t slo = extract64(dn, 0, 32);
110
+ uint32_t shi = extract64(dn, 32, 32);
111
+
112
+ if (i >= 16) {
113
+ faddr += 8; /* skip the slot for the FPSCR */
114
+ }
115
+ stacked_ok = stacked_ok &&
116
+ v7m_stack_write(cpu, faddr, slo, mmu_idx, false) &&
117
+ v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false);
118
+ }
119
+ stacked_ok = stacked_ok &&
120
+ v7m_stack_write(cpu, frameptr + 0x60,
121
+ vfp_get_fpscr(env), mmu_idx, false);
122
+ if (cpacr_pass) {
123
+ for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
124
+ *aa32_vfp_dreg(env, i / 2) = 0;
125
+ }
126
+ vfp_set_fpscr(env, 0);
127
+ }
128
+ } else {
129
+ /* Lazy stacking enabled, save necessary info to stack later */
130
+ /* TODO : equivalent of UpdateFPCCR() pseudocode */
131
+ }
132
+ }
133
+ }
134
+
135
/*
136
* If we broke a stack limit then SP was already updated earlier;
137
* otherwise we update SP regardless of whether any of the stack
138
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
139
140
if (arm_feature(env, ARM_FEATURE_V8)) {
141
lr = R_V7M_EXCRET_RES1_MASK |
142
- R_V7M_EXCRET_DCRS_MASK |
143
- R_V7M_EXCRET_FTYPE_MASK;
144
+ R_V7M_EXCRET_DCRS_MASK;
145
/* The S bit indicates whether we should return to Secure
146
* or NonSecure (ie our current state).
147
* The ES bit indicates whether we're taking this exception
148
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
149
if (env->v7m.secure) {
150
lr |= R_V7M_EXCRET_S_MASK;
151
}
152
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) {
153
+ lr |= R_V7M_EXCRET_FTYPE_MASK;
154
+ }
155
} else {
156
lr = R_V7M_EXCRET_RES1_MASK |
157
R_V7M_EXCRET_S_MASK |
158
--
159
2.20.1
160
161
diff view generated by jsdifflib
Deleted patch
1
For v8M floating point support, transitions from Secure
2
to Non-secure state via BLNS and BLXNS must clear the
3
CONTROL.SFPA bit. (This corresponds to the pseudocode
4
BranchToNS() function.)
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-13-peter.maydell@linaro.org
9
---
10
target/arm/helper.c | 4 ++++
11
1 file changed, 4 insertions(+)
12
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
18
/* translate.c should have made BXNS UNDEF unless we're secure */
19
assert(env->v7m.secure);
20
21
+ if (!(dest & 1)) {
22
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
23
+ }
24
switch_v7m_security_state(env, dest & 1);
25
env->thumb = 1;
26
env->regs[15] = dest & ~1;
27
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
28
*/
29
write_v7m_exception(env, 1);
30
}
31
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
32
switch_v7m_security_state(env, 0);
33
env->thumb = 1;
34
env->regs[15] = dest;
35
--
36
2.20.1
37
38
diff view generated by jsdifflib
Deleted patch
1
The TailChain() pseudocode specifies that a tail chaining
2
exception should sanitize the excReturn all-ones bits and
3
(if there is no FPU) the excReturn FType bits; we weren't
4
doing this.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-14-peter.maydell@linaro.org
9
---
10
target/arm/helper.c | 8 ++++++++
11
1 file changed, 8 insertions(+)
12
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
18
qemu_log_mask(CPU_LOG_INT, "...taking pending %s exception %d\n",
19
targets_secure ? "secure" : "nonsecure", exc);
20
21
+ if (dotailchain) {
22
+ /* Sanitize LR FType and PREFIX bits */
23
+ if (!arm_feature(env, ARM_FEATURE_VFP)) {
24
+ lr |= R_V7M_EXCRET_FTYPE_MASK;
25
+ }
26
+ lr = deposit32(lr, 24, 8, 0xff);
27
+ }
28
+
29
if (arm_feature(env, ARM_FEATURE_V8)) {
30
if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
31
(lr & R_V7M_EXCRET_S_MASK)) {
32
--
33
2.20.1
34
35
diff view generated by jsdifflib
Deleted patch
1
The magic value pushed onto the callee stack as an integrity
2
check is different if floating point is present.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20190416125744.27770-15-peter.maydell@linaro.org
7
---
8
target/arm/helper.c | 22 +++++++++++++++++++---
9
1 file changed, 19 insertions(+), 3 deletions(-)
10
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@ load_fail:
16
return false;
17
}
18
19
+static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr)
20
+{
21
+ /*
22
+ * Return the integrity signature value for the callee-saves
23
+ * stack frame section. @lr is the exception return payload/LR value
24
+ * whose FType bit forms bit 0 of the signature if FP is present.
25
+ */
26
+ uint32_t sig = 0xfefa125a;
27
+
28
+ if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) {
29
+ sig |= 1;
30
+ }
31
+ return sig;
32
+}
33
+
34
static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
35
bool ignore_faults)
36
{
37
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
38
bool stacked_ok;
39
uint32_t limit;
40
bool want_psp;
41
+ uint32_t sig;
42
43
if (dotailchain) {
44
bool mode = lr & R_V7M_EXCRET_MODE_MASK;
45
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
46
/* Write as much of the stack frame as we can. A write failure may
47
* cause us to pend a derived exception.
48
*/
49
+ sig = v7m_integrity_sig(env, lr);
50
stacked_ok =
51
- v7m_stack_write(cpu, frameptr, 0xfefa125b, mmu_idx, ignore_faults) &&
52
+ v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) &&
53
v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx,
54
ignore_faults) &&
55
v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx,
56
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
57
if (return_to_secure &&
58
((excret & R_V7M_EXCRET_ES_MASK) == 0 ||
59
(excret & R_V7M_EXCRET_DCRS_MASK) == 0)) {
60
- uint32_t expected_sig = 0xfefa125b;
61
uint32_t actual_sig;
62
63
pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx);
64
65
- if (pop_ok && expected_sig != actual_sig) {
66
+ if (pop_ok && v7m_integrity_sig(env, excret) != actual_sig) {
67
/* Take a SecureFault on the current stack */
68
env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
69
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
70
--
71
2.20.1
72
73
diff view generated by jsdifflib
Deleted patch
1
Move the NS TBFLAG down from bit 19 to bit 6, which has not
2
been used since commit c1e3781090b9d36c60 in 2015, when we
3
started passing the entire MMU index in the TB flags rather
4
than just a 'privilege level' bit.
5
1
6
This rearrangement is not strictly necessary, but means that
7
we can put M-profile-only bits next to each other rather
8
than scattered across the flag word.
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190416125744.27770-17-peter.maydell@linaro.org
13
---
14
target/arm/cpu.h | 11 ++++++-----
15
1 file changed, 6 insertions(+), 5 deletions(-)
16
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
20
+++ b/target/arm/cpu.h
21
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
22
FIELD(TBFLAG_A32, THUMB, 0, 1)
23
FIELD(TBFLAG_A32, VECLEN, 1, 3)
24
FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
25
+/*
26
+ * Indicates whether cp register reads and writes by guest code should access
27
+ * the secure or nonsecure bank of banked registers; note that this is not
28
+ * the same thing as the current security state of the processor!
29
+ */
30
+FIELD(TBFLAG_A32, NS, 6, 1)
31
FIELD(TBFLAG_A32, VFPEN, 7, 1)
32
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
33
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
34
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
35
* checks on the other bits at runtime
36
*/
37
FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
38
-/* Indicates whether cp register reads and writes by guest code should access
39
- * the secure or nonsecure bank of banked registers; note that this is not
40
- * the same thing as the current security state of the processor!
41
- */
42
-FIELD(TBFLAG_A32, NS, 19, 1)
43
/* For M profile only, Handler (ie not Thread) mode */
44
FIELD(TBFLAG_A32, HANDLER, 21, 1)
45
/* For M profile only, whether we should generate stack-limit checks */
46
--
47
2.20.1
48
49
diff view generated by jsdifflib
1
The M-profile FPCCR.ASPEN bit indicates that automatic floating-point
1
From: Andrew Jones <drjones@redhat.com>
2
context preservation is enabled. Before executing any floating-point
3
instruction, if FPCCR.ASPEN is set and the CONTROL FPCA/SFPA bits
4
indicate that there is no active floating point context then we
5
must create a new context (by initializing FPSCR and setting
6
FPCA/SFPA to indicate that the context is now active). In the
7
pseudocode this is handled by ExecuteFPCheck().
8
2
9
Implement this with a new TB flag which tracks whether we
3
Add the missing GENERIC_TIMER feature to kvm64 cpus.
10
need to create a new FP context.
11
4
5
We don't currently use these registers when KVM is enabled, but it's
6
probably best we add the feature flag for consistency and potential
7
future use. There's also precedent, as we add the PMU feature flag to
8
KVM enabled guests, even though we don't use those registers either.
9
10
This change was originally posted as a hunk of a different, never
11
merged patch from Bijan Mottahedeh.
12
13
Signed-off-by: Andrew Jones <drjones@redhat.com>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20200120101023.16030-4-drjones@redhat.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190416125744.27770-20-peter.maydell@linaro.org
15
---
17
---
16
target/arm/cpu.h | 2 ++
18
target/arm/kvm64.c | 1 +
17
target/arm/translate.h | 1 +
19
1 file changed, 1 insertion(+)
18
target/arm/helper.c | 13 +++++++++++++
19
target/arm/translate.c | 29 +++++++++++++++++++++++++++++
20
4 files changed, 45 insertions(+)
21
20
22
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
23
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/cpu.h
23
--- a/target/arm/kvm64.c
25
+++ b/target/arm/cpu.h
24
+++ b/target/arm/kvm64.c
26
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
25
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
27
FIELD(TBFLAG_A32, VFPEN, 7, 1)
26
set_feature(&features, ARM_FEATURE_NEON);
28
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
27
set_feature(&features, ARM_FEATURE_AARCH64);
29
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
28
set_feature(&features, ARM_FEATURE_PMU);
30
+/* For M profile only, set if we must create a new FP context */
29
+ set_feature(&features, ARM_FEATURE_GENERIC_TIMER);
31
+FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1)
30
32
/* For M profile only, set if FPCCR.S does not match current security state */
31
ahcf->features = features;
33
FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1)
34
/* For M profile only, Handler (ie not Thread) mode */
35
diff --git a/target/arm/translate.h b/target/arm/translate.h
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/translate.h
38
+++ b/target/arm/translate.h
39
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
40
bool v8m_secure; /* true if v8M and we're in Secure mode */
41
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
42
bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
43
+ bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */
44
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
45
* so that top level loop can generate correct syndrome information.
46
*/
47
diff --git a/target/arm/helper.c b/target/arm/helper.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/helper.c
50
+++ b/target/arm/helper.c
51
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
52
flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1);
53
}
54
55
+ if (arm_feature(env, ARM_FEATURE_M) &&
56
+ (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) &&
57
+ (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) ||
58
+ (env->v7m.secure &&
59
+ !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) {
60
+ /*
61
+ * ASPEN is set, but FPCA/SFPA indicate that there is no active
62
+ * FP context; we must create a new FP context before executing
63
+ * any FP insn.
64
+ */
65
+ flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1);
66
+ }
67
+
68
*pflags = flags;
69
*cs_base = 0;
70
}
71
diff --git a/target/arm/translate.c b/target/arm/translate.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/target/arm/translate.c
74
+++ b/target/arm/translate.c
75
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
76
/* Don't need to do this for any further FP insns in this TB */
77
s->v8m_fpccr_s_wrong = false;
78
}
79
+
80
+ if (s->v7m_new_fp_ctxt_needed) {
81
+ /*
82
+ * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA
83
+ * and the FPSCR.
84
+ */
85
+ TCGv_i32 control, fpscr;
86
+ uint32_t bits = R_V7M_CONTROL_FPCA_MASK;
87
+
88
+ fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]);
89
+ gen_helper_vfp_set_fpscr(cpu_env, fpscr);
90
+ tcg_temp_free_i32(fpscr);
91
+ /*
92
+ * We don't need to arrange to end the TB, because the only
93
+ * parts of FPSCR which we cache in the TB flags are the VECLEN
94
+ * and VECSTRIDE, and those don't exist for M-profile.
95
+ */
96
+
97
+ if (s->v8m_secure) {
98
+ bits |= R_V7M_CONTROL_SFPA_MASK;
99
+ }
100
+ control = load_cpu_field(v7m.control[M_REG_S]);
101
+ tcg_gen_ori_i32(control, control, bits);
102
+ store_cpu_field(control, v7m.control[M_REG_S]);
103
+ /* Don't need to do this for any further FP insns in this TB */
104
+ s->v7m_new_fp_ctxt_needed = false;
105
+ }
106
}
107
108
if (extract32(insn, 28, 4) == 0xf) {
109
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
110
regime_is_secure(env, dc->mmu_idx);
111
dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK);
112
dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
113
+ dc->v7m_new_fp_ctxt_needed =
114
+ FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED);
115
dc->cp_regs = cpu->cp_regs;
116
dc->features = env->features;
117
32
118
--
33
--
119
2.20.1
34
2.20.1
120
35
121
36
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Andrew Jones <drjones@redhat.com>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
If we know what the default value should be then we can test for
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
that as well as the feature existence.
5
Message-id: 20190412165416.7977-5-philmd@redhat.com
5
6
Signed-off-by: Andrew Jones <drjones@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200120101023.16030-5-drjones@redhat.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
include/hw/devices.h | 6 ------
11
tests/qtest/arm-cpu-features.c | 37 +++++++++++++++++++++++++---------
9
include/hw/display/tc6393xb.h | 24 ++++++++++++++++++++++++
12
1 file changed, 28 insertions(+), 9 deletions(-)
10
hw/arm/tosa.c | 2 +-
11
hw/display/tc6393xb.c | 2 +-
12
MAINTAINERS | 1 +
13
5 files changed, 27 insertions(+), 8 deletions(-)
14
create mode 100644 include/hw/display/tc6393xb.h
15
13
16
diff --git a/include/hw/devices.h b/include/hw/devices.h
14
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/devices.h
16
--- a/tests/qtest/arm-cpu-features.c
19
+++ b/include/hw/devices.h
17
+++ b/tests/qtest/arm-cpu-features.c
20
@@ -XXX,XX +XXX,XX @@ void *tahvo_init(qemu_irq irq, int betty);
18
@@ -XXX,XX +XXX,XX @@ static bool resp_get_feature(QDict *resp, const char *feature)
21
19
qobject_unref(_resp); \
22
void retu_key_event(void *retu, int state);
20
})
23
21
24
-/* tc6393xb.c */
22
+#define assert_feature(qts, cpu_type, feature, expected_value) \
25
-typedef struct TC6393xbState TC6393xbState;
23
+({ \
26
-TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
24
+ QDict *_resp, *_props; \
27
- uint32_t base, qemu_irq irq);
25
+ \
28
-qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
26
+ _resp = do_query_no_props(qts, cpu_type); \
29
-
27
+ g_assert(_resp); \
30
#endif
28
+ g_assert(resp_has_props(_resp)); \
31
diff --git a/include/hw/display/tc6393xb.h b/include/hw/display/tc6393xb.h
29
+ _props = resp_get_props(_resp); \
32
new file mode 100644
30
+ g_assert(qdict_get(_props, feature)); \
33
index XXXXXXX..XXXXXXX
31
+ g_assert(qdict_get_bool(_props, feature) == (expected_value)); \
34
--- /dev/null
32
+ qobject_unref(_resp); \
35
+++ b/include/hw/display/tc6393xb.h
33
+})
36
@@ -XXX,XX +XXX,XX @@
37
+/*
38
+ * Toshiba TC6393XB I/O Controller.
39
+ * Found in Sharp Zaurus SL-6000 (tosa) or some
40
+ * Toshiba e-Series PDAs.
41
+ *
42
+ * Copyright (c) 2007 Hervé Poussineau
43
+ *
44
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
45
+ * See the COPYING file in the top-level directory.
46
+ */
47
+
34
+
48
+#ifndef HW_DISPLAY_TC6393XB_H
35
+#define assert_has_feature_enabled(qts, cpu_type, feature) \
49
+#define HW_DISPLAY_TC6393XB_H
36
+ assert_feature(qts, cpu_type, feature, true)
50
+
37
+
51
+#include "exec/memory.h"
38
+#define assert_has_feature_disabled(qts, cpu_type, feature) \
52
+#include "hw/irq.h"
39
+ assert_feature(qts, cpu_type, feature, false)
53
+
40
+
54
+typedef struct TC6393xbState TC6393xbState;
41
static void assert_type_full(QTestState *qts)
55
+
42
{
56
+TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
43
const char *error;
57
+ uint32_t base, qemu_irq irq);
44
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data)
58
+qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
45
assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);
59
+
46
60
+#endif
47
/* Test expected feature presence/absence for some cpu types */
61
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
48
- assert_has_feature(qts, "max", "pmu");
62
index XXXXXXX..XXXXXXX 100644
49
- assert_has_feature(qts, "cortex-a15", "pmu");
63
--- a/hw/arm/tosa.c
50
+ assert_has_feature_enabled(qts, "max", "pmu");
64
+++ b/hw/arm/tosa.c
51
+ assert_has_feature_enabled(qts, "cortex-a15", "pmu");
65
@@ -XXX,XX +XXX,XX @@
52
assert_has_not_feature(qts, "cortex-a15", "aarch64");
66
#include "hw/hw.h"
53
67
#include "hw/arm/pxa.h"
54
if (g_str_equal(qtest_get_arch(), "aarch64")) {
68
#include "hw/arm/arm.h"
55
- assert_has_feature(qts, "max", "aarch64");
69
-#include "hw/devices.h"
56
- assert_has_feature(qts, "max", "sve");
70
#include "hw/arm/sharpsl.h"
57
- assert_has_feature(qts, "max", "sve128");
71
#include "hw/pcmcia.h"
58
- assert_has_feature(qts, "cortex-a57", "pmu");
72
#include "hw/boards.h"
59
- assert_has_feature(qts, "cortex-a57", "aarch64");
73
+#include "hw/display/tc6393xb.h"
60
+ assert_has_feature_enabled(qts, "max", "aarch64");
74
#include "hw/i2c/i2c.h"
61
+ assert_has_feature_enabled(qts, "max", "sve");
75
#include "hw/ssi/ssi.h"
62
+ assert_has_feature_enabled(qts, "max", "sve128");
76
#include "hw/sysbus.h"
63
+ assert_has_feature_enabled(qts, "cortex-a57", "pmu");
77
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
64
+ assert_has_feature_enabled(qts, "cortex-a57", "aarch64");
78
index XXXXXXX..XXXXXXX 100644
65
79
--- a/hw/display/tc6393xb.c
66
sve_tests_default(qts, "max");
80
+++ b/hw/display/tc6393xb.c
67
81
@@ -XXX,XX +XXX,XX @@
68
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
82
#include "qapi/error.h"
69
QDict *resp;
83
#include "qemu/host-utils.h"
70
char *error;
84
#include "hw/hw.h"
71
85
-#include "hw/devices.h"
72
- assert_has_feature(qts, "host", "aarch64");
86
+#include "hw/display/tc6393xb.h"
73
- assert_has_feature(qts, "host", "pmu");
87
#include "hw/block/flash.h"
74
+ assert_has_feature_enabled(qts, "host", "aarch64");
88
#include "ui/console.h"
75
+ assert_has_feature_enabled(qts, "host", "pmu");
89
#include "ui/pixel_ops.h"
76
90
diff --git a/MAINTAINERS b/MAINTAINERS
77
assert_error(qts, "cortex-a15",
91
index XXXXXXX..XXXXXXX 100644
78
"We cannot guarantee the CPU type 'cortex-a15' works "
92
--- a/MAINTAINERS
93
+++ b/MAINTAINERS
94
@@ -XXX,XX +XXX,XX @@ F: hw/misc/mst_fpga.c
95
F: hw/misc/max111x.c
96
F: include/hw/arm/pxa.h
97
F: include/hw/arm/sharpsl.h
98
+F: include/hw/display/tc6393xb.h
99
100
SABRELITE / i.MX6
101
M: Peter Maydell <peter.maydell@linaro.org>
102
--
79
--
103
2.20.1
80
2.20.1
104
81
105
82
diff view generated by jsdifflib
1
Add a new helper function which returns the MMU index to use
1
From: Andrew Jones <drjones@redhat.com>
2
for v7M, where the caller specifies all of the security
2
3
state, privilege level and whether the execution priority
3
When a VM is stopped (such as when it's paused) guest virtual time
4
is negative, and reimplement the existing
4
should stop counting. Otherwise, when the VM is resumed it will
5
arm_v7m_mmu_idx_for_secstate_and_priv() in terms of it.
5
experience time jumps and its kernel may report soft lockups. Not
6
6
counting virtual time while the VM is stopped has the side effect
7
We are going to need this for the lazy-FP-stacking code.
7
of making the guest's time appear to lag when compared with real
8
8
time, and even with time derived from the physical counter. For
9
this reason, this change, which is enabled by default, comes with
10
a KVM CPU feature allowing it to be disabled, restoring legacy
11
behavior.
12
13
This patch only provides the implementation of the virtual time
14
adjustment. A subsequent patch will provide the CPU property
15
allowing the change to be enabled and disabled.
16
17
Reported-by: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
18
Signed-off-by: Andrew Jones <drjones@redhat.com>
19
Message-id: 20200120101023.16030-6-drjones@redhat.com
20
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20190416125744.27770-21-peter.maydell@linaro.org
12
---
22
---
13
target/arm/cpu.h | 7 +++++++
23
target/arm/cpu.h | 7 ++++
14
target/arm/helper.c | 14 +++++++++++---
24
target/arm/kvm_arm.h | 38 ++++++++++++++++++
15
2 files changed, 18 insertions(+), 3 deletions(-)
25
target/arm/kvm.c | 92 ++++++++++++++++++++++++++++++++++++++++++++
26
target/arm/kvm32.c | 3 ++
27
target/arm/kvm64.c | 3 ++
28
target/arm/machine.c | 7 ++++
29
6 files changed, 150 insertions(+)
16
30
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
31
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
18
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
33
--- a/target/arm/cpu.h
20
+++ b/target/arm/cpu.h
34
+++ b/target/arm/cpu.h
21
@@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
35
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
22
}
36
/* KVM init features for this CPU */
23
}
37
uint32_t kvm_init_features[7];
24
38
25
+/*
39
+ /* KVM CPU state */
26
+ * Return the MMU index for a v7M CPU with all relevant information
40
+
27
+ * manually specified.
41
+ /* KVM virtual time adjustment */
28
+ */
42
+ bool kvm_adjvtime;
29
+ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
43
+ bool kvm_vtime_dirty;
30
+ bool secstate, bool priv, bool negpri);
44
+ uint64_t kvm_vtime;
31
+
45
+
32
/* Return the MMU index for a v7M CPU in the specified security and
46
/* Uniprocessor system with MP extensions */
33
* privilege state.
47
bool mp_is_up;
48
49
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
50
index XXXXXXX..XXXXXXX 100644
51
--- a/target/arm/kvm_arm.h
52
+++ b/target/arm/kvm_arm.h
53
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level);
34
*/
54
*/
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
55
bool write_kvmstate_to_list(ARMCPU *cpu);
36
index XXXXXXX..XXXXXXX 100644
56
37
--- a/target/arm/helper.c
57
+/**
38
+++ b/target/arm/helper.c
58
+ * kvm_arm_cpu_pre_save:
39
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
59
+ * @cpu: ARMCPU
60
+ *
61
+ * Called after write_kvmstate_to_list() from cpu_pre_save() to update
62
+ * the cpreg list with KVM CPU state.
63
+ */
64
+void kvm_arm_cpu_pre_save(ARMCPU *cpu);
65
+
66
+/**
67
+ * kvm_arm_cpu_post_load:
68
+ * @cpu: ARMCPU
69
+ *
70
+ * Called from cpu_post_load() to update KVM CPU state from the cpreg list.
71
+ */
72
+void kvm_arm_cpu_post_load(ARMCPU *cpu);
73
+
74
/**
75
* kvm_arm_reset_vcpu:
76
* @cpu: ARMCPU
77
@@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu);
78
*/
79
int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu);
80
81
+/**
82
+ * kvm_arm_get_virtual_time:
83
+ * @cs: CPUState
84
+ *
85
+ * Gets the VCPU's virtual counter and stores it in the KVM CPU state.
86
+ */
87
+void kvm_arm_get_virtual_time(CPUState *cs);
88
+
89
+/**
90
+ * kvm_arm_put_virtual_time:
91
+ * @cs: CPUState
92
+ *
93
+ * Sets the VCPU's virtual counter to the value stored in the KVM CPU state.
94
+ */
95
+void kvm_arm_put_virtual_time(CPUState *cs);
96
+
97
+void kvm_arm_vm_state_change(void *opaque, int running, RunState state);
98
+
99
int kvm_arm_vgic_probe(void);
100
101
void kvm_arm_pmu_set_irq(CPUState *cs, int irq);
102
@@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {}
103
static inline void kvm_arm_pmu_init(CPUState *cs) {}
104
105
static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {}
106
+
107
+static inline void kvm_arm_get_virtual_time(CPUState *cs) {}
108
+static inline void kvm_arm_put_virtual_time(CPUState *cs) {}
109
#endif
110
111
static inline const char *gic_class_name(void)
112
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
113
index XXXXXXX..XXXXXXX 100644
114
--- a/target/arm/kvm.c
115
+++ b/target/arm/kvm.c
116
@@ -XXX,XX +XXX,XX @@ static int compare_u64(const void *a, const void *b)
40
return 0;
117
return 0;
41
}
118
}
42
119
43
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
120
+/*
44
- bool secstate, bool priv)
121
+ * cpreg_values are sorted in ascending order by KVM register ID
45
+ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
122
+ * (see kvm_arm_init_cpreg_list). This allows us to cheaply find
46
+ bool secstate, bool priv, bool negpri)
123
+ * the storage for a KVM register by ID with a binary search.
124
+ */
125
+static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, uint64_t regidx)
126
+{
127
+ uint64_t *res;
128
+
129
+ res = bsearch(&regidx, cpu->cpreg_indexes, cpu->cpreg_array_len,
130
+ sizeof(uint64_t), compare_u64);
131
+ assert(res);
132
+
133
+ return &cpu->cpreg_values[res - cpu->cpreg_indexes];
134
+}
135
+
136
/* Initialize the ARMCPU cpreg list according to the kernel's
137
* definition of what CPU registers it knows about (and throw away
138
* the previous TCG-created cpreg list).
139
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
140
return ok;
141
}
142
143
+void kvm_arm_cpu_pre_save(ARMCPU *cpu)
144
+{
145
+ /* KVM virtual time adjustment */
146
+ if (cpu->kvm_vtime_dirty) {
147
+ *kvm_arm_get_cpreg_ptr(cpu, KVM_REG_ARM_TIMER_CNT) = cpu->kvm_vtime;
148
+ }
149
+}
150
+
151
+void kvm_arm_cpu_post_load(ARMCPU *cpu)
152
+{
153
+ /* KVM virtual time adjustment */
154
+ if (cpu->kvm_adjvtime) {
155
+ cpu->kvm_vtime = *kvm_arm_get_cpreg_ptr(cpu, KVM_REG_ARM_TIMER_CNT);
156
+ cpu->kvm_vtime_dirty = true;
157
+ }
158
+}
159
+
160
void kvm_arm_reset_vcpu(ARMCPU *cpu)
47
{
161
{
48
ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
162
int ret;
49
163
@@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu)
50
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
164
return 0;
51
mmu_idx |= ARM_MMU_IDX_M_PRIV;
165
}
166
167
+void kvm_arm_get_virtual_time(CPUState *cs)
168
+{
169
+ ARMCPU *cpu = ARM_CPU(cs);
170
+ struct kvm_one_reg reg = {
171
+ .id = KVM_REG_ARM_TIMER_CNT,
172
+ .addr = (uintptr_t)&cpu->kvm_vtime,
173
+ };
174
+ int ret;
175
+
176
+ if (cpu->kvm_vtime_dirty) {
177
+ return;
178
+ }
179
+
180
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
181
+ if (ret) {
182
+ error_report("Failed to get KVM_REG_ARM_TIMER_CNT");
183
+ abort();
184
+ }
185
+
186
+ cpu->kvm_vtime_dirty = true;
187
+}
188
+
189
+void kvm_arm_put_virtual_time(CPUState *cs)
190
+{
191
+ ARMCPU *cpu = ARM_CPU(cs);
192
+ struct kvm_one_reg reg = {
193
+ .id = KVM_REG_ARM_TIMER_CNT,
194
+ .addr = (uintptr_t)&cpu->kvm_vtime,
195
+ };
196
+ int ret;
197
+
198
+ if (!cpu->kvm_vtime_dirty) {
199
+ return;
200
+ }
201
+
202
+ ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
203
+ if (ret) {
204
+ error_report("Failed to set KVM_REG_ARM_TIMER_CNT");
205
+ abort();
206
+ }
207
+
208
+ cpu->kvm_vtime_dirty = false;
209
+}
210
+
211
int kvm_put_vcpu_events(ARMCPU *cpu)
212
{
213
CPUARMState *env = &cpu->env;
214
@@ -XXX,XX +XXX,XX @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
215
return MEMTXATTRS_UNSPECIFIED;
216
}
217
218
+void kvm_arm_vm_state_change(void *opaque, int running, RunState state)
219
+{
220
+ CPUState *cs = opaque;
221
+ ARMCPU *cpu = ARM_CPU(cs);
222
+
223
+ if (running) {
224
+ if (cpu->kvm_adjvtime) {
225
+ kvm_arm_put_virtual_time(cs);
226
+ }
227
+ } else {
228
+ if (cpu->kvm_adjvtime) {
229
+ kvm_arm_get_virtual_time(cs);
230
+ }
231
+ }
232
+}
233
234
int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
235
{
236
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
237
index XXXXXXX..XXXXXXX 100644
238
--- a/target/arm/kvm32.c
239
+++ b/target/arm/kvm32.c
240
@@ -XXX,XX +XXX,XX @@
241
#include "qemu-common.h"
242
#include "cpu.h"
243
#include "qemu/timer.h"
244
+#include "sysemu/runstate.h"
245
#include "sysemu/kvm.h"
246
#include "kvm_arm.h"
247
#include "internals.h"
248
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
249
return -EINVAL;
52
}
250
}
53
251
54
- if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) {
252
+ qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs);
55
+ if (negpri) {
253
+
56
mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
254
/* Determine init features for this CPU */
255
memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
256
if (cpu->start_powered_off) {
257
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
258
index XXXXXXX..XXXXXXX 100644
259
--- a/target/arm/kvm64.c
260
+++ b/target/arm/kvm64.c
261
@@ -XXX,XX +XXX,XX @@
262
#include "qemu/host-utils.h"
263
#include "qemu/main-loop.h"
264
#include "exec/gdbstub.h"
265
+#include "sysemu/runstate.h"
266
#include "sysemu/kvm.h"
267
#include "sysemu/kvm_int.h"
268
#include "kvm_arm.h"
269
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
270
return -EINVAL;
57
}
271
}
58
272
59
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
273
+ qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs);
60
return mmu_idx;
274
+
61
}
275
/* Determine init features for this CPU */
62
276
memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
63
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
277
if (cpu->start_powered_off) {
64
+ bool secstate, bool priv)
278
diff --git a/target/arm/machine.c b/target/arm/machine.c
65
+{
279
index XXXXXXX..XXXXXXX 100644
66
+ bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
280
--- a/target/arm/machine.c
67
+
281
+++ b/target/arm/machine.c
68
+ return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
282
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
69
+}
283
/* This should never fail */
70
+
284
abort();
71
/* Return the MMU index for a v7M CPU in the specified security state */
285
}
72
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
286
+
73
{
287
+ /*
288
+ * kvm_arm_cpu_pre_save() must be called after
289
+ * write_kvmstate_to_list()
290
+ */
291
+ kvm_arm_cpu_pre_save(cpu);
292
} else {
293
if (!write_cpustate_to_list(cpu, false)) {
294
/* This should never fail. */
295
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
296
* we're using it.
297
*/
298
write_list_to_cpustate(cpu);
299
+ kvm_arm_cpu_post_load(cpu);
300
} else {
301
if (!write_list_to_cpustate(cpu)) {
302
return -1;
74
--
303
--
75
2.20.1
304
2.20.1
76
305
77
306
diff view generated by jsdifflib
1
We are close to running out of TB flags for AArch32; we could
1
From: Andrew Jones <drjones@redhat.com>
2
start using the cs_base word, but before we do that we can
2
3
economise on our usage by sharing the same bits for the VFP
3
kvm-no-adjvtime is a KVM specific CPU property and a first of its
4
VECSTRIDE field and the XScale XSCALE_CPAR field. This
4
kind. To accommodate it we also add kvm_arm_add_vcpu_properties()
5
works because no XScale CPU ever had VFP.
5
and a KVM specific CPU properties description to the CPU features
6
6
document.
7
8
Signed-off-by: Andrew Jones <drjones@redhat.com>
9
Message-id: 20200120101023.16030-7-drjones@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-18-peter.maydell@linaro.org
10
---
12
---
11
target/arm/cpu.h | 10 ++++++----
13
include/hw/arm/virt.h | 1 +
12
target/arm/cpu.c | 7 +++++++
14
target/arm/kvm_arm.h | 11 ++++++++++
13
target/arm/helper.c | 6 +++++-
15
hw/arm/virt.c | 8 ++++++++
14
target/arm/translate.c | 9 +++++++--
16
target/arm/cpu.c | 2 ++
15
4 files changed, 25 insertions(+), 7 deletions(-)
17
target/arm/cpu64.c | 1 +
16
18
target/arm/kvm.c | 28 +++++++++++++++++++++++++
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
target/arm/monitor.c | 1 +
18
index XXXXXXX..XXXXXXX 100644
20
tests/qtest/arm-cpu-features.c | 4 ++++
19
--- a/target/arm/cpu.h
21
docs/arm-cpu-features.rst | 37 +++++++++++++++++++++++++++++++++-
20
+++ b/target/arm/cpu.h
22
9 files changed, 92 insertions(+), 1 deletion(-)
21
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
23
22
FIELD(TBFLAG_A32, THUMB, 0, 1)
24
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
23
FIELD(TBFLAG_A32, VECLEN, 1, 3)
25
index XXXXXXX..XXXXXXX 100644
24
FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
26
--- a/include/hw/arm/virt.h
25
+/*
27
+++ b/include/hw/arm/virt.h
26
+ * We store the bottom two bits of the CPAR as TB flags and handle
28
@@ -XXX,XX +XXX,XX @@ typedef struct {
27
+ * checks on the other bits at runtime. This shares the same bits as
29
bool smbios_old_sys_ver;
28
+ * VECSTRIDE, which is OK as no XScale CPU has VFP.
30
bool no_highmem_ecam;
31
bool no_ged; /* Machines < 4.2 has no support for ACPI GED device */
32
+ bool kvm_no_adjvtime;
33
} VirtMachineClass;
34
35
typedef struct {
36
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/kvm_arm.h
39
+++ b/target/arm/kvm_arm.h
40
@@ -XXX,XX +XXX,XX @@ void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map);
41
*/
42
void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);
43
44
+/**
45
+ * kvm_arm_add_vcpu_properties:
46
+ * @obj: The CPU object to add the properties to
47
+ *
48
+ * Add all KVM specific CPU properties to the CPU object. These
49
+ * are the CPU properties with "kvm-" prefixed names.
29
+ */
50
+ */
30
+FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2)
51
+void kvm_arm_add_vcpu_properties(Object *obj);
31
/*
52
+
32
* Indicates whether cp register reads and writes by guest code should access
53
/**
33
* the secure or nonsecure bank of banked registers; note that this is not
54
* kvm_arm_aarch32_supported:
34
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
55
* @cs: CPUState
35
FIELD(TBFLAG_A32, VFPEN, 7, 1)
56
@@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
36
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
57
cpu->host_cpu_probe_failed = true;
37
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
58
}
38
-/* We store the bottom two bits of the CPAR as TB flags and handle
59
39
- * checks on the other bits at runtime
60
+static inline void kvm_arm_add_vcpu_properties(Object *obj) {}
40
- */
61
+
41
-FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
62
static inline bool kvm_arm_aarch32_supported(CPUState *cs)
42
/* For M profile only, Handler (ie not Thread) mode */
63
{
43
FIELD(TBFLAG_A32, HANDLER, 21, 1)
64
return false;
44
/* For M profile only, whether we should generate stack-limit checks */
65
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/hw/arm/virt.c
68
+++ b/hw/arm/virt.c
69
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
70
}
71
}
72
73
+ if (vmc->kvm_no_adjvtime &&
74
+ object_property_find(cpuobj, "kvm-no-adjvtime", NULL)) {
75
+ object_property_set_bool(cpuobj, true, "kvm-no-adjvtime", NULL);
76
+ }
77
+
78
if (vmc->no_pmu && object_property_find(cpuobj, "pmu", NULL)) {
79
object_property_set_bool(cpuobj, false, "pmu", NULL);
80
}
81
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 0)
82
83
static void virt_machine_4_2_options(MachineClass *mc)
84
{
85
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
86
+
87
virt_machine_5_0_options(mc);
88
compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
89
+ vmc->kvm_no_adjvtime = true;
90
}
91
DEFINE_VIRT_MACHINE(4, 2)
92
45
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
93
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
46
index XXXXXXX..XXXXXXX 100644
94
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/cpu.c
95
--- a/target/arm/cpu.c
48
+++ b/target/arm/cpu.c
96
+++ b/target/arm/cpu.c
49
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
97
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
50
set_feature(env, ARM_FEATURE_THUMB_DSP);
98
99
if (kvm_enabled()) {
100
kvm_arm_set_cpu_features_from_host(cpu);
101
+ kvm_arm_add_vcpu_properties(obj);
102
} else {
103
cortex_a15_initfn(obj);
104
105
@@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj)
106
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
107
aarch64_add_sve_properties(obj);
51
}
108
}
52
109
+ kvm_arm_add_vcpu_properties(obj);
53
+ /*
110
arm_cpu_post_init(obj);
54
+ * We rely on no XScale CPU having VFP so we can use the same bits in the
111
}
55
+ * TB flags field for VECSTRIDE and XSCALE_CPAR.
112
56
+ */
113
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
57
+ assert(!(arm_feature(env, ARM_FEATURE_VFP) &&
114
index XXXXXXX..XXXXXXX 100644
58
+ arm_feature(env, ARM_FEATURE_XSCALE)));
115
--- a/target/arm/cpu64.c
59
+
116
+++ b/target/arm/cpu64.c
60
if (arm_feature(env, ARM_FEATURE_V7) &&
117
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
61
!arm_feature(env, ARM_FEATURE_M) &&
118
62
!arm_feature(env, ARM_FEATURE_PMSA)) {
119
if (kvm_enabled()) {
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
120
kvm_arm_set_cpu_features_from_host(cpu);
64
index XXXXXXX..XXXXXXX 100644
121
+ kvm_arm_add_vcpu_properties(obj);
65
--- a/target/arm/helper.c
122
} else {
66
+++ b/target/arm/helper.c
123
uint64_t t;
67
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
124
uint32_t u;
68
|| arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) {
125
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
69
flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1);
126
index XXXXXXX..XXXXXXX 100644
70
}
127
--- a/target/arm/kvm.c
71
- flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar);
128
+++ b/target/arm/kvm.c
72
+ /* Note that XSCALE_CPAR shares bits with VECSTRIDE */
129
@@ -XXX,XX +XXX,XX @@
73
+ if (arm_feature(env, ARM_FEATURE_XSCALE)) {
130
#include "qemu/timer.h"
74
+ flags = FIELD_DP32(flags, TBFLAG_A32,
131
#include "qemu/error-report.h"
75
+ XSCALE_CPAR, env->cp15.c15_cpar);
132
#include "qemu/main-loop.h"
76
+ }
133
+#include "qom/object.h"
134
+#include "qapi/error.h"
135
#include "sysemu/sysemu.h"
136
#include "sysemu/kvm.h"
137
#include "sysemu/kvm_int.h"
138
@@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
139
env->features = arm_host_cpu_features.features;
140
}
141
142
+static bool kvm_no_adjvtime_get(Object *obj, Error **errp)
143
+{
144
+ return !ARM_CPU(obj)->kvm_adjvtime;
145
+}
146
+
147
+static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp)
148
+{
149
+ ARM_CPU(obj)->kvm_adjvtime = !value;
150
+}
151
+
152
+/* KVM VCPU properties should be prefixed with "kvm-". */
153
+void kvm_arm_add_vcpu_properties(Object *obj)
154
+{
155
+ if (!kvm_enabled()) {
156
+ return;
157
+ }
158
+
159
+ ARM_CPU(obj)->kvm_adjvtime = true;
160
+ object_property_add_bool(obj, "kvm-no-adjvtime", kvm_no_adjvtime_get,
161
+ kvm_no_adjvtime_set, &error_abort);
162
+ object_property_set_description(obj, "kvm-no-adjvtime",
163
+ "Set on to disable the adjustment of "
164
+ "the virtual counter. VM stopped time "
165
+ "will be counted.", &error_abort);
166
+}
167
+
168
bool kvm_arm_pmu_supported(CPUState *cpu)
169
{
170
return kvm_check_extension(cpu->kvm_state, KVM_CAP_ARM_PMU_V3);
171
diff --git a/target/arm/monitor.c b/target/arm/monitor.c
172
index XXXXXXX..XXXXXXX 100644
173
--- a/target/arm/monitor.c
174
+++ b/target/arm/monitor.c
175
@@ -XXX,XX +XXX,XX @@ static const char *cpu_model_advertised_features[] = {
176
"sve128", "sve256", "sve384", "sve512",
177
"sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280",
178
"sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048",
179
+ "kvm-no-adjvtime",
180
NULL
181
};
182
183
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
184
index XXXXXXX..XXXXXXX 100644
185
--- a/tests/qtest/arm-cpu-features.c
186
+++ b/tests/qtest/arm-cpu-features.c
187
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data)
188
assert_has_feature_enabled(qts, "cortex-a15", "pmu");
189
assert_has_not_feature(qts, "cortex-a15", "aarch64");
190
191
+ assert_has_not_feature(qts, "max", "kvm-no-adjvtime");
192
+
193
if (g_str_equal(qtest_get_arch(), "aarch64")) {
194
assert_has_feature_enabled(qts, "max", "aarch64");
195
assert_has_feature_enabled(qts, "max", "sve");
196
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
197
return;
77
}
198
}
78
199
79
flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx));
200
+ assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");
80
diff --git a/target/arm/translate.c b/target/arm/translate.c
201
+
81
index XXXXXXX..XXXXXXX 100644
202
if (g_str_equal(qtest_get_arch(), "aarch64")) {
82
--- a/target/arm/translate.c
203
bool kvm_supports_sve;
83
+++ b/target/arm/translate.c
204
char max_name[8], name[8];
84
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
205
diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst
85
dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL);
206
index XXXXXXX..XXXXXXX 100644
86
dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN);
207
--- a/docs/arm-cpu-features.rst
87
dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN);
208
+++ b/docs/arm-cpu-features.rst
88
- dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
209
@@ -XXX,XX +XXX,XX @@ supporting the feature or only supporting the feature under certain
89
- dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
210
configurations. For example, the `aarch64` CPU feature, which, when
90
+ if (arm_feature(env, ARM_FEATURE_XSCALE)) {
211
disabled, enables the optional AArch32 CPU feature, is only supported
91
+ dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
212
when using the KVM accelerator and when running on a host CPU type that
92
+ dc->vec_stride = 0;
213
-supports the feature.
93
+ } else {
214
+supports the feature. While `aarch64` currently only works with KVM,
94
+ dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
215
+it could work with TCG. CPU features that are specific to KVM are
95
+ dc->c15_cpar = 0;
216
+prefixed with "kvm-" and are described in "KVM VCPU Features".
96
+ }
217
97
dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_A32, HANDLER);
218
CPU Feature Probing
98
dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
219
===================
99
regime_is_secure(env, dc->mmu_idx);
220
@@ -XXX,XX +XXX,XX @@ disabling many SVE vector lengths would be quite verbose, the `sve<N>` CPU
221
properties have special semantics (see "SVE CPU Property Parsing
222
Semantics").
223
224
+KVM VCPU Features
225
+=================
226
+
227
+KVM VCPU features are CPU features that are specific to KVM, such as
228
+paravirt features or features that enable CPU virtualization extensions.
229
+The features' CPU properties are only available when KVM is enabled and
230
+are named with the prefix "kvm-". KVM VCPU features may be probed,
231
+enabled, and disabled in the same way as other CPU features. Below is
232
+the list of KVM VCPU features and their descriptions.
233
+
234
+ kvm-no-adjvtime By default kvm-no-adjvtime is disabled. This
235
+ means that by default the virtual time
236
+ adjustment is enabled (vtime is *not not*
237
+ adjusted).
238
+
239
+ When virtual time adjustment is enabled each
240
+ time the VM transitions back to running state
241
+ the VCPU's virtual counter is updated to ensure
242
+ stopped time is not counted. This avoids time
243
+ jumps surprising guest OSes and applications,
244
+ as long as they use the virtual counter for
245
+ timekeeping. However it has the side effect of
246
+ the virtual and physical counters diverging.
247
+ All timekeeping based on the virtual counter
248
+ will appear to lag behind any timekeeping that
249
+ does not subtract VM stopped time. The guest
250
+ may resynchronize its virtual counter with
251
+ other time sources as needed.
252
+
253
+ Enable kvm-no-adjvtime to disable virtual time
254
+ adjustment, also restoring the legacy (pre-5.0)
255
+ behavior.
256
+
257
SVE CPU Properties
258
==================
259
100
--
260
--
101
2.20.1
261
2.20.1
102
262
103
263
diff view generated by jsdifflib
Deleted patch
1
The M-profile FPCCR.S bit indicates the security status of
2
the floating point context. In the pseudocode ExecuteFPCheck()
3
function it is unconditionally set to match the current
4
security state whenever a floating point instruction is
5
executed.
6
1
7
Implement this by adding a new TB flag which tracks whether
8
FPCCR.S is different from the current security state, so
9
that we only need to emit the code to update it in the
10
less-common case when it is not already set correctly.
11
12
Note that we will add the handling for the other work done
13
by ExecuteFPCheck() in later commits.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20190416125744.27770-19-peter.maydell@linaro.org
18
---
19
target/arm/cpu.h | 2 ++
20
target/arm/translate.h | 1 +
21
target/arm/helper.c | 5 +++++
22
target/arm/translate.c | 20 ++++++++++++++++++++
23
4 files changed, 28 insertions(+)
24
25
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
26
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/cpu.h
28
+++ b/target/arm/cpu.h
29
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
30
FIELD(TBFLAG_A32, VFPEN, 7, 1)
31
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
32
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
33
+/* For M profile only, set if FPCCR.S does not match current security state */
34
+FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1)
35
/* For M profile only, Handler (ie not Thread) mode */
36
FIELD(TBFLAG_A32, HANDLER, 21, 1)
37
/* For M profile only, whether we should generate stack-limit checks */
38
diff --git a/target/arm/translate.h b/target/arm/translate.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/translate.h
41
+++ b/target/arm/translate.h
42
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
43
bool v7m_handler_mode;
44
bool v8m_secure; /* true if v8M and we're in Secure mode */
45
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
46
+ bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
47
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
48
* so that top level loop can generate correct syndrome information.
49
*/
50
diff --git a/target/arm/helper.c b/target/arm/helper.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/helper.c
53
+++ b/target/arm/helper.c
54
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
55
flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1);
56
}
57
58
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
59
+ FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) {
60
+ flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1);
61
+ }
62
+
63
*pflags = flags;
64
*cs_base = 0;
65
}
66
diff --git a/target/arm/translate.c b/target/arm/translate.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/translate.c
69
+++ b/target/arm/translate.c
70
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
71
}
72
}
73
74
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
75
+ /* Handle M-profile lazy FP state mechanics */
76
+
77
+ /* Update ownership of FP context: set FPCCR.S to match current state */
78
+ if (s->v8m_fpccr_s_wrong) {
79
+ TCGv_i32 tmp;
80
+
81
+ tmp = load_cpu_field(v7m.fpccr[M_REG_S]);
82
+ if (s->v8m_secure) {
83
+ tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK);
84
+ } else {
85
+ tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK);
86
+ }
87
+ store_cpu_field(tmp, v7m.fpccr[M_REG_S]);
88
+ /* Don't need to do this for any further FP insns in this TB */
89
+ s->v8m_fpccr_s_wrong = false;
90
+ }
91
+ }
92
+
93
if (extract32(insn, 28, 4) == 0xf) {
94
/*
95
* Encodings with T=1 (Thumb) or unconditional (ARM):
96
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
97
dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
98
regime_is_secure(env, dc->mmu_idx);
99
dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK);
100
+ dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
101
dc->cp_regs = cpu->cp_regs;
102
dc->features = env->features;
103
104
--
105
2.20.1
106
107
diff view generated by jsdifflib
Deleted patch
1
In the v7M architecture, if an exception is generated in the process
2
of doing the lazy stacking of FP registers, the handling of
3
possible escalation to HardFault is treated differently to the normal
4
approach: it works based on the saved information about exception
5
readiness that was stored in the FPCCR when the stack frame was
6
created. Provide a new function armv7m_nvic_set_pending_lazyfp()
7
which pends exceptions during lazy stacking, and implements
8
this logic.
9
1
10
This corresponds to the pseudocode TakePreserveFPException().
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190416125744.27770-22-peter.maydell@linaro.org
15
---
16
target/arm/cpu.h | 12 ++++++
17
hw/intc/armv7m_nvic.c | 96 +++++++++++++++++++++++++++++++++++++++++++
18
2 files changed, 108 insertions(+)
19
20
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.h
23
+++ b/target/arm/cpu.h
24
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
25
* a different exception).
26
*/
27
void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);
28
+/**
29
+ * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
30
+ * @opaque: the NVIC
31
+ * @irq: the exception number to mark pending
32
+ * @secure: false for non-banked exceptions or for the nonsecure
33
+ * version of a banked exception, true for the secure version of a banked
34
+ * exception.
35
+ *
36
+ * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
37
+ * generated in the course of lazy stacking of FP registers.
38
+ */
39
+void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure);
40
/**
41
* armv7m_nvic_get_pending_irq_info: return highest priority pending
42
* exception, and whether it targets Secure state
43
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/intc/armv7m_nvic.c
46
+++ b/hw/intc/armv7m_nvic.c
47
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure)
48
do_armv7m_nvic_set_pending(opaque, irq, secure, true);
49
}
50
51
+void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
52
+{
53
+ /*
54
+ * Pend an exception during lazy FP stacking. This differs
55
+ * from the usual exception pending because the logic for
56
+ * whether we should escalate depends on the saved context
57
+ * in the FPCCR register, not on the current state of the CPU/NVIC.
58
+ */
59
+ NVICState *s = (NVICState *)opaque;
60
+ bool banked = exc_is_banked(irq);
61
+ VecInfo *vec;
62
+ bool targets_secure;
63
+ bool escalate = false;
64
+ /*
65
+ * We will only look at bits in fpccr if this is a banked exception
66
+ * (in which case 'secure' tells us whether it is the S or NS version).
67
+ * All the bits for the non-banked exceptions are in fpccr_s.
68
+ */
69
+ uint32_t fpccr_s = s->cpu->env.v7m.fpccr[M_REG_S];
70
+ uint32_t fpccr = s->cpu->env.v7m.fpccr[secure];
71
+
72
+ assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
73
+ assert(!secure || banked);
74
+
75
+ vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq];
76
+
77
+ targets_secure = banked ? secure : exc_targets_secure(s, irq);
78
+
79
+ switch (irq) {
80
+ case ARMV7M_EXCP_DEBUG:
81
+ if (!(fpccr_s & R_V7M_FPCCR_MONRDY_MASK)) {
82
+ /* Ignore DebugMonitor exception */
83
+ return;
84
+ }
85
+ break;
86
+ case ARMV7M_EXCP_MEM:
87
+ escalate = !(fpccr & R_V7M_FPCCR_MMRDY_MASK);
88
+ break;
89
+ case ARMV7M_EXCP_USAGE:
90
+ escalate = !(fpccr & R_V7M_FPCCR_UFRDY_MASK);
91
+ break;
92
+ case ARMV7M_EXCP_BUS:
93
+ escalate = !(fpccr_s & R_V7M_FPCCR_BFRDY_MASK);
94
+ break;
95
+ case ARMV7M_EXCP_SECURE:
96
+ escalate = !(fpccr_s & R_V7M_FPCCR_SFRDY_MASK);
97
+ break;
98
+ default:
99
+ g_assert_not_reached();
100
+ }
101
+
102
+ if (escalate) {
103
+ /*
104
+ * Escalate to HardFault: faults that initially targeted Secure
105
+ * continue to do so, even if HF normally targets NonSecure.
106
+ */
107
+ irq = ARMV7M_EXCP_HARD;
108
+ if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) &&
109
+ (targets_secure ||
110
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))) {
111
+ vec = &s->sec_vectors[irq];
112
+ } else {
113
+ vec = &s->vectors[irq];
114
+ }
115
+ }
116
+
117
+ if (!vec->enabled ||
118
+ nvic_exec_prio(s) <= exc_group_prio(s, vec->prio, secure)) {
119
+ if (!(fpccr_s & R_V7M_FPCCR_HFRDY_MASK)) {
120
+ /*
121
+ * We want to escalate to HardFault but the context the
122
+ * FP state belongs to prevents the exception pre-empting.
123
+ */
124
+ cpu_abort(&s->cpu->parent_obj,
125
+ "Lockup: can't escalate to HardFault during "
126
+ "lazy FP register stacking\n");
127
+ }
128
+ }
129
+
130
+ if (escalate) {
131
+ s->cpu->env.v7m.hfsr |= R_V7M_HFSR_FORCED_MASK;
132
+ }
133
+ if (!vec->pending) {
134
+ vec->pending = 1;
135
+ /*
136
+ * We do not call nvic_irq_update(), because we know our caller
137
+ * is going to handle causing us to take the exception by
138
+ * raising EXCP_LAZYFP, so raising the IRQ line would be
139
+ * pointless extra work. We just need to recompute the
140
+ * priorities so that armv7m_nvic_can_take_pending_exception()
141
+ * returns the right answer.
142
+ */
143
+ nvic_recompute_state(s);
144
+ }
145
+}
146
+
147
/* Make pending IRQ active. */
148
void armv7m_nvic_acknowledge_irq(void *opaque)
149
{
150
--
151
2.20.1
152
153
diff view generated by jsdifflib
Deleted patch
1
Pushing registers to the stack for v7M needs to handle three cases:
2
* the "normal" case where we pend exceptions
3
* an "ignore faults" case where we set FSR bits but
4
do not pend exceptions (this is used when we are
5
handling some kinds of derived exception on exception entry)
6
* a "lazy FP stacking" case, where different FSR bits
7
are set and the exception is pended differently
8
1
9
Implement this by changing the existing flag argument that
10
tells us whether to ignore faults or not into an enum that
11
specifies which of the 3 modes we should handle.
12
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20190416125744.27770-23-peter.maydell@linaro.org
16
---
17
target/arm/helper.c | 118 +++++++++++++++++++++++++++++---------------
18
1 file changed, 79 insertions(+), 39 deletions(-)
19
20
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/helper.c
23
+++ b/target/arm/helper.c
24
@@ -XXX,XX +XXX,XX @@ static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
25
}
26
}
27
28
+/*
29
+ * What kind of stack write are we doing? This affects how exceptions
30
+ * generated during the stacking are treated.
31
+ */
32
+typedef enum StackingMode {
33
+ STACK_NORMAL,
34
+ STACK_IGNFAULTS,
35
+ STACK_LAZYFP,
36
+} StackingMode;
37
+
38
static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
39
- ARMMMUIdx mmu_idx, bool ignfault)
40
+ ARMMMUIdx mmu_idx, StackingMode mode)
41
{
42
CPUState *cs = CPU(cpu);
43
CPUARMState *env = &cpu->env;
44
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
45
&attrs, &prot, &page_size, &fi, NULL)) {
46
/* MPU/SAU lookup failed */
47
if (fi.type == ARMFault_QEMU_SFault) {
48
- qemu_log_mask(CPU_LOG_INT,
49
- "...SecureFault with SFSR.AUVIOL during stacking\n");
50
- env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK | R_V7M_SFSR_SFARVALID_MASK;
51
+ if (mode == STACK_LAZYFP) {
52
+ qemu_log_mask(CPU_LOG_INT,
53
+ "...SecureFault with SFSR.LSPERR "
54
+ "during lazy stacking\n");
55
+ env->v7m.sfsr |= R_V7M_SFSR_LSPERR_MASK;
56
+ } else {
57
+ qemu_log_mask(CPU_LOG_INT,
58
+ "...SecureFault with SFSR.AUVIOL "
59
+ "during stacking\n");
60
+ env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK;
61
+ }
62
+ env->v7m.sfsr |= R_V7M_SFSR_SFARVALID_MASK;
63
env->v7m.sfar = addr;
64
exc = ARMV7M_EXCP_SECURE;
65
exc_secure = false;
66
} else {
67
- qemu_log_mask(CPU_LOG_INT, "...MemManageFault with CFSR.MSTKERR\n");
68
- env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK;
69
+ if (mode == STACK_LAZYFP) {
70
+ qemu_log_mask(CPU_LOG_INT,
71
+ "...MemManageFault with CFSR.MLSPERR\n");
72
+ env->v7m.cfsr[secure] |= R_V7M_CFSR_MLSPERR_MASK;
73
+ } else {
74
+ qemu_log_mask(CPU_LOG_INT,
75
+ "...MemManageFault with CFSR.MSTKERR\n");
76
+ env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK;
77
+ }
78
exc = ARMV7M_EXCP_MEM;
79
exc_secure = secure;
80
}
81
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
82
attrs, &txres);
83
if (txres != MEMTX_OK) {
84
/* BusFault trying to write the data */
85
- qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n");
86
- env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK;
87
+ if (mode == STACK_LAZYFP) {
88
+ qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.LSPERR\n");
89
+ env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_LSPERR_MASK;
90
+ } else {
91
+ qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n");
92
+ env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK;
93
+ }
94
exc = ARMV7M_EXCP_BUS;
95
exc_secure = false;
96
goto pend_fault;
97
@@ -XXX,XX +XXX,XX @@ pend_fault:
98
* later if we have two derived exceptions.
99
* The only case when we must not pend the exception but instead
100
* throw it away is if we are doing the push of the callee registers
101
- * and we've already generated a derived exception. Even in this
102
- * case we will still update the fault status registers.
103
+ * and we've already generated a derived exception (this is indicated
104
+ * by the caller passing STACK_IGNFAULTS). Even in this case we will
105
+ * still update the fault status registers.
106
*/
107
- if (!ignfault) {
108
+ switch (mode) {
109
+ case STACK_NORMAL:
110
armv7m_nvic_set_pending_derived(env->nvic, exc, exc_secure);
111
+ break;
112
+ case STACK_LAZYFP:
113
+ armv7m_nvic_set_pending_lazyfp(env->nvic, exc, exc_secure);
114
+ break;
115
+ case STACK_IGNFAULTS:
116
+ break;
117
}
118
return false;
119
}
120
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
121
uint32_t limit;
122
bool want_psp;
123
uint32_t sig;
124
+ StackingMode smode = ignore_faults ? STACK_IGNFAULTS : STACK_NORMAL;
125
126
if (dotailchain) {
127
bool mode = lr & R_V7M_EXCRET_MODE_MASK;
128
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
129
*/
130
sig = v7m_integrity_sig(env, lr);
131
stacked_ok =
132
- v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) &&
133
- v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx,
134
- ignore_faults) &&
135
- v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx,
136
- ignore_faults) &&
137
- v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx,
138
- ignore_faults) &&
139
- v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx,
140
- ignore_faults) &&
141
- v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx,
142
- ignore_faults) &&
143
- v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx,
144
- ignore_faults) &&
145
- v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx,
146
- ignore_faults) &&
147
- v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx,
148
- ignore_faults);
149
+ v7m_stack_write(cpu, frameptr, sig, mmu_idx, smode) &&
150
+ v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, smode) &&
151
+ v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, smode) &&
152
+ v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, smode) &&
153
+ v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, smode) &&
154
+ v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, smode) &&
155
+ v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, smode) &&
156
+ v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, smode) &&
157
+ v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, smode);
158
159
/* Update SP regardless of whether any of the stack accesses failed. */
160
*frame_sp_p = frameptr;
161
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
162
* if it has higher priority).
163
*/
164
stacked_ok = stacked_ok &&
165
- v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) &&
166
- v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) &&
167
- v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) &&
168
- v7m_stack_write(cpu, frameptr + 12, env->regs[3], mmu_idx, false) &&
169
- v7m_stack_write(cpu, frameptr + 16, env->regs[12], mmu_idx, false) &&
170
- v7m_stack_write(cpu, frameptr + 20, env->regs[14], mmu_idx, false) &&
171
- v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
172
- v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
173
+ v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, STACK_NORMAL) &&
174
+ v7m_stack_write(cpu, frameptr + 4, env->regs[1],
175
+ mmu_idx, STACK_NORMAL) &&
176
+ v7m_stack_write(cpu, frameptr + 8, env->regs[2],
177
+ mmu_idx, STACK_NORMAL) &&
178
+ v7m_stack_write(cpu, frameptr + 12, env->regs[3],
179
+ mmu_idx, STACK_NORMAL) &&
180
+ v7m_stack_write(cpu, frameptr + 16, env->regs[12],
181
+ mmu_idx, STACK_NORMAL) &&
182
+ v7m_stack_write(cpu, frameptr + 20, env->regs[14],
183
+ mmu_idx, STACK_NORMAL) &&
184
+ v7m_stack_write(cpu, frameptr + 24, env->regs[15],
185
+ mmu_idx, STACK_NORMAL) &&
186
+ v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, STACK_NORMAL);
187
188
if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) {
189
/* FPU is active, try to save its registers */
190
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
191
faddr += 8; /* skip the slot for the FPSCR */
192
}
193
stacked_ok = stacked_ok &&
194
- v7m_stack_write(cpu, faddr, slo, mmu_idx, false) &&
195
- v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false);
196
+ v7m_stack_write(cpu, faddr, slo,
197
+ mmu_idx, STACK_NORMAL) &&
198
+ v7m_stack_write(cpu, faddr + 4, shi,
199
+ mmu_idx, STACK_NORMAL);
200
}
201
stacked_ok = stacked_ok &&
202
v7m_stack_write(cpu, frameptr + 0x60,
203
- vfp_get_fpscr(env), mmu_idx, false);
204
+ vfp_get_fpscr(env), mmu_idx, STACK_NORMAL);
205
if (cpacr_pass) {
206
for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
207
*aa32_vfp_dreg(env, i / 2) = 0;
208
--
209
2.20.1
210
211
diff view generated by jsdifflib
Deleted patch
1
Enable the FPU by default for the Cortex-M4 and Cortex-M33.
2
1
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-27-peter.maydell@linaro.org
6
---
7
target/arm/cpu.c | 8 ++++++++
8
1 file changed, 8 insertions(+)
9
10
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/arm/cpu.c
13
+++ b/target/arm/cpu.c
14
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
15
set_feature(&cpu->env, ARM_FEATURE_M);
16
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
17
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
18
+ set_feature(&cpu->env, ARM_FEATURE_VFP4);
19
cpu->midr = 0x410fc240; /* r0p0 */
20
cpu->pmsav7_dregion = 8;
21
+ cpu->isar.mvfr0 = 0x10110021;
22
+ cpu->isar.mvfr1 = 0x11000011;
23
+ cpu->isar.mvfr2 = 0x00000000;
24
cpu->id_pfr0 = 0x00000030;
25
cpu->id_pfr1 = 0x00000200;
26
cpu->id_dfr0 = 0x00100000;
27
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
28
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
29
set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
30
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
31
+ set_feature(&cpu->env, ARM_FEATURE_VFP4);
32
cpu->midr = 0x410fd213; /* r0p3 */
33
cpu->pmsav7_dregion = 16;
34
cpu->sau_sregion = 8;
35
+ cpu->isar.mvfr0 = 0x10110021;
36
+ cpu->isar.mvfr1 = 0x11000011;
37
+ cpu->isar.mvfr2 = 0x00000040;
38
cpu->id_pfr0 = 0x00000030;
39
cpu->id_pfr1 = 0x00000210;
40
cpu->id_dfr0 = 0x00200000;
41
--
42
2.20.1
43
44
diff view generated by jsdifflib