git: c4df8cbfde53 - Remove bvmconsole and bvmdebug.

Robert Wing rew at FreeBSD.org
Wed Dec 23 18:26:58 UTC 2020


The branch main has been updated by rew:

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

commit c4df8cbfde53c376d93f439eac3f45a7b4fc705e
Author:     Robert Wing <rew at FreeBSD.org>
AuthorDate: 2020-12-24 01:15:33 +0000
Commit:     Robert Wing <rew at FreeBSD.org>
CommitDate: 2020-12-24 02:15:23 +0000

    Remove bvmconsole and bvmdebug.
    
    Now that bhyve(8) supports UART, bvmconsole and bvmdebug are no longer needed.
    
    This also removes the '-b' and '-g' flag from bhyve(8). These two flags were
    marked deprecated in r368519.
    
    Reviewed by:    grehan, kevans
    Approved by:    kevans (mentor)
    Differential Revision:  https://reviews.freebsd.org/D27490
---
 sys/conf/files.amd64      |   5 -
 sys/conf/files.i386       |   5 -
 sys/dev/bvm/bvm_console.c | 241 ----------------------------------------------
 sys/dev/bvm/bvm_dbg.c     | 104 --------------------
 usr.sbin/bhyve/Makefile   |   2 -
 usr.sbin/bhyve/bhyve.8    |  21 +---
 usr.sbin/bhyve/bhyverun.c |  28 +-----
 usr.sbin/bhyve/consport.c | 178 ----------------------------------
 usr.sbin/bhyve/dbgport.c  | 178 ----------------------------------
 usr.sbin/bhyve/dbgport.h  |  36 -------
 usr.sbin/bhyve/inout.h    |   1 -
 usr.sbin/bhyve/snapshot.c |   1 -
 12 files changed, 7 insertions(+), 793 deletions(-)

diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 983fea2cb8c2..00b8b8c57ee1 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -444,11 +444,6 @@ compat/ndis/winx64_wrap.S	optional	ndisapi pci
 #
 compat/x86bios/x86bios.c	optional x86bios | dpms | pci | vesa
 contrib/x86emu/x86emu.c		optional x86bios | dpms | pci | vesa
-#
-# bvm console
-#
-dev/bvm/bvm_console.c		optional	bvmconsole
-dev/bvm/bvm_dbg.c		optional	bvmdebug
 # Common files where we currently configure the system differently, but perhaps shouldn't
 # config(8) doesn't have a way to force standard options, so we've been inconsistent
 # about marking non-optional things 'standard'.
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index bae1a8cde184..96d2413b532d 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -226,11 +226,6 @@ libkern/umoddi3.c		standard
 # x86 real mode BIOS support, required by dpms/pci/vesa
 #
 compat/x86bios/x86bios.c	optional x86bios | dpms | pci | vesa
-#
-# bvm console
-#
-dev/bvm/bvm_console.c		optional	bvmconsole
-dev/bvm/bvm_dbg.c		optional	bvmdebug
 # Common files where we currently configure the system differently, but perhaps shouldn't
 # config(8) doesn't have a way to force standard options, so we've been inconsistent
 # about marking non-optional things 'standard'.
diff --git a/sys/dev/bvm/bvm_console.c b/sys/dev/bvm/bvm_console.c
deleted file mode 100644
index c73f462ed84f..000000000000
--- a/sys/dev/bvm/bvm_console.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2011 NetApp, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/types.h>
-#include <sys/cons.h>
-#include <sys/tty.h>
-#include <sys/reboot.h>
-#include <sys/bus.h>
-
-#include <sys/kdb.h>
-#include <ddb/ddb.h>
-
-#ifndef	BVMCONS_POLL_HZ
-#define	BVMCONS_POLL_HZ	4
-#endif
-#define BVMBURSTLEN	16	/* max number of bytes to write in one chunk */
-
-static tsw_open_t bvm_tty_open;
-static tsw_close_t bvm_tty_close;
-static tsw_outwakeup_t bvm_tty_outwakeup;
-
-static struct ttydevsw bvm_ttydevsw = {
-	.tsw_flags	= TF_NOPREFIX,
-	.tsw_open	= bvm_tty_open,
-	.tsw_close	= bvm_tty_close,
-	.tsw_outwakeup	= bvm_tty_outwakeup,
-};
-
-static int			polltime;
-static struct callout		bvm_timer;
-
-#if defined(KDB)
-static int			alt_break_state;
-#endif
-
-#define	BVM_CONS_PORT	0x220
-static int bvm_cons_port = BVM_CONS_PORT;
-
-#define BVM_CONS_SIG	('b' << 8 | 'v')
-
-static void	bvm_timeout(void *);
-
-static cn_probe_t	bvm_cnprobe;
-static cn_init_t	bvm_cninit;
-static cn_term_t	bvm_cnterm;
-static cn_getc_t	bvm_cngetc;
-static cn_putc_t	bvm_cnputc;
-static cn_grab_t 	bvm_cngrab;
-static cn_ungrab_t 	bvm_cnungrab;
-
-CONSOLE_DRIVER(bvm);
-
-static int
-bvm_rcons(u_char *ch)
-{
-	int c;
-
-	c = inl(bvm_cons_port);
-	if (c != -1) {
-		*ch = (u_char)c;
-		return (0);
-	} else
-		return (-1);
-}
-
-static void
-bvm_wcons(u_char ch)
-{
-
-	outl(bvm_cons_port, ch);
-}
-
-static void
-cn_drvinit(void *unused)
-{
-	struct tty *tp;
-    
-	gone_in(13, "bvmconsole");
-
-	if (bvm_consdev.cn_pri != CN_DEAD) {
-		tp = tty_alloc(&bvm_ttydevsw, NULL);
-		callout_init_mtx(&bvm_timer, tty_getlock(tp), 0);
-		tty_makedev(tp, NULL, "bvmcons");
-	}
-}
-
-static int
-bvm_tty_open(struct tty *tp)
-{
-	polltime = hz / BVMCONS_POLL_HZ;
-	if (polltime < 1)
-		polltime = 1;
-	callout_reset(&bvm_timer, polltime, bvm_timeout, tp);
-
-	return (0);
-}
-
-static void
-bvm_tty_close(struct tty *tp)
-{
-
-	tty_assert_locked(tp);
-	callout_stop(&bvm_timer);
-}
-
-static void
-bvm_tty_outwakeup(struct tty *tp)
-{
-	int len, written;
-	u_char buf[BVMBURSTLEN];
-
-	for (;;) {
-		len = ttydisc_getc(tp, buf, sizeof(buf));
-		if (len == 0)
-			break;
-
-		written = 0;
-		while (written < len)
-			bvm_wcons(buf[written++]);
-	}
-}
-
-static void
-bvm_timeout(void *v)
-{
-	struct	tty *tp;
-	int 	c;
-
-	tp = (struct tty *)v;
-
-	tty_assert_locked(tp);
-	while ((c = bvm_cngetc(NULL)) != -1)
-		ttydisc_rint(tp, c, 0);
-	ttydisc_rint_done(tp);
-
-	callout_reset(&bvm_timer, polltime, bvm_timeout, tp);
-}
-
-static void
-bvm_cnprobe(struct consdev *cp)
-{
-	int disabled, port;
-
-	disabled = 0;
-	cp->cn_pri = CN_DEAD;
-	strcpy(cp->cn_name, "bvmcons");
-
-	resource_int_value("bvmconsole", 0, "disabled", &disabled);
-	if (!disabled) {
-		if (resource_int_value("bvmconsole", 0, "port", &port) == 0)
-			bvm_cons_port = port;
-
-		if (inw(bvm_cons_port) == BVM_CONS_SIG)
-			cp->cn_pri = CN_REMOTE;
-	}
-}
-
-static void
-bvm_cninit(struct consdev *cp)
-{
-	int i;
-	const char *bootmsg = "Using bvm console.\n";
-
-	if (boothowto & RB_VERBOSE) {
-		for (i = 0; i < strlen(bootmsg); i++)
-			bvm_cnputc(cp, bootmsg[i]);
-	}
-}
-
-static void
-bvm_cnterm(struct consdev *cp)
-{
-
-}
-
-static int
-bvm_cngetc(struct consdev *cp)
-{
-	unsigned char ch;
-
-	if (bvm_rcons(&ch) == 0) {
-#if defined(KDB)
-		kdb_alt_break(ch, &alt_break_state);
-#endif
-		return (ch);
-	}
-
-	return (-1);
-}
-
-static void
-bvm_cnputc(struct consdev *cp, int c)
-{
-
-	bvm_wcons(c);
-}
-
-static void
-bvm_cngrab(struct consdev *cp)
-{
-}
-
-static void
-bvm_cnungrab(struct consdev *cp)
-{
-}
-
-SYSINIT(cndev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, cn_drvinit, NULL);
diff --git a/sys/dev/bvm/bvm_dbg.c b/sys/dev/bvm/bvm_dbg.c
deleted file mode 100644
index 9aff8c10c8fb..000000000000
--- a/sys/dev/bvm/bvm_dbg.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2011 NetApp, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-
-#include <gdb/gdb.h>
-
-#include <machine/cpufunc.h>
-
-static gdb_probe_f bvm_dbg_probe;
-static gdb_init_f bvm_dbg_init;
-static gdb_term_f bvm_dbg_term;
-static gdb_getc_f bvm_dbg_getc;
-static gdb_putc_f bvm_dbg_putc;
-
-GDB_DBGPORT(bvm, bvm_dbg_probe, bvm_dbg_init, bvm_dbg_term,
-    bvm_dbg_getc, bvm_dbg_putc);
-
-#define	BVM_DBG_PORT	0x224
-static int bvm_dbg_port = BVM_DBG_PORT;
-
-#define BVM_DBG_SIG	('B' << 8 | 'V')
-
-static int
-bvm_dbg_probe(void)
-{
-	int disabled, port;
-
-	disabled = 0;
-	resource_int_value("bvmdbg", 0, "disabled", &disabled);
-
-	gone_in(13, "bvmdebug");
-
-	if (!disabled) {
-		if (resource_int_value("bvmdbg", 0, "port", &port) == 0)
-			bvm_dbg_port = port;
-
-		if (inw(bvm_dbg_port) == BVM_DBG_SIG) {
-			/*
-			 * Return a higher priority than 0 to override other
-			 * gdb dbgport providers that may be present (e.g. uart)
-			 */
-			return (1);
-		}
-	}
-
-	return (-1);
-}
-
-static void
-bvm_dbg_init(void)
-{
-}
-
-static void
-bvm_dbg_term(void)
-{
-}
-
-static void
-bvm_dbg_putc(int c)
-{
-
-	outl(bvm_dbg_port, c);
-}
-
-static int
-bvm_dbg_getc(void)
-{
-
-	return (inl(bvm_dbg_port));
-}
diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile
index b884930d5b03..0233690a5082 100644
--- a/usr.sbin/bhyve/Makefile
+++ b/usr.sbin/bhyve/Makefile
@@ -23,10 +23,8 @@ SRCS=	\
 	block_if.c		\
 	bootrom.c		\
 	console.c		\
-	consport.c		\
 	ctl_util.c		\
 	ctl_scsi_all.c		\
-	dbgport.c		\
 	fwctl.c			\
 	gdb.c			\
 	hda_codec.c		\
diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8
index f93e73e2e1be..a3ea7be0b579 100644
--- a/usr.sbin/bhyve/bhyve.8
+++ b/usr.sbin/bhyve/bhyve.8
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 8, 2020
+.Dd December 23, 2020
 .Dt BHYVE 8
 .Os
 .Sh NAME
@@ -32,7 +32,7 @@
 .Nd "run a guest operating system inside a virtual machine"
 .Sh SYNOPSIS
 .Nm
-.Op Fl AabCDeHhPSuWwxY
+.Op Fl AaCDeHhPSuWwxY
 .Oo
 .Sm off
 .Fl c\~
@@ -46,7 +46,6 @@
 .Oc
 .Sm on
 .Op Fl G Ar port
-.Op Fl g Ar gdbport
 .Oo Fl l
 .Sm off
 .Cm help | Ar lpcdev Op Cm \&, Ar conf
@@ -99,13 +98,6 @@ Generate ACPI tables.
 Required for
 .Fx Ns /amd64
 guests.
-.It Fl b
-Enable a low-level console device supported by
-.Fx
-kernels compiled with
-.Cd "device bvmconsole" .
-This option is deprecated and will be removed in
-.Fx 13.0 .
 .It Fl c Op Ar setting ...
 Number of guest virtual CPUs
 and/or the CPU topology.
@@ -139,15 +131,6 @@ Force
 .Nm
 to exit when a guest issues an access to an I/O port that is not emulated.
 This is intended for debug purposes.
-.It Fl g Ar gdbport
-For
-.Fx
-kernels compiled with
-.Cd "device bvmdebug" ,
-allow a remote kernel kgdb to be relayed to the guest kernel gdb stub
-via a local IPv4 address and this port.
-This option is deprecated and will be removed in
-.Fx 13.0 .
 .It Fl G Ar port
 Start a debug server that uses the GDB protocol to export guest state to a
 debugger.
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index bca5f44c2b40..aafab4af8d8c 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -88,7 +88,6 @@ __FBSDID("$FreeBSD$");
 #include "atkbdc.h"
 #include "bootrom.h"
 #include "inout.h"
-#include "dbgport.h"
 #include "debug.h"
 #include "fwctl.h"
 #include "gdb.h"
@@ -237,9 +236,9 @@ usage(int code)
 {
 
         fprintf(stderr,
-		"Usage: %s [-abehuwxACDHPSWY]\n"
+		"Usage: %s [-aehuwxACDHPSWY]\n"
 		"       %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n"
-		"       %*s [-g <gdb port>] [-l <lpc>]\n"
+		"       %*s [-l <lpc>]\n"
 		"       %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] <vm>\n"
 		"       -a: local apic is in xAPIC mode (deprecated)\n"
 		"       -A: create ACPI tables\n"
@@ -247,7 +246,6 @@ usage(int code)
 		"       -C: include guest memory in core file\n"
 		"       -D: destroy on power-off\n"
 		"       -e: exit on unhandled I/O access\n"
-		"       -g: gdb port\n"
 		"       -h: help\n"
 		"       -H: vmexit from the guest on hlt\n"
 		"       -l: LPC device configuration\n"
@@ -1082,7 +1080,7 @@ spinup_vcpu(struct vmctx *ctx, int vcpu)
 int
 main(int argc, char *argv[])
 {
-	int c, error, dbg_port, err, bvmcons;
+	int c, error, err;
 	int max_vcpus, mptgen, memflags;
 	int rtc_localtime;
 	bool gdb_stop;
@@ -1098,9 +1096,7 @@ main(int argc, char *argv[])
 	restore_file = NULL;
 #endif
 
-	bvmcons = 0;
 	progname = basename(argv[0]);
-	dbg_port = 0;
 	gdb_stop = false;
 	guest_ncpus = 1;
 	sockets = cores = threads = 1;
@@ -1111,9 +1107,9 @@ main(int argc, char *argv[])
 	memflags = 0;
 
 #ifdef BHYVE_SNAPSHOT
-	optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:U:r:";
+	optstr = "aehuwxACDHIPSWYp:G:c:s:m:l:U:r:";
 #else
-	optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:U:";
+	optstr = "aehuwxACDHIPSWYp:G:c:s:m:l:U:";
 #endif
 	while ((c = getopt(argc, argv, optstr)) != -1) {
 		switch (c) {
@@ -1123,10 +1119,6 @@ main(int argc, char *argv[])
 		case 'A':
 			acpi = 1;
 			break;
-		case 'b':
-			warnx("-b flag is deprecated and will be removed in FreeBSD 13.0");
-			bvmcons = 1;
-			break;
 		case 'D':
 			destroy_on_poweroff = 1;
 			break;
@@ -1145,10 +1137,6 @@ main(int argc, char *argv[])
 		case 'C':
 			memflags |= VM_MEM_F_INCORE;
 			break;
-		case 'g':
-			warnx("-g flag is deprecated and will be removed in FreeBSD 13.0");
-			dbg_port = atoi(optarg);
-			break;
 		case 'G':
 			if (optarg[0] == 'w') {
 				gdb_stop = true;
@@ -1323,15 +1311,9 @@ main(int argc, char *argv[])
 	if (acpi)
 		vmgenc_init(ctx);
 
-	if (dbg_port != 0)
-		init_dbgport(dbg_port);
-
 	if (gdb_port != 0)
 		init_gdb(ctx, gdb_port, gdb_stop);
 
-	if (bvmcons)
-		init_bvmcons();
-
 	if (lpc_bootrom()) {
 		if (vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1)) {
 			fprintf(stderr, "ROM boot failed: unrestricted guest "
diff --git a/usr.sbin/bhyve/consport.c b/usr.sbin/bhyve/consport.c
deleted file mode 100644
index 634521985541..000000000000
--- a/usr.sbin/bhyve/consport.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2011 NetApp, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#ifndef WITHOUT_CAPSICUM
-#include <sys/capsicum.h>
-#endif
-#include <sys/select.h>
-
-#ifndef WITHOUT_CAPSICUM
-#include <capsicum_helpers.h>
-#endif
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <termios.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sysexits.h>
-
-#include "inout.h"
-#include "pci_lpc.h"
-#include "debug.h"
-
-#define	BVM_CONSOLE_PORT	0x220
-#define	BVM_CONS_SIG		('b' << 8 | 'v')
-
-static struct termios tio_orig, tio_new;
-
-static void
-ttyclose(void)
-{
-	tcsetattr(STDIN_FILENO, TCSANOW, &tio_orig);
-}
-
-static void
-ttyopen(void)
-{
-	tcgetattr(STDIN_FILENO, &tio_orig);
-
-	cfmakeraw(&tio_new);
-	tcsetattr(STDIN_FILENO, TCSANOW, &tio_new);	
-	raw_stdio = 1;
-
-	atexit(ttyclose);
-}
-
-static bool
-tty_char_available(void)
-{
-	fd_set rfds;
-	struct timeval tv;
-
-	FD_ZERO(&rfds);
-	FD_SET(STDIN_FILENO, &rfds);
-	tv.tv_sec = 0;
-	tv.tv_usec = 0;
-	if (select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv) > 0) {
-		return (true);
-	} else {
-		return (false);
-	}
-}
-
-static int
-ttyread(void)
-{
-	char rb;
-
-	if (tty_char_available()) {
-		read(STDIN_FILENO, &rb, 1);
-		return (rb & 0xff);
-	} else {
-		return (-1);
-	}
-}
-
-static void
-ttywrite(unsigned char wb)
-{
-	(void) write(STDOUT_FILENO, &wb, 1);
-}
-
-static int
-console_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
-		uint32_t *eax, void *arg)
-{
-	static int opened;
-#ifndef WITHOUT_CAPSICUM
-	cap_rights_t rights;
-	cap_ioctl_t cmds[] = { TIOCGETA, TIOCSETA, TIOCGWINSZ };
-#endif
-
-	if (bytes == 2 && in) {
-		*eax = BVM_CONS_SIG;
-		return (0);
-	}
-
-	/*
-	 * Guests might probe this port to look for old ISA devices
-	 * using single-byte reads.  Return 0xff for those.
-	 */
-	if (bytes == 1 && in) {
-		*eax = 0xff;
-		return (0);
-	}
-
-	if (bytes != 4)
-		return (-1);
-
-	if (!opened) {
-#ifndef WITHOUT_CAPSICUM
-		cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ,
-		    CAP_WRITE);
-		if (caph_rights_limit(STDIN_FILENO, &rights) == -1)
-			errx(EX_OSERR, "Unable to apply rights for sandbox");
-		if (caph_ioctls_limit(STDIN_FILENO, cmds, nitems(cmds)) == -1)
-			errx(EX_OSERR, "Unable to apply rights for sandbox");
-#endif
-		ttyopen();
-		opened = 1;
-	}
-	
-	if (in)
-		*eax = ttyread();
-	else
-		ttywrite(*eax);
-
-	return (0);
-}
-
-SYSRES_IO(BVM_CONSOLE_PORT, 4);
-
-static struct inout_port consport = {
-	"bvmcons",
-	BVM_CONSOLE_PORT,
-	1,
-	IOPORT_F_INOUT,
-	console_handler
-};
-
-void
-init_bvmcons(void)
-{
-
-	register_inout(&consport);
-}
diff --git a/usr.sbin/bhyve/dbgport.c b/usr.sbin/bhyve/dbgport.c
deleted file mode 100644
index e0aab7e64ff2..000000000000
--- a/usr.sbin/bhyve/dbgport.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2011 NetApp, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#ifndef WITHOUT_CAPSICUM
-#include <sys/capsicum.h>
-#endif
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <sys/uio.h>
-
-#ifndef WITHOUT_CAPSICUM
-#include <capsicum_helpers.h>
-#endif
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sysexits.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "inout.h"
-#include "dbgport.h"
-#include "pci_lpc.h"
-
-#define	BVM_DBG_PORT	0x224
-#define	BVM_DBG_SIG	('B' << 8 | 'V')
-
-static int listen_fd, conn_fd;
-
-static struct sockaddr_in sin;
-
-static int
-dbg_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
-	    uint32_t *eax, void *arg)
-{
-	int nwritten, nread, printonce;
-	int on = 1;
-	char ch;
-
-	if (bytes == 2 && in) {
-		*eax = BVM_DBG_SIG;
-		return (0);
-	}
-
-	if (bytes != 4)
-		return (-1);
-
-again:
-	printonce = 0;
-	while (conn_fd < 0) {
-		if (!printonce) {
-			printf("Waiting for connection from gdb\r\n");
-			printonce = 1;
-		}
-		conn_fd = accept4(listen_fd, NULL, NULL, SOCK_NONBLOCK);
-		if (conn_fd >= 0) {
-			/* Avoid EPIPE after the client drops off. */
-			(void)setsockopt(conn_fd, SOL_SOCKET, SO_NOSIGPIPE,
-			    &on, sizeof(on));
-			/* Improve latency for one byte at a time tranfers. */
-			(void)setsockopt(conn_fd, IPPROTO_TCP, TCP_NODELAY,
-			    &on, sizeof(on));
-		} else if (errno != EINTR) {
-			perror("accept");
-		}
-	}
-
-	if (in) {
-		nread = read(conn_fd, &ch, 1);
-		if (nread == -1 && errno == EAGAIN)
-			*eax = -1;
-		else if (nread == 1)
-			*eax = ch;
-		else {
-			close(conn_fd);
-			conn_fd = -1;
-			goto again;
-		}
-	} else {
-		ch = *eax;
-		nwritten = write(conn_fd, &ch, 1);
-		if (nwritten != 1) {
-			close(conn_fd);
-			conn_fd = -1;
-			goto again;
-		}
-	}
-	return (0);
-}
-
-static struct inout_port dbgport = {
-	"bvmdbg",
-	BVM_DBG_PORT,
-	1,
-	IOPORT_F_INOUT,
-	dbg_handler
-};
-
-SYSRES_IO(BVM_DBG_PORT, 4);
-
-void
-init_dbgport(int sport)
-{
-	int reuse;
-#ifndef WITHOUT_CAPSICUM
-	cap_rights_t rights;
-#endif
-
-	conn_fd = -1;
-
-	if ((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		perror("cannot create socket");
-		exit(4);
-	}
-
-	sin.sin_len = sizeof(sin);
-	sin.sin_family = AF_INET;
-	sin.sin_addr.s_addr = htonl(INADDR_ANY);
-	sin.sin_port = htons(sport);
-
-	reuse = 1;
-	if (setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &reuse,
-	    sizeof(reuse)) < 0) {
-		perror("cannot set socket options");
-		exit(4);
-	}
-
-	if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
-		perror("cannot bind socket");
-		exit(4);
-	}
-
-	if (listen(listen_fd, 1) < 0) {
-		perror("cannot listen socket");
-		exit(4);
-	}
-
-#ifndef WITHOUT_CAPSICUM
-	cap_rights_init(&rights, CAP_ACCEPT, CAP_READ, CAP_WRITE);
-	if (caph_rights_limit(listen_fd, &rights) == -1)
-		errx(EX_OSERR, "Unable to apply rights for sandbox");
-#endif
-
-	register_inout(&dbgport);
-}
diff --git a/usr.sbin/bhyve/dbgport.h b/usr.sbin/bhyve/dbgport.h
deleted file mode 100644
index 407ff3ffbf5f..000000000000
--- a/usr.sbin/bhyve/dbgport.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2011 NetApp, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
*** 46 LINES SKIPPED ***


More information about the dev-commits-src-all mailing list