Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2713633imu; Sat, 10 Nov 2018 22:37:19 -0800 (PST) X-Google-Smtp-Source: AJdET5fYAJ+ALzOF5ZJgaqM5srLIvAEZnNjCCEtKYpXOE0xUMbaYXUMLGhNa+uZpaCL5DdYRhYKp X-Received: by 2002:a17:902:1124:: with SMTP id d33-v6mr15841878pla.125.1541918239640; Sat, 10 Nov 2018 22:37:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541918239; cv=none; d=google.com; s=arc-20160816; b=N/TrNWhK2KaaqSSQnUHgZttATcgh0mwJtjNEa0FN+d4rrN22sMBHa7Bf/sYKBHEcTn Gzx0bvrqnhVOdVVGmnzxbYmMKUcrLrZB5bvnCk63Qh7zIqTKhpZyQwQZzs4Kyh6TVy8S hwuMV3u4N4F4sFZN/2qtRKxpyxJAr649ox4T8bSVjLe4iZH6IK2FO4AIgJPIwyweqN/L 54xUYU22oQSTYQNWAQPT5gJ7/GRRIoJAeur7ewI6ZeUja/WdteW6gmIjVjIJ3u8zFlpR 6nGKVrPPHBVcaA2IiOmOr+iUT/dL8O2H5CsUcUWqgr0tn90v/GGPzkNaN+yOLjiBYDYt DOTg== 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=bMXW8gUjRIWgUnho4yRu/g1IngZq6XZdEUKSKYquu2c=; b=c3j6/oEkcu7P8czGckNXct1+grh3wjF1X2uRs5nok2AGxemTi1mkvS0/2pvX+p3Uo3 0kOSE+4j0Sx9yA9KjND51asVHwuq2rqmEJkEBqd6nTSco5gtJk6Jb1TWHeLwWsC3ov5m xRosnwG0CvEI1tW3Gs4NqRwg+CYPl+8kvnnNINOYanswHTcSxvtsUJ8DGmV7W6AfbzZT gbq3MptPwvFpeo264ty2q6AIWSOdzeBXHOLE954TEk2+uuN89dM7UFhasJDHLLPTmgzv 8qsQD+RrjaiTS3OS/rhy7gn5FuqxpwuMJPmk9oM2NbS0NFYrudHMTORyGGNOH6JqLzLG p/Jg== 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 g9-v6si13141290plo.328.2018.11.10.22.36.25; Sat, 10 Nov 2018 22:37:19 -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 S1728006AbeKKQXK (ORCPT + 99 others); Sun, 11 Nov 2018 11:23:10 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:25452 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727648AbeKKQXJ (ORCPT ); Sun, 11 Nov 2018 11:23:09 -0500 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Sat, 10 Nov 2018 22:35:01 -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 8DA4640762; 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 , Peter Zijlstra , Dave Hansen , Masami Hiramatsu Subject: [PATCH v4 09/10] x86/jump-label: remove support for custom poker Date: Sat, 10 Nov 2018 15:17:31 -0800 Message-ID: <20181110231732.15060-10-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-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 | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index ed5fe274a7d8..7947df599e58 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -39,13 +39,13 @@ 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; const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP }; const unsigned char *ideal_nop = ideal_nops[NOP_ATOMIC5]; const void *expect, *code; + bool early_poking = init; int line; jmp.jump = 0xe9; @@ -58,7 +58,7 @@ static void __ref __jump_label_transform(struct jump_entry *entry, * SYSTEM_SCHEDULING before going either. */ if (system_state == SYSTEM_BOOTING) - poker = text_poke_early; + early_poking = true; if (type == JUMP_LABEL_JMP) { if (init) { @@ -82,16 +82,13 @@ 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. - * * 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 (early_poking) { + text_poke_early((void *)jump_entry_code(entry), code, + JUMP_LABEL_NOP_SIZE); return; } @@ -103,7 +100,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 +130,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