Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /******************************************************************************
0003  * arch-x86_32.h
0004  *
0005  * Guest OS interface to x86 32-bit Xen.
0006  *
0007  * Copyright (c) 2004, K A Fraser
0008  */
0009 
0010 #ifndef _ASM_X86_XEN_INTERFACE_32_H
0011 #define _ASM_X86_XEN_INTERFACE_32_H
0012 
0013 
0014 /*
0015  * These flat segments are in the Xen-private section of every GDT. Since these
0016  * are also present in the initial GDT, many OSes will be able to avoid
0017  * installing their own GDT.
0018  */
0019 #define FLAT_RING1_CS 0xe019    /* GDT index 259 */
0020 #define FLAT_RING1_DS 0xe021    /* GDT index 260 */
0021 #define FLAT_RING1_SS 0xe021    /* GDT index 260 */
0022 #define FLAT_RING3_CS 0xe02b    /* GDT index 261 */
0023 #define FLAT_RING3_DS 0xe033    /* GDT index 262 */
0024 #define FLAT_RING3_SS 0xe033    /* GDT index 262 */
0025 
0026 #define FLAT_KERNEL_CS FLAT_RING1_CS
0027 #define FLAT_KERNEL_DS FLAT_RING1_DS
0028 #define FLAT_KERNEL_SS FLAT_RING1_SS
0029 #define FLAT_USER_CS    FLAT_RING3_CS
0030 #define FLAT_USER_DS    FLAT_RING3_DS
0031 #define FLAT_USER_SS    FLAT_RING3_SS
0032 
0033 /* And the trap vector is... */
0034 #define TRAP_INSTR "int $0x82"
0035 
0036 #define __MACH2PHYS_VIRT_START 0xF5800000
0037 #define __MACH2PHYS_VIRT_END   0xF6800000
0038 
0039 #define __MACH2PHYS_SHIFT      2
0040 
0041 /*
0042  * Virtual addresses beyond this are not modifiable by guest OSes. The
0043  * machine->physical mapping table starts at this address, read-only.
0044  */
0045 #define __HYPERVISOR_VIRT_START 0xF5800000
0046 
0047 #ifndef __ASSEMBLY__
0048 
0049 struct cpu_user_regs {
0050     uint32_t ebx;
0051     uint32_t ecx;
0052     uint32_t edx;
0053     uint32_t esi;
0054     uint32_t edi;
0055     uint32_t ebp;
0056     uint32_t eax;
0057     uint16_t error_code;    /* private */
0058     uint16_t entry_vector;  /* private */
0059     uint32_t eip;
0060     uint16_t cs;
0061     uint8_t  saved_upcall_mask;
0062     uint8_t  _pad0;
0063     uint32_t eflags;        /* eflags.IF == !saved_upcall_mask */
0064     uint32_t esp;
0065     uint16_t ss, _pad1;
0066     uint16_t es, _pad2;
0067     uint16_t ds, _pad3;
0068     uint16_t fs, _pad4;
0069     uint16_t gs, _pad5;
0070 };
0071 DEFINE_GUEST_HANDLE_STRUCT(cpu_user_regs);
0072 
0073 typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
0074 
0075 struct arch_vcpu_info {
0076     unsigned long cr2;
0077     unsigned long pad[5]; /* sizeof(struct vcpu_info) == 64 */
0078 };
0079 
0080 struct xen_callback {
0081     unsigned long cs;
0082     unsigned long eip;
0083 };
0084 typedef struct xen_callback xen_callback_t;
0085 
0086 #define XEN_CALLBACK(__cs, __eip)               \
0087     ((struct xen_callback){ .cs = (__cs), .eip = (unsigned long)(__eip) })
0088 #endif /* !__ASSEMBLY__ */
0089 
0090 
0091 /*
0092  * Page-directory addresses above 4GB do not fit into architectural %cr3.
0093  * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
0094  * must use the following accessor macros to pack/unpack valid MFNs.
0095  *
0096  * Note that Xen is using the fact that the pagetable base is always
0097  * page-aligned, and putting the 12 MSB of the address into the 12 LSB
0098  * of cr3.
0099  */
0100 #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
0101 #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
0102 
0103 #endif /* _ASM_X86_XEN_INTERFACE_32_H */