Skip to content

Commit cd8dbd9

Browse files
rtkbt-maxVudentz
authored andcommitted
Bluetooth: btrtl: Avoid loading the config file on security chips
For chips with security enabled, it's only possible to load firmware with a valid signature pattern. If key_id is not zero, it indicates a security chip, and the driver will not load the config file. - Example log for a security chip. Bluetooth: hci0: RTL: examining hci_ver=0c hci_rev=000a lmp_ver=0c lmp_subver=8922 Bluetooth: hci0: RTL: rom_version status=0 version=1 Bluetooth: hci0: RTL: btrtl_initialize: key id 1 Bluetooth: hci0: RTL: loading rtl_bt/rtl8922au_fw.bin Bluetooth: hci0: RTL: cfg_sz 0, total sz 71301 Bluetooth: hci0: RTL: fw version 0x41c0c905 - Example log for a normal chip. Bluetooth: hci0: RTL: examining hci_ver=0c hci_rev=000a lmp_ver=0c lmp_subver=8922 Bluetooth: hci0: RTL: rom_version status=0 version=1 Bluetooth: hci0: RTL: btrtl_initialize: key id 0 Bluetooth: hci0: RTL: loading rtl_bt/rtl8922au_fw.bin Bluetooth: hci0: RTL: loading rtl_bt/rtl8922au_config.bin Bluetooth: hci0: RTL: cfg_sz 6, total sz 71307 Bluetooth: hci0: RTL: fw version 0x41c0c905 Tested-by: Hilda Wu <hildawu@realtek.com> Signed-off-by: Nial Ni <niall_ni@realsil.com.cn> Signed-off-by: Max Chou <max.chou@realtek.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 485e062 commit cd8dbd9

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

drivers/bluetooth/btrtl.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
#define RTL_CHIP_SUBVER (&(struct rtl_vendor_cmd) {{0x10, 0x38, 0x04, 0x28, 0x80}})
5252
#define RTL_CHIP_REV (&(struct rtl_vendor_cmd) {{0x10, 0x3A, 0x04, 0x28, 0x80}})
53-
#define RTL_SEC_PROJ (&(struct rtl_vendor_cmd) {{0x10, 0xA4, 0x0D, 0x00, 0xb0}})
53+
#define RTL_SEC_PROJ (&(struct rtl_vendor_cmd) {{0x10, 0xA4, 0xAD, 0x00, 0xb0}})
5454

5555
#define RTL_PATCH_SNIPPETS 0x01
5656
#define RTL_PATCH_DUMMY_HEADER 0x02
@@ -534,7 +534,6 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
534534
{
535535
struct rtl_epatch_header_v2 *hdr;
536536
int rc;
537-
u8 reg_val[2];
538537
u8 key_id;
539538
u32 num_sections;
540539
struct rtl_section *section;
@@ -549,14 +548,7 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
549548
.len = btrtl_dev->fw_len - 7, /* Cut the tail */
550549
};
551550

552-
rc = btrtl_vendor_read_reg16(hdev, RTL_SEC_PROJ, reg_val);
553-
if (rc < 0)
554-
return -EIO;
555-
key_id = reg_val[0];
556-
557-
rtl_dev_dbg(hdev, "%s: key id %u", __func__, key_id);
558-
559-
btrtl_dev->key_id = key_id;
551+
key_id = btrtl_dev->key_id;
560552

561553
hdr = rtl_iov_pull_data(&iov, sizeof(*hdr));
562554
if (!hdr)
@@ -1070,6 +1062,8 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
10701062
u16 hci_rev, lmp_subver;
10711063
u8 hci_ver, lmp_ver, chip_type = 0;
10721064
int ret;
1065+
int rc;
1066+
u8 key_id;
10731067
u8 reg_val[2];
10741068

10751069
btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL);
@@ -1180,6 +1174,14 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
11801174
goto err_free;
11811175
}
11821176

1177+
rc = btrtl_vendor_read_reg16(hdev, RTL_SEC_PROJ, reg_val);
1178+
if (rc < 0)
1179+
goto err_free;
1180+
1181+
key_id = reg_val[0];
1182+
btrtl_dev->key_id = key_id;
1183+
rtl_dev_info(hdev, "%s: key id %u", __func__, key_id);
1184+
11831185
btrtl_dev->fw_len = -EIO;
11841186
if (lmp_subver == RTL_ROM_LMP_8852A && hci_rev == 0x000c) {
11851187
snprintf(fw_name, sizeof(fw_name), "%s_v2.bin",
@@ -1202,7 +1204,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
12021204
goto err_free;
12031205
}
12041206

1205-
if (btrtl_dev->ic_info->cfg_name) {
1207+
if (btrtl_dev->ic_info->cfg_name && !btrtl_dev->key_id) {
12061208
if (postfix) {
12071209
snprintf(cfg_name, sizeof(cfg_name), "%s-%s.bin",
12081210
btrtl_dev->ic_info->cfg_name, postfix);

0 commit comments

Comments
 (0)