From patchwork Fri Apr 26 13:32:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 2493881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 4DA903FD40 for ; Fri, 26 Apr 2013 13:33:26 +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 1UVilu-0004Eh-Rf; Fri, 26 Apr 2013 13:33:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVilm-0004Ci-KE; Fri, 26 Apr 2013 13:32:58 +0000 Received: from mail-da0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVilf-0004CE-EG for linux-arm-kernel@lists.infradead.org; Fri, 26 Apr 2013 13:32:52 +0000 Received: by mail-da0-f45.google.com with SMTP id v40so1930758dad.18 for ; Fri, 26 Apr 2013 06:32:48 -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=F8wtOAwUQNIeImnOGYWFO0aEH8NVq9YImodzD4i7Owg=; b=LXKSnYu8uiywZ3BRmoy3BQ7Fn/HOJCDHb2EpEKBc7Up20qQMlRXM0yGnMlnEL+xFVV +i/LbI1IivjEuxVutDbgJ0O9b3jQBC9lzyZuwyAK9XTa6TPJttkjsY065v8veZDRKw02 3uIIqQkWXbv2mDCFsMfUf3Z8gvLxSaIrjr80WAH1DfJzSmiac8mPLIz4q56V56tl6wb/ ib6Pzd+SDO7dVuEAKk9p+irZggarAkcPrnvj/f/7qmnYnd0tpLhn+jdaX00tkjOEsQyT /36YA5+4ODM4csfXN1w1Y3jzjQmRLC7hViADzMCAwCMH9cAdLwq+D1Tw0riOdxsS6Ezv aMBA== X-Received: by 10.66.228.233 with SMTP id sl9mr8651172pac.38.1366983168898; Fri, 26 Apr 2013 06:32:48 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.72.18.82]) by mx.google.com with ESMTPSA id nt2sm5191929pbc.17.2013.04.26.06.32.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Apr 2013 06:32:48 -0700 (PDT) From: Anup Patel To: kvmarm@lists.cs.columbia.edu Subject: [PATCH] arm64: KVM: Add kvm_target_timer_irq() for arch_timer Date: Fri, 26 Apr 2013 19:02:16 +0530 Message-Id: <1366983136-11147-1-git-send-email-anup.patel@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQkrEvIdLA5mg/DUm7GY+QUBBfA1O9TjIqceYinX5Ki/gunrRGPaVuLA/yvsLt0XRsP8R9d9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130426_093251_623268_74A971F3 X-CRM114-Status: GOOD ( 13.11 ) X-Spam-Score: 0.6 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (0.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- 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: marc.zyngier@arm.com, 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 This patch adds kvm_target_timer_irq() for KVM ARM64 which determines guest virtual timer ppi number based on vcpu target type. The patch also updates kvm_vcpu_reset() so that arch_timer is resetted on every vcpu reset. Signed-off-by: Anup Patel Signed-off-by: Pranavkumar Sawargaonkar --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/guest.c | 17 +++++++++++++++++ arch/arm64/kvm/reset.c | 13 +++++++++++++ 3 files changed, 31 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 77eec44..23e185d 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -43,6 +43,7 @@ struct kvm_vcpu; int kvm_target_cpu(void); +struct kvm_irq_level *kvm_target_timer_irq(struct kvm_vcpu *vcpu); int kvm_reset_vcpu(struct kvm_vcpu *vcpu); int kvm_arch_dev_ioctl_check_extension(long ext); diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 8dc349b..ac9ec08 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -36,6 +36,11 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { { NULL } }; +static struct kvm_irq_level target_cortex_a57_timer_irq = { + .irq = 27, + .level = 1, +}; + int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) { vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS; @@ -224,6 +229,18 @@ int __attribute_const__ kvm_target_cpu(void) } } +struct kvm_irq_level *kvm_target_timer_irq(struct kvm_vcpu *vcpu) +{ + switch (vcpu->arch.target) { + case KVM_ARM_TARGET_AEM_V8: + case KVM_ARM_TARGET_FOUNDATION_V8: + case KVM_ARM_TARGET_CORTEX_A57: + return &target_cortex_a57_timer_irq; + default: + return NULL; + }; +} + int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, const struct kvm_vcpu_init *init) { diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 64e0740..45f1f10 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -28,6 +28,14 @@ #include #include +#ifdef CONFIG_KVM_ARM_TIMER +/* + * We cannont directly include arm/include/asm/kvm_arch_timer.h here so, + * forward declaring required functions + */ +extern int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu); +#endif + /* * ARMv8 Reset Values */ @@ -95,5 +103,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) /* Reset system registers */ kvm_reset_sys_regs(vcpu); +#ifdef CONFIG_KVM_ARM_TIMER + /* Reset arch_timer context */ + return kvm_timer_vcpu_reset(vcpu); +#else return 0; +#endif }