[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210426063134.jvanqz7b3nfpwayg@box.shutemov.name>
Date: Mon, 26 Apr 2021 09:31:34 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: Yu-cheng Yu <yu-cheng.yu@...el.com>
Cc: x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, linux-mm@...ck.org,
linux-arch@...r.kernel.org, linux-api@...r.kernel.org,
Arnd Bergmann <arnd@...db.de>,
Andy Lutomirski <luto@...nel.org>,
Balbir Singh <bsingharora@...il.com>,
Borislav Petkov <bp@...en8.de>,
Cyrill Gorcunov <gorcunov@...il.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Eugene Syromiatnikov <esyr@...hat.com>,
Florian Weimer <fweimer@...hat.com>,
"H.J. Lu" <hjl.tools@...il.com>, Jann Horn <jannh@...gle.com>,
Jonathan Corbet <corbet@....net>,
Kees Cook <keescook@...omium.org>,
Mike Kravetz <mike.kravetz@...cle.com>,
Nadav Amit <nadav.amit@...il.com>,
Oleg Nesterov <oleg@...hat.com>, Pavel Machek <pavel@....cz>,
Peter Zijlstra <peterz@...radead.org>,
Randy Dunlap <rdunlap@...radead.org>,
"Ravi V. Shankar" <ravi.v.shankar@...el.com>,
Vedvyas Shanbhogue <vedvyas.shanbhogue@...el.com>,
Dave Martin <Dave.Martin@....com>,
Weijiang Yang <weijiang.yang@...el.com>,
Pengfei Xu <pengfei.xu@...el.com>,
Haitao Huang <haitao.huang@...el.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH v25 28/30] mm: Move arch_calc_vm_prot_bits() to
arch/x86/include/asm/mman.h
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 <yu-cheng.yu@...el.com>
> Reviewed-by: Kees Cook <keescook@...omium.org>
> Cc: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> ---
> 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 <linux/mm.h>
> +#include <uapi/asm/mman.h>
> +
> +#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 <kirill.shutemov@...ux.intel.com>
> #include <asm-generic/mman.h>
>
> -#endif /* _ASM_X86_MMAN_H */
> +#endif /* _UAPI_ASM_X86_MMAN_H */
> --
> 2.21.0
>
>
--
Kirill A. Shutemov
Powered by blists - more mailing lists