Revert "Revert "external/boringssl: Sync to 81080a729af568f7b5fde92b9170cc17065027c9.""
This reverts commit 228bd6249d17f351ea66508b3ec3112ed1cbdf30.
Reason for revert: All fixes submitted for modules affected by the ENGINE_free API change.
Change-Id: I30fafafa13ec0a6390f4a9211fbf3122a8b4865f
diff --git a/src/crypto/cpu-intel.c b/src/crypto/cpu-intel.c
index 98d8d4e..1621ef6 100644
--- a/src/crypto/cpu-intel.c
+++ b/src/crypto/cpu-intel.c
@@ -148,6 +148,9 @@
int is_intel = ebx == 0x756e6547 /* Genu */ &&
edx == 0x49656e69 /* ineI */ &&
ecx == 0x6c65746e /* ntel */;
+ int is_amd = ebx == 0x68747541 /* Auth */ &&
+ edx == 0x69746e65 /* enti */ &&
+ ecx == 0x444d4163 /* cAMD */;
uint32_t extended_features[2] = {0};
if (num_ids >= 7) {
@@ -158,6 +161,24 @@
OPENSSL_cpuid(&eax, &ebx, &ecx, &edx, 1);
+ if (is_amd) {
+ // See https://www.amd.com/system/files/TechDocs/25481.pdf, page 10.
+ const uint32_t base_family = (eax >> 8) & 15;
+
+ uint32_t family = base_family;
+ if (base_family == 0xf) {
+ const uint32_t ext_family = (eax >> 20) & 255;
+ family += ext_family;
+ }
+
+ if (family < 0x17) {
+ // Disable RDRAND on AMD families before 0x17 (Zen) due to reported
+ // failures after suspend.
+ // https://bugzilla.redhat.com/show_bug.cgi?id=1150286
+ ecx &= ~(1u << 30);
+ }
+ }
+
// Force the hyper-threading bit so that the more conservative path is always
// chosen.
edx |= 1u << 28;