Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2938377imm; Thu, 24 May 2018 19:28:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpMeJNuV0QP5SRyr0eaDSZFrgXwOjcfQFESUrORePi5JHRmf2ZX1fK3tRlW5GwU7Rjx+Qme X-Received: by 2002:a65:53c9:: with SMTP id z9-v6mr443485pgr.356.1527215283169; Thu, 24 May 2018 19:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527215283; cv=none; d=google.com; s=arc-20160816; b=evQSlQ67JkKtFQYcKhGemTbE6W69z3kgzhQlhdTelXUzpLM4O6mvILAidzvRijpnS4 Vx12yZ4ajUCjlUIHf0zvYbYOHgkwTB4qXee7ROmAC1jSkFS0VbAgxIFJAL86stiMgvsx oSk1xym5Sr1fjrkciS9E1WvpdkvFdRTXpVE1VDtlX2FiXd1esJWM3AW/qa2CXt8EjSr7 bkls+EMUHpNPkV+CCun/6mrW+pao2ndkVNUomMAGZEuNZ99oCnOzl96AA5cSIiknjCaI o1T37CzCLBKv4zI3Loo5myemfVXKV1JAK+hC2g1vWDwxNpvjk6uHPtM1Rmqa74oBOh3+ twjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=VHvOKablnpWnN6BScobVXm4leRBbLQYASdMsiVHM6IE=; b=xJrzikrIioYSdEw5CQ3qdD8151QDj+PCrKpbXO+bR1wED+WeKQsFntZ1gA0eoUdpY8 GDuUMIyH3zITPDLc6lbhcFdjpwWgKsaRW1DyIHUaWUgcfyewx36rfwg8voJeCNmnW5tN 8RH0zCN1j7pU58iBzlhk/3F6wf+D3ftBrxMspRGxD4oJgbvs8xNfZTIXXl/jjSjzcV1H JLNBuvDjpSppb1Y8oi9/kBaJKCrGDjgirLl2/NWO6ZBJhyRHBtNRJ0nP7wwVIt9sCiJL GpY22jZLKeHQ5TxBPZU05njTDJ9AwujKj4XFbB+UsEZsKXGr3bg/3y2AbjG/6VU1Z5Bi H9jQ== 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 t196-v6si11644887pgc.648.2018.05.24.19.27.48; Thu, 24 May 2018 19:28:03 -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 S1033573AbeEXQUF (ORCPT + 99 others); Thu, 24 May 2018 12:20:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47322 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030948AbeEXQUE (ORCPT ); Thu, 24 May 2018 12:20:04 -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 E3B811596; Thu, 24 May 2018 09:20:03 -0700 (PDT) Received: from [10.1.206.75] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 354CA3F25D; Thu, 24 May 2018 09:19:59 -0700 (PDT) Subject: Re: [PATCH v3 3/6] arm64: irqflags: Use ICC sysregs to implement IRQ masking To: Julien Thierry , linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mark.rutland@arm.com, christoffer.dall@arm.com, james.morse@arm.com, joelaf@google.com, joel.opensrc@gmail.com, daniel.thompson@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, Thomas Gleixner , Jason Cooper References: <1526902515-13769-1-git-send-email-julien.thierry@arm.com> <1526902515-13769-4-git-send-email-julien.thierry@arm.com> From: Marc Zyngier Organization: ARM Ltd Message-ID: <6c568926-b70f-ad96-7200-1d427ce148f3@arm.com> Date: Thu, 24 May 2018 17:19:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1526902515-13769-4-git-send-email-julien.thierry@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Julien, On 21/05/18 12:35, Julien Thierry wrote: > From: Daniel Thompson > > Currently irqflags is implemented using the PSR's I bit. It is possible > to implement irqflags by using the co-processor interface to the GIC. > Using the co-processor interface makes it feasible to simulate NMIs > using GIC interrupt prioritization. > > This patch changes the irqflags macros to modify, save and restore > ICC_PMR_EL1. This has a substantial knock on effect for the rest of > the kernel. There are four reasons for this: > > 1. The state of the PMR becomes part of the interrupt context and must be > saved and restored during exceptions. It is saved on the stack as part > of the saved context when an interrupt/exception is taken. > > 2. The hardware automatically masks the I bit (at boot, during traps, etc). > When the I bit is set by hardware we must add code to switch from I > bit masking and PMR masking: > - For IRQs, this is done after the interrupt has been acknowledged > avoiding the need to unmask. > - For other exceptions, this is done right after saving the context. > > 3. Some instructions, such as wfi, require that the PMR not be used > for interrupt masking. Before calling these instructions we must > switch from PMR masking to I bit masking. > This is also the case when KVM runs a guest, if the CPU receives > an interrupt from the host, interrupts must not be masked in PMR > otherwise the GIC will not signal it to the CPU. > > 4. We use the alternatives system to allow a single kernel to boot and > be switched to the alternative masking approach at runtime. > > Signed-off-by: Daniel Thompson > [julien.thierry@arm.com: changes reflected in commit, > message, fixes, renaming] > Signed-off-by: Julien Thierry > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Christoffer Dall > Cc: Marc Zyngier > Cc: Thomas Gleixner > Cc: Jason Cooper > Cc: James Morse > --- > arch/arm64/Kconfig | 15 ++++ > arch/arm64/include/asm/arch_gicv3.h | 20 ++++++ > arch/arm64/include/asm/assembler.h | 25 ++++++- > arch/arm64/include/asm/daifflags.h | 36 +++++++--- > arch/arm64/include/asm/efi.h | 5 ++ > arch/arm64/include/asm/irqflags.h | 125 +++++++++++++++++++++++++++++++++ > arch/arm64/include/asm/kvm_host.h | 14 ++++ > arch/arm64/include/asm/processor.h | 4 ++ > arch/arm64/include/asm/ptrace.h | 14 +++- > arch/arm64/kernel/asm-offsets.c | 1 + > arch/arm64/kernel/entry.S | 28 ++++++-- > arch/arm64/kernel/head.S | 37 ++++++++++ > arch/arm64/kernel/process.c | 6 ++ > arch/arm64/kernel/smp.c | 8 +++ > arch/arm64/kvm/hyp/switch.c | 25 +++++++ > arch/arm64/mm/fault.c | 5 +- > arch/arm64/mm/proc.S | 23 ++++++ > drivers/irqchip/irq-gic-v3-its.c | 2 +- > drivers/irqchip/irq-gic-v3.c | 82 +++++++++++---------- > include/linux/irqchip/arm-gic-common.h | 6 ++ > include/linux/irqchip/arm-gic.h | 5 -- > 21 files changed, 423 insertions(+), 63 deletions(-) I've commented about this particular patch offline, but let me state it on the list: As it is, this patch is almost impossible to review. It turns the interrupt masking upside down, messes with the GIC, hacks KVM... Too many things change at once, and I find it very hard to build a mental picture of the changes just by staring at it. Can you please try to split it into related chunks, moving the enabling of the feature right at the end, so that the reviewers can have a chance to understand it? It should make it much easier to review. Thanks, M. -- Jazz is not dead. It just smells funny...