Re: Watchpoint problems in 2.2 and later series x86 kernels (PATCH)

From: James Cownie (jcownie@etnus.com)
Date: Fri Jun 23 2000 - 09:00:17 EST


Here is a patch against 2.2.16 which ensures that watchpoints in user
code are not ignored.

Rather than restoring dr7 on every return to user space this simply
ignores the watchpoint debug trap while in kernel mode but does _not_
clear dr7. This means that we may see multiple traps if the kernel is
accessing a watchpointed area a lot, and that will be slow. However,
this will only happen to processes which have watchpoints enabled, and
having them run slowly seems preferable to penalising _all_ system
calls even when no watchpoints are enabled anywhere, which is the
alternative.

We will still not report to the user a system call overwriting watched
data, which is unpleasant. We should report that. However that seems
hard and potentially expensive.

At least this patch fixes the problem that watchpoints in user code
are disabled until the process is descheduled if the kernel had
hit one of them. Now all user code will see watchpoints, while kernel
code will skip them. This is, at least, explicable behaviour, even if
not desirable.

Enjoy.

-- Jim

James Cownie <jcownie@etnus.com>
Etnus, Inc. +44 117 9071438
http://www.etnus.com

begin 644 watchpoint-patch
M"BHJ*B!T<F%P<RYC+C(N,BXQ-@E7960@2G5N("`W(#(R.C(V.C0R(#(P,#`*
M+2TM('1R87!S+F,)1G)I($IU;B`R,R`Q-#HS-3HQ,"`R,#`P"BHJ*BHJ*BHJ
M*BHJ*BHJ*@HJ*BH@,S8W+#,W,B`J*BHJ"BTM+2`S-C<L,S<U("TM+2T*("`*
M("`)7U]A<VU?7R!?7W9O;&%T:6QE7U\H(FUO=FP@)25D8C8L)3`B(#H@(CUR
M(B`H8V]N9&ET:6]N*2D["B`@"BL@"2\J($5N<W5R92!T:&4@9&5B=6<@<W1A
M='5S(')E9VES=&5R(&ES('9I<VEB;&4@=&\@<'1R86-E("AO<B!T:&4@<')O
M8V5S<R!I='-E;&8I("HO"BL@"71S:RT^='-S+F1E8G5G<F5G6S9=(#T@8V]N
M9&ET:6]N.PHK(`H@(`DO*B!-87-K(&]U="!S<'5R:6]U<R!41B!E<G)O<G,@
M9'5E('1O(&QA>GD@5$8@8VQE87)I;F<@*B\*("`):68@*&-O;F1I=&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!I<R!A('1R87`@=&AE(&EN<W1R=6-T
M:6]N(&AA<R!C;VUP;&5T960L(&%N9"!W92!C86X@:G5S="`*(2`)("H@<F5S
M=6UE(&%T('1H92!N97AT(&EN<W1R=6-T:6]N+@HA(`D@*B!)9B!W92!W97)E
M('1O(&-L96%R('1H92!D96)U9R!R96=I<W1E<BP@=&AE;B!W92!W;W5L9"!N
M965D('1O(')E<W1O<F4*(2`)("H@:70@:6X@979E<GD@<F5T=7)N('1O('5S
M97(@;&5V96P@*&]R(&UI<W,@=7-E<B!L979E;"!W871C:'!O:6YT<RDN(`HA
M(`D@*B!)9B!W92!J=7-T(&QE879E(&ET(&]N(&AE<F4@=V4@(&UA>2!T86ME
M(&$@;G5M8F5R(&]F('1R87!S(&EN('1H92!K97)N96PL(`HA(`D@*B!B=70@
M;VYL>2!F;W(@82!P<F]C97-S('=H:6-H(&AA<R!W871C:'!O:6YT<R!E;F%B
M;&5D+"!A;F0@=&AA="!C86X@"B$@"2`J(')E87-O;F%B;'D@<&%Y('-I;F-E
M(&ET(&ES(&$@<F%R92!O8V-U<G)E;F-E+@HA(`D@*B!)="!W;W5L9"!B92!G
M;V]D('1O(&)E(&%B;&4@=&\@<VEG;F%L('1H92!P<F]C97-S+"!S:6YC92!C
M;VUP;&5T96QY"B$@"2`J(&EG;F]R:6YG('1H92!T<F%P(&UE86YS('1H870@
M=V%T8VAP;VEN=&5D(&1A=&$@8V%N(&)E('-I;&5N=&QY(&]V97)W<FET=&5N
M"B$@"2`J(&)Y(&$@<WES=&5M(&-A;&PL(&AO=V5V97(@=&AA="!S965M<R!H
M87)D+@HA(`D@*B\*(2`):68@*"AR96=S+3YX8W,@)B`S*2`]/2`P*2`*(2`)
M("`@("`@("!R971U<FX["B`@"B`@"2\J($]K+"!F:6YA;&QY('-O;65T:&EN
L9R!W92!C86X@:&%N9&QE("HO"B`@"71S:RT^='-S+G1R87!?;F\@/2`Q.PH`
`
end

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Jun 23 2000 - 21:00:26 EST