Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6537816imm; Wed, 27 Jun 2018 09:08:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJJe/kKk+KM4q+tX1Yoqmo1Inhd7fMjLs6x4H9earuWLCvUaabWYjm+WGCK9pYVOzKTr0dA X-Received: by 2002:a63:107:: with SMTP id 7-v6mr5613875pgb.289.1530115720552; Wed, 27 Jun 2018 09:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530115720; cv=none; d=google.com; s=arc-20160816; b=apJG4CoQ7lMDbH2Iqg3Ca/BMykmP3zj9YOzjkoFrlqcQrkAZHiJ1YuCbh4GbnJ8nRd nvnR0owlnzE2hbFqzZyM5FWMz+oieTbDfwCJwi8ZE8rcFaPSmsA3gf7J8LcQEsjHb0Az 0ihxzPy/BuSKcUbDI1SojYoIgDjZGwPMfTB8fY8lMWgcsEJZcECrNLUCkpbiNLUHIcAM vaquvohosV70NfO8YCQ9mnlU18Iz+zW33C1ICdsnBqhiErduamTk6hiH4GmhgV8Sia1I /oyJpWr3reQHCYOJh8UCsw7WfloCvFFMifv+Had3Re7mvlHPL/Mk7pyvd9mWoiHpzy74 G9og== 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 r24-v6si3936158pgo.295.2018.06.27.09.08.15; Wed, 27 Jun 2018 09:08:40 -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 S935102AbeF0QGT (ORCPT + 99 others); Wed, 27 Jun 2018 12:06:19 -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(-) 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, -- 2.11.0