We need to restore PDPE.U=1, similar to what the tests do after printing the "Set SMEP in CR4 - expect #GP: FAIL" message. Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> --- x86/access.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86/access.c b/x86/access.c index a0c19dc..11f561b 100644 --- a/x86/access.c +++ b/x86/access.c @@ -207,7 +207,7 @@ unsigned set_cr4_smep(int smep) if (smep) ptl2[2] &= ~PT_USER_MASK; r = write_cr4_checking(cr4); - if (!smep) + if (r || !smep) ptl2[2] |= PT_USER_MASK; return r; } -- 1.8.3.1