NetBSD Problem Report #54486

From gson@gson.org  Fri Aug 23 14:57:54 2019
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (unknown [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 78C5C7A153
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 23 Aug 2019 14:57:54 +0000 (UTC)
Message-Id: <20190823145732.AD1E4989388@guava.gson.org>
Date: Fri, 23 Aug 2019 17:57:32 +0300 (EEST)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: athn driver panics on arm
X-Send-Pr-Version: 3.95

>Number:         54486
>Category:       kern
>Synopsis:       athn driver panics on arm
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 23 15:00:00 +0000 2019
>Closed-Date:    Sun Sep 01 15:40:41 +0000 2019
>Last-Modified:  Thu Feb 06 08:05:01 +0000 2020
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current, source date 2019.08.23.07.29.29
>Organization:

>Environment:
System: NetBSD
Architecture: earmv7hf
Machine: evbarm
>Description:

Booting NetBSD-current on a Raspberry Pi 3 model B with a Comfast
CF-WU871N WiFi adapter plugged into a USB port, the kernel panics
with an "Alignment Fault 1" in athn_usb_start.  Attach message:

  http://www.gson.org/netbsd/bugs/athn.arm/attach.jpg

Panic message and backtrace:

  http://www.gson.org/netbsd/bugs/athn.arm/panic.jpg

This is the same adapter as in PRs 51151 and 52526.

>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Andreas Gustafsson <gson@gson.org>
To: gnats-bugs@netbsd.org
Cc: gson@gson.org (Andreas Gustafsson)
Subject: Re: kern/54486: athn driver panics on arm
Date: Fri, 23 Aug 2019 22:57:52 +0300

 Looks like gcc is optimizing the memcpy() call on line 2528 of
 src/sys/dev/usb/if_athn_usb.c into an unaligned 32-bit store:

                 txf = (struct ar_tx_frame *)&htc[1];
                 memset(txf, 0, sizeof(*txf));
                 txf->data_type = AR_HTC_NORMAL;
                 txf->node_idx = sta_index;
                 txf->vif_idx = 0;
                 txf->tid = tid;

 The fields at the beginning and end of *txf are being assigned to, so
 only the middle part really needs the memset()ting, and gcc apparently
 figures the way to do that is to store a 32-bit word of zeros there,
 at an unaligned address.

 I would not be surprised if this optimizaion is also breaking other
 parts of the arm kernel.  Does anyone know the right way to fix this?
 -- 
 Andreas Gustafsson, gson@gson.org

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, gson@gson.org (Andreas Gustafsson)
Subject: re: kern/54486: athn driver panics on arm
Date: Sat, 24 Aug 2019 09:59:58 +1000

 >  Looks like gcc is optimizing the memcpy() call on line 2528 of
 >  src/sys/dev/usb/if_athn_usb.c into an unaligned 32-bit store:
 >  
 >                  txf = (struct ar_tx_frame *)&htc[1];
 >                  memset(txf, 0, sizeof(*txf));
 >                  txf->data_type = AR_HTC_NORMAL;
 >                  txf->node_idx = sta_index;
 >                  txf->vif_idx = 0;
 >                  txf->tid = tid;
 >  
 >  The fields at the beginning and end of *txf are being assigned to, so
 >  only the middle part really needs the memset()ting, and gcc apparently
 >  figures the way to do that is to store a 32-bit word of zeros there,
 >  at an unaligned address.
 >  
 >  I would not be surprised if this optimizaion is also breaking other
 >  parts of the arm kernel.  Does anyone know the right way to fix this?

 this looks similar to the problem worked around in if_axe.c:

    http://mail-index.netbsd.org/source-changes/2019/01/06/msg102106.html

 i forget the status of a real fix.  there's some issue with
 unaligned on v6/v7, IIRC.

 but i think this one is a code bug.

 the axe case has a structure with two uint16_t's in it, and
 assumes they will be 32 bit aligned.  that's wrong.

 however, in this case, struct ar_tx_frame has 4 x uint8_ts
 and then a uint32_t.

 that means the compiler is probably right to assume that a
 pointer to this structure will be aligned for uint32_t, so
 in this case, the compiler seems to be not wrong, and we 
 should fix the code.


 .mrg.

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, gson@gson.org (Andreas Gustafsson)
Subject: re: kern/54486: athn driver panics on arm
Date: Sat, 24 Aug 2019 10:21:19 +1000

 could you try this patch?


 .mrg.


 Index: if_athn_usb.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/if_athn_usb.c,v
 retrieving revision 1.34
 diff -p -u -r1.34 if_athn_usb.c
 --- if_athn_usb.c	3 Jun 2019 09:58:31 -0000	1.34
 +++ if_athn_usb.c	24 Aug 2019 00:20:44 -0000
 @@ -2450,8 +2450,8 @@ athn_usb_tx(struct athn_softc *sc, struc
  	struct ieee80211_key *k = NULL;
  	struct ar_stream_hdr *hdr;
  	struct ar_htc_frame_hdr *htc;
 -	struct ar_tx_frame *txf;
  	struct ar_tx_mgmt *txm;
 +	uint8_t *next;
  	uint8_t *frm;
  	uint8_t sta_index, qid, tid;
  	int error, s, xferlen;
 @@ -2497,30 +2497,35 @@ athn_usb_tx(struct athn_softc *sc, struc

  	/* NB: We don't take advantage of USB Tx stream mode for now. */
  	hdr = (struct ar_stream_hdr *)data->buf;
 +	next = data->buf + sizeof(*hdr);
  	hdr->tag = htole16(AR_USB_TX_STREAM_TAG);

 -	htc = (struct ar_htc_frame_hdr *)&hdr[1];
 +	htc = (struct ar_htc_frame_hdr *)next;
 +	next = next + sizeof(*htc);
  	memset(htc, 0, sizeof(*htc));
  	if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  	    IEEE80211_FC0_TYPE_DATA) {
  		htc->endpoint_id = usc->usc_ep_data[qid];
 +		struct ar_tx_frame txf = {0};
 +		struct ar_tx_frame *txfp;

 -		txf = (struct ar_tx_frame *)&htc[1];
 -		memset(txf, 0, sizeof(*txf));
 -		txf->data_type = AR_HTC_NORMAL;
 -		txf->node_idx = sta_index;
 -		txf->vif_idx = 0;
 -		txf->tid = tid;
 +		txf.data_type = AR_HTC_NORMAL;
 +		txf.node_idx = sta_index;
 +		txf.vif_idx = 0;
 +		txf.tid = tid;
  		if (m->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold)
 -			txf->flags |= htobe32(AR_HTC_TX_RTSCTS);
 +			txf.flags |= htobe32(AR_HTC_TX_RTSCTS);
  		else if (ic->ic_flags & IEEE80211_F_USEPROT) {
  			if (ic->ic_protmode == IEEE80211_PROT_CTSONLY)
 -				txf->flags |= htobe32(AR_HTC_TX_CTSONLY);
 +				txf.flags |= htobe32(AR_HTC_TX_CTSONLY);
  			else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
 -				txf->flags |= htobe32(AR_HTC_TX_RTSCTS);
 +				txf.flags |= htobe32(AR_HTC_TX_RTSCTS);
  		}
 -		txf->key_idx = 0xff;
 -		frm = (uint8_t *)&txf[1];
 +		txf.key_idx = 0xff;
 +		txfp = (struct ar_tx_frame *)next;
 +		next = next + sizeof *txfp;
 +		memcpy(txfp, &txf, sizeof txf);
 +		frm = next;
  	} else {
  		htc->endpoint_id = usc->usc_ep_mgmt;


From: Andreas Gustafsson <gson@gson.org>
To: matthew green <mrg@eterna.com.au>, gnats-bugs@netbsd.org
Cc: Rin Okuyama <rokuyama@rk.phys.keio.ac.jp>, Christos Zoulas <christos@astron.com>, maya@NetBSD.org
Subject: Re: kern/54486: athn driver panics on arm
Date: Sat, 24 Aug 2019 11:20:17 +0300

 matthew green wrote:
 > >  Looks like gcc is optimizing the memcpy() call on line 2528 of
 > >  src/sys/dev/usb/if_athn_usb.c into an unaligned 32-bit store:
 > >  
 > >                  txf = (struct ar_tx_frame *)&htc[1];
 > >                  memset(txf, 0, sizeof(*txf));
 > >                  txf->data_type = AR_HTC_NORMAL;
 > >                  txf->node_idx = sta_index;
 > >                  txf->vif_idx = 0;
 > >                  txf->tid = tid;
 > >  
 > >  The fields at the beginning and end of *txf are being assigned to, so
 > >  only the middle part really needs the memset()ting, and gcc apparently
 > >  figures the way to do that is to store a 32-bit word of zeros there,
 > >  at an unaligned address.
 > >  
 > >  I would not be surprised if this optimizaion is also breaking other
 > >  parts of the arm kernel.  Does anyone know the right way to fix this?
 > 
 > this looks similar to the problem worked around in if_axe.c:
 > 
 >    http://mail-index.netbsd.org/source-changes/2019/01/06/msg102106.html
 > 
 > i forget the status of a real fix.  there's some issue with
 > unaligned on v6/v7, IIRC.

 I found some related discussion in the port-arm archives, starting at:

   http://mail-index.netbsd.org/port-arm/2019/01/06/msg005357.html

 My understanding of that discussion is that there are two alternative
 correct fixes: either apply the patch from the above message to add
 -mno-unaligned-access to CFLAGS, or stop using PMAP_NOCACHE in
 bus_dma.c as mentioned in:

   http://mail-index.netbsd.org/port-arm/2019/01/06/msg005358.html

 The problem is that *neither* has been done.  Since the patch is less
 likely to have bad side effects, I think we should apply the patch
 now, and if or when the pmap change is ever made, the patch can be
 reverted.

 > but i think this one is a code bug.
 > 
 > the axe case has a structure with two uint16_t's in it, and
 > assumes they will be 32 bit aligned.  that's wrong.
 > 
 > however, in this case, struct ar_tx_frame has 4 x uint8_ts
 > and then a uint32_t.

 Sorry, I quoted the code around the wrong memset() call in the PR.
 The actual code around line 2528 is:

                 txm = (struct ar_tx_mgmt *)&htc[1];
                 memset(txm, 0, sizeof(*txm));
                 txm->node_idx = sta_index;
                 txm->vif_idx = 0;
                 txm->key_idx = 0xff;
                 frm = (uint8_t *)&txm[1];

 which involves struct ar_tx_mgmt rather than ar_tx_frame.

 > that means the compiler is probably right to assume that a
 > pointer to this structure will be aligned for uint32_t, so
 > in this case, the compiler seems to be not wrong, and we 
 > should fix the code.

 The pointer to the structure is aligned.  The lack of alignment arises
 from gcc optimizing a memset of the full structure into a store to
 an unaligned subset of the structure fields.

 > could you try this patch?

 I'm not really interested in work-arounds for individual drivers.
 Unless we fix the general problem, it's going to continue to bite us
 again and again.
 -- 
 Andreas Gustafsson, gson@gson.org

From: matthew green <mrg@eterna.com.au>
To: Andreas Gustafsson <gson@gson.org>
Cc: Rin Okuyama <rokuyama@rk.phys.keio.ac.jp>,
    Christos Zoulas <christos@astron.com>, maya@NetBSD.org,
    gnats-bugs@netbsd.org
Subject: re: kern/54486: athn driver panics on arm
Date: Sat, 24 Aug 2019 21:11:04 +1000

 > > i forget the status of a real fix.  there's some issue with
 > > unaligned on v6/v7, IIRC.
 > 
 > I found some related discussion in the port-arm archives, starting at:
 > 
 >   http://mail-index.netbsd.org/port-arm/2019/01/06/msg005357.html
 > 
 > My understanding of that discussion is that there are two alternative
 > correct fixes: either apply the patch from the above message to add
 > -mno-unaligned-access to CFLAGS, or stop using PMAP_NOCACHE in
 > bus_dma.c as mentioned in:
 > 
 >   http://mail-index.netbsd.org/port-arm/2019/01/06/msg005358.html
 > 
 > The problem is that *neither* has been done.  Since the patch is less
 > likely to have bad side effects, I think we should apply the patch
 > now, and if or when the pmap change is ever made, the patch can be
 > reverted.

 apparently i agreed with you back in january.  Rin, can you
 commit your change for now.  at least until we fix pmap..

 i think you're right that this should be aligned.  the buffer
 should be at least 8 byte aligned, and should end up being 4
 byte aligned when copying to the 'struct ar_tx_frame' or
 'struct ar_tx_mgmt'.

 > > could you try this patch?
 > 
 > I'm not really interested in work-arounds for individual drivers.
 > Unless we fix the general problem, it's going to continue to bite us
 > again and again.

 my patch has a bug, but i still would like an updated version
 to be tested -- the code is dodgy and it would be nice to
 avoid having code that would trigger if poorly copied, if you
 could test that anyway (not ready currently.)

 thanks.


 .mrg.

From: Rin Okuyama <rokuyama@meiji.ac.jp>
To: matthew green <mrg@eterna.com.au>, Andreas Gustafsson <gson@gson.org>,
	Nick Hudson <nick.hudson@gmx.co.uk>
Cc: Christos Zoulas <christos@astron.com>, "maya@NetBSD.org"
	<maya@NetBSD.org>, "gnats-bugs@netbsd.org" <gnats-bugs@netbsd.org>
Subject: Re: kern/54486: athn driver panics on arm
Date: Sat, 24 Aug 2019 12:01:41 +0000

 On 2019/08/24 20:11, matthew green wrote:
 >> I found some related discussion in the port-arm archives, starting at:
 >>
 >>    http://mail-index.netbsd.org/port-arm/2019/01/06/msg005357.html
 >>
 >> My understanding of that discussion is that there are two alternative
 >> correct fixes: either apply the patch from the above message to add
 >> -mno-unaligned-access to CFLAGS, or stop using PMAP_NOCACHE in
 >> bus_dma.c as mentioned in:
 >>
 >>    http://mail-index.netbsd.org/port-arm/2019/01/06/msg005358.html
 >>
 >> The problem is that *neither* has been done.  Since the patch is less
 >> likely to have bad side effects, I think we should apply the patch
 >> now, and if or when the pmap change is ever made, the patch can be
 >> reverted.
 >=20
 > apparently i agreed with you back in january.  Rin, can you
 > commit your change for now.  at least until we fix pmap..

 IMO, adding -mno-unaligned-access to CFLAGS is not a correct fix,
 although affects on performance seems negligible as far as I can
 see (I guess that benefits by ability of unaligned access are
 canceled by penalty of it).

 A real fix should be using cacheble memory for DMA buffer. However,
 it breaks some drivers, at least, awge(4) and vchiq(4). Now, Nick
 is working on it.

 Nick, how is the progress? If it takes a long time, we need to
 consider a workaround of -mno-unaligned-access (and pull it up
 into netbsd-9).

 Thanks,
 rin

From: Nick Hudson <nick.hudson@gmx.co.uk>
To: Rin Okuyama <rokuyama@meiji.ac.jp>, matthew green <mrg@eterna.com.au>,
 Andreas Gustafsson <gson@gson.org>
Cc: Christos Zoulas <christos@astron.com>, "maya@NetBSD.org"
 <maya@NetBSD.org>, "gnats-bugs@netbsd.org" <gnats-bugs@netbsd.org>
Subject: Re: kern/54486: athn driver panics on arm
Date: Sun, 25 Aug 2019 08:54:35 +0100

 On 24/08/2019 13:01, Rin Okuyama wrote:
 > On 2019/08/24 20:11, matthew green wrote:
 >>> I found some related discussion in the port-arm archives, starting at:
 >>>
 >>>     http://mail-index.netbsd.org/port-arm/2019/01/06/msg005357.html
 >>>
 >>> My understanding of that discussion is that there are two alternative
 >>> correct fixes: either apply the patch from the above message to add
 >>> -mno-unaligned-access to CFLAGS, or stop using PMAP_NOCACHE in
 >>> bus_dma.c as mentioned in:
 >>>
 >>>     http://mail-index.netbsd.org/port-arm/2019/01/06/msg005358.html
 >>>
 >>> The problem is that *neither* has been done.  Since the patch is less
 >>> likely to have bad side effects, I think we should apply the patch
 >>> now, and if or when the pmap change is ever made, the patch can be
 >>> reverted.
 >>
 >> apparently i agreed with you back in january.  Rin, can you
 >> commit your change for now.  at least until we fix pmap..
 >
 > IMO, adding -mno-unaligned-access to CFLAGS is not a correct fix,
 > although affects on performance seems negligible as far as I can
 > see (I guess that benefits by ability of unaligned access are
 > canceled by penalty of it).
 >
 > A real fix should be using cacheble memory for DMA buffer. However,
 > it breaks some drivers, at least, awge(4) and vchiq(4). Now, Nick
 > is working on it.
 >
 > Nick, how is the progress? If it takes a long time, we need to
 > consider a workaround of -mno-unaligned-access (and pull it up
 > into netbsd-9).

 My focus is elsewhere at the moment, so feel free to apply the workaround.

 Perhaps we can compile a handful of drivers with -mno-unaligned-access
 and not the whole kernel?

 Thanks,
 Nick

From: Rin Okuyama <rokuyama@meiji.ac.jp>
To: Nick Hudson <nick.hudson@gmx.co.uk>, matthew green <mrg@eterna.com.au>,
	Andreas Gustafsson <gson@gson.org>
Cc: Christos Zoulas <christos@astron.com>, "maya@NetBSD.org"
	<maya@NetBSD.org>, "gnats-bugs@netbsd.org" <gnats-bugs@netbsd.org>
Subject: Re: kern/54486: athn driver panics on arm
Date: Mon, 26 Aug 2019 16:53:17 +0000

 On 2019/08/25 16:54, Nick Hudson wrote:
 > My focus is elsewhere at the moment, so feel free to apply the workaround=
 .

 I see. I will commit the workaround soon.

 > Perhaps we can compile a handful of drivers with -mno-unaligned-access
 > and not the whole kernel?

 Well, but it is difficult to make sure which components access
 DMA buffers and which do not. I prefer to forbid whole kernel to
 unaligned access. The affect on performance is, anyway, negligibly
 small as far as I can see; some lazy ``benchmark'' of building
 lang/perl shows only 0.1% difference between kernels with and
 without -mno-unaligned-access:

 http://mail-index.netbsd.org/port-arm/2019/01/07/msg005371.html

 If there's no objection, I will also send pull-up request for
 netbsd-9 in few days.

 Thanks,
 rin

From: Rin Okuyama <rokuyama.rk@gmail.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: kern/54486: athn driver panics on arm
Date: Tue, 27 Aug 2019 02:11:09 +0900

 Hmm, gnats doesn't like my alternate mail address...
 Resend from my main address.

 rin
 -------- Forwarded Message --------
 Subject: Re: kern/54486: athn driver panics on arm
 Date: Tue, 27 Aug 2019 01:53:15 +0900
 From: Rin Okuyama <rokuyama@meiji.ac.jp>
 To: Nick Hudson <nick.hudson@gmx.co.uk>, matthew green <mrg@eterna.com.au>, Andreas Gustafsson <gson@gson.org>
 CC: Christos Zoulas <christos@astron.com>, maya@NetBSD.org <maya@NetBSD.org>, gnats-bugs@netbsd.org <gnats-bugs@netbsd.org>

 On 2019/08/25 16:54, Nick Hudson wrote:
 > My focus is elsewhere at the moment, so feel free to apply the workaround.

 I see. I will commit the workaround soon.

 > Perhaps we can compile a handful of drivers with -mno-unaligned-access
 > and not the whole kernel?

 Well, but it is difficult to make sure which components access
 DMA buffers and which do not. I prefer to forbid whole kernel to
 unaligned access. The affect on performance is, anyway, negligibly
 small as far as I can see; some lazy ``benchmark'' of building
 lang/perl shows only 0.1% difference between kernels with and
 without -mno-unaligned-access:

 http://mail-index.netbsd.org/port-arm/2019/01/07/msg005371.html

 If there's no objection, I will also send pull-up request for
 netbsd-9 in few days.

 Thanks,
 rin

From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54486 CVS commit: src/sys/arch/arm/conf
Date: Mon, 26 Aug 2019 17:18:42 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Mon Aug 26 17:18:42 UTC 2019

 Modified Files:
 	src/sys/arch/arm/conf: Makefile.arm

 Log Message:
 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


 To generate a diff of this commit:
 cvs rdiff -u -r1.49 -r1.50 src/sys/arch/arm/conf/Makefile.arm

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54486 CVS commit: src/sys/dev/usb
Date: Mon, 26 Aug 2019 17:26:34 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Mon Aug 26 17:26:33 UTC 2019

 Modified Files:
 	src/sys/dev/usb: if_axe.c

 Log Message:
 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-9


 To generate a diff of this commit:
 cvs rdiff -u -r1.119 -r1.120 src/sys/dev/usb/if_axe.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: gson@NetBSD.org
State-Changed-When: Thu, 29 Aug 2019 08:08:52 +0000
State-Changed-Why:
Fix committed but not pulled up yet.


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: rin@NetBSD.org
State-Changed-When: Fri, 30 Aug 2019 11:01:38 +0000
State-Changed-Why:
[pullup-9 #146]
https://releng.netbsd.org/cgi-bin/req-9.cgi?show=146


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54486 CVS commit: [netbsd-9] src/sys
Date: Sun, 1 Sep 2019 14:03:03 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Sep  1 14:03:02 UTC 2019

 Modified Files:
 	src/sys/arch/arm/conf [netbsd-9]: Makefile.arm
 	src/sys/dev/usb [netbsd-9]: if_axe.c

 Log Message:
 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-9


 To generate a diff of this commit:
 cvs rdiff -u -r1.49 -r1.49.4.1 src/sys/arch/arm/conf/Makefile.arm
 cvs rdiff -u -r1.102.2.1 -r1.102.2.2 src/sys/dev/usb/if_axe.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: rin@NetBSD.org
State-Changed-When: Sun, 01 Sep 2019 15:40:41 +0000
State-Changed-Why:
pullup done


From: Rin Okuyama <rokuyama.rk@gmail.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: kern/54486 athn driver panics on arm
Date: Thu, 6 Feb 2020 17:03:27 +0900

 The PR is already closed, but for future reference:

 The real fix has been made to -HEAD by Nick.

    http://mail-index.netbsd.org/source-changes/2020/02/05/msg113706.html

 The workaround was removed at the same time.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.