https://github.com/torvalds/linux
Revision 49275fef986abfb8b476e4708aaecc07e7d3e087 authored by Andy Lutomirski on 11 December 2017, 06:47:19 UTC, committed by Ingo Molnar on 22 December 2017, 19:13:01 UTC
The kernel is very erratic as to which pagetables have _PAGE_USER set.  The
vsyscall page gets lucky: it seems that all of the relevant pagetables are
among the apparently arbitrary ones that set _PAGE_USER.  Rather than
relying on chance, just explicitly set _PAGE_USER.

This will let us clean up pagetable setup to stop setting _PAGE_USER.  The
added code can also be reused by pagetable isolation to manage the
_PAGE_USER bit in the usermode tables.

[ tglx: Folded paravirt fix from Juergen Gross ]

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Laight <David.Laight@aculab.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 146122e
Raw File
Tip revision: 49275fef986abfb8b476e4708aaecc07e7d3e087 authored by Andy Lutomirski on 11 December 2017, 06:47:19 UTC
x86/vsyscall/64: Explicitly set _PAGE_USER in the pagetable hierarchy
Tip revision: 49275fe
clz_ctz.c
/*
 * lib/clz_ctz.c
 *
 * Copyright (C) 2013 Chanho Min <chanho.min@lge.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 * The functions in this file aren't called directly, but are required by
 * GCC builtins such as __builtin_ctz, and therefore they can't be removed
 * despite appearing unreferenced in kernel source.
 *
 * __c[lt]z[sd]i2 can be overridden by linking arch-specific versions.
 */

#include <linux/export.h>
#include <linux/kernel.h>

int __weak __ctzsi2(int val);
int __weak __ctzsi2(int val)
{
	return __ffs(val);
}
EXPORT_SYMBOL(__ctzsi2);

int __weak __clzsi2(int val);
int __weak __clzsi2(int val)
{
	return 32 - fls(val);
}
EXPORT_SYMBOL(__clzsi2);

int __weak __clzdi2(long val);
int __weak __ctzdi2(long val);
#if BITS_PER_LONG == 32

int __weak __clzdi2(long val)
{
	return 32 - fls((int)val);
}
EXPORT_SYMBOL(__clzdi2);

int __weak __ctzdi2(long val)
{
	return __ffs((u32)val);
}
EXPORT_SYMBOL(__ctzdi2);

#elif BITS_PER_LONG == 64

int __weak __clzdi2(long val)
{
	return 64 - fls64((u64)val);
}
EXPORT_SYMBOL(__clzdi2);

int __weak __ctzdi2(long val)
{
	return __ffs64((u64)val);
}
EXPORT_SYMBOL(__ctzdi2);

#else
#error BITS_PER_LONG not 32 or 64
#endif
back to top