From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ysclv-0003l3-Ek for qemu-devel@nongnu.org; Wed, 13 May 2015 15:56:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yscls-0000u5-4o for qemu-devel@nongnu.org; Wed, 13 May 2015 15:56:51 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:47238 helo=cvs.linux-mips.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ysclr-0000oI-Sd for qemu-devel@nongnu.org; Wed, 13 May 2015 15:56:48 -0400 Received: (from localhost user: 'macro', uid#1010) by eddie.linux-mips.org with ESMTP id S27010788AbbEMT4hm9jYq (ORCPT ); Wed, 13 May 2015 21:56:37 +0200 Date: Wed, 13 May 2015 20:56:37 +0100 (BST) Sender: "Maciej W. Rozycki" From: "Maciej W. Rozycki" In-Reply-To: <5553A5C4.6030902@twiddle.net> Message-ID: References: <1431531457-17127-1-git-send-email-yongbok.kim@imgtec.com> <1431531457-17127-3-git-send-email-yongbok.kim@imgtec.com> <5553A5C4.6030902@twiddle.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH v3 2/2] target-mips: Misaligned memory accesses for MSA List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: Yongbok Kim , peter.maydell@linaro.org, leon.alrae@imgtec.com, qemu-devel@nongnu.org, afaerber@suse.de On Wed, 13 May 2015, Richard Henderson wrote: > > +static inline void ensure_atomic_msa_block_access(CPUMIPSState *env, > > + target_ulong addr, > > + int rw, > > + int mmu_idx) > > { > > +#if !defined(CONFIG_USER_ONLY) > > +#define MSA_PAGESPAN(x) (unlikely((((x) & ~TARGET_PAGE_MASK) \ > > + + MSA_WRLEN/8 - 1) >= TARGET_PAGE_SIZE)) > > + CPUState *cs = CPU(mips_env_get_cpu(env)); > > + target_ulong page_addr; > > > > + if (MSA_PAGESPAN(addr)) { > > + /* first page */ > > + tlb_fill(cs, addr, rw, mmu_idx, 0); > > + /* second page */ > > + page_addr = (addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; > > + tlb_fill(cs, page_addr, rw, mmu_idx, 0); > > } > > +#endif > > } > > This doesn't do quite what you think it does. It does trap if the page isn't > mapped at all, but it doesn't trap if e.g. rw is set and the page is read-only. > That requires a subsequent check for what permissions were installed by > tlb_set_page. > > I had thought there was a way to look this up besides duplicating the code in > softmmu_template.h, but I suppose that's in a patch set that never made it in. We must have a way to deal with memory access operations issued by a single machine instruction crossing a page boundary already as this is what MIPS16 SAVE and RESTORE instructions as well as microMIPS SWP, SDP, SWM, SDM, LWP, LDP, LWM and LDM ones do. Perhaps these are worth looking into and their approach copying (or reusing) here? Maciej