aboutsummaryrefslogtreecommitdiffstats
path: root/sys/syz-sysgen
diff options
context:
space:
mode:
Diffstat (limited to 'sys/syz-sysgen')
-rw-r--r--sys/syz-sysgen/sysgen.go96
1 files changed, 52 insertions, 44 deletions
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go
index 44e788fcf..e4791b3eb 100644
--- a/sys/syz-sysgen/sysgen.go
+++ b/sys/syz-sysgen/sysgen.go
@@ -92,17 +92,11 @@ func main() {
}
sort.Strings(archs)
- type Job struct {
- Target *targets.Target
- OK bool
- Errors []string
- Unsupported map[string]bool
- ArchData ArchData
- }
var jobs []*Job
for _, arch := range archs {
jobs = append(jobs, &Job{
- Target: targets.List[OS][arch],
+ Target: targets.List[OS][arch],
+ Unsupported: make(map[string]bool),
})
}
sort.Slice(jobs, func(i, j int) bool {
@@ -115,42 +109,7 @@ func main() {
job := job
go func() {
defer wg.Done()
- eh := func(pos ast.Pos, msg string) {
- job.Errors = append(job.Errors, fmt.Sprintf("%v: %v\n", pos, msg))
- }
- consts := constFile.Arch(job.Target.Arch)
- top := descriptions
- if OS == targets.Linux && (job.Target.Arch == targets.ARM || job.Target.Arch == targets.RiscV64) {
- // Hack: KVM is not supported on ARM anymore. On riscv64 it
- // is not supported yet but might be in the future.
- // Note: syz-extract also ignores this file for arm and riscv64.
- top = descriptions.Filter(func(n ast.Node) bool {
- pos, _, _ := n.Info()
- return !strings.HasSuffix(pos.File, "_kvm.txt")
- })
- }
- if OS == targets.TestOS {
- constInfo := compiler.ExtractConsts(top, job.Target, eh)
- compiler.FabricateSyscallConsts(job.Target, constInfo, consts)
- }
- prog := compiler.Compile(top, consts, job.Target, eh)
- if prog == nil {
- return
- }
- job.Unsupported = prog.Unsupported
-
- sysFile := filepath.Join(*outDir, "sys", OS, "gen", job.Target.Arch+".go")
- out := new(bytes.Buffer)
- generate(job.Target, prog, consts, out)
- rev := hash.String(out.Bytes())
- fmt.Fprintf(out, "const revision_%v = %q\n", job.Target.Arch, rev)
- writeSource(sysFile, out.Bytes())
-
- job.ArchData = generateExecutorSyscalls(job.Target, prog.Syscalls, rev)
-
- // Don't print warnings, they are printed in syz-check.
- job.Errors = nil
- job.OK = true
+ processJob(job, descriptions, constFile)
}()
}
wg.Wait()
@@ -198,6 +157,55 @@ func main() {
writeExecutorSyscalls(data)
}
+type Job struct {
+ Target *targets.Target
+ OK bool
+ Errors []string
+ Unsupported map[string]bool
+ ArchData ArchData
+}
+
+func processJob(job *Job, descriptions *ast.Description, constFile *compiler.ConstFile) {
+ eh := func(pos ast.Pos, msg string) {
+ job.Errors = append(job.Errors, fmt.Sprintf("%v: %v\n", pos, msg))
+ }
+ consts := constFile.Arch(job.Target.Arch)
+ top := descriptions
+ if job.Target.OS == targets.Linux && (job.Target.Arch == targets.ARM || job.Target.Arch == targets.RiscV64) {
+ // Hack: KVM is not supported on ARM anymore. On riscv64 it
+ // is not supported yet but might be in the future.
+ // Note: syz-extract also ignores this file for arm and riscv64.
+ top = descriptions.Filter(func(n ast.Node) bool {
+ pos, _, _ := n.Info()
+ return !strings.HasSuffix(pos.File, "_kvm.txt")
+ })
+ }
+ if job.Target.OS == targets.TestOS {
+ constInfo := compiler.ExtractConsts(top, job.Target, eh)
+ compiler.FabricateSyscallConsts(job.Target, constInfo, consts)
+ }
+ prog := compiler.Compile(top, consts, job.Target, eh)
+ if prog == nil {
+ return
+ }
+ for what := range prog.Unsupported {
+ job.Unsupported[what] = true
+ }
+
+ sysFile := filepath.Join(*outDir, "sys", job.Target.OS, "gen", job.Target.Arch+".go")
+ out := new(bytes.Buffer)
+ generate(job.Target, prog, consts, out)
+ rev := hash.String(out.Bytes())
+ fmt.Fprintf(out, "const revision_%v = %q\n", job.Target.Arch, rev)
+ writeSource(sysFile, out.Bytes())
+
+ job.ArchData = generateExecutorSyscalls(job.Target, prog.Syscalls, rev)
+
+ // Don't print warnings, they are printed in syz-check.
+ job.Errors = nil
+ job.OK = true
+}
+
func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint64, out io.Writer) {
tag := fmt.Sprintf("syz_target,syz_os_%v,syz_arch_%v", target.OS, target.Arch)
if target.VMArch != "" {