1 | Target-arm queue... | 1 | Arm patch queue -- these are all bug fix patches but we might |
---|---|---|---|
2 | as well put them in to rc0... | ||
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 2c8cfc0b52b5a4d123c26c0b5fdf941be24805be: |
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/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000) |
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 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180319 |
13 | 14 | ||
14 | for you to fetch changes up to 252a7a6a968c279a4636a86b0559ba3a930a90b5: | 15 | for you to fetch changes up to ff72cb6b46b95bb530787add5277c211af3d31c6: |
15 | 16 | ||
16 | hw/intc/arm_gicv3_its: Allow save/restore (2017-06-13 14:57:01 +0100) | 17 | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs (2018-03-19 18:23:24 +0000) |
17 | 18 | ||
18 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
19 | target-arm queue: | 20 | target-arm queue: |
20 | * vITS: Support save/restore | 21 | * fsl-imx6: Fix incorrect Ethernet interrupt defines |
21 | * timer/aspeed: Fix timer enablement when reload is not set | 22 | * dump: Update correct kdump phys_base field for AArch64 |
22 | * aspped: add temperature sensor device | 23 | * char: i.MX: Add support for "TX complete" interrupt |
23 | * timer.h: Provide better monotonic time on ARM hosts | 24 | * bcm2836/raspi: Fix various bugs resulting in panics trying |
24 | * exynos4210: various cleanups | 25 | to boot a Debian Linux kernel on raspi3 |
25 | * exynos4210: support system poweroff | ||
26 | 26 | ||
27 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
28 | Cédric Le Goater (3): | 28 | Andrey Smirnov (2): |
29 | hw/misc: add a TMP42{1, 2, 3} device model | 29 | char: i.MX: Simplify imx_update() |
30 | aspeed: add a temp sensor device on I2C bus 3 | 30 | char: i.MX: Add support for "TX complete" interrupt |
31 | timer/aspeed: fix timer enablement when a reload is not set | ||
32 | 31 | ||
33 | Eric Auger (4): | 32 | Guenter Roeck (1): |
34 | kvm-all: Pass an error object to kvm_device_access | 33 | fsl-imx6: Swap Ethernet interrupt defines |
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 | 34 | ||
39 | Krzysztof Kozlowski (9): | 35 | Peter Maydell (9): |
40 | hw/intc/exynos4210_gic: Use more meaningful name for local variable | 36 | hw/arm/raspi: Don't do board-setup or secure-boot for raspi3 |
41 | hw/timer/exynos4210_mct: Fix checkpatch style errors | 37 | hw/arm/boot: assert that secure_boot and secure_board_setup are false for AArch64 |
42 | hw/timer/exynos4210_mct: Cleanup indentation and empty new lines | 38 | hw/arm/boot: If booting a kernel in EL2, set SCR_EL3.HCE |
43 | hw/timer/exynos4210_mct: Remove unused defines | 39 | hw/arm/bcm2386: Fix parent type of bcm2386 |
44 | hw/arm/exynos: Move DRAM initialization next boards | 40 | hw/arm/bcm2836: Rename bcm2836 type/struct to bcm283x |
45 | hw/arm/exynos: Declare local variables in some order | 41 | hw/arm/bcm2836: Create proper bcm2837 device |
46 | hw/arm/exynos: Use type define instead of hard-coded a9mpcore_priv string | 42 | hw/arm/bcm2836: Use correct affinity values for BCM2837 |
47 | hw/intc/exynos4210_gic: Constify array of combiner interrupts | 43 | hw/arm/bcm2836: Hardcode correct CPU type |
48 | hw/misc/exynos4210_pmu: Add support for system poweroff | 44 | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs |
49 | 45 | ||
50 | Pranith Kumar (1): | 46 | Wei Huang (1): |
51 | timer.h: Provide better monotonic time | 47 | dump: Update correct kdump phys_base field for AArch64 |
52 | 48 | ||
53 | hw/misc/Makefile.objs | 1 + | 49 | include/hw/arm/bcm2836.h | 31 +++++++++++++--- |
54 | include/hw/arm/exynos4210.h | 5 +- | 50 | include/hw/arm/fsl-imx6.h | 4 +- |
55 | include/hw/intc/arm_gicv3_its_common.h | 8 + | 51 | include/hw/char/imx_serial.h | 3 ++ |
56 | include/migration/vmstate.h | 2 + | 52 | dump.c | 14 +++++-- |
57 | include/qemu/timer.h | 5 +- | 53 | hw/arm/bcm2836.c | 87 +++++++++++++++++++++++++++++++------------- |
58 | include/sysemu/kvm.h | 11 +- | 54 | hw/arm/boot.c | 12 ++++++ |
59 | hw/arm/aspeed.c | 9 + | 55 | hw/arm/raspi.c | 77 +++++++++++++++++++++++++++++++-------- |
60 | hw/arm/exynos4210.c | 27 +-- | 56 | hw/char/imx_serial.c | 44 ++++++++++++++++------ |
61 | hw/arm/exynos4_boards.c | 50 +++- | 57 | hw/net/imx_fec.c | 28 +++++++++++++- |
62 | hw/intc/arm_gic_kvm.c | 9 +- | 58 | 9 files changed, 237 insertions(+), 63 deletions(-) |
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 | 59 | 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 |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | Statements under 'case' were in some places wrongly indented bringing | ||
4 | confusion and making the code less readable. Remove also few unneeded | ||
5 | blank lines. No functional changes. | ||
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> | ||
11 | --- | ||
12 | hw/timer/exynos4210_mct.c | 45 ++++++++++++++++++++------------------------- | ||
13 | 1 file changed, 20 insertions(+), 25 deletions(-) | ||
14 | |||
15 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/timer/exynos4210_mct.c | ||
18 | +++ b/hw/timer/exynos4210_mct.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_mct_read(void *opaque, hwaddr offset, | ||
20 | |||
21 | case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3): | ||
22 | case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3): | ||
23 | - index = GET_G_COMP_IDX(offset); | ||
24 | - shift = 8 * (offset & 0x4); | ||
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; | ||
38 | |||
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 | |||
119 | -- | ||
120 | 2.7.4 | ||
121 | |||
122 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | We change the restoration priority of both the GICv3 and ITS. The | 3 | The sabrelite machine model used by qemu-system-arm is based on the |
4 | GICv3 must be restored before the ITS and the ITS needs to be restored | 4 | Freescale/NXP i.MX6Q processor. This SoC has an on-board ethernet |
5 | before PCIe devices since it translates their MSI transactions. | 5 | controller which is supported in QEMU using the imx_fec.c module |
6 | (actually called imx.enet for this model.) | ||
6 | 7 | ||
7 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 8 | The include/hw/arm/fsm-imx6.h file defines the interrupt vectors for the |
8 | Reviewed-by: Juan Quintela <quintela@redhat.com> | 9 | imx.enet device like this: |
9 | Message-id: 1497023553-18411-5-git-send-email-eric.auger@redhat.com | 10 | |
11 | #define FSL_IMX6_ENET_MAC_1588_IRQ 118 | ||
12 | #define FSL_IMX6_ENET_MAC_IRQ 119 | ||
13 | |||
14 | According to https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf, | ||
15 | page 225, in Table 3-1. ARM Cortex A9 domain interrupt summary, | ||
16 | interrupts are as follows. | ||
17 | |||
18 | 150 ENET MAC 0 IRQ | ||
19 | 151 ENET MAC 0 1588 Timer interrupt | ||
20 | |||
21 | where | ||
22 | |||
23 | 150 - 32 == 118 | ||
24 | 151 - 32 == 119 | ||
25 | |||
26 | In other words, the vector definitions in the fsl-imx6.h file are reversed. | ||
27 | |||
28 | Fixing the interrupts alone causes problems with older Linux kernels: | ||
29 | The Ethernet interface will fail to probe with Linux v4.9 and earlier. | ||
30 | Linux v4.1 and earlier will crash due to a bug in Ethernet driver probe | ||
31 | error handling. This is a Linux kernel problem, not a qemu problem: | ||
32 | the Linux kernel only worked by accident since it requested both interrupts. | ||
33 | |||
34 | For backward compatibility, generate the Ethernet interrupt on both interrupt | ||
35 | lines. This was shown to work from all Linux kernel releases starting with | ||
36 | v3.16. | ||
37 | |||
38 | Link: https://bugs.launchpad.net/qemu/+bug/1753309 | ||
39 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
40 | Message-id: 1520723090-22130-1-git-send-email-linux@roeck-us.net | ||
41 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 42 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 43 | --- |
12 | include/migration/vmstate.h | 2 ++ | 44 | include/hw/arm/fsl-imx6.h | 4 ++-- |
13 | hw/intc/arm_gicv3_common.c | 1 + | 45 | hw/net/imx_fec.c | 28 +++++++++++++++++++++++++++- |
14 | hw/intc/arm_gicv3_its_common.c | 2 +- | 46 | 2 files changed, 29 insertions(+), 3 deletions(-) |
15 | hw/intc/arm_gicv3_its_kvm.c | 24 ++++++++++++------------ | ||
16 | 4 files changed, 16 insertions(+), 13 deletions(-) | ||
17 | 47 | ||
18 | diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h | 48 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h |
19 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/migration/vmstate.h | 50 | --- a/include/hw/arm/fsl-imx6.h |
21 | +++ b/include/migration/vmstate.h | 51 | +++ b/include/hw/arm/fsl-imx6.h |
22 | @@ -XXX,XX +XXX,XX @@ enum VMStateFlags { | 52 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State { |
23 | typedef enum { | 53 | #define FSL_IMX6_HDMI_MASTER_IRQ 115 |
24 | MIG_PRI_DEFAULT = 0, | 54 | #define FSL_IMX6_HDMI_CEC_IRQ 116 |
25 | MIG_PRI_IOMMU, /* Must happen before PCI devices */ | 55 | #define FSL_IMX6_MLB150_LOW_IRQ 117 |
26 | + MIG_PRI_GICV3_ITS, /* Must happen before PCI devices */ | 56 | -#define FSL_IMX6_ENET_MAC_1588_IRQ 118 |
27 | + MIG_PRI_GICV3, /* Must happen before the ITS */ | 57 | -#define FSL_IMX6_ENET_MAC_IRQ 119 |
28 | MIG_PRI_MAX, | 58 | +#define FSL_IMX6_ENET_MAC_IRQ 118 |
29 | } MigrationPriority; | 59 | +#define FSL_IMX6_ENET_MAC_1588_IRQ 119 |
30 | 60 | #define FSL_IMX6_PCIE1_IRQ 120 | |
31 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | 61 | #define FSL_IMX6_PCIE2_IRQ 121 |
62 | #define FSL_IMX6_PCIE3_IRQ 122 | ||
63 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 64 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/hw/intc/arm_gicv3_common.c | 65 | --- a/hw/net/imx_fec.c |
34 | +++ b/hw/intc/arm_gicv3_common.c | 66 | +++ b/hw/net/imx_fec.c |
35 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3 = { | 67 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr) |
36 | .minimum_version_id = 1, | 68 | |
37 | .pre_save = gicv3_pre_save, | 69 | static void imx_eth_update(IMXFECState *s) |
38 | .post_load = gicv3_post_load, | 70 | { |
39 | + .priority = MIG_PRI_GICV3, | 71 | - if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & ENET_INT_TS_TIMER) { |
40 | .fields = (VMStateField[]) { | 72 | + /* |
41 | VMSTATE_UINT32(gicd_ctlr, GICv3State), | 73 | + * Previous versions of qemu had the ENET_INT_MAC and ENET_INT_TS_TIMER |
42 | VMSTATE_UINT32_ARRAY(gicd_statusr, GICv3State, 2), | 74 | + * interrupts swapped. This worked with older versions of Linux (4.14 |
43 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | 75 | + * and older) since Linux associated both interrupt lines with Ethernet |
44 | index XXXXXXX..XXXXXXX 100644 | 76 | + * MAC interrupts. Specifically, |
45 | --- a/hw/intc/arm_gicv3_its_common.c | 77 | + * - Linux 4.15 and later have separate interrupt handlers for the MAC and |
46 | +++ b/hw/intc/arm_gicv3_its_common.c | 78 | + * timer interrupts. Those versions of Linux fail with versions of QEMU |
47 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_its = { | 79 | + * with swapped interrupt assignments. |
48 | .name = "arm_gicv3_its", | 80 | + * - In linux 4.14, both interrupt lines were registered with the Ethernet |
49 | .pre_save = gicv3_its_pre_save, | 81 | + * MAC interrupt handler. As a result, all versions of qemu happen to |
50 | .post_load = gicv3_its_post_load, | 82 | + * work, though that is accidental. |
51 | - .unmigratable = true, | 83 | + * - In Linux 4.9 and older, the timer interrupt was registered directly |
52 | + .priority = MIG_PRI_GICV3_ITS, | 84 | + * with the Ethernet MAC interrupt handler. The MAC interrupt was |
53 | .fields = (VMStateField[]) { | 85 | + * redirected to a GPIO interrupt to work around erratum ERR006687. |
54 | VMSTATE_UINT32(ctlr, GICv3ITSState), | 86 | + * This was implemented using the SOC's IOMUX block. In qemu, this GPIO |
55 | VMSTATE_UINT32(iidr, GICv3ITSState), | 87 | + * interrupt never fired since IOMUX is currently not supported in qemu. |
56 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | 88 | + * Linux instead received MAC interrupts on the timer interrupt. |
57 | index XXXXXXX..XXXXXXX 100644 | 89 | + * As a result, qemu versions with the swapped interrupt assignment work, |
58 | --- a/hw/intc/arm_gicv3_its_kvm.c | 90 | + * albeit accidentally, but qemu versions with the correct interrupt |
59 | +++ b/hw/intc/arm_gicv3_its_kvm.c | 91 | + * assignment fail. |
60 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | 92 | + * |
61 | GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | 93 | + * To ensure that all versions of Linux work, generate ENET_INT_MAC |
62 | Error *local_err = NULL; | 94 | + * interrrupts on both interrupt lines. This should be changed if and when |
63 | 95 | + * qemu supports IOMUX. | |
64 | - /* | 96 | + */ |
65 | - * Block migration of a KVM GICv3 ITS device: the API for saving and | 97 | + if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & |
66 | - * restoring the state in the kernel is not yet available | 98 | + (ENET_INT_MAC | ENET_INT_TS_TIMER)) { |
67 | - */ | 99 | qemu_set_irq(s->irq[1], 1); |
68 | - error_setg(&s->migration_blocker, "vITS migration is not implemented"); | 100 | } else { |
69 | - migrate_add_blocker(s->migration_blocker, &local_err); | 101 | qemu_set_irq(s->irq[1], 0); |
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 | + | ||
95 | kvm_msi_use_devid = true; | ||
96 | kvm_gsi_direct_mapping = false; | ||
97 | kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled(); | ||
98 | -- | 102 | -- |
99 | 2.7.4 | 103 | 2.16.2 |
100 | 104 | ||
101 | 105 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Wei Huang <wei@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | When a timer is enabled before a reload value is set, the controller | 3 | For guest kernel that supports KASLR, the load address can change every |
4 | waits for a reload value to be set before starting decrementing. This | 4 | time when guest VM runs. To find the physical base address correctly, |
5 | fix tries to cover that case by changing the timer expiry only when | 5 | current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=". |
6 | a reload value is valid. | 6 | However this string pattern is only available on x86_64. AArch64 uses a |
7 | different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure | ||
8 | QEMU dump uses the correct string on AArch64. | ||
7 | 9 | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 10 | Signed-off-by: Wei Huang <wei@redhat.com> |
9 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | 11 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> |
10 | Message-id: 1496739312-32304-1-git-send-email-clg@kaod.org | 12 | Message-id: 1520615003-20869-1-git-send-email-wei@redhat.com |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 14 | --- |
13 | hw/timer/aspeed_timer.c | 37 +++++++++++++++++++++++++++++-------- | 15 | dump.c | 14 +++++++++++--- |
14 | 1 file changed, 29 insertions(+), 8 deletions(-) | 16 | 1 file changed, 11 insertions(+), 3 deletions(-) |
15 | 17 | ||
16 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | 18 | diff --git a/dump.c b/dump.c |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/timer/aspeed_timer.c | 20 | --- a/dump.c |
19 | +++ b/hw/timer/aspeed_timer.c | 21 | +++ b/dump.c |
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) | 22 | @@ -XXX,XX +XXX,XX @@ static void vmcoreinfo_update_phys_base(DumpState *s) |
21 | next = seq[1]; | 23 | |
22 | } else if (now < seq[2]) { | 24 | lines = g_strsplit((char *)vmci, "\n", -1); |
23 | next = seq[2]; | 25 | for (i = 0; lines[i]; i++) { |
24 | - } else { | 26 | - if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) { |
25 | + } else if (t->reload) { | 27 | - if (qemu_strtou64(lines[i] + 18, NULL, 16, |
26 | reload_ns = muldiv64(t->reload, NANOSECONDS_PER_SECOND, rate); | 28 | + const char *prefix = NULL; |
27 | t->start = now - ((now - t->start) % reload_ns); | ||
28 | + } else { | ||
29 | + /* no reload value, return 0 */ | ||
30 | + break; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | return next; | ||
35 | } | ||
36 | |||
37 | +static void aspeed_timer_mod(AspeedTimer *t) | ||
38 | +{ | ||
39 | + uint64_t next = calculate_next(t); | ||
40 | + if (next) { | ||
41 | + timer_mod(&t->timer, next); | ||
42 | + } | ||
43 | +} | ||
44 | + | 29 | + |
45 | static void aspeed_timer_expire(void *opaque) | 30 | + if (s->dump_info.d_machine == EM_X86_64) { |
46 | { | 31 | + prefix = "NUMBER(phys_base)="; |
47 | AspeedTimer *t = opaque; | 32 | + } else if (s->dump_info.d_machine == EM_AARCH64) { |
48 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_expire(void *opaque) | 33 | + prefix = "NUMBER(PHYS_OFFSET)="; |
49 | qemu_set_irq(t->irq, t->level); | ||
50 | } | ||
51 | |||
52 | - timer_mod(&t->timer, calculate_next(t)); | ||
53 | + aspeed_timer_mod(t); | ||
54 | } | ||
55 | |||
56 | static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg) | ||
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 | + } | 34 | + } |
77 | + | 35 | + |
78 | case TIMER_REG_STATUS: | 36 | + if (prefix && g_str_has_prefix(lines[i], prefix)) { |
79 | if (timer_enabled(t)) { | 37 | + if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16, |
80 | uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 38 | &phys_base) < 0) { |
81 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, | 39 | - warn_report("Failed to read NUMBER(phys_base)="); |
82 | uint32_t rate = calculate_rate(t); | 40 | + warn_report("Failed to read %s", prefix); |
83 | 41 | } else { | |
84 | t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); | 42 | s->dump_info.phys_base = phys_base; |
85 | - timer_mod(&t->timer, calculate_next(t)); | 43 | } |
86 | + aspeed_timer_mod(t); | ||
87 | } | ||
88 | break; | ||
89 | - case TIMER_REG_RELOAD: | ||
90 | - t->reload = value; | ||
91 | - break; | ||
92 | case TIMER_REG_MATCH_FIRST: | ||
93 | case TIMER_REG_MATCH_SECOND: | ||
94 | t->match[reg - 2] = value; | ||
95 | if (timer_enabled(t)) { | ||
96 | - timer_mod(&t->timer, calculate_next(t)); | ||
97 | + aspeed_timer_mod(t); | ||
98 | } | ||
99 | break; | ||
100 | default: | ||
101 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_ctrl_enable(AspeedTimer *t, bool enable) | ||
102 | trace_aspeed_timer_ctrl_enable(t->id, enable); | ||
103 | if (enable) { | ||
104 | t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
105 | - timer_mod(&t->timer, calculate_next(t)); | ||
106 | + aspeed_timer_mod(t); | ||
107 | } else { | ||
108 | timer_del(&t->timer); | ||
109 | } | ||
110 | -- | 44 | -- |
111 | 2.7.4 | 45 | 2.16.2 |
112 | 46 | ||
113 | 47 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | We need to handle both registers and ITS tables. While | 3 | Code of imx_update() is slightly confusing since the "flags" variable |
4 | register handling is standard, ITS table handling is more | 4 | doesn't really corespond to anything in real hardware and server as a |
5 | challenging since the kernel API is devised so that the | 5 | kitchensink accumulating events normally reported via USR1 and USR2 |
6 | tables are flushed into guest RAM and not in vmstate buffers. | 6 | registers. |
7 | 7 | ||
8 | Flushing the ITS tables on device pre_save() is too late | 8 | Change the code to explicitly evaluate state of interrupts reported |
9 | since the guest RAM is already saved at this point. | 9 | via USR1 and USR2 against corresponding masking bits and use the to |
10 | detemine if IRQ line should be asserted or not. | ||
10 | 11 | ||
11 | Table flushing needs to happen when we are sure the vcpus | 12 | NOTE: Check for UTS1_TXEMPTY being set has been dropped for two |
12 | are stopped and before the last dirty page saving. The | 13 | reasons: |
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 | 14 | ||
17 | For regular ITS registers we just can use vmstate pre_save() | 15 | 1. Emulation code implements a single character FIFO, so this flag |
18 | and post_load() callbacks. | 16 | will always be set since characters are trasmitted as a part of |
17 | the code emulating "push" into the FIFO | ||
19 | 18 | ||
20 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 19 | 2. imx_update() is really just a function doing ORing and maksing |
21 | Message-id: 1497023553-18411-3-git-send-email-eric.auger@redhat.com | 20 | of reported events, so checking for UTS1_TXEMPTY should happen, |
21 | if it's ever really needed should probably happen outside of | ||
22 | it. | ||
23 | |||
24 | Cc: qemu-devel@nongnu.org | ||
25 | Cc: qemu-arm@nongnu.org | ||
26 | Cc: Bill Paul <wpaul@windriver.com> | ||
27 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
28 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
29 | Message-id: 20180315191141.6789-1-andrew.smirnov@gmail.com | ||
22 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 30 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | --- | 32 | --- |
25 | include/hw/intc/arm_gicv3_its_common.h | 8 +++ | 33 | hw/char/imx_serial.c | 24 ++++++++++++++++-------- |
26 | hw/intc/arm_gicv3_its_common.c | 10 ++++ | 34 | 1 file changed, 16 insertions(+), 8 deletions(-) |
27 | hw/intc/arm_gicv3_its_kvm.c | 105 +++++++++++++++++++++++++++++++++ | ||
28 | 3 files changed, 123 insertions(+) | ||
29 | 35 | ||
30 | diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_gicv3_its_common.h | 36 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c |
31 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/include/hw/intc/arm_gicv3_its_common.h | 38 | --- a/hw/char/imx_serial.c |
33 | +++ b/include/hw/intc/arm_gicv3_its_common.h | 39 | +++ b/hw/char/imx_serial.c |
34 | @@ -XXX,XX +XXX,XX @@ | 40 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = { |
35 | #define ITS_TRANS_SIZE 0x10000 | 41 | |
36 | #define ITS_SIZE (ITS_CONTROL_SIZE + ITS_TRANS_SIZE) | 42 | static void imx_update(IMXSerialState *s) |
37 | 43 | { | |
38 | +#define GITS_CTLR 0x0 | 44 | - uint32_t flags; |
39 | +#define GITS_IIDR 0x4 | 45 | + uint32_t usr1; |
40 | +#define GITS_CBASER 0x80 | 46 | + uint32_t usr2; |
41 | +#define GITS_CWRITER 0x88 | 47 | + uint32_t mask; |
42 | +#define GITS_CREADR 0x90 | 48 | |
43 | +#define GITS_BASER 0x100 | 49 | - flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY); |
44 | + | 50 | - if (s->ucr1 & UCR1_TXMPTYEN) { |
45 | struct GICv3ITSState { | 51 | - flags |= (s->uts1 & UTS1_TXEMPTY); |
46 | SysBusDevice parent_obj; | 52 | - } else { |
47 | 53 | - flags &= ~USR1_TRDY; | |
48 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSState { | 54 | - } |
49 | 55 | + /* | |
50 | /* Registers */ | 56 | + * Lucky for us TRDY and RRDY has the same offset in both USR1 and |
51 | uint32_t ctlr; | 57 | + * UCR1, so we can get away with something as simple as the |
52 | + uint32_t iidr; | 58 | + * following: |
53 | uint64_t cbaser; | 59 | + */ |
54 | uint64_t cwriter; | 60 | + usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY); |
55 | uint64_t creadr; | 61 | + /* |
56 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | 62 | + * Bits that we want in USR2 are not as conveniently laid out, |
57 | index XXXXXXX..XXXXXXX 100644 | 63 | + * unfortunately. |
58 | --- a/hw/intc/arm_gicv3_its_common.c | 64 | + */ |
59 | +++ b/hw/intc/arm_gicv3_its_common.c | 65 | + mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; |
60 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_its = { | 66 | + usr2 = s->usr2 & mask; |
61 | .pre_save = gicv3_its_pre_save, | 67 | |
62 | .post_load = gicv3_its_post_load, | 68 | - qemu_set_irq(s->irq, !!flags); |
63 | .unmigratable = true, | 69 | + qemu_set_irq(s->irq, usr1 || usr2); |
64 | + .fields = (VMStateField[]) { | ||
65 | + VMSTATE_UINT32(ctlr, GICv3ITSState), | ||
66 | + VMSTATE_UINT32(iidr, GICv3ITSState), | ||
67 | + VMSTATE_UINT64(cbaser, GICv3ITSState), | ||
68 | + VMSTATE_UINT64(cwriter, GICv3ITSState), | ||
69 | + VMSTATE_UINT64(creadr, GICv3ITSState), | ||
70 | + VMSTATE_UINT64_ARRAY(baser, GICv3ITSState, 8), | ||
71 | + VMSTATE_END_OF_LIST() | ||
72 | + }, | ||
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 | ||
86 | --- a/hw/intc/arm_gicv3_its_kvm.c | ||
87 | +++ b/hw/intc/arm_gicv3_its_kvm.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint16_t devid) | ||
89 | return kvm_vm_ioctl(kvm_state, KVM_SIGNAL_MSI, &msi); | ||
90 | } | 70 | } |
91 | 71 | ||
92 | +/** | 72 | static void imx_serial_reset(IMXSerialState *s) |
93 | + * vm_change_state_handler - VM change state callback aiming at flushing | ||
94 | + * ITS tables into guest RAM | ||
95 | + * | ||
96 | + * The tables get flushed to guest RAM whenever the VM gets stopped. | ||
97 | + */ | ||
98 | +static void vm_change_state_handler(void *opaque, int running, | ||
99 | + RunState state) | ||
100 | +{ | ||
101 | + GICv3ITSState *s = (GICv3ITSState *)opaque; | ||
102 | + Error *err = NULL; | ||
103 | + int ret; | ||
104 | + | ||
105 | + if (running) { | ||
106 | + return; | ||
107 | + } | ||
108 | + | ||
109 | + ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
110 | + KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err); | ||
111 | + if (err) { | ||
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; | ||
176 | + } | ||
177 | + | ||
178 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
179 | + GITS_IIDR, &s->iidr, true, &error_abort); | ||
180 | + | ||
181 | + /* | ||
182 | + * must be written before GITS_CREADR since GITS_CBASER write | ||
183 | + * access resets GITS_CREADR. | ||
184 | + */ | ||
185 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
186 | + GITS_CBASER, &s->cbaser, true, &error_abort); | ||
187 | + | ||
188 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
189 | + GITS_CREADR, &s->creadr, true, &error_abort); | ||
190 | + | ||
191 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
192 | + GITS_CWRITER, &s->cwriter, true, &error_abort); | ||
193 | + | ||
194 | + | ||
195 | + for (i = 0; i < 8; i++) { | ||
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 | + } | ||
200 | + | ||
201 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
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 | +} | ||
208 | + | ||
209 | static void kvm_arm_its_class_init(ObjectClass *klass, void *data) | ||
210 | { | ||
211 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
212 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_class_init(ObjectClass *klass, void *data) | ||
213 | |||
214 | dc->realize = kvm_arm_its_realize; | ||
215 | icc->send_msi = kvm_its_send_msi; | ||
216 | + icc->pre_save = kvm_arm_its_pre_save; | ||
217 | + icc->post_load = kvm_arm_its_post_load; | ||
218 | } | ||
219 | |||
220 | static const TypeInfo kvm_arm_its_info = { | ||
221 | -- | 73 | -- |
222 | 2.7.4 | 74 | 2.16.2 |
223 | 75 | ||
224 | 76 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Remove defines not used anywhere. | 3 | Add support for "TX complete"/TXDC interrupt generate by real HW since |
4 | it is needed to support guests other than Linux. | ||
4 | 5 | ||
5 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 6 | Based on the patch by Bill Paul as found here: |
7 | https://bugs.launchpad.net/qemu/+bug/1753314 | ||
8 | |||
9 | Cc: qemu-devel@nongnu.org | ||
10 | Cc: qemu-arm@nongnu.org | ||
11 | Cc: Bill Paul <wpaul@windriver.com> | ||
12 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Bill Paul <wpaul@windriver.com> | ||
14 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
15 | Message-id: 20180315191141.6789-2-andrew.smirnov@gmail.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 18 | --- |
9 | hw/timer/exynos4210_mct.c | 3 --- | 19 | include/hw/char/imx_serial.h | 3 +++ |
10 | 1 file changed, 3 deletions(-) | 20 | hw/char/imx_serial.c | 20 +++++++++++++++++--- |
21 | 2 files changed, 20 insertions(+), 3 deletions(-) | ||
11 | 22 | ||
12 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | 23 | diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h |
13 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/timer/exynos4210_mct.c | 25 | --- a/include/hw/char/imx_serial.h |
15 | +++ b/hw/timer/exynos4210_mct.c | 26 | +++ b/include/hw/char/imx_serial.h |
16 | @@ -XXX,XX +XXX,XX @@ enum LocalTimerRegCntIndexes { | 27 | @@ -XXX,XX +XXX,XX @@ |
17 | L_REG_CNT_AMOUNT | 28 | #define UCR2_RXEN (1<<1) /* Receiver enable */ |
29 | #define UCR2_SRST (1<<0) /* Reset complete */ | ||
30 | |||
31 | +#define UCR4_TCEN BIT(3) /* TX complete interrupt enable */ | ||
32 | + | ||
33 | #define UTS1_TXEMPTY (1<<6) | ||
34 | #define UTS1_RXEMPTY (1<<5) | ||
35 | #define UTS1_TXFULL (1<<4) | ||
36 | @@ -XXX,XX +XXX,XX @@ typedef struct IMXSerialState { | ||
37 | uint32_t ubmr; | ||
38 | uint32_t ubrc; | ||
39 | uint32_t ucr3; | ||
40 | + uint32_t ucr4; | ||
41 | |||
42 | qemu_irq irq; | ||
43 | CharBackend chr; | ||
44 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/char/imx_serial.c | ||
47 | +++ b/hw/char/imx_serial.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | |||
50 | static const VMStateDescription vmstate_imx_serial = { | ||
51 | .name = TYPE_IMX_SERIAL, | ||
52 | - .version_id = 1, | ||
53 | - .minimum_version_id = 1, | ||
54 | + .version_id = 2, | ||
55 | + .minimum_version_id = 2, | ||
56 | .fields = (VMStateField[]) { | ||
57 | VMSTATE_INT32(readbuff, IMXSerialState), | ||
58 | VMSTATE_UINT32(usr1, IMXSerialState), | ||
59 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = { | ||
60 | VMSTATE_UINT32(ubmr, IMXSerialState), | ||
61 | VMSTATE_UINT32(ubrc, IMXSerialState), | ||
62 | VMSTATE_UINT32(ucr3, IMXSerialState), | ||
63 | + VMSTATE_UINT32(ucr4, IMXSerialState), | ||
64 | VMSTATE_END_OF_LIST() | ||
65 | }, | ||
18 | }; | 66 | }; |
19 | 67 | @@ -XXX,XX +XXX,XX @@ static void imx_update(IMXSerialState *s) | |
20 | -#define MCT_NIRQ 6 | 68 | * unfortunately. |
21 | #define MCT_SFR_SIZE 0x444 | 69 | */ |
22 | 70 | mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; | |
23 | #define MCT_GT_CMP_NUM 4 | 71 | + /* |
24 | 72 | + * TCEN and TXDC are both bit 3 | |
25 | -#define MCT_GT_MAX_VAL UINT64_MAX | 73 | + */ |
26 | - | 74 | + mask |= s->ucr4 & UCR4_TCEN; |
27 | #define MCT_GT_COUNTER_STEP 0x100000000ULL | 75 | + |
28 | #define MCT_LT_COUNTER_STEP 0x100000000ULL | 76 | usr2 = s->usr2 & mask; |
29 | #define MCT_LT_CNT_LOW_LIMIT 0x100 | 77 | |
78 | qemu_set_irq(s->irq, usr1 || usr2); | ||
79 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset, | ||
80 | return s->ucr3; | ||
81 | |||
82 | case 0x23: /* UCR4 */ | ||
83 | + return s->ucr4; | ||
84 | + | ||
85 | case 0x29: /* BRM Incremental */ | ||
86 | return 0x0; /* TODO */ | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset, | ||
89 | * qemu_chr_fe_write and background I/O callbacks */ | ||
90 | qemu_chr_fe_write_all(&s->chr, &ch, 1); | ||
91 | s->usr1 &= ~USR1_TRDY; | ||
92 | + s->usr2 &= ~USR2_TXDC; | ||
93 | imx_update(s); | ||
94 | s->usr1 |= USR1_TRDY; | ||
95 | + s->usr2 |= USR2_TXDC; | ||
96 | imx_update(s); | ||
97 | } | ||
98 | break; | ||
99 | @@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset, | ||
100 | s->ucr3 = value & 0xffff; | ||
101 | break; | ||
102 | |||
103 | - case 0x2d: /* UTS1 */ | ||
104 | case 0x23: /* UCR4 */ | ||
105 | + s->ucr4 = value & 0xffff; | ||
106 | + imx_update(s); | ||
107 | + break; | ||
108 | + | ||
109 | + case 0x2d: /* UTS1 */ | ||
110 | qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%" | ||
111 | HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset); | ||
112 | /* TODO */ | ||
30 | -- | 113 | -- |
31 | 2.7.4 | 114 | 2.16.2 |
32 | 115 | ||
33 | 116 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | For the rpi1 and 2 we want to boot the Linux kernel via some |
---|---|---|---|
2 | custom setup code that makes sure that the SMC instruction | ||
3 | acts as a no-op, because it's used for cache maintenance. | ||
4 | The rpi3 boots AArch64 kernels, which don't need SMC for | ||
5 | cache maintenance and always expect to be booted non-secure. | ||
6 | Don't fill in the aarch32-specific parts of the binfo struct. | ||
2 | 7 | ||
3 | Temperatures can be changed from the monitor with : | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20180313153458.26822-2-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/arm/raspi.c | 17 +++++++++++++---- | ||
14 | 1 file changed, 13 insertions(+), 4 deletions(-) | ||
4 | 15 | ||
5 | (qemu) qom-set /machine/unattached/device[2] temperature0 12000 | 16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
6 | |||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
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 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/aspeed.c | 18 | --- a/hw/arm/raspi.c |
18 | +++ b/hw/arm/aspeed.c | 19 | +++ b/hw/arm/raspi.c |
19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 20 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
20 | static void palmetto_bmc_i2c_init(AspeedBoardState *bmc) | 21 | binfo.board_id = raspi_boardid[version]; |
21 | { | 22 | binfo.ram_size = ram_size; |
22 | AspeedSoCState *soc = &bmc->soc; | 23 | binfo.nb_cpus = smp_cpus; |
23 | + DeviceState *dev; | 24 | - binfo.board_setup_addr = BOARDSETUP_ADDR; |
24 | 25 | - binfo.write_board_setup = write_board_setup; | |
25 | /* The palmetto platform expects a ds3231 RTC but a ds1338 is | 26 | - binfo.secure_board_setup = true; |
26 | * enough to provide basic RTC features. Alarms will be missing */ | 27 | - binfo.secure_boot = true; |
27 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68); | ||
28 | + | 28 | + |
29 | + /* add a TMP423 temperature sensor */ | 29 | + if (version <= 2) { |
30 | + dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), | 30 | + /* The rpi1 and 2 require some custom setup code to run in Secure |
31 | + "tmp423", 0x4c); | 31 | + * mode before booting a kernel (to set up the SMC vectors so |
32 | + object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abort); | 32 | + * that we get a no-op SMC; this is used by Linux to call the |
33 | + object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abort); | 33 | + * firmware for some cache maintenance operations. |
34 | + object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abort); | 34 | + * The rpi3 doesn't need this. |
35 | + object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort); | 35 | + */ |
36 | } | 36 | + binfo.board_setup_addr = BOARDSETUP_ADDR; |
37 | 37 | + binfo.write_board_setup = write_board_setup; | |
38 | static void palmetto_bmc_init(MachineState *machine) | 38 | + binfo.secure_board_setup = true; |
39 | + binfo.secure_boot = true; | ||
40 | + } | ||
41 | |||
42 | /* Pi2 and Pi3 requires SMP setup */ | ||
43 | if (version >= 2) { | ||
39 | -- | 44 | -- |
40 | 2.7.4 | 45 | 2.16.2 |
41 | 46 | ||
42 | 47 | diff view generated by jsdifflib |
1 | From: Pranith Kumar <bobby.prani@gmail.com> | 1 | Add some assertions that if we're about to boot an AArch64 kernel, |
---|---|---|---|
2 | the board code has not mistakenly set either secure_boot or | ||
3 | secure_board_setup. It doesn't make sense to set secure_boot, | ||
4 | because all AArch64 kernels must be booted in non-secure mode. | ||
2 | 5 | ||
3 | Tested and confirmed that the stretch i386 debian qcow2 image on a | 6 | It might in theory make sense to set secure_board_setup, but |
4 | raspberry pi 2 works. | 7 | we don't currently support that, because only the AArch32 |
8 | bootloader[] code calls this hook; bootloader_aarch64[] does not. | ||
9 | Since we don't have a current need for this functionality, just | ||
10 | assert that we don't try to use it. If it's needed we'll add | ||
11 | it later. | ||
5 | 12 | ||
6 | Fixes: LP#: 893208 <https://bugs.launchpad.net/qemu/+bug/893208/> | ||
7 | Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> | ||
8 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | ||
9 | Message-id: 20170418191817.10430-1-bobby.prani@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20180313153458.26822-3-peter.maydell@linaro.org | ||
11 | --- | 16 | --- |
12 | include/qemu/timer.h | 5 ++--- | 17 | hw/arm/boot.c | 7 +++++++ |
13 | 1 file changed, 2 insertions(+), 3 deletions(-) | 18 | 1 file changed, 7 insertions(+) |
14 | 19 | ||
15 | diff --git a/include/qemu/timer.h b/include/qemu/timer.h | 20 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/qemu/timer.h | 22 | --- a/hw/arm/boot.c |
18 | +++ b/include/qemu/timer.h | 23 | +++ b/hw/arm/boot.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline int64_t cpu_get_host_ticks(void) | 24 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) |
20 | /* The host CPU doesn't have an easily accessible cycle counter. | 25 | } else { |
21 | Just return a monotonically increasing value. This will be | 26 | env->pstate = PSTATE_MODE_EL1h; |
22 | totally wrong, but hopefully better than nothing. */ | 27 | } |
23 | -static inline int64_t cpu_get_host_ticks (void) | 28 | + /* AArch64 kernels never boot in secure mode */ |
24 | +static inline int64_t cpu_get_host_ticks(void) | 29 | + assert(!info->secure_boot); |
25 | { | 30 | + /* This hook is only supported for AArch32 currently: |
26 | - static int64_t ticks = 0; | 31 | + * bootloader_aarch64[] will not call the hook, and |
27 | - return ticks++; | 32 | + * the code above has already dropped us into EL2 or EL1. |
28 | + return get_clock(); | 33 | + */ |
29 | } | 34 | + assert(!info->secure_board_setup); |
30 | #endif | 35 | } |
31 | 36 | ||
37 | /* Set to non-secure if not a secure boot */ | ||
32 | -- | 38 | -- |
33 | 2.7.4 | 39 | 2.16.2 |
34 | 40 | ||
35 | 41 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | If we're directly booting a Linux kernel and the CPU supports both |
---|---|---|---|
2 | EL3 and EL2, we start the kernel in EL2, as it expects. We must also | ||
3 | set the SCR_EL3.HCE bit in this situation, so that the HVC | ||
4 | instruction is enabled rather than UNDEFing. Otherwise at least some | ||
5 | kernels will panic when trying to initialize KVM in the guest. | ||
2 | 6 | ||
3 | Use a define for a9mpcore_priv device type name instead of hard-coded | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | string. | 8 | Message-id: 20180313153458.26822-4-peter.maydell@linaro.org |
9 | --- | ||
10 | hw/arm/boot.c | 5 +++++ | ||
11 | 1 file changed, 5 insertions(+) | ||
5 | 12 | ||
6 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 13 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c |
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 | 3 ++- | ||
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/exynos4210.c | 15 | --- a/hw/arm/boot.c |
16 | +++ b/hw/arm/exynos4210.c | 16 | +++ b/hw/arm/boot.c |
17 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) |
18 | #include "qemu-common.h" | 18 | assert(!info->secure_board_setup); |
19 | #include "qemu/log.h" | 19 | } |
20 | #include "cpu.h" | 20 | |
21 | +#include "hw/cpu/a9mpcore.h" | 21 | + if (arm_feature(env, ARM_FEATURE_EL2)) { |
22 | #include "hw/boards.h" | 22 | + /* If we have EL2 then Linux expects the HVC insn to work */ |
23 | #include "sysemu/sysemu.h" | 23 | + env->cp15.scr_el3 |= SCR_HCE; |
24 | #include "hw/sysbus.h" | 24 | + } |
25 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | 25 | + |
26 | } | 26 | /* Set to non-secure if not a secure boot */ |
27 | 27 | if (!info->secure_boot && | |
28 | /* Private memory region and Internal GIC */ | 28 | (cs != first_cpu || !info->secure_board_setup)) { |
29 | - dev = qdev_create(NULL, "a9mpcore_priv"); | ||
30 | + dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV); | ||
31 | qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | ||
32 | qdev_init_nofail(dev); | ||
33 | busdev = SYS_BUS_DEVICE(dev); | ||
34 | -- | 29 | -- |
35 | 2.7.4 | 30 | 2.16.2 |
36 | 31 | ||
37 | 32 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | The TypeInfo and state struct for bcm2386 disagree about what the |
---|---|---|---|
2 | parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE, | ||
3 | but the BCM2386State struct only defines the parent_obj field | ||
4 | as DeviceState. This would have caused problems if anything | ||
5 | actually tried to treat the object as a TYPE_SYS_BUS_DEVICE. | ||
6 | Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't | ||
7 | need any of the additional functionality TYPE_SYS_BUS_DEVICE | ||
8 | provides. | ||
2 | 9 | ||
3 | The static array of interrupt combiner mappings is not modified so it | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | can be made const for code safeness. | 11 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> |
5 | |||
6 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Message-id: 20180313153458.26822-5-peter.maydell@linaro.org |
9 | --- | 14 | --- |
10 | hw/intc/exynos4210_gic.c | 2 +- | 15 | hw/arm/bcm2836.c | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 17 | ||
13 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | 18 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c |
14 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/intc/exynos4210_gic.c | 20 | --- a/hw/arm/bcm2836.c |
16 | +++ b/hw/intc/exynos4210_gic.c | 21 | +++ b/hw/arm/bcm2836.c |
17 | @@ -XXX,XX +XXX,XX @@ enum ExtInt { | 22 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) |
18 | * which is INTG16 in Internal Interrupt Combiner. | 23 | |
19 | */ | 24 | static const TypeInfo bcm2836_type_info = { |
20 | 25 | .name = TYPE_BCM2836, | |
21 | -static uint32_t | 26 | - .parent = TYPE_SYS_BUS_DEVICE, |
22 | +static const uint32_t | 27 | + .parent = TYPE_DEVICE, |
23 | combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | 28 | .instance_size = sizeof(BCM2836State), |
24 | /* int combiner groups 16-19 */ | 29 | .instance_init = bcm2836_init, |
25 | { }, { }, { }, { }, | 30 | .class_init = bcm2836_class_init, |
26 | -- | 31 | -- |
27 | 2.7.4 | 32 | 2.16.2 |
28 | 33 | ||
29 | 34 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Our BCM2836 type is really a generic one that can be any of |
---|---|---|---|
2 | the bcm283x family. Rename it accordingly. We change only | ||
3 | the names which are visible via the header file to the | ||
4 | rest of the QEMU code, leaving private function names | ||
5 | in bcm2836.c as they are. | ||
2 | 6 | ||
3 | In some circumstances, we don't want to abort if the | 7 | This is a preliminary to making bcm283x be an abstract |
4 | kvm_device_access fails. This will be the case during ITS | 8 | parent class to specific types for the bcm2836 and bcm2837. |
5 | migration, in case the ITS table save/restore fails because | ||
6 | the guest did not program the vITS correctly. So let's pass an | ||
7 | error object to the function and return the ioctl value. New | ||
8 | callers will be able to make a decision upon this returned | ||
9 | value. | ||
10 | 9 | ||
11 | Existing callers pass &error_abort which will cause the | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | function to abort on failure. | 11 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20180313153458.26822-6-peter.maydell@linaro.org | ||
14 | --- | ||
15 | include/hw/arm/bcm2836.h | 12 ++++++------ | ||
16 | hw/arm/bcm2836.c | 17 +++++++++-------- | ||
17 | hw/arm/raspi.c | 16 ++++++++-------- | ||
18 | 3 files changed, 23 insertions(+), 22 deletions(-) | ||
13 | 19 | ||
14 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 20 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h |
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> | ||
20 | --- | ||
21 | include/sysemu/kvm.h | 11 +++++++---- | ||
22 | hw/intc/arm_gic_kvm.c | 9 +++++---- | ||
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 | |||
28 | diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/include/sysemu/kvm.h | 22 | --- a/include/hw/arm/bcm2836.h |
31 | +++ b/include/sysemu/kvm.h | 23 | +++ b/include/hw/arm/bcm2836.h |
32 | @@ -XXX,XX +XXX,XX @@ int kvm_device_check_attr(int fd, uint32_t group, uint64_t attr); | 24 | @@ -XXX,XX +XXX,XX @@ |
33 | * @attr: the attribute of that group to set or get | 25 | #include "hw/arm/bcm2835_peripherals.h" |
34 | * @val: pointer to a storage area for the value | 26 | #include "hw/intc/bcm2836_control.h" |
35 | * @write: true for set and false for get operation | 27 | |
36 | + * @errp: error object handle | 28 | -#define TYPE_BCM2836 "bcm2836" |
37 | * | 29 | -#define BCM2836(obj) OBJECT_CHECK(BCM2836State, (obj), TYPE_BCM2836) |
38 | - * This function is not allowed to fail. Use kvm_device_check_attr() | 30 | +#define TYPE_BCM283X "bcm283x" |
39 | - * in order to check for the availability of optional attributes. | 31 | +#define BCM283X(obj) OBJECT_CHECK(BCM283XState, (obj), TYPE_BCM283X) |
40 | + * Returns: 0 on success | 32 | |
41 | + * < 0 on error | 33 | -#define BCM2836_NCPUS 4 |
42 | + * Use kvm_device_check_attr() in order to check for the availability | 34 | +#define BCM283X_NCPUS 4 |
43 | + * of optional attributes. | 35 | |
44 | */ | 36 | -typedef struct BCM2836State { |
45 | -void kvm_device_access(int fd, int group, uint64_t attr, | 37 | +typedef struct BCM283XState { |
46 | - void *val, bool write); | 38 | /*< private >*/ |
47 | +int kvm_device_access(int fd, int group, uint64_t attr, | 39 | DeviceState parent_obj; |
48 | + void *val, bool write, Error **errp); | 40 | /*< public >*/ |
49 | 41 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State { | |
50 | /** | 42 | char *cpu_type; |
51 | * kvm_create_device - create a KVM device for the device control API | 43 | uint32_t enabled_cpus; |
52 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c | 44 | |
45 | - ARMCPU cpus[BCM2836_NCPUS]; | ||
46 | + ARMCPU cpus[BCM283X_NCPUS]; | ||
47 | BCM2836ControlState control; | ||
48 | BCM2835PeripheralState peripherals; | ||
49 | -} BCM2836State; | ||
50 | +} BCM283XState; | ||
51 | |||
52 | #endif /* BCM2836_H */ | ||
53 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | 54 | index XXXXXXX..XXXXXXX 100644 |
54 | --- a/hw/intc/arm_gic_kvm.c | 55 | --- a/hw/arm/bcm2836.c |
55 | +++ b/hw/intc/arm_gic_kvm.c | 56 | +++ b/hw/arm/bcm2836.c |
56 | @@ -XXX,XX +XXX,XX @@ static void kvm_gicd_access(GICState *s, int offset, int cpu, | 57 | @@ -XXX,XX +XXX,XX @@ |
57 | uint32_t *val, bool write) | 58 | |
59 | static void bcm2836_init(Object *obj) | ||
58 | { | 60 | { |
59 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS, | 61 | - BCM2836State *s = BCM2836(obj); |
60 | - KVM_VGIC_ATTR(offset, cpu), val, write); | 62 | + BCM283XState *s = BCM283X(obj); |
61 | + KVM_VGIC_ATTR(offset, cpu), val, write, &error_abort); | 63 | |
64 | object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); | ||
65 | object_property_add_child(obj, "control", OBJECT(&s->control), NULL); | ||
66 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | ||
67 | |||
68 | static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
69 | { | ||
70 | - BCM2836State *s = BCM2836(dev); | ||
71 | + BCM283XState *s = BCM283X(dev); | ||
72 | Object *obj; | ||
73 | Error *err = NULL; | ||
74 | int n; | ||
75 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
76 | /* common peripherals from bcm2835 */ | ||
77 | |||
78 | obj = OBJECT(dev); | ||
79 | - for (n = 0; n < BCM2836_NCPUS; n++) { | ||
80 | + for (n = 0; n < BCM283X_NCPUS; n++) { | ||
81 | object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | ||
82 | s->cpu_type); | ||
83 | object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
84 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
85 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, | ||
86 | qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); | ||
87 | |||
88 | - for (n = 0; n < BCM2836_NCPUS; n++) { | ||
89 | + for (n = 0; n < BCM283X_NCPUS; n++) { | ||
90 | /* Mirror bcm2836, which has clusterid set to 0xf | ||
91 | * TODO: this should be converted to a property of ARM_CPU | ||
92 | */ | ||
93 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
62 | } | 94 | } |
63 | 95 | ||
64 | static void kvm_gicc_access(GICState *s, int offset, int cpu, | 96 | static Property bcm2836_props[] = { |
65 | uint32_t *val, bool write) | 97 | - DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type), |
66 | { | 98 | - DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS), |
67 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_REGS, | 99 | + DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), |
68 | - KVM_VGIC_ATTR(offset, cpu), val, write); | 100 | + DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, |
69 | + KVM_VGIC_ATTR(offset, cpu), val, write, &error_abort); | 101 | + BCM283X_NCPUS), |
102 | DEFINE_PROP_END_OF_LIST() | ||
103 | }; | ||
104 | |||
105 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) | ||
70 | } | 106 | } |
71 | 107 | ||
72 | #define for_each_irq_reg(_ctr, _max_irq, _field_width) \ | 108 | static const TypeInfo bcm2836_type_info = { |
73 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) | 109 | - .name = TYPE_BCM2836, |
74 | if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0)) { | 110 | + .name = TYPE_BCM283X, |
75 | uint32_t numirqs = s->num_irq; | 111 | .parent = TYPE_DEVICE, |
76 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0, | 112 | - .instance_size = sizeof(BCM2836State), |
77 | - &numirqs, true); | 113 | + .instance_size = sizeof(BCM283XState), |
78 | + &numirqs, true, &error_abort); | 114 | .instance_init = bcm2836_init, |
79 | } | 115 | .class_init = bcm2836_class_init, |
80 | /* Tell the kernel to complete VGIC initialization now */ | 116 | }; |
81 | if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | 117 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
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 | 118 | index XXXXXXX..XXXXXXX 100644 |
92 | --- a/hw/intc/arm_gicv3_its_kvm.c | 119 | --- a/hw/arm/raspi.c |
93 | +++ b/hw/intc/arm_gicv3_its_kvm.c | 120 | +++ b/hw/arm/raspi.c |
94 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | 121 | @@ -XXX,XX +XXX,XX @@ |
95 | 122 | static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; | |
96 | /* explicit init of the ITS */ | 123 | |
97 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | 124 | typedef struct RasPiState { |
98 | - KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); | 125 | - BCM2836State soc; |
99 | + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, &error_abort); | 126 | + BCM283XState soc; |
100 | 127 | MemoryRegion ram; | |
101 | /* register the base address */ | 128 | } RasPiState; |
102 | kvm_arm_register_device(&s->iomem_its_cntrl, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, | 129 | |
103 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 130 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) |
104 | index XXXXXXX..XXXXXXX 100644 | 131 | BusState *bus; |
105 | --- a/hw/intc/arm_gicv3_kvm.c | 132 | DeviceState *carddev; |
106 | +++ b/hw/intc/arm_gicv3_kvm.c | 133 | |
107 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gicd_access(GICv3State *s, int offset, | 134 | - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM2836); |
108 | { | 135 | + object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); |
109 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS, | 136 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), |
110 | KVM_VGIC_ATTR(offset, 0), | 137 | &error_abort); |
111 | - val, write); | 138 | |
112 | + val, write, &error_abort); | 139 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) |
140 | mc->no_floppy = 1; | ||
141 | mc->no_cdrom = 1; | ||
142 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); | ||
143 | - mc->max_cpus = BCM2836_NCPUS; | ||
144 | - mc->min_cpus = BCM2836_NCPUS; | ||
145 | - mc->default_cpus = BCM2836_NCPUS; | ||
146 | + mc->max_cpus = BCM283X_NCPUS; | ||
147 | + mc->min_cpus = BCM283X_NCPUS; | ||
148 | + mc->default_cpus = BCM283X_NCPUS; | ||
149 | mc->default_ram_size = 1024 * 1024 * 1024; | ||
150 | mc->ignore_memory_transaction_failures = true; | ||
151 | }; | ||
152 | @@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc) | ||
153 | mc->no_floppy = 1; | ||
154 | mc->no_cdrom = 1; | ||
155 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); | ||
156 | - mc->max_cpus = BCM2836_NCPUS; | ||
157 | - mc->min_cpus = BCM2836_NCPUS; | ||
158 | - mc->default_cpus = BCM2836_NCPUS; | ||
159 | + mc->max_cpus = BCM283X_NCPUS; | ||
160 | + mc->min_cpus = BCM283X_NCPUS; | ||
161 | + mc->default_cpus = BCM283X_NCPUS; | ||
162 | mc->default_ram_size = 1024 * 1024 * 1024; | ||
113 | } | 163 | } |
114 | 164 | DEFINE_MACHINE("raspi3", raspi3_machine_init) | |
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 | -- | 165 | -- |
207 | 2.7.4 | 166 | 2.16.2 |
208 | 167 | ||
209 | 168 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The bcm2837 is pretty similar to the bcm2836, but it does have |
---|---|---|---|
2 | some differences. Notably, the MPIDR affinity aff1 values it | ||
3 | sets for the CPUs are 0x0, rather than the 0xf that the bcm2836 | ||
4 | uses, and if this is wrong Linux will not boot. | ||
2 | 5 | ||
3 | Largely inspired by the TMP105 temperature sensor, here is a model for | 6 | Rather than trying to have one device with properties that |
4 | the TMP42{1,2,3} temperature sensors. | 7 | configure it differently for the two cases, create two |
8 | separate QOM devices for the two SoCs. We use the same approach | ||
9 | as hw/arm/aspeed_soc.c and share code and have a data table | ||
10 | that might differ per-SoC. For the moment the two types don't | ||
11 | actually have different behaviour. | ||
5 | 12 | ||
6 | Specs can be found here : | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20180313153458.26822-7-peter.maydell@linaro.org | ||
16 | --- | ||
17 | include/hw/arm/bcm2836.h | 19 +++++++++++++++++++ | ||
18 | hw/arm/bcm2836.c | 37 ++++++++++++++++++++++++++++++++----- | ||
19 | hw/arm/raspi.c | 3 ++- | ||
20 | 3 files changed, 53 insertions(+), 6 deletions(-) | ||
7 | 21 | ||
8 | http://www.ti.com/lit/gpn/tmp421 | 22 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h |
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 | 23 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/misc/Makefile.objs | 24 | --- a/include/hw/arm/bcm2836.h |
24 | +++ b/hw/misc/Makefile.objs | 25 | +++ b/include/hw/arm/bcm2836.h |
25 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ |
26 | common-obj-$(CONFIG_APPLESMC) += applesmc.o | 27 | |
27 | common-obj-$(CONFIG_MAX111X) += max111x.o | 28 | #define BCM283X_NCPUS 4 |
28 | common-obj-$(CONFIG_TMP105) += tmp105.o | 29 | |
29 | +common-obj-$(CONFIG_TMP421) += tmp421.o | 30 | +/* These type names are for specific SoCs; other than instantiating |
30 | common-obj-$(CONFIG_ISA_DEBUG) += debugexit.o | 31 | + * them, code using these devices should always handle them via the |
31 | common-obj-$(CONFIG_SGA) += sga.o | 32 | + * BCM283x base class, so they have no BCM2836(obj) etc macros. |
32 | common-obj-$(CONFIG_ISA_TESTDEV) += pc-testdev.o | 33 | + */ |
33 | diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c | 34 | +#define TYPE_BCM2836 "bcm2836" |
34 | new file mode 100644 | 35 | +#define TYPE_BCM2837 "bcm2837" |
35 | index XXXXXXX..XXXXXXX | 36 | + |
36 | --- /dev/null | 37 | typedef struct BCM283XState { |
37 | +++ b/hw/misc/tmp421.c | 38 | /*< private >*/ |
39 | DeviceState parent_obj; | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM283XState { | ||
41 | BCM2835PeripheralState peripherals; | ||
42 | } BCM283XState; | ||
43 | |||
44 | +typedef struct BCM283XInfo BCM283XInfo; | ||
45 | + | ||
46 | +typedef struct BCM283XClass { | ||
47 | + DeviceClass parent_class; | ||
48 | + const BCM283XInfo *info; | ||
49 | +} BCM283XClass; | ||
50 | + | ||
51 | +#define BCM283X_CLASS(klass) \ | ||
52 | + OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X) | ||
53 | +#define BCM283X_GET_CLASS(obj) \ | ||
54 | + OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X) | ||
55 | + | ||
56 | #endif /* BCM2836_H */ | ||
57 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/arm/bcm2836.c | ||
60 | +++ b/hw/arm/bcm2836.c | ||
38 | @@ -XXX,XX +XXX,XX @@ | 61 | @@ -XXX,XX +XXX,XX @@ |
39 | +/* | 62 | /* "QA7" (Pi2) interrupt controller and mailboxes etc. */ |
40 | + * Texas Instruments TMP421 temperature sensor. | 63 | #define BCM2836_CONTROL_BASE 0x40000000 |
41 | + * | 64 | |
42 | + * Copyright (c) 2016 IBM Corporation. | 65 | +struct BCM283XInfo { |
43 | + * | ||
44 | + * Largely inspired by : | ||
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; | 66 | + 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 | +}; | 67 | +}; |
87 | + | 68 | + |
88 | +typedef struct TMP421State { | 69 | +static const BCM283XInfo bcm283x_socs[] = { |
89 | + /*< private >*/ | 70 | + { |
90 | + I2CSlave i2c; | 71 | + .name = TYPE_BCM2836, |
91 | + /*< public >*/ | 72 | + }, |
92 | + | 73 | + { |
93 | + int16_t temperature[4]; | 74 | + .name = TYPE_BCM2837, |
94 | + | 75 | + }, |
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 | +}; | 76 | +}; |
348 | + | 77 | + |
349 | +static void tmp421_reset(I2CSlave *i2c) | 78 | static void bcm2836_init(Object *obj) |
350 | +{ | 79 | { |
351 | + TMP421State *s = TMP421(i2c); | 80 | BCM283XState *s = BCM283X(obj); |
352 | + TMP421Class *sc = TMP421_GET_CLASS(s); | 81 | @@ -XXX,XX +XXX,XX @@ static Property bcm2836_props[] = { |
353 | + | 82 | DEFINE_PROP_END_OF_LIST() |
354 | + memset(s->temperature, 0, sizeof(s->temperature)); | 83 | }; |
355 | + s->pointer = 0; | 84 | |
356 | + | 85 | -static void bcm2836_class_init(ObjectClass *oc, void *data) |
357 | + s->config[0] = 0; /* TMP421_CONFIG_RANGE */ | 86 | +static void bcm283x_class_init(ObjectClass *oc, void *data) |
358 | + | 87 | { |
359 | + /* resistance correction and channel enablement */ | 88 | DeviceClass *dc = DEVICE_CLASS(oc); |
360 | + switch (sc->dev->model) { | 89 | + BCM283XClass *bc = BCM283X_CLASS(oc); |
361 | + case TMP421_DEVICE_ID: | 90 | |
362 | + s->config[1] = 0x1c; | 91 | - dc->props = bcm2836_props; |
363 | + break; | 92 | + bc->info = data; |
364 | + case TMP422_DEVICE_ID: | 93 | dc->realize = bcm2836_realize; |
365 | + s->config[1] = 0x3c; | 94 | + dc->props = bcm2836_props; |
366 | + break; | 95 | } |
367 | + case TMP423_DEVICE_ID: | 96 | |
368 | + s->config[1] = 0x7c; | 97 | -static const TypeInfo bcm2836_type_info = { |
369 | + break; | 98 | +static const TypeInfo bcm283x_type_info = { |
370 | + } | 99 | .name = TYPE_BCM283X, |
371 | + | 100 | .parent = TYPE_DEVICE, |
372 | + s->rate = 0x7; /* 8Hz */ | 101 | .instance_size = sizeof(BCM283XState), |
373 | + s->status = 0; | 102 | .instance_init = bcm2836_init, |
374 | +} | 103 | - .class_init = bcm2836_class_init, |
375 | + | 104 | + .class_size = sizeof(BCM283XClass), |
376 | +static int tmp421_init(I2CSlave *i2c) | 105 | + .abstract = true, |
377 | +{ | 106 | }; |
378 | + TMP421State *s = TMP421(i2c); | 107 | |
379 | + | 108 | static void bcm2836_register_types(void) |
380 | + tmp421_reset(&s->i2c); | 109 | { |
381 | + | 110 | - type_register_static(&bcm2836_type_info); |
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; | 111 | + int i; |
427 | + | 112 | + |
428 | + type_register_static(&tmp421_info); | 113 | + type_register_static(&bcm283x_type_info); |
429 | + for (i = 0; i < ARRAY_SIZE(devices); ++i) { | 114 | + for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) { |
430 | + TypeInfo ti = { | 115 | + TypeInfo ti = { |
431 | + .name = devices[i].name, | 116 | + .name = bcm283x_socs[i].name, |
432 | + .parent = TYPE_TMP421, | 117 | + .parent = TYPE_BCM283X, |
433 | + .class_init = tmp421_class_init, | 118 | + .class_init = bcm283x_class_init, |
434 | + .class_data = (void *) &devices[i], | 119 | + .class_data = (void *) &bcm283x_socs[i], |
435 | + }; | 120 | + }; |
436 | + type_register(&ti); | 121 | + type_register(&ti); |
437 | + } | 122 | + } |
438 | +} | 123 | } |
439 | + | 124 | |
440 | +type_init(tmp421_register_types) | 125 | type_init(bcm2836_register_types) |
441 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | 126 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
442 | index XXXXXXX..XXXXXXX 100644 | 127 | index XXXXXXX..XXXXXXX 100644 |
443 | --- a/default-configs/arm-softmmu.mak | 128 | --- a/hw/arm/raspi.c |
444 | +++ b/default-configs/arm-softmmu.mak | 129 | +++ b/hw/arm/raspi.c |
445 | @@ -XXX,XX +XXX,XX @@ CONFIG_TWL92230=y | 130 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) |
446 | CONFIG_TSC2005=y | 131 | BusState *bus; |
447 | CONFIG_LM832X=y | 132 | DeviceState *carddev; |
448 | CONFIG_TMP105=y | 133 | |
449 | +CONFIG_TMP421=y | 134 | - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); |
450 | CONFIG_STELLARIS=y | 135 | + object_initialize(&s->soc, sizeof(s->soc), |
451 | CONFIG_STELLARIS_INPUT=y | 136 | + version == 3 ? TYPE_BCM2837 : TYPE_BCM2836); |
452 | CONFIG_STELLARIS_ENET=y | 137 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), |
138 | &error_abort); | ||
139 | |||
453 | -- | 140 | -- |
454 | 2.7.4 | 141 | 2.16.2 |
455 | 142 | ||
456 | 143 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | The BCM2837 sets the Aff1 field of the MPIDR affinity values for the |
---|---|---|---|
2 | CPUs to 0, whereas the BCM2836 uses 0xf. Set this correctly, as it | ||
3 | is required for Linux to boot. | ||
2 | 4 | ||
3 | On all Exynos-based boards, the system powers down itself by driving | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | PS_HOLD signal low - eight bit in PS_HOLD_CONTROL register of PMU. | 6 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> |
5 | Handle writing to respective PMU register to fix power off failure: | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Message-id: 20180313153458.26822-8-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/arm/bcm2836.c | 11 +++++++---- | ||
11 | 1 file changed, 7 insertions(+), 4 deletions(-) | ||
6 | 12 | ||
7 | reboot: Power down | 13 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c |
8 | Unable to poweroff system | ||
9 | shutdown: 31 output lines suppressed due to ratelimiting | ||
10 | Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000 | ||
11 | |||
12 | CPU: 0 PID: 1 Comm: shutdown Not tainted 4.11.0-rc8 #846 | ||
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> | ||
29 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
31 | --- | ||
32 | hw/misc/exynos4210_pmu.c | 20 +++++++++++++++++++- | ||
33 | 1 file changed, 19 insertions(+), 1 deletion(-) | ||
34 | |||
35 | diff --git a/hw/misc/exynos4210_pmu.c b/hw/misc/exynos4210_pmu.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/misc/exynos4210_pmu.c | 15 | --- a/hw/arm/bcm2836.c |
38 | +++ b/hw/misc/exynos4210_pmu.c | 16 | +++ b/hw/arm/bcm2836.c |
39 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
40 | 18 | ||
41 | #include "qemu/osdep.h" | 19 | struct BCM283XInfo { |
42 | #include "hw/sysbus.h" | 20 | const char *name; |
43 | +#include "sysemu/sysemu.h" | 21 | + int clusterid; |
44 | 22 | }; | |
45 | #ifndef DEBUG_PMU | 23 | |
46 | #define DEBUG_PMU 0 | 24 | static const BCM283XInfo bcm283x_socs[] = { |
47 | @@ -XXX,XX +XXX,XX @@ static const Exynos4210PmuReg exynos4210_pmu_regs[] = { | 25 | { |
48 | {"PAD_RETENTION_MMCB_OPTION", PAD_RETENTION_MMCB_OPTION, 0x00000000}, | 26 | .name = TYPE_BCM2836, |
49 | {"PAD_RETENTION_EBIA_OPTION", PAD_RETENTION_EBIA_OPTION, 0x00000000}, | 27 | + .clusterid = 0xf, |
50 | {"PAD_RETENTION_EBIB_OPTION", PAD_RETENTION_EBIB_OPTION, 0x00000000}, | 28 | }, |
51 | - {"PS_HOLD_CONTROL", PS_HOLD_CONTROL, 0x00005200}, | 29 | { |
52 | + /* | 30 | .name = TYPE_BCM2837, |
53 | + * PS_HOLD_CONTROL: reset value and manually toggle high the DATA bit. | 31 | + .clusterid = 0x0, |
54 | + * DATA bit high, set usually by bootloader, keeps system on. | 32 | }, |
55 | + */ | 33 | }; |
56 | + {"PS_HOLD_CONTROL", PS_HOLD_CONTROL, 0x00005200 | BIT(8)}, | 34 | |
57 | {"XUSBXTI_CONFIGURATION", XUSBXTI_CONFIGURATION, 0x00000001}, | 35 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) |
58 | {"XUSBXTI_STATUS", XUSBXTI_STATUS, 0x00000001}, | 36 | static void bcm2836_realize(DeviceState *dev, Error **errp) |
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 | + | ||
70 | static uint64_t exynos4210_pmu_read(void *opaque, hwaddr offset, | ||
71 | unsigned size) | ||
72 | { | 37 | { |
73 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pmu_write(void *opaque, hwaddr offset, | 38 | BCM283XState *s = BCM283X(dev); |
74 | PRINT_DEBUG_EXTEND("%s <0x%04x> <- 0x%04x\n", reg_p->name, | 39 | + BCM283XClass *bc = BCM283X_GET_CLASS(dev); |
75 | (uint32_t)offset, (uint32_t)val); | 40 | + const BCM283XInfo *info = bc->info; |
76 | s->reg[i] = val; | 41 | Object *obj; |
77 | + if ((offset == PS_HOLD_CONTROL) && ((val & BIT(8)) == 0)) { | 42 | Error *err = NULL; |
78 | + /* | 43 | int n; |
79 | + * We are interested only in setting data bit | 44 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) |
80 | + * of PS_HOLD_CONTROL register to indicate power off request. | 45 | qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); |
81 | + */ | 46 | |
82 | + exynos4210_pmu_poweroff(); | 47 | for (n = 0; n < BCM283X_NCPUS; n++) { |
83 | + } | 48 | - /* Mirror bcm2836, which has clusterid set to 0xf |
84 | return; | 49 | - * TODO: this should be converted to a property of ARM_CPU |
85 | } | 50 | - */ |
86 | reg_p++; | 51 | - s->cpus[n].mp_affinity = 0xF00 | n; |
52 | + /* TODO: this should be converted to a property of ARM_CPU */ | ||
53 | + s->cpus[n].mp_affinity = (info->clusterid << 8) | n; | ||
54 | |||
55 | /* set periphbase/CBAR value for CPU-local registers */ | ||
56 | object_property_set_int(OBJECT(&s->cpus[n]), | ||
87 | -- | 57 | -- |
88 | 2.7.4 | 58 | 2.16.2 |
89 | 59 | ||
90 | 60 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Now we have separate types for BCM2386 and BCM2387, we might as well |
---|---|---|---|
2 | just hard-code the CPU type they use rather than having it passed | ||
3 | through as an object property. This then lets us put the initialization | ||
4 | of the CPU object in init rather than realize. | ||
2 | 5 | ||
3 | This patch adds the flush of the LPI pending bits into the | 6 | Note that this change means that it's no longer possible on |
4 | redistributor pending tables. This happens on VM stop. | 7 | the command line to use -cpu to ask for a different kind of |
8 | CPU than the SoC supports. This was never a supported thing to | ||
9 | do anyway; we were just not sanity-checking the command line. | ||
5 | 10 | ||
6 | There is no explicit restore as the tables are implicitly sync'ed | 11 | This does require us to only build the bcm2837 object on |
7 | on ITS table restore and on LPI enable at redistributor level. | 12 | TARGET_AARCH64 configs, since otherwise it won't instantiate |
13 | due to the missing cortex-a53 device and "make check" will fail. | ||
8 | 14 | ||
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> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
17 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Message-id: 20180313153458.26822-9-peter.maydell@linaro.org | ||
13 | --- | 19 | --- |
14 | hw/intc/arm_gicv3_kvm.c | 34 ++++++++++++++++++++++++++++++++++ | 20 | hw/arm/bcm2836.c | 24 +++++++++++++++--------- |
15 | 1 file changed, 34 insertions(+) | 21 | hw/arm/raspi.c | 2 -- |
22 | 2 files changed, 15 insertions(+), 11 deletions(-) | ||
16 | 23 | ||
17 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 24 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c |
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/arm_gicv3_kvm.c | 26 | --- a/hw/arm/bcm2836.c |
20 | +++ b/hw/intc/arm_gicv3_kvm.c | 27 | +++ b/hw/arm/bcm2836.c |
21 | @@ -XXX,XX +XXX,XX @@ | 28 | @@ -XXX,XX +XXX,XX @@ |
22 | #include "hw/sysbus.h" | 29 | |
23 | #include "qemu/error-report.h" | 30 | struct BCM283XInfo { |
24 | #include "sysemu/kvm.h" | 31 | const char *name; |
25 | +#include "sysemu/sysemu.h" | 32 | + const char *cpu_type; |
26 | #include "kvm_arm.h" | 33 | int clusterid; |
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 | }; | 34 | }; |
32 | 35 | ||
33 | +/** | 36 | static const BCM283XInfo bcm283x_socs[] = { |
34 | + * vm_change_state_handler - VM change state callback aiming at flushing | 37 | { |
35 | + * RDIST pending tables into guest RAM | 38 | .name = TYPE_BCM2836, |
36 | + * | 39 | + .cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"), |
37 | + * The tables get flushed to guest RAM whenever the VM gets stopped. | 40 | .clusterid = 0xf, |
38 | + */ | 41 | }, |
39 | +static void vm_change_state_handler(void *opaque, int running, | 42 | +#ifdef TARGET_AARCH64 |
40 | + RunState state) | 43 | { |
41 | +{ | 44 | .name = TYPE_BCM2837, |
42 | + GICv3State *s = (GICv3State *)opaque; | 45 | + .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"), |
43 | + Error *err = NULL; | 46 | .clusterid = 0x0, |
44 | + int ret; | 47 | }, |
48 | +#endif | ||
49 | }; | ||
50 | |||
51 | static void bcm2836_init(Object *obj) | ||
52 | { | ||
53 | BCM283XState *s = BCM283X(obj); | ||
54 | + BCM283XClass *bc = BCM283X_GET_CLASS(obj); | ||
55 | + const BCM283XInfo *info = bc->info; | ||
56 | + int n; | ||
45 | + | 57 | + |
46 | + if (running) { | 58 | + for (n = 0; n < BCM283X_NCPUS; n++) { |
47 | + return; | 59 | + object_initialize(&s->cpus[n], sizeof(s->cpus[n]), |
60 | + info->cpu_type); | ||
61 | + object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
62 | + &error_abort); | ||
48 | + } | 63 | + } |
49 | + | 64 | |
50 | + ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | 65 | object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); |
51 | + KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES, | 66 | object_property_add_child(obj, "control", OBJECT(&s->control), NULL); |
52 | + NULL, true, &err); | 67 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) |
53 | + if (err) { | 68 | |
54 | + error_report_err(err); | 69 | /* common peripherals from bcm2835 */ |
55 | + } | 70 | |
56 | + if (ret < 0 && ret != -EFAULT) { | 71 | - obj = OBJECT(dev); |
57 | + abort(); | 72 | - for (n = 0; n < BCM283X_NCPUS; n++) { |
58 | + } | 73 | - object_initialize(&s->cpus[n], sizeof(s->cpus[n]), |
59 | +} | 74 | - s->cpu_type); |
60 | + | 75 | - object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), |
61 | + | 76 | - &error_abort); |
62 | static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | 77 | - } |
63 | { | 78 | - |
64 | GICv3State *s = KVM_ARM_GICV3(dev); | 79 | obj = object_property_get_link(OBJECT(dev), "ram", &err); |
65 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | 80 | if (obj == NULL) { |
66 | return; | 81 | error_setg(errp, "%s: required ram link not found: %s", |
67 | } | 82 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) |
68 | } | ||
69 | + if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
70 | + KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES)) { | ||
71 | + qemu_add_vm_change_state_handler(vm_change_state_handler, s); | ||
72 | + } | ||
73 | } | 83 | } |
74 | 84 | ||
75 | static void kvm_arm_gicv3_class_init(ObjectClass *klass, void *data) | 85 | static Property bcm2836_props[] = { |
86 | - DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), | ||
87 | DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, | ||
88 | BCM283X_NCPUS), | ||
89 | DEFINE_PROP_END_OF_LIST() | ||
90 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/hw/arm/raspi.c | ||
93 | +++ b/hw/arm/raspi.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | ||
95 | /* Setup the SOC */ | ||
96 | object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), | ||
97 | &error_abort); | ||
98 | - object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type", | ||
99 | - &error_abort); | ||
100 | object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus", | ||
101 | &error_abort); | ||
102 | int board_rev = version == 3 ? 0xa02082 : 0xa21041; | ||
76 | -- | 103 | -- |
77 | 2.7.4 | 104 | 2.16.2 |
78 | 105 | ||
79 | 106 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | The raspi3 has AArch64 CPUs, which means that our smpboot |
---|---|---|---|
2 | code for keeping the secondary CPUs in a pen needs to have | ||
3 | a version for A64 as well as A32. Without this, the | ||
4 | secondary CPUs go into an infinite loop of taking undefined | ||
5 | instruction exceptions. | ||
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: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | not SoC. | 9 | Message-id: 20180313153458.26822-10-peter.maydell@linaro.org |
10 | --- | ||
11 | hw/arm/raspi.c | 41 ++++++++++++++++++++++++++++++++++++++++- | ||
12 | 1 file changed, 40 insertions(+), 1 deletion(-) | ||
6 | 13 | ||
7 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.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/arm/raspi.c |
19 | +++ b/include/hw/arm/exynos4210.h | 17 | +++ b/hw/arm/raspi.c |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210State { | 18 | @@ -XXX,XX +XXX,XX @@ |
21 | MemoryRegion iram_mem; | 19 | #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */ |
22 | MemoryRegion irom_mem; | 20 | #define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */ |
23 | MemoryRegion irom_alias_mem; | 21 | #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ |
24 | - MemoryRegion dram0_mem; | 22 | +#define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */ |
25 | - MemoryRegion dram1_mem; | 23 | |
26 | MemoryRegion boot_secondary; | 24 | /* Table of Linux board IDs for different Pi versions */ |
27 | MemoryRegion bootreg_mem; | 25 | static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; |
28 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | 26 | @@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210State { | 27 | info->smp_loader_start); |
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 | } | 28 | } |
46 | 29 | ||
47 | -Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | 30 | +static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) |
48 | - unsigned long ram_size) | 31 | +{ |
49 | +Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | 32 | + /* Unlike the AArch32 version we don't need to call the board setup hook. |
50 | { | 33 | + * The mechanism for doing the spin-table is also entirely different. |
51 | int i, n; | 34 | + * We must have four 64-bit fields at absolute addresses |
52 | Exynos4210State *s = g_new(Exynos4210State, 1); | 35 | + * 0xd8, 0xe0, 0xe8, 0xf0 in RAM, which are the flag variables for |
53 | qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | 36 | + * our CPUs, and which we must ensure are zero initialized before |
54 | - unsigned long mem_size; | 37 | + * the primary CPU goes into the kernel. We put these variables inside |
55 | DeviceState *dev; | 38 | + * a rom blob, so that the reset for ROM contents zeroes them for us. |
56 | SysBusDevice *busdev; | 39 | + */ |
57 | ObjectClass *cpu_oc; | 40 | + static const uint32_t smpboot[] = { |
58 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | 41 | + 0xd2801b05, /* mov x5, 0xd8 */ |
59 | memory_region_add_subregion(system_mem, EXYNOS4210_IRAM_BASE_ADDR, | 42 | + 0xd53800a6, /* mrs x6, mpidr_el1 */ |
60 | &s->iram_mem); | 43 | + 0x924004c6, /* and x6, x6, #0x3 */ |
61 | 44 | + 0xd503205f, /* spin: wfe */ | |
62 | - /* DRAM */ | 45 | + 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */ |
63 | - mem_size = ram_size; | 46 | + 0xb4ffffc4, /* cbz x4, spin */ |
64 | - if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) { | 47 | + 0xd2800000, /* mov x0, #0x0 */ |
65 | - memory_region_init_ram(&s->dram1_mem, NULL, "exynos4210.dram1", | 48 | + 0xd2800001, /* mov x1, #0x0 */ |
66 | - mem_size - EXYNOS4210_DRAM_MAX_SIZE, &error_fatal); | 49 | + 0xd2800002, /* mov x2, #0x0 */ |
67 | - vmstate_register_ram_global(&s->dram1_mem); | 50 | + 0xd2800003, /* mov x3, #0x0 */ |
68 | - memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR, | 51 | + 0xd61f0080, /* br x4 */ |
69 | - &s->dram1_mem); | 52 | + }; |
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 | + | 53 | + |
103 | static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = { | 54 | + static const uint64_t spintables[] = { |
104 | [EXYNOS4_BOARD_NURI] = 0xD33, | 55 | + 0, 0, 0, 0 |
105 | [EXYNOS4_BOARD_SMDKC210] = 0xB16, | 56 | + }; |
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 | +{ | ||
116 | + unsigned long mem_size = ram_size; | ||
117 | + | 57 | + |
118 | + if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) { | 58 | + rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot), |
119 | + memory_region_init_ram(&s->dram1_mem, NULL, "exynos4210.dram1", | 59 | + info->smp_loader_start); |
120 | + mem_size - EXYNOS4210_DRAM_MAX_SIZE, | 60 | + rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables), |
121 | + &error_fatal); | 61 | + SPINTABLE_ADDR); |
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 | + } | ||
127 | + | ||
128 | + memory_region_init_ram(&s->dram0_mem, NULL, "exynos4210.dram0", mem_size, | ||
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 | +} | 62 | +} |
134 | + | 63 | + |
135 | +static Exynos4BoardState * | 64 | static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info) |
136 | +exynos4_boards_init_common(MachineState *machine, | ||
137 | + Exynos4BoardType board_type) | ||
138 | { | 65 | { |
139 | + Exynos4BoardState *s = g_new(Exynos4BoardState, 1); | 66 | arm_write_secure_board_setup_dummy_smc(cpu, info, MVBAR_ADDR); |
140 | MachineClass *mc = MACHINE_GET_CLASS(machine); | 67 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
141 | 68 | /* Pi2 and Pi3 requires SMP setup */ | |
142 | if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) { | 69 | if (version >= 2) { |
143 | @@ -XXX,XX +XXX,XX @@ static Exynos4210State *exynos4_boards_init_common(MachineState *machine, | 70 | binfo.smp_loader_start = SMPBOOT_ADDR; |
144 | machine->kernel_cmdline, | 71 | - binfo.write_secondary_boot = write_smpboot; |
145 | machine->initrd_filename); | 72 | + if (version == 2) { |
146 | 73 | + binfo.write_secondary_boot = write_smpboot; | |
147 | - return exynos4210_init(get_system_memory(), | 74 | + } else { |
148 | - exynos4_board_ram_size[board_type]); | 75 | + binfo.write_secondary_boot = write_smpboot64; |
149 | + exynos4_boards_init_ram(s, get_system_memory(), | 76 | + } |
150 | + exynos4_board_ram_size[board_type]); | 77 | binfo.secondary_cpu_reset_hook = reset_secondary; |
151 | + | 78 | } |
152 | + s->soc = exynos4210_init(get_system_memory()); | ||
153 | + | ||
154 | + return s; | ||
155 | } | ||
156 | |||
157 | static void nuri_init(MachineState *machine) | ||
158 | @@ -XXX,XX +XXX,XX @@ static void nuri_init(MachineState *machine) | ||
159 | |||
160 | static void smdkc210_init(MachineState *machine) | ||
161 | { | ||
162 | - Exynos4210State *s = exynos4_boards_init_common(machine, | ||
163 | - EXYNOS4_BOARD_SMDKC210); | ||
164 | + Exynos4BoardState *s = exynos4_boards_init_common(machine, | ||
165 | + EXYNOS4_BOARD_SMDKC210); | ||
166 | |||
167 | lan9215_init(SMDK_LAN9118_BASE_ADDR, | ||
168 | - qemu_irq_invert(s->irq_table[exynos4210_get_irq(37, 1)])); | ||
169 | + qemu_irq_invert(s->soc->irq_table[exynos4210_get_irq(37, 1)])); | ||
170 | arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo); | ||
171 | } | ||
172 | 79 | ||
173 | -- | 80 | -- |
174 | 2.7.4 | 81 | 2.16.2 |
175 | 82 | ||
176 | 83 | 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 |