From: Konrad Rzeszutek Wilk Date: Fri, 19 Aug 2016 15:06:44 +0000 (-0400) Subject: x86/xen: Add x86_platform.is_untracked_pat_range quirk to ignore ISA regions. X-Git-Tag: v4.1.12-92~86^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2fd36bd959fc8b9d8fc0bbe7347a4e8f1f07e5ee;p=users%2Fjedix%2Flinux-maple.git x86/xen: Add x86_platform.is_untracked_pat_range quirk to ignore ISA regions. On x86 whenever VMAs are setup, the 'is_ISA_range quirk' (which this patch re-implements) is used to figure whether to ignore the requested PAT type and always use WB (see 'reserve_memtype'). Specifically it forces the WB type for any region in the ISA space. From the Intel SDM, the combination of MTRR (UC, which is setup by the BIOS) and PAT (UC or WB) for the ISA region ends up with the same value - UC. However on Xen, due to XSA 154 we enforce that mappings that _ANY_ pagetable entry to MMIO ranges MUST have the same the same cachability mapping - and in this case we enforce UC. Which means that with XSA 154 (and without this patch) any application that maps /dev/mem to get SMBIOS information (like mcelog), and pokes in the ISA region will not have an PTE set. That is due to reserve_pfn_range returning -EINVAL which results in the PTE not being set. [These are debug entries added in 'reserve_pfn_range'] mcelog:2471 0xf0000->0xf1000, req_type=write-back new_type=write-back mcelog:2471 0xeb000->0xed000, req_type=write-back new_type=write-back .. above are successfull ones, but: mcelog:2471 0xeb000->0xed000, req_type=uncached new_type=uncached [again, a debug one:] mcelog:2471 want=uncached got=write-back strict 0x000eb000-0x000ecfff mcelog:2471 map pfn expected mapping type uncached for [mem 0x000eb000-0x000ecfff], got write-back ------------[ cut here ]------------ [] dump_stack+0x63/0x83 [] warn_slowpath_common+0x95/0xe0 [] warn_slowpath_null+0x1a/0x20 [] untrack_pfn+0x93/0xc0 [] unmap_single_vma+0xa9/0x100 [] unmap_vmas+0x54/0xa0 [] exit_mmap+0x9a/0x150 [] mmput+0x73/0x110 [] dup_mm+0x105/0x110 [] copy_process+0x11ed/0x1240 [] do_fork+0x79/0x280 [] ? syscall_trace_enter_phase1+0x153/0x180 [] SyS_clone+0x16/0x20 [] system_call_fastpath+0x12/0x71 results in that splat. The effective result of the function below is for 'reserver_memtype' to ignore the result from 'x86_platform.is_untracked_pat_range' quirk. Which means that the splat above does not happen. Orabug: 24491985 Signed-off-by: Konrad Rzeszutek Wilk --- diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index eb5b8b831d62..3dbd0944916f 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -288,6 +288,27 @@ static void __init xen_banner(void) version >> 16, version & 0xffff, extra.extraversion, xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : ""); } + +/* + * On x86 whenever VMAs are setup, the 'is_ISA_range quirk' (which we + * re-implement below) is used to figure whether to ignore the + * requested PAT type and always use WB (see 'reserve_memtype'). + * + * The combination of MTRR (UC) and PAT (UC or WB) for the ISA region ends + * up with the same value - UC. + * + * However on Xen, due to XSA 154 we enforce that mappings to _ANY_ MMIO + * range MUST have the same the same cachability mapping - and in this case + * we enforce UC for everything. + * + * The effective result of the function below is for 'reserver_memtype' + * to ignore the result from 'x86_platform.is_untracked_pat_range' quirk. + */ +static bool xen_ignore(u64 s, u64 e) +{ + return false; +} + /* Check if running on Xen version (major, minor) or later */ bool xen_running_on_version_or_later(unsigned int major, unsigned int minor) @@ -1685,6 +1706,8 @@ asmlinkage __visible void __init xen_start_kernel(void) x86_init.mpparse.get_smp_config = x86_init_uint_noop; xen_boot_params_init_edd(); + + x86_platform.is_untracked_pat_range = xen_ignore; } #ifdef CONFIG_PCI /* PCI BIOS service won't work from a PV guest. */