Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp264639pxb; Tue, 28 Sep 2021 21:33:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkI6gwk8oevpeqYBMtAGHX1bVlB9o4iIWcX8bTBcThoVDqOozmvYJjossYG2WPMXrOKQuS X-Received: by 2002:aa7:88cc:0:b0:431:c124:52ba with SMTP id k12-20020aa788cc000000b00431c12452bamr9058462pff.63.1632889991055; Tue, 28 Sep 2021 21:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632889991; cv=none; d=google.com; s=arc-20160816; b=j7+QSPltVPZCQp1pg+RZUQ4eQyL8sJdISY5mAN9+xWeG42kf7N26LB7UMclNnEBMlj yT/oGT7gz3wFpAkO9mADzH9/APjFlKCCKpAMuJposyoeVH+J70tQXWS9huv5Hm+6ebLy KA8XfKjITJvPOcyxH9IpKNQjEteF4+rK/+QO7XKa9k+CCe9CuEVx1X4mQ17P747Z+Y23 gwUUVMsWsb3gXtjrEtwYaeGofEHmr5WhT+kUWte13YYN9taLr+3ZvEd6OnaVUWHCzEPl QfAQTHUBmskLO5XmYULRe8Kkc3qkUTHh/cXPSLimRw0sQpQi4fm/O9//xbWeY90y9xs2 IHyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QkzreDQI8QXcNj6KF3HsvP+QbXFPHw1Mmnt63rKUKkA=; b=mBfQpy7aV3N9kGYQXjg3pMGBLLD1YeNWoLlIDvGrv3o4xlD8DDIWxeWqpxB3beccdj 9FriXfuRjJhrHlkVpGAmCHXgEl9WlvQVkm+y++/1kAP0ZY2O/6Rgb/hTI/z4PobHGI41 okM10vwCtaEcNFfnJ/kwGpJE3Ixnl1erKMhVAfDKqkT6Em8Korc1gFRwTee6/e9fQpAP lXOox6hp9AcDK2nMFLO0GDUcx3lIDHIuliXCDS6jacwMBdJ4Y2GwNmpxkVv/lsnl9YCR 7cL9iOGYpz0antIaSTZvpjQ4boOiQ9YY4eGVB4kogYWH3m4BtYLTMOahyl5rGy6HE+8O v/Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="SUgnMZX/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d128si1313106pgc.354.2021.09.28.21.32.58; Tue, 28 Sep 2021 21:33:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="SUgnMZX/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243999AbhI2EbY (ORCPT + 99 others); Wed, 29 Sep 2021 00:31:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbhI2EbM (ORCPT ); Wed, 29 Sep 2021 00:31:12 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D964DC06161C for ; Tue, 28 Sep 2021 21:29:31 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id m26so890382pff.3 for ; Tue, 28 Sep 2021 21:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QkzreDQI8QXcNj6KF3HsvP+QbXFPHw1Mmnt63rKUKkA=; b=SUgnMZX/AWTndTbWHhZMsZ/Q8rq2mha6o26G7OvAkCmtpgykvlWgC91PFYQimoCXyV v8PubmTDiQJMqehVuvd15V+PbUnLDyYAlOhEqLeGTkimABHe/8DNH5GMjyR3wqkwUf4N LrwHmT0opEc0XBq0yUrUiNhN23ksP4p5EJqgE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QkzreDQI8QXcNj6KF3HsvP+QbXFPHw1Mmnt63rKUKkA=; b=JFgOlVHSLdXojFD9tmxeLEBMlUDalfSB28Jk1e3HMbSHDDPGo0W5jpVeo9CTCVhdMw SiJclz/yEw7V+Mg8JexvAcWSDRrj+qfioSTAusWM9xBOBhM8+MrWkcrIW4b1bhNevK2+ K8rtJJlwzRbr6R5E2ZuDQ1dmxtXxCNpQ0vFf6Y9q6azxZk62t05qUWaRrhK/kGbRvE2k eLUvDW22eBAlvrC3ds48qEHSLs9JS0COtv1UNDDFME8PxDfe0CpJwjoEqsCE+psjoryB oh4W8WA89+WYQ0AQfXhnAVYqb2lhz7ZNTJp8r136rBDNvoXwW2K4WACMeZ86FNm+YAQh Ksbw== X-Gm-Message-State: AOAM532SfyAt7ViYvgTaUTRqbop6tmBH0fbozIbl5HNW2Hh9cg0Ju+k7 utK+PfC6S8AIXmtq2QkeWZnnQqUvBgzIlw== X-Received: by 2002:a63:e741:: with SMTP id j1mr7938740pgk.86.1632889771324; Tue, 28 Sep 2021 21:29:31 -0700 (PDT) Received: from localhost ([2401:fa00:8f:203:f818:368:93ef:fa36]) by smtp.gmail.com with UTF8SMTPSA id b5sm261924pjk.18.2021.09.28.21.29.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Sep 2021 21:29:30 -0700 (PDT) From: David Stevens X-Google-Original-From: David Stevens To: Marc Zyngier , Paolo Bonzini Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Will Deacon , Sean Christopherson , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, David Stevens Subject: [PATCH v4 0/4] KVM: allow mapping non-refcounted pages Date: Wed, 29 Sep 2021 13:29:04 +0900 Message-Id: <20210929042908.1313874-1-stevensd@google.com> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Stevens This patch series adds support for mapping non-refcount VM_IO and VM_PFNMAP memory into the guest. Currently, the gfn_to_pfn functions require being able to pin the target pfn, so they will fail if 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_page 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. The gfn_to_pfn functions should be depreciated, since as they are unsafe due to relying on trying to obtain a struct page from a pfn returned by follow_pte. I added new functions instead of simply adding another optional parameter to the existing functions to make it easier to track down users of the deprecated functions. This series updates x86 and arm64 secondary MMUs to the new API. 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_page functions KVM: x86/mmu: use gfn_to_pfn_page KVM: arm64/mmu: use gfn_to_pfn_page KVM: mmu: remove over-aggressive warnings arch/arm64/kvm/mmu.c | 27 +++-- arch/x86/kvm/mmu/mmu.c | 50 ++++---- arch/x86/kvm/mmu/mmu_internal.h | 3 +- arch/x86/kvm/mmu/paging_tmpl.h | 23 ++-- arch/x86/kvm/mmu/tdp_mmu.c | 6 +- arch/x86/kvm/mmu/tdp_mmu.h | 4 +- arch/x86/kvm/x86.c | 6 +- include/linux/kvm_host.h | 17 +++ virt/kvm/kvm_main.c | 198 +++++++++++++++++++++++--------- 9 files changed, 231 insertions(+), 103 deletions(-) -- 2.33.0.685.g46640cef36-goog