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: 13743410 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A042618C331 for ; Fri, 26 Jul 2024 23:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722038097; cv=none; b=MMIR64avGNjCZk/SS6LuvoCD97EpLU35JlfxyYKnaTd3LLSMSxy7yMeJXpfUMxfzNgAk/Fye75sZhy+wrvRhAelrdKiwlVcqQa/z/LoNml1gVS9Janp+YJVBq1eDjRg7kv72jOX8wB0Yoezkq8h4s/u3lZvzJ2QFLLhuqt9ikF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722038097; c=relaxed/simple; bh=p4k5vgBtys8Iq9l8Spp/J/Js17wYLPMbdqXjO7cF1ww=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gHHtnRS+XmQLVwpNhTsEFfFsn2Ud0ctqSm2rIrNHeeDLm3o0MVygu+je8ukwtmFMU5uPnS6H16VsfiCU7EonytFzRvUm48S2bFMIux4SvnSxSiWn4IjeNov+5xkKxsnOonWG3musqR/yMetdeZGuDtnpvQ1Gu8GVGMYhMyAi6gM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=a+5qY/gj; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="a+5qY/gj" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-66a2aee82a0so6621017b3.0 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=vger.kernel.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=a+5qY/gjEV973BT94wElPBxbqo2mZwcW6/G8h18rjsmsRzjd/TYQ0jt4Jx8isfadUg aRRe1GI6hNq/VCbCOddH1pptcuY0Ttru3r//wzksv7XTDeWAS7iWjPJhfw4EGL13QdrV wIRHozBkviUEVPsfnuc1XgYbfaAGequWB+XOBpDW2ym2S9Nhqqu+GbLtQL+RFmQCu4x1 q9IE5D1G9Ze6cIMqkUXVtt+4Jj5SEy5h6E2m+pwBULA06K5fugm2zMsN+BmnBG+RJ323 0v2Vd3+Y1G8iwUC65Q8yj1LGzI7XLysrlaq0l30Mjx3bnNSV8v+rkN1loMcqtnEUnTpY LuLQ== 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=hhgau12xKstx5igJXEXqFfUuaNyMJNwW+HezOwVQtYNgAEoxhLfW5xUBZI1YvMN3BE KvODfnh/85J2EoM+QvuFAMBB19IvKhjrUERXevgNnAx9o3KKi0YcK+0zhPWBaYZzqIJu hs5gN8O/tLe4GMHkfxeyiufcY8oFx2yIpF7dYRR5Z42K/JK3BoktrtiLWvGnlYcgmc2Z u4RIVPMZgd6yiugeQTFqfsF1XqVY7+bqA80pVUiE0DkuiTuqROeKFXFTb3aA2LPx3nVG H6NGgB/VYBc9NpBXz3akhHKlINi69B/RBPl7WeJRuXywm8SJTve3DAURJxWi9X81Mt2A GgOg== X-Gm-Message-State: AOJu0YzUpZlt5sGvUVXrlzQzk+yj1lxuuFMCocjDPFB4I3lgJehVjm33 9PT5r03yLHhR4sp5sJydh7hp+LrH51hheTOmFEb/BEoMFn7fygwzELnaz1pQUAyB6mYjKrEIT9W 2Ww== 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) Reply-To: Sean Christopherson Date: Fri, 26 Jul 2024 16:52:15 -0700 In-Reply-To: <20240726235234.228822-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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;