From patchwork Sun Feb 25 20:08:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13571022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33D28C54E41 for ; Sun, 25 Feb 2024 20:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YcWCiYSXPZCTR02DodhnH7fKzLrIrk13DlFtZ6SnJV4=; b=V3YD0CmYxG8T+M Az499l72j400ehMZw+jqUgnanBN7InzXxmu9cPH9NSaoQDw4j6dNcyt88GQ9ftXwUf/TCCbfPS2FL 3328V+JaPik3tBpd5Qd08+m5pspfypjjehHXqww1BxYXrgYbt+vo36Tff//M+Ro52eyi8JqMHyIut 3WansqYz9/txTx+h5GfuIeUT+ffWojzLq9kbUrUSFlCDK4UW+A4GqHEy5yiuoDZQdPncbQ6CxS0vL huwOe/EyR8YJl/jw2iT/yDr9kQdHyvVhSgzzuQnYI7jCJWrx4woGOVCii763Lh3Ed33EunYY2Ghk1 F2xNEpXQZapqyKLclPuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnK-0000000Fcl0-0nYQ; Sun, 25 Feb 2024 20:08:18 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnH-0000000FcjD-30ZP for linux-arm-kernel@lists.infradead.org; Sun, 25 Feb 2024 20:08:17 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a3e72ec566aso298359066b.2 for ; Sun, 25 Feb 2024 12:08:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708891693; x=1709496493; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vaHsL9uZaLpUW/gtSno6U8/q3nfzw7ffg7lr4P7gXB0=; b=bHGg96QGGLzk9FjFjGK59ofijThQzxYEI0xB/5EH57d2NuoIo2ZBvOeUsamXxs6qcu /9oxoo5eh1QcfY9x8xSwHtXKCl/Z7Re4Bc3xryjuase1by2X3iqsMKIjKAqhCYo2yX33 CV9pwdpRHTz77DIbEGe8vf5RkVmn44yUL8Q+wwFgIl2ImcgapXCnlyGzz+OisN52MRIz I6uKN0C78OcVi3e6FIoy7SfL1eC89IcGhRfCFc0+zBh2sYoiYgQ93PvMFKbUN0iJ3Usb iWky+fKSqhmrvk/ZtzTfJy8/IqKvBhVUdpemynosq785hMP1wb9GctJYfiF0/fKg49FR HjGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708891693; x=1709496493; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vaHsL9uZaLpUW/gtSno6U8/q3nfzw7ffg7lr4P7gXB0=; b=MllejWcd1J57VUvLBp+yDHlzJA7SgFkcJ3Zt+2n5+XBjlvY3iuWaYkfILXGY9c8b2+ C7nel5/KSQuhOY6+LrM2+y5X32w48E9Qs7akE+Z6cmErdM5AWS7LJV23aDNyy6xcXXPN 2l0GSP63G7AQGrAhisjFpqviBKyhkmIkgTgJScewY49m4exQYwRTty4+M/wYN5LWC4wO 0BtFtzsYwMssg7ztIAaEkbemrRm+a2ORipuD/GRgj3R1vlOVY3Dbv9MGa5ECHAVHw1QT lF0VsXYgAMkjWLW4yHsTCO9QDVy4DehmqvEnwVxj1Nvo1pXjSUjS7dfbdAvOnXkhR1AA e2oQ== X-Gm-Message-State: AOJu0Yz1y1KHyo4yqWssW9z+3kY35Puj1OPXd6b3bUpYTqJT0NlgvuC8 H8iG7S7E3hi/pvsl0iT2FjRYzkqEl5aGXDqkHRFA2V1OQkRYyg1Gp5ru0Pbd4hA= X-Google-Smtp-Source: AGHT+IGw6bV8g5dpeZCGmITdjJ+P4PQpu5m8y9ThBv8s80WquXr+nyJrO4fnc+MLmGg387rv6mLOGA== X-Received: by 2002:a17:906:a44d:b0:a3d:9a28:52e6 with SMTP id cb13-20020a170906a44d00b00a3d9a2852e6mr3284540ejb.50.1708891692758; Sun, 25 Feb 2024 12:08:12 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id hu14-20020a170907a08e00b00a4340138ab5sm504621ejc.5.2024.02.25.12.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:08:12 -0800 (PST) From: Linus Walleij Date: Sun, 25 Feb 2024 21:08:10 +0100 Subject: [PATCH 1/7] ARM: Support CLANG CFI MIME-Version: 1.0 Message-Id: <20240225-arm32-cfi-v1-1-6943306f065b@linaro.org> References: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> In-Reply-To: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_120815_793673_4DF285E6 X-CRM114-Status: GOOD ( 11.11 ) 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 Support Control Flow Integrity (CFI) when compiling with CLANG. In the as-of-writing LLVM CLANG implementation (v17) the 32-bit ARM platform is supported by the generic CFI implementation, which isn't tailored specifically for ARM32 but works well enough to enable the feature. Signed-off-by: Linus Walleij --- arch/arm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 0af6709570d1..1216656a40bc 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -34,6 +34,7 @@ config ARM select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7 select ARCH_SUPPORTS_ATOMIC_RMW + select ARCH_SUPPORTS_CFI_CLANG select ARCH_SUPPORTS_HUGETLBFS if ARM_LPAE select ARCH_SUPPORTS_PER_VMA_LOCK select ARCH_USE_BUILTIN_BSWAP From patchwork Sun Feb 25 20:08:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13571024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9AB5C47DD9 for ; Sun, 25 Feb 2024 20:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0SQjousCDXDkxOlBJ2ocfnM1o3srohN6EuFvnzEeHog=; b=L5qoXcNINrUQmv HLal3xsw7A5BHIxjY1pVLAIoRK06cBBnMkuCMBOOva4LuS8zESa90uOhzA4ie5vWIKKmakD/3V9MD g8m835Tvk7F0I4OvxC4zyABPm+FZFvwOVdnOBKkLsi4/wY/dYvaPJAeh5m9LvT3SV0AvLVZs56OpF b2lOnosZ/egQDSal4YJg+b9dquxk8WtxlYVO0CXoO/LXrXqGaCYcz2m+bEijJu4DAttdB/Xg8uvT7 CyfDYlosCmZIHrAONVEzmN3/FJH636bqLtnCCyt2XMojEinFzPoAaZrUdKxKuol9RFl0uqT3WQvsy JwR3MJGJ0IMUEtRqY4mQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnc-0000000Fcpx-0RKf; Sun, 25 Feb 2024 20:08:36 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnI-0000000FcjP-2sfS for linux-arm-kernel@lists.infradead.org; Sun, 25 Feb 2024 20:08:18 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a3e7f7b3d95so274252866b.3 for ; Sun, 25 Feb 2024 12:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708891694; x=1709496494; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=x8Pxmb+SJtaf6Rq8IgIflwtKkppPo4bfFWLJbSoBsFk=; b=dgqZvqtEkEnm6JHeGB6xteYe7pWwhs0huHSX2aHmsIl4nLMjyGXTfnlsIcOHiLYato tqVizPpwTGIzNAxzDPWy9ZCYAgQVpn1GVf7YaLxYOxweSRt9SwHFMX6MOWLpCSVF2/cd o65fsXmvSzlIrbLMbtxcsigNZ8onQ/R2iGUvHzUHuaiA1znrZBHorjh5RJB1erBjHPKH 1demXGXUJ6E9G40E6eQBg7qONNCmvZ34FPkyMadKowEZGnwnyCkZTj8jcI2ceF8aXTba JD+r/TZScAvJH04x52+1YHxEgKyR7gRWQckKuxc2fWt8dUMgvir1CbBlZkeNec/0bFXA Jv8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708891694; x=1709496494; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x8Pxmb+SJtaf6Rq8IgIflwtKkppPo4bfFWLJbSoBsFk=; b=mxg2sVFFJUFsaSFuTM+bm5d5qmxO5Aj67yvxIYZkel5aGtqETS1xQka3tS+uFBkB8c E1YJjslaUzfeakJ/O5p9FVu/g9xGltCOH8p+h1+Emx6bpqA4NpVE3pMrMJIscuffQ3/A Sb2vevb4PwoometmVNbfiFUbYiESZ7An5zOzvmFaL6LT8/UO/LDx/WEhSlNLgNP7/gZk vKb2+J7d6QxEayzcp3KixWhWWQ+2xCnWvU+gboTjtYhWbiLCvLcOSChj72D7c7rD1gZC 8ywCNwxPkn5WAYkQ+stOL6s2syl5/o6UXCrEAX55l9BPGGJ7XsSs8CZVYh0g95hmgfpK t11Q== X-Gm-Message-State: AOJu0YwOkSK6/pgwCzsCsSHwY7J8uijgpUoHBLqeJwoHty21+ut+3KwE tVD1wTKALdEah9NNXqJANd3+hxLRx4uT2fqNrR7EqlqslycZL23MYIGGMCE4Z/o= X-Google-Smtp-Source: AGHT+IF9H5P6JRdDN+PJTJcjkkqLAA9eKjemJxWKrfZTcfu2fwQ6Fg4JGDKRQi0oSxCd/8pdja2YVg== X-Received: by 2002:a17:906:13d2:b0:a43:1ee2:4345 with SMTP id g18-20020a17090613d200b00a431ee24345mr1634442ejc.75.1708891693861; Sun, 25 Feb 2024 12:08:13 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id hu14-20020a170907a08e00b00a4340138ab5sm504621ejc.5.2024.02.25.12.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:08:13 -0800 (PST) From: Linus Walleij Date: Sun, 25 Feb 2024 21:08:11 +0100 Subject: [PATCH 2/7] ARM: tlbflush: Make TLB flushes into static inlines MIME-Version: 1.0 Message-Id: <20240225-arm32-cfi-v1-2-6943306f065b@linaro.org> References: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> In-Reply-To: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_120816_763441_6A58E3DA X-CRM114-Status: GOOD ( 12.82 ) 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 Instead of just using defines to define the TLB flush functions, use static inlines. This has the upside that we can tag those as __nocfi so we can execute a CFI-enabled kernel. Move the variables around a bit so the functions can find their global variable cpu_tlb. Signed-off-by: Linus Walleij --- arch/arm/include/asm/tlbflush.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h index 38c6e4a2a0b6..7340518ee0e9 100644 --- a/arch/arm/include/asm/tlbflush.h +++ b/arch/arm/include/asm/tlbflush.h @@ -210,13 +210,23 @@ struct cpu_tlb_fns { unsigned long tlb_flags; }; +extern struct cpu_tlb_fns cpu_tlb; + +#define __cpu_tlb_flags cpu_tlb.tlb_flags + /* * Select the calling method */ #ifdef MULTI_TLB -#define __cpu_flush_user_tlb_range cpu_tlb.flush_user_range -#define __cpu_flush_kern_tlb_range cpu_tlb.flush_kern_range +static inline void __nocfi __cpu_flush_user_tlb_range(unsigned long s, unsigned long e, struct vm_area_struct *vma) +{ + cpu_tlb.flush_user_range(s, e, vma); +} +static inline void __nocfi __cpu_flush_kern_tlb_range(unsigned long s, unsigned long e) +{ + cpu_tlb.flush_kern_range(s, e); +} #else @@ -228,10 +238,6 @@ extern void __cpu_flush_kern_tlb_range(unsigned long, unsigned long); #endif -extern struct cpu_tlb_fns cpu_tlb; - -#define __cpu_tlb_flags cpu_tlb.tlb_flags - /* * TLB Management * ============== From patchwork Sun Feb 25 20:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13571025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34456C54E41 for ; Sun, 25 Feb 2024 20:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l3jz1S/MUSlE2CzazwdkxUsAg5LqjXJL8ESRjmegLhA=; b=Jih82HdhprEwo0 vwsoWv93qqH7W8891nkXXWi34aKcoIvhbOMpraYh8u+yxl5wuiV3iOPjrquFCM+4KUHEwfZ/UFcRa GcQ21ewscFuBmof+lflaonbVyOHD+Rtf5TYZG8KVHPwIURLcI2cHL7ONcxomDNsbGTYpFOtGcyC+q P2z16foPShSf87II9rWMtkWbOxXvgv/NfVkFdiM70JJeRpnE2HyABe8WIJUGnb31EkpIPHTju+9lT eDAkM8V8vXnnkJ/OSbypKOctAiFbttQyTjR/bhLtNwdS6ZkGG2g0VYzv5m6Bih98vi4JBYzSmWQk2 at3F3Kevvv6R9YaFs00A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnc-0000000FcqK-3LMF; Sun, 25 Feb 2024 20:08:36 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnJ-0000000FcjV-2CRX for linux-arm-kernel@lists.infradead.org; Sun, 25 Feb 2024 20:08:19 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-56533e30887so2354194a12.1 for ; Sun, 25 Feb 2024 12:08:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708891695; x=1709496495; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=B30jBDh8l6oorNFVXLBM1TGNZMOeiKLndpCjpsCjwrU=; b=GC6etEk42mox4r44ey2zFKLjzWVe8OXOh5Lb3Vscy6XHMRYlCs5TJneO+tjesPSN22 vas+zlHEL5JLqV95zVuBaN+97gWI/4BLk7LWrTJ4NPZJCFNyHsEsBiEXFiVt7FXBFBUw XOU5vbEb3i7KqH3EzilgKj6W8zd7UQPnrxejTQiIls62Xq5ggP3dfHfXcQEeRZ21S4sf 0x1646/hvmbilNgUXj7+lWDw9FJ825zHsCnnViQ2/Q6xg+AxmpsLuLxTeNS0Q8B7753B 9MYqpI61pVYJV16B1nQSBBT4SGq86S2xirBwVUck9FhLs2/tgnTdo87+QouW70AguN5V ksqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708891695; x=1709496495; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B30jBDh8l6oorNFVXLBM1TGNZMOeiKLndpCjpsCjwrU=; b=gE53mDuoJQ2g8GD5gq1F+tINYTZnh3JvjPJRZce6sIp+N3NwTjk1lchkdOMai8NC0C TxjSDbN0EFQfgDh+rmpd5VQRLNjXdwBqH9Q+qY+pvHVJMiRCXXA9UdTTAp4pdLLPamVU ziSKjOgRicsfwuFxAXiLIIMr6c0jZQY4Qs9sFLNQuzeHHKS6wWOeXnsjANGsM9Y0Xw6z WBo11ALa7/Wh/colKz3ggLS07gGi5IhTXH408e2WIgk3kxlB2DvLBQgbJkE2yRdiy1LZ Q3QT3GpcQysPv9ohY+1CnwcnQ1xFN1eTl2Qvq84WkfI/vSpvBglXuJv2BwFsYULFCkMA 8ZqQ== X-Gm-Message-State: AOJu0YyvvwiWy+odEy4CdRnVc20v8LIE2mIDiQJbkT0ZkV6B9557hkg6 T7HeJEnsdpjBSCpiR5sM7vbvBOq5xAfQdUyhlXmzI+QybuAtGLQjbpWbBKPqcKE= X-Google-Smtp-Source: AGHT+IG2qoyuh4S+jfoRRx1zENZfd3lkef19UKCSeTtf/j2FkZhkfI+btWJuX2mCaASM5yFXpwUUiw== X-Received: by 2002:a17:906:c00b:b0:a43:292c:7c38 with SMTP id e11-20020a170906c00b00b00a43292c7c38mr1353402ejz.14.1708891694976; Sun, 25 Feb 2024 12:08:14 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id hu14-20020a170907a08e00b00a4340138ab5sm504621ejc.5.2024.02.25.12.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:08:14 -0800 (PST) From: Linus Walleij Date: Sun, 25 Feb 2024 21:08:12 +0100 Subject: [PATCH 3/7] ARM: bugs: Check in the vtable instead of defined aliases MIME-Version: 1.0 Message-Id: <20240225-arm32-cfi-v1-3-6943306f065b@linaro.org> References: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> In-Reply-To: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_120817_602027_E914F9B7 X-CRM114-Status: GOOD ( 18.72 ) 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 Instead of checking if cpu_check_bugs() exist, check for this callback directly in the CPU vtable: this is better because the function is just a define to the vtable entry and this is why the code works. But we want to be able to specify a proper function for cpu_check_bugs() so look into the vtable instead. In bugs.c assign PROC_VTABLE(switch_mm) instead of assigning cpu_do_switch_mm where again this is just a define into the vtable: this makes it possible to make cpu_do_switch_mm() into a real function. Signed-off-by: Linus Walleij --- arch/arm/kernel/bugs.c | 2 +- arch/arm/mm/proc-v7-bugs.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/kernel/bugs.c b/arch/arm/kernel/bugs.c index 087bce6ec8e9..35d39efb51ed 100644 --- a/arch/arm/kernel/bugs.c +++ b/arch/arm/kernel/bugs.c @@ -7,7 +7,7 @@ void check_other_bugs(void) { #ifdef MULTI_CPU - if (cpu_check_bugs) + if (PROC_VTABLE(check_bugs)) cpu_check_bugs(); #endif } diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c index 8bc7a2d6d6c7..ea3ee2bd7b56 100644 --- a/arch/arm/mm/proc-v7-bugs.c +++ b/arch/arm/mm/proc-v7-bugs.c @@ -87,14 +87,14 @@ static unsigned int spectre_v2_install_workaround(unsigned int method) case SPECTRE_V2_METHOD_HVC: per_cpu(harden_branch_predictor_fn, cpu) = call_hvc_arch_workaround_1; - cpu_do_switch_mm = cpu_v7_hvc_switch_mm; + PROC_VTABLE(switch_mm) = cpu_v7_hvc_switch_mm; spectre_v2_method = "hypervisor"; break; case SPECTRE_V2_METHOD_SMC: per_cpu(harden_branch_predictor_fn, cpu) = call_smc_arch_workaround_1; - cpu_do_switch_mm = cpu_v7_smc_switch_mm; + PROC_VTABLE(switch_mm) = cpu_v7_smc_switch_mm; spectre_v2_method = "firmware"; break; } From patchwork Sun Feb 25 20:08:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13571026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C316C54E49 for ; Sun, 25 Feb 2024 20:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qxoQ93eM9I+Uwm39oKeoj5M+EBbsilPNKlOXRtRGf1U=; b=cWtG7nOgSymLK4 17C3tz6jy3JrdDz+AxR9ig3Q9l577H0QL28tX5Ah9rKyRo2+z2dT09ulEs41g0yCHa7G+ntPN+xXa ygcvwxMNTnmWdpyrAjwppPXeO+Nf9lLdXsCk+UUI8yl/lcfHG1gIRHmH9m9wmp/pNahkDUp9vG4be UZB0kTBzvZXeHlHvk4Vaozvho+PQFjaPn4WAYcvtZBRuUPhdVPemT82ADLeqJqjfR77g9s+X9viPz QduXwEt90WRQXyk0srlWk96uDCkWoiAsUpTQU8z9QO5aaU/W0vEBmCbHS0Vvb2C1xJ4w7ZS0hdSyJ qtYFP3rkNRpU0hzA3jTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnd-0000000Fcqo-2xCk; Sun, 25 Feb 2024 20:08:37 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnK-0000000FckB-2bN8 for linux-arm-kernel@lists.infradead.org; Sun, 25 Feb 2024 20:08:20 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a3ed9cae56fso369869766b.1 for ; Sun, 25 Feb 2024 12:08:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708891696; x=1709496496; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QC3pcDM1Ey3dTkjBKsVJTDPbi3o492y4kegvDdvubjY=; b=IaJ+bWL5LCykz2burBK9tId9FBY3Qlm/Jqvy9P/9+Sp6KURTSquNGSYbBAYn3gyPuu f9hlP1X1PXST5wNlhSxOba6+Z4Rurbsx3eyCmN26uYeXNBVtAIaPvKWeODRyBQ32wbjw RA+HgLL+LixiX1QfbHNhyyaWwcx5mxqNyD1hrtv+lf3YCEjEWCpeUGLUiVtZDsHyXBsI S2uTIrvzN3dGRDjbQTVTuG0paKCghnBehUDQBZxL/6vFJ+uw69vbpr9KFwu5dUqjKrfF tv9FOtj9Hl7SskhKRYlEtJyBh5hrrPC/iC3gc2cco+oqhmV9AJl00rfP69f0GUlu/iiw 0HSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708891696; x=1709496496; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QC3pcDM1Ey3dTkjBKsVJTDPbi3o492y4kegvDdvubjY=; b=UZmZUGz0cWiZjfiQDhejM55v8b8cUoHGK0EojK3HZ8/3jtj07Zgd5ibaAexvMVimhO GpjLBRHjX9BmanRT7yj+zlRg1824If6tjUaMqKHxySCReoBFtVND2rqkmqD43DhFGDYl 7vKiKqK9YVOuQkJFQDtVVgK3QQ9LO66++Ec3yh3Ql8VIctjjLbIl/Y0RjFEBjaSCXVy7 5Q0EQ/d7Yg11U3z48pH0XP/zLn9+DaCNAvUo+TsVkz0Nw6gsEvKzFcVpwVBVWt+ZxWy/ JGT9r9gkkaiwecwos65Wz9noESWc+Y607q5ok9R0Ct5CqCpZT1TC4gDBlD4l96HCQto+ rmcA== X-Gm-Message-State: AOJu0YwbEZnloyqLpWX6utg3FFlA8GEZWbq+lDwXd536rYRSp3K89nu9 9OoQc0n1xBG313Pq3bcwSJtI0ldKC8dzVqyZj6SRb0ZfKbHyiEtdmRSWAt8C/dw= X-Google-Smtp-Source: AGHT+IFhKSmAMGVKE3e79lh/Twxe14kufH36JgG8EFNdH/4PPIzZ7artQFAubFyeEzB2wpB3+rihOg== X-Received: by 2002:a17:907:208f:b0:a3f:421:26a5 with SMTP id pv15-20020a170907208f00b00a3f042126a5mr4791471ejb.12.1708891696123; Sun, 25 Feb 2024 12:08:16 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id hu14-20020a170907a08e00b00a4340138ab5sm504621ejc.5.2024.02.25.12.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:08:15 -0800 (PST) From: Linus Walleij Date: Sun, 25 Feb 2024 21:08:13 +0100 Subject: [PATCH 4/7] ARM: proc: Use inlines instead of defines MIME-Version: 1.0 Message-Id: <20240225-arm32-cfi-v1-4-6943306f065b@linaro.org> References: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> In-Reply-To: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_120818_810995_24F55D65 X-CRM114-Status: GOOD ( 15.35 ) 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 We currently access the per-cpu vtable with defines such as: define cpu_proc_init PROC_VTABLE(_proc_init) Convert all of these instances to static inlines instead: static inline __nocfi void cpu_proc_init(void) { PROC_VTABLE(_proc_init)(); } This has the upside that we can add the __nocfi tag to the inline function so CFI can skip over this and work, and we can simplify some platform code that was looking into the symbol table to be able to call cpu_reset(), now we can just call it instead. Signed-off-by: Linus Walleij --- arch/arm/common/mcpm_entry.c | 10 ++------ arch/arm/include/asm/proc-fns.h | 57 +++++++++++++++++++++++++++++++++-------- arch/arm/mach-sunxi/mc_smp.c | 7 +---- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c index e013ff1168d3..3e19f246caff 100644 --- a/arch/arm/common/mcpm_entry.c +++ b/arch/arm/common/mcpm_entry.c @@ -234,13 +234,10 @@ int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster) return ret; } -typedef typeof(cpu_reset) phys_reset_t; - void mcpm_cpu_power_down(void) { unsigned int mpidr, cpu, cluster; bool cpu_going_down, last_man; - phys_reset_t phys_reset; mpidr = read_cpuid_mpidr(); cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0); @@ -298,8 +295,7 @@ void mcpm_cpu_power_down(void) * the kernel as if the power_up method just had deasserted reset * on the CPU. */ - phys_reset = (phys_reset_t)(unsigned long)__pa_symbol(cpu_reset); - phys_reset(__pa_symbol(mcpm_entry_point), false); + cpu_reset(__pa_symbol(mcpm_entry_point), false); /* should never get here */ BUG(); @@ -376,7 +372,6 @@ static int __init nocache_trampoline(unsigned long _arg) unsigned int mpidr = read_cpuid_mpidr(); unsigned int cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0); unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1); - phys_reset_t phys_reset; mcpm_set_entry_vector(cpu, cluster, cpu_resume_no_hyp); setup_mm_for_reboot(); @@ -387,8 +382,7 @@ static int __init nocache_trampoline(unsigned long _arg) __mcpm_outbound_leave_critical(cluster, CLUSTER_DOWN); __mcpm_cpu_down(cpu, cluster); - phys_reset = (phys_reset_t)(unsigned long)__pa_symbol(cpu_reset); - phys_reset(__pa_symbol(mcpm_entry_point), false); + cpu_reset(__pa_symbol(mcpm_entry_point), false); BUG(); } diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index 280396483f5d..9bd6bf5f901a 100644 --- a/arch/arm/include/asm/proc-fns.h +++ b/arch/arm/include/asm/proc-fns.h @@ -131,18 +131,55 @@ static inline void init_proc_vtable(const struct processor *p) } #endif -#define cpu_proc_init PROC_VTABLE(_proc_init) -#define cpu_check_bugs PROC_VTABLE(check_bugs) -#define cpu_proc_fin PROC_VTABLE(_proc_fin) -#define cpu_reset PROC_VTABLE(reset) -#define cpu_do_idle PROC_VTABLE(_do_idle) -#define cpu_dcache_clean_area PROC_TABLE(dcache_clean_area) -#define cpu_set_pte_ext PROC_TABLE(set_pte_ext) -#define cpu_do_switch_mm PROC_VTABLE(switch_mm) +static inline void __nocfi cpu_proc_init(void) +{ + PROC_VTABLE(_proc_init)(); +} +static inline void __nocfi cpu_check_bugs(void) +{ + PROC_VTABLE(check_bugs)(); +} +static inline void __nocfi cpu_proc_fin(void) +{ + PROC_VTABLE(_proc_fin)(); +} +static inline void __nocfi cpu_reset(unsigned long addr, bool hvc) +{ + PROC_VTABLE(reset)(addr, hvc); +} +static inline int __nocfi cpu_do_idle(void) +{ + return PROC_VTABLE(_do_idle)(); +} +static inline void __nocfi cpu_dcache_clean_area(void *addr, int size) +{ + PROC_TABLE(dcache_clean_area)(addr, size); +} +#ifdef CONFIG_ARM_LPAE +static inline void __nocfi cpu_set_pte_ext(pte_t *ptep, pte_t pte) +{ + PROC_TABLE(set_pte_ext)(ptep, pte); +} +#else +static inline void __nocfi cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext) +{ + PROC_TABLE(set_pte_ext)(ptep, pte, ext); +} +#endif +static inline void __nocfi cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm) +{ + PROC_VTABLE(switch_mm)(pgd_phys, mm); +} /* These two are private to arch/arm/kernel/suspend.c */ -#define cpu_do_suspend PROC_VTABLE(do_suspend) -#define cpu_do_resume PROC_VTABLE(do_resume) +static inline void __nocfi cpu_do_suspend(void *p) +{ + PROC_VTABLE(do_suspend)(p); +} +static inline void __nocfi cpu_do_resume(void *p) +{ + PROC_VTABLE(do_resume)(p); +} #endif extern void cpu_resume(void); diff --git a/arch/arm/mach-sunxi/mc_smp.c b/arch/arm/mach-sunxi/mc_smp.c index 277f6aa8e6c2..791eabb7d433 100644 --- a/arch/arm/mach-sunxi/mc_smp.c +++ b/arch/arm/mach-sunxi/mc_smp.c @@ -646,17 +646,12 @@ static bool __init sunxi_mc_smp_cpu_table_init(void) * * We need the trampoline code to enable CCI-400 on the first cluster */ -typedef typeof(cpu_reset) phys_reset_t; - static int __init nocache_trampoline(unsigned long __unused) { - phys_reset_t phys_reset; - setup_mm_for_reboot(); sunxi_cluster_cache_disable_without_axi(); - phys_reset = (phys_reset_t)(unsigned long)__pa_symbol(cpu_reset); - phys_reset(__pa_symbol(sunxi_mc_smp_resume), false); + cpu_reset(__pa_symbol(sunxi_mc_smp_resume), false); BUG(); } From patchwork Sun Feb 25 20:08:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13571027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 511CFC47DD9 for ; Sun, 25 Feb 2024 20:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NyjxNT0wCJZdeKr3kg4RyYm6N2Ty38wHzESrLvSEkBY=; b=agv+lpfLKmUtDp YsLkS7CkVzO/1M5mVnr+JJceDhRcxYemlTIwJGGlXfiPlNFBfQAMNtOp1EOww/3hb+GcPoz+okWqO +baGnl5y1J5KcvuzGaQ1JotLgMe+gGiOqdb0eyloocoQmUiLEObcNhANM13KCE6LMDF+UJIw2QCDJ qEcf0C/kQPEAmP7wJaOBH28ff24TJ3SDyjOucXtMaAZGInzJ7FQfsLHDXk/B5zXkcYlGCudYgHL4D jRyYcwxCFSyhMusKPbXMJTsemgdrAYwOJll/g9QST0TWlPtFSyCsuC60/XBV49VuVJIv0Wk0iYiKJ Li05incJfp4xsqGgEDlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKne-0000000Fcra-2zRJ; Sun, 25 Feb 2024 20:08:38 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnL-0000000Fckl-2vda for linux-arm-kernel@lists.infradead.org; Sun, 25 Feb 2024 20:08:21 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a3e6f79e83dso245790266b.2 for ; Sun, 25 Feb 2024 12:08:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708891697; x=1709496497; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0hQVFeBxn1IenYJfJewA7K4YjroRXq1981Lcc541jow=; b=Sj4DDYKAoy2IjEidPtqOnBy994fZpDH6Yt3q4nS9MCKOBCOe0EsV0AGEuqcFGoYplu PeMUA4SdDZNSbkE3/yaLdFszmvt/sjX+omsMhWJIcmp8UGXbk6UdSujAo8N/JcQICi7Z mSHWAHDIG4zXSnPQyqBLEFghC08mCIbN9vGhIWAC70I0NSO03ot6GVhOnWwjJHASBy2I Iy8CQPVSN9dty50tpKaxS8VFkp5jglZoSFWxwARclLokPu7SCNU6f6gYeFRhpjSLeHal yxTJX3yZDquQbLjIcqbbPtw6UBVGlPImtM0ToHuG9xUb7awwHo/KHwh5PvqbLmXeFRsb uIPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708891697; x=1709496497; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0hQVFeBxn1IenYJfJewA7K4YjroRXq1981Lcc541jow=; b=R6zaupIj97cm69zGcmxon7LkudIsZVFhBAwCstV4SnDun3LTZbvNourqCwUZWbcJgr 9v41gUX3xSqCs05cJbcJG1j5gZgwp9y7ORwsldVkv2re51iO8zHy5783PED9TCCgHb+X W3eVaUHV2BXpaxduzzBHwO0mZc0orAZcu2Y9sezH0GO7mnFVK/dzzh/182AMwIfO1T6R cJIJYK6Oyp5dubKBfxsmJeKNbtUgAQ3/oD85S/r5qv90RTLhDhNJH3SfRMuFgwbp6HLO MxH21+MmODkwCvJgsyANxnq/FkBfj1GOhhkqU3t/iCycDOmq4Mu+kyiAHzfn09Qg5biJ oMjw== X-Gm-Message-State: AOJu0Yyn9YNYQKlCQIhu6UPEs9aWRMfr+TqD/eqMgbilRS76YGVzSuzj M8qHhtuGxgTonJucY8YKWmJSE+DyOd4mOgMC2oLe1pLWOcLUqXN5mLeikCiGOKo= X-Google-Smtp-Source: AGHT+IHACgERb6xIUeaYkFa6VntM3WbFza/uQrU+TjVC2bkt/yJGY3XoiECyU8pm8Wl+xgSi9WmMFQ== X-Received: by 2002:a17:906:f155:b0:a43:3f87:b985 with SMTP id gw21-20020a170906f15500b00a433f87b985mr936069ejb.75.1708891697175; Sun, 25 Feb 2024 12:08:17 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id hu14-20020a170907a08e00b00a4340138ab5sm504621ejc.5.2024.02.25.12.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:08:16 -0800 (PST) From: Linus Walleij Date: Sun, 25 Feb 2024 21:08:14 +0100 Subject: [PATCH 5/7] ARM: delay: Turn delay functions into static inlines MIME-Version: 1.0 Message-Id: <20240225-arm32-cfi-v1-5-6943306f065b@linaro.org> References: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> In-Reply-To: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_120819_888304_30F964C6 X-CRM114-Status: GOOD ( 12.52 ) 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 The members of the vector table arm_delay_ops are called directly using defines, but this is really confusing for KCFI. Wrap the calls in static inlines and tag them with __nocfi so things start to work. Without this patch, platforms without a delay timer will not boot (sticks in calibrating loop etc). Signed-off-by: Linus Walleij --- arch/arm/include/asm/delay.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h index 1d069e558d8d..7d611b810b6c 100644 --- a/arch/arm/include/asm/delay.h +++ b/arch/arm/include/asm/delay.h @@ -55,7 +55,10 @@ extern struct arm_delay_ops { unsigned long ticks_per_jiffy; } arm_delay_ops; -#define __delay(n) arm_delay_ops.delay(n) +static inline void __nocfi __delay(unsigned long n) +{ + arm_delay_ops.delay(n); +} /* * This function intentionally does not exist; if you see references to @@ -76,8 +79,15 @@ extern void __bad_udelay(void); * first constant multiplications gets optimized away if the delay is * a constant) */ -#define __udelay(n) arm_delay_ops.udelay(n) -#define __const_udelay(n) arm_delay_ops.const_udelay(n) +static inline void __nocfi __udelay(unsigned long n) +{ + arm_delay_ops.udelay(n); +} + +static inline void __nocfi __const_udelay(unsigned long n) +{ + arm_delay_ops.const_udelay(n); +} #define udelay(n) \ (__builtin_constant_p(n) ? \ From patchwork Sun Feb 25 20:08:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13571028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5C10C54E4F for ; Sun, 25 Feb 2024 20:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oCYZFnQhlAnpMSSMC1v+hap02Hvxmb7DsabuccVsbRQ=; b=wVPlNu3ud0rM3h WOP5KbUJFH4GWBX6oQ8Ty9hNO1COEr8Yg5HuRvxPpZdHMk2rHmlcA+9zRiD/Nw8g4VWs9LtpIUs5p wBbcDv/Qt0lQAz9U87HEbxzMtlNiI+uVwhxCRVNsVIZTfa8V5tWKuxVhdO/NF13oJrbZNK43foDdc qRQaiJV+eXUUkMH0aCyno72v/+ny74TF84/WBYeQ9nRcy1udCwHma0c7tmwttyK4Cn0Kbgycasqjb FlwPx5lecCQOwZqLAB5xX+3zBzuycAbXbhUQloy0OCWFkDxAfPFpDYrApiROqPLfbZzgIjd+PQjEa 3YofthMigmU+xyAWkk7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnf-0000000Fcs9-2ylz; Sun, 25 Feb 2024 20:08:39 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnL-0000000FclX-3MPr for linux-arm-kernel@lists.infradead.org; Sun, 25 Feb 2024 20:08:21 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a3f1bf03722so233307566b.1 for ; Sun, 25 Feb 2024 12:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708891698; x=1709496498; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VdBurprtbHQ0vf8zuRQqqoRGQBp+uV6pNFNeBm4lwRE=; b=wCaAk1hFhoKYzXruPQ1eeh68X3Jw/YYzJJCu/WP1lK3P9qp8Qj99bhawQFzvzPiU6g dV4Wy/gauyKbn016dnIkgmR/3AIWtAImzGFaRs9UOGTQkY3uWE64lnVxQTBNrI+EukBt mzTcQfLcE+Pe96+QNzmXd4eHjqu8/oRB5qsCk8NO8n8j6IFX6nLl14pn4PTqNvhxSByy BGQoLXoImGB0mKTPsT7iUOWMc8VVlt1y1JTKY1llCHGDuqt0cpmkZ8UhQPCRMiAsnNa9 lA/4+m9A/CwE/xHlIJ7di8iymqXKd80iBMZe8tFAGRYLPdLliD1S2CkAzR7e/3UsPmde xMdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708891698; x=1709496498; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VdBurprtbHQ0vf8zuRQqqoRGQBp+uV6pNFNeBm4lwRE=; b=fqPUgXP+iuMdcKFsHCw74HK6hZNZP2a/s7ROVAa/b0Y+GrPVUyXYgUcKJThtkdxgTc +rYYeJ6zyq9d30HNqHfnHDNY1ayZDbu6mDcCHEM6e/eIb74NRl4GHtei8NorqrRWu9P/ lko/mz0Mo5qmJOwhy0Fh/PkrMSAdx+Cof4Ou+WlVHXEALpgdJ2ds2oF6bFBUDVF6w4SJ 1Z7ivUyCvhn9iBmxL4QfxwmqVU5UVuQCCfY8h7xHZUR0Ly3Vx1BFkXEgePnFHBAFtJR2 T+ZaeIyf+d+x+nLxjutUEpWykEbVEnxwNRwOIvs2/+pX25+HPk8rkYIm1r2H/pFfLuys aI+g== X-Gm-Message-State: AOJu0YzQ1uRNU8xKIsCbhXhqR+Iqt9Wkl9Ez7wipwyvhey7kCNZZ1v2Q bDqlc5zR0bRQmNY7SgIYme2kCN+W5BGjqA2rke/ypRJ7Kl9hpuTCgnsj/eyjczw= X-Google-Smtp-Source: AGHT+IGvoPNI50CVDNAYE+aVj9zM2DSyGYeEYRqrj2AMI1bqHKAqqb7zFpBKsWASbUgdGEAsOR89SA== X-Received: by 2002:a17:907:9905:b0:a3e:998a:cab6 with SMTP id ka5-20020a170907990500b00a3e998acab6mr3511234ejc.74.1708891698443; Sun, 25 Feb 2024 12:08:18 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id hu14-20020a170907a08e00b00a4340138ab5sm504621ejc.5.2024.02.25.12.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:08:18 -0800 (PST) From: Linus Walleij Date: Sun, 25 Feb 2024 21:08:15 +0100 Subject: [PATCH 6/7] ARM: turn CPU cache flush functions into static inlines MIME-Version: 1.0 Message-Id: <20240225-arm32-cfi-v1-6-6943306f065b@linaro.org> References: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> In-Reply-To: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_120819_995477_20715287 X-CRM114-Status: GOOD ( 16.47 ) 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 The members of the vector table struct cpu_cache_fns cpu_cache are called directly using defines, but this is really confusing for KCFI. Wrap the calls in static inlines and tag them with __nocfi so things start to work. Conversely a similar approach is used for the __glue() helpers which define their way into an assembly ENTRY(symbol) for respective CPU variant. We wrap these into static inlines and prefix them with __nocfi as well. (This happens on !MULTI_CACHE systems.) For this case we also need to invoke the __glue() macro to provide a proper function prototype for the inner function. Signed-off-by: Linus Walleij --- arch/arm/include/asm/cacheflush.h | 45 +++++++++++++++++++++++++++++++-------- arch/arm/mm/dma.h | 28 ++++++++++++++++++------ 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h index 1075534b0a2e..76fb665162a4 100644 --- a/arch/arm/include/asm/cacheflush.h +++ b/arch/arm/include/asm/cacheflush.h @@ -122,14 +122,38 @@ struct cpu_cache_fns { extern struct cpu_cache_fns cpu_cache; -#define __cpuc_flush_icache_all cpu_cache.flush_icache_all -#define __cpuc_flush_kern_all cpu_cache.flush_kern_all -#define __cpuc_flush_kern_louis cpu_cache.flush_kern_louis -#define __cpuc_flush_user_all cpu_cache.flush_user_all -#define __cpuc_flush_user_range cpu_cache.flush_user_range -#define __cpuc_coherent_kern_range cpu_cache.coherent_kern_range -#define __cpuc_coherent_user_range cpu_cache.coherent_user_range -#define __cpuc_flush_dcache_area cpu_cache.flush_kern_dcache_area +static inline void __nocfi __cpuc_flush_icache_all(void) +{ + cpu_cache.flush_icache_all(); +} +static inline void __nocfi __cpuc_flush_kern_all(void) +{ + cpu_cache.flush_icache_all(); +} +static inline void __nocfi __cpuc_flush_kern_louis(void) +{ + cpu_cache.flush_kern_louis(); +} +static inline void __nocfi __cpuc_flush_user_all(void) +{ + cpu_cache.flush_user_all(); +} +static inline void __nocfi __cpuc_flush_user_range(unsigned long start, unsigned long end, unsigned int flags) +{ + cpu_cache.flush_user_range(start, end, flags); +} +static inline void __nocfi __cpuc_coherent_kern_range(unsigned long start, unsigned long end) +{ + cpu_cache.coherent_kern_range(start, end); +} +static inline int __nocfi __cpuc_coherent_user_range(unsigned long start, unsigned long end) +{ + return cpu_cache.coherent_user_range(start, end); +} +static inline void __nocfi __cpuc_flush_dcache_area(void *kaddr, size_t sz) +{ + cpu_cache.flush_kern_dcache_area(kaddr, sz); +} /* * These are private to the dma-mapping API. Do not use directly. @@ -137,7 +161,10 @@ extern struct cpu_cache_fns cpu_cache; * is visible to DMA, or data written by DMA to system memory is * visible to the CPU. */ -#define dmac_flush_range cpu_cache.dma_flush_range +static inline void __nocfi dmac_flush_range(const void *start, const void *end) +{ + cpu_cache.dma_flush_range(start, end); +} #else diff --git a/arch/arm/mm/dma.h b/arch/arm/mm/dma.h index aaef64b7f177..251b8a9fffc1 100644 --- a/arch/arm/mm/dma.h +++ b/arch/arm/mm/dma.h @@ -5,8 +5,6 @@ #include #ifndef MULTI_CACHE -#define dmac_map_area __glue(_CACHE,_dma_map_area) -#define dmac_unmap_area __glue(_CACHE,_dma_unmap_area) /* * These are private to the dma-mapping API. Do not use directly. @@ -14,8 +12,20 @@ * is visible to DMA, or data written by DMA to system memory is * visible to the CPU. */ -extern void dmac_map_area(const void *, size_t, int); -extern void dmac_unmap_area(const void *, size_t, int); + +/* These turn into function declarations for each per-CPU glue function */ +void __glue(_CACHE,_dma_map_area)(const void *, size_t, int); +void __glue(_CACHE,_dma_unmap_area)(const void *, size_t, int); + +static inline void __nocfi dmac_map_area(const void *start, size_t sz, int flags) +{ + __glue(_CACHE,_dma_map_area)(start, sz, flags); +} + +static inline void __nocfi dmac_unmap_area(const void *start, size_t sz, int flags) +{ + __glue(_CACHE,_dma_unmap_area)(start, sz, flags); +} #else @@ -25,8 +35,14 @@ extern void dmac_unmap_area(const void *, size_t, int); * is visible to DMA, or data written by DMA to system memory is * visible to the CPU. */ -#define dmac_map_area cpu_cache.dma_map_area -#define dmac_unmap_area cpu_cache.dma_unmap_area +static inline void __nocfi dmac_map_area(const void *start, size_t sz, int flags) +{ + cpu_cache.dma_map_area(start, sz, flags); +} +static inline void __nocfi dmac_unmap_area(const void *start, size_t sz, int flags) +{ + cpu_cache.dma_unmap_area(start, sz, flags); +} #endif From patchwork Sun Feb 25 20:08:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13571029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2DF8C54E41 for ; Sun, 25 Feb 2024 20:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CmM26Oo1B6dgB2aCt3tedBfAAWdc/hEfGy5RnWMq6xQ=; b=JG063wzxnzZeZa DFE7XYKnt8XNzjAsDg0twY0WFqMWn0qsdSR7xKwoexW+us8VupXYHqVqTA1L3+UMN86GCShWTSeRb MY4bq7J78QUWJaCelFRceJCqgUBLYjiJjtfnl0lckrSY+EMo1TuDkD9dMHOVJI6u6hKSf44Tp6AMP Chykl9m98HPphMM/txgjDjBlMH2iljyL2u73z4US6TWMDbtj97gYeNqiH3GXnXKYQZaxqFchYwMOI ox2J7BFdH25cbiCN5O0+qWhTSpiq9aK/gkX+aF4Rw5s4nmukMI9KAkqlQdF/JGhMFytPD84VPsOkB 9Fje/sXMD//JKPsK6lNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKng-0000000Fct4-32wo; Sun, 25 Feb 2024 20:08:40 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnO-0000000FcmF-1D1q for linux-arm-kernel@lists.infradead.org; Sun, 25 Feb 2024 20:08:23 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-512f7332252so1046747e87.0 for ; Sun, 25 Feb 2024 12:08:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708891699; x=1709496499; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hqBogdja5tMMOO5wTCklLeqAnS4o63/YOLSFeJQB8FQ=; b=TYQH6X41/8/6isT6SplIkkY+T63rfYC+pxf3+tw6D/k+ZDPl9XuYrK5Wk0ijax3N/D hyRzH/lDriGijrYOC61kENwUanrrvC+lI3+BNCWbbu7pWOEZ2MLxLkv5md2oOl9IW+0I 8JPNrdbHIkyd6Yoj+uPW+YBjcbVk9hYBFTA9Q0nCM2zNKFlmr1gAxc5NPr9yKDiXfWRr PHYJVlucGxqagYTU38z3W2gUcBqhmT+xoGxtUr/ogMuzgiR3xqcSqdIMhC+s/+GDR+Xj Ls6/3yjOItIo9VHcSWPRKdY6NtnER+9QbxjNv1d7DUinXdtTzuwlFsfZwnumanJUb6MD mI3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708891699; x=1709496499; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hqBogdja5tMMOO5wTCklLeqAnS4o63/YOLSFeJQB8FQ=; b=fMRegU7NLxAbJfVPaRPd/QIZdSH+UrOF9JsG6sP1q1Y8Ed0sFzmt1e3jLHFxIo1nGm sBAFZQzFVm76SwQsSOYeBa/Jh9oW7poQYjdniOGWMnwoo5WrWwvucq99F0QOR5Ht67E9 lZ9dlr95wSZMwoL7+lG7s1AQJIxXEABnYGMpC7DMTqfr1GEzdZ3PcPpJqRRZxG0KWElN msHNJg8nrV8WfVwBSLTBCIVfcGI90V7PFAgXshcqWU/tFqGcfygS6E0f4LEar/0EAjaR rK7DYLYw36LBHBvZrLHDksOBj1CFjCguRLk9dYskTjmICAw/8oZw9ghFsWGqrxdOpuN7 qKQg== X-Gm-Message-State: AOJu0YzI2BZyXRBFRyFi2FAual+yBFCzQQUr3oi5P0EmyvtGmaOgqNgS wKENmI/jkv1l0hXBxTxCJcbDishiCJ6W06QMeViUbD/vLWldu1J8gkp442ISL+c= X-Google-Smtp-Source: AGHT+IFk3ZUSgR50Q//sWITHnD3B/uSdVym8AuueDMcQPsH+TIpsuF27riPyDlhFM+zdSEFscG/Dsw== X-Received: by 2002:a05:6512:46c:b0:512:db3f:436 with SMTP id x12-20020a056512046c00b00512db3f0436mr2992602lfd.36.1708891699608; Sun, 25 Feb 2024 12:08:19 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id hu14-20020a170907a08e00b00a4340138ab5sm504621ejc.5.2024.02.25.12.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:08:19 -0800 (PST) From: Linus Walleij Date: Sun, 25 Feb 2024 21:08:16 +0100 Subject: [PATCH 7/7] ARM: page: Turn highpage accesses into static inlines MIME-Version: 1.0 Message-Id: <20240225-arm32-cfi-v1-7-6943306f065b@linaro.org> References: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> In-Reply-To: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_120822_370425_98B5D423 X-CRM114-Status: GOOD ( 13.22 ) 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 Clearing and copying pages in highmem uses either the cpu_user vtable or the __glue() assembler stubs to call into per-CPU versions of these functions. This is all really confusing for KCFI so wrap these into static inlines and prefix each inline function with __nocfi. __cpu_clear_user_highpage() and __cpu_copy_user_highpage() are exported in arch/arm/mm/proc-syms.c which causes a problem with using static inlines, but it turns out that these exports are completely unused, so we can just delete them. Signed-off-by: Linus Walleij --- arch/arm/include/asm/page.h | 36 +++++++++++++++++++++++++++++------- arch/arm/mm/proc-syms.c | 7 +------ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h index 119aa85d1feb..8bf297228627 100644 --- a/arch/arm/include/asm/page.h +++ b/arch/arm/include/asm/page.h @@ -138,17 +138,39 @@ void xscale_mc_clear_user_highpage(struct page *page, unsigned long vaddr); #ifdef MULTI_USER extern struct cpu_user_fns cpu_user; -#define __cpu_clear_user_highpage cpu_user.cpu_clear_user_highpage -#define __cpu_copy_user_highpage cpu_user.cpu_copy_user_highpage +static inline void __nocfi __cpu_clear_user_highpage(struct page *page, + unsigned long vaddr) +{ + cpu_user.cpu_clear_user_highpage(page, vaddr); +} + +static inline void __nocfi __cpu_copy_user_highpage(struct page *to, + struct page *from, unsigned long vaddr, + struct vm_area_struct *vma) +{ + cpu_user.cpu_copy_user_highpage(to, from, vaddr, vma); +} #else -#define __cpu_clear_user_highpage __glue(_USER,_clear_user_highpage) -#define __cpu_copy_user_highpage __glue(_USER,_copy_user_highpage) +/* These turn into function declarations for each per-CPU glue function */ +void __glue(_USER,_clear_user_highpage)(struct page *page, unsigned long vaddr); +void __glue(_USER,_copy_user_highpage)(struct page *to, struct page *from, + unsigned long vaddr, struct vm_area_struct *vma); + +static inline void __nocfi __cpu_clear_user_highpage(struct page *page, + unsigned long vaddr) +{ + __glue(_USER,_clear_user_highpage)(page, vaddr); +} + +static inline void __nocfi __cpu_copy_user_highpage(struct page *to, + struct page *from, unsigned long vaddr, + struct vm_area_struct *vma) +{ + __glue(_USER,_copy_user_highpage)(to, from, vaddr, vma); +} -extern void __cpu_clear_user_highpage(struct page *page, unsigned long vaddr); -extern void __cpu_copy_user_highpage(struct page *to, struct page *from, - unsigned long vaddr, struct vm_area_struct *vma); #endif #define clear_user_highpage(page,vaddr) \ diff --git a/arch/arm/mm/proc-syms.c b/arch/arm/mm/proc-syms.c index e21249548e9f..c93fec38d9f4 100644 --- a/arch/arm/mm/proc-syms.c +++ b/arch/arm/mm/proc-syms.c @@ -31,14 +31,9 @@ EXPORT_SYMBOL(__cpuc_flush_dcache_area); EXPORT_SYMBOL(cpu_cache); #endif -#ifdef CONFIG_MMU -#ifndef MULTI_USER -EXPORT_SYMBOL(__cpu_clear_user_highpage); -EXPORT_SYMBOL(__cpu_copy_user_highpage); -#else +#if defined(CONFIG_MMU) && defined(MULTI_USER) EXPORT_SYMBOL(cpu_user); #endif -#endif /* * No module should need to touch the TLB (and currently