1
Hi; here's the first arm pullreq for the 8.2 cycle. These are
1
Nothing exciting here: two minor bug fixes, some fixes for
2
pretty much all bug fixes (mostly for the experimental FEAT_RME),
2
running on a 32-bit host, and a docs tweak.
3
rather than any major features.
4
3
4
thanks
5
-- PMM
5
-- PMM
6
6
7
The following changes since commit b0dd9a7d6dd15a6898e9c585b521e6bec79b25aa:
7
The following changes since commit 6af9d12c88b9720f209912f6e4b01fefe5906d59:
8
8
9
Open 8.2 development tree (2023-08-22 07:14:07 -0700)
9
Merge tag 'migration-20240331-pull-request' of https://gitlab.com/peterx/qemu into staging (2024-04-01 13:12:40 +0100)
10
10
11
are available in the Git repository at:
11
are available in the Git repository at:
12
12
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230824
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240402
14
14
15
for you to fetch changes up to cd1e4db73646006039f25879af3bff55b2295ff3:
15
for you to fetch changes up to 393770d7a02135e7468018f52da610712f151ec0:
16
16
17
target/arm: Fix 64-bit SSRA (2023-08-22 17:31:14 +0100)
17
raspi4b: Reduce RAM to 1Gb on 32-bit hosts (2024-04-02 10:13:48 +0100)
18
18
19
----------------------------------------------------------------
19
----------------------------------------------------------------
20
target-arm queue:
20
target-arm queue:
21
* hw/gpio/nrf51: implement DETECT signal
21
* take HSTR traps of cp15 accesses to EL2, not EL1
22
* accel/kvm: Specify default IPA size for arm64
22
* docs: sbsa: update specs, add dt note
23
* ptw: refactor, fix some FEAT_RME bugs
23
* hw/intc/arm_gicv3: ICC_HPPIR* return SPURIOUS if int group is disabled
24
* target/arm: Adjust PAR_EL1.SH for Device and Normal-NC memory types
24
* tests/qtest: Fix STM32L4x5 GPIO test on 32-bit
25
* target/arm/helper: Implement CNTHCTL_EL2.CNT[VP]MASK
25
* raspi4b: Reduce RAM to 1Gb on 32-bit hosts
26
* Fix SME ST1Q
27
* Fix 64-bit SSRA
28
26
29
----------------------------------------------------------------
27
----------------------------------------------------------------
30
Akihiko Odaki (6):
28
Cédric Le Goater (2):
31
kvm: Introduce kvm_arch_get_default_type hook
29
tests/qtest: Fix STM32L4x5 GPIO test on 32-bit
32
accel/kvm: Specify default IPA size for arm64
30
raspi4b: Reduce RAM to 1Gb on 32-bit hosts
33
mips: Report an error when KVM_VM_MIPS_VZ is unavailable
34
accel/kvm: Use negative KVM type for error propagation
35
accel/kvm: Free as when an error occurred
36
accel/kvm: Make kvm_dirty_ring_reaper_init() void
37
31
38
Chris Laplante (6):
32
Marcin Juszkiewicz (1):
39
hw/gpio/nrf51: implement DETECT signal
33
docs: sbsa: update specs, add dt note
40
qtest: factor out qtest_install_gpio_out_intercept
41
qtest: implement named interception of out-GPIO
42
qtest: bail from irq_intercept_in if name is specified
43
qtest: irq_intercept_[out/in]: return FAIL if no intercepts are installed
44
qtest: microbit-test: add tests for nRF51 DETECT
45
34
46
Jean-Philippe Brucker (6):
35
Peter Maydell (2):
47
target/arm/ptw: Load stage-2 tables from realm physical space
36
target/arm: take HSTR traps of cp15 accesses to EL2, not EL1
48
target/arm/helper: Fix tlbmask and tlbbits for TLBI VAE2*
37
hw/intc/arm_gicv3: ICC_HPPIR* return SPURIOUS if int group is disabled
49
target/arm: Skip granule protection checks for AT instructions
50
target/arm: Pass security space rather than flag for AT instructions
51
target/arm/helper: Check SCR_EL3.{NSE, NS} encoding for AT instructions
52
target/arm/helper: Implement CNTHCTL_EL2.CNT[VP]MASK
53
38
54
Peter Maydell (15):
39
docs/system/arm/sbsa.rst | 35 +++++++++++++++++------
55
target/arm/ptw: Don't set fi->s1ptw for UnsuppAtomicUpdate fault
40
hw/arm/raspi4b.c | 4 +++
56
target/arm/ptw: Don't report GPC faults on stage 1 ptw as stage2 faults
41
hw/intc/arm_gicv3_cpuif.c | 4 +--
57
target/arm/ptw: Set s1ns bit in fault info more consistently
42
target/arm/tcg/translate.c | 2 +-
58
target/arm/ptw: Pass ptw into get_phys_addr_pmsa*() and get_phys_addr_disabled()
43
tests/qtest/stm32l4x5_gpio-test.c | 59 +++++++++++++++++++++++----------------
59
target/arm/ptw: Pass ARMSecurityState to regime_translation_disabled()
44
5 files changed, 68 insertions(+), 36 deletions(-)
60
target/arm/ptw: Pass an ARMSecuritySpace to arm_hcr_el2_eff_secstate()
61
target/arm: Pass an ARMSecuritySpace to arm_is_el2_enabled_secstate()
62
target/arm/ptw: Only fold in NSTable bit effects in Secure state
63
target/arm/ptw: Remove last uses of ptw->in_secure
64
target/arm/ptw: Remove S1Translate::in_secure
65
target/arm/ptw: Drop S1Translate::out_secure
66
target/arm/ptw: Set attributes correctly for MMU disabled data accesses
67
target/arm/ptw: Check for block descriptors at invalid levels
68
target/arm/ptw: Report stage 2 fault level for stage 2 faults on stage 1 ptw
69
target/arm: Adjust PAR_EL1.SH for Device and Normal-NC memory types
70
45
71
Richard Henderson (2):
72
target/arm: Fix SME ST1Q
73
target/arm: Fix 64-bit SSRA
74
75
include/hw/gpio/nrf51_gpio.h | 1 +
76
include/sysemu/kvm.h | 2 +
77
target/arm/cpu.h | 19 ++--
78
target/arm/internals.h | 25 ++---
79
target/mips/kvm_mips.h | 9 --
80
tests/qtest/libqtest.h | 11 +++
81
accel/kvm/kvm-all.c | 19 ++--
82
hw/arm/virt.c | 2 +-
83
hw/gpio/nrf51_gpio.c | 14 ++-
84
hw/mips/loongson3_virt.c | 2 -
85
hw/ppc/spapr.c | 2 +-
86
softmmu/qtest.c | 52 +++++++---
87
target/arm/cpu.c | 6 ++
88
target/arm/helper.c | 207 ++++++++++++++++++++++++++++----------
89
target/arm/kvm.c | 7 ++
90
target/arm/ptw.c | 231 ++++++++++++++++++++++++++-----------------
91
target/arm/tcg/sme_helper.c | 2 +-
92
target/arm/tcg/translate.c | 2 +-
93
target/i386/kvm/kvm.c | 5 +
94
target/mips/kvm.c | 3 +-
95
target/ppc/kvm.c | 5 +
96
target/riscv/kvm.c | 5 +
97
target/s390x/kvm/kvm.c | 5 +
98
tests/qtest/libqtest.c | 6 ++
99
tests/qtest/microbit-test.c | 44 +++++++++
100
target/arm/trace-events | 7 +-
101
26 files changed, 494 insertions(+), 199 deletions(-)
diff view generated by jsdifflib
Deleted patch
1
From: Chris Laplante <chris@laplante.io>
2
1
3
Implement nRF51 DETECT signal in the GPIO peripheral.
4
5
The reference manual makes mention of a per-pin DETECT signal, but these
6
are not exposed to the user. See https://devzone.nordicsemi.com/f/nordic-q-a/39858/gpio-per-pin-detect-signal-available
7
for more information. Currently, I don't see a reason to model these.
8
9
Signed-off-by: Chris Laplante <chris@laplante.io>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20230728160324.1159090-2-chris@laplante.io
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
include/hw/gpio/nrf51_gpio.h | 1 +
15
hw/gpio/nrf51_gpio.c | 14 +++++++++++++-
16
2 files changed, 14 insertions(+), 1 deletion(-)
17
18
diff --git a/include/hw/gpio/nrf51_gpio.h b/include/hw/gpio/nrf51_gpio.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/gpio/nrf51_gpio.h
21
+++ b/include/hw/gpio/nrf51_gpio.h
22
@@ -XXX,XX +XXX,XX @@ struct NRF51GPIOState {
23
uint32_t old_out_connected;
24
25
qemu_irq output[NRF51_GPIO_PINS];
26
+ qemu_irq detect;
27
};
28
29
30
diff --git a/hw/gpio/nrf51_gpio.c b/hw/gpio/nrf51_gpio.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/gpio/nrf51_gpio.c
33
+++ b/hw/gpio/nrf51_gpio.c
34
@@ -XXX,XX +XXX,XX @@ static void update_state(NRF51GPIOState *s)
35
int pull;
36
size_t i;
37
bool connected_out, dir, connected_in, out, in, input;
38
+ bool assert_detect = false;
39
40
for (i = 0; i < NRF51_GPIO_PINS; i++) {
41
pull = pull_value(s->cnf[i]);
42
@@ -XXX,XX +XXX,XX @@ static void update_state(NRF51GPIOState *s)
43
qemu_log_mask(LOG_GUEST_ERROR,
44
"GPIO pin %zu short circuited\n", i);
45
}
46
- if (!connected_in) {
47
+ if (connected_in) {
48
+ uint32_t detect_config = extract32(s->cnf[i], 16, 2);
49
+ if ((detect_config == 2) && (in == 1)) {
50
+ assert_detect = true;
51
+ }
52
+ if ((detect_config == 3) && (in == 0)) {
53
+ assert_detect = true;
54
+ }
55
+ } else {
56
/*
57
* Floating input: the output stimulates IN if connected,
58
* otherwise pull-up/pull-down resistors put a value on both
59
@@ -XXX,XX +XXX,XX @@ static void update_state(NRF51GPIOState *s)
60
}
61
update_output_irq(s, i, connected_out, out);
62
}
63
+
64
+ qemu_set_irq(s->detect, assert_detect);
65
}
66
67
/*
68
@@ -XXX,XX +XXX,XX @@ static void nrf51_gpio_init(Object *obj)
69
70
qdev_init_gpio_in(DEVICE(s), nrf51_gpio_set, NRF51_GPIO_PINS);
71
qdev_init_gpio_out(DEVICE(s), s->output, NRF51_GPIO_PINS);
72
+ qdev_init_gpio_out_named(DEVICE(s), &s->detect, "detect", 1);
73
}
74
75
static void nrf51_gpio_class_init(ObjectClass *klass, void *data)
76
--
77
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Chris Laplante <chris@laplante.io>
2
1
3
Signed-off-by: Chris Laplante <chris@laplante.io>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20230728160324.1159090-3-chris@laplante.io
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
softmmu/qtest.c | 16 ++++++++++------
9
1 file changed, 10 insertions(+), 6 deletions(-)
10
11
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/softmmu/qtest.c
14
+++ b/softmmu/qtest.c
15
@@ -XXX,XX +XXX,XX @@ void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words))
16
process_command_cb = pc_cb;
17
}
18
19
+static void qtest_install_gpio_out_intercept(DeviceState *dev, const char *name, int n)
20
+{
21
+ qemu_irq *disconnected = g_new0(qemu_irq, 1);
22
+ qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
23
+ disconnected, n);
24
+
25
+ *disconnected = qdev_intercept_gpio_out(dev, icpt, name, n);
26
+}
27
+
28
static void qtest_process_command(CharBackend *chr, gchar **words)
29
{
30
const gchar *command;
31
@@ -XXX,XX +XXX,XX @@ static void qtest_process_command(CharBackend *chr, gchar **words)
32
if (words[0][14] == 'o') {
33
int i;
34
for (i = 0; i < ngl->num_out; ++i) {
35
- qemu_irq *disconnected = g_new0(qemu_irq, 1);
36
- qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
37
- disconnected, i);
38
-
39
- *disconnected = qdev_intercept_gpio_out(dev, icpt,
40
- ngl->name, i);
41
+ qtest_install_gpio_out_intercept(dev, ngl->name, i);
42
}
43
} else {
44
qemu_irq_intercept_in(ngl->in, qtest_irq_handler,
45
--
46
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Chris Laplante <chris@laplante.io>
2
1
3
Adds qtest_irq_intercept_out_named method, which utilizes a new optional
4
name parameter to the irq_intercept_out qtest command.
5
6
Signed-off-by: Chris Laplante <chris@laplante.io>
7
Message-id: 20230728160324.1159090-4-chris@laplante.io
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
tests/qtest/libqtest.h | 11 +++++++++++
12
softmmu/qtest.c | 18 ++++++++++--------
13
tests/qtest/libqtest.c | 6 ++++++
14
3 files changed, 27 insertions(+), 8 deletions(-)
15
16
diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qtest/libqtest.h
19
+++ b/tests/qtest/libqtest.h
20
@@ -XXX,XX +XXX,XX @@ void qtest_irq_intercept_in(QTestState *s, const char *string);
21
*/
22
void qtest_irq_intercept_out(QTestState *s, const char *string);
23
24
+/**
25
+ * qtest_irq_intercept_out_named:
26
+ * @s: #QTestState instance to operate on.
27
+ * @qom_path: QOM path of a device.
28
+ * @name: Name of the GPIO out pin
29
+ *
30
+ * Associate a qtest irq with the named GPIO-out pin of the device
31
+ * whose path is specified by @string and whose name is @name.
32
+ */
33
+void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, const char *name);
34
+
35
/**
36
* qtest_set_irq_in:
37
* @s: QTestState instance to operate on.
38
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/softmmu/qtest.c
41
+++ b/softmmu/qtest.c
42
@@ -XXX,XX +XXX,XX @@ static void qtest_process_command(CharBackend *chr, gchar **words)
43
|| strcmp(words[0], "irq_intercept_in") == 0) {
44
DeviceState *dev;
45
NamedGPIOList *ngl;
46
+ bool is_outbound;
47
48
g_assert(words[1]);
49
+ is_outbound = words[0][14] == 'o';
50
dev = DEVICE(object_resolve_path(words[1], NULL));
51
if (!dev) {
52
qtest_send_prefix(chr);
53
@@ -XXX,XX +XXX,XX @@ static void qtest_process_command(CharBackend *chr, gchar **words)
54
}
55
56
QLIST_FOREACH(ngl, &dev->gpios, node) {
57
- /* We don't support intercept of named GPIOs yet */
58
- if (ngl->name) {
59
- continue;
60
- }
61
- if (words[0][14] == 'o') {
62
- int i;
63
- for (i = 0; i < ngl->num_out; ++i) {
64
- qtest_install_gpio_out_intercept(dev, ngl->name, i);
65
+ /* We don't support inbound interception of named GPIOs yet */
66
+ if (is_outbound) {
67
+ /* NULL is valid and matchable, for "unnamed GPIO" */
68
+ if (g_strcmp0(ngl->name, words[2]) == 0) {
69
+ int i;
70
+ for (i = 0; i < ngl->num_out; ++i) {
71
+ qtest_install_gpio_out_intercept(dev, ngl->name, i);
72
+ }
73
}
74
} else {
75
qemu_irq_intercept_in(ngl->in, qtest_irq_handler,
76
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/tests/qtest/libqtest.c
79
+++ b/tests/qtest/libqtest.c
80
@@ -XXX,XX +XXX,XX @@ void qtest_irq_intercept_out(QTestState *s, const char *qom_path)
81
qtest_rsp(s);
82
}
83
84
+void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, const char *name)
85
+{
86
+ qtest_sendf(s, "irq_intercept_out %s %s\n", qom_path, name);
87
+ qtest_rsp(s);
88
+}
89
+
90
void qtest_irq_intercept_in(QTestState *s, const char *qom_path)
91
{
92
qtest_sendf(s, "irq_intercept_in %s\n", qom_path);
93
--
94
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Chris Laplante <chris@laplante.io>
2
1
3
Named interception of in-GPIOs is not supported yet.
4
5
Signed-off-by: Chris Laplante <chris@laplante.io>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20230728160324.1159090-5-chris@laplante.io
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
softmmu/qtest.c | 8 ++++++++
11
1 file changed, 8 insertions(+)
12
13
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/softmmu/qtest.c
16
+++ b/softmmu/qtest.c
17
@@ -XXX,XX +XXX,XX @@ static void qtest_process_command(CharBackend *chr, gchar **words)
18
|| strcmp(words[0], "irq_intercept_in") == 0) {
19
DeviceState *dev;
20
NamedGPIOList *ngl;
21
+ bool is_named;
22
bool is_outbound;
23
24
g_assert(words[1]);
25
+ is_named = words[2] != NULL;
26
is_outbound = words[0][14] == 'o';
27
dev = DEVICE(object_resolve_path(words[1], NULL));
28
if (!dev) {
29
@@ -XXX,XX +XXX,XX @@ static void qtest_process_command(CharBackend *chr, gchar **words)
30
return;
31
}
32
33
+ if (is_named && !is_outbound) {
34
+ qtest_send_prefix(chr);
35
+ qtest_send(chr, "FAIL Interception of named in-GPIOs not yet supported\n");
36
+ return;
37
+ }
38
+
39
if (irq_intercept_dev) {
40
qtest_send_prefix(chr);
41
if (irq_intercept_dev != dev) {
42
--
43
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Chris Laplante <chris@laplante.io>
2
1
3
This is much better than just silently failing with OK.
4
5
Signed-off-by: Chris Laplante <chris@laplante.io>
6
Message-id: 20230728160324.1159090-6-chris@laplante.io
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
softmmu/qtest.c | 12 ++++++++++--
11
1 file changed, 10 insertions(+), 2 deletions(-)
12
13
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/softmmu/qtest.c
16
+++ b/softmmu/qtest.c
17
@@ -XXX,XX +XXX,XX @@ static void qtest_process_command(CharBackend *chr, gchar **words)
18
NamedGPIOList *ngl;
19
bool is_named;
20
bool is_outbound;
21
+ bool interception_succeeded = false;
22
23
g_assert(words[1]);
24
is_named = words[2] != NULL;
25
@@ -XXX,XX +XXX,XX @@ static void qtest_process_command(CharBackend *chr, gchar **words)
26
for (i = 0; i < ngl->num_out; ++i) {
27
qtest_install_gpio_out_intercept(dev, ngl->name, i);
28
}
29
+ interception_succeeded = true;
30
}
31
} else {
32
qemu_irq_intercept_in(ngl->in, qtest_irq_handler,
33
ngl->num_in);
34
+ interception_succeeded = true;
35
}
36
}
37
- irq_intercept_dev = dev;
38
+
39
qtest_send_prefix(chr);
40
- qtest_send(chr, "OK\n");
41
+ if (interception_succeeded) {
42
+ irq_intercept_dev = dev;
43
+ qtest_send(chr, "OK\n");
44
+ } else {
45
+ qtest_send(chr, "FAIL No intercepts installed\n");
46
+ }
47
} else if (strcmp(words[0], "set_irq_in") == 0) {
48
DeviceState *dev;
49
qemu_irq irq;
50
--
51
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Chris Laplante <chris@laplante.io>
2
1
3
Exercise the DETECT mechanism of the GPIO peripheral.
4
5
Signed-off-by: Chris Laplante <chris@laplante.io>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20230728160324.1159090-7-chris@laplante.io
8
[PMM: fixed coding style nits]
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
tests/qtest/microbit-test.c | 44 +++++++++++++++++++++++++++++++++++++
12
1 file changed, 44 insertions(+)
13
14
diff --git a/tests/qtest/microbit-test.c b/tests/qtest/microbit-test.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/microbit-test.c
17
+++ b/tests/qtest/microbit-test.c
18
@@ -XXX,XX +XXX,XX @@ static void test_nrf51_gpio(void)
19
qtest_quit(qts);
20
}
21
22
+static void test_nrf51_gpio_detect(void)
23
+{
24
+ QTestState *qts = qtest_init("-M microbit");
25
+ int i;
26
+
27
+ /* Connect input buffer on pins 1-7, configure SENSE for high level */
28
+ for (i = 1; i <= 7; i++) {
29
+ qtest_writel(qts, NRF51_GPIO_BASE + NRF51_GPIO_REG_CNF_START + i * 4,
30
+ deposit32(0, 16, 2, 2));
31
+ }
32
+
33
+ qtest_irq_intercept_out_named(qts, "/machine/nrf51/gpio", "detect");
34
+
35
+ for (i = 1; i <= 7; i++) {
36
+ /* Set pin high */
37
+ qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", i, 1);
38
+ uint32_t actual = qtest_readl(qts, NRF51_GPIO_BASE + NRF51_GPIO_REG_IN);
39
+ g_assert_cmpuint(actual, ==, 1 << i);
40
+
41
+ /* Check that DETECT is high */
42
+ g_assert_true(qtest_get_irq(qts, 0));
43
+
44
+ /* Set pin low, check that DETECT goes low. */
45
+ qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", i, 0);
46
+ actual = qtest_readl(qts, NRF51_GPIO_BASE + NRF51_GPIO_REG_IN);
47
+ g_assert_cmpuint(actual, ==, 0x0);
48
+ g_assert_false(qtest_get_irq(qts, 0));
49
+ }
50
+
51
+ /* Set pin 0 high, check that DETECT doesn't fire */
52
+ qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", 0, 1);
53
+ g_assert_false(qtest_get_irq(qts, 0));
54
+ qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", 0, 0);
55
+
56
+ /* Set pins 1, 2, and 3 high, then set 3 low. Check DETECT is still high */
57
+ for (i = 1; i <= 3; i++) {
58
+ qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", i, 1);
59
+ }
60
+ g_assert_true(qtest_get_irq(qts, 0));
61
+ qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", 3, 0);
62
+ g_assert_true(qtest_get_irq(qts, 0));
63
+}
64
+
65
static void timer_task(QTestState *qts, hwaddr task)
66
{
67
qtest_writel(qts, NRF51_TIMER_BASE + task, NRF51_TRIGGER_TASK);
68
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
69
70
qtest_add_func("/microbit/nrf51/uart", test_nrf51_uart);
71
qtest_add_func("/microbit/nrf51/gpio", test_nrf51_gpio);
72
+ qtest_add_func("/microbit/nrf51/gpio_detect", test_nrf51_gpio_detect);
73
qtest_add_func("/microbit/nrf51/nvmc", test_nrf51_nvmc);
74
qtest_add_func("/microbit/nrf51/timer", test_nrf51_timer);
75
qtest_add_func("/microbit/microbit/i2c", test_microbit_i2c);
76
--
77
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
1
3
kvm_arch_get_default_type() returns the default KVM type. This hook is
4
particularly useful to derive a KVM type that is valid for "none"
5
machine model, which is used by libvirt to probe the availability of
6
KVM.
7
8
For MIPS, the existing mips_kvm_type() is reused. This function ensures
9
the availability of VZ which is mandatory to use KVM on the current
10
QEMU.
11
12
Cc: qemu-stable@nongnu.org
13
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
14
Message-id: 20230727073134.134102-2-akihiko.odaki@daynix.com
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
[PMM: added doc comment for new function]
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
19
---
20
include/sysemu/kvm.h | 2 ++
21
target/mips/kvm_mips.h | 9 ---------
22
accel/kvm/kvm-all.c | 4 +++-
23
hw/mips/loongson3_virt.c | 2 --
24
target/arm/kvm.c | 5 +++++
25
target/i386/kvm/kvm.c | 5 +++++
26
target/mips/kvm.c | 2 +-
27
target/ppc/kvm.c | 5 +++++
28
target/riscv/kvm.c | 5 +++++
29
target/s390x/kvm/kvm.c | 5 +++++
30
10 files changed, 31 insertions(+), 13 deletions(-)
31
32
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
33
index XXXXXXX..XXXXXXX 100644
34
--- a/include/sysemu/kvm.h
35
+++ b/include/sysemu/kvm.h
36
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cpu);
37
38
int kvm_arch_put_registers(CPUState *cpu, int level);
39
40
+int kvm_arch_get_default_type(MachineState *ms);
41
+
42
int kvm_arch_init(MachineState *ms, KVMState *s);
43
44
int kvm_arch_init_vcpu(CPUState *cpu);
45
diff --git a/target/mips/kvm_mips.h b/target/mips/kvm_mips.h
46
index XXXXXXX..XXXXXXX 100644
47
--- a/target/mips/kvm_mips.h
48
+++ b/target/mips/kvm_mips.h
49
@@ -XXX,XX +XXX,XX @@ void kvm_mips_reset_vcpu(MIPSCPU *cpu);
50
int kvm_mips_set_interrupt(MIPSCPU *cpu, int irq, int level);
51
int kvm_mips_set_ipi_interrupt(MIPSCPU *cpu, int irq, int level);
52
53
-#ifdef CONFIG_KVM
54
-int mips_kvm_type(MachineState *machine, const char *vm_type);
55
-#else
56
-static inline int mips_kvm_type(MachineState *machine, const char *vm_type)
57
-{
58
- return 0;
59
-}
60
-#endif
61
-
62
#endif /* KVM_MIPS_H */
63
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/accel/kvm/kvm-all.c
66
+++ b/accel/kvm/kvm-all.c
67
@@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms)
68
KVMState *s;
69
const KVMCapabilityInfo *missing_cap;
70
int ret;
71
- int type = 0;
72
+ int type;
73
uint64_t dirty_log_manual_caps;
74
75
qemu_mutex_init(&kml_slots_lock);
76
@@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms)
77
type = mc->kvm_type(ms, kvm_type);
78
} else if (mc->kvm_type) {
79
type = mc->kvm_type(ms, NULL);
80
+ } else {
81
+ type = kvm_arch_get_default_type(ms);
82
}
83
84
do {
85
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/hw/mips/loongson3_virt.c
88
+++ b/hw/mips/loongson3_virt.c
89
@@ -XXX,XX +XXX,XX @@
90
#include "qemu/datadir.h"
91
#include "qapi/error.h"
92
#include "elf.h"
93
-#include "kvm_mips.h"
94
#include "hw/char/serial.h"
95
#include "hw/intc/loongson_liointc.h"
96
#include "hw/mips/mips.h"
97
@@ -XXX,XX +XXX,XX @@ static void loongson3v_machine_class_init(ObjectClass *oc, void *data)
98
mc->max_cpus = LOONGSON_MAX_VCPUS;
99
mc->default_ram_id = "loongson3.highram";
100
mc->default_ram_size = 1600 * MiB;
101
- mc->kvm_type = mips_kvm_type;
102
mc->minimum_page_bits = 14;
103
mc->default_nic = "virtio-net-pci";
104
}
105
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/target/arm/kvm.c
108
+++ b/target/arm/kvm.c
109
@@ -XXX,XX +XXX,XX @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
110
return ret > 0 ? ret : 40;
111
}
112
113
+int kvm_arch_get_default_type(MachineState *ms)
114
+{
115
+ return 0;
116
+}
117
+
118
int kvm_arch_init(MachineState *ms, KVMState *s)
119
{
120
int ret = 0;
121
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/target/i386/kvm/kvm.c
124
+++ b/target/i386/kvm/kvm.c
125
@@ -XXX,XX +XXX,XX @@ static void register_smram_listener(Notifier *n, void *unused)
126
&smram_address_space, 1, "kvm-smram");
127
}
128
129
+int kvm_arch_get_default_type(MachineState *ms)
130
+{
131
+ return 0;
132
+}
133
+
134
int kvm_arch_init(MachineState *ms, KVMState *s)
135
{
136
uint64_t identity_base = 0xfffbc000;
137
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
138
index XXXXXXX..XXXXXXX 100644
139
--- a/target/mips/kvm.c
140
+++ b/target/mips/kvm.c
141
@@ -XXX,XX +XXX,XX @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
142
abort();
143
}
144
145
-int mips_kvm_type(MachineState *machine, const char *vm_type)
146
+int kvm_arch_get_default_type(MachineState *machine)
147
{
148
#if defined(KVM_CAP_MIPS_VZ)
149
int r;
150
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
151
index XXXXXXX..XXXXXXX 100644
152
--- a/target/ppc/kvm.c
153
+++ b/target/ppc/kvm.c
154
@@ -XXX,XX +XXX,XX @@ static int kvm_ppc_register_host_cpu_type(void);
155
static void kvmppc_get_cpu_characteristics(KVMState *s);
156
static int kvmppc_get_dec_bits(void);
157
158
+int kvm_arch_get_default_type(MachineState *ms)
159
+{
160
+ return 0;
161
+}
162
+
163
int kvm_arch_init(MachineState *ms, KVMState *s)
164
{
165
cap_interrupt_unset = kvm_check_extension(s, KVM_CAP_PPC_UNSET_IRQ);
166
diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
167
index XXXXXXX..XXXXXXX 100644
168
--- a/target/riscv/kvm.c
169
+++ b/target/riscv/kvm.c
170
@@ -XXX,XX +XXX,XX @@ int kvm_arch_add_msi_route_post(struct kvm_irq_routing_entry *route,
171
return 0;
172
}
173
174
+int kvm_arch_get_default_type(MachineState *ms)
175
+{
176
+ return 0;
177
+}
178
+
179
int kvm_arch_init(MachineState *ms, KVMState *s)
180
{
181
return 0;
182
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
183
index XXXXXXX..XXXXXXX 100644
184
--- a/target/s390x/kvm/kvm.c
185
+++ b/target/s390x/kvm/kvm.c
186
@@ -XXX,XX +XXX,XX @@ static void ccw_machine_class_foreach(ObjectClass *oc, void *opaque)
187
mc->default_cpu_type = S390_CPU_TYPE_NAME("host");
188
}
189
190
+int kvm_arch_get_default_type(MachineState *ms)
191
+{
192
+ return 0;
193
+}
194
+
195
int kvm_arch_init(MachineState *ms, KVMState *s)
196
{
197
object_class_foreach(ccw_machine_class_foreach, TYPE_S390_CCW_MACHINE,
198
--
199
2.34.1
200
201
diff view generated by jsdifflib
Deleted patch
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
1
3
Before this change, the default KVM type, which is used for non-virt
4
machine models, was 0.
5
6
The kernel documentation says:
7
> On arm64, the physical address size for a VM (IPA Size limit) is
8
> limited to 40bits by default. The limit can be configured if the host
9
> supports the extension KVM_CAP_ARM_VM_IPA_SIZE. When supported, use
10
> KVM_VM_TYPE_ARM_IPA_SIZE(IPA_Bits) to set the size in the machine type
11
> identifier, where IPA_Bits is the maximum width of any physical
12
> address used by the VM. The IPA_Bits is encoded in bits[7-0] of the
13
> machine type identifier.
14
>
15
> e.g, to configure a guest to use 48bit physical address size::
16
>
17
> vm_fd = ioctl(dev_fd, KVM_CREATE_VM, KVM_VM_TYPE_ARM_IPA_SIZE(48));
18
>
19
> The requested size (IPA_Bits) must be:
20
>
21
> == =========================================================
22
> 0 Implies default size, 40bits (for backward compatibility)
23
> N Implies N bits, where N is a positive integer such that,
24
> 32 <= N <= Host_IPA_Limit
25
> == =========================================================
26
27
> Host_IPA_Limit is the maximum possible value for IPA_Bits on the host
28
> and is dependent on the CPU capability and the kernel configuration.
29
> The limit can be retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the
30
> KVM_CHECK_EXTENSION ioctl() at run-time.
31
>
32
> Creation of the VM will fail if the requested IPA size (whether it is
33
> implicit or explicit) is unsupported on the host.
34
https://docs.kernel.org/virt/kvm/api.html#kvm-create-vm
35
36
So if Host_IPA_Limit < 40, specifying 0 as the type will fail. This
37
actually confused libvirt, which uses "none" machine model to probe the
38
KVM availability, on M2 MacBook Air.
39
40
Fix this by using Host_IPA_Limit as the default type when
41
KVM_CAP_ARM_VM_IPA_SIZE is available.
42
43
Cc: qemu-stable@nongnu.org
44
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
45
Message-id: 20230727073134.134102-3-akihiko.odaki@daynix.com
46
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
47
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
48
---
49
target/arm/kvm.c | 4 +++-
50
1 file changed, 3 insertions(+), 1 deletion(-)
51
52
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/kvm.c
55
+++ b/target/arm/kvm.c
56
@@ -XXX,XX +XXX,XX @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
57
58
int kvm_arch_get_default_type(MachineState *ms)
59
{
60
- return 0;
61
+ bool fixed_ipa;
62
+ int size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa);
63
+ return fixed_ipa ? 0 : size;
64
}
65
66
int kvm_arch_init(MachineState *ms, KVMState *s)
67
--
68
2.34.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
The HSTR_EL2 register allows the hypervisor to trap AArch32 EL1 and
2
EL0 accesses to cp15 registers. We incorrectly implemented this so
3
they trap to EL1 when we detect the need for a HSTR trap at code
4
generation time. (The check in access_check_cp_reg() which we do at
5
runtime to catch traps from EL0 is correctly routing them to EL2.)
2
6
3
Typo applied byte-wise shift instead of double-word shift.
7
Use the correct target EL when generating the code to take the trap.
4
8
5
Cc: qemu-stable@nongnu.org
9
Cc: qemu-stable@nongnu.org
6
Fixes: 631e565450c ("target/arm: Create gen_gvec_[us]sra")
10
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2226
7
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1737
11
Fixes: 049edada5e93df ("target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1")
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Message-id: 20230821022025.397682-1-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20240325133116.2075362-1-peter.maydell@linaro.org
12
---
15
---
13
target/arm/tcg/translate.c | 2 +-
16
target/arm/tcg/translate.c | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
17
1 file changed, 1 insertion(+), 1 deletion(-)
15
18
16
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
19
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/tcg/translate.c
21
--- a/target/arm/tcg/translate.c
19
+++ b/target/arm/tcg/translate.c
22
+++ b/target/arm/tcg/translate.c
20
@@ -XXX,XX +XXX,XX @@ void gen_gvec_ssra(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs,
23
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
21
.vece = MO_32 },
24
tcg_gen_andi_i32(t, t, 1u << maskbit);
22
{ .fni8 = gen_ssra64_i64,
25
tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label);
23
.fniv = gen_ssra_vec,
26
24
- .fno = gen_helper_gvec_ssra_b,
27
- gen_exception_insn(s, 0, EXCP_UDEF, syndrome);
25
+ .fno = gen_helper_gvec_ssra_d,
28
+ gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2);
26
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
29
/*
27
.opt_opc = vecop_list,
30
* gen_exception_insn() will set is_jmp to DISAS_NORETURN,
28
.load_dest = true,
31
* but since we're conditionally branching over it, we want
29
--
32
--
30
2.34.1
33
2.34.1
31
32
diff view generated by jsdifflib
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
1
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
2
2
3
At the moment we only handle Secure and Nonsecure security spaces for
3
Hardware of sbsa-ref board is nowadays defined by both BSA and SBSA
4
the AT instructions. Add support for Realm and Root.
4
specifications. Then BBR defines firmware interface.
5
5
6
For AArch64, arm_security_space() gives the desired space. ARM DDI0487J
6
Added note about DeviceTree data passed from QEMU to firmware. It is
7
says (R_NYXTL):
7
very minimal and provides only data we use in firmware.
8
8
9
If EL3 is implemented, then when an address translation instruction
9
Added NUMA information to list of things reported by DeviceTree.
10
that applies to an Exception level lower than EL3 is executed, the
11
Effective value of SCR_EL3.{NSE, NS} determines the target Security
12
state that the instruction applies to.
13
10
14
For AArch32, some instructions can access NonSecure space from Secure,
11
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
15
so we still need to pass the state explicitly to do_ats_write().
12
Message-id: 20240328163851.1386176-1-marcin.juszkiewicz@linaro.org
16
13
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
17
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Message-id: 20230809123706.1842548-5-jean-philippe@linaro.org
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
15
---
22
target/arm/internals.h | 18 +++++++++---------
16
docs/system/arm/sbsa.rst | 35 ++++++++++++++++++++++++++---------
23
target/arm/helper.c | 27 ++++++++++++---------------
17
1 file changed, 26 insertions(+), 9 deletions(-)
24
target/arm/ptw.c | 12 ++++++------
25
3 files changed, 27 insertions(+), 30 deletions(-)
26
18
27
diff --git a/target/arm/internals.h b/target/arm/internals.h
19
diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst
28
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/internals.h
21
--- a/docs/system/arm/sbsa.rst
30
+++ b/target/arm/internals.h
22
+++ b/docs/system/arm/sbsa.rst
31
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
23
@@ -XXX,XX +XXX,XX @@
32
__attribute__((nonnull));
24
Arm Server Base System Architecture Reference board (``sbsa-ref``)
33
25
==================================================================
34
/**
26
35
- * get_phys_addr_with_secure_nogpc: get the physical address for a virtual
27
-While the ``virt`` board is a generic board platform that doesn't match
36
- * address
28
-any real hardware the ``sbsa-ref`` board intends to look like real
37
+ * get_phys_addr_with_space_nogpc: get the physical address for a virtual
29
-hardware. The `Server Base System Architecture
38
+ * address
30
-<https://developer.arm.com/documentation/den0029/latest>`_ defines a
39
* @env: CPUARMState
31
-minimum base line of hardware support and importantly how the firmware
40
* @address: virtual address to get physical address for
32
-reports that to any operating system.
41
* @access_type: 0 for read, 1 for write, 2 for execute
33
+The ``sbsa-ref`` board intends to look like real hardware (while the ``virt``
42
* @mmu_idx: MMU index indicating required translation regime
34
+board is a generic board platform that doesn't match any real hardware).
43
- * @is_secure: security state for the access
35
+
44
+ * @space: security space for the access
36
+The hardware part is defined by two specifications:
45
* @result: set on translation success.
37
+
46
* @fi: set to fault info if the translation fails
38
+ - `Base System Architecture <https://developer.arm.com/documentation/den0094/>`__ (BSA)
47
*
39
+ - `Server Base System Architecture <https://developer.arm.com/documentation/den0029/>`__ (SBSA)
48
- * Similar to get_phys_addr, but use the given security regime and don't perform
40
+
49
+ * Similar to get_phys_addr, but use the given security space and don't perform
41
+The `Arm Base Boot Requirements <https://developer.arm.com/documentation/den0044/>`__ (BBR)
50
* a Granule Protection Check on the resulting address.
42
+specification defines how the firmware reports that to any operating system.
51
*/
43
52
-bool get_phys_addr_with_secure_nogpc(CPUARMState *env, target_ulong address,
44
It is intended to be a machine for developing firmware and testing
53
- MMUAccessType access_type,
45
standards compliance with operating systems.
54
- ARMMMUIdx mmu_idx, bool is_secure,
46
@@ -XXX,XX +XXX,XX @@ includes both internal hardware and parts affected by the qemu command line
55
- GetPhysAddrResult *result,
47
(i.e. CPUs and memory). As a result it must have a firmware specifically built
56
- ARMMMUFaultInfo *fi)
48
to expect a certain hardware layout (as you would in a real machine).
57
+bool get_phys_addr_with_space_nogpc(CPUARMState *env, target_ulong address,
49
58
+ MMUAccessType access_type,
50
+Note
59
+ ARMMMUIdx mmu_idx, ARMSecuritySpace space,
51
+''''
60
+ GetPhysAddrResult *result,
52
+
61
+ ARMMMUFaultInfo *fi)
53
+QEMU provides the guest EL3 firmware with minimal information about hardware
62
__attribute__((nonnull));
54
+platform using minimalistic devicetree. This is not a Linux devicetree. It is
63
55
+not even a firmware devicetree.
64
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
56
+
65
diff --git a/target/arm/helper.c b/target/arm/helper.c
57
+It is information passed from QEMU to describe the information a hardware
66
index XXXXXXX..XXXXXXX 100644
58
+platform would have other mechanisms to discover at runtime, that are affected
67
--- a/target/arm/helper.c
59
+by the QEMU command line.
68
+++ b/target/arm/helper.c
60
+
69
@@ -XXX,XX +XXX,XX @@ static int par_el1_shareability(GetPhysAddrResult *res)
61
+Ultimately this devicetree may be replaced by IPC calls to an emulated SCP.
70
62
+
71
static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
63
DeviceTree information
72
MMUAccessType access_type, ARMMMUIdx mmu_idx,
64
''''''''''''''''''''''
73
- bool is_secure)
65
74
+ ARMSecuritySpace ss)
66
-The devicetree provided by the board model to the firmware is not intended
75
{
67
-to be a complete compliant DT. It currently reports:
76
bool ret;
68
+The devicetree reports:
77
uint64_t par64;
69
78
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
70
- CPUs
79
* I_MXTJT: Granule protection checks are not performed on the final address
71
- memory
80
* of a successful translation.
72
- platform version
81
*/
73
- GIC addresses
82
- ret = get_phys_addr_with_secure_nogpc(env, value, access_type, mmu_idx,
74
+ - NUMA node id for CPUs and memory
83
- is_secure, &res, &fi);
75
84
+ ret = get_phys_addr_with_space_nogpc(env, value, access_type, mmu_idx, ss,
76
Platform version
85
+ &res, &fi);
77
''''''''''''''''
86
78
@@ -XXX,XX +XXX,XX @@ Platform version changes:
87
/*
79
GIC ITS information is present in devicetree.
88
* ATS operations only do S1 or S1+S2 translations, so we never
80
89
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
81
0.3
90
uint64_t par64;
82
- The USB controller is an XHCI device, not EHCI
91
ARMMMUIdx mmu_idx;
83
+ The USB controller is an XHCI device, not EHCI.
92
int el = arm_current_el(env);
93
- bool secure = arm_is_secure_below_el3(env);
94
+ ARMSecuritySpace ss = arm_security_space(env);
95
96
switch (ri->opc2 & 6) {
97
case 0:
98
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
99
switch (el) {
100
case 3:
101
mmu_idx = ARMMMUIdx_E3;
102
- secure = true;
103
break;
104
case 2:
105
- g_assert(!secure); /* ARMv8.4-SecEL2 is 64-bit only */
106
+ g_assert(ss != ARMSS_Secure); /* ARMv8.4-SecEL2 is 64-bit only */
107
/* fall through */
108
case 1:
109
if (ri->crm == 9 && (env->uncached_cpsr & CPSR_PAN)) {
110
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
111
switch (el) {
112
case 3:
113
mmu_idx = ARMMMUIdx_E10_0;
114
- secure = true;
115
break;
116
case 2:
117
- g_assert(!secure); /* ARMv8.4-SecEL2 is 64-bit only */
118
+ g_assert(ss != ARMSS_Secure); /* ARMv8.4-SecEL2 is 64-bit only */
119
mmu_idx = ARMMMUIdx_Stage1_E0;
120
break;
121
case 1:
122
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
123
case 4:
124
/* stage 1+2 NonSecure PL1: ATS12NSOPR, ATS12NSOPW */
125
mmu_idx = ARMMMUIdx_E10_1;
126
- secure = false;
127
+ ss = ARMSS_NonSecure;
128
break;
129
case 6:
130
/* stage 1+2 NonSecure PL0: ATS12NSOUR, ATS12NSOUW */
131
mmu_idx = ARMMMUIdx_E10_0;
132
- secure = false;
133
+ ss = ARMSS_NonSecure;
134
break;
135
default:
136
g_assert_not_reached();
137
}
138
139
- par64 = do_ats_write(env, value, access_type, mmu_idx, secure);
140
+ par64 = do_ats_write(env, value, access_type, mmu_idx, ss);
141
142
A32_BANKED_CURRENT_REG_SET(env, par, par64);
143
#else
144
@@ -XXX,XX +XXX,XX @@ static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri,
145
uint64_t par64;
146
147
/* There is no SecureEL2 for AArch32. */
148
- par64 = do_ats_write(env, value, access_type, ARMMMUIdx_E2, false);
149
+ par64 = do_ats_write(env, value, access_type, ARMMMUIdx_E2,
150
+ ARMSS_NonSecure);
151
152
A32_BANKED_CURRENT_REG_SET(env, par, par64);
153
#else
154
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
155
#ifdef CONFIG_TCG
156
MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD;
157
ARMMMUIdx mmu_idx;
158
- int secure = arm_is_secure_below_el3(env);
159
uint64_t hcr_el2 = arm_hcr_el2_eff(env);
160
bool regime_e20 = (hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE);
161
162
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
163
break;
164
case 6: /* AT S1E3R, AT S1E3W */
165
mmu_idx = ARMMMUIdx_E3;
166
- secure = true;
167
break;
168
default:
169
g_assert_not_reached();
170
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
171
}
172
173
env->cp15.par_el[1] = do_ats_write(env, value, access_type,
174
- mmu_idx, secure);
175
+ mmu_idx, arm_security_space(env));
176
#else
177
/* Handled by hardware accelerator. */
178
g_assert_not_reached();
179
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
180
index XXXXXXX..XXXXXXX 100644
181
--- a/target/arm/ptw.c
182
+++ b/target/arm/ptw.c
183
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw,
184
return false;
185
}
186
187
-bool get_phys_addr_with_secure_nogpc(CPUARMState *env, target_ulong address,
188
- MMUAccessType access_type,
189
- ARMMMUIdx mmu_idx, bool is_secure,
190
- GetPhysAddrResult *result,
191
- ARMMMUFaultInfo *fi)
192
+bool get_phys_addr_with_space_nogpc(CPUARMState *env, target_ulong address,
193
+ MMUAccessType access_type,
194
+ ARMMMUIdx mmu_idx, ARMSecuritySpace space,
195
+ GetPhysAddrResult *result,
196
+ ARMMMUFaultInfo *fi)
197
{
198
S1Translate ptw = {
199
.in_mmu_idx = mmu_idx,
200
- .in_space = arm_secure_to_space(is_secure),
201
+ .in_space = space,
202
};
203
return get_phys_addr_nogpc(env, &ptw, address, access_type, result, fi);
204
}
205
--
84
--
206
2.34.1
85
2.34.1
diff view generated by jsdifflib
1
We no longer look at the in_secure field of the S1Translate struct
1
If the group of the highest priority pending interrupt is disabled
2
anyway, so we can remove it and all the code which sets it.
2
via ICC_IGRPEN*, the ICC_HPPIR* registers should return
3
INTID_SPURIOUS, not the interrupt ID. (See the GIC architecture
4
specification pseudocode functions ICC_HPPIR1_EL1[] and
5
HighestPriorityPendingInterrupt().)
3
6
7
Make HPPIR reads honour the group disable, the way we already do
8
when determining whether to preempt in icc_hppi_can_preempt().
9
10
Cc: qemu-stable@nongnu.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230807141514.19075-11-peter.maydell@linaro.org
13
Message-id: 20240328153333.2522667-1-peter.maydell@linaro.org
7
---
14
---
8
target/arm/ptw.c | 13 -------------
15
hw/intc/arm_gicv3_cpuif.c | 4 ++--
9
1 file changed, 13 deletions(-)
16
1 file changed, 2 insertions(+), 2 deletions(-)
10
17
11
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
18
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
12
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/ptw.c
20
--- a/hw/intc/arm_gicv3_cpuif.c
14
+++ b/target/arm/ptw.c
21
+++ b/hw/intc/arm_gicv3_cpuif.c
15
@@ -XXX,XX +XXX,XX @@ typedef struct S1Translate {
22
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_hppir0_value(GICv3CPUState *cs, CPUARMState *env)
16
* value being Stage2 vs Stage2_S distinguishes those.
17
*/
23
*/
18
ARMSecuritySpace in_space;
24
bool irq_is_secure;
19
- /*
25
20
- * in_secure: whether the translation regime is a Secure one.
26
- if (cs->hppi.prio == 0xff) {
21
- * This is always equal to arm_space_is_secure(in_space).
27
+ if (icc_no_enabled_hppi(cs)) {
22
- * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit,
28
return INTID_SPURIOUS;
23
- * this field is updated accordingly.
24
- */
25
- bool in_secure;
26
/*
27
* in_debug: is this a QEMU debug access (gdbstub, etc)? Debug
28
* accesses will not update the guest page table access flags
29
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
30
S1Translate s2ptw = {
31
.in_mmu_idx = s2_mmu_idx,
32
.in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx),
33
- .in_secure = arm_space_is_secure(s2_space),
34
.in_space = s2_space,
35
.in_debug = true,
36
};
37
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
38
QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_S + 1 != ARMMMUIdx_Phys_NS);
39
QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2_S + 1 != ARMMMUIdx_Stage2);
40
ptw->in_ptw_idx += 1;
41
- ptw->in_secure = false;
42
ptw->in_space = ARMSS_NonSecure;
43
}
29
}
44
30
45
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
31
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_hppir1_value(GICv3CPUState *cs, CPUARMState *env)
46
32
*/
47
ptw->in_s1_is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0;
33
bool irq_is_secure;
48
ptw->in_mmu_idx = ipa_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
34
49
- ptw->in_secure = ipa_secure;
35
- if (cs->hppi.prio == 0xff) {
50
ptw->in_space = ipa_space;
36
+ if (icc_no_enabled_hppi(cs)) {
51
ptw->in_ptw_idx = ptw_idx_for_stage_2(env, ptw->in_mmu_idx);
37
return INTID_SPURIOUS;
52
53
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address,
54
{
55
S1Translate ptw = {
56
.in_mmu_idx = mmu_idx,
57
- .in_secure = is_secure,
58
.in_space = arm_secure_to_space(is_secure),
59
};
60
return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi);
61
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
62
}
38
}
63
39
64
ptw.in_space = ss;
65
- ptw.in_secure = arm_space_is_secure(ss);
66
return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi);
67
}
68
69
@@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
70
S1Translate ptw = {
71
.in_mmu_idx = mmu_idx,
72
.in_space = ss,
73
- .in_secure = arm_space_is_secure(ss),
74
.in_debug = true,
75
};
76
GetPhysAddrResult res = {};
77
--
40
--
78
2.34.1
41
2.34.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Cédric Le Goater <clg@redhat.com>
2
2
3
A typo, noted in the bug report, resulting in an
3
The test mangles the GPIO address and the pin number in the
4
incorrect write offset.
4
qtest_add_data_func data parameter. Doing so, it assumes that the host
5
pointer size is always 64-bit, which breaks on 32-bit :
5
6
6
Cc: qemu-stable@nongnu.org
7
../tests/qtest/stm32l4x5_gpio-test.c: In function ‘test_gpio_output_mode’:
7
Fixes: 7390e0e9ab8 ("target/arm: Implement SME LD1, ST1")
8
../tests/qtest/stm32l4x5_gpio-test.c:272:25: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
8
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1833
9
272 | unsigned int pin = ((uint64_t)data) & 0xF;
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
| ^
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
../tests/qtest/stm32l4x5_gpio-test.c:273:22: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
11
Message-id: 20230818214255.146905-1-richard.henderson@linaro.org
12
273 | uint32_t gpio = ((uint64_t)data) >> 32;
13
| ^
14
15
To fix, improve the mangling of the GPIO address and pin number fields
16
by using GPIO_SIZE so that the resulting value fits in a 32-bit pointer.
17
While at it, include some helpers to hide the details.
18
19
Cc: Arnaud Minier <arnaud.minier@telecom-paris.fr>
20
Cc: Inès Varhol <ines.varhol@telecom-paris.fr>
21
Signed-off-by: Cédric Le Goater <clg@redhat.com>
22
Message-id: 20240329092747.298259-1-clg@redhat.com
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
25
---
14
target/arm/tcg/sme_helper.c | 2 +-
26
tests/qtest/stm32l4x5_gpio-test.c | 59 ++++++++++++++++++-------------
15
1 file changed, 1 insertion(+), 1 deletion(-)
27
1 file changed, 35 insertions(+), 24 deletions(-)
16
28
17
diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c
29
diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c
18
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/tcg/sme_helper.c
31
--- a/tests/qtest/stm32l4x5_gpio-test.c
20
+++ b/target/arm/tcg/sme_helper.c
32
+++ b/tests/qtest/stm32l4x5_gpio-test.c
21
@@ -XXX,XX +XXX,XX @@ static inline void HNAME##_host(void *za, intptr_t off, void *host) \
33
@@ -XXX,XX +XXX,XX @@ const uint32_t idr_reset[NUM_GPIOS] = {
22
{ \
34
0x00000000
23
uint64_t *ptr = za + off; \
35
};
24
HOST(host, ptr[BE]); \
36
25
- HOST(host + 1, ptr[!BE]); \
37
+#define PIN_MASK 0xF
26
+ HOST(host + 8, ptr[!BE]); \
38
+#define GPIO_ADDR_MASK (~(GPIO_SIZE - 1))
27
} \
39
+
28
static inline void VNAME##_v_host(void *za, intptr_t off, void *host) \
40
+static inline void *test_data(uint32_t gpio_addr, uint8_t pin)
29
{ \
41
+{
42
+ return (void *)(uintptr_t)((gpio_addr & GPIO_ADDR_MASK) | (pin & PIN_MASK));
43
+}
44
+
45
+#define test_gpio_addr(data) ((uintptr_t)(data) & GPIO_ADDR_MASK)
46
+#define test_pin(data) ((uintptr_t)(data) & PIN_MASK)
47
+
48
static uint32_t gpio_readl(unsigned int gpio, unsigned int offset)
49
{
50
return readl(gpio + offset);
51
@@ -XXX,XX +XXX,XX @@ static void test_gpio_output_mode(const void *data)
52
* Additionally, it checks that values written to ODR
53
* when not in output mode are stored and not discarded.
54
*/
55
- unsigned int pin = ((uint64_t)data) & 0xF;
56
- uint32_t gpio = ((uint64_t)data) >> 32;
57
+ unsigned int pin = test_pin(data);
58
+ uint32_t gpio = test_gpio_addr(data);
59
unsigned int gpio_id = get_gpio_id(gpio);
60
61
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
62
@@ -XXX,XX +XXX,XX @@ static void test_gpio_input_mode(const void *data)
63
* corresponding GPIO line high/low : it should set the
64
* right bit in IDR and send an irq to syscfg.
65
*/
66
- unsigned int pin = ((uint64_t)data) & 0xF;
67
- uint32_t gpio = ((uint64_t)data) >> 32;
68
+ unsigned int pin = test_pin(data);
69
+ uint32_t gpio = test_gpio_addr(data);
70
unsigned int gpio_id = get_gpio_id(gpio);
71
72
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
73
@@ -XXX,XX +XXX,XX @@ static void test_pull_up_pull_down(const void *data)
74
* Test that a floating pin with pull-up sets the pin
75
* high and vice-versa.
76
*/
77
- unsigned int pin = ((uint64_t)data) & 0xF;
78
- uint32_t gpio = ((uint64_t)data) >> 32;
79
+ unsigned int pin = test_pin(data);
80
+ uint32_t gpio = test_gpio_addr(data);
81
unsigned int gpio_id = get_gpio_id(gpio);
82
83
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
84
@@ -XXX,XX +XXX,XX @@ static void test_push_pull(const void *data)
85
* disconnects the pin, that the pin can't be set or reset
86
* externally afterwards.
87
*/
88
- unsigned int pin = ((uint64_t)data) & 0xF;
89
- uint32_t gpio = ((uint64_t)data) >> 32;
90
+ unsigned int pin = test_pin(data);
91
+ uint32_t gpio = test_gpio_addr(data);
92
uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio);
93
94
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
95
@@ -XXX,XX +XXX,XX @@ static void test_open_drain(const void *data)
96
* However a pin set low externally shouldn't be disconnected,
97
* and it can be set low externally when in open-drain mode.
98
*/
99
- unsigned int pin = ((uint64_t)data) & 0xF;
100
- uint32_t gpio = ((uint64_t)data) >> 32;
101
+ unsigned int pin = test_pin(data);
102
+ uint32_t gpio = test_gpio_addr(data);
103
uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio);
104
105
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
106
@@ -XXX,XX +XXX,XX @@ static void test_bsrr_brr(const void *data)
107
* has the desired effect on ODR.
108
* In BSRR, BSx has priority over BRx.
109
*/
110
- unsigned int pin = ((uint64_t)data) & 0xF;
111
- uint32_t gpio = ((uint64_t)data) >> 32;
112
+ unsigned int pin = test_pin(data);
113
+ uint32_t gpio = test_gpio_addr(data);
114
115
gpio_writel(gpio, BSRR, (1 << pin));
116
g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin));
117
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
118
* is problematic since the pin was already high.
119
*/
120
qtest_add_data_func("stm32l4x5/gpio/test_gpioc5_output_mode",
121
- (void *)((uint64_t)GPIO_C << 32 | 5),
122
+ test_data(GPIO_C, 5),
123
test_gpio_output_mode);
124
qtest_add_data_func("stm32l4x5/gpio/test_gpioh3_output_mode",
125
- (void *)((uint64_t)GPIO_H << 32 | 3),
126
+ test_data(GPIO_H, 3),
127
test_gpio_output_mode);
128
qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode1",
129
- (void *)((uint64_t)GPIO_D << 32 | 6),
130
+ test_data(GPIO_D, 6),
131
test_gpio_input_mode);
132
qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode2",
133
- (void *)((uint64_t)GPIO_C << 32 | 10),
134
+ test_data(GPIO_C, 10),
135
test_gpio_input_mode);
136
qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down1",
137
- (void *)((uint64_t)GPIO_B << 32 | 5),
138
+ test_data(GPIO_B, 5),
139
test_pull_up_pull_down);
140
qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down2",
141
- (void *)((uint64_t)GPIO_F << 32 | 1),
142
+ test_data(GPIO_F, 1),
143
test_pull_up_pull_down);
144
qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull1",
145
- (void *)((uint64_t)GPIO_G << 32 | 6),
146
+ test_data(GPIO_G, 6),
147
test_push_pull);
148
qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull2",
149
- (void *)((uint64_t)GPIO_H << 32 | 3),
150
+ test_data(GPIO_H, 3),
151
test_push_pull);
152
qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain1",
153
- (void *)((uint64_t)GPIO_C << 32 | 4),
154
+ test_data(GPIO_C, 4),
155
test_open_drain);
156
qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain2",
157
- (void *)((uint64_t)GPIO_E << 32 | 11),
158
+ test_data(GPIO_E, 11),
159
test_open_drain);
160
qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr1",
161
- (void *)((uint64_t)GPIO_A << 32 | 12),
162
+ test_data(GPIO_A, 12),
163
test_bsrr_brr);
164
qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr2",
165
- (void *)((uint64_t)GPIO_D << 32 | 0),
166
+ test_data(GPIO_D, 0),
167
test_bsrr_brr);
168
169
qtest_start("-machine b-l475e-iot01a");
30
--
170
--
31
2.34.1
171
2.34.1
32
172
33
173
diff view generated by jsdifflib
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
1
From: Cédric Le Goater <clg@redhat.com>
2
2
3
On MIPS, QEMU requires KVM_VM_MIPS_VZ type for KVM. Report an error in
3
Change the board revision number and RAM size to 1Gb on 32-bit hosts.
4
such a case as other architectures do when an error occurred during KVM
4
On these systems, RAM has a 2047 MB limit and this breaks the tests.
5
type decision.
6
5
7
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
6
Fixes: 7785e8ea2204 ("hw/arm: Introduce Raspberry PI 4 machine")
8
Message-id: 20230727073134.134102-4-akihiko.odaki@daynix.com
7
Signed-off-by: Cédric Le Goater <clg@redhat.com>
8
Message-id: 20240329150155.357043-1-clg@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
---
11
---
13
target/mips/kvm.c | 1 +
12
hw/arm/raspi4b.c | 4 ++++
14
1 file changed, 1 insertion(+)
13
1 file changed, 4 insertions(+)
15
14
16
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
15
diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/mips/kvm.c
17
--- a/hw/arm/raspi4b.c
19
+++ b/target/mips/kvm.c
18
+++ b/hw/arm/raspi4b.c
20
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_default_type(MachineState *machine)
19
@@ -XXX,XX +XXX,XX @@ static void raspi4b_machine_class_init(ObjectClass *oc, void *data)
21
}
20
MachineClass *mc = MACHINE_CLASS(oc);
22
#endif
21
RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc);
23
22
24
+ error_report("KVM_VM_MIPS_VZ type is not available");
23
+#if HOST_LONG_BITS == 32
25
return -1;
24
+ rmc->board_rev = 0xa03111; /* Revision 1.1, 1 Gb RAM */
25
+#else
26
rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */
27
+#endif
28
raspi_machine_class_common_init(mc, rmc->board_rev);
29
mc->init = raspi4b_machine_init;
26
}
30
}
27
28
--
31
--
29
2.34.1
32
2.34.1
30
33
31
34
diff view generated by jsdifflib
Deleted patch
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
1
3
On MIPS, kvm_arch_get_default_type() returns a negative value when an
4
error occurred so handle the case. Also, let other machines return
5
negative values when errors occur and declare returning a negative
6
value as the correct way to propagate an error that happened when
7
determining KVM type.
8
9
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
10
Message-id: 20230727073134.134102-5-akihiko.odaki@daynix.com
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
---
15
accel/kvm/kvm-all.c | 5 +++++
16
hw/arm/virt.c | 2 +-
17
hw/ppc/spapr.c | 2 +-
18
3 files changed, 7 insertions(+), 2 deletions(-)
19
20
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/accel/kvm/kvm-all.c
23
+++ b/accel/kvm/kvm-all.c
24
@@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms)
25
type = kvm_arch_get_default_type(ms);
26
}
27
28
+ if (type < 0) {
29
+ ret = -EINVAL;
30
+ goto err;
31
+ }
32
+
33
do {
34
ret = kvm_ioctl(s, KVM_CREATE_VM, type);
35
} while (ret == -EINTR);
36
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/arm/virt.c
39
+++ b/hw/arm/virt.c
40
@@ -XXX,XX +XXX,XX @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
41
"require an IPA range (%d bits) larger than "
42
"the one supported by the host (%d bits)",
43
requested_pa_size, max_vm_pa_size);
44
- exit(1);
45
+ return -1;
46
}
47
/*
48
* We return the requested PA log size, unless KVM only supports
49
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/ppc/spapr.c
52
+++ b/hw/ppc/spapr.c
53
@@ -XXX,XX +XXX,XX @@ static int spapr_kvm_type(MachineState *machine, const char *vm_type)
54
}
55
56
error_report("Unknown kvm-type specified '%s'", vm_type);
57
- exit(1);
58
+ return -1;
59
}
60
61
/*
62
--
63
2.34.1
64
65
diff view generated by jsdifflib
Deleted patch
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
1
3
An error may occur after s->as is allocated, for example if the
4
KVM_CREATE_VM ioctl call fails.
5
6
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
7
Message-id: 20230727073134.134102-6-akihiko.odaki@daynix.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
[PMM: tweaked commit message]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
accel/kvm/kvm-all.c | 1 +
13
1 file changed, 1 insertion(+)
14
15
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/accel/kvm/kvm-all.c
18
+++ b/accel/kvm/kvm-all.c
19
@@ -XXX,XX +XXX,XX @@ err:
20
if (s->fd != -1) {
21
close(s->fd);
22
}
23
+ g_free(s->as);
24
g_free(s->memory_listener.slots);
25
26
return ret;
27
--
28
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
1
3
The returned value was always zero and had no meaning.
4
5
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
6
Message-id: 20230727073134.134102-7-akihiko.odaki@daynix.com
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
---
11
accel/kvm/kvm-all.c | 9 ++-------
12
1 file changed, 2 insertions(+), 7 deletions(-)
13
14
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/accel/kvm/kvm-all.c
17
+++ b/accel/kvm/kvm-all.c
18
@@ -XXX,XX +XXX,XX @@ static void *kvm_dirty_ring_reaper_thread(void *data)
19
return NULL;
20
}
21
22
-static int kvm_dirty_ring_reaper_init(KVMState *s)
23
+static void kvm_dirty_ring_reaper_init(KVMState *s)
24
{
25
struct KVMDirtyRingReaper *r = &s->reaper;
26
27
qemu_thread_create(&r->reaper_thr, "kvm-reaper",
28
kvm_dirty_ring_reaper_thread,
29
s, QEMU_THREAD_JOINABLE);
30
-
31
- return 0;
32
}
33
34
static int kvm_dirty_ring_init(KVMState *s)
35
@@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms)
36
}
37
38
if (s->kvm_dirty_ring_size) {
39
- ret = kvm_dirty_ring_reaper_init(s);
40
- if (ret) {
41
- goto err;
42
- }
43
+ kvm_dirty_ring_reaper_init(s);
44
}
45
46
if (kvm_check_extension(kvm_state, KVM_CAP_BINARY_STATS_FD)) {
47
--
48
2.34.1
49
50
diff view generated by jsdifflib
Deleted patch
1
For an Unsupported Atomic Update fault where the stage 1 translation
2
table descriptor update can't be done because it's to an unsupported
3
memory type, this is a stage 1 abort (per the Arm ARM R_VSXXT). This
4
means we should not set fi->s1ptw, because this will cause the code
5
in the get_phys_addr_lpae() error-exit path to mark it as stage 2.
6
1
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230807141514.19075-2-peter.maydell@linaro.org
10
---
11
target/arm/ptw.c | 1 -
12
1 file changed, 1 deletion(-)
13
14
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/ptw.c
17
+++ b/target/arm/ptw.c
18
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val,
19
20
if (unlikely(!host)) {
21
fi->type = ARMFault_UnsuppAtomicUpdate;
22
- fi->s1ptw = true;
23
return 0;
24
}
25
26
--
27
2.34.1
diff view generated by jsdifflib
Deleted patch
1
In S1_ptw_translate() we set up the ARMMMUFaultInfo if the attempt to
2
translate the page descriptor address into a physical address fails.
3
This used to only be possible if we are doing a stage 2 ptw for that
4
descriptor address, and so the code always sets fi->stage2 and
5
fi->s1ptw to true. However, with FEAT_RME it is also possible for
6
the lookup of the page descriptor address to fail because of a
7
Granule Protection Check fault. These should not be reported as
8
stage 2, otherwise arm_deliver_fault() will incorrectly set
9
HPFAR_EL2. Similarly the s1ptw bit should only be set for stage 2
10
faults on stage 1 translation table walks, i.e. not for GPC faults.
11
1
12
Add a comment to the the other place where we might detect a
13
stage2-fault-on-stage-1-ptw, in arm_casq_ptw(), noting why we know in
14
that case that it must really be a stage 2 fault and not a GPC fault.
15
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20230807141514.19075-3-peter.maydell@linaro.org
19
---
20
target/arm/ptw.c | 10 ++++++++--
21
1 file changed, 8 insertions(+), 2 deletions(-)
22
23
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
24
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/ptw.c
26
+++ b/target/arm/ptw.c
27
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
28
fi->type = ARMFault_GPCFOnWalk;
29
}
30
fi->s2addr = addr;
31
- fi->stage2 = true;
32
- fi->s1ptw = true;
33
+ fi->stage2 = regime_is_stage2(s2_mmu_idx);
34
+ fi->s1ptw = fi->stage2;
35
fi->s1ns = !is_secure;
36
return false;
37
}
38
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val,
39
env->tlb_fi = NULL;
40
41
if (unlikely(flags & TLB_INVALID_MASK)) {
42
+ /*
43
+ * We know this must be a stage 2 fault because the granule
44
+ * protection table does not separately track read and write
45
+ * permission, so all GPC faults are caught in S1_ptw_translate():
46
+ * we only get here for "readable but not writeable".
47
+ */
48
assert(fi->type != ARMFault_None);
49
fi->s2addr = ptw->out_virt;
50
fi->stage2 = true;
51
--
52
2.34.1
diff view generated by jsdifflib
Deleted patch
1
The s1ns bit in ARMMMUFaultInfo is documented as "true if
2
we faulted on a non-secure IPA while in secure state". Both the
3
places which look at this bit only do so after having confirmed
4
that this is a stage 2 fault and we're dealing with Secure EL2,
5
which leaves the ptw.c code free to set the bit to any random
6
value in the other cases.
7
1
8
Instead of taking advantage of that freedom, consistently
9
make the bit be set to false for the "not a stage 2 fault
10
for Secure EL2" cases. This removes some cases where we
11
were using an 'is_secure' boolean and leaving the reader
12
guessing about whether that was the right thing for Realm
13
and Root cases.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20230807141514.19075-4-peter.maydell@linaro.org
18
---
19
target/arm/ptw.c | 19 +++++++++++++++----
20
1 file changed, 15 insertions(+), 4 deletions(-)
21
22
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
23
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/ptw.c
25
+++ b/target/arm/ptw.c
26
@@ -XXX,XX +XXX,XX @@ static ARMSecuritySpace S2_security_space(ARMSecuritySpace s1_space,
27
}
28
}
29
30
+static bool fault_s1ns(ARMSecuritySpace space, ARMMMUIdx s2_mmu_idx)
31
+{
32
+ /*
33
+ * For stage 2 faults in Secure EL22, S1NS indicates
34
+ * whether the faulting IPA is in the Secure or NonSecure
35
+ * IPA space. For all other kinds of fault, it is false.
36
+ */
37
+ return space == ARMSS_Secure && regime_is_stage2(s2_mmu_idx)
38
+ && s2_mmu_idx == ARMMMUIdx_Stage2_S;
39
+}
40
+
41
/* Translate a S1 pagetable walk through S2 if needed. */
42
static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
43
hwaddr addr, ARMMMUFaultInfo *fi)
44
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
45
fi->s2addr = addr;
46
fi->stage2 = true;
47
fi->s1ptw = true;
48
- fi->s1ns = !is_secure;
49
+ fi->s1ns = fault_s1ns(ptw->in_space, s2_mmu_idx);
50
return false;
51
}
52
}
53
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
54
fi->s2addr = addr;
55
fi->stage2 = regime_is_stage2(s2_mmu_idx);
56
fi->s1ptw = fi->stage2;
57
- fi->s1ns = !is_secure;
58
+ fi->s1ns = fault_s1ns(ptw->in_space, s2_mmu_idx);
59
return false;
60
}
61
62
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val,
63
fi->s2addr = ptw->out_virt;
64
fi->stage2 = true;
65
fi->s1ptw = true;
66
- fi->s1ns = !ptw->in_secure;
67
+ fi->s1ns = fault_s1ns(ptw->in_space, ptw->in_ptw_idx);
68
return 0;
69
}
70
71
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
72
fi->level = level;
73
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
74
fi->stage2 = fi->s1ptw || regime_is_stage2(mmu_idx);
75
- fi->s1ns = mmu_idx == ARMMMUIdx_Stage2;
76
+ fi->s1ns = fault_s1ns(ptw->in_space, mmu_idx);
77
return true;
78
}
79
80
--
81
2.34.1
diff view generated by jsdifflib
Deleted patch
1
In commit 6d2654ffacea813916176 we created the S1Translate struct and
2
used it to plumb through various arguments that we were previously
3
passing one-at-a-time to get_phys_addr_v5(), get_phys_addr_v6(), and
4
get_phys_addr_lpae(). Extend that pattern to get_phys_addr_pmsav5(),
5
get_phys_addr_pmsav7(), get_phys_addr_pmsav8() and
6
get_phys_addr_disabled(), so that all the get_phys_addr_* functions
7
we call from get_phys_addr_nogpc() take the S1Translate struct rather
8
than the mmu_idx and is_secure bool.
9
1
10
(This refactoring is a prelude to having the called functions look
11
at ptw->is_space rather than using an is_secure boolean.)
12
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20230807141514.19075-5-peter.maydell@linaro.org
16
---
17
target/arm/ptw.c | 57 ++++++++++++++++++++++++++++++------------------
18
1 file changed, 36 insertions(+), 21 deletions(-)
19
20
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/ptw.c
23
+++ b/target/arm/ptw.c
24
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
25
return true;
26
}
27
28
-static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
29
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
30
- bool is_secure, GetPhysAddrResult *result,
31
+static bool get_phys_addr_pmsav5(CPUARMState *env,
32
+ S1Translate *ptw,
33
+ uint32_t address,
34
+ MMUAccessType access_type,
35
+ GetPhysAddrResult *result,
36
ARMMMUFaultInfo *fi)
37
{
38
int n;
39
uint32_t mask;
40
uint32_t base;
41
+ ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
42
bool is_user = regime_is_user(env, mmu_idx);
43
+ bool is_secure = arm_space_is_secure(ptw->in_space);
44
45
if (regime_translation_disabled(env, mmu_idx, is_secure)) {
46
/* MPU disabled. */
47
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
48
return regime_sctlr(env, mmu_idx) & SCTLR_BR;
49
}
50
51
-static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
52
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
53
- bool secure, GetPhysAddrResult *result,
54
+static bool get_phys_addr_pmsav7(CPUARMState *env,
55
+ S1Translate *ptw,
56
+ uint32_t address,
57
+ MMUAccessType access_type,
58
+ GetPhysAddrResult *result,
59
ARMMMUFaultInfo *fi)
60
{
61
ARMCPU *cpu = env_archcpu(env);
62
int n;
63
+ ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
64
bool is_user = regime_is_user(env, mmu_idx);
65
+ bool secure = arm_space_is_secure(ptw->in_space);
66
67
result->f.phys_addr = address;
68
result->f.lg_page_size = TARGET_PAGE_BITS;
69
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
70
}
71
}
72
73
-static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
74
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
75
- bool secure, GetPhysAddrResult *result,
76
+static bool get_phys_addr_pmsav8(CPUARMState *env,
77
+ S1Translate *ptw,
78
+ uint32_t address,
79
+ MMUAccessType access_type,
80
+ GetPhysAddrResult *result,
81
ARMMMUFaultInfo *fi)
82
{
83
V8M_SAttributes sattrs = {};
84
+ ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
85
+ bool secure = arm_space_is_secure(ptw->in_space);
86
bool ret;
87
88
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
89
@@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(uint64_t hcr,
90
* MMU disabled. S1 addresses within aa64 translation regimes are
91
* still checked for bounds -- see AArch64.S1DisabledOutput().
92
*/
93
-static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address,
94
+static bool get_phys_addr_disabled(CPUARMState *env,
95
+ S1Translate *ptw,
96
+ target_ulong address,
97
MMUAccessType access_type,
98
- ARMMMUIdx mmu_idx, bool is_secure,
99
GetPhysAddrResult *result,
100
ARMMMUFaultInfo *fi)
101
{
102
+ ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
103
+ bool is_secure = arm_space_is_secure(ptw->in_space);
104
uint8_t memattr = 0x00; /* Device nGnRnE */
105
uint8_t shareability = 0; /* non-shareable */
106
int r_el;
107
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
108
case ARMMMUIdx_Phys_Root:
109
case ARMMMUIdx_Phys_Realm:
110
/* Checking Phys early avoids special casing later vs regime_el. */
111
- return get_phys_addr_disabled(env, address, access_type, mmu_idx,
112
- is_secure, result, fi);
113
+ return get_phys_addr_disabled(env, ptw, address, access_type,
114
+ result, fi);
115
116
case ARMMMUIdx_Stage1_E0:
117
case ARMMMUIdx_Stage1_E1:
118
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
119
120
if (arm_feature(env, ARM_FEATURE_V8)) {
121
/* PMSAv8 */
122
- ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx,
123
- is_secure, result, fi);
124
+ ret = get_phys_addr_pmsav8(env, ptw, address, access_type,
125
+ result, fi);
126
} else if (arm_feature(env, ARM_FEATURE_V7)) {
127
/* PMSAv7 */
128
- ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
129
- is_secure, result, fi);
130
+ ret = get_phys_addr_pmsav7(env, ptw, address, access_type,
131
+ result, fi);
132
} else {
133
/* Pre-v7 MPU */
134
- ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
135
- is_secure, result, fi);
136
+ ret = get_phys_addr_pmsav5(env, ptw, address, access_type,
137
+ result, fi);
138
}
139
qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32
140
" mmu_idx %u -> %s (prot %c%c%c)\n",
141
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
142
/* Definitely a real MMU, not an MPU */
143
144
if (regime_translation_disabled(env, mmu_idx, is_secure)) {
145
- return get_phys_addr_disabled(env, address, access_type, mmu_idx,
146
- is_secure, result, fi);
147
+ return get_phys_addr_disabled(env, ptw, address, access_type,
148
+ result, fi);
149
}
150
151
if (regime_using_lpae_format(env, mmu_idx)) {
152
--
153
2.34.1
diff view generated by jsdifflib
Deleted patch
1
Plumb the ARMSecurityState through to regime_translation_disabled()
2
rather than just a bool is_secure.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230807141514.19075-6-peter.maydell@linaro.org
7
---
8
target/arm/ptw.c | 15 ++++++++-------
9
1 file changed, 8 insertions(+), 7 deletions(-)
10
11
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/ptw.c
14
+++ b/target/arm/ptw.c
15
@@ -XXX,XX +XXX,XX @@ static uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn)
16
17
/* Return true if the specified stage of address translation is disabled */
18
static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx,
19
- bool is_secure)
20
+ ARMSecuritySpace space)
21
{
22
uint64_t hcr_el2;
23
+ bool is_secure = arm_space_is_secure(space);
24
25
if (arm_feature(env, ARM_FEATURE_M)) {
26
switch (env->v7m.mpu_ctrl[is_secure] &
27
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env,
28
uint32_t base;
29
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
30
bool is_user = regime_is_user(env, mmu_idx);
31
- bool is_secure = arm_space_is_secure(ptw->in_space);
32
33
- if (regime_translation_disabled(env, mmu_idx, is_secure)) {
34
+ if (regime_translation_disabled(env, mmu_idx, ptw->in_space)) {
35
/* MPU disabled. */
36
result->f.phys_addr = address;
37
result->f.prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
38
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env,
39
result->f.lg_page_size = TARGET_PAGE_BITS;
40
result->f.prot = 0;
41
42
- if (regime_translation_disabled(env, mmu_idx, secure) ||
43
+ if (regime_translation_disabled(env, mmu_idx, ptw->in_space) ||
44
m_is_ppb_region(env, address)) {
45
/*
46
* MPU disabled or M profile PPB access: use default memory map.
47
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
48
* are done in arm_v7m_load_vector(), which always does a direct
49
* read using address_space_ldl(), rather than going via this function.
50
*/
51
- if (regime_translation_disabled(env, mmu_idx, secure)) { /* MPU disabled */
52
+ if (regime_translation_disabled(env, mmu_idx, arm_secure_to_space(secure))) {
53
+ /* MPU disabled */
54
hit = true;
55
} else if (m_is_ppb_region(env, address)) {
56
hit = true;
57
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
58
*/
59
ptw->in_mmu_idx = mmu_idx = s1_mmu_idx;
60
if (arm_feature(env, ARM_FEATURE_EL2) &&
61
- !regime_translation_disabled(env, ARMMMUIdx_Stage2, is_secure)) {
62
+ !regime_translation_disabled(env, ARMMMUIdx_Stage2, ptw->in_space)) {
63
return get_phys_addr_twostage(env, ptw, address, access_type,
64
result, fi);
65
}
66
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
67
68
/* Definitely a real MMU, not an MPU */
69
70
- if (regime_translation_disabled(env, mmu_idx, is_secure)) {
71
+ if (regime_translation_disabled(env, mmu_idx, ptw->in_space)) {
72
return get_phys_addr_disabled(env, ptw, address, access_type,
73
result, fi);
74
}
75
--
76
2.34.1
diff view generated by jsdifflib
Deleted patch
1
arm_hcr_el2_eff_secstate() takes a bool secure, which it uses to
2
determine whether EL2 is enabled in the current security state.
3
With the advent of FEAT_RME this is no longer sufficient, because
4
EL2 can be enabled for Secure state but not for Root, and both
5
of those will pass 'secure == true' in the callsites in ptw.c.
6
1
7
As it happens in all of our callsites in ptw.c we either avoid making
8
the call or else avoid using the returned value if we're doing a
9
translation for Root, so this is not a behaviour change even if the
10
experimental FEAT_RME is enabled. But it is less confusing in the
11
ptw.c code if we avoid the use of a bool secure that duplicates some
12
of the information in the ArmSecuritySpace argument.
13
14
Make arm_hcr_el2_eff_secstate() take an ARMSecuritySpace argument
15
instead. Because we always want to know the HCR_EL2 for the
16
security state defined by the current effective value of
17
SCR_EL3.{NSE,NS}, it makes no sense to pass ARMSS_Root here,
18
and we assert that callers don't do that.
19
20
To avoid the assert(), we thus push the call to
21
arm_hcr_el2_eff_secstate() down into the cases in
22
regime_translation_disabled() that need it, rather than calling the
23
function and ignoring the result for the Root space translations.
24
All other calls to this function in ptw.c are already in places
25
where we have confirmed that the mmu_idx is a stage 2 translation
26
or that the regime EL is not 3.
27
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
30
Message-id: 20230807141514.19075-7-peter.maydell@linaro.org
31
---
32
target/arm/cpu.h | 2 +-
33
target/arm/helper.c | 8 +++++---
34
target/arm/ptw.c | 15 +++++++--------
35
3 files changed, 13 insertions(+), 12 deletions(-)
36
37
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
38
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/cpu.h
40
+++ b/target/arm/cpu.h
41
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_el2_enabled(CPUARMState *env)
42
* "for all purposes other than a direct read or write access of HCR_EL2."
43
* Not included here is HCR_RW.
44
*/
45
-uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, bool secure);
46
+uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, ARMSecuritySpace space);
47
uint64_t arm_hcr_el2_eff(CPUARMState *env);
48
uint64_t arm_hcrx_el2_eff(CPUARMState *env);
49
50
diff --git a/target/arm/helper.c b/target/arm/helper.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/helper.c
53
+++ b/target/arm/helper.c
54
@@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri,
55
* Bits that are not included here:
56
* RW (read from SCR_EL3.RW as needed)
57
*/
58
-uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, bool secure)
59
+uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, ARMSecuritySpace space)
60
{
61
uint64_t ret = env->cp15.hcr_el2;
62
63
- if (!arm_is_el2_enabled_secstate(env, secure)) {
64
+ assert(space != ARMSS_Root);
65
+
66
+ if (!arm_is_el2_enabled_secstate(env, arm_space_is_secure(space))) {
67
/*
68
* "This register has no effect if EL2 is not enabled in the
69
* current Security state". This is ARMv8.4-SecEL2 speak for
70
@@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff(CPUARMState *env)
71
if (arm_feature(env, ARM_FEATURE_M)) {
72
return 0;
73
}
74
- return arm_hcr_el2_eff_secstate(env, arm_is_secure_below_el3(env));
75
+ return arm_hcr_el2_eff_secstate(env, arm_security_space_below_el3(env));
76
}
77
78
/*
79
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/target/arm/ptw.c
82
+++ b/target/arm/ptw.c
83
@@ -XXX,XX +XXX,XX @@ static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx,
84
ARMSecuritySpace space)
85
{
86
uint64_t hcr_el2;
87
- bool is_secure = arm_space_is_secure(space);
88
89
if (arm_feature(env, ARM_FEATURE_M)) {
90
+ bool is_secure = arm_space_is_secure(space);
91
switch (env->v7m.mpu_ctrl[is_secure] &
92
(R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) {
93
case R_V7M_MPU_CTRL_ENABLE_MASK:
94
@@ -XXX,XX +XXX,XX @@ static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx,
95
}
96
}
97
98
- hcr_el2 = arm_hcr_el2_eff_secstate(env, is_secure);
99
100
switch (mmu_idx) {
101
case ARMMMUIdx_Stage2:
102
case ARMMMUIdx_Stage2_S:
103
/* HCR.DC means HCR.VM behaves as 1 */
104
+ hcr_el2 = arm_hcr_el2_eff_secstate(env, space);
105
return (hcr_el2 & (HCR_DC | HCR_VM)) == 0;
106
107
case ARMMMUIdx_E10_0:
108
case ARMMMUIdx_E10_1:
109
case ARMMMUIdx_E10_1_PAN:
110
/* TGE means that EL0/1 act as if SCTLR_EL1.M is zero */
111
+ hcr_el2 = arm_hcr_el2_eff_secstate(env, space);
112
if (hcr_el2 & HCR_TGE) {
113
return true;
114
}
115
@@ -XXX,XX +XXX,XX @@ static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx,
116
case ARMMMUIdx_Stage1_E1:
117
case ARMMMUIdx_Stage1_E1_PAN:
118
/* HCR.DC means SCTLR_EL1.M behaves as 0 */
119
+ hcr_el2 = arm_hcr_el2_eff_secstate(env, space);
120
if (hcr_el2 & HCR_DC) {
121
return true;
122
}
123
@@ -XXX,XX +XXX,XX @@ static bool fault_s1ns(ARMSecuritySpace space, ARMMMUIdx s2_mmu_idx)
124
static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
125
hwaddr addr, ARMMMUFaultInfo *fi)
126
{
127
- bool is_secure = ptw->in_secure;
128
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
129
ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx;
130
uint8_t pte_attrs;
131
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
132
}
133
134
if (regime_is_stage2(s2_mmu_idx)) {
135
- uint64_t hcr = arm_hcr_el2_eff_secstate(env, is_secure);
136
+ uint64_t hcr = arm_hcr_el2_eff_secstate(env, ptw->in_space);
137
138
if ((hcr & HCR_PTW) && S2_attrs_are_device(hcr, pte_attrs)) {
139
/*
140
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_disabled(CPUARMState *env,
141
ARMMMUFaultInfo *fi)
142
{
143
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
144
- bool is_secure = arm_space_is_secure(ptw->in_space);
145
uint8_t memattr = 0x00; /* Device nGnRnE */
146
uint8_t shareability = 0; /* non-shareable */
147
int r_el;
148
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_disabled(CPUARMState *env,
149
150
/* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */
151
if (r_el == 1) {
152
- uint64_t hcr = arm_hcr_el2_eff_secstate(env, is_secure);
153
+ uint64_t hcr = arm_hcr_el2_eff_secstate(env, ptw->in_space);
154
if (hcr & HCR_DC) {
155
if (hcr & HCR_DCT) {
156
memattr = 0xf0; /* Tagged, Normal, WB, RWA */
157
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
158
{
159
hwaddr ipa;
160
int s1_prot, s1_lgpgsz;
161
- bool is_secure = ptw->in_secure;
162
ARMSecuritySpace in_space = ptw->in_space;
163
bool ret, ipa_secure;
164
ARMCacheAttrs cacheattrs1;
165
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
166
}
167
168
/* Combine the S1 and S2 cache attributes. */
169
- hcr = arm_hcr_el2_eff_secstate(env, is_secure);
170
+ hcr = arm_hcr_el2_eff_secstate(env, in_space);
171
if (hcr & HCR_DC) {
172
/*
173
* HCR.DC forces the first stage attributes to
174
--
175
2.34.1
diff view generated by jsdifflib
Deleted patch
1
Pass an ARMSecuritySpace instead of a bool secure to
2
arm_is_el2_enabled_secstate(). This doesn't change behaviour.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230807141514.19075-8-peter.maydell@linaro.org
7
---
8
target/arm/cpu.h | 13 ++++++++-----
9
target/arm/helper.c | 2 +-
10
2 files changed, 9 insertions(+), 6 deletions(-)
11
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.h
15
+++ b/target/arm/cpu.h
16
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env)
17
18
/*
19
* Return true if the current security state has AArch64 EL2 or AArch32 Hyp.
20
- * This corresponds to the pseudocode EL2Enabled()
21
+ * This corresponds to the pseudocode EL2Enabled().
22
*/
23
-static inline bool arm_is_el2_enabled_secstate(CPUARMState *env, bool secure)
24
+static inline bool arm_is_el2_enabled_secstate(CPUARMState *env,
25
+ ARMSecuritySpace space)
26
{
27
+ assert(space != ARMSS_Root);
28
return arm_feature(env, ARM_FEATURE_EL2)
29
- && (!secure || (env->cp15.scr_el3 & SCR_EEL2));
30
+ && (space != ARMSS_Secure || (env->cp15.scr_el3 & SCR_EEL2));
31
}
32
33
static inline bool arm_is_el2_enabled(CPUARMState *env)
34
{
35
- return arm_is_el2_enabled_secstate(env, arm_is_secure_below_el3(env));
36
+ return arm_is_el2_enabled_secstate(env, arm_security_space_below_el3(env));
37
}
38
39
#else
40
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env)
41
return false;
42
}
43
44
-static inline bool arm_is_el2_enabled_secstate(CPUARMState *env, bool secure)
45
+static inline bool arm_is_el2_enabled_secstate(CPUARMState *env,
46
+ ARMSecuritySpace space)
47
{
48
return false;
49
}
50
diff --git a/target/arm/helper.c b/target/arm/helper.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/helper.c
53
+++ b/target/arm/helper.c
54
@@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, ARMSecuritySpace space)
55
56
assert(space != ARMSS_Root);
57
58
- if (!arm_is_el2_enabled_secstate(env, arm_space_is_secure(space))) {
59
+ if (!arm_is_el2_enabled_secstate(env, space)) {
60
/*
61
* "This register has no effect if EL2 is not enabled in the
62
* current Security state". This is ARMv8.4-SecEL2 speak for
63
--
64
2.34.1
diff view generated by jsdifflib
Deleted patch
1
When we do a translation in Secure state, the NSTable bits in table
2
descriptors may downgrade us to NonSecure; we update ptw->in_secure
3
and ptw->in_space accordingly. We guard that check correctly with a
4
conditional that means it's only applied for Secure stage 1
5
translations. However, later on in get_phys_addr_lpae() we fold the
6
effects of the NSTable bits into the final descriptor attributes
7
bits, and there we do it unconditionally regardless of the CPU state.
8
That means that in Realm state (where in_secure is false) we will set
9
bit 5 in attrs, and later use it to decide to output to non-secure
10
space.
11
1
12
We don't in fact need to do this folding in at all any more (since
13
commit 2f1ff4e7b9f30c): if an NSTable bit was set then we have
14
already set ptw->in_space to ARMSS_NonSecure, and in that situation
15
we don't look at attrs bit 5. The only thing we still need to deal
16
with is the real NS bit in the final descriptor word, so we can just
17
drop the code that ORed in the NSTable bit.
18
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Message-id: 20230807141514.19075-9-peter.maydell@linaro.org
22
---
23
target/arm/ptw.c | 3 +--
24
1 file changed, 1 insertion(+), 2 deletions(-)
25
26
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/ptw.c
29
+++ b/target/arm/ptw.c
30
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
31
* Extract attributes from the (modified) descriptor, and apply
32
* table descriptors. Stage 2 table descriptors do not include
33
* any attribute fields. HPD disables all the table attributes
34
- * except NSTable.
35
+ * except NSTable (which we have already handled).
36
*/
37
attrs = new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
38
if (!regime_is_stage2(mmu_idx)) {
39
- attrs |= !ptw->in_secure << 5; /* NS */
40
if (!param.hpd) {
41
attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */
42
/*
43
--
44
2.34.1
diff view generated by jsdifflib
Deleted patch
1
Replace the last uses of ptw->in_secure with appropriate
2
checks on ptw->in_space.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230807141514.19075-10-peter.maydell@linaro.org
7
---
8
target/arm/ptw.c | 11 +++++++----
9
1 file changed, 7 insertions(+), 4 deletions(-)
10
11
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/ptw.c
14
+++ b/target/arm/ptw.c
15
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
16
ARMMMUFaultInfo *fi)
17
{
18
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
19
- bool is_secure = ptw->in_secure;
20
ARMMMUIdx s1_mmu_idx;
21
22
/*
23
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
24
* cannot upgrade a NonSecure translation regime's attributes
25
* to Secure or Realm.
26
*/
27
- result->f.attrs.secure = is_secure;
28
result->f.attrs.space = ptw->in_space;
29
+ result->f.attrs.secure = arm_space_is_secure(ptw->in_space);
30
31
switch (mmu_idx) {
32
case ARMMMUIdx_Phys_S:
33
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
34
case ARMMMUIdx_Stage1_E0:
35
case ARMMMUIdx_Stage1_E1:
36
case ARMMMUIdx_Stage1_E1_PAN:
37
- /* First stage lookup uses second stage for ptw. */
38
- ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
39
+ /*
40
+ * First stage lookup uses second stage for ptw; only
41
+ * Secure has both S and NS IPA and starts with Stage2_S.
42
+ */
43
+ ptw->in_ptw_idx = (ptw->in_space == ARMSS_Secure) ?
44
+ ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
45
break;
46
47
case ARMMMUIdx_Stage2:
48
--
49
2.34.1
diff view generated by jsdifflib
Deleted patch
1
We only use S1Translate::out_secure in two places, where we are
2
setting up MemTxAttrs for a page table load. We can use
3
arm_space_is_secure(ptw->out_space) instead, which guarantees
4
that we're setting the MemTxAttrs secure and space fields
5
consistently, and allows us to drop the out_secure field in
6
S1Translate entirely.
7
1
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230807141514.19075-12-peter.maydell@linaro.org
11
---
12
target/arm/ptw.c | 7 ++-----
13
1 file changed, 2 insertions(+), 5 deletions(-)
14
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/ptw.c
18
+++ b/target/arm/ptw.c
19
@@ -XXX,XX +XXX,XX @@ typedef struct S1Translate {
20
* Stage 2 is indicated by in_mmu_idx set to ARMMMUIdx_Stage2{,_S}.
21
*/
22
bool in_s1_is_el0;
23
- bool out_secure;
24
bool out_rw;
25
bool out_be;
26
ARMSecuritySpace out_space;
27
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
28
pte_attrs = s2.cacheattrs.attrs;
29
ptw->out_host = NULL;
30
ptw->out_rw = false;
31
- ptw->out_secure = s2.f.attrs.secure;
32
ptw->out_space = s2.f.attrs.space;
33
} else {
34
#ifdef CONFIG_TCG
35
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
36
ptw->out_phys = full->phys_addr | (addr & ~TARGET_PAGE_MASK);
37
ptw->out_rw = full->prot & PAGE_WRITE;
38
pte_attrs = full->pte_attrs;
39
- ptw->out_secure = full->attrs.secure;
40
ptw->out_space = full->attrs.space;
41
#else
42
g_assert_not_reached();
43
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw,
44
} else {
45
/* Page tables are in MMIO. */
46
MemTxAttrs attrs = {
47
- .secure = ptw->out_secure,
48
.space = ptw->out_space,
49
+ .secure = arm_space_is_secure(ptw->out_space),
50
};
51
AddressSpace *as = arm_addressspace(cs, attrs);
52
MemTxResult result = MEMTX_OK;
53
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw,
54
} else {
55
/* Page tables are in MMIO. */
56
MemTxAttrs attrs = {
57
- .secure = ptw->out_secure,
58
.space = ptw->out_space,
59
+ .secure = arm_space_is_secure(ptw->out_space),
60
};
61
AddressSpace *as = arm_addressspace(cs, attrs);
62
MemTxResult result = MEMTX_OK;
63
--
64
2.34.1
diff view generated by jsdifflib
Deleted patch
1
When the MMU is disabled, data accesses should be Device nGnRnE,
2
Outer Shareable, Untagged. We handle the other cases from
3
AArch64.S1DisabledOutput() correctly but missed this one.
4
Device nGnRnE is memattr == 0, so the only part we were missing
5
was that shareability should be set to 2 for both insn fetches
6
and data accesses.
7
1
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230807141514.19075-13-peter.maydell@linaro.org
11
---
12
target/arm/ptw.c | 12 +++++++-----
13
1 file changed, 7 insertions(+), 5 deletions(-)
14
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/ptw.c
18
+++ b/target/arm/ptw.c
19
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_disabled(CPUARMState *env,
20
}
21
}
22
}
23
- if (memattr == 0 && access_type == MMU_INST_FETCH) {
24
- if (regime_sctlr(env, mmu_idx) & SCTLR_I) {
25
- memattr = 0xee; /* Normal, WT, RA, NT */
26
- } else {
27
- memattr = 0x44; /* Normal, NC, No */
28
+ if (memattr == 0) {
29
+ if (access_type == MMU_INST_FETCH) {
30
+ if (regime_sctlr(env, mmu_idx) & SCTLR_I) {
31
+ memattr = 0xee; /* Normal, WT, RA, NT */
32
+ } else {
33
+ memattr = 0x44; /* Normal, NC, No */
34
+ }
35
}
36
shareability = 2; /* outer shareable */
37
}
38
--
39
2.34.1
diff view generated by jsdifflib
Deleted patch
1
The architecture doesn't permit block descriptors at any arbitrary
2
level of the page table walk; it depends on the granule size which
3
levels are permitted. We implemented only a partial version of this
4
check which assumes that block descriptors are valid at all levels
5
except level 3, which meant that we wouldn't deliver the Translation
6
fault for all cases of this sort of guest page table error.
7
1
8
Implement the logic corresponding to the pseudocode
9
AArch64.DecodeDescriptorType() and AArch64.BlockDescSupported().
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20230807141514.19075-14-peter.maydell@linaro.org
14
---
15
target/arm/ptw.c | 25 +++++++++++++++++++++++--
16
1 file changed, 23 insertions(+), 2 deletions(-)
17
18
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/ptw.c
21
+++ b/target/arm/ptw.c
22
@@ -XXX,XX +XXX,XX @@ static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr,
23
return INT_MIN;
24
}
25
26
+static bool lpae_block_desc_valid(ARMCPU *cpu, bool ds,
27
+ ARMGranuleSize gran, int level)
28
+{
29
+ /*
30
+ * See pseudocode AArch46.BlockDescSupported(): block descriptors
31
+ * are not valid at all levels, depending on the page size.
32
+ */
33
+ switch (gran) {
34
+ case Gran4K:
35
+ return (level == 0 && ds) || level == 1 || level == 2;
36
+ case Gran16K:
37
+ return (level == 1 && ds) || level == 2;
38
+ case Gran64K:
39
+ return (level == 1 && arm_pamax(cpu) == 52) || level == 2;
40
+ default:
41
+ g_assert_not_reached();
42
+ }
43
+}
44
+
45
/**
46
* get_phys_addr_lpae: perform one stage of page table walk, LPAE format
47
*
48
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
49
new_descriptor = descriptor;
50
51
restart_atomic_update:
52
- if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) {
53
- /* Invalid, or the Reserved level 3 encoding */
54
+ if (!(descriptor & 1) ||
55
+ (!(descriptor & 2) &&
56
+ !lpae_block_desc_valid(cpu, param.ds, param.gran, level))) {
57
+ /* Invalid, or a block descriptor at an invalid level */
58
goto do_translation_fault;
59
}
60
61
--
62
2.34.1
diff view generated by jsdifflib
Deleted patch
1
When we report faults due to stage 2 faults during a stage 1
2
page table walk, the 'level' parameter should be the level
3
of the walk in stage 2 that faulted, not the level of the
4
walk in stage 1. Correct the reporting of these faults.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230807141514.19075-15-peter.maydell@linaro.org
9
---
10
target/arm/ptw.c | 10 +++++++---
11
1 file changed, 7 insertions(+), 3 deletions(-)
12
13
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/ptw.c
16
+++ b/target/arm/ptw.c
17
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
18
do_translation_fault:
19
fi->type = ARMFault_Translation;
20
do_fault:
21
- fi->level = level;
22
- /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
23
- fi->stage2 = fi->s1ptw || regime_is_stage2(mmu_idx);
24
+ if (fi->s1ptw) {
25
+ /* Retain the existing stage 2 fi->level */
26
+ assert(fi->stage2);
27
+ } else {
28
+ fi->level = level;
29
+ fi->stage2 = regime_is_stage2(mmu_idx);
30
+ }
31
fi->s1ns = fault_s1ns(ptw->in_space, mmu_idx);
32
return true;
33
}
34
--
35
2.34.1
diff view generated by jsdifflib
Deleted patch
1
The PAR_EL1.SH field documents that for the cases of:
2
* Device memory
3
* Normal memory with both Inner and Outer Non-Cacheable
4
the field should be 0b10 rather than whatever was in the
5
translation table descriptor field. (In the pseudocode this
6
is handled by PAREncodeShareability().) Perform this
7
adjustment when assembling a PAR value.
8
1
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20230807141514.19075-16-peter.maydell@linaro.org
12
---
13
target/arm/helper.c | 15 ++++++++++++++-
14
1 file changed, 14 insertions(+), 1 deletion(-)
15
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper.c
19
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri,
21
}
22
23
#ifdef CONFIG_TCG
24
+static int par_el1_shareability(GetPhysAddrResult *res)
25
+{
26
+ /*
27
+ * The PAR_EL1.SH field must be 0b10 for Device or Normal-NC
28
+ * memory -- see pseudocode PAREncodeShareability().
29
+ */
30
+ if (((res->cacheattrs.attrs & 0xf0) == 0) ||
31
+ res->cacheattrs.attrs == 0x44 || res->cacheattrs.attrs == 0x40) {
32
+ return 2;
33
+ }
34
+ return res->cacheattrs.shareability;
35
+}
36
+
37
static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
38
MMUAccessType access_type, ARMMMUIdx mmu_idx,
39
bool is_secure)
40
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
41
par64 |= (1 << 9); /* NS */
42
}
43
par64 |= (uint64_t)res.cacheattrs.attrs << 56; /* ATTR */
44
- par64 |= res.cacheattrs.shareability << 7; /* SH */
45
+ par64 |= par_el1_shareability(&res) << 7; /* SH */
46
} else {
47
uint32_t fsr = arm_fi_to_lfsc(&fi);
48
49
--
50
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
2
1
3
In realm state, stage-2 translation tables are fetched from the realm
4
physical address space (R_PGRQD).
5
6
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20230809123706.1842548-2-jean-philippe@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/ptw.c | 26 ++++++++++++++++++--------
12
1 file changed, 18 insertions(+), 8 deletions(-)
13
14
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/ptw.c
17
+++ b/target/arm/ptw.c
18
@@ -XXX,XX +XXX,XX @@ static ARMMMUIdx ptw_idx_for_stage_2(CPUARMState *env, ARMMMUIdx stage2idx)
19
20
/*
21
* We're OK to check the current state of the CPU here because
22
- * (1) we always invalidate all TLBs when the SCR_EL3.NS bit changes
23
+ * (1) we always invalidate all TLBs when the SCR_EL3.NS or SCR_EL3.NSE bit
24
+ * changes.
25
* (2) there's no way to do a lookup that cares about Stage 2 for a
26
* different security state to the current one for AArch64, and AArch32
27
* never has a secure EL2. (AArch32 ATS12NSO[UP][RW] allow EL3 to do
28
* an NS stage 1+2 lookup while the NS bit is 0.)
29
*/
30
- if (!arm_is_secure_below_el3(env) || !arm_el_is_aa64(env, 3)) {
31
+ if (!arm_el_is_aa64(env, 3)) {
32
return ARMMMUIdx_Phys_NS;
33
}
34
- if (stage2idx == ARMMMUIdx_Stage2_S) {
35
- s2walk_secure = !(env->cp15.vstcr_el2 & VSTCR_SW);
36
- } else {
37
- s2walk_secure = !(env->cp15.vtcr_el2 & VTCR_NSW);
38
- }
39
- return s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
40
41
+ switch (arm_security_space_below_el3(env)) {
42
+ case ARMSS_NonSecure:
43
+ return ARMMMUIdx_Phys_NS;
44
+ case ARMSS_Realm:
45
+ return ARMMMUIdx_Phys_Realm;
46
+ case ARMSS_Secure:
47
+ if (stage2idx == ARMMMUIdx_Stage2_S) {
48
+ s2walk_secure = !(env->cp15.vstcr_el2 & VSTCR_SW);
49
+ } else {
50
+ s2walk_secure = !(env->cp15.vtcr_el2 & VTCR_NSW);
51
+ }
52
+ return s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
53
+ default:
54
+ g_assert_not_reached();
55
+ }
56
}
57
58
static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx)
59
--
60
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
2
1
3
When HCR_EL2.E2H is enabled, TLB entries are formed using the EL2&0
4
translation regime, instead of the EL2 translation regime. The TLB VAE2*
5
instructions invalidate the regime that corresponds to the current value
6
of HCR_EL2.E2H.
7
8
At the moment we only invalidate the EL2 translation regime. This causes
9
problems with RMM, which issues TLBI VAE2IS instructions with
10
HCR_EL2.E2H enabled. Update vae2_tlbmask() to take HCR_EL2.E2H into
11
account.
12
13
Add vae2_tlbbits() as well, since the top-byte-ignore configuration is
14
different between the EL2&0 and EL2 regime.
15
16
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Message-id: 20230809123706.1842548-3-jean-philippe@linaro.org
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
target/arm/helper.c | 50 ++++++++++++++++++++++++++++++++++++---------
22
1 file changed, 40 insertions(+), 10 deletions(-)
23
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/helper.c
27
+++ b/target/arm/helper.c
28
@@ -XXX,XX +XXX,XX @@ static int vae1_tlbmask(CPUARMState *env)
29
return mask;
30
}
31
32
+static int vae2_tlbmask(CPUARMState *env)
33
+{
34
+ uint64_t hcr = arm_hcr_el2_eff(env);
35
+ uint16_t mask;
36
+
37
+ if (hcr & HCR_E2H) {
38
+ mask = ARMMMUIdxBit_E20_2 |
39
+ ARMMMUIdxBit_E20_2_PAN |
40
+ ARMMMUIdxBit_E20_0;
41
+ } else {
42
+ mask = ARMMMUIdxBit_E2;
43
+ }
44
+ return mask;
45
+}
46
+
47
/* Return 56 if TBI is enabled, 64 otherwise. */
48
static int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx,
49
uint64_t addr)
50
@@ -XXX,XX +XXX,XX @@ static int vae1_tlbbits(CPUARMState *env, uint64_t addr)
51
return tlbbits_for_regime(env, mmu_idx, addr);
52
}
53
54
+static int vae2_tlbbits(CPUARMState *env, uint64_t addr)
55
+{
56
+ uint64_t hcr = arm_hcr_el2_eff(env);
57
+ ARMMMUIdx mmu_idx;
58
+
59
+ /*
60
+ * Only the regime of the mmu_idx below is significant.
61
+ * Regime EL2&0 has two ranges with separate TBI configuration, while EL2
62
+ * only has one.
63
+ */
64
+ if (hcr & HCR_E2H) {
65
+ mmu_idx = ARMMMUIdx_E20_2;
66
+ } else {
67
+ mmu_idx = ARMMMUIdx_E2;
68
+ }
69
+
70
+ return tlbbits_for_regime(env, mmu_idx, addr);
71
+}
72
+
73
static void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
74
uint64_t value)
75
{
76
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri,
77
* flush-last-level-only.
78
*/
79
CPUState *cs = env_cpu(env);
80
- int mask = e2_tlbmask(env);
81
+ int mask = vae2_tlbmask(env);
82
uint64_t pageaddr = sextract64(value << 12, 0, 56);
83
+ int bits = vae2_tlbbits(env, pageaddr);
84
85
- tlb_flush_page_by_mmuidx(cs, pageaddr, mask);
86
+ tlb_flush_page_bits_by_mmuidx(cs, pageaddr, mask, bits);
87
}
88
89
static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri,
90
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
91
uint64_t value)
92
{
93
CPUState *cs = env_cpu(env);
94
+ int mask = vae2_tlbmask(env);
95
uint64_t pageaddr = sextract64(value << 12, 0, 56);
96
- int bits = tlbbits_for_regime(env, ARMMMUIdx_E2, pageaddr);
97
+ int bits = vae2_tlbbits(env, pageaddr);
98
99
- tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr,
100
- ARMMMUIdxBit_E2, bits);
101
+ tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits);
102
}
103
104
static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
105
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_rvae1is_write(CPUARMState *env,
106
do_rvae_write(env, value, vae1_tlbmask(env), true);
107
}
108
109
-static int vae2_tlbmask(CPUARMState *env)
110
-{
111
- return ARMMMUIdxBit_E2;
112
-}
113
-
114
static void tlbi_aa64_rvae2_write(CPUARMState *env,
115
const ARMCPRegInfo *ri,
116
uint64_t value)
117
--
118
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
2
1
3
GPC checks are not performed on the output address for AT instructions,
4
as stated by ARM DDI 0487J in D8.12.2:
5
6
When populating PAR_EL1 with the result of an address translation
7
instruction, granule protection checks are not performed on the final
8
output address of a successful translation.
9
10
Rename get_phys_addr_with_secure(), since it's only used to handle AT
11
instructions.
12
13
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Message-id: 20230809123706.1842548-4-jean-philippe@linaro.org
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
target/arm/internals.h | 25 ++++++++++++++-----------
19
target/arm/helper.c | 8 ++++++--
20
target/arm/ptw.c | 11 ++++++-----
21
3 files changed, 26 insertions(+), 18 deletions(-)
22
23
diff --git a/target/arm/internals.h b/target/arm/internals.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/internals.h
26
+++ b/target/arm/internals.h
27
@@ -XXX,XX +XXX,XX @@ typedef struct GetPhysAddrResult {
28
} GetPhysAddrResult;
29
30
/**
31
- * get_phys_addr_with_secure: get the physical address for a virtual address
32
+ * get_phys_addr: get the physical address for a virtual address
33
* @env: CPUARMState
34
* @address: virtual address to get physical address for
35
* @access_type: 0 for read, 1 for write, 2 for execute
36
* @mmu_idx: MMU index indicating required translation regime
37
- * @is_secure: security state for the access
38
* @result: set on translation success.
39
* @fi: set to fault info if the translation fails
40
*
41
@@ -XXX,XX +XXX,XX @@ typedef struct GetPhysAddrResult {
42
* * for PSMAv5 based systems we don't bother to return a full FSR format
43
* value.
44
*/
45
-bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address,
46
- MMUAccessType access_type,
47
- ARMMMUIdx mmu_idx, bool is_secure,
48
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
49
+bool get_phys_addr(CPUARMState *env, target_ulong address,
50
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
51
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
52
__attribute__((nonnull));
53
54
/**
55
- * get_phys_addr: get the physical address for a virtual address
56
+ * get_phys_addr_with_secure_nogpc: get the physical address for a virtual
57
+ * address
58
* @env: CPUARMState
59
* @address: virtual address to get physical address for
60
* @access_type: 0 for read, 1 for write, 2 for execute
61
* @mmu_idx: MMU index indicating required translation regime
62
+ * @is_secure: security state for the access
63
* @result: set on translation success.
64
* @fi: set to fault info if the translation fails
65
*
66
- * Similarly, but use the security regime of @mmu_idx.
67
+ * Similar to get_phys_addr, but use the given security regime and don't perform
68
+ * a Granule Protection Check on the resulting address.
69
*/
70
-bool get_phys_addr(CPUARMState *env, target_ulong address,
71
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
72
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
73
+bool get_phys_addr_with_secure_nogpc(CPUARMState *env, target_ulong address,
74
+ MMUAccessType access_type,
75
+ ARMMMUIdx mmu_idx, bool is_secure,
76
+ GetPhysAddrResult *result,
77
+ ARMMMUFaultInfo *fi)
78
__attribute__((nonnull));
79
80
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
81
diff --git a/target/arm/helper.c b/target/arm/helper.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/target/arm/helper.c
84
+++ b/target/arm/helper.c
85
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
86
ARMMMUFaultInfo fi = {};
87
GetPhysAddrResult res = {};
88
89
- ret = get_phys_addr_with_secure(env, value, access_type, mmu_idx,
90
- is_secure, &res, &fi);
91
+ /*
92
+ * I_MXTJT: Granule protection checks are not performed on the final address
93
+ * of a successful translation.
94
+ */
95
+ ret = get_phys_addr_with_secure_nogpc(env, value, access_type, mmu_idx,
96
+ is_secure, &res, &fi);
97
98
/*
99
* ATS operations only do S1 or S1+S2 translations, so we never
100
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/target/arm/ptw.c
103
+++ b/target/arm/ptw.c
104
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw,
105
return false;
106
}
107
108
-bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address,
109
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
110
- bool is_secure, GetPhysAddrResult *result,
111
- ARMMMUFaultInfo *fi)
112
+bool get_phys_addr_with_secure_nogpc(CPUARMState *env, target_ulong address,
113
+ MMUAccessType access_type,
114
+ ARMMMUIdx mmu_idx, bool is_secure,
115
+ GetPhysAddrResult *result,
116
+ ARMMMUFaultInfo *fi)
117
{
118
S1Translate ptw = {
119
.in_mmu_idx = mmu_idx,
120
.in_space = arm_secure_to_space(is_secure),
121
};
122
- return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi);
123
+ return get_phys_addr_nogpc(env, &ptw, address, access_type, result, fi);
124
}
125
126
bool get_phys_addr(CPUARMState *env, target_ulong address,
127
--
128
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
2
1
3
The AT instruction is UNDEFINED if the {NSE,NS} configuration is
4
invalid. Add a function to check this on all AT instructions that apply
5
to an EL lower than 3.
6
7
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
9
Message-id: 20230809123706.1842548-6-jean-philippe@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/helper.c | 38 +++++++++++++++++++++++++++-----------
14
1 file changed, 27 insertions(+), 11 deletions(-)
15
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper.c
19
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri,
21
#endif /* CONFIG_TCG */
22
}
23
24
+static CPAccessResult at_e012_access(CPUARMState *env, const ARMCPRegInfo *ri,
25
+ bool isread)
26
+{
27
+ /*
28
+ * R_NYXTL: instruction is UNDEFINED if it applies to an Exception level
29
+ * lower than EL3 and the combination SCR_EL3.{NSE,NS} is reserved. This can
30
+ * only happen when executing at EL3 because that combination also causes an
31
+ * illegal exception return. We don't need to check FEAT_RME either, because
32
+ * scr_write() ensures that the NSE bit is not set otherwise.
33
+ */
34
+ if ((env->cp15.scr_el3 & (SCR_NSE | SCR_NS)) == SCR_NSE) {
35
+ return CP_ACCESS_TRAP;
36
+ }
37
+ return CP_ACCESS_OK;
38
+}
39
+
40
static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri,
41
bool isread)
42
{
43
@@ -XXX,XX +XXX,XX @@ static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri,
44
!(env->cp15.scr_el3 & (SCR_NS | SCR_EEL2))) {
45
return CP_ACCESS_TRAP;
46
}
47
- return CP_ACCESS_OK;
48
+ return at_e012_access(env, ri, isread);
49
}
50
51
static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
52
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
53
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 0,
54
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
55
.fgt = FGT_ATS1E1R,
56
- .writefn = ats_write64 },
57
+ .accessfn = at_e012_access, .writefn = ats_write64 },
58
{ .name = "AT_S1E1W", .state = ARM_CP_STATE_AA64,
59
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 1,
60
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
61
.fgt = FGT_ATS1E1W,
62
- .writefn = ats_write64 },
63
+ .accessfn = at_e012_access, .writefn = ats_write64 },
64
{ .name = "AT_S1E0R", .state = ARM_CP_STATE_AA64,
65
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 2,
66
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
67
.fgt = FGT_ATS1E0R,
68
- .writefn = ats_write64 },
69
+ .accessfn = at_e012_access, .writefn = ats_write64 },
70
{ .name = "AT_S1E0W", .state = ARM_CP_STATE_AA64,
71
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 3,
72
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
73
.fgt = FGT_ATS1E0W,
74
- .writefn = ats_write64 },
75
+ .accessfn = at_e012_access, .writefn = ats_write64 },
76
{ .name = "AT_S12E1R", .state = ARM_CP_STATE_AA64,
77
.opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 4,
78
.access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
79
- .writefn = ats_write64 },
80
+ .accessfn = at_e012_access, .writefn = ats_write64 },
81
{ .name = "AT_S12E1W", .state = ARM_CP_STATE_AA64,
82
.opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 5,
83
.access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
84
- .writefn = ats_write64 },
85
+ .accessfn = at_e012_access, .writefn = ats_write64 },
86
{ .name = "AT_S12E0R", .state = ARM_CP_STATE_AA64,
87
.opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 6,
88
.access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
89
- .writefn = ats_write64 },
90
+ .accessfn = at_e012_access, .writefn = ats_write64 },
91
{ .name = "AT_S12E0W", .state = ARM_CP_STATE_AA64,
92
.opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 7,
93
.access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
94
- .writefn = ats_write64 },
95
+ .accessfn = at_e012_access, .writefn = ats_write64 },
96
/* AT S1E2* are elsewhere as they UNDEF from EL3 if EL2 is not present */
97
{ .name = "AT_S1E3R", .state = ARM_CP_STATE_AA64,
98
.opc0 = 1, .opc1 = 6, .crn = 7, .crm = 8, .opc2 = 0,
99
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1e1_reginfo[] = {
100
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0,
101
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
102
.fgt = FGT_ATS1E1RP,
103
- .writefn = ats_write64 },
104
+ .accessfn = at_e012_access, .writefn = ats_write64 },
105
{ .name = "AT_S1E1WP", .state = ARM_CP_STATE_AA64,
106
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1,
107
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
108
.fgt = FGT_ATS1E1WP,
109
- .writefn = ats_write64 },
110
+ .accessfn = at_e012_access, .writefn = ats_write64 },
111
};
112
113
static const ARMCPRegInfo ats1cp_reginfo[] = {
114
--
115
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
2
1
3
When FEAT_RME is implemented, these bits override the value of
4
CNT[VP]_CTL_EL0.IMASK in Realm and Root state. Move the IRQ state update
5
into a new gt_update_irq() function and test those bits every time we
6
recompute the IRQ state.
7
8
Since we're removing the IRQ state from some trace events, add a new
9
trace event for gt_update_irq().
10
11
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
12
Message-id: 20230809123706.1842548-7-jean-philippe@linaro.org
13
[PMM: only register change hook if not USER_ONLY and if TCG]
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
target/arm/cpu.h | 4 +++
18
target/arm/cpu.c | 6 ++++
19
target/arm/helper.c | 65 ++++++++++++++++++++++++++++++++++-------
20
target/arm/trace-events | 7 +++--
21
4 files changed, 68 insertions(+), 14 deletions(-)
22
23
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/cpu.h
26
+++ b/target/arm/cpu.h
27
@@ -XXX,XX +XXX,XX @@ struct ArchCPU {
28
};
29
30
unsigned int gt_cntfrq_period_ns(ARMCPU *cpu);
31
+void gt_rme_post_el_change(ARMCPU *cpu, void *opaque);
32
33
void arm_cpu_post_init(Object *obj);
34
35
@@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
36
#define HSTR_TTEE (1 << 16)
37
#define HSTR_TJDBX (1 << 17)
38
39
+#define CNTHCTL_CNTVMASK (1 << 18)
40
+#define CNTHCTL_CNTPMASK (1 << 19)
41
+
42
/* Return the current FPSCR value. */
43
uint32_t vfp_get_fpscr(CPUARMState *env);
44
void vfp_set_fpscr(CPUARMState *env, uint32_t val);
45
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/cpu.c
48
+++ b/target/arm/cpu.c
49
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
50
set_feature(env, ARM_FEATURE_VBAR);
51
}
52
53
+#ifndef CONFIG_USER_ONLY
54
+ if (tcg_enabled() && cpu_isar_feature(aa64_rme, cpu)) {
55
+ arm_register_el_change_hook(cpu, &gt_rme_post_el_change, 0);
56
+ }
57
+#endif
58
+
59
register_cp_regs_for_features(cpu);
60
arm_cpu_register_gdb_regs_for_features(cpu);
61
62
diff --git a/target/arm/helper.c b/target/arm/helper.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/target/arm/helper.c
65
+++ b/target/arm/helper.c
66
@@ -XXX,XX +XXX,XX @@ static uint64_t gt_get_countervalue(CPUARMState *env)
67
return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / gt_cntfrq_period_ns(cpu);
68
}
69
70
+static void gt_update_irq(ARMCPU *cpu, int timeridx)
71
+{
72
+ CPUARMState *env = &cpu->env;
73
+ uint64_t cnthctl = env->cp15.cnthctl_el2;
74
+ ARMSecuritySpace ss = arm_security_space(env);
75
+ /* ISTATUS && !IMASK */
76
+ int irqstate = (env->cp15.c14_timer[timeridx].ctl & 6) == 4;
77
+
78
+ /*
79
+ * If bit CNTHCTL_EL2.CNT[VP]MASK is set, it overrides IMASK.
80
+ * It is RES0 in Secure and NonSecure state.
81
+ */
82
+ if ((ss == ARMSS_Root || ss == ARMSS_Realm) &&
83
+ ((timeridx == GTIMER_VIRT && (cnthctl & CNTHCTL_CNTVMASK)) ||
84
+ (timeridx == GTIMER_PHYS && (cnthctl & CNTHCTL_CNTPMASK)))) {
85
+ irqstate = 0;
86
+ }
87
+
88
+ qemu_set_irq(cpu->gt_timer_outputs[timeridx], irqstate);
89
+ trace_arm_gt_update_irq(timeridx, irqstate);
90
+}
91
+
92
+void gt_rme_post_el_change(ARMCPU *cpu, void *ignored)
93
+{
94
+ /*
95
+ * Changing security state between Root and Secure/NonSecure, which may
96
+ * happen when switching EL, can change the effective value of CNTHCTL_EL2
97
+ * mask bits. Update the IRQ state accordingly.
98
+ */
99
+ gt_update_irq(cpu, GTIMER_VIRT);
100
+ gt_update_irq(cpu, GTIMER_PHYS);
101
+}
102
+
103
static void gt_recalc_timer(ARMCPU *cpu, int timeridx)
104
{
105
ARMGenericTimer *gt = &cpu->env.cp15.c14_timer[timeridx];
106
@@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx)
107
/* Note that this must be unsigned 64 bit arithmetic: */
108
int istatus = count - offset >= gt->cval;
109
uint64_t nexttick;
110
- int irqstate;
111
112
gt->ctl = deposit32(gt->ctl, 2, 1, istatus);
113
114
- irqstate = (istatus && !(gt->ctl & 2));
115
- qemu_set_irq(cpu->gt_timer_outputs[timeridx], irqstate);
116
-
117
if (istatus) {
118
/* Next transition is when count rolls back over to zero */
119
nexttick = UINT64_MAX;
120
@@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx)
121
} else {
122
timer_mod(cpu->gt_timer[timeridx], nexttick);
123
}
124
- trace_arm_gt_recalc(timeridx, irqstate, nexttick);
125
+ trace_arm_gt_recalc(timeridx, nexttick);
126
} else {
127
/* Timer disabled: ISTATUS and timer output always clear */
128
gt->ctl &= ~4;
129
- qemu_set_irq(cpu->gt_timer_outputs[timeridx], 0);
130
timer_del(cpu->gt_timer[timeridx]);
131
trace_arm_gt_recalc_disabled(timeridx);
132
}
133
+ gt_update_irq(cpu, timeridx);
134
}
135
136
static void gt_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri,
137
@@ -XXX,XX +XXX,XX @@ static void gt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri,
138
* IMASK toggled: don't need to recalculate,
139
* just set the interrupt line based on ISTATUS
140
*/
141
- int irqstate = (oldval & 4) && !(value & 2);
142
-
143
- trace_arm_gt_imask_toggle(timeridx, irqstate);
144
- qemu_set_irq(cpu->gt_timer_outputs[timeridx], irqstate);
145
+ trace_arm_gt_imask_toggle(timeridx);
146
+ gt_update_irq(cpu, timeridx);
147
}
148
}
149
150
@@ -XXX,XX +XXX,XX @@ static void gt_virt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri,
151
gt_ctl_write(env, ri, GTIMER_VIRT, value);
152
}
153
154
+static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri,
155
+ uint64_t value)
156
+{
157
+ ARMCPU *cpu = env_archcpu(env);
158
+ uint32_t oldval = env->cp15.cnthctl_el2;
159
+
160
+ raw_write(env, ri, value);
161
+
162
+ if ((oldval ^ value) & CNTHCTL_CNTVMASK) {
163
+ gt_update_irq(cpu, GTIMER_VIRT);
164
+ } else if ((oldval ^ value) & CNTHCTL_CNTPMASK) {
165
+ gt_update_irq(cpu, GTIMER_PHYS);
166
+ }
167
+}
168
+
169
static void gt_cntvoff_write(CPUARMState *env, const ARMCPRegInfo *ri,
170
uint64_t value)
171
{
172
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
173
* reset values as IMPDEF. We choose to reset to 3 to comply with
174
* both ARMv7 and ARMv8.
175
*/
176
- .access = PL2_RW, .resetvalue = 3,
177
+ .access = PL2_RW, .type = ARM_CP_IO, .resetvalue = 3,
178
+ .writefn = gt_cnthctl_write, .raw_writefn = raw_write,
179
.fieldoffset = offsetof(CPUARMState, cp15.cnthctl_el2) },
180
{ .name = "CNTVOFF_EL2", .state = ARM_CP_STATE_AA64,
181
.opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 3,
182
diff --git a/target/arm/trace-events b/target/arm/trace-events
183
index XXXXXXX..XXXXXXX 100644
184
--- a/target/arm/trace-events
185
+++ b/target/arm/trace-events
186
@@ -XXX,XX +XXX,XX @@
187
# See docs/devel/tracing.rst for syntax documentation.
188
189
# helper.c
190
-arm_gt_recalc(int timer, int irqstate, uint64_t nexttick) "gt recalc: timer %d irqstate %d next tick 0x%" PRIx64
191
-arm_gt_recalc_disabled(int timer) "gt recalc: timer %d irqstate 0 timer disabled"
192
+arm_gt_recalc(int timer, uint64_t nexttick) "gt recalc: timer %d next tick 0x%" PRIx64
193
+arm_gt_recalc_disabled(int timer) "gt recalc: timer %d timer disabled"
194
arm_gt_cval_write(int timer, uint64_t value) "gt_cval_write: timer %d value 0x%" PRIx64
195
arm_gt_tval_write(int timer, uint64_t value) "gt_tval_write: timer %d value 0x%" PRIx64
196
arm_gt_ctl_write(int timer, uint64_t value) "gt_ctl_write: timer %d value 0x%" PRIx64
197
-arm_gt_imask_toggle(int timer, int irqstate) "gt_ctl_write: timer %d IMASK toggle, new irqstate %d"
198
+arm_gt_imask_toggle(int timer) "gt_ctl_write: timer %d IMASK toggle"
199
arm_gt_cntvoff_write(uint64_t value) "gt_cntvoff_write: value 0x%" PRIx64
200
+arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d"
201
202
# kvm.c
203
kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64
204
--
205
2.34.1
diff view generated by jsdifflib