From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDyYI-0001oD-HO for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:50:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDyYC-0006C4-MQ for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:50:14 -0500 Received: from mel.v6.act-europe.fr ([2a02:2ab8:224:1::a0a:d2]:47249 helo=smtp.eu.adacore.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDyYC-0006BZ-Cg for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:50:08 -0500 Message-ID: <52FCE9BC.7040703@adacore.com> Date: Thu, 13 Feb 2014 16:50:20 +0100 From: Fabien Chouteau MIME-Version: 1.0 References: <1392285137-10598-1-git-send-email-sebastian.huber@embedded-brains.de> <52FCB414.2050306@adacore.com> <52FCC1F3.9020205@embedded-brains.de> <52FCDCD7.3070903@adacore.com> In-Reply-To: <52FCDCD7.3070903@adacore.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] SPARC: Add and use CPU_FEATURE_CASA List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sebastian Huber Cc: blauwirbel@gmail.com, qemu-devel@nongnu.org On 02/13/2014 03:55 PM, Fabien Chouteau wrote: > On 02/13/2014 02:00 PM, Sebastian Huber wrote: >> On 2014-02-13 13:01, Fabien Chouteau wrote: >>> On 02/13/2014 10:52 AM, Sebastian Huber wrote: >>>> The LEON3 processor has support for the CASA instruction which is >>>> normally only available for SPARC V9 processors. Binutils 2.24 >>>> and GCC 4.9 will support this instruction for LEON3. GCC uses it to >>>> generate C11 atomic operations. >>>> >>>> The CAS synthetic instruction uses an ASI of 0x80. If TARGET_SPARC64 is >>>> not defined use a supervisor data load/store for an ASI of 0x80 in >>>> helper_ld_asi()/helper_st_asi(). >>>> >>> >>> Hello Sebastian, >>> >>> If I understand correctly, the difference with V1 is that ASI 0x80. Why >>> did you chose Supervisor data access against User data access? >> >> User data access would work also. I don't have a preference here. >> >>> (I cannot >>> find documentation about 0x80 ASI) >> >> GCC will generate CAS instructions, e.g. > > ... > >> In the GNU Binutils you find: >> >> opcodes/sparc-opc.c:{ "cas", F3(3, 0x3c, 0)|ASI(0x80), F3(~3, ~0x3c, ~0)|ASI(~0x80), "[1],2,d", F_ALIAS, 0, v9andleon }, /* casa [rs1]ASI_P,rs2,rd */ >> >> This is where the 0x80 comes from. >> > > In some leon3 doc I found this: > > 62.2.7 Compare and Swap instruction (CASA) > LEON3 implements the SPARC V9 Compare and Swap Alternative (CASA) instruction. The CASA > is enabled the interger load delay is set to 1 and the NOTAG generic is 0. The CASA operates as > described in the SPARC V9 manual. The instruction is privileged but setting ASI = 0xA (user data) > will allow it to be used in user mode. > > Which confirm privileged instruction. I will ask our GCC expert if they > know where that 0x80 ASI comes from. > This ASI 0x80 is really defined nowhere in Leon3 not even in the sources :) Maybe there's a bug in binutils... Did you try to run this program on a real board? --- sparc.vhd --- subtype asi_type is std_logic_vector(4 downto 0); constant ASI_SYSR : asi_type := "00010"; -- 0x02 constant ASI_UINST : asi_type := "01000"; -- 0x08 constant ASI_SINST : asi_type := "01001"; -- 0x09 constant ASI_UDATA : asi_type := "01010"; -- 0x0A constant ASI_SDATA : asi_type := "01011"; -- 0x0B constant ASI_ITAG : asi_type := "01100"; -- 0x0C constant ASI_IDATA : asi_type := "01101"; -- 0x0D constant ASI_DTAG : asi_type := "01110"; -- 0x0E constant ASI_DDATA : asi_type := "01111"; -- 0x0F constant ASI_IFLUSH : asi_type := "10000"; -- 0x10 constant ASI_DFLUSH : asi_type := "10001"; -- 0x11 constant ASI_FLUSH_PAGE : std_logic_vector(4 downto 0) := "10000"; -- 0x10 i/dcache flush page constant ASI_FLUSH_CTX : std_logic_vector(4 downto 0) := "10011"; -- 0x13 i/dcache flush ctx constant ASI_DCTX : std_logic_vector(4 downto 0) := "10100"; -- 0x14 dcache ctx constant ASI_ICTX : std_logic_vector(4 downto 0) := "10101"; -- 0x15 icache ctx constant ASI_MMUFLUSHPROBE : std_logic_vector(4 downto 0) := "11000"; -- 0x18 i/dtlb flush/(probe) constant ASI_MMUREGS : std_logic_vector(4 downto 0) := "11001"; -- 0x19 mmu regs access constant ASI_MMU_BP : std_logic_vector(4 downto 0) := "11100"; -- 0x1c mmu Bypass constant ASI_MMU_DIAG : std_logic_vector(4 downto 0) := "11101"; -- 0x1d mmu diagnostic --constant ASI_MMU_DSU : std_logic_vector(4 downto 0) := "11111"; -- 0x1f mmu diagnostic constant ASI_MMUSNOOP_DTAG : std_logic_vector(4 downto 0) := "11110"; -- 0x1e mmusnoop physical dtag