- Use %edi register to save/restore contents of %ebx instead of pushing
it on stack to make the code work for both 32/64-bit x86 - Make the corresponding comment more accurate while I'm at it Reported by: pkg-fallout
This commit is contained in:
parent
4614f1c06f
commit
86ecf55589
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=395648
1 changed files with 8 additions and 6 deletions
|
@ -15,7 +15,7 @@
|
|||
// Other platforms.
|
||||
#else
|
||||
|
||||
@@ -421,6 +429,384 @@ uint64 System::get_process_virtual_memor
|
||||
@@ -421,6 +429,386 @@ uint64 System::get_process_virtual_memor
|
||||
return static_cast<uint64>(rss) * sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
|
@ -43,16 +43,17 @@
|
|||
+ size_t linesize;
|
||||
+} mycaches[3];
|
||||
+
|
||||
+// %ebx may be used to store GOT (Global Offset Table) for PIC (Position
|
||||
+// Independent Code), so use %esi instead.
|
||||
+// %ebx is used to point to GOT (Global Offset Table) for PIC (Position
|
||||
+// Independent Code) on 32-bit x86, so use %edi to preserve %ebx across
|
||||
+// the call and %esi when passing CPUID arguments and return values.
|
||||
+static inline void
|
||||
+cpuid(uint32_t* data)
|
||||
+{
|
||||
+ asm("pushl %%ebx\n\t"
|
||||
+ asm("movl %%ebx, %%edi\n\t"
|
||||
+ "movl %%esi, %%ebx\n\t"
|
||||
+ "cpuid\n\t"
|
||||
+ "movl %%ebx, %%esi\n\t"
|
||||
+ "popl %%ebx"
|
||||
+ "movl %%edi, %%ebx"
|
||||
+ : "=a" (data[eax]),
|
||||
+ "=S" (data[ebx]),
|
||||
+ "=c" (data[ecx]),
|
||||
|
@ -60,7 +61,8 @@
|
|||
+ : "a" (data[eax]),
|
||||
+ "S" (data[ebx]),
|
||||
+ "c" (data[ecx]),
|
||||
+ "d" (data[edx]));
|
||||
+ "d" (data[edx])
|
||||
+ : "%edi");
|
||||
+}
|
||||
+
|
||||
+// For modern CPUs, we use Deterministic Cache Parameters (Function 04h) to
|
||||
|
|
Loading…
Reference in a new issue