xen_pv_ops.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  1. /******************************************************************************
  2. * arch/ia64/xen/xen_pv_ops.c
  3. *
  4. * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
  5. * VA Linux Systems Japan K.K.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #include <linux/console.h>
  23. #include <linux/irq.h>
  24. #include <linux/kernel.h>
  25. #include <linux/pm.h>
  26. #include <linux/unistd.h>
  27. #include <asm/xen/hypervisor.h>
  28. #include <asm/xen/xencomm.h>
  29. #include <asm/xen/privop.h>
  30. #include "irq_xen.h"
  31. #include "time.h"
  32. /***************************************************************************
  33. * general info
  34. */
  35. static struct pv_info xen_info __initdata = {
  36. .kernel_rpl = 2, /* or 1: determin at runtime */
  37. .paravirt_enabled = 1,
  38. .name = "Xen/ia64",
  39. };
  40. #define IA64_RSC_PL_SHIFT 2
  41. #define IA64_RSC_PL_BIT_SIZE 2
  42. #define IA64_RSC_PL_MASK \
  43. (((1UL << IA64_RSC_PL_BIT_SIZE) - 1) << IA64_RSC_PL_SHIFT)
  44. static void __init
  45. xen_info_init(void)
  46. {
  47. /* Xenified Linux/ia64 may run on pl = 1 or 2.
  48. * determin at run time. */
  49. unsigned long rsc = ia64_getreg(_IA64_REG_AR_RSC);
  50. unsigned int rpl = (rsc & IA64_RSC_PL_MASK) >> IA64_RSC_PL_SHIFT;
  51. xen_info.kernel_rpl = rpl;
  52. }
  53. /***************************************************************************
  54. * pv_init_ops
  55. * initialization hooks.
  56. */
  57. static void
  58. xen_panic_hypercall(struct unw_frame_info *info, void *arg)
  59. {
  60. current->thread.ksp = (__u64)info->sw - 16;
  61. HYPERVISOR_shutdown(SHUTDOWN_crash);
  62. /* we're never actually going to get here... */
  63. }
  64. static int
  65. xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
  66. {
  67. unw_init_running(xen_panic_hypercall, NULL);
  68. /* we're never actually going to get here... */
  69. return NOTIFY_DONE;
  70. }
  71. static struct notifier_block xen_panic_block = {
  72. xen_panic_event, NULL, 0 /* try to go last */
  73. };
  74. static void xen_pm_power_off(void)
  75. {
  76. local_irq_disable();
  77. HYPERVISOR_shutdown(SHUTDOWN_poweroff);
  78. }
  79. static void __init
  80. xen_banner(void)
  81. {
  82. printk(KERN_INFO
  83. "Running on Xen! pl = %d start_info_pfn=0x%lx nr_pages=%ld "
  84. "flags=0x%x\n",
  85. xen_info.kernel_rpl,
  86. HYPERVISOR_shared_info->arch.start_info_pfn,
  87. xen_start_info->nr_pages, xen_start_info->flags);
  88. }
  89. static int __init
  90. xen_reserve_memory(struct rsvd_region *region)
  91. {
  92. region->start = (unsigned long)__va(
  93. (HYPERVISOR_shared_info->arch.start_info_pfn << PAGE_SHIFT));
  94. region->end = region->start + PAGE_SIZE;
  95. return 1;
  96. }
  97. static void __init
  98. xen_arch_setup_early(void)
  99. {
  100. struct shared_info *s;
  101. BUG_ON(!xen_pv_domain());
  102. s = HYPERVISOR_shared_info;
  103. xen_start_info = __va(s->arch.start_info_pfn << PAGE_SHIFT);
  104. /* Must be done before any hypercall. */
  105. xencomm_initialize();
  106. xen_setup_features();
  107. /* Register a call for panic conditions. */
  108. atomic_notifier_chain_register(&panic_notifier_list,
  109. &xen_panic_block);
  110. pm_power_off = xen_pm_power_off;
  111. xen_ia64_enable_opt_feature();
  112. }
  113. static void __init
  114. xen_arch_setup_console(char **cmdline_p)
  115. {
  116. add_preferred_console("xenboot", 0, NULL);
  117. add_preferred_console("tty", 0, NULL);
  118. /* use hvc_xen */
  119. add_preferred_console("hvc", 0, NULL);
  120. #if !defined(CONFIG_VT) || !defined(CONFIG_DUMMY_CONSOLE)
  121. conswitchp = NULL;
  122. #endif
  123. }
  124. static int __init
  125. xen_arch_setup_nomca(void)
  126. {
  127. return 1;
  128. }
  129. static void __init
  130. xen_post_smp_prepare_boot_cpu(void)
  131. {
  132. xen_setup_vcpu_info_placement();
  133. }
  134. #ifdef ASM_SUPPORTED
  135. static unsigned long __init_or_module
  136. xen_patch_bundle(void *sbundle, void *ebundle, unsigned long type);
  137. #endif
  138. static void __init
  139. xen_patch_branch(unsigned long tag, unsigned long type);
  140. static const struct pv_init_ops xen_init_ops __initconst = {
  141. .banner = xen_banner,
  142. .reserve_memory = xen_reserve_memory,
  143. .arch_setup_early = xen_arch_setup_early,
  144. .arch_setup_console = xen_arch_setup_console,
  145. .arch_setup_nomca = xen_arch_setup_nomca,
  146. .post_smp_prepare_boot_cpu = xen_post_smp_prepare_boot_cpu,
  147. #ifdef ASM_SUPPORTED
  148. .patch_bundle = xen_patch_bundle,
  149. #endif
  150. .patch_branch = xen_patch_branch,
  151. };
  152. /***************************************************************************
  153. * pv_fsys_data
  154. * addresses for fsys
  155. */
  156. extern unsigned long xen_fsyscall_table[NR_syscalls];
  157. extern char xen_fsys_bubble_down[];
  158. struct pv_fsys_data xen_fsys_data __initdata = {
  159. .fsyscall_table = (unsigned long *)xen_fsyscall_table,
  160. .fsys_bubble_down = (void *)xen_fsys_bubble_down,
  161. };
  162. /***************************************************************************
  163. * pv_patchdata
  164. * patchdata addresses
  165. */
  166. #define DECLARE(name) \
  167. extern unsigned long __xen_start_gate_##name##_patchlist[]; \
  168. extern unsigned long __xen_end_gate_##name##_patchlist[]
  169. DECLARE(fsyscall);
  170. DECLARE(brl_fsys_bubble_down);
  171. DECLARE(vtop);
  172. DECLARE(mckinley_e9);
  173. extern unsigned long __xen_start_gate_section[];
  174. #define ASSIGN(name) \
  175. .start_##name##_patchlist = \
  176. (unsigned long)__xen_start_gate_##name##_patchlist, \
  177. .end_##name##_patchlist = \
  178. (unsigned long)__xen_end_gate_##name##_patchlist
  179. static struct pv_patchdata xen_patchdata __initdata = {
  180. ASSIGN(fsyscall),
  181. ASSIGN(brl_fsys_bubble_down),
  182. ASSIGN(vtop),
  183. ASSIGN(mckinley_e9),
  184. .gate_section = (void*)__xen_start_gate_section,
  185. };
  186. /***************************************************************************
  187. * pv_cpu_ops
  188. * intrinsics hooks.
  189. */
  190. #ifndef ASM_SUPPORTED
  191. static void
  192. xen_set_itm_with_offset(unsigned long val)
  193. {
  194. /* ia64_cpu_local_tick() calls this with interrupt enabled. */
  195. /* WARN_ON(!irqs_disabled()); */
  196. xen_set_itm(val - XEN_MAPPEDREGS->itc_offset);
  197. }
  198. static unsigned long
  199. xen_get_itm_with_offset(void)
  200. {
  201. /* unused at this moment */
  202. printk(KERN_DEBUG "%s is called.\n", __func__);
  203. WARN_ON(!irqs_disabled());
  204. return ia64_native_getreg(_IA64_REG_CR_ITM) +
  205. XEN_MAPPEDREGS->itc_offset;
  206. }
  207. /* ia64_set_itc() is only called by
  208. * cpu_init() with ia64_set_itc(0) and ia64_sync_itc().
  209. * So XEN_MAPPEDRESG->itc_offset cal be considered as almost constant.
  210. */
  211. static void
  212. xen_set_itc(unsigned long val)
  213. {
  214. unsigned long mitc;
  215. WARN_ON(!irqs_disabled());
  216. mitc = ia64_native_getreg(_IA64_REG_AR_ITC);
  217. XEN_MAPPEDREGS->itc_offset = val - mitc;
  218. XEN_MAPPEDREGS->itc_last = val;
  219. }
  220. static unsigned long
  221. xen_get_itc(void)
  222. {
  223. unsigned long res;
  224. unsigned long itc_offset;
  225. unsigned long itc_last;
  226. unsigned long ret_itc_last;
  227. itc_offset = XEN_MAPPEDREGS->itc_offset;
  228. do {
  229. itc_last = XEN_MAPPEDREGS->itc_last;
  230. res = ia64_native_getreg(_IA64_REG_AR_ITC);
  231. res += itc_offset;
  232. if (itc_last >= res)
  233. res = itc_last + 1;
  234. ret_itc_last = cmpxchg(&XEN_MAPPEDREGS->itc_last,
  235. itc_last, res);
  236. } while (unlikely(ret_itc_last != itc_last));
  237. return res;
  238. #if 0
  239. /* ia64_itc_udelay() calls ia64_get_itc() with interrupt enabled.
  240. Should it be paravirtualized instead? */
  241. WARN_ON(!irqs_disabled());
  242. itc_offset = XEN_MAPPEDREGS->itc_offset;
  243. itc_last = XEN_MAPPEDREGS->itc_last;
  244. res = ia64_native_getreg(_IA64_REG_AR_ITC);
  245. res += itc_offset;
  246. if (itc_last >= res)
  247. res = itc_last + 1;
  248. XEN_MAPPEDREGS->itc_last = res;
  249. return res;
  250. #endif
  251. }
  252. static void xen_setreg(int regnum, unsigned long val)
  253. {
  254. switch (regnum) {
  255. case _IA64_REG_AR_KR0 ... _IA64_REG_AR_KR7:
  256. xen_set_kr(regnum - _IA64_REG_AR_KR0, val);
  257. break;
  258. case _IA64_REG_AR_ITC:
  259. xen_set_itc(val);
  260. break;
  261. case _IA64_REG_CR_TPR:
  262. xen_set_tpr(val);
  263. break;
  264. case _IA64_REG_CR_ITM:
  265. xen_set_itm_with_offset(val);
  266. break;
  267. case _IA64_REG_CR_EOI:
  268. xen_eoi(val);
  269. break;
  270. default:
  271. ia64_native_setreg_func(regnum, val);
  272. break;
  273. }
  274. }
  275. static unsigned long xen_getreg(int regnum)
  276. {
  277. unsigned long res;
  278. switch (regnum) {
  279. case _IA64_REG_PSR:
  280. res = xen_get_psr();
  281. break;
  282. case _IA64_REG_AR_ITC:
  283. res = xen_get_itc();
  284. break;
  285. case _IA64_REG_CR_ITM:
  286. res = xen_get_itm_with_offset();
  287. break;
  288. case _IA64_REG_CR_IVR:
  289. res = xen_get_ivr();
  290. break;
  291. case _IA64_REG_CR_TPR:
  292. res = xen_get_tpr();
  293. break;
  294. default:
  295. res = ia64_native_getreg_func(regnum);
  296. break;
  297. }
  298. return res;
  299. }
  300. /* turning on interrupts is a bit more complicated.. write to the
  301. * memory-mapped virtual psr.i bit first (to avoid race condition),
  302. * then if any interrupts were pending, we have to execute a hyperprivop
  303. * to ensure the pending interrupt gets delivered; else we're done! */
  304. static void
  305. xen_ssm_i(void)
  306. {
  307. int old = xen_get_virtual_psr_i();
  308. xen_set_virtual_psr_i(1);
  309. barrier();
  310. if (!old && xen_get_virtual_pend())
  311. xen_hyper_ssm_i();
  312. }
  313. /* turning off interrupts can be paravirtualized simply by writing
  314. * to a memory-mapped virtual psr.i bit (implemented as a 16-bit bool) */
  315. static void
  316. xen_rsm_i(void)
  317. {
  318. xen_set_virtual_psr_i(0);
  319. barrier();
  320. }
  321. static unsigned long
  322. xen_get_psr_i(void)
  323. {
  324. return xen_get_virtual_psr_i() ? IA64_PSR_I : 0;
  325. }
  326. static void
  327. xen_intrin_local_irq_restore(unsigned long mask)
  328. {
  329. if (mask & IA64_PSR_I)
  330. xen_ssm_i();
  331. else
  332. xen_rsm_i();
  333. }
  334. #else
  335. #define __DEFINE_FUNC(name, code) \
  336. extern const char xen_ ## name ## _direct_start[]; \
  337. extern const char xen_ ## name ## _direct_end[]; \
  338. asm (".align 32\n" \
  339. ".proc xen_" #name "\n" \
  340. "xen_" #name ":\n" \
  341. "xen_" #name "_direct_start:\n" \
  342. code \
  343. "xen_" #name "_direct_end:\n" \
  344. "br.cond.sptk.many b6\n" \
  345. ".endp xen_" #name "\n")
  346. #define DEFINE_VOID_FUNC0(name, code) \
  347. extern void \
  348. xen_ ## name (void); \
  349. __DEFINE_FUNC(name, code)
  350. #define DEFINE_VOID_FUNC1(name, code) \
  351. extern void \
  352. xen_ ## name (unsigned long arg); \
  353. __DEFINE_FUNC(name, code)
  354. #define DEFINE_VOID_FUNC1_VOID(name, code) \
  355. extern void \
  356. xen_ ## name (void *arg); \
  357. __DEFINE_FUNC(name, code)
  358. #define DEFINE_VOID_FUNC2(name, code) \
  359. extern void \
  360. xen_ ## name (unsigned long arg0, \
  361. unsigned long arg1); \
  362. __DEFINE_FUNC(name, code)
  363. #define DEFINE_FUNC0(name, code) \
  364. extern unsigned long \
  365. xen_ ## name (void); \
  366. __DEFINE_FUNC(name, code)
  367. #define DEFINE_FUNC1(name, type, code) \
  368. extern unsigned long \
  369. xen_ ## name (type arg); \
  370. __DEFINE_FUNC(name, code)
  371. #define XEN_PSR_I_ADDR_ADDR (XSI_BASE + XSI_PSR_I_ADDR_OFS)
  372. /*
  373. * static void xen_set_itm_with_offset(unsigned long val)
  374. * xen_set_itm(val - XEN_MAPPEDREGS->itc_offset);
  375. */
  376. /* 2 bundles */
  377. DEFINE_VOID_FUNC1(set_itm_with_offset,
  378. "mov r2 = " __stringify(XSI_BASE) " + "
  379. __stringify(XSI_ITC_OFFSET_OFS) "\n"
  380. ";;\n"
  381. "ld8 r3 = [r2]\n"
  382. ";;\n"
  383. "sub r8 = r8, r3\n"
  384. "break " __stringify(HYPERPRIVOP_SET_ITM) "\n");
  385. /*
  386. * static unsigned long xen_get_itm_with_offset(void)
  387. * return ia64_native_getreg(_IA64_REG_CR_ITM) + XEN_MAPPEDREGS->itc_offset;
  388. */
  389. /* 2 bundles */
  390. DEFINE_FUNC0(get_itm_with_offset,
  391. "mov r2 = " __stringify(XSI_BASE) " + "
  392. __stringify(XSI_ITC_OFFSET_OFS) "\n"
  393. ";;\n"
  394. "ld8 r3 = [r2]\n"
  395. "mov r8 = cr.itm\n"
  396. ";;\n"
  397. "add r8 = r8, r2\n");
  398. /*
  399. * static void xen_set_itc(unsigned long val)
  400. * unsigned long mitc;
  401. *
  402. * WARN_ON(!irqs_disabled());
  403. * mitc = ia64_native_getreg(_IA64_REG_AR_ITC);
  404. * XEN_MAPPEDREGS->itc_offset = val - mitc;
  405. * XEN_MAPPEDREGS->itc_last = val;
  406. */
  407. /* 2 bundles */
  408. DEFINE_VOID_FUNC1(set_itc,
  409. "mov r2 = " __stringify(XSI_BASE) " + "
  410. __stringify(XSI_ITC_LAST_OFS) "\n"
  411. "mov r3 = ar.itc\n"
  412. ";;\n"
  413. "sub r3 = r8, r3\n"
  414. "st8 [r2] = r8, "
  415. __stringify(XSI_ITC_LAST_OFS) " - "
  416. __stringify(XSI_ITC_OFFSET_OFS) "\n"
  417. ";;\n"
  418. "st8 [r2] = r3\n");
  419. /*
  420. * static unsigned long xen_get_itc(void)
  421. * unsigned long res;
  422. * unsigned long itc_offset;
  423. * unsigned long itc_last;
  424. * unsigned long ret_itc_last;
  425. *
  426. * itc_offset = XEN_MAPPEDREGS->itc_offset;
  427. * do {
  428. * itc_last = XEN_MAPPEDREGS->itc_last;
  429. * res = ia64_native_getreg(_IA64_REG_AR_ITC);
  430. * res += itc_offset;
  431. * if (itc_last >= res)
  432. * res = itc_last + 1;
  433. * ret_itc_last = cmpxchg(&XEN_MAPPEDREGS->itc_last,
  434. * itc_last, res);
  435. * } while (unlikely(ret_itc_last != itc_last));
  436. * return res;
  437. */
  438. /* 5 bundles */
  439. DEFINE_FUNC0(get_itc,
  440. "mov r2 = " __stringify(XSI_BASE) " + "
  441. __stringify(XSI_ITC_OFFSET_OFS) "\n"
  442. ";;\n"
  443. "ld8 r9 = [r2], " __stringify(XSI_ITC_LAST_OFS) " - "
  444. __stringify(XSI_ITC_OFFSET_OFS) "\n"
  445. /* r9 = itc_offset */
  446. /* r2 = XSI_ITC_OFFSET */
  447. "888:\n"
  448. "mov r8 = ar.itc\n" /* res = ar.itc */
  449. ";;\n"
  450. "ld8 r3 = [r2]\n" /* r3 = itc_last */
  451. "add r8 = r8, r9\n" /* res = ar.itc + itc_offset */
  452. ";;\n"
  453. "cmp.gtu p6, p0 = r3, r8\n"
  454. ";;\n"
  455. "(p6) add r8 = 1, r3\n" /* if (itc_last > res) itc_last + 1 */
  456. ";;\n"
  457. "mov ar.ccv = r8\n"
  458. ";;\n"
  459. "cmpxchg8.acq r10 = [r2], r8, ar.ccv\n"
  460. ";;\n"
  461. "cmp.ne p6, p0 = r10, r3\n"
  462. "(p6) hint @pause\n"
  463. "(p6) br.cond.spnt 888b\n");
  464. DEFINE_VOID_FUNC1_VOID(fc,
  465. "break " __stringify(HYPERPRIVOP_FC) "\n");
  466. /*
  467. * psr_i_addr_addr = XEN_PSR_I_ADDR_ADDR
  468. * masked_addr = *psr_i_addr_addr
  469. * pending_intr_addr = masked_addr - 1
  470. * if (val & IA64_PSR_I) {
  471. * masked = *masked_addr
  472. * *masked_addr = 0:xen_set_virtual_psr_i(1)
  473. * compiler barrier
  474. * if (masked) {
  475. * uint8_t pending = *pending_intr_addr;
  476. * if (pending)
  477. * XEN_HYPER_SSM_I
  478. * }
  479. * } else {
  480. * *masked_addr = 1:xen_set_virtual_psr_i(0)
  481. * }
  482. */
  483. /* 6 bundles */
  484. DEFINE_VOID_FUNC1(intrin_local_irq_restore,
  485. /* r8 = input value: 0 or IA64_PSR_I
  486. * p6 = (flags & IA64_PSR_I)
  487. * = if clause
  488. * p7 = !(flags & IA64_PSR_I)
  489. * = else clause
  490. */
  491. "cmp.ne p6, p7 = r8, r0\n"
  492. "mov r9 = " __stringify(XEN_PSR_I_ADDR_ADDR) "\n"
  493. ";;\n"
  494. /* r9 = XEN_PSR_I_ADDR */
  495. "ld8 r9 = [r9]\n"
  496. ";;\n"
  497. /* r10 = masked previous value */
  498. "(p6) ld1.acq r10 = [r9]\n"
  499. ";;\n"
  500. /* p8 = !masked interrupt masked previously? */
  501. "(p6) cmp.ne.unc p8, p0 = r10, r0\n"
  502. /* p7 = else clause */
  503. "(p7) mov r11 = 1\n"
  504. ";;\n"
  505. /* masked = 1 */
  506. "(p7) st1.rel [r9] = r11\n"
  507. /* p6 = if clause */
  508. /* masked = 0
  509. * r9 = masked_addr - 1
  510. * = pending_intr_addr
  511. */
  512. "(p8) st1.rel [r9] = r0, -1\n"
  513. ";;\n"
  514. /* r8 = pending_intr */
  515. "(p8) ld1.acq r11 = [r9]\n"
  516. ";;\n"
  517. /* p9 = interrupt pending? */
  518. "(p8) cmp.ne.unc p9, p10 = r11, r0\n"
  519. ";;\n"
  520. "(p10) mf\n"
  521. /* issue hypercall to trigger interrupt */
  522. "(p9) break " __stringify(HYPERPRIVOP_SSM_I) "\n");
  523. DEFINE_VOID_FUNC2(ptcga,
  524. "break " __stringify(HYPERPRIVOP_PTC_GA) "\n");
  525. DEFINE_VOID_FUNC2(set_rr,
  526. "break " __stringify(HYPERPRIVOP_SET_RR) "\n");
  527. /*
  528. * tmp = XEN_MAPPEDREGS->interrupt_mask_addr = XEN_PSR_I_ADDR_ADDR;
  529. * tmp = *tmp
  530. * tmp = *tmp;
  531. * psr_i = tmp? 0: IA64_PSR_I;
  532. */
  533. /* 4 bundles */
  534. DEFINE_FUNC0(get_psr_i,
  535. "mov r9 = " __stringify(XEN_PSR_I_ADDR_ADDR) "\n"
  536. ";;\n"
  537. "ld8 r9 = [r9]\n" /* r9 = XEN_PSR_I_ADDR */
  538. "mov r8 = 0\n" /* psr_i = 0 */
  539. ";;\n"
  540. "ld1.acq r9 = [r9]\n" /* r9 = XEN_PSR_I */
  541. ";;\n"
  542. "cmp.eq.unc p6, p0 = r9, r0\n" /* p6 = (XEN_PSR_I != 0) */
  543. ";;\n"
  544. "(p6) mov r8 = " __stringify(1 << IA64_PSR_I_BIT) "\n");
  545. DEFINE_FUNC1(thash, unsigned long,
  546. "break " __stringify(HYPERPRIVOP_THASH) "\n");
  547. DEFINE_FUNC1(get_cpuid, int,
  548. "break " __stringify(HYPERPRIVOP_GET_CPUID) "\n");
  549. DEFINE_FUNC1(get_pmd, int,
  550. "break " __stringify(HYPERPRIVOP_GET_PMD) "\n");
  551. DEFINE_FUNC1(get_rr, unsigned long,
  552. "break " __stringify(HYPERPRIVOP_GET_RR) "\n");
  553. /*
  554. * void xen_privop_ssm_i(void)
  555. *
  556. * int masked = !xen_get_virtual_psr_i();
  557. * // masked = *(*XEN_MAPPEDREGS->interrupt_mask_addr)
  558. * xen_set_virtual_psr_i(1)
  559. * // *(*XEN_MAPPEDREGS->interrupt_mask_addr) = 0
  560. * // compiler barrier
  561. * if (masked) {
  562. * uint8_t* pend_int_addr =
  563. * (uint8_t*)(*XEN_MAPPEDREGS->interrupt_mask_addr) - 1;
  564. * uint8_t pending = *pend_int_addr;
  565. * if (pending)
  566. * XEN_HYPER_SSM_I
  567. * }
  568. */
  569. /* 4 bundles */
  570. DEFINE_VOID_FUNC0(ssm_i,
  571. "mov r8 = " __stringify(XEN_PSR_I_ADDR_ADDR) "\n"
  572. ";;\n"
  573. "ld8 r8 = [r8]\n" /* r8 = XEN_PSR_I_ADDR */
  574. ";;\n"
  575. "ld1.acq r9 = [r8]\n" /* r9 = XEN_PSR_I */
  576. ";;\n"
  577. "st1.rel [r8] = r0, -1\n" /* psr_i = 0. enable interrupt
  578. * r8 = XEN_PSR_I_ADDR - 1
  579. * = pend_int_addr
  580. */
  581. "cmp.eq.unc p0, p6 = r9, r0\n"/* p6 = !XEN_PSR_I
  582. * previously interrupt
  583. * masked?
  584. */
  585. ";;\n"
  586. "(p6) ld1.acq r8 = [r8]\n" /* r8 = xen_pend_int */
  587. ";;\n"
  588. "(p6) cmp.eq.unc p6, p7 = r8, r0\n" /*interrupt pending?*/
  589. ";;\n"
  590. /* issue hypercall to get interrupt */
  591. "(p7) break " __stringify(HYPERPRIVOP_SSM_I) "\n"
  592. ";;\n");
  593. /*
  594. * psr_i_addr_addr = XEN_MAPPEDREGS->interrupt_mask_addr
  595. * = XEN_PSR_I_ADDR_ADDR;
  596. * psr_i_addr = *psr_i_addr_addr;
  597. * *psr_i_addr = 1;
  598. */
  599. /* 2 bundles */
  600. DEFINE_VOID_FUNC0(rsm_i,
  601. "mov r8 = " __stringify(XEN_PSR_I_ADDR_ADDR) "\n"
  602. /* r8 = XEN_PSR_I_ADDR */
  603. "mov r9 = 1\n"
  604. ";;\n"
  605. "ld8 r8 = [r8]\n" /* r8 = XEN_PSR_I */
  606. ";;\n"
  607. "st1.rel [r8] = r9\n"); /* XEN_PSR_I = 1 */
  608. extern void
  609. xen_set_rr0_to_rr4(unsigned long val0, unsigned long val1,
  610. unsigned long val2, unsigned long val3,
  611. unsigned long val4);
  612. __DEFINE_FUNC(set_rr0_to_rr4,
  613. "break " __stringify(HYPERPRIVOP_SET_RR0_TO_RR4) "\n");
  614. extern unsigned long xen_getreg(int regnum);
  615. #define __DEFINE_GET_REG(id, privop) \
  616. "mov r2 = " __stringify(_IA64_REG_ ## id) "\n" \
  617. ";;\n" \
  618. "cmp.eq p6, p0 = r2, r8\n" \
  619. ";;\n" \
  620. "(p6) break " __stringify(HYPERPRIVOP_GET_ ## privop) "\n" \
  621. "(p6) br.cond.sptk.many b6\n" \
  622. ";;\n"
  623. __DEFINE_FUNC(getreg,
  624. __DEFINE_GET_REG(PSR, PSR)
  625. /* get_itc */
  626. "mov r2 = " __stringify(_IA64_REG_AR_ITC) "\n"
  627. ";;\n"
  628. "cmp.eq p6, p0 = r2, r8\n"
  629. ";;\n"
  630. "(p6) br.cond.spnt xen_get_itc\n"
  631. ";;\n"
  632. /* get itm */
  633. "mov r2 = " __stringify(_IA64_REG_CR_ITM) "\n"
  634. ";;\n"
  635. "cmp.eq p6, p0 = r2, r8\n"
  636. ";;\n"
  637. "(p6) br.cond.spnt xen_get_itm_with_offset\n"
  638. ";;\n"
  639. __DEFINE_GET_REG(CR_IVR, IVR)
  640. __DEFINE_GET_REG(CR_TPR, TPR)
  641. /* fall back */
  642. "movl r2 = ia64_native_getreg_func\n"
  643. ";;\n"
  644. "mov b7 = r2\n"
  645. ";;\n"
  646. "br.cond.sptk.many b7\n");
  647. extern void xen_setreg(int regnum, unsigned long val);
  648. #define __DEFINE_SET_REG(id, privop) \
  649. "mov r2 = " __stringify(_IA64_REG_ ## id) "\n" \
  650. ";;\n" \
  651. "cmp.eq p6, p0 = r2, r9\n" \
  652. ";;\n" \
  653. "(p6) break " __stringify(HYPERPRIVOP_ ## privop) "\n" \
  654. "(p6) br.cond.sptk.many b6\n" \
  655. ";;\n"
  656. __DEFINE_FUNC(setreg,
  657. /* kr0 .. kr 7*/
  658. /*
  659. * if (_IA64_REG_AR_KR0 <= regnum &&
  660. * regnum <= _IA64_REG_AR_KR7) {
  661. * register __index asm ("r8") = regnum - _IA64_REG_AR_KR0
  662. * register __val asm ("r9") = val
  663. * "break HYPERPRIVOP_SET_KR"
  664. * }
  665. */
  666. "mov r17 = r9\n"
  667. "mov r2 = " __stringify(_IA64_REG_AR_KR0) "\n"
  668. ";;\n"
  669. "cmp.ge p6, p0 = r9, r2\n"
  670. "sub r17 = r17, r2\n"
  671. ";;\n"
  672. "(p6) cmp.ge.unc p7, p0 = "
  673. __stringify(_IA64_REG_AR_KR7) " - " __stringify(_IA64_REG_AR_KR0)
  674. ", r17\n"
  675. ";;\n"
  676. "(p7) mov r9 = r8\n"
  677. ";;\n"
  678. "(p7) mov r8 = r17\n"
  679. "(p7) break " __stringify(HYPERPRIVOP_SET_KR) "\n"
  680. /* set itm */
  681. "mov r2 = " __stringify(_IA64_REG_CR_ITM) "\n"
  682. ";;\n"
  683. "cmp.eq p6, p0 = r2, r8\n"
  684. ";;\n"
  685. "(p6) br.cond.spnt xen_set_itm_with_offset\n"
  686. /* set itc */
  687. "mov r2 = " __stringify(_IA64_REG_AR_ITC) "\n"
  688. ";;\n"
  689. "cmp.eq p6, p0 = r2, r8\n"
  690. ";;\n"
  691. "(p6) br.cond.spnt xen_set_itc\n"
  692. __DEFINE_SET_REG(CR_TPR, SET_TPR)
  693. __DEFINE_SET_REG(CR_EOI, EOI)
  694. /* fall back */
  695. "movl r2 = ia64_native_setreg_func\n"
  696. ";;\n"
  697. "mov b7 = r2\n"
  698. ";;\n"
  699. "br.cond.sptk.many b7\n");
  700. #endif
  701. static const struct pv_cpu_ops xen_cpu_ops __initconst = {
  702. .fc = xen_fc,
  703. .thash = xen_thash,
  704. .get_cpuid = xen_get_cpuid,
  705. .get_pmd = xen_get_pmd,
  706. .getreg = xen_getreg,
  707. .setreg = xen_setreg,
  708. .ptcga = xen_ptcga,
  709. .get_rr = xen_get_rr,
  710. .set_rr = xen_set_rr,
  711. .set_rr0_to_rr4 = xen_set_rr0_to_rr4,
  712. .ssm_i = xen_ssm_i,
  713. .rsm_i = xen_rsm_i,
  714. .get_psr_i = xen_get_psr_i,
  715. .intrin_local_irq_restore
  716. = xen_intrin_local_irq_restore,
  717. };
  718. /******************************************************************************
  719. * replacement of hand written assembly codes.
  720. */
  721. extern char xen_switch_to;
  722. extern char xen_leave_syscall;
  723. extern char xen_work_processed_syscall;
  724. extern char xen_leave_kernel;
  725. const struct pv_cpu_asm_switch xen_cpu_asm_switch = {
  726. .switch_to = (unsigned long)&xen_switch_to,
  727. .leave_syscall = (unsigned long)&xen_leave_syscall,
  728. .work_processed_syscall = (unsigned long)&xen_work_processed_syscall,
  729. .leave_kernel = (unsigned long)&xen_leave_kernel,
  730. };
  731. /***************************************************************************
  732. * pv_iosapic_ops
  733. * iosapic read/write hooks.
  734. */
  735. static void
  736. xen_pcat_compat_init(void)
  737. {
  738. /* nothing */
  739. }
  740. static struct irq_chip*
  741. xen_iosapic_get_irq_chip(unsigned long trigger)
  742. {
  743. return NULL;
  744. }
  745. static unsigned int
  746. xen_iosapic_read(char __iomem *iosapic, unsigned int reg)
  747. {
  748. struct physdev_apic apic_op;
  749. int ret;
  750. apic_op.apic_physbase = (unsigned long)iosapic -
  751. __IA64_UNCACHED_OFFSET;
  752. apic_op.reg = reg;
  753. ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);
  754. if (ret)
  755. return ret;
  756. return apic_op.value;
  757. }
  758. static void
  759. xen_iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)
  760. {
  761. struct physdev_apic apic_op;
  762. apic_op.apic_physbase = (unsigned long)iosapic -
  763. __IA64_UNCACHED_OFFSET;
  764. apic_op.reg = reg;
  765. apic_op.value = val;
  766. HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op);
  767. }
  768. static struct pv_iosapic_ops xen_iosapic_ops __initdata = {
  769. .pcat_compat_init = xen_pcat_compat_init,
  770. .__get_irq_chip = xen_iosapic_get_irq_chip,
  771. .__read = xen_iosapic_read,
  772. .__write = xen_iosapic_write,
  773. };
  774. /***************************************************************************
  775. * pv_ops initialization
  776. */
  777. void __init
  778. xen_setup_pv_ops(void)
  779. {
  780. xen_info_init();
  781. pv_info = xen_info;
  782. pv_init_ops = xen_init_ops;
  783. pv_fsys_data = xen_fsys_data;
  784. pv_patchdata = xen_patchdata;
  785. pv_cpu_ops = xen_cpu_ops;
  786. pv_iosapic_ops = xen_iosapic_ops;
  787. pv_irq_ops = xen_irq_ops;
  788. pv_time_ops = xen_time_ops;
  789. paravirt_cpu_asm_init(&xen_cpu_asm_switch);
  790. }
  791. #ifdef ASM_SUPPORTED
  792. /***************************************************************************
  793. * binary pacthing
  794. * pv_init_ops.patch_bundle
  795. */
  796. #define DEFINE_FUNC_GETREG(name, privop) \
  797. DEFINE_FUNC0(get_ ## name, \
  798. "break "__stringify(HYPERPRIVOP_GET_ ## privop) "\n")
  799. DEFINE_FUNC_GETREG(psr, PSR);
  800. DEFINE_FUNC_GETREG(eflag, EFLAG);
  801. DEFINE_FUNC_GETREG(ivr, IVR);
  802. DEFINE_FUNC_GETREG(tpr, TPR);
  803. #define DEFINE_FUNC_SET_KR(n) \
  804. DEFINE_VOID_FUNC0(set_kr ## n, \
  805. ";;\n" \
  806. "mov r9 = r8\n" \
  807. "mov r8 = " #n "\n" \
  808. "break " __stringify(HYPERPRIVOP_SET_KR) "\n")
  809. DEFINE_FUNC_SET_KR(0);
  810. DEFINE_FUNC_SET_KR(1);
  811. DEFINE_FUNC_SET_KR(2);
  812. DEFINE_FUNC_SET_KR(3);
  813. DEFINE_FUNC_SET_KR(4);
  814. DEFINE_FUNC_SET_KR(5);
  815. DEFINE_FUNC_SET_KR(6);
  816. DEFINE_FUNC_SET_KR(7);
  817. #define __DEFINE_FUNC_SETREG(name, privop) \
  818. DEFINE_VOID_FUNC0(name, \
  819. "break "__stringify(HYPERPRIVOP_ ## privop) "\n")
  820. #define DEFINE_FUNC_SETREG(name, privop) \
  821. __DEFINE_FUNC_SETREG(set_ ## name, SET_ ## privop)
  822. DEFINE_FUNC_SETREG(eflag, EFLAG);
  823. DEFINE_FUNC_SETREG(tpr, TPR);
  824. __DEFINE_FUNC_SETREG(eoi, EOI);
  825. extern const char xen_check_events[];
  826. extern const char __xen_intrin_local_irq_restore_direct_start[];
  827. extern const char __xen_intrin_local_irq_restore_direct_end[];
  828. extern const unsigned long __xen_intrin_local_irq_restore_direct_reloc;
  829. asm (
  830. ".align 32\n"
  831. ".proc xen_check_events\n"
  832. "xen_check_events:\n"
  833. /* masked = 0
  834. * r9 = masked_addr - 1
  835. * = pending_intr_addr
  836. */
  837. "st1.rel [r9] = r0, -1\n"
  838. ";;\n"
  839. /* r8 = pending_intr */
  840. "ld1.acq r11 = [r9]\n"
  841. ";;\n"
  842. /* p9 = interrupt pending? */
  843. "cmp.ne p9, p10 = r11, r0\n"
  844. ";;\n"
  845. "(p10) mf\n"
  846. /* issue hypercall to trigger interrupt */
  847. "(p9) break " __stringify(HYPERPRIVOP_SSM_I) "\n"
  848. "br.cond.sptk.many b6\n"
  849. ".endp xen_check_events\n"
  850. "\n"
  851. ".align 32\n"
  852. ".proc __xen_intrin_local_irq_restore_direct\n"
  853. "__xen_intrin_local_irq_restore_direct:\n"
  854. "__xen_intrin_local_irq_restore_direct_start:\n"
  855. "1:\n"
  856. "{\n"
  857. "cmp.ne p6, p7 = r8, r0\n"
  858. "mov r17 = ip\n" /* get ip to calc return address */
  859. "mov r9 = "__stringify(XEN_PSR_I_ADDR_ADDR) "\n"
  860. ";;\n"
  861. "}\n"
  862. "{\n"
  863. /* r9 = XEN_PSR_I_ADDR */
  864. "ld8 r9 = [r9]\n"
  865. ";;\n"
  866. /* r10 = masked previous value */
  867. "(p6) ld1.acq r10 = [r9]\n"
  868. "adds r17 = 1f - 1b, r17\n" /* calculate return address */
  869. ";;\n"
  870. "}\n"
  871. "{\n"
  872. /* p8 = !masked interrupt masked previously? */
  873. "(p6) cmp.ne.unc p8, p0 = r10, r0\n"
  874. "\n"
  875. /* p7 = else clause */
  876. "(p7) mov r11 = 1\n"
  877. ";;\n"
  878. "(p8) mov b6 = r17\n" /* set return address */
  879. "}\n"
  880. "{\n"
  881. /* masked = 1 */
  882. "(p7) st1.rel [r9] = r11\n"
  883. "\n"
  884. "[99:]\n"
  885. "(p8) brl.cond.dptk.few xen_check_events\n"
  886. "}\n"
  887. /* pv calling stub is 5 bundles. fill nop to adjust return address */
  888. "{\n"
  889. "nop 0\n"
  890. "nop 0\n"
  891. "nop 0\n"
  892. "}\n"
  893. "1:\n"
  894. "__xen_intrin_local_irq_restore_direct_end:\n"
  895. ".endp __xen_intrin_local_irq_restore_direct\n"
  896. "\n"
  897. ".align 8\n"
  898. "__xen_intrin_local_irq_restore_direct_reloc:\n"
  899. "data8 99b\n"
  900. );
  901. static struct paravirt_patch_bundle_elem xen_patch_bundle_elems[]
  902. __initdata_or_module =
  903. {
  904. #define XEN_PATCH_BUNDLE_ELEM(name, type) \
  905. { \
  906. (void*)xen_ ## name ## _direct_start, \
  907. (void*)xen_ ## name ## _direct_end, \
  908. PARAVIRT_PATCH_TYPE_ ## type, \
  909. }
  910. XEN_PATCH_BUNDLE_ELEM(fc, FC),
  911. XEN_PATCH_BUNDLE_ELEM(thash, THASH),
  912. XEN_PATCH_BUNDLE_ELEM(get_cpuid, GET_CPUID),
  913. XEN_PATCH_BUNDLE_ELEM(get_pmd, GET_PMD),
  914. XEN_PATCH_BUNDLE_ELEM(ptcga, PTCGA),
  915. XEN_PATCH_BUNDLE_ELEM(get_rr, GET_RR),
  916. XEN_PATCH_BUNDLE_ELEM(set_rr, SET_RR),
  917. XEN_PATCH_BUNDLE_ELEM(set_rr0_to_rr4, SET_RR0_TO_RR4),
  918. XEN_PATCH_BUNDLE_ELEM(ssm_i, SSM_I),
  919. XEN_PATCH_BUNDLE_ELEM(rsm_i, RSM_I),
  920. XEN_PATCH_BUNDLE_ELEM(get_psr_i, GET_PSR_I),
  921. {
  922. (void*)__xen_intrin_local_irq_restore_direct_start,
  923. (void*)__xen_intrin_local_irq_restore_direct_end,
  924. PARAVIRT_PATCH_TYPE_INTRIN_LOCAL_IRQ_RESTORE,
  925. },
  926. #define XEN_PATCH_BUNDLE_ELEM_GETREG(name, reg) \
  927. { \
  928. xen_get_ ## name ## _direct_start, \
  929. xen_get_ ## name ## _direct_end, \
  930. PARAVIRT_PATCH_TYPE_GETREG + _IA64_REG_ ## reg, \
  931. }
  932. XEN_PATCH_BUNDLE_ELEM_GETREG(psr, PSR),
  933. XEN_PATCH_BUNDLE_ELEM_GETREG(eflag, AR_EFLAG),
  934. XEN_PATCH_BUNDLE_ELEM_GETREG(ivr, CR_IVR),
  935. XEN_PATCH_BUNDLE_ELEM_GETREG(tpr, CR_TPR),
  936. XEN_PATCH_BUNDLE_ELEM_GETREG(itc, AR_ITC),
  937. XEN_PATCH_BUNDLE_ELEM_GETREG(itm_with_offset, CR_ITM),
  938. #define __XEN_PATCH_BUNDLE_ELEM_SETREG(name, reg) \
  939. { \
  940. xen_ ## name ## _direct_start, \
  941. xen_ ## name ## _direct_end, \
  942. PARAVIRT_PATCH_TYPE_SETREG + _IA64_REG_ ## reg, \
  943. }
  944. #define XEN_PATCH_BUNDLE_ELEM_SETREG(name, reg) \
  945. __XEN_PATCH_BUNDLE_ELEM_SETREG(set_ ## name, reg)
  946. XEN_PATCH_BUNDLE_ELEM_SETREG(kr0, AR_KR0),
  947. XEN_PATCH_BUNDLE_ELEM_SETREG(kr1, AR_KR1),
  948. XEN_PATCH_BUNDLE_ELEM_SETREG(kr2, AR_KR2),
  949. XEN_PATCH_BUNDLE_ELEM_SETREG(kr3, AR_KR3),
  950. XEN_PATCH_BUNDLE_ELEM_SETREG(kr4, AR_KR4),
  951. XEN_PATCH_BUNDLE_ELEM_SETREG(kr5, AR_KR5),
  952. XEN_PATCH_BUNDLE_ELEM_SETREG(kr6, AR_KR6),
  953. XEN_PATCH_BUNDLE_ELEM_SETREG(kr7, AR_KR7),
  954. XEN_PATCH_BUNDLE_ELEM_SETREG(eflag, AR_EFLAG),
  955. XEN_PATCH_BUNDLE_ELEM_SETREG(tpr, CR_TPR),
  956. __XEN_PATCH_BUNDLE_ELEM_SETREG(eoi, CR_EOI),
  957. XEN_PATCH_BUNDLE_ELEM_SETREG(itc, AR_ITC),
  958. XEN_PATCH_BUNDLE_ELEM_SETREG(itm_with_offset, CR_ITM),
  959. };
  960. static unsigned long __init_or_module
  961. xen_patch_bundle(void *sbundle, void *ebundle, unsigned long type)
  962. {
  963. const unsigned long nelems = sizeof(xen_patch_bundle_elems) /
  964. sizeof(xen_patch_bundle_elems[0]);
  965. unsigned long used;
  966. const struct paravirt_patch_bundle_elem *found;
  967. used = __paravirt_patch_apply_bundle(sbundle, ebundle, type,
  968. xen_patch_bundle_elems, nelems,
  969. &found);
  970. if (found == NULL)
  971. /* fallback */
  972. return ia64_native_patch_bundle(sbundle, ebundle, type);
  973. if (used == 0)
  974. return used;
  975. /* relocation */
  976. switch (type) {
  977. case PARAVIRT_PATCH_TYPE_INTRIN_LOCAL_IRQ_RESTORE: {
  978. unsigned long reloc =
  979. __xen_intrin_local_irq_restore_direct_reloc;
  980. unsigned long reloc_offset = reloc - (unsigned long)
  981. __xen_intrin_local_irq_restore_direct_start;
  982. unsigned long tag = (unsigned long)sbundle + reloc_offset;
  983. paravirt_patch_reloc_brl(tag, xen_check_events);
  984. break;
  985. }
  986. default:
  987. /* nothing */
  988. break;
  989. }
  990. return used;
  991. }
  992. #endif /* ASM_SUPPOTED */
  993. const struct paravirt_patch_branch_target xen_branch_target[]
  994. __initconst = {
  995. #define PARAVIRT_BR_TARGET(name, type) \
  996. { \
  997. &xen_ ## name, \
  998. PARAVIRT_PATCH_TYPE_BR_ ## type, \
  999. }
  1000. PARAVIRT_BR_TARGET(switch_to, SWITCH_TO),
  1001. PARAVIRT_BR_TARGET(leave_syscall, LEAVE_SYSCALL),
  1002. PARAVIRT_BR_TARGET(work_processed_syscall, WORK_PROCESSED_SYSCALL),
  1003. PARAVIRT_BR_TARGET(leave_kernel, LEAVE_KERNEL),
  1004. };
  1005. static void __init
  1006. xen_patch_branch(unsigned long tag, unsigned long type)
  1007. {
  1008. __paravirt_patch_apply_branch(tag, type, xen_branch_target,
  1009. ARRAY_SIZE(xen_branch_target));
  1010. }