-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: enable TestRootMem
for tests inside the SVSM
#165
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Due to how the offset_of crate works, it consumes too much stack when computing offsets, which causes a crash when running tests inside the SVSM. Disable them when this is the case. Signed-off-by: Carlos López <carlos.lopez@suse.com>
Tests relying on the memory allocator need to set up a `TestRootMem` when running in userspace to emulate a regular boot of the SVSM where the heap has been set up. `TestRootMem` simply requests a chunk of memory from the standard Rust allocator and initializes the SVSM root memory. However, when running the tests inside the SVSM, root memory is already set up, as the kernel has booted normally. Thus, do not attempt to reinitialize root memory and simply use the regular allocator. We still use a global lock to keep a consistent API. Do this by gating `TestRootMem::setup()` depending on whether cfg(test_inside_svsm) is set. This allows tests to use `TestRootMem` transparently. Signed-off-by: Carlos López <carlos.lopez@suse.com>
Now that TestRootMem can be used transparently, enable some allocator tests inside the SVSM. Unfortunately, tests that require going out of memory still won't work because it will affect the test runner itself, so keep them disabled for now. Signed-off-by: Carlos López <carlos.lopez@suse.com>
Now that TestRootMem can be used transparently when running tests inside the SVSM, enable all tests. RamFS files no longer need to be dropped manually since the introduction of TestRootMem, so remove explicit calls to drop(). Signed-off-by: Carlos López <carlos.lopez@suse.com>
Introduce a new guard-like struct to handle initialization and destruction of a filesystem for testing. This structure allows writing tests for the filesystem transparently, as it will act as a no-op when running tests inside the SVSM. This is need because in the latter case, the filesystem is already managed by the SVSM kernel. Signed-off-by: Carlos López <carlos.lopez@suse.com>
Now that TestFileSystemGuard has been introduced, enable filesystem tests inside the SVSM. Since the tests are running on the actual filesystem, clean up files to not interfere with other tests that will run afterwards. Filesystem tests cannot interfere with eachother concurrently because they all try to acquire the TestRootMem lock. Signed-off-by: Carlos López <carlos.lopez@suse.com>
There are a lot of uses of the parent submodule, so simply use everything from it. Signed-off-by: Carlos López <carlos.lopez@suse.com>
Enable most file mapping tests when running inside the SVSM. For now, page fault tests do not seem to work, so keep them disabled. This commit also includes a very small refactor in order to be able to properly clean up opened files. Signed-off-by: Carlos López <carlos.lopez@suse.com>
00xc
force-pushed
the
tests/allocator-in-svsm
branch
from
November 24, 2023 15:29
575428c
to
8513532
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
offset_of!()
inside the SVSM, as they cause faults due to excessive stack usage.TestRootMem
inside the SVSM viacfg(test_in_svsm)
gating.mm/alloc
.TestFileSystemGuard
.