From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: KVM <kvm@vger.kernel.org>,
linux-s390 <linux-s390@vger.kernel.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Carsten Otte <cotte@de.ibm.com>, Alexander Graf <agraf@suse.de>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Sebastian Ott <sebott@linux.vnet.ibm.com>
Subject: [PATCH 1/5] KVM: s390: Handle hosts not supporting s390-virtio.
Date: Mon, 29 Oct 2012 14:07:22 +0100 [thread overview]
Message-ID: <1351516046-30037-2-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1351516046-30037-1-git-send-email-cornelia.huck@de.ibm.com>
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.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/s390/kvm/kvm_virtio.c | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index 47cccd5..76b95f3 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -419,6 +419,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
* devices are in a single page above top of "normal" mem
*/
@@ -429,21 +449,24 @@ static int __init kvm_devices_init(void)
if (!MACHINE_IS_KVM)
return -ENODEV;
+ if (test_devices_support(real_memory_size) < 0)
+ /* No error. */
+ return 0;
+
+ 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");
if (IS_ERR(kvm_root)) {
rc = PTR_ERR(kvm_root);
printk(KERN_ERR "Could not register kvm_s390 root device");
+ vmem_remove_mapping(real_memory_size, PAGE_SIZE);
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);
service_subclass_irq_register();
--
1.7.12.4
next prev parent reply other threads:[~2012-10-29 13:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-29 13:07 [PATCH 0/5] s390: Guest support for virtio-ccw Cornelia Huck
2012-10-29 13:07 ` Cornelia Huck [this message]
2012-10-29 13:07 ` [PATCH 2/5] s390: Move css limits from drivers/s390/cio/ to include/asm/ Cornelia Huck
2012-10-29 13:07 ` [PATCH 3/5] s390: Add a mechanism to get the subchannel id Cornelia Huck
2012-10-29 13:07 ` [PATCH 4/5] KVM: s390: Add a channel I/O based virtio transport driver Cornelia Huck
2012-10-29 18:12 ` Alexander Graf
2012-10-29 18:34 ` Cornelia Huck
2012-10-29 18:37 ` Alexander Graf
2012-10-30 13:03 ` Cornelia Huck
2012-10-30 13:41 ` Alexander Graf
2012-10-30 14:00 ` Cornelia Huck
2012-10-30 14:05 ` Alexander Graf
2012-10-30 14:35 ` Cornelia Huck
2012-10-30 15:11 ` Alexander Graf
2012-10-29 13:07 ` [PATCH 5/5] KVM: s390: Split out early console code Cornelia Huck
2012-10-29 18:14 ` Alexander Graf
2012-10-30 12:59 ` Cornelia Huck
2012-10-30 13:43 ` Alexander Graf
2012-10-30 14:29 ` Cornelia Huck
2012-10-30 15:12 ` Alexander Graf
2012-10-30 15:35 ` Cornelia Huck
2012-10-30 15:42 ` Alexander Graf
2012-10-29 17:55 ` [PATCH 0/5] s390: Guest support for virtio-ccw Alexander Graf
2012-10-29 18:15 ` Cornelia Huck
2012-10-29 18:33 ` Alexander Graf
2012-10-30 13:04 ` Cornelia Huck
2012-10-30 13:43 ` Alexander Graf
-- strict thread matches above, loose matches on Subject: below --
2012-12-07 12:29 [PATCH v3 " Cornelia Huck
2012-12-07 12:29 ` [PATCH 1/5] KVM: s390: Handle hosts not supporting s390-virtio Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351516046-30037-2-git-send-email-cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=agraf@suse.de \
--cc=avi@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cotte@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=schwidefsky@de.ibm.com \
--cc=sebott@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox