From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B96EFC46463 for ; Tue, 20 Nov 2018 18:11:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB71120685 for ; Tue, 20 Nov 2018 18:11:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB71120685 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zytor.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728416AbeKUElf (ORCPT ); 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