LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Ian Rogers <irogers@google.com>
Subject: Re: [GIT pull] x86/urgent for v5.15-rc3
Date: Sun, 26 Sep 2021 20:15:43 +0200	[thread overview]
Message-ID: <YVC4zz1vCskBMb6I@zn.tnic> (raw)
In-Reply-To: <CAHk-=wj=C2W1VmW1RHU8ErvSjVF2Y=r9uWrnMCiz-U_aa8Dorw@mail.gmail.com>

On Sun, Sep 26, 2021 at 10:21:18AM -0700, Linus Torvalds wrote:
> On Sun, Sep 26, 2021 at 3:30 AM Thomas Gleixner <tglx@linutronix.de> wrote:
> >
> >  - Prevent undefined behaviour to the potential unaligned accesss in the
> >    instroction decoder library.
> 
> What a horrible fix that is.
> 
> This is why we have "get_unaligned()". It might use memcpy()
> internally on some architectures (it doesn't really any more - Arnd
> cleaned it all up and now it uses a pointer that is marked unaligned),
> but more importantly it explains _why_ something is done the way it's
> done, rather than be an odd memcpy().
> 
> Oh well. The memcpy works, and compilers will do the right thing for
> it, but it's ugly.
> 
> In this case, it's actually *doubly* ugly, though, because we
> literally have functions to "load unaligned data in little-endian
> format".
> 
> So instead of doing a "memcpy()", followed by a magic special macro
> that does a "switch (sizeof(t))" and does a "le*_to_cpu()" on the
> result, the code could  literally have used the functions that do this
> all for them.
> 
> Ugh. Pulled. But it's ugly.

Yeah, that came up during review:

https://lore.kernel.org/lkml/CAP-5=fU2XBoOa2=00VCuWYqsLUzMSMzUXY63ZJt9rz-NJ+vYwA@mail.gmail.com/

and the follow-on messages and AFAICT the only hurdle to using
get_unaligned() is exporting it into tools/ for use by the version of
the insn decoder there in tools/arch/x86/lib/insn.c.

There's this other rather "theoretical" thing of Intel PT
decoding being done on any arch but get_unaligned() from
include/asm-generic/unaligned.h looks as generic and as arch-agnostic as
they get, to me...

But let me add the gents to Cc.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  reply	other threads:[~2021-09-26 18:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26 10:30 [GIT pull] irq/urgent " Thomas Gleixner
2021-09-26 10:30 ` [GIT pull] timers/urgent " Thomas Gleixner
2021-09-26 17:27   ` pr-tracker-bot
2021-09-26 10:30 ` [GIT pull] x86/urgent " Thomas Gleixner
2021-09-26 17:21   ` Linus Torvalds
2021-09-26 18:15     ` Borislav Petkov [this message]
2021-09-26 19:10       ` Linus Torvalds
2021-09-28 17:56         ` Borislav Petkov
2021-09-28 20:13           ` Linus Torvalds
2021-09-28 20:41             ` Borislav Petkov
2021-09-28 22:44               ` Linus Torvalds
2021-09-29 18:10                 ` [PATCH] x86/insn: Use get_unaligned() instead of memcpy() Borislav Petkov
2021-09-30  0:00                   ` Masami Hiramatsu
2021-10-04  9:48                   ` [tip: x86/misc] " tip-bot2 for Borislav Petkov
2021-10-06 10:02                   ` tip-bot2 for Borislav Petkov
2021-09-26 17:27   ` [GIT pull] x86/urgent for v5.15-rc3 pr-tracker-bot
2021-09-26 17:27 ` [GIT pull] irq/urgent " pr-tracker-bot

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=YVC4zz1vCskBMb6I@zn.tnic \
    --to=bp@alien8.de \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    --subject='Re: [GIT pull] x86/urgent for v5.15-rc3' \
    /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

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).