Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5832368imu; Tue, 13 Nov 2018 12:26:35 -0800 (PST) X-Google-Smtp-Source: AJdET5dhXN+vccl1YYCbzrIY09c7G9UwuSb1QB60r5aTDOg5A8W/o9qckRF3jl6Q5QiX28w1C6lP X-Received: by 2002:a17:902:da8:: with SMTP id 37-v6mr6673519plv.12.1542140795909; Tue, 13 Nov 2018 12:26:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542140795; cv=none; d=google.com; s=arc-20160816; b=NKzyJejoSeBObnHxgImq4c064do1n65TWJFpEtaQmsPu0JYJFnLjPY81NZND16YiBM ckqlgNPL4AqZmlk2T5plTcJ/HyoQ8rBh0EENJq3Xniv0yDYQ2rYWl3hgu8zkdWJ6QA68 iPnhfFlnMJ9ZAdYWcA3RBnYLmfk7Svxk/ZmSV3QY0wDo5FXvB2NDJta6WVfAlJTXA0iF Wr2/JpiWltIGczSxiX0R5qsWpkn/Djpodtmcik/GFs6dLelZ3QIMGg3+QDQ7gGND7OkU jtqkFlQ5UdzNlfUVwyPMQl7XWBUy2aWADJCm1jERern8vP5YRvL/QKQu69yTx2z7+zK4 ft7A== 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=2dFoY4+kzIPcyhGw+Xo2THK0FXktjvSRxz7PmAGp+IQ=; b=QrxfZ4fdaePqspZ/hDwHXLENlsx36lWAkIYqdqbpkA8Q34rkvJooJ2XVjV0ukRMJYl /swZTB9PJB30ujVrab8qVMu6XGdClqEBK9SSWVtsMQMKUayaJykj4uUJaZh8KOjZOwII AkB2tiJLjYJPLyM2QiUfwKp5kSrDL6GwUWip2YE207tzv0wCKz5Q71nkUCgxtrQCUxiE U5avRXO54mF/xAFGLOK/nTjFRUd28HVvAOoHF2XSNhuAKlq0KYK+Keg8pvMrdrln5lZT WBkqmj7UOjJf8FYGPpoyKBaA2jA/dDfsrCFkpBvUk7TRxXUsyWp8xv/VMoNbuLTLulCr VtSA== 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 u69si2713190pfj.219.2018.11.13.12.26.08; Tue, 13 Nov 2018 12:26:35 -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 S1731197AbeKNGZb (ORCPT + 99 others); Wed, 14 Nov 2018 01:25:31 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:21360 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731024AbeKNGZa (ORCPT ); Wed, 14 Nov 2018 01:25:30 -0500 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Tue, 13 Nov 2018 12:25:12 -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 D9225B1A56; Tue, 13 Nov 2018 15:25:38 -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 v5 09/10] x86/jump-label: remove support for custom poker Date: Tue, 13 Nov 2018 05:07:29 -0800 Message-ID: <20181113130730.44844-10-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181113130730.44844-1-namit@vmware.com> References: <20181113130730.44844-1-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-001.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 are only two types of poking: early and breakpoint based. The use of a function pointer to perform poking complicates the code and is probably inefficient due to the use of indirect branches. Cc: Andy Lutomirski Cc: Kees Cook Cc: Peter Zijlstra Cc: Dave Hansen Cc: Masami Hiramatsu Signed-off-by: Nadav Amit --- arch/x86/kernel/jump_label.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index ed5fe274a7d8..994c13e2867d 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -39,7 +39,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; @@ -52,14 +51,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 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) { if (init) { expect = default_nop; line = __LINE__; @@ -82,16 +73,17 @@ 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 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. * * 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; } @@ -103,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); } @@ -133,7 +125,7 @@ __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); } #endif -- 2.17.1