Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9228099imu; Wed, 5 Dec 2018 00:55:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/UNWDnWMmEdFZWzKTKJ+gM4ouo/duOwalogcnU7RiAG/hUTaLi0WAUN1jd0pD8XMWkjDDuY X-Received: by 2002:a62:7504:: with SMTP id q4mr23096952pfc.180.1544000152036; Wed, 05 Dec 2018 00:55:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544000152; cv=none; d=google.com; s=arc-20160816; b=ipvl3BnWyR4O/QdWNfer7BL3qMTACetewQPygS3Ov65o+b+L5nvQCSLUMWpVXROKkk YCpKt3BJ39ClJdV3op8BYYYkGG5SZYXHi6V3gDUvGZ2XgW/q4zEan+cT/AbhqkFfSWQA 19BQHQSlqlC1TXdkTQsjlMhgK1J+tqjYPMydXIa6NvhBQlPcauiysIfveDOJH7zEENKD T6shNqkDVv9s/H8qTUFPpgVT6twzphxsZSJHO3QyrOi9n3M6Y5hogh0i8YonOzh8fCUT zkQ5jPqxm8Hv8EFuxRQ9HBBx7TZ6w+PdeJWllMwQXeWGAsiODI7/904ufP8ILYN3aQk1 as3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=6QXyyCE4r4iBK4nP3lT8zpze2raC96drdwRhQXQacHg=; b=BBN3ersYOuZzooe23/NOgWlizlsZGF6OrDXGhkzVbtddG2mA4pajripg0kNR0TAk1B q0O7GTV9jt+YsXJdTcLopojDJj0UfDkmjk5jU5KeC29AfOT83OJrRxKSZ26kBK51g78j c8RzbDorBa2lWG6mCr4FcWjw5Hn3eg4b69lb9foOm3vjCTeHwGVBfLPLpxTMrKNOa80s yJQRNI6qab/nB+TkNlypzKP7YSlnpyW/nr6g0xmXvXPnfPWM7I2BIL0JF3Os8CKUvPgf FpVYXWB3ZW3XwJ88/vt0M5jUvnFglCEqWowmv3ysb2CBoGOBn0/TbLLsNCINgvjumpkm USzw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si17088671pgm.112.2018.12.05.00.55.36; Wed, 05 Dec 2018 00:55:51 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727639AbeLEIxU (ORCPT + 99 others); Wed, 5 Dec 2018 03:53:20 -0500 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:46460 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbeLEIwH (ORCPT ); Wed, 5 Dec 2018 03:52:07 -0500 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 5 Dec 2018 00:52:03 -0800 Received: from sc2-haas01-esx0118.eng.vmware.com (sc2-haas01-esx0118.eng.vmware.com [10.172.44.118]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id D102B41391; Wed, 5 Dec 2018 00:52:04 -0800 (PST) From: Nadav Amit To: Ingo Molnar CC: , , "H. Peter Anvin" , Thomas Gleixner , Borislav Petkov , Andy Lutomirski , Nadav Amit , Dave Hansen , Peter Zijlstra , , , , Nadav Amit , Kees Cook , Dave Hansen , Masami Hiramatsu Subject: [PATCH v7 02/14] x86/jump_label: Use text_poke_early() during early init Date: Tue, 4 Dec 2018 17:33:56 -0800 Message-ID: <20181205013408.47725-3-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181205013408.47725-1-namit@vmware.com> References: <20181205013408.47725-1-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-002.vmware.com: namit@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: 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) { -- 2.17.1