Commit 5836e422 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus-4.12b-rc0c-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen fixes from Juergen Gross:
 "This contains two fixes for booting under Xen introduced during this
  merge window and two fixes for older problems, where one is just much
  more probable due to another merge window change"

* tag 'for-linus-4.12b-rc0c-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xen: adjust early dom0 p2m handling to xen hypervisor behavior
  x86/amd: don't set X86_BUG_SYSRET_SS_ATTRS when running under Xen
  xen/x86: Do not call xen_init_time_ops() until shared_info is initialized
  x86/xen: fix xsave capability setting
parents dc2a2481 69861e0a
...@@ -799,7 +799,8 @@ static void init_amd(struct cpuinfo_x86 *c) ...@@ -799,7 +799,8 @@ static void init_amd(struct cpuinfo_x86 *c)
if (cpu_has(c, X86_FEATURE_3DNOW) || cpu_has(c, X86_FEATURE_LM)) if (cpu_has(c, X86_FEATURE_3DNOW) || cpu_has(c, X86_FEATURE_LM))
set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH); set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH);
/* AMD CPUs don't reset SS attributes on SYSRET */ /* AMD CPUs don't reset SS attributes on SYSRET, Xen does. */
if (!cpu_has(c, X86_FEATURE_XENPV))
set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS); set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
} }
......
...@@ -277,31 +277,19 @@ static bool __init xen_check_mwait(void) ...@@ -277,31 +277,19 @@ static bool __init xen_check_mwait(void)
static bool __init xen_check_xsave(void) static bool __init xen_check_xsave(void)
{ {
unsigned int err, eax, edx; unsigned int cx, xsave_mask;
/* cx = cpuid_ecx(1);
* Xen 4.0 and older accidentally leaked the host XSAVE flag into guest
* view, despite not being able to support guests using the xsave_mask = (1 << (X86_FEATURE_XSAVE % 32)) |
* functionality. Probe for the actual availability of XSAVE by seeing (1 << (X86_FEATURE_OSXSAVE % 32));
* whether xgetbv executes successfully or raises #UD.
*/ /* Xen will set CR4.OSXSAVE if supported and not disabled by force */
asm volatile("1: .byte 0x0f,0x01,0xd0\n\t" /* xgetbv */ return (cx & xsave_mask) == xsave_mask;
"xor %[err], %[err]\n"
"2:\n\t"
".pushsection .fixup,\"ax\"\n\t"
"3: movl $1,%[err]\n\t"
"jmp 2b\n\t"
".popsection\n\t"
_ASM_EXTABLE(1b, 3b)
: [err] "=r" (err), "=a" (eax), "=d" (edx)
: "c" (0));
return err == 0;
} }
static void __init xen_init_capabilities(void) static void __init xen_init_capabilities(void)
{ {
setup_clear_cpu_cap(X86_BUG_SYSRET_SS_ATTRS);
setup_force_cpu_cap(X86_FEATURE_XENPV); setup_force_cpu_cap(X86_FEATURE_XENPV);
setup_clear_cpu_cap(X86_FEATURE_DCA); setup_clear_cpu_cap(X86_FEATURE_DCA);
setup_clear_cpu_cap(X86_FEATURE_APERFMPERF); setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
...@@ -317,10 +305,7 @@ static void __init xen_init_capabilities(void) ...@@ -317,10 +305,7 @@ static void __init xen_init_capabilities(void)
else else
setup_clear_cpu_cap(X86_FEATURE_MWAIT); setup_clear_cpu_cap(X86_FEATURE_MWAIT);
if (xen_check_xsave()) { if (!xen_check_xsave()) {
setup_force_cpu_cap(X86_FEATURE_XSAVE);
setup_force_cpu_cap(X86_FEATURE_OSXSAVE);
} else {
setup_clear_cpu_cap(X86_FEATURE_XSAVE); setup_clear_cpu_cap(X86_FEATURE_XSAVE);
setup_clear_cpu_cap(X86_FEATURE_OSXSAVE); setup_clear_cpu_cap(X86_FEATURE_OSXSAVE);
} }
...@@ -988,6 +973,13 @@ void xen_setup_shared_info(void) ...@@ -988,6 +973,13 @@ void xen_setup_shared_info(void)
#endif #endif
xen_setup_mfn_list_list(); xen_setup_mfn_list_list();
/*
* Now that shared info is set up we can start using routines that
* point to pvclock area.
*/
if (system_state == SYSTEM_BOOTING)
xen_init_time_ops();
} }
/* This is called once we have the cpu_possible_mask */ /* This is called once we have the cpu_possible_mask */
...@@ -1286,8 +1278,6 @@ asmlinkage __visible void __init xen_start_kernel(void) ...@@ -1286,8 +1278,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
x86_init.oem.arch_setup = xen_arch_setup; x86_init.oem.arch_setup = xen_arch_setup;
x86_init.oem.banner = xen_banner; x86_init.oem.banner = xen_banner;
xen_init_time_ops();
/* /*
* Set up some pagetable state before starting to set any ptes. * Set up some pagetable state before starting to set any ptes.
*/ */
......
...@@ -2025,7 +2025,8 @@ static unsigned long __init xen_read_phys_ulong(phys_addr_t addr) ...@@ -2025,7 +2025,8 @@ static unsigned long __init xen_read_phys_ulong(phys_addr_t addr)
/* /*
* Translate a virtual address to a physical one without relying on mapped * Translate a virtual address to a physical one without relying on mapped
* page tables. * page tables. Don't rely on big pages being aligned in (guest) physical
* space!
*/ */
static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr) static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
{ {
...@@ -2046,7 +2047,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr) ...@@ -2046,7 +2047,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
sizeof(pud))); sizeof(pud)));
if (!pud_present(pud)) if (!pud_present(pud))
return 0; return 0;
pa = pud_pfn(pud) << PAGE_SHIFT; pa = pud_val(pud) & PTE_PFN_MASK;
if (pud_large(pud)) if (pud_large(pud))
return pa + (vaddr & ~PUD_MASK); return pa + (vaddr & ~PUD_MASK);
...@@ -2054,7 +2055,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr) ...@@ -2054,7 +2055,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
sizeof(pmd))); sizeof(pmd)));
if (!pmd_present(pmd)) if (!pmd_present(pmd))
return 0; return 0;
pa = pmd_pfn(pmd) << PAGE_SHIFT; pa = pmd_val(pmd) & PTE_PFN_MASK;
if (pmd_large(pmd)) if (pmd_large(pmd))
return pa + (vaddr & ~PMD_MASK); return pa + (vaddr & ~PMD_MASK);
......
...@@ -406,7 +406,7 @@ static void __init xen_time_init(void) ...@@ -406,7 +406,7 @@ static void __init xen_time_init(void)
pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier); pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier);
} }
void __init xen_init_time_ops(void) void __ref xen_init_time_ops(void)
{ {
pv_time_ops = xen_time_ops; pv_time_ops = xen_time_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment