llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	"Russell King (Oracle)" <linux@armlinux.org.uk>,
	 Kees Cook <keescook@chromium.org>,
	Nathan Chancellor <nathan@kernel.org>,
	 Nick Desaulniers <ndesaulniers@google.com>,
	Arnd Bergmann <arnd@arndb.de>,
	 linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev
Subject: Re: [PATCH v3 2/9] ARM: tlbflush: Make TLB flushes into static inlines
Date: Tue, 12 Mar 2024 00:56:09 +0100	[thread overview]
Message-ID: <CACRpkdZOsST_QtouokNgF0XRVSyoOJQr0cfAGTMjSCb7ezBLPg@mail.gmail.com> (raw)
In-Reply-To: <CABCJKucJd-EG1yr6u5SvUW2Frxs3aBPCuo9TH83ba2chdkb7tw@mail.gmail.com>

On Mon, Mar 11, 2024 at 11:28 PM Sami Tolvanen <samitolvanen@google.com> wrote:
> On Mon, Mar 11, 2024 at 3:17 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> >   LD      .tmp_vmlinux.kallsyms1
> > ld.lld: error: undefined symbol: __kcfi_typeid_v7wbi_flush_user_tlb_range
> > >>> referenced by arch/arm/mm/tlb-v7.o:(.text+0x0) in archive vmlinux.a
> >
> > ld.lld: error: undefined symbol: __kcfi_typeid_v7wbi_flush_kern_tlb_range
> > >>> referenced by tlb-v7.S:60 (/mnt/storage/linus/linux-integrator/build-vexpress/../arch/arm/mm/tlb-v7.S:60)
> > >>>               arch/arm/mm/tlb-v7.o:(.text+0x40) in archive vmlinux.a
> >
> > ld.lld: error: undefined symbol: __kcfi_typeid_v7wbi_tlb_fns
> > >>> referenced by arch/arm/mm/tlb-v7.o:(.init.text+0x0) in archive vmlinux.a
>
> Clang only emits __kcfi_typeid symbols for functions that are
> address-taken in C code. You need to add __ADDRESSABLE(function)
> references to a C file somewhere for functions that otherwise are not
> address-taken.

Hey it works. So for example if for these functions I also add:

diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index d19d140a10c7..23eb0f9358cb 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -18,6 +18,11 @@

 #include "mm.h"

+void v7wbi_flush_user_tlb_range(unsigned long, unsigned long, struct
vm_area_struct *);
+void v7wbi_flush_kern_tlb_range(unsigned long, unsigned long);
+__ADDRESSABLE(v7wbi_flush_user_tlb_range);
+__ADDRESSABLE(v7wbi_flush_kern_tlb_range);

Then that works.

The problem is that I also have to define all these function signatures that
are never used in C and there are quite a few of them, if I start listing them
all and #ifdefining them for selected CPUs it's not going to be pretty.

It can be done and they can be in a cfi-defs.c file though.
And it's better than __nocfi.

The complexity comes from the fact that arm can boot a kernel
with support for several different CPU:s.

The different CPU management functions are put in a list of supported
processors by the linker, and then e.g. the tlb maintenance functions
are dereferenced directly from *list->tlb in setup_processor()
in arch/arm/kernel/setup.c.

Yours,
Linus Walleij

  reply	other threads:[~2024-03-11 23:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11  9:15 [PATCH v3 0/9] CFI for ARM32 using LLVM Linus Walleij
2024-03-11  9:15 ` [PATCH v3 1/9] ARM: Support CLANG CFI Linus Walleij
2024-03-11 10:24   ` Ard Biesheuvel
2024-03-11  9:15 ` [PATCH v3 2/9] ARM: tlbflush: Make TLB flushes into static inlines Linus Walleij
2024-03-11  9:39   ` Russell King (Oracle)
2024-03-11 10:03     ` Ard Biesheuvel
2024-03-11 15:34       ` Sami Tolvanen
2024-03-11 19:50         ` Linus Walleij
2024-03-11 21:36           ` Sami Tolvanen
2024-03-11 22:17             ` Linus Walleij
2024-03-11 22:28               ` Sami Tolvanen
2024-03-11 23:56                 ` Linus Walleij [this message]
2024-03-12  7:24                   ` Ard Biesheuvel
2024-03-12  8:14                     ` Linus Walleij
2024-03-11  9:15 ` [PATCH v3 3/9] ARM: bugs: Check in the vtable instead of defined aliases Linus Walleij
2024-03-11  9:15 ` [PATCH v3 4/9] ARM: proc: Use inlines instead of defines Linus Walleij
2024-03-11  9:15 ` [PATCH v3 5/9] ARM: delay: Turn delay functions into static inlines Linus Walleij
2024-03-11 12:26   ` Ard Biesheuvel
2024-03-11  9:15 ` [PATCH v3 6/9] ARM: turn CPU cache flush " Linus Walleij
2024-03-11  9:15 ` [PATCH v3 7/9] ARM: page: Turn highpage accesses " Linus Walleij
2024-03-11 12:15   ` Ard Biesheuvel
2024-03-28  8:18     ` Linus Walleij
2024-03-11  9:15 ` [PATCH v3 8/9] ARM: ftrace: Define ftrace_stub_graph Linus Walleij
2024-03-11  9:15 ` [PATCH v3 9/9] ARM: KCFI: Allow permissive CFI mode Linus Walleij
2024-03-11 22:03   ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACRpkdZOsST_QtouokNgF0XRVSyoOJQr0cfAGTMjSCb7ezBLPg@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=samitolvanen@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).