Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9622a79
Implement LLVM x86 vpclmulqdq intrinsics
TDecking Oct 22, 2024
05530b6
Adjust the vpclmulqdq test case
TDecking Oct 26, 2024
fb7bcd1
Merge pull request #3987 from TDecking/vpclmul
RalfJung Oct 27, 2024
cdc40a4
Add option for generating coverage reports
Mandragorian Oct 9, 2024
9023e35
Merge pull request #3954 from Mandragorian/coverage-report
RalfJung Oct 28, 2024
c8ce9e6
Android: Added syscall support
YohDeadfall Oct 25, 2024
f736269
Merge pull request #3992 from YohDeadfall/android-syscall
RalfJung Oct 28, 2024
6365ea1
contributing guide: mention expectations around force pushes and squa…
RalfJung Oct 27, 2024
d581d80
Merge pull request #3998 from RalfJung/contrib
oli-obk Oct 28, 2024
ff6e703
Preparing for merge from rustc
Oct 30, 2024
7d12e50
Merge from rustc
Oct 30, 2024
8a5f34a
Merge pull request #4001 from rust-lang/rustup-2024-10-30
RalfJung Oct 30, 2024
042f762
Change futex_wait errno from Scalar to IoError
noahmbright Oct 29, 2024
4ca9c07
Merge pull request #4000 from noahmbright/futex
RalfJung Oct 30, 2024
c5e86c4
Fixed a typo in the GetThreadDescription shim
YohDeadfall Oct 30, 2024
445a340
Merge pull request #4003 from YohDeadfall/windows-shim-typo
saethlin Oct 31, 2024
1c88af6
Preparing for merge from rustc
Oct 31, 2024
4828592
Merge from rustc
Oct 31, 2024
ef6b9a9
fmt
Oct 31, 2024
b8bd7be
silence clippy
RalfJung Oct 31, 2024
6630802
Merge pull request #4005 from rust-lang/rustup-2024-10-31
RalfJung Oct 31, 2024
06d869b
Preparing for merge from rustc
RalfJung Nov 2, 2024
3253cc6
Merge from rustc
RalfJung Nov 2, 2024
c1b8d66
teach clippy about IeeeFloat, and make all 'allow' into 'expect'
RalfJung Nov 2, 2024
c67ea44
Merge pull request #4009 from RalfJung/rustup
RalfJung Nov 2, 2024
9c75eff
Preparing for merge from rustc
Nov 3, 2024
b58cbe2
Merge from rustc
Nov 3, 2024
b17cf41
Merge pull request #4010 from rust-lang/rustup-2024-11-03
RalfJung Nov 3, 2024
dc62c34
Renamed ecx variales to this
YohDeadfall Nov 7, 2024
1254d8e
Get/set thread name shims return errors for invalid handles
YohDeadfall Oct 30, 2024
c8e089e
Merge pull request #4018 from YohDeadfall/ecx-name-standardization
RalfJung Nov 8, 2024
d7aceee
Merge pull request #4004 from YohDeadfall/thread-name-ice-fix
RalfJung Nov 8, 2024
beb8d6f
Preparing for merge from rustc
Nov 9, 2024
15d883e
Merge from rustc
Nov 9, 2024
c272bb4
Merge pull request #4019 from rust-lang/rustup-2024-11-09
saethlin Nov 9, 2024
fe39888
pthread-sync: avoid confusing error when running with preemption
RalfJung Nov 9, 2024
5ff90d0
Merge pull request #4020 from RalfJung/thread-sope
RalfJung Nov 9, 2024
ce7a560
Preparing for merge from rustc
RalfJung Nov 10, 2024
a01f37c
Merge from rustc
RalfJung Nov 10, 2024
a839fbf
Merge pull request #4021 from RalfJung/rustup
RalfJung Nov 10, 2024
d1a4812
store futexes in per-allocation data rather than globally
RalfJung Oct 12, 2024
673d9c3
Merge pull request #3971 from RalfJung/futex-virtual
RalfJung Nov 10, 2024
e8a3ffe
fix linux-futex test being accidentally disabled
RalfJung Nov 10, 2024
881f2ec
Merge pull request #4022 from RalfJung/linux-futex
RalfJung Nov 10, 2024
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
72 changes: 36 additions & 36 deletions src/tools/miri/src/alloc_addresses/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
// Returns the exposed `AllocId` that corresponds to the specified addr,
// or `None` if the addr is out of bounds
fn alloc_id_from_addr(&self, addr: u64, size: i64) -> Option<AllocId> {
let ecx = self.eval_context_ref();
let global_state = ecx.machine.alloc_addresses.borrow();
let this = self.eval_context_ref();
let global_state = this.machine.alloc_addresses.borrow();
assert!(global_state.provenance_mode != ProvenanceMode::Strict);

// We always search the allocation to the right of this address. So if the size is structly
Expand All @@ -134,15 +134,15 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
// entered for addresses that are not the base address, so even zero-sized
// allocations will get recognized at their base address -- but all other
// allocations will *not* be recognized at their "end" address.
let size = ecx.get_alloc_info(alloc_id).0;
let size = this.get_alloc_info(alloc_id).0;
if offset < size.bytes() { Some(alloc_id) } else { None }
}
}?;

// We only use this provenance if it has been exposed.
if global_state.exposed.contains(&alloc_id) {
// This must still be live, since we remove allocations from `int_to_ptr_map` when they get freed.
debug_assert!(ecx.is_alloc_live(alloc_id));
debug_assert!(this.is_alloc_live(alloc_id));
Some(alloc_id)
} else {
None
Expand All @@ -155,9 +155,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
alloc_id: AllocId,
memory_kind: MemoryKind,
) -> InterpResult<'tcx, u64> {
let ecx = self.eval_context_ref();
let mut rng = ecx.machine.rng.borrow_mut();
let (size, align, kind) = ecx.get_alloc_info(alloc_id);
let this = self.eval_context_ref();
let mut rng = this.machine.rng.borrow_mut();
let (size, align, kind) = this.get_alloc_info(alloc_id);
// This is either called immediately after allocation (and then cached), or when
// adjusting `tcx` pointers (which never get freed). So assert that we are looking
// at a live allocation. This also ensures that we never re-assign an address to an
Expand All @@ -166,12 +166,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
assert!(!matches!(kind, AllocKind::Dead));

// This allocation does not have a base address yet, pick or reuse one.
if ecx.machine.native_lib.is_some() {
if this.machine.native_lib.is_some() {
// In native lib mode, we use the "real" address of the bytes for this allocation.
// This ensures the interpreted program and native code have the same view of memory.
let base_ptr = match kind {
AllocKind::LiveData => {
if ecx.tcx.try_get_global_alloc(alloc_id).is_some() {
if this.tcx.try_get_global_alloc(alloc_id).is_some() {
// For new global allocations, we always pre-allocate the memory to be able use the machine address directly.
let prepared_bytes = MiriAllocBytes::zeroed(size, align)
.unwrap_or_else(|| {
Expand All @@ -185,7 +185,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
.unwrap();
ptr
} else {
ecx.get_alloc_bytes_unchecked_raw(alloc_id)?
this.get_alloc_bytes_unchecked_raw(alloc_id)?
}
}
AllocKind::Function | AllocKind::VTable => {
Expand All @@ -204,10 +204,10 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
}
// We are not in native lib mode, so we control the addresses ourselves.
if let Some((reuse_addr, clock)) =
global_state.reuse.take_addr(&mut *rng, size, align, memory_kind, ecx.active_thread())
global_state.reuse.take_addr(&mut *rng, size, align, memory_kind, this.active_thread())
{
if let Some(clock) = clock {
ecx.acquire_clock(&clock);
this.acquire_clock(&clock);
}
interp_ok(reuse_addr)
} else {
Expand All @@ -230,7 +230,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
.checked_add(max(size.bytes(), 1))
.ok_or_else(|| err_exhaust!(AddressSpaceFull))?;
// Even if `Size` didn't overflow, we might still have filled up the address space.
if global_state.next_base_addr > ecx.target_usize_max() {
if global_state.next_base_addr > this.target_usize_max() {
throw_exhaust!(AddressSpaceFull);
}

Expand All @@ -243,8 +243,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
alloc_id: AllocId,
memory_kind: MemoryKind,
) -> InterpResult<'tcx, u64> {
let ecx = self.eval_context_ref();
let mut global_state = ecx.machine.alloc_addresses.borrow_mut();
let this = self.eval_context_ref();
let mut global_state = this.machine.alloc_addresses.borrow_mut();
let global_state = &mut *global_state;

match global_state.base_addr.get(&alloc_id) {
Expand Down Expand Up @@ -283,31 +283,31 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn expose_ptr(&mut self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> {
let ecx = self.eval_context_mut();
let global_state = ecx.machine.alloc_addresses.get_mut();
let this = self.eval_context_mut();
let global_state = this.machine.alloc_addresses.get_mut();
// In strict mode, we don't need this, so we can save some cycles by not tracking it.
if global_state.provenance_mode == ProvenanceMode::Strict {
return interp_ok(());
}
// Exposing a dead alloc is a no-op, because it's not possible to get a dead allocation
// via int2ptr.
if !ecx.is_alloc_live(alloc_id) {
if !this.is_alloc_live(alloc_id) {
return interp_ok(());
}
trace!("Exposing allocation id {alloc_id:?}");
let global_state = ecx.machine.alloc_addresses.get_mut();
let global_state = this.machine.alloc_addresses.get_mut();
global_state.exposed.insert(alloc_id);
if ecx.machine.borrow_tracker.is_some() {
ecx.expose_tag(alloc_id, tag)?;
if this.machine.borrow_tracker.is_some() {
this.expose_tag(alloc_id, tag)?;
}
interp_ok(())
}

fn ptr_from_addr_cast(&self, addr: u64) -> InterpResult<'tcx, Pointer> {
trace!("Casting {:#x} to a pointer", addr);

let ecx = self.eval_context_ref();
let global_state = ecx.machine.alloc_addresses.borrow();
let this = self.eval_context_ref();
let global_state = this.machine.alloc_addresses.borrow();

// Potentially emit a warning.
match global_state.provenance_mode {
Expand All @@ -319,9 +319,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}
PAST_WARNINGS.with_borrow_mut(|past_warnings| {
let first = past_warnings.is_empty();
if past_warnings.insert(ecx.cur_span()) {
if past_warnings.insert(this.cur_span()) {
// Newly inserted, so first time we see this span.
ecx.emit_diagnostic(NonHaltingDiagnostic::Int2Ptr { details: first });
this.emit_diagnostic(NonHaltingDiagnostic::Int2Ptr { details: first });
}
});
}
Expand All @@ -347,19 +347,19 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
tag: BorTag,
kind: MemoryKind,
) -> InterpResult<'tcx, interpret::Pointer<Provenance>> {
let ecx = self.eval_context_ref();
let this = self.eval_context_ref();

let (prov, offset) = ptr.into_parts(); // offset is relative (AllocId provenance)
let alloc_id = prov.alloc_id();

// Get a pointer to the beginning of this allocation.
let base_addr = ecx.addr_from_alloc_id(alloc_id, kind)?;
let base_addr = this.addr_from_alloc_id(alloc_id, kind)?;
let base_ptr = interpret::Pointer::new(
Provenance::Concrete { alloc_id, tag },
Size::from_bytes(base_addr),
);
// Add offset with the right kind of pointer-overflowing arithmetic.
interp_ok(base_ptr.wrapping_offset(offset, ecx))
interp_ok(base_ptr.wrapping_offset(offset, this))
}

// This returns some prepared `MiriAllocBytes`, either because `addr_from_alloc_id` reserved
Expand All @@ -371,16 +371,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
bytes: &[u8],
align: Align,
) -> InterpResult<'tcx, MiriAllocBytes> {
let ecx = self.eval_context_ref();
if ecx.machine.native_lib.is_some() {
let this = self.eval_context_ref();
if this.machine.native_lib.is_some() {
// In native lib mode, MiriAllocBytes for global allocations are handled via `prepared_alloc_bytes`.
// This additional call ensures that some `MiriAllocBytes` are always prepared, just in case
// this function gets called before the first time `addr_from_alloc_id` gets called.
ecx.addr_from_alloc_id(id, kind)?;
this.addr_from_alloc_id(id, kind)?;
// The memory we need here will have already been allocated during an earlier call to
// `addr_from_alloc_id` for this allocation. So don't create a new `MiriAllocBytes` here, instead
// fetch the previously prepared bytes from `prepared_alloc_bytes`.
let mut global_state = ecx.machine.alloc_addresses.borrow_mut();
let mut global_state = this.machine.alloc_addresses.borrow_mut();
let mut prepared_alloc_bytes = global_state
.prepared_alloc_bytes
.remove(&id)
Expand All @@ -403,23 +403,23 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
ptr: interpret::Pointer<Provenance>,
size: i64,
) -> Option<(AllocId, Size)> {
let ecx = self.eval_context_ref();
let this = self.eval_context_ref();

let (tag, addr) = ptr.into_parts(); // addr is absolute (Tag provenance)

let alloc_id = if let Provenance::Concrete { alloc_id, .. } = tag {
alloc_id
} else {
// A wildcard pointer.
ecx.alloc_id_from_addr(addr.bytes(), size)?
this.alloc_id_from_addr(addr.bytes(), size)?
};

// This cannot fail: since we already have a pointer with that provenance, adjust_alloc_root_pointer
// must have been called in the past, so we can just look up the address in the map.
let base_addr = *ecx.machine.alloc_addresses.borrow().base_addr.get(&alloc_id).unwrap();
let base_addr = *this.machine.alloc_addresses.borrow().base_addr.get(&alloc_id).unwrap();

// Wrapping "addr - base_addr"
let rel_offset = ecx.truncate_to_target_usize(addr.bytes().wrapping_sub(base_addr));
let rel_offset = this.truncate_to_target_usize(addr.bytes().wrapping_sub(base_addr));
Some((alloc_id, Size::from_bytes(rel_offset)))
}
}
Expand Down