Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9226670imu; Wed, 5 Dec 2018 00:53:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/XEyNThi3i7aUE/FgHXtplBR9p6tUyEDUmHUW1VcCI9vPoxSqyb09Xa0Bifvingpz3+BRRQ X-Received: by 2002:a63:de04:: with SMTP id f4mr19350255pgg.292.1544000018347; Wed, 05 Dec 2018 00:53:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544000018; cv=none; d=google.com; s=arc-20160816; b=DtBLYu0dw/67wGRfRXVozdmX8ftZigFsYaumACMWp5K/Yb0MxBRTRySqbfVsxr7dFJ Q3Gj4jB4ZXVhzStrdfD3+hisaGQWz2cbcEcfLiL66WwcbBPV7oe7B0vMcZPnx/P8t2hB GB5yWBlz9MZGohtdgYg9QJfgo1xLPlPkGlcdWaQrNGo9X4MTkYu0EOu8/LLHK19ZoGSl 4unT4ryHetdCsy5mdfbvIUglw1O/2QJfOKNbPUSI5fklQSLjDYtLf4C7E3XfQMp2AMc4 6GvfMquC9EX9gE+ZuHl2kLlBYum/shbRnWNpj8iG0ol7yr5mNNb4R2SkGjj0TelnbKv7 nSrQ== 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=swwAtAMySsvXTQT/BwVsmrzZO7roGINuanazqxkTBhT7Rcplt0KRqP+CCEMsy0Gtg6 hLO1/fNSd6sGK0Riq32NIyxjPrtYQ4Ixa+S8T0kTr2nzfLC4M/a7uB2NvZobtEDS3VcX 99LTutW03Glwc1Rstpcz0JrkaoLobaneJf+fTyynInOFyGsxBVhKq+G+xSGzuQomkXPy of9jG1qrY5oFgAvLLIZmzD0Qn9EfN73HoTWRuUqoncpewFaXOWymZMoohKsuGDLK7T1o K7GXaVh6zMeEZH2XSBik1RXZlvcYYdprKMvB38pLJTyvFIIgBR1qvAZc6A4WX/Kuw0ID 6xww== 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 b21si21070410pfb.89.2018.12.05.00.53.23; Wed, 05 Dec 2018 00:53:38 -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 S1727484AbeLEIwN (ORCPT + 99 others); Wed, 5 Dec 2018 03:52:13 -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 S1727437AbeLEIwM (ORCPT ); Wed, 5 Dec 2018 03:52:12 -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 2F837412B7; Wed, 5 Dec 2018 00:52:05 -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 11/14] x86/jump-label: remove support for custom poker Date: Tue, 4 Dec 2018 17:34:05 -0800 Message-ID: <20181205013408.47725-12-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 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