1 | First target-arm pullreq of the 4.0 series; most of this | 1 | The following changes since commit f003dd8d81f7d88f4b1f8802309eaa76f6eb223a: |
---|---|---|---|
2 | is Mao's cleanups that finally let us drop sysbus::init; | ||
3 | the most interesting user-visible feature is RTH's patches | ||
4 | adding some v8.1 and v8.2 architecture features. | ||
5 | 2 | ||
6 | thanks | 3 | Merge tag 'pull-tcg-20230305' of https://gitlab.com/rth7680/qemu into staging (2023-03-06 10:20:04 +0000) |
7 | -- PMM | ||
8 | |||
9 | The following changes since commit 6145a6d84b3bf0f25935b88543febe076c61b0f4: | ||
10 | |||
11 | Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20181212' into staging (2018-12-13 13:06:09 +0000) | ||
12 | 4 | ||
13 | are available in the Git repository at: | 5 | are available in the Git repository at: |
14 | 6 | ||
15 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20181213 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230306 |
16 | 8 | ||
17 | for you to fetch changes up to 2d7137c10fafefe40a0a049ff8a7bd78b66e661f: | 9 | for you to fetch changes up to 2ddc45954f97cd1d7ee5cbca0def05e980d1da9f: |
18 | 10 | ||
19 | target/arm: Implement the ARMv8.1-LOR extension (2018-12-13 14:41:24 +0000) | 11 | hw: arm: allwinner-h3: Fix and complete H3 i2c devices (2023-03-06 15:31:24 +0000) |
20 | 12 | ||
21 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
22 | target-arm queue: | 14 | target-arm queue: |
23 | * Convert various devices from sysbus init to instance_init | 15 | * allwinner-h3: Fix I2C controller model for Sun6i SoCs |
24 | * Remove the now unused sysbus init support entirely | 16 | * allwinner-h3: Add missing i2c controllers |
25 | * Allow AArch64 processors to boot from a kernel placed over 4GB | 17 | * Expose M-profile system registers to gdbstub |
26 | * hw: arm: musicpal: drop TYPE_WM8750 in object_property_set_link() | 18 | * Expose pauth information to gdbstub |
27 | * versal: minor fixes to virtio-mmio instantation | 19 | * Support direct boot for Linux/arm64 EFI zboot images |
28 | * arm: Implement the ARMv8.1-HPD extension | 20 | * Fix incorrect stage 2 MMU setup validation |
29 | * arm: Implement the ARMv8.2-AA32HPD extension | ||
30 | * arm: Implement the ARMv8.1-LOR extension (as the trivial | ||
31 | "no limited ordering regions provided" minimum) | ||
32 | 21 | ||
33 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
34 | Edgar E. Iglesias (4): | 23 | Ard Biesheuvel (1): |
35 | hw/arm: versal: Remove bogus virtio-mmio creation | 24 | hw: arm: Support direct boot for Linux/arm64 EFI zboot images |
36 | hw/arm: versal: Reduce number of virtio-mmio instances | ||
37 | hw/arm: versal: Use IRQs 111 - 118 for virtio-mmio | ||
38 | hw/arm: versal: Correct the nr of IRQs to 192 | ||
39 | 25 | ||
40 | Li Qiang (1): | 26 | David Reiss (2): |
41 | hw: arm: musicpal: drop TYPE_WM8750 in object_property_set_link() | 27 | target/arm: Export arm_v7m_mrs_control |
28 | target/arm: Export arm_v7m_get_sp_ptr | ||
42 | 29 | ||
43 | Mao Zhongyi (21): | 30 | Richard Henderson (16): |
44 | musicpal: Convert sysbus init function to realize function | 31 | target/arm: Normalize aarch64 gdbstub get/set function names |
45 | block/noenand: Convert sysbus init function to realize function | 32 | target/arm: Unexport arm_gen_dynamic_sysreg_xml |
46 | char/grlib_apbuart: Convert sysbus init function to realize function | 33 | target/arm: Move arm_gen_dynamic_svereg_xml to gdbstub64.c |
47 | core/empty_slot: Convert sysbus init function to realize function | 34 | target/arm: Split out output_vector_union_type |
48 | display/g364fb: Convert sysbus init function to realize function | 35 | target/arm: Simplify register counting in arm_gen_dynamic_svereg_xml |
49 | dma/puv3_dma: Convert sysbus init function to realize function | 36 | target/arm: Hoist pred_width in arm_gen_dynamic_svereg_xml |
50 | gpio/puv3_gpio: Convert sysbus init function to realize function | 37 | target/arm: Fix svep width in arm_gen_dynamic_svereg_xml |
51 | milkymist-softusb: Convert sysbus init function to realize function | 38 | target/arm: Add name argument to output_vector_union_type |
52 | input/pl050: Convert sysbus init function to realize function | 39 | target/arm: Simplify iteration over bit widths |
53 | intc/puv3_intc: Convert sysbus init function to realize function | 40 | target/arm: Create pauth_ptr_mask |
54 | milkymist-hpdmc: Convert sysbus init function to realize function | 41 | target/arm: Implement gdbstub pauth extension |
55 | milkymist-pfpu: Convert sysbus init function to realize function | 42 | target/arm: Implement gdbstub m-profile systemreg and secext |
56 | puv3_pm.c: Convert sysbus init function to realize function | 43 | target/arm: Handle m-profile in arm_is_secure |
57 | nvram/ds1225y: Convert sysbus init function to realize function | 44 | target/arm: Stub arm_hcr_el2_eff for m-profile |
58 | pci-bridge/dec: Convert sysbus init function to realize function | 45 | target/arm: Diagnose incorrect usage of arm_is_secure subroutines |
59 | timer/etraxfs_timer: Convert sysbus init function to realize function | 46 | target/arm: Rewrite check_s2_mmu_setup |
60 | timer/grlib_gptimer: Convert sysbus init function to realize function | ||
61 | timer/puv3_ost: Convert sysbus init function to realize function | ||
62 | usb/tusb6010: Convert sysbus init function to realize function | ||
63 | xen_backend: remove xen_sysdev_init() function | ||
64 | core/sysbus: remove the SysBusDeviceClass::init path | ||
65 | 47 | ||
66 | Peter Maydell (1): | 48 | qianfan Zhao (2): |
67 | target/arm: Move id_aa64mmfr* to ARMISARegisters | 49 | hw: allwinner-i2c: Fix TWI_CNTR_INT_FLAG on SUN6i SoCs |
50 | hw: arm: allwinner-h3: Fix and complete H3 i2c devices | ||
68 | 51 | ||
69 | Ricardo Perez Blanco (1): | 52 | configs/targets/aarch64-linux-user.mak | 2 +- |
70 | Allow AArch64 processors to boot from a kernel placed over 4GB | 53 | configs/targets/aarch64-softmmu.mak | 2 +- |
71 | 54 | configs/targets/aarch64_be-linux-user.mak | 2 +- | |
72 | Richard Henderson (9): | 55 | include/hw/arm/allwinner-h3.h | 6 + |
73 | target/arm: Add HCR_EL2 bits up to ARMv8.5 | 56 | include/hw/i2c/allwinner-i2c.h | 6 + |
74 | target/arm: Add SCR_EL3 bits up to ARMv8.5 | 57 | include/hw/loader.h | 19 ++ |
75 | target/arm: Fix HCR_EL2.TGE check in arm_phys_excp_target_el | 58 | target/arm/cpu.h | 17 +- |
76 | target/arm: Tidy scr_write | 59 | target/arm/internals.h | 34 +++- |
77 | target/arm: Implement the ARMv8.1-HPD extension | 60 | hw/arm/allwinner-h3.c | 29 +++- |
78 | target/arm: Implement the ARMv8.2-AA32HPD extension | 61 | hw/arm/boot.c | 6 + |
79 | target/arm: Introduce arm_hcr_el2_eff | 62 | hw/core/loader.c | 91 ++++++++++ |
80 | target/arm: Use arm_hcr_el2_eff more places | 63 | hw/i2c/allwinner-i2c.c | 26 ++- |
81 | target/arm: Implement the ARMv8.1-LOR extension | 64 | target/arm/gdbstub.c | 278 ++++++++++++++++++------------ |
82 | 65 | target/arm/gdbstub64.c | 175 ++++++++++++++++++- | |
83 | include/hw/arm/xlnx-versal.h | 8 +- | 66 | target/arm/helper.c | 3 + |
84 | include/hw/sysbus.h | 3 - | 67 | target/arm/ptw.c | 173 +++++++++++-------- |
85 | target/arm/cpu.h | 141 ++++++++++++++++----------- | 68 | target/arm/tcg/m_helper.c | 90 +++++----- |
86 | target/arm/internals.h | 3 +- | 69 | target/arm/tcg/pauth_helper.c | 26 ++- |
87 | hw/arm/boot.c | 35 ++++--- | 70 | gdb-xml/aarch64-pauth.xml | 15 ++ |
88 | hw/arm/musicpal.c | 11 +-- | 71 | 19 files changed, 742 insertions(+), 258 deletions(-) |
89 | hw/arm/xlnx-versal-virt.c | 7 +- | 72 | create mode 100644 gdb-xml/aarch64-pauth.xml |
90 | hw/block/onenand.c | 16 ++-- | ||
91 | hw/char/grlib_apbuart.c | 12 +-- | ||
92 | hw/core/empty_slot.c | 9 +- | ||
93 | hw/core/sysbus.c | 15 +-- | ||
94 | hw/display/g364fb.c | 9 +- | ||
95 | hw/dma/puv3_dma.c | 10 +- | ||
96 | hw/gpio/puv3_gpio.c | 29 +++--- | ||
97 | hw/input/milkymist-softusb.c | 16 ++-- | ||
98 | hw/input/pl050.c | 11 +-- | ||
99 | hw/intc/arm_gicv3_cpuif.c | 21 ++-- | ||
100 | hw/intc/puv3_intc.c | 11 +-- | ||
101 | hw/misc/milkymist-hpdmc.c | 9 +- | ||
102 | hw/misc/milkymist-pfpu.c | 12 +-- | ||
103 | hw/misc/puv3_pm.c | 10 +- | ||
104 | hw/nvram/ds1225y.c | 12 +-- | ||
105 | hw/pci-bridge/dec.c | 12 +-- | ||
106 | hw/timer/etraxfs_timer.c | 14 +-- | ||
107 | hw/timer/grlib_gptimer.c | 11 +-- | ||
108 | hw/timer/puv3_ost.c | 13 ++- | ||
109 | hw/usb/tusb6010.c | 8 +- | ||
110 | hw/xen/xen_backend.c | 7 -- | ||
111 | target/arm/cpu.c | 4 + | ||
112 | target/arm/cpu64.c | 11 ++- | ||
113 | target/arm/helper.c | 222 ++++++++++++++++++++++++++++++++++++------- | ||
114 | target/arm/kvm64.c | 4 + | ||
115 | target/arm/op_helper.c | 14 ++- | ||
116 | target/arm/translate-a64.c | 12 +++ | ||
117 | 34 files changed, 456 insertions(+), 286 deletions(-) | ||
118 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Li Qiang <liq3ea@gmail.com> | ||
2 | 1 | ||
3 | The third argument of object_property_set_link() is the name of | ||
4 | property, not related with the QOM type name, using the constant | ||
5 | string instead. | ||
6 | |||
7 | Signed-off-by: Li Qiang <liq3ea@gmail.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 1542880825-2604-1-git-send-email-liq3ea@gmail.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/arm/musicpal.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/musicpal.c | ||
19 | +++ b/hw/arm/musicpal.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine) | ||
21 | dev = qdev_create(NULL, TYPE_MV88W8618_AUDIO); | ||
22 | s = SYS_BUS_DEVICE(dev); | ||
23 | object_property_set_link(OBJECT(dev), OBJECT(wm8750_dev), | ||
24 | - TYPE_WM8750, NULL); | ||
25 | + "wm8750", NULL); | ||
26 | qdev_init_nofail(dev); | ||
27 | sysbus_mmio_map(s, 0, MP_AUDIO_BASE); | ||
28 | sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]); | ||
29 | -- | ||
30 | 2.19.2 | ||
31 | |||
32 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | 3 | Make the form of the function names between fp and sve the same: |
4 | puv3_ost_class_init(). | 4 | - arm_gdb_*_svereg -> aarch64_gdb_*_sve_reg. |
5 | - aarch64_fpu_gdb_*_reg -> aarch64_gdb_*_fpu_reg. | ||
5 | 6 | ||
6 | Cc: gxt@mprc.pku.edu.cn | 7 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
7 | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | 10 | Message-id: 20230227213329.793795-2-richard.henderson@linaro.org |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20181130093852.20739-19-maozhongyi@cmss.chinamobile.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 12 | --- |
14 | hw/timer/puv3_ost.c | 13 ++++++------- | 13 | target/arm/internals.h | 8 ++++---- |
15 | 1 file changed, 6 insertions(+), 7 deletions(-) | 14 | target/arm/gdbstub.c | 9 +++++---- |
15 | target/arm/gdbstub64.c | 8 ++++---- | ||
16 | 3 files changed, 13 insertions(+), 12 deletions(-) | ||
16 | 17 | ||
17 | diff --git a/hw/timer/puv3_ost.c b/hw/timer/puv3_ost.c | 18 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/timer/puv3_ost.c | 20 | --- a/target/arm/internals.h |
20 | +++ b/hw/timer/puv3_ost.c | 21 | +++ b/target/arm/internals.h |
21 | @@ -XXX,XX +XXX,XX @@ static void puv3_ost_tick(void *opaque) | 22 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t pmu_counter_mask(CPUARMState *env) |
23 | } | ||
24 | |||
25 | #ifdef TARGET_AARCH64 | ||
26 | -int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg); | ||
27 | -int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg); | ||
28 | -int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
29 | -int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
30 | +int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
31 | +int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
32 | +int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
33 | +int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
34 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | ||
35 | void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp); | ||
36 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); | ||
37 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/gdbstub.c | ||
40 | +++ b/target/arm/gdbstub.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | ||
42 | */ | ||
43 | #ifdef TARGET_AARCH64 | ||
44 | if (isar_feature_aa64_sve(&cpu->isar)) { | ||
45 | - gdb_register_coprocessor(cs, arm_gdb_get_svereg, arm_gdb_set_svereg, | ||
46 | - arm_gen_dynamic_svereg_xml(cs, cs->gdb_num_regs), | ||
47 | + int nreg = arm_gen_dynamic_svereg_xml(cs, cs->gdb_num_regs); | ||
48 | + gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg, | ||
49 | + aarch64_gdb_set_sve_reg, nreg, | ||
50 | "sve-registers.xml", 0); | ||
51 | } else { | ||
52 | - gdb_register_coprocessor(cs, aarch64_fpu_gdb_get_reg, | ||
53 | - aarch64_fpu_gdb_set_reg, | ||
54 | + gdb_register_coprocessor(cs, aarch64_gdb_get_fpu_reg, | ||
55 | + aarch64_gdb_set_fpu_reg, | ||
56 | 34, "aarch64-fpu.xml", 0); | ||
57 | } | ||
58 | #endif | ||
59 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/gdbstub64.c | ||
62 | +++ b/target/arm/gdbstub64.c | ||
63 | @@ -XXX,XX +XXX,XX @@ int aarch64_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | -int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) | ||
68 | +int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg) | ||
69 | { | ||
70 | switch (reg) { | ||
71 | case 0 ... 31: | ||
72 | @@ -XXX,XX +XXX,XX @@ int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) | ||
22 | } | 73 | } |
23 | } | 74 | } |
24 | 75 | ||
25 | -static int puv3_ost_init(SysBusDevice *dev) | 76 | -int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) |
26 | +static void puv3_ost_realize(DeviceState *dev, Error **errp) | 77 | +int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg) |
27 | { | 78 | { |
28 | PUV3OSTState *s = PUV3_OST(dev); | 79 | switch (reg) { |
29 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 80 | case 0 ... 31: |
30 | 81 | @@ -XXX,XX +XXX,XX @@ int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) | |
31 | s->reg_OIER = 0; | 82 | } |
32 | s->reg_OSSR = 0; | ||
33 | s->reg_OSMR0 = 0; | ||
34 | s->reg_OSCR = 0; | ||
35 | |||
36 | - sysbus_init_irq(dev, &s->irq); | ||
37 | + sysbus_init_irq(sbd, &s->irq); | ||
38 | |||
39 | s->bh = qemu_bh_new(puv3_ost_tick, s); | ||
40 | s->ptimer = ptimer_init(s->bh, PTIMER_POLICY_DEFAULT); | ||
41 | @@ -XXX,XX +XXX,XX @@ static int puv3_ost_init(SysBusDevice *dev) | ||
42 | |||
43 | memory_region_init_io(&s->iomem, OBJECT(s), &puv3_ost_ops, s, "puv3_ost", | ||
44 | PUV3_REGS_OFFSET); | ||
45 | - sysbus_init_mmio(dev, &s->iomem); | ||
46 | - | ||
47 | - return 0; | ||
48 | + sysbus_init_mmio(sbd, &s->iomem); | ||
49 | } | 83 | } |
50 | 84 | ||
51 | static void puv3_ost_class_init(ObjectClass *klass, void *data) | 85 | -int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg) |
86 | +int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg) | ||
52 | { | 87 | { |
53 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | 88 | ARMCPU *cpu = env_archcpu(env); |
54 | + DeviceClass *dc = DEVICE_CLASS(klass); | 89 | |
55 | 90 | @@ -XXX,XX +XXX,XX @@ int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg) | |
56 | - sdc->init = puv3_ost_init; | 91 | return 0; |
57 | + dc->realize = puv3_ost_realize; | ||
58 | } | 92 | } |
59 | 93 | ||
60 | static const TypeInfo puv3_ost_info = { | 94 | -int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg) |
95 | +int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) | ||
96 | { | ||
97 | ARMCPU *cpu = env_archcpu(env); | ||
98 | |||
61 | -- | 99 | -- |
62 | 2.19.2 | 100 | 2.34.1 |
63 | 101 | ||
64 | 102 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Because EL3 has a fixed execution mode, we can properly decide | 3 | This function is not used outside gdbstub.c. |
4 | which of the bits are RES{0,1}. | ||
5 | 4 | ||
5 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20181203203839.757-8-richard.henderson@linaro.org | 8 | Message-id: 20230227213329.793795-3-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/cpu.h | 2 -- | 11 | target/arm/cpu.h | 1 - |
12 | target/arm/helper.c | 14 +++++++++----- | 12 | target/arm/gdbstub.c | 2 +- |
13 | 2 files changed, 9 insertions(+), 7 deletions(-) | 13 | 2 files changed, 1 insertion(+), 2 deletions(-) |
14 | 14 | ||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/cpu.h |
18 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 19 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); |
20 | #define SCR_FIEN (1U << 21) | 20 | * Helpers to dynamically generates XML descriptions of the sysregs |
21 | #define SCR_ENSCXT (1U << 25) | 21 | * and SVE registers. Returns the number of registers in each set. |
22 | #define SCR_ATA (1U << 26) | 22 | */ |
23 | -#define SCR_AARCH32_MASK (0x3fff & ~(SCR_RW | SCR_ST)) | 23 | -int arm_gen_dynamic_sysreg_xml(CPUState *cpu, int base_reg); |
24 | -#define SCR_AARCH64_MASK (0x3fff & ~SCR_NET) | 24 | int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); |
25 | 25 | ||
26 | /* Return the current FPSCR value. */ | 26 | /* Returns the dynamically generated XML for the gdb stub. |
27 | uint32_t vfp_get_fpscr(CPUARMState *env); | 27 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
28 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/helper.c | 29 | --- a/target/arm/gdbstub.c |
31 | +++ b/target/arm/helper.c | 30 | +++ b/target/arm/gdbstub.c |
32 | @@ -XXX,XX +XXX,XX @@ static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri, | 31 | @@ -XXX,XX +XXX,XX @@ static void arm_register_sysreg_for_xml(gpointer key, gpointer value, |
33 | 32 | } | |
34 | static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 33 | } |
34 | |||
35 | -int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) | ||
36 | +static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) | ||
35 | { | 37 | { |
36 | - /* We only mask off bits that are RES0 both for AArch64 and AArch32. | 38 | ARMCPU *cpu = ARM_CPU(cs); |
37 | - * For bits that vary between AArch32/64, code needs to check the | 39 | GString *s = g_string_new(NULL); |
38 | - * current execution mode before directly using the feature bit. | ||
39 | - */ | ||
40 | - uint32_t valid_mask = SCR_AARCH64_MASK | SCR_AARCH32_MASK; | ||
41 | + /* Begin with base v8.0 state. */ | ||
42 | + uint32_t valid_mask = 0x3fff; | ||
43 | + | ||
44 | + if (arm_el_is_aa64(env, 3)) { | ||
45 | + value |= SCR_FW | SCR_AW; /* these two bits are RES1. */ | ||
46 | + valid_mask &= ~SCR_NET; | ||
47 | + } else { | ||
48 | + valid_mask &= ~(SCR_RW | SCR_ST); | ||
49 | + } | ||
50 | |||
51 | if (!arm_feature(env, ARM_FEATURE_EL2)) { | ||
52 | valid_mask &= ~SCR_HCE; | ||
53 | -- | 40 | -- |
54 | 2.19.2 | 41 | 2.34.1 |
55 | 42 | ||
56 | 43 | diff view generated by jsdifflib |
1 | At the same time, define the fields for these registers, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | and use those defines in arm_pamax(). | 2 | |
3 | 3 | The function is only used for aarch64, so move it to the | |
4 | file that has the other aarch64 gdbstub stuff. Move the | ||
5 | declaration to internals.h. | ||
6 | |||
7 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20181203203839.757-2-richard.henderson@linaro.org | 10 | Message-id: 20230227213329.793795-4-richard.henderson@linaro.org |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | [PMM: fixed up typo (s/achf/ahcf/) belatedly spotted by RTH] | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | target/arm/cpu.h | 26 ++++++++++++++++++++++++-- | 13 | target/arm/cpu.h | 6 --- |
11 | target/arm/internals.h | 3 ++- | 14 | target/arm/internals.h | 1 + |
12 | target/arm/cpu64.c | 6 +++--- | 15 | target/arm/gdbstub.c | 120 ----------------------------------------- |
13 | target/arm/helper.c | 4 ++-- | 16 | target/arm/gdbstub64.c | 118 ++++++++++++++++++++++++++++++++++++++++ |
14 | target/arm/kvm64.c | 4 ++++ | 17 | 4 files changed, 119 insertions(+), 126 deletions(-) |
15 | 5 files changed, 35 insertions(+), 8 deletions(-) | ||
16 | 18 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 21 | --- a/target/arm/cpu.h |
20 | +++ b/target/arm/cpu.h | 22 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 23 | @@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, |
22 | uint64_t id_aa64isar1; | 24 | int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); |
23 | uint64_t id_aa64pfr0; | 25 | int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); |
24 | uint64_t id_aa64pfr1; | 26 | |
25 | + uint64_t id_aa64mmfr0; | 27 | -/* |
26 | + uint64_t id_aa64mmfr1; | 28 | - * Helpers to dynamically generates XML descriptions of the sysregs |
27 | } isar; | 29 | - * and SVE registers. Returns the number of registers in each set. |
28 | uint32_t midr; | 30 | - */ |
29 | uint32_t revidr; | 31 | -int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); |
30 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 32 | - |
31 | uint64_t id_aa64dfr1; | 33 | /* Returns the dynamically generated XML for the gdb stub. |
32 | uint64_t id_aa64afr0; | 34 | * Returns a pointer to the XML contents for the specified XML file or NULL |
33 | uint64_t id_aa64afr1; | 35 | * if the XML name doesn't match the predefined one. |
34 | - uint64_t id_aa64mmfr0; | ||
35 | - uint64_t id_aa64mmfr1; | ||
36 | uint32_t dbgdidr; | ||
37 | uint32_t clidr; | ||
38 | uint64_t mp_affinity; /* MP ID without feature bits */ | ||
39 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64PFR0, GIC, 24, 4) | ||
40 | FIELD(ID_AA64PFR0, RAS, 28, 4) | ||
41 | FIELD(ID_AA64PFR0, SVE, 32, 4) | ||
42 | |||
43 | +FIELD(ID_AA64MMFR0, PARANGE, 0, 4) | ||
44 | +FIELD(ID_AA64MMFR0, ASIDBITS, 4, 4) | ||
45 | +FIELD(ID_AA64MMFR0, BIGEND, 8, 4) | ||
46 | +FIELD(ID_AA64MMFR0, SNSMEM, 12, 4) | ||
47 | +FIELD(ID_AA64MMFR0, BIGENDEL0, 16, 4) | ||
48 | +FIELD(ID_AA64MMFR0, TGRAN16, 20, 4) | ||
49 | +FIELD(ID_AA64MMFR0, TGRAN64, 24, 4) | ||
50 | +FIELD(ID_AA64MMFR0, TGRAN4, 28, 4) | ||
51 | +FIELD(ID_AA64MMFR0, TGRAN16_2, 32, 4) | ||
52 | +FIELD(ID_AA64MMFR0, TGRAN64_2, 36, 4) | ||
53 | +FIELD(ID_AA64MMFR0, TGRAN4_2, 40, 4) | ||
54 | +FIELD(ID_AA64MMFR0, EXS, 44, 4) | ||
55 | + | ||
56 | +FIELD(ID_AA64MMFR1, HAFDBS, 0, 4) | ||
57 | +FIELD(ID_AA64MMFR1, VMIDBITS, 4, 4) | ||
58 | +FIELD(ID_AA64MMFR1, VH, 8, 4) | ||
59 | +FIELD(ID_AA64MMFR1, HPDS, 12, 4) | ||
60 | +FIELD(ID_AA64MMFR1, LO, 16, 4) | ||
61 | +FIELD(ID_AA64MMFR1, PAN, 20, 4) | ||
62 | +FIELD(ID_AA64MMFR1, SPECSEI, 24, 4) | ||
63 | +FIELD(ID_AA64MMFR1, XNX, 28, 4) | ||
64 | + | ||
65 | QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK); | ||
66 | |||
67 | /* If adding a feature bit which corresponds to a Linux ELF | ||
68 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 36 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
69 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
70 | --- a/target/arm/internals.h | 38 | --- a/target/arm/internals.h |
71 | +++ b/target/arm/internals.h | 39 | +++ b/target/arm/internals.h |
72 | @@ -XXX,XX +XXX,XX @@ static inline unsigned int arm_pamax(ARMCPU *cpu) | 40 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t pmu_counter_mask(CPUARMState *env) |
73 | [4] = 44, | 41 | } |
74 | [5] = 48, | 42 | |
75 | }; | 43 | #ifdef TARGET_AARCH64 |
76 | - unsigned int parange = extract32(cpu->id_aa64mmfr0, 0, 4); | 44 | +int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); |
77 | + unsigned int parange = | 45 | int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg); |
78 | + FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); | 46 | int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); |
79 | 47 | int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); | |
80 | /* id_aa64mmfr0 is a read-only register so values outside of the | 48 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
81 | * supported mappings can be considered an implementation error. */ | ||
82 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
84 | --- a/target/arm/cpu64.c | 50 | --- a/target/arm/gdbstub.c |
85 | +++ b/target/arm/cpu64.c | 51 | +++ b/target/arm/gdbstub.c |
86 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | 52 | @@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) |
87 | cpu->pmceid0 = 0x00000000; | 53 | return cpu->dyn_sysreg_xml.num; |
88 | cpu->pmceid1 = 0x00000000; | 54 | } |
89 | cpu->isar.id_aa64isar0 = 0x00011120; | 55 | |
90 | - cpu->id_aa64mmfr0 = 0x00001124; | 56 | -struct TypeSize { |
91 | + cpu->isar.id_aa64mmfr0 = 0x00001124; | 57 | - const char *gdb_type; |
92 | cpu->dbgdidr = 0x3516d000; | 58 | - int size; |
93 | cpu->clidr = 0x0a200023; | 59 | - const char sz, suffix; |
94 | cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | 60 | -}; |
95 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | 61 | - |
96 | cpu->isar.id_aa64pfr0 = 0x00002222; | 62 | -static const struct TypeSize vec_lanes[] = { |
97 | cpu->id_aa64dfr0 = 0x10305106; | 63 | - /* quads */ |
98 | cpu->isar.id_aa64isar0 = 0x00011120; | 64 | - { "uint128", 128, 'q', 'u' }, |
99 | - cpu->id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */ | 65 | - { "int128", 128, 'q', 's' }, |
100 | + cpu->isar.id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */ | 66 | - /* 64 bit */ |
101 | cpu->dbgdidr = 0x3516d000; | 67 | - { "ieee_double", 64, 'd', 'f' }, |
102 | cpu->clidr = 0x0a200023; | 68 | - { "uint64", 64, 'd', 'u' }, |
103 | cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ | 69 | - { "int64", 64, 'd', 's' }, |
104 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | 70 | - /* 32 bit */ |
105 | cpu->pmceid0 = 0x00000000; | 71 | - { "ieee_single", 32, 's', 'f' }, |
106 | cpu->pmceid1 = 0x00000000; | 72 | - { "uint32", 32, 's', 'u' }, |
107 | cpu->isar.id_aa64isar0 = 0x00011120; | 73 | - { "int32", 32, 's', 's' }, |
108 | - cpu->id_aa64mmfr0 = 0x00001124; | 74 | - /* 16 bit */ |
109 | + cpu->isar.id_aa64mmfr0 = 0x00001124; | 75 | - { "ieee_half", 16, 'h', 'f' }, |
110 | cpu->dbgdidr = 0x3516d000; | 76 | - { "uint16", 16, 'h', 'u' }, |
111 | cpu->clidr = 0x0a200023; | 77 | - { "int16", 16, 'h', 's' }, |
112 | cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | 78 | - /* bytes */ |
113 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 79 | - { "uint8", 8, 'b', 'u' }, |
80 | - { "int8", 8, 'b', 's' }, | ||
81 | -}; | ||
82 | - | ||
83 | - | ||
84 | -int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) | ||
85 | -{ | ||
86 | - ARMCPU *cpu = ARM_CPU(cs); | ||
87 | - GString *s = g_string_new(NULL); | ||
88 | - DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml; | ||
89 | - g_autoptr(GString) ts = g_string_new(""); | ||
90 | - int i, j, bits, reg_width = (cpu->sve_max_vq * 128); | ||
91 | - info->num = 0; | ||
92 | - g_string_printf(s, "<?xml version=\"1.0\"?>"); | ||
93 | - g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); | ||
94 | - g_string_append_printf(s, "<feature name=\"org.gnu.gdb.aarch64.sve\">"); | ||
95 | - | ||
96 | - /* First define types and totals in a whole VL */ | ||
97 | - for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { | ||
98 | - int count = reg_width / vec_lanes[i].size; | ||
99 | - g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, vec_lanes[i].suffix); | ||
100 | - g_string_append_printf(s, | ||
101 | - "<vector id=\"%s\" type=\"%s\" count=\"%d\"/>", | ||
102 | - ts->str, vec_lanes[i].gdb_type, count); | ||
103 | - } | ||
104 | - /* | ||
105 | - * Now define a union for each size group containing unsigned and | ||
106 | - * signed and potentially float versions of each size from 128 to | ||
107 | - * 8 bits. | ||
108 | - */ | ||
109 | - for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { | ||
110 | - const char suf[] = { 'q', 'd', 's', 'h', 'b' }; | ||
111 | - g_string_append_printf(s, "<union id=\"svevn%c\">", suf[i]); | ||
112 | - for (j = 0; j < ARRAY_SIZE(vec_lanes); j++) { | ||
113 | - if (vec_lanes[j].size == bits) { | ||
114 | - g_string_append_printf(s, "<field name=\"%c\" type=\"svev%c%c\"/>", | ||
115 | - vec_lanes[j].suffix, | ||
116 | - vec_lanes[j].sz, vec_lanes[j].suffix); | ||
117 | - } | ||
118 | - } | ||
119 | - g_string_append(s, "</union>"); | ||
120 | - } | ||
121 | - /* And now the final union of unions */ | ||
122 | - g_string_append(s, "<union id=\"svev\">"); | ||
123 | - for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { | ||
124 | - const char suf[] = { 'q', 'd', 's', 'h', 'b' }; | ||
125 | - g_string_append_printf(s, "<field name=\"%c\" type=\"svevn%c\"/>", | ||
126 | - suf[i], suf[i]); | ||
127 | - } | ||
128 | - g_string_append(s, "</union>"); | ||
129 | - | ||
130 | - /* Finally the sve prefix type */ | ||
131 | - g_string_append_printf(s, | ||
132 | - "<vector id=\"svep\" type=\"uint8\" count=\"%d\"/>", | ||
133 | - reg_width / 8); | ||
134 | - | ||
135 | - /* Then define each register in parts for each vq */ | ||
136 | - for (i = 0; i < 32; i++) { | ||
137 | - g_string_append_printf(s, | ||
138 | - "<reg name=\"z%d\" bitsize=\"%d\"" | ||
139 | - " regnum=\"%d\" type=\"svev\"/>", | ||
140 | - i, reg_width, base_reg++); | ||
141 | - info->num++; | ||
142 | - } | ||
143 | - /* fpscr & status registers */ | ||
144 | - g_string_append_printf(s, "<reg name=\"fpsr\" bitsize=\"32\"" | ||
145 | - " regnum=\"%d\" group=\"float\"" | ||
146 | - " type=\"int\"/>", base_reg++); | ||
147 | - g_string_append_printf(s, "<reg name=\"fpcr\" bitsize=\"32\"" | ||
148 | - " regnum=\"%d\" group=\"float\"" | ||
149 | - " type=\"int\"/>", base_reg++); | ||
150 | - info->num += 2; | ||
151 | - | ||
152 | - for (i = 0; i < 16; i++) { | ||
153 | - g_string_append_printf(s, | ||
154 | - "<reg name=\"p%d\" bitsize=\"%d\"" | ||
155 | - " regnum=\"%d\" type=\"svep\"/>", | ||
156 | - i, cpu->sve_max_vq * 16, base_reg++); | ||
157 | - info->num++; | ||
158 | - } | ||
159 | - g_string_append_printf(s, | ||
160 | - "<reg name=\"ffr\" bitsize=\"%d\"" | ||
161 | - " regnum=\"%d\" group=\"vector\"" | ||
162 | - " type=\"svep\"/>", | ||
163 | - cpu->sve_max_vq * 16, base_reg++); | ||
164 | - g_string_append_printf(s, | ||
165 | - "<reg name=\"vg\" bitsize=\"64\"" | ||
166 | - " regnum=\"%d\" type=\"int\"/>", | ||
167 | - base_reg++); | ||
168 | - info->num += 2; | ||
169 | - g_string_append_printf(s, "</feature>"); | ||
170 | - cpu->dyn_svereg_xml.desc = g_string_free(s, false); | ||
171 | - | ||
172 | - return cpu->dyn_svereg_xml.num; | ||
173 | -} | ||
174 | - | ||
175 | - | ||
176 | const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) | ||
177 | { | ||
178 | ARMCPU *cpu = ARM_CPU(cs); | ||
179 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | 180 | index XXXXXXX..XXXXXXX 100644 |
115 | --- a/target/arm/helper.c | 181 | --- a/target/arm/gdbstub64.c |
116 | +++ b/target/arm/helper.c | 182 | +++ b/target/arm/gdbstub64.c |
117 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 183 | @@ -XXX,XX +XXX,XX @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) |
118 | { .name = "ID_AA64MMFR0_EL1", .state = ARM_CP_STATE_AA64, | 184 | |
119 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 0, | 185 | return 0; |
120 | .access = PL1_R, .type = ARM_CP_CONST, | 186 | } |
121 | - .resetvalue = cpu->id_aa64mmfr0 }, | 187 | + |
122 | + .resetvalue = cpu->isar.id_aa64mmfr0 }, | 188 | +struct TypeSize { |
123 | { .name = "ID_AA64MMFR1_EL1", .state = ARM_CP_STATE_AA64, | 189 | + const char *gdb_type; |
124 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 1, | 190 | + short size; |
125 | .access = PL1_R, .type = ARM_CP_CONST, | 191 | + char sz, suffix; |
126 | - .resetvalue = cpu->id_aa64mmfr1 }, | 192 | +}; |
127 | + .resetvalue = cpu->isar.id_aa64mmfr1 }, | 193 | + |
128 | { .name = "ID_AA64MMFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, | 194 | +static const struct TypeSize vec_lanes[] = { |
129 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 2, | 195 | + /* quads */ |
130 | .access = PL1_R, .type = ARM_CP_CONST, | 196 | + { "uint128", 128, 'q', 'u' }, |
131 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 197 | + { "int128", 128, 'q', 's' }, |
132 | index XXXXXXX..XXXXXXX 100644 | 198 | + /* 64 bit */ |
133 | --- a/target/arm/kvm64.c | 199 | + { "ieee_double", 64, 'd', 'f' }, |
134 | +++ b/target/arm/kvm64.c | 200 | + { "uint64", 64, 'd', 'u' }, |
135 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | 201 | + { "int64", 64, 'd', 's' }, |
136 | ARM64_SYS_REG(3, 0, 0, 6, 0)); | 202 | + /* 32 bit */ |
137 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, | 203 | + { "ieee_single", 32, 's', 'f' }, |
138 | ARM64_SYS_REG(3, 0, 0, 6, 1)); | 204 | + { "uint32", 32, 's', 'u' }, |
139 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, | 205 | + { "int32", 32, 's', 's' }, |
140 | + ARM64_SYS_REG(3, 0, 0, 7, 0)); | 206 | + /* 16 bit */ |
141 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, | 207 | + { "ieee_half", 16, 'h', 'f' }, |
142 | + ARM64_SYS_REG(3, 0, 0, 7, 1)); | 208 | + { "uint16", 16, 'h', 'u' }, |
143 | 209 | + { "int16", 16, 'h', 's' }, | |
144 | /* | 210 | + /* bytes */ |
145 | * Note that if AArch32 support is not present in the host, | 211 | + { "uint8", 8, 'b', 'u' }, |
212 | + { "int8", 8, 'b', 's' }, | ||
213 | +}; | ||
214 | + | ||
215 | +int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) | ||
216 | +{ | ||
217 | + ARMCPU *cpu = ARM_CPU(cs); | ||
218 | + GString *s = g_string_new(NULL); | ||
219 | + DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml; | ||
220 | + g_autoptr(GString) ts = g_string_new(""); | ||
221 | + int i, j, bits, reg_width = (cpu->sve_max_vq * 128); | ||
222 | + info->num = 0; | ||
223 | + g_string_printf(s, "<?xml version=\"1.0\"?>"); | ||
224 | + g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); | ||
225 | + g_string_append_printf(s, "<feature name=\"org.gnu.gdb.aarch64.sve\">"); | ||
226 | + | ||
227 | + /* First define types and totals in a whole VL */ | ||
228 | + for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { | ||
229 | + int count = reg_width / vec_lanes[i].size; | ||
230 | + g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, vec_lanes[i].suffix); | ||
231 | + g_string_append_printf(s, | ||
232 | + "<vector id=\"%s\" type=\"%s\" count=\"%d\"/>", | ||
233 | + ts->str, vec_lanes[i].gdb_type, count); | ||
234 | + } | ||
235 | + /* | ||
236 | + * Now define a union for each size group containing unsigned and | ||
237 | + * signed and potentially float versions of each size from 128 to | ||
238 | + * 8 bits. | ||
239 | + */ | ||
240 | + for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { | ||
241 | + const char suf[] = { 'q', 'd', 's', 'h', 'b' }; | ||
242 | + g_string_append_printf(s, "<union id=\"svevn%c\">", suf[i]); | ||
243 | + for (j = 0; j < ARRAY_SIZE(vec_lanes); j++) { | ||
244 | + if (vec_lanes[j].size == bits) { | ||
245 | + g_string_append_printf(s, "<field name=\"%c\" type=\"svev%c%c\"/>", | ||
246 | + vec_lanes[j].suffix, | ||
247 | + vec_lanes[j].sz, vec_lanes[j].suffix); | ||
248 | + } | ||
249 | + } | ||
250 | + g_string_append(s, "</union>"); | ||
251 | + } | ||
252 | + /* And now the final union of unions */ | ||
253 | + g_string_append(s, "<union id=\"svev\">"); | ||
254 | + for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { | ||
255 | + const char suf[] = { 'q', 'd', 's', 'h', 'b' }; | ||
256 | + g_string_append_printf(s, "<field name=\"%c\" type=\"svevn%c\"/>", | ||
257 | + suf[i], suf[i]); | ||
258 | + } | ||
259 | + g_string_append(s, "</union>"); | ||
260 | + | ||
261 | + /* Finally the sve prefix type */ | ||
262 | + g_string_append_printf(s, | ||
263 | + "<vector id=\"svep\" type=\"uint8\" count=\"%d\"/>", | ||
264 | + reg_width / 8); | ||
265 | + | ||
266 | + /* Then define each register in parts for each vq */ | ||
267 | + for (i = 0; i < 32; i++) { | ||
268 | + g_string_append_printf(s, | ||
269 | + "<reg name=\"z%d\" bitsize=\"%d\"" | ||
270 | + " regnum=\"%d\" type=\"svev\"/>", | ||
271 | + i, reg_width, base_reg++); | ||
272 | + info->num++; | ||
273 | + } | ||
274 | + /* fpscr & status registers */ | ||
275 | + g_string_append_printf(s, "<reg name=\"fpsr\" bitsize=\"32\"" | ||
276 | + " regnum=\"%d\" group=\"float\"" | ||
277 | + " type=\"int\"/>", base_reg++); | ||
278 | + g_string_append_printf(s, "<reg name=\"fpcr\" bitsize=\"32\"" | ||
279 | + " regnum=\"%d\" group=\"float\"" | ||
280 | + " type=\"int\"/>", base_reg++); | ||
281 | + info->num += 2; | ||
282 | + | ||
283 | + for (i = 0; i < 16; i++) { | ||
284 | + g_string_append_printf(s, | ||
285 | + "<reg name=\"p%d\" bitsize=\"%d\"" | ||
286 | + " regnum=\"%d\" type=\"svep\"/>", | ||
287 | + i, cpu->sve_max_vq * 16, base_reg++); | ||
288 | + info->num++; | ||
289 | + } | ||
290 | + g_string_append_printf(s, | ||
291 | + "<reg name=\"ffr\" bitsize=\"%d\"" | ||
292 | + " regnum=\"%d\" group=\"vector\"" | ||
293 | + " type=\"svep\"/>", | ||
294 | + cpu->sve_max_vq * 16, base_reg++); | ||
295 | + g_string_append_printf(s, | ||
296 | + "<reg name=\"vg\" bitsize=\"64\"" | ||
297 | + " regnum=\"%d\" type=\"int\"/>", | ||
298 | + base_reg++); | ||
299 | + info->num += 2; | ||
300 | + g_string_append_printf(s, "</feature>"); | ||
301 | + info->desc = g_string_free(s, false); | ||
302 | + | ||
303 | + return info->num; | ||
304 | +} | ||
146 | -- | 305 | -- |
147 | 2.19.2 | 306 | 2.34.1 |
148 | 307 | ||
149 | 308 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Replace arm_hcr_el2_{fmo,imo,amo} with a more general routine | 3 | Create a subroutine for creating the union of unions |
4 | that also takes SCR_EL3.NS (aka arm_is_secure_below_el3) into | 4 | of the various type sizes that a vector may contain. |
5 | account, as documented for the plethora of bits in HCR_EL2. | ||
6 | 5 | ||
6 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20181210150501.7990-2-richard.henderson@linaro.org | 9 | Message-id: 20230227213329.793795-5-richard.henderson@linaro.org |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/cpu.h | 67 +++++++++------------------------------ | 12 | target/arm/gdbstub64.c | 83 +++++++++++++++++++++++------------------- |
13 | hw/intc/arm_gicv3_cpuif.c | 21 ++++++------ | 13 | 1 file changed, 45 insertions(+), 38 deletions(-) |
14 | target/arm/helper.c | 66 ++++++++++++++++++++++++++++++++------ | ||
15 | 3 files changed, 83 insertions(+), 71 deletions(-) | ||
16 | 14 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/gdbstub64.c |
20 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/gdbstub64.c |
21 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env) | 19 | @@ -XXX,XX +XXX,XX @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) |
20 | return 0; | ||
22 | } | 21 | } |
23 | #endif | 22 | |
24 | 23 | -struct TypeSize { | |
25 | +/** | 24 | - const char *gdb_type; |
26 | + * arm_hcr_el2_eff(): Return the effective value of HCR_EL2. | 25 | - short size; |
27 | + * E.g. when in secure state, fields in HCR_EL2 are suppressed, | 26 | - char sz, suffix; |
28 | + * "for all purposes other than a direct read or write access of HCR_EL2." | 27 | -}; |
29 | + * Not included here is HCR_RW. | 28 | - |
30 | + */ | 29 | -static const struct TypeSize vec_lanes[] = { |
31 | +uint64_t arm_hcr_el2_eff(CPUARMState *env); | 30 | - /* quads */ |
31 | - { "uint128", 128, 'q', 'u' }, | ||
32 | - { "int128", 128, 'q', 's' }, | ||
33 | - /* 64 bit */ | ||
34 | - { "ieee_double", 64, 'd', 'f' }, | ||
35 | - { "uint64", 64, 'd', 'u' }, | ||
36 | - { "int64", 64, 'd', 's' }, | ||
37 | - /* 32 bit */ | ||
38 | - { "ieee_single", 32, 's', 'f' }, | ||
39 | - { "uint32", 32, 's', 'u' }, | ||
40 | - { "int32", 32, 's', 's' }, | ||
41 | - /* 16 bit */ | ||
42 | - { "ieee_half", 16, 'h', 'f' }, | ||
43 | - { "uint16", 16, 'h', 'u' }, | ||
44 | - { "int16", 16, 'h', 's' }, | ||
45 | - /* bytes */ | ||
46 | - { "uint8", 8, 'b', 'u' }, | ||
47 | - { "int8", 8, 'b', 's' }, | ||
48 | -}; | ||
49 | - | ||
50 | -int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) | ||
51 | +static void output_vector_union_type(GString *s, int reg_width) | ||
52 | { | ||
53 | - ARMCPU *cpu = ARM_CPU(cs); | ||
54 | - GString *s = g_string_new(NULL); | ||
55 | - DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml; | ||
56 | + struct TypeSize { | ||
57 | + const char *gdb_type; | ||
58 | + short size; | ||
59 | + char sz, suffix; | ||
60 | + }; | ||
32 | + | 61 | + |
33 | /* Return true if the specified exception level is running in AArch64 state. */ | 62 | + static const struct TypeSize vec_lanes[] = { |
34 | static inline bool arm_el_is_aa64(CPUARMState *env, int el) | 63 | + /* quads */ |
35 | { | 64 | + { "uint128", 128, 'q', 'u' }, |
36 | @@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu); | 65 | + { "int128", 128, 'q', 's' }, |
37 | # define TARGET_VIRT_ADDR_SPACE_BITS 32 | 66 | + /* 64 bit */ |
38 | #endif | 67 | + { "ieee_double", 64, 'd', 'f' }, |
39 | 68 | + { "uint64", 64, 'd', 'u' }, | |
40 | -/** | 69 | + { "int64", 64, 'd', 's' }, |
41 | - * arm_hcr_el2_imo(): Return the effective value of HCR_EL2.IMO. | 70 | + /* 32 bit */ |
42 | - * Depending on the values of HCR_EL2.E2H and TGE, this may be | 71 | + { "ieee_single", 32, 's', 'f' }, |
43 | - * "behaves as 1 for all purposes other than direct read/write" or | 72 | + { "uint32", 32, 's', 'u' }, |
44 | - * "behaves as 0 for all purposes other than direct read/write" | 73 | + { "int32", 32, 's', 's' }, |
45 | - */ | 74 | + /* 16 bit */ |
46 | -static inline bool arm_hcr_el2_imo(CPUARMState *env) | 75 | + { "ieee_half", 16, 'h', 'f' }, |
47 | -{ | 76 | + { "uint16", 16, 'h', 'u' }, |
48 | - switch (env->cp15.hcr_el2 & (HCR_TGE | HCR_E2H)) { | 77 | + { "int16", 16, 'h', 's' }, |
49 | - case HCR_TGE: | 78 | + /* bytes */ |
50 | - return true; | 79 | + { "uint8", 8, 'b', 'u' }, |
51 | - case HCR_TGE | HCR_E2H: | 80 | + { "int8", 8, 'b', 's' }, |
52 | - return false; | 81 | + }; |
53 | - default: | 82 | + |
54 | - return env->cp15.hcr_el2 & HCR_IMO; | 83 | + static const char suf[] = { 'q', 'd', 's', 'h', 'b' }; |
55 | - } | 84 | + |
56 | -} | 85 | g_autoptr(GString) ts = g_string_new(""); |
57 | - | 86 | - int i, j, bits, reg_width = (cpu->sve_max_vq * 128); |
58 | -/** | 87 | - info->num = 0; |
59 | - * arm_hcr_el2_fmo(): Return the effective value of HCR_EL2.FMO. | 88 | - g_string_printf(s, "<?xml version=\"1.0\"?>"); |
60 | - */ | 89 | - g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); |
61 | -static inline bool arm_hcr_el2_fmo(CPUARMState *env) | 90 | - g_string_append_printf(s, "<feature name=\"org.gnu.gdb.aarch64.sve\">"); |
62 | -{ | 91 | + int i, j, bits; |
63 | - switch (env->cp15.hcr_el2 & (HCR_TGE | HCR_E2H)) { | 92 | |
64 | - case HCR_TGE: | 93 | /* First define types and totals in a whole VL */ |
65 | - return true; | 94 | for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { |
66 | - case HCR_TGE | HCR_E2H: | 95 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) |
67 | - return false; | 96 | * 8 bits. |
68 | - default: | 97 | */ |
69 | - return env->cp15.hcr_el2 & HCR_FMO; | 98 | for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { |
70 | - } | 99 | - const char suf[] = { 'q', 'd', 's', 'h', 'b' }; |
71 | -} | 100 | g_string_append_printf(s, "<union id=\"svevn%c\">", suf[i]); |
72 | - | 101 | for (j = 0; j < ARRAY_SIZE(vec_lanes); j++) { |
73 | -/** | 102 | if (vec_lanes[j].size == bits) { |
74 | - * arm_hcr_el2_amo(): Return the effective value of HCR_EL2.AMO. | 103 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) |
75 | - */ | 104 | /* And now the final union of unions */ |
76 | -static inline bool arm_hcr_el2_amo(CPUARMState *env) | 105 | g_string_append(s, "<union id=\"svev\">"); |
77 | -{ | 106 | for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { |
78 | - switch (env->cp15.hcr_el2 & (HCR_TGE | HCR_E2H)) { | 107 | - const char suf[] = { 'q', 'd', 's', 'h', 'b' }; |
79 | - case HCR_TGE: | 108 | g_string_append_printf(s, "<field name=\"%c\" type=\"svevn%c\"/>", |
80 | - return true; | 109 | suf[i], suf[i]); |
81 | - case HCR_TGE | HCR_E2H: | ||
82 | - return false; | ||
83 | - default: | ||
84 | - return env->cp15.hcr_el2 & HCR_AMO; | ||
85 | - } | ||
86 | -} | ||
87 | - | ||
88 | static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
89 | unsigned int target_el) | ||
90 | { | ||
91 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
92 | bool secure = arm_is_secure(env); | ||
93 | bool pstate_unmasked; | ||
94 | int8_t unmasked = 0; | ||
95 | + uint64_t hcr_el2; | ||
96 | |||
97 | /* Don't take exceptions if they target a lower EL. | ||
98 | * This check should catch any exceptions that would not be taken but left | ||
99 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
100 | return false; | ||
101 | } | 110 | } |
102 | 111 | g_string_append(s, "</union>"); | |
103 | + hcr_el2 = arm_hcr_el2_eff(env); | ||
104 | + | ||
105 | switch (excp_idx) { | ||
106 | case EXCP_FIQ: | ||
107 | pstate_unmasked = !(env->daif & PSTATE_F); | ||
108 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
109 | break; | ||
110 | |||
111 | case EXCP_VFIQ: | ||
112 | - if (secure || !arm_hcr_el2_fmo(env) || (env->cp15.hcr_el2 & HCR_TGE)) { | ||
113 | + if (secure || !(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) { | ||
114 | /* VFIQs are only taken when hypervized and non-secure. */ | ||
115 | return false; | ||
116 | } | ||
117 | return !(env->daif & PSTATE_F); | ||
118 | case EXCP_VIRQ: | ||
119 | - if (secure || !arm_hcr_el2_imo(env) || (env->cp15.hcr_el2 & HCR_TGE)) { | ||
120 | + if (secure || !(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) { | ||
121 | /* VIRQs are only taken when hypervized and non-secure. */ | ||
122 | return false; | ||
123 | } | ||
124 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
125 | * to the CPSR.F setting otherwise we further assess the state | ||
126 | * below. | ||
127 | */ | ||
128 | - hcr = arm_hcr_el2_fmo(env); | ||
129 | + hcr = hcr_el2 & HCR_FMO; | ||
130 | scr = (env->cp15.scr_el3 & SCR_FIQ); | ||
131 | |||
132 | /* When EL3 is 32-bit, the SCR.FW bit controls whether the | ||
133 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
134 | * when setting the target EL, so it does not have a further | ||
135 | * affect here. | ||
136 | */ | ||
137 | - hcr = arm_hcr_el2_imo(env); | ||
138 | + hcr = hcr_el2 & HCR_IMO; | ||
139 | scr = false; | ||
140 | break; | ||
141 | default: | ||
142 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
145 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
146 | @@ -XXX,XX +XXX,XX @@ static bool icv_access(CPUARMState *env, int hcr_flags) | ||
147 | * * access if NS EL1 and either IMO or FMO == 1: | ||
148 | * CTLR, DIR, PMR, RPR | ||
149 | */ | ||
150 | - bool flagmatch = ((hcr_flags & HCR_IMO) && arm_hcr_el2_imo(env)) || | ||
151 | - ((hcr_flags & HCR_FMO) && arm_hcr_el2_fmo(env)); | ||
152 | + uint64_t hcr_el2 = arm_hcr_el2_eff(env); | ||
153 | + bool flagmatch = hcr_el2 & hcr_flags & (HCR_IMO | HCR_FMO); | ||
154 | |||
155 | return flagmatch && arm_current_el(env) == 1 | ||
156 | && !arm_is_secure_below_el3(env); | ||
157 | @@ -XXX,XX +XXX,XX @@ static void icc_dir_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
158 | /* No need to include !IsSecure in route_*_to_el2 as it's only | ||
159 | * tested in cases where we know !IsSecure is true. | ||
160 | */ | ||
161 | - route_fiq_to_el2 = arm_hcr_el2_fmo(env); | ||
162 | - route_irq_to_el2 = arm_hcr_el2_imo(env); | ||
163 | + uint64_t hcr_el2 = arm_hcr_el2_eff(env); | ||
164 | + route_fiq_to_el2 = hcr_el2 & HCR_FMO; | ||
165 | + route_irq_to_el2 = hcr_el2 & HCR_IMO; | ||
166 | |||
167 | switch (arm_current_el(env)) { | ||
168 | case 3: | ||
169 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gicv3_irqfiq_access(CPUARMState *env, | ||
170 | if ((env->cp15.scr_el3 & (SCR_FIQ | SCR_IRQ)) == (SCR_FIQ | SCR_IRQ)) { | ||
171 | switch (el) { | ||
172 | case 1: | ||
173 | - if (arm_is_secure_below_el3(env) || | ||
174 | - (arm_hcr_el2_imo(env) == 0 && arm_hcr_el2_fmo(env) == 0)) { | ||
175 | + /* Note that arm_hcr_el2_eff takes secure state into account. */ | ||
176 | + if ((arm_hcr_el2_eff(env) & (HCR_IMO | HCR_FMO)) == 0) { | ||
177 | r = CP_ACCESS_TRAP_EL3; | ||
178 | } | ||
179 | break; | ||
180 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gicv3_dir_access(CPUARMState *env, | ||
181 | static CPAccessResult gicv3_sgi_access(CPUARMState *env, | ||
182 | const ARMCPRegInfo *ri, bool isread) | ||
183 | { | ||
184 | - if ((arm_hcr_el2_imo(env) || arm_hcr_el2_fmo(env)) && | ||
185 | - arm_current_el(env) == 1 && !arm_is_secure_below_el3(env)) { | ||
186 | + if (arm_current_el(env) == 1 && | ||
187 | + (arm_hcr_el2_eff(env) & (HCR_IMO | HCR_FMO)) != 0) { | ||
188 | /* Takes priority over a possible EL3 trap */ | ||
189 | return CP_ACCESS_TRAP_EL2; | ||
190 | } | ||
191 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gicv3_fiq_access(CPUARMState *env, | ||
192 | if (env->cp15.scr_el3 & SCR_FIQ) { | ||
193 | switch (el) { | ||
194 | case 1: | ||
195 | - if (arm_is_secure_below_el3(env) || !arm_hcr_el2_fmo(env)) { | ||
196 | + if ((arm_hcr_el2_eff(env) & HCR_FMO) == 0) { | ||
197 | r = CP_ACCESS_TRAP_EL3; | ||
198 | } | ||
199 | break; | ||
200 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gicv3_irq_access(CPUARMState *env, | ||
201 | if (env->cp15.scr_el3 & SCR_IRQ) { | ||
202 | switch (el) { | ||
203 | case 1: | ||
204 | - if (arm_is_secure_below_el3(env) || !arm_hcr_el2_imo(env)) { | ||
205 | + if ((arm_hcr_el2_eff(env) & HCR_IMO) == 0) { | ||
206 | r = CP_ACCESS_TRAP_EL3; | ||
207 | } | ||
208 | break; | ||
209 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
210 | index XXXXXXX..XXXXXXX 100644 | ||
211 | --- a/target/arm/helper.c | ||
212 | +++ b/target/arm/helper.c | ||
213 | @@ -XXX,XX +XXX,XX @@ static void csselr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
214 | static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
215 | { | ||
216 | CPUState *cs = ENV_GET_CPU(env); | ||
217 | + uint64_t hcr_el2 = arm_hcr_el2_eff(env); | ||
218 | uint64_t ret = 0; | ||
219 | |||
220 | - if (arm_hcr_el2_imo(env)) { | ||
221 | + if (hcr_el2 & HCR_IMO) { | ||
222 | if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) { | ||
223 | ret |= CPSR_I; | ||
224 | } | ||
225 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
226 | } | ||
227 | } | ||
228 | |||
229 | - if (arm_hcr_el2_fmo(env)) { | ||
230 | + if (hcr_el2 & HCR_FMO) { | ||
231 | if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) { | ||
232 | ret |= CPSR_F; | ||
233 | } | ||
234 | @@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | ||
235 | hcr_write(env, NULL, value); | ||
236 | } | ||
237 | |||
238 | +/* | ||
239 | + * Return the effective value of HCR_EL2. | ||
240 | + * Bits that are not included here: | ||
241 | + * RW (read from SCR_EL3.RW as needed) | ||
242 | + */ | ||
243 | +uint64_t arm_hcr_el2_eff(CPUARMState *env) | ||
244 | +{ | ||
245 | + uint64_t ret = env->cp15.hcr_el2; | ||
246 | + | ||
247 | + if (arm_is_secure_below_el3(env)) { | ||
248 | + /* | ||
249 | + * "This register has no effect if EL2 is not enabled in the | ||
250 | + * current Security state". This is ARMv8.4-SecEL2 speak for | ||
251 | + * !(SCR_EL3.NS==1 || SCR_EL3.EEL2==1). | ||
252 | + * | ||
253 | + * Prior to that, the language was "In an implementation that | ||
254 | + * includes EL3, when the value of SCR_EL3.NS is 0 the PE behaves | ||
255 | + * as if this field is 0 for all purposes other than a direct | ||
256 | + * read or write access of HCR_EL2". With lots of enumeration | ||
257 | + * on a per-field basis. In current QEMU, this is condition | ||
258 | + * is arm_is_secure_below_el3. | ||
259 | + * | ||
260 | + * Since the v8.4 language applies to the entire register, and | ||
261 | + * appears to be backward compatible, use that. | ||
262 | + */ | ||
263 | + ret = 0; | ||
264 | + } else if (ret & HCR_TGE) { | ||
265 | + /* These bits are up-to-date as of ARMv8.4. */ | ||
266 | + if (ret & HCR_E2H) { | ||
267 | + ret &= ~(HCR_VM | HCR_FMO | HCR_IMO | HCR_AMO | | ||
268 | + HCR_BSU_MASK | HCR_DC | HCR_TWI | HCR_TWE | | ||
269 | + HCR_TID0 | HCR_TID2 | HCR_TPCP | HCR_TPU | | ||
270 | + HCR_TDZ | HCR_CD | HCR_ID | HCR_MIOCNCE); | ||
271 | + } else { | ||
272 | + ret |= HCR_FMO | HCR_IMO | HCR_AMO; | ||
273 | + } | ||
274 | + ret &= ~(HCR_SWIO | HCR_PTW | HCR_VF | HCR_VI | HCR_VSE | | ||
275 | + HCR_FB | HCR_TID1 | HCR_TID3 | HCR_TSC | HCR_TACR | | ||
276 | + HCR_TSW | HCR_TTLB | HCR_TVM | HCR_HCD | HCR_TRVM | | ||
277 | + HCR_TLOR); | ||
278 | + } | ||
279 | + | ||
280 | + return ret; | ||
281 | +} | 112 | +} |
282 | + | 113 | + |
283 | static const ARMCPRegInfo el2_cp_reginfo[] = { | 114 | +int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) |
284 | { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64, | 115 | +{ |
285 | .type = ARM_CP_IO, | 116 | + ARMCPU *cpu = ARM_CPU(cs); |
286 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | 117 | + GString *s = g_string_new(NULL); |
287 | uint32_t cur_el, bool secure) | 118 | + DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml; |
288 | { | 119 | + int i, reg_width = (cpu->sve_max_vq * 128); |
289 | CPUARMState *env = cs->env_ptr; | 120 | + info->num = 0; |
290 | - int rw; | 121 | + g_string_printf(s, "<?xml version=\"1.0\"?>"); |
291 | - int scr; | 122 | + g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); |
292 | - int hcr; | 123 | + g_string_append_printf(s, "<feature name=\"org.gnu.gdb.aarch64.sve\">"); |
293 | + bool rw; | 124 | + |
294 | + bool scr; | 125 | + output_vector_union_type(s, reg_width); |
295 | + bool hcr; | 126 | |
296 | int target_el; | 127 | /* Finally the sve prefix type */ |
297 | /* Is the highest EL AArch64? */ | 128 | g_string_append_printf(s, |
298 | - int is64 = arm_feature(env, ARM_FEATURE_AARCH64); | ||
299 | + bool is64 = arm_feature(env, ARM_FEATURE_AARCH64); | ||
300 | + uint64_t hcr_el2; | ||
301 | |||
302 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
303 | rw = ((env->cp15.scr_el3 & SCR_RW) == SCR_RW); | ||
304 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | ||
305 | rw = is64; | ||
306 | } | ||
307 | |||
308 | + hcr_el2 = arm_hcr_el2_eff(env); | ||
309 | switch (excp_idx) { | ||
310 | case EXCP_IRQ: | ||
311 | scr = ((env->cp15.scr_el3 & SCR_IRQ) == SCR_IRQ); | ||
312 | - hcr = arm_hcr_el2_imo(env); | ||
313 | + hcr = hcr_el2 & HCR_IMO; | ||
314 | break; | ||
315 | case EXCP_FIQ: | ||
316 | scr = ((env->cp15.scr_el3 & SCR_FIQ) == SCR_FIQ); | ||
317 | - hcr = arm_hcr_el2_fmo(env); | ||
318 | + hcr = hcr_el2 & HCR_FMO; | ||
319 | break; | ||
320 | default: | ||
321 | scr = ((env->cp15.scr_el3 & SCR_EA) == SCR_EA); | ||
322 | - hcr = arm_hcr_el2_amo(env); | ||
323 | + hcr = hcr_el2 & HCR_AMO; | ||
324 | break; | ||
325 | }; | ||
326 | |||
327 | -- | 129 | -- |
328 | 2.19.2 | 130 | 2.34.1 |
329 | |||
330 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | 3 | Rather than increment base_reg and num, compute num from the change |
4 | milkymist_hpdmc_class_init(). | 4 | to base_reg at the end. Clean up some nearby comments. |
5 | 5 | ||
6 | Cc: gxt@mprc.pku.edu.cn | 6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Cc: michael@walle.cc | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | 8 | Message-id: 20230227213329.793795-6-richard.henderson@linaro.org | |
9 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
10 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20181130093852.20739-12-maozhongyi@cmss.chinamobile.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | hw/misc/milkymist-hpdmc.c | 9 +++------ | 11 | target/arm/gdbstub64.c | 27 ++++++++++++++++----------- |
16 | 1 file changed, 3 insertions(+), 6 deletions(-) | 12 | 1 file changed, 16 insertions(+), 11 deletions(-) |
17 | 13 | ||
18 | diff --git a/hw/misc/milkymist-hpdmc.c b/hw/misc/milkymist-hpdmc.c | 14 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/misc/milkymist-hpdmc.c | 16 | --- a/target/arm/gdbstub64.c |
21 | +++ b/hw/misc/milkymist-hpdmc.c | 17 | +++ b/target/arm/gdbstub64.c |
22 | @@ -XXX,XX +XXX,XX @@ static void milkymist_hpdmc_reset(DeviceState *d) | 18 | @@ -XXX,XX +XXX,XX @@ static void output_vector_union_type(GString *s, int reg_width) |
23 | | IODELAY_PLL2_LOCKED; | 19 | g_string_append(s, "</union>"); |
24 | } | 20 | } |
25 | 21 | ||
26 | -static int milkymist_hpdmc_init(SysBusDevice *dev) | 22 | -int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) |
27 | +static void milkymist_hpdmc_realize(DeviceState *dev, Error **errp) | 23 | +int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) |
28 | { | 24 | { |
29 | MilkymistHpdmcState *s = MILKYMIST_HPDMC(dev); | 25 | ARMCPU *cpu = ARM_CPU(cs); |
30 | 26 | GString *s = g_string_new(NULL); | |
31 | memory_region_init_io(&s->regs_region, OBJECT(dev), &hpdmc_mmio_ops, s, | 27 | DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml; |
32 | "milkymist-hpdmc", R_MAX * 4); | 28 | - int i, reg_width = (cpu->sve_max_vq * 128); |
33 | - sysbus_init_mmio(dev, &s->regs_region); | 29 | - info->num = 0; |
34 | - | 30 | + int reg_width = cpu->sve_max_vq * 128; |
35 | - return 0; | 31 | + int base_reg = orig_base_reg; |
36 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->regs_region); | 32 | + int i; |
37 | } | 33 | + |
38 | 34 | g_string_printf(s, "<?xml version=\"1.0\"?>"); | |
39 | static const VMStateDescription vmstate_milkymist_hpdmc = { | 35 | g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); |
40 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_milkymist_hpdmc = { | 36 | g_string_append_printf(s, "<feature name=\"org.gnu.gdb.aarch64.sve\">"); |
41 | static void milkymist_hpdmc_class_init(ObjectClass *klass, void *data) | 37 | |
42 | { | 38 | + /* Create the vector union type. */ |
43 | DeviceClass *dc = DEVICE_CLASS(klass); | 39 | output_vector_union_type(s, reg_width); |
44 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | 40 | |
45 | 41 | - /* Finally the sve prefix type */ | |
46 | - k->init = milkymist_hpdmc_init; | 42 | + /* Create the predicate vector type. */ |
47 | + dc->realize = milkymist_hpdmc_realize; | 43 | g_string_append_printf(s, |
48 | dc->reset = milkymist_hpdmc_reset; | 44 | "<vector id=\"svep\" type=\"uint8\" count=\"%d\"/>", |
49 | dc->vmsd = &vmstate_milkymist_hpdmc; | 45 | reg_width / 8); |
46 | |||
47 | - /* Then define each register in parts for each vq */ | ||
48 | + /* Define the vector registers. */ | ||
49 | for (i = 0; i < 32; i++) { | ||
50 | g_string_append_printf(s, | ||
51 | "<reg name=\"z%d\" bitsize=\"%d\"" | ||
52 | " regnum=\"%d\" type=\"svev\"/>", | ||
53 | i, reg_width, base_reg++); | ||
54 | - info->num++; | ||
55 | } | ||
56 | + | ||
57 | /* fpscr & status registers */ | ||
58 | g_string_append_printf(s, "<reg name=\"fpsr\" bitsize=\"32\"" | ||
59 | " regnum=\"%d\" group=\"float\"" | ||
60 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) | ||
61 | g_string_append_printf(s, "<reg name=\"fpcr\" bitsize=\"32\"" | ||
62 | " regnum=\"%d\" group=\"float\"" | ||
63 | " type=\"int\"/>", base_reg++); | ||
64 | - info->num += 2; | ||
65 | |||
66 | + /* Define the predicate registers. */ | ||
67 | for (i = 0; i < 16; i++) { | ||
68 | g_string_append_printf(s, | ||
69 | "<reg name=\"p%d\" bitsize=\"%d\"" | ||
70 | " regnum=\"%d\" type=\"svep\"/>", | ||
71 | i, cpu->sve_max_vq * 16, base_reg++); | ||
72 | - info->num++; | ||
73 | } | ||
74 | g_string_append_printf(s, | ||
75 | "<reg name=\"ffr\" bitsize=\"%d\"" | ||
76 | " regnum=\"%d\" group=\"vector\"" | ||
77 | " type=\"svep\"/>", | ||
78 | cpu->sve_max_vq * 16, base_reg++); | ||
79 | + | ||
80 | + /* Define the vector length pseudo-register. */ | ||
81 | g_string_append_printf(s, | ||
82 | "<reg name=\"vg\" bitsize=\"64\"" | ||
83 | " regnum=\"%d\" type=\"int\"/>", | ||
84 | base_reg++); | ||
85 | - info->num += 2; | ||
86 | - g_string_append_printf(s, "</feature>"); | ||
87 | - info->desc = g_string_free(s, false); | ||
88 | |||
89 | + g_string_append_printf(s, "</feature>"); | ||
90 | + | ||
91 | + info->desc = g_string_free(s, false); | ||
92 | + info->num = base_reg - orig_base_reg; | ||
93 | return info->num; | ||
50 | } | 94 | } |
51 | -- | 95 | -- |
52 | 2.19.2 | 96 | 2.34.1 |
53 | 97 | ||
54 | 98 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Correct the nr of IRQs to 192. | 3 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
4 | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 6 | Message-id: 20230227213329.793795-7-richard.henderson@linaro.org |
7 | Message-id: 20181129163655.20370-5-edgar.iglesias@gmail.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 8 | --- |
10 | include/hw/arm/xlnx-versal.h | 2 +- | 9 | target/arm/gdbstub64.c | 5 +++-- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 3 insertions(+), 2 deletions(-) |
12 | 11 | ||
13 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 12 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/arm/xlnx-versal.h | 14 | --- a/target/arm/gdbstub64.c |
16 | +++ b/include/hw/arm/xlnx-versal.h | 15 | +++ b/target/arm/gdbstub64.c |
17 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) |
18 | #define XLNX_VERSAL_NR_ACPUS 2 | 17 | GString *s = g_string_new(NULL); |
19 | #define XLNX_VERSAL_NR_UARTS 2 | 18 | DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml; |
20 | #define XLNX_VERSAL_NR_GEMS 2 | 19 | int reg_width = cpu->sve_max_vq * 128; |
21 | -#define XLNX_VERSAL_NR_IRQS 256 | 20 | + int pred_width = cpu->sve_max_vq * 16; |
22 | +#define XLNX_VERSAL_NR_IRQS 192 | 21 | int base_reg = orig_base_reg; |
23 | 22 | int i; | |
24 | typedef struct Versal { | 23 | |
25 | /*< private >*/ | 24 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) |
25 | g_string_append_printf(s, | ||
26 | "<reg name=\"p%d\" bitsize=\"%d\"" | ||
27 | " regnum=\"%d\" type=\"svep\"/>", | ||
28 | - i, cpu->sve_max_vq * 16, base_reg++); | ||
29 | + i, pred_width, base_reg++); | ||
30 | } | ||
31 | g_string_append_printf(s, | ||
32 | "<reg name=\"ffr\" bitsize=\"%d\"" | ||
33 | " regnum=\"%d\" group=\"vector\"" | ||
34 | " type=\"svep\"/>", | ||
35 | - cpu->sve_max_vq * 16, base_reg++); | ||
36 | + pred_width, base_reg++); | ||
37 | |||
38 | /* Define the vector length pseudo-register. */ | ||
39 | g_string_append_printf(s, | ||
26 | -- | 40 | -- |
27 | 2.19.2 | 41 | 2.34.1 |
28 | 42 | ||
29 | 43 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reduce number of virtio-mmio instances. This is in preparation | 3 | Define svep based on the size of the predicates, |
4 | for correcting the interrupt setup for Versal. | 4 | not the primary vector registers. |
5 | 5 | ||
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20181129163655.20370-3-edgar.iglesias@gmail.com | 8 | Message-id: 20230227213329.793795-8-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | hw/arm/xlnx-versal-virt.c | 2 +- | 11 | target/arm/gdbstub64.c | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 13 | ||
14 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | 14 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/xlnx-versal-virt.c | 16 | --- a/target/arm/gdbstub64.c |
17 | +++ b/hw/arm/xlnx-versal-virt.c | 17 | +++ b/target/arm/gdbstub64.c |
18 | @@ -XXX,XX +XXX,XX @@ static void *versal_virt_get_dtb(const struct arm_boot_info *binfo, | 18 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) |
19 | return board->fdt; | 19 | /* Create the predicate vector type. */ |
20 | } | 20 | g_string_append_printf(s, |
21 | 21 | "<vector id=\"svep\" type=\"uint8\" count=\"%d\"/>", | |
22 | -#define NUM_VIRTIO_TRANSPORT 32 | 22 | - reg_width / 8); |
23 | +#define NUM_VIRTIO_TRANSPORT 8 | 23 | + pred_width / 8); |
24 | static void create_virtio_regions(VersalVirt *s) | 24 | |
25 | { | 25 | /* Define the vector registers. */ |
26 | int virtio_mmio_size = 0x200; | 26 | for (i = 0; i < 32; i++) { |
27 | -- | 27 | -- |
28 | 2.19.2 | 28 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The enable for TGE has already occurred within arm_hcr_el2_amo | 3 | This will make the function usable between SVE and SME. |
4 | and friends. Moreover, when E2H is also set, the sense is | ||
5 | supposed to be reversed, which has also already occurred within | ||
6 | the helpers. | ||
7 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20181203203839.757-5-richard.henderson@linaro.org | 8 | Message-id: 20230227213329.793795-9-richard.henderson@linaro.org |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | target/arm/helper.c | 3 --- | 11 | target/arm/gdbstub64.c | 28 ++++++++++++++-------------- |
14 | 1 file changed, 3 deletions(-) | 12 | 1 file changed, 14 insertions(+), 14 deletions(-) |
15 | 13 | ||
16 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper.c | 16 | --- a/target/arm/gdbstub64.c |
19 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/gdbstub64.c |
20 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | 18 | @@ -XXX,XX +XXX,XX @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) |
21 | break; | 19 | return 0; |
20 | } | ||
21 | |||
22 | -static void output_vector_union_type(GString *s, int reg_width) | ||
23 | +static void output_vector_union_type(GString *s, int reg_width, | ||
24 | + const char *name) | ||
25 | { | ||
26 | struct TypeSize { | ||
27 | const char *gdb_type; | ||
28 | @@ -XXX,XX +XXX,XX @@ static void output_vector_union_type(GString *s, int reg_width) | ||
22 | }; | 29 | }; |
23 | 30 | ||
24 | - /* If HCR.TGE is set then HCR is treated as being 1 */ | 31 | static const char suf[] = { 'q', 'd', 's', 'h', 'b' }; |
25 | - hcr |= ((env->cp15.hcr_el2 & HCR_TGE) == HCR_TGE); | ||
26 | - | 32 | - |
27 | /* Perform a table-lookup for the target EL given the current state */ | 33 | - g_autoptr(GString) ts = g_string_new(""); |
28 | target_el = target_el_table[is64][scr][rw][hcr][secure][cur_el]; | 34 | int i, j, bits; |
29 | 35 | ||
36 | /* First define types and totals in a whole VL */ | ||
37 | for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { | ||
38 | - int count = reg_width / vec_lanes[i].size; | ||
39 | - g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, vec_lanes[i].suffix); | ||
40 | g_string_append_printf(s, | ||
41 | - "<vector id=\"%s\" type=\"%s\" count=\"%d\"/>", | ||
42 | - ts->str, vec_lanes[i].gdb_type, count); | ||
43 | + "<vector id=\"%s%c%c\" type=\"%s\" count=\"%d\"/>", | ||
44 | + name, vec_lanes[i].sz, vec_lanes[i].suffix, | ||
45 | + vec_lanes[i].gdb_type, reg_width / vec_lanes[i].size); | ||
46 | } | ||
47 | + | ||
48 | /* | ||
49 | * Now define a union for each size group containing unsigned and | ||
50 | * signed and potentially float versions of each size from 128 to | ||
51 | * 8 bits. | ||
52 | */ | ||
53 | for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { | ||
54 | - g_string_append_printf(s, "<union id=\"svevn%c\">", suf[i]); | ||
55 | + g_string_append_printf(s, "<union id=\"%sn%c\">", name, suf[i]); | ||
56 | for (j = 0; j < ARRAY_SIZE(vec_lanes); j++) { | ||
57 | if (vec_lanes[j].size == bits) { | ||
58 | - g_string_append_printf(s, "<field name=\"%c\" type=\"svev%c%c\"/>", | ||
59 | - vec_lanes[j].suffix, | ||
60 | + g_string_append_printf(s, "<field name=\"%c\" type=\"%s%c%c\"/>", | ||
61 | + vec_lanes[j].suffix, name, | ||
62 | vec_lanes[j].sz, vec_lanes[j].suffix); | ||
63 | } | ||
64 | } | ||
65 | g_string_append(s, "</union>"); | ||
66 | } | ||
67 | + | ||
68 | /* And now the final union of unions */ | ||
69 | - g_string_append(s, "<union id=\"svev\">"); | ||
70 | + g_string_append_printf(s, "<union id=\"%s\">", name); | ||
71 | for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { | ||
72 | - g_string_append_printf(s, "<field name=\"%c\" type=\"svevn%c\"/>", | ||
73 | - suf[i], suf[i]); | ||
74 | + g_string_append_printf(s, "<field name=\"%c\" type=\"%sn%c\"/>", | ||
75 | + suf[i], name, suf[i]); | ||
76 | } | ||
77 | g_string_append(s, "</union>"); | ||
78 | } | ||
79 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) | ||
80 | g_string_append_printf(s, "<feature name=\"org.gnu.gdb.aarch64.sve\">"); | ||
81 | |||
82 | /* Create the vector union type. */ | ||
83 | - output_vector_union_type(s, reg_width); | ||
84 | + output_vector_union_type(s, reg_width, "svev"); | ||
85 | |||
86 | /* Create the predicate vector type. */ | ||
87 | g_string_append_printf(s, | ||
30 | -- | 88 | -- |
31 | 2.19.2 | 89 | 2.34.1 |
32 | 90 | ||
33 | 91 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Since the TCR_*.HPD bits were RES0 in ARMv8.0, we can simply | 3 | Order suf[] by the log8 of the width. |
4 | interpret the bits as if ARMv8.1-HPD is present without checking. | 4 | Use ARRAY_SIZE instead of hard-coding 128. |
5 | We will need a slightly different check for hpd for aarch32. | 5 | |
6 | This changes the order of the union definitions, | ||
7 | but retains the order of the union-of-union members. | ||
6 | 8 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20181203203839.757-10-richard.henderson@linaro.org | 11 | Message-id: 20230227213329.793795-10-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/cpu64.c | 4 ++++ | 14 | target/arm/gdbstub64.c | 10 ++++++---- |
13 | target/arm/helper.c | 27 ++++++++++++++++++++------- | 15 | 1 file changed, 6 insertions(+), 4 deletions(-) |
14 | 2 files changed, 24 insertions(+), 7 deletions(-) | ||
15 | 16 | ||
16 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 17 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu64.c | 19 | --- a/target/arm/gdbstub64.c |
19 | +++ b/target/arm/cpu64.c | 20 | +++ b/target/arm/gdbstub64.c |
20 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 21 | @@ -XXX,XX +XXX,XX @@ static void output_vector_union_type(GString *s, int reg_width, |
21 | t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); | 22 | { "int8", 8, 'b', 's' }, |
22 | cpu->isar.id_aa64pfr0 = t; | 23 | }; |
23 | 24 | ||
24 | + t = cpu->isar.id_aa64mmfr1; | 25 | - static const char suf[] = { 'q', 'd', 's', 'h', 'b' }; |
25 | + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ | 26 | - int i, j, bits; |
26 | + cpu->isar.id_aa64mmfr1 = t; | 27 | + static const char suf[] = { 'b', 'h', 's', 'd', 'q' }; |
28 | + int i, j; | ||
29 | |||
30 | /* First define types and totals in a whole VL */ | ||
31 | for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { | ||
32 | @@ -XXX,XX +XXX,XX @@ static void output_vector_union_type(GString *s, int reg_width, | ||
33 | * signed and potentially float versions of each size from 128 to | ||
34 | * 8 bits. | ||
35 | */ | ||
36 | - for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { | ||
37 | + for (i = 0; i < ARRAY_SIZE(suf); i++) { | ||
38 | + int bits = 8 << i; | ||
27 | + | 39 | + |
28 | /* Replicate the same data to the 32-bit id registers. */ | 40 | g_string_append_printf(s, "<union id=\"%sn%c\">", name, suf[i]); |
29 | u = cpu->isar.id_isar5; | 41 | for (j = 0; j < ARRAY_SIZE(vec_lanes); j++) { |
30 | u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */ | 42 | if (vec_lanes[j].size == bits) { |
31 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 43 | @@ -XXX,XX +XXX,XX @@ static void output_vector_union_type(GString *s, int reg_width, |
32 | index XXXXXXX..XXXXXXX 100644 | 44 | |
33 | --- a/target/arm/helper.c | 45 | /* And now the final union of unions */ |
34 | +++ b/target/arm/helper.c | 46 | g_string_append_printf(s, "<union id=\"%s\">", name); |
35 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | 47 | - for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) { |
36 | bool ttbr1_valid = true; | 48 | + for (i = ARRAY_SIZE(suf) - 1; i >= 0; i--) { |
37 | uint64_t descaddrmask; | 49 | g_string_append_printf(s, "<field name=\"%c\" type=\"%sn%c\"/>", |
38 | bool aarch64 = arm_el_is_aa64(env, el); | 50 | suf[i], name, suf[i]); |
39 | + bool hpd = false; | ||
40 | |||
41 | /* TODO: | ||
42 | * This code does not handle the different format TCR for VTCR_EL2. | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
44 | if (tg == 2) { /* 16KB pages */ | ||
45 | stride = 11; | ||
46 | } | ||
47 | + if (aarch64) { | ||
48 | + if (el > 1) { | ||
49 | + hpd = extract64(tcr->raw_tcr, 24, 1); | ||
50 | + } else { | ||
51 | + hpd = extract64(tcr->raw_tcr, 41, 1); | ||
52 | + } | ||
53 | + } | ||
54 | } else { | ||
55 | /* We should only be here if TTBR1 is valid */ | ||
56 | assert(ttbr1_valid); | ||
57 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
58 | if (tg == 1) { /* 16KB pages */ | ||
59 | stride = 11; | ||
60 | } | ||
61 | + if (aarch64) { | ||
62 | + hpd = extract64(tcr->raw_tcr, 42, 1); | ||
63 | + } | ||
64 | } | 51 | } |
65 | |||
66 | /* Here we should have set up all the parameters for the translation: | ||
67 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
68 | descaddr = descriptor & descaddrmask; | ||
69 | |||
70 | if ((descriptor & 2) && (level < 3)) { | ||
71 | - /* Table entry. The top five bits are attributes which may | ||
72 | + /* Table entry. The top five bits are attributes which may | ||
73 | * propagate down through lower levels of the table (and | ||
74 | * which are all arranged so that 0 means "no effect", so | ||
75 | * we can gather them up by ORing in the bits at each level). | ||
76 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
77 | break; | ||
78 | } | ||
79 | /* Merge in attributes from table descriptors */ | ||
80 | - attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ | ||
81 | - attrs |= extract32(tableattrs, 3, 1) << 5; /* APTable[1] => AP[2] */ | ||
82 | + attrs |= nstable << 3; /* NS */ | ||
83 | + if (hpd) { | ||
84 | + /* HPD disables all the table attributes except NSTable. */ | ||
85 | + break; | ||
86 | + } | ||
87 | + attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ | ||
88 | /* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 | ||
89 | * means "force PL1 access only", which means forcing AP[1] to 0. | ||
90 | */ | ||
91 | - if (extract32(tableattrs, 2, 1)) { | ||
92 | - attrs &= ~(1 << 4); | ||
93 | - } | ||
94 | - attrs |= nstable << 3; /* NS */ | ||
95 | + attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */ | ||
96 | + attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */ | ||
97 | break; | ||
98 | } | ||
99 | /* Here descaddr is the final physical address, and attributes | ||
100 | -- | 52 | -- |
101 | 2.19.2 | 53 | 2.34.1 |
102 | |||
103 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Currently, all sysbus devices have been converted to realize(), | 3 | Keep the logic for pauth within pauth_helper.c, and expose |
4 | so remove this path. | 4 | a helper function for use with the gdbstub pac extension. |
5 | 5 | ||
6 | Cc: ehabkost@redhat.com | ||
7 | Cc: thuth@redhat.com | ||
8 | Cc: pbonzini@redhat.com | ||
9 | Cc: armbru@redhat.com | ||
10 | Cc: peter.maydell@linaro.org | ||
11 | Cc: richard.henderson@linaro.org | ||
12 | Cc: alistair.francis@wdc.com | ||
13 | |||
14 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
15 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
16 | Message-id: 20181130093852.20739-22-maozhongyi@cmss.chinamobile.com | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230227213329.793795-11-richard.henderson@linaro.org | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 10 | --- |
20 | include/hw/sysbus.h | 3 --- | 11 | target/arm/internals.h | 10 ++++++++++ |
21 | hw/core/sysbus.c | 15 +++++---------- | 12 | target/arm/tcg/pauth_helper.c | 26 ++++++++++++++++++++++---- |
22 | 2 files changed, 5 insertions(+), 13 deletions(-) | 13 | 2 files changed, 32 insertions(+), 4 deletions(-) |
23 | 14 | ||
24 | diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h | 15 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
25 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/sysbus.h | 17 | --- a/target/arm/internals.h |
27 | +++ b/include/hw/sysbus.h | 18 | +++ b/target/arm/internals.h |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct SysBusDevice SysBusDevice; | 19 | @@ -XXX,XX +XXX,XX @@ int exception_target_el(CPUARMState *env); |
29 | typedef struct SysBusDeviceClass { | 20 | bool arm_singlestep_active(CPUARMState *env); |
30 | /*< private >*/ | 21 | bool arm_generate_debug_exceptions(CPUARMState *env); |
31 | DeviceClass parent_class; | 22 | |
32 | - /*< public >*/ | 23 | +/** |
33 | - | 24 | + * pauth_ptr_mask: |
34 | - int (*init)(SysBusDevice *dev); | 25 | + * @env: cpu context |
35 | 26 | + * @ptr: selects between TTBR0 and TTBR1 | |
36 | /* | 27 | + * @data: selects between TBI and TBID |
37 | * Let the sysbus device format its own non-PIO, non-MMIO unit address. | 28 | + * |
38 | diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c | 29 | + * Return a mask of the bits of @ptr that contain the authentication code. |
30 | + */ | ||
31 | +uint64_t pauth_ptr_mask(CPUARMState *env, uint64_t ptr, bool data); | ||
32 | + | ||
33 | /* Add the cpreg definitions for debug related system registers */ | ||
34 | void define_debug_regs(ARMCPU *cpu); | ||
35 | |||
36 | diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/hw/core/sysbus.c | 38 | --- a/target/arm/tcg/pauth_helper.c |
41 | +++ b/hw/core/sysbus.c | 39 | +++ b/target/arm/tcg/pauth_helper.c |
42 | @@ -XXX,XX +XXX,XX @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size) | 40 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, |
43 | } | 41 | return pac | ext | ptr; |
44 | } | 42 | } |
45 | 43 | ||
46 | -/* TODO remove once all sysbus devices have been converted to realize */ | 44 | -static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) |
47 | +/* The purpose of preserving this empty realize function | 45 | +static uint64_t pauth_ptr_mask_internal(ARMVAParameters param) |
48 | + * is to prevent the parent_realize field of some subclasses | ||
49 | + * from being set to NULL to break the normal init/realize | ||
50 | + * of some devices. | ||
51 | + */ | ||
52 | static void sysbus_realize(DeviceState *dev, Error **errp) | ||
53 | { | 46 | { |
54 | - SysBusDevice *sd = SYS_BUS_DEVICE(dev); | 47 | - /* Note that bit 55 is used whether or not the regime has 2 ranges. */ |
55 | - SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd); | 48 | - uint64_t extfield = sextract64(ptr, 55, 1); |
56 | - | 49 | int bot_pac_bit = 64 - param.tsz; |
57 | - if (!sbc->init) { | 50 | int top_pac_bit = 64 - 8 * param.tbi; |
58 | - return; | 51 | |
59 | - } | 52 | - return deposit64(ptr, bot_pac_bit, top_pac_bit - bot_pac_bit, extfield); |
60 | - if (sbc->init(sd) < 0) { | 53 | + return MAKE_64BIT_MASK(bot_pac_bit, top_pac_bit - bot_pac_bit); |
61 | - error_setg(errp, "Device initialization failed"); | 54 | +} |
62 | - } | 55 | + |
56 | +static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) | ||
57 | +{ | ||
58 | + uint64_t mask = pauth_ptr_mask_internal(param); | ||
59 | + | ||
60 | + /* Note that bit 55 is used whether or not the regime has 2 ranges. */ | ||
61 | + if (extract64(ptr, 55, 1)) { | ||
62 | + return ptr | mask; | ||
63 | + } else { | ||
64 | + return ptr & ~mask; | ||
65 | + } | ||
66 | +} | ||
67 | + | ||
68 | +uint64_t pauth_ptr_mask(CPUARMState *env, uint64_t ptr, bool data) | ||
69 | +{ | ||
70 | + ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); | ||
71 | + ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); | ||
72 | + | ||
73 | + return pauth_ptr_mask_internal(param); | ||
63 | } | 74 | } |
64 | 75 | ||
65 | DeviceState *sysbus_create_varargs(const char *name, | 76 | static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, |
66 | -- | 77 | -- |
67 | 2.19.2 | 78 | 2.34.1 |
68 | |||
69 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Provide a trivial implementation with zero limited ordering regions, | 3 | The extension is primarily defined by the Linux kernel NT_ARM_PAC_MASK |
4 | which causes the LDLAR and STLLR instructions to devolve into the | 4 | ptrace register set. |
5 | LDAR and STLR instructions from the base ARMv8.0 instruction set. | ||
6 | 5 | ||
6 | The original gdb feature consists of two masks, data and code, which are | ||
7 | used to mask out the authentication code within a pointer. Following | ||
8 | discussion with Luis Machado, add two more masks in order to support | ||
9 | pointers within the high half of the address space (i.e. TTBR1 vs TTBR0). | ||
10 | |||
11 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1105 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20181210150501.7990-4-richard.henderson@linaro.org | 14 | Message-id: 20230227213329.793795-12-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 16 | --- |
12 | target/arm/cpu.h | 5 +++ | 17 | configs/targets/aarch64-linux-user.mak | 2 +- |
13 | target/arm/cpu64.c | 1 + | 18 | configs/targets/aarch64-softmmu.mak | 2 +- |
14 | target/arm/helper.c | 75 ++++++++++++++++++++++++++++++++++++++ | 19 | configs/targets/aarch64_be-linux-user.mak | 2 +- |
15 | target/arm/translate-a64.c | 12 ++++++ | 20 | target/arm/internals.h | 2 ++ |
16 | 4 files changed, 93 insertions(+) | 21 | target/arm/gdbstub.c | 5 ++++ |
22 | target/arm/gdbstub64.c | 34 +++++++++++++++++++++++ | ||
23 | gdb-xml/aarch64-pauth.xml | 15 ++++++++++ | ||
24 | 7 files changed, 59 insertions(+), 3 deletions(-) | ||
25 | create mode 100644 gdb-xml/aarch64-pauth.xml | ||
17 | 26 | ||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 27 | diff --git a/configs/targets/aarch64-linux-user.mak b/configs/targets/aarch64-linux-user.mak |
19 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/cpu.h | 29 | --- a/configs/targets/aarch64-linux-user.mak |
21 | +++ b/target/arm/cpu.h | 30 | +++ b/configs/targets/aarch64-linux-user.mak |
22 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) | 31 | @@ -XXX,XX +XXX,XX @@ |
23 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; | 32 | TARGET_ARCH=aarch64 |
33 | TARGET_BASE_ARCH=arm | ||
34 | -TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml | ||
35 | +TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-xml/aarch64-pauth.xml | ||
36 | TARGET_HAS_BFLT=y | ||
37 | CONFIG_SEMIHOSTING=y | ||
38 | CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y | ||
39 | diff --git a/configs/targets/aarch64-softmmu.mak b/configs/targets/aarch64-softmmu.mak | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/configs/targets/aarch64-softmmu.mak | ||
42 | +++ b/configs/targets/aarch64-softmmu.mak | ||
43 | @@ -XXX,XX +XXX,XX @@ | ||
44 | TARGET_ARCH=aarch64 | ||
45 | TARGET_BASE_ARCH=arm | ||
46 | TARGET_SUPPORTS_MTTCG=y | ||
47 | -TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sysregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-profile-mve.xml | ||
48 | +TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sysregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-profile-mve.xml gdb-xml/aarch64-pauth.xml | ||
49 | TARGET_NEED_FDT=y | ||
50 | diff --git a/configs/targets/aarch64_be-linux-user.mak b/configs/targets/aarch64_be-linux-user.mak | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/configs/targets/aarch64_be-linux-user.mak | ||
53 | +++ b/configs/targets/aarch64_be-linux-user.mak | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | TARGET_ARCH=aarch64 | ||
56 | TARGET_BASE_ARCH=arm | ||
57 | TARGET_BIG_ENDIAN=y | ||
58 | -TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml | ||
59 | +TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-xml/aarch64-pauth.xml | ||
60 | TARGET_HAS_BFLT=y | ||
61 | CONFIG_SEMIHOSTING=y | ||
62 | CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y | ||
63 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/internals.h | ||
66 | +++ b/target/arm/internals.h | ||
67 | @@ -XXX,XX +XXX,XX @@ int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
68 | int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
69 | int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
70 | int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
71 | +int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
72 | +int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
73 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | ||
74 | void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp); | ||
75 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); | ||
76 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/gdbstub.c | ||
79 | +++ b/target/arm/gdbstub.c | ||
80 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | ||
81 | aarch64_gdb_set_fpu_reg, | ||
82 | 34, "aarch64-fpu.xml", 0); | ||
83 | } | ||
84 | + if (isar_feature_aa64_pauth(&cpu->isar)) { | ||
85 | + gdb_register_coprocessor(cs, aarch64_gdb_get_pauth_reg, | ||
86 | + aarch64_gdb_set_pauth_reg, | ||
87 | + 4, "aarch64-pauth.xml", 0); | ||
88 | + } | ||
89 | #endif | ||
90 | } else { | ||
91 | if (arm_feature(env, ARM_FEATURE_NEON)) { | ||
92 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/gdbstub64.c | ||
95 | +++ b/target/arm/gdbstub64.c | ||
96 | @@ -XXX,XX +XXX,XX @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) | ||
97 | return 0; | ||
24 | } | 98 | } |
25 | 99 | ||
26 | +static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) | 100 | +int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg) |
27 | +{ | 101 | +{ |
28 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) != 0; | 102 | + switch (reg) { |
103 | + case 0: /* pauth_dmask */ | ||
104 | + case 1: /* pauth_cmask */ | ||
105 | + case 2: /* pauth_dmask_high */ | ||
106 | + case 3: /* pauth_cmask_high */ | ||
107 | + /* | ||
108 | + * Note that older versions of this feature only contained | ||
109 | + * pauth_{d,c}mask, for use with Linux user processes, and | ||
110 | + * thus exclusively in the low half of the address space. | ||
111 | + * | ||
112 | + * To support system mode, and to debug kernels, two new regs | ||
113 | + * were added to cover the high half of the address space. | ||
114 | + * For the purpose of pauth_ptr_mask, we can use any well-formed | ||
115 | + * address within the address space half -- here, 0 and -1. | ||
116 | + */ | ||
117 | + { | ||
118 | + bool is_data = !(reg & 1); | ||
119 | + bool is_high = reg & 2; | ||
120 | + uint64_t mask = pauth_ptr_mask(env, -is_high, is_data); | ||
121 | + return gdb_get_reg64(buf, mask); | ||
122 | + } | ||
123 | + default: | ||
124 | + return 0; | ||
125 | + } | ||
29 | +} | 126 | +} |
30 | + | 127 | + |
31 | /* | 128 | +int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg) |
32 | * Forward to the above feature tests given an ARMCPU pointer. | ||
33 | */ | ||
34 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/cpu64.c | ||
37 | +++ b/target/arm/cpu64.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
39 | |||
40 | t = cpu->isar.id_aa64mmfr1; | ||
41 | t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ | ||
42 | + t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); | ||
43 | cpu->isar.id_aa64mmfr1 = t; | ||
44 | |||
45 | /* Replicate the same data to the 32-bit id registers. */ | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/helper.c | ||
49 | +++ b/target/arm/helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
51 | { | ||
52 | /* Begin with base v8.0 state. */ | ||
53 | uint32_t valid_mask = 0x3fff; | ||
54 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
55 | |||
56 | if (arm_el_is_aa64(env, 3)) { | ||
57 | value |= SCR_FW | SCR_AW; /* these two bits are RES1. */ | ||
58 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
59 | valid_mask &= ~SCR_SMD; | ||
60 | } | ||
61 | } | ||
62 | + if (cpu_isar_feature(aa64_lor, cpu)) { | ||
63 | + valid_mask |= SCR_TLOR; | ||
64 | + } | ||
65 | |||
66 | /* Clear all-context RES0 bits. */ | ||
67 | value &= valid_mask; | ||
68 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
69 | */ | ||
70 | valid_mask &= ~HCR_TSC; | ||
71 | } | ||
72 | + if (cpu_isar_feature(aa64_lor, cpu)) { | ||
73 | + valid_mask |= HCR_TLOR; | ||
74 | + } | ||
75 | |||
76 | /* Clear RES0 bits. */ | ||
77 | value &= valid_mask; | ||
78 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
79 | return pfr0; | ||
80 | } | ||
81 | |||
82 | +/* Shared logic between LORID and the rest of the LOR* registers. | ||
83 | + * Secure state has already been delt with. | ||
84 | + */ | ||
85 | +static CPAccessResult access_lor_ns(CPUARMState *env) | ||
86 | +{ | 129 | +{ |
87 | + int el = arm_current_el(env); | 130 | + /* All pseudo registers are read-only. */ |
88 | + | 131 | + return 0; |
89 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_TLOR)) { | ||
90 | + return CP_ACCESS_TRAP_EL2; | ||
91 | + } | ||
92 | + if (el < 3 && (env->cp15.scr_el3 & SCR_TLOR)) { | ||
93 | + return CP_ACCESS_TRAP_EL3; | ||
94 | + } | ||
95 | + return CP_ACCESS_OK; | ||
96 | +} | 132 | +} |
97 | + | 133 | + |
98 | +static CPAccessResult access_lorid(CPUARMState *env, const ARMCPRegInfo *ri, | 134 | static void output_vector_union_type(GString *s, int reg_width, |
99 | + bool isread) | 135 | const char *name) |
100 | +{ | 136 | { |
101 | + if (arm_is_secure_below_el3(env)) { | 137 | diff --git a/gdb-xml/aarch64-pauth.xml b/gdb-xml/aarch64-pauth.xml |
102 | + /* Access ok in secure mode. */ | 138 | new file mode 100644 |
103 | + return CP_ACCESS_OK; | 139 | index XXXXXXX..XXXXXXX |
104 | + } | 140 | --- /dev/null |
105 | + return access_lor_ns(env); | 141 | +++ b/gdb-xml/aarch64-pauth.xml |
106 | +} | 142 | @@ -XXX,XX +XXX,XX @@ |
143 | +<?xml version="1.0"?> | ||
144 | +<!-- Copyright (C) 2018-2022 Free Software Foundation, Inc. | ||
107 | + | 145 | + |
108 | +static CPAccessResult access_lor_other(CPUARMState *env, | 146 | + Copying and distribution of this file, with or without modification, |
109 | + const ARMCPRegInfo *ri, bool isread) | 147 | + are permitted in any medium without royalty provided the copyright |
110 | +{ | 148 | + notice and this notice are preserved. --> |
111 | + if (arm_is_secure_below_el3(env)) { | ||
112 | + /* Access denied in secure mode. */ | ||
113 | + return CP_ACCESS_TRAP; | ||
114 | + } | ||
115 | + return access_lor_ns(env); | ||
116 | +} | ||
117 | + | 149 | + |
118 | void register_cp_regs_for_features(ARMCPU *cpu) | 150 | +<!DOCTYPE feature SYSTEM "gdb-target.dtd"> |
119 | { | 151 | +<feature name="org.gnu.gdb.aarch64.pauth"> |
120 | /* Register all the coprocessor registers based on feature bits */ | 152 | + <reg name="pauth_dmask" bitsize="64"/> |
121 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 153 | + <reg name="pauth_cmask" bitsize="64"/> |
122 | define_one_arm_cp_reg(cpu, &sctlr); | 154 | + <reg name="pauth_dmask_high" bitsize="64"/> |
123 | } | 155 | + <reg name="pauth_cmask_high" bitsize="64"/> |
124 | 156 | +</feature> | |
125 | + if (cpu_isar_feature(aa64_lor, cpu)) { | ||
126 | + /* | ||
127 | + * A trivial implementation of ARMv8.1-LOR leaves all of these | ||
128 | + * registers fixed at 0, which indicates that there are zero | ||
129 | + * supported Limited Ordering regions. | ||
130 | + */ | ||
131 | + static const ARMCPRegInfo lor_reginfo[] = { | ||
132 | + { .name = "LORSA_EL1", .state = ARM_CP_STATE_AA64, | ||
133 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 0, | ||
134 | + .access = PL1_RW, .accessfn = access_lor_other, | ||
135 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
136 | + { .name = "LOREA_EL1", .state = ARM_CP_STATE_AA64, | ||
137 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 1, | ||
138 | + .access = PL1_RW, .accessfn = access_lor_other, | ||
139 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
140 | + { .name = "LORN_EL1", .state = ARM_CP_STATE_AA64, | ||
141 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 2, | ||
142 | + .access = PL1_RW, .accessfn = access_lor_other, | ||
143 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
144 | + { .name = "LORC_EL1", .state = ARM_CP_STATE_AA64, | ||
145 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 3, | ||
146 | + .access = PL1_RW, .accessfn = access_lor_other, | ||
147 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
148 | + { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, | ||
149 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | ||
150 | + .access = PL1_R, .accessfn = access_lorid, | ||
151 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
152 | + REGINFO_SENTINEL | ||
153 | + }; | ||
154 | + define_arm_cp_regs(cpu, lor_reginfo); | ||
155 | + } | ||
156 | + | 157 | + |
157 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
158 | define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); | ||
159 | if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
160 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
161 | index XXXXXXX..XXXXXXX 100644 | ||
162 | --- a/target/arm/translate-a64.c | ||
163 | +++ b/target/arm/translate-a64.c | ||
164 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
165 | } | ||
166 | return; | ||
167 | |||
168 | + case 0x8: /* STLLR */ | ||
169 | + if (!dc_isar_feature(aa64_lor, s)) { | ||
170 | + break; | ||
171 | + } | ||
172 | + /* StoreLORelease is the same as Store-Release for QEMU. */ | ||
173 | + /* fall through */ | ||
174 | case 0x9: /* STLR */ | ||
175 | /* Generate ISS for non-exclusive accesses including LASR. */ | ||
176 | if (rn == 31) { | ||
177 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
178 | disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | ||
179 | return; | ||
180 | |||
181 | + case 0xc: /* LDLAR */ | ||
182 | + if (!dc_isar_feature(aa64_lor, s)) { | ||
183 | + break; | ||
184 | + } | ||
185 | + /* LoadLOAcquire is the same as Load-Acquire for QEMU. */ | ||
186 | + /* fall through */ | ||
187 | case 0xd: /* LDAR */ | ||
188 | /* Generate ISS for non-exclusive accesses including LASR. */ | ||
189 | if (rn == 31) { | ||
190 | -- | 158 | -- |
191 | 2.19.2 | 159 | 2.34.1 |
192 | |||
193 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: David Reiss <dreiss@meta.com> |
---|---|---|---|
2 | 2 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | 3 | Allow the function to be used outside of m_helper.c. |
4 | tusb6010_class_init(). | 4 | Rename with an "arm_" prefix. |
5 | 5 | ||
6 | Cc: kraxel@redhat.com | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 8 | Signed-off-by: David Reiss <dreiss@meta.com> |
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20181130093852.20739-20-maozhongyi@cmss.chinamobile.com | 10 | Message-id: 20230227213329.793795-13-richard.henderson@linaro.org |
11 | [rth: Split out of a larger patch] | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 14 | --- |
13 | hw/usb/tusb6010.c | 8 +++----- | 15 | target/arm/internals.h | 3 +++ |
14 | 1 file changed, 3 insertions(+), 5 deletions(-) | 16 | target/arm/tcg/m_helper.c | 6 +++--- |
17 | 2 files changed, 6 insertions(+), 3 deletions(-) | ||
15 | 18 | ||
16 | diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c | 19 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/usb/tusb6010.c | 21 | --- a/target/arm/internals.h |
19 | +++ b/hw/usb/tusb6010.c | 22 | +++ b/target/arm/internals.h |
20 | @@ -XXX,XX +XXX,XX @@ static void tusb6010_reset(DeviceState *dev) | 23 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); |
21 | musb_reset(s->musb); | 24 | void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); |
25 | #endif | ||
26 | |||
27 | +/* Read the CONTROL register as the MRS instruction would. */ | ||
28 | +uint32_t arm_v7m_mrs_control(CPUARMState *env, uint32_t secure); | ||
29 | + | ||
30 | #ifdef CONFIG_USER_ONLY | ||
31 | static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } | ||
32 | #else | ||
33 | diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/tcg/m_helper.c | ||
36 | +++ b/target/arm/tcg/m_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static uint32_t v7m_mrs_xpsr(CPUARMState *env, uint32_t reg, unsigned el) | ||
38 | return xpsr_read(env) & mask; | ||
22 | } | 39 | } |
23 | 40 | ||
24 | -static int tusb6010_init(SysBusDevice *sbd) | 41 | -static uint32_t v7m_mrs_control(CPUARMState *env, uint32_t secure) |
25 | +static void tusb6010_realize(DeviceState *dev, Error **errp) | 42 | +uint32_t arm_v7m_mrs_control(CPUARMState *env, uint32_t secure) |
26 | { | 43 | { |
27 | - DeviceState *dev = DEVICE(sbd); | 44 | uint32_t value = env->v7m.control[secure]; |
28 | TUSBState *s = TUSB(dev); | 45 | |
29 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 46 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) |
30 | 47 | case 0 ... 7: /* xPSR sub-fields */ | |
31 | s->otg_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tusb_otg_tick, s); | 48 | return v7m_mrs_xpsr(env, reg, 0); |
32 | s->pwr_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tusb_power_tick, s); | 49 | case 20: /* CONTROL */ |
33 | @@ -XXX,XX +XXX,XX @@ static int tusb6010_init(SysBusDevice *sbd) | 50 | - return v7m_mrs_control(env, 0); |
34 | sysbus_init_irq(sbd, &s->irq); | 51 | + return arm_v7m_mrs_control(env, 0); |
35 | qdev_init_gpio_in(dev, tusb6010_irq, musb_irq_max + 1); | 52 | default: |
36 | s->musb = musb_init(dev, 1); | 53 | /* Unprivileged reads others as zero. */ |
37 | - return 0; | 54 | return 0; |
38 | } | 55 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) |
39 | 56 | case 0 ... 7: /* xPSR sub-fields */ | |
40 | static void tusb6010_class_init(ObjectClass *klass, void *data) | 57 | return v7m_mrs_xpsr(env, reg, el); |
41 | { | 58 | case 20: /* CONTROL */ |
42 | DeviceClass *dc = DEVICE_CLASS(klass); | 59 | - return v7m_mrs_control(env, env->v7m.secure); |
43 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | 60 | + return arm_v7m_mrs_control(env, env->v7m.secure); |
44 | 61 | case 0x94: /* CONTROL_NS */ | |
45 | - k->init = tusb6010_init; | 62 | /* |
46 | + dc->realize = tusb6010_realize; | 63 | * We have to handle this here because unprivileged Secure code |
47 | dc->reset = tusb6010_reset; | ||
48 | } | ||
49 | |||
50 | -- | 64 | -- |
51 | 2.19.2 | 65 | 2.34.1 |
52 | 66 | ||
53 | 67 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: David Reiss <dreiss@meta.com> |
---|---|---|---|
2 | 2 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | 3 | Allow the function to be used outside of m_helper.c. |
4 | grlib_gptimer_class_init(). | 4 | Move to be outside of ifndef CONFIG_USER_ONLY block. |
5 | Rename from get_v7m_sp_ptr. | ||
5 | 6 | ||
6 | Cc: chouteau@adacore.com | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 9 | Signed-off-by: David Reiss <dreiss@meta.com> |
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 11 | Message-id: 20230227213329.793795-14-richard.henderson@linaro.org |
11 | Message-id: 20181130093852.20739-18-maozhongyi@cmss.chinamobile.com | 12 | [rth: Split out of a larger patch] |
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 15 | --- |
14 | hw/timer/grlib_gptimer.c | 11 +++++------ | 16 | target/arm/internals.h | 10 +++++ |
15 | 1 file changed, 5 insertions(+), 6 deletions(-) | 17 | target/arm/tcg/m_helper.c | 84 +++++++++++++++++++-------------------- |
18 | 2 files changed, 51 insertions(+), 43 deletions(-) | ||
16 | 19 | ||
17 | diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c | 20 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/timer/grlib_gptimer.c | 22 | --- a/target/arm/internals.h |
20 | +++ b/hw/timer/grlib_gptimer.c | 23 | +++ b/target/arm/internals.h |
21 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_reset(DeviceState *d) | 24 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); |
22 | } | 25 | /* Read the CONTROL register as the MRS instruction would. */ |
26 | uint32_t arm_v7m_mrs_control(CPUARMState *env, uint32_t secure); | ||
27 | |||
28 | +/* | ||
29 | + * Return a pointer to the location where we currently store the | ||
30 | + * stack pointer for the requested security state and thread mode. | ||
31 | + * This pointer will become invalid if the CPU state is updated | ||
32 | + * such that the stack pointers are switched around (eg changing | ||
33 | + * the SPSEL control bit). | ||
34 | + */ | ||
35 | +uint32_t *arm_v7m_get_sp_ptr(CPUARMState *env, bool secure, | ||
36 | + bool threadmode, bool spsel); | ||
37 | + | ||
38 | #ifdef CONFIG_USER_ONLY | ||
39 | static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } | ||
40 | #else | ||
41 | diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/tcg/m_helper.c | ||
44 | +++ b/target/arm/tcg/m_helper.c | ||
45 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
46 | arm_rebuild_hflags(env); | ||
23 | } | 47 | } |
24 | 48 | ||
25 | -static int grlib_gptimer_init(SysBusDevice *dev) | 49 | -static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, |
26 | +static void grlib_gptimer_realize(DeviceState *dev, Error **errp) | 50 | - bool spsel) |
51 | -{ | ||
52 | - /* | ||
53 | - * Return a pointer to the location where we currently store the | ||
54 | - * stack pointer for the requested security state and thread mode. | ||
55 | - * This pointer will become invalid if the CPU state is updated | ||
56 | - * such that the stack pointers are switched around (eg changing | ||
57 | - * the SPSEL control bit). | ||
58 | - * Compare the v8M ARM ARM pseudocode LookUpSP_with_security_mode(). | ||
59 | - * Unlike that pseudocode, we require the caller to pass us in the | ||
60 | - * SPSEL control bit value; this is because we also use this | ||
61 | - * function in handling of pushing of the callee-saves registers | ||
62 | - * part of the v8M stack frame (pseudocode PushCalleeStack()), | ||
63 | - * and in the tailchain codepath the SPSEL bit comes from the exception | ||
64 | - * return magic LR value from the previous exception. The pseudocode | ||
65 | - * opencodes the stack-selection in PushCalleeStack(), but we prefer | ||
66 | - * to make this utility function generic enough to do the job. | ||
67 | - */ | ||
68 | - bool want_psp = threadmode && spsel; | ||
69 | - | ||
70 | - if (secure == env->v7m.secure) { | ||
71 | - if (want_psp == v7m_using_psp(env)) { | ||
72 | - return &env->regs[13]; | ||
73 | - } else { | ||
74 | - return &env->v7m.other_sp; | ||
75 | - } | ||
76 | - } else { | ||
77 | - if (want_psp) { | ||
78 | - return &env->v7m.other_ss_psp; | ||
79 | - } else { | ||
80 | - return &env->v7m.other_ss_msp; | ||
81 | - } | ||
82 | - } | ||
83 | -} | ||
84 | - | ||
85 | static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | ||
86 | uint32_t *pvec) | ||
27 | { | 87 | { |
28 | GPTimerUnit *unit = GRLIB_GPTIMER(dev); | 88 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, |
29 | unsigned int i; | 89 | !mode; |
30 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 90 | |
31 | 91 | mmu_idx = arm_v7m_mmu_idx_for_secstate_and_priv(env, M_REG_S, priv); | |
32 | assert(unit->nr_timers > 0); | 92 | - frame_sp_p = get_v7m_sp_ptr(env, M_REG_S, mode, |
33 | assert(unit->nr_timers <= GPTIMER_MAX_TIMERS); | 93 | - lr & R_V7M_EXCRET_SPSEL_MASK); |
34 | @@ -XXX,XX +XXX,XX @@ static int grlib_gptimer_init(SysBusDevice *dev) | 94 | + frame_sp_p = arm_v7m_get_sp_ptr(env, M_REG_S, mode, |
35 | timer->id = i; | 95 | + lr & R_V7M_EXCRET_SPSEL_MASK); |
36 | 96 | want_psp = mode && (lr & R_V7M_EXCRET_SPSEL_MASK); | |
37 | /* One IRQ line for each timer */ | 97 | if (want_psp) { |
38 | - sysbus_init_irq(dev, &timer->irq); | 98 | limit = env->v7m.psplim[M_REG_S]; |
39 | + sysbus_init_irq(sbd, &timer->irq); | 99 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
40 | 100 | * use 'frame_sp_p' after we do something that makes it invalid. | |
41 | ptimer_set_freq(timer->ptimer, unit->freq_hz); | 101 | */ |
42 | } | 102 | bool spsel = env->v7m.control[return_to_secure] & R_V7M_CONTROL_SPSEL_MASK; |
43 | @@ -XXX,XX +XXX,XX @@ static int grlib_gptimer_init(SysBusDevice *dev) | 103 | - uint32_t *frame_sp_p = get_v7m_sp_ptr(env, |
44 | unit, "gptimer", | 104 | - return_to_secure, |
45 | UNIT_REG_SIZE + GPTIMER_REG_SIZE * unit->nr_timers); | 105 | - !return_to_handler, |
46 | 106 | - spsel); | |
47 | - sysbus_init_mmio(dev, &unit->iomem); | 107 | + uint32_t *frame_sp_p = arm_v7m_get_sp_ptr(env, return_to_secure, |
48 | - return 0; | 108 | + !return_to_handler, spsel); |
49 | + sysbus_init_mmio(sbd, &unit->iomem); | 109 | uint32_t frameptr = *frame_sp_p; |
110 | bool pop_ok = true; | ||
111 | ARMMMUIdx mmu_idx; | ||
112 | @@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu) | ||
113 | threadmode = !arm_v7m_is_handler_mode(env); | ||
114 | spsel = env->v7m.control[M_REG_S] & R_V7M_CONTROL_SPSEL_MASK; | ||
115 | |||
116 | - frame_sp_p = get_v7m_sp_ptr(env, true, threadmode, spsel); | ||
117 | + frame_sp_p = arm_v7m_get_sp_ptr(env, true, threadmode, spsel); | ||
118 | frameptr = *frame_sp_p; | ||
119 | |||
120 | /* | ||
121 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
50 | } | 122 | } |
51 | 123 | ||
52 | static Property grlib_gptimer_properties[] = { | 124 | #endif /* !CONFIG_USER_ONLY */ |
53 | @@ -XXX,XX +XXX,XX @@ static Property grlib_gptimer_properties[] = { | 125 | + |
54 | static void grlib_gptimer_class_init(ObjectClass *klass, void *data) | 126 | +uint32_t *arm_v7m_get_sp_ptr(CPUARMState *env, bool secure, bool threadmode, |
55 | { | 127 | + bool spsel) |
56 | DeviceClass *dc = DEVICE_CLASS(klass); | 128 | +{ |
57 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | 129 | + /* |
58 | 130 | + * Return a pointer to the location where we currently store the | |
59 | - k->init = grlib_gptimer_init; | 131 | + * stack pointer for the requested security state and thread mode. |
60 | + dc->realize = grlib_gptimer_realize; | 132 | + * This pointer will become invalid if the CPU state is updated |
61 | dc->reset = grlib_gptimer_reset; | 133 | + * such that the stack pointers are switched around (eg changing |
62 | dc->props = grlib_gptimer_properties; | 134 | + * the SPSEL control bit). |
63 | } | 135 | + * Compare the v8M ARM ARM pseudocode LookUpSP_with_security_mode(). |
136 | + * Unlike that pseudocode, we require the caller to pass us in the | ||
137 | + * SPSEL control bit value; this is because we also use this | ||
138 | + * function in handling of pushing of the callee-saves registers | ||
139 | + * part of the v8M stack frame (pseudocode PushCalleeStack()), | ||
140 | + * and in the tailchain codepath the SPSEL bit comes from the exception | ||
141 | + * return magic LR value from the previous exception. The pseudocode | ||
142 | + * opencodes the stack-selection in PushCalleeStack(), but we prefer | ||
143 | + * to make this utility function generic enough to do the job. | ||
144 | + */ | ||
145 | + bool want_psp = threadmode && spsel; | ||
146 | + | ||
147 | + if (secure == env->v7m.secure) { | ||
148 | + if (want_psp == v7m_using_psp(env)) { | ||
149 | + return &env->regs[13]; | ||
150 | + } else { | ||
151 | + return &env->v7m.other_sp; | ||
152 | + } | ||
153 | + } else { | ||
154 | + if (want_psp) { | ||
155 | + return &env->v7m.other_ss_psp; | ||
156 | + } else { | ||
157 | + return &env->v7m.other_ss_msp; | ||
158 | + } | ||
159 | + } | ||
160 | +} | ||
64 | -- | 161 | -- |
65 | 2.19.2 | 162 | 2.34.1 |
66 | 163 | ||
67 | 164 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Post v8.4 bits taken from SysReg_v85_xml-00bet8. | 3 | The upstream gdb xml only implements {MSP,PSP}{,_NS,S}, but |
4 | 4 | go ahead and implement the other system registers as well. | |
5 | |||
6 | Since there is significant overlap between the two, implement | ||
7 | them with common code. The only exception is the systemreg | ||
8 | view of CONTROL, which merges the banked bits as per MRS. | ||
9 | |||
10 | Signed-off-by: David Reiss <dreiss@meta.com> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20181203203839.757-4-richard.henderson@linaro.org | 12 | Message-id: 20230227213329.793795-15-richard.henderson@linaro.org |
13 | [rth: Substatial rewrite using enumerator and shared code.] | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 17 | --- |
10 | target/arm/cpu.h | 10 ++++++++++ | 18 | target/arm/cpu.h | 2 + |
11 | 1 file changed, 10 insertions(+) | 19 | target/arm/gdbstub.c | 178 +++++++++++++++++++++++++++++++++++++++++++ |
20 | 2 files changed, 180 insertions(+) | ||
12 | 21 | ||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.h | 24 | --- a/target/arm/cpu.h |
16 | +++ b/target/arm/cpu.h | 25 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 26 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
18 | #define SCR_ST (1U << 11) | 27 | |
19 | #define SCR_TWI (1U << 12) | 28 | DynamicGDBXMLInfo dyn_sysreg_xml; |
20 | #define SCR_TWE (1U << 13) | 29 | DynamicGDBXMLInfo dyn_svereg_xml; |
21 | +#define SCR_TLOR (1U << 14) | 30 | + DynamicGDBXMLInfo dyn_m_systemreg_xml; |
22 | +#define SCR_TERR (1U << 15) | 31 | + DynamicGDBXMLInfo dyn_m_secextreg_xml; |
23 | +#define SCR_APK (1U << 16) | 32 | |
24 | +#define SCR_API (1U << 17) | 33 | /* Timers used by the generic (architected) timer */ |
25 | +#define SCR_EEL2 (1U << 18) | 34 | QEMUTimer *gt_timer[NUM_GTIMERS]; |
26 | +#define SCR_EASE (1U << 19) | 35 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
27 | +#define SCR_NMEA (1U << 20) | 36 | index XXXXXXX..XXXXXXX 100644 |
28 | +#define SCR_FIEN (1U << 21) | 37 | --- a/target/arm/gdbstub.c |
29 | +#define SCR_ENSCXT (1U << 25) | 38 | +++ b/target/arm/gdbstub.c |
30 | +#define SCR_ATA (1U << 26) | 39 | @@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) |
31 | #define SCR_AARCH32_MASK (0x3fff & ~(SCR_RW | SCR_ST)) | 40 | return cpu->dyn_sysreg_xml.num; |
32 | #define SCR_AARCH64_MASK (0x3fff & ~SCR_NET) | 41 | } |
33 | 42 | ||
43 | +typedef enum { | ||
44 | + M_SYSREG_MSP, | ||
45 | + M_SYSREG_PSP, | ||
46 | + M_SYSREG_PRIMASK, | ||
47 | + M_SYSREG_CONTROL, | ||
48 | + M_SYSREG_BASEPRI, | ||
49 | + M_SYSREG_FAULTMASK, | ||
50 | + M_SYSREG_MSPLIM, | ||
51 | + M_SYSREG_PSPLIM, | ||
52 | +} MProfileSysreg; | ||
53 | + | ||
54 | +static const struct { | ||
55 | + const char *name; | ||
56 | + int feature; | ||
57 | +} m_sysreg_def[] = { | ||
58 | + [M_SYSREG_MSP] = { "msp", ARM_FEATURE_M }, | ||
59 | + [M_SYSREG_PSP] = { "psp", ARM_FEATURE_M }, | ||
60 | + [M_SYSREG_PRIMASK] = { "primask", ARM_FEATURE_M }, | ||
61 | + [M_SYSREG_CONTROL] = { "control", ARM_FEATURE_M }, | ||
62 | + [M_SYSREG_BASEPRI] = { "basepri", ARM_FEATURE_M_MAIN }, | ||
63 | + [M_SYSREG_FAULTMASK] = { "faultmask", ARM_FEATURE_M_MAIN }, | ||
64 | + [M_SYSREG_MSPLIM] = { "msplim", ARM_FEATURE_V8 }, | ||
65 | + [M_SYSREG_PSPLIM] = { "psplim", ARM_FEATURE_V8 }, | ||
66 | +}; | ||
67 | + | ||
68 | +static uint32_t *m_sysreg_ptr(CPUARMState *env, MProfileSysreg reg, bool sec) | ||
69 | +{ | ||
70 | + uint32_t *ptr; | ||
71 | + | ||
72 | + switch (reg) { | ||
73 | + case M_SYSREG_MSP: | ||
74 | + ptr = arm_v7m_get_sp_ptr(env, sec, false, true); | ||
75 | + break; | ||
76 | + case M_SYSREG_PSP: | ||
77 | + ptr = arm_v7m_get_sp_ptr(env, sec, true, true); | ||
78 | + break; | ||
79 | + case M_SYSREG_MSPLIM: | ||
80 | + ptr = &env->v7m.msplim[sec]; | ||
81 | + break; | ||
82 | + case M_SYSREG_PSPLIM: | ||
83 | + ptr = &env->v7m.psplim[sec]; | ||
84 | + break; | ||
85 | + case M_SYSREG_PRIMASK: | ||
86 | + ptr = &env->v7m.primask[sec]; | ||
87 | + break; | ||
88 | + case M_SYSREG_BASEPRI: | ||
89 | + ptr = &env->v7m.basepri[sec]; | ||
90 | + break; | ||
91 | + case M_SYSREG_FAULTMASK: | ||
92 | + ptr = &env->v7m.faultmask[sec]; | ||
93 | + break; | ||
94 | + case M_SYSREG_CONTROL: | ||
95 | + ptr = &env->v7m.control[sec]; | ||
96 | + break; | ||
97 | + default: | ||
98 | + return NULL; | ||
99 | + } | ||
100 | + return arm_feature(env, m_sysreg_def[reg].feature) ? ptr : NULL; | ||
101 | +} | ||
102 | + | ||
103 | +static int m_sysreg_get(CPUARMState *env, GByteArray *buf, | ||
104 | + MProfileSysreg reg, bool secure) | ||
105 | +{ | ||
106 | + uint32_t *ptr = m_sysreg_ptr(env, reg, secure); | ||
107 | + | ||
108 | + if (ptr == NULL) { | ||
109 | + return 0; | ||
110 | + } | ||
111 | + return gdb_get_reg32(buf, *ptr); | ||
112 | +} | ||
113 | + | ||
114 | +static int arm_gdb_get_m_systemreg(CPUARMState *env, GByteArray *buf, int reg) | ||
115 | +{ | ||
116 | + /* | ||
117 | + * Here, we emulate MRS instruction, where CONTROL has a mix of | ||
118 | + * banked and non-banked bits. | ||
119 | + */ | ||
120 | + if (reg == M_SYSREG_CONTROL) { | ||
121 | + return gdb_get_reg32(buf, arm_v7m_mrs_control(env, env->v7m.secure)); | ||
122 | + } | ||
123 | + return m_sysreg_get(env, buf, reg, env->v7m.secure); | ||
124 | +} | ||
125 | + | ||
126 | +static int arm_gdb_set_m_systemreg(CPUARMState *env, uint8_t *buf, int reg) | ||
127 | +{ | ||
128 | + return 0; /* TODO */ | ||
129 | +} | ||
130 | + | ||
131 | +static int arm_gen_dynamic_m_systemreg_xml(CPUState *cs, int orig_base_reg) | ||
132 | +{ | ||
133 | + ARMCPU *cpu = ARM_CPU(cs); | ||
134 | + CPUARMState *env = &cpu->env; | ||
135 | + GString *s = g_string_new(NULL); | ||
136 | + int base_reg = orig_base_reg; | ||
137 | + int i; | ||
138 | + | ||
139 | + g_string_printf(s, "<?xml version=\"1.0\"?>"); | ||
140 | + g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); | ||
141 | + g_string_append_printf(s, "<feature name=\"org.gnu.gdb.arm.m-system\">\n"); | ||
142 | + | ||
143 | + for (i = 0; i < ARRAY_SIZE(m_sysreg_def); i++) { | ||
144 | + if (arm_feature(env, m_sysreg_def[i].feature)) { | ||
145 | + g_string_append_printf(s, | ||
146 | + "<reg name=\"%s\" bitsize=\"32\" regnum=\"%d\"/>\n", | ||
147 | + m_sysreg_def[i].name, base_reg++); | ||
148 | + } | ||
149 | + } | ||
150 | + | ||
151 | + g_string_append_printf(s, "</feature>"); | ||
152 | + cpu->dyn_m_systemreg_xml.desc = g_string_free(s, false); | ||
153 | + cpu->dyn_m_systemreg_xml.num = base_reg - orig_base_reg; | ||
154 | + | ||
155 | + return cpu->dyn_m_systemreg_xml.num; | ||
156 | +} | ||
157 | + | ||
158 | +#ifndef CONFIG_USER_ONLY | ||
159 | +/* | ||
160 | + * For user-only, we see the non-secure registers via m_systemreg above. | ||
161 | + * For secext, encode the non-secure view as even and secure view as odd. | ||
162 | + */ | ||
163 | +static int arm_gdb_get_m_secextreg(CPUARMState *env, GByteArray *buf, int reg) | ||
164 | +{ | ||
165 | + return m_sysreg_get(env, buf, reg >> 1, reg & 1); | ||
166 | +} | ||
167 | + | ||
168 | +static int arm_gdb_set_m_secextreg(CPUARMState *env, uint8_t *buf, int reg) | ||
169 | +{ | ||
170 | + return 0; /* TODO */ | ||
171 | +} | ||
172 | + | ||
173 | +static int arm_gen_dynamic_m_secextreg_xml(CPUState *cs, int orig_base_reg) | ||
174 | +{ | ||
175 | + ARMCPU *cpu = ARM_CPU(cs); | ||
176 | + GString *s = g_string_new(NULL); | ||
177 | + int base_reg = orig_base_reg; | ||
178 | + int i; | ||
179 | + | ||
180 | + g_string_printf(s, "<?xml version=\"1.0\"?>"); | ||
181 | + g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); | ||
182 | + g_string_append_printf(s, "<feature name=\"org.gnu.gdb.arm.secext\">\n"); | ||
183 | + | ||
184 | + for (i = 0; i < ARRAY_SIZE(m_sysreg_def); i++) { | ||
185 | + g_string_append_printf(s, | ||
186 | + "<reg name=\"%s_ns\" bitsize=\"32\" regnum=\"%d\"/>\n", | ||
187 | + m_sysreg_def[i].name, base_reg++); | ||
188 | + g_string_append_printf(s, | ||
189 | + "<reg name=\"%s_s\" bitsize=\"32\" regnum=\"%d\"/>\n", | ||
190 | + m_sysreg_def[i].name, base_reg++); | ||
191 | + } | ||
192 | + | ||
193 | + g_string_append_printf(s, "</feature>"); | ||
194 | + cpu->dyn_m_secextreg_xml.desc = g_string_free(s, false); | ||
195 | + cpu->dyn_m_secextreg_xml.num = base_reg - orig_base_reg; | ||
196 | + | ||
197 | + return cpu->dyn_m_secextreg_xml.num; | ||
198 | +} | ||
199 | +#endif | ||
200 | + | ||
201 | const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) | ||
202 | { | ||
203 | ARMCPU *cpu = ARM_CPU(cs); | ||
204 | @@ -XXX,XX +XXX,XX @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) | ||
205 | return cpu->dyn_sysreg_xml.desc; | ||
206 | } else if (strcmp(xmlname, "sve-registers.xml") == 0) { | ||
207 | return cpu->dyn_svereg_xml.desc; | ||
208 | + } else if (strcmp(xmlname, "arm-m-system.xml") == 0) { | ||
209 | + return cpu->dyn_m_systemreg_xml.desc; | ||
210 | +#ifndef CONFIG_USER_ONLY | ||
211 | + } else if (strcmp(xmlname, "arm-m-secext.xml") == 0) { | ||
212 | + return cpu->dyn_m_secextreg_xml.desc; | ||
213 | +#endif | ||
214 | } | ||
215 | return NULL; | ||
216 | } | ||
217 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | ||
218 | arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_regs), | ||
219 | "system-registers.xml", 0); | ||
220 | |||
221 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
222 | + gdb_register_coprocessor(cs, | ||
223 | + arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, | ||
224 | + arm_gen_dynamic_m_systemreg_xml(cs, cs->gdb_num_regs), | ||
225 | + "arm-m-system.xml", 0); | ||
226 | +#ifndef CONFIG_USER_ONLY | ||
227 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
228 | + gdb_register_coprocessor(cs, | ||
229 | + arm_gdb_get_m_secextreg, arm_gdb_set_m_secextreg, | ||
230 | + arm_gen_dynamic_m_secextreg_xml(cs, cs->gdb_num_regs), | ||
231 | + "arm-m-secext.xml", 0); | ||
232 | + } | ||
233 | +#endif | ||
234 | + } | ||
235 | } | ||
34 | -- | 236 | -- |
35 | 2.19.2 | 237 | 2.34.1 |
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The bulk of the work here, beyond base HPD, is defining the | 3 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1421 |
4 | TTBCR2 register. In addition we must check TTBCR.T2E, which | ||
5 | is not present (RES0) for AArch64. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20181203203839.757-11-richard.henderson@linaro.org | 6 | Message-id: 20230227225832.816605-2-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 8 | --- |
12 | target/arm/cpu.h | 9 +++++++++ | 9 | target/arm/cpu.h | 3 +++ |
13 | target/arm/cpu.c | 4 ++++ | 10 | 1 file changed, 3 insertions(+) |
14 | target/arm/helper.c | 37 +++++++++++++++++++++++++++++-------- | ||
15 | 3 files changed, 42 insertions(+), 8 deletions(-) | ||
16 | 11 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 12 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 14 | --- a/target/arm/cpu.h |
20 | +++ b/target/arm/cpu.h | 15 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_ISAR6, FHM, 8, 4) | 16 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_is_el3_or_mon(CPUARMState *env) |
22 | FIELD(ID_ISAR6, SB, 12, 4) | 17 | /* Return true if the processor is in secure state */ |
23 | FIELD(ID_ISAR6, SPECRES, 16, 4) | 18 | static inline bool arm_is_secure(CPUARMState *env) |
24 | 19 | { | |
25 | +FIELD(ID_MMFR4, SPECSEI, 0, 4) | 20 | + if (arm_feature(env, ARM_FEATURE_M)) { |
26 | +FIELD(ID_MMFR4, AC2, 4, 4) | 21 | + return env->v7m.secure; |
27 | +FIELD(ID_MMFR4, XNX, 8, 4) | 22 | + } |
28 | +FIELD(ID_MMFR4, CNP, 12, 4) | 23 | if (arm_is_el3_or_mon(env)) { |
29 | +FIELD(ID_MMFR4, HPDS, 16, 4) | 24 | return true; |
30 | +FIELD(ID_MMFR4, LSM, 20, 4) | ||
31 | +FIELD(ID_MMFR4, CCIDX, 24, 4) | ||
32 | +FIELD(ID_MMFR4, EVT, 28, 4) | ||
33 | + | ||
34 | FIELD(ID_AA64ISAR0, AES, 4, 4) | ||
35 | FIELD(ID_AA64ISAR0, SHA1, 8, 4) | ||
36 | FIELD(ID_AA64ISAR0, SHA2, 12, 4) | ||
37 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/cpu.c | ||
40 | +++ b/target/arm/cpu.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
42 | t = cpu->isar.id_isar6; | ||
43 | t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
44 | cpu->isar.id_isar6 = t; | ||
45 | + | ||
46 | + t = cpu->id_mmfr4; | ||
47 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
48 | + cpu->id_mmfr4 = t; | ||
49 | } | ||
50 | #endif | ||
51 | } | 25 | } |
52 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/helper.c | ||
55 | +++ b/target/arm/helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
57 | uint64_t value) | ||
58 | { | ||
59 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
60 | + TCR *tcr = raw_ptr(env, ri); | ||
61 | |||
62 | if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
63 | /* With LPAE the TTBCR could result in a change of ASID | ||
64 | @@ -XXX,XX +XXX,XX @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
65 | */ | ||
66 | tlb_flush(CPU(cpu)); | ||
67 | } | ||
68 | + /* Preserve the high half of TCR_EL1, set via TTBCR2. */ | ||
69 | + value = deposit64(tcr->raw_tcr, 0, 32, value); | ||
70 | vmsa_ttbcr_raw_write(env, ri, value); | ||
71 | } | ||
72 | |||
73 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
74 | REGINFO_SENTINEL | ||
75 | }; | ||
76 | |||
77 | +/* Note that unlike TTBCR, writing to TTBCR2 does not require flushing | ||
78 | + * qemu tlbs nor adjusting cached masks. | ||
79 | + */ | ||
80 | +static const ARMCPRegInfo ttbcr2_reginfo = { | ||
81 | + .name = "TTBCR2", .cp = 15, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 3, | ||
82 | + .access = PL1_RW, .type = ARM_CP_ALIAS, | ||
83 | + .bank_fieldoffsets = { offsetofhigh32(CPUARMState, cp15.tcr_el[3]), | ||
84 | + offsetofhigh32(CPUARMState, cp15.tcr_el[1]) }, | ||
85 | +}; | ||
86 | + | ||
87 | static void omap_ticonfig_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
88 | uint64_t value) | ||
89 | { | ||
90 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
91 | } else { | ||
92 | define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo); | ||
93 | define_arm_cp_regs(cpu, vmsa_cp_reginfo); | ||
94 | + /* TTCBR2 is introduced with ARMv8.2-A32HPD. */ | ||
95 | + if (FIELD_EX32(cpu->id_mmfr4, ID_MMFR4, HPDS) != 0) { | ||
96 | + define_one_arm_cp_reg(cpu, &ttbcr2_reginfo); | ||
97 | + } | ||
98 | } | ||
99 | if (arm_feature(env, ARM_FEATURE_THUMB2EE)) { | ||
100 | define_arm_cp_regs(cpu, t2ee_cp_reginfo); | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
102 | if (tg == 2) { /* 16KB pages */ | ||
103 | stride = 11; | ||
104 | } | ||
105 | - if (aarch64) { | ||
106 | - if (el > 1) { | ||
107 | - hpd = extract64(tcr->raw_tcr, 24, 1); | ||
108 | - } else { | ||
109 | - hpd = extract64(tcr->raw_tcr, 41, 1); | ||
110 | - } | ||
111 | + if (aarch64 && el > 1) { | ||
112 | + hpd = extract64(tcr->raw_tcr, 24, 1); | ||
113 | + } else { | ||
114 | + hpd = extract64(tcr->raw_tcr, 41, 1); | ||
115 | + } | ||
116 | + if (!aarch64) { | ||
117 | + /* For aarch32, hpd0 is not enabled without t2e as well. */ | ||
118 | + hpd &= extract64(tcr->raw_tcr, 6, 1); | ||
119 | } | ||
120 | } else { | ||
121 | /* We should only be here if TTBR1 is valid */ | ||
122 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
123 | if (tg == 1) { /* 16KB pages */ | ||
124 | stride = 11; | ||
125 | } | ||
126 | - if (aarch64) { | ||
127 | - hpd = extract64(tcr->raw_tcr, 42, 1); | ||
128 | + hpd = extract64(tcr->raw_tcr, 42, 1); | ||
129 | + if (!aarch64) { | ||
130 | + /* For aarch32, hpd1 is not enabled without t2e as well. */ | ||
131 | + hpd &= extract64(tcr->raw_tcr, 6, 1); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | -- | 26 | -- |
136 | 2.19.2 | 27 | 2.34.1 |
137 | |||
138 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Since arm_hcr_el2_eff includes a check against | 3 | M-profile doesn't have HCR_EL2. While we could test features |
4 | arm_is_secure_below_el3, we can often remove a | 4 | before each call, zero is a generally safe return value to |
5 | nearby check against secure state. | 5 | disable the code in the caller. This test is required to |
6 | 6 | avoid an assert in arm_is_secure_below_el3. | |
7 | In some cases, sort the call to arm_hcr_el2_eff | ||
8 | to the end of a short-circuit logical sequence. | ||
9 | 7 | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20181210150501.7990-3-richard.henderson@linaro.org | 10 | Message-id: 20230227225832.816605-3-richard.henderson@linaro.org |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 12 | --- |
15 | target/arm/helper.c | 12 +++++------- | 13 | target/arm/helper.c | 3 +++ |
16 | target/arm/op_helper.c | 14 ++++++-------- | 14 | 1 file changed, 3 insertions(+) |
17 | 2 files changed, 11 insertions(+), 15 deletions(-) | ||
18 | 15 | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 18 | --- a/target/arm/helper.c |
22 | +++ b/target/arm/helper.c | 19 | +++ b/target/arm/helper.c |
23 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tdosa(CPUARMState *env, const ARMCPRegInfo *ri, | 20 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, bool secure) |
24 | int el = arm_current_el(env); | 21 | |
25 | bool mdcr_el2_tdosa = (env->cp15.mdcr_el2 & MDCR_TDOSA) || | 22 | uint64_t arm_hcr_el2_eff(CPUARMState *env) |
26 | (env->cp15.mdcr_el2 & MDCR_TDE) || | ||
27 | - (env->cp15.hcr_el2 & HCR_TGE); | ||
28 | + (arm_hcr_el2_eff(env) & HCR_TGE); | ||
29 | |||
30 | if (el < 2 && mdcr_el2_tdosa && !arm_is_secure_below_el3(env)) { | ||
31 | return CP_ACCESS_TRAP_EL2; | ||
32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tdra(CPUARMState *env, const ARMCPRegInfo *ri, | ||
33 | int el = arm_current_el(env); | ||
34 | bool mdcr_el2_tdra = (env->cp15.mdcr_el2 & MDCR_TDRA) || | ||
35 | (env->cp15.mdcr_el2 & MDCR_TDE) || | ||
36 | - (env->cp15.hcr_el2 & HCR_TGE); | ||
37 | + (arm_hcr_el2_eff(env) & HCR_TGE); | ||
38 | |||
39 | if (el < 2 && mdcr_el2_tdra && !arm_is_secure_below_el3(env)) { | ||
40 | return CP_ACCESS_TRAP_EL2; | ||
41 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tda(CPUARMState *env, const ARMCPRegInfo *ri, | ||
42 | int el = arm_current_el(env); | ||
43 | bool mdcr_el2_tda = (env->cp15.mdcr_el2 & MDCR_TDA) || | ||
44 | (env->cp15.mdcr_el2 & MDCR_TDE) || | ||
45 | - (env->cp15.hcr_el2 & HCR_TGE); | ||
46 | + (arm_hcr_el2_eff(env) & HCR_TGE); | ||
47 | |||
48 | if (el < 2 && mdcr_el2_tda && !arm_is_secure_below_el3(env)) { | ||
49 | return CP_ACCESS_TRAP_EL2; | ||
50 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
51 | if (disabled) { | ||
52 | /* route_to_el2 */ | ||
53 | return (arm_feature(env, ARM_FEATURE_EL2) | ||
54 | - && !arm_is_secure(env) | ||
55 | - && (env->cp15.hcr_el2 & HCR_TGE) ? 2 : 1); | ||
56 | + && (arm_hcr_el2_eff(env) & HCR_TGE) ? 2 : 1); | ||
57 | } | ||
58 | |||
59 | /* Check CPACR.FPEN. */ | ||
60 | @@ -XXX,XX +XXX,XX @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type) | ||
61 | * and CPS are treated as illegal mode changes. | ||
62 | */ | ||
63 | if (write_type == CPSRWriteByInstr && | ||
64 | - (env->cp15.hcr_el2 & HCR_TGE) && | ||
65 | (env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_MON && | ||
66 | - !arm_is_secure_below_el3(env)) { | ||
67 | + (arm_hcr_el2_eff(env) & HCR_TGE)) { | ||
68 | return 1; | ||
69 | } | ||
70 | return 0; | ||
71 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/op_helper.c | ||
74 | +++ b/target/arm/op_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ void raise_exception(CPUARMState *env, uint32_t excp, | ||
76 | { | 23 | { |
77 | CPUState *cs = CPU(arm_env_get_cpu(env)); | 24 | + if (arm_feature(env, ARM_FEATURE_M)) { |
78 | 25 | + return 0; | |
79 | - if ((env->cp15.hcr_el2 & HCR_TGE) && | 26 | + } |
80 | - target_el == 1 && !arm_is_secure(env)) { | 27 | return arm_hcr_el2_eff_secstate(env, arm_is_secure_below_el3(env)); |
81 | + if (target_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) { | 28 | } |
82 | /* | ||
83 | * Redirect NS EL1 exceptions to NS EL2. These are reported with | ||
84 | * their original syndrome register value, with the exception of | ||
85 | @@ -XXX,XX +XXX,XX @@ static inline int check_wfx_trap(CPUARMState *env, bool is_wfe) | ||
86 | * No need for ARM_FEATURE check as if HCR_EL2 doesn't exist the | ||
87 | * bits will be zero indicating no trap. | ||
88 | */ | ||
89 | - if (cur_el < 2 && !arm_is_secure(env)) { | ||
90 | - mask = (is_wfe) ? HCR_TWE : HCR_TWI; | ||
91 | - if (env->cp15.hcr_el2 & mask) { | ||
92 | + if (cur_el < 2) { | ||
93 | + mask = is_wfe ? HCR_TWE : HCR_TWI; | ||
94 | + if (arm_hcr_el2_eff(env) & mask) { | ||
95 | return 2; | ||
96 | } | ||
97 | } | ||
98 | @@ -XXX,XX +XXX,XX @@ void HELPER(pre_smc)(CPUARMState *env, uint32_t syndrome) | ||
99 | exception_target_el(env)); | ||
100 | } | ||
101 | |||
102 | - if (!secure && cur_el == 1 && (env->cp15.hcr_el2 & HCR_TSC)) { | ||
103 | + if (cur_el == 1 && (arm_hcr_el2_eff(env) & HCR_TSC)) { | ||
104 | /* In NS EL1, HCR controlled routing to EL2 has priority over SMD. | ||
105 | * We also want an EL2 guest to be able to forbid its EL1 from | ||
106 | * making PSCI calls into QEMU's "firmware" via HCR.TSC. | ||
107 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env) | ||
108 | goto illegal_return; | ||
109 | } | ||
110 | |||
111 | - if (new_el == 1 && (env->cp15.hcr_el2 & HCR_TGE) | ||
112 | - && !arm_is_secure_below_el3(env)) { | ||
113 | + if (new_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) { | ||
114 | goto illegal_return; | ||
115 | } | ||
116 | 29 | ||
117 | -- | 30 | -- |
118 | 2.19.2 | 31 | 2.34.1 |
119 | |||
120 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Post v8.3 bits taken from SysReg_v85_xml-00bet8. | 3 | In several places we use arm_is_secure_below_el3 and |
4 | arm_is_el3_or_mon separately from arm_is_secure. | ||
5 | These functions make no sense for m-profile, and | ||
6 | would indicate prior incorrect feature testing. | ||
4 | 7 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20181203203839.757-3-richard.henderson@linaro.org | 11 | Message-id: 20230227225832.816605-4-richard.henderson@linaro.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 13 | --- |
10 | target/arm/cpu.h | 22 +++++++++++++++++++++- | 14 | target/arm/cpu.h | 5 ++++- |
11 | 1 file changed, 21 insertions(+), 1 deletion(-) | 15 | 1 file changed, 4 insertions(+), 1 deletion(-) |
12 | 16 | ||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.h | 19 | --- a/target/arm/cpu.h |
16 | +++ b/target/arm/cpu.h | 20 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 21 | @@ -XXX,XX +XXX,XX @@ static inline int arm_feature(CPUARMState *env, int feature) |
18 | #define HCR_TIDCP (1ULL << 20) | 22 | void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); |
19 | #define HCR_TACR (1ULL << 21) | 23 | |
20 | #define HCR_TSW (1ULL << 22) | 24 | #if !defined(CONFIG_USER_ONLY) |
21 | -#define HCR_TPC (1ULL << 23) | 25 | -/* Return true if exception levels below EL3 are in secure state, |
22 | +#define HCR_TPCP (1ULL << 23) | 26 | +/* |
23 | #define HCR_TPU (1ULL << 24) | 27 | + * Return true if exception levels below EL3 are in secure state, |
24 | #define HCR_TTLB (1ULL << 25) | 28 | * or would be following an exception return to that level. |
25 | #define HCR_TVM (1ULL << 26) | 29 | * Unlike arm_is_secure() (which is always a question about the |
26 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 30 | * _current_ state of the CPU) this doesn't care about the current |
27 | #define HCR_CD (1ULL << 32) | 31 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); |
28 | #define HCR_ID (1ULL << 33) | 32 | */ |
29 | #define HCR_E2H (1ULL << 34) | 33 | static inline bool arm_is_secure_below_el3(CPUARMState *env) |
30 | +#define HCR_TLOR (1ULL << 35) | 34 | { |
31 | +#define HCR_TERR (1ULL << 36) | 35 | + assert(!arm_feature(env, ARM_FEATURE_M)); |
32 | +#define HCR_TEA (1ULL << 37) | 36 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
33 | +#define HCR_MIOCNCE (1ULL << 38) | 37 | return !(env->cp15.scr_el3 & SCR_NS); |
34 | +#define HCR_APK (1ULL << 40) | 38 | } else { |
35 | +#define HCR_API (1ULL << 41) | 39 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure_below_el3(CPUARMState *env) |
36 | +#define HCR_NV (1ULL << 42) | 40 | /* Return true if the CPU is AArch64 EL3 or AArch32 Mon */ |
37 | +#define HCR_NV1 (1ULL << 43) | 41 | static inline bool arm_is_el3_or_mon(CPUARMState *env) |
38 | +#define HCR_AT (1ULL << 44) | 42 | { |
39 | +#define HCR_NV2 (1ULL << 45) | 43 | + assert(!arm_feature(env, ARM_FEATURE_M)); |
40 | +#define HCR_FWB (1ULL << 46) | 44 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
41 | +#define HCR_FIEN (1ULL << 47) | 45 | if (is_a64(env) && extract32(env->pstate, 2, 2) == 3) { |
42 | +#define HCR_TID4 (1ULL << 49) | 46 | /* CPU currently in AArch64 state and EL3 */ |
43 | +#define HCR_TICAB (1ULL << 50) | ||
44 | +#define HCR_TOCU (1ULL << 52) | ||
45 | +#define HCR_TTLBIS (1ULL << 54) | ||
46 | +#define HCR_TTLBOS (1ULL << 55) | ||
47 | +#define HCR_ATA (1ULL << 56) | ||
48 | +#define HCR_DCT (1ULL << 57) | ||
49 | + | ||
50 | /* | ||
51 | * When we actually implement ARMv8.1-VHE we should add HCR_E2H to | ||
52 | * HCR_MASK and then clear it again if the feature bit is not set in | ||
53 | -- | 47 | -- |
54 | 2.19.2 | 48 | 2.34.1 |
55 | 49 | ||
56 | 50 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | 3 | Integrate neighboring code from get_phys_addr_lpae which computed |
4 | mv88w8618_wlan_class_init(). | 4 | starting level, as it is easier to validate when doing both at the |
5 | 5 | same time. Mirror the checks at the start of AArch{64,32}.S2Walk, | |
6 | Cc: jan.kiszka@web.de | 6 | especially S2InvalidSL and S2InconsistentSL. |
7 | Cc: peter.maydell@linaro.org | 7 | |
8 | Cc: qemu-arm@nongnu.org | 8 | This reverts 49ba115bb74, which was incorrect -- there is nothing |
9 | 9 | in the ARM pseudocode that depends on TxSZ, i.e. outputsize; the | |
10 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 10 | pseudocode is consistent in referencing PAMax. |
11 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | 11 | |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | Fixes: 49ba115bb74 ("target/arm: Pass outputsize down to check_s2_mmu_setup") |
13 | Message-id: 20181130093852.20739-2-maozhongyi@cmss.chinamobile.com | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20230227225832.816605-5-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 17 | --- |
16 | hw/arm/musicpal.c | 9 ++++----- | 18 | target/arm/ptw.c | 173 ++++++++++++++++++++++++++--------------------- |
17 | 1 file changed, 4 insertions(+), 5 deletions(-) | 19 | 1 file changed, 97 insertions(+), 76 deletions(-) |
18 | 20 | ||
19 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | 21 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
20 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/musicpal.c | 23 | --- a/target/arm/ptw.c |
22 | +++ b/hw/arm/musicpal.c | 24 | +++ b/target/arm/ptw.c |
23 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps mv88w8618_wlan_ops = { | 25 | @@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, |
24 | .endianness = DEVICE_NATIVE_ENDIAN, | 26 | * check_s2_mmu_setup |
25 | }; | 27 | * @cpu: ARMCPU |
26 | 28 | * @is_aa64: True if the translation regime is in AArch64 state | |
27 | -static int mv88w8618_wlan_init(SysBusDevice *dev) | 29 | - * @startlevel: Suggested starting level |
28 | +static void mv88w8618_wlan_realize(DeviceState *dev, Error **errp) | 30 | - * @inputsize: Bitsize of IPAs |
31 | + * @tcr: VTCR_EL2 or VSTCR_EL2 | ||
32 | + * @ds: Effective value of TCR.DS. | ||
33 | + * @iasize: Bitsize of IPAs | ||
34 | * @stride: Page-table stride (See the ARM ARM) | ||
35 | * | ||
36 | - * Returns true if the suggested S2 translation parameters are OK and | ||
37 | - * false otherwise. | ||
38 | + * Decode the starting level of the S2 lookup, returning INT_MIN if | ||
39 | + * the configuration is invalid. | ||
40 | */ | ||
41 | -static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
42 | - int inputsize, int stride, int outputsize) | ||
43 | +static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr, | ||
44 | + bool ds, int iasize, int stride) | ||
29 | { | 45 | { |
30 | MemoryRegion *iomem = g_new(MemoryRegion, 1); | 46 | - const int grainsize = stride + 3; |
31 | 47 | - int startsizecheck; | |
32 | memory_region_init_io(iomem, OBJECT(dev), &mv88w8618_wlan_ops, NULL, | 48 | - |
33 | "musicpal-wlan", MP_WLAN_SIZE); | 49 | - /* |
34 | - sysbus_init_mmio(dev, iomem); | 50 | - * Negative levels are usually not allowed... |
35 | - return 0; | 51 | - * Except for FEAT_LPA2, 4k page table, 52-bit address space, which |
36 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), iomem); | 52 | - * begins with level -1. Note that previous feature tests will have |
53 | - * eliminated this combination if it is not enabled. | ||
54 | - */ | ||
55 | - if (level < (inputsize == 52 && stride == 9 ? -1 : 0)) { | ||
56 | - return false; | ||
57 | - } | ||
58 | - | ||
59 | - startsizecheck = inputsize - ((3 - level) * stride + grainsize); | ||
60 | - if (startsizecheck < 1 || startsizecheck > stride + 4) { | ||
61 | - return false; | ||
62 | - } | ||
63 | + int sl0, sl2, startlevel, granulebits, levels; | ||
64 | + int s1_min_iasize, s1_max_iasize; | ||
65 | |||
66 | + sl0 = extract32(tcr, 6, 2); | ||
67 | if (is_aa64) { | ||
68 | + /* | ||
69 | + * AArch64.S2InvalidTxSZ: While we checked tsz_oob near the top of | ||
70 | + * get_phys_addr_lpae, that used aa64_va_parameters which apply | ||
71 | + * to aarch64. If Stage1 is aarch32, the min_txsz is larger. | ||
72 | + * See AArch64.S2MinTxSZ, where min_tsz is 24, translated to | ||
73 | + * inputsize is 64 - 24 = 40. | ||
74 | + */ | ||
75 | + if (iasize < 40 && !arm_el_is_aa64(&cpu->env, 1)) { | ||
76 | + goto fail; | ||
77 | + } | ||
78 | + | ||
79 | + /* | ||
80 | + * AArch64.S2InvalidSL: Interpretation of SL depends on the page size, | ||
81 | + * so interleave AArch64.S2StartLevel. | ||
82 | + */ | ||
83 | switch (stride) { | ||
84 | - case 13: /* 64KB Pages. */ | ||
85 | - if (level == 0 || (level == 1 && outputsize <= 42)) { | ||
86 | - return false; | ||
87 | + case 9: /* 4KB */ | ||
88 | + /* SL2 is RES0 unless DS=1 & 4KB granule. */ | ||
89 | + sl2 = extract64(tcr, 33, 1); | ||
90 | + if (ds && sl2) { | ||
91 | + if (sl0 != 0) { | ||
92 | + goto fail; | ||
93 | + } | ||
94 | + startlevel = -1; | ||
95 | + } else { | ||
96 | + startlevel = 2 - sl0; | ||
97 | + switch (sl0) { | ||
98 | + case 2: | ||
99 | + if (arm_pamax(cpu) < 44) { | ||
100 | + goto fail; | ||
101 | + } | ||
102 | + break; | ||
103 | + case 3: | ||
104 | + if (!cpu_isar_feature(aa64_st, cpu)) { | ||
105 | + goto fail; | ||
106 | + } | ||
107 | + startlevel = 3; | ||
108 | + break; | ||
109 | + } | ||
110 | } | ||
111 | break; | ||
112 | - case 11: /* 16KB Pages. */ | ||
113 | - if (level == 0 || (level == 1 && outputsize <= 40)) { | ||
114 | - return false; | ||
115 | + case 11: /* 16KB */ | ||
116 | + switch (sl0) { | ||
117 | + case 2: | ||
118 | + if (arm_pamax(cpu) < 42) { | ||
119 | + goto fail; | ||
120 | + } | ||
121 | + break; | ||
122 | + case 3: | ||
123 | + if (!ds) { | ||
124 | + goto fail; | ||
125 | + } | ||
126 | + break; | ||
127 | } | ||
128 | + startlevel = 3 - sl0; | ||
129 | break; | ||
130 | - case 9: /* 4KB Pages. */ | ||
131 | - if (level == 0 && outputsize <= 42) { | ||
132 | - return false; | ||
133 | + case 13: /* 64KB */ | ||
134 | + switch (sl0) { | ||
135 | + case 2: | ||
136 | + if (arm_pamax(cpu) < 44) { | ||
137 | + goto fail; | ||
138 | + } | ||
139 | + break; | ||
140 | + case 3: | ||
141 | + goto fail; | ||
142 | } | ||
143 | + startlevel = 3 - sl0; | ||
144 | break; | ||
145 | default: | ||
146 | g_assert_not_reached(); | ||
147 | } | ||
148 | - | ||
149 | - /* Inputsize checks. */ | ||
150 | - if (inputsize > outputsize && | ||
151 | - (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { | ||
152 | - /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ | ||
153 | - return false; | ||
154 | - } | ||
155 | } else { | ||
156 | - /* AArch32 only supports 4KB pages. Assert on that. */ | ||
157 | + /* | ||
158 | + * Things are simpler for AArch32 EL2, with only 4k pages. | ||
159 | + * There is no separate S2InvalidSL function, but AArch32.S2Walk | ||
160 | + * begins with walkparms.sl0 in {'1x'}. | ||
161 | + */ | ||
162 | assert(stride == 9); | ||
163 | - | ||
164 | - if (level == 0) { | ||
165 | - return false; | ||
166 | + if (sl0 >= 2) { | ||
167 | + goto fail; | ||
168 | } | ||
169 | + startlevel = 2 - sl0; | ||
170 | } | ||
171 | - return true; | ||
172 | + | ||
173 | + /* AArch{64,32}.S2InconsistentSL are functionally equivalent. */ | ||
174 | + levels = 3 - startlevel; | ||
175 | + granulebits = stride + 3; | ||
176 | + | ||
177 | + s1_min_iasize = levels * stride + granulebits + 1; | ||
178 | + s1_max_iasize = s1_min_iasize + (stride - 1) + 4; | ||
179 | + | ||
180 | + if (iasize >= s1_min_iasize && iasize <= s1_max_iasize) { | ||
181 | + return startlevel; | ||
182 | + } | ||
183 | + | ||
184 | + fail: | ||
185 | + return INT_MIN; | ||
37 | } | 186 | } |
38 | 187 | ||
39 | /* GPIO register offsets */ | 188 | /** |
40 | @@ -XXX,XX +XXX,XX @@ DEFINE_MACHINE("musicpal", musicpal_machine_init) | 189 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, |
41 | 190 | */ | |
42 | static void mv88w8618_wlan_class_init(ObjectClass *klass, void *data) | 191 | level = 4 - (inputsize - 4) / stride; |
43 | { | 192 | } else { |
44 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | 193 | - /* |
45 | + DeviceClass *dc = DEVICE_CLASS(klass); | 194 | - * For stage 2 translations the starting level is specified by the |
46 | 195 | - * VTCR_EL2.SL0 field (whose interpretation depends on the page size) | |
47 | - sdc->init = mv88w8618_wlan_init; | 196 | - */ |
48 | + dc->realize = mv88w8618_wlan_realize; | 197 | - uint32_t sl0 = extract32(tcr, 6, 2); |
49 | } | 198 | - uint32_t sl2 = extract64(tcr, 33, 1); |
50 | 199 | - int32_t startlevel; | |
51 | static const TypeInfo mv88w8618_wlan_info = { | 200 | - bool ok; |
201 | - | ||
202 | - /* SL2 is RES0 unless DS=1 & 4kb granule. */ | ||
203 | - if (param.ds && stride == 9 && sl2) { | ||
204 | - if (sl0 != 0) { | ||
205 | - level = 0; | ||
206 | - goto do_translation_fault; | ||
207 | - } | ||
208 | - startlevel = -1; | ||
209 | - } else if (!aarch64 || stride == 9) { | ||
210 | - /* AArch32 or 4KB pages */ | ||
211 | - startlevel = 2 - sl0; | ||
212 | - | ||
213 | - if (cpu_isar_feature(aa64_st, cpu)) { | ||
214 | - startlevel &= 3; | ||
215 | - } | ||
216 | - } else { | ||
217 | - /* 16KB or 64KB pages */ | ||
218 | - startlevel = 3 - sl0; | ||
219 | - } | ||
220 | - | ||
221 | - /* Check that the starting level is valid. */ | ||
222 | - ok = check_s2_mmu_setup(cpu, aarch64, startlevel, | ||
223 | - inputsize, stride, outputsize); | ||
224 | - if (!ok) { | ||
225 | + int startlevel = check_s2_mmu_setup(cpu, aarch64, tcr, param.ds, | ||
226 | + inputsize, stride); | ||
227 | + if (startlevel == INT_MIN) { | ||
228 | + level = 0; | ||
229 | goto do_translation_fault; | ||
230 | } | ||
231 | level = startlevel; | ||
52 | -- | 232 | -- |
53 | 2.19.2 | 233 | 2.34.1 |
54 | |||
55 | diff view generated by jsdifflib |
1 | From: Ricardo Perez Blanco <ricardo.perez_blanco@nokia.com> | 1 | From: Ard Biesheuvel <ardb@kernel.org> |
---|---|---|---|
2 | 2 | ||
3 | Architecturally, it's possible for an AArch64 machine to have | 3 | Fedora 39 will ship its arm64 kernels in the new generic EFI zboot |
4 | all of its RAM over the 4GB mark, but our kernel/initrd loading | 4 | format, using gzip compression for the payload. |
5 | code in boot.c assumes that the upper half of the addresses | ||
6 | to load these images to is always zero. Write the whole 64 bit | ||
7 | address into the bootloader code fragment, not just the low half. | ||
8 | 5 | ||
9 | Note that, currently, none of the existing QEMU machines have | 6 | For doing EFI boot in QEMU, this is completely transparent, as the |
10 | their main memory over 4GBs, so this was not a user-visible bug. | 7 | firmware or bootloader will take care of this. However, for direct |
8 | kernel boot without firmware, we will lose the ability to boot such | ||
9 | distro kernels unless we deal with the new format directly. | ||
11 | 10 | ||
12 | Signed-off-by: Ricardo Perez Blanco <ricardo.perez_blanco@nokia.com> | 11 | EFI zboot images contain metadata in the header regarding the placement |
13 | [PMM: revised commit message and tweaked some long lines] | 12 | of the compressed payload inside the image, and the type of compression |
13 | used. This means we can wire up the existing gzip support without too | ||
14 | much hassle, by parsing the header and grabbing the payload from inside | ||
15 | the loaded zboot image. | ||
16 | |||
17 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Cc: Alex Bennée <alex.bennee@linaro.org> | ||
19 | Cc: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Signed-off-by: Ard Biesheuvel <ardb@kernel.org> | ||
22 | Message-id: 20230303160109.3626966-1-ardb@kernel.org | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
24 | [PMM: tweaked comment formatting, fixed checkpatch nits] | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 26 | --- |
17 | hw/arm/boot.c | 35 ++++++++++++++++++++++------------- | 27 | include/hw/loader.h | 19 ++++++++++ |
18 | 1 file changed, 22 insertions(+), 13 deletions(-) | 28 | hw/arm/boot.c | 6 +++ |
29 | hw/core/loader.c | 91 +++++++++++++++++++++++++++++++++++++++++++++ | ||
30 | 3 files changed, 116 insertions(+) | ||
19 | 31 | ||
32 | diff --git a/include/hw/loader.h b/include/hw/loader.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/include/hw/loader.h | ||
35 | +++ b/include/hw/loader.h | ||
36 | @@ -XXX,XX +XXX,XX @@ ssize_t load_image_gzipped_buffer(const char *filename, uint64_t max_sz, | ||
37 | uint8_t **buffer); | ||
38 | ssize_t load_image_gzipped(const char *filename, hwaddr addr, uint64_t max_sz); | ||
39 | |||
40 | +/** | ||
41 | + * unpack_efi_zboot_image: | ||
42 | + * @buffer: pointer to a variable holding the address of a buffer containing the | ||
43 | + * image | ||
44 | + * @size: pointer to a variable holding the size of the buffer | ||
45 | + * | ||
46 | + * Check whether the buffer contains a EFI zboot image, and if it does, extract | ||
47 | + * the compressed payload and decompress it into a new buffer. If successful, | ||
48 | + * the old buffer is freed, and the *buffer and size variables pointed to by the | ||
49 | + * function arguments are updated to refer to the newly populated buffer. | ||
50 | + * | ||
51 | + * Returns 0 if the image could not be identified as a EFI zboot image. | ||
52 | + * Returns -1 if the buffer contents were identified as a EFI zboot image, but | ||
53 | + * unpacking failed for any reason. | ||
54 | + * Returns the size of the decompressed payload if decompression was performed | ||
55 | + * successfully. | ||
56 | + */ | ||
57 | +ssize_t unpack_efi_zboot_image(uint8_t **buffer, int *size); | ||
58 | + | ||
59 | #define ELF_LOAD_FAILED -1 | ||
60 | #define ELF_LOAD_NOT_ELF -2 | ||
61 | #define ELF_LOAD_WRONG_ARCH -3 | ||
20 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 62 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c |
21 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/boot.c | 64 | --- a/hw/arm/boot.c |
23 | +++ b/hw/arm/boot.c | 65 | +++ b/hw/arm/boot.c |
24 | @@ -XXX,XX +XXX,XX @@ typedef enum { | 66 | @@ -XXX,XX +XXX,XX @@ static uint64_t load_aarch64_image(const char *filename, hwaddr mem_base, |
25 | FIXUP_TERMINATOR, /* end of insns */ | 67 | return -1; |
26 | FIXUP_BOARDID, /* overwrite with board ID number */ | ||
27 | FIXUP_BOARD_SETUP, /* overwrite with board specific setup code address */ | ||
28 | - FIXUP_ARGPTR, /* overwrite with pointer to kernel args */ | ||
29 | - FIXUP_ENTRYPOINT, /* overwrite with kernel entry point */ | ||
30 | + FIXUP_ARGPTR_LO, /* overwrite with pointer to kernel args */ | ||
31 | + FIXUP_ARGPTR_HI, /* overwrite with pointer to kernel args (high half) */ | ||
32 | + FIXUP_ENTRYPOINT_LO, /* overwrite with kernel entry point */ | ||
33 | + FIXUP_ENTRYPOINT_HI, /* overwrite with kernel entry point (high half) */ | ||
34 | FIXUP_GIC_CPU_IF, /* overwrite with GIC CPU interface address */ | ||
35 | FIXUP_BOOTREG, /* overwrite with boot register address */ | ||
36 | FIXUP_DSB, /* overwrite with correct DSB insn for cpu */ | ||
37 | @@ -XXX,XX +XXX,XX @@ static const ARMInsnFixup bootloader_aarch64[] = { | ||
38 | { 0xaa1f03e3 }, /* mov x3, xzr */ | ||
39 | { 0x58000084 }, /* ldr x4, entry ; Load the lower 32-bits of kernel entry */ | ||
40 | { 0xd61f0080 }, /* br x4 ; Jump to the kernel entry point */ | ||
41 | - { 0, FIXUP_ARGPTR }, /* arg: .word @DTB Lower 32-bits */ | ||
42 | - { 0 }, /* .word @DTB Higher 32-bits */ | ||
43 | - { 0, FIXUP_ENTRYPOINT }, /* entry: .word @Kernel Entry Lower 32-bits */ | ||
44 | - { 0 }, /* .word @Kernel Entry Higher 32-bits */ | ||
45 | + { 0, FIXUP_ARGPTR_LO }, /* arg: .word @DTB Lower 32-bits */ | ||
46 | + { 0, FIXUP_ARGPTR_HI}, /* .word @DTB Higher 32-bits */ | ||
47 | + { 0, FIXUP_ENTRYPOINT_LO }, /* entry: .word @Kernel Entry Lower 32-bits */ | ||
48 | + { 0, FIXUP_ENTRYPOINT_HI }, /* .word @Kernel Entry Higher 32-bits */ | ||
49 | { 0, FIXUP_TERMINATOR } | ||
50 | }; | ||
51 | |||
52 | @@ -XXX,XX +XXX,XX @@ static const ARMInsnFixup bootloader[] = { | ||
53 | { 0xe59f2004 }, /* ldr r2, [pc, #4] */ | ||
54 | { 0xe59ff004 }, /* ldr pc, [pc, #4] */ | ||
55 | { 0, FIXUP_BOARDID }, | ||
56 | - { 0, FIXUP_ARGPTR }, | ||
57 | - { 0, FIXUP_ENTRYPOINT }, | ||
58 | + { 0, FIXUP_ARGPTR_LO }, | ||
59 | + { 0, FIXUP_ENTRYPOINT_LO }, | ||
60 | { 0, FIXUP_TERMINATOR } | ||
61 | }; | ||
62 | |||
63 | @@ -XXX,XX +XXX,XX @@ static void write_bootloader(const char *name, hwaddr addr, | ||
64 | break; | ||
65 | case FIXUP_BOARDID: | ||
66 | case FIXUP_BOARD_SETUP: | ||
67 | - case FIXUP_ARGPTR: | ||
68 | - case FIXUP_ENTRYPOINT: | ||
69 | + case FIXUP_ARGPTR_LO: | ||
70 | + case FIXUP_ARGPTR_HI: | ||
71 | + case FIXUP_ENTRYPOINT_LO: | ||
72 | + case FIXUP_ENTRYPOINT_HI: | ||
73 | case FIXUP_GIC_CPU_IF: | ||
74 | case FIXUP_BOOTREG: | ||
75 | case FIXUP_DSB: | ||
76 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | ||
77 | /* Place the DTB after the initrd in memory with alignment. */ | ||
78 | info->dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, | ||
79 | align); | ||
80 | - fixupcontext[FIXUP_ARGPTR] = info->dtb_start; | ||
81 | + fixupcontext[FIXUP_ARGPTR_LO] = info->dtb_start; | ||
82 | + fixupcontext[FIXUP_ARGPTR_HI] = info->dtb_start >> 32; | ||
83 | } else { | ||
84 | - fixupcontext[FIXUP_ARGPTR] = info->loader_start + KERNEL_ARGS_ADDR; | ||
85 | + fixupcontext[FIXUP_ARGPTR_LO] = | ||
86 | + info->loader_start + KERNEL_ARGS_ADDR; | ||
87 | + fixupcontext[FIXUP_ARGPTR_HI] = | ||
88 | + (info->loader_start + KERNEL_ARGS_ADDR) >> 32; | ||
89 | if (info->ram_size >= (1ULL << 32)) { | ||
90 | error_report("RAM size must be less than 4GB to boot" | ||
91 | " Linux kernel using ATAGS (try passing a device tree" | ||
92 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | ||
93 | exit(1); | ||
94 | } | ||
95 | } | 68 | } |
96 | - fixupcontext[FIXUP_ENTRYPOINT] = entry; | 69 | size = len; |
97 | + fixupcontext[FIXUP_ENTRYPOINT_LO] = entry; | 70 | + |
98 | + fixupcontext[FIXUP_ENTRYPOINT_HI] = entry >> 32; | 71 | + /* Unpack the image if it is a EFI zboot image */ |
99 | 72 | + if (unpack_efi_zboot_image(&buffer, &size) < 0) { | |
100 | write_bootloader("bootloader", info->loader_start, | 73 | + g_free(buffer); |
101 | primary_loader, fixupcontext, as); | 74 | + return -1; |
75 | + } | ||
76 | } | ||
77 | |||
78 | /* check the arm64 magic header value -- very old kernels may not have it */ | ||
79 | diff --git a/hw/core/loader.c b/hw/core/loader.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/core/loader.c | ||
82 | +++ b/hw/core/loader.c | ||
83 | @@ -XXX,XX +XXX,XX @@ ssize_t load_image_gzipped(const char *filename, hwaddr addr, uint64_t max_sz) | ||
84 | return bytes; | ||
85 | } | ||
86 | |||
87 | +/* The PE/COFF MS-DOS stub magic number */ | ||
88 | +#define EFI_PE_MSDOS_MAGIC "MZ" | ||
89 | + | ||
90 | +/* | ||
91 | + * The Linux header magic number for a EFI PE/COFF | ||
92 | + * image targetting an unspecified architecture. | ||
93 | + */ | ||
94 | +#define EFI_PE_LINUX_MAGIC "\xcd\x23\x82\x81" | ||
95 | + | ||
96 | +/* | ||
97 | + * Bootable Linux kernel images may be packaged as EFI zboot images, which are | ||
98 | + * self-decompressing executables when loaded via EFI. The compressed payload | ||
99 | + * can also be extracted from the image and decompressed by a non-EFI loader. | ||
100 | + * | ||
101 | + * The de facto specification for this format is at the following URL: | ||
102 | + * | ||
103 | + * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/firmware/efi/libstub/zboot-header.S | ||
104 | + * | ||
105 | + * This definition is based on Linux upstream commit 29636a5ce87beba. | ||
106 | + */ | ||
107 | +struct linux_efi_zboot_header { | ||
108 | + uint8_t msdos_magic[2]; /* PE/COFF 'MZ' magic number */ | ||
109 | + uint8_t reserved0[2]; | ||
110 | + uint8_t zimg[4]; /* "zimg" for Linux EFI zboot images */ | ||
111 | + uint32_t payload_offset; /* LE offset to compressed payload */ | ||
112 | + uint32_t payload_size; /* LE size of the compressed payload */ | ||
113 | + uint8_t reserved1[8]; | ||
114 | + char compression_type[32]; /* Compression type, NUL terminated */ | ||
115 | + uint8_t linux_magic[4]; /* Linux header magic */ | ||
116 | + uint32_t pe_header_offset; /* LE offset to the PE header */ | ||
117 | +}; | ||
118 | + | ||
119 | +/* | ||
120 | + * Check whether *buffer points to a Linux EFI zboot image in memory. | ||
121 | + * | ||
122 | + * If it does, attempt to decompress it to a new buffer, and free the old one. | ||
123 | + * If any of this fails, return an error to the caller. | ||
124 | + * | ||
125 | + * If the image is not a Linux EFI zboot image, do nothing and return success. | ||
126 | + */ | ||
127 | +ssize_t unpack_efi_zboot_image(uint8_t **buffer, int *size) | ||
128 | +{ | ||
129 | + const struct linux_efi_zboot_header *header; | ||
130 | + uint8_t *data = NULL; | ||
131 | + int ploff, plsize; | ||
132 | + ssize_t bytes; | ||
133 | + | ||
134 | + /* ignore if this is too small to be a EFI zboot image */ | ||
135 | + if (*size < sizeof(*header)) { | ||
136 | + return 0; | ||
137 | + } | ||
138 | + | ||
139 | + header = (struct linux_efi_zboot_header *)*buffer; | ||
140 | + | ||
141 | + /* ignore if this is not a Linux EFI zboot image */ | ||
142 | + if (memcmp(&header->msdos_magic, EFI_PE_MSDOS_MAGIC, 2) != 0 || | ||
143 | + memcmp(&header->zimg, "zimg", 4) != 0 || | ||
144 | + memcmp(&header->linux_magic, EFI_PE_LINUX_MAGIC, 4) != 0) { | ||
145 | + return 0; | ||
146 | + } | ||
147 | + | ||
148 | + if (strcmp(header->compression_type, "gzip") != 0) { | ||
149 | + fprintf(stderr, | ||
150 | + "unable to handle EFI zboot image with \"%.*s\" compression\n", | ||
151 | + (int)sizeof(header->compression_type) - 1, | ||
152 | + header->compression_type); | ||
153 | + return -1; | ||
154 | + } | ||
155 | + | ||
156 | + ploff = ldl_le_p(&header->payload_offset); | ||
157 | + plsize = ldl_le_p(&header->payload_size); | ||
158 | + | ||
159 | + if (ploff < 0 || plsize < 0 || ploff + plsize > *size) { | ||
160 | + fprintf(stderr, "unable to handle corrupt EFI zboot image\n"); | ||
161 | + return -1; | ||
162 | + } | ||
163 | + | ||
164 | + data = g_malloc(LOAD_IMAGE_MAX_GUNZIP_BYTES); | ||
165 | + bytes = gunzip(data, LOAD_IMAGE_MAX_GUNZIP_BYTES, *buffer + ploff, plsize); | ||
166 | + if (bytes < 0) { | ||
167 | + fprintf(stderr, "failed to decompress EFI zboot image\n"); | ||
168 | + g_free(data); | ||
169 | + return -1; | ||
170 | + } | ||
171 | + | ||
172 | + g_free(*buffer); | ||
173 | + *buffer = g_realloc(data, bytes); | ||
174 | + *size = bytes; | ||
175 | + return bytes; | ||
176 | +} | ||
177 | + | ||
178 | /* | ||
179 | * Functions for reboot-persistent memory regions. | ||
180 | * - used for vga bios and option roms. | ||
102 | -- | 181 | -- |
103 | 2.19.2 | 182 | 2.34.1 |
104 | 183 | ||
105 | 184 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: qianfan Zhao <qianfanguijin@163.com> |
---|---|---|---|
2 | 2 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | 3 | TWI_CNTR_INT_FLAG is W1C(write 1 to clear and write 0 has non-effect) |
4 | grlib_apbuart_class_init(). | 4 | register on SUN6i based SoCs, we should lower interrupt when the guest |
5 | set this bit. | ||
5 | 6 | ||
6 | Cc: chouteau@adacore.com | 7 | The linux kernel will hang in irq handler(mv64xxx_i2c_intr) if no |
7 | Cc: marcandre.lureau@redhat.com | 8 | device connected on the i2c bus, next is the trace log: |
8 | Cc: pbonzini@redhat.com | ||
9 | 9 | ||
10 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 10 | allwinner_i2c_write write CNTR(0x0c): 0xc4 A_ACK BUS_EN INT_EN |
11 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | 11 | allwinner_i2c_write write CNTR(0x0c): 0xcc A_ACK INT_FLAG BUS_EN INT_EN |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | allwinner_i2c_read read CNTR(0x0c): 0xcc A_ACK INT_FLAG BUS_EN INT_EN |
13 | Message-id: 20181130093852.20739-4-maozhongyi@cmss.chinamobile.com | 13 | allwinner_i2c_read read STAT(0x10): 0x20 STAT_M_ADDR_WR_NACK |
14 | allwinner_i2c_write write CNTR(0x0c): 0x54 A_ACK M_STP BUS_EN | ||
15 | allwinner_i2c_write write CNTR(0x0c): 0x4c A_ACK INT_FLAG BUS_EN | ||
16 | allwinner_i2c_read read CNTR(0x0c): 0x4c A_ACK INT_FLAG BUS_EN | ||
17 | allwinner_i2c_read read STAT(0x10): 0xf8 STAT_IDLE | ||
18 | allwinner_i2c_write write CNTR(0x0c): 0x54 A_ACK M_STP BUS_EN | ||
19 | allwinner_i2c_write write CNTR(0x0c): 0x4c A_ACK INT_FLAG BUS_EN | ||
20 | allwinner_i2c_read read CNTR(0x0c): 0x4c A_ACK INT_FLAG BUS_EN | ||
21 | allwinner_i2c_read read STAT(0x10): 0xf8 STAT_IDLE | ||
22 | ... | ||
23 | |||
24 | Fix it. | ||
25 | |||
26 | Signed-off-by: qianfan Zhao <qianfanguijin@163.com> | ||
27 | Reviewed-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | ||
28 | Tested-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | ||
29 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 31 | --- |
16 | hw/char/grlib_apbuart.c | 12 +++++------- | 32 | include/hw/i2c/allwinner-i2c.h | 6 ++++++ |
17 | 1 file changed, 5 insertions(+), 7 deletions(-) | 33 | hw/i2c/allwinner-i2c.c | 26 ++++++++++++++++++++++++-- |
34 | 2 files changed, 30 insertions(+), 2 deletions(-) | ||
18 | 35 | ||
19 | diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c | 36 | diff --git a/include/hw/i2c/allwinner-i2c.h b/include/hw/i2c/allwinner-i2c.h |
20 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/char/grlib_apbuart.c | 38 | --- a/include/hw/i2c/allwinner-i2c.h |
22 | +++ b/hw/char/grlib_apbuart.c | 39 | +++ b/include/hw/i2c/allwinner-i2c.h |
23 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps grlib_apbuart_ops = { | 40 | @@ -XXX,XX +XXX,XX @@ |
24 | .endianness = DEVICE_NATIVE_ENDIAN, | 41 | #include "qom/object.h" |
42 | |||
43 | #define TYPE_AW_I2C "allwinner.i2c" | ||
44 | + | ||
45 | +/** Allwinner I2C sun6i family and newer (A31, H2+, H3, etc) */ | ||
46 | +#define TYPE_AW_I2C_SUN6I TYPE_AW_I2C "-sun6i" | ||
47 | + | ||
48 | OBJECT_DECLARE_SIMPLE_TYPE(AWI2CState, AW_I2C) | ||
49 | |||
50 | #define AW_I2C_MEM_SIZE 0x24 | ||
51 | @@ -XXX,XX +XXX,XX @@ struct AWI2CState { | ||
52 | uint8_t srst; | ||
53 | uint8_t efr; | ||
54 | uint8_t lcr; | ||
55 | + | ||
56 | + bool irq_clear_inverted; | ||
25 | }; | 57 | }; |
26 | 58 | ||
27 | -static int grlib_apbuart_init(SysBusDevice *dev) | 59 | #endif /* ALLWINNER_I2C_H */ |
28 | +static void grlib_apbuart_realize(DeviceState *dev, Error **errp) | 60 | diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c |
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/i2c/allwinner-i2c.c | ||
63 | +++ b/hw/i2c/allwinner-i2c.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static void allwinner_i2c_write(void *opaque, hwaddr offset, | ||
65 | s->stat = STAT_FROM_STA(STAT_IDLE); | ||
66 | s->cntr &= ~TWI_CNTR_M_STP; | ||
67 | } | ||
68 | - if ((s->cntr & TWI_CNTR_INT_FLAG) == 0) { | ||
69 | - /* Interrupt flag cleared */ | ||
70 | + | ||
71 | + if (!s->irq_clear_inverted && !(s->cntr & TWI_CNTR_INT_FLAG)) { | ||
72 | + /* Write 0 to clear this flag */ | ||
73 | + qemu_irq_lower(s->irq); | ||
74 | + } else if (s->irq_clear_inverted && (s->cntr & TWI_CNTR_INT_FLAG)) { | ||
75 | + /* Write 1 to clear this flag */ | ||
76 | + s->cntr &= ~TWI_CNTR_INT_FLAG; | ||
77 | qemu_irq_lower(s->irq); | ||
78 | } | ||
79 | + | ||
80 | if ((s->cntr & TWI_CNTR_A_ACK) == 0) { | ||
81 | if (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_ACK) { | ||
82 | s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK); | ||
83 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo allwinner_i2c_type_info = { | ||
84 | .class_init = allwinner_i2c_class_init, | ||
85 | }; | ||
86 | |||
87 | +static void allwinner_i2c_sun6i_init(Object *obj) | ||
88 | +{ | ||
89 | + AWI2CState *s = AW_I2C(obj); | ||
90 | + | ||
91 | + s->irq_clear_inverted = true; | ||
92 | +} | ||
93 | + | ||
94 | +static const TypeInfo allwinner_i2c_sun6i_type_info = { | ||
95 | + .name = TYPE_AW_I2C_SUN6I, | ||
96 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
97 | + .instance_size = sizeof(AWI2CState), | ||
98 | + .instance_init = allwinner_i2c_sun6i_init, | ||
99 | + .class_init = allwinner_i2c_class_init, | ||
100 | +}; | ||
101 | + | ||
102 | static void allwinner_i2c_register_types(void) | ||
29 | { | 103 | { |
30 | UART *uart = GRLIB_APB_UART(dev); | 104 | type_register_static(&allwinner_i2c_type_info); |
31 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 105 | + type_register_static(&allwinner_i2c_sun6i_type_info); |
32 | |||
33 | qemu_chr_fe_set_handlers(&uart->chr, | ||
34 | grlib_apbuart_can_receive, | ||
35 | @@ -XXX,XX +XXX,XX @@ static int grlib_apbuart_init(SysBusDevice *dev) | ||
36 | grlib_apbuart_event, | ||
37 | NULL, uart, NULL, true); | ||
38 | |||
39 | - sysbus_init_irq(dev, &uart->irq); | ||
40 | + sysbus_init_irq(sbd, &uart->irq); | ||
41 | |||
42 | memory_region_init_io(&uart->iomem, OBJECT(uart), &grlib_apbuart_ops, uart, | ||
43 | "uart", UART_REG_SIZE); | ||
44 | |||
45 | - sysbus_init_mmio(dev, &uart->iomem); | ||
46 | - | ||
47 | - return 0; | ||
48 | + sysbus_init_mmio(sbd, &uart->iomem); | ||
49 | } | 106 | } |
50 | 107 | ||
51 | static void grlib_apbuart_reset(DeviceState *d) | 108 | type_init(allwinner_i2c_register_types) |
52 | @@ -XXX,XX +XXX,XX @@ static Property grlib_apbuart_properties[] = { | ||
53 | static void grlib_apbuart_class_init(ObjectClass *klass, void *data) | ||
54 | { | ||
55 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
56 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
57 | |||
58 | - k->init = grlib_apbuart_init; | ||
59 | + dc->realize = grlib_apbuart_realize; | ||
60 | dc->reset = grlib_apbuart_reset; | ||
61 | dc->props = grlib_apbuart_properties; | ||
62 | } | ||
63 | -- | 109 | -- |
64 | 2.19.2 | 110 | 2.34.1 |
65 | |||
66 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: qianfan Zhao <qianfanguijin@163.com> |
---|---|---|---|
2 | 2 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | 3 | Allwinner h3 has 4 twi(i2c) devices named twi0, twi1, twi2 and r_twi. |
4 | onenand_class_init(). | 4 | The registers are compatible with TYPE_AW_I2C_SUN6I, write 1 to clear |
5 | control register's INT_FLAG bit. | ||
5 | 6 | ||
6 | Cc: kwolf@redhat.com | 7 | Signed-off-by: qianfan Zhao <qianfanguijin@163.com> |
7 | Cc: mreitz@redhat.com | 8 | Reviewed-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
8 | Cc: qemu-block@nongnu.org | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | |||
10 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
11 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Message-id: 20181130093852.20739-3-maozhongyi@cmss.chinamobile.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 11 | --- |
16 | hw/block/onenand.c | 16 +++++++--------- | 12 | include/hw/arm/allwinner-h3.h | 6 ++++++ |
17 | 1 file changed, 7 insertions(+), 9 deletions(-) | 13 | hw/arm/allwinner-h3.c | 29 +++++++++++++++++++++++++---- |
14 | 2 files changed, 31 insertions(+), 4 deletions(-) | ||
18 | 15 | ||
19 | diff --git a/hw/block/onenand.c b/hw/block/onenand.c | 16 | diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/block/onenand.c | 18 | --- a/include/hw/arm/allwinner-h3.h |
22 | +++ b/hw/block/onenand.c | 19 | +++ b/include/hw/arm/allwinner-h3.h |
23 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps onenand_ops = { | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
24 | .endianness = DEVICE_NATIVE_ENDIAN, | 21 | AW_H3_DEV_UART3, |
22 | AW_H3_DEV_EMAC, | ||
23 | AW_H3_DEV_TWI0, | ||
24 | + AW_H3_DEV_TWI1, | ||
25 | + AW_H3_DEV_TWI2, | ||
26 | AW_H3_DEV_DRAMCOM, | ||
27 | AW_H3_DEV_DRAMCTL, | ||
28 | AW_H3_DEV_DRAMPHY, | ||
29 | @@ -XXX,XX +XXX,XX @@ enum { | ||
30 | AW_H3_DEV_GIC_VCPU, | ||
31 | AW_H3_DEV_RTC, | ||
32 | AW_H3_DEV_CPUCFG, | ||
33 | + AW_H3_DEV_R_TWI, | ||
34 | AW_H3_DEV_SDRAM | ||
25 | }; | 35 | }; |
26 | 36 | ||
27 | -static int onenand_initfn(SysBusDevice *sbd) | 37 | @@ -XXX,XX +XXX,XX @@ struct AwH3State { |
28 | +static void onenand_realize(DeviceState *dev, Error **errp) | 38 | AwSidState sid; |
29 | { | 39 | AwSdHostState mmc0; |
30 | - DeviceState *dev = DEVICE(sbd); | 40 | AWI2CState i2c0; |
31 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 41 | + AWI2CState i2c1; |
32 | OneNANDState *s = ONE_NAND(dev); | 42 | + AWI2CState i2c2; |
33 | uint32_t size = 1 << (24 + ((s->id.dev >> 4) & 7)); | 43 | + AWI2CState r_twi; |
34 | void *ram; | 44 | AwSun8iEmacState emac; |
35 | @@ -XXX,XX +XXX,XX @@ static int onenand_initfn(SysBusDevice *sbd) | 45 | AwRtcState rtc; |
36 | 0xff, size + (size >> 5)); | 46 | GICState gic; |
37 | } else { | 47 | diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c |
38 | if (blk_is_read_only(s->blk)) { | 48 | index XXXXXXX..XXXXXXX 100644 |
39 | - error_report("Can't use a read-only drive"); | 49 | --- a/hw/arm/allwinner-h3.c |
40 | - return -1; | 50 | +++ b/hw/arm/allwinner-h3.c |
41 | + error_setg(errp, "Can't use a read-only drive"); | 51 | @@ -XXX,XX +XXX,XX @@ const hwaddr allwinner_h3_memmap[] = { |
42 | + return; | 52 | [AW_H3_DEV_UART2] = 0x01c28800, |
43 | } | 53 | [AW_H3_DEV_UART3] = 0x01c28c00, |
44 | blk_set_perm(s->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE, | 54 | [AW_H3_DEV_TWI0] = 0x01c2ac00, |
45 | BLK_PERM_ALL, &local_err); | 55 | + [AW_H3_DEV_TWI1] = 0x01c2b000, |
46 | if (local_err) { | 56 | + [AW_H3_DEV_TWI2] = 0x01c2b400, |
47 | - error_report_err(local_err); | 57 | [AW_H3_DEV_EMAC] = 0x01c30000, |
48 | - return -1; | 58 | [AW_H3_DEV_DRAMCOM] = 0x01c62000, |
49 | + error_propagate(errp, local_err); | 59 | [AW_H3_DEV_DRAMCTL] = 0x01c63000, |
50 | + return; | 60 | @@ -XXX,XX +XXX,XX @@ const hwaddr allwinner_h3_memmap[] = { |
51 | } | 61 | [AW_H3_DEV_GIC_VCPU] = 0x01c86000, |
52 | s->blk_cur = s->blk; | 62 | [AW_H3_DEV_RTC] = 0x01f00000, |
53 | } | 63 | [AW_H3_DEV_CPUCFG] = 0x01f01c00, |
54 | @@ -XXX,XX +XXX,XX @@ static int onenand_initfn(SysBusDevice *sbd) | 64 | + [AW_H3_DEV_R_TWI] = 0x01f02400, |
55 | | ((s->id.dev & 0xff) << 8) | 65 | [AW_H3_DEV_SDRAM] = 0x40000000 |
56 | | (s->id.ver & 0xff), | 66 | }; |
57 | &vmstate_onenand, s); | 67 | |
58 | - return 0; | 68 | @@ -XXX,XX +XXX,XX @@ struct AwH3Unimplemented { |
69 | { "uart1", 0x01c28400, 1 * KiB }, | ||
70 | { "uart2", 0x01c28800, 1 * KiB }, | ||
71 | { "uart3", 0x01c28c00, 1 * KiB }, | ||
72 | - { "twi1", 0x01c2b000, 1 * KiB }, | ||
73 | - { "twi2", 0x01c2b400, 1 * KiB }, | ||
74 | { "scr", 0x01c2c400, 1 * KiB }, | ||
75 | { "gpu", 0x01c40000, 64 * KiB }, | ||
76 | { "hstmr", 0x01c60000, 4 * KiB }, | ||
77 | @@ -XXX,XX +XXX,XX @@ struct AwH3Unimplemented { | ||
78 | { "r_prcm", 0x01f01400, 1 * KiB }, | ||
79 | { "r_twd", 0x01f01800, 1 * KiB }, | ||
80 | { "r_cir-rx", 0x01f02000, 1 * KiB }, | ||
81 | - { "r_twi", 0x01f02400, 1 * KiB }, | ||
82 | { "r_uart", 0x01f02800, 1 * KiB }, | ||
83 | { "r_pio", 0x01f02c00, 1 * KiB }, | ||
84 | { "r_pwm", 0x01f03800, 1 * KiB }, | ||
85 | @@ -XXX,XX +XXX,XX @@ enum { | ||
86 | AW_H3_GIC_SPI_UART2 = 2, | ||
87 | AW_H3_GIC_SPI_UART3 = 3, | ||
88 | AW_H3_GIC_SPI_TWI0 = 6, | ||
89 | + AW_H3_GIC_SPI_TWI1 = 7, | ||
90 | + AW_H3_GIC_SPI_TWI2 = 8, | ||
91 | AW_H3_GIC_SPI_TIMER0 = 18, | ||
92 | AW_H3_GIC_SPI_TIMER1 = 19, | ||
93 | + AW_H3_GIC_SPI_R_TWI = 44, | ||
94 | AW_H3_GIC_SPI_MMC0 = 60, | ||
95 | AW_H3_GIC_SPI_EHCI0 = 72, | ||
96 | AW_H3_GIC_SPI_OHCI0 = 73, | ||
97 | @@ -XXX,XX +XXX,XX @@ static void allwinner_h3_init(Object *obj) | ||
98 | |||
99 | object_initialize_child(obj, "rtc", &s->rtc, TYPE_AW_RTC_SUN6I); | ||
100 | |||
101 | - object_initialize_child(obj, "twi0", &s->i2c0, TYPE_AW_I2C); | ||
102 | + object_initialize_child(obj, "twi0", &s->i2c0, TYPE_AW_I2C_SUN6I); | ||
103 | + object_initialize_child(obj, "twi1", &s->i2c1, TYPE_AW_I2C_SUN6I); | ||
104 | + object_initialize_child(obj, "twi2", &s->i2c2, TYPE_AW_I2C_SUN6I); | ||
105 | + object_initialize_child(obj, "r_twi", &s->r_twi, TYPE_AW_I2C_SUN6I); | ||
59 | } | 106 | } |
60 | 107 | ||
61 | static Property onenand_properties[] = { | 108 | static void allwinner_h3_realize(DeviceState *dev, Error **errp) |
62 | @@ -XXX,XX +XXX,XX @@ static Property onenand_properties[] = { | 109 | @@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) |
63 | static void onenand_class_init(ObjectClass *klass, void *data) | 110 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0, |
64 | { | 111 | qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI0)); |
65 | DeviceClass *dc = DEVICE_CLASS(klass); | 112 | |
66 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | 113 | + sysbus_realize(SYS_BUS_DEVICE(&s->i2c1), &error_fatal); |
67 | 114 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c1), 0, s->memmap[AW_H3_DEV_TWI1]); | |
68 | - k->init = onenand_initfn; | 115 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c1), 0, |
69 | + dc->realize = onenand_realize; | 116 | + qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI1)); |
70 | dc->reset = onenand_system_reset; | 117 | + |
71 | dc->props = onenand_properties; | 118 | + sysbus_realize(SYS_BUS_DEVICE(&s->i2c2), &error_fatal); |
72 | } | 119 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c2), 0, s->memmap[AW_H3_DEV_TWI2]); |
120 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c2), 0, | ||
121 | + qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI2)); | ||
122 | + | ||
123 | + sysbus_realize(SYS_BUS_DEVICE(&s->r_twi), &error_fatal); | ||
124 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->r_twi), 0, s->memmap[AW_H3_DEV_R_TWI]); | ||
125 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->r_twi), 0, | ||
126 | + qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_R_TWI)); | ||
127 | + | ||
128 | /* Unimplemented devices */ | ||
129 | for (i = 0; i < ARRAY_SIZE(unimplemented); i++) { | ||
130 | create_unimplemented_device(unimplemented[i].device_name, | ||
73 | -- | 131 | -- |
74 | 2.19.2 | 132 | 2.34.1 |
75 | |||
76 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | empty_slot_class_init(). | ||
5 | |||
6 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
7 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20181130093852.20739-5-maozhongyi@cmss.chinamobile.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/core/empty_slot.c | 9 ++++----- | ||
14 | 1 file changed, 4 insertions(+), 5 deletions(-) | ||
15 | |||
16 | diff --git a/hw/core/empty_slot.c b/hw/core/empty_slot.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/core/empty_slot.c | ||
19 | +++ b/hw/core/empty_slot.c | ||
20 | @@ -XXX,XX +XXX,XX @@ void empty_slot_init(hwaddr addr, uint64_t slot_size) | ||
21 | } | ||
22 | } | ||
23 | |||
24 | -static int empty_slot_init1(SysBusDevice *dev) | ||
25 | +static void empty_slot_realize(DeviceState *dev, Error **errp) | ||
26 | { | ||
27 | EmptySlot *s = EMPTY_SLOT(dev); | ||
28 | |||
29 | memory_region_init_io(&s->iomem, OBJECT(s), &empty_slot_ops, s, | ||
30 | "empty-slot", s->size); | ||
31 | - sysbus_init_mmio(dev, &s->iomem); | ||
32 | - return 0; | ||
33 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
34 | } | ||
35 | |||
36 | static void empty_slot_class_init(ObjectClass *klass, void *data) | ||
37 | { | ||
38 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
39 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
40 | |||
41 | - k->init = empty_slot_init1; | ||
42 | + dc->realize = empty_slot_realize; | ||
43 | } | ||
44 | |||
45 | static const TypeInfo empty_slot_info = { | ||
46 | -- | ||
47 | 2.19.2 | ||
48 | |||
49 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | g364fb_sysbus_class_init(). | ||
5 | |||
6 | Cc: pbonzini@redhat.com | ||
7 | Cc: kraxel@redhat.com | ||
8 | Cc: f4bug@amsat.org | ||
9 | Cc: alistair.francis@wdc.com | ||
10 | |||
11 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
12 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Message-id: 20181130093852.20739-6-maozhongyi@cmss.chinamobile.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/display/g364fb.c | 9 +++------ | ||
19 | 1 file changed, 3 insertions(+), 6 deletions(-) | ||
20 | |||
21 | diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/display/g364fb.c | ||
24 | +++ b/hw/display/g364fb.c | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
26 | G364State g364; | ||
27 | } G364SysBusState; | ||
28 | |||
29 | -static int g364fb_sysbus_init(SysBusDevice *sbd) | ||
30 | +static void g364fb_sysbus_realize(DeviceState *dev, Error **errp) | ||
31 | { | ||
32 | - DeviceState *dev = DEVICE(sbd); | ||
33 | G364SysBusState *sbs = G364(dev); | ||
34 | G364State *s = &sbs->g364; | ||
35 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
36 | |||
37 | g364fb_init(dev, s); | ||
38 | sysbus_init_irq(sbd, &s->irq); | ||
39 | sysbus_init_mmio(sbd, &s->mem_ctrl); | ||
40 | sysbus_init_mmio(sbd, &s->mem_vram); | ||
41 | - | ||
42 | - return 0; | ||
43 | } | ||
44 | |||
45 | static void g364fb_sysbus_reset(DeviceState *d) | ||
46 | @@ -XXX,XX +XXX,XX @@ static Property g364fb_sysbus_properties[] = { | ||
47 | static void g364fb_sysbus_class_init(ObjectClass *klass, void *data) | ||
48 | { | ||
49 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
50 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
51 | |||
52 | - k->init = g364fb_sysbus_init; | ||
53 | + dc->realize = g364fb_sysbus_realize; | ||
54 | set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); | ||
55 | dc->desc = "G364 framebuffer"; | ||
56 | dc->reset = g364fb_sysbus_reset; | ||
57 | -- | ||
58 | 2.19.2 | ||
59 | |||
60 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | puv3_dma_class_init(). | ||
5 | |||
6 | Cc: gxt@mprc.pku.edu.cn | ||
7 | |||
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20181130093852.20739-7-maozhongyi@cmss.chinamobile.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/dma/puv3_dma.c | 10 ++++------ | ||
16 | 1 file changed, 4 insertions(+), 6 deletions(-) | ||
17 | |||
18 | diff --git a/hw/dma/puv3_dma.c b/hw/dma/puv3_dma.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/dma/puv3_dma.c | ||
21 | +++ b/hw/dma/puv3_dma.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps puv3_dma_ops = { | ||
23 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
24 | }; | ||
25 | |||
26 | -static int puv3_dma_init(SysBusDevice *dev) | ||
27 | +static void puv3_dma_realize(DeviceState *dev, Error **errp) | ||
28 | { | ||
29 | PUV3DMAState *s = PUV3_DMA(dev); | ||
30 | int i; | ||
31 | @@ -XXX,XX +XXX,XX @@ static int puv3_dma_init(SysBusDevice *dev) | ||
32 | |||
33 | memory_region_init_io(&s->iomem, OBJECT(s), &puv3_dma_ops, s, "puv3_dma", | ||
34 | PUV3_REGS_OFFSET); | ||
35 | - sysbus_init_mmio(dev, &s->iomem); | ||
36 | - | ||
37 | - return 0; | ||
38 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
39 | } | ||
40 | |||
41 | static void puv3_dma_class_init(ObjectClass *klass, void *data) | ||
42 | { | ||
43 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | ||
44 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
45 | |||
46 | - sdc->init = puv3_dma_init; | ||
47 | + dc->realize = puv3_dma_realize; | ||
48 | } | ||
49 | |||
50 | static const TypeInfo puv3_dma_info = { | ||
51 | -- | ||
52 | 2.19.2 | ||
53 | |||
54 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | puv3_gpio_class_init(). | ||
5 | |||
6 | Cc: gxt@mprc.pku.edu.cn | ||
7 | Cc: peter.maydell@linaro.org | ||
8 | |||
9 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
10 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20181130093852.20739-8-maozhongyi@cmss.chinamobile.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/gpio/puv3_gpio.c | 29 ++++++++++++++--------------- | ||
16 | 1 file changed, 14 insertions(+), 15 deletions(-) | ||
17 | |||
18 | diff --git a/hw/gpio/puv3_gpio.c b/hw/gpio/puv3_gpio.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/gpio/puv3_gpio.c | ||
21 | +++ b/hw/gpio/puv3_gpio.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps puv3_gpio_ops = { | ||
23 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
24 | }; | ||
25 | |||
26 | -static int puv3_gpio_init(SysBusDevice *dev) | ||
27 | +static void puv3_gpio_realize(DeviceState *dev, Error **errp) | ||
28 | { | ||
29 | PUV3GPIOState *s = PUV3_GPIO(dev); | ||
30 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
31 | |||
32 | s->reg_GPLR = 0; | ||
33 | s->reg_GPDR = 0; | ||
34 | |||
35 | /* FIXME: these irqs not handled yet */ | ||
36 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW0]); | ||
37 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW1]); | ||
38 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW2]); | ||
39 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW3]); | ||
40 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW4]); | ||
41 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW5]); | ||
42 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW6]); | ||
43 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW7]); | ||
44 | - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOHIGH]); | ||
45 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOLOW0]); | ||
46 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOLOW1]); | ||
47 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOLOW2]); | ||
48 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOLOW3]); | ||
49 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOLOW4]); | ||
50 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOLOW5]); | ||
51 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOLOW6]); | ||
52 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOLOW7]); | ||
53 | + sysbus_init_irq(sbd, &s->irq[PUV3_IRQS_GPIOHIGH]); | ||
54 | |||
55 | memory_region_init_io(&s->iomem, OBJECT(s), &puv3_gpio_ops, s, "puv3_gpio", | ||
56 | PUV3_REGS_OFFSET); | ||
57 | - sysbus_init_mmio(dev, &s->iomem); | ||
58 | - | ||
59 | - return 0; | ||
60 | + sysbus_init_mmio(sbd, &s->iomem); | ||
61 | } | ||
62 | |||
63 | static void puv3_gpio_class_init(ObjectClass *klass, void *data) | ||
64 | { | ||
65 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | ||
66 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
67 | |||
68 | - sdc->init = puv3_gpio_init; | ||
69 | + dc->realize = puv3_gpio_realize; | ||
70 | } | ||
71 | |||
72 | static const TypeInfo puv3_gpio_info = { | ||
73 | -- | ||
74 | 2.19.2 | ||
75 | |||
76 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | milkymist_softusb_class_init(). | ||
5 | |||
6 | Cc: michael@walle.cc | ||
7 | |||
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20181130093852.20739-9-maozhongyi@cmss.chinamobile.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/input/milkymist-softusb.c | 16 +++++++--------- | ||
15 | 1 file changed, 7 insertions(+), 9 deletions(-) | ||
16 | |||
17 | diff --git a/hw/input/milkymist-softusb.c b/hw/input/milkymist-softusb.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/input/milkymist-softusb.c | ||
20 | +++ b/hw/input/milkymist-softusb.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void milkymist_softusb_reset(DeviceState *d) | ||
22 | s->regs[R_CTRL] = CTRL_RESET; | ||
23 | } | ||
24 | |||
25 | -static int milkymist_softusb_init(SysBusDevice *dev) | ||
26 | +static void milkymist_softusb_realize(DeviceState *dev, Error **errp) | ||
27 | { | ||
28 | MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(dev); | ||
29 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
30 | |||
31 | - sysbus_init_irq(dev, &s->irq); | ||
32 | + sysbus_init_irq(sbd, &s->irq); | ||
33 | |||
34 | memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s, | ||
35 | "milkymist-softusb", R_MAX * 4); | ||
36 | - sysbus_init_mmio(dev, &s->regs_region); | ||
37 | + sysbus_init_mmio(sbd, &s->regs_region); | ||
38 | |||
39 | /* register pmem and dmem */ | ||
40 | memory_region_init_ram_nomigrate(&s->pmem, OBJECT(s), "milkymist-softusb.pmem", | ||
41 | s->pmem_size, &error_fatal); | ||
42 | vmstate_register_ram_global(&s->pmem); | ||
43 | s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem); | ||
44 | - sysbus_init_mmio(dev, &s->pmem); | ||
45 | + sysbus_init_mmio(sbd, &s->pmem); | ||
46 | memory_region_init_ram_nomigrate(&s->dmem, OBJECT(s), "milkymist-softusb.dmem", | ||
47 | s->dmem_size, &error_fatal); | ||
48 | vmstate_register_ram_global(&s->dmem); | ||
49 | s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem); | ||
50 | - sysbus_init_mmio(dev, &s->dmem); | ||
51 | + sysbus_init_mmio(sbd, &s->dmem); | ||
52 | |||
53 | hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain); | ||
54 | hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain); | ||
55 | - | ||
56 | - return 0; | ||
57 | } | ||
58 | |||
59 | static const VMStateDescription vmstate_milkymist_softusb = { | ||
60 | @@ -XXX,XX +XXX,XX @@ static Property milkymist_softusb_properties[] = { | ||
61 | static void milkymist_softusb_class_init(ObjectClass *klass, void *data) | ||
62 | { | ||
63 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
64 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
65 | |||
66 | - k->init = milkymist_softusb_init; | ||
67 | + dc->realize = milkymist_softusb_realize; | ||
68 | dc->reset = milkymist_softusb_reset; | ||
69 | dc->vmsd = &vmstate_milkymist_softusb; | ||
70 | dc->props = milkymist_softusb_properties; | ||
71 | -- | ||
72 | 2.19.2 | ||
73 | |||
74 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | pl050_class_init(). | ||
5 | |||
6 | Cc: peter.maydell@linaro.org | ||
7 | Cc: qemu-arm@nongnu.org | ||
8 | |||
9 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
10 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20181130093852.20739-10-maozhongyi@cmss.chinamobile.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/input/pl050.c | 11 +++++------ | ||
16 | 1 file changed, 5 insertions(+), 6 deletions(-) | ||
17 | |||
18 | diff --git a/hw/input/pl050.c b/hw/input/pl050.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/input/pl050.c | ||
21 | +++ b/hw/input/pl050.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps pl050_ops = { | ||
23 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
24 | }; | ||
25 | |||
26 | -static int pl050_initfn(SysBusDevice *dev) | ||
27 | +static void pl050_realize(DeviceState *dev, Error **errp) | ||
28 | { | ||
29 | PL050State *s = PL050(dev); | ||
30 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
31 | |||
32 | memory_region_init_io(&s->iomem, OBJECT(s), &pl050_ops, s, "pl050", 0x1000); | ||
33 | - sysbus_init_mmio(dev, &s->iomem); | ||
34 | - sysbus_init_irq(dev, &s->irq); | ||
35 | + sysbus_init_mmio(sbd, &s->iomem); | ||
36 | + sysbus_init_irq(sbd, &s->irq); | ||
37 | if (s->is_mouse) { | ||
38 | s->dev = ps2_mouse_init(pl050_update, s); | ||
39 | } else { | ||
40 | s->dev = ps2_kbd_init(pl050_update, s); | ||
41 | } | ||
42 | - return 0; | ||
43 | } | ||
44 | |||
45 | static void pl050_keyboard_init(Object *obj) | ||
46 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo pl050_mouse_info = { | ||
47 | static void pl050_class_init(ObjectClass *oc, void *data) | ||
48 | { | ||
49 | DeviceClass *dc = DEVICE_CLASS(oc); | ||
50 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc); | ||
51 | |||
52 | - sdc->init = pl050_initfn; | ||
53 | + dc->realize = pl050_realize; | ||
54 | dc->vmsd = &vmstate_pl050; | ||
55 | } | ||
56 | |||
57 | -- | ||
58 | 2.19.2 | ||
59 | |||
60 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | puv3_intc_class_init(). | ||
5 | |||
6 | Cc: gxt@mprc.pku.edu.cn | ||
7 | |||
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20181130093852.20739-11-maozhongyi@cmss.chinamobile.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/intc/puv3_intc.c | 11 ++++------- | ||
15 | 1 file changed, 4 insertions(+), 7 deletions(-) | ||
16 | |||
17 | diff --git a/hw/intc/puv3_intc.c b/hw/intc/puv3_intc.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/intc/puv3_intc.c | ||
20 | +++ b/hw/intc/puv3_intc.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps puv3_intc_ops = { | ||
22 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
23 | }; | ||
24 | |||
25 | -static int puv3_intc_init(SysBusDevice *sbd) | ||
26 | +static void puv3_intc_realize(DeviceState *dev, Error **errp) | ||
27 | { | ||
28 | - DeviceState *dev = DEVICE(sbd); | ||
29 | PUV3INTCState *s = PUV3_INTC(dev); | ||
30 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
31 | |||
32 | qdev_init_gpio_in(dev, puv3_intc_handler, PUV3_IRQS_NR); | ||
33 | sysbus_init_irq(sbd, &s->parent_irq); | ||
34 | @@ -XXX,XX +XXX,XX @@ static int puv3_intc_init(SysBusDevice *sbd) | ||
35 | memory_region_init_io(&s->iomem, OBJECT(s), &puv3_intc_ops, s, "puv3_intc", | ||
36 | PUV3_REGS_OFFSET); | ||
37 | sysbus_init_mmio(sbd, &s->iomem); | ||
38 | - | ||
39 | - return 0; | ||
40 | } | ||
41 | |||
42 | static void puv3_intc_class_init(ObjectClass *klass, void *data) | ||
43 | { | ||
44 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | ||
45 | - | ||
46 | - sdc->init = puv3_intc_init; | ||
47 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
48 | + dc->realize = puv3_intc_realize; | ||
49 | } | ||
50 | |||
51 | static const TypeInfo puv3_intc_info = { | ||
52 | -- | ||
53 | 2.19.2 | ||
54 | |||
55 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | milkymist_pfpu_class_init(). | ||
5 | |||
6 | Cc: michael@walle.cc | ||
7 | |||
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20181130093852.20739-13-maozhongyi@cmss.chinamobile.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/misc/milkymist-pfpu.c | 12 +++++------- | ||
15 | 1 file changed, 5 insertions(+), 7 deletions(-) | ||
16 | |||
17 | diff --git a/hw/misc/milkymist-pfpu.c b/hw/misc/milkymist-pfpu.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/misc/milkymist-pfpu.c | ||
20 | +++ b/hw/misc/milkymist-pfpu.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void milkymist_pfpu_reset(DeviceState *d) | ||
22 | } | ||
23 | } | ||
24 | |||
25 | -static int milkymist_pfpu_init(SysBusDevice *dev) | ||
26 | +static void milkymist_pfpu_realize(DeviceState *dev, Error **errp) | ||
27 | { | ||
28 | MilkymistPFPUState *s = MILKYMIST_PFPU(dev); | ||
29 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
30 | |||
31 | - sysbus_init_irq(dev, &s->irq); | ||
32 | + sysbus_init_irq(sbd, &s->irq); | ||
33 | |||
34 | memory_region_init_io(&s->regs_region, OBJECT(dev), &pfpu_mmio_ops, s, | ||
35 | "milkymist-pfpu", MICROCODE_END * 4); | ||
36 | - sysbus_init_mmio(dev, &s->regs_region); | ||
37 | - | ||
38 | - return 0; | ||
39 | + sysbus_init_mmio(sbd, &s->regs_region); | ||
40 | } | ||
41 | |||
42 | static const VMStateDescription vmstate_milkymist_pfpu = { | ||
43 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_milkymist_pfpu = { | ||
44 | static void milkymist_pfpu_class_init(ObjectClass *klass, void *data) | ||
45 | { | ||
46 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
47 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
48 | |||
49 | - k->init = milkymist_pfpu_init; | ||
50 | + dc->realize = milkymist_pfpu_realize; | ||
51 | dc->reset = milkymist_pfpu_reset; | ||
52 | dc->vmsd = &vmstate_milkymist_pfpu; | ||
53 | } | ||
54 | -- | ||
55 | 2.19.2 | ||
56 | |||
57 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | puv3_pm_class_init(). | ||
5 | |||
6 | Cc: gxt@mprc.pku.edu.cn | ||
7 | |||
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20181130093852.20739-14-maozhongyi@cmss.chinamobile.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/misc/puv3_pm.c | 10 ++++------ | ||
16 | 1 file changed, 4 insertions(+), 6 deletions(-) | ||
17 | |||
18 | diff --git a/hw/misc/puv3_pm.c b/hw/misc/puv3_pm.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/misc/puv3_pm.c | ||
21 | +++ b/hw/misc/puv3_pm.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps puv3_pm_ops = { | ||
23 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
24 | }; | ||
25 | |||
26 | -static int puv3_pm_init(SysBusDevice *dev) | ||
27 | +static void puv3_pm_realize(DeviceState *dev, Error **errp) | ||
28 | { | ||
29 | PUV3PMState *s = PUV3_PM(dev); | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ static int puv3_pm_init(SysBusDevice *dev) | ||
32 | |||
33 | memory_region_init_io(&s->iomem, OBJECT(s), &puv3_pm_ops, s, "puv3_pm", | ||
34 | PUV3_REGS_OFFSET); | ||
35 | - sysbus_init_mmio(dev, &s->iomem); | ||
36 | - | ||
37 | - return 0; | ||
38 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
39 | } | ||
40 | |||
41 | static void puv3_pm_class_init(ObjectClass *klass, void *data) | ||
42 | { | ||
43 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | ||
44 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
45 | |||
46 | - sdc->init = puv3_pm_init; | ||
47 | + dc->realize = puv3_pm_realize; | ||
48 | } | ||
49 | |||
50 | static const TypeInfo puv3_pm_info = { | ||
51 | -- | ||
52 | 2.19.2 | ||
53 | |||
54 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | nvram_sysbus_class_init(). | ||
5 | |||
6 | Cc: pbonzini@redhat.com | ||
7 | Cc: marcandre.lureau@redhat.com | ||
8 | |||
9 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
10 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20181130093852.20739-15-maozhongyi@cmss.chinamobile.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/nvram/ds1225y.c | 12 +++++------- | ||
16 | 1 file changed, 5 insertions(+), 7 deletions(-) | ||
17 | |||
18 | diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/nvram/ds1225y.c | ||
21 | +++ b/hw/nvram/ds1225y.c | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #include "qemu/osdep.h" | ||
24 | #include "hw/sysbus.h" | ||
25 | #include "trace.h" | ||
26 | +#include "qemu/error-report.h" | ||
27 | |||
28 | typedef struct { | ||
29 | MemoryRegion iomem; | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
31 | NvRamState nvram; | ||
32 | } SysBusNvRamState; | ||
33 | |||
34 | -static int nvram_sysbus_initfn(SysBusDevice *dev) | ||
35 | +static void nvram_sysbus_realize(DeviceState *dev, Error **errp) | ||
36 | { | ||
37 | SysBusNvRamState *sys = DS1225Y(dev); | ||
38 | NvRamState *s = &sys->nvram; | ||
39 | @@ -XXX,XX +XXX,XX @@ static int nvram_sysbus_initfn(SysBusDevice *dev) | ||
40 | |||
41 | memory_region_init_io(&s->iomem, OBJECT(s), &nvram_ops, s, | ||
42 | "nvram", s->chip_size); | ||
43 | - sysbus_init_mmio(dev, &s->iomem); | ||
44 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
45 | |||
46 | /* Read current file */ | ||
47 | file = s->filename ? fopen(s->filename, "rb") : NULL; | ||
48 | if (file) { | ||
49 | /* Read nvram contents */ | ||
50 | if (fread(s->contents, s->chip_size, 1, file) != 1) { | ||
51 | - printf("nvram_sysbus_initfn: short read\n"); | ||
52 | + error_report("nvram_sysbus_realize: short read"); | ||
53 | } | ||
54 | fclose(file); | ||
55 | } | ||
56 | nvram_post_load(s, 0); | ||
57 | - | ||
58 | - return 0; | ||
59 | } | ||
60 | |||
61 | static Property nvram_sysbus_properties[] = { | ||
62 | @@ -XXX,XX +XXX,XX @@ static Property nvram_sysbus_properties[] = { | ||
63 | static void nvram_sysbus_class_init(ObjectClass *klass, void *data) | ||
64 | { | ||
65 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
66 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
67 | |||
68 | - k->init = nvram_sysbus_initfn; | ||
69 | + dc->realize = nvram_sysbus_realize; | ||
70 | dc->vmsd = &vmstate_nvram; | ||
71 | dc->props = nvram_sysbus_properties; | ||
72 | } | ||
73 | -- | ||
74 | 2.19.2 | ||
75 | |||
76 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | pci_dec_21154_device_class_init(). | ||
5 | |||
6 | Cc: david@gibson.dropbear.id.au | ||
7 | Cc: mst@redhat.com | ||
8 | Cc: marcel.apfelbaum@gmail.com | ||
9 | Cc: qemu-ppc@nongnu.org | ||
10 | |||
11 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
12 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
13 | Reviewed-by: David Gibson <david@gibson.dropbear.id.au> | ||
14 | Acked-by: David Gibson <david@gibson.dropbear.id.au> | ||
15 | Message-id: 20181130093852.20739-16-maozhongyi@cmss.chinamobile.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/pci-bridge/dec.c | 12 ++++++------ | ||
19 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
20 | |||
21 | diff --git a/hw/pci-bridge/dec.c b/hw/pci-bridge/dec.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/pci-bridge/dec.c | ||
24 | +++ b/hw/pci-bridge/dec.c | ||
25 | @@ -XXX,XX +XXX,XX @@ PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn) | ||
26 | return pci_bridge_get_sec_bus(br); | ||
27 | } | ||
28 | |||
29 | -static int pci_dec_21154_device_init(SysBusDevice *dev) | ||
30 | +static void pci_dec_21154_device_realize(DeviceState *dev, Error **errp) | ||
31 | { | ||
32 | PCIHostState *phb; | ||
33 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
34 | |||
35 | phb = PCI_HOST_BRIDGE(dev); | ||
36 | |||
37 | @@ -XXX,XX +XXX,XX @@ static int pci_dec_21154_device_init(SysBusDevice *dev) | ||
38 | dev, "pci-conf-idx", 0x1000); | ||
39 | memory_region_init_io(&phb->data_mem, OBJECT(dev), &pci_host_data_le_ops, | ||
40 | dev, "pci-data-idx", 0x1000); | ||
41 | - sysbus_init_mmio(dev, &phb->conf_mem); | ||
42 | - sysbus_init_mmio(dev, &phb->data_mem); | ||
43 | - return 0; | ||
44 | + sysbus_init_mmio(sbd, &phb->conf_mem); | ||
45 | + sysbus_init_mmio(sbd, &phb->data_mem); | ||
46 | } | ||
47 | |||
48 | static void dec_21154_pci_host_realize(PCIDevice *d, Error **errp) | ||
49 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo dec_21154_pci_host_info = { | ||
50 | |||
51 | static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data) | ||
52 | { | ||
53 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | ||
54 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
55 | |||
56 | - sdc->init = pci_dec_21154_device_init; | ||
57 | + dc->realize = pci_dec_21154_device_realize; | ||
58 | } | ||
59 | |||
60 | static const TypeInfo pci_dec_21154_device_info = { | ||
61 | -- | ||
62 | 2.19.2 | ||
63 | |||
64 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | Use DeviceClass rather than SysBusDeviceClass in | ||
4 | etraxfs_timer_class_init(). | ||
5 | |||
6 | Cc: edgar.iglesias@gmail.com | ||
7 | |||
8 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
9 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
12 | Message-id: 20181130093852.20739-17-maozhongyi@cmss.chinamobile.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/timer/etraxfs_timer.c | 14 +++++++------- | ||
16 | 1 file changed, 7 insertions(+), 7 deletions(-) | ||
17 | |||
18 | diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/timer/etraxfs_timer.c | ||
21 | +++ b/hw/timer/etraxfs_timer.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void etraxfs_timer_reset(void *opaque) | ||
23 | qemu_irq_lower(t->irq); | ||
24 | } | ||
25 | |||
26 | -static int etraxfs_timer_init(SysBusDevice *dev) | ||
27 | +static void etraxfs_timer_realize(DeviceState *dev, Error **errp) | ||
28 | { | ||
29 | ETRAXTimerState *t = ETRAX_TIMER(dev); | ||
30 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
31 | |||
32 | t->bh_t0 = qemu_bh_new(timer0_hit, t); | ||
33 | t->bh_t1 = qemu_bh_new(timer1_hit, t); | ||
34 | @@ -XXX,XX +XXX,XX @@ static int etraxfs_timer_init(SysBusDevice *dev) | ||
35 | t->ptimer_t1 = ptimer_init(t->bh_t1, PTIMER_POLICY_DEFAULT); | ||
36 | t->ptimer_wd = ptimer_init(t->bh_wd, PTIMER_POLICY_DEFAULT); | ||
37 | |||
38 | - sysbus_init_irq(dev, &t->irq); | ||
39 | - sysbus_init_irq(dev, &t->nmi); | ||
40 | + sysbus_init_irq(sbd, &t->irq); | ||
41 | + sysbus_init_irq(sbd, &t->nmi); | ||
42 | |||
43 | memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, | ||
44 | "etraxfs-timer", 0x5c); | ||
45 | - sysbus_init_mmio(dev, &t->mmio); | ||
46 | + sysbus_init_mmio(sbd, &t->mmio); | ||
47 | qemu_register_reset(etraxfs_timer_reset, t); | ||
48 | - return 0; | ||
49 | } | ||
50 | |||
51 | static void etraxfs_timer_class_init(ObjectClass *klass, void *data) | ||
52 | { | ||
53 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | ||
54 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
55 | |||
56 | - sdc->init = etraxfs_timer_init; | ||
57 | + dc->realize = etraxfs_timer_realize; | ||
58 | } | ||
59 | |||
60 | static const TypeInfo etraxfs_timer_info = { | ||
61 | -- | ||
62 | 2.19.2 | ||
63 | |||
64 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
2 | 1 | ||
3 | The init function doesn't do anything at all, so we | ||
4 | just omit it. | ||
5 | |||
6 | Cc: sstabellini@kernel.org | ||
7 | Cc: anthony.perard@citrix.com | ||
8 | Cc: xen-devel@lists.xenproject.org | ||
9 | Cc: peter.maydell@linaro.org | ||
10 | |||
11 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | ||
12 | Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> | ||
13 | Acked-by: Anthony PERARD <anthony.perard@citrix.com> | ||
14 | Message-id: 20181130093852.20739-21-maozhongyi@cmss.chinamobile.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/xen/xen_backend.c | 7 ------- | ||
18 | 1 file changed, 7 deletions(-) | ||
19 | |||
20 | diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/xen/xen_backend.c | ||
23 | +++ b/hw/xen/xen_backend.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo xensysbus_info = { | ||
25 | } | ||
26 | }; | ||
27 | |||
28 | -static int xen_sysdev_init(SysBusDevice *dev) | ||
29 | -{ | ||
30 | - return 0; | ||
31 | -} | ||
32 | - | ||
33 | static Property xen_sysdev_properties[] = { | ||
34 | {/* end of property list */}, | ||
35 | }; | ||
36 | @@ -XXX,XX +XXX,XX @@ static Property xen_sysdev_properties[] = { | ||
37 | static void xen_sysdev_class_init(ObjectClass *klass, void *data) | ||
38 | { | ||
39 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
40 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
41 | |||
42 | - k->init = xen_sysdev_init; | ||
43 | dc->props = xen_sysdev_properties; | ||
44 | dc->bus_type = TYPE_XENSYSBUS; | ||
45 | } | ||
46 | -- | ||
47 | 2.19.2 | ||
48 | |||
49 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | ||
2 | 1 | ||
3 | Remove bogus virtio-mmio creation. This was an accidental | ||
4 | left-over an experiment. | ||
5 | |||
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
9 | Message-id: 20181129163655.20370-2-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/xlnx-versal-virt.c | 1 - | ||
13 | 1 file changed, 1 deletion(-) | ||
14 | |||
15 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/xlnx-versal-virt.c | ||
18 | +++ b/hw/arm/xlnx-versal-virt.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void create_virtio_regions(VersalVirt *s) | ||
20 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic_irq); | ||
21 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
22 | memory_region_add_subregion(&s->soc.mr_ps, base, mr); | ||
23 | - sysbus_create_simple("virtio-mmio", base, pic_irq); | ||
24 | } | ||
25 | |||
26 | for (i = 0; i < NUM_VIRTIO_TRANSPORT; i++) { | ||
27 | -- | ||
28 | 2.19.2 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | ||
2 | 1 | ||
3 | Use IRQs 111 - 118 for virtio-mmio. The interrupts we're currently | ||
4 | using 160+ are not available in the Versal GIC. | ||
5 | |||
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20181129163655.20370-4-edgar.iglesias@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/xlnx-versal.h | 6 +++--- | ||
12 | hw/arm/xlnx-versal-virt.c | 4 ++-- | ||
13 | 2 files changed, 5 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/arm/xlnx-versal.h | ||
18 | +++ b/include/hw/arm/xlnx-versal.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
20 | #define VERSAL_GEM1_IRQ_0 58 | ||
21 | #define VERSAL_GEM1_WAKE_IRQ_0 59 | ||
22 | |||
23 | -/* Architecturally eserved IRQs suitable for virtualization. */ | ||
24 | -#define VERSAL_RSVD_HIGH_IRQ_FIRST 160 | ||
25 | -#define VERSAL_RSVD_HIGH_IRQ_LAST 255 | ||
26 | +/* Architecturally reserved IRQs suitable for virtualization. */ | ||
27 | +#define VERSAL_RSVD_IRQ_FIRST 111 | ||
28 | +#define VERSAL_RSVD_IRQ_LAST 118 | ||
29 | |||
30 | #define MM_TOP_RSVD 0xa0000000U | ||
31 | #define MM_TOP_RSVD_SIZE 0x4000000 | ||
32 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/arm/xlnx-versal-virt.c | ||
35 | +++ b/hw/arm/xlnx-versal-virt.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void create_virtio_regions(VersalVirt *s) | ||
37 | for (i = 0; i < NUM_VIRTIO_TRANSPORT; i++) { | ||
38 | char *name = g_strdup_printf("virtio%d", i);; | ||
39 | hwaddr base = MM_TOP_RSVD + i * virtio_mmio_size; | ||
40 | - int irq = VERSAL_RSVD_HIGH_IRQ_FIRST + i; | ||
41 | + int irq = VERSAL_RSVD_IRQ_FIRST + i; | ||
42 | MemoryRegion *mr; | ||
43 | DeviceState *dev; | ||
44 | qemu_irq pic_irq; | ||
45 | @@ -XXX,XX +XXX,XX @@ static void create_virtio_regions(VersalVirt *s) | ||
46 | |||
47 | for (i = 0; i < NUM_VIRTIO_TRANSPORT; i++) { | ||
48 | hwaddr base = MM_TOP_RSVD + i * virtio_mmio_size; | ||
49 | - int irq = VERSAL_RSVD_HIGH_IRQ_FIRST + i; | ||
50 | + int irq = VERSAL_RSVD_IRQ_FIRST + i; | ||
51 | char *name = g_strdup_printf("/virtio_mmio@%" PRIx64, base); | ||
52 | |||
53 | qemu_fdt_add_subnode(s->fdt, name); | ||
54 | -- | ||
55 | 2.19.2 | ||
56 | |||
57 | diff view generated by jsdifflib |