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=-13.8 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 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 09CC6C433B4 for ; Tue, 6 Apr 2021 11:30:30 +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 93EEB6124C for ; Tue, 6 Apr 2021 11:30:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93EEB6124C 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=WdNfFnDMlGRxHR3n2MnG+8T/jlWGzqmPtnMqr+Mao1s=; b=IENRwJ1I5TC0fyldQOkLas5P6 ymMylXbVVuSmQq9CGexcQz/iRv+PoSOn5ZCcluuJKj6THL8ZQJ2heZK+Dw90e93smOfxpGBniHb1n PllynuNT2zlYf4UiFEozfPkRmOoiiRhRghUs0JeaIcgb4RYw1c2SFuvVG8Tz7Dc1RJPF2K8EknQw5 1sfQiWjiQ5J5L9zLNECYTW+VaXPRaeLno44kD2UPvcDIuClTgSVb7JtY1sPd+Hcq2H76RggA4Bvql Mj+S/Sy33RT6N+8MACEAAWPXX+/mvpDrQOScICi6QURn230YG6gT8iAatuDLELMiFXJF40LNw+5GA ruggaqkVg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTjs5-002JgD-N6; Tue, 06 Apr 2021 11:27:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTjs1-002JfL-8I for linux-arm-kernel@lists.infradead.org; Tue, 06 Apr 2021 11:27:47 +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 5792DED1; Tue, 6 Apr 2021 04:27:42 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CC5943F73D; Tue, 6 Apr 2021 04:27:37 -0700 (PDT) Date: Tue, 6 Apr 2021 12:27:35 +0100 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 , Sedat Dilek , Catalin Marinas , 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, clang-built-linux@googlegroups.com Subject: Re: [PATCH v5 11/18] psci: use function_nocfi for cpu_resume Message-ID: <20210406112735.GB96480@C02TD0UTHF1T.local> References: <20210401233216.2540591-1-samitolvanen@google.com> <20210401233216.2540591-12-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210401233216.2540591-12-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210406_122745_655319_A74FC00D X-CRM114-Status: GOOD ( 18.18 ) 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 Thu, Apr 01, 2021 at 04:32:09PM -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 function_nocfi to get the actual address of > cpu_resume. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Kees Cook Acked-by: Mark Rutland Mark. > --- > drivers/firmware/psci/psci.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > index f5fc429cae3f..64344e84bd63 100644 > --- a/drivers/firmware/psci/psci.c > +++ b/drivers/firmware/psci/psci.c > @@ -325,8 +325,9 @@ static int __init psci_features(u32 psci_func_id) > static int psci_suspend_finisher(unsigned long state) > { > u32 power_state = state; > + phys_addr_t pa_cpu_resume = __pa_symbol(function_nocfi(cpu_resume)); > > - return psci_ops.cpu_suspend(power_state, __pa_symbol(cpu_resume)); > + return psci_ops.cpu_suspend(power_state, pa_cpu_resume); > } > > int psci_cpu_suspend_enter(u32 state) > @@ -344,8 +345,10 @@ int psci_cpu_suspend_enter(u32 state) > > static int psci_system_suspend(unsigned long unused) > { > + phys_addr_t pa_cpu_resume = __pa_symbol(function_nocfi(cpu_resume)); > + > return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND), > - __pa_symbol(cpu_resume), 0, 0); > + pa_cpu_resume, 0, 0); > } > > static int psci_system_suspend_enter(suspend_state_t state) > -- > 2.31.0.208.g409f899ff0-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel