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

Validate or define ARM HWCAP2_XXX macros #2164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
33 changes: 28 additions & 5 deletions crypto/fipsmodule/cpucap/cpu_arm_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,37 @@ extern "C" {
// The cpuinfo parser lives in a header file so it may be accessible from
// cross-platform fuzzers without adding code to those platforms normally.

#define HWCAP_NEON (1 << 12)
#if defined(HWCAP_NEON) && HWCAP_NEON != 4096
#error "HWCAP_NEON is defined but has wrong value (expected 4096)"
#elif !defined(HWCAP_NEON)
#define HWCAP_NEON 4096
#endif

// See /usr/include/asm/hwcap.h on an ARM installation for the source of
// these values.
#define HWCAP2_AES (1 << 0)
#define HWCAP2_PMULL (1 << 1)
#define HWCAP2_SHA1 (1 << 2)
#define HWCAP2_SHA2 (1 << 3)
#if defined(HWCAP2_AES) && HWCAP2_AES != 1
#error "HWCAP2_AES is defined but has wrong value (expected 1)"
#elif !defined(HWCAP2_AES)
#define HWCAP2_AES 1
#endif

#if defined(HWCAP2_PMULL) && HWCAP2_PMULL != 2
#error "HWCAP2_PMULL is defined but has wrong value (expected 2)"
#elif !defined(HWCAP2_PMULL)
#define HWCAP2_PMULL 2
#endif

#if defined(HWCAP2_SHA1) && HWCAP2_SHA1 != 4
#error "HWCAP2_SHA1 is defined but has wrong value (expected 4)"
#elif !defined(HWCAP2_SHA1)
#define HWCAP2_SHA1 4
#endif

#if defined(HWCAP2_SHA2) && HWCAP2_SHA2 != 8
#error "HWCAP2_SHA2 is defined but has wrong value (expected 8)"
#elif !defined(HWCAP2_SHA2)
#define HWCAP2_SHA2 8
#endif

typedef struct {
const char *data;
Expand Down
Loading