From patchwork Sat Oct 1 10:05:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 9359175 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 F3172607D6 for ; Sat, 1 Oct 2016 10:37:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4282294A6 for ; Sat, 1 Oct 2016 10:37:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7F45295F9; Sat, 1 Oct 2016 10:37:21 +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 78752294A6 for ; Sat, 1 Oct 2016 10:37:21 +0000 (UTC) Received: from localhost ([::1]:55088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqHfU-0006Mi-MK for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Oct 2016 06:37:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqHCn-0006UY-TO for qemu-devel@nongnu.org; Sat, 01 Oct 2016 06:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bqHCl-0007qr-RX for qemu-devel@nongnu.org; Sat, 01 Oct 2016 06:07:40 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:32857) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqHCl-0007qX-Kh for qemu-devel@nongnu.org; Sat, 01 Oct 2016 06:07:39 -0400 Received: by mail-wm0-x242.google.com with SMTP id p138so6759143wmb.0 for ; Sat, 01 Oct 2016 03:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GxlTjjCkMtgzI3UgG3PH6bzIGsdTKX8Dr0tYMjuBiFs=; b=L4o2jvQoNO7tNQ8tHoKIQeyciE/lOESGEkLWB24A1hD42nSU/bBHMZYSNx+UG2hrwV 6tNpSGioPlb6m2JL7e0nOfumMfyzMRjVOotKe9+RiDL1pc2LVGtgWSYdB2QrjfeB7rnm 3jUEoSl3oZI04pi40Wds3eO1pUWJ0wVLpGlYoq6MBQy3UDyRFrFEezKzh1PvQh0Ibs1l 7mKtNHOB2VJpPd3J1p5p9HXUWmomfLnu2v+hG3qdIw6pkzEqlxib11KjGmm9DFCdYsC4 MNxtc4Jlep6z78HBXC2Js8TfC824OdFb5Tjv1nBtdLMv9A+1sNUtNH0gWCGHbtSwbYi+ rYkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GxlTjjCkMtgzI3UgG3PH6bzIGsdTKX8Dr0tYMjuBiFs=; b=fxLwGPA7BVG3VffC0I07JDcU5lYAEBgFt8+WHJz8zRASokSCFqIc6HVywy/xVMScG6 L9oOT4okrO7rLJIk2Yxmt6Z1FEXtNRVogIq3MgELthUnCnls+SJ68KoVilMuoepotC8F v/1k7m8V9LT9MczNX1JWJ+JCguSse/fDtZHH5kpkdg0uzeprTBktCpUG1FRyVX7I/BdG kiY5y5ssPr5zPNP8pHmpmmCr3/jIohLBUb8q/gRBRHrA2dMFVVJh1NC9j1GiDgESDG1k 09cGnRzCktEhrn9q7aH7aebwJgnnsfQ7tZstSX8WMIFX2iZVuWl9f0QzuoIYhu5QYWJb LIUQ== X-Gm-Message-State: AA6/9RkJy+j6UGwbxBB5vWL5dyNf7/Rj4z9yOXP6XENpixSo3qtECjEdDIy20dVXg6AeuA== X-Received: by 10.28.73.138 with SMTP id w132mr1670475wma.92.1475316459089; Sat, 01 Oct 2016 03:07:39 -0700 (PDT) Received: from localhost (x55b4da19.dyn.telefonica.de. [85.180.218.25]) by smtp.gmail.com with ESMTPSA id va3sm23981534wjb.18.2016.10.01.03.07.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Oct 2016 03:07:38 -0700 (PDT) From: Artyom Tarasenko To: qemu-devel@nongnu.org Date: Sat, 1 Oct 2016 12:05:26 +0200 Message-Id: <1475316333-9776-23-git-send-email-atar4qemu@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1475316333-9776-1-git-send-email-atar4qemu@gmail.com> References: <1475316333-9776-1-git-send-email-atar4qemu@gmail.com> 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 22/29] 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c index a85552e..c27e668 100644 --- a/target-sparc/ldst_helper.c +++ b/target-sparc/ldst_helper.c @@ -210,6 +210,27 @@ 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 = 1024ULL * (8 << 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 = 1024ULL * (8 << 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)) {