Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3276594imm; Fri, 25 May 2018 02:56:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp4HXWNXm7WLydx40l83Hw8/mYeJDY1dvdHLEEz1tqr0yjsvC89BYmFtBnVZjtJCgLPSUe/ X-Received: by 2002:a62:6e88:: with SMTP id j130-v6mr1824936pfc.111.1527242173545; Fri, 25 May 2018 02:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527242173; cv=none; d=google.com; s=arc-20160816; b=FRadL8PQ/i/zCmGnxIqy6RN5LbNXWphSyiWc1287zzFEl7SOBsGgZsawZzwTi9jkRt SmPfJVHGIRIleg8Sap/ZKn9LrAn30zElO2FNn8B3JZAogOR40BUxY4VX3XoaLb6xm3LL J5cZlJmFFC5RlUWplO3/5o6iV+A+dumv0aC4dL4Q0jNzcr6FiSmz+wE9GOGWhcIDpiY4 aAvfsMgOutk2hFMStuU+GoRC0Fv2vkY2UBIB7Qjl2th+kb5MaeyYdDAjX4zgPirqi8V9 ja/YiiCuxltLAF6vPIXSDxyoBtGUpQnqZLbIv9Nxrbdm4VBoaW2OMpUxePdzp0mKBnqU 5BAQ== 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:arc-authentication-results; bh=6EzOKc5476RFPV41n1lqoysA08J2no4LgWWVfVcFRUw=; b=dORoO/gnVJDe49UaGvQXBxrkA1iIseaqC907Gv9bOi1kx3sN0c/Ob5ep3UhNsOZ6Hg sYjkg+Ut232zca0w10j3p8HzZlPHMGSxnC+a/lHs0H5g2+AOzCkSBlooIxjv9nbwzXDu aZAcTEC+1S44krPhcljs+IUBrdJdKDkZyRofb2KcLd5VBxcv3wavEI73IvZ1SVNCFYNi rDjYbMU7fB1vW8TYtBhTg45EkKQFZk4+yeMJnoXBkVk+4AxM2pOKqz81QmpPysB0eB4d xp41WZFzeH+TeGvMu44J+cbj/v3e9rKFxf+7b/srtiVDMnllEA9gfJBQ33JHKTMErxhY T1vg== 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 18-v6si275454pft.235.2018.05.25.02.55.59; Fri, 25 May 2018 02:56:13 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966101AbeEYJuc (ORCPT + 99 others); Fri, 25 May 2018 05:50:32 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57542 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966084AbeEYJua (ORCPT ); Fri, 25 May 2018 05:50:30 -0400 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 E9FB719E8; Fri, 25 May 2018 02:50:29 -0700 (PDT) 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 C417A3F25D; Fri, 25 May 2018 02:50:27 -0700 (PDT) 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, mark.rutland@arm.com, christoffer.dall@arm.com, james.morse@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Julien Thierry , kvmarm@lists.cs.columbia.edu Subject: [PATCH v4 14/26] arm64: kvm: Unmask PMR before entering guest Date: Fri, 25 May 2018 10:49:20 +0100 Message-Id: <1527241772-48007-15-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527241772-48007-1-git-send-email-julien.thierry@arm.com> References: <1527241772-48007-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 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 | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 469de8a..bfd9e5b 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 @@ -433,6 +434,17 @@ static inline void kvm_fpsimd_flush_cpu_state(void) 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 (gic_prio_masking_enabled()) { + gic_write_pmr(ICC_PMR_EL1_UNMASKED); + 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 d964523..f00a04c 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -21,6 +21,7 @@ #include +#include #include #include #include @@ -442,6 +443,19 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu) struct kvm_cpu_context *guest_ctxt; bool fp_enabled; u64 exit_code; + u32 host_pmr = ICC_PMR_EL1_UNMASKED; + + /* + * 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 (gic_prio_masking_enabled()) { + host_pmr = gic_read_pmr(); + gic_write_pmr(ICC_PMR_EL1_UNMASKED); + dsb(sy); + } vcpu = kern_hyp_va(vcpu); @@ -496,6 +510,9 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu) */ __debug_switch_to_host(vcpu); + if (gic_prio_masking_enabled()) + gic_write_pmr(host_pmr); + return exit_code; } -- 1.9.1