Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Jan 2021 08:36:58 +0000 (UTC)
From:      Mikael Urankar <mikael@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r561715 - head/www/zola/files
Message-ID:  <202101160836.10G8aweE085902@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mikael
Date: Sat Jan 16 08:36:58 2021
New Revision: 561715
URL: https://svnweb.freebsd.org/changeset/ports/561715

Log:
  www/zola: regen aarch64 patch

Modified:
  head/www/zola/files/patch-ring-aarch64

Modified: head/www/zola/files/patch-ring-aarch64
==============================================================================
--- head/www/zola/files/patch-ring-aarch64	Sat Jan 16 08:11:17 2021	(r561714)
+++ head/www/zola/files/patch-ring-aarch64	Sat Jan 16 08:36:58 2021	(r561715)
@@ -1,208 +1,123 @@
-From d27594754dc2257ac55070450fb96dba5a757d03 Mon Sep 17 00:00:00 2001
-From: Greg V <greg@unrelenting.technology>
-Date: Sun, 25 Aug 2019 16:54:24 +0300
-Subject: [PATCH 1/2] Fix build on aarch64 on arbitrary OS (without a feature
- detection method)
+--- cargo-crates/ring-0.16.19/Cargo.toml.orig	2021-01-16 08:59:14 UTC
++++ cargo-crates/ring-0.16.19/Cargo.toml
+@@ -62,10 +62,10 @@ wasm32_c = []
+ version = "0.3.37"
+ features = ["Crypto", "Window"]
+ default-features = false
+-[target."cfg(any(target_arch = \"x86\",target_arch = \"x86_64\", all(any(target_arch = \"aarch64\", target_arch = \"arm\"), any(target_os = \"android\", target_os = \"fuchsia\", target_os = \"linux\"))))".dependencies.spin]
++[target."cfg(any(target_arch = \"x86\",target_arch = \"x86_64\", all(any(target_arch = \"aarch64\", target_arch = \"arm\"), any(target_os = \"android\", target_os = \"freebsd\", target_os = \"fuchsia\", target_os = \"linux\"))))".dependencies.spin]
+ version = "0.5.2"
+ default-features = false
+-[target."cfg(any(target_os = \"android\", target_os = \"linux\"))".dependencies.libc]
++[target."cfg(any(target_os = \"android\", target_os = \"freebsd\", target_os = \"linux\"))".dependencies.libc]
+ version = "0.2.69"
+ default-features = false
 
