Author: neel
Date: Tue Dec 30 23:38:31 2014
New Revision: 276432
URL: https://svnweb.freebsd.org/changeset/base/276432

Log:
  Initialize all fields of 'struct vm_exception exception' before passing it to
  vm_inject_exception(). This fixes the issue that 'exception.cpuid' is
  uninitialized when calling 'vm_inject_exception()'.
  
  However, in practice this change is a no-op because vm_inject_exception()
  does not use 'exception.cpuid' for anything.
  
  Reported by:    Coverity Scan
  CID:            1261297
  MFC after:      3 days

Modified:
  head/sys/amd64/vmm/amd/svm.c

Modified: head/sys/amd64/vmm/amd/svm.c
==============================================================================
--- head/sys/amd64/vmm/amd/svm.c        Tue Dec 30 22:46:20 2014        
(r276431)
+++ head/sys/amd64/vmm/amd/svm.c        Tue Dec 30 23:38:31 2014        
(r276432)
@@ -1322,9 +1322,12 @@ svm_vmexit(struct svm_softc *svm_sc, int
 
                if (reflect) {
                        /* Reflect the exception back into the guest */
+                       bzero(&exception, sizeof(struct vm_exception));
                        exception.vector = idtvec;
-                       exception.error_code_valid = errcode_valid;
-                       exception.error_code = errcode_valid ? info1 : 0;
+                       if (errcode_valid) {
+                               exception.error_code = info1;
+                               exception.error_code_valid = 1;
+                       }
                        VCPU_CTR2(svm_sc->vm, vcpu, "Reflecting exception "
                            "%d/%#x into the guest", exception.vector,
                            exception.error_code);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to