Skip to content

Commit

Permalink
Build Morello benchmark ABI kernels.
Browse files Browse the repository at this point in the history
This is enabled by the build-benchmark-abi-kernels.
  • Loading branch information
qwattash authored and jrtc27 committed May 21, 2024
1 parent ea5db9a commit d28a85a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
35 changes: 30 additions & 5 deletions pycheribuild/projects/cross/cheribsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class KernelABI(Enum):
NOCHERI = "no-cheri"
HYBRID = "hybrid"
PURECAP = "purecap"
PURECAP_BENCHMARK = "purecap-benchmark"


class ConfigPlatform(Enum):
Expand Down Expand Up @@ -161,6 +162,9 @@ def get_platform_name(self, platforms: "set[ConfigPlatform]") -> Optional[str]:
return self.platform_name_map[platform]
assert False, "Should not be reached..."

def get_available_kabis(self) -> "list[KernelABI]":
return [KernelABI.NOCHERI, KernelABI.HYBRID, KernelABI.PURECAP]

def get_flag_names(
self,
platforms: "set[ConfigPlatform]",
Expand Down Expand Up @@ -240,15 +244,15 @@ def get_flag_names(
def make_all(self) -> "list[CheriBSDConfig]":
configs = []
# Generate QEMU kernels
for kernel_abi in KernelABI:
for kernel_abi in self.get_available_kabis():
configs.append(self.make_config({ConfigPlatform.QEMU}, kernel_abi, default=True))
configs.append(self.make_config({ConfigPlatform.QEMU}, kernel_abi, benchmark=True, default=True))
configs.append(self.make_config({ConfigPlatform.QEMU}, kernel_abi, mfsroot=True, default=True))
configs.append(
self.make_config({ConfigPlatform.QEMU}, kernel_abi, mfsroot=True, benchmark=True, default=True)
)
# Generate FPGA kernels
for kernel_abi in KernelABI:
for kernel_abi in self.get_available_kabis():
configs.append(self.make_config({ConfigPlatform.GFE}, kernel_abi, mfsroot=True, default=True))
configs.append(
self.make_config({ConfigPlatform.GFE}, kernel_abi, mfsroot=True, benchmark=True, default=True)
Expand All @@ -260,7 +264,7 @@ def make_all(self) -> "list[CheriBSDConfig]":
configs.append(self.make_config({ConfigPlatform.QEMU}, KernelABI.HYBRID, fett=True, default=True))

# Caprevoke kernels
for kernel_abi in KernelABI:
for kernel_abi in self.get_available_kabis():
configs.append(self.make_config({ConfigPlatform.QEMU}, kernel_abi, nocaprevoke=True, default=True))
configs.append(
self.make_config({ConfigPlatform.QEMU}, kernel_abi, nocaprevoke=True, benchmark=True, default=True)
Expand Down Expand Up @@ -295,11 +299,17 @@ def get_kabi_name(self, kernel_abi) -> Optional[str]:
return "MORELLO"
elif kernel_abi == KernelABI.PURECAP:
return f"MORELLO{self.separator}PURECAP"
elif kernel_abi == KernelABI.PURECAP_BENCHMARK:
return f"MORELLO{self.separator}PURECAP{self.separator}BENCHMARK"

def get_available_kabis(self) -> "list[KernelABI]":
abis = super().get_available_kabis()
return [*abis, KernelABI.PURECAP_BENCHMARK]

def make_all(self) -> "list[CheriBSDConfig]":
configs = []
# Generate QEMU/FVP kernels
for kernel_abi in KernelABI:
for kernel_abi in self.get_available_kabis():
configs.append(self.make_config({ConfigPlatform.QEMU, ConfigPlatform.FVP}, kernel_abi, default=True))
configs.append(
self.make_config({ConfigPlatform.QEMU, ConfigPlatform.FVP}, kernel_abi, default=True, benchmark=True)
Expand All @@ -308,7 +318,7 @@ def make_all(self) -> "list[CheriBSDConfig]":
self.make_config({ConfigPlatform.QEMU, ConfigPlatform.FVP}, kernel_abi, default=True, mfsroot=True)
)
# Caprevoke kernels
for kernel_abi in KernelABI:
for kernel_abi in self.get_available_kabis():
configs.append(
self.make_config({ConfigPlatform.QEMU, ConfigPlatform.FVP}, kernel_abi, default=True, nocaprevoke=True)
)
Expand Down Expand Up @@ -1876,6 +1886,17 @@ def setup_config_options(cls, kernel_only_target=False, install_directory_help=N
help="Also build kernels with non-default ABI (purecap or hybrid)",
)

cls.build_benchmark_abi_kernels = cls.add_bool_option(
"build-benchmark-abi-kernels",
show_help=True,
only_add_for_targets=(
CompilationTargets.CHERIBSD_MORELLO_HYBRID,
CompilationTargets.CHERIBSD_MORELLO_PURECAP,
),
default=False,
help="Also build Morello Benchmark ABI kernels",
)

cls.build_bench_kernels = cls.add_bool_option(
"build-bench-kernels", show_help=True, _allow_unknown_targets=True, help="Also build benchmark kernels"
)
Expand Down Expand Up @@ -1942,6 +1963,10 @@ def _get_kernel_abis_to_build(self) -> "list[KernelABI]":
if self.crosscompile_target in self.purecap_kernel_targets and self.build_alternate_abi_kernels:
other_abi = KernelABI.PURECAP if default_kernel_abi != KernelABI.PURECAP else KernelABI.HYBRID
kernel_abis.append(other_abi)
if self.build_benchmark_abi_kernels and default_kernel_abi != KernelABI.PURECAP_BENCHMARK:
# Enable benchmark ABI kernels
kernel_abis.append(KernelABI.PURECAP_BENCHMARK)

return kernel_abis

def _get_all_kernel_configs(self) -> "list[CheriBSDConfig]":
Expand Down
15 changes: 15 additions & 0 deletions tests/test_argument_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,23 @@ def test_disk_image_path(target, expected_name):
pytest.param(
"cheribsd-morello-purecap",
[],
["GENERIC-MORELLO-PURECAP", "GENERIC-MORELLO"],
),
pytest.param(
"cheribsd-morello-purecap",
["--cheribsd/build-benchmark-abi-kernels"],
["GENERIC-MORELLO-PURECAP", "GENERIC-MORELLO", "GENERIC-MORELLO-PURECAP-BENCHMARK"],
),
pytest.param(
"cheribsd-morello-purecap",
["--cheribsd/build-benchmark-abi-kernels", "--cheribsd/build-bench-kernels"],
[
"GENERIC-MORELLO-PURECAP",
"GENERIC-MORELLO-PURECAP-NODEBUG",
"GENERIC-MORELLO",
"GENERIC-MORELLO-NODEBUG",
"GENERIC-MORELLO-PURECAP-BENCHMARK",
"GENERIC-MORELLO-PURECAP-BENCHMARK-NODEBUG",
],
),
pytest.param(
Expand Down Expand Up @@ -1252,6 +1266,7 @@ def test_mfs_root_kernel_config_options():
"auto_var_init",
"build_alternate_abi_kernels",
"build_bench_kernels",
"build_benchmark_abi_kernels",
"build_fett_kernels",
"build_fpga_kernels",
"build_nocaprevoke_kernels",
Expand Down

0 comments on commit d28a85a

Please sign in to comment.