git: 4eadbef92493 - main - vmm: emulate INVD by ignoring it

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Wed, 27 Jul 2022 16:21:26 UTC
The branch main has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=4eadbef92493ea8d375207b2c2a0bd3a22603750

commit 4eadbef92493ea8d375207b2c2a0bd3a22603750
Author:     Corvin Köhne <CorvinK@beckhoff.com>
AuthorDate: 2022-07-27 14:39:47 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-07-27 16:20:47 +0000

    vmm: emulate INVD by ignoring it
    
    On physical systems the ram isn't initialized on boot. So, coreboot uses
    the cache as ram in this boot phase. When exiting cache as ram, coreboot
    calls INVD for making the cache consistent.
    
    In a virtual environment ram is always initialized and the cache is
    always consistent. So, we can safely ignore this call.
    
    Reviewed by:    jhb, imp
    Differential Revision:  https://reviews.freebsd.org/D35620
    Sponsored by:   Beckhoff Automation GmbH & Co. KG
---
 sys/amd64/vmm/amd/svm.c   | 4 ++--
 sys/amd64/vmm/intel/vmx.c | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c
index 91e747774b24..35e8d9833d0e 100644
--- a/sys/amd64/vmm/amd/svm.c
+++ b/sys/amd64/vmm/amd/svm.c
@@ -1551,13 +1551,13 @@ svm_vmexit(struct svm_softc *svm_sc, int vcpu, struct vm_exit *vmexit)
 	case VMCB_EXIT_CLGI:
 	case VMCB_EXIT_SKINIT:
 	case VMCB_EXIT_ICEBP:
-	case VMCB_EXIT_INVD:
 	case VMCB_EXIT_INVLPGA:
 		vm_inject_ud(svm_sc->vm, vcpu);
 		handled = 1;
 		break;
+	case VMCB_EXIT_INVD:
 	case VMCB_EXIT_WBINVD:
-		/* ignore WBINVD */
+		/* ignore exit */
 		handled = 1;
 		break;
 	default:
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c
index f1aea1d2a9db..64544a6e7955 100644
--- a/sys/amd64/vmm/intel/vmx.c
+++ b/sys/amd64/vmm/intel/vmx.c
@@ -2790,8 +2790,9 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit)
 		SDT_PROBE3(vmm, vmx, exit, vminsn, vmx, vcpu, vmexit);
 		vmexit->exitcode = VM_EXITCODE_VMINSN;
 		break;
+	case EXIT_REASON_INVD:
 	case EXIT_REASON_WBINVD:
-		/* ignore WBINVD */
+		/* ignore exit */
 		handled = HANDLED;
 		break;
 	default: