paravirt.h 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  1. #ifndef __ASM_PARAVIRT_H
  2. #define __ASM_PARAVIRT_H
  3. /* Various instructions on x86 need to be replaced for
  4. * para-virtualization: those hooks are defined here. */
  5. #ifdef CONFIG_PARAVIRT
  6. #include <asm/page.h>
  7. /* Bitmask of what can be clobbered: usually at least eax. */
  8. #define CLBR_NONE 0x0
  9. #define CLBR_EAX 0x1
  10. #define CLBR_ECX 0x2
  11. #define CLBR_EDX 0x4
  12. #define CLBR_ANY 0x7
  13. #ifndef __ASSEMBLY__
  14. #include <linux/types.h>
  15. #include <linux/cpumask.h>
  16. #include <asm/kmap_types.h>
  17. #include <asm/desc_defs.h>
  18. struct page;
  19. struct thread_struct;
  20. struct desc_ptr;
  21. struct tss_struct;
  22. struct mm_struct;
  23. struct desc_struct;
  24. /* general info */
  25. struct pv_info {
  26. unsigned int kernel_rpl;
  27. int shared_kernel_pmd;
  28. int paravirt_enabled;
  29. const char *name;
  30. };
  31. struct pv_init_ops {
  32. /*
  33. * Patch may replace one of the defined code sequences with
  34. * arbitrary code, subject to the same register constraints.
  35. * This generally means the code is not free to clobber any
  36. * registers other than EAX. The patch function should return
  37. * the number of bytes of code generated, as we nop pad the
  38. * rest in generic code.
  39. */
  40. unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
  41. unsigned long addr, unsigned len);
  42. /* Basic arch-specific setup */
  43. void (*arch_setup)(void);
  44. char *(*memory_setup)(void);
  45. void (*post_allocator_init)(void);
  46. /* Print a banner to identify the environment */
  47. void (*banner)(void);
  48. };
  49. struct pv_lazy_ops {
  50. /* Set deferred update mode, used for batching operations. */
  51. void (*enter)(void);
  52. void (*leave)(void);
  53. };
  54. struct pv_time_ops {
  55. void (*time_init)(void);
  56. /* Set and set time of day */
  57. unsigned long (*get_wallclock)(void);
  58. int (*set_wallclock)(unsigned long);
  59. unsigned long long (*sched_clock)(void);
  60. unsigned long (*get_cpu_khz)(void);
  61. };
  62. struct pv_cpu_ops {
  63. /* hooks for various privileged instructions */
  64. unsigned long (*get_debugreg)(int regno);
  65. void (*set_debugreg)(int regno, unsigned long value);
  66. void (*clts)(void);
  67. unsigned long (*read_cr0)(void);
  68. void (*write_cr0)(unsigned long);
  69. unsigned long (*read_cr4_safe)(void);
  70. unsigned long (*read_cr4)(void);
  71. void (*write_cr4)(unsigned long);
  72. /* Segment descriptor handling */
  73. void (*load_tr_desc)(void);
  74. void (*load_gdt)(const struct desc_ptr *);
  75. void (*load_idt)(const struct desc_ptr *);
  76. void (*store_gdt)(struct desc_ptr *);
  77. void (*store_idt)(struct desc_ptr *);
  78. void (*set_ldt)(const void *desc, unsigned entries);
  79. unsigned long (*store_tr)(void);
  80. void (*load_tls)(struct thread_struct *t, unsigned int cpu);
  81. void (*write_ldt_entry)(struct desc_struct *,
  82. int entrynum, u32 low, u32 high);
  83. void (*write_gdt_entry)(struct desc_struct *,
  84. int entrynum, u32 low, u32 high);
  85. void (*write_idt_entry)(gate_desc *,
  86. int entrynum, const gate_desc *gate);
  87. void (*load_sp0)(struct tss_struct *tss, struct thread_struct *t);
  88. void (*set_iopl_mask)(unsigned mask);
  89. void (*wbinvd)(void);
  90. void (*io_delay)(void);
  91. /* cpuid emulation, mostly so that caps bits can be disabled */
  92. void (*cpuid)(unsigned int *eax, unsigned int *ebx,
  93. unsigned int *ecx, unsigned int *edx);
  94. /* MSR, PMC and TSR operations.
  95. err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */
  96. u64 (*read_msr)(unsigned int msr, int *err);
  97. int (*write_msr)(unsigned int msr, unsigned low, unsigned high);
  98. u64 (*read_tsc)(void);
  99. u64 (*read_pmc)(int counter);
  100. /* These two are jmp to, not actually called. */
  101. void (*irq_enable_syscall_ret)(void);
  102. void (*iret)(void);
  103. struct pv_lazy_ops lazy_mode;
  104. };
  105. struct pv_irq_ops {
  106. void (*init_IRQ)(void);
  107. /*
  108. * Get/set interrupt state. save_fl and restore_fl are only
  109. * expected to use X86_EFLAGS_IF; all other bits
  110. * returned from save_fl are undefined, and may be ignored by
  111. * restore_fl.
  112. */
  113. unsigned long (*save_fl)(void);
  114. void (*restore_fl)(unsigned long);
  115. void (*irq_disable)(void);
  116. void (*irq_enable)(void);
  117. void (*safe_halt)(void);
  118. void (*halt)(void);
  119. };
  120. struct pv_apic_ops {
  121. #ifdef CONFIG_X86_LOCAL_APIC
  122. /*
  123. * Direct APIC operations, principally for VMI. Ideally
  124. * these shouldn't be in this interface.
  125. */
  126. void (*apic_write)(unsigned long reg, u32 v);
  127. void (*apic_write_atomic)(unsigned long reg, u32 v);
  128. u32 (*apic_read)(unsigned long reg);
  129. void (*setup_boot_clock)(void);
  130. void (*setup_secondary_clock)(void);
  131. void (*startup_ipi_hook)(int phys_apicid,
  132. unsigned long start_eip,
  133. unsigned long start_esp);
  134. #endif
  135. };
  136. struct pv_mmu_ops {
  137. /*
  138. * Called before/after init_mm pagetable setup. setup_start
  139. * may reset %cr3, and may pre-install parts of the pagetable;
  140. * pagetable setup is expected to preserve any existing
  141. * mapping.
  142. */
  143. void (*pagetable_setup_start)(pgd_t *pgd_base);
  144. void (*pagetable_setup_done)(pgd_t *pgd_base);
  145. unsigned long (*read_cr2)(void);
  146. void (*write_cr2)(unsigned long);
  147. unsigned long (*read_cr3)(void);
  148. void (*write_cr3)(unsigned long);
  149. /*
  150. * Hooks for intercepting the creation/use/destruction of an
  151. * mm_struct.
  152. */
  153. void (*activate_mm)(struct mm_struct *prev,
  154. struct mm_struct *next);
  155. void (*dup_mmap)(struct mm_struct *oldmm,
  156. struct mm_struct *mm);
  157. void (*exit_mmap)(struct mm_struct *mm);
  158. /* TLB operations */
  159. void (*flush_tlb_user)(void);
  160. void (*flush_tlb_kernel)(void);
  161. void (*flush_tlb_single)(unsigned long addr);
  162. void (*flush_tlb_others)(const cpumask_t *cpus, struct mm_struct *mm,
  163. unsigned long va);
  164. /* Hooks for allocating/releasing pagetable pages */
  165. void (*alloc_pt)(struct mm_struct *mm, u32 pfn);
  166. void (*alloc_pd)(u32 pfn);
  167. void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count);
  168. void (*release_pt)(u32 pfn);
  169. void (*release_pd)(u32 pfn);
  170. /* Pagetable manipulation functions */
  171. void (*set_pte)(pte_t *ptep, pte_t pteval);
  172. void (*set_pte_at)(struct mm_struct *mm, unsigned long addr,
  173. pte_t *ptep, pte_t pteval);
  174. void (*set_pmd)(pmd_t *pmdp, pmd_t pmdval);
  175. void (*pte_update)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
  176. void (*pte_update_defer)(struct mm_struct *mm,
  177. unsigned long addr, pte_t *ptep);
  178. #ifdef CONFIG_X86_PAE
  179. void (*set_pte_atomic)(pte_t *ptep, pte_t pteval);
  180. void (*set_pte_present)(struct mm_struct *mm, unsigned long addr,
  181. pte_t *ptep, pte_t pte);
  182. void (*set_pud)(pud_t *pudp, pud_t pudval);
  183. void (*pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
  184. void (*pmd_clear)(pmd_t *pmdp);
  185. unsigned long long (*pte_val)(pte_t);
  186. unsigned long long (*pmd_val)(pmd_t);
  187. unsigned long long (*pgd_val)(pgd_t);
  188. pte_t (*make_pte)(unsigned long long pte);
  189. pmd_t (*make_pmd)(unsigned long long pmd);
  190. pgd_t (*make_pgd)(unsigned long long pgd);
  191. #else
  192. unsigned long (*pte_val)(pte_t);
  193. unsigned long (*pgd_val)(pgd_t);
  194. pte_t (*make_pte)(unsigned long pte);
  195. pgd_t (*make_pgd)(unsigned long pgd);
  196. #endif
  197. #ifdef CONFIG_HIGHPTE
  198. void *(*kmap_atomic_pte)(struct page *page, enum km_type type);
  199. #endif
  200. struct pv_lazy_ops lazy_mode;
  201. };
  202. /* This contains all the paravirt structures: we get a convenient
  203. * number for each function using the offset which we use to indicate
  204. * what to patch. */
  205. struct paravirt_patch_template
  206. {
  207. struct pv_init_ops pv_init_ops;
  208. struct pv_time_ops pv_time_ops;
  209. struct pv_cpu_ops pv_cpu_ops;
  210. struct pv_irq_ops pv_irq_ops;
  211. struct pv_apic_ops pv_apic_ops;
  212. struct pv_mmu_ops pv_mmu_ops;
  213. };
  214. extern struct pv_info pv_info;
  215. extern struct pv_init_ops pv_init_ops;
  216. extern struct pv_time_ops pv_time_ops;
  217. extern struct pv_cpu_ops pv_cpu_ops;
  218. extern struct pv_irq_ops pv_irq_ops;
  219. extern struct pv_apic_ops pv_apic_ops;
  220. extern struct pv_mmu_ops pv_mmu_ops;
  221. #define PARAVIRT_PATCH(x) \
  222. (offsetof(struct paravirt_patch_template, x) / sizeof(void *))
  223. #define paravirt_type(op) \
  224. [paravirt_typenum] "i" (PARAVIRT_PATCH(op)), \
  225. [paravirt_opptr] "m" (op)
  226. #define paravirt_clobber(clobber) \
  227. [paravirt_clobber] "i" (clobber)
  228. /*
  229. * Generate some code, and mark it as patchable by the
  230. * apply_paravirt() alternate instruction patcher.
  231. */
  232. #define _paravirt_alt(insn_string, type, clobber) \
  233. "771:\n\t" insn_string "\n" "772:\n" \
  234. ".pushsection .parainstructions,\"a\"\n" \
  235. " .long 771b\n" \
  236. " .byte " type "\n" \
  237. " .byte 772b-771b\n" \
  238. " .short " clobber "\n" \
  239. ".popsection\n"
  240. /* Generate patchable code, with the default asm parameters. */
  241. #define paravirt_alt(insn_string) \
  242. _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]")
  243. unsigned paravirt_patch_nop(void);
  244. unsigned paravirt_patch_ignore(unsigned len);
  245. unsigned paravirt_patch_call(void *insnbuf,
  246. const void *target, u16 tgt_clobbers,
  247. unsigned long addr, u16 site_clobbers,
  248. unsigned len);
  249. unsigned paravirt_patch_jmp(void *insnbuf, const void *target,
  250. unsigned long addr, unsigned len);
  251. unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
  252. unsigned long addr, unsigned len);
  253. unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
  254. const char *start, const char *end);
  255. int paravirt_disable_iospace(void);
  256. /*
  257. * This generates an indirect call based on the operation type number.
  258. * The type number, computed in PARAVIRT_PATCH, is derived from the
  259. * offset into the paravirt_patch_template structure, and can therefore be
  260. * freely converted back into a structure offset.
  261. */
  262. #define PARAVIRT_CALL "call *%[paravirt_opptr];"
  263. /*
  264. * These macros are intended to wrap calls through one of the paravirt
  265. * ops structs, so that they can be later identified and patched at
  266. * runtime.
  267. *
  268. * Normally, a call to a pv_op function is a simple indirect call:
  269. * (paravirt_ops.operations)(args...).
  270. *
  271. * Unfortunately, this is a relatively slow operation for modern CPUs,
  272. * because it cannot necessarily determine what the destination
  273. * address is. In this case, the address is a runtime constant, so at
  274. * the very least we can patch the call to e a simple direct call, or
  275. * ideally, patch an inline implementation into the callsite. (Direct
  276. * calls are essentially free, because the call and return addresses
  277. * are completely predictable.)
  278. *
  279. * These macros rely on the standard gcc "regparm(3)" calling
  280. * convention, in which the first three arguments are placed in %eax,
  281. * %edx, %ecx (in that order), and the remaining arguments are placed
  282. * on the stack. All caller-save registers (eax,edx,ecx) are expected
  283. * to be modified (either clobbered or used for return values).
  284. *
  285. * The call instruction itself is marked by placing its start address
  286. * and size into the .parainstructions section, so that
  287. * apply_paravirt() in arch/i386/kernel/alternative.c can do the
  288. * appropriate patching under the control of the backend pv_init_ops
  289. * implementation.
  290. *
  291. * Unfortunately there's no way to get gcc to generate the args setup
  292. * for the call, and then allow the call itself to be generated by an
  293. * inline asm. Because of this, we must do the complete arg setup and
  294. * return value handling from within these macros. This is fairly
  295. * cumbersome.
  296. *
  297. * There are 5 sets of PVOP_* macros for dealing with 0-4 arguments.
  298. * It could be extended to more arguments, but there would be little
  299. * to be gained from that. For each number of arguments, there are
  300. * the two VCALL and CALL variants for void and non-void functions.
  301. *
  302. * When there is a return value, the invoker of the macro must specify
  303. * the return type. The macro then uses sizeof() on that type to
  304. * determine whether its a 32 or 64 bit value, and places the return
  305. * in the right register(s) (just %eax for 32-bit, and %edx:%eax for
  306. * 64-bit).
  307. *
  308. * 64-bit arguments are passed as a pair of adjacent 32-bit arguments
  309. * in low,high order.
  310. *
  311. * Small structures are passed and returned in registers. The macro
  312. * calling convention can't directly deal with this, so the wrapper
  313. * functions must do this.
  314. *
  315. * These PVOP_* macros are only defined within this header. This
  316. * means that all uses must be wrapped in inline functions. This also
  317. * makes sure the incoming and outgoing types are always correct.
  318. */
  319. #define __PVOP_CALL(rettype, op, pre, post, ...) \
  320. ({ \
  321. rettype __ret; \
  322. unsigned long __eax, __edx, __ecx; \
  323. if (sizeof(rettype) > sizeof(unsigned long)) { \
  324. asm volatile(pre \
  325. paravirt_alt(PARAVIRT_CALL) \
  326. post \
  327. : "=a" (__eax), "=d" (__edx), \
  328. "=c" (__ecx) \
  329. : paravirt_type(op), \
  330. paravirt_clobber(CLBR_ANY), \
  331. ##__VA_ARGS__ \
  332. : "memory", "cc"); \
  333. __ret = (rettype)((((u64)__edx) << 32) | __eax); \
  334. } else { \
  335. asm volatile(pre \
  336. paravirt_alt(PARAVIRT_CALL) \
  337. post \
  338. : "=a" (__eax), "=d" (__edx), \
  339. "=c" (__ecx) \
  340. : paravirt_type(op), \
  341. paravirt_clobber(CLBR_ANY), \
  342. ##__VA_ARGS__ \
  343. : "memory", "cc"); \
  344. __ret = (rettype)__eax; \
  345. } \
  346. __ret; \
  347. })
  348. #define __PVOP_VCALL(op, pre, post, ...) \
  349. ({ \
  350. unsigned long __eax, __edx, __ecx; \
  351. asm volatile(pre \
  352. paravirt_alt(PARAVIRT_CALL) \
  353. post \
  354. : "=a" (__eax), "=d" (__edx), "=c" (__ecx) \
  355. : paravirt_type(op), \
  356. paravirt_clobber(CLBR_ANY), \
  357. ##__VA_ARGS__ \
  358. : "memory", "cc"); \
  359. })
  360. #define PVOP_CALL0(rettype, op) \
  361. __PVOP_CALL(rettype, op, "", "")
  362. #define PVOP_VCALL0(op) \
  363. __PVOP_VCALL(op, "", "")
  364. #define PVOP_CALL1(rettype, op, arg1) \
  365. __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)))
  366. #define PVOP_VCALL1(op, arg1) \
  367. __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)))
  368. #define PVOP_CALL2(rettype, op, arg1, arg2) \
  369. __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)), "1" ((u32)(arg2)))
  370. #define PVOP_VCALL2(op, arg1, arg2) \
  371. __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)), "1" ((u32)(arg2)))
  372. #define PVOP_CALL3(rettype, op, arg1, arg2, arg3) \
  373. __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)), \
  374. "1"((u32)(arg2)), "2"((u32)(arg3)))
  375. #define PVOP_VCALL3(op, arg1, arg2, arg3) \
  376. __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)), "1"((u32)(arg2)), \
  377. "2"((u32)(arg3)))
  378. #define PVOP_CALL4(rettype, op, arg1, arg2, arg3, arg4) \
  379. __PVOP_CALL(rettype, op, \
  380. "push %[_arg4];", "lea 4(%%esp),%%esp;", \
  381. "0" ((u32)(arg1)), "1" ((u32)(arg2)), \
  382. "2" ((u32)(arg3)), [_arg4] "mr" ((u32)(arg4)))
  383. #define PVOP_VCALL4(op, arg1, arg2, arg3, arg4) \
  384. __PVOP_VCALL(op, \
  385. "push %[_arg4];", "lea 4(%%esp),%%esp;", \
  386. "0" ((u32)(arg1)), "1" ((u32)(arg2)), \
  387. "2" ((u32)(arg3)), [_arg4] "mr" ((u32)(arg4)))
  388. static inline int paravirt_enabled(void)
  389. {
  390. return pv_info.paravirt_enabled;
  391. }
  392. static inline void load_sp0(struct tss_struct *tss,
  393. struct thread_struct *thread)
  394. {
  395. PVOP_VCALL2(pv_cpu_ops.load_sp0, tss, thread);
  396. }
  397. #define ARCH_SETUP pv_init_ops.arch_setup();
  398. static inline unsigned long get_wallclock(void)
  399. {
  400. return PVOP_CALL0(unsigned long, pv_time_ops.get_wallclock);
  401. }
  402. static inline int set_wallclock(unsigned long nowtime)
  403. {
  404. return PVOP_CALL1(int, pv_time_ops.set_wallclock, nowtime);
  405. }
  406. static inline void (*choose_time_init(void))(void)
  407. {
  408. return pv_time_ops.time_init;
  409. }
  410. /* The paravirtualized CPUID instruction. */
  411. static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
  412. unsigned int *ecx, unsigned int *edx)
  413. {
  414. PVOP_VCALL4(pv_cpu_ops.cpuid, eax, ebx, ecx, edx);
  415. }
  416. /*
  417. * These special macros can be used to get or set a debugging register
  418. */
  419. static inline unsigned long paravirt_get_debugreg(int reg)
  420. {
  421. return PVOP_CALL1(unsigned long, pv_cpu_ops.get_debugreg, reg);
  422. }
  423. #define get_debugreg(var, reg) var = paravirt_get_debugreg(reg)
  424. static inline void set_debugreg(unsigned long val, int reg)
  425. {
  426. PVOP_VCALL2(pv_cpu_ops.set_debugreg, reg, val);
  427. }
  428. static inline void clts(void)
  429. {
  430. PVOP_VCALL0(pv_cpu_ops.clts);
  431. }
  432. static inline unsigned long read_cr0(void)
  433. {
  434. return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr0);
  435. }
  436. static inline void write_cr0(unsigned long x)
  437. {
  438. PVOP_VCALL1(pv_cpu_ops.write_cr0, x);
  439. }
  440. static inline unsigned long read_cr2(void)
  441. {
  442. return PVOP_CALL0(unsigned long, pv_mmu_ops.read_cr2);
  443. }
  444. static inline void write_cr2(unsigned long x)
  445. {
  446. PVOP_VCALL1(pv_mmu_ops.write_cr2, x);
  447. }
  448. static inline unsigned long read_cr3(void)
  449. {
  450. return PVOP_CALL0(unsigned long, pv_mmu_ops.read_cr3);
  451. }
  452. static inline void write_cr3(unsigned long x)
  453. {
  454. PVOP_VCALL1(pv_mmu_ops.write_cr3, x);
  455. }
  456. static inline unsigned long read_cr4(void)
  457. {
  458. return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr4);
  459. }
  460. static inline unsigned long read_cr4_safe(void)
  461. {
  462. return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr4_safe);
  463. }
  464. static inline void write_cr4(unsigned long x)
  465. {
  466. PVOP_VCALL1(pv_cpu_ops.write_cr4, x);
  467. }
  468. static inline void raw_safe_halt(void)
  469. {
  470. PVOP_VCALL0(pv_irq_ops.safe_halt);
  471. }
  472. static inline void halt(void)
  473. {
  474. PVOP_VCALL0(pv_irq_ops.safe_halt);
  475. }
  476. static inline void wbinvd(void)
  477. {
  478. PVOP_VCALL0(pv_cpu_ops.wbinvd);
  479. }
  480. #define get_kernel_rpl() (pv_info.kernel_rpl)
  481. static inline u64 paravirt_read_msr(unsigned msr, int *err)
  482. {
  483. return PVOP_CALL2(u64, pv_cpu_ops.read_msr, msr, err);
  484. }
  485. static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high)
  486. {
  487. return PVOP_CALL3(int, pv_cpu_ops.write_msr, msr, low, high);
  488. }
  489. /* These should all do BUG_ON(_err), but our headers are too tangled. */
  490. #define rdmsr(msr,val1,val2) do { \
  491. int _err; \
  492. u64 _l = paravirt_read_msr(msr, &_err); \
  493. val1 = (u32)_l; \
  494. val2 = _l >> 32; \
  495. } while(0)
  496. #define wrmsr(msr,val1,val2) do { \
  497. paravirt_write_msr(msr, val1, val2); \
  498. } while(0)
  499. #define rdmsrl(msr,val) do { \
  500. int _err; \
  501. val = paravirt_read_msr(msr, &_err); \
  502. } while(0)
  503. #define wrmsrl(msr,val) wrmsr(msr, (u32)((u64)(val)), ((u64)(val))>>32)
  504. #define wrmsr_safe(msr,a,b) paravirt_write_msr(msr, a, b)
  505. /* rdmsr with exception handling */
  506. #define rdmsr_safe(msr,a,b) ({ \
  507. int _err; \
  508. u64 _l = paravirt_read_msr(msr, &_err); \
  509. (*a) = (u32)_l; \
  510. (*b) = _l >> 32; \
  511. _err; })
  512. static inline u64 paravirt_read_tsc(void)
  513. {
  514. return PVOP_CALL0(u64, pv_cpu_ops.read_tsc);
  515. }
  516. #define rdtscl(low) do { \
  517. u64 _l = paravirt_read_tsc(); \
  518. low = (int)_l; \
  519. } while(0)
  520. #define rdtscll(val) (val = paravirt_read_tsc())
  521. static inline unsigned long long paravirt_sched_clock(void)
  522. {
  523. return PVOP_CALL0(unsigned long long, pv_time_ops.sched_clock);
  524. }
  525. #define calculate_cpu_khz() (pv_time_ops.get_cpu_khz())
  526. #define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
  527. static inline unsigned long long paravirt_read_pmc(int counter)
  528. {
  529. return PVOP_CALL1(u64, pv_cpu_ops.read_pmc, counter);
  530. }
  531. #define rdpmc(counter,low,high) do { \
  532. u64 _l = paravirt_read_pmc(counter); \
  533. low = (u32)_l; \
  534. high = _l >> 32; \
  535. } while(0)
  536. static inline void load_TR_desc(void)
  537. {
  538. PVOP_VCALL0(pv_cpu_ops.load_tr_desc);
  539. }
  540. static inline void load_gdt(const struct desc_ptr *dtr)
  541. {
  542. PVOP_VCALL1(pv_cpu_ops.load_gdt, dtr);
  543. }
  544. static inline void load_idt(const struct desc_ptr *dtr)
  545. {
  546. PVOP_VCALL1(pv_cpu_ops.load_idt, dtr);
  547. }
  548. static inline void set_ldt(const void *addr, unsigned entries)
  549. {
  550. PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries);
  551. }
  552. static inline void store_gdt(struct desc_ptr *dtr)
  553. {
  554. PVOP_VCALL1(pv_cpu_ops.store_gdt, dtr);
  555. }
  556. static inline void store_idt(struct desc_ptr *dtr)
  557. {
  558. PVOP_VCALL1(pv_cpu_ops.store_idt, dtr);
  559. }
  560. static inline unsigned long paravirt_store_tr(void)
  561. {
  562. return PVOP_CALL0(unsigned long, pv_cpu_ops.store_tr);
  563. }
  564. #define store_tr(tr) ((tr) = paravirt_store_tr())
  565. static inline void load_TLS(struct thread_struct *t, unsigned cpu)
  566. {
  567. PVOP_VCALL2(pv_cpu_ops.load_tls, t, cpu);
  568. }
  569. static inline void write_ldt_entry(void *dt, int entry, u32 low, u32 high)
  570. {
  571. PVOP_VCALL4(pv_cpu_ops.write_ldt_entry, dt, entry, low, high);
  572. }
  573. static inline void write_gdt_entry(void *dt, int entry, u32 low, u32 high)
  574. {
  575. PVOP_VCALL4(pv_cpu_ops.write_gdt_entry, dt, entry, low, high);
  576. }
  577. static inline void write_idt_entry(gate_desc *dt, int entry, const gate_desc *g)
  578. {
  579. PVOP_VCALL3(pv_cpu_ops.write_idt_entry, dt, entry, g);
  580. }
  581. static inline void set_iopl_mask(unsigned mask)
  582. {
  583. PVOP_VCALL1(pv_cpu_ops.set_iopl_mask, mask);
  584. }
  585. /* The paravirtualized I/O functions */
  586. static inline void slow_down_io(void) {
  587. pv_cpu_ops.io_delay();
  588. #ifdef REALLY_SLOW_IO
  589. pv_cpu_ops.io_delay();
  590. pv_cpu_ops.io_delay();
  591. pv_cpu_ops.io_delay();
  592. #endif
  593. }
  594. #ifdef CONFIG_X86_LOCAL_APIC
  595. /*
  596. * Basic functions accessing APICs.
  597. */
  598. static inline void apic_write(unsigned long reg, u32 v)
  599. {
  600. PVOP_VCALL2(pv_apic_ops.apic_write, reg, v);
  601. }
  602. static inline void apic_write_atomic(unsigned long reg, u32 v)
  603. {
  604. PVOP_VCALL2(pv_apic_ops.apic_write_atomic, reg, v);
  605. }
  606. static inline u32 apic_read(unsigned long reg)
  607. {
  608. return PVOP_CALL1(unsigned long, pv_apic_ops.apic_read, reg);
  609. }
  610. static inline void setup_boot_clock(void)
  611. {
  612. PVOP_VCALL0(pv_apic_ops.setup_boot_clock);
  613. }
  614. static inline void setup_secondary_clock(void)
  615. {
  616. PVOP_VCALL0(pv_apic_ops.setup_secondary_clock);
  617. }
  618. #endif
  619. static inline void paravirt_post_allocator_init(void)
  620. {
  621. if (pv_init_ops.post_allocator_init)
  622. (*pv_init_ops.post_allocator_init)();
  623. }
  624. static inline void paravirt_pagetable_setup_start(pgd_t *base)
  625. {
  626. (*pv_mmu_ops.pagetable_setup_start)(base);
  627. }
  628. static inline void paravirt_pagetable_setup_done(pgd_t *base)
  629. {
  630. (*pv_mmu_ops.pagetable_setup_done)(base);
  631. }
  632. #ifdef CONFIG_SMP
  633. static inline void startup_ipi_hook(int phys_apicid, unsigned long start_eip,
  634. unsigned long start_esp)
  635. {
  636. PVOP_VCALL3(pv_apic_ops.startup_ipi_hook,
  637. phys_apicid, start_eip, start_esp);
  638. }
  639. #endif
  640. static inline void paravirt_activate_mm(struct mm_struct *prev,
  641. struct mm_struct *next)
  642. {
  643. PVOP_VCALL2(pv_mmu_ops.activate_mm, prev, next);
  644. }
  645. static inline void arch_dup_mmap(struct mm_struct *oldmm,
  646. struct mm_struct *mm)
  647. {
  648. PVOP_VCALL2(pv_mmu_ops.dup_mmap, oldmm, mm);
  649. }
  650. static inline void arch_exit_mmap(struct mm_struct *mm)
  651. {
  652. PVOP_VCALL1(pv_mmu_ops.exit_mmap, mm);
  653. }
  654. static inline void __flush_tlb(void)
  655. {
  656. PVOP_VCALL0(pv_mmu_ops.flush_tlb_user);
  657. }
  658. static inline void __flush_tlb_global(void)
  659. {
  660. PVOP_VCALL0(pv_mmu_ops.flush_tlb_kernel);
  661. }
  662. static inline void __flush_tlb_single(unsigned long addr)
  663. {
  664. PVOP_VCALL1(pv_mmu_ops.flush_tlb_single, addr);
  665. }
  666. static inline void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
  667. unsigned long va)
  668. {
  669. PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, &cpumask, mm, va);
  670. }
  671. static inline void paravirt_alloc_pt(struct mm_struct *mm, unsigned pfn)
  672. {
  673. PVOP_VCALL2(pv_mmu_ops.alloc_pt, mm, pfn);
  674. }
  675. static inline void paravirt_release_pt(unsigned pfn)
  676. {
  677. PVOP_VCALL1(pv_mmu_ops.release_pt, pfn);
  678. }
  679. static inline void paravirt_alloc_pd(unsigned pfn)
  680. {
  681. PVOP_VCALL1(pv_mmu_ops.alloc_pd, pfn);
  682. }
  683. static inline void paravirt_alloc_pd_clone(unsigned pfn, unsigned clonepfn,
  684. unsigned start, unsigned count)
  685. {
  686. PVOP_VCALL4(pv_mmu_ops.alloc_pd_clone, pfn, clonepfn, start, count);
  687. }
  688. static inline void paravirt_release_pd(unsigned pfn)
  689. {
  690. PVOP_VCALL1(pv_mmu_ops.release_pd, pfn);
  691. }
  692. #ifdef CONFIG_HIGHPTE
  693. static inline void *kmap_atomic_pte(struct page *page, enum km_type type)
  694. {
  695. unsigned long ret;
  696. ret = PVOP_CALL2(unsigned long, pv_mmu_ops.kmap_atomic_pte, page, type);
  697. return (void *)ret;
  698. }
  699. #endif
  700. static inline void pte_update(struct mm_struct *mm, unsigned long addr,
  701. pte_t *ptep)
  702. {
  703. PVOP_VCALL3(pv_mmu_ops.pte_update, mm, addr, ptep);
  704. }
  705. static inline void pte_update_defer(struct mm_struct *mm, unsigned long addr,
  706. pte_t *ptep)
  707. {
  708. PVOP_VCALL3(pv_mmu_ops.pte_update_defer, mm, addr, ptep);
  709. }
  710. #ifdef CONFIG_X86_PAE
  711. static inline pte_t __pte(unsigned long long val)
  712. {
  713. unsigned long long ret = PVOP_CALL2(unsigned long long,
  714. pv_mmu_ops.make_pte,
  715. val, val >> 32);
  716. return (pte_t) { ret, ret >> 32 };
  717. }
  718. static inline pmd_t __pmd(unsigned long long val)
  719. {
  720. return (pmd_t) { PVOP_CALL2(unsigned long long, pv_mmu_ops.make_pmd,
  721. val, val >> 32) };
  722. }
  723. static inline pgd_t __pgd(unsigned long long val)
  724. {
  725. return (pgd_t) { PVOP_CALL2(unsigned long long, pv_mmu_ops.make_pgd,
  726. val, val >> 32) };
  727. }
  728. static inline unsigned long long pte_val(pte_t x)
  729. {
  730. return PVOP_CALL2(unsigned long long, pv_mmu_ops.pte_val,
  731. x.pte_low, x.pte_high);
  732. }
  733. static inline unsigned long long pmd_val(pmd_t x)
  734. {
  735. return PVOP_CALL2(unsigned long long, pv_mmu_ops.pmd_val,
  736. x.pmd, x.pmd >> 32);
  737. }
  738. static inline unsigned long long pgd_val(pgd_t x)
  739. {
  740. return PVOP_CALL2(unsigned long long, pv_mmu_ops.pgd_val,
  741. x.pgd, x.pgd >> 32);
  742. }
  743. static inline void set_pte(pte_t *ptep, pte_t pteval)
  744. {
  745. PVOP_VCALL3(pv_mmu_ops.set_pte, ptep, pteval.pte_low, pteval.pte_high);
  746. }
  747. static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
  748. pte_t *ptep, pte_t pteval)
  749. {
  750. /* 5 arg words */
  751. pv_mmu_ops.set_pte_at(mm, addr, ptep, pteval);
  752. }
  753. static inline void set_pte_atomic(pte_t *ptep, pte_t pteval)
  754. {
  755. PVOP_VCALL3(pv_mmu_ops.set_pte_atomic, ptep,
  756. pteval.pte_low, pteval.pte_high);
  757. }
  758. static inline void set_pte_present(struct mm_struct *mm, unsigned long addr,
  759. pte_t *ptep, pte_t pte)
  760. {
  761. /* 5 arg words */
  762. pv_mmu_ops.set_pte_present(mm, addr, ptep, pte);
  763. }
  764. static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval)
  765. {
  766. PVOP_VCALL3(pv_mmu_ops.set_pmd, pmdp,
  767. pmdval.pmd, pmdval.pmd >> 32);
  768. }
  769. static inline void set_pud(pud_t *pudp, pud_t pudval)
  770. {
  771. PVOP_VCALL3(pv_mmu_ops.set_pud, pudp,
  772. pudval.pgd.pgd, pudval.pgd.pgd >> 32);
  773. }
  774. static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
  775. {
  776. PVOP_VCALL3(pv_mmu_ops.pte_clear, mm, addr, ptep);
  777. }
  778. static inline void pmd_clear(pmd_t *pmdp)
  779. {
  780. PVOP_VCALL1(pv_mmu_ops.pmd_clear, pmdp);
  781. }
  782. #else /* !CONFIG_X86_PAE */
  783. static inline pte_t __pte(unsigned long val)
  784. {
  785. return (pte_t) { PVOP_CALL1(unsigned long, pv_mmu_ops.make_pte, val) };
  786. }
  787. static inline pgd_t __pgd(unsigned long val)
  788. {
  789. return (pgd_t) { PVOP_CALL1(unsigned long, pv_mmu_ops.make_pgd, val) };
  790. }
  791. static inline unsigned long pte_val(pte_t x)
  792. {
  793. return PVOP_CALL1(unsigned long, pv_mmu_ops.pte_val, x.pte_low);
  794. }
  795. static inline unsigned long pgd_val(pgd_t x)
  796. {
  797. return PVOP_CALL1(unsigned long, pv_mmu_ops.pgd_val, x.pgd);
  798. }
  799. static inline void set_pte(pte_t *ptep, pte_t pteval)
  800. {
  801. PVOP_VCALL2(pv_mmu_ops.set_pte, ptep, pteval.pte_low);
  802. }
  803. static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
  804. pte_t *ptep, pte_t pteval)
  805. {
  806. PVOP_VCALL4(pv_mmu_ops.set_pte_at, mm, addr, ptep, pteval.pte_low);
  807. }
  808. static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval)
  809. {
  810. PVOP_VCALL2(pv_mmu_ops.set_pmd, pmdp, pmdval.pud.pgd.pgd);
  811. }
  812. #endif /* CONFIG_X86_PAE */
  813. /* Lazy mode for batching updates / context switch */
  814. enum paravirt_lazy_mode {
  815. PARAVIRT_LAZY_NONE,
  816. PARAVIRT_LAZY_MMU,
  817. PARAVIRT_LAZY_CPU,
  818. };
  819. enum paravirt_lazy_mode paravirt_get_lazy_mode(void);
  820. void paravirt_enter_lazy_cpu(void);
  821. void paravirt_leave_lazy_cpu(void);
  822. void paravirt_enter_lazy_mmu(void);
  823. void paravirt_leave_lazy_mmu(void);
  824. void paravirt_leave_lazy(enum paravirt_lazy_mode mode);
  825. #define __HAVE_ARCH_ENTER_LAZY_CPU_MODE
  826. static inline void arch_enter_lazy_cpu_mode(void)
  827. {
  828. PVOP_VCALL0(pv_cpu_ops.lazy_mode.enter);
  829. }
  830. static inline void arch_leave_lazy_cpu_mode(void)
  831. {
  832. PVOP_VCALL0(pv_cpu_ops.lazy_mode.leave);
  833. }
  834. static inline void arch_flush_lazy_cpu_mode(void)
  835. {
  836. if (unlikely(paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU)) {
  837. arch_leave_lazy_cpu_mode();
  838. arch_enter_lazy_cpu_mode();
  839. }
  840. }
  841. #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
  842. static inline void arch_enter_lazy_mmu_mode(void)
  843. {
  844. PVOP_VCALL0(pv_mmu_ops.lazy_mode.enter);
  845. }
  846. static inline void arch_leave_lazy_mmu_mode(void)
  847. {
  848. PVOP_VCALL0(pv_mmu_ops.lazy_mode.leave);
  849. }
  850. static inline void arch_flush_lazy_mmu_mode(void)
  851. {
  852. if (unlikely(paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU)) {
  853. arch_leave_lazy_mmu_mode();
  854. arch_enter_lazy_mmu_mode();
  855. }
  856. }
  857. void _paravirt_nop(void);
  858. #define paravirt_nop ((void *)_paravirt_nop)
  859. /* These all sit in the .parainstructions section to tell us what to patch. */
  860. struct paravirt_patch_site {
  861. u8 *instr; /* original instructions */
  862. u8 instrtype; /* type of this instruction */
  863. u8 len; /* length of original instruction */
  864. u16 clobbers; /* what registers you may clobber */
  865. };
  866. extern struct paravirt_patch_site __parainstructions[],
  867. __parainstructions_end[];
  868. static inline unsigned long __raw_local_save_flags(void)
  869. {
  870. unsigned long f;
  871. asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;"
  872. PARAVIRT_CALL
  873. "popl %%edx; popl %%ecx")
  874. : "=a"(f)
  875. : paravirt_type(pv_irq_ops.save_fl),
  876. paravirt_clobber(CLBR_EAX)
  877. : "memory", "cc");
  878. return f;
  879. }
  880. static inline void raw_local_irq_restore(unsigned long f)
  881. {
  882. asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;"
  883. PARAVIRT_CALL
  884. "popl %%edx; popl %%ecx")
  885. : "=a"(f)
  886. : "0"(f),
  887. paravirt_type(pv_irq_ops.restore_fl),
  888. paravirt_clobber(CLBR_EAX)
  889. : "memory", "cc");
  890. }
  891. static inline void raw_local_irq_disable(void)
  892. {
  893. asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;"
  894. PARAVIRT_CALL
  895. "popl %%edx; popl %%ecx")
  896. :
  897. : paravirt_type(pv_irq_ops.irq_disable),
  898. paravirt_clobber(CLBR_EAX)
  899. : "memory", "eax", "cc");
  900. }
  901. static inline void raw_local_irq_enable(void)
  902. {
  903. asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;"
  904. PARAVIRT_CALL
  905. "popl %%edx; popl %%ecx")
  906. :
  907. : paravirt_type(pv_irq_ops.irq_enable),
  908. paravirt_clobber(CLBR_EAX)
  909. : "memory", "eax", "cc");
  910. }
  911. static inline unsigned long __raw_local_irq_save(void)
  912. {
  913. unsigned long f;
  914. f = __raw_local_save_flags();
  915. raw_local_irq_disable();
  916. return f;
  917. }
  918. #define CLI_STRING \
  919. _paravirt_alt("pushl %%ecx; pushl %%edx;" \
  920. "call *%[paravirt_cli_opptr];" \
  921. "popl %%edx; popl %%ecx", \
  922. "%c[paravirt_cli_type]", "%c[paravirt_clobber]")
  923. #define STI_STRING \
  924. _paravirt_alt("pushl %%ecx; pushl %%edx;" \
  925. "call *%[paravirt_sti_opptr];" \
  926. "popl %%edx; popl %%ecx", \
  927. "%c[paravirt_sti_type]", "%c[paravirt_clobber]")
  928. #define CLI_STI_CLOBBERS , "%eax"
  929. #define CLI_STI_INPUT_ARGS \
  930. , \
  931. [paravirt_cli_type] "i" (PARAVIRT_PATCH(pv_irq_ops.irq_disable)), \
  932. [paravirt_cli_opptr] "m" (pv_irq_ops.irq_disable), \
  933. [paravirt_sti_type] "i" (PARAVIRT_PATCH(pv_irq_ops.irq_enable)), \
  934. [paravirt_sti_opptr] "m" (pv_irq_ops.irq_enable), \
  935. paravirt_clobber(CLBR_EAX)
  936. /* Make sure as little as possible of this mess escapes. */
  937. #undef PARAVIRT_CALL
  938. #undef __PVOP_CALL
  939. #undef __PVOP_VCALL
  940. #undef PVOP_VCALL0
  941. #undef PVOP_CALL0
  942. #undef PVOP_VCALL1
  943. #undef PVOP_CALL1
  944. #undef PVOP_VCALL2
  945. #undef PVOP_CALL2
  946. #undef PVOP_VCALL3
  947. #undef PVOP_CALL3
  948. #undef PVOP_VCALL4
  949. #undef PVOP_CALL4
  950. #else /* __ASSEMBLY__ */
  951. #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
  952. #define PARA_SITE(ptype, clobbers, ops) \
  953. 771:; \
  954. ops; \
  955. 772:; \
  956. .pushsection .parainstructions,"a"; \
  957. .long 771b; \
  958. .byte ptype; \
  959. .byte 772b-771b; \
  960. .short clobbers; \
  961. .popsection
  962. #define INTERRUPT_RETURN \
  963. PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_iret), CLBR_NONE, \
  964. jmp *%cs:pv_cpu_ops+PV_CPU_iret)
  965. #define DISABLE_INTERRUPTS(clobbers) \
  966. PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_irq_disable), clobbers, \
  967. pushl %eax; pushl %ecx; pushl %edx; \
  968. call *%cs:pv_irq_ops+PV_IRQ_irq_disable; \
  969. popl %edx; popl %ecx; popl %eax) \
  970. #define ENABLE_INTERRUPTS(clobbers) \
  971. PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_irq_enable), clobbers, \
  972. pushl %eax; pushl %ecx; pushl %edx; \
  973. call *%cs:pv_irq_ops+PV_IRQ_irq_enable; \
  974. popl %edx; popl %ecx; popl %eax)
  975. #define ENABLE_INTERRUPTS_SYSCALL_RET \
  976. PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_syscall_ret),\
  977. CLBR_NONE, \
  978. jmp *%cs:pv_cpu_ops+PV_CPU_irq_enable_syscall_ret)
  979. #define GET_CR0_INTO_EAX \
  980. push %ecx; push %edx; \
  981. call *pv_cpu_ops+PV_CPU_read_cr0; \
  982. pop %edx; pop %ecx
  983. #endif /* __ASSEMBLY__ */
  984. #endif /* CONFIG_PARAVIRT */
  985. #endif /* __ASM_PARAVIRT_H */