From patchwork Fri Jan 27 01:04:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9540487 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 7141460429 for ; Fri, 27 Jan 2017 01:08:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60641281C3 for ; Fri, 27 Jan 2017 01:08:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54D6E28305; Fri, 27 Jan 2017 01:08:14 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7C2B281C3 for ; Fri, 27 Jan 2017 01:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753777AbdA0BGw (ORCPT ); Thu, 26 Jan 2017 20:06:52 -0500 Received: from outprodmail01.cc.columbia.edu ([128.59.72.39]:57855 "EHLO outprodmail01.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752987AbdA0BGZ (ORCPT ); Thu, 26 Jan 2017 20:06:25 -0500 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v0R156AR051140 for ; Thu, 26 Jan 2017 20:05:08 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id D574680 for ; Thu, 26 Jan 2017 20:05:08 -0500 (EST) Received: from sendprodmail01.cc.columbia.edu (sendprodmail01.cc.columbia.edu [128.59.72.13]) by hazelnut (Postfix) with ESMTP id B3F5B81 for ; Thu, 26 Jan 2017 20:05:08 -0500 (EST) Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by sendprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v0R158RT062501 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 26 Jan 2017 20:05:08 -0500 Received: by mail-qt0-f197.google.com with SMTP id w20so61044867qtb.3 for ; Thu, 26 Jan 2017 17:05:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=fclCMotDIKGxuc186LgWDZ6AkJGgLm68syPye1hp4z4=; b=kreskFUU7AYvHAVqJmG87HOMogdHhTti9KJbKqXOPE9mIrI0khzrYW5uV2txk8QROt NCM/oRKr9qZVGrLrxncAJiNdHEhd5Y3FSTyEyMk3y+f3kgsuREhkeNnRlj0G5ldfI0QX l1tKthSCCVPV5TsjXhuxkKv0XIfVNsryonaiyPnd842zLf7Ca+BIOQzzMgvJSvQMarYZ XpSRcaqZzCpUq9romqwk+A7q5hC8CSCbYwetZ7y9GNPOEOwKZYixaAWkLnUUqwlDebw3 QeL9ZtQoIvg4rkAYCyMCCK1HBGhcTnpcbopeayqR8ddaGsIYETHiJSlX6EjJ47+p52tP 1Fcg== X-Gm-Message-State: AIkVDXJnasoxdug3QnnS2bomvcxSmTFH8FolqI+kaXqXe8vq/IuoG1QyhcgfUEs71P2lKSQi69cRpFXvLxycKjxyvYAmBJRB2OAYrI/zjf4VX0Hu93rouLsdPuVKzV3OdloKpMlSPxbDdE4= X-Received: by 10.237.63.119 with SMTP id q52mr5544232qtf.29.1485479108342; Thu, 26 Jan 2017 17:05:08 -0800 (PST) X-Received: by 10.237.63.119 with SMTP id q52mr5544204qtf.29.1485479107858; Thu, 26 Jan 2017 17:05:07 -0800 (PST) Received: from jintack.cs.columbia.edu ([2001:18d8:ffff:16:21a:4aff:feaa:f900]) by smtp.gmail.com with ESMTPSA id f68sm2709538qkf.34.2017.01.26.17.05.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Jan 2017 17:05:07 -0800 (PST) From: Jintack Lim To: pbonzini@redhat.com, rkrcmar@redhat.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, andre.przywara@arm.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: [RFC v2 06/10] KVM: arm/arm64: Update the physical timer interrupt level Date: Thu, 26 Jan 2017 20:04:56 -0500 Message-Id: <1485479100-4966-7-git-send-email-jintack@cs.columbia.edu> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485479100-4966-1-git-send-email-jintack@cs.columbia.edu> References: <1485479100-4966-1-git-send-email-jintack@cs.columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.78 on 128.59.72.13 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we maintain the EL1 physical timer register states of VMs, update the physical timer interrupt level along with the virtual one. Note that the emulated EL1 physical timer is not mapped to any hardware timer, so we call a proper vgic function. Signed-off-by: Jintack Lim --- virt/kvm/arm/arch_timer.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 0f6e935..3b6bd50 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -180,6 +180,21 @@ static void kvm_timer_update_mapped_irq(struct kvm_vcpu *vcpu, bool new_level, WARN_ON(ret); } +static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level, + struct arch_timer_context *timer) +{ + int ret; + + BUG_ON(!vgic_initialized(vcpu->kvm)); + + timer->irq.level = new_level; + trace_kvm_timer_update_irq(vcpu->vcpu_id, timer->irq.irq, + timer->irq.level); + ret = kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id, timer->irq.irq, + timer->irq.level); + WARN_ON(ret); +} + /* * Check if there was a change in the timer state (should we raise or lower * the line level to the GIC). @@ -188,6 +203,7 @@ static int kvm_timer_update_state(struct kvm_vcpu *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 userspace modified the timer registers via SET_ONE_REG before @@ -201,6 +217,10 @@ static int kvm_timer_update_state(struct kvm_vcpu *vcpu) if (kvm_timer_should_fire(vcpu, vtimer) != vtimer->irq.level) kvm_timer_update_mapped_irq(vcpu, !vtimer->irq.level, vtimer); + /* The emulated EL1 physical timer irq is not mapped to hardware */ + if (kvm_timer_should_fire(vcpu, ptimer) != ptimer->irq.level) + kvm_timer_update_irq(vcpu, !ptimer->irq.level, ptimer); + return 0; }