教學 1 · HMB是借出去的Host記憶體
Host 仍擁有實體記憶體,但在 HMB 啟用期間,controller 具有規範允許的專用使用權。Host 不能因某筆普通命令完成就回收它,也不能改寫 descriptor list。先成功停用 HMB,確認存取生命週期結束,再釋放或重用,才能避免 controller 寫到新用途資料。
NVMe · Q1–328
Q223–Q236
先看記憶體位於哪裡、由誰提供與何時可回收,再看持久性。HMB、CMB、PMR 不能因都含 Memory 就套同一組 reset 規則。
每個問題都接著完整解說,依內容帶讀欄位、比較機制或追蹤流程。先看本冊總覽,再沿問題閱讀;必要條件與正常路徑直接顯示。所有數字案例均為教學假設;Status 以 SCT/SC 表示,代碼後的 h 代表十六進位。
位址設定保留,不代表原內容保留;CQE 成功也不必然證明 PMR 資料已持久化。
| 機制 | 記憶體與用途 | 結束或確認條件 |
|---|---|---|
| HMB | Host 提供 controller 專用 buffer | 成功停用後才能回收 |
| CMB | Controller 提供可選用途記憶體 | 依 reset/CMSE 規則重建內容 |
| PMR | PCIe function 提供持久記憶體 | 檢查 Ready、健康及 PMRWBM |
舉例看懂:HMB 停用成功前,Host 不能重用其 buffer。CMB 在某些 reset 後即使 CBA 還在,CQ 內容仍須重新初始化;PMR 則另有持久性與健康要求。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties)
Host 仍擁有實體記憶體,但在 HMB 啟用期間,controller 具有規範允許的專用使用權。Host 不能因某筆普通命令完成就回收它,也不能改寫 descriptor list。先成功停用 HMB,確認存取生命週期結束,再釋放或重用,才能避免 controller 寫到新用途資料。
支援 CMB 不代表能放所有 queue、資料或清單。SQS、CQS、LISTS、RDS、WDS 各管不同用途,其他限制還管是否能混用 Host 與 CMB 範圍。先把某筆命令需要的 queue、data、metadata、list 逐一標位置,再檢查每種用途,不能只確認地址落在 CMB 就算合法。
EN 設定後仍需等 NRDY 清除,再看 ERR 及 HSTS。先前寫入是否已持久化,還要按 PMRWBM 使用支援的確認方法。即使讀取可以完成,Restore Error 或 Read Only 也會改變能做的推論;不能只憑讀回一個值就宣稱整份資料歷經斷電仍可靠。
它們都與記憶體有關,但借用方向、使用者與保存承諾不同;先辨認這三件事,才不會錯配 buffer。
HMB 位於 Host,專供 controller 使用;CMB 位於 controller,供宣告支援的 queue 或 buffer;PMR 是可直接讀寫的持久記憶體區域。
HMB 用 FID0Dh 配置 descriptor;CMB 用 CMBMSC/CMBLOC 建立地址關係;PMR 用 PMRCTL 與 PMRSTS 確認啟用和健康。
HMB 查 HMPRE;CMB 查 CAP.CMBS、CMBSZ;PMR 查 CAP.PMRS、PMRCAP。
依需求選擇:借 Host RAM 給韌體使用選 HMB;將 SQ 放到裝置記憶體須查 CMB.SQS;要直接存放持久資料則研究 PMR 的 barrier 與健康。
正確結果是功能可用且符合各自使用限制,不是所有記憶體都能放所有資料結構。
PMR 的 queue、PRP/SGL list 支援不在規範範圍,controller 可回 Invalid Field;不能因 PMR 可讀寫就把它當成另一個 CMB。
用能力、配置、存取方式與恢復後內容交叉比對,而不是只看一個地址能不能讀到 bytes。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
Host 以多段實體連續記憶體提供 HMB,不必一次取得整塊連續 RAM,但 descriptor list 本身必須實體連續。
配置給一個 controller 專用,Host 啟用後不能當一般工作 buffer 改寫。
查 HMPRE、HMMIN、HMMINDS、HMMAXD;前兩者及 HMMINDS 用 4 KiB 單位。
HSIZE 與每筆 BSIZE 卻用 CC.MPS page 單位;HMDLEC 是實際筆數,list address 16-byte 對齊,BADD 按 CC.MPS 對齊。
先配置並固定 RAM,填 16-byte descriptors,核對各段大小與 HSIZE,再以 EHM=1 啟用,等 CQE 成功才交給 controller 使用。
Get 回 EHM 與 attributes 可核對實際配置。假設 CC.MPS 選 8 KiB,HSIZE=256 表示 2 MiB,不是 1 MiB。
HMDLEC=0 須 Invalid Field;超過建議可用 descriptor 限制可能只使部分記憶體未利用,不能一律預期拒絕整個配置。
同時比對能力單位、命令單位與 Get attributes,不能直接將 HMPRE 數字抄進 HSIZE。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
不同欄位的錯誤規則不同;驗證時要指定單一錯誤,才知道應預期哪一種反應。
包含 descriptor list 本身、每筆記憶體範圍,以及目前 HMB 是否已啟用。
HMDLEC=0 是 Invalid Field;BSIZE=0 的 descriptor 必須忽略。HMDLLA 低 4 bits 要清零,但 controller 必須如同其為零運作,且不必檢查。
已啟用又要求 EHM=1 必須 Command Sequence Error;不支援 HMBR 卻設 HMNARE=1 必須 Invalid Field。不能要求每個低位對齊錯誤都回相同 Status。
查 HMMINDS/HMMAXD、HMBR 與 Get.EHM,再核對 Set 的欄位。
先測可判定的格式錯誤,再將地址無法存取造成的傳輸失敗分開;不要把 Host 錯誤 mapping 當作同一種參數錯誤。
合法配置成功;超出可用 descriptor 限制時,可出現未完全利用 HMB 的結果。
將具體欄位條件對到指定反應,保留「忽略」與「必須拒絕」之間的差別。
先確認測試是否同時放入多種錯誤,造成 Status 無法唯一預測。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
HMB 的使用權要明確交接,Host 才知道何時能回收記憶體。
EHM 控制 controller 是否可使用 HMB,MR 描述返回的內容是否仍符合原狀。
先 Get.EHM 與配置,Reset 後也重新確認,而不沿用 Host 記錄的啟用狀態。
EHM=0 時 CDW12~15 忽略;MR=1 要求原大小、list 位址、list 內容及 buffer 內容完全相同。
Host 已提交停用命令時,controller 仍可能在使用 HMB。要等完成結果,才能回收記憶體。
Host 維持 buffer、Descriptor List 與位址映射有效。
尚未成功完成前,不改寫或回收仍由 controller 使用的記憶體。
在重新啟用前,controller 不得再存取 HMB;原本就停用時,再停用也成功且不做其他動作。
Reset 不是停用 HMB 的必做步驟。若發生 Reset,可提供保留的原配置或新配置;只有完全符合 MR 前提時才能設 MR=1。
驗證時把最後一次 HMB 存取、停用 CQE 與 Host 回收時刻放在同一條時間軸上。
已啟用再次啟用是 Command Sequence Error;內容已被改動卻宣告 MR=1 是 Host 違反前提,不能期待原快取仍安全可用。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
這會破壞 controller 專用記憶體的前提,可能讓裝置讀到其他用途的資料,或改寫已被重新分配的 RAM。
受影響可能超過 NVMe buffer 本身,因為 Host 已把同一實體頁交给別的程式。
HMB descriptor 與描述的 ranges 都受保護;只保留 list 卻回收資料頁,仍違反規則。
查 EHM 與最後一次停用 CQE,並保存記憶體配置和 mapping 的生命週期。
先請求停用,等成功完成,再解除 mapping 與回收;若故障無法停用,需完成足以終止舊存取的恢復流程後才回收。
正確交接後,controller 不再使用舊區域,Host 才可安全重用。
這種 Host 違規沒有保證會被 controller 偵測或以固定 Status 拒絕;可能出現資料損壞,不能靠期待 Error Log 防護。
區分 Host 提前回收與 controller 在成功停用後仍存取:前者是 Host 問題,後者才違反明定停止存取要求。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
需要同時知道 Host 如何存取 CMB,以及命令中的地址如何讓 controller 指向同一區域。
CMB 有 PCIe address range 與 controller address range,兩者基底可不同,相同 offset 對應相同內容。
查 CAP.CMBS,設 CMBMSC.CRE 後讀 CMBLOC 與 CMBSZ;CRE=0 時這兩個屬性可為零。
CMBLOC.BIR 選 BAR、OFST 配合大小單位求偏移;CMBSZ.SZ×SZU 求大小,再受 BAR 可用範圍限制。SQS、CQS、LISTS、RDS、WDS 各自宣告用途。
配置不衝突的 CBA,設 CMSE,檢查 CMBSTS.CBAI,再初始化要放入的 queue 或 buffer。
Host 與命令使用各自正確的地址,同一 offset 對到同一份 CMB 內容。
無效 CBA 會使 CBAI=1 且未成功啟用 controller memory space;這是 Register 狀態,不是回一筆 Admin CQE。
比對 BAR 範圍、OFST、SZU、CBA 與支援 flags,不能只看 CAP.CMBS。
先檢查是否把 BAR 地址直接拿去當已重新配置的 controller 地址。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
CMB 用途由多個能力位元分別控制,支援 SQ 不表示同時支援 CQ 或資料。
限制可能以整條 queue、單筆命令的 list,或該命令的所有 data/metadata 為單位。
CQMMS=0 要求單一 queue 全在 CMB 或全在外;CQPDS=0 要求 CMB queue 實體連續。LISTS 控制 PRP/SGL list,其他 bits 再決定混放與 SQ 位置限制。
查 CMBSZ.SQS、CQS、LISTS、RDS、WDS,以及 CMBLOC.CQMMS、CQPDS、CDPMLS、CDPCILS、CDMMMS。
先按物件選用途 flag,再檢查它和 SQ、data、metadata 的組合條件,最後才配置地址。
假設 SQS=1、CQS=0,可把支援的 SQ 放 CMB,CQ 仍放 Host memory;不是兩者一定一起搬。
違反使用要求一般須 Invalid Use of Controller Memory Buffer;但 LISTS=0 仍放 list 的條文明定 undefined,不能強行替它指定固定 Status。
RDS/WDS 要按命令資料方向解讀,例如 Read 的結果是 controller 傳向 Host 的資料。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
要分清無效 mapping、合法 mapping 中的用途違規,以及根本不被解讀成 CMB 的地址。
CBA 與大小決定 controller address range;CMSE=0 時 Host 提供的地址不被視為 CMB。
CBA 不得使範圍溢出 64-bit 地址,也不得與已啟用的 PMR controller range 重疊。
無效 mapping 看 CBAI;用途違規依 Invalid Use of CMB;範圍外地址可能被當成其他記憶體,不能一律預期「CMB 越界」專用 Status。
保存 CMBMSC、CMBSTS、CMBLOC、CMBSZ 與命令完整資料範圍。
先算起點與末端,再判斷每個地址落在哪個空間;最後檢查用途旗標與混放條件。
合法範圍且符合用途限制時,命令按正常資料存取執行。
命令錯誤與 Register 狀態是兩份證據;沒有 CQE 不表示 Register 啟用成功。
先檢查範圍計算是否溢位,以及計算用的是 Host 還是 controller 地址。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
位址保留與內容保留是兩件事,這是 CMB 恢復時最容易混淆的地方。
CC.EN 觸發的 CLR 與 FLR 有明確 CMBMSC 保留例外,其他來源須看對應 Register 規則。
保存 Reset 來源、CMBMSC 與 CMBSTS,恢復後再讀取確認。
CMSE 由 0 轉 1、Controller Reset 或 FLR,都使 CMB 內容 undefined。
恢復 mapping 後重新初始化會用到的記憶體,再建立 queue;CQ 尤其要初始化 Phase,避免誤讀殘留完成。
新的使用期間從已初始化的內容開始,不能沿用舊 queue 指標或假定資料保存。
| 觸發方式 | 這項操作或狀態會如何變化 |
|---|---|
| Controller Reset 後是否保留或繼續? | CC.EN 觸發的 CLR 與 FLR 保留 CMBMSC,但 CMB 內容變成 undefined。Host 必須重新初始化要使用的內容,特別是 CQ Phase;位址設定保留不等於 queue 或資料有效。 |
| NVM Subsystem Reset 後是否保留或繼續? | Subsystem Reset 後重新確認 CMB Register 與 mapping,重建使用它的 queues。不能把 CC.EN/FLR 的特定 CMBMSC 保留規則擴大成所有重設都保留。 |
| Power Cycle 後是否保留或繼續? | CMB 不提供 PMR 的跨斷電持久性保證。Power Cycle 後重新配置、初始化,再使用支援的用途。 |
讀到與 Reset 前相同 bytes 也不代表規範保證保留;undefined 可以碰巧相同。
用 Register 保留規則驗 mapping,用 queue 與內容初始化規則驗使用權,兩項分開判定。
先檢查是否因 CMBMSC 沒變,就省略了 CQ 與 buffer 初始化。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
PMR 可獨立於 NVMe 命令處理環境啟用,Host 必須等其自己的 Ready 狀態。
PMR 占用 PMRCAP.BIR 指定 BAR 的整個區域;controller 地址可另由 PMRMSC 設定。
查 CAP.PMRS、PMRCAP 的 BIR、CMSS、RDS、WDS、PMRWBM、PMRTO、PMRTU。
PMRCTL.EN 啟用;PMRSTS.NRDY=0 配合 EN=1 才代表 Ready,還要看 HSTS 與 ERR。
不要把 CSTS.RDY 或 CC.EN 當成 PMR 是否可用的答案。
依能力建立 BAR/controller 位址映射;無效 controller base address 另查 CBAI。
PMR 可以在 CC.EN=0 時啟用,不必先建立 NVMe 命令處理環境。
判斷未完成轉換前,Host 應至少等待 PMRTO×PMRTU;確認 PMRTU 使用分鐘或 500 ms 單位。
EN=1、NRDY=0、健康與映射條件成立後,才能依支援用途存取。
NRDY=1 的意思是「尚未就緒」。PMRTO 也不是任意一筆 I/O 命令的執行期限。
PMRTO 是 Host 應給的等待時間,不可直接寫成 controller 每筆命令的 timeout。CBA 無效另看 CBAI。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
存取在傳輸層完成,不表示記憶體內容有效;PMR 必須同時檢查自身狀態。
直接 PMR 讀寫與 NVMe 命令使用 PMR buffer,兩者的錯誤觀察方式不同。
Not-ready 直接讀可成功卻回 undefined;直接寫可成功卻不更新內容。HSTS 可表示 Restore Error、Read Only 或 Unreliable。
若關聯 controller 偵測命令寫 PMR 未成功,應以 Data Transfer Error 中止;直接 MMIO 存取沒有可要求的 NVMe CQE。
檢查 EN、NRDY、HSTS、ERR;HSTS 在 not-ready 時清零,因此零 HSTS 不能單獨證明健康可用。
先確認 Ready,再存取;完成後用支援的 barrier 與狀態檢查,遇到健康改變則回查上次正常觀察後的操作。
NVMe 命令成功把資料寫向 PMR,也不單憑 CQE 保證 PMR 實際寫入成功。
將 CQE 成功與 PMRSTS 正常分別核對,不可用其中一項替代另一項。
先檢查存取當時 EN/NRDY,而不只看較晚恢復後的狀態。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
停用前要先確認先前寫入已完成且持久,避免把仍在路上的寫入誤當成保存完成。
包含直接 PMR 存取與仍以 PMR 為 buffer 的命令,所有使用者都要協調停止。
查 PMRWBM 支援的 barrier、PMRSTS 健康與 PMRTO/PMRTU。
依能力可用 PMR memory read 或 PMRSTS read 建立先前寫入已持久的保證;不能假設任意 Register read 都是 barrier。
停止新存取,等相關工作結束,執行支援的 barrier 並確認健康,再清 PMRCTL.EN,等待 NRDY=1。
NRDY=1 表示停用完成到可再次啟用的狀態;先前合法持久內容不因停用就變成 CMB 那樣的 undefined。
ERR 非零或 HSTS 不正常時,不能把停用成功當成先前資料已正確保存;應保留錯誤證據。
用 barrier、健康與 EN/NRDY 的順序驗證,不只看最後 EN=0。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
持久資料與目前可存取狀態不同;即使內容應保留,恢復期間仍可能尚未 Ready。
資料保留適用已完成且持久的 PMR 寫入,不擴張到 Host 尚未確認的寫入。
重設前保存 barrier 結果,恢復後讀 EN、NRDY、HSTS、ERR 與 mapping。
HSTS=Restore Error 表示 PMR 現在運作且持久,但前次內容可能未正確恢復;與目前 Unreliable 意義不同。
先恢復 Ready,再驗健康,最後按測試保存的內容核對;若同時做 Sanitize,另依清除規則判斷。
符合前提的持久資料應跨 CLR、停用與 Power Cycle 保留;Register 保留則依 Reset 來源分別檢查。
| 觸發方式 | 這項操作或狀態會如何變化 |
|---|---|
| Controller Reset 後是否保留或繼續? | Ready 且已確認持久的內容跨 CLR 保留。CC.EN 觸發的 CLR 另保留 PMR 控制/狀態 Register;但仍應確認健康,不能因 Register 保留就忽略 Restore Error。 |
| NVM Subsystem Reset 後是否保留或繼續? | Subsystem Reset 後重新確認啟用與 Ready 狀態,再檢查 HSTS。PMR 的資料持久性與 Register 是否須重建是不同問題;Restore Error 表示原內容可能未正確恢復。 |
| Power Cycle 後是否保留或繼續? | Ready 時已完成且確認持久的寫入應跨 Power Cycle 保留;恢復後仍須確認 HSTS 與 ERR。Sanitize 可清除 PMR,不能把同時發生的 Sanitize 當成一般斷電遺失。 |
PMRSTS.ERR 非零會維持到 PCI Function reset;清 CC.EN 不保證把錯誤清零。
內容、Register 與錯誤狀態分三項驗證,不能只因其中一項符合就宣稱全部通過。
先確認失去的是已持久內容,還是尚未完成的寫入或尚未恢復的讀取。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
同樣是資料地址,背後可能有不同擁有者、初始化責任與可回收條件。
普通 Host buffer 由 Host 管理,命令期間供 controller 存取;HMB 專供 controller;CMB 位於裝置;PMR 額外提供持久性機制。
普通 buffer 按命令與 queue 生命週期回收;HMB 等停用完成;CMB 重設後需初始化;PMR 保存前需支援的 barrier 與健康確認。
以 HMPRE、CMB/PMR flags 與每筆命令資料指標,確認實際使用哪一種空間。
先畫出 Host 地址、controller 地址與實際記憶體的對應,再標註從何時開始可存取、何時才能回收。
例如一個成功 Write CQE 可結束其來源 Host buffer 使用,但不代表整塊 HMB 同時釋放,也不代表 PMR barrier 已執行。
錯誤回應依違反哪個介面規則決定,不存在統一「記憶體錯誤」Status 可套用全部情況。
核對 ownership、mapping、命令完成與持久性各自的證據,避免用「還能讀到資料」代替全部驗證。
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
來源:Base 2.4 §5.2.30.2.3, 8.2.4 · Base 2.4 §8.2.1 (memory placement and lifetime) · Base 2.4 §3.1.4 (CMBLOC, CMBSZ, CMBMSC, CMBSTS) · Base 2.4 §8.2.5 (memory behavior; exclude PCIe packet detail) · Base 2.4 §3.1.4 (PMR properties) · Base 2.4 §5.2.14.2.1 · Base 2.4 §3.7.1–3.7.4 · Base 2.4 §4.2.3 · Base 2.4 §5.2.13.1.2 · Base 2.4 §5.2.2 · Base 2.4 §5.2.13.1.14 (header, reset, hardware, Set Feature events)
Base 的文件頁碼等於 PDF 頁碼減 26;NVM 與 PCIe 兩份規格的文件頁碼則與 PDF 頁碼相同。以下依提供的 PDF 本文列出章節、頁碼及 Figure 編號。若同一頁包含其他主題,只引用本題需要的定義,不納入 Fabrics 或 PCIe Link、封包內容。
以下連結可開啟對應的圖表教學,查閱欄位及判讀方式。每張圖保留固定的教學位置,方便之後反覆查詢。
NVM-Express-Base-Specification-Revision-2.4-Ratified-2026.07.31.pdfNVM-Express-NVM-Command-Set-Specification-Revision-1.3-Ratified-2026.07.31.pdfNVM-Express-NVMe-over-PCIe-Transport-Specification-Revision-1.4-Ratified-2026.07.31.pdf