diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2021-07-22 11:04:39 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-07-22 14:01:28 +0200 |
| commit | ebbf8d6c60b67460b5d7335d22441365e9fcbdbb (patch) | |
| tree | 066dd5d31e7904002c2756a3679ef080862fceb4 /prog/analysis.go | |
| parent | 302e51de43c05797424da429336824f6b87c3353 (diff) | |
prog: increase max number of syscalls
Currently fallback coverage imposes an implicit 8K limit
on the max number of syscalls. 8K is quite close to the
current number of syscalls we have on Linux.
1. Bump this limit to 2M.
2. Detect limit violation during startup rather than later,
with an obscure error message and only if fallback coverage is used.
Diffstat (limited to 'prog/analysis.go')
| -rw-r--r-- | prog/analysis.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/prog/analysis.go b/prog/analysis.go index 8a7b2730a..0ac0a97b9 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -195,7 +195,10 @@ const ( fallbackSignalErrnoBlocked fallbackSignalCtor fallbackSignalFlags - fallbackCallMask = 0x1fff + // This allows us to have 2M syscalls and leaves 8 bits for 256 errno values. + // Linux currently have 133 errno's. Larger errno values will be truncated, + // which is acceptable for fallback coverage. + fallbackCallMask = 0x1fffff ) func (p *Prog) FallbackSignal(info []CallInfo) { @@ -297,15 +300,19 @@ func DecodeFallbackSignal(s uint32) (callID, errno int) { } func encodeFallbackSignal(typ, id, aux int) uint32 { + checkMaxCallID(id) if typ & ^7 != 0 { panic(fmt.Sprintf("bad fallback signal type %v", typ)) } - if id & ^fallbackCallMask != 0 { - panic(fmt.Sprintf("bad call id in fallback signal %v", id)) - } - return uint32(typ) | uint32(id&fallbackCallMask)<<3 | uint32(aux)<<16 + return uint32(typ) | uint32(id&fallbackCallMask)<<3 | uint32(aux)<<24 } func decodeFallbackSignal(s uint32) (typ, id, aux int) { - return int(s & 7), int((s >> 3) & fallbackCallMask), int(s >> 16) + return int(s & 7), int((s >> 3) & fallbackCallMask), int(s >> 24) +} + +func checkMaxCallID(id int) { + if id & ^fallbackCallMask != 0 { + panic(fmt.Sprintf("too many syscalls, have %v, max supported %v", id, fallbackCallMask+1)) + } } |
