From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjmtT-0000KR-DC for qemu-devel@nongnu.org; Tue, 13 Sep 2016 08:32:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjmtO-0006D9-D2 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 08:32:55 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:20622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjmtO-0006Ap-6t for qemu-devel@nongnu.org; Tue, 13 Sep 2016 08:32:50 -0400 Date: Tue, 13 Sep 2016 13:32:31 +0100 From: Leon Alrae Message-ID: <20160913123230.GA10583@hhmipssw201.hh.imgtec.org> References: <1472935202-3342-1-git-send-email-rth@twiddle.net> <1472935202-3342-14-git-send-email-rth@twiddle.net> <20160909144616.GA6795@hhmipssw201.hh.imgtec.org> <20160912075932.GA3300@hhmipssw201.hh.imgtec.org> <111ee94e-124b-3a84-0de7-ee81faecd07f@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <111ee94e-124b-3a84-0de7-ee81faecd07f@twiddle.net> Subject: Re: [Qemu-devel] [PATCH v3 13/34] tcg: Add atomic helpers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: "qemu-devel@nongnu.org" On Mon, Sep 12, 2016 at 09:13:10AM -0700, Richard Henderson wrote: > On 09/12/2016 12:59 AM, Leon Alrae wrote: > >On Fri, Sep 09, 2016 at 09:26:29AM -0700, Richard Henderson wrote: > >>On 09/09/2016 07:46 AM, Leon Alrae wrote: > >>>Wouldn't it be useful if tcg.h provided also aliases for _le/_be atomic > >>>helpers (equivalent to helper_ret_X_mmu) so that in target-* code we wouldn't > >>>need to care about the endianness (specifically I'm thinking about SC in MIPS > >>>where I need to select between helper_atomic_cmpxchgl_le_mmu() and > >>>helper_atomic_cmpxchgl_be_mmu()). > >> > >>Perhaps. I would have hoped that you could do the SC inline now > >>though, and tcg_gen_atomic_cmpxchg() will do the selection for you. > > > >On every SC we need to do the virtual -> physical address translation as we > >have to compare the physical address against that of the preceeding LL. > >This operation seems too complex to be inlined :( > > What happens if you do virtual address comparisons, like everyone > else? It might not be strictly correct, but in practice I bet its > no worse than using cmpxchg in the first place. Yeah, probably true. Moreover, MIPS Instruction Set Manual explicitly says that an RMW sequence must use the same address in the LL and SC (virtual address, physical address, cacheability and coherency attributes must be identical). Otherwise the result of the SC is not predictable. I'll try to come up with simpler SC implementation using virtual addresses and tcg_gen_atomic_cmpxchg(). Thanks, Leon