xref: /onnv-gate/usr/src/uts/i86xpv/sys/xen_mmu.h (revision 10175:dd9708d1f561)
15084Sjohnlev /*
25084Sjohnlev  * CDDL HEADER START
35084Sjohnlev  *
45084Sjohnlev  * The contents of this file are subject to the terms of the
55084Sjohnlev  * Common Development and Distribution License (the "License").
65084Sjohnlev  * You may not use this file except in compliance with the License.
75084Sjohnlev  *
85084Sjohnlev  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95084Sjohnlev  * or http://www.opensolaris.org/os/licensing.
105084Sjohnlev  * See the License for the specific language governing permissions
115084Sjohnlev  * and limitations under the License.
125084Sjohnlev  *
135084Sjohnlev  * When distributing Covered Code, include this CDDL HEADER in each
145084Sjohnlev  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155084Sjohnlev  * If applicable, add the following below this CDDL HEADER, with the
165084Sjohnlev  * fields enclosed by brackets "[]" replaced with your own identifying
175084Sjohnlev  * information: Portions Copyright [yyyy] [name of copyright owner]
185084Sjohnlev  *
195084Sjohnlev  * CDDL HEADER END
205084Sjohnlev  */
215084Sjohnlev /*
22*10175SStuart.Maybee@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
235084Sjohnlev  * Use is subject to license terms.
245084Sjohnlev  */
255084Sjohnlev 
265084Sjohnlev #ifndef _SYS_XEN_MMU_H
275084Sjohnlev #define	_SYS_XEN_MMU_H
285084Sjohnlev 
295084Sjohnlev #ifdef __cplusplus
305084Sjohnlev extern "C" {
315084Sjohnlev #endif
325084Sjohnlev 
335084Sjohnlev /*
345084Sjohnlev  * Platform-dependent MMU routines and types for the hypervisor.
355084Sjohnlev  *
365084Sjohnlev  * WARNING: this header file is used by both dboot and i86pc, so don't go using
375084Sjohnlev  * normal kernel headers.
385084Sjohnlev  */
395084Sjohnlev 
405084Sjohnlev #if (defined(_BOOT) && defined(_BOOT_TARGET_amd64)) || \
415084Sjohnlev 	(!defined(_BOOT) && defined(__amd64))
425084Sjohnlev #define	__target_amd64
435084Sjohnlev #endif
445084Sjohnlev 
45*10175SStuart.Maybee@Sun.COM typedef uint64_t maddr_t;
46*10175SStuart.Maybee@Sun.COM #define	mfn_to_ma(mfn)	((maddr_t)(mfn) << MMU_PAGESHIFT)
47*10175SStuart.Maybee@Sun.COM 
48*10175SStuart.Maybee@Sun.COM #ifdef __xpv
49*10175SStuart.Maybee@Sun.COM 
505084Sjohnlev #ifdef __target_amd64
515084Sjohnlev 
525084Sjohnlev #define	IN_HYPERVISOR_VA(va) \
535084Sjohnlev 	((va) >= HYPERVISOR_VIRT_START && (va) < HYPERVISOR_VIRT_END)
545084Sjohnlev 
55*10175SStuart.Maybee@Sun.COM #else /* __target_amd64 */
565084Sjohnlev 
575084Sjohnlev #define	IN_HYPERVISOR_VA(va) ((va) >= xen_virt_start)
585084Sjohnlev 
595084Sjohnlev /*
605084Sjohnlev  * Do this to help catch any uses.
615084Sjohnlev  */
625084Sjohnlev #undef	HYPERVISOR_VIRT_START
635084Sjohnlev #undef	machine_to_phys_mapping
645084Sjohnlev 
65*10175SStuart.Maybee@Sun.COM #endif /* __target_amd64 */
665084Sjohnlev 
675084Sjohnlev #undef __target_amd64
685084Sjohnlev 
695084Sjohnlev paddr_t ma_to_pa(maddr_t);
705084Sjohnlev maddr_t pa_to_ma(paddr_t);
71*10175SStuart.Maybee@Sun.COM #endif /* __xpv */
725084Sjohnlev 
735084Sjohnlev extern uintptr_t xen_virt_start;
745084Sjohnlev extern pfn_t *mfn_to_pfn_mapping;
755084Sjohnlev 
765084Sjohnlev #ifndef _BOOT
775084Sjohnlev 
785084Sjohnlev /*
795084Sjohnlev  * On the hypervisor we need:
805084Sjohnlev  * - a way to map a machine address (ie, not pseudo-physical).
815084Sjohnlev  * - to relocate initial hypervisor data structures into kernel VA range.
825084Sjohnlev  * - a way to translate between physical addresses and machine addresses.
835084Sjohnlev  * - a way to change the machine address behind a physical address.
845084Sjohnlev  */
855084Sjohnlev typedef ulong_t mfn_t;
865084Sjohnlev extern mfn_t *mfn_list;
875084Sjohnlev extern mfn_t *mfn_list_pages;
885084Sjohnlev extern mfn_t *mfn_list_pages_page;
895084Sjohnlev extern ulong_t mfn_count;
905084Sjohnlev extern mfn_t cached_max_mfn;
915084Sjohnlev 
925084Sjohnlev /*
935084Sjohnlev  * locks for mfn_list[] and machine_to_phys_mapping[] when migration / suspend
945084Sjohnlev  * events happen
955084Sjohnlev  */
965084Sjohnlev extern void xen_block_migrate(void);
975084Sjohnlev extern void xen_allow_migrate(void);
985084Sjohnlev extern void xen_start_migrate(void);
995084Sjohnlev extern void xen_end_migrate(void);
1005084Sjohnlev 
1015084Sjohnlev /*
1025084Sjohnlev  * Conversion between machine (hardware) addresses and pseudo-physical
1035084Sjohnlev  * addresses.
1045084Sjohnlev  */
105*10175SStuart.Maybee@Sun.COM #ifdef __xpv
1065084Sjohnlev pfn_t mfn_to_pfn(mfn_t);
1075084Sjohnlev mfn_t pfn_to_mfn(pfn_t);
108*10175SStuart.Maybee@Sun.COM #endif
1095084Sjohnlev 
1105084Sjohnlev struct page;
1115084Sjohnlev 
1125084Sjohnlev void xen_relocate_start_info(void);
1135084Sjohnlev 
1145084Sjohnlev /*
1155084Sjohnlev  * interfaces to create/destroy pfn_t values for devices or foreign memory
1165084Sjohnlev  *
1175084Sjohnlev  * xen_assign_pfn() creates (or looks up) a local pfn value to use for things
1185084Sjohnlev  * like a foreign domain memory mfn or a device mfn.
1195084Sjohnlev  *
1205084Sjohnlev  * xen_release_pfn() destroys the association between a pfn and foreign mfn.
1215084Sjohnlev  */
1225084Sjohnlev pfn_t xen_assign_pfn(mfn_t mfn);
1235084Sjohnlev void xen_release_pfn(pfn_t);
1245084Sjohnlev uint_t pfn_is_foreign(pfn_t);
1255084Sjohnlev void reassign_pfn(pfn_t pfn, mfn_t mfn);
1265084Sjohnlev 
1275084Sjohnlev #define	MFN_INVALID	(-(mfn_t)1)
1285084Sjohnlev 
1295084Sjohnlev #endif /* !_BOOT */
1305084Sjohnlev 
1315084Sjohnlev #ifdef __cplusplus
1325084Sjohnlev }
1335084Sjohnlev #endif
1345084Sjohnlev 
1355084Sjohnlev #endif	/* _SYS_XEN_MMU_H */
136