From owner-freebsd-net@FreeBSD.ORG Tue Mar 3 21:28:54 2015 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 035006D0 for ; Tue, 3 Mar 2015 21:28:54 +0000 (UTC) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0134.outbound.protection.outlook.com [157.56.110.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "MSIT Machine Auth CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ABC7ACE9 for ; Tue, 3 Mar 2015 21:28:52 +0000 (UTC) Received: from BN1PR03MB008.namprd03.prod.outlook.com (10.255.224.38) by BN1PR03MB008.namprd03.prod.outlook.com (10.255.224.38) with Microsoft SMTP Server (TLS) id 15.1.106.11; Tue, 3 Mar 2015 20:55:03 +0000 Received: from BN1PR03MB008.namprd03.prod.outlook.com ([169.254.15.182]) by BN1PR03MB008.namprd03.prod.outlook.com ([169.254.15.182]) with mapi id 15.01.0106.007; Tue, 3 Mar 2015 20:55:03 +0000 From: "sumith.devvojini@freescale.com" To: "rizzo@iet.unipi.it" , "net@freebsd.org" Subject: Segmentation Fault When using Netmap with big endian Thread-Topic: Segmentation Fault When using Netmap with big endian Thread-Index: AdBV8RYShlFj5VpnQLqmM2/SWEC8Dw== Date: Tue, 3 Mar 2015 20:55:03 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.88.168.50] authentication-results: iet.unipi.it; dkim=none (message not signed) header.d=none; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB008; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(5005006); SRVR:BN1PR03MB008; BCL:0; PCL:0; RULEID:; SRVR:BN1PR03MB008; x-forefront-prvs: 0504F29D72 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(74316001)(19625215002)(16236675004)(33656002)(40100003)(19300405004)(122556002)(54356999)(86362001)(76576001)(2501003)(2900100001)(102836002)(15975445007)(77156002)(92566002)(62966003)(107886001)(229853001)(66066001)(2656002)(87936001)(50986999)(99286002)(46102003)(19580395003); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR03MB008; H:BN1PR03MB008.namprd03.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2015 20:55:03.4212 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR03MB008 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Mar 2015 21:28:54 -0000 Hello Luigi, I am a Software Engineer at Freescale semiconductor and I am currently work= ing on porting netmap to Freescale's integrated network controller ETSEC. I= came across the segmentation problem while testing my port with pkt-gen ap= plication provided as an example. This segmentation fault is due to the buf= fer pointer return to user space which is beyond the address space of the a= pplication. The reason for this I believe is line number 1351 in file netma= p_mem2.c *(uint16_t *)(uintptr_t)&ring->nr_buf_size =3D netmap_mem_bufsize(na->nm_mem); where nr_buf_size is a 32 bit integer but we are storing the buffer size wh= ile casting this variable to a 16 bit integer pointer. When userspace appli= cation requests the buffer address we read this variable as a 32 bit intege= r and apply that as the offset. Though this works on little endian systems because how they store the value= in memory, it breaks in big endian systems. The cast can be changed to 32 = bit integer pointer to make netmap more stable across different platforms. Thank you, Sumith Dev Vojini