github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/pkg/kcov/cdefs.go (about) 1 // Copyright 2025 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 package kcov 4 5 // This file defines values required for KCOV ioctl calls. More information on 6 // the values and their semantics can be found in the kernel documentation under 7 // Documentation/dev-tools/kcov.rst, or at docs.kernel.org/dev-tools/kcov.html. 8 9 import "unsafe" 10 11 const ( 12 sizeofUintPtr = int(unsafe.Sizeof((*int)(nil))) 13 14 iocNrBits = 8 15 iocTypeBits = 8 16 iocSizeBits = 14 17 iocDirBits = 2 18 19 iocNrShift = 0 20 iocTypeshift = iocNrShift + iocNrBits 21 iocSizeShift = iocTypeshift + iocTypeBits 22 iocDirShift = iocSizeShift + iocSizeBits 23 24 iocNone = 0 25 iocWrite = 1 26 iocRead = 2 27 28 // kcovInitTrace initializes KCOV tracing. 29 // #define kcovInitTrace _IOR('c', 1, unsigned long) 30 kcovInitTrace uintptr = (iocRead << iocDirShift) | 31 (unsafe.Sizeof(uint64(0)) << iocSizeShift) | ('c' << iocTypeshift) | (1 << iocNrShift) // 0x80086301. 32 33 // kcovEnable enables kcov for the current thread. 34 // #define kcovEnable _IO('c', 100) 35 kcovEnable uintptr = (iocNone << iocDirShift) | 36 (0 << iocSizeShift) | ('c' << iocTypeshift) | (100 << iocNrShift) // 0x6364. 37 38 // kcovDisable disables kcov for the current thread. 39 // #define kcovDisable _IO('c', 101) 40 kcovDisable uintptr = (iocNone << iocDirShift) | 41 (0 << iocSizeShift) | ('c' << iocTypeshift) | (101 << iocNrShift) // 0x6365. 42 43 kcovTracePC = 0 44 kcovTraceCMP = 1 45 )