Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp338944yba; Fri, 26 Apr 2019 00:34:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAw44kNYx1u7ZaUaCDCFpm+Uk0LIuq2uQCKJ3u342KtbAWbGxVaogLY6NsJsHkuIZ2T/Z+ X-Received: by 2002:a62:5795:: with SMTP id i21mr16817501pfj.194.1556264061420; Fri, 26 Apr 2019 00:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556264061; cv=none; d=google.com; s=arc-20160816; b=H24DBNm+viqoEHkWfG0+wDS9Y+VA6FfZk0UjJ11B/pduod06qa2rRf8A/vLrjOZ29l hR5Q3tKEKRDiwaqbpVjOi6gdJzoogtBJnQWP9ZHaRCv+twuScrXmv4R7dinJ+7wrA411 BHAdVAARRZZKFJhPx52taOvVQemjf5Gety0xVIleJZV+Vspbypq6p4jxzKQYfqyEqi9G Mn8iWazHAA8u25+eLh42WUQ/22W+YlDQS4QPUUdYr43Iao747z96Qe0ttkCD8mqJonnr KrImwzV6tJwJPTfvuupuKMGZs8mccKcmdX0xTw3XQR9lp1ZXna372rtWlHNZ8c2VQG2+ N+xQ== 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=a0R0Xf8x/FEfdOPmfJkRWPwDaNy7YthB2Sa0kPsS6+I=; b=znqbvJ88XQYFL/zpNZwPn8HiHO28zF50l5PaAtkatKNM1WKnP78Ypsp9Vz+mofmX6R lHiqwadq52YYLoaXDfEJZZvhQilYCmD5PtsYzaCeRiHxB6/ll0QT+8gVC9noU0cvg/2L DukC0JfsLb1DLwGsBmMSfk55+jh0RgfI2LnDUOSmltVBOhyB49S7i4Ul4x4QeK4PJ21I 1uWuGywwVcZpT8ZyHLIM3fFSdQdOugCxG/kA9Xh69swpe08nw2UyeHywqshkT1wNdfLs h8gdi8bcMCjc28B9cB1slVacntmhxPs1uYzwXVYpVTXflOoi0itr7vaJM6h3GzCk+tWA /pig== 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=QUARANTINE 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 d3si23984942pgh.238.2019.04.26.00.34.06; Fri, 26 Apr 2019 00:34:21 -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; 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=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726449AbfDZHcV (ORCPT + 99 others); Fri, 26 Apr 2019 03:32:21 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:29121 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbfDZHcB (ORCPT ); Fri, 26 Apr 2019 03:32:01 -0400 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; Fri, 26 Apr 2019 00:31:44 -0700 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 C60F7412A6; Fri, 26 Apr 2019 00:31:45 -0700 (PDT) From: Nadav Amit To: Peter Zijlstra , Borislav Petkov , Andy Lutomirski , Ingo Molnar CC: , , , Thomas Gleixner , Nadav Amit , Dave Hansen , , , , , , , , , , , Rick Edgecombe , Nadav Amit , Kees Cook , Dave Hansen , Masami Hiramatsu Subject: [PATCH v5 12/23] x86/jump-label: Remove support for custom poker Date: Thu, 25 Apr 2019 17:11:32 -0700 Message-ID: <20190426001143.4983-13-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426001143.4983-1-namit@vmware.com> References: <20190426001143.4983-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: Dave Hansen Cc: Masami Hiramatsu Acked-by: Peter Zijlstra (Intel) Signed-off-by: Nadav Amit Signed-off-by: Rick Edgecombe --- 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); } -- 2.17.1