From patchwork Tue Dec 1 10:19:45 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pavel Fedin
X-Patchwork-Id: 7735261
Return-Path:
X-Original-To: patchwork-kvm@patchwork.kernel.org
Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org
Received: from mail.kernel.org (mail.kernel.org [198.145.29.136])
by patchwork1.web.kernel.org (Postfix) with ESMTP id BC1C59F54F
for ;
Tue, 1 Dec 2015 10:20:06 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id DC55420644
for ;
Tue, 1 Dec 2015 10:20:04 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
by mail.kernel.org (Postfix) with ESMTP id B9A8D20544
for ;
Tue, 1 Dec 2015 10:20:03 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1754402AbbLAKT7 (ORCPT
);
Tue, 1 Dec 2015 05:19:59 -0500
Received: from mailout3.w1.samsung.com ([210.118.77.13]:30831 "EHLO
mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1753881AbbLAKTy (ORCPT );
Tue, 1 Dec 2015 05:19:54 -0500
Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245])
by mailout3.w1.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTP id <0NYO00ARXCP40N50@mailout3.w1.samsung.com> for
kvm@vger.kernel.org; Tue, 01 Dec 2015 10:19:52 +0000 (GMT)
X-AuditID: cbfec7f5-f79b16d000005389-68-565d7448d2b8
Received: from eusync3.samsung.com ( [203.254.199.213])
by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 0E.AF.21385.8447D565;
Tue, 1 Dec 2015 10:19:52 +0000 (GMT)
Received: from fedinw7x64.rnd.samsung.ru ([106.109.131.169])
by eusync3.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTPA id <0NYO000Z3COXWS30@eusync3.samsung.com>; Tue,
01 Dec 2015 10:19:52 +0000 (GMT)
From: Pavel Fedin
To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org
Cc: Marc Zyngier ,
Christoffer Dall ,
Gleb Natapov , Paolo Bonzini
Subject: [PATCH 3/3] KVM: arm/arm64: Decouple virtual timer from vGIC
Date: Tue, 01 Dec 2015 13:19:45 +0300
Message-id:
<341e7e63157bc677594fc92ac89cc365c37a3bc5.1448965024.git.p.fedin@samsung.com>
X-Mailer: git-send-email 2.4.4
In-reply-to:
References:
In-reply-to:
References:
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsVy+t/xq7oeJbFhBhfW81q8eP2P0eLLz+uM
FnOmFlp8PHWc3eLvnX9sFvu3/WN1YPNYM28No8emVZ1sHneu7WHzOL9pDbPH+31X2Tw+b5IL
YIvisklJzcksSy3St0vgyjja1spYsE2soufoP8YGxvlCXYycHBICJhKLj+9lg7DFJC7cWw9k
c3EICSxllJj+uwPKaWOSeHF6LitIFZuAusTprx9YQGwRAVOJ5//esoIUMQssYJR4Ne8rWJGw
gKvE6y/TmUFsFgFVib9Hf4Kt4BWIlth+ah07xDo5iSvXp4PFOQXMJQ4f6QGrFxIwk9iwfwdO
8QmM/AsYGVYxiqaWJhcUJ6XnGukVJ+YWl+al6yXn525ihITh1x2MS49ZHWIU4GBU4uGVWBsT
JsSaWFZcmXuIUYKDWUmEt7cgNkyINyWxsiq1KD++qDQntfgQozQHi5I478xd70OEBNITS1Kz
U1MLUotgskwcnFINjH4tE38baIkf/vAhWCdJ+1OaXXDq+zPHF0vkViUwzHyhWNhZrdPWtl14
TZNBVM7RT1sWpff+EBVYebqHkbvz/+JLCsv/8PCezqo8mXErSqza6+Eh6V0SkcwfUiUfPDeK
6S1PqUxgZ/n9b3N4xPlo9opDXHus3Z/GPryaW/58eiDPGhG1GdVSSizFGYmGWsxFxYkA6EqF
3T8CAAA=
Sender: kvm-owner@vger.kernel.org
Precedence: bulk
List-ID:
X-Mailing-List: kvm@vger.kernel.org
X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI,
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
Remove dependency on vgic_initialized() and use the newly introduced
infrastructure to send interrupts via the userspace if vGIC is not being
used.
Signed-off-by: Pavel Fedin
---
arch/arm/kvm/arm.c | 8 +-------
virt/kvm/arm/arch_timer.c | 23 +++++++++++++----------
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 6392a5b..e729068 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -468,13 +468,7 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
return ret;
}
- /*
- * Enable the arch timers only if we have an in-kernel VGIC
- * and it has been properly initialized, since we cannot handle
- * interrupts from the virtual timer with a userspace gic.
- */
- if (irqchip_in_kernel(kvm) && vgic_initialized(kvm))
- kvm_timer_enable(kvm);
+ kvm_timer_enable(kvm);
return 0;
}
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 69bca18..90c91b0 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -128,15 +128,17 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level)
int ret;
struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
- BUG_ON(!vgic_initialized(vcpu->kvm));
-
timer->irq.level = new_level;
trace_kvm_timer_update_irq(vcpu->vcpu_id, timer->map->virt_irq,
timer->irq.level);
- ret = kvm_vgic_inject_mapped_irq(vcpu->kvm, vcpu->vcpu_id,
- timer->map,
- timer->irq.level);
- WARN_ON(ret);
+ if (irqchip_in_kernel(vcpu->kvm)) {
+ ret = kvm_vgic_inject_mapped_irq(vcpu->kvm, vcpu->vcpu_id,
+ timer->map,
+ timer->irq.level);
+ WARN_ON(ret);
+ } else {
+ vcpu->irq = &timer->irq;
+ }
}
/*
@@ -149,12 +151,12 @@ static void kvm_timer_update_state(struct kvm_vcpu *vcpu)
/*
* If userspace modified the timer registers via SET_ONE_REG before
- * the vgic was initialized, we mustn't set the timer->irq.level value
+ * the timer was initialized, we mustn't set the timer->irq.level value
* because the guest would never see the interrupt. Instead wait
* until we call this function from kvm_timer_flush_hwstate.
*/
- if (!vgic_initialized(vcpu->kvm))
- return;
+ if (!vcpu->kvm->arch.timer.enabled)
+ return;
if (kvm_timer_should_fire(vcpu) != timer->irq.level)
kvm_timer_update_irq(vcpu, !timer->irq.level);
@@ -237,7 +239,8 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu)
* to ensure that hardware interrupts from the timer triggers a guest
* exit.
*/
- if (timer->irq.level || kvm_vgic_map_is_active(vcpu, timer->map))
+ if (timer->irq.level || (irqchip_in_kernel(vcpu->kvm) &&
+ kvm_vgic_map_is_active(vcpu, timer->map)))
phys_active = true;
else
phys_active = false;