Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 1 | // 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> |
Tom Lendacky | 291bd20 | 2020-12-10 11:09:47 -0600 | [diff] [blame] | 20 | #include <linux/bits.h> |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 21 | |
| 22 | #include <asm/svm.h> |
| 23 | |
Tom Lendacky | 85ca8be | 2020-12-10 11:10:04 -0600 | [diff] [blame] | 24 | #define __sme_page_pa(x) __sme_set(page_to_pfn(x) << PAGE_SHIFT) |
| 25 | |
Michael Roth | 553cc15 | 2021-02-02 13:01:25 -0600 | [diff] [blame] | 26 | static const u32 host_save_user_msrs[] = { |
| 27 | MSR_TSC_AUX, |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 28 | }; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 29 | #define NR_HOST_SAVE_USER_MSRS ARRAY_SIZE(host_save_user_msrs) |
| 30 | |
Maxim Levitsky | adc2a23 | 2021-04-01 14:19:28 +0300 | [diff] [blame] | 31 | #define MAX_DIRECT_ACCESS_MSRS 20 |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 32 | #define MSRPM_OFFSETS 16 |
| 33 | extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly; |
| 34 | extern bool npt_enabled; |
| 35 | |
| 36 | enum { |
| 37 | VMCB_INTERCEPTS, /* Intercept vectors, TSC offset, |
| 38 | pause filter count */ |
| 39 | VMCB_PERM_MAP, /* IOPM Base and MSRPM Base */ |
| 40 | VMCB_ASID, /* ASID */ |
| 41 | VMCB_INTR, /* int_ctl, int_vector */ |
| 42 | VMCB_NPT, /* npt_en, nCR3, gPAT */ |
| 43 | VMCB_CR, /* CR0, CR3, CR4, EFER */ |
| 44 | VMCB_DR, /* DR6, DR7 */ |
| 45 | VMCB_DT, /* GDT, IDT */ |
| 46 | VMCB_SEG, /* CS, DS, SS, ES, CPL */ |
| 47 | VMCB_CR2, /* CR2 only */ |
| 48 | VMCB_LBR, /* DBGCTL, BR_FROM, BR_TO, LAST_EX_FROM, LAST_EX_TO */ |
| 49 | VMCB_AVIC, /* AVIC APIC_BAR, AVIC APIC_BACKING_PAGE, |
| 50 | * AVIC PHYSICAL_TABLE pointer, |
| 51 | * AVIC LOGICAL_TABLE pointer |
| 52 | */ |
| 53 | VMCB_DIRTY_MAX, |
| 54 | }; |
| 55 | |
| 56 | /* TPR and CR2 are always written before VMRUN */ |
| 57 | #define VMCB_ALWAYS_DIRTY_MASK ((1U << VMCB_INTR) | (1U << VMCB_CR2)) |
| 58 | |
| 59 | struct kvm_sev_info { |
| 60 | bool active; /* SEV enabled guest */ |
Tom Lendacky | 916391a | 2020-12-10 11:09:38 -0600 | [diff] [blame] | 61 | bool es_active; /* SEV-ES enabled guest */ |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 62 | unsigned int asid; /* ASID used for this guest */ |
| 63 | unsigned int handle; /* SEV firmware handle */ |
| 64 | int fd; /* SEV device fd */ |
| 65 | unsigned long pages_locked; /* Number of pages locked */ |
| 66 | struct list_head regions_list; /* List of registered regions */ |
Tom Lendacky | 8640ca5 | 2020-12-15 12:44:07 -0500 | [diff] [blame] | 67 | u64 ap_jump_table; /* SEV-ES AP Jump Table address */ |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | struct 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 | |
| 82 | struct kvm_vcpu; |
| 83 | |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 84 | struct kvm_vmcb_info { |
| 85 | struct vmcb *ptr; |
| 86 | unsigned long pa; |
Cathy Avery | af18fa7 | 2021-01-12 11:43:12 -0500 | [diff] [blame] | 87 | int cpu; |
Cathy Avery | 193015a | 2021-01-12 11:43:13 -0500 | [diff] [blame] | 88 | uint64_t asid_generation; |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 89 | }; |
| 90 | |
Joerg Roedel | 7693b3e | 2020-06-25 10:03:22 +0200 | [diff] [blame] | 91 | struct svm_nested_state { |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 92 | struct kvm_vmcb_info vmcb02; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 93 | u64 hsave_msr; |
| 94 | u64 vm_cr_msr; |
Maxim Levitsky | 0dd16b5 | 2020-08-27 20:11:39 +0300 | [diff] [blame] | 95 | u64 vmcb12_gpa; |
Cathy Avery | 8173396 | 2021-03-01 15:08:44 -0500 | [diff] [blame] | 96 | u64 last_vmcb12_gpa; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 97 | |
| 98 | /* These are the merged vectors */ |
| 99 | u32 *msrpm; |
| 100 | |
Paolo Bonzini | f74f941 | 2020-04-23 13:22:27 -0400 | [diff] [blame] | 101 | /* A VMRUN has started but has not yet been performed, so |
| 102 | * we cannot inject a nested vmexit yet. */ |
| 103 | bool nested_run_pending; |
| 104 | |
Paolo Bonzini | e670bf6 | 2020-05-13 13:16:12 -0400 | [diff] [blame] | 105 | /* cache for control fields of the guest */ |
| 106 | struct vmcb_control_area ctl; |
Maxim Levitsky | 2fcf487 | 2020-10-01 14:29:54 +0300 | [diff] [blame] | 107 | |
| 108 | bool initialized; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | struct vcpu_svm { |
| 112 | struct kvm_vcpu vcpu; |
| 113 | struct vmcb *vmcb; |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 114 | struct kvm_vmcb_info vmcb01; |
| 115 | struct kvm_vmcb_info *current_vmcb; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 116 | struct svm_cpu_data *svm_data; |
Cathy Avery | 7e8e6ee | 2020-10-11 14:48:17 -0400 | [diff] [blame] | 117 | u32 asid; |
Maxim Levitsky | adc2a23 | 2021-04-01 14:19:28 +0300 | [diff] [blame] | 118 | u32 sysenter_esp_hi; |
| 119 | u32 sysenter_eip_hi; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 120 | uint64_t tsc_aux; |
| 121 | |
| 122 | u64 msr_decfg; |
| 123 | |
| 124 | u64 next_rip; |
| 125 | |
| 126 | u64 host_user_msrs[NR_HOST_SAVE_USER_MSRS]; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 127 | |
| 128 | u64 spec_ctrl; |
| 129 | /* |
| 130 | * Contains guest-controlled bits of VIRT_SPEC_CTRL, which will be |
| 131 | * translated into the appropriate L2_CFG bits on the host to |
| 132 | * perform speculative control. |
| 133 | */ |
| 134 | u64 virt_spec_ctrl; |
| 135 | |
| 136 | u32 *msrpm; |
| 137 | |
| 138 | ulong nmi_iret_rip; |
| 139 | |
Joerg Roedel | 7693b3e | 2020-06-25 10:03:22 +0200 | [diff] [blame] | 140 | struct svm_nested_state nested; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 141 | |
| 142 | bool nmi_singlestep; |
| 143 | u64 nmi_singlestep_guest_rflags; |
| 144 | |
| 145 | unsigned int3_injected; |
| 146 | unsigned long int3_rip; |
| 147 | |
| 148 | /* cached guest cpuid flags for faster access */ |
| 149 | bool nrips_enabled : 1; |
| 150 | |
| 151 | u32 ldr_reg; |
| 152 | u32 dfr_reg; |
| 153 | struct page *avic_backing_page; |
| 154 | u64 *avic_physical_id_cache; |
| 155 | bool avic_is_running; |
| 156 | |
| 157 | /* |
| 158 | * Per-vcpu list of struct amd_svm_iommu_ir: |
| 159 | * This is used mainly to store interrupt remapping information used |
| 160 | * when update the vcpu affinity. This avoids the need to scan for |
| 161 | * IRTE and try to match ga_tag in the IOMMU driver. |
| 162 | */ |
| 163 | struct list_head ir_list; |
| 164 | spinlock_t ir_list_lock; |
Alexander Graf | fd6fa73 | 2020-09-25 16:34:19 +0200 | [diff] [blame] | 165 | |
| 166 | /* Save desired MSR intercept (read: pass-through) state */ |
| 167 | struct { |
| 168 | DECLARE_BITMAP(read, MAX_DIRECT_ACCESS_MSRS); |
| 169 | DECLARE_BITMAP(write, MAX_DIRECT_ACCESS_MSRS); |
| 170 | } shadow_msr_intercept; |
Tom Lendacky | add5e2f | 2020-12-10 11:09:40 -0600 | [diff] [blame] | 171 | |
| 172 | /* SEV-ES support */ |
| 173 | struct vmcb_save_area *vmsa; |
| 174 | struct ghcb *ghcb; |
Tom Lendacky | 291bd20 | 2020-12-10 11:09:47 -0600 | [diff] [blame] | 175 | struct kvm_host_map ghcb_map; |
Tom Lendacky | 647daca | 2021-01-04 14:20:01 -0600 | [diff] [blame] | 176 | bool received_first_sipi; |
Tom Lendacky | 8f423a8 | 2020-12-10 11:09:53 -0600 | [diff] [blame] | 177 | |
| 178 | /* SEV-ES scratch area support */ |
| 179 | void *ghcb_sa; |
| 180 | u64 ghcb_sa_len; |
| 181 | bool ghcb_sa_sync; |
| 182 | bool ghcb_sa_free; |
Michael Roth | a7fc06d | 2021-02-02 13:01:26 -0600 | [diff] [blame] | 183 | |
| 184 | bool guest_state_loaded; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 185 | }; |
| 186 | |
Joerg Roedel | eaf7826 | 2020-03-24 10:41:54 +0100 | [diff] [blame] | 187 | struct svm_cpu_data { |
| 188 | int cpu; |
| 189 | |
| 190 | u64 asid_generation; |
| 191 | u32 max_asid; |
| 192 | u32 next_asid; |
| 193 | u32 min_asid; |
| 194 | struct kvm_ldttss_desc *tss_desc; |
| 195 | |
| 196 | struct page *save_area; |
| 197 | struct vmcb *current_vmcb; |
| 198 | |
| 199 | /* index = sev_asid, value = vmcb pointer */ |
| 200 | struct vmcb **sev_vmcbs; |
| 201 | }; |
| 202 | |
| 203 | DECLARE_PER_CPU(struct svm_cpu_data *, svm_data); |
| 204 | |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 205 | void recalc_intercepts(struct vcpu_svm *svm); |
| 206 | |
Joerg Roedel | ef0f649 | 2020-03-31 12:17:38 -0400 | [diff] [blame] | 207 | static inline struct kvm_svm *to_kvm_svm(struct kvm *kvm) |
| 208 | { |
| 209 | return container_of(kvm, struct kvm_svm, kvm); |
| 210 | } |
| 211 | |
Tom Lendacky | 916391a | 2020-12-10 11:09:38 -0600 | [diff] [blame] | 212 | static inline bool sev_guest(struct kvm *kvm) |
| 213 | { |
| 214 | #ifdef CONFIG_KVM_AMD_SEV |
| 215 | struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; |
| 216 | |
| 217 | return sev->active; |
| 218 | #else |
| 219 | return false; |
| 220 | #endif |
| 221 | } |
| 222 | |
| 223 | static inline bool sev_es_guest(struct kvm *kvm) |
| 224 | { |
| 225 | #ifdef CONFIG_KVM_AMD_SEV |
| 226 | struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; |
| 227 | |
| 228 | return sev_guest(kvm) && sev->es_active; |
| 229 | #else |
| 230 | return false; |
| 231 | #endif |
| 232 | } |
| 233 | |
Joerg Roedel | 06e7852 | 2020-06-25 10:03:23 +0200 | [diff] [blame] | 234 | static inline void vmcb_mark_all_dirty(struct vmcb *vmcb) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 235 | { |
| 236 | vmcb->control.clean = 0; |
| 237 | } |
| 238 | |
Joerg Roedel | 06e7852 | 2020-06-25 10:03:23 +0200 | [diff] [blame] | 239 | static inline void vmcb_mark_all_clean(struct vmcb *vmcb) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 240 | { |
| 241 | vmcb->control.clean = ((1 << VMCB_DIRTY_MAX) - 1) |
| 242 | & ~VMCB_ALWAYS_DIRTY_MASK; |
| 243 | } |
| 244 | |
Joerg Roedel | 06e7852 | 2020-06-25 10:03:23 +0200 | [diff] [blame] | 245 | static inline void vmcb_mark_dirty(struct vmcb *vmcb, int bit) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 246 | { |
| 247 | vmcb->control.clean &= ~(1 << bit); |
| 248 | } |
| 249 | |
Cathy Avery | 8173396 | 2021-03-01 15:08:44 -0500 | [diff] [blame] | 250 | static inline bool vmcb_is_dirty(struct vmcb *vmcb, int bit) |
| 251 | { |
| 252 | return !test_bit(bit, (unsigned long *)&vmcb->control.clean); |
| 253 | } |
| 254 | |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 255 | static inline struct vcpu_svm *to_svm(struct kvm_vcpu *vcpu) |
| 256 | { |
| 257 | return container_of(vcpu, struct vcpu_svm, vcpu); |
| 258 | } |
| 259 | |
Babu Moger | c45ad72 | 2020-09-11 14:27:58 -0500 | [diff] [blame] | 260 | static inline void vmcb_set_intercept(struct vmcb_control_area *control, u32 bit) |
| 261 | { |
| 262 | WARN_ON_ONCE(bit >= 32 * MAX_INTERCEPT); |
| 263 | __set_bit(bit, (unsigned long *)&control->intercepts); |
| 264 | } |
| 265 | |
| 266 | static inline void vmcb_clr_intercept(struct vmcb_control_area *control, u32 bit) |
| 267 | { |
| 268 | WARN_ON_ONCE(bit >= 32 * MAX_INTERCEPT); |
| 269 | __clear_bit(bit, (unsigned long *)&control->intercepts); |
| 270 | } |
| 271 | |
| 272 | static inline bool vmcb_is_intercept(struct vmcb_control_area *control, u32 bit) |
| 273 | { |
| 274 | WARN_ON_ONCE(bit >= 32 * MAX_INTERCEPT); |
| 275 | return test_bit(bit, (unsigned long *)&control->intercepts); |
| 276 | } |
| 277 | |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 278 | static inline void set_dr_intercepts(struct vcpu_svm *svm) |
| 279 | { |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 280 | struct vmcb *vmcb = svm->vmcb01.ptr; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 281 | |
Tom Lendacky | 8d4846b | 2020-12-10 11:09:43 -0600 | [diff] [blame] | 282 | if (!sev_es_guest(svm->vcpu.kvm)) { |
| 283 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR0_READ); |
| 284 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR1_READ); |
| 285 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR2_READ); |
| 286 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR3_READ); |
| 287 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR4_READ); |
| 288 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR5_READ); |
| 289 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR6_READ); |
| 290 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR0_WRITE); |
| 291 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR1_WRITE); |
| 292 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR2_WRITE); |
| 293 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR3_WRITE); |
| 294 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR4_WRITE); |
| 295 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR5_WRITE); |
| 296 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR6_WRITE); |
| 297 | } |
| 298 | |
Babu Moger | 30abaa88 | 2020-09-11 14:28:12 -0500 | [diff] [blame] | 299 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR7_READ); |
Babu Moger | 30abaa88 | 2020-09-11 14:28:12 -0500 | [diff] [blame] | 300 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR7_WRITE); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 301 | |
| 302 | recalc_intercepts(svm); |
| 303 | } |
| 304 | |
| 305 | static inline void clr_dr_intercepts(struct vcpu_svm *svm) |
| 306 | { |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 307 | struct vmcb *vmcb = svm->vmcb01.ptr; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 308 | |
Babu Moger | 30abaa88 | 2020-09-11 14:28:12 -0500 | [diff] [blame] | 309 | vmcb->control.intercepts[INTERCEPT_DR] = 0; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 310 | |
Tom Lendacky | 8d4846b | 2020-12-10 11:09:43 -0600 | [diff] [blame] | 311 | /* DR7 access must remain intercepted for an SEV-ES guest */ |
| 312 | if (sev_es_guest(svm->vcpu.kvm)) { |
| 313 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR7_READ); |
| 314 | vmcb_set_intercept(&vmcb->control, INTERCEPT_DR7_WRITE); |
| 315 | } |
| 316 | |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 317 | recalc_intercepts(svm); |
| 318 | } |
| 319 | |
Babu Moger | 9780d51 | 2020-09-11 14:28:20 -0500 | [diff] [blame] | 320 | static inline void set_exception_intercept(struct vcpu_svm *svm, u32 bit) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 321 | { |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 322 | struct vmcb *vmcb = svm->vmcb01.ptr; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 323 | |
Babu Moger | 9780d51 | 2020-09-11 14:28:20 -0500 | [diff] [blame] | 324 | WARN_ON_ONCE(bit >= 32); |
| 325 | vmcb_set_intercept(&vmcb->control, INTERCEPT_EXCEPTION_OFFSET + bit); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 326 | |
| 327 | recalc_intercepts(svm); |
| 328 | } |
| 329 | |
Babu Moger | 9780d51 | 2020-09-11 14:28:20 -0500 | [diff] [blame] | 330 | static inline void clr_exception_intercept(struct vcpu_svm *svm, u32 bit) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 331 | { |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 332 | struct vmcb *vmcb = svm->vmcb01.ptr; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 333 | |
Babu Moger | 9780d51 | 2020-09-11 14:28:20 -0500 | [diff] [blame] | 334 | WARN_ON_ONCE(bit >= 32); |
| 335 | vmcb_clr_intercept(&vmcb->control, INTERCEPT_EXCEPTION_OFFSET + bit); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 336 | |
| 337 | recalc_intercepts(svm); |
| 338 | } |
| 339 | |
Joerg Roedel | a284ba5 | 2020-06-25 10:03:24 +0200 | [diff] [blame] | 340 | static inline void svm_set_intercept(struct vcpu_svm *svm, int bit) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 341 | { |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 342 | struct vmcb *vmcb = svm->vmcb01.ptr; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 343 | |
Babu Moger | c62e2e9 | 2020-09-11 14:28:28 -0500 | [diff] [blame] | 344 | vmcb_set_intercept(&vmcb->control, bit); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 345 | |
| 346 | recalc_intercepts(svm); |
| 347 | } |
| 348 | |
Joerg Roedel | a284ba5 | 2020-06-25 10:03:24 +0200 | [diff] [blame] | 349 | static inline void svm_clr_intercept(struct vcpu_svm *svm, int bit) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 350 | { |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 351 | struct vmcb *vmcb = svm->vmcb01.ptr; |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 352 | |
Babu Moger | c62e2e9 | 2020-09-11 14:28:28 -0500 | [diff] [blame] | 353 | vmcb_clr_intercept(&vmcb->control, bit); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 354 | |
| 355 | recalc_intercepts(svm); |
| 356 | } |
| 357 | |
Joerg Roedel | a284ba5 | 2020-06-25 10:03:24 +0200 | [diff] [blame] | 358 | static inline bool svm_is_intercept(struct vcpu_svm *svm, int bit) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 359 | { |
Babu Moger | c62e2e9 | 2020-09-11 14:28:28 -0500 | [diff] [blame] | 360 | return vmcb_is_intercept(&svm->vmcb->control, bit); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | static inline bool vgif_enabled(struct vcpu_svm *svm) |
| 364 | { |
| 365 | return !!(svm->vmcb->control.int_ctl & V_GIF_ENABLE_MASK); |
| 366 | } |
| 367 | |
| 368 | static inline void enable_gif(struct vcpu_svm *svm) |
| 369 | { |
| 370 | if (vgif_enabled(svm)) |
| 371 | svm->vmcb->control.int_ctl |= V_GIF_MASK; |
| 372 | else |
| 373 | svm->vcpu.arch.hflags |= HF_GIF_MASK; |
| 374 | } |
| 375 | |
| 376 | static inline void disable_gif(struct vcpu_svm *svm) |
| 377 | { |
| 378 | if (vgif_enabled(svm)) |
| 379 | svm->vmcb->control.int_ctl &= ~V_GIF_MASK; |
| 380 | else |
| 381 | svm->vcpu.arch.hflags &= ~HF_GIF_MASK; |
| 382 | } |
| 383 | |
| 384 | static inline bool gif_set(struct vcpu_svm *svm) |
| 385 | { |
| 386 | if (vgif_enabled(svm)) |
| 387 | return !!(svm->vmcb->control.int_ctl & V_GIF_MASK); |
| 388 | else |
| 389 | return !!(svm->vcpu.arch.hflags & HF_GIF_MASK); |
| 390 | } |
| 391 | |
| 392 | /* svm.c */ |
Krish Sadhukhan | 761e416 | 2020-07-08 00:39:56 +0000 | [diff] [blame] | 393 | #define MSR_INVALID 0xffffffffU |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 394 | |
Tom Lendacky | 916391a | 2020-12-10 11:09:38 -0600 | [diff] [blame] | 395 | extern int sev; |
| 396 | extern int sev_es; |
Tom Lendacky | 291bd20 | 2020-12-10 11:09:47 -0600 | [diff] [blame] | 397 | extern bool dump_invalid_vmcb; |
Tom Lendacky | 916391a | 2020-12-10 11:09:38 -0600 | [diff] [blame] | 398 | |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 399 | u32 svm_msrpm_offset(u32 msr); |
Maxim Levitsky | 2fcf487 | 2020-10-01 14:29:54 +0300 | [diff] [blame] | 400 | u32 *svm_vcpu_alloc_msrpm(void); |
| 401 | void svm_vcpu_init_msrpm(struct kvm_vcpu *vcpu, u32 *msrpm); |
| 402 | void svm_vcpu_free_msrpm(u32 *msrpm); |
| 403 | |
Maxim Levitsky | 72f211e | 2020-10-01 14:29:53 +0300 | [diff] [blame] | 404 | int svm_set_efer(struct kvm_vcpu *vcpu, u64 efer); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 405 | void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); |
Sean Christopherson | c2fe3cd | 2020-10-06 18:44:15 -0700 | [diff] [blame] | 406 | void svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4); |
Sean Christopherson | f55ac30 | 2020-03-20 14:28:12 -0700 | [diff] [blame] | 407 | void svm_flush_tlb(struct kvm_vcpu *vcpu); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 408 | void disable_nmi_singlestep(struct vcpu_svm *svm); |
Paolo Bonzini | cae96af | 2020-04-23 14:19:26 -0400 | [diff] [blame] | 409 | bool svm_smi_blocked(struct kvm_vcpu *vcpu); |
| 410 | bool svm_nmi_blocked(struct kvm_vcpu *vcpu); |
| 411 | bool svm_interrupt_blocked(struct kvm_vcpu *vcpu); |
Paolo Bonzini | ffdf7f9 | 2020-05-22 12:18:27 -0400 | [diff] [blame] | 412 | void svm_set_gif(struct vcpu_svm *svm, bool value); |
Paolo Bonzini | 6312975 | 2021-03-02 14:40:39 -0500 | [diff] [blame] | 413 | int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code); |
Tom Lendacky | 376c6d2 | 2020-12-10 11:10:06 -0600 | [diff] [blame] | 414 | void set_msr_interception(struct kvm_vcpu *vcpu, u32 *msrpm, u32 msr, |
| 415 | int read, int write); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 416 | |
| 417 | /* nested.c */ |
| 418 | |
| 419 | #define NESTED_EXIT_HOST 0 /* Exit handled on host level */ |
| 420 | #define NESTED_EXIT_DONE 1 /* Exit caused nested vmexit */ |
| 421 | #define NESTED_EXIT_CONTINUE 2 /* Further checks needed */ |
| 422 | |
Joerg Roedel | 01c3b2b | 2020-06-25 10:03:25 +0200 | [diff] [blame] | 423 | static inline bool nested_svm_virtualize_tpr(struct kvm_vcpu *vcpu) |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 424 | { |
Paolo Bonzini | e9fd761 | 2020-05-13 13:28:23 -0400 | [diff] [blame] | 425 | struct vcpu_svm *svm = to_svm(vcpu); |
| 426 | |
| 427 | return is_guest_mode(vcpu) && (svm->nested.ctl.int_ctl & V_INTR_MASKING_MASK); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 428 | } |
| 429 | |
Paolo Bonzini | 55714cd | 2020-04-23 08:17:28 -0400 | [diff] [blame] | 430 | static inline bool nested_exit_on_smi(struct vcpu_svm *svm) |
| 431 | { |
Babu Moger | c62e2e9 | 2020-09-11 14:28:28 -0500 | [diff] [blame] | 432 | return vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_SMI); |
Paolo Bonzini | 55714cd | 2020-04-23 08:17:28 -0400 | [diff] [blame] | 433 | } |
| 434 | |
Paolo Bonzini | fc6f7c0 | 2020-04-23 18:02:45 -0400 | [diff] [blame] | 435 | static inline bool nested_exit_on_intr(struct vcpu_svm *svm) |
| 436 | { |
Babu Moger | c62e2e9 | 2020-09-11 14:28:28 -0500 | [diff] [blame] | 437 | return vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_INTR); |
Paolo Bonzini | fc6f7c0 | 2020-04-23 18:02:45 -0400 | [diff] [blame] | 438 | } |
| 439 | |
Paolo Bonzini | bbdad0b | 2020-04-23 08:06:43 -0400 | [diff] [blame] | 440 | static inline bool nested_exit_on_nmi(struct vcpu_svm *svm) |
| 441 | { |
Babu Moger | c62e2e9 | 2020-09-11 14:28:28 -0500 | [diff] [blame] | 442 | return vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_NMI); |
Paolo Bonzini | bbdad0b | 2020-04-23 08:06:43 -0400 | [diff] [blame] | 443 | } |
| 444 | |
Paolo Bonzini | 6312975 | 2021-03-02 14:40:39 -0500 | [diff] [blame] | 445 | int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb_gpa, struct vmcb *vmcb12); |
Paolo Bonzini | c513f48 | 2020-05-18 13:08:37 -0400 | [diff] [blame] | 446 | void svm_leave_nested(struct vcpu_svm *svm); |
Maxim Levitsky | 2fcf487 | 2020-10-01 14:29:54 +0300 | [diff] [blame] | 447 | void svm_free_nested(struct vcpu_svm *svm); |
| 448 | int svm_allocate_nested(struct vcpu_svm *svm); |
Paolo Bonzini | 6312975 | 2021-03-02 14:40:39 -0500 | [diff] [blame] | 449 | int nested_svm_vmrun(struct kvm_vcpu *vcpu); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 450 | void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb); |
| 451 | int nested_svm_vmexit(struct vcpu_svm *svm); |
Sean Christopherson | 3a87c7e | 2021-03-02 09:45:15 -0800 | [diff] [blame] | 452 | |
| 453 | static inline int nested_svm_simple_vmexit(struct vcpu_svm *svm, u32 exit_code) |
| 454 | { |
| 455 | svm->vmcb->control.exit_code = exit_code; |
| 456 | svm->vmcb->control.exit_info_1 = 0; |
| 457 | svm->vmcb->control.exit_info_2 = 0; |
| 458 | return nested_svm_vmexit(svm); |
| 459 | } |
| 460 | |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 461 | int nested_svm_exit_handled(struct vcpu_svm *svm); |
Paolo Bonzini | 6312975 | 2021-03-02 14:40:39 -0500 | [diff] [blame] | 462 | int nested_svm_check_permissions(struct kvm_vcpu *vcpu); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 463 | int nested_svm_check_exception(struct vcpu_svm *svm, unsigned nr, |
| 464 | bool has_error_code, u32 error_code); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 465 | int nested_svm_exit_special(struct vcpu_svm *svm); |
Paolo Bonzini | 9e8f0fb | 2020-11-17 05:15:41 -0500 | [diff] [blame] | 466 | void nested_sync_control_from_vmcb02(struct vcpu_svm *svm); |
Cathy Avery | 4995a36 | 2021-01-13 07:07:52 -0500 | [diff] [blame] | 467 | void nested_vmcb02_compute_g_pat(struct vcpu_svm *svm); |
| 468 | void svm_switch_vmcb(struct vcpu_svm *svm, struct kvm_vmcb_info *target_vmcb); |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 469 | |
Paolo Bonzini | 33b2217 | 2020-04-17 10:24:18 -0400 | [diff] [blame] | 470 | extern struct kvm_x86_nested_ops svm_nested_ops; |
| 471 | |
Joerg Roedel | ef0f649 | 2020-03-31 12:17:38 -0400 | [diff] [blame] | 472 | /* avic.c */ |
| 473 | |
| 474 | #define AVIC_LOGICAL_ID_ENTRY_GUEST_PHYSICAL_ID_MASK (0xFF) |
| 475 | #define AVIC_LOGICAL_ID_ENTRY_VALID_BIT 31 |
| 476 | #define AVIC_LOGICAL_ID_ENTRY_VALID_MASK (1 << 31) |
| 477 | |
| 478 | #define AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK (0xFFULL) |
| 479 | #define AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK (0xFFFFFFFFFFULL << 12) |
| 480 | #define AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK (1ULL << 62) |
| 481 | #define AVIC_PHYSICAL_ID_ENTRY_VALID_MASK (1ULL << 63) |
| 482 | |
| 483 | #define VMCB_AVIC_APIC_BAR_MASK 0xFFFFFFFFFF000ULL |
| 484 | |
| 485 | extern int avic; |
| 486 | |
| 487 | static inline void avic_update_vapic_bar(struct vcpu_svm *svm, u64 data) |
| 488 | { |
| 489 | svm->vmcb->control.avic_vapic_bar = data & VMCB_AVIC_APIC_BAR_MASK; |
Joerg Roedel | 06e7852 | 2020-06-25 10:03:23 +0200 | [diff] [blame] | 490 | vmcb_mark_dirty(svm->vmcb, VMCB_AVIC); |
Joerg Roedel | ef0f649 | 2020-03-31 12:17:38 -0400 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | static inline bool avic_vcpu_is_running(struct kvm_vcpu *vcpu) |
| 494 | { |
| 495 | struct vcpu_svm *svm = to_svm(vcpu); |
| 496 | u64 *entry = svm->avic_physical_id_cache; |
| 497 | |
| 498 | if (!entry) |
| 499 | return false; |
| 500 | |
| 501 | return (READ_ONCE(*entry) & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK); |
| 502 | } |
| 503 | |
| 504 | int avic_ga_log_notifier(u32 ga_tag); |
| 505 | void avic_vm_destroy(struct kvm *kvm); |
| 506 | int avic_vm_init(struct kvm *kvm); |
| 507 | void avic_init_vmcb(struct vcpu_svm *svm); |
| 508 | void svm_toggle_avic_for_irq_window(struct kvm_vcpu *vcpu, bool activate); |
Paolo Bonzini | 6312975 | 2021-03-02 14:40:39 -0500 | [diff] [blame] | 509 | int avic_incomplete_ipi_interception(struct kvm_vcpu *vcpu); |
| 510 | int avic_unaccelerated_access_interception(struct kvm_vcpu *vcpu); |
Joerg Roedel | ef0f649 | 2020-03-31 12:17:38 -0400 | [diff] [blame] | 511 | int avic_init_vcpu(struct vcpu_svm *svm); |
| 512 | void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu); |
| 513 | void avic_vcpu_put(struct kvm_vcpu *vcpu); |
| 514 | void avic_post_state_restore(struct kvm_vcpu *vcpu); |
| 515 | void svm_set_virtual_apic_mode(struct kvm_vcpu *vcpu); |
| 516 | void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu); |
| 517 | bool svm_check_apicv_inhibit_reasons(ulong bit); |
| 518 | void svm_pre_update_apicv_exec_ctrl(struct kvm *kvm, bool activate); |
| 519 | void svm_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap); |
| 520 | void svm_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr); |
| 521 | void svm_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr); |
| 522 | int svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec); |
| 523 | bool svm_dy_apicv_has_pending_interrupt(struct kvm_vcpu *vcpu); |
| 524 | int svm_update_pi_irte(struct kvm *kvm, unsigned int host_irq, |
| 525 | uint32_t guest_irq, bool set); |
| 526 | void svm_vcpu_blocking(struct kvm_vcpu *vcpu); |
| 527 | void svm_vcpu_unblocking(struct kvm_vcpu *vcpu); |
| 528 | |
Joerg Roedel | eaf7826 | 2020-03-24 10:41:54 +0100 | [diff] [blame] | 529 | /* sev.c */ |
| 530 | |
Tom Lendacky | 1edc145 | 2020-12-10 11:09:49 -0600 | [diff] [blame] | 531 | #define GHCB_VERSION_MAX 1ULL |
| 532 | #define GHCB_VERSION_MIN 1ULL |
| 533 | |
Tom Lendacky | 291bd20 | 2020-12-10 11:09:47 -0600 | [diff] [blame] | 534 | #define GHCB_MSR_INFO_POS 0 |
| 535 | #define GHCB_MSR_INFO_MASK (BIT_ULL(12) - 1) |
| 536 | |
Tom Lendacky | 1edc145 | 2020-12-10 11:09:49 -0600 | [diff] [blame] | 537 | #define GHCB_MSR_SEV_INFO_RESP 0x001 |
| 538 | #define GHCB_MSR_SEV_INFO_REQ 0x002 |
| 539 | #define GHCB_MSR_VER_MAX_POS 48 |
| 540 | #define GHCB_MSR_VER_MAX_MASK 0xffff |
| 541 | #define GHCB_MSR_VER_MIN_POS 32 |
| 542 | #define GHCB_MSR_VER_MIN_MASK 0xffff |
| 543 | #define GHCB_MSR_CBIT_POS 24 |
| 544 | #define GHCB_MSR_CBIT_MASK 0xff |
| 545 | #define GHCB_MSR_SEV_INFO(_max, _min, _cbit) \ |
| 546 | ((((_max) & GHCB_MSR_VER_MAX_MASK) << GHCB_MSR_VER_MAX_POS) | \ |
| 547 | (((_min) & GHCB_MSR_VER_MIN_MASK) << GHCB_MSR_VER_MIN_POS) | \ |
| 548 | (((_cbit) & GHCB_MSR_CBIT_MASK) << GHCB_MSR_CBIT_POS) | \ |
| 549 | GHCB_MSR_SEV_INFO_RESP) |
| 550 | |
Tom Lendacky | d369466 | 2020-12-10 11:09:50 -0600 | [diff] [blame] | 551 | #define GHCB_MSR_CPUID_REQ 0x004 |
| 552 | #define GHCB_MSR_CPUID_RESP 0x005 |
| 553 | #define GHCB_MSR_CPUID_FUNC_POS 32 |
| 554 | #define GHCB_MSR_CPUID_FUNC_MASK 0xffffffff |
| 555 | #define GHCB_MSR_CPUID_VALUE_POS 32 |
| 556 | #define GHCB_MSR_CPUID_VALUE_MASK 0xffffffff |
| 557 | #define GHCB_MSR_CPUID_REG_POS 30 |
| 558 | #define GHCB_MSR_CPUID_REG_MASK 0x3 |
| 559 | |
Tom Lendacky | e1d7111 | 2020-12-10 11:09:51 -0600 | [diff] [blame] | 560 | #define GHCB_MSR_TERM_REQ 0x100 |
| 561 | #define GHCB_MSR_TERM_REASON_SET_POS 12 |
| 562 | #define GHCB_MSR_TERM_REASON_SET_MASK 0xf |
| 563 | #define GHCB_MSR_TERM_REASON_POS 16 |
| 564 | #define GHCB_MSR_TERM_REASON_MASK 0xff |
| 565 | |
Joerg Roedel | eaf7826 | 2020-03-24 10:41:54 +0100 | [diff] [blame] | 566 | extern unsigned int max_sev_asid; |
| 567 | |
Joerg Roedel | eaf7826 | 2020-03-24 10:41:54 +0100 | [diff] [blame] | 568 | static inline bool svm_sev_enabled(void) |
| 569 | { |
| 570 | return IS_ENABLED(CONFIG_KVM_AMD_SEV) ? max_sev_asid : 0; |
| 571 | } |
| 572 | |
| 573 | void sev_vm_destroy(struct kvm *kvm); |
| 574 | int svm_mem_enc_op(struct kvm *kvm, void __user *argp); |
| 575 | int svm_register_enc_region(struct kvm *kvm, |
| 576 | struct kvm_enc_region *range); |
| 577 | int svm_unregister_enc_region(struct kvm *kvm, |
| 578 | struct kvm_enc_region *range); |
| 579 | void pre_sev_run(struct vcpu_svm *svm, int cpu); |
Tom Lendacky | 916391a | 2020-12-10 11:09:38 -0600 | [diff] [blame] | 580 | void __init sev_hardware_setup(void); |
Joerg Roedel | eaf7826 | 2020-03-24 10:41:54 +0100 | [diff] [blame] | 581 | void sev_hardware_teardown(void); |
Tom Lendacky | add5e2f | 2020-12-10 11:09:40 -0600 | [diff] [blame] | 582 | void sev_free_vcpu(struct kvm_vcpu *vcpu); |
Paolo Bonzini | 6312975 | 2021-03-02 14:40:39 -0500 | [diff] [blame] | 583 | int sev_handle_vmgexit(struct kvm_vcpu *vcpu); |
Tom Lendacky | 7ed9abf | 2020-12-10 11:09:54 -0600 | [diff] [blame] | 584 | int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in); |
Tom Lendacky | 376c6d2 | 2020-12-10 11:10:06 -0600 | [diff] [blame] | 585 | void sev_es_init_vmcb(struct vcpu_svm *svm); |
| 586 | void sev_es_create_vcpu(struct vcpu_svm *svm); |
Tom Lendacky | 647daca | 2021-01-04 14:20:01 -0600 | [diff] [blame] | 587 | void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector); |
Michael Roth | a7fc06d | 2021-02-02 13:01:26 -0600 | [diff] [blame] | 588 | void sev_es_prepare_guest_switch(struct vcpu_svm *svm, unsigned int cpu); |
Joerg Roedel | eaf7826 | 2020-03-24 10:41:54 +0100 | [diff] [blame] | 589 | |
Tom Lendacky | 16809ec | 2020-12-10 11:10:08 -0600 | [diff] [blame] | 590 | /* vmenter.S */ |
| 591 | |
| 592 | void __svm_sev_es_vcpu_run(unsigned long vmcb_pa); |
| 593 | void __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs); |
| 594 | |
Joerg Roedel | 883b0a9 | 2020-03-24 10:41:52 +0100 | [diff] [blame] | 595 | #endif |