From patchwork Sat Jan 24 11:59:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Nikolaev X-Patchwork-Id: 5699101 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 58194C058D for ; Sat, 24 Jan 2015 12:03:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 933C22011B for ; Sat, 24 Jan 2015 12:03:06 +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 BCEEB200F0 for ; Sat, 24 Jan 2015 12:03:05 +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 1YEzOX-0006Vp-3s; Sat, 24 Jan 2015 12:00:53 +0000 Received: from mail-wi0-f182.google.com ([209.85.212.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YEzNk-000509-JK for linux-arm-kernel@lists.infradead.org; Sat, 24 Jan 2015 12:00:05 +0000 Received: by mail-wi0-f182.google.com with SMTP id n3so1903513wiv.3 for ; Sat, 24 Jan 2015 03:59:42 -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=19xcQemK0ipTbVQNqPVTU4R5wUbZ2KhZaj3nMYtfCtg=; b=kJRlqETgkNvd0DuJf8PPGf5EY56t6CnqSSUedhyVGgKMcPy88u1r/8HWA4HZgfThh6 vLKuOxNfLC2NPXXGhZGSPeRn9phc3GP/dGG8ANqjQ1SxFjEVQMVaH3B5g9RCW3GE2MAh Uvkg+OqU6PzUH2PyyzUaay+dBeO3HepXWvaGCf8gY+bE6RNqkzGA+leMs6XiZCEZNXlW BhKgeo2ucYOqPH/d/gcUj1kZHC5NiWkY1GwghayGo55qR3Nlgyo0ZM70O8hNSZEKERgB 1wZceLir6wqA12Vx14diXSCjSGO4j4yX7jwcPVjzVBaNXN/FEeh/zhDier7259jeZDZI tEVg== X-Gm-Message-State: ALoCoQmue6n7AM/IhZfyVb9xhmLZUhKWHpvRS2WbTdoTBy8beojMZLeosVJTa2ay3kJ6WXKfNTEl X-Received: by 10.180.73.178 with SMTP id m18mr6341834wiv.65.1422100782619; Sat, 24 Jan 2015 03:59:42 -0800 (PST) Received: from [127.0.1.1] ([82.146.27.14]) by mx.google.com with ESMTPSA id q10sm5960086wjx.34.2015.01.24.03.59.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Jan 2015 03:59:41 -0800 (PST) Subject: [PATCH v3 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: Sat, 24 Jan 2015 13:59:40 +0200 Message-ID: <20150124115940.11052.23036.stgit@i3820> In-Reply-To: <20150124115815.11052.20755.stgit@i3820> References: <20150124115815.11052.20755.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-20150124_040004_844366_B2198515 X-CRM114-Status: UNSURE ( 9.92 ) X-CRM114-Notice: Please train this message. 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 5d3bfc0..d852137 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) { @@ -203,6 +233,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; }