From patchwork Thu Oct 10 18:24:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13831205 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 D12D6D24454 for ; Thu, 10 Oct 2024 21:47:00 +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=3FFUjrr9Bcuid6sLVD5OEsWVTb8VG25P9bGjkNYbAzk=; b=Xbw80HhaumOfhaHAKuA1UOhDOQ Umk+yHMYysSBIhtKRVcwqNxdMz0feFFg9mKmK1qEX8pjwuoxZWbQsXRIJjw44lRikNnYBndkyLzlQ aeWOhyjHfxkwTmwoSqjwfPhCxL2jIe4hWNnpXCk2P42HIuGmkQXbOnnVsceogA+O4nWN16okX3SPv h7M20oNf1Rriv929UVjvppM8hBvjYx3uyMrAFCIa4KJQrcXwx7oYN7n/vnSL2mOqAvx88lpV+c7/8 cLnDtTX67U6howBnb0ekAjzNbYx1Zi9dlFN4dSsqzvuM9wHO0CcNV2K/0Zdk4z2QtbhbdUCdfkkgl ROO8ZhEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz0zh-0000000ESn9-0vqK; Thu, 10 Oct 2024 21:46:49 +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 1syxsY-0000000DrTr-2kJD for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:27:18 +0000 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2e2ca4fb175so1249365a91.3 for ; Thu, 10 Oct 2024 11:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728584833; x=1729189633; 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=3FFUjrr9Bcuid6sLVD5OEsWVTb8VG25P9bGjkNYbAzk=; b=jRyJBHlowWWe5rLfr7phIk02+Dz1smiC9B+8+l8fjItytQHfaPqfwXS9kwAda+9AmE shexSqSJbO2Rx5qii1tALAryS4pGnWvtVZCfeOEjmFWSO4HKZPxS8nkGfwDKwQymv5/V wfkt5jyod4tGS84UNkBF5H1yJop/76JLfNyM1euymRTGgEs/dQq38usgpogljBsjQeGI Dm9WN/3n4aZGT70TBOP644TkbWftIVyZDtlLOtZt6iA+3KaFCeUyJfaSP6mtPhXMMbZl celjnP4Ov3sMYoEohXSA+AP8wA6JsEeZNgXH6S6QNub5U4W5uofyo/ebOoZSoyqeVbK2 vrZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728584833; x=1729189633; 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=3FFUjrr9Bcuid6sLVD5OEsWVTb8VG25P9bGjkNYbAzk=; b=QyD1WWQXxyY57LczOW8t3m/guqPNI0o82wX27nsMGE56OtTmchhYE3EFCGfaaF2x95 HsLgeoBjsimd8oYQM63N/Tzv7K6MV2iM4kEptkCaz3rsEJCmMQBAkqF7BG+hb1Ij08OV lloVtkGoVgM/0CxVaZVZWVJKnuWN7cKyONEcZC7ZafbPSxTE0/j9dhyFk2BdLM0DF/ih IBzt/1jF96id5QbDfrhD6mBtSOoy5Xk7o9S1VV3XocOfOEdEPrfP9uVIPv4q/8y9nXk9 OyDHPP68QoxITJSgnAVUrp+4pq+/HiJDM8daMOv/W6f/sADinmXoCwygLxXgTbI2YsLm iQBw== X-Forwarded-Encrypted: i=1; AJvYcCWBazJ/DXqo44Kd9CY0oMjCFUi2ixcIff/+qejt4k6Me/IfNG8NjRLOj8SLAZy4nic6ZU3e7bZfoVr/+XjbhKoh@lists.infradead.org X-Gm-Message-State: AOJu0Yzwz4JLcX+yS9K/FxUScTXVMPIgQYdiXcZXqbu7JpaxTtv9qt6O 9EDYfc2teI9nDPi2BLveYnS1h0avgrrMlsAJVo+SUmsi75xNLagBsYs3P960MhqK2lWTBalKbzD e/A== X-Google-Smtp-Source: AGHT+IFpwqxWKAWfrUvKF1EatvnBv5g5CrzcpgT/ZTuiTODJnzoCoYK053S1MFwF0WyL9wI3LVhDYDAiv74= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a17:90b:46d4:b0:2e2:e148:3d37 with SMTP id 98e67ed59e1d1-2e2f09f1a56mr94a91.2.1728584833102; Thu, 10 Oct 2024 11:27:13 -0700 (PDT) Date: Thu, 10 Oct 2024 11:24:09 -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-68-seanjc@google.com> Subject: [PATCH v13 67/85] KVM: LoongArch: 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_112714_817511_A226DCEA X-CRM114-Status: GOOD ( 11.35 ) 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 LoongArch can convert to kvm_release_faultin_page() without tripping its lockdep assertion on mmu_lock being held. Reviewed-by: Bibo Mao Signed-off-by: Sean Christopherson --- arch/loongarch/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/loongarch/kvm/mmu.c b/arch/loongarch/kvm/mmu.c index ed43504c5c7e..7066cafcce64 100644 --- a/arch/loongarch/kvm/mmu.c +++ b/arch/loongarch/kvm/mmu.c @@ -902,13 +902,13 @@ static int kvm_map_page(struct kvm_vcpu *vcpu, unsigned long gpa, bool write) if (writeable) kvm_set_pfn_dirty(pfn); + kvm_release_pfn_clean(pfn); spin_unlock(&kvm->mmu_lock); if (prot_bits & _PAGE_DIRTY) mark_page_dirty_in_slot(kvm, memslot, gfn); - kvm_release_pfn_clean(pfn); out: srcu_read_unlock(&kvm->srcu, srcu_idx); return err;