From: dv Date: Tue, 28 Nov 2023 00:17:48 +0000 (+0000) Subject: Adapt inv{vpid,ept} to return success or failure. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8ff827079faf006fe2172a937767c9bbeec9d2e1;p=openbsd Adapt inv{vpid,ept} to return success or failure. ok mlarkin@ --- diff --git a/sys/arch/amd64/amd64/vmm_support.S b/sys/arch/amd64/amd64/vmm_support.S index 8b4d44bf139..7b7d9f28181 100644 --- a/sys/arch/amd64/amd64/vmm_support.S +++ b/sys/arch/amd64/amd64/vmm_support.S @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm_support.S,v 1.23 2023/04/14 23:56:57 dv Exp $ */ +/* $OpenBSD: vmm_support.S,v 1.24 2023/11/28 00:17:48 dv Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -129,9 +129,19 @@ ENTRY(vmread) lfence END(vmread) +/* + * Intel SDM Vol 3C, 31.2 defines different "vmfail" types, but there's no + * need to distinguish between CF=1 and ZF=1 for invvpid or invept. + */ ENTRY(invvpid) RETGUARD_SETUP(invvpid, r11) invvpid (%rsi), %rdi + jbe invvpid_fail + xorq %rax, %rax + jmp invvpid_ret +invvpid_fail: + movq $1, %rax +invvpid_ret: RETGUARD_CHECK(invvpid, r11) ret lfence @@ -139,7 +149,13 @@ END(invvpid) ENTRY(invept) RETGUARD_SETUP(invept, r11) - invept (%rsi), %rdi + invept (%rsi), %rdi + jbe invept_fail + xorq %rax, %rax + jmp invept_ret +invept_fail: + movq $1, %rax +invept_ret: RETGUARD_CHECK(invept, r11) ret lfence diff --git a/sys/arch/amd64/include/vmmvar.h b/sys/arch/amd64/include/vmmvar.h index fe55eef9613..00471432c3e 100644 --- a/sys/arch/amd64/include/vmmvar.h +++ b/sys/arch/amd64/include/vmmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmmvar.h,v 1.94 2023/09/06 03:35:57 dv Exp $ */ +/* $OpenBSD: vmmvar.h,v 1.95 2023/11/28 00:17:48 dv Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -919,8 +919,8 @@ int vmptrld(paddr_t *); int vmptrst(paddr_t *); int vmwrite(uint64_t, uint64_t); int vmread(uint64_t, uint64_t *); -void invvpid(uint64_t, struct vmx_invvpid_descriptor *); -void invept(uint64_t, struct vmx_invept_descriptor *); +int invvpid(uint64_t, struct vmx_invvpid_descriptor *); +int invept(uint64_t, struct vmx_invept_descriptor *); int vmx_enter_guest(paddr_t *, struct vcpu_gueststate *, int, uint8_t); int svm_enter_guest(uint64_t, struct vcpu_gueststate *, struct region_descriptor *);