Skip to content

Commit

Permalink
Add support for generic NeoverseV2-based CPUs.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 665918039
  • Loading branch information
ksteuck authored and copybara-github committed Aug 21, 2024
1 parent 1ebb2bf commit 6984133
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions common/snapshot_proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

// ========================================================================= //
Expand Down
1 change: 1 addition & 0 deletions proto/snapshot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ enum PlatformId {

INTEL_GRANITERAPIDS = 41;
AMD_SIENA = 42;
ARM_NEOVERSE_V2 = 43;
}

// Describes a specific endstate of executing a snapshot.
Expand Down
15 changes: 14 additions & 1 deletion util/aarch64/platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ namespace silifuzz {

namespace {

absl::StatusOr<PlatformId> DistinguishNeoverseV2() {
return PlatformId::kArmNeoverseV2;
}

uint64_t GetMidr() {
uint64_t midr;
// The kernel will trap and emulate access to MIDR_EL1.
Expand All @@ -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;
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions util/platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions util/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -96,8 +97,8 @@ inline constexpr const char* EnumNameMap<PlatformId>[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
Expand Down

0 comments on commit 6984133

Please sign in to comment.