Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/ring0/kernel_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func HaltAndWriteFSBase(regs *arch.Registers)

// init initializes architecture-specific state.
func (k *Kernel) init(maxCPUs int) {
entrySize := reflect.TypeOf(kernelEntry{}).Size()
entrySize := reflect.TypeFor[kernelEntry]().Size()
var (
entries []kernelEntry
padding = 1
Expand All @@ -51,7 +51,7 @@ func (k *Kernel) init(maxCPUs int) {
k.cpuEntries = entries

k.globalIDT = &idt64{}
if reflect.TypeOf(idt64{}).Size() != hostarch.PageSize {
if reflect.TypeFor[idt64]().Size() != hostarch.PageSize {
panic("Size of globalIDT should be PageSize")
}
if reflect.ValueOf(k.globalIDT).Pointer()&(hostarch.PageSize-1) != 0 {
Expand All @@ -77,12 +77,12 @@ func (k *Kernel) EntryRegions() map[uintptr]uintptr {
regions := make(map[uintptr]uintptr)

addr := reflect.ValueOf(&k.cpuEntries[0]).Pointer()
size := reflect.TypeOf(kernelEntry{}).Size() * uintptr(len(k.cpuEntries))
size := reflect.TypeFor[kernelEntry]().Size() * uintptr(len(k.cpuEntries))
end, _ := hostarch.Addr(addr + size).RoundUp()
regions[uintptr(hostarch.Addr(addr).RoundDown())] = uintptr(end)

addr = reflect.ValueOf(k.globalIDT).Pointer()
size = reflect.TypeOf(idt64{}).Size()
size = reflect.TypeFor[idt64]().Size()
end, _ = hostarch.Addr(addr + size).RoundUp()
regions[uintptr(hostarch.Addr(addr).RoundDown())] = uintptr(end)

Expand Down
2 changes: 1 addition & 1 deletion pkg/sentry/kernel/seccomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (t *Task) evaluateSyscallFilters(sysno int32, args arch.SyscallArguments, i
func checkFilterCacheability(program bpf.Program, input bpf.Input) (uint32, error) {
// Look up Nr and Arch fields, we'll use their offsets later
// to verify whether they were accessed.
sdType := reflect.TypeOf(linux.SeccompData{})
sdType := reflect.TypeFor[linux.SeccompData]()
nrField, ok := sdType.FieldByName("Nr")
if !ok {
panic("linux.SeccompData.Nr field not found")
Expand Down
34 changes: 17 additions & 17 deletions pkg/state/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,23 @@ const interfaceType = "interface"
var primitiveTypeDatabase = func() map[string]reflect.Type {
r := make(map[string]reflect.Type)
for _, t := range []reflect.Type{
reflect.TypeOf(false),
reflect.TypeOf(int(0)),
reflect.TypeOf(int8(0)),
reflect.TypeOf(int16(0)),
reflect.TypeOf(int32(0)),
reflect.TypeOf(int64(0)),
reflect.TypeOf(uint(0)),
reflect.TypeOf(uintptr(0)),
reflect.TypeOf(uint8(0)),
reflect.TypeOf(uint16(0)),
reflect.TypeOf(uint32(0)),
reflect.TypeOf(uint64(0)),
reflect.TypeOf(""),
reflect.TypeOf(float32(0.0)),
reflect.TypeOf(float64(0.0)),
reflect.TypeOf(complex64(0.0)),
reflect.TypeOf(complex128(0.0)),
reflect.TypeFor[bool](),
reflect.TypeFor[int](),
reflect.TypeFor[int8](),
reflect.TypeFor[int16](),
reflect.TypeFor[int32](),
reflect.TypeFor[int64](),
reflect.TypeFor[uint](),
reflect.TypeFor[uintptr](),
reflect.TypeFor[uint8](),
reflect.TypeFor[uint16](),
reflect.TypeFor[uint32](),
reflect.TypeFor[uint64](),
reflect.TypeFor[string](),
reflect.TypeFor[float32](),
reflect.TypeFor[float64](),
reflect.TypeFor[complex64](),
reflect.TypeFor[complex128](),
} {
r[t.Name()] = t
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sync/locking/generic_mutex.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ func initLockNames() {}

func init() {
initLockNames()
genericMarkIndex = locking.NewMutexClass(reflect.TypeOf(Mutex{}), lockNames)
genericMarkIndex = locking.NewMutexClass(reflect.TypeFor[Mutex](), lockNames)
}
2 changes: 1 addition & 1 deletion pkg/sync/locking/generic_rwmutex.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ func initLockNames() {}

func init() {
initLockNames()
genericMarkIndex = locking.NewMutexClass(reflect.TypeOf(RWMutex{}), lockNames)
genericMarkIndex = locking.NewMutexClass(reflect.TypeFor[RWMutex](), lockNames)
}
2 changes: 1 addition & 1 deletion pkg/urpc/urpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (s *Server) Register(obj any) {
// Need single return.
panic(fmt.Sprintf("method %s has wrong number of returns.", prettyName))
}
if returnType := mtype.Out(0); returnType != reflect.TypeOf((*error)(nil)).Elem() {
if returnType := mtype.Out(0); returnType != reflect.TypeFor[error]() {
// Need error return.
panic(fmt.Sprintf("method %s has non-error return value.", prettyName))
}
Expand Down
2 changes: 1 addition & 1 deletion test/packetimpact/testbench/layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func stringLayer(l Layer) string {
v = reflect.Indirect(v)
switch {
// Try to use Stringers appropriately.
case v.Type().Implements(reflect.TypeOf((*fmt.Stringer)(nil)).Elem()):
case v.Type().Implements(reflect.TypeFor[fmt.Stringer]()):
ret = append(ret, fmt.Sprintf("%s:%v", t.Name, v))
// Print byte slices as hex.
case v.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8:
Expand Down