svn commit: r256062 - head/usr.sbin/bhyve

Peter Grehan grehan at FreeBSD.org
Fri Oct 4 23:29:08 UTC 2013


Author: grehan
Date: Fri Oct  4 23:29:07 2013
New Revision: 256062
URL: http://svnweb.freebsd.org/changeset/base/256062

Log:
  Remove obsolete cmd-line options and code associated with
  these.
   The mux-vcpus option may return at some point, given it's utility
  in finding bhyve (and FreeBSD) bugs.
  
  Approved by:	re@ (blanket)
  Discussed with:	neel@

Modified:
  head/usr.sbin/bhyve/bhyverun.c
  head/usr.sbin/bhyve/bhyverun.h
  head/usr.sbin/bhyve/pit_8254.c

Modified: head/usr.sbin/bhyve/bhyverun.c
==============================================================================
--- head/usr.sbin/bhyve/bhyverun.c	Fri Oct  4 22:05:23 2013	(r256061)
+++ head/usr.sbin/bhyve/bhyverun.c	Fri Oct  4 23:29:07 2013	(r256062)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 #include <unistd.h>
 #include <assert.h>
 #include <errno.h>
-#include <signal.h>
 #include <pthread.h>
 #include <pthread_np.h>
 
@@ -61,9 +60,6 @@ __FBSDID("$FreeBSD$");
 #include "spinup_ap.h"
 #include "rtc.h"
 
-#define	DEFAULT_GUEST_HZ	100
-#define	DEFAULT_GUEST_TSLICE	200
-
 #define GUEST_NIO_PORT		0x488	/* guest upcalls via i/o port */
 
 #define	VMEXIT_SWITCH		0	/* force vcpu switch in mux mode */
@@ -77,14 +73,11 @@ __FBSDID("$FreeBSD$");
 
 typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu);
 
-int guest_tslice = DEFAULT_GUEST_TSLICE;
-int guest_hz = DEFAULT_GUEST_HZ;
 char *vmname;
 
 int guest_ncpus;
 
 static int pincpu = -1;
-static int guest_vcpu_mux;
 static int guest_vmexit_on_hlt, guest_vmexit_on_pause, disable_x2apic;
 
 static int foundcpus;
