Skip to content

Commit

Permalink
SVSM/percpu: Add Request Processing WaitQueue
Browse files Browse the repository at this point in the history
Add a waitqueue which will be used to start and stop a separate task
for request processing.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
joergroedel committed Jan 19, 2024
1 parent 4927a08 commit ba6d560
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/cpu/percpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::mm::{
use crate::sev::ghcb::GHCB;
use crate::sev::utils::RMPFlags;
use crate::sev::vmsa::allocate_new_vmsa;
use crate::task::{RunQueue, TaskPointer};
use crate::task::{RunQueue, TaskPointer, WaitQueue};
use crate::types::{PAGE_SHIFT, PAGE_SHIFT_2M, PAGE_SIZE, PAGE_SIZE_2M, SVSM_TR_FLAGS, SVSM_TSS};
use alloc::sync::Arc;
use alloc::vec::Vec;
Expand Down Expand Up @@ -238,9 +238,20 @@ pub struct PerCpu {

/// Task list that has been assigned for scheduling on this CPU
runqueue: RWLock<RunQueue>,

/// WaitQueue for request processing
request_waitqueue: WaitQueue,
}

impl PerCpu {
pub fn wait_for_requests(&mut self) {
self.request_waitqueue.wait_for_event();
}

pub fn process_requests(&mut self) {
self.request_waitqueue.wakeup();
}

fn new(apic_id: u32, shared: &'static PerCpuShared) -> Self {
PerCpu {
shared,
Expand All @@ -257,6 +268,7 @@ impl PerCpu {
vrange_4k: VirtualRange::new(),
vrange_2m: VirtualRange::new(),
runqueue: RWLock::new(RunQueue::new()),
request_waitqueue: WaitQueue::new(),
}
}

Expand Down

0 comments on commit ba6d560

Please sign in to comment.