Commit Graph

96 Commits

Author SHA1 Message Date
Rahat Mahmood 1561ae3037 go-marshal: Allow array lens to be consts and simple expressions.
Previously, go-marshal only allowed literals for array
lengths. However, it's very common for ABI structs to have a fix-sized
array whose length is defined by a constant; for example PATH_MAX.
Having to convert all such arrays to have literal lengths is too
awkward.

PiperOrigin-RevId: 304289345
2020-04-01 16:51:28 -07:00
Rahat Mahmood 507f997213 go-marshal: Improve collision detection of import statments.
Previously, the import statement collision detection mechanism aborted
go-marshal whenever it detected two imports in any package that has
the same local name. Consider this trivial package, defined by the the
following two source files:

file1.go:

package example
import (
        path/a/to/foo
)
...

file2.go:

package example
import (
       another/package/with/final/component/foo
)
...

Go-marshal previously couldn't handle generating code for the the
above package, even if none of the types marked for marshalling used
either of the imported foo packages. This turns out to be too
restrictive as we run into this a lot in practice. Examples include
"encoding/binary" vs "gvisor/pkg/binary/binary", and "sync" vs
"gvisor/pkg/sync/sync".

This change allows go-marshal to proceed with marshalling, and only
abort if the code generated by go-marshal references any such
ambiguous import names.

PiperOrigin-RevId: 304131190
2020-04-01 00:43:55 -07:00
Rahat Mahmood 840980aeba Implement automated marshalling for slices of Marshallable types.
PiperOrigin-RevId: 304119255
2020-03-31 22:56:09 -07:00
Zach Koopmans e36eccc4b1 BigQuery schema for benchmark-tools dashboard.
PiperOrigin-RevId: 303805784
2020-03-30 13:05:45 -07:00
Zach Koopmans 4aee370640 Internal change.
PiperOrigin-RevId: 303773475
2020-03-30 10:44:55 -07:00
Adin Scannell a5742f177a Add nogo exemption for machine_arm64_unsafe.go 2020-03-26 12:29:14 -07:00
Adin Scannell 882ed330e6 nogo: enable sanitizers.
This enables all relevant santizers (though most analyzers will not find
much, it will prevent instances from creeping in), and codifies existing
exceptions in tools/nogo.js to be fixed.
2020-03-25 16:21:27 -07:00
Adin Scannell d440fe0613 Fix go_marshal Example name.
There is a canonical naming convention for Examples, which are checked
by analyzers. This must be fixed since adding exceptions for generated
code will be more challenging.
2020-03-25 16:18:05 -07:00
Eyal Soha fed59953aa Statically link libpthread for static c++ binaries.
The posix_server works fine when run in locally or in docker but fails in the
kokoro GCP build environment. Linking libpthread statically fixes it.

PiperOrigin-RevId: 302139082
2020-03-20 18:24:00 -07:00
Zach Koopmans b9210b2855 Fix bm-tools to run on bazel.
Fixes random stuff that is broken on bazel/kokoro.
- random output coming back as "bytes" object instead of str
- missed syntax error in bazel
- a flag is missing in the version of gcloud on kokoro

PiperOrigin-RevId: 301915289
2020-03-19 16:07:05 -07:00
Eyal Soha 3192e55ffe Packetimpact in Go with c++ stub
PiperOrigin-RevId: 301382690
2020-03-17 08:53:27 -07:00
Adin Scannell e5d9a4010b Add ability to execute go.mod in gopath context. 2020-02-28 10:21:17 -08:00
Adin Scannell c96bb4d2eb Fix apt-get reliability issues.
This is frequently causing the core build scripts to fail. The core ubuntu
distribution will perform an auto-update at first start, which may cause the
lock file to be held. All apt-get commands may be done in a loop in order to
retry to avoid this issue. We may want to consider retrying other pieces, but
for now this should avoid the most frequent cause of build flakes.

PiperOrigin-RevId: 297704789
2020-02-27 15:36:13 -08:00
Rahat Mahmood aa9f8abaef Implement automated marshalling for newtypes on arrays.
PiperOrigin-RevId: 297693838
2020-02-27 14:52:26 -08:00
Adin Scannell 8e2b14fecf Use automated release notes, if available.
PiperOrigin-RevId: 297628615
2020-02-27 10:22:41 -08:00
Adin Scannell 10aa4d3b34 Factor platform tags.
PiperOrigin-RevId: 296519566
2020-02-21 15:06:08 -08:00
Zach Koopmans 3733499952 Fix master installer.
Sometimes, when we start a new instance, the file
lock on "apt" is locked. Add a loop to the master
installer.

