Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1508592imu; Tue, 20 Nov 2018 19:54:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/XVLh3NCd43g0xFvDtq8HwgC+bKcdDC4asPfobs3EBrF/VMRBRCFIGswW9BoyjvkNsBXS5P X-Received: by 2002:a17:902:d806:: with SMTP id a6mr4915963plz.172.1542772491009; Tue, 20 Nov 2018 19:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542772490; cv=none; d=google.com; s=arc-20160816; b=zZS628xx7xIaD/2j93eTCcJHg0AnIW6A6xXxegvhr1ZwyQT44IOKLJlaOfK7lE5+Cd 6hQkc2zEq0kkYpTc1dSQEKMNiXqX+0cIIjiLQZ6LJJNyzxctq88FQmOYjJuFhDETflkq +38XBHMwIm8iyxd4Vg3sb0dnhwWlHtx+1KtHTK7ET91YdnR1mbIRWeAn+U3Xyi8mjUxy JbPAIIKMxOq5qjfgiZKV4jJl8np8xbcRRT8Z32Z5xfP2Wm9Q1ns7CS1snvphpoB0SNH2 2vpN3dth6vzHWK6UYgDXZVjmAvNSgGHAtbxHaC0S8115IjytwVgUWUnWlOm8rLgFDdCo Df/g== 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=JcWdv0FLQQFV/6F7PYdPbKYTDAHpFUsnopBaGEojo3EEhirHZ9L38g9Mp6Rq8Gw7GS lWpGKE3I51adhMd3Gnm/Li4k821oZWNVC5qe5tL9q3WGdh+4mK6nQ93n+es15PcWqVLd 2Tts8T+m/E3cFz67hT+jjGbsPqGcQibq94oG7DSTnBX22F/fkwiMJBno8f2RyioCTHDt esNXw7b6v2I3uNe9YZVbLJus/hKZNcuIoJJ6Yzejx3L1NsSuZOht+3jLvPhELHis4FUY Kr6/5CJ1VsO5eL8+6SM8N1W2LW8WUoTIaDz0eN+X22al+UakAw7dsLrTg7vywK5h2gDH yhaQ== 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 b14si24323838plk.333.2018.11.20.19.54.36; Tue, 20 Nov 2018 19:54:50 -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 S1728097AbeKUO0O (ORCPT + 99 others); Wed, 21 Nov 2018 09:26:14 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:13925 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728021AbeKUO0N (ORCPT ); Wed, 21 Nov 2018 09:26:13 -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, 20 Nov 2018 19:52:52 -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 A3EFFB1879; 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 09/10] x86/jump-label: remove support for custom poker Date: Tue, 20 Nov 2018 12:35:44 -0800 Message-ID: <20181120203545.34928-10-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-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