From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753390AbcGDIZY (ORCPT ); Mon, 4 Jul 2016 04:25:24 -0400 Received: from mga09.intel.com ([134.134.136.24]:14037 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750895AbcGDIZX (ORCPT ); Mon, 4 Jul 2016 04:25:23 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,574,1459839600"; d="scan'208";a="1015130407" Subject: Re: [PATCH 0/2] KVM: MMU: support VMAs that got remap_pfn_range-ed To: Paolo Bonzini , Neo Jia References: <1467291711-3230-1-git-send-email-pbonzini@redhat.com> <577A049A.4000402@linux.intel.com> <20160704070314.GA13291@nvidia.com> <577A123F.1060909@linux.intel.com> <8ff54c7b-2e64-4503-03f6-1a858d9d5746@redhat.com> <577A1765.6080606@linux.intel.com> Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Kirti Wankhede , Andrea Arcangeli , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= From: Xiao Guangrong Message-ID: <577A1C93.3010204@linux.intel.com> Date: Mon, 4 Jul 2016 16:21:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/04/2016 04:14 PM, Paolo Bonzini wrote: > > > On 04/07/2016 09:59, Xiao Guangrong wrote: >> >>> But apart from this, it's much more obvious to consider the refcount. >>> The x86 MMU code doesn't care if the page is reserved or not; >>> mmu_set_spte does a kvm_release_pfn_clean, hence it makes sense for >>> hva_to_pfn_remapped to try doing a get_page (via kvm_get_pfn) after >>> invoking the fault handler, just like the get_user_pages family of >>> function does. >> >> Well, it's little strange as you always try to get refcont >> for a PFNMAP region without MIXEDMAP which indicates all the memory >> in this region is no 'struct page' backend. > > Fair enough, I can modify the comment. > > /* > * In case the VMA has VM_MIXEDMAP set, whoever called remap_pfn_range > * is also going to call e.g. unmap_mapping_range before the underlying > * non-reserved pages are freed, which will then call our MMU notifier. > * We still have to get a reference here to the page, because the callers > * of *hva_to_pfn* and *gfn_to_pfn* ultimately end up doing a > * kvm_release_pfn_clean on the returned pfn. If the pfn is > * reserved, the kvm_get_pfn/kvm_release_pfn_clean pair will simply > * do nothing. > */ > Excellent. I like it. :)