@@ -20,9 +20,6 @@ static int invalid_mask;
#define PT_BASE_ADDR_MASK ((pt_element_t)((((pt_element_t)1 << 36) - 1) & PAGE_MASK))
#define PT_PSE_BASE_ADDR_MASK (PT_BASE_ADDR_MASK & ~(1ull << 21))
-#define CR0_WP_MASK (1UL << 16)
-#define CR4_SMEP_MASK (1UL << 20)
-
#define PFERR_PRESENT_MASK (1U << 0)
#define PFERR_WRITE_MASK (1U << 1)
#define PFERR_USER_MASK (1U << 2)
@@ -239,9 +236,9 @@ static void set_cr0_wp(int wp)
{
unsigned long cr0 = shadow_cr0;
- cr0 &= ~CR0_WP_MASK;
+ cr0 &= ~X86_CR0_WP;
if (wp)
- cr0 |= CR0_WP_MASK;
+ cr0 |= X86_CR0_WP;
if (cr0 != shadow_cr0) {
write_cr0(cr0);
shadow_cr0 = cr0;
@@ -272,9 +269,9 @@ static unsigned set_cr4_smep(ac_test_t *at, int smep)
unsigned long cr4 = shadow_cr4;
unsigned r;
- cr4 &= ~CR4_SMEP_MASK;
+ cr4 &= ~X86_CR4_SMEP;
if (smep)
- cr4 |= CR4_SMEP_MASK;
+ cr4 |= X86_CR4_SMEP;
if (cr4 == shadow_cr4)
return 0;
@@ -5,7 +5,6 @@
#include "x86/vm.h"
#include "x86/msr.h"
-#define CR0_WP_MASK (1UL << 16)
#define PTE_PKEY_BIT 59
#define SUPER_BASE (1 << 23)
#define SUPER_VAR(v) (*((__typeof__(&(v))) (((unsigned long)&v) + SUPER_BASE)))
@@ -18,9 +17,9 @@ static void set_cr0_wp(int wp)
{
unsigned long cr0 = read_cr0();
- cr0 &= ~CR0_WP_MASK;
+ cr0 &= ~X86_CR0_WP;
if (wp)
- cr0 |= CR0_WP_MASK;
+ cr0 |= X86_CR0_WP;
write_cr0(cr0);
}
@@ -5,7 +5,6 @@
#include "x86/vm.h"
#include "x86/msr.h"
-#define CR0_WP_MASK (1UL << 16)
#define PTE_PKEY_BIT 59
#define USER_BASE (1 << 23)
#define USER_VAR(v) (*((__typeof__(&(v))) (((unsigned long)&v) + USER_BASE)))
@@ -18,9 +17,9 @@ static void set_cr0_wp(int wp)
{
unsigned long cr0 = read_cr0();
- cr0 &= ~CR0_WP_MASK;
+ cr0 &= ~X86_CR0_WP;
if (wp)
- cr0 |= CR0_WP_MASK;
+ cr0 |= X86_CR0_WP;
write_cr0(cr0);
}
Use the existing bit definitions from x86/processor.h instead of defining one-off versions in individual tests. Signed-off-by: Mathias Krause <minipli@grsecurity.net> --- x86/access.c | 11 ++++------- x86/pks.c | 5 ++--- x86/pku.c | 5 ++--- 3 files changed, 8 insertions(+), 13 deletions(-)