From patchwork Sun Dec 7 09:37:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Nikolaev X-Patchwork-Id: 5451201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ECF169F30B for ; Sun, 7 Dec 2014 09:42:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3185720158 for ; Sun, 7 Dec 2014 09:42:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 4B8E320154 for ; Sun, 7 Dec 2014 09:42:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XxYIG-00027F-Jh; Sun, 07 Dec 2014 09:38:20 +0000 Received: from mail-wi0-f173.google.com ([209.85.212.173]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XxYIA-00022d-Fp for linux-arm-kernel@lists.infradead.org; Sun, 07 Dec 2014 09:38:15 +0000 Received: by mail-wi0-f173.google.com with SMTP id r20so2271658wiv.6 for ; Sun, 07 Dec 2014 01:37:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=51WkCpTr4a0fjSGeXCEweZ+2Z9jWYje64u6z7VtrtCY=; b=PSPFzBxMjjOutAmuikwG+vSuYkI70eG73xKF1Gg7wh6uwK0Fq7oI2GWYF1n2WRx056 VxisTAZsIw+GuNfz/wcFzcSAzjXD2ZEJ7um2YPgndxBjF4mdTL1xhys6zR/cdZ53Jhb4 4OvMjx3aXz5SnLu/cCtczDCPJSeHbAaSObmmXFdKiKkSuVmeMAAnrJkbQeiKt7Hxo2xJ 1MMrMAmO8Epf6wHsi7mURL1Wm+T2L5FuvRuPSH/akLkVOWa2rsbfBqqzMD+yb1524Pon YaysIp4AqOSqaJPxCwlri7ZDbidU84Trxu7i/1mp1znxLj9mUOAmcySqAVSoybZSdn3u LmVA== X-Gm-Message-State: ALoCoQmWJHecxnIOKooR43eFNEt2QuHJf4fCjpiKio4IuTSrj0jM/A3uH5YJoZvbFnqf+DMUWjy0 X-Received: by 10.180.103.6 with SMTP id fs6mr15977861wib.11.1417945071871; Sun, 07 Dec 2014 01:37:51 -0800 (PST) Received: from [127.0.1.1] ([82.146.27.14]) by mx.google.com with ESMTPSA id ce1sm51873217wjc.2.2014.12.07.01.37.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Dec 2014 01:37:51 -0800 (PST) Subject: [PATCH v2 2/5] KVM: ARM: on IO mem abort - route the call to KVM MMIO bus From: Nikolay Nikolaev To: kvm@vger.kernel.org, eric.auger@linaro.org, marc.zyngier@arm.com, andre.przywara@arm.com, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org Date: Sun, 07 Dec 2014 11:37:49 +0200 Message-ID: <20141207093749.17563.12497.stgit@i3820> In-Reply-To: <20141207093641.17563.84226.stgit@i3820> References: <20141207093641.17563.84226.stgit@i3820> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141207_013814_686594_875CD66D X-CRM114-Status: GOOD ( 10.77 ) X-Spam-Score: -0.7 (/) Cc: tech@virtualopensystems.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_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 On IO memory abort, try to handle the MMIO access thorugh the KVM registered read/write callbacks. This is done by invoking the relevant kvm_io_bus_* API. Signed-off-by: Nikolay Nikolaev --- arch/arm/kvm/mmio.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c index 4cb5a93..e42469f 100644 --- a/arch/arm/kvm/mmio.c +++ b/arch/arm/kvm/mmio.c @@ -162,6 +162,36 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, return 0; } +/** + * handle_kernel_mmio - handle an in-kernel MMIO access + * @vcpu: pointer to the vcpu performing the access + * @run: pointer to the kvm_run structure + * @mmio: pointer to the data describing the access + * + * returns true if the MMIO access has been performed in kernel space, + * and false if it needs to be emulated in user space. + */ +static bool handle_kernel_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run, + struct kvm_exit_mmio *mmio) +{ + int ret; + + if (mmio->is_write) { + ret = kvm_io_bus_write(vcpu, KVM_MMIO_BUS, mmio->phys_addr, + mmio->len, &mmio->data); + + } else { + ret = kvm_io_bus_read(vcpu, KVM_MMIO_BUS, mmio->phys_addr, + mmio->len, &mmio->data); + } + if (!ret) { + kvm_prepare_mmio(run, mmio); + kvm_handle_mmio_return(vcpu, run); + } + + return !ret; +} + int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, phys_addr_t fault_ipa) { @@ -200,6 +230,9 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, if (vgic_handle_mmio(vcpu, run, &mmio)) return 1; + if (handle_kernel_mmio(vcpu, run, &mmio)) + return 1; + kvm_prepare_mmio(run, &mmio); return 0; }