[Differential] D10540: vmx: explicit checking for necessary invvpid/invept types

2017-05-11 Thread jan.dakinevich_gmail.com (Jan Dakinevich)
jan.dakinevich_gmail.com added inline comments.

INLINE COMMENTS

> anish wrote in ept.c:58-59
> This is cryptic, better to have separate macros for it
> #define  INVVPID_SINGLE_CTX_SUP(cap)  ((cap) & (1UL << 41))
> #define  INVVPID_ALL_CTX_SUP(cap) ((cap) & (1UL << 42))

It was done in that way to minimize produced patch.  Actually, I would prefer 
to declare masks and check them against cap in code. Something like that:

  #define INVVPID_MASK_SINGLE_CONTEXT   (1UL << 41)
  #define INVVPID_MASK_ALL_CONTEXTS (1UL << 42)
  ...
  
  int
  ept_init(int ipinum)
  {
...
/* invvpid instruction with required types is supported */
if(!INVVPID_SUPPORTED(cap) ||
!(cap & INVVPID_MASK_SINGLE_CONTEXT) ||
!(cap & INVVPID_MASK_ALL_CONTEXTS))
return (EINVAL);

> grehan wrote in ept.c:68
> Might be worth splitting these out into individual tests, since I have a 
> change that will look at the EPT capabilities individually (for PR 203994, 
> bhyve as a KVM guest. Jan - judging from your work in 
> https://patchwork.kernel.org/project/kvm/list/?submitter=170053 you are 
> intimately familiar with this issue :)

> I have a change that will look at the EPT capabilities individually

I suppose it would be feasible to wait for your changes will be done.

> Jan - judging from your work in 
> https://patchwork.kernel.org/project/kvm/list/?submitter=170053 you are 
> intimately familiar with this issue :)

Yes, all these changes came from my attempt to run bhyve in KVM guest :)

REPOSITORY
  rS FreeBSD src repository

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

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

To: jan.dakinevich_gmail.com, grehan, neel
Cc: novel, anish, imp, freebsd-virtualization-list
___
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] D10540: vmx: explicit checking for necessary invvpid/invept types

2017-04-28 Thread jan.dakinevich_gmail.com (Jan Dakinevich)
jan.dakinevich_gmail.com created this revision.
Herald added a subscriber: imp.

REVISION SUMMARY
  Currently, during EPT initialization it is checked that invvpid
  instruction supports all possible invalidation types, however only two
  of them are used (single context and all contexts invalidations).
  
  Checking for invept invalidation types is adjusted for code consistency.

REPOSITORY
  rS FreeBSD src repository

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

AFFECTED FILES
  sys/amd64/vmm/intel/ept.c

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

To: jan.dakinevich_gmail.com, grehan, neel
Cc: imp, freebsd-virtualization-list
diff --git a/sys/amd64/vmm/intel/ept.c b/sys/amd64/vmm/intel/ept.c
--- a/sys/amd64/vmm/intel/ept.c
+++ b/sys/amd64/vmm/intel/ept.c
@@ -54,13 +54,17 @@
 #define	AD_BITS_SUPPORTED(cap)		((cap) & (1UL << 21))
 #define	INVVPID_SUPPORTED(cap)		((cap) & (1UL << 32))
 
-#define	INVVPID_ALL_TYPES_MASK		0xF00UL
-#define	INVVPID_ALL_TYPES_SUPPORTED(cap)	\
-	(((cap) & INVVPID_ALL_TYPES_MASK) == INVVPID_ALL_TYPES_MASK)
-
-#define	INVEPT_ALL_TYPES_MASK		0x600UL
-#define	INVEPT_ALL_TYPES_SUPPORTED(cap)		\
-	(((cap) & INVEPT_ALL_TYPES_MASK) == INVEPT_ALL_TYPES_MASK)
+#define	INVVPID_REQUIRED_TYPES_MASK\
+	((1UL << (INVVPID_TYPE_SINGLE_CONTEXT + 40)) |	\
+	(1UL << (INVVPID_TYPE_ALL_CONTEXTS + 40)))
+#define	INVVPID_REQUIRED_TYPES_SUPPORTED(cap)	\
+	(((cap) & INVVPID_REQUIRED_TYPES_MASK) == INVVPID_REQUIRED_TYPES_MASK)
+
+#define	INVEPT_REQUIRED_TYPES_MASK			\
+	((1UL << (INVEPT_TYPE_SINGLE_CONTEXT + 24)) |	\
+	(1UL << (INVEPT_TYPE_ALL_CONTEXTS + 24)))
+#define	INVEPT_REQUIRED_TYPES_SUPPORTED(cap)		\
+	(((cap) & INVEPT_REQUIRED_TYPES_MASK) == INVEPT_REQUIRED_TYPES_MASK)
 
 #define	EPT_PWLEVELS		4		/* page walk levels */
 #define	EPT_ENABLE_AD_BITS	(1 << 6)
@@ -86,15 +90,15 @@
 	 * Verify that:
 	 * - page walk length is 4 steps
 	 * - extended page tables can be laid out in write-back memory
-	 * - invvpid instruction with all possible types is supported
-	 * - invept instruction with all possible types is supported
+	 * - invvpid instruction with required types is supported
+	 * - invept instruction with required types is supported
 	 */
 	if (!EPT_PWL4(cap) ||
 	!EPT_MEMORY_TYPE_WB(cap) ||
 	!INVVPID_SUPPORTED(cap) ||
-	!INVVPID_ALL_TYPES_SUPPORTED(cap) ||
+	!INVVPID_REQUIRED_TYPES_SUPPORTED(cap) ||
 	!INVEPT_SUPPORTED(cap) ||
-	!INVEPT_ALL_TYPES_SUPPORTED(cap))
+	!INVEPT_REQUIRED_TYPES_SUPPORTED(cap))
 		return (EINVAL);
 
 	ept_pmap_flags = ipinum & PMAP_NESTED_IPIMASK;

___
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"