Skip to content

Commit adb68c3

Browse files
vaibhav92mpe
authored andcommitted
powerpc/papr_scm: Mark nvdimm as unarmed if needed during probe
In case an nvdimm is found to be unarmed during probe then set its NDD_UNARMED flag before nvdimm_create(). This would enforce a read-only access to the ndimm region. Presently even if an nvdimm is unarmed its not marked as read-only on ppc64 guests. The patch updates papr_scm_nvdimm_init() to force query of nvdimm health via __drc_pmem_query_health() and if nvdimm is found to be unarmed then set the nvdimm flag ND_UNARMED for nvdimm_create(). Signed-off-by: Vaibhav Jain <[email protected]> Reviewed-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ee1bc69 commit adb68c3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/powerpc/platforms/pseries/papr_scm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,15 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
947947
dimm_flags = 0;
948948
set_bit(NDD_LABELING, &dimm_flags);
949949

950+
/*
951+
* Check if the nvdimm is unarmed. No locking needed as we are still
952+
* initializing. Ignore error encountered if any.
953+
*/
954+
__drc_pmem_query_health(p);
955+
956+
if (p->health_bitmap & PAPR_PMEM_UNARMED_MASK)
957+
set_bit(NDD_UNARMED, &dimm_flags);
958+
950959
p->nvdimm = nvdimm_create(p->bus, p, papr_nd_attr_groups,
951960
dimm_flags, PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
952961
if (!p->nvdimm) {

0 commit comments

Comments
 (0)