Return 0 on read from PIT control port. Intel explicitly says this is not
authormlarkin <mlarkin@openbsd.org>
Fri, 8 Jul 2016 06:35:12 +0000 (06:35 +0000)
committermlarkin <mlarkin@openbsd.org>
Fri, 8 Jul 2016 06:35:12 +0000 (06:35 +0000)
supported, and it looks like other emulators/hypervisors do a variety of
different things here. Most return 0, but at least one might return random
garbage. Returning 0 seems safest here, but leave a warning in place for
the logs in case a guest VM does this.

usr.sbin/vmd/vmm.c

index f8f37a2..b863a87 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vmm.c,v 1.30 2016/07/07 00:58:31 mlarkin Exp $        */
+/*     $OpenBSD: vmm.c,v 1.31 2016/07/08 06:35:12 mlarkin Exp $        */
 
 /*
  * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -1088,9 +1088,9 @@ vcpu_exit_i8253(struct vm_run_params *vrp)
 
                        goto ret;
                } else {
-                       /* XXX should this return 0xff as the data read? */
                        log_warnx("%s: i8253 PIT: read from control "
-                           "port unsupported", __progname);
+                           "port unsupported - returning 0", __progname);
+                       vei->vei.vei_data = 0;
                }
        } else {
                sel = vei->vei.vei_port - (TIMER_CNTR0 + TIMER_BASE);