History

nfit, libnvdimm: limited/whitelisted dimm command marshaling mechanism

There are currently 4 known similar but incompatible definitions of the command sets that can be sent to an NVDIMM through ACPI. It is also clear that future platform generations (ACPI or not) will continue to revise and extend the DIMM command set as new devices and use cases arrive. It is obviously untenable to continue to proliferate divergence of these command definitions, and to that end a standardization process has begun to provide for a unified specification. However, that leaves a problem about what to do with this first generation where vendors are already shipping divergence. The Linux kernel can support these initial diverged platforms without giving platform-firmware free reign to continue to diverge and compound kernel maintenance overhead. The kernel implementation can encourage standardization in two ways: 1/ Require that any function code that userspace wants to send be explicitly white-listed in the implementation. For ACPI this means function codes marked as supported by acpi_check_dsm() may only be invoked if they appear in the white-list. A function must be publicly documented before it is added to the white-list. 2/ The above restrictions can be trivially bypassed by using the "vendor-specific" payload command. However, since vendor-specific commands are by definition not publicly documented and have the potential to corrupt the kernel's view of the dimm state, we provide a toggle to disable vendor-specific operations. Enabling undefined behavior is a policy decision that can be made by the platform owner and encourages firmware implementations to choose public over private command implementations. Based on an initial patch from Jerry Hoemann Cc: Jerry Hoemann <jerry.hoemann@hpe.com> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Dan Williams committed 10 years ago

Commit 31eca761 parent e3654ec4 files · +179 −17Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/linux/ndctl.h+42−0
@@ -125,6 +125,7 @@ enum { · 124 unmodified lines
125125 ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
126126 ND_CMD_VENDOR_EFFECT_LOG = 8,
127127 ND_CMD_VENDOR = 9,
128+ ND_CMD_CALL = 10,
128129 };
129130
130131 enum {
@@ -158,6 +159,7 @@ static inline const char *nvdimm_cmd_name(unsigned cmd) · 27 unmodified lines
158159 [ND_CMD_VENDOR_EFFECT_LOG_SIZE] = "effect_size",
159160 [ND_CMD_VENDOR_EFFECT_LOG] = "effect_log",
160161 [ND_CMD_VENDOR] = "vendor",
162+ [ND_CMD_CALL] = "cmd_call",
161163 };
162164
163165 if (cmd < ARRAY_SIZE(names) && names[cmd])
@@ -224,4 +226,44 @@ enum ars_masks { · 60 unmodified lines
224226 ARS_STATUS_MASK = 0x0000FFFF,
225227 ARS_EXT_STATUS_SHIFT = 16,
226228 };
229+
230+/*
231+ * struct nd_cmd_pkg
232+ *
233+ * is a wrapper to a quasi pass thru interface for invoking firmware
234+ * associated with nvdimms.
235+ *
236+ * INPUT PARAMETERS
237+ *
238+ * nd_family corresponds to the firmware (e.g. DSM) interface.
239+ *
240+ * nd_command are the function index advertised by the firmware.
241+ *
242+ * nd_size_in is the size of the input parameters being passed to firmware
243+ *
244+ * OUTPUT PARAMETERS
245+ *
246+ * nd_fw_size is the size of the data firmware wants to return for
247+ * the call. If nd_fw_size is greater than size of nd_size_out, only
248+ * the first nd_size_out bytes are returned.
249+ */
250+
251+struct nd_cmd_pkg {
252+ __u64 nd_family; /* family of commands */
253+ __u64 nd_command;
254+ __u32 nd_size_in; /* INPUT: size of input args */
255+ __u32 nd_size_out; /* INPUT: size of payload */
256+ __u32 nd_reserved2[9]; /* reserved must be zero */
257+ __u32 nd_fw_size; /* OUTPUT: size fw wants to return */
258+ unsigned char nd_payload[]; /* Contents of call */
259+};
260+
261+/* These NVDIMM families represent pre-standardization command sets */
262+#define NVDIMM_FAMILY_INTEL 0
263+#define NVDIMM_FAMILY_HPE1 1
264+#define NVDIMM_FAMILY_HPE2 2
265+
266+#define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL,\
267+ struct nd_cmd_pkg)
268+
227269 #endif /* __NDCTL_H__ */