mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
Merge tag 'for-linus-6.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen updates from Juergen Gross: - fix the migration of a Xen virq to another cpu plus some related cleanup work - clean up Xen-PV mode specific code, resulting in removing some of that code in the resulting binary in case CONFIG_XEN_PV is not set - fixes and cleanup for suspend handling under Xen * tag 'for-linus-6.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen: take system_transition_mutex on suspend xen/manage: Fix suspend error path xen/events: Update virq_to_irq on migration xen/events: Return -EEXIST for bound VIRQs xen/events: Cleanup find_virq() return codes x86/xen: select HIBERNATE_CALLBACKS more directly drivers/xen/gntdev: use xen_pv_domain() instead of cached value xen: replace XENFEAT_auto_translated_physmap with xen_pv_domain() xen: rework xen_pv_domain()
This commit is contained in:
@@ -12,7 +12,6 @@ CONFIG_CPU_FREQ=y
|
||||
|
||||
# x86 xen specific config options
|
||||
CONFIG_XEN_PVH=y
|
||||
CONFIG_XEN_SAVE_RESTORE=y
|
||||
# CONFIG_XEN_DEBUG_FS is not set
|
||||
CONFIG_XEN_MCE_LOG=y
|
||||
CONFIG_XEN_ACPI_PROCESSOR=m
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include <asm/extable.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
#include <xen/xen.h>
|
||||
#include <xen/interface/xen.h>
|
||||
#include <xen/interface/grant_table.h>
|
||||
#include <xen/features.h>
|
||||
|
||||
/* Xen machine address */
|
||||
typedef struct xmaddr {
|
||||
@@ -162,7 +162,7 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
|
||||
* pfn_to_mfn. This will have to be removed when we figured
|
||||
* out which call.
|
||||
*/
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return pfn;
|
||||
|
||||
mfn = __pfn_to_mfn(pfn);
|
||||
@@ -175,7 +175,7 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
|
||||
|
||||
static inline int phys_to_machine_mapping_valid(unsigned long pfn)
|
||||
{
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return 1;
|
||||
|
||||
return __pfn_to_mfn(pfn) != INVALID_P2M_ENTRY;
|
||||
@@ -210,7 +210,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
|
||||
* gfn_to_pfn. This will have to be removed when we figure
|
||||
* out which call.
|
||||
*/
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return mfn;
|
||||
|
||||
pfn = mfn_to_pfn_no_overrides(mfn);
|
||||
@@ -242,7 +242,7 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)
|
||||
/* Pseudo-physical <-> Guest conversion */
|
||||
static inline unsigned long pfn_to_gfn(unsigned long pfn)
|
||||
{
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return pfn;
|
||||
else
|
||||
return pfn_to_mfn(pfn);
|
||||
@@ -250,7 +250,7 @@ static inline unsigned long pfn_to_gfn(unsigned long pfn)
|
||||
|
||||
static inline unsigned long gfn_to_pfn(unsigned long gfn)
|
||||
{
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return gfn;
|
||||
else
|
||||
return mfn_to_pfn(gfn);
|
||||
@@ -284,7 +284,7 @@ static inline unsigned long bfn_to_local_pfn(unsigned long mfn)
|
||||
{
|
||||
unsigned long pfn;
|
||||
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return mfn;
|
||||
|
||||
pfn = mfn_to_pfn(mfn);
|
||||
|
||||
@@ -8,6 +8,7 @@ config XEN
|
||||
depends on PARAVIRT
|
||||
select PARAVIRT_CLOCK
|
||||
select X86_HV_CALLBACK_VECTOR
|
||||
select HIBERNATE_CALLBACKS
|
||||
depends on X86_64 || (X86_32 && X86_PAE)
|
||||
depends on X86_64 || (X86_GENERIC || MPENTIUM4 || MATOM)
|
||||
depends on X86_LOCAL_APIC && X86_TSC
|
||||
@@ -64,12 +65,6 @@ config XEN_PVHVM_GUEST
|
||||
help
|
||||
Support running as a Xen PVHVM guest.
|
||||
|
||||
config XEN_SAVE_RESTORE
|
||||
bool
|
||||
depends on XEN
|
||||
select HIBERNATE_CALLBACKS
|
||||
default y
|
||||
|
||||
config XEN_DEBUG_FS
|
||||
bool "Enable Xen debug and tuning parameters in debugfs"
|
||||
depends on XEN && DEBUG_FS
|
||||
|
||||
@@ -382,7 +382,6 @@ static bool __init xen_check_xsave(void)
|
||||
|
||||
static void __init xen_init_capabilities(void)
|
||||
{
|
||||
setup_force_cpu_cap(X86_FEATURE_XENPV);
|
||||
setup_clear_cpu_cap(X86_FEATURE_DCA);
|
||||
setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
|
||||
setup_clear_cpu_cap(X86_FEATURE_MTRR);
|
||||
@@ -1402,6 +1401,7 @@ asmlinkage __visible void __init xen_start_kernel(struct start_info *si)
|
||||
JMP32_INSN_SIZE);
|
||||
|
||||
xen_domain_type = XEN_PV_DOMAIN;
|
||||
setup_force_cpu_cap(X86_FEATURE_XENPV);
|
||||
xen_start_flags = xen_start_info->flags;
|
||||
/* Interrupts are guaranteed to be off initially. */
|
||||
early_boot_irqs_disabled = true;
|
||||
|
||||
@@ -41,7 +41,7 @@ EXPORT_SYMBOL_GPL(arbitrary_virt_to_machine);
|
||||
int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
|
||||
int nr, struct page **pages)
|
||||
{
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return xen_xlate_unmap_gfn_range(vma, nr, pages);
|
||||
|
||||
if (!pages)
|
||||
|
||||
@@ -686,7 +686,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
|
||||
int i, ret = 0;
|
||||
pte_t *pte;
|
||||
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return 0;
|
||||
|
||||
if (kmap_ops) {
|
||||
@@ -769,7 +769,7 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
|
||||
@@ -302,7 +302,7 @@ static enum bp_state reserve_additional_memory(void)
|
||||
* are not restored since this region is now known not to
|
||||
* conflict with any devices.
|
||||
*/
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
|
||||
if (xen_pv_domain()) {
|
||||
unsigned long pfn, i;
|
||||
|
||||
pfn = PFN_DOWN(resource->start);
|
||||
@@ -626,7 +626,7 @@ int xen_alloc_ballooned_pages(unsigned int nr_pages, struct page **pages)
|
||||
*/
|
||||
BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE);
|
||||
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
|
||||
if (xen_pv_domain()) {
|
||||
ret = xen_alloc_p2m_entry(page_to_pfn(page));
|
||||
if (ret < 0)
|
||||
goto out_undo;
|
||||
|
||||
@@ -1314,14 +1314,17 @@ int bind_interdomain_evtchn_to_irq_lateeoi(struct xenbus_device *dev,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irq_lateeoi);
|
||||
|
||||
static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t *evtchn)
|
||||
static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t *evtchn,
|
||||
bool percpu)
|
||||
{
|
||||
struct evtchn_status status;
|
||||
evtchn_port_t port;
|
||||
int rc = -ENOENT;
|
||||
bool exists = false;
|
||||
|
||||
memset(&status, 0, sizeof(status));
|
||||
for (port = 0; port < xen_evtchn_max_channels(); port++) {
|
||||
int rc;
|
||||
|
||||
status.dom = DOMID_SELF;
|
||||
status.port = port;
|
||||
rc = HYPERVISOR_event_channel_op(EVTCHNOP_status, &status);
|
||||
@@ -1329,12 +1332,16 @@ static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t *evtchn)
|
||||
continue;
|
||||
if (status.status != EVTCHNSTAT_virq)
|
||||
continue;
|
||||
if (status.u.virq == virq && status.vcpu == xen_vcpu_nr(cpu)) {
|
||||
if (status.u.virq != virq)
|
||||
continue;
|
||||
if (status.vcpu == xen_vcpu_nr(cpu)) {
|
||||
*evtchn = port;
|
||||
break;
|
||||
return 0;
|
||||
} else if (!percpu) {
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
return exists ? -EEXIST : -ENOENT;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1381,8 +1388,11 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu)
|
||||
evtchn = bind_virq.port;
|
||||
else {
|
||||
if (ret == -EEXIST)
|
||||
ret = find_virq(virq, cpu, &evtchn);
|
||||
BUG_ON(ret < 0);
|
||||
ret = find_virq(virq, cpu, &evtchn, percpu);
|
||||
if (ret) {
|
||||
__unbind_from_irq(info, info->irq);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
ret = xen_irq_info_virq_setup(info, cpu, evtchn, virq);
|
||||
@@ -1787,9 +1797,20 @@ static int xen_rebind_evtchn_to_cpu(struct irq_info *info, unsigned int tcpu)
|
||||
* virq or IPI channel, which don't actually need to be rebound. Ignore
|
||||
* it, but don't do the xenlinux-level rebind in that case.
|
||||
*/
|
||||
if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
|
||||
if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) {
|
||||
int old_cpu = info->cpu;
|
||||
|
||||
bind_evtchn_to_cpu(info, tcpu, false);
|
||||
|
||||
if (info->type == IRQT_VIRQ) {
|
||||
int virq = info->u.virq;
|
||||
int irq = per_cpu(virq_to_irq, old_cpu)[virq];
|
||||
|
||||
per_cpu(virq_to_irq, old_cpu)[virq] = -1;
|
||||
per_cpu(virq_to_irq, tcpu)[virq] = irq;
|
||||
}
|
||||
}
|
||||
|
||||
do_unmask(info, EVT_MASK_REASON_TEMPORARY);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -720,16 +720,15 @@ static void dmabuf_imp_release_all(struct gntdev_dmabuf_priv *priv)
|
||||
|
||||
/* DMA buffer IOCTL support. */
|
||||
|
||||
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod,
|
||||
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv,
|
||||
struct ioctl_gntdev_dmabuf_exp_from_refs __user *u)
|
||||
{
|
||||
struct ioctl_gntdev_dmabuf_exp_from_refs op;
|
||||
u32 *refs;
|
||||
long ret;
|
||||
|
||||
if (use_ptemod) {
|
||||
pr_debug("Cannot provide dma-buf: use_ptemode %d\n",
|
||||
use_ptemod);
|
||||
if (xen_pv_domain()) {
|
||||
pr_debug("Cannot provide dma-buf in a PV domain\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp);
|
||||
|
||||
void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv);
|
||||
|
||||
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod,
|
||||
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv,
|
||||
struct ioctl_gntdev_dmabuf_exp_from_refs __user *u);
|
||||
|
||||
long gntdev_ioctl_dmabuf_exp_wait_released(struct gntdev_priv *priv,
|
||||
|
||||
@@ -73,9 +73,6 @@ module_param(limit, uint, 0644);
|
||||
MODULE_PARM_DESC(limit,
|
||||
"Maximum number of grants that may be mapped by one mapping request");
|
||||
|
||||
/* True in PV mode, false otherwise */
|
||||
static int use_ptemod;
|
||||
|
||||
static void unmap_grant_pages(struct gntdev_grant_map *map,
|
||||
int offset, int pages);
|
||||
|
||||
@@ -163,7 +160,7 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
|
||||
NULL == add->pages ||
|
||||
NULL == add->being_removed)
|
||||
goto err;
|
||||
if (use_ptemod) {
|
||||
if (xen_pv_domain()) {
|
||||
add->kmap_ops = kvmalloc_array(count, sizeof(add->kmap_ops[0]),
|
||||
GFP_KERNEL);
|
||||
add->kunmap_ops = kvmalloc_array(count, sizeof(add->kunmap_ops[0]),
|
||||
@@ -211,7 +208,7 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
|
||||
add->grants[i].ref = INVALID_GRANT_REF;
|
||||
add->map_ops[i].handle = INVALID_GRANT_HANDLE;
|
||||
add->unmap_ops[i].handle = INVALID_GRANT_HANDLE;
|
||||
if (use_ptemod) {
|
||||
if (xen_pv_domain()) {
|
||||
add->kmap_ops[i].handle = INVALID_GRANT_HANDLE;
|
||||
add->kunmap_ops[i].handle = INVALID_GRANT_HANDLE;
|
||||
}
|
||||
@@ -268,7 +265,7 @@ void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map)
|
||||
if (!refcount_dec_and_test(&map->users))
|
||||
return;
|
||||
|
||||
if (map->pages && !use_ptemod) {
|
||||
if (map->pages && !xen_pv_domain()) {
|
||||
/*
|
||||
* Increment the reference count. This ensures that the
|
||||
* subsequent call to unmap_grant_pages() will not wind up
|
||||
@@ -298,7 +295,7 @@ void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map)
|
||||
*/
|
||||
}
|
||||
|
||||
if (use_ptemod && map->notifier_init)
|
||||
if (xen_pv_domain() && map->notifier_init)
|
||||
mmu_interval_notifier_remove(&map->notifier);
|
||||
|
||||
if (map->notify.flags & UNMAP_NOTIFY_SEND_EVENT) {
|
||||
@@ -334,7 +331,7 @@ int gntdev_map_grant_pages(struct gntdev_grant_map *map)
|
||||
size_t alloced = 0;
|
||||
int i, err = 0;
|
||||
|
||||
if (!use_ptemod) {
|
||||
if (!xen_pv_domain()) {
|
||||
/* Note: it could already be mapped */
|
||||
if (map->map_ops[0].handle != INVALID_GRANT_HANDLE)
|
||||
return 0;
|
||||
@@ -389,7 +386,7 @@ int gntdev_map_grant_pages(struct gntdev_grant_map *map)
|
||||
if (map->flags & GNTMAP_device_map)
|
||||
map->unmap_ops[i].dev_bus_addr = map->map_ops[i].dev_bus_addr;
|
||||
|
||||
if (use_ptemod) {
|
||||
if (xen_pv_domain()) {
|
||||
if (map->kmap_ops[i].status == GNTST_okay) {
|
||||
alloced++;
|
||||
map->kunmap_ops[i].handle = map->kmap_ops[i].handle;
|
||||
@@ -421,7 +418,7 @@ static void __unmap_grant_pages_done(int result,
|
||||
map->unmap_ops[offset+i].handle,
|
||||
map->unmap_ops[offset+i].status);
|
||||
map->unmap_ops[offset+i].handle = INVALID_GRANT_HANDLE;
|
||||
if (use_ptemod) {
|
||||
if (xen_pv_domain()) {
|
||||
if (map->kunmap_ops[offset + i].status == GNTST_okay &&
|
||||
map->kunmap_ops[offset + i].handle != INVALID_GRANT_HANDLE)
|
||||
successful_unmaps++;
|
||||
@@ -464,7 +461,7 @@ static void __unmap_grant_pages(struct gntdev_grant_map *map, int offset,
|
||||
}
|
||||
|
||||
map->unmap_data.unmap_ops = map->unmap_ops + offset;
|
||||
map->unmap_data.kunmap_ops = use_ptemod ? map->kunmap_ops + offset : NULL;
|
||||
map->unmap_data.kunmap_ops = xen_pv_domain() ? map->kunmap_ops + offset : NULL;
|
||||
map->unmap_data.pages = map->pages + offset;
|
||||
map->unmap_data.count = pages;
|
||||
map->unmap_data.done = __unmap_grant_pages_done;
|
||||
@@ -1039,7 +1036,7 @@ static long gntdev_ioctl(struct file *flip,
|
||||
|
||||
#ifdef CONFIG_XEN_GNTDEV_DMABUF
|
||||
case IOCTL_GNTDEV_DMABUF_EXP_FROM_REFS:
|
||||
return gntdev_ioctl_dmabuf_exp_from_refs(priv, use_ptemod, ptr);
|
||||
return gntdev_ioctl_dmabuf_exp_from_refs(priv, ptr);
|
||||
|
||||
case IOCTL_GNTDEV_DMABUF_EXP_WAIT_RELEASED:
|
||||
return gntdev_ioctl_dmabuf_exp_wait_released(priv, ptr);
|
||||
@@ -1086,7 +1083,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
|
||||
|
||||
vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP | VM_MIXEDMAP);
|
||||
|
||||
if (use_ptemod)
|
||||
if (xen_pv_domain())
|
||||
vm_flags_set(vma, VM_DONTCOPY);
|
||||
|
||||
vma->vm_private_data = map;
|
||||
@@ -1102,7 +1099,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
|
||||
|
||||
map->pages_vm_start = vma->vm_start;
|
||||
|
||||
if (use_ptemod) {
|
||||
if (xen_pv_domain()) {
|
||||
err = mmu_interval_notifier_insert_locked(
|
||||
&map->notifier, vma->vm_mm, vma->vm_start,
|
||||
vma->vm_end - vma->vm_start, &gntdev_mmu_ops);
|
||||
@@ -1113,7 +1110,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
|
||||
}
|
||||
mutex_unlock(&priv->lock);
|
||||
|
||||
if (use_ptemod) {
|
||||
if (xen_pv_domain()) {
|
||||
/*
|
||||
* gntdev takes the address of the PTE in find_grant_ptes() and
|
||||
* passes it to the hypervisor in gntdev_map_grant_pages(). The
|
||||
@@ -1139,7 +1136,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
|
||||
if (err)
|
||||
goto out_put_map;
|
||||
|
||||
if (!use_ptemod) {
|
||||
if (!xen_pv_domain()) {
|
||||
err = vm_map_pages_zero(vma, map->pages, map->count);
|
||||
if (err)
|
||||
goto out_put_map;
|
||||
@@ -1154,7 +1151,7 @@ unlock_out:
|
||||
out_unlock_put:
|
||||
mutex_unlock(&priv->lock);
|
||||
out_put_map:
|
||||
if (use_ptemod)
|
||||
if (xen_pv_domain())
|
||||
unmap_grant_pages(map, 0, map->count);
|
||||
gntdev_put_map(priv, map);
|
||||
return err;
|
||||
@@ -1183,8 +1180,6 @@ static int __init gntdev_init(void)
|
||||
if (!xen_domain())
|
||||
return -ENODEV;
|
||||
|
||||
use_ptemod = !xen_feature(XENFEAT_auto_translated_physmap);
|
||||
|
||||
err = misc_register(&gntdev_miscdev);
|
||||
if (err != 0) {
|
||||
pr_err("Could not register gntdev device\n");
|
||||
|
||||
@@ -1449,7 +1449,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
|
||||
unsigned int nr_gframes = end_idx + 1;
|
||||
int rc;
|
||||
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap)) {
|
||||
if (!xen_pv_domain()) {
|
||||
struct xen_add_to_physmap xatp;
|
||||
unsigned int i = end_idx;
|
||||
rc = 0;
|
||||
@@ -1570,7 +1570,7 @@ static int gnttab_setup(void)
|
||||
if (max_nr_gframes < nr_grant_frames)
|
||||
return -ENOSYS;
|
||||
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap) && gnttab_shared.addr == NULL) {
|
||||
if (!xen_pv_domain() && gnttab_shared.addr == NULL) {
|
||||
gnttab_shared.addr = xen_auto_xlat_grant_frames.vaddr;
|
||||
if (gnttab_shared.addr == NULL) {
|
||||
pr_warn("gnttab share frames is not mapped!\n");
|
||||
@@ -1588,7 +1588,7 @@ int gnttab_resume(void)
|
||||
|
||||
int gnttab_suspend(void)
|
||||
{
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (xen_pv_domain())
|
||||
gnttab_interface->unmap_frames();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/sysrq.h>
|
||||
#include <linux/stop_machine.h>
|
||||
#include <linux/suspend.h>
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/syscore_ops.h>
|
||||
#include <linux/export.h>
|
||||
@@ -95,10 +96,16 @@ static void do_suspend(void)
|
||||
|
||||
shutting_down = SHUTDOWN_SUSPEND;
|
||||
|
||||
if (!mutex_trylock(&system_transition_mutex))
|
||||
{
|
||||
pr_err("%s: failed to take system_transition_mutex\n", __func__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = freeze_processes();
|
||||
if (err) {
|
||||
pr_err("%s: freeze processes failed %d\n", __func__, err);
|
||||
goto out;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
err = freeze_kernel_threads();
|
||||
@@ -110,7 +117,7 @@ static void do_suspend(void)
|
||||
err = dpm_suspend_start(PMSG_FREEZE);
|
||||
if (err) {
|
||||
pr_err("%s: dpm_suspend_start %d\n", __func__, err);
|
||||
goto out_thaw;
|
||||
goto out_resume_end;
|
||||
}
|
||||
|
||||
printk(KERN_DEBUG "suspending xenstore...\n");
|
||||
@@ -150,10 +157,13 @@ out_resume:
|
||||
else
|
||||
xs_suspend_cancel();
|
||||
|
||||
out_resume_end:
|
||||
dpm_resume_end(si.cancelled ? PMSG_THAW : PMSG_RESTORE);
|
||||
|
||||
out_thaw:
|
||||
thaw_processes();
|
||||
out_unlock:
|
||||
mutex_unlock(&system_transition_mutex);
|
||||
out:
|
||||
shutting_down = SHUTDOWN_INVALID;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
|
||||
struct mmap_gfn_state state;
|
||||
|
||||
/* We only support privcmd_ioctl_mmap_batch for non-auto-translated. */
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return -ENOSYS;
|
||||
|
||||
if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd)))
|
||||
@@ -353,7 +353,7 @@ static int mmap_batch_fn(void *data, int nr, void *state)
|
||||
struct page **cur_pages = NULL;
|
||||
int ret;
|
||||
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
cur_pages = &pages[st->index];
|
||||
|
||||
BUG_ON(nr < 0);
|
||||
@@ -535,7 +535,7 @@ static long privcmd_ioctl_mmap_batch(
|
||||
ret = -EINVAL;
|
||||
goto out_unlock;
|
||||
}
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap)) {
|
||||
if (!xen_pv_domain()) {
|
||||
ret = alloc_empty_pages(vma, nr_pages);
|
||||
if (ret < 0)
|
||||
goto out_unlock;
|
||||
@@ -779,8 +779,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) &&
|
||||
xen_feature(XENFEAT_auto_translated_physmap)) {
|
||||
if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && !xen_pv_domain()) {
|
||||
unsigned int nr = DIV_ROUND_UP(kdata.num, XEN_PFN_PER_PAGE);
|
||||
struct page **pages;
|
||||
unsigned int i;
|
||||
@@ -811,8 +810,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file,
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) &&
|
||||
xen_feature(XENFEAT_auto_translated_physmap)) {
|
||||
if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && !xen_pv_domain()) {
|
||||
rc = xen_remap_vma_range(vma, kdata.addr, kdata.num << PAGE_SHIFT);
|
||||
} else {
|
||||
unsigned int domid =
|
||||
@@ -1591,7 +1589,7 @@ static void privcmd_close(struct vm_area_struct *vma)
|
||||
int numgfns = (vma->vm_end - vma->vm_start) >> XEN_PAGE_SHIFT;
|
||||
int rc;
|
||||
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages)
|
||||
if (xen_pv_domain() || !numpgs || !pages)
|
||||
return;
|
||||
|
||||
rc = xen_unmap_domain_gfn_range(vma, numgfns, pages);
|
||||
|
||||
@@ -105,7 +105,7 @@ static int fill_list(unsigned int nr_pages)
|
||||
* are not restored since this region is now known not to
|
||||
* conflict with any devices.
|
||||
*/
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
|
||||
if (xen_pv_domain()) {
|
||||
xen_pfn_t pfn = PFN_DOWN(res->start);
|
||||
|
||||
for (i = 0; i < alloc_pages; i++) {
|
||||
@@ -184,7 +184,7 @@ int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages)
|
||||
pages[i] = pg;
|
||||
|
||||
#ifdef CONFIG_XEN_HAVE_PVMMU
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
|
||||
if (xen_pv_domain()) {
|
||||
ret = xen_alloc_p2m_entry(page_to_pfn(pg));
|
||||
if (ret < 0) {
|
||||
unsigned int j;
|
||||
|
||||
@@ -955,7 +955,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {
|
||||
void __init xenbus_ring_ops_init(void)
|
||||
{
|
||||
#ifdef CONFIG_XEN_PV
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (xen_pv_domain())
|
||||
ring_ops = &ring_ops_pv;
|
||||
else
|
||||
#endif
|
||||
|
||||
@@ -164,7 +164,7 @@ gnttab_set_map_op(struct gnttab_map_grant_ref *map, phys_addr_t addr,
|
||||
{
|
||||
if (flags & GNTMAP_contains_pte)
|
||||
map->host_addr = addr;
|
||||
else if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
else if (!xen_pv_domain())
|
||||
map->host_addr = __pa(addr);
|
||||
else
|
||||
map->host_addr = addr;
|
||||
@@ -181,7 +181,7 @@ gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, phys_addr_t addr,
|
||||
{
|
||||
if (flags & GNTMAP_contains_pte)
|
||||
unmap->host_addr = addr;
|
||||
else if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
else if (!xen_pv_domain())
|
||||
unmap->host_addr = __pa(addr);
|
||||
else
|
||||
unmap->host_addr = addr;
|
||||
|
||||
@@ -39,7 +39,7 @@ static inline void xenmem_reservation_va_mapping_update(unsigned long count,
|
||||
xen_pfn_t *frames)
|
||||
{
|
||||
#ifdef CONFIG_XEN_HAVE_PVMMU
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (xen_pv_domain())
|
||||
__xenmem_reservation_va_mapping_update(count, pages, frames);
|
||||
#endif
|
||||
}
|
||||
@@ -48,7 +48,7 @@ static inline void xenmem_reservation_va_mapping_reset(unsigned long count,
|
||||
struct page **pages)
|
||||
{
|
||||
#ifdef CONFIG_XEN_HAVE_PVMMU
|
||||
if (!xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (xen_pv_domain())
|
||||
__xenmem_reservation_va_mapping_reset(count, pages);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/efi.h>
|
||||
#include <linux/virtio_anchor.h>
|
||||
#include <xen/xen.h>
|
||||
#include <xen/features.h>
|
||||
#include <asm/xen/interface.h>
|
||||
#include <xen/interface/vcpu.h>
|
||||
@@ -116,7 +117,7 @@ static inline int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
|
||||
unsigned int domid,
|
||||
struct page **pages)
|
||||
{
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return xen_xlate_remap_gfn_array(vma, addr, gfn, nr, err_ptr,
|
||||
prot, domid, pages);
|
||||
|
||||
@@ -150,7 +151,7 @@ static inline int xen_remap_domain_mfn_array(struct vm_area_struct *vma,
|
||||
int nr, int *err_ptr,
|
||||
pgprot_t prot, unsigned int domid)
|
||||
{
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return xen_remap_pfn(vma, addr, mfn, nr, err_ptr, prot, domid,
|
||||
@@ -175,7 +176,7 @@ static inline int xen_remap_domain_gfn_range(struct vm_area_struct *vma,
|
||||
pgprot_t prot, unsigned int domid,
|
||||
struct page **pages)
|
||||
{
|
||||
if (xen_feature(XENFEAT_auto_translated_physmap))
|
||||
if (!xen_pv_domain())
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return xen_remap_pfn(vma, addr, &gfn, nr, NULL, prot, domid, false);
|
||||
|
||||
@@ -22,8 +22,15 @@ extern bool xen_pvh;
|
||||
#define xen_pvh 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
#include <asm/cpufeature.h>
|
||||
|
||||
#define xen_pv_domain() (cpu_feature_enabled(X86_FEATURE_XENPV))
|
||||
#else
|
||||
#define xen_pv_domain() 0
|
||||
#endif
|
||||
|
||||
#define xen_domain() (xen_domain_type != XEN_NATIVE)
|
||||
#define xen_pv_domain() (xen_domain_type == XEN_PV_DOMAIN)
|
||||
#define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN)
|
||||
#define xen_pvh_domain() (xen_pvh)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user