From patchwork Thu Mar 7 14:22:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13585776 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 E37CFC48BF6 for ; Thu, 7 Mar 2024 14:22:54 +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=lmDdM3XSdBPPGd OU4TaymntTXlDUK8rN/l4fXzj5ofFGIf21eutMAnoKrAfXCvk9iiLebtswZhZgrvLHZcFTMi8z+KM cifjTY0ILiO1yKhwSSHRVIazyibdp3kRs5eFBKqG7v14Rz2WCHU95PlPt7xUu0jmt0a1smFqFPai1 dFOLmIHQ9hMNGKgUKe1GA6kdPhX5E755GJhLN7MGUEZuRay8QfdWutMV/XgxaWuR1TtGJech7fzA2 aqwVUjGbz5Ti3yYqaHQkM/YSVUeFnbE0N75VDTNHxajNC3CEPfVpnVs/NOexxoVg2hq0VRQk1ZXym x7k0F6bFbGnveDObTxCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riEdt-000000051XV-1oX9; Thu, 07 Mar 2024 14:22:41 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1riEdR-000000051BP-3g2w for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2024 14:22:15 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-51325c38d10so1984251e87.1 for ; Thu, 07 Mar 2024 06:22:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709821332; x=1710426132; 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=oqHPNWH0PODYLvxCcOHXyQM5b83R86PBtI1g/mhe7XENzM9i94QFTjrAcKfZRoxe3c ezlZY8G9XJj+xmQVuSLT2v79QThfH92R/PdQ3mBNJkYAXrLxuXY6YzcHyzuO66oQObPg KF6xF19OHbEBgYNGhKW5YUjA/NnH03JB/yyTIhpFKNTxqnvXYR4zGtrXzldYh/U6O0hZ o8UnOO9NymVBxzgJjskFc/S7kOTlGV1a8xOwkQYZMIaHblgYN/AeWMMG9CoR6oAhV4da xxzmc6NaKroqm8EkKQWI37J1UsbmYnuuGPKgsAOtI0Nnn43BvWWnorA4Ufuwn5Ua7RF8 iyJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709821332; x=1710426132; 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=ATpPZBdafpFqyeh2f7CkPlGu5zro0mpN2+jS6zw7DglbCgoR/sIPuaHk3/fXwwnXNp /Fzx12bOPSbzjywPKsyvLHHAYjL2amUnvUVU1tYhXrK4DON2dqsXHucWgKP0YRVs/hrX m1IOxH+pv+DfdV87qJCJdP3sQ2+fzx+tUx91FwwzjbCWf4RkO9KnjTFF/FxeRVgcB7Na g/I0BZ/M14ZEBZNxgoNKJ2n7Bexpz9+6BjZ9UoRLrXfnUtquMHTxOO86aYD37qUIh5Jf nsRH2SbahXs1nofpAF8/fYeuF8pKG7GlfZ42Ostl+cCnukcvqy9/cTbfpqRBTVpoLzvh uyLA== X-Gm-Message-State: AOJu0Yz+H4SxFZvTb6D/Ijw9atOcakMCsqcWG2EHEqMdiUQFrhNjZf0H oKEEruE0zsLY3aHdbVBrWW2WckTR120KzFrNfU6KVDniSztZsHBYkcwKOlDE/v4= X-Google-Smtp-Source: AGHT+IGHiABAzZ0gzslhFBFFCHaQfxDyREIPjRltUdsCGKwCOVgo5+NjSeovE0CeKpTNYEbNM0cxZA== X-Received: by 2002:a19:ca1d:0:b0:513:3b3e:c361 with SMTP id a29-20020a19ca1d000000b005133b3ec361mr610924lfg.2.1709821332426; Thu, 07 Mar 2024 06:22:12 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id x11-20020a19e00b000000b005133b381a5csm2417137lfg.90.2024.03.07.06.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 06:22:11 -0800 (PST) From: Linus Walleij Date: Thu, 07 Mar 2024 15:22:06 +0100 Subject: [PATCH v2 7/9] ARM: page: Turn highpage accesses into static inlines MIME-Version: 1.0 Message-Id: <20240307-arm32-cfi-v2-7-cc74ea0306b3@linaro.org> References: <20240307-arm32-cfi-v2-0-cc74ea0306b3@linaro.org> In-Reply-To: <20240307-arm32-cfi-v2-0-cc74ea0306b3@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-20240307_062214_142128_827E9293 X-CRM114-Status: GOOD ( 13.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 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