> > +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