Received: by 10.223.164.202 with SMTP id h10csp1541704wrb; Wed, 15 Nov 2017 23:19:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMZIjnK9y70rudGGYOJ9gBoGFjcp8D7qRYTMVqyCiaOIXTIMPc8GQ2cl/8ycKIWxZAXqoEOE X-Received: by 10.84.224.75 with SMTP id a11mr751806plt.421.1510816783044; Wed, 15 Nov 2017 23:19:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510816782; cv=none; d=google.com; s=arc-20160816; b=e//J3AvQ5ni3oR+koE80wpaRiJhAnnUy/kY7qosHKoQrV7/CN0OaOwVvkArj+h48SR 49SuUWzj5asuquiL0A+jO8kglBTsj7YHI80Wh0pvrggClCYZHkFcpqxpiipgnEJdoasJ p2Vr9pRAJ0gkxTyeAKaGz3+g0XRHzHnKlTd/bkTzDyYK/Q9cYhY7t/ceawxx9SZCxP8R bMfFgMgjpSDhWpgQvT7XwX2ZCU/6oj+TJmtaB2IcIQy8tPlx04AaHAN5V/ZWwAFltF9Z aj36srTTt7Jd1hWoqzo7kRIhgxcIrAC/OvAUFr9qquHg+rwd4gE3yXIWLgtVAcGWvPTd KXfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:arc-authentication-results; bh=dmaAbpReF/uxIquENyfvnWW7MARfuPSZ9uwaATHnZFM=; b=WKlXF9FqZFUGmI7WHQg1GmbE2nTOWTAiraFnxdEmFO1dglvFQ3RQSA7uzyYLAZgtqK NkUTajZqZGp7xr3Lzolw0OmbKBz95SFOrBgot6/AZQVliN3Gm9casLf2B/2GcfUsAHdb 2Hq+K3LG2THlT6gXZE8qWnwXc5QJQwyF2zMW3KJyq3b12thYKJEnHlAJpPTyu+9Cdgoo eUx5uumxxdHwqkHsrzjgA8NnbSBhMZMG/B1nNv0pJAH7L1lZhC5Fekt4Endgn8csNW5z jrcLFJZOMfbSTgeQZIideM5JKxlrblkpUhg3Hl5yqfbf12FCi66EOuQmoo8gx4muQ4E9 Wn9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w34si399651pla.356.2017.11.15.23.19.30; Wed, 15 Nov 2017 23:19:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758268AbdKPGMr (ORCPT + 91 others); Thu, 16 Nov 2017 01:12:47 -0500 Received: from mga09.intel.com ([134.134.136.24]:1933 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751455AbdKPGMj (ORCPT ); Thu, 16 Nov 2017 01:12:39 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2017 22:12:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,402,1505804400"; d="scan'208";a="2394330" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by FMSMGA003.fm.intel.com with ESMTP; 15 Nov 2017 22:12:35 -0800 Date: Thu, 16 Nov 2017 14:13:00 +0800 From: Haozhong Zhang To: Dan Williams Cc: KVM list , X86 ML , "linux-kernel@vger.kernel.org" , Paolo Bonzini , rkrcmar@redhat.com, Xiao Guangrong , "Cuevas Escareno, Ivan D" , "Kumar, Karthik" , Konrad Rzeszutek Wilk , Olif Chapman , Mikulas Patocka , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Tom Lendacky Subject: Re: [PATCH v5 1/2] x86/mm: add a function to check if a pfn is UC/UC- Message-ID: <20171116061300.52vlwdoxmf6l4mqh@hz-desktop> Mail-Followup-To: Dan Williams , KVM list , X86 ML , "linux-kernel@vger.kernel.org" , Paolo Bonzini , rkrcmar@redhat.com, Xiao Guangrong , "Cuevas Escareno, Ivan D" , "Kumar, Karthik" , Konrad Rzeszutek Wilk , Olif Chapman , Mikulas Patocka , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Tom Lendacky References: <20171108075630.16991-1-haozhong.zhang@intel.com> <20171108075630.16991-2-haozhong.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170714 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/15/17 07:17 -0800, Dan Williams wrote: > On Tue, Nov 7, 2017 at 11:56 PM, Haozhong Zhang > wrote: > > It will be used by KVM to check whether a pfn should be > > mapped to guest as UC. > > > > Signed-off-by: Haozhong Zhang > > --- > > arch/x86/include/asm/pat.h | 2 ++ > > arch/x86/mm/pat.c | 16 ++++++++++++++++ > > 2 files changed, 18 insertions(+) > > > > diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h > > index fffb2794dd89..fabb0cf00e77 100644 > > --- a/arch/x86/include/asm/pat.h > > +++ b/arch/x86/include/asm/pat.h > > @@ -21,4 +21,6 @@ int io_reserve_memtype(resource_size_t start, resource_size_t end, > > > > void io_free_memtype(resource_size_t start, resource_size_t end); > > > > +bool pat_pfn_is_uc_or_uc_minus(unsigned long pfn); > > + > > #endif /* _ASM_X86_PAT_H */ > > diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c > > index fe7d57a8fb60..e1282dd4eeb8 100644 > > --- a/arch/x86/mm/pat.c > > +++ b/arch/x86/mm/pat.c > > @@ -677,6 +677,22 @@ static enum page_cache_mode lookup_memtype(u64 paddr) > > return rettype; > > } > > > > +/** > > + * Check with PAT whether the memory type of a pfn is UC or UC-. > > + * > > + * Only to be called when PAT is enabled. > > + * > > + * Returns true, if the memory type of @pfn is UC or UC-. > > + * Otherwise, returns false. > > + */ > > +bool pat_pfn_is_uc_or_uc_minus(unsigned long pfn) > > +{ > > + enum page_cache_mode cm = lookup_memtype(PFN_PHYS(pfn)); > > + > > + return cm == _PAGE_CACHE_MODE_UC || cm == _PAGE_CACHE_MODE_UC_MINUS; > > +} > > +EXPORT_SYMBOL_GPL(pat_pfn_is_uc_or_uc_minus); > > Why do we need this strangely named new accessor? It seems to be > open-coding a new / more limited version of track_pfn_insert(). In the first version patchset, KVM did extract and check the cache mode got from track_pfn_insert(), but Ingo thought it was better to keep all the low-level details out of KVM, so I encapsulated them in a function in mm in subsequent versions. Haozhong From 1584146139205923007@xxx Wed Nov 15 15:24:46 +0000 2017 X-GM-THRID: 1583483967361382783 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread