From mboxrd@z Thu Jan 1 00:00:00 1970 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 1E9C4C6FD1D for ; Thu, 30 Mar 2023 08:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hn3CONWwWyfuUj6JNHXK92yTDTJKStGPW3JTvZAaT6M=; b=FZI9T4Nl5rb0tT jx7OtzAYl2hAu6enTAIBQtkywOmc7XtNhjwUVyDHDFVu1PSClkIMs70VDUllv3RI+lmKNib7XO3g6 myYR5eXw1kbkqbJ2kO93SV3+5EGy1QrCpZSTe0Nn82lCT+mgqAT3R+njx8qz+etplKLsudbz9TGzd lKwYT3Kv/+C0kiVUZ1ny7gzT/vdeUnGUJAq0oy8SutdY4tt/JW73fKj/8mwhPyRv5DsDugz256DR5 Cy2s9towrgsST9tDANKkeGM8zk5IBgBrMuItIGCwj2ghpTUNUJbaLYknVQ2ioV/MMfLWbLwIr+FaK sYSfjyJDImZULlSIR4TQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pho6q-003BTs-2c; Thu, 30 Mar 2023 08:58:16 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pho6o-003BSd-04 for linux-arm-kernel@lists.infradead.org; Thu, 30 Mar 2023 08:58:15 +0000 Received: by mail-pj1-x1031.google.com with SMTP id om3-20020a17090b3a8300b0023efab0e3bfso21259206pjb.3 for ; Thu, 30 Mar 2023 01:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1680166690; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=khZuI90C3yICc2QlVMZxoINj4hbBwgvv4lkvCwQn0oM=; b=EXT9oCu6maH6hdfTnR/yspZUXl4VC9pYBcFM28HOWhVhVGfjKr06H97hxY5NEcXDVy O6AYwjuUW+eoRs3XHt58Vt+g8j0rm222Dq96fo5vNQMf/niag4j/MHyFyVmXmvni74E6 /YSWF5zCloCKf2Ewpv0BTU/CsQe8NgLXcgDAc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680166690; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=khZuI90C3yICc2QlVMZxoINj4hbBwgvv4lkvCwQn0oM=; b=YUBr8Hyb2l2rE+J4F3OEZ17fVCwlnsx6GSkkdCR6s00N9BJXPztx0M4CjEbWSEksWX GPUv43t6X2CiYc4A7C1gYbZtYm4rt38RSonvDH2sYEld/I6mNGngeN3dANqlp8IfsVQj aAoNlNxFqpaQ0NpHZ8fN5uiGeYcAp0P56SjG1oMnM/J4dTN01XsBdss+pwTGcbChXox8 JMqmEOC7sjBOlkmCnRqDWVHdbch7ykJDmAtkfFnm/tp7xSXZ+/Ez3IYVMxXYVusc8lpV +r/DthApirg8O7MT1UZ5oQrwiGb7Ky+1Rjv1Q5ghmDO3pIDTwev3+X/sxj7nPAU0byFt a6Xg== X-Gm-Message-State: AAQBX9fuQNxwpJX2CJBXSQ8nRjB4Qcbdn4WSYMs2apo2YXFHUpX2wea5 VzyK3LT50gIDuLPvoWdNOrhMmw== X-Google-Smtp-Source: AKy350ZDrTpkuW3KLUjaRcClMpQ+xS+Gsu2ak5nMpigAHapulHNWYWEUZil+IM2Hxt1/98K3/CNwAQ== X-Received: by 2002:a17:903:11ce:b0:1a1:da3c:6065 with SMTP id q14-20020a17090311ce00b001a1da3c6065mr28208585plh.22.1680166690463; Thu, 30 Mar 2023 01:58:10 -0700 (PDT) Received: from localhost ([2401:fa00:8f:203:1320:eef8:d0bb:b161]) by smtp.gmail.com with UTF8SMTPSA id bj4-20020a170902850400b001a076568da9sm7239405plb.216.2023.03.30.01.58.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Mar 2023 01:58:09 -0700 (PDT) From: David Stevens X-Google-Original-From: David Stevens To: Marc Zyngier , Sean Christopherson Cc: Oliver Upton , Paolo Bonzini , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, David Stevens Subject: [PATCH v6 0/4] KVM: allow mapping non-refcounted pages Date: Thu, 30 Mar 2023 17:57:58 +0900 Message-Id: <20230330085802.2414466-1-stevensd@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_015814_084619_240515A5 X-CRM114-Status: GOOD ( 18.81 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: David Stevens This patch series adds support for mapping VM_IO and VM_PFNMAP memory that is backed by struct pages that aren't currently being refcounted (e.g. tail pages of non-compound higher order allocations) into the guest. Our use case is virtio-gpu blob resources [1], which directly map host graphics buffers into the guest as "vram" for the virtio-gpu device. This feature currently does not work on systems using the amdgpu driver, as that driver allocates non-compound higher order pages via ttm_pool_alloc_page. Currently, the gfn_to_pfn functions require being able to pin the target pfn, so they fail when the pfn returned by follow_pte isn't a ref-counted page. However, the KVM secondary MMUs do not require that the pfn be pinned, since they are integrated with the mmu notifier API. This series adds a new set of gfn_to_pfn_noref functions which parallel the gfn_to_pfn functions but do not pin the pfn. The new functions return the page from gup if it was present, so callers can use it and call put_page when done. This series updates x86 and arm64 secondary MMUs to the new API. Other MMUs can likely be updated without too much difficulty, but I am not familiar with them and have no way to test them. On the other hand, updating the rest of KVM would require replacing all usages of kvm_vcpu_map with the gfn_to_pfn_cache, which is not at all easy [2]. [1] https://patchwork.kernel.org/project/dri-devel/cover/20200814024000.2485-1-gurchetansingh@chromium.org/ [2] https://lore.kernel.org/all/ZBEEQtmtNPaEqU1i@google.com/ v5 -> v6: - rebase on kvm next branch - rename gfn_to_pfn_page to gfn_to_pfn_noref - fix uninitialized outparam in error case of __kvm_faultin_pfn - add kvm_release_pfn_noref_clean for releasing pfn/page pair v4 -> v5: - rebase on kvm next branch again v3 -> v4: - rebase on kvm next branch again - Add some more context to a comment in ensure_pfn_ref v2 -> v3: - rebase on kvm next branch v1 -> v2: - Introduce new gfn_to_pfn_page functions instead of modifying the behavior of existing gfn_to_pfn functions, to make the change less invasive. - Drop changes to mmu_audit.c - Include Nicholas Piggin's patch to avoid corrupting refcount in the follow_pte case, and use it in depreciated gfn_to_pfn functions. - Rebase on kvm/next David Stevens (4): KVM: mmu: introduce new gfn_to_pfn_noref functions KVM: x86/mmu: use gfn_to_pfn_noref KVM: arm64/mmu: use gfn_to_pfn_noref KVM: mmu: remove over-aggressive warnings arch/arm64/kvm/mmu.c | 21 ++-- arch/x86/kvm/mmu/mmu.c | 29 ++--- arch/x86/kvm/mmu/mmu_internal.h | 1 + arch/x86/kvm/mmu/paging_tmpl.h | 7 +- arch/x86/kvm/x86.c | 5 +- include/linux/kvm_host.h | 18 +++ virt/kvm/kvm_main.c | 214 +++++++++++++++++++++++--------- virt/kvm/kvm_mm.h | 6 +- virt/kvm/pfncache.c | 12 +- 9 files changed, 220 insertions(+), 93 deletions(-) -- 2.40.0.348.gf938b09366-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel