blob: 2f54829c9ad64f7d2010c8beb65eee0c52d79746 [file] [log] [blame]
Joerg Roedel883b0a92020-03-24 10:41:52 +01001// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Kernel-based Virtual Machine driver for Linux
4 *
5 * AMD SVM support
6 *
7 * Copyright (C) 2006 Qumranet, Inc.
8 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
9 *
10 * Authors:
11 * Yaniv Kamay <yaniv@qumranet.com>
12 * Avi Kivity <avi@qumranet.com>
13 */
14
15#ifndef __SVM_SVM_H
16#define __SVM_SVM_H
17
18#include <linux/kvm_types.h>
19#include <linux/kvm_host.h>
20
21#include <asm/svm.h>
22
23static const u32 host_save_user_msrs[] = {
24#ifdef CONFIG_X86_64
25 MSR_STAR, MSR_LSTAR, MSR_CSTAR, MSR_SYSCALL_MASK, MSR_KERNEL_GS_BASE,
26 MSR_FS_BASE,
27#endif
28 MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP,
29 MSR_TSC_AUX,
30};
31
32#define NR_HOST_SAVE_USER_MSRS ARRAY_SIZE(host_save_user_msrs)
33
34#define MSRPM_OFFSETS 16
35extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly;
36extern bool npt_enabled;
37
38enum {
39 VMCB_INTERCEPTS, /* Intercept vectors, TSC offset,
40 pause filter count */
41 VMCB_PERM_MAP, /* IOPM Base and MSRPM Base */
42 VMCB_ASID, /* ASID */
43 VMCB_INTR, /* int_ctl, int_vector */
44 VMCB_NPT, /* npt_en, nCR3, gPAT */
45 VMCB_CR, /* CR0, CR3, CR4, EFER */
46 VMCB_DR, /* DR6, DR7 */
47 VMCB_DT, /* GDT, IDT */
48 VMCB_SEG, /* CS, DS, SS, ES, CPL */
49 VMCB_CR2, /* CR2 only */
50 VMCB_LBR, /* DBGCTL, BR_FROM, BR_TO, LAST_EX_FROM, LAST_EX_TO */
51 VMCB_AVIC, /* AVIC APIC_BAR, AVIC APIC_BACKING_PAGE,
52 * AVIC PHYSICAL_TABLE pointer,
53 * AVIC LOGICAL_TABLE pointer
54 */
55 VMCB_DIRTY_MAX,
56};
57
58/* TPR and CR2 are always written before VMRUN */
59#define VMCB_ALWAYS_DIRTY_MASK ((1U << VMCB_INTR) | (1U << VMCB_CR2))
60
61struct kvm_sev_info {
62 bool active; /* SEV enabled guest */
63 unsigned int asid; /* ASID used for this guest */
64 unsigned int handle; /* SEV firmware handle */
65 int fd; /* SEV device fd */
66 unsigned long pages_locked; /* Number of pages locked */
67 struct list_head regions_list; /* List of registered regions */
68};
69
70struct kvm_svm {
71 struct kvm kvm;
72
73 /* Struct members for AVIC */
74 u32 avic_vm_id;
75 struct page *avic_logical_id_table_page;
76 struct page *avic_physical_id_table_page;
77 struct hlist_node hnode;
78
79 struct kvm_sev_info sev_info;
80};
81
82struct kvm_vcpu;
83
Joerg Roedel7693b3e2020-06-25 10:03:22 +020084struct svm_nested_state {
Joerg Roedel883b0a92020-03-24 10:41:52 +010085 struct vmcb *hsave;
86 u64 hsave_msr;
87 u64 vm_cr_msr;
Maxim Levitsky0dd16b52020-08-27 20:11:39 +030088 u64 vmcb12_gpa;
Joerg Roedel883b0a92020-03-24 10:41:52 +010089
90 /* These are the merged vectors */
91 u32 *msrpm;
92
Paolo Bonzinif74f9412020-04-23 13:22:27 -040093 /* A VMRUN has started but has not yet been performed, so
94 * we cannot inject a nested vmexit yet. */
95 bool nested_run_pending;
96
Paolo Bonzinie670bf62020-05-13 13:16:12 -040097 /* cache for control fields of the guest */
98 struct vmcb_control_area ctl;
Joerg Roedel883b0a92020-03-24 10:41:52 +010099};
100
101struct vcpu_svm {
102 struct kvm_vcpu vcpu;
103 struct vmcb *vmcb;
104 unsigned long vmcb_pa;
105 struct svm_cpu_data *svm_data;
106 uint64_t asid_generation;
107 uint64_t sysenter_esp;
108 uint64_t sysenter_eip;
109 uint64_t tsc_aux;
110
111 u64 msr_decfg;
112
113 u64 next_rip;
114
115 u64 host_user_msrs[NR_HOST_SAVE_USER_MSRS];
116 struct {
117 u16 fs;
118 u16 gs;
119 u16 ldt;
120 u64 gs_base;
121 } host;
122
123 u64 spec_ctrl;
124 /*
125 * Contains guest-controlled bits of VIRT_SPEC_CTRL, which will be
126 * translated into the appropriate L2_CFG bits on the host to
127 * perform speculative control.
128 */
129 u64 virt_spec_ctrl;
130
131 u32 *msrpm;
132
133 ulong nmi_iret_rip;
134
Joerg Roedel7693b3e2020-06-25 10:03:22 +0200135 struct svm_nested_state nested;
Joerg Roedel883b0a92020-03-24 10:41:52 +0100136
137 bool nmi_singlestep;
138 u64 nmi_singlestep_guest_rflags;
139
140 unsigned int3_injected;
141 unsigned long int3_rip;
142
143 /* cached guest cpuid flags for faster access */
144 bool nrips_enabled : 1;
145
146 u32 ldr_reg;
147 u32 dfr_reg;
148 struct page *avic_backing_page;
149 u64 *avic_physical_id_cache;
150 bool avic_is_running;
151
152 /*
153 * Per-vcpu list of struct amd_svm_iommu_ir:
154 * This is used mainly to store interrupt remapping information used
155 * when update the vcpu affinity. This avoids the need to scan for
156 * IRTE and try to match ga_tag in the IOMMU driver.
157 */
158 struct list_head ir_list;
159 spinlock_t ir_list_lock;
Joerg Roedel883b0a92020-03-24 10:41:52 +0100160};
161
Joerg Roedeleaf78262020-03-24 10:41:54 +0100162struct svm_cpu_data {
163 int cpu;
164
165 u64 asid_generation;
166 u32 max_asid;
167 u32 next_asid;
168 u32 min_asid;
169 struct kvm_ldttss_desc *tss_desc;
170
171 struct page *save_area;
172 struct vmcb *current_vmcb;
173
174 /* index = sev_asid, value = vmcb pointer */
175 struct vmcb **sev_vmcbs;
176};
177
178DECLARE_PER_CPU(struct svm_cpu_data *, svm_data);
179
Joerg Roedel883b0a92020-03-24 10:41:52 +0100180void recalc_intercepts(struct vcpu_svm *svm);
181
Joerg Roedelef0f6492020-03-31 12:17:38 -0400182static inline struct kvm_svm *to_kvm_svm(struct kvm *kvm)
183{
184 return container_of(kvm, struct kvm_svm, kvm);
185}
186
Joerg Roedel06e78522020-06-25 10:03:23 +0200187static inline void vmcb_mark_all_dirty(struct vmcb *vmcb)
Joerg Roedel883b0a92020-03-24 10:41:52 +0100188{
189 vmcb->control.clean = 0;
190}
191
Joerg Roedel06e78522020-06-25 10:03:23 +0200192static inline void vmcb_mark_all_clean(struct vmcb *vmcb)
Joerg Roedel883b0a92020-03-24 10:41:52 +0100193{
194 vmcb->control.clean = ((1 << VMCB_DIRTY_MAX) - 1)
195 & ~VMCB_ALWAYS_DIRTY_MASK;
196}
197
Joerg Roedel06e78522020-06-25 10:03:23 +0200198static inline void vmcb_mark_dirty(struct vmcb *vmcb, int bit)
Joerg Roedel883b0a92020-03-24 10:41:52 +0100199{
200 vmcb->control.clean &= ~(1 << bit);
201}
202
203static inline struct vcpu_svm *to_svm(struct kvm_vcpu *vcpu)
204{
205 return container_of(vcpu, struct vcpu_svm, vcpu);
206}
207
208static inline struct vmcb *get_host_vmcb(struct vcpu_svm *svm)
209{
210 if (is_guest_mode(&svm->vcpu))
211 return svm->nested.hsave;
212 else
213 return svm->vmcb;
214}
215
Babu Mogerc45ad722020-09-11 14:27:58 -0500216static inline void vmcb_set_intercept(struct vmcb_control_area *control, u32 bit)
217{
218 WARN_ON_ONCE(bit >= 32 * MAX_INTERCEPT);
219 __set_bit(bit, (unsigned long *)&control->intercepts);
220}
221
222static inline void vmcb_clr_intercept(struct vmcb_control_area *control, u32 bit)
223{
224 WARN_ON_ONCE(bit >= 32 * MAX_INTERCEPT);
225 __clear_bit(bit, (unsigned long *)&control->intercepts);
226}
227
228static inline bool vmcb_is_intercept(struct vmcb_control_area *control, u32 bit)
229{
230 WARN_ON_ONCE(bit >= 32 * MAX_INTERCEPT);
231 return test_bit(bit, (unsigned long *)&control->intercepts);
232}
233
Joerg Roedel883b0a92020-03-24 10:41:52 +0100234static inline void set_cr_intercept(struct vcpu_svm *svm, int bit)
235{
236 struct vmcb *vmcb = get_host_vmcb(svm);
237
Babu Moger03bfeeb2020-09-11 14:28:05 -0500238 vmcb_set_intercept(&vmcb->control, bit);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100239
240 recalc_intercepts(svm);
241}
242
243static inline void clr_cr_intercept(struct vcpu_svm *svm, int bit)
244{
245 struct vmcb *vmcb = get_host_vmcb(svm);
246
Babu Moger03bfeeb2020-09-11 14:28:05 -0500247 vmcb_clr_intercept(&vmcb->control, bit);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100248
249 recalc_intercepts(svm);
250}
251
252static inline bool is_cr_intercept(struct vcpu_svm *svm, int bit)
253{
254 struct vmcb *vmcb = get_host_vmcb(svm);
255
Babu Moger03bfeeb2020-09-11 14:28:05 -0500256 return vmcb_is_intercept(&vmcb->control, bit);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100257}
258
259static inline void set_dr_intercepts(struct vcpu_svm *svm)
260{
261 struct vmcb *vmcb = get_host_vmcb(svm);
262
Babu Moger30abaa882020-09-11 14:28:12 -0500263 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR0_READ);
264 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR1_READ);
265 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR2_READ);
266 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR3_READ);
267 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR4_READ);
268 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR5_READ);
269 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR6_READ);
270 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR7_READ);
271 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR0_WRITE);
272 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR1_WRITE);
273 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR2_WRITE);
274 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR3_WRITE);
275 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR4_WRITE);
276 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR5_WRITE);
277 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR6_WRITE);
278 vmcb_set_intercept(&vmcb->control, INTERCEPT_DR7_WRITE);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100279
280 recalc_intercepts(svm);
281}
282
283static inline void clr_dr_intercepts(struct vcpu_svm *svm)
284{
285 struct vmcb *vmcb = get_host_vmcb(svm);
286
Babu Moger30abaa882020-09-11 14:28:12 -0500287 vmcb->control.intercepts[INTERCEPT_DR] = 0;
Joerg Roedel883b0a92020-03-24 10:41:52 +0100288
289 recalc_intercepts(svm);
290}
291
292static inline void set_exception_intercept(struct vcpu_svm *svm, int bit)
293{
294 struct vmcb *vmcb = get_host_vmcb(svm);
295
296 vmcb->control.intercept_exceptions |= (1U << bit);
297
298 recalc_intercepts(svm);
299}
300
301static inline void clr_exception_intercept(struct vcpu_svm *svm, int bit)
302{
303 struct vmcb *vmcb = get_host_vmcb(svm);
304
305 vmcb->control.intercept_exceptions &= ~(1U << bit);
306
307 recalc_intercepts(svm);
308}
309
Joerg Roedela284ba52020-06-25 10:03:24 +0200310static inline void svm_set_intercept(struct vcpu_svm *svm, int bit)
Joerg Roedel883b0a92020-03-24 10:41:52 +0100311{
312 struct vmcb *vmcb = get_host_vmcb(svm);
313
314 vmcb->control.intercept |= (1ULL << bit);
315
316 recalc_intercepts(svm);
317}
318
Joerg Roedela284ba52020-06-25 10:03:24 +0200319static inline void svm_clr_intercept(struct vcpu_svm *svm, int bit)
Joerg Roedel883b0a92020-03-24 10:41:52 +0100320{
321 struct vmcb *vmcb = get_host_vmcb(svm);
322
323 vmcb->control.intercept &= ~(1ULL << bit);
324
325 recalc_intercepts(svm);
326}
327
Joerg Roedela284ba52020-06-25 10:03:24 +0200328static inline bool svm_is_intercept(struct vcpu_svm *svm, int bit)
Joerg Roedel883b0a92020-03-24 10:41:52 +0100329{
330 return (svm->vmcb->control.intercept & (1ULL << bit)) != 0;
331}
332
333static inline bool vgif_enabled(struct vcpu_svm *svm)
334{
335 return !!(svm->vmcb->control.int_ctl & V_GIF_ENABLE_MASK);
336}
337
338static inline void enable_gif(struct vcpu_svm *svm)
339{
340 if (vgif_enabled(svm))
341 svm->vmcb->control.int_ctl |= V_GIF_MASK;
342 else
343 svm->vcpu.arch.hflags |= HF_GIF_MASK;
344}
345
346static inline void disable_gif(struct vcpu_svm *svm)
347{
348 if (vgif_enabled(svm))
349 svm->vmcb->control.int_ctl &= ~V_GIF_MASK;
350 else
351 svm->vcpu.arch.hflags &= ~HF_GIF_MASK;
352}
353
354static inline bool gif_set(struct vcpu_svm *svm)
355{
356 if (vgif_enabled(svm))
357 return !!(svm->vmcb->control.int_ctl & V_GIF_MASK);
358 else
359 return !!(svm->vcpu.arch.hflags & HF_GIF_MASK);
360}
361
362/* svm.c */
Krish Sadhukhan761e4162020-07-08 00:39:56 +0000363#define MSR_CR3_LEGACY_RESERVED_MASK 0xfe7U
364#define MSR_CR3_LEGACY_PAE_RESERVED_MASK 0x7U
365#define MSR_CR3_LONG_RESERVED_MASK 0xfff0000000000fe7U
366#define MSR_INVALID 0xffffffffU
Joerg Roedel883b0a92020-03-24 10:41:52 +0100367
368u32 svm_msrpm_offset(u32 msr);
369void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer);
370void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);
371int svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4);
Sean Christophersonf55ac302020-03-20 14:28:12 -0700372void svm_flush_tlb(struct kvm_vcpu *vcpu);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100373void disable_nmi_singlestep(struct vcpu_svm *svm);
Paolo Bonzinicae96af2020-04-23 14:19:26 -0400374bool svm_smi_blocked(struct kvm_vcpu *vcpu);
375bool svm_nmi_blocked(struct kvm_vcpu *vcpu);
376bool svm_interrupt_blocked(struct kvm_vcpu *vcpu);
Paolo Bonziniffdf7f92020-05-22 12:18:27 -0400377void svm_set_gif(struct vcpu_svm *svm, bool value);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100378
379/* nested.c */
380
381#define NESTED_EXIT_HOST 0 /* Exit handled on host level */
382#define NESTED_EXIT_DONE 1 /* Exit caused nested vmexit */
383#define NESTED_EXIT_CONTINUE 2 /* Further checks needed */
384
Joerg Roedel01c3b2b2020-06-25 10:03:25 +0200385static inline bool nested_svm_virtualize_tpr(struct kvm_vcpu *vcpu)
Joerg Roedel883b0a92020-03-24 10:41:52 +0100386{
Paolo Bonzinie9fd7612020-05-13 13:28:23 -0400387 struct vcpu_svm *svm = to_svm(vcpu);
388
389 return is_guest_mode(vcpu) && (svm->nested.ctl.int_ctl & V_INTR_MASKING_MASK);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100390}
391
Paolo Bonzini55714cd2020-04-23 08:17:28 -0400392static inline bool nested_exit_on_smi(struct vcpu_svm *svm)
393{
Paolo Bonzinie670bf62020-05-13 13:16:12 -0400394 return (svm->nested.ctl.intercept & (1ULL << INTERCEPT_SMI));
Paolo Bonzini55714cd2020-04-23 08:17:28 -0400395}
396
Paolo Bonzinifc6f7c02020-04-23 18:02:45 -0400397static inline bool nested_exit_on_intr(struct vcpu_svm *svm)
398{
Paolo Bonzinie670bf62020-05-13 13:16:12 -0400399 return (svm->nested.ctl.intercept & (1ULL << INTERCEPT_INTR));
Paolo Bonzinifc6f7c02020-04-23 18:02:45 -0400400}
401
Paolo Bonzinibbdad0b2020-04-23 08:06:43 -0400402static inline bool nested_exit_on_nmi(struct vcpu_svm *svm)
403{
Paolo Bonzinie670bf62020-05-13 13:16:12 -0400404 return (svm->nested.ctl.intercept & (1ULL << INTERCEPT_NMI));
Paolo Bonzinibbdad0b2020-04-23 08:06:43 -0400405}
406
Vitaly Kuznetsov59cd9bc2020-07-10 16:11:52 +0200407int enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb_gpa,
408 struct vmcb *nested_vmcb);
Paolo Bonzinic513f482020-05-18 13:08:37 -0400409void svm_leave_nested(struct vcpu_svm *svm);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100410int nested_svm_vmrun(struct vcpu_svm *svm);
411void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb);
412int nested_svm_vmexit(struct vcpu_svm *svm);
413int nested_svm_exit_handled(struct vcpu_svm *svm);
414int nested_svm_check_permissions(struct vcpu_svm *svm);
415int nested_svm_check_exception(struct vcpu_svm *svm, unsigned nr,
416 bool has_error_code, u32 error_code);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100417int nested_svm_exit_special(struct vcpu_svm *svm);
Paolo Bonzini2d8a42b2020-05-22 03:50:14 -0400418void sync_nested_vmcb_control(struct vcpu_svm *svm);
Joerg Roedel883b0a92020-03-24 10:41:52 +0100419
Paolo Bonzini33b22172020-04-17 10:24:18 -0400420extern struct kvm_x86_nested_ops svm_nested_ops;
421
Joerg Roedelef0f6492020-03-31 12:17:38 -0400422/* avic.c */
423
424#define AVIC_LOGICAL_ID_ENTRY_GUEST_PHYSICAL_ID_MASK (0xFF)
425#define AVIC_LOGICAL_ID_ENTRY_VALID_BIT 31
426#define AVIC_LOGICAL_ID_ENTRY_VALID_MASK (1 << 31)
427
428#define AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK (0xFFULL)
429#define AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK (0xFFFFFFFFFFULL << 12)
430#define AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK (1ULL << 62)
431#define AVIC_PHYSICAL_ID_ENTRY_VALID_MASK (1ULL << 63)
432
433#define VMCB_AVIC_APIC_BAR_MASK 0xFFFFFFFFFF000ULL
434
435extern int avic;
436
437static inline void avic_update_vapic_bar(struct vcpu_svm *svm, u64 data)
438{
439 svm->vmcb->control.avic_vapic_bar = data & VMCB_AVIC_APIC_BAR_MASK;
Joerg Roedel06e78522020-06-25 10:03:23 +0200440 vmcb_mark_dirty(svm->vmcb, VMCB_AVIC);
Joerg Roedelef0f6492020-03-31 12:17:38 -0400441}
442
443static inline bool avic_vcpu_is_running(struct kvm_vcpu *vcpu)
444{
445 struct vcpu_svm *svm = to_svm(vcpu);
446 u64 *entry = svm->avic_physical_id_cache;
447
448 if (!entry)
449 return false;
450
451 return (READ_ONCE(*entry) & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK);
452}
453
454int avic_ga_log_notifier(u32 ga_tag);
455void avic_vm_destroy(struct kvm *kvm);
456int avic_vm_init(struct kvm *kvm);
457void avic_init_vmcb(struct vcpu_svm *svm);
458void svm_toggle_avic_for_irq_window(struct kvm_vcpu *vcpu, bool activate);
459int avic_incomplete_ipi_interception(struct vcpu_svm *svm);
460int avic_unaccelerated_access_interception(struct vcpu_svm *svm);
461int avic_init_vcpu(struct vcpu_svm *svm);
462void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
463void avic_vcpu_put(struct kvm_vcpu *vcpu);
464void avic_post_state_restore(struct kvm_vcpu *vcpu);
465void svm_set_virtual_apic_mode(struct kvm_vcpu *vcpu);
466void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu);
467bool svm_check_apicv_inhibit_reasons(ulong bit);
468void svm_pre_update_apicv_exec_ctrl(struct kvm *kvm, bool activate);
469void svm_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap);
470void svm_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr);
471void svm_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr);
472int svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec);
473bool svm_dy_apicv_has_pending_interrupt(struct kvm_vcpu *vcpu);
474int svm_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
475 uint32_t guest_irq, bool set);
476void svm_vcpu_blocking(struct kvm_vcpu *vcpu);
477void svm_vcpu_unblocking(struct kvm_vcpu *vcpu);
478
Joerg Roedeleaf78262020-03-24 10:41:54 +0100479/* sev.c */
480
481extern unsigned int max_sev_asid;
482
483static inline bool sev_guest(struct kvm *kvm)
484{
485#ifdef CONFIG_KVM_AMD_SEV
486 struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
487
488 return sev->active;
489#else
490 return false;
491#endif
492}
493
494static inline bool svm_sev_enabled(void)
495{
496 return IS_ENABLED(CONFIG_KVM_AMD_SEV) ? max_sev_asid : 0;
497}
498
499void sev_vm_destroy(struct kvm *kvm);
500int svm_mem_enc_op(struct kvm *kvm, void __user *argp);
501int svm_register_enc_region(struct kvm *kvm,
502 struct kvm_enc_region *range);
503int svm_unregister_enc_region(struct kvm *kvm,
504 struct kvm_enc_region *range);
505void pre_sev_run(struct vcpu_svm *svm, int cpu);
506int __init sev_hardware_setup(void);
507void sev_hardware_teardown(void);
508
Joerg Roedel883b0a92020-03-24 10:41:52 +0100509#endif