android_kernel_samsung_univ.../include/linux/kaiser.h
Arnd Bergmann 4b35dcb5e0 x86: fix build warnign with 32-bit PAE
I ran into a 4.9 build warning in randconfig testing, starting with the
KAISER patches:

arch/x86/kernel/ldt.c: In function 'alloc_ldt_struct':
arch/x86/include/asm/pgtable_types.h:208:24: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
 #define __PAGE_KERNEL  (__PAGE_KERNEL_EXEC | _PAGE_NX)
                        ^
arch/x86/kernel/ldt.c:81:6: note: in expansion of macro '__PAGE_KERNEL'
      __PAGE_KERNEL);
      ^~~~~~~~~~~~~

I originally ran into this last year when the patches were part of linux-next,
and tried to work around it by using the proper 'pteval_t' types consistently,
but that caused additional problems.

This takes a much simpler approach, and makes the argument type of the dummy
helper always 64-bit, which is wide enough for any page table layout and
won't hurt since this call is just an empty stub anyway.

Fixes: 8f0baadf2bea ("kaiser: merged update")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-22 15:45:01 +01:00

53 lines
1.2 KiB
C

#ifndef _LINUX_KAISER_H
#define _LINUX_KAISER_H
#ifdef CONFIG_PAGE_TABLE_ISOLATION
#include <asm/kaiser.h>
static inline int kaiser_map_thread_stack(void *stack)
{
/*
* Map that page of kernel stack on which we enter from user context.
*/
return kaiser_add_mapping((unsigned long)stack +
THREAD_SIZE - PAGE_SIZE, PAGE_SIZE, __PAGE_KERNEL);
}
static inline void kaiser_unmap_thread_stack(void *stack)
{
/*
* Note: may be called even when kaiser_map_thread_stack() failed.
*/
kaiser_remove_mapping((unsigned long)stack +
THREAD_SIZE - PAGE_SIZE, PAGE_SIZE);
}
#else
/*
* These stubs are used whenever CONFIG_PAGE_TABLE_ISOLATION is off, which
* includes architectures that support KAISER, but have it disabled.
*/
static inline void kaiser_init(void)
{
}
static inline int kaiser_add_mapping(unsigned long addr,
unsigned long size, u64 flags)
{
return 0;
}
static inline void kaiser_remove_mapping(unsigned long start,
unsigned long size)
{
}
static inline int kaiser_map_thread_stack(void *stack)
{
return 0;
}
static inline void kaiser_unmap_thread_stack(void *stack)
{
}
#endif /* !CONFIG_PAGE_TABLE_ISOLATION */
#endif /* _LINUX_KAISER_H */