From patchwork Tue Jan 2 20:05:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 123221 Delivered-To: patch@linaro.org Received: by 10.80.135.92 with SMTP id 28csp4761848edv; Tue, 2 Jan 2018 12:07:21 -0800 (PST) X-Google-Smtp-Source: ACJfBou7HnPvqQx6ODe+p9hX/53JNnfKqR+dIJhMZ6rJcPhEmIhV9djfLIfiSy7gwwmwNJP/UGUt X-Received: by 10.99.145.68 with SMTP id l65mr9070831pge.204.1514923641254; Tue, 02 Jan 2018 12:07:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514923641; cv=none; d=google.com; s=arc-20160816; b=Mjg9+PcRzX/Z1wCO/ZMrzHTqAzHlBAMTf0n7J3Jm0qSj2fc1m+mZgFwJ1VoeW0egkB np7YRoQQv3003pSQsH2Ctoq9Jta/TfianlJ/HY3GrHH4c5Ze7eDt6ISNOKSIT8nS6+MO 2LIoPddRykMk6PcEgFKPSplRuUFSAoLklkWp+dZLRLOoGMicG22ev1BbKyLJOqgOsX7/ Jue/2pfqxP3xKM0huuhh1PFcNkFM052UFn/r+XR4Cyxil6nJzWeBn5e6GZJxxmkcTXaR z40ZacOLkqA2DtgCGbcpiyKHySD7kiImUmyUIVtnjxDHMuiiUZRxlfaU8lp6RgQZ/9+j WGTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3xW6hB18H7nCj1B8KM19meDl2NukzrBIHv9vfi9d94c=; b=mo1pMdxI0mqSAxg/jg5AHjZOm0YFIAoAh6Db6/HwYwXe1BHA/beAM2zEGyu/T7J9+J E+sWpN/HsCBOvikwDGvW4L9bZjOIBIiYd8kwRVqqwfVRSFosFc3wya4KXEaFC4VYfAG8 aHcvrnZKcoxCdOkTWkWvbokTV5FhJfYkiki7Poin9v3QP3ZLx1ZiJOiLObIVxkgT4Fpo CoQby1XwXG0ng7wn5SyrSaq5wmB9Nnn+MURSI0rArO21PDTYlCsoxgvH1KE1Vlw5jdp1 5dJ/R+TGPh1/l6Pt4bEMcDBYOB87HnDF0/AgdE6ngz7xim8Y2VA2ec4pRh1dJR0aPfjJ l5xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IlsjC4yq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si34181770pli.392.2018.01.02.12.07.20; Tue, 02 Jan 2018 12:07:21 -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; dkim=pass header.i=@linaro.org header.s=google header.b=IlsjC4yq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751266AbeABUHN (ORCPT + 28 others); Tue, 2 Jan 2018 15:07:13 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34244 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbeABUHL (ORCPT ); Tue, 2 Jan 2018 15:07:11 -0500 Received: by mail-wr0-f196.google.com with SMTP id 36so16291021wrh.1 for ; Tue, 02 Jan 2018 12:07:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3xW6hB18H7nCj1B8KM19meDl2NukzrBIHv9vfi9d94c=; b=IlsjC4yqku/Bgvxd3dSYA80TsqwMeZzyABWwlbxe827nworF3Z2Xw2NJJ9GC5u1EVj TlmJPcYtP0p5eP2s5u9UB06rVtkb1x+/J7q2wqmbSLsSc3bgNNB1+bkZWxdCYlujbUoP GxFZ5Jka238l0BCJThgTwy43cQ6Jj89D4IPmg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3xW6hB18H7nCj1B8KM19meDl2NukzrBIHv9vfi9d94c=; b=TUd05nRPCGFQbvPwAgmidrAxF990jTUM9HeynmWW1BC2SG9WvJOV/uo++XknQuneMf CvLJBVvfW1QAyq6cXZgqGLLeQwbBjBR4l3sfVTJ5005Uz9W/UWCmaaFQXRAQxp32Gnmg thpuVwi2QTdZBSjTjIHwKQipSQef/fn2DVf7QPymmU63g1OPfcKh4d9Lxlh7ZJGIeky8 m2DYd416FsQNrvCA0bKdhAbf6YEAB6Db0N1GUSjLgEWwTKfadVYS//wc6doIsvtOzgDS lZEQmrzBfyY4yGd9SoqvU6X9mFGrW4cX+ov2qgRaCOLIY6gF6JWpP2y4N4RnyxTPEwDN tzAQ== X-Gm-Message-State: AKGB3mJYJCMyzztO+4rqo9NARtePUCMDCaLXKxPc7BHdWa6uL1zKOgZH Fu2PXXksNQjm3CMpsi5rGJqXBT1A/nY= X-Received: by 10.223.177.143 with SMTP id q15mr14341520wra.42.1514923629540; Tue, 02 Jan 2018 12:07:09 -0800 (PST) Received: from localhost.localdomain ([160.89.138.198]) by smtp.gmail.com with ESMTPSA id m70sm19128526wma.36.2018.01.02.12.07.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jan 2018 12:07:08 -0800 (PST) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , "H. Peter Anvin" , Ralf Baechle , Arnd Bergmann , Heiko Carstens , Kees Cook , Will Deacon , Michael Ellerman , Thomas Garnier , Thomas Gleixner , "Serge E. Hallyn" , Bjorn Helgaas , Benjamin Herrenschmidt , Russell King , Paul Mackerras , Catalin Marinas , "David S. Miller" , Petr Mladek , Ingo Molnar , James Morris , Andrew Morton , Nicolas Pitre , Josh Poimboeuf , Steven Rostedt , Martin Schwidefsky , Sergey Senozhatsky , Linus Torvalds , Jessica Yu , linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v7 09/10] x86: jump_label: switch to jump_entry accessors Date: Tue, 2 Jan 2018 20:05:48 +0000 Message-Id: <20180102200549.22984-10-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180102200549.22984-1-ard.biesheuvel@linaro.org> References: <20180102200549.22984-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation of switching x86 to use place-relative references for the code, target and key members of struct jump_entry, replace direct references to the struct member with invocations of the new accessors. This will allow us to make the switch by modifying the accessors only. Signed-off-by: Ard Biesheuvel --- arch/x86/kernel/jump_label.c | 43 ++++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) -- 2.11.0 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index e56c95be2808..d64296092ef5 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -52,22 +52,24 @@ static void __jump_label_transform(struct jump_entry *entry, * Jump label is enabled for the first time. * So we expect a default_nop... */ - if (unlikely(memcmp((void *)entry->code, default_nop, 5) - != 0)) - bug_at((void *)entry->code, __LINE__); + if (unlikely(memcmp((void *)jump_entry_code(entry), + default_nop, 5) != 0)) + bug_at((void *)jump_entry_code(entry), + __LINE__); } else { /* * ...otherwise expect an ideal_nop. Otherwise * something went horribly wrong. */ - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) - != 0)) - bug_at((void *)entry->code, __LINE__); + if (unlikely(memcmp((void *)jump_entry_code(entry), + ideal_nop, 5) != 0)) + bug_at((void *)jump_entry_code(entry), + __LINE__); } code.jump = 0xe9; - code.offset = entry->target - - (entry->code + JUMP_LABEL_NOP_SIZE); + code.offset = jump_entry_target(entry) - + (jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); } else { /* * We are disabling this jump label. If it is not what @@ -76,14 +78,18 @@ static void __jump_label_transform(struct jump_entry *entry, * are converting the default nop to the ideal nop. */ if (init) { - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0)) - bug_at((void *)entry->code, __LINE__); + if (unlikely(memcmp((void *)jump_entry_code(entry), + default_nop, 5) != 0)) + bug_at((void *)jump_entry_code(entry), + __LINE__); } else { code.jump = 0xe9; - code.offset = entry->target - - (entry->code + JUMP_LABEL_NOP_SIZE); - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0)) - bug_at((void *)entry->code, __LINE__); + code.offset = jump_entry_target(entry) - + (jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); + if (unlikely(memcmp((void *)jump_entry_code(entry), + &code, 5) != 0)) + bug_at((void *)jump_entry_code(entry), + __LINE__); } memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE); } @@ -97,10 +103,13 @@ static void __jump_label_transform(struct jump_entry *entry, * */ if (poker) - (*poker)((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE); + (*poker)((void *)jump_entry_code(entry), &code, + JUMP_LABEL_NOP_SIZE); else - text_poke_bp((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE, - (void *)entry->code + JUMP_LABEL_NOP_SIZE); + text_poke_bp((void *)jump_entry_code(entry), &code, + JUMP_LABEL_NOP_SIZE, + (void *)jump_entry_code(entry) + + JUMP_LABEL_NOP_SIZE); } void arch_jump_label_transform(struct jump_entry *entry,