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: 140803 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp75122ljj; Mon, 2 Jul 2018 08:18:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcrX1O1Sq7Sk82jXjKkUKVd5DzAuvR30rgMW/fKhikx41ABWUpmAlDZaPsAR5Po9JHVlM3R X-Received: by 2002:ac8:2f42:: with SMTP id k2-v6mr18860360qta.169.1530544728268; Mon, 02 Jul 2018 08:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544728; cv=none; d=google.com; s=arc-20160816; b=Iam9uLWDSQEw3JMl5Vvehtzn46nvpeP8VSn509XS66zEYt8qQ+g2uJJ3A2pwjamy4X mvcmpWPu3qWUDbMsnagCCr80bk8ev1ZnVTy4AgrWvImxIyl4Rlrsw2Rf2XFaXdlxacAa IruwLIiamJjLE6r7ex2cbprUiuu5xPFyLtcO6bbp2Fq9Czts2kPCYkKTLz/256N7ygbT vGnFCUNoRK4Y6v6WOqibeFGpusm9txvd5b68nL23RhYayoqL1YaxxskYA3Qa42LY1rQ+ deU0Z6Fs/5wi2YVrAJ+icv2IlkYxbv2+z7Mj/cGFs4gsTZ0zPPPq+SeEHnPBZjBUm2E3 L0Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Yixh9gBbGs/L/HsYKBIMiny0gxQr3xXkYWn48J9gsi0=; b=ruLhLVlAa8wFdU9oM0ib9K5XlfwTahdaQxV3eA7zLVXOxhsPeA2hW0Cu+CulnCHwU6 y+YmbPNodoH2cIvNSGflUO048EUwe0L0O/xD3XEGfjzNq09JG3uO/GV8F0MAqEaPQ8Nn tw1NKRS+BSALM4BN0mSWKShRml7WMopPWN+KEk3kcAg819ead7GbarfXInEuQKnfxiIH x+vcn01JS4mzfG3M1BzfL/QoAhh4gin4iPCxgnL0k/Bv2Sy9VVt/U3FDdcfpLN1LdeTe 26PYC8HOoR6pqU1PDBY9RWA5nx17j+Mk6XMhGWN5NKjiNz0y2vFhgOaTfOE8oDHto/w3 9C0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=udu5eby0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d47-v6si2515896qvd.46.2018.07.02.08.18.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=udu5eby0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0bH-0001dd-IJ for patch@linaro.org; Mon, 02 Jul 2018 11:18:47 -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-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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.0 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; }