summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd
diff options
context:
space:
mode:
authorMike Larkin <mlarkin@cvs.openbsd.org>2018-10-03 20:13:34 +0000
committerMike Larkin <mlarkin@cvs.openbsd.org>2018-10-03 20:13:34 +0000
commit8b7f24c8403dfe7a11c92bd9e3b75a078f96221a (patch)
tree8cc1fd415f5f1536bc77a62b583804467a553c04 /usr.sbin/vmd
parent38b2b09d5f6907d19f28aec8950c097186cb0486 (diff)
vmd(8): avoid a divide by zero when the user specified a low baud rate
Low baud rates would result in a 0 "rate limiter pause count" in the serial port output code. This pause counter is used to implement a delay in what otherwise is an instantaneous serial port output path, and is needed by some guest OS kernels. This fix only enables the rate limiter pause if the count is > 0 ("pause after 0 characters" makes no sense anyway). Note that this will result in skipping the limiter on unusually low baud rates, but since nobody is using a low baud rate console in vmd, I don't think this is going to be a problem. ok pd
Diffstat (limited to 'usr.sbin/vmd')
-rw-r--r--usr.sbin/vmd/ns8250.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/vmd/ns8250.c b/usr.sbin/vmd/ns8250.c
index 74e86a92954..cf1f4240a54 100644
--- a/usr.sbin/vmd/ns8250.c
+++ b/usr.sbin/vmd/ns8250.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ns8250.c,v 1.17 2018/07/12 10:15:44 mlarkin Exp $ */
+/* $OpenBSD: ns8250.c,v 1.18 2018/10/03 20:13:33 mlarkin Exp $ */
/*
* Copyright (c) 2016 Mike Larkin <mlarkin@openbsd.org>
*
@@ -237,8 +237,9 @@ vcpu_process_com_data(struct vm_exit *vei, uint32_t vm_id, uint32_t vcpu_id)
if (com1_dev.regs.ier & IER_ETXRDY) {
/* Limit output rate if needed */
- if (com1_dev.byte_out % com1_dev.pause_ct == 0) {
- evtimer_add(&com1_dev.rate, &com1_dev.rate_tv);
+ if (com1_dev.pause_ct > 0) {
+ if (com1_dev.byte_out % com1_dev.pause_ct == 0)
+ evtimer_add(&com1_dev.rate, &com1_dev.rate_tv);
} else {
/* Set TXRDY and clear "no pending interrupt" */
com1_dev.regs.iir |= IIR_TXRDY;