Date: Mon, 21 Feb 2011 21:39:09 -0800 From: Artem Belevich <fbsdlist@src.cx> To: "Jayachandran C." <c.jayachandran@gmail.com> Cc: freebsd-mips@freebsd.org Subject: Re: lib/libc/mips/string/bzero.S -- problem in 64-bit mode. Message-ID: <AANLkTin7%2Bf5v6fBX-TeMt=BxrH_3r1Qb_Y_y=HJ08Z=K@mail.gmail.com> In-Reply-To: <AANLkTim83G00D_xw1tyK8qyVwOWL6-_ivpt-zDOoe3-U@mail.gmail.com> References: <AANLkTik2evgf4-k85P%2Bsm953ofa0=UNd7o2uWhQw7qiB@mail.gmail.com> <AANLkTim83G00D_xw1tyK8qyVwOWL6-_ivpt-zDOoe3-U@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] > I just tested this with a simple program - and there is certainly an > issue here. If you can send me a patch, I can check that in after > testing. Try attached diff. > The kernel version of bzero() does not seem to have the SZREG==8 case, > and this bug. True. It still uses 32-bit sw to zero stuff out. There are number of routines in the kernel that could take advantage of 64-bit instructions. --Artem [-- Attachment #2 --] diff --git a/lib/libc/mips/string/bzero.S b/lib/libc/mips/string/bzero.S index 66f29dd..83e54ba 100644 --- a/lib/libc/mips/string/bzero.S +++ b/lib/libc/mips/string/bzero.S @@ -58,27 +58,9 @@ LEAF(bzero) PTR_SUBU a3, zero, a0 # compute # bytes to word align address and a3, a3, SZREG-1 beq a3, zero, 1f # skip if word aligned -#if SZREG == 4 PTR_SUBU a1, a1, a3 # subtract from remaining count - SWHI zero, 0(a0) # clear 1, 2, or 3 bytes to align + REG_SHI zero, 0(a0) # clear 1, 2, or 3 bytes to align PTR_ADDU a0, a0, a3 -#endif -#if SZREG == 8 - PTR_SUBU a1, a1, a3 # subtract from remaining count - PTR_ADDU a0, a0, a3 # align dst to next word - sll a3, a3, 3 # bits to bytes - li a2, -1 # make a mask -#if _BYTE_ORDER == _BIG_ENDIAN - REG_SRLV a2, a2, a3 # we want to keep the MSB bytes -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN - REG_SLLV a2, a2, a3 # we want to keep the LSB bytes -#endif - nor a2, zero, a2 # complement the mask - REG_L v0, -SZREG(a0) # load the word to partially clear - and v0, v0, a2 # clear the bytes - REG_S v0, -SZREG(a0) # store it back -#endif 1: and v0, a1, SZREG-1 # compute number of words left PTR_SUBU a3, a1, v0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTin7%2Bf5v6fBX-TeMt=BxrH_3r1Qb_Y_y=HJ08Z=K>
