Author: royger
Date: Fri Apr  6 16:22:14 2018
New Revision: 332109
URL: https://svnweb.freebsd.org/changeset/base/332109

Log:
  x86: fix trampoline memory allocation after r332073
  
  Add the missing breaks in the for loops, in order to exit the loop
  when a suitable entry is found.
  
  Also switch amd64 native_start_all_aps to use PHYS_TO_DMAP in order to
  find the virtual address of the boot_trampoline and the initial page
  tables.
  
  Reported and tested by:       pho
  Sponsored by:         Citrix Systems R&D

Modified:
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/amd64/amd64/mp_machdep.c
==============================================================================
--- head/sys/amd64/amd64/mp_machdep.c   Fri Apr  6 15:57:20 2018        
(r332108)
+++ head/sys/amd64/amd64/mp_machdep.c   Fri Apr  6 16:22:14 2018        
(r332109)
@@ -128,6 +128,7 @@ mp_bootaddress(vm_paddr_t *physmap, unsigned int *phys
                            sizeof(*physmap) * (*physmap_idx - i + 2));
                        *physmap_idx -= 2;
                }
+               break;
        }
 
        if (!allocated) {
@@ -336,7 +337,6 @@ init_secondary(void)
 int
 native_start_all_aps(void)
 {
-       vm_offset_t va = boot_address + KERNBASE;
        u_int64_t *pt4, *pt3, *pt2;
        u_int32_t mpbioswarmvec;
        int apic_id, cpu, i;
@@ -344,13 +344,11 @@ native_start_all_aps(void)
 
        mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);
 
-       /* install the AP 1st level boot code */
-       pmap_kenter(va, boot_address);
-       pmap_invalidate_page(kernel_pmap, va);
-       bcopy(mptramp_start, (void *)va, bootMP_size);
+       /* copy the AP 1st level boot code */
+       bcopy(mptramp_start, (void *)PHYS_TO_DMAP(boot_address), bootMP_size);
 
        /* Locate the page tables, they'll be below the trampoline */
-       pt4 = (u_int64_t *)(uintptr_t)(mptramp_pagetables + KERNBASE);
+       pt4 = (uint64_t *)PHYS_TO_DMAP(mptramp_pagetables);
        pt3 = pt4 + (PAGE_SIZE) / sizeof(u_int64_t);
        pt2 = pt3 + (PAGE_SIZE) / sizeof(u_int64_t);
 

Modified: head/sys/x86/x86/mp_x86.c
==============================================================================
--- head/sys/x86/x86/mp_x86.c   Fri Apr  6 15:57:20 2018        (r332108)
+++ head/sys/x86/x86/mp_x86.c   Fri Apr  6 16:22:14 2018        (r332109)
@@ -947,6 +947,7 @@ alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int 
                            sizeof(*physmap) * (*physmap_idx - i + 2));
                        *physmap_idx -= 2;
                }
+               break;
        }
 
        if (!allocated) {
_______________________________________________
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