Received: by 10.213.65.68 with SMTP id h4csp486656imn; Fri, 6 Apr 2018 03:58:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx49bj7WAok/hniaQEhQk9krLHU2I5uczUIFH9iuoTOKmjetc/F+6CJaGva+0VVBWrtXXAxuW X-Received: by 10.167.129.217 with SMTP id c25mr20239502pfn.143.1523012324908; Fri, 06 Apr 2018 03:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523012324; cv=none; d=google.com; s=arc-20160816; b=QXCekbH96DFga4+vpmaL2iFqVongyyuK+p1LsYBN0t4jk/+yhrfATukCDDBeRW2qyJ 4PN45PnBpd0o6senvpsaSZ1cZnq3tKw+EzHv5cDQP+3B1I1ZUpPsXdb8K5Z6P0ZIt0Vm Lz4iIG3NT795/SaPQ3OZ9S2tFLdkj/5YGrz2cd068jY5uggiCao2owDzQ8gbOaNdajRb 3C20bZWEb/elrEUNmBC7bIpowy+JyaO+RQhatU9b1jjFVFXRkvpTX8CjdjElyw022OPO KF0q6oXmSntCZopuT6MwylZnmYi/akxfs7qckJdzvf1YeVQpofNYdSfgktvGNbpECQcy Gn9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=UHR+HWBo+s1JUHB7NuGNrGZ+dmwOdWG5xhrf7V0k5XQ=; b=AXrFjBxW0q5Ix8rhQPn1h8K57rv/SP2Yl9DmostqHIIJK/7m8XdP4Zh3TS1gBQw7jB AzClhUDt8bR9xotD/ql8tt+ilqJ/rNV0n3FgPdZMr+Z0/8SgsJI96lp57N16Ey8Et9nH xWpuUkmjmSXqm5tawLJpBhvVaol0ibXqIFHK2xWd/oOengguUYqVpGFSG0pWnw+woBi7 vWWkta6Jxht3ChH0lSzKuLT/rFWGT0kTHkcUFZRFSCQY6+BzNI0jb0Cyj+M2NqeA5mlc MXEXPpYMh+BK1rRRwX0zKfpUJpk5xUWVANZogYFmR57wS4QJA7ZIQZ0SAl6YoI5KguRE 98yg== 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 k73si6969474pge.131.2018.04.06.03.58.30; Fri, 06 Apr 2018 03:58:44 -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 S1752045AbeDFK5R (ORCPT + 99 others); Fri, 6 Apr 2018 06:57:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35098 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751579AbeDFK5Q (ORCPT ); Fri, 6 Apr 2018 06:57:16 -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 BEE6A1529; Fri, 6 Apr 2018 03:57:15 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 407263F487; Fri, 6 Apr 2018 03:57:12 -0700 (PDT) Date: Fri, 6 Apr 2018 11:57:09 +0100 From: Mark Rutland To: Yury Norov Cc: "Paul E. McKenney" , Will Deacon , Chris Metcalf , Christopher Lameter , Russell King - ARM Linux , Steven Rostedt , Mathieu Desnoyers , Catalin Marinas , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Alexey Klimov , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] arm64: entry: isb in el1_irq Message-ID: <20180406105709.kd3uumwustwnzcd4@lakrids.cambridge.arm.com> References: <20180405171800.5648-1-ynorov@caviumnetworks.com> <20180405171800.5648-2-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180405171800.5648-2-ynorov@caviumnetworks.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 05, 2018 at 08:17:56PM +0300, Yury Norov wrote: > Kernel text patching framework relies on IPI to ensure that other > SMP cores observe the change. Target core calls isb() in IPI handler > path, but not at the beginning of el1_irq entry. There's a chance > that modified instruction will appear prior isb(), and so will not be > observed. > > This patch inserts isb early at el1_irq entry to avoid that chance. As James pointed out, taking an exception is context synchronizing, so this looks unnecessary. Also, it's important to realise that the exception entry is not tied to a specific interrupt. We might take an EL1 IRQ because of a timer interrupt, then an IPI could be taken before we get to gic_handle_irq(). This means that we can race: CPU0 CPU1 ISB ... and thus the ISB is too early. Only once we're in the interrupt handler can we pair an ISB with the IPI, and any code executed before that is not guaranteed to be up-to-date. Thanks, Mark. > > Signed-off-by: Yury Norov > --- > arch/arm64/kernel/entry.S | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S > index ec2ee720e33e..9c06b4b80060 100644 > --- a/arch/arm64/kernel/entry.S > +++ b/arch/arm64/kernel/entry.S > @@ -593,6 +593,7 @@ ENDPROC(el1_sync) > > .align 6 > el1_irq: > + isb // pairs with aarch64_insn_patch_text > kernel_entry 1 > enable_da_f > #ifdef CONFIG_TRACE_IRQFLAGS > -- > 2.14.1 >