| 1 |
/* COVERAGE: ioperm iopl */ |
| 2 |
|
| 3 |
#define _GNU_SOURCE |
| 4 |
#include <unistd.h> |
| 5 |
#include <sys/syscall.h> |
| 6 |
|
| 7 |
#ifdef __NR_ioperm |
| 8 |
static inline int __ioperm(unsigned long from, unsigned long num, int turn_on) |
| 9 |
{ |
| 10 |
return syscall(__NR_ioperm, from, num, turn_on); |
| 11 |
} |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifdef __NR_iopl |
| 15 |
static inline int __iopl(int level) |
| 16 |
{ |
| 17 |
return syscall(__NR_iopl, level); |
| 18 |
} |
| 19 |
#endif |
| 20 |
|
| 21 |
// ENOSYS expected on s390 (31-on-64) and on powerpc |
| 22 |
|
| 23 |
int main() { |
| 24 |
|
| 25 |
#ifdef __NR_ioperm |
| 26 |
__ioperm(1060, 1, 1); |
| 27 |
#if defined(__powerpc__) || defined(__s390__) |
| 28 |
//staptest// ni_syscall () = -38 (ENOSYS) |
| 29 |
#else |
| 30 |
//staptest// ioperm (0x424, 0x1, 0x1) = NNNN |
| 31 |
#endif |
| 32 |
|
| 33 |
__ioperm((unsigned long)-1, 1, 1); |
| 34 |
#if defined(__powerpc__) || defined(__s390__) |
| 35 |
//staptest// ni_syscall () = -38 (ENOSYS) |
| 36 |
#else |
| 37 |
#if __WORDSIZE == 64 |
| 38 |
//staptest// ioperm (0xffffffffffffffff, 0x1, 0x1) = NNNN |
| 39 |
#else |
| 40 |
//staptest// ioperm (0xffffffff, 0x1, 0x1) = NNNN |
| 41 |
#endif |
| 42 |
#endif |
| 43 |
|
| 44 |
__ioperm(1060, (unsigned long)-1, 1); |
| 45 |
#if defined(__powerpc__) || defined(__s390__) |
| 46 |
//staptest// ni_syscall () = -38 (ENOSYS) |
| 47 |
#else |
| 48 |
#if __WORDSIZE == 64 |
| 49 |
//staptest// ioperm (0x424, 0xffffffffffffffff, 0x1) = NNNN |
| 50 |
#else |
| 51 |
//staptest// ioperm (0x424, 0xffffffff, 0x1) = NNNN |
| 52 |
#endif |
| 53 |
#endif |
| 54 |
|
| 55 |
__ioperm(1060, 1, -1); |
| 56 |
#if defined(__powerpc__) || defined(__s390__) |
| 57 |
//staptest// ni_syscall () = -38 (ENOSYS) |
| 58 |
#else |
| 59 |
//staptest// ioperm (0x424, 0x1, 0xffffffff) = NNNN |
| 60 |
#endif |
| 61 |
#endif /* __NR_ioperm */ |
| 62 |
|
| 63 |
#if defined(__i386__) || defined(__x86_64__) |
| 64 |
// NOTE. This function is only in i386 and x86_64 and |
| 65 |
// its args vary between those two archs. Not all are |
| 66 |
// being addressed in the tapset. |
| 67 |
|
| 68 |
__iopl(3); |
| 69 |
//staptest// iopl (3) = NNNN |
| 70 |
|
| 71 |
__iopl(-1); |
| 72 |
//staptest// iopl (4294967295) = NNNN |
| 73 |
#endif |
| 74 |
|
| 75 |
return 0; |
| 76 |
} |