Skip to content

Commit f670268

Browse files
committed
Merge tag 'for-linus-4.3b-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen bug fixes from David Vrabel: - Fix VM save performance regression with x86 PV guests - Make kexec work in x86 PVHVM guests (if Xen has the soft-reset ABI) - Other minor fixes. * tag 'for-linus-4.3b-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: x86/xen/p2m: hint at the last populated P2M entry x86/xen: Do not clip xen_e820_map to xen_e820_map_entries when sanitizing map x86/xen: Support kexec/kdump in HVM guests by doing a soft reset xen/x86: Don't try to write syscall-related MSRs for PV guests xen: use correct type for HYPERVISOR_memory_op()
2 parents 3ec20e2 + 98dd166 commit f670268

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

arch/x86/include/asm/xen/hypercall.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,10 @@ HYPERVISOR_update_descriptor(u64 ma, u64 desc)
336336
return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
337337
}
338338

339-
static inline int
339+
static inline long
340340
HYPERVISOR_memory_op(unsigned int cmd, void *arg)
341341
{
342-
return _hypercall2(int, memory_op, cmd, arg);
342+
return _hypercall2(long, memory_op, cmd, arg);
343343
}
344344

345345
static inline int

arch/x86/xen/enlighten.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include <linux/memblock.h>
3434
#include <linux/edd.h>
3535

36+
#ifdef CONFIG_KEXEC_CORE
37+
#include <linux/kexec.h>
38+
#endif
39+
3640
#include <xen/xen.h>
3741
#include <xen/events.h>
3842
#include <xen/interface/xen.h>
@@ -1077,6 +1081,7 @@ static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
10771081
/* Fast syscall setup is all done in hypercalls, so
10781082
these are all ignored. Stub them out here to stop
10791083
Xen console noise. */
1084+
break;
10801085

10811086
default:
10821087
if (!pmu_msr_write(msr, low, high, &ret))
@@ -1807,6 +1812,21 @@ static struct notifier_block xen_hvm_cpu_notifier = {
18071812
.notifier_call = xen_hvm_cpu_notify,
18081813
};
18091814

1815+
#ifdef CONFIG_KEXEC_CORE
1816+
static void xen_hvm_shutdown(void)
1817+
{
1818+
native_machine_shutdown();
1819+
if (kexec_in_progress)
1820+
xen_reboot(SHUTDOWN_soft_reset);
1821+
}
1822+
1823+
static void xen_hvm_crash_shutdown(struct pt_regs *regs)
1824+
{
1825+
native_machine_crash_shutdown(regs);
1826+
xen_reboot(SHUTDOWN_soft_reset);
1827+
}
1828+
#endif
1829+
18101830
static void __init xen_hvm_guest_init(void)
18111831
{
18121832
if (xen_pv_domain())
@@ -1826,6 +1846,10 @@ static void __init xen_hvm_guest_init(void)
18261846
x86_init.irqs.intr_init = xen_init_IRQ;
18271847
xen_hvm_init_time_ops();
18281848
xen_hvm_init_mmu_ops();
1849+
#ifdef CONFIG_KEXEC_CORE
1850+
machine_ops.shutdown = xen_hvm_shutdown;
1851+
machine_ops.crash_shutdown = xen_hvm_crash_shutdown;
1852+
#endif
18291853
}
18301854
#endif
18311855

arch/x86/xen/p2m.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ static unsigned long *p2m_identity;
112112
static pte_t *p2m_missing_pte;
113113
static pte_t *p2m_identity_pte;
114114

115+
/*
116+
* Hint at last populated PFN.
117+
*
118+
* Used to set HYPERVISOR_shared_info->arch.max_pfn so the toolstack
119+
* can avoid scanning the whole P2M (which may be sized to account for
120+
* hotplugged memory).
121+
*/
122+
static unsigned long xen_p2m_last_pfn;
123+
115124
static inline unsigned p2m_top_index(unsigned long pfn)
116125
{
117126
BUG_ON(pfn >= MAX_P2M_PFN);
@@ -270,7 +279,7 @@ void xen_setup_mfn_list_list(void)
270279
else
271280
HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
272281
virt_to_mfn(p2m_top_mfn);
273-
HYPERVISOR_shared_info->arch.max_pfn = xen_max_p2m_pfn;
282+
HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
274283
HYPERVISOR_shared_info->arch.p2m_generation = 0;
275284
HYPERVISOR_shared_info->arch.p2m_vaddr = (unsigned long)xen_p2m_addr;
276285
HYPERVISOR_shared_info->arch.p2m_cr3 =
@@ -406,6 +415,8 @@ void __init xen_vmalloc_p2m_tree(void)
406415
static struct vm_struct vm;
407416
unsigned long p2m_limit;
408417

418+
xen_p2m_last_pfn = xen_max_p2m_pfn;
419+
409420
p2m_limit = (phys_addr_t)P2M_LIMIT * 1024 * 1024 * 1024 / PAGE_SIZE;
410421
vm.flags = VM_ALLOC;
411422
vm.size = ALIGN(sizeof(unsigned long) * max(xen_max_p2m_pfn, p2m_limit),
@@ -608,6 +619,12 @@ static bool alloc_p2m(unsigned long pfn)
608619
free_p2m_page(p2m);
609620
}
610621

622+
/* Expanded the p2m? */
623+
if (pfn > xen_p2m_last_pfn) {
624+
xen_p2m_last_pfn = pfn;
625+
HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
626+
}
627+
611628
return true;
612629
}
613630

arch/x86/xen/setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ static unsigned long __init xen_get_max_pages(void)
548548
{
549549
unsigned long max_pages, limit;
550550
domid_t domid = DOMID_SELF;
551-
int ret;
551+
long ret;
552552

553553
limit = xen_get_pages_limit();
554554
max_pages = limit;
@@ -798,7 +798,7 @@ char * __init xen_memory_setup(void)
798798
xen_ignore_unusable();
799799

800800
/* Make sure the Xen-supplied memory map is well-ordered. */
801-
sanitize_e820_map(xen_e820_map, xen_e820_map_entries,
801+
sanitize_e820_map(xen_e820_map, ARRAY_SIZE(xen_e820_map),
802802
&xen_e820_map_entries);
803803

804804
max_pages = xen_get_max_pages();

include/xen/interface/sched.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,13 @@ struct sched_watchdog {
107107
#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
108108
#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
109109
#define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */
110+
/*
111+
* Domain asked to perform 'soft reset' for it. The expected behavior is to
112+
* reset internal Xen state for the domain returning it to the point where it
113+
* was created but leaving the domain's memory contents and vCPU contexts
114+
* intact. This will allow the domain to start over and set up all Xen specific
115+
* interfaces again.
116+
*/
117+
#define SHUTDOWN_soft_reset 5
110118

111119
#endif /* __XEN_PUBLIC_SCHED_H__ */

0 commit comments

Comments
 (0)