From patchwork Fri Jul 26 23:52:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13743564 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 D7827C3DA4A for ; Sat, 27 Jul 2024 00:27:56 +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=r/0kdPmZ+ClWir3sWShoQK9y6l+vrSl7wHPcCrpa8dU=; b=xQ2kc9oCeH3nred2TumyIOB32A T1AjXaoOaPuoArypQ/Xc9YDNNkvfRs4gUUMVlMjF2R0nb6UyiGDgoYQYcSA54uoniHnKZHZEma81y Zaios9zWxuOc9SN51LY5qN/rFMGKn9bVKJ555tCKfN96wZkZ/SvuMFlBxMbs/mwzjFg2ZP89lQgZA n7NFvizcKEUhQTbjcb1fPGox9J8rtYEjV8oJEVu2I1NDhEAnuoaNbsQqUUXOuE2FQSeSXRRTgoT8I ZQjws3gwDP2Lzfx/JsjMN4bbLyyuZVP6s9TqQrrJ2K8fzd7SadzABzaMMzicIA6ApOqofKHGD3uMy 0Xo3+pHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXVHn-00000005hdW-3rKX; Sat, 27 Jul 2024 00:27:47 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUm0-00000005Qya-0FYI for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 23:54:58 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-665a6dd38c8so7226467b3.1 for ; Fri, 26 Jul 2024 16:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722038094; x=1722642894; 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=r/0kdPmZ+ClWir3sWShoQK9y6l+vrSl7wHPcCrpa8dU=; b=ppTrVMrqQJ6FMlV9ZBvfqCcD53spTKFXDhRoolesutIT2ET4fAwSbh5bbA+G9kzNB2 MdrYrwb3TXPr86pCi74VSUoY+mSwR651m/AW1Matp5Ul41EkGRvkE+tFsa8JEWEXgDjN zohX8hOWz0Z/f9iT8mzs64XLWHuFIyeMK2mEIHKhS2+MOK0Jcmw38tYT8Dhtl6aEpbhI 9YqvXBK+9CEcOJGNC0RoaGqeZMKGes5X9FPjrJ5OUbw7E2yKQ+pnQlexCfcfwq+Y/alR QsPrEn/EReLp2dBUML/6PFVoAjXu9DR+A2MrNpLGpdL9hUhgaIqw5VPAk1wnuWDynQ2Z MN2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722038094; x=1722642894; 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=r/0kdPmZ+ClWir3sWShoQK9y6l+vrSl7wHPcCrpa8dU=; b=Mw/bN5cNwb1kStdrdsGgtGzhX0NKgmph/UF/CHQ9YgOmNgp2kZaKlbEY5TFWGIn3BF hbCIVDOX8oj+dPV9tIvdNsVD9HAE7DNBoQ60UfF1vn0UG6czLdbrCAWvcpHxrlgDbcaC b0N8MPK02gABz4uEfrRi8uTUBH/DVN5BOD5ZGng0a0gF6o8pOK/sKdymiRW3A5Rn7UQE C473GtMdYHVvL45uLpOLPj8TE9AuJaKOe3Qq3wrfDTQu5sdtEJqK2cL1Nn9OLCy8kS3J qnzGfyOQZF0vGkyhx7GWCA+3r0LaKvAb47y2Fv7znVa3f2qSae9AHPmDujjeMGiOZpFX lj3Q== X-Forwarded-Encrypted: i=1; AJvYcCUhcpqwLR5qT/hWnZHM19xGAD2nFhDX7OQlrBAQVAT3B4JJLyaeDxJXICNvtPUqBVPuQ73m5D1ObK1jv1Y4KvmZei99t9o3oPbTAhtwLqComLFZBbo= X-Gm-Message-State: AOJu0Yy7e+fAPCj0+29JjDA7Ddj/fFtMbGiQHtN6IepSJeOQmYr/vh9Q qdhjtvPIPNe7ydKwQvZQVzfFkM2w/Aej2q6bPd9RX0OmLGw9YB9apKiSVg3/9eIwCxnAugg77bx w/A== X-Google-Smtp-Source: AGHT+IFfaCc2nH86ghdgf4dpmC6KBZ4LBEB5Lf4TmkgG+fOYVVXJfjBbiJJRrvW3lQJXVsfLzyeGSOH6WxY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:830:b0:61b:e103:804d with SMTP id 00721157ae682-67a004a2a4amr37847b3.0.1722038094439; Fri, 26 Jul 2024 16:54:54 -0700 (PDT) Date: Fri, 26 Jul 2024 16:52:15 -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-67-seanjc@google.com> Subject: [PATCH v12 66/84] 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, David Matlack , David Stevens X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_165456_212736_9784730B X-CRM114-Status: GOOD ( 11.46 ) 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. Signed-off-by: Sean Christopherson Reviewed-by: Bibo Mao --- 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 52b5c16cf250..230cafa178d7 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;