From patchwork Tue Sep 4 15:13:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 181615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 54C9B2C008F for ; Wed, 5 Sep 2012 02:07:47 +1000 (EST) Received: from localhost ([::1]:53468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uq9-0003H5-O0 for incoming@patchwork.ozlabs.org; Tue, 04 Sep 2012 11:14:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8upN-0002Fq-HV for qemu-devel@nongnu.org; Tue, 04 Sep 2012 11:14:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8upI-0003Cv-3F for qemu-devel@nongnu.org; Tue, 04 Sep 2012 11:14:09 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:46899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8upH-0003CV-Qf for qemu-devel@nongnu.org; Tue, 04 Sep 2012 11:14:04 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Sep 2012 16:14:03 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Sep 2012 16:13:45 +0100 Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q84FDcuW42205220 for ; Tue, 4 Sep 2012 15:13:38 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q84EibIe024701 for ; Tue, 4 Sep 2012 10:44:38 -0400 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q84Eiajs024630; Tue, 4 Sep 2012 10:44:36 -0400 From: Cornelia Huck To: KVM , linux-s390 , qemu-devel Date: Tue, 4 Sep 2012 17:13:39 +0200 Message-Id: <1346771622-52763-2-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1346771622-52763-1-git-send-email-cornelia.huck@de.ibm.com> References: <1346771622-52763-1-git-send-email-cornelia.huck@de.ibm.com> x-cbid: 12090415-1948-0000-0000-000002DB7C7C X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.110 Cc: Carsten Otte , Anthony Liguori , Rusty Russell , Sebastian Ott , Marcelo Tosatti , Heiko Carstens , Alexander Graf , Christian Borntraeger , Avi Kivity , Martin Schwidefsky Subject: [Qemu-devel] [PATCH v2 1/4] s390/kvm: Handle hosts not supporting s390-virtio. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- Changes v1->v2: - check for the presence of the patch with lura - reorder init sequence - comments --- 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();