Skip to content

Commit b9384b3

Browse files
committed
Pausing work to create a PR
1 parent a65b17d commit b9384b3

File tree

7 files changed

+58
-15
lines changed

7 files changed

+58
-15
lines changed

vm/devices/storage/disk_nvme/nvme_driver/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use mesh::CellUpdater;
1212
use nvme::NvmeControllerCaps;
1313
use nvme_resources::fault::AdminQueueFaultConfig;
1414
use nvme_resources::fault::FaultConfiguration;
15-
use nvme_resources::fault::QueueFaultBehavior;
15+
use nvme_resources::fault::FaultBehaviour;
1616
use nvme_spec::AdminOpcode;
1717
use nvme_spec::Cap;
1818
use nvme_spec::Command;
@@ -48,7 +48,7 @@ async fn test_nvme_command_fault(driver: DefaultDriver) {
4848
fault_active: CellUpdater::new(true).cell(),
4949
admin_fault: AdminQueueFaultConfig::new().with_submission_queue_fault(
5050
AdminOpcode::CREATE_IO_COMPLETION_QUEUE.0,
51-
QueueFaultBehavior::Update(output_cmd),
51+
FaultBehaviour::Update(output_cmd),
5252
),
5353
},
5454
)

vm/devices/storage/nvme_resources/src/fault.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::time::Duration;
1010

