All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Borislav Petkov <bp@alien8.de>
Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"the arch/x86 maintainers" <x86@kernel.org>,
	"Borislav Petkov" <bp@suse.de>, "H . Peter Anvin" <hpa@zytor.com>,
	"Andy Lutomirski" <luto@amacapital.net>,
	"Brian Gerst" <brgerst@gmail.com>,
	"Denys Vlasenko" <dvlasenk@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@kernel.org>, "Jiri Kosina" <jkosina@suse.cz>
Subject: Re: [PATCH] x86/hweight: Don't clobber %rdi
Date: Mon, 8 Aug 2016 11:21:20 -0700	[thread overview]
Message-ID: <CA+55aFw8vH5eP8quj=YUXd4YtHXLks2VA18QaveJNVJ1PEsQYg@mail.gmail.com> (raw)
In-Reply-To: <20160808180430.GE511@nazgul.tnic>

On Mon, Aug 8, 2016 at 11:04 AM, Borislav Petkov <bp@alien8.de> wrote:
>
> Hmm, I've been staring at asm for the last hours and my head is spinning
> now, so can you please point me at the exact where this happens. I can't
> find it in x86_perf_event_update().

The corruption could easily have happened long long before.

With a random register clobbered (by a function that is *not* a C
function - it's a replacement for the "popcnt %rdi, %rax"
instruction), you might end up with memory corruption somewhere, and
then an oops much later.

That said, in this case it's likely something like the the
intel_pmu_init() doing

    c->weight = hweight64(c->idxmsk64);

in arch/x86/events/intel/core.c, which then corrupts something related
to the event constraints, and then you get the oops in
x86_perf_event_update() later.

> In any case, it is not a good idea to do the compiler's work. :-\

The compiler has absolutely nothing to do with this. It's all assembly
language and an inline asm.

We *used* to try to have the compiler generate the code. That's what
caused problems.

               Linus

  reply	other threads:[~2016-08-08 18:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 17:35 [PATCH] x86/hweight: Don't clobber %rdi ville.syrjala
2016-08-08 17:58 ` Linus Torvalds
2016-08-08 18:32   ` Peter Zijlstra
2016-08-08 18:53     ` Jiri Kosina
2016-08-08 19:17       ` Borislav Petkov
2016-08-08 18:04 ` Borislav Petkov
2016-08-08 18:21   ` Linus Torvalds [this message]
2016-08-08 18:37     ` Borislav Petkov
2016-08-08 18:45       ` Linus Torvalds
2016-08-08 18:55         ` Borislav Petkov

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='CA+55aFw8vH5eP8quj=YUXd4YtHXLks2VA18QaveJNVJ1PEsQYg@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=ville.syrjala@linux.intel.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.