Re: [V181,22/54] x86/cpu_entry_area: Move it out of fixmap

2017-12-22 Thread Thomas Gleixner
On Thu, 21 Dec 2017, Andrei Vagin wrote:

> Hi Thomas,
> [0.00]   DMA32 zone: 520153 pages, LIFO batch:31
> 
> And then it starts booting again...

Yes. It triple faults. Aside of having made the area one page too small, my
approach of changing this was just naive.

Andrey rescued me and provided the fix below. Thanks again!

Thanks,

tglx

---
 arch/x86/mm/kasan_init_64.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c
index 6353b8d31e6a..47388f0c0e59 100644
--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -323,32 +323,33 @@ void __init kasan_init(void)
map_range(&pfn_mapped[i]);
}
 
-   kasan_populate_zero_shadow(
-   kasan_mem_to_shadow((void *)PAGE_OFFSET + MAXMEM),
-   kasan_mem_to_shadow((void *)__START_KERNEL_map));
-
-   kasan_populate_shadow((unsigned long)kasan_mem_to_shadow(_stext),
- (unsigned long)kasan_mem_to_shadow(_end),
- early_pfn_to_nid(__pa(_stext)));
-
shadow_cpu_entry_begin = (void *)CPU_ENTRY_AREA_BASE;
shadow_cpu_entry_begin = kasan_mem_to_shadow(shadow_cpu_entry_begin);
shadow_cpu_entry_begin = (void *)round_down((unsigned 
long)shadow_cpu_entry_begin,
PAGE_SIZE);
 
shadow_cpu_entry_end = (void *)(CPU_ENTRY_AREA_BASE +
-   CPU_ENTRY_AREA_TOT_SIZE);
+   CPU_ENTRY_AREA_MAP_SIZE);
shadow_cpu_entry_end = kasan_mem_to_shadow(shadow_cpu_entry_end);
shadow_cpu_entry_end = (void *)round_up((unsigned 
long)shadow_cpu_entry_end,
PAGE_SIZE);
 
-   kasan_populate_zero_shadow(kasan_mem_to_shadow((void *)MODULES_END),
-  shadow_cpu_entry_begin);
+   kasan_populate_zero_shadow(
+   kasan_mem_to_shadow((void *)PAGE_OFFSET + MAXMEM),
+   shadow_cpu_entry_begin);
 
kasan_populate_shadow((unsigned long)shadow_cpu_entry_begin,
  (unsigned long)shadow_cpu_entry_end, 0);
 
-   kasan_populate_zero_shadow(shadow_cpu_entry_end, (void 
*)KASAN_SHADOW_END);
+   kasan_populate_zero_shadow(shadow_cpu_entry_end,
+   kasan_mem_to_shadow((void 
*)__START_KERNEL_map));
+
+   kasan_populate_shadow((unsigned long)kasan_mem_to_shadow(_stext),
+ (unsigned long)kasan_mem_to_shadow(_end),
+ early_pfn_to_nid(__pa(_stext)));
+
+   kasan_populate_zero_shadow(kasan_mem_to_shadow((void *)MODULES_END),
+   (void *)KASAN_SHADOW_END);
 
load_cr3(init_top_pgt);
__flush_tlb_all();
-- 
2.13.6





Re: [V181,22/54] x86/cpu_entry_area: Move it out of fixmap

2017-12-21 Thread Andrei Vagin
Hi Thomas,

