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
55 printf("[WARN]\tSIGTRAP handler had TF set\n"); in sigtrap()
64 (unsigned long)info->si_addr, in sigtrap()
65 (unsigned long)ctx->uc_mcontext.gregs[REG_IP]); in sigtrap()
80 printf("\tGot %s with RIP=%lx, TF=%ld\n", signames[sig], in print_and_longjmp()
81 (unsigned long)ctx->uc_mcontext.gregs[REG_IP], in print_and_longjmp()
82 (unsigned long)ctx->uc_mcontext.gregs[REG_EFL] & X86_EFLAGS_TF); in print_and_longjmp()
84 sig_eflags = (unsigned long)ctx->uc_mcontext.gregs[REG_EFL]; in print_and_longjmp()
103 printf("[OK]\tSurvived with TF set and %d traps\n", (int)sig_traps); in check_result()
110 printf("[RUN]\tFast syscall with TF cleared\n"); in fast_syscall_no_tf()
111 fflush(stdout); /* Force a syscall */ in fast_syscall_no_tf()
131 printf("[RUN]\tSet TF and check nop\n"); in main()
137 printf("[RUN]\tSet TF and check syscall-less opportunistic sysret\n"); in main()
148 printf("[RUN]\tSet TF and check int80\n"); in main()
150 asm volatile ("int $0x80" : "=a" (tmp) : "a" (SYS_getpid) in main()
157 * SYSENTER: it triggers a nasty design flaw in SYSENTER. in main()
158 * Specifically, SYSENTER does not clear TF, so either SYSENTER in main()
161 * get a CPL0 fault with usergs (on 64-bit kernels) and possibly in main()
163 * it is to clear TF on return from the #DB handler, but this in main()
164 * happens way too early to set TF in the saved pt_regs, so the in main()
166 * the TF bit. in main()
170 syscall(SYS_getpid); /* Force symbol binding without TF set. */ in main()
171 printf("[RUN]\tSet TF and check a fast syscall\n"); in main()
176 /* Now make sure that another fast syscall doesn't set TF again. */ in main()
180 * And do a forced SYSENTER to make sure that this works even if in main()
188 printf("[RUN]\tSet TF and check SYSENTER\n"); in main()
201 asm volatile ("xorl %%ebp, %%ebp; SYSENTER" : "+a" (nr) :: "flags", "rcx" in main()
216 /* Now make sure that another fast syscall doesn't set TF again. */ in main()