瀏覽代碼

iwlwifi: trans: Take ownership on secure machine before FW load

When we load the firmware for the 8000 B step device, it'll
verify its signature. In the current version of the
hardware, there can be a race between the WiFi firmware
being loaded and the Bluetooth firmware being loaded.

Check that WiFi is authenticated, if not, take ownership
on the authentication machine to make sure that the WiFi
firmware will be authenticated.

Signed-off-by: Eran Harary <eran.harary@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Eran Harary 10 年之前
父節點
當前提交
16bc119b6b
共有 2 個文件被更改,包括 52 次插入0 次删除
  1. 10 0
      drivers/net/wireless/iwlwifi/iwl-prph.h
  2. 42 0
      drivers/net/wireless/iwlwifi/pcie/trans.c

+ 10 - 0
drivers/net/wireless/iwlwifi/iwl-prph.h

@@ -381,6 +381,7 @@ enum secure_load_status_reg {
 #define WFPM_CTRL_REG			0xA03030
 #define WFPM_CTRL_REG			0xA03030
 enum {
 enum {
 	ENABLE_WFPM = BIT(31),
 	ENABLE_WFPM = BIT(31),
+	WFPM_AUX_CTL_AUX_IF_MAC_OWNER_MSK	= 0x80000000,
 };
 };
 
 
 #define AUX_MISC_REG			0xA200B0
 #define AUX_MISC_REG			0xA200B0
@@ -388,6 +389,15 @@ enum {
 	HW_STEP_LOCATION_BITS = 24,
 	HW_STEP_LOCATION_BITS = 24,
 };
 };
 
 
+#define AUX_MISC_MASTER1_EN		0xA20818
+enum aux_misc_master1_en {
+	AUX_MISC_MASTER1_EN_SBE_MSK	= 0x1,
+};
+
+#define AUX_MISC_MASTER1_SMPHR_STATUS	0xA20800
+#define RSA_ENABLE			0xA24B08
+#define PREG_AUX_BUS_WPROT_0		0xA04CC0
+
 /* FW chicken bits */
 /* FW chicken bits */
 #define LMPM_CHICK			0xA01FF8
 #define LMPM_CHICK			0xA01FF8
 enum {
 enum {

+ 42 - 0
drivers/net/wireless/iwlwifi/pcie/trans.c

@@ -682,6 +682,43 @@ static int iwl_pcie_load_section(struct iwl_trans *trans, u8 section_num,
 	return ret;
 	return ret;
 }
 }
 
 
+/*
+ * Driver Takes the ownership on secure machine before FW load
+ * and prevent race with the BT load.
+ * W/A for ROM bug. (should be remove in the next Si step)
+ */
+static int iwl_pcie_rsa_race_bug_wa(struct iwl_trans *trans)
+{
+	u32 val, loop = 1000;
+
+	/* Check the RSA semaphore is accessible - if not, we are in trouble */
+	val = iwl_read_prph(trans, PREG_AUX_BUS_WPROT_0);
+	if (val & (BIT(1) | BIT(17))) {
+		IWL_ERR(trans,
+			"can't access the RSA semaphore it is write protected\n");
+		return 0;
+	}
+
+	/* take ownership on the AUX IF */
+	iwl_write_prph(trans, WFPM_CTRL_REG, WFPM_AUX_CTL_AUX_IF_MAC_OWNER_MSK);
+	iwl_write_prph(trans, AUX_MISC_MASTER1_EN, AUX_MISC_MASTER1_EN_SBE_MSK);
+
+	do {
+		iwl_write_prph(trans, AUX_MISC_MASTER1_SMPHR_STATUS, 0x1);
+		val = iwl_read_prph(trans, AUX_MISC_MASTER1_SMPHR_STATUS);
+		if (val == 0x1) {
+			iwl_write_prph(trans, RSA_ENABLE, 0);
+			return 0;
+		}
+
+		udelay(10);
+		loop--;
+	} while (loop > 0);
+
+	IWL_ERR(trans, "Failed to take ownership on secure machine\n");
+	return -EIO;
+}
+
 static int iwl_pcie_load_cpu_sections_8000b(struct iwl_trans *trans,
 static int iwl_pcie_load_cpu_sections_8000b(struct iwl_trans *trans,
 					    const struct fw_img *image,
 					    const struct fw_img *image,
 					    int cpu,
 					    int cpu,
@@ -901,6 +938,11 @@ static int iwl_pcie_load_given_ucode_8000b(struct iwl_trans *trans,
 	if (trans->dbg_dest_tlv)
 	if (trans->dbg_dest_tlv)
 		iwl_pcie_apply_destination(trans);
 		iwl_pcie_apply_destination(trans);
 
 
+	/* TODO: remove in the next Si step */
+	ret = iwl_pcie_rsa_race_bug_wa(trans);
+	if (ret)
+		return ret;
+
 	/* configure the ucode to be ready to get the secured image */
 	/* configure the ucode to be ready to get the secured image */
 	/* release CPU reset */
 	/* release CPU reset */
 	iwl_write_prph(trans, RELEASE_CPU_RESET, RELEASE_CPU_RESET_BIT);
 	iwl_write_prph(trans, RELEASE_CPU_RESET, RELEASE_CPU_RESET_BIT);