Author: avg
Date: Tue Oct 25 10:34:14 2016
New Revision: 307903
URL: https://svnweb.freebsd.org/changeset/base/307903

Log:
  vmm/svm: iopm_bitmap and msr_bitmap must be contiguous in physical memory
  
  To achieve that the whole svm_softc is allocated with contigmalloc now.
  It would be more effient to de-embed those arrays and allocate only them
  with contigmalloc.
  
  Previously, if malloc(9) used non-contiguous pages for the arrays, then
  random bits in physical pages next to the first page would be used to
  determine permissions for I/O port and MSR accesses.  That could result
  in a guest dangerously modifying the host hardware configuration.
  
  One example is that sometimes NMI watchdog driver in a Linux guest
  would be able to configure a performance counter on a host system.
  The counter would generate an interrupt and if hwpmc(4) driver is loaded
  on the host, then the interrupt would be delivered as an NMI.
  
  Discussed with:       jhb
  Reviewed by:  grehan
  MFC after:    2 weeks
  Differential Revision: https://reviews.freebsd.org/D8321

Modified:
  head/sys/amd64/vmm/amd/svm.c

Modified: head/sys/amd64/vmm/amd/svm.c
==============================================================================
--- head/sys/amd64/vmm/amd/svm.c        Tue Oct 25 07:48:19 2016        
(r307902)
+++ head/sys/amd64/vmm/amd/svm.c        Tue Oct 25 10:34:14 2016        
(r307903)
@@ -517,7 +517,8 @@ svm_vminit(struct vm *vm, pmap_t pmap)
        vm_paddr_t msrpm_pa, iopm_pa, pml4_pa;  
        int i;
 
-       svm_sc = malloc(sizeof (struct svm_softc), M_SVM, M_WAITOK | M_ZERO);
+       svm_sc = contigmalloc(sizeof (*svm_sc), M_SVM, M_WAITOK | M_ZERO,
+           0, BUS_SPACE_MAXADDR, PAGE_SIZE, 0);
        svm_sc->vm = vm;
        svm_sc->nptp = (vm_offset_t)vtophys(pmap->pm_pml4);
 
@@ -2042,7 +2043,7 @@ svm_vmcleanup(void *arg)
 {
        struct svm_softc *sc = arg;
 
-       free(sc, M_SVM);
+       contigfree(sc, sizeof (*sc), M_SVM);
 }
 
 static register_t *
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to