From owner-svn-src-stable@FreeBSD.ORG Wed Mar 14 10:02:36 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 937E8106564A; Wed, 14 Mar 2012 10:02:36 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 63B418FC14; Wed, 14 Mar 2012 10:02:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2EA2aMi096567; Wed, 14 Mar 2012 10:02:36 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2EA2aYS096565; Wed, 14 Mar 2012 10:02:36 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201203141002.q2EA2aYS096565@svn.freebsd.org> From: Marius Strobl Date: Wed, 14 Mar 2012 10:02:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232962 - in stable/9/sys: boot/common i386/conf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Mar 2012 10:02:36 -0000 Author: marius Date: Wed Mar 14 10:02:35 2012 New Revision: 232962 URL: http://svn.freebsd.org/changeset/base/232962 Log: MFC: r232822 Fix a bug introduced in r223938; 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/9/sys/boot/common/ufsread.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/i386/conf/XENHVM (props changed) Modified: stable/9/sys/boot/common/ufsread.c ============================================================================== --- stable/9/sys/boot/common/ufsread.c Wed Mar 14 09:44:46 2012 (r232961) +++ stable/9/sys/boot/common/ufsread.c Wed Mar 14 10:02:35 2012 (r232962) @@ -46,6 +46,8 @@ #include __FBSDID("$FreeBSD$"); +#include + #include #include #include @@ -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));