Lines Matching +full:tf +full:- +full:a
1 // SPDX-License-Identifier: GPL-2.0-only
3 * single_step_syscall.c - single-steps various x86 syscalls
4 * Copyright (c) 2014-2015 Andrew Lutomirski
6 * This is a very simple series of tests that makes system calls with
7 * the TF flag set. This exercises some nasty kernel code in the
8 * SYSENTER case: SYSENTER does not clear TF, so SYSENTER with TF set
78 printf("[WARN]\tSIGTRAP handler had TF set\n"); in sigtrap()
87 (unsigned long)info->si_addr, in sigtrap()
88 (unsigned long)ctx->uc_mcontext.gregs[REG_IP]); in sigtrap()
103 printf("\tGot %s with RIP=%lx, TF=%ld\n", signames[sig], in print_and_longjmp()
104 (unsigned long)ctx->uc_mcontext.gregs[REG_IP], in print_and_longjmp()
105 (unsigned long)ctx->uc_mcontext.gregs[REG_EFL] & X86_EFLAGS_TF); in print_and_longjmp()
107 sig_eflags = (unsigned long)ctx->uc_mcontext.gregs[REG_EFL]; in print_and_longjmp()
126 printf("[OK]\tSurvived with TF set and %d traps\n", (int)sig_traps); in check_result()
133 printf("[RUN]\tFast syscall with TF cleared\n"); in fast_syscall_no_tf()
134 fflush(stdout); /* Force a syscall */ in fast_syscall_no_tf()
154 printf("[RUN]\tSet TF and check nop\n"); in main()
160 printf("[RUN]\tSet TF and check syscall-less opportunistic sysret\n"); in main()
171 printf("[RUN]\tSet TF and check int80\n"); in main()
173 asm volatile ("int $0x80" : "=a" (tmp) : "a" (SYS_getpid) in main()
180 * SYSENTER: it triggers a nasty design flaw in SYSENTER. in main()
181 * Specifically, SYSENTER does not clear TF, so either SYSENTER in main()
184 * get a CPL0 fault with usergs (on 64-bit kernels) and possibly in main()
186 * it is to clear TF on return from the #DB handler, but this in main()
187 * happens way too early to set TF in the saved pt_regs, so the in main()
189 * the TF bit. in main()
193 syscall(SYS_getpid); /* Force symbol binding without TF set. */ in main()
194 printf("[RUN]\tSet TF and check a fast syscall\n"); in main()
199 /* Now make sure that another fast syscall doesn't set TF again. */ in main()
203 * And do a forced SYSENTER to make sure that this works even if in main()
211 printf("[RUN]\tSet TF and check SYSENTER\n"); in main()
223 asm volatile ("xorl %%ebp, %%ebp; SYSENTER" : "+a" (nr) :: "flags", "rcx" in main()
238 /* Now make sure that another fast syscall doesn't set TF again. */ in main()