diff --git a/Cargo.lock b/Cargo.lock index 1c364753b93992..048327850cc47c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6780,9 +6780,9 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe055100805e9069715acf73529ec563ad987a4d042da9defe9b7554560f2df4" +checksum = "b13ec17b58709d07634895dbca4cae6bebeaddf3b83bf4fa8dfeaf3621222347" dependencies = [ "byteorder", "combine", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 2d18a76502a11e..6fd332e29a41cb 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -22,7 +22,14 @@ humantime = "2.0.1" log = "0.4.17" num-traits = "0.2" pretty-hex = "0.3.0" -reqwest = { version = "0.11.12", default-features = false, features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] } +reqwest = { version = "0.11.12", default-features = false, features = [ + "blocking", + "brotli", + "deflate", + "gzip", + "rustls-tls", + "json" +] } semver = "1.0.14" serde = "1.0.144" serde_derive = "1.0.103" @@ -47,7 +54,7 @@ solana-tpu-client = { path = "../tpu-client", version = "=1.15.0" } solana-transaction-status = { path = "../transaction-status", version = "=1.15.0" } solana-version = { path = "../version", version = "=1.15.0" } solana-vote-program = { path = "../programs/vote", version = "=1.15.0" } -solana_rbpf = "=0.2.32" +solana_rbpf = "=0.2.33" spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] } thiserror = "1.0.31" tiny-bip39 = "0.8.2" diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index 47d4e1a8de72a9..c918cefea1ff06 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -5998,9 +5998,9 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe055100805e9069715acf73529ec563ad987a4d042da9defe9b7554560f2df4" +checksum = "b13ec17b58709d07634895dbca4cae6bebeaddf3b83bf4fa8dfeaf3621222347" dependencies = [ "byteorder 1.4.3", "combine", diff --git a/programs/bpf/Cargo.toml b/programs/bpf/Cargo.toml index 0f59f4db642428..6724e3c47f2575 100644 --- a/programs/bpf/Cargo.toml +++ b/programs/bpf/Cargo.toml @@ -38,7 +38,7 @@ solana-program-runtime = { path = "../../program-runtime", version = "=1.15.0" } solana-runtime = { path = "../../runtime", version = "=1.15.0" } solana-sdk = { path = "../../sdk", version = "=1.15.0" } solana-transaction-status = { path = "../../transaction-status", version = "=1.15.0" } -solana_rbpf = "=0.2.32" +solana_rbpf = "=0.2.33" [dev-dependencies] solana-ledger = { path = "../../ledger", version = "=1.15.0" } diff --git a/programs/bpf_loader/Cargo.toml b/programs/bpf_loader/Cargo.toml index d0fc87c5af3814..b4a2cd312bf055 100644 --- a/programs/bpf_loader/Cargo.toml +++ b/programs/bpf_loader/Cargo.toml @@ -19,7 +19,7 @@ solana-metrics = { path = "../../metrics", version = "=1.15.0" } solana-program-runtime = { path = "../../program-runtime", version = "=1.15.0" } solana-sdk = { path = "../../sdk", version = "=1.15.0" } solana-zk-token-sdk = { path = "../../zk-token-sdk", version = "=1.15.0" } -solana_rbpf = "=0.2.32" +solana_rbpf = "=0.2.33" thiserror = "1.0" [dev-dependencies] diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index 00f60f9099ddd8..951bd37c961ef3 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -187,6 +187,7 @@ pub fn create_executor( enable_elf_vaddr: false, reject_rodata_stack_overlap: false, new_elf_parser: false, + aligned_memory_mapping: true, // Warning, do not use `Config::default()` so that configuration here is explicit. }; let mut create_executor_metrics = executor_metrics::CreateMetrics::default(); diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index 52a82b99af588d..0134f1b94e1af6 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -2054,10 +2054,7 @@ mod tests { let addr = data.as_ptr() as u64; let config = Config::default(); let memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion::new_readonly(&data, START), - ], + vec![MemoryRegion::new_readonly(&data, START)], &config, ) .unwrap(); @@ -2097,16 +2094,13 @@ mod tests { let addr = &pubkey as *const _ as u64; let config = Config::default(); let memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: std::mem::size_of::() as u64, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: std::mem::size_of::() as u64, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2128,17 +2122,19 @@ mod tests { vm_gap_shift: 63, is_writable: false, }; - let mut memory_mapping = MemoryMapping::new::( - vec![MemoryRegion::default(), memory_region.clone()], - &config, - ) - .unwrap(); + let mut memory_mapping = + MemoryMapping::new::(vec![memory_region.clone()], &config).unwrap(); let translated_instruction = translate_type::(&memory_mapping, 0x100000000, true).unwrap(); assert_eq!(instruction, *translated_instruction); memory_region.len = 1; + let memory_region_index = memory_mapping + .get_regions() + .iter() + .position(|memory_region| memory_region.vm_addr == 0x100000000) + .unwrap(); memory_mapping - .replace_region::(1, memory_region) + .replace_region::(memory_region_index, memory_region) .unwrap(); assert!(translate_type::(&memory_mapping, 0x100000000, true).is_err()); } @@ -2152,16 +2148,13 @@ mod tests { let addr = good_data.as_ptr() as *const _ as u64; let config = Config::default(); let memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: good_data.len() as u64, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: good_data.len() as u64, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2174,16 +2167,13 @@ mod tests { let mut data = vec![1u8, 2, 3, 4, 5]; let addr = data.as_ptr() as *const _ as u64; let memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: data.len() as u64, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: data.len() as u64, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2211,16 +2201,13 @@ mod tests { let mut data = vec![1u64, 2, 3, 4, 5]; let addr = data.as_ptr() as *const _ as u64; let memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: (data.len() * size_of::()) as u64, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: (data.len() * size_of::()) as u64, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2238,16 +2225,13 @@ mod tests { let mut data = vec![solana_sdk::pubkey::new_rand(); 5]; let addr = data.as_ptr() as *const _ as u64; let memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: (data.len() * std::mem::size_of::()) as u64, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: (data.len() * std::mem::size_of::()) as u64, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2265,16 +2249,13 @@ mod tests { let addr = string.as_ptr() as *const _ as u64; let config = Config::default(); let memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: string.len() as u64, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: string.len() as u64, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2305,8 +2286,7 @@ mod tests { bpf_loader::id(), ); let config = Config::default(); - let mut memory_mapping = - MemoryMapping::new::(vec![MemoryRegion::default()], &config).unwrap(); + let mut memory_mapping = MemoryMapping::new::(vec![], &config).unwrap(); let mut result: Result> = Ok(0); SyscallAbort::call( &mut SyscallAbort { @@ -2340,16 +2320,13 @@ mod tests { let addr = string.as_ptr() as *const _ as u64; let config = Config::default(); let mut memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: string.len() as u64, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: string.len() as u64, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2412,16 +2389,13 @@ mod tests { let addr = string.as_ptr() as *const _ as u64; let config = Config::default(); let mut memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: string.len() as u64, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: string.len() as u64, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2549,16 +2523,13 @@ mod tests { let addr = pubkey.as_ref().first().unwrap() as *const _ as u64; let config = Config::default(); let mut memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: addr, - vm_addr: 0x100000000, - len: 32, - vm_gap_shift: 63, - is_writable: false, - }, - ], + vec![MemoryRegion { + host_addr: addr, + vm_addr: 0x100000000, + len: 32, + vm_gap_shift: 63, + is_writable: false, + }], &config, ) .unwrap(); @@ -2627,7 +2598,6 @@ mod tests { let mut heap = AlignedMemory::::zero_filled(100); let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion::new_readonly(&[], ebpf::MM_PROGRAM_START), MemoryRegion::new_writable_gapped(&mut [], ebpf::MM_STACK_START, 4096), MemoryRegion::new_writable(heap.as_slice_mut(), ebpf::MM_HEAP_START), @@ -2669,7 +2639,6 @@ mod tests { let mut heap = AlignedMemory::::zero_filled(100); let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion::new_readonly(&[], ebpf::MM_PROGRAM_START), MemoryRegion::new_writable_gapped(&mut [], ebpf::MM_STACK_START, 4096), MemoryRegion::new_writable(heap.as_slice_mut(), ebpf::MM_HEAP_START), @@ -2710,7 +2679,6 @@ mod tests { let mut heap = AlignedMemory::::zero_filled(100); let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion::new_readonly(&[], ebpf::MM_PROGRAM_START), MemoryRegion::new_writable_gapped(&mut [], ebpf::MM_STACK_START, 4096), MemoryRegion::new_writable(heap.as_slice_mut(), ebpf::MM_HEAP_START), @@ -2753,7 +2721,6 @@ mod tests { let config = Config::default(); let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion::new_readonly(&[], ebpf::MM_PROGRAM_START), MemoryRegion::new_writable_gapped(&mut [], ebpf::MM_STACK_START, 4096), MemoryRegion::new_writable(heap.as_slice_mut(), ebpf::MM_HEAP_START), @@ -2825,7 +2792,6 @@ mod tests { let rw_va = 0x200000000; let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion { host_addr: bytes_to_hash.as_ptr() as *const _ as u64, vm_addr: ro_va, @@ -2951,7 +2917,6 @@ mod tests { let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion { host_addr: valid_bytes.as_ptr() as *const _ as u64, vm_addr: valid_bytes_va, @@ -3052,7 +3017,6 @@ mod tests { let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion { host_addr: valid_bytes.as_ptr() as *const _ as u64, vm_addr: valid_bytes_va, @@ -3166,7 +3130,6 @@ mod tests { let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion { host_addr: left_point.as_ptr() as *const _ as u64, vm_addr: left_point_va, @@ -3373,7 +3336,6 @@ mod tests { let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion { host_addr: left_point.as_ptr() as *const _ as u64, vm_addr: left_point_va, @@ -3613,16 +3575,13 @@ mod tests { let got_clock_va = 0x100000000; let mut memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: &got_clock as *const _ as u64, - vm_addr: got_clock_va, - len: size_of::() as u64, - vm_gap_shift: 63, - is_writable: true, - }, - ], + vec![MemoryRegion { + host_addr: &got_clock as *const _ as u64, + vm_addr: got_clock_va, + len: size_of::() as u64, + vm_gap_shift: 63, + is_writable: true, + }], &config, ) .unwrap(); @@ -3650,16 +3609,13 @@ mod tests { let got_epochschedule_va = 0x100000000; let mut memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: &got_epochschedule as *const _ as u64, - vm_addr: got_epochschedule_va, - len: size_of::() as u64, - vm_gap_shift: 63, - is_writable: true, - }, - ], + vec![MemoryRegion { + host_addr: &got_epochschedule as *const _ as u64, + vm_addr: got_epochschedule_va, + len: size_of::() as u64, + vm_gap_shift: 63, + is_writable: true, + }], &config, ) .unwrap(); @@ -3696,16 +3652,13 @@ mod tests { let got_fees_va = 0x100000000; let mut memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: &got_fees as *const _ as u64, - vm_addr: got_fees_va, - len: size_of::() as u64, - vm_gap_shift: 63, - is_writable: true, - }, - ], + vec![MemoryRegion { + host_addr: &got_fees as *const _ as u64, + vm_addr: got_fees_va, + len: size_of::() as u64, + vm_gap_shift: 63, + is_writable: true, + }], &config, ) .unwrap(); @@ -3729,16 +3682,13 @@ mod tests { let got_rent_va = 0x100000000; let mut memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: &got_rent as *const _ as u64, - vm_addr: got_rent_va, - len: size_of::() as u64, - vm_gap_shift: 63, - is_writable: true, - }, - ], + vec![MemoryRegion { + host_addr: &got_rent as *const _ as u64, + vm_addr: got_rent_va, + len: size_of::() as u64, + vm_gap_shift: 63, + is_writable: true, + }], &config, ) .unwrap(); @@ -3775,7 +3725,6 @@ mod tests { let bump_seed = 0; let mut mock_slices = Vec::with_capacity(seeds.len()); let mut regions = vec![ - MemoryRegion::default(), MemoryRegion { host_addr: mock_slices.as_ptr() as u64, vm_addr: SEEDS_VA, @@ -3908,16 +3857,13 @@ mod tests { let mut memory = [0u8; END_OFFSET]; let config = Config::default(); let mut memory_mapping = MemoryMapping::new::( - vec![ - MemoryRegion::default(), - MemoryRegion { - host_addr: memory.as_mut_ptr() as u64, - vm_addr: VM_BASE_ADDRESS, - len: END_OFFSET as u64, - vm_gap_shift: 63, - is_writable: true, - }, - ], + vec![MemoryRegion { + host_addr: memory.as_mut_ptr() as u64, + vm_addr: VM_BASE_ADDRESS, + len: END_OFFSET as u64, + vm_gap_shift: 63, + is_writable: true, + }], &config, ) .unwrap(); @@ -4101,7 +4047,6 @@ mod tests { let config = Config::default(); let mut memory_mapping = MemoryMapping::new::( vec![ - MemoryRegion::default(), MemoryRegion { host_addr: keys.as_ptr() as u64, vm_addr: VM_ADDRESS_KEYS, diff --git a/rbpf-cli/Cargo.toml b/rbpf-cli/Cargo.toml index 5d00b001c88a68..47403d57bd3d8d 100644 --- a/rbpf-cli/Cargo.toml +++ b/rbpf-cli/Cargo.toml @@ -17,4 +17,4 @@ solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "=1.15. solana-logger = { path = "../logger", version = "=1.15.0" } solana-program-runtime = { path = "../program-runtime", version = "=1.15.0" } solana-sdk = { path = "../sdk", version = "=1.15.0" } -solana_rbpf = "=0.2.32" +solana_rbpf = "=0.2.33"