MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pmap_force_invalidate_cache_range

Function pmap_force_invalidate_cache_range

freebsd/i386/i386/pmap_base.c:331–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331void
332pmap_force_invalidate_cache_range(vm_offset_t sva, vm_offset_t eva)
333{
334
335 sva &= ~(vm_offset_t)(cpu_clflush_line_size - 1);
336 if (eva - sva >= PMAP_CLFLUSH_THRESHOLD) {
337 /*
338 * The supplied range is bigger than 2MB.
339 * Globally invalidate cache.
340 */
341 pmap_invalidate_cache();
342 return;
343 }
344
345#ifdef DEV_APIC
346 /*
347 * XXX: Some CPUs fault, hang, or trash the local APIC
348 * registers if we use CLFLUSH on the local APIC
349 * range. The local APIC is always uncached, so we
350 * don't need to flush for that range anyway.
351 */
352 if (pmap_kextract(sva) == lapic_paddr)
353 return;
354#endif
355
356 if ((cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0) {
357 /*
358 * Do per-cache line flush. Use the sfence
359 * instruction to insure that previous stores are
360 * included in the write-back. The processor
361 * propagates flush to other processors in the cache
362 * coherence domain.
363 */
364 sfence();
365 for (; sva < eva; sva += cpu_clflush_line_size)
366 clflushopt(sva);
367 sfence();
368 } else {
369 /*
370 * Writes are ordered by CLFLUSH on Intel CPUs.
371 */
372 if (cpu_vendor_id != CPU_VENDOR_INTEL)
373 mfence();
374 for (; sva < eva; sva += cpu_clflush_line_size)
375 clflush(sva);
376 if (cpu_vendor_id != CPU_VENDOR_INTEL)
377 mfence();
378 }
379}
380
381static void
382pmap_invalidate_cache_range_all(vm_offset_t sva, vm_offset_t eva)

Callers

nothing calls this directly

Calls 6

pmap_invalidate_cacheFunction · 0.70
pmap_kextractFunction · 0.70
sfenceFunction · 0.50
clflushoptFunction · 0.50
mfenceFunction · 0.50
clflushFunction · 0.50

Tested by

no test coverage detected