From patchwork Thu Jun 25 15:00:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 11625521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E0C0618 for ; Thu, 25 Jun 2020 15:01:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 232D820768 for ; Thu, 25 Jun 2020 15:01:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sMwMRB5S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 232D820768 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=ECZf+uDnKWMZ/ahabHoMNuW89S+kRq6+E2+2wZU2h+s=; b=sMwMRB5SEGasyL+5J6j2bsnpOZ zs9BRfRANbAIEhNtJDNl97jM2R+/8UY27pnI42N3fwAceB3F1vVCP46wLafhtiF2bYu8KI6VzmjrP UrYlpIwO2RyPoqMW85Fvk3id1VfhD2RFuHBW7qfPPoEVv5iOVycf42GocgocUCejeejcjDQ2zAYvB iZ6nEStSMd4Lz77b9WdxBduJqwclil09xGF28lIzIQH1JMKXk36VKT/7CtVJpnVjRYBdZ0bScsYzd gQxl4TPQKOjnjtaoGQ3XVmEU3tBJ0Xck5BEoYnK0riLNnnf7eCUhYN3CxOMJLML4PgBr2zSZ6mRIC hwTrSICw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1joTM3-0000UY-7s; Thu, 25 Jun 2020 14:59:55 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1joTM0-0000Tx-K0 for linux-arm-kernel@lists.infradead.org; Thu, 25 Jun 2020 14:59:53 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB161C0A; Thu, 25 Jun 2020 07:59:51 -0700 (PDT) Received: from monolith.arm.com (unknown [10.37.8.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E46153F6CF; Thu, 25 Jun 2020 07:59:49 -0700 (PDT) From: Alexandru Elisei To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH 0/2] irqchip/gic-v3: Support pseudo-NMIs when SCR_EL3.FIQ == 0 Date: Thu, 25 Jun 2020 16:00:24 +0100 Message-Id: <20200625150026.867727-1-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, jason@lakedaemon.net, maz@kernel.org, catalin.marinas@arm.com, yuzenghui@huawei.com, tglx@linutronix.de, will@kernel.org, julien.thierry.kdev@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Trusted Firmware-A's default interrupt routing model is to clear SCR_EL3.FIQ, which is the only case that GICv3 doesn't support. This series tries to fix that by detecting it at runtime and using a different priority value for ICC_PMR_EL1 when masking regular interrupts. As a result, we will be able to support pseudo-NMIs on all combinations of GIC security states and firmware configurations. The series is based on v5.8-rc1, the same as the PMU NMI patches [1] which I used for testing. The first patch was there because when I started working on the PMU NMI patches I found it confusing that there was no clear message stating that NMIs were successfully enabled. The second patch is the main patch of the series, where pseudo-NMIs are enabled even if SCR_EL3.FIQ == 0. The are still some things I'm not 100% sure about regarding the last patch: - From my very limited experience of trying pseudo-NMIs on 3 machines (rockpro64, espressobin-v5 and v7), all of them had SCR_EL3.FIQ zero. I tend to believe that since this is the default on TFA, this will also be the common case on hardware. However, when Linux is a KVM guest, the original set of priorities is used because GIC security is disabled. I erred on the side of caution and chose the original set of priorities as the common case. - Most of the changes to arch_local_irq_enable() might seem pointless, but I chose to make them so the function looks similar to arch_local_irq_disable(). The generated code is identical if the static branch is not taken. I tried changing only arch_local_irq_disable(), but the enable function ended up looking strangely asymmetrical. If someone suggests a better way of doing things, I'd be happy to implement it. As an aside, the set of priorities that I've added would work in all cases if there was no need to use GIC_PRIO_PSR_I_SET, but that is a much more intrusive change and I'm not comfortable attempting it. I'm pretty sure I will end up breaking things really badly. I've tested the series using PMU NMIs [1] on the model and on espressobin-v7. 1. On the model: - Host with SCR_EL3.FIQ == 1 (so using the original priorities), ran perf record -a -- iperf3 -c 127.0.0.1 -t 30. - On a KVM guest (security disabled, so using the original priorities), ran the same command as above. 2. On an espressobin-v7: - Host with SCR_EL3.FIQ == 0 (using the priority added by the series), ran perf record -a -- iperf3 -c 127.0.0.1 -t 60. - On a KVM guest (security disabled, so using the original priorities), ran the same command. - Stress test for an hour with CONFIG_ARM64_DEBUG_PRIORITY_MASKING set for the host and guest. On the host, I ran in parallel perf record -a -- iperf3 -c 127.0.0.1 -t 3600 and perf record -ae L1-dcache-loads -a -- sleep 3600. On the guest, I ran the same iperf3 command as on the host. [1] https://www.spinics.net/lists/kernel/msg3554236.html Alexandru Elisei (2): irqchip/gicv3: Spell out when pseudo-NMIs are enabled irqchip/gic-v3: Support pseudo-NMIs when SCR_EL3.FIQ == 0 arch/arm64/include/asm/arch_gicv3.h | 8 ++++- arch/arm64/include/asm/daifflags.h | 4 +-- arch/arm64/include/asm/irqflags.h | 14 +++++--- arch/arm64/include/asm/ptrace.h | 12 +++++++ arch/arm64/kernel/entry.S | 2 +- arch/arm64/kvm/hyp/switch.c | 2 +- drivers/irqchip/irq-gic-v3.c | 56 +++++++++++++++++++++-------- 7 files changed, 75 insertions(+), 23 deletions(-)