risc0_zkvm_platform/
memory.rs

1// Copyright 2025 RISC Zero, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15pub const GUEST_MIN_MEM: usize = 0x0000_4000;
16pub const GUEST_MAX_MEM: usize = 0xC000_0000;
17
18/// Top of stack; stack grows down from this location.
19pub const STACK_TOP: u32 = 0x0020_0400;
20
21/// Program (text followed by data and then bss) gets loaded in
22/// starting at this location.  HEAP begins right afterwards.
23pub const TEXT_START: u32 = 0x0020_0800;
24
25/// Returns whether `addr` is within guest memory bounds.
26pub fn is_guest_memory(addr: u32) -> bool {
27    GUEST_MIN_MEM <= (addr as usize) && (addr as usize) < GUEST_MAX_MEM
28}