debuggers.hg

view xen/include/asm-x86/io_apic.h @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents e8acb9753ff1
children
line source
1 #ifndef __ASM_IO_APIC_H
2 #define __ASM_IO_APIC_H
4 #include <xen/config.h>
5 #include <asm/types.h>
6 #include <asm/mpspec.h>
7 #include <asm/apicdef.h>
8 #include <asm/fixmap.h>
9 #include <xen/iommu.h>
11 /*
12 * Intel IO-APIC support for SMP and UP systems.
13 *
14 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
15 */
17 #ifdef CONFIG_X86_IO_APIC
19 #define IO_APIC_BASE(idx) \
20 ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
21 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
23 #define IO_APIC_ID(idx) (mp_ioapics[idx].mpc_apicid)
25 /* I/O Unit Redirection Table */
26 #define IO_APIC_REDIR_VECTOR_MASK 0x000FF
27 #define IO_APIC_REDIR_DEST_LOGICAL 0x00800
28 #define IO_APIC_REDIR_DEST_PHYSICAL 0x00000
29 #define IO_APIC_REDIR_SEND_PENDING (1 << 12)
30 #define IO_APIC_REDIR_REMOTE_IRR (1 << 14)
31 #define IO_APIC_REDIR_LEVEL_TRIGGER (1 << 15)
32 #define IO_APIC_REDIR_MASKED (1 << 16)
34 /*
35 * The structure of the IO-APIC:
36 */
37 union IO_APIC_reg_00 {
38 u32 raw;
39 struct {
40 u32 __reserved_2 : 14,
41 LTS : 1,
42 delivery_type : 1,
43 __reserved_1 : 8,
44 ID : 8;
45 } __attribute__ ((packed)) bits;
46 };
48 union IO_APIC_reg_01 {
49 u32 raw;
50 struct {
51 u32 version : 8,
52 __reserved_2 : 7,
53 PRQ : 1,
54 entries : 8,
55 __reserved_1 : 8;
56 } __attribute__ ((packed)) bits;
57 };
59 union IO_APIC_reg_02 {
60 u32 raw;
61 struct {
62 u32 __reserved_2 : 24,
63 arbitration : 4,
64 __reserved_1 : 4;
65 } __attribute__ ((packed)) bits;
66 };
68 union IO_APIC_reg_03 {
69 u32 raw;
70 struct {
71 u32 boot_DT : 1,
72 __reserved_1 : 31;
73 } __attribute__ ((packed)) bits;
74 };
76 /*
77 * # of IO-APICs and # of IRQ routing registers
78 */
79 extern int nr_ioapics;
80 extern int nr_ioapic_registers[MAX_IO_APICS];
82 enum ioapic_irq_destination_types {
83 dest_Fixed = 0,
84 dest_LowestPrio = 1,
85 dest_SMI = 2,
86 dest__reserved_1 = 3,
87 dest_NMI = 4,
88 dest_INIT = 5,
89 dest__reserved_2 = 6,
90 dest_ExtINT = 7
91 };
93 struct IO_APIC_route_entry {
94 __u32 vector : 8,
95 delivery_mode : 3, /* 000: FIXED
96 * 001: lowest prio
97 * 111: ExtINT
98 */
99 dest_mode : 1, /* 0: physical, 1: logical */
100 delivery_status : 1,
101 polarity : 1,
102 irr : 1,
103 trigger : 1, /* 0: edge, 1: level */
104 mask : 1, /* 0: enabled, 1: disabled */
105 __reserved_2 : 15;
107 union { struct { __u32
108 __reserved_1 : 24,
109 physical_dest : 4,
110 __reserved_2 : 4;
111 } physical;
113 struct { __u32
114 __reserved_1 : 24,
115 logical_dest : 8;
116 } logical;
118 /* used when Interrupt Remapping with EIM is enabled */
119 __u32 dest32;
120 } dest;
122 } __attribute__ ((packed));
124 /*
125 * MP-BIOS irq configuration table structures:
126 */
128 /* I/O APIC entries */
129 extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
131 /* Only need to remap ioapic RTE (reg: 10~3Fh) */
132 #define ioapic_reg_remapped(reg) (iommu_enabled && ((reg) >= 0x10))
134 static inline unsigned int __io_apic_read(unsigned int apic, unsigned int reg)
135 {
136 *IO_APIC_BASE(apic) = reg;
137 return *(IO_APIC_BASE(apic)+4);
138 }
140 static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
141 {
142 if (ioapic_reg_remapped(reg))
143 return iommu_read_apic_from_ire(apic, reg);
144 return __io_apic_read(apic, reg);
145 }
147 static inline void __io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
148 {
149 *IO_APIC_BASE(apic) = reg;
150 *(IO_APIC_BASE(apic)+4) = value;
151 }
153 static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
154 {
155 if (ioapic_reg_remapped(reg))
156 return iommu_update_ire_from_apic(apic, reg, value);
157 __io_apic_write(apic, reg, value);
158 }
160 static inline void io_apic_eoi(unsigned int apic, unsigned int vector)
161 {
162 *(IO_APIC_BASE(apic)+16) = vector;
163 }
165 /*
166 * Re-write a value: to be used for read-modify-write
167 * cycles where the read already set up the index register.
168 *
169 * Older SiS APIC requires we rewrite the index regiser
170 */
171 #ifdef __i386__
172 extern int sis_apic_bug;
173 #else
174 #define sis_apic_bug 0
175 #endif
176 static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
177 {
178 if (ioapic_reg_remapped(reg))
179 return iommu_update_ire_from_apic(apic, reg, value);
180 if (sis_apic_bug)
181 *IO_APIC_BASE(apic) = reg;
182 *(IO_APIC_BASE(apic)+4) = value;
183 }
185 /* 1 if "noapic" boot option passed */
186 extern bool_t skip_ioapic_setup;
188 #ifdef CONFIG_ACPI_BOOT
189 extern int io_apic_get_unique_id (int ioapic, int apic_id);
190 extern int io_apic_get_version (int ioapic);
191 extern int io_apic_get_redir_entries (int ioapic);
192 extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low);
193 #endif /*CONFIG_ACPI_BOOT*/
195 extern void init_ioapic_mappings(void);
197 extern void ioapic_suspend(void);
198 extern void ioapic_resume(void);
200 extern struct IO_APIC_route_entry **alloc_ioapic_entries(void);
201 extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries);
202 extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
203 extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
204 extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
206 #else /* !CONFIG_X86_IO_APIC */
207 static inline void init_ioapic_mappings(void) {}
208 static inline void ioapic_suspend(void) {}
209 static inline void ioapic_resume(void) {}
210 #endif
212 extern int assign_irq_vector(int irq);
213 extern int free_irq_vector(int vector);
215 #endif