From patchwork Thu Jun 28 03:03:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 140393 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1649254ljj; Wed, 27 Jun 2018 20:12:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfynw7LwDV2OLChSCFIzfMlMuc+2B38W9nE383l/PDSrpZBX9ugvRigbqpP6GoLqjSkHVb1 X-Received: by 2002:ac8:1987:: with SMTP id u7-v6mr7750838qtj.296.1530155538284; Wed, 27 Jun 2018 20:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530155538; cv=none; d=google.com; s=arc-20160816; b=FdPX8HOHdOuThxVtvnexUGS7SpdR/945HCOI6CIRbOCfx91QIwtYyozZkGZ27CrFHV uC98rVPnM5UbS6egXLD7i6l/0ilcttOXTuBYsMvY1AAEReZ0ZhP/duu1+Ilehk3PQlZk ndkVT30HrnljlalwzI0VUnLVta+IA4T0oc5V0qR58Zs4mSbFoZUYU5fQFeAGc1oTUZ61 4D4QZ8NRgXDbp5UVNPEnbyXozJWC1+gGNbByXb6xgm/Rk5VH3CZGLrJElx2O9ln4pd00 WZIsvopmrZ1aEgu6bxNgZBlPOq8XZWC3jqKbrPmEBLYrlJvB1aoQ8gEYXq8qD2On5fW0 y/pQ== 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=HfUf5ME0B58UupEHc+Qjiiql58dh2ZppYbSI6v7Vjbc=; b=Pk5qG1uxbxHmBdm54KxR6hQ9aWhJ55BDvZxoqO1N8uwSDpi6Zhq5kWSY3qpKITEn6T 09rb78Mn8g8BbJw8lYt8bsWnjjFqr5otu57p1sOd9QvP96wmxpMS7SgTcfnDDavovcVh 0pTiY++fNPToX1x+R+CRtcYGvsB14sukEjMdBUwC3THgD2uerlrTz6JRGhXLtimTXNAC 1R+LT2lshESMrFzOEn7rpelYtVBxW7iiRCxi1q0bk0i6bOH6nPgFs8a/3p+vL8oCdQj/ lLGeBvokLu1i+cbE1euACpxfSwO8jZV1DscwEd8ksnTauXlc3+LxRUJu4fZX1HiW9Bal 7RsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Y8Yij7/+"; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f3-v6si5585964qkc.82.2018.06.27.20.12.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jun 2018 20:12:18 -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=@linaro.org header.s=google header.b="Y8Yij7/+"; 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=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYNM1-0002hH-L7 for patch@linaro.org; Wed, 27 Jun 2018 23:12:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYNDo-00050Y-S6 for qemu-devel@nongnu.org; Wed, 27 Jun 2018 23:03:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYNDk-0007l6-TF for qemu-devel@nongnu.org; Wed, 27 Jun 2018 23:03:48 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:45138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYNDk-0007jM-Mf for qemu-devel@nongnu.org; Wed, 27 Jun 2018 23:03:44 -0400 Received: by mail-pf0-x242.google.com with SMTP id a22-v6so1883172pfo.12 for ; Wed, 27 Jun 2018 20:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HfUf5ME0B58UupEHc+Qjiiql58dh2ZppYbSI6v7Vjbc=; b=Y8Yij7/+xl4Dt7p4ZyR7+X5TxndFB2dUgMqhggJ7cUAnQdfv1V38s2GeBgJh3UhO77 S4SA8Q5SHLpAhOWySEGHY79//TFnB0VrzViVrf32fovLIKRRkIaOy9y1KGT46OBgKxjZ C3XY7235IJxIRLzdmRNNuXhwZ6Z5+7FL4lgKs= 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=HfUf5ME0B58UupEHc+Qjiiql58dh2ZppYbSI6v7Vjbc=; b=J6Y/CZd7LAG/i2eWqqlMwaAeNDFAHB2whSQVVxUvksKbHnXjOXtGspsVH+ecUXOLRC oDUgdvi0xwwv+RHDOZuYGqrgLrErmx0qfJ5tcq+37h6IJHet9wq6juZUbAC6HHTUFr5J FeCKFvD812TI0Vg+MX5IMfTGcPQhFyCTeEUnjJZdM6983dVqe6NI1fWFwr0jIuIVLap6 gc+0vz1KASNVW2FbUZXjeQMuq6PCI1TSBWruc2YbsYUoyArcyaQaxKlQxhoc+PV9CrRd PQuD9yjGeNXdsqCAWTmY6UaRWYbboak91oaz3aguvZKKKNkALL7N8Nyq/udmqo7h0JPj Lcww== X-Gm-Message-State: APt69E3qJbjzUgmi+kjuCLlPxO8xQ2K7SRwHbS7Gu70NJBYjLvQ+rKXp 19kmM/um5PZLaUHCQViXaWHe3umZGmM= X-Received: by 2002:a62:39cd:: with SMTP id u74-v6mr8397359pfj.95.1530155023458; Wed, 27 Jun 2018 20:03:43 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id y15-v6sm8030489pfm.136.2018.06.27.20.03.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Jun 2018 20:03:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Jun 2018 20:03:15 -0700 Message-Id: <20180628030330.15615-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180628030330.15615-1-richard.henderson@linaro.org> References: <20180628030330.15615-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v3 08/23] 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: shorne@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- target/openrisc/translate.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) -- 2.17.1 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; }