@@ -102,7 +95,7 @@ static void vm_loop(struct vmctx *ctx, i
 
 struct vm_exit vmexit[VM_MAXCPU];
 
-struct fbsdstats {
+struct bhyvestats {
         uint64_t        vmexit_bogus;
         uint64_t        vmexit_bogus_switch;
         uint64_t        vmexit_hlt;
@@ -125,28 +118,24 @@ usage(int code)
 {
 
         fprintf(stderr,
-                "Usage: %s [-aehABHIP][-g <gdb port>][-z <hz>][-s <pci>]"
-		"[-S <pci>][-p pincpu][-n <pci>][-m lowmem][-M highmem]"
+                "Usage: %s [-aehAHIP][-g <gdb port>][-s <pci>][-S <pci>]"
+		"[-c vcpus][-p pincpu][-m mem]"
 		" <vmname>\n"
 		"       -a: local apic is in XAPIC mode (default is X2APIC)\n"
 		"       -A: create an ACPI table\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"
-		"       -B: inject breakpoint exception on vm entry\n"
 		"       -H: vmexit from the guest on hlt\n"
 		"       -I: present an ioapic to the guest\n"
 		"       -P: vmexit from the guest on pause\n"
 		"	-e: exit on unhandled i/o access\n"
 		"       -h: help\n"
-		"       -z: guest hz (default is %d)\n"
 		"       -s: <slot,driver,configinfo> PCI slot config\n"
 		"       -S: <slot,driver,configinfo> legacy PCI slot config\n"
-		"       -m: memory size in MB\n"
-		"       -x: mux vcpus to 1 hcpu\n"
-		"       -t: mux vcpu timeslice hz (default %d)\n",
-		progname, DEFAULT_GDB_PORT, DEFAULT_GUEST_HZ,
-		DEFAULT_GUEST_TSLICE);
+		"       -m: memory size in MB\n",
+		progname, DEFAULT_GDB_PORT);
+
 	exit(code);
 }
 
@@ -178,13 +167,6 @@ fbsdrun_vmexit_on_hlt(void)
 	return (guest_vmexit_on_hlt);
 }
 
-int
-fbsdrun_muxed(void)
-{
-
-	return (guest_vcpu_mux);
-}
-
 static void *
 fbsdrun_start_thread(void *param)
 {
@@ -226,7 +208,7 @@ fbsdrun_addcpu(struct vmctx *ctx, int vc
 	vmexit[vcpu].rip = rip;
 	vmexit[vcpu].inst_length = 0;
 
-	if (vcpu == BSP || !guest_vcpu_mux){
+	if (vcpu == BSP) {
 		mt_vmm_info[vcpu].mt_ctx = ctx;
 		mt_vmm_info[vcpu].mt_vcpu = vcpu;
 	
@@ -264,17 +246,10 @@ static int
 vmexit_handle_notify(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu,
 		     uint32_t eax)
 {
-#if PG_DEBUG /* put all types of debug here */
-        if (eax == 0) {
-		pause_noswitch = 1;
-	} else if (eax == 1) {
-		pause_noswitch = 0;
-	} else {
-		pause_noswitch = 0;
-		if (eax == 5) {
-			vm_set_capability(ctx, *pvcpu, VM_CAP_MTRAP_EXIT, 1);
-		}
-	}
+#if BHYVE_DEBUG
+	/*
+	 * put guest-driven debug here
+	 */
 #endif
         return (VMEXIT_CONTINUE);
 }
@@ -337,11 +312,6 @@ vmexit_wrmsr(struct vmctx *ctx, struct v
 
 	newcpu = emulate_wrmsr(ctx, *pvcpu, vme->u.msr.code,vme->u.msr.wval);
 
-	if (guest_vcpu_mux && *pvcpu != newcpu) {
-                retval = VMEXIT_SWITCH;
-                *pvcpu = newcpu;
-        }
-        
         return (retval);
 }
 
@@ -354,11 +324,6 @@ vmexit_spinup_ap(struct vmctx *ctx, stru
 	newcpu = spinup_ap(ctx, *pvcpu,
 			   vme->u.spinup_ap.vcpu, vme->u.spinup_ap.rip);
 
-	if (guest_vcpu_mux && *pvcpu != newcpu) {
-		retval = VMEXIT_SWITCH;
-		*pvcpu = newcpu;
-	}
-        
 	return (retval);
 }
 
@@ -378,58 +343,42 @@ vmexit_vmx(struct vmctx *ctx, struct vm_
 	return (VMEXIT_ABORT);
 }
 
-static int bogus_noswitch = 1;
-
 static int
 vmexit_bogus(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
 {
+
 	stats.vmexit_bogus++;
 
-	if (!guest_vcpu_mux || guest_ncpus == 1 || bogus_noswitch) {
-		return (VMEXIT_RESTART);
-	} else {
-		stats.vmexit_bogus_switch++;
-		vmexit->inst_length = 0;
-		*pvcpu = -1;		
-		return (VMEXIT_SWITCH);
-	}
+	return (VMEXIT_RESTART);
 }
 
 static int
 vmexit_hlt(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
 {
+
 	stats.vmexit_hlt++;
-	if (fbsdrun_muxed()) {
-		*pvcpu = -1;
-		return (VMEXIT_SWITCH);
-	} else {
-		/*
-		 * Just continue execution with the next instruction. We use
-		 * the HLT VM exit as a way to be friendly with the host
-		 * scheduler.
-		 */
-		return (VMEXIT_CONTINUE);
-	}
-}
 
-static int pause_noswitch;
+	/*
+	 * Just continue execution with the next instruction. We use
+	 * the HLT VM exit as a way to be friendly with the host
+	 * scheduler.
+	 */
+	return (VMEXIT_CONTINUE);
+}
 
 static int
 vmexit_pause(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
 {
+
 	stats.vmexit_pause++;
 
-	if (fbsdrun_muxed() && !pause_noswitch) {
-		*pvcpu = -1;
-		return (VMEXIT_SWITCH);
-        } else {
-		return (VMEXIT_CONTINUE);
-	}
+	return (VMEXIT_CONTINUE);
 }
 
 static int
 vmexit_mtrap(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
 {
+
 	stats.vmexit_mtrap++;
 
 	return (VMEXIT_RESTART);
@@ -460,39 +409,6 @@ vmexit_paging(struct vmctx *ctx, struct 
 	return (VMEXIT_CONTINUE);
 }
 
-static void
-sigalrm(int sig)
-{
-	return;
-}
-
-static void
-setup_timeslice(void)
-{
-	struct sigaction sa;
-	struct itimerval itv;
-	int error;
-
-	/*
-	 * Setup a realtime timer to generate a SIGALRM at a
-	 * frequency of 'guest_tslice' ticks per second.
-	 */
-	sigemptyset(&sa.sa_mask);
-	sa.sa_flags = 0;
-	sa.sa_handler = sigalrm;
-	
-	error = sigaction(SIGALRM, &sa, NULL);
-	assert(error == 0);
-
-	itv.it_interval.tv_sec = 0;
-	itv.it_interval.tv_usec = 1000000 / guest_tslice;
-	itv.it_value.tv_sec = 0;
-	itv.it_value.tv_usec = 1000000 / guest_tslice;
-	
-	error = setitimer(ITIMER_REAL, &itv, NULL);
-	assert(error == 0);
-}
-
 static vmexit_handler_t handler[VM_EXITCODE_MAX] = {
 	[VM_EXITCODE_INOUT]  = vmexit_inout,
 	[VM_EXITCODE_VMX]    = vmexit_vmx,
@@ -511,9 +427,6 @@ vm_loop(struct vmctx *ctx, int vcpu, uin
 	int error, rc, prevcpu;
 	enum vm_exitcode exitcode;
 
-	if (guest_vcpu_mux)
-		setup_timeslice();
-
 	if (pincpu >= 0) {
 		CPU_ZERO(&mask);
 		CPU_SET(pincpu + vcpu, &mask);
@@ -550,15 +463,6 @@ vm_loop(struct vmctx *ctx, int vcpu, uin
                 rc = (*handler[exitcode])(ctx, &vmexit[vcpu], &vcpu);
 
 		switch (rc) {
-                case VMEXIT_SWITCH:
-			assert(guest_vcpu_mux);
-			if (vcpu == -1) {
-				stats.cpu_switch_rotate++;
-				vcpu = fbsdrun_get_next_cpu(prevcpu);
-			} else {
-				stats.cpu_switch_direct++;
-			}
-			/* fall through */
 		case VMEXIT_CONTINUE:
                         rip = vmexit[vcpu].rip + vmexit[vcpu].inst_length;
 			break;
@@ -594,21 +498,20 @@ num_vcpus_allowed(struct vmctx *ctx)
 int
 main(int argc, char *argv[])
 {
-	int c, error, gdb_port, inject_bkpt, tmp, err, ioapic, bvmcons;
+	int c, error, gdb_port, tmp, err, ioapic, bvmcons;
 	int max_vcpus;
 	struct vmctx *ctx;
 	uint64_t rip;
 	size_t memsize;
 
 	bvmcons = 0;
-	inject_bkpt = 0;
 	progname = basename(argv[0]);
 	gdb_port = DEFAULT_GDB_PORT;
 	guest_ncpus = 1;
 	ioapic = 0;
 	memsize = 256 * MB;
 
-	while ((c = getopt(argc, argv, "abehABHIPxp:g:c:z:s:S:n:m:")) != -1) {
+	while ((c = getopt(argc, argv, "abehAHIPp:g:c:s:S:m:")) != -1) {
 		switch (c) {
 		case 'a':
 			disable_x2apic = 1;
@@ -619,12 +522,6 @@ main(int argc, char *argv[])
 		case 'b':
 			bvmcons = 1;
 			break;
-		case 'B':
-			inject_bkpt = 1;
-			break;
-		case 'x':
-			guest_vcpu_mux = 1;
-			break;
 		case 'p':
 			pincpu = atoi(optarg);
 			break;
@@ -634,12 +531,6 @@ main(int argc, char *argv[])
 		case 'g':
 			gdb_port = atoi(optarg);
 			break;
-		case 'z':
-			guest_hz = atoi(optarg);
-			break;
-		case 't':
-			guest_tslice = atoi(optarg);
-			break;
 		case 's':
 			if (pci_parse_slot(optarg, 0) != 0)
 				exit(1);
@@ -677,16 +568,6 @@ main(int argc, char *argv[])
 	if (argc != 1)
 		usage(1);
 
-	/* No need to mux if guest is uni-processor */
-	if (guest_ncpus <= 1)
-		guest_vcpu_mux = 0;
-
-	/* vmexit on hlt if guest is muxed */
-	if (guest_vcpu_mux) {
-		guest_vmexit_on_hlt = 1;
-		guest_vmexit_on_pause = 1;
-	}
-
 	vmname = argv[0];
 
 	ctx = vm_open(vmname);
@@ -765,11 +646,6 @@ main(int argc, char *argv[])
 	error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip);
 	assert(error == 0);
 
-	if (inject_bkpt) {
-		error = vm_inject_event(ctx, BSP, VM_HW_EXCEPTION, IDT_BP);
-		assert(error == 0);
-	}
-
 	/*
 	 * build the guest tables, MP etc.
 	 */

Modified: head/usr.sbin/bhyve/bhyverun.h
==============================================================================
--- head/usr.sbin/bhyve/bhyverun.h	Fri Oct  4 22:05:23 2013	(r256061)
+++ head/usr.sbin/bhyve/bhyverun.h	Fri Oct  4 23:29:07 2013	(r256062)
@@ -36,8 +36,6 @@
 #endif
 
 struct vmctx;
-extern int guest_hz;
-extern int guest_tslice;
 extern int guest_ncpus;
 extern char *vmname;
 

Modified: head/usr.sbin/bhyve/pit_8254.c
==============================================================================
--- head/usr.sbin/bhyve/pit_8254.c	Fri Oct  4 22:05:23 2013	(r256061)
+++ head/usr.sbin/bhyve/pit_8254.c	Fri Oct  4 23:29:07 2013	(r256062)
@@ -153,10 +153,10 @@ pit_update_counter(struct counter *c, in
 		 * of the program.
 		 *
 		 * If the counter's initial value is not programmed we
-		 * assume a value that would be set to generate 'guest_hz'
+		 * assume a value that would be set to generate 100
 		 * interrupts per second.
 		 */
-		c->initial = TIMER_DIV(PIT_8254_FREQ, guest_hz);
+		c->initial = TIMER_DIV(PIT_8254_FREQ, 100);
 		gettimeofday(&c->tv, NULL);
 	}
 	


More information about the svn-src-head mailing list