The kernel with this patch doesn't boot, if CONFIG_KASAN is set:
[0.00] Linux version 4.14.0-00142-g8604322546c0 (avagin@laptop) (gcc 
version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)) #11 SMP Thu Dec 21 18:38:44 PST 
2017
[0.00] Command line: root=/dev/vda2 ro debug console=ttyS0,115200 
LANG=en_US.UTF-8 slub_debug=FZP raid=noautodetect selinux=0 
earlyprintk=serial,ttyS0,115200
[0.00] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point 
registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x008: 'MPX bounds registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x010: 'MPX CSR'
[0.00] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[0.00] x86/fpu: xstate_offset[3]:  832, xstate_sizes[3]:   64
[0.00] x86/fpu: xstate_offset[4]:  896, xstate_sizes[4]:   64
[0.00] x86/fpu: Enabled xstate features 0x1f, context size is 960 
bytes, using 'compacted' format.
[0.00] e820: BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x-0x0009fbff] usable
[0.00] BIOS-e820: [mem 0x0009fc00-0x0009] reserved
[0.00] BIOS-e820: [mem 0x000f-0x000f] reserved
[0.00] BIOS-e820: [mem 0x0010-0x7ffd8fff] usable
[0.00] BIOS-e820: [mem 0x7ffd9000-0x7fff] reserved
[0.00] BIOS-e820: [mem 0xfeffc000-0xfeff] reserved
[0.00] BIOS-e820: [mem 0xfffc-0x] reserved
[0.00] bootconsole [earlyser0] enabled
[0.00] NX (Execute Disable) protection: active
[0.00] random: fast init done
[0.00] SMBIOS 2.8 present.
[0.00] DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1.fc26 
04/01/2014
[0.00] Hypervisor detected: KVM
[0.00] tsc: Fast TSC calibration using PIT
[0.00] e820: update [mem 0x-0x0fff] usable ==> reserved
[0.00] e820: remove [mem 0x000a-0x000f] usable
[0.00] e820: last_pfn = 0x7ffd9 max_arch_pfn = 0x4
[0.00] MTRR default type: write-back
[0.00] MTRR fixed ranges enabled:
[0.00]   0-9 write-back
[0.00]   A-B uncachable
[0.00]   C-F write-protect
[0.00] MTRR variable ranges enabled:
[0.00]   0 base 008000 mask FF8000 uncachable
[0.00]   1 disabled
[0.00]   2 disabled
[0.00]   3 disabled
[0.00]   4 disabled
[0.00]   5 disabled
[0.00]   6 disabled
[0.00]   7 disabled
[0.00] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- WT  
[0.00] found SMP MP-table at [mem 0x000f6bd0-0x000f6bdf] mapped at 
[ff200bd0]
[0.00] Base memory trampoline at [88099000] 99000 size 24576
[0.00] Using GB pages for direct mapping
[0.00] BRK [0x5bf4e000, 0x5bf4efff] PGTABLE
[0.00] BRK [0x5bf4f000, 0x5bf4] PGTABLE
[0.00] BRK [0x5bf5, 0x5bf50fff] PGTABLE
[0.00] BRK [0x5bf51000, 0x5bf51fff] PGTABLE
[0.00] BRK [0x5bf52000, 0x5bf52fff] PGTABLE
[0.00] ACPI: Early table checksum verification disabled
[0.00] ACPI: RSDP 0x000F69C0 14 (v00 BOCHS )
[0.00] ACPI: RSDT 0x7FFE12FF 2C (v01 BOCHS  BXPCRSDT 
0001 BXPC 0001)
[0.00] ACPI: FACP 0x7FFE120B 74 (v01 BOCHS  BXPCFACP 
0001 BXPC 0001)
[0.00] ACPI: DSDT 0x7FFE0040 0011CB (v01 BOCHS  BXPCDSDT 
0001 BXPC 0001)
[0.00] ACPI: FACS 0x7FFE 40
[0.00] ACPI: APIC 0x7FFE127F 80 (v01 BOCHS  BXPCAPIC 
0001 BXPC 0001)
[0.00] ACPI: Local APIC address 0xfee0
[0.00] No NUMA configuration found
[0.00] Faking a node at [mem 0x-0x7ffd8fff]
[0.00] NODE_DATA(0) allocated [mem 0x7ffc2000-0x7ffd8fff]
[0.00] kvm-clock: Using msrs 4b564d01 and 4b564d00
[0.00] kvm-clock: cpu 0, msr 0:7ffc1001, primary cpu clock
[0.00] kvm-clock: using sched offset of 137192604594 cycles
[0.00] clocksource: kvm-clock: mask: 0x max_cycles: 
0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x1000-0x00ff]
[0.00]   DMA32[mem 0x0100-0x7ffd8fff]
[0.00]   Normal   empty
[0.00]   Device   empty
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x1000-0x0009efff]
[0.00]   node   0: [mem 0x0010-0x7ffd8fff]
[0.00] Initmem setup node 0 [mem 0x1000-0x7f