From owner-freebsd-current@FreeBSD.ORG Sat Sep 7 19:21:27 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id AF6DAC4C; Sat, 7 Sep 2013 19:21:27 +0000 (UTC) (envelope-from mark@grondar.org) Received: from gromit.grondar.org (grandfather.grondar.org [IPv6:2a01:348:0:15:5d59:5c20:0:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4AC8A206C; Sat, 7 Sep 2013 19:21:27 +0000 (UTC) Received: from graveyard.grondar.org ([88.96.155.33] helo=gronkulator.grondar.org) by gromit.grondar.org with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1VIO4S-000DkH-Cd; Sat, 07 Sep 2013 20:21:26 +0100 Subject: Re: random(4) update causes mips compile fail | mips boot fail Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Content-Type: multipart/signed; boundary="Apple-Mail=_6773E15C-F2D7-4499-9C6C-B6C799B2C96A"; protocol="application/pgp-signature"; micalg=pgp-sha512 From: Mark R V Murray In-Reply-To: <1378581133.1588.18.camel@localhost> Date: Sat, 7 Sep 2013 20:21:23 +0100 Message-Id: References: <1378572186.1588.5.camel@localhost> <24DB010A-F374-491B-9203-FDDD7EA14A51@grondar.org> <1378579011.1588.16.camel@localhost> <9240BEF1-2791-4D58-A422-08AEF1CD306C@grondar.org> <1378579756.1588.17.camel@localhost> <1378581133.1588.18.camel@localhost> To: sbruno@freebsd.org X-Mailer: Apple Mail (2.1508) X-SA-Score: -2.2 X-Mailman-Approved-At: Sat, 07 Sep 2013 20:55:07 +0000 Cc: "freebsd-current@freebsd.org" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 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: Sat, 07 Sep 2013 19:21:27 -0000 --Apple-Mail=_6773E15C-F2D7-4499-9C6C-B6C799B2C96A Content-Type: multipart/mixed; boundary="Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7" --Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 7 Sep 2013, at 20:12, Sean Bruno wrote: > On Sat, 2013-09-07 at 19:56 +0100, Mark R V Murray wrote: >>> Ok. Right now, the mips kernel doesn't build unless I have random >> built >>> in, we were using it as a module previously. >> >> >> I'm testing a fix, but if you want to help out, please move the >> random_null_func() >> from randomdev.c to pseudo_rng.c in sys/dev/random. Patch enclosed. >> >> Thanks! >> >> M > > Closer: > > --- kernel.debug --- > linking kernel.debug > random_adaptors.o: In function `random_sysctl_active_adaptor_handler': > /home/sbruno/bsd/head/sys/dev/random/random_adaptors.c:(.text+0x2dc): > undefined reference to `random_get_active_adaptor' > /home/sbruno/bsd/head/sys/dev/random/random_adaptors.c:(.text+0x2dc): > relocation truncated to fit: R_MIPS_26 against > `random_get_active_adaptor' > *** [kernel.debug] Error code 1 Nearly there - I saw that too. Proposed fix enclosed. M -- Mark R V Murray --Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7 Content-Disposition: attachment; filename=rng_fix.patch Content-Type: application/octet-stream; name="rng_fix.patch" Content-Transfer-Encoding: 7bit Index: arm/arm/locore.S =================================================================== --- arm/arm/locore.S (revision 255362) +++ arm/arm/locore.S (working copy) @@ -84,6 +84,17 @@ mov ip, r2 /* Save meta data */ mov fp, r3 /* Future expantion */ +#if defined(CPU_CORTEXA) + /* Get this bit done early so we have some decent startup jitter in CCNT */ + /* Better to do access to these counters as some kind of device? */ + /* Set INTENS to 0 to block all counter interrupts */ + mov r7, #0x8000000F + mcr p15, 0, r7, c9, c14, 2 + /* Set PMNC[0] to 1 to enable CCNT, used in get_cyclecount() */ + mov r7, #1 + mcr p15, 0, r7, c9, c12, 0 +#endif + /* Make sure interrupts are disabled. */ mrs r7, cpsr orr r7, r7, #(I32_bit|F32_bit) Index: arm/include/cpu.h =================================================================== --- arm/include/cpu.h (revision 255362) +++ arm/include/cpu.h (working copy) @@ -13,11 +13,18 @@ static __inline uint64_t get_cyclecount(void) { +#if defined(CPU_CORTEXA) + uint32_t ccnt; + + /* Read CCNT. Darn; its only 32 bits. */ + __asm __volatile("mrc p15, 0, %0, c9, c13, 0": "=r" (ccnt)); + return ((uint64_t)ccnt); +#else struct bintime bt; binuptime(&bt); return ((uint64_t)bt.sec << 56 | bt.frac >> 8); - +#endif } #endif Index: dev/random/pseudo_rng.c =================================================================== --- dev/random/pseudo_rng.c (revision 255362) +++ dev/random/pseudo_rng.c (working copy) @@ -39,6 +39,12 @@ static struct mtx pseudo_random_block_mtx; +/* Used to fake out unused random calls in random_adaptor */ +void +random_null_func(void) +{ +} + static int pseudo_random_block_read(void *buf __unused, int c __unused) { Index: dev/random/random_adaptors.c =================================================================== --- dev/random/random_adaptors.c (revision 255362) +++ dev/random/random_adaptors.c (working copy) @@ -53,6 +53,8 @@ /* List for the dynamic sysctls */ static struct sysctl_ctx_list random_clist; +struct random_adaptor *random_adaptor; + MALLOC_DEFINE(M_RANDOM_ADAPTORS, "random_adaptors", "Random adaptors buffers"); int @@ -230,7 +232,7 @@ int error; name = NULL; - rsp = random_get_active_adaptor(); + rsp = random_adaptor; if (rsp != NULL) { sx_slock(&adaptors_lock); Index: dev/random/random_adaptors.h =================================================================== --- dev/random/random_adaptors.h (revision 255362) +++ dev/random/random_adaptors.h (working copy) @@ -41,6 +41,8 @@ int random_adaptor_register(const char *, struct random_adaptor *); void random_adaptor_choose(struct random_adaptor **); +extern struct random_adaptor *random_adaptor; + /* * random_adaptor's should be registered prior to * random module (SI_SUB_DRIVERS/SI_ORDER_MIDDLE) Index: dev/random/randomdev.c =================================================================== --- dev/random/randomdev.c (revision 255362) +++ dev/random/randomdev.c (working copy) @@ -72,27 +72,12 @@ .d_name = "random", }; -static struct random_adaptor *random_adaptor; static eventhandler_tag attach_tag; static int random_inited; - /* For use with make_dev(9)/destroy_dev(9). */ static struct cdev *random_dev; -/* Used to fake out unused random calls in random_adaptor */ -void -random_null_func(void) -{ -} - -struct random_adaptor * -random_get_active_adaptor(void) -{ - - return (random_adaptor); -} - /* ARGSUSED */ static int random_close(struct cdev *dev __unused, int flags, int fmt __unused, Index: dev/random/randomdev.h =================================================================== --- dev/random/randomdev.h (revision 255362) +++ dev/random/randomdev.h (working copy) @@ -53,4 +53,3 @@ extern void random_ident_hardware(struct random_adaptor **); extern void random_null_func(void); -struct random_adaptor *random_get_active_adaptor(void); --Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7-- --Apple-Mail=_6773E15C-F2D7-4499-9C6C-B6C799B2C96A Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.20 (Darwin) Comment: GPGTools - http://gpgtools.org iQCVAwUBUit8s958vKOKE6LNAQouFgP8CUonQkFn7z4JUsPLKVjeij2LVWBGIKmu mK9MeKSV3K/qZg8Z2eGQyWDHFcp6enCrv4eTiTY2tYpw6wNA4VZGpOlMs0fqUrYK 5cqxzyoZzop8KTwkuoCF5DRBX0/ykvrQ/KMhEuuV7TTDEWbgbKuLeM7vbdFDXt9b elpIRkNSs4g= =mN42 -----END PGP SIGNATURE----- --Apple-Mail=_6773E15C-F2D7-4499-9C6C-B6C799B2C96A--