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.
Tags
None
Referenced Files
Unknown Object (File)
Mar 26 2024, 9:00 PM
Unknown Object (File)
Jan 8 2024, 10:38 PM
Unknown Object (File)
Dec 20 2023, 10:50 AM
Unknown Object (File)
Dec 20 2023, 3:57 AM
Unknown Object (File)
Dec 9 2023, 3:39 PM
Unknown Object (File)
Nov 18 2023, 5:51 AM
Unknown Object (File)
Nov 18 2023, 4:56 AM
Unknown Object (File)
Aug 29 2023, 7:49 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 - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

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

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