-I agree to license my contributions to each file under the terms given
-at the top of each file I changed.
----
- src/cpu.rs | 18 ++++++++++++------
- 1 file changed, 12 insertions(+), 6 deletions(-)
-
-diff --git cargo-crates/ring-0.16.15/src/cpu.rs cargo-crates/ring-0.16.15/src/cpu.rs
-index 4492da391..d00ef3e76 100644
---- cargo-crates/ring-0.16.15/src/cpu.rs
-+++ cargo-crates/ring-0.16.15/src/cpu.rs
-@@ -171,10 +171,10 @@ pub(crate) mod arm {
-     #[cfg(not(target_arch = "wasm32"))]
-     pub(crate) struct Feature {
-         #[cfg_attr(
--            any(
--                target_os = "ios",
--                not(any(target_arch = "arm", target_arch = "aarch64"))
--            ),
-+            not(all(
-+                any(target_os = "android", target_os = "linux", target_os = "fuchsia"),
-+                any(target_arch = "arm", target_arch = "aarch64")
-+            )),
-             allow(dead_code)
-         )]
-         mask: u32,
-@@ -200,7 +200,10 @@ pub(crate) mod arm {
-                 return self.mask == self.mask & unsafe { GFp_armcap_P };
-             }
+--- cargo-crates/ring-0.16.19/src/cpu.rs.orig	2020-11-30 20:30:03 UTC
++++ cargo-crates/ring-0.16.19/src/cpu.rs
+@@ -31,7 +31,7 @@ pub(crate) fn features() -> Features {
+         target_arch = "x86_64",
+         all(
+             any(target_arch = "aarch64", target_arch = "arm"),
+-            any(target_os = "android", target_os = "fuchsia", target_os = "linux")
++            any(target_os = "android", target_os = "fuchsia", target_os = "freebsd", target_os = "linux")
+         )
+     ))]
+     {
+@@ -49,7 +49,7 @@ pub(crate) fn features() -> Features {
  
--            #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
-+            #[cfg(not(all(
-+                any(target_os = "android", target_os = "ios", target_os = "linux", target_os = "fuchsia"),
-+                any(target_arch = "arm", target_arch = "aarch64")
-+            )))]
+             #[cfg(all(
+                 any(target_arch = "aarch64", target_arch = "arm"),
+-                any(target_os = "android", target_os = "fuchsia", target_os = "linux")
++                any(target_os = "android", target_os = "fuchsia", target_os = "freebsd", target_os = "linux")
+             ))]
              {
-                 return false;
-             }
-@@ -208,7 +211,10 @@ pub(crate) mod arm {
-     }
+                 arm::setup();
+@@ -62,28 +62,58 @@ pub(crate) fn features() -> Features {
  
-     // Keep in sync with `ARMV7_NEON`.
--    #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
-+    #[cfg(all(
-+        any(target_os = "android", target_os = "ios", target_os = "linux", target_os = "fuchsia"),
-+        any(target_arch = "arm", target_arch = "aarch64")
-+    ))]
-     pub(crate) const NEON: Feature = Feature {
-         mask: 1 << 0,
-         ios: true,
--- 
-2.28.0
-
-From e8674734c31136678fb87e9dbaabe928d67f4aae Mon Sep 17 00:00:00 2001
-From: Greg V <greg@unrelenting.technology>
-Date: Sun, 25 Aug 2019 17:52:18 +0300
-Subject: [PATCH 2/2] Add CPU feature detection for FreeBSD/aarch64
-
-I agree to license my contributions to each file under the terms given
-at the top of each file I changed.
----
- build.rs             |  1 +
- crypto/cpu-aarch64.c | 32 ++++++++++++++++++++++++++++++++
- src/cpu.rs           | 40 ++++++++++++++++++++++++++++++++++++----
- 3 files changed, 69 insertions(+), 4 deletions(-)
- create mode 100644 crypto/cpu-aarch64.c
-
-diff --git cargo-crates/ring-0.16.15/build.rs cargo-crates/ring-0.16.15/build.rs
-index d7c8466b2..9b6580a79 100644
---- cargo-crates/ring-0.16.15/build.rs
-+++ cargo-crates/ring-0.16.15/build.rs
-@@ -68,6 +68,7 @@ const RING_SRCS: &[(&[&str], &str)] = &[
-     (&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/gfp_p384.c"),
+ pub(crate) mod arm {
+     #[cfg(all(
+-        any(target_os = "android", target_os = "linux"),
++        any(target_os = "android", target_os = "freebsd", target_os = "linux"),
+         any(target_arch = "aarch64", target_arch = "arm")
+     ))]
+     pub fn setup() {
+         use libc::c_ulong;
++        #[cfg(target_os = "freebsd")]
++        use libc::{c_int, c_void};
++        #[cfg(target_os = "freebsd")]
++        extern crate std;
  
-     (&[X86_64, X86], "crypto/cpu-intel.c"),
-+    (&[AARCH64], "crypto/cpu-aarch64.c"),
- 
-     (&[X86], "crypto/fipsmodule/aes/asm/aesni-x86.pl"),
-     (&[X86], "crypto/fipsmodule/aes/asm/vpaes-x86.pl"),
-diff --git cargo-crates/ring-0.16.15/crypto/cpu-aarch64.c cargo-crates/ring-0.16.15/crypto/cpu-aarch64.c
-new file mode 100644
-index 000000000..8bb537b78
---- /dev/null
-+++ cargo-crates/ring-0.16.15/crypto/cpu-aarch64.c
-@@ -0,0 +1,32 @@
-+// Copyright 2019 Greg V
-+//
-+// Permission to use, copy, modify, and/or distribute this software for any
-+// purpose with or without fee is hereby granted, provided that the above
-+// copyright notice and this permission notice appear in all copies.
-+//
-+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
-+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-+// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
-+// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-+// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-+
-+
-+// Run-time feature detection for aarch64 on any OS that emulates the mrs instruction.
-+//
-+// On FreeBSD >= 12.0, Linux >= 4.11 and other operating systems, it is possible to use
-+// privileged system registers from userspace to check CPU feature support.
-+//
-+// For proper support of SoCs where different cores have different capabilities
-+// the OS has to always report only the features supported by all cores, like FreeBSD does.
-+//
-+// Only FreeBSD uses this right now.
-+
-+#include <stdint.h>
-+
-+uint64_t GFp_aarch64_read_isar0(void) {
-+  uint64_t val;
-+  __asm __volatile("mrs %0, ID_AA64ISAR0_EL1" : "=&r" (val));
-+  return val;
-+}
-diff --git cargo-crates/ring-0.16.15/src/cpu.rs cargo-crates/ring-0.16.15/src/cpu.rs
-index d00ef3e76..7b7801706 100644
---- cargo-crates/ring-0.16.15/src/cpu.rs
-+++ cargo-crates/ring-0.16.15/src/cpu.rs
-@@ -60,6 +60,11 @@ pub(crate) fn features() -> Features {
-             {
-                 arm::fuchsia_setup();
-             }
-+
-+            #[cfg(all(any(target_os = "freebsd"), target_arch = "aarch64"))]
-+            {
-+                arm::aarch64_mrs_setup();
-+            }
-         });
-     }
- 
-@@ -168,11 +173,38 @@ pub(crate) mod arm {
+         // XXX: The `libc` crate doesn't provide `libc::getauxval` consistently
+         // across all Android/Linux targets, e.g. musl.
++        #[cfg(any(target_os = "android", target_os = "linux"))]
+         extern "C" {
+             fn getauxval(type_: c_ulong) -> c_ulong;
          }
-     }
  
