Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

instruction: [wbinvd]

1 view
Skip to first unread message

Iman Habib

unread,
Jul 22, 2001, 3:59:57 PM7/22/01
to
Hi.

I just came across a small sourcefile explaining how to
disable the cache(s) on a Intel CPU (and the 486).

Looking at the source a I found the instruction:

WBINVD

After reading a bit more about it in the Intel Manual
(vol. 2, page: 748) I found out that the instruction
is supposed to write back, flush and invalidate the
cache but I wonder... Does this state apply to all
processes on the CPU or just the single process
that runs the instruction?


cheers
/iman


... the source ...
;/***************************************************************************
;* DisableCache() *
;* *
;* This routine disables cache(s) on a 486 or Pentium processor *
;* *
;* NOTE: due to the protection schemes incorporated into the 486 and *
;* Pentium processors, it will NOT work in virtual 8086 mode. *
;* *
;* written on Thursday, 2 November 1995 by Ed Beroset *
;* and released to the public domain by the author *
;***************************************************************************/
.486P

CR0_CD equ 040000000h ; Cache Disable bit of CR0
CR0_NW equ 020000000h ; Not Write-through bit of CR0

DisableCache proc
pushf ; save the flags
push eax ; save eax
cli ; disable interrupts while we do this
mov eax,cr0 ; read CR0
or eax,CR0_CD ; set CD but not NW bit of CR0
mov cr0,eax ; cache is now disabled
wbinvd ; flush and invalidate cache

; the cache is effectively disabled at this point, but memory
; consistency will be maintained. To completely disable cache,
; the following two lines may used as well:

or eax,CR0_NW ; now set the NW bit
mov cr0,eax ; turn off the cache entirely
pop eax ; restore eax
popf ; restore the flags
ret ; return to caller
DisableCache endp
end


Karl Olsen

unread,
Jul 22, 2001, 8:35:51 PM7/22/01
to
Iman Habib <pixel...@hotmail.com> wrote in message
news:9jefmc$p9e$1...@nyheter.chalmers.se...

> I just came across a small sourcefile explaining how to
> disable the cache(s) on a Intel CPU (and the 486).
>
> Looking at the source a I found the instruction:
>
> WBINVD
>
> After reading a bit more about it in the Intel Manual
> (vol. 2, page: 748) I found out that the instruction
> is supposed to write back, flush and invalidate the
> cache but I wonder... Does this state apply to all
> processes on the CPU or just the single process
> that runs the instruction?

The instruction writes back and invalidates all data, regardless of
processes. The caches are physically mapped and know nothing about
processes.

Regards,
Karl Olsen

Daniel Pfeffer

unread,
Jul 23, 2001, 1:22:45 PM7/23/01
to
"Iman Habib" <pixel...@hotmail.com> wrote in message
news:9jefmc$p9e$1...@nyheter.chalmers.se...

the WBINVD instruction works on the _processor_ cache, which is shared by
all code running on the machine.


Daniel Pfeffer


0 new messages