Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4558393pxf; Tue, 23 Mar 2021 13:42:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhoIoq0PlyA+7zssPz/kLhVW4cDlNzxwaB9aNm2b2rinf5kadiTPe94Bd+Dxs2NK0gQRMS X-Received: by 2002:a17:906:d797:: with SMTP id pj23mr30651ejb.367.1616532122465; Tue, 23 Mar 2021 13:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616532122; cv=none; d=google.com; s=arc-20160816; b=BqZ+cfhF9GyZN9SNyB+JGBhg3IJzXIuVghpPiC9WB911Mi0FxKI2qARPVAg1bSFj9Z dbph35XnDKQsJdmQKc1kQ73yxePe8Hm1lJzKcjGpBYKHyo7vE2yqRZQW+sN4oFarYq7/ D1MloNe797GZygy/0YnyFLpMieQhYp7/p2K9ubNSHRhUBI1qosUWY/jxd54H7RchtuAK 6z/9rMxLq8UL6EjEOd5FGHf8LLXepXNU74IHpWvwSVtrlyRQLjSOYCAAmikWb15hZmnp wz//83y3kUAVO+Rrf4q22byYXoMAIpBqajlDalki+wnalqH5tbgRsVZG4GMiXNVHx3uj WeCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=bxVrKYuxs5XU9fnnKC3lGs6PXwAVYnFmVHHh5prD+bw=; b=RWoDoykJsy/o+9EcVOICOfNu9td11BNY6bOI6VBfk7scjFVdI+LEWewpGgjNBm60du 7tLrkcNRy1gIb2sjiTmLjGYGJYg7S1VjWnx8ZhK6yqKXaWjDQ0waQSMxhlgipsc3CN5H X2JBiBvLZZCHm8riQJh3enJhUrh6M/oGusCOTFl+2qaa5ZSa91azynvgdTSYfVHBqf9q nOkzz1X6C8FUa6HVcZEWsg9kt+xQur9vZEd7Cx8doz3I3K7heo4iibdpCrWRWgQ6m1l3 Fjb3w8AQftMyaMhmpiPUMr1Y2iEUyATmLjx8ZIYwWH5pKrXrs31Woa6UizhzNLQ5zZ5F TjQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tT+mhGxc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x14si78900edr.255.2021.03.23.13.41.39; Tue, 23 Mar 2021 13:42:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tT+mhGxc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233705AbhCWUlB (ORCPT + 99 others); Tue, 23 Mar 2021 16:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233520AbhCWUkK (ORCPT ); Tue, 23 Mar 2021 16:40:10 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5C7DC0613DE for ; Tue, 23 Mar 2021 13:40:09 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id t18so1968528qtw.15 for ; Tue, 23 Mar 2021 13:40:09 -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=tT+mhGxcn72LL+S/wxj6p6pgongKWrRuo4s35bHXpLA2dicqXg5urUYbPt3d9T/ByR IPHjRKTiXQnv2rbt1aRKlxrdR2rPLJ7tORytyy1drMdPlsn4xgMEb2VaXi9KnmRXw0b+ 1McGQM2Thg4csg/H4j9okV5jZZhUrLRSHuFW27uwZsHK3LpCc5+cy7/TMp0EDcRjnuha JF7+v1vVLu+/0lrJCTHtkCwIx8QFpif22GcIKNGwCbR4j/Je8b9blw7GwduI3m2NOHlM YfgJo/D20uuFbhQvjr6gzbOj6Nv05LUXHIHdnyfSlGGvEfwFsp60pVuwWb09eTm3iH6Q VSag== 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=HY+DLSHqU9uh0zTxcTu1KaPQUXgArLc+58bc7SjJMRGkAgn1vl9kVApqTS+Za94p8B oxTojuJ6LfPFbPg/WZwLJsbRoirh42QlA00ZvtuYUPXooqE6nn2AaC1XKzxIY2NY4Gzk tjZ2/2jeYf+fTZudECJq6WWisuIdU9VemiHSMn+Tc5MAwrP7ExbXAwBcZmVmg9TKbMvV f8WuxNE71HXhjzNo6GzB3d75dwInYBAUFjXT+D/VfHlpz3eRll2/kLyYdyYd8jXa28W4 uvJIXKAgA0ScmnrZ7M7iNThjuecnijETG1a02UgMonbkmnQxZp7pQ/ixMTrxTK9ISDOr Gvwg== X-Gm-Message-State: AOAM531KbnUIDJz6tHh2STt3UO9kSei9HT/RDqlA+JDD8zGYatf54xrg OhsYHzueuFywoM13O0NhoTJ8IDfnNj3Kg7YKM9U= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:e9a3:260d:763b:67dc]) (user=samitolvanen job=sendgmr) by 2002:a05:6214:aae:: with SMTP id ew14mr188842qvb.24.1616532008942; Tue, 23 Mar 2021 13:40:08 -0700 (PDT) Date: Tue, 23 Mar 2021 13:39:40 -0700 In-Reply-To: <20210323203946.2159693-1-samitolvanen@google.com> Message-Id: <20210323203946.2159693-12-samitolvanen@google.com> Mime-Version: 1.0 References: <20210323203946.2159693-1-samitolvanen@google.com> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH v3 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 , 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, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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) -- 2.31.0.291.g576ba9dcdaf-goog