diff options
| author | Alexey Kardashevskiy <aik@linux.ibm.com> | 2021-06-01 15:07:38 +1000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-07-19 11:29:36 +0200 |
| commit | 40c360bea98928f9826762046ddeefad6405ca09 (patch) | |
| tree | 72e9ef0f61f2cac052e1d86c71f539dd7176a0c4 | |
| parent | 8cad1b789fd41ebbae53b5ffd4aefb21b738fdab (diff) | |
pkg/ifuzz/powerpc: add helper for system call ("sc") instruction
In order to keep all macro instruction helpers together, his moves
the "sc" helper to the instruction set next to ld64().
This should not cause any behavioral change.
Signed-off-by: Alexey Kardashevskiy <aik@linux.ibm.com>
| -rw-r--r-- | pkg/ifuzz/powerpc/powerpc.go | 4 | ||||
| -rw-r--r-- | pkg/ifuzz/powerpc/pseudo.go | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/pkg/ifuzz/powerpc/powerpc.go b/pkg/ifuzz/powerpc/powerpc.go index d87f073b6..2704ae33b 100644 --- a/pkg/ifuzz/powerpc/powerpc.go +++ b/pkg/ifuzz/powerpc/powerpc.go @@ -173,3 +173,7 @@ func (imap insnSetMap) ld64(reg uint, v uint64) []byte { return ret } + +func (imap insnSetMap) sc(lev uint) []byte { + return imap["sc"].enc(map[string]uint{"LEV": lev}) +} diff --git a/pkg/ifuzz/powerpc/pseudo.go b/pkg/ifuzz/powerpc/pseudo.go index 7529a16fc..91b705b02 100644 --- a/pkg/ifuzz/powerpc/pseudo.go +++ b/pkg/ifuzz/powerpc/pseudo.go @@ -9,6 +9,11 @@ import ( "github.com/google/syzkaller/pkg/ifuzz/iset" ) +const ( + // Valid hcall humbers at the momemt are: 4..0x450. + MaxHcall = 0x450 // MAX_HCALL +) + // nolint:dupl func (insnset *InsnSet) initPseudo() { insnset.Insns = append(insnset.Insns, &Insn{ @@ -63,11 +68,12 @@ func (gen *generator) byte(v []byte) { } func (gen *generator) sc(lev uint) { + imap := gen.imap + n := gen.r.Intn(9) - // Valid hcall humbers at the momemt are: 4..0x450 - gen.byte(gen.imap.ld64(3, uint64(gen.r.Intn(4+(0x450-4)/4)))) + gen.byte(imap.ld64(3, uint64(gen.r.Intn(4+(MaxHcall-4)/4)))) for i := 4; i < n+4; i++ { - gen.byte(gen.imap.ld64(uint(i), gen.r.Uint64())) + gen.byte(imap.ld64(uint(i), gen.r.Uint64())) } - gen.byte(gen.imap["sc"].enc(map[string]uint{"LEV": lev})) + gen.byte(imap.sc(lev)) } |
