Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp59355ybj; Fri, 8 May 2020 06:31:38 -0700 (PDT) X-Google-Smtp-Source: APiQypIIAkcL/uyWvyLOL/0pCL3MzhSe1Ky75DDZPeW6tHwTLxBO4E/v9Y/GMX0QsECLqFrDLn+U X-Received: by 2002:a17:906:b2c4:: with SMTP id cf4mr1998632ejb.340.1588944698330; Fri, 08 May 2020 06:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588944698; cv=none; d=google.com; s=arc-20160816; b=iYp6EckskI3n//Xt/v2B2L9+MsKwRFUpG3G7i9cC71feb1NCniJ9EOVuMgoBxJqQ11 1xHwOEyNU7UihWe1hWbR5o1+/mOhgQf7KZ2Iz7wzqr3ILrn2kxF6ylzGWbGSRyjc4Vxe cOPa1x5krgt9gNyu0KUXyGBJL3p4RmjxsYStgLvMLG3xnFo9bkbf73jnlALTS/xLbm9s jht0xdEnTmz65Yt+3i9byquKm/Lrdu7lpFSSHecHrgpPOq/QFzhoVaiElsYUJ87lgB2X qbECwqJQOFg1yOvE+WL+ZEx8TsEaZjwS3xyeucuKYgw2CtNcUmvebLCJ4ZmHpv4GxJNX D8zw== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=GIeAlp7u4TqlEjyNhGIWEoUzy3vByOrOu6QRRXUZnR0=; b=eMU+TiHzhDC46nUMGrHCcWKu/EirCTQmYhOUtkX/kWlPvhS1G2ShdmixKPuFHfOywX BJTDMyxlOqnR+kr41TrQgIF1uV0u9ehljvQE8ojr+ou6wIRYkpt9pBTfIhxgXlnNfkYp ee9SKxt7lUzBIgdeXOIYN9OWqh0DDXCx1M1rMg38hh+Y7WsK0pZnLM/pxF4ykX43OruL /SnjTnUd2OLBnF+mfMlL4PuWYFrd0j8yWAt+Mm1LdQWQeImxiRImmRH1oU4ij9VhB9L+ r2RCeHHtODhXDgtqSDEFtLQ5MoftbooMTrg4E5VGaJZBiJVl5jTpSsvIkxG+fj9xZgCe Hltw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OYg5EcUy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w24si970932ejn.277.2020.05.08.06.31.14; Fri, 08 May 2020 06:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OYg5EcUy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727886AbgEHN16 (ORCPT + 99 others); Fri, 8 May 2020 09:27:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:50096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgEHN15 (ORCPT ); Fri, 8 May 2020 09:27:57 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC57024953; Fri, 8 May 2020 13:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588944477; bh=XmKr+actPKIyBSF7+MJNsc70eQDYMdbsWtd71MQ4z8o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OYg5EcUy5J7fNhWiDvM5ZKpmTJRL9DKvTrTcXTEdc6xz2hCkG0mdPoNVFHZ7r1uRH fNBfP+EGrEG7ysIj/kfXDidRX6YkYZNZPo4XQyFVdOmysrCJxjyuYPzNCClroTi/+w 0mjbsYbVE85F3wPCuxZTkDZ8XFCRP8952LksoUO8= Date: Fri, 8 May 2020 22:27:50 +0900 From: Masami Hiramatsu To: Thomas Gleixner Cc: LKML , x86@kernel.org, "Paul E. McKenney" , Andy Lutomirski , Alexandre Chartre , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Josh Poimboeuf , Will Deacon , "Peter Zijlstra (Intel)" Subject: Re: [patch V4 part 4 02/24] x86/int3: Avoid atomic instrumentation Message-Id: <20200508222750.a7aca9f898b7637d402e8726@kernel.org> In-Reply-To: <20200505135313.517429268@linutronix.de> References: <20200505134926.578885807@linutronix.de> <20200505135313.517429268@linutronix.de> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 05 May 2020 15:49:28 +0200 Thomas Gleixner wrote: > From: Peter Zijlstra > > Use arch_atomic_*() and READ_ONCE_NOCHECK() to ensure nothing untoward > creeps in and ruins things. > > That is; this is the INT3 text poke handler, strictly limit the code > that runs in it, lest it inadvertenly hits yet another INT3. > > Reported-by: Thomas Gleixner > Signed-off-by: Peter Zijlstra (Intel) > Signed-off-by: Thomas Gleixner Looks good to me. Reviewed-by: Masami Hiramatsu > --- > arch/x86/kernel/alternative.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -960,9 +960,9 @@ static struct bp_patching_desc *bp_desc; > static __always_inline > struct bp_patching_desc *try_get_desc(struct bp_patching_desc **descp) > { > - struct bp_patching_desc *desc = READ_ONCE(*descp); /* rcu_dereference */ > + struct bp_patching_desc *desc = READ_ONCE_NOCHECK(*descp); /* rcu_dereference */ > > - if (!desc || !atomic_inc_not_zero(&desc->refs)) > + if (!desc || !arch_atomic_inc_not_zero(&desc->refs)) > return NULL; > > return desc; > @@ -971,7 +971,7 @@ struct bp_patching_desc *try_get_desc(st > static __always_inline void put_desc(struct bp_patching_desc *desc) > { > smp_mb__before_atomic(); > - atomic_dec(&desc->refs); > + arch_atomic_dec(&desc->refs); > } > > static __always_inline void *text_poke_addr(struct text_poke_loc *tp) > -- Masami Hiramatsu