Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,25 @@ config_setting(
},
visibility = ["//visibility:public"],
)

# Enable the ARM MTE (Memory Tagging Extension) memory provider.
#
# The provider allocates health monitor memory regions with hardware-assisted
# tagging. It takes effect only on targets that support MTE (currently
# aarch64 Linux). On every other target, and on CPUs without MTE, allocation
# reports an error and degrades to plain, unprotected memory.
#
# Enable with: --//config:enable_arm_mte=True
bool_flag(
name = "enable_arm_mte",
build_setting_default = False,
visibility = ["//visibility:public"],
)

config_setting(
name = "arm_mte_enabled",
flag_values = {
":enable_arm_mte": "True",
},
visibility = ["//visibility:public"],
)
4 changes: 4 additions & 0 deletions score/health_monitor/src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ thread.workspace = true
score_log.workspace = true
score_testing_macros.workspace = true
containers.workspace = true
libc.workspace = true
alive_rs = { workspace = true, optional = true }

[dev-dependencies]
Expand All @@ -29,3 +30,6 @@ loom = { version = "0.7.2", features = ["checkpoint"] }
[features]
default = ["alive_rs"]
stub_supervisor_api_client = []
# Enable the ARM MTE (Memory Tagging Extension) protected memory provider.
# Activated by the `//config:enable_arm_mte` Bazel flag.
mte = []
41 changes: 38 additions & 3 deletions score/health_monitor/src/rust/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ COMMON_RUST_DEPS = [
"@score_baselibs//src/containers:containers",
"@score_baselibs//src/thread:thread",
"@score_baselibs//src/log/score_log:score_log",
"@score_crates//:libc",
"//score/launch_manager:alive_rust",
]

Expand All @@ -27,6 +28,10 @@ PROC_MACRO_DEPS = [
rust_library(
name = "health_monitoring_lib",
srcs = glob(["**/*.rs"]),
crate_features = select({
"//config:arm_mte_enabled": ["mte"],
"//conditions:default": [],
}),
crate_root = "lib.rs",
proc_macro_deps = PROC_MACRO_DEPS,
visibility = ["//score:__subpackages__"],
Expand All @@ -36,17 +41,41 @@ rust_library(
rust_static_library(
name = "health_monitoring_lib_ffi",
srcs = glob(["**/*.rs"]),
crate_features = select({
"//config:arm_mte_enabled": ["mte"],
"//conditions:default": [],
}),
crate_name = "health_monitoring_lib",
crate_root = "lib.rs",
proc_macro_deps = PROC_MACRO_DEPS,
visibility = ["//score/health_monitor:__subpackages__"],
deps = COMMON_RUST_DEPS,
)

# Build coverage for the MTE backend. No default configuration compiles it, as
# it is both feature and target gated, so it is built unconditionally for
# aarch64 Linux. Skipped on every other platform.
rust_library(
name = "health_monitoring_lib_mte",
srcs = glob(["**/*.rs"]),
crate_features = ["mte"],
crate_name = "health_monitoring_lib",
crate_root = "lib.rs",
proc_macro_deps = PROC_MACRO_DEPS,
target_compatible_with = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
],
deps = COMMON_RUST_DEPS,
)

rust_static_library(
name = "health_monitoring_lib_stub_supervisor",
srcs = glob(["**/*.rs"]),
crate_features = ["stub_supervisor_api_client"],
crate_features = ["stub_supervisor_api_client"] + select({
"//config:arm_mte_enabled": ["mte"],
"//conditions:default": [],
}),
crate_root = "lib.rs",
proc_macro_deps = PROC_MACRO_DEPS,
visibility = ["//score/health_monitor:__subpackages__"],
Expand All @@ -56,7 +85,10 @@ rust_static_library(
rust_test(
name = "tests",
crate = ":health_monitoring_lib",
crate_features = ["stub_supervisor_api_client"],
crate_features = ["stub_supervisor_api_client"] + select({
"//config:arm_mte_enabled": ["mte"],
"//conditions:default": [],
}),
rustc_flags = [
"-C",
"link-arg=-lm",
Expand Down Expand Up @@ -84,7 +116,10 @@ rust_test(
rust_test(
name = "loom_tests",
crate = ":health_monitoring_lib",
crate_features = ["stub_supervisor_api_client"],
crate_features = ["stub_supervisor_api_client"] + select({
"//config:arm_mte_enabled": ["mte"],
"//conditions:default": [],
}),
rustc_flags = [
"--cfg",
"loom",
Expand Down
Loading