[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-03-07 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de added a comment.


  In D14473#306827 , @grehan wrote:
  
  > So a comment on this: in general, api's are not added to FreeBSD that don't 
have base-system clients that use them, or for a good reason. I think this 
falls into the latter but I'd like to cut it down a bit.
  >
  > - can the get_unrestricted_guest() routine be removed ? There is an error 
return on the set, which seems like it can be used to determine if unrestricted 
mode is not available (e.g. that's how bhyve uses the ioctl).
  
  
  Yes, it can.
  
  > - is there a need for vcpu_reset() ? The BSP should be initialized to 
power-on state.. That could be a bug in bhyve and better to have it fixed there.
  
  Not necessarily, as everything in vcpu_reset() could also be accomplished 
with the other callbacks. I don't think bhyverun should call vcpu_reset(), as 
bhyveload sets up registers before. I guess this should happen before 
`loader_main` is called?

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

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
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-03-07 Thread grehan (Peter Grehan)
grehan added a comment.


  So a comment on this: in general, api's are not added to FreeBSD that don't 
have base-system clients that use them, or for a good reason. I think this 
falls into the latter but I'd like to cut it down a bit.
  
  - can the get_unrestricted_guest() routine be removed ? There is an error 
return on the set, which seems like it can be used to determine if unrestricted 
mode is not available (e.g. that's how bhyve uses the ioctl).
  - is there a need for vcpu_reset() ? The BSP should be initialized to 
power-on state.. That could be a bug in bhyve and better to have it fixed there.

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

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
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-03-07 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de added 1 blocking reviewer(s): grehan.

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

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
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-27 Thread rgrimes
rgrimes added a comment.


  If Peter accepts this and says I can go ahead with a commit I would do that, 
but I need his approval to commit it.

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

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
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-27 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de added a comment.


  ping?
  
  Would these changes be welcome in base? If yes, what would still need to be 
done to this review in order to get it into a committable state?

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

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
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-23 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
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
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);
 };

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-23 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de updated this revision to Diff 39653.
fabian.freyer_physik.tu-berlin.de added a comment.
This revision now requires review to proceed.


  pass `USERBOOT_VERSION_5` to `loader_main`.

REPOSITORY
  rS FreeBSD src repository

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

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
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);
 };

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread rgrimes
rgrimes added reviewers: bhyve, grehan.
rgrimes added a comment.


  I dont know why it did that, I tried to simply "accept revision" and it 
removed all other reviewers, so put them back.

REPOSITORY
  rS FreeBSD src repository

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

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
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread rgrimes
rgrimes removed reviewers: bhyve, grehan.
rgrimes accepted this revision as: rgrimes.
This revision is now accepted and ready to land.

REPOSITORY
  rS FreeBSD src repository

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

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

To: fabian.freyer_physik.tu-berlin.de, imp, rgrimes, #bhyve
Cc: grehan, imp, freebsd-virtualization-list, #contributor_reviews_base
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de marked 5 inline comments as done.
fabian.freyer_physik.tu-berlin.de added a comment.


  I hope I got them all now

REPOSITORY
  rS FreeBSD src repository

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

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

To: fabian.freyer_physik.tu-berlin.de, imp, #bhyve, grehan
Cc: grehan, imp, freebsd-virtualization-list, #contributor_reviews_base
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de updated this revision to Diff 39622.
fabian.freyer_physik.tu-berlin.de added a comment.


  addressed @grehan's comments regarding style(9)

REPOSITORY
  rS FreeBSD src repository

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

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, #bhyve, grehan
Cc: grehan, imp, freebsd-virtualization-list, #contributor_reviews_base
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
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);
 };

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread grehan (Peter Grehan)
grehan added inline comments.

INLINE COMMENTS

> bhyveload.c:566
> +{
> + return (vm_get_capability(ctx, vcpu,
> + VM_CAP_UNRESTRICTED_GUEST, retval));

Minor style(9) - should be an empty line before the rreturn - see the routine 
above.

> bhyveload.c:567
> + return (vm_get_capability(ctx, vcpu,
> + VM_CAP_UNRESTRICTED_GUEST, retval));
> +}

Minor style(9) - continued lines should be indented by 4 spaces.

> bhyveload.c:574
> + int error, tmp;
> + if ((error = cb_vm_get_unrestricted_guest(arg, vcpu, &tmp)))
> + return error;

Minor style(9) - blank line between declarations and statement.

> bhyveload.c:575
> + if ((error = cb_vm_get_unrestricted_guest(arg, vcpu, &tmp)))
> + return error;
> +

Minor style(9) - return expression should be enclosed in parens.

