From nobody Wed Nov 27 10:49:36 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 7428F212635 for ; Thu, 10 Oct 2024 18:27:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728584847; cv=none; b=e2DXEp68ho6lwgLiEOLKWCNtXpnFSmKmAQfqSDLfZPeh676Mc4mWMMxNfLgc6/7QJkSTS5Jsy3pMA7uTj5UB6xrkd3vr8c4r7gca3qbaCcJW+OFVeoMNhVXCdyNYSM4+tl1Zh0G+nnRCp/f6mfp5n0tTXkCKPNyERmzxqibu034= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728584847; c=relaxed/simple; bh=8dGNSdkZyds89DzrI//tIWXaU4bIHqe2OXPOvN+ci/o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tZrzNKZmQbfgO+/8Zh6f3DZ6PmqsttLWw6tGTmtfKJB9My7iPkSAD5JHWiU8Q8xOGF3wlabNy1E1csZPzWhI5dlps2HjEOAzZvYCpJ6Pkij9h9ablrUYkeHVhII4sHikY+6LZ6GDB9DlGu7S7nyu+v/M+jbnc+M0ghXo9Aa4Nlc= 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=JPv9zkzp; arc=none smtp.client-ip=209.85.219.201 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="JPv9zkzp" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e1159159528so3623549276.1 for ; Thu, 10 Oct 2024 11:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728584844; x=1729189644; 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=ojyPU0tzKIRRbswoqL6JjpEgqRgu1FFXpokE5rqa8U0=; b=JPv9zkzpTer/tRVsCcO0xpoVowSI9sq8yAveFD2GfRunYb5X0FtcPWNADF5sqlUd/3 iuZOBdxa/cq2pQY/AtFf67RWj9iN68fjShGVpAPx4/qOHMoD0+4MDx5ng50F99dpeqZz D7tj1u3tjV11ltIQLbM+e6UJ2OtxC2znpSGhxBoavgsmxRK8vxqwx1Wv6ERJeKC1sxzZ warJrQCxdXVL7hXsRhLLyu6K6XZyuCXcbnBSMP58XjLa6moCXuL2/gm/dZ9g29lFRGQD oz4+v/DmwPgsIZnAE2dQyOCO8flkAv8ygdRPm7vy8SmXxLTWo0sUXu9l6nOoTHE0oXK6 D4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728584844; x=1729189644; 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=ojyPU0tzKIRRbswoqL6JjpEgqRgu1FFXpokE5rqa8U0=; b=RXvMTi4QX7hv27EseY4Oa+cjpBp/ZsDoCVc66GVwd6/N8NUzonSi/1EbQtValUn3uz 3NwL2LH1N7ShQKLs0cc+gx+xs7uNuVELMJZzNG1siDCOHF/CMGKteeRkrxB5nEgWupZ5 cSOldJ+N+tNitKujIswgJJPE/szenL9GX66lkcgQ/MGZ03oxj+mvUxJHDwbPlR+gEi8x n0knzizOdty/0z7rY7E+MbC2h0rm19Aq1YZ1GMG/nCModwkrKvfyjvyfPIMFPcpD6PVE uUi3J/XY89qf7qXoDsa+7Z//5W3dImfujsxdadZuH6OdKle2n+ViQC0cx20Xv+dFRqJX P47Q== X-Forwarded-Encrypted: i=1; AJvYcCXAm1XRyrAX4GD6UP+7KXFoQY7+Ef532Kosj1PFAEM2jqsbDGgP1lcSMFq/0lG9XG+jirRh5g/JugLJj+E=@vger.kernel.org X-Gm-Message-State: AOJu0YwVM9FbfuXsOGX5jgVeKwKK8X/6Po5UjI5Bhby88kCPxAFQT4vW uTDd7pFBi8cfD4BYVXLGxbg9E10/KG5TpUdZJ32CXqeB2Fp/ht2Y2X1wbA8l5tVQW6h1Fno/zYK VcA== X-Google-Smtp-Source: AGHT+IHEyKrdGSoNbMWcRNiKhgC/jPgVf/TjauaPCrq7yqhpXyuJQagleroMC0w40O7lZsOojHLr7EwrZqI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a25:6805:0:b0:e20:cfc2:a326 with SMTP id 3f1490d57ef6-e29184333b9mr26276.6.1728584844184; Thu, 10 Oct 2024 11:27:24 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 10 Oct 2024 11:24:14 -0700 In-Reply-To: <20241010182427.1434605-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-73-seanjc@google.com> Subject: [PATCH v13 72/85] KVM: MIPS: Use kvm_faultin_pfn() to map pfns into the guest 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=20Benn=C3=A9e?=" , Yan Zhao , David Matlack , David Stevens , Andrew Jones Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert MIPS to kvm_faultin_pfn()+kvm_release_faultin_page(), which are new APIs to consolidate arch code and provide consistent behavior across all KVM architectures. Signed-off-by: Sean Christopherson --- arch/mips/kvm/mmu.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c index 69463ab24d97..d2c3b6b41f18 100644 --- a/arch/mips/kvm/mmu.c +++ b/arch/mips/kvm/mmu.c @@ -557,6 +557,7 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, uns= igned long gpa, bool writeable; unsigned long prot_bits; unsigned long mmu_seq; + struct page *page; =20 /* Try the fast path to handle old / clean pages */ srcu_idx =3D srcu_read_lock(&kvm->srcu); @@ -578,7 +579,7 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, uns= igned long gpa, mmu_seq =3D kvm->mmu_invalidate_seq; /* * Ensure the read of mmu_invalidate_seq isn't reordered with PTE reads - * in gfn_to_pfn_prot() (which calls get_user_pages()), so that we don't + * in kvm_faultin_pfn() (which calls get_user_pages()), so that we don't * risk the page we get a reference to getting unmapped before we have a * chance to grab the mmu_lock without mmu_invalidate_retry() noticing. * @@ -590,7 +591,7 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, uns= igned long gpa, smp_rmb(); =20 /* Slow path - ask KVM core whether we can access this GPA */ - pfn =3D gfn_to_pfn_prot(kvm, gfn, write_fault, &writeable); + pfn =3D kvm_faultin_pfn(vcpu, gfn, write_fault, &writeable, &page); if (is_error_noslot_pfn(pfn)) { err =3D -EFAULT; goto out; @@ -602,10 +603,10 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, u= nsigned long gpa, /* * This can happen when mappings are changed asynchronously, but * also synchronously if a COW is triggered by - * gfn_to_pfn_prot(). + * kvm_faultin_pfn(). */ spin_unlock(&kvm->mmu_lock); - kvm_release_pfn_clean(pfn); + kvm_release_page_unused(page); goto retry; } =20 @@ -632,10 +633,7 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, un= signed long gpa, if (out_buddy) *out_buddy =3D *ptep_buddy(ptep); =20 - if (writeable) - kvm_set_pfn_dirty(pfn); - kvm_release_pfn_clean(pfn); - + kvm_release_faultin_page(kvm, page, false, writeable); spin_unlock(&kvm->mmu_lock); out: srcu_read_unlock(&kvm->srcu, srcu_idx); --=20 2.47.0.rc1.288.g06298d1525-goog