Subject: port-i386/5682: ALIGNED_POINTER vs BUS_SPACE_DEBUG
To: None <gnats-bugs@gnats.netbsd.org>
From: None <danw@MIT.EDU>
List: netbsd-bugs
Date: 07/01/1998 02:56:16
>Number:         5682
>Category:       port-i386
>Synopsis:       ALIGNED_POINTER vs BUS_SPACE_DEBUG
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul  1 00:05:01 1998
>Last-Modified:
>Originator:     Dan Winship
>Organization:
	
>Release:        current of 6/22
>Environment:
	
System: NetBSD zork.mit.edu 1.3F NetBSD 1.3F (COCONUT) #13: Sun Jun 21 16:22:15 EDT 1998 danw@zork.mit.edu:/u1/usr/src/sys/arch/i386/compile/COCONUT i386


>Description:
So I got a

  buffer 0xf062ad95 not aligned to 2 bytes ../../../../dev/ic/ne2000.c:508

and investigated and found that actually the code was already trying
to check alignment, but it was losing because i386/include/param.h
says

  #define ALIGNED_POINTER(p,t)     1

Oops.

>How-To-Repeat:

>Fix:
(Copying in the definition of __BUS_SPACE_ALIGNED_ADDRESS. Although
maybe people like making unaligned accesses on the i386 and this
should only be #ifdef BUS_SPACE_DEBUG?)

*** /usr/src/sys/arch/i386/include/param.h~	Thu Apr 30 07:12:09 1998
--- /usr/src/sys/arch/i386/include/param.h	Wed Jul  1 02:32:55 1998
***************
*** 69,75 ****
   */
  #define ALIGNBYTES		(sizeof(int) - 1)
  #define ALIGN(p)		(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
! #define ALIGNED_POINTER(p,t)	1
  
  #define	PGSHIFT		12		/* LOG2(NBPG) */
  #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
--- 69,76 ----
   */
  #define ALIGNBYTES		(sizeof(int) - 1)
  #define ALIGN(p)		(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
! #define ALIGNED_POINTER(p,t)	\
! 	((((u_long)(p)) & (sizeof(t)-1)) == 0)
  
  #define	PGSHIFT		12		/* LOG2(NBPG) */
  #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
>Audit-Trail:
>Unformatted: