summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd
diff options
context:
space:
mode:
authorDave Voutila <dv@cvs.openbsd.org>2022-09-01 22:01:41 +0000
committerDave Voutila <dv@cvs.openbsd.org>2022-09-01 22:01:41 +0000
commite78ceda5d5c2eeaa389b71c7c5e150450b0fa9a4 (patch)
tree2eed415aa526c0f7741609cf66ea23856402ea82 /usr.sbin/vmd
parent3784830faf1eccd63cb8ace72001bee59d2ba4e4 (diff)
vmm(4): send all port io emulation to userland
Simplify things by sending any io exits from IN/OUT instructions to userland instead of trying to emulate anything in the kernel. vmm was sending most pertinent exits to vmd anyways, so this functionally changes little. An added benefit is this solves an issue reported by tb@ where i386 OpenBSD guests would probe for a pc keyboard repeatedly and cause excessive vm exits. (The emulation in vmm was not properly handling these port reads.) While here, make the assignment of the VEI_DIR_{IN,OUT} enum values not assume the underlying integer the compiler may assign. ok mlarkin@
Diffstat (limited to 'usr.sbin/vmd')
-rw-r--r--usr.sbin/vmd/i8253.h3
-rw-r--r--usr.sbin/vmd/i8259.h9
-rw-r--r--usr.sbin/vmd/vm.c4
3 files changed, 10 insertions, 6 deletions
diff --git a/usr.sbin/vmd/i8253.h b/usr.sbin/vmd/i8253.h
index e72fbe40bac..569c1a93a6f 100644
--- a/usr.sbin/vmd/i8253.h
+++ b/usr.sbin/vmd/i8253.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i8253.h,v 1.9 2018/04/26 17:10:10 mlarkin Exp $ */
+/* $OpenBSD: i8253.h,v 1.10 2022/09/01 22:01:40 dv Exp $ */
/*
* Copyright (c) 2016 Mike Larkin <mlarkin@openbsd.org>
*
@@ -26,6 +26,7 @@
#define TIMER_RB_C0 0x2 /* read back channel 0 */
#define TIMER_RB_C1 0x4 /* read back channel 1 */
#define TIMER_RB_C2 0x8 /* read back channel 1 */
+#define PCKBC_AUX 0x61 /* PC keyboard aux port for i8253 misc access */
/* i8253 registers */
struct i8253_channel {
diff --git a/usr.sbin/vmd/i8259.h b/usr.sbin/vmd/i8259.h
index ce8a22d5c57..f4b7598692c 100644
--- a/usr.sbin/vmd/i8259.h
+++ b/usr.sbin/vmd/i8259.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i8259.h,v 1.4 2018/04/27 12:15:10 mlarkin Exp $ */
+/* $OpenBSD: i8259.h,v 1.5 2022/09/01 22:01:40 dv Exp $ */
/*
* Copyright (c) 2016 Mike Larkin <mlarkin@openbsd.org>
*
@@ -19,8 +19,11 @@
#include <machine/vmmvar.h>
-#define MASTER 0
-#define SLAVE 1
+#define MASTER 0
+#define SLAVE 1
+
+#define ELCR0 0x4D0
+#define ELCR1 0x4D1
#define ICW1_ICW4 (0x1 << 0)
#define ICW1_SNGL (0x1 << 1)
diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c
index 209814e4bda..8efbdaadb32 100644
--- a/usr.sbin/vmd/vm.c
+++ b/usr.sbin/vmd/vm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm.c,v 1.72 2022/08/30 17:09:21 dv Exp $ */
+/* $OpenBSD: vm.c,v 1.73 2022/09/01 22:01:40 dv Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -1636,7 +1636,7 @@ vcpu_exit_inout(struct vm_run_params *vrp)
if (ioports_map[vei->vei.vei_port] != NULL)
intr = ioports_map[vei->vei.vei_port](vrp);
else if (vei->vei.vei_dir == VEI_DIR_IN)
- set_return_data(vei, 0xFFFFFFFF);
+ set_return_data(vei, 0xFFFFFFFF);
if (intr != 0xFF)
vcpu_assert_pic_irq(vrp->vrp_vm_id, vrp->vrp_vcpu_id, intr);