mirror of
https://github.com/torvalds/linux.git
synced 2024-12-14 23:25:54 +00:00
e371fd7607
When rebooting DOM0 with ACPI on ARM64, the kernel is crashing with the stack trace [1]. This is happening because when EFI runtimes are enabled, the reset code (see machine_restart) will first try to use EFI restart method. However, the EFI restart code is expecting the reset_system callback to be always set. This is not the case for Xen and will lead to crash. The EFI restart helper is used in multiple places and some of them don't not have fallback (see machine_power_off). So implement reset_system callback as a call to xen_reboot when using EFI Xen. [ 36.999270] reboot: Restarting system [ 37.002921] Internal error: Attempting to execute userspace memory: 86000004 [#1] PREEMPT SMP [ 37.011460] Modules linked in: [ 37.014598] CPU: 0 PID: 1 Comm: systemd-shutdow Not tainted 4.11.0-rc1-00003-g1e248b60a39b-dirty #506 [ 37.023903] Hardware name: (null) (DT) [ 37.027734] task: ffff800902068000 task.stack: ffff800902064000 [ 37.033739] PC is at 0x0 [ 37.036359] LR is at efi_reboot+0x94/0xd0 [ 37.040438] pc : [<0000000000000000>] lr : [<ffff00000880f2c4>] pstate: 404001c5 [ 37.047920] sp : ffff800902067cf0 [ 37.051314] x29: ffff800902067cf0 x28: ffff800902068000 [ 37.056709] x27: ffff000008992000 x26: 000000000000008e [ 37.062104] x25: 0000000000000123 x24: 0000000000000015 [ 37.067499] x23: 0000000000000000 x22: ffff000008e6e250 [ 37.072894] x21: ffff000008e6e000 x20: 0000000000000000 [ 37.078289] x19: ffff000008e5d4c8 x18: 0000000000000010 [ 37.083684] x17: 0000ffffa7c27470 x16: 00000000deadbeef [ 37.089079] x15: 0000000000000006 x14: ffff000088f42bef [ 37.094474] x13: ffff000008f42bfd x12: ffff000008e706c0 [ 37.099870] x11: ffff000008e70000 x10: 0000000005f5e0ff [ 37.105265] x9 : ffff800902067a50 x8 : 6974726174736552 [ 37.110660] x7 : ffff000008cc6fb8 x6 : ffff000008cc6fb0 [ 37.116055] x5 : ffff000008c97dd8 x4 : 0000000000000000 [ 37.121453] x3 : 0000000000000000 x2 : 0000000000000000 [ 37.126845] x1 : 0000000000000000 x0 : 0000000000000000 [ 37.132239] [ 37.133808] Process systemd-shutdow (pid: 1, stack limit = 0xffff800902064000) [ 37.141118] Stack: (0xffff800902067cf0 to 0xffff800902068000) [ 37.146949] 7ce0: ffff800902067d40 ffff000008085334 [ 37.154869] 7d00: 0000000000000000 ffff000008f3b000 ffff800902067d40 ffff0000080852e0 [ 37.162787] 7d20: ffff000008cc6fb0 ffff000008cc6fb8 ffff000008c7f580 ffff000008c97dd8 [ 37.170706] 7d40: ffff800902067d60 ffff0000080e2c2c 0000000000000000 0000000001234567 [ 37.178624] 7d60: ffff800902067d80 ffff0000080e2ee8 0000000000000000 ffff0000080e2df4 [ 37.186544] 7d80: 0000000000000000 ffff0000080830f0 0000000000000000 00008008ff1c1000 [ 37.194462] 7da0: ffffffffffffffff 0000ffffa7c4b1cc 0000000000000000 0000000000000024 [ 37.202380] 7dc0: ffff800902067dd0 0000000000000005 0000fffff24743c8 0000000000000004 [ 37.210299] 7de0: 0000fffff2475f03 0000000000000010 0000fffff2474418 0000000000000005 [ 37.218218] 7e00: 0000fffff2474578 000000000000000a 0000aaaad6b722c0 0000000000000001 [ 37.226136] 7e20: 0000000000000123 0000000000000038 ffff800902067e50 ffff0000081e7294 [ 37.234055] 7e40: ffff800902067e60 ffff0000081e935c ffff800902067e60 ffff0000081e9388 [ 37.241973] 7e60: ffff800902067eb0 ffff0000081ea388 0000000000000000 00008008ff1c1000 [ 37.249892] 7e80: ffffffffffffffff 0000ffffa7c4a79c 0000000000000000 ffff000000020000 [ 37.257810] 7ea0: 0000010000000004 0000000000000000 0000000000000000 ffff0000080830f0 [ 37.265729] 7ec0: fffffffffee1dead 0000000028121969 0000000001234567 0000000000000000 [ 37.273651] 7ee0: ffffffffffffffff 8080000000800000 0000800000008080 feffa9a9d4ff2d66 [ 37.281567] 7f00: 000000000000008e feffa9a9d5b60e0f 7f7fffffffff7f7f 0101010101010101 [ 37.289485] 7f20: 0000000000000010 0000000000000008 000000000000003a 0000ffffa7ccf588 [ 37.297404] 7f40: 0000aaaad6b87d00 0000ffffa7c4b1b0 0000fffff2474be0 0000aaaad6b88000 [ 37.305326] 7f60: 0000fffff2474fb0 0000000001234567 0000000000000000 0000000000000000 [ 37.313240] 7f80: 0000000000000000 0000000000000001 0000aaaad6b70d4d 0000000000000000 [ 37.321159] 7fa0: 0000000000000001 0000fffff2474ea0 0000aaaad6b5e2e0 0000fffff2474e80 [ 37.329078] 7fc0: 0000ffffa7c4b1cc 0000000000000000 fffffffffee1dead 000000000000008e [ 37.336997] 7fe0: 0000000000000000 0000000000000000 9ce839cffee77eab fafdbf9f7ed57f2f [ 37.344911] Call trace: [ 37.347437] Exception stack(0xffff800902067b20 to 0xffff800902067c50) [ 37.353970] 7b20: ffff000008e5d4c8 0001000000000000 0000000080f82000 0000000000000000 [ 37.361883] 7b40: ffff800902067b60 ffff000008e17000 ffff000008f44c68 00000001081081b4 [ 37.369802] 7b60: ffff800902067bf0 ffff000008108478 0000000000000000 ffff000008c235b0 [ 37.377721] 7b80: ffff800902067ce0 0000000000000000 0000000000000000 0000000000000015 [ 37.385643] 7ba0: 0000000000000123 000000000000008e ffff000008992000 ffff800902068000 [ 37.393557] 7bc0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 [ 37.401477] 7be0: 0000000000000000 ffff000008c97dd8 ffff000008cc6fb0 ffff000008cc6fb8 [ 37.409396] 7c00: 6974726174736552 ffff800902067a50 0000000005f5e0ff ffff000008e70000 [ 37.417318] 7c20: ffff000008e706c0 ffff000008f42bfd ffff000088f42bef 0000000000000006 [ 37.425234] 7c40: 00000000deadbeef 0000ffffa7c27470 [ 37.430190] [< (null)>] (null) [ 37.434982] [<ffff000008085334>] machine_restart+0x6c/0x70 [ 37.440550] [<ffff0000080e2c2c>] kernel_restart+0x6c/0x78 [ 37.446030] [<ffff0000080e2ee8>] SyS_reboot+0x130/0x228 [ 37.451337] [<ffff0000080830f0>] el0_svc_naked+0x24/0x28 [ 37.456737] Code: bad PC value [ 37.459891] ---[ end trace 76e2fc17e050aecd ]--- Signed-off-by: Julien Grall <julien.grall@arm.com> -- Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Juergen Gross <jgross@suse.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: x86@kernel.org The x86 code has theoritically a similar issue, altought EFI does not seem to be the preferred method. I have only built test it on x86. This should also probably be fixed in stable tree. Changes in v2: - Implement xen_efi_reset_system using xen_reboot - Move xen_efi_reset_system in drivers/xen/efi.c Signed-off-by: Juergen Gross <jgross@suse.com>
157 lines
5.4 KiB
C
157 lines
5.4 KiB
C
/*
|
|
* Copyright (c) 2014 Oracle Co., Daniel Kiper
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <linux/bitops.h>
|
|
#include <linux/efi.h>
|
|
#include <linux/init.h>
|
|
#include <linux/string.h>
|
|
|
|
#include <xen/xen.h>
|
|
#include <xen/xen-ops.h>
|
|
#include <xen/interface/platform.h>
|
|
|
|
#include <asm/page.h>
|
|
#include <asm/setup.h>
|
|
#include <asm/xen/hypercall.h>
|
|
|
|
static efi_char16_t vendor[100] __initdata;
|
|
|
|
static efi_system_table_t efi_systab_xen __initdata = {
|
|
.hdr = {
|
|
.signature = EFI_SYSTEM_TABLE_SIGNATURE,
|
|
.revision = 0, /* Initialized later. */
|
|
.headersize = 0, /* Ignored by Linux Kernel. */
|
|
.crc32 = 0, /* Ignored by Linux Kernel. */
|
|
.reserved = 0
|
|
},
|
|
.fw_vendor = EFI_INVALID_TABLE_ADDR, /* Initialized later. */
|
|
.fw_revision = 0, /* Initialized later. */
|
|
.con_in_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
|
|
.con_in = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
|
|
.con_out_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
|
|
.con_out = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
|
|
.stderr_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
|
|
.stderr = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
|
|
.runtime = (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
|
|
/* Not used under Xen. */
|
|
.boottime = (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
|
|
/* Not used under Xen. */
|
|
.nr_tables = 0, /* Initialized later. */
|
|
.tables = EFI_INVALID_TABLE_ADDR /* Initialized later. */
|
|
};
|
|
|
|
static const struct efi efi_xen __initconst = {
|
|
.systab = NULL, /* Initialized later. */
|
|
.runtime_version = 0, /* Initialized later. */
|
|
.mps = EFI_INVALID_TABLE_ADDR,
|
|
.acpi = EFI_INVALID_TABLE_ADDR,
|
|
.acpi20 = EFI_INVALID_TABLE_ADDR,
|
|
.smbios = EFI_INVALID_TABLE_ADDR,
|
|
.smbios3 = EFI_INVALID_TABLE_ADDR,
|
|
.sal_systab = EFI_INVALID_TABLE_ADDR,
|
|
.boot_info = EFI_INVALID_TABLE_ADDR,
|
|
.hcdp = EFI_INVALID_TABLE_ADDR,
|
|
.uga = EFI_INVALID_TABLE_ADDR,
|
|
.uv_systab = EFI_INVALID_TABLE_ADDR,
|
|
.fw_vendor = EFI_INVALID_TABLE_ADDR,
|
|
.runtime = EFI_INVALID_TABLE_ADDR,
|
|
.config_table = EFI_INVALID_TABLE_ADDR,
|
|
.get_time = xen_efi_get_time,
|
|
.set_time = xen_efi_set_time,
|
|
.get_wakeup_time = xen_efi_get_wakeup_time,
|
|
.set_wakeup_time = xen_efi_set_wakeup_time,
|
|
.get_variable = xen_efi_get_variable,
|
|
.get_next_variable = xen_efi_get_next_variable,
|
|
.set_variable = xen_efi_set_variable,
|
|
.query_variable_info = xen_efi_query_variable_info,
|
|
.update_capsule = xen_efi_update_capsule,
|
|
.query_capsule_caps = xen_efi_query_capsule_caps,
|
|
.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
|
|
.reset_system = xen_efi_reset_system,
|
|
.set_virtual_address_map = NULL, /* Not used under Xen. */
|
|
.flags = 0 /* Initialized later. */
|
|
};
|
|
|
|
static efi_system_table_t __init *xen_efi_probe(void)
|
|
{
|
|
struct xen_platform_op op = {
|
|
.cmd = XENPF_firmware_info,
|
|
.u.firmware_info = {
|
|
.type = XEN_FW_EFI_INFO,
|
|
.index = XEN_FW_EFI_CONFIG_TABLE
|
|
}
|
|
};
|
|
union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
|
|
|
|
if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
|
|
return NULL;
|
|
|
|
/* Here we know that Xen runs on EFI platform. */
|
|
|
|
efi = efi_xen;
|
|
|
|
efi_systab_xen.tables = info->cfg.addr;
|
|
efi_systab_xen.nr_tables = info->cfg.nent;
|
|
|
|
op.cmd = XENPF_firmware_info;
|
|
op.u.firmware_info.type = XEN_FW_EFI_INFO;
|
|
op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
|
|
info->vendor.bufsz = sizeof(vendor);
|
|
set_xen_guest_handle(info->vendor.name, vendor);
|
|
|
|
if (HYPERVISOR_platform_op(&op) == 0) {
|
|
efi_systab_xen.fw_vendor = __pa_symbol(vendor);
|
|
efi_systab_xen.fw_revision = info->vendor.revision;
|
|
} else
|
|
efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
|
|
|
|
op.cmd = XENPF_firmware_info;
|
|
op.u.firmware_info.type = XEN_FW_EFI_INFO;
|
|
op.u.firmware_info.index = XEN_FW_EFI_VERSION;
|
|
|
|
if (HYPERVISOR_platform_op(&op) == 0)
|
|
efi_systab_xen.hdr.revision = info->version;
|
|
|
|
op.cmd = XENPF_firmware_info;
|
|
op.u.firmware_info.type = XEN_FW_EFI_INFO;
|
|
op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
|
|
|
|
if (HYPERVISOR_platform_op(&op) == 0)
|
|
efi.runtime_version = info->version;
|
|
|
|
return &efi_systab_xen;
|
|
}
|
|
|
|
void __init xen_efi_init(void)
|
|
{
|
|
efi_system_table_t *efi_systab_xen;
|
|
|
|
efi_systab_xen = xen_efi_probe();
|
|
|
|
if (efi_systab_xen == NULL)
|
|
return;
|
|
|
|
strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
|
|
sizeof(boot_params.efi_info.efi_loader_signature));
|
|
boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
|
|
boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
|
|
|
|
set_bit(EFI_BOOT, &efi.flags);
|
|
set_bit(EFI_PARAVIRT, &efi.flags);
|
|
set_bit(EFI_64BIT, &efi.flags);
|
|
}
|