From patchwork Tue Aug 7 14:52:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 175665 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 679122C0098 for ; Wed, 8 Aug 2012 01:11:49 +1000 (EST) Received: from localhost ([::1]:36472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SylAG-0004we-Vt for incoming@patchwork.ozlabs.org; Tue, 07 Aug 2012 10:53:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Syl9T-0003ML-Gs for qemu-devel@nongnu.org; Tue, 07 Aug 2012 10:53:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Syl9Q-00008I-GN for qemu-devel@nongnu.org; Tue, 07 Aug 2012 10:52:55 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:44090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Syl9P-000081-Rg for qemu-devel@nongnu.org; Tue, 07 Aug 2012 10:52:52 -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, 7 Aug 2012 15:52:51 +0100 Received: from d06nrmr1806.portsmouth.uk.ibm.com (9.149.39.193) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Aug 2012 15:52:50 +0100 Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q77EqnXZ2912408 for ; Tue, 7 Aug 2012 15:52:49 +0100 Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q77EqnL7009278 for ; Tue, 7 Aug 2012 08:52:49 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q77EqmHm009235; Tue, 7 Aug 2012 08:52:48 -0600 From: Cornelia Huck To: KVM , linux-s390 , qemu-devel Date: Tue, 7 Aug 2012 16:52:45 +0200 Message-Id: <1344351168-2568-2-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1344351168-2568-1-git-send-email-cornelia.huck@de.ibm.com> References: <1344351168-2568-1-git-send-email-cornelia.huck@de.ibm.com> x-cbid: 12080714-1948-0000-0000-0000029C15CA 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 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 --- drivers/s390/kvm/kvm_virtio.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index 47cccd5..408447c 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c @@ -418,6 +418,21 @@ static void kvm_extint_handler(struct ext_code ext_code, } } +static int __init test_devices_support(void) +{ + int ccode = -EIO; + + asm volatile( + "0: cli 0(%1),0\n" + " ipm %0\n" + " srl %0,28\n" + "1:\n" + EX_TABLE(0b,1b) + : "+d" (ccode) + : "a" (kvm_devices) + : "cc"); + return ccode; +} /* * Init function for virtio * devices are in a single page above top of "normal" mem @@ -443,6 +458,12 @@ static int __init kvm_devices_init(void) } kvm_devices = (void *) real_memory_size; + if (test_devices_support() < 0) { + vmem_remove_mapping(real_memory_size, PAGE_SIZE); + root_device_unregister(kvm_root); + /* No error. */ + return 0; + } INIT_WORK(&hotplug_work, hotplug_devices);