Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5730308imb; Fri, 8 Mar 2019 00:39:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxbWFrpSh32nnQUit/hvBdvc9irdd7dhfdta1hrDGOdZIHxXlUItWoVrsfWZqXG1l2cjC+F X-Received: by 2002:aa7:85d1:: with SMTP id z17mr17070244pfn.226.1552034358011; Fri, 08 Mar 2019 00:39:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552034358; cv=none; d=google.com; s=arc-20160816; b=K4JaV+Ho5JdbqP/4Q0HMWSleglxkK28rm9OQu8TNhUoLKP7/iDRQoAN4bPgPLqgo89 gabAC8AByVrJShue6b0fZyBCbSy6LZmY3POv83bZW7ZhkdJUDalT8tcUdX/BijFpBOyi PqscxaWMnCpi7Vy1xS6y4vXd1k4LUOE3ti3iDjogMxfLjpxB+3NGq1yBqBVP5Y5DGNFj w4DQyNr3tJ7pqpKyo41BgXP0ezx/17bNbDaqHukRMohibfvLogHYijXc2SpOuF3dX+6x lgixbzsNonya/NY4bRiWHd1aur0gltTSoxfeqpn94F0wrgyQ2tQMkXtWsKPZ+AdRxkTm 4S0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=ePhRCP/1RbXIVh3HvW2KjFjjpUVfZZoUSVe3o/osuz8=; b=PM7EN6fcofCufQi58fH8tnpOX8t24Hc/bBaopwFAYc+uQNKkWqqgvLt1Ue/Q+k6hIa l1jUlsQZ+bVsyzZSZ2NLX8DdoEEORORIcAh9c8cUrGRovVQmE6RR6M9REDQF1kTYl9pb bXJNo/6LseKn/07YdNWjpeVvzgdi88OFvK9VVH+IutxvmL+xAZBWIueKVFXmliEMSFHt V55fOzN1+IfsHtrDWB1UD9zY7yUGHT48KJ6u0kEuK4GpZiUx/PFcodPYphjvvOXtVIcn duIyd+llDKRVDwnie9plJrbQ89o1eDXyN80uWbC/CwelWljAOjIEb5UHMljuX/xHF4im OOFQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si6244725pfa.197.2019.03.08.00.39.02; Fri, 08 Mar 2019 00:39:18 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbfCHIiB (ORCPT + 99 others); Fri, 8 Mar 2019 03:38:01 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40320 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725776AbfCHIiB (ORCPT ); Fri, 8 Mar 2019 03:38:01 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x288ZHdX001312 for ; Fri, 8 Mar 2019 03:37:59 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2r3kqbude9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 08 Mar 2019 03:37:59 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Mar 2019 08:37:57 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 8 Mar 2019 08:37:50 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x288bnKj60686356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Mar 2019 08:37:49 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 281C15204F; Fri, 8 Mar 2019 08:37:49 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.204.28]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id EF93D52052; Fri, 8 Mar 2019 08:37:46 +0000 (GMT) Date: Fri, 8 Mar 2019 10:37:45 +0200 From: Mike Rapoport To: Steven Price Cc: linux-mm@kvack.org, Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?iso-8859-1?B?Suly9G1l?= Glisse , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang, Kan" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org Subject: Re: [PATCH v4 04/19] powerpc: mm: Add p?d_large() definitions References: <20190306155031.4291-1-steven.price@arm.com> <20190306155031.4291-5-steven.price@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190306155031.4291-5-steven.price@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19030808-0028-0000-0000-0000035189F9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19030808-0029-0000-0000-0000240FFED7 Message-Id: <20190308083744.GA6592@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-08_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903080062 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 06, 2019 at 03:50:16PM +0000, Steven Price wrote: > walk_page_range() is going to be allowed to walk page tables other than > those of user space. For this it needs to know when it has reached a > 'leaf' entry in the page tables. This information is provided by the > p?d_large() functions/macros. > > For powerpc pmd_large() was already implemented, so hoist it out of the > CONFIG_TRANSPARENT_HUGEPAGE condition and implement the other levels. > > Also since we now have a pmd_large always implemented we can drop the > pmd_is_leaf() function. > > CC: Benjamin Herrenschmidt > CC: Paul Mackerras > CC: Michael Ellerman > CC: linuxppc-dev@lists.ozlabs.org > CC: kvm-ppc@vger.kernel.org > Signed-off-by: Steven Price > --- > arch/powerpc/include/asm/book3s/64/pgtable.h | 30 ++++++++++++++------ There is one more definition of pmd_large() in arch/powerpc/include/asm/pgtable.h > arch/powerpc/kvm/book3s_64_mmu_radix.c | 12 ++------ > 2 files changed, 24 insertions(+), 18 deletions(-) > > diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h > index c9bfe526ca9d..c4b29caf2a3b 100644 > --- a/arch/powerpc/include/asm/book3s/64/pgtable.h > +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h > @@ -907,6 +907,12 @@ static inline int pud_present(pud_t pud) > return (pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT)); > } > > +#define pud_large pud_large > +static inline int pud_large(pud_t pud) > +{ > + return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); > +} > + > extern struct page *pud_page(pud_t pud); > extern struct page *pmd_page(pmd_t pmd); > static inline pte_t pud_pte(pud_t pud) > @@ -954,6 +960,12 @@ static inline int pgd_present(pgd_t pgd) > return (pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT)); > } > > +#define pgd_large pgd_large > +static inline int pgd_large(pgd_t pgd) > +{ > + return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE)); > +} > + > static inline pte_t pgd_pte(pgd_t pgd) > { > return __pte_raw(pgd_raw(pgd)); > @@ -1107,6 +1119,15 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write) > return pte_access_permitted(pmd_pte(pmd), write); > } > > +#define pmd_large pmd_large > +/* > + * returns true for pmd migration entries, THP, devmap, hugetlb > + */ > +static inline int pmd_large(pmd_t pmd) > +{ > + return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > +} > + > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot); > extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot); > @@ -1133,15 +1154,6 @@ pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, > return hash__pmd_hugepage_update(mm, addr, pmdp, clr, set); > } > > -/* > - * returns true for pmd migration entries, THP, devmap, hugetlb > - * But compile time dependent on THP config > - */ > -static inline int pmd_large(pmd_t pmd) > -{ > - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > -} > - > static inline pmd_t pmd_mknotpresent(pmd_t pmd) > { > return __pmd(pmd_val(pmd) & ~_PAGE_PRESENT); > diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c > index 1b821c6efdef..040db20ac2ab 100644 > --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c > +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c > @@ -363,12 +363,6 @@ static void kvmppc_pte_free(pte_t *ptep) > kmem_cache_free(kvm_pte_cache, ptep); > } > > -/* Like pmd_huge() and pmd_large(), but works regardless of config options */ > -static inline int pmd_is_leaf(pmd_t pmd) > -{ > - return !!(pmd_val(pmd) & _PAGE_PTE); > -} > - > static pmd_t *kvmppc_pmd_alloc(void) > { > return kmem_cache_alloc(kvm_pmd_cache, GFP_KERNEL); > @@ -455,7 +449,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t *pmd, bool full, > for (im = 0; im < PTRS_PER_PMD; ++im, ++p) { > if (!pmd_present(*p)) > continue; > - if (pmd_is_leaf(*p)) { > + if (pmd_large(*p)) { > if (full) { > pmd_clear(p); > } else { > @@ -588,7 +582,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte, > else if (level <= 1) > new_pmd = kvmppc_pmd_alloc(); > > - if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_is_leaf(*pmd))) > + if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_large(*pmd))) > new_ptep = kvmppc_pte_alloc(); > > /* Check if we might have been invalidated; let the guest retry if so */ > @@ -657,7 +651,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte, > new_pmd = NULL; > } > pmd = pmd_offset(pud, gpa); > - if (pmd_is_leaf(*pmd)) { > + if (pmd_large(*pmd)) { > unsigned long lgpa = gpa & PMD_MASK; > > /* Check if we raced and someone else has set the same thing */ > -- > 2.20.1 > -- Sincerely yours, Mike.