Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6103428imd; Wed, 31 Oct 2018 06:56:45 -0700 (PDT) X-Google-Smtp-Source: AJdET5eAlVYJyx7reszXGYyFiq138AX3+hPFg6KXMpLPF++7Vz4N6B6Ru6f7Qddx7FFApZSa8nLh X-Received: by 2002:a63:f0c:: with SMTP id e12mr389346pgl.274.1540994205045; Wed, 31 Oct 2018 06:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540994205; cv=none; d=google.com; s=arc-20160816; b=HNsUq2KsuhdlCsc4gZvuKRUnTt/R+G3YIhQef8Dr1VV4auuHlQ5PcX+gheECOA/MRu TyxvkhZMXEahtOU8J85vjidmFY0BwuAPMn4KnF8DvF2F2owg/WiukiKarMSYcTY6hVsR AUdZWchntGHwAcPJHymXh5DICvx1Rw7R0bfz+5R34+vXrwuWTSShziVWRTo3o8t4BZQq 1upFQZZGjfm5V6nxOlK65m/R0eS+6mk8nPM7+oZKn1ic+Wf+o+YDzzQQ6aogzaEmMQhf JOOGCGtq5Kz6h36TgGEBwbtWUiO2SroRjIVLaz46/jm8HecKXKyrZhpHvhttZQTgdnmb PwRw== 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:dkim-signature; bh=jK2vllVynI4Vdu1UBSTv+648erhxJoPT7Y1W6GANjes=; b=McYzqzXOiNgKyhclp4Pdoi/fgEbwW3OTTglaH4T4IU7zwJAlqgln5B69s9J9WIhivd YdsMS8OlkdM22VVQ3rcj34HMB7Z1pMWC88SZwjMd+wosHpVDNle0eqZP17KgVNvu75gL JuFu6rBPLkFG8Kt6igSar/Jvqm8iqexwTONcwqIpw7mKP5v00L4CPnBu0wow9+dwNUEv RlQQ4AvBaJBI7Js3jwuPAY1/+za32q0f6ABjPdzYdleyZQfbLnH1RvqzcScNqzOAPgU/ 1zbYkkvdwRokaPpiMMPO0TJuXqAyw3YUkesiPEaIsdh0aj36B/SpM4aivEGT8i0ltHa5 A/GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QmkNvIiG; 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 185-v6si28423511pff.270.2018.10.31.06.56.07; Wed, 31 Oct 2018 06:56:45 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QmkNvIiG; 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 S1729397AbeJaWve (ORCPT + 99 others); Wed, 31 Oct 2018 18:51:34 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58384 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729321AbeJaWve (ORCPT ); Wed, 31 Oct 2018 18:51:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jK2vllVynI4Vdu1UBSTv+648erhxJoPT7Y1W6GANjes=; b=QmkNvIiGMq7fJl6vwbxs0bn14 iDxLcWu2QCKCYqZOSjtY64MStFiXrqoSXFEp5b6tG001eoQEZswHsEIwOvGDWkvKIhpkUf+LxDXnx aHCJo/SJWpmiWEbFv0OSEYg8iuu79AVBcd0RQwYp4cQaM/dyCGt57QDLWju8+q9BmmzGZF49RtBk8 kIl1d/pYzwNywlQpNjKM9FdxhC41PsLX1wt7S/YKE88Gvz3Z36c2XoELzzM3DpRqRlhUUxKCecd73 wS5j0A7nIVbWu7Aa8A4nRiSBB/OqQ3eeeuxvEP+vPpFc4TxByY6SFD2XfAwOvkhK0LAMuab08kv5B KT3GzDDUA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHqvy-0002lP-NP; Wed, 31 Oct 2018 13:53:22 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id DDE442029F885; Wed, 31 Oct 2018 14:53:20 +0100 (CET) Date: Wed, 31 Oct 2018 14:53:20 +0100 From: Peter Zijlstra To: Zhenzhong Duan Cc: Linux-Kernel , mingo@redhat.com, konrad.wilk@oracle.com, dwmw@amazon.co.uk, tglx@linutronix.de, Srinivas REDDY Eeda , bp@suse.de, hpa@zytor.com Subject: Re: [PATCH 3/3] kprobes/x86: Simplify indirect-jump check in retpoline Message-ID: <20181031135320.GC13237@hirez.programming.kicks-ass.net> References: <20181030083650.GB1459@hirez.programming.kicks-ass.net> <849ae148-85cd-5f46-d98b-b827cc9c605c@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <849ae148-85cd-5f46-d98b-b827cc9c605c@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 31, 2018 at 02:01:20PM +0800, Zhenzhong Duan wrote: > On 2018/10/30 16:36, Peter Zijlstra wrote: > > On Mon, Oct 29, 2018 at 11:55:06PM -0700, Zhenzhong Duan wrote: > > > Since CONFIG_RETPOLINE hard depends on compiler support now, so > > > replacing indirect-jump check with the range check is safe in that case. > > > > Can we put kprobes on module init text before we run alternatives on it? > > Forgive me I doesn't understand your question. Do you mean this patch impact > kprobes on module init text? In that case we would still see the indirect paravirt calls for example, and we'd still need that cascade you took out. Now, I'm not at all sure we're able to use kprobes at those times, so it might be a non-issue. > > > @@ -240,20 +242,16 @@ static int insn_jump_into_range(struct insn *insn, unsigned long start, int len) > > > static int insn_is_indirect_jump(struct insn *insn) > > > { > > > - int ret = __insn_is_indirect_jump(insn); > > > + int ret; > > > #ifdef CONFIG_RETPOLINE > > > - /* > > > - * Jump to x86_indirect_thunk_* is treated as an indirect jump. > > > - * Note that even with CONFIG_RETPOLINE=y, the kernel compiled with > > > - * older gcc may use indirect jump. So we add this check instead of > > > - * replace indirect-jump check. > > > - */ > > > - if (!ret) > > > + /* Jump to x86_indirect_thunk_* is treated as an indirect jump. */ > > > ret = insn_jump_into_range(insn, > > > (unsigned long)__indirect_thunk_start, > > > (unsigned long)__indirect_thunk_end - > > > (unsigned long)__indirect_thunk_start); > > > +#else > > > + ret = __insn_is_indirect_jump(insn); > > > #endif > > > return ret; > > > } > > > > The resulting code is indented wrong. > > > > Oh, yes. Thanks for point out. > > Zhenzhong