From: "KUWAMURA Shin'ya" Subject: [PATCH] libfsimage: FAT: Fix unaligned access Date: Wed, 08 Aug 2007 14:19:51 +0900 (JST) Message-ID: <20070808.141951.08319847.kuwa@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Aug__8_14_19_51_2007_855)--" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org ----Next_Part(Wed_Aug__8_14_19_51_2007_855)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, Using pygrub on IA64, the following messages output: pygrub(5742): unaligned access to 0x600000000013515c, ip=0x2000000003b721f0 pygrub(5742): unaligned access to 0x600000000013515e, ip=0x2000000003b721f0 pygrub(5742): unaligned access to 0x6000000000135162, ip=0x2000000003b721f0 pygrub(5742): unaligned access to 0x6000000000135164, ip=0x2000000003b721f0 pygrub(5742): unaligned access to 0x6000000000135166, ip=0x2000000003b721f0 The ip indicates this line of tools/libfsimage/fat/fsys_fat.c:231: next_cluster = * (unsigned long *) (FAT_BUF + (cached_pos >> 1)); If the partition is FAT16, this access causes an unaligned access. This patch fixes it. Signed-off-by: Kouya Shimura Signed-off-by: KUWAMURA Shin'ya Best Regards, -- KUWAMURA Shin'ya ----Next_Part(Wed_Aug__8_14_19_51_2007_855)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fsys_fat.patch" diff -r 7953164cebb6 tools/libfsimage/fat/fsys_fat.c --- a/tools/libfsimage/fat/fsys_fat.c Tue Aug 07 09:07:29 2007 +0100 +++ b/tools/libfsimage/fat/fsys_fat.c Wed Aug 08 13:28:54 2007 +0900 @@ -228,15 +228,15 @@ fat_read (fsi_file_t *ffi, char *buf, in if (!devread (ffi, sector, 0, FAT_CACHE_SIZE, (char*) FAT_BUF)) return 0; } - next_cluster = * (unsigned long *) (FAT_BUF + (cached_pos >> 1)); + next_cluster = ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[0]; if (FAT_SUPER->fat_size == 3) { if (cached_pos & 1) next_cluster >>= 4; next_cluster &= 0xFFF; } - else if (FAT_SUPER->fat_size == 4) - next_cluster &= 0xFFFF; + else if (FAT_SUPER->fat_size > 4) + next_cluster |= ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[1] << 16; if (next_cluster >= FAT_SUPER->clust_eof_marker) return ret; ----Next_Part(Wed_Aug__8_14_19_51_2007_855)-- Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ----Next_Part(Wed_Aug__8_14_19_51_2007_855)----