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=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT 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 96BA3C10F14 for ; Tue, 23 Apr 2019 11:43:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 607AB21773 for ; Tue, 23 Apr 2019 11:43:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WS7cJETq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 607AB21773 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=akYx5PGIJ9JfCwTEoCInUpTDiJ5x9f3Kadd8v95+Ngc=; b=WS7cJETqU05q+2 vjpAt5FIHjjWthRK8WpiPfiqIUhEmMiSf1IlN4wk9iG6GvEpWcvV7KkgE/L8OBlkSLxGOa4KKGxUa 1ARcCPV6QOi+gjQ5ioB7VTp2PRBx6uxZKTerSXpyyIJnhbAt/UCpbzpoj5k2Cau4exbsKRQbBaLL6 R5g0HM1GeKX77kCWz9h1tDzKyjLTNMSUgJyc//2cY4u7gYb/4py+aPoBqbRVHRD1XqzkfjYmDrXtQ flYRhhrM68UbLDeDRShn4IJNsp4eS37U17ZgUDEYPaJhXKrQ8wTE7cMPEK55G/OJdPuInsHElWzX7 M1BMmSbHuOxJV7IZu0Lw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hItpZ-0008Lu-E5; Tue, 23 Apr 2019 11:43:21 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hItpW-0008LY-OQ for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2019 11:43:20 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 70337EBD; Tue, 23 Apr 2019 04:43:18 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 330783F557; Tue, 23 Apr 2019 04:43:17 -0700 (PDT) Date: Tue, 23 Apr 2019 12:43:12 +0100 From: Will Deacon To: Ard Biesheuvel , catalin.marinas@arm.com Subject: Re: [PATCH] arm64/module: ftrace: deal with place relative nature of PLTs Message-ID: <20190423114312.GA6732@fuggles.cambridge.arm.com> References: <20190413065925.6981-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190413065925.6981-1-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190423_044318_797049_8A9C1257 X-CRM114-Status: GOOD ( 20.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, dann.frazier@canonical.com, duwe@lst.de, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 12, 2019 at 11:59:25PM -0700, Ard Biesheuvel wrote: > Another bodge for the ftrace PLT code: plt_entries_equal() now takes > the place relative nature of the ADRP/ADD based PLT entries into > account, which means that a struct trampoline instance on the stack > is no longer equal to the same set of opcodes in the module struct, > given that they don't point to the same place in memory anymore. > > Work around this by using memcmp() in the ftrace PLT handling code. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/kernel/ftrace.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c > index 07b298120182..65a51331088e 100644 > --- a/arch/arm64/kernel/ftrace.c > +++ b/arch/arm64/kernel/ftrace.c > @@ -103,10 +103,15 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) > * to be revisited if support for multiple ftrace entry points > * is added in the future, but for now, the pr_err() below > * deals with a theoretical issue only. > + * > + * Note that PLTs are place relative, and plt_entries_equal() > + * checks whether they point to the same target. Here, we need > + * to check if the actual opcodes are in fact identical, > + * regardless of the offset in memory so use memcmp() instead. > */ > trampoline = get_plt_entry(addr, mod->arch.ftrace_trampoline); > - if (!plt_entries_equal(mod->arch.ftrace_trampoline, > - &trampoline)) { > + if (memcmp(mod->arch.ftrace_trampoline, &trampoline, > + sizeof(trampoline))) { > if (plt_entry_is_initialized(mod->arch.ftrace_trampoline)) { > pr_err("ftrace: far branches to multiple entry points unsupported inside a single module\n"); > return -EINVAL; Acked-by: Will Deacon I guess this can also go in as a fix via Catalin. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel