Bluetooth: vhci: Add support for setting msft_opcode
Luiz Augusto von Dentz
maintainerRFC 1/1 Bluetooth: vhci: Add support for setting msft_opcode
From: Luiz Augusto von Dentz <[email protected]>
This adds a debugfs entry to set msft_opcode enabling vhci to emulate controllers with MSFT extention support.
--- drivers/bluetooth/hci_vhci.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/bluetooth/hci_vhci.c +32 -0
@@ -194,6 +194,34 @@ static const struct file_operations force_wakeup_fops = { .llseek = default_llseek, }; + +static int msft_opcode_set (void *data,u64 val) +{ +struct vhci_data *vhci = data; +uint16_t ogf = (val &0xffff >>10 ); + +if (val >0xffff || ogf !=0x3f ) +return -EINVAL ; + +hci_set_msft_opcode (vhci->hdev, val); + +return 0 ; +} + +static int msft_opcode_get (void *data,u64 *val) +{ +struct vhci_data *vhci = data; + +hci_dev_lock (vhci->hdev); + *val = vhci->hdev->msft_opcode; +hci_dev_unlock (vhci->hdev); + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (msft_opcode_fops, msft_opcode_get, msft_opcode_set, +"%llu\n" ); +static int __vhci_create_device (struct vhci_data *data,__u8 opcode) {struct hci_dev *hdev;
@@ -259,6 +287,10 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)debugfs_create_file ("force_wakeup" ,0644 , hdev->debugfs, data, &force_wakeup_fops); +if (IS_ENABLED (CONFIG_BT_MSFTEXT )) +debugfs_create_file ("msft_opcode" ,0644 , hdev->debugfs, data, + &msft_opcode_fops); +hci_skb_pkt_type (skb) =HCI_VENDOR_PKT ;skb_put_u8 (skb,0xff );
Signature · 1 line
2.31.1
kernel test robot
build bot[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Luiz,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on next-20211011]
[cannot apply to bluetooth/master v5.15-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Luiz-Augusto-von-Dentz/Bluetooth-vhci-Add-support-for-setting-msft_opcode/20211012-051319 base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master config: sparc64-randconfig-r013-20211011 (attached as .config) compiler: sparc64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/fb773fdf30cade9ffce927d653090595ed809a2a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luiz-Augusto-von-Dentz/Bluetooth-vhci-Add-support-for-setting-msft_opcode/20211012-051319 git checkout fb773fdf30cade9ffce927d653090595ed809a2a
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc64 SHELL=/bin/bash drivers/bluetooth/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/bluetooth/hci_vhci.c: In function 'msft_opcode_get':
>> drivers/bluetooth/hci_vhci.c:216:26: error: 'struct hci_dev' has no member named 'msft_opcode'
216 | *val = vhci->hdev->msft_opcode;
| ^~vim +216 drivers/bluetooth/hci_vhci.c
210
211 static int msft_opcode_get(void *data, u64 *val)
212 {
213 struct vhci_data *vhci = data;
214
215 hci_dev_lock(vhci->hdev);
> 216 *val = vhci->hdev->msft_opcode;
217 hci_dev_unlock(vhci->hdev);
218
219 return 0;
220 }
221
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build bot[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Luiz,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on next-20211011]
[cannot apply to bluetooth/master v5.15-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Luiz-Augusto-von-Dentz/Bluetooth-vhci-Add-support-for-setting-msft_opcode/20211012-051319 base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master config: mips-buildonly-randconfig-r003-20211012 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c3dcf39554dbea780d6cb7e12239451ba47a2668)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://github.com/0day-ci/linux/commit/fb773fdf30cade9ffce927d653090595ed809a2a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luiz-Augusto-von-Dentz/Bluetooth-vhci-Add-support-for-setting-msft_opcode/20211012-051319 git checkout fb773fdf30cade9ffce927d653090595ed809a2a
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/bluetooth/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/bluetooth/hci_vhci.c:216:21: error: no member named 'msft_opcode' in 'struct hci_dev'
*val = vhci->hdev->msft_opcode;
~~~~~~~~~~ ^1 error generated.
vim +216 drivers/bluetooth/hci_vhci.c
210
211 static int msft_opcode_get(void *data, u64 *val)
212 {
213 struct vhci_data *vhci = data;
214
215 hci_dev_lock(vhci->hdev);
> 216 *val = vhci->hdev->msft_opcode;
217 hci_dev_unlock(vhci->hdev);
218
219 return 0;
220 }
221
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Marcel Holtmann
maintainerHi Luiz,
Quoted 13 lines
This adds a debugfs entry to set
msft_opcodeenabling vhci to emulate controllers with MSFT extention support.Signed-off-by Luiz Augusto von Dentz <[email protected]>---
drivers/bluetooth/hci_vhci.c| 32 ++++++++++++++++++++++++++++++++1 file changed, 32 insertions(+)drivers/bluetooth/hci_vhci.c +0
-0
drivers/bluetooth/hci_vhci.c static const struct file_operations force_wakeup_fops = { · line 203
Quoted 10 lines
drivers/bluetooth/hci_vhci.c +7
-0@@ -194,6 +194,34 @@ static const struct file_operations force_wakeup_fops = { .llseek = default_llseek, }; + +static int msft_opcode_set (void *data,u64 val) +{ +struct vhci_data *vhci = data; +uint16_t ogf = (val &0xffff >>10 ); + +if (val >0xffff || ogf !=0x3f )
I would actually just include it here to avoid any 16-bit overflow.
if (val > 0xffff || (val & 0xffff >> 10) != 0x3f)
Quoted 25 lines
drivers/bluetooth/hci_vhci.c +21
-0+return -EINVAL ; + +hci_set_msft_opcode (vhci->hdev, val); + +return 0 ; +} + +static int msft_opcode_get (void *data,u64 *val) +{ +struct vhci_data *vhci = data; + +hci_dev_lock (vhci->hdev); + *val = vhci->hdev->msft_opcode; +hci_dev_unlock (vhci->hdev); + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (msft_opcode_fops, msft_opcode_get, msft_opcode_set, +"%llu\n" ); +static int __vhci_create_device (struct vhci_data *data,__u8 opcode) {struct hci_dev *hdev;
drivers/bluetooth/hci_vhci.c static int __vhci_create_device(struct vhci_data *data, __u8 opcode) · line 293
Quoted 7 lines
drivers/bluetooth/hci_vhci.c +4
-0@@ -259,6 +287,10 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)debugfs_create_file ("force_wakeup" ,0644 , hdev->debugfs, data, &force_wakeup_fops); +if (IS_ENABLED (CONFIG_BT_MSFTEXT )) +debugfs_create_file ("msft_opcode" ,0644 , hdev->debugfs, data, + &msft_opcode_fops); +
So my concern is that you can modify this value when the device is up and running. That will cause havoc.
Just checking HCI_UP is kinda bad since we just removed that access from the drivers.
Regards
Marcel
Luiz Augusto von Dentz
maintainerHi Marcel,
Quoted 29 lines · Marcel Holtmann
Hi Luiz,
Quoted 13 lines
This adds a debugfs entry to set
msft_opcodeenabling vhci to emulate controllers with MSFT extention support.Signed-off-by Luiz Augusto von Dentz <[email protected]>---
drivers/bluetooth/hci_vhci.c| 32 ++++++++++++++++++++++++++++++++1 file changed, 32 insertions(+)drivers/bluetooth/hci_vhci.c +0
-0drivers/bluetooth/hci_vhci.c static const struct file_operations force_wakeup_fops = { · line 203
Quoted 10 lines
drivers/bluetooth/hci_vhci.c +7
-0@@ -194,6 +194,34 @@ static const struct file_operations force_wakeup_fops = { .llseek = default_llseek, }; + +static int msft_opcode_set (void *data,u64 val) +{ +struct vhci_data *vhci = data; +uint16_t ogf = (val &0xffff >>10 ); + +if (val >0xffff || ogf !=0x3f )I would actually just include it here to avoid any 16-bit overflow.
Quoted 1 line
if (val > 0xffff || (val & 0xffff >> 10) != 0x3f)
Ack.
Quoted 28 lines
Quoted 28 lines
drivers/bluetooth/hci_vhci.c +21
-0+return -EINVAL ; + +hci_set_msft_opcode (vhci->hdev, val); + +return 0 ; +} + +static int msft_opcode_get (void *data,u64 *val) +{ +struct vhci_data *vhci = data; + +hci_dev_lock (vhci->hdev); + *val = vhci->hdev->msft_opcode; +hci_dev_unlock (vhci->hdev); + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (msft_opcode_fops, msft_opcode_get, msft_opcode_set, +"%llu\n" ); +static int __vhci_create_device (struct vhci_data *data,__u8 opcode) {struct hci_dev *hdev;@@ -259,6 +287,10 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)debugfs_create_file ("force_wakeup" ,0644 , hdev->debugfs, data, &force_wakeup_fops);
Quoted 8 lines
drivers/bluetooth/hci_vhci.c static int __vhci_create_device(struct vhci_data *data, __u8 opcode) · line 293
Quoted 4 lines
drivers/bluetooth/hci_vhci.c +4
-0+if (IS_ENABLED (CONFIG_BT_MSFTEXT )) +debugfs_create_file ("msft_opcode" ,0644 , hdev->debugfs, data, + &msft_opcode_fops); +So my concern is that you can modify this value when the device is up and running. That will cause havoc.
Just checking
HCI_UPis kinda bad since we just removed that access from the drivers.
Right but we could add a check to HCI_UP inside hci_set_msft_opcode and make it return an error, actually this might be a good idea anyway even with existing so we prevent bad usage of hci_set_msft_opcode when already up.
Quoted 4 lines
Regards
Marcel
Signature · 1 line
Luiz Augusto von Dentz
Marcel Holtmann
maintainerHi Luiz,
Quoted 65 lines
Quoted 26 lines
Quoted 13 lines
This adds a debugfs entry to set
msft_opcodeenabling vhci to emulate controllers with MSFT extention support.Signed-off-by Luiz Augusto von Dentz <[email protected]>---
drivers/bluetooth/hci_vhci.c| 32 ++++++++++++++++++++++++++++++++1 file changed, 32 insertions(+)drivers/bluetooth/hci_vhci.c +0
-0drivers/bluetooth/hci_vhci.c static const struct file_operations force_wakeup_fops = { · line 203
Quoted 10 lines
drivers/bluetooth/hci_vhci.c +7
-0@@ -194,6 +194,34 @@ static const struct file_operations force_wakeup_fops = { .llseek = default_llseek, }; + +static int msft_opcode_set (void *data,u64 val) +{ +struct vhci_data *vhci = data; +uint16_t ogf = (val &0xffff >>10 ); + +if (val >0xffff || ogf !=0x3f )I would actually just include it here to avoid any 16-bit overflow.
Quoted 1 line
if (val > 0xffff || (val & 0xffff >> 10) != 0x3f)Ack.
Quoted 35 lines
Quoted 25 lines
drivers/bluetooth/hci_vhci.c +21
-0+return -EINVAL ; + +hci_set_msft_opcode (vhci->hdev, val); + +return 0 ; +} + +static int msft_opcode_get (void *data,u64 *val) +{ +struct vhci_data *vhci = data; + +hci_dev_lock (vhci->hdev); + *val = vhci->hdev->msft_opcode; +hci_dev_unlock (vhci->hdev); + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (msft_opcode_fops, msft_opcode_get, msft_opcode_set, +"%llu\n" ); +static int __vhci_create_device (struct vhci_data *data,__u8 opcode) {struct hci_dev *hdev;drivers/bluetooth/hci_vhci.c static int __vhci_create_device(struct vhci_data *data, __u8 opcode) · line 293
Quoted 7 lines
drivers/bluetooth/hci_vhci.c +4
-0@@ -259,6 +287,10 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)debugfs_create_file ("force_wakeup" ,0644 , hdev->debugfs, data, &force_wakeup_fops); +if (IS_ENABLED (CONFIG_BT_MSFTEXT )) +debugfs_create_file ("msft_opcode" ,0644 , hdev->debugfs, data, + &msft_opcode_fops); +So my concern is that you can modify this value when the device is up and running. That will cause havoc.
Quoted 6 lines
Quoted 1 line
Just checking
HCI_UPis kinda bad since we just removed that access from the drivers.Right but we could add a check to
HCI_UPinsidehci_set_msft_opcodeand make it return an error, actually this might be a good idea anyway even with existing so we prevent bad usage ofhci_set_msft_opcodewhen already up.
I did mean actually HCI_RUNNING, but this still won't work out since you should be able to set the opcode from hdev->setup.
You might be able to craft enough tests around HCI_INIT and HCI_SETUP to make it fail hci_set_msft_opcode. So that might be the safest way after all.
One other option is to actually just store the msft_opcode from debugfs in vhci_data. And then only set it from within hdev->setup. You need to set HCI_QUIRK_NON_PERSISTENT_SETUP for this, but that might actually work best then.
Note: you need an aosp_capable debugfs setting as well.
Regards
Marcel