1111
/// Supported fault behaviour for NVMe queues
1212
#[derive(Debug, Clone, Copy, MeshPayload)]
13-
pub enum QueueFaultBehavior<T> {
13+
pub enum FaultBehaviour<T> {
1414
/// Update the queue entry with the returned data
1515
Update(T),
1616
/// Drop the queue entry
@@ -21,11 +21,18 @@ pub enum QueueFaultBehavior<T> {
2121
Delay(Duration),
2222
}
2323

24+
#[derive(MeshPayload)]
25+
/// A buildable fault configuration for the controller management interface (cc.en(), csts.rdy(), ... )
26+
pub struct ControllerManagementFaultConfig {
27+
/// Fault to apply to cc.en() bit during enablement
28+
pub controller_management_fault_enable: FaultBehaviour<bool>,
29+
}
30+
2431
#[derive(MeshPayload, Clone)]
2532
/// A buildable fault configuration
2633
pub struct AdminQueueFaultConfig {
2734
/// A map of NVME opcodes to the fault behavior for each. (This would ideally be a `HashMap`, but `mesh` doesn't support that type. Given that this is not performance sensitive, the lookup is okay)
28-
pub admin_submission_queue_faults: Vec<(u8, QueueFaultBehavior<Command>)>,
35+
pub admin_submission_queue_faults: Vec<(u8, FaultBehaviour<Command>)>,
2936
}
3037

3138
#[derive(MeshPayload, Clone)]
@@ -35,6 +42,26 @@ pub struct FaultConfiguration {
3542
pub fault_active: Cell<bool>,
3643
/// Fault to apply to the admin queues
3744
pub admin_fault: AdminQueueFaultConfig,
45+
/// Fault to apply to management layer of the controller
46+
pub controller_management_fault: ControllerManagementFaultConfig,
47+
}
48+
49+
impl ControllerManagementFaultConfig {
50+
/// Create a new no-op fault configuration
51+
pub fn new() -> Self {
52+
Self {
53+
controller_management_fault_enable: FaultBehaviour::Default,
54+
}
55+
}
56+
57+
/// Create a new fault configuration
58+
pub fn with_controller_management_enable_fault(
59+
mut self,
60+
behaviour: FaultBehaviour<bool>,
61+
) -> Self {
62+
self.controller_management_fault_enable = behaviour;
63+
self
64+
}
3865
}
3966

4067
impl AdminQueueFaultConfig {
@@ -49,7 +76,7 @@ impl AdminQueueFaultConfig {
4976
pub fn with_submission_queue_fault(
5077
mut self,
5178
opcode: u8,
52-
behaviour: QueueFaultBehavior<Command>,
79+
behaviour: FaultBehaviour<Command>,
5380
) -> Self {
5481
if self
5582
.admin_submission_queue_faults

vm/devices/storage/nvme_test/src/pci.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ pub struct NvmeFaultController {
5959
qe_sizes: Arc<Mutex<IoQueueEntrySizes>>,
6060
#[inspect(flatten, mut)]
6161
workers: NvmeWorkers,
62+
#[inspect(skip)]
63+
fault_configuration: FaultConfiguration,
6264
}
6365

6466
#[derive(Inspect)]
@@ -341,6 +343,9 @@ impl NvmeFaultController {
341343

342344
if cc.en() != self.registers.cc.en() {
343345
if cc.en() {
346+
// If any, perform the fault at the beginning of the enable sequence.
347+
if
348+
344349
// Some drivers will write zeros to IOSQES and IOCQES, assuming that the defaults will work.
345350
if cc.iocqes() == 0 {
346351
cc.set_iocqes(IOCQES);
@@ -384,6 +389,8 @@ impl NvmeFaultController {
384389
}
385390
}
386391

392+
393+
387394
self.registers.cc = cc;
388395
*self.qe_sizes.lock() = IoQueueEntrySizes {
389396
sqe_bits: cc.iosqes(),

vm/devices/storage/nvme_test/src/tests/controller_tests.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use guestmem::GuestMemory;
1717
use guid::Guid;
1818
use mesh::CellUpdater;
1919
use nvme_resources::fault::AdminQueueFaultConfig;
20+
use nvme_resources::fault::ControllerManagementFaultConfig;
21+
use nvme_resources::fault::FaultBehaviour;
2022
use nvme_resources::fault::FaultConfiguration;
21-
use nvme_resources::fault::QueueFaultBehavior;
2223
use nvme_spec::Command;
2324
use nvme_spec::Completion;
2425
use pal_async::DefaultDriver;
@@ -208,6 +209,7 @@ async fn test_basic_registers(driver: DefaultDriver) {
208209
let fault_configuration = FaultConfiguration {
209210
fault_active: CellUpdater::new(false).cell(),
210211
admin_fault: AdminQueueFaultConfig::new(),
212+
controller_management_fault: ControllerManagementFaultConfig::new(),
211213
};
212214
let mut nvmec = instantiate_controller(driver, &gm, None, fault_configuration);
213215
let mut dword = 0u32;
@@ -236,6 +238,7 @@ async fn test_invalid_configuration(driver: DefaultDriver) {
236238
let fault_configuration = FaultConfiguration {
237239
fault_active: CellUpdater::new(false).cell(),
238240
admin_fault: AdminQueueFaultConfig::new(),
241+
controller_management_fault: ControllerManagementFaultConfig::new(),
239242
};
240243
let mut nvmec = instantiate_controller(driver, &gm, None, fault_configuration);
241244
let mut dword = 0u32;
@@ -254,6 +257,7 @@ async fn test_enable_controller(driver: DefaultDriver) {
254257
let fault_configuration = FaultConfiguration {
255258
fault_active: CellUpdater::new(false).cell(),
256259
admin_fault: AdminQueueFaultConfig::new(),
260+
controller_management_fault: ControllerManagementFaultConfig::new(),
257261
};
258262
let mut nvmec = instantiate_controller(driver, &gm, None, fault_configuration);
259263

@@ -285,6 +289,7 @@ async fn test_multi_page_admin_queues(driver: DefaultDriver) {
285289
let fault_configuration = FaultConfiguration {
286290
fault_active: CellUpdater::new(false).cell(),
287291
admin_fault: AdminQueueFaultConfig::new(),
292+
controller_management_fault: ControllerManagementFaultConfig::new(),
288293
};
289294
let mut nvmec = instantiate_controller(driver, &gm, None, fault_configuration);
290295

@@ -359,6 +364,7 @@ async fn test_send_identify_no_fault(driver: DefaultDriver) {
359364
let fault_configuration = FaultConfiguration {
360365
fault_active: CellUpdater::new(false).cell(),
361366
admin_fault: AdminQueueFaultConfig::new(),
367+
controller_management_fault: ControllerManagementFaultConfig::new(),
362368
};
363369
let cqe = send_identify(driver, fault_configuration).await;
364370

@@ -374,8 +380,9 @@ async fn test_send_identify_with_sq_fault(driver: DefaultDriver) {
374380
fault_active: CellUpdater::new(true).cell(),
375381
admin_fault: AdminQueueFaultConfig::new().with_submission_queue_fault(
376382
nvme_spec::AdminOpcode::IDENTIFY.0,
377-
QueueFaultBehavior::Update(faulty_identify),
383+
FaultBehaviour::Update(faulty_identify),
378384
),
385+
controller_management_fault: ControllerManagementFaultConfig::new(),
379386
};
380387
let cqe = send_identify(driver, fault_configuration).await;
381388

vm/devices/storage/nvme_test/src/tests/shadow_doorbell_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::tests::test_helpers::write_command_to_queue;
1414
use guestmem::GuestMemory;
1515
use mesh::CellUpdater;
1616
use nvme_resources::fault::AdminQueueFaultConfig;
17+
use nvme_resources::fault::ControllerManagementFaultConfig;
1718
use nvme_resources::fault::FaultConfiguration;
1819
use pal_async::DefaultDriver;
1920
use pal_async::async_test;
@@ -42,6 +43,7 @@ async fn setup_shadow_doorbells(
4243
let fault_configuration = FaultConfiguration {
4344
fault_active: CellUpdater::new(false).cell(),
4445
admin_fault: AdminQueueFaultConfig::new(),
46+
controller_management_fault: ControllerManagementFaultConfig::new(),
4547
}; // Build a controller with 64 entries in the admin queue (just so that the ASQ fits in one page).
4648
let mut nvmec = instantiate_and_build_admin_queue(
4749
cq_buf,

vm/devices/storage/nvme_test/src/workers/admin.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use guestmem::GuestMemory;
3232
use guid::Guid;
3333
use inspect::Inspect;
3434
use nvme_resources::fault::FaultConfiguration;
35-
use nvme_resources::fault::QueueFaultBehavior;
35+
use nvme_resources::fault::FaultBehaviour;
3636
use pal_async::task::Spawn;
3737
use pal_async::task::Task;
3838
use pal_async::timer::PolledTimer;
@@ -478,28 +478,28 @@ impl AdminHandler {
478478
.iter()
479479
.find(|(op, _)| *op == opcode.0)
480480
.map(|(_, behavior)| *behavior)
481-
.unwrap_or_else(|| QueueFaultBehavior::Default);
481+
.unwrap_or_else(|| FaultBehaviour::Default);
482482

483483
match fault {
484-
QueueFaultBehavior::Update(command_updated) => {
484+
FaultBehaviour::Update(command_updated) => {
485485
tracing::warn!(
486486
"configured fault: admin command updated in sq. original: {:?},\n new: {:?}",
487487
&command,
488488
&command_updated
489489
);
490490
command = command_updated;
491491
}
492-
QueueFaultBehavior::Drop => {
492+
FaultBehaviour::Drop => {
493493
tracing::warn!(
494494
"configured fault: admin command dropped from sq {:?}",
495495
&command
496496
);
497497
return Ok(());
498498
}
499-
QueueFaultBehavior::Delay(duration) => {
499+
FaultBehaviour::Delay(duration) => {
500500
self.timer.sleep(duration).await;
501501
}
502-
QueueFaultBehavior::Default => {}
502+
FaultBehaviour::Default => {}
503503
}
504504
}
505505

vmm_tests/vmm_tests/tests/tests/multiarch/openhcl_servicing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use nvme_resources::NamespaceDefinition;
1616
use nvme_resources::NvmeFaultControllerHandle;
1717
use nvme_resources::fault::AdminQueueFaultConfig;
1818
use nvme_resources::fault::FaultConfiguration;
19-
use nvme_resources::fault::QueueFaultBehavior;
19+
use nvme_resources::fault::FaultBehaviour;
2020
use petri::OpenHclServicingFlags;
2121
use petri::PetriVmBuilder;
2222
use petri::PetriVmmBackend;
@@ -256,7 +256,7 @@ async fn keepalive_with_nvme_fault(
256256
fault_active: fault_start_updater.cell(),
257257
admin_fault: AdminQueueFaultConfig::new().with_submission_queue_fault(
258258
nvme_spec::AdminOpcode::CREATE_IO_COMPLETION_QUEUE.0,
259-
QueueFaultBehavior::Drop,
259+
FaultBehaviour::Drop,
260260
),
261261
};
262262

0 commit comments

Comments
 (0)