Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp230235iob; Mon, 2 May 2022 17:55:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMZr4/4S837KkC1mRwgJxdSIB+qXqLtfo4YmUip/mtsexuVmMpdmP6Odhq1tl+BM+xekqF X-Received: by 2002:a05:6a00:174a:b0:4fd:ac35:6731 with SMTP id j10-20020a056a00174a00b004fdac356731mr13858216pfc.71.1651539309028; Mon, 02 May 2022 17:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651539309; cv=none; d=google.com; s=arc-20160816; b=yWO7dRA4HRfOO/qv3IBAZNrXEgQO5PwG8P+caqMCyGLFAhnOPGvfEfhTwG7yhHOgnE lNhePqOONj/TiCG/zAOYPt9zWhIvSVXdTw9Tu4ei/2YTh1bG/hJeWlg+MCQr4fFuvdCh JXUasBlY68eP+AXX3xXsMwMv0uYyzPhX2ejdNOQcSg7luZ3MT3WAI0I2ZHcOslw7nRZO ItfQNLT2Ae/1PJ94yJyBUbGWJbrvJ/G8G1bxC9UpCBbM10z1/WhP6BkQpzJNPT+uKK05 7cuCKPKyNp1sbogBNAQ4/Gh9Ja2goxEYPVX+U8xcj3m0pbKBJpzABLDNMpgOTdmnUUlr y/aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=cVgS1u5MhvRMiR1WU9isbIwtBDwqAYBDvFb5Rwt/KL4=; b=nWDPc3v9M+uF2yuQmCJaXBQjRnp9MH5Z3HG6xVl0SpwDjhlHRYOBUp+50eXK8D5SsV sAF6nzWiKDzG8vN9L+4RCwgJyx6/0zQ9MpezSxEq0xwi4GtAos6wBKw+7uO4afBms/yv kYMoQ2rNfy4e3kZWthw0Hu0j2CK6Fg48dx3iZITyjN/qg6Ke23BCC20G2vk7Epab+Foh xnfT/R6DRMWoLT75I7nKDSVUNPDOLTgmMpGO9wn6fnL25D0pbsXC2XpzOE6g9ZnmUCcR UuYmML/nlOAzjpraCWKCAzIiGCsoS5EPV0mHfSHNRBmgJHa/tC3Ra5uE0aOt4vrvr6rD EtOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=tVbCOpJ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v29-20020a63b95d000000b003984c7f4990si15359499pgo.243.2022.05.02.17.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:55:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=tVbCOpJ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5D76488B0; Mon, 2 May 2022 17:41:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238153AbiD2UlA (ORCPT + 99 others); Fri, 29 Apr 2022 16:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380912AbiD2Ukc (ORCPT ); Fri, 29 Apr 2022 16:40:32 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6448483B3C for ; Fri, 29 Apr 2022 13:37:12 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f7dbceab08so83958987b3.10 for ; Fri, 29 Apr 2022 13:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cVgS1u5MhvRMiR1WU9isbIwtBDwqAYBDvFb5Rwt/KL4=; b=tVbCOpJ0sZ4rDt1MYoC0Min9+6wSFsedsvM0gD96SVPmYGNZp89DjlCHwo5SOABbCw yNrlap1HSnjUnL8WCYE7p+mSnFLciWvKqHeiX+i+LnGScaJuaHBZGSfUBhI0Z8mjlJ9G cRZG7uklBj75QtC40VbJ2hUrZDngH9/Tlt/83KBvAvd8v3rXSY/k3ck+1faWVxH+QUM9 llg59EPv4O8gdCRjZIdegcnQC+JursjYHfZUISVVxkxhNHceQjNsZRMaHZwQrDE9IfIJ sMN4kIUKc4biyB/rd0QGkHqfaDLSpuOh8NW0O8dsMBXsEbANLKJ6WVzCTDvubUTfv95F b4kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cVgS1u5MhvRMiR1WU9isbIwtBDwqAYBDvFb5Rwt/KL4=; b=lX6AtQlHZsJke5lJ4ScZ7wsOm0IyeK2w/vZxSqa+1Tfp6xQPxta3CCk8wG/TsgK3c5 bdZpqLNDiSBkiUE4f+9VDlQDDRbUq0av398myGxbC1prRPjSlZIJmMZQPM3aouqnNhcK gkHbrJ/tW2MQri/MjN4YJYtWyvhG2IVaqwGjWQqU+mIGHWLK9CryZnhbieSxne0ZGC/U sdIUDPX9Z9f1MDWXKkXkDyMDbw0Z/VDHfVDusAm7NwqmYG4bZzzZpuKWfqNWBQ3TWNU5 vosav16YU629sLfBzdIIv2gC7G0ATCBMabQHb5TSjVsFrv2L+TrabqSp0hZC8zXCaQeu g90w== X-Gm-Message-State: AOAM530aIzspyCXC+CbTafK38bQsJszxQx8Wdq+2JhHOfzqQGSGhLTfh emIITPpx8gKesttIHuXA5pEJDJlrAD22jrgtyVx+x4Bicrt3Myw9MUfcGR6JDODw0kHGHo3V42j fYJlMIHfRp7NiWA0QnPtYdTlITA9zopMwaWjezlFoIWV35NJQEry+eXX2qbEUmuoAQ361R93gJ8 l+7A1Zybbpaw== X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:351:bea9:f158:1021]) (user=samitolvanen job=sendgmr) by 2002:a81:949:0:b0:2f7:c45b:e291 with SMTP id 70-20020a810949000000b002f7c45be291mr1105855ywj.503.1651264631532; Fri, 29 Apr 2022 13:37:11 -0700 (PDT) Date: Fri, 29 Apr 2022 13:36:33 -0700 In-Reply-To: <20220429203644.2868448-1-samitolvanen@google.com> Message-Id: <20220429203644.2868448-11-samitolvanen@google.com> Mime-Version: 1.0 References: <20220429203644.2868448-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=8367; h=from:subject; bh=wxPfyY3n6qk4ggt+1iaVhPzUbNJ4pejg7hKWKsOWDww=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBibExW3T+BGjsIEzJbw7cxjH3V+dvYpLhrtRTSNf6l BujPW6iJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYmxMVgAKCRBMtfaEi7xW7vRsC/ sHqWUB62HWVZ1/7qSk0SXqQ8W11ZJCOwR11Zg5msEkkO2Q1Hi8jH3MPCalRU59BDSHPYEo+pUBmwvk jftNvM6a0H9awx5zB9WTMPal4OsoW4Mm5Twqa9c4jqyNfAcXZMJuYKWbJ59LGWWllZoX5MQjLAdxrE ipjyG+yC1VFAgwpmJAh7Rw0Uyas9d4Ew0aSMsWO3IJQP3yfexzbAu5gLCgVRzcXACm2kNFPFdl5Fco cLFQ3aUaF4C99w2Ks+llSux1J3zs9Icoqrxj0fKbJjEQRQxvFNobQcJLNUxUNwfphjRr7CfdXjwX5Q 71tDw0Qw/OO+qDDxuGgU3HabllChobINT0sMGg1xspp2C3JdF95uuBIw3bPuNaYcaapEwh6GKwgMEu f1gEImJzUtbFdHKbWoPNxD2jRd8Vo9FDvcbnlEiYY8HN68rzUPj/REoq7XbhweFt9Xrt4UG0RjeuKp UkAuZv5Pqw9aJr72AhHkU+TE7FrgSBaafkSMTnO07zUrE= X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [RFC PATCH 10/21] treewide: Drop function_nocfi From: Sami Tolvanen To: linux-kernel@vger.kernel.org Cc: Kees Cook , Josh Poimboeuf , Peter Zijlstra , x86@kernel.org, Catalin Marinas , Will Deacon , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Joao Moreira , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With -fsanitize=kcfi, we no longer need function_nocfi() as the compiler won't change function references to point to a jump table. Remove all implementations and uses of the macro. Signed-off-by: Sami Tolvanen --- arch/arm64/include/asm/compiler.h | 16 ---------------- arch/arm64/include/asm/ftrace.h | 2 +- arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/kernel/acpi_parking_protocol.c | 2 +- arch/arm64/kernel/cpufeature.c | 2 +- arch/arm64/kernel/ftrace.c | 2 +- arch/arm64/kernel/machine_kexec.c | 2 +- arch/arm64/kernel/psci.c | 2 +- arch/arm64/kernel/smp_spin_table.c | 2 +- drivers/firmware/psci/psci.c | 4 ++-- drivers/misc/lkdtm/usercopy.c | 2 +- include/linux/compiler.h | 10 ---------- 12 files changed, 11 insertions(+), 37 deletions(-) diff --git a/arch/arm64/include/asm/compiler.h b/arch/arm64/include/asm/compiler.h index dc3ea4080e2e..6fb2e6bcc392 100644 --- a/arch/arm64/include/asm/compiler.h +++ b/arch/arm64/include/asm/compiler.h @@ -23,20 +23,4 @@ #define __builtin_return_address(val) \ (void *)(ptrauth_clear_pac((unsigned long)__builtin_return_address(val))) -#ifdef CONFIG_CFI_CLANG -/* - * With CONFIG_CFI_CLANG, the compiler replaces function address - * references with the address of the function's CFI jump table - * entry. The function_nocfi macro always returns the address of the - * actual function instead. - */ -#define function_nocfi(x) ({ \ - void *addr; \ - asm("adrp %0, " __stringify(x) "\n\t" \ - "add %0, %0, :lo12:" __stringify(x) \ - : "=r" (addr)); \ - addr; \ -}) -#endif - #endif /* __ASM_COMPILER_H */ diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h index 1494cfa8639b..c96d47cb8f46 100644 --- a/arch/arm64/include/asm/ftrace.h +++ b/arch/arm64/include/asm/ftrace.h @@ -26,7 +26,7 @@ #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS #define ARCH_SUPPORTS_FTRACE_OPS 1 #else -#define MCOUNT_ADDR ((unsigned long)function_nocfi(_mcount)) +#define MCOUNT_ADDR ((unsigned long)_mcount) #endif /* The BL at the callsite's adjusted rec->ip */ diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index 6770667b34a3..c9df5ab2c448 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -164,7 +164,7 @@ static inline void __nocfi cpu_replace_ttbr1(pgd_t *pgdp) ttbr1 |= TTBR_CNP_BIT; } - replace_phys = (void *)__pa_symbol(function_nocfi(idmap_cpu_replace_ttbr1)); + replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1); cpu_install_idmap(); replace_phys(ttbr1); diff --git a/arch/arm64/kernel/acpi_parking_protocol.c b/arch/arm64/kernel/acpi_parking_protocol.c index bfeeb5319abf..b1990e38aed0 100644 --- a/arch/arm64/kernel/acpi_parking_protocol.c +++ b/arch/arm64/kernel/acpi_parking_protocol.c @@ -99,7 +99,7 @@ static int acpi_parking_protocol_cpu_boot(unsigned int cpu) * that read this address need to convert this address to the * Boot-Loader's endianness before jumping. */ - writeq_relaxed(__pa_symbol(function_nocfi(secondary_entry)), + writeq_relaxed(__pa_symbol(secondary_entry), &mailbox->entry_point); writel_relaxed(cpu_entry->gic_cpu_id, &mailbox->cpu_id); diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index d72c4b4d389c..dae07d99508b 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1619,7 +1619,7 @@ kpti_install_ng_mappings(const struct arm64_cpu_capabilities *__unused) if (arm64_use_ng_mappings) return; - remap_fn = (void *)__pa_symbol(function_nocfi(idmap_kpti_install_ng_mappings)); + remap_fn = (void *)__pa_symbol(idmap_kpti_install_ng_mappings); cpu_install_idmap(); remap_fn(cpu, num_online_cpus(), __pa_symbol(swapper_pg_dir)); diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index 4506c4a90ac1..4128ca6ed485 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -56,7 +56,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func) unsigned long pc; u32 new; - pc = (unsigned long)function_nocfi(ftrace_call); + pc = (unsigned long)ftrace_call; new = aarch64_insn_gen_branch_imm(pc, (unsigned long)func, AARCH64_INSN_BRANCH_LINK); diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index e16b248699d5..4eb5388aa5a6 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -204,7 +204,7 @@ void machine_kexec(struct kimage *kimage) typeof(cpu_soft_restart) *restart; cpu_install_idmap(); - restart = (void *)__pa_symbol(function_nocfi(cpu_soft_restart)); + restart = (void *)__pa_symbol(cpu_soft_restart); restart(is_hyp_nvhe(), kimage->start, kimage->arch.dtb_mem, 0, 0); } else { diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index ab7f4c476104..29a8e444db83 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -38,7 +38,7 @@ static int __init cpu_psci_cpu_prepare(unsigned int cpu) static int cpu_psci_cpu_boot(unsigned int cpu) { - phys_addr_t pa_secondary_entry = __pa_symbol(function_nocfi(secondary_entry)); + phys_addr_t pa_secondary_entry = __pa_symbol(secondary_entry); int err = psci_ops.cpu_on(cpu_logical_map(cpu), pa_secondary_entry); if (err) pr_err("failed to boot CPU%d (%d)\n", cpu, err); diff --git a/arch/arm64/kernel/smp_spin_table.c b/arch/arm64/kernel/smp_spin_table.c index 7e1624ecab3c..49029eace3ad 100644 --- a/arch/arm64/kernel/smp_spin_table.c +++ b/arch/arm64/kernel/smp_spin_table.c @@ -66,7 +66,7 @@ static int smp_spin_table_cpu_init(unsigned int cpu) static int smp_spin_table_cpu_prepare(unsigned int cpu) { __le64 __iomem *release_addr; - phys_addr_t pa_holding_pen = __pa_symbol(function_nocfi(secondary_holding_pen)); + phys_addr_t pa_holding_pen = __pa_symbol(secondary_holding_pen); if (!cpu_release_addr[cpu]) return -ENODEV; diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index cfb448eabdaa..aa3133cafced 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -334,7 +334,7 @@ static int __init psci_features(u32 psci_func_id) static int psci_suspend_finisher(unsigned long state) { u32 power_state = state; - phys_addr_t pa_cpu_resume = __pa_symbol(function_nocfi(cpu_resume)); + phys_addr_t pa_cpu_resume = __pa_symbol(cpu_resume); return psci_ops.cpu_suspend(power_state, pa_cpu_resume); } @@ -359,7 +359,7 @@ int psci_cpu_suspend_enter(u32 state) static int psci_system_suspend(unsigned long unused) { - phys_addr_t pa_cpu_resume = __pa_symbol(function_nocfi(cpu_resume)); + phys_addr_t pa_cpu_resume = __pa_symbol(cpu_resume); return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND), pa_cpu_resume, 0, 0); diff --git a/drivers/misc/lkdtm/usercopy.c b/drivers/misc/lkdtm/usercopy.c index 9161ce7ed47a..79a17b1c4885 100644 --- a/drivers/misc/lkdtm/usercopy.c +++ b/drivers/misc/lkdtm/usercopy.c @@ -318,7 +318,7 @@ void lkdtm_USERCOPY_KERNEL(void) pr_info("attempting bad copy_to_user from kernel text: %px\n", vm_mmap); - if (copy_to_user((void __user *)user_addr, function_nocfi(vm_mmap), + if (copy_to_user((void __user *)user_addr, vm_mmap, unconst + PAGE_SIZE)) { pr_warn("copy_to_user failed, but lacked Oops\n"); goto free_user; diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 9303f5fe5d89..80ed9644d129 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -203,16 +203,6 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, __v; \ }) -/* - * With CONFIG_CFI_CLANG, the compiler replaces function addresses in - * instrumented C code with jump table addresses. Architectures that - * support CFI can define this macro to return the actual function address - * when needed. - */ -#ifndef function_nocfi -#define function_nocfi(x) (x) -#endif - #endif /* __KERNEL__ */ /* -- 2.36.0.464.gb9c8b46e94-goog