Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add more validation for DeallocChunk messages
Fixes #574 Fixes #575 Fixes #576 Also set timeout on tests. They all currently complete in <1s, so a 30s timeout is plenty.
- Loading branch information
1 parent
dbd6da4
commit b75b96b
Showing
7 changed files
with
253 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
experiments/process_sandbox/include/process_sandbox/sandbox_meta_entry.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright Microsoft and Project Verona Contributors. | ||
// SPDX-License-Identifier: MIT | ||
|
||
#pragma once | ||
|
||
#include <snmalloc/snmalloc_core.h> | ||
|
||
namespace sandbox | ||
{ | ||
/** | ||
* Pagemap entry. Extends the front-end's version to use one bit to identify | ||
* pagemap entries as owned by the child. | ||
*/ | ||
class SandboxMetaEntry | ||
: public snmalloc::FrontendMetaEntry<snmalloc::FrontendSlabMetadata> | ||
{ | ||
/** | ||
* Bit set if this metaentry is owned by the sandbox. | ||
*/ | ||
static constexpr snmalloc::address_t SANDBOX_BIT = 1 << 3; | ||
|
||
public: | ||
/** | ||
* Inherit all constructors. | ||
*/ | ||
using snmalloc::FrontendMetaEntry< | ||
snmalloc::FrontendSlabMetadata>::FrontendMetaEntry; | ||
|
||
/** | ||
* Does this metaentry correspond to sandbox-owned memory | ||
*/ | ||
bool is_sandbox_owned() const | ||
{ | ||
return (meta & SANDBOX_BIT) == SANDBOX_BIT; | ||
} | ||
|
||
/** | ||
* Claim this entry for the sandbox. | ||
*/ | ||
void claim_for_sandbox() | ||
{ | ||
meta |= SANDBOX_BIT; | ||
} | ||
|
||
[[nodiscard]] bool is_unowned() const | ||
{ | ||
auto m = meta & ~SANDBOX_BIT; | ||
return ((m == 0) || (m == META_BOUNDARY_BIT)) && | ||
(remote_and_sizeclass == 0); | ||
} | ||
|
||
[[nodiscard]] SNMALLOC_FAST_PATH snmalloc::FrontendSlabMetadata* | ||
get_slab_metadata() const | ||
{ | ||
SNMALLOC_ASSERT(get_remote() != nullptr); | ||
auto m = meta & ~(SANDBOX_BIT | META_BOUNDARY_BIT); | ||
return snmalloc::unsafe_from_uintptr<snmalloc::FrontendSlabMetadata>(m); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters