Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2015 17:57:53 GMT
From:      mihai@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r288700 - soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm
Message-ID:  <201507231757.t6NHvrZc037041@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mihai
Date: Thu Jul 23 17:57:53 2015
New Revision: 288700
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=288700

Log:
  soc2015: mihai: bhyve: usr.sbin: bhyvearm: bhyverun.c : added support for instruction emulation

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

Modified: soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/Makefile
==============================================================================
--- soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/Makefile	Thu Jul 23 17:56:52 2015	(r288699)
+++ soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/Makefile	Thu Jul 23 17:57:53 2015	(r288700)
@@ -6,12 +6,15 @@
 
 DEBUG_FLAGS= -g -O0 
 
-SRCS=	bhyverun.c block_if.c mem.c mevent.c
+SRCS=	bhyverun.c block_if.c mem.c mevent.c consport.c
 
 .PATH:	${.CURDIR}/../../sys/arm/vmm
 
 NO_MAN=
 
+.PATH:	${.CURDIR}/../../sys/arm/vmm
+SRCS+=	vmm_instruction_emul.c
+
 DPADD=	${LIBVMMAPIARM} ${LIBMD} ${LIBPTHREAD}
 LDADD=	-lvmmapiarm -lmd -lpthread
 

Modified: soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/bhyverun.c
==============================================================================
--- soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/bhyverun.c	Thu Jul 23 17:56:52 2015	(r288699)
+++ soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyvearm/bhyverun.c	Thu Jul 23 17:57:53 2015	(r288700)
@@ -82,14 +82,7 @@
 
 struct bhyvestats {
         uint64_t        vmexit_bogus;
-        uint64_t        vmexit_bogus_switch;
-        uint64_t        vmexit_hlt;
-        uint64_t        vmexit_pause;
-        uint64_t        vmexit_mtrap;
-        uint64_t        vmexit_paging;
-        uint64_t        cpu_switch_rotate;
-        uint64_t        cpu_switch_direct;
-        int             io_reset;
+        uint64_t        vmexit_inst_emul;
 } stats;
 
 struct mt_vmm_info {
@@ -103,13 +96,11 @@
 {
 
         fprintf(stderr,
-                "Usage: %s [-aehAHIP][-g <gdb port>][-s <pci>][-S <pci>]"
-		"[-c vcpus][-p pincpu]"
+                "Usage: %s [-b] [-c vcpus][-p pincpu]"
 		" <vmname>\n"
+		"       -b: use bvmconsole"
 		"       -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",
 		progname);
 
@@ -203,25 +194,6 @@
 }
 
 static int
-vmexit_catch_reset(void)
-{
-        stats.io_reset++;
-        return (VMEXIT_RESET);
-}
-
-static int
-vmexit_handle_notify(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu,
-		     uint32_t eax)
-{
-#if BHYVE_DEBUG
-	/*
-	 * put guest-driven debug here
-	 */
-#endif
-        return (VMEXIT_CONTINUE);
-}
-
-static int
 vmexit_hyp(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
 {
 
@@ -243,67 +215,33 @@
 }
 
 static int
-vmexit_hlt(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
-	stats.vmexit_hlt++;
-
-	/*
-	 * 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++;
-
-	return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_mtrap(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
-	stats.vmexit_mtrap++;
-
-	return (VMEXIT_RESTART);
-}
-
-static int
-vmexit_paging(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
+vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
 {
 	int err;
-	stats.vmexit_paging++;
+	struct vie *vie;
+
+	stats.vmexit_inst_emul++;
 
-	err = emulate_mem(ctx, *pvcpu, vmexit->u.paging.gpa, NULL);
-//			  &vmexit->u.paging.vie);
+	vie = &vmexit->u.inst_emul.vie;
+	err = emulate_mem(ctx, *pvcpu, vmexit->u.inst_emul.gpa, vie);
 
 	if (err) {
-		if (err == EINVAL) {
-			fprintf(stderr,
-			    "Failed to emulate instruction at 0x%llx\n", 
-			    vmexit->pc);
-		} else if (err == ESRCH) {
+		if (err == ESRCH) {
 			fprintf(stderr, "Unhandled memory access to 0x%llx\n",
-			    vmexit->u.paging.gpa);
+			    vmexit->u.inst_emul.gpa);
 		}
 
+		fprintf(stderr, "Failed to emulate instruction at 0x%llx\n", vmexit->pc);
 		return (VMEXIT_ABORT);
 	}
-
 	return (VMEXIT_CONTINUE);
 }
 
+
 static vmexit_handler_t handler[VM_EXITCODE_MAX] = {
 	[VM_EXITCODE_HYP]    = vmexit_hyp,
 	[VM_EXITCODE_BOGUS]  = vmexit_bogus,
-	[VM_EXITCODE_MTRAP]  = vmexit_mtrap,
-	[VM_EXITCODE_PAGING] = vmexit_paging,
+	[VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
 };
 
 static void
@@ -378,18 +316,22 @@
 int
 main(int argc, char *argv[])
 {
-	int c, error, tmp, err;
+	int c, error, bvmcons;
 	int max_vcpus;
 	struct vmctx *ctx;
 	uint64_t pc;
 	size_t memsize;
 
+	bvmcons = 0;
 	progname = basename(argv[0]);
 	guest_ncpus = 1;
 	memsize = 256 * MB;
 
 	while ((c = getopt(argc, argv, "abehAHIPp:g:c:s:S:m:")) != -1) {
 		switch (c) {
+		case 'b':
+			bvmcons = 1;
+			break;
 		case 'p':
 			pincpu = atoi(optarg);
 			break;
@@ -429,33 +371,11 @@
 		exit(1);
 	}
 
-	if (fbsdrun_vmexit_on_hlt()) {
-		err = vm_get_capability(ctx, BSP, VM_CAP_HALT_EXIT, &tmp);
-		if (err < 0) {
-			fprintf(stderr, "VM exit on HLT not supported\n");
-			exit(1);
-		}
-		vm_set_capability(ctx, BSP, VM_CAP_HALT_EXIT, 1);
-		handler[VM_EXITCODE_HLT] = vmexit_hlt;
-	}
-
-        if (fbsdrun_vmexit_on_pause()) {
-		/*
-		 * pause exit support required for this mode
-		 */
-		err = vm_get_capability(ctx, BSP, VM_CAP_PAUSE_EXIT, &tmp);
-		if (err < 0) {
-			fprintf(stderr,
-			    "SMP mux requested, no pause support\n");
-			exit(1);
-		}
-		vm_set_capability(ctx, BSP, VM_CAP_PAUSE_EXIT, 1);
-		handler[VM_EXITCODE_PAUSE] = vmexit_pause;
-        }
-
-
 	init_mem();
 
+	if (bvmcons)
+		init_bvmcons();
+
 	error = vm_get_register(ctx, BSP, VM_REG_GUEST_PC, &pc);
 	assert(error == 0);
 	printf("%s pc: %llx\n",__func__, pc);



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