From patchwork Wed Jan 11 20:19:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 9511379 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 2EA9260762 for ; Wed, 11 Jan 2017 21:09:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21AC22861A for ; Wed, 11 Jan 2017 21:09:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 166132865F; Wed, 11 Jan 2017 21:09:52 +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 634F428655 for ; Wed, 11 Jan 2017 21:09:51 +0000 (UTC) Received: from localhost ([::1]:57114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRQ9W-00078X-Jy for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Jan 2017 16:09:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRPOV-0006uZ-T1 for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRPOU-0001I0-DC for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:15 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRPOU-0001Gv-4Z for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:14 -0500 Received: by mail-wm0-x243.google.com with SMTP id l2so569988wml.2 for ; Wed, 11 Jan 2017 12:21:14 -0800 (PST) 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 :in-reply-to:references; bh=7/njzZLLk1m6hgN2FNShq8YZzEyFsGu1K6Vhp53CRfU=; b=M/m08IbMffgsA/g3nzTwf224Muiio3qzzsFKmctAEvq4U/cOnXRiXIEe693KJoRXAk 5mTZu45jsrtSAp1Q5u+3/wXZTISA0xHAnh6L3ufs6f783x6W7fa4v1otJFypcdEx9oMi muChy90ke70zYFfNk3QX5Mr8dMaGt8oUSZ7RrFxDu6KIXeG2p+YvUM9tOm8NKMna6HxH 1eB/DyFwD1lXauJ8MHTNVwkC6vO6sfxrUG/PsnW3Mu3JOuEq+1sV4lHV5IEycZJFpnFd 1VaVTbB/cZY9yoD0bS31qzcp8Urch2jY3CgBKtbJUCjVpe3RJrzcpclT86jjCEePHA8f NPNQ== 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:in-reply-to:references; bh=7/njzZLLk1m6hgN2FNShq8YZzEyFsGu1K6Vhp53CRfU=; b=Ms/WmlbIoQtrLCrNQsvr6EOGftE4nEqgg8vbJyC3dlXiF/kNNrZxd69xgX+HsuT7rR yzdg3Un92GXE5/lYfN10rPtbV16JPbmtwR4cmI0Z79GAvWvW58N/a91IG7qnt5hAgbQZ 9W5u6ZlldPg35cQYRxAr4R+Cp4dPKkk2EZ3QA/NJNI0KHLBQ/JNEnIb3MC9pGQJ0c3FM 5Cpf+ahHrvTEEr6vei8S0QGoZQtWpgRTIEFiVxHOQ3ZeY53Wu4LVHTyB9DrOmsu6IhuV 3O/eXi79eC4KefWFI9r2X9g6U5AV+BfHuNw8yvg552eVSdQC2yTWElg7bFljZekhI6Nf Pn3A== X-Gm-Message-State: AIkVDXI/nKd5e96Znh46PwZpjxh9D5rSc4jaoCDj174u/OKhLBoZXKHImTvMa9IkmZBaIQ== X-Received: by 10.28.8.12 with SMTP id 12mr4552129wmi.46.1484166073108; Wed, 11 Jan 2017 12:21:13 -0800 (PST) Received: from localhost (x55b4b54a.dyn.telefonica.de. [85.180.181.74]) by smtp.gmail.com with ESMTPSA id cj1sm10075961wjd.46.2017.01.11.12.21.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 12:21:11 -0800 (PST) From: Artyom Tarasenko To: qemu-devel@nongnu.org Date: Wed, 11 Jan 2017 21:19:52 +0100 Message-Id: <0293a0b12e38e253a3590cebeee517ee16cf24d8.1484165352.git.atar4qemu@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: 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 v2 21/30] 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 4b8ca69..0447d4e 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, + const SparcV9MMU *mmu, const 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 @@ -1266,20 +1257,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 */ @@ -1338,20 +1323,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 */