diff options
author | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2010-11-16 12:09:59 -0500 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-11-22 15:10:31 -0500 |
commit | ec35a69c467026437519bafcf325a7362e422db9 (patch) | |
tree | 6fbecdd24a347d2abb11bb8ccbc1fb7486090b14 /arch | |
parent | d2a817130cdc142f1c80a8e60eca824a321926af (diff) |
xen: set IO permission early (before early_cpu_init())
This patch is based off "xen dom0: Set up basic IO permissions for dom0."
by Juan Quintela <quintela@redhat.com>.
On AMD machines when we boot the kernel as Domain 0 we get this nasty:
mapping kernel into physical memory
Xen: setup ISA identity maps
about to get started...
(XEN) traps.c:475:d0 Unhandled general protection fault fault/trap [#13] on VCPU 0 [ec=0000]
(XEN) domain_crash_sync called from entry.S
(XEN) Domain 0 (vcpu#0) crashed on cpu#0:
(XEN) ----[ Xen-4.1-101116 x86_64 debug=y Not tainted ]----
(XEN) CPU: 0
(XEN) RIP: e033:[<ffffffff8130271b>]
(XEN) RFLAGS: 0000000000000282 EM: 1 CONTEXT: pv guest
(XEN) rax: 000000008000c068 rbx: ffffffff8186c680 rcx: 0000000000000068
(XEN) rdx: 0000000000000cf8 rsi: 000000000000c000 rdi: 0000000000000000
(XEN) rbp: ffffffff81801e98 rsp: ffffffff81801e50 r8: ffffffff81801eac
(XEN) r9: ffffffff81801ea8 r10: ffffffff81801eb4 r11: 00000000ffffffff
(XEN) r12: ffffffff8186c694 r13: ffffffff81801f90 r14: ffffffffffffffff
(XEN) r15: 0000000000000000 cr0: 000000008005003b cr4: 00000000000006f0
(XEN) cr3: 0000000221803000 cr2: 0000000000000000
(XEN) ds: 0000 es: 0000 fs: 0000 gs: 0000 ss: e02b cs: e033
(XEN) Guest stack trace from rsp=ffffffff81801e50:
RIP points to read_pci_config() function.
The issue is that we don't set IO permissions for the Linux kernel early enough.
The call sequence used to be:
xen_start_kernel()
x86_init.oem.arch_setup = xen_setup_arch;
setup_arch:
- early_cpu_init
- early_init_amd
- read_pci_config
- x86_init.oem.arch_setup [ xen_arch_setup ]
- set IO permissions.
We need to set the IO permissions earlier on, which this patch does.
Acked-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/xen/enlighten.c | 12 | ||||
-rw-r--r-- | arch/x86/xen/setup.c | 8 |
2 files changed, 11 insertions, 9 deletions
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index bd3554934613..7250bef7f49e 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -1095,6 +1095,8 @@ static void __init xen_setup_stackprotector(void) | |||
1095 | /* First C function to be called on Xen boot */ | 1095 | /* First C function to be called on Xen boot */ |
1096 | asmlinkage void __init xen_start_kernel(void) | 1096 | asmlinkage void __init xen_start_kernel(void) |
1097 | { | 1097 | { |
1098 | struct physdev_set_iopl set_iopl; | ||
1099 | int rc; | ||
1098 | pgd_t *pgd; | 1100 | pgd_t *pgd; |
1099 | 1101 | ||
1100 | if (!xen_start_info) | 1102 | if (!xen_start_info) |
@@ -1209,10 +1211,18 @@ asmlinkage void __init xen_start_kernel(void) | |||
1209 | #else | 1211 | #else |
1210 | pv_info.kernel_rpl = 0; | 1212 | pv_info.kernel_rpl = 0; |
1211 | #endif | 1213 | #endif |
1212 | |||
1213 | /* set the limit of our address space */ | 1214 | /* set the limit of our address space */ |
1214 | xen_reserve_top(); | 1215 | xen_reserve_top(); |
1215 | 1216 | ||
1217 | /* We used to do this in xen_arch_setup, but that is too late on AMD | ||
1218 | * were early_cpu_init (run before ->arch_setup()) calls early_amd_init | ||
1219 | * which pokes 0xcf8 port. | ||
1220 | */ | ||
1221 | set_iopl.iopl = 1; | ||
1222 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); | ||
1223 | if (rc != 0) | ||
1224 | xen_raw_printk("physdev_op failed %d\n", rc); | ||
1225 | |||
1216 | #ifdef CONFIG_X86_32 | 1226 | #ifdef CONFIG_X86_32 |
1217 | /* set up basic CPUID stuff */ | 1227 | /* set up basic CPUID stuff */ |
1218 | cpu_detect(&new_cpu_data); | 1228 | cpu_detect(&new_cpu_data); |
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 630fb53c95f3..38fdffaa71d3 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c | |||
@@ -336,9 +336,6 @@ void __cpuinit xen_enable_syscall(void) | |||
336 | 336 | ||
337 | void __init xen_arch_setup(void) | 337 | void __init xen_arch_setup(void) |
338 | { | 338 | { |
339 | struct physdev_set_iopl set_iopl; | ||
340 | int rc; | ||
341 | |||
342 | xen_panic_handler_init(); | 339 | xen_panic_handler_init(); |
343 | 340 | ||
344 | HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments); | 341 | HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments); |
@@ -355,11 +352,6 @@ void __init xen_arch_setup(void) | |||
355 | xen_enable_sysenter(); | 352 | xen_enable_sysenter(); |
356 | xen_enable_syscall(); | 353 | xen_enable_syscall(); |
357 | 354 | ||
358 | set_iopl.iopl = 1; | ||
359 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); | ||
360 | if (rc != 0) | ||
361 | printk(KERN_INFO "physdev_op failed %d\n", rc); | ||
362 | |||
363 | #ifdef CONFIG_ACPI | 355 | #ifdef CONFIG_ACPI |
364 | if (!(xen_start_info->flags & SIF_INITDOMAIN)) { | 356 | if (!(xen_start_info->flags & SIF_INITDOMAIN)) { |
365 | printk(KERN_INFO "ACPI in unprivileged domain disabled\n"); | 357 | printk(KERN_INFO "ACPI in unprivileged domain disabled\n"); |