1 | Target-arm queue... | 1 | arm pullreq for rc1. All minor bugfixes, except for the sve-default-vector-length |
---|---|---|---|
2 | patches, which are somewhere between a bugfix and a new feature. | ||
2 | 3 | ||
3 | thanks | 4 | thanks |
4 | -- PMM | 5 | -- PMM |
5 | 6 | ||
6 | The following changes since commit 735286a4f88255e1463d42ce28d8d14181fd32d4: | 7 | The following changes since commit c08ccd1b53f488ac86c1f65cf7623dc91acc249a: |
7 | 8 | ||
8 | Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20170613' into staging (2017-06-13 13:51:29 +0100) | 9 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210726' into staging (2021-07-27 08:35:01 +0100) |
9 | 10 | ||
10 | are available in the git repository at: | 11 | are available in the Git repository at: |
11 | 12 | ||
12 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170613 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210727 |
13 | 14 | ||
14 | for you to fetch changes up to 252a7a6a968c279a4636a86b0559ba3a930a90b5: | 15 | for you to fetch changes up to e229a179a503f2aee43a76888cf12fbdfe8a3749: |
15 | 16 | ||
16 | hw/intc/arm_gicv3_its: Allow save/restore (2017-06-13 14:57:01 +0100) | 17 | hw: aspeed_gpio: Fix memory size (2021-07-27 11:00:00 +0100) |
17 | 18 | ||
18 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
19 | target-arm queue: | 20 | target-arm queue: |
20 | * vITS: Support save/restore | 21 | * hw/arm/smmuv3: Check 31st bit to see if CD is valid |
21 | * timer/aspeed: Fix timer enablement when reload is not set | 22 | * qemu-options.hx: Fix formatting of -machine memory-backend option |
22 | * aspped: add temperature sensor device | 23 | * hw: aspeed_gpio: Fix memory size |
23 | * timer.h: Provide better monotonic time on ARM hosts | 24 | * hw/arm/nseries: Display hexadecimal value with '0x' prefix |
24 | * exynos4210: various cleanups | 25 | * Add sve-default-vector-length cpu property |
25 | * exynos4210: support system poweroff | 26 | * docs: Update path that mentions deprecated.rst |
27 | * hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS | ||
28 | * hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING | ||
29 | * hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | ||
30 | * target/arm: Report M-profile alignment faults correctly to the guest | ||
31 | * target/arm: Add missing 'return's after calling v7m_exception_taken() | ||
32 | * target/arm: Enforce that M-profile SP low 2 bits are always zero | ||
26 | 33 | ||
27 | ---------------------------------------------------------------- | 34 | ---------------------------------------------------------------- |
28 | Cédric Le Goater (3): | 35 | Joe Komlodi (1): |
29 | hw/misc: add a TMP42{1, 2, 3} device model | 36 | hw/arm/smmuv3: Check 31st bit to see if CD is valid |
30 | aspeed: add a temp sensor device on I2C bus 3 | ||
31 | timer/aspeed: fix timer enablement when a reload is not set | ||
32 | 37 | ||
33 | Eric Auger (4): | 38 | Joel Stanley (1): |
34 | kvm-all: Pass an error object to kvm_device_access | 39 | hw: aspeed_gpio: Fix memory size |
35 | hw/intc/arm_gicv3_its: Implement state save/restore | ||
36 | hw/intc/arm_gicv3_kvm: Implement pending table save | ||
37 | hw/intc/arm_gicv3_its: Allow save/restore | ||
38 | 40 | ||
39 | Krzysztof Kozlowski (9): | 41 | Mao Zhongyi (1): |
40 | hw/intc/exynos4210_gic: Use more meaningful name for local variable | 42 | docs: Update path that mentions deprecated.rst |
41 | hw/timer/exynos4210_mct: Fix checkpatch style errors | ||
42 | hw/timer/exynos4210_mct: Cleanup indentation and empty new lines | ||
43 | hw/timer/exynos4210_mct: Remove unused defines | ||
44 | hw/arm/exynos: Move DRAM initialization next boards | ||
45 | hw/arm/exynos: Declare local variables in some order | ||
46 | hw/arm/exynos: Use type define instead of hard-coded a9mpcore_priv string | ||
47 | hw/intc/exynos4210_gic: Constify array of combiner interrupts | ||
48 | hw/misc/exynos4210_pmu: Add support for system poweroff | ||
49 | 43 | ||
50 | Pranith Kumar (1): | 44 | Peter Maydell (7): |
51 | timer.h: Provide better monotonic time | 45 | qemu-options.hx: Fix formatting of -machine memory-backend option |
46 | target/arm: Enforce that M-profile SP low 2 bits are always zero | ||
47 | target/arm: Add missing 'return's after calling v7m_exception_taken() | ||
48 | target/arm: Report M-profile alignment faults correctly to the guest | ||
49 | hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | ||
50 | hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING | ||
51 | hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS | ||
52 | 52 | ||
53 | hw/misc/Makefile.objs | 1 + | 53 | Philippe Mathieu-Daudé (1): |
54 | include/hw/arm/exynos4210.h | 5 +- | 54 | hw/arm/nseries: Display hexadecimal value with '0x' prefix |
55 | include/hw/intc/arm_gicv3_its_common.h | 8 + | ||
56 | include/migration/vmstate.h | 2 + | ||
57 | include/qemu/timer.h | 5 +- | ||
58 | include/sysemu/kvm.h | 11 +- | ||
59 | hw/arm/aspeed.c | 9 + | ||
60 | hw/arm/exynos4210.c | 27 +-- | ||
61 | hw/arm/exynos4_boards.c | 50 +++- | ||
62 | hw/intc/arm_gic_kvm.c | 9 +- | ||
63 | hw/intc/arm_gicv3_common.c | 1 + | ||
64 | hw/intc/arm_gicv3_its_common.c | 12 +- | ||
65 | hw/intc/arm_gicv3_its_kvm.c | 131 +++++++++-- | ||
66 | hw/intc/arm_gicv3_kvm.c | 48 +++- | ||
67 | hw/intc/exynos4210_gic.c | 14 +- | ||
68 | hw/misc/exynos4210_pmu.c | 20 +- | ||
69 | hw/misc/tmp421.c | 402 +++++++++++++++++++++++++++++++++ | ||
70 | hw/timer/aspeed_timer.c | 37 ++- | ||
71 | hw/timer/exynos4210_mct.c | 50 ++-- | ||
72 | kvm-all.c | 14 +- | ||
73 | default-configs/arm-softmmu.mak | 1 + | ||
74 | 21 files changed, 741 insertions(+), 116 deletions(-) | ||
75 | create mode 100644 hw/misc/tmp421.c | ||
76 | 55 | ||
56 | Richard Henderson (3): | ||
57 | target/arm: Correctly bound length in sve_zcr_get_valid_len | ||
58 | target/arm: Export aarch64_sve_zcr_get_valid_len | ||
59 | target/arm: Add sve-default-vector-length cpu property | ||
60 | |||
61 | docs/system/arm/cpu-features.rst | 15 ++++++++++ | ||
62 | configure | 2 +- | ||
63 | hw/arm/smmuv3-internal.h | 2 +- | ||
64 | target/arm/cpu.h | 5 ++++ | ||
65 | target/arm/internals.h | 10 +++++++ | ||
66 | hw/arm/nseries.c | 2 +- | ||
67 | hw/gpio/aspeed_gpio.c | 3 +- | ||
68 | hw/intc/armv7m_nvic.c | 40 +++++++++++++++++++-------- | ||
69 | target/arm/cpu.c | 14 ++++++++-- | ||
70 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++++++++++ | ||
71 | target/arm/gdbstub.c | 4 +++ | ||
72 | target/arm/helper.c | 8 ++++-- | ||
73 | target/arm/m_helper.c | 24 ++++++++++++---- | ||
74 | target/arm/translate.c | 3 ++ | ||
75 | target/i386/cpu.c | 2 +- | ||
76 | MAINTAINERS | 2 +- | ||
77 | qemu-options.hx | 30 +++++++++++--------- | ||
78 | 17 files changed, 183 insertions(+), 43 deletions(-) | ||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | There are to SysBusDevice variables in exynos4210_gic_realize() | ||
4 | function: one for the device itself and second for arm_gic device. Add | ||
5 | a prefix "gic" to the second one so it will be easier to understand the | ||
6 | code. | ||
7 | |||
8 | While at it, put local uninitialized 'i' variable at the end, next to | ||
9 | other uninitialized ones. | ||
10 | |||
11 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/intc/exynos4210_gic.c | 12 ++++++------ | ||
17 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
18 | |||
19 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/intc/exynos4210_gic.c | ||
22 | +++ b/hw/intc/exynos4210_gic.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_init(Object *obj) | ||
24 | DeviceState *dev = DEVICE(obj); | ||
25 | Exynos4210GicState *s = EXYNOS4210_GIC(obj); | ||
26 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
27 | - uint32_t i; | ||
28 | const char cpu_prefix[] = "exynos4210-gic-alias_cpu"; | ||
29 | const char dist_prefix[] = "exynos4210-gic-alias_dist"; | ||
30 | char cpu_alias_name[sizeof(cpu_prefix) + 3]; | ||
31 | char dist_alias_name[sizeof(cpu_prefix) + 3]; | ||
32 | - SysBusDevice *busdev; | ||
33 | + SysBusDevice *gicbusdev; | ||
34 | + uint32_t i; | ||
35 | |||
36 | s->gic = qdev_create(NULL, "arm_gic"); | ||
37 | qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu); | ||
38 | qdev_prop_set_uint32(s->gic, "num-irq", EXYNOS4210_GIC_NIRQ); | ||
39 | qdev_init_nofail(s->gic); | ||
40 | - busdev = SYS_BUS_DEVICE(s->gic); | ||
41 | + gicbusdev = SYS_BUS_DEVICE(s->gic); | ||
42 | |||
43 | /* Pass through outbound IRQ lines from the GIC */ | ||
44 | - sysbus_pass_irq(sbd, busdev); | ||
45 | + sysbus_pass_irq(sbd, gicbusdev); | ||
46 | |||
47 | /* Pass through inbound GPIO lines to the GIC */ | ||
48 | qdev_init_gpio_in(dev, exynos4210_gic_set_irq, | ||
49 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_init(Object *obj) | ||
50 | sprintf(cpu_alias_name, "%s%x", cpu_prefix, i); | ||
51 | memory_region_init_alias(&s->cpu_alias[i], obj, | ||
52 | cpu_alias_name, | ||
53 | - sysbus_mmio_get_region(busdev, 1), | ||
54 | + sysbus_mmio_get_region(gicbusdev, 1), | ||
55 | 0, | ||
56 | EXYNOS4210_GIC_CPU_REGION_SIZE); | ||
57 | memory_region_add_subregion(&s->cpu_container, | ||
58 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_init(Object *obj) | ||
59 | sprintf(dist_alias_name, "%s%x", dist_prefix, i); | ||
60 | memory_region_init_alias(&s->dist_alias[i], obj, | ||
61 | dist_alias_name, | ||
62 | - sysbus_mmio_get_region(busdev, 0), | ||
63 | + sysbus_mmio_get_region(gicbusdev, 0), | ||
64 | 0, | ||
65 | EXYNOS4210_GIC_DIST_REGION_SIZE); | ||
66 | memory_region_add_subregion(&s->dist_container, | ||
67 | -- | ||
68 | 2.7.4 | ||
69 | |||
70 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | Fix checkpatch errors: | ||
4 | 1. ERROR: spaces required around that '+' (ctx:VxV) | ||
5 | 2. ERROR: spaces required around that '&' (ctx:VxV) | ||
6 | |||
7 | No functional changes. | ||
8 | |||
9 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/timer/exynos4210_mct.c | 4 ++-- | ||
15 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/timer/exynos4210_mct.c | ||
20 | +++ b/hw/timer/exynos4210_mct.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s) | ||
22 | { | ||
23 | uint32_t freq = s->freq; | ||
24 | s->freq = 24000000 / | ||
25 | - ((MCT_CFG_GET_PRESCALER(s->reg_mct_cfg)+1) * | ||
26 | + ((MCT_CFG_GET_PRESCALER(s->reg_mct_cfg) + 1) * | ||
27 | MCT_CFG_GET_DIVIDER(s->reg_mct_cfg)); | ||
28 | |||
29 | if (freq != s->freq) { | ||
30 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
31 | |||
32 | DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift); | ||
33 | |||
34 | - if (offset&0x4) { | ||
35 | + if (offset & 0x4) { | ||
36 | s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index); | ||
37 | } else { | ||
38 | s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index); | ||
39 | -- | ||
40 | 2.7.4 | ||
41 | |||
42 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Joe Komlodi <joe.komlodi@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Remove defines not used anywhere. | 3 | The bit to see if a CD is valid is the last bit of the first word of the CD. |
4 | 4 | ||
5 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 5 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> |
6 | Message-id: 1626728232-134665-2-git-send-email-joe.komlodi@xilinx.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 9 | --- |
9 | hw/timer/exynos4210_mct.c | 3 --- | 10 | hw/arm/smmuv3-internal.h | 2 +- |
10 | 1 file changed, 3 deletions(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | 12 | ||
12 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | 13 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/timer/exynos4210_mct.c | 15 | --- a/hw/arm/smmuv3-internal.h |
15 | +++ b/hw/timer/exynos4210_mct.c | 16 | +++ b/hw/arm/smmuv3-internal.h |
16 | @@ -XXX,XX +XXX,XX @@ enum LocalTimerRegCntIndexes { | 17 | @@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste) |
17 | L_REG_CNT_AMOUNT | 18 | |
18 | }; | 19 | /* CD fields */ |
19 | 20 | ||
20 | -#define MCT_NIRQ 6 | 21 | -#define CD_VALID(x) extract32((x)->word[0], 30, 1) |
21 | #define MCT_SFR_SIZE 0x444 | 22 | +#define CD_VALID(x) extract32((x)->word[0], 31, 1) |
22 | 23 | #define CD_ASID(x) extract32((x)->word[1], 16, 16) | |
23 | #define MCT_GT_CMP_NUM 4 | 24 | #define CD_TTB(x, sel) \ |
24 | 25 | ({ \ | |
25 | -#define MCT_GT_MAX_VAL UINT64_MAX | ||
26 | - | ||
27 | #define MCT_GT_COUNTER_STEP 0x100000000ULL | ||
28 | #define MCT_LT_COUNTER_STEP 0x100000000ULL | ||
29 | #define MCT_LT_CNT_LOW_LIMIT 0x100 | ||
30 | -- | 26 | -- |
31 | 2.7.4 | 27 | 2.20.1 |
32 | 28 | ||
33 | 29 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | The documentation of the -machine memory-backend has some minor |
---|---|---|---|
2 | formatting errors: | ||
3 | * Misindentation of the initial line meant that the whole option | ||
4 | section is incorrectly indented in the HTML output compared to | ||
5 | the other -machine options | ||
6 | * The examples weren't indented, which meant that they were formatted | ||
7 | as plain run-on text including outputting the "::" as text. | ||
8 | * The a) b) list has no rst-format markup so it is rendered as | ||
9 | a single run-on paragraph | ||
2 | 10 | ||
3 | We change the restoration priority of both the GICv3 and ITS. The | 11 | Fix the formatting. |
4 | GICv3 must be restored before the ITS and the ITS needs to be restored | ||
5 | before PCIe devices since it translates their MSI transactions. | ||
6 | 12 | ||
7 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Reviewed-by: Juan Quintela <quintela@redhat.com> | ||
9 | Message-id: 1497023553-18411-5-git-send-email-eric.auger@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Message-id: 20210719105257.3599-1-peter.maydell@linaro.org | ||
11 | --- | 16 | --- |
12 | include/migration/vmstate.h | 2 ++ | 17 | qemu-options.hx | 30 +++++++++++++++++------------- |
13 | hw/intc/arm_gicv3_common.c | 1 + | 18 | 1 file changed, 17 insertions(+), 13 deletions(-) |
14 | hw/intc/arm_gicv3_its_common.c | 2 +- | ||
15 | hw/intc/arm_gicv3_its_kvm.c | 24 ++++++++++++------------ | ||
16 | 4 files changed, 16 insertions(+), 13 deletions(-) | ||
17 | 19 | ||
18 | diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h | 20 | diff --git a/qemu-options.hx b/qemu-options.hx |
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/migration/vmstate.h | 22 | --- a/qemu-options.hx |
21 | +++ b/include/migration/vmstate.h | 23 | +++ b/qemu-options.hx |
22 | @@ -XXX,XX +XXX,XX @@ enum VMStateFlags { | 24 | @@ -XXX,XX +XXX,XX @@ SRST |
23 | typedef enum { | 25 | Enables or disables ACPI Heterogeneous Memory Attribute Table |
24 | MIG_PRI_DEFAULT = 0, | 26 | (HMAT) support. The default is off. |
25 | MIG_PRI_IOMMU, /* Must happen before PCI devices */ | 27 | |
26 | + MIG_PRI_GICV3_ITS, /* Must happen before PCI devices */ | 28 | - ``memory-backend='id'`` |
27 | + MIG_PRI_GICV3, /* Must happen before the ITS */ | 29 | + ``memory-backend='id'`` |
28 | MIG_PRI_MAX, | 30 | An alternative to legacy ``-mem-path`` and ``mem-prealloc`` options. |
29 | } MigrationPriority; | 31 | Allows to use a memory backend as main RAM. |
30 | 32 | ||
31 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | 33 | For example: |
32 | index XXXXXXX..XXXXXXX 100644 | 34 | :: |
33 | --- a/hw/intc/arm_gicv3_common.c | 35 | - -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on |
34 | +++ b/hw/intc/arm_gicv3_common.c | 36 | - -machine memory-backend=pc.ram |
35 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3 = { | 37 | - -m 512M |
36 | .minimum_version_id = 1, | ||
37 | .pre_save = gicv3_pre_save, | ||
38 | .post_load = gicv3_post_load, | ||
39 | + .priority = MIG_PRI_GICV3, | ||
40 | .fields = (VMStateField[]) { | ||
41 | VMSTATE_UINT32(gicd_ctlr, GICv3State), | ||
42 | VMSTATE_UINT32_ARRAY(gicd_statusr, GICv3State, 2), | ||
43 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/intc/arm_gicv3_its_common.c | ||
46 | +++ b/hw/intc/arm_gicv3_its_common.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_its = { | ||
48 | .name = "arm_gicv3_its", | ||
49 | .pre_save = gicv3_its_pre_save, | ||
50 | .post_load = gicv3_its_post_load, | ||
51 | - .unmigratable = true, | ||
52 | + .priority = MIG_PRI_GICV3_ITS, | ||
53 | .fields = (VMStateField[]) { | ||
54 | VMSTATE_UINT32(ctlr, GICv3ITSState), | ||
55 | VMSTATE_UINT32(iidr, GICv3ITSState), | ||
56 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/intc/arm_gicv3_its_kvm.c | ||
59 | +++ b/hw/intc/arm_gicv3_its_kvm.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
61 | GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | ||
62 | Error *local_err = NULL; | ||
63 | |||
64 | - /* | ||
65 | - * Block migration of a KVM GICv3 ITS device: the API for saving and | ||
66 | - * restoring the state in the kernel is not yet available | ||
67 | - */ | ||
68 | - error_setg(&s->migration_blocker, "vITS migration is not implemented"); | ||
69 | - migrate_add_blocker(s->migration_blocker, &local_err); | ||
70 | - if (local_err) { | ||
71 | - error_propagate(errp, local_err); | ||
72 | - error_free(s->migration_blocker); | ||
73 | - return; | ||
74 | - } | ||
75 | - | ||
76 | s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_ITS, false); | ||
77 | if (s->dev_fd < 0) { | ||
78 | error_setg_errno(errp, -s->dev_fd, "error creating in-kernel ITS"); | ||
79 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
80 | |||
81 | gicv3_its_init_mmio(s, NULL); | ||
82 | |||
83 | + if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
84 | + GITS_CTLR)) { | ||
85 | + error_setg(&s->migration_blocker, "This operating system kernel " | ||
86 | + "does not support vITS migration"); | ||
87 | + migrate_add_blocker(s->migration_blocker, &local_err); | ||
88 | + if (local_err) { | ||
89 | + error_propagate(errp, local_err); | ||
90 | + error_free(s->migration_blocker); | ||
91 | + return; | ||
92 | + } | ||
93 | + } | ||
94 | + | 38 | + |
95 | kvm_msi_use_devid = true; | 39 | + -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on |
96 | kvm_gsi_direct_mapping = false; | 40 | + -machine memory-backend=pc.ram |
97 | kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled(); | 41 | + -m 512M |
42 | |||
43 | Migration compatibility note: | ||
44 | - a) as backend id one shall use value of 'default-ram-id', advertised by | ||
45 | - machine type (available via ``query-machines`` QMP command), if migration | ||
46 | - to/from old QEMU (<5.0) is expected. | ||
47 | - b) for machine types 4.0 and older, user shall | ||
48 | - use ``x-use-canonical-path-for-ramblock-id=off`` backend option | ||
49 | - if migration to/from old QEMU (<5.0) is expected. | ||
50 | + | ||
51 | + * as backend id one shall use value of 'default-ram-id', advertised by | ||
52 | + machine type (available via ``query-machines`` QMP command), if migration | ||
53 | + to/from old QEMU (<5.0) is expected. | ||
54 | + * for machine types 4.0 and older, user shall | ||
55 | + use ``x-use-canonical-path-for-ramblock-id=off`` backend option | ||
56 | + if migration to/from old QEMU (<5.0) is expected. | ||
57 | + | ||
58 | For example: | ||
59 | :: | ||
60 | - -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off | ||
61 | - -machine memory-backend=pc.ram | ||
62 | - -m 512M | ||
63 | + | ||
64 | + -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off | ||
65 | + -machine memory-backend=pc.ram | ||
66 | + -m 512M | ||
67 | ERST | ||
68 | |||
69 | HXCOMM Deprecated by -machine | ||
98 | -- | 70 | -- |
99 | 2.7.4 | 71 | 2.20.1 |
100 | 72 | ||
101 | 73 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | For M-profile, unlike A-profile, the low 2 bits of SP are defined to be |
---|---|---|---|
2 | RES0H, which is to say that they must be hardwired to zero so that | ||
3 | guest attempts to write non-zero values to them are ignored. | ||
2 | 4 | ||
3 | When a timer is enabled before a reload value is set, the controller | 5 | Implement this behaviour by masking out the low bits: |
4 | waits for a reload value to be set before starting decrementing. This | 6 | * for writes to r13 by the gdbstub |
5 | fix tries to cover that case by changing the timer expiry only when | 7 | * for writes to any of the various flavours of SP via MSR |
6 | a reload value is valid. | 8 | * for writes to r13 via store_reg() in generated code |
7 | 9 | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 10 | Note that all the direct uses of cpu_R[] in translate.c are in places |
9 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | 11 | where the register is definitely not r13 (usually because that has |
10 | Message-id: 1496739312-32304-1-git-send-email-clg@kaod.org | 12 | been checked for as an UNDEFINED or UNPREDICTABLE case and handled as |
13 | UNDEF). | ||
14 | |||
15 | All the other writes to regs[13] in C code are either: | ||
16 | * A-profile only code | ||
17 | * writes of values we can guarantee to be aligned, such as | ||
18 | - writes of previous-SP-value plus or minus a 4-aligned constant | ||
19 | - writes of the value in an SP limit register (which we already | ||
20 | enforce to be aligned) | ||
21 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20210723162146.5167-2-peter.maydell@linaro.org | ||
12 | --- | 25 | --- |
13 | hw/timer/aspeed_timer.c | 37 +++++++++++++++++++++++++++++-------- | 26 | target/arm/gdbstub.c | 4 ++++ |
14 | 1 file changed, 29 insertions(+), 8 deletions(-) | 27 | target/arm/m_helper.c | 14 ++++++++------ |
28 | target/arm/translate.c | 3 +++ | ||
29 | 3 files changed, 15 insertions(+), 6 deletions(-) | ||
15 | 30 | ||
16 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | 31 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
17 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/timer/aspeed_timer.c | 33 | --- a/target/arm/gdbstub.c |
19 | +++ b/hw/timer/aspeed_timer.c | 34 | +++ b/target/arm/gdbstub.c |
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) | 35 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) |
21 | next = seq[1]; | 36 | |
22 | } else if (now < seq[2]) { | 37 | if (n < 16) { |
23 | next = seq[2]; | 38 | /* Core integer register. */ |
24 | - } else { | 39 | + if (n == 13 && arm_feature(env, ARM_FEATURE_M)) { |
25 | + } else if (t->reload) { | 40 | + /* M profile SP low bits are always 0 */ |
26 | reload_ns = muldiv64(t->reload, NANOSECONDS_PER_SECOND, rate); | 41 | + tmp &= ~3; |
27 | t->start = now - ((now - t->start) % reload_ns); | 42 | + } |
28 | + } else { | 43 | env->regs[n] = tmp; |
29 | + /* no reload value, return 0 */ | 44 | return 4; |
30 | + break; | ||
31 | } | ||
32 | } | 45 | } |
33 | 46 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | |
34 | return next; | 47 | index XXXXXXX..XXXXXXX 100644 |
35 | } | 48 | --- a/target/arm/m_helper.c |
36 | 49 | +++ b/target/arm/m_helper.c | |
37 | +static void aspeed_timer_mod(AspeedTimer *t) | 50 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) |
38 | +{ | 51 | if (!env->v7m.secure) { |
39 | + uint64_t next = calculate_next(t); | 52 | return; |
40 | + if (next) { | 53 | } |
41 | + timer_mod(&t->timer, next); | 54 | - env->v7m.other_ss_msp = val; |
42 | + } | 55 | + env->v7m.other_ss_msp = val & ~3; |
43 | +} | 56 | return; |
57 | case 0x89: /* PSP_NS */ | ||
58 | if (!env->v7m.secure) { | ||
59 | return; | ||
60 | } | ||
61 | - env->v7m.other_ss_psp = val; | ||
62 | + env->v7m.other_ss_psp = val & ~3; | ||
63 | return; | ||
64 | case 0x8a: /* MSPLIM_NS */ | ||
65 | if (!env->v7m.secure) { | ||
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
67 | |||
68 | limit = is_psp ? env->v7m.psplim[false] : env->v7m.msplim[false]; | ||
69 | |||
70 | + val &= ~0x3; | ||
44 | + | 71 | + |
45 | static void aspeed_timer_expire(void *opaque) | 72 | if (val < limit) { |
46 | { | 73 | raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); |
47 | AspeedTimer *t = opaque; | 74 | } |
48 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_expire(void *opaque) | 75 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) |
49 | qemu_set_irq(t->irq, t->level); | 76 | break; |
50 | } | 77 | case 8: /* MSP */ |
51 | 78 | if (v7m_using_psp(env)) { | |
52 | - timer_mod(&t->timer, calculate_next(t)); | 79 | - env->v7m.other_sp = val; |
53 | + aspeed_timer_mod(t); | 80 | + env->v7m.other_sp = val & ~3; |
54 | } | 81 | } else { |
55 | 82 | - env->regs[13] = val; | |
56 | static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg) | 83 | + env->regs[13] = val & ~3; |
57 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, | ||
58 | uint32_t value) | ||
59 | { | ||
60 | AspeedTimer *t; | ||
61 | + uint32_t old_reload; | ||
62 | |||
63 | trace_aspeed_timer_set_value(timer, reg, value); | ||
64 | t = &s->timers[timer]; | ||
65 | switch (reg) { | ||
66 | + case TIMER_REG_RELOAD: | ||
67 | + old_reload = t->reload; | ||
68 | + t->reload = value; | ||
69 | + | ||
70 | + /* If the reload value was not previously set, or zero, and | ||
71 | + * the current value is valid, try to start the timer if it is | ||
72 | + * enabled. | ||
73 | + */ | ||
74 | + if (old_reload || !t->reload) { | ||
75 | + break; | ||
76 | + } | ||
77 | + | ||
78 | case TIMER_REG_STATUS: | ||
79 | if (timer_enabled(t)) { | ||
80 | uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, | ||
82 | uint32_t rate = calculate_rate(t); | ||
83 | |||
84 | t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); | ||
85 | - timer_mod(&t->timer, calculate_next(t)); | ||
86 | + aspeed_timer_mod(t); | ||
87 | } | 84 | } |
88 | break; | 85 | break; |
89 | - case TIMER_REG_RELOAD: | 86 | case 9: /* PSP */ |
90 | - t->reload = value; | 87 | if (v7m_using_psp(env)) { |
91 | - break; | 88 | - env->regs[13] = val; |
92 | case TIMER_REG_MATCH_FIRST: | 89 | + env->regs[13] = val & ~3; |
93 | case TIMER_REG_MATCH_SECOND: | 90 | } else { |
94 | t->match[reg - 2] = value; | 91 | - env->v7m.other_sp = val; |
95 | if (timer_enabled(t)) { | 92 | + env->v7m.other_sp = val & ~3; |
96 | - timer_mod(&t->timer, calculate_next(t)); | ||
97 | + aspeed_timer_mod(t); | ||
98 | } | 93 | } |
99 | break; | 94 | break; |
100 | default: | 95 | case 10: /* MSPLIM */ |
101 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_ctrl_enable(AspeedTimer *t, bool enable) | 96 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
102 | trace_aspeed_timer_ctrl_enable(t->id, enable); | 97 | index XXXXXXX..XXXXXXX 100644 |
103 | if (enable) { | 98 | --- a/target/arm/translate.c |
104 | t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 99 | +++ b/target/arm/translate.c |
105 | - timer_mod(&t->timer, calculate_next(t)); | 100 | @@ -XXX,XX +XXX,XX @@ void store_reg(DisasContext *s, int reg, TCGv_i32 var) |
106 | + aspeed_timer_mod(t); | 101 | */ |
107 | } else { | 102 | tcg_gen_andi_i32(var, var, s->thumb ? ~1 : ~3); |
108 | timer_del(&t->timer); | 103 | s->base.is_jmp = DISAS_JUMP; |
104 | + } else if (reg == 13 && arm_dc_feature(s, ARM_FEATURE_M)) { | ||
105 | + /* For M-profile SP bits [1:0] are always zero */ | ||
106 | + tcg_gen_andi_i32(var, var, ~3); | ||
109 | } | 107 | } |
108 | tcg_gen_mov_i32(cpu_R[reg], var); | ||
109 | tcg_temp_free_i32(var); | ||
110 | -- | 110 | -- |
111 | 2.7.4 | 111 | 2.20.1 |
112 | 112 | ||
113 | 113 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | In do_v7m_exception_exit(), we perform various checks as part of |
---|---|---|---|
2 | performing the exception return. If one of these checks fails, the | ||
3 | architecture requires that we take an appropriate exception on the | ||
4 | existing stackframe. We implement this by calling | ||
5 | v7m_exception_taken() to set up to take the new exception, and then | ||
6 | immediately returning from do_v7m_exception_exit() without proceeding | ||
7 | any further with the unstack-and-exception-return process. | ||
2 | 8 | ||
3 | In some circumstances, we don't want to abort if the | 9 | In a couple of checks that are new in v8.1M, we forgot the "return" |
4 | kvm_device_access fails. This will be the case during ITS | 10 | statement, with the effect that if bad code in the guest tripped over |
5 | migration, in case the ITS table save/restore fails because | 11 | these checks we would set up to take a UsageFault exception but then |
6 | the guest did not program the vITS correctly. So let's pass an | 12 | blunder on trying to also unstack and return from the original |
7 | error object to the function and return the ioctl value. New | 13 | exception, with the probable result that the guest would crash. |
8 | callers will be able to make a decision upon this returned | ||
9 | value. | ||
10 | 14 | ||
11 | Existing callers pass &error_abort which will cause the | 15 | Add the missing return statements. |
12 | function to abort on failure. | ||
13 | 16 | ||
14 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
15 | Reviewed-by: Juan Quintela <quintela@redhat.com> | ||
16 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
17 | Message-id: 1497023553-18411-2-git-send-email-eric.auger@redhat.com | ||
18 | [PMM: wrapped long line] | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20210723162146.5167-3-peter.maydell@linaro.org | ||
20 | --- | 20 | --- |
21 | include/sysemu/kvm.h | 11 +++++++---- | 21 | target/arm/m_helper.c | 2 ++ |
22 | hw/intc/arm_gic_kvm.c | 9 +++++---- | 22 | 1 file changed, 2 insertions(+) |
23 | hw/intc/arm_gicv3_its_kvm.c | 2 +- | ||
24 | hw/intc/arm_gicv3_kvm.c | 14 +++++++------- | ||
25 | kvm-all.c | 14 ++++++++------ | ||
26 | 5 files changed, 28 insertions(+), 22 deletions(-) | ||
27 | 23 | ||
28 | diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h | 24 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
29 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/include/sysemu/kvm.h | 26 | --- a/target/arm/m_helper.c |
31 | +++ b/include/sysemu/kvm.h | 27 | +++ b/target/arm/m_helper.c |
32 | @@ -XXX,XX +XXX,XX @@ int kvm_device_check_attr(int fd, uint32_t group, uint64_t attr); | 28 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
33 | * @attr: the attribute of that group to set or get | 29 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
34 | * @val: pointer to a storage area for the value | 30 | "stackframe: NSACR prevents clearing FPU registers\n"); |
35 | * @write: true for set and false for get operation | 31 | v7m_exception_taken(cpu, excret, true, false); |
36 | + * @errp: error object handle | 32 | + return; |
37 | * | 33 | } else if (!cpacr_pass) { |
38 | - * This function is not allowed to fail. Use kvm_device_check_attr() | 34 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, |
39 | - * in order to check for the availability of optional attributes. | 35 | exc_secure); |
40 | + * Returns: 0 on success | 36 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
41 | + * < 0 on error | 37 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
42 | + * Use kvm_device_check_attr() in order to check for the availability | 38 | "stackframe: CPACR prevents clearing FPU registers\n"); |
43 | + * of optional attributes. | 39 | v7m_exception_taken(cpu, excret, true, false); |
44 | */ | 40 | + return; |
45 | -void kvm_device_access(int fd, int group, uint64_t attr, | 41 | } |
46 | - void *val, bool write); | 42 | } |
47 | +int kvm_device_access(int fd, int group, uint64_t attr, | 43 | /* Clear s0..s15, FPSCR and VPR */ |
48 | + void *val, bool write, Error **errp); | ||
49 | |||
50 | /** | ||
51 | * kvm_create_device - create a KVM device for the device control API | ||
52 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/hw/intc/arm_gic_kvm.c | ||
55 | +++ b/hw/intc/arm_gic_kvm.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void kvm_gicd_access(GICState *s, int offset, int cpu, | ||
57 | uint32_t *val, bool write) | ||
58 | { | ||
59 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS, | ||
60 | - KVM_VGIC_ATTR(offset, cpu), val, write); | ||
61 | + KVM_VGIC_ATTR(offset, cpu), val, write, &error_abort); | ||
62 | } | ||
63 | |||
64 | static void kvm_gicc_access(GICState *s, int offset, int cpu, | ||
65 | uint32_t *val, bool write) | ||
66 | { | ||
67 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_REGS, | ||
68 | - KVM_VGIC_ATTR(offset, cpu), val, write); | ||
69 | + KVM_VGIC_ATTR(offset, cpu), val, write, &error_abort); | ||
70 | } | ||
71 | |||
72 | #define for_each_irq_reg(_ctr, _max_irq, _field_width) \ | ||
73 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) | ||
74 | if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0)) { | ||
75 | uint32_t numirqs = s->num_irq; | ||
76 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0, | ||
77 | - &numirqs, true); | ||
78 | + &numirqs, true, &error_abort); | ||
79 | } | ||
80 | /* Tell the kernel to complete VGIC initialization now */ | ||
81 | if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
82 | KVM_DEV_ARM_VGIC_CTRL_INIT)) { | ||
83 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
84 | - KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); | ||
85 | + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, | ||
86 | + &error_abort); | ||
87 | } | ||
88 | } else if (ret != -ENODEV && ret != -ENOTSUP) { | ||
89 | error_setg_errno(errp, -ret, "error creating in-kernel VGIC"); | ||
90 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/hw/intc/arm_gicv3_its_kvm.c | ||
93 | +++ b/hw/intc/arm_gicv3_its_kvm.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
95 | |||
96 | /* explicit init of the ITS */ | ||
97 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
98 | - KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); | ||
99 | + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, &error_abort); | ||
100 | |||
101 | /* register the base address */ | ||
102 | kvm_arm_register_device(&s->iomem_its_cntrl, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, | ||
103 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/hw/intc/arm_gicv3_kvm.c | ||
106 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gicd_access(GICv3State *s, int offset, | ||
108 | { | ||
109 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS, | ||
110 | KVM_VGIC_ATTR(offset, 0), | ||
111 | - val, write); | ||
112 | + val, write, &error_abort); | ||
113 | } | ||
114 | |||
115 | static inline void kvm_gicr_access(GICv3State *s, int offset, int cpu, | ||
116 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gicr_access(GICv3State *s, int offset, int cpu, | ||
117 | { | ||
118 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_REDIST_REGS, | ||
119 | KVM_VGIC_ATTR(offset, s->cpu[cpu].gicr_typer), | ||
120 | - val, write); | ||
121 | + val, write, &error_abort); | ||
122 | } | ||
123 | |||
124 | static inline void kvm_gicc_access(GICv3State *s, uint64_t reg, int cpu, | ||
125 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gicc_access(GICv3State *s, uint64_t reg, int cpu, | ||
126 | { | ||
127 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS, | ||
128 | KVM_VGIC_ATTR(reg, s->cpu[cpu].gicr_typer), | ||
129 | - val, write); | ||
130 | + val, write, &error_abort); | ||
131 | } | ||
132 | |||
133 | static inline void kvm_gic_line_level_access(GICv3State *s, int irq, int cpu, | ||
134 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gic_line_level_access(GICv3State *s, int irq, int cpu, | ||
135 | KVM_VGIC_ATTR(irq, s->cpu[cpu].gicr_typer) | | ||
136 | (VGIC_LEVEL_INFO_LINE_LEVEL << | ||
137 | KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT), | ||
138 | - val, write); | ||
139 | + val, write, &error_abort); | ||
140 | } | ||
141 | |||
142 | /* Loop through each distributor IRQ related register; since bits | ||
143 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) | ||
144 | /* Initialize to actual HW supported configuration */ | ||
145 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS, | ||
146 | KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity), | ||
147 | - &c->icc_ctlr_el1[GICV3_NS], false); | ||
148 | + &c->icc_ctlr_el1[GICV3_NS], false, &error_abort); | ||
149 | |||
150 | c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS]; | ||
151 | } | ||
152 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
153 | } | ||
154 | |||
155 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, | ||
156 | - 0, &s->num_irq, true); | ||
157 | + 0, &s->num_irq, true, &error_abort); | ||
158 | |||
159 | /* Tell the kernel to complete VGIC initialization now */ | ||
160 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
161 | - KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); | ||
162 | + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, &error_abort); | ||
163 | |||
164 | kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, | ||
165 | KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd); | ||
166 | diff --git a/kvm-all.c b/kvm-all.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/kvm-all.c | ||
169 | +++ b/kvm-all.c | ||
170 | @@ -XXX,XX +XXX,XX @@ | ||
171 | #include "qemu/option.h" | ||
172 | #include "qemu/config-file.h" | ||
173 | #include "qemu/error-report.h" | ||
174 | +#include "qapi/error.h" | ||
175 | #include "hw/hw.h" | ||
176 | #include "hw/pci/msi.h" | ||
177 | #include "hw/pci/msix.h" | ||
178 | @@ -XXX,XX +XXX,XX @@ int kvm_device_check_attr(int dev_fd, uint32_t group, uint64_t attr) | ||
179 | return kvm_device_ioctl(dev_fd, KVM_HAS_DEVICE_ATTR, &attribute) ? 0 : 1; | ||
180 | } | ||
181 | |||
182 | -void kvm_device_access(int fd, int group, uint64_t attr, | ||
183 | - void *val, bool write) | ||
184 | +int kvm_device_access(int fd, int group, uint64_t attr, | ||
185 | + void *val, bool write, Error **errp) | ||
186 | { | ||
187 | struct kvm_device_attr kvmattr; | ||
188 | int err; | ||
189 | @@ -XXX,XX +XXX,XX @@ void kvm_device_access(int fd, int group, uint64_t attr, | ||
190 | write ? KVM_SET_DEVICE_ATTR : KVM_GET_DEVICE_ATTR, | ||
191 | &kvmattr); | ||
192 | if (err < 0) { | ||
193 | - error_report("KVM_%s_DEVICE_ATTR failed: %s", | ||
194 | - write ? "SET" : "GET", strerror(-err)); | ||
195 | - error_printf("Group %d attr 0x%016" PRIx64 "\n", group, attr); | ||
196 | - abort(); | ||
197 | + error_setg_errno(errp, -err, | ||
198 | + "KVM_%s_DEVICE_ATTR failed: Group %d " | ||
199 | + "attr 0x%016" PRIx64, | ||
200 | + write ? "SET" : "GET", group, attr); | ||
201 | } | ||
202 | + return err; | ||
203 | } | ||
204 | |||
205 | /* Return 1 on success, 0 on failure */ | ||
206 | -- | 44 | -- |
207 | 2.7.4 | 45 | 2.20.1 |
208 | 46 | ||
209 | 47 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | For M-profile, we weren't reporting alignment faults triggered by the |
---|---|---|---|
2 | generic TCG code correctly to the guest. These get passed into | ||
3 | arm_v7m_cpu_do_interrupt() as an EXCP_DATA_ABORT with an A-profile | ||
4 | style exception.fsr value of 1. We didn't check for this, and so | ||
5 | they fell through into the default of "assume this is an MPU fault" | ||
6 | and were reported to the guest as a data access violation MPU fault. | ||
2 | 7 | ||
3 | Temperatures can be changed from the monitor with : | 8 | Report these alignment faults as UsageFaults which set the UNALIGNED |
9 | bit in the UFSR. | ||
4 | 10 | ||
5 | (qemu) qom-set /machine/unattached/device[2] temperature0 12000 | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210723162146.5167-4-peter.maydell@linaro.org | ||
14 | --- | ||
15 | target/arm/m_helper.c | 8 ++++++++ | ||
16 | 1 file changed, 8 insertions(+) | ||
6 | 17 | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 18 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
8 | Message-id: 1496739230-32109-3-git-send-email-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/aspeed.c | 9 +++++++++ | ||
13 | 1 file changed, 9 insertions(+) | ||
14 | |||
15 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/aspeed.c | 20 | --- a/target/arm/m_helper.c |
18 | +++ b/hw/arm/aspeed.c | 21 | +++ b/target/arm/m_helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 22 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
20 | static void palmetto_bmc_i2c_init(AspeedBoardState *bmc) | 23 | env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; |
21 | { | 24 | break; |
22 | AspeedSoCState *soc = &bmc->soc; | 25 | case EXCP_UNALIGNED: |
23 | + DeviceState *dev; | 26 | + /* Unaligned faults reported by M-profile aware code */ |
24 | 27 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | |
25 | /* The palmetto platform expects a ds3231 RTC but a ds1338 is | 28 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
26 | * enough to provide basic RTC features. Alarms will be missing */ | 29 | break; |
27 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68); | 30 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
28 | + | 31 | } |
29 | + /* add a TMP423 temperature sensor */ | 32 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); |
30 | + dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), | 33 | break; |
31 | + "tmp423", 0x4c); | 34 | + case 0x1: /* Alignment fault reported by generic code */ |
32 | + object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abort); | 35 | + qemu_log_mask(CPU_LOG_INT, |
33 | + object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abort); | 36 | + "...really UsageFault with UFSR.UNALIGNED\n"); |
34 | + object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abort); | 37 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
35 | + object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort); | 38 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, |
36 | } | 39 | + env->v7m.secure); |
37 | 40 | + break; | |
38 | static void palmetto_bmc_init(MachineState *machine) | 41 | default: |
42 | /* | ||
43 | * All other FSR values are either MPU faults or "can't happen | ||
39 | -- | 44 | -- |
40 | 2.7.4 | 45 | 2.20.1 |
41 | 46 | ||
42 | 47 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The ISCR.ISRPENDING bit is set when an external interrupt is pending. |
---|---|---|---|
2 | This is true whether that external interrupt is enabled or not. | ||
3 | This means that we can't use 's->vectpending == 0' as a shortcut to | ||
4 | "ISRPENDING is zero", because s->vectpending indicates only the | ||
5 | highest priority pending enabled interrupt. | ||
2 | 6 | ||
3 | Largely inspired by the TMP105 temperature sensor, here is a model for | 7 | Remove the incorrect optimization so that if there is no pending |
4 | the TMP42{1,2,3} temperature sensors. | 8 | enabled interrupt we fall through to scanning through the whole |
9 | interrupt array. | ||
5 | 10 | ||
6 | Specs can be found here : | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210723162146.5167-5-peter.maydell@linaro.org | ||
14 | --- | ||
15 | hw/intc/armv7m_nvic.c | 9 ++++----- | ||
16 | 1 file changed, 4 insertions(+), 5 deletions(-) | ||
7 | 17 | ||
8 | http://www.ti.com/lit/gpn/tmp421 | 18 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
9 | |||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Message-id: 1496739230-32109-2-git-send-email-clg@kaod.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/misc/Makefile.objs | 1 + | ||
16 | hw/misc/tmp421.c | 402 ++++++++++++++++++++++++++++++++++++++++ | ||
17 | default-configs/arm-softmmu.mak | 1 + | ||
18 | 3 files changed, 404 insertions(+) | ||
19 | create mode 100644 hw/misc/tmp421.c | ||
20 | |||
21 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | ||
22 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/misc/Makefile.objs | 20 | --- a/hw/intc/armv7m_nvic.c |
24 | +++ b/hw/misc/Makefile.objs | 21 | +++ b/hw/intc/armv7m_nvic.c |
25 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s) |
26 | common-obj-$(CONFIG_APPLESMC) += applesmc.o | 23 | { |
27 | common-obj-$(CONFIG_MAX111X) += max111x.o | 24 | int irq; |
28 | common-obj-$(CONFIG_TMP105) += tmp105.o | 25 | |
29 | +common-obj-$(CONFIG_TMP421) += tmp421.o | 26 | - /* We can shortcut if the highest priority pending interrupt |
30 | common-obj-$(CONFIG_ISA_DEBUG) += debugexit.o | 27 | - * happens to be external or if there is nothing pending. |
31 | common-obj-$(CONFIG_SGA) += sga.o | 28 | + /* |
32 | common-obj-$(CONFIG_ISA_TESTDEV) += pc-testdev.o | 29 | + * We can shortcut if the highest priority pending interrupt |
33 | diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c | 30 | + * happens to be external; if not we need to check the whole |
34 | new file mode 100644 | 31 | + * vectors[] array. |
35 | index XXXXXXX..XXXXXXX | 32 | */ |
36 | --- /dev/null | 33 | if (s->vectpending > NVIC_FIRST_IRQ) { |
37 | +++ b/hw/misc/tmp421.c | 34 | return true; |
38 | @@ -XXX,XX +XXX,XX @@ | 35 | } |
39 | +/* | 36 | - if (s->vectpending == 0) { |
40 | + * Texas Instruments TMP421 temperature sensor. | 37 | - return false; |
41 | + * | 38 | - } |
42 | + * Copyright (c) 2016 IBM Corporation. | 39 | |
43 | + * | 40 | for (irq = NVIC_FIRST_IRQ; irq < s->num_irq; irq++) { |
44 | + * Largely inspired by : | 41 | if (s->vectors[irq].pending) { |
45 | + * | ||
46 | + * Texas Instruments TMP105 temperature sensor. | ||
47 | + * | ||
48 | + * Copyright (C) 2008 Nokia Corporation | ||
49 | + * Written by Andrzej Zaborowski <andrew@openedhand.com> | ||
50 | + * | ||
51 | + * This program is free software; you can redistribute it and/or | ||
52 | + * modify it under the terms of the GNU General Public License as | ||
53 | + * published by the Free Software Foundation; either version 2 or | ||
54 | + * (at your option) version 3 of the License. | ||
55 | + * | ||
56 | + * This program is distributed in the hope that it will be useful, | ||
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
59 | + * GNU General Public License for more details. | ||
60 | + * | ||
61 | + * You should have received a copy of the GNU General Public License along | ||
62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
63 | + */ | ||
64 | + | ||
65 | +#include "qemu/osdep.h" | ||
66 | +#include "hw/hw.h" | ||
67 | +#include "hw/i2c/i2c.h" | ||
68 | +#include "qapi/error.h" | ||
69 | +#include "qapi/visitor.h" | ||
70 | + | ||
71 | +/* Manufacturer / Device ID's */ | ||
72 | +#define TMP421_MANUFACTURER_ID 0x55 | ||
73 | +#define TMP421_DEVICE_ID 0x21 | ||
74 | +#define TMP422_DEVICE_ID 0x22 | ||
75 | +#define TMP423_DEVICE_ID 0x23 | ||
76 | + | ||
77 | +typedef struct DeviceInfo { | ||
78 | + int model; | ||
79 | + const char *name; | ||
80 | +} DeviceInfo; | ||
81 | + | ||
82 | +static const DeviceInfo devices[] = { | ||
83 | + { TMP421_DEVICE_ID, "tmp421" }, | ||
84 | + { TMP422_DEVICE_ID, "tmp422" }, | ||
85 | + { TMP423_DEVICE_ID, "tmp423" }, | ||
86 | +}; | ||
87 | + | ||
88 | +typedef struct TMP421State { | ||
89 | + /*< private >*/ | ||
90 | + I2CSlave i2c; | ||
91 | + /*< public >*/ | ||
92 | + | ||
93 | + int16_t temperature[4]; | ||
94 | + | ||
95 | + uint8_t status; | ||
96 | + uint8_t config[2]; | ||
97 | + uint8_t rate; | ||
98 | + | ||
99 | + uint8_t len; | ||
100 | + uint8_t buf[2]; | ||
101 | + uint8_t pointer; | ||
102 | + | ||
103 | +} TMP421State; | ||
104 | + | ||
105 | +typedef struct TMP421Class { | ||
106 | + I2CSlaveClass parent_class; | ||
107 | + DeviceInfo *dev; | ||
108 | +} TMP421Class; | ||
109 | + | ||
110 | +#define TYPE_TMP421 "tmp421-generic" | ||
111 | +#define TMP421(obj) OBJECT_CHECK(TMP421State, (obj), TYPE_TMP421) | ||
112 | + | ||
113 | +#define TMP421_CLASS(klass) \ | ||
114 | + OBJECT_CLASS_CHECK(TMP421Class, (klass), TYPE_TMP421) | ||
115 | +#define TMP421_GET_CLASS(obj) \ | ||
116 | + OBJECT_GET_CLASS(TMP421Class, (obj), TYPE_TMP421) | ||
117 | + | ||
118 | +/* the TMP421 registers */ | ||
119 | +#define TMP421_STATUS_REG 0x08 | ||
120 | +#define TMP421_STATUS_BUSY (1 << 7) | ||
121 | +#define TMP421_CONFIG_REG_1 0x09 | ||
122 | +#define TMP421_CONFIG_RANGE (1 << 2) | ||
123 | +#define TMP421_CONFIG_SHUTDOWN (1 << 6) | ||
124 | +#define TMP421_CONFIG_REG_2 0x0A | ||
125 | +#define TMP421_CONFIG_RC (1 << 2) | ||
126 | +#define TMP421_CONFIG_LEN (1 << 3) | ||
127 | +#define TMP421_CONFIG_REN (1 << 4) | ||
128 | +#define TMP421_CONFIG_REN2 (1 << 5) | ||
129 | +#define TMP421_CONFIG_REN3 (1 << 6) | ||
130 | + | ||
131 | +#define TMP421_CONVERSION_RATE_REG 0x0B | ||
132 | +#define TMP421_ONE_SHOT 0x0F | ||
133 | + | ||
134 | +#define TMP421_RESET 0xFC | ||
135 | +#define TMP421_MANUFACTURER_ID_REG 0xFE | ||
136 | +#define TMP421_DEVICE_ID_REG 0xFF | ||
137 | + | ||
138 | +#define TMP421_TEMP_MSB0 0x00 | ||
139 | +#define TMP421_TEMP_MSB1 0x01 | ||
140 | +#define TMP421_TEMP_MSB2 0x02 | ||
141 | +#define TMP421_TEMP_MSB3 0x03 | ||
142 | +#define TMP421_TEMP_LSB0 0x10 | ||
143 | +#define TMP421_TEMP_LSB1 0x11 | ||
144 | +#define TMP421_TEMP_LSB2 0x12 | ||
145 | +#define TMP421_TEMP_LSB3 0x13 | ||
146 | + | ||
147 | +static const int32_t mins[2] = { -40000, -55000 }; | ||
148 | +static const int32_t maxs[2] = { 127000, 150000 }; | ||
149 | + | ||
150 | +static void tmp421_get_temperature(Object *obj, Visitor *v, const char *name, | ||
151 | + void *opaque, Error **errp) | ||
152 | +{ | ||
153 | + TMP421State *s = TMP421(obj); | ||
154 | + bool ext_range = (s->config[0] & TMP421_CONFIG_RANGE); | ||
155 | + int offset = ext_range * 64 * 256; | ||
156 | + int64_t value; | ||
157 | + int tempid; | ||
158 | + | ||
159 | + if (sscanf(name, "temperature%d", &tempid) != 1) { | ||
160 | + error_setg(errp, "error reading %s: %m", name); | ||
161 | + return; | ||
162 | + } | ||
163 | + | ||
164 | + if (tempid >= 4 || tempid < 0) { | ||
165 | + error_setg(errp, "error reading %s", name); | ||
166 | + return; | ||
167 | + } | ||
168 | + | ||
169 | + value = ((s->temperature[tempid] - offset) * 1000 + 128) / 256; | ||
170 | + | ||
171 | + visit_type_int(v, name, &value, errp); | ||
172 | +} | ||
173 | + | ||
174 | +/* Units are 0.001 centigrades relative to 0 C. s->temperature is 8.8 | ||
175 | + * fixed point, so units are 1/256 centigrades. A simple ratio will do. | ||
176 | + */ | ||
177 | +static void tmp421_set_temperature(Object *obj, Visitor *v, const char *name, | ||
178 | + void *opaque, Error **errp) | ||
179 | +{ | ||
180 | + TMP421State *s = TMP421(obj); | ||
181 | + Error *local_err = NULL; | ||
182 | + int64_t temp; | ||
183 | + bool ext_range = (s->config[0] & TMP421_CONFIG_RANGE); | ||
184 | + int offset = ext_range * 64 * 256; | ||
185 | + int tempid; | ||
186 | + | ||
187 | + visit_type_int(v, name, &temp, &local_err); | ||
188 | + if (local_err) { | ||
189 | + error_propagate(errp, local_err); | ||
190 | + return; | ||
191 | + } | ||
192 | + | ||
193 | + if (temp >= maxs[ext_range] || temp < mins[ext_range]) { | ||
194 | + error_setg(errp, "value %" PRId64 ".%03" PRIu64 " °C is out of range", | ||
195 | + temp / 1000, temp % 1000); | ||
196 | + return; | ||
197 | + } | ||
198 | + | ||
199 | + if (sscanf(name, "temperature%d", &tempid) != 1) { | ||
200 | + error_setg(errp, "error reading %s: %m", name); | ||
201 | + return; | ||
202 | + } | ||
203 | + | ||
204 | + if (tempid >= 4 || tempid < 0) { | ||
205 | + error_setg(errp, "error reading %s", name); | ||
206 | + return; | ||
207 | + } | ||
208 | + | ||
209 | + s->temperature[tempid] = (int16_t) ((temp * 256 - 128) / 1000) + offset; | ||
210 | +} | ||
211 | + | ||
212 | +static void tmp421_read(TMP421State *s) | ||
213 | +{ | ||
214 | + TMP421Class *sc = TMP421_GET_CLASS(s); | ||
215 | + | ||
216 | + s->len = 0; | ||
217 | + | ||
218 | + switch (s->pointer) { | ||
219 | + case TMP421_MANUFACTURER_ID_REG: | ||
220 | + s->buf[s->len++] = TMP421_MANUFACTURER_ID; | ||
221 | + break; | ||
222 | + case TMP421_DEVICE_ID_REG: | ||
223 | + s->buf[s->len++] = sc->dev->model; | ||
224 | + break; | ||
225 | + case TMP421_CONFIG_REG_1: | ||
226 | + s->buf[s->len++] = s->config[0]; | ||
227 | + break; | ||
228 | + case TMP421_CONFIG_REG_2: | ||
229 | + s->buf[s->len++] = s->config[1]; | ||
230 | + break; | ||
231 | + case TMP421_CONVERSION_RATE_REG: | ||
232 | + s->buf[s->len++] = s->rate; | ||
233 | + break; | ||
234 | + case TMP421_STATUS_REG: | ||
235 | + s->buf[s->len++] = s->status; | ||
236 | + break; | ||
237 | + | ||
238 | + /* FIXME: check for channel enablement in config registers */ | ||
239 | + case TMP421_TEMP_MSB0: | ||
240 | + s->buf[s->len++] = (((uint16_t) s->temperature[0]) >> 8); | ||
241 | + s->buf[s->len++] = (((uint16_t) s->temperature[0]) >> 0) & 0xf0; | ||
242 | + break; | ||
243 | + case TMP421_TEMP_MSB1: | ||
244 | + s->buf[s->len++] = (((uint16_t) s->temperature[1]) >> 8); | ||
245 | + s->buf[s->len++] = (((uint16_t) s->temperature[1]) >> 0) & 0xf0; | ||
246 | + break; | ||
247 | + case TMP421_TEMP_MSB2: | ||
248 | + s->buf[s->len++] = (((uint16_t) s->temperature[2]) >> 8); | ||
249 | + s->buf[s->len++] = (((uint16_t) s->temperature[2]) >> 0) & 0xf0; | ||
250 | + break; | ||
251 | + case TMP421_TEMP_MSB3: | ||
252 | + s->buf[s->len++] = (((uint16_t) s->temperature[3]) >> 8); | ||
253 | + s->buf[s->len++] = (((uint16_t) s->temperature[3]) >> 0) & 0xf0; | ||
254 | + break; | ||
255 | + case TMP421_TEMP_LSB0: | ||
256 | + s->buf[s->len++] = (((uint16_t) s->temperature[0]) >> 0) & 0xf0; | ||
257 | + break; | ||
258 | + case TMP421_TEMP_LSB1: | ||
259 | + s->buf[s->len++] = (((uint16_t) s->temperature[1]) >> 0) & 0xf0; | ||
260 | + break; | ||
261 | + case TMP421_TEMP_LSB2: | ||
262 | + s->buf[s->len++] = (((uint16_t) s->temperature[2]) >> 0) & 0xf0; | ||
263 | + break; | ||
264 | + case TMP421_TEMP_LSB3: | ||
265 | + s->buf[s->len++] = (((uint16_t) s->temperature[3]) >> 0) & 0xf0; | ||
266 | + break; | ||
267 | + } | ||
268 | +} | ||
269 | + | ||
270 | +static void tmp421_reset(I2CSlave *i2c); | ||
271 | + | ||
272 | +static void tmp421_write(TMP421State *s) | ||
273 | +{ | ||
274 | + switch (s->pointer) { | ||
275 | + case TMP421_CONVERSION_RATE_REG: | ||
276 | + s->rate = s->buf[0]; | ||
277 | + break; | ||
278 | + case TMP421_CONFIG_REG_1: | ||
279 | + s->config[0] = s->buf[0]; | ||
280 | + break; | ||
281 | + case TMP421_CONFIG_REG_2: | ||
282 | + s->config[1] = s->buf[0]; | ||
283 | + break; | ||
284 | + case TMP421_RESET: | ||
285 | + tmp421_reset(I2C_SLAVE(s)); | ||
286 | + break; | ||
287 | + } | ||
288 | +} | ||
289 | + | ||
290 | +static int tmp421_rx(I2CSlave *i2c) | ||
291 | +{ | ||
292 | + TMP421State *s = TMP421(i2c); | ||
293 | + | ||
294 | + if (s->len < 2) { | ||
295 | + return s->buf[s->len++]; | ||
296 | + } else { | ||
297 | + return 0xff; | ||
298 | + } | ||
299 | +} | ||
300 | + | ||
301 | +static int tmp421_tx(I2CSlave *i2c, uint8_t data) | ||
302 | +{ | ||
303 | + TMP421State *s = TMP421(i2c); | ||
304 | + | ||
305 | + if (s->len == 0) { | ||
306 | + /* first byte is the register pointer for a read or write | ||
307 | + * operation */ | ||
308 | + s->pointer = data; | ||
309 | + s->len++; | ||
310 | + } else if (s->len == 1) { | ||
311 | + /* second byte is the data to write. The device only supports | ||
312 | + * one byte writes */ | ||
313 | + s->buf[0] = data; | ||
314 | + tmp421_write(s); | ||
315 | + } | ||
316 | + | ||
317 | + return 0; | ||
318 | +} | ||
319 | + | ||
320 | +static int tmp421_event(I2CSlave *i2c, enum i2c_event event) | ||
321 | +{ | ||
322 | + TMP421State *s = TMP421(i2c); | ||
323 | + | ||
324 | + if (event == I2C_START_RECV) { | ||
325 | + tmp421_read(s); | ||
326 | + } | ||
327 | + | ||
328 | + s->len = 0; | ||
329 | + return 0; | ||
330 | +} | ||
331 | + | ||
332 | +static const VMStateDescription vmstate_tmp421 = { | ||
333 | + .name = "TMP421", | ||
334 | + .version_id = 0, | ||
335 | + .minimum_version_id = 0, | ||
336 | + .fields = (VMStateField[]) { | ||
337 | + VMSTATE_UINT8(len, TMP421State), | ||
338 | + VMSTATE_UINT8_ARRAY(buf, TMP421State, 2), | ||
339 | + VMSTATE_UINT8(pointer, TMP421State), | ||
340 | + VMSTATE_UINT8_ARRAY(config, TMP421State, 2), | ||
341 | + VMSTATE_UINT8(status, TMP421State), | ||
342 | + VMSTATE_UINT8(rate, TMP421State), | ||
343 | + VMSTATE_INT16_ARRAY(temperature, TMP421State, 4), | ||
344 | + VMSTATE_I2C_SLAVE(i2c, TMP421State), | ||
345 | + VMSTATE_END_OF_LIST() | ||
346 | + } | ||
347 | +}; | ||
348 | + | ||
349 | +static void tmp421_reset(I2CSlave *i2c) | ||
350 | +{ | ||
351 | + TMP421State *s = TMP421(i2c); | ||
352 | + TMP421Class *sc = TMP421_GET_CLASS(s); | ||
353 | + | ||
354 | + memset(s->temperature, 0, sizeof(s->temperature)); | ||
355 | + s->pointer = 0; | ||
356 | + | ||
357 | + s->config[0] = 0; /* TMP421_CONFIG_RANGE */ | ||
358 | + | ||
359 | + /* resistance correction and channel enablement */ | ||
360 | + switch (sc->dev->model) { | ||
361 | + case TMP421_DEVICE_ID: | ||
362 | + s->config[1] = 0x1c; | ||
363 | + break; | ||
364 | + case TMP422_DEVICE_ID: | ||
365 | + s->config[1] = 0x3c; | ||
366 | + break; | ||
367 | + case TMP423_DEVICE_ID: | ||
368 | + s->config[1] = 0x7c; | ||
369 | + break; | ||
370 | + } | ||
371 | + | ||
372 | + s->rate = 0x7; /* 8Hz */ | ||
373 | + s->status = 0; | ||
374 | +} | ||
375 | + | ||
376 | +static int tmp421_init(I2CSlave *i2c) | ||
377 | +{ | ||
378 | + TMP421State *s = TMP421(i2c); | ||
379 | + | ||
380 | + tmp421_reset(&s->i2c); | ||
381 | + | ||
382 | + return 0; | ||
383 | +} | ||
384 | + | ||
385 | +static void tmp421_initfn(Object *obj) | ||
386 | +{ | ||
387 | + object_property_add(obj, "temperature0", "int", | ||
388 | + tmp421_get_temperature, | ||
389 | + tmp421_set_temperature, NULL, NULL, NULL); | ||
390 | + object_property_add(obj, "temperature1", "int", | ||
391 | + tmp421_get_temperature, | ||
392 | + tmp421_set_temperature, NULL, NULL, NULL); | ||
393 | + object_property_add(obj, "temperature2", "int", | ||
394 | + tmp421_get_temperature, | ||
395 | + tmp421_set_temperature, NULL, NULL, NULL); | ||
396 | + object_property_add(obj, "temperature3", "int", | ||
397 | + tmp421_get_temperature, | ||
398 | + tmp421_set_temperature, NULL, NULL, NULL); | ||
399 | +} | ||
400 | + | ||
401 | +static void tmp421_class_init(ObjectClass *klass, void *data) | ||
402 | +{ | ||
403 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
404 | + I2CSlaveClass *k = I2C_SLAVE_CLASS(klass); | ||
405 | + TMP421Class *sc = TMP421_CLASS(klass); | ||
406 | + | ||
407 | + k->init = tmp421_init; | ||
408 | + k->event = tmp421_event; | ||
409 | + k->recv = tmp421_rx; | ||
410 | + k->send = tmp421_tx; | ||
411 | + dc->vmsd = &vmstate_tmp421; | ||
412 | + sc->dev = (DeviceInfo *) data; | ||
413 | +} | ||
414 | + | ||
415 | +static const TypeInfo tmp421_info = { | ||
416 | + .name = TYPE_TMP421, | ||
417 | + .parent = TYPE_I2C_SLAVE, | ||
418 | + .instance_size = sizeof(TMP421State), | ||
419 | + .class_size = sizeof(TMP421Class), | ||
420 | + .instance_init = tmp421_initfn, | ||
421 | + .abstract = true, | ||
422 | +}; | ||
423 | + | ||
424 | +static void tmp421_register_types(void) | ||
425 | +{ | ||
426 | + int i; | ||
427 | + | ||
428 | + type_register_static(&tmp421_info); | ||
429 | + for (i = 0; i < ARRAY_SIZE(devices); ++i) { | ||
430 | + TypeInfo ti = { | ||
431 | + .name = devices[i].name, | ||
432 | + .parent = TYPE_TMP421, | ||
433 | + .class_init = tmp421_class_init, | ||
434 | + .class_data = (void *) &devices[i], | ||
435 | + }; | ||
436 | + type_register(&ti); | ||
437 | + } | ||
438 | +} | ||
439 | + | ||
440 | +type_init(tmp421_register_types) | ||
441 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | ||
442 | index XXXXXXX..XXXXXXX 100644 | ||
443 | --- a/default-configs/arm-softmmu.mak | ||
444 | +++ b/default-configs/arm-softmmu.mak | ||
445 | @@ -XXX,XX +XXX,XX @@ CONFIG_TWL92230=y | ||
446 | CONFIG_TSC2005=y | ||
447 | CONFIG_LM832X=y | ||
448 | CONFIG_TMP105=y | ||
449 | +CONFIG_TMP421=y | ||
450 | CONFIG_STELLARIS=y | ||
451 | CONFIG_STELLARIS_INPUT=y | ||
452 | CONFIG_STELLARIS_ENET=y | ||
453 | -- | 42 | -- |
454 | 2.7.4 | 43 | 2.20.1 |
455 | 44 | ||
456 | 45 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | The VECTPENDING field in the ICSR is 9 bits wide, in bits [20:12] of |
---|---|---|---|
2 | the register. We were incorrectly masking it to 8 bits, so it would | ||
3 | report the wrong value if the pending exception was greater than 256. | ||
4 | Fix the bug. | ||
2 | 5 | ||
3 | The static array of interrupt combiner mappings is not modified so it | ||
4 | can be made const for code safeness. | ||
5 | |||
6 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210723162146.5167-6-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | hw/intc/exynos4210_gic.c | 2 +- | 10 | hw/intc/armv7m_nvic.c | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 12 | ||
13 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | 13 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/intc/exynos4210_gic.c | 15 | --- a/hw/intc/armv7m_nvic.c |
16 | +++ b/hw/intc/exynos4210_gic.c | 16 | +++ b/hw/intc/armv7m_nvic.c |
17 | @@ -XXX,XX +XXX,XX @@ enum ExtInt { | 17 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
18 | * which is INTG16 in Internal Interrupt Combiner. | 18 | /* VECTACTIVE */ |
19 | */ | 19 | val = cpu->env.v7m.exception; |
20 | 20 | /* VECTPENDING */ | |
21 | -static uint32_t | 21 | - val |= (s->vectpending & 0xff) << 12; |
22 | +static const uint32_t | 22 | + val |= (s->vectpending & 0x1ff) << 12; |
23 | combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | 23 | /* ISRPENDING - set if any external IRQ is pending */ |
24 | /* int combiner groups 16-19 */ | 24 | if (nvic_isrpending(s)) { |
25 | { }, { }, { }, { }, | 25 | val |= (1 << 22); |
26 | -- | 26 | -- |
27 | 2.7.4 | 27 | 2.20.1 |
28 | 28 | ||
29 | 29 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | In Arm v8.1M the VECTPENDING field in the ICSR has new behaviour: if |
---|---|---|---|
2 | the register is accessed NonSecure and the highest priority pending | ||
3 | enabled exception (that would be returned in the VECTPENDING field) | ||
4 | targets Secure, then the VECTPENDING field must read 1 rather than | ||
5 | the exception number of the pending exception. Implement this. | ||
2 | 6 | ||
3 | Before QOM-ifying the Exynos4 SoC model, move the DRAM initialization | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | from exynos4210.c to exynos4_boards.c because DRAM is board specific, | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | not SoC. | 9 | Message-id: 20210723162146.5167-7-peter.maydell@linaro.org |
10 | --- | ||
11 | hw/intc/armv7m_nvic.c | 31 ++++++++++++++++++++++++------- | ||
12 | 1 file changed, 24 insertions(+), 7 deletions(-) | ||
6 | 13 | ||
7 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/exynos4210.h | 5 +---- | ||
12 | hw/arm/exynos4210.c | 20 +----------------- | ||
13 | hw/arm/exynos4_boards.c | 50 ++++++++++++++++++++++++++++++++++++++------- | ||
14 | 3 files changed, 45 insertions(+), 30 deletions(-) | ||
15 | |||
16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/exynos4210.h | 16 | --- a/hw/intc/armv7m_nvic.c |
19 | +++ b/include/hw/arm/exynos4210.h | 17 | +++ b/hw/intc/armv7m_nvic.c |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210State { | 18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque) |
21 | MemoryRegion iram_mem; | 19 | nvic_irq_update(s); |
22 | MemoryRegion irom_mem; | ||
23 | MemoryRegion irom_alias_mem; | ||
24 | - MemoryRegion dram0_mem; | ||
25 | - MemoryRegion dram1_mem; | ||
26 | MemoryRegion boot_secondary; | ||
27 | MemoryRegion bootreg_mem; | ||
28 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210State { | ||
30 | void exynos4210_write_secondary(ARMCPU *cpu, | ||
31 | const struct arm_boot_info *info); | ||
32 | |||
33 | -Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | ||
34 | - unsigned long ram_size); | ||
35 | +Exynos4210State *exynos4210_init(MemoryRegion *system_mem); | ||
36 | |||
37 | /* Initialize exynos4210 IRQ subsystem stub */ | ||
38 | qemu_irq *exynos4210_init_irq(Exynos4210Irq *env); | ||
39 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/arm/exynos4210.c | ||
42 | +++ b/hw/arm/exynos4210.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_calc_affinity(int cpu) | ||
44 | return mp_affinity; | ||
45 | } | 20 | } |
46 | 21 | ||
47 | -Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | 22 | +static bool vectpending_targets_secure(NVICState *s) |
48 | - unsigned long ram_size) | ||
49 | +Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | ||
50 | { | ||
51 | int i, n; | ||
52 | Exynos4210State *s = g_new(Exynos4210State, 1); | ||
53 | qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||
54 | - unsigned long mem_size; | ||
55 | DeviceState *dev; | ||
56 | SysBusDevice *busdev; | ||
57 | ObjectClass *cpu_oc; | ||
58 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | ||
59 | memory_region_add_subregion(system_mem, EXYNOS4210_IRAM_BASE_ADDR, | ||
60 | &s->iram_mem); | ||
61 | |||
62 | - /* DRAM */ | ||
63 | - mem_size = ram_size; | ||
64 | - if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) { | ||
65 | - memory_region_init_ram(&s->dram1_mem, NULL, "exynos4210.dram1", | ||
66 | - mem_size - EXYNOS4210_DRAM_MAX_SIZE, &error_fatal); | ||
67 | - vmstate_register_ram_global(&s->dram1_mem); | ||
68 | - memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR, | ||
69 | - &s->dram1_mem); | ||
70 | - mem_size = EXYNOS4210_DRAM_MAX_SIZE; | ||
71 | - } | ||
72 | - memory_region_init_ram(&s->dram0_mem, NULL, "exynos4210.dram0", mem_size, | ||
73 | - &error_fatal); | ||
74 | - vmstate_register_ram_global(&s->dram0_mem); | ||
75 | - memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR, | ||
76 | - &s->dram0_mem); | ||
77 | - | ||
78 | /* PMU. | ||
79 | * The only reason of existence at the moment is that secondary CPU boot | ||
80 | * loader uses PMU INFORM5 register as a holding pen. | ||
81 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/arm/exynos4_boards.c | ||
84 | +++ b/hw/arm/exynos4_boards.c | ||
85 | @@ -XXX,XX +XXX,XX @@ | ||
86 | */ | ||
87 | |||
88 | #include "qemu/osdep.h" | ||
89 | +#include "qapi/error.h" | ||
90 | #include "qemu/error-report.h" | ||
91 | #include "qemu-common.h" | ||
92 | #include "cpu.h" | ||
93 | @@ -XXX,XX +XXX,XX @@ typedef enum Exynos4BoardType { | ||
94 | EXYNOS4_NUM_OF_BOARDS | ||
95 | } Exynos4BoardType; | ||
96 | |||
97 | +typedef struct Exynos4BoardState { | ||
98 | + Exynos4210State *soc; | ||
99 | + MemoryRegion dram0_mem; | ||
100 | + MemoryRegion dram1_mem; | ||
101 | +} Exynos4BoardState; | ||
102 | + | ||
103 | static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = { | ||
104 | [EXYNOS4_BOARD_NURI] = 0xD33, | ||
105 | [EXYNOS4_BOARD_SMDKC210] = 0xB16, | ||
106 | @@ -XXX,XX +XXX,XX @@ static void lan9215_init(uint32_t base, qemu_irq irq) | ||
107 | } | ||
108 | } | ||
109 | |||
110 | -static Exynos4210State *exynos4_boards_init_common(MachineState *machine, | ||
111 | - Exynos4BoardType board_type) | ||
112 | +static void exynos4_boards_init_ram(Exynos4BoardState *s, | ||
113 | + MemoryRegion *system_mem, | ||
114 | + unsigned long ram_size) | ||
115 | +{ | 23 | +{ |
116 | + unsigned long mem_size = ram_size; | 24 | + /* Return true if s->vectpending targets Secure state */ |
117 | + | 25 | + if (s->vectpending_is_s_banked) { |
118 | + if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) { | 26 | + return true; |
119 | + memory_region_init_ram(&s->dram1_mem, NULL, "exynos4210.dram1", | ||
120 | + mem_size - EXYNOS4210_DRAM_MAX_SIZE, | ||
121 | + &error_fatal); | ||
122 | + vmstate_register_ram_global(&s->dram1_mem); | ||
123 | + memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR, | ||
124 | + &s->dram1_mem); | ||
125 | + mem_size = EXYNOS4210_DRAM_MAX_SIZE; | ||
126 | + } | 27 | + } |
127 | + | 28 | + return !exc_is_banked(s->vectpending) && |
128 | + memory_region_init_ram(&s->dram0_mem, NULL, "exynos4210.dram0", mem_size, | 29 | + exc_targets_secure(s, s->vectpending); |
129 | + &error_fatal); | ||
130 | + vmstate_register_ram_global(&s->dram0_mem); | ||
131 | + memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR, | ||
132 | + &s->dram0_mem); | ||
133 | +} | 30 | +} |
134 | + | 31 | + |
135 | +static Exynos4BoardState * | 32 | void armv7m_nvic_get_pending_irq_info(void *opaque, |
136 | +exynos4_boards_init_common(MachineState *machine, | 33 | int *pirq, bool *ptargets_secure) |
137 | + Exynos4BoardType board_type) | ||
138 | { | 34 | { |
139 | + Exynos4BoardState *s = g_new(Exynos4BoardState, 1); | 35 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque, |
140 | MachineClass *mc = MACHINE_GET_CLASS(machine); | 36 | |
141 | 37 | assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq); | |
142 | if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) { | 38 | |
143 | @@ -XXX,XX +XXX,XX @@ static Exynos4210State *exynos4_boards_init_common(MachineState *machine, | 39 | - if (s->vectpending_is_s_banked) { |
144 | machine->kernel_cmdline, | 40 | - targets_secure = true; |
145 | machine->initrd_filename); | 41 | - } else { |
146 | 42 | - targets_secure = !exc_is_banked(pending) && | |
147 | - return exynos4210_init(get_system_memory(), | 43 | - exc_targets_secure(s, pending); |
148 | - exynos4_board_ram_size[board_type]); | 44 | - } |
149 | + exynos4_boards_init_ram(s, get_system_memory(), | 45 | + targets_secure = vectpending_targets_secure(s); |
150 | + exynos4_board_ram_size[board_type]); | 46 | |
151 | + | 47 | trace_nvic_get_pending_irq_info(pending, targets_secure); |
152 | + s->soc = exynos4210_init(get_system_memory()); | 48 | |
153 | + | 49 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
154 | + return s; | 50 | /* VECTACTIVE */ |
155 | } | 51 | val = cpu->env.v7m.exception; |
156 | 52 | /* VECTPENDING */ | |
157 | static void nuri_init(MachineState *machine) | 53 | - val |= (s->vectpending & 0x1ff) << 12; |
158 | @@ -XXX,XX +XXX,XX @@ static void nuri_init(MachineState *machine) | 54 | + if (s->vectpending) { |
159 | 55 | + /* | |
160 | static void smdkc210_init(MachineState *machine) | 56 | + * From v8.1M VECTPENDING must read as 1 if accessed as |
161 | { | 57 | + * NonSecure and the highest priority pending and enabled |
162 | - Exynos4210State *s = exynos4_boards_init_common(machine, | 58 | + * exception targets Secure. |
163 | - EXYNOS4_BOARD_SMDKC210); | 59 | + */ |
164 | + Exynos4BoardState *s = exynos4_boards_init_common(machine, | 60 | + int vp = s->vectpending; |
165 | + EXYNOS4_BOARD_SMDKC210); | 61 | + if (!attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_V8_1M) && |
166 | 62 | + vectpending_targets_secure(s)) { | |
167 | lan9215_init(SMDK_LAN9118_BASE_ADDR, | 63 | + vp = 1; |
168 | - qemu_irq_invert(s->irq_table[exynos4210_get_irq(37, 1)])); | 64 | + } |
169 | + qemu_irq_invert(s->soc->irq_table[exynos4210_get_irq(37, 1)])); | 65 | + val |= (vp & 0x1ff) << 12; |
170 | arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo); | 66 | + } |
171 | } | 67 | /* ISRPENDING - set if any external IRQ is pending */ |
172 | 68 | if (nvic_isrpending(s)) { | |
69 | val |= (1 << 22); | ||
173 | -- | 70 | -- |
174 | 2.7.4 | 71 | 2.20.1 |
175 | 72 | ||
176 | 73 | diff view generated by jsdifflib |
1 | From: Pranith Kumar <bobby.prani@gmail.com> | 1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> |
---|---|---|---|
2 | 2 | ||
3 | Tested and confirmed that the stretch i386 debian qcow2 image on a | 3 | Missed in commit f3478392 "docs: Move deprecation, build |
4 | raspberry pi 2 works. | 4 | and license info out of system/" |
5 | 5 | ||
6 | Fixes: LP#: 893208 <https://bugs.launchpad.net/qemu/+bug/893208/> | 6 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> |
7 | Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | 8 | Message-id: 20210723065828.1336760-1-maozhongyi@cmss.chinamobile.com |
9 | Message-id: 20170418191817.10430-1-bobby.prani@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | include/qemu/timer.h | 5 ++--- | 11 | configure | 2 +- |
13 | 1 file changed, 2 insertions(+), 3 deletions(-) | 12 | target/i386/cpu.c | 2 +- |
13 | MAINTAINERS | 2 +- | ||
14 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
14 | 15 | ||
15 | diff --git a/include/qemu/timer.h b/include/qemu/timer.h | 16 | diff --git a/configure b/configure |
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/configure | ||
19 | +++ b/configure | ||
20 | @@ -XXX,XX +XXX,XX @@ fi | ||
21 | |||
22 | if test -n "${deprecated_features}"; then | ||
23 | echo "Warning, deprecated features enabled." | ||
24 | - echo "Please see docs/system/deprecated.rst" | ||
25 | + echo "Please see docs/about/deprecated.rst" | ||
26 | echo " features: ${deprecated_features}" | ||
27 | fi | ||
28 | |||
29 | diff --git a/target/i386/cpu.c b/target/i386/cpu.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/qemu/timer.h | 31 | --- a/target/i386/cpu.c |
18 | +++ b/include/qemu/timer.h | 32 | +++ b/target/i386/cpu.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline int64_t cpu_get_host_ticks(void) | 33 | @@ -XXX,XX +XXX,XX @@ static const X86CPUDefinition builtin_x86_defs[] = { |
20 | /* The host CPU doesn't have an easily accessible cycle counter. | 34 | * none", but this is just for compatibility while libvirt isn't |
21 | Just return a monotonically increasing value. This will be | 35 | * adapted to resolve CPU model versions before creating VMs. |
22 | totally wrong, but hopefully better than nothing. */ | 36 | * See "Runnability guarantee of CPU models" at |
23 | -static inline int64_t cpu_get_host_ticks (void) | 37 | - * docs/system/deprecated.rst. |
24 | +static inline int64_t cpu_get_host_ticks(void) | 38 | + * docs/about/deprecated.rst. |
25 | { | 39 | */ |
26 | - static int64_t ticks = 0; | 40 | X86CPUVersion default_cpu_version = 1; |
27 | - return ticks++; | 41 | |
28 | + return get_clock(); | 42 | diff --git a/MAINTAINERS b/MAINTAINERS |
29 | } | 43 | index XXXXXXX..XXXXXXX 100644 |
30 | #endif | 44 | --- a/MAINTAINERS |
31 | 45 | +++ b/MAINTAINERS | |
46 | @@ -XXX,XX +XXX,XX @@ F: contrib/gitdm/* | ||
47 | |||
48 | Incompatible changes | ||
49 | R: libvir-list@redhat.com | ||
50 | -F: docs/system/deprecated.rst | ||
51 | +F: docs/about/deprecated.rst | ||
52 | |||
53 | Build System | ||
54 | ------------ | ||
32 | -- | 55 | -- |
33 | 2.7.4 | 56 | 2.20.1 |
34 | 57 | ||
35 | 58 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | On all Exynos-based boards, the system powers down itself by driving | 3 | Currently, our only caller is sve_zcr_len_for_el, which has |
4 | PS_HOLD signal low - eight bit in PS_HOLD_CONTROL register of PMU. | 4 | already masked the length extracted from ZCR_ELx, so the |
5 | Handle writing to respective PMU register to fix power off failure: | 5 | masking done here is a nop. But we will shortly have uses |
6 | from other locations, where the length will be unmasked. | ||
6 | 7 | ||
7 | reboot: Power down | 8 | Saturate the length to ARM_MAX_VQ instead of truncating to |
8 | Unable to poweroff system | 9 | the low 4 bits. |
9 | shutdown: 31 output lines suppressed due to ratelimiting | ||
10 | Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000 | ||
11 | 10 | ||
12 | CPU: 0 PID: 1 Comm: shutdown Not tainted 4.11.0-rc8 #846 | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) | ||
14 | [<c031050c>] (unwind_backtrace) from [<c030ba6c>] (show_stack+0x10/0x14) | ||
15 | [<c030ba6c>] (show_stack) from [<c05b2800>] (dump_stack+0x88/0x9c) | ||
16 | [<c05b2800>] (dump_stack) from [<c03d3140>] (panic+0xdc/0x268) | ||
17 | [<c03d3140>] (panic) from [<c0343614>] (do_exit+0xa90/0xab4) | ||
18 | [<c0343614>] (do_exit) from [<c035f2dc>] (SyS_reboot+0x164/0x1d0) | ||
19 | [<c035f2dc>] (SyS_reboot) from [<c0307c80>] (ret_fast_syscall+0x0/0x3c) | ||
20 | |||
21 | Additionally the initial value of PS_HOLD has to be changed because | ||
22 | recent Linux kernel (v4.12-rc1) uses regmap cache for this access. | ||
23 | When the register is kept at reset value, the kernel will not issue a | ||
24 | write to it. Usually the bootloader sets the eight bit of PS_HOLD high | ||
25 | so mimic its existence here. | ||
26 | |||
27 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
28 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
29 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | Message-id: 20210723203344.968563-2-richard.henderson@linaro.org |
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | --- | 15 | --- |
32 | hw/misc/exynos4210_pmu.c | 20 +++++++++++++++++++- | 16 | target/arm/helper.c | 4 +++- |
33 | 1 file changed, 19 insertions(+), 1 deletion(-) | 17 | 1 file changed, 3 insertions(+), 1 deletion(-) |
34 | 18 | ||
35 | diff --git a/hw/misc/exynos4210_pmu.c b/hw/misc/exynos4210_pmu.c | 19 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
36 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/misc/exynos4210_pmu.c | 21 | --- a/target/arm/helper.c |
38 | +++ b/hw/misc/exynos4210_pmu.c | 22 | +++ b/target/arm/helper.c |
39 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
40 | 24 | { | |
41 | #include "qemu/osdep.h" | 25 | uint32_t end_len; |
42 | #include "hw/sysbus.h" | 26 | |
43 | +#include "sysemu/sysemu.h" | 27 | - end_len = start_len &= 0xf; |
44 | 28 | + start_len = MIN(start_len, ARM_MAX_VQ - 1); | |
45 | #ifndef DEBUG_PMU | 29 | + end_len = start_len; |
46 | #define DEBUG_PMU 0 | ||
47 | @@ -XXX,XX +XXX,XX @@ static const Exynos4210PmuReg exynos4210_pmu_regs[] = { | ||
48 | {"PAD_RETENTION_MMCB_OPTION", PAD_RETENTION_MMCB_OPTION, 0x00000000}, | ||
49 | {"PAD_RETENTION_EBIA_OPTION", PAD_RETENTION_EBIA_OPTION, 0x00000000}, | ||
50 | {"PAD_RETENTION_EBIB_OPTION", PAD_RETENTION_EBIB_OPTION, 0x00000000}, | ||
51 | - {"PS_HOLD_CONTROL", PS_HOLD_CONTROL, 0x00005200}, | ||
52 | + /* | ||
53 | + * PS_HOLD_CONTROL: reset value and manually toggle high the DATA bit. | ||
54 | + * DATA bit high, set usually by bootloader, keeps system on. | ||
55 | + */ | ||
56 | + {"PS_HOLD_CONTROL", PS_HOLD_CONTROL, 0x00005200 | BIT(8)}, | ||
57 | {"XUSBXTI_CONFIGURATION", XUSBXTI_CONFIGURATION, 0x00000001}, | ||
58 | {"XUSBXTI_STATUS", XUSBXTI_STATUS, 0x00000001}, | ||
59 | {"XUSBXTI_DURATION", XUSBXTI_DURATION, 0xFFF00000}, | ||
60 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210PmuState { | ||
61 | uint32_t reg[PMU_NUM_OF_REGISTERS]; | ||
62 | } Exynos4210PmuState; | ||
63 | |||
64 | +static void exynos4210_pmu_poweroff(void) | ||
65 | +{ | ||
66 | + PRINT_DEBUG("QEMU PMU: PS_HOLD bit down, powering off\n"); | ||
67 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | ||
68 | +} | ||
69 | + | 30 | + |
70 | static uint64_t exynos4210_pmu_read(void *opaque, hwaddr offset, | 31 | if (!test_bit(start_len, cpu->sve_vq_map)) { |
71 | unsigned size) | 32 | end_len = find_last_bit(cpu->sve_vq_map, start_len); |
72 | { | 33 | assert(end_len < start_len); |
73 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pmu_write(void *opaque, hwaddr offset, | ||
74 | PRINT_DEBUG_EXTEND("%s <0x%04x> <- 0x%04x\n", reg_p->name, | ||
75 | (uint32_t)offset, (uint32_t)val); | ||
76 | s->reg[i] = val; | ||
77 | + if ((offset == PS_HOLD_CONTROL) && ((val & BIT(8)) == 0)) { | ||
78 | + /* | ||
79 | + * We are interested only in setting data bit | ||
80 | + * of PS_HOLD_CONTROL register to indicate power off request. | ||
81 | + */ | ||
82 | + exynos4210_pmu_poweroff(); | ||
83 | + } | ||
84 | return; | ||
85 | } | ||
86 | reg_p++; | ||
87 | -- | 34 | -- |
88 | 2.7.4 | 35 | 2.20.1 |
89 | 36 | ||
90 | 37 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds the flush of the LPI pending bits into the | 3 | Rename from sve_zcr_get_valid_len and make accessible |
4 | redistributor pending tables. This happens on VM stop. | 4 | from outside of helper.c. |
5 | 5 | ||
6 | There is no explicit restore as the tables are implicitly sync'ed | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | on ITS table restore and on LPI enable at redistributor level. | ||
8 | |||
9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Message-id: 1497023553-18411-4-git-send-email-eric.auger@redhat.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20210723203344.968563-3-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | hw/intc/arm_gicv3_kvm.c | 34 ++++++++++++++++++++++++++++++++++ | 11 | target/arm/internals.h | 10 ++++++++++ |
15 | 1 file changed, 34 insertions(+) | 12 | target/arm/helper.c | 4 ++-- |
13 | 2 files changed, 12 insertions(+), 2 deletions(-) | ||
16 | 14 | ||
17 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 15 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/arm_gicv3_kvm.c | 17 | --- a/target/arm/internals.h |
20 | +++ b/hw/intc/arm_gicv3_kvm.c | 18 | +++ b/target/arm/internals.h |
21 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void); |
22 | #include "hw/sysbus.h" | 20 | void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); |
23 | #include "qemu/error-report.h" | 21 | #endif /* CONFIG_TCG */ |
24 | #include "sysemu/kvm.h" | ||
25 | +#include "sysemu/sysemu.h" | ||
26 | #include "kvm_arm.h" | ||
27 | #include "gicv3_internal.h" | ||
28 | #include "vgic_common.h" | ||
29 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
30 | REGINFO_SENTINEL | ||
31 | }; | ||
32 | 22 | ||
33 | +/** | 23 | +/** |
34 | + * vm_change_state_handler - VM change state callback aiming at flushing | 24 | + * aarch64_sve_zcr_get_valid_len: |
35 | + * RDIST pending tables into guest RAM | 25 | + * @cpu: cpu context |
26 | + * @start_len: maximum len to consider | ||
36 | + * | 27 | + * |
37 | + * The tables get flushed to guest RAM whenever the VM gets stopped. | 28 | + * Return the maximum supported sve vector length <= @start_len. |
29 | + * Note that both @start_len and the return value are in units | ||
30 | + * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128. | ||
38 | + */ | 31 | + */ |
39 | +static void vm_change_state_handler(void *opaque, int running, | 32 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len); |
40 | + RunState state) | 33 | |
41 | +{ | 34 | enum arm_fprounding { |
42 | + GICv3State *s = (GICv3State *)opaque; | 35 | FPROUNDING_TIEEVEN, |
43 | + Error *err = NULL; | 36 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
44 | + int ret; | 37 | index XXXXXXX..XXXXXXX 100644 |
45 | + | 38 | --- a/target/arm/helper.c |
46 | + if (running) { | 39 | +++ b/target/arm/helper.c |
47 | + return; | 40 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
48 | + } | 41 | return 0; |
49 | + | 42 | } |
50 | + ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | 43 | |
51 | + KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES, | 44 | -static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
52 | + NULL, true, &err); | 45 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
53 | + if (err) { | ||
54 | + error_report_err(err); | ||
55 | + } | ||
56 | + if (ret < 0 && ret != -EFAULT) { | ||
57 | + abort(); | ||
58 | + } | ||
59 | +} | ||
60 | + | ||
61 | + | ||
62 | static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
63 | { | 46 | { |
64 | GICv3State *s = KVM_ARM_GICV3(dev); | 47 | uint32_t end_len; |
65 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | 48 | |
66 | return; | 49 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) |
67 | } | 50 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); |
68 | } | 51 | } |
69 | + if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | 52 | |
70 | + KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES)) { | 53 | - return sve_zcr_get_valid_len(cpu, zcr_len); |
71 | + qemu_add_vm_change_state_handler(vm_change_state_handler, s); | 54 | + return aarch64_sve_zcr_get_valid_len(cpu, zcr_len); |
72 | + } | ||
73 | } | 55 | } |
74 | 56 | ||
75 | static void kvm_arm_gicv3_class_init(ObjectClass *klass, void *data) | 57 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
76 | -- | 58 | -- |
77 | 2.7.4 | 59 | 2.20.1 |
78 | 60 | ||
79 | 61 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We need to handle both registers and ITS tables. While | 3 | Mirror the behavour of /proc/sys/abi/sve_default_vector_length |
4 | register handling is standard, ITS table handling is more | 4 | under the real linux kernel. We have no way of passing along |
5 | challenging since the kernel API is devised so that the | 5 | a real default across exec like the kernel can, but this is a |
6 | tables are flushed into guest RAM and not in vmstate buffers. | 6 | decent way of adjusting the startup vector length of a process. |
7 | 7 | ||
8 | Flushing the ITS tables on device pre_save() is too late | 8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/482 |
9 | since the guest RAM is already saved at this point. | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | |||
11 | Table flushing needs to happen when we are sure the vcpus | ||
12 | are stopped and before the last dirty page saving. The | ||
13 | right point is RUN_STATE_FINISH_MIGRATE but sometimes the | ||
14 | VM gets stopped before migration launch so let's simply | ||
15 | flush the tables each time the VM gets stopped. | ||
16 | |||
17 | For regular ITS registers we just can use vmstate pre_save() | ||
18 | and post_load() callbacks. | ||
19 | |||
20 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
21 | Message-id: 1497023553-18411-3-git-send-email-eric.auger@redhat.com | ||
22 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20210723203344.968563-4-richard.henderson@linaro.org | ||
12 | [PMM: tweaked docs formatting, document -1 special-case, | ||
13 | added fixup patch from RTH mentioning QEMU's maximum veclen.] | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | --- | 15 | --- |
25 | include/hw/intc/arm_gicv3_its_common.h | 8 +++ | 16 | docs/system/arm/cpu-features.rst | 15 ++++++++ |
26 | hw/intc/arm_gicv3_its_common.c | 10 ++++ | 17 | target/arm/cpu.h | 5 +++ |
27 | hw/intc/arm_gicv3_its_kvm.c | 105 +++++++++++++++++++++++++++++++++ | 18 | target/arm/cpu.c | 14 ++++++-- |
28 | 3 files changed, 123 insertions(+) | 19 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++ |
20 | 4 files changed, 92 insertions(+), 2 deletions(-) | ||
29 | 21 | ||
30 | diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_gicv3_its_common.h | 22 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst |
31 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/include/hw/intc/arm_gicv3_its_common.h | 24 | --- a/docs/system/arm/cpu-features.rst |
33 | +++ b/include/hw/intc/arm_gicv3_its_common.h | 25 | +++ b/docs/system/arm/cpu-features.rst |
34 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector |
35 | #define ITS_TRANS_SIZE 0x10000 | 27 | lengths is to explicitly enable each desired length. Therefore only |
36 | #define ITS_SIZE (ITS_CONTROL_SIZE + ITS_TRANS_SIZE) | 28 | example's (1), (4), and (6) exhibit recommended uses of the properties. |
37 | 29 | ||
38 | +#define GITS_CTLR 0x0 | 30 | +SVE User-mode Default Vector Length Property |
39 | +#define GITS_IIDR 0x4 | 31 | +-------------------------------------------- |
40 | +#define GITS_CBASER 0x80 | ||
41 | +#define GITS_CWRITER 0x88 | ||
42 | +#define GITS_CREADR 0x90 | ||
43 | +#define GITS_BASER 0x100 | ||
44 | + | 32 | + |
45 | struct GICv3ITSState { | 33 | +For qemu-aarch64, the cpu property ``sve-default-vector-length=N`` is |
46 | SysBusDevice parent_obj; | 34 | +defined to mirror the Linux kernel parameter file |
47 | 35 | +``/proc/sys/abi/sve_default_vector_length``. The default length, ``N``, | |
48 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSState { | 36 | +is in units of bytes and must be between 16 and 8192. |
49 | 37 | +If not specified, the default vector length is 64. | |
50 | /* Registers */ | 38 | + |
51 | uint32_t ctlr; | 39 | +If the default length is larger than the maximum vector length enabled, |
52 | + uint32_t iidr; | 40 | +the actual vector length will be reduced. Note that the maximum vector |
53 | uint64_t cbaser; | 41 | +length supported by QEMU is 256. |
54 | uint64_t cwriter; | 42 | + |
55 | uint64_t creadr; | 43 | +If this property is set to ``-1`` then the default vector length |
56 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | 44 | +is set to the maximum possible length. |
45 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
57 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
58 | --- a/hw/intc/arm_gicv3_its_common.c | 47 | --- a/target/arm/cpu.h |
59 | +++ b/hw/intc/arm_gicv3_its_common.c | 48 | +++ b/target/arm/cpu.h |
60 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_its = { | 49 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
61 | .pre_save = gicv3_its_pre_save, | 50 | /* Used to set the maximum vector length the cpu will support. */ |
62 | .post_load = gicv3_its_post_load, | 51 | uint32_t sve_max_vq; |
63 | .unmigratable = true, | 52 | |
64 | + .fields = (VMStateField[]) { | 53 | +#ifdef CONFIG_USER_ONLY |
65 | + VMSTATE_UINT32(ctlr, GICv3ITSState), | 54 | + /* Used to set the default vector length at process start. */ |
66 | + VMSTATE_UINT32(iidr, GICv3ITSState), | 55 | + uint32_t sve_default_vq; |
67 | + VMSTATE_UINT64(cbaser, GICv3ITSState), | 56 | +#endif |
68 | + VMSTATE_UINT64(cwriter, GICv3ITSState), | 57 | + |
69 | + VMSTATE_UINT64(creadr, GICv3ITSState), | 58 | /* |
70 | + VMSTATE_UINT64_ARRAY(baser, GICv3ITSState, 8), | 59 | * In sve_vq_map each set bit is a supported vector length of |
71 | + VMSTATE_END_OF_LIST() | 60 | * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector |
72 | + }, | 61 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
73 | }; | ||
74 | |||
75 | static MemTxResult gicv3_its_trans_read(void *opaque, hwaddr offset, | ||
76 | @@ -XXX,XX +XXX,XX @@ static void gicv3_its_common_reset(DeviceState *dev) | ||
77 | s->cbaser = 0; | ||
78 | s->cwriter = 0; | ||
79 | s->creadr = 0; | ||
80 | + s->iidr = 0; | ||
81 | memset(&s->baser, 0, sizeof(s->baser)); | ||
82 | |||
83 | gicv3_its_post_load(s, 0); | ||
84 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
86 | --- a/hw/intc/arm_gicv3_its_kvm.c | 63 | --- a/target/arm/cpu.c |
87 | +++ b/hw/intc/arm_gicv3_its_kvm.c | 64 | +++ b/target/arm/cpu.c |
88 | @@ -XXX,XX +XXX,XX @@ static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint16_t devid) | 65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
89 | return kvm_vm_ioctl(kvm_state, KVM_SIGNAL_MSI, &msi); | 66 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); |
67 | /* with reasonable vector length */ | ||
68 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
69 | - env->vfp.zcr_el[1] = MIN(cpu->sve_max_vq - 1, 3); | ||
70 | + env->vfp.zcr_el[1] = | ||
71 | + aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1); | ||
72 | } | ||
73 | /* | ||
74 | * Enable TBI0 but not TBI1. | ||
75 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | ||
76 | QLIST_INIT(&cpu->pre_el_change_hooks); | ||
77 | QLIST_INIT(&cpu->el_change_hooks); | ||
78 | |||
79 | -#ifndef CONFIG_USER_ONLY | ||
80 | +#ifdef CONFIG_USER_ONLY | ||
81 | +# ifdef TARGET_AARCH64 | ||
82 | + /* | ||
83 | + * The linux kernel defaults to 512-bit vectors, when sve is supported. | ||
84 | + * See documentation for /proc/sys/abi/sve_default_vector_length, and | ||
85 | + * our corresponding sve-default-vector-length cpu property. | ||
86 | + */ | ||
87 | + cpu->sve_default_vq = 4; | ||
88 | +# endif | ||
89 | +#else | ||
90 | /* Our inbound IRQ and FIQ lines */ | ||
91 | if (kvm_enabled()) { | ||
92 | /* VIRQ and VFIQ are unused with KVM but we add them to maintain | ||
93 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/cpu64.c | ||
96 | +++ b/target/arm/cpu64.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) | ||
98 | cpu->isar.id_aa64pfr0 = t; | ||
90 | } | 99 | } |
91 | 100 | ||
92 | +/** | 101 | +#ifdef CONFIG_USER_ONLY |
93 | + * vm_change_state_handler - VM change state callback aiming at flushing | 102 | +/* Mirror linux /proc/sys/abi/sve_default_vector_length. */ |
94 | + * ITS tables into guest RAM | 103 | +static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, |
95 | + * | 104 | + const char *name, void *opaque, |
96 | + * The tables get flushed to guest RAM whenever the VM gets stopped. | 105 | + Error **errp) |
97 | + */ | ||
98 | +static void vm_change_state_handler(void *opaque, int running, | ||
99 | + RunState state) | ||
100 | +{ | 106 | +{ |
101 | + GICv3ITSState *s = (GICv3ITSState *)opaque; | 107 | + ARMCPU *cpu = ARM_CPU(obj); |
102 | + Error *err = NULL; | 108 | + int32_t default_len, default_vq, remainder; |
103 | + int ret; | ||
104 | + | 109 | + |
105 | + if (running) { | 110 | + if (!visit_type_int32(v, name, &default_len, errp)) { |
106 | + return; | 111 | + return; |
107 | + } | 112 | + } |
108 | + | 113 | + |
109 | + ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | 114 | + /* Undocumented, but the kernel allows -1 to indicate "maximum". */ |
110 | + KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err); | 115 | + if (default_len == -1) { |
111 | + if (err) { | 116 | + cpu->sve_default_vq = ARM_MAX_VQ; |
112 | + error_report_err(err); | ||
113 | + } | ||
114 | + if (ret < 0 && ret != -EFAULT) { | ||
115 | + abort(); | ||
116 | + } | ||
117 | +} | ||
118 | + | ||
119 | static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
120 | { | ||
121 | GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | ||
122 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
123 | kvm_msi_use_devid = true; | ||
124 | kvm_gsi_direct_mapping = false; | ||
125 | kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled(); | ||
126 | + | ||
127 | + qemu_add_vm_change_state_handler(vm_change_state_handler, s); | ||
128 | } | ||
129 | |||
130 | static void kvm_arm_its_init(Object *obj) | ||
131 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_init(Object *obj) | ||
132 | &error_abort); | ||
133 | } | ||
134 | |||
135 | +/** | ||
136 | + * kvm_arm_its_pre_save - handles the saving of ITS registers. | ||
137 | + * ITS tables are flushed into guest RAM separately and earlier, | ||
138 | + * through the VM change state handler, since at the moment pre_save() | ||
139 | + * is called, the guest RAM has already been saved. | ||
140 | + */ | ||
141 | +static void kvm_arm_its_pre_save(GICv3ITSState *s) | ||
142 | +{ | ||
143 | + int i; | ||
144 | + | ||
145 | + for (i = 0; i < 8; i++) { | ||
146 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
147 | + GITS_BASER + i * 8, &s->baser[i], false, | ||
148 | + &error_abort); | ||
149 | + } | ||
150 | + | ||
151 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
152 | + GITS_CTLR, &s->ctlr, false, &error_abort); | ||
153 | + | ||
154 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
155 | + GITS_CBASER, &s->cbaser, false, &error_abort); | ||
156 | + | ||
157 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
158 | + GITS_CREADR, &s->creadr, false, &error_abort); | ||
159 | + | ||
160 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
161 | + GITS_CWRITER, &s->cwriter, false, &error_abort); | ||
162 | + | ||
163 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
164 | + GITS_IIDR, &s->iidr, false, &error_abort); | ||
165 | +} | ||
166 | + | ||
167 | +/** | ||
168 | + * kvm_arm_its_post_load - Restore both the ITS registers and tables | ||
169 | + */ | ||
170 | +static void kvm_arm_its_post_load(GICv3ITSState *s) | ||
171 | +{ | ||
172 | + int i; | ||
173 | + | ||
174 | + if (!s->iidr) { | ||
175 | + return; | 117 | + return; |
176 | + } | 118 | + } |
177 | + | 119 | + |
178 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | 120 | + default_vq = default_len / 16; |
179 | + GITS_IIDR, &s->iidr, true, &error_abort); | 121 | + remainder = default_len % 16; |
180 | + | 122 | + |
181 | + /* | 123 | + /* |
182 | + * must be written before GITS_CREADR since GITS_CBASER write | 124 | + * Note that the 512 max comes from include/uapi/asm/sve_context.h |
183 | + * access resets GITS_CREADR. | 125 | + * and is the maximum architectural width of ZCR_ELx.LEN. |
184 | + */ | 126 | + */ |
185 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | 127 | + if (remainder || default_vq < 1 || default_vq > 512) { |
186 | + GITS_CBASER, &s->cbaser, true, &error_abort); | 128 | + error_setg(errp, "cannot set sve-default-vector-length"); |
187 | + | 129 | + if (remainder) { |
188 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | 130 | + error_append_hint(errp, "Vector length not a multiple of 16\n"); |
189 | + GITS_CREADR, &s->creadr, true, &error_abort); | 131 | + } else if (default_vq < 1) { |
190 | + | 132 | + error_append_hint(errp, "Vector length smaller than 16\n"); |
191 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | 133 | + } else { |
192 | + GITS_CWRITER, &s->cwriter, true, &error_abort); | 134 | + error_append_hint(errp, "Vector length larger than %d\n", |
193 | + | 135 | + 512 * 16); |
194 | + | 136 | + } |
195 | + for (i = 0; i < 8; i++) { | 137 | + return; |
196 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
197 | + GITS_BASER + i * 8, &s->baser[i], true, | ||
198 | + &error_abort); | ||
199 | + } | 138 | + } |
200 | + | 139 | + |
201 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | 140 | + cpu->sve_default_vq = default_vq; |
202 | + KVM_DEV_ARM_ITS_RESTORE_TABLES, NULL, true, | ||
203 | + &error_abort); | ||
204 | + | ||
205 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
206 | + GITS_CTLR, &s->ctlr, true, &error_abort); | ||
207 | +} | 141 | +} |
208 | + | 142 | + |
209 | static void kvm_arm_its_class_init(ObjectClass *klass, void *data) | 143 | +static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, |
144 | + const char *name, void *opaque, | ||
145 | + Error **errp) | ||
146 | +{ | ||
147 | + ARMCPU *cpu = ARM_CPU(obj); | ||
148 | + int32_t value = cpu->sve_default_vq * 16; | ||
149 | + | ||
150 | + visit_type_int32(v, name, &value, errp); | ||
151 | +} | ||
152 | +#endif | ||
153 | + | ||
154 | void aarch64_add_sve_properties(Object *obj) | ||
210 | { | 155 | { |
211 | DeviceClass *dc = DEVICE_CLASS(klass); | 156 | uint32_t vq; |
212 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_class_init(ObjectClass *klass, void *data) | 157 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) |
213 | 158 | object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | |
214 | dc->realize = kvm_arm_its_realize; | 159 | cpu_arm_set_sve_vq, NULL, NULL); |
215 | icc->send_msi = kvm_its_send_msi; | 160 | } |
216 | + icc->pre_save = kvm_arm_its_pre_save; | 161 | + |
217 | + icc->post_load = kvm_arm_its_post_load; | 162 | +#ifdef CONFIG_USER_ONLY |
163 | + /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
164 | + object_property_add(obj, "sve-default-vector-length", "int32", | ||
165 | + cpu_arm_get_sve_default_vec_len, | ||
166 | + cpu_arm_set_sve_default_vec_len, NULL, NULL); | ||
167 | +#endif | ||
218 | } | 168 | } |
219 | 169 | ||
220 | static const TypeInfo kvm_arm_its_info = { | 170 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) |
221 | -- | 171 | -- |
222 | 2.7.4 | 172 | 2.20.1 |
223 | 173 | ||
224 | 174 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Statements under 'case' were in some places wrongly indented bringing | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | confusion and making the code less readable. Remove also few unneeded | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | blank lines. No functional changes. | 5 | Message-id: 20210726150953.1218690-1-f4bug@amsat.org |
6 | |||
7 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 7 | --- |
12 | hw/timer/exynos4210_mct.c | 45 ++++++++++++++++++++------------------------- | 8 | hw/arm/nseries.c | 2 +- |
13 | 1 file changed, 20 insertions(+), 25 deletions(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 10 | ||
15 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | 11 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/timer/exynos4210_mct.c | 13 | --- a/hw/arm/nseries.c |
18 | +++ b/hw/timer/exynos4210_mct.c | 14 | +++ b/hw/arm/nseries.c |
19 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_mct_read(void *opaque, hwaddr offset, | 15 | @@ -XXX,XX +XXX,XX @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len) |
20 | 16 | default: | |
21 | case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3): | 17 | bad_cmd: |
22 | case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3): | 18 | qemu_log_mask(LOG_GUEST_ERROR, |
23 | - index = GET_G_COMP_IDX(offset); | 19 | - "%s: unknown command %02x\n", __func__, s->cmd); |
24 | - shift = 8 * (offset & 0x4); | 20 | + "%s: unknown command 0x%02x\n", __func__, s->cmd); |
25 | - value = UINT32_MAX & (s->g_timer.reg.comp[index] >> shift); | ||
26 | + index = GET_G_COMP_IDX(offset); | ||
27 | + shift = 8 * (offset & 0x4); | ||
28 | + value = UINT32_MAX & (s->g_timer.reg.comp[index] >> shift); | ||
29 | break; | ||
30 | |||
31 | case G_TCON: | ||
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_mct_read(void *opaque, hwaddr offset, | ||
33 | lt_i = GET_L_TIMER_IDX(offset); | ||
34 | |||
35 | value = exynos4210_lfrc_get_count(&s->l_timer[lt_i]); | ||
36 | - | ||
37 | break; | 21 | break; |
38 | 22 | } | |
39 | case L0_TCON: case L1_TCON: | ||
40 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
41 | |||
42 | case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3): | ||
43 | case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3): | ||
44 | - index = GET_G_COMP_IDX(offset); | ||
45 | - shift = 8 * (offset & 0x4); | ||
46 | - s->g_timer.reg.comp[index] = | ||
47 | - (s->g_timer.reg.comp[index] & | ||
48 | - (((uint64_t)UINT32_MAX << 32) >> shift)) + | ||
49 | - (value << shift); | ||
50 | + index = GET_G_COMP_IDX(offset); | ||
51 | + shift = 8 * (offset & 0x4); | ||
52 | + s->g_timer.reg.comp[index] = | ||
53 | + (s->g_timer.reg.comp[index] & | ||
54 | + (((uint64_t)UINT32_MAX << 32) >> shift)) + | ||
55 | + (value << shift); | ||
56 | |||
57 | - DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift); | ||
58 | + DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift); | ||
59 | |||
60 | - if (offset & 0x4) { | ||
61 | - s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index); | ||
62 | - } else { | ||
63 | - s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index); | ||
64 | - } | ||
65 | + if (offset & 0x4) { | ||
66 | + s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index); | ||
67 | + } else { | ||
68 | + s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index); | ||
69 | + } | ||
70 | |||
71 | - exynos4210_gfrc_restart(s); | ||
72 | - break; | ||
73 | + exynos4210_gfrc_restart(s); | ||
74 | + break; | ||
75 | |||
76 | case G_TCON: | ||
77 | old_val = s->g_timer.reg.tcon; | ||
78 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
79 | break; | ||
80 | |||
81 | case G_INT_ENB: | ||
82 | - | ||
83 | /* Raise IRQ if transition from disabled to enabled and CSTAT pending */ | ||
84 | for (i = 0; i < MCT_GT_CMP_NUM; i++) { | ||
85 | if ((value & G_INT_ENABLE(i)) > (s->g_timer.reg.tcon & | ||
86 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
87 | break; | ||
88 | |||
89 | case L0_TCNTB: case L1_TCNTB: | ||
90 | - | ||
91 | lt_i = GET_L_TIMER_IDX(offset); | ||
92 | index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); | ||
93 | |||
94 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
95 | break; | ||
96 | |||
97 | case L0_ICNTB: case L1_ICNTB: | ||
98 | - | ||
99 | lt_i = GET_L_TIMER_IDX(offset); | ||
100 | index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
103 | if (icntb_max[lt_i] < value) { | ||
104 | icntb_max[lt_i] = value; | ||
105 | } | ||
106 | -DPRINTF("local timer[%d] ICNTB write %llx; max=%x, min=%x\n\n", | ||
107 | - lt_i, value, icntb_max[lt_i], icntb_min[lt_i]); | ||
108 | + DPRINTF("local timer[%d] ICNTB write %llx; max=%x, min=%x\n\n", | ||
109 | + lt_i, value, icntb_max[lt_i], icntb_min[lt_i]); | ||
110 | #endif | ||
111 | -break; | ||
112 | + break; | ||
113 | |||
114 | case L0_FRCNTB: case L1_FRCNTB: | ||
115 | - | ||
116 | lt_i = GET_L_TIMER_IDX(offset); | ||
117 | index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); | ||
118 | 23 | ||
119 | -- | 24 | -- |
120 | 2.7.4 | 25 | 2.20.1 |
121 | 26 | ||
122 | 27 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | Bring some more readability by declaring local function variables: first | ||
4 | initialized ones and then the rest (with reversed-christmas-tree order). | ||
5 | |||
6 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/arm/exynos4210.c | 4 ++-- | ||
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/exynos4210.c | ||
16 | +++ b/hw/arm/exynos4210.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_calc_affinity(int cpu) | ||
18 | |||
19 | Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | ||
20 | { | ||
21 | - int i, n; | ||
22 | Exynos4210State *s = g_new(Exynos4210State, 1); | ||
23 | qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||
24 | - DeviceState *dev; | ||
25 | SysBusDevice *busdev; | ||
26 | ObjectClass *cpu_oc; | ||
27 | + DeviceState *dev; | ||
28 | + int i, n; | ||
29 | |||
30 | cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, "cortex-a9"); | ||
31 | assert(cpu_oc); | ||
32 | -- | ||
33 | 2.7.4 | ||
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Use a define for a9mpcore_priv device type name instead of hard-coded | 3 | The macro used to calculate the maximum memory size of the MMIO region |
4 | string. | 4 | had a mistake, causing all GPIO models to create a mapping of 0x9D8. |
5 | The intent was to have it be 0x9D8 - 0x800. | ||
5 | 6 | ||
6 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 7 | This extra size doesn't matter on ast2400 and ast2500, which have a 4KB |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | region set aside for the GPIO controller. |
9 | |||
10 | On the ast2600 the 3.3V and 1.8V GPIO controllers are 2KB apart, so the | ||
11 | regions would overlap. Worse was the 1.8V controller would map over the | ||
12 | top of the following peripheral, which happens to be the RTC. | ||
13 | |||
14 | The mmio region used by each device is a maximum of 2KB, so avoid the | ||
15 | calculations and hard code this as the maximum. | ||
16 | |||
17 | Fixes: 36d737ee82b2 ("hw/gpio: Add in AST2600 specific implementation") | ||
18 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
19 | Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
21 | Message-id: 20210713065854.134634-2-joel@jms.id.au | ||
22 | [PMM: fix autocorrect error in commit message] | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 24 | --- |
10 | hw/arm/exynos4210.c | 3 ++- | 25 | hw/gpio/aspeed_gpio.c | 3 +-- |
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | 26 | 1 file changed, 1 insertion(+), 2 deletions(-) |
12 | 27 | ||
13 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 28 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c |
14 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/exynos4210.c | 30 | --- a/hw/gpio/aspeed_gpio.c |
16 | +++ b/hw/arm/exynos4210.c | 31 | +++ b/hw/gpio/aspeed_gpio.c |
17 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ |
18 | #include "qemu-common.h" | 33 | #define GPIO_1_8V_MEM_SIZE 0x9D8 |
19 | #include "qemu/log.h" | 34 | #define GPIO_1_8V_REG_ARRAY_SIZE ((GPIO_1_8V_MEM_SIZE - \ |
20 | #include "cpu.h" | 35 | GPIO_1_8V_REG_OFFSET) >> 2) |
21 | +#include "hw/cpu/a9mpcore.h" | 36 | -#define GPIO_MAX_MEM_SIZE MAX(GPIO_3_6V_MEM_SIZE, GPIO_1_8V_MEM_SIZE) |
22 | #include "hw/boards.h" | 37 | |
23 | #include "sysemu/sysemu.h" | 38 | static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) |
24 | #include "hw/sysbus.h" | 39 | { |
25 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | 40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_realize(DeviceState *dev, Error **errp) |
26 | } | 41 | } |
27 | 42 | ||
28 | /* Private memory region and Internal GIC */ | 43 | memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s, |
29 | - dev = qdev_create(NULL, "a9mpcore_priv"); | 44 | - TYPE_ASPEED_GPIO, GPIO_MAX_MEM_SIZE); |
30 | + dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV); | 45 | + TYPE_ASPEED_GPIO, 0x800); |
31 | qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | 46 | |
32 | qdev_init_nofail(dev); | 47 | sysbus_init_mmio(sbd, &s->iomem); |
33 | busdev = SYS_BUS_DEVICE(dev); | 48 | } |
34 | -- | 49 | -- |
35 | 2.7.4 | 50 | 2.20.1 |
36 | 51 | ||
37 | 52 | diff view generated by jsdifflib |