From patchwork Wed Jan 11 20:19:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 9511303 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 08E356075C for ; Wed, 11 Jan 2017 20:43:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDF17285E1 for ; Wed, 11 Jan 2017 20:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2A4028655; Wed, 11 Jan 2017 20:43:49 +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 86D5A285E1 for ; Wed, 11 Jan 2017 20:43:49 +0000 (UTC) Received: from localhost ([::1]:56965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRPkK-0005YE-DE for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Jan 2017 15:43:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRPOZ-0006xc-66 for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRPOY-0001N2-GU for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:19 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33757) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRPOY-0001Lx-AS for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:18 -0500 Received: by mail-wm0-x242.google.com with SMTP id r144so589144wme.0 for ; Wed, 11 Jan 2017 12:21:18 -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=d3w/XpswDNAEsvMZsoelPPWhxUZd3G5f6vcBcJTxWaQ=; b=c8D3G05aN9ltRdfIm4iBZeJFSI/xjH5lRyBuSDjo6H73b4Bro0hvwSja9tpqrcgt22 sWeGa5aQ/Dgq4lYgxyjzU3TluoApVhXyszs1Q/puA7MR0W4TrcF3IyJMKpjzf9FDFNe2 jEE0UXeBDR3GQKaRcTXEYf7iyraV4zQew0ebpaT+UimefM9hs/+cOWe3imluWdoaNDUf VMrDCLPFHQd8K7SyNIo1FNessSVLK25T6ClSQye49KpyGVxLhF1NCCsMrjnxk9/taqx3 bGRSVsSaRdJ4YWdr/O5U3iUtqM+uxQfTl/ilkpWYhGBeg2R4x6ZZep2SsJSi03hVOvHA seuA== 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=d3w/XpswDNAEsvMZsoelPPWhxUZd3G5f6vcBcJTxWaQ=; b=iu7Os/HFdLV1ryg7KG3bPVYmaVv/N6C9PdoqPaPM5xYc3haUvSQD+ieOQxrD0cFGtC e7OqTtu8eWlriVHnHA915V4ikIsZHyUixX8cPVON0+vMIGk4qYLVniM9m/o64PxD/xdN E8Zqr1w2YajpKOTs9/eV4j+omMdjaZJpO+oeoj5kKNhIMQViUtFqhif5QPfSkXYsvlUT RLrB/hY+4yfhp5UVK5w3Mlbbegk5/8dvkwq0BWkxrdBXzfuZR+UUdv2Fjv9odTC5uIti SFcPhnwiJab6MWlp9/DQEuKQ4F6E1KByLCVaBKe8fSf56sWUPeP3Txrz+Y2y03TdMdbV mXmQ== X-Gm-Message-State: AIkVDXJUoCLVOZ8BMnDpxTk5EN5teBx5lg3lMa1Nt7UqpCI5U/xxErEJlWa9O3dkpWxnrw== X-Received: by 10.223.133.132 with SMTP id 4mr5604314wrt.136.1484166077290; Wed, 11 Jan 2017 12:21:17 -0800 (PST) Received: from localhost (x55b4b54a.dyn.telefonica.de. [85.180.181.74]) by smtp.gmail.com with ESMTPSA id u81sm10621564wmu.10.2017.01.11.12.21.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 12:21:16 -0800 (PST) From: Artyom Tarasenko To: qemu-devel@nongnu.org Date: Wed, 11 Jan 2017 21:19:54 +0100 Message-Id: <2bf424bff7e4dee34fcbcada4fd490205f392823.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::242 Subject: [Qemu-devel] [PATCH v2 23/30] target-sparc: implement auto-demapping for UA2005 CPUs 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 0447d4e..57b3b97 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -210,6 +210,28 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb, { unsigned int i, replace_used; + if (cpu_has_hypervisor(env1)) { + uint64_t new_vaddr = tlb_tag & ~0x1fffULL; + uint64_t new_size = 8192ULL << 3 * TTE_PGSIZE(tlb_tte); + uint32_t new_ctx = tlb_tag & 0x1fffU; + for (i = 0; i < 64; i++) { + uint32_t ctx = tlb[i].tag & 0x1fffU; + /* check if new mapping overlaps an existing one */ + if (new_ctx == ctx) { + uint64_t vaddr = tlb[i].tag & ~0x1fffULL; + uint64_t size = 8192ULL << 3 * TTE_PGSIZE(tlb[i].tte); + if (new_vaddr == vaddr + || (new_vaddr < vaddr + size + && vaddr < new_vaddr + new_size)) { + DPRINTF_MMU("auto demap entry [%d] %lx->%lx\n", i, vaddr, + new_vaddr); + replace_tlb_entry(&tlb[i], tlb_tag, tlb_tte, env1); + return; + } + } + + } + } /* Try replacing invalid entry */ for (i = 0; i < 64; i++) { if (!TTE_IS_VALID(tlb[i].tte)) {