preprocessor cleanup: __xpv
[unleashed.git] / usr / src / uts / intel / ia32 / os / comm_page_util.c
blob1e0145279001566f1047ed258c57f6d8cde5df8e
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2016 Joyent, Inc.
17 #include <sys/types.h>
18 #include <sys/thread.h>
19 #include <sys/proc.h>
20 #include <sys/mman.h>
21 #include <sys/vmsystm.h>
22 #include <vm/as.h>
23 #include <vm/seg_umap.h>
25 #include <sys/comm_page.h>
28 * Map in the comm page.
30 * The contents of the comm page are only defined on non-xpv x86 at this time.
31 * Furthermore, the data is only valid in userspace (32-bit or 64-bit) when
32 * mapped from a 64-bit kernel.
33 * See: "uts/i86pc/sys/comm_page.h"
35 caddr_t
36 comm_page_mapin()
38 #if defined(__amd64) && !defined(__xpv)
39 proc_t *p = curproc;
40 caddr_t addr = NULL;
41 size_t len = COMM_PAGE_SIZE;
42 uint_t prot = PROT_USER | PROT_READ;
43 segumap_crargs_t suarg;
45 map_addr(&addr, len, (offset_t)0, 1, 0);
46 if (addr == NULL || valid_usr_range(addr, len, prot, p->p_as,
47 p->p_as->a_userlimit) != RANGE_OKAY) {
48 return (NULL);
51 suarg.kaddr = (caddr_t)&comm_page;
52 suarg.prot = suarg.maxprot = prot;
53 if (as_map(p->p_as, addr, len, segumap_create, &suarg) != 0) {
54 return (NULL);
56 return (addr);
57 #else /* defined(__amd64) && !defined(__xpv) */
58 return (NULL);
59 #endif /* defined(__amd64) && !defined(__xpv) */