In addition, the "apt-get install" fails to register
runsc in docker, so run the appropriate scripts to
get that to happen.

Also, add some helpful log messages.

PiperOrigin-RevId: 296497357
2020-02-21 13:18:51 -08:00
gVisor bot f1b72752e5 Implement automated marshalling for newtypes on primitives.
PiperOrigin-RevId: 296322954
2020-02-20 16:23:56 -08:00
gVisor bot d90d71474f Remove bytes read/written from marshal.Marshallable API.
Users of the API only care about whether the copy in/out succeeds in
their entirety, which is already signalled by the returned error.

PiperOrigin-RevId: 296297843
2020-02-20 14:29:26 -08:00
Adin Scannell 72187fa7a9 Import tags.bzl directly from tools/defs.bzl.
This simplifies the script slightly.

PiperOrigin-RevId: 296272077
2020-02-20 12:33:35 -08:00
Adin Scannell 30794512d3 Add basic microbenchmarks.
PiperOrigin-RevId: 296104390
2020-02-19 18:21:54 -08:00
gVisor bot 660cfdff3f Handle situations where go-marshal generates an empty test file.
This can happen due to conditional compilation, where a subset of the
source files contain no marshallable types. go-marshal is still
required to write an output file in these cases, since bazel defines
the output package before calling go-marshal.

PiperOrigin-RevId: 296074321
2020-02-19 15:42:19 -08:00
gVisor bot 737a3d072e go-marshal: Stop complaining about files with no +marshal types.
Since we tag entire packages as marshallable, due to conditional
compiling for different architectures we can end up with sets of
source files that don't contain any marshallable types. It's safe to
silently ignore this scenario.

PiperOrigin-RevId: 295831871
2020-02-18 15:09:17 -08:00
gVisor bot 5cc0bbbafb Ensure Marshallable.SizeBytes() always works on a typed nil pointer.
This lets go-marshal replace various calls to binary.Size() throughout
the sentry without requiring concrete objects.

PiperOrigin-RevId: 295299965
2020-02-15 00:01:02 -08:00
gVisor bot 3d32ad1367 Generate implementation of io.WriterTo via go-marshal.
PiperOrigin-RevId: 295269654
2020-02-14 18:32:49 -08:00
gVisor bot 48d9aa7ab3 Add a minimal binary target for escape analysis on go-marshal.
Note that this is not an automated test.

PiperOrigin-RevId: 295238672
2020-02-14 15:21:03 -08:00
gVisor bot b2e86906ea Fix various issues related to enabling go-marshal.
- Add missing build tags to files in the abi package.

- Add the marshal package as a sentry dependency, allowed by deps_test.

- Fix an issue with our top-level go_library BUILD rule, which
  incorrectly shadows the variable containing the input set of source
  files. This caused the expansion for the go_marshal clause to
  silently omit input files.

- Fix formatting when copying build tags to gomarshal-generated files.

- Fix a bug with import statement collision detection in go-marshal.

PiperOrigin-RevId: 295112284
2020-02-14 03:27:34 -08:00
gVisor bot 336f758d59 Ensure the marshalled object doesn't escape.
Add new Marshallable interface methods CopyIn/CopyOut, which can be directly
called on the marshalled object, avoiding an interface indirection. Such
indirections are problematic because they always cause the marshalled object to
escape.

PiperOrigin-RevId: 295028010
2020-02-13 16:32:23 -08:00
gVisor bot 3ad6d30563 Call py_requirement with named argument for optional kwarg.
PiperOrigin-RevId: 294930818
2020-02-13 09:21:39 -08:00
gVisor bot 9be46e55c2 Stateify: register types with full package names
This is to avoid conflicts with types that share the same
[short] package and type names, e.g. proc.smapsData exist
in pkg/sentry/fs/proc and pkg/sentry/fsimpl/proc.

Updates #1663

PiperOrigin-RevId: 294485146
2020-02-11 11:41:55 -08:00
Adin Scannell dc5a8e52d7 Rename build to builddefs and minor build clean-up.
The name 'bazel' also doesn't work because bazel will treat it specially.

Fixes #1807

PiperOrigin-RevId: 294321221
2020-02-10 15:45:17 -08:00
Brad Burlage 20840bfec0 Move x86 state definition to its own file.
PiperOrigin-RevId: 294271541
2020-02-10 12:00:46 -08:00
Adin Scannell 0efa8168c7 Update visibility.
PiperOrigin-RevId: 294265019
2020-02-10 11:30:21 -08:00
Zach Koopmans 16561e461e Add logic to run from baked images.
Change adds the following:
- logic to run from "baked images". See [GVISOR_DIR]/tools/images
- installers which install modified files from a workspace. This
allows users to run benchmarks while modifying runsc.
- removes the --preemptible tag from built GCE instances. Preemptible
instances are much more likely to be preempted on startup, which
manifests for the user as a failed benchmark. I don't currently have
a way to detect if a VM has been preempted that will work for this
change.
https://cloud.google.com/compute/docs/instances/preemptible#preemption_process
https://cloud.google.com/compute/docs/instances/preemptible#preemption_selection

PiperOrigin-RevId: 293697949
2020-02-06 16:02:48 -08:00
Adin Scannell 1b6a12a768 Add notes to relevant tests.
These were out-of-band notes that can help provide additional context
and simplify automated imports.

PiperOrigin-RevId: 293525915
2020-02-05 22:46:35 -08:00
Adin Scannell 95ce8bb4c7 Automatically propagate tags for stateify and marshal.
Note that files will need to be appropriately segmented in order for the
mechanism to work, in suffixes implying special tags. This only needs to happen
for cases where marshal or state structures are defined, which should be rare
and mostly architecture specific.

PiperOrigin-RevId: 293231579
2020-02-04 14:37:39 -08:00
Adin Scannell 14959250fe Simplify testing link rules.
PiperOrigin-RevId: 292458933
2020-01-30 17:49:17 -08:00
Adin Scannell 0e2f1b7abd Update package locations.
Because the abi will depend on the core types for marshalling (usermem,
context, safemem, safecopy), these need to be flattened from the sentry
directory. These packages contain no sentry-specific details.

PiperOrigin-RevId: 291811289
2020-01-27 15:31:32 -08:00
Adin Scannell 90ec596166 Fix licenses.
The preferred Copyright holder is "The gVisor Authors".

PiperOrigin-RevId: 291786657
2020-01-27 13:23:57 -08:00
Adin Scannell d29e59af9f Standardize on tools directory.
PiperOrigin-RevId: 291745021
2020-01-27 12:21:00 -08:00
Adin Scannell cb3906ae00 Add tools for generating images.
This formalizes the adhoc scripts previously in kokoro. The image targets can
be used by e.g. benchmarks in order to automated image prepation.

PiperOrigin-RevId: 290982744
2020-01-22 10:39:45 -08:00
Fabricio Voznika 1c24201467 Github bug reviver
For everyone's joy, this is a tool that reopens issues that
have been closed, but are still referenced by TODOs in the
code. The idea is to run it in Kokoro nightly. Kokoro changes
are coming up next.

PiperOrigin-RevId: 288789560
2020-01-08 16:06:40 -08:00
gVisor bot d1528df715 Merge pull request #1026 from lubinszARM:pr_savable
PiperOrigin-RevId: 286667216
2019-12-20 18:07:09 -08:00
Adin Scannell d92dc065fd Fix typo in go_branch.sh script.
With the ticks, the command `master` is actually be run and the output included
(which is nothing). This is confusing, as we actually mean to say "master" in
the description of the Go branch.

PiperOrigin-RevId: 282426081
2019-11-25 13:53:27 -08:00
Adin Scannell c0f89eba6e Import and structure cleanup.
PiperOrigin-RevId: 281795269
2019-11-21 11:41:30 -08:00
Adin Scannell 9601943685 release: fix tag script
The tag script, when not run interactively, will fail without a provided commit
message (since it now uses annotated tags). For now, use a trivial message. In
the future, this could be extended to provide automated release notes.

PiperOrigin-RevId: 281112651
2019-11-18 11:22:38 -08:00
Adin Scannell e904823833 Fix repository build scripts.
This fixes a number of issues with the repository build process:

 * Fix the overall structure of the repository.
 * Fix the debian package description.
 * Fix the broken version number for packages.
 * Update the digest algorithm used for signing the release.

I've validated that installation works from a separate staging bucket.

Updates #852

PiperOrigin-RevId: 278716914
2019-11-05 15:16:04 -08:00
Adin Scannell fe2e0764ac Add LICENSE and AUTHORS to the go branch.
Also, construct the README directly so that edits can be made.

PiperOrigin-RevId: 277782095
2019-10-31 12:53:27 -07:00
Bin Lu e9d43f9022 Add tools/go_stateify to support Arm64
2 jobs were finished in this patch:
  1, add a new attribute to specify the target platform.
  2, check the source files that whether we can build this file for target platform by checking file name and build tags.
Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-10-28 09:44:19 +00:00
Kevin Krakauer 2a82d5ad68 Reorder BUILD license and load functions in gvisor.
PiperOrigin-RevId: 275139066
2019-10-16 16:40:30 -07:00