Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial draft of MEDIA_SANITIZE protocol with NVM Express Support #107

Merged
merged 37 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ce00b77
Initial draft of EFI_MEDIA_SANITIZE protocol and native NVM Express c…
rayrobles Apr 28, 2022
935db6f
Subset of modifications from code review comments - Part 1
rayrobles Apr 29, 2022
7ea5306
Subset of modifications from code review comments - Part 2
rayrobles Apr 29, 2022
90bf438
Merge branch 'release/202202' into release/202202
rayrobles Apr 29, 2022
8174a25
Subset of modifications from code review comments - Part 3
rayrobles Apr 30, 2022
0e41979
Subset of modifications from code review comments - Part 4
rayrobles May 2, 2022
9f16b6c
Updated CopyMem() to use sizeof(Device->MediaSantize.SanitizeCapabili…
rayrobles May 2, 2022
0777f6e
Merge branch 'release/202202' into release/202202
rayrobles May 2, 2022
b30e582
Added TPL restriction comment to function headers; removed saving of …
rayrobles May 4, 2022
c6d6ff1
Added BLOCK_MEDIA_FORMAT() function to Media Sanitize protocol; and m…
rayrobles May 12, 2022
606262a
Merge branch 'release/202202' into release/202202
rayrobles May 12, 2022
b882558
Merge branch 'release/202202' into release/202202
rayrobles May 12, 2022
5f685c5
Resolve bug from code review (Jeff Glaum) on checking correct Flbas p…
rayrobles May 13, 2022
7aa4f2c
Merge branch 'release/202202' of https://github.com/rayrobles/efi_med…
rayrobles May 13, 2022
1b4483e
Merge branch 'release/202202' into release/202202
rayrobles May 13, 2022
6f5d5e3
Merge branch 'release/202202' into release/202202
rayrobles May 18, 2022
050a6ed
Fix outdated comments
rayrobles May 19, 2022
95a81dc
Merge branch 'release/202202' of https://github.com/rayrobles/efi_med…
rayrobles May 19, 2022
699401f
Initial draft of EFI_MEDIA_SANITIZE protocol and native NVM Express c…
rayrobles Apr 28, 2022
3006fae
Subset of modifications from code review comments - Part 1
rayrobles Apr 29, 2022
96969bc
Subset of modifications from code review comments - Part 2
rayrobles Apr 29, 2022
23a391e
Subset of modifications from code review comments - Part 3
rayrobles Apr 30, 2022
40e979b
Subset of modifications from code review comments - Part 4
rayrobles May 2, 2022
b6abf04
Updated CopyMem() to use sizeof(Device->MediaSantize.SanitizeCapabili…
rayrobles May 2, 2022
c1e1c30
Added TPL restriction comment to function headers; removed saving of …
rayrobles May 4, 2022
1ae962c
Added BLOCK_MEDIA_FORMAT() function to Media Sanitize protocol; and m…
rayrobles May 12, 2022
51c916d
Resolve bug from code review (Jeff Glaum) on checking correct Flbas p…
rayrobles May 13, 2022
910c7a3
Fix outdated comments
rayrobles May 19, 2022
bacda1d
Merge branch 'release/202202' into release/202202
rayrobles May 22, 2022
38f58b3
Port of Media Sanitize unit tests to GitHub repo (from ADO)
rayrobles May 23, 2022
283a4c2
Port over media sanitize unit tests from ADO repo
rayrobles May 23, 2022
21be2ba
First revision of chages for review feedback
rayrobles May 25, 2022
c62147e
Second revision of updates from code review comments
rayrobles May 25, 2022
301dec0
Resolve compile and uncrustify issues in latest set of updates for re…
rayrobles May 25, 2022
0b1d3ae
Final pass on PR code review comments
rayrobles May 26, 2022
890f449
Fix gcc MdeModulePkg Debug compile issue for unsued, but set, variable
rayrobles May 27, 2022
50897b1
Merge branch 'release/202202' into release/202202
rayrobles May 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
NVM Express specification.

Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
Expand Down Expand Up @@ -166,6 +167,26 @@ EnumerateNvmeDevNamespace (
Device->BlockIo2.FlushBlocksEx = NvmeBlockIoFlushBlocksEx;
InitializeListHead (&Device->AsyncQueue);

//
// Create Media Sanitize Protocol instance
//
Device->MediaSanitize.Revision = MEDIA_SANITIZE_PROTOCOL_REVISION;
Device->MediaSanitize.Media = &Device->Media;
Device->MediaSanitize.MediaClear = NvmExpressMediaClear;
Device->MediaSanitize.MediaPurge = NvmExpressMediaPurge;
Device->MediaSanitize.MediaFormat = NvmExpressMediaFormat;

ASSERT (
sizeof (Device->MediaSanitize.SanitizeCapabilities) ==
sizeof (Device->Controller->ControllerData->Sanicap)
);

CopyMem (
&(Device->MediaSanitize.SanitizeCapabilities),
&(Device->Controller->ControllerData->Sanicap),
sizeof (Device->MediaSanitize.SanitizeCapabilities)
);
makubacki marked this conversation as resolved.
Show resolved Hide resolved

//
// Create StorageSecurityProtocol Instance
//
Expand Down
40 changes: 38 additions & 2 deletions MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
NVM Express specification.

(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
Expand All @@ -29,6 +30,7 @@
#include <Protocol/DriverSupportedEfiVersion.h>
#include <Protocol/StorageSecurityCommand.h>
#include <Protocol/ResetNotification.h>
#include <Protocol/MediaSanitize.h>

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
Expand All @@ -51,6 +53,7 @@ typedef struct _NVME_DEVICE_PRIVATE_DATA NVME_DEVICE_PRIVATE_DATA;
#include "NvmExpressBlockIo.h"
#include "NvmExpressDiskInfo.h"
#include "NvmExpressHci.h"
#include "NvmExpressMediaSanitize.h"

extern EFI_DRIVER_BINDING_PROTOCOL gNvmExpressDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gNvmExpressComponentName;
Expand Down Expand Up @@ -84,6 +87,30 @@ extern EFI_GUID gNVMeEnableCompleteEventGroupGuid;

#define NVME_MAX_QUEUES 3 // Number of queues supported by the driver

//
// FormatNVM Admin Command LBA Format (LBAF) Mask
//
#define NVME_LBA_FORMATNVM_LBAF_MASK 0xF

//
// NVMe Completion Queue Entry Bits, Fields, Masks
//
#define NVME_CQE_STATUS_FIELD_MASK 0xFFFF0000
#define NVME_CQE_STATUS_FIELD_OFFSET 16
#define NVME_CQE_STATUS_FIELD_SCT_MASK 0x0E00
#define NVME_CQE_STATUS_FIELD_SCT_OFFSET 0x9
#define NVME_CQE_STATUS_FIELD_SC_MASK 0x1FE
#define NVME_CQE_STATUS_FIELD_SC_OFFSET 0x01
#define NVME_CQE_SCT_GENERIC_CMD_STATUS 0x0
#define NVME_CQE_SCT_CMD_SPECIFIC_STATUS 0x1
#define NVME_CQE_SCT_MEDIA_DATA_INTEGRITY_ERRORS_STATUS 0x2
#define NVME_CQE_SCT_PATH_RELATED_STATUS 0x3
#define NVME_CQE_SC_SUCCESSFUL_COMPLETION 0x00
#define NVME_CQE_SC_INVALID_CMD_OPCODE 0x01
#define NVME_CQE_SC_INVALID_FIELD_IN_CMD 0x02

#define NVME_ALL_NAMESPACES 0xFFFFFFFF

// MU_CHANGE [BEGIN] - Support alternative hardware queue sizes in NVME driver

//
Expand Down Expand Up @@ -224,6 +251,8 @@ struct _NVME_DEVICE_PRIVATE_DATA {
EFI_DISK_INFO_PROTOCOL DiskInfo;
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;

MEDIA_SANITIZE_PROTOCOL MediaSanitize;

LIST_ENTRY AsyncQueue;

EFI_LBA NumBlocks;
Expand Down Expand Up @@ -265,6 +294,13 @@ struct _NVME_DEVICE_PRIVATE_DATA {
NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
)

#define NVME_DEVICE_PRIVATE_DATA_FROM_MEDIA_SANITIZE(a) \
CR (a, \
NVME_DEVICE_PRIVATE_DATA, \
MediaSanitize, \
NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
)

//
// Nvme block I/O 2 request.
//
Expand Down
5 changes: 4 additions & 1 deletion MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# NVM Express specification.
#
# Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.<BR>
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
Expand Down Expand Up @@ -40,6 +40,8 @@
NvmExpressHci.c
NvmExpressHci.h
NvmExpressPassthru.c
NvmExpressMediaSanitize.c
makubacki marked this conversation as resolved.
Show resolved Hide resolved
NvmExpressMediaSanitize.h

## MSChange [BEGIN]
[Guids]
Expand Down Expand Up @@ -74,6 +76,7 @@
gEfiDiskInfoProtocolGuid ## BY_START
gEfiStorageSecurityCommandProtocolGuid ## BY_START
gEfiDriverSupportedEfiVersionProtocolGuid ## PRODUCES
gMediaSanitizeProtocolGuid ## PRODUCES
gEfiResetNotificationProtocolGuid ## CONSUMES

[Pcd]
Expand Down
Loading