From 418476ecb925e5d58ba9c22928a4e37dc30909df Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 20 Nov 2020 19:28:53 +0100 Subject: pkg/ifuzz/iset: rename ifuzzimpl to iset ifuzzimpl is too lenghty and too clumsy on my taste (nm/vmimpl worked better b/c it's shorter and used less). I've tried to come up with something shorter and nicer. We could use "insn" as a common name for "instruction" in ifuzz, but it's a commonly used name already so would cause lots of conflicts. "iset" is somewhat descriptive, short and nice. --- pkg/ifuzz/powerpc/powerpc.go | 24 ++++++++++++------------ pkg/ifuzz/powerpc/pseudo.go | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'pkg/ifuzz/powerpc') diff --git a/pkg/ifuzz/powerpc/powerpc.go b/pkg/ifuzz/powerpc/powerpc.go index a78e0a251..bee20850d 100644 --- a/pkg/ifuzz/powerpc/powerpc.go +++ b/pkg/ifuzz/powerpc/powerpc.go @@ -18,7 +18,7 @@ import ( "fmt" "math/rand" - "github.com/google/syzkaller/pkg/ifuzz/ifuzzimpl" + "github.com/google/syzkaller/pkg/ifuzz/iset" ) type InsnBits struct { @@ -35,20 +35,20 @@ type Insn struct { Opcode uint32 Mask uint32 - generator func(cfg *ifuzzimpl.Config, r *rand.Rand) []byte + generator func(cfg *iset.Config, r *rand.Rand) []byte } type InsnSet struct { Insns []*Insn - modeInsns ifuzzimpl.ModeInsns + modeInsns iset.ModeInsns insnMap map[string]*Insn } -func (insnset *InsnSet) GetInsns(mode ifuzzimpl.Mode, typ ifuzzimpl.Type) []ifuzzimpl.Insn { +func (insnset *InsnSet) GetInsns(mode iset.Mode, typ iset.Type) []iset.Insn { return insnset.modeInsns[mode][typ] } -func (insnset *InsnSet) Decode(mode ifuzzimpl.Mode, text []byte) (int, error) { +func (insnset *InsnSet) Decode(mode iset.Mode, text []byte) (int, error) { if len(text) < 4 { return 0, errors.New("must be at least 4 bytes") } @@ -61,7 +61,7 @@ func (insnset *InsnSet) Decode(mode ifuzzimpl.Mode, text []byte) (int, error) { return 0, fmt.Errorf("unrecognised instruction %08x", insn32) } -func (insnset *InsnSet) DecodeExt(mode ifuzzimpl.Mode, text []byte) (int, error) { +func (insnset *InsnSet) DecodeExt(mode iset.Mode, text []byte) (int, error) { return 0, fmt.Errorf("no external decoder") } @@ -85,7 +85,7 @@ func (insn *Insn) EncodeParam(v map[string]uint, r *rand.Rand) []byte { return ret } -func (insn Insn) Encode(cfg *ifuzzimpl.Config, r *rand.Rand) []byte { +func (insn Insn) Encode(cfg *iset.Config, r *rand.Rand) []byte { if insn.Pseudo { return insn.generator(cfg, r) } @@ -108,16 +108,16 @@ func Register(insns []*Insn) { for _, insn := range insnset.Insns { insnset.modeInsns.Add(insn) } - ifuzzimpl.Arches[ifuzzimpl.ArchPowerPC] = insnset + iset.Arches[iset.ArchPowerPC] = insnset } -func (insn *Insn) Info() (string, ifuzzimpl.Mode, bool, bool) { +func (insn *Insn) Info() (string, iset.Mode, bool, bool) { return insn.Name, insn.mode(), insn.Pseudo, insn.Priv } -func (insn Insn) mode() ifuzzimpl.Mode { +func (insn Insn) mode() iset.Mode { if insn.M64 { - return (1 << ifuzzimpl.ModeLong64) + return (1 << iset.ModeLong64) } - return (1 << ifuzzimpl.ModeLong64) | (1 << ifuzzimpl.ModeProt32) + return (1 << iset.ModeLong64) | (1 << iset.ModeProt32) } diff --git a/pkg/ifuzz/powerpc/pseudo.go b/pkg/ifuzz/powerpc/pseudo.go index 495e0f935..f300eec0f 100644 --- a/pkg/ifuzz/powerpc/pseudo.go +++ b/pkg/ifuzz/powerpc/pseudo.go @@ -6,7 +6,7 @@ package powerpc import ( "math/rand" - "github.com/google/syzkaller/pkg/ifuzz/ifuzzimpl" + "github.com/google/syzkaller/pkg/ifuzz/iset" ) // nolint:dupl @@ -15,7 +15,7 @@ func (insnset *InsnSet) initPseudo() { Name: "PSEUDO_hypercall", Priv: true, Pseudo: true, - generator: func(cfg *ifuzzimpl.Config, r *rand.Rand) []byte { + generator: func(cfg *iset.Config, r *rand.Rand) []byte { gen := makeGen(insnset, cfg, r) gen.sc(1) return gen.text @@ -25,7 +25,7 @@ func (insnset *InsnSet) initPseudo() { Name: "PSEUDO_syscall", Priv: true, Pseudo: true, - generator: func(cfg *ifuzzimpl.Config, r *rand.Rand) []byte { + generator: func(cfg *iset.Config, r *rand.Rand) []byte { gen := makeGen(insnset, cfg, r) gen.sc(0) return gen.text @@ -35,7 +35,7 @@ func (insnset *InsnSet) initPseudo() { Name: "PSEUDO_ultracall", Priv: true, Pseudo: true, - generator: func(cfg *ifuzzimpl.Config, r *rand.Rand) []byte { + generator: func(cfg *iset.Config, r *rand.Rand) []byte { gen := makeGen(insnset, cfg, r) gen.sc(2) return gen.text @@ -45,12 +45,12 @@ func (insnset *InsnSet) initPseudo() { type generator struct { imap map[string]*Insn - mode ifuzzimpl.Mode + mode iset.Mode r *rand.Rand text []byte } -func makeGen(insnset *InsnSet, cfg *ifuzzimpl.Config, r *rand.Rand) *generator { +func makeGen(insnset *InsnSet, cfg *iset.Config, r *rand.Rand) *generator { return &generator{ imap: insnset.insnMap, mode: cfg.Mode, -- cgit mrf-deployment