From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5u5O-0002rt-VB for qemu-devel@nongnu.org; Mon, 07 Dec 2015 06:36:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a5u5L-0005iJ-LZ for qemu-devel@nongnu.org; Mon, 07 Dec 2015 06:36:06 -0500 Received: from mel.act-europe.fr ([194.98.77.210]:38397 helo=smtp.eu.adacore.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5u5L-0005i1-Fv for qemu-devel@nongnu.org; Mon, 07 Dec 2015 06:36:03 -0500 References: <1449241262-3002-1-git-send-email-azu@sysgo.de> From: Fabien Chouteau Message-ID: <56656F18.4060605@adacore.com> Date: Mon, 7 Dec 2015 12:35:52 +0100 MIME-Version: 1.0 In-Reply-To: <1449241262-3002-1-git-send-email-azu@sysgo.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] sparc: allow CASA with ASI 0xa from user space List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Zuepke , qemu-devel@nongnu.org Hello Alex, Thanks for your patch! I have a couple of comments. On 12/04/2015 04:01 PM, Alex Zuepke wrote: > LEON3 allows the CASA instruction to be used from user space > if the ASI is set to 0xa (user data). > > Signed-off-by: Alex Zuepke > --- > target-sparc/translate.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/target-sparc/translate.c b/target-sparc/translate.c > index 41a3319..63440dd 100644 > --- a/target-sparc/translate.c > +++ b/target-sparc/translate.c > @@ -5097,7 +5097,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) > if (IS_IMM) { > goto illegal_insn; > } > - if (!supervisor(dc)) { > + /* LEON3 allows CASA from user space with ASI 0xa */ Since this is a LEON3 specific feature, when you check the ASI you should also check CPU_FEATURE_CASA. > + if ((GET_FIELD(insn, 19, 26) != 0xa) && !supervisor(dc)) { > goto priv_insn; > } That would give you something like this: diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 41a3319..b93faea 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -2463,6 +2463,9 @@ static void gen_faligndata(TCGv dst, TCGv gsr, TCGv s1, TCGv s2) } #endif +#define IU_FEATURE(dc, FEATURE) \ + (((dc)->def->features & CPU_FEATURE_ ## FEATURE)) + #define CHECK_IU_FEATURE(dc, FEATURE) \ if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \ goto illegal_insn; @@ -5097,7 +5100,11 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) if (IS_IMM) { goto illegal_insn; } - if (!supervisor(dc)) { + + /* LEON3 allows CASA from user space with ASI 0xa */ + if (!((IU_FEATURE(dc, CASA) && + (GET_FIELD(insn, 19, 26) == 0xa)) + || supervisor(dc))) { goto priv_insn; } #endif to be tested of course ;) Regards,