Commit b9f7c36d authored by Jack Xu's avatar Jack Xu Committed by Herbert Xu

crypto: qat - check MMP size before writing to the SRAM

Change "sram_visible" to "mmp_sram_size" and compare it with the MMP
size to prevent an overly large MMP file being written to SRAM.
Signed-off-by: default avatarJack Xu <jack.xu@intel.com>
Co-developed-by: default avatarZhehui Xiang <zhehui.xiang@intel.com>
Signed-off-by: default avatarZhehui Xiang <zhehui.xiang@intel.com>
Reviewed-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent fc9818e6
...@@ -24,7 +24,7 @@ struct icp_qat_fw_loader_hal_handle { ...@@ -24,7 +24,7 @@ struct icp_qat_fw_loader_hal_handle {
}; };
struct icp_qat_fw_loader_chip_info { struct icp_qat_fw_loader_chip_info {
bool sram_visible; int mmp_sram_size;
bool nn; bool nn;
bool lm2lm3; bool lm2lm3;
u32 lm_size; u32 lm_size;
......
...@@ -696,7 +696,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle, ...@@ -696,7 +696,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle,
handle->pci_dev = pci_info->pci_dev; handle->pci_dev = pci_info->pci_dev;
switch (handle->pci_dev->device) { switch (handle->pci_dev->device) {
case ADF_4XXX_PCI_DEVICE_ID: case ADF_4XXX_PCI_DEVICE_ID:
handle->chip_info->sram_visible = false; handle->chip_info->mmp_sram_size = 0;
handle->chip_info->nn = false; handle->chip_info->nn = false;
handle->chip_info->lm2lm3 = true; handle->chip_info->lm2lm3 = true;
handle->chip_info->lm_size = ICP_QAT_UCLO_MAX_LMEM_REG_2X; handle->chip_info->lm_size = ICP_QAT_UCLO_MAX_LMEM_REG_2X;
...@@ -730,7 +730,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle, ...@@ -730,7 +730,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle,
break; break;
case PCI_DEVICE_ID_INTEL_QAT_C62X: case PCI_DEVICE_ID_INTEL_QAT_C62X:
case PCI_DEVICE_ID_INTEL_QAT_C3XXX: case PCI_DEVICE_ID_INTEL_QAT_C3XXX:
handle->chip_info->sram_visible = false; handle->chip_info->mmp_sram_size = 0;
handle->chip_info->nn = true; handle->chip_info->nn = true;
handle->chip_info->lm2lm3 = false; handle->chip_info->lm2lm3 = false;
handle->chip_info->lm_size = ICP_QAT_UCLO_MAX_LMEM_REG; handle->chip_info->lm_size = ICP_QAT_UCLO_MAX_LMEM_REG;
...@@ -763,7 +763,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle, ...@@ -763,7 +763,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle,
+ LOCAL_TO_XFER_REG_OFFSET); + LOCAL_TO_XFER_REG_OFFSET);
break; break;
case PCI_DEVICE_ID_INTEL_QAT_DH895XCC: case PCI_DEVICE_ID_INTEL_QAT_DH895XCC:
handle->chip_info->sram_visible = true; handle->chip_info->mmp_sram_size = 0x40000;
handle->chip_info->nn = true; handle->chip_info->nn = true;
handle->chip_info->lm2lm3 = false; handle->chip_info->lm2lm3 = false;
handle->chip_info->lm_size = ICP_QAT_UCLO_MAX_LMEM_REG; handle->chip_info->lm_size = ICP_QAT_UCLO_MAX_LMEM_REG;
...@@ -800,7 +800,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle, ...@@ -800,7 +800,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle,
goto out_err; goto out_err;
} }
if (handle->chip_info->sram_visible) { if (handle->chip_info->mmp_sram_size > 0) {
sram_bar = sram_bar =
&pci_info->pci_bars[hw_data->get_sram_bar_id(hw_data)]; &pci_info->pci_bars[hw_data->get_sram_bar_id(hw_data)];
handle->hal_sram_addr_v = sram_bar->virt_addr; handle->hal_sram_addr_v = sram_bar->virt_addr;
......
...@@ -1551,7 +1551,7 @@ int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle, ...@@ -1551,7 +1551,7 @@ int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle,
status = qat_uclo_auth_fw(handle, desc); status = qat_uclo_auth_fw(handle, desc);
qat_uclo_ummap_auth_fw(handle, &desc); qat_uclo_ummap_auth_fw(handle, &desc);
} else { } else {
if (!handle->chip_info->sram_visible) { if (handle->chip_info->mmp_sram_size < mem_size) {
dev_dbg(&handle->pci_dev->dev, dev_dbg(&handle->pci_dev->dev,
"QAT MMP fw not loaded for device 0x%x", "QAT MMP fw not loaded for device 0x%x",
handle->pci_dev->device); handle->pci_dev->device);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment