From patchwork Mon May 19 09:22:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 350171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 19DDD140086 for ; Mon, 19 May 2014 19:27:26 +1000 (EST) Received: from localhost ([::1]:46832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmJqt-0007ui-O7 for incoming@patchwork.ozlabs.org; Mon, 19 May 2014 05:27:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmJq6-0006pk-H1 for qemu-devel@nongnu.org; Mon, 19 May 2014 05:26:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmJq0-0005vt-F0 for qemu-devel@nongnu.org; Mon, 19 May 2014 05:26:34 -0400 Received: from mail-yk0-x232.google.com ([2607:f8b0:4002:c07::232]:42418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmJq0-0005uu-Bv for qemu-devel@nongnu.org; Mon, 19 May 2014 05:26:28 -0400 Received: by mail-yk0-f178.google.com with SMTP id 20so4294079yks.9 for ; Mon, 19 May 2014 02:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QZzPVnR3Rh2+Hmr+Y8pKeD3dnP/nifPQDgXPmaTSMvY=; b=IhqgINwD1l6inb1H9GrtnFGbn1h26oy4hA3eqx7pwrzRzzDlbNcjJK4Stls7chqU0r 8GrlHJnxB/K1RRymBwTuj2jOxZ7xqhb8W7JundlBMovSsDwmpxX99iasaSPzJXEzQy7k 1eGvMVJB6irFFRImJ+JrWYy49X0tjeIVSHoJ2apKCbnW9C8Ue1P6VRTYY92RPc3P7O7l ygq2QpfHdo8KjpQkfyEiHNQEXrC/1pdYNC1O2ow/x0soc0SC8ppyAZmGYQ/PM5vbRl4g 9XpF5M4DPPbp9klRNkbuDTDlS5jo9XMWvfsqwTKz9hwJ/TNKmsjyB0Oq4dquaX8/5LJP 8iVA== X-Received: by 10.236.160.67 with SMTP id t43mr50502641yhk.11.1400491587981; Mon, 19 May 2014 02:26:27 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id v60sm24328547yhc.40.2014.05.19.02.26.21 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 19 May 2014 02:26:26 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Mon, 19 May 2014 19:22:45 +1000 Message-Id: <1400491383-6725-5-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1400491383-6725-1-git-send-email-edgar.iglesias@gmail.com> References: <1400491383-6725-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c07::232 Cc: rob.herring@linaro.org, peter.crosthwaite@xilinx.com, aggelerf@ethz.ch, agraf@suse.de, john.williams@xilinx.com, alex.bennee@linaro.org, christoffer.dall@linaro.org, rth@twiddle.net Subject: [Qemu-devel] [PATCH v3 04/22] target-arm: Add arm_el_to_mmu_idx() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Edgar E. Iglesias" Maps a given EL to the corresponding MMU index. Reviewed-by: Peter Crosthwaite Signed-off-by: Edgar E. Iglesias --- target-arm/cpu.h | 22 +++++++++++++++++++++- target-arm/translate-a64.c | 8 ++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 11b7a0b..b6ad913 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -1083,9 +1083,29 @@ static inline CPUARMState *cpu_init(const char *cpu_model) #define MMU_MODE0_SUFFIX _kernel #define MMU_MODE1_SUFFIX _user #define MMU_USER_IDX 1 + +static inline int arm_el_to_mmu_idx(int current_el) +{ +#ifdef CONFIG_USER_ONLY + return MMU_USER_IDX; +#else + switch (current_el) { + case 0: + return MMU_USER_IDX; + case 1: + return 0; + default: + /* Unsupported EL. */ + assert(0); + return 0; + } +#endif +} + static inline int cpu_mmu_index (CPUARMState *env) { - return arm_current_pl(env) ? 0 : 1; + int cur_el = arm_current_pl(env); + return arm_el_to_mmu_idx(cur_el); } #include "exec/cpu-all.h" diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index b62db4d..7fce05f 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -162,13 +162,9 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, } } -static int get_mem_index(DisasContext *s) +static inline int get_mem_index(DisasContext *s) { -#ifdef CONFIG_USER_ONLY - return 1; -#else - return s->user; -#endif + return arm_el_to_mmu_idx(s->current_pl); } void gen_a64_set_pc_im(uint64_t val)