Skip to content

Instantly share code, notes, and snippets.

From e2c7e11c1de7917b2104e27fd222a28ac117319f Mon Sep 17 00:00:00 2001
From: Rob Bradford <[email protected]>
Date: Fri, 12 Jun 2020 16:52:25 +0100
Subject: [PATCH] arch/x86: Only try EFI reboot if booted via EFI
As well as checking for the presence of "noefi" field via
efi_runtime_disabled() also check that the kernel was booted with EFI.
This fixes an issue on Cloud Hypervisor (which uses ACPI
Hardware-Reduced) where the kernel tries to reboot via EFI even though
Bad
rob@kronos:~/src/cloud-hypervisor (2020-06-01-event-idx-enable)$ target/debug/cloud-hypervisor --restore source_url=file:///home/rob/snapshot
cloud-hypervisor: 49.368434ms: ERROR:vm-virtio/src/net.rs:311 -- Listener registered at start
cloud-hypervisor: 49.409287ms: ERROR:vm-virtio/src/net.rs:247 -- RX queue (tap)
cloud-hypervisor: 49.46915ms: ERROR:vm-virtio/src/queue.rs:716 -- Needs notification: true
cloud-hypervisor: 49.503571ms: ERROR:vm-virtio/src/net.rs:250 -- Signalling RX queue
cloud-hypervisor: 368.988478ms: ERROR:vm-virtio/src/net.rs:247 -- RX queue (tap)
cloud-hypervisor: 369.324728ms: ERROR:vm-virtio/src/queue.rs:705 -- used_event = 17 used_idx = 19 old_idx = 18
cloud-hypervisor: 369.395155ms: ERROR:vm-virtio/src/queue.rs:716 -- Needs notification: false
#!/usr/bin/env python2
#
# Author: Craig Chi <[email protected]>
#
import sys
import os
import getopt
from subprocess import check_output
[ 0.346562] virtiofs virtio2: Cache len: 0x0 @ 0x0
[ 0.348653] ------------[ cut here ]------------
[ 0.349878] memremap_pages attempted on mixed region [??? 0x00000000-0xffffffffffffffff flags 0x0]
[ 0.351975] WARNING: CPU: 2 PID: 1 at memremap_pages+0x2de/0x530
[ 0.352467] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.5.0-rc1+ #1
[ 0.352467] RIP: 0010:memremap_pages+0x2de/0x530
[ 0.352467] Code: 48 c7 c0 fc d7 dd 81 48 c7 c6 40 52 c2 81 48 0f 45 d0 49 8d 4c 24 30 48 c7 c7 10 35 e0 81 c6 05 0f 04 e0 00 01 e8 ce a6 e7 ff <0f> 0b e9 87 fe ff ff 48 c7 c7 72 34 e0 81 e8 bb a6 e7 ff 0f 0b 49
[ 0.356510] RSP: 0000:ffffc90000007958 EFLAGS: 00010282
[ 0.356510] RAX: 0000000000000000 RBX: 00000000ffffffff RCX: 00000000000000d4
[ 0.360418] RDX: 0000000000000001 RSI: 0000000000000096 RDI: ffffffff8225636c
DefinitionBlock ("", "DSDT", 6, "CLOUDH", "CHDSDT ", 0x00000001)
{
Device (_SB.PCI0)
{
Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID
Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID
Name (_ADR, Zero) // _ADR: Address
Name (_SEG, Zero) // _SEG: PCI Segment
Name (_UID, Zero) // _UID: Unique ID
Name (SUPP, Zero)
rob@artemis:~/src/linux (virtio-fs-virtio-iommu)$ diff -u config-working-hotplug-reboot .config
--- config-working-hotplug-reboot 2019-12-04 17:06:33.665919837 +0000
+++ .config 2019-12-05 08:32:12.602680837 +0000
@@ -61,6 +61,7 @@
CONFIG_IRQ_DOMAIN_HIERARCHY=y
CONFIG_GENERIC_MSI_IRQ=y
CONFIG_GENERIC_MSI_IRQ_DOMAIN=y
+CONFIG_IRQ_MSI_IOMMU=y
CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR=y
CONFIG_GENERIC_IRQ_RESERVATION_MODE=y
RAX=0000000000000001 RBX=00000000007cc400 RCX=0000000000000000 RDX=0000000000000080
RSI=00000000001029db RDI=00000000001fc338 RBP=0000000000000000 RSP=00000000001fac80
R8 =00000000001029db R9 =0000000000102f72 R10=000000000004b7ff R11=2f2f2f2f2f2f2f2f
R12=00000000005d02a0 R13=00000000005d02a0 R14=00000000000000f0 R15=000000000004b000
RIP=000000000010eefe RFL=00000046 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 0000000000000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 0000000000000000 00000000 00209f00 DPL=0 CS64 [CRA]
SS =0010 0000000000000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 0000000000000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 0000000000000000 ffffffff 00c09300 DPL=0 DS [-WA]
cloud-hypervisor: 554.735766ms: ERROR:vmm/src/cpu.rs:333 -- regs Ok(
kvm_regs {
rax: 0x1,
rbx: 0x7cc400,
rcx: 0x0,
rdx: 0x80,
rsi: 0x1029db,
rdi: 0x1fc338,
rsp: 0x1fac80,
rbp: 0x0,
diff --git a/devices/src/acpi.rs b/devices/src/acpi.rs
index 3165b504..e092e27d 100644
--- a/devices/src/acpi.rs
+++ b/devices/src/acpi.rs
@@ -37,6 +37,8 @@ impl BusDevice for AcpiShutdownDevice {
if let Err(e) = self.reset_evt.write(1) {
error!("Error triggering ACPI reset event: {}", e);
}
+
+ self.reset_evt.write(std::u64::MAX - 1).unwrap();
@rbradford
rbradford / gist:5650a389afce2289e7a6e0527a1cb57b
Created August 22, 2019 15:49
Cloud Hypervisor DSDT ASL
DefinitionBlock ("", "DSDT", 6, "CLOUDH", "CHDSDT ", 0x00000001)
{
Device (_SB.PCI0)
{
Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID
Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID
Name (_ADR, Zero) // _ADR: Address
Name (_SEG, Zero) // _SEG: PCI Segment
Name (_UID, Zero) // _UID: Unique ID
Name (SUPP, Zero)