Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
* Add `Sandbox::recreate()`, which rebuilds a sandbox's VM and memory from a snapshot. It recovers unrecoverable sandboxes and keeps configuration, host functions, and interrupt handles by @ludfjig in https://github.com/hyperlight-dev/hyperlight/pull/1751

### Changed
* **Breaking:** In the guest libc bindings, `timeval.tv_usec` is now
`suseconds_t` (`i32`) instead of `c_long`. Use `suseconds_t` for values assigned
to the field, or convert existing `c_long` values with
`suseconds_t::try_from(value)`.
* `Snapshot::save` caches memory-layer hashes and trusts existing same-length
regular blobs by their content-addressed filenames without verifying their
contents. Callers must keep blobs immutable. Use the new
Expand Down
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Component. picolibc
picolibc is a C library designed for embedded systems, derived from newlib.
https://github.com/picolibc/picolibc

Version: 1.8.11
Version: 1.8.12 (upstream snapshot ff59ec82f)

Open Source License/Copyright Notice.

Expand Down
7 changes: 7 additions & 0 deletions docs/picolibc.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ For full details on available picolibc build options, see the

The file list of picolibc sources to compile is maintained in `build_files.rs`.

## Pinned Snapshot

Hyperlight uses the BSD-filtered snapshot of upstream
[`ff59ec82f`](https://github.com/picolibc/picolibc/commit/ff59ec82f), based on Picolibc
1.8.12. This snapshot includes the buffered `fwrite` fixes and follow-up fixes for
error reporting on `fclose` and buffered stream positioning.

## Updating Picolibc

To update picolibc to a new version:
Expand Down
5 changes: 5 additions & 0 deletions src/hyperlight_libc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use bindgen::Formatter::Prettyplease;
use bindgen::RustEdition::Edition2021;
use build_files::{
LIBC_FILES, LIBC_FILES_AARCH64, LIBC_FILES_X86, LIBM_FILES, LIBM_FILES_AARCH64, LIBM_FILES_X86,
LIBOS_FALLBACK_FILES,
};

fn copy_includes<P: AsRef<Path>, Q: AsRef<Path> + std::fmt::Debug>(
Expand Down Expand Up @@ -159,6 +160,10 @@ fn add_libc(build: &mut cc::Build, picolibc_dir: &Path, target: Target) -> Resul
let source_path = picolibc_dir.join("libc").join(file);
build.file(&source_path);
}
let fallback_dir = picolibc_dir.join("libos/fallback");
for file in LIBOS_FALLBACK_FILES {
build.file(fallback_dir.join(file));
}

Ok(())
}
Expand Down
22 changes: 15 additions & 7 deletions src/hyperlight_libc/build_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,11 @@ pub(crate) const LIBC_FILES: &[&str] = &[
"misc/init.c",
"misc/inittls.c",
"misc/lock.c",
"misc/picosbrk.c",
"misc/unctrl.c",
"posix/basename.c",
"posix/collcmp.c",
"posix/dirname.c",
"posix/fnmatch.c",
"posix/fpathconf.c",
"posix/pathconf.c",
"posix/regcomp.c",
"posix/regerror.c",
"posix/regexec.c",
Expand Down Expand Up @@ -154,7 +151,6 @@ pub(crate) const LIBC_FILES: &[&str] = &[
"search/twalk.c",
"signal/psignal.c",
"signal/sig2str.c",
"signal/signal.c",
"ssp/chk_fail.c",
"ssp/gets_chk.c",
"ssp/memcpy_chk.c",
Expand Down Expand Up @@ -213,6 +209,7 @@ pub(crate) const LIBC_FILES: &[&str] = &[
"stdio/fgetwc.c",
"stdio/fgetws.c",
"stdio/fileno.c",
"stdio/filewstrput.c",
"stdio/filestrget.c",
"stdio/filestrput.c",
"stdio/filestrputalloc.c",
Expand All @@ -221,6 +218,7 @@ pub(crate) const LIBC_FILES: &[&str] = &[
"stdio/flockfile_init.c",
"stdio/fmemopen.c",
"stdio/fopen.c",
"stdio/fopencookie.c",
"stdio/fprintf.c",
"stdio/fputc.c",
"stdio/fputs.c",
Expand Down Expand Up @@ -385,8 +383,8 @@ pub(crate) const LIBC_FILES: &[&str] = &[
"stdlib/erand48.c",
"stdlib/exit.c",
"stdlib/exitprocs.c",
"stdlib/_findenv.c",
"stdlib/getenv.c",
"stdlib/getenv_r.c",
"stdlib/getopt.c",
"stdlib/getsubopt.c",
"stdlib/ignore_handler_s.c",
Expand Down Expand Up @@ -434,6 +432,7 @@ pub(crate) const LIBC_FILES: &[&str] = &[
"stdlib/uctoej.c",
"stdlib/uctoji.c",
"stdlib/uctosj.c",
"stdlib/unsetenv.c",
"stdlib/utoa.c",
"stdlib/wcrtomb.c",
"stdlib/wcsnrtombs.c",
Expand Down Expand Up @@ -558,7 +557,6 @@ pub(crate) const LIBC_FILES: &[&str] = &[
"time/difftime.c",
"time/getdate.c",
"time/getdate_r.c",
"time/gettzinfo.c",
"time/gmtime.c",
"time/gmtime_r.c",
"time/lcltime.c",
Expand Down Expand Up @@ -668,6 +666,16 @@ pub(crate) const LIBC_FILES_AARCH64: &[&str] = &[
"machine/aarch64/tls.c",
];

// Bare-metal functions that moved out of libc in Picolibc 1.8.12.
pub(crate) const LIBOS_FALLBACK_FILES: &[&str] = &[
"fpathconf.c",
"pathconf.c",
"raise.c",
"sbrk.c",
"signal.c",
"sigprocmask.c",
];

pub(crate) const LIBM_FILES: &[&str] = &[
"common/copysignl.c",
"common/exp10l.c",
Expand Down Expand Up @@ -805,7 +813,7 @@ pub(crate) const LIBM_FILES: &[&str] = &[
"ld/e_tgammal.c",
"ld/invtrig.c",
"ld/k_cosl.c",
"ld/k_rem_pio2.c",
"ld/k_rem_pio2l.c",
"ld/k_sinl.c",
"ld/k_tanl.c",
"ld/math_errl_check_oflowl.c",
Expand Down
4 changes: 2 additions & 2 deletions src/hyperlight_libc/include/picolibc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#define __NEWLIB__ 4
#define __NEWLIB_MINOR__ 3
#define __NEWLIB_PATCHLEVEL__ 0
#define __PICOLIBC_VERSION__ "1.8.11"
#define __PICOLIBC_VERSION__ "1.8.12"
#define __PICOLIBC__ 1
#define __PICOLIBC_MINOR__ 8
#define __PICOLIBC_PATCHLEVEL__ 11
#define __PICOLIBC_PATCHLEVEL__ 12

// static configuration - enabled features
#define __ASSERT_VERBOSE
Expand Down
3 changes: 2 additions & 1 deletion src/hyperlight_libc/src/stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ extern "C" fn gettimeofday(tv: *mut timeval, _tz: *mut c_void) -> c_int {

unsafe {
(*tv).tv_sec = ts.tv_sec;
(*tv).tv_usec = ts.tv_nsec / 1000;
// A normalized timespec converts to at most 999_999 microseconds.
(*tv).tv_usec = (ts.tv_nsec / 1000) as _;
Comment thread
qbradley marked this conversation as resolved.
Resolved
}

0
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_libc/third_party/picolibc
Submodule picolibc updated 2407 files
Loading