Skip to content

Commit 1d0b44a

Browse files
committed
test(uffd): add test_fault_all_handler_exit
The test verifies that if the fault-all handler exits, the VM is still functional. THe test is mostly relevant to Secret Free VMs. Signed-off-by: Nikita Kalyazin <[email protected]>
1 parent ca6a13b commit 1d0b44a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/integration_tests/functional/test_uffd.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,31 @@ def test_malicious_handler(uvm_plain, snapshot):
142142
assert False, "Firecracker should freeze"
143143
except (TimeoutError, requests.exceptions.ReadTimeout):
144144
vm.uffd_handler.mark_killed()
145+
146+
147+
def test_fault_all_handler_exit(uvm_plain, snapshot):
148+
"""
149+
Test that the VM is functional if the fault-all handler exits
150+
after prepopulating the guest memory.
151+
"""
152+
vm = uvm_plain
153+
vm.memory_monitor = None
154+
vm.spawn()
155+
vm.restore_from_snapshot(snapshot, resume=True, uffd_handler_name="fault_all")
156+
157+
# Verify if the restored guest works.
158+
vm.ssh.check_output("true")
159+
160+
# Kill the UFFD handler.
161+
vm.uffd_handler.kill()
162+
163+
# Verify if the restored guest works after the handler exited.
164+
#
165+
# It is empirically known that invoking `ps` first time after snapshot restore
166+
# will likely trigger an MMIO instruction lookup and emulation on x86
167+
# that walks guest page tables via accessing them through the userspace mapping.
168+
# On Secret Free VMs, we do not preinstall userspace mappings when prepopulating
169+
# guest memory in the fault-all handler. If we fail to unregister all guest memory
170+
# with UFFD on the handler exit, accessing the userspace mapping will trigger
171+
# a UFFD notification that will never be handled.
172+
vm.ssh.check_output("ps")

0 commit comments

Comments
 (0)