x86/earlyprintk: Don't fail the pciserial device with incorrect class code
RFC PATCH 1/1 x86/earlyprintk: Don't fail the pciserial device with incorrect class code
"pciserial" earlyprintk helps much on many modern x86 platforms, but unfortunately there are some platforms whose PCI UART devices have wrong PCI class code, which will be blocked by current check.
So loose the class code check by giving a warning message instead. This should be fine, as a developer who can give the accurate BDF should know whether it's a usable UART device.
--- arch/x86/kernel/early_printk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/early_printk.c +2 -1
@@ -265,7 +265,8 @@ static __init void early_pci_serial_init(char *s)if (((classcode >>16 !=PCI_CLASS_COMMUNICATION_MODEM ) && (classcode >>16 !=PCI_CLASS_COMMUNICATION_SERIAL )) || (((classcode >>8 ) &0xff ) !=0x02 ))/* 16550 I/F at BAR0 */ -return ; +pr_warn ("earlyprintk: classcode for pcidev %d:%d:%d shows it's not a UART like device, please check!\n" , + bus, slot, func);/* * Determine if it is IO or memory mapped
Signature · 1 line
2.7.4
Borislav Petkov
maintainerQuoted 7 lines · Feng Tang
"pciserial" earlyprintk helps much on many modern x86 platforms, but unfortunately there are some platforms whose PCI UART devices have wrong PCI class code, which will be blocked by current check.
So loose the class code check by giving a warning message instead. This should be fine, as a developer who can give the accurate BDF should know whether it's a usable UART device.
BDF? No.
Please write it out what it means.
Quoted 10 lines
Signed-off-by Feng Tang <[email protected]>--- arch/x86/kernel/early_printk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/kernel/early_printk.c +0
-0
arch/x86/kernel/early_printk.c static __init void early_pci_serial_init(char *s) · line 269
Quoted 6 lines
arch/x86/kernel/early_printk.c +2
-1@@ -265,7 +265,8 @@ static __init void early_pci_serial_init(char *s)if (((classcode >>16 !=PCI_CLASS_COMMUNICATION_MODEM ) && (classcode >>16 !=PCI_CLASS_COMMUNICATION_SERIAL )) || (((classcode >>8 ) &0xff ) !=0x02 ))/* 16550 I/F at BAR0 */ -return ; +pr_warn ("earlyprintk: classcode for pcidev %d:%d:%d shows it's not a UART like device, please check!\n" , + bus, slot, func);
So where did the return statement go?
What are you trying to do here? If the device is still an UART device then we don't need the check at all as you're basically overriding it and only the class code is wrong.
If so, why do we need the pr_warn at all? What can the user do about the class code? Nothing, I'd say. I don't see her "fixing" PCI config space so that the device has a correct class code.
But what happens if the user really supplies the wrong BDF? We end up poking in PCI config space of *some* device and then the cat might catch fire.
So it sounds to me like we need:
earlyprintk=pciserial,force,00:18.1,115200
where "force" allows the function to continue even if the classcode is wrong. Or
earlyprintk=pciserial,i_know_what_im_doing,00:18.1,115200
:-)
Also, if you're going to use pr_* variants, convert the file to use pr_fmt() - grep the kernel sources for examples.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Hi Borislav,
Thanks for the review.
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Feng Tang
"pciserial" earlyprintk helps much on many modern x86 platforms, but unfortunately there are some platforms whose PCI UART devices have wrong PCI class code, which will be blocked by current check.
Quoted 7 lines
Quoted 3 lines
So loose the class code check by giving a warning message instead. This should be fine, as a developer who can give the accurate BDF should know whether it's a usable UART device.
BDF? No.
Please write it out what it means.
Will do.
Quoted 19 lines
Quoted 10 lines
Signed-off-by Feng Tang <[email protected]>--- arch/x86/kernel/early_printk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/kernel/early_printk.c +0
-0arch/x86/kernel/early_printk.c static __init void early_pci_serial_init(char *s) · line 269
Quoted 6 lines
arch/x86/kernel/early_printk.c +2
-1@@ -265,7 +265,8 @@ static __init void early_pci_serial_init(char *s)if (((classcode >>16 !=PCI_CLASS_COMMUNICATION_MODEM ) && (classcode >>16 !=PCI_CLASS_COMMUNICATION_SERIAL )) || (((classcode >>8 ) &0xff ) !=0x02 ))/* 16550 I/F at BAR0 */ -return ; +pr_warn ("earlyprintk: classcode for pcidev %d:%d:%d shows it's not a UART like device, please check!\n" , + bus, slot, func);So where did the return statement go?
Quoted 7 lines
What are you trying to do here? If the device is still an UART device then we don't need the check at all as you're basically overriding it and only the class code is wrong.
If so, why do we need the
pr_warnat all? What can the user do about the class code? Nothing, I'd say. I don't see her "fixing" PCI config space so that the device has a correct class code.
That's true. We can hardly do anything from OS side,
Quoted 4 lines
But what happens if the user really supplies the wrong BDF? We end up poking in PCI config space of *some* device and then the cat might catch fire.
Valid point, I can not argue on this :)
Quoted 4 lines
So it sounds to me like we need:
earlyprintk=pciserial,force,00:18.1,115200
I would follow this way, thanks
-Feng