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

Cleanup memory map #304

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 6 additions & 10 deletions risc0/build/risc0.ld
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ OUTPUT_ARCH(riscv)
ENTRY(_start)
EXTERN(__start)

/* Must match risc0/zkvm/platform/memory.h and zkvm/sdk/rust/platform/src/memory.rs */
/* Write-only section must match the range hardcoded in the circuit. */
/* Must match risc0/zkvm/platform/src/memory.rs */
MEMORY {
stack : ORIGIN = 0x00000000, LENGTH = 9M
data (RW) : ORIGIN = 0x00900000, LENGTH = 1M
heap : ORIGIN = 0x00A00000, LENGTH = 20M
input : ORIGIN = 0x01E00000, LENGTH = 1M
gpio : ORIGIN = 0x01F00000, LENGTH = 1M
prog (X) : ORIGIN = 0x02000000, LENGTH = 10M
sha : ORIGIN = 0x02A00000, LENGTH = 1M
wom : ORIGIN = 0x02B00000, LENGTH = 21M
stack : ORIGIN = 0x00000000, LENGTH = 16M
data (RW) : ORIGIN = 0x01000000, LENGTH = 16M
heap : ORIGIN = 0x02000000, LENGTH = 32M
input : ORIGIN = 0x04000000, LENGTH = 32M
prog (X) : ORIGIN = 0x06000000, LENGTH = 32M
}

SECTIONS {
Expand Down
22 changes: 9 additions & 13 deletions risc0/zkvm/platform/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use super::WORD_SIZE;

pub const MEM_BITS: usize = 24;
pub const MEM_BITS: usize = 28;
pub const MEM_SIZE: usize = (1 << MEM_BITS) * 4;

pub struct Region {
Expand Down Expand Up @@ -53,17 +53,13 @@ impl Region {
}
}

// These should match zkvm/platform/memory.h and zkvm/platform/risc0.ld.
// Write-only section must match the range hardcoded in the circuit.
pub const STACK: Region = Region::new(0x0000_0000, mb(9));
pub const DATA: Region = Region::new(0x0090_0000, mb(1));
pub const HEAP: Region = Region::new(0x00A0_0000, mb(20));
pub const INPUT: Region = Region::new(0x01E0_0000, mb(1));
pub const GPIO: Region = Region::new(0x01F0_0000, mb(1));
pub const PROG: Region = Region::new(0x0200_0000, mb(10));
pub const SHA: Region = Region::new(0x02A0_0000, mb(1));
pub const WOM: Region = Region::new(0x02B0_0000, mb(21));
pub const OUTPUT: Region = Region::new(0x02B0_0000, mb(20));
pub const COMMIT: Region = Region::new(0x03F0_0000, mb(1));
// These should match the linker script in `risc0/build/risc0.ld`.
pub const STACK: Region = Region::new(0x0000_0000, mb(16));
pub const DATA: Region = Region::new(0x0100_0000, mb(16));
pub const HEAP: Region = Region::new(0x0200_0000, mb(32));
pub const INPUT: Region = Region::new(0x0400_0000, mb(32));
pub const PROG: Region = Region::new(0x0600_0000, mb(32));
pub const OUTPUT: Region = Region::new(0x0800_0000, mb(32));
pub const COMMIT: Region = Region::new(0x0A00_0000, mb(32));
pub const SYSTEM: Region = Region::new(0x0C00_0000, mb(64));
pub const FFPU: Region = Region::new(0x0C00_0000 + 192 * WORD_SIZE, mb(64) - 192 * WORD_SIZE);
1 change: 0 additions & 1 deletion risc0/zkvm/src/guest/sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use core::{

use risc0_zkp::core::sha::{Digest, DIGEST_WORDS, SHA256_INIT};
use risc0_zkvm_platform::{
memory,
syscall::{sys_sha_buffer, sys_sha_compress},
WORD_SIZE,
};
Expand Down