Skip to content

Commit

Permalink
Aarch64: add halt_handler closure implementation
Browse files Browse the repository at this point in the history
In an Aarch64 VM, if the Angel shutdown command is not supported,
it generates an exception, which is logged by the kernel. With the
existing code, when shutting down a VM which does not support the
Angel shutdown command (for example, on Apple M1 and M2 machines),
a "QEMU exit code will not reflect program exit code" error message
is output by the kernel, even if the "debug_exit" option is not
specified in the manifest.
This change adds a halt_handler implementation to the Aarch64
platform, so that the Angel shutdown command is only executed if
the "debug_exit" option is specified. This removes the above error
message when the option is not specified. In addition, the
`-t "(debug_exit:t)"` command line option for the mkfs invocation
in the Makefile is being moved before the `$(IMAGE)` argument: this
allows this option to be properly parsed on OSes (such as MacOS)
where option arguments specified after non-option arguments are
ignored.
  • Loading branch information
francescolavra committed Nov 11, 2023
1 parent 04e7081 commit b66be2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion platform/virt/Makefile
Expand Up @@ -322,7 +322,7 @@ ifeq ($(IMAGE),)
endif
@ echo "MKFS $@"
@ $(MKDIR) $(dir $(IMAGE))
$(Q) cd $(ROOTDIR); $(AWK) 'BEGIN{getline l < "$(PLATFORMDIR)/test-libs"}/TEST-LIBS/{gsub("TEST-LIBS",l)}1' $(ROOTDIR)/test/runtime/$(TARGET).manifest | $(MKFS) $(TARGET_ROOT_OPT) -b $(BOOTIMG) $(MKFS_UEFI) -k $(KERNEL) $(TRACELOG_MKFS_OPTS) $(IMAGE) -t "(debug_exit:t)"
$(Q) cd $(ROOTDIR); $(AWK) 'BEGIN{getline l < "$(PLATFORMDIR)/test-libs"}/TEST-LIBS/{gsub("TEST-LIBS",l)}1' $(ROOTDIR)/test/runtime/$(TARGET).manifest | $(MKFS) $(TARGET_ROOT_OPT) -b $(BOOTIMG) $(MKFS_UEFI) -k $(KERNEL) $(TRACELOG_MKFS_OPTS) -t "(debug_exit:t)" $(IMAGE)

release: mkfs kernel
$(Q) $(RM) -r release
Expand Down
16 changes: 7 additions & 9 deletions platform/virt/service.c
Expand Up @@ -222,21 +222,15 @@ void reclaim_regions(void)
{
}

extern filesystem root_fs;

static inline void virt_shutdown(u64 code)
closure_function(0, 1, void, psci_vm_halt,
int, status)
{
tuple root = get_root_tuple();
if (root) {
if (!get(root, sym(psci)))
angel_shutdown(code);
}
psci_shutdown();
}

void vm_shutdown(u8 code)
{
virt_shutdown(code);
angel_shutdown(code);
while (1);
}

Expand Down Expand Up @@ -372,4 +366,8 @@ void detect_devices(kernel_heaps kh, storage_attach sa)
init_virtio_rng(kh);
init_virtio_9p(kh);
init_virtio_socket(kh);
if (!vm_halt) {
vm_halt = closure(heap_locked(kh), psci_vm_halt);
assert(vm_halt != INVALID_ADDRESS);
}
}

0 comments on commit b66be2b

Please sign in to comment.