From owner-freebsd-usb@freebsd.org Thu Dec 26 00:46:25 2019 Return-Path: Delivered-To: freebsd-usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 068051E91B9 for ; Thu, 26 Dec 2019 00:46:25 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47jrqh0vBGz4Q2s for ; Thu, 26 Dec 2019 00:46:23 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id A750D5E5 for ; Wed, 25 Dec 2019 19:46:22 -0500 (EST) Received: from imap35 ([10.202.2.85]) by compute5.internal (MEProxy); Wed, 25 Dec 2019 19:46:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=farhan.codes; h= mime-version:message-id:date:from:to:subject:content-type; s= fm1; bh=v/mqE0V59A0tpjUYUk4uP470dy1nGTxpv4WkI+T8nbM=; b=eH1Rq2Gs pWT6uWkFcBRe4r1l1WpF8DdKfl6gnRgPWfcniBmBvTZT+6bbaDY8LL9j+PwHTqyk vW170xueQLNNXIoXvJ5/TGrrFCcPexL4MRCL7uCdZQTPczvWaexJqI8EJ+ElHcbd jL5qMex6tAwXal6m5OEMmVRZ9odbsWS13msSNymtkYsVcWBRir0zAwhFMEtli/gs DT1X0HF8gIE/qL4Fz6JYioOa0LIvHMNyGMS9Lfy2pMBvC7cSmWfXBwzqL0BVlw2U BpmeNKkfonFYbqtRb4+mFvQxIm8qT6iP38ca/nSCFlt8Bzb2/dfZVXNJvDE8ZbpN WUTSQP4m0RnxWg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=v/mqE0V59A0tpjUYUk4uP470dy1nG Txpv4WkI+T8nbM=; b=PZYhqAsmrBvBYvBQNL9ndWFQs0GKL20ST23MBHg3LDP9Y jdfs6b/u1noQstvQ566kL+pNRYBLnO79ts0rv/pvsywLx7gHRgbDPr3biHaMC/Te OTAcrrbRpDzlqu3HE+B5QTjSvgKNFhcTGGsZMGRowYvu+LRlspZnRiZk7R8x7Gu9 h+1RTj2D1iI9bBHGcc6ZPWyf7EBAAo5+2a9e8zrysGIBf52lqOK0tyjKV4dID5Bf XnUASuXER5U56Yf05/UX0+MvWhwjrtzbuhjE3CFGNviEDs3fAVfFH2Eoy00/cWkm RmKcI9M5soixYxQbAKPjdpjlwoAYDDWNYWhmyZL1A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvddvhedgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsegrtderre erredtnecuhfhrohhmpedfhfgrrhhhrghnucfmhhgrnhdfuceofhgrrhhhrghnsehfrghr hhgrnhdrtghouggvsheqnecuffhomhgrihhnpehkohdrughopdhgnhhurdhorhhgnecurf grrhgrmhepmhgrihhlfhhrohhmpehfrghrhhgrnhesfhgrrhhhrghnrdgtohguvghsnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id DFE1414C0068; Wed, 25 Dec 2019 19:46:21 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-694-gd5bab98-fmstable-20191218v1 Mime-Version: 1.0 Message-Id: <7b2a53c8-8640-4b0c-8d6e-22a1988a3ebd@www.fastmail.com> Date: Wed, 25 Dec 2019 19:46:01 -0500 From: "Farhan Khan" To: freebsd-usb@freebsd.org Subject: Page fault at USB attachment code X-Rspamd-Queue-Id: 47jrqh0vBGz4Q2s X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=farhan.codes header.s=fm1 header.b=eH1Rq2Gs; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=PZYhqAsm; dmarc=none; spf=pass (mx1.freebsd.org: domain of farhan@farhan.codes designates 64.147.123.25 as permitted sender) smtp.mailfrom=farhan@farhan.codes X-Spamd-Result: default: False [-4.08 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[farhan.codes:s=fm1,messagingengine.com:s=fm1]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:64.147.123.25]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-usb@freebsd.org]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; URI_COUNT_ODD(1.00)[9]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[4]; DMARC_NA(0.00)[farhan.codes]; MV_CASE(0.50)[]; DKIM_TRACE(0.00)[farhan.codes:+,messagingengine.com:+]; IP_SCORE(-3.49)[ip: (-9.82), ipnet: 64.147.123.0/24(-4.92), asn: 11403(-2.68), country: US(-0.05)]; RCVD_IN_DNSWL_LOW(-0.10)[25.123.147.64.list.dnswl.org : 127.0.5.1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:11403, ipnet:64.147.123.0/24, country:US]; RCVD_TLS_LAST(0.00)[]; MID_RHS_WWW(0.50)[] Content-Type: text/plain X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Dec 2019 00:46:25 -0000 Hi all, I am writing a simple USB network device driver skeleton, just to learn the framework. What I think is fairly simple code is having a kernel panic when it hits the attachment code. The code and kgdb output are below. I apologize, its been some time since I used kgdb, so I am not sure what the next step I should do to debug this. --------------------- static int skel_usb_attach(device_t self) { struct usb_attach_arg *uaa = device_get_ivars(self); struct skel_usb_softc *uc = device_get_softc(self); struct skel_softc *sc = uc->sc_sc; struct ieee80211com *ic = &sc->sc_ic; device_set_usb_desc(self); uc->uc_udev = uaa->device; sc->sc_dev = self; ic->ic_name = device_get_nameunit(self); return 0; } --------------------- When I run kgdb, I get the following output. --------------------- sudo kgdb -n last GNU gdb (GDB) 8.3.1 [GDB v8.3.1 for FreeBSD] Copyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-portbld-freebsd13.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /usr/obj/usr/src/amd64.amd64/sys/GENERIC/kernel.full... Unread portion of the kernel message buffer: Matched! skel0 on uhub0 skel0: on usbus0 Fatal trap 12: page fault while in kernel mode cpuid = 0; apic id = 00 fault virtual address = 0x7170 fault code = supervisor write data, page not present instruction pointer = 0x20:0xffffffff8271f094 stack pointer = 0x28:0xfffffe00036f5930 frame pointer = 0x28:0xfffffe00036f5950 code segment = base 0x0, limit 0xfffff, type 0x1b = DPL 0, pres 1, long 1, def32 0, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 15 (usbus0) trap number = 12 panic: page fault cpuid = 0 time = 1577299341 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00036f5590 vpanic() at vpanic+0x17e/frame 0xfffffe00036f55f0 panic() at panic+0x43/frame 0xfffffe00036f5650 trap_fatal() at trap_fatal+0x386/frame 0xfffffe00036f56b0 trap_pfault() at trap_pfault+0x99/frame 0xfffffe00036f5730 trap() at trap+0x2a3/frame 0xfffffe00036f5860 calltrap() at calltrap+0x8/frame 0xfffffe00036f5860 --- trap 0xc, rip = 0xffffffff8271f094, rsp = 0xfffffe00036f5930, rbp = 0xfffffe00036f5950 --- skel_usb_attach() at skel_usb_attach+0x34/frame 0xfffffe00036f5950 device_attach() at device_attach+0x3ca/frame 0xfffffe00036f5990 device_probe_and_attach() at device_probe_and_attach+0x70/frame 0xfffffe00036f59c0 usb_probe_and_attach_sub() at usb_probe_and_attach_sub+0x150/frame 0xfffffe00036f5a10 usb_probe_and_attach() at usb_probe_and_attach+0x463/frame 0xfffffe00036f5ae0 uhub_explore() at uhub_explore+0x753/frame 0xfffffe00036f5b50 usb_bus_explore() at usb_bus_explore+0x11a/frame 0xfffffe00036f5b70 usb_process() at usb_process+0x103/frame 0xfffffe00036f5bb0 fork_exit() at fork_exit+0x80/frame 0xfffffe00036f5bf0 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe00036f5bf0 --- trap 0, rip = 0, rsp = 0, rbp = 0 --- KDB: enter: panic warning: Could not load shared library symbols for if_skel_usb.ko. Do you need "set solib-search-path" or "set sysroot"? --------------------- Note: I am testing this with an Atheros USB device. Thanks! -- Farhan Khan PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE