aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ifuzz/x86/decode.go
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/x86/decode.go
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/x86/decode.go')
-rw-r--r--pkg/ifuzz/x86/decode.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/pkg/ifuzz/x86/decode.go b/pkg/ifuzz/x86/decode.go
index a40643a6b..1306f40db 100644
--- a/pkg/ifuzz/x86/decode.go
+++ b/pkg/ifuzz/x86/decode.go
@@ -6,26 +6,26 @@ package x86
import (
"fmt"
- "github.com/google/syzkaller/pkg/ifuzz/ifuzzimpl"
+ "github.com/google/syzkaller/pkg/ifuzz/iset"
)
// Decode decodes instruction length for the given mode.
// It can have falsely decode incorrect instructions,
// but should not fail to decode correct instructions.
// nolint: gocyclo, nestif, gocognit, funlen
-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) == 0 {
return 0, fmt.Errorf("zero-length instruction")
}
prefixes := prefixes32
var operSize, immSize, dispSize, addrSize int
switch mode {
- case ifuzzimpl.ModeLong64:
+ case iset.ModeLong64:
operSize, immSize, dispSize, addrSize = 4, 4, 4, 8
prefixes = prefixes64
- case ifuzzimpl.ModeProt32:
+ case iset.ModeProt32:
operSize, immSize, dispSize, addrSize = 4, 4, 4, 4
- case ifuzzimpl.ModeProt16, ifuzzimpl.ModeReal16:
+ case iset.ModeProt16, iset.ModeReal16:
operSize, immSize, dispSize, addrSize = 2, 2, 2, 2
default:
panic("bad mode")
@@ -36,7 +36,7 @@ func (insnset *InsnSet) Decode(mode ifuzzimpl.Mode, text []byte) (int, error) {
if len(text) > 1 {
// There are only 2 32-bit instructions that look like VEX-prefixed but are actually not: LDS, LES.
// They always reference memory (mod!=3), but all VEX instructions have "mod=3" where LDS/LES would have mod.
- if (text[0] == 0xc4 || text[0] == 0xc5) && (mode == ifuzzimpl.ModeLong64 || text[1]&0xc0 == 0xc0) {
+ if (text[0] == 0xc4 || text[0] == 0xc5) && (mode == iset.ModeLong64 || text[1]&0xc0 == 0xc0) {
vex = true
}
// There is only one instruction that looks like XOP-prefixed but is actually not: POP.
@@ -208,7 +208,7 @@ nextInsn:
return 0, fmt.Errorf("unknown instruction")
}
-var XedDecode func(mode ifuzzimpl.Mode, text []byte) (int, error)
+var XedDecode func(mode iset.Mode, text []byte) (int, error)
var (
prefixes32 = map[byte]bool{
@@ -226,7 +226,7 @@ var (
}
)
-func (insnset *InsnSet) DecodeExt(mode ifuzzimpl.Mode, text []byte) (int, error) {
+func (insnset *InsnSet) DecodeExt(mode iset.Mode, text []byte) (int, error) {
if XedDecode != nil && text != nil && len(text) > 0 {
return XedDecode(mode, text)
}