numa: Add optional sgx_epc_sections field to NumaConfig

This new option allows the user to define a list of SGX EPC sections
attached to a specific NUMA node.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-07-09 11:22:35 +02:00
parent 3987026997
commit 6b710209b1
5 changed files with 90 additions and 7 deletions
+26 -4
View File
@@ -103,12 +103,24 @@ impl MemoryAffinity {
proximity_domain: u32,
flags: MemAffinityFlags,
) -> Self {
let base_addr = region.start_addr().raw_value();
Self::from_range(
region.start_addr().raw_value(),
region.len(),
proximity_domain,
flags,
)
}
fn from_range(
base_addr: u64,
size: u64,
proximity_domain: u32,
flags: MemAffinityFlags,
) -> Self {
let base_addr_lo = (base_addr & 0xffff_ffff) as u32;
let base_addr_hi = (base_addr >> 32) as u32;
let length = region.len() as u64;
let length_lo = (length & 0xffff_ffff) as u32;
let length_hi = (length >> 32) as u32;
let length_lo = (size & 0xffff_ffff) as u32;
let length_hi = (size >> 32) as u32;
MemoryAffinity {
type_: 1,
@@ -254,6 +266,16 @@ fn create_srat_table(numa_nodes: &NumaNodes) -> Sdt {
))
}
#[cfg(target_arch = "x86_64")]
for section in node.sgx_epc_sections() {
srat.append(MemoryAffinity::from_range(
section.start().raw_value(),
section.size(),
proximity_domain,
MemAffinityFlags::ENABLE,
))
}
for cpu in node.cpus() {
let x2apic_id = *cpu as u32;