Skip to content

Commit bce510f

Browse files
committed
Cleanup
1 parent 5f90ed2 commit bce510f

File tree

6 files changed

+8
-30
lines changed

6 files changed

+8
-30
lines changed

packages/orchestrator/internal/sandbox/uffd/mapping/firecracker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ type GuestRegionUffdMapping struct {
1111
PageSize uintptr `json:"page_size_kib"`
1212
}
1313

14-
func (m *GuestRegionUffdMapping) relativeOffset(addr uintptr) uint64 {
15-
return uint64(m.Offset + addr - m.BaseHostVirtAddr)
14+
func (m *GuestRegionUffdMapping) relativeOffset(addr uintptr) int64 {
15+
return int64(m.Offset + addr - m.BaseHostVirtAddr)
1616
}
1717

1818
type FcMappings []GuestRegionUffdMapping
1919

2020
// Returns the relative offset and the page size of the mapped range for a given address
21-
func (m FcMappings) GetRange(addr uintptr) (uint64, uint64, error) {
21+
func (m FcMappings) GetRange(addr uintptr) (int64, uint64, error) {
2222
for _, m := range m {
2323
if addr < m.BaseHostVirtAddr || m.BaseHostVirtAddr+m.Size <= addr {
2424
// Outside of this mapping
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package mapping
22

33
type Mappings interface {
4-
GetRange(addr uintptr) (offset uint64, pagesize uint64, err error)
4+
GetRange(addr uintptr) (offset int64, pagesize uint64, err error)
55
}

packages/orchestrator/internal/sandbox/uffd/userfaultfd/constants.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const (
2828

2929
UFFDIO_REGISTER_MODE_MISSING = C.UFFDIO_REGISTER_MODE_MISSING
3030
UFFDIO_REGISTER_MODE_WP = C.UFFDIO_REGISTER_MODE_WP
31-
UFFDIO_REGISTER_MODE_MINOR = C.UFFDIO_REGISTER_MODE_MINOR
3231

3332
UFFDIO_WRITEPROTECT_MODE_WP = C.UFFDIO_WRITEPROTECT_MODE_WP
3433
UFFDIO_COPY_MODE_WP = C.UFFDIO_COPY_MODE_WP

packages/orchestrator/internal/sandbox/uffd/userfaultfd/mocks_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ func newMockMappings(start uintptr, size, pagesize uint64) *mockMappings {
2626
}
2727
}
2828

29-
func (m *mockMappings) GetRange(addr uintptr) (uint64, uint64, error) {
29+
func (m *mockMappings) GetRange(addr uintptr) (int64, uint64, error) {
3030
offset := addr - m.start
3131
pagesize := m.pagesize
3232

33-
return uint64(offset), pagesize, nil
33+
return int64(offset), pagesize, nil
3434
}
3535

3636
type mockSlicer struct {

packages/orchestrator/internal/sandbox/uffd/userfaultfd/serve.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (u *userfaultfd) Serve(
4141

4242
var eg errgroup.Group
4343

44-
missingChunksBeingHandled := map[uint64]struct{}{}
44+
missingChunksBeingHandled := map[int64]struct{}{}
4545

4646
outerLoop:
4747
for {
@@ -156,8 +156,6 @@ outerLoop:
156156
return nil
157157
})
158158

159-
fmt.Fprintf(os.Stderr, "wp trigger %d %d\n", addr, offset/pagesize)
160-
161159
continue
162160
}
163161

@@ -187,7 +185,7 @@ outerLoop:
187185

188186
var copyMode CULong
189187

190-
b, sliceErr := src.Slice(int64(offset), int64(pagesize))
188+
b, sliceErr := src.Slice(offset, int64(pagesize))
191189
if sliceErr != nil {
192190
signalErr := fdExit.SignalExit()
193191

packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,6 @@ func (u *userfaultfd) copy(addr uintptr, data []byte, pagesize uint64, mode CULo
9292
return nil
9393
}
9494

95-
// Wake wakes up the faulting thread(s) waiting on the given address range.
96-
func (u *userfaultfd) Wake(addr uintptr, size uint64) error {
97-
type uffdioWake struct {
98-
addr CULong
99-
len CULong
100-
flags CULong
101-
}
102-
wake := uffdioWake{
103-
addr: CULong(addr),
104-
len: CULong(size),
105-
flags: 0,
106-
}
107-
108-
if _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, u.fd, UFFDIO_WAKE, uintptr(unsafe.Pointer(&wake))); errno != 0 {
109-
return errno
110-
}
111-
return nil
112-
}
113-
11495
func (u *userfaultfd) Close() error {
11596
return syscall.Close(int(u.fd))
11697
}

0 commit comments

Comments
 (0)