CVS commit: [netbsd-7] src/sys/arch/xen/xen

2020-03-16 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Mon Mar 16 12:08:37 UTC 2020

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: xennet_checksum.c

Log Message:
Pull up the following revisions(s) (requested by jdolecek in ticket #1726):
sys/arch/xen/xen/xennet_checksum.c: revision 1.4

Make the packet length check less strict, allow the physical packet longer
than IP payload. This fixes problem where checksum was not recomputed for
short packets coming from Windows domU on same physical host as it seems
Windows does some padding.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.80.1 src/sys/arch/xen/xen/xennet_checksum.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2020-03-16 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Mon Mar 16 12:08:37 UTC 2020

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: xennet_checksum.c

Log Message:
Pull up the following revisions(s) (requested by jdolecek in ticket #1726):
sys/arch/xen/xen/xennet_checksum.c: revision 1.4

Make the packet length check less strict, allow the physical packet longer
than IP payload. This fixes problem where checksum was not recomputed for
short packets coming from Windows domU on same physical host as it seems
Windows does some padding.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.80.1 src/sys/arch/xen/xen/xennet_checksum.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/xennet_checksum.c
diff -u src/sys/arch/xen/xen/xennet_checksum.c:1.3 src/sys/arch/xen/xen/xennet_checksum.c:1.3.80.1
--- src/sys/arch/xen/xen/xennet_checksum.c:1.3	Thu Nov 22 16:17:10 2007
+++ src/sys/arch/xen/xen/xennet_checksum.c	Mon Mar 16 12:08:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xennet_checksum.c,v 1.3 2007/11/22 16:17:10 bouyer Exp $	*/
+/*	$NetBSD: xennet_checksum.c,v 1.3.80.1 2020/03/16 12:08:37 sborrill Exp $	*/
 
 /*-
  * Copyright (c)2006 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.3 2007/11/22 16:17:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.3.80.1 2020/03/16 12:08:37 sborrill Exp $");
 
 #include 
 #include 
@@ -124,7 +124,7 @@ xennet_checksum_fill(struct mbuf **mp)
 	nxt = iph->ip_p;
 	iphlen = iph->ip_hl * 4;
 	iplen = ntohs(iph->ip_len);
-	if (ehlen + iplen != m->m_pkthdr.len) {
+	if (ehlen + iplen > m->m_pkthdr.len) {
 		return EINVAL;
 	}
 	if (nxt == IPPROTO_UDP) {



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2017-03-26 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Mar 26 16:08:12 UTC 2017

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: if_xennet_xenbus.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1379):
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.70 via patch
Try to be smarted in the rx path: if the packet is small enough copy the
data to the mbuf's data area instead of allocating a new page from the pool.
While there fix a struct xennet_rxreq leak if xennet_checksum_fill()
fails with ENOMEM.


To generate a diff of this commit:
cvs rdiff -u -r1.63.2.1 -r1.63.2.2 src/sys/arch/xen/xen/if_xennet_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.63.2.1 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.63.2.2
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.63.2.1	Sun Mar  6 18:52:06 2016
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Sun Mar 26 16:08:12 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.63.2.1 2016/03/06 18:52:06 martin Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.63.2.2 2017/03/26 16:08:12 snj Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.63.2.1 2016/03/06 18:52:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.63.2.2 2017/03/26 16:08:12 snj Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -1073,26 +1073,35 @@ again:
 		MCLAIM(m, >sc_ethercom.ec_rx_mowner);
 
 		m->m_pkthdr.rcvif = ifp;
-		req->rxreq_va = (vaddr_t)pool_cache_get_paddr(
-		if_xennetrxbuf_cache, PR_NOWAIT, >rxreq_pa);
-		if (__predict_false(req->rxreq_va == 0)) {
-			printf("%s: rx no buf\n", ifp->if_xname);
-			ifp->if_ierrors++;
-			req->rxreq_va = va;
-			req->rxreq_pa = pa;
-			xennet_rx_free_req(req);
-			m_freem(m);
-			continue;
+		if (rx->status <= MHLEN) {
+			/* small packet; copy to mbuf data area */
+			m_copyback(m, 0, rx->status, pktp);
+			KASSERT(m->m_pkthdr.len == rx->status);
+			KASSERT(m->m_len == rx->status);
+		} else {
+			/* large packet; attach buffer to mbuf */
+			req->rxreq_va = (vaddr_t)pool_cache_get_paddr(
+			if_xennetrxbuf_cache, PR_NOWAIT, >rxreq_pa);
+			if (__predict_false(req->rxreq_va == 0)) {
+printf("%s: rx no buf\n", ifp->if_xname);
+ifp->if_ierrors++;
+req->rxreq_va = va;
+req->rxreq_pa = pa;
+xennet_rx_free_req(req);
+m_freem(m);
+continue;
+			}
+			m->m_len = m->m_pkthdr.len = rx->status;
+			MEXTADD(m, pktp, rx->status,
+			M_DEVBUF, xennet_rx_mbuf_free, NULL);
+			m->m_ext.ext_paddr = pa;
+			m->m_flags |= M_EXT_RW; /* we own the buffer */
 		}
-		m->m_len = m->m_pkthdr.len = rx->status;
-		MEXTADD(m, pktp, rx->status,
-		M_DEVBUF, xennet_rx_mbuf_free, NULL);
-		m->m_flags |= M_EXT_RW; /* we own the buffer */
-		m->m_ext.ext_paddr = pa;
 		if ((rx->flags & NETRXF_csum_blank) != 0) {
 			xennet_checksum_fill();
 			if (m == NULL) {
 ifp->if_ierrors++;
+xennet_rx_free_req(req);
 continue;
 			}
 		}



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2017-03-07 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Mar  7 20:26:12 UTC 2017

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: hypervisor.c

Log Message:
Pull up following revision(s) (requested by jnmeth in ticket #1328):
sys/arch/xen/xen/hypervisor.c: revision 1.67
add machdep.xen.version sysctl to easily get hypervisor version


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.65.4.1 src/sys/arch/xen/xen/hypervisor.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.65 src/sys/arch/xen/xen/hypervisor.c:1.65.4.1
--- src/sys/arch/xen/xen/hypervisor.c:1.65	Sat Feb  1 20:07:07 2014
+++ src/sys/arch/xen/xen/hypervisor.c	Tue Mar  7 20:26:12 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.65 2014/02/01 20:07:07 bouyer Exp $ */
+/* $NetBSD: hypervisor.c,v 1.65.4.1 2017/03/07 20:26:12 snj Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -53,12 +53,13 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.65 2014/02/01 20:07:07 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.65.4.1 2017/03/07 20:26:12 snj Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "xenbus.h"
 #include "xencons.h"
@@ -203,14 +204,32 @@ hypervisor_attach(device_t parent, devic
 #endif /* NPCI */
 	union hypervisor_attach_cookie hac;
 	char xen_extra_version[XEN_EXTRAVERSION_LEN];
+	static char xen_version_string[20];
+	int rc;
+	const struct sysctlnode *node = NULL;
 
 	xenkernfs_init();
 
 	xen_version = HYPERVISOR_xen_version(XENVER_version, NULL);
 	memset(xen_extra_version, 0, sizeof(xen_extra_version));
 	HYPERVISOR_xen_version(XENVER_extraversion, xen_extra_version);
-	aprint_normal(": Xen version %d.%d%s\n", XEN_MAJOR(xen_version),
+	rc = snprintf(xen_version_string, 20, "%d.%d%s", XEN_MAJOR(xen_version),
 		XEN_MINOR(xen_version), xen_extra_version);
+	aprint_normal(": Xen version %s\n", xen_version_string);
+	if (rc >= 20)
+		aprint_debug(": xen_version_string truncated\n");
+
+	sysctl_createv(NULL, 0, NULL, , 0,
+	CTLTYPE_NODE, "xen",
+	SYSCTL_DESCR("Xen top level node"),
+	NULL, 0, NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+
+	if (node != NULL) {
+		sysctl_createv(NULL, 0, , NULL, CTLFLAG_READONLY,
+		CTLTYPE_STRING, "version",
+		SYSCTL_DESCR("Xen hypervisor version"),
+		NULL, 0, xen_version_string, 0, CTL_CREATE, CTL_EOL);
+	}
 
 	xengnt_init();
 	events_init();



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2017-03-07 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Mar  7 20:26:12 UTC 2017

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: hypervisor.c

Log Message:
Pull up following revision(s) (requested by jnmeth in ticket #1328):
sys/arch/xen/xen/hypervisor.c: revision 1.67
add machdep.xen.version sysctl to easily get hypervisor version


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.65.4.1 src/sys/arch/xen/xen/hypervisor.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2016-03-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  6 18:52:07 UTC 2016

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: if_xennet_xenbus.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1125):
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.67
In xennet_xenbus_detach(), remove the event handler early (just after
xennet_stop()) so that we don't get events while slepping (e.g.
in softint_disestablish()) when some structures have already been
freed.
Problem reported and patch tested by Rohan Desai.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.63.2.1 src/sys/arch/xen/xen/if_xennet_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.63 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.63.2.1
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.63	Sun Aug 10 16:44:35 2014
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Sun Mar  6 18:52:06 2016
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.63 2014/08/10 16:44:35 tls Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.63.2.1 2016/03/06 18:52:06 martin Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.63 2014/08/10 16:44:35 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.63.2.1 2016/03/06 18:52:06 martin Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -421,6 +421,7 @@ xennet_xenbus_detach(device_t self, int 
 	DPRINTF(("%s: xennet_xenbus_detach\n", device_xname(self)));
 	s0 = splnet();
 	xennet_stop(ifp, 1);
+	event_remove_handler(sc->sc_evtchn, _handler, sc);
 	/* wait for pending TX to complete, and collect pending RX packets */
 	xennet_handler(sc);
 	while (sc->sc_tx_ring.sring->rsp_prod != sc->sc_tx_ring.rsp_cons) {
@@ -456,7 +457,6 @@ xennet_xenbus_detach(device_t self, int 
 	uvm_km_free(kernel_map, (vaddr_t)sc->sc_rx_ring.sring, PAGE_SIZE,
 	UVM_KMF_WIRED);
 	softint_disestablish(sc->sc_softintr);
-	event_remove_handler(sc->sc_evtchn, _handler, sc);
 	splx(s0);
 
 	pmf_device_deregister(self);



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2016-03-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  6 18:52:07 UTC 2016

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: if_xennet_xenbus.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1125):
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.67
In xennet_xenbus_detach(), remove the event handler early (just after
xennet_stop()) so that we don't get events while slepping (e.g.
in softint_disestablish()) when some structures have already been
freed.
Problem reported and patch tested by Rohan Desai.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.63.2.1 src/sys/arch/xen/xen/if_xennet_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2015-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 16 07:34:08 UTC 2015

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: xbdback_xenbus.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1040):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.61
Fix typo which caused the kenrel thread to be created with a 0 priority.
This would cause the thread to be almost never scheduled when a userland
process could use all CPU.
Should fix the problem reported by Torbj?rn Granlund on port-xen@


To generate a diff of this commit:
cvs rdiff -u -r1.59.4.1 -r1.59.4.2 src/sys/arch/xen/xen/xbdback_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.59.4.1 src/sys/arch/xen/xen/xbdback_xenbus.c:1.59.4.2
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.59.4.1	Mon Sep 22 11:15:57 2014
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Mon Nov 16 07:34:08 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.59.4.1 2014/09/22 11:15:57 martin Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.59.4.2 2015/11/16 07:34:08 msaitoh Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.59.4.1 2014/09/22 11:15:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.59.4.2 2015/11/16 07:34:08 msaitoh Exp $");
 
 #include 
 #include 
@@ -647,7 +647,7 @@ xbdback_connect(struct xbdback_instance 
 	hypervisor_enable_event(xbdi->xbdi_evtchn);
 	hypervisor_notify_via_evtchn(xbdi->xbdi_evtchn);
 
-	if (kthread_create(IPL_NONE, KTHREAD_MPSAFE, NULL,
+	if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
 	xbdback_thread, xbdi, NULL, "%s", xbdi->xbdi_name) == 0)
 		return 0;
 



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2015-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 16 07:34:08 UTC 2015

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: xbdback_xenbus.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1040):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.61
Fix typo which caused the kenrel thread to be created with a 0 priority.
This would cause the thread to be almost never scheduled when a userland
process could use all CPU.
Should fix the problem reported by Torbj?rn Granlund on port-xen@


To generate a diff of this commit:
cvs rdiff -u -r1.59.4.1 -r1.59.4.2 src/sys/arch/xen/xen/xbdback_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2015-05-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May 22 16:56:45 UTC 2015

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: xenevt.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #796):
sys/arch/xen/xen/xenevt.c: revision 1.42
Fix off by one error, pointed out by Wei Liu in port-xen/49919


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/arch/xen/xen/xenevt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/xenevt.c
diff -u src/sys/arch/xen/xen/xenevt.c:1.41 src/sys/arch/xen/xen/xenevt.c:1.41.2.1
--- src/sys/arch/xen/xen/xenevt.c:1.41	Fri Jul 25 08:10:35 2014
+++ src/sys/arch/xen/xen/xenevt.c	Fri May 22 16:56:45 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: xenevt.c,v 1.41 2014/07/25 08:10:35 dholland Exp $  */
+/*  $NetBSD: xenevt.c,v 1.41.2.1 2015/05/22 16:56:45 snj Exp $  */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xenevt.c,v 1.41 2014/07/25 08:10:35 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: xenevt.c,v 1.41.2.1 2015/05/22 16:56:45 snj Exp $);
 
 #include opt_xen.h
 #include sys/param.h
@@ -489,7 +489,7 @@ xenevt_fwrite(struct file *fp, off_t *of
 	if (uio-uio_resid == 0)
 		return (0);
 	nentries = uio-uio_resid / sizeof(uint16_t);
-	if (nentries  NR_EVENT_CHANNELS)
+	if (nentries = NR_EVENT_CHANNELS)
 		return EMSGSIZE;
 	chans = kmem_alloc(nentries * sizeof(uint16_t), KM_SLEEP);
 	if (chans == NULL)
@@ -582,7 +582,7 @@ xenevt_fioctl(struct file *fp, u_long cm
 	{
 		struct ioctl_evtchn_unbind *unbind = addr;
 		
-		if (unbind-port  NR_EVENT_CHANNELS)
+		if (unbind-port = NR_EVENT_CHANNELS)
 			return EINVAL;
 		mutex_enter(devevent_lock);
 		if (devevent[unbind-port] != d) {
@@ -603,7 +603,7 @@ xenevt_fioctl(struct file *fp, u_long cm
 	{
 		struct ioctl_evtchn_notify *notify = addr;
 		
-		if (notify-port  NR_EVENT_CHANNELS)
+		if (notify-port = NR_EVENT_CHANNELS)
 			return EINVAL;
 		mutex_enter(devevent_lock);
 		if (devevent[notify-port] != d) {



CVS commit: [netbsd-7] src/sys/arch/xen/xen

2015-05-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May 22 16:56:45 UTC 2015

Modified Files:
src/sys/arch/xen/xen [netbsd-7]: xenevt.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #796):
sys/arch/xen/xen/xenevt.c: revision 1.42
Fix off by one error, pointed out by Wei Liu in port-xen/49919


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/arch/xen/xen/xenevt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.