-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrundata.go
77 lines (60 loc) · 1.65 KB
/
rundata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package kvm
import (
"reflect"
"unsafe"
)
type runData struct {
// in
requestInterrupWindow uint8
immediateExit uint8
_ [6]uint8
// out
exitReason uint32
readyForInterruptInjection uint8
ifFlag uint8
flags uint16
// in (pre_kvm_run), out (post_kvm_run)
cr8 uint64
apicBase uint64
// #ifdef __KVM_S390
// /* the processor status word for s390 */
// __u64 psw_mask; /* psw upper half */
// __u64 psw_addr; /* psw lower half */
// #endif
exitReasonDataUnion [256]byte
kvmValidRegs uint64
kvmDirtyRegs uint64
synRegsUnion [2048]byte
}
func (k *runData) exitUnknown() ExitUnknown {
exit := (*ExitUnknown)(unsafe.Pointer(&k.exitReasonDataUnion[0]))
return *exit
}
func (k *runData) exitException() ExitException {
exit := (*ExitException)(unsafe.Pointer(&k.exitReasonDataUnion[0]))
return *exit
}
func (k *runData) exitIO() ExitIO {
exit := (*ExitIO)(unsafe.Pointer(&k.exitReasonDataUnion[0]))
return *exit
}
func (k *runData) exitIOData() []byte {
io := k.exitIO()
dataStart := unsafe.Pointer(uintptr(unsafe.Pointer(k)) + uintptr(io.DataOffset))
var srcData []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&srcData))
hdr.Data = uintptr(dataStart)
hdr.Len = int(io.Size)
hdr.Cap = int(io.Size)
data := make([]byte, len(srcData))
copy(data, srcData)
return data
}
func (k *runData) exitFailEntry() ExitFailEntry {
exit := (*ExitFailEntry)(unsafe.Pointer(&k.exitReasonDataUnion[0]))
return *exit
}
func (k *runData) exitInternalError() ExitInternalError {
exit := (*ExitInternalError)(unsafe.Pointer(&k.exitReasonDataUnion[0]))
return *exit
}