From: Mikael Pettersson <mikpe@csd.uu.se>
To: vamsi@in.ibm.com
Cc: linux-kernel@vger.kernel.org, richardj_moore@uk.ibm.com,
grundym@us.ibm.com, vamsi_krishna@in.ibm.com,
suparna <bsuparna@in.ibm.com>
Subject: Re: [rfc] [patch] kernel hooks
Date: Thu, 3 Oct 2002 14:40:48 +0200 [thread overview]
Message-ID: <15772.15056.287602.502467@kim.it.uu.se> (raw)
In-Reply-To: <20021003175600.A17884@in.ibm.com>
Vamsi Krishna S . writes:
> Hooks are implemented as fast and slim-line insertions to kernel
> space code. When not active that have practically no overhead to
> the kernel. Optimized versions are implemented on ia32, ppc,
> ppc64, s390, s390x archs, where they expand to:
> movl $0, %reg
> ^x
> testl %reg, %reg
> jz out
> call out exits
> out:
>
> Hooks are armed by editing the number at ^x above to a non-zero
> value so that the exits will be now be called out.
...
> +static inline void activate_asm_hook(struct hook *hook)
> +{
> + unsigned char *addr = (unsigned char *) (hook->hook_addr);
> + addr[2] = 1;
> + flush_icache_range(addr + 2, addr + 2);
> + return;
> +}
You just triggered Intel's "Unsynchronised Cross-Modifying Code
Operations Can Cause Unexpected Instruction Execution Results"
Erratum, which affects _every_ multiprocessor Intel P6 box.
It's Pentium 3 Erratum E49 if you want to look it up; the other
Intel P6s have it too, but with different numbers.
In short, the only safe way to do this sort of thing is to force
all other processors to wait on a barrier first, then modify the
code, then release the barrier.
On a general note, I wish people would pay more attention to Intel's
and AMD's errata documents. There are a number of things documented
in Intel's IA32 manual set which simply do not work in the real world
due to errata. Unsync cross-modifying code is one, the PAT is another.
/Mikael
next prev parent reply other threads:[~2002-10-03 12:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-03 12:26 Vamsi Krishna S .
2002-10-03 12:40 ` Mikael Pettersson [this message]
2002-10-03 13:01 ` Alan Cox
2002-10-03 13:32 Richard J Moore
2002-10-03 14:00 ` Alan Cox
2002-10-04 9:23 Richard J Moore
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=15772.15056.287602.502467@kim.it.uu.se \
--to=mikpe@csd.uu.se \
--cc=bsuparna@in.ibm.com \
--cc=grundym@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=richardj_moore@uk.ibm.com \
--cc=vamsi@in.ibm.com \
--cc=vamsi_krishna@in.ibm.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
all inboxes | Powered by JetHome®