From owner-svn-src-all@freebsd.org Sun Apr 16 00:07:20 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 75729D3FDAF; Sun, 16 Apr 2017 00:07:20 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 14689A9E; Sun, 16 Apr 2017 00:07:19 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wm0-f51.google.com with SMTP id t189so13941887wmt.1; Sat, 15 Apr 2017 17:07:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=Fg0mfZND90/+U03b8wyA+qBCIR9011iIVZMgoEhBuSo=; b=ODF+NgGJ04915RXe4+zoMNH61Zz6bpJ4LWODcd4HxmiNKFlVLSOMYrSH8HTn25/7Cr /FNHPufsNinz1vuOHfRJMj8+EAo2MJPy9HNZFVJLx39XjZHQv3m4dIOCoUjh4GawPKAE rF+b9X1ihRScAxHLayUCUsW8bVEQwtcKHT/E/rlEq7NmZmYR1e8UIQR6Pc69b3vIiwwt GRlzegMPskOGrdCKg0ceEYwmuVADfBUUL+yaIULJprzlgMl5U6/lF8LOWScETyDAEJIz xQHuk8RU+a/I1NZOsTUdegSHUghCe7EhvPC7T/wteps5swShY9RHKZC0EmUP9E24uq9M 2NIg== X-Gm-Message-State: AN3rC/6sFTdVI/ldHnSUHCPN5Onja4w7uHrEORjbw8Jd1GdOX62grdhP 59yTM6QW2gzVIg== X-Received: by 10.28.207.204 with SMTP id f195mr3705360wmg.72.1492300871704; Sat, 15 Apr 2017 17:01:11 -0700 (PDT) Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com. [209.85.128.178]) by smtp.gmail.com with ESMTPSA id b188sm4360346wmh.6.2017.04.15.17.01.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Apr 2017 17:01:11 -0700 (PDT) Received: by mail-wr0-f178.google.com with SMTP id o21so66916248wrb.2; Sat, 15 Apr 2017 17:01:11 -0700 (PDT) X-Received: by 10.223.160.214 with SMTP id n22mr13509738wrn.198.1492300871390; Sat, 15 Apr 2017 17:01:11 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.80.169.4 with HTTP; Sat, 15 Apr 2017 17:01:10 -0700 (PDT) In-Reply-To: <201704152337.v3FNb2m1014053@pdx.rh.CN85.dnsmgr.net> References: <201704152005.v3FK5M2j002459@repo.freebsd.org> <201704152337.v3FNb2m1014053@pdx.rh.CN85.dnsmgr.net> From: Conrad Meyer Date: Sat, 15 Apr 2017 17:01:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r316978 - in head: contrib/zstd etc/mtree lib lib/libzstd share/mk usr.bin usr.bin/zstd To: "Rodney W. Grimes" Cc: Baptiste Daroussin , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 00:07:20 -0000 On Sat, Apr 15, 2017 at 4:37 PM, Rodney W. Grimes wrote: > And we need this in base for what great purpose??? Can you tone down the condescension, Rod? Being rude doesn't help you make your case. We already have zlib, bzip2, and xz in base. zstd is just one more that fills an important niche. If you're not familiar with it, zstd is a relatively recent new compression algorithm that provides a better compression/performance point relative to zlib at any point along the -0/-9 curve. It performs favorably to bzip2 and xz as well, although it's not dominant at all points relative to those two. See the last figure in https://clearlinux.org/blogs/linux-os-data-compression-options-comparing-behavior for a better idea of what niche it fills. Thanks, Conrad From owner-svn-src-all@freebsd.org Sun Apr 16 00:09:47 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B0FCD3FF09; Sun, 16 Apr 2017 00:09:47 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from mx1.scaleengine.net (mx1.scaleengine.net [209.51.186.6]) (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 1C1F6C67; Sun, 16 Apr 2017 00:09:47 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from [192.168.1.10] (unknown [192.168.1.10]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id BD6E4DEDD; Sun, 16 Apr 2017 00:09:44 +0000 (UTC) Subject: Re: svn commit: r316978 - in head: contrib/zstd etc/mtree lib lib/libzstd share/mk usr.bin usr.bin/zstd To: rgrimes@freebsd.org, Baptiste Daroussin References: <201704152337.v3FNb2m1014053@pdx.rh.CN85.dnsmgr.net> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Allan Jude Message-ID: Date: Sat, 15 Apr 2017 20:09:31 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <201704152337.v3FNb2m1014053@pdx.rh.CN85.dnsmgr.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="MXCfp1blvxdCEt9VCiixXb6uho1PsTtuj" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 00:09:47 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MXCfp1blvxdCEt9VCiixXb6uho1PsTtuj Content-Type: multipart/mixed; boundary="PlPD1NikJ78VxJFJvFBiP2SP6pVupxt1a"; protected-headers="v1" From: Allan Jude To: rgrimes@freebsd.org, Baptiste Daroussin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: Subject: Re: svn commit: r316978 - in head: contrib/zstd etc/mtree lib lib/libzstd share/mk usr.bin usr.bin/zstd References: <201704152337.v3FNb2m1014053@pdx.rh.CN85.dnsmgr.net> In-Reply-To: <201704152337.v3FNb2m1014053@pdx.rh.CN85.dnsmgr.net> --PlPD1NikJ78VxJFJvFBiP2SP6pVupxt1a Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2017-04-15 19:37, Rodney W. Grimes wrote: > And we need this in base for what great purpose??? >=20 It is a new faster compression algorithm from the creator of LZ4, Yann Collet. It offers compression ratios similar or great than gzip, but 4-6x faster compression, and 2-3x faster decompression (in excess of 1 gigabyte per second per core). It will be used in ZFS shortly, and is expected to supplant gzip/bzip2 for compressed kernel/memdisk in the loader for pxeboot / iscsi boot etc.= >=20 >> Author: bapt >> Date: Sat Apr 15 20:05:22 2017 >> New Revision: 316978 >> URL: https://svnweb.freebsd.org/changeset/base/316978 >> >> Log: >> Import zstandard 1.1.4 in base >> =20 >> zstandard is a new compression library/tool which is very fast at >> compression/decompression >> =20 >> For now import as a private library >> --=20 Allan Jude --PlPD1NikJ78VxJFJvFBiP2SP6pVupxt1a-- --MXCfp1blvxdCEt9VCiixXb6uho1PsTtuj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (MingW32) iQIcBAEBAgAGBQJY8rY/AAoJEBmVNT4SmAt+dBwQANogMqwDoAuBTRiOoHOPns3u S46rR+hyw8+YhAvlk7PYUKnjRz+3U6GgoKI3dTA0pQssS5XWdoyDCr+U3ua6Ic0y 8UTeLwBAznNs8xCg8qVVCQT65Wb/5aRvLXAQqGwJsUNDhbv/UrxfJT0c6hwSRImv QZm7QLAP6EuoDsf4wH+zoUoCj/RcgxZdflsclHI1cx9J1H7afIP9UEwAyHhLSYj/ yfVynJVHQxWWtIImixoa32gcT+gqD1GztYCOq6MCXsbFBs02Hdn/TiX0fwhie+bs iIX03EFNlNhTlD28fWGX02MZf5C3NbBvbztfv0ccZP9FBfb0U7CvCaP3EbH/J5oZ aTn9O322pra81PlniHjDZ4pcF4SgY5V0RhKJ0Y7LYV6foVLJ7hjvoEu7GIJpWCJo U6gPa6nHMPJ5UrQQ4aNZApWoyKX4Y9UykIaHQjp/W1jgDVJxzL81lntIkQJgc2DD C+oM8f8O7dqi1nnobEzaXzt3em+1VIp7SEUUmZknMj8DbzHjSDIhDGVT93EtJu4l 25ebxduB3Gf+Ac6ys7vUTty0inhK2Z/C2Fm++mesKl0JOmdmn6V0WR9IAjZfcBAv N/i8ZS41DXo3dSbe7t4ohdp8CwfqgSFtrPJmyYMfbqSdry+BmHUBc7VmoyWtMQXb Xdps7/9NeYCIkQF8NKzE =Itcb -----END PGP SIGNATURE----- --MXCfp1blvxdCEt9VCiixXb6uho1PsTtuj-- From owner-svn-src-all@freebsd.org Sun Apr 16 01:13:48 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E85DD3587E; Sun, 16 Apr 2017 01:13:48 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 40C7A1AF2; Sun, 16 Apr 2017 01:13:48 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G1DlAT028402; Sun, 16 Apr 2017 01:13:47 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G1DlbA028401; Sun, 16 Apr 2017 01:13:47 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201704160113.v3G1DlbA028401@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 16 Apr 2017 01:13:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316993 - head/contrib/ipfilter/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 01:13:48 -0000 Author: cy Date: Sun Apr 16 01:13:47 2017 New Revision: 316993 URL: https://svnweb.freebsd.org/changeset/base/316993 Log: Fix CID 1372601, possible NULL pointer dereference should reallocarray() fail. Reported by: Coverity CID 1372601 MFC after: 1 week Modified: head/contrib/ipfilter/lib/parsefields.c Modified: head/contrib/ipfilter/lib/parsefields.c ============================================================================== --- head/contrib/ipfilter/lib/parsefields.c Sat Apr 15 23:35:57 2017 (r316992) +++ head/contrib/ipfilter/lib/parsefields.c Sun Apr 16 01:13:47 2017 (r316993) @@ -32,6 +32,10 @@ wordtab_t *parsefields(table, arg) fields = malloc(2 * sizeof(*fields)); } else { fields = reallocarray(fields, num + 1, sizeof(*fields)); + if (fields == NULL) { + perror("memory allocation error at __LINE__ in __FUNCTIOIN__ in __FILE__"); + abort(); + } } if (t == NULL) { From owner-svn-src-all@freebsd.org Sun Apr 16 01:15:39 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 17C8ED35ABB; Sun, 16 Apr 2017 01:15:39 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 DC2AA1D94; Sun, 16 Apr 2017 01:15:38 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G1FcpE028511; Sun, 16 Apr 2017 01:15:38 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G1FcL3028510; Sun, 16 Apr 2017 01:15:38 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201704160115.v3G1FcL3028510@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 16 Apr 2017 01:15:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316994 - head/contrib/ipfilter/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 01:15:39 -0000 Author: cy Date: Sun Apr 16 01:15:37 2017 New Revision: 316994 URL: https://svnweb.freebsd.org/changeset/base/316994 Log: Fix CID 1372600, possible NULL pointer dereference should reallocarray() fail. Reported by: Coverity CID 1372600 MFC after: 1 week Modified: head/contrib/ipfilter/tools/ipf_y.y Modified: head/contrib/ipfilter/tools/ipf_y.y ============================================================================== --- head/contrib/ipfilter/tools/ipf_y.y Sun Apr 16 01:13:47 2017 (r316993) +++ head/contrib/ipfilter/tools/ipf_y.y Sun Apr 16 01:15:37 2017 (r316994) @@ -2195,6 +2195,10 @@ char *phrase; for (i = 0, s = strtok(phrase, " \r\n\t"); s != NULL; s = strtok(NULL, " \r\n\t"), i++) { fb = reallocarray(fb, i / 4 + 1, sizeof(*fb)); + if (fb == NULL) { + perror("memory allocation error at __LINE__ in __FUNCTION__ in __FILE"); + abort(); + } l = (u_32_t)strtol(s, NULL, 0); switch (i & 3) { From owner-svn-src-all@freebsd.org Sun Apr 16 01:40:18 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A8ADD40BBA; Sun, 16 Apr 2017 01:40:18 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 67A72F9F; Sun, 16 Apr 2017 01:40:18 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G1eHpA036886; Sun, 16 Apr 2017 01:40:17 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G1eHMK036884; Sun, 16 Apr 2017 01:40:17 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201704160140.v3G1eHMK036884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 16 Apr 2017 01:40:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316995 - head/sys/dev/mii X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 01:40:18 -0000 Author: ian Date: Sun Apr 16 01:40:17 2017 New Revision: 316995 URL: https://svnweb.freebsd.org/changeset/base/316995 Log: Add support for the Micrel KSZ8081 ethernet PHY. The only thing this phy needs that the ukphy driver doesn't provide is that the value in the proprietary Phy Control 2 Register must be saved before doing a soft reset and restored afterwards. Most modern phys have "sticky bits" for low-level config that survive a reset, but on this one the values in all registers go back to defaults, wiping out any board- specific config set up by the bootloader/bios/whatever. Modified: head/sys/dev/mii/micphy.c head/sys/dev/mii/miidevs Modified: head/sys/dev/mii/micphy.c ============================================================================== --- head/sys/dev/mii/micphy.c Sun Apr 16 01:15:37 2017 (r316994) +++ head/sys/dev/mii/micphy.c Sun Apr 16 01:40:17 2017 (r316995) @@ -76,10 +76,13 @@ __FBSDID("$FreeBSD$"); #define MII_KSZ9031_TX_DATA_PAD_SKEW 0x6 #define MII_KSZ9031_CLOCK_PAD_SKEW 0x8 +#define MII_KSZ8081_PHYCTL2 0x1f + #define PS_TO_REG(p) ((p) / 200) static int micphy_probe(device_t); static int micphy_attach(device_t); +static void micphy_reset(struct mii_softc *); static int micphy_service(struct mii_softc *, struct mii_data *, int); static device_method_t micphy_methods[] = { @@ -102,6 +105,7 @@ static driver_t micphy_driver = { DRIVER_MODULE(micphy, miibus, micphy_driver, micphy_devclass, 0, 0); static const struct mii_phydesc micphys[] = { + MII_PHY_DESC(MICREL, KSZ8081), MII_PHY_DESC(MICREL, KSZ9021), MII_PHY_DESC(MICREL, KSZ9031), MII_PHY_END @@ -110,7 +114,7 @@ static const struct mii_phydesc micphys[ static const struct mii_phy_funcs micphy_funcs = { micphy_service, ukphy_status, - mii_phy_reset + micphy_reset }; static uint32_t @@ -257,6 +261,10 @@ micphy_attach(device_t dev) mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &micphy_funcs, 1); mii_phy_setmedia(sc); + /* Nothing further to configure for 8081 model. */ + if (sc->mii_mpd_model == MII_MODEL_MICREL_KSZ8081) + return (0); + miibus = device_get_parent(dev); parent = device_get_parent(miibus); @@ -271,6 +279,24 @@ micphy_attach(device_t dev) return (0); } +static void +micphy_reset(struct mii_softc *sc) +{ + int reg; + + /* + * The 8081 has no "sticky bits" that survive a soft reset; several bits + * in the Phy Control Register 2 must be preserved across the reset. + * These bits are set up by the bootloader; they control how the phy + * interfaces to the board (such as clock frequency and LED behavior). + */ + if (sc->mii_mpd_model == MII_MODEL_MICREL_KSZ8081) + reg = PHY_READ(sc, MII_KSZ8081_PHYCTL2); + mii_phy_reset(sc); + if (sc->mii_mpd_model == MII_MODEL_MICREL_KSZ8081) + PHY_WRITE(sc, MII_KSZ8081_PHYCTL2, reg); +} + static int micphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { Modified: head/sys/dev/mii/miidevs ============================================================================== --- head/sys/dev/mii/miidevs Sun Apr 16 01:15:37 2017 (r316994) +++ head/sys/dev/mii/miidevs Sun Apr 16 01:40:17 2017 (r316995) @@ -282,6 +282,7 @@ model MARVELL E1000_5 0x0005 Marvell 88 model MARVELL E1111 0x000c Marvell 88E1111 Gigabit PHY /* Micrel PHYs */ +model MICREL KSZ8081 0x0016 Micrel KSZ8081 10/100 PHY model MICREL KSZ9021 0x0021 Micrel KSZ9021 10/100/1000 PHY model MICREL KSZ9031 0x0022 Micrel KSZ9031 10/100/1000 PHY From owner-svn-src-all@freebsd.org Sun Apr 16 01:50:07 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56D92D3519E; Sun, 16 Apr 2017 01:50:07 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EC01E18E6; Sun, 16 Apr 2017 01:50:06 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wm0-f42.google.com with SMTP id o81so15115916wmb.1; Sat, 15 Apr 2017 18:50:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=02nqjgniJ9dQSXb2knYaGpPLIstMh8S8IlASkZnie3g=; b=SA6fM1PT26DtqYtCxK6hm10IqEWTfZ53Xe7YAgQBbaCb5Ey0s5IM8XmbQJCw8VXxHj I4GGaJ0SkYWFAupa1q+CDoWG3m91bA02iXtE11EohF82lDi4dWxqjJClYbpp0Z+O6KGG DSE5Ko0wIBUc1wo8dCof49Z0BzjYMljIoX1kj2PDYI1h9J4e03APGXFBCylq0DTsWDoY En3jbxVWpiTt99uuDcGGA/7LXpZnj/w+xZls9aD4B9OfBh62KElsnJLJhRkU/WDjh88s qcCWqHjX53u2UpyU0l1H/7BoUJsyhs8yhU5GhwtLjdraf6H5afKuZ8xekAInl6Idbk+P FBVQ== X-Gm-Message-State: AN3rC/4Zb/kqtrt4xov4jXGvl313vaNyjpQ89ovS98RTARG0z57KKj3G 4WyqU4+ziuvOntgJTlY= X-Received: by 10.28.86.68 with SMTP id k65mr4018304wmb.112.1492307399084; Sat, 15 Apr 2017 18:49:59 -0700 (PDT) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com. [74.125.82.53]) by smtp.gmail.com with ESMTPSA id v8sm55641wrd.42.2017.04.15.18.49.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Apr 2017 18:49:59 -0700 (PDT) Received: by mail-wm0-f53.google.com with SMTP id o81so15115852wmb.1; Sat, 15 Apr 2017 18:49:58 -0700 (PDT) X-Received: by 10.28.16.148 with SMTP id 142mr3836682wmq.75.1492307398778; Sat, 15 Apr 2017 18:49:58 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.80.169.4 with HTTP; Sat, 15 Apr 2017 18:49:58 -0700 (PDT) In-Reply-To: <201704160113.v3G1DlbA028401@repo.freebsd.org> References: <201704160113.v3G1DlbA028401@repo.freebsd.org> From: Conrad Meyer Date: Sat, 15 Apr 2017 18:49:58 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r316993 - head/contrib/ipfilter/lib To: Cy Schubert Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 01:50:07 -0000 On Sat, Apr 15, 2017 at 6:13 PM, Cy Schubert wrote: > Author: cy > Date: Sun Apr 16 01:13:47 2017 > New Revision: 316993 > URL: https://svnweb.freebsd.org/changeset/base/316993 > > Log: > Fix CID 1372601, possible NULL pointer dereference should > reallocarray() fail. > > Reported by: Coverity CID 1372601 > MFC after: 1 week > > Modified: > head/contrib/ipfilter/lib/parsefields.c > > Modified: head/contrib/ipfilter/lib/parsefields.c > ============================================================================== > --- head/contrib/ipfilter/lib/parsefields.c Sat Apr 15 23:35:57 2017 (r316992) > +++ head/contrib/ipfilter/lib/parsefields.c Sun Apr 16 01:13:47 2017 (r316993) > @@ -32,6 +32,10 @@ wordtab_t *parsefields(table, arg) > fields = malloc(2 * sizeof(*fields)); > } else { > fields = reallocarray(fields, num + 1, sizeof(*fields)); > + if (fields == NULL) { > + perror("memory allocation error at __LINE__ in __FUNCTIOIN__ in __FILE__"); Hey Cy, Does this actually work? I was under the impression it wouldn't work. Instead, maybe warnx("... error at %d in %s in %s", __LINE__, __func__, __FILE__)? Best, Conrad From owner-svn-src-all@freebsd.org Sun Apr 16 03:34:42 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7860AD40799; Sun, 16 Apr 2017 03:34:42 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 25199309; Sun, 16 Apr 2017 03:34:41 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id zaxNcUaVIsa1kzaxOcitIA; Sat, 15 Apr 2017 21:34:35 -0600 X-Authority-Analysis: v=2.2 cv=W+NIbVek c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=kj9zAlcOel0A:10 a=AzvcPWV-tVgA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=zm8RW0_Aktz8uO5TyfIA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id EEEB62028; Sat, 15 Apr 2017 20:34:32 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id v3G3YWKc032550; Sat, 15 Apr 2017 20:34:32 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201704160334.v3G3YWKc032550@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: cem@freebsd.org cc: Cy Schubert , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r316993 - head/contrib/ipfilter/lib In-Reply-To: Message from Conrad Meyer of "Sat, 15 Apr 2017 18:49:58 -0700." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 15 Apr 2017 20:34:32 -0700 X-CMAE-Envelope: MS4wfIEK3Bs2fGGmEUAhrkx56psDQGGFR0XxEblyMT8zu+RC/IKX//jPvHGpPahSMuDCSz4AM7VdW0LMPmV+LWnO37oqjhRr6Crpux1h631LZCx1qvqL5ztw y1OGO85KQwGWNUsigQ9c0apMC4Rw3Cl04lJpY5qb9CZdh9JWbP0NYUofDubRmxkIdb1+HVTguhqfr213DO+VX/BaA3WFoenVaEoITUB6MGuU9RVkdaNdZ8eH PNOJg/b/206Tg1kjzkNwmeSFjMk7iVDU3IMSHBXmiCOEWPtAqXrtP62U+Gedk75/PIWjCxVrm6w6abP9bgudCw== X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 03:34:42 -0000 In message , Conrad Meyer writes: > On Sat, Apr 15, 2017 at 6:13 PM, Cy Schubert wrote: > > Author: cy > > Date: Sun Apr 16 01:13:47 2017 > > New Revision: 316993 > > URL: https://svnweb.freebsd.org/changeset/base/316993 > > > > Log: > > Fix CID 1372601, possible NULL pointer dereference should > > reallocarray() fail. > > > > Reported by: Coverity CID 1372601 > > MFC after: 1 week > > > > Modified: > > head/contrib/ipfilter/lib/parsefields.c > > > > Modified: head/contrib/ipfilter/lib/parsefields.c > > =========================================================================== > === > > --- head/contrib/ipfilter/lib/parsefields.c Sat Apr 15 23:35:57 2017 > (r316992) > > +++ head/contrib/ipfilter/lib/parsefields.c Sun Apr 16 01:13:47 2017 > (r316993) > > @@ -32,6 +32,10 @@ wordtab_t *parsefields(table, arg) > > fields = malloc(2 * sizeof(*fields)); > > } else { > > fields = reallocarray(fields, num + 1, sizeof(*fiel > ds)); > > + if (fields == NULL) { > > + perror("memory allocation error at __LINE__ > in __FUNCTIOIN__ in __FILE__"); > > Hey Cy, > > Does this actually work? I was under the impression it wouldn't work. > Instead, maybe warnx("... error at %d in %s in %s", __LINE__, > __func__, __FILE__)? You are indeed correct Conrad. My mistake. I'll fix it right away. Thanks for pointing this out. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-all@freebsd.org Sun Apr 16 03:49:15 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A713CD40E39; Sun, 16 Apr 2017 03:49:15 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5F276C29; Sun, 16 Apr 2017 03:49:15 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G3nEKj091375; Sun, 16 Apr 2017 03:49:14 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G3nEgi091374; Sun, 16 Apr 2017 03:49:14 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201704160349.v3G3nEgi091374@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 16 Apr 2017 03:49:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316996 - head/sys/dev/ffec X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 03:49:15 -0000 Author: ian Date: Sun Apr 16 03:49:14 2017 New Revision: 316996 URL: https://svnweb.freebsd.org/changeset/base/316996 Log: Add imx6ul SoC support, and get the PHY number from the FDT data. If there is no phy-handle property, fall back to using MII_PHY_ANY. This still doesn't support an mdio bus with multiple PHYs on it, or the possibility that the PHY being used by this instance of ffec is on the mdio bus of some other instance (which is now a possibility with imx6ul). Adding that support will require changes in fdt_get_phyaddr(), which is currently making some assumptions that don't work with modern fdt data. Modified: head/sys/dev/ffec/if_ffec.c Modified: head/sys/dev/ffec/if_ffec.c ============================================================================== --- head/sys/dev/ffec/if_ffec.c Sun Apr 16 01:40:17 2017 (r316995) +++ head/sys/dev/ffec/if_ffec.c Sun Apr 16 03:49:14 2017 (r316996) @@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -113,6 +114,7 @@ static struct ofw_compat_data compat_dat {"fsl,imx51-fec", FECTYPE_GENERIC}, {"fsl,imx53-fec", FECTYPE_IMX53}, {"fsl,imx6q-fec", FECTYPE_IMX6 | FECFLAG_GBE}, + {"fsl,imx6ul-fec", FECTYPE_IMX6}, {"fsl,mvf600-fec", FECTYPE_MVF}, {"fsl,mvf-fec", FECTYPE_MVF}, {NULL, FECTYPE_NONE}, @@ -1424,8 +1426,9 @@ ffec_attach(device_t dev) struct ffec_softc *sc; struct ifnet *ifp = NULL; struct mbuf *m; + void *dummy; phandle_t ofw_node; - int error, rid; + int error, phynum, rid; uint8_t eaddr[ETHER_ADDR_LEN]; char phy_conn_name[32]; uint32_t idx, mscr; @@ -1695,8 +1698,11 @@ ffec_attach(device_t dev) ffec_miigasket_setup(sc); /* Attach the mii driver. */ + if (fdt_get_phyaddr(ofw_node, dev, &phynum, &dummy) != 0) { + phynum = MII_PHY_ANY; + } error = mii_attach(dev, &sc->miibus, ifp, ffec_media_change, - ffec_media_status, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, + ffec_media_status, BMSR_DEFCAPMASK, phynum, MII_OFFSET_ANY, (sc->fectype & FECTYPE_MVF) ? MIIF_FORCEANEG : 0); if (error != 0) { device_printf(dev, "PHY attach failed\n"); From owner-svn-src-all@freebsd.org Sun Apr 16 04:36:23 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 60E8AD40EC2; Sun, 16 Apr 2017 04:36:23 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 279D5355; Sun, 16 Apr 2017 04:36:23 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G4aM3S011471; Sun, 16 Apr 2017 04:36:22 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G4aMtX011469; Sun, 16 Apr 2017 04:36:22 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201704160436.v3G4aMtX011469@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 16 Apr 2017 04:36:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316997 - in head/contrib/ipfilter: lib tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 04:36:23 -0000 Author: cy Date: Sun Apr 16 04:36:22 2017 New Revision: 316997 URL: https://svnweb.freebsd.org/changeset/base/316997 Log: Use warnx() to issue error message. Reported by: cem MFC after: 1 week X-MFC with: r316993, r316994 Modified: head/contrib/ipfilter/lib/parsefields.c head/contrib/ipfilter/tools/ipf_y.y Modified: head/contrib/ipfilter/lib/parsefields.c ============================================================================== --- head/contrib/ipfilter/lib/parsefields.c Sun Apr 16 03:49:14 2017 (r316996) +++ head/contrib/ipfilter/lib/parsefields.c Sun Apr 16 04:36:22 2017 (r316997) @@ -1,4 +1,5 @@ #include "ipf.h" +#include extern int nohdrfields; @@ -33,7 +34,7 @@ wordtab_t *parsefields(table, arg) } else { fields = reallocarray(fields, num + 1, sizeof(*fields)); if (fields == NULL) { - perror("memory allocation error at __LINE__ in __FUNCTIOIN__ in __FILE__"); + warnx("memory allocation error at %d in %s in %s", __LINE__, __FUNCTION__, __FILE__); abort(); } } Modified: head/contrib/ipfilter/tools/ipf_y.y ============================================================================== --- head/contrib/ipfilter/tools/ipf_y.y Sun Apr 16 03:49:14 2017 (r316996) +++ head/contrib/ipfilter/tools/ipf_y.y Sun Apr 16 04:36:22 2017 (r316997) @@ -9,6 +9,7 @@ #include "ipf.h" #include #include +#include #ifdef IPFILTER_BPF # include #endif @@ -2196,7 +2197,7 @@ char *phrase; s = strtok(NULL, " \r\n\t"), i++) { fb = reallocarray(fb, i / 4 + 1, sizeof(*fb)); if (fb == NULL) { - perror("memory allocation error at __LINE__ in __FUNCTION__ in __FILE"); + warnx("memory allocation error at %d in %s in %s", __LINE__, __FUNCTION__, __FILE__); abort(); } l = (u_32_t)strtol(s, NULL, 0); From owner-svn-src-all@freebsd.org Sun Apr 16 05:14:44 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72C74D40760; Sun, 16 Apr 2017 05:14:44 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 342465E2; Sun, 16 Apr 2017 05:14:44 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G5Ehsx027561; Sun, 16 Apr 2017 05:14:43 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G5EhKp027557; Sun, 16 Apr 2017 05:14:43 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160514.v3G5EhKp027557@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 05:14:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r316998 - in stable/11: contrib/compiler-rt/lib/builtins lib/libc/arm/aeabi X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 05:14:44 -0000 Author: mmel Date: Sun Apr 16 05:14:42 2017 New Revision: 316998 URL: https://svnweb.freebsd.org/changeset/base/316998 Log: MFC r313823,r313866: r313823: Pull in r285478 from upstream compiler-rt trunk (by Saleem Abdulrasool): r313866: Publish __aeabi_uidiv and __aeabi_idiv as compatible symbols from libc. Added: stable/11/lib/libc/arm/aeabi/aeabi_int_div.S - copied unchanged from r313866, head/lib/libc/arm/aeabi/aeabi_int_div.S Modified: stable/11/contrib/compiler-rt/lib/builtins/assembly.h stable/11/lib/libc/arm/aeabi/Makefile.inc stable/11/lib/libc/arm/aeabi/Symbol.map Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/compiler-rt/lib/builtins/assembly.h ============================================================================== --- stable/11/contrib/compiler-rt/lib/builtins/assembly.h Sun Apr 16 04:36:22 2017 (r316997) +++ stable/11/contrib/compiler-rt/lib/builtins/assembly.h Sun Apr 16 05:14:42 2017 (r316998) @@ -164,6 +164,7 @@ #define DEFINE_COMPILERRT_FUNCTION_ALIAS(name, target) \ .globl SYMBOL_NAME(name) SEPARATOR \ SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ + DECLARE_SYMBOL_VISIBILITY(SYMBOL_NAME(name)) SEPARATOR \ .set SYMBOL_NAME(name), SYMBOL_NAME(target) SEPARATOR #if defined(__ARM_EABI__) Modified: stable/11/lib/libc/arm/aeabi/Makefile.inc ============================================================================== --- stable/11/lib/libc/arm/aeabi/Makefile.inc Sun Apr 16 04:36:22 2017 (r316997) +++ stable/11/lib/libc/arm/aeabi/Makefile.inc Sun Apr 16 05:14:42 2017 (r316998) @@ -28,5 +28,6 @@ SRCS+= aeabi_memcmp.S \ aeabi_memmove.S \ aeabi_memset.S -SYM_MAPS+=${LIBC_SRCTOP}/arm/aeabi/Symbol.map +SRCS+= aeabi_int_div.S +SYM_MAPS+=${LIBC_SRCTOP}/arm/aeabi/Symbol.map Modified: stable/11/lib/libc/arm/aeabi/Symbol.map ============================================================================== --- stable/11/lib/libc/arm/aeabi/Symbol.map Sun Apr 16 04:36:22 2017 (r316997) +++ stable/11/lib/libc/arm/aeabi/Symbol.map Sun Apr 16 05:14:42 2017 (r316998) @@ -69,4 +69,11 @@ FBSDprivate_1.0 { __aeabi_memset; __aeabi_memset4; __aeabi_memset8; + + /* + * A workaround for DEFINE_AEABI_FUNCTION_ALIAS() bug. + * - see aeabi_int_div.S + */ + __aeabi_idiv; + __aeabi_uidiv; }; Copied: stable/11/lib/libc/arm/aeabi/aeabi_int_div.S (from r313866, head/lib/libc/arm/aeabi/aeabi_int_div.S) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/lib/libc/arm/aeabi/aeabi_int_div.S Sun Apr 16 05:14:42 2017 (r316998, copy of r313866, head/lib/libc/arm/aeabi/aeabi_int_div.S) @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2017 Michal Meloun + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * Due to bug in libcompiler_rt, all symbols declared by + * DEFINE_AEABI_FUNCTION_ALIAS() are not hidden. All these but + * __aeabi_uidiv_compat and/or __aeabi_idiv_compat are explicitly + * exported from libc and don't causes problems. + * + * As workaround, export these from libc as compatible symbols, + * in global namespace + */ + +ENTRY(__aeabi_uidiv_compat) + .symver __aeabi_uidiv_compat, __aeabi_uidiv@ + b __udivsi3 +END(__aeabi_uidiv_compat) + +ENTRY(__aeabi_idiv_compat) + .symver __aeabi_idiv_compat, __aeabi_idiv@ + b __divsi3 +END(__aeabi_idiv_compat) + + .section .note.GNU-stack,"",%progbits From owner-svn-src-all@freebsd.org Sun Apr 16 05:17:49 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF015D40894; Sun, 16 Apr 2017 05:17:49 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7E4A3841; Sun, 16 Apr 2017 05:17:49 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G5HmVP027731; Sun, 16 Apr 2017 05:17:48 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G5HmKx027730; Sun, 16 Apr 2017 05:17:48 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160517.v3G5HmKx027730@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 05:17:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r316999 - stable/11/lib/libc/arm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 05:17:49 -0000 Author: mmel Date: Sun Apr 16 05:17:48 2017 New Revision: 316999 URL: https://svnweb.freebsd.org/changeset/base/316999 Log: MFC r313873: Publish fp[get][set]sticky() for ARMv6. Modified: stable/11/lib/libc/arm/Symbol_vfp.map Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/arm/Symbol_vfp.map ============================================================================== --- stable/11/lib/libc/arm/Symbol_vfp.map Sun Apr 16 05:14:42 2017 (r316998) +++ stable/11/lib/libc/arm/Symbol_vfp.map Sun Apr 16 05:17:48 2017 (r316999) @@ -8,3 +8,8 @@ FBSD_1.0 { fpsetmask; fpsetround; }; + +FBSD_1.5 { + fpgetsticky; + fpsetsticky; +}; From owner-svn-src-all@freebsd.org Sun Apr 16 05:59:30 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4E06D40304; Sun, 16 Apr 2017 05:59:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9A1C7AEC; Sun, 16 Apr 2017 05:59:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G5xTUq043945; Sun, 16 Apr 2017 05:59:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G5xTKV043944; Sun, 16 Apr 2017 05:59:29 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704160559.v3G5xTKV043944@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 16 Apr 2017 05:59:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317000 - stable/11/usr.sbin/bhyve X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 05:59:31 -0000 Author: mav Date: Sun Apr 16 05:59:29 2017 New Revision: 317000 URL: https://svnweb.freebsd.org/changeset/base/317000 Log: MFC r316427, r316428: Add Log directory and SATA NCQ Send and Receive Log. Those are used at least by Linux guests to detect queued TRIM support. Modified: stable/11/usr.sbin/bhyve/pci_ahci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- stable/11/usr.sbin/bhyve/pci_ahci.c Sun Apr 16 05:17:48 2017 (r316999) +++ stable/11/usr.sbin/bhyve/pci_ahci.c Sun Apr 16 05:59:29 2017 (r317000) @@ -932,19 +932,36 @@ static void ahci_handle_read_log(struct ahci_port *p, int slot, uint8_t *cfis) { struct ahci_cmd_hdr *hdr; - uint8_t buf[512]; + uint32_t buf[128]; + uint8_t *buf8 = (uint8_t *)buf; + uint16_t *buf16 = (uint16_t *)buf; hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); - if (p->atapi || hdr->prdtl == 0 || cfis[4] != 0x10 || - cfis[5] != 0 || cfis[9] != 0 || cfis[12] != 1 || cfis[13] != 0) { + if (p->atapi || hdr->prdtl == 0 || cfis[5] != 0 || + cfis[9] != 0 || cfis[12] != 1 || cfis[13] != 0) { ahci_write_fis_d2h(p, slot, cfis, (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); return; } memset(buf, 0, sizeof(buf)); - memcpy(buf, p->err_cfis, sizeof(p->err_cfis)); - ahci_checksum(buf, sizeof(buf)); + if (cfis[4] == 0x00) { /* Log directory */ + buf16[0x00] = 1; /* Version -- 1 */ + buf16[0x10] = 1; /* NCQ Command Error Log -- 1 page */ + buf16[0x13] = 1; /* SATA NCQ Send and Receive Log -- 1 page */ + } else if (cfis[4] == 0x10) { /* NCQ Command Error Log */ + memcpy(buf8, p->err_cfis, sizeof(p->err_cfis)); + ahci_checksum(buf8, sizeof(buf)); + } else if (cfis[4] == 0x13) { /* SATA NCQ Send and Receive Log */ + if (blockif_candelete(p->bctx) && !blockif_is_ro(p->bctx)) { + buf[0x00] = 1; /* SFQ DSM supported */ + buf[0x01] = 1; /* SFQ DSM TRIM supported */ + } + } else { + ahci_write_fis_d2h(p, slot, cfis, + (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); + return; + } if (cfis[2] == ATA_READ_LOG_EXT) ahci_write_fis_piosetup(p); From owner-svn-src-all@freebsd.org Sun Apr 16 06:00:15 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6882BD4038E; Sun, 16 Apr 2017 06:00:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 2050BC3D; Sun, 16 Apr 2017 06:00:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G60E25044077; Sun, 16 Apr 2017 06:00:14 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G60EBi044076; Sun, 16 Apr 2017 06:00:14 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704160600.v3G60EBi044076@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 16 Apr 2017 06:00:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r317001 - stable/10/usr.sbin/bhyve X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 06:00:15 -0000 Author: mav Date: Sun Apr 16 06:00:14 2017 New Revision: 317001 URL: https://svnweb.freebsd.org/changeset/base/317001 Log: MFC r316427, r316428: Add Log directory and SATA NCQ Send and Receive Log. Those are used at least by Linux guests to detect queued TRIM support. Modified: stable/10/usr.sbin/bhyve/pci_ahci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- stable/10/usr.sbin/bhyve/pci_ahci.c Sun Apr 16 05:59:29 2017 (r317000) +++ stable/10/usr.sbin/bhyve/pci_ahci.c Sun Apr 16 06:00:14 2017 (r317001) @@ -936,19 +936,36 @@ static void ahci_handle_read_log(struct ahci_port *p, int slot, uint8_t *cfis) { struct ahci_cmd_hdr *hdr; - uint8_t buf[512]; + uint32_t buf[128]; + uint8_t *buf8 = (uint8_t *)buf; + uint16_t *buf16 = (uint16_t *)buf; hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); - if (p->atapi || hdr->prdtl == 0 || cfis[4] != 0x10 || - cfis[5] != 0 || cfis[9] != 0 || cfis[12] != 1 || cfis[13] != 0) { + if (p->atapi || hdr->prdtl == 0 || cfis[5] != 0 || + cfis[9] != 0 || cfis[12] != 1 || cfis[13] != 0) { ahci_write_fis_d2h(p, slot, cfis, (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); return; } memset(buf, 0, sizeof(buf)); - memcpy(buf, p->err_cfis, sizeof(p->err_cfis)); - ahci_checksum(buf, sizeof(buf)); + if (cfis[4] == 0x00) { /* Log directory */ + buf16[0x00] = 1; /* Version -- 1 */ + buf16[0x10] = 1; /* NCQ Command Error Log -- 1 page */ + buf16[0x13] = 1; /* SATA NCQ Send and Receive Log -- 1 page */ + } else if (cfis[4] == 0x10) { /* NCQ Command Error Log */ + memcpy(buf8, p->err_cfis, sizeof(p->err_cfis)); + ahci_checksum(buf8, sizeof(buf)); + } else if (cfis[4] == 0x13) { /* SATA NCQ Send and Receive Log */ + if (blockif_candelete(p->bctx) && !blockif_is_ro(p->bctx)) { + buf[0x00] = 1; /* SFQ DSM supported */ + buf[0x01] = 1; /* SFQ DSM TRIM supported */ + } + } else { + ahci_write_fis_d2h(p, slot, cfis, + (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); + return; + } if (cfis[2] == ATA_READ_LOG_EXT) ahci_write_fis_piosetup(p); From owner-svn-src-all@freebsd.org Sun Apr 16 06:35:10 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1732D40EE8; Sun, 16 Apr 2017 06:35:10 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B2C225DF; Sun, 16 Apr 2017 06:35:10 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G6Z9wB060870; Sun, 16 Apr 2017 06:35:09 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G6Z9J4060866; Sun, 16 Apr 2017 06:35:09 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160635.v3G6Z9J4060866@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 06:35:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317002 - in stable/11/sys/arm: arm include X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 06:35:11 -0000 Author: mmel Date: Sun Apr 16 06:35:09 2017 New Revision: 317002 URL: https://svnweb.freebsd.org/changeset/base/317002 Log: MFC r306631,r306640,r306641,r306650,r306656: r306631: Use C99 designated initializers to create the armv6 cpu_functions structs. This will help with a later cleanup of what functions we implement. r306640: Only define the CF_* macros on ARMv4/v5. They are unused on armv6. r306641: Remove the parts of cpu_functions from armv6 that are unused on that architecture. r306650: Add the Cortex-A{53,57,72} ID register values. These can all run 32-bit code so could run a 32-bit kernel. r306656: Use the cortex functions when booting on one of the Cortex-A ARMv8 CPUs. This list is incomplete, however we don't have the ID values for the missing Cortex-A32 or A35. Modified: stable/11/sys/arm/arm/cpufunc.c stable/11/sys/arm/arm/genassym.c stable/11/sys/arm/include/armreg.h stable/11/sys/arm/include/cpufunc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/cpufunc.c ============================================================================== --- stable/11/sys/arm/arm/cpufunc.c Sun Apr 16 06:00:14 2017 (r317001) +++ stable/11/sys/arm/arm/cpufunc.c Sun Apr 16 06:35:09 2017 (r317002) @@ -241,50 +241,23 @@ struct cpu_functions sheeva_cpufuncs = { #ifdef CPU_MV_PJ4B struct cpu_functions pj4bv7_cpufuncs = { - /* CPU functions */ - - armv7_drain_writebuf, /* cpwait */ - /* MMU functions */ - - cpufunc_control, /* control */ - armv7_setttb, /* Setttb */ - - /* TLB functions */ - - armv7_tlb_flushID, /* tlb_flushID */ - armv7_tlb_flushID_SE, /* tlb_flushID_SE */ - armv7_tlb_flushID, /* tlb_flushD */ - armv7_tlb_flushID_SE, /* tlb_flushD_SE */ + .cf_control = cpufunc_control, + .cf_setttb = armv7_setttb, /* Cache operations */ - armv7_icache_sync_range, /* icache_sync_range */ - - armv7_dcache_wbinv_all, /* dcache_wbinv_all */ - armv7_dcache_wbinv_range, /* dcache_wbinv_range */ - armv7_dcache_inv_range, /* dcache_inv_range */ - armv7_dcache_wb_range, /* dcache_wb_range */ - - armv7_idcache_inv_all, /* idcache_inv_all */ - armv7_idcache_wbinv_all, /* idcache_wbinv_all */ - armv7_idcache_wbinv_range, /* idcache_wbinv_all */ - - (void *)cpufunc_nullop, /* l2cache_wbinv_all */ - (void *)cpufunc_nullop, /* l2cache_wbinv_range */ - (void *)cpufunc_nullop, /* l2cache_inv_range */ - (void *)cpufunc_nullop, /* l2cache_wb_range */ - (void *)cpufunc_nullop, /* l2cache_drain_writebuf */ + .cf_l2cache_wbinv_all = (void *)cpufunc_nullop, + .cf_l2cache_wbinv_range = (void *)cpufunc_nullop, + .cf_l2cache_inv_range = (void *)cpufunc_nullop, + .cf_l2cache_wb_range = (void *)cpufunc_nullop, + .cf_l2cache_drain_writebuf = (void *)cpufunc_nullop, /* Other functions */ - - armv7_drain_writebuf, /* drain_writebuf */ - - (void *)cpufunc_nullop, /* sleep */ + .cf_drain_writebuf = armv7_drain_writebuf, + .cf_sleep = (void *)cpufunc_nullop, /* Soft functions */ - armv7_context_switch, /* context_switch */ - - pj4bv7_setup /* cpu setup */ + .cf_setup = pj4bv7_setup }; #endif /* CPU_MV_PJ4B */ @@ -444,111 +417,50 @@ struct cpu_functions fa526_cpufuncs = { #if defined(CPU_ARM1176) struct cpu_functions arm1176_cpufuncs = { - /* CPU functions */ - - cpufunc_nullop, /* cpwait */ - /* MMU functions */ - - cpufunc_control, /* control */ - arm11x6_setttb, /* Setttb */ - - /* TLB functions */ - - arm11_tlb_flushID, /* tlb_flushID */ - arm11_tlb_flushID_SE, /* tlb_flushID_SE */ - arm11_tlb_flushD, /* tlb_flushD */ - arm11_tlb_flushD_SE, /* tlb_flushD_SE */ + .cf_control = cpufunc_control, + .cf_setttb = arm11x6_setttb, /* Cache operations */ - - arm11x6_icache_sync_range, /* icache_sync_range */ - - arm11x6_dcache_wbinv_all, /* dcache_wbinv_all */ - armv6_dcache_wbinv_range, /* dcache_wbinv_range */ - armv6_dcache_inv_range, /* dcache_inv_range */ - armv6_dcache_wb_range, /* dcache_wb_range */ - - armv6_idcache_inv_all, /* idcache_inv_all */ - arm11x6_idcache_wbinv_all, /* idcache_wbinv_all */ - arm11x6_idcache_wbinv_range, /* idcache_wbinv_range */ - - (void *)cpufunc_nullop, /* l2cache_wbinv_all */ - (void *)cpufunc_nullop, /* l2cache_wbinv_range */ - (void *)cpufunc_nullop, /* l2cache_inv_range */ - (void *)cpufunc_nullop, /* l2cache_wb_range */ - (void *)cpufunc_nullop, /* l2cache_drain_writebuf */ + .cf_l2cache_wbinv_all = (void *)cpufunc_nullop, + .cf_l2cache_wbinv_range = (void *)cpufunc_nullop, + .cf_l2cache_inv_range = (void *)cpufunc_nullop, + .cf_l2cache_wb_range = (void *)cpufunc_nullop, + .cf_l2cache_drain_writebuf = (void *)cpufunc_nullop, /* Other functions */ - - arm11_drain_writebuf, /* drain_writebuf */ - - arm11x6_sleep, /* sleep */ + .cf_drain_writebuf = arm11_drain_writebuf, + .cf_sleep = arm11x6_sleep, /* Soft functions */ - - arm11_context_switch, /* context_switch */ - - arm11x6_setup /* cpu setup */ + .cf_setup = arm11x6_setup }; #endif /*CPU_ARM1176 */ #if defined(CPU_CORTEXA) || defined(CPU_KRAIT) struct cpu_functions cortexa_cpufuncs = { - /* CPU functions */ - - cpufunc_nullop, /* cpwait */ - /* MMU functions */ - - cpufunc_control, /* control */ - armv7_setttb, /* Setttb */ - - /* - * TLB functions. ARMv7 does all TLB ops based on a unified TLB model - * whether the hardware implements separate I+D or not, so we use the - * same 'ID' functions for all 3 variations. - */ - - armv7_tlb_flushID, /* tlb_flushID */ - armv7_tlb_flushID_SE, /* tlb_flushID_SE */ - armv7_tlb_flushID, /* tlb_flushD */ - armv7_tlb_flushID_SE, /* tlb_flushD_SE */ + .cf_control = cpufunc_control, + .cf_setttb = armv7_setttb, /* Cache operations */ - armv7_icache_sync_range, /* icache_sync_range */ - - armv7_dcache_wbinv_all, /* dcache_wbinv_all */ - armv7_dcache_wbinv_range, /* dcache_wbinv_range */ - armv7_dcache_inv_range, /* dcache_inv_range */ - armv7_dcache_wb_range, /* dcache_wb_range */ - - armv7_idcache_inv_all, /* idcache_inv_all */ - armv7_idcache_wbinv_all, /* idcache_wbinv_all */ - armv7_idcache_wbinv_range, /* idcache_wbinv_range */ - /* * Note: For CPUs using the PL310 the L2 ops are filled in when the * L2 cache controller is actually enabled. */ - cpufunc_nullop, /* l2cache_wbinv_all */ - (void *)cpufunc_nullop, /* l2cache_wbinv_range */ - (void *)cpufunc_nullop, /* l2cache_inv_range */ - (void *)cpufunc_nullop, /* l2cache_wb_range */ - (void *)cpufunc_nullop, /* l2cache_drain_writebuf */ + .cf_l2cache_wbinv_all = cpufunc_nullop, + .cf_l2cache_wbinv_range = (void *)cpufunc_nullop, + .cf_l2cache_inv_range = (void *)cpufunc_nullop, + .cf_l2cache_wb_range = (void *)cpufunc_nullop, + .cf_l2cache_drain_writebuf = (void *)cpufunc_nullop, /* Other functions */ - - armv7_drain_writebuf, /* drain_writebuf */ - - armv7_cpu_sleep, /* sleep */ + .cf_drain_writebuf = armv7_drain_writebuf, + .cf_sleep = armv7_cpu_sleep, /* Soft functions */ - - armv7_context_switch, /* context_switch */ - - cortexa_setup /* cpu setup */ + .cf_setup = cortexa_setup }; #endif /* CPU_CORTEXA */ @@ -767,6 +679,9 @@ set_cpufuncs(void) case CPU_ID_CORTEXA9: case CPU_ID_CORTEXA12: case CPU_ID_CORTEXA15: + case CPU_ID_CORTEXA53: + case CPU_ID_CORTEXA57: + case CPU_ID_CORTEXA72: case CPU_ID_KRAIT300: cpufuncs = cortexa_cpufuncs; get_cachetype_cp15(); Modified: stable/11/sys/arm/arm/genassym.c ============================================================================== --- stable/11/sys/arm/arm/genassym.c Sun Apr 16 06:00:14 2017 (r317001) +++ stable/11/sys/arm/arm/genassym.c Sun Apr 16 06:35:09 2017 (r317002) @@ -92,11 +92,13 @@ ASSYM(M_DATA, offsetof(struct mbuf, m_da ASSYM(M_NEXT, offsetof(struct mbuf, m_next)); ASSYM(IP_SRC, offsetof(struct ip, ip_src)); ASSYM(IP_DST, offsetof(struct ip, ip_dst)); +#if __ARM_ARCH < 6 ASSYM(CF_CONTEXT_SWITCH, offsetof(struct cpu_functions, cf_context_switch)); ASSYM(CF_DCACHE_WB_RANGE, offsetof(struct cpu_functions, cf_dcache_wb_range)); ASSYM(CF_IDCACHE_WBINV_ALL, offsetof(struct cpu_functions, cf_idcache_wbinv_all)); ASSYM(CF_L2CACHE_WBINV_ALL, offsetof(struct cpu_functions, cf_l2cache_wbinv_all)); ASSYM(CF_TLB_FLUSHID_SE, offsetof(struct cpu_functions, cf_tlb_flushID_SE)); +#endif ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); Modified: stable/11/sys/arm/include/armreg.h ============================================================================== --- stable/11/sys/arm/include/armreg.h Sun Apr 16 06:00:14 2017 (r317001) +++ stable/11/sys/arm/include/armreg.h Sun Apr 16 06:35:09 2017 (r317002) @@ -152,6 +152,9 @@ #define CPU_ID_CORTEXA15R1 (CPU_ID_CORTEXA15 | (1 << CPU_ID_VARIANT_SHIFT)) #define CPU_ID_CORTEXA15R2 (CPU_ID_CORTEXA15 | (2 << CPU_ID_VARIANT_SHIFT)) #define CPU_ID_CORTEXA15R3 (CPU_ID_CORTEXA15 | (3 << CPU_ID_VARIANT_SHIFT)) +#define CPU_ID_CORTEXA53 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xd030) +#define CPU_ID_CORTEXA57 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xd070) +#define CPU_ID_CORTEXA72 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xd080) #define CPU_ID_KRAIT300 (CPU_ID_QUALCOM | CPU_ID_CPUID_SCHEME | 0x06f0) /* Snapdragon S4 Pro/APQ8064 */ Modified: stable/11/sys/arm/include/cpufunc.h ============================================================================== --- stable/11/sys/arm/include/cpufunc.h Sun Apr 16 06:00:14 2017 (r317001) +++ stable/11/sys/arm/include/cpufunc.h Sun Apr 16 06:35:09 2017 (r317002) @@ -58,14 +58,16 @@ breakpoint(void) struct cpu_functions { /* CPU functions */ - +#if __ARM_ARCH < 6 void (*cf_cpwait) (void); +#endif /* MMU functions */ u_int (*cf_control) (u_int bic, u_int eor); void (*cf_setttb) (u_int ttb); +#if __ARM_ARCH < 6 /* TLB functions */ void (*cf_tlb_flushID) (void); @@ -138,6 +140,7 @@ struct cpu_functions { void (*cf_idcache_inv_all) (void); void (*cf_idcache_wbinv_all) (void); void (*cf_idcache_wbinv_range) (vm_offset_t, vm_size_t); +#endif void (*cf_l2cache_wbinv_all) (void); void (*cf_l2cache_wbinv_range) (vm_offset_t, vm_size_t); void (*cf_l2cache_inv_range) (vm_offset_t, vm_size_t); @@ -150,9 +153,11 @@ struct cpu_functions { void (*cf_sleep) (int mode); +#if __ARM_ARCH < 6 /* Soft functions */ void (*cf_context_switch) (void); +#endif void (*cf_setup) (void); }; From owner-svn-src-all@freebsd.org Sun Apr 16 06:51:07 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C962DD403D2; Sun, 16 Apr 2017 06:51:07 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A4855E07; Sun, 16 Apr 2017 06:51:07 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G6p6OX065221; Sun, 16 Apr 2017 06:51:06 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G6p6NL065218; Sun, 16 Apr 2017 06:51:06 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160651.v3G6p6NL065218@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 06:51:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317003 - in stable/11/sys/arm: arm include X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 06:51:07 -0000 Author: mmel Date: Sun Apr 16 06:51:06 2017 New Revision: 317003 URL: https://svnweb.freebsd.org/changeset/base/317003 Log: MFC r306704,r308406: r306704: ARM: Remove next bunch of unused cpu_functions from ARMv6. r308406: Only include sys/boot.h if LINUX_BOOT_ABI is defined Modified: stable/11/sys/arm/arm/cpufunc.c stable/11/sys/arm/arm/machdep.c stable/11/sys/arm/include/cpufunc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/cpufunc.c ============================================================================== --- stable/11/sys/arm/arm/cpufunc.c Sun Apr 16 06:35:09 2017 (r317002) +++ stable/11/sys/arm/arm/cpufunc.c Sun Apr 16 06:51:06 2017 (r317003) @@ -241,9 +241,6 @@ struct cpu_functions sheeva_cpufuncs = { #ifdef CPU_MV_PJ4B struct cpu_functions pj4bv7_cpufuncs = { - /* MMU functions */ - .cf_control = cpufunc_control, - .cf_setttb = armv7_setttb, /* Cache operations */ .cf_l2cache_wbinv_all = (void *)cpufunc_nullop, @@ -253,7 +250,6 @@ struct cpu_functions pj4bv7_cpufuncs = { .cf_l2cache_drain_writebuf = (void *)cpufunc_nullop, /* Other functions */ - .cf_drain_writebuf = armv7_drain_writebuf, .cf_sleep = (void *)cpufunc_nullop, /* Soft functions */ @@ -417,9 +413,6 @@ struct cpu_functions fa526_cpufuncs = { #if defined(CPU_ARM1176) struct cpu_functions arm1176_cpufuncs = { - /* MMU functions */ - .cf_control = cpufunc_control, - .cf_setttb = arm11x6_setttb, /* Cache operations */ .cf_l2cache_wbinv_all = (void *)cpufunc_nullop, @@ -429,7 +422,6 @@ struct cpu_functions arm1176_cpufuncs = .cf_l2cache_drain_writebuf = (void *)cpufunc_nullop, /* Other functions */ - .cf_drain_writebuf = arm11_drain_writebuf, .cf_sleep = arm11x6_sleep, /* Soft functions */ @@ -439,9 +431,6 @@ struct cpu_functions arm1176_cpufuncs = #if defined(CPU_CORTEXA) || defined(CPU_KRAIT) struct cpu_functions cortexa_cpufuncs = { - /* MMU functions */ - .cf_control = cpufunc_control, - .cf_setttb = armv7_setttb, /* Cache operations */ @@ -456,7 +445,6 @@ struct cpu_functions cortexa_cpufuncs = .cf_l2cache_drain_writebuf = (void *)cpufunc_nullop, /* Other functions */ - .cf_drain_writebuf = armv7_drain_writebuf, .cf_sleep = armv7_cpu_sleep, /* Soft functions */ Modified: stable/11/sys/arm/arm/machdep.c ============================================================================== --- stable/11/sys/arm/arm/machdep.c Sun Apr 16 06:35:09 2017 (r317002) +++ stable/11/sys/arm/arm/machdep.c Sun Apr 16 06:51:06 2017 (r317003) @@ -76,7 +76,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#if defined(LINUX_BOOT_ABI) #include +#endif #include #include #include @@ -412,7 +414,7 @@ arm_vector_init(vm_offset_t va, int whic icache_sync(va, (ARM_NVEC * 2) * sizeof(u_int)); vector_page = va; - +#if __ARM_ARCH < 6 if (va == ARM_VECTORS_HIGH) { /* * Enable high vectors in the system control reg (SCTLR). @@ -427,6 +429,7 @@ arm_vector_init(vm_offset_t va, int whic */ cpu_control(CPU_CONTROL_VECRELOC, CPU_CONTROL_VECRELOC); } +#endif } static void Modified: stable/11/sys/arm/include/cpufunc.h ============================================================================== --- stable/11/sys/arm/include/cpufunc.h Sun Apr 16 06:35:09 2017 (r317002) +++ stable/11/sys/arm/include/cpufunc.h Sun Apr 16 06:51:06 2017 (r317003) @@ -60,14 +60,12 @@ struct cpu_functions { /* CPU functions */ #if __ARM_ARCH < 6 void (*cf_cpwait) (void); -#endif /* MMU functions */ u_int (*cf_control) (u_int bic, u_int eor); void (*cf_setttb) (u_int ttb); -#if __ARM_ARCH < 6 /* TLB functions */ void (*cf_tlb_flushID) (void); @@ -149,7 +147,9 @@ struct cpu_functions { /* Other functions */ +#if __ARM_ARCH < 6 void (*cf_drain_writebuf) (void); +#endif void (*cf_sleep) (int mode); From owner-svn-src-all@freebsd.org Sun Apr 16 07:21:22 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 577FED40A72; Sun, 16 Apr 2017 07:21:22 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 25B9CCC8; Sun, 16 Apr 2017 07:21:22 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G7LL3e080339; Sun, 16 Apr 2017 07:21:21 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G7LLb6080335; Sun, 16 Apr 2017 07:21:21 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160721.v3G7LLb6080335@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 07:21:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317004 - in stable/11/sys: amd64/amd64 amd64/include/pc arm/arm arm/at91 arm/include arm64/arm64 conf i386/include/pc sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 07:21:22 -0000 Author: mmel Date: Sun Apr 16 07:21:20 2017 New Revision: 317004 URL: https://svnweb.freebsd.org/changeset/base/317004 Log: MFC r303261,r315059: r303261: Add more UEFI/e820 memory types from latest specifications. r315059: Split overbloated machep.c to multiple files and do basic cleanup of these fragments. Added: stable/11/sys/arm/arm/machdep_boot.c - copied unchanged from r315059, head/sys/arm/arm/machdep_boot.c stable/11/sys/arm/arm/machdep_kdb.c - copied unchanged from r315059, head/sys/arm/arm/machdep_kdb.c stable/11/sys/arm/arm/machdep_ptrace.c - copied unchanged from r315059, head/sys/arm/arm/machdep_ptrace.c Modified: stable/11/sys/amd64/amd64/machdep.c stable/11/sys/amd64/include/pc/bios.h stable/11/sys/arm/arm/machdep.c stable/11/sys/arm/at91/at91_machdep.c stable/11/sys/arm/include/machdep.h stable/11/sys/arm64/arm64/machdep.c stable/11/sys/conf/files.arm stable/11/sys/i386/include/pc/bios.h stable/11/sys/sys/efi.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/machdep.c ============================================================================== --- stable/11/sys/amd64/amd64/machdep.c Sun Apr 16 06:51:06 2017 (r317003) +++ stable/11/sys/amd64/amd64/machdep.c Sun Apr 16 07:21:20 2017 (r317004) @@ -1086,7 +1086,8 @@ add_efi_map_entries(struct efi_map_heade "ACPIMemoryNVS", "MemoryMappedIO", "MemoryMappedIOPortSpace", - "PalCode" + "PalCode", + "PersistentMemory" }; /* @@ -1107,7 +1108,7 @@ add_efi_map_entries(struct efi_map_heade for (i = 0, p = map; i < ndesc; i++, p = efi_next_descriptor(p, efihdr->descriptor_size)) { if (boothowto & RB_VERBOSE) { - if (p->md_type <= EFI_MD_TYPE_PALCODE) + if (p->md_type < nitems(types)) type = types[p->md_type]; else type = ""; @@ -1129,6 +1130,12 @@ add_efi_map_entries(struct efi_map_heade printf("RP "); if (p->md_attr & EFI_MD_ATTR_XP) printf("XP "); + if (p->md_attr & EFI_MD_ATTR_NV) + printf("NV "); + if (p->md_attr & EFI_MD_ATTR_MORE_RELIABLE) + printf("MORE_RELIABLE "); + if (p->md_attr & EFI_MD_ATTR_RO) + printf("RO "); if (p->md_attr & EFI_MD_ATTR_RT) printf("RUNTIME"); printf("\n"); Modified: stable/11/sys/amd64/include/pc/bios.h ============================================================================== --- stable/11/sys/amd64/include/pc/bios.h Sun Apr 16 06:51:06 2017 (r317003) +++ stable/11/sys/amd64/include/pc/bios.h Sun Apr 16 07:21:20 2017 (r317004) @@ -40,6 +40,9 @@ #define SMAP_TYPE_ACPI_RECLAIM 3 #define SMAP_TYPE_ACPI_NVS 4 #define SMAP_TYPE_ACPI_ERROR 5 +#define SMAP_TYPE_DISABLED 6 +#define SMAP_TYPE_PMEM 7 +#define SMAP_TYPE_PRAM 12 #define SMAP_XATTR_ENABLED 0x00000001 #define SMAP_XATTR_NON_VOLATILE 0x00000002 Modified: stable/11/sys/arm/arm/machdep.c ============================================================================== --- stable/11/sys/arm/arm/machdep.c Sun Apr 16 06:51:06 2017 (r317003) +++ stable/11/sys/arm/arm/machdep.c Sun Apr 16 07:21:20 2017 (r317004) @@ -53,129 +53,43 @@ __FBSDID("$FreeBSD$"); #include -#include -#include -#include #include #include #include #include -#include #include #include -#include #include #include #include -#include #include -#include -#include #include -#include -#include -#include -#include -#if defined(LINUX_BOOT_ABI) -#include -#endif #include #include -#include #include -#include #include #include -#include -#include -#include -#include -#include #include #include #include -#include -#include -#include -#include #include -#include -#include -#include #include -#include #include #include #include #include -#include -#include +#include #include #include #include -#include #ifdef FDT -#include #include -#include +#include #endif -#ifdef DDB -#include - -#if __ARM_ARCH >= 6 - -DB_SHOW_COMMAND(cp15, db_show_cp15) -{ - u_int reg; - - reg = cp15_midr_get(); - db_printf("Cpu ID: 0x%08x\n", reg); - reg = cp15_ctr_get(); - db_printf("Current Cache Lvl ID: 0x%08x\n",reg); - - reg = cp15_sctlr_get(); - db_printf("Ctrl: 0x%08x\n",reg); - reg = cp15_actlr_get(); - db_printf("Aux Ctrl: 0x%08x\n",reg); - - reg = cp15_id_pfr0_get(); - db_printf("Processor Feat 0: 0x%08x\n", reg); - reg = cp15_id_pfr1_get(); - db_printf("Processor Feat 1: 0x%08x\n", reg); - reg = cp15_id_dfr0_get(); - db_printf("Debug Feat 0: 0x%08x\n", reg); - reg = cp15_id_afr0_get(); - db_printf("Auxiliary Feat 0: 0x%08x\n", reg); - reg = cp15_id_mmfr0_get(); - db_printf("Memory Model Feat 0: 0x%08x\n", reg); - reg = cp15_id_mmfr1_get(); - db_printf("Memory Model Feat 1: 0x%08x\n", reg); - reg = cp15_id_mmfr2_get(); - db_printf("Memory Model Feat 2: 0x%08x\n", reg); - reg = cp15_id_mmfr3_get(); - db_printf("Memory Model Feat 3: 0x%08x\n", reg); - reg = cp15_ttbr_get(); - db_printf("TTB0: 0x%08x\n", reg); -} - -DB_SHOW_COMMAND(vtop, db_show_vtop) -{ - u_int reg; - - if (have_addr) { - cp15_ats1cpr_set(addr); - reg = cp15_par_get(); - db_printf("Physical address reg: 0x%08x\n",reg); - } else - db_printf("show vtop \n"); -} -#endif /* __ARM_ARCH >= 6 */ -#endif /* DDB */ - #ifdef DEBUG #define debugf(fmt, args...) printf(fmt, ##args) #else @@ -204,10 +118,7 @@ int _min_bzero_size = 0; extern int *end; #ifdef FDT -static char *loader_envp; - vm_paddr_t pmap_pa; - #if __ARM_ARCH >= 6 vm_offset_t systempage; vm_offset_t irqstack; @@ -220,64 +131,21 @@ vm_offset_t abtstack; * stacks etc.), uprounded to be divisible by 4. */ #define KERNEL_PT_MAX 78 - static struct pv_addr kernel_pt_table[KERNEL_PT_MAX]; - struct pv_addr systempage; static struct pv_addr msgbufpv; struct pv_addr irqstack; struct pv_addr undstack; struct pv_addr abtstack; static struct pv_addr kernelstack; -#endif -#endif - -#if defined(LINUX_BOOT_ABI) -#define LBABI_MAX_BANKS 10 +#endif /* __ARM_ARCH >= 6 */ +#endif /* FDT */ -#define CMDLINE_GUARD "FreeBSD:" -uint32_t board_id; -struct arm_lbabi_tag *atag_list; -char linux_command_line[LBABI_MAX_COMMAND_LINE + 1]; -char atags[LBABI_MAX_COMMAND_LINE * 2]; -uint32_t memstart[LBABI_MAX_BANKS]; -uint32_t memsize[LBABI_MAX_BANKS]; -uint32_t membanks; -#endif #ifdef MULTIDELAY static delay_func *delay_impl; static void *delay_arg; #endif -static uint32_t board_revision; -/* hex representation of uint64_t */ -static char board_serial[32]; - -SYSCTL_NODE(_hw, OID_AUTO, board, CTLFLAG_RD, 0, "Board attributes"); -SYSCTL_UINT(_hw_board, OID_AUTO, revision, CTLFLAG_RD, - &board_revision, 0, "Board revision"); -SYSCTL_STRING(_hw_board, OID_AUTO, serial, CTLFLAG_RD, - board_serial, 0, "Board serial"); - -int vfp_exists; -SYSCTL_INT(_hw, HW_FLOATINGPT, floatingpoint, CTLFLAG_RD, - &vfp_exists, 0, "Floating point support enabled"); - -void -board_set_serial(uint64_t serial) -{ - - snprintf(board_serial, sizeof(board_serial)-1, - "%016jx", serial); -} - -void -board_set_revision(uint32_t revision) -{ - - board_revision = revision; -} - void sendsig(catcher, ksi, mask) sig_t catcher; @@ -569,237 +437,6 @@ DELAY(int usec) } #endif -int -fill_regs(struct thread *td, struct reg *regs) -{ - struct trapframe *tf = td->td_frame; - bcopy(&tf->tf_r0, regs->r, sizeof(regs->r)); - regs->r_sp = tf->tf_usr_sp; - regs->r_lr = tf->tf_usr_lr; - regs->r_pc = tf->tf_pc; - regs->r_cpsr = tf->tf_spsr; - return (0); -} -int -fill_fpregs(struct thread *td, struct fpreg *regs) -{ - bzero(regs, sizeof(*regs)); - return (0); -} - -int -set_regs(struct thread *td, struct reg *regs) -{ - struct trapframe *tf = td->td_frame; - - bcopy(regs->r, &tf->tf_r0, sizeof(regs->r)); - tf->tf_usr_sp = regs->r_sp; - tf->tf_usr_lr = regs->r_lr; - tf->tf_pc = regs->r_pc; - tf->tf_spsr &= ~PSR_FLAGS; - tf->tf_spsr |= regs->r_cpsr & PSR_FLAGS; - return (0); -} - -int -set_fpregs(struct thread *td, struct fpreg *regs) -{ - return (0); -} - -int -fill_dbregs(struct thread *td, struct dbreg *regs) -{ - return (0); -} -int -set_dbregs(struct thread *td, struct dbreg *regs) -{ - return (0); -} - - -static int -ptrace_read_int(struct thread *td, vm_offset_t addr, uint32_t *v) -{ - - if (proc_readmem(td, td->td_proc, addr, v, sizeof(*v)) != sizeof(*v)) - return (ENOMEM); - return (0); -} - -static int -ptrace_write_int(struct thread *td, vm_offset_t addr, uint32_t v) -{ - - if (proc_writemem(td, td->td_proc, addr, &v, sizeof(v)) != sizeof(v)) - return (ENOMEM); - return (0); -} - -static u_int -ptrace_get_usr_reg(void *cookie, int reg) -{ - int ret; - struct thread *td = cookie; - - KASSERT(((reg >= 0) && (reg <= ARM_REG_NUM_PC)), - ("reg is outside range")); - - switch(reg) { - case ARM_REG_NUM_PC: - ret = td->td_frame->tf_pc; - break; - case ARM_REG_NUM_LR: - ret = td->td_frame->tf_usr_lr; - break; - case ARM_REG_NUM_SP: - ret = td->td_frame->tf_usr_sp; - break; - default: - ret = *((register_t*)&td->td_frame->tf_r0 + reg); - break; - } - - return (ret); -} - -static u_int -ptrace_get_usr_int(void* cookie, vm_offset_t offset, u_int* val) -{ - struct thread *td = cookie; - u_int error; - - error = ptrace_read_int(td, offset, val); - - return (error); -} - -/** - * This function parses current instruction opcode and decodes - * any possible jump (change in PC) which might occur after - * the instruction is executed. - * - * @param td Thread structure of analysed task - * @param cur_instr Currently executed instruction - * @param alt_next_address Pointer to the variable where - * the destination address of the - * jump instruction shall be stored. - * - * @return <0> when jump is possible - * otherwise - */ -static int -ptrace_get_alternative_next(struct thread *td, uint32_t cur_instr, - uint32_t *alt_next_address) -{ - int error; - - if (inst_branch(cur_instr) || inst_call(cur_instr) || - inst_return(cur_instr)) { - error = arm_predict_branch(td, cur_instr, td->td_frame->tf_pc, - alt_next_address, ptrace_get_usr_reg, ptrace_get_usr_int); - - return (error); - } - - return (EINVAL); -} - -int -ptrace_single_step(struct thread *td) -{ - struct proc *p; - int error, error_alt; - uint32_t cur_instr, alt_next = 0; - - /* TODO: This needs to be updated for Thumb-2 */ - if ((td->td_frame->tf_spsr & PSR_T) != 0) - return (EINVAL); - - KASSERT(td->td_md.md_ptrace_instr == 0, - ("Didn't clear single step")); - KASSERT(td->td_md.md_ptrace_instr_alt == 0, - ("Didn't clear alternative single step")); - p = td->td_proc; - PROC_UNLOCK(p); - - error = ptrace_read_int(td, td->td_frame->tf_pc, - &cur_instr); - if (error) - goto out; - - error = ptrace_read_int(td, td->td_frame->tf_pc + INSN_SIZE, - &td->td_md.md_ptrace_instr); - if (error == 0) { - error = ptrace_write_int(td, td->td_frame->tf_pc + INSN_SIZE, - PTRACE_BREAKPOINT); - if (error) { - td->td_md.md_ptrace_instr = 0; - } else { - td->td_md.md_ptrace_addr = td->td_frame->tf_pc + - INSN_SIZE; - } - } - - error_alt = ptrace_get_alternative_next(td, cur_instr, &alt_next); - if (error_alt == 0) { - error_alt = ptrace_read_int(td, alt_next, - &td->td_md.md_ptrace_instr_alt); - if (error_alt) { - td->td_md.md_ptrace_instr_alt = 0; - } else { - error_alt = ptrace_write_int(td, alt_next, - PTRACE_BREAKPOINT); - if (error_alt) - td->td_md.md_ptrace_instr_alt = 0; - else - td->td_md.md_ptrace_addr_alt = alt_next; - } - } - -out: - PROC_LOCK(p); - return ((error != 0) && (error_alt != 0)); -} - -int -ptrace_clear_single_step(struct thread *td) -{ - struct proc *p; - - /* TODO: This needs to be updated for Thumb-2 */ - if ((td->td_frame->tf_spsr & PSR_T) != 0) - return (EINVAL); - - if (td->td_md.md_ptrace_instr != 0) { - p = td->td_proc; - PROC_UNLOCK(p); - ptrace_write_int(td, td->td_md.md_ptrace_addr, - td->td_md.md_ptrace_instr); - PROC_LOCK(p); - td->td_md.md_ptrace_instr = 0; - } - - if (td->td_md.md_ptrace_instr_alt != 0) { - p = td->td_proc; - PROC_UNLOCK(p); - ptrace_write_int(td, td->td_md.md_ptrace_addr_alt, - td->td_md.md_ptrace_instr_alt); - PROC_LOCK(p); - td->td_md.md_ptrace_instr_alt = 0; - } - - return (0); -} - -int -ptrace_set_pc(struct thread *td, unsigned long addr) -{ - td->td_frame->tf_pc = addr; - return (0); -} - void cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) { @@ -919,9 +556,6 @@ set_mcontext(struct thread *td, mcontext return (0); } -/* - * MPSAFE - */ int sys_sigreturn(td, uap) struct thread *td; @@ -953,7 +587,6 @@ sys_sigreturn(td, uap) return (EJUSTRETURN); } - /* * Construct a PCB from a trapframe. This is called from kdb_trap() where * we want to start a backtrace from the function that caused us to enter @@ -978,68 +611,6 @@ makectx(struct trapframe *tf, struct pcb pcb->pcb_regs.sf_sp = tf->tf_usr_sp; } -/* - * Fake up a boot descriptor table - */ -vm_offset_t -fake_preload_metadata(struct arm_boot_params *abp __unused, void *dtb_ptr, - size_t dtb_size) -{ -#ifdef DDB - vm_offset_t zstart = 0, zend = 0; -#endif - vm_offset_t lastaddr; - int i = 0; - static uint32_t fake_preload[35]; - - fake_preload[i++] = MODINFO_NAME; - fake_preload[i++] = strlen("kernel") + 1; - strcpy((char*)&fake_preload[i++], "kernel"); - i += 1; - fake_preload[i++] = MODINFO_TYPE; - fake_preload[i++] = strlen("elf kernel") + 1; - strcpy((char*)&fake_preload[i++], "elf kernel"); - i += 2; - fake_preload[i++] = MODINFO_ADDR; - fake_preload[i++] = sizeof(vm_offset_t); - fake_preload[i++] = KERNVIRTADDR; - fake_preload[i++] = MODINFO_SIZE; - fake_preload[i++] = sizeof(uint32_t); - fake_preload[i++] = (uint32_t)&end - KERNVIRTADDR; -#ifdef DDB - if (*(uint32_t *)KERNVIRTADDR == MAGIC_TRAMP_NUMBER) { - fake_preload[i++] = MODINFO_METADATA|MODINFOMD_SSYM; - fake_preload[i++] = sizeof(vm_offset_t); - fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 4); - fake_preload[i++] = MODINFO_METADATA|MODINFOMD_ESYM; - fake_preload[i++] = sizeof(vm_offset_t); - fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 8); - lastaddr = *(uint32_t *)(KERNVIRTADDR + 8); - zend = lastaddr; - zstart = *(uint32_t *)(KERNVIRTADDR + 4); - db_fetch_ksymtab(zstart, zend); - } else -#endif - lastaddr = (vm_offset_t)&end; - if (dtb_ptr != NULL) { - /* Copy DTB to KVA space and insert it into module chain. */ - lastaddr = roundup(lastaddr, sizeof(int)); - fake_preload[i++] = MODINFO_METADATA | MODINFOMD_DTBP; - fake_preload[i++] = sizeof(uint32_t); - fake_preload[i++] = (uint32_t)lastaddr; - memmove((void *)lastaddr, dtb_ptr, dtb_size); - lastaddr += dtb_size; - lastaddr = roundup(lastaddr, sizeof(int)); - } - fake_preload[i++] = 0; - fake_preload[i] = 0; - preload_metadata = (void *)fake_preload; - - init_static_kenv(NULL, 0); - - return (lastaddr); -} - void pcpu0_init(void) { @@ -1050,208 +621,6 @@ pcpu0_init(void) PCPU_SET(curthread, &thread0); } -#if defined(LINUX_BOOT_ABI) - -/* Convert the U-Boot command line into FreeBSD kenv and boot options. */ -static void -cmdline_set_env(char *cmdline, const char *guard) -{ - char *cmdline_next, *env; - size_t size, guard_len; - int i; - - size = strlen(cmdline); - /* Skip leading spaces. */ - for (; isspace(*cmdline) && (size > 0); cmdline++) - size--; - - /* Test and remove guard. */ - if (guard != NULL && guard[0] != '\0') { - guard_len = strlen(guard); - if (strncasecmp(cmdline, guard, guard_len) != 0) - return; - cmdline += guard_len; - size -= guard_len; - } - - /* Skip leading spaces. */ - for (; isspace(*cmdline) && (size > 0); cmdline++) - size--; - - /* Replace ',' with '\0'. */ - /* TODO: implement escaping for ',' character. */ - cmdline_next = cmdline; - while(strsep(&cmdline_next, ",") != NULL) - ; - init_static_kenv(cmdline, 0); - /* Parse boothowto. */ - for (i = 0; howto_names[i].ev != NULL; i++) { - env = kern_getenv(howto_names[i].ev); - if (env != NULL) { - if (strtoul(env, NULL, 10) != 0) - boothowto |= howto_names[i].mask; - freeenv(env); - } - } -} - -vm_offset_t -linux_parse_boot_param(struct arm_boot_params *abp) -{ - struct arm_lbabi_tag *walker; - uint32_t revision; - uint64_t serial; - int size; - vm_offset_t lastaddr; -#ifdef FDT - struct fdt_header *dtb_ptr; - uint32_t dtb_size; -#endif - - /* - * Linux boot ABI: r0 = 0, r1 is the board type (!= 0) and r2 - * is atags or dtb pointer. If all of these aren't satisfied, - * then punt. Unfortunately, it looks like DT enabled kernels - * doesn't uses board type and U-Boot delivers 0 in r1 for them. - */ - if (abp->abp_r0 != 0 || abp->abp_r2 == 0) - return (0); -#ifdef FDT - /* Test if r2 point to valid DTB. */ - dtb_ptr = (struct fdt_header *)abp->abp_r2; - if (fdt_check_header(dtb_ptr) == 0) { - dtb_size = fdt_totalsize(dtb_ptr); - return (fake_preload_metadata(abp, dtb_ptr, dtb_size)); - } -#endif - - board_id = abp->abp_r1; - walker = (struct arm_lbabi_tag *)abp->abp_r2; - - if (ATAG_TAG(walker) != ATAG_CORE) - return 0; - - atag_list = walker; - while (ATAG_TAG(walker) != ATAG_NONE) { - switch (ATAG_TAG(walker)) { - case ATAG_CORE: - break; - case ATAG_MEM: - arm_physmem_hardware_region(walker->u.tag_mem.start, - walker->u.tag_mem.size); - break; - case ATAG_INITRD2: - break; - case ATAG_SERIAL: - serial = walker->u.tag_sn.high; - serial <<= 32; - serial |= walker->u.tag_sn.low; - board_set_serial(serial); - break; - case ATAG_REVISION: - revision = walker->u.tag_rev.rev; - board_set_revision(revision); - break; - case ATAG_CMDLINE: - size = ATAG_SIZE(walker) - - sizeof(struct arm_lbabi_header); - size = min(size, LBABI_MAX_COMMAND_LINE); - strncpy(linux_command_line, walker->u.tag_cmd.command, - size); - linux_command_line[size] = '\0'; - break; - default: - break; - } - walker = ATAG_NEXT(walker); - } - - /* Save a copy for later */ - bcopy(atag_list, atags, - (char *)walker - (char *)atag_list + ATAG_SIZE(walker)); - - lastaddr = fake_preload_metadata(abp, NULL, 0); - cmdline_set_env(linux_command_line, CMDLINE_GUARD); - return lastaddr; -} -#endif - -#if defined(FREEBSD_BOOT_LOADER) -vm_offset_t -freebsd_parse_boot_param(struct arm_boot_params *abp) -{ - vm_offset_t lastaddr = 0; - void *mdp; - void *kmdp; -#ifdef DDB - vm_offset_t ksym_start; - vm_offset_t ksym_end; -#endif - - /* - * Mask metadata pointer: it is supposed to be on page boundary. If - * the first argument (mdp) doesn't point to a valid address the - * bootloader must have passed us something else than the metadata - * ptr, so we give up. Also give up if we cannot find metadta section - * the loader creates that we get all this data out of. - */ - - if ((mdp = (void *)(abp->abp_r0 & ~PAGE_MASK)) == NULL) - return 0; - preload_metadata = mdp; - kmdp = preload_search_by_type("elf kernel"); - if (kmdp == NULL) - return 0; - - boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - loader_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); - init_static_kenv(loader_envp, 0); - lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); -#ifdef DDB - ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); - ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); - db_fetch_ksymtab(ksym_start, ksym_end); -#endif - return lastaddr; -} -#endif - -vm_offset_t -default_parse_boot_param(struct arm_boot_params *abp) -{ - vm_offset_t lastaddr; - -#if defined(LINUX_BOOT_ABI) - if ((lastaddr = linux_parse_boot_param(abp)) != 0) - return lastaddr; -#endif -#if defined(FREEBSD_BOOT_LOADER) - if ((lastaddr = freebsd_parse_boot_param(abp)) != 0) - return lastaddr; -#endif - /* Fall back to hardcoded metadata. */ - lastaddr = fake_preload_metadata(abp, NULL, 0); - - return lastaddr; -} - -/* - * Stub version of the boot parameter parsing routine. We are - * called early in initarm, before even VM has been initialized. - * This routine needs to preserve any data that the boot loader - * has passed in before the kernel starts to grow past the end - * of the BSS, traditionally the place boot-loaders put this data. - * - * Since this is called so early, things that depend on the vm system - * being setup (including access to some SoC's serial ports), about - * all that can be done in this routine is to copy the arguments. - * - * This is the default boot parameter parsing routine. Individual - * kernels/boards can override this weak function with one of their - * own. We just fake metadata... - */ -__weak_reference(default_parse_boot_param, parse_boot_param); - /* * Initialize proc0 */ @@ -1269,111 +638,6 @@ init_proc0(vm_offset_t kstack) pcpup->pc_curpcb = thread0.td_pcb; } -int -arm_predict_branch(void *cookie, u_int insn, register_t pc, register_t *new_pc, - u_int (*fetch_reg)(void*, int), u_int (*read_int)(void*, vm_offset_t, u_int*)) -{ - u_int addr, nregs, offset = 0; - int error = 0; - - switch ((insn >> 24) & 0xf) { - case 0x2: /* add pc, reg1, #value */ - case 0x0: /* add pc, reg1, reg2, lsl #offset */ - addr = fetch_reg(cookie, (insn >> 16) & 0xf); - if (((insn >> 16) & 0xf) == 15) - addr += 8; - if (insn & 0x0200000) { - offset = (insn >> 7) & 0x1e; - offset = (insn & 0xff) << (32 - offset) | - (insn & 0xff) >> offset; - } else { - - offset = fetch_reg(cookie, insn & 0x0f); - if ((insn & 0x0000ff0) != 0x00000000) { - if (insn & 0x10) - nregs = fetch_reg(cookie, - (insn >> 8) & 0xf); - else - nregs = (insn >> 7) & 0x1f; - switch ((insn >> 5) & 3) { - case 0: - /* lsl */ - offset = offset << nregs; - break; - case 1: - /* lsr */ - offset = offset >> nregs; - break; - default: - break; /* XXX */ - } - - } - *new_pc = addr + offset; - return (0); - - } - - case 0xa: /* b ... */ - case 0xb: /* bl ... */ - addr = ((insn << 2) & 0x03ffffff); - if (addr & 0x02000000) - addr |= 0xfc000000; - *new_pc = (pc + 8 + addr); - return (0); - case 0x7: /* ldr pc, [pc, reg, lsl #2] */ - addr = fetch_reg(cookie, insn & 0xf); - addr = pc + 8 + (addr << 2); - error = read_int(cookie, addr, &addr); - *new_pc = addr; - return (error); - case 0x1: /* mov pc, reg */ - *new_pc = fetch_reg(cookie, insn & 0xf); - return (0); - case 0x4: - case 0x5: /* ldr pc, [reg] */ - addr = fetch_reg(cookie, (insn >> 16) & 0xf); - /* ldr pc, [reg, #offset] */ - if (insn & (1 << 24)) - offset = insn & 0xfff; - if (insn & 0x00800000) - addr += offset; - else - addr -= offset; - error = read_int(cookie, addr, &addr); - *new_pc = addr; - - return (error); - case 0x8: /* ldmxx reg, {..., pc} */ - case 0x9: - addr = fetch_reg(cookie, (insn >> 16) & 0xf); - nregs = (insn & 0x5555) + ((insn >> 1) & 0x5555); - nregs = (nregs & 0x3333) + ((nregs >> 2) & 0x3333); - nregs = (nregs + (nregs >> 4)) & 0x0f0f; - nregs = (nregs + (nregs >> 8)) & 0x001f; - switch ((insn >> 23) & 0x3) { - case 0x0: /* ldmda */ - addr = addr - 0; - break; - case 0x1: /* ldmia */ - addr = addr + 0 + ((nregs - 1) << 2); - break; - case 0x2: /* ldmdb */ - addr = addr - 4; - break; - case 0x3: /* ldmib */ - addr = addr + 4 + ((nregs - 1) << 2); - break; - } - error = read_int(cookie, addr, &addr); - *new_pc = addr; - - return (error); - default: - return (EINVAL); - } -} - #if __ARM_ARCH >= 6 void set_stackptrs(int cpu) @@ -1400,139 +664,8 @@ set_stackptrs(int cpu) } #endif -#ifdef EFI -static void -add_efi_map_entries(struct efi_map_header *efihdr, struct mem_region *mr, - int *mrcnt) -{ - struct efi_md *map, *p; - const char *type; - size_t efisz, memory_size; - int ndesc, i, j; - - static const char *types[] = { - "Reserved", - "LoaderCode", - "LoaderData", - "BootServicesCode", - "BootServicesData", - "RuntimeServicesCode", - "RuntimeServicesData", - "ConventionalMemory", - "UnusableMemory", - "ACPIReclaimMemory", - "ACPIMemoryNVS", - "MemoryMappedIO", - "MemoryMappedIOPortSpace", - "PalCode" - }; - - *mrcnt = 0; - - /* - * Memory map data provided by UEFI via the GetMemoryMap - * Boot Services API. - */ - efisz = roundup2(sizeof(struct efi_map_header), 0x10); - map = (struct efi_md *)((uint8_t *)efihdr + efisz); - - if (efihdr->descriptor_size == 0) - return; - ndesc = efihdr->memory_size / efihdr->descriptor_size; - - if (boothowto & RB_VERBOSE) - printf("%23s %12s %12s %8s %4s\n", - "Type", "Physical", "Virtual", "#Pages", "Attr"); - - memory_size = 0; - for (i = 0, j = 0, p = map; i < ndesc; i++, - p = efi_next_descriptor(p, efihdr->descriptor_size)) { - if (boothowto & RB_VERBOSE) { - if (p->md_type <= EFI_MD_TYPE_PALCODE) - type = types[p->md_type]; - else - type = ""; - printf("%23s %012llx %12p %08llx ", type, p->md_phys, - p->md_virt, p->md_pages); - if (p->md_attr & EFI_MD_ATTR_UC) - printf("UC "); - if (p->md_attr & EFI_MD_ATTR_WC) - printf("WC "); - if (p->md_attr & EFI_MD_ATTR_WT) - printf("WT "); - if (p->md_attr & EFI_MD_ATTR_WB) - printf("WB "); - if (p->md_attr & EFI_MD_ATTR_UCE) - printf("UCE "); - if (p->md_attr & EFI_MD_ATTR_WP) - printf("WP "); - if (p->md_attr & EFI_MD_ATTR_RP) - printf("RP "); - if (p->md_attr & EFI_MD_ATTR_XP) - printf("XP "); - if (p->md_attr & EFI_MD_ATTR_RT) - printf("RUNTIME"); - printf("\n"); - } - - switch (p->md_type) { - case EFI_MD_TYPE_CODE: - case EFI_MD_TYPE_DATA: - case EFI_MD_TYPE_BS_CODE: - case EFI_MD_TYPE_BS_DATA: - case EFI_MD_TYPE_FREE: - /* - * We're allowed to use any entry with these types. - */ - break; - default: - continue; - } - - j++; - if (j >= FDT_MEM_REGIONS) - break; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sun Apr 16 07:33:49 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43CCCD40EA2; Sun, 16 Apr 2017 07:33:49 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 11E601475; Sun, 16 Apr 2017 07:33:48 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G7Xm4T085455; Sun, 16 Apr 2017 07:33:48 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G7Xlja085445; Sun, 16 Apr 2017 07:33:47 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160733.v3G7Xlja085445@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 07:33:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317005 - in stable/11: lib/libthread_db/arch/arm sys/arm/arm sys/arm/include X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 07:33:49 -0000 Author: mmel Date: Sun Apr 16 07:33:47 2017 New Revision: 317005 URL: https://svnweb.freebsd.org/changeset/base/317005 Log: MFC r315900,r315973,r315974: r315900: Cleanup structures related to VFP and/or mcontext_t. - in mcontext_t, rename newer used 'union __vfp' to equaly sized 'mc_spare'. Space allocated by 'union __vfp' is too small and cannot hold full VFP context. - move structures defined in fp.h to more appropriate headers. - remove all unused VFP structures. r315973: Save VFP state on fork(). Update the copy of VFP state in PCB before it is cloned for new process. r315974: Preserve VFP state across signal delivery. Deleted: stable/11/sys/arm/include/fp.h Modified: stable/11/lib/libthread_db/arch/arm/libpthread_md.c stable/11/sys/arm/arm/machdep.c stable/11/sys/arm/arm/vfp.c stable/11/sys/arm/arm/vm_machdep.c stable/11/sys/arm/include/frame.h stable/11/sys/arm/include/pcb.h stable/11/sys/arm/include/reg.h stable/11/sys/arm/include/ucontext.h stable/11/sys/arm/include/vfp.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libthread_db/arch/arm/libpthread_md.c ============================================================================== --- stable/11/lib/libthread_db/arch/arm/libpthread_md.c Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/lib/libthread_db/arch/arm/libpthread_md.c Sun Apr 16 07:33:47 2017 (r317005) @@ -90,7 +90,9 @@ pt_fpreg_to_ucontext(const struct fpreg mcontext_t *mc = &uc->uc_mcontext; /* XXX */ - memset(&mc->__fpu, 0, sizeof(mc->__fpu)); + mc->mc_vfp_size = 0; + mc->mc_vfp_ptr = NULL; + memset(mc->mc_spare, 0, sizeof(mc->mc_spare)); } void Modified: stable/11/sys/arm/arm/machdep.c ============================================================================== --- stable/11/sys/arm/arm/machdep.c Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/sys/arm/arm/machdep.c Sun Apr 16 07:33:47 2017 (r317005) @@ -146,105 +146,6 @@ static delay_func *delay_impl; static void *delay_arg; #endif -void -sendsig(catcher, ksi, mask) - sig_t catcher; - ksiginfo_t *ksi; - sigset_t *mask; -{ - struct thread *td; - struct proc *p; - struct trapframe *tf; - struct sigframe *fp, frame; - struct sigacts *psp; - struct sysentvec *sysent; - int onstack; - int sig; - int code; - - td = curthread; - p = td->td_proc; - PROC_LOCK_ASSERT(p, MA_OWNED); - sig = ksi->ksi_signo; - code = ksi->ksi_code; - psp = p->p_sigacts; - mtx_assert(&psp->ps_mtx, MA_OWNED); - tf = td->td_frame; - onstack = sigonstack(tf->tf_usr_sp); - - CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, - catcher, sig); - - /* Allocate and validate space for the signal handler context. */ - if ((td->td_pflags & TDP_ALTSTACK) != 0 && !(onstack) && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - fp = (struct sigframe *)((uintptr_t)td->td_sigstk.ss_sp + - td->td_sigstk.ss_size); -#if defined(COMPAT_43) - td->td_sigstk.ss_flags |= SS_ONSTACK; -#endif - } else - fp = (struct sigframe *)td->td_frame->tf_usr_sp; - - /* make room on the stack */ - fp--; - - /* make the stack aligned */ - fp = (struct sigframe *)STACKALIGN(fp); - /* Populate the siginfo frame. */ - get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); - frame.sf_si = ksi->ksi_info; - frame.sf_uc.uc_sigmask = *mask; - frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK ) - ? ((onstack) ? SS_ONSTACK : 0) : SS_DISABLE; - frame.sf_uc.uc_stack = td->td_sigstk; - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(td->td_proc); - - /* Copy the sigframe out to the user's stack. */ - if (copyout(&frame, fp, sizeof(*fp)) != 0) { - /* Process has trashed its stack. Kill it. */ - CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp); - PROC_LOCK(p); - sigexit(td, SIGILL); - } - - /* - * Build context to run handler in. We invoke the handler - * directly, only returning via the trampoline. Note the - * trampoline version numbers are coordinated with machine- - * dependent code in libc. - */ - - tf->tf_r0 = sig; - tf->tf_r1 = (register_t)&fp->sf_si; - tf->tf_r2 = (register_t)&fp->sf_uc; - - /* the trampoline uses r5 as the uc address */ - tf->tf_r5 = (register_t)&fp->sf_uc; - tf->tf_pc = (register_t)catcher; - tf->tf_usr_sp = (register_t)fp; - sysent = p->p_sysent; - if (sysent->sv_sigcode_base != 0) - tf->tf_usr_lr = (register_t)sysent->sv_sigcode_base; - else - tf->tf_usr_lr = (register_t)(sysent->sv_psstrings - - *(sysent->sv_szsigcode)); - /* Set the mode to enter in the signal handler */ -#if __ARM_ARCH >= 7 - if ((register_t)catcher & 1) - tf->tf_spsr |= PSR_T; - else - tf->tf_spsr &= ~PSR_T; -#endif - - CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_usr_lr, - tf->tf_usr_sp); - - PROC_LOCK(p); - mtx_lock(&psp->ps_mtx); -} - struct kva_md_info kmi; /* @@ -488,6 +389,47 @@ exec_setregs(struct thread *td, struct i tf->tf_spsr = PSR_USR32_MODE; } + +#ifdef VFP +/* + * Get machine VFP context. + */ +static void +get_vfpcontext(struct thread *td, mcontext_vfp_t *vfp) +{ + struct pcb *curpcb; + + curpcb = curthread->td_pcb; + critical_enter(); + + vfp_store(&curpcb->pcb_vfpstate, false); + memcpy(vfp->mcv_reg, curpcb->pcb_vfpstate.reg, + sizeof(vfp->mcv_reg)); + vfp->mcv_fpscr = curpcb->pcb_vfpstate.fpscr; + + critical_exit(); +} + +/* + * Set machine VFP context. + */ +static void +set_vfpcontext(struct thread *td, mcontext_vfp_t *vfp) +{ + struct pcb *curpcb; + + curpcb = curthread->td_pcb; + critical_enter(); + + vfp_discard(td); + memcpy(curpcb->pcb_vfpstate.reg, vfp->mcv_reg, + sizeof(curpcb->pcb_vfpstate.reg)); + curpcb->pcb_vfpstate.fpscr = vfp->mcv_fpscr; + + critical_exit(); +} +#endif + /* * Get machine context. */ @@ -520,6 +462,10 @@ get_mcontext(struct thread *td, mcontext gr[_REG_LR] = tf->tf_usr_lr; gr[_REG_PC] = tf->tf_pc; + mcp->mc_vfp_size = 0; + mcp->mc_vfp_ptr = NULL; + memset(&mcp->mc_spare, 0, sizeof(mcp->mc_spare)); + return (0); } @@ -532,9 +478,29 @@ get_mcontext(struct thread *td, mcontext int set_mcontext(struct thread *td, mcontext_t *mcp) { + mcontext_vfp_t mc_vfp, *vfp; struct trapframe *tf = td->td_frame; const __greg_t *gr = mcp->__gregs; +#ifdef WITNESS + if (mcp->mc_vfp_size != 0 && mcp->mc_vfp_size != sizeof(mc_vfp)) { + printf("%s: %s: Malformed mc_vfp_size: %d (0x%08X)\n", + td->td_proc->p_comm, __func__, + mcp->mc_vfp_size, mcp->mc_vfp_size); + } else if (mcp->mc_vfp_size != 0 && mcp->mc_vfp_ptr == NULL) { + printf("%s: %s: c_vfp_size != 0 but mc_vfp_ptr == NULL\n", + td->td_proc->p_comm, __func__); + } +#endif + + if (mcp->mc_vfp_size == sizeof(mc_vfp) && mcp->mc_vfp_ptr != NULL) { + if (copyin(mcp->mc_vfp_ptr, &mc_vfp, sizeof(mc_vfp)) != 0) + return (EFAULT); + vfp = &mc_vfp; + } else { + vfp = NULL; + } + tf->tf_r0 = gr[_REG_R0]; tf->tf_r1 = gr[_REG_R1]; tf->tf_r2 = gr[_REG_R2]; @@ -552,10 +518,120 @@ set_mcontext(struct thread *td, mcontext tf->tf_usr_lr = gr[_REG_LR]; tf->tf_pc = gr[_REG_PC]; tf->tf_spsr = gr[_REG_CPSR]; - +#ifdef VFP + if (vfp != NULL) + set_vfpcontext(td, vfp); +#endif return (0); } +void +sendsig(catcher, ksi, mask) + sig_t catcher; + ksiginfo_t *ksi; + sigset_t *mask; +{ + struct thread *td; + struct proc *p; + struct trapframe *tf; + struct sigframe *fp, frame; + struct sigacts *psp; + struct sysentvec *sysent; + int onstack; + int sig; + int code; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + sig = ksi->ksi_signo; + code = ksi->ksi_code; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); + tf = td->td_frame; + onstack = sigonstack(tf->tf_usr_sp); + + CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, + catcher, sig); + + /* Allocate and validate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) != 0 && !(onstack) && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + fp = (struct sigframe *)((uintptr_t)td->td_sigstk.ss_sp + + td->td_sigstk.ss_size); +#if defined(COMPAT_43) + td->td_sigstk.ss_flags |= SS_ONSTACK; +#endif + } else + fp = (struct sigframe *)td->td_frame->tf_usr_sp; + + /* make room on the stack */ + fp--; + + /* make the stack aligned */ + fp = (struct sigframe *)STACKALIGN(fp); + /* Populate the siginfo frame. */ + get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); +#ifdef VFP + get_vfpcontext(td, &frame.sf_vfp); + frame.sf_uc.uc_mcontext.mc_vfp_size = sizeof(fp->sf_vfp); + frame.sf_uc.uc_mcontext.mc_vfp_ptr = &fp->sf_vfp; +#else + frame.sf_uc.uc_mcontext.mc_vfp_size = 0; + frame.sf_uc.uc_mcontext.mc_vfp_ptr = NULL; +#endif + frame.sf_si = ksi->ksi_info; + frame.sf_uc.uc_sigmask = *mask; + frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK ) + ? ((onstack) ? SS_ONSTACK : 0) : SS_DISABLE; + frame.sf_uc.uc_stack = td->td_sigstk; + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(td->td_proc); + + /* Copy the sigframe out to the user's stack. */ + if (copyout(&frame, fp, sizeof(*fp)) != 0) { + /* Process has trashed its stack. Kill it. */ + CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp); + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + /* + * Build context to run handler in. We invoke the handler + * directly, only returning via the trampoline. Note the + * trampoline version numbers are coordinated with machine- + * dependent code in libc. + */ + + tf->tf_r0 = sig; + tf->tf_r1 = (register_t)&fp->sf_si; + tf->tf_r2 = (register_t)&fp->sf_uc; + + /* the trampoline uses r5 as the uc address */ + tf->tf_r5 = (register_t)&fp->sf_uc; + tf->tf_pc = (register_t)catcher; + tf->tf_usr_sp = (register_t)fp; + sysent = p->p_sysent; + if (sysent->sv_sigcode_base != 0) + tf->tf_usr_lr = (register_t)sysent->sv_sigcode_base; + else + tf->tf_usr_lr = (register_t)(sysent->sv_psstrings - + *(sysent->sv_szsigcode)); + /* Set the mode to enter in the signal handler */ +#if __ARM_ARCH >= 7 + if ((register_t)catcher & 1) + tf->tf_spsr |= PSR_T; + else + tf->tf_spsr &= ~PSR_T; +#endif + + CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_usr_lr, + tf->tf_usr_sp); + + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} + int sys_sigreturn(td, uap) struct thread *td; @@ -578,7 +654,7 @@ sys_sigreturn(td, uap) if ((spsr & PSR_MODE) != PSR_USR32_MODE || (spsr & (PSR_I | PSR_F)) != 0) return (EINVAL); - /* Restore register context. */ + /* Restore register context. */ set_mcontext(td, &uc.uc_mcontext); /* Restore signal mask. */ Modified: stable/11/sys/arm/arm/vfp.c ============================================================================== --- stable/11/sys/arm/arm/vfp.c Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/sys/arm/arm/vfp.c Sun Apr 16 07:33:47 2017 (r317005) @@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include Modified: stable/11/sys/arm/arm/vm_machdep.c ============================================================================== --- stable/11/sys/arm/arm/vm_machdep.c Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/sys/arm/arm/vm_machdep.c Sun Apr 16 07:33:47 2017 (r317005) @@ -111,6 +111,14 @@ cpu_fork(register struct thread *td1, re pmap_use_minicache(td2->td_kstack, td2->td_kstack_pages * PAGE_SIZE); #endif #endif +#ifdef VFP + /* Store actual state of VFP */ + if (curthread == td1) { + critical_enter(); + vfp_store(&td1->td_pcb->pcb_vfpstate, false); + critical_exit(); + } +#endif td2->td_pcb = pcb2; /* Clone td1's pcb */ Modified: stable/11/sys/arm/include/frame.h ============================================================================== --- stable/11/sys/arm/include/frame.h Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/sys/arm/include/frame.h Sun Apr 16 07:33:47 2017 (r317005) @@ -94,6 +94,7 @@ struct trapframe { struct sigframe { siginfo_t sf_si; /* actual saved siginfo */ ucontext_t sf_uc; /* actual saved ucontext */ + mcontext_vfp_t sf_vfp; /* actual saved VFP context */ }; Modified: stable/11/sys/arm/include/pcb.h ============================================================================== --- stable/11/sys/arm/include/pcb.h Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/sys/arm/include/pcb.h Sun Apr 16 07:33:47 2017 (r317005) @@ -38,8 +38,8 @@ #ifndef _MACHINE_PCB_H_ #define _MACHINE_PCB_H_ -#include #include +#include /* Modified: stable/11/sys/arm/include/reg.h ============================================================================== --- stable/11/sys/arm/include/reg.h Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/sys/arm/include/reg.h Sun Apr 16 07:33:47 2017 (r317005) @@ -3,8 +3,6 @@ #ifndef MACHINE_REG_H #define MACHINE_REG_H -#include - struct reg { unsigned int r[13]; unsigned int r_sp; @@ -13,6 +11,14 @@ struct reg { unsigned int r_cpsr; }; +struct fp_extended_precision { + u_int32_t fp_exponent; + u_int32_t fp_mantissa_hi; + u_int32_t fp_mantissa_lo; +}; + +typedef struct fp_extended_precision fp_reg_t; + struct fpreg { unsigned int fpr_fpsr; fp_reg_t fpr[8]; Modified: stable/11/sys/arm/include/ucontext.h ============================================================================== --- stable/11/sys/arm/include/ucontext.h Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/sys/arm/include/ucontext.h Sun Apr 16 07:33:47 2017 (r317005) @@ -66,35 +66,22 @@ typedef __greg_t __gregset_t[_NGREG]; /* * Floating point register state */ -/* Note: the storage layout of this structure must be identical to ARMFPE! */ typedef struct { - unsigned int __fp_fpsr; - struct { - unsigned int __fp_exponent; - unsigned int __fp_mantissa_hi; - unsigned int __fp_mantissa_lo; - } __fp_fr[8]; -} __fpregset_t; - -typedef struct { - unsigned int __vfp_fpscr; - unsigned int __vfp_fstmx[33]; - unsigned int __vfp_fpsid; -} __vfpregset_t; + __uint64_t mcv_reg[32]; + __uint32_t mcv_fpscr; +} mcontext_vfp_t; typedef struct { __gregset_t __gregs; - union { - __fpregset_t __fpregs; - __vfpregset_t __vfpregs; - } __fpu; -} mcontext_t; -/* Machine-dependent uc_flags */ -#define _UC_ARM_VFP 0x00010000 /* FPU field is VFP */ - -/* used by signal delivery to indicate status of signal stack */ -#define _UC_SETSTACK 0x00020000 -#define _UC_CLRSTACK 0x00040000 + /* + * Originally, rest of this structure was named __fpu, 35 * 4 bytes + * long, never accessed from kernel. + */ + size_t mc_vfp_size; + void *mc_vfp_ptr; + unsigned int mc_spare[33]; +} mcontext_t; +#define UC_ #endif /* !_MACHINE_MCONTEXT_H_ */ Modified: stable/11/sys/arm/include/vfp.h ============================================================================== --- stable/11/sys/arm/include/vfp.h Sun Apr 16 07:21:20 2017 (r317004) +++ stable/11/sys/arm/include/vfp.h Sun Apr 16 07:33:47 2017 (r317005) @@ -133,9 +133,19 @@ #define COPROC11 (0x3 << 22) #ifndef LOCORE +struct vfp_state { + uint64_t reg[32]; + uint32_t fpscr; + uint32_t fpexec; + uint32_t fpinst; + uint32_t fpinst2; +}; + +#ifdef _KERNEL void vfp_init(void); void vfp_store(struct vfp_state *, boolean_t); void vfp_discard(struct thread *); -#endif +#endif /* _KERNEL */ +#endif /* LOCORE */ #endif From owner-svn-src-all@freebsd.org Sun Apr 16 07:35:52 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D3B75D40F59; Sun, 16 Apr 2017 07:35:52 +0000 (UTC) (envelope-from bapt@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B344F15FA; Sun, 16 Apr 2017 07:35:52 +0000 (UTC) (envelope-from bapt@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1235) id D9638663F; Sun, 16 Apr 2017 07:35:51 +0000 (UTC) Date: Sun, 16 Apr 2017 09:35:51 +0200 From: Baptiste Daroussin To: rgrimes@freebsd.org Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r316978 - in head: contrib/zstd etc/mtree lib lib/libzstd share/mk usr.bin usr.bin/zstd Message-ID: <20170416073551.557czdcksdmmuz24@ivaldir.net> References: <201704152005.v3FK5M2j002459@repo.freebsd.org> <201704152337.v3FNb2m1014053@pdx.rh.CN85.dnsmgr.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="z6jkgyiag243hzob" Content-Disposition: inline In-Reply-To: <201704152337.v3FNb2m1014053@pdx.rh.CN85.dnsmgr.net> User-Agent: NeoMutt/20170306 (1.8.0) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 07:35:52 -0000 --z6jkgyiag243hzob Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Apr 15, 2017 at 04:37:02PM -0700, Rodney W. Grimes wrote: > And we need this in base for what great purpose??? >=20 zstandard is the successor to lz4, there are attempts to integrate zstandar= d in ZFS, Allan Jude is working on that, I am working on integrating in libstand= to allow to boot a kernel compressed with zstandard or a mfsroot with zstandar= d, which would benefit lots of pxe users. I have also added it to newsyslog(8) so users can benefit zstandard compres= sion for the log files, which will consume less CPUs for greater compression that bzip2. On low ended boxes with low storage this is actually very useful as = well. I haven't checked yet the performances on my armv6 boxes, but on the low en= ded recent atom laptops I can tell this is already very useful. Bapt --z6jkgyiag243hzob Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgOTj3suS2urGXVU3Y4mL3PG3PloFAljzHtAACgkQY4mL3PG3 Plo1xBAAuZ6z6kVMXL1fLmonHGgEfXRmBL0yrBtdG++18BXJ1DstY7Mogijygnyr 8qiBIx/SoBFLRK5MQ43anDLZydlZ4nM+2zwLjx21SjUnGzqqvixZEaB61WRNPms3 ZIN8QMVAWirSRyjaLx1Tgf9NWeYOzkpN53qHCGI8fY8NxC7fN+3y27IFkD66EjJH rYtOlrXPqCNqUaFGD4WJkSpuLuH13mWwa72N/IQry1J64FpJQdOawSsM5MxS68HY l/+wZ/tWBsoNZBhvRi+Shi2X9xyEPMBBxuFJDC42mxw6LHtlrB2dAD+0JfSeVz2i bo5eteUJkSL7yTzjJXLHke3dC8sDbl0HkGtA/oMhVN0j7WD5BAx6s5HxUzfany+0 m+VhPLy6nICQ3FlA06Yq2QEw3i4qPgB3oRx3dVih4UowI176fnkwQgjiIF24uHW+ nZkYgvKgaersGqbHzP4BvSw8hpZDeRTe6R11TzVsY98BFo87uhmj0nQeluiGag9n l1k6VJFDU2m6AwX1+L4ilufJFReTxjHKLuz5Fj0XVaAENLmnHwCEIK9YszMmaKZH 0jc3M8MG3a7FEu40v6rt7YUJJoOX+1RajZnKxJIKAhO4w20iMkB5zZUJWV6YUMw2 Lmk+goq43WHAt05F4CG3piuwcKFK9SBHNXHObPdQxEayX1PrVkw= =WUd3 -----END PGP SIGNATURE----- --z6jkgyiag243hzob-- From owner-svn-src-all@freebsd.org Sun Apr 16 07:41:32 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16CCDD40137; Sun, 16 Apr 2017 07:41:32 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 CA63219E2; Sun, 16 Apr 2017 07:41:31 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G7fUoF087329; Sun, 16 Apr 2017 07:41:30 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G7fUsc087325; Sun, 16 Apr 2017 07:41:30 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160741.v3G7fUsc087325@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 07:41:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317006 - in stable/11/sys/arm: conf nvidia/tegra124 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 07:41:32 -0000 Author: mmel Date: Sun Apr 16 07:41:30 2017 New Revision: 317006 URL: https://svnweb.freebsd.org/changeset/base/317006 Log: MFC r306442,r306444,r306445,r306550: r306442: TEGRA: Add support for MULTIDELAY option. r306444: TEGRA: Don't include files already included by system or arch configs. r306445: TEGRA: Return back kern_clocksource.c into tegra config file. It was removed in r306444 by mistake. r306550: TEGRA: Extend timeout for PLLs lock to 5 ms. Real lock time for PLLA has been very near to old limit. Modified: stable/11/sys/arm/conf/TEGRA124 stable/11/sys/arm/nvidia/tegra124/files.tegra124 stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c stable/11/sys/arm/nvidia/tegra124/tegra124_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/conf/TEGRA124 ============================================================================== --- stable/11/sys/arm/conf/TEGRA124 Sun Apr 16 07:33:47 2017 (r317005) +++ stable/11/sys/arm/conf/TEGRA124 Sun Apr 16 07:41:30 2017 (r317006) @@ -26,6 +26,7 @@ ident TEGRA124 options SCHED_ULE # ULE scheduler options PLATFORM # Platform based SoC options PLATFORM_SMP +options MULTIDELAY options SMP # Enable multiple cores options LINUX_BOOT_ABI Modified: stable/11/sys/arm/nvidia/tegra124/files.tegra124 ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/files.tegra124 Sun Apr 16 07:33:47 2017 (r317005) +++ stable/11/sys/arm/nvidia/tegra124/files.tegra124 Sun Apr 16 07:41:30 2017 (r317006) @@ -4,7 +4,6 @@ # Standard ARM support. # kern/kern_clocksource.c standard -dev/ofw/ofw_cpu.c optional fdt # # Standard tegra124 devices and support. Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Sun Apr 16 07:33:47 2017 (r317005) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Sun Apr 16 07:41:30 2017 (r317006) @@ -86,7 +86,7 @@ enum pll_type { #define PLLRE_IDDQ_BIT 16 #define PLLSS_IDDQ_BIT 19 -#define PLL_LOCK_TIMEOUT 1000 +#define PLL_LOCK_TIMEOUT 5000 /* Post divider <-> register value mapping. */ struct pdiv_table { Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_machdep.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_machdep.c Sun Apr 16 07:33:47 2017 (r317005) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_machdep.c Sun Apr 16 07:41:30 2017 (r317006) @@ -151,4 +151,4 @@ static platform_method_t tegra124_method PLATFORMMETHOD_END, }; -FDT_PLATFORM_DEF(tegra124, "Nvidia Jetson-TK1", 0, "nvidia,jetson-tk1", 0); +FDT_PLATFORM_DEF(tegra124, "Nvidia Jetson-TK1", 0, "nvidia,jetson-tk1", 120); From owner-svn-src-all@freebsd.org Sun Apr 16 07:43:30 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A8C6D40395; Sun, 16 Apr 2017 07:43:30 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5C3701C18; Sun, 16 Apr 2017 07:43:30 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G7hTZO089564; Sun, 16 Apr 2017 07:43:29 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G7hTN2089563; Sun, 16 Apr 2017 07:43:29 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160743.v3G7hTN2089563@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 07:43:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317007 - stable/11/sys/conf X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 07:43:30 -0000 Author: mmel Date: Sun Apr 16 07:43:29 2017 New Revision: 317007 URL: https://svnweb.freebsd.org/changeset/base/317007 Log: MFC r306703: ARM: Disconnect elf_trampoline.c from ARMv6 build. The trampoline code never functioned properly for Cortex CPUs, and its functionality is already provided by ubldr. Modified: stable/11/sys/conf/Makefile.arm Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/Makefile.arm ============================================================================== --- stable/11/sys/conf/Makefile.arm Sun Apr 16 07:41:30 2017 (r317006) +++ stable/11/sys/conf/Makefile.arm Sun Apr 16 07:43:29 2017 (r317007) @@ -74,7 +74,7 @@ FILES_CPU_FUNC = \ $S/$M/$M/cpufunc_asm_pj4b.S $S/$M/$M/cpufunc_asm_armv6.S \ $S/$M/$M/cpufunc_asm_armv7.S -.if defined(KERNPHYSADDR) +.if ${TARGET_ARCH} != "armv6" && defined(KERNPHYSADDR) KERNEL_EXTRA=trampoline KERNEL_EXTRA_INSTALL=kernel.gz.tramp trampoline: ${KERNEL_KO}.tramp From owner-svn-src-all@freebsd.org Sun Apr 16 07:58:43 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6169D40692; Sun, 16 Apr 2017 07:58:43 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 853A0391; Sun, 16 Apr 2017 07:58:43 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G7wg86094286; Sun, 16 Apr 2017 07:58:42 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G7wge0094279; Sun, 16 Apr 2017 07:58:42 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160758.v3G7wge0094279@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 07:58:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317008 - in stable/11/sys: conf dev/drm2 dev/drm2/ttm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 07:58:43 -0000 Author: mmel Date: Sun Apr 16 07:58:41 2017 New Revision: 317008 URL: https://svnweb.freebsd.org/changeset/base/317008 Log: MFC r308612,r308614: r308612: Allow DRM2 code to be built on platforms without AGP. This patch is taken from original drm-3.8 code. r308614: Allow embeding DRM2 code into kernel. It's usefull for development (for netboot) and it also helps to boot FreeBSD on some embeded platforms (where we must boot kernel directly, without standard boot loader). Modified: stable/11/sys/conf/files stable/11/sys/dev/drm2/drmP.h stable/11/sys/dev/drm2/drm_memory.c stable/11/sys/dev/drm2/drm_os_freebsd.c stable/11/sys/dev/drm2/drm_os_freebsd.h stable/11/sys/dev/drm2/ttm/ttm_bo_util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Sun Apr 16 07:43:29 2017 (r317007) +++ stable/11/sys/conf/files Sun Apr 16 07:58:41 2017 (r317008) @@ -1451,6 +1451,49 @@ dev/drm/via_map.c optional viadrm dev/drm/via_mm.c optional viadrm dev/drm/via_verifier.c optional viadrm dev/drm/via_video.c optional viadrm +dev/drm2/drm_agpsupport.c optional drm2 +dev/drm2/drm_auth.c optional drm2 +dev/drm2/drm_bufs.c optional drm2 +dev/drm2/drm_buffer.c optional drm2 +dev/drm2/drm_context.c optional drm2 +dev/drm2/drm_crtc.c optional drm2 +dev/drm2/drm_crtc_helper.c optional drm2 +dev/drm2/drm_dma.c optional drm2 +dev/drm2/drm_dp_helper.c optional drm2 +dev/drm2/drm_dp_iic_helper.c optional drm2 +dev/drm2/drm_drv.c optional drm2 +dev/drm2/drm_edid.c optional drm2 +dev/drm2/drm_fb_helper.c optional drm2 +dev/drm2/drm_fops.c optional drm2 +dev/drm2/drm_gem.c optional drm2 +dev/drm2/drm_gem_names.c optional drm2 +dev/drm2/drm_global.c optional drm2 +dev/drm2/drm_hashtab.c optional drm2 +dev/drm2/drm_ioctl.c optional drm2 +dev/drm2/drm_irq.c optional drm2 +dev/drm2/drm_linux_list_sort.c optional drm2 +dev/drm2/drm_lock.c optional drm2 +dev/drm2/drm_memory.c optional drm2 +dev/drm2/drm_mm.c optional drm2 +dev/drm2/drm_modes.c optional drm2 +dev/drm2/drm_pci.c optional drm2 +dev/drm2/drm_scatter.c optional drm2 +dev/drm2/drm_stub.c optional drm2 +dev/drm2/drm_sysctl.c optional drm2 +dev/drm2/drm_vm.c optional drm2 +dev/drm2/drm_os_freebsd.c optional drm2 +dev/drm2/ttm/ttm_agp_backend.c optional drm2 +dev/drm2/ttm/ttm_lock.c optional drm2 +dev/drm2/ttm/ttm_object.c optional drm2 +dev/drm2/ttm/ttm_tt.c optional drm2 +dev/drm2/ttm/ttm_bo_util.c optional drm2 +dev/drm2/ttm/ttm_bo.c optional drm2 +dev/drm2/ttm/ttm_bo_manager.c optional drm2 +dev/drm2/ttm/ttm_execbuf_util.c optional drm2 +dev/drm2/ttm/ttm_memory.c optional drm2 +dev/drm2/ttm/ttm_page_alloc.c optional drm2 +dev/drm2/ttm/ttm_bo_vm.c optional drm2 +dev/drm2/ati_pcigart.c optional drm2 agp pci dev/ed/if_ed.c optional ed dev/ed/if_ed_novell.c optional ed dev/ed/if_ed_rtl80x9.c optional ed Modified: stable/11/sys/dev/drm2/drmP.h ============================================================================== --- stable/11/sys/dev/drm2/drmP.h Sun Apr 16 07:43:29 2017 (r317007) +++ stable/11/sys/dev/drm2/drmP.h Sun Apr 16 07:58:41 2017 (r317008) @@ -1204,17 +1204,6 @@ int drm_mmap_single(struct cdev *kdev, v vm_size_t size, struct vm_object **obj_res, int nprot); d_poll_t drm_poll; - /* Memory management support (drm_memory.h) */ -extern void drm_free_agp(DRM_AGP_MEM * handle, int pages); -extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); -#ifdef FREEBSD_NOTYET -extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, - struct page **pages, - unsigned long num_pages, - uint32_t gtt_offset, - uint32_t type); -#endif /* FREEBSD_NOTYET */ -extern int drm_unbind_agp(DRM_AGP_MEM * handle); /* Misc. IOCTL support (drm_ioctl.h) */ extern int drm_irq_by_busid(struct drm_device *dev, void *data, @@ -1363,32 +1352,6 @@ extern void drm_vblank_post_modeset(stru extern int drm_modeset_ctl(struct drm_device *dev, void *data, struct drm_file *file_priv); - /* AGP/GART support (drm_agpsupport.h) */ -extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); -extern int drm_agp_acquire(struct drm_device *dev); -extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); -extern int drm_agp_release(struct drm_device *dev); -extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); -extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); -extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); -extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); -extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); -extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); -extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); -extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); -extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); -extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); -extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); -extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); -extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); /* Stub support (drm_stub.h) */ extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, @@ -1814,5 +1777,175 @@ int ttm_bo_mmap_single(struct ttm_bo_dev struct ttm_buffer_object; void ttm_bo_release_mmap(struct ttm_buffer_object *bo); +#if __OS_HAS_AGP + /* Memory management support (drm_memory.h) */ +extern void drm_free_agp(DRM_AGP_MEM * handle, int pages); +extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); +#ifdef FREEBSD_NOTYET +extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, + struct page **pages, + unsigned long num_pages, + uint32_t gtt_offset, + uint32_t type); +#endif /* FREEBSD_NOTYET */ +extern int drm_unbind_agp(DRM_AGP_MEM * handle); + + /* AGP/GART support (drm_agpsupport.h) */ +extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); +extern int drm_agp_acquire(struct drm_device *dev); +extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); +extern int drm_agp_release(struct drm_device *dev); +extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); +extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); +extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); +extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); +extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); +extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); +extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); +extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); +extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); +extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); +extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); +extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); +extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); + +#else + +static inline void drm_free_agp(DRM_AGP_MEM * handle, int pages) +{ +} + +static inline int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start) +{ + return -ENODEV; +} + +static inline int drm_unbind_agp(DRM_AGP_MEM * handle) +{ + return -ENODEV; +} +#ifdef FREEBSD_NOTYET +static inline struct agp_memory *drm_agp_bind_pages(struct drm_device *dev, + struct page **pages, + unsigned long num_pages, + uint32_t gtt_offset, + uint32_t type) +{ + return NULL; +} +#endif +static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev) +{ + return NULL; +} + +static inline void drm_agp_clear(struct drm_device *dev) +{ +} + +static inline int drm_agp_acquire(struct drm_device *dev) +{ + return -ENODEV; +} + +static inline int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return -ENODEV; +} + +static inline int drm_agp_release(struct drm_device *dev) +{ + return -ENODEV; +} + +static inline int drm_agp_release_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return -ENODEV; +} + +static inline int drm_agp_enable(struct drm_device *dev, + struct drm_agp_mode mode) +{ + return -ENODEV; +} + +static inline int drm_agp_enable_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return -ENODEV; +} + +static inline int drm_agp_info(struct drm_device *dev, + struct drm_agp_info *info) +{ + return -ENODEV; +} + +static inline int drm_agp_info_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return -ENODEV; +} + +static inline int drm_agp_alloc(struct drm_device *dev, + struct drm_agp_buffer *request) +{ + return -ENODEV; +} + +static inline int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return -ENODEV; +} + +static inline int drm_agp_free(struct drm_device *dev, + struct drm_agp_buffer *request) +{ + return -ENODEV; +} + +static inline int drm_agp_free_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return -ENODEV; +} + +static inline int drm_agp_unbind(struct drm_device *dev, + struct drm_agp_binding *request) +{ + return -ENODEV; +} + +static inline int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return -ENODEV; +} + +static inline int drm_agp_bind(struct drm_device *dev, + struct drm_agp_binding *request) +{ + return -ENODEV; +} + +static inline int drm_agp_bind_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return -ENODEV; +} + +#endif /* __OS_HAS_AGP */ + #endif /* __KERNEL__ */ #endif Modified: stable/11/sys/dev/drm2/drm_memory.c ============================================================================== --- stable/11/sys/dev/drm2/drm_memory.c Sun Apr 16 07:43:29 2017 (r317007) +++ stable/11/sys/dev/drm2/drm_memory.c Sun Apr 16 07:58:41 2017 (r317008) @@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$"); #include +#define vunmap(handle) + #if __OS_HAS_AGP static void *agp_remap(unsigned long offset, unsigned long size, struct drm_device * dev) @@ -50,8 +52,6 @@ static void *agp_remap(unsigned long off return NULL; } -#define vunmap(handle) - /** Wrapper around agp_free_memory() */ void drm_free_agp(DRM_AGP_MEM * handle, int pages) { Modified: stable/11/sys/dev/drm2/drm_os_freebsd.c ============================================================================== --- stable/11/sys/dev/drm2/drm_os_freebsd.c Sun Apr 16 07:43:29 2017 (r317007) +++ stable/11/sys/dev/drm2/drm_os_freebsd.c Sun Apr 16 07:58:41 2017 (r317008) @@ -347,6 +347,7 @@ dmi_check_system(const struct dmi_system return (res); } +#if __OS_HAS_MTRR int drm_mtrr_add(unsigned long offset, unsigned long size, unsigned int flags) { @@ -375,6 +376,7 @@ drm_mtrr_del(int handle __unused, unsign strlcpy(mrdesc.mr_owner, "drm", sizeof(mrdesc.mr_owner)); return (-mem_range_attr_set(&mrdesc, &act)); } +#endif void drm_clflush_pages(vm_page_t *pages, unsigned long num_pages) Modified: stable/11/sys/dev/drm2/drm_os_freebsd.h ============================================================================== --- stable/11/sys/dev/drm2/drm_os_freebsd.h Sun Apr 16 07:43:29 2017 (r317007) +++ stable/11/sys/dev/drm2/drm_os_freebsd.h Sun Apr 16 07:58:41 2017 (r317008) @@ -591,8 +591,10 @@ typedef struct drm_pci_id_list #define CONFIG_COMPAT #endif +#ifndef __arm__ #define CONFIG_AGP 1 #define CONFIG_MTRR 1 +#endif #define CONFIG_FB 1 extern const char *fb_mode_option; Modified: stable/11/sys/dev/drm2/ttm/ttm_bo_util.c ============================================================================== --- stable/11/sys/dev/drm2/ttm/ttm_bo_util.c Sun Apr 16 07:43:29 2017 (r317007) +++ stable/11/sys/dev/drm2/ttm/ttm_bo_util.c Sun Apr 16 07:58:41 2017 (r317008) @@ -439,7 +439,8 @@ ttm_buffer_object_transfer(struct ttm_bu vm_memattr_t ttm_io_prot(uint32_t caching_flags) { -#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) +#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) || \ + defined(__arm__) if (caching_flags & TTM_PL_FLAG_WC) return (VM_MEMATTR_WRITE_COMBINING); else From owner-svn-src-all@freebsd.org Sun Apr 16 08:01:59 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 047C1D40AB0; Sun, 16 Apr 2017 08:01:59 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C46559A0; Sun, 16 Apr 2017 08:01:58 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G81v7A097498; Sun, 16 Apr 2017 08:01:57 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G81vks097497; Sun, 16 Apr 2017 08:01:57 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160801.v3G81vks097497@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 08:01:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317009 - stable/11/sys/dev/extres/clk X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 08:01:59 -0000 Author: mmel Date: Sun Apr 16 08:01:57 2017 New Revision: 317009 URL: https://svnweb.freebsd.org/changeset/base/317009 Log: MFC r309537: Clock framework fixes: - The clk_test_freq() (aka CLK_SET_DRYRUN) doesn't change frequency, don't cache it result. - Fix busy condition for clk_set_freq(). Modified: stable/11/sys/dev/extres/clk/clk.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/extres/clk/clk.c ============================================================================== --- stable/11/sys/dev/extres/clk/clk.c Sun Apr 16 07:58:41 2017 (r317008) +++ stable/11/sys/dev/extres/clk/clk.c Sun Apr 16 08:01:57 2017 (r317009) @@ -830,9 +830,10 @@ clknode_set_freq(struct clknode *clknode * OR * clock is glitch free and is enabled by calling consumer only */ - if ((clknode->enable_cnt > 1) && - ((clknode->enable_cnt > enablecnt) || - !(clknode->flags & CLK_NODE_GLITCH_FREE))) { + if ((flags & CLK_SET_DRYRUN) == 0 && + clknode->enable_cnt > 1 && + clknode->enable_cnt > enablecnt && + (clknode->flags & CLK_NODE_GLITCH_FREE) == 0) { return (EBUSY); } @@ -856,9 +857,10 @@ clknode_set_freq(struct clknode *clknode if (done) { /* Success - invalidate frequency cache for all children. */ - clknode->freq = freq; - if ((flags & CLK_SET_DRYRUN) == 0) + if ((flags & CLK_SET_DRYRUN) == 0) { + clknode->freq = freq; clknode_refresh_cache(clknode, parent_freq); + } } else if (clknode->parent != NULL) { /* Nothing changed, pass request to parent. */ rv = clknode_set_freq(clknode->parent, freq, flags, enablecnt); From owner-svn-src-all@freebsd.org Sun Apr 16 08:04:03 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2831BD40B50; Sun, 16 Apr 2017 08:04:03 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F267BB53; Sun, 16 Apr 2017 08:04:02 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G842Hs098304; Sun, 16 Apr 2017 08:04:02 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G841Zc098300; Sun, 16 Apr 2017 08:04:01 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160804.v3G841Zc098300@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 08:04:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317010 - stable/11/sys/dev/sound/pci/hda X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 08:04:03 -0000 Author: mmel Date: Sun Apr 16 08:04:01 2017 New Revision: 317010 URL: https://svnweb.freebsd.org/changeset/base/317010 Log: MFC r309532,r310674: r309532: Add IDs for HDA codecs found on Nvidia Tegra SoCs. r310674: Limit number of stripes supported by HDA codec to maximum number announced by HDA controller. Incorrectly implermented HDA codec may report support for more stripes that HDA controller already have. Due to this, always limit number of enabled stripes by global controller maximum. Modified: stable/11/sys/dev/sound/pci/hda/hdaa.c stable/11/sys/dev/sound/pci/hda/hdac.c stable/11/sys/dev/sound/pci/hda/hdac.h stable/11/sys/dev/sound/pci/hda/hdacc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sound/pci/hda/hdaa.c ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdaa.c Sun Apr 16 08:01:57 2017 (r317009) +++ stable/11/sys/dev/sound/pci/hda/hdaa.c Sun Apr 16 08:04:01 2017 (r317010) @@ -2130,7 +2130,8 @@ hdaa_channel_start(struct hdaa_chan *ch) uint32_t fmt; fmt = hdaa_stream_format(ch); - ch->stripectl = fls(ch->stripecap & hdaa_allowed_stripes(fmt)) - 1; + ch->stripectl = fls(ch->stripecap & hdaa_allowed_stripes(fmt) & + hda_get_stripes_mask(devinfo->dev)) - 1; ch->sid = HDAC_STREAM_ALLOC(device_get_parent(devinfo->dev), devinfo->dev, ch->dir == PCMDIR_PLAY ? 1 : 0, fmt, ch->stripectl, &ch->dmapos); if (ch->sid <= 0) Modified: stable/11/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.c Sun Apr 16 08:01:57 2017 (r317009) +++ stable/11/sys/dev/sound/pci/hda/hdac.c Sun Apr 16 08:04:01 2017 (r317010) @@ -1767,6 +1767,9 @@ hdac_read_ivar(device_t dev, device_t ch case HDA_IVAR_DMA_NOCACHE: *result = (sc->flags & HDAC_F_DMA_NOCACHE) != 0; break; + case HDA_IVAR_STRIPES_MASK: + *result = (1 << (1 << sc->num_sdo)) - 1; + break; default: return (ENOENT); } Modified: stable/11/sys/dev/sound/pci/hda/hdac.h ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.h Sun Apr 16 08:01:57 2017 (r317009) +++ stable/11/sys/dev/sound/pci/hda/hdac.h Sun Apr 16 08:04:01 2017 (r317010) @@ -619,6 +619,10 @@ #define HDA_CODEC_NVIDIAGT440 HDA_CODEC_CONSTRUCT(NVIDIA, 0x0014) #define HDA_CODEC_NVIDIAGTX550 HDA_CODEC_CONSTRUCT(NVIDIA, 0x0015) #define HDA_CODEC_NVIDIAGTX570 HDA_CODEC_CONSTRUCT(NVIDIA, 0x0018) +#define HDA_CODEC_NVIDIATEGRA30 HDA_CODEC_CONSTRUCT(NVIDIA, 0x0020) +#define HDA_CODEC_NVIDIATEGRA114 HDA_CODEC_CONSTRUCT(NVIDIA, 0x0022) +#define HDA_CODEC_NVIDIATEGRA124 HDA_CODEC_CONSTRUCT(NVIDIA, 0x0028) +#define HDA_CODEC_NVIDIATEGRA210 HDA_CODEC_CONSTRUCT(NVIDIA, 0x0029) #define HDA_CODEC_NVIDIAMCP67 HDA_CODEC_CONSTRUCT(NVIDIA, 0x0067) #define HDA_CODEC_NVIDIAMCP73 HDA_CODEC_CONSTRUCT(NVIDIA, 0x8001) #define HDA_CODEC_NVIDIAXXXX HDA_CODEC_CONSTRUCT(NVIDIA, 0xffff) @@ -703,6 +707,7 @@ enum hdac_device_ivars { HDA_IVAR_SUBSYSTEM_ID, HDA_IVAR_NODE_TYPE, HDA_IVAR_DMA_NOCACHE, + HDA_IVAR_STRIPES_MASK, }; #define HDA_ACCESSOR(var, ivar, type) \ @@ -719,6 +724,7 @@ HDA_ACCESSOR(subdevice_id, SUBDEVICE_ID, HDA_ACCESSOR(subsystem_id, SUBSYSTEM_ID, uint32_t); HDA_ACCESSOR(node_type, NODE_TYPE, uint8_t); HDA_ACCESSOR(dma_nocache, DMA_NOCACHE, uint8_t); +HDA_ACCESSOR(stripes_mask, STRIPES_MASK, uint8_t); #define PCIS_MULTIMEDIA_HDA 0x03 Modified: stable/11/sys/dev/sound/pci/hda/hdacc.c ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdacc.c Sun Apr 16 08:01:57 2017 (r317009) +++ stable/11/sys/dev/sound/pci/hda/hdacc.c Sun Apr 16 08:04:01 2017 (r317010) @@ -314,6 +314,10 @@ static const struct { { HDA_CODEC_NVIDIAGT440, 0, "NVIDIA GT440" }, { HDA_CODEC_NVIDIAGTX550, 0, "NVIDIA GTX550" }, { HDA_CODEC_NVIDIAGTX570, 0, "NVIDIA GTX570" }, + { HDA_CODEC_NVIDIATEGRA30, 0, "NVIDIA Tegra30" }, + { HDA_CODEC_NVIDIATEGRA114, 0, "NVIDIA Tegra114" }, + { HDA_CODEC_NVIDIATEGRA124, 0, "NVIDIA Tegra124" }, + { HDA_CODEC_NVIDIATEGRA210, 0, "NVIDIA Tegra210" }, { HDA_CODEC_INTELIP, 0, "Intel Ibex Peak" }, { HDA_CODEC_INTELBL, 0, "Intel Bearlake" }, { HDA_CODEC_INTELCA, 0, "Intel Cantiga" }, From owner-svn-src-all@freebsd.org Sun Apr 16 08:07:39 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6599D40CB5; Sun, 16 Apr 2017 08:07:39 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C34ACCF9; Sun, 16 Apr 2017 08:07:39 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G87cF2098494; Sun, 16 Apr 2017 08:07:38 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G87cBL098490; Sun, 16 Apr 2017 08:07:38 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160807.v3G87cBL098490@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 08:07:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317011 - in stable/11/sys: conf dev/drm2 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 08:07:40 -0000 Author: mmel Date: Sun Apr 16 08:07:38 2017 New Revision: 317011 URL: https://svnweb.freebsd.org/changeset/base/317011 Log: MFC r310593,r310599: r310593: Fix late monitor hotplug event. If system starts without attached monitor, DRM create framebuffer for VT console. Later, when monitor is attached, the hotplug event must issue full modeset procedure to setup CRTC. In original code, this was done in drm_fb_helper_set_par(), but we don't have this function implemented yet. Use unrolled version of drm_fb_helper_set_par() to ensure same functionality. r310599: Import drm_patform.c, an implementation of non-PCI based attachment for graphics drivers. It will be used in upcoming driver for Nvidia Tegra boards. Added: stable/11/sys/dev/drm2/drm_platform.c - copied unchanged from r310599, head/sys/dev/drm2/drm_platform.c Modified: stable/11/sys/conf/files stable/11/sys/dev/drm2/drmP.h stable/11/sys/dev/drm2/drm_fb_helper.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Sun Apr 16 08:04:01 2017 (r317010) +++ stable/11/sys/conf/files Sun Apr 16 08:07:38 2017 (r317011) @@ -1477,6 +1477,7 @@ dev/drm2/drm_memory.c optional drm2 dev/drm2/drm_mm.c optional drm2 dev/drm2/drm_modes.c optional drm2 dev/drm2/drm_pci.c optional drm2 +dev/drm2/drm_platform.c optional drm2 dev/drm2/drm_scatter.c optional drm2 dev/drm2/drm_stub.c optional drm2 dev/drm2/drm_sysctl.c optional drm2 Modified: stable/11/sys/dev/drm2/drmP.h ============================================================================== --- stable/11/sys/dev/drm2/drmP.h Sun Apr 16 08:04:01 2017 (r317010) +++ stable/11/sys/dev/drm2/drmP.h Sun Apr 16 08:07:38 2017 (r317011) @@ -1576,6 +1576,10 @@ extern int drm_pcie_get_speed_cap_mask(s #define drm_can_sleep() (DRM_HZ & 1) +/* Platform section */ +int drm_get_platform_dev(device_t kdev, struct drm_device *dev, + struct drm_driver *driver); + /* FreeBSD specific -- should be moved to drm_os_freebsd.h */ #define DRM_GEM_MAPPING_MASK (3ULL << 62) Modified: stable/11/sys/dev/drm2/drm_fb_helper.c ============================================================================== --- stable/11/sys/dev/drm2/drm_fb_helper.c Sun Apr 16 08:04:01 2017 (r317010) +++ stable/11/sys/dev/drm2/drm_fb_helper.c Sun Apr 16 08:07:38 2017 (r317011) @@ -339,6 +339,7 @@ bool drm_fb_helper_restore_fbdev_mode(st { bool error = false; int i, ret; + for (i = 0; i < fb_helper->crtc_count; i++) { struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set; ret = mode_set->crtc->funcs->set_config(mode_set); @@ -841,6 +842,9 @@ int drm_fb_helper_single_fb_probe(struct struct drm_fb_helper_surface_size sizes; int gamma_size = 0; #if defined(__FreeBSD__) + struct drm_crtc *crtc; + struct drm_device *dev; + int ret; device_t kdev; #endif @@ -942,6 +946,24 @@ int drm_fb_helper_single_fb_probe(struct if (ret != 0) DRM_ERROR("Failed to attach fbd device: %d\n", ret); #endif + } else { + /* Modified version of drm_fb_helper_set_par() */ + dev = fb_helper->dev; + sx_xlock(&dev->mode_config.mutex); + for (i = 0; i < fb_helper->crtc_count; i++) { + crtc = fb_helper->crtc_info[i].mode_set.crtc; + ret = crtc->funcs->set_config(&fb_helper->crtc_info[i].mode_set); + if (ret) { + sx_xunlock(&dev->mode_config.mutex); + return ret; + } + } + sx_xunlock(&dev->mode_config.mutex); + + if (fb_helper->delayed_hotplug) { + fb_helper->delayed_hotplug = false; + drm_fb_helper_hotplug_event(fb_helper); + } } #else if (new_fb) { Copied: stable/11/sys/dev/drm2/drm_platform.c (from r310599, head/sys/dev/drm2/drm_platform.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/dev/drm2/drm_platform.c Sun Apr 16 08:07:38 2017 (r317011, copy of r310599, head/sys/dev/drm2/drm_platform.c) @@ -0,0 +1,183 @@ +/* + * Derived from drm_pci.c + * + * Copyright 2003 José Fonseca. + * Copyright 2003 Leif Delgass. + * Copyright (c) 2009, Code Aurora Forum. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include +__FBSDID("$FreeBSD$"); + +#include + +static void drm_platform_free_irq(struct drm_device *dev) +{ + if (dev->irqr == NULL) + return; + + bus_release_resource(dev->dev, SYS_RES_IRQ, + dev->irqrid, dev->irqr); + + dev->irqr = NULL; + dev->irq = 0; +} + +static const char *drm_platform_get_name(struct drm_device *dev) +{ + return dev->driver->name; +} + +static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master) +{ + int len, ret, id; + + master->unique_len = 13 + strlen(dev->driver->name); + master->unique_size = master->unique_len; + master->unique = malloc(master->unique_len + 1, DRM_MEM_DRIVER, M_NOWAIT); + + if (master->unique == NULL) + return -ENOMEM; + + id = 0; // XXX dev->driver->id; + + /* if only a single instance of the platform device, id will be + * set to -1.. use 0 instead to avoid a funny looking bus-id: + */ + if (id == -1) + id = 0; + + len = snprintf(master->unique, master->unique_len, + "platform:%s:%02d", dev->driver->name, id); + + if (len > master->unique_len) { + DRM_ERROR("Unique buffer overflowed\n"); + ret = -EINVAL; + goto err; + } + + return 0; +err: + return ret; +} + +static int drm_platform_get_irq(struct drm_device *dev) +{ + if (dev->irqr) + return (dev->irq); + + dev->irqr = bus_alloc_resource_any(dev->dev, SYS_RES_IRQ, + &dev->irqrid, RF_SHAREABLE); + if (!dev->irqr) { + dev_err(dev->dev, "Failed to allocate IRQ\n"); + return (0); + } + + dev->irq = (int) rman_get_start(dev->irqr); + + return (dev->irq); +} + +static struct drm_bus drm_platform_bus = { + .bus_type = DRIVER_BUS_PLATFORM, + .get_irq = drm_platform_get_irq, + .free_irq = drm_platform_free_irq, + .get_name = drm_platform_get_name, + .set_busid = drm_platform_set_busid, +}; + +/** + * Register. + * + * \param platdev - Platform device struture + * \return zero on success or a negative number on failure. + * + * Attempt to gets inter module "drm" information. If we are first + * then register the character device and inter module information. + * Try and register, if we fail to register, backout previous work. + */ + +int drm_get_platform_dev(device_t kdev, struct drm_device *dev, + struct drm_driver *driver) +{ + int ret; + + DRM_DEBUG("\n"); + + driver->bus = &drm_platform_bus; + + dev->dev = kdev; + + sx_xlock(&drm_global_mutex); + + ret = drm_fill_in_dev(dev, driver); + + if (ret) { + printf("DRM: Fill_in_dev failed.\n"); + goto err_g1; + } + + if (drm_core_check_feature(dev, DRIVER_MODESET)) { + ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL); + if (ret) + goto err_g1; + } + + ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY); + if (ret) + goto err_g2; + + if (dev->driver->load) { + ret = dev->driver->load(dev, 0); + if (ret) + goto err_g3; + } + + /* setup the grouping for the legacy output */ + if (drm_core_check_feature(dev, DRIVER_MODESET)) { + ret = drm_mode_group_init_legacy_group(dev, + &dev->primary->mode_group); + if (ret) + goto err_g3; + } + +#ifdef FREEBSD_NOTYET + list_add_tail(&dev->driver_item, &driver->device_list); +#endif /* FREEBSD_NOTYET */ + + sx_xunlock(&drm_global_mutex); + + DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", + driver->name, driver->major, driver->minor, driver->patchlevel, + driver->date, dev->primary->index); + + return 0; + +err_g3: + drm_put_minor(&dev->primary); +err_g2: + if (drm_core_check_feature(dev, DRIVER_MODESET)) + drm_put_minor(&dev->control); +err_g1: + sx_xunlock(&drm_global_mutex); + return ret; +} +EXPORT_SYMBOL(drm_get_platform_dev); From owner-svn-src-all@freebsd.org Sun Apr 16 08:18:39 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0A0F3D3E078; Sun, 16 Apr 2017 08:18:39 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 CA23413B4; Sun, 16 Apr 2017 08:18:38 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G8Icaf002686; Sun, 16 Apr 2017 08:18:38 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G8Ib5K002681; Sun, 16 Apr 2017 08:18:37 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160818.v3G8Ib5K002681@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 08:18:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317012 - in stable/11/sys/arm/nvidia: . tegra124 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 08:18:39 -0000 Author: mmel Date: Sun Apr 16 08:18:37 2017 New Revision: 317012 URL: https://svnweb.freebsd.org/changeset/base/317012 Log: MFC r308286,r308287: r308286: TEGRA: Add basic driver for memory controller. For now, it only reports memory and SMMU access errors. r308287: TEGRA: Fix numerous issues in clock code. Define and export clocks related to XUSB driver. Added: stable/11/sys/arm/nvidia/tegra_mc.c - copied unchanged from r308286, head/sys/arm/nvidia/tegra_mc.c Modified: stable/11/sys/arm/nvidia/tegra124/files.tegra124 stable/11/sys/arm/nvidia/tegra124/tegra124_car.c stable/11/sys/arm/nvidia/tegra124/tegra124_clk_per.c stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/nvidia/tegra124/files.tegra124 ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/files.tegra124 Sun Apr 16 08:07:38 2017 (r317011) +++ stable/11/sys/arm/nvidia/tegra124/files.tegra124 Sun Apr 16 08:18:37 2017 (r317012) @@ -33,6 +33,7 @@ arm/nvidia/tegra_efuse.c standard arm/nvidia/tegra_soctherm_if.m standard arm/nvidia/tegra_soctherm.c standard arm/nvidia/tegra_lic.c standard +arm/nvidia/tegra_mc.c standard #arm/nvidia/tegra_hda.c optional snd_hda #arm/nvidia/drm2/hdmi.c optional drm2 #arm/nvidia/drm2/tegra_drm_if.m optional drm2 Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_car.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_car.c Sun Apr 16 08:07:38 2017 (r317011) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_car.c Sun Apr 16 08:18:37 2017 (r317012) @@ -191,13 +191,13 @@ PLIST(mux_plle_src) = {"pllE_src1", "pll PLIST(mux_plld_out0_plld2_out0) = {"pllD_out0", "pllD2_out0"}; PLIST(mux_pllmcp_clkm) = {"pllM_out0", "pllC_out0", "pllP_out0", "clk_m", "pllM_UD", "pllC2_out0", "pllC3_out0", "pllC_UD"}; -PLIST(mux_xusb_hs) = {"pc_xusb_ss", "pllU_60"}; +PLIST(mux_xusb_hs) = {"xusb_ss_div2", "pllU_60"}; PLIST(mux_xusb_ss) = {"pc_xusb_ss", "osc_div_clk"}; /* Clocks ajusted online. */ static struct clk_fixed_def fixed_clk_m = - FRATE(0, "clk_m", 12000000); + FRATE(TEGRA124_CLK_CLK_M, "clk_m", 12000000); static struct clk_fixed_def fixed_osc_div_clk = FACT(0, "osc_div_clk", "clk_m", 1, 1); @@ -222,6 +222,10 @@ static struct clk_fixed_def tegra124_fix FRATE(0, "audio3", 10000000), FRATE(0, "audio4", 10000000), FRATE(0, "ext_vimclk", 10000000), + + /* XUSB */ + FACT(TEGRA124_CLK_XUSB_SS_DIV2, "xusb_ss_div2", "xusb_ss", 1, 2), + }; @@ -239,7 +243,7 @@ static struct clk_mux_def tegra124_mux_c MUX(0, "emc_mux", mux_pllmcp_clkm, CLK_SOURCE_EMC, 29, 3), /* USB. */ - MUX(0, "xusb_hs", mux_xusb_hs, CLK_SOURCE_XUSB_SS, 25, 1), + MUX(TEGRA124_CLK_XUSB_HS_SRC, "xusb_hs", mux_xusb_hs, CLK_SOURCE_XUSB_SS, 25, 1), MUX(0, "xusb_ss_mux", mux_xusb_ss, CLK_SOURCE_XUSB_SS, 24, 1), }; @@ -249,7 +253,7 @@ static struct clk_gate_def tegra124_gate /* Core clocks. */ GATE_PLL(0, "pllC_out1", "pllC_out1_div", PLLC_OUT, 0), GATE_PLL(0, "pllM_out1", "pllM_out1_div", PLLM_OUT, 0), - GATE_PLL(0, "pllU_480", "pllU_out", PLLU_BASE, 22), + GATE_PLL(TEGRA124_CLK_PLL_U_480M, "pllU_480", "pllU_out", PLLU_BASE, 22), GATE_PLL(0, "pllP_outX0", "pllP_outX0_div", PLLP_RESHIFT, 0), GATE_PLL(0, "pllP_out1", "pllP_out1_div", PLLP_OUTA, 0), GATE_PLL(0, "pllP_out2", "pllP_out2_div", PLLP_OUTA, 16), Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_clk_per.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_clk_per.c Sun Apr 16 08:07:38 2017 (r317011) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_clk_per.c Sun Apr 16 08:18:37 2017 (r317012) @@ -41,6 +41,15 @@ __FBSDID("$FreeBSD$"); #include #include "tegra124_car.h" +/* The TEGRA124_CLK_XUSB_GATE is missing in current + * DT bindings, define it localy + */ +#ifdef TEGRA124_CLK_XUSB_GATE +#error "TEGRA124_CLK_XUSB_GATE is now defined, revisit XUSB code!" +#else +#define TEGRA124_CLK_XUSB_GATE 143 +#endif + /* Bits in base register. */ #define PERLCK_AMUX_MASK 0x0F #define PERLCK_AMUX_SHIFT 16 @@ -175,7 +184,7 @@ PLIST(mux_sep_audio) = "spdif_in", "i2s0", "i2s1", "i2s2", "i2s4", "pllA_out0", "ext_vimclk"}; -static uint32_t clk_enabale_reg[] = { +static uint32_t clk_enable_reg[] = { CLK_OUT_ENB_L, CLK_OUT_ENB_H, CLK_OUT_ENB_U, @@ -285,7 +294,7 @@ static struct pgate_def pgate_def[] = { GATE(CSUS, "sus_out", "clk_m", U(28)), /* GATE(DEVD2_OUT, "devd2_out", "clk_m", U(29)), */ /* GATE(DEVD1_OUT, "devd1_out", "clk_m", U(30)), */ - GATE(XUSB_DEV_SRC, "xusb_core_dev", "pc_xusb_core_dev", U(31)), + GATE(XUSB_DEV, "xusb_core_dev", "pc_xusb_core_dev", U(31)), /* bank V -> 96-127 */ /* GATE(CPUG, "cpug", "clk_m", V(0)), */ @@ -328,7 +337,7 @@ static struct pgate_def pgate_def[] = { /* GATE(HDMI_IOBIST, "hdmi_iobist", "clk_m", W(11)), */ /* GATE(SATA_IOBIST, "sata_iobist", "clk_m", W(12)), */ /* GATE(MIPI_IOBIST, "mipi_iobist", "clk_m", W(13)), */ - /* GATE(XUSB_IOBIST, "xusb_iobist", "clk_m", W(15)), */ + GATE(XUSB_GATE, "xusb_gate", "clk_m", W(15)), GATE(CILAB, "cilab", "pc_cilab", W(16)), GATE(CILCD, "cilcd", "pc_cilcd", W(17)), GATE(CILE, "cile", "pc_cile", W(18)), @@ -337,10 +346,10 @@ static struct pgate_def pgate_def[] = { GATE(ENTROPY, "entropy", "pc_entropy", W(21)), GATE(AMX, "amx", "pc_amx", W(25)), GATE(ADX, "adx", "pc_adx", W(26)), - GATE(DFLL_REF, "dvfs_ref", "pc_dvfs_ref", X(27)), - GATE(DFLL_SOC, "dvfs_soc", "pc_dvfs_soc", X(27)), - GATE(XUSB_SS_SRC, "xusb_ss", "xusb_ss_mux", X(28)), - /* GATE(EMC_LATENCY, "emc_latency", "pc_emc_latency", X(29)), */ + GATE(DFLL_REF, "dvfs_ref", "pc_dvfs_ref", W(27)), + GATE(DFLL_SOC, "dvfs_soc", "pc_dvfs_soc", W(27)), + GATE(XUSB_SS, "xusb_ss", "xusb_ss_mux", W(28)), + /* GATE(EMC_LATENCY, "emc_latency", "pc_emc_latency", W(29)), */ /* bank X -> 160-191*/ /* GATE(SPARE, "spare", "clk_m", X(0)), */ @@ -391,111 +400,115 @@ static struct pgate_def pgate_def[] = { } /* Mux with fractional 8.1 divider. */ -#define CLK_8_1(cn, pl, r, f) \ - PER_CLK(0, cn, pl, r, 8, 1, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) +#define CLK_8_1(id, cn, pl, r, f) \ + PER_CLK(id, cn, pl, r, 8, 1, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) + /* Mux with fractional 16.1 divider. */ -#define CLK16_1(cn, pl, r, f) \ - PER_CLK(0, cn, pl, r, 16, 1, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) +#define CLK16_1(id, cn, pl, r, f) \ + PER_CLK(id, cn, pl, r, 16, 1, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) /* Mux with integer 16bits divider. */ -#define CLK16_0(cn, pl, r, f) \ - PER_CLK(0, cn, pl, r, 16, 0, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) +#define CLK16_0(id, cn, pl, r, f) \ + PER_CLK(id, cn, pl, r, 16, 0, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) /* Mux wihout divider. */ -#define CLK_0_0(cn, pl, r, f) \ - PER_CLK(0, cn, pl, r, 0, 0, (f) | DCF_HAVE_MUX) +#define CLK_0_0(id, cn, pl, r, f) \ + PER_CLK(id, cn, pl, r, 0, 0, (f) | DCF_HAVE_MUX) static struct periph_def periph_def[] = { - CLK_8_1("pc_i2s1", mux_a_N_audio1_N_p_N_clkm, CLK_SOURCE_I2S1, DCF_HAVE_ENA), - CLK_8_1("pc_i2s2", mux_a_N_audio2_N_p_N_clkm, CLK_SOURCE_I2S2, DCF_HAVE_ENA), - CLK_8_1("pc_spdif_out", mux_a_N_audio_N_p_N_clkm, CLK_SOURCE_SPDIF_OUT, 0), - CLK_8_1("pc_spdif_in", mux_p_c2_c_c3_m, CLK_SOURCE_SPDIF_IN, 0), - CLK_8_1("pc_pwm", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_PWM, 0), - CLK_8_1("pc_spi2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI2, 0), - CLK_8_1("pc_spi3", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI3, 0), - CLK16_0("pc_i2c5", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C5, 0), - CLK16_0("pc_i2c1", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C1, 0), - CLK_8_1("pc_spi1", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI1, 0), - CLK_0_0("pc_disp1", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_DISP1, 0), - CLK_0_0("pc_disp2", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_DISP2, 0), - CLK_8_1("pc_isp", mux_m_c_p_a_c2_c3_clkm_c4, CLK_SOURCE_ISP, 0), - CLK_8_1("pc_vi", mux_m_c2_c_c3_p_N_a_c4, CLK_SOURCE_VI, DCF_IS_VI), - CLK_8_1("pc_sdmmc1", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC1, 0), - CLK_8_1("pc_sdmmc2", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC2, 0), - CLK_8_1("pc_sdmmc4", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC4, 0), - CLK_8_1("pc_vfir", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_VFIR, 0), - CLK_8_1("pc_hsi", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HSI, 0), - CLK16_1("pc_uarta", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTA, DCF_IS_UART), - CLK16_1("pc_uartb", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTB, DCF_IS_UART), - CLK_8_1("pc_host1x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HOST1X, DCF_IS_HOST1X), - CLK_8_1("pc_hdmi", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_HDMI, 0), - CLK16_0("pc_i2c2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C2, 0), + CLK_8_1(0, "pc_i2s1", mux_a_N_audio1_N_p_N_clkm, CLK_SOURCE_I2S1, DCF_HAVE_ENA), + CLK_8_1(0, "pc_i2s2", mux_a_N_audio2_N_p_N_clkm, CLK_SOURCE_I2S2, DCF_HAVE_ENA), + CLK_8_1(0, "pc_spdif_out", mux_a_N_audio_N_p_N_clkm, CLK_SOURCE_SPDIF_OUT, 0), + CLK_8_1(0, "pc_spdif_in", mux_p_c2_c_c3_m, CLK_SOURCE_SPDIF_IN, 0), + CLK_8_1(0, "pc_pwm", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_PWM, 0), + CLK_8_1(0, "pc_spi2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI2, 0), + CLK_8_1(0, "pc_spi3", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI3, 0), + CLK16_0(0, "pc_i2c5", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C5, 0), + CLK16_0(0, "pc_i2c1", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C1, 0), + CLK_8_1(0, "pc_spi1", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI1, 0), + CLK_0_0(0, "pc_disp1", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_DISP1, 0), + CLK_0_0(0, "pc_disp2", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_DISP2, 0), + CLK_8_1(0, "pc_isp", mux_m_c_p_a_c2_c3_clkm_c4, CLK_SOURCE_ISP, 0), + CLK_8_1(0, "pc_vi", mux_m_c2_c_c3_p_N_a_c4, CLK_SOURCE_VI, DCF_IS_VI), + CLK_8_1(0, "pc_sdmmc1", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC1, 0), + CLK_8_1(0, "pc_sdmmc2", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC2, 0), + CLK_8_1(0, "pc_sdmmc4", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC4, 0), + CLK_8_1(0, "pc_vfir", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_VFIR, 0), + CLK_8_1(0, "pc_hsi", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HSI, 0), + CLK16_1(0, "pc_uarta", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTA, DCF_IS_UART), + CLK16_1(0, "pc_uartb", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTB, DCF_IS_UART), + CLK_8_1(0, "pc_host1x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HOST1X, DCF_IS_HOST1X), + CLK_8_1(0, "pc_hdmi", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_HDMI, 0), + CLK16_0(0, "pc_i2c2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C2, 0), /* EMC 8 */ - CLK16_1("pc_uartc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTC, DCF_IS_UART), - CLK_8_1("pc_vi_sensor", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR, 0), - CLK_8_1("pc_spi4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI4, 0), - CLK16_0("pc_i2c3", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C3, 0), - CLK_8_1("pc_sdmmc3", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC3, 0), - CLK16_1("pc_uartd", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTD, DCF_IS_UART), - CLK_8_1("pc_vde", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_VDE, 0), - CLK_8_1("pc_owr", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_OWR, 0), - CLK_8_1("pc_snor", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_NOR, 0), - CLK_8_1("pc_csite", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_CSITE, 0), - CLK_8_1("pc_i2s0", mux_a_N_audio0_N_p_N_clkm, CLK_SOURCE_I2S0, 0), + CLK16_1(0, "pc_uartc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTC, DCF_IS_UART), + CLK_8_1(0, "pc_vi_sensor", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR, 0), + CLK_8_1(0, "pc_spi4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI4, 0), + CLK16_0(0, "pc_i2c3", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C3, 0), + CLK_8_1(0, "pc_sdmmc3", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC3, 0), + CLK16_1(0, "pc_uartd", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTD, DCF_IS_UART), + CLK_8_1(0, "pc_vde", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_VDE, 0), + CLK_8_1(0, "pc_owr", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_OWR, 0), + CLK_8_1(0, "pc_snor", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_NOR, 0), + CLK_8_1(0, "pc_csite", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_CSITE, 0), + CLK_8_1(0, "pc_i2s0", mux_a_N_audio0_N_p_N_clkm, CLK_SOURCE_I2S0, 0), /* DTV xxx */ - CLK_8_1("pc_msenc", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_MSENC, 0), - CLK_8_1("pc_tsec", mux_p_c2_c_c3_m_a_clkm, CLK_SOURCE_TSEC, 0), + CLK_8_1(0, "pc_msenc", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_MSENC, 0), + CLK_8_1(0, "pc_tsec", mux_p_c2_c_c3_m_a_clkm, CLK_SOURCE_TSEC, 0), /* SPARE2 */ - CLK_8_1("pc_mselect", mux_p_c2_c_c3_m_clks_clkm, CLK_SOURCE_MSELECT, 0), - CLK_8_1("pc_tsensor", mux_p_c2_c_c3_clkm_N_clks, CLK_SOURCE_TSENSOR, 0), - CLK_8_1("pc_i2s3", mux_a_N_audio3_N_p_N_clkm, CLK_SOURCE_I2S3, DCF_HAVE_ENA), - CLK_8_1("pc_i2s4", mux_a_N_audio4_N_p_N_clkm, CLK_SOURCE_I2S4, DCF_HAVE_ENA), - CLK16_0("pc_i2c4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C4, 0), - CLK_8_1("pc_spi5", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI5, 0), - CLK_8_1("pc_spi6", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI6, 0), - CLK_8_1("pc_audio", mux_sep_audio, CLK_SOURCE_AUDIO, DCF_IS_AUDIO), - CLK_8_1("pc_dam0", mux_sep_audio, CLK_SOURCE_DAM0, DCF_IS_AUDIO), - CLK_8_1("pc_dam1", mux_sep_audio, CLK_SOURCE_DAM1, DCF_IS_AUDIO), - CLK_8_1("pc_dam2", mux_sep_audio, CLK_SOURCE_DAM2, DCF_IS_AUDIO), - CLK_8_1("pc_hda2codec_2x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA2CODEC_2X, 0), - CLK_8_1("pc_actmon", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_ACTMON, 0), - CLK_8_1("pc_extperiph1", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH1, 0), - CLK_8_1("pc_extperiph2", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH2, 0), - CLK_8_1("pc_extperiph3", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH3, 0), - CLK_8_1("pc_i2c_slow", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_I2C_SLOW, 0), + CLK_8_1(0, "pc_mselect", mux_p_c2_c_c3_m_clks_clkm, CLK_SOURCE_MSELECT, 0), + CLK_8_1(0, "pc_tsensor", mux_p_c2_c_c3_clkm_N_clks, CLK_SOURCE_TSENSOR, 0), + CLK_8_1(0, "pc_i2s3", mux_a_N_audio3_N_p_N_clkm, CLK_SOURCE_I2S3, DCF_HAVE_ENA), + CLK_8_1(0, "pc_i2s4", mux_a_N_audio4_N_p_N_clkm, CLK_SOURCE_I2S4, DCF_HAVE_ENA), + CLK16_0(0, "pc_i2c4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C4, 0), + CLK_8_1(0, "pc_spi5", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI5, 0), + CLK_8_1(0, "pc_spi6", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI6, 0), + CLK_8_1(0, "pc_audio", mux_sep_audio, CLK_SOURCE_AUDIO, DCF_IS_AUDIO), + CLK_8_1(0, "pc_dam0", mux_sep_audio, CLK_SOURCE_DAM0, DCF_IS_AUDIO), + CLK_8_1(0, "pc_dam1", mux_sep_audio, CLK_SOURCE_DAM1, DCF_IS_AUDIO), + CLK_8_1(0, "pc_dam2", mux_sep_audio, CLK_SOURCE_DAM2, DCF_IS_AUDIO), + CLK_8_1(0, "pc_hda2codec_2x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA2CODEC_2X, 0), + CLK_8_1(0, "pc_actmon", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_ACTMON, 0), + CLK_8_1(0, "pc_extperiph1", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH1, 0), + CLK_8_1(0, "pc_extperiph2", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH2, 0), + CLK_8_1(0, "pc_extperiph3", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH3, 0), + CLK_8_1(0, "pc_i2c_slow", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_I2C_SLOW, 0), /* SYS */ - CLK_8_1("pc_sor0", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_SOR0, DCF_IS_SOR0), - CLK_8_1("pc_sata_oob", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA_OOB, 0), - CLK_8_1("pc_sata", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA, FDS_IS_SATA), - CLK_8_1("pc_hda", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA, 0), - - - CLK_8_1("pc_xusb_core_host", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_HOST, 0), - CLK_8_1("pc_xusb_falcon", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_FALCON, 0), - CLK_8_1("pc_xusb_fs", mux_clkm_N_u48_N_p_N_u480, CLK_SOURCE_XUSB_FS, 0), - CLK_8_1("pc_xusb_core_dev", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_DEV, 0), - CLK_8_1("pc_xusb_ss", mux_clkm_refe_clks_u480_c_c2_c3_oscdiv, CLK_SOURCE_XUSB_SS, DCF_IS_XUSB_SS), - CLK_8_1("pc_cilab", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILAB, 0), - CLK_8_1("pc_cilcd", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILCD, 0), - CLK_8_1("pc_cile", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILE, 0), - CLK_8_1("pc_dsia_lp", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_DSIA_LP, 0), - CLK_8_1("pc_dsib_lp", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_DSIB_LP, 0), - CLK_8_1("pc_entropy", mux_p_clkm_clks_E, CLK_SOURCE_ENTROPY, 0), - CLK_8_1("pc_dvfs_ref", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_DVFS_REF, DCF_HAVE_ENA), - CLK_8_1("pc_dvfs_soc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_DVFS_SOC, DCF_HAVE_ENA), - CLK_8_1("pc_traceclkin", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_TRACECLKIN, 0), - CLK_8_1("pc_adx", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_ADX, DCF_HAVE_ENA), - CLK_8_1("pc_amx", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_AMX, DCF_HAVE_ENA), - CLK_8_1("pc_emc_latency", mux_m_c_p_clkm_mud_c2_c3, CLK_SOURCE_EMC_LATENCY, 0), - CLK_8_1("pc_soc_therm", mux_m_c_p_a_c2_c3, CLK_SOURCE_SOC_THERM, 0), - CLK_8_1("pc_vi_sensor2", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR2, 0), - CLK16_0("pc_i2c6", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C6, 0), - CLK_8_1("pc_emc_dll", mux_m_c_p_clkm_mud_c2_c3, CLK_SOURCE_EMC_DLL, DCF_IS_EMC_DLL), - CLK_8_1("pc_hdmi_audio", mux_p_c_c2_clkm, CLK_SOURCE_HDMI_AUDIO, 0), - CLK_8_1("pc_clk72mhz", mux_p_c_c2_clkm, CLK_SOURCE_CLK72MHZ, 0), - CLK_8_1("pc_adx1", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_ADX1, DCF_HAVE_ENA), - CLK_8_1("pc_amx1", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_AMX1, DCF_HAVE_ENA), - CLK_8_1("pc_vic", mux_m_c_p_a_c2_c3_clkm, CLK_SOURCE_VIC, DCF_IS_VIC), + CLK_8_1(0, "pc_sor0", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_SOR0, DCF_IS_SOR0), + CLK_8_1(0, "pc_sata_oob", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA_OOB, 0), + CLK_8_1(0, "pc_sata", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA, FDS_IS_SATA), + CLK_8_1(0, "pc_hda", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA, 0), + CLK_8_1(TEGRA124_CLK_XUSB_HOST_SRC, + "pc_xusb_core_host", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_HOST, 0), + CLK_8_1(TEGRA124_CLK_XUSB_FALCON_SRC, + "pc_xusb_falcon", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_FALCON, 0), + CLK_8_1(TEGRA124_CLK_XUSB_FS_SRC, + "pc_xusb_fs", mux_clkm_N_u48_N_p_N_u480, CLK_SOURCE_XUSB_FS, 0), + CLK_8_1(TEGRA124_CLK_XUSB_DEV_SRC, + "pc_xusb_core_dev", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_DEV, 0), + CLK_8_1(TEGRA124_CLK_XUSB_SS_SRC, + "pc_xusb_ss", mux_clkm_refe_clks_u480_c_c2_c3_oscdiv, CLK_SOURCE_XUSB_SS, DCF_IS_XUSB_SS), + CLK_8_1(0, "pc_cilab", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILAB, 0), + CLK_8_1(0, "pc_cilcd", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILCD, 0), + CLK_8_1(0, "pc_cile", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILE, 0), + CLK_8_1(0, "pc_dsia_lp", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_DSIA_LP, 0), + CLK_8_1(0, "pc_dsib_lp", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_DSIB_LP, 0), + CLK_8_1(0, "pc_entropy", mux_p_clkm_clks_E, CLK_SOURCE_ENTROPY, 0), + CLK_8_1(0, "pc_dvfs_ref", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_DVFS_REF, DCF_HAVE_ENA), + CLK_8_1(0, "pc_dvfs_soc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_DVFS_SOC, DCF_HAVE_ENA), + CLK_8_1(0, "pc_traceclkin", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_TRACECLKIN, 0), + CLK_8_1(0, "pc_adx", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_ADX, DCF_HAVE_ENA), + CLK_8_1(0, "pc_amx", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_AMX, DCF_HAVE_ENA), + CLK_8_1(0, "pc_emc_latency", mux_m_c_p_clkm_mud_c2_c3, CLK_SOURCE_EMC_LATENCY, 0), + CLK_8_1(0, "pc_soc_therm", mux_m_c_p_a_c2_c3, CLK_SOURCE_SOC_THERM, 0), + CLK_8_1(0, "pc_vi_sensor2", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR2, 0), + CLK16_0(0, "pc_i2c6", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C6, 0), + CLK_8_1(0, "pc_emc_dll", mux_m_c_p_clkm_mud_c2_c3, CLK_SOURCE_EMC_DLL, DCF_IS_EMC_DLL), + CLK_8_1(0, "pc_hdmi_audio", mux_p_c_c2_clkm, CLK_SOURCE_HDMI_AUDIO, 0), + CLK_8_1(0, "pc_clk72mhz", mux_p_c_c2_clkm, CLK_SOURCE_CLK72MHZ, 0), + CLK_8_1(0, "pc_adx1", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_ADX1, DCF_HAVE_ENA), + CLK_8_1(0, "pc_amx1", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_AMX1, DCF_HAVE_ENA), + CLK_8_1(0, "pc_vic", mux_m_c_p_a_c2_c3_clkm, CLK_SOURCE_VIC, DCF_IS_VIC), }; static int periph_init(struct clknode *clk, device_t dev); @@ -528,6 +541,7 @@ static clknode_method_t periph_methods[] }; DEFINE_CLASS_1(tegra124_periph, tegra124_periph_class, periph_methods, sizeof(struct periph_sc), clknode_class); + static int periph_init(struct clknode *clk, device_t dev) { @@ -637,14 +651,13 @@ periph_set_freq(struct clknode *clk, uin divider++; if (divider < (1 << sc->div_f_width)) - divider = 1 << sc->div_f_width; + divider = 1 << (sc->div_f_width - 1); - if ((*stop != 0) && - ((flags & (CLK_SET_ROUND_UP | CLK_SET_ROUND_DOWN)) == 0) && - (*fout != (tmp / divider))) - return (ERANGE); - - if ((flags & CLK_SET_DRYRUN) == 0) { + if (flags & CLK_SET_DRYRUN) { + if (((flags & (CLK_SET_ROUND_UP | CLK_SET_ROUND_DOWN)) == 0) && + (*fout != (tmp / divider))) + return (ERANGE); + } else { DEVICE_LOCK(sc); MD4(sc, sc->base_reg, sc->div_mask, (divider - (1 << sc->div_f_width))); @@ -703,9 +716,9 @@ DEFINE_CLASS_1(tegra124_pgate, tegra124_ static uint32_t get_enable_reg(int idx) { - KASSERT(idx / 32 < nitems(clk_enabale_reg), + KASSERT(idx / 32 < nitems(clk_enable_reg), ("Invalid clock index for enable: %d", idx)); - return (clk_enabale_reg[idx / 32]); + return (clk_enable_reg[idx / 32]); } static uint32_t Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Sun Apr 16 08:07:38 2017 (r317011) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Sun Apr 16 08:18:37 2017 (r317012) @@ -205,6 +205,16 @@ static struct pdiv_table pllu_map[] = { {0, 0} }; +static struct pdiv_table pllrefe_map[] = { + {1, 0}, + {2, 1}, + {3, 2}, + {4, 3}, + {5, 4}, + {6, 5}, + {0, 0}, +}; + static struct clk_pll_def pll_clks[] = { /* PLLM: 880 MHz Clock source for EMC 2x clock */ { @@ -342,6 +352,7 @@ static struct clk_pll_def pll_clks[] = { .lock_enable = PLLRE_MISC_LOCK_ENABLE, .iddq_reg = PLLRE_MISC, .iddq_mask = 1 << PLLRE_IDDQ_BIT, + .pdiv_table = pllrefe_map, .mnp_bits = {8, 8, 4, 16}, }, /* PLLE: generate the 100 MHz reference clock for USB 3.0 (spread spectrum) */ @@ -433,14 +444,14 @@ pdiv_to_reg(struct pll_sc *sc, uint32_t tbl = sc->pdiv_table; if (tbl == NULL) - return (ffs(p_div)); + return (ffs(p_div) - 1); while (tbl->divider != 0) { if (p_div <= tbl->divider) return (tbl->value); tbl++; } - return ~0; + return (0xFFFFFFFF); } static uint32_t @@ -449,15 +460,15 @@ reg_to_pdiv(struct pll_sc *sc, uint32_t struct pdiv_table *tbl; tbl = sc->pdiv_table; - if (tbl != NULL) { - while (tbl->divider) { - if (reg == tbl->value) - return (tbl->divider); - tbl++; - } - return (0); + if (tbl == NULL) + return (1 << reg); + + while (tbl->divider) { + if (reg == tbl->value) + return (tbl->divider); + tbl++; } - return (1 << reg); + return (0); } static uint32_t @@ -790,6 +801,7 @@ pllrefe_set_freq(struct pll_sc *sc, uint m = 1; p = 1; n = *fout * p * m / fin; + dprintf("%s: m: %d, n: %d, p: %d\n", __func__, m, n, p); return (pll_set_std(sc, fin, fout, flags, m, n, p)); } @@ -902,6 +914,7 @@ tegra124_pll_set_freq(struct clknode *cl rv = ENXIO; break; } + return (rv); } @@ -921,6 +934,11 @@ tegra124_pll_init(struct clknode *clk, d reg |= sc->lock_enable; WR4(sc, sc->misc_reg, reg); } + if (sc->type == PLL_REFE) { + RD4(sc, sc->misc_reg, ®); + reg &= ~(1 << 29); /* Diasble lock override */ + WR4(sc, sc->misc_reg, reg); + } clknode_init_parent_idx(clk, 0); return(0); Copied: stable/11/sys/arm/nvidia/tegra_mc.c (from r308286, head/sys/arm/nvidia/tegra_mc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/arm/nvidia/tegra_mc.c Sun Apr 16 08:18:37 2017 (r317012, copy of r308286, head/sys/arm/nvidia/tegra_mc.c) @@ -0,0 +1,311 @@ +/*- + * Copyright (c) 2016 Michal Meloun + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * Memory controller driver for Tegra SoCs. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "clock_if.h" + +#define MC_INTSTATUS 0x000 +#define MC_INTMASK 0x004 +#define MC_INT_DECERR_MTS (1 << 16) +#define MC_INT_SECERR_SEC (1 << 13) +#define MC_INT_DECERR_VPR (1 << 12) +#define MC_INT_INVALID_APB_ASID_UPDATE (1 << 11) +#define MC_INT_INVALID_SMMU_PAGE (1 << 10) +#define MC_INT_ARBITRATION_EMEM (1 << 9) +#define MC_INT_SECURITY_VIOLATION (1 << 8) +#define MC_INT_DECERR_EMEM (1 << 6) +#define MC_INT_INT_MASK (MC_INT_DECERR_MTS | \ + MC_INT_SECERR_SEC | \ + MC_INT_DECERR_VPR | \ + MC_INT_INVALID_APB_ASID_UPDATE | \ + MC_INT_INVALID_SMMU_PAGE | \ + MC_INT_ARBITRATION_EMEM | \ + MC_INT_SECURITY_VIOLATION | \ + MC_INT_DECERR_EMEM) + +#define MC_ERR_STATUS 0x008 +#define MC_ERR_TYPE(x) (((x) >> 28) & 0x7) +#define MC_ERR_TYPE_DECERR_EMEM 2 +#define MC_ERR_TYPE_SECURITY_TRUSTZONE 3 +#define MC_ERR_TYPE_SECURITY_CARVEOUT 4 +#define MC_ERR_TYPE_INVALID_SMMU_PAGE 6 +#define MC_ERR_INVALID_SMMU_PAGE_READABLE (1 << 27) +#define MC_ERR_INVALID_SMMU_PAGE_WRITABLE (1 << 26) +#define MC_ERR_INVALID_SMMU_PAGE_NONSECURE (1 << 25) +#define MC_ERR_ADR_HI(x) (((x) >> 20) & 0x3) +#define MC_ERR_SWAP (1 << 18) +#define MC_ERR_SECURITY (1 << 17) +#define MC_ERR_RW (1 << 16) +#define MC_ERR_ADR1(x) (((x) >> 12) & 0x7) +#define MC_ERR_ID(x) (((x) >> 0) & 07F) + +#define MC_ERR_ADDR 0x00C +#define MC_EMEM_CFG 0x050 +#define MC_EMEM_ADR_CFG 0x054 +#define MC_EMEM_NUMDEV(x) (((x) >> 0 ) & 0x1) + +#define MC_EMEM_ADR_CFG_DEV0 0x058 +#define MC_EMEM_ADR_CFG_DEV1 0x05C +#define EMEM_DEV_DEVSIZE(x) (((x) >> 16) & 0xF) +#define EMEM_DEV_BANKWIDTH(x) (((x) >> 8) & 0x3) +#define EMEM_DEV_COLWIDTH(x) (((x) >> 8) & 0x3) + +#define WR4(_sc, _r, _v) bus_write_4((_sc)->mem_res, (_r), (_v)) +#define RD4(_sc, _r) bus_read_4((_sc)->mem_res, (_r)) + +#define LOCK(_sc) mtx_lock(&(_sc)->mtx) +#define UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) +#define SLEEP(_sc, timeout) mtx_sleep(sc, &sc->mtx, 0, "tegra_mc", timeout); +#define LOCK_INIT(_sc) \ + mtx_init(&_sc->mtx, device_get_nameunit(_sc->dev), "tegra_mc", MTX_DEF) +#define LOCK_DESTROY(_sc) mtx_destroy(&_sc->mtx) +#define ASSERT_LOCKED(_sc) mtx_assert(&_sc->mtx, MA_OWNED) +#define ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->mtx, MA_NOTOWNED) + +static struct ofw_compat_data compat_data[] = { + {"nvidia,tegra124-mc", 1}, + {NULL, 0} +}; + +struct tegra_mc_softc { + device_t dev; + struct mtx mtx; + + struct resource *mem_res; + struct resource *irq_res; + void *irq_h; + + clk_t clk; +}; + +static char *smmu_err_tbl[16] = { + "reserved", /* 0 */ + "reserved", /* 1 */ + "DRAM decode", /* 2 */ + "Trustzome Security", /* 3 */ + "Security carveout", /* 4 */ + "reserved", /* 5 */ + "Invalid SMMU page", /* 6 */ + "reserved", /* 7 */ +}; + +static void +tegra_mc_intr(void *arg) +{ + struct tegra_mc_softc *sc; + uint32_t stat, err; + uint64_t addr; + + sc = (struct tegra_mc_softc *)arg; + + stat = RD4(sc, MC_INTSTATUS); + if ((stat & MC_INT_INT_MASK) == 0) { + WR4(sc, MC_INTSTATUS, stat); + return; + } + + device_printf(sc->dev, "Memory Controller Interrupt:\n"); + if (stat & MC_INT_DECERR_MTS) + printf(" - MTS carveout violation\n"); + if (stat & MC_INT_SECERR_SEC) + printf(" - SEC carveout violation\n"); + if (stat & MC_INT_DECERR_VPR) + printf(" - VPR requirements violated\n"); + if (stat & MC_INT_INVALID_APB_ASID_UPDATE) + printf(" - ivalid APB ASID update\n"); + if (stat & MC_INT_INVALID_SMMU_PAGE) + printf(" - SMMU address translation error\n"); + if (stat & MC_INT_ARBITRATION_EMEM) + printf(" - arbitration deadlock-prevention threshold hit\n"); + if (stat & MC_INT_SECURITY_VIOLATION) + printf(" - SMMU address translation security error\n"); + if (stat & MC_INT_DECERR_EMEM) + printf(" - SMMU address decode error\n"); + + if ((stat & (MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION | + MC_INT_DECERR_EMEM)) != 0) { + err = RD4(sc, MC_ERR_STATUS); + addr = RD4(sc, MC_ERR_STATUS); + addr |= (uint64_t)(MC_ERR_ADR_HI(err)) << 32; + printf(" at 0x%012llX [%s %s %s] - %s error.\n", + addr, + stat & MC_ERR_SWAP ? "Swap, " : "", + stat & MC_ERR_SECURITY ? "Sec, " : "", + stat & MC_ERR_RW ? "Write" : "Read", + smmu_err_tbl[MC_ERR_TYPE(err)]); + } + WR4(sc, MC_INTSTATUS, stat); +} + +static void +tegra_mc_init_hw(struct tegra_mc_softc *sc) +{ + + /* Disable and acknowledge all interrupts */ + WR4(sc, MC_INTMASK, 0); + WR4(sc, MC_INTSTATUS, MC_INT_INT_MASK); +} + +static int +tegra_mc_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + device_set_desc(dev, "Tegra Memory Controller"); + return (BUS_PROBE_DEFAULT); +} + +static int +tegra_mc_attach(device_t dev) +{ + int rv, rid; + struct tegra_mc_softc *sc; + + sc = device_get_softc(dev); + sc->dev = dev; + + LOCK_INIT(sc); + + /* Get the memory resource for the register mapping. */ + rid = 0; + sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->mem_res == NULL) { + device_printf(dev, "Cannot map registers.\n"); + rv = ENXIO; + goto fail; + } + + /* Allocate our IRQ resource. */ + rid = 0; + sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE); + if (sc->irq_res == NULL) { + device_printf(dev, "Cannot allocate interrupt.\n"); + rv = ENXIO; + goto fail; + } + + /* OFW resources. */ + rv = clk_get_by_ofw_name(dev, 0, "mc", &sc->clk); + if (rv != 0) { + device_printf(dev, "Cannot get mc clock: %d\n", rv); + goto fail; + } + rv = clk_enable(sc->clk); + if (rv != 0) { + device_printf(dev, "Cannot enable clock: %d\n", rv); + goto fail; + } + + /* Init hardware. */ + tegra_mc_init_hw(sc); + + /* Setup interrupt */ + rv = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, + NULL, tegra_mc_intr, sc, &sc->irq_h); + if (rv) { + device_printf(dev, "Cannot setup interrupt.\n"); + goto fail; + } + + /* Enable Interrupts */ + WR4(sc, MC_INTMASK, MC_INT_INT_MASK); + + return (bus_generic_attach(dev)); + +fail: + if (sc->clk != NULL) + clk_release(sc->clk); + if (sc->irq_h != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->irq_h); + if (sc->irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); + if (sc->mem_res != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); + LOCK_DESTROY(sc); + + return (rv); +} + +static int +tegra_mc_detach(device_t dev) +{ + struct tegra_mc_softc *sc; + + sc = device_get_softc(dev); + if (sc->irq_h != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->irq_h); + if (sc->irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); + if (sc->mem_res != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); + + LOCK_DESTROY(sc); + return (bus_generic_detach(dev)); +} + +static device_method_t tegra_mc_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, tegra_mc_probe), + DEVMETHOD(device_attach, tegra_mc_attach), + DEVMETHOD(device_detach, tegra_mc_detach), + + + DEVMETHOD_END +}; + +static devclass_t tegra_mc_devclass; +static DEFINE_CLASS_0(mc, tegra_mc_driver, tegra_mc_methods, + sizeof(struct tegra_mc_softc)); +DRIVER_MODULE(tegra_mc, simplebus, tegra_mc_driver, tegra_mc_devclass, + NULL, NULL); From owner-svn-src-all@freebsd.org Sun Apr 16 08:21:16 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C331D3E19E; Sun, 16 Apr 2017 08:21:16 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 DAE7B1670; Sun, 16 Apr 2017 08:21:15 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G8LF8e003578; Sun, 16 Apr 2017 08:21:15 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G8LEHM003575; Sun, 16 Apr 2017 08:21:14 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160821.v3G8LEHM003575@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 08:21:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317013 - stable/11/sys/arm/nvidia/tegra124 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 08:21:16 -0000 Author: mmel Date: Sun Apr 16 08:21:14 2017 New Revision: 317013 URL: https://svnweb.freebsd.org/changeset/base/317013 Log: MFC r309538: Fixes for NVIDIA Tegra124 clocks: - EMC clock have standard peripheral clock block. Use it. - Implement full frequency set method for PLLD2. This PLL is used as HDMI pixel clock so we must be able to set it to wide range of frequencies, within 5% tolerance allowed by HDMI specification. Due to this, full state space search (over m, n, p fields) is necessary. Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_car.c stable/11/sys/arm/nvidia/tegra124/tegra124_clk_per.c stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_car.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_car.c Sun Apr 16 08:18:37 2017 (r317012) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_car.c Sun Apr 16 08:21:14 2017 (r317013) @@ -189,8 +189,6 @@ PLIST(mux_pll_srcs) = {"osc_div_clk", NU PLIST(mux_plle_src1) = {"osc_div_clk", "pllP_out0"}; PLIST(mux_plle_src) = {"pllE_src1", "pllREFE_out"}; PLIST(mux_plld_out0_plld2_out0) = {"pllD_out0", "pllD2_out0"}; -PLIST(mux_pllmcp_clkm) = {"pllM_out0", "pllC_out0", "pllP_out0", "clk_m", - "pllM_UD", "pllC2_out0", "pllC3_out0", "pllC_UD"}; PLIST(mux_xusb_hs) = {"xusb_ss_div2", "pllU_60"}; PLIST(mux_xusb_ss) = {"pc_xusb_ss", "osc_div_clk"}; @@ -240,7 +238,6 @@ static struct clk_mux_def tegra124_mux_c /* Base peripheral clocks. */ MUX(0, "dsia_mux", mux_plld_out0_plld2_out0, PLLD_BASE, 25, 1), MUX(0, "dsib_mux", mux_plld_out0_plld2_out0, PLLD2_BASE, 25, 1), - MUX(0, "emc_mux", mux_pllmcp_clkm, CLK_SOURCE_EMC, 29, 3), /* USB. */ MUX(TEGRA124_CLK_XUSB_HS_SRC, "xusb_hs", mux_xusb_hs, CLK_SOURCE_XUSB_SS, 25, 1), Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_clk_per.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_clk_per.c Sun Apr 16 08:18:37 2017 (r317012) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_clk_per.c Sun Apr 16 08:21:14 2017 (r317013) @@ -126,6 +126,10 @@ PLIST(mux_m_c_p_a_c2_c3_clkm_c4) = PLIST(mux_m_c_p_clkm_mud_c2_c3) = {"pllM_out0", "pllC_out0", "pllP_out0", "clk_m", "pllM_UD", "pllC2_out0", "pllC3_out0"}; +PLIST(mux_m_c_p_clkm_mud_c2_c3_cud) = + {"pllM_out0", "pllC_out0", "pllP_out0", "clk_m", + "pllM_UD", "pllC2_out0", "pllC3_out0", "pllC_UD"}; + PLIST(mux_m_c2_c_c3_p_N_a) = {"pllM_out0", "pllC2_out0", "pllC_out0", "pllC3_out0", "pllP_out0", NULL, "pllA_out0"}; @@ -260,7 +264,7 @@ static struct pgate_def pgate_def[] = { GATE(I2C2, "i2c2", "pc_i2c2", H(22)), GATE(UARTC, "uartc", "pc_uartc", H(23)), GATE(MIPI_CAL, "mipi_cal", "clk_m", H(24)), - GATE(EMC, "emc", "emc_mux", H(25)), + GATE(EMC, "emc", "pc_emc_2x", H(25)), GATE(USB2, "usb2", "clk_m", H(26)), GATE(USB3, "usb3", "clk_m", H(27)), GATE(VDE, "vde", "pc_vde", H(29)), @@ -356,7 +360,7 @@ static struct pgate_def pgate_def[] = { /* GATE(CAM_MCLK, "CAM_MCLK", "clk_m", X(4)), */ /* GATE(CAM_MCLK2, "CAM_MCLK2", "clk_m", X(5)), */ GATE(I2C6, "i2c6", "pc_i2c6", X(6)), - /* GATE(VIM2_CLK, "vim2_clk", clk_m, X(11)), */ + GATE(VIM2_CLK, "vim2_clk", "clk_m", X(11)), /* GATE(EMC_DLL, "emc_dll", "pc_emc_dll", X(14)), */ GATE(HDMI_AUDIO, "hdmi_audio", "pc_hdmi_audio", X(16)), GATE(CLK72MHZ, "clk72mhz", "pc_clk72mhz", X(17)), @@ -373,17 +377,18 @@ static struct pgate_def pgate_def[] = { #define DCF_HAVE_ENA 0x0200 /* Block with enable bit */ #define DCF_HAVE_DIV 0x0400 /* Block with divider */ -/* Mark block with additional bis / functionality. */ +/* Mark block with additional bits / functionality. */ #define DCF_IS_MASK 0x00FF #define DCF_IS_UART 0x0001 #define DCF_IS_VI 0x0002 #define DCF_IS_HOST1X 0x0003 #define DCF_IS_XUSB_SS 0x0004 #define DCF_IS_EMC_DLL 0x0005 -#define FDS_IS_SATA 0x0006 +#define DCF_IS_SATA 0x0006 #define DCF_IS_VIC 0x0007 #define DCF_IS_AUDIO 0x0008 #define DCF_IS_SOR0 0x0009 +#define DCF_IS_EMC 0x000A /* Basic pheripheral clock */ #define PER_CLK(_id, cn, pl, r, diw, fiw, f) \ @@ -438,7 +443,7 @@ static struct periph_def periph_def[] = CLK_8_1(0, "pc_host1x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HOST1X, DCF_IS_HOST1X), CLK_8_1(0, "pc_hdmi", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_HDMI, 0), CLK16_0(0, "pc_i2c2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C2, 0), -/* EMC 8 */ + CLK_8_1(0, "pc_emc_2x", mux_m_c_p_clkm_mud_c2_c3_cud, CLK_SOURCE_EMC, DCF_IS_EMC), CLK16_1(0, "pc_uartc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTC, DCF_IS_UART), CLK_8_1(0, "pc_vi_sensor", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR, 0), CLK_8_1(0, "pc_spi4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI4, 0), @@ -476,7 +481,7 @@ static struct periph_def periph_def[] = /* SYS */ CLK_8_1(0, "pc_sor0", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_SOR0, DCF_IS_SOR0), CLK_8_1(0, "pc_sata_oob", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA_OOB, 0), - CLK_8_1(0, "pc_sata", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA, FDS_IS_SATA), + CLK_8_1(0, "pc_sata", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA, DCF_IS_SATA), CLK_8_1(0, "pc_hda", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA, 0), CLK_8_1(TEGRA124_CLK_XUSB_HOST_SRC, "pc_xusb_core_host", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_HOST, 0), Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Sun Apr 16 08:18:37 2017 (r317012) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Sun Apr 16 08:21:14 2017 (r317013) @@ -713,6 +713,7 @@ pll_set_std(struct pll_sc *sc, uint64_t return (ERANGE); *fout = ((fin / m) * n) /p; + return (0); } @@ -771,7 +772,6 @@ pllc_set_freq(struct pll_sc *sc, uint64_ { uint32_t m, n, p; - p = 2; m = 1; n = (*fout * p * m + fin / 2)/ fin; @@ -779,19 +779,88 @@ pllc_set_freq(struct pll_sc *sc, uint64_ return (pll_set_std( sc, fin, fout, flags, m, n, p)); } +/* + * PLLD2 is used as source for pixel clock for HDMI. + * We must be able to set it frequency very flexibly and + * precisely (within 5% tolerance limit allowed by HDMI specs). + * + * For this reason, it is necessary to search the full state space. + * Fortunately, thanks to early cycle terminations, performance + * is within acceptable limits. + */ +#define PLLD2_PFD_MIN 12000000 /* 12 MHz */ +#define PLLD2_PFD_MAX 38000000 /* 38 MHz */ +#define PLLD2_VCO_MIN 600000000 /* 600 MHz */ +#define PLLD2_VCO_MAX 1200000000 /* 1.2 GHz */ + static int plld2_set_freq(struct pll_sc *sc, uint64_t fin, uint64_t *fout, int flags) { uint32_t m, n, p; + uint32_t best_m, best_n, best_p; + uint64_t vco, pfd; + int64_t err, best_err; + struct mnp_bits *mnp_bits; + struct pdiv_table *tbl; + int p_idx, rv; - p = 2; - m = 1; - n = (*fout * p * m + fin / 2)/ fin; - dprintf("%s: m: %d, n: %d, p: %d\n", __func__, m, n, p); - return (pll_set_std(sc, fin, fout, flags, m, n, p)); -} + mnp_bits = &sc->mnp_bits; + tbl = sc->pdiv_table; + best_err = INT64_MAX; + for (p_idx = 0; tbl[p_idx].divider != 0; p_idx++) { + p = tbl[p_idx].divider; + /* Check constraints */ + vco = *fout * p; + if (vco < PLLD2_VCO_MIN) + continue; + if (vco > PLLD2_VCO_MAX) + break; + + for (m = 1; m < (1 << mnp_bits->m_width); m++) { + n = (*fout * p * m + fin / 2) / fin; + + /* Check constraints */ + if (n == 0) + continue; + if (n >= (1 << mnp_bits->n_width)) + break; + vco = (fin * n) / m; + if (vco > PLLD2_VCO_MAX || vco < PLLD2_VCO_MIN) + continue; + pfd = fin / m; + if (pfd > PLLD2_PFD_MAX || vco < PLLD2_PFD_MIN) + continue; + + /* Constraints passed, save best result */ + err = *fout - vco / p; + if (err < 0) + err = -err; + if (err < best_err) { + best_err = err; + best_p = p; + best_m = m; + best_n = n; + } + if (err == 0) + goto done; + } + } +done: + /* + * HDMI specification allows 5% pixel clock tolerance, + * we will by a slightly stricter + */ + if (best_err > ((*fout * 100) / 4)) + return (ERANGE); + + if (flags & CLK_SET_DRYRUN) + return (0); + rv = pll_set_std(sc, fin, fout, flags, best_m, best_n, best_p); + /* XXXX Panic for rv == ERANGE ? */ + return (rv); +} static int pllrefe_set_freq(struct pll_sc *sc, uint64_t fin, uint64_t *fout, int flags) @@ -883,8 +952,8 @@ tegra124_pll_set_freq(struct clknode *cl struct pll_sc *sc; sc = clknode_get_softc(clknode); - dprintf("%s: Requested freq: %llu, input freq: %llu\n", __func__, - *fout, fin); + dprintf("%s: %s requested freq: %llu, input freq: %llu\n", __func__, + clknode_get_name(clknode), *fout, fin); switch (sc->type) { case PLL_A: rv = plla_set_freq(sc, fin, fout, flags); From owner-svn-src-all@freebsd.org Sun Apr 16 08:43:03 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06467D3EB5B; Sun, 16 Apr 2017 08:43:03 +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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C981D6C2; Sun, 16 Apr 2017 08:43:02 +0000 (UTC) (envelope-from mark@grondar.org) Received: from graveyard.grondar.org ([88.96.155.33] helo=gronkulator.grondar.org) by gromit.grondar.org with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1czflr-000PqI-HA; Sun, 16 Apr 2017 09:42:59 +0100 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r316982 - in head/sys: conf crypto/chacha20 modules modules/chacha20 From: Mark R V Murray In-Reply-To: <201704152051.v3FKpr38020502@repo.freebsd.org> Date: Sun, 16 Apr 2017 09:42:57 +0100 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <144B63D2-039E-46A2-B2A1-EFB7BD9589A4@grondar.org> References: <201704152051.v3FKpr38020502@repo.freebsd.org> To: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= X-Mailer: Apple Mail (2.3273) X-SA-Score: -1.0 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 08:43:03 -0000 > On 15 Apr 2017, at 21:51, Dag-Erling Sm=C3=B8rgrav = wrote: >=20 > Author: des > Date: Sat Apr 15 20:51:53 2017 > New Revision: 316982 > URL: https://svnweb.freebsd.org/changeset/base/316982 >=20 > Log: > 3BSD-licensed implementation of the chacha20 stream cipher, intended = for > use by the upcoming arc4random replacement. >=20 > Added: > head/sys/crypto/chacha20/ > head/sys/crypto/chacha20/chacha20.c (contents, props changed) > head/sys/crypto/chacha20/chacha20.h (contents, props changed) > head/sys/modules/chacha20/ > head/sys/modules/chacha20/Makefile (contents, props changed) > Modified: > head/sys/conf/files > head/sys/modules/Makefile This is a loadable module, unlike the RC4 code which it needs to = replace, and which is standard. Making it loadable makes no sense in the context of arc4random(9). Do you mind if I strip out the module bits in order to get my = arc4random(9) commit completed? M --=20 Mark R V Murray From owner-svn-src-all@freebsd.org Sun Apr 16 09:00:12 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2409DD4025B; Sun, 16 Apr 2017 09:00:12 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 E9B4ACDF; Sun, 16 Apr 2017 09:00:11 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G90BQQ018750; Sun, 16 Apr 2017 09:00:11 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G90B2H018749; Sun, 16 Apr 2017 09:00:11 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201704160900.v3G90B2H018749@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 16 Apr 2017 09:00:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317014 - stable/11/sys/conf X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 09:00:12 -0000 Author: mmel Date: Sun Apr 16 09:00:10 2017 New Revision: 317014 URL: https://svnweb.freebsd.org/changeset/base/317014 Log: MFC r307686: Use MACHINE_ARCH rather than TARGET_ARCH which has no meaning outside of Makefile.inc1 Modified: stable/11/sys/conf/Makefile.arm Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/Makefile.arm ============================================================================== --- stable/11/sys/conf/Makefile.arm Sun Apr 16 08:21:14 2017 (r317013) +++ stable/11/sys/conf/Makefile.arm Sun Apr 16 09:00:10 2017 (r317014) @@ -74,7 +74,7 @@ FILES_CPU_FUNC = \ $S/$M/$M/cpufunc_asm_pj4b.S $S/$M/$M/cpufunc_asm_armv6.S \ $S/$M/$M/cpufunc_asm_armv7.S -.if ${TARGET_ARCH} != "armv6" && defined(KERNPHYSADDR) +.if ${MACHINE_ARCH} != "armv6" && defined(KERNPHYSADDR) KERNEL_EXTRA=trampoline KERNEL_EXTRA_INSTALL=kernel.gz.tramp trampoline: ${KERNEL_KO}.tramp From owner-svn-src-all@freebsd.org Sun Apr 16 09:11:04 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9FA7D40794; Sun, 16 Apr 2017 09:11:04 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 AAD4A1596; Sun, 16 Apr 2017 09:11:04 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3G9B38L023105; Sun, 16 Apr 2017 09:11:03 GMT (envelope-from markm@FreeBSD.org) Received: (from markm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3G9B3df023095; Sun, 16 Apr 2017 09:11:03 GMT (envelope-from markm@FreeBSD.org) Message-Id: <201704160911.v3G9B3df023095@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markm set sender to markm@FreeBSD.org using -f From: Mark Murray Date: Sun, 16 Apr 2017 09:11:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 09:11:05 -0000 Author: markm Date: Sun Apr 16 09:11:02 2017 New Revision: 317015 URL: https://svnweb.freebsd.org/changeset/base/317015 Log: Replace the RC4 algorithm for generating in-kernel secure random numbers with Chacha20. Keep the API, though, as that is what the other *BSD's have done. Use the boot-time entropy stash (if present) to bootstrap the in-kernel entropy source. Reviewed by: delphij,rwatson Approved by: so(delphij) MFC after: 2 months Relnotes: yes Differential Revision: https://reviews.freebsd.org/D10048 --This line, and those below, will be ignored-- > Description of fields to fill in above: 76 columns --| > PR: If and which Problem Report is related. > Submitted by: If someone else sent in the change. > Reported by: If someone else reported the issue. > Reviewed by: If someone else reviewed your modification. > Approved by: If you needed approval for this commit. > Obtained from: If the change is from a third party. > MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email. > MFH: Ports tree branch name. Request approval for merge. > Relnotes: Set to 'yes' for mention in release notes. > Security: Vulnerability reference (one per line) or description. > Sponsored by: If the change was sponsored by an organization. > Differential Revision: https://reviews.freebsd.org/D### (*full* phabric URL needed). > Empty fields above will be automatically removed. Added: head/sys/crypto/chacha20/chacha.c (contents, props changed) head/sys/crypto/chacha20/chacha.h (contents, props changed) Modified: head/sys/boot/forth/loader.conf head/sys/conf/files head/sys/dev/random/random_harvestq.c head/sys/dev/random/random_harvestq.h head/sys/libkern/arc4random.c head/sys/sys/libkern.h head/sys/sys/random.h Modified: head/sys/boot/forth/loader.conf ============================================================================== --- head/sys/boot/forth/loader.conf Sun Apr 16 09:00:10 2017 (r317014) +++ head/sys/boot/forth/loader.conf Sun Apr 16 09:11:02 2017 (r317015) @@ -48,7 +48,7 @@ bitmap_type="splash_image_data" # and pl entropy_cache_load="YES" # Set this to NO to disable loading # entropy at boot time entropy_cache_name="/boot/entropy" # Set this to the name of the file -entropy_cache_type="/boot/entropy" # Required for the kernel to find +entropy_cache_type="boot_entropy_cache" # Required for the kernel to find # the boot-time entropy cache. This # must not change value even if the # _name above does change! Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sun Apr 16 09:00:10 2017 (r317014) +++ head/sys/conf/files Sun Apr 16 09:11:02 2017 (r317015) @@ -3810,6 +3810,7 @@ kgssapi/gsstest.c optional kgssapi_debu # the file should be moved to conf/files. from here. # libkern/arc4random.c standard +crypto/chacha20/chacha.c standard libkern/asprintf.c standard libkern/bcd.c standard libkern/bsearch.c standard Added: head/sys/crypto/chacha20/chacha.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/crypto/chacha20/chacha.c Sun Apr 16 09:11:02 2017 (r317015) @@ -0,0 +1,224 @@ +/* +chacha-merged.c version 20080118 +D. J. Bernstein +Public domain. +*/ + +/* $OpenBSD: chacha.c,v 1.1 2013/11/21 00:45:44 djm Exp $ */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include + + +typedef uint8_t u8; +typedef uint32_t u32; + +typedef struct chacha_ctx chacha_ctx; + +#define U8C(v) (v##U) +#define U32C(v) (v##U) + +#define U8V(v) ((u8)(v) & U8C(0xFF)) +#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF)) + +#define ROTL32(v, n) \ + (U32V((v) << (n)) | ((v) >> (32 - (n)))) + +#define U8TO32_LITTLE(p) \ + (((u32)((p)[0]) ) | \ + ((u32)((p)[1]) << 8) | \ + ((u32)((p)[2]) << 16) | \ + ((u32)((p)[3]) << 24)) + +#define U32TO8_LITTLE(p, v) \ + do { \ + (p)[0] = U8V((v) ); \ + (p)[1] = U8V((v) >> 8); \ + (p)[2] = U8V((v) >> 16); \ + (p)[3] = U8V((v) >> 24); \ + } while (0) + +#define ROTATE(v,c) (ROTL32(v,c)) +#define XOR(v,w) ((v) ^ (w)) +#define PLUS(v,w) (U32V((v) + (w))) +#define PLUSONE(v) (PLUS((v),1)) + +#define QUARTERROUND(a,b,c,d) \ + a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \ + c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \ + a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ + c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); + +static const char sigma[16] = "expand 32-byte k"; +static const char tau[16] = "expand 16-byte k"; + +void +chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits) +{ + const char *constants; + + x->input[4] = U8TO32_LITTLE(k + 0); + x->input[5] = U8TO32_LITTLE(k + 4); + x->input[6] = U8TO32_LITTLE(k + 8); + x->input[7] = U8TO32_LITTLE(k + 12); + if (kbits == 256) { /* recommended */ + k += 16; + constants = sigma; + } else { /* kbits == 128 */ + constants = tau; + } + x->input[8] = U8TO32_LITTLE(k + 0); + x->input[9] = U8TO32_LITTLE(k + 4); + x->input[10] = U8TO32_LITTLE(k + 8); + x->input[11] = U8TO32_LITTLE(k + 12); + x->input[0] = U8TO32_LITTLE(constants + 0); + x->input[1] = U8TO32_LITTLE(constants + 4); + x->input[2] = U8TO32_LITTLE(constants + 8); + x->input[3] = U8TO32_LITTLE(constants + 12); +} + +void +chacha_ivsetup(chacha_ctx *x, const u8 *iv, const u8 *counter) +{ + x->input[12] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 0); + x->input[13] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 4); + x->input[14] = U8TO32_LITTLE(iv + 0); + x->input[15] = U8TO32_LITTLE(iv + 4); +} + +void +chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes) +{ + u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; + u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15; + u8 *ctarget = NULL; + u8 tmp[64]; + u_int i; + + if (!bytes) return; + + j0 = x->input[0]; + j1 = x->input[1]; + j2 = x->input[2]; + j3 = x->input[3]; + j4 = x->input[4]; + j5 = x->input[5]; + j6 = x->input[6]; + j7 = x->input[7]; + j8 = x->input[8]; + j9 = x->input[9]; + j10 = x->input[10]; + j11 = x->input[11]; + j12 = x->input[12]; + j13 = x->input[13]; + j14 = x->input[14]; + j15 = x->input[15]; + + for (;;) { + if (bytes < 64) { + for (i = 0;i < bytes;++i) tmp[i] = m[i]; + m = tmp; + ctarget = c; + c = tmp; + } + x0 = j0; + x1 = j1; + x2 = j2; + x3 = j3; + x4 = j4; + x5 = j5; + x6 = j6; + x7 = j7; + x8 = j8; + x9 = j9; + x10 = j10; + x11 = j11; + x12 = j12; + x13 = j13; + x14 = j14; + x15 = j15; + for (i = 20;i > 0;i -= 2) { + QUARTERROUND( x0, x4, x8,x12) + QUARTERROUND( x1, x5, x9,x13) + QUARTERROUND( x2, x6,x10,x14) + QUARTERROUND( x3, x7,x11,x15) + QUARTERROUND( x0, x5,x10,x15) + QUARTERROUND( x1, x6,x11,x12) + QUARTERROUND( x2, x7, x8,x13) + QUARTERROUND( x3, x4, x9,x14) + } + x0 = PLUS(x0,j0); + x1 = PLUS(x1,j1); + x2 = PLUS(x2,j2); + x3 = PLUS(x3,j3); + x4 = PLUS(x4,j4); + x5 = PLUS(x5,j5); + x6 = PLUS(x6,j6); + x7 = PLUS(x7,j7); + x8 = PLUS(x8,j8); + x9 = PLUS(x9,j9); + x10 = PLUS(x10,j10); + x11 = PLUS(x11,j11); + x12 = PLUS(x12,j12); + x13 = PLUS(x13,j13); + x14 = PLUS(x14,j14); + x15 = PLUS(x15,j15); + + x0 = XOR(x0,U8TO32_LITTLE(m + 0)); + x1 = XOR(x1,U8TO32_LITTLE(m + 4)); + x2 = XOR(x2,U8TO32_LITTLE(m + 8)); + x3 = XOR(x3,U8TO32_LITTLE(m + 12)); + x4 = XOR(x4,U8TO32_LITTLE(m + 16)); + x5 = XOR(x5,U8TO32_LITTLE(m + 20)); + x6 = XOR(x6,U8TO32_LITTLE(m + 24)); + x7 = XOR(x7,U8TO32_LITTLE(m + 28)); + x8 = XOR(x8,U8TO32_LITTLE(m + 32)); + x9 = XOR(x9,U8TO32_LITTLE(m + 36)); + x10 = XOR(x10,U8TO32_LITTLE(m + 40)); + x11 = XOR(x11,U8TO32_LITTLE(m + 44)); + x12 = XOR(x12,U8TO32_LITTLE(m + 48)); + x13 = XOR(x13,U8TO32_LITTLE(m + 52)); + x14 = XOR(x14,U8TO32_LITTLE(m + 56)); + x15 = XOR(x15,U8TO32_LITTLE(m + 60)); + + j12 = PLUSONE(j12); + if (!j12) { + j13 = PLUSONE(j13); + /* stopping at 2^70 bytes per nonce is user's responsibility */ + } + + U32TO8_LITTLE(c + 0,x0); + U32TO8_LITTLE(c + 4,x1); + U32TO8_LITTLE(c + 8,x2); + U32TO8_LITTLE(c + 12,x3); + U32TO8_LITTLE(c + 16,x4); + U32TO8_LITTLE(c + 20,x5); + U32TO8_LITTLE(c + 24,x6); + U32TO8_LITTLE(c + 28,x7); + U32TO8_LITTLE(c + 32,x8); + U32TO8_LITTLE(c + 36,x9); + U32TO8_LITTLE(c + 40,x10); + U32TO8_LITTLE(c + 44,x11); + U32TO8_LITTLE(c + 48,x12); + U32TO8_LITTLE(c + 52,x13); + U32TO8_LITTLE(c + 56,x14); + U32TO8_LITTLE(c + 60,x15); + + if (bytes <= 64) { + if (bytes < 64) { + for (i = 0;i < bytes;++i) ctarget[i] = c[i]; + } + x->input[12] = j12; + x->input[13] = j13; + return; + } + bytes -= 64; + c += 64; + m += 64; + } +} Added: head/sys/crypto/chacha20/chacha.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/crypto/chacha20/chacha.h Sun Apr 16 09:11:02 2017 (r317015) @@ -0,0 +1,32 @@ +/* $OpenBSD: chacha.h,v 1.4 2016/08/27 04:04:56 guenther Exp $ */ + +/* +chacha-merged.c version 20080118 +D. J. Bernstein +Public domain. + + $FreeBSD$ +*/ + +#ifndef CHACHA_H +#define CHACHA_H + +#include + +struct chacha_ctx { + u_int input[16]; +}; + +#define CHACHA_MINKEYLEN 16 +#define CHACHA_NONCELEN 8 +#define CHACHA_CTRLEN 8 +#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) +#define CHACHA_BLOCKLEN 64 + +void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits); +void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const u_char *ctr); +void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m, + u_char *c, u_int bytes); + +#endif /* CHACHA_H */ + Modified: head/sys/dev/random/random_harvestq.c ============================================================================== --- head/sys/dev/random/random_harvestq.c Sun Apr 16 09:00:10 2017 (r317014) +++ head/sys/dev/random/random_harvestq.c Sun Apr 16 09:11:02 2017 (r317015) @@ -352,10 +352,19 @@ random_harvestq_prime(void *unused __unu * Get entropy that may have been preloaded by loader(8) * and use it to pre-charge the entropy harvest queue. */ - keyfile = preload_search_by_type(RANDOM_HARVESTQ_BOOT_ENTROPY_FILE); + keyfile = preload_search_by_type(RANDOM_CACHED_BOOT_ENTROPY_MODULE); +#ifndef NO_BACKWARD_COMPATIBILITY + if (keyfile == NULL) + keyfile = preload_search_by_type(RANDOM_LEGACY_BOOT_ENTROPY_MODULE); +#endif if (keyfile != NULL) { data = preload_fetch_addr(keyfile); size = preload_fetch_size(keyfile); + /* skip the first bit of the stash so others like arc4 can also have some. */ + if (size > RANDOM_CACHED_SKIP_START) { + data += RANDOM_CACHED_SKIP_START; + size -= RANDOM_CACHED_SKIP_START; + } /* Trim the size. If the admin has a file with a funny size, we lose some. Tough. */ size -= (size % sizeof(event.he_entropy)); if (data != NULL && size != 0) { Modified: head/sys/dev/random/random_harvestq.h ============================================================================== --- head/sys/dev/random/random_harvestq.h Sun Apr 16 09:00:10 2017 (r317014) +++ head/sys/dev/random/random_harvestq.h Sun Apr 16 09:11:02 2017 (r317015) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013-2015 Mark R V Murray + * Copyright (c) 2013-2015, 2017 Mark R V Murray * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,8 +45,6 @@ struct harvest_event { void read_rate_increment(u_int); -#define RANDOM_HARVESTQ_BOOT_ENTROPY_FILE "/boot/entropy" - #define RANDOM_HARVEST_INIT_LOCK(x) mtx_init(&harvest_context.hc_mtx, "entropy harvest mutex", NULL, MTX_SPIN) #define RANDOM_HARVEST_LOCK(x) mtx_lock_spin(&harvest_context.hc_mtx) #define RANDOM_HARVEST_UNLOCK(x) mtx_unlock_spin(&harvest_context.hc_mtx) Modified: head/sys/libkern/arc4random.c ============================================================================== --- head/sys/libkern/arc4random.c Sun Apr 16 09:00:10 2017 (r317014) +++ head/sys/libkern/arc4random.c Sun Apr 16 09:11:02 2017 (r317015) @@ -1,11 +1,28 @@ /*- - * THE BEER-WARE LICENSE + * Copyright (c) 2017 The FreeBSD Foundation + * All rights reserved. * - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you - * think this stuff is worth it, you can buy me a beer in return. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Dan Moschuk */ #include @@ -14,144 +31,122 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include +#include #include -#include +#include #include -#include +#include + +#include -#define ARC4_RESEED_BYTES 65536 -#define ARC4_RESEED_SECONDS 300 -#define ARC4_KEYBYTES 256 +#define CHACHA20_RESEED_BYTES 65536 +#define CHACHA20_RESEED_SECONDS 300 +#define CHACHA20_KEYBYTES 32 +#define CHACHA20_BUFFER_SIZE 64 + +CTASSERT(CHACHA20_KEYBYTES*8 >= CHACHA_MINKEYLEN); int arc4rand_iniseed_state = ARC4_ENTR_NONE; -MALLOC_DEFINE(M_ARC4RANDOM, "arc4random", "arc4random structures"); +MALLOC_DEFINE(M_CHACHA20RANDOM, "chacha20random", "chacha20random structures"); -struct arc4_s { +struct chacha20_s { struct mtx mtx; - u_int8_t i, j; - int numruns; - u_int8_t sbox[256]; + int numbytes; + int first_time_done; time_t t_reseed; - + u_int8_t m_buffer[CHACHA20_BUFFER_SIZE]; + struct chacha_ctx ctx; } __aligned(CACHE_LINE_SIZE); -static struct arc4_s *arc4inst = NULL; +static struct chacha20_s *chacha20inst = NULL; -#define ARC4_FOREACH(_arc4) \ - for (_arc4 = &arc4inst[0]; _arc4 <= &arc4inst[mp_maxid]; _arc4++) - -static u_int8_t arc4_randbyte(struct arc4_s *arc4); - -static __inline void -arc4_swap(u_int8_t *a, u_int8_t *b) -{ - u_int8_t c; - - c = *a; - *a = *b; - *b = c; -} +#define CHACHA20_FOREACH(_chacha20) \ + for (_chacha20 = &chacha20inst[0]; \ + _chacha20 <= &chacha20inst[mp_maxid]; \ + _chacha20++) /* - * Stir our S-box. + * Mix up the current context. */ static void -arc4_randomstir(struct arc4_s* arc4) +chacha20_randomstir(struct chacha20_s* chacha20) { - u_int8_t key[ARC4_KEYBYTES]; - int n; struct timeval tv_now; + size_t n, size; + u_int8_t key[CHACHA20_KEYBYTES], *data; + caddr_t keyfile; /* - * XXX: FIX!! This isn't brilliant. Need more confidence. - * This returns zero entropy before random(4) is seeded. + * This is making the best of what may be an insecure + * Situation. If the loader(8) did not have an entropy + * stash from the previous shutdown to load, then we will + * be improperly seeded. The answer is to make sure there + * is an entropy stash at shutdown time. */ - (void)read_random(key, ARC4_KEYBYTES); - getmicrouptime(&tv_now); - mtx_lock(&arc4->mtx); - for (n = 0; n < 256; n++) { - arc4->j = (arc4->j + arc4->sbox[n] + key[n]) % 256; - arc4_swap(&arc4->sbox[n], &arc4->sbox[arc4->j]); + (void)read_random(key, CHACHA20_KEYBYTES); + if (!chacha20->first_time_done) { + keyfile = preload_search_by_type(RANDOM_CACHED_BOOT_ENTROPY_MODULE); + if (keyfile != NULL) { + data = preload_fetch_addr(keyfile); + size = MIN(preload_fetch_size(keyfile), CHACHA20_KEYBYTES); + for (n = 0; n < size; n++) + key[n] ^= data[n]; + explicit_bzero(data, size); + if (bootverbose) + printf("arc4random: read %zu bytes from preloaded cache\n", size); + } else + printf("arc4random: no preloaded entropy cache\n"); + chacha20->first_time_done = 1; } - arc4->i = arc4->j = 0; + getmicrouptime(&tv_now); + mtx_lock(&chacha20->mtx); + chacha_keysetup(&chacha20->ctx, key, CHACHA20_KEYBYTES*8); + chacha_ivsetup(&chacha20->ctx, (u_char *)&tv_now.tv_sec, (u_char *)&tv_now.tv_usec); /* Reset for next reseed cycle. */ - arc4->t_reseed = tv_now.tv_sec + ARC4_RESEED_SECONDS; - arc4->numruns = 0; - /* - * Throw away the first N words of output, as suggested in the - * paper "Weaknesses in the Key Scheduling Algorithm of RC4" - * by Fluher, Mantin, and Shamir. (N = 768 in our case.) - * - * http://dl.acm.org/citation.cfm?id=646557.694759 - */ - for (n = 0; n < 768*4; n++) - arc4_randbyte(arc4); - - mtx_unlock(&arc4->mtx); + chacha20->t_reseed = tv_now.tv_sec + CHACHA20_RESEED_SECONDS; + chacha20->numbytes = 0; + mtx_unlock(&chacha20->mtx); } /* - * Initialize our S-box to its beginning defaults. + * Initialize the contexts. */ static void -arc4_init(void) +chacha20_init(void) { - struct arc4_s *arc4; - int n; - - arc4inst = malloc((mp_maxid + 1) * sizeof(struct arc4_s), - M_ARC4RANDOM, M_NOWAIT | M_ZERO); - KASSERT(arc4inst != NULL, ("arc4_init: memory allocation error")); + struct chacha20_s *chacha20; - ARC4_FOREACH(arc4) { - mtx_init(&arc4->mtx, "arc4_mtx", NULL, MTX_DEF); - - arc4->i = arc4->j = 0; - for (n = 0; n < 256; n++) - arc4->sbox[n] = (u_int8_t) n; - - arc4->t_reseed = -1; - arc4->numruns = 0; + chacha20inst = malloc((mp_maxid + 1) * sizeof(struct chacha20_s), + M_CHACHA20RANDOM, M_NOWAIT | M_ZERO); + KASSERT(chacha20inst != NULL, ("chacha20_init: memory allocation error")); + + CHACHA20_FOREACH(chacha20) { + mtx_init(&chacha20->mtx, "chacha20_mtx", NULL, MTX_DEF); + chacha20->t_reseed = -1; + chacha20->numbytes = 0; + chacha20->first_time_done = 0; + explicit_bzero(chacha20->m_buffer, CHACHA20_BUFFER_SIZE); + explicit_bzero(&chacha20->ctx, sizeof(chacha20->ctx)); } } -SYSINIT(arc4, SI_SUB_LOCK, SI_ORDER_ANY, arc4_init, NULL); +SYSINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_init, NULL); static void -arc4_uninit(void) +chacha20_uninit(void) { - struct arc4_s *arc4; + struct chacha20_s *chacha20; - ARC4_FOREACH(arc4) { - mtx_destroy(&arc4->mtx); - } - - free(arc4inst, M_ARC4RANDOM); + CHACHA20_FOREACH(chacha20) + mtx_destroy(&chacha20->mtx); + free(chacha20inst, M_CHACHA20RANDOM); } +SYSUNINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_uninit, NULL); -SYSUNINIT(arc4, SI_SUB_LOCK, SI_ORDER_ANY, arc4_uninit, NULL); - - -/* - * Generate a random byte. - */ -static u_int8_t -arc4_randbyte(struct arc4_s *arc4) -{ - u_int8_t arc4_t; - - arc4->i = (arc4->i + 1) % 256; - arc4->j = (arc4->j + arc4->sbox[arc4->i]) % 256; - - arc4_swap(&arc4->sbox[arc4->i], &arc4->sbox[arc4->j]); - - arc4_t = (arc4->sbox[arc4->i] + arc4->sbox[arc4->j]) % 256; - return arc4->sbox[arc4_t]; -} /* * MPSAFE @@ -159,28 +154,36 @@ arc4_randbyte(struct arc4_s *arc4) void arc4rand(void *ptr, u_int len, int reseed) { - u_char *p; + struct chacha20_s *chacha20; struct timeval tv; - struct arc4_s *arc4; + u_int length; + u_int8_t *p; - if (reseed || atomic_cmpset_int(&arc4rand_iniseed_state, - ARC4_ENTR_HAVE, ARC4_ENTR_SEED)) { - ARC4_FOREACH(arc4) - arc4_randomstir(arc4); - } + if (reseed || atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_HAVE, ARC4_ENTR_SEED)) + CHACHA20_FOREACH(chacha20) + chacha20_randomstir(chacha20); - arc4 = &arc4inst[curcpu]; + chacha20 = &chacha20inst[curcpu]; getmicrouptime(&tv); - if ((arc4->numruns > ARC4_RESEED_BYTES) || - (tv.tv_sec > arc4->t_reseed)) - arc4_randomstir(arc4); + /* We may get unlucky and be migrated off this CPU, but that is expected to be infrequent */ + if ((chacha20->numbytes > CHACHA20_RESEED_BYTES) || (tv.tv_sec > chacha20->t_reseed)) + chacha20_randomstir(chacha20); - mtx_lock(&arc4->mtx); - arc4->numruns += len; + mtx_lock(&chacha20->mtx); p = ptr; - while (len--) - *p++ = arc4_randbyte(arc4); - mtx_unlock(&arc4->mtx); + while (len) { + length = MIN(CHACHA20_BUFFER_SIZE, len); + chacha_encrypt_bytes(&chacha20->ctx, chacha20->m_buffer, p, length); + p += length; + len -= length; + chacha20->numbytes += length; + if (chacha20->numbytes > CHACHA20_RESEED_BYTES) { + mtx_unlock(&chacha20->mtx); + chacha20_randomstir(chacha20); + mtx_lock(&chacha20->mtx); + } + } + mtx_unlock(&chacha20->mtx); } uint32_t @@ -188,6 +191,13 @@ arc4random(void) { uint32_t ret; - arc4rand(&ret, sizeof ret, 0); + arc4rand(&ret, sizeof(ret), 0); return ret; } + +void +arc4random_buf(void *ptr, size_t len) +{ + + arc4rand(ptr, len, 0); +} Modified: head/sys/sys/libkern.h ============================================================================== --- head/sys/sys/libkern.h Sun Apr 16 09:00:10 2017 (r317014) +++ head/sys/sys/libkern.h Sun Apr 16 09:11:02 2017 (r317015) @@ -117,7 +117,8 @@ extern int arc4rand_iniseed_state; /* Prototypes for non-quad routines. */ struct malloc_type; uint32_t arc4random(void); -void arc4rand(void *ptr, u_int len, int reseed); +void arc4random_buf(void *, size_t); +void arc4rand(void *, u_int, int); int bcmp(const void *, const void *, size_t); int timingsafe_bcmp(const void *, const void *, size_t); void *bsearch(const void *, const void *, size_t, Modified: head/sys/sys/random.h ============================================================================== --- head/sys/sys/random.h Sun Apr 16 09:00:10 2017 (r317014) +++ head/sys/sys/random.h Sun Apr 16 09:11:02 2017 (r317015) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2000-2015 Mark R. V. Murray + * Copyright (c) 2000-2015, 2017 Mark R. V. Murray * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -96,6 +96,10 @@ enum random_entropy_source { #define RANDOM_HARVEST_EVERYTHING_MASK ((1 << (RANDOM_ENVIRONMENTAL_END + 1)) - 1) +#define RANDOM_LEGACY_BOOT_ENTROPY_MODULE "/boot/entropy" +#define RANDOM_CACHED_BOOT_ENTROPY_MODULE "boot_entropy_cache" +#define RANDOM_CACHED_SKIP_START 256 + #if defined(DEV_RANDOM) void random_harvest_queue(const void *, u_int, u_int, enum random_entropy_source); void random_harvest_fast(const void *, u_int, u_int, enum random_entropy_source); From owner-svn-src-all@freebsd.org Sun Apr 16 09:19:45 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22FF9D40AC4; Sun, 16 Apr 2017 09:19:45 +0000 (UTC) (envelope-from markm@FreeBSD.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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0A2A19F3; Sun, 16 Apr 2017 09:19:44 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from graveyard.grondar.org ([88.96.155.33] helo=gronkulator.grondar.org) by gromit.grondar.org with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1czgLM-000Pss-5E; Sun, 16 Apr 2017 10:19:43 +0100 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys From: Mark R V Murray In-Reply-To: <201704160911.v3G9B3df023095@repo.freebsd.org> Date: Sun, 16 Apr 2017 10:19:39 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201704160911.v3G9B3df023095@repo.freebsd.org> To: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org X-Mailer: Apple Mail (2.3273) X-SA-Score: -1.0 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 09:19:45 -0000 This does not use DES' Chacha20 commit, as I had already completed the testing for it, and received SO@ approval. DES's commit made Chaha20 a module. This is of no use to arc4random(9), which needs the code to be standard. Also his API is different. I have no objection to reworking the arc4random/Chacha below to use DES' version of Chacha, but his code needs to be standard library code, not an optional module. Any objections to me doing this? M > On 16 Apr 2017, at 10:11, Mark Murray wrote: >=20 > Author: markm > Date: Sun Apr 16 09:11:02 2017 > New Revision: 317015 > URL: https://svnweb.freebsd.org/changeset/base/317015 >=20 > Log: > Replace the RC4 algorithm for generating in-kernel secure random > numbers with Chacha20. Keep the API, though, as that is what the > other *BSD's have done. >=20 > Use the boot-time entropy stash (if present) to bootstrap the > in-kernel entropy source. >=20 > Reviewed by: delphij,rwatson > Approved by: so(delphij) > MFC after: 2 months > Relnotes: yes > Differential Revision: https://reviews.freebsd.org/D10048 > --This line, and those below, will be ignored-- >> Description of fields to fill in above: 76 = columns --| >> PR: If and which Problem Report is related. >> Submitted by: If someone else sent in the change. >> Reported by: If someone else reported the issue. >> Reviewed by: If someone else reviewed your modification. >> Approved by: If you needed approval for this commit. >> Obtained from: If the change is from a third party. >> MFC after: N [day[s]|week[s]|month[s]]. Request a = reminder email. >> MFH: Ports tree branch name. Request approval = for merge. >> Relnotes: Set to 'yes' for mention in release notes. >> Security: Vulnerability reference (one per line) or = description. >> Sponsored by: If the change was sponsored by an = organization. >> Differential Revision: https://reviews.freebsd.org/D### (*full* = phabric URL needed). >> Empty fields above will be automatically removed. >=20 > Added: > head/sys/crypto/chacha20/chacha.c (contents, props changed) > head/sys/crypto/chacha20/chacha.h (contents, props changed) > Modified: > head/sys/boot/forth/loader.conf > head/sys/conf/files > head/sys/dev/random/random_harvestq.c > head/sys/dev/random/random_harvestq.h > head/sys/libkern/arc4random.c > head/sys/sys/libkern.h > head/sys/sys/random.h >=20 > Modified: head/sys/boot/forth/loader.conf > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/boot/forth/loader.conf Sun Apr 16 09:00:10 2017 = (r317014) > +++ head/sys/boot/forth/loader.conf Sun Apr 16 09:11:02 2017 = (r317015) > @@ -48,7 +48,7 @@ bitmap_type=3D"splash_image_data" # and pl > entropy_cache_load=3D"YES" # Set this to NO to disable = loading > # entropy at boot time > entropy_cache_name=3D"/boot/entropy" # Set this to the name of the = file > -entropy_cache_type=3D"/boot/entropy" # Required for the kernel to = find > +entropy_cache_type=3D"boot_entropy_cache" # Required for the = kernel to find > # the boot-time entropy cache. = This > # must not change value even if = the > # _name above does change! >=20 > Modified: head/sys/conf/files > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/conf/files Sun Apr 16 09:00:10 2017 = (r317014) > +++ head/sys/conf/files Sun Apr 16 09:11:02 2017 = (r317015) > @@ -3810,6 +3810,7 @@ kgssapi/gsstest.c optional = kgssapi_debu > # the file should be moved to conf/files. from here. > # > libkern/arc4random.c standard > +crypto/chacha20/chacha.c standard > libkern/asprintf.c standard > libkern/bcd.c standard > libkern/bsearch.c standard >=20 > Added: head/sys/crypto/chacha20/chacha.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/sys/crypto/chacha20/chacha.c Sun Apr 16 09:11:02 2017 = (r317015) > @@ -0,0 +1,224 @@ > +/* > +chacha-merged.c version 20080118 > +D. J. Bernstein > +Public domain. > +*/ > + > +/* $OpenBSD: chacha.c,v 1.1 2013/11/21 00:45:44 djm Exp $ */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > + > +#include > + > + > +typedef uint8_t u8; > +typedef uint32_t u32; > + > +typedef struct chacha_ctx chacha_ctx; > + > +#define U8C(v) (v##U) > +#define U32C(v) (v##U) > + > +#define U8V(v) ((u8)(v) & U8C(0xFF)) > +#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF)) > + > +#define ROTL32(v, n) \ > + (U32V((v) << (n)) | ((v) >> (32 - (n)))) > + > +#define U8TO32_LITTLE(p) \ > + (((u32)((p)[0]) ) | \ > + ((u32)((p)[1]) << 8) | \ > + ((u32)((p)[2]) << 16) | \ > + ((u32)((p)[3]) << 24)) > + > +#define U32TO8_LITTLE(p, v) \ > + do { \ > + (p)[0] =3D U8V((v) ); \ > + (p)[1] =3D U8V((v) >> 8); \ > + (p)[2] =3D U8V((v) >> 16); \ > + (p)[3] =3D U8V((v) >> 24); \ > + } while (0) > + > +#define ROTATE(v,c) (ROTL32(v,c)) > +#define XOR(v,w) ((v) ^ (w)) > +#define PLUS(v,w) (U32V((v) + (w))) > +#define PLUSONE(v) (PLUS((v),1)) > + > +#define QUARTERROUND(a,b,c,d) \ > + a =3D PLUS(a,b); d =3D ROTATE(XOR(d,a),16); \ > + c =3D PLUS(c,d); b =3D ROTATE(XOR(b,c),12); \ > + a =3D PLUS(a,b); d =3D ROTATE(XOR(d,a), 8); \ > + c =3D PLUS(c,d); b =3D ROTATE(XOR(b,c), 7); > + > +static const char sigma[16] =3D "expand 32-byte k"; > +static const char tau[16] =3D "expand 16-byte k"; > + > +void > +chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits) > +{ > + const char *constants; > + > + x->input[4] =3D U8TO32_LITTLE(k + 0); > + x->input[5] =3D U8TO32_LITTLE(k + 4); > + x->input[6] =3D U8TO32_LITTLE(k + 8); > + x->input[7] =3D U8TO32_LITTLE(k + 12); > + if (kbits =3D=3D 256) { /* recommended */ > + k +=3D 16; > + constants =3D sigma; > + } else { /* kbits =3D=3D 128 */ > + constants =3D tau; > + } > + x->input[8] =3D U8TO32_LITTLE(k + 0); > + x->input[9] =3D U8TO32_LITTLE(k + 4); > + x->input[10] =3D U8TO32_LITTLE(k + 8); > + x->input[11] =3D U8TO32_LITTLE(k + 12); > + x->input[0] =3D U8TO32_LITTLE(constants + 0); > + x->input[1] =3D U8TO32_LITTLE(constants + 4); > + x->input[2] =3D U8TO32_LITTLE(constants + 8); > + x->input[3] =3D U8TO32_LITTLE(constants + 12); > +} > + > +void > +chacha_ivsetup(chacha_ctx *x, const u8 *iv, const u8 *counter) > +{ > + x->input[12] =3D counter =3D=3D NULL ? 0 : U8TO32_LITTLE(counter + = 0); > + x->input[13] =3D counter =3D=3D NULL ? 0 : U8TO32_LITTLE(counter + = 4); > + x->input[14] =3D U8TO32_LITTLE(iv + 0); > + x->input[15] =3D U8TO32_LITTLE(iv + 4); > +} > + > +void > +chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes) > +{ > + u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, = x14, x15; > + u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, = j14, j15; > + u8 *ctarget =3D NULL; > + u8 tmp[64]; > + u_int i; > + > + if (!bytes) return; > + > + j0 =3D x->input[0]; > + j1 =3D x->input[1]; > + j2 =3D x->input[2]; > + j3 =3D x->input[3]; > + j4 =3D x->input[4]; > + j5 =3D x->input[5]; > + j6 =3D x->input[6]; > + j7 =3D x->input[7]; > + j8 =3D x->input[8]; > + j9 =3D x->input[9]; > + j10 =3D x->input[10]; > + j11 =3D x->input[11]; > + j12 =3D x->input[12]; > + j13 =3D x->input[13]; > + j14 =3D x->input[14]; > + j15 =3D x->input[15]; > + > + for (;;) { > + if (bytes < 64) { > + for (i =3D 0;i < bytes;++i) tmp[i] =3D m[i]; > + m =3D tmp; > + ctarget =3D c; > + c =3D tmp; > + } > + x0 =3D j0; > + x1 =3D j1; > + x2 =3D j2; > + x3 =3D j3; > + x4 =3D j4; > + x5 =3D j5; > + x6 =3D j6; > + x7 =3D j7; > + x8 =3D j8; > + x9 =3D j9; > + x10 =3D j10; > + x11 =3D j11; > + x12 =3D j12; > + x13 =3D j13; > + x14 =3D j14; > + x15 =3D j15; > + for (i =3D 20;i > 0;i -=3D 2) { > + QUARTERROUND( x0, x4, x8,x12) > + QUARTERROUND( x1, x5, x9,x13) > + QUARTERROUND( x2, x6,x10,x14) > + QUARTERROUND( x3, x7,x11,x15) > + QUARTERROUND( x0, x5,x10,x15) > + QUARTERROUND( x1, x6,x11,x12) > + QUARTERROUND( x2, x7, x8,x13) > + QUARTERROUND( x3, x4, x9,x14) > + } > + x0 =3D PLUS(x0,j0); > + x1 =3D PLUS(x1,j1); > + x2 =3D PLUS(x2,j2); > + x3 =3D PLUS(x3,j3); > + x4 =3D PLUS(x4,j4); > + x5 =3D PLUS(x5,j5); > + x6 =3D PLUS(x6,j6); > + x7 =3D PLUS(x7,j7); > + x8 =3D PLUS(x8,j8); > + x9 =3D PLUS(x9,j9); > + x10 =3D PLUS(x10,j10); > + x11 =3D PLUS(x11,j11); > + x12 =3D PLUS(x12,j12); > + x13 =3D PLUS(x13,j13); > + x14 =3D PLUS(x14,j14); > + x15 =3D PLUS(x15,j15); > + > + x0 =3D XOR(x0,U8TO32_LITTLE(m + 0)); > + x1 =3D XOR(x1,U8TO32_LITTLE(m + 4)); > + x2 =3D XOR(x2,U8TO32_LITTLE(m + 8)); > + x3 =3D XOR(x3,U8TO32_LITTLE(m + 12)); > + x4 =3D XOR(x4,U8TO32_LITTLE(m + 16)); > + x5 =3D XOR(x5,U8TO32_LITTLE(m + 20)); > + x6 =3D XOR(x6,U8TO32_LITTLE(m + 24)); > + x7 =3D XOR(x7,U8TO32_LITTLE(m + 28)); > + x8 =3D XOR(x8,U8TO32_LITTLE(m + 32)); > + x9 =3D XOR(x9,U8TO32_LITTLE(m + 36)); > + x10 =3D XOR(x10,U8TO32_LITTLE(m + 40)); > + x11 =3D XOR(x11,U8TO32_LITTLE(m + 44)); > + x12 =3D XOR(x12,U8TO32_LITTLE(m + 48)); > + x13 =3D XOR(x13,U8TO32_LITTLE(m + 52)); > + x14 =3D XOR(x14,U8TO32_LITTLE(m + 56)); > + x15 =3D XOR(x15,U8TO32_LITTLE(m + 60)); > + > + j12 =3D PLUSONE(j12); > + if (!j12) { > + j13 =3D PLUSONE(j13); > + /* stopping at 2^70 bytes per nonce is user's responsibility */ > + } > + > + U32TO8_LITTLE(c + 0,x0); > + U32TO8_LITTLE(c + 4,x1); > + U32TO8_LITTLE(c + 8,x2); > + U32TO8_LITTLE(c + 12,x3); > + U32TO8_LITTLE(c + 16,x4); > + U32TO8_LITTLE(c + 20,x5); > + U32TO8_LITTLE(c + 24,x6); > + U32TO8_LITTLE(c + 28,x7); > + U32TO8_LITTLE(c + 32,x8); > + U32TO8_LITTLE(c + 36,x9); > + U32TO8_LITTLE(c + 40,x10); > + U32TO8_LITTLE(c + 44,x11); > + U32TO8_LITTLE(c + 48,x12); > + U32TO8_LITTLE(c + 52,x13); > + U32TO8_LITTLE(c + 56,x14); > + U32TO8_LITTLE(c + 60,x15); > + > + if (bytes <=3D 64) { > + if (bytes < 64) { > + for (i =3D 0;i < bytes;++i) ctarget[i] =3D c[i]; > + } > + x->input[12] =3D j12; > + x->input[13] =3D j13; > + return; > + } > + bytes -=3D 64; > + c +=3D 64; > + m +=3D 64; > + } > +} >=20 > Added: head/sys/crypto/chacha20/chacha.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/sys/crypto/chacha20/chacha.h Sun Apr 16 09:11:02 2017 = (r317015) > @@ -0,0 +1,32 @@ > +/* $OpenBSD: chacha.h,v 1.4 2016/08/27 04:04:56 guenther Exp $ */ > + > +/* > +chacha-merged.c version 20080118 > +D. J. Bernstein > +Public domain. > + > + $FreeBSD$ > +*/ > + > +#ifndef CHACHA_H > +#define CHACHA_H > + > +#include > + > +struct chacha_ctx { > + u_int input[16]; > +}; > + > +#define CHACHA_MINKEYLEN 16 > +#define CHACHA_NONCELEN 8 > +#define CHACHA_CTRLEN 8 > +#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) > +#define CHACHA_BLOCKLEN 64 > + > +void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int = kbits); > +void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const = u_char *ctr); > +void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m, > + u_char *c, u_int bytes); > + > +#endif /* CHACHA_H */ > + >=20 > Modified: head/sys/dev/random/random_harvestq.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/dev/random/random_harvestq.c Sun Apr 16 09:00:10 2017 = (r317014) > +++ head/sys/dev/random/random_harvestq.c Sun Apr 16 09:11:02 2017 = (r317015) > @@ -352,10 +352,19 @@ random_harvestq_prime(void *unused __unu > * Get entropy that may have been preloaded by loader(8) > * and use it to pre-charge the entropy harvest queue. > */ > - keyfile =3D = preload_search_by_type(RANDOM_HARVESTQ_BOOT_ENTROPY_FILE); > + keyfile =3D = preload_search_by_type(RANDOM_CACHED_BOOT_ENTROPY_MODULE); > +#ifndef NO_BACKWARD_COMPATIBILITY > + if (keyfile =3D=3D NULL) > + keyfile =3D = preload_search_by_type(RANDOM_LEGACY_BOOT_ENTROPY_MODULE); > +#endif > if (keyfile !=3D NULL) { > data =3D preload_fetch_addr(keyfile); > size =3D preload_fetch_size(keyfile); > + /* skip the first bit of the stash so others like arc4 = can also have some. */ > + if (size > RANDOM_CACHED_SKIP_START) { > + data +=3D RANDOM_CACHED_SKIP_START; > + size -=3D RANDOM_CACHED_SKIP_START; > + } > /* Trim the size. If the admin has a file with a funny = size, we lose some. Tough. */ > size -=3D (size % sizeof(event.he_entropy)); > if (data !=3D NULL && size !=3D 0) { >=20 > Modified: head/sys/dev/random/random_harvestq.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/dev/random/random_harvestq.h Sun Apr 16 09:00:10 2017 = (r317014) > +++ head/sys/dev/random/random_harvestq.h Sun Apr 16 09:11:02 2017 = (r317015) > @@ -1,5 +1,5 @@ > /*- > - * Copyright (c) 2013-2015 Mark R V Murray > + * Copyright (c) 2013-2015, 2017 Mark R V Murray > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -45,8 +45,6 @@ struct harvest_event { >=20 > void read_rate_increment(u_int); >=20 > -#define RANDOM_HARVESTQ_BOOT_ENTROPY_FILE "/boot/entropy" > - > #define RANDOM_HARVEST_INIT_LOCK(x) = mtx_init(&harvest_context.hc_mtx, "entropy harvest mutex", NULL, = MTX_SPIN) > #define RANDOM_HARVEST_LOCK(x) = mtx_lock_spin(&harvest_context.hc_mtx) > #define RANDOM_HARVEST_UNLOCK(x) = mtx_unlock_spin(&harvest_context.hc_mtx) >=20 > Modified: head/sys/libkern/arc4random.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/libkern/arc4random.c Sun Apr 16 09:00:10 2017 = (r317014) > +++ head/sys/libkern/arc4random.c Sun Apr 16 09:11:02 2017 = (r317015) > @@ -1,11 +1,28 @@ > /*- > - * THE BEER-WARE LICENSE > + * Copyright (c) 2017 The FreeBSD Foundation > + * All rights reserved. > * > - * wrote this file. As long as you retain this = notice you > - * can do whatever you want with this stuff. If we meet some day, = and you > - * think this stuff is worth it, you can buy me a beer in return. > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer > + * in this position and unchanged. > + * 2. Redistributions in binary form must reproduce the above = copyright > + * notice, this list of conditions and the following disclaimer in = the > + * documentation and/or other materials provided with the = distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS = OR > + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED = WARRANTIES > + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE = DISCLAIMED. > + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES = (INCLUDING, BUT > + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS = OF USE, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON = ANY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR = TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE = USE OF > + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > - * Dan Moschuk > */ >=20 > #include > @@ -14,144 +31,122 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > -#include > #include > +#include > #include > +#include > #include > -#include > +#include > #include > -#include > +#include > + > +#include >=20 > -#define ARC4_RESEED_BYTES 65536 > -#define ARC4_RESEED_SECONDS 300 > -#define ARC4_KEYBYTES 256 > +#define CHACHA20_RESEED_BYTES 65536 > +#define CHACHA20_RESEED_SECONDS 300 > +#define CHACHA20_KEYBYTES 32 > +#define CHACHA20_BUFFER_SIZE 64 > + > +CTASSERT(CHACHA20_KEYBYTES*8 >=3D CHACHA_MINKEYLEN); >=20 > int arc4rand_iniseed_state =3D ARC4_ENTR_NONE; >=20 > -MALLOC_DEFINE(M_ARC4RANDOM, "arc4random", "arc4random structures"); > +MALLOC_DEFINE(M_CHACHA20RANDOM, "chacha20random", "chacha20random = structures"); >=20 > -struct arc4_s { > +struct chacha20_s { > struct mtx mtx; > - u_int8_t i, j; > - int numruns; > - u_int8_t sbox[256]; > + int numbytes; > + int first_time_done; > time_t t_reseed; > - > + u_int8_t m_buffer[CHACHA20_BUFFER_SIZE]; > + struct chacha_ctx ctx; > } __aligned(CACHE_LINE_SIZE); >=20 > -static struct arc4_s *arc4inst =3D NULL; > +static struct chacha20_s *chacha20inst =3D NULL; >=20 > -#define ARC4_FOREACH(_arc4) \ > - for (_arc4 =3D &arc4inst[0]; _arc4 <=3D &arc4inst[mp_maxid]; = _arc4++) > - > -static u_int8_t arc4_randbyte(struct arc4_s *arc4); > - > -static __inline void > -arc4_swap(u_int8_t *a, u_int8_t *b) > -{ > - u_int8_t c; > - > - c =3D *a; > - *a =3D *b; > - *b =3D c; > -}=09 > +#define CHACHA20_FOREACH(_chacha20) \ > + for (_chacha20 =3D &chacha20inst[0]; \ > + _chacha20 <=3D &chacha20inst[mp_maxid]; \ > + _chacha20++) >=20 > /* > - * Stir our S-box. > + * Mix up the current context. > */ > static void > -arc4_randomstir(struct arc4_s* arc4) > +chacha20_randomstir(struct chacha20_s* chacha20) > { > - u_int8_t key[ARC4_KEYBYTES]; > - int n; > struct timeval tv_now; > + size_t n, size; > + u_int8_t key[CHACHA20_KEYBYTES], *data; > + caddr_t keyfile; >=20 > /* > - * XXX: FIX!! This isn't brilliant. Need more confidence. > - * This returns zero entropy before random(4) is seeded. > + * This is making the best of what may be an insecure > + * Situation. If the loader(8) did not have an entropy > + * stash from the previous shutdown to load, then we will > + * be improperly seeded. The answer is to make sure there > + * is an entropy stash at shutdown time. > */ > - (void)read_random(key, ARC4_KEYBYTES); > - getmicrouptime(&tv_now); > - mtx_lock(&arc4->mtx); > - for (n =3D 0; n < 256; n++) { > - arc4->j =3D (arc4->j + arc4->sbox[n] + key[n]) % 256; > - arc4_swap(&arc4->sbox[n], &arc4->sbox[arc4->j]); > + (void)read_random(key, CHACHA20_KEYBYTES); > + if (!chacha20->first_time_done) { > + keyfile =3D = preload_search_by_type(RANDOM_CACHED_BOOT_ENTROPY_MODULE); > + if (keyfile !=3D NULL) { > + data =3D preload_fetch_addr(keyfile); > + size =3D MIN(preload_fetch_size(keyfile), = CHACHA20_KEYBYTES); > + for (n =3D 0; n < size; n++) > + key[n] ^=3D data[n]; > + explicit_bzero(data, size); > + if (bootverbose) > + printf("arc4random: read %zu bytes from = preloaded cache\n", size); > + } else > + printf("arc4random: no preloaded entropy = cache\n"); > + chacha20->first_time_done =3D 1; > } > - arc4->i =3D arc4->j =3D 0; > + getmicrouptime(&tv_now); > + mtx_lock(&chacha20->mtx); > + chacha_keysetup(&chacha20->ctx, key, CHACHA20_KEYBYTES*8); > + chacha_ivsetup(&chacha20->ctx, (u_char *)&tv_now.tv_sec, (u_char = *)&tv_now.tv_usec); > /* Reset for next reseed cycle. */ > - arc4->t_reseed =3D tv_now.tv_sec + ARC4_RESEED_SECONDS; > - arc4->numruns =3D 0; > - /* > - * Throw away the first N words of output, as suggested in the > - * paper "Weaknesses in the Key Scheduling Algorithm of RC4" > - * by Fluher, Mantin, and Shamir. (N =3D 768 in our case.) > - * > - * http://dl.acm.org/citation.cfm?id=3D646557.694759 > - */ > - for (n =3D 0; n < 768*4; n++) > - arc4_randbyte(arc4); > - > - mtx_unlock(&arc4->mtx); > + chacha20->t_reseed =3D tv_now.tv_sec + CHACHA20_RESEED_SECONDS; > + chacha20->numbytes =3D 0; > + mtx_unlock(&chacha20->mtx); > } >=20 > /* > - * Initialize our S-box to its beginning defaults. > + * Initialize the contexts. > */ > static void > -arc4_init(void) > +chacha20_init(void) > { > - struct arc4_s *arc4; > - int n; > - > - arc4inst =3D malloc((mp_maxid + 1) * sizeof(struct arc4_s), > - M_ARC4RANDOM, M_NOWAIT | M_ZERO); > - KASSERT(arc4inst !=3D NULL, ("arc4_init: memory allocation = error")); > + struct chacha20_s *chacha20; >=20 > - ARC4_FOREACH(arc4) { > - mtx_init(&arc4->mtx, "arc4_mtx", NULL, MTX_DEF); > - > - arc4->i =3D arc4->j =3D 0; > - for (n =3D 0; n < 256; n++) > - arc4->sbox[n] =3D (u_int8_t) n; > - > - arc4->t_reseed =3D -1; > - arc4->numruns =3D 0; > + chacha20inst =3D malloc((mp_maxid + 1) * sizeof(struct = chacha20_s), > + M_CHACHA20RANDOM, M_NOWAIT | M_ZERO); > + KASSERT(chacha20inst !=3D NULL, ("chacha20_init: memory = allocation error")); > + > + CHACHA20_FOREACH(chacha20) { > + mtx_init(&chacha20->mtx, "chacha20_mtx", NULL, MTX_DEF); > + chacha20->t_reseed =3D -1; > + chacha20->numbytes =3D 0; > + chacha20->first_time_done =3D 0; > + explicit_bzero(chacha20->m_buffer, = CHACHA20_BUFFER_SIZE); > + explicit_bzero(&chacha20->ctx, sizeof(chacha20->ctx)); > } > } > -SYSINIT(arc4, SI_SUB_LOCK, SI_ORDER_ANY, arc4_init, NULL); > +SYSINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_init, NULL); >=20 >=20 > static void > -arc4_uninit(void) > +chacha20_uninit(void) > { > - struct arc4_s *arc4; > + struct chacha20_s *chacha20; >=20 > - ARC4_FOREACH(arc4) { > - mtx_destroy(&arc4->mtx); > - } > - > - free(arc4inst, M_ARC4RANDOM); > + CHACHA20_FOREACH(chacha20) > + mtx_destroy(&chacha20->mtx); > + free(chacha20inst, M_CHACHA20RANDOM); > } > +SYSUNINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_uninit, = NULL); >=20 > -SYSUNINIT(arc4, SI_SUB_LOCK, SI_ORDER_ANY, arc4_uninit, NULL); > - > - > -/* > - * Generate a random byte. > - */ > -static u_int8_t > -arc4_randbyte(struct arc4_s *arc4) > -{ > - u_int8_t arc4_t; > - > - arc4->i =3D (arc4->i + 1) % 256; > - arc4->j =3D (arc4->j + arc4->sbox[arc4->i]) % 256; > - > - arc4_swap(&arc4->sbox[arc4->i], &arc4->sbox[arc4->j]); > - > - arc4_t =3D (arc4->sbox[arc4->i] + arc4->sbox[arc4->j]) % 256; > - return arc4->sbox[arc4_t]; > -} >=20 > /* > * MPSAFE > @@ -159,28 +154,36 @@ arc4_randbyte(struct arc4_s *arc4) > void > arc4rand(void *ptr, u_int len, int reseed) > { > - u_char *p; > + struct chacha20_s *chacha20; > struct timeval tv; > - struct arc4_s *arc4; > + u_int length; > + u_int8_t *p; >=20 > - if (reseed || atomic_cmpset_int(&arc4rand_iniseed_state, > - ARC4_ENTR_HAVE, ARC4_ENTR_SEED)) { > - ARC4_FOREACH(arc4) > - arc4_randomstir(arc4); > - } > + if (reseed || atomic_cmpset_int(&arc4rand_iniseed_state, = ARC4_ENTR_HAVE, ARC4_ENTR_SEED)) > + CHACHA20_FOREACH(chacha20) > + chacha20_randomstir(chacha20); >=20 > - arc4 =3D &arc4inst[curcpu]; > + chacha20 =3D &chacha20inst[curcpu]; > getmicrouptime(&tv); > - if ((arc4->numruns > ARC4_RESEED_BYTES) || > - (tv.tv_sec > arc4->t_reseed)) > - arc4_randomstir(arc4); > + /* We may get unlucky and be migrated off this CPU, but that is = expected to be infrequent */ > + if ((chacha20->numbytes > CHACHA20_RESEED_BYTES) || (tv.tv_sec > = chacha20->t_reseed)) > + chacha20_randomstir(chacha20); >=20 > - mtx_lock(&arc4->mtx); > - arc4->numruns +=3D len; > + mtx_lock(&chacha20->mtx); > p =3D ptr; > - while (len--) > - *p++ =3D arc4_randbyte(arc4); > - mtx_unlock(&arc4->mtx); > + while (len) { > + length =3D MIN(CHACHA20_BUFFER_SIZE, len); > + chacha_encrypt_bytes(&chacha20->ctx, chacha20->m_buffer, = p, length); > + p +=3D length; > + len -=3D length; > + chacha20->numbytes +=3D length; > + if (chacha20->numbytes > CHACHA20_RESEED_BYTES) { > + mtx_unlock(&chacha20->mtx); > + chacha20_randomstir(chacha20); > + mtx_lock(&chacha20->mtx); > + } > + } > + mtx_unlock(&chacha20->mtx); > } >=20 > uint32_t > @@ -188,6 +191,13 @@ arc4random(void) > { > uint32_t ret; >=20 > - arc4rand(&ret, sizeof ret, 0); > + arc4rand(&ret, sizeof(ret), 0); > return ret; > } > + > +void > +arc4random_buf(void *ptr, size_t len) > +{ > + > + arc4rand(ptr, len, 0); > +} >=20 > Modified: head/sys/sys/libkern.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/sys/libkern.h Sun Apr 16 09:00:10 2017 = (r317014) > +++ head/sys/sys/libkern.h Sun Apr 16 09:11:02 2017 = (r317015) > @@ -117,7 +117,8 @@ extern int arc4rand_iniseed_state; > /* Prototypes for non-quad routines. */ > struct malloc_type; > uint32_t arc4random(void); > -void arc4rand(void *ptr, u_int len, int reseed); > +void arc4random_buf(void *, size_t); > +void arc4rand(void *, u_int, int); > int bcmp(const void *, const void *, size_t); > int timingsafe_bcmp(const void *, const void *, size_t); > void *bsearch(const void *, const void *, size_t, >=20 > Modified: head/sys/sys/random.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/sys/random.h Sun Apr 16 09:00:10 2017 = (r317014) > +++ head/sys/sys/random.h Sun Apr 16 09:11:02 2017 = (r317015) > @@ -1,5 +1,5 @@ > /*- > - * Copyright (c) 2000-2015 Mark R. V. Murray > + * Copyright (c) 2000-2015, 2017 Mark R. V. Murray > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -96,6 +96,10 @@ enum random_entropy_source { >=20 > #define RANDOM_HARVEST_EVERYTHING_MASK ((1 << = (RANDOM_ENVIRONMENTAL_END + 1)) - 1) >=20 > +#define RANDOM_LEGACY_BOOT_ENTROPY_MODULE "/boot/entropy" > +#define RANDOM_CACHED_BOOT_ENTROPY_MODULE "boot_entropy_cache" > +#define RANDOM_CACHED_SKIP_START 256 > + > #if defined(DEV_RANDOM) > void random_harvest_queue(const void *, u_int, u_int, enum = random_entropy_source); > void random_harvest_fast(const void *, u_int, u_int, enum = random_entropy_source); >=20 --=20 Mark R V Murray From owner-svn-src-all@freebsd.org Sun Apr 16 11:50:54 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 760BED41077; Sun, 16 Apr 2017 11:50:54 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 540651606; Sun, 16 Apr 2017 11:50:53 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id v3GBojYq016404; Sun, 16 Apr 2017 04:50:45 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id v3GBohYF016403; Sun, 16 Apr 2017 04:50:43 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201704161150.v3GBohYF016403@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys In-Reply-To: To: Mark R V Murray Date: Sun, 16 Apr 2017 04:50:43 -0700 (PDT) CC: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 11:50:54 -0000 > This does not use DES' Chacha20 commit, as I had already completed the > testing for it, and received SO@ approval. > > DES's commit made Chaha20 a module. This is of no use to arc4random(9), > which needs the code to be standard. Also his API is different. > > I have no objection to reworking the arc4random/Chacha below to use DES' > version of Chacha, but his code needs to be standard library code, > not an optional module. > > Any objections to me doing this? Yes We need to move towards more modules, not less. Having this standard does not even allow one to compile a kernel without it. I should be able to compile a kernel without arc4random(9) and without chacha if I so desire. And I should be able to load and unload these if I so desire. This later feature is VERY usefull for developement and debug cycles. I am sure with careful though we can find a way to allow arc4random to use a pointer that knows if the chacha code is avaliable, and use it if so, and if not fall back to something else, or punt with an error return. I have done this with minidumps, if my module is not loaded and the kernel panics, and is set to attempt a minidump it just logs another error when it finds the NULL pointer and continues on its way to panic. > M > > > On 16 Apr 2017, at 10:11, Mark Murray wrote: > > > > Author: markm > > Date: Sun Apr 16 09:11:02 2017 > > New Revision: 317015 > > URL: https://svnweb.freebsd.org/changeset/base/317015 > > > > Log: > > Replace the RC4 algorithm for generating in-kernel secure random > > numbers with Chacha20. Keep the API, though, as that is what the > > other *BSD's have done. > > > > Use the boot-time entropy stash (if present) to bootstrap the > > in-kernel entropy source. > > > > Reviewed by: delphij,rwatson > > Approved by: so(delphij) > > MFC after: 2 months > > Relnotes: yes > > Differential Revision: https://reviews.freebsd.org/D10048 > > --This line, and those below, will be ignored-- > >> Description of fields to fill in above: 76 columns --| > >> PR: If and which Problem Report is related. > >> Submitted by: If someone else sent in the change. > >> Reported by: If someone else reported the issue. > >> Reviewed by: If someone else reviewed your modification. > >> Approved by: If you needed approval for this commit. > >> Obtained from: If the change is from a third party. > >> MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email. > >> MFH: Ports tree branch name. Request approval for merge. > >> Relnotes: Set to 'yes' for mention in release notes. > >> Security: Vulnerability reference (one per line) or description. > >> Sponsored by: If the change was sponsored by an organization. > >> Differential Revision: https://reviews.freebsd.org/D### (*full* phabric URL needed). > >> Empty fields above will be automatically removed. > > > > Added: > > head/sys/crypto/chacha20/chacha.c (contents, props changed) > > head/sys/crypto/chacha20/chacha.h (contents, props changed) > > Modified: > > head/sys/boot/forth/loader.conf > > head/sys/conf/files > > head/sys/dev/random/random_harvestq.c > > head/sys/dev/random/random_harvestq.h > > head/sys/libkern/arc4random.c > > head/sys/sys/libkern.h > > head/sys/sys/random.h > > > > Modified: head/sys/boot/forth/loader.conf > > ============================================================================== > > --- head/sys/boot/forth/loader.conf Sun Apr 16 09:00:10 2017 (r317014) > > +++ head/sys/boot/forth/loader.conf Sun Apr 16 09:11:02 2017 (r317015) > > @@ -48,7 +48,7 @@ bitmap_type="splash_image_data" # and pl > > entropy_cache_load="YES" # Set this to NO to disable loading > > # entropy at boot time > > entropy_cache_name="/boot/entropy" # Set this to the name of the file > > -entropy_cache_type="/boot/entropy" # Required for the kernel to find > > +entropy_cache_type="boot_entropy_cache" # Required for the kernel to find > > # the boot-time entropy cache. This > > # must not change value even if the > > # _name above does change! > > > > Modified: head/sys/conf/files > > ============================================================================== > > --- head/sys/conf/files Sun Apr 16 09:00:10 2017 (r317014) > > +++ head/sys/conf/files Sun Apr 16 09:11:02 2017 (r317015) > > @@ -3810,6 +3810,7 @@ kgssapi/gsstest.c optional kgssapi_debu > > # the file should be moved to conf/files. from here. > > # > > libkern/arc4random.c standard > > +crypto/chacha20/chacha.c standard > > libkern/asprintf.c standard > > libkern/bcd.c standard > > libkern/bsearch.c standard > > > > Added: head/sys/crypto/chacha20/chacha.c > > ============================================================================== > > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > > +++ head/sys/crypto/chacha20/chacha.c Sun Apr 16 09:11:02 2017 (r317015) > > @@ -0,0 +1,224 @@ > > +/* > > +chacha-merged.c version 20080118 > > +D. J. Bernstein > > +Public domain. > > +*/ > > + > > +/* $OpenBSD: chacha.c,v 1.1 2013/11/21 00:45:44 djm Exp $ */ > > + > > +#include > > +__FBSDID("$FreeBSD$"); > > + > > +#include > > +#include > > + > > +#include > > + > > + > > +typedef uint8_t u8; > > +typedef uint32_t u32; > > + > > +typedef struct chacha_ctx chacha_ctx; > > + > > +#define U8C(v) (v##U) > > +#define U32C(v) (v##U) > > + > > +#define U8V(v) ((u8)(v) & U8C(0xFF)) > > +#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF)) > > + > > +#define ROTL32(v, n) \ > > + (U32V((v) << (n)) | ((v) >> (32 - (n)))) > > + > > +#define U8TO32_LITTLE(p) \ > > + (((u32)((p)[0]) ) | \ > > + ((u32)((p)[1]) << 8) | \ > > + ((u32)((p)[2]) << 16) | \ > > + ((u32)((p)[3]) << 24)) > > + > > +#define U32TO8_LITTLE(p, v) \ > > + do { \ > > + (p)[0] = U8V((v) ); \ > > + (p)[1] = U8V((v) >> 8); \ > > + (p)[2] = U8V((v) >> 16); \ > > + (p)[3] = U8V((v) >> 24); \ > > + } while (0) > > + > > +#define ROTATE(v,c) (ROTL32(v,c)) > > +#define XOR(v,w) ((v) ^ (w)) > > +#define PLUS(v,w) (U32V((v) + (w))) > > +#define PLUSONE(v) (PLUS((v),1)) > > + > > +#define QUARTERROUND(a,b,c,d) \ > > + a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \ > > + c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \ > > + a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ > > + c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); > > + > > +static const char sigma[16] = "expand 32-byte k"; > > +static const char tau[16] = "expand 16-byte k"; > > + > > +void > > +chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits) > > +{ > > + const char *constants; > > + > > + x->input[4] = U8TO32_LITTLE(k + 0); > > + x->input[5] = U8TO32_LITTLE(k + 4); > > + x->input[6] = U8TO32_LITTLE(k + 8); > > + x->input[7] = U8TO32_LITTLE(k + 12); > > + if (kbits == 256) { /* recommended */ > > + k += 16; > > + constants = sigma; > > + } else { /* kbits == 128 */ > > + constants = tau; > > + } > > + x->input[8] = U8TO32_LITTLE(k + 0); > > + x->input[9] = U8TO32_LITTLE(k + 4); > > + x->input[10] = U8TO32_LITTLE(k + 8); > > + x->input[11] = U8TO32_LITTLE(k + 12); > > + x->input[0] = U8TO32_LITTLE(constants + 0); > > + x->input[1] = U8TO32_LITTLE(constants + 4); > > + x->input[2] = U8TO32_LITTLE(constants + 8); > > + x->input[3] = U8TO32_LITTLE(constants + 12); > > +} > > + > > +void > > +chacha_ivsetup(chacha_ctx *x, const u8 *iv, const u8 *counter) > > +{ > > + x->input[12] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 0); > > + x->input[13] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 4); > > + x->input[14] = U8TO32_LITTLE(iv + 0); > > + x->input[15] = U8TO32_LITTLE(iv + 4); > > +} > > + > > +void > > +chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes) > > +{ > > + u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; > > + u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15; > > + u8 *ctarget = NULL; > > + u8 tmp[64]; > > + u_int i; > > + > > + if (!bytes) return; > > + > > + j0 = x->input[0]; > > + j1 = x->input[1]; > > + j2 = x->input[2]; > > + j3 = x->input[3]; > > + j4 = x->input[4]; > > + j5 = x->input[5]; > > + j6 = x->input[6]; > > + j7 = x->input[7]; > > + j8 = x->input[8]; > > + j9 = x->input[9]; > > + j10 = x->input[10]; > > + j11 = x->input[11]; > > + j12 = x->input[12]; > > + j13 = x->input[13]; > > + j14 = x->input[14]; > > + j15 = x->input[15]; > > + > > + for (;;) { > > + if (bytes < 64) { > > + for (i = 0;i < bytes;++i) tmp[i] = m[i]; > > + m = tmp; > > + ctarget = c; > > + c = tmp; > > + } > > + x0 = j0; > > + x1 = j1; > > + x2 = j2; > > + x3 = j3; > > + x4 = j4; > > + x5 = j5; > > + x6 = j6; > > + x7 = j7; > > + x8 = j8; > > + x9 = j9; > > + x10 = j10; > > + x11 = j11; > > + x12 = j12; > > + x13 = j13; > > + x14 = j14; > > + x15 = j15; > > + for (i = 20;i > 0;i -= 2) { > > + QUARTERROUND( x0, x4, x8,x12) > > + QUARTERROUND( x1, x5, x9,x13) > > + QUARTERROUND( x2, x6,x10,x14) > > + QUARTERROUND( x3, x7,x11,x15) > > + QUARTERROUND( x0, x5,x10,x15) > > + QUARTERROUND( x1, x6,x11,x12) > > + QUARTERROUND( x2, x7, x8,x13) > > + QUARTERROUND( x3, x4, x9,x14) > > + } > > + x0 = PLUS(x0,j0); > > + x1 = PLUS(x1,j1); > > + x2 = PLUS(x2,j2); > > + x3 = PLUS(x3,j3); > > + x4 = PLUS(x4,j4); > > + x5 = PLUS(x5,j5); > > + x6 = PLUS(x6,j6); > > + x7 = PLUS(x7,j7); > > + x8 = PLUS(x8,j8); > > + x9 = PLUS(x9,j9); > > + x10 = PLUS(x10,j10); > > + x11 = PLUS(x11,j11); > > + x12 = PLUS(x12,j12); > > + x13 = PLUS(x13,j13); > > + x14 = PLUS(x14,j14); > > + x15 = PLUS(x15,j15); > > + > > + x0 = XOR(x0,U8TO32_LITTLE(m + 0)); > > + x1 = XOR(x1,U8TO32_LITTLE(m + 4)); > > + x2 = XOR(x2,U8TO32_LITTLE(m + 8)); > > + x3 = XOR(x3,U8TO32_LITTLE(m + 12)); > > + x4 = XOR(x4,U8TO32_LITTLE(m + 16)); > > + x5 = XOR(x5,U8TO32_LITTLE(m + 20)); > > + x6 = XOR(x6,U8TO32_LITTLE(m + 24)); > > + x7 = XOR(x7,U8TO32_LITTLE(m + 28)); > > + x8 = XOR(x8,U8TO32_LITTLE(m + 32)); > > + x9 = XOR(x9,U8TO32_LITTLE(m + 36)); > > + x10 = XOR(x10,U8TO32_LITTLE(m + 40)); > > + x11 = XOR(x11,U8TO32_LITTLE(m + 44)); > > + x12 = XOR(x12,U8TO32_LITTLE(m + 48)); > > + x13 = XOR(x13,U8TO32_LITTLE(m + 52)); > > + x14 = XOR(x14,U8TO32_LITTLE(m + 56)); > > + x15 = XOR(x15,U8TO32_LITTLE(m + 60)); > > + > > + j12 = PLUSONE(j12); > > + if (!j12) { > > + j13 = PLUSONE(j13); > > + /* stopping at 2^70 bytes per nonce is user's responsibility */ > > + } > > + > > + U32TO8_LITTLE(c + 0,x0); > > + U32TO8_LITTLE(c + 4,x1); > > + U32TO8_LITTLE(c + 8,x2); > > + U32TO8_LITTLE(c + 12,x3); > > + U32TO8_LITTLE(c + 16,x4); > > + U32TO8_LITTLE(c + 20,x5); > > + U32TO8_LITTLE(c + 24,x6); > > + U32TO8_LITTLE(c + 28,x7); > > + U32TO8_LITTLE(c + 32,x8); > > + U32TO8_LITTLE(c + 36,x9); > > + U32TO8_LITTLE(c + 40,x10); > > + U32TO8_LITTLE(c + 44,x11); > > + U32TO8_LITTLE(c + 48,x12); > > + U32TO8_LITTLE(c + 52,x13); > > + U32TO8_LITTLE(c + 56,x14); > > + U32TO8_LITTLE(c + 60,x15); > > + > > + if (bytes <= 64) { > > + if (bytes < 64) { > > + for (i = 0;i < bytes;++i) ctarget[i] = c[i]; > > + } > > + x->input[12] = j12; > > + x->input[13] = j13; > > + return; > > + } > > + bytes -= 64; > > + c += 64; > > + m += 64; > > + } > > +} > > > > Added: head/sys/crypto/chacha20/chacha.h > > ============================================================================== > > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > > +++ head/sys/crypto/chacha20/chacha.h Sun Apr 16 09:11:02 2017 (r317015) > > @@ -0,0 +1,32 @@ > > +/* $OpenBSD: chacha.h,v 1.4 2016/08/27 04:04:56 guenther Exp $ */ > > + > > +/* > > +chacha-merged.c version 20080118 > > +D. J. Bernstein > > +Public domain. > > + > > + $FreeBSD$ > > +*/ > > + > > +#ifndef CHACHA_H > > +#define CHACHA_H > > + > > +#include > > + > > +struct chacha_ctx { > > + u_int input[16]; > > +}; > > + > > +#define CHACHA_MINKEYLEN 16 > > +#define CHACHA_NONCELEN 8 > > +#define CHACHA_CTRLEN 8 > > +#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) > > +#define CHACHA_BLOCKLEN 64 > > + > > +void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits); > > +void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const u_char *ctr); > > +void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m, > > + u_char *c, u_int bytes); > > + > > +#endif /* CHACHA_H */ > > + > > > > Modified: head/sys/dev/random/random_harvestq.c > > ============================================================================== > > --- head/sys/dev/random/random_harvestq.c Sun Apr 16 09:00:10 2017 (r317014) > > +++ head/sys/dev/random/random_harvestq.c Sun Apr 16 09:11:02 2017 (r317015) > > @@ -352,10 +352,19 @@ random_harvestq_prime(void *unused __unu > > * Get entropy that may have been preloaded by loader(8) > > * and use it to pre-charge the entropy harvest queue. > > */ > > - keyfile = preload_search_by_type(RANDOM_HARVESTQ_BOOT_ENTROPY_FILE); > > + keyfile = preload_search_by_type(RANDOM_CACHED_BOOT_ENTROPY_MODULE); > > +#ifndef NO_BACKWARD_COMPATIBILITY > > + if (keyfile == NULL) > > + keyfile = preload_search_by_type(RANDOM_LEGACY_BOOT_ENTROPY_MODULE); > > +#endif > > if (keyfile != NULL) { > > data = preload_fetch_addr(keyfile); > > size = preload_fetch_size(keyfile); > > + /* skip the first bit of the stash so others like arc4 can also have some. */ > > + if (size > RANDOM_CACHED_SKIP_START) { > > + data += RANDOM_CACHED_SKIP_START; > > + size -= RANDOM_CACHED_SKIP_START; > > + } > > /* Trim the size. If the admin has a file with a funny size, we lose some. Tough. */ > > size -= (size % sizeof(event.he_entropy)); > > if (data != NULL && size != 0) { > > > > Modified: head/sys/dev/random/random_harvestq.h > > ============================================================================== > > --- head/sys/dev/random/random_harvestq.h Sun Apr 16 09:00:10 2017 (r317014) > > +++ head/sys/dev/random/random_harvestq.h Sun Apr 16 09:11:02 2017 (r317015) > > @@ -1,5 +1,5 @@ > > /*- > > - * Copyright (c) 2013-2015 Mark R V Murray > > + * Copyright (c) 2013-2015, 2017 Mark R V Murray > > * All rights reserved. > > * > > * Redistribution and use in source and binary forms, with or without > > @@ -45,8 +45,6 @@ struct harvest_event { > > > > void read_rate_increment(u_int); > > > > -#define RANDOM_HARVESTQ_BOOT_ENTROPY_FILE "/boot/entropy" > > - > > #define RANDOM_HARVEST_INIT_LOCK(x) mtx_init(&harvest_context.hc_mtx, "entropy harvest mutex", NULL, MTX_SPIN) > > #define RANDOM_HARVEST_LOCK(x) mtx_lock_spin(&harvest_context.hc_mtx) > > #define RANDOM_HARVEST_UNLOCK(x) mtx_unlock_spin(&harvest_context.hc_mtx) > > > > Modified: head/sys/libkern/arc4random.c > > ============================================================================== > > --- head/sys/libkern/arc4random.c Sun Apr 16 09:00:10 2017 (r317014) > > +++ head/sys/libkern/arc4random.c Sun Apr 16 09:11:02 2017 (r317015) > > @@ -1,11 +1,28 @@ > > /*- > > - * THE BEER-WARE LICENSE > > + * Copyright (c) 2017 The FreeBSD Foundation > > + * All rights reserved. > > * > > - * wrote this file. As long as you retain this notice you > > - * can do whatever you want with this stuff. If we meet some day, and you > > - * think this stuff is worth it, you can buy me a beer in return. > > + * Redistribution and use in source and binary forms, with or without > > + * modification, are permitted provided that the following conditions > > + * are met: > > + * 1. Redistributions of source code must retain the above copyright > > + * notice, this list of conditions and the following disclaimer > > + * in this position and unchanged. > > + * 2. Redistributions in binary form must reproduce the above copyright > > + * notice, this list of conditions and the following disclaimer in the > > + * documentation and/or other materials provided with the distribution. > > + * > > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > > + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > > + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > > + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > > + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > > + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > > * > > - * Dan Moschuk > > */ > > > > #include > > @@ -14,144 +31,122 @@ __FBSDID("$FreeBSD$"); > > #include > > #include > > #include > > -#include > > #include > > +#include > > #include > > +#include > > #include > > -#include > > +#include > > #include > > -#include > > +#include > > + > > +#include > > > > -#define ARC4_RESEED_BYTES 65536 > > -#define ARC4_RESEED_SECONDS 300 > > -#define ARC4_KEYBYTES 256 > > +#define CHACHA20_RESEED_BYTES 65536 > > +#define CHACHA20_RESEED_SECONDS 300 > > +#define CHACHA20_KEYBYTES 32 > > +#define CHACHA20_BUFFER_SIZE 64 > > + > > +CTASSERT(CHACHA20_KEYBYTES*8 >= CHACHA_MINKEYLEN); > > > > int arc4rand_iniseed_state = ARC4_ENTR_NONE; > > > > -MALLOC_DEFINE(M_ARC4RANDOM, "arc4random", "arc4random structures"); > > +MALLOC_DEFINE(M_CHACHA20RANDOM, "chacha20random", "chacha20random structures"); > > > > -struct arc4_s { > > +struct chacha20_s { > > struct mtx mtx; > > - u_int8_t i, j; > > - int numruns; > > - u_int8_t sbox[256]; > > + int numbytes; > > + int first_time_done; > > time_t t_reseed; > > - > > + u_int8_t m_buffer[CHACHA20_BUFFER_SIZE]; > > + struct chacha_ctx ctx; > > } __aligned(CACHE_LINE_SIZE); > > > > -static struct arc4_s *arc4inst = NULL; > > +static struct chacha20_s *chacha20inst = NULL; > > > > -#define ARC4_FOREACH(_arc4) \ > > - for (_arc4 = &arc4inst[0]; _arc4 <= &arc4inst[mp_maxid]; _arc4++) > > - > > -static u_int8_t arc4_randbyte(struct arc4_s *arc4); > > - > > -static __inline void > > -arc4_swap(u_int8_t *a, u_int8_t *b) > > -{ > > - u_int8_t c; > > - > > - c = *a; > > - *a = *b; > > - *b = c; > > -} > > +#define CHACHA20_FOREACH(_chacha20) \ > > + for (_chacha20 = &chacha20inst[0]; \ > > + _chacha20 <= &chacha20inst[mp_maxid]; \ > > + _chacha20++) > > > > /* > > - * Stir our S-box. > > + * Mix up the current context. > > */ > > static void > > -arc4_randomstir(struct arc4_s* arc4) > > +chacha20_randomstir(struct chacha20_s* chacha20) > > { > > - u_int8_t key[ARC4_KEYBYTES]; > > - int n; > > struct timeval tv_now; > > + size_t n, size; > > + u_int8_t key[CHACHA20_KEYBYTES], *data; > > + caddr_t keyfile; > > > > /* > > - * XXX: FIX!! This isn't brilliant. Need more confidence. > > - * This returns zero entropy before random(4) is seeded. > > + * This is making the best of what may be an insecure > > + * Situation. If the loader(8) did not have an entropy > > + * stash from the previous shutdown to load, then we will > > + * be improperly seeded. The answer is to make sure there > > + * is an entropy stash at shutdown time. > > */ > > - (void)read_random(key, ARC4_KEYBYTES); > > - getmicrouptime(&tv_now); > > - mtx_lock(&arc4->mtx); > > - for (n = 0; n < 256; n++) { > > - arc4->j = (arc4->j + arc4->sbox[n] + key[n]) % 256; > > - arc4_swap(&arc4->sbox[n], &arc4->sbox[arc4->j]); > > + (void)read_random(key, CHACHA20_KEYBYTES); > > + if (!chacha20->first_time_done) { > > + keyfile = preload_search_by_type(RANDOM_CACHED_BOOT_ENTROPY_MODULE); > > + if (keyfile != NULL) { > > + data = preload_fetch_addr(keyfile); > > + size = MIN(preload_fetch_size(keyfile), CHACHA20_KEYBYTES); > > + for (n = 0; n < size; n++) > > + key[n] ^= data[n]; > > + explicit_bzero(data, size); > > + if (bootverbose) > > + printf("arc4random: read %zu bytes from preloaded cache\n", size); > > + } else > > + printf("arc4random: no preloaded entropy cache\n"); > > + chacha20->first_time_done = 1; > > } > > - arc4->i = arc4->j = 0; > > + getmicrouptime(&tv_now); > > + mtx_lock(&chacha20->mtx); > > + chacha_keysetup(&chacha20->ctx, key, CHACHA20_KEYBYTES*8); > > + chacha_ivsetup(&chacha20->ctx, (u_char *)&tv_now.tv_sec, (u_char *)&tv_now.tv_usec); > > /* Reset for next reseed cycle. */ > > - arc4->t_reseed = tv_now.tv_sec + ARC4_RESEED_SECONDS; > > - arc4->numruns = 0; > > - /* > > - * Throw away the first N words of output, as suggested in the > > - * paper "Weaknesses in the Key Scheduling Algorithm of RC4" > > - * by Fluher, Mantin, and Shamir. (N = 768 in our case.) > > - * > > - * http://dl.acm.org/citation.cfm?id=646557.694759 > > - */ > > - for (n = 0; n < 768*4; n++) > > - arc4_randbyte(arc4); > > - > > - mtx_unlock(&arc4->mtx); > > + chacha20->t_reseed = tv_now.tv_sec + CHACHA20_RESEED_SECONDS; > > + chacha20->numbytes = 0; > > + mtx_unlock(&chacha20->mtx); > > } > > > > /* > > - * Initialize our S-box to its beginning defaults. > > + * Initialize the contexts. > > */ > > static void > > -arc4_init(void) > > +chacha20_init(void) > > { > > - struct arc4_s *arc4; > > - int n; > > - > > - arc4inst = malloc((mp_maxid + 1) * sizeof(struct arc4_s), > > - M_ARC4RANDOM, M_NOWAIT | M_ZERO); > > - KASSERT(arc4inst != NULL, ("arc4_init: memory allocation error")); > > + struct chacha20_s *chacha20; > > > > - ARC4_FOREACH(arc4) { > > - mtx_init(&arc4->mtx, "arc4_mtx", NULL, MTX_DEF); > > - > > - arc4->i = arc4->j = 0; > > - for (n = 0; n < 256; n++) > > - arc4->sbox[n] = (u_int8_t) n; > > - > > - arc4->t_reseed = -1; > > - arc4->numruns = 0; > > + chacha20inst = malloc((mp_maxid + 1) * sizeof(struct chacha20_s), > > + M_CHACHA20RANDOM, M_NOWAIT | M_ZERO); > > + KASSERT(chacha20inst != NULL, ("chacha20_init: memory allocation error")); > > + > > + CHACHA20_FOREACH(chacha20) { > > + mtx_init(&chacha20->mtx, "chacha20_mtx", NULL, MTX_DEF); > > + chacha20->t_reseed = -1; > > + chacha20->numbytes = 0; > > + chacha20->first_time_done = 0; > > + explicit_bzero(chacha20->m_buffer, CHACHA20_BUFFER_SIZE); > > + explicit_bzero(&chacha20->ctx, sizeof(chacha20->ctx)); > > } > > } > > -SYSINIT(arc4, SI_SUB_LOCK, SI_ORDER_ANY, arc4_init, NULL); > > +SYSINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_init, NULL); > > > > > > static void > > -arc4_uninit(void) > > +chacha20_uninit(void) > > { > > - struct arc4_s *arc4; > > + struct chacha20_s *chacha20; > > > > - ARC4_FOREACH(arc4) { > > - mtx_destroy(&arc4->mtx); > > - } > > - > > - free(arc4inst, M_ARC4RANDOM); > > + CHACHA20_FOREACH(chacha20) > > + mtx_destroy(&chacha20->mtx); > > + free(chacha20inst, M_CHACHA20RANDOM); > > } > > +SYSUNINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_uninit, NULL); > > > > -SYSUNINIT(arc4, SI_SUB_LOCK, SI_ORDER_ANY, arc4_uninit, NULL); > > - > > - > > -/* > > - * Generate a random byte. > > - */ > > -static u_int8_t > > -arc4_randbyte(struct arc4_s *arc4) > > -{ > > - u_int8_t arc4_t; > > - > > - arc4->i = (arc4->i + 1) % 256; > > - arc4->j = (arc4->j + arc4->sbox[arc4->i]) % 256; > > - > > - arc4_swap(&arc4->sbox[arc4->i], &arc4->sbox[arc4->j]); > > - > > - arc4_t = (arc4->sbox[arc4->i] + arc4->sbox[arc4->j]) % 256; > > - return arc4->sbox[arc4_t]; > > -} > > > > /* > > * MPSAFE > > @@ -159,28 +154,36 @@ arc4_randbyte(struct arc4_s *arc4) > > void > > arc4rand(void *ptr, u_int len, int reseed) > > { > > - u_char *p; > > + struct chacha20_s *chacha20; > > struct timeval tv; > > - struct arc4_s *arc4; > > + u_int length; > > + u_int8_t *p; > > > > - if (reseed || atomic_cmpset_int(&arc4rand_iniseed_state, > > - ARC4_ENTR_HAVE, ARC4_ENTR_SEED)) { > > - ARC4_FOREACH(arc4) > > - arc4_randomstir(arc4); > > - } > > + if (reseed || atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_HAVE, ARC4_ENTR_SEED)) > > + CHACHA20_FOREACH(chacha20) > > + chacha20_randomstir(chacha20); > > > > - arc4 = &arc4inst[curcpu]; > > + chacha20 = &chacha20inst[curcpu]; > > getmicrouptime(&tv); > > - if ((arc4->numruns > ARC4_RESEED_BYTES) || > > - (tv.tv_sec > arc4->t_reseed)) > > - arc4_randomstir(arc4); > > + /* We may get unlucky and be migrated off this CPU, but that is expected to be infrequent */ > > + if ((chacha20->numbytes > CHACHA20_RESEED_BYTES) || (tv.tv_sec > chacha20->t_reseed)) > > + chacha20_randomstir(chacha20); > > > > - mtx_lock(&arc4->mtx); > > - arc4->numruns += len; > > + mtx_lock(&chacha20->mtx); > > p = ptr; > > - while (len--) > > - *p++ = arc4_randbyte(arc4); > > - mtx_unlock(&arc4->mtx); > > + while (len) { > > + length = MIN(CHACHA20_BUFFER_SIZE, len); > > + chacha_encrypt_bytes(&chacha20->ctx, chacha20->m_buffer, p, length); > > + p += length; > > + len -= length; > > + chacha20->numbytes += length; > > + if (chacha20->numbytes > CHACHA20_RESEED_BYTES) { > > + mtx_unlock(&chacha20->mtx); > > + chacha20_randomstir(chacha20); > > + mtx_lock(&chacha20->mtx); > > + } > > + } > > + mtx_unlock(&chacha20->mtx); > > } > > > > uint32_t > > @@ -188,6 +191,13 @@ arc4random(void) > > { > > uint32_t ret; > > > > - arc4rand(&ret, sizeof ret, 0); > > + arc4rand(&ret, sizeof(ret), 0); > > return ret; > > } > > + > > +void > > +arc4random_buf(void *ptr, size_t len) > > +{ > > + > > + arc4rand(ptr, len, 0); > > +} > > > > Modified: head/sys/sys/libkern.h > > ============================================================================== > > --- head/sys/sys/libkern.h Sun Apr 16 09:00:10 2017 (r317014) > > +++ head/sys/sys/libkern.h Sun Apr 16 09:11:02 2017 (r317015) > > @@ -117,7 +117,8 @@ extern int arc4rand_iniseed_state; > > /* Prototypes for non-quad routines. */ > > struct malloc_type; > > uint32_t arc4random(void); > > -void arc4rand(void *ptr, u_int len, int reseed); > > +void arc4random_buf(void *, size_t); > > +void arc4rand(void *, u_int, int); > > int bcmp(const void *, const void *, size_t); > > int timingsafe_bcmp(const void *, const void *, size_t); > > void *bsearch(const void *, const void *, size_t, > > > > Modified: head/sys/sys/random.h > > ============================================================================== > > --- head/sys/sys/random.h Sun Apr 16 09:00:10 2017 (r317014) > > +++ head/sys/sys/random.h Sun Apr 16 09:11:02 2017 (r317015) > > @@ -1,5 +1,5 @@ > > /*- > > - * Copyright (c) 2000-2015 Mark R. V. Murray > > + * Copyright (c) 2000-2015, 2017 Mark R. V. Murray > > * All rights reserved. > > * > > * Redistribution and use in source and binary forms, with or without > > @@ -96,6 +96,10 @@ enum random_entropy_source { > > > > #define RANDOM_HARVEST_EVERYTHING_MASK ((1 << (RANDOM_ENVIRONMENTAL_END + 1)) - 1) > > > > +#define RANDOM_LEGACY_BOOT_ENTROPY_MODULE "/boot/entropy" > > +#define RANDOM_CACHED_BOOT_ENTROPY_MODULE "boot_entropy_cache" > > +#define RANDOM_CACHED_SKIP_START 256 > > + > > #if defined(DEV_RANDOM) > > void random_harvest_queue(const void *, u_int, u_int, enum random_entropy_source); > > void random_harvest_fast(const void *, u_int, u_int, enum random_entropy_source); > > > > -- > Mark R V Murray > > > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Sun Apr 16 11:58:54 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 741EDD411EE; Sun, 16 Apr 2017 11:58:54 +0000 (UTC) (envelope-from markm@FreeBSD.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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 441F71A4C; Sun, 16 Apr 2017 11:58:54 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from graveyard.grondar.org ([88.96.155.33] helo=gronkulator.grondar.org) by gromit.grondar.org with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1czipN-000Pzb-RD; Sun, 16 Apr 2017 12:58:51 +0100 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys From: Mark R V Murray In-Reply-To: <201704161150.v3GBohYF016403@pdx.rh.CN85.dnsmgr.net> Date: Sun, 16 Apr 2017 12:58:49 +0100 Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <8814F883-F255-45E4-8FFE-254359B51B38@FreeBSD.org> References: <201704161150.v3GBohYF016403@pdx.rh.CN85.dnsmgr.net> To: rgrimes@freebsd.org X-Mailer: Apple Mail (2.3273) X-SA-Score: -1.0 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 11:58:54 -0000 > On 16 Apr 2017, at 12:50, Rodney W. Grimes = wrote: >=20 >> This does not use DES' Chacha20 commit, as I had already completed = the >> testing for it, and received SO@ approval. >>=20 >> DES's commit made Chaha20 a module. This is of no use to = arc4random(9), >> which needs the code to be standard. Also his API is different. >>=20 >> I have no objection to reworking the arc4random/Chacha below to use = DES' >> version of Chacha, but his code needs to be standard library code, >> not an optional module. >>=20 >> Any objections to me doing this? >=20 > Yes >=20 > We need to move towards more modules, not less. Having this standard > does not even allow one to compile a kernel without it. I should be > able to compile a kernel without arc4random(9) and without chacha if > I so desire. And I should be able to load and unload these if I so > desire. This later feature is VERY usefull for developement and > debug cycles. =46rom replacing the rc4 algorithm with chacha20, this chalice has now become poisoned with the job of redesigning the entire structure of kernel random-number generation. This may take a while, and I'm already behind on RNG jobs. > I am sure with careful though we can find a way to allow arc4random > to use a pointer that knows if the chacha code is avaliable, and use > it if so, and if not fall back to something else, or punt with an > error return. Error return is out of the question; arc4random() is pretty fundamental. The alternative is to return no or fake random numbers, which rather misses the point of what this is for. But it can be done. M --=20 Mark R V Murray From owner-svn-src-all@freebsd.org Sun Apr 16 12:07:37 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D692BD41A6E; Sun, 16 Apr 2017 12:07:37 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A1E80329; Sun, 16 Apr 2017 12:07:37 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id v3GC7aqW016486; Sun, 16 Apr 2017 05:07:36 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id v3GC7adp016485; Sun, 16 Apr 2017 05:07:36 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201704161207.v3GC7adp016485@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys In-Reply-To: <8814F883-F255-45E4-8FFE-254359B51B38@FreeBSD.org> To: Mark R V Murray Date: Sun, 16 Apr 2017 05:07:36 -0700 (PDT) CC: rgrimes@FreeBSD.org, src-committers , svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Reply-To: rgrimes@FreeBSD.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 12:07:37 -0000 > > > On 16 Apr 2017, at 12:50, Rodney W. Grimes wrote: > > > >> This does not use DES' Chacha20 commit, as I had already completed the > >> testing for it, and received SO@ approval. > >> > >> DES's commit made Chaha20 a module. This is of no use to arc4random(9), > >> which needs the code to be standard. Also his API is different. > >> > >> I have no objection to reworking the arc4random/Chacha below to use DES' > >> version of Chacha, but his code needs to be standard library code, > >> not an optional module. > >> > >> Any objections to me doing this? > > > > Yes > > > > We need to move towards more modules, not less. Having this standard > > does not even allow one to compile a kernel without it. I should be > > able to compile a kernel without arc4random(9) and without chacha if > > I so desire. And I should be able to load and unload these if I so > > desire. This later feature is VERY usefull for developement and > > debug cycles. > > >From replacing the rc4 algorithm with chacha20, this chalice has now > become poisoned with the job of redesigning the entire structure of > kernel random-number generation. > > This may take a while, and I'm already behind on RNG jobs. I do not see how this is a complete redesign of RNG, and if it is such a heart ache to change algorithms in this code then it probably should be redesigned? Also you can always compile in a module, you can not compile out a 'standard' file. For now could you just add options chacha #Required by arc4random, do not remove to your kernel and move on? For me this would be an acceptable developement, even releasable, way to proceed while the more complex issue of how to make the kernel RNG use plagable lkm lower layers. > > I am sure with careful though we can find a way to allow arc4random > > to use a pointer that knows if the chacha code is avaliable, and use > > it if so, and if not fall back to something else, or punt with an > > error return. > > Error return is out of the question; arc4random() is pretty fundamental. > The alternative is to return no or fake random numbers, which rather > misses the point of what this is for. But it can be done. Arc4random works today without chacha, why would adding support for chache as an optional loadable function break that? *truely confused* -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Sun Apr 16 12:13:25 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A52ACD41C7D; Sun, 16 Apr 2017 12:13:25 +0000 (UTC) (envelope-from markm@FreeBSD.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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 753FA9F3; Sun, 16 Apr 2017 12:13:25 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from graveyard.grondar.org ([88.96.155.33] helo=gronkulator.grondar.org) by gromit.grondar.org with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1czj3S-000Q0o-Nf; Sun, 16 Apr 2017 13:13:24 +0100 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys From: Mark R V Murray In-Reply-To: <201704161207.v3GC7adp016485@pdx.rh.CN85.dnsmgr.net> Date: Sun, 16 Apr 2017 13:13:22 +0100 Cc: src-committers , svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Content-Transfer-Encoding: quoted-printable Message-Id: <60A59E27-47CD-4552-8265-0E60C09E1966@FreeBSD.org> References: <201704161207.v3GC7adp016485@pdx.rh.CN85.dnsmgr.net> To: rgrimes@FreeBSD.org X-Mailer: Apple Mail (2.3273) X-SA-Score: -1.0 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 12:13:25 -0000 > On 16 Apr 2017, at 13:07, Rodney W. Grimes = wrote: >=20 >>> =46rom replacing the rc4 algorithm with chacha20, this chalice has = now >> become poisoned with the job of redesigning the entire structure of >> kernel random-number generation. >>=20 >> This may take a while, and I'm already behind on RNG jobs. >=20 > I do not see how this is a complete redesign of RNG, and if it is > such a heart ache to change algorithms in this code then it probably > should be redesigned? The RC4 algorithm is standard. Making the alogorithm pluggable means = more code, more testing and more time (time which I am rather short of). > Also you can always compile in a module, you can not compile out > a 'standard' file. >=20 > For now could you just add > options chacha #Required by arc4random, do not remove > to your kernel and move on? For me this would be an acceptable > developement, even releasable, way to proceed while the more > complex issue of how to make the kernel RNG use plagable lkm > lower layers. It would have to be unconditionally added to *all* kernels. Could be done, I guess. RC4 has been standard for many years. >>> I am sure with careful though we can find a way to allow arc4random >>> to use a pointer that knows if the chacha code is avaliable, and use >>> it if so, and if not fall back to something else, or punt with an >>> error return. >>=20 >> Error return is out of the question; arc4random() is pretty = fundamental. >> The alternative is to return no or fake random numbers, which rather >> misses the point of what this is for. But it can be done. >=20 > Arc4random works today without chacha, why would adding support for = chache > as an optional loadable function break that? *truely confused* Up until now, arc4random worked with unconditional RC4. M --=20 Mark R V Murray From owner-svn-src-all@freebsd.org Sun Apr 16 06:04:36 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E0EF3D40566; Sun, 16 Apr 2017 06:04:36 +0000 (UTC) (envelope-from ohartmann@walstatt.org) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 30A5179; Sun, 16 Apr 2017 06:04:35 +0000 (UTC) (envelope-from ohartmann@walstatt.org) Received: from thor.intern.walstatt.dynvpn.de ([85.179.171.81]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MgKoE-1ceH8O3FPa-00NjfY; Sun, 16 Apr 2017 07:58:50 +0200 Date: Sun, 16 Apr 2017 07:58:48 +0200 From: "O. Hartmann" To: Larry Rosenman Cc: Maxim Sobolev , "O. Hartmann" , Peter Wemm , src-committers , , Hiroki Sato , Hiren Panchasara , , "Ngie Cooper (yaneurabeya)" Subject: Re: svn commit: r316874 - head/sys/kern Message-ID: <20170416075848.1e8276d9@thor.intern.walstatt.dynvpn.de> In-Reply-To: <04DD11C2-A001-49C8-A91F-7B4119CAD16A@lerctr.org> References: <201704141723.v3EHNS3B043902@repo.freebsd.org> <2109294.KVn8xeR1jZ@overcee.wemm.org> <11221477.gRA6BXfcIE@overcee.wemm.org> <5B7F917E-EA2A-4DB4-B032-48BBBEDD7556@lerctr.org> <20170415174533.3dd6349a@thor.intern.walstatt.dynvpn.de> <04DD11C2-A001-49C8-A91F-7B4119CAD16A@lerctr.org> Organization: WALSTATT User-Agent: OutScare 3.1415926 X-Operating-System: ImNotAnOperatingSystem 3.141592527 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/hifUn5PV7VuBmUo6+jSG6a3"; protocol="application/pgp-signature" X-Provags-ID: V03:K0:tpQar7Wja/ZLNCFF154DenzT9fVitMlp5SkVsV2PDe9iE9YvrnB H74yAdfUZChALClHQwn24XzIy2WyicfYFwKz2h/RFmhXc2XMXOdCKQFrmAq4GFHwYfw7BQu dBPK67y+SViukVIZNkotcJVvkdIAo+23OQgBQKg9WpQeKWeCiuJGn6LE2cKa7uDxTC3PkMU lPoOnefCWp2JO1dnOuciQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:Pk5dAYR+OnI=:tG3EgutISmyfo7ZLxCEiK8 wpjWovvhMs4KYz9sYrPinlcJ5gfbFjAvrPiX02vUFiaC+PScMRNCEBxxUIkbtyjGnA9LGv57r fS0V8lgrF3pCmu3nmiH9Fo+D3ULc5avKDDer04obP8m1oSD4XPg6PQr0EasXXZfF0QsO489V5 XuyRrDu74IXYbBpk3l+GOyf4mFeyQn5WXyRxw4jdMezkNAP9JvWuM5d+pAsnt969raBnU/nZY caI+nprjH0NCtxZj67fzirt2olGom52slu6lvsLkxQx0e2HnYLjdvWOawwAkIdH2UZLkzEgfj d+ucoDwWAmOUbv/KBp+A+nglemiQ+FOnZjUBQiJ0ZprMVFRAFlDWuU1gsY7qUh0Eb2Gos7+9Z f1YIEcp104Vdcu2NMf1qukw9Wm8Zq+SbbFOHCDlI7+YDsSCBeTlmDHIVVvbsRAvNn7xDNUbfr H/ThXWeiggf6Acq4qWleIWBrLC3MQmYAtTf2CTQPHYl9zEe6nf+8SkItX4rRF6lypWbK3qAwR Qe3fTXX8JnmiYjoFHjVAvjPOJpLoHekXRKG4TvlUEQfnlOuUyV2wJLju0lYBBz10TcVdYwWKZ /fSJ/8WJkM9tiOgQO1YPl+CyeIUKvL6mYUlQ/nGCryAu7/XFKg+XarUICEpxQ0WgzlZZN3ju1 ZzYQWct6ujfyo9mXX2MiA7JhF3PVWTs7RKCCfpW9XT1i8zvQI8mfdZa3PmZ+NDw9pAt0qzSUY KAtSyQjEKXvD2zy1p9EwVERkMPv9Q06qldSq+vM4bU8aWiON8EsHhX0FJoc= X-Mailman-Approved-At: Sun, 16 Apr 2017 12:16:10 +0000 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 06:04:37 -0000 --Sig_/hifUn5PV7VuBmUo6+jSG6a3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Am Sat, 15 Apr 2017 14:22:57 -0500 Larry Rosenman schrieb: > This looks MUCH better, startup was it=E2=80=99s usual speedy self. >=20 > =20 >=20 > =20 >=20 ... same here with FreeBSD 12.0-CURRENT #23 r316999: Sun Apr 16 07:28:14 CE= ST 2017 amd64. Systems boot as usual again - speedy and reliable. Regards, Oliver --=20 O. Hartmann Ich widerspreche der Nutzung oder =C3=9Cbermittlung meiner Daten f=C3=BCr Werbezwecke oder f=C3=BCr die Markt- oder Meinungsforschung (=C2=A7 28 Abs.= 4 BDSG). --Sig_/hifUn5PV7VuBmUo6+jSG6a3 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iLUEARMKAB0WIQQZVZMzAtwC2T/86TrS528fyFhYlAUCWPMIGAAKCRDS528fyFhY lBW1AgCJ3Zdzu4EV2U96VC9AjEjQLSQhSmh0BW7yhasPMxs0xrx3VndBQeNeGljO TXZzge8Tz7Je25br9NhcrZBBbdNsAf0T+iU5M6WlP177yiN7eelHS/phLKghdi0J F6+QW9V9D5b1tOezJOFFx8p6LqRd9TftEdDmD/vwZDHe98kKjugO =49hn -----END PGP SIGNATURE----- --Sig_/hifUn5PV7VuBmUo6+jSG6a3-- From owner-svn-src-all@freebsd.org Sun Apr 16 12:30:58 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39FEAD3F148; Sun, 16 Apr 2017 12:30:58 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E176F10A7; Sun, 16 Apr 2017 12:30:57 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id v3GCUulQ016579; Sun, 16 Apr 2017 05:30:56 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id v3GCUujl016578; Sun, 16 Apr 2017 05:30:56 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201704161230.v3GCUujl016578@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys In-Reply-To: <60A59E27-47CD-4552-8265-0E60C09E1966@FreeBSD.org> To: Mark R V Murray Date: Sun, 16 Apr 2017 05:30:56 -0700 (PDT) CC: rgrimes@freebsd.org, src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 12:30:58 -0000 > > > On 16 Apr 2017, at 13:07, Rodney W. Grimes wrote: > > > >>> From replacing the rc4 algorithm with chacha20, this chalice has now > >> become poisoned with the job of redesigning the entire structure of > >> kernel random-number generation. > >> > >> This may take a while, and I'm already behind on RNG jobs. > > > > I do not see how this is a complete redesign of RNG, and if it is > > such a heart ache to change algorithms in this code then it probably > > should be redesigned? > > The RC4 algorithm is standard. Making the alogorithm pluggable means more > code, more testing and more time (time which I am rather short of). I would rather see a proper implementation later, than a poor design decision today. > > Also you can always compile in a module, you can not compile out > > a 'standard' file. > > > > For now could you just add > > options chacha #Required by arc4random, do not remove > > to your kernel and move on? For me this would be an acceptable > > developement, even releasable, way to proceed while the more > > complex issue of how to make the kernel RNG use plagable lkm > > lower layers. > > It would have to be unconditionally added to *all* kernels. Could be > done, I guess. We dont have that many in base kernel configs do we? > RC4 has been standard for many years. Probably another rapid mode of design rather than a thoughful mode, we have a chance to correct this here, and imho, should. > >>> I am sure with careful though we can find a way to allow arc4random > >>> to use a pointer that knows if the chacha code is avaliable, and use > >>> it if so, and if not fall back to something else, or punt with an > >>> error return. > >> > >> Error return is out of the question; arc4random() is pretty fundamental. > >> The alternative is to return no or fake random numbers, which rather > >> misses the point of what this is for. But it can be done. > > > > Arc4random works today without chacha, why would adding support for chache > > as an optional loadable function break that? *truely confused* > > Up until now, arc4random worked with unconditional RC4. And your wanting to just replace unconditional RC4 for unconditional chacha? Or actuall, aleady did? -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Sun Apr 16 12:45:56 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6AE1BD3F5A3; Sun, 16 Apr 2017 12:45:56 +0000 (UTC) (envelope-from markm@FreeBSD.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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A61E1994; Sun, 16 Apr 2017 12:45:56 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from graveyard.grondar.org ([88.96.155.33] helo=gronkulator.grondar.org) by gromit.grondar.org with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1czjYv-00003H-98; Sun, 16 Apr 2017 13:45:54 +0100 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys From: Mark R V Murray In-Reply-To: <201704161230.v3GCUujl016578@pdx.rh.CN85.dnsmgr.net> Date: Sun, 16 Apr 2017 13:45:52 +0100 Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <201704161230.v3GCUujl016578@pdx.rh.CN85.dnsmgr.net> To: rgrimes@freebsd.org X-Mailer: Apple Mail (2.3273) X-SA-Score: -1.0 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 12:45:56 -0000 > On 16 Apr 2017, at 13:30, Rodney W. Grimes = wrote: >=20 >> The RC4 algorithm is standard. Making the alogorithm pluggable means = more >> code, more testing and more time (time which I am rather short of). >=20 > I would rather see a proper implementation later, than a poor design > decision today. I would love to see a perfect solution too. As I don't have the time for = it, I took the time to get a working solution reviewed and pretty heavily = tested. Reviewed by SO@, that is. >>> Also you can always compile in a module, you can not compile out >>> a 'standard' file. >>>=20 >>> For now could you just add >>> options chacha #Required by arc4random, do not remove >>> to your kernel and move on? For me this would be an acceptable >>> developement, even releasable, way to proceed while the more >>> complex issue of how to make the kernel RNG use plagable lkm >>> lower layers. >>=20 >> It would have to be unconditionally added to *all* kernels. Could be >> done, I guess. >=20 > We dont have that many in base kernel configs do we? No. But what about folks' own configs that break all-of-a-sudden? I've been pretty angry n a few occasions when I'm trying to fix my own = problems and I had to waste time sorting out tangential, avoidable problems. What's the difference between making this 'standard' in sys/files/conf and adding a compulsory change to ALL kernel files (apart from the fact that we miss the users' kernel configs)? We can even keep the module stubs in the code. Later, when/if arc4random(9) becomes a = loadable module (I'd *LOVE* to see how we get that right without compromising the RNG early start), we can make it optional. That is a one line change to sys/conf/files. >> RC4 has been standard for many years. > Probably another rapid mode of design rather than a thoughful mode, we > have a chance to correct this here, and imho, should. Fix it, sure. What's wrong with doing that as a next step? Why does this change need to be held to ransom? >> Up until now, arc4random worked with unconditional RC4. >=20 > And your wanting to just replace unconditional RC4 for unconditional = chacha? > Or actuall, aleady did? Correct. Both counts. It was up on Phabricator for weeks, BTW. M --=20 Mark R V Murray From owner-svn-src-all@freebsd.org Sun Apr 16 14:21:48 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9C0AD40471; Sun, 16 Apr 2017 14:21:48 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D8C2BC6; Sun, 16 Apr 2017 14:21:48 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id v3GELkpj017001; Sun, 16 Apr 2017 07:21:46 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id v3GELk3U017000; Sun, 16 Apr 2017 07:21:46 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201704161421.v3GELk3U017000@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys In-Reply-To: To: Mark R V Murray Date: Sun, 16 Apr 2017 07:21:46 -0700 (PDT) CC: rgrimes@FreeBSD.org, src-committers , svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Reply-To: rgrimes@FreeBSD.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 14:21:48 -0000 > > On 16 Apr 2017, at 13:30, Rodney W. Grimes wrote: > > > >> The RC4 algorithm is standard. Making the alogorithm pluggable means more > >> code, more testing and more time (time which I am rather short of). > > > > I would rather see a proper implementation later, than a poor design > > decision today. > > I would love to see a perfect solution too. As I don't have the time for it, > I took the time to get a working solution reviewed and pretty heavily tested. > Reviewed by SO@, that is. > > >>> Also you can always compile in a module, you can not compile out > >>> a 'standard' file. > >>> > >>> For now could you just add > >>> options chacha #Required by arc4random, do not remove > >>> to your kernel and move on? For me this would be an acceptable > >>> developement, even releasable, way to proceed while the more > >>> complex issue of how to make the kernel RNG use plagable lkm > >>> lower layers. > >> > >> It would have to be unconditionally added to *all* kernels. Could be > >> done, I guess. > > > > We dont have that many in base kernel configs do we? > > No. But what about folks' own configs that break all-of-a-sudden? I've > been pretty angry n a few occasions when I'm trying to fix my own problems > and I had to waste time sorting out tangential, avoidable problems. Fair point. I have spent the last 4 months dealing with what are the un portability of the human to a new version of FreeBSD due to breakage and changes in the new version, not to mention all the new features that broke old behavior in sometimes very subtle ways. > > What's the difference between making this 'standard' in sys/files/conf > and adding a compulsory change to ALL kernel files (apart from the fact > that we miss the users' kernel configs)? We can even keep the > module stubs in the code. Later, when/if arc4random(9) becomes a loadable > module (I'd *LOVE* to see how we get that right without compromising > the RNG early start), we can make it optional. That is a one line change > to sys/conf/files. Later never seems to happen.... thats why I am trying to push for stopping the later mode of operation and pushing the if we are going to change things we should be changing them in the right and for the better and stop rushing so we can only do it over again later. As far as getting things right at boot time, thats trivial, the module *can* be loaded by the loader afterall, this is not new science. We have similiar with ZFS, you have to load that with your kernel if you are booting with zfs root, correct? > >> RC4 has been standard for many years. > > Probably another rapid mode of design rather than a thoughful mode, we > > have a chance to correct this here, and imho, should. > > Fix it, sure. What's wrong with doing that as a next step? Why does this > change need to be held to ransom? Thats a fair point, let me counter, why do I want this change at all? Is it just the new kid on the block and everyone wants to play with the new toy, or does it bring the users some wonderful star bright feature that they just can not live without? Is arc4random(9) some how fundementaly broken without chacha? Your code in and working now? We just have 2 implementations of chacha, correct? One in your static compiled in kernel section, and one as an LKM? > >> Up until now, arc4random worked with unconditional RC4. > > > > And your wanting to just replace unconditional RC4 for unconditional chacha? > > Or actuall, aleady did? > > Correct. Both counts. It was up on Phabricator for weeks, BTW. We are having what I believe is a very serious disjoint in project communications caused by phabricator. How are the developers notified of new things going up in phabricator? I get bugzilla reports, but I get zip from phabriactor unless I go ask it for stuff. I get #network stuff cause I saw that in a commit that I would of liked to been aware of early and added into that project, but overall I think we need to work on this communcations too. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Sun Apr 16 14:26:50 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23263D4057B; Sun, 16 Apr 2017 14:26:50 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B594FF0D; Sun, 16 Apr 2017 14:26:49 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wr0-f173.google.com with SMTP id l28so71895257wre.0; Sun, 16 Apr 2017 07:26:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=9Ksgs0OygMb9MAZWTbagFj2BzrQnVpA+xvHyOyzBviM=; b=NhYrMFc2+6XwwsXbpVzmcYL1mGKBlUfgIAS5qOQh9LRq7E7W6k1yZd2V96Nt6Rqc/N kNwEDYa6+vryIyS1cAZlGpHwuYy7U76Jb/4U8uDx17wKhEu/Z65+MQ7+yuhyNThge0ez /ytVFY1S/gTjxCb6ih02KnkaNC0Rn3CdyMSkpBdFUpLFXJI0w3xBZ3H6JW6YEb7G4xej Q0GSyE/iZZGNdbU1YzuGy88h7a6DkV/PiYO+v1FtdAL9UgbGSXogsf9+XIuNIZvipnWK 1/6dr9wUwIw+yoDbjwV3rjk9M8D4qIQKIAHuQcbqSoUfxQxKNPSkHfxyml09xqSbmh1d rxCA== X-Gm-Message-State: AN3rC/7fDa17tmSE4HJxwBkfttydgZXXtF+5zwTRqmByPe8fpOTwYyyA kb7K+f2lZu1zmPC3RsM= X-Received: by 10.223.153.18 with SMTP id x18mr14748368wrb.55.1492352802123; Sun, 16 Apr 2017 07:26:42 -0700 (PDT) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com. [74.125.82.52]) by smtp.gmail.com with ESMTPSA id a10sm10480363wra.17.2017.04.16.07.26.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Apr 2017 07:26:42 -0700 (PDT) Received: by mail-wm0-f52.google.com with SMTP id t189so19729795wmt.1; Sun, 16 Apr 2017 07:26:42 -0700 (PDT) X-Received: by 10.28.130.210 with SMTP id e201mr5558461wmd.128.1492352801866; Sun, 16 Apr 2017 07:26:41 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.80.169.4 with HTTP; Sun, 16 Apr 2017 07:26:41 -0700 (PDT) In-Reply-To: References: <201704160911.v3G9B3df023095@repo.freebsd.org> From: Conrad Meyer Date: Sun, 16 Apr 2017 07:26:41 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys To: Mark R V Murray Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 14:26:50 -0000 On Sun, Apr 16, 2017 at 2:19 AM, Mark R V Murray wrote: > This does not use DES' Chacha20 commit, as I had already completed the > testing for it, and received SO@ approval. > > DES's commit made Chaha20 a module. This is of no use to arc4random(9), > which needs the code to be standard. Also his API is different. > > I have no objection to reworking the arc4random/Chacha below to use DES' > version of Chacha, but his code needs to be standard library code, > not an optional module. > > Any objections to me doing this? Hi Mark, I think you've taken the only sane approach possible here. arc4random cannot be loadable, and it needs a standard cipher. RC4 is undesirable because large parts of its early keystream are predictable and it is anticipated to have other weaknesses. I doubt Chacha comes out to much in the way of object code, and removing RC4 should subsidize even that number. From AMD64: chacha20.ko is 7 kB. Furthermore, I do not believe you should be harangued into rewriting how RNG use works in the kernel just to allow Chacha to be loadable. And if it is "loadable," so what? You can't boot without it; what good does a mandatory loadable module do? So: * I believe you've taken the right approach. But somehow your import of chacha should be reconciled with DES' import (i.e., keep only one copy in the tree). * I don't believe the chacha code being standard is an undue burden. Especially balanced by kicking out RC4. Thanks for doing this work. Best, Conrad From owner-svn-src-all@freebsd.org Sun Apr 16 14:35:07 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D49ED4087F; Sun, 16 Apr 2017 14:35:07 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C007613E1; Sun, 16 Apr 2017 14:35:06 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wm0-f52.google.com with SMTP id t189so19795290wmt.1; Sun, 16 Apr 2017 07:35:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=B2TE4rt6LN4dYoBSUl675EsqCxU7JuDknvJagLNSqHg=; b=S5HJA1LrVEpQdubACbm4jT04F2X+/frCTSj6SHU288G3J63AYWaPwM5r0vKvzQoo81 QRhmYhBdFTPaUBYe02Xre8Kh1y/C4G0Q3kYDlE0K9kVptaYk7BWAvZ1x8aHMt5mv8NJu 7ZQVzKbSZhrf1V9g9k2b23KRRjVYvL7m50jDbX4nOcAjE0nLlSikjXzaUo4hYrHCp78T k8WunItSdmurzlzAEVHp9XmKYktNsuDlju3N6mt5jiGZEugzR+Gc2mDfFp2ilRmRVOHw Ra3P54/sXKRBLb++ileqQnhobo3O98jQ5e42B0ihxL5gYa0qCVukUmWyO7l0bE6NKpuF F6yw== X-Gm-Message-State: AN3rC/7COCLs9KwP6iQ3/DuMJDgsCJriFKtJsSKAdCXNqnGm3ffcjbWK m4WWaIEdnBbp18TSQqM= X-Received: by 10.28.181.69 with SMTP id e66mr5585659wmf.33.1492353298911; Sun, 16 Apr 2017 07:34:58 -0700 (PDT) Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com. [209.85.128.171]) by smtp.gmail.com with ESMTPSA id u206sm6644995wmg.20.2017.04.16.07.34.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Apr 2017 07:34:58 -0700 (PDT) Received: by mail-wr0-f171.google.com with SMTP id z109so72052405wrb.1; Sun, 16 Apr 2017 07:34:58 -0700 (PDT) X-Received: by 10.223.181.132 with SMTP id c4mr7223758wre.178.1492353298651; Sun, 16 Apr 2017 07:34:58 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.80.169.4 with HTTP; Sun, 16 Apr 2017 07:34:58 -0700 (PDT) In-Reply-To: References: <201704160911.v3G9B3df023095@repo.freebsd.org> From: Conrad Meyer Date: Sun, 16 Apr 2017 07:34:58 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys To: Mark R V Murray Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 14:35:07 -0000 Furthmore: chacha20.ko: 7 kB GENERIC w/out chacha20: 27095416 GENERIC w/ chacha20: 27097976 device chacha20 adds 2560 *bytes* to the kernel. That's +0.009%. Not worth bikeshedding about. Best, Conrad On Sun, Apr 16, 2017 at 7:26 AM, Conrad Meyer wrote: > On Sun, Apr 16, 2017 at 2:19 AM, Mark R V Murray wrote: >> This does not use DES' Chacha20 commit, as I had already completed the >> testing for it, and received SO@ approval. >> >> DES's commit made Chaha20 a module. This is of no use to arc4random(9), >> which needs the code to be standard. Also his API is different. >> >> I have no objection to reworking the arc4random/Chacha below to use DES' >> version of Chacha, but his code needs to be standard library code, >> not an optional module. >> >> Any objections to me doing this? > > Hi Mark, > > I think you've taken the only sane approach possible here. arc4random > cannot be loadable, and it needs a standard cipher. RC4 is > undesirable because large parts of its early keystream are predictable > and it is anticipated to have other weaknesses. > > I doubt Chacha comes out to much in the way of object code, and > removing RC4 should subsidize even that number. From AMD64: > chacha20.ko is 7 kB. > > Furthermore, I do not believe you should be harangued into rewriting > how RNG use works in the kernel just to allow Chacha to be loadable. > And if it is "loadable," so what? You can't boot without it; what > good does a mandatory loadable module do? > > So: > > * I believe you've taken the right approach. But somehow your import > of chacha should be reconciled with DES' import (i.e., keep only one > copy in the tree). > * I don't believe the chacha code being standard is an undue burden. > Especially balanced by kicking out RC4. > > Thanks for doing this work. > > Best, > Conrad From owner-svn-src-all@freebsd.org Sun Apr 16 14:36:37 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31634D40945; Sun, 16 Apr 2017 14:36:37 +0000 (UTC) (envelope-from markm@FreeBSD.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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0065F15B5; Sun, 16 Apr 2017 14:36:36 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from graveyard.grondar.org ([88.96.155.33] helo=gronkulator.grondar.org) by gromit.grondar.org with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1czlHx-00008M-Br; Sun, 16 Apr 2017 15:36:34 +0100 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys From: Mark R V Murray In-Reply-To: <201704161421.v3GELk3U017000@pdx.rh.CN85.dnsmgr.net> Date: Sun, 16 Apr 2017 15:36:28 +0100 Cc: src-committers , svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <201704161421.v3GELk3U017000@pdx.rh.CN85.dnsmgr.net> To: rgrimes@FreeBSD.org X-Mailer: Apple Mail (2.3273) X-SA-Score: -1.0 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 14:36:37 -0000 > On 16 Apr 2017, at 15:21, Rodney W. Grimes = wrote: >>>> RC4 has been standard for many years. >>> Probably another rapid mode of design rather than a thoughful mode, = we >>> have a chance to correct this here, and imho, should. >>=20 >> Fix it, sure. What's wrong with doing that as a next step? Why does = this >> change need to be held to ransom? >=20 > Thats a fair point, let me counter, why do I want this change at all? RC4 is broken cryptographically. FreeBSD was lagging behind in still = using it. > Is it just the new kid on the block and everyone wants to play with = the > new toy, or does it bring the users some wonderful star bright feature > that they just can not live without? Is arc4random(9) some how = fundementaly > broken without chacha? Most folks won't notice a darn thing. Crap random numbers are very often hard to tell apart from good ones, and if you are not depending on them = in a relevant way you won't notice anything. The big deal is that the attack vector for folks counting on (broken) RC4 is now gone. For most FreeBSD users this is theoretical interest = only. > Your code in and working now?=20 Yes. > We just have 2 implementations of chacha, correct? Correct. > One in your static compiled in kernel section, and one as an LKM? Correct. The latter startled me when it arrived. >>>> Up until now, arc4random worked with unconditional RC4. >>>=20 >>> And your wanting to just replace unconditional RC4 for unconditional = chacha? >>> Or actuall, aleady did? >>=20 >> Correct. Both counts. It was up on Phabricator for weeks, BTW. >=20 > We are having what I believe is a very serious disjoint in project = communications > caused by phabricator. How are the developers notified of new things = going > up in phabricator? I get bugzilla reports, but I get zip from = phabriactor unless > I go ask it for stuff. I get #network stuff cause I saw that in a = commit that > I would of liked to been aware of early and added into that project, = but overall > I think we need to work on this communcations too. True. I promised SO@ that I would get all my CSPRNG stuff reviewed in = Phabricator before committing it. All the folks who in the past have cared about my = work now are on the relevant watch-list. Apart from spamming everyone, what do = you suggest? M --=20 Mark R V Murray= From owner-svn-src-all@freebsd.org Sun Apr 16 15:45:13 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ACD80D4195E for ; Sun, 16 Apr 2017 15:45:13 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm3-vm2.bullet.mail.ne1.yahoo.com (nm3-vm2.bullet.mail.ne1.yahoo.com [98.138.91.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 69B311717 for ; Sun, 16 Apr 2017 15:45:13 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1492357145; bh=X008d3r9vM8Ij5Jg8yGVpEnCd9r10cdj3yCVi0hOMl8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=O5sSkBeZcZ6Joa6RRTfiP0U8RqWGT/BSd8bKVr5qOSmksQA+CAMLVJXVc12C3xRLmlRWXOc2Jr6CiZEuYewij6jNN+ChE+Bz9FDmPsq7ealnowR9pSxc5YXMrGUzUggBFfmYH7+y2Qcm8MrYKGF5WTmprfs1zjC4K9G21QtzXJXfQoFBqm3gvsdWDVbOtgv3Azn/LIY6Xs2ocjwxDmmg/j63EO8chQqLHRBZXNk0O0zeCcTFTg9MxkDqKWk+1rxx68GF8xWwQgyJwC4T66deVQrNkH/BZgOkLWthgU23YqE2RawqLSMQmXAbie9+GO7e9ESig6lgV8gSt/ma+gC+gA== Received: from [98.138.100.118] by nm3.bullet.mail.ne1.yahoo.com with NNFMP; 16 Apr 2017 15:39:05 -0000 Received: from [98.138.226.58] by tm109.bullet.mail.ne1.yahoo.com with NNFMP; 16 Apr 2017 15:39:05 -0000 Received: from [127.0.0.1] by smtp209.mail.ne1.yahoo.com with NNFMP; 16 Apr 2017 15:39:05 -0000 X-Yahoo-Newman-Id: 509997.86581.bm@smtp209.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 4o47AJwVM1kfsZUloGBLKQ92J2HC8OCyYsSQY8CE_nyQeoJ _erDlPWQtH_VLBe46CYilj25juTIe49_0bXIInAM.MZyQW20UAlzSx0LfoWz lvWwHGJex9C.mr7fnxVlKNzlyBzexymCt7cDFo7zpSYDKzEP1uRAjHQr2VDO qjhmkVf0gb7.aLiZNavYvnQzN5Wn.aJqAAa98ANp8wI1PeeAdayDSEQSSyMt dKqJ_Yp6m5tWq879ZU5d2_4K9q8yhCzEJ9QpE3zD6._itBr0Xccvfod1brFv TWN4p.4T.fyxLxvMO2bllWMU3tXIUaiUqdyOfkbI7ApKDh68e4YCeGEFglBb tiLktWcaiL82wZAAC4kFg8uOweFeCZA48UZYVAaZOYI5AHBF7PM4f1GitN4a HwK4fCZApIx8BXhtcELgDZv9exWKur7Vyx4fJHtPfMeeiHaCFvU5C1ViIcdY UNOPuOUjz68eLVI7eR45VDAQTxV9OsnbEyJcdPAyrlMeGpAEY6jX9BPYpMuu aMss9YfgIcjRqyQ3S6ONpvNhcDdCXh2i1RnAE2NtKF_yH X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r317015 - in head/sys: boot/forth conf crypto/chacha20 dev/random libkern sys To: cem@freebsd.org, Mark R V Murray Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201704160911.v3G9B3df023095@repo.freebsd.org> From: Pedro Giffuni Organization: FreeBSD Message-ID: Date: Sun, 16 Apr 2017 10:36:51 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 15:45:13 -0000 On 04/16/17 09:26, Conrad Meyer wrote: > On Sun, Apr 16, 2017 at 2:19 AM, Mark R V Murray wrote: >> This does not use DES' Chacha20 commit, as I had already completed the >> testing for it, and received SO@ approval. >> >> DES's commit made Chaha20 a module. This is of no use to arc4random(9), >> which needs the code to be standard. Also his API is different. >> >> I have no objection to reworking the arc4random/Chacha below to use DES' >> version of Chacha, but his code needs to be standard library code, >> not an optional module. >> >> Any objections to me doing this? > Hi Mark, > > I think you've taken the only sane approach possible here. arc4random > cannot be loadable, and it needs a standard cipher. RC4 is > undesirable because large parts of its early keystream are predictable > and it is anticipated to have other weaknesses. > > I doubt Chacha comes out to much in the way of object code, and > removing RC4 should subsidize even that number. From AMD64: > chacha20.ko is 7 kB. > > Furthermore, I do not believe you should be harangued into rewriting > how RNG use works in the kernel just to allow Chacha to be loadable. > And if it is "loadable," so what? You can't boot without it; what > good does a mandatory loadable module do? FWIW, I would think the major advantage of making Chacha a module would be making us cipher-agnostic. The end user doesn't need to know what cypher is being used. It would still be mandatory to use *a* cypher and chacha20 would be the default. This said, I am fine with markm's approach and, not that it matters, in most "sane" jurisdictions Public Domain is less restricted than 3-Clause BSD. Pedro. From owner-svn-src-all@freebsd.org Sun Apr 16 16:01:30 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 144CCD41EA1; Sun, 16 Apr 2017 16:01:30 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 CA55F1E00; Sun, 16 Apr 2017 16:01:28 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3GG1Scn096020; Sun, 16 Apr 2017 16:01:28 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3GG1QIx096002; Sun, 16 Apr 2017 16:01:26 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201704161601.v3GG1QIx096002@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 16 Apr 2017 16:01:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r317017 - in vendor/llvm/dist: . bindings/go/llvm cmake cmake/modules cmake/platforms docs docs/CommandGuide docs/Proposals docs/TableGen docs/tutorial examples/BrainF examples/Fibonacc... X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Apr 2017 16:01:30 -0000 Author: dim Date: Sun Apr 16 16:01:22 2017 New Revision: 317017 URL: https://svnweb.freebsd.org/changeset/base/317017 Log: Vendor import of llvm trunk r300422: https://llvm.org/svn/llvm-project/llvm/trunk@300422 Added: vendor/llvm/dist/docs/XRayExample.rst vendor/llvm/dist/include/llvm/ADT/BreadthFirstIterator.h (contents, props changed) vendor/llvm/dist/include/llvm/Analysis/MemorySSA.h (contents, props changed) vendor/llvm/dist/include/llvm/Analysis/MemorySSAUpdater.h (contents, props changed) vendor/llvm/dist/include/llvm/Analysis/ObjectUtils.h (contents, props changed) vendor/llvm/dist/include/llvm/CodeGen/ExecutionDepsFix.h (contents, props changed) vendor/llvm/dist/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h (contents, props changed) vendor/llvm/dist/include/llvm/CodeGen/LiveRegUnits.h (contents, props changed) vendor/llvm/dist/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/CodeView/Formatters.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/CodeView/TypeServerHandler.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/DWARF/DWARFAttribute.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/ vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/DbiStream.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/EnumTables.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/Formatters.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/Hash.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/HashTable.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/InfoStream.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/ModInfo.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/ModInfoBuilder.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/ModStream.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/NativeEnumModules.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/NativeSession.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/PDBFile.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/PublicsStream.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/RawConstants.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/RawError.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/RawTypes.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/StringTable.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/StringTableBuilder.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/SymbolStream.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/TpiHashing.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/TpiStream.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h (contents, props changed) vendor/llvm/dist/include/llvm/DebugInfo/PDB/UDTLayout.h (contents, props changed) vendor/llvm/dist/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h (contents, props changed) vendor/llvm/dist/include/llvm/MC/MCAsmInfoWasm.h (contents, props changed) vendor/llvm/dist/include/llvm/MC/MCSectionWasm.h (contents, props changed) vendor/llvm/dist/include/llvm/MC/MCSymbolWasm.h (contents, props changed) vendor/llvm/dist/include/llvm/MC/MCWasmObjectWriter.h (contents, props changed) vendor/llvm/dist/include/llvm/MC/MCWasmStreamer.h (contents, props changed) vendor/llvm/dist/include/llvm/Object/IRSymtab.h (contents, props changed) vendor/llvm/dist/include/llvm/ObjectYAML/DWARFEmitter.h (contents, props changed) vendor/llvm/dist/include/llvm/ObjectYAML/WasmYAML.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/ARMAttributeParser.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/BinaryByteStream.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/BinaryItemStream.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/BinaryStream.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/BinaryStreamArray.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/BinaryStreamError.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/BinaryStreamReader.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/BinaryStreamRef.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/BinaryStreamWriter.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/CMakeLists.txt (contents, props changed) vendor/llvm/dist/include/llvm/Support/DebugCounter.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/LowLevelTypeImpl.h (contents, props changed) vendor/llvm/dist/include/llvm/Support/WasmRelocs/ vendor/llvm/dist/include/llvm/Support/WasmRelocs/WebAssembly.def vendor/llvm/dist/include/llvm/Target/GlobalISel/ vendor/llvm/dist/include/llvm/Target/GlobalISel/RegisterBank.td vendor/llvm/dist/include/llvm/Target/GlobalISel/SelectionDAGCompat.td vendor/llvm/dist/include/llvm/Target/GlobalISel/Target.td vendor/llvm/dist/include/llvm/Transforms/IPO/ArgumentPromotion.h (contents, props changed) vendor/llvm/dist/include/llvm/Transforms/Scalar/LoopLoadElimination.h (contents, props changed) vendor/llvm/dist/include/llvm/Transforms/Scalar/LoopPredication.h (contents, props changed) vendor/llvm/dist/include/llvm/Transforms/Scalar/LoopSink.h (contents, props changed) vendor/llvm/dist/include/llvm/Transforms/Utils/LowerMemIntrinsics.h (contents, props changed) vendor/llvm/dist/include/llvm/Transforms/Utils/PredicateInfo.h (contents, props changed) vendor/llvm/dist/include/llvm/Transforms/Utils/VNCoercion.h (contents, props changed) vendor/llvm/dist/include/llvm/XRay/Graph.h (contents, props changed) vendor/llvm/dist/include/llvm/XRay/InstrumentationMap.h (contents, props changed) vendor/llvm/dist/lib/Analysis/MemorySSA.cpp (contents, props changed) vendor/llvm/dist/lib/Analysis/MemorySSAUpdater.cpp (contents, props changed) vendor/llvm/dist/lib/CodeGen/BranchCoalescing.cpp (contents, props changed) vendor/llvm/dist/lib/CodeGen/FEntryInserter.cpp (contents, props changed) vendor/llvm/dist/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp (contents, props changed) vendor/llvm/dist/lib/CodeGen/LiveRegUnits.cpp (contents, props changed) vendor/llvm/dist/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp (contents, props changed) vendor/llvm/dist/lib/CodeGen/MachineOutliner.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/CodeView/Formatters.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/CodeView/SymbolSerializer.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/ vendor/llvm/dist/lib/DebugInfo/PDB/Native/DbiStream.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/EnumTables.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/GSI.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/GSI.h (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/GlobalsStream.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/Hash.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/HashTable.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/InfoStream.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/ModInfo.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/ModInfoBuilder.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/ModStream.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/NativeSession.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/PDBFile.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/PublicsStream.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/RawError.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/StringTable.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/SymbolStream.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/TpiHashing.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/TpiStream.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp (contents, props changed) vendor/llvm/dist/lib/DebugInfo/PDB/UDTLayout.cpp (contents, props changed) vendor/llvm/dist/lib/ExecutionEngine/Orc/RPCUtils.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/FuzzerExtFunctionsDlsymWin.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/FuzzerExtraCounters.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/FuzzerShmem.h (contents, props changed) vendor/llvm/dist/lib/Fuzzer/FuzzerShmemPosix.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/FuzzerShmemWindows.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/BadStrcmpTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/BogusInitializeTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/CustomCrossOverAndMutateTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/CxxStringEqTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/EquivalenceATest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/EquivalenceBTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/LargeTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/Memcmp64BytesTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/NotinstrumentedTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/SingleByteInputTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/TableLookupTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/TwoDifferentBugsTest.cpp (contents, props changed) vendor/llvm/dist/lib/Fuzzer/test/bad-strcmp.test vendor/llvm/dist/lib/Fuzzer/test/cxxstring.test vendor/llvm/dist/lib/Fuzzer/test/disable-leaks.test vendor/llvm/dist/lib/Fuzzer/test/equivalence-signals.test vendor/llvm/dist/lib/Fuzzer/test/equivalence.test vendor/llvm/dist/lib/Fuzzer/test/extra-counters.test vendor/llvm/dist/lib/Fuzzer/test/fuzzer-customcrossoverandmutate.test vendor/llvm/dist/lib/Fuzzer/test/merge-posix.test vendor/llvm/dist/lib/Fuzzer/test/merge-summary.test vendor/llvm/dist/lib/Fuzzer/test/minimize_two_crashes.test vendor/llvm/dist/lib/Fuzzer/test/trace-malloc-2.test vendor/llvm/dist/lib/Fuzzer/test/trace-pc.test vendor/llvm/dist/lib/Fuzzer/test/trace-pc/CMakeLists.txt (contents, props changed) vendor/llvm/dist/lib/MC/MCAsmInfoWasm.cpp (contents, props changed) vendor/llvm/dist/lib/MC/MCSectionWasm.cpp (contents, props changed) vendor/llvm/dist/lib/MC/MCWasmObjectTargetWriter.cpp (contents, props changed) vendor/llvm/dist/lib/MC/MCWasmStreamer.cpp (contents, props changed) vendor/llvm/dist/lib/MC/WasmObjectWriter.cpp (contents, props changed) vendor/llvm/dist/lib/Object/IRSymtab.cpp (contents, props changed) vendor/llvm/dist/lib/ObjectYAML/DWARFEmitter.cpp (contents, props changed) vendor/llvm/dist/lib/ObjectYAML/DWARFVisitor.cpp (contents, props changed) vendor/llvm/dist/lib/ObjectYAML/DWARFVisitor.h (contents, props changed) vendor/llvm/dist/lib/ObjectYAML/WasmYAML.cpp (contents, props changed) vendor/llvm/dist/lib/Support/ARMAttributeParser.cpp (contents, props changed) vendor/llvm/dist/lib/Support/BinaryStreamError.cpp (contents, props changed) vendor/llvm/dist/lib/Support/BinaryStreamReader.cpp (contents, props changed) vendor/llvm/dist/lib/Support/BinaryStreamWriter.cpp (contents, props changed) vendor/llvm/dist/lib/Support/DebugCounter.cpp (contents, props changed) vendor/llvm/dist/lib/Support/LowLevelType.cpp (contents, props changed) vendor/llvm/dist/lib/Support/Unix/Threading.inc (contents, props changed) vendor/llvm/dist/lib/Support/Windows/Threading.inc (contents, props changed) vendor/llvm/dist/lib/Target/AArch64/AArch64MacroFusion.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AArch64/AArch64MacroFusion.h (contents, props changed) vendor/llvm/dist/lib/Target/AArch64/AArch64RegisterBanks.td vendor/llvm/dist/lib/Target/AArch64/AArch64SchedFalkorDetails.td vendor/llvm/dist/lib/Target/AArch64/AArch64SchedFalkorWriteRes.td vendor/llvm/dist/lib/Target/AArch64/AArch64SchedThunderX.td vendor/llvm/dist/lib/Target/AArch64/AArch64SchedThunderX2T99.td vendor/llvm/dist/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def vendor/llvm/dist/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPUInstructionSelector.h (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPULegalizerInfo.h (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPULowerIntrinsics.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/AMDGPURegisterBanks.td vendor/llvm/dist/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/GCNIterativeScheduler.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/GCNIterativeScheduler.h (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/GCNMinRegStrategy.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/GCNRegPressure.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/GCNRegPressure.h (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadata.h (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadataStreamer.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadataStreamer.h (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/SIFixVGPRCopies.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/SIInsertWaitcnts.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/SIPeepholeSDWA.cpp (contents, props changed) vendor/llvm/dist/lib/Target/AMDGPU/VOP3PInstructions.td vendor/llvm/dist/lib/Target/ARM/ARMRegisterBanks.td vendor/llvm/dist/lib/Target/Hexagon/HexagonDepArch.h (contents, props changed) vendor/llvm/dist/lib/Target/Hexagon/HexagonDepArch.td vendor/llvm/dist/lib/Target/Hexagon/HexagonDepDecoders.h (contents, props changed) vendor/llvm/dist/lib/Target/Hexagon/HexagonDepITypes.h (contents, props changed) vendor/llvm/dist/lib/Target/Hexagon/HexagonDepITypes.td vendor/llvm/dist/lib/Target/Hexagon/HexagonDepInstrFormats.td vendor/llvm/dist/lib/Target/Hexagon/HexagonDepInstrInfo.td vendor/llvm/dist/lib/Target/Hexagon/HexagonDepMappings.td vendor/llvm/dist/lib/Target/Hexagon/HexagonDepOperands.td vendor/llvm/dist/lib/Target/Hexagon/HexagonIICHVX.td vendor/llvm/dist/lib/Target/Hexagon/HexagonIICScalar.td vendor/llvm/dist/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp (contents, props changed) vendor/llvm/dist/lib/Target/Hexagon/HexagonMapAsm2IntrinV62.gen.td vendor/llvm/dist/lib/Target/Hexagon/HexagonPseudo.td vendor/llvm/dist/lib/Target/Hexagon/HexagonScheduleV62.td vendor/llvm/dist/lib/Target/Hexagon/RDFRegisters.cpp (contents, props changed) vendor/llvm/dist/lib/Target/Hexagon/RDFRegisters.h (contents, props changed) vendor/llvm/dist/lib/Target/PowerPC/PPCExpandISEL.cpp (contents, props changed) vendor/llvm/dist/lib/Target/WebAssembly/MC