mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-29 18:34:15 +00:00
Some alternatives associated with a specific feature need to be treated in a special way. Since the features and how to treat them vary from one architecture to another, move the special case handling to arch specific code. Reviewed-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Julien Thierry <jthierry@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
37 lines
966 B
C
37 lines
966 B
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#include "../../special.h"
|
|
#include "../../builtin.h"
|
|
|
|
#define X86_FEATURE_POPCNT (4 * 32 + 23)
|
|
#define X86_FEATURE_SMAP (9 * 32 + 20)
|
|
|
|
void arch_handle_alternative(unsigned short feature, struct special_alt *alt)
|
|
{
|
|
switch (feature) {
|
|
case X86_FEATURE_SMAP:
|
|
/*
|
|
* If UACCESS validation is enabled; force that alternative;
|
|
* otherwise force it the other way.
|
|
*
|
|
* What we want to avoid is having both the original and the
|
|
* alternative code flow at the same time, in that case we can
|
|
* find paths that see the STAC but take the NOP instead of
|
|
* CLAC and the other way around.
|
|
*/
|
|
if (uaccess)
|
|
alt->skip_orig = true;
|
|
else
|
|
alt->skip_alt = true;
|
|
break;
|
|
case X86_FEATURE_POPCNT:
|
|
/*
|
|
* It has been requested that we don't validate the !POPCNT
|
|
* feature path which is a "very very small percentage of
|
|
* machines".
|
|
*/
|
|
alt->skip_orig = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|