Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp52036pxb; Tue, 24 Aug 2021 19:51:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMQbtV+SGa2DA/Ke+BqfU8HhFC6IG80PF1ipTYJpPoiDsvGao7geWVr34TJlvYY83K42ll X-Received: by 2002:a05:6638:328d:: with SMTP id f13mr8583552jav.105.1629859908537; Tue, 24 Aug 2021 19:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629859908; cv=none; d=google.com; s=arc-20160816; b=N4SlZfq8Stno2WO62wEEBphqPCM21X406tlkLpzxZm1OEjA9ah6MnQgh533xbgROWd drIRuFUrR6CJa+c++jZUvRxsGgX2Q4z1YFFYVar/+WlzNjsJYCyo2OT021JcHewqCPFi dVka0Q+3PNpJDxRckAo0mje30KHWNqCsUPLab/4paVGKmX0aUVk7QnhKH07ZByIAgpLi 6kXfWbi1m6sGhNpizwP7BW+b8A9vPM6zDtEV2QCsQgB+jliiBIywiGvEYor3YAVJaNad pB5hiR4Ij+YyU0PJ+dKHJcRR9c3K3hf2HltjQPKTKVgKWPslqcFwVkII2mlxc3VsQefM 9T1A== 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=G+VFbxZv56JqJJvHvZfxmdl5/mMwzz6LNS7nJgyEuFg=; b=lkRU1PEqNVyNDd++72eQPsqjN09L9L2/g9LghcasDCJQab0qNzMIhvRq38exQopLNG 5LYqJp88MXv6fCoz7WQd7FdD8F2PoUS0W7V7/RXKv8r0CDTcxdWGNF3qMo4r9aQlnhz2 87iehsKCTztWQYxC0GtoB0nhMDm/+3qZPXqa6XGzLUFhCPgeZXOaO7yDz5W/3OiX+tOK 8prej5Nk07mBWz5BI0eS8iqAtAENHiI5ThLFoAE/adGibnomYtT04H9qs9otDYy2x4KN 8I/di1SdkE9Sx/5n8R4+N5mUQeODYQ3VWOE4MFbAxUbL31VOPE/C59/by8fJ357SUFcj 1FYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PuRuwB6G; 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 v18si19218145ilj.94.2021.08.24.19.51.37; Tue, 24 Aug 2021 19:51:48 -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=PuRuwB6G; 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 S236992AbhHYCvc (ORCPT + 99 others); Tue, 24 Aug 2021 22:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230021AbhHYCv3 (ORCPT ); Tue, 24 Aug 2021 22:51:29 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D73F6C061757 for ; Tue, 24 Aug 2021 19:50:44 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id n12so2023251plk.10 for ; Tue, 24 Aug 2021 19:50:44 -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=G+VFbxZv56JqJJvHvZfxmdl5/mMwzz6LNS7nJgyEuFg=; b=PuRuwB6GpTZkYLCohD7vc5rbOm294HWMBPOKGiKyMcID0d/cqaUomfm4BIGY/jgOL3 IGabpTvdWyYabHtI4zlkTEsxa3btaZbdtY8jO5jSGxiFSrKVrc7KOS8a7z3HapC8BNcS QGRYo/m43G5PNg6mhJEEn7nooJHKIHnJPb7/Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=G+VFbxZv56JqJJvHvZfxmdl5/mMwzz6LNS7nJgyEuFg=; b=Q2BHGGamOY+5uMymo1VEtpRSF8iOcLo5acs7bgap3HvZR8ko+FVZbTX6BvlSA/mR50 T851il0wZBknVPtfVCrL26AcD019JgijoCEEeRXaaah3C9vzMfnXqiPZ80IW5QwCyOWF WRYu5yzni0P2Tvv6n/9xDkXS3Kkse/8YNyDD7y+589vmmJ/OWeL3ubzVfKIZdS4x+5YS /whK65RFlVTm1akP4GlNgafP7VhO07YQcX4339ewtXbtDuBE/UAL/sFS6CGQb0eg6+N8 sIWgKVFiZuV6t8yidhHeJj006nPMoyIjSR904lJoR0BHaTIQ2yyejdcTe8pIBC+6BXpe hiIw== X-Gm-Message-State: AOAM533SHTqrQcbUlUiT9zEMUTxg6kYLqBkU86MfN0mq+d/nzOAw6mzN E+5auOy5hT694cPBoBHP4/syNw== X-Received: by 2002:a17:90a:b00e:: with SMTP id x14mr7953567pjq.155.1629859844343; Tue, 24 Aug 2021 19:50:44 -0700 (PDT) Received: from localhost ([2401:fa00:8f:203:d273:c78c:fce8:a0e2]) by smtp.gmail.com with UTF8SMTPSA id j6sm20237041pfn.107.2021.08.24.19.50.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Aug 2021 19:50:44 -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 v3 0/4] KVM: allow mapping non-refcounted pages Date: Wed, 25 Aug 2021 11:50:05 +0900 Message-Id: <20210825025009.2081060-1-stevensd@google.com> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-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. 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 | 26 +++-- 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 | 188 +++++++++++++++++++++++--------- 9 files changed, 220 insertions(+), 103 deletions(-) -- 2.33.0.rc2.250.ged5fa647cd-goog