Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp5109199pxb; Tue, 28 Sep 2021 10:41:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeW1/aHuitYt8+4Wex377ElPtZW0IWsheuCR4UiOe+m61HNEYEM75PVbycVpkVCYSXmDuJ X-Received: by 2002:a17:902:6e0f:b0:13c:9d43:7d7a with SMTP id u15-20020a1709026e0f00b0013c9d437d7amr6385308plk.62.1632850911003; Tue, 28 Sep 2021 10:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632850910; cv=none; d=google.com; s=arc-20160816; b=myo9T8YSCIf/E4JEucsNdbb2atu2ICuRBGZQ4vEaB6q+8PhfXXpYLcm/EZJxiSP5q2 4BZtqZFmbndXt4EpKbVhifyzpvz92tt3qOTF6XapopYQMjQO45+ggcMd6as1kkweExp8 Zxfr6nqBL6AHKQDMqdrhx/4bvT0wEH9LiuleZIdURzsdYz8DsSYSqVuGurRbF9nopRmA /GzL+YxvaW0RQj49Tud2tc1tDIx+aa7xzbtiaEhlWsrD8gRngkQRbDo4Y9DaDxs+JwV1 rn1PNfowsug4Pgh65j4SVrT5rWPKCsqJPfT0CbZwkJ9nYtSfRdWDNltZNwAM6sPK9g2u e6JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=i/mLExJpGEltWuxQX4FZe3M+4GoSDCEzgPhBEr5FMEA=; b=0u7hb+88ktoJOT15Ich0VdAIHN1uvFr17JlTpeQcW5YcI4UIpsSWVYJbt8eohMDOB8 X+8mK3uIkP35cZqW2NrLfmt1ZlQuUSsXCpVgaUm2CdaqvOF4E7n+FvaKWr2/HLWx0ryg NgLa0lVwbnDObOYQDIlgK3hjxFbg2Nn8cREXbmkQSDHCYwwrRsbI87eqn37484rqODkj mksw14jtEFiVh8D74Es5WPY4d+X/+2z+BW8DqiYVHlVI9b6uSyyjQNVYGQ4eX6RHBCs9 g4aMSmLGCrQA5qT1U2mRg2cFHse66K2t4h/Xm034/dfd9RSThteCWVszGFFaQ72YAMUk 9cKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eDKUMRN6; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t40si16067100pfg.334.2021.09.28.10.41.25; Tue, 28 Sep 2021 10:41:50 -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=@redhat.com header.s=mimecast20190719 header.b=eDKUMRN6; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242239AbhI1RmQ (ORCPT + 99 others); Tue, 28 Sep 2021 13:42:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35367 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242202AbhI1RmQ (ORCPT ); Tue, 28 Sep 2021 13:42:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632850836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i/mLExJpGEltWuxQX4FZe3M+4GoSDCEzgPhBEr5FMEA=; b=eDKUMRN6BkhN+Eve4uu+X6/Wjg2AAbS1BrpkZA2hqlmxdUHBKA09wDjy/TN7CZGQ3lp6bd UYhF0b9Rw79j+HKbs7T2Y84l+Q71TY3GB+ekNy9cwvFShgmTWzDUPJY9BuBeJEhdihmpvz M+ruup6NTszz9tcw9eU4tAZIyj4jI20= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-wGEJYakTOOuep1qZAwcWKQ-1; Tue, 28 Sep 2021 13:40:34 -0400 X-MC-Unique: wGEJYakTOOuep1qZAwcWKQ-1 Received: by mail-ed1-f69.google.com with SMTP id z6-20020a50cd06000000b003d2c2e38f1fso22676865edi.1 for ; Tue, 28 Sep 2021 10:40:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=i/mLExJpGEltWuxQX4FZe3M+4GoSDCEzgPhBEr5FMEA=; b=iUDu2DAix78V/btMDuqyjYAORZBDkfKkhDBq8hpcujFmw529//dD47odm86PXZNlaE 0naMq84/UMCrNGf7YzVyD6iIw8VZnFJqSOEjHN14P0cP6cNlJG3a5/RsxD1jC3xld0cF 46jTUpZDtsj4Z3abIFGFD2gupTUdQ8bavLbdTSqZEmtaqWufMMf7hctDJT3sJBYNVRZK ThYEp+5D2IwjBL6j5qu3TWlJCdAWf5iJjKQGI/ugkmxDcqUj1JywiwayTffcEQDcIekb jz08NxMDb0qQ5PiGRbIzASpZMbY5vB8TPueEimxRNIdOFA5elWASempQ2KKdfkWKTP1k 1W5w== X-Gm-Message-State: AOAM530TX7XFOmftw8qzLaeqVIxJXTXItqLv7qGnSwgW9giCgm4ENjFD C0m01+wBR2Ly9CzsaSXFpGoD5UGoD9HNEGx58AbguPGQ1ctc1WNVekWeP7xoeQlHXmriu5ondGZ 1dhn0Nm0zwljuG6LpLqGDNJ2z X-Received: by 2002:a05:6402:54d:: with SMTP id i13mr9049823edx.389.1632850833768; Tue, 28 Sep 2021 10:40:33 -0700 (PDT) X-Received: by 2002:a05:6402:54d:: with SMTP id i13mr9049801edx.389.1632850833583; Tue, 28 Sep 2021 10:40:33 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id y3sm13952710eda.9.2021.09.28.10.40.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Sep 2021 10:40:32 -0700 (PDT) Message-ID: Date: Tue, 28 Sep 2021 19:40:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH v3 0/4] KVM: allow mapping non-refcounted pages Content-Language: en-US To: David Stevens , Marc Zyngier 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 References: <20210825025009.2081060-1-stevensd@google.com> From: Paolo Bonzini In-Reply-To: <20210825025009.2081060-1-stevensd@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/08/21 04:50, David Stevens wrote: > 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 Hi David, this needs a rebase. I have pushed my current queue, but note that parts of it are still untested. A bigger question here is the gfn_to_pfn caches and how to properly invalidate them. However your patch doesn't make things worse (only a bit inconsistent because pointing certain MSRs to a VM_PFNMAP|VM_IO page can fail). Paolo > 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(-) >