-
Notifications
You must be signed in to change notification settings - Fork 705
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
Add MIPS support #1277
Add MIPS support #1277
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ const X86: &str = "x86"; | |
const X86_64: &str = "x86_64"; | ||
const AARCH64: &str = "aarch64"; | ||
const ARM: &str = "arm"; | ||
const MIPS: &str = "mips"; | ||
const MIPS64: &str = "mips64"; | ||
|
||
#[rustfmt::skip] | ||
const RING_SRCS: &[(&[&str], &str)] = &[ | ||
|
@@ -40,12 +42,12 @@ 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/curve25519/curve25519.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, MIPS, MIPS64, X86_64, X86], "crypto/crypto.c"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. crypto.c isn't relevant to MIPS so this should be reverted. |
||
(&[AARCH64, ARM, MIPS, MIPS64, X86_64, X86], "crypto/curve25519/curve25519.c"), | ||
(&[AARCH64, ARM, MIPS, MIPS64, X86_64, X86], "crypto/fipsmodule/ec/ecp_nistz.c"), | ||
(&[AARCH64, ARM, MIPS, MIPS64, X86_64, X86], "crypto/fipsmodule/ec/gfp_p256.c"), | ||
(&[AARCH64, ARM, MIPS, MIPS64, X86_64, X86], "crypto/fipsmodule/ec/gfp_p384.c"), | ||
(&[AARCH64, ARM, MIPS, MIPS64, X86_64, X86], "crypto/fipsmodule/ec/p256.c"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just use |
||
|
||
(&[X86_64, X86], "crypto/cpu-intel.c"), | ||
|
||
|
@@ -87,6 +89,8 @@ const RING_SRCS: &[(&[&str], &str)] = &[ | |
(&[AARCH64], "crypto/chacha/asm/chacha-armv8.pl"), | ||
(&[AARCH64], "crypto/fipsmodule/modes/asm/ghash-neon-armv8.pl"), | ||
(&[AARCH64], SHA512_ARMV8), | ||
|
||
(&[MIPS, MIPS64], "crypto/fipsmodule/bn/asm/mips-mont.pl"), | ||
]; | ||
|
||
const SHA256_X86_64: &str = "crypto/fipsmodule/sha/asm/sha256-x86_64.pl"; | ||
|
@@ -200,6 +204,20 @@ const ASM_TARGETS: &[AsmTarget] = &[ | |
asm_extension: "S", | ||
preassemble: false, | ||
}, | ||
AsmTarget { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove the |
||
oss: LINUX_ABI, | ||
arch: "mips", | ||
perlasm_format: "elf", | ||
asm_extension: "S", | ||
preassemble: false, | ||
}, | ||
AsmTarget { | ||
oss: LINUX_ABI, | ||
arch: "mips64", | ||
perlasm_format: "elf", | ||
asm_extension: "S", | ||
preassemble: false, | ||
}, | ||
AsmTarget { | ||
oss: MACOS_ABI, | ||
arch: "aarch64", | ||
|
@@ -309,6 +327,7 @@ fn ring_build_rs_main() { | |
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); | ||
let os = env::var("CARGO_CFG_TARGET_OS").unwrap(); | ||
let env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); | ||
let endian = env::var("CARGO_CFG_TARGET_ENDIAN").unwrap(); | ||
let (obj_ext, obj_opt) = if env == MSVC { | ||
(MSVC_OBJ_EXT, MSVC_OBJ_OPT) | ||
} else { | ||
|
@@ -322,6 +341,7 @@ fn ring_build_rs_main() { | |
|
||
let target = Target { | ||
arch, | ||
endian, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to store endian in the target since no big-endian targets are supported. |
||
os, | ||
env, | ||
obj_ext, | ||
|
@@ -373,6 +393,7 @@ fn pregenerate_asm_main() { | |
|
||
struct Target { | ||
arch: String, | ||
endian: String, | ||
os: String, | ||
env: String, | ||
obj_ext: &'static str, | ||
|
@@ -391,6 +412,10 @@ fn build_c_code(target: &Target, pregenerated: PathBuf, out_dir: &Path, ring_cor | |
} | ||
} | ||
|
||
if target.arch == "mips" && target.endian == "big" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for |
||
panic!("MIPS Big-Endian detected. Stoping compilation as BoringSSL code are not available for this platform"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just write "Big-endian targets are not supported yet." |
||
} | ||
|
||
let asm_target = ASM_TARGETS.iter().find(|asm_target| { | ||
asm_target.arch == target.arch && asm_target.oss.contains(&target.os.as_ref()) | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why you're trying to do it this way, but this is exactly what I'm hoping to avoid. Let's find a way to do it without bringing in any MIPS assembly code. It's just not realistic to maintain the MIPS assembly code given current constraints. I'd rather concentrate on improving the C (in the near future, Rust) code instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mostly reverse-engineering the error messages which complained about
bn_mul_mont
not existing, and I found this file defines it. I'm ok with removing it if I can figure out another way to overcome the error message.