From patchwork Mon Mar 11 09:15:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13588402 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 82FF5C5475B for ; Mon, 11 Mar 2024 09:16:28 +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=BTv2r/BjfpYFYg 75K1N0HRvHAwIcGX7E+6YTdWOZGnBut5ojj4G0bm7aQbCTEUPSJjyNtu8lJPdnGBXqtHAcbSEfnBM 52PQgKNg9TPzj9QkdJ18FkL2WAC7FGU51U8oW9DzxBIB27IwiwFhIXGNTSbV/plO/ud7e3r2jSHX5 xheTct7MgGcNL/M9+7bp8yAwRGxcN8UZY+g5IUPZ6RO59X1NvCk+BDz3djhsJmS0hCyTgCTRQhZAw odO+0wFKRkTlEn+9jw5SL3tBSPEfXhQEKXn2Q9Smbcp32JsbsIqKD917tY84EWZLnBbC8l92FjBmu XMVMbGowc2ZwgtwQ3CYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjblP-00000000mhL-3ym9; Mon, 11 Mar 2024 09:16:07 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjbl8-00000000mTE-3krr for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:15:55 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a44cdb2d3a6so568932966b.2 for ; Mon, 11 Mar 2024 02:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710148549; x=1710753349; 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=e/xr98A+Qhhj+S5clvl8UBFfl00BTJ4sJCtBba2drFV241W8LstRILygSRgmyUHEK2 TzXF2wXeUNQBZbwJU3YyhQIEjX330ykHCJuQ7laYbvqIQVgORi0qmEWjfm2+ESPH/ayC ecbZ8o+wOnxYOd0AxDkad4ZIYWCH1bFpWobal2VM5YUhpgp1oGZKeHc8zL9hPCEeC1xn qxnlhxwTWRlLCMiv9XoU49emcwzIkF/vd4EXkI6lqkS9o5O5H5svssqkBhcvlh6bpBTP dmuzc4Jc4XsI4Llj+yzIABcGUOElbpM5PuLZFPRIWq1Hxj9LXP1koXvRuKlLZMgHrefT sm4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710148549; x=1710753349; 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=bcNT85yLnbBDWEK3L9p4r4arTZDKCRKzl6SBnYX/hzzDw0hVztReYXvZN8wm/1qLoL 1cxKp7JtxpDjP/aWySIvrwRN4scFw4JMzdvF4/tPh7Mv5Rp3jCDWiVDte7ch+s/OvM/p aduLvJJsAXvtfexe0Na4Pv75yviN692wxKhdwYpG3Uf0xWrjInMEopclu//uBVvYGO/A JqekNlBLz7r+wja9P8qIKcrAzSNUbRNKEV/c3t63EteOAjKy8DLTvrVDDcPwcU17xbk6 tHXLpWlkaFFh3OLPjUHlPDMONRDrStFsgLXZUQCtD53tSBcFKL7+nWzBc4g9nrqg/Svp YcQg== X-Gm-Message-State: AOJu0YzGNKnfRXt3/HXW4yB3yTkHNSsxI2eIBfMHXn7fam+i9JRBAsy+ HWzpCODHPEWmpBQ28qIn7kngYDThQiNh9NmP67xFGqN5b3ILjNRwQowKnLj+EHk= X-Google-Smtp-Source: AGHT+IEP1SSz9yPrDJnqOEruTPOynch6dZWKvcAjOUpOIrdb62bA7bA/LhoylzwSep0OofKyhGJhog== X-Received: by 2002:a17:906:b14b:b0:a3e:d2ea:ff5e with SMTP id bt11-20020a170906b14b00b00a3ed2eaff5emr3888747ejb.58.1710148549011; Mon, 11 Mar 2024 02:15:49 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id js23-20020a170906ca9700b00a4617f1ccf3sm1601256ejb.169.2024.03.11.02.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 02:15:48 -0700 (PDT) From: Linus Walleij Date: Mon, 11 Mar 2024 10:15:44 +0100 Subject: [PATCH v3 7/9] ARM: page: Turn highpage accesses into static inlines MIME-Version: 1.0 Message-Id: <20240311-arm32-cfi-v3-7-224a0f0a45c2@linaro.org> References: <20240311-arm32-cfi-v3-0-224a0f0a45c2@linaro.org> In-Reply-To: <20240311-arm32-cfi-v3-0-224a0f0a45c2@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-20240311_021553_038520_2F04732D X-CRM114-Status: GOOD ( 13.62 ) 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