Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Feb 2018 19:32:01 +0000
From:      "fabian.freyer_physik.tu-berlin.de (Fabian Freyer)" <phabric-noreply@FreeBSD.org>
To:        freebsd-virtualization@freebsd.org
Subject:   [Differential] D14473: userboot: add callbacks to set unrestricted guest mode
Message-ID:  <a3b44848b44a0152d1904e62152d9115@localhost.localdomain>
In-Reply-To: <differential-rev-PHID-DREV-z4kdgdlru2lrsvfkw4bo-req@FreeBSD.org>
References:  <differential-rev-PHID-DREV-z4kdgdlru2lrsvfkw4bo-req@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
fabian.freyer_physik.tu-berlin.de updated this revision to Diff 39655.
fabian.freyer_physik.tu-berlin.de added a comment.


  I'm sorry, I seem to have created the previous patch without full context, so here it is again, this time with full context.

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D14473?vs=39653&id=39655

REVISION DETAIL
  https://reviews.freebsd.org/D14473

AFFECTED FILES
  stand/userboot/userboot.h
  usr.sbin/bhyveload/bhyveload.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: fabian.freyer_physik.tu-berlin.de, imp, rgrimes, #bhyve, grehan
Cc: grehan, imp, freebsd-virtualization-list, #contributor_reviews_base

[-- Attachment #2 --]
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -560,6 +560,33 @@
 	return (vm_set_desc(ctx, vcpu, reg, base, limit, access));
 }
 
+static int
+cb_vm_get_unrestricted_guest(void* arg, int vcpu, int *retval)
+{
+
+	return (vm_get_capability(ctx, vcpu,
+	    VM_CAP_UNRESTRICTED_GUEST, retval));
+}
+
+static int
+cb_vm_set_unrestricted_guest(void* arg, int vcpu, int val)
+{
+	int error, tmp;
+
+	if ((error = cb_vm_get_unrestricted_guest(arg, vcpu, &tmp)))
+		return (error);
+
+	return (vm_set_capability(ctx, vcpu,
+	    VM_CAP_UNRESTRICTED_GUEST, val));
+}
+
+static int
+cb_vcpu_reset(void* arg, int vcpu)
+{
+
+	return (vcpu_reset(ctx, vcpu));
+}
+
 static struct loader_callbacks cb = {
 	.getc = cb_getc,
 	.putc = cb_putc,
@@ -593,6 +620,11 @@
 	/* Version 4 additions */
 	.vm_set_register = cb_vm_set_register,
 	.vm_set_desc = cb_vm_set_desc,
+
+	/* Version 5 additions */
+	.vm_set_unrestricted_guest = cb_vm_set_unrestricted_guest,
+	.vm_get_unrestricted_guest = cb_vm_get_unrestricted_guest,
+	.vcpu_reset = cb_vcpu_reset,
 };
 
 static int
@@ -790,7 +822,7 @@
 	addenv("smbios.bios.vendor=BHYVE");
 	addenv("boot_serial=1");
 
-	func(&cb, NULL, USERBOOT_VERSION_4, ndisks);
+	func(&cb, NULL, USERBOOT_VERSION_5, ndisks);
 
 	free(loader);
 	return (0);
diff --git a/stand/userboot/userboot.h b/stand/userboot/userboot.h
--- a/stand/userboot/userboot.h
+++ b/stand/userboot/userboot.h
@@ -41,6 +41,14 @@
  */
 #define	USERBOOT_VERSION_4      4
 
+/*
+ * Version 5 adds callbacks to set unrestricted guest
+ * capabilities and reset the vcpu state. The callback
+ * structure backward compatible (new callbacks have
+ * been added at the tail end).
+ */
+#define	USERBOOT_VERSION_5      5
+
 /*
  * Exit codes from the loader
  */
@@ -210,4 +218,22 @@
 	int	(*vm_set_register)(void *arg, int vcpu, int reg, uint64_t val);
 	int	(*vm_set_desc)(void *arg, int vcpu, int reg, uint64_t base,
 	    u_int limit, u_int access);
+
+	/*
+	 * Version 5 additions.
+	 *
+	 * vm_get_unrestricted_guest checks support for the UNRESTRICTED_GUEST
+	 * capability and if supported, sets 'retval'. If unsupported, an error
+	 * code is returned.
+	 *
+	 * vm_set_unrestricted_guest sets the UNRESTRICTED_GUEST capability if
+	 * supported, and returns an error code otherwise.
+	 *
+	 * vcpu_reset initializes the vCPU state as defined in
+	 * Intel Vol 3a, Table 9.1. IA-32 Processor States Following Power-up,
+	 * Reset or INIT
+	 */
+	int	(*vm_get_unrestricted_guest)(void* arg, int vcpu, int *retval);
+	int	(*vm_set_unrestricted_guest)(void* arg, int vcpu, int val);
+	int	(*vcpu_reset)(void* arg, int vcpu);
 };

help

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