aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ifuzz/powerpc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-11-20 19:28:53 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-11-21 08:46:20 +0100
commit418476ecb925e5d58ba9c22928a4e37dc30909df (patch)
tree702468b5ca1b0df89a83d861b18eaff9ae2237c5 /pkg/ifuzz/powerpc
parente1dea42221c13dabdf9d4938428f1ef91863b813 (diff)
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.
Diffstat (limited to 'pkg/ifuzz/powerpc')
-rw-r--r--pkg/ifuzz/powerpc/powerpc.go24
-rw-r--r--pkg/ifuzz/powerpc/pseudo.go12
2 files changed, 18 insertions, 18 deletions
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,