From be0a5269ab2f5ea4e8d8f659902491916aae127c Mon Sep 17 00:00:00 2001 From: Daniel Lubarov Date: Mon, 1 Aug 2022 21:21:35 -0700 Subject: [PATCH] UserspaceProgramCounter --- evm/src/cpu/kernel/context_metadata.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/evm/src/cpu/kernel/context_metadata.rs b/evm/src/cpu/kernel/context_metadata.rs index cf0bfc23..ff075814 100644 --- a/evm/src/cpu/kernel/context_metadata.rs +++ b/evm/src/cpu/kernel/context_metadata.rs @@ -5,17 +5,20 @@ pub(crate) enum ContextMetadata { ParentContext = 0, /// The program counter to return to when we return to the parent context. ParentProgramCounter = 1, - CalldataSize = 2, - ReturndataSize = 3, + /// If we're in a system call, this holds the userspace program counter to return to. + UserspaceProgramCounter = 2, + CalldataSize = 3, + ReturndataSize = 4, } impl ContextMetadata { - pub(crate) const COUNT: usize = 4; + pub(crate) const COUNT: usize = 5; pub(crate) fn all() -> [Self; Self::COUNT] { [ Self::ParentContext, Self::ParentProgramCounter, + Self::UserspaceProgramCounter, Self::CalldataSize, Self::ReturndataSize, ] @@ -26,6 +29,7 @@ impl ContextMetadata { match self { ContextMetadata::ParentContext => "CTX_METADATA_PARENT_CONTEXT", ContextMetadata::ParentProgramCounter => "CTX_METADATA_PARENT_PC", + ContextMetadata::UserspaceProgramCounter => "CTX_METADATA_USERSPACE_PC", ContextMetadata::CalldataSize => "CTX_METADATA_CALLDATA_SIZE", ContextMetadata::ReturndataSize => "CTX_METADATA_RETURNDATA_SIZE", }