From nobody Tue Nov 4 18:42:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530544836449279.50846075632296; Mon, 2 Jul 2018 08:20:36 -0700 (PDT) Received: from localhost ([::1]:33489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0d1-0002oj-Ki for importer@patchew.org; Mon, 02 Jul 2018 11:20:35 -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) 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) 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9 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; =20 +static inline bool is_user(DisasContext *dc) +{ +#ifdef CONFIG_USER_ONLY + return true; +#else + return dc->mem_idx =3D=3D MMU_USER_IDX; +#endif +} + /* Include the auto-generated decoder. */ #include "decode.inc.c" =20 @@ -853,33 +862,25 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfs= pr *a, uint32_t insn) { check_r0_write(a->d); =20 -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx =3D=3D MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti =3D tcg_const_i32(a->k); gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], t= i); tcg_temp_free_i32(ti); } -#endif return true; } =20 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 =3D=3D MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti =3D 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; } =20 @@ -1104,16 +1105,12 @@ static bool trans_l_csync(DisasContext *dc, arg_l_c= sync *a, uint32_t insn) =20 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 =3D=3D MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { gen_helper_rfe(cpu_env); dc->base.is_jmp =3D DISAS_EXIT; } -#endif return true; } =20 --=20 2.17.0