From patchwork Fri Apr 1 20:19:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 12798778 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 9601FC433EF for ; Fri, 1 Apr 2022 20:40:40 +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:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n4of7ZLHk+ZofgHW0TPFmm8tBJn9CJNuNf00Pw0Tw+Y=; b=LEW4vZo71JmgHExs9eggjULDAu T9pbvH94PbIKPoQn5RXbDNk7aSN0iLIDCFpTyrGZqPCkd5ZGIPjSAMf2WRLbHb+xZ3HXc47D0BrfV UxIJNIx+ZXmc92PsI1HaDT90Ta4oVBfJvB0ZKqdfZ6p3CrLgv9txLKSnzla3hwV7tTeQ7VlMw7Ucs p8IOaQ1aAbGa3jhXQWQMf4cR2u+OP9i1KS821EXcGncvDlbGKuRrMpGPnJK4dMB1GcDfYSAUBI/0u IzB2NL88EXpuIJowC9qdpy29JPaY6pMympBoaqEOqTDD5HMYvtxJobRlhplVaxnm+v/Q/a+DTlPAG NShryKbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1naO3G-007FHD-19; Fri, 01 Apr 2022 20:39:22 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1naNk0-0075cR-1D for linux-arm-kernel@lists.infradead.org; Fri, 01 Apr 2022 20:19:29 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2e8216c4c46so35203607b3.23 for ; Fri, 01 Apr 2022 13:19:24 -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=ATcdLAiyB0HmFVQDg4Xl7rvZSmepnr+daM3v/Y+LeMI=; b=EoyjCfGV3FCQpOkbXV+W3kTnXGO1Evzvf/ZY38A9M1NFlrIqtx1VS6qnTsGBd7BwjX WoMjEr/RMAn4q8VmBMj6mKCCSJYHInMMKdfBk6wZQvwoBizwF+NZ8BoF/h/iCTmyVqoC G7HNo6/dYJ2gtGhM3NTwMeNao+r+TProu7GExptuAVxeL/kk3ZIkTTOekXFAtNjuD2NU ma1hWOS5qp5Duz30EY9BFcZJwxIWP8vW/FC5lCWqXj8YNzw5RVfVB8q0U357R2cNp4mw hIbFGaH0dJMNrmMTAzN7dJIn2fB0mcgwx8f4VQjnqYm/fpUcfe0YQqEExQvrwoLFRu3/ Rs/g== 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=ATcdLAiyB0HmFVQDg4Xl7rvZSmepnr+daM3v/Y+LeMI=; b=ohqyNxfrSvyMhxwwJDCNtpH5H58z9tV8AhrvyNZR5Q3wltBSFuEj7x0yaPBUyClEhg k+Y9doPsBAVqS9MuMHz3PLIWwga/uzmZ9f8Xz+t6y41+4t38JjFqKDIhzqSuquyLTVDN 7WblEz/owoswGdi+Q7+aKM2efOww53CpNYUTcjVdgVOJ/7qRljkhfzHaygti05EF9o7M qmJo4Lc4eRaJrksrl9xA/UVvZ8DLk5MuwRpCLbs8ytWPSe7l76uSg1HEmqAErDJsckNb /WJl613TSYI74SNrfeFsDBt7Vd86Bb6LyqH3Aj414hBqdH8247ACZHYUHhVatDRFMtFx vtuA== X-Gm-Message-State: AOAM5312fK7/ZgDQcGNaQzNN1+x0jaXls9NIlWDL1gAYizbIlch0V2SU q4aOOpV67BZTq3zIrZcIin3rCa7A30CsmduYJT4= X-Google-Smtp-Source: ABdhPJyew2kq+WRmdfIe6euP7IdAfz4Lf1J4a3hpbhDfzorQRebEdIXVNDbDfQueKfPJDVocv/gDvOOrkxzODDApak4= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:ebe8:1acf:913c:f19e]) (user=samitolvanen job=sendgmr) by 2002:a5b:90a:0:b0:634:15f3:871b with SMTP id a10-20020a5b090a000000b0063415f3871bmr10173555ybq.306.1648844363642; Fri, 01 Apr 2022 13:19:23 -0700 (PDT) Date: Fri, 1 Apr 2022 13:19:15 -0700 In-Reply-To: <20220401201916.1487500-1-samitolvanen@google.com> Message-Id: <20220401201916.1487500-3-samitolvanen@google.com> Mime-Version: 1.0 References: <20220401201916.1487500-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=1056; h=from:subject; bh=TxU5yU7eF6HnJJtCowWe9icJOHczcBwSXoiV/s/cDrI=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBiR15CugMAC3++WEpyG4vENztHvLXakUUYXOQsyeYl rVPXFE2JAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYkdeQgAKCRBMtfaEi7xW7gliC/ 9FfQ7TZrKMqndhgdzS0eK9T5tspAJnIZpf3oeBTdH1yAeQIwZvHzFf76rSoqV6LrbI+gqMeIdHKr08 UIVlKWpl6xs1zdEc+NvkBalo7cGuCVrQhcVyGSCHyr4qFrtFKg3hA4cA134xfBCef2dRq4OlcjlxyW noFvvInv0CUwZj+cCNYqM5+PjO39zKKvvYF0L6VlWVNn7Fa3UCbymDa6AcmA7O6TO7t+SExVQ1nE8W vTxJKJBAKAt1rgs3KjEFPVgalAUFnfhfNCCPeh/SC6LF5++tnbSJCjTFzzpyehcjyrrPscjSrGh7yZ pwQxCsuHKH3E7frUwQXCr1167ogQen62ZBUZKyJA3stmJfOtSXlUGXDLPyuNpWNM5SiuQxTE3I9b01 ptlVlMGTab3Tl/kHLSb2PvyQA2hVbrgske+Vc7c0KZGmn1zs1kS+LUgKIU9z5d0Hu0XyCrg3psuddv BDIDadUv7bfb+ZZXkjWwR/kblPiEkSPZWT/MZkK6KiBf0= X-Mailer: git-send-email 2.35.0 Subject: [PATCH 2/3] linux/compiler-clang.h: define function_nocfi From: Sami Tolvanen To: Kees Cook Cc: Catalin Marinas , Mark Rutland , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Sami Tolvanen X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220401_131928_127244_4ABD5E7E X-CRM114-Status: GOOD ( 11.08 ) 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 Use __builtin_function_start() to implement the function_nocfi() macro when CONFIG_CFI_CLANG is selected. Signed-off-by: Sami Tolvanen --- include/linux/compiler-clang.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index babb1347148c..c84fec767445 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -69,6 +69,16 @@ #define __nocfi __attribute__((__no_sanitize__("cfi"))) #define __cficanonical __attribute__((__cfi_canonical_jump_table__)) +#if defined(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) __builtin_function_start(x) +#endif + /* * Turn individual warnings and errors on and off locally, depending * on version.