Commit 4dbb4460 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

Revert "Revisiting auxvec data gathering for PPC/ARM."

This reverts commit f5bee002.

Reason for revert: Crashes android webview, see https://crbug.com/1071708.

Original change's description:
> Revisiting auxvec data gathering for PPC/ARM.
> 
> /proc/sys/auxv might not be accessible, instead
> getting these from the user's stack.
> 
> Change-Id: I2dcf696734e2b4dc1da27a991930b9e0d4228d51
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1730990
> Commit-Queue: Clemens Backes [né Hammacher] <clemensb@chromium.org>
> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
> Reviewed-by: Clemens Backes [né Hammacher] <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#64037}

TBR=clemensb@chromium.org,bmeurer@chromium.org,devnexen@gmail.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromium:1071708
Change-Id: I05659f245c1020e98b7225a25e82987d9955d595
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2154800Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67234}
parent bbb4c24e
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#endif #endif
#if V8_OS_LINUX #if V8_OS_LINUX
#include <linux/auxvec.h> // AT_HWCAP #include <linux/auxvec.h> // AT_HWCAP
extern "C" char** environ;
#endif #endif
#if V8_GLIBC_PREREQ(2, 16) #if V8_GLIBC_PREREQ(2, 16)
#include <sys/auxv.h> // getauxval() #include <sys/auxv.h> // getauxval()
...@@ -17,7 +16,7 @@ extern "C" char** environ; ...@@ -17,7 +16,7 @@ extern "C" char** environ;
#if V8_OS_QNX #if V8_OS_QNX
#include <sys/syspage.h> // cpuinfo #include <sys/syspage.h> // cpuinfo
#endif #endif
#if (V8_OS_LINUX && (V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64)) || V8_OS_ANDROID #if V8_OS_LINUX && (V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64)
#include <elf.h> #include <elf.h>
#endif #endif
#if V8_OS_AIX #if V8_OS_AIX
...@@ -110,25 +109,31 @@ static V8_INLINE void __cpuid(int cpu_info[4], int info_type) { ...@@ -110,25 +109,31 @@ static V8_INLINE void __cpuid(int cpu_info[4], int info_type) {
#define HWCAP_LPAE (1 << 20) #define HWCAP_LPAE (1 << 20)
static uint32_t ReadELFHWCaps() { static uint32_t ReadELFHWCaps() {
uint32_t result = 0;
#if V8_GLIBC_PREREQ(2, 16) #if V8_GLIBC_PREREQ(2, 16)
return static_cast<uint32_t>(getauxval(AT_HWCAP)); result = static_cast<uint32_t>(getauxval(AT_HWCAP));
#else
char** head = environ;
while (*head++ != nullptr) {
}
#ifdef __LP64__
using elf_auxv_t = Elf64_auxv_t;
#else #else
using elf_auxv_t = Elf32_auxv_t; // Read the ELF HWCAP flags by parsing /proc/self/auxv.
#endif FILE* fp = fopen("/proc/self/auxv", "r");
for (elf_auxv_t* entry = reinterpret_cast<elf_auxv_t*>(head); if (fp != nullptr) {
entry->a_type != AT_NULL; ++entry) { struct {
if (entry->a_type == AT_HWCAP) { uint32_t tag;
return entry->a_un.a_val; uint32_t value;
} entry;
for (;;) {
size_t n = fread(&entry, sizeof(entry), 1, fp);
if (n == 0 || (entry.tag == 0 && entry.value == 0)) {
break;
}
if (entry.tag == AT_HWCAP) {
result = entry.value;
break;
}
} }
fclose(fp);
} }
return 0u;
#endif #endif
return result;
} }
#endif // V8_HOST_ARCH_ARM #endif // V8_HOST_ARCH_ARM
...@@ -610,28 +615,33 @@ CPU::CPU() ...@@ -610,28 +615,33 @@ CPU::CPU()
#ifndef USE_SIMULATOR #ifndef USE_SIMULATOR
#if V8_OS_LINUX #if V8_OS_LINUX
// Read processor info from /proc/self/auxv.
char* auxv_cpu_type = nullptr; char* auxv_cpu_type = nullptr;
char** head = environ; FILE* fp = fopen("/proc/self/auxv", "r");
while (*head++ != nullptr) { if (fp != nullptr) {
}
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
using elf_auxv_t = Elf64_auxv_t; Elf64_auxv_t entry;
#else #else
using elf_auxv_t = Elf32_auxv_t; Elf32_auxv_t entry;
#endif #endif
for (elf_auxv_t* entry = reinterpret_cast<elf_auxv_t*>(head); for (;;) {
entry->a_type != AT_NULL; ++entry) { size_t n = fread(&entry, sizeof(entry), 1, fp);
switch (entry->a_type) { if (n == 0 || entry.a_type == AT_NULL) {
case AT_PLATFORM:
auxv_cpu_type = reinterpret_cast<char*>(entry->a_un.a_val);
break;
case AT_ICACHEBSIZE:
icache_line_size_ = entry->a_un.a_val;
break;
case AT_DCACHEBSIZE:
dcache_line_size_ = entry->a_un.a_val;
break; break;
}
switch (entry.a_type) {
case AT_PLATFORM:
auxv_cpu_type = reinterpret_cast<char*>(entry.a_un.a_val);
break;
case AT_ICACHEBSIZE:
icache_line_size_ = entry.a_un.a_val;
break;
case AT_DCACHEBSIZE:
dcache_line_size_ = entry.a_un.a_val;
break;
}
} }
fclose(fp);
} }
part_ = -1; part_ = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment