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