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=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 F079CC433DB for ; Thu, 25 Mar 2021 10:28:07 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 6E18661A2C for ; Thu, 25 Mar 2021 10:28:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E18661A2C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc: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=xh58yk0QZuZMtsl4jowm2CXNmHVEsYxKjl0EqUZb2LE=; b=D2swqCJ7PYPTHZxZdzIJ21vo3 WfVixrgtohjJ0wBa5/lJRqPZ8taFL4tj8fK/01k3bSc3KeUcKZZJadWlgNLQR1vatO1rx+Ij95kZo 8+Yra7iAKU0muDKw4OMwyVxs2yTxn6PredUbyOc1nUY5pmJ3ne1dFuzEXO1ZYErtf4Xvi0iegZHkz SBCtNgTfzMxJ+5yprFzNRu1fVCYfH1jloGN8sanQs3j/lbSnqMKGFKFHgj9/Bdg/7kTkGR7fha1rk nY+YOHB4+Cz1CD1tpb2iwucySbSV2TaWi0CYBY4vfCafa1q3Xn4iEfeh0vEh0MRdSMoiYHgQm/pSv WR5ChZ3MQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lPNA4-001CrT-FU; Thu, 25 Mar 2021 10:24:20 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lPN9d-001Coy-9N for linux-arm-kernel@lists.infradead.org; Thu, 25 Mar 2021 10:23:59 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DB4BD13D5; Thu, 25 Mar 2021 03:23:50 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF2603F718; Thu, 25 Mar 2021 03:23:46 -0700 (PDT) Date: Thu, 25 Mar 2021 10:23:43 +0000 From: Mark Rutland To: Sami Tolvanen Cc: Kees Cook , Nathan Chancellor , Nick Desaulniers , Masahiro Yamada , Will Deacon , Jessica Yu , Arnd Bergmann , Tejun Heo , "Paul E. McKenney" , Christoph Hellwig , Peter Zijlstra , bpf@vger.kernel.org, linux-hardening@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 11/17] psci: use __pa_function for cpu_resume Message-ID: <20210325102343.GC36570@C02TD0UTHF1T.local> References: <20210323203946.2159693-1-samitolvanen@google.com> <20210323203946.2159693-12-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210323203946.2159693-12-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210325_102357_285271_7D050BBD X-CRM114-Status: GOOD ( 21.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Tue, Mar 23, 2021 at 01:39:40PM -0700, Sami Tolvanen wrote: > With CONFIG_CFI_CLANG, the compiler replaces function pointers with > jump table addresses, which results in __pa_symbol returning the > physical address of the jump table entry. As the jump table contains > an immediate jump to an EL1 virtual address, this typically won't > work as intended. Use __pa_function instead to get the address to > cpu_resume. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Kees Cook > --- > drivers/firmware/psci/psci.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > index f5fc429cae3f..facd3cce3244 100644 > --- a/drivers/firmware/psci/psci.c > +++ b/drivers/firmware/psci/psci.c > @@ -326,7 +326,7 @@ static int psci_suspend_finisher(unsigned long state) > { > u32 power_state = state; > > - return psci_ops.cpu_suspend(power_state, __pa_symbol(cpu_resume)); > + return psci_ops.cpu_suspend(power_state, __pa_function(cpu_resume)); As mentioned on the patch adding __pa_function(), I'd prefer to keep the whatever->phys conversion separate from the CFI removal, since we have a number of distinct virtual address ranges with differing conversions to phys, and I don't think it's clear that __pa_function() only works for kernel symbols (rather than module addresses, linear map addresses, etc). Other than that, I'm happy in principle with wrapping this. I suspect that for clarity we should add an intermediate variable, e.g. | phys_addr_t pa_cpu_resume = pa_symbol(function_nocfi(cpu_resume)); | return psci_ops.cpu_suspend(power_state, pa_cpu_resume) Thanks, Mark. > } > > int psci_cpu_suspend_enter(u32 state) > @@ -345,7 +345,7 @@ int psci_cpu_suspend_enter(u32 state) > static int psci_system_suspend(unsigned long unused) > { > return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND), > - __pa_symbol(cpu_resume), 0, 0); > + __pa_function(cpu_resume), 0, 0); > } > > static int psci_system_suspend_enter(suspend_state_t state) > -- > 2.31.0.291.g576ba9dcdaf-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel