Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #74415

Closed
wants to merge 58 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c4b0265
Enable some timeouts in SGX platform
mzohreva Jun 12, 2020
d7dc64b
Handle spurious wakeups in wait_timeout_sgx
mzohreva Jun 12, 2020
c5d1fcd
Allow more ui tests for SGX
mzohreva Jun 12, 2020
3442d23
Improve wait_timeout_sgx, simplify usercalls::wait
mzohreva Jun 18, 2020
c457b67
Remove unnecessary check in SGX wait usercall
mzohreva Jul 1, 2020
a18848b
Create implib for dlls when testing MinGW targets
mati865 Jun 13, 2020
177a495
Allow matching test by target and env
mati865 Jul 3, 2020
3324bc5
Remove invalid test
mati865 Jul 3, 2020
17bc07d
Fix various tests to run on windows-gnu
mati865 Jul 3, 2020
1466598
Address review comments
mzohreva Jul 11, 2020
f970632
Don't render unstable for rustc docs
tesuji Jul 15, 2020
47fea96
Remove unused CSS rules for internal rustc items
tesuji Jul 15, 2020
8c6c1dd
Automatically calculate std::env::consts::ARCH.
ehuss May 21, 2020
432b4c1
Use cfg_if in libtest.
ehuss May 22, 2020
9e58908
Use cfg_if in libpanic_abort.
ehuss May 22, 2020
ef6c026
Improve ayu rustdoc theme
Aloso Jul 15, 2020
6e9a1de
Introduce restricted-std feature.
ehuss Jun 1, 2020
cee9f05
Tweak formatting.
ehuss Jul 7, 2020
0eb293d
Use an allow-list of platforms that support std.
ehuss Jul 7, 2020
3d44d3c
Simplify os_str_bytes cfg expression.
ehuss Jul 7, 2020
d08bb40
Remove drop-shadow
Aloso Jul 15, 2020
85c25ae
Move usercall_wait_timeout to abi::usercalls::wait_timeout
mzohreva Jul 15, 2020
1813ae7
Add RISC-V GNU/Linux to src/tools/build-manifest as a host platform
msizanoen1 Jul 16, 2020
03bbe9d
Clean up E0723 explanation
GuillaumeGomez Jul 16, 2020
8e92f4f
Remove unused `cx` parameter from `pathvec_std` and `path_std`.
nnethercote Jul 14, 2020
bccff14
Simplify `LifetimeBounds`.
nnethercote Jul 14, 2020
5271e98
Use get_module instead of `module_map` for `resolve_str_path_error`
jyn514 Jun 6, 2020
848a766
Use the scope of the imported variable for resolution, not the curren…
jyn514 Jun 6, 2020
69bd13f
Use DefId for modules
jyn514 Jun 7, 2020
c3d9a73
Don't panic on fake IDs
jyn514 Jun 7, 2020
20106d5
unwrap() -> expect()
jyn514 Jun 7, 2020
24c3d85
Make sure that module_id is actually a module
jyn514 Jun 7, 2020
9542e23
Add tests for basic intra-doc links
jyn514 Jun 8, 2020
99f34d8
Remove warnings
jyn514 Jun 8, 2020
e78d499
Add test for re-exports
jyn514 Jun 8, 2020
9eb6394
Add test for documenting the re-export
jyn514 Jun 8, 2020
71fe8f7
Add test for submodules in inner crate
jyn514 Jun 10, 2020
432b043
Move import to top of function
jyn514 Jun 10, 2020
769acba
#![deny(intra_doc_resolution_failure)]
jyn514 Jun 10, 2020
5f49f55
rand -> my_rand
jyn514 Jun 10, 2020
e63e5cd
Support intra-doc links on macro re-exports
jyn514 Jun 12, 2020
82b3b07
Support intra-doc links on trait and module re-exports
jyn514 Jul 11, 2020
0ad1dcd
Add more debugging
jyn514 Jul 12, 2020
8387e38
Add (broken and ignored) test for #73829
jyn514 Jul 15, 2020
c46e038
Fix invalid lint
jyn514 Jul 16, 2020
9f00808
Remove `ExtCtxt::ident_of`.
nnethercote Jul 14, 2020
002af4d
Avoid storing `SymbolStr` in a struct.
nnethercote Jul 13, 2020
f03c7f8
Add `UnsafetyViolationDetails`.
nnethercote Jul 14, 2020
a4ba181
Remove some `Symbol:as_str()` calls.
nnethercote Jul 14, 2020
dcd0180
Rollup merge of #73101 - jyn514:rustdoc-absolute-module, r=Manishearth
Manishearth Jul 16, 2020
599a77d
Rollup merge of #73269 - mzohreva:mz/sgx-wait-timeout, r=jethrogb
Manishearth Jul 16, 2020
9d59c05
Rollup merge of #74009 - mati865:mingw-tests-implib, r=nikomatsakis
Manishearth Jul 16, 2020
f14a5da
Rollup merge of #74033 - ehuss:std-compile-all-platforms, r=Mark-Simu…
Manishearth Jul 16, 2020
dbdc096
Rollup merge of #74351 - lzutao:remove-rustc-internal-compiler-warns,…
Manishearth Jul 16, 2020
6a4e73e
Rollup merge of #74357 - nnethercote:symbol-related-improvements, r=o…
Manishearth Jul 16, 2020
01c80f5
Rollup merge of #74371 - Aloso:patch-1, r=GuilliameGomez
Manishearth Jul 16, 2020
bea4bb9
Rollup merge of #74386 - msizanoen1:riscv-add-manifest-host, r=pietro…
Manishearth Jul 16, 2020
f97e6ad
Rollup merge of #74398 - GuillaumeGomez:cleanup-e0723, r=Dylan-DPC
Manishearth Jul 16, 2020
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
17 changes: 6 additions & 11 deletions src/libstd/sys/sgx/abi/usercalls/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::cmp;
use crate::convert::TryFrom;
use crate::io::{Error as IoError, IoSlice, IoSliceMut, Result as IoResult};
use crate::sys::rand::rdrand64;
use crate::time::Duration;
@@ -159,17 +160,11 @@ pub fn wait(event_mask: u64, mut timeout: u64) -> IoResult<u64> {
// to make things work in other cases. Note that in the SGX threat
// model the enclave runner which is serving the wait usercall is not
// trusted to ensure accurate timeouts.
let base = cmp::max(1, timeout / 10) * 2 + 1;
let zero = base / 2;
match rdrand64() % base {
jitter if jitter > zero => {
timeout = timeout.checked_add(jitter - zero).unwrap_or(timeout)
}
jitter if jitter < zero => {
timeout = timeout.checked_sub(zero - jitter).unwrap_or(timeout)
}
_ => {}
};
if let Ok(timeout_signed) = i64::try_from(timeout) {
let tenth = 1 + timeout_signed / 10;
let deviation = (rdrand64() as i64).checked_rem(tenth).unwrap_or(0);
timeout = timeout_signed.saturating_add(deviation) as _;
}
timeout = cmp::min(u64::MAX - 1, cmp::max(1, timeout));
}
unsafe { raw::wait(event_mask, timeout).from_sgx_result() }
67 changes: 50 additions & 17 deletions src/libstd/sys/sgx/mod.rs
Original file line number Diff line number Diff line change
@@ -110,43 +110,76 @@ pub fn decode_error_kind(code: i32) -> ErrorKind {
}
}

// This function makes an effort to sleep at least as long as `duration`.
// Note that in general there is no guarantee about accuracy of time and
// timeouts in SGX model. The enclave runner serving usercalls may lie about
// current time and/or ignore timeout values.
// This function makes an effort to wait for a non-spurious event at least as
// long as `duration`. Note that in general there is no guarantee about accuracy
// of time and timeouts in SGX model. The enclave runner serving usercalls may
// lie about current time and/or ignore timeout values.
//
// Once the event is observed, `stop` will be used to determine whether or not
// we should continue to wait.
// Once the event is observed, `woken_up` will be used to determine whether or
// not the event was spurious.
//
// FIXME: note these caveats in documentation of all public types that use this
// function in their execution path.
pub fn wait_timeout_sgx<F>(event_mask: u64, duration: crate::time::Duration, stop: F)
pub fn wait_timeout_sgx<F>(event_mask: u64, duration: crate::time::Duration, woken_up: F)
where
F: Fn() -> bool,
{
use self::abi::usercalls;
use crate::cmp;
use crate::io::ErrorKind;
use crate::time::Instant;

let start = Instant::now();
let mut remaining = duration;
loop {
let timeout = cmp::min((u64::MAX - 1) as u128, remaining.as_nanos()) as u64;
use crate::time::{Duration, Instant};

// Calls the wait usercall and checks the result. Returns true if event was
// returned, and false if WouldBlock/TimedOut was returned.
// If duration is None, it will use WAIT_NO.
fn wait_checked(event_mask: u64, duration: Option<Duration>) -> bool {
let timeout = duration.map_or(usercalls::raw::WAIT_NO, |duration| {
cmp::min((u64::MAX - 1) as u128, duration.as_nanos()) as u64
});
match usercalls::wait(event_mask, timeout) {
Ok(eventset) => {
if event_mask == 0 {
rtabort!("expected usercalls::wait() to return Err, found Ok.");
}
rtassert!(eventset & event_mask == event_mask);
if stop() {
return;
}
true
}
Err(e) => {
rtassert!(e.kind() == ErrorKind::TimedOut || e.kind() == ErrorKind::WouldBlock)
rtassert!(e.kind() == ErrorKind::TimedOut || e.kind() == ErrorKind::WouldBlock);
false
}
}
}

match wait_checked(event_mask, Some(duration)) {
false => return, // timed out
true if woken_up() => return, // woken up
true => {} // spurious event
}

// Drain all cached events.
// Note that `event_mask != 0` is implied if we get here.
loop {
match wait_checked(event_mask, None) {
false => break, // no more cached events
true if woken_up() => return, // woken up
true => {} // spurious event
}
}

// Continue waiting, but take note of time spent waiting so we don't wait
// forever. We intentionally don't call `Instant::now()` before this point
// to avoid the cost of the `insecure_time` usercall in case there are no
// spurious wakeups.

let start = Instant::now();
let mut remaining = duration;
loop {
match wait_checked(event_mask, Some(remaining)) {
false => return, // timed out
true if woken_up() => return, // woken up
true => {} // spurious event
}
remaining = match duration.checked_sub(start.elapsed()) {
Some(remaining) => remaining,
None => break,