From owner-freebsd-current@FreeBSD.ORG Thu Jan 1 19:49:48 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9AA2106564A for ; Thu, 1 Jan 2009 19:49:48 +0000 (UTC) (envelope-from oliver.pntr@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.157]) by mx1.freebsd.org (Postfix) with ESMTP id 6E3048FC14 for ; Thu, 1 Jan 2009 19:49:48 +0000 (UTC) (envelope-from oliver.pntr@gmail.com) Received: by fg-out-1718.google.com with SMTP id l26so1983138fgb.35 for ; Thu, 01 Jan 2009 11:49:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=AjnzUH6Pj37rnG0ypQE8luNrBCzXYxp/lBqys0HR1l0=; b=LtcrGoSoZZIQFtVpGlyDSqvxXbw3U21GAvZW1VM08r9NrwtnZmYgJl5Qn/se+/V7xf gnbNrdVBO7jD468ibnidKHinOBOMKCXDUVozO4yz09xLKFlc4m6pNrezLNkoYWAA4OMM fxP1vptJL4BZgo6/rEoukBbDBCaQILkEDTSMY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=QVjHfF19kwPJPBZCSu1pdmktflWvhrkfJQRVv0Oh3EUZavyuwB7Xnnsn4aohwb0cuh CWdBwAUR0P/Dr/BR0K96zmcs8OIQ/T/9DP7yB1SqVvSYyrwwoxn8SY42If8q8dRZoF/a hliW1gGJNNtDNY+Uq5HENzqWtrd5qeF8GD9Dc= Received: by 10.86.79.4 with SMTP id c4mr10021538fgb.7.1230837444581; Thu, 01 Jan 2009 11:17:24 -0800 (PST) Received: by 10.86.90.7 with HTTP; Thu, 1 Jan 2009 11:17:24 -0800 (PST) Message-ID: <6101e8c40901011117y3e82a226id6f9de940b0f7dcd@mail.gmail.com> Date: Thu, 1 Jan 2009 20:17:24 +0100 From: "Oliver Pinter" To: "Luigi Rizzo" In-Reply-To: <20090101183026.GA15385@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20090101183026.GA15385@onelab2.iet.unipi.it> Cc: current@freebsd.org Subject: Re: RFC: new utility, kmodpatch X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jan 2009 19:49:49 -0000 Hi! Do You think for this project: http://www.ksplice.com/ ? On 1/1/09, Luigi Rizzo wrote: > I mentioned this utility a couple of months ago, and it's now working > so i would like to receive feedback on whether this is good to have > as part of the system, or just keep it as a port (which is what > i plan to do by default). > > In a nutshell, the kmodpatch utility can print or alter the content > of device/quirk tables in kernel modules (I think Linux has some > similar tool, though i don't remember the name -- or perhaps it is > a feature of insmod ?). > > Full manpage is attached at the end, full sources are at > > http://info.iet.unipi.it/~luigi/FreeBSD/20090101-kmodpatch.tgz > > What is missing is some extra code to let it patch an on-disk file > (elfdump returns the info we need, so in the worst case we just > need to write a wrapper around elfdump). > > Feedback welcome. > > cheers > luigi > > ------- manpage content -------- > > KMODPATCH(8) FreeBSD System Manager's Manual > KMODPATCH(8) > > NAME > kmodpatch -- print/modify device/quirk tables in kernel modules > > SYNOPSIS > kmodpatch [-v] [-t file | format] module_name table_name [@offset [args > ...]] > > DESCRIPTION > The kmodpatch utility can print or alter the content of device/quirk > tables in kernel modules. These tables are generally used to identify > devices, and possibly apply specific quirks to enable/disable certain > features. kmodpatch is especially useful to let the kernel recognise a > new device without rebooting and rebuilding/reinstalling kernel or mod- > ules. > > In read mode (when no args are specified), kmodpatch only list one or > more entries in the matching module and table. > > In write mode, kmodpatch overwrites a user's specified entry in a table > with the values passed on the command line. kmodpatch does some amount > of checking to make sure that the arguments (module and table name, > off- > set, parameters formats) are compatible with the currently loaded mod- > ules. > > A couple of real life examples: > > kmodpatch umass.ko - @0 0x4050 0x4a5 0x0101 0x4200 > set the kernel to use flags UMASS_PROTO_SCSI | UMASS_PROTO_BBB and > quirks WRONG_CSWSIG | NO_SYNCHRONIZE_CACHE for a certain GSM phone > that implements the umass interface; > > kmodpatch uscanner.ko - @0 0x04b8 0x084a 0 > let uscanner.ko recognise a newly introduced MFP scanner device. > > kmodpatch relies on a list of which modules and tables (associated to > kernel symbols) it can work on, and the format of the records in each > ta- > ble. By default kmodpatch uses an internal list, which can be > overridden > from the command line using the -t option followed by either a file > name, > or by immediate text describing the kernel table. The format of the > file > is described in Section MODULE DESCRIPTION > > The following options are available: > > -v Verbose mode, print some debugging info > > -t file | format > Specify a file containing the name and format of descriptor > tables, or a line with the actual format of the table. > > MODULE DESCRIPTION > The file (or text) describing modules, tables and record structure has > a > simple text format with one line per table. The `#' character is a com- > ment delimiter, and can appear anywhere in the text. Each valid line > must contain the following fields: > > module_name symbol_name entry_format [entry_format ...] > > Each entry_format describes one field in the table, and it is made of a > number and/or a character specifying the field size and format, > followed > by an optional ':' and a word describing the field itself. > > Supported formats are: > > 2 | 2l | 2b > 16-bit unsigned in host, little-endian or big-endian format; > > 4 | 4l | 4b > 32-bit unsigned in host, little-endian or big-endian format; > > 8 | 8l | 8b > 64-bit unsigned in host, little-endian or big-endian format; > > p a pointer; > > s a null-terminated string; > > The optional description is used as a header when listing the content > of > a table. > > EXAMPLE MODULE DESCRIPTION > The following is an example of a file containing module descriptions. > > umass.ko umass_devdescrs 4:vendor 4:product 4:rev 2:proto > 2:quirks > uscanner.ko uscanner_devs 2:vendor 2:device 4:flags # comment > if_nfe.ko nfe_devs 2:vendor 2:device s:name > if_re.ko re_devs 2:vendor 2:device 4:type s:name > > EXAMPLES > In addition to the two examples given at the beginning, one can use > kmodpatch to explore the content of kernel tables, as follows. > > To list entries in module if_re: > > kmodpatch if_re - > > To list entry 10 in module umass: > > kmodpatch umass - @10 > > To set the last entry in module uscanner.ko > > kmodpatch uscanner.ko - @-1 0x04b8 0x0839 0 > > WARNINGS > kmodpatch requires root privileges even to just read the content of the > kernel tables. > > In write mode, the use of kmodpatch is as dangerous as accessing > /dev/kmem in write mode, even though kmodpatch does some amount of > check- > ing to make sure that the arguments passed are reasonable. To this pur- > pose, it is fundamental that the table descriptions used by kmodpatch > match the actual structure of the kernel tables. There is no automatic > way to extract this info. > > BUGS > Right now, kmodpatch only writes to in-memory modules (or kernel). As a > consequence the approach is not suitable to devices that are > persistently > connected to the system and for which the system cannot do a "reprobe". > > SEE ALSO > kldconfig(8), kldload(8), kldstat(8), kldunload(8) > > HISTORY > The kmodpatch utility first appeared in FreeBSD 8.0 inspired by a > similar > feature present on Linux. > > AUTHORS > The kmodpatch utility was designed and implemented by Luigi Rizzo > . > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >