NetBSD Problem Report #46407

From Wolfgang.Stukenbrock@nagler-company.com  Fri May  4 08:27:56 2012
Return-Path: <Wolfgang.Stukenbrock@nagler-company.com>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 766EC63B915
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  4 May 2012 08:27:56 +0000 (UTC)
Message-Id: <20120504082805.4A0331E80A9@test-s0.nagler-company.com>
Date: Fri,  4 May 2012 10:28:05 +0200 (CEST)
From: Wolfgang.Stukenbrock@nagler-company.com
Reply-To: Wolfgang.Stukenbrock@nagler-company.com
To: gnats-bugs@gnats.NetBSD.org
Subject: iavc driver and i4b parts does not compile an amd64 - 64-bit-Problem
X-Send-Pr-Version: 3.95

>Number:         46407
>Category:       kern
>Synopsis:       iavc driver and i4b parts does not compile an amd64 - 64-bit-Problem
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 04 08:30:01 +0000 2012
>Closed-Date:    Sat Sep 22 11:57:58 +0000 2018
>Last-Modified:  Sat Sep 22 11:57:58 +0000 2018
>Originator:     Wolfgang.Stukenbrock@nagler-company.com
>Release:        NetBSD 5.1.2
>Organization:
Dr. Nagler & Company GmbH
>Environment:


System: NetBSD test-s0 4.0 NetBSD 4.0 (NSW-WS) #0: Tue Aug 17 17:28:09 CEST 2010 wgstuken@test-s0:/usr/src/sys/arch/amd64/compile/NSW-WS amd64
Architecture: x86_64
Machine: amd64
>Description:
	Some 32/64 bit integer/pointer problems in the source of
	i4b and the iavc driver are the reason.
	Theese are easy to fix and get it compiling again - see below.
	It should run on machines with less than 4GB memory.
	(Still not fully tested - sorry. The system comes up and the card
	gets initialized.)

	Accedently the capi-interface uses only 32-Bit values as data pointers.
	So the driver has to enshure that the pointer will fit.
	I've added a KASSERT() that will check at least the pointer (not the
	length ...) for now.

	During sending data to the interface the routine cap_data_b3_req()
	from netisdn/i4b_capi_msgs.c is called by capi_start_tx() from
	netisdn/i4b_capi_l4if.c. There is a loop over all queued mbuf's.
	This seems to be the output interface of the driver and I do not
	know where theese mbufs are allocated and if it is garantied that
	the memory is in the lower 32-bit region.
	If not the contents must be copied to some fresh allocated buffers
	in the correct region and used instead of the orignal ones.

	If the maintainer of the iavc driver or the i4b-stuff can have a look
	at this, it would be nice.
	Thanks in advance.

>How-To-Repeat:
	Try to compile the iavc (and isic) drivers on amd64. It will not work.
>Fix:
	The following patches will get it compiling again.

===================================================================
--- netisdn/i4b_capi.h  2012/05/02 14:47:44     1.1
+++ netisdn/i4b_capi.h  2012/05/02 14:47:59
@@ -119,7 +119,7 @@
 #define I4BCAPI_APPLID 1

 extern int capi_ll_attach(capi_softc_t *, const char *, const char *);
-extern int capi_ll_control(capi_softc_t *, int op, int arg);
+extern int capi_ll_control(capi_softc_t *, int op, intptr_t arg);
 extern int capi_ll_detach(capi_softc_t *);

 #define CAPI_CTRL_READY     0 /* ctrl ready, value=TRUE/FALSE */
===================================================================
--- netisdn/i4b_capi_llif.c     2012/05/02 15:13:49     1.1
+++ netisdn/i4b_capi_llif.c     2012/05/02 15:14:02
@@ -57,7 +57,7 @@
 */

 int
-capi_ll_control(capi_softc_t *sc, int op, int arg)
+capi_ll_control(capi_softc_t *sc, int op, intptr_t arg)
 {
     switch (op) {
     case CAPI_CTRL_READY:
===================================================================
--- netisdn/i4b_capi_msgs.c     2012/05/02 15:17:32     1.1
+++ netisdn/i4b_capi_msgs.c     2012/05/02 15:33:34
@@ -726,7 +726,8 @@
     msg = capimsg_setu16(msg, msgid);

     msg = capimsg_setu32(msg, sc->sc_bchan[chan].ncci);
-    msg = capimsg_setu32(msg, (u_int32_t) m_b3->m_data); /* Pointer */
+    KASSERT((((uintptr_t)m_b3->m_data) & ~(uintptr_t)0xffffffff) == 0);
+    msg = capimsg_setu32(msg, (u_int32_t) ((uintptr_t)m_b3->m_data)); /* Pointer */
     msg = capimsg_setu16(msg, m_b3->m_len);
     msg = capimsg_setu16(msg, chan);
     msg = capimsg_setu16(msg, 0); /* Flags */
===================================================================
--- dev/ic/iavc.c      2010/05/12 09:44:32     1.2
+++ dev/ic/iavc.c      2012/05/02 14:47:00
@@ -621,7 +621,7 @@
                cardtype, serial, nbch, vers, prot);
        aprint_verbose_dev(&sc->sc_dev, "%s\n", caps);

-        capi_ll_control(&sc->sc_capi, CAPI_CTRL_PROFILE, (int) profile);
+        capi_ll_control(&sc->sc_capi, CAPI_CTRL_PROFILE, (intptr_t) profile);

     } else {
        printf("%s: no profile data in info response?\n", device_xname(&sc->sc_dev));


>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Fri, 04 May 2012 08:35:30 +0000
Responsible-Changed-Why:
take


State-Changed-From-To: open->closed
State-Changed-By: maxv@NetBSD.org
State-Changed-When: Sat, 22 Sep 2018 11:57:58 +0000
State-Changed-Why:
iavc was removed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.