From patchwork Thu Apr 25 08:45:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 2487601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id D67FDDF5B1 for ; Thu, 25 Apr 2013 08:47:03 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVHp4-0000nH-Je; Thu, 25 Apr 2013 08:46:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVHom-0003fW-RE; Thu, 25 Apr 2013 08:46:16 +0000 Received: from mail-da0-f47.google.com ([209.85.210.47]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVHok-0003fC-NJ for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2013 08:46:15 +0000 Received: by mail-da0-f47.google.com with SMTP id p1so1322236dad.20 for ; Thu, 25 Apr 2013 01:46:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=CqcuqcTjPc6i5QcxPPaxY2cNmIaxc7xy0J7e+K4E4nQ=; b=iHDBYSKk13vRbIpj2mi2YN+z39d1VmpsjgHczDxZ9ieCIMGLX5qAgtsQxy2h9F4Dbc iqfPrn2XQUCL3jC06nbkn9ZPHzY1O/0BAlZ+usZLQ862tsF66ETBtzsP6xY8YdDF5Z0n bWIsKCAD2tjMy4HQpXaiaOcLA8++CFbg6Dt6bDXAACZaUUimf+1GyzDz4+7WDh+PnKUN LFyrVngCQfiyCmKpH9Lpia1V0J8H6p1WY20SqndQvokXGWluUj1UhzCqi1PGNLIjpYIW bRkVyhHzcpJa+jcvzLtYCxTcLH/K8eiWKCIfClCEL19Js0JwPIyMR06LNQgHvF1JSRhr 57Ww== X-Received: by 10.68.173.5 with SMTP id bg5mr52799463pbc.186.1366879569589; Thu, 25 Apr 2013 01:46:09 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.72.18.82]) by mx.google.com with ESMTPSA id xz4sm6514396pbb.18.2013.04.25.01.46.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Apr 2013 01:46:08 -0700 (PDT) From: Anup Patel To: kvmarm@lists.cs.columbia.edu Subject: [PATCH] ARM: KVM: Allow host virtual timer irq number to be different from guest virtual timer irq number Date: Thu, 25 Apr 2013 14:15:34 +0530 Message-Id: <1366879534-31578-1-git-send-email-anup.patel@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQniXu1tIiDs1o3siMxVEHjU7+0VE7j4tsYgb/CMCnhzVlv01pPL6bkdRL2hk+tzSwsooiNq X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130425_044614_860348_D530D582 X-CRM114-Status: GOOD ( 11.34 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.47 listed in list.dnswl.org] 2.5 SUSPICIOUS_RECIPS Similar addresses in recipient list -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-kernel@lists.linaro.org, Anup Patel , linux-arm-kernel@lists.infradead.org, Pranavkumar Sawargaonkar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The arch_timer irq numbers (or PPI number) are implementation dependent so, the host virtual timer irq number can be different from guest virtual timer irq number. Currently, we only have Cortex-A15 guest (for KVM ARMv7) and Cortex-A57 guest (for KVM ARMv8) supported. These guests have virtual timer irq number as 27. This patch ensures that host virtual timer irq number is read from DTB and guest virtual timer irq is always 27. Signed-off-by: Pranavkumar Sawargaonkar --- arch/arm/kvm/arch_timer.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/arm/kvm/arch_timer.c b/arch/arm/kvm/arch_timer.c index 49a7516..376abf0 100644 --- a/arch/arm/kvm/arch_timer.c +++ b/arch/arm/kvm/arch_timer.c @@ -30,10 +30,18 @@ static struct timecounter *timecounter; static struct workqueue_struct *wqueue; -static struct kvm_irq_level timer_irq = { +static struct kvm_irq_level host_timer_irq = { .level = 1, }; +/* Guest virtual timer irq number will be based on type of guest we emulate. + * For Cortex-A15 & Cortex-A57 guest, virtual timer irq is 27 + */ +static struct kvm_irq_level guest_timer_irq = { + .irq = 27, + .level = 1, +}; + static cycle_t kvm_phys_timer_read(void) { return timecounter->cc->read(timecounter->cc); @@ -163,12 +171,12 @@ void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu) INIT_WORK(&timer->expired, kvm_timer_inject_irq_work); hrtimer_init(&timer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); timer->timer.function = kvm_timer_expire; - timer->irq = &timer_irq; + timer->irq = &guest_timer_irq; } static void kvm_timer_init_interrupt(void *info) { - enable_percpu_irq(timer_irq.irq, 0); + enable_percpu_irq(host_timer_irq.irq, 0); } @@ -182,7 +190,7 @@ static int kvm_timer_cpu_notify(struct notifier_block *self, break; case CPU_DYING: case CPU_DYING_FROZEN: - disable_percpu_irq(timer_irq.irq); + disable_percpu_irq(host_timer_irq.irq); break; } @@ -230,7 +238,7 @@ int kvm_timer_hyp_init(void) goto out; } - timer_irq.irq = ppi; + host_timer_irq.irq = ppi; err = register_cpu_notifier(&kvm_timer_cpu_nb); if (err) {