Skip to content

Commit f026cfa

Browse files
author
H. Peter Anvin
committed
Revert "x86-64/efi: Use EFI to deal with platform wall clock"
This reverts commit bacef66. This commit has been found to cause serious regressions on a number of ASUS machines at the least. We probably need to provide a 1:1 map in addition to the EFI virtual memory map in order for this to work. Signed-off-by: H. Peter Anvin <[email protected]> Reported-and-bisected-by: Jérôme Carretero <[email protected]> Cc: Jan Beulich <[email protected]> Cc: Matt Fleming <[email protected]> Cc: Matthew Garrett <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
1 parent f1c6300 commit f026cfa

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

arch/x86/mm/pageattr.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -919,13 +919,11 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
919919

920920
/*
921921
* On success we use clflush, when the CPU supports it to
922-
* avoid the wbindv. If the CPU does not support it, in the
923-
* error case, and during early boot (for EFI) we fall back
924-
* to cpa_flush_all (which uses wbinvd):
922+
* avoid the wbindv. If the CPU does not support it and in the
923+
* error case we fall back to cpa_flush_all (which uses
924+
* wbindv):
925925
*/
926-
if (early_boot_irqs_disabled)
927-
__cpa_flush_all((void *)(long)cache);
928-
else if (!ret && cpu_has_clflush) {
926+
if (!ret && cpu_has_clflush) {
929927
if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) {
930928
cpa_flush_array(addr, numpages, cache,
931929
cpa.flags, pages);

arch/x86/platform/efi/efi.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,22 @@ static efi_status_t __init phys_efi_set_virtual_address_map(
234234
return status;
235235
}
236236

237-
static int efi_set_rtc_mmss(unsigned long nowtime)
237+
static efi_status_t __init phys_efi_get_time(efi_time_t *tm,
238+
efi_time_cap_t *tc)
239+
{
240+
unsigned long flags;
241+
efi_status_t status;
242+
243+
spin_lock_irqsave(&rtc_lock, flags);
244+
efi_call_phys_prelog();
245+
status = efi_call_phys2(efi_phys.get_time, virt_to_phys(tm),
246+
virt_to_phys(tc));
247+
efi_call_phys_epilog();
248+
spin_unlock_irqrestore(&rtc_lock, flags);
249+
return status;
250+
}
251+
252+
int efi_set_rtc_mmss(unsigned long nowtime)
238253
{
239254
int real_seconds, real_minutes;
240255
efi_status_t status;
@@ -263,7 +278,7 @@ static int efi_set_rtc_mmss(unsigned long nowtime)
263278
return 0;
264279
}
265280

266-
static unsigned long efi_get_time(void)
281+
unsigned long efi_get_time(void)
267282
{
268283
efi_status_t status;
269284
efi_time_t eft;
@@ -606,13 +621,18 @@ static int __init efi_runtime_init(void)
606621
}
607622
/*
608623
* We will only need *early* access to the following
609-
* EFI runtime service before set_virtual_address_map
624+
* two EFI runtime services before set_virtual_address_map
610625
* is invoked.
611626
*/
627+
efi_phys.get_time = (efi_get_time_t *)runtime->get_time;
612628
efi_phys.set_virtual_address_map =
613629
(efi_set_virtual_address_map_t *)
614630
runtime->set_virtual_address_map;
615-
631+
/*
632+
* Make efi_get_time can be called before entering
633+
* virtual mode.
634+
*/
635+
efi.get_time = phys_efi_get_time;
616636
early_iounmap(runtime, sizeof(efi_runtime_services_t));
617637

618638
return 0;
@@ -700,10 +720,12 @@ void __init efi_init(void)
700720
efi_enabled = 0;
701721
return;
702722
}
723+
#ifdef CONFIG_X86_32
703724
if (efi_native) {
704725
x86_platform.get_wallclock = efi_get_time;
705726
x86_platform.set_wallclock = efi_set_rtc_mmss;
706727
}
728+
#endif
707729

708730
#if EFI_DEBUG
709731
print_efi_memmap();

include/linux/efi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
503503
extern int __init efi_uart_console_only (void);
504504
extern void efi_initialize_iomem_resources(struct resource *code_resource,
505505
struct resource *data_resource, struct resource *bss_resource);
506+
extern unsigned long efi_get_time(void);
507+
extern int efi_set_rtc_mmss(unsigned long nowtime);
506508
extern void efi_reserve_boot_services(void);
507509
extern struct efi_memory_map memmap;
508510

init/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,6 @@ static void __init mm_init(void)
461461
percpu_init_late();
462462
pgtable_cache_init();
463463
vmalloc_init();
464-
#ifdef CONFIG_X86
465-
if (efi_enabled)
466-
efi_enter_virtual_mode();
467-
#endif
468464
}
469465

470466
asmlinkage void __init start_kernel(void)
@@ -606,6 +602,10 @@ asmlinkage void __init start_kernel(void)
606602
calibrate_delay();
607603
pidmap_init();
608604
anon_vma_init();
605+
#ifdef CONFIG_X86
606+
if (efi_enabled)
607+
efi_enter_virtual_mode();
608+
#endif
609609
thread_info_cache_init();
610610
cred_init();
611611
fork_init(totalram_pages);

0 commit comments

Comments
 (0)