From patchwork Thu Oct 10 18:23:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13831200 Return-Path: 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 2FF7DD24456 for ; Thu, 10 Oct 2024 21:46: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=RAEBOjiR86B8MKio5svj+gL/GJb0VtWq7ImNxArS0H8=; b=Kwwz4Dr5i//fBDM6BHBX3zNzFk nN7ysdvrDmQ3RknEbLQxXlRIDNEArtYwQO7+8oQTIG5Cd7to2LHBSngvZRfN0OhKQvYTosvJZlUbw K30CFOFpwxnYMonluf4k93hk7j0hhWLOLAypRh2iIS1DGpJgH2WZtT1poMKBmxYMlJWtPNoTRlqoV phYo9/UVHvn0jM+box9Lj/6w51PBX/AVw9tFEh/7WQ3SXYLaLN11QtxdTPa674RUHxzAHc3s9OF6o rcePe4h8mKwQuoDnpIeuZRbjJK2I1apIBfVe2F7/jMqIpyMeSqEp91trFDoSgHHQeQ0b8XJzBtfcI BrtrZ1/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz0zK-0000000ESSd-0Brt; Thu, 10 Oct 2024 21:46:26 +0000 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxs6-0000000Dr5x-4B0R for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:26:48 +0000 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2e18b6cd304so1251732a91.0 for ; Thu, 10 Oct 2024 11:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728584805; x=1729189605; 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=RAEBOjiR86B8MKio5svj+gL/GJb0VtWq7ImNxArS0H8=; b=M+42XwPeNm2oSLyAg3Vl9WyPEJno5UFR5cRhnp+qZDz+0cqpTMt6YrirrABxaPv4FV X5sXr42pqnv6G1sQWDVLbO442GXAXQG2xyM3M6hcjelKEbRIy6LZO34fqlWHgsRi7Dn5 pe3x97wUmaoCQM1ZXS/3Vl1pXCclzZ79Oao4ekCGwyg+ntTW5kORcLutbnMz2yqINPCW e6N8R1w5Gma7o0kQmT4SxmZY4nm22nwQ7NlqJ5SdPUEv2jT5Vm9fPfwj7eK0gmVTDy6p /bUqBoiqtFPjelGUsNSKXHemm2iWSIzBddpPfZJioxZ+Ky5Ja03rjPcof5VsFg8VXqyr vjOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728584805; x=1729189605; 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=RAEBOjiR86B8MKio5svj+gL/GJb0VtWq7ImNxArS0H8=; b=BVSAxtCRm7XWWOIRRNhzGok+6PeDkNNhODQVPK5ie2qx7flAXVpj34mZpHhGUqtLRB OAJATPwa1f4ni6bvy5WEMuFU+w26O4wI6kZc8yjYLb94HPz/oq/g3hHWeE38GILBubW2 F1nt3YQKhFPyY9C9+n7usCrYkwUQ9uaU8jl9rwFFxq5rHRoG6X8CLph0ON5j2RAlBbYX Xj5A7Z+g+gptu4Ume/ADI331dPZJbHNaqyB6KgXi4hlrPXMYSafoewDnP+G3UmjmgemK MpLbAd6ADAQH5EkC8lNmHmoqjucYzEFHP9gm7cYNBr1DjWX5goUInu9YzMT6HbXMmX9d CxHw== X-Forwarded-Encrypted: i=1; AJvYcCVqyGH9GTcafiOaJMaVUuHdP2zYGEViQo7EpAdLfkJ9ivuSw2RVR6mre2C31WzwSgJvwHkFQH9w9faJ/r3Sa5kj@lists.infradead.org X-Gm-Message-State: AOJu0Yy/b0smcwm9XC8/Y7ZNanBqQMxTacK94+f+oPYhaJNYIiLvs/BE rQnINowjFuvOypchPXD/iSRmDoSQETuFs6xs/WNtuzdmXPCd53ZgU4GDwnVq216T8GOBsxe0sSi T4Q== X-Google-Smtp-Source: AGHT+IH3g+or1uGKI8zaqA7g6VjAId1uToioip8sNGZo/KyXggeZoODfUOK1q5z450FXHERnWYgwR7EwX2I= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a17:90a:5107:b0:2e2:ca3e:10fe with SMTP id 98e67ed59e1d1-2e2f0f88a54mr24a91.8.1728584805241; Thu, 10 Oct 2024 11:26:45 -0700 (PDT) Date: Thu, 10 Oct 2024 11:23:55 -0700 In-Reply-To: <20241010182427.1434605-1-seanjc@google.com> Mime-Version: 1.0 References: <20241010182427.1434605-1-seanjc@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241010182427.1434605-54-seanjc@google.com> Subject: [PATCH v13 53/85] KVM: PPC: e500: Mark "struct page" pfn accessed before dropping mmu_lock From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson 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, " =?utf-8?q?Alex_Benn=C3=A9e?= " , Yan Zhao , David Matlack , David Stevens , Andrew Jones X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_112647_145524_4C77BAF4 X-CRM114-Status: UNSURE ( 9.80 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Mark pages accessed before dropping mmu_lock when faulting in guest memory so that shadow_map() can convert to kvm_release_faultin_page() without tripping its lockdep assertion on mmu_lock being held. Marking pages accessed outside of mmu_lock is ok (not great, but safe), but marking pages _dirty_ outside of mmu_lock can make filesystems unhappy. Signed-off-by: Sean Christopherson --- arch/powerpc/kvm/e500_mmu_host.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c index 5c2adfd19e12..334dd96f8081 100644 --- a/arch/powerpc/kvm/e500_mmu_host.c +++ b/arch/powerpc/kvm/e500_mmu_host.c @@ -498,11 +498,9 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, kvmppc_mmu_flush_icache(pfn); out: - spin_unlock(&kvm->mmu_lock); - /* Drop refcount on page, so that mmu notifiers can clear it */ kvm_release_pfn_clean(pfn); - + spin_unlock(&kvm->mmu_lock); return ret; }