* Determine the appropriate bits to set in a PTE or PDE for a specified * caching mode. */
| 2528 | * caching mode. |
| 2529 | */ |
| 2530 | int |
| 2531 | pmap_cache_bits(pmap_t pmap, int mode, boolean_t is_pde) |
| 2532 | { |
| 2533 | int cache_bits, pat_flag, pat_idx; |
| 2534 | |
| 2535 | if (!pmap_is_valid_memattr(pmap, mode)) |
| 2536 | panic("Unknown caching mode %d\n", mode); |
| 2537 | |
| 2538 | switch (pmap->pm_type) { |
| 2539 | case PT_X86: |
| 2540 | case PT_RVI: |
| 2541 | /* The PAT bit is different for PTE's and PDE's. */ |
| 2542 | pat_flag = is_pde ? X86_PG_PDE_PAT : X86_PG_PTE_PAT; |
| 2543 | |
| 2544 | /* Map the caching mode to a PAT index. */ |
| 2545 | pat_idx = pat_index[mode]; |
| 2546 | |
| 2547 | /* Map the 3-bit index value into the PAT, PCD, and PWT bits. */ |
| 2548 | cache_bits = 0; |
| 2549 | if (pat_idx & 0x4) |
| 2550 | cache_bits |= pat_flag; |
| 2551 | if (pat_idx & 0x2) |
| 2552 | cache_bits |= PG_NC_PCD; |
| 2553 | if (pat_idx & 0x1) |
| 2554 | cache_bits |= PG_NC_PWT; |
| 2555 | break; |
| 2556 | |
| 2557 | case PT_EPT: |
| 2558 | cache_bits = EPT_PG_IGNORE_PAT | EPT_PG_MEMORY_TYPE(mode); |
| 2559 | break; |
| 2560 | |
| 2561 | default: |
| 2562 | panic("unsupported pmap type %d", pmap->pm_type); |
| 2563 | } |
| 2564 | |
| 2565 | return (cache_bits); |
| 2566 | } |
| 2567 | |
| 2568 | static int |
| 2569 | pmap_cache_mask(pmap_t pmap, boolean_t is_pde) |
no test coverage detected