Message ID | 154792410908.2360577.7879178748203288256.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive) |
---|---|
State | Mainlined |
Commit | 11189c1089da413aa4b5fd6be4c4d47c78968819 |
Headers | show |
Series | [v4] acpi/nfit: Fix command-supported detection | expand |
Hi, [This is an automated email] This commit has been processed because it contains a "Fixes:" tag, fixing commit: 31eca76ba2fc nfit, libnvdimm: limited/whitelisted dimm command marshaling mechanism. The bot has tested the following trees: v4.20.3, v4.19.16, v4.14.94, v4.9.151. v4.20.3: Failed to apply! Possible dependencies: b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands") v4.19.16: Failed to apply! Possible dependencies: 0ead11181fe0 ("acpi, nfit: Collect shutdown status") 6f07f86c4940 ("acpi, nfit: Introduce nfit_mem flags") b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands") v4.14.94: Build OK! v4.9.151: Failed to apply! Possible dependencies: 0f817ae696b0 ("usb: dwc3: pci: add a private driver structure") 11e142701609 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs") 23222f8f8dce ("acpi, nfit: Add function to look up nvdimm device and provide SMBIOS handle") 36daf3aa399c ("usb: dwc3: pci: avoid build warning") 3f23df72dc35 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI byt sdio") 41c8bdb3ab10 ("acpi, nfit: Switch to use new generic UUID API") 42237e393f64 ("libnvdimm: allow a platform to force enable label support") 42b06496407c ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio") 4b27db7e26cd ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label methods") 8f078b38dd38 ("libnvdimm: convert NDD_ flags to use bitops, introduce NDD_LOCKED") 94116f8126de ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()") 9cecca75b5a0 ("usb: dwc3: pci: call _DSM for suspend/resume") 9d62ed965118 ("libnvdimm: handle locked label storage areas") b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands") b7fe92999a98 ("ACPI / extlog: Switch to use new generic UUID API") b917078c1c10 ("net: hns: Add ACPI support to check SFP present") c959a6b00ff5 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices") d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY") fab9288428ec ("usb: USB Type-C connector class") How should we proceed with this patch? -- Thanks, Sasha
Hi, [This is an automated email] This commit has been processed because it contains a "Fixes:" tag, fixing commit: 31eca76ba2fc nfit, libnvdimm: limited/whitelisted dimm command marshaling mechanism. The bot has tested the following trees: v4.20.3, v4.19.16, v4.14.94, v4.9.151. v4.20.3: Failed to apply! Possible dependencies: b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands") v4.19.16: Failed to apply! Possible dependencies: 0ead11181fe0 ("acpi, nfit: Collect shutdown status") 6f07f86c4940 ("acpi, nfit: Introduce nfit_mem flags") b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands") v4.14.94: Build OK! v4.9.151: Failed to apply! Possible dependencies: 0f817ae696b0 ("usb: dwc3: pci: add a private driver structure") 11e142701609 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs") 23222f8f8dce ("acpi, nfit: Add function to look up nvdimm device and provide SMBIOS handle") 36daf3aa399c ("usb: dwc3: pci: avoid build warning") 3f23df72dc35 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI byt sdio") 41c8bdb3ab10 ("acpi, nfit: Switch to use new generic UUID API") 42237e393f64 ("libnvdimm: allow a platform to force enable label support") 42b06496407c ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio") 4b27db7e26cd ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label methods") 8f078b38dd38 ("libnvdimm: convert NDD_ flags to use bitops, introduce NDD_LOCKED") 94116f8126de ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()") 9cecca75b5a0 ("usb: dwc3: pci: call _DSM for suspend/resume") 9d62ed965118 ("libnvdimm: handle locked label storage areas") b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands") b7fe92999a98 ("ACPI / extlog: Switch to use new generic UUID API") b917078c1c10 ("net: hns: Add ACPI support to check SFP present") c959a6b00ff5 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices") d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY") fab9288428ec ("usb: USB Type-C connector class") How should we proceed with this patch? -- Thanks, Sasha
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 73281b19d3dd..71d03a4004fb 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -409,6 +409,32 @@ static bool payload_dumpable(struct nvdimm *nvdimm, unsigned int func) return true; } +static int cmd_to_func(struct nfit_mem *nfit_mem, unsigned int cmd, + struct nd_cmd_pkg *call_pkg) +{ + if (call_pkg) { + int i; + + if (nfit_mem->family != call_pkg->nd_family) + return -ENOTTY; + + for (i = 0; i < ARRAY_SIZE(call_pkg->nd_reserved2); i++) + if (call_pkg->nd_reserved2[i]) + return -EINVAL; + return call_pkg->nd_command; + } + + /* Linux ND commands == NVDIMM_FAMILY_INTEL function numbers */ + if (nfit_mem->family == NVDIMM_FAMILY_INTEL) + return cmd; + + /* + * Force function number validation to fail since 0 is never + * published as a valid function in dsm_mask. + */ + return 0; +} + int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc) { @@ -422,30 +448,23 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, unsigned long cmd_mask, dsm_mask; u32 offset, fw_status = 0; acpi_handle handle; - unsigned int func; const guid_t *guid; - int rc, i; + int func, rc, i; if (cmd_rc) *cmd_rc = -EINVAL; - func = cmd; - if (cmd == ND_CMD_CALL) { - call_pkg = buf; - func = call_pkg->nd_command; - - for (i = 0; i < ARRAY_SIZE(call_pkg->nd_reserved2); i++) - if (call_pkg->nd_reserved2[i]) - return -EINVAL; - } if (nvdimm) { struct acpi_device *adev = nfit_mem->adev; if (!adev) return -ENOTTY; - if (call_pkg && nfit_mem->family != call_pkg->nd_family) - return -ENOTTY; + if (cmd == ND_CMD_CALL) + call_pkg = buf; + func = cmd_to_func(nfit_mem, cmd, call_pkg); + if (func < 0) + return func; dimm_name = nvdimm_name(nvdimm); cmd_name = nvdimm_cmd_name(cmd); cmd_mask = nvdimm_cmd_mask(nvdimm); @@ -456,6 +475,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, } else { struct acpi_device *adev = to_acpi_dev(acpi_desc); + func = cmd; cmd_name = nvdimm_bus_cmd_name(cmd); cmd_mask = nd_desc->cmd_mask; dsm_mask = cmd_mask; @@ -470,7 +490,13 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, if (!desc || (cmd && (desc->out_num + desc->in_num == 0))) return -ENOTTY; - if (!test_bit(cmd, &cmd_mask) || !test_bit(func, &dsm_mask)) + /* + * Check for a valid command. For ND_CMD_CALL, we also have to + * make sure that the DSM function is supported. + */ + if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask)) + return -ENOTTY; + else if (!test_bit(cmd, &cmd_mask)) return -ENOTTY; in_obj.type = ACPI_TYPE_PACKAGE;