1
target-arm queue. The big thing here is the landing of the 3-phase
1
The following changes since commit 5a67d7735d4162630769ef495cf813244fc850df:
2
reset patches...
3
2
4
-- PMM
3
Merge remote-tracking branch 'remotes/berrange-gitlab/tags/tls-deps-pull-request' into staging (2021-07-02 08:22:39 +0100)
5
6
The following changes since commit 204aa60b37c23a89e690d418f49787d274303ca7:
7
8
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-jan-29-2020' into staging (2020-01-30 14:18:45 +0000)
9
4
10
are available in the Git repository at:
5
are available in the Git repository at:
11
6
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200130
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210702
13
8
14
for you to fetch changes up to dea101a1ae9968c9fec6ab0291489dad7c49f36f:
9
for you to fetch changes up to 04ea4d3cfd0a21b248ece8eb7a9436a3d9898dd8:
15
10
16
target/arm/cpu: Add the kvm-no-adjvtime CPU property (2020-01-30 16:02:06 +0000)
11
target/arm: Implement MVE shifts by register (2021-07-02 11:48:38 +0100)
17
12
18
----------------------------------------------------------------
13
----------------------------------------------------------------
19
target-arm queue:
14
target-arm queue:
20
* hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
15
* more MVE instructions
21
* target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr
16
* hw/gpio/gpio_pwr: use shutdown function for reboot
22
* aspeed: some minor bugfixes
17
* target/arm: Check NaN mode before silencing NaN
23
* aspeed: add eMMC controller model for AST2600 SoC
18
* tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine
24
* hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus'
19
* hw/arm: Add basic power management to raspi.
25
* New 3-phase reset API for device models
20
* docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc
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
28
21
29
----------------------------------------------------------------
22
----------------------------------------------------------------
30
Andrew Jeffery (2):
23
Joe Komlodi (1):
31
hw/sd: Configure number of slots exposed by the ASPEED SDHCI model
24
target/arm: Check NaN mode before silencing NaN
32
hw/arm: ast2600: Wire up the eMMC controller
33
25
34
Andrew Jones (6):
26
Maxim Uvarov (1):
35
target/arm/kvm: trivial: Clean up header documentation
27
hw/gpio/gpio_pwr: use shutdown function for reboot
36
hw/arm/virt: Add missing 5.0 options call to 4.2 options
37
target/arm/kvm64: kvm64 cpus have timer registers
38
tests/arm-cpu-features: Check feature default values
39
target/arm/kvm: Implement virtual time adjustment
40
target/arm/cpu: Add the kvm-no-adjvtime CPU property
41
28
42
Cédric Le Goater (2):
29
Nolan Leake (1):
43
ftgmac100: check RX and TX buffer alignment
30
hw/arm: Add basic power management to raspi.
44
hw/arm/aspeed: add a 'execute-in-place' property to boot directly from CE0
45
31
46
Damien Hedde (11):
32
Patrick Venture (2):
47
add device_legacy_reset function to prepare for reset api change
33
docs/system/arm: Add quanta-q7l1-bmc reference
48
hw/core/qdev: add trace events to help with resettable transition
34
docs/system/arm: Add quanta-gbs-bmc reference
49
hw/core: create Resettable QOM interface
50
hw/core: add Resettable support to BusClass and DeviceClass
51
hw/core/resettable: add support for changing parent
52
hw/core/qdev: handle parent bus change regarding resettable
53
hw/core/qdev: update hotplug reset regarding resettable
54
hw/core: deprecate old reset functions and introduce new ones
55
docs/devel/reset.rst: add doc about Resettable interface
56
vl: replace deprecated qbus_reset_all registration
57
hw/s390x/ipl: replace deprecated qdev_reset_all registration
58
35
59
Joel Stanley (1):
36
Peter Maydell (18):
60
misc/pca9552: Add qom set and get
37
target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation
61
38
target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH
62
Peter Maydell (2):
39
target/arm: Make asimd_imm_const() public
63
hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
40
target/arm: Use asimd_imm_const for A64 decode
64
target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr
41
target/arm: Use dup_const() instead of bitfield_replicate()
42
target/arm: Implement MVE logical immediate insns
43
target/arm: Implement MVE vector shift left by immediate insns
44
target/arm: Implement MVE vector shift right by immediate insns
45
target/arm: Implement MVE VSHLL
46
target/arm: Implement MVE VSRI, VSLI
47
target/arm: Implement MVE VSHRN, VRSHRN
48
target/arm: Implement MVE saturating narrowing shifts
49
target/arm: Implement MVE VSHLC
50
target/arm: Implement MVE VADDLV
51
target/arm: Implement MVE long shifts by immediate
52
target/arm: Implement MVE long shifts by register
53
target/arm: Implement MVE shifts by immediate
54
target/arm: Implement MVE shifts by register
65
55
66
Philippe Mathieu-Daudé (1):
56
Philippe Mathieu-Daudé (1):
67
hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus'
57
tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine
68
58
69
Zenghui Yu (1):
59
docs/system/arm/aspeed.rst | 1 +
70
hw/intc/arm_gicv3_kvm: Stop wrongly programming GICR_PENDBASER.PTZ bit
60
docs/system/arm/nuvoton.rst | 5 +-
61
include/hw/arm/bcm2835_peripherals.h | 3 +-
62
include/hw/misc/bcm2835_powermgt.h | 29 ++
63
target/arm/helper-mve.h | 108 +++++++
64
target/arm/translate.h | 41 +++
65
target/arm/mve.decode | 177 ++++++++++-
66
target/arm/t32.decode | 71 ++++-
67
hw/arm/bcm2835_peripherals.c | 13 +-
68
hw/gpio/gpio_pwr.c | 2 +-
69
hw/misc/bcm2835_powermgt.c | 160 ++++++++++
70
target/arm/helper-a64.c | 12 +-
71
target/arm/mve_helper.c | 524 +++++++++++++++++++++++++++++++--
72
target/arm/translate-a64.c | 86 +-----
73
target/arm/translate-mve.c | 261 +++++++++++++++-
74
target/arm/translate-neon.c | 81 -----
75
target/arm/translate.c | 327 +++++++++++++++++++-
76
target/arm/vfp_helper.c | 24 +-
77
hw/misc/meson.build | 1 +
78
tests/acceptance/boot_linux_console.py | 43 +++
79
20 files changed, 1760 insertions(+), 209 deletions(-)
80
create mode 100644 include/hw/misc/bcm2835_powermgt.h
81
create mode 100644 hw/misc/bcm2835_powermgt.c
71
82
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
From: Andrew Jones <drjones@redhat.com>
1
From: Patrick Venture <venture@google.com>
2
2
3
Add the missing GENERIC_TIMER feature to kvm64 cpus.
3
Adds a line-item reference to the supported quanta-q71l-bmc aspeed
4
entry.
4
5
5
We don't currently use these registers when KVM is enabled, but it's
6
Signed-off-by: Patrick Venture <venture@google.com>
6
probably best we add the feature flag for consistency and potential
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
7
future use. There's also precedent, as we add the PMU feature flag to
8
Message-id: 20210615192848.1065297-2-venture@google.com
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
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
10
---
18
target/arm/kvm64.c | 1 +
11
docs/system/arm/aspeed.rst | 1 +
19
1 file changed, 1 insertion(+)
12
1 file changed, 1 insertion(+)
20
13
21
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
14
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
22
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/kvm64.c
16
--- a/docs/system/arm/aspeed.rst
24
+++ b/target/arm/kvm64.c
17
+++ b/docs/system/arm/aspeed.rst
25
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
18
@@ -XXX,XX +XXX,XX @@ etc.
26
set_feature(&features, ARM_FEATURE_NEON);
19
AST2400 SoC based machines :
27
set_feature(&features, ARM_FEATURE_AARCH64);
20
28
set_feature(&features, ARM_FEATURE_PMU);
21
- ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC
29
+ set_feature(&features, ARM_FEATURE_GENERIC_TIMER);
22
+- ``quanta-q71l-bmc`` OpenBMC Quanta BMC
30
23
31
ahcf->features = features;
24
AST2500 SoC based machines :
32
25
33
--
26
--
34
2.20.1
27
2.20.1
35
28
36
29
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Patrick Venture <venture@google.com>
2
2
3
If we know what the default value should be then we can test for
3
Add line item reference to quanta-gbs-bmc machine.
4
that as well as the feature existence.
5
4
6
Signed-off-by: Andrew Jones <drjones@redhat.com>
5
Signed-off-by: Patrick Venture <venture@google.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Message-id: 20200120101023.16030-5-drjones@redhat.com
7
Message-id: 20210615192848.1065297-3-venture@google.com
8
[PMM: fixed underline Sphinx warning]
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
tests/qtest/arm-cpu-features.c | 37 +++++++++++++++++++++++++---------
11
docs/system/arm/nuvoton.rst | 5 +++--
12
1 file changed, 28 insertions(+), 9 deletions(-)
12
1 file changed, 3 insertions(+), 2 deletions(-)
13
13
14
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
14
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/arm-cpu-features.c
16
--- a/docs/system/arm/nuvoton.rst
17
+++ b/tests/qtest/arm-cpu-features.c
17
+++ b/docs/system/arm/nuvoton.rst
18
@@ -XXX,XX +XXX,XX @@ static bool resp_get_feature(QDict *resp, const char *feature)
18
@@ -XXX,XX +XXX,XX @@
19
qobject_unref(_resp); \
19
-Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``)
20
})
20
-=====================================================
21
21
+Nuvoton iBMC boards (``*-bmc``, ``npcm750-evb``, ``quanta-gsj``)
22
+#define assert_feature(qts, cpu_type, feature, expected_value) \
22
+================================================================
23
+({ \
23
24
+ QDict *_resp, *_props; \
24
The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are
25
+ \
25
designed to be used as Baseboard Management Controllers (BMCs) in various
26
+ _resp = do_query_no_props(qts, cpu_type); \
26
@@ -XXX,XX +XXX,XX @@ segment. The following machines are based on this chip :
27
+ g_assert(_resp); \
27
The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and
28
+ g_assert(resp_has_props(_resp)); \
28
Hyperscale applications. The following machines are based on this chip :
29
+ _props = resp_get_props(_resp); \
29
30
+ g_assert(qdict_get(_props, feature)); \
30
+- ``quanta-gbs-bmc`` Quanta GBS server BMC
31
+ g_assert(qdict_get_bool(_props, feature) == (expected_value)); \
31
- ``quanta-gsj`` Quanta GSJ server BMC
32
+ qobject_unref(_resp); \
32
33
+})
33
There are also two more SoCs, NPCM710 and NPCM705, which are single-core
34
+
35
+#define assert_has_feature_enabled(qts, cpu_type, feature) \
36
+ assert_feature(qts, cpu_type, feature, true)
37
+
38
+#define assert_has_feature_disabled(qts, cpu_type, feature) \
39
+ assert_feature(qts, cpu_type, feature, false)
40
+
41
static void assert_type_full(QTestState *qts)
42
{
43
const char *error;
44
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data)
45
assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);
46
47
/* Test expected feature presence/absence for some cpu types */
48
- assert_has_feature(qts, "max", "pmu");
49
- assert_has_feature(qts, "cortex-a15", "pmu");
50
+ assert_has_feature_enabled(qts, "max", "pmu");
51
+ assert_has_feature_enabled(qts, "cortex-a15", "pmu");
52
assert_has_not_feature(qts, "cortex-a15", "aarch64");
53
54
if (g_str_equal(qtest_get_arch(), "aarch64")) {
55
- assert_has_feature(qts, "max", "aarch64");
56
- assert_has_feature(qts, "max", "sve");
57
- assert_has_feature(qts, "max", "sve128");
58
- assert_has_feature(qts, "cortex-a57", "pmu");
59
- assert_has_feature(qts, "cortex-a57", "aarch64");
60
+ assert_has_feature_enabled(qts, "max", "aarch64");
61
+ assert_has_feature_enabled(qts, "max", "sve");
62
+ assert_has_feature_enabled(qts, "max", "sve128");
63
+ assert_has_feature_enabled(qts, "cortex-a57", "pmu");
64
+ assert_has_feature_enabled(qts, "cortex-a57", "aarch64");
65
66
sve_tests_default(qts, "max");
67
68
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
69
QDict *resp;
70
char *error;
71
72
- assert_has_feature(qts, "host", "aarch64");
73
- assert_has_feature(qts, "host", "pmu");
74
+ assert_has_feature_enabled(qts, "host", "aarch64");
75
+ assert_has_feature_enabled(qts, "host", "pmu");
76
77
assert_error(qts, "cortex-a15",
78
"We cannot guarantee the CPU type 'cortex-a15' works "
79
--
34
--
80
2.20.1
35
2.20.1
81
36
82
37
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
From: Nolan Leake <nolan@sigbus.net>
2
2
3
This commit defines an interface allowing multi-phase reset. This aims
3
This is just enough to make reboot and poweroff work. Works for
4
to solve a problem of the actual single-phase reset (built in
4
linux, u-boot, and the arm trusted firmware. Not tested, but should
5
DeviceClass and BusClass): reset behavior is dependent on the order
5
work for plan9, and bare-metal/hobby OSes, since they seem to generally
6
in which reset handlers are called. In particular doing external
6
do what linux does for reset.
7
side-effect (like setting an qemu_irq) is problematic because receiving
7
8
object may not be reset yet.
8
The watchdog timer functionality is not yet implemented.
9
9
10
The Resettable interface divides the reset in 3 well defined phases.
10
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/64
11
To reset an object tree, all 1st phases are executed then all 2nd then
11
Signed-off-by: Nolan Leake <nolan@sigbus.net>
12
all 3rd. See the comments in include/hw/resettable.h for a more complete
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
description. The interface defines 3 phases to let the future
13
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
possibility of holding an object into reset for some time.
14
Message-id: 20210625210209.1870217-1-nolan@sigbus.net
15
15
[PMM: tweaked commit title; fixed region size to 0x200;
16
The qdev/qbus reset in DeviceClass and BusClass will be modified in
16
moved header file to include/]
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
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
---
18
---
32
hw/core/Makefile.objs | 1 +
19
include/hw/arm/bcm2835_peripherals.h | 3 +-
33
include/hw/resettable.h | 211 +++++++++++++++++++++++++++++++++++
20
include/hw/misc/bcm2835_powermgt.h | 29 +++++
34
hw/core/resettable.c | 238 ++++++++++++++++++++++++++++++++++++++++
21
hw/arm/bcm2835_peripherals.c | 13 ++-
35
hw/core/trace-events | 17 +++
22
hw/misc/bcm2835_powermgt.c | 160 +++++++++++++++++++++++++++
36
4 files changed, 467 insertions(+)
23
hw/misc/meson.build | 1 +
37
create mode 100644 include/hw/resettable.h
24
5 files changed, 204 insertions(+), 2 deletions(-)
38
create mode 100644 hw/core/resettable.c
25
create mode 100644 include/hw/misc/bcm2835_powermgt.h
39
26
create mode 100644 hw/misc/bcm2835_powermgt.c
40
diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
27
28
diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h
41
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/core/Makefile.objs
30
--- a/include/hw/arm/bcm2835_peripherals.h
43
+++ b/hw/core/Makefile.objs
31
+++ b/include/hw/arm/bcm2835_peripherals.h
44
@@ -XXX,XX +XXX,XX @@
32
@@ -XXX,XX +XXX,XX @@
45
common-obj-y += qdev.o qdev-properties.o
33
#include "hw/misc/bcm2835_mphi.h"
46
common-obj-y += bus.o
34
#include "hw/misc/bcm2835_thermal.h"
47
common-obj-y += cpu.o
35
#include "hw/misc/bcm2835_cprman.h"
48
+common-obj-y += resettable.o
36
+#include "hw/misc/bcm2835_powermgt.h"
49
common-obj-y += hotplug.o
37
#include "hw/sd/sdhci.h"
50
common-obj-y += vmstate-if.o
38
#include "hw/sd/bcm2835_sdhost.h"
51
# irq.o needed for qdev GPIO handling:
39
#include "hw/gpio/bcm2835_gpio.h"
52
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
40
@@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState {
41
BCM2835MphiState mphi;
42
UnimplementedDeviceState txp;
43
UnimplementedDeviceState armtmr;
44
- UnimplementedDeviceState powermgt;
45
+ BCM2835PowerMgtState powermgt;
46
BCM2835CprmanState cprman;
47
PL011State uart0;
48
BCM2835AuxState aux;
49
diff --git a/include/hw/misc/bcm2835_powermgt.h b/include/hw/misc/bcm2835_powermgt.h
53
new file mode 100644
50
new file mode 100644
54
index XXXXXXX..XXXXXXX
51
index XXXXXXX..XXXXXXX
55
--- /dev/null
52
--- /dev/null
56
+++ b/include/hw/resettable.h
53
+++ b/include/hw/misc/bcm2835_powermgt.h
57
@@ -XXX,XX +XXX,XX @@
54
@@ -XXX,XX +XXX,XX @@
58
+/*
55
+/*
59
+ * Resettable interface header.
56
+ * BCM2835 Power Management emulation
60
+ *
57
+ *
61
+ * Copyright (c) 2019 GreenSocs SAS
58
+ * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com>
62
+ *
59
+ * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net>
63
+ * Authors:
64
+ * Damien Hedde
65
+ *
60
+ *
66
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
61
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
67
+ * See the COPYING file in the top-level directory.
62
+ * See the COPYING file in the top-level directory.
68
+ */
63
+ */
69
+
64
+
70
+#ifndef HW_RESETTABLE_H
65
+#ifndef BCM2835_POWERMGT_H
71
+#define HW_RESETTABLE_H
66
+#define BCM2835_POWERMGT_H
72
+
67
+
68
+#include "hw/sysbus.h"
73
+#include "qom/object.h"
69
+#include "qom/object.h"
74
+
70
+
75
+#define TYPE_RESETTABLE_INTERFACE "resettable"
71
+#define TYPE_BCM2835_POWERMGT "bcm2835-powermgt"
76
+
72
+OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PowerMgtState, BCM2835_POWERMGT)
77
+#define RESETTABLE_CLASS(class) \
73
+
78
+ OBJECT_CLASS_CHECK(ResettableClass, (class), TYPE_RESETTABLE_INTERFACE)
74
+struct BCM2835PowerMgtState {
79
+
75
+ SysBusDevice busdev;
80
+#define RESETTABLE_GET_CLASS(obj) \
76
+ MemoryRegion iomem;
81
+ OBJECT_GET_CLASS(ResettableClass, (obj), TYPE_RESETTABLE_INTERFACE)
77
+
82
+
78
+ uint32_t rstc;
83
+typedef struct ResettableState ResettableState;
79
+ uint32_t rsts;
84
+
80
+ uint32_t wdog;
85
+/**
81
+};
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);
267
+
82
+
268
+#endif
83
+#endif
269
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
84
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
85
index XXXXXXX..XXXXXXX 100644
86
--- a/hw/arm/bcm2835_peripherals.c
87
+++ b/hw/arm/bcm2835_peripherals.c
88
@@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj)
89
90
object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr",
91
OBJECT(&s->gpu_bus_mr));
92
+
93
+ /* Power Management */
94
+ object_initialize_child(obj, "powermgt", &s->powermgt,
95
+ TYPE_BCM2835_POWERMGT);
96
}
97
98
static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
99
@@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
100
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
101
INTERRUPT_USB));
102
103
+ /* Power Management */
104
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->powermgt), errp)) {
105
+ return;
106
+ }
107
+
108
+ memory_region_add_subregion(&s->peri_mr, PM_OFFSET,
109
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->powermgt), 0));
110
+
111
create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000);
112
create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40);
113
- create_unimp(s, &s->powermgt, "bcm2835-powermgt", PM_OFFSET, 0x114);
114
create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100);
115
create_unimp(s, &s->smi, "bcm2835-smi", SMI_OFFSET, 0x100);
116
create_unimp(s, &s->spi[0], "bcm2835-spi0", SPI0_OFFSET, 0x20);
117
diff --git a/hw/misc/bcm2835_powermgt.c b/hw/misc/bcm2835_powermgt.c
270
new file mode 100644
118
new file mode 100644
271
index XXXXXXX..XXXXXXX
119
index XXXXXXX..XXXXXXX
272
--- /dev/null
120
--- /dev/null
273
+++ b/hw/core/resettable.c
121
+++ b/hw/misc/bcm2835_powermgt.c
274
@@ -XXX,XX +XXX,XX @@
122
@@ -XXX,XX +XXX,XX @@
275
+/*
123
+/*
276
+ * Resettable interface.
124
+ * BCM2835 Power Management emulation
277
+ *
125
+ *
278
+ * Copyright (c) 2019 GreenSocs SAS
126
+ * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com>
279
+ *
127
+ * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net>
280
+ * Authors:
281
+ * Damien Hedde
282
+ *
128
+ *
283
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
129
+ * 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.
130
+ * See the COPYING file in the top-level directory.
285
+ */
131
+ */
286
+
132
+
287
+#include "qemu/osdep.h"
133
+#include "qemu/osdep.h"
134
+#include "qemu/log.h"
288
+#include "qemu/module.h"
135
+#include "qemu/module.h"
289
+#include "hw/resettable.h"
136
+#include "hw/misc/bcm2835_powermgt.h"
290
+#include "trace.h"
137
+#include "migration/vmstate.h"
291
+
138
+#include "sysemu/runstate.h"
292
+/**
139
+
293
+ * resettable_phase_enter/hold/exit:
140
+#define PASSWORD 0x5a000000
294
+ * Function executing a phase recursively in a resettable object and its
141
+#define PASSWORD_MASK 0xff000000
295
+ * children.
142
+
296
+ */
143
+#define R_RSTC 0x1c
297
+static void resettable_phase_enter(Object *obj, void *opaque, ResetType type);
144
+#define V_RSTC_RESET 0x20
298
+static void resettable_phase_hold(Object *obj, void *opaque, ResetType type);
145
+#define R_RSTS 0x20
299
+static void resettable_phase_exit(Object *obj, void *opaque, ResetType type);
146
+#define V_RSTS_POWEROFF 0x555 /* Linux uses partition 63 to indicate halt. */
300
+
147
+#define R_WDOG 0x24
301
+/**
148
+
302
+ * enter_phase_in_progress:
149
+static uint64_t bcm2835_powermgt_read(void *opaque, hwaddr offset,
303
+ * True if we are currently in reset enter phase.
150
+ unsigned size)
304
+ *
151
+{
305
+ * Note: This flag is only used to guarantee (using asserts) that the reset
152
+ BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque;
306
+ * API is used correctly. We can use a global variable because we rely on the
153
+ uint32_t res = 0;
307
+ * iothread mutex to ensure only one reset operation is in a progress at a
154
+
308
+ * given time.
155
+ switch (offset) {
309
+ */
156
+ case R_RSTC:
310
+static bool enter_phase_in_progress;
157
+ res = s->rstc;
311
+
158
+ break;
312
+void resettable_reset(Object *obj, ResetType type)
159
+ case R_RSTS:
313
+{
160
+ res = s->rsts;
314
+ trace_resettable_reset(obj, type);
161
+ break;
315
+ resettable_assert_reset(obj, type);
162
+ case R_WDOG:
316
+ resettable_release_reset(obj, type);
163
+ res = s->wdog;
317
+}
164
+ break;
318
+
165
+
319
+void resettable_assert_reset(Object *obj, ResetType type)
166
+ default:
320
+{
167
+ qemu_log_mask(LOG_UNIMP,
321
+ /* TODO: change this assert when adding support for other reset types */
168
+ "bcm2835_powermgt_read: Unknown offset 0x%08"HWADDR_PRIx
322
+ assert(type == RESET_TYPE_COLD);
169
+ "\n", offset);
323
+ trace_resettable_reset_assert_begin(obj, type);
170
+ res = 0;
324
+ assert(!enter_phase_in_progress);
171
+ break;
325
+
172
+ }
326
+ enter_phase_in_progress = true;
173
+
327
+ resettable_phase_enter(obj, NULL, type);
174
+ return res;
328
+ enter_phase_in_progress = false;
175
+}
329
+
176
+
330
+ resettable_phase_hold(obj, NULL, type);
177
+static void bcm2835_powermgt_write(void *opaque, hwaddr offset,
331
+
178
+ uint64_t value, unsigned size)
332
+ trace_resettable_reset_assert_end(obj);
179
+{
333
+}
180
+ BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque;
334
+
181
+
335
+void resettable_release_reset(Object *obj, ResetType type)
182
+ if ((value & PASSWORD_MASK) != PASSWORD) {
336
+{
183
+ qemu_log_mask(LOG_GUEST_ERROR,
337
+ /* TODO: change this assert when adding support for other reset types */
184
+ "bcm2835_powermgt_write: Bad password 0x%"PRIx64
338
+ assert(type == RESET_TYPE_COLD);
185
+ " at offset 0x%08"HWADDR_PRIx"\n",
339
+ trace_resettable_reset_release_begin(obj, type);
186
+ value, offset);
340
+ assert(!enter_phase_in_progress);
187
+ return;
341
+
188
+ }
342
+ resettable_phase_exit(obj, NULL, type);
189
+
343
+
190
+ value = value & ~PASSWORD_MASK;
344
+ trace_resettable_reset_release_end(obj);
191
+
345
+}
192
+ switch (offset) {
346
+
193
+ case R_RSTC:
347
+bool resettable_is_in_reset(Object *obj)
194
+ s->rstc = value;
348
+{
195
+ if (value & V_RSTC_RESET) {
349
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
196
+ if ((s->rsts & 0xfff) == V_RSTS_POWEROFF) {
350
+ ResettableState *s = rc->get_state(obj);
197
+ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
351
+
198
+ } else {
352
+ return s->count > 0;
199
+ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
353
+}
200
+ }
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
+ }
201
+ }
424
+ s->hold_phase_pending = true;
202
+ break;
425
+ }
203
+ case R_RSTS:
426
+ trace_resettable_phase_enter_end(obj, obj_typename, s->count);
204
+ qemu_log_mask(LOG_UNIMP,
427
+}
205
+ "bcm2835_powermgt_write: RSTS\n");
428
+
206
+ s->rsts = value;
429
+static void resettable_phase_hold(Object *obj, void *opaque, ResetType type)
207
+ break;
430
+{
208
+ case R_WDOG:
431
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
209
+ qemu_log_mask(LOG_UNIMP,
432
+ ResettableState *s = rc->get_state(obj);
210
+ "bcm2835_powermgt_write: WDOG\n");
433
+ const char *obj_typename = object_get_typename(obj);
211
+ s->wdog = value;
434
+
212
+ break;
435
+ /* exit phase has to finish properly before entering back in reset */
213
+
436
+ assert(!s->exit_phase_in_progress);
214
+ default:
437
+
215
+ qemu_log_mask(LOG_UNIMP,
438
+ trace_resettable_phase_hold_begin(obj, obj_typename, s->count, type);
216
+ "bcm2835_powermgt_write: Unknown offset 0x%08"HWADDR_PRIx
439
+
217
+ "\n", offset);
440
+ /* handle children first */
218
+ break;
441
+ resettable_child_foreach(rc, obj, resettable_phase_hold, NULL, type);
219
+ }
442
+
220
+}
443
+ /* exec hold phase */
221
+
444
+ if (s->hold_phase_pending) {
222
+static const MemoryRegionOps bcm2835_powermgt_ops = {
445
+ s->hold_phase_pending = false;
223
+ .read = bcm2835_powermgt_read,
446
+ ResettableTrFunction tr_func = resettable_get_tr_func(rc, obj);
224
+ .write = bcm2835_powermgt_write,
447
+ trace_resettable_phase_hold_exec(obj, obj_typename, !!rc->phases.hold);
225
+ .endianness = DEVICE_NATIVE_ENDIAN,
448
+ if (tr_func) {
226
+ .impl.min_access_size = 4,
449
+ trace_resettable_transitional_function(obj, obj_typename);
227
+ .impl.max_access_size = 4,
450
+ tr_func(obj);
228
+};
451
+ } else if (rc->phases.hold) {
229
+
452
+ rc->phases.hold(obj);
230
+static const VMStateDescription vmstate_bcm2835_powermgt = {
453
+ }
231
+ .name = TYPE_BCM2835_POWERMGT,
454
+ }
232
+ .version_id = 1,
455
+ trace_resettable_phase_hold_end(obj, obj_typename, s->count);
233
+ .minimum_version_id = 1,
456
+}
234
+ .fields = (VMStateField[]) {
457
+
235
+ VMSTATE_UINT32(rstc, BCM2835PowerMgtState),
458
+static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
236
+ VMSTATE_UINT32(rsts, BCM2835PowerMgtState),
459
+{
237
+ VMSTATE_UINT32(wdog, BCM2835PowerMgtState),
460
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
238
+ VMSTATE_END_OF_LIST()
461
+ ResettableState *s = rc->get_state(obj);
239
+ }
462
+ const char *obj_typename = object_get_typename(obj);
240
+};
463
+
241
+
464
+ assert(!s->exit_phase_in_progress);
242
+static void bcm2835_powermgt_init(Object *obj)
465
+ trace_resettable_phase_exit_begin(obj, obj_typename, s->count, type);
243
+{
466
+
244
+ BCM2835PowerMgtState *s = BCM2835_POWERMGT(obj);
467
+ /* exit_phase_in_progress ensures this phase is 'atomic' */
245
+
468
+ s->exit_phase_in_progress = true;
246
+ memory_region_init_io(&s->iomem, obj, &bcm2835_powermgt_ops, s,
469
+ resettable_child_foreach(rc, obj, resettable_phase_exit, NULL, type);
247
+ TYPE_BCM2835_POWERMGT, 0x200);
470
+
248
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
471
+ assert(s->count > 0);
249
+}
472
+ if (s->count == 1) {
250
+
473
+ trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
251
+static void bcm2835_powermgt_reset(DeviceState *dev)
474
+ if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
252
+{
475
+ rc->phases.exit(obj);
253
+ BCM2835PowerMgtState *s = BCM2835_POWERMGT(dev);
476
+ }
254
+
477
+ s->count = 0;
255
+ /* https://elinux.org/BCM2835_registers#PM */
478
+ }
256
+ s->rstc = 0x00000102;
479
+ s->exit_phase_in_progress = false;
257
+ s->rsts = 0x00001000;
480
+ trace_resettable_phase_exit_end(obj, obj_typename, s->count);
258
+ s->wdog = 0x00000000;
481
+}
259
+}
482
+
260
+
483
+void resettable_class_set_parent_phases(ResettableClass *rc,
261
+static void bcm2835_powermgt_class_init(ObjectClass *klass, void *data)
484
+ ResettableEnterPhase enter,
262
+{
485
+ ResettableHoldPhase hold,
263
+ DeviceClass *dc = DEVICE_CLASS(klass);
486
+ ResettableExitPhase exit,
264
+
487
+ ResettablePhases *parent_phases)
265
+ dc->reset = bcm2835_powermgt_reset;
488
+{
266
+ dc->vmsd = &vmstate_bcm2835_powermgt;
489
+ *parent_phases = rc->phases;
267
+}
490
+ if (enter) {
268
+
491
+ rc->phases.enter = enter;
269
+static TypeInfo bcm2835_powermgt_info = {
492
+ }
270
+ .name = TYPE_BCM2835_POWERMGT,
493
+ if (hold) {
271
+ .parent = TYPE_SYS_BUS_DEVICE,
494
+ rc->phases.hold = hold;
272
+ .instance_size = sizeof(BCM2835PowerMgtState),
495
+ }
273
+ .class_init = bcm2835_powermgt_class_init,
496
+ if (exit) {
274
+ .instance_init = bcm2835_powermgt_init,
497
+ rc->phases.exit = exit;
275
+};
498
+ }
276
+
499
+}
277
+static void bcm2835_powermgt_register_types(void)
500
+
278
+{
501
+static const TypeInfo resettable_interface_info = {
279
+ type_register_static(&bcm2835_powermgt_info);
502
+ .name = TYPE_RESETTABLE_INTERFACE,
280
+}
503
+ .parent = TYPE_INTERFACE,
281
+
504
+ .class_size = sizeof(ResettableClass),
282
+type_init(bcm2835_powermgt_register_types)
505
+};
283
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
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
514
index XXXXXXX..XXXXXXX 100644
284
index XXXXXXX..XXXXXXX 100644
515
--- a/hw/core/trace-events
285
--- a/hw/misc/meson.build
516
+++ b/hw/core/trace-events
286
+++ b/hw/misc/meson.build
517
@@ -XXX,XX +XXX,XX @@ qbus_reset(void *obj, const char *objtype) "obj=%p(%s)"
287
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files(
518
qbus_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
288
'bcm2835_rng.c',
519
qbus_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
289
'bcm2835_thermal.c',
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)"
290
'bcm2835_cprman.c',
521
+
291
+ 'bcm2835_powermgt.c',
522
+# resettable.c
292
))
523
+resettable_reset(void *obj, int cold) "obj=%p cold=%d"
293
softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c'))
524
+resettable_reset_assert_begin(void *obj, int cold) "obj=%p cold=%d"
294
softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c'))
525
+resettable_reset_assert_end(void *obj) "obj=%p"
526
+resettable_reset_release_begin(void *obj, int cold) "obj=%p cold=%d"
527
+resettable_reset_release_end(void *obj) "obj=%p"
528
+resettable_phase_enter_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
529
+resettable_phase_enter_exec(void *obj, const char *objtype, int type, int has_method) "obj=%p(%s) type=%d method=%d"
530
+resettable_phase_enter_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
531
+resettable_phase_hold_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
532
+resettable_phase_hold_exec(void *obj, const char *objtype, int has_method) "obj=%p(%s) method=%d"
533
+resettable_phase_hold_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
534
+resettable_phase_exit_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
535
+resettable_phase_exit_exec(void *obj, const char *objtype, int has_method) "obj=%p(%s) method=%d"
536
+resettable_phase_exit_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
537
+resettable_transitional_function(void *obj, const char *objtype) "obj=%p(%s)"
538
--
295
--
539
2.20.1
296
2.20.1
540
297
541
298
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Since we enabled parallel TCG code generation for softmmu (see
3
Add a test booting and quickly shutdown a raspi2 machine,
4
commit 3468b59 "tcg: enable multiple TCG contexts in softmmu")
4
to test the power management model:
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
5
9
See in hw/arm/raspi2 (with BCM283X_NCPUS set to 4):
6
(1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd:
7
console: [ 0.000000] Booting Linux on physical CPU 0xf00
8
console: [ 0.000000] Linux version 4.14.98-v7+ (dom@dom-XPS-13-9370) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1200 SMP Tue Feb 12 20:27:48 GMT 2019
9
console: [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
10
console: [ 0.000000] CPU: div instructions available: patching division code
11
console: [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
12
console: [ 0.000000] OF: fdt: Machine model: Raspberry Pi 2 Model B
13
...
14
console: Boot successful.
15
console: cat /proc/cpuinfo
16
console: / # cat /proc/cpuinfo
17
...
18
console: processor : 3
19
console: model name : ARMv7 Processor rev 5 (v7l)
20
console: BogoMIPS : 125.00
21
console: Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
22
console: CPU implementer : 0x41
23
console: CPU architecture: 7
24
console: CPU variant : 0x0
25
console: CPU part : 0xc07
26
console: CPU revision : 5
27
console: Hardware : BCM2835
28
console: Revision : 0000
29
console: Serial : 0000000000000000
30
console: cat /proc/iomem
31
console: / # cat /proc/iomem
32
console: 00000000-3bffffff : System RAM
33
console: 00008000-00afffff : Kernel code
34
console: 00c00000-00d468ef : Kernel data
35
console: 3f006000-3f006fff : dwc_otg
36
console: 3f007000-3f007eff : /soc/dma@7e007000
37
console: 3f00b880-3f00b8bf : /soc/mailbox@7e00b880
38
console: 3f100000-3f100027 : /soc/watchdog@7e100000
39
console: 3f101000-3f102fff : /soc/cprman@7e101000
40
console: 3f200000-3f2000b3 : /soc/gpio@7e200000
41
PASS (24.59 s)
42
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
43
JOB TIME : 25.02 s
10
44
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>
45
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
33
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
46
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
34
Message-id: 20200120235159.18510-2-f4bug@amsat.org
47
Message-id: 20210531113837.1689775-1-f4bug@amsat.org
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
48
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
36
---
49
---
37
hw/arm/raspi.c | 2 --
50
tests/acceptance/boot_linux_console.py | 43 ++++++++++++++++++++++++++
38
1 file changed, 2 deletions(-)
51
1 file changed, 43 insertions(+)
39
52
40
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
53
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
41
index XXXXXXX..XXXXXXX 100644
54
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/arm/raspi.c
55
--- a/tests/acceptance/boot_linux_console.py
43
+++ b/hw/arm/raspi.c
56
+++ b/tests/acceptance/boot_linux_console.py
44
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
57
@@ -XXX,XX +XXX,XX @@
45
/* Setup the SOC */
58
from avocado import skip
46
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
59
from avocado import skipUnless
47
&error_abort);
60
from avocado_qemu import Test
48
- object_property_set_int(OBJECT(&s->soc), machine->smp.cpus, "enabled-cpus",
61
+from avocado_qemu import exec_command
49
- &error_abort);
62
from avocado_qemu import exec_command_and_wait_for_pattern
50
int board_rev = version == 3 ? 0xa02082 : 0xa21041;
63
from avocado_qemu import interrupt_interactive_console_until_pattern
51
object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev",
64
from avocado_qemu import wait_for_console_pattern
52
&error_abort);
65
@@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self):
66
"""
67
self.do_test_arm_raspi2(0)
68
69
+ def test_arm_raspi2_initrd(self):
70
+ """
71
+ :avocado: tags=arch:arm
72
+ :avocado: tags=machine:raspi2
73
+ """
74
+ deb_url = ('http://archive.raspberrypi.org/debian/'
75
+ 'pool/main/r/raspberrypi-firmware/'
76
+ 'raspberrypi-kernel_1.20190215-1_armhf.deb')
77
+ deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
78
+ deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
79
+ kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
80
+ dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
81
+
82
+ initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
83
+ '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
84
+ 'arm/rootfs-armv7a.cpio.gz')
85
+ initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
86
+ initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
87
+ initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
88
+ archive.gzip_uncompress(initrd_path_gz, initrd_path)
89
+
90
+ self.vm.set_console()
91
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
92
+ 'earlycon=pl011,0x3f201000 console=ttyAMA0 '
93
+ 'panic=-1 noreboot ' +
94
+ 'dwc_otg.fiq_fsm_enable=0')
95
+ self.vm.add_args('-kernel', kernel_path,
96
+ '-dtb', dtb_path,
97
+ '-initrd', initrd_path,
98
+ '-append', kernel_command_line,
99
+ '-no-reboot')
100
+ self.vm.launch()
101
+ self.wait_for_console_pattern('Boot successful.')
102
+
103
+ exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
104
+ 'BCM2835')
105
+ exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
106
+ '/soc/cprman@7e101000')
107
+ exec_command(self, 'halt')
108
+ # Wait for VM to shut down gracefully
109
+ self.vm.wait()
110
+
111
def test_arm_exynos4210_initrd(self):
112
"""
113
:avocado: tags=arch:arm
53
--
114
--
54
2.20.1
115
2.20.1
55
116
56
117
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Joe Komlodi <joe.komlodi@xilinx.com>
2
2
3
Signed-off-by: Andrew Jones <drjones@redhat.com>
3
If the CPU is running in default NaN mode (FPCR.DN == 1) and we execute
4
Message-id: 20200120101023.16030-3-drjones@redhat.com
4
FRSQRTE, FRECPE, or FRECPX with a signaling NaN, parts_silence_nan_frac() will
5
assert due to fpst->default_nan_mode being set.
6
7
To avoid this, we check to see what NaN mode we're running in before we call
8
floatxx_silence_nan().
9
10
Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 1624662174-175828-2-git-send-email-joe.komlodi@xilinx.com
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
15
---
8
hw/arm/virt.c | 1 +
16
target/arm/helper-a64.c | 12 +++++++++---
9
1 file changed, 1 insertion(+)
17
target/arm/vfp_helper.c | 24 ++++++++++++++++++------
18
2 files changed, 27 insertions(+), 9 deletions(-)
10
19
11
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
20
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
12
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/virt.c
22
--- a/target/arm/helper-a64.c
14
+++ b/hw/arm/virt.c
23
+++ b/target/arm/helper-a64.c
15
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 0)
24
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp)
16
25
float16 nan = a;
17
static void virt_machine_4_2_options(MachineClass *mc)
26
if (float16_is_signaling_nan(a, fpst)) {
18
{
27
float_raise(float_flag_invalid, fpst);
19
+ virt_machine_5_0_options(mc);
28
- nan = float16_silence_nan(a, fpst);
20
compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
29
+ if (!fpst->default_nan_mode) {
21
}
30
+ nan = float16_silence_nan(a, fpst);
22
DEFINE_VIRT_MACHINE(4, 2)
31
+ }
32
}
33
if (fpst->default_nan_mode) {
34
nan = float16_default_nan(fpst);
35
@@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp)
36
float32 nan = a;
37
if (float32_is_signaling_nan(a, fpst)) {
38
float_raise(float_flag_invalid, fpst);
39
- nan = float32_silence_nan(a, fpst);
40
+ if (!fpst->default_nan_mode) {
41
+ nan = float32_silence_nan(a, fpst);
42
+ }
43
}
44
if (fpst->default_nan_mode) {
45
nan = float32_default_nan(fpst);
46
@@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp)
47
float64 nan = a;
48
if (float64_is_signaling_nan(a, fpst)) {
49
float_raise(float_flag_invalid, fpst);
50
- nan = float64_silence_nan(a, fpst);
51
+ if (!fpst->default_nan_mode) {
52
+ nan = float64_silence_nan(a, fpst);
53
+ }
54
}
55
if (fpst->default_nan_mode) {
56
nan = float64_default_nan(fpst);
57
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
58
index XXXXXXX..XXXXXXX 100644
59
--- a/target/arm/vfp_helper.c
60
+++ b/target/arm/vfp_helper.c
61
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp)
62
float16 nan = f16;
63
if (float16_is_signaling_nan(f16, fpst)) {
64
float_raise(float_flag_invalid, fpst);
65
- nan = float16_silence_nan(f16, fpst);
66
+ if (!fpst->default_nan_mode) {
67
+ nan = float16_silence_nan(f16, fpst);
68
+ }
69
}
70
if (fpst->default_nan_mode) {
71
nan = float16_default_nan(fpst);
72
@@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp)
73
float32 nan = f32;
74
if (float32_is_signaling_nan(f32, fpst)) {
75
float_raise(float_flag_invalid, fpst);
76
- nan = float32_silence_nan(f32, fpst);
77
+ if (!fpst->default_nan_mode) {
78
+ nan = float32_silence_nan(f32, fpst);
79
+ }
80
}
81
if (fpst->default_nan_mode) {
82
nan = float32_default_nan(fpst);
83
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp)
84
float64 nan = f64;
85
if (float64_is_signaling_nan(f64, fpst)) {
86
float_raise(float_flag_invalid, fpst);
87
- nan = float64_silence_nan(f64, fpst);
88
+ if (!fpst->default_nan_mode) {
89
+ nan = float64_silence_nan(f64, fpst);
90
+ }
91
}
92
if (fpst->default_nan_mode) {
93
nan = float64_default_nan(fpst);
94
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp)
95
float16 nan = f16;
96
if (float16_is_signaling_nan(f16, s)) {
97
float_raise(float_flag_invalid, s);
98
- nan = float16_silence_nan(f16, s);
99
+ if (!s->default_nan_mode) {
100
+ nan = float16_silence_nan(f16, fpstp);
101
+ }
102
}
103
if (s->default_nan_mode) {
104
nan = float16_default_nan(s);
105
@@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp)
106
float32 nan = f32;
107
if (float32_is_signaling_nan(f32, s)) {
108
float_raise(float_flag_invalid, s);
109
- nan = float32_silence_nan(f32, s);
110
+ if (!s->default_nan_mode) {
111
+ nan = float32_silence_nan(f32, fpstp);
112
+ }
113
}
114
if (s->default_nan_mode) {
115
nan = float32_default_nan(s);
116
@@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp)
117
float64 nan = f64;
118
if (float64_is_signaling_nan(f64, s)) {
119
float_raise(float_flag_invalid, s);
120
- nan = float64_silence_nan(f64, s);
121
+ if (!s->default_nan_mode) {
122
+ nan = float64_silence_nan(f64, fpstp);
123
+ }
124
}
125
if (s->default_nan_mode) {
126
nan = float64_default_nan(s);
23
--
127
--
24
2.20.1
128
2.20.1
25
129
26
130
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
From: Maxim Uvarov <maxim.uvarov@linaro.org>
2
2
3
Provide a temporary device_legacy_reset function doing what
3
qemu has 2 type of functions: shutdown and reboot. Shutdown
4
device_reset does to prepare for the transition with Resettable
4
function has to be used for machine shutdown. Otherwise we cause
5
API.
5
a reset with a bogus "cause" value, when we intended a shutdown.
6
6
7
All occurrence of device_reset in the code tree are also replaced
7
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
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>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210625111842.3790-3-maxim.uvarov@linaro.org
18
Acked-by: David Gibson <david@gibson.dropbear.id.au>
10
[PMM: tweaked commit message]
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
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
12
---
25
include/hw/qdev-core.h | 4 ++--
13
hw/gpio/gpio_pwr.c | 2 +-
26
hw/audio/intel-hda.c | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
27
hw/core/qdev.c | 6 +++---
28
hw/hyperv/hyperv.c | 2 +-
29
hw/i386/microvm.c | 2 +-
30
hw/i386/pc.c | 2 +-
31
hw/ide/microdrive.c | 8 ++++----
32
hw/intc/spapr_xive.c | 2 +-
33
hw/ppc/pnv_psi.c | 4 ++--
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
15
42
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
16
diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c
43
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
44
--- a/include/hw/qdev-core.h
18
--- a/hw/gpio/gpio_pwr.c
45
+++ b/include/hw/qdev-core.h
19
+++ b/hw/gpio/gpio_pwr.c
46
@@ -XXX,XX +XXX,XX @@ char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev);
20
@@ -XXX,XX +XXX,XX @@ static void gpio_pwr_reset(void *opaque, int n, int level)
47
void qdev_machine_init(void);
21
static void gpio_pwr_shutdown(void *opaque, int n, int level)
48
49
/**
50
- * @device_reset
51
+ * device_legacy_reset:
52
*
53
* Reset a single device (by calling the reset method).
54
*/
55
-void device_reset(DeviceState *dev);
56
+void device_legacy_reset(DeviceState *dev);
57
58
void device_class_set_props(DeviceClass *dc, Property *props);
59
60
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/hw/audio/intel-hda.c
63
+++ b/hw/audio/intel-hda.c
64
@@ -XXX,XX +XXX,XX @@ static void intel_hda_reset(DeviceState *dev)
65
QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) {
66
DeviceState *qdev = kid->child;
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
{
22
{
81
- device_reset(dev);
23
if (level) {
82
+ device_legacy_reset(dev);
24
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
83
25
+ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
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
}
26
}
115
}
27
}
116
28
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)
296
--
29
--
297
2.20.1
30
2.20.1
298
31
299
32
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
In do_ldst(), the calculation of the offset needs to be based on the
2
size of the memory access, not the size of the elements in the
3
vector. This meant we were getting it wrong for the widening and
4
narrowing variants of the various VLDR and VSTR insns.
2
5
3
Initialise another SDHCI model instance for the AST2600's eMMC
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
controller and use the SDHCI's num_slots value introduced previously to
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
determine whether we should create an SD card instance for the new slot.
8
Message-id: 20210628135835.6690-2-peter.maydell@linaro.org
9
---
10
target/arm/translate-mve.c | 17 +++++++++--------
11
1 file changed, 9 insertions(+), 8 deletions(-)
6
12
7
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
13
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
Message-id: 20200114103433.30534-3-clg@kaod.org
12
[ clg : - removed ternary operator from sdhci_attach_drive()
13
- renamed SDHCI objects with a '-controller' prefix ]
14
Signed-off-by: Cédric Le Goater <clg@kaod.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
include/hw/arm/aspeed_soc.h | 2 ++
18
hw/arm/aspeed.c | 26 +++++++++++++++++---------
19
hw/arm/aspeed_ast2600.c | 29 ++++++++++++++++++++++++++---
20
3 files changed, 45 insertions(+), 12 deletions(-)
21
22
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
23
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
24
--- a/include/hw/arm/aspeed_soc.h
15
--- a/target/arm/translate-mve.c
25
+++ b/include/hw/arm/aspeed_soc.h
16
+++ b/target/arm/translate-mve.c
26
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
17
@@ -XXX,XX +XXX,XX @@ static bool mve_skip_first_beat(DisasContext *s)
27
AspeedGPIOState gpio;
28
AspeedGPIOState gpio_1_8v;
29
AspeedSDHCIState sdhci;
30
+ AspeedSDHCIState emmc;
31
} AspeedSoCState;
32
33
#define TYPE_ASPEED_SOC "aspeed-soc"
34
@@ -XXX,XX +XXX,XX @@ enum {
35
ASPEED_MII4,
36
ASPEED_SDRAM,
37
ASPEED_XDMA,
38
+ ASPEED_EMMC,
39
};
40
41
#endif /* ASPEED_SOC_H */
42
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/arm/aspeed.c
45
+++ b/hw/arm/aspeed.c
46
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
47
}
18
}
48
}
19
}
49
20
50
+static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
21
-static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn)
51
+{
22
+static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn,
52
+ DeviceState *card;
23
+ unsigned msize)
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
{
24
{
65
AspeedBoardState *bmc;
25
TCGv_i32 addr;
66
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
26
uint32_t offset;
27
@@ -XXX,XX +XXX,XX @@ static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn)
28
return true;
67
}
29
}
68
30
69
for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
31
- offset = a->imm << a->size;
70
- SDHCIState *sdhci = &bmc->soc.sdhci.slots[i];
32
+ offset = a->imm << msize;
71
- DriveInfo *dinfo = drive_get_next(IF_SD);
33
if (!a->a) {
72
- BlockBackend *blk;
34
offset = -offset;
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
}
35
}
85
36
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a)
86
arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
37
{ gen_helper_mve_vstrw, gen_helper_mve_vldrw },
87
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
38
{ NULL, NULL }
88
index XXXXXXX..XXXXXXX 100644
39
};
89
--- a/hw/arm/aspeed_ast2600.c
40
- return do_ldst(s, a, ldstfns[a->size][a->l]);
90
+++ b/hw/arm/aspeed_ast2600.c
41
+ return do_ldst(s, a, ldstfns[a->size][a->l], a->size);
91
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
42
}
92
[ASPEED_ADC] = 0x1E6E9000,
43
93
[ASPEED_VIDEO] = 0x1E700000,
44
-#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \
94
[ASPEED_SDHCI] = 0x1E740000,
45
+#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST, MSIZE) \
95
+ [ASPEED_EMMC] = 0x1E750000,
46
static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \
96
[ASPEED_GPIO] = 0x1E780000,
47
{ \
97
[ASPEED_GPIO_1_8V] = 0x1E780800,
48
static MVEGenLdStFn * const ldstfns[2][2] = { \
98
[ASPEED_RTC] = 0x1E781000,
49
{ gen_helper_mve_##ST, gen_helper_mve_##SLD }, \
99
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
50
{ NULL, gen_helper_mve_##ULD }, \
100
51
}; \
101
#define ASPEED_SOC_AST2600_MAX_IRQ 128
52
- return do_ldst(s, a, ldstfns[a->u][a->l]); \
102
53
+ return do_ldst(s, a, ldstfns[a->u][a->l], MSIZE); \
103
+/* Shared Peripheral Interrupt values below are offset by -32 from datasheet */
104
static const int aspeed_soc_ast2600_irqmap[] = {
105
[ASPEED_UART1] = 47,
106
[ASPEED_UART2] = 48,
107
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
108
[ASPEED_ADC] = 78,
109
[ASPEED_XDMA] = 6,
110
[ASPEED_SDHCI] = 43,
111
+ [ASPEED_EMMC] = 15,
112
[ASPEED_GPIO] = 40,
113
[ASPEED_GPIO_1_8V] = 11,
114
[ASPEED_RTC] = 13,
115
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
116
sysbus_init_child_obj(obj, "gpio_1_8v", OBJECT(&s->gpio_1_8v),
117
sizeof(s->gpio_1_8v), typename);
118
119
- sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
120
- TYPE_ASPEED_SDHCI);
121
+ sysbus_init_child_obj(obj, "sd-controller", OBJECT(&s->sdhci),
122
+ sizeof(s->sdhci), TYPE_ASPEED_SDHCI);
123
124
object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
125
126
/* Init sd card slot class here so that they're under the correct parent */
127
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
128
- sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
129
+ sysbus_init_child_obj(obj, "sd-controller.sdhci[*]",
130
+ OBJECT(&s->sdhci.slots[i]),
131
sizeof(s->sdhci.slots[i]), TYPE_SYSBUS_SDHCI);
132
}
54
}
133
+
55
134
+ sysbus_init_child_obj(obj, "emmc-controller", OBJECT(&s->emmc),
56
-DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h)
135
+ sizeof(s->emmc), TYPE_ASPEED_SDHCI);
57
-DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w)
136
+
58
-DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w)
137
+ object_property_set_int(OBJECT(&s->emmc), 1, "num-slots", &error_abort);
59
+DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8)
138
+
60
+DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8)
139
+ sysbus_init_child_obj(obj, "emmc-controller.sdhci",
61
+DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16)
140
+ OBJECT(&s->emmc.slots[0]), sizeof(s->emmc.slots[0]),
62
141
+ TYPE_SYSBUS_SDHCI);
63
static bool trans_VDUP(DisasContext *s, arg_VDUP *a)
142
}
64
{
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)
162
--
65
--
163
2.20.1
66
2.20.1
164
67
165
68
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
The initial implementation of the MVE VRMLALDAVH and VRMLSLDAVH
2
insns had some bugs:
3
* the 32x32 multiply of elements was being done as 32x32->32,
4
not 32x32->64
5
* we were incorrectly maintaining the accumulator in its full
6
72-bit form across all 4 beats of the insn; in the pseudocode
7
it is squashed back into the 64 bits of the RdaHi:RdaLo
8
registers after each beat
2
9
3
The AST2600 includes a second cut-down version of the SD/MMC controller
10
In particular, fixing the second of these allows us to recast
4
found in the AST2500, named the eMMC controller. It's cut down in the
11
the implementation to avoid 128-bit arithmetic entirely.
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.
7
12
8
The existing code assumed that the SD controller always provided two
13
Since the element size here is always 4, we can also drop the
9
slots. Rework the SDHCI object to expose the number of slots as a
14
parameterization of ESIZE to make the code a little more readable.
10
property to be set by the SoC configuration.
11
15
12
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
16
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
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()]
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20210628135835.6690-3-peter.maydell@linaro.org
19
---
20
---
20
include/hw/sd/aspeed_sdhci.h | 1 +
21
target/arm/mve_helper.c | 38 +++++++++++++++++++++-----------------
21
hw/arm/aspeed.c | 2 +-
22
1 file changed, 21 insertions(+), 17 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(-)
26
23
27
diff --git a/include/hw/sd/aspeed_sdhci.h b/include/hw/sd/aspeed_sdhci.h
24
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
28
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/sd/aspeed_sdhci.h
26
--- a/target/arm/mve_helper.c
30
+++ b/include/hw/sd/aspeed_sdhci.h
27
+++ b/target/arm/mve_helper.c
31
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSDHCIState {
28
@@ -XXX,XX +XXX,XX @@
32
SysBusDevice parent;
29
*/
33
30
34
SDHCIState slots[ASPEED_SDHCI_NUM_SLOTS];
31
#include "qemu/osdep.h"
35
+ uint8_t num_slots;
32
-#include "qemu/int128.h"
36
33
#include "cpu.h"
37
MemoryRegion iomem;
34
#include "internals.h"
38
qemu_irq irq;
35
#include "vec_internal.h"
39
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
36
@@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=)
40
index XXXXXXX..XXXXXXX 100644
37
DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=)
41
--- a/hw/arm/aspeed.c
38
42
+++ b/hw/arm/aspeed.c
39
/*
43
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
40
- * Rounding multiply add long dual accumulate high: we must keep
44
amc->i2c_init(bmc);
41
- * a 72-bit internal accumulator value and return the top 64 bits.
42
+ * Rounding multiply add long dual accumulate high. In the pseudocode
43
+ * this is implemented with a 72-bit internal accumulator value of which
44
+ * the top 64 bits are returned. We optimize this to avoid having to
45
+ * use 128-bit arithmetic -- we can do this because the 74-bit accumulator
46
+ * is squashed back into 64-bits after each beat.
47
*/
48
-#define DO_LDAVH(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC, TO128) \
49
+#define DO_LDAVH(OP, TYPE, LTYPE, XCHG, SUB) \
50
uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \
51
void *vm, uint64_t a) \
52
{ \
53
uint16_t mask = mve_element_mask(env); \
54
unsigned e; \
55
TYPE *n = vn, *m = vm; \
56
- Int128 acc = int128_lshift(TO128(a), 8); \
57
- for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \
58
+ for (e = 0; e < 16 / 4; e++, mask >>= 4) { \
59
if (mask & 1) { \
60
+ LTYPE mul; \
61
if (e & 1) { \
62
- acc = ODDACC(acc, TO128(n[H##ESIZE(e - 1 * XCHG)] * \
63
- m[H##ESIZE(e)])); \
64
+ mul = (LTYPE)n[H4(e - 1 * XCHG)] * m[H4(e)]; \
65
+ if (SUB) { \
66
+ mul = -mul; \
67
+ } \
68
} else { \
69
- acc = EVENACC(acc, TO128(n[H##ESIZE(e + 1 * XCHG)] * \
70
- m[H##ESIZE(e)])); \
71
+ mul = (LTYPE)n[H4(e + 1 * XCHG)] * m[H4(e)]; \
72
} \
73
- acc = int128_add(acc, int128_make64(1 << 7)); \
74
+ mul = (mul >> 8) + ((mul >> 7) & 1); \
75
+ a += mul; \
76
} \
77
} \
78
mve_advance_vpt(env); \
79
- return int128_getlo(int128_rshift(acc, 8)); \
80
+ return a; \
45
}
81
}
46
82
47
- for (i = 0; i < ARRAY_SIZE(bmc->soc.sdhci.slots); i++) {
83
-DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64)
48
+ for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
84
-DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64)
49
SDHCIState *sdhci = &bmc->soc.sdhci.slots[i];
85
+DO_LDAVH(vrmlaldavhsw, int32_t, int64_t, false, false)
50
DriveInfo *dinfo = drive_get_next(IF_SD);
86
+DO_LDAVH(vrmlaldavhxsw, int32_t, int64_t, true, false)
51
BlockBackend *blk;
87
52
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
88
-DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64)
53
index XXXXXXX..XXXXXXX 100644
89
+DO_LDAVH(vrmlaldavhuw, uint32_t, uint64_t, false, false)
54
--- a/hw/arm/aspeed_ast2600.c
90
55
+++ b/hw/arm/aspeed_ast2600.c
91
-DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64)
56
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
92
-DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64)
57
sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
93
+DO_LDAVH(vrmlsldavhsw, int32_t, int64_t, false, true)
58
TYPE_ASPEED_SDHCI);
94
+DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true)
59
95
60
+ object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
96
/* Vector add across vector */
61
+
97
#define DO_VADDV(OP, ESIZE, TYPE) \
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
},
109
};
110
111
+static Property aspeed_sdhci_properties[] = {
112
+ DEFINE_PROP_UINT8("num-slots", AspeedSDHCIState, num_slots, 0),
113
+ DEFINE_PROP_END_OF_LIST(),
114
+};
115
+
116
static void aspeed_sdhci_class_init(ObjectClass *classp, void *data)
117
{
118
DeviceClass *dc = DEVICE_CLASS(classp);
119
@@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_class_init(ObjectClass *classp, void *data)
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);
124
}
125
126
static TypeInfo aspeed_sdhci_info = {
127
--
98
--
128
2.20.1
99
2.20.1
129
100
130
101
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
The function asimd_imm_const() in translate-neon.c is an
2
implementation of the pseudocode AdvSIMDExpandImm(), which we will
3
also want for MVE. Move the implementation to translate.c, with a
4
prototype in translate.h.
2
5
3
This commit make use of the resettable API to reset the device being
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
hotplugged when it is realized. Also it ensures it is put in a reset
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
state coherent with the parent it is plugged into.
8
Message-id: 20210628135835.6690-4-peter.maydell@linaro.org
9
---
10
target/arm/translate.h | 16 ++++++++++
11
target/arm/translate-neon.c | 63 -------------------------------------
12
target/arm/translate.c | 57 +++++++++++++++++++++++++++++++++
13
3 files changed, 73 insertions(+), 63 deletions(-)
6
14
7
Note that there is a difference in the reset. Instead of resetting
15
diff --git a/target/arm/translate.h b/target/arm/translate.h
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
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
27
include/hw/resettable.h | 11 +++++++++++
28
hw/core/qdev.c | 15 ++++++++++++++-
29
2 files changed, 25 insertions(+), 1 deletion(-)
30
31
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
32
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
33
--- a/include/hw/resettable.h
17
--- a/target/arm/translate.h
34
+++ b/include/hw/resettable.h
18
+++ b/target/arm/translate.h
35
@@ -XXX,XX +XXX,XX @@ struct ResettableState {
19
@@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc)
36
bool exit_phase_in_progress;
20
return opc | s->be_data;
37
};
21
}
38
22
39
+/**
23
+/**
40
+ * resettable_state_clear:
24
+ * asimd_imm_const: Expand an encoded SIMD constant value
41
+ * Clear the state. It puts the state to the initial (zeroed) state required
25
+ *
42
+ * to reuse an object. Typically used in realize step of base classes
26
+ * Expand a SIMD constant value. This is essentially the pseudocode
43
+ * implementing the interface.
27
+ * AdvSIMDExpandImm, except that we also perform the boolean NOT needed for
28
+ * VMVN and VBIC (when cmode < 14 && op == 1).
29
+ *
30
+ * The combination cmode == 15 op == 1 is a reserved encoding for AArch32;
31
+ * callers must catch this.
32
+ *
33
+ * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but
34
+ * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A;
35
+ * we produce an immediate constant value of 0 in these cases.
44
+ */
36
+ */
45
+static inline void resettable_state_clear(ResettableState *state)
37
+uint64_t asimd_imm_const(uint32_t imm, int cmode, int op);
38
+
39
#endif /* TARGET_ARM_TRANSLATE_H */
40
diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/translate-neon.c
43
+++ b/target/arm/translate-neon.c
44
@@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_UH, gen_helper_gvec_vcvt_uh)
45
DO_FP_2SH(VCVT_HS, gen_helper_gvec_vcvt_hs)
46
DO_FP_2SH(VCVT_HU, gen_helper_gvec_vcvt_hu)
47
48
-static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op)
49
-{
50
- /*
51
- * Expand the encoded constant.
52
- * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE.
53
- * We choose to not special-case this and will behave as if a
54
- * valid constant encoding of 0 had been given.
55
- * cmode = 15 op = 1 must UNDEF; we assume decode has handled that.
56
- */
57
- switch (cmode) {
58
- case 0: case 1:
59
- /* no-op */
60
- break;
61
- case 2: case 3:
62
- imm <<= 8;
63
- break;
64
- case 4: case 5:
65
- imm <<= 16;
66
- break;
67
- case 6: case 7:
68
- imm <<= 24;
69
- break;
70
- case 8: case 9:
71
- imm |= imm << 16;
72
- break;
73
- case 10: case 11:
74
- imm = (imm << 8) | (imm << 24);
75
- break;
76
- case 12:
77
- imm = (imm << 8) | 0xff;
78
- break;
79
- case 13:
80
- imm = (imm << 16) | 0xffff;
81
- break;
82
- case 14:
83
- if (op) {
84
- /*
85
- * This is the only case where the top and bottom 32 bits
86
- * of the encoded constant differ.
87
- */
88
- uint64_t imm64 = 0;
89
- int n;
90
-
91
- for (n = 0; n < 8; n++) {
92
- if (imm & (1 << n)) {
93
- imm64 |= (0xffULL << (n * 8));
94
- }
95
- }
96
- return imm64;
97
- }
98
- imm |= (imm << 8) | (imm << 16) | (imm << 24);
99
- break;
100
- case 15:
101
- imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19)
102
- | ((imm & 0x40) ? (0x1f << 25) : (1 << 30));
103
- break;
104
- }
105
- if (op) {
106
- imm = ~imm;
107
- }
108
- return dup_const(MO_32, imm);
109
-}
110
-
111
static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a,
112
GVecGen2iFn *fn)
113
{
114
diff --git a/target/arm/translate.c b/target/arm/translate.c
115
index XXXXXXX..XXXXXXX 100644
116
--- a/target/arm/translate.c
117
+++ b/target/arm/translate.c
118
@@ -XXX,XX +XXX,XX @@ void arm_translate_init(void)
119
a64_translate_init();
120
}
121
122
+uint64_t asimd_imm_const(uint32_t imm, int cmode, int op)
46
+{
123
+{
47
+ memset(state, 0, sizeof(ResettableState));
124
+ /* Expand the encoded constant as per AdvSIMDExpandImm pseudocode */
125
+ switch (cmode) {
126
+ case 0: case 1:
127
+ /* no-op */
128
+ break;
129
+ case 2: case 3:
130
+ imm <<= 8;
131
+ break;
132
+ case 4: case 5:
133
+ imm <<= 16;
134
+ break;
135
+ case 6: case 7:
136
+ imm <<= 24;
137
+ break;
138
+ case 8: case 9:
139
+ imm |= imm << 16;
140
+ break;
141
+ case 10: case 11:
142
+ imm = (imm << 8) | (imm << 24);
143
+ break;
144
+ case 12:
145
+ imm = (imm << 8) | 0xff;
146
+ break;
147
+ case 13:
148
+ imm = (imm << 16) | 0xffff;
149
+ break;
150
+ case 14:
151
+ if (op) {
152
+ /*
153
+ * This is the only case where the top and bottom 32 bits
154
+ * of the encoded constant differ.
155
+ */
156
+ uint64_t imm64 = 0;
157
+ int n;
158
+
159
+ for (n = 0; n < 8; n++) {
160
+ if (imm & (1 << n)) {
161
+ imm64 |= (0xffULL << (n * 8));
162
+ }
163
+ }
164
+ return imm64;
165
+ }
166
+ imm |= (imm << 8) | (imm << 16) | (imm << 24);
167
+ break;
168
+ case 15:
169
+ imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19)
170
+ | ((imm & 0x40) ? (0x1f << 25) : (1 << 30));
171
+ break;
172
+ }
173
+ if (op) {
174
+ imm = ~imm;
175
+ }
176
+ return dup_const(MO_32, imm);
48
+}
177
+}
49
+
178
+
50
/**
179
/* Generate a label used for skipping this instruction */
51
* resettable_reset:
180
void arm_gen_condlabel(DisasContext *s)
52
* Trigger a reset on an object @obj of type @type. @obj must implement
181
{
53
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/hw/core/qdev.c
56
+++ b/hw/core/qdev.c
57
@@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp)
58
}
59
}
60
61
+ /*
62
+ * Clear the reset state, in case the object was previously unrealized
63
+ * with a dirty state.
64
+ */
65
+ resettable_state_clear(&dev->reset);
66
+
67
QLIST_FOREACH(bus, &dev->child_bus, sibling) {
68
object_property_set_bool(OBJECT(bus), true, "realized",
69
&local_err);
70
@@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp)
71
}
72
}
73
if (dev->hotplugged) {
74
- device_legacy_reset(dev);
75
+ /*
76
+ * Reset the device, as well as its subtree which, at this point,
77
+ * should be realized too.
78
+ */
79
+ resettable_assert_reset(OBJECT(dev), RESET_TYPE_COLD);
80
+ resettable_change_parent(OBJECT(dev), OBJECT(dev->parent_bus),
81
+ NULL);
82
+ resettable_release_reset(OBJECT(dev), RESET_TYPE_COLD);
83
}
84
dev->pending_deleted_event = false;
85
86
--
182
--
87
2.20.1
183
2.20.1
88
184
89
185
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
The A64 AdvSIMD modified-immediate grouping uses almost the same
2
constant encoding that A32 Neon does; reuse asimd_imm_const() (to
3
which we add the AArch64-specific case for cmode 15 op 1) instead of
4
reimplementing it all.
2
5
3
kvm-no-adjvtime is a KVM specific CPU property and a first of its
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
kind. To accommodate it we also add kvm_arm_add_vcpu_properties()
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
and a KVM specific CPU properties description to the CPU features
8
Message-id: 20210628135835.6690-5-peter.maydell@linaro.org
6
document.
9
---
10
target/arm/translate.h | 3 +-
11
target/arm/translate-a64.c | 86 ++++----------------------------------
12
target/arm/translate.c | 17 +++++++-
13
3 files changed, 24 insertions(+), 82 deletions(-)
7
14
8
Signed-off-by: Andrew Jones <drjones@redhat.com>
15
diff --git a/target/arm/translate.h b/target/arm/translate.h
9
Message-id: 20200120101023.16030-7-drjones@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
include/hw/arm/virt.h | 1 +
14
target/arm/kvm_arm.h | 11 ++++++++++
15
hw/arm/virt.c | 8 ++++++++
16
target/arm/cpu.c | 2 ++
17
target/arm/cpu64.c | 1 +
18
target/arm/kvm.c | 28 +++++++++++++++++++++++++
19
target/arm/monitor.c | 1 +
20
tests/qtest/arm-cpu-features.c | 4 ++++
21
docs/arm-cpu-features.rst | 37 +++++++++++++++++++++++++++++++++-
22
9 files changed, 92 insertions(+), 1 deletion(-)
23
24
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
25
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/arm/virt.h
17
--- a/target/arm/translate.h
27
+++ b/include/hw/arm/virt.h
18
+++ b/target/arm/translate.h
28
@@ -XXX,XX +XXX,XX @@ typedef struct {
19
@@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc)
29
bool smbios_old_sys_ver;
20
* VMVN and VBIC (when cmode < 14 && op == 1).
30
bool no_highmem_ecam;
21
*
31
bool no_ged; /* Machines < 4.2 has no support for ACPI GED device */
22
* The combination cmode == 15 op == 1 is a reserved encoding for AArch32;
32
+ bool kvm_no_adjvtime;
23
- * callers must catch this.
33
} VirtMachineClass;
24
+ * callers must catch this; we return the 64-bit constant value defined
34
25
+ * for AArch64.
35
typedef struct {
26
*
36
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
27
* cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but
28
* is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A;
29
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
37
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/kvm_arm.h
31
--- a/target/arm/translate-a64.c
39
+++ b/target/arm/kvm_arm.h
32
+++ b/target/arm/translate-a64.c
40
@@ -XXX,XX +XXX,XX @@ void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map);
33
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
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.
50
+ */
51
+void kvm_arm_add_vcpu_properties(Object *obj);
52
+
53
/**
54
* kvm_arm_aarch32_supported:
55
* @cs: CPUState
56
@@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
57
cpu->host_cpu_probe_failed = true;
58
}
59
60
+static inline void kvm_arm_add_vcpu_properties(Object *obj) {}
61
+
62
static inline bool kvm_arm_aarch32_supported(CPUState *cs)
63
{
34
{
64
return false;
35
int rd = extract32(insn, 0, 5);
65
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
36
int cmode = extract32(insn, 12, 4);
66
index XXXXXXX..XXXXXXX 100644
37
- int cmode_3_1 = extract32(cmode, 1, 3);
67
--- a/hw/arm/virt.c
38
- int cmode_0 = extract32(cmode, 0, 1);
68
+++ b/hw/arm/virt.c
39
int o2 = extract32(insn, 11, 1);
69
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
40
uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5);
70
}
41
bool is_neg = extract32(insn, 29, 1);
71
}
42
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
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
93
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/target/arm/cpu.c
96
+++ b/target/arm/cpu.c
97
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
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);
108
}
109
+ kvm_arm_add_vcpu_properties(obj);
110
arm_cpu_post_init(obj);
111
}
112
113
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
114
index XXXXXXX..XXXXXXX 100644
115
--- a/target/arm/cpu64.c
116
+++ b/target/arm/cpu64.c
117
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
118
119
if (kvm_enabled()) {
120
kvm_arm_set_cpu_features_from_host(cpu);
121
+ kvm_arm_add_vcpu_properties(obj);
122
} else {
123
uint64_t t;
124
uint32_t u;
125
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
126
index XXXXXXX..XXXXXXX 100644
127
--- a/target/arm/kvm.c
128
+++ b/target/arm/kvm.c
129
@@ -XXX,XX +XXX,XX @@
130
#include "qemu/timer.h"
131
#include "qemu/error-report.h"
132
#include "qemu/main-loop.h"
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;
43
return;
198
}
44
}
199
45
200
+ assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");
46
- /* See AdvSIMDExpandImm() in ARM ARM */
201
+
47
- switch (cmode_3_1) {
202
if (g_str_equal(qtest_get_arch(), "aarch64")) {
48
- case 0: /* Replicate(Zeros(24):imm8, 2) */
203
bool kvm_supports_sve;
49
- case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */
204
char max_name[8], name[8];
50
- case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */
205
diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst
51
- case 3: /* Replicate(imm8:Zeros(24), 2) */
52
- {
53
- int shift = cmode_3_1 * 8;
54
- imm = bitfield_replicate(abcdefgh << shift, 32);
55
- break;
56
- }
57
- case 4: /* Replicate(Zeros(8):imm8, 4) */
58
- case 5: /* Replicate(imm8:Zeros(8), 4) */
59
- {
60
- int shift = (cmode_3_1 & 0x1) * 8;
61
- imm = bitfield_replicate(abcdefgh << shift, 16);
62
- break;
63
- }
64
- case 6:
65
- if (cmode_0) {
66
- /* Replicate(Zeros(8):imm8:Ones(16), 2) */
67
- imm = (abcdefgh << 16) | 0xffff;
68
- } else {
69
- /* Replicate(Zeros(16):imm8:Ones(8), 2) */
70
- imm = (abcdefgh << 8) | 0xff;
71
- }
72
- imm = bitfield_replicate(imm, 32);
73
- break;
74
- case 7:
75
- if (!cmode_0 && !is_neg) {
76
- imm = bitfield_replicate(abcdefgh, 8);
77
- } else if (!cmode_0 && is_neg) {
78
- int i;
79
- imm = 0;
80
- for (i = 0; i < 8; i++) {
81
- if ((abcdefgh) & (1 << i)) {
82
- imm |= 0xffULL << (i * 8);
83
- }
84
- }
85
- } else if (cmode_0) {
86
- if (is_neg) {
87
- imm = (abcdefgh & 0x3f) << 48;
88
- if (abcdefgh & 0x80) {
89
- imm |= 0x8000000000000000ULL;
90
- }
91
- if (abcdefgh & 0x40) {
92
- imm |= 0x3fc0000000000000ULL;
93
- } else {
94
- imm |= 0x4000000000000000ULL;
95
- }
96
- } else {
97
- if (o2) {
98
- /* FMOV (vector, immediate) - half-precision */
99
- imm = vfp_expand_imm(MO_16, abcdefgh);
100
- /* now duplicate across the lanes */
101
- imm = bitfield_replicate(imm, 16);
102
- } else {
103
- imm = (abcdefgh & 0x3f) << 19;
104
- if (abcdefgh & 0x80) {
105
- imm |= 0x80000000;
106
- }
107
- if (abcdefgh & 0x40) {
108
- imm |= 0x3e000000;
109
- } else {
110
- imm |= 0x40000000;
111
- }
112
- imm |= (imm << 32);
113
- }
114
- }
115
- }
116
- break;
117
- default:
118
- g_assert_not_reached();
119
- }
120
-
121
- if (cmode_3_1 != 7 && is_neg) {
122
- imm = ~imm;
123
+ if (cmode == 15 && o2 && !is_neg) {
124
+ /* FMOV (vector, immediate) - half-precision */
125
+ imm = vfp_expand_imm(MO_16, abcdefgh);
126
+ /* now duplicate across the lanes */
127
+ imm = bitfield_replicate(imm, 16);
128
+ } else {
129
+ imm = asimd_imm_const(abcdefgh, cmode, is_neg);
130
}
131
132
if (!((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9)) {
133
diff --git a/target/arm/translate.c b/target/arm/translate.c
206
index XXXXXXX..XXXXXXX 100644
134
index XXXXXXX..XXXXXXX 100644
207
--- a/docs/arm-cpu-features.rst
135
--- a/target/arm/translate.c
208
+++ b/docs/arm-cpu-features.rst
136
+++ b/target/arm/translate.c
209
@@ -XXX,XX +XXX,XX @@ supporting the feature or only supporting the feature under certain
137
@@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op)
210
configurations. For example, the `aarch64` CPU feature, which, when
138
case 14:
211
disabled, enables the optional AArch32 CPU feature, is only supported
139
if (op) {
212
when using the KVM accelerator and when running on a host CPU type that
140
/*
213
-supports the feature.
141
- * This is the only case where the top and bottom 32 bits
214
+supports the feature. While `aarch64` currently only works with KVM,
142
- * of the encoded constant differ.
215
+it could work with TCG. CPU features that are specific to KVM are
143
+ * This and cmode == 15 op == 1 are the only cases where
216
+prefixed with "kvm-" and are described in "KVM VCPU Features".
144
+ * the top and bottom 32 bits of the encoded constant differ.
217
145
*/
218
CPU Feature Probing
146
uint64_t imm64 = 0;
219
===================
147
int n;
220
@@ -XXX,XX +XXX,XX @@ disabling many SVE vector lengths would be quite verbose, the `sve<N>` CPU
148
@@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op)
221
properties have special semantics (see "SVE CPU Property Parsing
149
imm |= (imm << 8) | (imm << 16) | (imm << 24);
222
Semantics").
150
break;
223
151
case 15:
224
+KVM VCPU Features
152
+ if (op) {
225
+=================
153
+ /* Reserved encoding for AArch32; valid for AArch64 */
226
+
154
+ uint64_t imm64 = (uint64_t)(imm & 0x3f) << 48;
227
+KVM VCPU features are CPU features that are specific to KVM, such as
155
+ if (imm & 0x80) {
228
+paravirt features or features that enable CPU virtualization extensions.
156
+ imm64 |= 0x8000000000000000ULL;
229
+The features' CPU properties are only available when KVM is enabled and
157
+ }
230
+are named with the prefix "kvm-". KVM VCPU features may be probed,
158
+ if (imm & 0x40) {
231
+enabled, and disabled in the same way as other CPU features. Below is
159
+ imm64 |= 0x3fc0000000000000ULL;
232
+the list of KVM VCPU features and their descriptions.
160
+ } else {
233
+
161
+ imm64 |= 0x4000000000000000ULL;
234
+ kvm-no-adjvtime By default kvm-no-adjvtime is disabled. This
162
+ }
235
+ means that by default the virtual time
163
+ return imm64;
236
+ adjustment is enabled (vtime is *not not*
164
+ }
237
+ adjusted).
165
imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19)
238
+
166
| ((imm & 0x40) ? (0x1f << 25) : (1 << 30));
239
+ When virtual time adjustment is enabled each
167
break;
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
260
--
168
--
261
2.20.1
169
2.20.1
262
170
263
171
diff view generated by jsdifflib
1
The num-lines property of the TYPE_OR_GATE device sets the number
1
Use dup_const() instead of bitfield_replicate() in
2
of input lines it has. An assert() in or_irq_realize() restricts
2
disas_simd_mod_imm().
3
this to the maximum supported by the implementation. However we
4
got the condition in the assert wrong: it should be using <=,
5
because num-lines == MAX_OR_LINES is permitted, and means that
6
all entries from 0 to MAX_OR_LINES-1 in the s->levels[] array
7
are used.
8
3
9
We didn't notice this previously because no user has so far
4
(We can't replace the other use of bitfield_replicate() in this file,
10
needed that many input lines.
5
in logic_imm_decode_wmask(), because that location needs to handle 2
6
and 4 bit elements, which dup_const() cannot.)
11
7
12
Reported-by: Guenter Roeck <linux@roeck-us.net>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
10
Message-id: 20210628135835.6690-6-peter.maydell@linaro.org
16
Message-id: 20200120142235.10432-1-peter.maydell@linaro.org
17
---
11
---
18
hw/core/or-irq.c | 2 +-
12
target/arm/translate-a64.c | 2 +-
19
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
20
14
21
diff --git a/hw/core/or-irq.c b/hw/core/or-irq.c
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
22
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/core/or-irq.c
17
--- a/target/arm/translate-a64.c
24
+++ b/hw/core/or-irq.c
18
+++ b/target/arm/translate-a64.c
25
@@ -XXX,XX +XXX,XX @@ static void or_irq_realize(DeviceState *dev, Error **errp)
19
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
26
{
20
/* FMOV (vector, immediate) - half-precision */
27
qemu_or_irq *s = OR_IRQ(dev);
21
imm = vfp_expand_imm(MO_16, abcdefgh);
28
22
/* now duplicate across the lanes */
29
- assert(s->num_lines < MAX_OR_LINES);
23
- imm = bitfield_replicate(imm, 16);
30
+ assert(s->num_lines <= MAX_OR_LINES);
24
+ imm = dup_const(MO_16, imm);
31
25
} else {
32
qdev_init_gpio_in(dev, or_irq_handler, s->num_lines);
26
imm = asimd_imm_const(abcdefgh, cmode, is_neg);
33
}
27
}
34
--
28
--
35
2.20.1
29
2.20.1
36
30
37
31
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Implement the MVE logical-immediate insns (VMOV, VMVN,
2
VORR and VBIC). These have essentially the same encoding
3
as their Neon equivalents, and we implement the decode
4
in the same way.
2
5
3
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200123132823.1117486-10-damien.hedde@greensocs.com
8
Message-id: 20210628135835.6690-7-peter.maydell@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
---
9
docs/devel/index.rst | 1 +
10
target/arm/helper-mve.h | 4 +++
10
docs/devel/reset.rst | 289 +++++++++++++++++++++++++++++++++++++++++++
11
target/arm/mve.decode | 17 +++++++++++++
11
2 files changed, 290 insertions(+)
12
target/arm/mve_helper.c | 24 ++++++++++++++++++
12
create mode 100644 docs/devel/reset.rst
13
target/arm/translate-mve.c | 50 ++++++++++++++++++++++++++++++++++++++
14
4 files changed, 95 insertions(+)
13
15
14
diff --git a/docs/devel/index.rst b/docs/devel/index.rst
16
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/devel/index.rst
18
--- a/target/arm/helper-mve.h
17
+++ b/docs/devel/index.rst
19
+++ b/target/arm/helper-mve.h
18
@@ -XXX,XX +XXX,XX @@ Contents:
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32)
19
tcg
21
DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32)
20
tcg-plugins
22
DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32)
21
bitops
23
DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32)
22
+ reset
24
+
23
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
25
+DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64)
24
new file mode 100644
26
+DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64)
25
index XXXXXXX..XXXXXXX
27
+DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64)
26
--- /dev/null
28
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
27
+++ b/docs/devel/reset.rst
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/mve.decode
31
+++ b/target/arm/mve.decode
28
@@ -XXX,XX +XXX,XX @@
32
@@ -XXX,XX +XXX,XX @@
33
# VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit
34
%size_28 28:1 !function=plus_1
35
36
+# 1imm format immediate
37
+%imm_28_16_0 28:1 16:3 0:4
29
+
38
+
30
+=======================================
39
&vldr_vstr rn qd imm p a w size l u
31
+Reset in QEMU: the Resettable interface
40
&1op qd qm size
32
+=======================================
41
&2op qd qm qn size
42
&2scalar qd qn rm size
43
+&1imm qd imm cmode op
44
45
@vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0
46
# Note that both Rn and Qd are 3 bits only (no D bit)
47
@@ -XXX,XX +XXX,XX @@
48
@2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0
49
@2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \
50
size=%size_28
51
+@1imm .... .... .... .... .... cmode:4 .. op:1 . .... &1imm qd=%qd imm=%imm_28_16_0
52
53
# The _rev suffix indicates that Vn and Vm are reversed. This is
54
# the case for shifts. In the Arm ARM these insns are documented
55
@@ -XXX,XX +XXX,XX @@ VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rd
56
# Predicate operations
57
%mask_22_13 22:1 13:3
58
VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13
33
+
59
+
34
+The reset of qemu objects is handled using the resettable interface declared
60
+# Logical immediate operations (1 reg and modified-immediate)
35
+in ``include/hw/resettable.h``.
36
+
61
+
37
+This interface allows objects to be grouped (on a tree basis); so that the
62
+# The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but
38
+whole group can be reset consistently. Each individual member object does not
63
+# not in a way we can conveniently represent in decodetree without
39
+have to care about others; in particular, problems of order (which object is
64
+# a lot of repetition:
40
+reset first) are addressed.
65
+# VORR: op=0, (cmode & 1) && cmode < 12
41
+
66
+# VBIC: op=1, (cmode & 1) && cmode < 12
42
+As of now DeviceClass and BusClass implement this interface.
67
+# VMOV: everything else
43
+
68
+# So we have a single decode line and check the cmode/op in the
44
+
69
+# trans function.
45
+Triggering reset
70
+Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm
46
+----------------
71
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
47
+
72
index XXXXXXX..XXXXXXX 100644
48
+This section documents the APIs which "users" of a resettable object should use
73
--- a/target/arm/mve_helper.c
49
+to control it. All resettable control functions must be called while holding
74
+++ b/target/arm/mve_helper.c
50
+the iothread lock.
75
@@ -XXX,XX +XXX,XX @@ DO_1OP(vnegw, 4, int32_t, DO_NEG)
51
+
76
DO_1OP(vfnegh, 8, uint64_t, DO_FNEGH)
52
+You can apply a reset to an object using ``resettable_assert_reset()``. You need
77
DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS)
53
+to call ``resettable_release_reset()`` to release the object from reset. To
78
54
+instantly reset an object, without keeping it in reset state, just call
79
+/*
55
+``resettable_reset()``. These functions take two parameters: a pointer to the
80
+ * 1 operand immediates: Vda is destination and possibly also one source.
56
+object to reset and a reset type.
81
+ * All these insns work at 64-bit widths.
57
+
82
+ */
58
+Several types of reset will be supported. For now only cold reset is defined;
83
+#define DO_1OP_IMM(OP, FN) \
59
+others may be added later. The Resettable interface handles reset types with an
84
+ void HELPER(mve_##OP)(CPUARMState *env, void *vda, uint64_t imm) \
60
+enum:
85
+ { \
61
+
86
+ uint64_t *da = vda; \
62
+``RESET_TYPE_COLD``
87
+ uint16_t mask = mve_element_mask(env); \
63
+ Cold reset is supported by every resettable object. In QEMU, it means we reset
88
+ unsigned e; \
64
+ to the initial state corresponding to the start of QEMU; this might differ
89
+ for (e = 0; e < 16 / 8; e++, mask >>= 8) { \
65
+ from what is a real hardware cold reset. It differs from other resets (like
90
+ mergemask(&da[H8(e)], FN(da[H8(e)], imm), mask); \
66
+ warm or bus resets) which may keep certain parts untouched.
91
+ } \
67
+
92
+ mve_advance_vpt(env); \
68
+Calling ``resettable_reset()`` is equivalent to calling
69
+``resettable_assert_reset()`` then ``resettable_release_reset()``. It is
70
+possible to interleave multiple calls to these three functions. There may
71
+be several reset sources/controllers of a given object. The interface handles
72
+everything and the different reset controllers do not need to know anything
73
+about each others. The object will leave reset state only when each other
74
+controllers end their reset operation. This point is handled internally by
75
+maintaining a count of in-progress resets; it is crucial to call
76
+``resettable_release_reset()`` one time and only one time per
77
+``resettable_assert_reset()`` call.
78
+
79
+For now migration of a device or bus in reset is not supported. Care must be
80
+taken not to delay ``resettable_release_reset()`` after its
81
+``resettable_assert_reset()`` counterpart.
82
+
83
+Note that, since resettable is an interface, the API takes a simple Object as
84
+parameter. Still, it is a programming error to call a resettable function on a
85
+non-resettable object and it will trigger a run time assert error. Since most
86
+calls to resettable interface are done through base class functions, such an
87
+error is not likely to happen.
88
+
89
+For Devices and Buses, the following helper functions exist:
90
+
91
+- ``device_cold_reset()``
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
+ }
93
+ }
180
+
94
+
181
+ static void mydev_reset_hold(Object *obj)
95
+#define DO_MOVI(N, I) (I)
182
+ {
96
+#define DO_ANDI(N, I) ((N) & (I))
183
+ MyDevClass *myclass = MYDEV_GET_CLASS(obj);
97
+#define DO_ORRI(N, I) ((N) | (I))
184
+ MyDevState *mydev = MYDEV(obj);
98
+
185
+ /* call parent class hold phase */
99
+DO_1OP_IMM(vmovi, DO_MOVI)
186
+ if (myclass->parent_phases.hold) {
100
+DO_1OP_IMM(vandi, DO_ANDI)
187
+ myclass->parent_phases.hold(obj);
101
+DO_1OP_IMM(vorri, DO_ORRI)
188
+ }
102
+
189
+ /* set an IO */
103
#define DO_2OP(OP, ESIZE, TYPE, FN) \
190
+ qemu_set_irq(mydev->irq, 1);
104
void HELPER(glue(mve_, OP))(CPUARMState *env, \
105
void *vd, void *vn, void *vm) \
106
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/target/arm/translate-mve.c
109
+++ b/target/arm/translate-mve.c
110
@@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr);
111
typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32);
112
typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64);
113
typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32);
114
+typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64);
115
116
/* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */
117
static inline long mve_qreg_offset(unsigned reg)
118
@@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a)
119
mve_update_eci(s);
120
return true;
121
}
122
+
123
+static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn)
124
+{
125
+ TCGv_ptr qd;
126
+ uint64_t imm;
127
+
128
+ if (!dc_isar_feature(aa32_mve, s) ||
129
+ !mve_check_qreg_bank(s, a->qd) ||
130
+ !fn) {
131
+ return false;
132
+ }
133
+ if (!mve_eci_check(s) || !vfp_access_check(s)) {
134
+ return true;
191
+ }
135
+ }
192
+
136
+
193
+ static void mydev_reset_exit(Object *obj)
137
+ imm = asimd_imm_const(a->imm, a->cmode, a->op);
194
+ {
138
+
195
+ MyDevClass *myclass = MYDEV_GET_CLASS(obj);
139
+ qd = mve_qreg_ptr(a->qd);
196
+ MyDevState *mydev = MYDEV(obj);
140
+ fn(cpu_env, qd, tcg_constant_i64(imm));
197
+ /* call parent class exit phase */
141
+ tcg_temp_free_ptr(qd);
198
+ if (myclass->parent_phases.exit) {
142
+ mve_update_eci(s);
199
+ myclass->parent_phases.exit(obj);
143
+ return true;
144
+}
145
+
146
+static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a)
147
+{
148
+ /* Handle decode of cmode/op here between VORR/VBIC/VMOV */
149
+ MVEGenOneOpImmFn *fn;
150
+
151
+ if ((a->cmode & 1) && a->cmode < 12) {
152
+ if (a->op) {
153
+ /*
154
+ * For op=1, the immediate will be inverted by asimd_imm_const(),
155
+ * so the VBIC becomes a logical AND operation.
156
+ */
157
+ fn = gen_helper_mve_vandi;
158
+ } else {
159
+ fn = gen_helper_mve_vorri;
200
+ }
160
+ }
201
+ /* clear an IO */
161
+ } else {
202
+ qemu_set_irq(mydev->irq, 0);
162
+ /* There is one unallocated cmode/op combination in this space */
163
+ if (a->cmode == 15 && a->op == 1) {
164
+ return false;
165
+ }
166
+ /* asimd_imm_const() sorts out VMVNI vs VMOVI for us */
167
+ fn = gen_helper_mve_vmovi;
203
+ }
168
+ }
204
+
169
+ return do_1imm(s, a, fn);
205
+ typedef struct MyDevClass {
170
+}
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.
318
--
171
--
319
2.20.1
172
2.20.1
320
173
321
174
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
Implement the MVE shift-vector-left-by-immediate insns VSHL, VQSHL
2
2
and VQSHLU.
3
Signed-off-by: Andrew Jones <drjones@redhat.com>
3
4
Message-id: 20200120101023.16030-2-drjones@redhat.com
4
The size-and-immediate encoding here is the same as Neon, and we
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
handle it the same way neon-dp.decode does.
6
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210628135835.6690-8-peter.maydell@linaro.org
7
---
10
---
8
target/arm/kvm_arm.h | 46 ++++++++++++++++++++++++++------------------
11
target/arm/helper-mve.h | 16 +++++++++++
9
1 file changed, 27 insertions(+), 19 deletions(-)
12
target/arm/mve.decode | 23 +++++++++++++++
10
13
target/arm/mve_helper.c | 57 ++++++++++++++++++++++++++++++++++++++
11
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
14
target/arm/translate-mve.c | 51 ++++++++++++++++++++++++++++++++++
12
index XXXXXXX..XXXXXXX 100644
15
4 files changed, 147 insertions(+)
13
--- a/target/arm/kvm_arm.h
16
14
+++ b/target/arm/kvm_arm.h
17
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper-mve.h
20
+++ b/target/arm/helper-mve.h
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32)
22
DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64)
23
DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64)
24
DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64)
25
+
26
+DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
27
+DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
28
+DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
29
+
30
+DEF_HELPER_FLAGS_4(mve_vqshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
31
+DEF_HELPER_FLAGS_4(mve_vqshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
32
+DEF_HELPER_FLAGS_4(mve_vqshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
33
+
34
+DEF_HELPER_FLAGS_4(mve_vqshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
35
+DEF_HELPER_FLAGS_4(mve_vqshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
+DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
37
+
38
+DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
39
+DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
40
+DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
41
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
42
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/mve.decode
44
+++ b/target/arm/mve.decode
15
@@ -XXX,XX +XXX,XX @@
45
@@ -XXX,XX +XXX,XX @@
16
int kvm_arm_vcpu_init(CPUState *cs);
46
&2op qd qm qn size
17
47
&2scalar qd qn rm size
18
/**
48
&1imm qd imm cmode op
19
- * kvm_arm_vcpu_finalize
49
+&2shift qd qm shift size
20
+ * kvm_arm_vcpu_finalize:
50
21
* @cs: CPUState
51
@vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0
22
- * @feature: int
52
# Note that both Rn and Qd are 3 bits only (no D bit)
23
+ * @feature: feature to finalize
53
@@ -XXX,XX +XXX,XX @@
24
*
54
@2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn
25
* Finalizes the configuration of the specified VCPU feature by
55
@2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn
26
* invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring
56
27
@@ -XXX,XX +XXX,XX @@ void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
57
+@2_shl_b .... .... .. 001 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0
28
int kvm_arm_init_cpreg_list(ARMCPU *cpu);
58
+@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1
29
59
+@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2
30
/**
60
+
31
- * kvm_arm_reg_syncs_via_cpreg_list
61
# Vector loads and stores
32
- * regidx: KVM register index
62
33
+ * kvm_arm_reg_syncs_via_cpreg_list:
63
# Widening loads and narrowing stores:
34
+ * @regidx: KVM register index
64
@@ -XXX,XX +XXX,XX @@ VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13
35
*
65
# So we have a single decode line and check the cmode/op in the
36
* Return true if this KVM register should be synchronized via the
66
# trans function.
37
* cpreg list of arbitrary system registers, false if it is synchronized
67
Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm
38
@@ -XXX,XX +XXX,XX @@ int kvm_arm_init_cpreg_list(ARMCPU *cpu);
68
+
39
bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx);
69
+# Shifts by immediate
40
70
+
41
/**
71
+VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b
42
- * kvm_arm_cpreg_level
72
+VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h
43
- * regidx: KVM register index
73
+VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w
44
+ * kvm_arm_cpreg_level:
74
+
45
+ * @regidx: KVM register index
75
+VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b
46
*
76
+VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h
47
* Return the level of this coprocessor/system register. Return value is
77
+VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w
48
* either KVM_PUT_RUNTIME_STATE, KVM_PUT_RESET_STATE, or KVM_PUT_FULL_STATE.
78
+
49
@@ -XXX,XX +XXX,XX @@ void kvm_arm_init_serror_injection(CPUState *cs);
79
+VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b
50
* @cpu: ARMCPU
80
+VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h
51
*
81
+VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w
52
* Get VCPU related state from kvm.
82
+
53
+ *
83
+VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b
54
+ * Returns: 0 if success else < 0 error code
84
+VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h
55
*/
85
+VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w
56
int kvm_get_vcpu_events(ARMCPU *cpu);
86
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
57
87
index XXXXXXX..XXXXXXX 100644
58
@@ -XXX,XX +XXX,XX @@ int kvm_get_vcpu_events(ARMCPU *cpu);
88
--- a/target/arm/mve_helper.c
59
* @cpu: ARMCPU
89
+++ b/target/arm/mve_helper.c
60
*
90
@@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W)
61
* Put VCPU related state to kvm.
91
WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp)
62
+ *
92
#define DO_UQRSHL_OP(N, M, satp) \
63
+ * Returns: 0 if success else < 0 error code
93
WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, true, satp)
64
*/
94
+#define DO_SUQSHL_OP(N, M, satp) \
65
int kvm_put_vcpu_events(ARMCPU *cpu);
95
+ WRAP_QRSHL_HELPER(do_suqrshl_bhs, N, M, false, satp)
66
96
67
@@ -XXX,XX +XXX,XX @@ typedef struct ARMHostCPUFeatures {
97
DO_2OP_SAT_S(vqshls, DO_SQSHL_OP)
68
98
DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP)
69
/**
99
@@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvsw, 4, uint32_t)
70
* kvm_arm_get_host_cpu_features:
100
DO_VADDV(vaddvub, 1, uint8_t)
71
- * @ahcc: ARMHostCPUClass to fill in
101
DO_VADDV(vaddvuh, 2, uint16_t)
72
+ * @ahcf: ARMHostCPUClass to fill in
102
DO_VADDV(vaddvuw, 4, uint32_t)
73
*
103
+
74
* Probe the capabilities of the host kernel's preferred CPU and fill
104
+/* Shifts by immediate */
75
* in the ARMHostCPUClass struct accordingly.
105
+#define DO_2SHIFT(OP, ESIZE, TYPE, FN) \
76
+ *
106
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
77
+ * Returns true on success and false otherwise.
107
+ void *vm, uint32_t shift) \
78
*/
108
+ { \
79
bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf);
109
+ TYPE *d = vd, *m = vm; \
80
110
+ uint16_t mask = mve_element_mask(env); \
81
@@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);
111
+ unsigned e; \
82
bool kvm_arm_aarch32_supported(CPUState *cs);
112
+ for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \
83
113
+ mergemask(&d[H##ESIZE(e)], \
84
/**
114
+ FN(m[H##ESIZE(e)], shift), mask); \
85
- * bool kvm_arm_pmu_supported:
115
+ } \
86
+ * kvm_arm_pmu_supported:
116
+ mve_advance_vpt(env); \
87
* @cs: CPUState
117
+ }
88
*
118
+
89
* Returns: true if the KVM VCPU can enable its PMU
119
+#define DO_2SHIFT_SAT(OP, ESIZE, TYPE, FN) \
90
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_aarch32_supported(CPUState *cs);
120
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
91
bool kvm_arm_pmu_supported(CPUState *cs);
121
+ void *vm, uint32_t shift) \
92
122
+ { \
93
/**
123
+ TYPE *d = vd, *m = vm; \
94
- * bool kvm_arm_sve_supported:
124
+ uint16_t mask = mve_element_mask(env); \
95
+ * kvm_arm_sve_supported:
125
+ unsigned e; \
96
* @cs: CPUState
126
+ bool qc = false; \
97
*
127
+ for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \
98
* Returns true if the KVM VCPU can enable SVE and false otherwise.
128
+ bool sat = false; \
99
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_pmu_supported(CPUState *cs);
129
+ mergemask(&d[H##ESIZE(e)], \
100
bool kvm_arm_sve_supported(CPUState *cs);
130
+ FN(m[H##ESIZE(e)], shift, &sat), mask); \
101
131
+ qc |= sat & mask & 1; \
102
/**
132
+ } \
103
- * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the
133
+ if (qc) { \
104
- * IPA address space supported by KVM
134
+ env->vfp.qc[0] = qc; \
105
- *
135
+ } \
106
+ * kvm_arm_get_max_vm_ipa_size:
136
+ mve_advance_vpt(env); \
107
* @ms: Machine state handle
137
+ }
108
+ *
138
+
109
+ * Returns the number of bits in the IPA address space supported by KVM
139
+/* provide unsigned 2-op shift helpers for all sizes */
110
*/
140
+#define DO_2SHIFT_U(OP, FN) \
111
int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
141
+ DO_2SHIFT(OP##b, 1, uint8_t, FN) \
112
142
+ DO_2SHIFT(OP##h, 2, uint16_t, FN) \
113
/**
143
+ DO_2SHIFT(OP##w, 4, uint32_t, FN)
114
- * kvm_arm_sync_mpstate_to_kvm
144
+
115
+ * kvm_arm_sync_mpstate_to_kvm:
145
+#define DO_2SHIFT_SAT_U(OP, FN) \
116
* @cpu: ARMCPU
146
+ DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \
117
*
147
+ DO_2SHIFT_SAT(OP##h, 2, uint16_t, FN) \
118
* If supported set the KVM MP_STATE based on QEMU's model.
148
+ DO_2SHIFT_SAT(OP##w, 4, uint32_t, FN)
119
+ *
149
+#define DO_2SHIFT_SAT_S(OP, FN) \
120
+ * Returns 0 on success and -1 on failure.
150
+ DO_2SHIFT_SAT(OP##b, 1, int8_t, FN) \
121
*/
151
+ DO_2SHIFT_SAT(OP##h, 2, int16_t, FN) \
122
int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu);
152
+ DO_2SHIFT_SAT(OP##w, 4, int32_t, FN)
123
153
+
124
/**
154
+DO_2SHIFT_U(vshli_u, DO_VSHLU)
125
- * kvm_arm_sync_mpstate_to_qemu
155
+DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP)
126
+ * kvm_arm_sync_mpstate_to_qemu:
156
+DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP)
127
* @cpu: ARMCPU
157
+DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP)
128
*
158
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
129
* If supported get the MP_STATE from KVM and store in QEMU's model.
159
index XXXXXXX..XXXXXXX 100644
130
+ *
160
--- a/target/arm/translate-mve.c
131
+ * Returns 0 on success and aborts on failure.
161
+++ b/target/arm/translate-mve.c
132
*/
162
@@ -XXX,XX +XXX,XX @@ typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
133
int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu);
163
typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
134
164
typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr);
135
@@ -XXX,XX +XXX,XX @@ int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
165
typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32);
136
166
+typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32);
137
static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
167
typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64);
138
{
168
typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32);
139
- /* This should never actually be called in the "not KVM" case,
169
typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64);
170
@@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a)
171
}
172
return do_1imm(s, a, fn);
173
}
174
+
175
+static bool do_2shift(DisasContext *s, arg_2shift *a, MVEGenTwoOpShiftFn fn,
176
+ bool negateshift)
177
+{
178
+ TCGv_ptr qd, qm;
179
+ int shift = a->shift;
180
+
181
+ if (!dc_isar_feature(aa32_mve, s) ||
182
+ !mve_check_qreg_bank(s, a->qd | a->qm) ||
183
+ !fn) {
184
+ return false;
185
+ }
186
+ if (!mve_eci_check(s) || !vfp_access_check(s)) {
187
+ return true;
188
+ }
189
+
140
+ /*
190
+ /*
141
+ * This should never actually be called in the "not KVM" case,
191
+ * When we handle a right shift insn using a left-shift helper
142
* but set up the fields to indicate an error anyway.
192
+ * which permits a negative shift count to indicate a right-shift,
143
*/
193
+ * we must negate the shift count.
144
cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
194
+ */
145
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit);
195
+ if (negateshift) {
146
*
196
+ shift = -shift;
147
* Return: TRUE if any hardware breakpoints in use.
197
+ }
148
*/
198
+
149
-
199
+ qd = mve_qreg_ptr(a->qd);
150
bool kvm_arm_hw_debug_active(CPUState *cs);
200
+ qm = mve_qreg_ptr(a->qm);
151
201
+ fn(cpu_env, qd, qm, tcg_constant_i32(shift));
152
/**
202
+ tcg_temp_free_ptr(qd);
153
* kvm_arm_copy_hw_debug_data:
203
+ tcg_temp_free_ptr(qm);
154
- *
204
+ mve_update_eci(s);
155
* @ptr: kvm_guest_debug_arch structure
205
+ return true;
156
*
206
+}
157
* Copy the architecture specific debug registers into the
207
+
158
* kvm_guest_debug ioctl structure.
208
+#define DO_2SHIFT(INSN, FN, NEGATESHIFT) \
159
*/
209
+ static bool trans_##INSN(DisasContext *s, arg_2shift *a) \
160
struct kvm_guest_debug_arch;
210
+ { \
161
-
211
+ static MVEGenTwoOpShiftFn * const fns[] = { \
162
void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr);
212
+ gen_helper_mve_##FN##b, \
163
213
+ gen_helper_mve_##FN##h, \
164
/**
214
+ gen_helper_mve_##FN##w, \
165
- * its_class_name
215
+ NULL, \
166
+ * its_class_name:
216
+ }; \
167
*
217
+ return do_2shift(s, a, fns[a->size], NEGATESHIFT); \
168
* Return the ITS class name to use depending on whether KVM acceleration
218
+ }
169
* and KVM CAP_SIGNAL_MSI are supported
219
+
220
+DO_2SHIFT(VSHLI, vshli_u, false)
221
+DO_2SHIFT(VQSHLI_S, vqshli_s, false)
222
+DO_2SHIFT(VQSHLI_U, vqshli_u, false)
223
+DO_2SHIFT(VQSHLUI, vqshlui_s, false)
170
--
224
--
171
2.20.1
225
2.20.1
172
226
173
227
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
Implement the MVE vector shift right by immediate insns VSHRI and
2
VRSHRI. As with Neon, we implement these by using helper functions
3
which perform left shifts but allow negative shift counts to indicate
4
right shifts.
2
5
3
The overhead for the OpenBMC firmware images using the a custom U-Boot
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
is around 2 seconds, which is fine, but with a U-Boot from mainline,
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
it takes an extra 50 seconds or so to reach Linux. A quick survey on
8
Message-id: 20210628135835.6690-9-peter.maydell@linaro.org
6
the number of reads performed on the flash memory region gives the
9
---
7
following figures :
10
target/arm/helper-mve.h | 12 ++++++++++++
11
target/arm/translate.h | 20 ++++++++++++++++++++
12
target/arm/mve.decode | 28 ++++++++++++++++++++++++++++
13
target/arm/mve_helper.c | 7 +++++++
14
target/arm/translate-mve.c | 5 +++++
15
target/arm/translate-neon.c | 18 ------------------
16
6 files changed, 72 insertions(+), 18 deletions(-)
8
17
9
OpenBMC U-Boot 922478 (~ 3.5 MBytes)
18
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
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
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
24
include/hw/arm/aspeed.h | 2 ++
25
hw/arm/aspeed.c | 44 ++++++++++++++++++++++++++++++++++++-----
26
2 files changed, 41 insertions(+), 5 deletions(-)
27
28
diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
29
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
30
--- a/include/hw/arm/aspeed.h
20
--- a/target/arm/helper-mve.h
31
+++ b/include/hw/arm/aspeed.h
21
+++ b/target/arm/helper-mve.h
32
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedBoardState AspeedBoardState;
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64)
33
23
DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64)
34
typedef struct AspeedMachine {
24
DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64)
35
MachineState parent_obj;
25
26
+DEF_HELPER_FLAGS_4(mve_vshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
27
+DEF_HELPER_FLAGS_4(mve_vshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
28
+DEF_HELPER_FLAGS_4(mve_vshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
+
29
+
37
+ bool mmio_exec;
30
DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
38
} AspeedMachine;
31
DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
39
32
DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
40
#define ASPEED_MACHINE_CLASS(klass) \
33
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
41
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
34
DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
35
DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
37
+
38
+DEF_HELPER_FLAGS_4(mve_vrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
39
+DEF_HELPER_FLAGS_4(mve_vrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
40
+DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
41
+
42
+DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
43
+DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
44
+DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
45
diff --git a/target/arm/translate.h b/target/arm/translate.h
42
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/arm/aspeed.c
47
--- a/target/arm/translate.h
44
+++ b/hw/arm/aspeed.c
48
+++ b/target/arm/translate.h
45
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
49
@@ -XXX,XX +XXX,XX @@ static inline int times_2_plus_1(DisasContext *s, int x)
46
* SoC and 128MB for the AST2500 SoC, which is twice as big as
50
return x * 2 + 1;
47
* needed by the flash modules of the Aspeed machines.
48
*/
49
- memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
50
- fl->size, &error_abort);
51
- memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
52
- boot_rom);
53
- write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort);
54
+ if (ASPEED_MACHINE(machine)->mmio_exec) {
55
+ memory_region_init_alias(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
56
+ &fl->mmio, 0, fl->size);
57
+ memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
58
+ boot_rom);
59
+ } else {
60
+ memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
61
+ fl->size, &error_abort);
62
+ memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
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;
69
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
70
/* Bus 11: TODO ucd90160@64 */
71
}
51
}
72
52
73
+static bool aspeed_get_mmio_exec(Object *obj, Error **errp)
53
+static inline int rsub_64(DisasContext *s, int x)
74
+{
54
+{
75
+ return ASPEED_MACHINE(obj)->mmio_exec;
55
+ return 64 - x;
76
+}
56
+}
77
+
57
+
78
+static void aspeed_set_mmio_exec(Object *obj, bool value, Error **errp)
58
+static inline int rsub_32(DisasContext *s, int x)
79
+{
59
+{
80
+ ASPEED_MACHINE(obj)->mmio_exec = value;
60
+ return 32 - x;
81
+}
61
+}
82
+
62
+
83
+static void aspeed_machine_instance_init(Object *obj)
63
+static inline int rsub_16(DisasContext *s, int x)
84
+{
64
+{
85
+ ASPEED_MACHINE(obj)->mmio_exec = false;
65
+ return 16 - x;
86
+}
66
+}
87
+
67
+
88
+static void aspeed_machine_class_props_init(ObjectClass *oc)
68
+static inline int rsub_8(DisasContext *s, int x)
89
+{
69
+{
90
+ object_class_property_add_bool(oc, "execute-in-place",
70
+ return 8 - x;
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
+}
71
+}
96
+
72
+
97
static void aspeed_machine_class_init(ObjectClass *oc, void *data)
73
static inline int arm_dc_feature(DisasContext *dc, int feature)
98
{
74
{
99
MachineClass *mc = MACHINE_CLASS(oc);
75
return (dc->features & (1ULL << feature)) != 0;
100
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data)
76
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
101
mc->no_floppy = 1;
77
index XXXXXXX..XXXXXXX 100644
102
mc->no_cdrom = 1;
78
--- a/target/arm/mve.decode
103
mc->no_parallel = 1;
79
+++ b/target/arm/mve.decode
80
@@ -XXX,XX +XXX,XX @@
81
@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1
82
@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2
83
84
+# Right shifts are encoded as N - shift, where N is the element size in bits.
85
+%rshift_i5 16:5 !function=rsub_32
86
+%rshift_i4 16:4 !function=rsub_16
87
+%rshift_i3 16:3 !function=rsub_8
104
+
88
+
105
+ aspeed_machine_class_props_init(oc);
89
+@2_shr_b .... .... .. 001 ... .... .... .... .... &2shift qd=%qd qm=%qm \
90
+ size=0 shift=%rshift_i3
91
+@2_shr_h .... .... .. 01 .... .... .... .... .... &2shift qd=%qd qm=%qm \
92
+ size=1 shift=%rshift_i4
93
+@2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \
94
+ size=2 shift=%rshift_i5
95
+
96
# Vector loads and stores
97
98
# Widening loads and narrowing stores:
99
@@ -XXX,XX +XXX,XX @@ VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w
100
VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b
101
VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h
102
VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w
103
+
104
+VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b
105
+VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h
106
+VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w
107
+
108
+VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b
109
+VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h
110
+VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w
111
+
112
+VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b
113
+VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h
114
+VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w
115
+
116
+VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b
117
+VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h
118
+VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w
119
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
120
index XXXXXXX..XXXXXXX 100644
121
--- a/target/arm/mve_helper.c
122
+++ b/target/arm/mve_helper.c
123
@@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t)
124
DO_2SHIFT(OP##b, 1, uint8_t, FN) \
125
DO_2SHIFT(OP##h, 2, uint16_t, FN) \
126
DO_2SHIFT(OP##w, 4, uint32_t, FN)
127
+#define DO_2SHIFT_S(OP, FN) \
128
+ DO_2SHIFT(OP##b, 1, int8_t, FN) \
129
+ DO_2SHIFT(OP##h, 2, int16_t, FN) \
130
+ DO_2SHIFT(OP##w, 4, int32_t, FN)
131
132
#define DO_2SHIFT_SAT_U(OP, FN) \
133
DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \
134
@@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t)
135
DO_2SHIFT_SAT(OP##w, 4, int32_t, FN)
136
137
DO_2SHIFT_U(vshli_u, DO_VSHLU)
138
+DO_2SHIFT_S(vshli_s, DO_VSHLS)
139
DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP)
140
DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP)
141
DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP)
142
+DO_2SHIFT_U(vrshli_u, DO_VRSHLU)
143
+DO_2SHIFT_S(vrshli_s, DO_VRSHLS)
144
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
145
index XXXXXXX..XXXXXXX 100644
146
--- a/target/arm/translate-mve.c
147
+++ b/target/arm/translate-mve.c
148
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHLI, vshli_u, false)
149
DO_2SHIFT(VQSHLI_S, vqshli_s, false)
150
DO_2SHIFT(VQSHLI_U, vqshli_u, false)
151
DO_2SHIFT(VQSHLUI, vqshlui_s, false)
152
+/* These right shifts use a left-shift helper with negated shift count */
153
+DO_2SHIFT(VSHRI_S, vshli_s, true)
154
+DO_2SHIFT(VSHRI_U, vshli_u, true)
155
+DO_2SHIFT(VRSHRI_S, vrshli_s, true)
156
+DO_2SHIFT(VRSHRI_U, vrshli_u, true)
157
diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c
158
index XXXXXXX..XXXXXXX 100644
159
--- a/target/arm/translate-neon.c
160
+++ b/target/arm/translate-neon.c
161
@@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x)
162
return x + 1;
106
}
163
}
107
164
108
static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
165
-static inline int rsub_64(DisasContext *s, int x)
109
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = {
166
-{
110
.name = TYPE_ASPEED_MACHINE,
167
- return 64 - x;
111
.parent = TYPE_MACHINE,
168
-}
112
.instance_size = sizeof(AspeedMachine),
169
-
113
+ .instance_init = aspeed_machine_instance_init,
170
-static inline int rsub_32(DisasContext *s, int x)
114
.class_size = sizeof(AspeedMachineClass),
171
-{
115
.class_init = aspeed_machine_class_init,
172
- return 32 - x;
116
.abstract = true,
173
-}
174
-static inline int rsub_16(DisasContext *s, int x)
175
-{
176
- return 16 - x;
177
-}
178
-static inline int rsub_8(DisasContext *s, int x)
179
-{
180
- return 8 - x;
181
-}
182
-
183
static inline int neon_3same_fp_size(DisasContext *s, int x)
184
{
185
/* Convert 0==fp32, 1==fp16 into a MO_* value */
117
--
186
--
118
2.20.1
187
2.20.1
119
188
120
189
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
Implement the MVE VHLL (vector shift left long) insn. This has two
2
encodings: the T1 encoding is the usual shift-by-immediate format,
3
and the T2 encoding is a special case where the shift count is always
4
equal to the element size.
2
5
3
When a VM is stopped (such as when it's paused) guest virtual time
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
should stop counting. Otherwise, when the VM is resumed it will
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
experience time jumps and its kernel may report soft lockups. Not
8
Message-id: 20210628135835.6690-10-peter.maydell@linaro.org
6
counting virtual time while the VM is stopped has the side effect
9
---
7
of making the guest's time appear to lag when compared with real
10
target/arm/helper-mve.h | 9 +++++++
8
time, and even with time derived from the physical counter. For
11
target/arm/mve.decode | 53 +++++++++++++++++++++++++++++++++++---
9
this reason, this change, which is enabled by default, comes with
12
target/arm/mve_helper.c | 32 +++++++++++++++++++++++
10
a KVM CPU feature allowing it to be disabled, restoring legacy
13
target/arm/translate-mve.c | 15 +++++++++++
11
behavior.
14
4 files changed, 105 insertions(+), 4 deletions(-)
12
15
13
This patch only provides the implementation of the virtual time
16
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
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>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
target/arm/cpu.h | 7 ++++
24
target/arm/kvm_arm.h | 38 ++++++++++++++++++
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(+)
30
31
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
32
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/cpu.h
18
--- a/target/arm/helper-mve.h
34
+++ b/target/arm/cpu.h
19
+++ b/target/arm/helper-mve.h
35
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
/* KVM init features for this CPU */
21
DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
37
uint32_t kvm_init_features[7];
22
DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
38
23
DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
39
+ /* KVM CPU state */
40
+
24
+
41
+ /* KVM virtual time adjustment */
25
+DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
42
+ bool kvm_adjvtime;
26
+DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
43
+ bool kvm_vtime_dirty;
27
+DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
44
+ uint64_t kvm_vtime;
28
+DEF_HELPER_FLAGS_4(mve_vshllbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
29
+DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
30
+DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
31
+DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
32
+DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
33
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/mve.decode
36
+++ b/target/arm/mve.decode
37
@@ -XXX,XX +XXX,XX @@
38
@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1
39
@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2
40
41
+@2_shll_b .... .... ... 01 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0
42
+@2_shll_h .... .... ... 1 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1
43
+# VSHLL encoding T2 where shift == esize
44
+@2_shll_esize_b .... .... .... 00 .. .... .... .... .... &2shift \
45
+ qd=%qd qm=%qm size=0 shift=8
46
+@2_shll_esize_h .... .... .... 01 .. .... .... .... .... &2shift \
47
+ qd=%qd qm=%qm size=1 shift=16
45
+
48
+
46
/* Uniprocessor system with MP extensions */
49
# Right shifts are encoded as N - shift, where N is the element size in bits.
47
bool mp_is_up;
50
%rshift_i5 16:5 !function=rsub_32
48
51
%rshift_i4 16:4 !function=rsub_16
49
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
52
@@ -XXX,XX +XXX,XX @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op
50
index XXXXXXX..XXXXXXX 100644
53
VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op
51
--- a/target/arm/kvm_arm.h
54
VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op
52
+++ b/target/arm/kvm_arm.h
55
53
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level);
56
-VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op
54
*/
57
-VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op
55
bool write_kvmstate_to_list(ARMCPU *cpu);
58
+# The VSHLL T2 encoding is not a @2op pattern, but is here because it
56
59
+# overlaps what would be size=0b11 VMULH/VRMULH
57
+/**
58
+ * kvm_arm_cpu_pre_save:
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)
117
return 0;
118
}
119
120
+/*
121
+ * cpreg_values are sorted in ascending order by KVM register ID
122
+ * (see kvm_arm_init_cpreg_list). This allows us to cheaply find
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
+{
60
+{
127
+ uint64_t *res;
61
+ VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b
128
+
62
+ VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h
129
+ res = bsearch(&regidx, cpu->cpreg_indexes, cpu->cpreg_array_len,
63
130
+ sizeof(uint64_t), compare_u64);
64
-VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op
131
+ assert(res);
65
-VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op
132
+
66
+ VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op
133
+ return &cpu->cpreg_values[res - cpu->cpreg_indexes];
134
+}
67
+}
135
+
68
+
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
+{
69
+{
145
+ /* KVM virtual time adjustment */
70
+ VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b
146
+ if (cpu->kvm_vtime_dirty) {
71
+ VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h
147
+ *kvm_arm_get_cpreg_ptr(cpu, KVM_REG_ARM_TIMER_CNT) = cpu->kvm_vtime;
72
+
148
+ }
73
+ VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op
149
+}
74
+}
150
+
75
+
151
+void kvm_arm_cpu_post_load(ARMCPU *cpu)
152
+{
76
+{
153
+ /* KVM virtual time adjustment */
77
+ VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b
154
+ if (cpu->kvm_adjvtime) {
78
+ VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h
155
+ cpu->kvm_vtime = *kvm_arm_get_cpreg_ptr(cpu, KVM_REG_ARM_TIMER_CNT);
79
+
156
+ cpu->kvm_vtime_dirty = true;
80
+ VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op
157
+ }
158
+}
81
+}
159
+
82
+
160
void kvm_arm_reset_vcpu(ARMCPU *cpu)
161
{
162
int ret;
163
@@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu)
164
return 0;
165
}
166
167
+void kvm_arm_get_virtual_time(CPUState *cs)
168
+{
83
+{
169
+ ARMCPU *cpu = ARM_CPU(cs);
84
+ VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b
170
+ struct kvm_one_reg reg = {
85
+ VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h
171
+ .id = KVM_REG_ARM_TIMER_CNT,
172
+ .addr = (uintptr_t)&cpu->kvm_vtime,
173
+ };
174
+ int ret;
175
+
86
+
176
+ if (cpu->kvm_vtime_dirty) {
87
+ VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op
177
+ return;
88
+}
89
90
VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op
91
VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op
92
@@ -XXX,XX +XXX,XX @@ VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w
93
VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b
94
VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h
95
VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w
96
+
97
+# VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file
98
+VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b
99
+VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h
100
+
101
+VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b
102
+VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h
103
+
104
+VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b
105
+VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h
106
+
107
+VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b
108
+VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h
109
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
110
index XXXXXXX..XXXXXXX 100644
111
--- a/target/arm/mve_helper.c
112
+++ b/target/arm/mve_helper.c
113
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP)
114
DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP)
115
DO_2SHIFT_U(vrshli_u, DO_VRSHLU)
116
DO_2SHIFT_S(vrshli_s, DO_VRSHLS)
117
+
118
+/*
119
+ * Long shifts taking half-sized inputs from top or bottom of the input
120
+ * vector and producing a double-width result. ESIZE, TYPE are for
121
+ * the input, and LESIZE, LTYPE for the output.
122
+ * Unlike the normal shift helpers, we do not handle negative shift counts,
123
+ * because the long shift is strictly left-only.
124
+ */
125
+#define DO_VSHLL(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \
126
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
127
+ void *vm, uint32_t shift) \
128
+ { \
129
+ LTYPE *d = vd; \
130
+ TYPE *m = vm; \
131
+ uint16_t mask = mve_element_mask(env); \
132
+ unsigned le; \
133
+ assert(shift <= 16); \
134
+ for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \
135
+ LTYPE r = (LTYPE)m[H##ESIZE(le * 2 + TOP)] << shift; \
136
+ mergemask(&d[H##LESIZE(le)], r, mask); \
137
+ } \
138
+ mve_advance_vpt(env); \
178
+ }
139
+ }
179
+
140
+
180
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
141
+#define DO_VSHLL_ALL(OP, TOP) \
181
+ if (ret) {
142
+ DO_VSHLL(OP##sb, TOP, 1, int8_t, 2, int16_t) \
182
+ error_report("Failed to get KVM_REG_ARM_TIMER_CNT");
143
+ DO_VSHLL(OP##ub, TOP, 1, uint8_t, 2, uint16_t) \
183
+ abort();
144
+ DO_VSHLL(OP##sh, TOP, 2, int16_t, 4, int32_t) \
145
+ DO_VSHLL(OP##uh, TOP, 2, uint16_t, 4, uint32_t) \
146
+
147
+DO_VSHLL_ALL(vshllb, false)
148
+DO_VSHLL_ALL(vshllt, true)
149
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
150
index XXXXXXX..XXXXXXX 100644
151
--- a/target/arm/translate-mve.c
152
+++ b/target/arm/translate-mve.c
153
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_S, vshli_s, true)
154
DO_2SHIFT(VSHRI_U, vshli_u, true)
155
DO_2SHIFT(VRSHRI_S, vrshli_s, true)
156
DO_2SHIFT(VRSHRI_U, vrshli_u, true)
157
+
158
+#define DO_VSHLL(INSN, FN) \
159
+ static bool trans_##INSN(DisasContext *s, arg_2shift *a) \
160
+ { \
161
+ static MVEGenTwoOpShiftFn * const fns[] = { \
162
+ gen_helper_mve_##FN##b, \
163
+ gen_helper_mve_##FN##h, \
164
+ }; \
165
+ return do_2shift(s, a, fns[a->size], false); \
184
+ }
166
+ }
185
+
167
+
186
+ cpu->kvm_vtime_dirty = true;
168
+DO_VSHLL(VSHLL_BS, vshllbs)
187
+}
169
+DO_VSHLL(VSHLL_BU, vshllbu)
188
+
170
+DO_VSHLL(VSHLL_TS, vshllts)
189
+void kvm_arm_put_virtual_time(CPUState *cs)
171
+DO_VSHLL(VSHLL_TU, vshlltu)
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;
250
}
251
252
+ qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs);
253
+
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;
271
}
272
273
+ qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs);
274
+
275
/* Determine init features for this CPU */
276
memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
277
if (cpu->start_powered_off) {
278
diff --git a/target/arm/machine.c b/target/arm/machine.c
279
index XXXXXXX..XXXXXXX 100644
280
--- a/target/arm/machine.c
281
+++ b/target/arm/machine.c
282
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
283
/* This should never fail */
284
abort();
285
}
286
+
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;
303
--
172
--
304
2.20.1
173
2.20.1
305
174
306
175
diff view generated by jsdifflib
1
From: Zenghui Yu <yuzenghui@huawei.com>
1
Implement the MVE VSRI and VSLI insns, which perform a
2
shift-and-insert operation.
2
3
3
If LPIs are disabled, KVM will just ignore the GICR_PENDBASER.PTZ bit when
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
restoring GICR_CTLR. Setting PTZ here makes littlt sense in "reduce GIC
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
initialization time".
6
Message-id: 20210628135835.6690-11-peter.maydell@linaro.org
7
---
8
target/arm/helper-mve.h | 8 ++++++++
9
target/arm/mve.decode | 9 ++++++++
10
target/arm/mve_helper.c | 42 ++++++++++++++++++++++++++++++++++++++
11
target/arm/translate-mve.c | 3 +++
12
4 files changed, 62 insertions(+)
6
13
7
And what's worse, PTZ is generally programmed by guest to indicate to the
14
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
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
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
hw/intc/arm_gicv3_kvm.c | 11 ++++-------
22
1 file changed, 4 insertions(+), 7 deletions(-)
23
24
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
25
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/intc/arm_gicv3_kvm.c
16
--- a/target/arm/helper-mve.h
27
+++ b/hw/intc/arm_gicv3_kvm.c
17
+++ b/target/arm/helper-mve.h
28
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_put(GICv3State *s)
18
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
29
kvm_gicd_access(s, GICD_CTLR, &reg, true);
19
DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
30
20
DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
31
if (redist_typer & GICR_TYPER_PLPIS) {
21
DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
32
- /* Set base addresses before LPIs are enabled by GICR_CTLR write */
22
+
33
+ /*
23
+DEF_HELPER_FLAGS_4(mve_vsrib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
34
+ * Restore base addresses before LPIs are potentially enabled by
24
+DEF_HELPER_FLAGS_4(mve_vsrih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
35
+ * GICR_CTLR write
25
+DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
+ */
26
+
37
for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
27
+DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
38
GICv3CPUState *c = &s->cpu[ncpu];
28
+DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
39
29
+DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
40
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_put(GICv3State *s)
30
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
41
kvm_gicr_access(s, GICR_PROPBASER + 4, ncpu, &regh, true);
31
index XXXXXXX..XXXXXXX 100644
42
32
--- a/target/arm/mve.decode
43
reg64 = c->gicr_pendbaser;
33
+++ b/target/arm/mve.decode
44
- if (!(c->gicr_ctlr & GICR_CTLR_ENABLE_LPIS)) {
34
@@ -XXX,XX +XXX,XX @@ VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h
45
- /* Setting PTZ is advised if LPIs are disabled, to reduce
35
46
- * GIC initialization time.
36
VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b
47
- */
37
VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h
48
- reg64 |= GICR_PENDBASER_PTZ;
38
+
49
- }
39
+# Shift-and-insert
50
regl = (uint32_t)reg64;
40
+VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_b
51
kvm_gicr_access(s, GICR_PENDBASER, ncpu, &regl, true);
41
+VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_h
52
regh = (uint32_t)(reg64 >> 32);
42
+VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w
43
+
44
+VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b
45
+VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h
46
+VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w
47
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/mve_helper.c
50
+++ b/target/arm/mve_helper.c
51
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP)
52
DO_2SHIFT_U(vrshli_u, DO_VRSHLU)
53
DO_2SHIFT_S(vrshli_s, DO_VRSHLS)
54
55
+/* Shift-and-insert; we always work with 64 bits at a time */
56
+#define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \
57
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
58
+ void *vm, uint32_t shift) \
59
+ { \
60
+ uint64_t *d = vd, *m = vm; \
61
+ uint16_t mask; \
62
+ uint64_t shiftmask; \
63
+ unsigned e; \
64
+ if (shift == 0 || shift == ESIZE * 8) { \
65
+ /* \
66
+ * Only VSLI can shift by 0; only VSRI can shift by <dt>. \
67
+ * The generic logic would give the right answer for 0 but \
68
+ * fails for <dt>. \
69
+ */ \
70
+ goto done; \
71
+ } \
72
+ assert(shift < ESIZE * 8); \
73
+ mask = mve_element_mask(env); \
74
+ /* ESIZE / 2 gives the MO_* value if ESIZE is in [1,2,4] */ \
75
+ shiftmask = dup_const(ESIZE / 2, MASKFN(ESIZE * 8, shift)); \
76
+ for (e = 0; e < 16 / 8; e++, mask >>= 8) { \
77
+ uint64_t r = (SHIFTFN(m[H8(e)], shift) & shiftmask) | \
78
+ (d[H8(e)] & ~shiftmask); \
79
+ mergemask(&d[H8(e)], r, mask); \
80
+ } \
81
+done: \
82
+ mve_advance_vpt(env); \
83
+ }
84
+
85
+#define DO_SHL(N, SHIFT) ((N) << (SHIFT))
86
+#define DO_SHR(N, SHIFT) ((N) >> (SHIFT))
87
+#define SHL_MASK(EBITS, SHIFT) MAKE_64BIT_MASK((SHIFT), (EBITS) - (SHIFT))
88
+#define SHR_MASK(EBITS, SHIFT) MAKE_64BIT_MASK(0, (EBITS) - (SHIFT))
89
+
90
+DO_2SHIFT_INSERT(vsrib, 1, DO_SHR, SHR_MASK)
91
+DO_2SHIFT_INSERT(vsrih, 2, DO_SHR, SHR_MASK)
92
+DO_2SHIFT_INSERT(vsriw, 4, DO_SHR, SHR_MASK)
93
+DO_2SHIFT_INSERT(vslib, 1, DO_SHL, SHL_MASK)
94
+DO_2SHIFT_INSERT(vslih, 2, DO_SHL, SHL_MASK)
95
+DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK)
96
+
97
/*
98
* Long shifts taking half-sized inputs from top or bottom of the input
99
* vector and producing a double-width result. ESIZE, TYPE are for
100
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/target/arm/translate-mve.c
103
+++ b/target/arm/translate-mve.c
104
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_U, vshli_u, true)
105
DO_2SHIFT(VRSHRI_S, vrshli_s, true)
106
DO_2SHIFT(VRSHRI_U, vrshli_u, true)
107
108
+DO_2SHIFT(VSRI, vsri, false)
109
+DO_2SHIFT(VSLI, vsli, false)
110
+
111
#define DO_VSHLL(INSN, FN) \
112
static bool trans_##INSN(DisasContext *s, arg_2shift *a) \
113
{ \
53
--
114
--
54
2.20.1
115
2.20.1
55
116
56
117
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Implement the MVE shift-right-and-narrow insn VSHRN and VRSHRN.
2
2
3
Add a function resettable_change_parent() to do the required
3
do_urshr() is borrowed from sve_helper.c.
4
plumbing when changing the parent a of Resettable object.
5
4
6
We need to make sure that the reset state of the object remains
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
coherent with the reset state of the new parent.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20210628135835.6690-12-peter.maydell@linaro.org
8
---
9
target/arm/helper-mve.h | 10 ++++++++++
10
target/arm/mve.decode | 11 +++++++++++
11
target/arm/mve_helper.c | 40 ++++++++++++++++++++++++++++++++++++++
12
target/arm/translate-mve.c | 15 ++++++++++++++
13
4 files changed, 76 insertions(+)
8
14
9
We make the 2 following hypothesis:
15
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
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
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
25
include/hw/resettable.h | 16 +++++++++++
26
hw/core/resettable.c | 62 +++++++++++++++++++++++++++++++++++++++--
27
hw/core/trace-events | 1 +
28
3 files changed, 77 insertions(+), 2 deletions(-)
29
30
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
31
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
32
--- a/include/hw/resettable.h
17
--- a/target/arm/helper-mve.h
33
+++ b/include/hw/resettable.h
18
+++ b/target/arm/helper-mve.h
34
@@ -XXX,XX +XXX,XX @@ void resettable_release_reset(Object *obj, ResetType type);
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
35
*/
20
DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
bool resettable_is_in_reset(Object *obj);
21
DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
37
22
DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
38
+/**
23
+
39
+ * resettable_change_parent:
24
+DEF_HELPER_FLAGS_4(mve_vshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
40
+ * Indicate that the parent of Ressettable @obj is changing from @oldp to @newp.
25
+DEF_HELPER_FLAGS_4(mve_vshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
41
+ * All 3 objects must implement resettable interface. @oldp or @newp may be
26
+DEF_HELPER_FLAGS_4(mve_vshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
42
+ * NULL.
27
+DEF_HELPER_FLAGS_4(mve_vshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
43
+ *
28
+
44
+ * This function will adapt the reset state of @obj so that it is coherent
29
+DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
45
+ * with the reset state of @newp. It may trigger @resettable_assert_reset()
30
+DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
46
+ * or @resettable_release_reset(). It will do such things only if the reset
31
+DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
47
+ * state of @newp and @oldp are different.
32
+DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
48
+ *
33
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
49
+ * When using this function during reset, it must only be called during
34
index XXXXXXX..XXXXXXX 100644
50
+ * a hold phase method. Calling this during enter or exit phase is an error.
35
--- a/target/arm/mve.decode
36
+++ b/target/arm/mve.decode
37
@@ -XXX,XX +XXX,XX @@ VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w
38
VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b
39
VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h
40
VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w
41
+
42
+# Narrowing shifts (which only support b and h sizes)
43
+VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b
44
+VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h
45
+VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b
46
+VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h
47
+
48
+VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b
49
+VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h
50
+VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b
51
+VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h
52
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/mve_helper.c
55
+++ b/target/arm/mve_helper.c
56
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK)
57
58
DO_VSHLL_ALL(vshllb, false)
59
DO_VSHLL_ALL(vshllt, true)
60
+
61
+/*
62
+ * Narrowing right shifts, taking a double sized input, shifting it
63
+ * and putting the result in either the top or bottom half of the output.
64
+ * ESIZE, TYPE are the output, and LESIZE, LTYPE the input.
51
+ */
65
+ */
52
+void resettable_change_parent(Object *obj, Object *newp, Object *oldp);
66
+#define DO_VSHRN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \
67
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
68
+ void *vm, uint32_t shift) \
69
+ { \
70
+ LTYPE *m = vm; \
71
+ TYPE *d = vd; \
72
+ uint16_t mask = mve_element_mask(env); \
73
+ unsigned le; \
74
+ for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \
75
+ TYPE r = FN(m[H##LESIZE(le)], shift); \
76
+ mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \
77
+ } \
78
+ mve_advance_vpt(env); \
79
+ }
53
+
80
+
54
/**
81
+#define DO_VSHRN_ALL(OP, FN) \
55
* resettable_class_set_parent_phases:
82
+ DO_VSHRN(OP##bb, false, 1, uint8_t, 2, uint16_t, FN) \
56
*
83
+ DO_VSHRN(OP##bh, false, 2, uint16_t, 4, uint32_t, FN) \
57
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
84
+ DO_VSHRN(OP##tb, true, 1, uint8_t, 2, uint16_t, FN) \
58
index XXXXXXX..XXXXXXX 100644
85
+ DO_VSHRN(OP##th, true, 2, uint16_t, 4, uint32_t, FN)
59
--- a/hw/core/resettable.c
86
+
60
+++ b/hw/core/resettable.c
87
+static inline uint64_t do_urshr(uint64_t x, unsigned sh)
61
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type);
62
* enter_phase_in_progress:
63
* True if we are currently in reset enter phase.
64
*
65
- * Note: This flag is only used to guarantee (using asserts) that the reset
66
- * API is used correctly. We can use a global variable because we rely on the
67
+ * exit_phase_in_progress:
68
+ * count the number of exit phase we are in.
69
+ *
70
+ * Note: These flags are only used to guarantee (using asserts) that the reset
71
+ * API is used correctly. We can use global variables because we rely on the
72
* iothread mutex to ensure only one reset operation is in a progress at a
73
* given time.
74
*/
75
static bool enter_phase_in_progress;
76
+static unsigned exit_phase_in_progress;
77
78
void resettable_reset(Object *obj, ResetType type)
79
{
80
@@ -XXX,XX +XXX,XX @@ void resettable_release_reset(Object *obj, ResetType type)
81
trace_resettable_reset_release_begin(obj, type);
82
assert(!enter_phase_in_progress);
83
84
+ exit_phase_in_progress += 1;
85
resettable_phase_exit(obj, NULL, type);
86
+ exit_phase_in_progress -= 1;
87
88
trace_resettable_reset_release_end(obj);
89
}
90
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
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)
99
+{
88
+{
100
+ if (obj) {
89
+ if (likely(sh < 64)) {
101
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
90
+ return (x >> sh) + ((x >> (sh - 1)) & 1);
102
+ return rc->get_state(obj)->count;
91
+ } else if (sh == 64) {
103
+ }
92
+ return x >> 63;
104
+ return 0;
93
+ } else {
105
+}
94
+ return 0;
106
+
107
+void resettable_change_parent(Object *obj, Object *newp, Object *oldp)
108
+{
109
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
110
+ ResettableState *s = rc->get_state(obj);
111
+ unsigned newp_count = resettable_get_count(newp);
112
+ unsigned oldp_count = resettable_get_count(oldp);
113
+
114
+ /*
115
+ * Ensure we do not change parent when in enter or exit phase.
116
+ * During these phases, the reset subtree being updated is partly in reset
117
+ * and partly not in reset (it depends on the actual position in
118
+ * resettable_child_foreach()s). We are not able to tell in which part is a
119
+ * leaving or arriving device. Thus we cannot set the reset count of the
120
+ * moving device to the proper value.
121
+ */
122
+ assert(!enter_phase_in_progress && !exit_phase_in_progress);
123
+ trace_resettable_change_parent(obj, oldp, oldp_count, newp, newp_count);
124
+
125
+ /*
126
+ * At most one of the two 'for' loops will be executed below
127
+ * in order to cope with the difference between the two counts.
128
+ */
129
+ /* if newp is more reset than oldp */
130
+ for (unsigned i = oldp_count; i < newp_count; i++) {
131
+ resettable_assert_reset(obj, RESET_TYPE_COLD);
132
+ }
133
+ /*
134
+ * if obj is leaving a bus under reset, we need to ensure
135
+ * hold phase is not pending.
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
+ }
95
+ }
144
+}
96
+}
145
+
97
+
146
void resettable_class_set_parent_phases(ResettableClass *rc,
98
+DO_VSHRN_ALL(vshrn, DO_SHR)
147
ResettableEnterPhase enter,
99
+DO_VSHRN_ALL(vrshrn, do_urshr)
148
ResettableHoldPhase hold,
100
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
149
diff --git a/hw/core/trace-events b/hw/core/trace-events
150
index XXXXXXX..XXXXXXX 100644
101
index XXXXXXX..XXXXXXX 100644
151
--- a/hw/core/trace-events
102
--- a/target/arm/translate-mve.c
152
+++ b/hw/core/trace-events
103
+++ b/target/arm/translate-mve.c
153
@@ -XXX,XX +XXX,XX @@ resettable_reset_assert_begin(void *obj, int cold) "obj=%p cold=%d"
104
@@ -XXX,XX +XXX,XX @@ DO_VSHLL(VSHLL_BS, vshllbs)
154
resettable_reset_assert_end(void *obj) "obj=%p"
105
DO_VSHLL(VSHLL_BU, vshllbu)
155
resettable_reset_release_begin(void *obj, int cold) "obj=%p cold=%d"
106
DO_VSHLL(VSHLL_TS, vshllts)
156
resettable_reset_release_end(void *obj) "obj=%p"
107
DO_VSHLL(VSHLL_TU, vshlltu)
157
+resettable_change_parent(void *obj, void *o, unsigned oc, void *n, unsigned nc) "obj=%p from=%p(%d) to=%p(%d)"
108
+
158
resettable_phase_enter_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
109
+#define DO_2SHIFT_N(INSN, FN) \
159
resettable_phase_enter_exec(void *obj, const char *objtype, int type, int has_method) "obj=%p(%s) type=%d method=%d"
110
+ static bool trans_##INSN(DisasContext *s, arg_2shift *a) \
160
resettable_phase_enter_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
111
+ { \
112
+ static MVEGenTwoOpShiftFn * const fns[] = { \
113
+ gen_helper_mve_##FN##b, \
114
+ gen_helper_mve_##FN##h, \
115
+ }; \
116
+ return do_2shift(s, a, fns[a->size], false); \
117
+ }
118
+
119
+DO_2SHIFT_N(VSHRNB, vshrnb)
120
+DO_2SHIFT_N(VSHRNT, vshrnt)
121
+DO_2SHIFT_N(VRSHRNB, vrshrnb)
122
+DO_2SHIFT_N(VRSHRNT, vrshrnt)
161
--
123
--
162
2.20.1
124
2.20.1
163
125
164
126
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Implement the MVE saturating shift-right-and-narrow insns
2
2
VQSHRN, VQSHRUN, VQRSHRN and VQRSHRUN.
3
This commit adds support of Resettable interface to buses and devices:
3
4
+ ResettableState structure is added in the Bus/Device state
4
do_srshr() is borrowed from sve_helper.c.
5
+ Resettable methods are implemented.
5
6
+ device/bus_is_in_reset function defined
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
8
This commit allows to transition the objects to the new
9
multi-phase interface without changing the reset behavior at all.
10
Object single reset method can be split into the 3 different phases
11
but the 3 phases are still executed in a row for a given object.
12
From the qdev/qbus reset api point of view, nothing is changed.
13
qdev_reset_all() and qbus_reset_all() are not modified as well as
14
device_legacy_reset().
15
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>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20210628135835.6690-13-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
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
---
9
---
30
tests/Makefile.include | 1 +
10
target/arm/helper-mve.h | 30 +++++++++++
31
include/hw/qdev-core.h | 27 ++++++++++++
11
target/arm/mve.decode | 28 ++++++++++
32
hw/core/bus.c | 97 ++++++++++++++++++++++++++++++++++++++++++
12
target/arm/mve_helper.c | 104 +++++++++++++++++++++++++++++++++++++
33
hw/core/qdev.c | 93 ++++++++++++++++++++++++++++++++++++++++
13
target/arm/translate-mve.c | 12 +++++
34
4 files changed, 218 insertions(+)
14
4 files changed, 174 insertions(+)
35
15
36
diff --git a/tests/Makefile.include b/tests/Makefile.include
16
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
37
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
38
--- a/tests/Makefile.include
18
--- a/target/arm/helper-mve.h
39
+++ b/tests/Makefile.include
19
+++ b/target/arm/helper-mve.h
40
@@ -XXX,XX +XXX,XX @@ tests/fp/%:
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
41
tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
21
DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
42
    hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\
22
DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
43
    hw/core/bus.o \
23
DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
44
+    hw/core/resettable.o \
24
+
45
    hw/core/irq.o \
25
+DEF_HELPER_FLAGS_4(mve_vqshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
46
    hw/core/fw-path-provider.o \
26
+DEF_HELPER_FLAGS_4(mve_vqshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
47
    hw/core/reset.o \
27
+DEF_HELPER_FLAGS_4(mve_vqshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
48
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
28
+DEF_HELPER_FLAGS_4(mve_vqshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
49
index XXXXXXX..XXXXXXX 100644
29
+
50
--- a/include/hw/qdev-core.h
30
+DEF_HELPER_FLAGS_4(mve_vqshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
51
+++ b/include/hw/qdev-core.h
31
+DEF_HELPER_FLAGS_4(mve_vqshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
52
@@ -XXX,XX +XXX,XX @@
32
+DEF_HELPER_FLAGS_4(mve_vqshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
53
#include "qemu/bitmap.h"
33
+DEF_HELPER_FLAGS_4(mve_vqshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
54
#include "qom/object.h"
34
+
55
#include "hw/hotplug.h"
35
+DEF_HELPER_FLAGS_4(mve_vqshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
56
+#include "hw/resettable.h"
36
+DEF_HELPER_FLAGS_4(mve_vqshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
57
37
+DEF_HELPER_FLAGS_4(mve_vqshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
58
enum {
38
+DEF_HELPER_FLAGS_4(mve_vqshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
59
DEV_NVECTORS_UNSPECIFIED = -1,
39
+
60
@@ -XXX,XX +XXX,XX @@ typedef struct DeviceClass {
40
+DEF_HELPER_FLAGS_4(mve_vqrshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
61
bool hotpluggable;
41
+DEF_HELPER_FLAGS_4(mve_vqrshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
62
42
+DEF_HELPER_FLAGS_4(mve_vqrshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
63
/* callbacks */
43
+DEF_HELPER_FLAGS_4(mve_vqrshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
64
+ /*
44
+
65
+ * Reset method here is deprecated and replaced by methods in the
45
+DEF_HELPER_FLAGS_4(mve_vqrshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
66
+ * resettable class interface to implement a multi-phase reset.
46
+DEF_HELPER_FLAGS_4(mve_vqrshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
67
+ * TODO: remove once every reset callback is unused
47
+DEF_HELPER_FLAGS_4(mve_vqrshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
68
+ */
48
+DEF_HELPER_FLAGS_4(mve_vqrshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
69
DeviceReset reset;
49
+
70
DeviceRealize realize;
50
+DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
71
DeviceUnrealize unrealize;
51
+DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
72
@@ -XXX,XX +XXX,XX @@ struct NamedGPIOList {
52
+DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
73
/**
53
+DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
74
* DeviceState:
54
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
75
* @realized: Indicates whether the device has been fully constructed.
55
index XXXXXXX..XXXXXXX 100644
76
+ * @reset: ResettableState for the device; handled by Resettable interface.
56
--- a/target/arm/mve.decode
77
*
57
+++ b/target/arm/mve.decode
78
* This structure should not be accessed directly. We declare it here
58
@@ -XXX,XX +XXX,XX @@ VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b
79
* so that it can be embedded in individual device state structures.
59
VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h
80
@@ -XXX,XX +XXX,XX @@ struct DeviceState {
60
VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b
81
int num_child_bus;
61
VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h
82
int instance_id_alias;
62
+
83
int alias_required_for_version;
63
+VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b
84
+ ResettableState reset;
64
+VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h
85
};
65
+VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b
86
66
+VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h
87
struct DeviceListener {
67
+VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b
88
@@ -XXX,XX +XXX,XX @@ typedef struct BusChild {
68
+VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h
89
/**
69
+VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b
90
* BusState:
70
+VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h
91
* @hotplug_handler: link to a hotplug handler associated with bus.
71
+
92
+ * @reset: ResettableState for the bus; handled by Resettable interface.
72
+VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b
93
*/
73
+VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h
94
struct BusState {
74
+VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b
95
Object obj;
75
+VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h
96
@@ -XXX,XX +XXX,XX @@ struct BusState {
76
+
97
int num_children;
77
+VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b
98
QTAILQ_HEAD(, BusChild) children;
78
+VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h
99
QLIST_ENTRY(BusState) sibling;
79
+VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b
100
+ ResettableState reset;
80
+VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h
101
};
81
+VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b
102
82
+VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h
103
/**
83
+VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b
104
@@ -XXX,XX +XXX,XX @@ void qdev_reset_all_fn(void *opaque);
84
+VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h
105
void qbus_reset_all(BusState *bus);
85
+
106
void qbus_reset_all_fn(void *opaque);
86
+VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b
107
87
+VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h
108
+/**
88
+VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b
109
+ * device_is_in_reset:
89
+VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h
110
+ * Return true if the device @dev is currently being reset.
90
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
111
+ */
91
index XXXXXXX..XXXXXXX 100644
112
+bool device_is_in_reset(DeviceState *dev);
92
--- a/target/arm/mve_helper.c
113
+
93
+++ b/target/arm/mve_helper.c
114
+/**
94
@@ -XXX,XX +XXX,XX @@ static inline uint64_t do_urshr(uint64_t x, unsigned sh)
115
+ * bus_is_in_reset:
95
}
116
+ * Return true if the bus @bus is currently being reset.
117
+ */
118
+bool bus_is_in_reset(BusState *bus);
119
+
120
/* This should go away once we get rid of the NULL bus hack */
121
BusState *sysbus_get_default(void);
122
123
@@ -XXX,XX +XXX,XX @@ void device_legacy_reset(DeviceState *dev);
124
125
void device_class_set_props(DeviceClass *dc, Property *props);
126
127
+/**
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
136
index XXXXXXX..XXXXXXX 100644
137
--- a/hw/core/bus.c
138
+++ b/hw/core/bus.c
139
@@ -XXX,XX +XXX,XX @@ int qbus_walk_children(BusState *bus,
140
return 0;
141
}
96
}
142
97
143
+bool bus_is_in_reset(BusState *bus)
98
+static inline int64_t do_srshr(int64_t x, unsigned sh)
144
+{
99
+{
145
+ return resettable_is_in_reset(OBJECT(bus));
100
+ if (likely(sh < 64)) {
146
+}
101
+ return (x >> sh) + ((x >> (sh - 1)) & 1);
147
+
102
+ } else {
148
+static ResettableState *bus_get_reset_state(Object *obj)
103
+ /* Rounding the sign bit always produces 0. */
149
+{
104
+ return 0;
150
+ BusState *bus = BUS(obj);
151
+ return &bus->reset;
152
+}
153
+
154
+static void bus_reset_child_foreach(Object *obj, ResettableChildCallback cb,
155
+ void *opaque, ResetType type)
156
+{
157
+ BusState *bus = BUS(obj);
158
+ BusChild *kid;
159
+
160
+ QTAILQ_FOREACH(kid, &bus->children, sibling) {
161
+ cb(OBJECT(kid->child), opaque, type);
162
+ }
105
+ }
163
+}
106
+}
164
+
107
+
165
static void qbus_realize(BusState *bus, DeviceState *parent, const char *name)
108
DO_VSHRN_ALL(vshrn, DO_SHR)
166
{
109
DO_VSHRN_ALL(vrshrn, do_urshr)
167
const char *typename = object_get_typename(OBJECT(bus));
110
+
168
@@ -XXX,XX +XXX,XX @@ static char *default_bus_get_fw_dev_path(DeviceState *dev)
111
+static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max,
169
return g_strdup(object_get_typename(OBJECT(dev)));
112
+ bool *satp)
170
}
171
172
+/**
173
+ * bus_phases_reset:
174
+ * Transition reset method for buses to allow moving
175
+ * smoothly from legacy reset method to multi-phases
176
+ */
177
+static void bus_phases_reset(BusState *bus)
178
+{
113
+{
179
+ ResettableClass *rc = RESETTABLE_GET_CLASS(bus);
114
+ if (val > max) {
180
+
115
+ *satp = true;
181
+ if (rc->phases.enter) {
116
+ return max;
182
+ rc->phases.enter(OBJECT(bus), RESET_TYPE_COLD);
117
+ } else if (val < min) {
183
+ }
118
+ *satp = true;
184
+ if (rc->phases.hold) {
119
+ return min;
185
+ rc->phases.hold(OBJECT(bus));
120
+ } else {
186
+ }
121
+ return val;
187
+ if (rc->phases.exit) {
188
+ rc->phases.exit(OBJECT(bus));
189
+ }
122
+ }
190
+}
123
+}
191
+
124
+
192
+static void bus_transitional_reset(Object *obj)
125
+/* Saturating narrowing right shifts */
193
+{
126
+#define DO_VSHRN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \
194
+ BusClass *bc = BUS_GET_CLASS(obj);
127
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
195
+
128
+ void *vm, uint32_t shift) \
196
+ /*
129
+ { \
197
+ * This will call either @bus_phases_reset (for multi-phases transitioned
130
+ LTYPE *m = vm; \
198
+ * buses) or a bus's specific method for not-yet transitioned buses.
131
+ TYPE *d = vd; \
199
+ * In both case, it does not reset children.
132
+ uint16_t mask = mve_element_mask(env); \
200
+ */
133
+ bool qc = false; \
201
+ if (bc->reset) {
134
+ unsigned le; \
202
+ bc->reset(BUS(obj));
135
+ for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \
136
+ bool sat = false; \
137
+ TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \
138
+ mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \
139
+ qc |= sat && (mask & 1 << (TOP * ESIZE)); \
140
+ } \
141
+ if (qc) { \
142
+ env->vfp.qc[0] = qc; \
143
+ } \
144
+ mve_advance_vpt(env); \
203
+ }
145
+ }
204
+}
146
+
205
+
147
+#define DO_VSHRN_SAT_UB(BOP, TOP, FN) \
206
+/**
148
+ DO_VSHRN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \
207
+ * bus_get_transitional_reset:
149
+ DO_VSHRN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN)
208
+ * check if the bus's class is ready for multi-phase
150
+
209
+ */
151
+#define DO_VSHRN_SAT_UH(BOP, TOP, FN) \
210
+static ResettableTrFunction bus_get_transitional_reset(Object *obj)
152
+ DO_VSHRN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \
211
+{
153
+ DO_VSHRN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN)
212
+ BusClass *dc = BUS_GET_CLASS(obj);
154
+
213
+ if (dc->reset != bus_phases_reset) {
155
+#define DO_VSHRN_SAT_SB(BOP, TOP, FN) \
214
+ /*
156
+ DO_VSHRN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \
215
+ * dc->reset has been overridden by a subclass,
157
+ DO_VSHRN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN)
216
+ * the bus is not ready for multi phase yet.
158
+
217
+ */
159
+#define DO_VSHRN_SAT_SH(BOP, TOP, FN) \
218
+ return bus_transitional_reset;
160
+ DO_VSHRN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \
219
+ }
161
+ DO_VSHRN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN)
220
+ return NULL;
162
+
221
+}
163
+#define DO_SHRN_SB(N, M, SATP) \
222
+
164
+ do_sat_bhs((int64_t)(N) >> (M), INT8_MIN, INT8_MAX, SATP)
223
static void bus_class_init(ObjectClass *class, void *data)
165
+#define DO_SHRN_UB(N, M, SATP) \
224
{
166
+ do_sat_bhs((uint64_t)(N) >> (M), 0, UINT8_MAX, SATP)
225
BusClass *bc = BUS_CLASS(class);
167
+#define DO_SHRUN_B(N, M, SATP) \
226
+ ResettableClass *rc = RESETTABLE_CLASS(class);
168
+ do_sat_bhs((int64_t)(N) >> (M), 0, UINT8_MAX, SATP)
227
169
+
228
class->unparent = bus_unparent;
170
+#define DO_SHRN_SH(N, M, SATP) \
229
bc->get_fw_dev_path = default_bus_get_fw_dev_path;
171
+ do_sat_bhs((int64_t)(N) >> (M), INT16_MIN, INT16_MAX, SATP)
230
+
172
+#define DO_SHRN_UH(N, M, SATP) \
231
+ rc->get_state = bus_get_reset_state;
173
+ do_sat_bhs((uint64_t)(N) >> (M), 0, UINT16_MAX, SATP)
232
+ rc->child_foreach = bus_reset_child_foreach;
174
+#define DO_SHRUN_H(N, M, SATP) \
233
+
175
+ do_sat_bhs((int64_t)(N) >> (M), 0, UINT16_MAX, SATP)
234
+ /*
176
+
235
+ * @bus_phases_reset is put as the default reset method below, allowing
177
+#define DO_RSHRN_SB(N, M, SATP) \
236
+ * to do the multi-phase transition from base classes to leaf classes. It
178
+ do_sat_bhs(do_srshr(N, M), INT8_MIN, INT8_MAX, SATP)
237
+ * allows a legacy-reset Bus class to extend a multi-phases-reset
179
+#define DO_RSHRN_UB(N, M, SATP) \
238
+ * Bus class for the following reason:
180
+ do_sat_bhs(do_urshr(N, M), 0, UINT8_MAX, SATP)
239
+ * + If a base class B has been moved to multi-phase, then it does not
181
+#define DO_RSHRUN_B(N, M, SATP) \
240
+ * override this default reset method and may have defined phase methods.
182
+ do_sat_bhs(do_srshr(N, M), 0, UINT8_MAX, SATP)
241
+ * + A child class C (extending class B) which uses
183
+
242
+ * bus_class_set_parent_reset() (or similar means) to override the
184
+#define DO_RSHRN_SH(N, M, SATP) \
243
+ * reset method will still work as expected. @bus_phases_reset function
185
+ do_sat_bhs(do_srshr(N, M), INT16_MIN, INT16_MAX, SATP)
244
+ * will be registered as the parent reset method and effectively call
186
+#define DO_RSHRN_UH(N, M, SATP) \
245
+ * parent reset phases.
187
+ do_sat_bhs(do_urshr(N, M), 0, UINT16_MAX, SATP)
246
+ */
188
+#define DO_RSHRUN_H(N, M, SATP) \
247
+ bc->reset = bus_phases_reset;
189
+ do_sat_bhs(do_srshr(N, M), 0, UINT16_MAX, SATP)
248
+ rc->get_transitional_function = bus_get_transitional_reset;
190
+
249
}
191
+DO_VSHRN_SAT_SB(vqshrnb_sb, vqshrnt_sb, DO_SHRN_SB)
250
192
+DO_VSHRN_SAT_SH(vqshrnb_sh, vqshrnt_sh, DO_SHRN_SH)
251
static void qbus_finalize(Object *obj)
193
+DO_VSHRN_SAT_UB(vqshrnb_ub, vqshrnt_ub, DO_SHRN_UB)
252
@@ -XXX,XX +XXX,XX @@ static const TypeInfo bus_info = {
194
+DO_VSHRN_SAT_UH(vqshrnb_uh, vqshrnt_uh, DO_SHRN_UH)
253
.instance_init = qbus_initfn,
195
+DO_VSHRN_SAT_SB(vqshrunbb, vqshruntb, DO_SHRUN_B)
254
.instance_finalize = qbus_finalize,
196
+DO_VSHRN_SAT_SH(vqshrunbh, vqshrunth, DO_SHRUN_H)
255
.class_init = bus_class_init,
197
+
256
+ .interfaces = (InterfaceInfo[]) {
198
+DO_VSHRN_SAT_SB(vqrshrnb_sb, vqrshrnt_sb, DO_RSHRN_SB)
257
+ { TYPE_RESETTABLE_INTERFACE },
199
+DO_VSHRN_SAT_SH(vqrshrnb_sh, vqrshrnt_sh, DO_RSHRN_SH)
258
+ { }
200
+DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB)
259
+ },
201
+DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH)
260
};
202
+DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B)
261
203
+DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H)
262
static void bus_register_types(void)
204
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
263
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
205
index XXXXXXX..XXXXXXX 100644
264
index XXXXXXX..XXXXXXX 100644
206
--- a/target/arm/translate-mve.c
265
--- a/hw/core/qdev.c
207
+++ b/target/arm/translate-mve.c
266
+++ b/hw/core/qdev.c
208
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VSHRNB, vshrnb)
267
@@ -XXX,XX +XXX,XX @@ void qbus_reset_all_fn(void *opaque)
209
DO_2SHIFT_N(VSHRNT, vshrnt)
268
qbus_reset_all(bus);
210
DO_2SHIFT_N(VRSHRNB, vrshrnb)
269
}
211
DO_2SHIFT_N(VRSHRNT, vrshrnt)
270
212
+DO_2SHIFT_N(VQSHRNB_S, vqshrnb_s)
271
+bool device_is_in_reset(DeviceState *dev)
213
+DO_2SHIFT_N(VQSHRNT_S, vqshrnt_s)
272
+{
214
+DO_2SHIFT_N(VQSHRNB_U, vqshrnb_u)
273
+ return resettable_is_in_reset(OBJECT(dev));
215
+DO_2SHIFT_N(VQSHRNT_U, vqshrnt_u)
274
+}
216
+DO_2SHIFT_N(VQSHRUNB, vqshrunb)
275
+
217
+DO_2SHIFT_N(VQSHRUNT, vqshrunt)
276
+static ResettableState *device_get_reset_state(Object *obj)
218
+DO_2SHIFT_N(VQRSHRNB_S, vqrshrnb_s)
277
+{
219
+DO_2SHIFT_N(VQRSHRNT_S, vqrshrnt_s)
278
+ DeviceState *dev = DEVICE(obj);
220
+DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u)
279
+ return &dev->reset;
221
+DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u)
280
+}
222
+DO_2SHIFT_N(VQRSHRUNB, vqrshrunb)
281
+
223
+DO_2SHIFT_N(VQRSHRUNT, vqrshrunt)
282
+static void device_reset_child_foreach(Object *obj, ResettableChildCallback cb,
283
+ void *opaque, ResetType type)
284
+{
285
+ DeviceState *dev = DEVICE(obj);
286
+ BusState *bus;
287
+
288
+ QLIST_FOREACH(bus, &dev->child_bus, sibling) {
289
+ cb(OBJECT(bus), opaque, type);
290
+ }
291
+}
292
+
293
/* can be used as ->unplug() callback for the simple cases */
294
void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
295
DeviceState *dev, Error **errp)
296
@@ -XXX,XX +XXX,XX @@ device_vmstate_if_get_id(VMStateIf *obj)
297
return qdev_get_dev_path(dev);
298
}
299
300
+/**
301
+ * device_phases_reset:
302
+ * Transition reset method for devices to allow moving
303
+ * smoothly from legacy reset method to multi-phases
304
+ */
305
+static void device_phases_reset(DeviceState *dev)
306
+{
307
+ ResettableClass *rc = RESETTABLE_GET_CLASS(dev);
308
+
309
+ if (rc->phases.enter) {
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
{ }
390
}
391
};
392
--
224
--
393
2.20.1
225
2.20.1
394
226
395
227
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Implement the MVE VSHLC insn, which performs a shift left of the
2
entire vector with carry in bits provided from a general purpose
3
register and carry out bits written back to that register.
2
4
3
Replace deprecated qdev_reset_all by resettable_cold_reset_fn for
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
the ipl registration in the main reset handlers.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20210628135835.6690-14-peter.maydell@linaro.org
8
---
9
target/arm/helper-mve.h | 2 ++
10
target/arm/mve.decode | 2 ++
11
target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++++++++++++
12
target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++
13
4 files changed, 72 insertions(+)
5
14
6
This does not impact the behavior for the following reasons:
15
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
7
+ at this point resettable just call the old reset methods of devices
8
and buses in the same order than qdev/qbus.
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
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
hw/s390x/ipl.c | 10 +++++++++-
24
1 file changed, 9 insertions(+), 1 deletion(-)
25
26
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
27
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/s390x/ipl.c
17
--- a/target/arm/helper-mve.h
29
+++ b/hw/s390x/ipl.c
18
+++ b/target/arm/helper-mve.h
30
@@ -XXX,XX +XXX,XX @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
31
*/
20
DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
32
ipl->compat_start_addr = ipl->start_addr;
21
DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
33
ipl->compat_bios_start_addr = ipl->bios_start_addr;
22
DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
34
- qemu_register_reset(qdev_reset_all_fn, dev);
23
+
24
+DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32)
25
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
26
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/mve.decode
28
+++ b/target/arm/mve.decode
29
@@ -XXX,XX +XXX,XX @@ VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b
30
VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h
31
VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b
32
VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h
33
+
34
+VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd
35
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/mve_helper.c
38
+++ b/target/arm/mve_helper.c
39
@@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB)
40
DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH)
41
DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B)
42
DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H)
43
+
44
+uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm,
45
+ uint32_t shift)
46
+{
47
+ uint32_t *d = vd;
48
+ uint16_t mask = mve_element_mask(env);
49
+ unsigned e;
50
+ uint32_t r;
51
+
35
+ /*
52
+ /*
36
+ * Because this Device is not on any bus in the qbus tree (it is
53
+ * For each 32-bit element, we shift it left, bringing in the
37
+ * not a sysbus device and it's not on some other bus like a PCI
54
+ * low 'shift' bits of rdm at the bottom. Bits shifted out at
38
+ * bus) it will not be automatically reset by the 'reset the
55
+ * the top become the new rdm, if the predicate mask permits.
39
+ * sysbus' hook registered by vl.c like most devices. So we must
56
+ * The final rdm value is returned to update the register.
40
+ * manually register a reset hook for it.
57
+ * shift == 0 here means "shift by 32 bits".
41
+ * TODO: there should be a better way to do this.
42
+ */
58
+ */
43
+ qemu_register_reset(resettable_cold_reset_fn, dev);
59
+ if (shift == 0) {
44
error:
60
+ for (e = 0; e < 16 / 4; e++, mask >>= 4) {
45
error_propagate(errp, err);
61
+ r = rdm;
46
}
62
+ if (mask & 1) {
63
+ rdm = d[H4(e)];
64
+ }
65
+ mergemask(&d[H4(e)], r, mask);
66
+ }
67
+ } else {
68
+ uint32_t shiftmask = MAKE_64BIT_MASK(0, shift);
69
+
70
+ for (e = 0; e < 16 / 4; e++, mask >>= 4) {
71
+ r = (d[H4(e)] << shift) | (rdm & shiftmask);
72
+ if (mask & 1) {
73
+ rdm = d[H4(e)] >> (32 - shift);
74
+ }
75
+ mergemask(&d[H4(e)], r, mask);
76
+ }
77
+ }
78
+ mve_advance_vpt(env);
79
+ return rdm;
80
+}
81
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/target/arm/translate-mve.c
84
+++ b/target/arm/translate-mve.c
85
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u)
86
DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u)
87
DO_2SHIFT_N(VQRSHRUNB, vqrshrunb)
88
DO_2SHIFT_N(VQRSHRUNT, vqrshrunt)
89
+
90
+static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a)
91
+{
92
+ /*
93
+ * Whole Vector Left Shift with Carry. The carry is taken
94
+ * from a general purpose register and written back there.
95
+ * An imm of 0 means "shift by 32".
96
+ */
97
+ TCGv_ptr qd;
98
+ TCGv_i32 rdm;
99
+
100
+ if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) {
101
+ return false;
102
+ }
103
+ if (a->rdm == 13 || a->rdm == 15) {
104
+ /* CONSTRAINED UNPREDICTABLE: we UNDEF */
105
+ return false;
106
+ }
107
+ if (!mve_eci_check(s) || !vfp_access_check(s)) {
108
+ return true;
109
+ }
110
+
111
+ qd = mve_qreg_ptr(a->qd);
112
+ rdm = load_reg(s, a->rdm);
113
+ gen_helper_mve_vshlc(rdm, cpu_env, qd, rdm, tcg_constant_i32(a->imm));
114
+ store_reg(s, a->rdm, rdm);
115
+ tcg_temp_free_ptr(qd);
116
+ mve_update_eci(s);
117
+ return true;
118
+}
47
--
119
--
48
2.20.1
120
2.20.1
49
121
50
122
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Implement the MVE VADDLV insn; this is similar to VADDV, except
2
that it accumulates 32-bit elements into a 64-bit accumulator
3
stored in a pair of general-purpose registers.
2
4
3
Adds trace events to reset procedure and when updating the parent
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
bus of a device.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20210628135835.6690-15-peter.maydell@linaro.org
8
---
9
target/arm/helper-mve.h | 3 ++
10
target/arm/mve.decode | 6 +++-
11
target/arm/mve_helper.c | 19 ++++++++++++
12
target/arm/translate-mve.c | 63 ++++++++++++++++++++++++++++++++++++++
13
4 files changed, 90 insertions(+), 1 deletion(-)
5
14
6
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
15
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
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
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/core/qdev.c | 29 ++++++++++++++++++++++++++---
15
hw/core/trace-events | 9 +++++++++
16
2 files changed, 35 insertions(+), 3 deletions(-)
17
18
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/core/qdev.c
17
--- a/target/arm/helper-mve.h
21
+++ b/hw/core/qdev.c
18
+++ b/target/arm/helper-mve.h
22
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32)
23
#include "hw/boards.h"
20
DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32)
24
#include "hw/sysbus.h"
21
DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32)
25
#include "migration/vmstate.h"
22
26
+#include "trace.h"
23
+DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64)
27
24
+DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64)
28
bool qdev_hotplug = false;
25
+
29
static bool qdev_hot_added = false;
26
DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64)
30
@@ -XXX,XX +XXX,XX @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
27
DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64)
31
bool replugging = dev->parent_bus != NULL;
28
DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64)
32
29
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
33
if (replugging) {
30
index XXXXXXX..XXXXXXX 100644
34
- /* Keep a reference to the device while it's not plugged into
31
--- a/target/arm/mve.decode
35
+ trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)),
32
+++ b/target/arm/mve.decode
36
+ dev->parent_bus, object_get_typename(OBJECT(dev->parent_bus)),
33
@@ -XXX,XX +XXX,XX @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar
37
+ OBJECT(bus), object_get_typename(OBJECT(bus)));
34
VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar
38
+ /*
35
39
+ * Keep a reference to the device while it's not plugged into
36
# Vector add across vector
40
* any bus, to avoid it potentially evaporating when it is
37
-VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo
41
* dereffed in bus_remove_child().
38
+{
42
*/
39
+ VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo
43
@@ -XXX,XX +XXX,XX @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
40
+ VADDLV 111 u:1 1110 1 ... 1001 ... 0 1111 00 a:1 0 qm:3 0 \
44
return hotplug_ctrl;
41
+ rdahi=%rdahi rdalo=%rdalo
42
+}
43
44
# Predicate operations
45
%mask_22_13 22:1 13:3
46
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/mve_helper.c
49
+++ b/target/arm/mve_helper.c
50
@@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvub, 1, uint8_t)
51
DO_VADDV(vaddvuh, 2, uint16_t)
52
DO_VADDV(vaddvuw, 4, uint32_t)
53
54
+#define DO_VADDLV(OP, TYPE, LTYPE) \
55
+ uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \
56
+ uint64_t ra) \
57
+ { \
58
+ uint16_t mask = mve_element_mask(env); \
59
+ unsigned e; \
60
+ TYPE *m = vm; \
61
+ for (e = 0; e < 16 / 4; e++, mask >>= 4) { \
62
+ if (mask & 1) { \
63
+ ra += (LTYPE)m[H4(e)]; \
64
+ } \
65
+ } \
66
+ mve_advance_vpt(env); \
67
+ return ra; \
68
+ } \
69
+
70
+DO_VADDLV(vaddlv_s, int32_t, int64_t)
71
+DO_VADDLV(vaddlv_u, uint32_t, uint64_t)
72
+
73
/* Shifts by immediate */
74
#define DO_2SHIFT(OP, ESIZE, TYPE, FN) \
75
void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
76
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/target/arm/translate-mve.c
79
+++ b/target/arm/translate-mve.c
80
@@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a)
81
return true;
45
}
82
}
46
83
47
+static int qdev_prereset(DeviceState *dev, void *opaque)
84
+static bool trans_VADDLV(DisasContext *s, arg_VADDLV *a)
48
+{
85
+{
49
+ trace_qdev_reset_tree(dev, object_get_typename(OBJECT(dev)));
86
+ /*
50
+ return 0;
87
+ * Vector Add Long Across Vector: accumulate the 32-bit
88
+ * elements of the vector into a 64-bit result stored in
89
+ * a pair of general-purpose registers.
90
+ * No need to check Qm's bank: it is only 3 bits in decode.
91
+ */
92
+ TCGv_ptr qm;
93
+ TCGv_i64 rda;
94
+ TCGv_i32 rdalo, rdahi;
95
+
96
+ if (!dc_isar_feature(aa32_mve, s)) {
97
+ return false;
98
+ }
99
+ /*
100
+ * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related
101
+ * encoding; rdalo always has bit 0 clear so cannot be 13 or 15.
102
+ */
103
+ if (a->rdahi == 13 || a->rdahi == 15) {
104
+ return false;
105
+ }
106
+ if (!mve_eci_check(s) || !vfp_access_check(s)) {
107
+ return true;
108
+ }
109
+
110
+ /*
111
+ * This insn is subject to beat-wise execution. Partial execution
112
+ * of an A=0 (no-accumulate) insn which does not execute the first
113
+ * beat must start with the current value of RdaHi:RdaLo, not zero.
114
+ */
115
+ if (a->a || mve_skip_first_beat(s)) {
116
+ /* Accumulate input from RdaHi:RdaLo */
117
+ rda = tcg_temp_new_i64();
118
+ rdalo = load_reg(s, a->rdalo);
119
+ rdahi = load_reg(s, a->rdahi);
120
+ tcg_gen_concat_i32_i64(rda, rdalo, rdahi);
121
+ tcg_temp_free_i32(rdalo);
122
+ tcg_temp_free_i32(rdahi);
123
+ } else {
124
+ /* Accumulate starting at zero */
125
+ rda = tcg_const_i64(0);
126
+ }
127
+
128
+ qm = mve_qreg_ptr(a->qm);
129
+ if (a->u) {
130
+ gen_helper_mve_vaddlv_u(rda, cpu_env, qm, rda);
131
+ } else {
132
+ gen_helper_mve_vaddlv_s(rda, cpu_env, qm, rda);
133
+ }
134
+ tcg_temp_free_ptr(qm);
135
+
136
+ rdalo = tcg_temp_new_i32();
137
+ rdahi = tcg_temp_new_i32();
138
+ tcg_gen_extrl_i64_i32(rdalo, rda);
139
+ tcg_gen_extrh_i64_i32(rdahi, rda);
140
+ store_reg(s, a->rdalo, rdalo);
141
+ store_reg(s, a->rdahi, rdahi);
142
+ tcg_temp_free_i64(rda);
143
+ mve_update_eci(s);
144
+ return true;
51
+}
145
+}
52
+
146
+
53
+static int qbus_prereset(BusState *bus, void *opaque)
147
static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn)
54
+{
55
+ trace_qbus_reset_tree(bus, object_get_typename(OBJECT(bus)));
56
+ return 0;
57
+}
58
+
59
static int qdev_reset_one(DeviceState *dev, void *opaque)
60
{
148
{
61
device_legacy_reset(dev);
149
TCGv_ptr qd;
62
@@ -XXX,XX +XXX,XX @@ static int qdev_reset_one(DeviceState *dev, void *opaque)
63
static int qbus_reset_one(BusState *bus, void *opaque)
64
{
65
BusClass *bc = BUS_GET_CLASS(bus);
66
+ trace_qbus_reset(bus, object_get_typename(OBJECT(bus)));
67
if (bc->reset) {
68
bc->reset(bus);
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)"
116
--
150
--
117
2.20.1
151
2.20.1
118
152
119
153
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
The MVE extension to v8.1M includes some new shift instructions which
2
2
sit entirely within the non-coprocessor part of the encoding space
3
These buffers should be aligned on 16 bytes.
3
and which operate only on general-purpose registers. They take up
4
4
the space which was previously UNPREDICTABLE MOVS and ORRS encodings
5
Ignore invalid RX and TX buffer addresses and log an error. All
5
with Rm == 13 or 15.
6
incoming and outgoing traffic will be dropped because no valid RX or
6
7
TX descriptors will be available.
7
Implement the long shifts by immediate, which perform shifts on a
8
8
pair of general-purpose registers treated as a 64-bit quantity, with
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
an immediate shift count between 1 and 32.
10
Message-id: 20200114103433.30534-4-clg@kaod.org
10
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Awkwardly, because the MOVS and ORRS trans functions do not UNDEF for
12
the Rm==13,15 case, we need to explicitly emit code to UNDEF for the
13
cases where v8.1M now requires that. (Trying to change MOVS and ORRS
14
is too difficult, because the functions that generate the code are
15
shared between a dozen different kinds of arithmetic or logical
16
instruction for all A32, T16 and T32 encodings, and for some insns
17
and some encodings Rm==13,15 are valid.)
18
19
We make the helper functions we need for UQSHLL and SQSHLL take
20
a 32-bit value which the helper casts to int8_t because we'll need
21
these helpers also for the shift-by-register insns, where the shift
22
count might be < 0 or > 32.
23
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
26
Message-id: 20210628135835.6690-16-peter.maydell@linaro.org
13
---
27
---
14
hw/net/ftgmac100.c | 13 +++++++++++++
28
target/arm/helper-mve.h | 3 ++
15
1 file changed, 13 insertions(+)
29
target/arm/translate.h | 1 +
16
30
target/arm/t32.decode | 28 +++++++++++++
17
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
31
target/arm/mve_helper.c | 10 +++++
18
index XXXXXXX..XXXXXXX 100644
32
target/arm/translate.c | 90 +++++++++++++++++++++++++++++++++++++++++
19
--- a/hw/net/ftgmac100.c
33
5 files changed, 132 insertions(+)
20
+++ b/hw/net/ftgmac100.c
34
21
@@ -XXX,XX +XXX,XX @@ typedef struct {
35
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
22
uint32_t des3;
36
index XXXXXXX..XXXXXXX 100644
23
} FTGMAC100Desc;
37
--- a/target/arm/helper-mve.h
24
38
+++ b/target/arm/helper-mve.h
25
+#define FTGMAC100_DESC_ALIGNMENT 16
39
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
40
DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
41
42
DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32)
43
+
44
+DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
45
+DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
46
diff --git a/target/arm/translate.h b/target/arm/translate.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/translate.h
49
+++ b/target/arm/translate.h
50
@@ -XXX,XX +XXX,XX @@ typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr);
51
typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
52
typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
53
typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
54
+typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift);
55
56
/**
57
* arm_tbflags_from_tb:
58
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/t32.decode
61
+++ b/target/arm/t32.decode
62
@@ -XXX,XX +XXX,XX @@
63
&mcr !extern cp opc1 crn crm opc2 rt
64
&mcrr !extern cp opc1 crm rt rt2
65
66
+&mve_shl_ri rdalo rdahi shim
67
+
68
+# rdahi: bits [3:1] from insn, bit 0 is 1
69
+# rdalo: bits [3:1] from insn, bit 0 is 0
70
+%rdahi_9 9:3 !function=times_2_plus_1
71
+%rdalo_17 17:3 !function=times_2
72
+
73
# Data-processing (register)
74
75
%imm5_12_6 12:3 6:2
76
@@ -XXX,XX +XXX,XX @@
77
@S_xrr_shi ....... .... . rn:4 .... .... .. shty:2 rm:4 \
78
&s_rrr_shi shim=%imm5_12_6 s=1 rd=0
79
80
+@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \
81
+ &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9
82
+
83
{
84
TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi
85
AND_rrri 1110101 0000 . .... 0 ... .... .... .... @s_rrr_shi
86
}
87
BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi
88
{
89
+ # The v8.1M MVE shift insns overlap in encoding with MOVS/ORRS
90
+ # and are distinguished by having Rm==13 or 15. Those are UNPREDICTABLE
91
+ # cases for MOVS/ORRS. We decode the MVE cases first, ensuring that
92
+ # they explicitly call unallocated_encoding() for cases that must UNDEF
93
+ # (eg "using a new shift insn on a v8.1M CPU without MVE"), and letting
94
+ # the rest fall through (where ORR_rrri and MOV_rxri will end up
95
+ # handling them as r13 and r15 accesses with the same semantics as A32).
96
+ [
97
+ LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri
98
+ LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri
99
+ ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri
100
+
101
+ UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri
102
+ URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri
103
+ SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri
104
+ SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri
105
+ ]
106
+
107
MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi
108
ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi
109
}
110
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
111
index XXXXXXX..XXXXXXX 100644
112
--- a/target/arm/mve_helper.c
113
+++ b/target/arm/mve_helper.c
114
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm,
115
mve_advance_vpt(env);
116
return rdm;
117
}
118
+
119
+uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift)
120
+{
121
+ return do_sqrshl_d(n, (int8_t)shift, false, &env->QF);
122
+}
123
+
124
+uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift)
125
+{
126
+ return do_uqrshl_d(n, (int8_t)shift, false, &env->QF);
127
+}
128
diff --git a/target/arm/translate.c b/target/arm/translate.c
129
index XXXXXXX..XXXXXXX 100644
130
--- a/target/arm/translate.c
131
+++ b/target/arm/translate.c
132
@@ -XXX,XX +XXX,XX @@ static bool trans_MOVT(DisasContext *s, arg_MOVW *a)
133
return true;
134
}
135
136
+/*
137
+ * v8.1M MVE wide-shifts
138
+ */
139
+static bool do_mve_shl_ri(DisasContext *s, arg_mve_shl_ri *a,
140
+ WideShiftImmFn *fn)
141
+{
142
+ TCGv_i64 rda;
143
+ TCGv_i32 rdalo, rdahi;
144
+
145
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
146
+ /* Decode falls through to ORR/MOV UNPREDICTABLE handling */
147
+ return false;
148
+ }
149
+ if (a->rdahi == 15) {
150
+ /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */
151
+ return false;
152
+ }
153
+ if (!dc_isar_feature(aa32_mve, s) ||
154
+ !arm_dc_feature(s, ARM_FEATURE_M_MAIN) ||
155
+ a->rdahi == 13) {
156
+ /* RdaHi == 13 is UNPREDICTABLE; we choose to UNDEF */
157
+ unallocated_encoding(s);
158
+ return true;
159
+ }
160
+
161
+ if (a->shim == 0) {
162
+ a->shim = 32;
163
+ }
164
+
165
+ rda = tcg_temp_new_i64();
166
+ rdalo = load_reg(s, a->rdalo);
167
+ rdahi = load_reg(s, a->rdahi);
168
+ tcg_gen_concat_i32_i64(rda, rdalo, rdahi);
169
+
170
+ fn(rda, rda, a->shim);
171
+
172
+ tcg_gen_extrl_i64_i32(rdalo, rda);
173
+ tcg_gen_extrh_i64_i32(rdahi, rda);
174
+ store_reg(s, a->rdalo, rdalo);
175
+ store_reg(s, a->rdahi, rdahi);
176
+ tcg_temp_free_i64(rda);
177
+
178
+ return true;
179
+}
180
+
181
+static bool trans_ASRL_ri(DisasContext *s, arg_mve_shl_ri *a)
182
+{
183
+ return do_mve_shl_ri(s, a, tcg_gen_sari_i64);
184
+}
185
+
186
+static bool trans_LSLL_ri(DisasContext *s, arg_mve_shl_ri *a)
187
+{
188
+ return do_mve_shl_ri(s, a, tcg_gen_shli_i64);
189
+}
190
+
191
+static bool trans_LSRL_ri(DisasContext *s, arg_mve_shl_ri *a)
192
+{
193
+ return do_mve_shl_ri(s, a, tcg_gen_shri_i64);
194
+}
195
+
196
+static void gen_mve_sqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift)
197
+{
198
+ gen_helper_mve_sqshll(r, cpu_env, n, tcg_constant_i32(shift));
199
+}
200
+
201
+static bool trans_SQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a)
202
+{
203
+ return do_mve_shl_ri(s, a, gen_mve_sqshll);
204
+}
205
+
206
+static void gen_mve_uqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift)
207
+{
208
+ gen_helper_mve_uqshll(r, cpu_env, n, tcg_constant_i32(shift));
209
+}
210
+
211
+static bool trans_UQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a)
212
+{
213
+ return do_mve_shl_ri(s, a, gen_mve_uqshll);
214
+}
215
+
216
+static bool trans_SRSHRL_ri(DisasContext *s, arg_mve_shl_ri *a)
217
+{
218
+ return do_mve_shl_ri(s, a, gen_srshr64_i64);
219
+}
220
+
221
+static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a)
222
+{
223
+ return do_mve_shl_ri(s, a, gen_urshr64_i64);
224
+}
26
+
225
+
27
/*
226
/*
28
* Specific RTL8211E MII Registers
227
* Multiply and multiply accumulate
29
*/
228
*/
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
+ }
39
+
40
s->rx_ring = value;
41
s->rx_descriptor = s->rx_ring;
42
break;
43
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_write(void *opaque, hwaddr addr,
44
break;
45
46
case FTGMAC100_NPTXR_BADR: /* Transmit buffer address */
47
+ if (!QEMU_IS_ALIGNED(value, FTGMAC100_DESC_ALIGNMENT)) {
48
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad TX buffer alignment 0x%"
49
+ HWADDR_PRIx "\n", __func__, value);
50
+ return;
51
+ }
52
s->tx_ring = value;
53
s->tx_descriptor = s->tx_ring;
54
break;
55
--
229
--
56
2.20.1
230
2.20.1
57
231
58
232
diff view generated by jsdifflib
1
The guest can use the semihosting API to open a handle
1
Implement the MVE long shifts by register, which perform shifts on a
2
corresponding to QEMU's own stdin, stdout, or stderr.
2
pair of general-purpose registers treated as a 64-bit quantity, with
3
When the guest closes this handle, we should not
3
the shift count in another general-purpose register, which might be
4
close the underlying host stdin/stdout/stderr
4
either positive or negative.
5
the way we would do if the handle corresponded to
5
6
a host fd we'd opened on behalf of the guest in SYS_OPEN.
6
Like the long-shifts-by-immediate, these encodings sit in the space
7
that was previously the UNPREDICTABLE MOVS/ORRS with Rm==13,15.
8
Because LSLL_rr and ASRL_rr overlap with both MOV_rxri/ORR_rrri and
9
also with CSEL (as one of the previously-UNPREDICTABLE Rm==13 cases),
10
we have to move the CSEL pattern into the same decodetree group.
7
11
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Message-id: 20210628135835.6690-17-peter.maydell@linaro.org
11
Message-id: 20200124172954.28481-1-peter.maydell@linaro.org
12
---
15
---
13
target/arm/arm-semi.c | 9 +++++++++
16
target/arm/helper-mve.h | 6 +++
14
1 file changed, 9 insertions(+)
17
target/arm/translate.h | 1 +
15
18
target/arm/t32.decode | 16 +++++--
16
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
19
target/arm/mve_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++
17
index XXXXXXX..XXXXXXX 100644
20
target/arm/translate.c | 69 ++++++++++++++++++++++++++++++
18
--- a/target/arm/arm-semi.c
21
5 files changed, 182 insertions(+), 3 deletions(-)
19
+++ b/target/arm/arm-semi.c
22
20
@@ -XXX,XX +XXX,XX @@ static uint32_t host_closefn(ARMCPU *cpu, GuestFD *gf)
23
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
21
{
24
index XXXXXXX..XXXXXXX 100644
22
CPUARMState *env = &cpu->env;
25
--- a/target/arm/helper-mve.h
23
26
+++ b/target/arm/helper-mve.h
24
+ /*
27
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
25
+ * Only close the underlying host fd if it's one we opened on behalf
28
26
+ * of the guest in SYS_OPEN.
29
DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32)
27
+ */
30
28
+ if (gf->hostfd == STDIN_FILENO ||
31
+DEF_HELPER_FLAGS_3(mve_sshrl, TCG_CALL_NO_RWG, i64, env, i64, i32)
29
+ gf->hostfd == STDOUT_FILENO ||
32
+DEF_HELPER_FLAGS_3(mve_ushll, TCG_CALL_NO_RWG, i64, env, i64, i32)
30
+ gf->hostfd == STDERR_FILENO) {
33
DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
34
DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
35
+DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32)
36
+DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
37
+DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32)
38
+DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32)
39
diff --git a/target/arm/translate.h b/target/arm/translate.h
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/translate.h
42
+++ b/target/arm/translate.h
43
@@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
44
typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
45
typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
46
typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift);
47
+typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32);
48
49
/**
50
* arm_tbflags_from_tb:
51
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
52
index XXXXXXX..XXXXXXX 100644
53
--- a/target/arm/t32.decode
54
+++ b/target/arm/t32.decode
55
@@ -XXX,XX +XXX,XX @@
56
&mcrr !extern cp opc1 crm rt rt2
57
58
&mve_shl_ri rdalo rdahi shim
59
+&mve_shl_rr rdalo rdahi rm
60
61
# rdahi: bits [3:1] from insn, bit 0 is 1
62
# rdalo: bits [3:1] from insn, bit 0 is 0
63
@@ -XXX,XX +XXX,XX @@
64
65
@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \
66
&mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9
67
+@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \
68
+ &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9
69
70
{
71
TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi
72
@@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi
73
URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri
74
SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri
75
SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri
76
+
77
+ LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr
78
+ ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr
79
+ UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr
80
+ SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr
81
+ UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr
82
+ SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr
83
]
84
85
MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi
86
ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi
87
+
88
+ # v8.1M CSEL and friends
89
+ CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4
90
}
91
{
92
MVN_rxri 1110101 0011 . 1111 0 ... .... .... .... @s_rxr_shi
93
@@ -XXX,XX +XXX,XX @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... .... @s_rrr_shi
94
}
95
RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi
96
97
-# v8.1M CSEL and friends
98
-CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4
99
-
100
# Data-processing (register-shifted register)
101
102
MOV_rxrr 1111 1010 0 shty:2 s:1 rm:4 1111 rd:4 0000 rs:4 \
103
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
104
index XXXXXXX..XXXXXXX 100644
105
--- a/target/arm/mve_helper.c
106
+++ b/target/arm/mve_helper.c
107
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm,
108
return rdm;
109
}
110
111
+uint64_t HELPER(mve_sshrl)(CPUARMState *env, uint64_t n, uint32_t shift)
112
+{
113
+ return do_sqrshl_d(n, -(int8_t)shift, false, NULL);
114
+}
115
+
116
+uint64_t HELPER(mve_ushll)(CPUARMState *env, uint64_t n, uint32_t shift)
117
+{
118
+ return do_uqrshl_d(n, (int8_t)shift, false, NULL);
119
+}
120
+
121
uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift)
122
{
123
return do_sqrshl_d(n, (int8_t)shift, false, &env->QF);
124
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift)
125
{
126
return do_uqrshl_d(n, (int8_t)shift, false, &env->QF);
127
}
128
+
129
+uint64_t HELPER(mve_sqrshrl)(CPUARMState *env, uint64_t n, uint32_t shift)
130
+{
131
+ return do_sqrshl_d(n, -(int8_t)shift, true, &env->QF);
132
+}
133
+
134
+uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift)
135
+{
136
+ return do_uqrshl_d(n, (int8_t)shift, true, &env->QF);
137
+}
138
+
139
+/* Operate on 64-bit values, but saturate at 48 bits */
140
+static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift,
141
+ bool round, uint32_t *sat)
142
+{
143
+ if (shift <= -48) {
144
+ /* Rounding the sign bit always produces 0. */
145
+ if (round) {
146
+ return 0;
147
+ }
148
+ return src >> 63;
149
+ } else if (shift < 0) {
150
+ if (round) {
151
+ src >>= -shift - 1;
152
+ return (src >> 1) + (src & 1);
153
+ }
154
+ return src >> -shift;
155
+ } else if (shift < 48) {
156
+ int64_t val = src << shift;
157
+ int64_t extval = sextract64(val, 0, 48);
158
+ if (!sat || val == extval) {
159
+ return extval;
160
+ }
161
+ } else if (!sat || src == 0) {
31
+ return 0;
162
+ return 0;
32
+ }
163
+ }
33
return set_swi_errno(env, close(gf->hostfd));
164
+
34
}
165
+ *sat = 1;
35
166
+ return (1ULL << 47) - (src >= 0);
167
+}
168
+
169
+/* Operate on 64-bit values, but saturate at 48 bits */
170
+static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift,
171
+ bool round, uint32_t *sat)
172
+{
173
+ uint64_t val, extval;
174
+
175
+ if (shift <= -(48 + round)) {
176
+ return 0;
177
+ } else if (shift < 0) {
178
+ if (round) {
179
+ val = src >> (-shift - 1);
180
+ val = (val >> 1) + (val & 1);
181
+ } else {
182
+ val = src >> -shift;
183
+ }
184
+ extval = extract64(val, 0, 48);
185
+ if (!sat || val == extval) {
186
+ return extval;
187
+ }
188
+ } else if (shift < 48) {
189
+ uint64_t val = src << shift;
190
+ uint64_t extval = extract64(val, 0, 48);
191
+ if (!sat || val == extval) {
192
+ return extval;
193
+ }
194
+ } else if (!sat || src == 0) {
195
+ return 0;
196
+ }
197
+
198
+ *sat = 1;
199
+ return MAKE_64BIT_MASK(0, 48);
200
+}
201
+
202
+uint64_t HELPER(mve_sqrshrl48)(CPUARMState *env, uint64_t n, uint32_t shift)
203
+{
204
+ return do_sqrshl48_d(n, -(int8_t)shift, true, &env->QF);
205
+}
206
+
207
+uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift)
208
+{
209
+ return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF);
210
+}
211
diff --git a/target/arm/translate.c b/target/arm/translate.c
212
index XXXXXXX..XXXXXXX 100644
213
--- a/target/arm/translate.c
214
+++ b/target/arm/translate.c
215
@@ -XXX,XX +XXX,XX @@ static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a)
216
return do_mve_shl_ri(s, a, gen_urshr64_i64);
217
}
218
219
+static bool do_mve_shl_rr(DisasContext *s, arg_mve_shl_rr *a, WideShiftFn *fn)
220
+{
221
+ TCGv_i64 rda;
222
+ TCGv_i32 rdalo, rdahi;
223
+
224
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
225
+ /* Decode falls through to ORR/MOV UNPREDICTABLE handling */
226
+ return false;
227
+ }
228
+ if (a->rdahi == 15) {
229
+ /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */
230
+ return false;
231
+ }
232
+ if (!dc_isar_feature(aa32_mve, s) ||
233
+ !arm_dc_feature(s, ARM_FEATURE_M_MAIN) ||
234
+ a->rdahi == 13 || a->rm == 13 || a->rm == 15 ||
235
+ a->rm == a->rdahi || a->rm == a->rdalo) {
236
+ /* These rdahi/rdalo/rm cases are UNPREDICTABLE; we choose to UNDEF */
237
+ unallocated_encoding(s);
238
+ return true;
239
+ }
240
+
241
+ rda = tcg_temp_new_i64();
242
+ rdalo = load_reg(s, a->rdalo);
243
+ rdahi = load_reg(s, a->rdahi);
244
+ tcg_gen_concat_i32_i64(rda, rdalo, rdahi);
245
+
246
+ /* The helper takes care of the sign-extension of the low 8 bits of Rm */
247
+ fn(rda, cpu_env, rda, cpu_R[a->rm]);
248
+
249
+ tcg_gen_extrl_i64_i32(rdalo, rda);
250
+ tcg_gen_extrh_i64_i32(rdahi, rda);
251
+ store_reg(s, a->rdalo, rdalo);
252
+ store_reg(s, a->rdahi, rdahi);
253
+ tcg_temp_free_i64(rda);
254
+
255
+ return true;
256
+}
257
+
258
+static bool trans_LSLL_rr(DisasContext *s, arg_mve_shl_rr *a)
259
+{
260
+ return do_mve_shl_rr(s, a, gen_helper_mve_ushll);
261
+}
262
+
263
+static bool trans_ASRL_rr(DisasContext *s, arg_mve_shl_rr *a)
264
+{
265
+ return do_mve_shl_rr(s, a, gen_helper_mve_sshrl);
266
+}
267
+
268
+static bool trans_UQRSHLL64_rr(DisasContext *s, arg_mve_shl_rr *a)
269
+{
270
+ return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll);
271
+}
272
+
273
+static bool trans_SQRSHRL64_rr(DisasContext *s, arg_mve_shl_rr *a)
274
+{
275
+ return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl);
276
+}
277
+
278
+static bool trans_UQRSHLL48_rr(DisasContext *s, arg_mve_shl_rr *a)
279
+{
280
+ return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll48);
281
+}
282
+
283
+static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a)
284
+{
285
+ return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48);
286
+}
287
+
288
/*
289
* Multiply and multiply accumulate
290
*/
36
--
291
--
37
2.20.1
292
2.20.1
38
293
39
294
diff view generated by jsdifflib
1
From: Joel Stanley <joel@jms.id.au>
1
Implement the MVE shifts by immediate, which perform shifts
2
2
on a single general-purpose register.
3
Following the pattern of the work recently done with the ASPEED GPIO
3
4
model, this adds support for inspecting and modifying the PCA9552 LEDs
4
These patterns overlap with the long-shift-by-immediates,
5
from the monitor.
5
so we have to rearrange the grouping a little here.
6
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>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210628135835.6690-18-peter.maydell@linaro.org
20
---
10
---
21
hw/misc/pca9552.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++
11
target/arm/helper-mve.h | 3 ++
22
1 file changed, 90 insertions(+)
12
target/arm/translate.h | 1 +
23
13
target/arm/t32.decode | 31 ++++++++++++++-----
24
diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c
14
target/arm/mve_helper.c | 10 ++++++
25
index XXXXXXX..XXXXXXX 100644
15
target/arm/translate.c | 68 +++++++++++++++++++++++++++++++++++++++--
26
--- a/hw/misc/pca9552.c
16
5 files changed, 104 insertions(+), 9 deletions(-)
27
+++ b/hw/misc/pca9552.c
17
18
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper-mve.h
21
+++ b/target/arm/helper-mve.h
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32)
23
DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
24
DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32)
25
DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32)
26
+
27
+DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
28
+DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
29
diff --git a/target/arm/translate.h b/target/arm/translate.h
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/translate.h
32
+++ b/target/arm/translate.h
33
@@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
34
typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
35
typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift);
36
typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32);
37
+typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift);
38
39
/**
40
* arm_tbflags_from_tb:
41
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
42
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/t32.decode
44
+++ b/target/arm/t32.decode
28
@@ -XXX,XX +XXX,XX @@
45
@@ -XXX,XX +XXX,XX @@
29
#include "hw/misc/pca9552.h"
46
30
#include "hw/misc/pca9552_regs.h"
47
&mve_shl_ri rdalo rdahi shim
31
#include "migration/vmstate.h"
48
&mve_shl_rr rdalo rdahi rm
32
+#include "qapi/error.h"
49
+&mve_sh_ri rda shim
33
+#include "qapi/visitor.h"
50
34
51
# rdahi: bits [3:1] from insn, bit 0 is 1
35
#define PCA9552_LED_ON 0x0
52
# rdalo: bits [3:1] from insn, bit 0 is 0
36
#define PCA9552_LED_OFF 0x1
53
@@ -XXX,XX +XXX,XX @@
37
#define PCA9552_LED_PWM0 0x2
54
&mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9
38
#define PCA9552_LED_PWM1 0x3
55
@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \
39
56
&mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9
40
+static const char *led_state[] = {"on", "off", "pwm0", "pwm1"};
57
+@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \
41
+
58
+ &mve_sh_ri shim=%imm5_12_6
42
static uint8_t pca9552_pin_get_config(PCA9552State *s, int pin)
59
43
{
60
{
44
uint8_t reg = PCA9552_LS0 + (pin / 4);
61
TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi
45
@@ -XXX,XX +XXX,XX @@ static int pca9552_event(I2CSlave *i2c, enum i2c_event event)
62
@@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi
46
return 0;
63
# the rest fall through (where ORR_rrri and MOV_rxri will end up
64
# handling them as r13 and r15 accesses with the same semantics as A32).
65
[
66
- LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri
67
- LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri
68
- ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri
69
+ {
70
+ UQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 00 1111 @mve_sh_ri
71
+ LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri
72
+ UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri
73
+ }
74
75
- UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri
76
- URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri
77
- SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri
78
- SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri
79
+ {
80
+ URSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 01 1111 @mve_sh_ri
81
+ LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri
82
+ URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri
83
+ }
84
+
85
+ {
86
+ SRSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 10 1111 @mve_sh_ri
87
+ ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri
88
+ SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri
89
+ }
90
+
91
+ {
92
+ SQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 11 1111 @mve_sh_ri
93
+ SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri
94
+ }
95
96
LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr
97
ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr
98
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
99
index XXXXXXX..XXXXXXX 100644
100
--- a/target/arm/mve_helper.c
101
+++ b/target/arm/mve_helper.c
102
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift)
103
{
104
return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF);
47
}
105
}
48
106
+
49
+static void pca9552_get_led(Object *obj, Visitor *v, const char *name,
107
+uint32_t HELPER(mve_uqshl)(CPUARMState *env, uint32_t n, uint32_t shift)
50
+ void *opaque, Error **errp)
108
+{
51
+{
109
+ return do_uqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF);
52
+ PCA9552State *s = PCA9552(obj);
110
+}
53
+ int led, rc, reg;
111
+
54
+ uint8_t state;
112
+uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift)
55
+
113
+{
56
+ rc = sscanf(name, "led%2d", &led);
114
+ return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF);
57
+ if (rc != 1) {
115
+}
58
+ error_setg(errp, "%s: error reading %s", __func__, name);
116
diff --git a/target/arm/translate.c b/target/arm/translate.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/target/arm/translate.c
119
+++ b/target/arm/translate.c
120
@@ -XXX,XX +XXX,XX @@ static void gen_srshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh)
121
122
static void gen_srshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh)
123
{
124
- TCGv_i32 t = tcg_temp_new_i32();
125
+ TCGv_i32 t;
126
127
+ /* Handle shift by the input size for the benefit of trans_SRSHR_ri */
128
+ if (sh == 32) {
129
+ tcg_gen_movi_i32(d, 0);
59
+ return;
130
+ return;
60
+ }
131
+ }
61
+ if (led < 0 || led > s->nr_leds) {
132
+ t = tcg_temp_new_i32();
62
+ error_setg(errp, "%s invalid led %s", __func__, name);
133
tcg_gen_extract_i32(t, a, sh - 1, 1);
134
tcg_gen_sari_i32(d, a, sh);
135
tcg_gen_add_i32(d, d, t);
136
@@ -XXX,XX +XXX,XX @@ static void gen_urshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh)
137
138
static void gen_urshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh)
139
{
140
- TCGv_i32 t = tcg_temp_new_i32();
141
+ TCGv_i32 t;
142
143
+ /* Handle shift by the input size for the benefit of trans_URSHR_ri */
144
+ if (sh == 32) {
145
+ tcg_gen_extract_i32(d, a, sh - 1, 1);
63
+ return;
146
+ return;
64
+ }
147
+ }
65
+ /*
148
+ t = tcg_temp_new_i32();
66
+ * Get the LSx register as the qom interface should expose the device
149
tcg_gen_extract_i32(t, a, sh - 1, 1);
67
+ * state, not the modeled 'input line' behaviour which would come from
150
tcg_gen_shri_i32(d, a, sh);
68
+ * reading the INPUTx reg
151
tcg_gen_add_i32(d, d, t);
69
+ */
152
@@ -XXX,XX +XXX,XX @@ static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a)
70
+ reg = PCA9552_LS0 + led / 4;
153
return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48);
71
+ state = (pca9552_read(s, reg) >> (led % 8)) & 0x3;
72
+ visit_type_str(v, name, (char **)&led_state[state], errp);
73
+}
74
+
75
+/*
76
+ * Return an LED selector register value based on an existing one, with
77
+ * the appropriate 2-bit state value set for the given LED number (0-3).
78
+ */
79
+static inline uint8_t pca955x_ledsel(uint8_t oldval, int led_num, int state)
80
+{
81
+ return (oldval & (~(0x3 << (led_num << 1)))) |
82
+ ((state & 0x3) << (led_num << 1));
83
+}
84
+
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);
106
+ return;
107
+ }
108
+
109
+ for (state = 0; state < ARRAY_SIZE(led_state); state++) {
110
+ if (!strcmp(state_str, led_state[state])) {
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;
117
+ }
118
+
119
+ reg = PCA9552_LS0 + led / 4;
120
+ val = pca9552_read(s, reg);
121
+ val = pca955x_ledsel(val, led % 4, state);
122
+ pca9552_write(s, reg, val);
123
+}
124
+
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)
130
{
131
PCA9552State *s = PCA9552(obj);
132
+ int led;
133
134
/* If support for the other PCA955X devices are implemented, these
135
* constant values might be part of class structure describing the
136
@@ -XXX,XX +XXX,XX @@ static void pca9552_initfn(Object *obj)
137
*/
138
s->max_reg = PCA9552_LS3;
139
s->nr_leds = 16;
140
+
141
+ for (led = 0; led < s->nr_leds; led++) {
142
+ char *name;
143
+
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
}
154
}
150
155
151
static void pca9552_class_init(ObjectClass *klass, void *data)
156
+static bool do_mve_sh_ri(DisasContext *s, arg_mve_sh_ri *a, ShiftImmFn *fn)
157
+{
158
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
159
+ /* Decode falls through to ORR/MOV UNPREDICTABLE handling */
160
+ return false;
161
+ }
162
+ if (!dc_isar_feature(aa32_mve, s) ||
163
+ !arm_dc_feature(s, ARM_FEATURE_M_MAIN) ||
164
+ a->rda == 13 || a->rda == 15) {
165
+ /* These rda cases are UNPREDICTABLE; we choose to UNDEF */
166
+ unallocated_encoding(s);
167
+ return true;
168
+ }
169
+
170
+ if (a->shim == 0) {
171
+ a->shim = 32;
172
+ }
173
+ fn(cpu_R[a->rda], cpu_R[a->rda], a->shim);
174
+
175
+ return true;
176
+}
177
+
178
+static bool trans_URSHR_ri(DisasContext *s, arg_mve_sh_ri *a)
179
+{
180
+ return do_mve_sh_ri(s, a, gen_urshr32_i32);
181
+}
182
+
183
+static bool trans_SRSHR_ri(DisasContext *s, arg_mve_sh_ri *a)
184
+{
185
+ return do_mve_sh_ri(s, a, gen_srshr32_i32);
186
+}
187
+
188
+static void gen_mve_sqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift)
189
+{
190
+ gen_helper_mve_sqshl(r, cpu_env, n, tcg_constant_i32(shift));
191
+}
192
+
193
+static bool trans_SQSHL_ri(DisasContext *s, arg_mve_sh_ri *a)
194
+{
195
+ return do_mve_sh_ri(s, a, gen_mve_sqshl);
196
+}
197
+
198
+static void gen_mve_uqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift)
199
+{
200
+ gen_helper_mve_uqshl(r, cpu_env, n, tcg_constant_i32(shift));
201
+}
202
+
203
+static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a)
204
+{
205
+ return do_mve_sh_ri(s, a, gen_mve_uqshl);
206
+}
207
+
208
/*
209
* Multiply and multiply accumulate
210
*/
152
--
211
--
153
2.20.1
212
2.20.1
154
213
155
214
diff view generated by jsdifflib
Deleted patch
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
1
3
In qdev_set_parent_bus(), when changing the parent bus of a
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.
8
9
The addition is a no-op if:
10
1. the device being parented is not realized.
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
71
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
72
---
73
hw/core/qdev.c | 16 +++++++++++-----
74
1 file changed, 11 insertions(+), 5 deletions(-)
75
76
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/hw/core/qdev.c
79
+++ b/hw/core/qdev.c
80
@@ -XXX,XX +XXX,XX @@ static void bus_add_child(BusState *bus, DeviceState *child)
81
82
void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
83
{
84
- bool replugging = dev->parent_bus != NULL;
85
+ BusState *old_parent_bus = dev->parent_bus;
86
87
- if (replugging) {
88
+ if (old_parent_bus) {
89
trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)),
90
- dev->parent_bus, object_get_typename(OBJECT(dev->parent_bus)),
91
+ old_parent_bus, object_get_typename(OBJECT(old_parent_bus)),
92
OBJECT(bus), object_get_typename(OBJECT(bus)));
93
/*
94
* Keep a reference to the device while it's not plugged into
95
* any bus, to avoid it potentially evaporating when it is
96
* dereffed in bus_remove_child().
97
+ * Also keep the ref of the parent bus until the end, so that
98
+ * we can safely call resettable_change_parent() below.
99
*/
100
object_ref(OBJECT(dev));
101
bus_remove_child(dev->parent_bus, dev);
102
- object_unref(OBJECT(dev->parent_bus));
103
}
104
dev->parent_bus = bus;
105
object_ref(OBJECT(bus));
106
bus_add_child(bus, dev);
107
- if (replugging) {
108
+ if (dev->realized) {
109
+ resettable_change_parent(OBJECT(dev), OBJECT(bus),
110
+ OBJECT(old_parent_bus));
111
+ }
112
+ if (old_parent_bus) {
113
+ object_unref(OBJECT(old_parent_bus));
114
object_unref(OBJECT(dev));
115
}
116
}
117
--
118
2.20.1
119
120
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Implement the MVE shifts by register, which perform
2
shifts on a single general-purpose register.
2
3
3
Deprecate device_legacy_reset(), qdev_reset_all() and
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
qbus_reset_all() to be replaced by new functions
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
device_cold_reset() and bus_cold_reset() which uses resettable API.
6
Message-id: 20210628135835.6690-19-peter.maydell@linaro.org
7
---
8
target/arm/helper-mve.h | 2 ++
9
target/arm/translate.h | 1 +
10
target/arm/t32.decode | 18 ++++++++++++++----
11
target/arm/mve_helper.c | 10 ++++++++++
12
target/arm/translate.c | 30 ++++++++++++++++++++++++++++++
13
5 files changed, 57 insertions(+), 4 deletions(-)
6
14
7
Also introduce resettable_cold_reset_fn() which may be used as a
15
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
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
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
22
include/hw/qdev-core.h | 27 +++++++++++++++++++++++++++
23
include/hw/resettable.h | 9 +++++++++
24
hw/core/bus.c | 5 +++++
25
hw/core/qdev.c | 5 +++++
26
hw/core/resettable.c | 5 +++++
27
5 files changed, 51 insertions(+)
28
29
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
30
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
31
--- a/include/hw/qdev-core.h
17
--- a/target/arm/helper-mve.h
32
+++ b/include/hw/qdev-core.h
18
+++ b/target/arm/helper-mve.h
33
@@ -XXX,XX +XXX,XX @@ int qdev_walk_children(DeviceState *dev,
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32)
34
qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
20
35
void *opaque);
21
DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
36
22
DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
37
+/**
23
+DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
38
+ * @qdev_reset_all:
24
+DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32)
39
+ * Reset @dev. See @qbus_reset_all() for more details.
25
diff --git a/target/arm/translate.h b/target/arm/translate.h
40
+ *
26
index XXXXXXX..XXXXXXX 100644
41
+ * Note: This function is deprecated and will be removed when it becomes unused.
27
--- a/target/arm/translate.h
42
+ * Please use device_cold_reset() now.
28
+++ b/target/arm/translate.h
43
+ */
29
@@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
44
void qdev_reset_all(DeviceState *dev);
30
typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift);
45
void qdev_reset_all_fn(void *opaque);
31
typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32);
46
32
typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift);
47
@@ -XXX,XX +XXX,XX @@ void qdev_reset_all_fn(void *opaque);
33
+typedef void ShiftFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32);
48
* hard reset means that qbus_reset_all will reset all state of the device.
34
49
* For PCI devices, for example, this will include the base address registers
35
/**
50
* or configuration space.
36
* arm_tbflags_from_tb:
51
+ *
37
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
52
+ * Note: This function is deprecated and will be removed when it becomes unused.
38
index XXXXXXX..XXXXXXX 100644
53
+ * Please use bus_cold_reset() now.
39
--- a/target/arm/t32.decode
54
*/
40
+++ b/target/arm/t32.decode
55
void qbus_reset_all(BusState *bus);
41
@@ -XXX,XX +XXX,XX @@
56
void qbus_reset_all_fn(void *opaque);
42
&mve_shl_ri rdalo rdahi shim
57
43
&mve_shl_rr rdalo rdahi rm
58
+/**
44
&mve_sh_ri rda shim
59
+ * device_cold_reset:
45
+&mve_sh_rr rda rm
60
+ * Reset device @dev and perform a recursive processing using the resettable
46
61
+ * interface. It triggers a RESET_TYPE_COLD.
47
# rdahi: bits [3:1] from insn, bit 0 is 1
62
+ */
48
# rdalo: bits [3:1] from insn, bit 0 is 0
63
+void device_cold_reset(DeviceState *dev);
49
@@ -XXX,XX +XXX,XX @@
50
&mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9
51
@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \
52
&mve_sh_ri shim=%imm5_12_6
53
+@mve_sh_rr ....... .... . rda:4 rm:4 .... .... .... &mve_sh_rr
54
55
{
56
TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi
57
@@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi
58
SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri
59
}
60
61
- LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr
62
- ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr
63
- UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr
64
- SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr
65
+ {
66
+ UQRSHL_rr 1110101 0010 1 .... .... 1111 0000 1101 @mve_sh_rr
67
+ LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr
68
+ UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr
69
+ }
64
+
70
+
65
+/**
71
+ {
66
+ * bus_cold_reset:
72
+ SQRSHR_rr 1110101 0010 1 .... .... 1111 0010 1101 @mve_sh_rr
67
+ *
73
+ ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr
68
+ * Reset bus @bus and perform a recursive processing using the resettable
74
+ SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr
69
+ * interface. It triggers a RESET_TYPE_COLD.
75
+ }
70
+ */
71
+void bus_cold_reset(BusState *bus);
72
+
76
+
73
/**
77
UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr
74
* device_is_in_reset:
78
SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr
75
* Return true if the device @dev is currently being reset.
79
]
76
@@ -XXX,XX +XXX,XX @@ void qdev_machine_init(void);
80
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
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
86
index XXXXXXX..XXXXXXX 100644
81
index XXXXXXX..XXXXXXX 100644
87
--- a/include/hw/resettable.h
82
--- a/target/arm/mve_helper.c
88
+++ b/include/hw/resettable.h
83
+++ b/target/arm/mve_helper.c
89
@@ -XXX,XX +XXX,XX @@ bool resettable_is_in_reset(Object *obj);
84
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift)
90
*/
85
{
91
void resettable_change_parent(Object *obj, Object *newp, Object *oldp);
86
return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF);
92
87
}
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);
101
+
88
+
102
/**
89
+uint32_t HELPER(mve_uqrshl)(CPUARMState *env, uint32_t n, uint32_t shift)
103
* resettable_class_set_parent_phases:
104
*
105
diff --git a/hw/core/bus.c b/hw/core/bus.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/hw/core/bus.c
108
+++ b/hw/core/bus.c
109
@@ -XXX,XX +XXX,XX @@ int qbus_walk_children(BusState *bus,
110
return 0;
111
}
112
113
+void bus_cold_reset(BusState *bus)
114
+{
90
+{
115
+ resettable_reset(OBJECT(bus), RESET_TYPE_COLD);
91
+ return do_uqrshl_bhs(n, (int8_t)shift, 32, true, &env->QF);
116
+}
92
+}
117
+
93
+
118
bool bus_is_in_reset(BusState *bus)
94
+uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift)
119
{
95
+{
120
return resettable_is_in_reset(OBJECT(bus));
96
+ return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF);
121
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
97
+}
98
diff --git a/target/arm/translate.c b/target/arm/translate.c
122
index XXXXXXX..XXXXXXX 100644
99
index XXXXXXX..XXXXXXX 100644
123
--- a/hw/core/qdev.c
100
--- a/target/arm/translate.c
124
+++ b/hw/core/qdev.c
101
+++ b/target/arm/translate.c
125
@@ -XXX,XX +XXX,XX @@ void qbus_reset_all_fn(void *opaque)
102
@@ -XXX,XX +XXX,XX @@ static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a)
126
qbus_reset_all(bus);
103
return do_mve_sh_ri(s, a, gen_mve_uqshl);
127
}
104
}
128
105
129
+void device_cold_reset(DeviceState *dev)
106
+static bool do_mve_sh_rr(DisasContext *s, arg_mve_sh_rr *a, ShiftFn *fn)
130
+{
107
+{
131
+ resettable_reset(OBJECT(dev), RESET_TYPE_COLD);
108
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
109
+ /* Decode falls through to ORR/MOV UNPREDICTABLE handling */
110
+ return false;
111
+ }
112
+ if (!dc_isar_feature(aa32_mve, s) ||
113
+ !arm_dc_feature(s, ARM_FEATURE_M_MAIN) ||
114
+ a->rda == 13 || a->rda == 15 || a->rm == 13 || a->rm == 15 ||
115
+ a->rm == a->rda) {
116
+ /* These rda/rm cases are UNPREDICTABLE; we choose to UNDEF */
117
+ unallocated_encoding(s);
118
+ return true;
119
+ }
120
+
121
+ /* The helper takes care of the sign-extension of the low 8 bits of Rm */
122
+ fn(cpu_R[a->rda], cpu_env, cpu_R[a->rda], cpu_R[a->rm]);
123
+ return true;
132
+}
124
+}
133
+
125
+
134
bool device_is_in_reset(DeviceState *dev)
126
+static bool trans_SQRSHR_rr(DisasContext *s, arg_mve_sh_rr *a)
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)
142
}
143
}
144
145
+void resettable_cold_reset_fn(void *opaque)
146
+{
127
+{
147
+ resettable_reset((Object *) opaque, RESET_TYPE_COLD);
128
+ return do_mve_sh_rr(s, a, gen_helper_mve_sqrshr);
148
+}
129
+}
149
+
130
+
150
void resettable_class_set_parent_phases(ResettableClass *rc,
131
+static bool trans_UQRSHL_rr(DisasContext *s, arg_mve_sh_rr *a)
151
ResettableEnterPhase enter,
132
+{
152
ResettableHoldPhase hold,
133
+ return do_mve_sh_rr(s, a, gen_helper_mve_uqrshl);
134
+}
135
+
136
/*
137
* Multiply and multiply accumulate
138
*/
153
--
139
--
154
2.20.1
140
2.20.1
155
141
156
142
diff view generated by jsdifflib
Deleted patch
1
From: Damien Hedde <damien.hedde@greensocs.com>
2
1
3
Replace deprecated qbus_reset_all by resettable_cold_reset_fn for
4
the sysbus reset registration.
5
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
79
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
80
---
81
vl.c | 10 +++++++++-
82
1 file changed, 9 insertions(+), 1 deletion(-)
83
84
diff --git a/vl.c b/vl.c
85
index XXXXXXX..XXXXXXX 100644
86
--- a/vl.c
87
+++ b/vl.c
88
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
89
90
/* TODO: once all bus devices are qdevified, this should be done
91
* when bus is created by qdev.c */
92
- qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
93
+ /*
94
+ * TODO: If we had a main 'reset container' that the whole system
95
+ * lived in, we could reset that using the multi-phase reset
96
+ * APIs. For the moment, we just reset the sysbus, which will cause
97
+ * all devices hanging off it (and all their child buses, recursively)
98
+ * to be reset. Note that this will *not* reset any Device objects
99
+ * which are not attached to some part of the qbus tree!
100
+ */
101
+ qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default());
102
qemu_run_machine_init_done_notifiers();
103
104
if (rom_check_and_register_reset() != 0) {
105
--
106
2.20.1
107
108
diff view generated by jsdifflib