Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/sys/arch/i386/stand/lib Pull up revision 1.4 (requested b...



details:   https://anonhg.NetBSD.org/src/rev/8a45656bf420
branches:  netbsd-3
changeset: 575945:8a45656bf420
user:      riz <riz%NetBSD.org@localhost>
date:      Mon May 30 00:23:01 2005 +0000

description:
Pull up revision 1.4 (requested by gavan in ticket #356):
Workaround for issues seen on VIA C3-based systems. PR port-i386/26007
Tested on ML5000 board. This may not fix the problem on all variations
of the
hardware, but it's likely that variations on the theme will. This workaround
is non-intrusive and should not affect any other CPUs.

diffstat:

 sys/arch/i386/stand/lib/realprot.S |  45 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diffs (74 lines):

diff -r 02abdcc0aaf5 -r 8a45656bf420 sys/arch/i386/stand/lib/realprot.S
--- a/sys/arch/i386/stand/lib/realprot.S        Sat May 28 18:39:42 2005 +0000
+++ b/sys/arch/i386/stand/lib/realprot.S        Mon May 30 00:23:01 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: realprot.S,v 1.3 2004/02/13 11:36:14 wiz Exp $ */
+/*     $NetBSD: realprot.S,v 1.3.14.1 2005/05/30 00:23:01 riz Exp $    */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -188,7 +188,34 @@
  * Based on the descripton in section 14.5 of the 80386 Programmer's
  * reference book.
  */
+/*
+ * EPIA_HACK
+ *
+ * VIA C3 processors don't seem to correctly switch back to executing
+ * 16 bit code after the switch to real mode and subsequent jump.
+ *
+ * It is speculated that the CPU is prefetching and decoding branch
+ * targets and not invalidating this buffer on the long jump.
+ *
+ * The precise reason for this hack working is still unknown, but
+ * it was determined experimentally on two theories:
+ * 1) Flush the pipeline with NOPs
+ * 2) call/ret after the return from prot_to_real seems to improve matters,
+ *    perhaps by making more work for the branch prediction/prefetch logic.
+ *
+ * Neither of these individually are effective, but this combination is
+ * determined experimentally to be sufficient.
+ */
 ENTRY(prot_to_real)
+#ifdef EPIA_HACK
+       .code32
+       call prot_to_real_main
+       .code16
+       call epia_nops
+       retl
+
+prot_to_real_main:
+#endif
        .code32
        pushl   %eax
 
@@ -240,6 +267,10 @@
        jne     1f
        pop     %bp
 
+#ifdef EPIA_HACK
+       call epia_nops 
+#endif
+
        sti
        popl    %eax
        retl
@@ -258,6 +289,18 @@
 dump_eax_buff:
        . = . + 16
 
+#ifdef EPIA_HACK
+epia_nops:
+       .code16
+       nop
+       nop
+       nop
+       nop
+       nop
+       nop
+       ret
+#endif
+
 /* vtophys(void *)
  * convert boot time 'linear' address to a physical one
  */



Home | Main Index | Thread Index | Old Index