FreeBSD/sys/amd64/vmm/amd/svm.c
/*
 * Get the index and bit position for a MSR in permission bitmap.
 * Two bits are used for each MSR: lower bit for read and higher bit for write.
 */
Get the index and bit position for a MSR in permission bitmap.
Two bits are used for each MSR: lower bit for read and higher bit for write.
Get the index and bit position for a MSR in permission bitmap . Two bits are used for each MSR : lower bit for read and higher bit for write .
static int
svm_msr_index(uint64_t msr, int *index, int *bit)
{
	uint32_t base, off;
	*index = -1;
	*bit = (msr % 4) * 2;
	base = 0;
	if (msr >= MSR_PENTIUM_START && msr <= MSR_PENTIUM_END) {
		*index = msr / 4;
		return (0);
	}
	base += (MSR_PENTIUM_END - MSR_PENTIUM_START + 1); 
	if (msr >= MSR_AMD6TH_START && msr <= MSR_AMD6TH_END) {
		off = (msr - MSR_AMD6TH_START); 
		*index = (off + base) / 4;
		return (0);
	} 
	base += (MSR_AMD6TH_END - MSR_AMD6TH_START + 1);
	if (msr >= MSR_AMD7TH_START && msr <= MSR_AMD7TH_END) {
		off = (msr - MSR_AMD7TH_START);
		*index = (off + base) / 4;
		return (0);
	}
	return (EINVAL);
}
static int svm_msr_index ( uint64_t msr , int * index , int * bit ) { uint32_t base , off ; * index = -1 ; * bit = ( msr % 4 ) * 2 ; base = 0 ; if ( msr >= MSR_PENTIUM_START && msr <= MSR_PENTIUM_END ) { * index = msr / 4 ; return ( 0 ) ; } base += ( MSR_PENTIUM_END - MSR_PENTIUM_START + 1 ) ; if ( msr >= MSR_AMD6TH_START && msr <= MSR_AMD6TH_END ) { off = ( msr - MSR_AMD6TH_START ) ; * index = ( off + base ) / 4 ; return ( 0 ) ; } base += ( MSR_AMD6TH_END - MSR_AMD6TH_START + 1 ) ; if ( msr >= MSR_AMD7TH_START && msr <= MSR_AMD7TH_END ) { off = ( msr - MSR_AMD7TH_START ) ; * index = ( off + base ) / 4 ; return ( 0 ) ; } return ( EINVAL ) ; }
Get the index and bit position for a MSR in permission bitmap.
Get the index and bit position for a MSR in permission bitmap .