Skip to content

Commit

Permalink
Update to gvisor release-20240826.0
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Fergeau <[email protected]>
  • Loading branch information
cfergeau committed Sep 23, 2024
1 parent f1c8464 commit 41b59e3
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 117 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
golang.org/x/crypto v0.27.0
golang.org/x/sync v0.8.0
golang.org/x/sys v0.25.0
gvisor.dev/gvisor v0.0.0-20240726212243-a2b0498dbe7d
gvisor.dev/gvisor v0.0.0-20240826182512-9f3309e5b121
inet.af/tcpproxy v0.0.0-20220326234310-be3ee21c9fa0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gvisor.dev/gvisor v0.0.0-20240726212243-a2b0498dbe7d h1:nF+dSOz0u0DLrhnOmGp3ocPAylsgpim29DGIt/oxNR4=
gvisor.dev/gvisor v0.0.0-20240726212243-a2b0498dbe7d/go.mod h1:sxc3Uvk/vHcd3tj7/DHVBoR5wvWT/MmRq2pj7HRJnwU=
gvisor.dev/gvisor v0.0.0-20240826182512-9f3309e5b121 h1:2Vd3QUoPYevmDp3S7jUQgxEzdeMlDh8pYFELopFXn3w=
gvisor.dev/gvisor v0.0.0-20240826182512-9f3309e5b121/go.mod h1:sxc3Uvk/vHcd3tj7/DHVBoR5wvWT/MmRq2pj7HRJnwU=
9 changes: 8 additions & 1 deletion vendor/gvisor.dev/gvisor/pkg/cpuid/cpuid_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (fs FeatureSet) HasFeature(feature Feature) bool {

// WriteCPUInfoTo is to generate a section of one cpu in /proc/cpuinfo. This is
// a minimal /proc/cpuinfo, it is missing some fields like "microcode" that are
// not always printed in Linux. The bogomips field is simply made up.
// not always printed in Linux. Several fields are simply made up.
func (fs FeatureSet) WriteCPUInfoTo(cpu, numCPU uint, w io.Writer) {
// Avoid many redundant calls here, since this can occasionally appear
// in the hot path. Read all basic information up front, see above.
Expand All @@ -322,6 +322,13 @@ func (fs FeatureSet) WriteCPUInfoTo(cpu, numCPU uint, w io.Writer) {
fmt.Fprintf(w, "model name\t: %s\n", "unknown") // Unknown for now.
fmt.Fprintf(w, "stepping\t: %s\n", "unknown") // Unknown for now.
fmt.Fprintf(w, "cpu MHz\t\t: %.3f\n", cpuFreqMHz)
// Pretend the CPU has 8192 KB of cache. Note that real /proc/cpuinfo exposes total L3 cache
// size on Intel and per-core L2 cache size on AMD (as of Linux 6.1.0), so the value of this
// field is not really important in practice. Any value that is chosen here will be wrong
// by an order of magnitude on a significant chunk of x86 machines.
// 8192 KB is selected because it is a reasonable size that will be effectively usable on
// lightly loaded machines - most machines have 1-4MB of L3 cache per core.
fmt.Fprintf(w, "cache size\t: 8192 KB\n")
fmt.Fprintf(w, "physical id\t: 0\n") // Pretend all CPUs are in the same socket.
fmt.Fprintf(w, "siblings\t: %d\n", numCPU)
fmt.Fprintf(w, "core id\t\t: %d\n", cpu)
Expand Down
11 changes: 5 additions & 6 deletions vendor/gvisor.dev/gvisor/pkg/state/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"bytes"
"context"
"fmt"
"io"
"math"
"reflect"

Expand Down Expand Up @@ -143,7 +142,7 @@ type decodeState struct {
ctx context.Context

// r is the input stream.
r io.Reader
r wire.Reader

// types is the type database.
types typeDecodeDatabase
Expand Down Expand Up @@ -591,7 +590,7 @@ func (ds *decodeState) Load(obj reflect.Value) {
ds.pending.PushBack(rootOds)

// Read the number of objects.
numObjects, object, err := ReadHeader(ds.r)
numObjects, object, err := ReadHeader(&ds.r)
if err != nil {
Failf("header error: %w", err)
}
Expand All @@ -613,7 +612,7 @@ func (ds *decodeState) Load(obj reflect.Value) {
// decoding loop in state/pretty/pretty.printer.printStream().
for i := uint64(0); i < numObjects; {
// Unmarshal either a type object or object ID.
encoded = wire.Load(ds.r)
encoded = wire.Load(&ds.r)
switch we := encoded.(type) {
case *wire.Type:
ds.types.Register(we)
Expand All @@ -624,7 +623,7 @@ func (ds *decodeState) Load(obj reflect.Value) {
id = objectID(we)
i++
// Unmarshal and resolve the actual object.
encoded = wire.Load(ds.r)
encoded = wire.Load(&ds.r)
ods = ds.lookup(id)
if ods != nil {
// Decode the object.
Expand Down Expand Up @@ -718,7 +717,7 @@ func (ds *decodeState) Load(obj reflect.Value) {
// Each object written to the statefile is prefixed with a header. See
// WriteHeader for more information; these functions are exported to allow
// non-state writes to the file to play nice with debugging tools.
func ReadHeader(r io.Reader) (length uint64, object bool, err error) {
func ReadHeader(r *wire.Reader) (length uint64, object bool, err error) {
// Read the header.
err = safely(func() {
length = wire.LoadUint(r)
Expand Down
13 changes: 6 additions & 7 deletions vendor/gvisor.dev/gvisor/pkg/state/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package state

import (
"context"
"io"
"reflect"
"sort"

Expand Down Expand Up @@ -62,7 +61,7 @@ type encodeState struct {
ctx context.Context

// w is the output stream.
w io.Writer
w wire.Writer

// types is the type database.
types typeEncodeDatabase
Expand Down Expand Up @@ -781,7 +780,7 @@ func (es *encodeState) Save(obj reflect.Value) {
}

// Write the header with the number of objects.
if err := WriteHeader(es.w, uint64(len(es.pending)), true); err != nil {
if err := WriteHeader(&es.w, uint64(len(es.pending)), true); err != nil {
Failf("error writing header: %w", err)
}

Expand All @@ -791,7 +790,7 @@ func (es *encodeState) Save(obj reflect.Value) {
if err := safely(func() {
for _, wt := range es.pendingTypes {
// Encode the type.
wire.Save(es.w, &wt)
wire.Save(&es.w, &wt)
}
// Emit objects in ID order.
ids := make([]objectID, 0, len(es.pending))
Expand All @@ -803,10 +802,10 @@ func (es *encodeState) Save(obj reflect.Value) {
})
for _, id := range ids {
// Encode the id.
wire.Save(es.w, wire.Uint(id))
wire.Save(&es.w, wire.Uint(id))
// Marshal the object.
oes := es.pending[id]
wire.Save(es.w, oes.encoded)
wire.Save(&es.w, oes.encoded)
}
}); err != nil {
// Include the object and the error.
Expand All @@ -825,7 +824,7 @@ const objectFlag uint64 = 1 << 63
// order to generate statefiles that play nicely with debugging tools, raw
// writes should be prefixed with a header with object set to false and the
// appropriate length. This will allow tools to skip these regions.
func WriteHeader(w io.Writer, length uint64, object bool) error {
func WriteHeader(w *wire.Writer, length uint64, object bool) error {
// Sanity check the length.
if length&objectFlag != 0 {
Failf("impossibly huge length: %d", length)
Expand Down
4 changes: 2 additions & 2 deletions vendor/gvisor.dev/gvisor/pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func Save(ctx context.Context, w io.Writer, rootPtr any) (Stats, error) {
// Create the encoding state.
es := encodeState{
ctx: ctx,
w: w,
w: wire.Writer{Writer: w},
types: makeTypeEncodeDatabase(),
zeroValues: make(map[reflect.Type]*objectEncodeState),
pending: make(map[objectID]*objectEncodeState),
Expand All @@ -111,7 +111,7 @@ func Load(ctx context.Context, r io.Reader, rootPtr any) (Stats, error) {
// Create the decoding state.
ds := decodeState{
ctx: ctx,
r: r,
r: wire.Reader{Reader: r},
types: makeTypeDecodeDatabase(),
deferred: make(map[objectID]wire.Object),
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/gvisor.dev/gvisor/pkg/state/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ var singleFieldOrder = []int{0}
//
// This method never returns nil.
func (tbd *typeDecodeDatabase) Lookup(id typeID, typ reflect.Type) *reconciledTypeEntry {
if len(tbd.byID) > int(id) && tbd.byID[id-1] != nil {
if len(tbd.byID) >= int(id) && tbd.byID[id-1] != nil {
// Already reconciled.
return tbd.byID[id-1]
}
Expand Down
Loading

0 comments on commit 41b59e3

Please sign in to comment.