Skip to content
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
merged 8 commits into from
Nov 27, 2023

Conversation

00xc
Copy link
Member

@00xc 00xc commented Nov 23, 2023

  • Fix some tests relying on offset_of!() inside the SVSM, as they cause faults due to excessive stack usage.
  • Enable the use of TestRootMem inside the SVSM via cfg(test_in_svsm) gating.
  • Enable a few disabled tests in mm/alloc.
  • Enable RamFS tests.
  • Enable filesystem tests by introducing TestFileSystemGuard.
  • Enable most file mapping tests.
    • Page fault tests do not seem to work, so they stay disabled.

00xc added 3 commits November 23, 2023 14:41
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>
@00xc 00xc marked this pull request as draft November 23, 2023 14:34
00xc added 5 commits November 24, 2023 11:16
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 00xc force-pushed the tests/allocator-in-svsm branch from 575428c to 8513532 Compare November 24, 2023 15:29
@00xc 00xc marked this pull request as ready for review November 24, 2023 15:29
@joergroedel joergroedel merged commit 5adfa49 into coconut-svsm:main Nov 27, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants