diff --git a/common/snapshot_proto.cc b/common/snapshot_proto.cc index 31ea8c9e..bacab626 100644 --- a/common/snapshot_proto.cc +++ b/common/snapshot_proto.cc @@ -130,6 +130,9 @@ static_assert(ToInt(PlatformId::kAmdSiena) == ToInt(proto::PlatformId::AMD_SIENA)); static_assert(ToInt(PlatformId::kAmdRyzenV3000) == ToInt(proto::PlatformId::AMD_RYZEN_V3000)); +static_assert(ToInt(PlatformId::kArmNeoverseV2) == + ToInt(proto::PlatformId::ARM_NEOVERSE_V2)); + static_assert(ToInt(kMaxPlatformId) < 64); // ========================================================================= // diff --git a/proto/snapshot.proto b/proto/snapshot.proto index 5c9e4c7a..2574dcad 100644 --- a/proto/snapshot.proto +++ b/proto/snapshot.proto @@ -164,6 +164,7 @@ enum PlatformId { INTEL_GRANITERAPIDS = 41; AMD_SIENA = 42; + ARM_NEOVERSE_V2 = 43; } // Describes a specific endstate of executing a snapshot. diff --git a/util/aarch64/platform.cc b/util/aarch64/platform.cc index 6946e290..99ca0101 100644 --- a/util/aarch64/platform.cc +++ b/util/aarch64/platform.cc @@ -25,6 +25,10 @@ namespace silifuzz { namespace { +absl::StatusOr DistinguishNeoverseV2() { + return PlatformId::kArmNeoverseV2; +} + uint64_t GetMidr() { uint64_t midr; // The kernel will trap and emulate access to MIDR_EL1. @@ -46,6 +50,15 @@ PlatformId DoCurrentPlatformId() { switch (part_number) { case 0xd0c: return PlatformId::kArmNeoverseN1; + case 0xd4f: { + auto soc_platform_id = DistinguishNeoverseV2(); + if (soc_platform_id.ok()) { + return soc_platform_id.value(); + } + LOG_ERROR("Failed to determine NeoverseV2-based CPU: ", + soc_platform_id.status()); + return PlatformId::kUndefined; + } default: LOG_ERROR("Unknown ARM part number: ", HexStr(part_number)); return PlatformId::kUndefined; @@ -55,7 +68,7 @@ PlatformId DoCurrentPlatformId() { if (part_number == 0xac3) { return PlatformId::kAmpereOne; } else { - LOG_ERROR("Unknown ARM part number: ", HexStr(part_number)); + LOG_ERROR("Unknown Ampere part number: ", HexStr(part_number)); return PlatformId::kUndefined; } } else { diff --git a/util/platform.cc b/util/platform.cc index 8973f211..47064f8b 100644 --- a/util/platform.cc +++ b/util/platform.cc @@ -40,6 +40,7 @@ ArchitectureId PlatformArchitecture(PlatformId platform) { case PlatformId::kAmdSiena: return ArchitectureId::kX86_64; case PlatformId::kArmNeoverseN1: + case PlatformId::kArmNeoverseV2: case PlatformId::kAmpereOne: return ArchitectureId::kAArch64; case PlatformId::kUndefined: diff --git a/util/platform.h b/util/platform.h index 3951c9d5..cbd5bdbe 100644 --- a/util/platform.h +++ b/util/platform.h @@ -71,10 +71,11 @@ enum class PlatformId { kIntelGraniteRapids = 41, kAmdSiena = 42, + kArmNeoverseV2 = 43, // The values below are meta-values that don't have proto::PlatformId // representation. Never persisted and can be renumbered as needed. - kAny = 43, // any platform for platform selectors - kNonExistent = 44, // for tests only + kAny = 44, // any platform for platform selectors + kNonExistent = 45, // for tests only }; // Max valid value of PlatformId, min being kUndefined. @@ -96,8 +97,8 @@ inline constexpr const char* EnumNameMap[ToInt(kMaxPlatformId) + "reserved-25", "reserved-26", "reserved-27", "reserved-28", "reserved-29", "reserved-30", "reserved-31", "reserved-32", "reserved-33", "reserved-34", "reserved-35", "reserved-36", "reserved-37", "reserved-38", "reserved-39", - "reserved-40", "intel-graniterapids", "amd-siena", "ANY-PLATFORM", - "NON-EXISTENT-PLATFORM", + "reserved-40", "intel-graniterapids", "amd-siena", "arm-neoverse-v2", + "ANY-PLATFORM", "NON-EXISTENT-PLATFORM", }; // Returns the PlatformId of where this code runs on or kUndefined if