Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support powerpc64-ibm-aix target #1513

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ include = [
"crypto/cipher_extra/test/aes_256_gcm_siv_tests.txt",
"crypto/constant_time_test.c",
"crypto/cpu-intel.c",
"crypto/cpu-ppc.c",
"crypto/crypto.c",
"crypto/curve25519/asm/x25519-asm-arm.S",
"crypto/curve25519/curve25519.c",
Expand All @@ -57,6 +58,8 @@ include = [
"crypto/fipsmodule/aes/asm/vpaes-x86_64.pl",
"crypto/fipsmodule/bn/asm/armv4-mont.pl",
"crypto/fipsmodule/bn/asm/armv8-mont.pl",
"crypto/fipsmodule/bn/asm/ppc-mont.pl",
"crypto/fipsmodule/bn/asm/ppc64-mont.pl",
"crypto/fipsmodule/bn/asm/x86-mont.pl",
"crypto/fipsmodule/bn/asm/x86_64-mont.pl",
"crypto/fipsmodule/bn/asm/x86_64-mont5.pl",
Expand Down Expand Up @@ -93,6 +96,7 @@ include = [
"crypto/limbs/limbs.inl",
"crypto/mem.c",
"crypto/perlasm/arm-xlate.pl",
"crypto/perlasm/ppc-xlate.pl",
"crypto/perlasm/x86asm.pl",
"crypto/perlasm/x86gas.pl",
"crypto/perlasm/x86nasm.pl",
Expand Down Expand Up @@ -171,7 +175,7 @@ spin = { version = "0.9.2", default-features = false, features = ["once"] }
libc = { version = "0.2.100", default-features = false }
once_cell = { version = "1.8.0", default-features = false, features=["std"], optional = true }

[target.'cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "illumos", target_os = "netbsd", target_os = "openbsd", target_os = "redox", target_os = "solaris"))'.dependencies]
[target.'cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "illumos", target_os = "netbsd", target_os = "openbsd", target_os = "redox", target_os = "solaris", target_os = "aix"))'.dependencies]
once_cell = { version = "1.8.0", default-features = false, features=["std"] }

[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown", target_env = ""))'.dependencies]
Expand Down
25 changes: 20 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const X86: &str = "x86";
const X86_64: &str = "x86_64";
const AARCH64: &str = "aarch64";
const ARM: &str = "arm";
const PPC64: &str = "powerpc64";
const PPC: &str = "powerpc";

#[rustfmt::skip]
const RING_SRCS: &[(&[&str], &str)] = &[
Expand All @@ -41,11 +43,11 @@ const RING_SRCS: &[(&[&str], &str)] = &[
(&[], "crypto/mem.c"),
(&[], "crypto/poly1305/poly1305.c"),

(&[AARCH64, ARM, X86_64, X86], "crypto/crypto.c"),
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/ecp_nistz.c"),
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/gfp_p256.c"),
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/gfp_p384.c"),
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/p256.c"),
(&[AARCH64, ARM, X86_64, X86, PPC64, PPC], "crypto/crypto.c"),
(&[AARCH64, ARM, X86_64, X86, PPC64, PPC], "crypto/fipsmodule/ec/ecp_nistz.c"),
(&[AARCH64, ARM, X86_64, X86, PPC64, PPC], "crypto/fipsmodule/ec/gfp_p256.c"),
(&[AARCH64, ARM, X86_64, X86, PPC64, PPC], "crypto/fipsmodule/ec/gfp_p384.c"),
(&[AARCH64, ARM, X86_64, X86, PPC64, PPC], "crypto/fipsmodule/ec/p256.c"),

(&[X86_64, X86], "crypto/cpu-intel.c"),

Expand Down Expand Up @@ -87,6 +89,10 @@ const RING_SRCS: &[(&[&str], &str)] = &[
(&[AARCH64], "crypto/chacha/asm/chacha-armv8.pl"),
(&[AARCH64], "crypto/fipsmodule/modes/asm/ghash-neon-armv8.pl"),
(&[AARCH64], SHA512_ARMV8),

(&[PPC64], "crypto/fipsmodule/bn/asm/ppc64-mont.pl"),
(&[PPC], "crypto/fipsmodule/bn/asm/ppc-mont.pl"),
(&[PPC64, PPC], "crypto/cpu-ppc.c"),
];

const SHA256_X86_64: &str = "crypto/fipsmodule/sha/asm/sha256-x86_64.pl";
Expand Down Expand Up @@ -235,6 +241,13 @@ const ASM_TARGETS: &[AsmTarget] = &[
asm_extension: "S",
preassemble: true,
},
AsmTarget {
oss: &[AIX],
arch: "powerpc64",
perlasm_format: "aix64",
asm_extension: "S",
preassemble: true,
},
];

struct AsmTarget {
Expand Down Expand Up @@ -279,6 +292,8 @@ const MACOS_ABI: &[&str] = &["ios", "macos"];

const WINDOWS: &str = "windows";

const AIX: &str = "aix";

/// Read an environment variable and tell Cargo that we depend on it.
///
/// This needs to be used for any environment variable that isn't a standard
Expand Down
38 changes: 38 additions & 0 deletions crypto/cpu-ppc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2009-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/* This file is derived from ppccap.c in OpenSSL */

#include <ring-core/cpu.h>
#include "internal.h"

int bn_mul_mont_int(unsigned long *rp, const unsigned long *ap, const unsigned long *bp,
const unsigned long *np, const unsigned long *n0, int num);
int bn_mul4x_mont_int(unsigned long *rp, const unsigned long *ap, const unsigned long *bp,
const unsigned long *np, const unsigned long *n0, int num);
int bn_mul_mont(unsigned long *rp, const unsigned long *ap, const unsigned long *bp,
const unsigned long *np, const unsigned long *n0, int num)
{
if (num < 4)
return 0;

if ((num & 3) == 0)
return bn_mul4x_mont_int(rp, ap, bp, np, n0, num);

/*
* There used to be [optional] call to bn_mul_mont_fpu64 here,
* but above subroutine is faster on contemporary processors.
* Formulation means that there might be old processors where
* FPU code path would be faster, POWER6 perhaps, but there was
* no opportunity to figure it out...
*/

return bn_mul_mont_int(rp, ap, bp, np, n0, num);
}


Loading