* [PATCH v2] Bluetooth: btrtl: Avoid loading the config file on security chips
@ 2025-11-05 12:02 Max Chou
2025-11-05 12:51 ` [v2] " bluez.test.bot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Max Chou @ 2025-11-05 12:02 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, linux-bluetooth,
linux-kernel, Paul Menzel
Cc: Hilda Wu, alex_lu, niall_ni, KidmanLee, Max Chou
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>
---
Changes in V2:
- Print key_id at INFO level
- Update commit information for key_id based on review suggestions
---
drivers/bluetooth/btrtl.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 8290932b8f7b..5603b282f9bc 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -50,7 +50,7 @@
#define RTL_CHIP_SUBVER (&(struct rtl_vendor_cmd) {{0x10, 0x38, 0x04, 0x28, 0x80}})
#define RTL_CHIP_REV (&(struct rtl_vendor_cmd) {{0x10, 0x3A, 0x04, 0x28, 0x80}})
-#define RTL_SEC_PROJ (&(struct rtl_vendor_cmd) {{0x10, 0xA4, 0x0D, 0x00, 0xb0}})
+#define RTL_SEC_PROJ (&(struct rtl_vendor_cmd) {{0x10, 0xA4, 0xAD, 0x00, 0xb0}})
#define RTL_PATCH_SNIPPETS 0x01
#define RTL_PATCH_DUMMY_HEADER 0x02
@@ -544,7 +544,6 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
{
struct rtl_epatch_header_v2 *hdr;
int rc;
- u8 reg_val[2];
u8 key_id;
u32 num_sections;
struct rtl_section *section;
@@ -559,14 +558,7 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
.len = btrtl_dev->fw_len - 7, /* Cut the tail */
};
- rc = btrtl_vendor_read_reg16(hdev, RTL_SEC_PROJ, reg_val);
- if (rc < 0)
- return -EIO;
- key_id = reg_val[0];
-
- rtl_dev_dbg(hdev, "%s: key id %u", __func__, key_id);
-
- btrtl_dev->key_id = key_id;
+ key_id = btrtl_dev->key_id;
hdr = rtl_iov_pull_data(&iov, sizeof(*hdr));
if (!hdr)
@@ -1081,6 +1073,8 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
u16 hci_rev, lmp_subver;
u8 hci_ver, lmp_ver, chip_type = 0;
int ret;
+ int rc;
+ u8 key_id;
u8 reg_val[2];
btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL);
@@ -1191,6 +1185,14 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
goto err_free;
}
+ rc = btrtl_vendor_read_reg16(hdev, RTL_SEC_PROJ, reg_val);
+ if (rc < 0)
+ goto err_free;
+
+ key_id = reg_val[0];
+ btrtl_dev->key_id = key_id;
+ rtl_dev_info(hdev, "%s: key id %u", __func__, key_id);
+
btrtl_dev->fw_len = -EIO;
if (lmp_subver == RTL_ROM_LMP_8852A && hci_rev == 0x000c) {
snprintf(fw_name, sizeof(fw_name), "%s_v2.bin",
@@ -1213,7 +1215,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
goto err_free;
}
- if (btrtl_dev->ic_info->cfg_name) {
+ if (btrtl_dev->ic_info->cfg_name && !btrtl_dev->key_id) {
if (postfix) {
snprintf(cfg_name, sizeof(cfg_name), "%s-%s.bin",
btrtl_dev->ic_info->cfg_name, postfix);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* RE: [v2] Bluetooth: btrtl: Avoid loading the config file on security chips
2025-11-05 12:02 [PATCH v2] Bluetooth: btrtl: Avoid loading the config file on security chips Max Chou
@ 2025-11-05 12:51 ` bluez.test.bot
2025-11-10 20:40 ` [PATCH v2] " patchwork-bot+bluetooth
2025-11-11 9:05 ` Paul Menzel
2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-11-05 12:51 UTC (permalink / raw)
To: linux-bluetooth, max.chou
[-- Attachment #1: Type: text/plain, Size: 2296 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1019859
---Test result---
Test Summary:
CheckPatch PENDING 0.44 seconds
GitLint PENDING 0.39 seconds
SubjectPrefix PASS 0.06 seconds
BuildKernel PASS 25.17 seconds
CheckAllWarning PASS 27.24 seconds
CheckSparse PASS 30.83 seconds
BuildKernel32 PASS 24.65 seconds
TestRunnerSetup PASS 492.14 seconds
TestRunner_l2cap-tester PASS 23.33 seconds
TestRunner_iso-tester PASS 95.34 seconds
TestRunner_bnep-tester PASS 5.98 seconds
TestRunner_mgmt-tester FAIL 118.52 seconds
TestRunner_rfcomm-tester PASS 9.09 seconds
TestRunner_sco-tester PASS 14.24 seconds
TestRunner_ioctl-tester PASS 9.71 seconds
TestRunner_mesh-tester FAIL 11.74 seconds
TestRunner_smp-tester PASS 8.40 seconds
TestRunner_userchan-tester PASS 6.38 seconds
IncrementalBuild PENDING 1.11 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.102 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.380 seconds
Mesh - Send cancel - 2 Timed out 1.996 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Bluetooth: btrtl: Avoid loading the config file on security chips
2025-11-05 12:02 [PATCH v2] Bluetooth: btrtl: Avoid loading the config file on security chips Max Chou
2025-11-05 12:51 ` [v2] " bluez.test.bot
@ 2025-11-10 20:40 ` patchwork-bot+bluetooth
2025-11-11 9:05 ` Paul Menzel
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-11-10 20:40 UTC (permalink / raw)
To: Max Chou
Cc: marcel, luiz.dentz, linux-bluetooth, linux-kernel, pmenzel,
hildawu, alex_lu, niall_ni, kidman
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 5 Nov 2025 20:02:04 +0800 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [v2] Bluetooth: btrtl: Avoid loading the config file on security chips
https://git.kernel.org/bluetooth/bluetooth-next/c/9063119bdaee
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] Bluetooth: btrtl: Avoid loading the config file on security chips
2025-11-05 12:02 [PATCH v2] Bluetooth: btrtl: Avoid loading the config file on security chips Max Chou
2025-11-05 12:51 ` [v2] " bluez.test.bot
2025-11-10 20:40 ` [PATCH v2] " patchwork-bot+bluetooth
@ 2025-11-11 9:05 ` Paul Menzel
2 siblings, 0 replies; 4+ messages in thread
From: Paul Menzel @ 2025-11-11 9:05 UTC (permalink / raw)
To: Max Chou
Cc: Marcel Holtmann, Luiz Augusto von Dentz, linux-bluetooth,
linux-kernel, Hilda Wu, alex_lu, niall_ni, KidmanLee
Dear Max,
Thank you for your patch. I respond despite your patch already been
committed.
Am 05.11.25 um 13:02 schrieb Max Chou:
> 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
No linebreak needed for pasted lines.
> Bluetooth: hci0: RTL: rom_version status=0 version=1
> Bluetooth: hci0: RTL: btrtl_initialize: key id 1
Maybe you could send a follow-up to make that line more informative by
also printing, that this chip runs in security mode.
> 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>
> ---
> Changes in V2:
> - Print key_id at INFO level
> - Update commit information for key_id based on review suggestions
> ---
> drivers/bluetooth/btrtl.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> index 8290932b8f7b..5603b282f9bc 100644
> --- a/drivers/bluetooth/btrtl.c
> +++ b/drivers/bluetooth/btrtl.c
> @@ -50,7 +50,7 @@
>
> #define RTL_CHIP_SUBVER (&(struct rtl_vendor_cmd) {{0x10, 0x38, 0x04, 0x28, 0x80}})
> #define RTL_CHIP_REV (&(struct rtl_vendor_cmd) {{0x10, 0x3A, 0x04, 0x28, 0x80}})
> -#define RTL_SEC_PROJ (&(struct rtl_vendor_cmd) {{0x10, 0xA4, 0x0D, 0x00, 0xb0}})
> +#define RTL_SEC_PROJ (&(struct rtl_vendor_cmd) {{0x10, 0xA4, 0xAD, 0x00, 0xb0}})
>
> #define RTL_PATCH_SNIPPETS 0x01
> #define RTL_PATCH_DUMMY_HEADER 0x02
> @@ -544,7 +544,6 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
> {
> struct rtl_epatch_header_v2 *hdr;
> int rc;
> - u8 reg_val[2];
> u8 key_id;
> u32 num_sections;
> struct rtl_section *section;
> @@ -559,14 +558,7 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
> .len = btrtl_dev->fw_len - 7, /* Cut the tail */
> };
>
> - rc = btrtl_vendor_read_reg16(hdev, RTL_SEC_PROJ, reg_val);
> - if (rc < 0)
> - return -EIO;
> - key_id = reg_val[0];
> -
> - rtl_dev_dbg(hdev, "%s: key id %u", __func__, key_id);
> -
> - btrtl_dev->key_id = key_id;
> + key_id = btrtl_dev->key_id;
>
> hdr = rtl_iov_pull_data(&iov, sizeof(*hdr));
> if (!hdr)
> @@ -1081,6 +1073,8 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
> u16 hci_rev, lmp_subver;
> u8 hci_ver, lmp_ver, chip_type = 0;
> int ret;
> + int rc;
> + u8 key_id;
> u8 reg_val[2];
>
> btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL);
> @@ -1191,6 +1185,14 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
> goto err_free;
> }
>
> + rc = btrtl_vendor_read_reg16(hdev, RTL_SEC_PROJ, reg_val);
> + if (rc < 0)
> + goto err_free;
> +
> + key_id = reg_val[0];
> + btrtl_dev->key_id = key_id;
> + rtl_dev_info(hdev, "%s: key id %u", __func__, key_id);
> +
> btrtl_dev->fw_len = -EIO;
> if (lmp_subver == RTL_ROM_LMP_8852A && hci_rev == 0x000c) {
> snprintf(fw_name, sizeof(fw_name), "%s_v2.bin",
> @@ -1213,7 +1215,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
> goto err_free;
> }
>
> - if (btrtl_dev->ic_info->cfg_name) {
> + if (btrtl_dev->ic_info->cfg_name && !btrtl_dev->key_id) {
> if (postfix) {
> snprintf(cfg_name, sizeof(cfg_name), "%s-%s.bin",
> btrtl_dev->ic_info->cfg_name, postfix);
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-11 9:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 12:02 [PATCH v2] Bluetooth: btrtl: Avoid loading the config file on security chips Max Chou
2025-11-05 12:51 ` [v2] " bluez.test.bot
2025-11-10 20:40 ` [PATCH v2] " patchwork-bot+bluetooth
2025-11-11 9:05 ` Paul Menzel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox