aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-07-22 11:04:39 +0200
committerDmitry Vyukov <dvyukov@google.com>2021-07-22 14:01:28 +0200
commitebbf8d6c60b67460b5d7335d22441365e9fcbdbb (patch)
tree066dd5d31e7904002c2756a3679ef080862fceb4
parent302e51de43c05797424da429336824f6b87c3353 (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.
-rw-r--r--prog/analysis.go19
-rw-r--r--prog/target.go1
2 files changed, 14 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))
+ }
}
diff --git a/prog/target.go b/prog/target.go
index 2cfb25108..cb485c069 100644
--- a/prog/target.go
+++ b/prog/target.go
@@ -138,6 +138,7 @@ func (target *Target) lazyInit() {
}
func (target *Target) initTarget() {
+ checkMaxCallID(len(target.Syscalls) - 1)
target.ConstMap = make(map[string]uint64)
for _, c := range target.Consts {
target.ConstMap[c.Name] = c.Value