diff options
author | neel <neel@FreeBSD.org> | 2012-09-26 00:06:17 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2012-09-26 00:06:17 +0000 |
commit | 5dbc1ca26acaa3175dae7b9d0c45151fba0275ab (patch) | |
tree | c995abae29493221169dd97e854cf339038315e3 /usr.sbin/bhyve | |
parent | bc269b51afe43aab28df7ea0d543c167bb7c7d2e (diff) | |
download | FreeBSD-src-5dbc1ca26acaa3175dae7b9d0c45151fba0275ab.zip FreeBSD-src-5dbc1ca26acaa3175dae7b9d0c45151fba0275ab.tar.gz |
Add an option "-a" to present the local apic in the XAPIC mode instead of the
default X2APIC mode to the guest.
Diffstat (limited to 'usr.sbin/bhyve')
-rw-r--r-- | usr.sbin/bhyve/fbsdrun.c | 27 | ||||
-rw-r--r-- | usr.sbin/bhyve/fbsdrun.h | 1 | ||||
-rw-r--r-- | usr.sbin/bhyve/spinup_ap.c | 6 |
3 files changed, 31 insertions, 3 deletions
diff --git a/usr.sbin/bhyve/fbsdrun.c b/usr.sbin/bhyve/fbsdrun.c index df2238a..b8bebba 100644 --- a/usr.sbin/bhyve/fbsdrun.c +++ b/usr.sbin/bhyve/fbsdrun.c @@ -84,7 +84,7 @@ int guest_ncpus; static int pincpu = -1; static int guest_vcpu_mux; -static int guest_vmexit_on_hlt, guest_vmexit_on_pause; +static int guest_vmexit_on_hlt, guest_vmexit_on_pause, disable_x2apic; static int foundcpus; @@ -128,8 +128,9 @@ usage(int code) { fprintf(stderr, - "Usage: %s [-ehBHIP][-g <gdb port>][-z <hz>][-s <pci>]" + "Usage: %s [-aehBHIP][-g <gdb port>][-z <hz>][-s <pci>]" "[-S <pci>][-p pincpu][-n <pci>][-m lowmem][-M highmem] <vm>\n" + " -a: local apic is in XAPIC mode (default is X2APIC)\n" " -g: gdb port (default is %d and 0 means don't open)\n" " -c: # cpus (default 1)\n" " -p: pin vcpu 'n' to host cpu 'pincpu + n'\n" @@ -174,6 +175,13 @@ fbsdrun_add_oemtbl(void *tbl, int tblsz) } int +fbsdrun_disable_x2apic(void) +{ + + return (disable_x2apic); +} + +int fbsdrun_vmexit_on_pause(void) { @@ -553,8 +561,11 @@ main(int argc, char *argv[]) guest_ncpus = 1; ioapic = 0; - while ((c = getopt(argc, argv, "ehBHIPxp:g:c:z:s:S:n:m:M:")) != -1) { + while ((c = getopt(argc, argv, "aehBHIPxp:g:c:z:s:S:n:m:M:")) != -1) { switch (c) { + case 'a': + disable_x2apic = 1; + break; case 'B': inject_bkpt = 1; break; @@ -656,6 +667,16 @@ main(int argc, char *argv[]) handler[VM_EXITCODE_PAUSE] = vmexit_pause; } + if (fbsdrun_disable_x2apic()) + err = vm_set_x2apic_state(ctx, BSP, X2APIC_DISABLED); + else + err = vm_set_x2apic_state(ctx, BSP, X2APIC_ENABLED); + + if (err) { + printf("Unable to set x2apic state (%d)\n", err); + exit(1); + } + if (lomem_sz != 0) { lomem_addr = vm_map_memory(ctx, 0, lomem_sz); if (lomem_addr == (char *) MAP_FAILED) { diff --git a/usr.sbin/bhyve/fbsdrun.h b/usr.sbin/bhyve/fbsdrun.h index 8106122..0b9fe7d 100644 --- a/usr.sbin/bhyve/fbsdrun.h +++ b/usr.sbin/bhyve/fbsdrun.h @@ -50,4 +50,5 @@ void fbsdrun_add_oemtbl(void *tbl, int tblsz); int fbsdrun_muxed(void); int fbsdrun_vmexit_on_hlt(void); int fbsdrun_vmexit_on_pause(void); +int fbsdrun_disable_x2apic(void); #endif diff --git a/usr.sbin/bhyve/spinup_ap.c b/usr.sbin/bhyve/spinup_ap.c index e845515..3aa3b65 100644 --- a/usr.sbin/bhyve/spinup_ap.c +++ b/usr.sbin/bhyve/spinup_ap.c @@ -156,6 +156,12 @@ spinup_ap(struct vmctx *ctx, int vcpu, int newcpu, uint64_t rip) assert(error == 0); } + if (fbsdrun_disable_x2apic()) + error = vm_set_x2apic_state(ctx, newcpu, X2APIC_DISABLED); + else + error = vm_set_x2apic_state(ctx, newcpu, X2APIC_ENABLED); + assert(error == 0); + /* * There are 2 startup modes possible here: * - if the CPU supports 'unrestricted guest' mode, the spinup can |