Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4783891yba; Tue, 30 Apr 2019 04:26:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwe28IajuPwptNKlElSBW8p70NsZ9pz7nvHEzAlU9ORIaz2Gnxcr9H8JIxOFaK9M4cY0uRi X-Received: by 2002:a17:902:e086:: with SMTP id cb6mr6894751plb.237.1556623602271; Tue, 30 Apr 2019 04:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556623602; cv=none; d=google.com; s=arc-20160816; b=EbGyJ5lGhHVoBnAbA2tcmqGsEvKjfE9+J8RrrpooRWR/jN7BNZjDL/71fZdKG+IfHM KzVnw/wCYkRAmOW5XV9vr53gwHr+RlPj5R2wQSCeCSbENQJiUaH7EUOwz4RVDZfrOtf2 7XmzAKJaXTFLFJTEN+em43kPyz8IWGlUqI5tO2cCj64k4i6I1xfU7/O032DCtwY8nwTl 4vr3FuYxHKi+scK9lKs0YMOo9ikC0NmHuLnJ/xPY70nt0t6BPw7QO2/cEbVTLzKN6jLY fYPr1PqULq0zUhE6rG/1bU6Yr0qCGg2eheNQgG7od3dzdRo7pXeM2jqqVjRa5xLKvF2i s/7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=tmZb/ywuy5RuSOeSqOG7vwZj6rmGFHYEwUdw428e/8c=; b=sslJciTB+e1Cus02PYYSaSSK7mXlObxeRxGJJoTTImEJuHhrqg9+UFLmQsjLVQu+Yj XAYoUsyQQqZ5SlZ1JIHQWFxLh44CdFk+ya1WVPv7839uIQu1KCNdnL8e2d+zWBXidfzK 41QYiDFkepsmQ5tGci4OoQaw8x5cb3ZrYwyXhrj58YBYwzsABY283iEqO8x6USObHGrY 4+clN2M8lcqSctd496b9+RYBBj6wD8REhIzZs8NV6C/1YEg11huwZAKW2Ms5ypRsvS6W ec3tEt6+rwQh2Hn8yW42BexZGsti2Ny9NA8gN2FFAl72zqnJ2XKOOyAToGQXO9VCkKfg PpNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019041745 header.b=XeJMlENZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si35530957pga.257.2019.04.30.04.26.25; Tue, 30 Apr 2019 04:26:42 -0700 (PDT) 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; dkim=pass header.i=@zytor.com header.s=2019041745 header.b=XeJMlENZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727481AbfD3LYE (ORCPT + 99 others); Tue, 30 Apr 2019 07:24:04 -0400 Received: from terminus.zytor.com ([198.137.202.136]:40259 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbfD3LYE (ORCPT ); Tue, 30 Apr 2019 07:24:04 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x3UBNT3Z1347949 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 30 Apr 2019 04:23:29 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x3UBNT3Z1347949 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019041745; t=1556623410; bh=tmZb/ywuy5RuSOeSqOG7vwZj6rmGFHYEwUdw428e/8c=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=XeJMlENZHQHbFaWMJDB3MciBCjCAAIoX03eRjcdiOQizNlIIBARcZolUSGxSZW84N qqm1JktCBbgTIGH29WfwK+GouyWJeeq+WxGD6SWgFZ6QlU+YQ6baojEDBRqOR4bxYU oShqIPYI5ssL6NWmrrBtms3OG0xkDvWOSRJxxqvFi79IzcgfFQmIAz2ODeLZgLqjag TyIbXClTNcsmtUjqCY5lYZRl7raXnfOcvu8X+f1cQ7dw6w/vgoAPq9F5YKAAbNu3Fb md9bZBlQfNwQvROLZ9v/Y10tK7s3TdrhKELqsf9htHPslEyxDKA6eVSur6Qmc2oCMb uBJArRkcF+fBw== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x3UBNSS41347946; Tue, 30 Apr 2019 04:23:28 -0700 Date: Tue, 30 Apr 2019 04:23:28 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Nadav Amit Message-ID: Cc: luto@kernel.org, bp@alien8.de, dave.hansen@intel.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, tglx@linutronix.de, mhiramat@kernel.org, kernel-hardening@lists.openwall.com, deneen.t.dock@intel.com, linux_dti@icloud.com, hpa@zytor.com, riel@surriel.com, mingo@kernel.org, kristen@linux.intel.com, keescook@chromium.org, namit@vmware.com, peterz@infradead.org, will.deacon@arm.com, ard.biesheuvel@linaro.org, rick.p.edgecombe@intel.com, torvalds@linux-foundation.org Reply-To: mingo@kernel.org, kristen@linux.intel.com, hpa@zytor.com, riel@surriel.com, rick.p.edgecombe@intel.com, torvalds@linux-foundation.org, peterz@infradead.org, keescook@chromium.org, namit@vmware.com, will.deacon@arm.com, ard.biesheuvel@linaro.org, akpm@linux-foundation.org, bp@alien8.de, luto@kernel.org, dave.hansen@intel.com, linux-kernel@vger.kernel.org, deneen.t.dock@intel.com, linux_dti@icloud.com, tglx@linutronix.de, mhiramat@kernel.org, kernel-hardening@lists.openwall.com In-Reply-To: <20190426001143.4983-13-namit@vmware.com> References: <20190426001143.4983-13-namit@vmware.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/jump-label: Remove support for custom text poker Git-Commit-ID: bb0a008d6a2c543efc11313b448d2f26f91dc4f8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, FREEMAIL_FORGED_REPLYTO,T_DATE_IN_FUTURE_96_Q autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: bb0a008d6a2c543efc11313b448d2f26f91dc4f8 Gitweb: https://git.kernel.org/tip/bb0a008d6a2c543efc11313b448d2f26f91dc4f8 Author: Nadav Amit AuthorDate: Thu, 25 Apr 2019 17:11:32 -0700 Committer: Ingo Molnar CommitDate: Tue, 30 Apr 2019 12:37:55 +0200 x86/jump-label: Remove support for custom text poker There are only two types of text poking: early and breakpoint based. The use of a function pointer to perform text poking complicates the code and is probably inefficient due to the use of indirect branches. Signed-off-by: Nadav Amit Signed-off-by: Rick Edgecombe Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: H. Peter Anvin Cc: Kees Cook Cc: Linus Torvalds Cc: Masami Hiramatsu Cc: Rik van Riel Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/20190426001143.4983-13-namit@vmware.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/jump_label.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index e7d8c636b228..e631c358f7f4 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -37,7 +37,6 @@ static void bug_at(unsigned char *ip, int line) static void __ref __jump_label_transform(struct jump_entry *entry, enum jump_label_type type, - void *(*poker)(void *, const void *, size_t), int init) { union jump_code_union jmp; @@ -50,14 +49,6 @@ static void __ref __jump_label_transform(struct jump_entry *entry, jmp.offset = jump_entry_target(entry) - (jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); - /* - * As long as only a single processor is running and the code is still - * not marked as RO, text_poke_early() can be used; Checking that - * system_state is SYSTEM_BOOTING guarantees it. - */ - if (system_state == SYSTEM_BOOTING) - poker = text_poke_early; - if (type == JUMP_LABEL_JMP) { if (init) { expect = default_nop; line = __LINE__; @@ -80,16 +71,19 @@ static void __ref __jump_label_transform(struct jump_entry *entry, bug_at((void *)jump_entry_code(entry), line); /* - * Make text_poke_bp() a default fallback poker. + * As long as only a single processor is running and the code is still + * not marked as RO, text_poke_early() can be used; Checking that + * system_state is SYSTEM_BOOTING guarantees it. It will be set to + * SYSTEM_SCHEDULING before other cores are awaken and before the + * code is write-protected. * * At the time the change is being done, just ignore whether we * are doing nop -> jump or jump -> nop transition, and assume * always nop being the 'currently valid' instruction - * */ - if (poker) { - (*poker)((void *)jump_entry_code(entry), code, - JUMP_LABEL_NOP_SIZE); + if (init || system_state == SYSTEM_BOOTING) { + text_poke_early((void *)jump_entry_code(entry), code, + JUMP_LABEL_NOP_SIZE); return; } @@ -101,7 +95,7 @@ void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type) { mutex_lock(&text_mutex); - __jump_label_transform(entry, type, NULL, 0); + __jump_label_transform(entry, type, 0); mutex_unlock(&text_mutex); } @@ -131,5 +125,5 @@ __init_or_module void arch_jump_label_transform_static(struct jump_entry *entry, jlstate = JL_STATE_NO_UPDATE; } if (jlstate == JL_STATE_UPDATE) - __jump_label_transform(entry, type, text_poke_early, 1); + __jump_label_transform(entry, type, 1); }