1 | ARM queue: nothing particularly exciting here, but no | 1 | The following changes since commit 65cc5ccf06a74c98de73ec683d9a543baa302a12: |
---|---|---|---|
2 | reason to sit on them for another week. | ||
3 | 2 | ||
4 | thanks | 3 | Merge tag 'pull-riscv-to-apply-20230120' of https://github.com/alistair23/qemu into staging (2023-01-20 16:17:56 +0000) |
5 | -- PMM | ||
6 | 4 | ||
7 | The following changes since commit 61eedf7aec0e2395aabd628cc055096909a3ea15: | 5 | are available in the Git repository at: |
8 | 6 | ||
9 | tests/prom-env: Ease time-out problems on slow hosts (2017-02-10 15:44:53 +0000) | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230123 |
10 | 8 | ||
11 | are available in the git repository at: | 9 | for you to fetch changes up to 3b07a936d3bfe97b07ddffcfbb532985a88033dd: |
12 | 10 | ||
13 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170210 | 11 | target/arm: Look up ARMCPRegInfo at runtime (2023-01-23 13:32:38 +0000) |
14 | |||
15 | for you to fetch changes up to b4cc583f0285a2e1e78621dfba142f00ca47414a: | ||
16 | |||
17 | aspeed/smc: use a modulo to check segment limits (2017-02-10 17:40:30 +0000) | ||
18 | 12 | ||
19 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
20 | target-arm queue: | 14 | target-arm queue: |
21 | * aspeed: minor fixes | 15 | * Widen cnthctl_el2 to uint64_t |
22 | * virt: declare fwcfg and virtio-mmio as DMA coherent in DT & ACPI | 16 | * Unify checking for M Main Extension in MRS/MSR |
23 | * arm: enable basic TCG emulation of PMU for AArch64 | 17 | * bitbang_i2c, versatile_i2c: code cleanups |
18 | * SME: refactor SME SM/ZA handling | ||
19 | * Fix physical address resolution for MTE | ||
20 | * Fix in_debug path in S1_ptw_translate | ||
21 | * Don't set EXC_RETURN.ES if Security Extension not present | ||
22 | * Implement DBGCLAIM registers | ||
23 | * Provide stubs for more external debug registers | ||
24 | * Look up ARMCPRegInfo at runtime, not translate time | ||
24 | 25 | ||
25 | ---------------------------------------------------------------- | 26 | ---------------------------------------------------------------- |
26 | Alexander Graf (4): | 27 | David Reiss (1): |
27 | target-arm: Declare virtio-mmio as dma-coherent in dt | 28 | target/arm: Unify checking for M Main Extension in MRS/MSR |
28 | hw/arm/virt: Declare virtio-mmio as dma cache coherent in ACPI | ||
29 | hw/arm/virt: Declare fwcfg as dma cache coherent in ACPI | ||
30 | hw/arm/virt: Declare fwcfg as dma cache coherent in dt | ||
31 | 29 | ||
32 | Cédric Le Goater (4): | 30 | Evgeny Iakovlev (2): |
33 | aspeed: check for negative values returned by blk_getlength() | 31 | target/arm: implement DBGCLAIM registers |
34 | aspeed: remove useless comment on controller segment size | 32 | target/arm: provide stubs for more external debug registers |
35 | aspeed/smc: handle dummies only in fast read mode | ||
36 | aspeed/smc: use a modulo to check segment limits | ||
37 | 33 | ||
38 | Wei Huang (4): | 34 | Peter Maydell (1): |
39 | target-arm: Add support for PMU register PMSELR_EL0 | 35 | target/arm: Don't set EXC_RETURN.ES if Security Extension not present |
40 | target-arm: Add support for AArch64 PMU register PMXEVTYPER_EL0 | ||
41 | target-arm: Add support for PMU register PMINTENSET_EL1 | ||
42 | target-arm: Enable vPMU support under TCG mode | ||
43 | 36 | ||
44 | target/arm/cpu.h | 4 +-- | 37 | Philippe Mathieu-Daudé (10): |
45 | hw/arm/aspeed.c | 22 +++++++++----- | 38 | hw/i2c/bitbang_i2c: Define TYPE_GPIO_I2C in public header |
46 | hw/arm/vexpress.c | 1 + | 39 | hw/i2c/bitbang_i2c: Remove unused dummy MemoryRegion |
47 | hw/arm/virt-acpi-build.c | 2 ++ | 40 | hw/i2c/bitbang_i2c: Change state calling bitbang_i2c_set_state() helper |
48 | hw/arm/virt.c | 4 ++- | 41 | hw/i2c/bitbang_i2c: Trace state changes |
49 | hw/ssi/aspeed_smc.c | 13 +++++---- | 42 | hw/i2c/bitbang_i2c: Convert DPRINTF() to trace events |
50 | target/arm/cpu.c | 2 +- | 43 | hw/i2c/versatile_i2c: Drop useless casts from void * to pointer |
51 | target/arm/helper.c | 74 ++++++++++++++++++++++++++++++++++++------------ | 44 | hw/i2c/versatile_i2c: Replace VersatileI2CState -> ArmSbconI2CState |
52 | 8 files changed, 88 insertions(+), 34 deletions(-) | 45 | hw/i2c/versatile_i2c: Replace TYPE_VERSATILE_I2C -> TYPE_ARM_SBCON_I2C |
46 | hw/i2c/versatile_i2c: Use ARM_SBCON_I2C() macro | ||
47 | hw/i2c/versatile_i2c: Rename versatile_i2c -> arm_sbcon_i2c | ||
53 | 48 | ||
49 | Richard Henderson (12): | ||
50 | target/arm: Widen cnthctl_el2 to uint64_t | ||
51 | target/arm/sme: Reorg SME access handling in handle_msr_i() | ||
52 | target/arm/sme: Rebuild hflags in set_pstate() helpers | ||
53 | target/arm/sme: Introduce aarch64_set_svcr() | ||
54 | target/arm/sme: Reset SVE state in aarch64_set_svcr() | ||
55 | target/arm/sme: Reset ZA state in aarch64_set_svcr() | ||
56 | target/arm/sme: Rebuild hflags in aarch64_set_svcr() | ||
57 | target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr() | ||
58 | target/arm: Fix physical address resolution for MTE | ||
59 | target/arm: Fix in_debug path in S1_ptw_translate | ||
60 | target/arm: Reorg do_coproc_insn | ||
61 | target/arm: Look up ARMCPRegInfo at runtime | ||
62 | |||
63 | MAINTAINERS | 1 + | ||
64 | include/hw/i2c/arm_sbcon_i2c.h | 6 +- | ||
65 | include/hw/i2c/bitbang_i2c.h | 2 + | ||
66 | target/arm/cpu.h | 5 +- | ||
67 | target/arm/helper-sme.h | 3 +- | ||
68 | target/arm/helper.h | 11 +- | ||
69 | target/arm/translate.h | 7 + | ||
70 | hw/arm/musicpal.c | 3 +- | ||
71 | hw/arm/realview.c | 2 +- | ||
72 | hw/arm/versatilepb.c | 2 +- | ||
73 | hw/arm/vexpress.c | 2 +- | ||
74 | hw/i2c/{versatile_i2c.c => arm_sbcon_i2c.c} | 39 ++- | ||
75 | hw/i2c/bitbang_i2c.c | 80 ++++-- | ||
76 | linux-user/aarch64/cpu_loop.c | 11 +- | ||
77 | linux-user/aarch64/signal.c | 13 +- | ||
78 | target/arm/debug_helper.c | 54 ++++ | ||
79 | target/arm/helper.c | 41 ++- | ||
80 | target/arm/m_helper.c | 24 +- | ||
81 | target/arm/mte_helper.c | 2 +- | ||
82 | target/arm/op_helper.c | 27 +- | ||
83 | target/arm/ptw.c | 4 +- | ||
84 | target/arm/sme_helper.c | 37 +-- | ||
85 | target/arm/translate-a64.c | 68 +++-- | ||
86 | target/arm/translate.c | 430 +++++++++++++++------------- | ||
87 | hw/arm/Kconfig | 4 +- | ||
88 | hw/i2c/Kconfig | 2 +- | ||
89 | hw/i2c/meson.build | 2 +- | ||
90 | hw/i2c/trace-events | 7 + | ||
91 | 28 files changed, 506 insertions(+), 383 deletions(-) | ||
92 | rename hw/i2c/{versatile_i2c.c => arm_sbcon_i2c.c} (70%) | ||
93 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This is a 64-bit register on AArch64, even if the high 44 bits | ||
4 | are RES0. Because this is defined as ARM_CP_STATE_BOTH, we are | ||
5 | asserting that the cpreg field is 64-bits. | ||
6 | |||
7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1400 | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230115171633.3171890-1-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/cpu.h | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
21 | }; | ||
22 | uint64_t c14_cntfrq; /* Counter Frequency register */ | ||
23 | uint64_t c14_cntkctl; /* Timer Control register */ | ||
24 | - uint32_t cnthctl_el2; /* Counter/Timer Hyp Control register */ | ||
25 | + uint64_t cnthctl_el2; /* Counter/Timer Hyp Control register */ | ||
26 | uint64_t cntvoff_el2; /* Counter Virtual Offset register */ | ||
27 | ARMGenericTimer c14_timer[NUM_GTIMERS]; | ||
28 | uint32_t c15_cpar; /* XScale Coprocessor Access Register */ | ||
29 | -- | ||
30 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: David Reiss <dreiss@meta.com> | ||
1 | 2 | ||
3 | BASEPRI, FAULTMASK, and their _NS equivalents only exist on devices with | ||
4 | the Main Extension. However, the MRS instruction did not check this, | ||
5 | and the MSR instruction handled it inconsistently (warning BASEPRI, but | ||
6 | silently ignoring writes to BASEPRI_NS). Unify this behavior and always | ||
7 | warn when reading or writing any of these registers if the extension is | ||
8 | not present. | ||
9 | |||
10 | Signed-off-by: David Reiss <dreiss@meta.com> | ||
11 | Message-id: 167330628518.10497.13100425787268927786-0@git.sr.ht | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/m_helper.c | 22 ++++++++++++++++++++-- | ||
16 | 1 file changed, 20 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/m_helper.c | ||
21 | +++ b/target/arm/m_helper.c | ||
22 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
23 | } | ||
24 | return env->v7m.primask[M_REG_NS]; | ||
25 | case 0x91: /* BASEPRI_NS */ | ||
26 | + if (!arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
27 | + goto bad_reg; | ||
28 | + } | ||
29 | if (!env->v7m.secure) { | ||
30 | return 0; | ||
31 | } | ||
32 | return env->v7m.basepri[M_REG_NS]; | ||
33 | case 0x93: /* FAULTMASK_NS */ | ||
34 | + if (!arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
35 | + goto bad_reg; | ||
36 | + } | ||
37 | if (!env->v7m.secure) { | ||
38 | return 0; | ||
39 | } | ||
40 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
41 | return env->v7m.primask[env->v7m.secure]; | ||
42 | case 17: /* BASEPRI */ | ||
43 | case 18: /* BASEPRI_MAX */ | ||
44 | + if (!arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
45 | + goto bad_reg; | ||
46 | + } | ||
47 | return env->v7m.basepri[env->v7m.secure]; | ||
48 | case 19: /* FAULTMASK */ | ||
49 | + if (!arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
50 | + goto bad_reg; | ||
51 | + } | ||
52 | return env->v7m.faultmask[env->v7m.secure]; | ||
53 | default: | ||
54 | bad_reg: | ||
55 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
56 | env->v7m.primask[M_REG_NS] = val & 1; | ||
57 | return; | ||
58 | case 0x91: /* BASEPRI_NS */ | ||
59 | - if (!env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
60 | + if (!arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
61 | + goto bad_reg; | ||
62 | + } | ||
63 | + if (!env->v7m.secure) { | ||
64 | return; | ||
65 | } | ||
66 | env->v7m.basepri[M_REG_NS] = val & 0xff; | ||
67 | return; | ||
68 | case 0x93: /* FAULTMASK_NS */ | ||
69 | - if (!env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
70 | + if (!arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
71 | + goto bad_reg; | ||
72 | + } | ||
73 | + if (!env->v7m.secure) { | ||
74 | return; | ||
75 | } | ||
76 | env->v7m.faultmask[M_REG_NS] = val & 1; | ||
77 | -- | ||
78 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
1 | 2 | ||
3 | Define TYPE_GPIO_I2C in the public "hw/i2c/bitbang_i2c.h" | ||
4 | header and use it in hw/arm/musicpal.c. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Acked-by: Corey Minyard <cminyard@mvista.com> | ||
9 | Message-id: 20230111085016.44551-2-philmd@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/i2c/bitbang_i2c.h | 2 ++ | ||
13 | hw/arm/musicpal.c | 3 ++- | ||
14 | hw/i2c/bitbang_i2c.c | 1 - | ||
15 | 3 files changed, 4 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/i2c/bitbang_i2c.h b/include/hw/i2c/bitbang_i2c.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/i2c/bitbang_i2c.h | ||
20 | +++ b/include/hw/i2c/bitbang_i2c.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | |||
23 | #include "hw/i2c/i2c.h" | ||
24 | |||
25 | +#define TYPE_GPIO_I2C "gpio_i2c" | ||
26 | + | ||
27 | typedef struct bitbang_i2c_interface bitbang_i2c_interface; | ||
28 | |||
29 | #define BITBANG_I2C_SDA 0 | ||
30 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/hw/arm/musicpal.c | ||
33 | +++ b/hw/arm/musicpal.c | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | #include "hw/block/flash.h" | ||
36 | #include "ui/console.h" | ||
37 | #include "hw/i2c/i2c.h" | ||
38 | +#include "hw/i2c/bitbang_i2c.h" | ||
39 | #include "hw/irq.h" | ||
40 | #include "hw/or-irq.h" | ||
41 | #include "hw/audio/wm8750.h" | ||
42 | @@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine) | ||
43 | |||
44 | dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE, | ||
45 | qdev_get_gpio_in(pic, MP_GPIO_IRQ)); | ||
46 | - i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL); | ||
47 | + i2c_dev = sysbus_create_simple(TYPE_GPIO_I2C, -1, NULL); | ||
48 | i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, "i2c"); | ||
49 | |||
50 | lcd_dev = sysbus_create_simple(TYPE_MUSICPAL_LCD, MP_LCD_BASE, NULL); | ||
51 | diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/i2c/bitbang_i2c.c | ||
54 | +++ b/hw/i2c/bitbang_i2c.c | ||
55 | @@ -XXX,XX +XXX,XX @@ void bitbang_i2c_init(bitbang_i2c_interface *s, I2CBus *bus) | ||
56 | |||
57 | /* GPIO interface. */ | ||
58 | |||
59 | -#define TYPE_GPIO_I2C "gpio_i2c" | ||
60 | OBJECT_DECLARE_SIMPLE_TYPE(GPIOI2CState, GPIO_I2C) | ||
61 | |||
62 | struct GPIOI2CState { | ||
63 | -- | ||
64 | 2.34.1 | ||
65 | |||
66 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Acked-by: Corey Minyard <cminyard@mvista.com> | ||
6 | Message-id: 20230111085016.44551-3-philmd@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | hw/i2c/bitbang_i2c.c | 7 ++----- | ||
10 | 1 file changed, 2 insertions(+), 5 deletions(-) | ||
11 | |||
12 | diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/i2c/bitbang_i2c.c | ||
15 | +++ b/hw/i2c/bitbang_i2c.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void bitbang_i2c_init(bitbang_i2c_interface *s, I2CBus *bus) | ||
17 | OBJECT_DECLARE_SIMPLE_TYPE(GPIOI2CState, GPIO_I2C) | ||
18 | |||
19 | struct GPIOI2CState { | ||
20 | + /*< private >*/ | ||
21 | SysBusDevice parent_obj; | ||
22 | + /*< public >*/ | ||
23 | |||
24 | - MemoryRegion dummy_iomem; | ||
25 | bitbang_i2c_interface bitbang; | ||
26 | int last_level; | ||
27 | qemu_irq out; | ||
28 | @@ -XXX,XX +XXX,XX @@ static void gpio_i2c_init(Object *obj) | ||
29 | { | ||
30 | DeviceState *dev = DEVICE(obj); | ||
31 | GPIOI2CState *s = GPIO_I2C(obj); | ||
32 | - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
33 | I2CBus *bus; | ||
34 | |||
35 | - memory_region_init(&s->dummy_iomem, obj, "gpio_i2c", 0); | ||
36 | - sysbus_init_mmio(sbd, &s->dummy_iomem); | ||
37 | - | ||
38 | bus = i2c_init_bus(dev, "i2c"); | ||
39 | bitbang_i2c_init(&s->bitbang, bus); | ||
40 | |||
41 | -- | ||
42 | 2.34.1 | ||
43 | |||
44 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Acked-by: Corey Minyard <cminyard@mvista.com> | ||
6 | Message-id: 20230111085016.44551-4-philmd@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | hw/i2c/bitbang_i2c.c | 23 +++++++++++++++-------- | ||
10 | 1 file changed, 15 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/i2c/bitbang_i2c.c | ||
15 | +++ b/hw/i2c/bitbang_i2c.c | ||
16 | @@ -XXX,XX +XXX,XX @@ do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0) | ||
17 | #define DPRINTF(fmt, ...) do {} while(0) | ||
18 | #endif | ||
19 | |||
20 | +static void bitbang_i2c_set_state(bitbang_i2c_interface *i2c, | ||
21 | + bitbang_i2c_state state) | ||
22 | +{ | ||
23 | + i2c->state = state; | ||
24 | +} | ||
25 | + | ||
26 | static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) | ||
27 | { | ||
28 | DPRINTF("STOP\n"); | ||
29 | if (i2c->current_addr >= 0) | ||
30 | i2c_end_transfer(i2c->bus); | ||
31 | i2c->current_addr = -1; | ||
32 | - i2c->state = STOPPED; | ||
33 | + bitbang_i2c_set_state(i2c, STOPPED); | ||
34 | } | ||
35 | |||
36 | /* Set device data pin. */ | ||
37 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
38 | if (level == 0) { | ||
39 | DPRINTF("START\n"); | ||
40 | /* START condition. */ | ||
41 | - i2c->state = SENDING_BIT7; | ||
42 | + bitbang_i2c_set_state(i2c, SENDING_BIT7); | ||
43 | i2c->current_addr = -1; | ||
44 | } else { | ||
45 | /* STOP condition. */ | ||
46 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
47 | case SENDING_BIT7 ... SENDING_BIT0: | ||
48 | i2c->buffer = (i2c->buffer << 1) | data; | ||
49 | /* will end up in WAITING_FOR_ACK */ | ||
50 | - i2c->state++; | ||
51 | + bitbang_i2c_set_state(i2c, i2c->state + 1); | ||
52 | return bitbang_i2c_ret(i2c, 1); | ||
53 | |||
54 | case WAITING_FOR_ACK: | ||
55 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
56 | * device we were sending to decided to NACK us). | ||
57 | */ | ||
58 | DPRINTF("Got NACK\n"); | ||
59 | + bitbang_i2c_set_state(i2c, SENT_NACK); | ||
60 | bitbang_i2c_enter_stop(i2c); | ||
61 | return bitbang_i2c_ret(i2c, 1); | ||
62 | } | ||
63 | if (i2c->current_addr & 1) { | ||
64 | - i2c->state = RECEIVING_BIT7; | ||
65 | + bitbang_i2c_set_state(i2c, RECEIVING_BIT7); | ||
66 | } else { | ||
67 | - i2c->state = SENDING_BIT7; | ||
68 | + bitbang_i2c_set_state(i2c, SENDING_BIT7); | ||
69 | } | ||
70 | return bitbang_i2c_ret(i2c, 0); | ||
71 | } | ||
72 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
73 | case RECEIVING_BIT6 ... RECEIVING_BIT0: | ||
74 | data = i2c->buffer >> 7; | ||
75 | /* will end up in SENDING_ACK */ | ||
76 | - i2c->state++; | ||
77 | + bitbang_i2c_set_state(i2c, i2c->state + 1); | ||
78 | i2c->buffer <<= 1; | ||
79 | return bitbang_i2c_ret(i2c, data); | ||
80 | |||
81 | case SENDING_ACK: | ||
82 | - i2c->state = RECEIVING_BIT7; | ||
83 | if (data != 0) { | ||
84 | DPRINTF("NACKED\n"); | ||
85 | - i2c->state = SENT_NACK; | ||
86 | + bitbang_i2c_set_state(i2c, SENT_NACK); | ||
87 | i2c_nack(i2c->bus); | ||
88 | } else { | ||
89 | DPRINTF("ACKED\n"); | ||
90 | + bitbang_i2c_set_state(i2c, RECEIVING_BIT7); | ||
91 | } | ||
92 | return bitbang_i2c_ret(i2c, 1); | ||
93 | } | ||
94 | -- | ||
95 | 2.34.1 | ||
96 | |||
97 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
1 | 2 | ||
3 | Trace bitbang state machine changes with trace events. | ||
4 | |||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Acked-by: Corey Minyard <cminyard@mvista.com> | ||
8 | Message-id: 20230111085016.44551-5-philmd@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/i2c/bitbang_i2c.c | 33 ++++++++++++++++++++++++++++----- | ||
12 | hw/i2c/trace-events | 3 +++ | ||
13 | 2 files changed, 31 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/i2c/bitbang_i2c.c | ||
18 | +++ b/hw/i2c/bitbang_i2c.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "hw/sysbus.h" | ||
21 | #include "qemu/module.h" | ||
22 | #include "qom/object.h" | ||
23 | +#include "trace.h" | ||
24 | |||
25 | //#define DEBUG_BITBANG_I2C | ||
26 | |||
27 | @@ -XXX,XX +XXX,XX @@ do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0) | ||
28 | #define DPRINTF(fmt, ...) do {} while(0) | ||
29 | #endif | ||
30 | |||
31 | +/* bitbang_i2c_state enum to name */ | ||
32 | +static const char * const sname[] = { | ||
33 | +#define NAME(e) [e] = stringify(e) | ||
34 | + NAME(STOPPED), | ||
35 | + [SENDING_BIT7] = "SENDING_BIT7 (START)", | ||
36 | + NAME(SENDING_BIT6), | ||
37 | + NAME(SENDING_BIT5), | ||
38 | + NAME(SENDING_BIT4), | ||
39 | + NAME(SENDING_BIT3), | ||
40 | + NAME(SENDING_BIT2), | ||
41 | + NAME(SENDING_BIT1), | ||
42 | + NAME(SENDING_BIT0), | ||
43 | + NAME(WAITING_FOR_ACK), | ||
44 | + [RECEIVING_BIT7] = "RECEIVING_BIT7 (ACK)", | ||
45 | + NAME(RECEIVING_BIT6), | ||
46 | + NAME(RECEIVING_BIT5), | ||
47 | + NAME(RECEIVING_BIT4), | ||
48 | + NAME(RECEIVING_BIT3), | ||
49 | + NAME(RECEIVING_BIT2), | ||
50 | + NAME(RECEIVING_BIT1), | ||
51 | + NAME(RECEIVING_BIT0), | ||
52 | + NAME(SENDING_ACK), | ||
53 | + NAME(SENT_NACK) | ||
54 | +#undef NAME | ||
55 | +}; | ||
56 | + | ||
57 | static void bitbang_i2c_set_state(bitbang_i2c_interface *i2c, | ||
58 | bitbang_i2c_state state) | ||
59 | { | ||
60 | + trace_bitbang_i2c_state(sname[i2c->state], sname[state]); | ||
61 | i2c->state = state; | ||
62 | } | ||
63 | |||
64 | static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) | ||
65 | { | ||
66 | - DPRINTF("STOP\n"); | ||
67 | if (i2c->current_addr >= 0) | ||
68 | i2c_end_transfer(i2c->bus); | ||
69 | i2c->current_addr = -1; | ||
70 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
71 | return bitbang_i2c_nop(i2c); | ||
72 | } | ||
73 | if (level == 0) { | ||
74 | - DPRINTF("START\n"); | ||
75 | /* START condition. */ | ||
76 | bitbang_i2c_set_state(i2c, SENDING_BIT7); | ||
77 | i2c->current_addr = -1; | ||
78 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
79 | /* NACK (either addressing a nonexistent device, or the | ||
80 | * device we were sending to decided to NACK us). | ||
81 | */ | ||
82 | - DPRINTF("Got NACK\n"); | ||
83 | bitbang_i2c_set_state(i2c, SENT_NACK); | ||
84 | bitbang_i2c_enter_stop(i2c); | ||
85 | return bitbang_i2c_ret(i2c, 1); | ||
86 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
87 | |||
88 | case SENDING_ACK: | ||
89 | if (data != 0) { | ||
90 | - DPRINTF("NACKED\n"); | ||
91 | bitbang_i2c_set_state(i2c, SENT_NACK); | ||
92 | i2c_nack(i2c->bus); | ||
93 | } else { | ||
94 | - DPRINTF("ACKED\n"); | ||
95 | bitbang_i2c_set_state(i2c, RECEIVING_BIT7); | ||
96 | } | ||
97 | return bitbang_i2c_ret(i2c, 1); | ||
98 | diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/hw/i2c/trace-events | ||
101 | +++ b/hw/i2c/trace-events | ||
102 | @@ -XXX,XX +XXX,XX @@ | ||
103 | # See docs/devel/tracing.rst for syntax documentation. | ||
104 | |||
105 | +# bitbang_i2c.c | ||
106 | +bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s" | ||
107 | + | ||
108 | # core.c | ||
109 | |||
110 | i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)" | ||
111 | -- | ||
112 | 2.34.1 | ||
113 | |||
114 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
1 | 2 | ||
3 | Convert the remaining DPRINTF debug macro uses to tracepoints. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Acked-by: Corey Minyard <cminyard@mvista.com> | ||
8 | Message-id: 20230111085016.44551-6-philmd@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/i2c/bitbang_i2c.c | 18 ++++++------------ | ||
12 | hw/i2c/trace-events | 4 ++++ | ||
13 | 2 files changed, 10 insertions(+), 12 deletions(-) | ||
14 | |||
15 | diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/i2c/bitbang_i2c.c | ||
18 | +++ b/hw/i2c/bitbang_i2c.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "qom/object.h" | ||
21 | #include "trace.h" | ||
22 | |||
23 | -//#define DEBUG_BITBANG_I2C | ||
24 | - | ||
25 | -#ifdef DEBUG_BITBANG_I2C | ||
26 | -#define DPRINTF(fmt, ...) \ | ||
27 | -do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0) | ||
28 | -#else | ||
29 | -#define DPRINTF(fmt, ...) do {} while(0) | ||
30 | -#endif | ||
31 | |||
32 | /* bitbang_i2c_state enum to name */ | ||
33 | static const char * const sname[] = { | ||
34 | @@ -XXX,XX +XXX,XX @@ static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) | ||
35 | /* Set device data pin. */ | ||
36 | static int bitbang_i2c_ret(bitbang_i2c_interface *i2c, int level) | ||
37 | { | ||
38 | + trace_bitbang_i2c_data(i2c->last_clock, i2c->last_data, | ||
39 | + i2c->device_out, level); | ||
40 | i2c->device_out = level; | ||
41 | - //DPRINTF("%d %d %d\n", i2c->last_clock, i2c->last_data, i2c->device_out); | ||
42 | + | ||
43 | return level & i2c->last_data; | ||
44 | } | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
47 | |||
48 | if (i2c->current_addr < 0) { | ||
49 | i2c->current_addr = i2c->buffer; | ||
50 | - DPRINTF("Address 0x%02x\n", i2c->current_addr); | ||
51 | + trace_bitbang_i2c_addr(i2c->current_addr); | ||
52 | ret = i2c_start_transfer(i2c->bus, i2c->current_addr >> 1, | ||
53 | i2c->current_addr & 1); | ||
54 | } else { | ||
55 | - DPRINTF("Sent 0x%02x\n", i2c->buffer); | ||
56 | + trace_bitbang_i2c_send(i2c->buffer); | ||
57 | ret = i2c_send(i2c->bus, i2c->buffer); | ||
58 | } | ||
59 | if (ret) { | ||
60 | @@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) | ||
61 | } | ||
62 | case RECEIVING_BIT7: | ||
63 | i2c->buffer = i2c_recv(i2c->bus); | ||
64 | - DPRINTF("RX byte 0x%02x\n", i2c->buffer); | ||
65 | + trace_bitbang_i2c_recv(i2c->buffer); | ||
66 | /* Fall through... */ | ||
67 | case RECEIVING_BIT6 ... RECEIVING_BIT0: | ||
68 | data = i2c->buffer >> 7; | ||
69 | diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/hw/i2c/trace-events | ||
72 | +++ b/hw/i2c/trace-events | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | |||
75 | # bitbang_i2c.c | ||
76 | bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s" | ||
77 | +bitbang_i2c_addr(uint8_t addr) "Address 0x%02x" | ||
78 | +bitbang_i2c_send(uint8_t byte) "TX byte 0x%02x" | ||
79 | +bitbang_i2c_recv(uint8_t byte) "RX byte 0x%02x" | ||
80 | +bitbang_i2c_data(unsigned dat, unsigned clk, unsigned old_out, unsigned new_out) "dat %u clk %u out %u -> %u" | ||
81 | |||
82 | # core.c | ||
83 | |||
84 | -- | ||
85 | 2.34.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20230110082508.24038-2-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/i2c/versatile_i2c.c | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/i2c/versatile_i2c.c | ||
14 | +++ b/hw/i2c/versatile_i2c.c | ||
15 | @@ -XXX,XX +XXX,XX @@ REG32(CONTROL_CLR, 4) | ||
16 | static uint64_t versatile_i2c_read(void *opaque, hwaddr offset, | ||
17 | unsigned size) | ||
18 | { | ||
19 | - VersatileI2CState *s = (VersatileI2CState *)opaque; | ||
20 | + VersatileI2CState *s = opaque; | ||
21 | |||
22 | switch (offset) { | ||
23 | case A_CONTROL_SET: | ||
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t versatile_i2c_read(void *opaque, hwaddr offset, | ||
25 | static void versatile_i2c_write(void *opaque, hwaddr offset, | ||
26 | uint64_t value, unsigned size) | ||
27 | { | ||
28 | - VersatileI2CState *s = (VersatileI2CState *)opaque; | ||
29 | + VersatileI2CState *s = opaque; | ||
30 | |||
31 | switch (offset) { | ||
32 | case A_CONTROL_SET: | ||
33 | -- | ||
34 | 2.34.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The size of a segment is not necessarily a power of 2. | 3 | In order to rename TYPE_VERSATILE_I2C as TYPE_ARM_SBCON_I2C |
4 | (the formal ARM naming), start renaming its state. | ||
4 | 5 | ||
5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 1486648058-520-5-git-send-email-clg@kaod.org | 8 | Message-id: 20230110082508.24038-3-philmd@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | hw/ssi/aspeed_smc.c | 4 ++-- | 11 | include/hw/i2c/arm_sbcon_i2c.h | 3 +-- |
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | 12 | hw/i2c/versatile_i2c.c | 10 +++++----- |
13 | 2 files changed, 6 insertions(+), 7 deletions(-) | ||
12 | 14 | ||
13 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | 15 | diff --git a/include/hw/i2c/arm_sbcon_i2c.h b/include/hw/i2c/arm_sbcon_i2c.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/ssi/aspeed_smc.c | 17 | --- a/include/hw/i2c/arm_sbcon_i2c.h |
16 | +++ b/hw/ssi/aspeed_smc.c | 18 | +++ b/include/hw/i2c/arm_sbcon_i2c.h |
17 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_smc_check_segment_addr(const AspeedSMCFlash *fl, | 19 | @@ -XXX,XX +XXX,XX @@ |
18 | AspeedSegments seg; | 20 | #define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C |
19 | 21 | ||
20 | aspeed_smc_reg_to_segment(s->regs[R_SEG_ADDR0 + fl->id], &seg); | 22 | typedef struct ArmSbconI2CState ArmSbconI2CState; |
21 | - if ((addr & (seg.size - 1)) != addr) { | 23 | -DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C, |
22 | + if ((addr % seg.size) != addr) { | 24 | - TYPE_ARM_SBCON_I2C) |
23 | qemu_log_mask(LOG_GUEST_ERROR, | 25 | +DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C, TYPE_ARM_SBCON_I2C) |
24 | "%s: invalid address 0x%08x for CS%d segment : " | 26 | |
25 | "[ 0x%"HWADDR_PRIx" - 0x%"HWADDR_PRIx" ]\n", | 27 | struct ArmSbconI2CState { |
26 | s->ctrl->name, addr, fl->id, seg.addr, | 28 | /*< private >*/ |
27 | seg.addr + seg.size); | 29 | diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c |
28 | + addr %= seg.size; | 30 | index XXXXXXX..XXXXXXX 100644 |
29 | } | 31 | --- a/hw/i2c/versatile_i2c.c |
30 | 32 | +++ b/hw/i2c/versatile_i2c.c | |
31 | - addr &= seg.size - 1; | 33 | @@ -XXX,XX +XXX,XX @@ |
32 | return addr; | 34 | #include "qom/object.h" |
33 | } | 35 | |
36 | typedef ArmSbconI2CState VersatileI2CState; | ||
37 | -DECLARE_INSTANCE_CHECKER(VersatileI2CState, VERSATILE_I2C, | ||
38 | +DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, VERSATILE_I2C, | ||
39 | TYPE_VERSATILE_I2C) | ||
40 | |||
41 | |||
42 | @@ -XXX,XX +XXX,XX @@ REG32(CONTROL_CLR, 4) | ||
43 | static uint64_t versatile_i2c_read(void *opaque, hwaddr offset, | ||
44 | unsigned size) | ||
45 | { | ||
46 | - VersatileI2CState *s = opaque; | ||
47 | + ArmSbconI2CState *s = opaque; | ||
48 | |||
49 | switch (offset) { | ||
50 | case A_CONTROL_SET: | ||
51 | @@ -XXX,XX +XXX,XX @@ static uint64_t versatile_i2c_read(void *opaque, hwaddr offset, | ||
52 | static void versatile_i2c_write(void *opaque, hwaddr offset, | ||
53 | uint64_t value, unsigned size) | ||
54 | { | ||
55 | - VersatileI2CState *s = opaque; | ||
56 | + ArmSbconI2CState *s = opaque; | ||
57 | |||
58 | switch (offset) { | ||
59 | case A_CONTROL_SET: | ||
60 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps versatile_i2c_ops = { | ||
61 | static void versatile_i2c_init(Object *obj) | ||
62 | { | ||
63 | DeviceState *dev = DEVICE(obj); | ||
64 | - VersatileI2CState *s = VERSATILE_I2C(obj); | ||
65 | + ArmSbconI2CState *s = VERSATILE_I2C(obj); | ||
66 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
67 | I2CBus *bus; | ||
68 | |||
69 | @@ -XXX,XX +XXX,XX @@ static void versatile_i2c_init(Object *obj) | ||
70 | static const TypeInfo versatile_i2c_info = { | ||
71 | .name = TYPE_VERSATILE_I2C, | ||
72 | .parent = TYPE_SYS_BUS_DEVICE, | ||
73 | - .instance_size = sizeof(VersatileI2CState), | ||
74 | + .instance_size = sizeof(ArmSbconI2CState), | ||
75 | .instance_init = versatile_i2c_init, | ||
76 | }; | ||
34 | 77 | ||
35 | -- | 78 | -- |
36 | 2.7.4 | 79 | 2.34.1 |
37 | 80 | ||
38 | 81 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@suse.de> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | QEMU emulated hardware is always dma coherent with its guest. We do | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | annotate that correctly on the PCI host controller, but left out | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | virtio-mmio. | 5 | Message-id: 20230110082508.24038-4-philmd@linaro.org |
6 | |||
7 | Recent kernels have started to interpret that flag rather than take | ||
8 | dma coherency as granted with virtio-mmio. While that is considered | ||
9 | a kernel bug, as it breaks previously working systems, it showed that | ||
10 | our dt description is incomplete. | ||
11 | |||
12 | This patch adds the respective marker that allows guest OSs to evaluate | ||
13 | that our virtio-mmio devices are indeed cache coherent. | ||
14 | |||
15 | Signed-off-by: Alexander Graf <agraf@suse.de> | ||
16 | Reviewed-by: Laszlo Ersek <lersek@redhat.com> | ||
17 | Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> | ||
18 | Message-id: 1486644810-33181-2-git-send-email-agraf@suse.de | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 7 | --- |
21 | hw/arm/vexpress.c | 1 + | 8 | include/hw/i2c/arm_sbcon_i2c.h | 3 +-- |
22 | hw/arm/virt.c | 1 + | 9 | hw/arm/realview.c | 2 +- |
23 | 2 files changed, 2 insertions(+) | 10 | hw/arm/versatilepb.c | 2 +- |
11 | hw/arm/vexpress.c | 2 +- | ||
12 | hw/i2c/versatile_i2c.c | 4 ++-- | ||
13 | 5 files changed, 6 insertions(+), 7 deletions(-) | ||
24 | 14 | ||
15 | diff --git a/include/hw/i2c/arm_sbcon_i2c.h b/include/hw/i2c/arm_sbcon_i2c.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/i2c/arm_sbcon_i2c.h | ||
18 | +++ b/include/hw/i2c/arm_sbcon_i2c.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "hw/i2c/bitbang_i2c.h" | ||
21 | #include "qom/object.h" | ||
22 | |||
23 | -#define TYPE_VERSATILE_I2C "versatile_i2c" | ||
24 | -#define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C | ||
25 | +#define TYPE_ARM_SBCON_I2C "versatile_i2c" | ||
26 | |||
27 | typedef struct ArmSbconI2CState ArmSbconI2CState; | ||
28 | DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C, TYPE_ARM_SBCON_I2C) | ||
29 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/realview.c | ||
32 | +++ b/hw/arm/realview.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, | ||
34 | } | ||
35 | } | ||
36 | |||
37 | - dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL); | ||
38 | + dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL); | ||
39 | i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); | ||
40 | i2c_slave_create_simple(i2c, "ds1338", 0x68); | ||
41 | |||
42 | diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/arm/versatilepb.c | ||
45 | +++ b/hw/arm/versatilepb.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static void versatile_init(MachineState *machine, int board_id) | ||
47 | /* Add PL031 Real Time Clock. */ | ||
48 | sysbus_create_simple("pl031", 0x101e8000, pic[10]); | ||
49 | |||
50 | - dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL); | ||
51 | + dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL); | ||
52 | i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); | ||
53 | i2c_slave_create_simple(i2c, "ds1338", 0x68); | ||
54 | |||
25 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c | 55 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c |
26 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/arm/vexpress.c | 57 | --- a/hw/arm/vexpress.c |
28 | +++ b/hw/arm/vexpress.c | 58 | +++ b/hw/arm/vexpress.c |
29 | @@ -XXX,XX +XXX,XX @@ static int add_virtio_mmio_node(void *fdt, uint32_t acells, uint32_t scells, | 59 | @@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine) |
30 | acells, addr, scells, size); | 60 | sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]); |
31 | qemu_fdt_setprop_cells(fdt, nodename, "interrupt-parent", intc); | 61 | sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]); |
32 | qemu_fdt_setprop_cells(fdt, nodename, "interrupts", 0, irq, 1); | 62 | |
33 | + qemu_fdt_setprop(fdt, nodename, "dma-coherent", NULL, 0); | 63 | - dev = sysbus_create_simple(TYPE_VERSATILE_I2C, map[VE_SERIALDVI], NULL); |
34 | g_free(nodename); | 64 | + dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, map[VE_SERIALDVI], NULL); |
35 | if (rc) { | 65 | i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); |
36 | return -1; | 66 | i2c_slave_create_simple(i2c, "sii9022", 0x39); |
37 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 67 | |
68 | diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | 69 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/hw/arm/virt.c | 70 | --- a/hw/i2c/versatile_i2c.c |
40 | +++ b/hw/arm/virt.c | 71 | +++ b/hw/i2c/versatile_i2c.c |
41 | @@ -XXX,XX +XXX,XX @@ static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic) | 72 | @@ -XXX,XX +XXX,XX @@ |
42 | qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupts", | 73 | |
43 | GIC_FDT_IRQ_TYPE_SPI, irq, | 74 | typedef ArmSbconI2CState VersatileI2CState; |
44 | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI); | 75 | DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, VERSATILE_I2C, |
45 | + qemu_fdt_setprop(vms->fdt, nodename, "dma-coherent", NULL, 0); | 76 | - TYPE_VERSATILE_I2C) |
46 | g_free(nodename); | 77 | + TYPE_ARM_SBCON_I2C) |
47 | } | 78 | |
79 | |||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ static void versatile_i2c_init(Object *obj) | ||
48 | } | 82 | } |
83 | |||
84 | static const TypeInfo versatile_i2c_info = { | ||
85 | - .name = TYPE_VERSATILE_I2C, | ||
86 | + .name = TYPE_ARM_SBCON_I2C, | ||
87 | .parent = TYPE_SYS_BUS_DEVICE, | ||
88 | .instance_size = sizeof(ArmSbconI2CState), | ||
89 | .instance_init = versatile_i2c_init, | ||
49 | -- | 90 | -- |
50 | 2.7.4 | 91 | 2.34.1 |
51 | 92 | ||
52 | 93 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | HW works fine in normal read mode with dummy bytes being set. So let's | 3 | ARM_SBCON_I2C() macro and ArmSbconI2CState typedef are |
4 | check this case to not transfer bytes. | 4 | already declared via the QOM DECLARE_INSTANCE_CHECKER() |
5 | macro in "hw/i2c/arm_sbcon_i2c.h". Drop the VERSATILE_I2C | ||
6 | declarations from versatile_i2c.c. | ||
5 | 7 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Message-id: 1486648058-520-4-git-send-email-clg@kaod.org | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20230110082508.24038-5-philmd@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 | hw/ssi/aspeed_smc.c | 9 ++++++--- | 13 | hw/i2c/versatile_i2c.c | 7 +------ |
11 | 1 file changed, 6 insertions(+), 3 deletions(-) | 14 | 1 file changed, 1 insertion(+), 6 deletions(-) |
12 | 15 | ||
13 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | 16 | diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/ssi/aspeed_smc.c | 18 | --- a/hw/i2c/versatile_i2c.c |
16 | +++ b/hw/ssi/aspeed_smc.c | 19 | +++ b/hw/i2c/versatile_i2c.c |
17 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size) | 20 | @@ -XXX,XX +XXX,XX @@ |
18 | /* | 21 | #include "qemu/module.h" |
19 | * Use fake transfers to model dummy bytes. The value should | 22 | #include "qom/object.h" |
20 | * be configured to some non-zero value in fast read mode and | 23 | |
21 | - * zero in read mode. | 24 | -typedef ArmSbconI2CState VersatileI2CState; |
22 | + * zero in read mode. But, as the HW allows inconsistent | 25 | -DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, VERSATILE_I2C, |
23 | + * settings, let's check for fast read mode. | 26 | - TYPE_ARM_SBCON_I2C) |
24 | */ | 27 | - |
25 | - for (i = 0; i < aspeed_smc_flash_dummies(fl); i++) { | 28 | - |
26 | - ssi_transfer(fl->controller->spi, 0xFF); | 29 | |
27 | + if (aspeed_smc_flash_mode(fl) == CTRL_FREADMODE) { | 30 | REG32(CONTROL_GET, 0) |
28 | + for (i = 0; i < aspeed_smc_flash_dummies(fl); i++) { | 31 | REG32(CONTROL_SET, 0) |
29 | + ssi_transfer(fl->controller->spi, 0xFF); | 32 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps versatile_i2c_ops = { |
30 | + } | 33 | static void versatile_i2c_init(Object *obj) |
31 | } | 34 | { |
32 | 35 | DeviceState *dev = DEVICE(obj); | |
33 | for (i = 0; i < size; i++) { | 36 | - ArmSbconI2CState *s = VERSATILE_I2C(obj); |
37 | + ArmSbconI2CState *s = ARM_SBCON_I2C(obj); | ||
38 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
39 | I2CBus *bus; | ||
40 | |||
34 | -- | 41 | -- |
35 | 2.7.4 | 42 | 2.34.1 |
36 | 43 | ||
37 | 44 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The flash devices used for the FMC controller (BMC firmware) are well | 3 | This device model started with the Versatile board, named |
4 | defined for each Aspeed machine and are all smaller than the default | 4 | TYPE_VERSATILE_I2C, then ended up renamed TYPE_ARM_SBCON_I2C |
5 | mapping window size, at least for CE0 which is the chip the SoC boots | 5 | as per the official "ARM SBCon two-wire serial bus interface" |
6 | from. | 6 | description from: |
7 | https://developer.arm.com/documentation/dui0440/b/programmer-s-reference/two-wire-serial-bus-interface--sbcon | ||
7 | 8 | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 9 | Use the latter name as a better description. |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 10 | |
10 | Message-id: 1486648058-520-3-git-send-email-clg@kaod.org | 11 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20230110082508.24038-6-philmd@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 15 | --- |
13 | hw/arm/aspeed.c | 8 +++----- | 16 | MAINTAINERS | 1 + |
14 | 1 file changed, 3 insertions(+), 5 deletions(-) | 17 | hw/i2c/{versatile_i2c.c => arm_sbcon_i2c.c} | 24 ++++++++++----------- |
18 | hw/arm/Kconfig | 4 ++-- | ||
19 | hw/i2c/Kconfig | 2 +- | ||
20 | hw/i2c/meson.build | 2 +- | ||
21 | 5 files changed, 17 insertions(+), 16 deletions(-) | ||
22 | rename hw/i2c/{versatile_i2c.c => arm_sbcon_i2c.c} (81%) | ||
15 | 23 | ||
16 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 24 | diff --git a/MAINTAINERS b/MAINTAINERS |
17 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/aspeed.c | 26 | --- a/MAINTAINERS |
19 | +++ b/hw/arm/aspeed.c | 27 | +++ b/MAINTAINERS |
20 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, | 28 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> |
21 | DriveInfo *dinfo = drive_get_next(IF_MTD); | 29 | L: qemu-arm@nongnu.org |
22 | qemu_irq cs_line; | 30 | S: Maintained |
23 | 31 | F: hw/*/versatile* | |
24 | - /* | 32 | +F: hw/i2c/arm_sbcon_i2c.c |
25 | - * FIXME: check that we are not using a flash module exceeding | 33 | F: include/hw/i2c/arm_sbcon_i2c.h |
26 | - * the controller segment size | 34 | F: hw/misc/arm_sysctl.c |
27 | - */ | 35 | F: docs/system/arm/versatile.rst |
28 | fl->flash = ssi_create_slave_no_init(s->spi, flashtype); | 36 | diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/arm_sbcon_i2c.c |
29 | if (dinfo) { | 37 | similarity index 81% |
30 | qdev_prop_set_drive(fl->flash, "drive", blk_by_legacy_dinfo(dinfo), | 38 | rename from hw/i2c/versatile_i2c.c |
31 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 39 | rename to hw/i2c/arm_sbcon_i2c.c |
32 | 40 | index XXXXXXX..XXXXXXX 100644 | |
33 | /* | 41 | --- a/hw/i2c/versatile_i2c.c |
34 | * create a ROM region using the default mapping window size of | 42 | +++ b/hw/i2c/arm_sbcon_i2c.c |
35 | - * the flash module. | 43 | @@ -XXX,XX +XXX,XX @@ REG32(CONTROL_CLR, 4) |
36 | + * the flash module. The window size is 64MB for the AST2400 | 44 | #define SCL BIT(0) |
37 | + * SoC and 128MB for the AST2500 SoC, which is twice as big as | 45 | #define SDA BIT(1) |
38 | + * needed by the flash modules of the Aspeed machines. | 46 | |
39 | */ | 47 | -static uint64_t versatile_i2c_read(void *opaque, hwaddr offset, |
40 | memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom", | 48 | +static uint64_t arm_sbcon_i2c_read(void *opaque, hwaddr offset, |
41 | fl->size, &error_abort); | 49 | unsigned size) |
50 | { | ||
51 | ArmSbconI2CState *s = opaque; | ||
52 | @@ -XXX,XX +XXX,XX @@ static uint64_t versatile_i2c_read(void *opaque, hwaddr offset, | ||
53 | } | ||
54 | } | ||
55 | |||
56 | -static void versatile_i2c_write(void *opaque, hwaddr offset, | ||
57 | +static void arm_sbcon_i2c_write(void *opaque, hwaddr offset, | ||
58 | uint64_t value, unsigned size) | ||
59 | { | ||
60 | ArmSbconI2CState *s = opaque; | ||
61 | @@ -XXX,XX +XXX,XX @@ static void versatile_i2c_write(void *opaque, hwaddr offset, | ||
62 | s->in = bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SDA, (s->out & SDA) != 0); | ||
63 | } | ||
64 | |||
65 | -static const MemoryRegionOps versatile_i2c_ops = { | ||
66 | - .read = versatile_i2c_read, | ||
67 | - .write = versatile_i2c_write, | ||
68 | +static const MemoryRegionOps arm_sbcon_i2c_ops = { | ||
69 | + .read = arm_sbcon_i2c_read, | ||
70 | + .write = arm_sbcon_i2c_write, | ||
71 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
72 | }; | ||
73 | |||
74 | -static void versatile_i2c_init(Object *obj) | ||
75 | +static void arm_sbcon_i2c_init(Object *obj) | ||
76 | { | ||
77 | DeviceState *dev = DEVICE(obj); | ||
78 | ArmSbconI2CState *s = ARM_SBCON_I2C(obj); | ||
79 | @@ -XXX,XX +XXX,XX @@ static void versatile_i2c_init(Object *obj) | ||
80 | |||
81 | bus = i2c_init_bus(dev, "i2c"); | ||
82 | bitbang_i2c_init(&s->bitbang, bus); | ||
83 | - memory_region_init_io(&s->iomem, obj, &versatile_i2c_ops, s, | ||
84 | + memory_region_init_io(&s->iomem, obj, &arm_sbcon_i2c_ops, s, | ||
85 | "arm_sbcon_i2c", 0x1000); | ||
86 | sysbus_init_mmio(sbd, &s->iomem); | ||
87 | } | ||
88 | |||
89 | -static const TypeInfo versatile_i2c_info = { | ||
90 | +static const TypeInfo arm_sbcon_i2c_info = { | ||
91 | .name = TYPE_ARM_SBCON_I2C, | ||
92 | .parent = TYPE_SYS_BUS_DEVICE, | ||
93 | .instance_size = sizeof(ArmSbconI2CState), | ||
94 | - .instance_init = versatile_i2c_init, | ||
95 | + .instance_init = arm_sbcon_i2c_init, | ||
96 | }; | ||
97 | |||
98 | -static void versatile_i2c_register_types(void) | ||
99 | +static void arm_sbcon_i2c_register_types(void) | ||
100 | { | ||
101 | - type_register_static(&versatile_i2c_info); | ||
102 | + type_register_static(&arm_sbcon_i2c_info); | ||
103 | } | ||
104 | |||
105 | -type_init(versatile_i2c_register_types) | ||
106 | +type_init(arm_sbcon_i2c_register_types) | ||
107 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/hw/arm/Kconfig | ||
110 | +++ b/hw/arm/Kconfig | ||
111 | @@ -XXX,XX +XXX,XX @@ config REALVIEW | ||
112 | select PL110 | ||
113 | select PL181 # display | ||
114 | select PL310 # cache controller | ||
115 | - select VERSATILE_I2C | ||
116 | + select ARM_SBCON_I2C | ||
117 | select DS1338 # I2C RTC+NVRAM | ||
118 | select USB_OHCI | ||
119 | |||
120 | @@ -XXX,XX +XXX,XX @@ config MPS2 | ||
121 | select SPLIT_IRQ | ||
122 | select UNIMP | ||
123 | select CMSDK_APB_WATCHDOG | ||
124 | - select VERSATILE_I2C | ||
125 | + select ARM_SBCON_I2C | ||
126 | |||
127 | config FSL_IMX7 | ||
128 | bool | ||
129 | diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/hw/i2c/Kconfig | ||
132 | +++ b/hw/i2c/Kconfig | ||
133 | @@ -XXX,XX +XXX,XX @@ config SMBUS_EEPROM | ||
134 | bool | ||
135 | select SMBUS | ||
136 | |||
137 | -config VERSATILE_I2C | ||
138 | +config ARM_SBCON_I2C | ||
139 | bool | ||
140 | select BITBANG_I2C | ||
141 | |||
142 | diff --git a/hw/i2c/meson.build b/hw/i2c/meson.build | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/hw/i2c/meson.build | ||
145 | +++ b/hw/i2c/meson.build | ||
146 | @@ -XXX,XX +XXX,XX @@ i2c_ss.add(when: 'CONFIG_ALLWINNER_I2C', if_true: files('allwinner-i2c.c')) | ||
147 | i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c')) | ||
148 | i2c_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_smbus.c')) | ||
149 | i2c_ss.add(when: 'CONFIG_SMBUS_EEPROM', if_true: files('smbus_eeprom.c')) | ||
150 | -i2c_ss.add(when: 'CONFIG_VERSATILE_I2C', if_true: files('versatile_i2c.c')) | ||
151 | +i2c_ss.add(when: 'CONFIG_ARM_SBCON_I2C', if_true: files('arm_sbcon_i2c.c')) | ||
152 | i2c_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_i2c.c')) | ||
153 | i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_i2c.c')) | ||
154 | i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c')) | ||
42 | -- | 155 | -- |
43 | 2.7.4 | 156 | 2.34.1 |
44 | 157 | ||
45 | 158 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@suse.de> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Fw-cfg recently learned how to directly access guest memory and does so in | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | cache coherent fashion. Tell the guest about that fact when it's using DT. | 4 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
5 | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
6 | Signed-off-by: Alexander Graf <agraf@suse.de> | 6 | Message-id: 20230112102436.1913-2-philmd@linaro.org |
7 | Reviewed-by: Laszlo Ersek <lersek@redhat.com> | 7 | Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> |
8 | Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> | 8 | [PMD: Split patch in multiple tiny steps] |
9 | Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Message-id: 1486644810-33181-5-git-send-email-agraf@suse.de | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/arm/virt.c | 1 + | 12 | target/arm/translate-a64.c | 24 +++++++++++++----------- |
14 | 1 file changed, 1 insertion(+) | 13 | 1 file changed, 13 insertions(+), 11 deletions(-) |
15 | 14 | ||
16 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/virt.c | 17 | --- a/target/arm/translate-a64.c |
19 | +++ b/hw/arm/virt.c | 18 | +++ b/target/arm/translate-a64.c |
20 | @@ -XXX,XX +XXX,XX @@ static FWCfgState *create_fw_cfg(const VirtMachineState *vms, AddressSpace *as) | 19 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, |
21 | "compatible", "qemu,fw-cfg-mmio"); | 20 | goto do_unallocated; |
22 | qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg", | 21 | } |
23 | 2, base, 2, size); | 22 | if (sme_access_check(s)) { |
24 | + qemu_fdt_setprop(vms->fdt, nodename, "dma-coherent", NULL, 0); | 23 | - bool i = crm & 1; |
25 | g_free(nodename); | 24 | - bool changed = false; |
26 | return fw_cfg; | 25 | + int old = s->pstate_sm | (s->pstate_za << 1); |
27 | } | 26 | + int new = (crm & 1) * 3; |
27 | + int msk = (crm >> 1) & 3; | ||
28 | |||
29 | - if ((crm & 2) && i != s->pstate_sm) { | ||
30 | - gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); | ||
31 | - changed = true; | ||
32 | - } | ||
33 | - if ((crm & 4) && i != s->pstate_za) { | ||
34 | - gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); | ||
35 | - changed = true; | ||
36 | - } | ||
37 | - if (changed) { | ||
38 | + if ((old ^ new) & msk) { | ||
39 | + /* At least one bit changes. */ | ||
40 | + bool i = crm & 1; | ||
41 | + | ||
42 | + if ((crm & 2) && i != s->pstate_sm) { | ||
43 | + gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); | ||
44 | + } | ||
45 | + if ((crm & 4) && i != s->pstate_za) { | ||
46 | + gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); | ||
47 | + } | ||
48 | gen_rebuild_hflags(s); | ||
49 | } else { | ||
50 | s->base.is_jmp = DISAS_NEXT; | ||
28 | -- | 51 | -- |
29 | 2.7.4 | 52 | 2.34.1 |
30 | 53 | ||
31 | 54 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@suse.de> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Fw-cfg recently learned how to directly access guest memory and does so in | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | cache coherent fashion. Tell the guest about that fact when it's using ACPI. | 4 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
5 | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
6 | Signed-off-by: Alexander Graf <agraf@suse.de> | 6 | Message-id: 20230112102436.1913-3-philmd@linaro.org |
7 | Reviewed-by: Laszlo Ersek <lersek@redhat.com> | 7 | Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> |
8 | Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> | 8 | [PMD: Split patch in multiple tiny steps] |
9 | Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Message-id: 1486644810-33181-4-git-send-email-agraf@suse.de | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/arm/virt-acpi-build.c | 1 + | 12 | target/arm/sme_helper.c | 2 ++ |
14 | 1 file changed, 1 insertion(+) | 13 | target/arm/translate-a64.c | 1 - |
14 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
15 | 15 | ||
16 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 16 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/virt-acpi-build.c | 18 | --- a/target/arm/sme_helper.c |
19 | +++ b/hw/arm/virt-acpi-build.c | 19 | +++ b/target/arm/sme_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_memmap) | 20 | @@ -XXX,XX +XXX,XX @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i) |
21 | aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); | 21 | } |
22 | /* device present, functioning, decoding, not shown in UI */ | 22 | env->svcr ^= R_SVCR_SM_MASK; |
23 | aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); | 23 | arm_reset_sve_state(env); |
24 | + aml_append(dev, aml_name_decl("_CCA", aml_int(1))); | 24 | + arm_rebuild_hflags(env); |
25 | 25 | } | |
26 | Aml *crs = aml_resource_template(); | 26 | |
27 | aml_append(crs, aml_memory32_fixed(fw_cfg_memmap->base, | 27 | void helper_set_pstate_za(CPUARMState *env, uint32_t i) |
28 | @@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i) | ||
29 | if (i) { | ||
30 | memset(env->zarray, 0, sizeof(env->zarray)); | ||
31 | } | ||
32 | + arm_rebuild_hflags(env); | ||
33 | } | ||
34 | |||
35 | void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl) | ||
36 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/translate-a64.c | ||
39 | +++ b/target/arm/translate-a64.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
41 | if ((crm & 4) && i != s->pstate_za) { | ||
42 | gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); | ||
43 | } | ||
44 | - gen_rebuild_hflags(s); | ||
45 | } else { | ||
46 | s->base.is_jmp = DISAS_NEXT; | ||
47 | } | ||
28 | -- | 48 | -- |
29 | 2.7.4 | 49 | 2.34.1 |
30 | 50 | ||
31 | 51 | diff view generated by jsdifflib |
1 | From: Wei Huang <wei@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds support for AArch64 register PMSELR_EL0. The existing | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | PMSELR definition is revised accordingly. | 4 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
5 | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
6 | Signed-off-by: Wei Huang <wei@redhat.com> | 6 | Message-id: 20230112102436.1913-4-philmd@linaro.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> |
8 | [PMM: Moved #ifndef CONFIG_USER_ONLY to cover new regdefs] | 8 | [PMD: Split patch in multiple tiny steps] |
9 | Message-id: 1486504171-26807-2-git-send-email-wei@redhat.com | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/cpu.h | 1 + | 12 | target/arm/cpu.h | 1 + |
13 | target/arm/helper.c | 27 +++++++++++++++++++++------ | 13 | linux-user/aarch64/cpu_loop.c | 2 +- |
14 | 2 files changed, 22 insertions(+), 6 deletions(-) | 14 | linux-user/aarch64/signal.c | 2 +- |
15 | target/arm/helper.c | 8 ++++++++ | ||
16 | target/arm/sme_helper.c | 4 ++-- | ||
17 | 5 files changed, 13 insertions(+), 4 deletions(-) | ||
15 | 18 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 21 | --- a/target/arm/cpu.h |
19 | +++ b/target/arm/cpu.h | 22 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 23 | @@ -XXX,XX +XXX,XX @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); |
21 | uint32_t c9_pmovsr; /* perf monitor overflow status */ | 24 | void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); |
22 | uint32_t c9_pmxevtyper; /* perf monitor event type */ | 25 | void aarch64_sve_change_el(CPUARMState *env, int old_el, |
23 | uint32_t c9_pmuserenr; /* perf monitor user enable */ | 26 | int new_el, bool el0_a64); |
24 | + uint64_t c9_pmselr; /* perf monitor counter selection register */ | 27 | +void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask); |
25 | uint32_t c9_pminten; /* perf monitor interrupt enables */ | 28 | void arm_reset_sve_state(CPUARMState *env); |
26 | union { /* Memory attribute redirection */ | 29 | |
27 | struct { | 30 | /* |
31 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/linux-user/aarch64/cpu_loop.c | ||
34 | +++ b/linux-user/aarch64/cpu_loop.c | ||
35 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | ||
36 | * On syscall, PSTATE.ZA is preserved, along with the ZA matrix. | ||
37 | * PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState. | ||
38 | */ | ||
39 | + aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); | ||
40 | if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
41 | - env->svcr = FIELD_DP64(env->svcr, SVCR, SM, 0); | ||
42 | arm_rebuild_hflags(env); | ||
43 | arm_reset_sve_state(env); | ||
44 | } | ||
45 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/linux-user/aarch64/signal.c | ||
48 | +++ b/linux-user/aarch64/signal.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
50 | * Invoke the signal handler with both SM and ZA disabled. | ||
51 | * When clearing SM, ResetSVEState, per SMSTOP. | ||
52 | */ | ||
53 | + aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); | ||
54 | if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
55 | arm_reset_sve_state(env); | ||
56 | } | ||
57 | if (env->svcr) { | ||
58 | - env->svcr = 0; | ||
59 | arm_rebuild_hflags(env); | ||
60 | } | ||
61 | |||
28 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 62 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
29 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/helper.c | 64 | --- a/target/arm/helper.c |
31 | +++ b/target/arm/helper.c | 65 | +++ b/target/arm/helper.c |
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 66 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri, |
33 | return total_ticks - env->cp15.c15_ccnt; | 67 | return CP_ACCESS_OK; |
34 | } | 68 | } |
35 | 69 | ||
36 | +static void pmselr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 70 | +void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) |
37 | + uint64_t value) | ||
38 | +{ | 71 | +{ |
39 | + /* The value of PMSELR.SEL affects the behavior of PMXEVTYPER and | 72 | + uint64_t change = (env->svcr ^ new) & mask; |
40 | + * PMXEVCNTR. We allow [0..31] to be written to PMSELR here; in the | 73 | + |
41 | + * meanwhile, we check PMSELR.SEL when PMXEVTYPER and PMXEVCNTR are | 74 | + env->svcr ^= change; |
42 | + * accessed. | ||
43 | + */ | ||
44 | + env->cp15.c9_pmselr = value & 0x1f; | ||
45 | +} | 75 | +} |
46 | + | 76 | + |
47 | static void pmccntr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 77 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
48 | uint64_t value) | 78 | uint64_t value) |
49 | { | 79 | { |
50 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 80 | helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM)); |
51 | /* Unimplemented so WI. */ | 81 | helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA)); |
52 | { .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4, | 82 | + aarch64_set_svcr(env, value, -1); |
53 | .access = PL0_W, .accessfn = pmreg_access, .type = ARM_CP_NOP }, | 83 | arm_rebuild_hflags(env); |
54 | - /* Since we don't implement any events, writing to PMSELR is UNPREDICTABLE. | 84 | } |
55 | - * We choose to RAZ/WI. | 85 | |
56 | - */ | 86 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c |
57 | - { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, | 87 | index XXXXXXX..XXXXXXX 100644 |
58 | - .access = PL0_RW, .type = ARM_CP_CONST, .resetvalue = 0, | 88 | --- a/target/arm/sme_helper.c |
59 | - .accessfn = pmreg_access }, | 89 | +++ b/target/arm/sme_helper.c |
60 | #ifndef CONFIG_USER_ONLY | 90 | @@ -XXX,XX +XXX,XX @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i) |
61 | + { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, | 91 | if (i == FIELD_EX64(env->svcr, SVCR, SM)) { |
62 | + .access = PL0_RW, .type = ARM_CP_ALIAS, | 92 | return; |
63 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr), | 93 | } |
64 | + .accessfn = pmreg_access, .writefn = pmselr_write, | 94 | - env->svcr ^= R_SVCR_SM_MASK; |
65 | + .raw_writefn = raw_write}, | 95 | + aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); |
66 | + { .name = "PMSELR_EL0", .state = ARM_CP_STATE_AA64, | 96 | arm_reset_sve_state(env); |
67 | + .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 5, | 97 | arm_rebuild_hflags(env); |
68 | + .access = PL0_RW, .accessfn = pmreg_access, | 98 | } |
69 | + .fieldoffset = offsetof(CPUARMState, cp15.c9_pmselr), | 99 | @@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i) |
70 | + .writefn = pmselr_write, .raw_writefn = raw_write, }, | 100 | if (i == FIELD_EX64(env->svcr, SVCR, ZA)) { |
71 | { .name = "PMCCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 0, | 101 | return; |
72 | .access = PL0_RW, .resetvalue = 0, .type = ARM_CP_IO, | 102 | } |
73 | .readfn = pmccntr_read, .writefn = pmccntr_write32, | 103 | - env->svcr ^= R_SVCR_ZA_MASK; |
104 | + aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK); | ||
105 | |||
106 | /* | ||
107 | * ResetSMEState. | ||
74 | -- | 108 | -- |
75 | 2.7.4 | 109 | 2.34.1 |
76 | 110 | ||
77 | 111 | diff view generated by jsdifflib |
1 | From: Wei Huang <wei@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In order to support Linux perf, which uses PMXEVTYPER register, | 3 | Move arm_reset_sve_state() calls to aarch64_set_svcr(). |
4 | this patch adds read/write access support for PMXEVTYPER. The access | ||
5 | is CONSTRAINED UNPREDICTABLE when PMSELR is not 0x1f. Additionally | ||
6 | this patch adds support for PMXEVTYPER_EL0. | ||
7 | 4 | ||
8 | Signed-off-by: Wei Huang <wei@redhat.com> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 1486504171-26807-3-git-send-email-wei@redhat.com | 6 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Message-id: 20230112102436.1913-5-philmd@linaro.org | ||
9 | Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> | ||
10 | [PMD: Split patch in multiple tiny steps] | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 13 | --- |
13 | target/arm/cpu.h | 1 - | 14 | target/arm/cpu.h | 1 - |
14 | target/arm/helper.c | 30 +++++++++++++++++++++++++----- | 15 | linux-user/aarch64/cpu_loop.c | 1 - |
15 | 2 files changed, 25 insertions(+), 6 deletions(-) | 16 | linux-user/aarch64/signal.c | 8 +------- |
17 | target/arm/helper.c | 13 +++++++++++++ | ||
18 | target/arm/sme_helper.c | 10 ---------- | ||
19 | 5 files changed, 14 insertions(+), 19 deletions(-) | ||
16 | 20 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 23 | --- a/target/arm/cpu.h |
20 | +++ b/target/arm/cpu.h | 24 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 25 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); |
22 | uint64_t c9_pmcr; /* performance monitor control register */ | 26 | void aarch64_sve_change_el(CPUARMState *env, int old_el, |
23 | uint64_t c9_pmcnten; /* perf monitor counter enables */ | 27 | int new_el, bool el0_a64); |
24 | uint32_t c9_pmovsr; /* perf monitor overflow status */ | 28 | void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask); |
25 | - uint32_t c9_pmxevtyper; /* perf monitor event type */ | 29 | -void arm_reset_sve_state(CPUARMState *env); |
26 | uint32_t c9_pmuserenr; /* perf monitor user enable */ | 30 | |
27 | uint64_t c9_pmselr; /* perf monitor counter selection register */ | 31 | /* |
28 | uint32_t c9_pminten; /* perf monitor interrupt enables */ | 32 | * SVE registers are encoded in KVM's memory in an endianness-invariant format. |
33 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/linux-user/aarch64/cpu_loop.c | ||
36 | +++ b/linux-user/aarch64/cpu_loop.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | ||
38 | aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); | ||
39 | if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
40 | arm_rebuild_hflags(env); | ||
41 | - arm_reset_sve_state(env); | ||
42 | } | ||
43 | ret = do_syscall(env, | ||
44 | env->xregs[8], | ||
45 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/linux-user/aarch64/signal.c | ||
48 | +++ b/linux-user/aarch64/signal.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
50 | env->btype = 2; | ||
51 | } | ||
52 | |||
53 | - /* | ||
54 | - * Invoke the signal handler with both SM and ZA disabled. | ||
55 | - * When clearing SM, ResetSVEState, per SMSTOP. | ||
56 | - */ | ||
57 | + /* Invoke the signal handler with both SM and ZA disabled. */ | ||
58 | aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); | ||
59 | - if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
60 | - arm_reset_sve_state(env); | ||
61 | - } | ||
62 | if (env->svcr) { | ||
63 | arm_rebuild_hflags(env); | ||
64 | } | ||
29 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 65 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
30 | index XXXXXXX..XXXXXXX 100644 | 66 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/helper.c | 67 | --- a/target/arm/helper.c |
32 | +++ b/target/arm/helper.c | 68 | +++ b/target/arm/helper.c |
33 | @@ -XXX,XX +XXX,XX @@ static void pmovsr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 69 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri, |
34 | static void pmxevtyper_write(CPUARMState *env, const ARMCPRegInfo *ri, | 70 | return CP_ACCESS_OK; |
35 | uint64_t value) | 71 | } |
36 | { | 72 | |
37 | - env->cp15.c9_pmxevtyper = value & 0xff; | 73 | +/* ResetSVEState */ |
38 | + /* Attempts to access PMXEVTYPER are CONSTRAINED UNPREDICTABLE when | 74 | +static void arm_reset_sve_state(CPUARMState *env) |
39 | + * PMSELR value is equal to or greater than the number of implemented | 75 | +{ |
40 | + * counters, but not equal to 0x1f. We opt to behave as a RAZ/WI. | 76 | + memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs)); |
41 | + */ | 77 | + /* Recall that FFR is stored as pregs[16]. */ |
42 | + if (env->cp15.c9_pmselr == 0x1f) { | 78 | + memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs)); |
43 | + pmccfiltr_write(env, ri, value); | 79 | + vfp_set_fpcr(env, 0x0800009f); |
44 | + } | ||
45 | +} | 80 | +} |
46 | + | 81 | + |
47 | +static uint64_t pmxevtyper_read(CPUARMState *env, const ARMCPRegInfo *ri) | 82 | void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) |
48 | +{ | 83 | { |
49 | + /* We opt to behave as a RAZ/WI when attempts to access PMXEVTYPER | 84 | uint64_t change = (env->svcr ^ new) & mask; |
50 | + * are CONSTRAINED UNPREDICTABLE. See comments in pmxevtyper_write(). | 85 | |
51 | + */ | 86 | env->svcr ^= change; |
52 | + if (env->cp15.c9_pmselr == 0x1f) { | 87 | + |
53 | + return env->cp15.pmccfiltr_el0; | 88 | + if (change & R_SVCR_SM_MASK) { |
54 | + } else { | 89 | + arm_reset_sve_state(env); |
55 | + return 0; | ||
56 | + } | 90 | + } |
57 | } | 91 | } |
58 | 92 | ||
59 | static void pmuserenr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 93 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
60 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 94 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c |
61 | .fieldoffset = offsetof(CPUARMState, cp15.pmccfiltr_el0), | 95 | index XXXXXXX..XXXXXXX 100644 |
62 | .resetvalue = 0, }, | 96 | --- a/target/arm/sme_helper.c |
63 | { .name = "PMXEVTYPER", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 1, | 97 | +++ b/target/arm/sme_helper.c |
64 | - .access = PL0_RW, | 98 | @@ -XXX,XX +XXX,XX @@ |
65 | - .fieldoffset = offsetof(CPUARMState, cp15.c9_pmxevtyper), | 99 | #include "vec_internal.h" |
66 | - .accessfn = pmreg_access, .writefn = pmxevtyper_write, | 100 | #include "sve_ldst_internal.h" |
67 | - .raw_writefn = raw_write }, | 101 | |
68 | + .access = PL0_RW, .type = ARM_CP_NO_RAW, .accessfn = pmreg_access, | 102 | -/* ResetSVEState */ |
69 | + .writefn = pmxevtyper_write, .readfn = pmxevtyper_read }, | 103 | -void arm_reset_sve_state(CPUARMState *env) |
70 | + { .name = "PMXEVTYPER_EL0", .state = ARM_CP_STATE_AA64, | 104 | -{ |
71 | + .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 1, | 105 | - memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs)); |
72 | + .access = PL0_RW, .type = ARM_CP_NO_RAW, .accessfn = pmreg_access, | 106 | - /* Recall that FFR is stored as pregs[16]. */ |
73 | + .writefn = pmxevtyper_write, .readfn = pmxevtyper_read }, | 107 | - memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs)); |
74 | /* Unimplemented, RAZ/WI. */ | 108 | - vfp_set_fpcr(env, 0x0800009f); |
75 | { .name = "PMXEVCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 2, | 109 | -} |
76 | .access = PL0_RW, .type = ARM_CP_CONST, .resetvalue = 0, | 110 | - |
111 | void helper_set_pstate_sm(CPUARMState *env, uint32_t i) | ||
112 | { | ||
113 | if (i == FIELD_EX64(env->svcr, SVCR, SM)) { | ||
114 | return; | ||
115 | } | ||
116 | aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); | ||
117 | - arm_reset_sve_state(env); | ||
118 | arm_rebuild_hflags(env); | ||
119 | } | ||
120 | |||
77 | -- | 121 | -- |
78 | 2.7.4 | 122 | 2.34.1 |
79 | 123 | ||
80 | 124 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@suse.de> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Virtio-mmio devices can directly access guest memory and do so in cache | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | coherent fashion. Tell the guest about that fact when it's using ACPI. | 4 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
5 | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
6 | Signed-off-by: Alexander Graf <agraf@suse.de> | 6 | Message-id: 20230112102436.1913-6-philmd@linaro.org |
7 | Reviewed-by: Laszlo Ersek <lersek@redhat.com> | 7 | Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> |
8 | Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> | 8 | [PMD: Split patch in multiple tiny steps] |
9 | Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Message-id: 1486644810-33181-3-git-send-email-agraf@suse.de | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/arm/virt-acpi-build.c | 1 + | 12 | target/arm/helper.c | 12 ++++++++++++ |
14 | 1 file changed, 1 insertion(+) | 13 | target/arm/sme_helper.c | 12 ------------ |
14 | 2 files changed, 12 insertions(+), 12 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/virt-acpi-build.c | 18 | --- a/target/arm/helper.c |
19 | +++ b/hw/arm/virt-acpi-build.c | 19 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_virtio(Aml *scope, | 20 | @@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) |
21 | Aml *dev = aml_device("VR%02u", i); | 21 | if (change & R_SVCR_SM_MASK) { |
22 | aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005"))); | 22 | arm_reset_sve_state(env); |
23 | aml_append(dev, aml_name_decl("_UID", aml_int(i))); | 23 | } |
24 | + aml_append(dev, aml_name_decl("_CCA", aml_int(1))); | 24 | + |
25 | 25 | + /* | |
26 | Aml *crs = aml_resource_template(); | 26 | + * ResetSMEState. |
27 | aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE)); | 27 | + * |
28 | + * SetPSTATE_ZA zeros on enable and disable. We can zero this only | ||
29 | + * on enable: while disabled, the storage is inaccessible and the | ||
30 | + * value does not matter. We're not saving the storage in vmstate | ||
31 | + * when disabled either. | ||
32 | + */ | ||
33 | + if (change & new & R_SVCR_ZA_MASK) { | ||
34 | + memset(env->zarray, 0, sizeof(env->zarray)); | ||
35 | + } | ||
36 | } | ||
37 | |||
38 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
39 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/sme_helper.c | ||
42 | +++ b/target/arm/sme_helper.c | ||
43 | @@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i) | ||
44 | return; | ||
45 | } | ||
46 | aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK); | ||
47 | - | ||
48 | - /* | ||
49 | - * ResetSMEState. | ||
50 | - * | ||
51 | - * SetPSTATE_ZA zeros on enable and disable. We can zero this only | ||
52 | - * on enable: while disabled, the storage is inaccessible and the | ||
53 | - * value does not matter. We're not saving the storage in vmstate | ||
54 | - * when disabled either. | ||
55 | - */ | ||
56 | - if (i) { | ||
57 | - memset(env->zarray, 0, sizeof(env->zarray)); | ||
58 | - } | ||
59 | arm_rebuild_hflags(env); | ||
60 | } | ||
61 | |||
28 | -- | 62 | -- |
29 | 2.7.4 | 63 | 2.34.1 |
30 | 64 | ||
31 | 65 | diff view generated by jsdifflib |
1 | From: Wei Huang <wei@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds access support for PMINTENSET_EL1. | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | 4 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | |
5 | Signed-off-by: Wei Huang <wei@redhat.com> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Message-id: 20230112102436.1913-7-philmd@linaro.org |
7 | Message-id: 1486504171-26807-4-git-send-email-wei@redhat.com | 7 | Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> |
8 | [PMD: Split patch in multiple tiny steps] | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | target/arm/cpu.h | 2 +- | 12 | linux-user/aarch64/cpu_loop.c | 8 +------- |
11 | target/arm/helper.c | 10 +++++++++- | 13 | linux-user/aarch64/signal.c | 3 --- |
12 | 2 files changed, 10 insertions(+), 2 deletions(-) | 14 | target/arm/helper.c | 6 +++++- |
15 | target/arm/sme_helper.c | 8 -------- | ||
16 | 4 files changed, 6 insertions(+), 19 deletions(-) | ||
13 | 17 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 20 | --- a/linux-user/aarch64/cpu_loop.c |
17 | +++ b/target/arm/cpu.h | 21 | +++ b/linux-user/aarch64/cpu_loop.c |
18 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 22 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
19 | uint32_t c9_pmovsr; /* perf monitor overflow status */ | 23 | |
20 | uint32_t c9_pmuserenr; /* perf monitor user enable */ | 24 | switch (trapnr) { |
21 | uint64_t c9_pmselr; /* perf monitor counter selection register */ | 25 | case EXCP_SWI: |
22 | - uint32_t c9_pminten; /* perf monitor interrupt enables */ | 26 | - /* |
23 | + uint64_t c9_pminten; /* perf monitor interrupt enables */ | 27 | - * On syscall, PSTATE.ZA is preserved, along with the ZA matrix. |
24 | union { /* Memory attribute redirection */ | 28 | - * PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState. |
25 | struct { | 29 | - */ |
26 | #ifdef HOST_WORDS_BIGENDIAN | 30 | + /* On syscall, PSTATE.ZA is preserved, PSTATE.SM is cleared. */ |
31 | aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); | ||
32 | - if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
33 | - arm_rebuild_hflags(env); | ||
34 | - } | ||
35 | ret = do_syscall(env, | ||
36 | env->xregs[8], | ||
37 | env->xregs[0], | ||
38 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/linux-user/aarch64/signal.c | ||
41 | +++ b/linux-user/aarch64/signal.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
43 | |||
44 | /* Invoke the signal handler with both SM and ZA disabled. */ | ||
45 | aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); | ||
46 | - if (env->svcr) { | ||
47 | - arm_rebuild_hflags(env); | ||
48 | - } | ||
49 | |||
50 | if (info) { | ||
51 | tswap_siginfo(&frame->info, info); | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 52 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
28 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/helper.c | 54 | --- a/target/arm/helper.c |
30 | +++ b/target/arm/helper.c | 55 | +++ b/target/arm/helper.c |
31 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 56 | @@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) |
32 | .writefn = pmuserenr_write, .raw_writefn = raw_write }, | 57 | { |
33 | { .name = "PMINTENSET", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 1, | 58 | uint64_t change = (env->svcr ^ new) & mask; |
34 | .access = PL1_RW, .accessfn = access_tpm, | 59 | |
35 | - .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), | 60 | + if (change == 0) { |
36 | + .type = ARM_CP_ALIAS, | 61 | + return; |
37 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pminten), | 62 | + } |
38 | .resetvalue = 0, | 63 | env->svcr ^= change; |
39 | .writefn = pmintenset_write, .raw_writefn = raw_write }, | 64 | |
40 | + { .name = "PMINTENSET_EL1", .state = ARM_CP_STATE_AA64, | 65 | if (change & R_SVCR_SM_MASK) { |
41 | + .opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 1, | 66 | @@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) |
42 | + .access = PL1_RW, .accessfn = access_tpm, | 67 | if (change & new & R_SVCR_ZA_MASK) { |
43 | + .type = ARM_CP_IO, | 68 | memset(env->zarray, 0, sizeof(env->zarray)); |
44 | + .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), | 69 | } |
45 | + .writefn = pmintenset_write, .raw_writefn = raw_write, | 70 | + |
46 | + .resetvalue = 0x0 }, | 71 | + arm_rebuild_hflags(env); |
47 | { .name = "PMINTENCLR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 2, | 72 | } |
48 | .access = PL1_RW, .accessfn = access_tpm, .type = ARM_CP_ALIAS, | 73 | |
49 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), | 74 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
75 | @@ -XXX,XX +XXX,XX @@ static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
76 | helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM)); | ||
77 | helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA)); | ||
78 | aarch64_set_svcr(env, value, -1); | ||
79 | - arm_rebuild_hflags(env); | ||
80 | } | ||
81 | |||
82 | static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
83 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/target/arm/sme_helper.c | ||
86 | +++ b/target/arm/sme_helper.c | ||
87 | @@ -XXX,XX +XXX,XX @@ | ||
88 | |||
89 | void helper_set_pstate_sm(CPUARMState *env, uint32_t i) | ||
90 | { | ||
91 | - if (i == FIELD_EX64(env->svcr, SVCR, SM)) { | ||
92 | - return; | ||
93 | - } | ||
94 | aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); | ||
95 | - arm_rebuild_hflags(env); | ||
96 | } | ||
97 | |||
98 | void helper_set_pstate_za(CPUARMState *env, uint32_t i) | ||
99 | { | ||
100 | - if (i == FIELD_EX64(env->svcr, SVCR, ZA)) { | ||
101 | - return; | ||
102 | - } | ||
103 | aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK); | ||
104 | - arm_rebuild_hflags(env); | ||
105 | } | ||
106 | |||
107 | void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl) | ||
50 | -- | 108 | -- |
51 | 2.7.4 | 109 | 2.34.1 |
52 | 110 | ||
53 | 111 | diff view generated by jsdifflib |
1 | From: Wei Huang <wei@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch contains several fixes to enable vPMU under TCG mode. It | 3 | Unify the two helper_set_pstate_{sm,za} in this function. |
4 | first removes the checking of kvm_enabled() while unsetting | 4 | Do not call helper_* functions from svcr_write. |
5 | ARM_FEATURE_PMU. With it, the .pmu option can be used to turn on/off vPMU | ||
6 | under TCG mode. Secondly the PMU node of DT table is now created under TCG. | ||
7 | The last fix is to disable the masking of PMUver field of ID_AA64DFR0_EL1. | ||
8 | 5 | ||
9 | Signed-off-by: Wei Huang <wei@redhat.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
11 | Message-id: 1486504171-26807-5-git-send-email-wei@redhat.com | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Message-id: 20230112102436.1913-8-philmd@linaro.org | ||
10 | Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> | ||
11 | [PMD: Split patch in multiple tiny steps] | ||
12 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 14 | --- |
14 | hw/arm/virt.c | 2 +- | 15 | target/arm/helper-sme.h | 3 +-- |
15 | target/arm/cpu.c | 2 +- | 16 | target/arm/helper.c | 2 -- |
16 | target/arm/helper.c | 7 +------ | 17 | target/arm/sme_helper.c | 9 ++------- |
17 | 3 files changed, 3 insertions(+), 8 deletions(-) | 18 | target/arm/translate-a64.c | 10 ++-------- |
19 | 4 files changed, 5 insertions(+), 19 deletions(-) | ||
18 | 20 | ||
19 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 21 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h |
20 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/virt.c | 23 | --- a/target/arm/helper-sme.h |
22 | +++ b/hw/arm/virt.c | 24 | +++ b/target/arm/helper-sme.h |
23 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) | 25 | @@ -XXX,XX +XXX,XX @@ |
24 | CPU_FOREACH(cpu) { | 26 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
25 | armcpu = ARM_CPU(cpu); | 27 | */ |
26 | if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU) || | 28 | |
27 | - !kvm_arm_pmu_create(cpu, PPI(VIRTUAL_PMU_IRQ))) { | 29 | -DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32) |
28 | + (kvm_enabled() && !kvm_arm_pmu_create(cpu, PPI(VIRTUAL_PMU_IRQ)))) { | 30 | -DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32) |
29 | return; | 31 | +DEF_HELPER_FLAGS_3(set_svcr, TCG_CALL_NO_RWG, void, env, i32, i32) |
30 | } | 32 | |
31 | } | 33 | DEF_HELPER_FLAGS_3(sme_zero, TCG_CALL_NO_RWG, void, env, i32, i32) |
32 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 34 | |
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/cpu.c | ||
35 | +++ b/target/arm/cpu.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
37 | unset_feature(env, ARM_FEATURE_EL2); | ||
38 | } | ||
39 | |||
40 | - if (!cpu->has_pmu || !kvm_enabled()) { | ||
41 | + if (!cpu->has_pmu) { | ||
42 | cpu->has_pmu = false; | ||
43 | unset_feature(env, ARM_FEATURE_PMU); | ||
44 | } | ||
45 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 35 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
46 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/helper.c | 37 | --- a/target/arm/helper.c |
48 | +++ b/target/arm/helper.c | 38 | +++ b/target/arm/helper.c |
49 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 39 | @@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) |
50 | { .name = "ID_AA64DFR0_EL1", .state = ARM_CP_STATE_AA64, | 40 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
51 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 0, | 41 | uint64_t value) |
52 | .access = PL1_R, .type = ARM_CP_CONST, | 42 | { |
53 | - /* We mask out the PMUVer field, because we don't currently | 43 | - helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM)); |
54 | - * implement the PMU. Not advertising it prevents the guest | 44 | - helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA)); |
55 | - * from trying to use it and getting UNDEFs on registers we | 45 | aarch64_set_svcr(env, value, -1); |
56 | - * don't implement. | 46 | } |
57 | - */ | 47 | |
58 | - .resetvalue = cpu->id_aa64dfr0 & ~0xf00 }, | 48 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c |
59 | + .resetvalue = cpu->id_aa64dfr0 }, | 49 | index XXXXXXX..XXXXXXX 100644 |
60 | { .name = "ID_AA64DFR1_EL1", .state = ARM_CP_STATE_AA64, | 50 | --- a/target/arm/sme_helper.c |
61 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 1, | 51 | +++ b/target/arm/sme_helper.c |
62 | .access = PL1_R, .type = ARM_CP_CONST, | 52 | @@ -XXX,XX +XXX,XX @@ |
53 | #include "vec_internal.h" | ||
54 | #include "sve_ldst_internal.h" | ||
55 | |||
56 | -void helper_set_pstate_sm(CPUARMState *env, uint32_t i) | ||
57 | +void helper_set_svcr(CPUARMState *env, uint32_t val, uint32_t mask) | ||
58 | { | ||
59 | - aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); | ||
60 | -} | ||
61 | - | ||
62 | -void helper_set_pstate_za(CPUARMState *env, uint32_t i) | ||
63 | -{ | ||
64 | - aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK); | ||
65 | + aarch64_set_svcr(env, val, mask); | ||
66 | } | ||
67 | |||
68 | void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl) | ||
69 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/translate-a64.c | ||
72 | +++ b/target/arm/translate-a64.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
74 | |||
75 | if ((old ^ new) & msk) { | ||
76 | /* At least one bit changes. */ | ||
77 | - bool i = crm & 1; | ||
78 | - | ||
79 | - if ((crm & 2) && i != s->pstate_sm) { | ||
80 | - gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); | ||
81 | - } | ||
82 | - if ((crm & 4) && i != s->pstate_za) { | ||
83 | - gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); | ||
84 | - } | ||
85 | + gen_helper_set_svcr(cpu_env, tcg_constant_i32(new), | ||
86 | + tcg_constant_i32(msk)); | ||
87 | } else { | ||
88 | s->base.is_jmp = DISAS_NEXT; | ||
89 | } | ||
63 | -- | 90 | -- |
64 | 2.7.4 | 91 | 2.34.1 |
65 | 92 | ||
66 | 93 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Conversion to probe_access_full missed applying the page offset. | ||
4 | |||
5 | Fixes: b8967ddf ("target/arm: Use probe_access_full for MTE") | ||
6 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1416 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230114031213.2970349-1-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/mte_helper.c | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/mte_helper.c | ||
18 | +++ b/target/arm/mte_helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, | ||
20 | * Remember these values across the second lookup below, | ||
21 | * which may invalidate this pointer via tlb resize. | ||
22 | */ | ||
23 | - ptr_paddr = full->phys_addr; | ||
24 | + ptr_paddr = full->phys_addr | (ptr & ~TARGET_PAGE_MASK); | ||
25 | attrs = full->attrs; | ||
26 | full = NULL; | ||
27 | |||
28 | -- | ||
29 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | During the conversion, the test against get_phys_addr_lpae got inverted, | ||
4 | meaning that successful translations went to the 'failed' label. | ||
5 | |||
6 | Cc: qemu-stable@nongnu.org | ||
7 | Fixes: f3639a64f60 ("target/arm: Use softmmu tlbs for page table walking") | ||
8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1417 | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20230114054605.2977022-1-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/ptw.c | 4 ++-- | ||
15 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/ptw.c | ||
20 | +++ b/target/arm/ptw.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, | ||
22 | }; | ||
23 | GetPhysAddrResult s2 = { }; | ||
24 | |||
25 | - if (!get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD, | ||
26 | - false, &s2, fi)) { | ||
27 | + if (get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD, | ||
28 | + false, &s2, fi)) { | ||
29 | goto fail; | ||
30 | } | ||
31 | ptw->out_phys = s2.f.phys_addr; | ||
32 | -- | ||
33 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In v7m_exception_taken(), for v8M we set the EXC_RETURN.ES bit if | ||
2 | either the exception targets Secure or if the CPU doesn't implement | ||
3 | the Security Extension. This is incorrect: the v8M Arm ARM specifies | ||
4 | that the ES bit should be RES0 if the Security Extension is not | ||
5 | implemented, and the pseudocode agrees. | ||
1 | 6 | ||
7 | Remove the incorrect condition, so that we leave the ES bit 0 | ||
8 | if the Security Extension isn't implemented. | ||
9 | |||
10 | This doesn't have any guest-visible effects for our current set of | ||
11 | emulated CPUs, because all our v8M CPUs implement the Security | ||
12 | Extension; but it's worth fixing in case we add a v8M CPU without | ||
13 | the extension in future. | ||
14 | |||
15 | Reported-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | --- | ||
19 | target/arm/m_helper.c | 2 +- | ||
20 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
21 | |||
22 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/m_helper.c | ||
25 | +++ b/target/arm/m_helper.c | ||
26 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
27 | } | ||
28 | |||
29 | lr &= ~R_V7M_EXCRET_ES_MASK; | ||
30 | - if (targets_secure || !arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
31 | + if (targets_secure) { | ||
32 | lr |= R_V7M_EXCRET_ES_MASK; | ||
33 | } | ||
34 | lr &= ~R_V7M_EXCRET_SPSEL_MASK; | ||
35 | -- | ||
36 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> | ||
1 | 2 | ||
3 | The architecture does not define any functionality for the CLAIM tag bits. | ||
4 | So we will just keep the raw bits, as per spec. | ||
5 | |||
6 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230120155929.32384-2-eiakovlev@linux.microsoft.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 1 + | ||
13 | target/arm/debug_helper.c | 33 +++++++++++++++++++++++++++++++++ | ||
14 | 2 files changed, 34 insertions(+) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
21 | uint64_t dbgbcr[16]; /* breakpoint control registers */ | ||
22 | uint64_t dbgwvr[16]; /* watchpoint value registers */ | ||
23 | uint64_t dbgwcr[16]; /* watchpoint control registers */ | ||
24 | + uint64_t dbgclaim; /* DBGCLAIM bits */ | ||
25 | uint64_t mdscr_el1; | ||
26 | uint64_t oslsr_el1; /* OS Lock Status */ | ||
27 | uint64_t osdlr_el1; /* OS DoubleLock status */ | ||
28 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/debug_helper.c | ||
31 | +++ b/target/arm/debug_helper.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void osdlr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
33 | } | ||
34 | } | ||
35 | |||
36 | +static void dbgclaimset_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
37 | + uint64_t value) | ||
38 | +{ | ||
39 | + env->cp15.dbgclaim |= (value & 0xFF); | ||
40 | +} | ||
41 | + | ||
42 | +static uint64_t dbgclaimset_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
43 | +{ | ||
44 | + /* CLAIM bits are RAO */ | ||
45 | + return 0xFF; | ||
46 | +} | ||
47 | + | ||
48 | +static void dbgclaimclr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
49 | + uint64_t value) | ||
50 | +{ | ||
51 | + env->cp15.dbgclaim &= ~(value & 0xFF); | ||
52 | +} | ||
53 | + | ||
54 | static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
55 | /* | ||
56 | * DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped | ||
57 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
58 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, | ||
59 | .access = PL1_RW, .accessfn = access_tda, | ||
60 | .type = ARM_CP_NOP }, | ||
61 | + /* | ||
62 | + * Dummy DBGCLAIM registers. | ||
63 | + * "The architecture does not define any functionality for the CLAIM tag bits.", | ||
64 | + * so we only keep the raw bits | ||
65 | + */ | ||
66 | + { .name = "DBGCLAIMSET_EL1", .state = ARM_CP_STATE_BOTH, | ||
67 | + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 6, | ||
68 | + .type = ARM_CP_ALIAS, | ||
69 | + .access = PL1_RW, .accessfn = access_tda, | ||
70 | + .writefn = dbgclaimset_write, .readfn = dbgclaimset_read }, | ||
71 | + { .name = "DBGCLAIMCLR_EL1", .state = ARM_CP_STATE_BOTH, | ||
72 | + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 6, | ||
73 | + .access = PL1_RW, .accessfn = access_tda, | ||
74 | + .writefn = dbgclaimclr_write, .raw_writefn = raw_write, | ||
75 | + .fieldoffset = offsetof(CPUARMState, cp15.dbgclaim) }, | ||
76 | }; | ||
77 | |||
78 | static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
79 | -- | ||
80 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> | ||
1 | 2 | ||
3 | Qemu doesn't implement Debug Communication Channel, as well as the rest | ||
4 | of external debug interface. However, Microsoft Hyper-V in tries to | ||
5 | access some of those registers during an EL2 context switch. | ||
6 | |||
7 | Since there is no architectural way to not advertise support for external | ||
8 | debug, provide RAZ/WI stubs for OSDTRRX_EL1, OSDTRTX_EL1 and OSECCR_EL1 | ||
9 | registers in the same way the rest of DCM is currently done. Do account | ||
10 | for access traps though with access_tda. | ||
11 | |||
12 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Message-id: 20230120155929.32384-3-eiakovlev@linux.microsoft.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/debug_helper.c | 21 +++++++++++++++++++++ | ||
18 | 1 file changed, 21 insertions(+) | ||
19 | |||
20 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/debug_helper.c | ||
23 | +++ b/target/arm/debug_helper.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
25 | .opc0 = 2, .opc1 = 3, .crn = 0, .crm = 1, .opc2 = 0, | ||
26 | .access = PL0_R, .accessfn = access_tda, | ||
27 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
28 | + /* | ||
29 | + * OSDTRRX_EL1/OSDTRTX_EL1 are used for save and restore of DBGDTRRX_EL0. | ||
30 | + * It is a component of the Debug Communications Channel, which is not implemented. | ||
31 | + */ | ||
32 | + { .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, | ||
33 | + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2, | ||
34 | + .access = PL1_RW, .accessfn = access_tda, | ||
35 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
36 | + { .name = "OSDTRTX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, | ||
37 | + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2, | ||
38 | + .access = PL1_RW, .accessfn = access_tda, | ||
39 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
40 | + /* | ||
41 | + * OSECCR_EL1 provides a mechanism for an operating system | ||
42 | + * to access the contents of EDECCR. EDECCR is not implemented though, | ||
43 | + * as is the rest of external device mechanism. | ||
44 | + */ | ||
45 | + { .name = "OSECCR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, | ||
46 | + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, | ||
47 | + .access = PL1_RW, .accessfn = access_tda, | ||
48 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
49 | /* | ||
50 | * DBGDSCRint[15,12,5:2] map to MDSCR_EL1[15,12,5:2]. Map all bits as | ||
51 | * it is unlikely a guest will care. | ||
52 | -- | ||
53 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | write_boot_rom() does not check for negative values. This is more a | 3 | Move the ri == NULL case to the top of the function and return. |
4 | problem for coverity than the actual code as the size of the flash | 4 | This allows the else to be removed and the code unindented. |
5 | device is checked when the m25p80 object is created. If there is | ||
6 | anything wrong with the backing file, we should not even reach that | ||
7 | path. | ||
8 | 5 | ||
9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 1486648058-520-2-git-send-email-clg@kaod.org | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | Message-id: 20230106194451.1213153-2-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | hw/arm/aspeed.c | 14 ++++++++++++-- | 12 | target/arm/translate.c | 406 ++++++++++++++++++++--------------------- |
15 | 1 file changed, 12 insertions(+), 2 deletions(-) | 13 | 1 file changed, 203 insertions(+), 203 deletions(-) |
16 | 14 | ||
17 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 15 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/aspeed.c | 17 | --- a/target/arm/translate.c |
20 | +++ b/hw/arm/aspeed.c | 18 | +++ b/target/arm/translate.c |
21 | @@ -XXX,XX +XXX,XX @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size, | 19 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
20 | bool isread, int rt, int rt2) | ||
22 | { | 21 | { |
23 | BlockBackend *blk = blk_by_legacy_dinfo(dinfo); | 22 | const ARMCPRegInfo *ri; |
24 | uint8_t *storage; | 23 | + bool need_exit_tb; |
25 | + int64_t size; | 24 | |
26 | 25 | ri = get_arm_cp_reginfo(s->cp_regs, | |
27 | - if (rom_size > blk_getlength(blk)) { | 26 | ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2)); |
28 | - rom_size = blk_getlength(blk); | 27 | - if (ri) { |
29 | + /* The block backend size should have already been 'validated' by | 28 | - bool need_exit_tb; |
30 | + * the creation of the m25p80 object. | 29 | |
31 | + */ | 30 | - /* Check access permissions */ |
32 | + size = blk_getlength(blk); | 31 | - if (!cp_access_ok(s->current_el, ri, isread)) { |
33 | + if (size <= 0) { | 32 | - unallocated_encoding(s); |
34 | + error_setg(errp, "failed to get flash size"); | 33 | - return; |
34 | - } | ||
35 | - | ||
36 | - if (s->hstr_active || ri->accessfn || | ||
37 | - (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) { | ||
38 | - /* Emit code to perform further access permissions checks at | ||
39 | - * runtime; this may result in an exception. | ||
40 | - * Note that on XScale all cp0..c13 registers do an access check | ||
41 | - * call in order to handle c15_cpar. | ||
42 | - */ | ||
43 | - uint32_t syndrome; | ||
44 | - | ||
45 | - /* Note that since we are an implementation which takes an | ||
46 | - * exception on a trapped conditional instruction only if the | ||
47 | - * instruction passes its condition code check, we can take | ||
48 | - * advantage of the clause in the ARM ARM that allows us to set | ||
49 | - * the COND field in the instruction to 0xE in all cases. | ||
50 | - * We could fish the actual condition out of the insn (ARM) | ||
51 | - * or the condexec bits (Thumb) but it isn't necessary. | ||
52 | - */ | ||
53 | - switch (cpnum) { | ||
54 | - case 14: | ||
55 | - if (is64) { | ||
56 | - syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2, | ||
57 | - isread, false); | ||
58 | - } else { | ||
59 | - syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm, | ||
60 | - rt, isread, false); | ||
61 | - } | ||
62 | - break; | ||
63 | - case 15: | ||
64 | - if (is64) { | ||
65 | - syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2, | ||
66 | - isread, false); | ||
67 | - } else { | ||
68 | - syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm, | ||
69 | - rt, isread, false); | ||
70 | - } | ||
71 | - break; | ||
72 | - default: | ||
73 | - /* ARMv8 defines that only coprocessors 14 and 15 exist, | ||
74 | - * so this can only happen if this is an ARMv7 or earlier CPU, | ||
75 | - * in which case the syndrome information won't actually be | ||
76 | - * guest visible. | ||
77 | - */ | ||
78 | - assert(!arm_dc_feature(s, ARM_FEATURE_V8)); | ||
79 | - syndrome = syn_uncategorized(); | ||
80 | - break; | ||
81 | - } | ||
82 | - | ||
83 | - gen_set_condexec(s); | ||
84 | - gen_update_pc(s, 0); | ||
85 | - gen_helper_access_check_cp_reg(cpu_env, | ||
86 | - tcg_constant_ptr(ri), | ||
87 | - tcg_constant_i32(syndrome), | ||
88 | - tcg_constant_i32(isread)); | ||
89 | - } else if (ri->type & ARM_CP_RAISES_EXC) { | ||
90 | - /* | ||
91 | - * The readfn or writefn might raise an exception; | ||
92 | - * synchronize the CPU state in case it does. | ||
93 | - */ | ||
94 | - gen_set_condexec(s); | ||
95 | - gen_update_pc(s, 0); | ||
96 | - } | ||
97 | - | ||
98 | - /* Handle special cases first */ | ||
99 | - switch (ri->type & ARM_CP_SPECIAL_MASK) { | ||
100 | - case 0: | ||
101 | - break; | ||
102 | - case ARM_CP_NOP: | ||
103 | - return; | ||
104 | - case ARM_CP_WFI: | ||
105 | - if (isread) { | ||
106 | - unallocated_encoding(s); | ||
107 | - return; | ||
108 | - } | ||
109 | - gen_update_pc(s, curr_insn_len(s)); | ||
110 | - s->base.is_jmp = DISAS_WFI; | ||
111 | - return; | ||
112 | - default: | ||
113 | - g_assert_not_reached(); | ||
114 | - } | ||
115 | - | ||
116 | - if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | ||
117 | - gen_io_start(); | ||
118 | - } | ||
119 | - | ||
120 | - if (isread) { | ||
121 | - /* Read */ | ||
122 | - if (is64) { | ||
123 | - TCGv_i64 tmp64; | ||
124 | - TCGv_i32 tmp; | ||
125 | - if (ri->type & ARM_CP_CONST) { | ||
126 | - tmp64 = tcg_constant_i64(ri->resetvalue); | ||
127 | - } else if (ri->readfn) { | ||
128 | - tmp64 = tcg_temp_new_i64(); | ||
129 | - gen_helper_get_cp_reg64(tmp64, cpu_env, | ||
130 | - tcg_constant_ptr(ri)); | ||
131 | - } else { | ||
132 | - tmp64 = tcg_temp_new_i64(); | ||
133 | - tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset); | ||
134 | - } | ||
135 | - tmp = tcg_temp_new_i32(); | ||
136 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
137 | - store_reg(s, rt, tmp); | ||
138 | - tmp = tcg_temp_new_i32(); | ||
139 | - tcg_gen_extrh_i64_i32(tmp, tmp64); | ||
140 | - tcg_temp_free_i64(tmp64); | ||
141 | - store_reg(s, rt2, tmp); | ||
142 | - } else { | ||
143 | - TCGv_i32 tmp; | ||
144 | - if (ri->type & ARM_CP_CONST) { | ||
145 | - tmp = tcg_constant_i32(ri->resetvalue); | ||
146 | - } else if (ri->readfn) { | ||
147 | - tmp = tcg_temp_new_i32(); | ||
148 | - gen_helper_get_cp_reg(tmp, cpu_env, tcg_constant_ptr(ri)); | ||
149 | - } else { | ||
150 | - tmp = load_cpu_offset(ri->fieldoffset); | ||
151 | - } | ||
152 | - if (rt == 15) { | ||
153 | - /* Destination register of r15 for 32 bit loads sets | ||
154 | - * the condition codes from the high 4 bits of the value | ||
155 | - */ | ||
156 | - gen_set_nzcv(tmp); | ||
157 | - tcg_temp_free_i32(tmp); | ||
158 | - } else { | ||
159 | - store_reg(s, rt, tmp); | ||
160 | - } | ||
161 | - } | ||
162 | + if (!ri) { | ||
163 | + /* | ||
164 | + * Unknown register; this might be a guest error or a QEMU | ||
165 | + * unimplemented feature. | ||
166 | + */ | ||
167 | + if (is64) { | ||
168 | + qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " | ||
169 | + "64 bit system register cp:%d opc1: %d crm:%d " | ||
170 | + "(%s)\n", | ||
171 | + isread ? "read" : "write", cpnum, opc1, crm, | ||
172 | + s->ns ? "non-secure" : "secure"); | ||
173 | } else { | ||
174 | - /* Write */ | ||
175 | - if (ri->type & ARM_CP_CONST) { | ||
176 | - /* If not forbidden by access permissions, treat as WI */ | ||
177 | - return; | ||
178 | - } | ||
179 | - | ||
180 | - if (is64) { | ||
181 | - TCGv_i32 tmplo, tmphi; | ||
182 | - TCGv_i64 tmp64 = tcg_temp_new_i64(); | ||
183 | - tmplo = load_reg(s, rt); | ||
184 | - tmphi = load_reg(s, rt2); | ||
185 | - tcg_gen_concat_i32_i64(tmp64, tmplo, tmphi); | ||
186 | - tcg_temp_free_i32(tmplo); | ||
187 | - tcg_temp_free_i32(tmphi); | ||
188 | - if (ri->writefn) { | ||
189 | - gen_helper_set_cp_reg64(cpu_env, tcg_constant_ptr(ri), | ||
190 | - tmp64); | ||
191 | - } else { | ||
192 | - tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset); | ||
193 | - } | ||
194 | - tcg_temp_free_i64(tmp64); | ||
195 | - } else { | ||
196 | - TCGv_i32 tmp = load_reg(s, rt); | ||
197 | - if (ri->writefn) { | ||
198 | - gen_helper_set_cp_reg(cpu_env, tcg_constant_ptr(ri), tmp); | ||
199 | - tcg_temp_free_i32(tmp); | ||
200 | - } else { | ||
201 | - store_cpu_offset(tmp, ri->fieldoffset, 4); | ||
202 | - } | ||
203 | - } | ||
204 | + qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " | ||
205 | + "system register cp:%d opc1:%d crn:%d crm:%d " | ||
206 | + "opc2:%d (%s)\n", | ||
207 | + isread ? "read" : "write", cpnum, opc1, crn, | ||
208 | + crm, opc2, s->ns ? "non-secure" : "secure"); | ||
209 | } | ||
210 | - | ||
211 | - /* I/O operations must end the TB here (whether read or write) */ | ||
212 | - need_exit_tb = ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && | ||
213 | - (ri->type & ARM_CP_IO)); | ||
214 | - | ||
215 | - if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { | ||
216 | - /* | ||
217 | - * A write to any coprocessor register that ends a TB | ||
218 | - * must rebuild the hflags for the next TB. | ||
219 | - */ | ||
220 | - gen_rebuild_hflags(s, ri->type & ARM_CP_NEWEL); | ||
221 | - /* | ||
222 | - * We default to ending the TB on a coprocessor register write, | ||
223 | - * but allow this to be suppressed by the register definition | ||
224 | - * (usually only necessary to work around guest bugs). | ||
225 | - */ | ||
226 | - need_exit_tb = true; | ||
227 | - } | ||
228 | - if (need_exit_tb) { | ||
229 | - gen_lookup_tb(s); | ||
230 | - } | ||
231 | - | ||
232 | + unallocated_encoding(s); | ||
233 | return; | ||
234 | } | ||
235 | |||
236 | - /* Unknown register; this might be a guest error or a QEMU | ||
237 | - * unimplemented feature. | ||
238 | - */ | ||
239 | - if (is64) { | ||
240 | - qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " | ||
241 | - "64 bit system register cp:%d opc1: %d crm:%d " | ||
242 | - "(%s)\n", | ||
243 | - isread ? "read" : "write", cpnum, opc1, crm, | ||
244 | - s->ns ? "non-secure" : "secure"); | ||
245 | - } else { | ||
246 | - qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " | ||
247 | - "system register cp:%d opc1:%d crn:%d crm:%d opc2:%d " | ||
248 | - "(%s)\n", | ||
249 | - isread ? "read" : "write", cpnum, opc1, crn, crm, opc2, | ||
250 | - s->ns ? "non-secure" : "secure"); | ||
251 | + /* Check access permissions */ | ||
252 | + if (!cp_access_ok(s->current_el, ri, isread)) { | ||
253 | + unallocated_encoding(s); | ||
35 | + return; | 254 | + return; |
36 | + } | ||
37 | + | ||
38 | + if (rom_size > size) { | ||
39 | + rom_size = size; | ||
40 | } | 255 | } |
41 | 256 | ||
42 | storage = g_new0(uint8_t, rom_size); | 257 | - unallocated_encoding(s); |
258 | - return; | ||
259 | + if (s->hstr_active || ri->accessfn || | ||
260 | + (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) { | ||
261 | + /* | ||
262 | + * Emit code to perform further access permissions checks at | ||
263 | + * runtime; this may result in an exception. | ||
264 | + * Note that on XScale all cp0..c13 registers do an access check | ||
265 | + * call in order to handle c15_cpar. | ||
266 | + */ | ||
267 | + uint32_t syndrome; | ||
268 | + | ||
269 | + /* | ||
270 | + * Note that since we are an implementation which takes an | ||
271 | + * exception on a trapped conditional instruction only if the | ||
272 | + * instruction passes its condition code check, we can take | ||
273 | + * advantage of the clause in the ARM ARM that allows us to set | ||
274 | + * the COND field in the instruction to 0xE in all cases. | ||
275 | + * We could fish the actual condition out of the insn (ARM) | ||
276 | + * or the condexec bits (Thumb) but it isn't necessary. | ||
277 | + */ | ||
278 | + switch (cpnum) { | ||
279 | + case 14: | ||
280 | + if (is64) { | ||
281 | + syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2, | ||
282 | + isread, false); | ||
283 | + } else { | ||
284 | + syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm, | ||
285 | + rt, isread, false); | ||
286 | + } | ||
287 | + break; | ||
288 | + case 15: | ||
289 | + if (is64) { | ||
290 | + syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2, | ||
291 | + isread, false); | ||
292 | + } else { | ||
293 | + syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm, | ||
294 | + rt, isread, false); | ||
295 | + } | ||
296 | + break; | ||
297 | + default: | ||
298 | + /* | ||
299 | + * ARMv8 defines that only coprocessors 14 and 15 exist, | ||
300 | + * so this can only happen if this is an ARMv7 or earlier CPU, | ||
301 | + * in which case the syndrome information won't actually be | ||
302 | + * guest visible. | ||
303 | + */ | ||
304 | + assert(!arm_dc_feature(s, ARM_FEATURE_V8)); | ||
305 | + syndrome = syn_uncategorized(); | ||
306 | + break; | ||
307 | + } | ||
308 | + | ||
309 | + gen_set_condexec(s); | ||
310 | + gen_update_pc(s, 0); | ||
311 | + gen_helper_access_check_cp_reg(cpu_env, | ||
312 | + tcg_constant_ptr(ri), | ||
313 | + tcg_constant_i32(syndrome), | ||
314 | + tcg_constant_i32(isread)); | ||
315 | + } else if (ri->type & ARM_CP_RAISES_EXC) { | ||
316 | + /* | ||
317 | + * The readfn or writefn might raise an exception; | ||
318 | + * synchronize the CPU state in case it does. | ||
319 | + */ | ||
320 | + gen_set_condexec(s); | ||
321 | + gen_update_pc(s, 0); | ||
322 | + } | ||
323 | + | ||
324 | + /* Handle special cases first */ | ||
325 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { | ||
326 | + case 0: | ||
327 | + break; | ||
328 | + case ARM_CP_NOP: | ||
329 | + return; | ||
330 | + case ARM_CP_WFI: | ||
331 | + if (isread) { | ||
332 | + unallocated_encoding(s); | ||
333 | + return; | ||
334 | + } | ||
335 | + gen_update_pc(s, curr_insn_len(s)); | ||
336 | + s->base.is_jmp = DISAS_WFI; | ||
337 | + return; | ||
338 | + default: | ||
339 | + g_assert_not_reached(); | ||
340 | + } | ||
341 | + | ||
342 | + if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | ||
343 | + gen_io_start(); | ||
344 | + } | ||
345 | + | ||
346 | + if (isread) { | ||
347 | + /* Read */ | ||
348 | + if (is64) { | ||
349 | + TCGv_i64 tmp64; | ||
350 | + TCGv_i32 tmp; | ||
351 | + if (ri->type & ARM_CP_CONST) { | ||
352 | + tmp64 = tcg_constant_i64(ri->resetvalue); | ||
353 | + } else if (ri->readfn) { | ||
354 | + tmp64 = tcg_temp_new_i64(); | ||
355 | + gen_helper_get_cp_reg64(tmp64, cpu_env, | ||
356 | + tcg_constant_ptr(ri)); | ||
357 | + } else { | ||
358 | + tmp64 = tcg_temp_new_i64(); | ||
359 | + tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset); | ||
360 | + } | ||
361 | + tmp = tcg_temp_new_i32(); | ||
362 | + tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
363 | + store_reg(s, rt, tmp); | ||
364 | + tmp = tcg_temp_new_i32(); | ||
365 | + tcg_gen_extrh_i64_i32(tmp, tmp64); | ||
366 | + tcg_temp_free_i64(tmp64); | ||
367 | + store_reg(s, rt2, tmp); | ||
368 | + } else { | ||
369 | + TCGv_i32 tmp; | ||
370 | + if (ri->type & ARM_CP_CONST) { | ||
371 | + tmp = tcg_constant_i32(ri->resetvalue); | ||
372 | + } else if (ri->readfn) { | ||
373 | + tmp = tcg_temp_new_i32(); | ||
374 | + gen_helper_get_cp_reg(tmp, cpu_env, tcg_constant_ptr(ri)); | ||
375 | + } else { | ||
376 | + tmp = load_cpu_offset(ri->fieldoffset); | ||
377 | + } | ||
378 | + if (rt == 15) { | ||
379 | + /* Destination register of r15 for 32 bit loads sets | ||
380 | + * the condition codes from the high 4 bits of the value | ||
381 | + */ | ||
382 | + gen_set_nzcv(tmp); | ||
383 | + tcg_temp_free_i32(tmp); | ||
384 | + } else { | ||
385 | + store_reg(s, rt, tmp); | ||
386 | + } | ||
387 | + } | ||
388 | + } else { | ||
389 | + /* Write */ | ||
390 | + if (ri->type & ARM_CP_CONST) { | ||
391 | + /* If not forbidden by access permissions, treat as WI */ | ||
392 | + return; | ||
393 | + } | ||
394 | + | ||
395 | + if (is64) { | ||
396 | + TCGv_i32 tmplo, tmphi; | ||
397 | + TCGv_i64 tmp64 = tcg_temp_new_i64(); | ||
398 | + tmplo = load_reg(s, rt); | ||
399 | + tmphi = load_reg(s, rt2); | ||
400 | + tcg_gen_concat_i32_i64(tmp64, tmplo, tmphi); | ||
401 | + tcg_temp_free_i32(tmplo); | ||
402 | + tcg_temp_free_i32(tmphi); | ||
403 | + if (ri->writefn) { | ||
404 | + gen_helper_set_cp_reg64(cpu_env, tcg_constant_ptr(ri), tmp64); | ||
405 | + } else { | ||
406 | + tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset); | ||
407 | + } | ||
408 | + tcg_temp_free_i64(tmp64); | ||
409 | + } else { | ||
410 | + TCGv_i32 tmp = load_reg(s, rt); | ||
411 | + if (ri->writefn) { | ||
412 | + gen_helper_set_cp_reg(cpu_env, tcg_constant_ptr(ri), tmp); | ||
413 | + tcg_temp_free_i32(tmp); | ||
414 | + } else { | ||
415 | + store_cpu_offset(tmp, ri->fieldoffset, 4); | ||
416 | + } | ||
417 | + } | ||
418 | + } | ||
419 | + | ||
420 | + /* I/O operations must end the TB here (whether read or write) */ | ||
421 | + need_exit_tb = ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && | ||
422 | + (ri->type & ARM_CP_IO)); | ||
423 | + | ||
424 | + if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { | ||
425 | + /* | ||
426 | + * A write to any coprocessor register that ends a TB | ||
427 | + * must rebuild the hflags for the next TB. | ||
428 | + */ | ||
429 | + gen_rebuild_hflags(s, ri->type & ARM_CP_NEWEL); | ||
430 | + /* | ||
431 | + * We default to ending the TB on a coprocessor register write, | ||
432 | + * but allow this to be suppressed by the register definition | ||
433 | + * (usually only necessary to work around guest bugs). | ||
434 | + */ | ||
435 | + need_exit_tb = true; | ||
436 | + } | ||
437 | + if (need_exit_tb) { | ||
438 | + gen_lookup_tb(s); | ||
439 | + } | ||
440 | } | ||
441 | |||
442 | /* Decode XScale DSP or iWMMXt insn (in the copro space, cp=0 or 1) */ | ||
43 | -- | 443 | -- |
44 | 2.7.4 | 444 | 2.34.1 |
45 | 445 | ||
46 | 446 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Do not encode the pointer as a constant in the opcode stream. | ||
4 | This pointer is specific to the cpu that first generated the | ||
5 | translation, which runs into problems with both hot-pluggable | ||
6 | cpus and user-only threads, as cpus are removed. It's also a | ||
7 | potential correctness issue in the theoretical case of a | ||
8 | slightly-heterogenous system, because if CPU 0 generates a | ||
9 | TB and then CPU 1 executes it, CPU 1 will end up using CPU 0's | ||
10 | hash table, which might have a wrong set of registers in it. | ||
11 | (All our current systems are either completely homogenous, | ||
12 | M-profile, or have CPUs sufficiently different that they | ||
13 | wouldn't be sharing TBs anyway because the differences would | ||
14 | show up in the TB flags, so the correctness issue is only | ||
15 | theoretical, not practical.) | ||
16 | |||
17 | Perform the lookup in either helper_access_check_cp_reg, | ||
18 | or a new helper_lookup_cp_reg. | ||
19 | |||
20 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20230106194451.1213153-3-richard.henderson@linaro.org | ||
22 | [PMM: added note in commit message about correctness issue] | ||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | --- | ||
26 | target/arm/helper.h | 11 +++++---- | ||
27 | target/arm/translate.h | 7 ++++++ | ||
28 | target/arm/op_helper.c | 27 ++++++++++++++------ | ||
29 | target/arm/translate-a64.c | 49 ++++++++++++++++++++++--------------- | ||
30 | target/arm/translate.c | 50 +++++++++++++++++++++++++------------- | ||
31 | 5 files changed, 95 insertions(+), 49 deletions(-) | ||
32 | |||
33 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/helper.h | ||
36 | +++ b/target/arm/helper.h | ||
37 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v8m_stackcheck, void, env, i32) | ||
38 | |||
39 | DEF_HELPER_FLAGS_2(check_bxj_trap, TCG_CALL_NO_WG, void, env, i32) | ||
40 | |||
41 | -DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | ||
42 | -DEF_HELPER_3(set_cp_reg, void, env, ptr, i32) | ||
43 | -DEF_HELPER_2(get_cp_reg, i32, env, ptr) | ||
44 | -DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64) | ||
45 | -DEF_HELPER_2(get_cp_reg64, i64, env, ptr) | ||
46 | +DEF_HELPER_4(access_check_cp_reg, cptr, env, i32, i32, i32) | ||
47 | +DEF_HELPER_FLAGS_2(lookup_cp_reg, TCG_CALL_NO_RWG_SE, cptr, env, i32) | ||
48 | +DEF_HELPER_3(set_cp_reg, void, env, cptr, i32) | ||
49 | +DEF_HELPER_2(get_cp_reg, i32, env, cptr) | ||
50 | +DEF_HELPER_3(set_cp_reg64, void, env, cptr, i64) | ||
51 | +DEF_HELPER_2(get_cp_reg64, i64, env, cptr) | ||
52 | |||
53 | DEF_HELPER_2(get_r13_banked, i32, env, i32) | ||
54 | DEF_HELPER_3(set_r13_banked, void, env, i32, i32) | ||
55 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/translate.h | ||
58 | +++ b/target/arm/translate.h | ||
59 | @@ -XXX,XX +XXX,XX @@ static inline void set_disas_label(DisasContext *s, DisasLabel l) | ||
60 | s->pc_save = l.pc_save; | ||
61 | } | ||
62 | |||
63 | +static inline TCGv_ptr gen_lookup_cp_reg(uint32_t key) | ||
64 | +{ | ||
65 | + TCGv_ptr ret = tcg_temp_new_ptr(); | ||
66 | + gen_helper_lookup_cp_reg(ret, cpu_env, tcg_constant_i32(key)); | ||
67 | + return ret; | ||
68 | +} | ||
69 | + | ||
70 | /* | ||
71 | * Helpers for implementing sets of trans_* functions. | ||
72 | * Defer the implementation of NAME to FUNC, with optional extra arguments. | ||
73 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/op_helper.c | ||
76 | +++ b/target/arm/op_helper.c | ||
77 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t tgtmode, uint32_t regno) | ||
78 | } | ||
79 | } | ||
80 | |||
81 | -void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
82 | - uint32_t isread) | ||
83 | +const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key, | ||
84 | + uint32_t syndrome, uint32_t isread) | ||
85 | { | ||
86 | ARMCPU *cpu = env_archcpu(env); | ||
87 | - const ARMCPRegInfo *ri = rip; | ||
88 | + const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, key); | ||
89 | CPAccessResult res = CP_ACCESS_OK; | ||
90 | int target_el; | ||
91 | |||
92 | + assert(ri != NULL); | ||
93 | + | ||
94 | if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14 | ||
95 | && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) { | ||
96 | res = CP_ACCESS_TRAP; | ||
97 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
98 | res = ri->accessfn(env, ri, isread); | ||
99 | } | ||
100 | if (likely(res == CP_ACCESS_OK)) { | ||
101 | - return; | ||
102 | + return ri; | ||
103 | } | ||
104 | |||
105 | fail: | ||
106 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
107 | raise_exception(env, EXCP_UDEF, syndrome, target_el); | ||
108 | } | ||
109 | |||
110 | -void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value) | ||
111 | +const void *HELPER(lookup_cp_reg)(CPUARMState *env, uint32_t key) | ||
112 | +{ | ||
113 | + ARMCPU *cpu = env_archcpu(env); | ||
114 | + const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, key); | ||
115 | + | ||
116 | + assert(ri != NULL); | ||
117 | + return ri; | ||
118 | +} | ||
119 | + | ||
120 | +void HELPER(set_cp_reg)(CPUARMState *env, const void *rip, uint32_t value) | ||
121 | { | ||
122 | const ARMCPRegInfo *ri = rip; | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value) | ||
125 | } | ||
126 | } | ||
127 | |||
128 | -uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip) | ||
129 | +uint32_t HELPER(get_cp_reg)(CPUARMState *env, const void *rip) | ||
130 | { | ||
131 | const ARMCPRegInfo *ri = rip; | ||
132 | uint32_t res; | ||
133 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip) | ||
134 | return res; | ||
135 | } | ||
136 | |||
137 | -void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value) | ||
138 | +void HELPER(set_cp_reg64)(CPUARMState *env, const void *rip, uint64_t value) | ||
139 | { | ||
140 | const ARMCPRegInfo *ri = rip; | ||
141 | |||
142 | @@ -XXX,XX +XXX,XX @@ void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value) | ||
143 | } | ||
144 | } | ||
145 | |||
146 | -uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip) | ||
147 | +uint64_t HELPER(get_cp_reg64)(CPUARMState *env, const void *rip) | ||
148 | { | ||
149 | const ARMCPRegInfo *ri = rip; | ||
150 | uint64_t res; | ||
151 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/target/arm/translate-a64.c | ||
154 | +++ b/target/arm/translate-a64.c | ||
155 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
156 | unsigned int op0, unsigned int op1, unsigned int op2, | ||
157 | unsigned int crn, unsigned int crm, unsigned int rt) | ||
158 | { | ||
159 | - const ARMCPRegInfo *ri; | ||
160 | + uint32_t key = ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, | ||
161 | + crn, crm, op0, op1, op2); | ||
162 | + const ARMCPRegInfo *ri = get_arm_cp_reginfo(s->cp_regs, key); | ||
163 | + TCGv_ptr tcg_ri = NULL; | ||
164 | TCGv_i64 tcg_rt; | ||
165 | |||
166 | - ri = get_arm_cp_reginfo(s->cp_regs, | ||
167 | - ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, | ||
168 | - crn, crm, op0, op1, op2)); | ||
169 | - | ||
170 | if (!ri) { | ||
171 | /* Unknown register; this might be a guest error or a QEMU | ||
172 | * unimplemented feature. | ||
173 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
174 | |||
175 | syndrome = syn_aa64_sysregtrap(op0, op1, op2, crn, crm, rt, isread); | ||
176 | gen_a64_update_pc(s, 0); | ||
177 | - gen_helper_access_check_cp_reg(cpu_env, | ||
178 | - tcg_constant_ptr(ri), | ||
179 | + tcg_ri = tcg_temp_new_ptr(); | ||
180 | + gen_helper_access_check_cp_reg(tcg_ri, cpu_env, | ||
181 | + tcg_constant_i32(key), | ||
182 | tcg_constant_i32(syndrome), | ||
183 | tcg_constant_i32(isread)); | ||
184 | } else if (ri->type & ARM_CP_RAISES_EXC) { | ||
185 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
186 | case 0: | ||
187 | break; | ||
188 | case ARM_CP_NOP: | ||
189 | - return; | ||
190 | + goto exit; | ||
191 | case ARM_CP_NZCV: | ||
192 | tcg_rt = cpu_reg(s, rt); | ||
193 | if (isread) { | ||
194 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
195 | } else { | ||
196 | gen_set_nzcv(tcg_rt); | ||
197 | } | ||
198 | - return; | ||
199 | + goto exit; | ||
200 | case ARM_CP_CURRENTEL: | ||
201 | /* Reads as current EL value from pstate, which is | ||
202 | * guaranteed to be constant by the tb flags. | ||
203 | */ | ||
204 | tcg_rt = cpu_reg(s, rt); | ||
205 | tcg_gen_movi_i64(tcg_rt, s->current_el << 2); | ||
206 | - return; | ||
207 | + goto exit; | ||
208 | case ARM_CP_DC_ZVA: | ||
209 | /* Writes clear the aligned block of memory which rt points into. */ | ||
210 | if (s->mte_active[0]) { | ||
211 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
212 | tcg_rt = clean_data_tbi(s, cpu_reg(s, rt)); | ||
213 | } | ||
214 | gen_helper_dc_zva(cpu_env, tcg_rt); | ||
215 | - return; | ||
216 | + goto exit; | ||
217 | case ARM_CP_DC_GVA: | ||
218 | { | ||
219 | TCGv_i64 clean_addr, tag; | ||
220 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
221 | tcg_temp_free_i64(tag); | ||
222 | } | ||
223 | } | ||
224 | - return; | ||
225 | + goto exit; | ||
226 | case ARM_CP_DC_GZVA: | ||
227 | { | ||
228 | TCGv_i64 clean_addr, tag; | ||
229 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
230 | tcg_temp_free_i64(tag); | ||
231 | } | ||
232 | } | ||
233 | - return; | ||
234 | + goto exit; | ||
235 | default: | ||
236 | g_assert_not_reached(); | ||
237 | } | ||
238 | if ((ri->type & ARM_CP_FPU) && !fp_access_check_only(s)) { | ||
239 | - return; | ||
240 | + goto exit; | ||
241 | } else if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) { | ||
242 | - return; | ||
243 | + goto exit; | ||
244 | } else if ((ri->type & ARM_CP_SME) && !sme_access_check(s)) { | ||
245 | - return; | ||
246 | + goto exit; | ||
247 | } | ||
248 | |||
249 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | ||
250 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
251 | if (ri->type & ARM_CP_CONST) { | ||
252 | tcg_gen_movi_i64(tcg_rt, ri->resetvalue); | ||
253 | } else if (ri->readfn) { | ||
254 | - gen_helper_get_cp_reg64(tcg_rt, cpu_env, tcg_constant_ptr(ri)); | ||
255 | + if (!tcg_ri) { | ||
256 | + tcg_ri = gen_lookup_cp_reg(key); | ||
257 | + } | ||
258 | + gen_helper_get_cp_reg64(tcg_rt, cpu_env, tcg_ri); | ||
259 | } else { | ||
260 | tcg_gen_ld_i64(tcg_rt, cpu_env, ri->fieldoffset); | ||
261 | } | ||
262 | } else { | ||
263 | if (ri->type & ARM_CP_CONST) { | ||
264 | /* If not forbidden by access permissions, treat as WI */ | ||
265 | - return; | ||
266 | + goto exit; | ||
267 | } else if (ri->writefn) { | ||
268 | - gen_helper_set_cp_reg64(cpu_env, tcg_constant_ptr(ri), tcg_rt); | ||
269 | + if (!tcg_ri) { | ||
270 | + tcg_ri = gen_lookup_cp_reg(key); | ||
271 | + } | ||
272 | + gen_helper_set_cp_reg64(cpu_env, tcg_ri, tcg_rt); | ||
273 | } else { | ||
274 | tcg_gen_st_i64(tcg_rt, cpu_env, ri->fieldoffset); | ||
275 | } | ||
276 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
277 | */ | ||
278 | s->base.is_jmp = DISAS_UPDATE_EXIT; | ||
279 | } | ||
280 | + | ||
281 | + exit: | ||
282 | + if (tcg_ri) { | ||
283 | + tcg_temp_free_ptr(tcg_ri); | ||
284 | + } | ||
285 | } | ||
286 | |||
287 | /* System | ||
288 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
289 | index XXXXXXX..XXXXXXX 100644 | ||
290 | --- a/target/arm/translate.c | ||
291 | +++ b/target/arm/translate.c | ||
292 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
293 | int opc1, int crn, int crm, int opc2, | ||
294 | bool isread, int rt, int rt2) | ||
295 | { | ||
296 | - const ARMCPRegInfo *ri; | ||
297 | + uint32_t key = ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2); | ||
298 | + const ARMCPRegInfo *ri = get_arm_cp_reginfo(s->cp_regs, key); | ||
299 | + TCGv_ptr tcg_ri = NULL; | ||
300 | bool need_exit_tb; | ||
301 | |||
302 | - ri = get_arm_cp_reginfo(s->cp_regs, | ||
303 | - ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2)); | ||
304 | - | ||
305 | if (!ri) { | ||
306 | /* | ||
307 | * Unknown register; this might be a guest error or a QEMU | ||
308 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
309 | |||
310 | gen_set_condexec(s); | ||
311 | gen_update_pc(s, 0); | ||
312 | - gen_helper_access_check_cp_reg(cpu_env, | ||
313 | - tcg_constant_ptr(ri), | ||
314 | + tcg_ri = tcg_temp_new_ptr(); | ||
315 | + gen_helper_access_check_cp_reg(tcg_ri, cpu_env, | ||
316 | + tcg_constant_i32(key), | ||
317 | tcg_constant_i32(syndrome), | ||
318 | tcg_constant_i32(isread)); | ||
319 | } else if (ri->type & ARM_CP_RAISES_EXC) { | ||
320 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
321 | case 0: | ||
322 | break; | ||
323 | case ARM_CP_NOP: | ||
324 | - return; | ||
325 | + goto exit; | ||
326 | case ARM_CP_WFI: | ||
327 | if (isread) { | ||
328 | unallocated_encoding(s); | ||
329 | - return; | ||
330 | + } else { | ||
331 | + gen_update_pc(s, curr_insn_len(s)); | ||
332 | + s->base.is_jmp = DISAS_WFI; | ||
333 | } | ||
334 | - gen_update_pc(s, curr_insn_len(s)); | ||
335 | - s->base.is_jmp = DISAS_WFI; | ||
336 | - return; | ||
337 | + goto exit; | ||
338 | default: | ||
339 | g_assert_not_reached(); | ||
340 | } | ||
341 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
342 | if (ri->type & ARM_CP_CONST) { | ||
343 | tmp64 = tcg_constant_i64(ri->resetvalue); | ||
344 | } else if (ri->readfn) { | ||
345 | + if (!tcg_ri) { | ||
346 | + tcg_ri = gen_lookup_cp_reg(key); | ||
347 | + } | ||
348 | tmp64 = tcg_temp_new_i64(); | ||
349 | - gen_helper_get_cp_reg64(tmp64, cpu_env, | ||
350 | - tcg_constant_ptr(ri)); | ||
351 | + gen_helper_get_cp_reg64(tmp64, cpu_env, tcg_ri); | ||
352 | } else { | ||
353 | tmp64 = tcg_temp_new_i64(); | ||
354 | tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset); | ||
355 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
356 | if (ri->type & ARM_CP_CONST) { | ||
357 | tmp = tcg_constant_i32(ri->resetvalue); | ||
358 | } else if (ri->readfn) { | ||
359 | + if (!tcg_ri) { | ||
360 | + tcg_ri = gen_lookup_cp_reg(key); | ||
361 | + } | ||
362 | tmp = tcg_temp_new_i32(); | ||
363 | - gen_helper_get_cp_reg(tmp, cpu_env, tcg_constant_ptr(ri)); | ||
364 | + gen_helper_get_cp_reg(tmp, cpu_env, tcg_ri); | ||
365 | } else { | ||
366 | tmp = load_cpu_offset(ri->fieldoffset); | ||
367 | } | ||
368 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
369 | /* Write */ | ||
370 | if (ri->type & ARM_CP_CONST) { | ||
371 | /* If not forbidden by access permissions, treat as WI */ | ||
372 | - return; | ||
373 | + goto exit; | ||
374 | } | ||
375 | |||
376 | if (is64) { | ||
377 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
378 | tcg_temp_free_i32(tmplo); | ||
379 | tcg_temp_free_i32(tmphi); | ||
380 | if (ri->writefn) { | ||
381 | - gen_helper_set_cp_reg64(cpu_env, tcg_constant_ptr(ri), tmp64); | ||
382 | + if (!tcg_ri) { | ||
383 | + tcg_ri = gen_lookup_cp_reg(key); | ||
384 | + } | ||
385 | + gen_helper_set_cp_reg64(cpu_env, tcg_ri, tmp64); | ||
386 | } else { | ||
387 | tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset); | ||
388 | } | ||
389 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
390 | } else { | ||
391 | TCGv_i32 tmp = load_reg(s, rt); | ||
392 | if (ri->writefn) { | ||
393 | - gen_helper_set_cp_reg(cpu_env, tcg_constant_ptr(ri), tmp); | ||
394 | + if (!tcg_ri) { | ||
395 | + tcg_ri = gen_lookup_cp_reg(key); | ||
396 | + } | ||
397 | + gen_helper_set_cp_reg(cpu_env, tcg_ri, tmp); | ||
398 | tcg_temp_free_i32(tmp); | ||
399 | } else { | ||
400 | store_cpu_offset(tmp, ri->fieldoffset, 4); | ||
401 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
402 | if (need_exit_tb) { | ||
403 | gen_lookup_tb(s); | ||
404 | } | ||
405 | + | ||
406 | + exit: | ||
407 | + if (tcg_ri) { | ||
408 | + tcg_temp_free_ptr(tcg_ri); | ||
409 | + } | ||
410 | } | ||
411 | |||
412 | /* Decode XScale DSP or iWMMXt insn (in the copro space, cp=0 or 1) */ | ||
413 | -- | ||
414 | 2.34.1 | diff view generated by jsdifflib |