Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1518561imu; Tue, 20 Nov 2018 20:09:09 -0800 (PST) X-Google-Smtp-Source: AJdET5dHza3APX7GkLpRj6DOFp26pkJ/8sRgzJR48WCPcNVYWipH1FrgCQbKbSaTIPOFv2/Zo1eN X-Received: by 2002:a62:848d:: with SMTP id k135mr4713872pfd.47.1542773349479; Tue, 20 Nov 2018 20:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542773349; cv=none; d=google.com; s=arc-20160816; b=jhHfYBrWsi7FXSM0byrmUgr5ycMAoAdNDTSzPO9sf7l4WRzKB+qQWnDtZOkkrjb8iA uwfBQ45cAOv5xxIzStsAWgtmUbisvfFU2itr7aSAXQUah6hpXKhy86A/1nzFlM3zLxEF D/Og8g97it5UGkrICPxvhG1KXKZlhnReDyi9ZLASKdutkbqzZF5Zb5rkVy3fMrnJh0aR K9+4R5u1iTDC6V5YPM5Wv815qdhl95/j5+Zuum5/aHAjxDTTGCxVDCNc3Hcpzt1hxM/w xNa5CFrPoCEPU6BM1fpt4VfY3nt6JbCtAwIBu1q5OWQCXRChr5hBPQYbHk1Wj9ISViFe WREg== 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=RV2yvjagArs8QL5fAOg/r553cukKUVnX6QA9hhksWcl59YiE/SQnHuX2s3gieTnoyF x8lAAPT9RS1xaQcnL1bWLFFnyzBNj/9XFK+sJgzEU14hJrtAPk4fEWewTFpwnxZAt3UU ucbOVXQGwoPChT4yBnQ29j3Fbm0arfwktVRIBWPLZJbj03tdMHkr2LyqnmejIaHxiplP BuqHic+A6fPyZTKSlSfib+NOR5ebTlJCaaa8ZZeXVHTBzLA+pOWMPeCi4yeJjUZ8ay+s l5MPsWECiOdmWjwgLyR6/Tp3WUAKI8sNNPD9Je5BPqnvq1L2fRK0kriq6vUhtt0Wi3Si GIBg== 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 g8si17745838pgb.128.2018.11.20.20.08.52; Tue, 20 Nov 2018 20:09:09 -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 S1727534AbeKUO0J (ORCPT + 99 others); Wed, 21 Nov 2018 09:26:09 -0500 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:2110 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726849AbeKUO0J (ORCPT ); Wed, 21 Nov 2018 09:26:09 -0500 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Tue, 20 Nov 2018 19:52:59 -0800 Received: from sc2-haas01-esx0118.eng.vmware.com (sc2-haas01-esx0118.eng.vmware.com [10.172.44.118]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 429FAB1874; Tue, 20 Nov 2018 22:53:30 -0500 (EST) From: Nadav Amit To: Ingo Molnar CC: , , "H. Peter Anvin" , Thomas Gleixner , Borislav Petkov , Dave Hansen , Peter Zijlstra , , , , Nadav Amit , Andy Lutomirski , Kees Cook , Dave Hansen , Masami Hiramatsu Subject: [PATCH v6 02/10] x86/jump_label: Use text_poke_early() during early init Date: Tue, 20 Nov 2018 12:35:37 -0800 Message-ID: <20181120203545.34928-3-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181120203545.34928-1-namit@vmware.com> References: <20181120203545.34928-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