提交 55c171a6 编写于 作者: C Cornelia Huck 提交者: Gleb Natapov

KVM: s390: Handle hosts not supporting s390-virtio.

Running under a kvm host does not necessarily imply the presence of
a page mapped above the main memory with the virtio information;
however, the code includes a hard coded access to that page.

Instead, check for the presence of the page and exit gracefully
before we hit an addressing exception if it does not exist.
Reviewed-by: NMarcelo Tosatti <mtosatti@redhat.com>
Reviewed-by: NAlexander Graf <agraf@suse.de>
Signed-off-by: NCornelia Huck <cornelia.huck@de.ibm.com>
cc: stable@vger.kernel.org
Signed-off-by: NGleb Natapov <gleb@redhat.com>
上级 d4b06c2d
...@@ -421,6 +421,26 @@ static void kvm_extint_handler(struct ext_code ext_code, ...@@ -421,6 +421,26 @@ static void kvm_extint_handler(struct ext_code ext_code,
} }
} }
/*
* For s390-virtio, we expect a page above main storage containing
* the virtio configuration. Try to actually load from this area
* in order to figure out if the host provides this page.
*/
static int __init test_devices_support(unsigned long addr)
{
int ret = -EIO;
asm volatile(
"0: lura 0,%1\n"
"1: xgr %0,%0\n"
"2:\n"
EX_TABLE(0b,2b)
EX_TABLE(1b,2b)
: "+d" (ret)
: "a" (addr)
: "0", "cc");
return ret;
}
/* /*
* Init function for virtio * Init function for virtio
* devices are in a single page above top of "normal" mem * devices are in a single page above top of "normal" mem
...@@ -432,21 +452,23 @@ static int __init kvm_devices_init(void) ...@@ -432,21 +452,23 @@ static int __init kvm_devices_init(void)
if (!MACHINE_IS_KVM) if (!MACHINE_IS_KVM)
return -ENODEV; return -ENODEV;
if (test_devices_support(real_memory_size) < 0)
return -ENODEV;
rc = vmem_add_mapping(real_memory_size, PAGE_SIZE);
if (rc)
return rc;
kvm_devices = (void *) real_memory_size;
kvm_root = root_device_register("kvm_s390"); kvm_root = root_device_register("kvm_s390");
if (IS_ERR(kvm_root)) { if (IS_ERR(kvm_root)) {
rc = PTR_ERR(kvm_root); rc = PTR_ERR(kvm_root);
printk(KERN_ERR "Could not register kvm_s390 root device"); printk(KERN_ERR "Could not register kvm_s390 root device");
vmem_remove_mapping(real_memory_size, PAGE_SIZE);
return rc; return rc;
} }
rc = vmem_add_mapping(real_memory_size, PAGE_SIZE);
if (rc) {
root_device_unregister(kvm_root);
return rc;
}
kvm_devices = (void *) real_memory_size;
INIT_WORK(&hotplug_work, hotplug_devices); INIT_WORK(&hotplug_work, hotplug_devices);
service_subclass_irq_register(); service_subclass_irq_register();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册