From patchwork Fri Sep 16 05:16:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 9335003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 000A960839 for ; Fri, 16 Sep 2016 05:18:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E66DD29EA0 for ; Fri, 16 Sep 2016 05:18:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D994F29EA8; Fri, 16 Sep 2016 05:18:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7014929EA0 for ; Fri, 16 Sep 2016 05:18:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bklWo-0000un-3d; Fri, 16 Sep 2016 05:17:34 +0000 Received: from mx2.suse.de ([195.135.220.15]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bklWj-0000sU-R5 for linux-arm-kernel@lists.infradead.org; Fri, 16 Sep 2016 05:17:30 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E0B6BAC4B; Fri, 16 Sep 2016 05:17:06 +0000 (UTC) From: Alexander Graf To: kvmarm@lists.cs.columbia.edu Subject: [PATCH] KVM: arm/arm64: timer: Fix hw sync for user space irqchip path Date: Fri, 16 Sep 2016 07:16:11 +0200 Message-Id: <1474002971-31434-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 2.6.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160915_221730_238233_4FCC1A40 X-CRM114-Status: UNSURE ( 8.80 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP While adding the new vgic implementation, apparently nobody tested the non-vgic path where user space controls the vgic, so two functions slipped through the cracks that get called in generic code but don't check whether hardware support is enabled. This patch guards them with proper checks to ensure we only try to use vgic data structures if they are available. Without this, I get a stack trace: [ 74.363037] Unable to handle kernel paging request at virtual address ffffffffffffffe8 [...] [ 74.929654] [] _raw_spin_lock+0x1c/0x58 [ 74.935133] [] kvm_vgic_flush_hwstate+0x88/0x288 [ 74.941406] [] kvm_arch_vcpu_ioctl_run+0xfc/0x630 [ 74.947766] [] kvm_vcpu_ioctl+0x2f4/0x710 [ 74.953420] [] do_vfs_ioctl+0xb0/0x728 [ 74.958807] [] SyS_ioctl+0x94/0xa8 [ 74.963844] [] el0_svc_naked+0x38/0x3c Fixes: 0919e84c0 Cc: stable@vger.kernel.org Signed-off-by: Alexander Graf --- virt/kvm/arm/vgic/vgic.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index e83b7fe..9f312ba 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -645,6 +645,9 @@ next: /* Sync back the hardware VGIC state into our emulation after a guest's run. */ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) { + if (!vcpu->kvm->arch.vgic.enabled) + return; + vgic_process_maintenance_interrupt(vcpu); vgic_fold_lr_state(vcpu); vgic_prune_ap_list(vcpu); @@ -653,6 +656,9 @@ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) /* Flush our emulation state into the GIC hardware before entering the guest. */ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) { + if (!vcpu->kvm->arch.vgic.enabled) + return; + spin_lock(&vcpu->arch.vgic_cpu.ap_list_lock); vgic_flush_lr_state(vcpu); spin_unlock(&vcpu->arch.vgic_cpu.ap_list_lock);