From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HY3V6-0005hJ-7z for qemu-devel@nongnu.org; Sun, 01 Apr 2007 13:05:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HY3V5-0005gm-96 for qemu-devel@nongnu.org; Sun, 01 Apr 2007 13:05:55 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HY3V4-0005gj-Vh for qemu-devel@nongnu.org; Sun, 01 Apr 2007 13:05:55 -0400 Received: from farad.aurel32.net ([82.232.2.251] helo=mail.aurel32.net) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HY3S7-0005ya-V2 for qemu-devel@nongnu.org; Sun, 01 Apr 2007 13:02:52 -0400 Received: from amd64.aurel32.net ([2001:618:400:fc13:216:3eff:fe00:1009]) by mail.aurel32.net with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1HY3S5-0003NV-K4 for qemu-devel@nongnu.org; Sun, 01 Apr 2007 19:02:49 +0200 Received: from aurel32 by amd64.aurel32.net with local (Exim 4.63) (envelope-from ) id 1HY3S5-00011K-3r for qemu-devel@nongnu.org; Sun, 01 Apr 2007 19:02:49 +0200 Date: Sun, 1 Apr 2007 19:02:49 +0200 From: Aurelien Jarno Message-ID: <20070401170248.GA3005@amd64.aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Subject: [Qemu-devel] [PATCH][SPARC] mem_address_not_aligned trap for unaligned PC Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi all, According to the SPARCv8 and SPARCv9 manuals, the jmpl, rett and return instructions should generate a mem_address_not_aligned trap if either of the low-order two bits of the target address is nonzero. The patch below implements that. Bye, Aurelien Index: target-sparc/cpu.h =================================================================== RCS file: /sources/qemu/qemu/target-sparc/cpu.h,v retrieving revision 1.32 diff -u -d -p -r1.32 cpu.h --- target-sparc/cpu.h 1 Apr 2007 15:15:36 -0000 1.32 +++ target-sparc/cpu.h 1 Apr 2007 16:51:22 -0000 @@ -35,6 +35,7 @@ #define TT_NFPU_INSN 0x04 #define TT_WIN_OVF 0x05 #define TT_WIN_UNF 0x06 +#define TT_UNALIGNED 0x07 #define TT_FP_EXCP 0x08 #define TT_DFAULT 0x09 #define TT_TOVF 0x0a @@ -55,6 +56,7 @@ #define TT_DFAULT 0x30 #define TT_DMISS 0x31 #define TT_DPROT 0x32 +#define TT_UNALIGNED 0x34 #define TT_PRIV_ACT 0x37 #define TT_EXTINT 0x40 #define TT_SPILL 0x80 Index: target-sparc/op.c =================================================================== RCS file: /sources/qemu/qemu/target-sparc/op.c,v retrieving revision 1.27 diff -u -d -p -r1.27 op.c --- target-sparc/op.c 1 Apr 2007 15:38:17 -0000 1.27 +++ target-sparc/op.c 1 Apr 2007 17:01:15 -0000 @@ -1486,7 +1486,10 @@ void OPPROTO op_movl_npc_im(void) void OPPROTO op_movl_npc_T0(void) { - env->npc = T0; + if (T0 & 0x3) + raise_exception(TT_UNALIGNED); + else + env->npc = T0; } void OPPROTO op_mov_pc_npc(void) -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net