1 | Arm patch queue -- these are all bug fix patches but we might | 1 | target-arm queue for 3.1: mostly bug fixes, but the "turn on |
---|---|---|---|
2 | as well put them in to rc0... | 2 | EL2 support for Cortex-A7 and -A15" is technically enabling |
3 | of a new feature... I think this is OK since we're only at rc1, | ||
4 | and it's easy to revert that feature bit flip if necessary. | ||
3 | 5 | ||
4 | thanks | 6 | thanks |
5 | -- PMM | 7 | -- PMM |
6 | 8 | ||
7 | The following changes since commit 2c8cfc0b52b5a4d123c26c0b5fdf941be24805be: | ||
8 | 9 | ||
9 | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000) | 10 | The following changes since commit 5704c36d25ee84e7129722cb0db53df9faefe943: |
11 | |||
12 | Merge remote-tracking branch 'remotes/kraxel/tags/fixes-31-20181112-pull-request' into staging (2018-11-12 15:55:40 +0000) | ||
10 | 13 | ||
11 | are available in the Git repository at: | 14 | are available in the Git repository at: |
12 | 15 | ||
13 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180319 | 16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20181112 |
14 | 17 | ||
15 | for you to fetch changes up to ff72cb6b46b95bb530787add5277c211af3d31c6: | 18 | for you to fetch changes up to 1a4c1a6dbf60aebddd07753f1013ea896c06ad29: |
16 | 19 | ||
17 | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs (2018-03-19 18:23:24 +0000) | 20 | target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature (2018-11-12 16:52:29 +0000) |
18 | 21 | ||
19 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
20 | target-arm queue: | 23 | target/arm queue: |
21 | * fsl-imx6: Fix incorrect Ethernet interrupt defines | 24 | * Remove no-longer-needed workaround for small SAU regions for v8M |
22 | * dump: Update correct kdump phys_base field for AArch64 | 25 | * Remove antique TODO comment |
23 | * char: i.MX: Add support for "TX complete" interrupt | 26 | * MAINTAINERS: Add an entry for the 'collie' machine |
24 | * bcm2836/raspi: Fix various bugs resulting in panics trying | 27 | * hw/arm/sysbus-fdt: Only call match_fn callback if the type matches |
25 | to boot a Debian Linux kernel on raspi3 | 28 | * Fix infinite recursion in tlbi_aa64_vmalle1_write() |
29 | * ARM KVM: fix various bugs in handling of guest debugging | ||
30 | * Correctly implement handling of HCR_EL2.{VI, VF} | ||
31 | * Hyp mode R14 is shared with User and System | ||
32 | * Give Cortex-A15 and -A7 the EL2 feature | ||
26 | 33 | ||
27 | ---------------------------------------------------------------- | 34 | ---------------------------------------------------------------- |
28 | Andrey Smirnov (2): | 35 | Alex Bennée (6): |
29 | char: i.MX: Simplify imx_update() | 36 | target/arm64: properly handle DBGVR RESS bits |
30 | char: i.MX: Add support for "TX complete" interrupt | 37 | target/arm64: hold BQL when calling do_interrupt() |
38 | target/arm64: kvm debug set target_el when passing exception to guest | ||
39 | tests/guest-debug: fix scoping of failcount | ||
40 | arm: use symbolic MDCR_TDE in arm_debug_target_el | ||
41 | arm: fix aa64_generate_debug_exceptions to work with EL2 | ||
31 | 42 | ||
32 | Guenter Roeck (1): | 43 | Eric Auger (1): |
33 | fsl-imx6: Swap Ethernet interrupt defines | 44 | hw/arm/sysbus-fdt: Only call match_fn callback if the type matches |
34 | 45 | ||
35 | Peter Maydell (9): | 46 | Peter Maydell (7): |
36 | hw/arm/raspi: Don't do board-setup or secure-boot for raspi3 | 47 | target/arm: Remove workaround for small SAU regions |
37 | hw/arm/boot: assert that secure_boot and secure_board_setup are false for AArch64 | 48 | target/arm: Remove antique TODO comment |
38 | hw/arm/boot: If booting a kernel in EL2, set SCR_EL3.HCE | 49 | Revert "target/arm: Implement HCR.VI and VF" |
39 | hw/arm/bcm2386: Fix parent type of bcm2386 | 50 | target/arm: Track the state of our irq lines from the GIC explicitly |
40 | hw/arm/bcm2836: Rename bcm2836 type/struct to bcm283x | 51 | target/arm: Correctly implement handling of HCR_EL2.{VI, VF} |
41 | hw/arm/bcm2836: Create proper bcm2837 device | 52 | target/arm: Hyp mode R14 is shared with User and System |
42 | hw/arm/bcm2836: Use correct affinity values for BCM2837 | 53 | target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature |
43 | hw/arm/bcm2836: Hardcode correct CPU type | ||
44 | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs | ||
45 | 54 | ||
46 | Wei Huang (1): | 55 | Richard Henderson (1): |
47 | dump: Update correct kdump phys_base field for AArch64 | 56 | target/arm: Fix typo in tlbi_aa64_vmalle1_write |
48 | 57 | ||
49 | include/hw/arm/bcm2836.h | 31 +++++++++++++--- | 58 | Thomas Huth (1): |
50 | include/hw/arm/fsl-imx6.h | 4 +- | 59 | MAINTAINERS: Add an entry for the 'collie' machine |
51 | include/hw/char/imx_serial.h | 3 ++ | ||
52 | dump.c | 14 +++++-- | ||
53 | hw/arm/bcm2836.c | 87 +++++++++++++++++++++++++++++++------------- | ||
54 | hw/arm/boot.c | 12 ++++++ | ||
55 | hw/arm/raspi.c | 77 +++++++++++++++++++++++++++++++-------- | ||
56 | hw/char/imx_serial.c | 44 ++++++++++++++++------ | ||
57 | hw/net/imx_fec.c | 28 +++++++++++++- | ||
58 | 9 files changed, 237 insertions(+), 63 deletions(-) | ||
59 | 60 | ||
61 | target/arm/cpu.h | 44 +++++++++++------ | ||
62 | target/arm/internals.h | 34 +++++++++++++ | ||
63 | hw/arm/sysbus-fdt.c | 12 +++-- | ||
64 | target/arm/cpu.c | 66 ++++++++++++++++++++++++- | ||
65 | target/arm/helper.c | 101 +++++++++++++------------------------- | ||
66 | target/arm/kvm32.c | 4 +- | ||
67 | target/arm/kvm64.c | 20 +++++++- | ||
68 | target/arm/machine.c | 51 +++++++++++++++++++ | ||
69 | target/arm/op_helper.c | 4 +- | ||
70 | MAINTAINERS | 7 +++ | ||
71 | tests/guest-debug/test-gdbstub.py | 1 + | ||
72 | 11 files changed, 248 insertions(+), 96 deletions(-) | ||
73 | diff view generated by jsdifflib |
1 | If we're directly booting a Linux kernel and the CPU supports both | 1 | Before we supported direct execution from MMIO regions, we |
---|---|---|---|
2 | EL3 and EL2, we start the kernel in EL2, as it expects. We must also | 2 | implemented workarounds in commit 720424359917887c926a33d2 |
3 | set the SCR_EL3.HCE bit in this situation, so that the HVC | 3 | which let us avoid doing so, even if the SAU or MPU region |
4 | instruction is enabled rather than UNDEFing. Otherwise at least some | 4 | was less than page-sized. |
5 | kernels will panic when trying to initialize KVM in the guest. | 5 | |
6 | Once we implemented execute-from-MMIO, we removed part | ||
7 | of those workarounds in commit d4b6275df320cee76; but | ||
8 | we forgot the one in get_phys_addr_pmsav8() which | ||
9 | suppressed use of small SAU regions in executable regions. | ||
10 | Remove that workaround now. | ||
6 | 11 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20180313153458.26822-4-peter.maydell@linaro.org | 13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20181106163801.14474-1-peter.maydell@linaro.org | ||
9 | --- | 16 | --- |
10 | hw/arm/boot.c | 5 +++++ | 17 | target/arm/helper.c | 12 ------------ |
11 | 1 file changed, 5 insertions(+) | 18 | 1 file changed, 12 deletions(-) |
12 | 19 | ||
13 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 20 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/boot.c | 22 | --- a/target/arm/helper.c |
16 | +++ b/hw/arm/boot.c | 23 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 24 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, |
18 | assert(!info->secure_board_setup); | 25 | |
19 | } | 26 | ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, |
20 | 27 | txattrs, prot, &mpu_is_subpage, fi, NULL); | |
21 | + if (arm_feature(env, ARM_FEATURE_EL2)) { | 28 | - /* |
22 | + /* If we have EL2 then Linux expects the HVC insn to work */ | 29 | - * TODO: this is a temporary hack to ignore the fact that the SAU region |
23 | + env->cp15.scr_el3 |= SCR_HCE; | 30 | - * is smaller than a page if this is an executable region. We never |
24 | + } | 31 | - * supported small MPU regions, but we did (accidentally) allow small |
25 | + | 32 | - * SAU regions, and if we now made small SAU regions not be executable |
26 | /* Set to non-secure if not a secure boot */ | 33 | - * then this would break previously working guest code. We can't |
27 | if (!info->secure_boot && | 34 | - * remove this until/unless we implement support for execution from |
28 | (cs != first_cpu || !info->secure_board_setup)) { | 35 | - * small regions. |
36 | - */ | ||
37 | - if (*prot & PAGE_EXEC) { | ||
38 | - sattrs.subpage = false; | ||
39 | - } | ||
40 | *page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | ||
41 | return ret; | ||
42 | } | ||
29 | -- | 43 | -- |
30 | 2.16.2 | 44 | 2.19.1 |
31 | 45 | ||
32 | 46 | diff view generated by jsdifflib |
1 | For the rpi1 and 2 we want to boot the Linux kernel via some | 1 | Remove a TODO comment about implementing the vectored interrupt |
---|---|---|---|
2 | custom setup code that makes sure that the SMC instruction | 2 | controller. We have had an implementation of that for a decade; |
3 | acts as a no-op, because it's used for cache maintenance. | 3 | it's in hw/intc/pl190.c. |
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. | ||
7 | 4 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20181106164118.16184-1-peter.maydell@linaro.org | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
11 | Message-id: 20180313153458.26822-2-peter.maydell@linaro.org | 9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
12 | --- | 10 | --- |
13 | hw/arm/raspi.c | 17 +++++++++++++---- | 11 | target/arm/helper.c | 1 - |
14 | 1 file changed, 13 insertions(+), 4 deletions(-) | 12 | 1 file changed, 1 deletion(-) |
15 | 13 | ||
16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/raspi.c | 16 | --- a/target/arm/helper.c |
19 | +++ b/hw/arm/raspi.c | 17 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) |
21 | binfo.board_id = raspi_boardid[version]; | 19 | return; |
22 | binfo.ram_size = ram_size; | 20 | } |
23 | binfo.nb_cpus = smp_cpus; | 21 | |
24 | - binfo.board_setup_addr = BOARDSETUP_ADDR; | 22 | - /* TODO: Vectored interrupt controller. */ |
25 | - binfo.write_board_setup = write_board_setup; | 23 | switch (cs->exception_index) { |
26 | - binfo.secure_board_setup = true; | 24 | case EXCP_UDEF: |
27 | - binfo.secure_boot = true; | 25 | new_mode = ARM_CPU_MODE_UND; |
28 | + | ||
29 | + if (version <= 2) { | ||
30 | + /* The rpi1 and 2 require some custom setup code to run in Secure | ||
31 | + * mode before booting a kernel (to set up the SMC vectors so | ||
32 | + * that we get a no-op SMC; this is used by Linux to call the | ||
33 | + * firmware for some cache maintenance operations. | ||
34 | + * The rpi3 doesn't need this. | ||
35 | + */ | ||
36 | + binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
37 | + binfo.write_board_setup = write_board_setup; | ||
38 | + binfo.secure_board_setup = true; | ||
39 | + binfo.secure_boot = true; | ||
40 | + } | ||
41 | |||
42 | /* Pi2 and Pi3 requires SMP setup */ | ||
43 | if (version >= 2) { | ||
44 | -- | 26 | -- |
45 | 2.16.2 | 27 | 2.19.1 |
46 | 28 | ||
47 | 29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
1 | 2 | ||
3 | There is no active maintainer, but since Peter is picking up | ||
4 | patches via qemu-arm@nongnu.org, I think we could at least use | ||
5 | "Odd Fixes" as status here. | ||
6 | |||
7 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 1541528230-31817-1-git-send-email-thuth@redhat.com | ||
10 | [PMM: Also add myself as an M: contact] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | MAINTAINERS | 7 +++++++ | ||
14 | 1 file changed, 7 insertions(+) | ||
15 | |||
16 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/MAINTAINERS | ||
19 | +++ b/MAINTAINERS | ||
20 | @@ -XXX,XX +XXX,XX @@ F: hw/*/pxa2xx* | ||
21 | F: hw/misc/mst_fpga.c | ||
22 | F: include/hw/arm/pxa.h | ||
23 | |||
24 | +Sharp SL-5500 (Collie) PDA | ||
25 | +M: Peter Maydell <peter.maydell@linaro.org> | ||
26 | +L: qemu-arm@nongnu.org | ||
27 | +S: Odd Fixes | ||
28 | +F: hw/arm/collie.c | ||
29 | +F: hw/arm/strongarm* | ||
30 | + | ||
31 | Stellaris | ||
32 | M: Peter Maydell <peter.maydell@linaro.org> | ||
33 | L: qemu-arm@nongnu.org | ||
34 | -- | ||
35 | 2.19.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
1 | Now we have separate types for BCM2386 and BCM2387, we might as well | 1 | From: Eric Auger <eric.auger@redhat.com> |
---|---|---|---|
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. | ||
5 | 2 | ||
6 | Note that this change means that it's no longer possible on | 3 | Commit af7d64ede0b9 (hw/arm/sysbus-fdt: Allow device matching with DT |
7 | the command line to use -cpu to ask for a different kind of | 4 | compatible value) introduced a match_fn callback which gets called |
8 | CPU than the SoC supports. This was never a supported thing to | 5 | for each registered combo to check whether a sysbus device can be |
9 | do anyway; we were just not sanity-checking the command line. | 6 | dynamically instantiated. However the callback gets called even if |
7 | the device type does not match the binding combo typename field. | ||
8 | This causes an assert when passing "-device ramfb" to the qemu | ||
9 | command line as vfio_platform_match() gets called on a non | ||
10 | vfio-platform device. | ||
10 | 11 | ||
11 | This does require us to only build the bcm2837 object on | 12 | To fix this regression, let's change the add_fdt_node() logic so |
12 | TARGET_AARCH64 configs, since otherwise it won't instantiate | 13 | that we first check the type and if the match_fn callback is defined, |
13 | due to the missing cortex-a53 device and "make check" will fail. | 14 | then we also call it. |
14 | 15 | ||
16 | Binding combos only requesting a type check do not define the | ||
17 | match_fn callback. | ||
18 | |||
19 | Fixes: af7d64ede0b9 (hw/arm/sysbus-fdt: Allow device matching with | ||
20 | DT compatible value) | ||
21 | |||
22 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
23 | Reported-by: Thomas Huth <thuth@redhat.com> | ||
24 | Reviewed-by: Alex Williamson <alex.williamson@redhat.com> | ||
25 | Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> | ||
26 | Message-id: 20181106184212.29377-1-eric.auger@redhat.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | 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 | ||
19 | --- | 28 | --- |
20 | hw/arm/bcm2836.c | 24 +++++++++++++++--------- | 29 | hw/arm/sysbus-fdt.c | 12 +++++++----- |
21 | hw/arm/raspi.c | 2 -- | 30 | 1 file changed, 7 insertions(+), 5 deletions(-) |
22 | 2 files changed, 15 insertions(+), 11 deletions(-) | ||
23 | 31 | ||
24 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 32 | diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c |
25 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/arm/bcm2836.c | 34 | --- a/hw/arm/sysbus-fdt.c |
27 | +++ b/hw/arm/bcm2836.c | 35 | +++ b/hw/arm/sysbus-fdt.c |
28 | @@ -XXX,XX +XXX,XX @@ | 36 | @@ -XXX,XX +XXX,XX @@ static bool type_match(SysBusDevice *sbdev, const BindingEntry *entry) |
29 | 37 | return !strcmp(object_get_typename(OBJECT(sbdev)), entry->typename); | |
30 | struct BCM283XInfo { | ||
31 | const char *name; | ||
32 | + const char *cpu_type; | ||
33 | int clusterid; | ||
34 | }; | ||
35 | |||
36 | static const BCM283XInfo bcm283x_socs[] = { | ||
37 | { | ||
38 | .name = TYPE_BCM2836, | ||
39 | + .cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"), | ||
40 | .clusterid = 0xf, | ||
41 | }, | ||
42 | +#ifdef TARGET_AARCH64 | ||
43 | { | ||
44 | .name = TYPE_BCM2837, | ||
45 | + .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"), | ||
46 | .clusterid = 0x0, | ||
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; | ||
57 | + | ||
58 | + for (n = 0; n < BCM283X_NCPUS; n++) { | ||
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); | ||
63 | + } | ||
64 | |||
65 | object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); | ||
66 | object_property_add_child(obj, "control", OBJECT(&s->control), NULL); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
68 | |||
69 | /* common peripherals from bcm2835 */ | ||
70 | |||
71 | - obj = OBJECT(dev); | ||
72 | - for (n = 0; n < BCM283X_NCPUS; n++) { | ||
73 | - object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | ||
74 | - s->cpu_type); | ||
75 | - object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
76 | - &error_abort); | ||
77 | - } | ||
78 | - | ||
79 | obj = object_property_get_link(OBJECT(dev), "ram", &err); | ||
80 | if (obj == NULL) { | ||
81 | error_setg(errp, "%s: required ram link not found: %s", | ||
82 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
83 | } | 38 | } |
84 | 39 | ||
85 | static Property bcm2836_props[] = { | 40 | -#define TYPE_BINDING(type, add_fn) {(type), NULL, (add_fn), type_match} |
86 | - DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), | 41 | +#define TYPE_BINDING(type, add_fn) {(type), NULL, (add_fn), NULL} |
87 | DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, | 42 | |
88 | BCM283X_NCPUS), | 43 | /* list of supported dynamic sysbus bindings */ |
89 | DEFINE_PROP_END_OF_LIST() | 44 | static const BindingEntry bindings[] = { |
90 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 45 | @@ -XXX,XX +XXX,XX @@ static void add_fdt_node(SysBusDevice *sbdev, void *opaque) |
91 | index XXXXXXX..XXXXXXX 100644 | 46 | for (i = 0; i < ARRAY_SIZE(bindings); i++) { |
92 | --- a/hw/arm/raspi.c | 47 | const BindingEntry *iter = &bindings[i]; |
93 | +++ b/hw/arm/raspi.c | 48 | |
94 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | 49 | - if (iter->match_fn(sbdev, iter)) { |
95 | /* Setup the SOC */ | 50 | - ret = iter->add_fn(sbdev, opaque); |
96 | object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), | 51 | - assert(!ret); |
97 | &error_abort); | 52 | - return; |
98 | - object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type", | 53 | + if (type_match(sbdev, iter)) { |
99 | - &error_abort); | 54 | + if (!iter->match_fn || iter->match_fn(sbdev, iter)) { |
100 | object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus", | 55 | + ret = iter->add_fn(sbdev, opaque); |
101 | &error_abort); | 56 | + assert(!ret); |
102 | int board_rev = version == 3 ? 0xa02082 : 0xa21041; | 57 | + return; |
58 | + } | ||
59 | } | ||
60 | } | ||
61 | error_report("Device %s can not be dynamically instantiated", | ||
103 | -- | 62 | -- |
104 | 2.16.2 | 63 | 2.19.1 |
105 | 64 | ||
106 | 65 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add support for "TX complete"/TXDC interrupt generate by real HW since | 3 | This would cause an infinite recursion or loop. |
4 | it is needed to support guests other than Linux. | ||
5 | 4 | ||
6 | Based on the patch by Bill Paul as found here: | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | https://bugs.launchpad.net/qemu/+bug/1753314 | 6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | |
9 | Cc: qemu-devel@nongnu.org | 8 | Message-id: 20181110121711.15257-1-richard.henderson@linaro.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 | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 11 | --- |
19 | include/hw/char/imx_serial.h | 3 +++ | 12 | target/arm/helper.c | 2 +- |
20 | hw/char/imx_serial.c | 20 +++++++++++++++++--- | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
21 | 2 files changed, 20 insertions(+), 3 deletions(-) | ||
22 | 14 | ||
23 | diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
24 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/char/imx_serial.h | 17 | --- a/target/arm/helper.c |
26 | +++ b/include/hw/char/imx_serial.h | 18 | +++ b/target/arm/helper.c |
27 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri, |
28 | #define UCR2_RXEN (1<<1) /* Receiver enable */ | 20 | CPUState *cs = ENV_GET_CPU(env); |
29 | #define UCR2_SRST (1<<0) /* Reset complete */ | 21 | |
30 | 22 | if (tlb_force_broadcast(env)) { | |
31 | +#define UCR4_TCEN BIT(3) /* TX complete interrupt enable */ | 23 | - tlbi_aa64_vmalle1_write(env, NULL, value); |
32 | + | 24 | + tlbi_aa64_vmalle1is_write(env, NULL, value); |
33 | #define UTS1_TXEMPTY (1<<6) | 25 | return; |
34 | #define UTS1_RXEMPTY (1<<5) | 26 | } |
35 | #define UTS1_TXFULL (1<<4) | 27 | |
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 | }, | ||
66 | }; | ||
67 | @@ -XXX,XX +XXX,XX @@ static void imx_update(IMXSerialState *s) | ||
68 | * unfortunately. | ||
69 | */ | ||
70 | mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; | ||
71 | + /* | ||
72 | + * TCEN and TXDC are both bit 3 | ||
73 | + */ | ||
74 | + mask |= s->ucr4 & UCR4_TCEN; | ||
75 | + | ||
76 | usr2 = s->usr2 & mask; | ||
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 */ | ||
113 | -- | 28 | -- |
114 | 2.16.2 | 29 | 2.19.1 |
115 | 30 | ||
116 | 31 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
1 | 2 | ||
3 | This only fails with some (broken) versions of gdb but we should | ||
4 | treat the top bits of DBGBVR as RESS. Properly sign extend QEMU's | ||
5 | reference copy of dbgbvr and also update the register descriptions in | ||
6 | the comment. | ||
7 | |||
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20181109152119.9242-2-alex.bennee@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/kvm64.c | 17 +++++++++++++++-- | ||
14 | 1 file changed, 15 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/kvm64.c | ||
19 | +++ b/target/arm/kvm64.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_init_debug(CPUState *cs) | ||
21 | * capable of fancier matching but that will require exposing that | ||
22 | * fanciness to GDB's interface | ||
23 | * | ||
24 | - * D7.3.2 DBGBCR<n>_EL1, Debug Breakpoint Control Registers | ||
25 | + * DBGBCR<n>_EL1, Debug Breakpoint Control Registers | ||
26 | * | ||
27 | * 31 24 23 20 19 16 15 14 13 12 9 8 5 4 3 2 1 0 | ||
28 | * +------+------+-------+-----+----+------+-----+------+-----+---+ | ||
29 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_init_debug(CPUState *cs) | ||
30 | * SSC/HMC/PMC: Security, Higher and Priv access control (Table D-12) | ||
31 | * BAS: Byte Address Select (RES1 for AArch64) | ||
32 | * E: Enable bit | ||
33 | + * | ||
34 | + * DBGBVR<n>_EL1, Debug Breakpoint Value Registers | ||
35 | + * | ||
36 | + * 63 53 52 49 48 2 1 0 | ||
37 | + * +------+-----------+----------+-----+ | ||
38 | + * | RESS | VA[52:49] | VA[48:2] | 0 0 | | ||
39 | + * +------+-----------+----------+-----+ | ||
40 | + * | ||
41 | + * Depending on the addressing mode bits the top bits of the register | ||
42 | + * are a sign extension of the highest applicable VA bit. Some | ||
43 | + * versions of GDB don't do it correctly so we ensure they are correct | ||
44 | + * here so future PC comparisons will work properly. | ||
45 | */ | ||
46 | + | ||
47 | static int insert_hw_breakpoint(target_ulong addr) | ||
48 | { | ||
49 | HWBreakpoint brk = { | ||
50 | .bcr = 0x1, /* BCR E=1, enable */ | ||
51 | - .bvr = addr | ||
52 | + .bvr = sextract64(addr, 0, 53) | ||
53 | }; | ||
54 | |||
55 | if (cur_hw_bps >= max_hw_bps) { | ||
56 | -- | ||
57 | 2.19.1 | ||
58 | |||
59 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
1 | 2 | ||
3 | Fix the assertion failure when running interrupts. | ||
4 | |||
5 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20181109152119.9242-3-alex.bennee@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/kvm64.c | 2 ++ | ||
12 | 1 file changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/kvm64.c | ||
17 | +++ b/target/arm/kvm64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) | ||
19 | cs->exception_index = EXCP_BKPT; | ||
20 | env->exception.syndrome = debug_exit->hsr; | ||
21 | env->exception.vaddress = debug_exit->far; | ||
22 | + qemu_mutex_lock_iothread(); | ||
23 | cc->do_interrupt(cs); | ||
24 | + qemu_mutex_unlock_iothread(); | ||
25 | |||
26 | return false; | ||
27 | } | ||
28 | -- | ||
29 | 2.19.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
1 | From: Wei Huang <wei@redhat.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | For guest kernel that supports KASLR, the load address can change every | 3 | When we are debugging the guest all exceptions come our way but might |
4 | time when guest VM runs. To find the physical base address correctly, | 4 | be for the guest's own debug exceptions. We use the ->do_interrupt() |
5 | current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=". | 5 | infrastructure to inject the exception into the guest. However, we are |
6 | However this string pattern is only available on x86_64. AArch64 uses a | 6 | missing a full setup of the exception structure, causing an assert |
7 | different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure | 7 | later down the line. |
8 | QEMU dump uses the correct string on AArch64. | ||
9 | 8 | ||
10 | Signed-off-by: Wei Huang <wei@redhat.com> | 9 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
11 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Message-id: 1520615003-20869-1-git-send-email-wei@redhat.com | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20181109152119.9242-4-alex.bennee@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 14 | --- |
15 | dump.c | 14 +++++++++++--- | 15 | target/arm/kvm64.c | 1 + |
16 | 1 file changed, 11 insertions(+), 3 deletions(-) | 16 | 1 file changed, 1 insertion(+) |
17 | 17 | ||
18 | diff --git a/dump.c b/dump.c | 18 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c |
19 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/dump.c | 20 | --- a/target/arm/kvm64.c |
21 | +++ b/dump.c | 21 | +++ b/target/arm/kvm64.c |
22 | @@ -XXX,XX +XXX,XX @@ static void vmcoreinfo_update_phys_base(DumpState *s) | 22 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) |
23 | 23 | cs->exception_index = EXCP_BKPT; | |
24 | lines = g_strsplit((char *)vmci, "\n", -1); | 24 | env->exception.syndrome = debug_exit->hsr; |
25 | for (i = 0; lines[i]; i++) { | 25 | env->exception.vaddress = debug_exit->far; |
26 | - if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) { | 26 | + env->exception.target_el = 1; |
27 | - if (qemu_strtou64(lines[i] + 18, NULL, 16, | 27 | qemu_mutex_lock_iothread(); |
28 | + const char *prefix = NULL; | 28 | cc->do_interrupt(cs); |
29 | + | 29 | qemu_mutex_unlock_iothread(); |
30 | + if (s->dump_info.d_machine == EM_X86_64) { | ||
31 | + prefix = "NUMBER(phys_base)="; | ||
32 | + } else if (s->dump_info.d_machine == EM_AARCH64) { | ||
33 | + prefix = "NUMBER(PHYS_OFFSET)="; | ||
34 | + } | ||
35 | + | ||
36 | + if (prefix && g_str_has_prefix(lines[i], prefix)) { | ||
37 | + if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16, | ||
38 | &phys_base) < 0) { | ||
39 | - warn_report("Failed to read NUMBER(phys_base)="); | ||
40 | + warn_report("Failed to read %s", prefix); | ||
41 | } else { | ||
42 | s->dump_info.phys_base = phys_base; | ||
43 | } | ||
44 | -- | 30 | -- |
45 | 2.16.2 | 31 | 2.19.1 |
46 | 32 | ||
47 | 33 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The sabrelite machine model used by qemu-system-arm is based on the | 3 | You should declare you are using a global version of a variable before |
4 | Freescale/NXP i.MX6Q processor. This SoC has an on-board ethernet | 4 | you attempt to modify it in a function. |
5 | controller which is supported in QEMU using the imx_fec.c module | ||
6 | (actually called imx.enet for this model.) | ||
7 | 5 | ||
8 | The include/hw/arm/fsm-imx6.h file defines the interrupt vectors for the | 6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
9 | imx.enet device like this: | ||
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> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20181109152119.9242-5-alex.bennee@linaro.org | ||
42 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
43 | --- | 11 | --- |
44 | include/hw/arm/fsl-imx6.h | 4 ++-- | 12 | tests/guest-debug/test-gdbstub.py | 1 + |
45 | hw/net/imx_fec.c | 28 +++++++++++++++++++++++++++- | 13 | 1 file changed, 1 insertion(+) |
46 | 2 files changed, 29 insertions(+), 3 deletions(-) | ||
47 | 14 | ||
48 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h | 15 | diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py |
49 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/include/hw/arm/fsl-imx6.h | 17 | --- a/tests/guest-debug/test-gdbstub.py |
51 | +++ b/include/hw/arm/fsl-imx6.h | 18 | +++ b/tests/guest-debug/test-gdbstub.py |
52 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State { | 19 | @@ -XXX,XX +XXX,XX @@ def report(cond, msg): |
53 | #define FSL_IMX6_HDMI_MASTER_IRQ 115 | 20 | print ("PASS: %s" % (msg)) |
54 | #define FSL_IMX6_HDMI_CEC_IRQ 116 | 21 | else: |
55 | #define FSL_IMX6_MLB150_LOW_IRQ 117 | 22 | print ("FAIL: %s" % (msg)) |
56 | -#define FSL_IMX6_ENET_MAC_1588_IRQ 118 | 23 | + global failcount |
57 | -#define FSL_IMX6_ENET_MAC_IRQ 119 | 24 | failcount += 1 |
58 | +#define FSL_IMX6_ENET_MAC_IRQ 118 | 25 | |
59 | +#define FSL_IMX6_ENET_MAC_1588_IRQ 119 | 26 | |
60 | #define FSL_IMX6_PCIE1_IRQ 120 | ||
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 | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/net/imx_fec.c | ||
66 | +++ b/hw/net/imx_fec.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr) | ||
68 | |||
69 | static void imx_eth_update(IMXFECState *s) | ||
70 | { | ||
71 | - if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & ENET_INT_TS_TIMER) { | ||
72 | + /* | ||
73 | + * Previous versions of qemu had the ENET_INT_MAC and ENET_INT_TS_TIMER | ||
74 | + * interrupts swapped. This worked with older versions of Linux (4.14 | ||
75 | + * and older) since Linux associated both interrupt lines with Ethernet | ||
76 | + * MAC interrupts. Specifically, | ||
77 | + * - Linux 4.15 and later have separate interrupt handlers for the MAC and | ||
78 | + * timer interrupts. Those versions of Linux fail with versions of QEMU | ||
79 | + * with swapped interrupt assignments. | ||
80 | + * - In linux 4.14, both interrupt lines were registered with the Ethernet | ||
81 | + * MAC interrupt handler. As a result, all versions of qemu happen to | ||
82 | + * work, though that is accidental. | ||
83 | + * - In Linux 4.9 and older, the timer interrupt was registered directly | ||
84 | + * with the Ethernet MAC interrupt handler. The MAC interrupt was | ||
85 | + * redirected to a GPIO interrupt to work around erratum ERR006687. | ||
86 | + * This was implemented using the SOC's IOMUX block. In qemu, this GPIO | ||
87 | + * interrupt never fired since IOMUX is currently not supported in qemu. | ||
88 | + * Linux instead received MAC interrupts on the timer interrupt. | ||
89 | + * As a result, qemu versions with the swapped interrupt assignment work, | ||
90 | + * albeit accidentally, but qemu versions with the correct interrupt | ||
91 | + * assignment fail. | ||
92 | + * | ||
93 | + * To ensure that all versions of Linux work, generate ENET_INT_MAC | ||
94 | + * interrrupts on both interrupt lines. This should be changed if and when | ||
95 | + * qemu supports IOMUX. | ||
96 | + */ | ||
97 | + if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & | ||
98 | + (ENET_INT_MAC | ENET_INT_TS_TIMER)) { | ||
99 | qemu_set_irq(s->irq[1], 1); | ||
100 | } else { | ||
101 | qemu_set_irq(s->irq[1], 0); | ||
102 | -- | 27 | -- |
103 | 2.16.2 | 28 | 2.19.1 |
104 | 29 | ||
105 | 30 | diff view generated by jsdifflib |
1 | The TypeInfo and state struct for bcm2386 disagree about what the | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
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. | ||
9 | 2 | ||
3 | We already have this symbol defined so lets use it. | ||
4 | |||
5 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20181109152119.9242-7-alex.bennee@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20180313153458.26822-5-peter.maydell@linaro.org | ||
14 | --- | 9 | --- |
15 | hw/arm/bcm2836.c | 2 +- | 10 | target/arm/cpu.h | 2 +- |
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
17 | 12 | ||
18 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
19 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/bcm2836.c | 15 | --- a/target/arm/cpu.h |
21 | +++ b/hw/arm/bcm2836.c | 16 | +++ b/target/arm/cpu.h |
22 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) | 17 | @@ -XXX,XX +XXX,XX @@ static inline int arm_debug_target_el(CPUARMState *env) |
23 | 18 | ||
24 | static const TypeInfo bcm2836_type_info = { | 19 | if (arm_feature(env, ARM_FEATURE_EL2) && !secure) { |
25 | .name = TYPE_BCM2836, | 20 | route_to_el2 = env->cp15.hcr_el2 & HCR_TGE || |
26 | - .parent = TYPE_SYS_BUS_DEVICE, | 21 | - env->cp15.mdcr_el2 & (1 << 8); |
27 | + .parent = TYPE_DEVICE, | 22 | + env->cp15.mdcr_el2 & MDCR_TDE; |
28 | .instance_size = sizeof(BCM2836State), | 23 | } |
29 | .instance_init = bcm2836_init, | 24 | |
30 | .class_init = bcm2836_class_init, | 25 | if (route_to_el2) { |
31 | -- | 26 | -- |
32 | 2.16.2 | 27 | 2.19.1 |
33 | 28 | ||
34 | 29 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Code of imx_update() is slightly confusing since the "flags" variable | 3 | The test was incomplete and incorrectly caused debug exceptions to be |
4 | doesn't really corespond to anything in real hardware and server as a | 4 | generated when returning to EL2 after a failed attempt to single-step |
5 | kitchensink accumulating events normally reported via USR1 and USR2 | 5 | an EL1 instruction. Fix this while cleaning up the function a little. |
6 | registers. | ||
7 | 6 | ||
8 | Change the code to explicitly evaluate state of interrupts reported | 7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
9 | via USR1 and USR2 against corresponding masking bits and use the to | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | detemine if IRQ line should be asserted or not. | 9 | Message-id: 20181109152119.9242-8-alex.bennee@linaro.org |
11 | |||
12 | NOTE: Check for UTS1_TXEMPTY being set has been dropped for two | ||
13 | reasons: | ||
14 | |||
15 | 1. Emulation code implements a single character FIFO, so this flag | ||
16 | will always be set since characters are trasmitted as a part of | ||
17 | the code emulating "push" into the FIFO | ||
18 | |||
19 | 2. imx_update() is really just a function doing ORing and maksing | ||
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 | ||
30 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
32 | --- | 11 | --- |
33 | hw/char/imx_serial.c | 24 ++++++++++++++++-------- | 12 | target/arm/cpu.h | 39 ++++++++++++++++++++++++--------------- |
34 | 1 file changed, 16 insertions(+), 8 deletions(-) | 13 | 1 file changed, 24 insertions(+), 15 deletions(-) |
35 | 14 | ||
36 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
37 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/char/imx_serial.c | 17 | --- a/target/arm/cpu.h |
39 | +++ b/hw/char/imx_serial.c | 18 | +++ b/target/arm/cpu.h |
40 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = { | 19 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu) |
41 | 20 | return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0; | |
42 | static void imx_update(IMXSerialState *s) | 21 | } |
22 | |||
23 | +/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */ | ||
24 | static inline bool aa64_generate_debug_exceptions(CPUARMState *env) | ||
43 | { | 25 | { |
44 | - uint32_t flags; | 26 | - if (arm_is_secure(env)) { |
45 | + uint32_t usr1; | 27 | - /* MDCR_EL3.SDD disables debug events from Secure state */ |
46 | + uint32_t usr2; | 28 | - if (extract32(env->cp15.mdcr_el3, 16, 1) != 0 |
47 | + uint32_t mask; | 29 | - || arm_current_el(env) == 3) { |
48 | 30 | - return false; | |
49 | - flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY); | 31 | - } |
50 | - if (s->ucr1 & UCR1_TXMPTYEN) { | 32 | + int cur_el = arm_current_el(env); |
51 | - flags |= (s->uts1 & UTS1_TXEMPTY); | 33 | + int debug_el; |
52 | - } else { | 34 | + |
53 | - flags &= ~USR1_TRDY; | 35 | + if (cur_el == 3) { |
54 | - } | 36 | + return false; |
37 | } | ||
38 | |||
39 | - if (arm_current_el(env) == arm_debug_target_el(env)) { | ||
40 | - if ((extract32(env->cp15.mdscr_el1, 13, 1) == 0) | ||
41 | - || (env->daif & PSTATE_D)) { | ||
42 | - return false; | ||
43 | - } | ||
44 | + /* MDCR_EL3.SDD disables debug events from Secure state */ | ||
45 | + if (arm_is_secure_below_el3(env) | ||
46 | + && extract32(env->cp15.mdcr_el3, 16, 1)) { | ||
47 | + return false; | ||
48 | } | ||
49 | - return true; | ||
50 | + | ||
55 | + /* | 51 | + /* |
56 | + * Lucky for us TRDY and RRDY has the same offset in both USR1 and | 52 | + * Same EL to same EL debug exceptions need MDSCR_KDE enabled |
57 | + * UCR1, so we can get away with something as simple as the | 53 | + * while not masking the (D)ebug bit in DAIF. |
58 | + * following: | ||
59 | + */ | 54 | + */ |
60 | + usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY); | 55 | + debug_el = arm_debug_target_el(env); |
61 | + /* | 56 | + |
62 | + * Bits that we want in USR2 are not as conveniently laid out, | 57 | + if (cur_el == debug_el) { |
63 | + * unfortunately. | 58 | + return extract32(env->cp15.mdscr_el1, 13, 1) |
64 | + */ | 59 | + && !(env->daif & PSTATE_D); |
65 | + mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; | 60 | + } |
66 | + usr2 = s->usr2 & mask; | 61 | + |
67 | 62 | + /* Otherwise the debug target needs to be a higher EL */ | |
68 | - qemu_set_irq(s->irq, !!flags); | 63 | + return debug_el > cur_el; |
69 | + qemu_set_irq(s->irq, usr1 || usr2); | ||
70 | } | 64 | } |
71 | 65 | ||
72 | static void imx_serial_reset(IMXSerialState *s) | 66 | static inline bool aa32_generate_debug_exceptions(CPUARMState *env) |
67 | @@ -XXX,XX +XXX,XX @@ static inline bool aa32_generate_debug_exceptions(CPUARMState *env) | ||
68 | * since the pseudocode has it at all callsites except for the one in | ||
69 | * CheckSoftwareStep(), where it is elided because both branches would | ||
70 | * always return the same value. | ||
71 | - * | ||
72 | - * Parts of the pseudocode relating to EL2 and EL3 are omitted because we | ||
73 | - * don't yet implement those exception levels or their associated trap bits. | ||
74 | */ | ||
75 | static inline bool arm_generate_debug_exceptions(CPUARMState *env) | ||
76 | { | ||
73 | -- | 77 | -- |
74 | 2.16.2 | 78 | 2.19.1 |
75 | 79 | ||
76 | 80 | diff view generated by jsdifflib |
1 | The bcm2837 is pretty similar to the bcm2836, but it does have | 1 | This reverts commit 8a0fc3a29fc2315325400c738f807d0d4ae0ab7f. |
---|---|---|---|
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. | ||
5 | 2 | ||
6 | Rather than trying to have one device with properties that | 3 | The implementation of HCR.VI and VF in that commit is not |
7 | configure it differently for the two cases, create two | 4 | correct -- they do not track the overall "is there a pending |
8 | separate QOM devices for the two SoCs. We use the same approach | 5 | VIRQ or VFIQ" status, but whether there is a pending interrupt |
9 | as hw/arm/aspeed_soc.c and share code and have a data table | 6 | due to "this mechanism", ie the hypervisor having set the VI/VF |
10 | that might differ per-SoC. For the moment the two types don't | 7 | bits. The overall pending state for VIRQ and VFIQ is effectively |
11 | actually have different behaviour. | 8 | the logical OR of the inbound lines from the GIC with the |
9 | VI and VF bits. Commit 8a0fc3a29fc231 would result in pending | ||
10 | VIRQ/VFIQ possibly being lost when the hypervisor wrote to HCR. | ||
11 | |||
12 | As a preliminary to implementing the HCR.VI/VF feature properly, | ||
13 | revert the broken one entirely. | ||
12 | 14 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 16 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | Message-id: 20180313153458.26822-7-peter.maydell@linaro.org | 17 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
18 | Message-id: 20181109134731.11605-2-peter.maydell@linaro.org | ||
16 | --- | 19 | --- |
17 | include/hw/arm/bcm2836.h | 19 +++++++++++++++++++ | 20 | target/arm/helper.c | 47 ++++----------------------------------------- |
18 | hw/arm/bcm2836.c | 37 ++++++++++++++++++++++++++++++++----- | 21 | 1 file changed, 4 insertions(+), 43 deletions(-) |
19 | hw/arm/raspi.c | 3 ++- | ||
20 | 3 files changed, 53 insertions(+), 6 deletions(-) | ||
21 | 22 | ||
22 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 23 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
23 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/arm/bcm2836.h | 25 | --- a/target/arm/helper.c |
25 | +++ b/include/hw/arm/bcm2836.h | 26 | +++ b/target/arm/helper.c |
26 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { |
27 | 28 | static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | |
28 | #define BCM283X_NCPUS 4 | ||
29 | |||
30 | +/* These type names are for specific SoCs; other than instantiating | ||
31 | + * them, code using these devices should always handle them via the | ||
32 | + * BCM283x base class, so they have no BCM2836(obj) etc macros. | ||
33 | + */ | ||
34 | +#define TYPE_BCM2836 "bcm2836" | ||
35 | +#define TYPE_BCM2837 "bcm2837" | ||
36 | + | ||
37 | typedef struct BCM283XState { | ||
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 | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | /* "QA7" (Pi2) interrupt controller and mailboxes etc. */ | ||
63 | #define BCM2836_CONTROL_BASE 0x40000000 | ||
64 | |||
65 | +struct BCM283XInfo { | ||
66 | + const char *name; | ||
67 | +}; | ||
68 | + | ||
69 | +static const BCM283XInfo bcm283x_socs[] = { | ||
70 | + { | ||
71 | + .name = TYPE_BCM2836, | ||
72 | + }, | ||
73 | + { | ||
74 | + .name = TYPE_BCM2837, | ||
75 | + }, | ||
76 | +}; | ||
77 | + | ||
78 | static void bcm2836_init(Object *obj) | ||
79 | { | 29 | { |
80 | BCM283XState *s = BCM283X(obj); | 30 | ARMCPU *cpu = arm_env_get_cpu(env); |
81 | @@ -XXX,XX +XXX,XX @@ static Property bcm2836_props[] = { | 31 | - CPUState *cs = ENV_GET_CPU(env); |
82 | DEFINE_PROP_END_OF_LIST() | 32 | uint64_t valid_mask = HCR_MASK; |
83 | }; | 33 | |
84 | 34 | if (arm_feature(env, ARM_FEATURE_EL3)) { | |
85 | -static void bcm2836_class_init(ObjectClass *oc, void *data) | 35 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
86 | +static void bcm283x_class_init(ObjectClass *oc, void *data) | 36 | /* Clear RES0 bits. */ |
87 | { | 37 | value &= valid_mask; |
88 | DeviceClass *dc = DEVICE_CLASS(oc); | 38 | |
89 | + BCM283XClass *bc = BCM283X_CLASS(oc); | 39 | - /* |
90 | 40 | - * VI and VF are kept in cs->interrupt_request. Modifying that | |
91 | - dc->props = bcm2836_props; | 41 | - * requires that we have the iothread lock, which is done by |
92 | + bc->info = data; | 42 | - * marking the reginfo structs as ARM_CP_IO. |
93 | dc->realize = bcm2836_realize; | 43 | - * Note that if a write to HCR pends a VIRQ or VFIQ it is never |
94 | + dc->props = bcm2836_props; | 44 | - * possible for it to be taken immediately, because VIRQ and |
45 | - * VFIQ are masked unless running at EL0 or EL1, and HCR | ||
46 | - * can only be written at EL2. | ||
47 | - */ | ||
48 | - g_assert(qemu_mutex_iothread_locked()); | ||
49 | - if (value & HCR_VI) { | ||
50 | - cs->interrupt_request |= CPU_INTERRUPT_VIRQ; | ||
51 | - } else { | ||
52 | - cs->interrupt_request &= ~CPU_INTERRUPT_VIRQ; | ||
53 | - } | ||
54 | - if (value & HCR_VF) { | ||
55 | - cs->interrupt_request |= CPU_INTERRUPT_VFIQ; | ||
56 | - } else { | ||
57 | - cs->interrupt_request &= ~CPU_INTERRUPT_VFIQ; | ||
58 | - } | ||
59 | - value &= ~(HCR_VI | HCR_VF); | ||
60 | - | ||
61 | /* These bits change the MMU setup: | ||
62 | * HCR_VM enables stage 2 translation | ||
63 | * HCR_PTW forbids certain page-table setups | ||
64 | @@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | ||
65 | hcr_write(env, NULL, value); | ||
95 | } | 66 | } |
96 | 67 | ||
97 | -static const TypeInfo bcm2836_type_info = { | 68 | -static uint64_t hcr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
98 | +static const TypeInfo bcm283x_type_info = { | 69 | -{ |
99 | .name = TYPE_BCM283X, | 70 | - /* The VI and VF bits live in cs->interrupt_request */ |
100 | .parent = TYPE_DEVICE, | 71 | - uint64_t ret = env->cp15.hcr_el2 & ~(HCR_VI | HCR_VF); |
101 | .instance_size = sizeof(BCM283XState), | 72 | - CPUState *cs = ENV_GET_CPU(env); |
102 | .instance_init = bcm2836_init, | 73 | - |
103 | - .class_init = bcm2836_class_init, | 74 | - if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) { |
104 | + .class_size = sizeof(BCM283XClass), | 75 | - ret |= HCR_VI; |
105 | + .abstract = true, | 76 | - } |
106 | }; | 77 | - if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) { |
107 | 78 | - ret |= HCR_VF; | |
108 | static void bcm2836_register_types(void) | 79 | - } |
109 | { | 80 | - return ret; |
110 | - type_register_static(&bcm2836_type_info); | 81 | -} |
111 | + int i; | 82 | - |
112 | + | 83 | static const ARMCPRegInfo el2_cp_reginfo[] = { |
113 | + type_register_static(&bcm283x_type_info); | 84 | { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64, |
114 | + for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) { | 85 | - .type = ARM_CP_IO, |
115 | + TypeInfo ti = { | 86 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, |
116 | + .name = bcm283x_socs[i].name, | 87 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), |
117 | + .parent = TYPE_BCM283X, | 88 | - .writefn = hcr_write, .readfn = hcr_read }, |
118 | + .class_init = bcm283x_class_init, | 89 | + .writefn = hcr_write }, |
119 | + .class_data = (void *) &bcm283x_socs[i], | 90 | { .name = "HCR", .state = ARM_CP_STATE_AA32, |
120 | + }; | 91 | - .type = ARM_CP_ALIAS | ARM_CP_IO, |
121 | + type_register(&ti); | 92 | + .type = ARM_CP_ALIAS, |
122 | + } | 93 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, |
123 | } | 94 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), |
124 | 95 | - .writefn = hcr_writelow, .readfn = hcr_read }, | |
125 | type_init(bcm2836_register_types) | 96 | + .writefn = hcr_writelow }, |
126 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 97 | { .name = "ELR_EL2", .state = ARM_CP_STATE_AA64, |
127 | index XXXXXXX..XXXXXXX 100644 | 98 | .type = ARM_CP_ALIAS, |
128 | --- a/hw/arm/raspi.c | 99 | .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 1, |
129 | +++ b/hw/arm/raspi.c | 100 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { |
130 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | 101 | |
131 | BusState *bus; | 102 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { |
132 | DeviceState *carddev; | 103 | { .name = "HCR2", .state = ARM_CP_STATE_AA32, |
133 | 104 | - .type = ARM_CP_ALIAS | ARM_CP_IO, | |
134 | - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); | 105 | + .type = ARM_CP_ALIAS, |
135 | + object_initialize(&s->soc, sizeof(s->soc), | 106 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, |
136 | + version == 3 ? TYPE_BCM2837 : TYPE_BCM2836); | 107 | .access = PL2_RW, |
137 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), | 108 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), |
138 | &error_abort); | ||
139 | |||
140 | -- | 109 | -- |
141 | 2.16.2 | 110 | 2.19.1 |
142 | 111 | ||
143 | 112 | diff view generated by jsdifflib |
1 | The BCM2837 sets the Aff1 field of the MPIDR affinity values for the | 1 | Currently we track the state of the four irq lines from the GIC |
---|---|---|---|
2 | CPUs to 0, whereas the BCM2836 uses 0xf. Set this correctly, as it | 2 | only via the cs->interrupt_request or KVM irq state. That means |
3 | is required for Linux to boot. | 3 | that we assume that an interrupt is asserted if and only if the |
4 | external line is set. This assumption is incorrect for VIRQ | ||
5 | and VFIQ, because the HCR_EL2.{VI,VF} bits allow assertion | ||
6 | of VIRQ and VFIQ separately from the state of the external line. | ||
7 | |||
8 | To handle this, start tracking the state of the external lines | ||
9 | explicitly in a CPU state struct field, as is common practice | ||
10 | for devices. | ||
11 | |||
12 | The complicated part of this is dealing with inbound migration | ||
13 | from an older QEMU which didn't have this state. We assume in | ||
14 | that case that the older QEMU did not implement the HCR_EL2.{VI,VF} | ||
15 | bits as generating interrupts, and so the line state matches | ||
16 | the current state in cs->interrupt_request. (This is not quite | ||
17 | true between commit 8a0fc3a29fc2315325400c7 and its revert, but | ||
18 | that commit is broken and never made it into any released QEMU | ||
19 | version.) | ||
4 | 20 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 22 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Message-id: 20180313153458.26822-8-peter.maydell@linaro.org | 23 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
24 | Message-id: 20181109134731.11605-3-peter.maydell@linaro.org | ||
9 | --- | 25 | --- |
10 | hw/arm/bcm2836.c | 11 +++++++---- | 26 | target/arm/cpu.h | 3 +++ |
11 | 1 file changed, 7 insertions(+), 4 deletions(-) | 27 | target/arm/cpu.c | 16 ++++++++++++++ |
28 | target/arm/machine.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ | ||
29 | 3 files changed, 70 insertions(+) | ||
12 | 30 | ||
13 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 31 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/bcm2836.c | 33 | --- a/target/arm/cpu.h |
16 | +++ b/hw/arm/bcm2836.c | 34 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { |
18 | 36 | uint64_t esr; | |
19 | struct BCM283XInfo { | 37 | } serror; |
20 | const char *name; | 38 | |
21 | + int clusterid; | 39 | + /* State of our input IRQ/FIQ/VIRQ/VFIQ lines */ |
40 | + uint32_t irq_line_state; | ||
41 | + | ||
42 | /* Thumb-2 EE state. */ | ||
43 | uint32_t teecr; | ||
44 | uint32_t teehbr; | ||
45 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/cpu.c | ||
48 | +++ b/target/arm/cpu.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level) | ||
50 | [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ | ||
51 | }; | ||
52 | |||
53 | + if (level) { | ||
54 | + env->irq_line_state |= mask[irq]; | ||
55 | + } else { | ||
56 | + env->irq_line_state &= ~mask[irq]; | ||
57 | + } | ||
58 | + | ||
59 | switch (irq) { | ||
60 | case ARM_CPU_VIRQ: | ||
61 | case ARM_CPU_VFIQ: | ||
62 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level) | ||
63 | ARMCPU *cpu = opaque; | ||
64 | CPUState *cs = CPU(cpu); | ||
65 | int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT; | ||
66 | + uint32_t linestate_bit; | ||
67 | |||
68 | switch (irq) { | ||
69 | case ARM_CPU_IRQ: | ||
70 | kvm_irq |= KVM_ARM_IRQ_CPU_IRQ; | ||
71 | + linestate_bit = CPU_INTERRUPT_HARD; | ||
72 | break; | ||
73 | case ARM_CPU_FIQ: | ||
74 | kvm_irq |= KVM_ARM_IRQ_CPU_FIQ; | ||
75 | + linestate_bit = CPU_INTERRUPT_FIQ; | ||
76 | break; | ||
77 | default: | ||
78 | g_assert_not_reached(); | ||
79 | } | ||
80 | + | ||
81 | + if (level) { | ||
82 | + env->irq_line_state |= linestate_bit; | ||
83 | + } else { | ||
84 | + env->irq_line_state &= ~linestate_bit; | ||
85 | + } | ||
86 | + | ||
87 | kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT; | ||
88 | kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0); | ||
89 | #endif | ||
90 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/machine.c | ||
93 | +++ b/target/arm/machine.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_serror = { | ||
95 | } | ||
22 | }; | 96 | }; |
23 | 97 | ||
24 | static const BCM283XInfo bcm283x_socs[] = { | 98 | +static bool irq_line_state_needed(void *opaque) |
25 | { | 99 | +{ |
26 | .name = TYPE_BCM2836, | 100 | + return true; |
27 | + .clusterid = 0xf, | 101 | +} |
28 | }, | 102 | + |
29 | { | 103 | +static const VMStateDescription vmstate_irq_line_state = { |
30 | .name = TYPE_BCM2837, | 104 | + .name = "cpu/irq-line-state", |
31 | + .clusterid = 0x0, | 105 | + .version_id = 1, |
32 | }, | 106 | + .minimum_version_id = 1, |
107 | + .needed = irq_line_state_needed, | ||
108 | + .fields = (VMStateField[]) { | ||
109 | + VMSTATE_UINT32(env.irq_line_state, ARMCPU), | ||
110 | + VMSTATE_END_OF_LIST() | ||
111 | + } | ||
112 | +}; | ||
113 | + | ||
114 | static bool m_needed(void *opaque) | ||
115 | { | ||
116 | ARMCPU *cpu = opaque; | ||
117 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | ||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | +static int cpu_pre_load(void *opaque) | ||
122 | +{ | ||
123 | + ARMCPU *cpu = opaque; | ||
124 | + CPUARMState *env = &cpu->env; | ||
125 | + | ||
126 | + /* | ||
127 | + * Pre-initialize irq_line_state to a value that's never valid as | ||
128 | + * real data, so cpu_post_load() can tell whether we've seen the | ||
129 | + * irq-line-state subsection in the incoming migration state. | ||
130 | + */ | ||
131 | + env->irq_line_state = UINT32_MAX; | ||
132 | + | ||
133 | + return 0; | ||
134 | +} | ||
135 | + | ||
136 | static int cpu_post_load(void *opaque, int version_id) | ||
137 | { | ||
138 | ARMCPU *cpu = opaque; | ||
139 | + CPUARMState *env = &cpu->env; | ||
140 | int i, v; | ||
141 | |||
142 | + /* | ||
143 | + * Handle migration compatibility from old QEMU which didn't | ||
144 | + * send the irq-line-state subsection. A QEMU without it did not | ||
145 | + * implement the HCR_EL2.{VI,VF} bits as generating interrupts, | ||
146 | + * so for TCG the line state matches the bits set in cs->interrupt_request. | ||
147 | + * For KVM the line state is not stored in cs->interrupt_request | ||
148 | + * and so this will leave irq_line_state as 0, but this is OK because | ||
149 | + * we only need to care about it for TCG. | ||
150 | + */ | ||
151 | + if (env->irq_line_state == UINT32_MAX) { | ||
152 | + CPUState *cs = CPU(cpu); | ||
153 | + | ||
154 | + env->irq_line_state = cs->interrupt_request & | ||
155 | + (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIQ | | ||
156 | + CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VFIQ); | ||
157 | + } | ||
158 | + | ||
159 | /* Update the values list from the incoming migration data. | ||
160 | * Anything in the incoming data which we don't know about is | ||
161 | * a migration failure; anything we know about but the incoming | ||
162 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = { | ||
163 | .version_id = 22, | ||
164 | .minimum_version_id = 22, | ||
165 | .pre_save = cpu_pre_save, | ||
166 | + .pre_load = cpu_pre_load, | ||
167 | .post_load = cpu_post_load, | ||
168 | .fields = (VMStateField[]) { | ||
169 | VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16), | ||
170 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = { | ||
171 | &vmstate_sve, | ||
172 | #endif | ||
173 | &vmstate_serror, | ||
174 | + &vmstate_irq_line_state, | ||
175 | NULL | ||
176 | } | ||
33 | }; | 177 | }; |
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | ||
36 | static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
37 | { | ||
38 | BCM283XState *s = BCM283X(dev); | ||
39 | + BCM283XClass *bc = BCM283X_GET_CLASS(dev); | ||
40 | + const BCM283XInfo *info = bc->info; | ||
41 | Object *obj; | ||
42 | Error *err = NULL; | ||
43 | int n; | ||
44 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
45 | qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); | ||
46 | |||
47 | for (n = 0; n < BCM283X_NCPUS; n++) { | ||
48 | - /* Mirror bcm2836, which has clusterid set to 0xf | ||
49 | - * TODO: this should be converted to a property of ARM_CPU | ||
50 | - */ | ||
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]), | ||
57 | -- | 178 | -- |
58 | 2.16.2 | 179 | 2.19.1 |
59 | 180 | ||
60 | 181 | diff view generated by jsdifflib |
1 | The raspi3 has AArch64 CPUs, which means that our smpboot | 1 | In commit 8a0fc3a29fc2315325400 we tried to implement HCR_EL2.{VI,VF}, |
---|---|---|---|
2 | code for keeping the secondary CPUs in a pen needs to have | 2 | but we got it wrong and had to revert it. |
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. | ||
6 | 3 | ||
4 | In that commit we implemented them as simply tracking whether there | ||
5 | is a pending virtual IRQ or virtual FIQ. This is not correct -- these | ||
6 | bits cause a software-generated VIRQ/VFIQ, which is distinct from | ||
7 | whether there is a hardware-generated VIRQ/VFIQ caused by the | ||
8 | external interrupt controller. So we need to track separately | ||
9 | the HCR_EL2 bit state and the external virq/vfiq line state, and | ||
10 | OR the two together to get the actual pending VIRQ/VFIQ state. | ||
11 | |||
12 | Fixes: 8a0fc3a29fc2315325400c738f807d0d4ae0ab7f | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Message-id: 20180313153458.26822-10-peter.maydell@linaro.org | 15 | Message-id: 20181109134731.11605-4-peter.maydell@linaro.org |
10 | --- | 16 | --- |
11 | hw/arm/raspi.c | 41 ++++++++++++++++++++++++++++++++++++++++- | 17 | target/arm/internals.h | 18 ++++++++++++++++ |
12 | 1 file changed, 40 insertions(+), 1 deletion(-) | 18 | target/arm/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++- |
19 | target/arm/helper.c | 20 ++++++++++++++++-- | ||
20 | 3 files changed, 83 insertions(+), 3 deletions(-) | ||
13 | 21 | ||
14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 22 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
15 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/raspi.c | 24 | --- a/target/arm/internals.h |
17 | +++ b/hw/arm/raspi.c | 25 | +++ b/target/arm/internals.h |
18 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ static inline const char *aarch32_mode_name(uint32_t psr) |
19 | #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */ | 27 | return cpu_mode_names[psr & 0xf]; |
20 | #define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */ | ||
21 | #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ | ||
22 | +#define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */ | ||
23 | |||
24 | /* Table of Linux board IDs for different Pi versions */ | ||
25 | static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; | ||
26 | @@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) | ||
27 | info->smp_loader_start); | ||
28 | } | 28 | } |
29 | 29 | ||
30 | +static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) | 30 | +/** |
31 | + * arm_cpu_update_virq: Update CPU_INTERRUPT_VIRQ bit in cs->interrupt_request | ||
32 | + * | ||
33 | + * Update the CPU_INTERRUPT_VIRQ bit in cs->interrupt_request, following | ||
34 | + * a change to either the input VIRQ line from the GIC or the HCR_EL2.VI bit. | ||
35 | + * Must be called with the iothread lock held. | ||
36 | + */ | ||
37 | +void arm_cpu_update_virq(ARMCPU *cpu); | ||
38 | + | ||
39 | +/** | ||
40 | + * arm_cpu_update_vfiq: Update CPU_INTERRUPT_VFIQ bit in cs->interrupt_request | ||
41 | + * | ||
42 | + * Update the CPU_INTERRUPT_VFIQ bit in cs->interrupt_request, following | ||
43 | + * a change to either the input VFIQ line from the GIC or the HCR_EL2.VF bit. | ||
44 | + * Must be called with the iothread lock held. | ||
45 | + */ | ||
46 | +void arm_cpu_update_vfiq(ARMCPU *cpu); | ||
47 | + | ||
48 | #endif | ||
49 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/cpu.c | ||
52 | +++ b/target/arm/cpu.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
54 | } | ||
55 | #endif | ||
56 | |||
57 | +void arm_cpu_update_virq(ARMCPU *cpu) | ||
31 | +{ | 58 | +{ |
32 | + /* Unlike the AArch32 version we don't need to call the board setup hook. | 59 | + /* |
33 | + * The mechanism for doing the spin-table is also entirely different. | 60 | + * Update the interrupt level for VIRQ, which is the logical OR of |
34 | + * We must have four 64-bit fields at absolute addresses | 61 | + * the HCR_EL2.VI bit and the input line level from the GIC. |
35 | + * 0xd8, 0xe0, 0xe8, 0xf0 in RAM, which are the flag variables for | ||
36 | + * our CPUs, and which we must ensure are zero initialized before | ||
37 | + * the primary CPU goes into the kernel. We put these variables inside | ||
38 | + * a rom blob, so that the reset for ROM contents zeroes them for us. | ||
39 | + */ | 62 | + */ |
40 | + static const uint32_t smpboot[] = { | 63 | + CPUARMState *env = &cpu->env; |
41 | + 0xd2801b05, /* mov x5, 0xd8 */ | 64 | + CPUState *cs = CPU(cpu); |
42 | + 0xd53800a6, /* mrs x6, mpidr_el1 */ | ||
43 | + 0x924004c6, /* and x6, x6, #0x3 */ | ||
44 | + 0xd503205f, /* spin: wfe */ | ||
45 | + 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */ | ||
46 | + 0xb4ffffc4, /* cbz x4, spin */ | ||
47 | + 0xd2800000, /* mov x0, #0x0 */ | ||
48 | + 0xd2800001, /* mov x1, #0x0 */ | ||
49 | + 0xd2800002, /* mov x2, #0x0 */ | ||
50 | + 0xd2800003, /* mov x3, #0x0 */ | ||
51 | + 0xd61f0080, /* br x4 */ | ||
52 | + }; | ||
53 | + | 65 | + |
54 | + static const uint64_t spintables[] = { | 66 | + bool new_state = (env->cp15.hcr_el2 & HCR_VI) || |
55 | + 0, 0, 0, 0 | 67 | + (env->irq_line_state & CPU_INTERRUPT_VIRQ); |
56 | + }; | ||
57 | + | 68 | + |
58 | + rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot), | 69 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VIRQ) != 0)) { |
59 | + info->smp_loader_start); | 70 | + if (new_state) { |
60 | + rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables), | 71 | + cpu_interrupt(cs, CPU_INTERRUPT_VIRQ); |
61 | + SPINTABLE_ADDR); | 72 | + } else { |
73 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ); | ||
74 | + } | ||
75 | + } | ||
62 | +} | 76 | +} |
63 | + | 77 | + |
64 | static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info) | 78 | +void arm_cpu_update_vfiq(ARMCPU *cpu) |
79 | +{ | ||
80 | + /* | ||
81 | + * Update the interrupt level for VFIQ, which is the logical OR of | ||
82 | + * the HCR_EL2.VF bit and the input line level from the GIC. | ||
83 | + */ | ||
84 | + CPUARMState *env = &cpu->env; | ||
85 | + CPUState *cs = CPU(cpu); | ||
86 | + | ||
87 | + bool new_state = (env->cp15.hcr_el2 & HCR_VF) || | ||
88 | + (env->irq_line_state & CPU_INTERRUPT_VFIQ); | ||
89 | + | ||
90 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VFIQ) != 0)) { | ||
91 | + if (new_state) { | ||
92 | + cpu_interrupt(cs, CPU_INTERRUPT_VFIQ); | ||
93 | + } else { | ||
94 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VFIQ); | ||
95 | + } | ||
96 | + } | ||
97 | +} | ||
98 | + | ||
99 | #ifndef CONFIG_USER_ONLY | ||
100 | static void arm_cpu_set_irq(void *opaque, int irq, int level) | ||
65 | { | 101 | { |
66 | arm_write_secure_board_setup_dummy_smc(cpu, info, MVBAR_ADDR); | 102 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level) |
67 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | 103 | |
68 | /* Pi2 and Pi3 requires SMP setup */ | 104 | switch (irq) { |
69 | if (version >= 2) { | 105 | case ARM_CPU_VIRQ: |
70 | binfo.smp_loader_start = SMPBOOT_ADDR; | 106 | + assert(arm_feature(env, ARM_FEATURE_EL2)); |
71 | - binfo.write_secondary_boot = write_smpboot; | 107 | + arm_cpu_update_virq(cpu); |
72 | + if (version == 2) { | 108 | + break; |
73 | + binfo.write_secondary_boot = write_smpboot; | 109 | case ARM_CPU_VFIQ: |
74 | + } else { | 110 | assert(arm_feature(env, ARM_FEATURE_EL2)); |
75 | + binfo.write_secondary_boot = write_smpboot64; | 111 | - /* fall through */ |
76 | + } | 112 | + arm_cpu_update_vfiq(cpu); |
77 | binfo.secondary_cpu_reset_hook = reset_secondary; | 113 | + break; |
114 | case ARM_CPU_IRQ: | ||
115 | case ARM_CPU_FIQ: | ||
116 | if (level) { | ||
117 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/target/arm/helper.c | ||
120 | +++ b/target/arm/helper.c | ||
121 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
122 | tlb_flush(CPU(cpu)); | ||
78 | } | 123 | } |
79 | 124 | env->cp15.hcr_el2 = value; | |
125 | + | ||
126 | + /* | ||
127 | + * Updates to VI and VF require us to update the status of | ||
128 | + * virtual interrupts, which are the logical OR of these bits | ||
129 | + * and the state of the input lines from the GIC. (This requires | ||
130 | + * that we have the iothread lock, which is done by marking the | ||
131 | + * reginfo structs as ARM_CP_IO.) | ||
132 | + * Note that if a write to HCR pends a VIRQ or VFIQ it is never | ||
133 | + * possible for it to be taken immediately, because VIRQ and | ||
134 | + * VFIQ are masked unless running at EL0 or EL1, and HCR | ||
135 | + * can only be written at EL2. | ||
136 | + */ | ||
137 | + g_assert(qemu_mutex_iothread_locked()); | ||
138 | + arm_cpu_update_virq(cpu); | ||
139 | + arm_cpu_update_vfiq(cpu); | ||
140 | } | ||
141 | |||
142 | static void hcr_writehigh(CPUARMState *env, const ARMCPRegInfo *ri, | ||
143 | @@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | ||
144 | |||
145 | static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
146 | { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64, | ||
147 | + .type = ARM_CP_IO, | ||
148 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
149 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
150 | .writefn = hcr_write }, | ||
151 | { .name = "HCR", .state = ARM_CP_STATE_AA32, | ||
152 | - .type = ARM_CP_ALIAS, | ||
153 | + .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
154 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
155 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
156 | .writefn = hcr_writelow }, | ||
157 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
158 | |||
159 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
160 | { .name = "HCR2", .state = ARM_CP_STATE_AA32, | ||
161 | - .type = ARM_CP_ALIAS, | ||
162 | + .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
163 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
164 | .access = PL2_RW, | ||
165 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), | ||
80 | -- | 166 | -- |
81 | 2.16.2 | 167 | 2.19.1 |
82 | 168 | ||
83 | 169 | diff view generated by jsdifflib |
1 | Our BCM2836 type is really a generic one that can be any of | 1 | Hyp mode is an exception to the general rule that each AArch32 |
---|---|---|---|
2 | the bcm283x family. Rename it accordingly. We change only | 2 | mode has its own r13, r14 and SPSR -- it has a banked r13 and |
3 | the names which are visible via the header file to the | 3 | SPSR but shares its r14 with User and System mode. We were |
4 | rest of the QEMU code, leaving private function names | 4 | incorrectly implementing it as banked, which meant that on |
5 | in bcm2836.c as they are. | 5 | entry to Hyp mode r14 was 0 rather than the USR/SYS r14. |
6 | 6 | ||
7 | This is a preliminary to making bcm283x be an abstract | 7 | We provide a new function r14_bank_number() which is like |
8 | parent class to specific types for the bcm2836 and bcm2837. | 8 | the existing bank_number() but provides the index into |
9 | env->banked_r14[]; bank_number() provides the index to use | ||
10 | for env->banked_r13[] and env->banked_cpsr[]. | ||
11 | |||
12 | All the points in the code that were using bank_number() | ||
13 | to index into env->banked_r14[] are updated for consintency: | ||
14 | * switch_mode() -- this is the only place where we fix | ||
15 | an actual bug | ||
16 | * aarch64_sync_32_to_64() and aarch64_sync_64_to_32(): | ||
17 | no behavioural change as we already special-cased Hyp R14 | ||
18 | * kvm32.c: no behavioural change since the guest can't ever | ||
19 | be in Hyp mode, but conceptually the right thing to do | ||
20 | * msr_banked()/mrs_banked(): we can never get to the case | ||
21 | that accesses banked_r14[] with tgtmode == ARM_CPU_MODE_HYP, | ||
22 | so no behavioural change | ||
9 | 23 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 25 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
13 | Message-id: 20180313153458.26822-6-peter.maydell@linaro.org | 26 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
27 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
28 | Message-id: 20181109173553.22341-2-peter.maydell@linaro.org | ||
14 | --- | 29 | --- |
15 | include/hw/arm/bcm2836.h | 12 ++++++------ | 30 | target/arm/internals.h | 16 ++++++++++++++++ |
16 | hw/arm/bcm2836.c | 17 +++++++++-------- | 31 | target/arm/helper.c | 29 +++++++++++++++-------------- |
17 | hw/arm/raspi.c | 16 ++++++++-------- | 32 | target/arm/kvm32.c | 4 ++-- |
18 | 3 files changed, 23 insertions(+), 22 deletions(-) | 33 | target/arm/op_helper.c | 4 ++-- |
19 | 34 | 4 files changed, 35 insertions(+), 18 deletions(-) | |
20 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 35 | |
21 | index XXXXXXX..XXXXXXX 100644 | 36 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
22 | --- a/include/hw/arm/bcm2836.h | 37 | index XXXXXXX..XXXXXXX 100644 |
23 | +++ b/include/hw/arm/bcm2836.h | 38 | --- a/target/arm/internals.h |
24 | @@ -XXX,XX +XXX,XX @@ | 39 | +++ b/target/arm/internals.h |
25 | #include "hw/arm/bcm2835_peripherals.h" | 40 | @@ -XXX,XX +XXX,XX @@ static inline int bank_number(int mode) |
26 | #include "hw/intc/bcm2836_control.h" | 41 | g_assert_not_reached(); |
27 | |||
28 | -#define TYPE_BCM2836 "bcm2836" | ||
29 | -#define BCM2836(obj) OBJECT_CHECK(BCM2836State, (obj), TYPE_BCM2836) | ||
30 | +#define TYPE_BCM283X "bcm283x" | ||
31 | +#define BCM283X(obj) OBJECT_CHECK(BCM283XState, (obj), TYPE_BCM283X) | ||
32 | |||
33 | -#define BCM2836_NCPUS 4 | ||
34 | +#define BCM283X_NCPUS 4 | ||
35 | |||
36 | -typedef struct BCM2836State { | ||
37 | +typedef struct BCM283XState { | ||
38 | /*< private >*/ | ||
39 | DeviceState parent_obj; | ||
40 | /*< public >*/ | ||
41 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State { | ||
42 | char *cpu_type; | ||
43 | uint32_t enabled_cpus; | ||
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 | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/arm/bcm2836.c | ||
56 | +++ b/hw/arm/bcm2836.c | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | |||
59 | static void bcm2836_init(Object *obj) | ||
60 | { | ||
61 | - BCM2836State *s = BCM2836(obj); | ||
62 | + BCM283XState *s = BCM283X(obj); | ||
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) | ||
94 | } | 42 | } |
95 | 43 | ||
96 | static Property bcm2836_props[] = { | 44 | +/** |
97 | - DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type), | 45 | + * r14_bank_number: Map CPU mode onto register bank for r14 |
98 | - DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS), | 46 | + * |
99 | + DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), | 47 | + * Given an AArch32 CPU mode, return the index into the saved register |
100 | + DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, | 48 | + * banks to use for the R14 (LR) in that mode. This is the same as |
101 | + BCM283X_NCPUS), | 49 | + * bank_number(), except for the special case of Hyp mode, where |
102 | DEFINE_PROP_END_OF_LIST() | 50 | + * R14 is shared with USR and SYS, unlike its R13 and SPSR. |
103 | }; | 51 | + * This should be used as the index into env->banked_r14[], and |
104 | 52 | + * bank_number() used for the index into env->banked_r13[] and | |
105 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) | 53 | + * env->banked_spsr[]. |
54 | + */ | ||
55 | +static inline int r14_bank_number(int mode) | ||
56 | +{ | ||
57 | + return (mode == ARM_CPU_MODE_HYP) ? BANK_USRSYS : bank_number(mode); | ||
58 | +} | ||
59 | + | ||
60 | void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); | ||
61 | void arm_translate_init(void); | ||
62 | |||
63 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/helper.c | ||
66 | +++ b/target/arm/helper.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode) | ||
68 | |||
69 | i = bank_number(old_mode); | ||
70 | env->banked_r13[i] = env->regs[13]; | ||
71 | - env->banked_r14[i] = env->regs[14]; | ||
72 | env->banked_spsr[i] = env->spsr; | ||
73 | |||
74 | i = bank_number(mode); | ||
75 | env->regs[13] = env->banked_r13[i]; | ||
76 | - env->regs[14] = env->banked_r14[i]; | ||
77 | env->spsr = env->banked_spsr[i]; | ||
78 | + | ||
79 | + env->banked_r14[r14_bank_number(old_mode)] = env->regs[14]; | ||
80 | + env->regs[14] = env->banked_r14[r14_bank_number(mode)]; | ||
106 | } | 81 | } |
107 | 82 | ||
108 | static const TypeInfo bcm2836_type_info = { | 83 | /* Physical Interrupt Target EL Lookup Table |
109 | - .name = TYPE_BCM2836, | 84 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) |
110 | + .name = TYPE_BCM283X, | 85 | if (mode == ARM_CPU_MODE_HYP) { |
111 | .parent = TYPE_DEVICE, | 86 | env->xregs[14] = env->regs[14]; |
112 | - .instance_size = sizeof(BCM2836State), | 87 | } else { |
113 | + .instance_size = sizeof(BCM283XState), | 88 | - env->xregs[14] = env->banked_r14[bank_number(ARM_CPU_MODE_USR)]; |
114 | .instance_init = bcm2836_init, | 89 | + env->xregs[14] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_USR)]; |
115 | .class_init = bcm2836_class_init, | 90 | } |
116 | }; | 91 | } |
117 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 92 | |
118 | index XXXXXXX..XXXXXXX 100644 | 93 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) |
119 | --- a/hw/arm/raspi.c | 94 | env->xregs[16] = env->regs[14]; |
120 | +++ b/hw/arm/raspi.c | 95 | env->xregs[17] = env->regs[13]; |
121 | @@ -XXX,XX +XXX,XX @@ | 96 | } else { |
122 | static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; | 97 | - env->xregs[16] = env->banked_r14[bank_number(ARM_CPU_MODE_IRQ)]; |
123 | 98 | + env->xregs[16] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_IRQ)]; | |
124 | typedef struct RasPiState { | 99 | env->xregs[17] = env->banked_r13[bank_number(ARM_CPU_MODE_IRQ)]; |
125 | - BCM2836State soc; | 100 | } |
126 | + BCM283XState soc; | 101 | |
127 | MemoryRegion ram; | 102 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) |
128 | } RasPiState; | 103 | env->xregs[18] = env->regs[14]; |
129 | 104 | env->xregs[19] = env->regs[13]; | |
130 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | 105 | } else { |
131 | BusState *bus; | 106 | - env->xregs[18] = env->banked_r14[bank_number(ARM_CPU_MODE_SVC)]; |
132 | DeviceState *carddev; | 107 | + env->xregs[18] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_SVC)]; |
133 | 108 | env->xregs[19] = env->banked_r13[bank_number(ARM_CPU_MODE_SVC)]; | |
134 | - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM2836); | 109 | } |
135 | + object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); | 110 | |
136 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), | 111 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) |
137 | &error_abort); | 112 | env->xregs[20] = env->regs[14]; |
138 | 113 | env->xregs[21] = env->regs[13]; | |
139 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) | 114 | } else { |
140 | mc->no_floppy = 1; | 115 | - env->xregs[20] = env->banked_r14[bank_number(ARM_CPU_MODE_ABT)]; |
141 | mc->no_cdrom = 1; | 116 | + env->xregs[20] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_ABT)]; |
142 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); | 117 | env->xregs[21] = env->banked_r13[bank_number(ARM_CPU_MODE_ABT)]; |
143 | - mc->max_cpus = BCM2836_NCPUS; | 118 | } |
144 | - mc->min_cpus = BCM2836_NCPUS; | 119 | |
145 | - mc->default_cpus = BCM2836_NCPUS; | 120 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) |
146 | + mc->max_cpus = BCM283X_NCPUS; | 121 | env->xregs[22] = env->regs[14]; |
147 | + mc->min_cpus = BCM283X_NCPUS; | 122 | env->xregs[23] = env->regs[13]; |
148 | + mc->default_cpus = BCM283X_NCPUS; | 123 | } else { |
149 | mc->default_ram_size = 1024 * 1024 * 1024; | 124 | - env->xregs[22] = env->banked_r14[bank_number(ARM_CPU_MODE_UND)]; |
150 | mc->ignore_memory_transaction_failures = true; | 125 | + env->xregs[22] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_UND)]; |
151 | }; | 126 | env->xregs[23] = env->banked_r13[bank_number(ARM_CPU_MODE_UND)]; |
152 | @@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc) | 127 | } |
153 | mc->no_floppy = 1; | 128 | |
154 | mc->no_cdrom = 1; | 129 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) |
155 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); | 130 | env->xregs[i] = env->fiq_regs[i - 24]; |
156 | - mc->max_cpus = BCM2836_NCPUS; | 131 | } |
157 | - mc->min_cpus = BCM2836_NCPUS; | 132 | env->xregs[29] = env->banked_r13[bank_number(ARM_CPU_MODE_FIQ)]; |
158 | - mc->default_cpus = BCM2836_NCPUS; | 133 | - env->xregs[30] = env->banked_r14[bank_number(ARM_CPU_MODE_FIQ)]; |
159 | + mc->max_cpus = BCM283X_NCPUS; | 134 | + env->xregs[30] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_FIQ)]; |
160 | + mc->min_cpus = BCM283X_NCPUS; | 135 | } |
161 | + mc->default_cpus = BCM283X_NCPUS; | 136 | |
162 | mc->default_ram_size = 1024 * 1024 * 1024; | 137 | env->pc = env->regs[15]; |
163 | } | 138 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) |
164 | DEFINE_MACHINE("raspi3", raspi3_machine_init) | 139 | if (mode == ARM_CPU_MODE_HYP) { |
140 | env->regs[14] = env->xregs[14]; | ||
141 | } else { | ||
142 | - env->banked_r14[bank_number(ARM_CPU_MODE_USR)] = env->xregs[14]; | ||
143 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_USR)] = env->xregs[14]; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
148 | env->regs[14] = env->xregs[16]; | ||
149 | env->regs[13] = env->xregs[17]; | ||
150 | } else { | ||
151 | - env->banked_r14[bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[16]; | ||
152 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[16]; | ||
153 | env->banked_r13[bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[17]; | ||
154 | } | ||
155 | |||
156 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
157 | env->regs[14] = env->xregs[18]; | ||
158 | env->regs[13] = env->xregs[19]; | ||
159 | } else { | ||
160 | - env->banked_r14[bank_number(ARM_CPU_MODE_SVC)] = env->xregs[18]; | ||
161 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_SVC)] = env->xregs[18]; | ||
162 | env->banked_r13[bank_number(ARM_CPU_MODE_SVC)] = env->xregs[19]; | ||
163 | } | ||
164 | |||
165 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
166 | env->regs[14] = env->xregs[20]; | ||
167 | env->regs[13] = env->xregs[21]; | ||
168 | } else { | ||
169 | - env->banked_r14[bank_number(ARM_CPU_MODE_ABT)] = env->xregs[20]; | ||
170 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_ABT)] = env->xregs[20]; | ||
171 | env->banked_r13[bank_number(ARM_CPU_MODE_ABT)] = env->xregs[21]; | ||
172 | } | ||
173 | |||
174 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
175 | env->regs[14] = env->xregs[22]; | ||
176 | env->regs[13] = env->xregs[23]; | ||
177 | } else { | ||
178 | - env->banked_r14[bank_number(ARM_CPU_MODE_UND)] = env->xregs[22]; | ||
179 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_UND)] = env->xregs[22]; | ||
180 | env->banked_r13[bank_number(ARM_CPU_MODE_UND)] = env->xregs[23]; | ||
181 | } | ||
182 | |||
183 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
184 | env->fiq_regs[i - 24] = env->xregs[i]; | ||
185 | } | ||
186 | env->banked_r13[bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[29]; | ||
187 | - env->banked_r14[bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[30]; | ||
188 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[30]; | ||
189 | } | ||
190 | |||
191 | env->regs[15] = env->pc; | ||
192 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/target/arm/kvm32.c | ||
195 | +++ b/target/arm/kvm32.c | ||
196 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
197 | memcpy(env->usr_regs, env->regs + 8, 5 * sizeof(uint32_t)); | ||
198 | } | ||
199 | env->banked_r13[bn] = env->regs[13]; | ||
200 | - env->banked_r14[bn] = env->regs[14]; | ||
201 | env->banked_spsr[bn] = env->spsr; | ||
202 | + env->banked_r14[r14_bank_number(mode)] = env->regs[14]; | ||
203 | |||
204 | /* Now we can safely copy stuff down to the kernel */ | ||
205 | for (i = 0; i < ARRAY_SIZE(regs); i++) { | ||
206 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
207 | memcpy(env->regs + 8, env->usr_regs, 5 * sizeof(uint32_t)); | ||
208 | } | ||
209 | env->regs[13] = env->banked_r13[bn]; | ||
210 | - env->regs[14] = env->banked_r14[bn]; | ||
211 | env->spsr = env->banked_spsr[bn]; | ||
212 | + env->regs[14] = env->banked_r14[r14_bank_number(mode)]; | ||
213 | |||
214 | /* VFP registers */ | ||
215 | r.id = KVM_REG_ARM | KVM_REG_SIZE_U64 | KVM_REG_ARM_VFP; | ||
216 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
217 | index XXXXXXX..XXXXXXX 100644 | ||
218 | --- a/target/arm/op_helper.c | ||
219 | +++ b/target/arm/op_helper.c | ||
220 | @@ -XXX,XX +XXX,XX @@ void HELPER(msr_banked)(CPUARMState *env, uint32_t value, uint32_t tgtmode, | ||
221 | env->banked_r13[bank_number(tgtmode)] = value; | ||
222 | break; | ||
223 | case 14: | ||
224 | - env->banked_r14[bank_number(tgtmode)] = value; | ||
225 | + env->banked_r14[r14_bank_number(tgtmode)] = value; | ||
226 | break; | ||
227 | case 8 ... 12: | ||
228 | switch (tgtmode) { | ||
229 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t tgtmode, uint32_t regno) | ||
230 | case 13: | ||
231 | return env->banked_r13[bank_number(tgtmode)]; | ||
232 | case 14: | ||
233 | - return env->banked_r14[bank_number(tgtmode)]; | ||
234 | + return env->banked_r14[r14_bank_number(tgtmode)]; | ||
235 | case 8 ... 12: | ||
236 | switch (tgtmode) { | ||
237 | case ARM_CPU_MODE_USR: | ||
165 | -- | 238 | -- |
166 | 2.16.2 | 239 | 2.19.1 |
167 | 240 | ||
168 | 241 | diff view generated by jsdifflib |
1 | Add some assertions that if we're about to boot an AArch64 kernel, | 1 | The Cortex-A15 and Cortex-A7 both have EL2; now we've implemented |
---|---|---|---|
2 | the board code has not mistakenly set either secure_boot or | 2 | it properly we can enable the feature bit. |
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. | ||
5 | |||
6 | It might in theory make sense to set secure_board_setup, but | ||
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. | ||
12 | 3 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | Message-id: 20180313153458.26822-3-peter.maydell@linaro.org | 6 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
7 | Message-id: 20181109173553.22341-3-peter.maydell@linaro.org | ||
16 | --- | 8 | --- |
17 | hw/arm/boot.c | 7 +++++++ | 9 | target/arm/cpu.c | 2 ++ |
18 | 1 file changed, 7 insertions(+) | 10 | 1 file changed, 2 insertions(+) |
19 | 11 | ||
20 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/boot.c | 14 | --- a/target/arm/cpu.c |
23 | +++ b/hw/arm/boot.c | 15 | +++ b/target/arm/cpu.c |
24 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 16 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) |
25 | } else { | 17 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
26 | env->pstate = PSTATE_MODE_EL1h; | 18 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); |
27 | } | 19 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
28 | + /* AArch64 kernels never boot in secure mode */ | 20 | + set_feature(&cpu->env, ARM_FEATURE_EL2); |
29 | + assert(!info->secure_boot); | 21 | set_feature(&cpu->env, ARM_FEATURE_EL3); |
30 | + /* This hook is only supported for AArch32 currently: | 22 | cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A7; |
31 | + * bootloader_aarch64[] will not call the hook, and | 23 | cpu->midr = 0x410fc075; |
32 | + * the code above has already dropped us into EL2 or EL1. | 24 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) |
33 | + */ | 25 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
34 | + assert(!info->secure_board_setup); | 26 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); |
35 | } | 27 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
36 | 28 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | |
37 | /* Set to non-secure if not a secure boot */ | 29 | set_feature(&cpu->env, ARM_FEATURE_EL3); |
30 | cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A15; | ||
31 | cpu->midr = 0x412fc0f1; | ||
38 | -- | 32 | -- |
39 | 2.16.2 | 33 | 2.19.1 |
40 | 34 | ||
41 | 35 | diff view generated by jsdifflib |