From owner-freebsd-arch@FreeBSD.ORG Sat Oct 25 02:28:14 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 432E97B7 for ; Sat, 25 Oct 2014 02:28:14 +0000 (UTC) Received: from mail-wi0-x22b.google.com (mail-wi0-x22b.google.com [IPv6:2a00:1450:400c:c05::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D24D3EF5 for ; Sat, 25 Oct 2014 02:28:13 +0000 (UTC) Received: by mail-wi0-f171.google.com with SMTP id em10so2529675wid.10 for ; Fri, 24 Oct 2014 19:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=aecj7wA5gTFAHiyNXTyeldZ2loAkPMWzcxe16D5yhfs=; b=ygIrRAD3pCf0FaRwCXR4P2B1O/J6Qp0mnxxcGIqQW12z6C5z9SKohaxTB31+fiqrSm BCsJIK9xqtcNGa4E2IhoMGqD+bd7UKYpWTNQ2xay9k5d6Je0Y4RWlXnI7C6qx2tdgC57 Ds2T1ORxmpUfJZezl40TCyZJqApTY5vIV7HjrFa1FZRdWBtkODg+FtSkMwTMW9OhV0fM kgso2HBJvMpUpD+vSrCXerxzzyo3zIfYyT6FavASQJ4I0rBjhuIKctF3z8WexWsxYFpM cN8RSuJwgb+G/cl506pUnC01lkLQ7BbKcw1mFBwWM3PYVtVSppA7s2mTl63/aHWclSKW El1Q== X-Received: by 10.180.74.142 with SMTP id t14mr7554382wiv.17.1414204092088; Fri, 24 Oct 2014 19:28:12 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id fa7sm7430018wjd.27.2014.10.24.19.28.10 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 24 Oct 2014 19:28:11 -0700 (PDT) Date: Sat, 25 Oct 2014 04:28:09 +0200 From: Mateusz Guzik To: freebsd-arch@freebsd.org Subject: syscalls from loadable modules compiled in statically into the kernel Message-ID: <20141025022808.GA14551@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Oct 2014 02:28:14 -0000 The kernel has the following mechanism: int syscall_thread_enter(struct thread *td, struct sysent *se) { u_int32_t cnt, oldcnt; do { oldcnt = se->sy_thrcnt; if ((oldcnt & SY_THR_STATIC) != 0) return (0); if ((oldcnt & (SY_THR_DRAINING | SY_THR_ABSENT)) != 0) return (ENOSYS); cnt = oldcnt + SY_THR_INCR; } while (atomic_cmpset_acq_32(&se->sy_thrcnt, oldcnt, cnt) == 0); return (0); } Except it turns out that it is used even if given module (here: sysvshm) is compiled in statically. So my proposal is to give modules an easy way to tell whether they got compiled in and extend syscall_register interface so that it would allow registering static syscalls. The latter could also be used by modules which are loadable, but don't support unloads. I don't have any good idea how to provide aforementioned detection method though. Also, please see https://reviews.freebsd.org/D1007 which moves SY_THR_STATIC check to an inline function, saving us 2 function calls on each syscall. -- Mateusz Guzik