From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 461D4C433E0 for ; Thu, 9 Jul 2020 13:01:23 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1482C2073A for ; Thu, 9 Jul 2020 13:01:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xZxEZeR4"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z1vqBYsK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1482C2073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=dUeu2UI+MC5yTUK51t8W+Xl//tnY5pb/MHaiKn9+kRM=; b=xZxEZeR4DbI3dgJCDV9GdMWozz casZfBtV5v0yJxvDkYDLDPo8C7qLRM4PBDPmhQ4Ng71hFKYVgTJxGIiiUCeGvXphskE1+Yeb38Qwb l+StRTE4RZB7S8v+Ztr9PCUHNwSP8DaEaeKsDzzO5NN9R2BzogJvDr45P9pZfDUNkXXUwccJyvTNT W8kFIh+ZDXvubBhOmmCXXKpRSEmtpankoAr4QOmMaEGzF8IcfvL9zFEJ9mFQLx2T/90l9/yXEasI4 YmJS5VjmaDMkiyTlLXuJE1KM5yY5sDeKwQPVn5BNq0gGNtMwY1PWchfXPTMRncAggMu3+eSVBESx9 4BzcX/Rg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtW9l-0000th-KD; Thu, 09 Jul 2020 13:00:05 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtW9i-0000sI-30 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2020 13:00:03 +0000 Received: from e123331-lin.nice.arm.com (adsl-53.109.242.3.tellas.gr [109.242.3.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF8C22073A; Thu, 9 Jul 2020 12:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594299601; bh=uR/f4/XDtRtNuOSnEFdVl6s7MdsNkYs/x5g5OGBtH9M=; h=From:To:Cc:Subject:Date:From; b=Z1vqBYsKV2xwTohmCtx/NgRt45Cvd1xqNGw74tT3WMZ5EmWrNK9vfcBDLhu/vYLYQ sGaSRiSZPP+yiXq/XKoJ5BfGzQkd648qDT6qXPTTVZ/jHXsPfKS4bCAGdcH3gKm0o2 GGsaJbogmwUo4xLrFov3mP7F2gi+q6NmtBr3c0OE= From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64/alternatives: don't patch up internal branches Date: Thu, 9 Jul 2020 15:59:53 +0300 Message-Id: <20200709125953.30918-1-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200709_090002_362110_6F835946 X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: catalin.marinas@arm.com, will@kernel.org, Ard Biesheuvel , alexandru.elisei@arm.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit f7b93d429 ("arm64/alternatives: use subsections for replacement sequences") moved the alternatives replacement sequences into subsections, in order to keep the as close as possible to the code that they replace. Unfortunately, this broke the logic in branch_insn_requires_update, which assumed that any branch into kernel executable code was a branch that required updating, which is no longer the case now that the code sequences that are patched in are in the same section as the patch site itself. So the only way to discriminate branches that require updating and ones that don't is to check whether the branch targets the replacement sequence itself, and so we can drop the call to kernel_text_address() entirely. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/alternative.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index d1757ef1b1e7..5711adda14bb 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -45,18 +45,8 @@ static bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc) { unsigned long replptr; - if (kernel_text_address(pc)) - return true; - replptr = (unsigned long)ALT_REPL_PTR(alt); - if (pc >= replptr && pc <= (replptr + alt->alt_len)) - return false; - - /* - * Branching into *another* alternate sequence is doomed, and - * we're not even trying to fix it up. - */ - BUG(); + return !(pc >= replptr && pc <= (replptr + alt->alt_len)); } #define align_down(x, a) ((unsigned long)(x) & ~(((unsigned long)(a)) - 1)) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel