Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6360285imu; Mon, 21 Jan 2019 07:36:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN5M7DqsCML2d2LUCQzeZxc6mCoTopz+PpWnb93mtFfXxkneO5pVzOXC1PJuGzDNPGwgLVOA X-Received: by 2002:a62:56c7:: with SMTP id h68mr31308134pfj.134.1548084972188; Mon, 21 Jan 2019 07:36:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548084972; cv=none; d=google.com; s=arc-20160816; b=kphqGLB8fgsxPlRF46PEFHkF2HuWQMIXBkkI4+KsC9+2Pjx9nnmsZIc+eLeYDY4LQ9 wskcSBpIcLy/baex/M2+5aZrmxdL96GR34+gLijSkyZ4FK/58QdfoKKKTPfcEpvrWoqa ND7T3BKwiaYbAntB3SjMgMMxNgJVDRN5UefSY9dP8jsrkSCJgQ8TQRMonnoYSFjYUB1+ PzYAaatDurWEmNdE/Usl5l2HVbr7yerAimY8xn4rwHVCb536Thbzwx8jeLgwiJ4Zj5vf vIlYht9rOHR90lhVWp7plqV6tJP1tzprMD2TVCjq0T7O6jDwrFldGAjm7tzwyfH2DJma NuGA== 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=RGuD8MnGjQ369rtoDPLd9lIK0/+GTBgTtwdZsB3I3k0=; b=kRaWFCq+ZvBHutGFFaRgCuCy5Cyf+qTOrteh2w+bc9h0tBYjknWme8h5LYcy2XgjZ6 pQYiodxf/RLO/TF+yW//07UlmEWWu2E53SEZWkoEPicPd7my9ZPCyzyydhgpwK6w4PP1 sbACYTJ6Got9PL8mj0lZAqHR9JXqtyMobrZonwL5yIpiu8hqAv6NX8hyk/PlWcjeisu9 2B0X8Om0YsKydPJ/3UsE08UPAAHGGkqa1gDmFIgVaZhxfccXYurr6E8KVX2MhdrLNqr6 JdXQXuFQGbpyMNTEz37q/RW2TafkdAcpTbgM/89/3/iWQji8Zc3ZbYjXn3RCGubYGHJ/ kpjw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t65si12888770pfd.246.2019.01.21.07.35.56; Mon, 21 Jan 2019 07:36:12 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730169AbfAUPeZ (ORCPT + 99 others); Mon, 21 Jan 2019 10:34:25 -0500 Received: from foss.arm.com ([217.140.101.70]:36492 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730135AbfAUPeZ (ORCPT ); Mon, 21 Jan 2019 10:34:25 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7FAC81993; Mon, 21 Jan 2019 07:34:24 -0800 (PST) Received: from e112298-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 62EE23F5C1; Mon, 21 Jan 2019 07:34:22 -0800 (PST) From: Julien Thierry To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, joel@joelfernandes.org, marc.zyngier@arm.com, christoffer.dall@arm.com, james.morse@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, Julien Thierry , kvmarm@lists.cs.columbia.edu Subject: [PATCH v9 10/26] arm64: kvm: Unmask PMR before entering guest Date: Mon, 21 Jan 2019 15:33:29 +0000 Message-Id: <1548084825-8803-11-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548084825-8803-1-git-send-email-julien.thierry@arm.com> References: <1548084825-8803-1-git-send-email-julien.thierry@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Interrupts masked by ICC_PMR_EL1 will not be signaled to the CPU. This means that hypervisor will not receive masked interrupts while running a guest. Avoid this by making sure ICC_PMR_EL1 is unmasked when we enter a guest. Signed-off-by: Julien Thierry Acked-by: Catalin Marinas Cc: Christoffer Dall Cc: Marc Zyngier Cc: Catalin Marinas Cc: Will Deacon Cc: kvmarm@lists.cs.columbia.edu --- arch/arm64/include/asm/kvm_host.h | 12 ++++++++++++ arch/arm64/kvm/hyp/switch.c | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 7732d0b..a1f9f55 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -474,6 +475,17 @@ static inline int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu) static inline void kvm_arm_vhe_guest_enter(void) { local_daif_mask(); + + /* + * Having IRQs masked via PMR when entering the guest means the GIC + * will not signal the CPU of interrupts of lower priority, and the + * only way to get out will be via guest exceptions. + * Naturally, we want to avoid this. + */ + if (system_uses_irq_prio_masking()) { + gic_write_pmr(GIC_PRIO_IRQON); + dsb(sy); + } } static inline void kvm_arm_vhe_guest_exit(void) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index b0b1478..6a4c2d6 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -22,6 +22,7 @@ #include +#include #include #include #include @@ -521,6 +522,17 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu) struct kvm_cpu_context *guest_ctxt; u64 exit_code; + /* + * Having IRQs masked via PMR when entering the guest means the GIC + * will not signal the CPU of interrupts of lower priority, and the + * only way to get out will be via guest exceptions. + * Naturally, we want to avoid this. + */ + if (system_uses_irq_prio_masking()) { + gic_write_pmr(GIC_PRIO_IRQON); + dsb(sy); + } + vcpu = kern_hyp_va(vcpu); host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context); @@ -573,6 +585,10 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu) */ __debug_switch_to_host(vcpu); + /* Returning to host will clear PSR.I, remask PMR if needed */ + if (system_uses_irq_prio_masking()) + gic_write_pmr(GIC_PRIO_IRQOFF); + return exit_code; } -- 1.9.1