From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QO7UG-0004Kf-3y for qemu-devel@nongnu.org; Sun, 22 May 2011 08:10:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QO7UE-0003zB-Ty for qemu-devel@nongnu.org; Sun, 22 May 2011 08:10:24 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:47629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QO7UE-0003z3-PB for qemu-devel@nongnu.org; Sun, 22 May 2011 08:10:22 -0400 Received: by eyb6 with SMTP id 6so1920852eyb.4 for ; Sun, 22 May 2011 05:10:21 -0700 (PDT) From: Max Filippov Date: Sun, 22 May 2011 16:10:16 +0400 References: <1305671572-5899-1-git-send-email-jcmvbkbc@gmail.com> <1305671572-5899-22-git-send-email-jcmvbkbc@gmail.com> <4DD593E6.1060704@twiddle.net> In-Reply-To: <4DD593E6.1060704@twiddle.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201105221610.17663.jcmvbkbc@gmail.com> Subject: Re: [Qemu-devel] [PATCH 21/26] target-xtensa: implement unaligned exception option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org > > +static void gen_load_store_alignment(DisasContext *dc, int shift, TCGv_i32 addr) > > +{ > > + TCGv_i32 tmp = tcg_temp_local_new_i32(); > > + tcg_gen_mov_i32(tmp, addr); > > + tcg_gen_andi_i32(addr, addr, ~0 << shift); > > + if (option_enabled(dc, XTENSA_OPTION_UNALIGNED_EXCEPTION)) { > > + int label = gen_new_label(); > > + tcg_gen_brcond_i32(TCG_COND_EQ, addr, tmp, label); > > + gen_exception_cause_vaddr(dc, LOAD_STORE_ALIGNMENT_CAUSE, tmp); > > + gen_set_label(label); > > + } > > + tcg_temp_free(tmp); > > +} > > This is not the correct method for this. Set ALIGNED_ONLY before > defining the softmmu_templates. Define do_unaligned_access to raise > the exception. See e.g. target-sparc/op_helper.c. There are three alignment possibilities for xtensa: no unaligned exception, unaligned exception and hardware alignment. In the first case unaligned access silently goes to aligned address. It looks like it cannot be done via do_unaligned_access, can it? In the third case most unaligned accesses are handled transparently by the hardware. But e.g. unaligned access by multiprocessor synchronization instructions still cause alignment exception. Do I need to implement a different alignment checking mechanism for those unhandled cases? Thanks. -- Max