From patchwork Tue Sep 5 14:52:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 111688 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp5584805ybm; Tue, 5 Sep 2017 07:52:23 -0700 (PDT) X-Received: by 10.98.219.6 with SMTP id f6mr1658274pfg.59.1504623143639; Tue, 05 Sep 2017 07:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504623143; cv=none; d=google.com; s=arc-20160816; b=dh1q15keMQIEQfMLK6+p220P9fr8sLiRXOvY2OzbIBLcqfYyZQ9p9JX9iCS3k7aat1 WTNDFaGVUzJ/spVqGyLFHsD75GFdEl1FWdS89zilxvbRF2i7DO9bKETmfUq2uggEvIf0 MrDmdl3SnVGPT8rITRJedcWfAS+KTW+HTlDxSbKVkNWoiVWcMYgpLTcd8tNgNsAoplab EsqG3vvsW6UNLcmuZMx+8E4udoeuGLStMbx/QaRqeyvdEGGaPmNpCtz/QfWL4gw02WSs /8ISV/z+E2OTBaHqj4hmFcimgtZA/11pre4cMlToVOjZivqdYzotW2JDwQgHkTiiG3dO 23wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=C5mcrcSYz1JszUCrY5rd4ytVwD04XUEXna1B0/tl3Ww=; b=MyXZg5h3l8idNYYlPQ7IszA0cT09ALhGP7yK53Cu2W5lZFTbrRJOtei8b/dNoDYnVX QDX5sWPfrEf/ceya+C+ScaVGS94oKcbCnsmhJ4wAosfj3OemxrSLzXH0/ThkW5e6A24z OA5ZMQzCsA62yQY5/OIg+4TOzk15K3vN5Vvm0DWuOFszJED5Qv0ROMAPD9gFA9SgpMuc FMQwVtct1mPP36PieQaOG93wUn21WUOsMyHW66REC8DaeVTdiP4QvnhQmjUT7yDwlUDY mVM9OVwldwABceCWHmsVv20zDCp206MFRHbqZTc/l2q523x7jO9BlIPypz1Y+x6Lwx2z ws3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7KpyGHc; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si365197pgd.499.2017.09.05.07.52.23; Tue, 05 Sep 2017 07:52:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7KpyGHc; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751969AbdIEOwW (ORCPT + 6 others); Tue, 5 Sep 2017 10:52:22 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37806 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751778AbdIEOwS (ORCPT ); Tue, 5 Sep 2017 10:52:18 -0400 Received: by mail-wm0-f53.google.com with SMTP id u26so20488310wma.0 for ; Tue, 05 Sep 2017 07:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C5mcrcSYz1JszUCrY5rd4ytVwD04XUEXna1B0/tl3Ww=; b=S7KpyGHcSXhyPIx3y3e6ltGj/augHWXYXlWPeNlZigojr/bBSLPy6ivms4QO2SO74U KLVkkRoLVNsi/fZOsk+1X5809e2L9jsJnB/R4dFNuwKioDen0pP/Om4hXXodrgtGKaEK NgnAXGX6FvOsk/N+avZApum6KOtoqV9BH9Rj4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C5mcrcSYz1JszUCrY5rd4ytVwD04XUEXna1B0/tl3Ww=; b=ozyMjH1CBQ4fTgxuP6J2t/nIRN3C76HzoJmjMB4/+pSQ+vaSaN8W4ZDzWYmn55cytT HKm/WRl4fRvM8o6T7A0edhKvwZVuI2+9nhLWOe5xje1Lj6a6QD9ZOxnbllPT6PMJiZdv 0MrnUMelRrHDJS3EwwHF4t4OPr9aS2ZJxR0AaFHTDVz5sBpZVEokCzDiNrwik5MuQrGx vhzqoONr0Aeq0221pvefYLmNs67esfUTZx8oEDnVvzlhZvWlikhQrRnUPYmbcPdiyY52 qUWKNlTtYS2+dH5yXFNVb/6qxzmScC12Ta8PM+OJVAHbAy1lxrXjzgn3XuUGKD33VYmn 8rpA== X-Gm-Message-State: AHPjjUiy+NdlpSZZRzFcb/93VbrFtz1kjCZQZNpOUwwyE7oU/ye3py/k IXUzSLuMqUxampR0 X-Google-Smtp-Source: ADKCNb7ZVt8BKCltBRGEy9n0az30aHEzfGJiP6X+D4lF9wYDi680V8J6Ezc0GWQFlFJCedvLB5PxbA== X-Received: by 10.80.143.67 with SMTP id 61mr3446553edy.290.1504623136567; Tue, 05 Sep 2017 07:52:16 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id a28sm293809edc.14.2017.09.05.07.52.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 07:52:15 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Shanker Donthineni , stable@vger.kernel.org Subject: [PULL 1/8] KVM: arm/arm64: Fix bug in advertising KVM_CAP_MSI_DEVID capability Date: Tue, 5 Sep 2017 16:52:00 +0200 Message-Id: <20170905145207.18447-2-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170905145207.18447-1-cdall@linaro.org> References: <20170905145207.18447-1-cdall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Shanker Donthineni Commit 0e4e82f154e3 ("KVM: arm64: vgic-its: Enable ITS emulation as a virtual MSI controller") tried to advertise KVM_CAP_MSI_DEVID, but the code logic was not updating the dist->msis_require_devid field correctly. If hypervisor tool creates the ITS device after VGIC initialization then we don't advertise KVM_CAP_MSI_DEVID capability. Update the field msis_require_devid to true inside vgic_its_create() to fix the issue. Cc: stable@vger.kernel.org Fixes: 0e4e82f154e3 ("vgic-its: Enable ITS emulation as a virtual MSI controller") Signed-off-by: Shanker Donthineni Signed-off-by: Marc Zyngier --- virt/kvm/arm/vgic/vgic-init.c | 3 --- virt/kvm/arm/vgic/vgic-its.c | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) -- 2.9.0 diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index 3a0b899..5801261 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -285,9 +285,6 @@ int vgic_init(struct kvm *kvm) if (ret) goto out; - if (vgic_has_its(kvm)) - dist->msis_require_devid = true; - kvm_for_each_vcpu(i, vcpu, kvm) kvm_vgic_vcpu_enable(vcpu); diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 2dff288..aa6b68d 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1598,6 +1598,7 @@ static int vgic_its_create(struct kvm_device *dev, u32 type) INIT_LIST_HEAD(&its->device_list); INIT_LIST_HEAD(&its->collection_list); + dev->kvm->arch.vgic.msis_require_devid = true; dev->kvm->arch.vgic.has_its = true; its->enabled = false; its->dev = dev; From patchwork Tue Sep 5 14:52:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 111690 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp5585166ybm; Tue, 5 Sep 2017 07:52:48 -0700 (PDT) X-Received: by 10.84.217.91 with SMTP id e27mr4456791plj.99.1504623168579; Tue, 05 Sep 2017 07:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504623168; cv=none; d=google.com; s=arc-20160816; b=nZbO20iJI6nFu39WQS9HB06f0llN86vHPGlT4KA4LQvq0O5VL9h0EYzr5DiId4zVX+ 9OGiGEHPnFogtDZAbqVdXC2SNI+OPKRsX2yesaCkJpP7oY6Tg3VgowUlmYKVZn7baLkR BLFD8LYgrs+3pL3JRTaaetfZrq63ww+negmWv4e1w2axRvnETMCHb630dp1z3ROaB3mQ 1NNbnineO00metZzUUZY2KDHiLwZEa4mFP/MU9bmkBGVmi5uaaKtGiOExh+Z1Ya8MRL2 kCFYid0PcD6d9R6yQYB2K3aNQf8BJ09xqivP13QizFkPUIhuxdsBq4P4ImGx1GVwHDDh akHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4QiWICnV1aXkBo3u9jBc/us9u1kWSriFMFHu31UQ7jU=; b=lzIzQCnnve7MLfUkOixccLEflGkUJWtys+uDRS8BM3y9HxokOH0tYy0dD4+6i4ucou OsmCYOyOfwGcJzFUDrUCf/i1e43IumxV6JGVrCJ2vIrOZuQVIrmxxyVLBUsjiiwgZL7G vgv2ZlQu9noqZX4u1DmlX1lzcltRQu1jtruOZOG3386NXw7oWCb/zaFY0QlIJoU19b23 W/q/kVNHX9yH4xIxa07BRzI0jZmooNrGwwFBzJ24FNHpPfPjPedaBw/0JCN1nSlS7Hiv +j2HE3phrKL0f3iHqrBBq6GgP5wDIsW43T+boKx9ZfggWuPRk8pxzXDLHDFzZap1vkMa 9Y6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HThIkp3c; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si365197pgd.499.2017.09.05.07.52.48; Tue, 05 Sep 2017 07:52:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HThIkp3c; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751857AbdIEOwp (ORCPT + 6 others); Tue, 5 Sep 2017 10:52:45 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:36580 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751835AbdIEOwT (ORCPT ); Tue, 5 Sep 2017 10:52:19 -0400 Received: by mail-wm0-f47.google.com with SMTP id i145so20451957wmf.1 for ; Tue, 05 Sep 2017 07:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4QiWICnV1aXkBo3u9jBc/us9u1kWSriFMFHu31UQ7jU=; b=HThIkp3c5lZxj5EkkYRTQZ/OUfiDkTKjB/mZnjcfUrSvJaFcrqL1+LzFw32jzUSiSi MSEqYVsqb5jePQ6w4wzW/vALMr+ENTrlysWj15oh7ptHfbvgRwjgveOUJREFQidmuDMM 9+fawuf6BPCjGZILp1nx0vj+Jf3BdyUeS3Q3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4QiWICnV1aXkBo3u9jBc/us9u1kWSriFMFHu31UQ7jU=; b=MHVdtrII9XNKNoEHLiYTh0k8AzUtaTAvTwhiP1O2PYYZRmWJCvmLYeimOzJh4g1i49 9BJxD/mxa4x06zmU/2xsEeXDzr+VThHkFBcU04yBeB0bClM0HeP1v4aERO4bmMJ01mKT /xzU13xJehwp/faJe1RfCMeLjmG7cEPIuKBBMadH+LIWWP5mdmbilTdBkb6sSMztdTMn ezSesO0B8OGzffB1zPsJHjih4iN6Qpn8PuElHKP/VSz7fdcIoQNdhklGfuMEvHN4s4Xs KcwEBEjazutcv0VBoHel3NOX1yRk0z+u65EDCVrR5FT0GZupg7CgCzkNm5KMEg9pwy3O kjBQ== X-Gm-Message-State: AHPjjUh8fyj6WHhWzusWFbGJpoU7NIrBUTqeYZvs5Y6eXIhFQPy6aS9S rLfQIvnx/Nc6NVd4 X-Google-Smtp-Source: ADKCNb4G14w6ztLs5MjJ+mFRUHIC5jDfVF7RElAdKg8D4WGz6h2Eo16ketiLQWb9sjJC5niNdWuOuQ== X-Received: by 10.80.203.6 with SMTP id g6mr3594404edi.54.1504623138091; Tue, 05 Sep 2017 07:52:18 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id a28sm293809edc.14.2017.09.05.07.52.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 07:52:17 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Andrew Jones , stable@vger.kernel.org Subject: [PULL 2/8] KVM: arm/arm64: PMU: Fix overflow interrupt injection Date: Tue, 5 Sep 2017 16:52:01 +0200 Message-Id: <20170905145207.18447-3-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170905145207.18447-1-cdall@linaro.org> References: <20170905145207.18447-1-cdall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Andrew Jones kvm_pmu_overflow_set() is called from perf's interrupt handler, making the call of kvm_vgic_inject_irq() from it introduced with "KVM: arm/arm64: PMU: remove request-less vcpu kick" a really bad idea, as it's quite easy to try and retake a lock that the interrupted context is already holding. The fix is to use a vcpu kick, leaving the interrupt injection to kvm_pmu_sync_hwstate(), like it was doing before the refactoring. We don't just revert, though, because before the kick was request-less, leaving the vcpu exposed to the request-less vcpu kick race, and also because the kick was used unnecessarily from register access handlers. Cc: stable@vger.kernel.org Reviewed-by: Christoffer Dall Signed-off-by: Andrew Jones Signed-off-by: Marc Zyngier --- arch/arm64/kvm/sys_regs.c | 2 +- include/kvm/arm_pmu.h | 2 -- virt/kvm/arm/pmu.c | 43 +++++++++++++++---------------------------- 3 files changed, 16 insertions(+), 31 deletions(-) -- 2.9.0 diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 7786288..2e070d3 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -764,7 +764,7 @@ static bool access_pmovs(struct kvm_vcpu *vcpu, struct sys_reg_params *p, if (p->is_write) { if (r->CRm & 0x2) /* accessing PMOVSSET_EL0 */ - kvm_pmu_overflow_set(vcpu, p->regval & mask); + vcpu_sys_reg(vcpu, PMOVSSET_EL0) |= (p->regval & mask); else /* accessing PMOVSCLR_EL0 */ vcpu_sys_reg(vcpu, PMOVSSET_EL0) &= ~(p->regval & mask); diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h index f6e0306..f87fe20 100644 --- a/include/kvm/arm_pmu.h +++ b/include/kvm/arm_pmu.h @@ -48,7 +48,6 @@ void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu); void kvm_pmu_vcpu_destroy(struct kvm_vcpu *vcpu); void kvm_pmu_disable_counter(struct kvm_vcpu *vcpu, u64 val); void kvm_pmu_enable_counter(struct kvm_vcpu *vcpu, u64 val); -void kvm_pmu_overflow_set(struct kvm_vcpu *vcpu, u64 val); void kvm_pmu_flush_hwstate(struct kvm_vcpu *vcpu); void kvm_pmu_sync_hwstate(struct kvm_vcpu *vcpu); bool kvm_pmu_should_notify_user(struct kvm_vcpu *vcpu); @@ -86,7 +85,6 @@ static inline void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu) {} static inline void kvm_pmu_vcpu_destroy(struct kvm_vcpu *vcpu) {} static inline void kvm_pmu_disable_counter(struct kvm_vcpu *vcpu, u64 val) {} static inline void kvm_pmu_enable_counter(struct kvm_vcpu *vcpu, u64 val) {} -static inline void kvm_pmu_overflow_set(struct kvm_vcpu *vcpu, u64 val) {} static inline void kvm_pmu_flush_hwstate(struct kvm_vcpu *vcpu) {} static inline void kvm_pmu_sync_hwstate(struct kvm_vcpu *vcpu) {} static inline bool kvm_pmu_should_notify_user(struct kvm_vcpu *vcpu) diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c index fc8a723..8a9c423 100644 --- a/virt/kvm/arm/pmu.c +++ b/virt/kvm/arm/pmu.c @@ -203,11 +203,15 @@ static u64 kvm_pmu_overflow_status(struct kvm_vcpu *vcpu) return reg; } -static void kvm_pmu_check_overflow(struct kvm_vcpu *vcpu) +static void kvm_pmu_update_state(struct kvm_vcpu *vcpu) { struct kvm_pmu *pmu = &vcpu->arch.pmu; - bool overflow = !!kvm_pmu_overflow_status(vcpu); + bool overflow; + + if (!kvm_arm_pmu_v3_ready(vcpu)) + return; + overflow = !!kvm_pmu_overflow_status(vcpu); if (pmu->irq_level == overflow) return; @@ -215,33 +219,11 @@ static void kvm_pmu_check_overflow(struct kvm_vcpu *vcpu) if (likely(irqchip_in_kernel(vcpu->kvm))) { int ret = kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id, - pmu->irq_num, overflow, - &vcpu->arch.pmu); + pmu->irq_num, overflow, pmu); WARN_ON(ret); } } -/** - * kvm_pmu_overflow_set - set PMU overflow interrupt - * @vcpu: The vcpu pointer - * @val: the value guest writes to PMOVSSET register - */ -void kvm_pmu_overflow_set(struct kvm_vcpu *vcpu, u64 val) -{ - if (val == 0) - return; - - vcpu_sys_reg(vcpu, PMOVSSET_EL0) |= val; - kvm_pmu_check_overflow(vcpu); -} - -static void kvm_pmu_update_state(struct kvm_vcpu *vcpu) -{ - if (!kvm_arm_pmu_v3_ready(vcpu)) - return; - kvm_pmu_check_overflow(vcpu); -} - bool kvm_pmu_should_notify_user(struct kvm_vcpu *vcpu) { struct kvm_pmu *pmu = &vcpu->arch.pmu; @@ -303,7 +285,7 @@ static inline struct kvm_vcpu *kvm_pmc_to_vcpu(struct kvm_pmc *pmc) } /** - * When perf event overflows, call kvm_pmu_overflow_set to set overflow status. + * When the perf event overflows, set the overflow status and inform the vcpu. */ static void kvm_pmu_perf_overflow(struct perf_event *perf_event, struct perf_sample_data *data, @@ -313,7 +295,12 @@ static void kvm_pmu_perf_overflow(struct perf_event *perf_event, struct kvm_vcpu *vcpu = kvm_pmc_to_vcpu(pmc); int idx = pmc->idx; - kvm_pmu_overflow_set(vcpu, BIT(idx)); + vcpu_sys_reg(vcpu, PMOVSSET_EL0) |= BIT(idx); + + if (kvm_pmu_overflow_status(vcpu)) { + kvm_make_request(KVM_REQ_IRQ_PENDING, vcpu); + kvm_vcpu_kick(vcpu); + } } /** @@ -341,7 +328,7 @@ void kvm_pmu_software_increment(struct kvm_vcpu *vcpu, u64 val) reg = lower_32_bits(reg); vcpu_sys_reg(vcpu, PMEVCNTR0_EL0 + i) = reg; if (!reg) - kvm_pmu_overflow_set(vcpu, BIT(i)); + vcpu_sys_reg(vcpu, PMOVSSET_EL0) |= BIT(i); } } } From patchwork Tue Sep 5 14:52:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 111689 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp5584853ybm; Tue, 5 Sep 2017 07:52:26 -0700 (PDT) X-Received: by 10.99.126.84 with SMTP id o20mr4379394pgn.239.1504623146854; Tue, 05 Sep 2017 07:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504623146; cv=none; d=google.com; s=arc-20160816; b=H9UUhfV7mrt/ruG6SdmcckI9qcNfBkjSPfAVcoJjjm1beJDkiVk5pf58HAyn5aHeX+ 5sqDzEzgRF3p08ndfqEJrru98Y2d5uS0iMCABZ3Pj0uruxTyISyPvAFo3LAc1Q5RaTgo IIJjrI79AVyOY205izx8yxZIb7OJSti5Q0Kpd1YaO+hbaDoSns4m+4+4sRi083ne4dS/ ZDjqLk8zYVuWM1FPDs0ztsD4b6/OqwoD0yzZ5YK9HncbiJ3HgoTonNBpH576Qoake2ds UsR1p7khA7IufrF4on0Ai5D0eHKx4KBdqL9IKw2uahFEKEeME/A0YcsdB8D1EyC3Fy/t 3Pjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=P40sPM+bpPwt4Ofd4X9sttgTW53WOA7sah6mw3xKPZ8=; b=IwMfkaooMZzBBisqKj7ZHq/ibYI42hrNpB8YYocLc9b2HhgevJpKqddZH8oq8yqqZe htL7tiXIWxwm5VaLYiMRc4N4naSfhjloBUEW4yHQuiJ5wn1QzFJfwnxLVcw3Byu4iWAf kp7YN9NeC2f+YOfE4CXp0wXj3jOeeJKIy8w7sNQt/j8Ke0RLmNShLLAyJ4oF7hPa9xJ3 QYnYE4V9u1ZpnEVC5mwA9H5sowtgJL9zo+VLOsyJs6rmBWto91sxt5FLD97okn9YGYCF 2AJhMfkPFl/Axr3IxAJ2WHFhf5pEuZfeMRNyZDWUeN9RBWkDKH6ktKpvirm6bvdyoxXS zV9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eqPh+6w+; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si365197pgd.499.2017.09.05.07.52.26; Tue, 05 Sep 2017 07:52:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eqPh+6w+; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751974AbdIEOwZ (ORCPT + 6 others); Tue, 5 Sep 2017 10:52:25 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:36592 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751863AbdIEOwV (ORCPT ); Tue, 5 Sep 2017 10:52:21 -0400 Received: by mail-wm0-f46.google.com with SMTP id i145so20452214wmf.1 for ; Tue, 05 Sep 2017 07:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P40sPM+bpPwt4Ofd4X9sttgTW53WOA7sah6mw3xKPZ8=; b=eqPh+6w+vXOLscbws0/1XKfqTgQMgcXoPwM/kCYTdJbN/nl71GP4UPbNNlSSosR0ul 6bCW1ivjhtVxWcZmRDa+YMEGP6P6EWLd38ufBXgiKKMdSwD2sSgl6DbH8cscWhp+09Mz 00Fs3UYT3FQKAgaNOvKRQYn+EdPtAiJxOAl5o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P40sPM+bpPwt4Ofd4X9sttgTW53WOA7sah6mw3xKPZ8=; b=M5UgGaim0aXtSclxa6M6BwP/6qBkko6fhBBgIulL1I07iPVuN1OdSMXWO3LYQ2uoKL XDUsw0JC/LN6MXVvICvm7QlWlcVHZrCXZ2aA6afP/3w8WYxcqHbZmPmtJ+kTVRjbvLk5 OtDLum/dzoX+FnllRMDUsxVptaOiz8Y4oDD0NMjr6LTHwbCyXFOfmVtjdfqIeCFERS4Z 8tQkTjlxwSWcux/wERqvMmJB08gtI/eCSfiX85kLCmRysRiAtf11Snt+IO/YHWb7Vun9 urkQbovsBL67Qo8hniwP69HmMOLfYxo65niqA3Sp3y7JUZuNeroojjjAEo5EogJqWuoJ zaeg== X-Gm-Message-State: AHPjjUirJJZSXBBJ1T2m/e05cLfkRUSGqD0NZcCvzjkLr6Qjdd8lJTkB fsYdctxjtzUr+K+9aDAFIw== X-Google-Smtp-Source: ADKCNb6AE+/mGmSz1M4zpEmAU2iL2KFvQnPaGZsDjMJII/MW++NW/lNe/EEgV+C/a+jWqKXrA8kJPA== X-Received: by 10.80.218.10 with SMTP id z10mr3372658edj.224.1504623139483; Tue, 05 Sep 2017 07:52:19 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id a28sm293809edc.14.2017.09.05.07.52.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 07:52:18 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Suzuki K Poulose , stable@vger.kernel.org, Suzuki K Poulose Subject: [PULL 3/8] KVM: arm/arm64: Handle hva aging while destroying the vm Date: Tue, 5 Sep 2017 16:52:02 +0200 Message-Id: <20170905145207.18447-4-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170905145207.18447-1-cdall@linaro.org> References: <20170905145207.18447-1-cdall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Suzuki K Poulose The mmu_notifier_release() callback of KVM triggers cleaning up the stage2 page table on kvm-arm. However there could be other notifier callbacks in parallel with the mmu_notifier_release(), which could cause the call backs ending up in an empty stage2 page table. Make sure we check it for all the notifier callbacks. Cc: stable@vger.kernel.org Fixes: commit 293f29363 ("kvm-arm: Unmap shadow pagetables properly") Reported-by: Alex Graf Reviewed-by: Christoffer Dall Signed-off-by: Suzuki K Poulose Signed-off-by: Marc Zyngier --- virt/kvm/arm/mmu.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.9.0 diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 0e1fc75..2ea21da 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1718,12 +1718,16 @@ static int kvm_test_age_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void * int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end) { + if (!kvm->arch.pgd) + return 0; trace_kvm_age_hva(start, end); return handle_hva_to_gpa(kvm, start, end, kvm_age_hva_handler, NULL); } int kvm_test_age_hva(struct kvm *kvm, unsigned long hva) { + if (!kvm->arch.pgd) + return 0; trace_kvm_test_age_hva(hva); return handle_hva_to_gpa(kvm, hva, hva, kvm_test_age_hva_handler, NULL); }