microsoft/openvmm

Public

mirrored fromhttps://github.com/microsoft/openvmmAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e6ecba8b2156c531b0e75aad31180ded04f30973

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

guest_test_uefi/src/uefi/rt.rs

29lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Runtime support for the UEFI application environment.
5
6#[cfg(target_os = "uefi")]
7#[panic_handler]
8fn panic_handler(panic: &core::panic::PanicInfo<'_>) -> ! {
9 use uefi::println;
10
11 println!("{}", panic);
12
13 // If the system table is available, use UEFI's standard shutdown mechanism
14 if uefi::table::system_table_raw().is_none() {
15 use uefi::table::runtime::ResetType;
16 uefi::runtime::reset(ResetType::SHUTDOWN, uefi::Status::ABORTED, None);
17 }
18
19 println!("Could not shut down... falling back to invoking an undefined instruction");
20
21 // SAFETY: the undefined instruction trap handler in `guest_test_uefi` will not return
22 unsafe {
23 #[cfg(target_arch = "x86_64")]
24 core::arch::asm!("ud2");
25 #[cfg(target_arch = "aarch64")]
26 core::arch::asm!("brk #0");
27 core::hint::unreachable_unchecked();
28 }
29}
30