From patchwork Thu Dec 5 15:10:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 3288891 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 45F81C0D4A for ; Thu, 5 Dec 2013 15:11:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A6662038C for ; Thu, 5 Dec 2013 15:11:26 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E5F620265 for ; Thu, 5 Dec 2013 15:11:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoaaD-0003me-JL; Thu, 05 Dec 2013 15:11:17 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Voaa8-0003Yi-KQ; Thu, 05 Dec 2013 15:11:12 +0000 Received: from mail-ee0-f51.google.com ([74.125.83.51]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Voaa7-0003YC-4v for linux-arm-kernel@lists.infradead.org; Thu, 05 Dec 2013 15:11:11 +0000 Received: by mail-ee0-f51.google.com with SMTP id b15so3163547eek.24 for ; Thu, 05 Dec 2013 07:10:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xSxhaiJ6YsQtGieyMe1YMKjC7/+6C/8Hxlb2igzhgLI=; b=UGrW55WL/cOFQ6FdIwAXkag8xRDFnfuoBML0poNP7Seykazlhp36qqYDY0k8hNmsdQ 7Kr0yJG9/t8NPE1yid3jz8dvQj0/dSs6KHH6PvjnyWOWdMWvtFyFFHqpxoXjPU5HG6Wg RWr6w7q9sGMxrF3wLLHn7GjI7dvR/uiEkBXBGsV9MMC2hTw/3fy/rrMD1L0/zgKD4DGc iw8fO//89ffFVeboWnNOWCYlB2Hmpax/cDx6u49WNtBJCJSK7BbBH6gg1XM9Ji5Dncem w+tZmaQfFsaFW7wmMvFpKgyquNsWIRJ3pJj1occdH7nBMG10Mi9HFmzR0FElDwGFRhlR IdNA== X-Gm-Message-State: ALoCoQkASvHO7tlFqMNxMdRwe3xhfs+JDqNcKlWY+Bzlxb0mmoWBhp8BGsOy+mQ4CyZpNglIYZTT X-Received: by 10.15.63.134 with SMTP id m6mr13218817eex.74.1386256246326; Thu, 05 Dec 2013 07:10:46 -0800 (PST) Received: from slackpad.drs.calxeda.com (g224192075.adsl.alicedsl.de. [92.224.192.75]) by mx.google.com with ESMTPSA id g7sm58333931eet.12.2013.12.05.07.10.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2013 07:10:45 -0800 (PST) From: Andre Przywara To: peter.maydell@linaro.org, marc.zyngier@arm.com, christoffer.dall@linaro.org Subject: [PATCH] ARM/KVM: inject data abort on unhandled memory access Date: Thu, 5 Dec 2013 16:10:21 +0100 Message-Id: <1386256221-12294-1-git-send-email-andre.przywara@linaro.org> X-Mailer: git-send-email 1.7.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131205_101111_310009_05DD7B3E X-CRM114-Status: GOOD ( 11.02 ) X-Spam-Score: -2.6 (--) Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a KVM guest accesses memory that is outside its memory map (so no MMIO and no RAM), KVM will return -ENOSYS to userland, causing QEMU to do an abort() and kill the whole guest. This happens while executing dmidecode on ARM, which mmaps /dev/mem and scans the first Megabyte of memory for a DMI BIOS signature (sic!). Of course this is silly, but in any case crashing the whole guest does not seems appropriate. So lets mimic native hardware's behavior in this case and inject a Data Abort exception into the guest. In the previous case this will crash dmidecode with SIGSEGV, but keeps the guest alive. I am not sure if this too coarse grained, but I just wanted to start discussion on this. Signed-off-by: Andre Przywara --- arch/arm/kvm/mmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c index 4cb5a93..04a105e 100644 --- a/arch/arm/kvm/mmio.c +++ b/arch/arm/kvm/mmio.c @@ -183,7 +183,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, return ret; } else { kvm_err("load/store instruction decoding not implemented\n"); - return -ENOSYS; + kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu)); + return 1; } rt = vcpu->arch.mmio_decode.rt;