Message ID | 20240726235234.228822-52-seanjc@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48A09C3DA4A for <linux-arm-kernel@archiver.kernel.org>; Sat, 27 Jul 2024 00:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To: From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cHTm12hU98ihrn/4YhoQtTNxFr6qD1GrOX0sqy5dmrg=; b=G637FdTNRVcIdVjMYmlxVI0Mwe M+wjpM8FPEUlLy571eepEqDUBwJyqHxgCVzMvX3C4jDAoyGcg1SsriSvpf628Bgw6Da3N94xMVZv+ GH5w9svL/4s3LQ623biGv6q+NpI3k9bRI8MXezPKR0TsOhOMluR5MbO63fFOd5pOT30S69Be7lxJF jux/VZ3kG7T6dFoGLXKdrxuOawpY6mG/00fYbY7+xWcBnQ5e16cUWCb7IX4pkOoz2ZqJC8RRrgwiu lDF6rNEO3dUqBrxHnX6ZqvxsCsqkll2t37yQVH1vLAZwb+UfEwJ5HRQPsWyJc72JZNSp9J121S0R9 NMoFhfBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXVBb-00000005eWw-0nOG; Sat, 27 Jul 2024 00:21:23 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUlb-00000005QfJ-2OKg for linux-arm-kernel@bombadil.infradead.org; Fri, 26 Jul 2024 23:54:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=cHTm12hU98ihrn/4YhoQtTNxFr6qD1GrOX0sqy5dmrg=; b=CZTRi8jLfDlpvna2dsvIBASjA5 vLJ3trbL9QseQ4wLkjYN1pyM66OtnHyU0zpvgtbO+j0h/9yaciYUyEbBAl16Dv2kXfb7aC0NqvrNe /3me0zorBaAynuuoogjhs5QudVdcpMbcbDwu6kdGZ4dPFgJ/tX1pKPUshaOE0RNKWLrLh5SlAH22b zZMSpNHSSbSohbQ5xjEULqj/QZwtCi0/01BcUcvAs0K5OL2q2GVpqlISjxXPkvWfjGZUSjhRlhOAl zkib5qpwHSrFdsvGlF3NV+gSKi37+G/qt24XFP965OO3AQurDO0EGY4i2xmpdo8GwbffKtrE2FljO sJiqgTPw==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUlU-00000004K1G-20zW for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 23:54:30 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-66b8faa2a4aso7071887b3.0 for <linux-arm-kernel@lists.infradead.org>; Fri, 26 Jul 2024 16:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722038062; x=1722642862; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=cHTm12hU98ihrn/4YhoQtTNxFr6qD1GrOX0sqy5dmrg=; b=1b1yYmKP7mnXxMD8tnd+bW+btmybxXMpXB9ZXxcbBPnk+y4Xq9L0jBGrXdeHOBJaEd uC+H+nUCYNpyEQdXJ+nfU3WnD90l2xR7m6qttWhkfpTr9nbPF8hyg6bFDel1hBhA09Zh W7s0yYoht5LCR3cLfE53AP+OBr0k9fFZuH7KoAmBCJ+/zmcPeuu8FHEcAca3Y+9cnw9E LqoF0LHpsAIbV7LI27bxZ3EDfXCAtVRXou/8AkGPVA9M5IKZv4XuTsUBH7LbVJI3mvLc tdeUZ8Tq2/MfUfEFY67Tet/kbztVAei3X6LYK1t45ciMHH9UmdCg+dP2KDlWAG8o0+Q5 22uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722038062; x=1722642862; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cHTm12hU98ihrn/4YhoQtTNxFr6qD1GrOX0sqy5dmrg=; b=Irqt6+TPdcTkqJM3rpW7DCAyyCtaZabgmRgQFZNeAOGxJdOZq/i2++b+7f1BT/pB0W //9jSR92Tq2pBfYYKOrIUZxzrNLcZdnSclmmlG8btxgCcyyjX2Cv8yYZP6ouud+fg/ft hlYPozy99T9KozpgleH4MSk9EnaC+Ru+ixG73xkihFDsUcLCbRM56zvpSECbPu+M/M0P XZjUm7Q4FB6+s4otGf7c04bqRQ8QR9JJPVO1vM+YC39p5WtL0zIy217JKnRqhO3xs3D3 bnbrjtjlKKgADw1JT26ggrgvAyYtV/pHSrNzOH8fcyRvpxGO8rruX5CKbi5JuYqjLkSe g4Lg== X-Forwarded-Encrypted: i=1; AJvYcCUFDUSMBVnM6RmYncNJ6S4TUfF15OQ7lZuh45wtkalkbGhBMBaqWMpCMuG34105F9uvP/94iwnUJ6Kg/ozAtVFz4zEHWMmvjHZWzowB+p8L58BrUJg= X-Gm-Message-State: AOJu0YwIaGGcWxUQhU30qwG9qYC7c9fMKo/jsMGmn0eHr1ASZdjh102U BP4viVtq5J8bV1Ohn3KJgAnB2/fAcAksc76HnMvS5/7qsc3yFe7cJ8yX5WWXRRVzQa7rSQQ2MtR 8JQ== X-Google-Smtp-Source: AGHT+IE591qeJqHACb7CkRANjpP2e5907DfMapi1wU/6IAMP+NJSB5aPgL5hiS9fj7k9JDiJNu7gQfM60rI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1005:b0:e0b:f93:fe8c with SMTP id 3f1490d57ef6-e0b5427fa67mr79886276.0.1722038062601; Fri, 26 Jul 2024 16:54:22 -0700 (PDT) Date: Fri, 26 Jul 2024 16:52:00 -0700 In-Reply-To: <20240726235234.228822-1-seanjc@google.com> Mime-Version: 1.0 References: <20240726235234.228822-1-seanjc@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240726235234.228822-52-seanjc@google.com> Subject: [PATCH v12 51/84] KVM: PPC: e500: Mark "struct page" dirty in kvmppc_e500_shadow_map() From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>, Tianrui Zhao <zhaotianrui@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Huacai Chen <chenhuacai@kernel.org>, Michael Ellerman <mpe@ellerman.id.au>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Sean Christopherson <seanjc@google.com> Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack <dmatlack@google.com>, David Stevens <stevensd@chromium.org> Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240727_005428_814985_82BA0B12 X-CRM114-Status: GOOD ( 13.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Reply-To: Sean Christopherson <seanjc@google.com> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
KVM: Stop grabbing references to PFNMAP'd pages
|
expand
|
diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c index c664fdec75b1..5c2adfd19e12 100644 --- a/arch/powerpc/kvm/e500_mmu_host.c +++ b/arch/powerpc/kvm/e500_mmu_host.c @@ -242,7 +242,7 @@ static inline int tlbe_is_writable(struct kvm_book3e_206_tlb_entry *tlbe) return tlbe->mas7_3 & (MAS3_SW|MAS3_UW); } -static inline void kvmppc_e500_ref_setup(struct tlbe_ref *ref, +static inline bool kvmppc_e500_ref_setup(struct tlbe_ref *ref, struct kvm_book3e_206_tlb_entry *gtlbe, kvm_pfn_t pfn, unsigned int wimg) { @@ -252,11 +252,7 @@ static inline void kvmppc_e500_ref_setup(struct tlbe_ref *ref, /* Use guest supplied MAS2_G and MAS2_E */ ref->flags |= (gtlbe->mas2 & MAS2_ATTRIB_MASK) | wimg; - /* Mark the page accessed */ - kvm_set_pfn_accessed(pfn); - - if (tlbe_is_writable(gtlbe)) - kvm_set_pfn_dirty(pfn); + return tlbe_is_writable(gtlbe); } static inline void kvmppc_e500_ref_release(struct tlbe_ref *ref) @@ -337,6 +333,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, unsigned int wimg = 0; pgd_t *pgdir; unsigned long flags; + bool writable = false; /* used to check for invalidations in progress */ mmu_seq = kvm->mmu_invalidate_seq; @@ -490,7 +487,9 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, goto out; } } - kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); + writable = kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); + if (writable) + kvm_set_pfn_dirty(pfn); kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, ref, gvaddr, stlbe);
Mark the underlying page as dirty in kvmppc_e500_ref_setup()'s sole caller, kvmppc_e500_shadow_map(), which will allow converting e500 to __kvm_faultin_pfn() + kvm_release_faultin_page() without having to do a weird dance between ref_setup() and shadow_map(). Opportunistically drop the redundant kvm_set_pfn_accessed(), as shadow_map() puts the page via kvm_release_pfn_clean(). Signed-off-by: Sean Christopherson <seanjc@google.com> --- arch/powerpc/kvm/e500_mmu_host.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)