Message ID | 20241010182427.1434605-60-seanjc@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 796C0CFC5FE for <linux-arm-kernel@archiver.kernel.org>; Thu, 10 Oct 2024 19:31: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=OPPvMTYiUGb6pAXW02Q14XiUF2+KvArosM2sRK6VjAA=; b=Z2iIqyCRLvEfG5E+OYp39IG3Xn bxfOLEIRAFYcITw/FoC/yrcbT6k1LV0TjFaNG26Zm26gjd7Tul9ulxe0dFokBH3A8VFd4LOB8jRU8 4OBoik7PCqK5zK9nKwldWWp2ESzT31mh+kDsE1guMQQjYJBiT9hkr0UDw1ObZHcaH8BKaFnhjeYJA DVEc0iSdjGddwLdRohcHoDG/CARIrEwfq2uB56gkTWKBI2w52wwxmoG7ms0T3MCCXmn3kSS6ZS1YS WWQq8l9lFWsAB8OFzEuRFfPmWgRidiw5gZsL/H508AqVHkzmGxZfu4WrX6iE09IcNvlAy0P/zIXit msn0tDFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syyse-0000000E7Dk-0y47; Thu, 10 Oct 2024 19:31:24 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxsJ-0000000DrHJ-17c0 for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:27:02 +0000 Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-7e6c40a5795so1041173a12.3 for <linux-arm-kernel@lists.infradead.org>; Thu, 10 Oct 2024 11:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728584818; x=1729189618; 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=OPPvMTYiUGb6pAXW02Q14XiUF2+KvArosM2sRK6VjAA=; b=jHZE+5uWuKTW/XclrN7CxgU01R867qap0OT1d1SQAxMutGogOns2m7h4OczE0MMOAh 1bOC4OAreKrsxWwPn6Lq4yUn6ww5VGN/P/6dCQu7Wz1aJXS6RA5MlDKU8blhQdAK3+oJ w7Hui36VpO0Ua+GpakXkDzGrrZtAOQ4i+bpjS2LZB15ep1oIi954CEVd8VSCUEpuTEmH uMVRVR+qn2o1f5I/7taWb50bvQjkE/GagwpScYZSMNiGtslKvTiZXEYVCdh7kpLhPoVU OeNf3Txm2Xav5Rvn23+I0GhmOXaelr06WRlnGWvEKKd7xtGeetms/WSDotPLATORh2a1 urMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728584818; x=1729189618; 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=OPPvMTYiUGb6pAXW02Q14XiUF2+KvArosM2sRK6VjAA=; b=VFI+42+49rzon9N9oyctzW9FjM+uU8ljcPUjy+oc514DVKjup51T0MrYj3Bt3QbXvD EeGlvjzduyb3zmA0LQW0RIt1ziOFUAImyTRbOR1so1ckraKLfQ7ifCOcXXL/31VAH+rx jWZnsDKulSuw/ymgvkxG8VVXPp1vznqdunsTUXBno/vr8JwBlT/aPwDWLRaguaZEvRs+ tEJTwm9iP/FH0eidQJXfCSnRBvuAEIqmGy+fnOaownBSjRIU53wNs53VkKdHgw9W9dEP Lwd3r0ihGzUHT3nvp4iOLgWRbQtFWf7cdVQUX6bG2IXhXDixUqEp3b1mGq6Fiqe+ZzXi UWOA== X-Forwarded-Encrypted: i=1; AJvYcCUopsP68u+eLV0O5aAyYwTTzYy3DirlyUeOQ6eC/Dl9SAMN7bQU20r4H4i+MmCr8u2R4cyn+7pe82Ajd0EgI3Au@lists.infradead.org X-Gm-Message-State: AOJu0YwvrJHb99IDrOjVyDnoZ8Kb9pxQsxrz4/tYPMT96phD66HUJ+O0 TMGfltR0S00h8Mz5SmZu9W3+MuNkjlFq9Mc2Dxuv7tqOb5Q3ST/xNx+fqYgXEEffqfL0c9cOzQl M7g== X-Google-Smtp-Source: AGHT+IHVZkXcNH8eDb3GIQubykYaXKWHdrpGe/zHTLQHIjPMwQpAN0ra/QncFunLfkL/hgYZuPxk0qgLkH8= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a17:903:2343:b0:20c:747d:ec15 with SMTP id d9443c01a7336-20c747df618mr290175ad.1.1728584817934; Thu, 10 Oct 2024 11:26:57 -0700 (PDT) Date: Thu, 10 Oct 2024 11:24:01 -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-60-seanjc@google.com> Subject: [PATCH v13 59/85] KVM: RISC-V: Use kvm_faultin_pfn() when mapping pfns into the guest From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>, Tianrui Zhao <zhaotianrui@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Huacai Chen <chenhuacai@kernel.org>, Michael Ellerman <mpe@ellerman.id.au>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Sean Christopherson <seanjc@google.com> 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?= " <alex.bennee@linaro.org>, Yan Zhao <yan.y.zhao@intel.com>, David Matlack <dmatlack@google.com>, David Stevens <stevensd@chromium.org>, Andrew Jones <ajones@ventanamicro.com> Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_112659_428112_68420971 X-CRM114-Status: GOOD ( 11.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Reply-To: Sean Christopherson <seanjc@google.com> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
KVM: Stop grabbing references to PFNMAP'd pages
|
expand
|
diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c index 2e9aee518142..e11ad1b616f3 100644 --- a/arch/riscv/kvm/mmu.c +++ b/arch/riscv/kvm/mmu.c @@ -601,6 +601,7 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu, bool logging = (memslot->dirty_bitmap && !(memslot->flags & KVM_MEM_READONLY)) ? true : false; unsigned long vma_pagesize, mmu_seq; + struct page *page; /* We need minimum second+third level pages */ ret = kvm_mmu_topup_memory_cache(pcache, gstage_pgd_levels); @@ -631,7 +632,7 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu, /* * Read mmu_invalidate_seq so that KVM can detect if the results of - * vma_lookup() or gfn_to_pfn_prot() become stale priort to acquiring + * vma_lookup() or __kvm_faultin_pfn() become stale prior to acquiring * kvm->mmu_lock. * * Rely on mmap_read_unlock() for an implicit smp_rmb(), which pairs @@ -647,7 +648,7 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu, return -EFAULT; } - hfn = gfn_to_pfn_prot(kvm, gfn, is_write, &writable); + hfn = kvm_faultin_pfn(vcpu, gfn, is_write, &writable, &page); if (hfn == KVM_PFN_ERR_HWPOISON) { send_sig_mceerr(BUS_MCEERR_AR, (void __user *)hva, vma_pageshift, current); @@ -681,11 +682,7 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu, kvm_err("Failed to map in G-stage\n"); out_unlock: - if ((!ret || ret == -EEXIST) && writable) - kvm_release_pfn_dirty(hfn); - else - kvm_release_pfn_clean(hfn); - + kvm_release_faultin_page(kvm, page, ret && ret != -EEXIST, writable); spin_unlock(&kvm->mmu_lock); return ret; }