From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E816C433ED for ; Mon, 26 Apr 2021 06:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E90626008E for ; Mon, 26 Apr 2021 06:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231939AbhDZGcP (ORCPT ); Mon, 26 Apr 2021 02:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231907AbhDZGcO (ORCPT ); Mon, 26 Apr 2021 02:32:14 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C363C06175F for ; Sun, 25 Apr 2021 23:31:33 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 4so26687708lfp.11 for ; Sun, 25 Apr 2021 23:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Kc8jqGhH/i/p+4zlWWcYzH0ChU/St4I0f5Kj38coM28=; b=ea1DMqRjyF1ClzXaKHMM0Z9eX6h5DFcL3hRzk2eCDRy/Ifo94Vugt7WwKUVt/pgzB6 Ts2xfzV3ITD4iy+zLFdec/huDftVxl3DH/3ceQHbAuweThMwKQs6kPkCG8huUR7R2sMP HFyNCBke+lD8sNWbn2FOY2iO590B51S0xxShGn77Od+PgvC9j6ABRgsFYWSqQlyKua5y SfTnh16O9CZZZjpXQCTHqkHLrOfIm1dFaBG0ho7el8283nr+VITUQnmTviMiHTQ6zjR9 R58quTJq2r6It/sq8BwbD0qcH7Oq++rc+ML6P87vxKIYvXieXTOcsOmZkuyOyEHeqEqn XpDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Kc8jqGhH/i/p+4zlWWcYzH0ChU/St4I0f5Kj38coM28=; b=PeSLGhPYtsCT4mOr1KGtPYxnH4CeachhyLDCsPYvU0Udz14Ms35uJjtxqUIDViQjvK kxb1Ztw0KNMWN564U1Kqo+mTOWnCoUbz8Vv6LQNoFT2Ln0QFIXysg1yXztLvcxFCzUbr ha2nPe2MnEPhtHHL00HRDTIK03gTVJQdTjnzM+Li0EWOQhPCQw/WFIi+79bv1cI/vyEl L4WBXhz6UhqhMOPSmJ+mmscVIj4Eo4ZJeWmINFY+pTJJ0qn62z41DQYgl1yA79x3tqHR TL0xFzGjuHNdCQzE2Fzk2eko1+grbmtrx0QMXt91GWlAvGgp/mLN6Kx6AdUiojgs7bZZ ZHgw== X-Gm-Message-State: AOAM532XY386ADiCnW9LBL/kCnq1Y+4dYIMshGI0dDyWkKL6z4dLSxfC FtvJFPQsp+0rHiOEGBjoFtI31Q== X-Google-Smtp-Source: ABdhPJwuKmHWKe78Ra3S1nRhqGYoyQaGIDPMrykQP/oSt9wVx1sOW2E55k0v8y5JqHL0ArYKyqfy9A== X-Received: by 2002:ac2:5e6b:: with SMTP id a11mr11636367lfr.513.1619418691736; Sun, 25 Apr 2021 23:31:31 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id x19sm1409635ljh.50.2021.04.25.23.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Apr 2021 23:31:31 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id A84621026AB; Mon, 26 Apr 2021 09:31:34 +0300 (+03) Date: Mon, 26 Apr 2021 09:31:34 +0300 From: "Kirill A. Shutemov" To: Yu-cheng Yu Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang , "Kirill A . Shutemov" Subject: Re: [PATCH v25 28/30] mm: Move arch_calc_vm_prot_bits() to arch/x86/include/asm/mman.h Message-ID: <20210426063134.jvanqz7b3nfpwayg@box.shutemov.name> References: <20210415221419.31835-1-yu-cheng.yu@intel.com> <20210415221419.31835-29-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210415221419.31835-29-yu-cheng.yu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Thu, Apr 15, 2021 at 03:14:17PM -0700, Yu-cheng Yu wrote: > To prepare the introduction of PROT_SHSTK and be consistent with other > architectures, move arch_vm_get_page_prot() and arch_calc_vm_prot_bits() to > arch/x86/include/asm/mman.h. > > Signed-off-by: Yu-cheng Yu > Reviewed-by: Kees Cook > Cc: Kirill A. Shutemov > --- > arch/x86/include/asm/mman.h | 30 ++++++++++++++++++++++++++++++ > arch/x86/include/uapi/asm/mman.h | 27 +++------------------------ > 2 files changed, 33 insertions(+), 24 deletions(-) > create mode 100644 arch/x86/include/asm/mman.h > > diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h > new file mode 100644 > index 000000000000..629f6c81263a > --- /dev/null > +++ b/arch/x86/include/asm/mman.h > @@ -0,0 +1,30 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_X86_MMAN_H > +#define _ASM_X86_MMAN_H > + > +#include > +#include > + > +#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS > +/* > + * Take the 4 protection key bits out of the vma->vm_flags > + * value and turn them in to the bits that we can put in > + * to a pte. > + * > + * Only override these if Protection Keys are available > + * (which is only on 64-bit). > + */ > +#define arch_vm_get_page_prot(vm_flags) __pgprot( \ > + ((vm_flags) & VM_PKEY_BIT0 ? _PAGE_PKEY_BIT0 : 0) | \ > + ((vm_flags) & VM_PKEY_BIT1 ? _PAGE_PKEY_BIT1 : 0) | \ > + ((vm_flags) & VM_PKEY_BIT2 ? _PAGE_PKEY_BIT2 : 0) | \ > + ((vm_flags) & VM_PKEY_BIT3 ? _PAGE_PKEY_BIT3 : 0)) > + > +#define arch_calc_vm_prot_bits(prot, key) ( \ > + ((key) & 0x1 ? VM_PKEY_BIT0 : 0) | \ > + ((key) & 0x2 ? VM_PKEY_BIT1 : 0) | \ > + ((key) & 0x4 ? VM_PKEY_BIT2 : 0) | \ > + ((key) & 0x8 ? VM_PKEY_BIT3 : 0)) > +#endif > + > +#endif /* _ASM_X86_MMAN_H */ > diff --git a/arch/x86/include/uapi/asm/mman.h b/arch/x86/include/uapi/asm/mman.h > index d4a8d0424bfb..3ce1923e6ed9 100644 > --- a/arch/x86/include/uapi/asm/mman.h > +++ b/arch/x86/include/uapi/asm/mman.h > @@ -1,31 +1,10 @@ > /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > -#ifndef _ASM_X86_MMAN_H > -#define _ASM_X86_MMAN_H > +#ifndef _UAPI_ASM_X86_MMAN_H > +#define _UAPI_ASM_X86_MMAN_H > > #define MAP_32BIT 0x40 /* only give out 32bit addresses */ > > -#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS > -/* > - * Take the 4 protection key bits out of the vma->vm_flags > - * value and turn them in to the bits that we can put in > - * to a pte. > - * > - * Only override these if Protection Keys are available > - * (which is only on 64-bit). > - */ > -#define arch_vm_get_page_prot(vm_flags) __pgprot( \ > - ((vm_flags) & VM_PKEY_BIT0 ? _PAGE_PKEY_BIT0 : 0) | \ > - ((vm_flags) & VM_PKEY_BIT1 ? _PAGE_PKEY_BIT1 : 0) | \ > - ((vm_flags) & VM_PKEY_BIT2 ? _PAGE_PKEY_BIT2 : 0) | \ > - ((vm_flags) & VM_PKEY_BIT3 ? _PAGE_PKEY_BIT3 : 0)) > - > -#define arch_calc_vm_prot_bits(prot, key) ( \ > - ((key) & 0x1 ? VM_PKEY_BIT0 : 0) | \ > - ((key) & 0x2 ? VM_PKEY_BIT1 : 0) | \ > - ((key) & 0x4 ? VM_PKEY_BIT2 : 0) | \ > - ((key) & 0x8 ? VM_PKEY_BIT3 : 0)) > -#endif > Looks like you leave two empty lines here. Otherwise: Reviewed-by: Kirill A. Shutemov > #include > > -#endif /* _ASM_X86_MMAN_H */ > +#endif /* _UAPI_ASM_X86_MMAN_H */ > -- > 2.21.0 > > -- Kirill A. Shutemov