FreeBSD/lib/libvmmapi/vmmapi.c
/*
 * Returns a non-NULL pointer if [gaddr, gaddr+len) is entirely contained in
 * the lowmem or highmem regions.
 *
 * In particular return NULL if [gaddr, gaddr+len) falls in guest MMIO region.
 * The instruction emulation code depends on this behavior.
 */
Returns a non-NULL pointer if [gaddr, gaddr+len) is entirely contained in
the lowmem or highmem regions.

In particular return NULL if [gaddr, gaddr+len) falls in guest MMIO region.
The instruction emulation code depends on this behavior.
Returns a non - NULL pointer if [ gaddr gaddr + len ) is entirely contained in the lowmem or highmem regions . In particular return NULL if [ gaddr gaddr + len ) falls in guest MMIO region . The instruction emulation code depends on this behavior .
void *
vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len)
{
	if (ctx->lowmem > 0) {
		if (gaddr < ctx->lowmem && len <= ctx->lowmem &&
		    gaddr + len <= ctx->lowmem)
			return (ctx->baseaddr + gaddr);
	}
	if (ctx->highmem > 0) {
                if (gaddr >= 4*GB) {
			if (gaddr < 4*GB + ctx->highmem &&
			    len <= ctx->highmem &&
			    gaddr + len <= 4*GB + ctx->highmem)
				return (ctx->baseaddr + gaddr);
		}
	}
	return (NULL);
}
void * vm_map_gpa ( struct vmctx * ctx , vm_paddr_t gaddr , size_t len ) { if ( ctx -> lowmem > 0 ) { if ( gaddr < ctx -> lowmem && len <= ctx -> lowmem && gaddr + len <= ctx -> lowmem ) return ( ctx -> baseaddr + gaddr ) ; } if ( ctx -> highmem > 0 ) { if ( gaddr >= 4 * GB ) { if ( gaddr < 4 * GB + ctx -> highmem && len <= ctx -> highmem && gaddr + len <= 4 * GB + ctx -> highmem ) return ( ctx -> baseaddr + gaddr ) ; } } return ( NULL ) ; }
Returns a non-NULL pointer if [gaddr, gaddr+len) is entirely contained in
 the lowmem or highmem regions.
Returns a non - NULL pointer if [ gaddr gaddr + len ) is entirely contained in the lowmem or highmem regions .