From patchwork Mon Jul 2 15:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 10501827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE4D86028F for ; Mon, 2 Jul 2018 15:19:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C85F286F2 for ; Mon, 2 Jul 2018 15:19:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E8D628BDC; Mon, 2 Jul 2018 15:19:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 35E7F286F2 for ; Mon, 2 Jul 2018 15:19:58 +0000 (UTC) Received: from localhost ([::1]:33489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0cP-0002oj-9C for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 Jul 2018 11:19:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tl-00041Q-9I for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tj-0007rt-Uo for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:01 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:33271) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tj-0007ri-Oo for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:59 -0400 Received: by mail-pg0-x244.google.com with SMTP id e11-v6so7285956pgq.0 for ; Mon, 02 Jul 2018 08:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yixh9gBbGs/L/HsYKBIMiny0gxQr3xXkYWn48J9gsi0=; b=udu5eby0qJwFDT5Ye7sl8WFXXbMK2Tx2qKpb3b+/tyhewtgkj7SSWdYIySiN5MEnhs HzzQOuLWs1LLzCdKz21QhmFG56t77N8t6DVCIaoZNhgG9+7ZynxmxLpF6E0YeXdxizOu VLcSOAvKfKf2zwaodg3soHQmK3Zc4SHTtPX+KjS7xh5zQMpwyY3SnI0w9r6ioVD8Bmz2 n7N582h//l1A2VZuwSptE/n8Azwo3kkKZsnvtIicOPN06hxXINu5skOi41vpAcFG6Q+o EeNpLHUbJwC0+nmzFN4vE6VxRa6Cxk44D6AvN7Z3oLjeREaAZ03hV4BnWJ7vWXfys2sy TdvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yixh9gBbGs/L/HsYKBIMiny0gxQr3xXkYWn48J9gsi0=; b=rF4APYId4uDFWB4dCQ0JKWHLXiR/N/240Kkjh/otbr+UmMKIBOQQv3E8ndl3qceBdl JWMyazim4a5T4oWULOHWqgCa4h5VIEe4no3tB5+w1yFpeffxP5wMVLF2esklyf/47GOg x4D4p0epa+N84LFB9rh67YYrgurx/ONe48WZUsBOryeFVeKDXwOI9JGbMddUgfAQzWGZ Jbn+WchxdIHXNl2OpEmQcmqJUyj7uVbhqywnbrcC8qmPmNqXw0IIbeWmQ49NfWdD+Lu9 lX3t7J328L7KodN1+SF9CACtit9U+xFKqycOlNiTCxd7/rbNzISWkMWMsXPg2zNtTwn8 gJGw== X-Gm-Message-State: APt69E1NQIQV/wWZPmFWwmRbngfA+y0EveJt7hR04T7Gs6GMlgnJmG0K ApQIQ1pR9GwiSEzrGWRitk0= X-Google-Smtp-Source: ADUXVKL/BBcYiR82KkEiSXw+fXqYQzVM+nitN1O1RKTqGj5bga4f4SR0CHemHS1S+YRjKckhFjWZLQ== X-Received: by 2002:a63:64c2:: with SMTP id y185-v6mr21922531pgb.126.1530544258956; Mon, 02 Jul 2018 08:10:58 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id v14-v6sm13846096pfi.55.2018.07.02.08.10.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:58 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:06 +0900 Message-Id: <20180702151023.24532-9-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PULL v2 08/25] target/openrisc: Split out is_user X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Richard Henderson This allows us to limit the amount of ifdefs and isolate the test for usermode. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/translate.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index a618d39242..db149986af 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -50,6 +50,15 @@ typedef struct DisasContext { target_ulong jmp_pc_imm; } DisasContext; +static inline bool is_user(DisasContext *dc) +{ +#ifdef CONFIG_USER_ONLY + return true; +#else + return dc->mem_idx == MMU_USER_IDX; +#endif +} + /* Include the auto-generated decoder. */ #include "decode.inc.c" @@ -853,33 +862,25 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a, uint32_t insn) { check_r0_write(a->d); -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti = tcg_const_i32(a->k); gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], ti); tcg_temp_free_i32(ti); } -#endif return true; } static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) { -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti = tcg_const_i32(a->k); gen_helper_mtspr(cpu_env, cpu_R[a->a], cpu_R[a->b], ti); tcg_temp_free_i32(ti); } -#endif return true; } @@ -1104,16 +1105,12 @@ static bool trans_l_csync(DisasContext *dc, arg_l_csync *a, uint32_t insn) static bool trans_l_rfe(DisasContext *dc, arg_l_rfe *a, uint32_t insn) { -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { gen_helper_rfe(cpu_env); dc->base.is_jmp = DISAS_EXIT; } -#endif return true; }