llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	 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: Mon, 11 Mar 2024 11:03:39 +0100	[thread overview]
Message-ID: <CAMj1kXHNK+peQUjO4dRnQmLDF+4of0F7cOTSoMPKucMT6NiGDw@mail.gmail.com> (raw)
In-Reply-To: <Ze7RNalwiZbceFxX@shell.armlinux.org.uk>

On Mon, 11 Mar 2024 at 10:39, Russell King (Oracle)
<linux@armlinux.org.uk> wrote:
>
> On Mon, Mar 11, 2024 at 10:15:39AM +0100, Linus Walleij wrote:
> > Instead of just using defines to define the TLB flush functions,
> > use static inlines.
> >
> > This has the upside that we can tag those as __nocfi so we can
> > execute a CFI-enabled kernel.
>
> Why? This seems to be brain dead.
>
> Why can't CLANG cope with directly calling e.g.
> cpu_tlb.flush_user_range? Why does it need a static function to do
> exactly the same as the macro does?
>

I had the same question, so I played around a bit with the code.

What I think would be better is if we could add the __nocfi annotation
to the type, i.e.,

--- a/arch/arm/include/asm/tlbflush.h
+++ b/arch/arm/include/asm/tlbflush.h
@@ -205,8 +205,8 @@
 #include <linux/sched.h>

 struct cpu_tlb_fns {
-       void (*flush_user_range)(unsigned long, unsigned long, ...);
-       void (*flush_kern_range)(unsigned long, unsigned long);
+       void (__nocfi *flush_user_range)(unsigned long, unsigned long, ...);
+       void (__nocfi *flush_kern_range)(unsigned long, unsigned long);
        unsigned long tlb_flags;
 };

This works for some function attributes (e.g., __efiapi is used like
this), but the attribute specifier to which __nocfi resolves does not
appear to be usable in the same manner.

Best would be to annotate the asm code using
SYM_TYPED_FUNC_START/_END, so that the CFI machinery is invoked at the
call site to validate the function type of the destination.

  reply	other threads:[~2024-03-11 10:03 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 [this message]
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
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=CAMj1kXHNK+peQUjO4dRnQmLDF+4of0F7cOTSoMPKucMT6NiGDw@mail.gmail.com \
    --to=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=keescook@chromium.org \
    --cc=linus.walleij@linaro.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).