Skip to contentSkip to conversation

Crash in usb_keyboard

DISCUSSION Pavel Roskin 2 participants 5 messages Apr 28, 2009 – May 3, 2009

lore
Share & tools
lore
#0 lore raw

Hello!

Running "terminal_input.usb_keyboard" crashed GRUB (or qemu it's running in). It turns out we never check if usbdev in term/usb_keyboard.c is not NULL. It is NULL if no USB host controllers have been detected.

I'm not sure if we even want to call grub_term_register_input() if no USB keyboard is present.

Signature · 2 lines
Regards,
Pavel Roskin
#1 lore raw
Quoted 8 lines · Pavel Roskin

Hello!

Running "terminal_input.usb_keyboard" crashed GRUB (or qemu it's running in). It turns out we never check if usbdev in term/usb_keyboard.c is not NULL. It is NULL if no USB host controllers have been detected.

I'm not sure if we even want to call grub_term_register_input() if no USB keyboard is present.

What if a keyboard is not present, but plugged in later?

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#2 lore raw
Quoted 11 lines · Robert Millan
Quoted 8 lines · Pavel Roskin

Hello!

Running "terminal_input.usb_keyboard" crashed GRUB (or qemu it's running in). It turns out we never check if usbdev in term/usb_keyboard.c is not NULL. It is NULL if no USB host controllers have been detected.

I'm not sure if we even want to call grub_term_register_input() if no USB keyboard is present.

What if a keyboard is not present, but plugged in later?

If we add support for USB hotplug, then we'll take care of it. I don't think GRUB will support interrupts, but it may get support for timers that would rescan the USB tree periodically.

When USB hotplug is not supported, it doesn't really matter if terminal_input.usb_keyboard succeeds of fails in absence of a USB keyboard.

By the way, we need to handle the case of multiple keyboards. That would automatically take care of the zero keyboards.

It looks like the current code can match non-keyboards.

For my keyboard, "lsusb -v" gives:

  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
...
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None

The existing code doesn't check interfaces.

Signature · 2 lines
Regards,
Pavel Roskin
#3 lore raw
Quoted 8 lines · Pavel Roskin
Quoted 7 lines · Robert Millan
Quoted 6 lines · Pavel Roskin

Hello!

Running "terminal_input.usb_keyboard" crashed GRUB (or qemu it's running in). It turns out we never check if usbdev in term/usb_keyboard.c is not NULL. It is NULL if no USB host controllers have been detected.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I'm not sure if we even want to call grub_term_register_input() if no USB keyboard is present.

What if a keyboard is not present, but plugged in later?

If we add support for USB hotplug, then we'll take care of it. I don't think GRUB will support interrupts, but it may get support for timers that would rescan the USB tree periodically.

Our alternative to interrupts has so far been polling. Is it viable to poll for USB keyboards every time a read is attempted?

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#4 lore raw
Quoted 2 lines · Robert Millan

Our alternative to interrupts has so far been polling. Is it viable to poll for USB keyboards every time a read is attempted?

We can try it.

Signature · 2 lines
Regards,
Pavel Roskin