kvm_fw.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /*
  2. * PAL/SAL call delegation
  3. *
  4. * Copyright (c) 2004 Li Susie <susie.li@intel.com>
  5. * Copyright (c) 2005 Yu Ke <ke.yu@intel.com>
  6. * Copyright (c) 2007 Xiantao Zhang <xiantao.zhang@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  19. * Place - Suite 330, Boston, MA 02111-1307 USA.
  20. */
  21. #include <linux/kvm_host.h>
  22. #include <linux/smp.h>
  23. #include <asm/sn/addrs.h>
  24. #include <asm/sn/clksupport.h>
  25. #include <asm/sn/shub_mmr.h>
  26. #include "vti.h"
  27. #include "misc.h"
  28. #include <asm/pal.h>
  29. #include <asm/sal.h>
  30. #include <asm/tlb.h>
  31. /*
  32. * Handy macros to make sure that the PAL return values start out
  33. * as something meaningful.
  34. */
  35. #define INIT_PAL_STATUS_UNIMPLEMENTED(x) \
  36. { \
  37. x.status = PAL_STATUS_UNIMPLEMENTED; \
  38. x.v0 = 0; \
  39. x.v1 = 0; \
  40. x.v2 = 0; \
  41. }
  42. #define INIT_PAL_STATUS_SUCCESS(x) \
  43. { \
  44. x.status = PAL_STATUS_SUCCESS; \
  45. x.v0 = 0; \
  46. x.v1 = 0; \
  47. x.v2 = 0; \
  48. }
  49. static void kvm_get_pal_call_data(struct kvm_vcpu *vcpu,
  50. u64 *gr28, u64 *gr29, u64 *gr30, u64 *gr31) {
  51. struct exit_ctl_data *p;
  52. if (vcpu) {
  53. p = &vcpu->arch.exit_data;
  54. if (p->exit_reason == EXIT_REASON_PAL_CALL) {
  55. *gr28 = p->u.pal_data.gr28;
  56. *gr29 = p->u.pal_data.gr29;
  57. *gr30 = p->u.pal_data.gr30;
  58. *gr31 = p->u.pal_data.gr31;
  59. return ;
  60. }
  61. }
  62. printk(KERN_DEBUG"Failed to get vcpu pal data!!!\n");
  63. }
  64. static void set_pal_result(struct kvm_vcpu *vcpu,
  65. struct ia64_pal_retval result) {
  66. struct exit_ctl_data *p;
  67. p = kvm_get_exit_data(vcpu);
  68. if (p->exit_reason == EXIT_REASON_PAL_CALL) {
  69. p->u.pal_data.ret = result;
  70. return ;
  71. }
  72. INIT_PAL_STATUS_UNIMPLEMENTED(p->u.pal_data.ret);
  73. }
  74. static void set_sal_result(struct kvm_vcpu *vcpu,
  75. struct sal_ret_values result) {
  76. struct exit_ctl_data *p;
  77. p = kvm_get_exit_data(vcpu);
  78. if (p->exit_reason == EXIT_REASON_SAL_CALL) {
  79. p->u.sal_data.ret = result;
  80. return ;
  81. }
  82. printk(KERN_WARNING"Failed to set sal result!!\n");
  83. }
  84. struct cache_flush_args {
  85. u64 cache_type;
  86. u64 operation;
  87. u64 progress;
  88. long status;
  89. };
  90. cpumask_t cpu_cache_coherent_map;
  91. static void remote_pal_cache_flush(void *data)
  92. {
  93. struct cache_flush_args *args = data;
  94. long status;
  95. u64 progress = args->progress;
  96. status = ia64_pal_cache_flush(args->cache_type, args->operation,
  97. &progress, NULL);
  98. if (status != 0)
  99. args->status = status;
  100. }
  101. static struct ia64_pal_retval pal_cache_flush(struct kvm_vcpu *vcpu)
  102. {
  103. u64 gr28, gr29, gr30, gr31;
  104. struct ia64_pal_retval result = {0, 0, 0, 0};
  105. struct cache_flush_args args = {0, 0, 0, 0};
  106. long psr;
  107. gr28 = gr29 = gr30 = gr31 = 0;
  108. kvm_get_pal_call_data(vcpu, &gr28, &gr29, &gr30, &gr31);
  109. if (gr31 != 0)
  110. printk(KERN_ERR"vcpu:%p called cache_flush error!\n", vcpu);
  111. /* Always call Host Pal in int=1 */
  112. gr30 &= ~PAL_CACHE_FLUSH_CHK_INTRS;
  113. args.cache_type = gr29;
  114. args.operation = gr30;
  115. smp_call_function(remote_pal_cache_flush,
  116. (void *)&args, 1);
  117. if (args.status != 0)
  118. printk(KERN_ERR"pal_cache_flush error!,"
  119. "status:0x%lx\n", args.status);
  120. /*
  121. * Call Host PAL cache flush
  122. * Clear psr.ic when call PAL_CACHE_FLUSH
  123. */
  124. local_irq_save(psr);
  125. result.status = ia64_pal_cache_flush(gr29, gr30, &result.v1,
  126. &result.v0);
  127. local_irq_restore(psr);
  128. if (result.status != 0)
  129. printk(KERN_ERR"vcpu:%p crashed due to cache_flush err:%ld"
  130. "in1:%lx,in2:%lx\n",
  131. vcpu, result.status, gr29, gr30);
  132. #if 0
  133. if (gr29 == PAL_CACHE_TYPE_COHERENT) {
  134. cpus_setall(vcpu->arch.cache_coherent_map);
  135. cpu_clear(vcpu->cpu, vcpu->arch.cache_coherent_map);
  136. cpus_setall(cpu_cache_coherent_map);
  137. cpu_clear(vcpu->cpu, cpu_cache_coherent_map);
  138. }
  139. #endif
  140. return result;
  141. }
  142. struct ia64_pal_retval pal_cache_summary(struct kvm_vcpu *vcpu)
  143. {
  144. struct ia64_pal_retval result;
  145. PAL_CALL(result, PAL_CACHE_SUMMARY, 0, 0, 0);
  146. return result;
  147. }
  148. static struct ia64_pal_retval pal_freq_base(struct kvm_vcpu *vcpu)
  149. {
  150. struct ia64_pal_retval result;
  151. PAL_CALL(result, PAL_FREQ_BASE, 0, 0, 0);
  152. /*
  153. * PAL_FREQ_BASE may not be implemented in some platforms,
  154. * call SAL instead.
  155. */
  156. if (result.v0 == 0) {
  157. result.status = ia64_sal_freq_base(SAL_FREQ_BASE_PLATFORM,
  158. &result.v0,
  159. &result.v1);
  160. result.v2 = 0;
  161. }
  162. return result;
  163. }
  164. /*
  165. * On the SGI SN2, the ITC isn't stable. Emulation backed by the SN2
  166. * RTC is used instead. This function patches the ratios from SAL
  167. * to match the RTC before providing them to the guest.
  168. */
  169. static void sn2_patch_itc_freq_ratios(struct ia64_pal_retval *result)
  170. {
  171. struct pal_freq_ratio *ratio;
  172. unsigned long sal_freq, sal_drift, factor;
  173. result->status = ia64_sal_freq_base(SAL_FREQ_BASE_PLATFORM,
  174. &sal_freq, &sal_drift);
  175. ratio = (struct pal_freq_ratio *)&result->v2;
  176. factor = ((sal_freq * 3) + (sn_rtc_cycles_per_second / 2)) /
  177. sn_rtc_cycles_per_second;
  178. ratio->num = 3;
  179. ratio->den = factor;
  180. }
  181. static struct ia64_pal_retval pal_freq_ratios(struct kvm_vcpu *vcpu)
  182. {
  183. struct ia64_pal_retval result;
  184. PAL_CALL(result, PAL_FREQ_RATIOS, 0, 0, 0);
  185. if (vcpu->kvm->arch.is_sn2)
  186. sn2_patch_itc_freq_ratios(&result);
  187. return result;
  188. }
  189. static struct ia64_pal_retval pal_logical_to_physica(struct kvm_vcpu *vcpu)
  190. {
  191. struct ia64_pal_retval result;
  192. INIT_PAL_STATUS_UNIMPLEMENTED(result);
  193. return result;
  194. }
  195. static struct ia64_pal_retval pal_platform_addr(struct kvm_vcpu *vcpu)
  196. {
  197. struct ia64_pal_retval result;
  198. INIT_PAL_STATUS_SUCCESS(result);
  199. return result;
  200. }
  201. static struct ia64_pal_retval pal_proc_get_features(struct kvm_vcpu *vcpu)
  202. {
  203. struct ia64_pal_retval result = {0, 0, 0, 0};
  204. long in0, in1, in2, in3;
  205. kvm_get_pal_call_data(vcpu, &in0, &in1, &in2, &in3);
  206. result.status = ia64_pal_proc_get_features(&result.v0, &result.v1,
  207. &result.v2, in2);
  208. return result;
  209. }
  210. static struct ia64_pal_retval pal_register_info(struct kvm_vcpu *vcpu)
  211. {
  212. struct ia64_pal_retval result = {0, 0, 0, 0};
  213. long in0, in1, in2, in3;
  214. kvm_get_pal_call_data(vcpu, &in0, &in1, &in2, &in3);
  215. result.status = ia64_pal_register_info(in1, &result.v1, &result.v2);
  216. return result;
  217. }
  218. static struct ia64_pal_retval pal_cache_info(struct kvm_vcpu *vcpu)
  219. {
  220. pal_cache_config_info_t ci;
  221. long status;
  222. unsigned long in0, in1, in2, in3, r9, r10;
  223. kvm_get_pal_call_data(vcpu, &in0, &in1, &in2, &in3);
  224. status = ia64_pal_cache_config_info(in1, in2, &ci);
  225. r9 = ci.pcci_info_1.pcci1_data;
  226. r10 = ci.pcci_info_2.pcci2_data;
  227. return ((struct ia64_pal_retval){status, r9, r10, 0});
  228. }
  229. #define GUEST_IMPL_VA_MSB 59
  230. #define GUEST_RID_BITS 18
  231. static struct ia64_pal_retval pal_vm_summary(struct kvm_vcpu *vcpu)
  232. {
  233. pal_vm_info_1_u_t vminfo1;
  234. pal_vm_info_2_u_t vminfo2;
  235. struct ia64_pal_retval result;
  236. PAL_CALL(result, PAL_VM_SUMMARY, 0, 0, 0);
  237. if (!result.status) {
  238. vminfo1.pvi1_val = result.v0;
  239. vminfo1.pal_vm_info_1_s.max_itr_entry = 8;
  240. vminfo1.pal_vm_info_1_s.max_dtr_entry = 8;
  241. result.v0 = vminfo1.pvi1_val;
  242. vminfo2.pal_vm_info_2_s.impl_va_msb = GUEST_IMPL_VA_MSB;
  243. vminfo2.pal_vm_info_2_s.rid_size = GUEST_RID_BITS;
  244. result.v1 = vminfo2.pvi2_val;
  245. }
  246. return result;
  247. }
  248. static struct ia64_pal_retval pal_vm_info(struct kvm_vcpu *vcpu)
  249. {
  250. struct ia64_pal_retval result;
  251. unsigned long in0, in1, in2, in3;
  252. kvm_get_pal_call_data(vcpu, &in0, &in1, &in2, &in3);
  253. result.status = ia64_pal_vm_info(in1, in2,
  254. (pal_tc_info_u_t *)&result.v1, &result.v2);
  255. return result;
  256. }
  257. static u64 kvm_get_pal_call_index(struct kvm_vcpu *vcpu)
  258. {
  259. u64 index = 0;
  260. struct exit_ctl_data *p;
  261. p = kvm_get_exit_data(vcpu);
  262. if (p->exit_reason == EXIT_REASON_PAL_CALL)
  263. index = p->u.pal_data.gr28;
  264. return index;
  265. }
  266. static void prepare_for_halt(struct kvm_vcpu *vcpu)
  267. {
  268. vcpu->arch.timer_pending = 1;
  269. vcpu->arch.timer_fired = 0;
  270. }
  271. static struct ia64_pal_retval pal_perf_mon_info(struct kvm_vcpu *vcpu)
  272. {
  273. long status;
  274. unsigned long in0, in1, in2, in3, r9;
  275. unsigned long pm_buffer[16];
  276. kvm_get_pal_call_data(vcpu, &in0, &in1, &in2, &in3);
  277. status = ia64_pal_perf_mon_info(pm_buffer,
  278. (pal_perf_mon_info_u_t *) &r9);
  279. if (status != 0) {
  280. printk(KERN_DEBUG"PAL_PERF_MON_INFO fails ret=%ld\n", status);
  281. } else {
  282. if (in1)
  283. memcpy((void *)in1, pm_buffer, sizeof(pm_buffer));
  284. else {
  285. status = PAL_STATUS_EINVAL;
  286. printk(KERN_WARNING"Invalid parameters "
  287. "for PAL call:0x%lx!\n", in0);
  288. }
  289. }
  290. return (struct ia64_pal_retval){status, r9, 0, 0};
  291. }
  292. static struct ia64_pal_retval pal_halt_info(struct kvm_vcpu *vcpu)
  293. {
  294. unsigned long in0, in1, in2, in3;
  295. long status;
  296. unsigned long res = 1000UL | (1000UL << 16) | (10UL << 32)
  297. | (1UL << 61) | (1UL << 60);
  298. kvm_get_pal_call_data(vcpu, &in0, &in1, &in2, &in3);
  299. if (in1) {
  300. memcpy((void *)in1, &res, sizeof(res));
  301. status = 0;
  302. } else{
  303. status = PAL_STATUS_EINVAL;
  304. printk(KERN_WARNING"Invalid parameters "
  305. "for PAL call:0x%lx!\n", in0);
  306. }
  307. return (struct ia64_pal_retval){status, 0, 0, 0};
  308. }
  309. static struct ia64_pal_retval pal_mem_attrib(struct kvm_vcpu *vcpu)
  310. {
  311. unsigned long r9;
  312. long status;
  313. status = ia64_pal_mem_attrib(&r9);
  314. return (struct ia64_pal_retval){status, r9, 0, 0};
  315. }
  316. static void remote_pal_prefetch_visibility(void *v)
  317. {
  318. s64 trans_type = (s64)v;
  319. ia64_pal_prefetch_visibility(trans_type);
  320. }
  321. static struct ia64_pal_retval pal_prefetch_visibility(struct kvm_vcpu *vcpu)
  322. {
  323. struct ia64_pal_retval result = {0, 0, 0, 0};
  324. unsigned long in0, in1, in2, in3;
  325. kvm_get_pal_call_data(vcpu, &in0, &in1, &in2, &in3);
  326. result.status = ia64_pal_prefetch_visibility(in1);
  327. if (result.status == 0) {
  328. /* Must be performed on all remote processors
  329. in the coherence domain. */
  330. smp_call_function(remote_pal_prefetch_visibility,
  331. (void *)in1, 1);
  332. /* Unnecessary on remote processor for other vcpus!*/
  333. result.status = 1;
  334. }
  335. return result;
  336. }
  337. static void remote_pal_mc_drain(void *v)
  338. {
  339. ia64_pal_mc_drain();
  340. }
  341. static struct ia64_pal_retval pal_get_brand_info(struct kvm_vcpu *vcpu)
  342. {
  343. struct ia64_pal_retval result = {0, 0, 0, 0};
  344. unsigned long in0, in1, in2, in3;
  345. kvm_get_pal_call_data(vcpu, &in0, &in1, &in2, &in3);
  346. if (in1 == 0 && in2) {
  347. char brand_info[128];
  348. result.status = ia64_pal_get_brand_info(brand_info);
  349. if (result.status == PAL_STATUS_SUCCESS)
  350. memcpy((void *)in2, brand_info, 128);
  351. } else {
  352. result.status = PAL_STATUS_REQUIRES_MEMORY;
  353. printk(KERN_WARNING"Invalid parameters for "
  354. "PAL call:0x%lx!\n", in0);
  355. }
  356. return result;
  357. }
  358. int kvm_pal_emul(struct kvm_vcpu *vcpu, struct kvm_run *run)
  359. {
  360. u64 gr28;
  361. struct ia64_pal_retval result;
  362. int ret = 1;
  363. gr28 = kvm_get_pal_call_index(vcpu);
  364. switch (gr28) {
  365. case PAL_CACHE_FLUSH:
  366. result = pal_cache_flush(vcpu);
  367. break;
  368. case PAL_MEM_ATTRIB:
  369. result = pal_mem_attrib(vcpu);
  370. break;
  371. case PAL_CACHE_SUMMARY:
  372. result = pal_cache_summary(vcpu);
  373. break;
  374. case PAL_PERF_MON_INFO:
  375. result = pal_perf_mon_info(vcpu);
  376. break;
  377. case PAL_HALT_INFO:
  378. result = pal_halt_info(vcpu);
  379. break;
  380. case PAL_HALT_LIGHT:
  381. {
  382. INIT_PAL_STATUS_SUCCESS(result);
  383. prepare_for_halt(vcpu);
  384. if (kvm_highest_pending_irq(vcpu) == -1)
  385. ret = kvm_emulate_halt(vcpu);
  386. }
  387. break;
  388. case PAL_PREFETCH_VISIBILITY:
  389. result = pal_prefetch_visibility(vcpu);
  390. break;
  391. case PAL_MC_DRAIN:
  392. result.status = ia64_pal_mc_drain();
  393. /* FIXME: All vcpus likely call PAL_MC_DRAIN.
  394. That causes the congestion. */
  395. smp_call_function(remote_pal_mc_drain, NULL, 1);
  396. break;
  397. case PAL_FREQ_RATIOS:
  398. result = pal_freq_ratios(vcpu);
  399. break;
  400. case PAL_FREQ_BASE:
  401. result = pal_freq_base(vcpu);
  402. break;
  403. case PAL_LOGICAL_TO_PHYSICAL :
  404. result = pal_logical_to_physica(vcpu);
  405. break;
  406. case PAL_VM_SUMMARY :
  407. result = pal_vm_summary(vcpu);
  408. break;
  409. case PAL_VM_INFO :
  410. result = pal_vm_info(vcpu);
  411. break;
  412. case PAL_PLATFORM_ADDR :
  413. result = pal_platform_addr(vcpu);
  414. break;
  415. case PAL_CACHE_INFO:
  416. result = pal_cache_info(vcpu);
  417. break;
  418. case PAL_PTCE_INFO:
  419. INIT_PAL_STATUS_SUCCESS(result);
  420. result.v1 = (1L << 32) | 1L;
  421. break;
  422. case PAL_REGISTER_INFO:
  423. result = pal_register_info(vcpu);
  424. break;
  425. case PAL_VM_PAGE_SIZE:
  426. result.status = ia64_pal_vm_page_size(&result.v0,
  427. &result.v1);
  428. break;
  429. case PAL_RSE_INFO:
  430. result.status = ia64_pal_rse_info(&result.v0,
  431. (pal_hints_u_t *)&result.v1);
  432. break;
  433. case PAL_PROC_GET_FEATURES:
  434. result = pal_proc_get_features(vcpu);
  435. break;
  436. case PAL_DEBUG_INFO:
  437. result.status = ia64_pal_debug_info(&result.v0,
  438. &result.v1);
  439. break;
  440. case PAL_VERSION:
  441. result.status = ia64_pal_version(
  442. (pal_version_u_t *)&result.v0,
  443. (pal_version_u_t *)&result.v1);
  444. break;
  445. case PAL_FIXED_ADDR:
  446. result.status = PAL_STATUS_SUCCESS;
  447. result.v0 = vcpu->vcpu_id;
  448. break;
  449. case PAL_BRAND_INFO:
  450. result = pal_get_brand_info(vcpu);
  451. break;
  452. case PAL_GET_PSTATE:
  453. case PAL_CACHE_SHARED_INFO:
  454. INIT_PAL_STATUS_UNIMPLEMENTED(result);
  455. break;
  456. default:
  457. INIT_PAL_STATUS_UNIMPLEMENTED(result);
  458. printk(KERN_WARNING"kvm: Unsupported pal call,"
  459. " index:0x%lx\n", gr28);
  460. }
  461. set_pal_result(vcpu, result);
  462. return ret;
  463. }
  464. static struct sal_ret_values sal_emulator(struct kvm *kvm,
  465. long index, unsigned long in1,
  466. unsigned long in2, unsigned long in3,
  467. unsigned long in4, unsigned long in5,
  468. unsigned long in6, unsigned long in7)
  469. {
  470. unsigned long r9 = 0;
  471. unsigned long r10 = 0;
  472. long r11 = 0;
  473. long status;
  474. status = 0;
  475. switch (index) {
  476. case SAL_FREQ_BASE:
  477. status = ia64_sal_freq_base(in1, &r9, &r10);
  478. break;
  479. case SAL_PCI_CONFIG_READ:
  480. printk(KERN_WARNING"kvm: Not allowed to call here!"
  481. " SAL_PCI_CONFIG_READ\n");
  482. break;
  483. case SAL_PCI_CONFIG_WRITE:
  484. printk(KERN_WARNING"kvm: Not allowed to call here!"
  485. " SAL_PCI_CONFIG_WRITE\n");
  486. break;
  487. case SAL_SET_VECTORS:
  488. if (in1 == SAL_VECTOR_OS_BOOT_RENDEZ) {
  489. if (in4 != 0 || in5 != 0 || in6 != 0 || in7 != 0) {
  490. status = -2;
  491. } else {
  492. kvm->arch.rdv_sal_data.boot_ip = in2;
  493. kvm->arch.rdv_sal_data.boot_gp = in3;
  494. }
  495. printk("Rendvous called! iip:%lx\n\n", in2);
  496. } else
  497. printk(KERN_WARNING"kvm: CALLED SAL_SET_VECTORS %lu."
  498. "ignored...\n", in1);
  499. break;
  500. case SAL_GET_STATE_INFO:
  501. /* No more info. */
  502. status = -5;
  503. r9 = 0;
  504. break;
  505. case SAL_GET_STATE_INFO_SIZE:
  506. /* Return a dummy size. */
  507. status = 0;
  508. r9 = 128;
  509. break;
  510. case SAL_CLEAR_STATE_INFO:
  511. /* Noop. */
  512. break;
  513. case SAL_MC_RENDEZ:
  514. printk(KERN_WARNING
  515. "kvm: called SAL_MC_RENDEZ. ignored...\n");
  516. break;
  517. case SAL_MC_SET_PARAMS:
  518. printk(KERN_WARNING
  519. "kvm: called SAL_MC_SET_PARAMS.ignored!\n");
  520. break;
  521. case SAL_CACHE_FLUSH:
  522. if (1) {
  523. /*Flush using SAL.
  524. This method is faster but has a side
  525. effect on other vcpu running on
  526. this cpu. */
  527. status = ia64_sal_cache_flush(in1);
  528. } else {
  529. /*Maybe need to implement the method
  530. without side effect!*/
  531. status = 0;
  532. }
  533. break;
  534. case SAL_CACHE_INIT:
  535. printk(KERN_WARNING
  536. "kvm: called SAL_CACHE_INIT. ignored...\n");
  537. break;
  538. case SAL_UPDATE_PAL:
  539. printk(KERN_WARNING
  540. "kvm: CALLED SAL_UPDATE_PAL. ignored...\n");
  541. break;
  542. default:
  543. printk(KERN_WARNING"kvm: called SAL_CALL with unknown index."
  544. " index:%ld\n", index);
  545. status = -1;
  546. break;
  547. }
  548. return ((struct sal_ret_values) {status, r9, r10, r11});
  549. }
  550. static void kvm_get_sal_call_data(struct kvm_vcpu *vcpu, u64 *in0, u64 *in1,
  551. u64 *in2, u64 *in3, u64 *in4, u64 *in5, u64 *in6, u64 *in7){
  552. struct exit_ctl_data *p;
  553. p = kvm_get_exit_data(vcpu);
  554. if (p->exit_reason == EXIT_REASON_SAL_CALL) {
  555. *in0 = p->u.sal_data.in0;
  556. *in1 = p->u.sal_data.in1;
  557. *in2 = p->u.sal_data.in2;
  558. *in3 = p->u.sal_data.in3;
  559. *in4 = p->u.sal_data.in4;
  560. *in5 = p->u.sal_data.in5;
  561. *in6 = p->u.sal_data.in6;
  562. *in7 = p->u.sal_data.in7;
  563. return ;
  564. }
  565. *in0 = 0;
  566. }
  567. void kvm_sal_emul(struct kvm_vcpu *vcpu)
  568. {
  569. struct sal_ret_values result;
  570. u64 index, in1, in2, in3, in4, in5, in6, in7;
  571. kvm_get_sal_call_data(vcpu, &index, &in1, &in2,
  572. &in3, &in4, &in5, &in6, &in7);
  573. result = sal_emulator(vcpu->kvm, index, in1, in2, in3,
  574. in4, in5, in6, in7);
  575. set_sal_result(vcpu, result);
  576. }