From patchwork Fri Nov 4 20:50:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 9413323 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 BA7C76022E for ; Fri, 4 Nov 2016 21:14:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB7102B09D for ; Fri, 4 Nov 2016 21:14:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A032D2B0AE; Fri, 4 Nov 2016 21:14:56 +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 528692B0BA for ; Fri, 4 Nov 2016 21:14:56 +0000 (UTC) Received: from localhost ([::1]:40821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2lp9-0003sv-4Z for patchwork-qemu-devel@patchwork.kernel.org; Fri, 04 Nov 2016 17:14:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2lSp-0001H0-Ou for qemu-devel@nongnu.org; Fri, 04 Nov 2016 16:51:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2lSo-0004SO-VK for qemu-devel@nongnu.org; Fri, 04 Nov 2016 16:51:51 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:35967) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c2lSo-0004RW-Pb for qemu-devel@nongnu.org; Fri, 04 Nov 2016 16:51:50 -0400 Received: by mail-wm0-x241.google.com with SMTP id c17so5607278wmc.3 for ; Fri, 04 Nov 2016 13:51:50 -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 :in-reply-to:references; bh=dcWD5lcojlC3wo5oVzWXKcm6CQ6l+DQx9OuEwO4kao4=; b=OJL5nU77VtCVaIoZ4tRwFqTvNgECPRGUNHho1sD3kCMydyaB2Nzve7FUBO6oVtoVpO /1dgLDsmTaKigGWMWEvmPCrSvrhJU/331GbthCIyBB7IUwwsaOReXUsY2ZJB+/0G4EVG g1GF85FnkUZ1kHQF7cJiqIpgsqNhum2KQMhUoravY2dkPveSOMBZqTz3J67aLm56ytec /cipz2lYurGN1e8ziHqhsSeUYDW6gEeDzF3lm4FzjB4s7F40XxxLm4k8TQ3kwAg4DM70 ktswJrxTjiO2mOaqOSfo0oLI30VTjZQGV2CjJ5hR6N5rHKmUMkhdrSbWhMI/PKUuTb/T gCYw== 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:in-reply-to:references; bh=dcWD5lcojlC3wo5oVzWXKcm6CQ6l+DQx9OuEwO4kao4=; b=dhPiiE8eN6I+oUyJ6T0tlG0LWLNmb1GhN72XlIWQAp52gN0W8mPKpRi6ntOqosi3XL VE4BQ4Q2ntCLH26znh51aQAaHJIWLwFsvvxzGU48G1KdI5BWfC6Ka4YmDqc4FZNCIhqt mnLHTQN6k84hGjOki4gm/dU+m9WSbWwu/yljD+HIXSi9a0WJ/+WlOrMBmgJUNSHJzqfa cSc7YKpMGluVukb4FuCpIf/VU0XtFUtxkJidoAGuPnoiISp6bpydZ+OjsDWZ041RhsXl 5JP+P8ksm1PSIFv3/GIMxoH3RSrjsYTNs4O/d9accmuMy3dZDsuxI9zItkXO2CVlmOE0 4yPA== X-Gm-Message-State: ABUngvcsdRaDpoUU3wIZq/2zhcCCV8qKjVHxk5CA/7zadAzjnmcwZcV/gQrlFJk/KUH4Vw== X-Received: by 10.28.87.85 with SMTP id l82mr178092wmb.99.1478292709636; Fri, 04 Nov 2016 13:51:49 -0700 (PDT) Received: from localhost (x55b4b5cf.dyn.telefonica.de. [85.180.181.207]) by smtp.gmail.com with ESMTPSA id z6sm7158330wjt.24.2016.11.04.13.51.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Nov 2016 13:51:48 -0700 (PDT) From: Artyom Tarasenko To: qemu-devel@nongnu.org Date: Fri, 4 Nov 2016 21:50:24 +0100 Message-Id: <85116641ed900a97d07e5ed91ea55bba330a14b2.1478291230.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::241 Subject: [Qemu-devel] [PATCH v1 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)) {