From patchwork Fri Jan 12 21:06:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 124380 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2507341qgn; Fri, 12 Jan 2018 13:08:52 -0800 (PST) X-Google-Smtp-Source: ACJfBovVupIVJ8sdFjqkUaE9jtKE5IP9qFUuppLqoamezvrj24d9QhHCH9wcW8so43SpAUnKQIxb X-Received: by 10.129.157.198 with SMTP id u189mr17319967ywg.472.1515791332629; Fri, 12 Jan 2018 13:08:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515791332; cv=none; d=google.com; s=arc-20160816; b=qAtonRpwLmbZxYOUQw9AaFr7os2hFVpLS5Jgu/9rHDeCvoqRt5V4KJ+OrwwdsUF0nX MAnrwiQ+EkaczeAxSEBuOJB8WlTgkYBuy+UqsOTpbHB5KzVgPHNoUU7nE5v670cY2CXF l9unUMEYvBzKVOrnio0PwIUHYeXxZzEdIERWU2HbJVwdb4Y1JQz49YQC5lw+0UOwaTvb AkJJ4u1MW2xMjRTf2mIfgMEjzieqhltGmSOJYdIEtE2EuytxjR6S5s8fGtkC6n2FYb9P RTbCcNt0VnlS40b5QtxuzIellpUskEqrbmNvNkOLKV5t28MUpBWP8HWVuqVKfFyG8aF3 Nlaw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=AyEats20dBLg765p+pFXKeVHxfgYwUJeYJhOT46OMcg=; b=CIBn1McLk8OaXasmnrzVcsdwv5d/DerPSF7BSOuWnwjDzVjwr7mL83qi/YpBEJlA4H Zp+zxrGDARKhUwfhD+etw+bXRBPxgaOVIqN11eaNf1a5y9q+eZGjKyFfxnKP5ODwg0D6 uByDdBZ+/gP0e87oiAOuRPKym9fna/XJTma4KZq9/AFyOU9Mj4wFlphmQm9uvxStpsUU cuxaWphCl/9abYNEMH1FLIaUnUB5tKIQ1mBcC4IgO8BubaQAXMHVfktXX5u9DogQmEa6 G+svJRBqDS/UFVSFMPuSxf+JOWpwZr2JdVa3PUqIKcsKwrkNG8EbObLZYwoNRXbZh7f8 8bgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=P1EH4iiV; 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 o8si4688077ywa.213.2018.01.12.13.08.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 12 Jan 2018 13:08:52 -0800 (PST) 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=P1EH4iiV; 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]:38896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ea6ZI-0000zq-3u for patch@linaro.org; Fri, 12 Jan 2018 16:08:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ea6Ws-0008Mx-AR for qemu-devel@nongnu.org; Fri, 12 Jan 2018 16:06:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ea6Wr-0002lx-CU for qemu-devel@nongnu.org; Fri, 12 Jan 2018 16:06:22 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:36127) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ea6Wr-0002lR-6Z for qemu-devel@nongnu.org; Fri, 12 Jan 2018 16:06:21 -0500 Received: by mail-pg0-x241.google.com with SMTP id j2so5355981pgv.3 for ; Fri, 12 Jan 2018 13:06:21 -0800 (PST) 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; bh=AyEats20dBLg765p+pFXKeVHxfgYwUJeYJhOT46OMcg=; b=P1EH4iiV+/8WNSso9ra1eaIPsM+9zAhAUmKnjInsp7SbZZTVSRnE3OxjHX7QxqQP1T p/v/FuGnj0Dk3uJEfD5rUiL6ENjJhtbnHNiyJITXMDvP8C7pPv8NKeZkRS60c6F/D159 QMaFdlkm7pRcTDZXxoKFJm0f3aEDQMyHeR1Mk= 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; bh=AyEats20dBLg765p+pFXKeVHxfgYwUJeYJhOT46OMcg=; b=Qdf8J2l091QNVWQWik/FwDBZj5gCpN0wwMJ8IwxBl5cU9iYS8iQ0GOIns01OVH6LSZ SpVRteM0Ndat9S0I2yOsNhl3vvbVwNbFEV1Ien5TJ3B6GePL9T/9dH6G/47PkL1op3E7 K3nJ2u35wwZaTOjPEMLuYcI7NGn0obVj36357xNrhW0U400iMxuFbpSITGwkmQunDxP3 KGaD8DWczuBF6hd6gDsMXKceB6amcx8mYLhvbmS/HHW3jEwtyz8brHInQL+/L3UwolaW kTbtOQlHsCJ1ZNZkipaiqiKkSpjw+ufAhegNAbMiraGyVdgBXZdh4yAXjZhnzaP5TzZJ t0Zg== X-Gm-Message-State: AKGB3mKrfGVbyQD0WU60EhIBibMzlrxUUS8RbtT5xI3It+AifI7Lzkiv WbBvblXIPPPave4oWaaXGPgqExf1xv0= X-Received: by 10.84.236.70 with SMTP id h6mr26707653pln.256.1515791179941; Fri, 12 Jan 2018 13:06:19 -0800 (PST) Received: from cloudburst.twiddle.net (50-78-183-178-static.hfc.comcastbusiness.net. [50.78.183.178]) by smtp.gmail.com with ESMTPSA id t80sm20197600pgb.88.2018.01.12.13.06.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jan 2018 13:06:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 13:06:11 -0800 Message-Id: <20180112210613.14124-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180112210613.14124-1-richard.henderson@linaro.org> References: <20180112210613.14124-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PULL 2/4] tcg/arm: Support tlb offsets larger than 64k 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: peter.maydell@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" AArch64 with SVE has an offset of 80k to the 8th TLB. Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.inc.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) -- 2.14.3 diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index b9890c8bd8..4bd465732b 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -1261,12 +1261,6 @@ static TCGReg tcg_out_arg_reg64(TCGContext *s, TCGReg argreg, /* We're expecting to use an 8-bit immediate and to mask. */ QEMU_BUILD_BUG_ON(CPU_TLB_BITS > 8); -/* We're expecting to use an 8-bit immediate add + 8-bit ldrd offset. - Using the offset of the second entry in the last tlb table ensures - that we can index all of the elements of the first entry. */ -QEMU_BUILD_BUG_ON(offsetof(CPUArchState, tlb_table[NB_MMU_MODES - 1][1]) - > 0xffff); - /* Load and compare a TLB entry, leaving the flags set. Returns the register containing the addend of the tlb entry. Clobbers R0, R1, R2, TMP. */ @@ -1279,6 +1273,7 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, ? offsetof(CPUArchState, tlb_table[mem_index][0].addr_read) : offsetof(CPUArchState, tlb_table[mem_index][0].addr_write)); int add_off = offsetof(CPUArchState, tlb_table[mem_index][0].addend); + int mask_off; unsigned s_bits = opc & MO_SIZE; unsigned a_bits = get_alignment_bits(opc); @@ -1310,16 +1305,25 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, 0, addrlo, SHIFT_IMM_LSR(TARGET_PAGE_BITS)); } - /* We checked that the offset is contained within 16 bits above. */ - if (add_off > 0xfff - || (use_armv6_instructions && TARGET_LONG_BITS == 64 - && cmp_off > 0xff)) { + /* Add portions of the offset until the memory access is in range. + * If we plan on using ldrd, reduce to an 8-bit offset; otherwise + * we can use a 12-bit offset. */ + if (use_armv6_instructions && TARGET_LONG_BITS == 64) { + mask_off = 0xff; + } else { + mask_off = 0xfff; + } + while (add_off > mask_off) { + int shift = ctz32(cmp_off & ~mask_off) & ~1; + int rot = ((32 - shift) << 7) & 0xf00; + int addend = cmp_off & (0xff << shift); tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R2, base, - (24 << 7) | (cmp_off >> 8)); + rot | ((cmp_off >> shift) & 0xff)); base = TCG_REG_R2; - add_off -= cmp_off & 0xff00; - cmp_off &= 0xff; + add_off -= addend; + cmp_off -= addend; } + if (!use_armv7_instructions) { tcg_out_dat_imm(s, COND_AL, ARITH_AND, TCG_REG_R0, TCG_REG_TMP, CPU_TLB_SIZE - 1);