Page MenuHomeFreeBSD

vmx: explicit checking for necessary invvpid/invept types
Needs ReviewPublic

Authored by jan.dakinevich_gmail.com on Apr 29 2017, 12:27 AM.

Details

Reviewers
grehan
neel
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.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

anish added a subscriber: anish.Apr 29 2017, 4:41 AM
anish added inline comments.
sys/amd64/vmm/intel/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))

novel added a subscriber: novel.Apr 29 2017, 6:26 AM
grehan added inline comments.May 1 2017, 4:43 PM
sys/amd64/vmm/intel/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 :)

sys/amd64/vmm/intel/ept.c
58–59

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

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 :)