From patchwork Sat Oct 1 10:05:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 9359171 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 02FC3600C8 for ; Sat, 1 Oct 2016 10:33:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDCDD29948 for ; Sat, 1 Oct 2016 10:33:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D233D2995E; Sat, 1 Oct 2016 10:33:34 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 4FFC729948 for ; Sat, 1 Oct 2016 10:33:34 +0000 (UTC) Received: from localhost ([::1]:55055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqHbp-0003BK-AY for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Oct 2016 06:33:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqHCn-0006Ti-6T for qemu-devel@nongnu.org; Sat, 01 Oct 2016 06:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bqHCi-0007pB-Ta for qemu-devel@nongnu.org; Sat, 01 Oct 2016 06:07:40 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:36669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqHCi-0007op-J4 for qemu-devel@nongnu.org; Sat, 01 Oct 2016 06:07:36 -0400 Received: by mail-wm0-x243.google.com with SMTP id b184so6755529wma.3 for ; Sat, 01 Oct 2016 03:07:36 -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=cYqwWZyXLVSKS1o2VWJmXx5y4xuSdExb8U7DEFHqRos=; b=a3Dg1zcYEtgqv7Yg6LRQSSgDe4K6FqQKVRkpUnftlXCcmnzHue+zmbyfNWkcf1K1cG xSRUxMwdGrVCyUdaAwdelh6huQx1WCgeHM/HA66AOA0n6GinYpa6sFK+sxEnfGe+01CZ zRcH4u7BCpQR3juAVd6pgLlDBsZM/tFryZm6WHA5smEXenHDjdcSoBBteJZFIrjGirpU R/5TFtlDPEIZ63fWII0ke/fx5CKZm2SRS6xRnqJMoSz569735bBiWNltMPgquzpnROHt mTZO7YTbLQdclB0C91mRJ1GmhF96DVCIK6g+WeFs0E3Nwm86vL+gl90KgSQCCF2AqWia f5Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cYqwWZyXLVSKS1o2VWJmXx5y4xuSdExb8U7DEFHqRos=; b=j/7zEL11cSVXGAKE97OcWGRwRBpzKvBUyvgsJQul6kmYkJXZaiLeOSto+RJxGX5E6G MLIWDONgIHRY5qydY7gvOt82ESiI2DR9dSK93ymZhhtLowSlyM1AULnD75JUL8SuwvH5 0owoZDRD1OKak4Onr8Vjs1RJNeWAiQUiz2IkEBMnQsW72AGET34/m7ew4udyziWExwg/ J6kOWx81KdOMEV8olKDWsOj3O0iH0mI/bkLyzitq8THv8f/52MYRg2iR2xMuxfNeYQ2T SxckuNX+UBOjLm3GyeuDB36mmdyKKpFAJlacnrv2jZYV7EZKYJomQ4PTuTg4IQNDRMzA n/UA== X-Gm-Message-State: AA6/9RnYF5LZ2CF95ggtj0iPXuRgVKqdiEKu/ZtbKfWAZXAEJZ2pV4QipCmWT1gYgHKGqQ== X-Received: by 10.28.161.133 with SMTP id k127mr1805230wme.103.1475316456010; Sat, 01 Oct 2016 03:07:36 -0700 (PDT) Received: from localhost (x55b4da19.dyn.telefonica.de. [85.180.218.25]) by smtp.gmail.com with ESMTPSA id w138sm9145145wmd.1.2016.10.01.03.07.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Oct 2016 03:07:35 -0700 (PDT) From: Artyom Tarasenko To: qemu-devel@nongnu.org Date: Sat, 1 Oct 2016 12:05:24 +0200 Message-Id: <1475316333-9776-21-git-send-email-atar4qemu@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1475316333-9776-1-git-send-email-atar4qemu@gmail.com> References: <1475316333-9776-1-git-send-email-atar4qemu@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH 20/29] target-sparc: simplify ultrasparc_tsb_pointer 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: Mark Cave-Ayland , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Artyom Tarasenko --- target-sparc/ldst_helper.c | 51 ++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c index 8d788fa..a85552e 100644 --- a/target-sparc/ldst_helper.c +++ b/target-sparc/ldst_helper.c @@ -70,44 +70,35 @@ #define QT1 (env->qt1) #if defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) -static uint64_t ultrasparc_tsb_pointer(CPUSPARCState *env, uint64_t tsb, - uint64_t *tsb_ptr, - uint64_t tag_access_register, - int idx, uint64_t *cfg_ptr) /* Calculates TSB pointer value for fault page size * UltraSPARC IIi has fixed sizes (8k or 64k) for the page pointers * UA2005 holds the page size configuration in mmu_ctx registers */ +static uint64_t ultrasparc_tsb_pointer(CPUSPARCState *env, SparcV9MMU mmu, + int idx) { uint64_t tsb_register; int page_size; if (cpu_has_hypervisor(env)) { int tsb_index = 0; - int ctx = tag_access_register & 0x1fffULL; - uint64_t ctx_register = cfg_ptr[ctx ? 1 : 0]; + int ctx = mmu.tag_access & 0x1fffULL; + uint64_t ctx_register = mmu.sun4v_ctx_config[ctx ? 1 : 0]; tsb_index = idx; tsb_index |= ctx ? 2 : 0; page_size = idx ? ctx_register >> 8 : ctx_register; page_size &= 7; - tsb_register = tsb_ptr[tsb_index]; + tsb_register = mmu.sun4v_tsb_pointers[tsb_index]; } else { page_size = idx; - tsb_register = tsb; + tsb_register = mmu.tsb; } - uint64_t tsb_base = tsb_register & ~0x1fffULL; int tsb_split = (tsb_register & 0x1000ULL) ? 1 : 0; int tsb_size = tsb_register & 0xf; - /* discard lower 13 bits which hold tag access context */ - uint64_t tag_access_va = tag_access_register & ~0x1fffULL; + uint64_t tsb_base_mask = (~0x1fffULL) << tsb_size; - /* now reorder bits */ - uint64_t tsb_base_mask = ~0x1fffULL; - uint64_t va = tag_access_va; - - /* move va bits to correct position */ - va >>= 3 * page_size + 9; - - tsb_base_mask <<= tsb_size; + /* move va bits to correct position, + * the context bits will be masked out later */ + uint64_t va = mmu.tag_access >> (3 * page_size + 9); /* calculate tsb_base mask and adjust va if split is in use */ if (tsb_split) { @@ -119,7 +110,7 @@ static uint64_t ultrasparc_tsb_pointer(CPUSPARCState *env, uint64_t tsb, tsb_base_mask <<= 1; } - return ((tsb_base & tsb_base_mask) | (va & ~tsb_base_mask)) & ~0xfULL; + return ((tsb_register & tsb_base_mask) | (va & ~tsb_base_mask)) & ~0xfULL; } /* Calculates tag target register value by reordering bits @@ -1516,20 +1507,14 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, { /* env->immuregs[5] holds I-MMU TSB register value env->immuregs[6] holds I-MMU Tag Access register value */ - ret = ultrasparc_tsb_pointer(env, env->immu.tsb, - env->immu.sun4v_tsb_pointers, - env->immu.tag_access, - 0, env->immu.sun4v_ctx_config); + ret = ultrasparc_tsb_pointer(env, env->immu, 0); break; } case ASI_IMMU_TSB_64KB_PTR: /* I-MMU 64k TSB pointer */ { /* env->immuregs[5] holds I-MMU TSB register value env->immuregs[6] holds I-MMU Tag Access register value */ - ret = ultrasparc_tsb_pointer(env, env->immu.tsb, - env->immu.sun4v_tsb_pointers, - env->immu.tag_access, - 1, env->immu.sun4v_ctx_config); + ret = ultrasparc_tsb_pointer(env, env->immu, 1); break; } case ASI_ITLB_DATA_ACCESS: /* I-MMU data access */ @@ -1588,20 +1573,14 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, { /* env->dmmuregs[5] holds D-MMU TSB register value env->dmmuregs[6] holds D-MMU Tag Access register value */ - ret = ultrasparc_tsb_pointer(env, env->dmmu.tsb, - env->dmmu.sun4v_tsb_pointers, - env->dmmu.tag_access, - 0, env->dmmu.sun4v_ctx_config); + ret = ultrasparc_tsb_pointer(env, env->dmmu, 0); break; } case ASI_DMMU_TSB_64KB_PTR: /* D-MMU 64k TSB pointer */ { /* env->dmmuregs[5] holds D-MMU TSB register value env->dmmuregs[6] holds D-MMU Tag Access register value */ - ret = ultrasparc_tsb_pointer(env, env->dmmu.tsb, - env->dmmu.sun4v_tsb_pointers, - env->dmmu.tag_access, - 1, env->dmmu.sun4v_ctx_config); + ret = ultrasparc_tsb_pointer(env, env->dmmu, 1); break; } case ASI_DTLB_DATA_ACCESS: /* D-MMU data access */