From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHf11-0003pj-HY for qemu-devel@nongnu.org; Wed, 04 May 2011 12:33:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QHf10-0008Mt-Mt for qemu-devel@nongnu.org; Wed, 04 May 2011 12:33:31 -0400 Received: from mail-px0-f173.google.com ([209.85.212.173]:33651) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHf10-0008Mf-G3 for qemu-devel@nongnu.org; Wed, 04 May 2011 12:33:30 -0400 Received: by pxi16 with SMTP id 16so1050799pxi.4 for ; Wed, 04 May 2011 09:33:29 -0700 (PDT) Sender: Richard Henderson Message-ID: <4DC17FCF.2090706@twiddle.net> Date: Wed, 04 May 2011 09:33:19 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1304470768-16924-1-git-send-email-jcmvbkbc@gmail.com> <1304470768-16924-18-git-send-email-jcmvbkbc@gmail.com> In-Reply-To: <1304470768-16924-18-git-send-email-jcmvbkbc@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC 18/28] target-xtensa: implement exceptions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Filippov Cc: qemu-devel@nongnu.org On 05/03/2011 05:59 PM, Max Filippov wrote: > +static void gen_check_privilege(DisasContext *dc) > +{ > + if (option_enabled(dc, XTENSA_OPTION_MMU)) { > + TCGv_i32 tmp = tcg_temp_new_i32(); > + int label = gen_new_label(); > + > + tcg_gen_andi_i32(tmp, cpu_SR[PS], PS_EXCM); > + tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, PS_EXCM, label); > + tcg_gen_andi_i32(tmp, cpu_SR[PS], PS_RING); > + tcg_gen_brcondi_i32(TCG_COND_GEU, tmp, 0, label); > + > + gen_exception_cause(dc, PRIVILEGED_CAUSE); > + > + gen_set_label(label); > + tcg_temp_free(tmp); > + } > +} This is a case where you almost certainly want to check this condition inside QEMU and translate the opcode differently. See cpu_get_tb_cpu_state, which sets bits in *flags. These flags can then be checked in tb->flags while translating. At which point you'd avoid all the conditionalization on the value in PS here in check_privilege and merely issue the exception_cause. The ARM port is a good example for testing these sorts of bits. r~