Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1019668imu; Tue, 20 Nov 2018 10:18:42 -0800 (PST) X-Google-Smtp-Source: AJdET5epi39vsY0W4LZ4ptPT71fm7bhLKd3Q4VnO3TXwozaARsKimAyjfM6S/mlD83UFCTQDp9fZ X-Received: by 2002:a62:5ac3:: with SMTP id o186-v6mr3400988pfb.40.1542737922332; Tue, 20 Nov 2018 10:18:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542737922; cv=none; d=google.com; s=arc-20160816; b=HcMjsADbjLioNFgLmjdWYJcjZ1znrgy7alBMbvOzMOEAhk7CiK7E1HNrtCuxCeTou8 LZzt54A4Xa5oLrvddoZJt5dJK/dSbqEKb1Pk7YCeqhoKVrl7wn6Cj8za00i8znru1iw2 6URk+Lac7S9RV8+sp2YjbR/lPtn5tdjSG8wx5ggAkbItKep2/QdcVbsFgZ5f1djB15E3 t+CEdy05IkzP1P6jFXe+L9dX6Vft1wI0rRzro++ESpUAzuCUDGTK8VXn35GGKUBfhoM6 IINjhf4o0mrRUHauroRR8Io7zvYLKa+3Jtip62fyBl6r7RFJW1KAb0u7wVU0bTOcQMOK vgCQ== 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:from:references:cc:to:subject; bh=bp2KQaSDyHaoqdC8cjIqMh2XLT9rgDhE4AftoyoQ/As=; b=l5NQrqr3X2AmHiq4429px3dgc8FdVssQxe5wfMrNsXleceQ1XuC6Pbkz1CNwavkc2E 9waP5O0rkx2jv3QMXN1mhNAMSrIcYTa1WYiCT0DOfKwPYNNDiwnx8xwbhoxgiDYQkQob oyDYv6NCPba5qyDyOpqHxGRtjgXo6KNuBiZvNDpVYZ0LAHicFui8JKe5j181CPfvJ3d1 cxaDCADlSiTTCva+epjMLS1BsDaEX2gZhmq9GgCXyiB4DshOZxNxE5jd/SP1QYPGfC9t G3jbx5zlUx+TSjpTO4V/Lc8m0OUoTszYU+rW9qwtPt21jXU6H8vMjHn3xxnmf+mxWzIE +IQw== 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 t130si15768300pgb.521.2018.11.20.10.18.27; Tue, 20 Nov 2018 10:18:42 -0800 (PST) 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 S1728397AbeKUElf (ORCPT + 99 others); Tue, 20 Nov 2018 23:41:35 -0500 Received: from terminus.zytor.com ([198.137.202.136]:45375 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbeKUElf (ORCPT ); Tue, 20 Nov 2018 23:41:35 -0500 Received: from hanvin-mobl2.amr.corp.intel.com (fmdmzpr04-ext.fm.intel.com [192.55.54.39]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id wAKIAJZC3063572 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Tue, 20 Nov 2018 10:10:20 -0800 Subject: Re: [PATCH v5 02/10] x86/jump_label: Use text_poke_early() during early init To: Nadav Amit , Ingo Molnar Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Borislav Petkov , Dave Hansen , Peter Zijlstra , linux_dti@icloud.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Andy Lutomirski , Kees Cook , Dave Hansen , Masami Hiramatsu References: <20181113130730.44844-1-namit@vmware.com> <20181113130730.44844-3-namit@vmware.com> From: "H. Peter Anvin" Message-ID: <76c41854-b12d-5c4e-cfa4-f448e102860b@zytor.com> Date: Tue, 20 Nov 2018 10:10:14 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181113130730.44844-3-namit@vmware.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/13/18 5:07 AM, Nadav Amit wrote: > There is no apparent reason not to use text_poke_early() while we are > during early-init and we do not patch code that might be on the stack > (i.e., we'll return to the middle of the patched code). This appears to > be the case of jump-labels, so do so. > > This is required for the next patches that would set a temporary mm for > patching, which is initialized after some static-keys are > enabled/disabled. > > Cc: Andy Lutomirski > Cc: Kees Cook > Cc: Dave Hansen > Cc: Masami Hiramatsu > Co-Developed-by: Peter Zijlstra > Signed-off-by: Nadav Amit > --- > arch/x86/kernel/jump_label.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c > index aac0c1f7e354..ed5fe274a7d8 100644 > --- a/arch/x86/kernel/jump_label.c > +++ b/arch/x86/kernel/jump_label.c > @@ -52,7 +52,12 @@ static void __ref __jump_label_transform(struct jump_entry *entry, > jmp.offset = jump_entry_target(entry) - > (jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); > > - if (early_boot_irqs_disabled) > + /* > + * As long as we're UP and not yet marked RO, we can use > + * text_poke_early; SYSTEM_BOOTING guarantees both, as we switch to > + * SYSTEM_SCHEDULING before going either. > + */ > + if (system_state == SYSTEM_BOOTING) > poker = text_poke_early; > > if (type == JUMP_LABEL_JMP) { > Can't we make this test in text_poke() directly, please? -hpa