x86.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef ARCH_X86_KVM_X86_H
  3. #define ARCH_X86_KVM_X86_H
  4. #include <linux/kvm_host.h>
  5. #include <asm/fpu/xstate.h>
  6. #include <asm/mce.h>
  7. #include <asm/pvclock.h>
  8. #include "kvm_cache_regs.h"
  9. #include "kvm_emulate.h"
  10. struct kvm_caps {
  11. /* control of guest tsc rate supported? */
  12. bool has_tsc_control;
  13. /* maximum supported tsc_khz for guests */
  14. u32 max_guest_tsc_khz;
  15. /* number of bits of the fractional part of the TSC scaling ratio */
  16. u8 tsc_scaling_ratio_frac_bits;
  17. /* maximum allowed value of TSC scaling ratio */
  18. u64 max_tsc_scaling_ratio;
  19. /* 1ull << kvm_caps.tsc_scaling_ratio_frac_bits */
  20. u64 default_tsc_scaling_ratio;
  21. /* bus lock detection supported? */
  22. bool has_bus_lock_exit;
  23. /* notify VM exit supported? */
  24. bool has_notify_vmexit;
  25. /* bit mask of VM types */
  26. u32 supported_vm_types;
  27. u64 supported_mce_cap;
  28. u64 supported_xcr0;
  29. u64 supported_xss;
  30. u64 supported_perf_cap;
  31. };
  32. struct kvm_host_values {
  33. /*
  34. * The host's raw MAXPHYADDR, i.e. the number of non-reserved physical
  35. * address bits irrespective of features that repurpose legal bits,
  36. * e.g. MKTME.
  37. */
  38. u8 maxphyaddr;
  39. u64 efer;
  40. u64 xcr0;
  41. u64 xss;
  42. u64 arch_capabilities;
  43. };
  44. void kvm_spurious_fault(void);
  45. #define KVM_NESTED_VMENTER_CONSISTENCY_CHECK(consistency_check) \
  46. ({ \
  47. bool failed = (consistency_check); \
  48. if (failed) \
  49. trace_kvm_nested_vmenter_failed(#consistency_check, 0); \
  50. failed; \
  51. })
  52. /*
  53. * The first...last VMX feature MSRs that are emulated by KVM. This may or may
  54. * not cover all known VMX MSRs, as KVM doesn't emulate an MSR until there's an
  55. * associated feature that KVM supports for nested virtualization.
  56. */
  57. #define KVM_FIRST_EMULATED_VMX_MSR MSR_IA32_VMX_BASIC
  58. #define KVM_LAST_EMULATED_VMX_MSR MSR_IA32_VMX_VMFUNC
  59. #define KVM_DEFAULT_PLE_GAP 128
  60. #define KVM_VMX_DEFAULT_PLE_WINDOW 4096
  61. #define KVM_DEFAULT_PLE_WINDOW_GROW 2
  62. #define KVM_DEFAULT_PLE_WINDOW_SHRINK 0
  63. #define KVM_VMX_DEFAULT_PLE_WINDOW_MAX UINT_MAX
  64. #define KVM_SVM_DEFAULT_PLE_WINDOW_MAX USHRT_MAX
  65. #define KVM_SVM_DEFAULT_PLE_WINDOW 3000
  66. static inline unsigned int __grow_ple_window(unsigned int val,
  67. unsigned int base, unsigned int modifier, unsigned int max)
  68. {
  69. u64 ret = val;
  70. if (modifier < 1)
  71. return base;
  72. if (modifier < base)
  73. ret *= modifier;
  74. else
  75. ret += modifier;
  76. return min(ret, (u64)max);
  77. }
  78. static inline unsigned int __shrink_ple_window(unsigned int val,
  79. unsigned int base, unsigned int modifier, unsigned int min)
  80. {
  81. if (modifier < 1)
  82. return base;
  83. if (modifier < base)
  84. val /= modifier;
  85. else
  86. val -= modifier;
  87. return max(val, min);
  88. }
  89. #define MSR_IA32_CR_PAT_DEFAULT \
  90. PAT_VALUE(WB, WT, UC_MINUS, UC, WB, WT, UC_MINUS, UC)
  91. void kvm_service_local_tlb_flush_requests(struct kvm_vcpu *vcpu);
  92. int kvm_check_nested_events(struct kvm_vcpu *vcpu);
  93. /* Forcibly leave the nested mode in cases like a vCPU reset */
  94. static inline void kvm_leave_nested(struct kvm_vcpu *vcpu)
  95. {
  96. kvm_x86_ops.nested_ops->leave_nested(vcpu);
  97. }
  98. static inline bool kvm_vcpu_has_run(struct kvm_vcpu *vcpu)
  99. {
  100. return vcpu->arch.last_vmentry_cpu != -1;
  101. }
  102. static inline bool kvm_is_exception_pending(struct kvm_vcpu *vcpu)
  103. {
  104. return vcpu->arch.exception.pending ||
  105. vcpu->arch.exception_vmexit.pending ||
  106. kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu);
  107. }
  108. static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu)
  109. {
  110. vcpu->arch.exception.pending = false;
  111. vcpu->arch.exception.injected = false;
  112. vcpu->arch.exception_vmexit.pending = false;
  113. }
  114. static inline void kvm_queue_interrupt(struct kvm_vcpu *vcpu, u8 vector,
  115. bool soft)
  116. {
  117. vcpu->arch.interrupt.injected = true;
  118. vcpu->arch.interrupt.soft = soft;
  119. vcpu->arch.interrupt.nr = vector;
  120. }
  121. static inline void kvm_clear_interrupt_queue(struct kvm_vcpu *vcpu)
  122. {
  123. vcpu->arch.interrupt.injected = false;
  124. }
  125. static inline bool kvm_event_needs_reinjection(struct kvm_vcpu *vcpu)
  126. {
  127. return vcpu->arch.exception.injected || vcpu->arch.interrupt.injected ||
  128. vcpu->arch.nmi_injected;
  129. }
  130. static inline bool kvm_exception_is_soft(unsigned int nr)
  131. {
  132. return (nr == BP_VECTOR) || (nr == OF_VECTOR);
  133. }
  134. static inline bool is_protmode(struct kvm_vcpu *vcpu)
  135. {
  136. return kvm_is_cr0_bit_set(vcpu, X86_CR0_PE);
  137. }
  138. static inline bool is_long_mode(struct kvm_vcpu *vcpu)
  139. {
  140. #ifdef CONFIG_X86_64
  141. return !!(vcpu->arch.efer & EFER_LMA);
  142. #else
  143. return false;
  144. #endif
  145. }
  146. static inline bool is_64_bit_mode(struct kvm_vcpu *vcpu)
  147. {
  148. int cs_db, cs_l;
  149. WARN_ON_ONCE(vcpu->arch.guest_state_protected);
  150. if (!is_long_mode(vcpu))
  151. return false;
  152. kvm_x86_call(get_cs_db_l_bits)(vcpu, &cs_db, &cs_l);
  153. return cs_l;
  154. }
  155. static inline bool is_64_bit_hypercall(struct kvm_vcpu *vcpu)
  156. {
  157. /*
  158. * If running with protected guest state, the CS register is not
  159. * accessible. The hypercall register values will have had to been
  160. * provided in 64-bit mode, so assume the guest is in 64-bit.
  161. */
  162. return vcpu->arch.guest_state_protected || is_64_bit_mode(vcpu);
  163. }
  164. static inline bool x86_exception_has_error_code(unsigned int vector)
  165. {
  166. static u32 exception_has_error_code = BIT(DF_VECTOR) | BIT(TS_VECTOR) |
  167. BIT(NP_VECTOR) | BIT(SS_VECTOR) | BIT(GP_VECTOR) |
  168. BIT(PF_VECTOR) | BIT(AC_VECTOR);
  169. return (1U << vector) & exception_has_error_code;
  170. }
  171. static inline bool mmu_is_nested(struct kvm_vcpu *vcpu)
  172. {
  173. return vcpu->arch.walk_mmu == &vcpu->arch.nested_mmu;
  174. }
  175. static inline bool is_pae(struct kvm_vcpu *vcpu)
  176. {
  177. return kvm_is_cr4_bit_set(vcpu, X86_CR4_PAE);
  178. }
  179. static inline bool is_pse(struct kvm_vcpu *vcpu)
  180. {
  181. return kvm_is_cr4_bit_set(vcpu, X86_CR4_PSE);
  182. }
  183. static inline bool is_paging(struct kvm_vcpu *vcpu)
  184. {
  185. return likely(kvm_is_cr0_bit_set(vcpu, X86_CR0_PG));
  186. }
  187. static inline bool is_pae_paging(struct kvm_vcpu *vcpu)
  188. {
  189. return !is_long_mode(vcpu) && is_pae(vcpu) && is_paging(vcpu);
  190. }
  191. static inline u8 vcpu_virt_addr_bits(struct kvm_vcpu *vcpu)
  192. {
  193. return kvm_is_cr4_bit_set(vcpu, X86_CR4_LA57) ? 57 : 48;
  194. }
  195. static inline bool is_noncanonical_address(u64 la, struct kvm_vcpu *vcpu)
  196. {
  197. return !__is_canonical_address(la, vcpu_virt_addr_bits(vcpu));
  198. }
  199. static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
  200. gva_t gva, gfn_t gfn, unsigned access)
  201. {
  202. u64 gen = kvm_memslots(vcpu->kvm)->generation;
  203. if (unlikely(gen & KVM_MEMSLOT_GEN_UPDATE_IN_PROGRESS))
  204. return;
  205. /*
  206. * If this is a shadow nested page table, the "GVA" is
  207. * actually a nGPA.
  208. */
  209. vcpu->arch.mmio_gva = mmu_is_nested(vcpu) ? 0 : gva & PAGE_MASK;
  210. vcpu->arch.mmio_access = access;
  211. vcpu->arch.mmio_gfn = gfn;
  212. vcpu->arch.mmio_gen = gen;
  213. }
  214. static inline bool vcpu_match_mmio_gen(struct kvm_vcpu *vcpu)
  215. {
  216. return vcpu->arch.mmio_gen == kvm_memslots(vcpu->kvm)->generation;
  217. }
  218. /*
  219. * Clear the mmio cache info for the given gva. If gva is MMIO_GVA_ANY, we
  220. * clear all mmio cache info.
  221. */
  222. #define MMIO_GVA_ANY (~(gva_t)0)
  223. static inline void vcpu_clear_mmio_info(struct kvm_vcpu *vcpu, gva_t gva)
  224. {
  225. if (gva != MMIO_GVA_ANY && vcpu->arch.mmio_gva != (gva & PAGE_MASK))
  226. return;
  227. vcpu->arch.mmio_gva = 0;
  228. }
  229. static inline bool vcpu_match_mmio_gva(struct kvm_vcpu *vcpu, unsigned long gva)
  230. {
  231. if (vcpu_match_mmio_gen(vcpu) && vcpu->arch.mmio_gva &&
  232. vcpu->arch.mmio_gva == (gva & PAGE_MASK))
  233. return true;
  234. return false;
  235. }
  236. static inline bool vcpu_match_mmio_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
  237. {
  238. if (vcpu_match_mmio_gen(vcpu) && vcpu->arch.mmio_gfn &&
  239. vcpu->arch.mmio_gfn == gpa >> PAGE_SHIFT)
  240. return true;
  241. return false;
  242. }
  243. static inline unsigned long kvm_register_read(struct kvm_vcpu *vcpu, int reg)
  244. {
  245. unsigned long val = kvm_register_read_raw(vcpu, reg);
  246. return is_64_bit_mode(vcpu) ? val : (u32)val;
  247. }
  248. static inline void kvm_register_write(struct kvm_vcpu *vcpu,
  249. int reg, unsigned long val)
  250. {
  251. if (!is_64_bit_mode(vcpu))
  252. val = (u32)val;
  253. return kvm_register_write_raw(vcpu, reg, val);
  254. }
  255. static inline bool kvm_check_has_quirk(struct kvm *kvm, u64 quirk)
  256. {
  257. return !(kvm->arch.disabled_quirks & quirk);
  258. }
  259. void kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip);
  260. u64 get_kvmclock_ns(struct kvm *kvm);
  261. uint64_t kvm_get_wall_clock_epoch(struct kvm *kvm);
  262. bool kvm_get_monotonic_and_clockread(s64 *kernel_ns, u64 *tsc_timestamp);
  263. int kvm_read_guest_virt(struct kvm_vcpu *vcpu,
  264. gva_t addr, void *val, unsigned int bytes,
  265. struct x86_exception *exception);
  266. int kvm_write_guest_virt_system(struct kvm_vcpu *vcpu,
  267. gva_t addr, void *val, unsigned int bytes,
  268. struct x86_exception *exception);
  269. int handle_ud(struct kvm_vcpu *vcpu);
  270. void kvm_deliver_exception_payload(struct kvm_vcpu *vcpu,
  271. struct kvm_queued_exception *ex);
  272. int kvm_mtrr_set_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data);
  273. int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata);
  274. bool kvm_vector_hashing_enabled(void);
  275. void kvm_fixup_and_inject_pf_error(struct kvm_vcpu *vcpu, gva_t gva, u16 error_code);
  276. int x86_decode_emulated_instruction(struct kvm_vcpu *vcpu, int emulation_type,
  277. void *insn, int insn_len);
  278. int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
  279. int emulation_type, void *insn, int insn_len);
  280. fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu);
  281. fastpath_t handle_fastpath_hlt(struct kvm_vcpu *vcpu);
  282. extern struct kvm_caps kvm_caps;
  283. extern struct kvm_host_values kvm_host;
  284. extern bool enable_pmu;
  285. /*
  286. * Get a filtered version of KVM's supported XCR0 that strips out dynamic
  287. * features for which the current process doesn't (yet) have permission to use.
  288. * This is intended to be used only when enumerating support to userspace,
  289. * e.g. in KVM_GET_SUPPORTED_CPUID and KVM_CAP_XSAVE2, it does NOT need to be
  290. * used to check/restrict guest behavior as KVM rejects KVM_SET_CPUID{2} if
  291. * userspace attempts to enable unpermitted features.
  292. */
  293. static inline u64 kvm_get_filtered_xcr0(void)
  294. {
  295. u64 permitted_xcr0 = kvm_caps.supported_xcr0;
  296. BUILD_BUG_ON(XFEATURE_MASK_USER_DYNAMIC != XFEATURE_MASK_XTILE_DATA);
  297. if (permitted_xcr0 & XFEATURE_MASK_USER_DYNAMIC) {
  298. permitted_xcr0 &= xstate_get_guest_group_perm();
  299. /*
  300. * Treat XTILE_CFG as unsupported if the current process isn't
  301. * allowed to use XTILE_DATA, as attempting to set XTILE_CFG in
  302. * XCR0 without setting XTILE_DATA is architecturally illegal.
  303. */
  304. if (!(permitted_xcr0 & XFEATURE_MASK_XTILE_DATA))
  305. permitted_xcr0 &= ~XFEATURE_MASK_XTILE_CFG;
  306. }
  307. return permitted_xcr0;
  308. }
  309. static inline bool kvm_mpx_supported(void)
  310. {
  311. return (kvm_caps.supported_xcr0 & (XFEATURE_MASK_BNDREGS | XFEATURE_MASK_BNDCSR))
  312. == (XFEATURE_MASK_BNDREGS | XFEATURE_MASK_BNDCSR);
  313. }
  314. extern unsigned int min_timer_period_us;
  315. extern bool enable_vmware_backdoor;
  316. extern int pi_inject_timer;
  317. extern bool report_ignored_msrs;
  318. extern bool eager_page_split;
  319. static inline void kvm_pr_unimpl_wrmsr(struct kvm_vcpu *vcpu, u32 msr, u64 data)
  320. {
  321. if (report_ignored_msrs)
  322. vcpu_unimpl(vcpu, "Unhandled WRMSR(0x%x) = 0x%llx\n", msr, data);
  323. }
  324. static inline void kvm_pr_unimpl_rdmsr(struct kvm_vcpu *vcpu, u32 msr)
  325. {
  326. if (report_ignored_msrs)
  327. vcpu_unimpl(vcpu, "Unhandled RDMSR(0x%x)\n", msr);
  328. }
  329. static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec)
  330. {
  331. return pvclock_scale_delta(nsec, vcpu->arch.virtual_tsc_mult,
  332. vcpu->arch.virtual_tsc_shift);
  333. }
  334. /* Same "calling convention" as do_div:
  335. * - divide (n << 32) by base
  336. * - put result in n
  337. * - return remainder
  338. */
  339. #define do_shl32_div32(n, base) \
  340. ({ \
  341. u32 __quot, __rem; \
  342. asm("divl %2" : "=a" (__quot), "=d" (__rem) \
  343. : "rm" (base), "0" (0), "1" ((u32) n)); \
  344. n = __quot; \
  345. __rem; \
  346. })
  347. static inline bool kvm_mwait_in_guest(struct kvm *kvm)
  348. {
  349. return kvm->arch.mwait_in_guest;
  350. }
  351. static inline bool kvm_hlt_in_guest(struct kvm *kvm)
  352. {
  353. return kvm->arch.hlt_in_guest;
  354. }
  355. static inline bool kvm_pause_in_guest(struct kvm *kvm)
  356. {
  357. return kvm->arch.pause_in_guest;
  358. }
  359. static inline bool kvm_cstate_in_guest(struct kvm *kvm)
  360. {
  361. return kvm->arch.cstate_in_guest;
  362. }
  363. static inline bool kvm_notify_vmexit_enabled(struct kvm *kvm)
  364. {
  365. return kvm->arch.notify_vmexit_flags & KVM_X86_NOTIFY_VMEXIT_ENABLED;
  366. }
  367. static __always_inline void kvm_before_interrupt(struct kvm_vcpu *vcpu,
  368. enum kvm_intr_type intr)
  369. {
  370. WRITE_ONCE(vcpu->arch.handling_intr_from_guest, (u8)intr);
  371. }
  372. static __always_inline void kvm_after_interrupt(struct kvm_vcpu *vcpu)
  373. {
  374. WRITE_ONCE(vcpu->arch.handling_intr_from_guest, 0);
  375. }
  376. static inline bool kvm_handling_nmi_from_guest(struct kvm_vcpu *vcpu)
  377. {
  378. return vcpu->arch.handling_intr_from_guest == KVM_HANDLING_NMI;
  379. }
  380. static inline bool kvm_pat_valid(u64 data)
  381. {
  382. if (data & 0xF8F8F8F8F8F8F8F8ull)
  383. return false;
  384. /* 0, 1, 4, 5, 6, 7 are valid values. */
  385. return (data | ((data & 0x0202020202020202ull) << 1)) == data;
  386. }
  387. static inline bool kvm_dr7_valid(u64 data)
  388. {
  389. /* Bits [63:32] are reserved */
  390. return !(data >> 32);
  391. }
  392. static inline bool kvm_dr6_valid(u64 data)
  393. {
  394. /* Bits [63:32] are reserved */
  395. return !(data >> 32);
  396. }
  397. /*
  398. * Trigger machine check on the host. We assume all the MSRs are already set up
  399. * by the CPU and that we still run on the same CPU as the MCE occurred on.
  400. * We pass a fake environment to the machine check handler because we want
  401. * the guest to be always treated like user space, no matter what context
  402. * it used internally.
  403. */
  404. static inline void kvm_machine_check(void)
  405. {
  406. #if defined(CONFIG_X86_MCE)
  407. struct pt_regs regs = {
  408. .cs = 3, /* Fake ring 3 no matter what the guest ran on */
  409. .flags = X86_EFLAGS_IF,
  410. };
  411. do_machine_check(&regs);
  412. #endif
  413. }
  414. void kvm_load_guest_xsave_state(struct kvm_vcpu *vcpu);
  415. void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu);
  416. int kvm_spec_ctrl_test_value(u64 value);
  417. bool __kvm_is_valid_cr4(struct kvm_vcpu *vcpu, unsigned long cr4);
  418. int kvm_handle_memory_failure(struct kvm_vcpu *vcpu, int r,
  419. struct x86_exception *e);
  420. int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva);
  421. bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type);
  422. enum kvm_msr_access {
  423. MSR_TYPE_R = BIT(0),
  424. MSR_TYPE_W = BIT(1),
  425. MSR_TYPE_RW = MSR_TYPE_R | MSR_TYPE_W,
  426. };
  427. /*
  428. * Internal error codes that are used to indicate that MSR emulation encountered
  429. * an error that should result in #GP in the guest, unless userspace handles it.
  430. * Note, '1', '0', and negative numbers are off limits, as they are used by KVM
  431. * as part of KVM's lightly documented internal KVM_RUN return codes.
  432. *
  433. * UNSUPPORTED - The MSR isn't supported, either because it is completely
  434. * unknown to KVM, or because the MSR should not exist according
  435. * to the vCPU model.
  436. *
  437. * FILTERED - Access to the MSR is denied by a userspace MSR filter.
  438. */
  439. #define KVM_MSR_RET_UNSUPPORTED 2
  440. #define KVM_MSR_RET_FILTERED 3
  441. #define __cr4_reserved_bits(__cpu_has, __c) \
  442. ({ \
  443. u64 __reserved_bits = CR4_RESERVED_BITS; \
  444. \
  445. if (!__cpu_has(__c, X86_FEATURE_XSAVE)) \
  446. __reserved_bits |= X86_CR4_OSXSAVE; \
  447. if (!__cpu_has(__c, X86_FEATURE_SMEP)) \
  448. __reserved_bits |= X86_CR4_SMEP; \
  449. if (!__cpu_has(__c, X86_FEATURE_SMAP)) \
  450. __reserved_bits |= X86_CR4_SMAP; \
  451. if (!__cpu_has(__c, X86_FEATURE_FSGSBASE)) \
  452. __reserved_bits |= X86_CR4_FSGSBASE; \
  453. if (!__cpu_has(__c, X86_FEATURE_PKU)) \
  454. __reserved_bits |= X86_CR4_PKE; \
  455. if (!__cpu_has(__c, X86_FEATURE_LA57)) \
  456. __reserved_bits |= X86_CR4_LA57; \
  457. if (!__cpu_has(__c, X86_FEATURE_UMIP)) \
  458. __reserved_bits |= X86_CR4_UMIP; \
  459. if (!__cpu_has(__c, X86_FEATURE_VMX)) \
  460. __reserved_bits |= X86_CR4_VMXE; \
  461. if (!__cpu_has(__c, X86_FEATURE_PCID)) \
  462. __reserved_bits |= X86_CR4_PCIDE; \
  463. if (!__cpu_has(__c, X86_FEATURE_LAM)) \
  464. __reserved_bits |= X86_CR4_LAM_SUP; \
  465. __reserved_bits; \
  466. })
  467. int kvm_sev_es_mmio_write(struct kvm_vcpu *vcpu, gpa_t src, unsigned int bytes,
  468. void *dst);
  469. int kvm_sev_es_mmio_read(struct kvm_vcpu *vcpu, gpa_t src, unsigned int bytes,
  470. void *dst);
  471. int kvm_sev_es_string_io(struct kvm_vcpu *vcpu, unsigned int size,
  472. unsigned int port, void *data, unsigned int count,
  473. int in);
  474. #endif