diff --git a/distro/kernel.go b/distro/kernel.go index c5d1130..c0d8929 100644 --- a/distro/kernel.go +++ b/distro/kernel.go @@ -1,5 +1,7 @@ package distro +import "code.dumpstack.io/tools/out-of-tree/qemu" + // ByRootFS is sorting by .RootFS lexicographically type ByRootFS []KernelInfo @@ -25,6 +27,8 @@ type KernelInfo struct { InitrdPath string ModulesPath string + CPU qemu.CPU + RootFS string // Debug symbols diff --git a/pew.go b/pew.go index 9da4d0d..b963863 100644 --- a/pew.go +++ b/pew.go @@ -695,6 +695,14 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup, q.SetSMAP(!ka.Mitigations.DisableSmap) q.SetKPTI(!ka.Mitigations.DisableKpti) + if ki.CPU.Model != "" { + q.CPU.Model = ki.CPU.Model + } + + if len(ki.CPU.Flags) != 0 { + q.CPU.Flags = ki.CPU.Flags + } + if cmd.Endless { q.Timeout = 0 } diff --git a/qemu/qemu-kernel.go b/qemu/qemu-kernel.go index e9d4d4d..87c8810 100644 --- a/qemu/qemu-kernel.go +++ b/qemu/qemu-kernel.go @@ -44,6 +44,11 @@ type Kernel struct { InitrdPath string } +type CPU struct { + Model string + Flags []string +} + // System describe qemu parameters and executed process type System struct { arch arch @@ -55,6 +60,8 @@ type System struct { Cpus int Memory int + CPU CPU + debug bool gdb string // tcp::1234 @@ -247,15 +254,23 @@ func (q *System) Args() (qemuArgs []string) { qemuArgs = append(qemuArgs, "-initrd", q.kernel.InitrdPath) } + cpu := "max" + if q.CPU.Model != "" { + cpu = q.CPU.Model + } + for _, flag := range q.CPU.Flags { + cpu += "," + flag + } + qemuArgs = append(qemuArgs, "-cpu", cpu) + if q.arch == X86x64 || q.arch == X86x32 { if kvmExists() { qemuArgs = append(qemuArgs, "-enable-kvm") } - qemuArgs = append(qemuArgs, "-cpu", "max") } if q.arch == X86x64 && runtime.GOOS == "darwin" { - qemuArgs = append(qemuArgs, "-accel", "hvf", "-cpu", "max") + qemuArgs = append(qemuArgs, "-accel", "hvf") } qemuArgs = append(qemuArgs, "-append", q.cmdline())