Print this page
OS-6546 Use PCID if KPTI is enabled

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/vm/kboot_mmu.c
          +++ new/usr/src/uts/i86pc/vm/kboot_mmu.c
↓ open down ↓ 137 lines elided ↑ open up ↑
 138  138          if (!writeable)
 139  139                  pt_bits &= ~PT_WRITABLE;
 140  140          if (HYPERVISOR_update_va_mapping((uintptr_t)window,
 141  141              pa_to_ma(physaddr) | pt_bits, UVMF_INVLPG | UVMF_LOCAL) < 0)
 142  142                  bop_panic("HYPERVISOR_update_va_mapping() failed");
 143  143  #else
 144  144          if (kbm_pae_support)
 145  145                  *((x86pte_t *)pte_to_window) = physaddr | pt_bits;
 146  146          else
 147  147                  *((x86pte32_t *)pte_to_window) = physaddr | pt_bits;
 148      -        mmu_tlbflush_entry(window);
      148 +        mmu_invlpg(window);
 149  149  #endif
 150  150          DBG(window);
 151  151          return (window);
 152  152  }
 153  153  
 154  154  /*
 155  155   * Add a mapping for the physical page at the given virtual address.
 156  156   */
 157  157  void
 158  158  kbm_map(uintptr_t va, paddr_t pa, uint_t level, uint_t is_kernel)
↓ open down ↓ 29 lines elided ↑ open up ↑
 188  188                  bop_panic("kbm_map: find_pte returned NULL");
 189  189  
 190  190  #ifdef __xpv
 191  191          if (HYPERVISOR_update_va_mapping(va, pteval, UVMF_INVLPG | UVMF_LOCAL))
 192  192                  bop_panic("HYPERVISOR_update_va_mapping() failed");
 193  193  #else
 194  194          if (kbm_pae_support)
 195  195                  *ptep = pteval;
 196  196          else
 197  197                  *((x86pte32_t *)ptep) = pteval;
 198      -        mmu_tlbflush_entry((caddr_t)va);
      198 +        mmu_invlpg((caddr_t)va);
 199  199  #endif
 200  200  }
 201  201  
 202  202  #ifdef __xpv
 203  203  
 204  204  /*
 205  205   * Add a mapping for the machine page at the given virtual address.
 206  206   */
 207  207  void
 208  208  kbm_map_ma(maddr_t ma, uintptr_t va, uint_t level)
↓ open down ↓ 133 lines elided ↑ open up ↑
 342  342                  uint_t  probe_only = 1;
 343  343  
 344  344                  ptep = find_pte(va, NULL, level, probe_only);
 345  345                  if (ptep == NULL)
 346  346                          return;
 347  347  
 348  348                  if (kbm_pae_support)
 349  349                          *ptep = 0;
 350  350                  else
 351  351                          *((x86pte32_t *)ptep) = 0;
 352      -                mmu_tlbflush_entry((caddr_t)va);
      352 +                mmu_invlpg((caddr_t)va);
 353  353  #endif
 354  354          }
 355  355  }
 356  356  
 357  357  
 358  358  /*
 359  359   * Change a boot loader page table 4K mapping.
 360  360   * Returns the pfn of the old mapping.
 361  361   */
 362  362  pfn_t
↓ open down ↓ 18 lines elided ↑ open up ↑
 381  381                  old_pte = *((x86pte32_t *)ptep);
 382  382  
 383  383  #ifdef __xpv
 384  384          if (HYPERVISOR_update_va_mapping(va, pte_val, UVMF_INVLPG | UVMF_LOCAL))
 385  385                  bop_panic("HYPERVISOR_update_va_mapping() failed");
 386  386  #else
 387  387          if (kbm_pae_support)
 388  388                  *((x86pte_t *)ptep) = pte_val;
 389  389          else
 390  390                  *((x86pte32_t *)ptep) = pte_val;
 391      -        mmu_tlbflush_entry((caddr_t)va);
      391 +        mmu_invlpg((caddr_t)va);
 392  392  #endif
 393  393  
 394  394          if (!(old_pte & PT_VALID) || ma_to_pa(old_pte) == -1)
 395  395                  return (PFN_INVALID);
 396  396          return (mmu_btop(ma_to_pa(old_pte)));
 397  397  }
 398  398  
 399  399  
 400  400  /*
 401  401   * Change a boot loader page table 4K mapping to read only.
↓ open down ↓ 12 lines elided ↑ open up ↑
 414  414          level_t level = 0;
 415  415  
 416  416          ptep = find_pte(va, NULL, level, 0);
 417  417          if (ptep == NULL)
 418  418                  bop_panic("kbm_read_only: find_pte returned NULL");
 419  419  
 420  420          if (kbm_pae_support)
 421  421                  *ptep = pte_val;
 422  422          else
 423  423                  *((x86pte32_t *)ptep) = pte_val;
 424      -        mmu_tlbflush_entry((caddr_t)va);
      424 +        mmu_invlpg((caddr_t)va);
 425  425  #endif
 426  426  }
 427  427  
 428  428  /*
 429  429   * interfaces for kernel debugger to access physical memory
 430  430   */
 431  431  static x86pte_t save_pte;
 432  432  
 433  433  void *
 434  434  kbm_push(paddr_t pa)
↓ open down ↓ 17 lines elided ↑ open up ↑
 452  452  {
 453  453  #ifdef __xpv
 454  454          if (HYPERVISOR_update_va_mapping((uintptr_t)window, save_pte,
 455  455              UVMF_INVLPG | UVMF_LOCAL) < 0)
 456  456                  bop_panic("HYPERVISOR_update_va_mapping() failed");
 457  457  #else
 458  458          if (kbm_pae_support)
 459  459                  *((x86pte_t *)pte_to_window) = save_pte;
 460  460          else
 461  461                  *((x86pte32_t *)pte_to_window) = save_pte;
 462      -        mmu_tlbflush_entry(window);
      462 +        mmu_invlpg(window);
 463  463  #endif
 464  464  }
 465  465  
 466  466  x86pte_t
 467  467  get_pteval(paddr_t table, uint_t index)
 468  468  {
 469  469          void *table_ptr = kbm_remap_window(table, 0);
 470  470  
 471  471          if (kbm_pae_support)
 472  472                  return (((x86pte_t *)table_ptr)[index]);
↓ open down ↓ 46 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX