Skip to content

Targets for the portable stand-alone variant of the CheriBSD test suite#479

Open
paul-metzger wants to merge 9 commits into
mainfrom
cheritest
Open

Targets for the portable stand-alone variant of the CheriBSD test suite#479
paul-metzger wants to merge 9 commits into
mainfrom
cheritest

Conversation

@paul-metzger
Copy link
Copy Markdown
Contributor

@paul-metzger paul-metzger commented Apr 14, 2026

This PR contains CHERI/Morello Linux targets for a portable stand-alone variant of the CheriBSD test suite. We'd like to be able to use it on CHERI/Morello Linux for testing and to help with cataloguing design differences between the CHERI-related parts of CheriBSD's and CHERI/Morello Linux's OS interfaces.
@heshamelmatary is interested in this PR for testing.

Setup for Morello Linux:

  1. Build the test suite: ./cheribuild.py cheri-portable-os-tests --qemu/no-use-smbd -d
  2. Start Morello Linux in Qemu: ./cheribuild.py run-minimal-morello-linux-morello-purecap --qemu/no-use-smbd -d
  3. The test cases are then in /opt/cheri-portable-os-tests.
    This issue causes a compile time error and needs to be fixed by hand for Morello Muslc: Fix const dropping cast CHERI-Alliance/musl#3
    The test suite needs to be built first in order for it to be included into the image built in the second step.
    The workflow for RVY CHERI Linux is similar.

The repository with the adapted test cases is private currently, but the intention is to make it publicly available soon.

@paul-metzger paul-metzger force-pushed the cheritest branch 3 times, most recently from bb04b69 to dc097fd Compare April 14, 2026 15:37
@paul-metzger
Copy link
Copy Markdown
Contributor Author

After a conversation with Hesham, we want to have the binaries in a subdirectory of /opt/.

@heshamelmatary
Copy link
Copy Markdown
Member

After a conversation with Hesham, we want to have the binaries in a subdirectory of /opt/.

Probably under /opt/cheri-api-tests or such?

@paulmetzger
Copy link
Copy Markdown
Contributor

The target name is tentative -- please feel free to make suggestions.

@paul-metzger paul-metzger force-pushed the cheritest branch 9 times, most recently from e5592d9 to f7f5463 Compare April 15, 2026 11:12
Comment thread pycheribuild/projects/cross/cheritestsuite.py Outdated
Comment thread pycheribuild/projects/cross/cheritestsuite.py Outdated
# We are including cheriintrin.h for some of the definitions
# that are on CheriBSD in other header files. However, cheric.h
# and cheriintrin.h define cheri_is_subset() but a comment in
# cheric.h indicates that the intrinsic is still unstable. Therefore,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is that a CheriBSD's cheric.h?

Copy link
Copy Markdown
Contributor Author

@paul-metzger paul-metzger Apr 16, 2026

Choose a reason for hiding this comment

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

Yes, the stand-alone variant of the CheriBSD test suite includes a copy of CheriBSD's cheric.h because some test cases use macros and functions defined in it.

I removed this comment and the -Wno-error=macro-redefined that followed it and added #undef cheri_is_subset before the redefinition of cheri_is_subset in the copy of cheric.h instead.

# cheriintrin.h if necessary.
self.cross_warning_flags.append("-Wno-error=macro-redefined")

# Musl libc's endian.h causes these warnings
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably worth bookkeepings those somewhere so that we can properly fix in musl later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would it be useful to create matching issues in the CHERI Alliance's musl repository?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd say yes, and probably link it here as well https://github.com/CHERI-Alliance/linux/milestone/1
Probably also the cheric.h for Linux too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I created an issue in the CHERI Alliance Musl repository for one of these: CHERI-Alliance/musl#8
The other's were not CHERI-related and benign. I changed the use of -W flags in the test suite repository and removed the -Wno flags from the cheribuild target.

Copy link
Copy Markdown
Contributor Author

@paul-metzger paul-metzger Apr 30, 2026

Choose a reason for hiding this comment

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

Probably also the cheric.h for Linux too?

@heshamelmatary, cheric.h is deprecated. It may be better to not bundle cheric.h with CHERI Musl and just bundle a copy with the test cases instead, with the intention to remove it and adapt the test cases at a later point.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For things we're not sure about, I might suggest creating a local macro in the cheritest_* namespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@brooksdavis I’m not quite sure what you’re suggesting. Could you elaborate a little? For what would you like me to create a macro?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For non-portable macros, the test suite should define it's own version of them until and unless they are added to cheriintrin.h

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks

Comment thread pycheribuild/projects/cross/cheritestsuite.py Outdated
"MACHINE_ARCH": machine_arch,
}

def install(self, **kwargs):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is that needed? if it's just make install I guess the CrossCompileMakefileProjector CrossCompileAutotoolsProject parent would do that for you, without you having to define install

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This tells cheribuild that the makefile is not in the root directory of the repository but in <repo_root>/cheribsdtest. This makefile and the source code will move from <repo_root>/cheribsdtest to the repository's root directory in the future.

Comment thread pycheribuild/projects/cross/cheritestsuite.py Outdated
Comment thread pycheribuild/projects/cross/cheritestsuite.py Outdated
Comment thread pycheribuild/projects/cross/libbsd.py Outdated
Comment thread pycheribuild/projects/cross/libxo.py Outdated
@paul-metzger paul-metzger force-pushed the cheritest branch 7 times, most recently from dbda961 to 6d013f7 Compare April 20, 2026 17:35

# Overwrite dependencies because libsys and libcompiler_rt don't exist in
# the CHERI/Morello Linux sysroot
self.make_args.set(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems rather awkward. I think you're bundling the makefiles so could you fix it in the source repo? Or alternatively it might make sense to write a CMake/meson based build system which should be quite simple for this small project.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, I fixed this in the test suite repository instead, as suggested.

The bundled makefiles are just an interim solution that will be replaced by cmake. However, these tests would be very useful to @heshamelmatary and potentially others, including work on a CI setup for the CHERI Alliance Linux repositories, and so I created this PR before replacing the makefiles with cmake.

Comment thread pycheribuild/projects/cross/cheritestsuite.py Outdated
Comment thread pycheribuild/projects/cross/libmd.py Outdated
Comment thread pycheribuild/projects/cross/libmd.py Outdated
@paul-metzger paul-metzger force-pushed the cheritest branch 3 times, most recently from 78ccd1a to 38c87e0 Compare April 27, 2026 14:20
Comment thread pycheribuild/projects/cross/libbsd.py Outdated
# `default_branch` is set because the build scripts assume that
# a git tag is checked out. In more detail ./get-version returns an
# empty string if main is checked out.
repository = GitRepository("https://gitlab.freedesktop.org/libbsd/libbsd.git", default_branch="0.12.2")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What I've done in cases like this in the past is use temporary_url_override to point it at a fork with the patch applied to avoid needing the logic for patching inside the target.

Copy link
Copy Markdown
Contributor Author

@paul-metzger paul-metzger Apr 28, 2026

Choose a reason for hiding this comment

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

Done - I've created a patched fork of libbsd on the freedesktop GitLab instance with a view to upstreaming the patch to libbsd soon (see my comment above).

@paul-metzger paul-metzger force-pushed the cheritest branch 4 times, most recently from 6c27825 to 382a91e Compare April 29, 2026 15:34
@heshamelmatary
Copy link
Copy Markdown
Member

It's looking way better to me. I built and tested it locally for Morello and RVY and it's working just fine. @paul-metzger please let us know once you're ready to make the repo public, then can add it to Jenkins tests after we merge this PR

@@ -0,0 +1,136 @@
#
# Copyright (c) 2025 Paul Metzger
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# Copyright (c) 2025 Paul Metzger
# Copyright (c) 2026 Paul Metzger

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I've updated the copyright in all files.

from ...utils import classproperty


class BuildCheriAPITests(CrossCompileMakefileProject):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we give this an explicit target name instead of the default?

E.g. cheri-portable-tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've named them cheri-portable-os-tests. I think Robert would like to have OS or the like in the name.

@paul-metzger paul-metzger force-pushed the cheritest branch 3 times, most recently from d3086e2 to 2a11df7 Compare April 30, 2026 08:02
paul-metzger and others added 3 commits May 11, 2026 10:14
CheriBSDtest depends on libxo which in turn depends on libmd.
This is a dependency of the stand-alone CheriBSD test suite.
This is a dependency of the stand-alone CheriBSD test suite.
@paul-metzger paul-metzger force-pushed the cheritest branch 2 times, most recently from cc7b8fd to ea9aed7 Compare May 11, 2026 09:58
Added targets for the stand-alone test suite, including flags to
avoid linking with libgcc_s, which isn't available on CHERI
Alliance Linux.
The installation of libcheribsdtest_dynamic failed when
cross-compiling on Ubuntu because the local objcopy was used
instead of CHERI LLVM's objcopy. This commit fixes this by setting
the OBJCOPY environment variable. The property objcopy was
add to _ClangBasedTargetInfo to support this.
The targets for Morello Linux and CHERI Linux on Morello both used
the 'morello-purecap' suffix. This commit fixes this by chaning
the suffix for Morello Linux targets to 'legacy-morello-purecap',
as suggested by Alexander Richardson.
This commit also includes a similar fix for non-purecap Morello
targets.
We are now using a patched fork of libbsd with a view to merging
the patch upstream.
This cambridge-morello-7.0 branch has fixes for the Morello support
and should be used until all of those fixes are merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants