Pull up following revision(s) (requested by rin in ticket #146): sys/arch/arm/conf/Makefile.arm: revision 1.50 sys/dev/usb/if_axe.c: revision 1.120 PR kern/54486 Workaround for alignment faults on ARMv6+, at least occur with axe(4) and athn(4) drivers. For ARMv6+, unaligned access is enabled by default. However, it cannot be used for non-cacheable memory, which is used as DMA buffers. This results in alignment faults above. A real fix is to use cacheable memory as DMA buffers. However, it breaks some drivers, awge(4) and vchiq(4) at least. Until we figure out problems and fix them, we choose a fail-safe workaround here; forbid unaligned memory access for whole kernel. Affects on performance is negligibly small as far as we can see. XXX pullup netbsd-9 - PR kern/54486 Revert workaround introduced in rev 1.94: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/usb/if_axe.c#rev1.94 This is a problem specific to ARMv6+, and addressed by arch/arm/conf/Makefile.arm rev 1.50: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/arm/conf/Makefile.arm#rev1.50 XXX pullup netbsd-9diff -r1.49 -r1.49.4.1 src/sys/arch/arm/conf/Makefile.arm
(martin)
--- src/sys/arch/arm/conf/Makefile.arm 2018/09/22 12:24:01 1.49
+++ src/sys/arch/arm/conf/Makefile.arm 2019/09/01 14:03:02 1.49.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: Makefile.arm,v 1.49 2018/09/22 12:24:01 rin Exp $ | 1 | # $NetBSD: Makefile.arm,v 1.49.4.1 2019/09/01 14:03:02 martin Exp $ | |
2 | 2 | |||
3 | # Makefile for NetBSD | 3 | # Makefile for NetBSD | |
4 | # | 4 | # | |
5 | # This makefile is constructed from a machine description: | 5 | # This makefile is constructed from a machine description: | |
6 | # config machineid | 6 | # config machineid | |
7 | # Most changes should be made in the machine description | 7 | # Most changes should be made in the machine description | |
8 | # /sys/arch/<arch>/conf/``machineid'' | 8 | # /sys/arch/<arch>/conf/``machineid'' | |
9 | # after which you should do | 9 | # after which you should do | |
10 | # config machineid | 10 | # config machineid | |
11 | # Machine generic makefile changes should be made in | 11 | # Machine generic makefile changes should be made in | |
12 | # /sys/arch/arm/conf/Makefile.arm | 12 | # /sys/arch/arm/conf/Makefile.arm | |
13 | # after which config should be rerun for all machines of that type. | 13 | # after which config should be rerun for all machines of that type. | |
14 | # | 14 | # | |
@@ -43,26 +43,46 @@ AFLAGS.fusu.S+=-marm | @@ -43,26 +43,46 @@ AFLAGS.fusu.S+=-marm | |||
43 | AFLAGS.exception.S+=-marm | 43 | AFLAGS.exception.S+=-marm | |
44 | AFLAGS.irq_dispatch.S+=-marm | 44 | AFLAGS.irq_dispatch.S+=-marm | |
45 | AFLAGS.blockio.S+=-marm | 45 | AFLAGS.blockio.S+=-marm | |
46 | AFLAGS.copystr.S+=-marm | 46 | AFLAGS.copystr.S+=-marm | |
47 | CFLAGS+= -mfloat-abi=soft | 47 | CFLAGS+= -mfloat-abi=soft | |
48 | 48 | |||
49 | # This files use instructions deprecated for ARMv7+, but still | 49 | # This files use instructions deprecated for ARMv7+, but still | |
50 | # included in kernel that build with higher -mcpu=... settings. | 50 | # included in kernel that build with higher -mcpu=... settings. | |
51 | CPPFLAGS.cpufunc_asm_armv4.S+= -mcpu=arm8 | 51 | CPPFLAGS.cpufunc_asm_armv4.S+= -mcpu=arm8 | |
52 | CPPFLAGS.cpufunc_asm_armv6.S+= -mcpu=arm1136j-s | 52 | CPPFLAGS.cpufunc_asm_armv6.S+= -mcpu=arm1136j-s | |
53 | CPPFLAGS.cpufunc_asm_arm11.S+= -mcpu=arm1136j-s | 53 | CPPFLAGS.cpufunc_asm_arm11.S+= -mcpu=arm1136j-s | |
54 | CPPFLAGS.cpufunc_asm_xscale.S+= -mcpu=xscale | 54 | CPPFLAGS.cpufunc_asm_xscale.S+= -mcpu=xscale | |
55 | 55 | |||
56 | .if !empty(MACHINE_ARCH:Mearmv6*) || !empty(MACHINE_ARCH:Mearmv7*) | |||
57 | # XXX | |||
58 | # | |||
59 | # Workaround for alignment faults on ARMv6+, at least occur with | |||
60 | # axe(4) and athn(4) drivers. | |||
61 | # | |||
62 | # For ARMv6+, unaligned access is enabled by default. However, it | |||
63 | # cannot be used for non-cacheable memory, which is used as DMA | |||
64 | # buffers. This results in alignment faults above. A real fix is | |||
65 | # to use cacheable memory as DMA buffers. However, it breaks some | |||
66 | # drivers, awge(4) and vchiq(4) at least. | |||
67 | # | |||
68 | # Until we figure out problems and fix them, we choose a fail-safe | |||
69 | # workaround here; forbid unaligned memory access for whole kernel. | |||
70 | # Affects on performance is negligibly small as far as we can see. | |||
71 | # | |||
72 | # See PR kern/54486 for more details. | |||
73 | CFLAGS+= -mno-unaligned-access | |||
74 | .endif | |||
75 | ||||
56 | ## | 76 | ## | |
57 | ## (3) libkern and compat | 77 | ## (3) libkern and compat | |
58 | ## | 78 | ## | |
59 | OPT_MODULAR= %MODULAR% | 79 | OPT_MODULAR= %MODULAR% | |
60 | 80 | |||
61 | ## | 81 | ## | |
62 | ## (4) local objects, compile rules, and dependencies | 82 | ## (4) local objects, compile rules, and dependencies | |
63 | ## | 83 | ## | |
64 | MD_OBJS+= ${SYSTEM_FIRST_OBJ} locore.o | 84 | MD_OBJS+= ${SYSTEM_FIRST_OBJ} locore.o | |
65 | MD_CFILES+= | 85 | MD_CFILES+= | |
66 | MD_SFILES+= ${SYSTEM_FIRST_SFILE} ${ARM}/arm32/locore.S | 86 | MD_SFILES+= ${SYSTEM_FIRST_SFILE} ${ARM}/arm32/locore.S | |
67 | 87 | |||
68 | .if defined(SYSTEM_FIRST_OBJ) | 88 | .if defined(SYSTEM_FIRST_OBJ) |
--- src/sys/dev/usb/if_axe.c 2019/09/01 13:00:36 1.102.2.1
+++ src/sys/dev/usb/if_axe.c 2019/09/01 14:03:02 1.102.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_axe.c,v 1.102.2.1 2019/09/01 13:00:36 martin Exp $ */ | 1 | /* $NetBSD: if_axe.c,v 1.102.2.2 2019/09/01 14:03:02 martin Exp $ */ | |
2 | /* $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */ | 2 | /* $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 2005, 2006, 2007 Jonathan Gray <jsg@openbsd.org> | 5 | * Copyright (c) 2005, 2006, 2007 Jonathan Gray <jsg@openbsd.org> | |
6 | * | 6 | * | |
7 | * Permission to use, copy, modify, and distribute this software for any | 7 | * Permission to use, copy, modify, and distribute this software for any | |
8 | * purpose with or without fee is hereby granted, provided that the above | 8 | * purpose with or without fee is hereby granted, provided that the above | |
9 | * copyright notice and this permission notice appear in all copies. | 9 | * copyright notice and this permission notice appear in all copies. | |
10 | * | 10 | * | |
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
@@ -77,27 +77,27 @@ | @@ -77,27 +77,27 @@ | |||
77 | * (Adam Weinberger wanted me to name this driver if_gir.c.) | 77 | * (Adam Weinberger wanted me to name this driver if_gir.c.) | |
78 | */ | 78 | */ | |
79 | 79 | |||
80 | /* | 80 | /* | |
81 | * Ax88178 and Ax88772 support backported from the OpenBSD driver. | 81 | * Ax88178 and Ax88772 support backported from the OpenBSD driver. | |
82 | * 2007/02/12, J.R. Oldroyd, fbsd@opal.com | 82 | * 2007/02/12, J.R. Oldroyd, fbsd@opal.com | |
83 | * | 83 | * | |
84 | * Manual here: | 84 | * Manual here: | |
85 | * http://www.asix.com.tw/FrootAttach/datasheet/AX88178_datasheet_Rev10.pdf | 85 | * http://www.asix.com.tw/FrootAttach/datasheet/AX88178_datasheet_Rev10.pdf | |
86 | * http://www.asix.com.tw/FrootAttach/datasheet/AX88772_datasheet_Rev10.pdf | 86 | * http://www.asix.com.tw/FrootAttach/datasheet/AX88772_datasheet_Rev10.pdf | |
87 | */ | 87 | */ | |
88 | 88 | |||
89 | #include <sys/cdefs.h> | 89 | #include <sys/cdefs.h> | |
90 | __KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.102.2.1 2019/09/01 13:00:36 martin Exp $"); | 90 | __KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.102.2.2 2019/09/01 14:03:02 martin Exp $"); | |
91 | 91 | |||
92 | #ifdef _KERNEL_OPT | 92 | #ifdef _KERNEL_OPT | |
93 | #include "opt_usb.h" | 93 | #include "opt_usb.h" | |
94 | #include "opt_net_mpsafe.h" | 94 | #include "opt_net_mpsafe.h" | |
95 | #endif | 95 | #endif | |
96 | 96 | |||
97 | #include <sys/param.h> | 97 | #include <sys/param.h> | |
98 | 98 | |||
99 | #include <dev/usb/usbnet.h> | 99 | #include <dev/usb/usbnet.h> | |
100 | #include <dev/usb/usbhist.h> | 100 | #include <dev/usb/usbhist.h> | |
101 | #include <dev/usb/if_axereg.h> | 101 | #include <dev/usb/if_axereg.h> | |
102 | 102 | |||
103 | struct axe_type { | 103 | struct axe_type { | |
@@ -1028,38 +1028,27 @@ axe_rx_loop(struct usbnet * un, struct u | @@ -1028,38 +1028,27 @@ axe_rx_loop(struct usbnet * un, struct u | |||
1028 | do { | 1028 | do { | |
1029 | u_int pktlen = 0; | 1029 | u_int pktlen = 0; | |
1030 | u_int rxlen = 0; | 1030 | u_int rxlen = 0; | |
1031 | int flags = 0; | 1031 | int flags = 0; | |
1032 | 1032 | |||
1033 | if ((un->un_flags & AXSTD_FRAME) != 0) { | 1033 | if ((un->un_flags & AXSTD_FRAME) != 0) { | |
1034 | struct axe_sframe_hdr hdr; | 1034 | struct axe_sframe_hdr hdr; | |
1035 | 1035 | |||
1036 | if (total_len < sizeof(hdr)) { | 1036 | if (total_len < sizeof(hdr)) { | |
1037 | ifp->if_ierrors++; | 1037 | ifp->if_ierrors++; | |
1038 | break; | 1038 | break; | |
1039 | } | 1039 | } | |
1040 | 1040 | |||
1041 | #if !defined(__NO_STRICT_ALIGNMENT) && __GNUC_PREREQ__(6, 1) | |||
1042 | /* | |||
1043 | * XXX hdr is 2-byte aligned in buf, not 4-byte. | |||
1044 | * For some architectures, __builtin_memcpy() of | |||
1045 | * GCC 6 attempts to copy sizeof(hdr) = 4 bytes | |||
1046 | * at onece, which results in alignment error. | |||
1047 | */ | |||
1048 | hdr.len = *(uint16_t *)buf; | |||
1049 | hdr.ilen = *(uint16_t *)(buf + sizeof(uint16_t)); | |||
1050 | #else | |||
1051 | memcpy(&hdr, buf, sizeof(hdr)); | 1041 | memcpy(&hdr, buf, sizeof(hdr)); | |
1052 | #endif | |||
1053 | 1042 | |||
1054 | DPRINTFN(20, "total_len %#jx len %jx ilen %#jx", | 1043 | DPRINTFN(20, "total_len %#jx len %jx ilen %#jx", | |
1055 | total_len, | 1044 | total_len, | |
1056 | (le16toh(hdr.len) & AXE_RH1M_RXLEN_MASK), | 1045 | (le16toh(hdr.len) & AXE_RH1M_RXLEN_MASK), | |
1057 | (le16toh(hdr.ilen) & AXE_RH1M_RXLEN_MASK), 0); | 1046 | (le16toh(hdr.ilen) & AXE_RH1M_RXLEN_MASK), 0); | |
1058 | 1047 | |||
1059 | total_len -= sizeof(hdr); | 1048 | total_len -= sizeof(hdr); | |
1060 | buf += sizeof(hdr); | 1049 | buf += sizeof(hdr); | |
1061 | 1050 | |||
1062 | if (((le16toh(hdr.len) & AXE_RH1M_RXLEN_MASK) ^ | 1051 | if (((le16toh(hdr.len) & AXE_RH1M_RXLEN_MASK) ^ | |
1063 | (le16toh(hdr.ilen) & AXE_RH1M_RXLEN_MASK)) != | 1052 | (le16toh(hdr.ilen) & AXE_RH1M_RXLEN_MASK)) != | |
1064 | AXE_RH1M_RXLEN_MASK) { | 1053 | AXE_RH1M_RXLEN_MASK) { | |
1065 | ifp->if_ierrors++; | 1054 | ifp->if_ierrors++; |