  In the non-volatile memory, ensuring the security and correctness of
persistent data is fundamental. However, the security and persistence issues
are usually studied independently in existing work. To achieve both data
security and persistence, simply combining existing persistence schemes with
memory encryption is inefficient due to crash inconsistency and significant
performance degradation. To bridge the gap between security and persistence,
this paper proposes SecPM, a Secure and Persistent Memory system, which
consists of a counter cache write-through (CWT) scheme and a locality-aware
counter write reduction (CWR) scheme. Specifically, SecPM leverages the CWT
scheme to guarantee the crash consistency via ensuring both the data and its
counter are durable before the data flush completes, and leverages the CWR
scheme to improve the system performance via exploiting the spatial locality of
counter storage, log and data writes. We have implemented SecPM in gem5 with
NVMain and evaluated it using five widely-used workloads. Extensive
experimental results demonstrate that SecPM reduces up to half of write
requests and speeds up the transaction execution by 1.3-2.0 times via using the
CWR scheme, and achieves the performance close to an un-encrypted persistent
memory system for large transactions.
