NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/54395: earmv7hf binaries trigger kernel panic on aarch64



The following reply was made to PR kern/54395; it has been noted by GNATS.

From: Rin Okuyama <rokuyama.rk%gmail.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: Valery Ushakov <uwe%stderr.spb.ru@localhost>, Joerg Sonnenberger <joerg%bec.de@localhost>
Subject: Re: kern/54395: earmv7hf binaries trigger kernel panic on aarch64
Date: Wed, 2 Oct 2019 17:59:22 +0900

 On 2019/10/01 21:40, Valery Ushakov wrote:
 > +#define ALIGN_VA(va, align, topdown) do { \
 > +	if ((align) != 0 && ((va) & ((align) - 1)) != 0) { \
 > +		if (topdown) \
 > +			(va) &= ~((align) - 1); \
 >   
 > Use roundown2() here?
 >   
 > +		else \
 > +			(va) = roundup(va, align); \
 >   
 > Use roundup2() here instead, which avoids multiplication?
 
 Thank you for your comments! Yes, we can use round{down,up}2() here.
 
 > We don't seem to have a convenience macro for testing power of 2
 > alignment to use in the test though.
 
 We have powerof2(9) macro in sys/param.h:
 
 https://nxr.netbsd.org/xref/src/sys/sys/param.h#427
      427 #define	powerof2(x)	((((x)-1)&(x))==0)
 
 ALIGN_VA() macro in the patch is used in uvm_map_space_avail() and
 uvm_map_findspace(). For the latter, we already have an equivalent
 check:
 
 https://nxr.netbsd.org/xref/src/sys/uvm/uvm_map.c#1850
     1850 struct vm_map_entry *
     1851 uvm_map_findspace(struct vm_map *map, vaddr_t hint, vsize_t length,
     1852     vaddr_t *result /* OUT */, struct uvm_object *uobj, voff_t uoffset,
     1853     vsize_t align, int flags)
     ....
     1864 	KASSERT((flags & UVM_FLAG_COLORMATCH) != 0 || (align & (align - 1)) == 0);
 
 I rewrote this with powerof2(9). For the former, I added KASSERT.
 
 I updated the patch accordingly. Also, VA_ALIGN() macro was turned
 into inline function va_align() (Thanks Joerg for his comment):
 
 http://www.netbsd.org/~rin/uvm_map_20191002.patch
 
 I will commit the revised patch and send a pullup request in the
 weekend, if there's no objections.
 
 Thanks,
 rin
 


Home | Main Index | Thread Index | Old Index