-+    #[cfg(all(any(target_os = "freebsd"), target_arch = "aarch64"))]
-+    pub fn aarch64_mrs_setup() {
++        #[cfg(target_os = "freebsd")]
 +        extern "C" {
-+            fn GFp_aarch64_read_isar0() -> u64;
++            fn elf_aux_info(aux: c_int, buf: *mut c_void, buflen: c_int) -> c_int;
 +        }
 +
-+        #[inline]
-+        fn bits_shift(x: u64, high: usize, low: usize) -> u64 {
-+            (x >> low) & ((1 << (high - low + 1)) - 1)
-+        }
++        #[cfg(not(target_os = "freebsd"))]
+         const AT_HWCAP: c_ulong = 16;
+ 
++        #[cfg(target_os = "freebsd")]
++        const AT_HWCAP: c_int = 25;
 +
-+        let mut features = 0;
-+        let aa64isar0 = unsafe { GFp_aarch64_read_isar0() };
+         #[cfg(target_arch = "aarch64")]
+         const HWCAP_NEON: c_ulong = 1 << 1;
+ 
+         #[cfg(target_arch = "arm")]
+         const HWCAP_NEON: c_ulong = 1 << 12;
+ 
++        #[cfg(not(target_os = "freebsd"))]
+         let caps = unsafe { getauxval(AT_HWCAP) };
+ 
++        #[cfg(target_os = "freebsd")]
++        let caps: c_ulong = 0;
 +
-+        if bits_shift(aa64isar0, 7, 4) >= 1 {
-+            features |= AES.mask;
++        #[cfg(target_os = "freebsd")]
++        {
++            let buffer : *mut c_void = { let t: *const c_ulong = &caps; t} as *mut c_void;
++            unsafe {
++                let _ret = elf_aux_info(
++                    AT_HWCAP,
++                    buffer,
++                    std::mem::size_of_val(&caps) as i32
++                );
++            }
 +        }
-+        if bits_shift(aa64isar0, 7, 4) >= 2 {
-+            features |= PMULL.mask;
-+        }
-+        if bits_shift(aa64isar0, 15, 12) >= 1 {
-+            features |= 1 << 4;
-+        }
 +
-+        unsafe { GFp_armcap_P = features };
-+    }
+         // We assume NEON is available on AARCH64 because it is a required
+         // feature.
+         #[cfg(target_arch = "aarch64")]
+@@ -100,11 +130,26 @@ pub(crate) mod arm {
+             #[cfg(target_arch = "arm")]
+             const OFFSET: c_ulong = 0;
+ 
+-            #[cfg(target_arch = "arm")]
++            #[cfg(target_os = "freebsd")]
++            let buffer : *mut c_void = { let t: *const c_ulong = &caps; t} as *mut c_void;
 +
-     #[cfg(not(target_arch = "wasm32"))]
-     pub(crate) struct Feature {
-         #[cfg_attr(
-             not(all(
--                any(target_os = "android", target_os = "linux", target_os = "fuchsia"),
-+                any(target_os = "android", all(target_os = "freebsd", target_arch = "aarch64"), target_os = "linux", target_os = "fuchsia"),
-                 any(target_arch = "arm", target_arch = "aarch64")
-             )),
-             allow(dead_code)
-@@ -193,7 +225,7 @@ pub(crate) mod arm {
-             }
++            #[cfg(not(target_os = "freebsd"))]
+             let caps = {
+                 const AT_HWCAP2: c_ulong = 26;
+                 unsafe { getauxval(AT_HWCAP2) }
+             };
++
++            #[cfg(target_os = "freebsd")]
++            {
++                const AT_HWCAP2: c_int = 26;
++                unsafe {
++                    let _ret = elf_aux_info(
++                        AT_HWCAP2,
++                        buffer,
++                        std::mem::size_of_val(&caps) as i32
++                    );
++                };
++            }
  
-             #[cfg(all(
--                any(target_os = "android", target_os = "linux", target_os = "fuchsia"),
-+                any(target_os = "android", all(target_os = "freebsd", target_arch = "aarch64"), target_os = "linux", target_os = "fuchsia"),
-                 any(target_arch = "arm", target_arch = "aarch64")
-             ))]
-             {
-@@ -201,7 +233,7 @@ pub(crate) mod arm {
-             }
- 
-             #[cfg(not(all(
--                any(target_os = "android", target_os = "ios", target_os = "linux", target_os = "fuchsia"),
-+                any(target_os = "android", all(target_os = "freebsd", target_arch = "aarch64"), target_os = "ios", target_os = "linux", target_os = "fuchsia"),
-                 any(target_arch = "arm", target_arch = "aarch64")
-             )))]
-             {
-@@ -245,7 +277,7 @@ pub(crate) mod arm {
-     };
- 
-     #[cfg(all(
--        any(target_os = "android", target_os = "linux", target_os = "fuchsia"),
-+        any(target_os = "android", all(target_os = "freebsd", target_arch = "aarch64"), target_os = "linux", target_os = "fuchsia"),
-         any(target_arch = "arm", target_arch = "aarch64")
-     ))]
-     extern "C" {
--- 
-2.28.0
-
+             const HWCAP_AES: c_ulong = 1 << 0 + OFFSET;
+             const HWCAP_PMULL: c_ulong = 1 << 1 + OFFSET;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101160836.10G8aweE085902>