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
77 printf("[WARN]\tSIGTRAP handler had TF set\n"); in sigtrap()
86 (unsigned long)info->si_addr, in sigtrap()
87 (unsigned long)ctx->uc_mcontext.gregs[REG_IP]); in sigtrap()
102 printf("\tGot %s with RIP=%lx, TF=%ld\n", signames[sig], in print_and_longjmp()
103 (unsigned long)ctx->uc_mcontext.gregs[REG_IP], in print_and_longjmp()
104 (unsigned long)ctx->uc_mcontext.gregs[REG_EFL] & X86_EFLAGS_TF); in print_and_longjmp()
106 sig_eflags = (unsigned long)ctx->uc_mcontext.gregs[REG_EFL]; in print_and_longjmp()
125 printf("[OK]\tSurvived with TF set and %d traps\n", (int)sig_traps); in check_result()
132 printf("[RUN]\tFast syscall with TF cleared\n"); in fast_syscall_no_tf()
133 fflush(stdout); /* Force a syscall */ in fast_syscall_no_tf()
153 printf("[RUN]\tSet TF and check nop\n"); in main()
159 printf("[RUN]\tSet TF and check syscall-less opportunistic sysret\n"); in main()
170 printf("[RUN]\tSet TF and check int80\n"); in main()
172 asm volatile ("int $0x80" : "=a" (tmp) : "a" (SYS_getpid) in main()
179 * SYSENTER: it triggers a nasty design flaw in SYSENTER. in main()
180 * Specifically, SYSENTER does not clear TF, so either SYSENTER in main()
183 * get a CPL0 fault with usergs (on 64-bit kernels) and possibly in main()
185 * it is to clear TF on return from the #DB handler, but this in main()
186 * happens way too early to set TF in the saved pt_regs, so the in main()
188 * the TF bit. in main()
192 syscall(SYS_getpid); /* Force symbol binding without TF set. */ in main()
193 printf("[RUN]\tSet TF and check a fast syscall\n"); in main()
198 /* Now make sure that another fast syscall doesn't set TF again. */ in main()
202 * And do a forced SYSENTER to make sure that this works even if in main()
210 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()