> bhyveload.c:584
> +{
> + return vcpu_reset(ctx, vcpu);
> +}

Minor style(9) - blank line needed before statement, and return expression 
should be in parens.

REPOSITORY
  rS FreeBSD src repository

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

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

To: fabian.freyer_physik.tu-berlin.de, imp, #bhyve, grehan
Cc: grehan, imp, freebsd-virtualization-list, #contributor_reviews_base
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de marked an inline comment as done.

REPOSITORY
  rS FreeBSD src repository

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

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

To: fabian.freyer_physik.tu-berlin.de, imp, #bhyve, grehan
Cc: grehan, imp, freebsd-virtualization-list, #contributor_reviews_base
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de updated this revision to Diff 39619.
fabian.freyer_physik.tu-berlin.de edited the summary of this revision.
fabian.freyer_physik.tu-berlin.de edited the test plan for this revision.
fabian.freyer_physik.tu-berlin.de added a comment.
This revision now requires review to proceed.


  - updated the comment at the version identifier to correctly list the changes 
introduced by this version
  - added a callback to `vcpu_reset`

REPOSITORY
  rS FreeBSD src repository

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

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, #bhyve, grehan
Cc: grehan, imp, freebsd-virtualization-list, #contributor_reviews_base
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,30 @@
 	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 +617,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
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);
 };

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread grehan (Peter Grehan)
grehan accepted this revision.
grehan added a comment.


  You may be able to get away with just the "set" call. Given that all h/w that 
is supported by bhyve, with the exception of only Nehalem systems, support 
this, you may want to use just the error from the set call to handle this 
low-probability error.
  
  Note that AMD SVM has always supported this mode. "Unrestricted Guest" is an 
Intel-only feature, but given that the name is baked into a bhyve API already, 
there doesn't seem to be any harm in keeping it going.

REPOSITORY
  rS FreeBSD src repository

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

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

To: fabian.freyer_physik.tu-berlin.de, imp, #bhyve, grehan
Cc: grehan, imp, freebsd-virtualization-list, #contributor_reviews_base
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread rgrimes
rgrimes added a reviewer: bhyve.

REPOSITORY
  rS FreeBSD src repository

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

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

To: fabian.freyer_physik.tu-berlin.de, imp, #bhyve
Cc: imp, freebsd-virtualization-list, #contributor_reviews_base
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de added a comment.


  I may also add a vcpu_reset callback still, would be nice to have that in as 
well.

INLINE COMMENTS

> userboot.h:45
> +/*
> + * Version 5 adds callbacks to set up long mode and set
> + * unrestricted guest capabilities. The callback structure

Tbh this is no longer true, so I will update the patch to fix the comment

REPOSITORY
  rS FreeBSD src repository

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

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

To: fabian.freyer_physik.tu-berlin.de, imp
Cc: imp, freebsd-virtualization-list, #contributor_reviews_base
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread imp (Warner Losh)
imp accepted this revision.
This revision is now accepted and ready to land.

REPOSITORY
  rS FreeBSD src repository

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

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

To: fabian.freyer_physik.tu-berlin.de, imp
Cc: imp, freebsd-virtualization-list, #contributor_reviews_base
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Differential] D14473: userboot: add callbacks to set unrestricted guest mode

2018-02-22 Thread fabian.freyer_physik.tu-berlin.de (Fabian Freyer)
fabian.freyer_physik.tu-berlin.de created this revision.
fabian.freyer_physik.tu-berlin.de added a project: bhyve.
Herald added subscribers: Contributor Reviews (base), imp.

REVISION SUMMARY
  The current userboot interface sets this capability using 
`vm_setup_freebsd_registers_i386` in lib/libvmmapi/libvmmapi_freebsd.c. This 
patch adds support for loaders to explicitly query and/or set this capability 
without having to go through the `exec` callback, but set up registers 
themselves.
  
  This change is backwards-compatible as all new callbacks are added to the end 
of the callback structure.

TEST PLAN
  test with a library implementing `loader_main` and calling these callbacks. 
Check whether capability is set.

REPOSITORY
  rS FreeBSD src repository

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
Cc: imp, freebsd-virtualization-list, #contributor_reviews_base
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,24 @@
 	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 struct loader_callbacks cb = {
 	.getc = cb_getc,
 	.putc = cb_putc,
@@ -593,6 +611,10 @@
 	/* 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,
 };
 
 static int
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 up long mode and set
+ * unrestricted guest capabilities. 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,17 @@
 	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.
+	 */
+	int	(*vm_get_unrestricted_guest)(void* arg, int vcpu, int *retval);
+	int	(*vm_set_unrestricted_guest)(void* arg, int vcpu, int val);
 };

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"