Skip to content

Conversation

@DavidSpickett
Copy link
Collaborator

@DavidSpickett DavidSpickett commented Jul 29, 2025

These entries serve the same purpose as the Linux HWCAPs but have been assigned different numbers as FreeBSD had already used the Linux ones.

The numbers were assigned in:
freebsd/freebsd-src@8500787

In theory we can read these for the purposes of register field detection, even on earlier versions of FreeBSD. As the aux data is a key-value structure, we simply won't find the new numbers on older systems.

However, FreeBSD has not defined any feature bits for HWACP3 and 4. It is likley that they will match the Linux feature bits, but I have no proof of that yet.

For instance, FEAT_MTE_STORE_ONLY is indicated by a HWCAP3 feature bit on Linux. FreeBSD does not support this feature at all yet.

So for now, these values exist for future use and are not used for register field detection on FreeBSD.

These entries serve the same purpose as the Linux HWCAPs but
have been assigned different numbers as FreeBSD had already used
the Linux ones.

The numbers were assigned in:
freebsd/freebsd-src@8500787

In theory we can read these for the purposes of register field detection,
even on earlier versions of FreeBSD. As the aux data is a key-value
structure, we simply won't find the new numbers on older systems.

However, FreeBSD has not defined any feature bits for HWACP3 and 4.
It is likley that they will match the Linux feature bits, but I have
no proof of that yet.

For instance, FEAT_MTE_STORE_ONLY is indicated by a HWCAP3 feature
bit on Linux. FreeBSD does not support this feature at all yet.

So for now, these defines exist for future use and are not used
for register field detection on FreeBSD.
@llvmbot
Copy link
Member

llvmbot commented Jul 29, 2025

@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)

Changes

These entries serve the same purpose as the Linux HWCAPs but have been assigned different numbers as FreeBSD had already used the Linux ones.

The numbers were assigned in:
freebsd/freebsd-src@8500787

In theory we can read these for the purposes of register field detection, even on earlier versions of FreeBSD. As the aux data is a key-value structure, we simply won't find the new numbers on older systems.

However, FreeBSD has not defined any feature bits for HWACP3 and 4. It is likley that they will match the Linux feature bits, but I have no proof of that yet.

For instance, FEAT_MTE_STORE_ONLY is indicated by a HWCAP3 feature bit on Linux. FreeBSD does not support this feature at all yet.

So for now, these values exist for future use and are not used for register field detection on FreeBSD.


Full diff: https://github.com/llvm/llvm-project/pull/151152.diff

2 Files Affected:

  • (modified) lldb/source/Plugins/Process/Utility/AuxVector.cpp (+2)
  • (modified) lldb/source/Plugins/Process/Utility/AuxVector.h (+4)
diff --git a/lldb/source/Plugins/Process/Utility/AuxVector.cpp b/lldb/source/Plugins/Process/Utility/AuxVector.cpp
index 50500a8593e1d..d660bfea327bf 100644
--- a/lldb/source/Plugins/Process/Utility/AuxVector.cpp
+++ b/lldb/source/Plugins/Process/Utility/AuxVector.cpp
@@ -92,6 +92,8 @@ const char *AuxVector::GetEntryName(EntryType type) const {
     case ENTRY_NAME(AUXV_AT_L1D_CACHESHAPE); break;
     case ENTRY_NAME(AUXV_AT_L2_CACHESHAPE);  break;
     case ENTRY_NAME(AUXV_AT_L3_CACHESHAPE);  break;
+    case ENTRY_NAME(AUXV_FREEBSD_AT_HWCAP3);  break;
+    case ENTRY_NAME(AUXV_FREEBSD_AT_HWCAP4);  break;
     }
 #undef ENTRY_NAME
 
diff --git a/lldb/source/Plugins/Process/Utility/AuxVector.h b/lldb/source/Plugins/Process/Utility/AuxVector.h
index 7733e0ffc6832..ad6b70ef101e8 100644
--- a/lldb/source/Plugins/Process/Utility/AuxVector.h
+++ b/lldb/source/Plugins/Process/Utility/AuxVector.h
@@ -70,6 +70,10 @@ class AuxVector {
     // Platform specific values which may overlap the Linux values.
 
     AUXV_FREEBSD_AT_HWCAP = 25, ///< FreeBSD specific AT_HWCAP value.
+    // FreeBSD and Linux use the same AT_HWCAP2 value.
+    AUXV_FREEBSD_AT_HWCAP3 = 38, ///< FreeBSD specific AT_HWCAP3 value.
+    AUXV_FREEBSD_AT_HWCAP4 = 39, ///< FreeBSD specific AT_HWCAP4 value.
+
   };
 
   std::optional<uint64_t> GetAuxValue(enum EntryType entry_type) const;

Copy link
Contributor

@omjavaid omjavaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Thanks!

@DavidSpickett DavidSpickett merged commit 10d7352 into llvm:main Jul 30, 2025
11 checks passed
@DavidSpickett DavidSpickett deleted the lldb-freebsd-hwcap3 branch July 30, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants