Lines Matching +full:gpa +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0
14 bool __read_mostly enable_sgx = 1;
30 /* Skip vmcs.GUEST_DS retrieval for 64-bit mode to avoid VMREADs. */ in sgx_get_encls_gva()
47 (((u64)*gva + size - 1) > s.limit + 1)); in sgx_get_encls_gva()
51 return fault ? -EINVAL : 0; in sgx_get_encls_gva()
67 return -EFAULT; in sgx_read_hva()
74 gpa_t *gpa) in sgx_gva_to_gpa() argument
79 *gpa = kvm_mmu_gva_to_gpa_write(vcpu, gva, &ex); in sgx_gva_to_gpa()
81 *gpa = kvm_mmu_gva_to_gpa_read(vcpu, gva, &ex); in sgx_gva_to_gpa()
83 if (*gpa == INVALID_GPA) { in sgx_gva_to_gpa()
85 return -EFAULT; in sgx_gva_to_gpa()
91 static int sgx_gpa_to_hva(struct kvm_vcpu *vcpu, gpa_t gpa, unsigned long *hva) in sgx_gpa_to_hva() argument
93 *hva = kvm_vcpu_gfn_to_hva(vcpu, PFN_DOWN(gpa)); in sgx_gpa_to_hva()
95 sgx_handle_emulation_failure(vcpu, gpa, 1); in sgx_gpa_to_hva()
96 return -EFAULT; in sgx_gpa_to_hva()
99 *hva |= gpa & ~PAGE_MASK; in sgx_gpa_to_hva()
109 * A non-EPCM #PF indicates a bad userspace HVA. This *should* check in sgx_inject_fault()
137 return 1; in sgx_inject_fault()
145 struct sgx_secs *contents = (struct sgx_secs *)pageinfo->contents; in __handle_encls_ecreate()
153 sgx_12_1 = kvm_find_cpuid_entry_index(vcpu, 0x12, 1); in __handle_encls_ecreate()
159 miscselect = contents->miscselect; in __handle_encls_ecreate()
160 attributes = contents->attributes; in __handle_encls_ecreate()
161 xfrm = contents->xfrm; in __handle_encls_ecreate()
162 size = contents->size; in __handle_encls_ecreate()
165 if (!vcpu->kvm->arch.sgx_provisioning_allowed && in __handle_encls_ecreate()
167 if (sgx_12_1->eax & SGX_ATTR_PROVISIONKEY) in __handle_encls_ecreate()
170 return 1; in __handle_encls_ecreate()
179 if ((u32)miscselect & ~sgx_12_0->ebx || in __handle_encls_ecreate()
180 (u32)attributes & ~sgx_12_1->eax || in __handle_encls_ecreate()
181 (u32)(attributes >> 32) & ~sgx_12_1->ebx || in __handle_encls_ecreate()
182 (u32)xfrm & ~sgx_12_1->ecx || in __handle_encls_ecreate()
183 (u32)(xfrm >> 32) & ~sgx_12_1->edx || in __handle_encls_ecreate()
184 xfrm & ~(vcpu->arch.guest_supported_xcr0 | XFEATURE_MASK_FPSSE) || in __handle_encls_ecreate()
187 return 1; in __handle_encls_ecreate()
191 max_size_log2 = (attributes & SGX_ATTR_MODE64BIT) ? sgx_12_0->edx >> 8 : in __handle_encls_ecreate()
192 sgx_12_0->edx; in __handle_encls_ecreate()
195 return 1; in __handle_encls_ecreate()
200 * 1) 0: ECREATE was successful in __handle_encls_ecreate()
201 * 2) -EFAULT: ECREATE was run but faulted, and trapnr was set to the in __handle_encls_ecreate()
203 * 3) -EINVAL: access_ok() on @secs_hva failed. This should never in __handle_encls_ecreate()
210 if (ret == -EFAULT) in __handle_encls_ecreate()
229 return 1; in handle_encls_ecreate()
239 return 1; in handle_encls_ecreate()
249 return 1; in handle_encls_ecreate()
252 * Translate the SECINFO, SOURCE and SECS pointers from GVA to GPA. in handle_encls_ecreate()
258 return 1; in handle_encls_ecreate()
263 * userspace if a GPA is invalid. in handle_encls_ecreate()
278 return -ENOMEM; in handle_encls_ecreate()
307 return 1; in handle_encls_einit()
310 * Translate the SIGSTRUCT, SECS and TOKEN pointers from GVA to GPA. in handle_encls_einit()
316 return 1; in handle_encls_einit()
321 * userspace if a GPA is invalid. Note, all structures are aligned and in handle_encls_einit()
331 vmx->msr_ia32_sgxlepubkeyhash, &trapnr); in handle_encls_einit()
333 if (ret == -EFAULT) in handle_encls_einit()
337 * sgx_virt_einit() returns -EINVAL when access_ok() fails on @sig_hva, in handle_encls_einit()
377 return (to_vmx(vcpu)->msr_ia32_feature_control & bits) == bits; in sgx_enabled_in_guest_bios()
395 WARN_ONCE(1, "unexpected exit on ENCLS[%u]", leaf); in handle_encls()
396 vcpu->run->exit_reason = KVM_EXIT_UNKNOWN; in handle_encls()
397 vcpu->run->hw.hardware_exit_reason = EXIT_REASON_ENCLS; in handle_encls()
400 return 1; in handle_encls()
411 * MSRs exist but are read-only (locked and not writable). in setup_default_sgx_lepubkeyhash()
416 sgx_pubkey_hash[1] = 0x6cfbe8ba8b3b413dULL; in setup_default_sgx_lepubkeyhash()
421 rdmsrl(MSR_IA32_SGXLEPUBKEYHASH1, sgx_pubkey_hash[1]); in setup_default_sgx_lepubkeyhash()
431 memcpy(vmx->msr_ia32_sgxlepubkeyhash, sgx_pubkey_hash, in vcpu_setup_sgx_lepubkeyhash()
437 * restrictions if the guest's allowed-1 settings diverge from hardware.
444 if (!vcpu->kvm->arch.sgx_provisioning_allowed) in sgx_intercept_encls_ecreate()
452 if (guest_cpuid->ebx != ebx || guest_cpuid->edx != edx) in sgx_intercept_encls_ecreate()
455 guest_cpuid = kvm_find_cpuid_entry_index(vcpu, 0x12, 1); in sgx_intercept_encls_ecreate()
459 cpuid_count(0x12, 1, &eax, &ebx, &ecx, &edx); in sgx_intercept_encls_ecreate()
460 if (guest_cpuid->eax != eax || guest_cpuid->ebx != ebx || in sgx_intercept_encls_ecreate()
461 guest_cpuid->ecx != ecx || guest_cpuid->edx != edx) in sgx_intercept_encls_ecreate()
476 u64 bitmap = -1ull; in vmx_write_encls_bitmap()
487 bitmap |= (1 << ECREATE); in vmx_write_encls_bitmap()
497 * The MSRs are not loaded/saved on VM-Enter/VM-Exit as writing in vmx_write_encls_bitmap()
501 bitmap |= (1 << EINIT); in vmx_write_encls_bitmap()
506 bitmap |= vmcs12->encls_exiting_bitmap; in vmx_write_encls_bitmap()