Date: Wed, 14 Mar 2012 10:02:42 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r232963 - in stable/8/sys: boot/common i386/conf Message-ID: <201203141002.q2EA2gop096606@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Wed Mar 14 10:02:42 2012 New Revision: 232963 URL: http://svn.freebsd.org/changeset/base/232963 Log: MFC: r232822 Fix a bug introduced in r223938 (MFC'ed to stable/8 in r224411); on big-endian machines coping a 32-bit quantum bytewise to the address of a 64-bit variable results in writing to the "wrong" 32-bit half so adjust the address accordingly. This fix is implemented in a hackish way for two reasons: o in order to be able to get it into 8.3 with zero impact on the little- endian architectures where this bug has no effect and o to avoid blowing the x86 boot2 out of the water again when compiling it with clang, which all sane versions of this fix tested do. This change fixes booting from UFS1 file systems on big-endian machines. Modified: stable/8/sys/boot/common/ufsread.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/boot/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/e1000/ (props changed) stable/8/sys/i386/conf/XENHVM (props changed) Modified: stable/8/sys/boot/common/ufsread.c ============================================================================== --- stable/8/sys/boot/common/ufsread.c Wed Mar 14 10:02:35 2012 (r232962) +++ stable/8/sys/boot/common/ufsread.c Wed Mar 14 10:02:42 2012 (r232963) @@ -46,6 +46,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/endian.h> + #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> #include <ufs/ffs/fs.h> @@ -262,15 +264,28 @@ fsread(ino_t inode, void *buf, size_t nb } n = (lbn - NDADDR) & (n - 1); #if defined(UFS1_ONLY) +#if BYTE_ORDER == BIG_ENDIAN + memcpy((char *)&addr + sizeof(addr) - + sizeof(ufs1_daddr_t), (ufs1_daddr_t *)indbuf + n, + sizeof(ufs1_daddr_t)); +#else memcpy(&addr, (ufs1_daddr_t *)indbuf + n, sizeof(ufs1_daddr_t)); +#endif #elif defined(UFS2_ONLY) memcpy(&addr, (ufs2_daddr_t *)indbuf + n, sizeof(ufs2_daddr_t)); #else if (fs.fs_magic == FS_UFS1_MAGIC) +#if BYTE_ORDER == BIG_ENDIAN + memcpy((char *)&addr + sizeof(addr) - + sizeof(ufs1_daddr_t), + (ufs1_daddr_t *)indbuf + n, + sizeof(ufs1_daddr_t)); +#else memcpy(&addr, (ufs1_daddr_t *)indbuf + n, sizeof(ufs1_daddr_t)); +#endif else memcpy(&addr, (ufs2_daddr_t *)indbuf + n, sizeof(ufs2_daddr_t));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203141002.q2EA2gop096606>