From patchwork Mon Jan 28 15:59:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156776 Delivered-To: patch@linaro.org Received: by 2002:ac9:7558:0:0:0:0:0 with SMTP id r24csp3534842oct; Mon, 28 Jan 2019 08:13:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN7WGMNPTfHjnTb6zIFjE758ptZTxuBXtR9cYpgaAabD3Zz35qRnllHnYe24iiLypy9g25n/ X-Received: by 2002:adf:ecc8:: with SMTP id s8mr21772760wro.208.1548692033341; Mon, 28 Jan 2019 08:13:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548692033; cv=none; d=google.com; s=arc-20160816; b=NTKvZvk+v1ucg5XJa4sTuNF/o3K9ZJQxBKeuEGra/fKsmgvAY6768jENjMpB8zoQiS Vq/0sxE3P/xp0sQnbPFm4aydPPC/aMTht3K4lWkfjC/tUeS0b6Zr0bpwlTbxbkGI3WEF 8pOxEEeAVcHs/Euil66gdWjS5uJjTndHjfkrQx/KirLhuSwwzYX67NrpYFFkPVTaeY6J jZzjmkREbXwP5g4YeCYDrDX1aATUUKlcf4uMG5yHQpmzz4TgOBbnoUYdmoEcxQKgX+IW At5a8jFIJG5LJVOdC4b97nrQq5lP3lQQy82cAtjRMobiRGAc2rF5G/BLvyQLgJpaD/NF QbHg== 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; bh=u1h6Y+1jeyggZCDYjdrFQDBu8S/E6FnZ3feRJf5H+uM=; b=g4UKpknr/hO95NCKE2xOAn3sYnna2IhZ3q1BIIwrNPwFyVTBIpyt5hgwuVB5+uQrc0 7t+EpO51EkoILJjRt+OC0oHx2WYf2gs3KaCo7EDh5NArjq2zhU3qRLV+a7R4bpdd7CzT DOrQRrsLvhLNfIR2vUikVLIYNoM0NAy3n0fie7KAwk12MKr5HuTaUtPSeZub8MpMLBT/ RYYsd+o6681iv5imOLb7+LBmHc3yMP8NCoCUYa21aS5sZMyJbRD5l6VRD8NkKa7bG9aT CYWdmhyRGA9awZR/rMIdNsPN6xNmHUTgummEh2MAEqeFZCrS+V7NSGHw/DWFM9W3zUnX ebjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dLSxUdTC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id t82si47420342wmb.150.2019.01.28.08.13.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 08:13:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dLSxUdTC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:34352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go9Xk-0007YU-5e for patch@linaro.org; Mon, 28 Jan 2019 11:13:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go9K5-0005CL-7l for qemu-devel@nongnu.org; Mon, 28 Jan 2019 10:59:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1go9K4-0007v1-4z for qemu-devel@nongnu.org; Mon, 28 Jan 2019 10:59:45 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:46138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1go9K3-0007pt-T9 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 10:59:44 -0500 Received: by mail-pg1-x535.google.com with SMTP id w7so7368116pgp.13 for ; Mon, 28 Jan 2019 07:59:35 -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=u1h6Y+1jeyggZCDYjdrFQDBu8S/E6FnZ3feRJf5H+uM=; b=dLSxUdTCzq5+3zQc76tDGeEPS6ODRGSmjKlJTz+ivzRNlXOioJUkHPnjQKo5pyqUmW IEfPbSW89gv8jfg0OcwbcNXBX2YDpyXxTP8ITtXzArRiN+MVLtdaun1tu+XiAy9geDrH QzARw8OHDuEz50CtckKGb0O1lSK23c90XWFaM= 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=u1h6Y+1jeyggZCDYjdrFQDBu8S/E6FnZ3feRJf5H+uM=; b=qEjnbBYK2vBXCGOhvNY/7vK564pggNWOz+zmSnbDuy7BeTwg32TVNd8DGvD9lwFkwV FkZfiJyTuLvWgr9jAPzfmCTY4320UfEf1OkYWCBiRhrl9EYrW+dhsI+CLEsCDlsEyAl0 KVteBXnw3wOmrMEi8ZPkaIA1QPGNtZ5tu88VnzUC7+NX0JQXEQsYTkKvRcXpzTWrgp5H bwl3grANcHS9dVLzAdkjjm/mS6qvAywZbspEGRcKNicKlQgvV3dYnqRShHXRy4uQGa6K 1DCuwopbToA1G6Whe+dNDTJwFdiK6J8F1VSMer2WPSRV0FxddizmrrNxoXL7OuMRQoVu hmNw== X-Gm-Message-State: AJcUuke1EuJXOWl8/nPqZh8SFRZ5/0unZ8pwonJbVjqQ8q+M7iC7k3QI mrOZ/In9yjg5l/pDpTuiPIO7vJpwL2A= X-Received: by 2002:a63:b94c:: with SMTP id v12mr20263483pgo.221.1548691174301; Mon, 28 Jan 2019 07:59:34 -0800 (PST) Received: from cloudburst.twiddle.net (50-233-235-3-static.hfc.comcastbusiness.net. [50.233.235.3]) by smtp.gmail.com with ESMTPSA id p2sm45518687pfp.125.2019.01.28.07.59.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 07:59:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2019 07:59:01 -0800 Message-Id: <20190128155907.20607-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190128155907.20607-1-richard.henderson@linaro.org> References: <20190128155907.20607-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::535 Subject: [Qemu-devel] [PULL 17/23] tcg/s390: enable dynamic TLB sizing 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" Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.h | 2 +- tcg/s390/tcg-target.inc.c | 45 +++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 27 deletions(-) -- 2.17.2 diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index 394b545369..357528dd97 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -27,7 +27,7 @@ #define TCG_TARGET_INSN_UNIT_SIZE 2 #define TCG_TARGET_TLB_DISPLACEMENT_BITS 19 -#define TCG_TARGET_IMPLEMENTS_DYN_TLB 0 +#define TCG_TARGET_IMPLEMENTS_DYN_TLB 1 typedef enum TCGReg { TCG_REG_R0 = 0, diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index 39ecf609a1..7db90b3bae 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -1537,10 +1537,10 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGMemOp opc, TCGReg data, #if defined(CONFIG_SOFTMMU) #include "tcg-ldst.inc.c" -/* We're expecting to use a 20-bit signed offset on the tlb memory ops. - 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]) +/* We're expecting to use a 20-bit signed offset on the tlb memory ops. */ +QEMU_BUILD_BUG_ON(offsetof(CPUArchState, tlb_mask[NB_MMU_MODES - 1]) + > 0x7ffff); +QEMU_BUILD_BUG_ON(offsetof(CPUArchState, tlb_table[NB_MMU_MODES - 1]) > 0x7ffff); /* Load and compare a TLB entry, leaving the flags set. Loads the TLB @@ -1552,48 +1552,41 @@ static TCGReg tcg_out_tlb_read(TCGContext* s, TCGReg addr_reg, TCGMemOp opc, unsigned a_bits = get_alignment_bits(opc); unsigned s_mask = (1 << s_bits) - 1; unsigned a_mask = (1 << a_bits) - 1; + int mask_off = offsetof(CPUArchState, tlb_mask[mem_index]); + int table_off = offsetof(CPUArchState, tlb_table[mem_index]); int ofs, a_off; uint64_t tlb_mask; + tcg_out_sh64(s, RSY_SRLG, TCG_REG_R2, addr_reg, TCG_REG_NONE, + TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS); + tcg_out_insn(s, RXY, NG, TCG_REG_R2, TCG_AREG0, TCG_REG_NONE, mask_off); + tcg_out_insn(s, RXY, AG, TCG_REG_R2, TCG_AREG0, TCG_REG_NONE, table_off); + /* For aligned accesses, we check the first byte and include the alignment bits within the address. For unaligned access, we check that we don't cross pages using the address of the last byte of the access. */ a_off = (a_bits >= s_bits ? 0 : s_mask - a_mask); tlb_mask = (uint64_t)TARGET_PAGE_MASK | a_mask; - - if (s390_facilities & FACILITY_GEN_INST_EXT) { - tcg_out_risbg(s, TCG_REG_R2, addr_reg, - 64 - CPU_TLB_BITS - CPU_TLB_ENTRY_BITS, - 63 - CPU_TLB_ENTRY_BITS, - 64 + CPU_TLB_ENTRY_BITS - TARGET_PAGE_BITS, 1); - if (a_off) { - tcg_out_insn(s, RX, LA, TCG_REG_R3, addr_reg, TCG_REG_NONE, a_off); - tgen_andi(s, TCG_TYPE_TL, TCG_REG_R3, tlb_mask); - } else { - tgen_andi_risbg(s, TCG_REG_R3, addr_reg, tlb_mask); - } + if ((s390_facilities & FACILITY_GEN_INST_EXT) && a_off == 0) { + tgen_andi_risbg(s, TCG_REG_R3, addr_reg, tlb_mask); } else { - tcg_out_sh64(s, RSY_SRLG, TCG_REG_R2, addr_reg, TCG_REG_NONE, - TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS); tcg_out_insn(s, RX, LA, TCG_REG_R3, addr_reg, TCG_REG_NONE, a_off); - tgen_andi(s, TCG_TYPE_I64, TCG_REG_R2, - (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS); tgen_andi(s, TCG_TYPE_TL, TCG_REG_R3, tlb_mask); } if (is_ld) { - ofs = offsetof(CPUArchState, tlb_table[mem_index][0].addr_read); + ofs = offsetof(CPUTLBEntry, addr_read); } else { - ofs = offsetof(CPUArchState, tlb_table[mem_index][0].addr_write); + ofs = offsetof(CPUTLBEntry, addr_write); } if (TARGET_LONG_BITS == 32) { - tcg_out_mem(s, RX_C, RXY_CY, TCG_REG_R3, TCG_REG_R2, TCG_AREG0, ofs); + tcg_out_insn(s, RX, C, TCG_REG_R3, TCG_REG_R2, TCG_REG_NONE, ofs); } else { - tcg_out_mem(s, 0, RXY_CG, TCG_REG_R3, TCG_REG_R2, TCG_AREG0, ofs); + tcg_out_insn(s, RXY, CG, TCG_REG_R3, TCG_REG_R2, TCG_REG_NONE, ofs); } - ofs = offsetof(CPUArchState, tlb_table[mem_index][0].addend); - tcg_out_mem(s, 0, RXY_LG, TCG_REG_R2, TCG_REG_R2, TCG_AREG0, ofs); + tcg_out_insn(s, RXY, LG, TCG_REG_R2, TCG_REG_R2, TCG_REG_NONE, + offsetof(CPUTLBEntry, addend)); if (TARGET_LONG_BITS == 32) { tgen_ext32u(s, TCG_REG_R3, addr_reg);