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=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 1BB50C433E0 for ; Thu, 9 Jul 2020 12:41:45 +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 D7FDB2077D for ; Thu, 9 Jul 2020 12:41:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="2xc3TD5H"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="u7VoEStn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7FDB2077D 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:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EoeoSKZCmcZDaMis3eQdkU79ljNogIQeG1sZl/IPJXI=; b=2xc3TD5HAsAwo40vn6DOdak+T g1qn24WSIwYgNR969g0OzzY8XD5b3osv435Ln1u8+LHCWTJ5htNiPfaq0iyJSzXvf9f16i5RQ2Y+F DGXUhCjtuUEr5wr/lzB57NhxQ808lBaiTP8LtmxC6S+FxoVwGDGfy6n83pgrEo8CJ7A+aANSirBIt VqFgCmzBV4vriaB990lv3YENdMhQYNwPqTOKLBou13wATOLzfJhNTzcqr2zf4BwvfVtJ8WIr/qDsP DcbqShl6QGgHQZyTPEQ3ZzfcOwX3m8a3j31sodw3fxZiEv4OIC7AQShWiN2kuvQhKpK5JMPdtCdBg 442bsc0bQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtVqT-00068S-9i; Thu, 09 Jul 2020 12:40:09 +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 1jtVqQ-000687-Dt for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2020 12:40:07 +0000 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 3EA332076A for ; Thu, 9 Jul 2020 12:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594298405; bh=gecSNfW4UzuBs2/gftOwqQsfcmkY3XkgqJ0JxsgJ/S8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=u7VoEStnMV37f0lyAyGa8xK+g3Y3ol6diUedii5Cq4N59rnwRbc+VkYv+u4BwxMxq whS/nW4iH7+EGfOWRkfshEj68xaLiaqYxcBP34Vbkh+1wREpOIx5Fa6cLPz8yKB0Jo 084NHiUdTapMPYbsqRfDG4/yxH10mOBN+YigpSJc= Received: by mail-oi1-f180.google.com with SMTP id l63so1708788oih.13 for ; Thu, 09 Jul 2020 05:40:05 -0700 (PDT) X-Gm-Message-State: AOAM530S3WJ93WhjeA6njqQHwDZDrRgWEaZNR97QwMOgGzu4lMosel/d PUouCQp+yE94CUdcyj7IIexnCmyP9ALqqFaGUNM= X-Google-Smtp-Source: ABdhPJw3yQ+ckrSX5bqKJWUjz6uOUdsFcTYv7oYqBEpilEAF+3PjCA18TXbDF59X8rDQlQAfDLyWI6VzRq1eKG7yHQA= X-Received: by 2002:aca:d643:: with SMTP id n64mr10996654oig.33.1594298404649; Thu, 09 Jul 2020 05:40:04 -0700 (PDT) MIME-Version: 1.0 References: <20200630081921.13443-1-ardb@kernel.org> <45e53113-75bb-9e7b-cd81-72d782bbb57d@arm.com> <7b503f04-f4fd-54a8-db42-fcf927ee96fa@arm.com> In-Reply-To: From: Ard Biesheuvel Date: Thu, 9 Jul 2020 15:39:53 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64/alternatives: use subsections for replacement sequences To: Alexandru Elisei , Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200709_084006_611881_60C89778 X-CRM114-Status: GOOD ( 23.11 ) 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: Mark Rutland , Anders Roxell , Arnd Bergmann , Suzuki K Poulose , Catalin Marinas , James Morse , Andre Przywara , Dave P Martin , Linux ARM 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 On Thu, 9 Jul 2020 at 15:31, Ard Biesheuvel wrote: > > On Thu, 9 Jul 2020 at 14:11, Alexandru Elisei wrote: > > > > Hi, > > > > Hi Alex, > > Apologies for the breakage. > > > > I should post the entire boot log: > ... > > [ 0.002204] pc : work_pending+0x32c/0x348 > > This suggests that you ended executing directly from the alternatives > replacement section that gets appended to the end of work_pending (and > therefore gets mistaken for being part of it) > > It appears that the following code in alternatives.c > > static bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc) > { > unsigned long replptr; > > if (kernel_text_address(pc)) > return true; > > returns true inadvertently for the branch in this piece of code in entry.S > > alternative_if ARM64_HAS_IRQ_PRIO_MASKING > ldr x20, [sp, #S_PMR_SAVE] > msr_s SYS_ICC_PMR_EL1, x20 > mrs_s x21, SYS_ICC_CTLR_EL1 > tbz x21, #6, .L__skip_pmr_sync\@ // Check for ICC_CTLR_EL1.PMHE > dsb sy // Ensure priority change is seen by redistributor > .L__skip_pmr_sync\@: > > > due to the fact that kernel_text_address() has no way of > distinguishing branches inside the subsection from branches that > require updating. So the alternatives patching code dutifully updates > the tbz opcode and points it to its original target in the subsection. > > This is going to be rather tricky to fix, unless we special case > tbz/cbz branches and other branches with limited range that would > never have worked before anyway. > > For now, better to just revert it and revisit it later. > ... unless we decide to fix up all branches pointing outside the replacement sequence, which is not an entirely unreasonable thing to do: diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index d1757ef1b1e7..7c205f9202a3 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -45,18 +45,11 @@ { 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 true; } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel