From 92f293800dc866073bd62c8d8fb5b148b38f5e31 Mon Sep 17 00:00:00 2001 From: Patrick Sabanic Date: Fri, 6 Dec 2024 15:34:13 +0000 Subject: [PATCH 1/3] Add memory channels with fixed address ranges to ProcessContext --- kernel/src/process_manager/allocation.rs | 63 ++++++++++++++++++++---- kernel/src/process_manager/mod.rs | 1 + kernel/src/process_manager/process.rs | 21 ++++++-- 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/kernel/src/process_manager/allocation.rs b/kernel/src/process_manager/allocation.rs index 3683c8872..e5c6dfcef 100644 --- a/kernel/src/process_manager/allocation.rs +++ b/kernel/src/process_manager/allocation.rs @@ -7,35 +7,80 @@ use crate::cpu::control_regs::read_cr3; use crate::{paddr_as_slice, map_paddr, vaddr_as_slice}; use crate::mm::PerCPUPageMappingGuard; +const ALLOCATION_VADDR_START: u64 = 0x30000000000u64; +pub const DEFAULT_ALLOCATION_RANGE_MOUNT: usize = 6; +const PGD_SHIFT: u64 = 39; #[repr(C)] -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Default)] pub struct AllocationRange(pub u64, pub u64); - impl AllocationRange { +impl AllocationRange { pub fn allocate(&mut self, pages: u64){ - // Reuses the Process page managment to add new memory to the Monitor let mut page_table_ref = ProcessPageTableRef::default(); page_table_ref.set_external_table(read_cr3().bits() as u64); + self.allocate_(&mut page_table_ref, pages, ALLOCATION_VADDR_START, true); + } + + pub fn allocate_with_start_addr(&mut self, page_table_ref: &mut ProcessPageTableRef, pages: u64, start_addr: u64){ + self.allocate_(page_table_ref, pages, start_addr, false); + } + + fn allocate_(&mut self, page_table_ref: &mut ProcessPageTableRef, pages: u64, start_addr: u64, mount: bool){ + // Reuses the Process page managment to add new memory to the Monitor + //let mut page_table_ref = ProcessPageTableRef::default(); + //page_table_ref.set_external_table(read_cr3().bits() as u64); let table_flags = ProcessPageFlags::PRESENT | ProcessPageFlags::WRITABLE | - ProcessPageFlags::DIRTY | ProcessPageFlags::ACCESSED; + ProcessPageFlags::DIRTY | ProcessPageFlags::ACCESSED; - let start_address = VirtAddr::from(0x30000000000u64); + let start_address = VirtAddr::from(start_addr); for i in 0..(pages as usize) { let current_page = allocate_page(); page_table_ref.map_4k_page(start_address + i * PAGE_SIZE, current_page, table_flags); }; + if mount { + let (_mapping, pgd) = paddr_as_slice!(read_cr3()); + self.0 = pgd[DEFAULT_ALLOCATION_RANGE_MOUNT]; + self.1 = pages; + } else { + let offset = start_addr >> PGD_SHIFT; + let (_mapping, pgd) = paddr_as_slice!(page_table_ref.process_page_table); + self.0 = pgd[offset as usize]; + self.1 = pages; + } + } - let (_mapping, pgd) = paddr_as_slice!(read_cr3()); - self.0 = pgd[6]; + pub fn inflate(&mut self, page_table_ref: &mut ProcessPageTableRef, pages: u64, start_addr: u64) { + if self.1 >= pages { + return; + } + let table_flags = ProcessPageFlags::PRESENT | ProcessPageFlags::WRITABLE | + ProcessPageFlags::DIRTY | ProcessPageFlags::ACCESSED; + let start_address = VirtAddr::from(start_addr); + let begin = self.1; + for i in 0..(pages as usize) { + let current_page = allocate_page(); + page_table_ref.map_4k_page(start_address + i * PAGE_SIZE, current_page, table_flags); + } self.1 = pages; - } pub fn mount(&self) { let (_mapping, pgd) = paddr_as_slice!(read_cr3()); - pgd[6] = self.0; + pgd[DEFAULT_ALLOCATION_RANGE_MOUNT] = self.0; + } + + pub fn mount_at(&self, loc: usize) -> u64 { + let (_mapping, pgd) = paddr_as_slice!(read_cr3()); + let old_table = pgd[loc]; + pgd[loc] = self.0; + return old_table; + } + + pub fn reset_mount(&self, loc: usize, t: u64) { + let (_mapping, pgd) = paddr_as_slice!(read_cr3()); + pgd[loc] = t; } pub fn delete(&self) { diff --git a/kernel/src/process_manager/mod.rs b/kernel/src/process_manager/mod.rs index d686a7ea0..78f50c2cd 100644 --- a/kernel/src/process_manager/mod.rs +++ b/kernel/src/process_manager/mod.rs @@ -10,6 +10,7 @@ pub mod process_memory; pub mod process_paging; pub mod memory_helper; pub mod allocation; +pub mod memory_channels; static MONITOR_INIT_STATE: ImmutAfterInitCell = ImmutAfterInitCell::new(false); const MONITOR_INIT_STATE_TRUE: bool = true; diff --git a/kernel/src/process_manager/process.rs b/kernel/src/process_manager/process.rs index 8a26ea743..ac0c6ed9d 100644 --- a/kernel/src/process_manager/process.rs +++ b/kernel/src/process_manager/process.rs @@ -2,9 +2,11 @@ extern crate alloc; use core::cell::UnsafeCell; use alloc::vec::Vec; +use igvm_defs::PAGE_SIZE_4K; use crate::address::PhysAddr; use crate::cpu::percpu::this_cpu_shared; use crate::cpu::percpu::this_cpu_unsafe; +use crate::mm::PAGE_SIZE; use crate::mm::SVSM_PERCPU_VMSA_BASE; use crate::process_manager::process_memory::allocate_page; use crate::process_manager::allocation::AllocationRange; @@ -25,6 +27,8 @@ use crate::vaddr_as_u64_slice; use cpuarch::vmsa::VMSA; use core::mem::replace; +use super::memory_channels::MemoryChannel; + trait FromVAddr { fn from_virt_addr(v: VirtAddr) -> &'static mut VMSA; } @@ -103,7 +107,7 @@ impl ProcessData { } } -#[derive(Clone,Copy,Debug)] +#[derive(Clone,Copy,Debug, Default)] pub struct ProcessID(pub usize); #[derive(Clone,Copy,Debug)] @@ -113,9 +117,7 @@ pub struct TrustedProcess { pub base: ProcessBaseContext, #[allow(dead_code)] pub context: ProcessContext, - /*input: VirtAddr, - output: VirtAddr, - pub hash: [u8; 32]i,*/ + //pub channel: MemoryChannel, } impl TrustedProcess { @@ -346,6 +348,7 @@ impl ProcessBaseContext { pub struct ProcessContext { pub base: ProcessBaseContext, pub vmsa: PhysAddr, + pub channel: MemoryChannel, pub sev_features: u64, } @@ -354,6 +357,7 @@ impl Default for ProcessContext { return ProcessContext { base: ProcessBaseContext::default(), vmsa: PhysAddr::null(), + channel: MemoryChannel::default(), sev_features: 0, } } @@ -402,6 +406,15 @@ impl ProcessContext { panic!("Failed to create new VMSA"); } + + //Memory Channel setup -- No chain setup here + let page_table_addr = vmsa.cr3; + let mut pptr = ProcessPageTableRef::default(); + pptr.set_external_table(page_table_addr); + self.channel.allocate_input(&mut pptr, PAGE_SIZE); + self.channel.allocate_output(&mut pptr, PAGE_SIZE); + + self.vmsa = new_vmsa_page; self.sev_features = vmsa.sev_features; self.base = base; From ef6ed2ff776986aafc1f900938f96ed3dee69bba Mon Sep 17 00:00:00 2001 From: Patrick Sabanic Date: Fri, 6 Dec 2024 17:45:24 +0000 Subject: [PATCH 2/3] Add memory channel for single Trustlet use --- kernel/src/process_manager/allocation.rs | 2 +- kernel/src/process_manager/memory_channels.rs | 70 +++++++++++++++++++ kernel/src/process_manager/process.rs | 12 +++- kernel/src/process_manager/process_paging.rs | 8 ++- kernel/src/process_runtime/runtime.rs | 4 ++ 5 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 kernel/src/process_manager/memory_channels.rs diff --git a/kernel/src/process_manager/allocation.rs b/kernel/src/process_manager/allocation.rs index e5c6dfcef..865f9018c 100644 --- a/kernel/src/process_manager/allocation.rs +++ b/kernel/src/process_manager/allocation.rs @@ -84,7 +84,7 @@ impl AllocationRange { } pub fn delete(&self) { - todo!("Not implemented"); + } } diff --git a/kernel/src/process_manager/memory_channels.rs b/kernel/src/process_manager/memory_channels.rs new file mode 100644 index 000000000..7b6940952 --- /dev/null +++ b/kernel/src/process_manager/memory_channels.rs @@ -0,0 +1,70 @@ +use crate::{address::VirtAddr, mm::PAGE_SIZE, process_manager::process_memory::ALLOCATION_RANGE_VIRT_START}; + +use super::{allocation::AllocationRange, process::ProcessID, process_paging::ProcessPageTableRef}; + +pub const INPUT_VADDR: u64 = 0xFF0000000000u64; +pub const OUTPUT_VADDR: u64 = 0xFF8000000000u64; + +#[derive(Debug, Clone, Copy, Default)] +pub struct MemoryChannel { + pub input: AllocationRange, + pub output: AllocationRange, + pub owner: ProcessID, + pub last_in_channel: bool, + pub next: ProcessID, +} + +impl MemoryChannel { + + pub fn allocate_input(&mut self, page_table_ref: &mut ProcessPageTableRef, size: usize) { + self.input = self.allocate_range(page_table_ref, size, INPUT_VADDR); + } + + pub fn allocate_output(&mut self, page_table_ref: &mut ProcessPageTableRef, size: usize) { + self.output = self.allocate_range(page_table_ref, size, OUTPUT_VADDR); + } + + pub fn inflate_input(&mut self, page_table_ref: &mut ProcessPageTableRef, size: usize) { + let page_count = (size + PAGE_SIZE - (size % PAGE_SIZE)) / PAGE_SIZE; + self.input.inflate(page_table_ref, page_count as u64, INPUT_VADDR); + } + + pub fn inflate_output(&mut self, page_table_ref: &mut ProcessPageTableRef, size: usize) { + let page_count = (size + PAGE_SIZE - (size % PAGE_SIZE)) / PAGE_SIZE; + self.output.inflate(page_table_ref, page_count as u64, OUTPUT_VADDR); + } + + pub fn copy_into(&mut self, source_addr: u64, page_table: u64, size: usize) { + let copy_size = size + PAGE_SIZE - (size % PAGE_SIZE); + let copy_page_count = copy_size / PAGE_SIZE; + let target = VirtAddr::from(ALLOCATION_RANGE_VIRT_START); + + let mut page_table_ref = ProcessPageTableRef::default(); + page_table_ref.set_external_table(page_table); + + self.input.mount(); + + page_table_ref.copy_address_range(VirtAddr::from(source_addr), copy_size as u64, target); + + } + + pub fn copy_out(&mut self, target_addr: u64, page_table: u64, size: usize) { + let copy_size = size + PAGE_SIZE - (size % PAGE_SIZE); + let copy_page_count = copy_size / PAGE_SIZE; + let target = VirtAddr::from(ALLOCATION_RANGE_VIRT_START); + let mut page_table_ref = ProcessPageTableRef::default(); + page_table_ref.set_external_table(page_table); + + self.output.mount(); + + page_table_ref.copy_address_range(VirtAddr::from(target), copy_size as u64, VirtAddr::from(target_addr)); + } + + fn allocate_range(&mut self, page_table_ref: &mut ProcessPageTableRef, size: usize, start: u64) -> AllocationRange{ + let mut r = AllocationRange::default(); + let page_count = (size + PAGE_SIZE - (size % PAGE_SIZE)) / PAGE_SIZE; + r.allocate_with_start_addr(page_table_ref, page_count as u64, start); + return r; + } + +} diff --git a/kernel/src/process_manager/process.rs b/kernel/src/process_manager/process.rs index ac0c6ed9d..5c7b628c3 100644 --- a/kernel/src/process_manager/process.rs +++ b/kernel/src/process_manager/process.rs @@ -173,9 +173,14 @@ impl TrustedProcess { } - pub fn trustlet(parent: ProcessID, _data: u64, _size: u64, _pgt: u64) -> Self{ + pub fn trustlet(parent: ProcessID, data: u64, size: u64, pgt: u64) -> Self{ // Inherit the data from the Zygote let trustlet = TrustedProcess::dublicate(parent); + if data != 0 { + let (function_code, function_code_range) = ProcessPageTableRef::copy_data_from_guest(data, size, pgt); + trustlet.base.page_table_ref.add_function(function_code, size); + function_code_range.delete(); + } trustlet } @@ -421,6 +426,11 @@ impl ProcessContext { } + pub fn add_function(&mut self, function: VirtAddr, size: u64) { + let size = size + PAGE_SIZE_4K - (size % PAGE_SIZE_4K); + self.base.page_table_ref.add_function(function, size); + } + pub fn test_run(&self) { let apic_id = this_cpu().get_apic_id(); log::info!("Trying to execute Context"); diff --git a/kernel/src/process_manager/process_paging.rs b/kernel/src/process_manager/process_paging.rs index 0d900d92d..e5f8c87ae 100644 --- a/kernel/src/process_manager/process_paging.rs +++ b/kernel/src/process_manager/process_paging.rs @@ -286,6 +286,12 @@ impl ProcessPageTableRef { self.add_region_vaddr(VirtAddr::from(0x18000000000u64), data); } + pub fn add_function(&self, data:VirtAddr, size: u64) { + let data: *mut u8 = data.as_mut_ptr::(); + let data = unsafe { slice::from_raw_parts(data, size as usize) }; + self.add_region_vaddr(VirtAddr::from(0xFE8000000000u64), data); + } + pub fn add_pages(&self, start: VirtAddr, size: u64, flags: ProcessPageFlags) { for i in 0..(size as usize) { let new_page = allocate_page(); @@ -394,7 +400,7 @@ impl ProcessPageTableRef { pub fn virt_to_phys(&self, vaddr: VirtAddr) -> PhysAddr { let (_pgd_mapping, pgd_table) = paddr_as_table!(self.process_page_table); let mut current_mapping = self.page_walk(&pgd_table, self.process_page_table, vaddr); - log::info!("Current Mapping {:?}", current_mapping); + //log::info!("Current Mapping {:?}", current_mapping); match current_mapping { ProcessTableLevelMapping::PTE(addr, index) => { let (_mapping, table) = paddr_as_u64_slice!(addr); diff --git a/kernel/src/process_runtime/runtime.rs b/kernel/src/process_runtime/runtime.rs index 30a6b21d8..6c7cba739 100644 --- a/kernel/src/process_runtime/runtime.rs +++ b/kernel/src/process_runtime/runtime.rs @@ -37,6 +37,8 @@ pub fn invoke_trustlet(params: &mut RequestParams) -> Result<(), SvsmReqError> { log::info!("Invoking Trustlet"); let id = params.rcx; + let function_arg = params.r8; + let function_arg_size = params.r9; let trustlet = PROCESS_STORE.get(ProcessID(id.try_into().unwrap())); @@ -53,6 +55,8 @@ pub fn invoke_trustlet(params: &mut RequestParams) -> Result<(), SvsmReqError> { let mut string_pos: usize = 0; let sev_features = trustlet.context.sev_features; + trustlet.context.channel.copy_into(function_arg, vmsa.cr3, function_arg_size as usize); + let mut rc = PALContext{ process: trustlet, From b68ce76071260454a047eb9fedc7c605809ed54f Mon Sep 17 00:00:00 2001 From: Patrick Sabanic Date: Mon, 9 Dec 2024 14:36:19 +0000 Subject: [PATCH 3/3] Fix Problems with memory channels Set new ranges for input and output Add rmp_adjust for new memory Fix input copy --- kernel/src/process_manager/allocation.rs | 18 ++++++++++++++---- kernel/src/process_manager/memory_channels.rs | 13 ++++++------- kernel/src/process_manager/process.rs | 1 + kernel/src/process_manager/process_paging.rs | 17 +++++++++++++++-- kernel/src/process_runtime/runtime.rs | 4 ++-- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/kernel/src/process_manager/allocation.rs b/kernel/src/process_manager/allocation.rs index 865f9018c..75cf09723 100644 --- a/kernel/src/process_manager/allocation.rs +++ b/kernel/src/process_manager/allocation.rs @@ -4,6 +4,8 @@ use crate::address::{Address, VirtAddr}; use crate::process_manager::process_paging::ProcessPageTableRef; use crate::process_manager::process_paging::ProcessPageFlags; use crate::cpu::control_regs::read_cr3; +use crate::sev::{rmp_adjust, RMPFlags}; +use crate::types::PageSize; use crate::{paddr_as_slice, map_paddr, vaddr_as_slice}; use crate::mm::PerCPUPageMappingGuard; @@ -19,24 +21,32 @@ impl AllocationRange { pub fn allocate(&mut self, pages: u64){ let mut page_table_ref = ProcessPageTableRef::default(); page_table_ref.set_external_table(read_cr3().bits() as u64); - self.allocate_(&mut page_table_ref, pages, ALLOCATION_VADDR_START, true); + self.allocate_(&mut page_table_ref, pages, ALLOCATION_VADDR_START, true, false); } pub fn allocate_with_start_addr(&mut self, page_table_ref: &mut ProcessPageTableRef, pages: u64, start_addr: u64){ - self.allocate_(page_table_ref, pages, start_addr, false); + self.allocate_(page_table_ref, pages, start_addr, false, true); } - fn allocate_(&mut self, page_table_ref: &mut ProcessPageTableRef, pages: u64, start_addr: u64, mount: bool){ + fn allocate_(&mut self, page_table_ref: &mut ProcessPageTableRef, pages: u64, start_addr: u64, mount: bool, user: bool){ // Reuses the Process page managment to add new memory to the Monitor //let mut page_table_ref = ProcessPageTableRef::default(); //page_table_ref.set_external_table(read_cr3().bits() as u64); - let table_flags = ProcessPageFlags::PRESENT | ProcessPageFlags::WRITABLE | + let mut table_flags = ProcessPageFlags::PRESENT | ProcessPageFlags::WRITABLE | ProcessPageFlags::DIRTY | ProcessPageFlags::ACCESSED; + if user { + table_flags = table_flags | ProcessPageFlags::USER_ACCESSIBLE; + } + let start_address = VirtAddr::from(start_addr); for i in 0..(pages as usize) { let current_page = allocate_page(); + if !mount { + let (mapping, _page_mapped) = paddr_as_slice!(current_page); + rmp_adjust(mapping.virt_addr(), RMPFlags::VMPL1 | RMPFlags::RWX, PageSize::Regular); + } page_table_ref.map_4k_page(start_address + i * PAGE_SIZE, current_page, table_flags); }; if mount { diff --git a/kernel/src/process_manager/memory_channels.rs b/kernel/src/process_manager/memory_channels.rs index 7b6940952..4969b2c0a 100644 --- a/kernel/src/process_manager/memory_channels.rs +++ b/kernel/src/process_manager/memory_channels.rs @@ -1,9 +1,11 @@ -use crate::{address::VirtAddr, mm::PAGE_SIZE, process_manager::process_memory::ALLOCATION_RANGE_VIRT_START}; +use log::Metadata; + +use crate::{address::{PhysAddr, VirtAddr}, map_paddr, mm::{PerCPUPageMappingGuard, PAGE_SIZE}, paddr_as_slice, process_manager::process_memory::ALLOCATION_RANGE_VIRT_START, vaddr_as_slice}; use super::{allocation::AllocationRange, process::ProcessID, process_paging::ProcessPageTableRef}; -pub const INPUT_VADDR: u64 = 0xFF0000000000u64; -pub const OUTPUT_VADDR: u64 = 0xFF8000000000u64; +pub const INPUT_VADDR: u64 = 0x28000000000u64; +pub const OUTPUT_VADDR: u64 = 0x30000000000u64; #[derive(Debug, Clone, Copy, Default)] pub struct MemoryChannel { @@ -38,14 +40,11 @@ impl MemoryChannel { let copy_size = size + PAGE_SIZE - (size % PAGE_SIZE); let copy_page_count = copy_size / PAGE_SIZE; let target = VirtAddr::from(ALLOCATION_RANGE_VIRT_START); - let mut page_table_ref = ProcessPageTableRef::default(); page_table_ref.set_external_table(page_table); self.input.mount(); - - page_table_ref.copy_address_range(VirtAddr::from(source_addr), copy_size as u64, target); - + ProcessPageTableRef::copy_data_from_guest_to(source_addr, size as u64, page_table, ALLOCATION_RANGE_VIRT_START); } pub fn copy_out(&mut self, target_addr: u64, page_table: u64, size: usize) { diff --git a/kernel/src/process_manager/process.rs b/kernel/src/process_manager/process.rs index 5c7b628c3..d359e8d91 100644 --- a/kernel/src/process_manager/process.rs +++ b/kernel/src/process_manager/process.rs @@ -178,6 +178,7 @@ impl TrustedProcess { let trustlet = TrustedProcess::dublicate(parent); if data != 0 { let (function_code, function_code_range) = ProcessPageTableRef::copy_data_from_guest(data, size, pgt); + let size = (4096 - (size & 0xFFF)) + size; trustlet.base.page_table_ref.add_function(function_code, size); function_code_range.delete(); } diff --git a/kernel/src/process_manager/process_paging.rs b/kernel/src/process_manager/process_paging.rs index e5f8c87ae..79ec7bbf7 100644 --- a/kernel/src/process_manager/process_paging.rs +++ b/kernel/src/process_manager/process_paging.rs @@ -12,7 +12,7 @@ use core::mem::replace; use crate::types::PageSize; use super::process_memory::{ALLOCATION_RANGE_VIRT_START, PGD, PMD, PTE, PUD}; use crate::process_manager::allocation::AllocationRange; - +use core::ffi::CStr; use super::memory_helper::{ZERO_PAGE}; // Flags for the Page Table @@ -289,7 +289,7 @@ impl ProcessPageTableRef { pub fn add_function(&self, data:VirtAddr, size: u64) { let data: *mut u8 = data.as_mut_ptr::(); let data = unsafe { slice::from_raw_parts(data, size as usize) }; - self.add_region_vaddr(VirtAddr::from(0xFE8000000000u64), data); + self.add_region_vaddr(VirtAddr::from(0x140_0000_0000u64), data); } pub fn add_pages(&self, start: VirtAddr, size: u64, flags: ProcessPageFlags) { @@ -346,6 +346,7 @@ impl ProcessPageTableRef { let mut index = ProcessPageTable::index::(addr); let mut table_entry = table[index]; + let mut _mapping: PerCPUPageMappingGuard; //let mut prev_addr = table_entry.0; @@ -424,6 +425,7 @@ impl ProcessPageTableRef { let target = VirtAddr::from(ALLOCATION_RANGE_VIRT_START); let mut page_table_ref = ProcessPageTableRef::default(); + page_table_ref.set_external_table(page_table); page_table_ref.copy_address_range(VirtAddr::from(addr), copy_size, target); @@ -431,6 +433,17 @@ impl ProcessPageTableRef { (target, alloc_range) } + pub fn copy_data_from_guest_to(addr: u64, size: u64, page_table: u64, dst: u64) { + let copy_size = size + (PAGE_SIZE_4K - size % PAGE_SIZE_4K); + let copy_page_count = copy_size / PAGE_SIZE_4K; + let target = VirtAddr::from(dst); + + let mut page_table_ref = ProcessPageTableRef::default(); + page_table_ref.set_external_table(page_table); + page_table_ref.copy_address_range(VirtAddr::from(addr), copy_size, target); + } + + pub fn map_4k_page(&self, target: VirtAddr, addr: PhysAddr, flags: ProcessPageFlags) { let (_pgd_mapping, pgd_table) = paddr_as_table!(self.process_page_table); let mut current_mapping = self.page_walk(&pgd_table, self.process_page_table, target); diff --git a/kernel/src/process_runtime/runtime.rs b/kernel/src/process_runtime/runtime.rs index 6c7cba739..147b9f201 100644 --- a/kernel/src/process_runtime/runtime.rs +++ b/kernel/src/process_runtime/runtime.rs @@ -39,6 +39,7 @@ pub fn invoke_trustlet(params: &mut RequestParams) -> Result<(), SvsmReqError> { let id = params.rcx; let function_arg = params.r8; let function_arg_size = params.r9; + let guest_page_table = params.rdx; let trustlet = PROCESS_STORE.get(ProcessID(id.try_into().unwrap())); @@ -55,8 +56,7 @@ pub fn invoke_trustlet(params: &mut RequestParams) -> Result<(), SvsmReqError> { let mut string_pos: usize = 0; let sev_features = trustlet.context.sev_features; - trustlet.context.channel.copy_into(function_arg, vmsa.cr3, function_arg_size as usize); - + trustlet.context.channel.copy_into(function_arg, guest_page_table, function_arg_size as usize); let mut rc = PALContext{ process: trustlet,