intel_utils.c (267992) | intel_utils.c (277023) |
---|---|
1/*- 2 * Copyright (c) 2013 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Konstantin Belousov <kib@FreeBSD.org> 6 * under sponsorship from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2013 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Konstantin Belousov <kib@FreeBSD.org> 6 * under sponsorship from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/x86/iommu/intel_utils.c 267992 2014-06-28 03:56:17Z hselasky $"); | 31__FBSDID("$FreeBSD: head/sys/x86/iommu/intel_utils.c 277023 2015-01-11 20:27:15Z kib $"); |
32 33#include <sys/param.h> 34#include <sys/bus.h> 35#include <sys/kernel.h> 36#include <sys/lock.h> 37#include <sys/malloc.h> 38#include <sys/memdesc.h> 39#include <sys/mutex.h> --- 309 unchanged lines hidden (view full) --- 349 (DMAR_PGF_WAITOK | DMAR_PGF_OBJL)) 350 VM_OBJECT_WLOCK(obj); 351 else if ((flags & (DMAR_PGF_WAITOK | DMAR_PGF_OBJL)) == 0) 352 VM_OBJECT_WUNLOCK(obj); 353 return ((void *)sf_buf_kva(*sf)); 354} 355 356void | 32 33#include <sys/param.h> 34#include <sys/bus.h> 35#include <sys/kernel.h> 36#include <sys/lock.h> 37#include <sys/malloc.h> 38#include <sys/memdesc.h> 39#include <sys/mutex.h> --- 309 unchanged lines hidden (view full) --- 349 (DMAR_PGF_WAITOK | DMAR_PGF_OBJL)) 350 VM_OBJECT_WLOCK(obj); 351 else if ((flags & (DMAR_PGF_WAITOK | DMAR_PGF_OBJL)) == 0) 352 VM_OBJECT_WUNLOCK(obj); 353 return ((void *)sf_buf_kva(*sf)); 354} 355 356void |
357dmar_unmap_pgtbl(struct sf_buf *sf, bool coherent) | 357dmar_unmap_pgtbl(struct sf_buf *sf) |
358{ | 358{ |
359 vm_page_t m; | |
360 | 359 |
361 m = sf_buf_page(sf); | |
362 sf_buf_free(sf); 363 sched_unpin(); | 360 sf_buf_free(sf); 361 sched_unpin(); |
362} |
|
364 | 363 |
364static void 365dmar_flush_transl_to_ram(struct dmar_unit *unit, void *dst, size_t sz) 366{ 367 368 if (DMAR_IS_COHERENT(unit)) 369 return; |
|
365 /* 366 * If DMAR does not snoop paging structures accesses, flush 367 * CPU cache to memory. 368 */ | 370 /* 371 * If DMAR does not snoop paging structures accesses, flush 372 * CPU cache to memory. 373 */ |
369 if (!coherent) 370 pmap_invalidate_cache_pages(&m, 1); | 374 pmap_invalidate_cache_range((uintptr_t)dst, (uintptr_t)dst + sz, 375 TRUE); |
371} 372 | 376} 377 |
378void 379dmar_flush_pte_to_ram(struct dmar_unit *unit, dmar_pte_t *dst) 380{ 381 382 dmar_flush_transl_to_ram(unit, dst, sizeof(*dst)); 383} 384 385void 386dmar_flush_ctx_to_ram(struct dmar_unit *unit, dmar_ctx_entry_t *dst) 387{ 388 389 dmar_flush_transl_to_ram(unit, dst, sizeof(*dst)); 390} 391 392void 393dmar_flush_root_to_ram(struct dmar_unit *unit, dmar_root_entry_t *dst) 394{ 395 396 dmar_flush_transl_to_ram(unit, dst, sizeof(*dst)); 397} 398 |
|
373/* 374 * Load the root entry pointer into the hardware, busily waiting for 375 * the completion. 376 */ 377int 378dmar_load_root_entry_ptr(struct dmar_unit *unit) 379{ 380 vm_page_t root_entry; --- 185 unchanged lines hidden --- | 399/* 400 * Load the root entry pointer into the hardware, busily waiting for 401 * the completion. 402 */ 403int 404dmar_load_root_entry_ptr(struct dmar_unit *unit) 405{ 406 vm_page_t root_entry; --- 185 unchanged lines hidden --- |