1 | ARM queue, various patches accumulated over the Christmas break. | 1 | One last arm pullreq before I stop work for the end of the year... |
---|---|---|---|
2 | 2 | ||
3 | -- PMM | 3 | -- PMM |
4 | 4 | ||
5 | The following changes since commit 612061b277915fadd80631eb7a6926f48a110c44: | 5 | The following changes since commit 8e5943260a8f765216674ee87ce8588cc4e7463e: |
6 | 6 | ||
7 | Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2018-01-10' into staging (2018-01-11 11:52:40 +0000) | 7 | Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging (2019-12-20 12:46:10 +0000) |
8 | 8 | ||
9 | are available in the git repository at: | 9 | are available in the Git repository at: |
10 | 10 | ||
11 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180111 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20191220 |
12 | 12 | ||
13 | for you to fetch changes up to 0cf09852015e47a5fbb974ff7ac320366afd21ee: | 13 | for you to fetch changes up to c8fa6079eb35888587f1be27c1590da4edcc5098: |
14 | 14 | ||
15 | hw/intc/arm_gic: reserved register addresses are RAZ/WI (2018-01-11 13:25:40 +0000) | 15 | arm/arm-powerctl: rebuild hflags after setting CP15 bits in arm_set_cpu_on() (2019-12-20 14:03:00 +0000) |
16 | 16 | ||
17 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
18 | target-arm queue: | 18 | target-arm queue: |
19 | * add aarch64_be linux-user target | 19 | * Support emulating the generic timers at frequencies other than 62.5MHz |
20 | * Virt: ACPI: fix qemu assert due to re-assigned table data address | 20 | * Various fixes for SMMUv3 emulation bugs |
21 | * imx_fec: various bug fixes and cleanups | 21 | * Improve assert error message for hflags mismatches |
22 | * hw/timer/pxa2xx_timer: replace hw_error() -> qemu_log_mask() | 22 | * arm-powerctl: rebuild hflags after setting CP15 bits in arm_set_cpu_on() |
23 | * hw/sd/pxa2xx_mmci: add read/write() trace events | ||
24 | * linux-user/arm/nwfpe: Check coprocessor number for FPA emulation | ||
25 | * target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions | ||
26 | * hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI | ||
27 | * hw/intc/arm_gic: reserved register addresses are RAZ/WI | ||
28 | 23 | ||
29 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
30 | Andrey Smirnov (11): | 25 | Andrew Jeffery (4): |
31 | imx_fec: Do not link to netdev | 26 | target/arm: Remove redundant scaling of nexttick |
32 | imx_fec: Refactor imx_eth_enable_rx() | 27 | target/arm: Abstract the generic timer frequency |
33 | imx_fec: Change queue flushing heuristics | 28 | target/arm: Prepare generic timer for per-platform CNTFRQ |
34 | imx_fec: Move Tx frame buffer away from the stack | 29 | ast2600: Configure CNTFRQ at 1125MHz |
35 | imx_fec: Use ENET_FTRL to determine truncation length | ||
36 | imx_fec: Use MIN instead of explicit ternary operator | ||
37 | imx_fec: Emulate SHIFT16 in ENETx_RACC | ||
38 | imx_fec: Add support for multiple Tx DMA rings | ||
39 | imx_fec: Use correct length for packet size | ||
40 | imx_fec: Fix a typo in imx_enet_receive() | ||
41 | imx_fec: Reserve full FSL_IMX25_FEC_SIZE page for the register file | ||
42 | 30 | ||
43 | Michael Weiser (8): | 31 | Niek Linnenbank (1): |
44 | linux-user: Add support for big-endian aarch64 | 32 | arm/arm-powerctl: rebuild hflags after setting CP15 bits in arm_set_cpu_on() |
45 | linux-user: Add separate aarch64_be uname | ||
46 | linux-user: Fix endianess of aarch64 signal trampoline | ||
47 | configure: Add aarch64_be-linux-user target | ||
48 | linux-user: Add aarch64_be magic numbers to qemu-binfmt-conf.sh | ||
49 | linux-user: Separate binfmt arm CPU families | ||
50 | linux-user: Activate armeb handler registration | ||
51 | target/arm: Fix stlxp for aarch64_be | ||
52 | 33 | ||
53 | Peter Maydell (4): | 34 | Philippe Mathieu-Daudé (1): |
54 | linux-user/arm/nwfpe: Check coprocessor number for FPA emulation | 35 | target/arm: Display helpful message when hflags mismatch |
55 | target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions | ||
56 | hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI | ||
57 | hw/intc/arm_gic: reserved register addresses are RAZ/WI | ||
58 | 36 | ||
59 | Philippe Mathieu-Daudé (2): | 37 | Simon Veith (6): |
60 | hw/timer/pxa2xx_timer: replace hw_error() -> qemu_log_mask() | 38 | hw/arm/smmuv3: Apply address mask to linear strtab base address |
61 | hw/sd/pxa2xx_mmci: add read/write() trace events | 39 | hw/arm/smmuv3: Correct SMMU_BASE_ADDR_MASK value |
40 | hw/arm/smmuv3: Check stream IDs against actual table LOG2SIZE | ||
41 | hw/arm/smmuv3: Align stream table base address to table size | ||
42 | hw/arm/smmuv3: Use correct bit positions in EVT_SET_ADDR2 macro | ||
43 | hw/arm/smmuv3: Report F_STE_FETCH fault address in correct word position | ||
62 | 44 | ||
63 | Zhaoshenglong (1): | 45 | hw/arm/smmuv3-internal.h | 6 ++--- |
64 | Virt: ACPI: fix qemu assert due to re-assigned table data address | 46 | target/arm/cpu.h | 5 ++++ |
47 | hw/arm/aspeed_ast2600.c | 3 +++ | ||
48 | hw/arm/smmuv3.c | 28 +++++++++++++++----- | ||
49 | target/arm/arm-powerctl.c | 3 +++ | ||
50 | target/arm/cpu.c | 65 +++++++++++++++++++++++++++++++++++++++++------ | ||
51 | target/arm/helper.c | 42 +++++++++++++++++++++++------- | ||
52 | 7 files changed, 125 insertions(+), 27 deletions(-) | ||
65 | 53 | ||
66 | configure | 5 +- | ||
67 | include/hw/arm/fsl-imx25.h | 1 - | ||
68 | include/hw/net/imx_fec.h | 27 +++- | ||
69 | linux-user/aarch64/target_syscall.h | 4 + | ||
70 | hw/arm/fsl-imx6.c | 1 + | ||
71 | hw/arm/virt-acpi-build.c | 18 ++- | ||
72 | hw/intc/arm_gic.c | 5 +- | ||
73 | hw/intc/arm_gicv3_dist.c | 13 ++ | ||
74 | hw/intc/arm_gicv3_its_common.c | 8 +- | ||
75 | hw/intc/arm_gicv3_redist.c | 13 ++ | ||
76 | hw/net/imx_fec.c | 210 +++++++++++++++++++++++------- | ||
77 | hw/sd/pxa2xx_mmci.c | 78 +++++++---- | ||
78 | hw/timer/pxa2xx_timer.c | 17 ++- | ||
79 | linux-user/arm/nwfpe/fpa11.c | 9 ++ | ||
80 | linux-user/main.c | 6 + | ||
81 | linux-user/signal.c | 10 +- | ||
82 | target/arm/helper-a64.c | 7 +- | ||
83 | target/arm/translate.c | 23 ++-- | ||
84 | default-configs/aarch64_be-linux-user.mak | 1 + | ||
85 | hw/sd/trace-events | 4 + | ||
86 | scripts/qemu-binfmt-conf.sh | 15 ++- | ||
87 | 21 files changed, 356 insertions(+), 119 deletions(-) | ||
88 | create mode 100644 default-configs/aarch64_be-linux-user.mak | ||
89 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Weiser <michael.weiser@gmx.de> | ||
2 | 1 | ||
3 | Enable big-endian mode for data accesses on aarch64 for big-endian linux | ||
4 | user mode. Activate it for all exception levels as documented by ARM: | ||
5 | Set the SCTLR EE bit for ELs 1 through 3. Additionally set bit E0E in | ||
6 | EL1 to enable it in EL0 as well. | ||
7 | |||
8 | Signed-off-by: Michael Weiser <michael.weiser@gmx.de> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20171220212308.12614-2-michael.weiser@gmx.de | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | linux-user/main.c | 6 ++++++ | ||
14 | 1 file changed, 6 insertions(+) | ||
15 | |||
16 | diff --git a/linux-user/main.c b/linux-user/main.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/linux-user/main.c | ||
19 | +++ b/linux-user/main.c | ||
20 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp) | ||
21 | } | ||
22 | env->pc = regs->pc; | ||
23 | env->xregs[31] = regs->sp; | ||
24 | +#ifdef TARGET_WORDS_BIGENDIAN | ||
25 | + env->cp15.sctlr_el[1] |= SCTLR_E0E; | ||
26 | + for (i = 1; i < 4; ++i) { | ||
27 | + env->cp15.sctlr_el[i] |= SCTLR_EE; | ||
28 | + } | ||
29 | +#endif | ||
30 | } | ||
31 | #elif defined(TARGET_ARM) | ||
32 | { | ||
33 | -- | ||
34 | 2.7.4 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Weiser <michael.weiser@gmx.de> | ||
2 | 1 | ||
3 | Make big-endian aarch64 systems identify as aarch64_be as expected by | ||
4 | big-endian userland and toolchains. | ||
5 | |||
6 | Signed-off-by: Michael Weiser <michael.weiser@gmx.de> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> | ||
9 | Message-id: 20171220212308.12614-3-michael.weiser@gmx.de | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | linux-user/aarch64/target_syscall.h | 4 ++++ | ||
13 | 1 file changed, 4 insertions(+) | ||
14 | |||
15 | diff --git a/linux-user/aarch64/target_syscall.h b/linux-user/aarch64/target_syscall.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/linux-user/aarch64/target_syscall.h | ||
18 | +++ b/linux-user/aarch64/target_syscall.h | ||
19 | @@ -XXX,XX +XXX,XX @@ struct target_pt_regs { | ||
20 | uint64_t pstate; | ||
21 | }; | ||
22 | |||
23 | +#if defined(TARGET_WORDS_BIGENDIAN) | ||
24 | +#define UNAME_MACHINE "aarch64_be" | ||
25 | +#else | ||
26 | #define UNAME_MACHINE "aarch64" | ||
27 | +#endif | ||
28 | #define UNAME_MINIMUM_RELEASE "3.8.0" | ||
29 | #define TARGET_CLONE_BACKWARDS | ||
30 | #define TARGET_MINSIGSTKSZ 2048 | ||
31 | -- | ||
32 | 2.7.4 | ||
33 | |||
34 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Weiser <michael.weiser@gmx.de> | ||
2 | 1 | ||
3 | Since for aarch64 the signal trampoline is synthesized directly into the | ||
4 | signal frame we need to make sure the instructions end up little-endian. | ||
5 | Otherwise the wrong endianness will cause a SIGILL upon return from the | ||
6 | signal handler on big-endian targets. | ||
7 | |||
8 | Signed-off-by: Michael Weiser <michael.weiser@gmx.de> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20171220212308.12614-4-michael.weiser@gmx.de | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | linux-user/signal.c | 10 +++++++--- | ||
14 | 1 file changed, 7 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/linux-user/signal.c b/linux-user/signal.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/linux-user/signal.c | ||
19 | +++ b/linux-user/signal.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
21 | if (ka->sa_flags & TARGET_SA_RESTORER) { | ||
22 | return_addr = ka->sa_restorer; | ||
23 | } else { | ||
24 | - /* mov x8,#__NR_rt_sigreturn; svc #0 */ | ||
25 | - __put_user(0xd2801168, &frame->tramp[0]); | ||
26 | - __put_user(0xd4000001, &frame->tramp[1]); | ||
27 | + /* | ||
28 | + * mov x8,#__NR_rt_sigreturn; svc #0 | ||
29 | + * Since these are instructions they need to be put as little-endian | ||
30 | + * regardless of target default or current CPU endianness. | ||
31 | + */ | ||
32 | + __put_user_e(0xd2801168, &frame->tramp[0], le); | ||
33 | + __put_user_e(0xd4000001, &frame->tramp[1], le); | ||
34 | return_addr = frame_addr + offsetof(struct target_rt_sigframe, tramp); | ||
35 | } | ||
36 | env->xregs[0] = usig; | ||
37 | -- | ||
38 | 2.7.4 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Weiser <michael.weiser@gmx.de> | ||
2 | 1 | ||
3 | Add target aarch64_be-linux-user. This allows a qemu-aarch64_be binary | ||
4 | to be built that will run big-endian aarch64 binaries. | ||
5 | |||
6 | Signed-off-by: Michael Weiser <michael.weiser@gmx.de> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> | ||
9 | Message-id: 20171220212308.12614-5-michael.weiser@gmx.de | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | configure | 5 +++-- | ||
13 | default-configs/aarch64_be-linux-user.mak | 1 + | ||
14 | 2 files changed, 4 insertions(+), 2 deletions(-) | ||
15 | create mode 100644 default-configs/aarch64_be-linux-user.mak | ||
16 | |||
17 | diff --git a/configure b/configure | ||
18 | index XXXXXXX..XXXXXXX 100755 | ||
19 | --- a/configure | ||
20 | +++ b/configure | ||
21 | @@ -XXX,XX +XXX,XX @@ target_name=$(echo $target | cut -d '-' -f 1) | ||
22 | target_bigendian="no" | ||
23 | |||
24 | case "$target_name" in | ||
25 | - armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb) | ||
26 | + armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb) | ||
27 | target_bigendian=yes | ||
28 | ;; | ||
29 | esac | ||
30 | @@ -XXX,XX +XXX,XX @@ case "$target_name" in | ||
31 | mttcg="yes" | ||
32 | gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" | ||
33 | ;; | ||
34 | - aarch64) | ||
35 | + aarch64|aarch64_be) | ||
36 | + TARGET_ARCH=aarch64 | ||
37 | TARGET_BASE_ARCH=arm | ||
38 | bflt="yes" | ||
39 | mttcg="yes" | ||
40 | diff --git a/default-configs/aarch64_be-linux-user.mak b/default-configs/aarch64_be-linux-user.mak | ||
41 | new file mode 100644 | ||
42 | index XXXXXXX..XXXXXXX | ||
43 | --- /dev/null | ||
44 | +++ b/default-configs/aarch64_be-linux-user.mak | ||
45 | @@ -0,0 +1 @@ | ||
46 | +# Default configuration for aarch64_be-linux-user | ||
47 | -- | ||
48 | 2.7.4 | ||
49 | |||
50 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Weiser <michael.weiser@gmx.de> | ||
2 | 1 | ||
3 | As we now have a linux-user aarch64_be target, we can add it to the list | ||
4 | of supported targets in qemu-binfmt-conf.sh | ||
5 | |||
6 | Signed-off-by: Michael Weiser <michael.weiser@gmx.de> | ||
7 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> | ||
8 | Message-id: 20171220212308.12614-6-michael.weiser@gmx.de | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | scripts/qemu-binfmt-conf.sh | 6 +++++- | ||
12 | 1 file changed, 5 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh | ||
15 | index XXXXXXX..XXXXXXX 100755 | ||
16 | --- a/scripts/qemu-binfmt-conf.sh | ||
17 | +++ b/scripts/qemu-binfmt-conf.sh | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | qemu_target_list="i386 i486 alpha arm sparc32plus ppc ppc64 ppc64le m68k \ | ||
21 | mips mipsel mipsn32 mipsn32el mips64 mips64el \ | ||
22 | -sh4 sh4eb s390x aarch64 hppa" | ||
23 | +sh4 sh4eb s390x aarch64 aarch64_be hppa" | ||
24 | |||
25 | i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00' | ||
26 | i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' | ||
27 | @@ -XXX,XX +XXX,XX @@ aarch64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x | ||
28 | aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' | ||
29 | aarch64_family=arm | ||
30 | |||
31 | +aarch64_be_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7' | ||
32 | +aarch64_be_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' | ||
33 | +aarch64_be_family=arm | ||
34 | + | ||
35 | hppa_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f' | ||
36 | hppa_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' | ||
37 | hppa_family=hppa | ||
38 | -- | ||
39 | 2.7.4 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Weiser <michael.weiser@gmx.de> | ||
2 | 1 | ||
3 | Give big-endian arm and aarch64 CPUs their own family in | ||
4 | qemu-binfmt-conf.sh to make sure we register qemu-user for binaries of | ||
5 | the opposite endianness on arm and aarch64. Apart from the family | ||
6 | assignments of the magic values, qemu_get_family() needs to be able to | ||
7 | distinguish the two and recognise aarch64{,_be} as well. | ||
8 | |||
9 | Signed-off-by: Michael Weiser <michael.weiser@gmx.de> | ||
10 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> | ||
11 | Message-id: 20171220212308.12614-7-michael.weiser@gmx.de | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | scripts/qemu-binfmt-conf.sh | 9 ++++++--- | ||
15 | 1 file changed, 6 insertions(+), 3 deletions(-) | ||
16 | |||
17 | diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh | ||
18 | index XXXXXXX..XXXXXXX 100755 | ||
19 | --- a/scripts/qemu-binfmt-conf.sh | ||
20 | +++ b/scripts/qemu-binfmt-conf.sh | ||
21 | @@ -XXX,XX +XXX,XX @@ arm_family=arm | ||
22 | |||
23 | armeb_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28' | ||
24 | armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' | ||
25 | -armeb_family=arm | ||
26 | +armeb_family=armeb | ||
27 | |||
28 | sparc_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02' | ||
29 | sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' | ||
30 | @@ -XXX,XX +XXX,XX @@ aarch64_family=arm | ||
31 | |||
32 | aarch64_be_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7' | ||
33 | aarch64_be_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' | ||
34 | -aarch64_be_family=arm | ||
35 | +aarch64_be_family=armeb | ||
36 | |||
37 | hppa_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f' | ||
38 | hppa_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' | ||
39 | @@ -XXX,XX +XXX,XX @@ qemu_get_family() { | ||
40 | ppc64el|ppc64le) | ||
41 | echo "ppcle" | ||
42 | ;; | ||
43 | - arm|armel|armhf|arm64|armv[4-9]*) | ||
44 | + arm|armel|armhf|arm64|armv[4-9]*l|aarch64) | ||
45 | echo "arm" | ||
46 | ;; | ||
47 | + armeb|armv[4-9]*b|aarch64_be) | ||
48 | + echo "armeb" | ||
49 | + ;; | ||
50 | sparc*) | ||
51 | echo "sparc" | ||
52 | ;; | ||
53 | -- | ||
54 | 2.7.4 | ||
55 | |||
56 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Weiser <michael.weiser@gmx.de> | ||
2 | 1 | ||
3 | armeb is missing from the target list in qemu-binfmt-conf.sh. Add it so | ||
4 | the handler for those binaries gets registered by the script. | ||
5 | |||
6 | Signed-off-by: Michael Weiser <michael.weiser@gmx.de> | ||
7 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> | ||
8 | Message-id: 20171220212308.12614-8-michael.weiser@gmx.de | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | scripts/qemu-binfmt-conf.sh | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh | ||
15 | index XXXXXXX..XXXXXXX 100755 | ||
16 | --- a/scripts/qemu-binfmt-conf.sh | ||
17 | +++ b/scripts/qemu-binfmt-conf.sh | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | # enable automatic i386/ARM/M68K/MIPS/SPARC/PPC/s390/HPPA | ||
20 | # program execution by the kernel | ||
21 | |||
22 | -qemu_target_list="i386 i486 alpha arm sparc32plus ppc ppc64 ppc64le m68k \ | ||
23 | +qemu_target_list="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k \ | ||
24 | mips mipsel mipsn32 mipsn32el mips64 mips64el \ | ||
25 | sh4 sh4eb s390x aarch64 aarch64_be hppa" | ||
26 | |||
27 | -- | ||
28 | 2.7.4 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Weiser <michael.weiser@gmx.de> | ||
2 | 1 | ||
3 | ldxp loads two consecutive doublewords from memory regardless of CPU | ||
4 | endianness. On store, stlxp currently assumes to work with a 128bit | ||
5 | value and consequently switches order in big-endian mode. With this | ||
6 | change it packs the doublewords in reverse order in anticipation of the | ||
7 | 128bit big-endian store operation interposing them so they end up in | ||
8 | memory in the right order. This makes it work for both MTTCG and !MTTCG. | ||
9 | It effectively implements the ARM ARM STLXP operation pseudo-code: | ||
10 | |||
11 | data = if BigEndian() then el1:el2 else el2:el1; | ||
12 | |||
13 | With this change an aarch64_be Linux 4.14.4 kernel succeeds to boot up | ||
14 | in system emulation mode. | ||
15 | |||
16 | Signed-off-by: Michael Weiser <michael.weiser@gmx.de> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | target/arm/helper-a64.c | 7 +++++-- | ||
21 | 1 file changed, 5 insertions(+), 2 deletions(-) | ||
22 | |||
23 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/arm/helper-a64.c | ||
26 | +++ b/target/arm/helper-a64.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_paired_cmpxchg64_be(CPUARMState *env, uint64_t addr, | ||
28 | Int128 oldv, cmpv, newv; | ||
29 | bool success; | ||
30 | |||
31 | - cmpv = int128_make128(env->exclusive_val, env->exclusive_high); | ||
32 | - newv = int128_make128(new_lo, new_hi); | ||
33 | + /* high and low need to be switched here because this is not actually a | ||
34 | + * 128bit store but two doublewords stored consecutively | ||
35 | + */ | ||
36 | + cmpv = int128_make128(env->exclusive_high, env->exclusive_val); | ||
37 | + newv = int128_make128(new_hi, new_lo); | ||
38 | |||
39 | if (parallel) { | ||
40 | #ifndef CONFIG_ATOMIC128 | ||
41 | -- | ||
42 | 2.7.4 | ||
43 | |||
44 | diff view generated by jsdifflib |
1 | The GICv2 specification says that reserved register addresses | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | must RAZ/WI; now that we implement external abort handling | ||
3 | for Arm CPUs this means we must return MEMTX_OK rather than | ||
4 | MEMTX_ERROR, to avoid generating a spurious guest data abort. | ||
5 | 2 | ||
6 | Cc: qemu-stable@nongnu.org | 3 | The corner-case codepath was adjusting nexttick such that overflow |
4 | wouldn't occur when timer_mod() scaled the value back up. Remove a use | ||
5 | of GTIMER_SCALE and avoid unnecessary operations by calling | ||
6 | timer_mod_ns() directly. | ||
7 | |||
8 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Message-id: f8c680720e3abe55476e6d9cb604ad27fdbeb2e0.1576215453.git-series.andrew@aj.id.au | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 1513183941-24300-3-git-send-email-peter.maydell@linaro.org | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
10 | --- | 13 | --- |
11 | hw/intc/arm_gic.c | 5 +++-- | 14 | target/arm/helper.c | 5 +++-- |
12 | 1 file changed, 3 insertions(+), 2 deletions(-) | 15 | 1 file changed, 3 insertions(+), 2 deletions(-) |
13 | 16 | ||
14 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/arm_gic.c | 19 | --- a/target/arm/helper.c |
17 | +++ b/hw/intc/arm_gic.c | 20 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_read(GICState *s, int cpu, int offset, | 21 | @@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) |
19 | default: | 22 | * timer expires we will reset the timer for any remaining period. |
20 | qemu_log_mask(LOG_GUEST_ERROR, | 23 | */ |
21 | "gic_cpu_read: Bad offset %x\n", (int)offset); | 24 | if (nexttick > INT64_MAX / GTIMER_SCALE) { |
22 | - return MEMTX_ERROR; | 25 | - nexttick = INT64_MAX / GTIMER_SCALE; |
23 | + *data = 0; | 26 | + timer_mod_ns(cpu->gt_timer[timeridx], INT64_MAX); |
24 | + break; | 27 | + } else { |
25 | } | 28 | + timer_mod(cpu->gt_timer[timeridx], nexttick); |
26 | return MEMTX_OK; | 29 | } |
27 | } | 30 | - timer_mod(cpu->gt_timer[timeridx], nexttick); |
28 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset, | 31 | trace_arm_gt_recalc(timeridx, irqstate, nexttick); |
29 | default: | 32 | } else { |
30 | qemu_log_mask(LOG_GUEST_ERROR, | 33 | /* Timer disabled: ISTATUS and timer output always clear */ |
31 | "gic_cpu_write: Bad offset %x\n", (int)offset); | ||
32 | - return MEMTX_ERROR; | ||
33 | + return MEMTX_OK; | ||
34 | } | ||
35 | gic_update(s); | ||
36 | return MEMTX_OK; | ||
37 | -- | 34 | -- |
38 | 2.7.4 | 35 | 2.20.1 |
39 | 36 | ||
40 | 37 | diff view generated by jsdifflib |
1 | From: Zhaoshenglong <zhaoshenglong@huawei.com> | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | 2 | ||
3 | acpi_data_push uses g_array_set_size to resize the memory size. If there | 3 | Prepare for SoCs such as the ASPEED AST2600 whose firmware configures |
4 | is no enough contiguous memory, the address will be changed. If we use | 4 | CNTFRQ to values significantly larger than the static 62.5MHz value |
5 | the old value, it will assert. | 5 | currently derived from GTIMER_SCALE. As the OS potentially derives its |
6 | qemu-kvm: hw/acpi/bios-linker-loader.c:214: bios_linker_loader_add_checksum: | 6 | timer periods from the CNTFRQ value the lack of support for running |
7 | Assertion `start_offset < file->blob->len' failed.` | 7 | QEMUTimers at the appropriate rate leads to sticky behaviour in the |
8 | guest. | ||
8 | 9 | ||
9 | This issue only happens in building SRAT table now but here we unify the | 10 | Substitute the GTIMER_SCALE constant with use of a helper to derive the |
10 | pattern for other tables as well to avoid possible issues in the future. | 11 | period from gt_cntfrq_hz stored in struct ARMCPU. Initially set |
12 | gt_cntfrq_hz to the frequency associated with GTIMER_SCALE so current | ||
13 | behaviour is maintained. | ||
11 | 14 | ||
12 | Signed-off-by: Zhaoshenglong <zhaoshenglong@huawei.com> | 15 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> |
13 | Reviewed-by: Andrew Jones <drjones@redhat.com> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
18 | Message-id: 40bd8df043f66e1ccfb3e9482999d099ac72bb2e.1576215453.git-series.andrew@aj.id.au | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 20 | --- |
16 | hw/arm/virt-acpi-build.c | 18 +++++++++++------- | 21 | target/arm/cpu.h | 5 +++++ |
17 | 1 file changed, 11 insertions(+), 7 deletions(-) | 22 | target/arm/cpu.c | 8 ++++++++ |
23 | target/arm/helper.c | 10 +++++++--- | ||
24 | 3 files changed, 20 insertions(+), 3 deletions(-) | ||
18 | 25 | ||
19 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 26 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/virt-acpi-build.c | 28 | --- a/target/arm/cpu.h |
22 | +++ b/hw/arm/virt-acpi-build.c | 29 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 30 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
24 | AcpiSerialPortConsoleRedirection *spcr; | 31 | */ |
25 | const MemMapEntry *uart_memmap = &vms->memmap[VIRT_UART]; | 32 | DECLARE_BITMAP(sve_vq_map, ARM_MAX_VQ); |
26 | int irq = vms->irqmap[VIRT_UART] + ARM_SPI_BASE; | 33 | DECLARE_BITMAP(sve_vq_init, ARM_MAX_VQ); |
27 | + int spcr_start = table_data->len; | 34 | + |
28 | 35 | + /* Generic timer counter frequency, in Hz */ | |
29 | spcr = acpi_data_push(table_data, sizeof(*spcr)); | 36 | + uint64_t gt_cntfrq_hz; |
30 | 37 | }; | |
31 | @@ -XXX,XX +XXX,XX @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 38 | |
32 | spcr->pci_device_id = 0xffff; /* PCI Device ID: not a PCI device */ | 39 | +unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); |
33 | spcr->pci_vendor_id = 0xffff; /* PCI Vendor ID: not a PCI device */ | 40 | + |
34 | 41 | void arm_cpu_post_init(Object *obj); | |
35 | - build_header(linker, table_data, (void *)spcr, "SPCR", sizeof(*spcr), 2, | 42 | |
36 | - NULL, NULL); | 43 | uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); |
37 | + build_header(linker, table_data, (void *)(table_data->data + spcr_start), | 44 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
38 | + "SPCR", table_data->len - spcr_start, 2, NULL, NULL); | 45 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/target/arm/cpu.c | ||
47 | +++ b/target/arm/cpu.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | ||
49 | if (tcg_enabled()) { | ||
50 | cpu->psci_version = 2; /* TCG implements PSCI 0.2 */ | ||
51 | } | ||
52 | + | ||
53 | + cpu->gt_cntfrq_hz = NANOSECONDS_PER_SECOND / GTIMER_SCALE; | ||
39 | } | 54 | } |
40 | 55 | ||
41 | static void | 56 | static Property arm_cpu_reset_cbar_property = |
42 | @@ -XXX,XX +XXX,XX @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 57 | @@ -XXX,XX +XXX,XX @@ static void arm_set_init_svtor(Object *obj, Visitor *v, const char *name, |
43 | mem_base += numa_info[i].node_mem; | 58 | visit_type_uint32(v, name, &cpu->init_svtor, errp); |
44 | } | ||
45 | |||
46 | - build_header(linker, table_data, (void *)srat, "SRAT", | ||
47 | - table_data->len - srat_start, 3, NULL, NULL); | ||
48 | + build_header(linker, table_data, (void *)(table_data->data + srat_start), | ||
49 | + "SRAT", table_data->len - srat_start, 3, NULL, NULL); | ||
50 | } | 59 | } |
51 | 60 | ||
52 | static void | 61 | +unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) |
53 | @@ -XXX,XX +XXX,XX @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 62 | +{ |
54 | AcpiTableMcfg *mcfg; | 63 | + return NANOSECONDS_PER_SECOND > cpu->gt_cntfrq_hz ? |
55 | const MemMapEntry *memmap = vms->memmap; | 64 | + NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; |
56 | int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]); | 65 | +} |
57 | + int mcfg_start = table_data->len; | 66 | + |
58 | 67 | void arm_cpu_post_init(Object *obj) | |
59 | mcfg = acpi_data_push(table_data, len); | 68 | { |
60 | mcfg->allocation[0].address = cpu_to_le64(memmap[VIRT_PCIE_ECAM].base); | 69 | ARMCPU *cpu = ARM_CPU(obj); |
61 | @@ -XXX,XX +XXX,XX @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 70 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
62 | mcfg->allocation[0].end_bus_number = (memmap[VIRT_PCIE_ECAM].size | 71 | index XXXXXXX..XXXXXXX 100644 |
63 | / PCIE_MMCFG_SIZE_MIN) - 1; | 72 | --- a/target/arm/helper.c |
64 | 73 | +++ b/target/arm/helper.c | |
65 | - build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL); | 74 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_stimer_access(CPUARMState *env, |
66 | + build_header(linker, table_data, (void *)(table_data->data + mcfg_start), | 75 | |
67 | + "MCFG", table_data->len - mcfg_start, 1, NULL, NULL); | 76 | static uint64_t gt_get_countervalue(CPUARMState *env) |
77 | { | ||
78 | - return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / GTIMER_SCALE; | ||
79 | + ARMCPU *cpu = env_archcpu(env); | ||
80 | + | ||
81 | + return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / gt_cntfrq_period_ns(cpu); | ||
68 | } | 82 | } |
69 | 83 | ||
70 | /* GTDT */ | 84 | static void gt_recalc_timer(ARMCPU *cpu, int timeridx) |
71 | @@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 85 | @@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) |
72 | static void build_fadt(GArray *table_data, BIOSLinker *linker, | 86 | * set the timer for as far in the future as possible. When the |
73 | VirtMachineState *vms, unsigned dsdt_tbl_offset) | 87 | * timer expires we will reset the timer for any remaining period. |
88 | */ | ||
89 | - if (nexttick > INT64_MAX / GTIMER_SCALE) { | ||
90 | + if (nexttick > INT64_MAX / gt_cntfrq_period_ns(cpu)) { | ||
91 | timer_mod_ns(cpu->gt_timer[timeridx], INT64_MAX); | ||
92 | } else { | ||
93 | timer_mod(cpu->gt_timer[timeridx], nexttick); | ||
94 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
95 | |||
96 | static uint64_t gt_virt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
74 | { | 97 | { |
75 | + int fadt_start = table_data->len; | 98 | + ARMCPU *cpu = env_archcpu(env); |
76 | AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt)); | 99 | + |
77 | unsigned xdsdt_entry_offset = (char *)&fadt->x_dsdt - table_data->data; | 100 | /* Currently we have no support for QEMUTimer in linux-user so we |
78 | uint16_t bootflags; | 101 | * can't call gt_get_countervalue(env), instead we directly |
79 | @@ -XXX,XX +XXX,XX @@ static void build_fadt(GArray *table_data, BIOSLinker *linker, | 102 | * call the lower level functions. |
80 | ACPI_BUILD_TABLE_FILE, xdsdt_entry_offset, sizeof(fadt->x_dsdt), | 103 | */ |
81 | ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset); | 104 | - return cpu_get_clock() / GTIMER_SCALE; |
82 | 105 | + return cpu_get_clock() / gt_cntfrq_period_ns(cpu); | |
83 | - build_header(linker, table_data, | ||
84 | - (void *)fadt, "FACP", sizeof(*fadt), 5, NULL, NULL); | ||
85 | + build_header(linker, table_data, (void *)(table_data->data + fadt_start), | ||
86 | + "FACP", table_data->len - fadt_start, 5, NULL, NULL); | ||
87 | } | 106 | } |
88 | 107 | ||
89 | /* DSDT */ | 108 | static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
90 | -- | 109 | -- |
91 | 2.7.4 | 110 | 2.20.1 |
92 | 111 | ||
93 | 112 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
2 | 1 | ||
3 | Binding to a particular netdev doesn't seem to belong to this layer | ||
4 | and should probably be done as a part of board or SoC specific code. | ||
5 | |||
6 | Convert all of the users of this IP block to use | ||
7 | qdev_set_nic_properties() instead. | ||
8 | |||
9 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Cc: Jason Wang <jasowang@redhat.com> | ||
11 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Cc: qemu-devel@nongnu.org | ||
13 | Cc: qemu-arm@nongnu.org | ||
14 | Cc: yurovsky@gmail.com | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | hw/arm/fsl-imx6.c | 1 + | ||
20 | hw/net/imx_fec.c | 2 -- | ||
21 | 2 files changed, 1 insertion(+), 2 deletions(-) | ||
22 | |||
23 | diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/hw/arm/fsl-imx6.c | ||
26 | +++ b/hw/arm/fsl-imx6.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
28 | spi_table[i].irq)); | ||
29 | } | ||
30 | |||
31 | + qdev_set_nic_properties(DEVICE(&s->eth), &nd_table[0]); | ||
32 | object_property_set_bool(OBJECT(&s->eth), true, "realized", &err); | ||
33 | if (err) { | ||
34 | error_propagate(errp, err); | ||
35 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/net/imx_fec.c | ||
38 | +++ b/hw/net/imx_fec.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_realize(DeviceState *dev, Error **errp) | ||
40 | |||
41 | qemu_macaddr_default_if_unset(&s->conf.macaddr); | ||
42 | |||
43 | - s->conf.peers.ncs[0] = nd_table[0].netdev; | ||
44 | - | ||
45 | s->nic = qemu_new_nic(&imx_eth_net_info, &s->conf, | ||
46 | object_get_typename(OBJECT(dev)), | ||
47 | DEVICE(dev)->id, s); | ||
48 | -- | ||
49 | 2.7.4 | ||
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Refactor imx_eth_enable_rx() to have more meaningfull variable name | 3 | The ASPEED AST2600 clocks the generic timer at the rate of HPLL. On |
4 | than 'tmp' and to reduce number of logical negations done. | 4 | recent firmwares this is at 1125MHz, which is considerably quicker than |
5 | the assumed 62.5MHz of the current generic timer implementation. The | ||
6 | delta between the value as read from CNTFRQ and the true rate of the | ||
7 | underlying QEMUTimer leads to sticky behaviour in AST2600 guests. | ||
5 | 8 | ||
6 | Cc: Peter Maydell <peter.maydell@linaro.org> | 9 | Add a feature-gated property exposing CNTFRQ for ARM CPUs providing the |
7 | Cc: Jason Wang <jasowang@redhat.com> | 10 | generic timer. This allows platforms to configure CNTFRQ (and the |
8 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | 11 | associated QEMUTimer) to the appropriate frequency prior to starting the |
9 | Cc: qemu-devel@nongnu.org | 12 | guest. |
10 | Cc: qemu-arm@nongnu.org | 13 | |
11 | Cc: yurovsky@gmail.com | 14 | As the platform can now determine the rate of CNTFRQ we're exposed to |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 15 | limitations of QEMUTimer that didn't previously materialise: In the |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | course of emulation we need to arbitrarily and accurately convert |
14 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | 17 | between guest ticks and time, but we're constrained by QEMUTimer's use |
18 | of an integer scaling factor. The effect is QEMUTimer cannot exactly | ||
19 | capture the period of frequencies that do not cleanly divide | ||
20 | NANOSECONDS_PER_SECOND for scaling ticks to time. As such, provide an | ||
21 | equally inaccurate scaling factor for scaling time to ticks so at least | ||
22 | a self-consistent inverse relationship holds. | ||
23 | |||
24 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
26 | Message-id: a22db9325f96e39f76e3c2baddcb712149f46bf2.1576215453.git-series.andrew@aj.id.au | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 28 | --- |
17 | hw/net/imx_fec.c | 8 ++++---- | 29 | target/arm/cpu.c | 61 +++++++++++++++++++++++++++++++++++++-------- |
18 | 1 file changed, 4 insertions(+), 4 deletions(-) | 30 | target/arm/helper.c | 9 ++++++- |
31 | 2 files changed, 59 insertions(+), 11 deletions(-) | ||
19 | 32 | ||
20 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 33 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/net/imx_fec.c | 35 | --- a/target/arm/cpu.c |
23 | +++ b/hw/net/imx_fec.c | 36 | +++ b/target/arm/cpu.c |
24 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_do_tx(IMXFECState *s) | 37 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) |
25 | static void imx_eth_enable_rx(IMXFECState *s) | 38 | if (tcg_enabled()) { |
39 | cpu->psci_version = 2; /* TCG implements PSCI 0.2 */ | ||
40 | } | ||
41 | - | ||
42 | - cpu->gt_cntfrq_hz = NANOSECONDS_PER_SECOND / GTIMER_SCALE; | ||
43 | } | ||
44 | |||
45 | +static Property arm_cpu_gt_cntfrq_property = | ||
46 | + DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, | ||
47 | + NANOSECONDS_PER_SECOND / GTIMER_SCALE); | ||
48 | + | ||
49 | static Property arm_cpu_reset_cbar_property = | ||
50 | DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); | ||
51 | |||
52 | @@ -XXX,XX +XXX,XX @@ static void arm_set_init_svtor(Object *obj, Visitor *v, const char *name, | ||
53 | |||
54 | unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) | ||
26 | { | 55 | { |
27 | IMXFECBufDesc bd; | 56 | + /* |
28 | - bool tmp; | 57 | + * The exact approach to calculating guest ticks is: |
29 | + bool rx_ring_full; | 58 | + * |
30 | 59 | + * muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), cpu->gt_cntfrq_hz, | |
31 | imx_fec_read_bd(&bd, s->rx_descriptor); | 60 | + * NANOSECONDS_PER_SECOND); |
32 | 61 | + * | |
33 | - tmp = ((bd.flags & ENET_BD_E) != 0); | 62 | + * We don't do that. Rather we intentionally use integer division |
34 | + rx_ring_full = !(bd.flags & ENET_BD_E); | 63 | + * truncation below and in the caller for the conversion of host monotonic |
35 | 64 | + * time to guest ticks to provide the exact inverse for the semantics of | |
36 | - if (!tmp) { | 65 | + * the QEMUTimer scale factor. QEMUTimer's scale facter is an integer, so |
37 | + if (rx_ring_full) { | 66 | + * it loses precision when representing frequencies where |
38 | FEC_PRINTF("RX buffer full\n"); | 67 | + * `(NANOSECONDS_PER_SECOND % cpu->gt_cntfrq) > 0` holds. Failing to |
39 | } else if (!s->regs[ENET_RDAR]) { | 68 | + * provide an exact inverse leads to scheduling timers with negative |
40 | qemu_flush_queued_packets(qemu_get_queue(s->nic)); | 69 | + * periods, which in turn leads to sticky behaviour in the guest. |
70 | + * | ||
71 | + * Finally, CNTFRQ is effectively capped at 1GHz to ensure our scale factor | ||
72 | + * cannot become zero. | ||
73 | + */ | ||
74 | return NANOSECONDS_PER_SECOND > cpu->gt_cntfrq_hz ? | ||
75 | NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; | ||
76 | } | ||
77 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | ||
78 | |||
79 | qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property, | ||
80 | &error_abort); | ||
81 | + | ||
82 | + if (arm_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER)) { | ||
83 | + qdev_property_add_static(DEVICE(cpu), &arm_cpu_gt_cntfrq_property, | ||
84 | + &error_abort); | ||
85 | + } | ||
86 | } | ||
87 | |||
88 | static void arm_cpu_finalizefn(Object *obj) | ||
89 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
90 | } | ||
41 | } | 91 | } |
42 | 92 | ||
43 | - s->regs[ENET_RDAR] = tmp ? ENET_RDAR_RDAR : 0; | 93 | - cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, |
44 | + s->regs[ENET_RDAR] = rx_ring_full ? 0 : ENET_RDAR_RDAR; | 94 | - arm_gt_ptimer_cb, cpu); |
95 | - cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, | ||
96 | - arm_gt_vtimer_cb, cpu); | ||
97 | - cpu->gt_timer[GTIMER_HYP] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, | ||
98 | - arm_gt_htimer_cb, cpu); | ||
99 | - cpu->gt_timer[GTIMER_SEC] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, | ||
100 | - arm_gt_stimer_cb, cpu); | ||
101 | + | ||
102 | + { | ||
103 | + uint64_t scale; | ||
104 | + | ||
105 | + if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { | ||
106 | + if (!cpu->gt_cntfrq_hz) { | ||
107 | + error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", | ||
108 | + cpu->gt_cntfrq_hz); | ||
109 | + return; | ||
110 | + } | ||
111 | + scale = gt_cntfrq_period_ns(cpu); | ||
112 | + } else { | ||
113 | + scale = GTIMER_SCALE; | ||
114 | + } | ||
115 | + | ||
116 | + cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, scale, | ||
117 | + arm_gt_ptimer_cb, cpu); | ||
118 | + cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, scale, | ||
119 | + arm_gt_vtimer_cb, cpu); | ||
120 | + cpu->gt_timer[GTIMER_HYP] = timer_new(QEMU_CLOCK_VIRTUAL, scale, | ||
121 | + arm_gt_htimer_cb, cpu); | ||
122 | + cpu->gt_timer[GTIMER_SEC] = timer_new(QEMU_CLOCK_VIRTUAL, scale, | ||
123 | + arm_gt_stimer_cb, cpu); | ||
124 | + } | ||
125 | #endif | ||
126 | |||
127 | cpu_exec_realizefn(cs, &local_err); | ||
128 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/target/arm/helper.c | ||
131 | +++ b/target/arm/helper.c | ||
132 | @@ -XXX,XX +XXX,XX @@ void arm_gt_stimer_cb(void *opaque) | ||
133 | gt_recalc_timer(cpu, GTIMER_SEC); | ||
45 | } | 134 | } |
46 | 135 | ||
47 | static void imx_eth_reset(DeviceState *d) | 136 | +static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaque) |
137 | +{ | ||
138 | + ARMCPU *cpu = env_archcpu(env); | ||
139 | + | ||
140 | + cpu->env.cp15.c14_cntfrq = cpu->gt_cntfrq_hz; | ||
141 | +} | ||
142 | + | ||
143 | static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
144 | /* Note that CNTFRQ is purely reads-as-written for the benefit | ||
145 | * of software; writing it doesn't actually change the timer frequency. | ||
146 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
147 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 0, | ||
148 | .access = PL1_RW | PL0_R, .accessfn = gt_cntfrq_access, | ||
149 | .fieldoffset = offsetof(CPUARMState, cp15.c14_cntfrq), | ||
150 | - .resetvalue = (1000 * 1000 * 1000) / GTIMER_SCALE, | ||
151 | + .resetfn = arm_gt_cntfrq_reset, | ||
152 | }, | ||
153 | /* overall control: mostly access permissions */ | ||
154 | { .name = "CNTKCTL", .state = ARM_CP_STATE_BOTH, | ||
48 | -- | 155 | -- |
49 | 2.7.4 | 156 | 2.20.1 |
50 | 157 | ||
51 | 158 | diff view generated by jsdifflib |
1 | Our copy of the nwfpe code for emulating of the old FPA11 floating | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | point unit doesn't check the coprocessor number in the instruction | ||
3 | when it emulates it. This means that we might treat some | ||
4 | instructions which should really UNDEF as being FPA11 instructions by | ||
5 | accident. | ||
6 | 2 | ||
7 | The kernel's copy of the nwfpe code doesn't make this error; I suspect | 3 | This matches the configuration set by u-boot on the AST2600. |
8 | the bug was noticed and fixed as part of the process of mainlining | ||
9 | the nwfpe code more than a decade ago. | ||
10 | 4 | ||
11 | Add a check that the coprocessor number (which is always in bits | 5 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> |
12 | [11:8] of the instruction) is either 1 or 2, which is where the | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | FPA11 lives. | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
14 | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | |
15 | Reported-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 080ca1267a09381c43cf3c50d434fb6c186f2b6e.1576215453.git-series.andrew@aj.id.au |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 11 | --- |
18 | linux-user/arm/nwfpe/fpa11.c | 9 +++++++++ | 12 | hw/arm/aspeed_ast2600.c | 3 +++ |
19 | 1 file changed, 9 insertions(+) | 13 | 1 file changed, 3 insertions(+) |
20 | 14 | ||
21 | diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c | 15 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c |
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/linux-user/arm/nwfpe/fpa11.c | 17 | --- a/hw/arm/aspeed_ast2600.c |
24 | +++ b/linux-user/arm/nwfpe/fpa11.c | 18 | +++ b/hw/arm/aspeed_ast2600.c |
25 | @@ -XXX,XX +XXX,XX @@ unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs) | 19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) |
26 | unsigned int nRc = 0; | 20 | object_property_set_int(OBJECT(&s->cpu[i]), aspeed_calc_affinity(i), |
27 | // unsigned long flags; | 21 | "mp-affinity", &error_abort); |
28 | FPA11 *fpa11; | 22 | |
29 | + unsigned int cp; | 23 | + object_property_set_int(OBJECT(&s->cpu[i]), 1125000000, "cntfrq", |
30 | // save_flags(flags); sti(); | 24 | + &error_abort); |
31 | |||
32 | + /* Check that this is really an FPA11 instruction: the coprocessor | ||
33 | + * field in bits [11:8] must be 1 or 2. | ||
34 | + */ | ||
35 | + cp = (opcode >> 8) & 0xf; | ||
36 | + if (cp != 1 && cp != 2) { | ||
37 | + return 0; | ||
38 | + } | ||
39 | + | 25 | + |
40 | qemufpa=qfpa; | 26 | /* |
41 | user_registers=qregs; | 27 | * TODO: the secondary CPUs are started and a boot helper |
42 | 28 | * is needed when using -kernel | |
43 | -- | 29 | -- |
44 | 2.7.4 | 30 | 2.20.1 |
45 | 31 | ||
46 | 32 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Simon Veith <sveith@amazon.de> |
---|---|---|---|
2 | 2 | ||
3 | Cc: Peter Maydell <peter.maydell@linaro.org> | 3 | In the SMMU_STRTAB_BASE register, the stream table base address only |
4 | Cc: Jason Wang <jasowang@redhat.com> | 4 | occupies bits [51:6]. Other bits, such as RA (bit [62]), must be masked |
5 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | out to obtain the base address. |
6 | |||
7 | The branch for 2-level stream tables correctly applies this mask by way | ||
8 | of SMMU_BASE_ADDR_MASK, but the one for linear stream tables does not. | ||
9 | |||
10 | Apply the missing mask in that case as well so that the correct stream | ||
11 | base address is used by guests which configure a linear stream table. | ||
12 | |||
13 | Linux guests are unaffected by this change because they choose a 2-level | ||
14 | stream table layout for the QEMU SMMUv3, based on the size of its stream | ||
15 | ID space. | ||
16 | |||
17 | ref. ARM IHI 0070C, section 6.3.23. | ||
18 | |||
19 | Signed-off-by: Simon Veith <sveith@amazon.de> | ||
20 | Acked-by: Eric Auger <eric.auger@redhat.com> | ||
21 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
22 | Message-id: 1576509312-13083-2-git-send-email-sveith@amazon.de | ||
23 | Cc: Eric Auger <eric.auger@redhat.com> | ||
6 | Cc: qemu-devel@nongnu.org | 24 | Cc: qemu-devel@nongnu.org |
7 | Cc: qemu-arm@nongnu.org | 25 | Cc: qemu-arm@nongnu.org |
8 | Cc: yurovsky@gmail.com | 26 | Acked-by: Eric Auger <eric.auger@redhat.com> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 29 | --- |
13 | hw/net/imx_fec.c | 2 +- | 30 | hw/arm/smmuv3.c | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 31 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 32 | ||
16 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 33 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
17 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/net/imx_fec.c | 35 | --- a/hw/arm/smmuv3.c |
19 | +++ b/hw/net/imx_fec.c | 36 | +++ b/hw/arm/smmuv3.c |
20 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | 37 | @@ -XXX,XX +XXX,XX @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, |
21 | size += 2; | 38 | } |
39 | addr = l2ptr + l2_ste_offset * sizeof(*ste); | ||
40 | } else { | ||
41 | - addr = s->strtab_base + sid * sizeof(*ste); | ||
42 | + addr = (s->strtab_base & SMMU_BASE_ADDR_MASK) + sid * sizeof(*ste); | ||
22 | } | 43 | } |
23 | 44 | ||
24 | - /* Huge frames are truncted. */ | 45 | if (smmu_get_ste(s, addr, ste, event)) { |
25 | + /* Huge frames are truncated. */ | ||
26 | if (size > s->regs[ENET_FTRL]) { | ||
27 | size = s->regs[ENET_FTRL]; | ||
28 | flags |= ENET_BD_TR | ENET_BD_LG; | ||
29 | -- | 46 | -- |
30 | 2.7.4 | 47 | 2.20.1 |
31 | 48 | ||
32 | 49 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Simon Veith <sveith@amazon.de> |
---|---|---|---|
2 | 2 | ||
3 | Use 'frame_size' instead of 'len' when calling qemu_send_packet(), | 3 | There are two issues with the current value of SMMU_BASE_ADDR_MASK: |
4 | failing to do so results in malformed packets send in case when that | ||
5 | packed is fragmented into multiple DMA transactions. | ||
6 | 4 | ||
7 | Cc: Peter Maydell <peter.maydell@linaro.org> | 5 | - At the lower end, we are clearing bits [4:0]. Per the SMMUv3 spec, |
8 | Cc: Jason Wang <jasowang@redhat.com> | 6 | we should also be treating bit 5 as zero in the base address. |
9 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | - At the upper end, we are clearing bits [63:48]. Per the SMMUv3 spec, |
8 | only bits [63:52] must be explicitly treated as zero. | ||
9 | |||
10 | Update the SMMU_BASE_ADDR_MASK value to mask out bits [63:52] and [5:0]. | ||
11 | |||
12 | ref. ARM IHI 0070C, section 6.3.23. | ||
13 | |||
14 | Signed-off-by: Simon Veith <sveith@amazon.de> | ||
15 | Acked-by: Eric Auger <eric.auger@redhat.com> | ||
16 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
17 | Message-id: 1576509312-13083-3-git-send-email-sveith@amazon.de | ||
18 | Cc: Eric Auger <eric.auger@redhat.com> | ||
10 | Cc: qemu-devel@nongnu.org | 19 | Cc: qemu-devel@nongnu.org |
11 | Cc: qemu-arm@nongnu.org | 20 | Cc: qemu-arm@nongnu.org |
12 | Cc: yurovsky@gmail.com | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 23 | --- |
17 | hw/net/imx_fec.c | 2 +- | 24 | hw/arm/smmuv3-internal.h | 2 +- |
18 | 1 file changed, 1 insertion(+), 1 deletion(-) | 25 | 1 file changed, 1 insertion(+), 1 deletion(-) |
19 | 26 | ||
20 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 27 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
21 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/net/imx_fec.c | 29 | --- a/hw/arm/smmuv3-internal.h |
23 | +++ b/hw/net/imx_fec.c | 30 | +++ b/hw/arm/smmuv3-internal.h |
24 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) | 31 | @@ -XXX,XX +XXX,XX @@ REG32(GERROR_IRQ_CFG2, 0x74) |
25 | } | 32 | |
26 | /* Last buffer in frame. */ | 33 | #define A_STRTAB_BASE 0x80 /* 64b */ |
27 | 34 | ||
28 | - qemu_send_packet(qemu_get_queue(s->nic), s->frame, len); | 35 | -#define SMMU_BASE_ADDR_MASK 0xffffffffffe0 |
29 | + qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size); | 36 | +#define SMMU_BASE_ADDR_MASK 0xfffffffffffc0 |
30 | ptr = s->frame; | 37 | |
31 | 38 | REG32(STRTAB_BASE_CFG, 0x88) | |
32 | frame_size = 0; | 39 | FIELD(STRTAB_BASE_CFG, FMT, 16, 2) |
33 | -- | 40 | -- |
34 | 2.7.4 | 41 | 2.20.1 |
35 | 42 | ||
36 | 43 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Simon Veith <sveith@amazon.de> |
---|---|---|---|
2 | 2 | ||
3 | Frame truncation length, TRUNC_FL, is determined by the contents of | 3 | When checking whether a stream ID is in range of the stream table, we |
4 | ENET_FTRL register, so convert the code to use it instead of a | 4 | have so far been only checking it against our implementation limit |
5 | hardcoded constant. | 5 | (SMMU_IDR1_SIDSIZE). However, the guest can program the |
6 | STRTAB_BASE_CFG.LOG2SIZE field to a size that is smaller than this | ||
7 | limit. | ||
6 | 8 | ||
7 | To avoid the case where TRUNC_FL is greater that ENET_MAX_FRAME_SIZE, | 9 | Check the stream ID against this limit as well to match the hardware |
8 | increase the value of the latter to its theoretical maximum of 16K. | 10 | behavior of raising C_BAD_STREAMID events in case the limit is exceeded. |
11 | Also, ensure that we do not go one entry beyond the end of the table by | ||
12 | checking that its index is strictly smaller than the table size. | ||
9 | 13 | ||
10 | Cc: Peter Maydell <peter.maydell@linaro.org> | 14 | ref. ARM IHI 0070C, section 6.3.24. |
11 | Cc: Jason Wang <jasowang@redhat.com> | 15 | |
12 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | 16 | Signed-off-by: Simon Veith <sveith@amazon.de> |
17 | Acked-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
19 | Message-id: 1576509312-13083-4-git-send-email-sveith@amazon.de | ||
20 | Cc: Eric Auger <eric.auger@redhat.com> | ||
13 | Cc: qemu-devel@nongnu.org | 21 | Cc: qemu-devel@nongnu.org |
14 | Cc: qemu-arm@nongnu.org | 22 | Cc: qemu-arm@nongnu.org |
15 | Cc: yurovsky@gmail.com | ||
16 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 25 | --- |
20 | include/hw/net/imx_fec.h | 3 ++- | 26 | hw/arm/smmuv3.c | 8 ++++++-- |
21 | hw/net/imx_fec.c | 4 ++-- | 27 | 1 file changed, 6 insertions(+), 2 deletions(-) |
22 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
23 | 28 | ||
24 | diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h | 29 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
25 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/net/imx_fec.h | 31 | --- a/hw/arm/smmuv3.c |
27 | +++ b/include/hw/net/imx_fec.h | 32 | +++ b/hw/arm/smmuv3.c |
28 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, |
29 | #define ENET_TCCR3 393 | 34 | SMMUEventInfo *event) |
30 | #define ENET_MAX 400 | 35 | { |
31 | 36 | dma_addr_t addr; | |
32 | -#define ENET_MAX_FRAME_SIZE 2032 | 37 | + uint32_t log2size; |
33 | 38 | int ret; | |
34 | /* EIR and EIMR */ | 39 | |
35 | #define ENET_INT_HB (1 << 31) | 40 | trace_smmuv3_find_ste(sid, s->features, s->sid_split); |
36 | @@ -XXX,XX +XXX,XX @@ | 41 | - /* Check SID range */ |
37 | #define ENET_RCR_NLC (1 << 30) | 42 | - if (sid > (1 << SMMU_IDR1_SIDSIZE)) { |
38 | #define ENET_RCR_GRS (1 << 31) | 43 | + log2size = FIELD_EX32(s->strtab_base_cfg, STRTAB_BASE_CFG, LOG2SIZE); |
39 | 44 | + /* | |
40 | +#define ENET_MAX_FRAME_SIZE (1 << ENET_RCR_MAX_FL_LENGTH) | 45 | + * Check SID range against both guest-configured and implementation limits |
41 | + | 46 | + */ |
42 | /* TCR */ | 47 | + if (sid >= (1 << MIN(log2size, SMMU_IDR1_SIDSIZE))) { |
43 | #define ENET_TCR_GTS (1 << 0) | 48 | event->type = SMMU_EVT_C_BAD_STREAMID; |
44 | #define ENET_TCR_FDEN (1 << 2) | 49 | return -EINVAL; |
45 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/net/imx_fec.c | ||
48 | +++ b/hw/net/imx_fec.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | ||
50 | crc_ptr = (uint8_t *) &crc; | ||
51 | |||
52 | /* Huge frames are truncted. */ | ||
53 | - if (size > ENET_MAX_FRAME_SIZE) { | ||
54 | - size = ENET_MAX_FRAME_SIZE; | ||
55 | + if (size > s->regs[ENET_FTRL]) { | ||
56 | + size = s->regs[ENET_FTRL]; | ||
57 | flags |= ENET_BD_TR | ENET_BD_LG; | ||
58 | } | 50 | } |
59 | |||
60 | -- | 51 | -- |
61 | 2.7.4 | 52 | 2.20.1 |
62 | 53 | ||
63 | 54 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Simon Veith <sveith@amazon.de> |
---|---|---|---|
2 | 2 | ||
3 | In current implementation, packet queue flushing logic seem to suffer | 3 | Per the specification, and as observed in hardware, the SMMUv3 aligns |
4 | from a deadlock like scenario if a packet is received by the interface | 4 | the SMMU_STRTAB_BASE address to the size of the table by masking out the |
5 | before before Rx ring is initialized by Guest's driver. Consider the | 5 | respective least significant bits in the ADDR field. |
6 | following sequence of events: | ||
7 | 6 | ||
8 | 1. A QEMU instance is started against a TAP device on Linux | 7 | Apply this masking logic to our smmu_find_ste() lookup function per the |
9 | host, running Linux guest, e. g., something to the effect | 8 | specification. |
10 | of: | ||
11 | 9 | ||
12 | qemu-system-arm \ | 10 | ref. ARM IHI 0070C, section 6.3.23. |
13 | -net nic,model=imx.fec,netdev=lan0 \ | ||
14 | netdev tap,id=lan0,ifname=tap0,script=no,downscript=no \ | ||
15 | ... rest of the arguments ... | ||
16 | 11 | ||
17 | 2. Once QEMU starts, but before guest reaches the point where | 12 | Signed-off-by: Simon Veith <sveith@amazon.de> |
18 | FEC deriver is done initializing the HW, Guest, via TAP | 13 | Acked-by: Eric Auger <eric.auger@redhat.com> |
19 | interface, receives a number of multicast MDNS packets from | 14 | Tested-by: Eric Auger <eric.auger@redhat.com> |
20 | Host (not necessarily true for every OS, but it happens at | 15 | Message-id: 1576509312-13083-5-git-send-email-sveith@amazon.de |
21 | least on Fedora 25) | 16 | Cc: Eric Auger <eric.auger@redhat.com> |
22 | |||
23 | 3. Recieving a packet in such a state results in | ||
24 | imx_eth_can_receive() returning '0', which in turn causes | ||
25 | tap_send() to disable corresponding event (tap.c:203) | ||
26 | |||
27 | 4. Once Guest's driver reaches the point where it is ready to | ||
28 | recieve packets it prepares Rx ring descriptors and writes | ||
29 | ENET_RDAR_RDAR to ENET_RDAR register to indicate to HW that | ||
30 | more descriptors are ready. And at this points emulation | ||
31 | layer does this: | ||
32 | |||
33 | s->regs[index] = ENET_RDAR_RDAR; | ||
34 | imx_eth_enable_rx(s); | ||
35 | |||
36 | which, combined with: | ||
37 | |||
38 | if (!s->regs[ENET_RDAR]) { | ||
39 | qemu_flush_queued_packets(qemu_get_queue(s->nic)); | ||
40 | } | ||
41 | |||
42 | results in Rx queue never being flushed and corresponding | ||
43 | I/O event beign disabled. | ||
44 | |||
45 | To prevent the problem, change the code to always flush packet queue | ||
46 | when ENET_RDAR transitions 0 -> ENET_RDAR_RDAR. | ||
47 | |||
48 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
49 | Cc: Jason Wang <jasowang@redhat.com> | ||
50 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
51 | Cc: qemu-devel@nongnu.org | 17 | Cc: qemu-devel@nongnu.org |
52 | Cc: qemu-arm@nongnu.org | 18 | Cc: qemu-arm@nongnu.org |
53 | Cc: yurovsky@gmail.com | ||
54 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
55 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
56 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
57 | --- | 21 | --- |
58 | hw/net/imx_fec.c | 12 ++++++------ | 22 | hw/arm/smmuv3.c | 18 ++++++++++++++---- |
59 | 1 file changed, 6 insertions(+), 6 deletions(-) | 23 | 1 file changed, 14 insertions(+), 4 deletions(-) |
60 | 24 | ||
61 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 25 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
62 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
63 | --- a/hw/net/imx_fec.c | 27 | --- a/hw/arm/smmuv3.c |
64 | +++ b/hw/net/imx_fec.c | 28 | +++ b/hw/arm/smmuv3.c |
65 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_do_tx(IMXFECState *s) | 29 | @@ -XXX,XX +XXX,XX @@ bad_ste: |
30 | static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, | ||
31 | SMMUEventInfo *event) | ||
32 | { | ||
33 | - dma_addr_t addr; | ||
34 | + dma_addr_t addr, strtab_base; | ||
35 | uint32_t log2size; | ||
36 | + int strtab_size_shift; | ||
37 | int ret; | ||
38 | |||
39 | trace_smmuv3_find_ste(sid, s->features, s->sid_split); | ||
40 | @@ -XXX,XX +XXX,XX @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, | ||
66 | } | 41 | } |
67 | } | 42 | if (s->features & SMMU_FEATURE_2LVL_STE) { |
68 | 43 | int l1_ste_offset, l2_ste_offset, max_l2_ste, span; | |
69 | -static void imx_eth_enable_rx(IMXFECState *s) | 44 | - dma_addr_t strtab_base, l1ptr, l2ptr; |
70 | +static void imx_eth_enable_rx(IMXFECState *s, bool flush) | 45 | + dma_addr_t l1ptr, l2ptr; |
71 | { | 46 | STEDesc l1std; |
72 | IMXFECBufDesc bd; | 47 | |
73 | bool rx_ring_full; | 48 | - strtab_base = s->strtab_base & SMMU_BASE_ADDR_MASK; |
74 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_enable_rx(IMXFECState *s) | 49 | + /* |
75 | 50 | + * Align strtab base address to table size. For this purpose, assume it | |
76 | if (rx_ring_full) { | 51 | + * is not bounded by SMMU_IDR1_SIDSIZE. |
77 | FEC_PRINTF("RX buffer full\n"); | 52 | + */ |
78 | - } else if (!s->regs[ENET_RDAR]) { | 53 | + strtab_size_shift = MAX(5, (int)log2size - s->sid_split - 1 + 3); |
79 | + } else if (flush) { | 54 | + strtab_base = s->strtab_base & SMMU_BASE_ADDR_MASK & |
80 | qemu_flush_queued_packets(qemu_get_queue(s->nic)); | 55 | + ~MAKE_64BIT_MASK(0, strtab_size_shift); |
56 | l1_ste_offset = sid >> s->sid_split; | ||
57 | l2_ste_offset = sid & ((1 << s->sid_split) - 1); | ||
58 | l1ptr = (dma_addr_t)(strtab_base + l1_ste_offset * sizeof(l1std)); | ||
59 | @@ -XXX,XX +XXX,XX @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, | ||
60 | } | ||
61 | addr = l2ptr + l2_ste_offset * sizeof(*ste); | ||
62 | } else { | ||
63 | - addr = (s->strtab_base & SMMU_BASE_ADDR_MASK) + sid * sizeof(*ste); | ||
64 | + strtab_size_shift = log2size + 5; | ||
65 | + strtab_base = s->strtab_base & SMMU_BASE_ADDR_MASK & | ||
66 | + ~MAKE_64BIT_MASK(0, strtab_size_shift); | ||
67 | + addr = strtab_base + sid * sizeof(*ste); | ||
81 | } | 68 | } |
82 | 69 | ||
83 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, | 70 | if (smmu_get_ste(s, addr, ste, event)) { |
84 | if (s->regs[ENET_ECR] & ENET_ECR_ETHEREN) { | ||
85 | if (!s->regs[index]) { | ||
86 | s->regs[index] = ENET_RDAR_RDAR; | ||
87 | - imx_eth_enable_rx(s); | ||
88 | + imx_eth_enable_rx(s, true); | ||
89 | } | ||
90 | } else { | ||
91 | s->regs[index] = 0; | ||
92 | @@ -XXX,XX +XXX,XX @@ static int imx_eth_can_receive(NetClientState *nc) | ||
93 | |||
94 | FEC_PRINTF("\n"); | ||
95 | |||
96 | - return s->regs[ENET_RDAR] ? 1 : 0; | ||
97 | + return !!s->regs[ENET_RDAR]; | ||
98 | } | ||
99 | |||
100 | static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, | ||
101 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, | ||
102 | } | ||
103 | } | ||
104 | s->rx_descriptor = addr; | ||
105 | - imx_eth_enable_rx(s); | ||
106 | + imx_eth_enable_rx(s, false); | ||
107 | imx_eth_update(s); | ||
108 | return len; | ||
109 | } | ||
110 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | ||
111 | } | ||
112 | } | ||
113 | s->rx_descriptor = addr; | ||
114 | - imx_eth_enable_rx(s); | ||
115 | + imx_eth_enable_rx(s, false); | ||
116 | imx_eth_update(s); | ||
117 | return len; | ||
118 | } | ||
119 | -- | 71 | -- |
120 | 2.7.4 | 72 | 2.20.1 |
121 | 73 | ||
122 | 74 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Simon Veith <sveith@amazon.de> |
---|---|---|---|
2 | 2 | ||
3 | Make Tx frame assembly buffer to be a paort of IMXFECState structure | 3 | The bit offsets in the EVT_SET_ADDR2 macro do not match those specified |
4 | to avoid a concern about having large data buffer on the stack. | 4 | in the ARM SMMUv3 Architecture Specification. In all events that use |
5 | this macro, e.g. F_WALK_EABT, the faulting fetch address or IPA actually | ||
6 | occupies the 32-bit words 6 and 7 in the event record contiguously, with | ||
7 | the upper and lower unused bits clear due to alignment or maximum | ||
8 | supported address bits. How many bits are clear depends on the | ||
9 | individual event type. | ||
5 | 10 | ||
6 | Cc: Peter Maydell <peter.maydell@linaro.org> | 11 | Update the macro to write to the correct words in the event record so |
7 | Cc: Jason Wang <jasowang@redhat.com> | 12 | that guest drivers can obtain accurate address information on events. |
8 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | |
14 | ref. ARM IHI 0070C, sections 7.3.12 through 7.3.16. | ||
15 | |||
16 | Signed-off-by: Simon Veith <sveith@amazon.de> | ||
17 | Acked-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
19 | Message-id: 1576509312-13083-6-git-send-email-sveith@amazon.de | ||
20 | Cc: Eric Auger <eric.auger@redhat.com> | ||
9 | Cc: qemu-devel@nongnu.org | 21 | Cc: qemu-devel@nongnu.org |
10 | Cc: qemu-arm@nongnu.org | 22 | Cc: qemu-arm@nongnu.org |
11 | Cc: yurovsky@gmail.com | 23 | Acked-by: Eric Auger <eric.auger@redhat.com> |
12 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 26 | --- |
16 | include/hw/net/imx_fec.h | 3 +++ | 27 | hw/arm/smmuv3-internal.h | 4 ++-- |
17 | hw/net/imx_fec.c | 22 +++++++++++----------- | 28 | 1 file changed, 2 insertions(+), 2 deletions(-) |
18 | 2 files changed, 14 insertions(+), 11 deletions(-) | ||
19 | 29 | ||
20 | diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h | 30 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
21 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/net/imx_fec.h | 32 | --- a/hw/arm/smmuv3-internal.h |
23 | +++ b/include/hw/net/imx_fec.h | 33 | +++ b/hw/arm/smmuv3-internal.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct IMXFECState { | 34 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUEventInfo { |
25 | uint32_t phy_int_mask; | 35 | } while (0) |
26 | 36 | #define EVT_SET_ADDR2(x, addr) \ | |
27 | bool is_fec; | 37 | do { \ |
28 | + | 38 | - (x)->word[7] = deposit32((x)->word[7], 3, 29, addr >> 16); \ |
29 | + /* Buffer used to assemble a Tx frame */ | 39 | - (x)->word[7] = deposit32((x)->word[7], 0, 16, addr & 0xffff);\ |
30 | + uint8_t frame[ENET_MAX_FRAME_SIZE]; | 40 | + (x)->word[7] = (uint32_t)(addr >> 32); \ |
31 | } IMXFECState; | 41 | + (x)->word[6] = (uint32_t)(addr & 0xffffffff); \ |
32 | 42 | } while (0) | |
33 | #endif | 43 | |
34 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 44 | void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *event); |
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/net/imx_fec.c | ||
37 | +++ b/hw/net/imx_fec.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_update(IMXFECState *s) | ||
39 | static void imx_fec_do_tx(IMXFECState *s) | ||
40 | { | ||
41 | int frame_size = 0, descnt = 0; | ||
42 | - uint8_t frame[ENET_MAX_FRAME_SIZE]; | ||
43 | - uint8_t *ptr = frame; | ||
44 | + uint8_t *ptr = s->frame; | ||
45 | uint32_t addr = s->tx_descriptor; | ||
46 | |||
47 | while (descnt++ < IMX_MAX_DESC) { | ||
48 | @@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s) | ||
49 | frame_size += len; | ||
50 | if (bd.flags & ENET_BD_L) { | ||
51 | /* Last buffer in frame. */ | ||
52 | - qemu_send_packet(qemu_get_queue(s->nic), frame, frame_size); | ||
53 | - ptr = frame; | ||
54 | + qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size); | ||
55 | + ptr = s->frame; | ||
56 | frame_size = 0; | ||
57 | s->regs[ENET_EIR] |= ENET_INT_TXF; | ||
58 | } | ||
59 | @@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s) | ||
60 | static void imx_enet_do_tx(IMXFECState *s) | ||
61 | { | ||
62 | int frame_size = 0, descnt = 0; | ||
63 | - uint8_t frame[ENET_MAX_FRAME_SIZE]; | ||
64 | - uint8_t *ptr = frame; | ||
65 | + uint8_t *ptr = s->frame; | ||
66 | uint32_t addr = s->tx_descriptor; | ||
67 | |||
68 | while (descnt++ < IMX_MAX_DESC) { | ||
69 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s) | ||
70 | frame_size += len; | ||
71 | if (bd.flags & ENET_BD_L) { | ||
72 | if (bd.option & ENET_BD_PINS) { | ||
73 | - struct ip_header *ip_hd = PKT_GET_IP_HDR(frame); | ||
74 | + struct ip_header *ip_hd = PKT_GET_IP_HDR(s->frame); | ||
75 | if (IP_HEADER_VERSION(ip_hd) == 4) { | ||
76 | - net_checksum_calculate(frame, frame_size); | ||
77 | + net_checksum_calculate(s->frame, frame_size); | ||
78 | } | ||
79 | } | ||
80 | if (bd.option & ENET_BD_IINS) { | ||
81 | - struct ip_header *ip_hd = PKT_GET_IP_HDR(frame); | ||
82 | + struct ip_header *ip_hd = PKT_GET_IP_HDR(s->frame); | ||
83 | /* We compute checksum only for IPv4 frames */ | ||
84 | if (IP_HEADER_VERSION(ip_hd) == 4) { | ||
85 | uint16_t csum; | ||
86 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s) | ||
87 | } | ||
88 | } | ||
89 | /* Last buffer in frame. */ | ||
90 | - qemu_send_packet(qemu_get_queue(s->nic), frame, len); | ||
91 | - ptr = frame; | ||
92 | + | ||
93 | + qemu_send_packet(qemu_get_queue(s->nic), s->frame, len); | ||
94 | + ptr = s->frame; | ||
95 | + | ||
96 | frame_size = 0; | ||
97 | if (bd.option & ENET_BD_TX_INT) { | ||
98 | s->regs[ENET_EIR] |= ENET_INT_TXF; | ||
99 | -- | 45 | -- |
100 | 2.7.4 | 46 | 2.20.1 |
101 | 47 | ||
102 | 48 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Simon Veith <sveith@amazon.de> |
---|---|---|---|
2 | 2 | ||
3 | Cc: Peter Maydell <peter.maydell@linaro.org> | 3 | The smmuv3_record_event() function that generates the F_STE_FETCH error |
4 | Cc: Jason Wang <jasowang@redhat.com> | 4 | uses the EVT_SET_ADDR macro to record the fetch address, placing it in |
5 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | 32-bit words 4 and 5. |
6 | |||
7 | The correct position for this address is in words 6 and 7, per the | ||
8 | SMMUv3 Architecture Specification. | ||
9 | |||
10 | Update the function to use the EVT_SET_ADDR2 macro instead, which is the | ||
11 | macro intended for writing to these words. | ||
12 | |||
13 | ref. ARM IHI 0070C, section 7.3.4. | ||
14 | |||
15 | Signed-off-by: Simon Veith <sveith@amazon.de> | ||
16 | Acked-by: Eric Auger <eric.auger@redhat.com> | ||
17 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Message-id: 1576509312-13083-7-git-send-email-sveith@amazon.de | ||
19 | Cc: Eric Auger <eric.auger@redhat.com> | ||
6 | Cc: qemu-devel@nongnu.org | 20 | Cc: qemu-devel@nongnu.org |
7 | Cc: qemu-arm@nongnu.org | 21 | Cc: qemu-arm@nongnu.org |
8 | Cc: yurovsky@gmail.com | 22 | Acked-by: Eric Auger <eric.auger@redhat.com> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 25 | --- |
13 | hw/net/imx_fec.c | 2 +- | 26 | hw/arm/smmuv3.c | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 27 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 28 | ||
16 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 29 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
17 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/net/imx_fec.c | 31 | --- a/hw/arm/smmuv3.c |
19 | +++ b/hw/net/imx_fec.c | 32 | +++ b/hw/arm/smmuv3.c |
20 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | 33 | @@ -XXX,XX +XXX,XX @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info) |
21 | TYPE_IMX_FEC, __func__); | 34 | case SMMU_EVT_F_STE_FETCH: |
22 | break; | 35 | EVT_SET_SSID(&evt, info->u.f_ste_fetch.ssid); |
23 | } | 36 | EVT_SET_SSV(&evt, info->u.f_ste_fetch.ssv); |
24 | - buf_len = (size <= s->regs[ENET_MRBR]) ? size : s->regs[ENET_MRBR]; | 37 | - EVT_SET_ADDR(&evt, info->u.f_ste_fetch.addr); |
25 | + buf_len = MIN(size, s->regs[ENET_MRBR]); | 38 | + EVT_SET_ADDR2(&evt, info->u.f_ste_fetch.addr); |
26 | bd.length = buf_len; | 39 | break; |
27 | size -= buf_len; | 40 | case SMMU_EVT_C_BAD_STE: |
28 | 41 | EVT_SET_SSID(&evt, info->u.c_bad_ste.ssid); | |
29 | -- | 42 | -- |
30 | 2.7.4 | 43 | 2.20.1 |
31 | 44 | ||
32 | 45 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
2 | 1 | ||
3 | Needed to support latest Linux kernel driver which relies on that | ||
4 | functionality. | ||
5 | |||
6 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Cc: Jason Wang <jasowang@redhat.com> | ||
8 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Cc: qemu-devel@nongnu.org | ||
10 | Cc: qemu-arm@nongnu.org | ||
11 | Cc: yurovsky@gmail.com | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/net/imx_fec.h | 2 ++ | ||
17 | hw/net/imx_fec.c | 23 +++++++++++++++++++++++ | ||
18 | 2 files changed, 25 insertions(+) | ||
19 | |||
20 | diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/hw/net/imx_fec.h | ||
23 | +++ b/include/hw/net/imx_fec.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | #define ENET_TWFR_TFWR_LENGTH (6) | ||
26 | #define ENET_TWFR_STRFWD (1 << 8) | ||
27 | |||
28 | +#define ENET_RACC_SHIFT16 BIT(7) | ||
29 | + | ||
30 | /* Buffer Descriptor. */ | ||
31 | typedef struct { | ||
32 | uint16_t length; | ||
33 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/hw/net/imx_fec.c | ||
36 | +++ b/hw/net/imx_fec.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | ||
38 | uint8_t *crc_ptr; | ||
39 | unsigned int buf_len; | ||
40 | size_t size = len; | ||
41 | + bool shift16 = s->regs[ENET_RACC] & ENET_RACC_SHIFT16; | ||
42 | |||
43 | FEC_PRINTF("len %d\n", (int)size); | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | ||
46 | crc = cpu_to_be32(crc32(~0, buf, size)); | ||
47 | crc_ptr = (uint8_t *) &crc; | ||
48 | |||
49 | + if (shift16) { | ||
50 | + size += 2; | ||
51 | + } | ||
52 | + | ||
53 | /* Huge frames are truncted. */ | ||
54 | if (size > s->regs[ENET_FTRL]) { | ||
55 | size = s->regs[ENET_FTRL]; | ||
56 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | ||
57 | buf_len += size - 4; | ||
58 | } | ||
59 | buf_addr = bd.data; | ||
60 | + | ||
61 | + if (shift16) { | ||
62 | + /* | ||
63 | + * If SHIFT16 bit of ENETx_RACC register is set we need to | ||
64 | + * align the payload to 4-byte boundary. | ||
65 | + */ | ||
66 | + const uint8_t zeros[2] = { 0 }; | ||
67 | + | ||
68 | + dma_memory_write(&address_space_memory, buf_addr, | ||
69 | + zeros, sizeof(zeros)); | ||
70 | + | ||
71 | + buf_addr += sizeof(zeros); | ||
72 | + buf_len -= sizeof(zeros); | ||
73 | + | ||
74 | + /* We only do this once per Ethernet frame */ | ||
75 | + shift16 = false; | ||
76 | + } | ||
77 | + | ||
78 | dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); | ||
79 | buf += buf_len; | ||
80 | if (size < 4) { | ||
81 | -- | ||
82 | 2.7.4 | ||
83 | |||
84 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | More recent version of the IP block support more than one Tx DMA ring, | 3 | Instead of crashing in a confuse way, give some hint to the user |
4 | so add the code implementing that feature. | 4 | about why we aborted. He might report the issue without having |
5 | to use a debugger. | ||
5 | 6 | ||
6 | Cc: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Cc: Jason Wang <jasowang@redhat.com> | 8 | Message-id: 20191209134552.27733-1-philmd@redhat.com |
8 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Cc: qemu-devel@nongnu.org | 10 | Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com> |
10 | Cc: qemu-arm@nongnu.org | ||
11 | Cc: yurovsky@gmail.com | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 12 | --- |
16 | include/hw/net/imx_fec.h | 18 ++++++- | 13 | target/arm/helper.c | 18 +++++++++++++++--- |
17 | hw/net/imx_fec.c | 133 ++++++++++++++++++++++++++++++++++++++++------- | 14 | 1 file changed, 15 insertions(+), 3 deletions(-) |
18 | 2 files changed, 130 insertions(+), 21 deletions(-) | ||
19 | 15 | ||
20 | diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/net/imx_fec.h | 18 | --- a/target/arm/helper.c |
23 | +++ b/include/hw/net/imx_fec.h | 19 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) |
25 | #define ENET_TFWR 81 | 21 | env->hflags = rebuild_hflags_a64(env, el, fp_el, mmu_idx); |
26 | #define ENET_FRBR 83 | 22 | } |
27 | #define ENET_FRSR 84 | 23 | |
28 | +#define ENET_TDSR1 89 | 24 | +static inline void assert_hflags_rebuild_correctly(CPUARMState *env) |
29 | +#define ENET_TDSR2 92 | 25 | +{ |
30 | #define ENET_RDSR 96 | 26 | +#ifdef CONFIG_DEBUG_TCG |
31 | #define ENET_TDSR 97 | 27 | + uint32_t env_flags_current = env->hflags; |
32 | #define ENET_MRBR 98 | 28 | + uint32_t env_flags_rebuilt = rebuild_hflags_internal(env); |
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | #define ENET_FTRL 108 | ||
35 | #define ENET_TACC 112 | ||
36 | #define ENET_RACC 113 | ||
37 | +#define ENET_TDAR1 121 | ||
38 | +#define ENET_TDAR2 123 | ||
39 | #define ENET_MIIGSK_CFGR 192 | ||
40 | #define ENET_MIIGSK_ENR 194 | ||
41 | #define ENET_ATCR 256 | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #define ENET_INT_WAKEUP (1 << 17) | ||
44 | #define ENET_INT_TS_AVAIL (1 << 16) | ||
45 | #define ENET_INT_TS_TIMER (1 << 15) | ||
46 | +#define ENET_INT_TXF2 (1 << 7) | ||
47 | +#define ENET_INT_TXB2 (1 << 6) | ||
48 | +#define ENET_INT_TXF1 (1 << 3) | ||
49 | +#define ENET_INT_TXB1 (1 << 2) | ||
50 | |||
51 | #define ENET_INT_MAC (ENET_INT_HB | ENET_INT_BABR | ENET_INT_BABT | \ | ||
52 | ENET_INT_GRA | ENET_INT_TXF | ENET_INT_TXB | \ | ||
53 | ENET_INT_RXF | ENET_INT_RXB | ENET_INT_MII | \ | ||
54 | ENET_INT_EBERR | ENET_INT_LC | ENET_INT_RL | \ | ||
55 | ENET_INT_UN | ENET_INT_PLR | ENET_INT_WAKEUP | \ | ||
56 | - ENET_INT_TS_AVAIL) | ||
57 | + ENET_INT_TS_AVAIL | ENET_INT_TXF1 | \ | ||
58 | + ENET_INT_TXB1 | ENET_INT_TXF2 | ENET_INT_TXB2) | ||
59 | |||
60 | /* RDAR */ | ||
61 | #define ENET_RDAR_RDAR (1 << 24) | ||
62 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
63 | |||
64 | #define ENET_BD_BDU (1 << 31) | ||
65 | |||
66 | +#define ENET_TX_RING_NUM 3 | ||
67 | + | 29 | + |
68 | + | 30 | + if (unlikely(env_flags_current != env_flags_rebuilt)) { |
69 | typedef struct IMXFECState { | 31 | + fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", |
70 | /*< private >*/ | 32 | + env_flags_current, env_flags_rebuilt); |
71 | SysBusDevice parent_obj; | 33 | + abort(); |
72 | @@ -XXX,XX +XXX,XX @@ typedef struct IMXFECState { | 34 | + } |
73 | 35 | +#endif | |
74 | uint32_t regs[ENET_MAX]; | ||
75 | uint32_t rx_descriptor; | ||
76 | - uint32_t tx_descriptor; | ||
77 | + | ||
78 | + uint32_t tx_descriptor[ENET_TX_RING_NUM]; | ||
79 | + uint32_t tx_ring_num; | ||
80 | |||
81 | uint32_t phy_status; | ||
82 | uint32_t phy_control; | ||
83 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/hw/net/imx_fec.c | ||
86 | +++ b/hw/net/imx_fec.c | ||
87 | @@ -XXX,XX +XXX,XX @@ static const char *imx_eth_reg_name(IMXFECState *s, uint32_t index) | ||
88 | } | ||
89 | } | ||
90 | |||
91 | +/* | ||
92 | + * Versions of this device with more than one TX descriptor save the | ||
93 | + * 2nd and 3rd descriptors in a subsection, to maintain migration | ||
94 | + * compatibility with previous versions of the device that only | ||
95 | + * supported a single descriptor. | ||
96 | + */ | ||
97 | +static bool imx_eth_is_multi_tx_ring(void *opaque) | ||
98 | +{ | ||
99 | + IMXFECState *s = IMX_FEC(opaque); | ||
100 | + | ||
101 | + return s->tx_ring_num > 1; | ||
102 | +} | 36 | +} |
103 | + | 37 | + |
104 | +static const VMStateDescription vmstate_imx_eth_txdescs = { | 38 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, |
105 | + .name = "imx.fec/txdescs", | 39 | target_ulong *cs_base, uint32_t *pflags) |
106 | + .version_id = 1, | ||
107 | + .minimum_version_id = 1, | ||
108 | + .needed = imx_eth_is_multi_tx_ring, | ||
109 | + .fields = (VMStateField[]) { | ||
110 | + VMSTATE_UINT32(tx_descriptor[1], IMXFECState), | ||
111 | + VMSTATE_UINT32(tx_descriptor[2], IMXFECState), | ||
112 | + VMSTATE_END_OF_LIST() | ||
113 | + } | ||
114 | +}; | ||
115 | + | ||
116 | static const VMStateDescription vmstate_imx_eth = { | ||
117 | .name = TYPE_IMX_FEC, | ||
118 | .version_id = 2, | ||
119 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_eth = { | ||
120 | .fields = (VMStateField[]) { | ||
121 | VMSTATE_UINT32_ARRAY(regs, IMXFECState, ENET_MAX), | ||
122 | VMSTATE_UINT32(rx_descriptor, IMXFECState), | ||
123 | - VMSTATE_UINT32(tx_descriptor, IMXFECState), | ||
124 | - | ||
125 | + VMSTATE_UINT32(tx_descriptor[0], IMXFECState), | ||
126 | VMSTATE_UINT32(phy_status, IMXFECState), | ||
127 | VMSTATE_UINT32(phy_control, IMXFECState), | ||
128 | VMSTATE_UINT32(phy_advertise, IMXFECState), | ||
129 | VMSTATE_UINT32(phy_int, IMXFECState), | ||
130 | VMSTATE_UINT32(phy_int_mask, IMXFECState), | ||
131 | VMSTATE_END_OF_LIST() | ||
132 | - } | ||
133 | + }, | ||
134 | + .subsections = (const VMStateDescription * []) { | ||
135 | + &vmstate_imx_eth_txdescs, | ||
136 | + NULL | ||
137 | + }, | ||
138 | }; | ||
139 | |||
140 | #define PHY_INT_ENERGYON (1 << 7) | ||
141 | @@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s) | ||
142 | { | 40 | { |
143 | int frame_size = 0, descnt = 0; | 41 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, |
144 | uint8_t *ptr = s->frame; | 42 | uint32_t pstate_for_ss; |
145 | - uint32_t addr = s->tx_descriptor; | 43 | |
146 | + uint32_t addr = s->tx_descriptor[0]; | 44 | *cs_base = 0; |
147 | 45 | -#ifdef CONFIG_DEBUG_TCG | |
148 | while (descnt++ < IMX_MAX_DESC) { | 46 | - assert(flags == rebuild_hflags_internal(env)); |
149 | IMXFECBufDesc bd; | 47 | -#endif |
150 | @@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s) | 48 | + assert_hflags_rebuild_correctly(env); |
151 | } | 49 | |
152 | } | 50 | if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) { |
153 | 51 | *pc = env->pc; | |
154 | - s->tx_descriptor = addr; | ||
155 | + s->tx_descriptor[0] = addr; | ||
156 | |||
157 | imx_eth_update(s); | ||
158 | } | ||
159 | |||
160 | -static void imx_enet_do_tx(IMXFECState *s) | ||
161 | +static void imx_enet_do_tx(IMXFECState *s, uint32_t index) | ||
162 | { | ||
163 | int frame_size = 0, descnt = 0; | ||
164 | + | ||
165 | uint8_t *ptr = s->frame; | ||
166 | - uint32_t addr = s->tx_descriptor; | ||
167 | + uint32_t addr, int_txb, int_txf, tdsr; | ||
168 | + size_t ring; | ||
169 | + | ||
170 | + switch (index) { | ||
171 | + case ENET_TDAR: | ||
172 | + ring = 0; | ||
173 | + int_txb = ENET_INT_TXB; | ||
174 | + int_txf = ENET_INT_TXF; | ||
175 | + tdsr = ENET_TDSR; | ||
176 | + break; | ||
177 | + case ENET_TDAR1: | ||
178 | + ring = 1; | ||
179 | + int_txb = ENET_INT_TXB1; | ||
180 | + int_txf = ENET_INT_TXF1; | ||
181 | + tdsr = ENET_TDSR1; | ||
182 | + break; | ||
183 | + case ENET_TDAR2: | ||
184 | + ring = 2; | ||
185 | + int_txb = ENET_INT_TXB2; | ||
186 | + int_txf = ENET_INT_TXF2; | ||
187 | + tdsr = ENET_TDSR2; | ||
188 | + break; | ||
189 | + default: | ||
190 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
191 | + "%s: bogus value for index %x\n", | ||
192 | + __func__, index); | ||
193 | + abort(); | ||
194 | + break; | ||
195 | + } | ||
196 | + | ||
197 | + addr = s->tx_descriptor[ring]; | ||
198 | |||
199 | while (descnt++ < IMX_MAX_DESC) { | ||
200 | IMXENETBufDesc bd; | ||
201 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s) | ||
202 | |||
203 | frame_size = 0; | ||
204 | if (bd.option & ENET_BD_TX_INT) { | ||
205 | - s->regs[ENET_EIR] |= ENET_INT_TXF; | ||
206 | + s->regs[ENET_EIR] |= int_txf; | ||
207 | } | ||
208 | } | ||
209 | if (bd.option & ENET_BD_TX_INT) { | ||
210 | - s->regs[ENET_EIR] |= ENET_INT_TXB; | ||
211 | + s->regs[ENET_EIR] |= int_txb; | ||
212 | } | ||
213 | bd.flags &= ~ENET_BD_R; | ||
214 | /* Write back the modified descriptor. */ | ||
215 | imx_enet_write_bd(&bd, addr); | ||
216 | /* Advance to the next descriptor. */ | ||
217 | if ((bd.flags & ENET_BD_W) != 0) { | ||
218 | - addr = s->regs[ENET_TDSR]; | ||
219 | + addr = s->regs[tdsr]; | ||
220 | } else { | ||
221 | addr += sizeof(bd); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | - s->tx_descriptor = addr; | ||
226 | + s->tx_descriptor[ring] = addr; | ||
227 | |||
228 | imx_eth_update(s); | ||
229 | } | ||
230 | |||
231 | -static void imx_eth_do_tx(IMXFECState *s) | ||
232 | +static void imx_eth_do_tx(IMXFECState *s, uint32_t index) | ||
233 | { | ||
234 | if (!s->is_fec && (s->regs[ENET_ECR] & ENET_ECR_EN1588)) { | ||
235 | - imx_enet_do_tx(s); | ||
236 | + imx_enet_do_tx(s, index); | ||
237 | } else { | ||
238 | imx_fec_do_tx(s); | ||
239 | } | ||
240 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_reset(DeviceState *d) | ||
241 | } | ||
242 | |||
243 | s->rx_descriptor = 0; | ||
244 | - s->tx_descriptor = 0; | ||
245 | + memset(s->tx_descriptor, 0, sizeof(s->tx_descriptor)); | ||
246 | |||
247 | /* We also reset the PHY */ | ||
248 | phy_reset(s); | ||
249 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, | ||
250 | unsigned size) | ||
251 | { | ||
252 | IMXFECState *s = IMX_FEC(opaque); | ||
253 | + const bool single_tx_ring = !imx_eth_is_multi_tx_ring(s); | ||
254 | uint32_t index = offset >> 2; | ||
255 | |||
256 | FEC_PRINTF("reg[%s] <= 0x%" PRIx32 "\n", imx_eth_reg_name(s, index), | ||
257 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, | ||
258 | s->regs[index] = 0; | ||
259 | } | ||
260 | break; | ||
261 | - case ENET_TDAR: | ||
262 | + case ENET_TDAR1: /* FALLTHROUGH */ | ||
263 | + case ENET_TDAR2: /* FALLTHROUGH */ | ||
264 | + if (unlikely(single_tx_ring)) { | ||
265 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
266 | + "[%s]%s: trying to access TDAR2 or TDAR1\n", | ||
267 | + TYPE_IMX_FEC, __func__); | ||
268 | + return; | ||
269 | + } | ||
270 | + case ENET_TDAR: /* FALLTHROUGH */ | ||
271 | if (s->regs[ENET_ECR] & ENET_ECR_ETHEREN) { | ||
272 | s->regs[index] = ENET_TDAR_TDAR; | ||
273 | - imx_eth_do_tx(s); | ||
274 | + imx_eth_do_tx(s, index); | ||
275 | } | ||
276 | s->regs[index] = 0; | ||
277 | break; | ||
278 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, | ||
279 | if ((s->regs[index] & ENET_ECR_ETHEREN) == 0) { | ||
280 | s->regs[ENET_RDAR] = 0; | ||
281 | s->rx_descriptor = s->regs[ENET_RDSR]; | ||
282 | - s->regs[ENET_TDAR] = 0; | ||
283 | - s->tx_descriptor = s->regs[ENET_TDSR]; | ||
284 | + s->regs[ENET_TDAR] = 0; | ||
285 | + s->regs[ENET_TDAR1] = 0; | ||
286 | + s->regs[ENET_TDAR2] = 0; | ||
287 | + s->tx_descriptor[0] = s->regs[ENET_TDSR]; | ||
288 | + s->tx_descriptor[1] = s->regs[ENET_TDSR1]; | ||
289 | + s->tx_descriptor[2] = s->regs[ENET_TDSR2]; | ||
290 | } | ||
291 | break; | ||
292 | case ENET_MMFR: | ||
293 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, | ||
294 | } else { | ||
295 | s->regs[index] = value & ~7; | ||
296 | } | ||
297 | - s->tx_descriptor = s->regs[index]; | ||
298 | + s->tx_descriptor[0] = s->regs[index]; | ||
299 | + break; | ||
300 | + case ENET_TDSR1: | ||
301 | + if (unlikely(single_tx_ring)) { | ||
302 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
303 | + "[%s]%s: trying to access TDSR1\n", | ||
304 | + TYPE_IMX_FEC, __func__); | ||
305 | + return; | ||
306 | + } | ||
307 | + | ||
308 | + s->regs[index] = value & ~7; | ||
309 | + s->tx_descriptor[1] = s->regs[index]; | ||
310 | + break; | ||
311 | + case ENET_TDSR2: | ||
312 | + if (unlikely(single_tx_ring)) { | ||
313 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
314 | + "[%s]%s: trying to access TDSR2\n", | ||
315 | + TYPE_IMX_FEC, __func__); | ||
316 | + return; | ||
317 | + } | ||
318 | + | ||
319 | + s->regs[index] = value & ~7; | ||
320 | + s->tx_descriptor[2] = s->regs[index]; | ||
321 | break; | ||
322 | case ENET_MRBR: | ||
323 | s->regs[index] = value & 0x00003ff0; | ||
324 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_realize(DeviceState *dev, Error **errp) | ||
325 | |||
326 | static Property imx_eth_properties[] = { | ||
327 | DEFINE_NIC_PROPERTIES(IMXFECState, conf), | ||
328 | + DEFINE_PROP_UINT32("tx-ring-num", IMXFECState, tx_ring_num, 1), | ||
329 | DEFINE_PROP_END_OF_LIST(), | ||
330 | }; | ||
331 | |||
332 | -- | 52 | -- |
333 | 2.7.4 | 53 | 2.20.1 |
334 | 54 | ||
335 | 55 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
2 | 1 | ||
3 | Some i.MX SoCs (e.g. i.MX7) have FEC registers going as far as offset | ||
4 | 0x614, so to avoid getting aborts when accessing those on QEMU, extend | ||
5 | the register file to cover FSL_IMX25_FEC_SIZE(16K) of address space | ||
6 | instead of just 1K. | ||
7 | |||
8 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Cc: Jason Wang <jasowang@redhat.com> | ||
10 | Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Cc: qemu-devel@nongnu.org | ||
12 | Cc: qemu-arm@nongnu.org | ||
13 | Cc: yurovsky@gmail.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | include/hw/arm/fsl-imx25.h | 1 - | ||
19 | include/hw/net/imx_fec.h | 1 + | ||
20 | hw/net/imx_fec.c | 2 +- | ||
21 | 3 files changed, 2 insertions(+), 2 deletions(-) | ||
22 | |||
23 | diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/include/hw/arm/fsl-imx25.h | ||
26 | +++ b/include/hw/arm/fsl-imx25.h | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX25State { | ||
28 | #define FSL_IMX25_UART5_ADDR 0x5002C000 | ||
29 | #define FSL_IMX25_UART5_SIZE 0x4000 | ||
30 | #define FSL_IMX25_FEC_ADDR 0x50038000 | ||
31 | -#define FSL_IMX25_FEC_SIZE 0x4000 | ||
32 | #define FSL_IMX25_CCM_ADDR 0x53F80000 | ||
33 | #define FSL_IMX25_CCM_SIZE 0x4000 | ||
34 | #define FSL_IMX25_GPT4_ADDR 0x53F84000 | ||
35 | diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/include/hw/net/imx_fec.h | ||
38 | +++ b/include/hw/net/imx_fec.h | ||
39 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
40 | |||
41 | #define ENET_TX_RING_NUM 3 | ||
42 | |||
43 | +#define FSL_IMX25_FEC_SIZE 0x4000 | ||
44 | |||
45 | typedef struct IMXFECState { | ||
46 | /*< private >*/ | ||
47 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/net/imx_fec.c | ||
50 | +++ b/hw/net/imx_fec.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_realize(DeviceState *dev, Error **errp) | ||
52 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
53 | |||
54 | memory_region_init_io(&s->iomem, OBJECT(dev), &imx_eth_ops, s, | ||
55 | - TYPE_IMX_FEC, 0x400); | ||
56 | + TYPE_IMX_FEC, FSL_IMX25_FEC_SIZE); | ||
57 | sysbus_init_mmio(sbd, &s->iomem); | ||
58 | sysbus_init_irq(sbd, &s->irq[0]); | ||
59 | sysbus_init_irq(sbd, &s->irq[1]); | ||
60 | -- | ||
61 | 2.7.4 | ||
62 | |||
63 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | After setting CP15 bits in arm_set_cpu_on() the cached hflags must |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | be rebuild to reflect the changed processor state. Without rebuilding, |
5 | Message-id: 20180103224208.30291-2-f4bug@amsat.org | 5 | the cached hflags would be inconsistent until the next call to |
6 | arm_rebuild_hflags(). When QEMU is compiled with debugging enabled | ||
7 | (--enable-debug), this problem is captured shortly after the first | ||
8 | call to arm_set_cpu_on() for CPUs running in ARM 32-bit non-secure mode: | ||
9 | |||
10 | qemu-system-arm: target/arm/helper.c:11359: cpu_get_tb_cpu_state: | ||
11 | Assertion `flags == rebuild_hflags_internal(env)' failed. | ||
12 | Aborted (core dumped) | ||
13 | |||
14 | Fixes: 0c7f8c43daf65 | ||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 19 | --- |
8 | hw/timer/pxa2xx_timer.c | 17 +++++++++++++++-- | 20 | target/arm/arm-powerctl.c | 3 +++ |
9 | 1 file changed, 15 insertions(+), 2 deletions(-) | 21 | 1 file changed, 3 insertions(+) |
10 | 22 | ||
11 | diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c | 23 | diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c |
12 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/timer/pxa2xx_timer.c | 25 | --- a/target/arm/arm-powerctl.c |
14 | +++ b/hw/timer/pxa2xx_timer.c | 26 | +++ b/target/arm/arm-powerctl.c |
15 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state, |
16 | #include "sysemu/sysemu.h" | 28 | target_cpu->env.regs[0] = info->context_id; |
17 | #include "hw/arm/pxa.h" | ||
18 | #include "hw/sysbus.h" | ||
19 | +#include "qemu/log.h" | ||
20 | |||
21 | #define OSMR0 0x00 | ||
22 | #define OSMR1 0x04 | ||
23 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_timer_read(void *opaque, hwaddr offset, | ||
24 | case OSNR: | ||
25 | return s->snapshot; | ||
26 | default: | ||
27 | + qemu_log_mask(LOG_UNIMP, | ||
28 | + "%s: unknown register 0x%02" HWADDR_PRIx "\n", | ||
29 | + __func__, offset); | ||
30 | + break; | ||
31 | badreg: | ||
32 | - hw_error("pxa2xx_timer_read: Bad offset " REG_FMT "\n", offset); | ||
33 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
34 | + "%s: incorrect register 0x%02" HWADDR_PRIx "\n", | ||
35 | + __func__, offset); | ||
36 | } | 29 | } |
37 | 30 | ||
38 | return 0; | 31 | + /* CP15 update requires rebuilding hflags */ |
39 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_timer_write(void *opaque, hwaddr offset, | 32 | + arm_rebuild_hflags(&target_cpu->env); |
40 | } | 33 | + |
41 | break; | 34 | /* Start the new CPU at the requested address */ |
42 | default: | 35 | cpu_set_pc(target_cpu_state, info->entry); |
43 | + qemu_log_mask(LOG_UNIMP, | ||
44 | + "%s: unknown register 0x%02" HWADDR_PRIx " " | ||
45 | + "(value 0x%08" PRIx64 ")\n", __func__, offset, value); | ||
46 | + break; | ||
47 | badreg: | ||
48 | - hw_error("pxa2xx_timer_write: Bad offset " REG_FMT "\n", offset); | ||
49 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
50 | + "%s: incorrect register 0x%02" HWADDR_PRIx " " | ||
51 | + "(value 0x%08" PRIx64 ")\n", __func__, offset, value); | ||
52 | } | ||
53 | } | ||
54 | 36 | ||
55 | -- | 37 | -- |
56 | 2.7.4 | 38 | 2.20.1 |
57 | 39 | ||
58 | 40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180104000156.30932-1-f4bug@amsat.org | ||
6 | [PMM: add missing include] | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | hw/sd/pxa2xx_mmci.c | 78 ++++++++++++++++++++++++++++++++++------------------- | ||
10 | hw/sd/trace-events | 4 +++ | ||
11 | 2 files changed, 54 insertions(+), 28 deletions(-) | ||
12 | |||
13 | diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/pxa2xx_mmci.c | ||
16 | +++ b/hw/sd/pxa2xx_mmci.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | #include "hw/qdev.h" | ||
19 | #include "hw/qdev-properties.h" | ||
20 | #include "qemu/error-report.h" | ||
21 | +#include "qemu/log.h" | ||
22 | +#include "trace.h" | ||
23 | |||
24 | #define TYPE_PXA2XX_MMCI "pxa2xx-mmci" | ||
25 | #define PXA2XX_MMCI(obj) OBJECT_CHECK(PXA2xxMMCIState, (obj), TYPE_PXA2XX_MMCI) | ||
26 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_mmci_wakequeues(PXA2xxMMCIState *s) | ||
27 | static uint64_t pxa2xx_mmci_read(void *opaque, hwaddr offset, unsigned size) | ||
28 | { | ||
29 | PXA2xxMMCIState *s = (PXA2xxMMCIState *) opaque; | ||
30 | - uint32_t ret; | ||
31 | + uint32_t ret = 0; | ||
32 | |||
33 | switch (offset) { | ||
34 | case MMC_STRPCL: | ||
35 | - return 0; | ||
36 | + break; | ||
37 | case MMC_STAT: | ||
38 | - return s->status; | ||
39 | + ret = s->status; | ||
40 | + break; | ||
41 | case MMC_CLKRT: | ||
42 | - return s->clkrt; | ||
43 | + ret = s->clkrt; | ||
44 | + break; | ||
45 | case MMC_SPI: | ||
46 | - return s->spi; | ||
47 | + ret = s->spi; | ||
48 | + break; | ||
49 | case MMC_CMDAT: | ||
50 | - return s->cmdat; | ||
51 | + ret = s->cmdat; | ||
52 | + break; | ||
53 | case MMC_RESTO: | ||
54 | - return s->resp_tout; | ||
55 | + ret = s->resp_tout; | ||
56 | + break; | ||
57 | case MMC_RDTO: | ||
58 | - return s->read_tout; | ||
59 | + ret = s->read_tout; | ||
60 | + break; | ||
61 | case MMC_BLKLEN: | ||
62 | - return s->blklen; | ||
63 | + ret = s->blklen; | ||
64 | + break; | ||
65 | case MMC_NUMBLK: | ||
66 | - return s->numblk; | ||
67 | + ret = s->numblk; | ||
68 | + break; | ||
69 | case MMC_PRTBUF: | ||
70 | - return 0; | ||
71 | + break; | ||
72 | case MMC_I_MASK: | ||
73 | - return s->intmask; | ||
74 | + ret = s->intmask; | ||
75 | + break; | ||
76 | case MMC_I_REG: | ||
77 | - return s->intreq; | ||
78 | + ret = s->intreq; | ||
79 | + break; | ||
80 | case MMC_CMD: | ||
81 | - return s->cmd | 0x40; | ||
82 | + ret = s->cmd | 0x40; | ||
83 | + break; | ||
84 | case MMC_ARGH: | ||
85 | - return s->arg >> 16; | ||
86 | + ret = s->arg >> 16; | ||
87 | + break; | ||
88 | case MMC_ARGL: | ||
89 | - return s->arg & 0xffff; | ||
90 | + ret = s->arg & 0xffff; | ||
91 | + break; | ||
92 | case MMC_RES: | ||
93 | - if (s->resp_len < 9) | ||
94 | - return s->resp_fifo[s->resp_len ++]; | ||
95 | - return 0; | ||
96 | + ret = (s->resp_len < 9) ? s->resp_fifo[s->resp_len++] : 0; | ||
97 | + break; | ||
98 | case MMC_RXFIFO: | ||
99 | - ret = 0; | ||
100 | while (size-- && s->rx_len) { | ||
101 | ret |= s->rx_fifo[s->rx_start++] << (size << 3); | ||
102 | s->rx_start &= 0x1f; | ||
103 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_mmci_read(void *opaque, hwaddr offset, unsigned size) | ||
104 | } | ||
105 | s->intreq &= ~INT_RXFIFO_REQ; | ||
106 | pxa2xx_mmci_fifo_update(s); | ||
107 | - return ret; | ||
108 | + break; | ||
109 | case MMC_RDWAIT: | ||
110 | - return 0; | ||
111 | + break; | ||
112 | case MMC_BLKS_REM: | ||
113 | - return s->numblk; | ||
114 | + ret = s->numblk; | ||
115 | + break; | ||
116 | default: | ||
117 | - hw_error("%s: Bad offset " REG_FMT "\n", __FUNCTION__, offset); | ||
118 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
119 | + "%s: incorrect register 0x%02" HWADDR_PRIx "\n", | ||
120 | + __func__, offset); | ||
121 | } | ||
122 | + trace_pxa2xx_mmci_read(size, offset, ret); | ||
123 | |||
124 | - return 0; | ||
125 | + return ret; | ||
126 | } | ||
127 | |||
128 | static void pxa2xx_mmci_write(void *opaque, | ||
129 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_mmci_write(void *opaque, | ||
130 | { | ||
131 | PXA2xxMMCIState *s = (PXA2xxMMCIState *) opaque; | ||
132 | |||
133 | + trace_pxa2xx_mmci_write(size, offset, value); | ||
134 | switch (offset) { | ||
135 | case MMC_STRPCL: | ||
136 | if (value & STRPCL_STRT_CLK) { | ||
137 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_mmci_write(void *opaque, | ||
138 | |||
139 | case MMC_SPI: | ||
140 | s->spi = value & 0xf; | ||
141 | - if (value & SPI_SPI_MODE) | ||
142 | - printf("%s: attempted to use card in SPI mode\n", __FUNCTION__); | ||
143 | + if (value & SPI_SPI_MODE) { | ||
144 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
145 | + "%s: attempted to use card in SPI mode\n", __func__); | ||
146 | + } | ||
147 | break; | ||
148 | |||
149 | case MMC_CMDAT: | ||
150 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_mmci_write(void *opaque, | ||
151 | break; | ||
152 | |||
153 | default: | ||
154 | - hw_error("%s: Bad offset " REG_FMT "\n", __FUNCTION__, offset); | ||
155 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
156 | + "%s: incorrect reg 0x%02" HWADDR_PRIx " " | ||
157 | + "(value 0x%08" PRIx64 ")\n", __func__, offset, value); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | diff --git a/hw/sd/trace-events b/hw/sd/trace-events | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/hw/sd/trace-events | ||
164 | +++ b/hw/sd/trace-events | ||
165 | @@ -XXX,XX +XXX,XX @@ | ||
166 | # hw/sd/milkymist-memcard.c | ||
167 | milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
168 | milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
169 | + | ||
170 | +# hw/sd/pxa2xx_mmci.c | ||
171 | +pxa2xx_mmci_read(uint8_t size, uint32_t addr, uint32_t value) "size %d addr 0x%02x value 0x%08x" | ||
172 | +pxa2xx_mmci_write(uint8_t size, uint32_t addr, uint32_t value) "size %d addr 0x%02x value 0x%08x" | ||
173 | -- | ||
174 | 2.7.4 | ||
175 | |||
176 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Refactor disas_thumb2_insn() so that it generates the code for raising | ||
2 | an UNDEF exception for invalid insns, rather than returning a flag | ||
3 | which the caller must check to see if it needs to generate the UNDEF | ||
4 | code. This brings the function in to line with the behaviour of | ||
5 | disas_thumb_insn() and disas_arm_insn(). | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 1513080506-17703-1-git-send-email-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/translate.c | 23 ++++++++++------------- | ||
12 | 1 file changed, 10 insertions(+), 13 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate.c | ||
17 | +++ b/target/arm/translate.c | ||
18 | @@ -XXX,XX +XXX,XX @@ gen_thumb2_data_op(DisasContext *s, int op, int conds, uint32_t shifter_out, | ||
19 | return 0; | ||
20 | } | ||
21 | |||
22 | -/* Translate a 32-bit thumb instruction. Returns nonzero if the instruction | ||
23 | - is not legal. */ | ||
24 | -static int disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
25 | +/* Translate a 32-bit thumb instruction. */ | ||
26 | +static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
27 | { | ||
28 | uint32_t imm, shift, offset; | ||
29 | uint32_t rd, rn, rm, rs; | ||
30 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
31 | /* UNPREDICTABLE, unallocated hint or | ||
32 | * PLD/PLDW/PLI (literal) | ||
33 | */ | ||
34 | - return 0; | ||
35 | + return; | ||
36 | } | ||
37 | if (op1 & 1) { | ||
38 | - return 0; /* PLD/PLDW/PLI or unallocated hint */ | ||
39 | + return; /* PLD/PLDW/PLI or unallocated hint */ | ||
40 | } | ||
41 | if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) { | ||
42 | - return 0; /* PLD/PLDW/PLI or unallocated hint */ | ||
43 | + return; /* PLD/PLDW/PLI or unallocated hint */ | ||
44 | } | ||
45 | /* UNDEF space, or an UNPREDICTABLE */ | ||
46 | - return 1; | ||
47 | + goto illegal_op; | ||
48 | } | ||
49 | } | ||
50 | memidx = get_mem_index(s); | ||
51 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
52 | default: | ||
53 | goto illegal_op; | ||
54 | } | ||
55 | - return 0; | ||
56 | + return; | ||
57 | illegal_op: | ||
58 | - return 1; | ||
59 | + gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
60 | + default_exception_el(s)); | ||
61 | } | ||
62 | |||
63 | static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
64 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
65 | if (is_16bit) { | ||
66 | disas_thumb_insn(dc, insn); | ||
67 | } else { | ||
68 | - if (disas_thumb2_insn(dc, insn)) { | ||
69 | - gen_exception_insn(dc, 4, EXCP_UDEF, syn_uncategorized(), | ||
70 | - default_exception_el(dc)); | ||
71 | - } | ||
72 | + disas_thumb2_insn(dc, insn); | ||
73 | } | ||
74 | |||
75 | /* Advance the Thumb condexec condition. */ | ||
76 | -- | ||
77 | 2.7.4 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The GICv3 specification says that reserved register addresses | ||
2 | should RAZ/WI. This means we need to return MEMTX_OK, not MEMTX_ERROR, | ||
3 | because now that we support generating external aborts the | ||
4 | latter will cause an abort on new board models. | ||
5 | 1 | ||
6 | Cc: qemu-stable@nongnu.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 1513183941-24300-2-git-send-email-peter.maydell@linaro.org | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
10 | --- | ||
11 | hw/intc/arm_gicv3_dist.c | 13 +++++++++++++ | ||
12 | hw/intc/arm_gicv3_its_common.c | 8 +++----- | ||
13 | hw/intc/arm_gicv3_redist.c | 13 +++++++++++++ | ||
14 | 3 files changed, 29 insertions(+), 5 deletions(-) | ||
15 | |||
16 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/intc/arm_gicv3_dist.c | ||
19 | +++ b/hw/intc/arm_gicv3_dist.c | ||
20 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
21 | "%s: invalid guest read at offset " TARGET_FMT_plx | ||
22 | "size %u\n", __func__, offset, size); | ||
23 | trace_gicv3_dist_badread(offset, size, attrs.secure); | ||
24 | + /* The spec requires that reserved registers are RAZ/WI; | ||
25 | + * so use MEMTX_ERROR returns from leaf functions as a way to | ||
26 | + * trigger the guest-error logging but don't return it to | ||
27 | + * the caller, or we'll cause a spurious guest data abort. | ||
28 | + */ | ||
29 | + r = MEMTX_OK; | ||
30 | + *data = 0; | ||
31 | } else { | ||
32 | trace_gicv3_dist_read(offset, *data, size, attrs.secure); | ||
33 | } | ||
34 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data, | ||
35 | "%s: invalid guest write at offset " TARGET_FMT_plx | ||
36 | "size %u\n", __func__, offset, size); | ||
37 | trace_gicv3_dist_badwrite(offset, data, size, attrs.secure); | ||
38 | + /* The spec requires that reserved registers are RAZ/WI; | ||
39 | + * so use MEMTX_ERROR returns from leaf functions as a way to | ||
40 | + * trigger the guest-error logging but don't return it to | ||
41 | + * the caller, or we'll cause a spurious guest data abort. | ||
42 | + */ | ||
43 | + r = MEMTX_OK; | ||
44 | } else { | ||
45 | trace_gicv3_dist_write(offset, data, size, attrs.secure); | ||
46 | } | ||
47 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/intc/arm_gicv3_its_common.c | ||
50 | +++ b/hw/intc/arm_gicv3_its_common.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicv3_its_trans_read(void *opaque, hwaddr offset, | ||
52 | MemTxAttrs attrs) | ||
53 | { | ||
54 | qemu_log_mask(LOG_GUEST_ERROR, "ITS read at offset 0x%"PRIx64"\n", offset); | ||
55 | - return MEMTX_ERROR; | ||
56 | + *data = 0; | ||
57 | + return MEMTX_OK; | ||
58 | } | ||
59 | |||
60 | static MemTxResult gicv3_its_trans_write(void *opaque, hwaddr offset, | ||
61 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicv3_its_trans_write(void *opaque, hwaddr offset, | ||
62 | if (ret <= 0) { | ||
63 | qemu_log_mask(LOG_GUEST_ERROR, | ||
64 | "ITS: Error sending MSI: %s\n", strerror(-ret)); | ||
65 | - return MEMTX_DECODE_ERROR; | ||
66 | } | ||
67 | - | ||
68 | - return MEMTX_OK; | ||
69 | } else { | ||
70 | qemu_log_mask(LOG_GUEST_ERROR, | ||
71 | "ITS write at bad offset 0x%"PRIx64"\n", offset); | ||
72 | - return MEMTX_DECODE_ERROR; | ||
73 | } | ||
74 | + return MEMTX_OK; | ||
75 | } | ||
76 | |||
77 | static const MemoryRegionOps gicv3_its_trans_ops = { | ||
78 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/hw/intc/arm_gicv3_redist.c | ||
81 | +++ b/hw/intc/arm_gicv3_redist.c | ||
82 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
83 | "size %u\n", __func__, offset, size); | ||
84 | trace_gicv3_redist_badread(gicv3_redist_affid(cs), offset, | ||
85 | size, attrs.secure); | ||
86 | + /* The spec requires that reserved registers are RAZ/WI; | ||
87 | + * so use MEMTX_ERROR returns from leaf functions as a way to | ||
88 | + * trigger the guest-error logging but don't return it to | ||
89 | + * the caller, or we'll cause a spurious guest data abort. | ||
90 | + */ | ||
91 | + r = MEMTX_OK; | ||
92 | + *data = 0; | ||
93 | } else { | ||
94 | trace_gicv3_redist_read(gicv3_redist_affid(cs), offset, *data, | ||
95 | size, attrs.secure); | ||
96 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, | ||
97 | "size %u\n", __func__, offset, size); | ||
98 | trace_gicv3_redist_badwrite(gicv3_redist_affid(cs), offset, data, | ||
99 | size, attrs.secure); | ||
100 | + /* The spec requires that reserved registers are RAZ/WI; | ||
101 | + * so use MEMTX_ERROR returns from leaf functions as a way to | ||
102 | + * trigger the guest-error logging but don't return it to | ||
103 | + * the caller, or we'll cause a spurious guest data abort. | ||
104 | + */ | ||
105 | + r = MEMTX_OK; | ||
106 | } else { | ||
107 | trace_gicv3_redist_write(gicv3_redist_affid(cs), offset, data, | ||
108 | size, attrs.secure); | ||
109 | -- | ||
110 | 2.7.4 | ||
111 | |||
112 | diff view generated by jsdifflib |