From patchwork Mon Nov 24 21:26:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Nikolaev X-Patchwork-Id: 5370111 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 1B5609F39D for ; Mon, 24 Nov 2014 21:30:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41D1320120 for ; Mon, 24 Nov 2014 21:30:22 +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 6F5652011B for ; Mon, 24 Nov 2014 21:30:21 +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 1Xt1Ab-0000su-JV; Mon, 24 Nov 2014 21:27:41 +0000 Received: from mail-wi0-f170.google.com ([209.85.212.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xt1AF-0000f6-9x for linux-arm-kernel@lists.infradead.org; Mon, 24 Nov 2014 21:27:20 +0000 Received: by mail-wi0-f170.google.com with SMTP id bs8so10229971wib.3 for ; Mon, 24 Nov 2014 13:26:53 -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=R7q+DD4eGdVkPUJKWGfjs7xc8J/1TuzXuXiITlu64ts=; b=ElUqlPaIW2xuTFDxmfLzMIL7/blmdRnN142sJ5Co6BXqH47lnMnDeTuvYRhUbALCuA 7jErAATtPlDLN8tE37/+hJCzRRcGNCXMJxQ+9+L53IQl/EmKATdHtJ+Bbq06km7ey+1o rJEcJ0OX7XoAsvmysEAzK03tp55eSPYJdO2QfgQpLkYQwJ1iKwJrFHDN1wK98VWZSl1w LhopNybPv4XIXMj41dXLXAJJtx584OXc5bGpfUD1Z+K502U3GqoEQNzW4eUcIveQLmFe TbOegSM7siD4s61EfWF1JaB1xfl577Fr1Jmi85/puoKrB7WfCaox96lJdHumSaF3aAkE zt9g== X-Gm-Message-State: ALoCoQndtwWHEdYVQ2HHjPB74ksU1Y3TQ4L0MP38mAkBVqzHl42gCbpIJQ8eiJ3wdbVa//Ct7rmb X-Received: by 10.194.78.3 with SMTP id x3mr36817414wjw.127.1416864413821; Mon, 24 Nov 2014 13:26:53 -0800 (PST) Received: from [127.0.1.1] ([82.146.27.14]) by mx.google.com with ESMTPSA id u8sm22710578wjq.1.2014.11.24.13.26.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Nov 2014 13:26:53 -0800 (PST) Subject: [RFC PATCH 2/5] 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: Mon, 24 Nov 2014 23:26:51 +0200 Message-ID: <20141124212651.10605.58116.stgit@i3820> In-Reply-To: <20141124212240.10605.46770.stgit@i3820> References: <20141124212240.10605.46770.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-20141124_132719_551192_046FAB98 X-CRM114-Status: GOOD ( 11.02 ) 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..81230da 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; } +/** + * kvm_handle_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; }