From patchwork Thu Mar 18 17:11:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 12148757 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 3E2CDC433DB for ; Thu, 18 Mar 2021 17:15:35 +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 95EF764EF2 for ; Thu, 18 Mar 2021 17:15:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95EF764EF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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:Cc:To:From:Subject:References:Mime-Version: Message-Id:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/bV771e6LeM77URAN8n0w7XYbbaougbXQdMz7qrZtlo=; b=LHgk9L+tANVaVg pPrgVyvystKNoTZka3Z57KyVPP0fqS8KCYIypOelMQq9jDredmdaDDx5bYyzqd0mVRDDzskY/mgyH zyehVWtsSDIlNzR+ShD0U0uZ4pIH51mRf1yfN0wG8DKuXnW5nyemcSmw0SoeEcIwxyUu5cjF3tFw6 MbgTW3RAe1eIMZuHBG/cCLPVJbIzdb4Ehzg94MevVAGbZ/7uJZEhGhPIwClnll45x/+yep0X2yLgf 8KMAdA1kZOZgC9M1BoCaw6EBQ/op49Y8u+h+b5/cOHHefgPjL3+9S3ZyhXSigbkz8x+fJ9GODG5PL 6cRsvA9DPCibJLHQ7LcA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMwDh-005goZ-6c; Thu, 18 Mar 2021 17:14:01 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMwBR-005fon-PX for linux-arm-kernel@lists.infradead.org; Thu, 18 Mar 2021 17:11:44 +0000 Received: by mail-pg1-x549.google.com with SMTP id e4so22993057pgt.17 for ; Thu, 18 Mar 2021 10:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=bxVrKYuxs5XU9fnnKC3lGs6PXwAVYnFmVHHh5prD+bw=; b=OQNEk3oOQ5hAytzarvFWWb63NfdPj+7PTKDlFTBcFLAUjEi2vCHNZnRQJ3JbBhmokW 7ygxqd9DvZZ+lHCZ2pGj3ZIL4B9bNb7BUkvcBJ/5vdPDvwSmaPRpk5kEx1pnn0fyhAGH V9yx9+Kvg6PMJmO7Vmd8ACDeVgvkNvq+CcQdwoqXDE4O2M0XZ+VWAInjgXiw4J+4web9 fWA+eQ8WVG97seli+TR+7Mx+62ki2Wn5MgzOGHqutKgMBINZEbFIcmHf0xZRCWdLhZsG MaaWJprhgnZ6mFcd0vrxtW9J8nLBK5CoUHFNoYcbdMOvzP7gePSn478jGBtjUgIu7qQz iy0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bxVrKYuxs5XU9fnnKC3lGs6PXwAVYnFmVHHh5prD+bw=; b=RmUakAydAGIGPuAPrs88+GBXQiSK9dvUkkXZRqs/0dM9GRU5XeSZl0xqySPmZzntxF BBCWr2St/Etuc+B1qsE0WmSexbXmn7XIrp/N689m5mpSn/fI9sAKBF/mTpznYbr+IzjQ VNLdIImFksM9ZVvmn5hUKK4zBvZrLJA2SidBC8S59LOdSX9PT0zFJEdsFS35jBpVDmiW 267pSmxooiyLqD3mQqJ6bSxfneqVQKvA14mPcFUuCEdcWtoDVQTL0dlSJ+sMGN+QZgDT yUNpSQJyfYxoC+2/SLlsHcZIaaghzhE2wNvqKWj/IpOn18i+gbKWZFPdCWKMhxvgjZda Q88g== X-Gm-Message-State: AOAM530bgtBdbVfKtRPB5ZwfmLrteGF8azizvqSWjBOIFzb+ZyQIgpYP /mgpkzp8TrGUKGvtBBQgb9Dwhmj/epZeELTXbWM= X-Google-Smtp-Source: ABdhPJxma7BoDEiA/35m54+pGSjy4Tq7Hy9BCEYhhH2pKkqkJ0kEBJy7AZ/Jez7IPPcm8dV8ucPCoNJ/LJla6dBOgeQ= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:c0d7:a7ba:fb41:a35a]) (user=samitolvanen job=sendgmr) by 2002:a62:1c8f:0:b029:209:7eb2:748f with SMTP id c137-20020a621c8f0000b02902097eb2748fmr5107163pfc.79.1616087499516; Thu, 18 Mar 2021 10:11:39 -0700 (PDT) Date: Thu, 18 Mar 2021 10:11:05 -0700 In-Reply-To: <20210318171111.706303-1-samitolvanen@google.com> Message-Id: <20210318171111.706303-12-samitolvanen@google.com> Mime-Version: 1.0 References: <20210318171111.706303-1-samitolvanen@google.com> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH v2 11/17] psci: use __pa_function for cpu_resume From: Sami Tolvanen To: Kees Cook Cc: Nathan Chancellor , Nick Desaulniers , Masahiro Yamada , Will Deacon , Jessica Yu , Arnd Bergmann , Tejun Heo , "Paul E. McKenney" , Christoph Hellwig , 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, Sami Tolvanen X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210318_171141_928073_3A0D407C X-CRM114-Status: GOOD ( 12.68 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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)); } 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)