Commit Graph
47 Commits
Author SHA1 Message Date
Ayush RanjanandgVisor bot bea6d33185 Add state:"nosave" annotation to nvproxy.objsMu.
With this, checkpoint command succeeds on nvproxy containers.

Updates #9363.

PiperOrigin-RevId: 565786118
2023-09-15 14:58:29 -07:00
Ayush RanjanandgVisor bot bdba8c6b69 Add NV0000_CTRL_CMD_SYSTEM_GET_P2P_CAPS to nvproxy.
PiperOrigin-RevId: 553015606
2023-08-01 21:23:05 -07:00
Lucas ManningandgVisor bot bc842b0f12 Implement accel fd methods and gasket ioctls.
The implementation of memory mapping and interrupt registration is
very similar to what's already been done for nvproxy.

PiperOrigin-RevId: 552644264
2023-07-31 18:05:28 -07:00
Lucas ManningandgVisor bot 7ddbcb9847 Add methods for generating PCI sysfs paths and registering accel devices.
The TPU userspace driver needs access to specific PCI device information
located in Linux sysfs. We mirror the sysfs paths the driver reads on the host
in the Sentry sysfs. This way we can ensure we only expose the host device
information that's strictly necessary for TPU to run.

PiperOrigin-RevId: 550005271
2023-07-21 11:43:55 -07:00
Ayush RanjanandgVisor bot 9ed79ed5a2 Add nvproxy support for V100 Nvidia GPUs.
Tested on 1 V100 GPU:
```
$ docker run --runtime=runsc --rm --gpus all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubi8
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
```

PiperOrigin-RevId: 549837326
2023-07-20 22:09:39 -07:00
Lucas ManningandgVisor bot 260ae87823 Add seccomp filters for TPU proxying and stub out accel fd methods.
PiperOrigin-RevId: 549718797
2023-07-20 13:16:46 -07:00
Nayana BidariandgVisor bot 808c547688 Plumb memory cgroup id in memmap.IncRef.
Update the memmap IncRef method to pass memory cgroup id and store it in the
FrameRefSet which will be used for memory accounting. During DecRef, the
memCgID from the FrameRefSet will be retrieved and passed to MemoryLocked.Dec
to remove the memory from the cgroup.

PiperOrigin-RevId: 549656411
2023-07-20 09:39:44 -07:00
Jamie LiuandgVisor bot f1e9a0d209 Pass NV2080_CTRL_CMD_MC_SERVICE_INTERRUPTS through nvproxy.
Fixes #9176

PiperOrigin-RevId: 549125072
2023-07-18 15:18:19 -07:00
Ayush RanjanandgVisor bot 86f6d07833 Add support for A10G Nvidia GPUs.
We were only missing `AMPERE_COMPUTE_B` allocation class.
Verified on an AWS g5.xlarge instance that runsc can at least run basic
vectoradd cuda application.

```
$ docker run --runtime=runsc --rm --gpus all --runtime=runsc nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubi8
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
```

Fixes #9151

PiperOrigin-RevId: 547560783
2023-07-12 11:58:49 -07:00
Jamie LiuandgVisor bot 3308fb0713 Support Nvidia driver 525.105.17.
`git diff` shows no relevant changes in
`src/common/sdk/nvidia/inc/{alloc,class,ctrl}/`,
`src/common/sdk/nvidia/inc/nvos.h`, `kernel-open/common/inc/`, or
`kernel-open/nvidia-uvm/uvm_ioctl.h`. Manually tested with T4, A100, L4.

PiperOrigin-RevId: 540992697
2023-06-16 13:59:20 -07:00
Kevin KrakauerandgVisor bot 8a2b1df3f6 have gVisor use renamed buffer package
PiperOrigin-RevId: 537209194
2023-06-01 21:27:49 -07:00
Ayush RanjanandgVisor bot 03eb16fae7 Add support for Nvidia Hopper GPU architecture.
With this change, we can now run simple CUDA applications on H100 GPUs.

```
$ docker run --runtime=runsc --gpus all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubi8
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
```

Note that this was tested with 525.60.13 driver version.

Updates #14

PiperOrigin-RevId: 534607359
2023-05-23 17:02:31 -07:00
Jamie LiuandgVisor bot 430c4bed01 Add //pkg/sentry/devices/nvproxy and //pkg/abi/nvgpu.
Currently, version 525.60.13 of the open-source driver is required; each driver
version needs to be individually qualified since the kernel driver's ABI is
unstable.

In conjunction with cl/529511919, on T4, A100, or L4 GPUs:

```
$ sudo docker run --gpus all --runtime=runsc nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubi8
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done

$ sudo docker run --gpus all --runtime=runsc -it nvcr.io/nvidia/pytorch:23.04-py3
...
root@ca01b7709883:/workspace# cd examples/upstream/word_language_model/ # see https://github.com/pytorch/examples/tree/main/word_language_model
root@ca01b7709883:/workspace/examples/upstream/word_language_model# python main.py --cuda --epochs 6 --model Transformer --lr 5
| epoch   1 |   200/ 2983 batches | lr 5.00 | ms/batch 10.52 | loss  7.60 | ppl  2003.10
| epoch   1 |   400/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  6.80 | ppl   895.15
| epoch   1 |   600/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  6.50 | ppl   664.17
| epoch   1 |   800/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  6.36 | ppl   576.66
| epoch   1 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.61 | loss  6.26 | ppl   522.67
| epoch   1 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  6.22 | ppl   504.51
| epoch   1 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  6.15 | ppl   466.58
| epoch   1 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  6.15 | ppl   470.48
| epoch   1 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  6.03 | ppl   415.41
| epoch   1 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.72 | loss  6.02 | ppl   412.43
| epoch   1 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.93 | loss  5.93 | ppl   374.53
| epoch   1 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.80 | loss  5.93 | ppl   377.23
| epoch   1 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.74 | loss  5.93 | ppl   375.84
| epoch   1 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  5.84 | ppl   343.92
-----------------------------------------------------------------------------------------
| end of epoch   1 | time: 19.08s | valid loss  5.75 | valid ppl   313.70
-----------------------------------------------------------------------------------------
| epoch   2 |   200/ 2983 batches | lr 5.00 | ms/batch  5.61 | loss  5.80 | ppl   329.43
| epoch   2 |   400/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.77 | ppl   319.79
| epoch   2 |   600/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.62 | ppl   276.16
| epoch   2 |   800/ 2983 batches | lr 5.00 | ms/batch  5.72 | loss  5.63 | ppl   277.32
| epoch   2 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.60 | ppl   270.96
| epoch   2 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.61 | ppl   273.71
| epoch   2 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  5.62 | ppl   275.38
| epoch   2 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.70 | loss  5.66 | ppl   286.58
| epoch   2 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.74 | loss  5.54 | ppl   255.62
| epoch   2 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  5.58 | ppl   264.36
| epoch   2 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  5.48 | ppl   240.27
| epoch   2 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  5.52 | ppl   248.69
| epoch   2 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.53 | ppl   251.46
| epoch   2 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.78 | loss  5.45 | ppl   233.75
-----------------------------------------------------------------------------------------
| end of epoch   2 | time: 18.00s | valid loss  5.53 | valid ppl   252.16
-----------------------------------------------------------------------------------------
| epoch   3 |   200/ 2983 batches | lr 5.00 | ms/batch  5.72 | loss  5.46 | ppl   235.25
| epoch   3 |   400/ 2983 batches | lr 5.00 | ms/batch  5.69 | loss  5.46 | ppl   234.59
| epoch   3 |   600/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.29 | ppl   197.90
| epoch   3 |   800/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.32 | ppl   204.71
| epoch   3 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  5.31 | ppl   201.70
| epoch   3 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.70 | loss  5.33 | ppl   205.88
| epoch   3 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.59 | loss  5.35 | ppl   211.48
| epoch   3 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.40 | ppl   220.79
| epoch   3 |  1800/ 2983 batches | lr 5.00 | ms/batch  6.03 | loss  5.29 | ppl   198.28
| epoch   3 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.63 | loss  5.33 | ppl   206.45
| epoch   3 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.23 | ppl   186.28
| epoch   3 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.77 | loss  5.27 | ppl   194.13
| epoch   3 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.29 | ppl   199.08
| epoch   3 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.75 | loss  5.22 | ppl   184.77
-----------------------------------------------------------------------------------------
| end of epoch   3 | time: 18.10s | valid loss  5.45 | valid ppl   232.50
-----------------------------------------------------------------------------------------
| epoch   4 |   200/ 2983 batches | lr 5.00 | ms/batch  5.71 | loss  5.24 | ppl   189.07
| epoch   4 |   400/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  5.25 | ppl   190.61
| epoch   4 |   600/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.07 | ppl   159.83
| epoch   4 |   800/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.13 | ppl   168.20
| epoch   4 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  5.12 | ppl   166.87
| epoch   4 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.61 | loss  5.13 | ppl   169.07
| epoch   4 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.60 | loss  5.17 | ppl   175.87
| epoch   4 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.70 | loss  5.22 | ppl   184.63
| epoch   4 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.69 | loss  5.12 | ppl   166.77
| epoch   4 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  5.16 | ppl   173.80
| epoch   4 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.71 | loss  5.05 | ppl   155.82
| epoch   4 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.76 | loss  5.10 | ppl   163.49
| epoch   4 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.71 | loss  5.12 | ppl   167.32
| epoch   4 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.05 | ppl   155.76
-----------------------------------------------------------------------------------------
| end of epoch   4 | time: 18.03s | valid loss  5.42 | valid ppl   225.19
-----------------------------------------------------------------------------------------
| epoch   5 |   200/ 2983 batches | lr 5.00 | ms/batch  5.83 | loss  5.08 | ppl   160.77
| epoch   5 |   400/ 2983 batches | lr 5.00 | ms/batch  5.70 | loss  5.09 | ppl   163.02
| epoch   5 |   600/ 2983 batches | lr 5.00 | ms/batch  5.60 | loss  4.92 | ppl   137.13
| epoch   5 |   800/ 2983 batches | lr 5.00 | ms/batch  5.58 | loss  4.97 | ppl   143.72
| epoch   5 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.96 | ppl   142.78
| epoch   5 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.76 | loss  4.98 | ppl   146.04
| epoch   5 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.03 | ppl   153.23
| epoch   5 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.08 | ppl   160.29
| epoch   5 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  4.98 | ppl   145.06
| epoch   5 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  5.02 | ppl   151.17
| epoch   5 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  4.90 | ppl   134.86
| epoch   5 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.61 | loss  4.96 | ppl   142.85
| epoch   5 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  4.98 | ppl   145.94
| epoch   5 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.92 | ppl   136.60
-----------------------------------------------------------------------------------------
| end of epoch   5 | time: 17.99s | valid loss  5.39 | valid ppl   218.33
-----------------------------------------------------------------------------------------
| epoch   6 |   200/ 2983 batches | lr 5.00 | ms/batch  5.60 | loss  4.95 | ppl   140.86
| epoch   6 |   400/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.97 | ppl   143.35
| epoch   6 |   600/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.79 | ppl   120.55
| epoch   6 |   800/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  4.85 | ppl   127.48
| epoch   6 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.84 | ppl   126.87
| epoch   6 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.60 | loss  4.86 | ppl   129.41
| epoch   6 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  4.91 | ppl   135.84
| epoch   6 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.82 | loss  4.96 | ppl   143.08
| epoch   6 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  4.86 | ppl   129.64
| epoch   6 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.57 | loss  4.91 | ppl   134.98
| epoch   6 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.80 | loss  4.79 | ppl   120.01
| epoch   6 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.89 | loss  4.84 | ppl   126.87
| epoch   6 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.79 | loss  4.87 | ppl   130.53
| epoch   6 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  4.81 | ppl   122.77
-----------------------------------------------------------------------------------------
| end of epoch   6 | time: 18.09s | valid loss  5.37 | valid ppl   214.45
-----------------------------------------------------------------------------------------
| End of training | test loss  5.28 | test ppl   195.78

root@ca01b7709883:/workspace/examples/upstream/word_language_model# python generate.py --cuda
| Generated 0/1000 words
| Generated 100/1000 words
| Generated 200/1000 words
| Generated 300/1000 words
| Generated 400/1000 words
| Generated 500/1000 words
| Generated 600/1000 words
| Generated 700/1000 words
| Generated 800/1000 words
| Generated 900/1000 words
```

Updates #14

PiperOrigin-RevId: 534515559
2023-05-23 12:23:14 -07:00
Etienne PerotandgVisor bot c6d19db4e4 Update unimpl.EmitUnimplementedEvent interface to add the syscall number.
This catches up the interface to the `EmitUnimplementedEvent` method signature
on `kernel.Kernel`.

Also add build-time test to verify that `kernel.Kernel` implements this
interface, in order to catch such breakages at build time in the future.

PiperOrigin-RevId: 519000411
2023-03-23 17:01:37 -07:00
Adin ScannellandgVisor bot 2911d8c3b8 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Lucas ManningandgVisor bot 76dc7422d5 Fix tun reference counting.
The tun code does not properly abide by reference counting rules. Change it
so the ownership is more clear and to prevent potential use-after-free.

PiperOrigin-RevId: 482865862
2022-10-21 12:56:42 -07:00
Lucas ManningandgVisor bot 57f173fcec Refactor netstack to use bufferv2 instead of buffer.
This change has significant performance implications. bufferv2 is reference
counted and pooled, which alleviates heap/GC pressure. Below are the results
from running the iperf benchmark.

HEAD:
BenchmarkIperf/operation.Upload-16    1552  ns/op   46.6GiB total allocations
BenchmarkIperf/operation.Download-16  1114  ns/op   68.6GiB total allocations

w/ change:
BenchmarkIperf/operation.Upload-16    1139  ns/op (-27%)   1.41GiB total allocations (-97%)
BenchmarkIperf/operation.Download-16  753.2 ns/op (-33%)   706MiB  total allocations (-99%)

PiperOrigin-RevId: 462453185
2022-07-21 13:09:31 -07:00
Kevin KrakauerandgVisor bot b8dd528b97 prohibit direct use of sync/atomic (u)int64 functions
All atomic 64 bit ints are changed to atomicbitops.(Ui|I)nt64. A nogo checker
enforces that sync/atomic 64 bit functions are not called.

For reviewers: the interesting changes are in the atomicbitops and checkaligned
packages.

Why do this?
- It is very easy to accidentally use atomic values without sync/atomic funcs.
- We have checkatomics, but this is optional and is forgotten in several places.
  - Using a type+checker to enforce this seems less error prone and simpler.
- We get NoCopy protection.
- Use of 64 bit atomics can break 32 bit builds. We have types to handle this
  without any runtime cost, so we might as well use them.

PiperOrigin-RevId: 440473398
2022-04-08 16:06:26 -07:00
Andrei VaginandgVisor bot 7021551370 tun: reject packets larger MTU
Reported-by: [email protected]
PiperOrigin-RevId: 429508995
2022-02-18 01:48:29 -08:00
Fabricio VoznikaandgVisor bot 9725ff1d9b Fix epoll_ctl(2) regular files and dirs
Linux behaves differently for regular files and dirs for poll(2)/select(2)
compared to epoll_ctl(2). The latter returns EPERM for file and dirs.
I've also changed host FDs to behave like the underlying FD in regards
to epoll to keep it compatible with docker.

Fixes #7134

PiperOrigin-RevId: 429412692
2022-02-17 15:12:36 -08:00
Ayush RanjanandgVisor bot a3efa4b3cf Handle 0 sized writes to /dev/net/tun.
Reported-by: [email protected]
PiperOrigin-RevId: 422944054
2022-01-19 17:41:04 -08:00
Fabricio VoznikaandgVisor bot cecd7315bc Don't eat error from epoll_ctl EPOLL_CTL_ADD
Docker maps stdin to `/dev/null` which doesn't support epoll. Host FD
was ignoring the error and suceeding the epoll_ctl call from the
container, giving false impressing that epoll would be notified.

This required plumbing failure to all waiter.Waitable.EventRegister
callers and implementers.

Closes #6795

PiperOrigin-RevId: 414797621
2021-12-07 12:36:00 -08:00
Adin ScannellandgVisor bot 4967b16af9 Update Waitable API.
Instead of passing the event mask at registratrion time, pass the mask as part
of the waiter. This makes the mask immutable and simplifies the architecture of
waiters. This is also necessary for a future fix that will allow the fdnotifier
to keep persistent entries, as opposed to requiring constant updates.

This change is intended to be a no-op in terms of function. The only exception
is signalfd, where this mask was abused. To handle this case, the operation of
signalfd changed to allow one layer of indirection.

PiperOrigin-RevId: 409702998
2021-11-13 12:54:39 -08:00
Chong CaiandgVisor bot 29549645e3 Remove quotedev device
PiperOrigin-RevId: 392982220
2021-08-25 14:39:21 -07:00
Zach KoopmansandgVisor bot f26a93e634 [syserror] Convert remaining syserror definitions to linuxerr.
Convert remaining public errors (e.g. EINTR) from syserror to linuxerr.

PiperOrigin-RevId: 390471763
2021-08-12 15:19:12 -07:00
Zach KoopmansandgVisor bot 5e6d494c2f [syserror] Update syserror to linuxerr for more errors.
Update the following from syserror to the linuxerr equivalent:
EEXIST
EFAULT
ENOTDIR
ENOTTY
EOPNOTSUPP
ERANGE
ESRCH

PiperOrigin-RevId: 384329869
2021-07-12 15:26:20 -07:00
Zach KoopmansandgVisor bot 895c2eaa09 [syserror] Update syserror to linuxerr for EACCES, EBADF, and EPERM.
Update all instances of the above errors to the faster linuxerr implementation.
With the temporary linuxerr.Equals(), no logical changes are made.

PiperOrigin-RevId: 382306655
2021-06-30 08:18:59 -07:00
Zach KoopmansandgVisor bot cd84634cc0 [syserror] Change syserror to linuxerr for E2BIG, EADDRINUSE, and EINVAL
Remove three syserror entries duplicated in linuxerr. Because of the
linuxerr.Equals method, this is a mere change of return values from
syserror to linuxerr definitions.

Done with only these three errnos as CLs removing all grow to a significantly
large size.

PiperOrigin-RevId: 382173835
2021-06-29 15:08:46 -07:00
gVisor bot 3ad25c8557 Internal change.
PiperOrigin-RevId: 373221316
2021-05-11 13:30:18 -07:00
gVisor bot 7feadd701c Internal change.
PiperOrigin-RevId: 366462448
2021-04-02 09:58:19 -07:00
Zach KoopmansandgVisor bot d8f34027b3 [syserror] Split usermem package
Split usermem package to help remove syserror dependency in go_marshal.
New hostarch package contains code not dependent on syserror.

PiperOrigin-RevId: 365651233
2021-03-29 13:30:21 -07:00
Kevin KrakauerandgVisor bot 89f5fc017d Make netstack (//pkg/tcpip) buildable for 32 bit
Doing so involved breaking dependencies between //pkg/tcpip and the rest
of gVisor, which are discouraged anyways.

Tested on the Go branch via:
  gvisor.dev/gvisor/pkg/tcpip/...

Addresses #1446.

PiperOrigin-RevId: 363081778
2021-03-15 18:49:59 -07:00
Ghanan GowripalanandgVisor bot deed0d929c Remove ARP address workaround
- Make AddressableEndpoint optional for NetworkEndpoint.
Not all NetworkEndpoints need to support addressing (e.g. ARP), so
AddressableEndpoint should only be implemented for protocols that
support addressing such as IPv4 and IPv6.

With this change, tcpip.ErrNotSupported will be returned by the stack
when attempting to modify addresses on a network endpoint that does
not support addressing.

Now that packets are fully handled at the network layer, and (with this
change) addresses are optional for network endpoints, we no longer need
the workaround for ARP where a fake ARP address was added to each NIC
that performs ARP so that packets would be delivered to the ARP layer.

PiperOrigin-RevId: 342722547
2020-11-16 14:36:10 -08:00
Jamie LiuandgVisor bot 114d68adb8 Support VFS2 save/restore.
Inode number consistency checks are now skipped in save/restore tests for
reasons described in greatest detail in StatTest.StateDoesntChangeAfterRename.
They pass in VFS1 due to the bug described in new test case
SimpleStatTest.DifferentFilesHaveDifferentDeviceInodeNumberPairs.

Fixes #1663

PiperOrigin-RevId: 338776148
2020-10-23 17:48:33 -07:00
Ghanan GowripalanandgVisor bot fb2cbb815d Automated rollback of changelist 336304024
PiperOrigin-RevId: 336339194
2020-10-09 12:09:12 -07:00
Bhasker HariharanandgVisor bot 265a36a8c2 Automated rollback of changelist 336185457
PiperOrigin-RevId: 336304024
2020-10-09 09:11:18 -07:00
Ghanan GowripalanandgVisor bot 7b7c276f6e Do not resolve routes immediately
When a response needs to be sent to an incoming packet, the stack should
consult its neighbour table to determine the remote address's link
address.

When an entry does not exist in the stack's neighbor table, the stack
should queue the packet while link resolution completes. See comments.

PiperOrigin-RevId: 336185457
2020-10-08 16:15:59 -07:00
Adin ScannellandgVisor bot 75df87e081 Add basic stateify annotations.
Updates #1663

PiperOrigin-RevId: 333539293
2020-09-24 10:13:04 -07:00
Jamie LiuandgVisor bot f943ff48de Use a tmpfs file for shared anonymous and /dev/zero mmap on VFS2.
This is more consistent with Linux (see comment on MM.NewSharedAnonMappable()).
We don't do the same thing on VFS1 for reasons documented by the updated
comment.

PiperOrigin-RevId: 332514849
2020-09-18 13:25:35 -07:00
Ayush RanjanandgVisor bot 5bfafe797a [go-marshal] Enable auto-marshalling for tundev.
PiperOrigin-RevId: 328863725
2020-08-27 19:27:18 -07:00
Ayush RanjanandgVisor bot 23c69cd610 [vfs] Return EIO when opening /dev/tty.
This is in compliance with VFS1. See pkg/sentry/fs/dev/tty.go in the struct
ttyInodeOperations.

Fixes the failure of python runtime test_ioctl.
Updates #3515

PiperOrigin-RevId: 327042758
2020-08-17 10:05:43 -07:00
Dean DengandgVisor bot bcc51b091b Only register /dev/net/tun if supported.
PiperOrigin-RevId: 325266487
2020-08-06 11:03:04 -07:00
Nayana BidariandgVisor bot 4a8d0d3f20 Plumbing context.Context to DecRef() and Release().
context is passed to DecRef() and Release() which is
needed for SO_LINGER implementation.

PiperOrigin-RevId: 324672584
2020-08-03 13:36:05 -07:00
Nicolas LacasseandgVisor bot ed24eb37ee Port /dev/net/tun device to VFS2.
Updates #2912 #1035

PiperOrigin-RevId: 318162565
2020-06-24 16:23:44 -07:00
Nicolas LacasseandgVisor bot 966d2e6930 Port /dev/tty device to VFS2.
Support is limited to the functionality that exists in VFS1.

Updates #2923 #1035

PiperOrigin-RevId: 317981417
2020-06-23 18:48:37 -07:00
Fabricio VoznikaandgVisor bot d12598b851 Implement flock(2) in VFS2
LockFD is the generic implementation that can be embedded in
FileDescriptionImpl implementations. Unique lock ID is
maintained in vfs.FileDescription and is created on demand.

Updates #1480

PiperOrigin-RevId: 315604825
2020-06-09 18:46:42 -07:00
Jamie LiuandgVisor bot b5c61c6257 Add //pkg/sentry/devices/memdev.
PiperOrigin-RevId: 292165063
2020-01-29 10:09:31 -08:00