Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3269973ybg; Fri, 25 Oct 2019 01:26:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNWrPR2KwjQHkXKFJg9Xi4C60MpNLdi7AevQUpjaz59C2+RDCniclw1JNWuOyJ69EobkFJ X-Received: by 2002:a50:895c:: with SMTP id f28mr2428335edf.125.1571991981259; Fri, 25 Oct 2019 01:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571991981; cv=none; d=google.com; s=arc-20160816; b=FIr++rgSpwOR+HTX4eeSzhnFPfmvbYf+EWyjQAhh5qZBvwUw3ebEX9EU4lRxLlom5O B4+t9zI59+5LZ53BDBxSEalY9vWOBCfe8+UgEUjOczYOyid6bsVBHc1PwdpN/gA1Rcvr bUPSV+9rF6ms/jtCzgzYIIHHqJWIH+D7nV2MCUzLtOGPFHscyqtb/G8PQgUXxrRFrM5/ j4ZA8klEkTyQAMcigPW6E6qS84ig/Lgl18glKsiCytfYm9bIu8IyrbhswwUdmxLB+bwF inQfyXNXgxa9hvZX5nsYmuadV3sTowB467iYlNoY6op/SEbNy2nuNADH1i7lKHzt30Nl rKvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=s1pCDvTSUJPt4XY93wDqaU5xrC9SAUPwSpBdBT7tXcc=; b=G78hZgYb/ck1RFN+E9hzR4YGY8jSeetnK6Qj0Ydn3u+EZSeVZinTq9TnqrD8ujK3w7 OVJ9ShDERVQSLcntpHnYx+8iDTUdO46etdfPik8IvENPA6aATzfyOrETtIiOXcb4WCXp XkIkGDeO4X43Y0Uw9TvoxfawTNCpziYtc+GapZJQxOyOm4G2tIcKI2X8lZ/T0XpINlzF QvtJEbSKJBZW8vpUi4HqR5wYkbIHzyNVZ7r1w9W+C8i58AucOdk1X5i2vgTd90xrjRcd 5RLwY5BO1+NTwHV/G+ZWFNIWcV/x8WE4hCW36FOuHlOJIK/wjdw8RR5GDD218dQEGaSb B5jg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si762746edm.395.2019.10.25.01.25.57; Fri, 25 Oct 2019 01:26:21 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393297AbfJXK15 (ORCPT + 99 others); Thu, 24 Oct 2019 06:27:57 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:52626 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409083AbfJXK14 (ORCPT ); Thu, 24 Oct 2019 06:27:56 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=shannon.zhao@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Tg2twD8_1571912871; Received: from localhost(mailfrom:shannon.zhao@linux.alibaba.com fp:SMTPD_---0Tg2twD8_1571912871) by smtp.aliyun-inc.com(127.0.0.1); Thu, 24 Oct 2019 18:27:52 +0800 From: Shannon Zhao To: kvmarm@lists.cs.columbia.edu, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, christoffer.dall@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 5/7] KVM: arch_timer: Add hyp uninitialize function Date: Thu, 24 Oct 2019 18:27:48 +0800 Message-Id: <1571912870-18471-6-git-send-email-shannon.zhao@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571912870-18471-1-git-send-email-shannon.zhao@linux.alibaba.com> References: <1571912870-18471-1-git-send-email-shannon.zhao@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When KVM ARM exits, it needs to cleanup arch_timer setup by kvm_timer_hyp_init. Signed-off-by: Shannon Zhao --- include/kvm/arm_arch_timer.h | 1 + virt/kvm/arm/arch_timer.c | 13 +++++++++++++ virt/kvm/arm/arm.c | 1 + 3 files changed, 15 insertions(+) diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h index d120e6c..3cb3a01 100644 --- a/include/kvm/arm_arch_timer.h +++ b/include/kvm/arm_arch_timer.h @@ -68,6 +68,7 @@ struct arch_timer_cpu { }; int kvm_timer_hyp_init(bool); +void kvm_timer_hyp_uninit(void); int kvm_timer_enable(struct kvm_vcpu *vcpu); int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu); void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu); diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index f5a5d51..7dafa97 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -991,6 +991,19 @@ int kvm_timer_hyp_init(bool has_gic) return err; } +void kvm_timer_hyp_uninit(void) +{ + struct arch_timer_kvm_info *info = arch_timer_get_kvm_info(); + + cpuhp_remove_state(CPUHP_AP_KVM_ARM_TIMER_STARTING); + if (info->physical_irq > 0) { + on_each_cpu(disable_percpu_irq, (void *)host_ptimer_irq, 1); + free_percpu_irq(host_ptimer_irq, kvm_get_running_vcpus()); + } + on_each_cpu(disable_percpu_irq, (void *)host_vtimer_irq, 1); + free_percpu_irq(host_vtimer_irq, kvm_get_running_vcpus()); +} + void kvm_timer_vcpu_terminate(struct kvm_vcpu *vcpu) { struct arch_timer_cpu *timer = vcpu_timer(vcpu); diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 0c60074..feb6649 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -1724,6 +1724,7 @@ int kvm_arch_init(void *opaque) void kvm_arch_exit(void) { kvm_perf_teardown(); + kvm_timer_hyp_uninit(); kvm_vgic_hyp_uninit(); hyp_cpu_pm_exit(); } -- 1.8.3.1