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,URIBL_BLOCKED,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 015EFC10F0E for ; Mon, 15 Apr 2019 18:47:24 +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 C3A42218DA for ; Mon, 15 Apr 2019 18:47: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="bDauwTrs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3A42218DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.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=uxdezxpiwE2s9uE8+6lyMzkM1fbXQAX561gEV8jrSGQ=; b=bDauwTrs902G6V OYY1P3JBQIwH3wFjkGlv2YpfWwfaE0NN1kIRMV0iBHssbTeLy0GeLN6T+HbwUWTXmSqq2QF+KlslO 3atkYZ1INiptMjefkDosfUZU5NsyF/Unt/fREUWT857m/4W8pWnN+MrfIVTago9AjxLkElbYRHi3M PQcB/g3JmDGPqHV14rcy2pBNPvWok2yqjt6PQ2GQyBlLsqrD1CzCwv5ClnoXN6QS6+qyRfG0SOWKt DAUkQGTHhHzr/xH2cRxl0Ksi2rsrSbj0ALUAQZ8hYGGuc+JSzYshSw+dEQC3MUo92us+5o8ADkKKT meO7iYAlyRAXyqX2OT8Q==; 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 1hG6dR-0003yt-CS; Mon, 15 Apr 2019 18:47:17 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hG6dO-0003xG-Aw for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2019 18:47:16 +0000 Received: from mail-it1-f200.google.com ([209.85.166.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hG6dI-0007ai-O9 for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2019 18:47:08 +0000 Received: by mail-it1-f200.google.com with SMTP id o197so17146365ito.3 for ; Mon, 15 Apr 2019 11:47:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CwmAt3EH34Y8aa4BxBKSJKW5Lju9XsMMY9xIuPusQUg=; b=bWFWy/jO9slyr+1LcutwtxdglKe8u9Jr8yP4EcjvR6CmtWu8stvblbiJYRjA22j/1X C1wONKccbSRqLlwPhgP4F2PoAlrZWwmMEYVs7azPEkzVO6fk0hERLtam+v4r0D5aDo2h Ba/izzg/vY4XxexnRtYjVUx8B2WfQZP9cyzvjDFjMi0IeCYovcxAzkJ096gKzzW0p2xl SiNKtgXbeg1tCKXKGo8ccFFaTRFBn1fyijw6/klFB4EKKpk+Hrj/JoydSmUFUCzswqLa 6DTaSr+BYTADVxPfBhmDtoPBgfq/JEsD5jIyF+c5y3uJsrig51z7CNnvTIPVJeGaiy6/ e9tw== X-Gm-Message-State: APjAAAVLvKBR6LRvhTg2h4s+jr/aUgu4dFvMX/KC3lpjjRWceFjsOPJJ Dwhz/vtHvioCdx3oV94ssh9IhIvkwSVegySVlnSgwMSurFOjGCtDOxUBKjzRbpy/Ousztp9BF9E mshVpiBzMP/ve7K+4HiFS8QnEu8iFbVEUnHIwaHBuFyZkidN6P/DS X-Received: by 2002:a24:7388:: with SMTP id y130mr27321684itb.85.1555354027461; Mon, 15 Apr 2019 11:47:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWDWNYCmO/V9u/kLU9R+zjdnyCCtj2Z1lELjaY56NxKGfNvojBOcSPwgIwSp6MyMF9209/Qw== X-Received: by 2002:a24:7388:: with SMTP id y130mr27321661itb.85.1555354027104; Mon, 15 Apr 2019 11:47:07 -0700 (PDT) Received: from xps13.canonical.com (c-71-56-235-36.hsd1.co.comcast.net. [71.56.235.36]) by smtp.gmail.com with ESMTPSA id z13sm18304149ioj.21.2019.04.15.11.47.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2019 11:47:06 -0700 (PDT) Date: Mon, 15 Apr 2019 12:47:05 -0600 From: dann frazier To: Ard Biesheuvel Subject: Re: [PATCH] arm64/module: ftrace: deal with place relative nature of PLTs Message-ID: <20190415184705.GA21567@xps13.dannf> 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.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190415_114714_519701_95F1F7FB X-CRM114-Status: GOOD ( 21.79 ) 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, catalin.marinas@arm.com, duwe@lst.de, will.deacon@arm.com, 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. This fixes an issue I was seeing on a HiSilicon D06 server: https://bugs.launchpad.net/bugs/1822871 > Signed-off-by: Ard Biesheuvel Tested-by: dann frazier -dann > --- > 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; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel