Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2714512imu; Sat, 10 Nov 2018 22:38:41 -0800 (PST) X-Google-Smtp-Source: AJdET5csJTBgYZl8BBGQ6JRtQBgVcXf9MwhsOgbxKs/+gb57sade84i91yLRTuCqx39Rt8J/TO36 X-Received: by 2002:a62:e707:: with SMTP id s7-v6mr15671787pfh.124.1541918321516; Sat, 10 Nov 2018 22:38:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541918321; cv=none; d=google.com; s=arc-20160816; b=cVNLTIX7Idc/kC8+GTv+yj7+dYdlEqxAKkXObBeai2/7tk5KV3Ais4T29XS+DiDD02 FL2l9YAFeXjXM/Wbp8S981YG6g8j7j5k3IdJ7vxxMc+X5GbViG8NpFFJmzTdU4mbiYOo 3BZENaUEZyUOi+VwcfAAyJfy3FYSshGN6I7S/TVC6hCZobdiQ+Pw9+D9w7lxACMx2rHA AUa3Mdu28UBK4Nufk7JcoBxPhDXTDReRGo3b3e3a19BW9WpPBLyW8uSL2m5Fp/WSLJ/d CS3c9YIhcTsVRMFctliYDMI0jo/Z6cGfYKFq6gWq2X995rWf8lu6kcGAZKqVT0+TEMnd vTPg== 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=k4fQGG2PtiLfYyVe1pdI0B7MjLTG3rMD5fjs5nzfD3g=; b=L5eAD7JrltV7xItoXJUMHJg6iLn0imp0YfyfU4+NO2fg7npP3pbVegN6FfHmEKOumY XjaoRpQKtKqUOi0lrmmZgBX8WRjuxNtRK5jwaqd01NihhRs7DanUI3bRV7GFmkDstH3n awNl7H6l+Hhxgw5WQWCF8PqZwEW9+s6D3TSrukloMvjOzOGu+QRMhFIj5vdhgreC0GN+ 042bdDqpBHtq0w8UFomy+6pTrCfPUcmQpsbDg0ggqS1xLib75fgY7mOt5n9vXol1hwFs 75wRU7vET0aA6T92XghT3P4r8Jk+XvBc7+Nf5hh1gMsErBb4I3zCYkrtOYG12VcuURP1 b+BA== 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 31-v6si13602636plz.181.2018.11.10.22.38.25; Sat, 10 Nov 2018 22:38:41 -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 S1727711AbeKKQXG (ORCPT + 99 others); Sun, 11 Nov 2018 11:23:06 -0500 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:35773 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727408AbeKKQXG (ORCPT ); Sun, 11 Nov 2018 11:23:06 -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; Sat, 10 Nov 2018 22:35:05 -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 4590E40762; Sat, 10 Nov 2018 22:35:24 -0800 (PST) From: Nadav Amit To: Ingo Molnar CC: , , "H. Peter Anvin" , Thomas Gleixner , Borislav Petkov , Dave Hansen , Nadav Amit , Andy Lutomirski , Kees Cook , Dave Hansen , Masami Hiramatsu Subject: [PATCH v4 02/10] x86/jump_label: Use text_poke_early() during early init Date: Sat, 10 Nov 2018 15:17:24 -0800 Message-ID: <20181110231732.15060-3-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181110231732.15060-1-namit@vmware.com> References: <20181110231732.15060-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 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) { -- 2.17.1