Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1833112imm; Mon, 3 Sep 2018 10:36:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYW/QMai72QQjqTujptX39TBZ3rxJhuWfdwrDPK1uIYYiGEjNsSLR/d4QB02HvX3nCnW4DM X-Received: by 2002:a17:902:bc4b:: with SMTP id t11-v6mr29073591plz.262.1535996167983; Mon, 03 Sep 2018 10:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535996167; cv=none; d=google.com; s=arc-20160816; b=Qat6s5j/xyVudijHujOBCz00fEv30ssZGwX3qD0zTXAUiQ4+NeqpT5oXAyGqdoJcx0 RW4PhQuuuO4EUsIboQdEomvsv6GKEiuNyYZAZZjf+sjnegoc0PEI+F7IlKZilOqPVgnR Nl5VjgB8I1zgGjOajzLmpR7PmpWo+aVU98xow19xMQBic77MHfllW47LdfsUaqRC2UeG HEAvYt0VUdFccKWmoNyzS3a0Xshg8ZG6uUm7wEqSBlypWzYOiDFyhm6JVWNUL+Ov0ixw 7sR38jGPcVV9WTRc/mJSVWxcx/mqSltJFA96inj4bfSqLYAK7TjsQUKS7Y1SO4sbi82/ VAyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nW7zggaPNBbn6XfkRLc3REo+RsAtOshcnpeX2fIsm6Y=; b=myllb2zG3hHpbokPvlgQ9sGJUSBHYoHbVgWcT6w0/O5YHN0rO8Cu2w8Qv0D8M5nazl tPljYtnmttnc/V7St1sVUz5SObrFONb9HYdbD6r9nqTdO6/vlA681BUio56MLkQCvOSM QmTdyaVUfSnivRpzs4VeHYcFd3Iq+GTKff8Y9lqovK4fFdehSISqB5YnjaaJaBA6j89v XvzeG6gpfnN7U9giv0XxTGFN4o9Xc3sTRT0zZBi+/89X+ggT0ikxWDe0comqYlIalZFn yVeKEFmf/nIl5gqYOkJcVy2ySecytVdkKO3O93+B1hyEOFLl+PUoOyXziHS7KfCdw2pk WGJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3-v6si18472606pgk.610.2018.09.03.10.35.52; Mon, 03 Sep 2018 10:36:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731420AbeICVz5 (ORCPT + 99 others); Mon, 3 Sep 2018 17:55:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47856 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728335AbeICVz5 (ORCPT ); Mon, 3 Sep 2018 17:55:57 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5FD56D16; Mon, 3 Sep 2018 17:34:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andre Przywara , Christoffer Dall , Marc Zyngier Subject: [PATCH 4.18 034/123] KVM: arm/arm64: Fix lost IRQs from emulated physcial timer when blocked Date: Mon, 3 Sep 2018 18:56:18 +0200 Message-Id: <20180903165720.922186161@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165719.499675257@linuxfoundation.org> References: <20180903165719.499675257@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christoffer Dall commit 245715cbe83ca934af5d20e078fd85175c62995e upstream. When the VCPU is blocked (for example from WFI) we don't inject the physical timer interrupt if it should fire while the CPU is blocked, but instead we just wake up the VCPU and expect kvm_timer_vcpu_load to take care of injecting the interrupt. Unfortunately, kvm_timer_vcpu_load() doesn't actually do that, it only has support to schedule a soft timer if the emulated phys timer is expected to fire in the future. Follow the same pattern as kvm_timer_update_state() and update the irq state after potentially scheduling a soft timer. Reported-by: Andre Przywara Cc: Stable # 4.15+ Fixes: bbdd52cfcba29 ("KVM: arm/arm64: Avoid phys timer emulation in vcpu entry/exit") Signed-off-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/arch_timer.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -487,6 +487,7 @@ void kvm_timer_vcpu_load(struct kvm_vcpu { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); + struct arch_timer_context *ptimer = vcpu_ptimer(vcpu); if (unlikely(!timer->enabled)) return; @@ -502,6 +503,10 @@ void kvm_timer_vcpu_load(struct kvm_vcpu /* Set the background timer for the physical timer emulation. */ phys_timer_emulate(vcpu); + + /* If the timer fired while we weren't running, inject it now */ + if (kvm_timer_should_fire(ptimer) != ptimer->irq.level) + kvm_timer_update_irq(vcpu, !ptimer->irq.level, ptimer); } bool kvm_timer_should_notify_user(struct kvm_vcpu *vcpu)