1 | A big pullreq by number of patches, but most of them are just docs | 1 | Hi; here's the first arm pullreq for the 8.2 cycle. These are |
---|---|---|---|
2 | updates or MAINTAINERS file fixes. The actual code changes are pretty | 2 | pretty much all bug fixes (mostly for the experimental FEAT_RME), |
3 | minimal bugfixes. | 3 | rather than any major features. |
4 | 4 | ||
5 | thanks | ||
6 | -- PMM | 5 | -- PMM |
7 | 6 | ||
8 | The following changes since commit 8cc30eb1400fc01f2b139cdd3dc524f8b84dbe07: | 7 | The following changes since commit b0dd9a7d6dd15a6898e9c585b521e6bec79b25aa: |
9 | 8 | ||
10 | Merge remote-tracking branch 'remotes/mcayland/tags/qemu-sparc-20201122' into staging (2020-11-22 15:02:52 +0000) | 9 | Open 8.2 development tree (2023-08-22 07:14:07 -0700) |
11 | 10 | ||
12 | are available in the Git repository at: | 11 | are available in the Git repository at: |
13 | 12 | ||
14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201123 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230824 |
15 | 14 | ||
16 | for you to fetch changes up to c6ff78563ad2971f289168c7cae6ecb0b4359516: | 15 | for you to fetch changes up to cd1e4db73646006039f25879af3bff55b2295ff3: |
17 | 16 | ||
18 | docs/system/pr-manager.rst: Fix minor docs nits (2020-11-23 11:10:04 +0000) | 17 | target/arm: Fix 64-bit SSRA (2023-08-22 17:31:14 +0100) |
19 | 18 | ||
20 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
21 | target-arm queue: | 20 | target-arm queue: |
22 | * incorporate 'orphan' rST docs into manuals | 21 | * hw/gpio/nrf51: implement DETECT signal |
23 | * linux-user/arm: Deliver SIGTRAP for UDF patterns used as breakpoints | 22 | * accel/kvm: Specify default IPA size for arm64 |
24 | * target/arm: Make SYS_HEAPINFO work with RAM that doesn't start at 0 | 23 | * ptw: refactor, fix some FEAT_RME bugs |
25 | * document raspi boards and tosa | 24 | * target/arm: Adjust PAR_EL1.SH for Device and Normal-NC memory types |
26 | * docs/system: Deprecate raspi2/raspi3 machine aliases | 25 | * target/arm/helper: Implement CNTHCTL_EL2.CNT[VP]MASK |
27 | * docs/system/arm: Document OpenPOWER Witherspoon BMC model Front LEDs | 26 | * Fix SME ST1Q |
28 | * MAINTAINERS: add lines for docs files for Arm boards | 27 | * Fix 64-bit SSRA |
29 | * hw/intc: fix heap-buffer-overflow in rxicu_realize() | ||
30 | * hw/arm: Fix bad print format specifiers | ||
31 | * target/arm: fix stage 2 page-walks in 32-bit emulation | ||
32 | 28 | ||
33 | ---------------------------------------------------------------- | 29 | ---------------------------------------------------------------- |
34 | AlexChen (1): | 30 | Akihiko Odaki (6): |
35 | hw/arm: Fix bad print format specifiers | 31 | kvm: Introduce kvm_arch_get_default_type hook |
32 | accel/kvm: Specify default IPA size for arm64 | ||
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 | ||
36 | 37 | ||
37 | Chen Qun (1): | 38 | Chris Laplante (6): |
38 | hw/intc: fix heap-buffer-overflow in rxicu_realize() | 39 | hw/gpio/nrf51: implement DETECT signal |
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 | ||
39 | 45 | ||
40 | Peter Maydell (11): | 46 | Jean-Philippe Brucker (6): |
41 | target/arm: Make SYS_HEAPINFO work with RAM that doesn't start at 0 | 47 | target/arm/ptw: Load stage-2 tables from realm physical space |
42 | linux-user/arm: Deliver SIGTRAP for UDF patterns used as breakpoints | 48 | target/arm/helper: Fix tlbmask and tlbbits for TLBI VAE2* |
43 | docs: Move virtio-net-failover.rst into the system manual | 49 | target/arm: Skip granule protection checks for AT instructions |
44 | docs: Move cpu-hotplug.rst into the system manual | 50 | target/arm: Pass security space rather than flag for AT instructions |
45 | docs: Move virtio-pmem.rst into the system manual | 51 | target/arm/helper: Check SCR_EL3.{NSE, NS} encoding for AT instructions |
46 | docs/system/virtio-pmem.rst: Fix minor style issues | 52 | target/arm/helper: Implement CNTHCTL_EL2.CNT[VP]MASK |
47 | docs: Split out 'pc' machine model docs into their own file | ||
48 | docs: Move microvm.rst into the system manual | ||
49 | docs: Move pr-manager.rst into the system manual | ||
50 | docs: Split qemu-pr-helper documentation into tools manual | ||
51 | docs/system/pr-manager.rst: Fix minor docs nits | ||
52 | 53 | ||
53 | Philippe Mathieu-Daudé (10): | 54 | Peter Maydell (15): |
54 | MAINTAINERS: Cover system/arm/cpu-features.rst with ARM TCG CPUs | 55 | target/arm/ptw: Don't set fi->s1ptw for UnsuppAtomicUpdate fault |
55 | MAINTAINERS: Cover system/arm/aspeed.rst with ASPEED BMC machines | 56 | target/arm/ptw: Don't report GPC faults on stage 1 ptw as stage2 faults |
56 | MAINTAINERS: Cover system/arm/nuvoton.rst with Nuvoton NPCM7xx | 57 | target/arm/ptw: Set s1ns bit in fault info more consistently |
57 | MAINTAINERS: Fix system/arm/orangepi.rst path | 58 | target/arm/ptw: Pass ptw into get_phys_addr_pmsa*() and get_phys_addr_disabled() |
58 | MAINTAINERS: Cover system/arm/sbsa.rst with SBSA-REF machine | 59 | target/arm/ptw: Pass ARMSecurityState to regime_translation_disabled() |
59 | MAINTAINERS: Cover system/arm/sx1.rst with OMAP machines | 60 | target/arm/ptw: Pass an ARMSecuritySpace to arm_hcr_el2_eff_secstate() |
60 | docs/system: Deprecate raspi2/raspi3 machine aliases | 61 | target/arm: Pass an ARMSecuritySpace to arm_is_el2_enabled_secstate() |
61 | docs/system/arm: Document the various raspi boards | 62 | target/arm/ptw: Only fold in NSTable bit effects in Secure state |
62 | docs/system/arm: Document OpenPOWER Witherspoon BMC model Front LEDs | 63 | target/arm/ptw: Remove last uses of ptw->in_secure |
63 | docs/system/arm: Document the Sharp Zaurus SL-6000 | 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 | ||
64 | 70 | ||
65 | Rémi Denis-Courmont (1): | 71 | Richard Henderson (2): |
66 | target/arm: fix stage 2 page-walks in 32-bit emulation | 72 | target/arm: Fix SME ST1Q |
73 | target/arm: Fix 64-bit SSRA | ||
67 | 74 | ||
68 | docs/meson.build | 1 + | 75 | include/hw/gpio/nrf51_gpio.h | 1 + |
69 | docs/system/arm/aspeed.rst | 1 + | 76 | include/sysemu/kvm.h | 2 + |
70 | docs/system/arm/raspi.rst | 43 +++++++++++++++ | 77 | target/arm/cpu.h | 19 ++-- |
71 | docs/system/arm/xscale.rst | 20 ++++--- | 78 | target/arm/internals.h | 25 ++--- |
72 | docs/{ => system}/cpu-hotplug.rst | 0 | 79 | target/mips/kvm_mips.h | 9 -- |
73 | docs/system/deprecated.rst | 7 +++ | 80 | tests/qtest/libqtest.h | 11 +++ |
74 | docs/{ => system/i386}/microvm.rst | 5 +- | 81 | accel/kvm/kvm-all.c | 19 ++-- |
75 | docs/system/i386/pc.rst | 7 +++ | 82 | hw/arm/virt.c | 2 +- |
76 | docs/system/index.rst | 4 ++ | 83 | hw/gpio/nrf51_gpio.c | 14 ++- |
77 | docs/{ => system}/pr-manager.rst | 44 +++------------ | 84 | hw/mips/loongson3_virt.c | 2 - |
78 | docs/system/target-arm.rst | 1 + | 85 | hw/ppc/spapr.c | 2 +- |
79 | docs/system/target-i386.rst | 19 +++++-- | 86 | softmmu/qtest.c | 52 +++++++--- |
80 | docs/{ => system}/virtio-net-failover.rst | 0 | 87 | target/arm/cpu.c | 6 ++ |
81 | docs/system/virtio-pmem.rst | 76 ++++++++++++++++++++++++++ | 88 | target/arm/helper.c | 207 ++++++++++++++++++++++++++++---------- |
82 | docs/tools/conf.py | 2 + | 89 | target/arm/kvm.c | 7 ++ |
83 | docs/tools/index.rst | 1 + | 90 | target/arm/ptw.c | 231 ++++++++++++++++++++++++++----------------- |
84 | docs/tools/qemu-pr-helper.rst | 90 +++++++++++++++++++++++++++++++ | 91 | target/arm/tcg/sme_helper.c | 2 +- |
85 | docs/virtio-pmem.rst | 76 -------------------------- | 92 | target/arm/tcg/translate.c | 2 +- |
86 | hw/arm/pxa2xx.c | 2 +- | 93 | target/i386/kvm/kvm.c | 5 + |
87 | hw/arm/spitz.c | 2 +- | 94 | target/mips/kvm.c | 3 +- |
88 | hw/arm/tosa.c | 2 +- | 95 | target/ppc/kvm.c | 5 + |
89 | hw/intc/rx_icu.c | 18 +++---- | 96 | target/riscv/kvm.c | 5 + |
90 | linux-user/arm/cpu_loop.c | 28 ++++++++++ | 97 | target/s390x/kvm/kvm.c | 5 + |
91 | target/arm/arm-semi.c | 12 +++-- | 98 | tests/qtest/libqtest.c | 6 ++ |
92 | target/arm/helper.c | 4 +- | 99 | tests/qtest/microbit-test.c | 44 +++++++++ |
93 | MAINTAINERS | 8 ++- | 100 | target/arm/trace-events | 7 +- |
94 | 26 files changed, 326 insertions(+), 147 deletions(-) | 101 | 26 files changed, 494 insertions(+), 199 deletions(-) |
95 | create mode 100644 docs/system/arm/raspi.rst | ||
96 | rename docs/{ => system}/cpu-hotplug.rst (100%) | ||
97 | rename docs/{ => system/i386}/microvm.rst (98%) | ||
98 | create mode 100644 docs/system/i386/pc.rst | ||
99 | rename docs/{ => system}/pr-manager.rst (68%) | ||
100 | rename docs/{ => system}/virtio-net-failover.rst (100%) | ||
101 | create mode 100644 docs/system/virtio-pmem.rst | ||
102 | create mode 100644 docs/tools/qemu-pr-helper.rst | ||
103 | delete mode 100644 docs/virtio-pmem.rst | ||
104 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Chris Laplante <chris@laplante.io> |
---|---|---|---|
2 | 2 | ||
3 | List the 'tosa' machine with the XScale-based PDAs models. | 3 | Implement nRF51 DETECT signal in the GPIO peripheral. |
4 | 4 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | The reference manual makes mention of a per-pin DETECT signal, but these |
6 | Message-id: 20201120173953.2539469-5-f4bug@amsat.org | 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> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20230728160324.1159090-2-chris@laplante.io | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 13 | --- |
10 | docs/system/arm/xscale.rst | 20 +++++++++++++------- | 14 | include/hw/gpio/nrf51_gpio.h | 1 + |
11 | 1 file changed, 13 insertions(+), 7 deletions(-) | 15 | hw/gpio/nrf51_gpio.c | 14 +++++++++++++- |
16 | 2 files changed, 14 insertions(+), 1 deletion(-) | ||
12 | 17 | ||
13 | diff --git a/docs/system/arm/xscale.rst b/docs/system/arm/xscale.rst | 18 | diff --git a/include/hw/gpio/nrf51_gpio.h b/include/hw/gpio/nrf51_gpio.h |
14 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/docs/system/arm/xscale.rst | 20 | --- a/include/hw/gpio/nrf51_gpio.h |
16 | +++ b/docs/system/arm/xscale.rst | 21 | +++ b/include/hw/gpio/nrf51_gpio.h |
17 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ struct NRF51GPIOState { |
18 | -Sharp XScale-based PDA models (``akita``, ``borzoi``, ``spitz``, ``terrier``) | 23 | uint32_t old_out_connected; |
19 | -============================================================================= | 24 | |
20 | +Sharp XScale-based PDA models (``akita``, ``borzoi``, ``spitz``, ``terrier``, ``tosa``) | 25 | qemu_irq output[NRF51_GPIO_PINS]; |
21 | +======================================================================================= | 26 | + qemu_irq detect; |
22 | 27 | }; | |
23 | -The XScale-based clamshell PDA models (\"Spitz\", \"Akita\", \"Borzoi\" | 28 | |
24 | -and \"Terrier\") emulation includes the following peripherals: | 29 | |
25 | +The Sharp Zaurus are PDAs based on XScale, able to run Linux ('SL series'). | 30 | diff --git a/hw/gpio/nrf51_gpio.c b/hw/gpio/nrf51_gpio.c |
26 | 31 | index XXXXXXX..XXXXXXX 100644 | |
27 | -- Intel PXA270 System-on-chip (ARMv5TE core) | 32 | --- a/hw/gpio/nrf51_gpio.c |
28 | +The SL-6000 (\"Tosa\"), released in 2005, uses a PXA255 System-on-chip. | 33 | +++ b/hw/gpio/nrf51_gpio.c |
29 | 34 | @@ -XXX,XX +XXX,XX @@ static void update_state(NRF51GPIOState *s) | |
30 | -- NAND Flash memory | 35 | int pull; |
31 | +The SL-C3000 (\"Spitz\"), SL-C1000 (\"Akita\"), SL-C3100 (\"Borzoi\") and | 36 | size_t i; |
32 | +SL-C3200 (\"Terrier\") use a PXA270. | 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 | } | ||
33 | + | 63 | + |
34 | +The clamshell PDA models emulation includes the following peripherals: | 64 | + qemu_set_irq(s->detect, assert_detect); |
35 | + | 65 | } |
36 | +- Intel PXA255/PXA270 System-on-chip (ARMv5TE core) | 66 | |
37 | + | 67 | /* |
38 | +- NAND Flash memory - not in \"Tosa\" | 68 | @@ -XXX,XX +XXX,XX @@ static void nrf51_gpio_init(Object *obj) |
39 | 69 | ||
40 | - IBM/Hitachi DSCM microdrive in a PXA PCMCIA slot - not in \"Akita\" | 70 | qdev_init_gpio_in(DEVICE(s), nrf51_gpio_set, NRF51_GPIO_PINS); |
41 | 71 | qdev_init_gpio_out(DEVICE(s), s->output, NRF51_GPIO_PINS); | |
42 | -- On-chip OHCI USB controller | 72 | + qdev_init_gpio_out_named(DEVICE(s), &s->detect, "detect", 1); |
43 | +- On-chip OHCI USB controller - not in \"Tosa\" | 73 | } |
44 | 74 | ||
45 | - On-chip LCD controller | 75 | static void nrf51_gpio_class_init(ObjectClass *klass, void *data) |
46 | |||
47 | -- | 76 | -- |
48 | 2.20.1 | 77 | 2.34.1 |
49 | |||
50 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Chris Laplante <chris@laplante.io> | ||
1 | 2 | ||
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 |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Chris Laplante <chris@laplante.io> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Adds qtest_irq_intercept_out_named method, which utilizes a new optional |
4 | Message-id: 20201120154545.2504625-7-f4bug@amsat.org | 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 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | MAINTAINERS | 1 + | 11 | tests/qtest/libqtest.h | 11 +++++++++++ |
9 | 1 file changed, 1 insertion(+) | 12 | softmmu/qtest.c | 18 ++++++++++-------- |
13 | tests/qtest/libqtest.c | 6 ++++++ | ||
14 | 3 files changed, 27 insertions(+), 8 deletions(-) | ||
10 | 15 | ||
11 | diff --git a/MAINTAINERS b/MAINTAINERS | 16 | diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h |
12 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/MAINTAINERS | 18 | --- a/tests/qtest/libqtest.h |
14 | +++ b/MAINTAINERS | 19 | +++ b/tests/qtest/libqtest.h |
15 | @@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org | 20 | @@ -XXX,XX +XXX,XX @@ void qtest_irq_intercept_in(QTestState *s, const char *string); |
16 | S: Maintained | 21 | */ |
17 | F: hw/*/omap* | 22 | void qtest_irq_intercept_out(QTestState *s, const char *string); |
18 | F: include/hw/arm/omap.h | 23 | |
19 | +F: docs/system/arm/sx1.rst | 24 | +/** |
20 | 25 | + * qtest_irq_intercept_out_named: | |
21 | IPack | 26 | + * @s: #QTestState instance to operate on. |
22 | M: Alberto Garcia <berto@igalia.com> | 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); | ||
23 | -- | 93 | -- |
24 | 2.20.1 | 94 | 2.34.1 |
25 | |||
26 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Chris Laplante <chris@laplante.io> | ||
1 | 2 | ||
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 |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Chris Laplante <chris@laplante.io> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | This is much better than just silently failing with OK. |
4 | Message-id: 20201120154545.2504625-6-f4bug@amsat.org | 4 | |
5 | Signed-off-by: Chris Laplante <chris@laplante.io> | ||
6 | Message-id: 20230728160324.1159090-6-chris@laplante.io | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | MAINTAINERS | 1 + | 10 | softmmu/qtest.c | 12 ++++++++++-- |
9 | 1 file changed, 1 insertion(+) | 11 | 1 file changed, 10 insertions(+), 2 deletions(-) |
10 | 12 | ||
11 | diff --git a/MAINTAINERS b/MAINTAINERS | 13 | diff --git a/softmmu/qtest.c b/softmmu/qtest.c |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/MAINTAINERS | 15 | --- a/softmmu/qtest.c |
14 | +++ b/MAINTAINERS | 16 | +++ b/softmmu/qtest.c |
15 | @@ -XXX,XX +XXX,XX @@ R: Leif Lindholm <leif@nuviainc.com> | 17 | @@ -XXX,XX +XXX,XX @@ static void qtest_process_command(CharBackend *chr, gchar **words) |
16 | L: qemu-arm@nongnu.org | 18 | NamedGPIOList *ngl; |
17 | S: Maintained | 19 | bool is_named; |
18 | F: hw/arm/sbsa-ref.c | 20 | bool is_outbound; |
19 | +F: docs/system/arm/sbsa.rst | 21 | + bool interception_succeeded = false; |
20 | 22 | ||
21 | Sharp SL-5500 (Collie) PDA | 23 | g_assert(words[1]); |
22 | M: Peter Maydell <peter.maydell@linaro.org> | 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; | ||
23 | -- | 50 | -- |
24 | 2.20.1 | 51 | 2.34.1 |
25 | |||
26 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Chris Laplante <chris@laplante.io> | ||
1 | 2 | ||
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 |
1 | From: AlexChen <alex.chen@huawei.com> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | We should use printf format specifier "%u" instead of "%i" for | 3 | kvm_arch_get_default_type() returns the default KVM type. This hook is |
4 | argument of type "unsigned int". | 4 | particularly useful to derive a KVM type that is valid for "none" |
5 | 5 | machine model, which is used by libvirt to probe the availability of | |
6 | Reported-by: Euler Robot <euler.robot@huawei.com> | 6 | KVM. |
7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> | 7 | |
8 | Message-id: 5F9FD78B.8000300@huawei.com | 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 | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | [PMM: added doc comment for new function] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | --- | 19 | --- |
12 | hw/arm/pxa2xx.c | 2 +- | 20 | include/sysemu/kvm.h | 2 ++ |
13 | hw/arm/spitz.c | 2 +- | 21 | target/mips/kvm_mips.h | 9 --------- |
14 | hw/arm/tosa.c | 2 +- | 22 | accel/kvm/kvm-all.c | 4 +++- |
15 | 3 files changed, 3 insertions(+), 3 deletions(-) | 23 | hw/mips/loongson3_virt.c | 2 -- |
16 | 24 | target/arm/kvm.c | 5 +++++ | |
17 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | 25 | target/i386/kvm/kvm.c | 5 +++++ |
18 | index XXXXXXX..XXXXXXX 100644 | 26 | target/mips/kvm.c | 2 +- |
19 | --- a/hw/arm/pxa2xx.c | 27 | target/ppc/kvm.c | 5 +++++ |
20 | +++ b/hw/arm/pxa2xx.c | 28 | target/riscv/kvm.c | 5 +++++ |
21 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_ssp_write(void *opaque, hwaddr addr, | 29 | target/s390x/kvm/kvm.c | 5 +++++ |
22 | if (value & SSCR0_MOD) | 30 | 10 files changed, 31 insertions(+), 13 deletions(-) |
23 | printf("%s: Attempt to use network mode\n", __func__); | 31 | |
24 | if (s->enable && SSCR0_DSS(value) < 4) | 32 | diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h |
25 | - printf("%s: Wrong data size: %i bits\n", __func__, | 33 | index XXXXXXX..XXXXXXX 100644 |
26 | + printf("%s: Wrong data size: %u bits\n", __func__, | 34 | --- a/include/sysemu/kvm.h |
27 | SSCR0_DSS(value)); | 35 | +++ b/include/sysemu/kvm.h |
28 | if (!(value & SSCR0_SSE)) { | 36 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cpu); |
29 | s->sssr = 0; | 37 | |
30 | diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c | 38 | int kvm_arch_put_registers(CPUState *cpu, int level); |
31 | index XXXXXXX..XXXXXXX 100644 | 39 | |
32 | --- a/hw/arm/spitz.c | 40 | +int kvm_arch_get_default_type(MachineState *ms); |
33 | +++ b/hw/arm/spitz.c | 41 | + |
34 | @@ -XXX,XX +XXX,XX @@ struct SpitzLCDTG { | 42 | int kvm_arch_init(MachineState *ms, KVMState *s); |
35 | static void spitz_bl_update(SpitzLCDTG *s) | 43 | |
36 | { | 44 | int kvm_arch_init_vcpu(CPUState *cpu); |
37 | if (s->bl_power && s->bl_intensity) | 45 | diff --git a/target/mips/kvm_mips.h b/target/mips/kvm_mips.h |
38 | - zaurus_printf("LCD Backlight now at %i/63\n", s->bl_intensity); | 46 | index XXXXXXX..XXXXXXX 100644 |
39 | + zaurus_printf("LCD Backlight now at %u/63\n", s->bl_intensity); | 47 | --- a/target/mips/kvm_mips.h |
40 | else | 48 | +++ b/target/mips/kvm_mips.h |
41 | zaurus_printf("LCD Backlight now off\n"); | 49 | @@ -XXX,XX +XXX,XX @@ void kvm_mips_reset_vcpu(MIPSCPU *cpu); |
42 | } | 50 | int kvm_mips_set_interrupt(MIPSCPU *cpu, int irq, int level); |
43 | diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c | 51 | int kvm_mips_set_ipi_interrupt(MIPSCPU *cpu, int irq, int level); |
44 | index XXXXXXX..XXXXXXX 100644 | 52 | |
45 | --- a/hw/arm/tosa.c | 53 | -#ifdef CONFIG_KVM |
46 | +++ b/hw/arm/tosa.c | 54 | -int mips_kvm_type(MachineState *machine, const char *vm_type); |
47 | @@ -XXX,XX +XXX,XX @@ static void tosa_gpio_setup(PXA2xxState *cpu, | 55 | -#else |
48 | 56 | -static inline int mips_kvm_type(MachineState *machine, const char *vm_type) | |
49 | static uint32_t tosa_ssp_tansfer(SSISlave *dev, uint32_t value) | 57 | -{ |
50 | { | 58 | - return 0; |
51 | - fprintf(stderr, "TG: %d %02x\n", value >> 5, value & 0x1f); | 59 | -} |
52 | + fprintf(stderr, "TG: %u %02x\n", value >> 5, value & 0x1f); | 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, | ||
53 | return 0; | 171 | return 0; |
54 | } | 172 | } |
55 | 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, | ||
56 | -- | 198 | -- |
57 | 2.20.1 | 199 | 2.34.1 |
58 | 200 | ||
59 | 201 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Before this change, the default KVM type, which is used for non-virt |
4 | Message-id: 20201120154545.2504625-4-f4bug@amsat.org | 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 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 46 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 47 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 48 | --- |
8 | MAINTAINERS | 1 + | 49 | target/arm/kvm.c | 4 +++- |
9 | 1 file changed, 1 insertion(+) | 50 | 1 file changed, 3 insertions(+), 1 deletion(-) |
10 | 51 | ||
11 | diff --git a/MAINTAINERS b/MAINTAINERS | 52 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
12 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/MAINTAINERS | 54 | --- a/target/arm/kvm.c |
14 | +++ b/MAINTAINERS | 55 | +++ b/target/arm/kvm.c |
15 | @@ -XXX,XX +XXX,XX @@ F: include/hw/*/npcm7xx* | 56 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa) |
16 | F: tests/qtest/npcm7xx* | 57 | |
17 | F: pc-bios/npcm7xx_bootrom.bin | 58 | int kvm_arch_get_default_type(MachineState *ms) |
18 | F: roms/vbootrom | 59 | { |
19 | +F: docs/system/arm/nuvoton.rst | 60 | - return 0; |
20 | 61 | + bool fixed_ipa; | |
21 | nSeries | 62 | + int size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa); |
22 | M: Andrzej Zaborowski <balrogg@gmail.com> | 63 | + return fixed_ipa ? 0 : size; |
64 | } | ||
65 | |||
66 | int kvm_arch_init(MachineState *ms, KVMState *s) | ||
23 | -- | 67 | -- |
24 | 2.20.1 | 68 | 2.34.1 |
25 | |||
26 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | On MIPS, QEMU requires KVM_VM_MIPS_VZ type for KVM. Report an error in |
4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 4 | such a case as other architectures do when an error occurred during KVM |
5 | Message-id: 20201120154545.2504625-3-f4bug@amsat.org | 5 | type decision. |
6 | |||
7 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
8 | Message-id: 20230727073134.134102-4-akihiko.odaki@daynix.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | 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> | ||
8 | --- | 12 | --- |
9 | MAINTAINERS | 1 + | 13 | target/mips/kvm.c | 1 + |
10 | 1 file changed, 1 insertion(+) | 14 | 1 file changed, 1 insertion(+) |
11 | 15 | ||
12 | diff --git a/MAINTAINERS b/MAINTAINERS | 16 | diff --git a/target/mips/kvm.c b/target/mips/kvm.c |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/MAINTAINERS | 18 | --- a/target/mips/kvm.c |
15 | +++ b/MAINTAINERS | 19 | +++ b/target/mips/kvm.c |
16 | @@ -XXX,XX +XXX,XX @@ F: include/hw/*/*aspeed* | 20 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_default_type(MachineState *machine) |
17 | F: include/hw/misc/pca9552*.h | 21 | } |
18 | F: hw/net/ftgmac100.c | 22 | #endif |
19 | F: include/hw/net/ftgmac100.h | 23 | |
20 | +F: docs/system/arm/aspeed.rst | 24 | + error_report("KVM_VM_MIPS_VZ type is not available"); |
21 | 25 | return -1; | |
22 | NRF51 | 26 | } |
23 | M: Joel Stanley <joel@jms.id.au> | 27 | |
24 | -- | 28 | -- |
25 | 2.20.1 | 29 | 2.34.1 |
26 | 30 | ||
27 | 31 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | On MIPS, kvm_arch_get_default_type() returns a negative value when an |
4 | Message-id: 20201120154545.2504625-2-f4bug@amsat.org | 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 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-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> | ||
7 | --- | 14 | --- |
8 | MAINTAINERS | 1 + | 15 | accel/kvm/kvm-all.c | 5 +++++ |
9 | 1 file changed, 1 insertion(+) | 16 | hw/arm/virt.c | 2 +- |
17 | hw/ppc/spapr.c | 2 +- | ||
18 | 3 files changed, 7 insertions(+), 2 deletions(-) | ||
10 | 19 | ||
11 | diff --git a/MAINTAINERS b/MAINTAINERS | 20 | diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c |
12 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/MAINTAINERS | 22 | --- a/accel/kvm/kvm-all.c |
14 | +++ b/MAINTAINERS | 23 | +++ b/accel/kvm/kvm-all.c |
15 | @@ -XXX,XX +XXX,XX @@ F: disas/arm.c | 24 | @@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms) |
16 | F: disas/arm-a64.cc | 25 | type = kvm_arch_get_default_type(ms); |
17 | F: disas/libvixl/ | 26 | } |
18 | F: docs/system/target-arm.rst | 27 | |
19 | +F: docs/system/arm/cpu-features.rst | 28 | + if (type < 0) { |
20 | 29 | + ret = -EINVAL; | |
21 | ARM SMMU | 30 | + goto err; |
22 | M: Eric Auger <eric.auger@redhat.com> | 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 | /* | ||
23 | -- | 62 | -- |
24 | 2.20.1 | 63 | 2.34.1 |
25 | 64 | ||
26 | 65 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Document the 3 front LEDs modeled on the OpenPOWER Witherspoon BMC | 3 | An error may occur after s->as is allocated, for example if the |
4 | (see commit 7cfbde5ea1c "hw/arm/aspeed: Add the 3 front LEDs drived | 4 | KVM_CREATE_VM ioctl call fails. |
5 | by the PCA9552 #1"). | ||
6 | 5 | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 6 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Message-id: 20230727073134.134102-6-akihiko.odaki@daynix.com |
9 | Message-id: 20201120173953.2539469-4-f4bug@amsat.org | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | [PMM: tweaked commit message] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | docs/system/arm/aspeed.rst | 1 + | 12 | accel/kvm/kvm-all.c | 1 + |
13 | 1 file changed, 1 insertion(+) | 13 | 1 file changed, 1 insertion(+) |
14 | 14 | ||
15 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 15 | diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/docs/system/arm/aspeed.rst | 17 | --- a/accel/kvm/kvm-all.c |
18 | +++ b/docs/system/arm/aspeed.rst | 18 | +++ b/accel/kvm/kvm-all.c |
19 | @@ -XXX,XX +XXX,XX @@ Supported devices | 19 | @@ -XXX,XX +XXX,XX @@ err: |
20 | * GPIO Controller (Master only) | 20 | if (s->fd != -1) { |
21 | * UART | 21 | close(s->fd); |
22 | * Ethernet controllers | 22 | } |
23 | + * Front LEDs (PCA9552 on I2C bus) | 23 | + g_free(s->as); |
24 | 24 | g_free(s->memory_listener.slots); | |
25 | 25 | ||
26 | Missing devices | 26 | return ret; |
27 | -- | 27 | -- |
28 | 2.20.1 | 28 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
---|---|---|---|
2 | |||
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> | ||
1 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
2 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
3 | --- | 10 | --- |
4 | docs/system/index.rst | 1 + | 11 | accel/kvm/kvm-all.c | 9 ++------- |
5 | docs/{ => system}/virtio-pmem.rst | 0 | 12 | 1 file changed, 2 insertions(+), 7 deletions(-) |
6 | 2 files changed, 1 insertion(+) | ||
7 | rename docs/{ => system}/virtio-pmem.rst (100%) | ||
8 | 13 | ||
9 | diff --git a/docs/system/index.rst b/docs/system/index.rst | 14 | diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c |
10 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/docs/system/index.rst | 16 | --- a/accel/kvm/kvm-all.c |
12 | +++ b/docs/system/index.rst | 17 | +++ b/accel/kvm/kvm-all.c |
13 | @@ -XXX,XX +XXX,XX @@ Contents: | 18 | @@ -XXX,XX +XXX,XX @@ static void *kvm_dirty_ring_reaper_thread(void *data) |
14 | gdb | 19 | return NULL; |
15 | managed-startup | 20 | } |
16 | cpu-hotplug | 21 | |
17 | + virtio-pmem | 22 | -static int kvm_dirty_ring_reaper_init(KVMState *s) |
18 | targets | 23 | +static void kvm_dirty_ring_reaper_init(KVMState *s) |
19 | security | 24 | { |
20 | deprecated | 25 | struct KVMDirtyRingReaper *r = &s->reaper; |
21 | diff --git a/docs/virtio-pmem.rst b/docs/system/virtio-pmem.rst | 26 | |
22 | similarity index 100% | 27 | qemu_thread_create(&r->reaper_thr, "kvm-reaper", |
23 | rename from docs/virtio-pmem.rst | 28 | kvm_dirty_ring_reaper_thread, |
24 | rename to docs/system/virtio-pmem.rst | 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)) { | ||
25 | -- | 47 | -- |
26 | 2.20.1 | 48 | 2.34.1 |
27 | 49 | ||
28 | 50 | diff view generated by jsdifflib |
New 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. | ||
1 | 6 | ||
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 |
New 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. | ||
1 | 11 | ||
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 |
New 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. | ||
1 | 7 | ||
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 |
New 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. | ||
1 | 9 | ||
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 |
New patch | |||
---|---|---|---|
1 | Plumb the ARMSecurityState through to regime_translation_disabled() | ||
2 | rather than just a bool is_secure. | ||
1 | 3 | ||
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 |
1 | Fix a couple of nits in pr-manager.rst: | 1 | arm_hcr_el2_eff_secstate() takes a bool secure, which it uses to |
---|---|---|---|
2 | * the title marker for the top level heading is overlength | 2 | determine whether EL2 is enabled in the current security state. |
3 | * stray capital 'R' in the middle of a sentence | 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 | |||
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. | ||
4 | 27 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
30 | Message-id: 20230807141514.19075-7-peter.maydell@linaro.org | ||
7 | --- | 31 | --- |
8 | docs/system/pr-manager.rst | 6 +++--- | 32 | target/arm/cpu.h | 2 +- |
9 | 1 file changed, 3 insertions(+), 3 deletions(-) | 33 | target/arm/helper.c | 8 +++++--- |
34 | target/arm/ptw.c | 15 +++++++-------- | ||
35 | 3 files changed, 13 insertions(+), 12 deletions(-) | ||
10 | 36 | ||
11 | diff --git a/docs/system/pr-manager.rst b/docs/system/pr-manager.rst | 37 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
12 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/docs/system/pr-manager.rst | 39 | --- a/target/arm/cpu.h |
14 | +++ b/docs/system/pr-manager.rst | 40 | +++ b/target/arm/cpu.h |
15 | @@ -XXX,XX +XXX,XX @@ | 41 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_is_el2_enabled(CPUARMState *env) |
16 | -====================================== | 42 | * "for all purposes other than a direct read or write access of HCR_EL2." |
17 | +=============================== | 43 | * Not included here is HCR_RW. |
18 | Persistent reservation managers | 44 | */ |
19 | -====================================== | 45 | -uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, bool secure); |
20 | +=============================== | 46 | +uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, ARMSecuritySpace space); |
21 | 47 | uint64_t arm_hcr_el2_eff(CPUARMState *env); | |
22 | -SCSI persistent Reservations allow restricting access to block devices | 48 | uint64_t arm_hcrx_el2_eff(CPUARMState *env); |
23 | +SCSI persistent reservations allow restricting access to block devices | 49 | |
24 | to specific initiators in a shared storage setup. When implementing | 50 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
25 | clustering of virtual machines, it is a common requirement for virtual | 51 | index XXXXXXX..XXXXXXX 100644 |
26 | machines to send persistent reservation SCSI commands. However, | 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 | ||
27 | -- | 174 | -- |
28 | 2.20.1 | 175 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | Split the documentation of the qemu-pr-helper binary into the tools | 1 | Pass an ARMSecuritySpace instead of a bool secure to |
---|---|---|---|
2 | manual, and give it a manpage like our other standalone executables. | 2 | arm_is_el2_enabled_secstate(). This doesn't change behaviour. |
3 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20230807141514.19075-8-peter.maydell@linaro.org | ||
6 | --- | 7 | --- |
7 | docs/meson.build | 1 + | 8 | target/arm/cpu.h | 13 ++++++++----- |
8 | docs/system/pr-manager.rst | 38 ++------------- | 9 | target/arm/helper.c | 2 +- |
9 | docs/tools/conf.py | 2 + | 10 | 2 files changed, 9 insertions(+), 6 deletions(-) |
10 | docs/tools/index.rst | 1 + | ||
11 | docs/tools/qemu-pr-helper.rst | 90 +++++++++++++++++++++++++++++++++++ | ||
12 | 5 files changed, 99 insertions(+), 33 deletions(-) | ||
13 | create mode 100644 docs/tools/qemu-pr-helper.rst | ||
14 | 11 | ||
15 | diff --git a/docs/meson.build b/docs/meson.build | 12 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/docs/meson.build | 14 | --- a/target/arm/cpu.h |
18 | +++ b/docs/meson.build | 15 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ if build_docs | 16 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env) |
20 | 'tools': { | 17 | |
21 | 'qemu-img.1': (have_tools ? 'man1' : ''), | 18 | /* |
22 | 'qemu-nbd.8': (have_tools ? 'man8' : ''), | 19 | * Return true if the current security state has AArch64 EL2 or AArch32 Hyp. |
23 | + 'qemu-pr-helper.8': (have_tools ? 'man8' : ''), | 20 | - * This corresponds to the pseudocode EL2Enabled() |
24 | 'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''), | 21 | + * This corresponds to the pseudocode EL2Enabled(). |
25 | 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''), | 22 | */ |
26 | 'virtiofsd.1': (have_virtiofsd ? 'man1' : ''), | 23 | -static inline bool arm_is_el2_enabled_secstate(CPUARMState *env, bool secure) |
27 | diff --git a/docs/system/pr-manager.rst b/docs/system/pr-manager.rst | 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 | ||
28 | index XXXXXXX..XXXXXXX 100644 | 51 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/docs/system/pr-manager.rst | 52 | --- a/target/arm/helper.c |
30 | +++ b/docs/system/pr-manager.rst | 53 | +++ b/target/arm/helper.c |
31 | @@ -XXX,XX +XXX,XX @@ Alternatively, using ``-blockdev``:: | 54 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, ARMSecuritySpace space) |
32 | -blockdev node-name=hd,driver=raw,file.driver=host_device,file.filename=/dev/sdb,file.pr-manager=helper0 | 55 | |
33 | -device scsi-block,drive=hd | 56 | assert(space != ARMSS_Root); |
34 | 57 | ||
35 | ----------------------------------- | 58 | - if (!arm_is_el2_enabled_secstate(env, arm_space_is_secure(space))) { |
36 | -Invoking :program:`qemu-pr-helper` | 59 | + if (!arm_is_el2_enabled_secstate(env, space)) { |
37 | ----------------------------------- | 60 | /* |
38 | - | 61 | * "This register has no effect if EL2 is not enabled in the |
39 | -QEMU provides an implementation of the persistent reservation helper, | 62 | * current Security state". This is ARMv8.4-SecEL2 speak for |
40 | -called :program:`qemu-pr-helper`. The helper should be started as a | ||
41 | -system service and supports the following option: | ||
42 | - | ||
43 | --d, --daemon run in the background | ||
44 | --q, --quiet decrease verbosity | ||
45 | --v, --verbose increase verbosity | ||
46 | --f, --pidfile=path PID file when running as a daemon | ||
47 | --k, --socket=path path to the socket | ||
48 | --T, --trace=trace-opts tracing options | ||
49 | - | ||
50 | -By default, the socket and PID file are placed in the runtime state | ||
51 | -directory, for example :file:`/var/run/qemu-pr-helper.sock` and | ||
52 | -:file:`/var/run/qemu-pr-helper.pid`. The PID file is not created | ||
53 | -unless :option:`-d` is passed too. | ||
54 | - | ||
55 | -:program:`qemu-pr-helper` can also use the systemd socket activation | ||
56 | -protocol. In this case, the systemd socket unit should specify a | ||
57 | -Unix stream socket, like this:: | ||
58 | - | ||
59 | - [Socket] | ||
60 | - ListenStream=/var/run/qemu-pr-helper.sock | ||
61 | - | ||
62 | -After connecting to the socket, :program:`qemu-pr-helper`` can optionally drop | ||
63 | -root privileges, except for those capabilities that are needed for | ||
64 | -its operation. To do this, add the following options: | ||
65 | - | ||
66 | --u, --user=user user to drop privileges to | ||
67 | --g, --group=group group to drop privileges to | ||
68 | +You will also need to ensure that the helper program | ||
69 | +:command:`qemu-pr-helper` is running, and that it has been | ||
70 | +set up to use the same socket filename as your QEMU commandline | ||
71 | +specifies. See the qemu-pr-helper documentation or manpage for | ||
72 | +further details. | ||
73 | |||
74 | --------------------------------------------- | ||
75 | Multipath devices and persistent reservations | ||
76 | diff --git a/docs/tools/conf.py b/docs/tools/conf.py | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/docs/tools/conf.py | ||
79 | +++ b/docs/tools/conf.py | ||
80 | @@ -XXX,XX +XXX,XX @@ man_pages = [ | ||
81 | ['Fabrice Bellard'], 1), | ||
82 | ('qemu-nbd', 'qemu-nbd', u'QEMU Disk Network Block Device Server', | ||
83 | ['Anthony Liguori <anthony@codemonkey.ws>'], 8), | ||
84 | + ('qemu-pr-helper', 'qemu-pr-helper', 'QEMU persistent reservation helper', | ||
85 | + [], 8), | ||
86 | ('qemu-trace-stap', 'qemu-trace-stap', u'QEMU SystemTap trace tool', | ||
87 | [], 1), | ||
88 | ('virtfs-proxy-helper', 'virtfs-proxy-helper', | ||
89 | diff --git a/docs/tools/index.rst b/docs/tools/index.rst | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/docs/tools/index.rst | ||
92 | +++ b/docs/tools/index.rst | ||
93 | @@ -XXX,XX +XXX,XX @@ Contents: | ||
94 | |||
95 | qemu-img | ||
96 | qemu-nbd | ||
97 | + qemu-pr-helper | ||
98 | qemu-trace-stap | ||
99 | virtfs-proxy-helper | ||
100 | virtiofsd | ||
101 | diff --git a/docs/tools/qemu-pr-helper.rst b/docs/tools/qemu-pr-helper.rst | ||
102 | new file mode 100644 | ||
103 | index XXXXXXX..XXXXXXX | ||
104 | --- /dev/null | ||
105 | +++ b/docs/tools/qemu-pr-helper.rst | ||
106 | @@ -XXX,XX +XXX,XX @@ | ||
107 | +QEMU persistent reservation helper | ||
108 | +================================== | ||
109 | + | ||
110 | +Synopsis | ||
111 | +-------- | ||
112 | + | ||
113 | +**qemu-pr-helper** [*OPTION*] | ||
114 | + | ||
115 | +Description | ||
116 | +----------- | ||
117 | + | ||
118 | +Implements the persistent reservation helper for QEMU. | ||
119 | + | ||
120 | +SCSI persistent reservations allow restricting access to block devices | ||
121 | +to specific initiators in a shared storage setup. When implementing | ||
122 | +clustering of virtual machines, it is a common requirement for virtual | ||
123 | +machines to send persistent reservation SCSI commands. However, | ||
124 | +the operating system restricts sending these commands to unprivileged | ||
125 | +programs because incorrect usage can disrupt regular operation of the | ||
126 | +storage fabric. QEMU's SCSI passthrough devices ``scsi-block`` | ||
127 | +and ``scsi-generic`` support passing guest persistent reservation | ||
128 | +requests to a privileged external helper program. :program:`qemu-pr-helper` | ||
129 | +is that external helper; it creates a socket which QEMU can | ||
130 | +connect to to communicate with it. | ||
131 | + | ||
132 | +If you want to run VMs in a setup like this, this helper should be | ||
133 | +started as a system service, and you should read the QEMU manual | ||
134 | +section on "persistent reservation managers" to find out how to | ||
135 | +configure QEMU to connect to the socket created by | ||
136 | +:program:`qemu-pr-helper`. | ||
137 | + | ||
138 | +After connecting to the socket, :program:`qemu-pr-helper` can | ||
139 | +optionally drop root privileges, except for those capabilities that | ||
140 | +are needed for its operation. | ||
141 | + | ||
142 | +:program:`qemu-pr-helper` can also use the systemd socket activation | ||
143 | +protocol. In this case, the systemd socket unit should specify a | ||
144 | +Unix stream socket, like this:: | ||
145 | + | ||
146 | + [Socket] | ||
147 | + ListenStream=/var/run/qemu-pr-helper.sock | ||
148 | + | ||
149 | +Options | ||
150 | +------- | ||
151 | + | ||
152 | +.. program:: qemu-pr-helper | ||
153 | + | ||
154 | +.. option:: -d, --daemon | ||
155 | + | ||
156 | + run in the background (and create a PID file) | ||
157 | + | ||
158 | +.. option:: -q, --quiet | ||
159 | + | ||
160 | + decrease verbosity | ||
161 | + | ||
162 | +.. option:: -v, --verbose | ||
163 | + | ||
164 | + increase verbosity | ||
165 | + | ||
166 | +.. option:: -f, --pidfile=PATH | ||
167 | + | ||
168 | + PID file when running as a daemon. By default the PID file | ||
169 | + is created in the system runtime state directory, for example | ||
170 | + :file:`/var/run/qemu-pr-helper.pid`. | ||
171 | + | ||
172 | +.. option:: -k, --socket=PATH | ||
173 | + | ||
174 | + path to the socket. By default the socket is created in | ||
175 | + the system runtime state directory, for example | ||
176 | + :file:`/var/run/qemu-pr-helper.sock`. | ||
177 | + | ||
178 | +.. option:: -T, --trace [[enable=]PATTERN][,events=FILE][,file=FILE] | ||
179 | + | ||
180 | + .. include:: ../qemu-option-trace.rst.inc | ||
181 | + | ||
182 | +.. option:: -u, --user=USER | ||
183 | + | ||
184 | + user to drop privileges to | ||
185 | + | ||
186 | +.. option:: -g, --group=GROUP | ||
187 | + | ||
188 | + group to drop privileges to | ||
189 | + | ||
190 | +.. option:: -h, --help | ||
191 | + | ||
192 | + Display a help message and exit. | ||
193 | + | ||
194 | +.. option:: -V, --version | ||
195 | + | ||
196 | + Display version information and exit. | ||
197 | -- | 63 | -- |
198 | 2.20.1 | 64 | 2.34.1 |
199 | |||
200 | diff view generated by jsdifflib |
1 | Move the pr-manager documentation into the system manual. | 1 | When we do a translation in Secure state, the NSTable bits in table |
---|---|---|---|
2 | Some of it (the documentation of the pr-manager-helper tool) | 2 | descriptors may downgrade us to NonSecure; we update ptw->in_secure |
3 | should be in tools, but we will split it up after moving it. | 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 | |||
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. | ||
4 | 18 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
21 | Message-id: 20230807141514.19075-9-peter.maydell@linaro.org | ||
7 | --- | 22 | --- |
8 | docs/system/index.rst | 1 + | 23 | target/arm/ptw.c | 3 +-- |
9 | docs/{ => system}/pr-manager.rst | 0 | 24 | 1 file changed, 1 insertion(+), 2 deletions(-) |
10 | 2 files changed, 1 insertion(+) | ||
11 | rename docs/{ => system}/pr-manager.rst (100%) | ||
12 | 25 | ||
13 | diff --git a/docs/system/index.rst b/docs/system/index.rst | 26 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
14 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/docs/system/index.rst | 28 | --- a/target/arm/ptw.c |
16 | +++ b/docs/system/index.rst | 29 | +++ b/target/arm/ptw.c |
17 | @@ -XXX,XX +XXX,XX @@ Contents: | 30 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, |
18 | managed-startup | 31 | * Extract attributes from the (modified) descriptor, and apply |
19 | cpu-hotplug | 32 | * table descriptors. Stage 2 table descriptors do not include |
20 | virtio-pmem | 33 | * any attribute fields. HPD disables all the table attributes |
21 | + pr-manager | 34 | - * except NSTable. |
22 | targets | 35 | + * except NSTable (which we have already handled). |
23 | security | 36 | */ |
24 | deprecated | 37 | attrs = new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); |
25 | diff --git a/docs/pr-manager.rst b/docs/system/pr-manager.rst | 38 | if (!regime_is_stage2(mmu_idx)) { |
26 | similarity index 100% | 39 | - attrs |= !ptw->in_secure << 5; /* NS */ |
27 | rename from docs/pr-manager.rst | 40 | if (!param.hpd) { |
28 | rename to docs/system/pr-manager.rst | 41 | attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ |
42 | /* | ||
29 | -- | 43 | -- |
30 | 2.20.1 | 44 | 2.34.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | Now that target-i386.rst has a place to list documentation of | 1 | Replace the last uses of ptw->in_secure with appropriate |
---|---|---|---|
2 | machines other than the 'pc' machine, we have a place we can | 2 | checks on ptw->in_space. |
3 | move the microvm documentation to. | ||
4 | 3 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20230807141514.19075-10-peter.maydell@linaro.org | ||
7 | --- | 7 | --- |
8 | docs/{ => system/i386}/microvm.rst | 5 ++--- | 8 | target/arm/ptw.c | 11 +++++++---- |
9 | docs/system/target-i386.rst | 1 + | 9 | 1 file changed, 7 insertions(+), 4 deletions(-) |
10 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
11 | rename docs/{ => system/i386}/microvm.rst (98%) | ||
12 | 10 | ||
13 | diff --git a/docs/microvm.rst b/docs/system/i386/microvm.rst | 11 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
14 | similarity index 98% | ||
15 | rename from docs/microvm.rst | ||
16 | rename to docs/system/i386/microvm.rst | ||
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/docs/microvm.rst | 13 | --- a/target/arm/ptw.c |
19 | +++ b/docs/system/i386/microvm.rst | 14 | +++ b/target/arm/ptw.c |
20 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, |
21 | -==================== | 16 | ARMMMUFaultInfo *fi) |
22 | -microvm Machine Type | 17 | { |
23 | -==================== | 18 | ARMMMUIdx mmu_idx = ptw->in_mmu_idx; |
24 | +'microvm' virtual platform (``microvm``) | 19 | - bool is_secure = ptw->in_secure; |
25 | +======================================== | 20 | ARMMMUIdx s1_mmu_idx; |
26 | 21 | ||
27 | ``microvm`` is a machine type inspired by ``Firecracker`` and | 22 | /* |
28 | constructed after its machine model. | 23 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, |
29 | diff --git a/docs/system/target-i386.rst b/docs/system/target-i386.rst | 24 | * cannot upgrade a NonSecure translation regime's attributes |
30 | index XXXXXXX..XXXXXXX 100644 | 25 | * to Secure or Realm. |
31 | --- a/docs/system/target-i386.rst | 26 | */ |
32 | +++ b/docs/system/target-i386.rst | 27 | - result->f.attrs.secure = is_secure; |
33 | @@ -XXX,XX +XXX,XX @@ Board-specific documentation | 28 | result->f.attrs.space = ptw->in_space; |
34 | .. toctree:: | 29 | + result->f.attrs.secure = arm_space_is_secure(ptw->in_space); |
35 | :maxdepth: 1 | 30 | |
36 | 31 | switch (mmu_idx) { | |
37 | + i386/microvm | 32 | case ARMMMUIdx_Phys_S: |
38 | i386/pc | 33 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, |
39 | 34 | case ARMMMUIdx_Stage1_E0: | |
40 | .. include:: cpu-models-x86.rst.inc | 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: | ||
41 | -- | 48 | -- |
42 | 2.20.1 | 49 | 2.34.1 |
43 | |||
44 | diff view generated by jsdifflib |
1 | The virtio-pmem documentation has some minor style issues we hadn't | 1 | We no longer look at the in_secure field of the S1Translate struct |
---|---|---|---|
2 | noticed since we weren't rendering it in our docs: | 2 | anyway, so we can remove it and all the code which sets it. |
3 | |||
4 | * Sphinx doesn't complain about overlong title-underlining the | ||
5 | way it complains about too-short underlining, but it looks odd; | ||
6 | make the underlines of section headers the right length | ||
7 | |||
8 | * Indent of paragraphs makes them render as blockquotes; | ||
9 | remove the indent so they just render as normal text | ||
10 | |||
11 | * Leading 'o' isn't rst markup, so it just renders as a literal | ||
12 | "o"; reformat as a subsection heading instead | ||
13 | |||
14 | * "QEMU" in the document title and section headings are a bit | ||
15 | odd and unnecessary since this is the QEMU manual; delete | ||
16 | or rephrase them | ||
17 | |||
18 | * There's no need to specify what QEMU version the device first | ||
19 | appeared in. | ||
20 | 3 | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
23 | Reviewed-by: Pankaj Gupta <pankaj.gupta@cloud.ionos.com> | 6 | Message-id: 20230807141514.19075-11-peter.maydell@linaro.org |
24 | --- | 7 | --- |
25 | docs/system/virtio-pmem.rst | 60 ++++++++++++++++++------------------- | 8 | target/arm/ptw.c | 13 ------------- |
26 | 1 file changed, 30 insertions(+), 30 deletions(-) | 9 | 1 file changed, 13 deletions(-) |
27 | 10 | ||
28 | diff --git a/docs/system/virtio-pmem.rst b/docs/system/virtio-pmem.rst | 11 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
29 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/docs/system/virtio-pmem.rst | 13 | --- a/target/arm/ptw.c |
31 | +++ b/docs/system/virtio-pmem.rst | 14 | +++ b/target/arm/ptw.c |
32 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct S1Translate { |
33 | 16 | * value being Stage2 vs Stage2_S distinguishes those. | |
34 | -======================== | 17 | */ |
35 | -QEMU virtio pmem | 18 | ARMSecuritySpace in_space; |
36 | -======================== | 19 | - /* |
37 | +=========== | 20 | - * in_secure: whether the translation regime is a Secure one. |
38 | +virtio pmem | 21 | - * This is always equal to arm_space_is_secure(in_space). |
39 | +=========== | 22 | - * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, |
40 | 23 | - * this field is updated accordingly. | |
41 | - This document explains the setup and usage of the virtio pmem device | 24 | - */ |
42 | - which is available since QEMU v4.1.0. | 25 | - bool in_secure; |
43 | - | 26 | /* |
44 | - The virtio pmem device is a paravirtualized persistent memory device | 27 | * in_debug: is this a QEMU debug access (gdbstub, etc)? Debug |
45 | - on regular (i.e non-NVDIMM) storage. | 28 | * accesses will not update the guest page table access flags |
46 | +This document explains the setup and usage of the virtio pmem device. | 29 | @@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, |
47 | +The virtio pmem device is a paravirtualized persistent memory device | 30 | S1Translate s2ptw = { |
48 | +on regular (i.e non-NVDIMM) storage. | 31 | .in_mmu_idx = s2_mmu_idx, |
49 | 32 | .in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx), | |
50 | Usecase | 33 | - .in_secure = arm_space_is_secure(s2_space), |
51 | --------- | 34 | .in_space = s2_space, |
52 | +------- | 35 | .in_debug = true, |
53 | 36 | }; | |
54 | - Virtio pmem allows to bypass the guest page cache and directly use | 37 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, |
55 | - host page cache. This reduces guest memory footprint as the host can | 38 | QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_S + 1 != ARMMMUIdx_Phys_NS); |
56 | - make efficient memory reclaim decisions under memory pressure. | 39 | QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2_S + 1 != ARMMMUIdx_Stage2); |
57 | +Virtio pmem allows to bypass the guest page cache and directly use | 40 | ptw->in_ptw_idx += 1; |
58 | +host page cache. This reduces guest memory footprint as the host can | 41 | - ptw->in_secure = false; |
59 | +make efficient memory reclaim decisions under memory pressure. | 42 | ptw->in_space = ARMSS_NonSecure; |
60 | 43 | } | |
61 | -o How does virtio-pmem compare to the nvdimm emulation supported by QEMU? | 44 | |
62 | +How does virtio-pmem compare to the nvdimm emulation? | 45 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
63 | +----------------------------------------------------- | 46 | |
64 | 47 | ptw->in_s1_is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0; | |
65 | - NVDIMM emulation on regular (i.e. non-NVDIMM) host storage does not | 48 | ptw->in_mmu_idx = ipa_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; |
66 | - persist the guest writes as there are no defined semantics in the device | 49 | - ptw->in_secure = ipa_secure; |
67 | - specification. The virtio pmem device provides guest write persistence | 50 | ptw->in_space = ipa_space; |
68 | - on non-NVDIMM host storage. | 51 | ptw->in_ptw_idx = ptw_idx_for_stage_2(env, ptw->in_mmu_idx); |
69 | +NVDIMM emulation on regular (i.e. non-NVDIMM) host storage does not | 52 | |
70 | +persist the guest writes as there are no defined semantics in the device | 53 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, |
71 | +specification. The virtio pmem device provides guest write persistence | 54 | { |
72 | +on non-NVDIMM host storage. | 55 | S1Translate ptw = { |
73 | 56 | .in_mmu_idx = mmu_idx, | |
74 | virtio pmem usage | 57 | - .in_secure = is_secure, |
75 | ----------------- | 58 | .in_space = arm_secure_to_space(is_secure), |
76 | 59 | }; | |
77 | - A virtio pmem device backed by a memory-backend-file can be created on | 60 | return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi); |
78 | - the QEMU command line as in the following example:: | 61 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, |
79 | +A virtio pmem device backed by a memory-backend-file can be created on | 62 | } |
80 | +the QEMU command line as in the following example:: | 63 | |
81 | 64 | ptw.in_space = ss; | |
82 | -object memory-backend-file,id=mem1,share,mem-path=./virtio_pmem.img,size=4G | 65 | - ptw.in_secure = arm_space_is_secure(ss); |
83 | -device virtio-pmem-pci,memdev=mem1,id=nv1 | 66 | return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi); |
84 | 67 | } | |
85 | - where: | 68 | |
86 | +where: | 69 | @@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, |
87 | 70 | S1Translate ptw = { | |
88 | - "object memory-backend-file,id=mem1,share,mem-path=<image>, size=<image size>" | 71 | .in_mmu_idx = mmu_idx, |
89 | creates a backend file with the specified size. | 72 | .in_space = ss, |
90 | @@ -XXX,XX +XXX,XX @@ virtio pmem usage | 73 | - .in_secure = arm_space_is_secure(ss), |
91 | - "device virtio-pmem-pci,id=nvdimm1,memdev=mem1" creates a virtio pmem | 74 | .in_debug = true, |
92 | pci device whose storage is provided by above memory backend device. | 75 | }; |
93 | 76 | GetPhysAddrResult res = {}; | |
94 | - Multiple virtio pmem devices can be created if multiple pairs of "-object" | ||
95 | - and "-device" are provided. | ||
96 | +Multiple virtio pmem devices can be created if multiple pairs of "-object" | ||
97 | +and "-device" are provided. | ||
98 | |||
99 | Hotplug | ||
100 | ------- | ||
101 | @@ -XXX,XX +XXX,XX @@ the guest:: | ||
102 | Guest Data Persistence | ||
103 | ---------------------- | ||
104 | |||
105 | - Guest data persistence on non-NVDIMM requires guest userspace applications | ||
106 | - to perform fsync/msync. This is different from a real nvdimm backend where | ||
107 | - no additional fsync/msync is required. This is to persist guest writes in | ||
108 | - host backing file which otherwise remains in host page cache and there is | ||
109 | - risk of losing the data in case of power failure. | ||
110 | +Guest data persistence on non-NVDIMM requires guest userspace applications | ||
111 | +to perform fsync/msync. This is different from a real nvdimm backend where | ||
112 | +no additional fsync/msync is required. This is to persist guest writes in | ||
113 | +host backing file which otherwise remains in host page cache and there is | ||
114 | +risk of losing the data in case of power failure. | ||
115 | |||
116 | - With virtio pmem device, MAP_SYNC mmap flag is not supported. This provides | ||
117 | - a hint to application to perform fsync for write persistence. | ||
118 | +With virtio pmem device, MAP_SYNC mmap flag is not supported. This provides | ||
119 | +a hint to application to perform fsync for write persistence. | ||
120 | |||
121 | Limitations | ||
122 | ------------- | ||
123 | +----------- | ||
124 | + | ||
125 | - Real nvdimm device backend is not supported. | ||
126 | - virtio pmem hotunplug is not supported. | ||
127 | - ACPI NVDIMM features like regions/namespaces are not supported. | ||
128 | -- | 77 | -- |
129 | 2.20.1 | 78 | 2.34.1 |
130 | |||
131 | diff view generated by jsdifflib |
1 | The cpu-hotplug.rst documentation is currently orphan and not | 1 | We only use S1Translate::out_secure in two places, where we are |
---|---|---|---|
2 | included in any manual; move it into the system manual. | 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. | ||
3 | 7 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20230807141514.19075-12-peter.maydell@linaro.org | ||
6 | --- | 11 | --- |
7 | docs/{ => system}/cpu-hotplug.rst | 0 | 12 | target/arm/ptw.c | 7 ++----- |
8 | docs/system/index.rst | 1 + | 13 | 1 file changed, 2 insertions(+), 5 deletions(-) |
9 | 2 files changed, 1 insertion(+) | ||
10 | rename docs/{ => system}/cpu-hotplug.rst (100%) | ||
11 | 14 | ||
12 | diff --git a/docs/cpu-hotplug.rst b/docs/system/cpu-hotplug.rst | 15 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
13 | similarity index 100% | ||
14 | rename from docs/cpu-hotplug.rst | ||
15 | rename to docs/system/cpu-hotplug.rst | ||
16 | diff --git a/docs/system/index.rst b/docs/system/index.rst | ||
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/docs/system/index.rst | 17 | --- a/target/arm/ptw.c |
19 | +++ b/docs/system/index.rst | 18 | +++ b/target/arm/ptw.c |
20 | @@ -XXX,XX +XXX,XX @@ Contents: | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct S1Translate { |
21 | tls | 20 | * Stage 2 is indicated by in_mmu_idx set to ARMMMUIdx_Stage2{,_S}. |
22 | gdb | 21 | */ |
23 | managed-startup | 22 | bool in_s1_is_el0; |
24 | + cpu-hotplug | 23 | - bool out_secure; |
25 | targets | 24 | bool out_rw; |
26 | security | 25 | bool out_be; |
27 | deprecated | 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; | ||
28 | -- | 63 | -- |
29 | 2.20.1 | 64 | 2.34.1 |
30 | |||
31 | diff view generated by jsdifflib |
1 | The virtio-net-failover documentation is currently orphan and | 1 | When the MMU is disabled, data accesses should be Device nGnRnE, |
---|---|---|---|
2 | not included in any manual; move it into the system manual, | 2 | Outer Shareable, Untagged. We handle the other cases from |
3 | immediately following the general network emulation section. | 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. | ||
4 | 7 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20230807141514.19075-13-peter.maydell@linaro.org | ||
7 | --- | 11 | --- |
8 | docs/system/index.rst | 1 + | 12 | target/arm/ptw.c | 12 +++++++----- |
9 | docs/{ => system}/virtio-net-failover.rst | 0 | 13 | 1 file changed, 7 insertions(+), 5 deletions(-) |
10 | 2 files changed, 1 insertion(+) | ||
11 | rename docs/{ => system}/virtio-net-failover.rst (100%) | ||
12 | 14 | ||
13 | diff --git a/docs/system/index.rst b/docs/system/index.rst | 15 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/docs/system/index.rst | 17 | --- a/target/arm/ptw.c |
16 | +++ b/docs/system/index.rst | 18 | +++ b/target/arm/ptw.c |
17 | @@ -XXX,XX +XXX,XX @@ Contents: | 19 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_disabled(CPUARMState *env, |
18 | monitor | 20 | } |
19 | images | 21 | } |
20 | net | 22 | } |
21 | + virtio-net-failover | 23 | - if (memattr == 0 && access_type == MMU_INST_FETCH) { |
22 | usb | 24 | - if (regime_sctlr(env, mmu_idx) & SCTLR_I) { |
23 | ivshmem | 25 | - memattr = 0xee; /* Normal, WT, RA, NT */ |
24 | linuxboot | 26 | - } else { |
25 | diff --git a/docs/virtio-net-failover.rst b/docs/system/virtio-net-failover.rst | 27 | - memattr = 0x44; /* Normal, NC, No */ |
26 | similarity index 100% | 28 | + if (memattr == 0) { |
27 | rename from docs/virtio-net-failover.rst | 29 | + if (access_type == MMU_INST_FETCH) { |
28 | rename to docs/system/virtio-net-failover.rst | 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 | } | ||
29 | -- | 38 | -- |
30 | 2.20.1 | 39 | 2.34.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | The Linux kernel doesn't use the official bkpt insn for breakpoints; | 1 | The architecture doesn't permit block descriptors at any arbitrary |
---|---|---|---|
2 | instead it uses three instructions in the guaranteed-to-UNDEF space, | 2 | level of the page table walk; it depends on the granule size which |
3 | and generates SIGTRAP for these rather than the SIGILL that most | 3 | levels are permitted. We implemented only a partial version of this |
4 | UNDEF insns generate: | 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. | ||
5 | 7 | ||
6 | https://elixir.bootlin.com/linux/v5.9.8/source/arch/arm/kernel/ptrace.c#L197 | 8 | Implement the logic corresponding to the pseudocode |
7 | 9 | AArch64.DecodeDescriptorType() and AArch64.BlockDescSupported(). | |
8 | Make QEMU treat these insns specially too. The main benefit of this | ||
9 | is that if you're running a debugger on a guest program that runs | ||
10 | into a GCC __builtin_trap() or LLVM "trap because execution should | ||
11 | never reach here" then you'll get the expected signal rather than a | ||
12 | SIGILL. | ||
13 | 10 | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
16 | Message-id: 20201117155634.6924-1-peter.maydell@linaro.org | 13 | Message-id: 20230807141514.19075-14-peter.maydell@linaro.org |
17 | --- | 14 | --- |
18 | linux-user/arm/cpu_loop.c | 28 ++++++++++++++++++++++++++++ | 15 | target/arm/ptw.c | 25 +++++++++++++++++++++++-- |
19 | 1 file changed, 28 insertions(+) | 16 | 1 file changed, 23 insertions(+), 2 deletions(-) |
20 | 17 | ||
21 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c | 18 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
22 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/linux-user/arm/cpu_loop.c | 20 | --- a/target/arm/ptw.c |
24 | +++ b/linux-user/arm/cpu_loop.c | 21 | +++ b/target/arm/ptw.c |
25 | @@ -XXX,XX +XXX,XX @@ do_kernel_trap(CPUARMState *env) | 22 | @@ -XXX,XX +XXX,XX @@ static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr, |
26 | return 0; | 23 | return INT_MIN; |
27 | } | 24 | } |
28 | 25 | ||
29 | +static bool insn_is_linux_bkpt(uint32_t opcode, bool is_thumb) | 26 | +static bool lpae_block_desc_valid(ARMCPU *cpu, bool ds, |
27 | + ARMGranuleSize gran, int level) | ||
30 | +{ | 28 | +{ |
31 | + /* | 29 | + /* |
32 | + * Return true if this insn is one of the three magic UDF insns | 30 | + * See pseudocode AArch46.BlockDescSupported(): block descriptors |
33 | + * which the kernel treats as breakpoint insns. | 31 | + * are not valid at all levels, depending on the page size. |
34 | + */ | 32 | + */ |
35 | + if (!is_thumb) { | 33 | + switch (gran) { |
36 | + return (opcode & 0x0fffffff) == 0x07f001f0; | 34 | + case Gran4K: |
37 | + } else { | 35 | + return (level == 0 && ds) || level == 1 || level == 2; |
38 | + /* | 36 | + case Gran16K: |
39 | + * Note that we get the two halves of the 32-bit T32 insn | 37 | + return (level == 1 && ds) || level == 2; |
40 | + * in the opposite order to the value the kernel uses in | 38 | + case Gran64K: |
41 | + * its undef_hook struct. | 39 | + return (level == 1 && arm_pamax(cpu) == 52) || level == 2; |
42 | + */ | 40 | + default: |
43 | + return ((opcode & 0xffff) == 0xde01) || (opcode == 0xa000f7f0); | 41 | + g_assert_not_reached(); |
44 | + } | 42 | + } |
45 | +} | 43 | +} |
46 | + | 44 | + |
47 | void cpu_loop(CPUARMState *env) | 45 | /** |
48 | { | 46 | * get_phys_addr_lpae: perform one stage of page table walk, LPAE format |
49 | CPUState *cs = env_cpu(env); | 47 | * |
50 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | 48 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, |
51 | /* FIXME - what to do if get_user() fails? */ | 49 | new_descriptor = descriptor; |
52 | get_user_code_u32(opcode, env->regs[15], env); | 50 | |
53 | 51 | restart_atomic_update: | |
54 | + /* | 52 | - if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) { |
55 | + * The Linux kernel treats some UDF patterns specially | 53 | - /* Invalid, or the Reserved level 3 encoding */ |
56 | + * to use as breakpoints (instead of the architectural | 54 | + if (!(descriptor & 1) || |
57 | + * bkpt insn). These should trigger a SIGTRAP rather | 55 | + (!(descriptor & 2) && |
58 | + * than SIGILL. | 56 | + !lpae_block_desc_valid(cpu, param.ds, param.gran, level))) { |
59 | + */ | 57 | + /* Invalid, or a block descriptor at an invalid level */ |
60 | + if (insn_is_linux_bkpt(opcode, env->thumb)) { | 58 | goto do_translation_fault; |
61 | + goto excp_debug; | 59 | } |
62 | + } | 60 | |
63 | + | ||
64 | rc = EmulateAll(opcode, &ts->fpa, env); | ||
65 | if (rc == 0) { /* illegal instruction */ | ||
66 | info.si_signo = TARGET_SIGILL; | ||
67 | -- | 61 | -- |
68 | 2.20.1 | 62 | 2.34.1 |
69 | |||
70 | diff view generated by jsdifflib |
1 | The semihosting SYS_HEAPINFO call is supposed to return an array | 1 | When we report faults due to stage 2 faults during a stage 1 |
---|---|---|---|
2 | of four guest addresses: | 2 | page table walk, the 'level' parameter should be the level |
3 | * base of heap memory | 3 | of the walk in stage 2 that faulted, not the level of the |
4 | * limit of heap memory | 4 | walk in stage 1. Correct the reporting of these faults. |
5 | * base of stack memory | ||
6 | * limit of stack memory | ||
7 | |||
8 | Some semihosting programs (including those compiled to use the | ||
9 | 'newlib' embedded C library) use this call to work out where they | ||
10 | should initialize themselves to. | ||
11 | |||
12 | QEMU's implementation when in system emulation mode is very | ||
13 | simplistic: we say that the heap starts halfway into RAM and | ||
14 | continues to the end of RAM, and the stack starts at the top of RAM | ||
15 | and works down to the bottom. Unfortunately the code assumes that | ||
16 | the base address of RAM is at address 0, so on boards like 'virt' | ||
17 | where this is not true the addresses returned will all be wrong and | ||
18 | the guest application will usually crash. | ||
19 | |||
20 | Conveniently since all Arm boards call arm_load_kernel() we have the | ||
21 | base address of the main RAM block in the arm_boot_info struct which | ||
22 | is accessible via the CPU object. Use this to return sensible values | ||
23 | from SYS_HEAPINFO. | ||
24 | 5 | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
26 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
27 | Message-id: 20201119092346.32356-1-peter.maydell@linaro.org | 8 | Message-id: 20230807141514.19075-15-peter.maydell@linaro.org |
28 | --- | 9 | --- |
29 | target/arm/arm-semi.c | 12 ++++++++---- | 10 | target/arm/ptw.c | 10 +++++++--- |
30 | 1 file changed, 8 insertions(+), 4 deletions(-) | 11 | 1 file changed, 7 insertions(+), 3 deletions(-) |
31 | 12 | ||
32 | diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c | 13 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
33 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/arm-semi.c | 15 | --- a/target/arm/ptw.c |
35 | +++ b/target/arm/arm-semi.c | 16 | +++ b/target/arm/ptw.c |
36 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, |
37 | #else | 18 | do_translation_fault: |
38 | #include "exec/gdbstub.h" | 19 | fi->type = ARMFault_Translation; |
39 | #include "qemu/cutils.h" | 20 | do_fault: |
40 | +#include "hw/arm/boot.h" | 21 | - fi->level = level; |
41 | #endif | 22 | - /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ |
42 | 23 | - fi->stage2 = fi->s1ptw || regime_is_stage2(mmu_idx); | |
43 | #define TARGET_SYS_OPEN 0x01 | 24 | + if (fi->s1ptw) { |
44 | @@ -XXX,XX +XXX,XX @@ target_ulong do_arm_semihosting(CPUARMState *env) | 25 | + /* Retain the existing stage 2 fi->level */ |
45 | int i; | 26 | + assert(fi->stage2); |
46 | #ifdef CONFIG_USER_ONLY | 27 | + } else { |
47 | TaskState *ts = cs->opaque; | 28 | + fi->level = level; |
48 | +#else | 29 | + fi->stage2 = regime_is_stage2(mmu_idx); |
49 | + const struct arm_boot_info *info = env->boot_info; | 30 | + } |
50 | + target_ulong rambase = info->loader_start; | 31 | fi->s1ns = fault_s1ns(ptw->in_space, mmu_idx); |
51 | #endif | 32 | return true; |
52 | 33 | } | |
53 | GET_ARG(0); | ||
54 | @@ -XXX,XX +XXX,XX @@ target_ulong do_arm_semihosting(CPUARMState *env) | ||
55 | #else | ||
56 | limit = ram_size; | ||
57 | /* TODO: Make this use the limit of the loaded application. */ | ||
58 | - retvals[0] = limit / 2; | ||
59 | - retvals[1] = limit; | ||
60 | - retvals[2] = limit; /* Stack base */ | ||
61 | - retvals[3] = 0; /* Stack limit. */ | ||
62 | + retvals[0] = rambase + limit / 2; | ||
63 | + retvals[1] = rambase + limit; | ||
64 | + retvals[2] = rambase + limit; /* Stack base */ | ||
65 | + retvals[3] = rambase; /* Stack limit. */ | ||
66 | #endif | ||
67 | |||
68 | for (i = 0; i < ARRAY_SIZE(retvals); i++) { | ||
69 | -- | 34 | -- |
70 | 2.20.1 | 35 | 2.34.1 |
71 | |||
72 | diff view generated by jsdifflib |
1 | Currently target-i386.rst includes the documentation of the 'pc' | 1 | The PAR_EL1.SH field documents that for the cases of: |
---|---|---|---|
2 | machine model inline. Split it out into its own file, in a | 2 | * Device memory |
3 | similar way to target-i386.rst; this gives us a place to put | 3 | * Normal memory with both Inner and Outer Non-Cacheable |
4 | documentation of other i386 machine models, such as 'microvm'. | 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. | ||
5 | 8 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20230807141514.19075-16-peter.maydell@linaro.org | ||
8 | --- | 12 | --- |
9 | docs/system/i386/pc.rst | 7 +++++++ | 13 | target/arm/helper.c | 15 ++++++++++++++- |
10 | docs/system/target-i386.rst | 18 +++++++++++++----- | 14 | 1 file changed, 14 insertions(+), 1 deletion(-) |
11 | 2 files changed, 20 insertions(+), 5 deletions(-) | ||
12 | create mode 100644 docs/system/i386/pc.rst | ||
13 | 15 | ||
14 | diff --git a/docs/system/i386/pc.rst b/docs/system/i386/pc.rst | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | new file mode 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | index XXXXXXX..XXXXXXX | 18 | --- a/target/arm/helper.c |
17 | --- /dev/null | 19 | +++ b/target/arm/helper.c |
18 | +++ b/docs/system/i386/pc.rst | 20 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, |
19 | @@ -XXX,XX +XXX,XX @@ | 21 | } |
20 | +i440fx PC (``pc-i440fx``, ``pc``) | 22 | |
21 | +================================= | 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 | +} | ||
22 | + | 36 | + |
23 | +Peripherals | 37 | static uint64_t do_ats_write(CPUARMState *env, uint64_t value, |
24 | +~~~~~~~~~~~ | 38 | MMUAccessType access_type, ARMMMUIdx mmu_idx, |
25 | + | 39 | bool is_secure) |
26 | +.. include:: ../target-i386-desc.rst.inc | 40 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, |
27 | diff --git a/docs/system/target-i386.rst b/docs/system/target-i386.rst | 41 | par64 |= (1 << 9); /* NS */ |
28 | index XXXXXXX..XXXXXXX 100644 | 42 | } |
29 | --- a/docs/system/target-i386.rst | 43 | par64 |= (uint64_t)res.cacheattrs.attrs << 56; /* ATTR */ |
30 | +++ b/docs/system/target-i386.rst | 44 | - par64 |= res.cacheattrs.shareability << 7; /* SH */ |
31 | @@ -XXX,XX +XXX,XX @@ | 45 | + par64 |= par_el1_shareability(&res) << 7; /* SH */ |
32 | .. _QEMU-PC-System-emulator: | 46 | } else { |
33 | 47 | uint32_t fsr = arm_fi_to_lfsc(&fi); | |
34 | -x86 (PC) System emulator | ||
35 | ------------------------- | ||
36 | +x86 System emulator | ||
37 | +------------------- | ||
38 | |||
39 | .. _pcsys_005fdevices: | ||
40 | |||
41 | -Peripherals | ||
42 | -~~~~~~~~~~~ | ||
43 | +Board-specific documentation | ||
44 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
45 | |||
46 | -.. include:: target-i386-desc.rst.inc | ||
47 | +.. | ||
48 | + This table of contents should be kept sorted alphabetically | ||
49 | + by the title text of each file, which isn't the same ordering | ||
50 | + as an alphabetical sort by filename. | ||
51 | + | ||
52 | +.. toctree:: | ||
53 | + :maxdepth: 1 | ||
54 | + | ||
55 | + i386/pc | ||
56 | |||
57 | .. include:: cpu-models-x86.rst.inc | ||
58 | 48 | ||
59 | -- | 49 | -- |
60 | 2.20.1 | 50 | 2.34.1 |
61 | |||
62 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
1 | 2 | ||
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 |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Using a target unsigned long would limit the Input Address to a LPAE | 3 | When HCR_EL2.E2H is enabled, TLB entries are formed using the EL2&0 |
4 | page-walk to 32 bits on AArch32 and 64 bits on AArch64. This is okay | 4 | translation regime, instead of the EL2 translation regime. The TLB VAE2* |
5 | for stage 1 or on AArch64, but it is insufficient for stage 2 on | 5 | instructions invalidate the regime that corresponds to the current value |
6 | AArch32. In that later case, the Input Address can have up to 40 bits. | 6 | of HCR_EL2.E2H. |
7 | 7 | ||
8 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 8 | At the moment we only invalidate the EL2 translation regime. This causes |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | problems with RMM, which issues TLBI VAE2IS instructions with |
10 | Message-id: 20201118150414.18360-1-remi@remlab.net | 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 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 20 | --- |
13 | target/arm/helper.c | 4 ++-- | 21 | target/arm/helper.c | 50 ++++++++++++++++++++++++++++++++++++--------- |
14 | 1 file changed, 2 insertions(+), 2 deletions(-) | 22 | 1 file changed, 40 insertions(+), 10 deletions(-) |
15 | 23 | ||
16 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 24 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper.c | 26 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/helper.c | 27 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ | 28 | @@ -XXX,XX +XXX,XX @@ static int vae1_tlbmask(CPUARMState *env) |
21 | 29 | return mask; | |
22 | #ifndef CONFIG_USER_ONLY | 30 | } |
23 | 31 | ||
24 | -static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | 32 | +static int vae2_tlbmask(CPUARMState *env) |
25 | +static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | 33 | +{ |
26 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 34 | + uint64_t hcr = arm_hcr_el2_eff(env); |
27 | bool s1_is_el0, | 35 | + uint16_t mask; |
28 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | 36 | + |
29 | @@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | 37 | + if (hcr & HCR_E2H) { |
30 | * @fi: set to fault info if the translation fails | 38 | + mask = ARMMMUIdxBit_E20_2 | |
31 | * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | 39 | + ARMMMUIdxBit_E20_2_PAN | |
32 | */ | 40 | + ARMMMUIdxBit_E20_0; |
33 | -static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | 41 | + } else { |
34 | +static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | 42 | + mask = ARMMMUIdxBit_E2; |
35 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 43 | + } |
36 | bool s1_is_el0, | 44 | + return mask; |
37 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | 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) | ||
38 | -- | 117 | -- |
39 | 2.20.1 | 118 | 2.34.1 |
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Since commit aa35ec2213b ("hw/arm/raspi: Use more specific | 3 | GPC checks are not performed on the output address for AT instructions, |
4 | machine names") the raspi2/raspi3 machines have been renamed | 4 | as stated by ARM DDI 0487J in D8.12.2: |
5 | as raspi2b/raspi3b. | ||
6 | 5 | ||
7 | Note, rather than the raspi3b, the raspi3ap introduced in | 6 | When populating PAR_EL1 with the result of an address translation |
8 | commit 5be94252d34 ("hw/arm/raspi: Add the Raspberry Pi 3 | 7 | instruction, granule protection checks are not performed on the final |
9 | model A+") is a closer match to what QEMU models, but only | 8 | output address of a successful translation. |
10 | provides 512 MB of RAM. | ||
11 | 9 | ||
12 | As more Raspberry Pi 2/3 models are emulated, in order | 10 | Rename get_phys_addr_with_secure(), since it's only used to handle AT |
13 | to avoid confusion, deprecate the raspi2/raspi3 machine | 11 | instructions. |
14 | aliases. | ||
15 | 12 | ||
16 | ACKed-by: Peter Krempa <pkrempa@redhat.com> | 13 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 15 | Message-id: 20230809123706.1842548-4-jean-philippe@linaro.org |
19 | Message-id: 20201120173953.2539469-2-f4bug@amsat.org | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 17 | --- |
22 | docs/system/deprecated.rst | 7 +++++++ | 18 | target/arm/internals.h | 25 ++++++++++++++----------- |
23 | 1 file changed, 7 insertions(+) | 19 | target/arm/helper.c | 8 ++++++-- |
20 | target/arm/ptw.c | 11 ++++++----- | ||
21 | 3 files changed, 26 insertions(+), 18 deletions(-) | ||
24 | 22 | ||
25 | diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst | 23 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
26 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/docs/system/deprecated.rst | 25 | --- a/target/arm/internals.h |
28 | +++ b/docs/system/deprecated.rst | 26 | +++ b/target/arm/internals.h |
29 | @@ -XXX,XX +XXX,XX @@ This machine has been renamed ``fuloong2e``. | 27 | @@ -XXX,XX +XXX,XX @@ typedef struct GetPhysAddrResult { |
30 | These machine types are very old and likely can not be used for live migration | 28 | } GetPhysAddrResult; |
31 | from old QEMU versions anymore. A newer machine type should be used instead. | 29 | |
32 | 30 | /** | |
33 | +Raspberry Pi ``raspi2`` and ``raspi3`` machines (since 5.2) | 31 | - * get_phys_addr_with_secure: get the physical address for a virtual address |
34 | +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | 32 | + * get_phys_addr: get the physical address for a virtual address |
35 | + | 33 | * @env: CPUARMState |
36 | +The Raspberry Pi machines come in various models (A, A+, B, B+). To be able | 34 | * @address: virtual address to get physical address for |
37 | +to distinguish which model QEMU is implementing, the ``raspi2`` and ``raspi3`` | 35 | * @access_type: 0 for read, 1 for write, 2 for execute |
38 | +machines have been renamed ``raspi2b`` and ``raspi3b``. | 36 | * @mmu_idx: MMU index indicating required translation regime |
39 | + | 37 | - * @is_secure: security state for the access |
40 | Device options | 38 | * @result: set on translation success. |
41 | -------------- | 39 | * @fi: set to fault info if the translation fails |
42 | 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, | ||
43 | -- | 127 | -- |
44 | 2.20.1 | 128 | 2.34.1 |
45 | |||
46 | diff view generated by jsdifflib |
1 | From: Chen Qun <kuhn.chenqun@huawei.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When 'j = icu->nr_sense – 1', the 'j < icu->nr_sense' condition is true, | 3 | At the moment we only handle Secure and Nonsecure security spaces for |
4 | then 'j = icu->nr_sense', the'icu->init_sense[j]' has out-of-bounds access. | 4 | the AT instructions. Add support for Realm and Root. |
5 | 5 | ||
6 | The asan showed stack: | 6 | For AArch64, arm_security_space() gives the desired space. ARM DDI0487J |
7 | ERROR: AddressSanitizer: heap-buffer-overflow on address 0x604000004d7d at pc 0x55852cd26a76 bp 0x7ffe39f26200 sp 0x7ffe39f261f0 | 7 | says (R_NYXTL): |
8 | READ of size 1 at 0x604000004d7d thread T0 | 8 | |
9 | #0 0x55852cd26a75 in rxicu_realize ../hw/intc/rx_icu.c:311 | 9 | If EL3 is implemented, then when an address translation instruction |
10 | #1 0x55852cf075f7 in device_set_realized ../hw/core/qdev.c:886 | 10 | that applies to an Exception level lower than EL3 is executed, the |
11 | #2 0x55852cd4a32f in property_set_bool ../qom/object.c:2251 | 11 | Effective value of SCR_EL3.{NSE, NS} determines the target Security |
12 | #3 0x55852cd4f9bb in object_property_set ../qom/object.c:1398 | 12 | state that the instruction applies to. |
13 | #4 0x55852cd54f3f in object_property_set_qobject ../qom/qom-qobject.c:28 | 13 | |
14 | #5 0x55852cd4fc3f in object_property_set_bool ../qom/object.c:1465 | 14 | For AArch32, some instructions can access NonSecure space from Secure, |
15 | #6 0x55852cbf0b27 in register_icu ../hw/rx/rx62n.c:156 | 15 | so we still need to pass the state explicitly to do_ats_write(). |
16 | #7 0x55852cbf12a6 in rx62n_realize ../hw/rx/rx62n.c:261 | 16 | |
17 | #8 0x55852cf075f7 in device_set_realized ../hw/core/qdev.c:886 | 17 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
18 | #9 0x55852cd4a32f in property_set_bool ../qom/object.c:2251 | ||
19 | #10 0x55852cd4f9bb in object_property_set ../qom/object.c:1398 | ||
20 | #11 0x55852cd54f3f in object_property_set_qobject ../qom/qom-qobject.c:28 | ||
21 | #12 0x55852cd4fc3f in object_property_set_bool ../qom/object.c:1465 | ||
22 | #13 0x55852cbf1a85 in rx_gdbsim_init ../hw/rx/rx-gdbsim.c:109 | ||
23 | #14 0x55852cd22de0 in qemu_init ../softmmu/vl.c:4380 | ||
24 | #15 0x55852ca57088 in main ../softmmu/main.c:49 | ||
25 | #16 0x7feefafa5d42 in __libc_start_main (/lib64/libc.so.6+0x26d42) | ||
26 | |||
27 | Add the 'ice->src[i].sense' initialize to the default value, and then | ||
28 | process init_sense array to identify which irqs should be level-triggered. | ||
29 | |||
30 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
31 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
32 | Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com> | ||
33 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
34 | Message-id: 20201111141733.2358800-1-kuhn.chenqun@huawei.com | 19 | Message-id: 20230809123706.1842548-5-jean-philippe@linaro.org |
35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
36 | --- | 21 | --- |
37 | hw/intc/rx_icu.c | 18 ++++++++---------- | 22 | target/arm/internals.h | 18 +++++++++--------- |
38 | 1 file changed, 8 insertions(+), 10 deletions(-) | 23 | target/arm/helper.c | 27 ++++++++++++--------------- |
39 | 24 | target/arm/ptw.c | 12 ++++++------ | |
40 | diff --git a/hw/intc/rx_icu.c b/hw/intc/rx_icu.c | 25 | 3 files changed, 27 insertions(+), 30 deletions(-) |
26 | |||
27 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/hw/intc/rx_icu.c | 29 | --- a/target/arm/internals.h |
43 | +++ b/hw/intc/rx_icu.c | 30 | +++ b/target/arm/internals.h |
44 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps icu_ops = { | 31 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, |
45 | static void rxicu_realize(DeviceState *dev, Error **errp) | 32 | __attribute__((nonnull)); |
33 | |||
34 | /** | ||
35 | - * get_phys_addr_with_secure_nogpc: get the physical address for a virtual | ||
36 | - * address | ||
37 | + * get_phys_addr_with_space_nogpc: get the physical address for a virtual | ||
38 | + * address | ||
39 | * @env: CPUARMState | ||
40 | * @address: virtual address to get physical address for | ||
41 | * @access_type: 0 for read, 1 for write, 2 for execute | ||
42 | * @mmu_idx: MMU index indicating required translation regime | ||
43 | - * @is_secure: security state for the access | ||
44 | + * @space: security space for the access | ||
45 | * @result: set on translation success. | ||
46 | * @fi: set to fault info if the translation fails | ||
47 | * | ||
48 | - * Similar to get_phys_addr, but use the given security regime and don't perform | ||
49 | + * Similar to get_phys_addr, but use the given security space and don't perform | ||
50 | * a Granule Protection Check on the resulting address. | ||
51 | */ | ||
52 | -bool get_phys_addr_with_secure_nogpc(CPUARMState *env, target_ulong address, | ||
53 | - MMUAccessType access_type, | ||
54 | - ARMMMUIdx mmu_idx, bool is_secure, | ||
55 | - GetPhysAddrResult *result, | ||
56 | - ARMMMUFaultInfo *fi) | ||
57 | +bool get_phys_addr_with_space_nogpc(CPUARMState *env, target_ulong address, | ||
58 | + MMUAccessType access_type, | ||
59 | + ARMMMUIdx mmu_idx, ARMSecuritySpace space, | ||
60 | + GetPhysAddrResult *result, | ||
61 | + ARMMMUFaultInfo *fi) | ||
62 | __attribute__((nonnull)); | ||
63 | |||
64 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
65 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/helper.c | ||
68 | +++ b/target/arm/helper.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static int par_el1_shareability(GetPhysAddrResult *res) | ||
70 | |||
71 | static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | ||
72 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
73 | - bool is_secure) | ||
74 | + ARMSecuritySpace ss) | ||
46 | { | 75 | { |
47 | RXICUState *icu = RX_ICU(dev); | 76 | bool ret; |
48 | - int i, j; | 77 | uint64_t par64; |
49 | + int i; | 78 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, |
50 | 79 | * I_MXTJT: Granule protection checks are not performed on the final address | |
51 | if (icu->init_sense == NULL) { | 80 | * of a successful translation. |
52 | qemu_log_mask(LOG_GUEST_ERROR, | 81 | */ |
53 | "rx_icu: trigger-level property must be set."); | 82 | - ret = get_phys_addr_with_secure_nogpc(env, value, access_type, mmu_idx, |
54 | return; | 83 | - is_secure, &res, &fi); |
84 | + ret = get_phys_addr_with_space_nogpc(env, value, access_type, mmu_idx, ss, | ||
85 | + &res, &fi); | ||
86 | |||
87 | /* | ||
88 | * ATS operations only do S1 or S1+S2 translations, so we never | ||
89 | @@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
90 | uint64_t par64; | ||
91 | ARMMMUIdx mmu_idx; | ||
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(); | ||
55 | } | 137 | } |
56 | - for (i = j = 0; i < NR_IRQS; i++) { | 138 | |
57 | - if (icu->init_sense[j] == i) { | 139 | - par64 = do_ats_write(env, value, access_type, mmu_idx, secure); |
58 | - icu->src[i].sense = TRG_LEVEL; | 140 | + par64 = do_ats_write(env, value, access_type, mmu_idx, ss); |
59 | - if (j < icu->nr_sense) { | 141 | |
60 | - j++; | 142 | A32_BANKED_CURRENT_REG_SET(env, par, par64); |
61 | - } | 143 | #else |
62 | - } else { | 144 | @@ -XXX,XX +XXX,XX @@ static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri, |
63 | - icu->src[i].sense = TRG_PEDGE; | 145 | uint64_t par64; |
64 | - } | 146 | |
65 | + | 147 | /* There is no SecureEL2 for AArch32. */ |
66 | + for (i = 0; i < NR_IRQS; i++) { | 148 | - par64 = do_ats_write(env, value, access_type, ARMMMUIdx_E2, false); |
67 | + icu->src[i].sense = TRG_PEDGE; | 149 | + par64 = do_ats_write(env, value, access_type, ARMMMUIdx_E2, |
68 | + } | 150 | + ARMSS_NonSecure); |
69 | + for (i = 0; i < icu->nr_sense; i++) { | 151 | |
70 | + uint8_t irqno = icu->init_sense[i]; | 152 | A32_BANKED_CURRENT_REG_SET(env, par, par64); |
71 | + icu->src[irqno].sense = TRG_LEVEL; | 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, | ||
72 | } | 171 | } |
73 | icu->req_irq = -1; | 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); | ||
74 | } | 204 | } |
75 | -- | 205 | -- |
76 | 2.20.1 | 206 | 2.34.1 |
77 | |||
78 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
1 | 2 | ||
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 |
New patch | |||
---|---|---|---|
1 | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | |
2 | |||
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, >_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 |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Document the following Raspberry Pi models: | 3 | A typo, noted in the bug report, resulting in an |
4 | incorrect write offset. | ||
4 | 5 | ||
5 | - raspi0 Raspberry Pi Zero (revision 1.2) | 6 | Cc: qemu-stable@nongnu.org |
6 | - raspi1ap Raspberry Pi A+ (revision 1.1) | 7 | Fixes: 7390e0e9ab8 ("target/arm: Implement SME LD1, ST1") |
7 | - raspi2b Raspberry Pi 2B (revision 1.1) | 8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1833 |
8 | - raspi3ap Raspberry Pi 3A+ (revision 1.0) | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | - raspi3b Raspberry Pi 3B (revision 1.2) | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | 11 | Message-id: 20230818214255.146905-1-richard.henderson@linaro.org | |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20201120173953.2539469-3-f4bug@amsat.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 13 | --- |
16 | docs/system/arm/raspi.rst | 43 ++++++++++++++++++++++++++++++++++++++ | 14 | target/arm/tcg/sme_helper.c | 2 +- |
17 | docs/system/target-arm.rst | 1 + | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
18 | MAINTAINERS | 1 + | ||
19 | 3 files changed, 45 insertions(+) | ||
20 | create mode 100644 docs/system/arm/raspi.rst | ||
21 | 16 | ||
22 | diff --git a/docs/system/arm/raspi.rst b/docs/system/arm/raspi.rst | 17 | diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c |
23 | new file mode 100644 | ||
24 | index XXXXXXX..XXXXXXX | ||
25 | --- /dev/null | ||
26 | +++ b/docs/system/arm/raspi.rst | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | +Raspberry Pi boards (``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b``) | ||
29 | +====================================================================================== | ||
30 | + | ||
31 | + | ||
32 | +QEMU provides models of the following Raspberry Pi boards: | ||
33 | + | ||
34 | +``raspi0`` and ``raspi1ap`` | ||
35 | + ARM1176JZF-S core, 512 MiB of RAM | ||
36 | +``raspi2b`` | ||
37 | + Cortex-A7 (4 cores), 1 GiB of RAM | ||
38 | +``raspi3ap`` | ||
39 | + Cortex-A53 (4 cores), 512 MiB of RAM | ||
40 | +``raspi3b`` | ||
41 | + Cortex-A53 (4 cores), 1 GiB of RAM | ||
42 | + | ||
43 | + | ||
44 | +Implemented devices | ||
45 | +------------------- | ||
46 | + | ||
47 | + * ARM1176JZF-S, Cortex-A7 or Cortex-A53 CPU | ||
48 | + * Interrupt controller | ||
49 | + * DMA controller | ||
50 | + * Clock and reset controller (CPRMAN) | ||
51 | + * System Timer | ||
52 | + * GPIO controller | ||
53 | + * Serial ports (BCM2835 AUX - 16550 based - and PL011) | ||
54 | + * Random Number Generator (RNG) | ||
55 | + * Frame Buffer | ||
56 | + * USB host (USBH) | ||
57 | + * GPIO controller | ||
58 | + * SD/MMC host controller | ||
59 | + * SoC thermal sensor | ||
60 | + * USB2 host controller (DWC2 and MPHI) | ||
61 | + * MailBox controller (MBOX) | ||
62 | + * VideoCore firmware (property) | ||
63 | + | ||
64 | + | ||
65 | +Missing devices | ||
66 | +--------------- | ||
67 | + | ||
68 | + * Peripheral SPI controller (SPI) | ||
69 | + * Analog to Digital Converter (ADC) | ||
70 | + * Pulse Width Modulation (PWM) | ||
71 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
72 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
73 | --- a/docs/system/target-arm.rst | 19 | --- a/target/arm/tcg/sme_helper.c |
74 | +++ b/docs/system/target-arm.rst | 20 | +++ b/target/arm/tcg/sme_helper.c |
75 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | 21 | @@ -XXX,XX +XXX,XX @@ static inline void HNAME##_host(void *za, intptr_t off, void *host) \ |
76 | arm/nuvoton | 22 | { \ |
77 | arm/orangepi | 23 | uint64_t *ptr = za + off; \ |
78 | arm/palm | 24 | HOST(host, ptr[BE]); \ |
79 | + arm/raspi | 25 | - HOST(host + 1, ptr[!BE]); \ |
80 | arm/xscale | 26 | + HOST(host + 8, ptr[!BE]); \ |
81 | arm/collie | 27 | } \ |
82 | arm/sx1 | 28 | static inline void VNAME##_v_host(void *za, intptr_t off, void *host) \ |
83 | diff --git a/MAINTAINERS b/MAINTAINERS | 29 | { \ |
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/MAINTAINERS | ||
86 | +++ b/MAINTAINERS | ||
87 | @@ -XXX,XX +XXX,XX @@ F: hw/arm/raspi_platform.h | ||
88 | F: hw/*/bcm283* | ||
89 | F: include/hw/arm/raspi* | ||
90 | F: include/hw/*/bcm283* | ||
91 | +F: docs/system/arm/raspi.rst | ||
92 | |||
93 | Real View | ||
94 | M: Peter Maydell <peter.maydell@linaro.org> | ||
95 | -- | 30 | -- |
96 | 2.20.1 | 31 | 2.34.1 |
97 | 32 | ||
98 | 33 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Fixes: 0553ef42571 ("docs: add Orange Pi PC document") | 3 | Typo applied byte-wise shift instead of double-word shift. |
4 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | |
5 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> | 5 | Cc: qemu-stable@nongnu.org |
6 | Message-id: 20201120154545.2504625-5-f4bug@amsat.org | 6 | Fixes: 631e565450c ("target/arm: Create gen_gvec_[us]sra") |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1737 |
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 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | MAINTAINERS | 2 +- | 13 | target/arm/tcg/translate.c | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 15 | ||
13 | diff --git a/MAINTAINERS b/MAINTAINERS | 16 | diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/MAINTAINERS | 18 | --- a/target/arm/tcg/translate.c |
16 | +++ b/MAINTAINERS | 19 | +++ b/target/arm/tcg/translate.c |
17 | @@ -XXX,XX +XXX,XX @@ S: Maintained | 20 | @@ -XXX,XX +XXX,XX @@ void gen_gvec_ssra(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs, |
18 | F: hw/*/allwinner-h3* | 21 | .vece = MO_32 }, |
19 | F: include/hw/*/allwinner-h3* | 22 | { .fni8 = gen_ssra64_i64, |
20 | F: hw/arm/orangepi.c | 23 | .fniv = gen_ssra_vec, |
21 | -F: docs/system/orangepi.rst | 24 | - .fno = gen_helper_gvec_ssra_b, |
22 | +F: docs/system/arm/orangepi.rst | 25 | + .fno = gen_helper_gvec_ssra_d, |
23 | 26 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
24 | ARM PrimeCell and CMSDK devices | 27 | .opt_opc = vecop_list, |
25 | M: Peter Maydell <peter.maydell@linaro.org> | 28 | .load_dest = true, |
26 | -- | 29 | -- |
27 | 2.20.1 | 30 | 2.34.1 |
28 | 31 | ||
29 | 32 | diff view generated by jsdifflib |