Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp255567pxf; Thu, 25 Mar 2021 03:25:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8jx7q9g3otl0o8j8kZQH3ieBZnhbW1PlCYcEeBT+za8Wh2W5QelveQcRFCGcIx862bznP X-Received: by 2002:a17:906:b316:: with SMTP id n22mr8310637ejz.249.1616667941801; Thu, 25 Mar 2021 03:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616667941; cv=none; d=google.com; s=arc-20160816; b=V7Nl6OaFuCiofIPYkDyK4Q3krk8UATZWoTNnpk6RcX0mnke9NVLxRZLjFUO0J/vYE4 AO4Hvl7gyURzjSaVelrCHZ3jgLjIwnl1uoWKekUIc7NsoDddBKmIgylAVPxvEWsS5GQx S/7r7sexEtkVeR5YlcHGBkZa3pgt9PRQPFez+3v5F45rTSHM921FqoP5BEZOUecVytvS edKDbSzuxmrlymORX1d15ccit6NG6ebodLf/StCpY6rkPDLzcMgqyd5ORY0oNT/1v23V iz20cLXBewSgdsJAqSoQ6H8TDYATcNRI8nCgQ1ph+QZNvButjtB2GxaorHt68vOko8yZ yzUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=eyKupZRmo+LqHi0hHq6izwKGerR+M2fD68Qsv2XpNk8=; b=Z/lRHGJwFR1VDm/3bzBBCcyh0cOaOnd6+rhmaMA4Jtctugu8siBlZNtpHVWEPSGvOW 4gQq0DS4oeVOpQnlVVaFhY5/BJtApEurYb0ImI2rhUEiWMog+2DvH5YJtBU7Dq7wQKf/ lyKShx7LsQ+3iLngTGM3hpgQRtZThpNN/bAXYnTGmy513itity3l+38mXAZvpOpk7Vr/ HE/rvQRd7gYOP4K/Ba/nUkR0TTHx5YX+qiZp+eZ1gtJ4hCIKbpaUAt7Xt41igISewAi5 qrOfDXlZIKag7bV9V7sdjqpXPmZ4GhdyYX+8hwy9qm8fJ3i1lV+/HXiHnE8Yuhu4fwtj JjdA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si3778284edw.371.2021.03.25.03.25.18; Thu, 25 Mar 2021 03:25:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230167AbhCYKYO (ORCPT + 99 others); Thu, 25 Mar 2021 06:24:14 -0400 Received: from foss.arm.com ([217.140.110.172]:45976 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbhCYKXv (ORCPT ); Thu, 25 Mar 2021 06:23:51 -0400 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210323203946.2159693-12-samitolvanen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 >