Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Jul 2015 12:45:24 GMT
From:      mihai@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r288088 - soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm
Message-ID:  <201507081245.t68CjOAQ035051@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mihai
Date: Wed Jul  8 12:45:24 2015
New Revision: 288088
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=288088

Log:
  soc2015: mihai: bhyve: usr.sbin: bhyvearm: remove memory mappings, fix guest register PC

Modified:
  soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/bhyverun.c
  soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/mem.c
  soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/mem.h

Modified: soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/bhyverun.c
==============================================================================
--- soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/bhyverun.c	Wed Jul  8 12:42:04 2015	(r288087)
+++ soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/bhyverun.c	Wed Jul  8 12:45:24 2015	(r288088)
@@ -76,7 +76,7 @@
 
 static int cpumask;
 
-static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip);
+static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t pc);
 
 struct vm_exit vmexit[VM_MAXCPU];
 
@@ -104,14 +104,13 @@
 
         fprintf(stderr,
                 "Usage: %s [-aehAHIP][-g <gdb port>][-s <pci>][-S <pci>]"
-		"[-c vcpus][-p pincpu][-m mem]"
+		"[-c vcpus][-p pincpu]"
 		" <vmname>\n"
 		"       -c: # cpus (default 1)\n"
 		"       -p: pin vcpu 'n' to host cpu 'pincpu + n'\n"
 		"       -H: vmexit from the guest on hlt\n"
 		"       -P: vmexit from the guest on pause\n"
-		"       -h: help\n"
-		"       -m: memory size in MB\n",
+		"       -h: help\n",
 		progname);
 
 	exit(code);
@@ -151,7 +150,7 @@
 	snprintf(tname, sizeof(tname), "%s vcpu %d", vmname, vcpu);
 	pthread_set_name_np(mtp->mt_thr, tname);
 
-	vm_loop(mtp->mt_ctx, vcpu, vmexit[vcpu].rip);
+	vm_loop(mtp->mt_ctx, vcpu, vmexit[vcpu].pc);
 
 	/* not reached */
 	exit(1);
@@ -159,7 +158,7 @@
 }
 
 void
-fbsdrun_addcpu(struct vmctx *ctx, int vcpu, uint64_t rip)
+fbsdrun_addcpu(struct vmctx *ctx, int vcpu, uint64_t pc)
 {
 	int error;
 
@@ -176,7 +175,7 @@
 	 * Set up the vmexit struct to allow execution to start
 	 * at the given RIP
 	 */
-	vmexit[vcpu].rip = rip;
+	vmexit[vcpu].pc = pc;
 	vmexit[vcpu].inst_length = 0;
 
 	if (vcpu == BSP) {
@@ -225,7 +224,7 @@
 
 	fprintf(stderr, "vm exit[%d]\n", *pvcpu);
 	fprintf(stderr, "\treason\t\tVMX\n");
-	fprintf(stderr, "\trip\t\t0x%016llx\n", vmexit->rip);
+	fprintf(stderr, "\tpc\t\t0x%016llx\n", vmexit->pc);
 	fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length);
 
 	return (VMEXIT_ABORT);
@@ -285,7 +284,7 @@
 		if (err == EINVAL) {
 			fprintf(stderr,
 			    "Failed to emulate instruction at 0x%llx\n", 
-			    vmexit->rip);
+			    vmexit->pc);
 		} else if (err == ESRCH) {
 			fprintf(stderr, "Unhandled memory access to 0x%llx\n",
 			    vmexit->u.paging.gpa);
@@ -305,7 +304,7 @@
 };
 
 static void
-vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip)
+vm_loop(struct vmctx *ctx, int vcpu, uint64_t pc)
 {
 	cpuset_t mask;
 	int error, rc, prevcpu;
@@ -320,7 +319,7 @@
 	}
 
 	while (1) {
-		error = vm_run(ctx, vcpu, rip, &vmexit[vcpu]);
+		error = vm_run(ctx, vcpu, pc, &vmexit[vcpu]);
 		if (error != 0) {
 			/*
 			 * It is possible that 'vmmctl' or some other process
@@ -348,10 +347,10 @@
 
 		switch (rc) {
 		case VMEXIT_CONTINUE:
-                        rip = vmexit[vcpu].rip + vmexit[vcpu].inst_length;
+                        pc = vmexit[vcpu].pc + vmexit[vcpu].inst_length;
 			break;
 		case VMEXIT_RESTART:
-                        rip = vmexit[vcpu].rip;
+                        pc = vmexit[vcpu].pc;
 			break;
 		case VMEXIT_RESET:
 			exit(0);
@@ -365,18 +364,8 @@
 static int
 num_vcpus_allowed(struct vmctx *ctx)
 {
-	int tmp, error;
-
-	error = vm_get_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, &tmp);
-
-	/*
-	 * The guest is allowed to spinup more than one processor only if the
-	 * UNRESTRICTED_GUEST capability is available.
-	 */
-	if (error == 0)
-		return (VM_MAXCPU);
-	else
-		return (1);
+	/* Max one VCPU */
+	return (1);
 }
 
 int
@@ -385,7 +374,7 @@
 	int c, error, tmp, err;
 	int max_vcpus;
 	struct vmctx *ctx;
-	uint64_t rip;
+	uint64_t pc;
 	size_t memsize;
 
 	progname = basename(argv[0]);
@@ -400,9 +389,6 @@
                 case 'c':
 			guest_ncpus = atoi(optarg);
 			break;
-                case 'm':
-			memsize = strtoul(optarg, NULL, 0) * MB;
-			break;
 		case 'H':
 			guest_vmexit_on_hlt = 1;
 			break;
@@ -460,21 +446,16 @@
 		handler[VM_EXITCODE_PAUSE] = vmexit_pause;
         }
 
-	err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
-	if (err) {
-		fprintf(stderr, "Unable to setup memory (%d)\n", err);
-		exit(1);
-	}
 
 	init_mem();
 
-	error = vm_get_register(ctx, BSP, VM_REG_GUEST_PC, &rip);
+	error = vm_get_register(ctx, BSP, VM_REG_GUEST_PC, &pc);
 	assert(error == 0);
 
 	/*
 	 * Add CPU 0
 	 */
-	fbsdrun_addcpu(ctx, BSP, rip);
+	fbsdrun_addcpu(ctx, BSP, pc);
 
 	/*
 	 * Head off to the main event dispatch loop

Modified: soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/mem.c
==============================================================================
--- soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/mem.c	Wed Jul  8 12:42:04 2015	(r288087)
+++ soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/mem.c	Wed Jul  8 12:45:24 2015	(r288088)
@@ -156,7 +156,7 @@
 }
 
 int
-emulate_mem(struct vmctx *ctx, int vcpu, uint64_t paddr, struct vie *vie)
+emulate_mem(struct vmctx *ctx, int vcpu, uint64_t paddr, void *vie)
 {
 	struct mmio_rb_range *entry;
 	int err;

Modified: soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/mem.h
==============================================================================
--- soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/mem.h	Wed Jul  8 12:42:04 2015	(r288087)
+++ soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/mem.h	Wed Jul  8 12:45:24 2015	(r288088)
@@ -50,7 +50,7 @@
 #define	MEM_F_RW		0x3
 
 void	init_mem(void);
-int     emulate_mem(struct vmctx *, int vcpu, uint64_t paddr, struct vie *vie);
+int     emulate_mem(struct vmctx *, int vcpu, uint64_t paddr, void *vie);
 		    
 int	register_mem(struct mem_range *memp);
 int	register_mem_fallback(struct mem_range *memp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507081245.t68CjOAQ035051>