From patchwork Tue Jan 16 16:45:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 124743 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1075551lje; Tue, 16 Jan 2018 08:46:42 -0800 (PST) X-Google-Smtp-Source: ACJfBosicyv0UCQgD/YXsymcjbxen+7/GbbyNexc9qL9/DCzM1zkcno5nvKNWD3Df0Spy1sjr1J7 X-Received: by 10.37.231.140 with SMTP id e134mr31159701ybh.329.1516121201959; Tue, 16 Jan 2018 08:46:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516121201; cv=none; d=google.com; s=arc-20160816; b=ww/s7+Gi+81VIs4g7jY4OkljYZIkp+fgC9rNWm0ra1K8XhMxU940yOA45rqKnbF7Qj oJz9h8Mnd5ltCxHRvnfzxOE6ANrUKhzURb5/oSmzKKH5LSYmuBvpmCf9ZZ45nSk4JSHX 117s2ZTs19OQrAAGMdaeT6ZxFywxiA/sTfuU2OFCWd10z4+1aq09Ql7QqTKr5elrD3r5 QIihhC0V0d8gBV9+7+Rd/QJ/TApjN5mdtJ1QpV0243padP73iu0NP1ZLRvMlRzNspK+L hSn52k0AoDaHK+yEOFw8m+HfqZc/DqfQq2c+TWP1jE5c75t3bZ6iq2XKuit4zBEuJ8+p jWSw== 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=NWl592gmcmqdqRRwvrPDTA263IuCumCkTRQeZKUCePU=; b=g2fexJqfhT+nmQNsc0Iycf2Qk6A0Ajjg6MA8rf6ZiYVrHOtaMNlG+cAQ/nD+8BhvmV syXOhq+iETAv4scLL44T03Xv4AbAzb7gRSRMBlmD8K6ptQunaQx7KG3rDP491lsrv/1f mTYsrp7xq7FjgSWCg2eRCWHDTnrhcujOKgQ2DH+zz27p6Gypo52LSVl9yTn5YULp1MAX 2x052IloI5kpb2Sr+ByJTLKXnUp8mKJVS+raLkMSAZwrfC4fjT7Bb9oAL3Qbmn4QEhEM YPquu6voPmY4Mr76pKnl2yl717OBHzccyFKVq9h99SPvc8GVFYDoi4ZUnCloTuNFq3v8 HVfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=M/iCaZLV; 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 s188si573169ywd.531.2018.01.16.08.46.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 16 Jan 2018 08:46:41 -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=M/iCaZLV; 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]:48216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebUNl-0000Vy-D2 for patch@linaro.org; Tue, 16 Jan 2018 11:46:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebUNI-0000UJ-B5 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 11:46:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebUNE-0008Ox-31 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 11:46:12 -0500 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:43808) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebUND-0008Oa-Tc for qemu-devel@nongnu.org; Tue, 16 Jan 2018 11:46:08 -0500 Received: by mail-pg0-x242.google.com with SMTP id n17so2201133pgf.10 for ; Tue, 16 Jan 2018 08:46:07 -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=NWl592gmcmqdqRRwvrPDTA263IuCumCkTRQeZKUCePU=; b=M/iCaZLVBDMSb5j2yXv9Cqw0Aqmudgr/z2Z4GNogS/9wys9K1jq6dQTEzMkQjnkMrQ 6MC/rfTgu/2RyI7cSRwPP5zFBLStGYebE8vh8X581ElcB4I3cneb2wZyX+DzpiOfaBca VzJbw8qJIP74UEpRQJxToo7j4udn/HVh5BXUI= 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=NWl592gmcmqdqRRwvrPDTA263IuCumCkTRQeZKUCePU=; b=ZCE9USZIjEaC7BqAMCiRHuFAqArQzMcFYYNTieLvSU8vqG1GqUZPr7Amr5I2k+qta0 mWS6aW/4VMNhgci6jQQwdlZvyCNd+KeBv9d6p5hN+1AHmFVCtC2S5xgnxRaborKsVQlO tR5QJYGnmoWTDAgomy8//gj5bzRLiYOjcF9IqfCmDsF0YtibnVDiE9o0xZbi9sd0oGBP rsLqjUO40s8yqJ2oSj6fwBt/d100llNgG0FYulGaP99NEqH9YxQd82oFfkGDyVburkUX BZUiUSDw0Qq2gkcAKOwXonTdXcNJnvubB1vt99rt8BgI7ygbuJ0FQSkoKZkwMX+DCkYU r3Ag== X-Gm-Message-State: AKwxytdj49WZyv9ffj2I6+/KqNRiNX9bOfDDVE6g3sGJKoJutlTYHwqW BIIzm7KIc/COCi8MsQhgMjRT5uDrARM= X-Received: by 10.101.75.81 with SMTP id k17mr208568pgt.335.1516121166510; Tue, 16 Jan 2018 08:46:06 -0800 (PST) Received: from cloudburst.twiddle.net.com (24-181-135-57.dhcp.knwc.wa.charter.com. [24.181.135.57]) by smtp.gmail.com with ESMTPSA id y7sm3875780pfe.48.2018.01.16.08.46.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jan 2018 08:46:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 08:45:58 -0800 Message-Id: <20180116164600.7480-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180116164600.7480-1-richard.henderson@linaro.org> References: <20180116164600.7480-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::242 Subject: [Qemu-devel] [PULL v2 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 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 d7b09e8e0c..dc83f3e5be 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -1247,12 +1247,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. */ @@ -1265,6 +1259,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); @@ -1296,16 +1291,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 (cmp_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);