diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2021-03-14 17:30:28 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-03-14 19:56:42 +0100 |
| commit | 8e461f0e356a22230d10a49322ee6b0282e3d7b7 (patch) | |
| tree | 0ef29e2d3f1e8cf52c0acc701c62f7329d09eef2 /tools/syz-kconf | |
| parent | 4a003785c5484e99127a20e069a5edddcb8c24d5 (diff) | |
tools/syz-kconf: disable all reduced configs on "reduced" instances
We list a number of configs in fragments intended for non-reduced instances.
However, lots of these configs are enabled by defconfig anyway.
This is not what we want, we want to actually disable them on reduced instances.
Diffstat (limited to 'tools/syz-kconf')
| -rw-r--r-- | tools/syz-kconf/kconf.go | 1 | ||||
| -rw-r--r-- | tools/syz-kconf/parser.go | 35 |
2 files changed, 30 insertions, 6 deletions
diff --git a/tools/syz-kconf/kconf.go b/tools/syz-kconf/kconf.go index bd185eb86..06d043790 100644 --- a/tools/syz-kconf/kconf.go +++ b/tools/syz-kconf/kconf.go @@ -31,6 +31,7 @@ const ( featAppend = "append" featWeak = "weak" featBaseline = "baseline" + featReduced = "reduced" featClang = "clang" featAndroid = "android" featChromeos = "chromeos" diff --git a/tools/syz-kconf/parser.go b/tools/syz-kconf/parser.go index 2311bdd8a..0f7d330a0 100644 --- a/tools/syz-kconf/parser.go +++ b/tools/syz-kconf/parser.go @@ -59,6 +59,15 @@ func (features Features) Match(constraints []string) bool { return true } +func constraintsInclude(constraints []string, what string) bool { + for _, feat := range constraints { + if feat == what { + return true + } + } + return false +} + type rawMain struct { Instances []map[string][]string Includes []map[string][]string @@ -115,14 +124,21 @@ func parseInstance(name, configDir string, features []string, includes []map[str errs := new(Errors) for _, include := range includes { for file, features := range include { - if !inst.Features.Match(features) { - continue - } raw, err := parseFile(filepath.Join(configDir, "bits", file)) if err != nil { return nil, err } - mergeFile(inst, raw, file, errs) + if inst.Features.Match(features) { + mergeFile(inst, raw, file, errs) + } else if inst.Features[featReduced] && constraintsInclude(features, "-"+featReduced) { + // For fragments that we exclude because of "reduced" config, + // we want to disable all configs listed there. + // For example, if the fragment enables config FOO, and we the defconfig + // also enabled FOO, we want to disable FOO to get reduced config. + for _, node := range raw.Config { + mergeConfig(inst, file, node, true, errs) + } + } } } inst.Verbatim = bytes.TrimSpace(inst.Verbatim) @@ -168,16 +184,23 @@ func mergeFile(inst *Instance, raw *rawFile, file string, errs *Errors) { } inst.Verbatim = append(append(inst.Verbatim, raw.Verbatim...), '\n') for _, node := range raw.Config { - mergeConfig(inst, file, node, errs) + mergeConfig(inst, file, node, false, errs) } } -func mergeConfig(inst *Instance, file string, node yaml.Node, errs *Errors) { +func mergeConfig(inst *Instance, file string, node yaml.Node, reduced bool, errs *Errors) { name, val, constraints, err := parseNode(node) if err != nil { errs.push("%v:%v: %v", file, node.Line, err) return } + if reduced { + if val != kconfig.No && val != kconfig.Yes { + return + } + val = kconfig.No + constraints = append(constraints, featWeak) + } cfg := &Config{ Name: name, Value: val, |
