From patchwork Wed Jun 27 16:06:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 140362 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1069281ljj; Wed, 27 Jun 2018 09:06:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJx32RQvo84XMNhXq4zVpqt+6ycjPxAlvUf9AF1Fjynu4O5XFoH5TH1BwJWvCAnlVuYsinO X-Received: by 2002:a17:902:ba8a:: with SMTP id k10-v6mr6799473pls.338.1530115583267; Wed, 27 Jun 2018 09:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530115583; cv=none; d=google.com; s=arc-20160816; b=KJv4sFVt9PKdXPB2adksXFNCfgTDppEgku2SlqcqDFbiyk7NTLEwyQFj3JN3RDPORf F5X/2l3DnNfxQZSxf6hVcSO/RriMZYUEmR40A907A3ECYWi0syTDM8LrQcuSsh1etq/B Ep7K2aIZAYfsbjYF+95TU+PshfiuHlLyZlMbFjQyMNVDnoF3JJazB1rcLfIEZ3l28mMu iGFur0i8yVv0YJAnzo5HIUEeGzneCnbQpZtkMCnIODC2AypbEhPjk2XpxOtgJ5LGyIH+ 3p2LGB+zvWw5KIwuzVXRPxZEVnMFMjfklf7xU4tnLtbHrI4ajQG07llXQ+E+ShZodrXI /iXw== 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=esdLUiP7Nq3pkGb9sS91qfLIwlUoKTrbJ1pPFJuzVN8=; b=fny9jkwc2mcNLUuVmeS7DVAbT3DTVZ/ACCeF3+XKipjCNR/MQqFSu1mgGoucKbN2DJ CqET+gZI022UYseuo5HRRy6H7IeTgsvGGh8T00xxu5hqnTBaLLMdpC41qTDZvCZ7YBud a0t9AOk1qz4xit4Fh8XCYOybf/P0/UpfhtDm6fSCReRrzbfusnu49DBwHQxJEFhStWnk 9JdtHpJyJVZeAqzltDakxyFFhgUudtq0V+712vliq0fZ32vLhimumvFUb0uK1fU4wiex fAFABIf+8qSLgSDs6Q60dSSEARvEPM61V7POti4kfRrs88QHRfnA0S+C5l6DO8hnDy1m nSuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CFOKClWp; 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 a10-v6si4089041pff.304.2018.06.27.09.06.22; Wed, 27 Jun 2018 09:06:23 -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; dkim=pass header.i=@linaro.org header.s=google header.b=CFOKClWp; 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 S935110AbeF0QGU (ORCPT + 31 others); Wed, 27 Jun 2018 12:06:20 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:54208 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934909AbeF0QGO (ORCPT ); Wed, 27 Jun 2018 12:06:14 -0400 Received: by mail-wm0-f67.google.com with SMTP id b188-v6so321937wme.3 for ; Wed, 27 Jun 2018 09:06:14 -0700 (PDT) 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=esdLUiP7Nq3pkGb9sS91qfLIwlUoKTrbJ1pPFJuzVN8=; b=CFOKClWpw5aVyAdTvFohT5qLEXHmaYuvG7el2Mj0dHB2mwVKTW2MFGWsyrkUpBMILS ChNE9yCoBxh78nTLsP/Bm0nc0tkOTSwx0MzIoHQUFzm4XeBhhuUnXwWjroQ8AF6w5i08 SAaSJr5sUWwDHqD9Aiox6yQObmW1VDz2iY1gs= 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=esdLUiP7Nq3pkGb9sS91qfLIwlUoKTrbJ1pPFJuzVN8=; b=bUsstkuIKUimNZQcn5pAyenJIi9vHyRio1sPDAYK8nQyHFaChX1USPIzcrOeOfwse0 YB895HVEbXwDBNkjI1FzvjZan+7h13KtAVOx1nJMbBrNe7uBgwzI81czpLlENYSQvOYc RgJP8q2BJaEOmy+cxUwP9yIXTvXOSVgIf2GeXQOJe0QRry+3CKVvscUXVLSQbstfRYG1 adCvl9euZcU4CzSUCF2r6BF2ENQ4i13L3f1OmZYLBtg7dF2g8JAPqcf049Kla9sAd+qk FjTLyD8jghAhfkNxTv94hyafPPT2VW+WWZBok8oB2zi+FUJSdpcy9istgJY0r56LZQ/7 3Qew== X-Gm-Message-State: APt69E1MMol4rwZhe1IeAF72bnhyfxZq1grO/TafMiSP+0hKdY1Ze7WJ 4DvA3glObRpqyTwuxBo9Z3kWI4UlAss= X-Received: by 2002:a1c:568a:: with SMTP id k132-v6mr2709334wmb.89.1530115573151; Wed, 27 Jun 2018 09:06:13 -0700 (PDT) Received: from rev02.home ([2a01:cb1d:112:6f00:4d04:66e:dea8:5b23]) by smtp.gmail.com with ESMTPSA id s2-v6sm7055000wrn.75.2018.06.27.09.06.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 09:06:12 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Arnd Bergmann , Steven Rostedt , Peter Zijlstra Subject: [PATCH 4/5] x86: jump_label: switch to jump_entry accessors Date: Wed, 27 Jun 2018 18:06:03 +0200 Message-Id: <20180627160604.8154-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180627160604.8154-1-ard.biesheuvel@linaro.org> References: <20180627160604.8154-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 members 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,