[prev in list] [next in list] [prev in thread] [next in thread] 

List:       grub-devel
Subject:    Re: Patch that fixes an 'at_keyboard' module issue (unreliable key presses)
From:       Michael Bideau <michael () michaelbideau ! net>
Date:       2019-09-10 22:29:42
Message-ID: BB12E251-5ED2-41B1-95F1-35DEA3B379A7 () michaelbideau ! net
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Paul and everyone,

My turn to be sorry for the late reply.
I was on my first sailing cruise last week, no computer on board. Scary
(45 knots), beautiful and a real team effort. Like grub dev' ahah.

My answer inline below...

Best regards,

Michael

Le mardi 03 septembre 2019 à 13:48 +0200, Paul Menzel a écrit :
> Dear Michael,
> 
> 
> I am sorry for the late reply.
> 
> 
> On 2019-08-29 00:24, Michael Bideau wrote:
> 
> > Le mardi 27 août 2019 à 11:57 +0200, Paul Menzel a écrit :
> > > On 8/24/19 9:09 PM, Michael Bideau wrote:
> > > 
> > > > This patch fixes an issue that prevented the 'at_keyboard'
> > > > module
> > > > to work (for me).
> > > > 
> > > > The cause is a bad/wrong return value in the function
> > > > 'grub_at_keyboard_getkey()' in file 
> > > > 'grub-core/term/at_keyboard.c' at line 234.
> > > > 
> > > > ///////// patch /////////
> > > > diff --git a/grub-core/term/at_keyboard.c b/grub-
> > > > core/term/at_keyboard.c
> > > > index f0a986eb1..597111077 100644
> > > > --- a/grub-core/term/at_keyboard.c
> > > > +++ b/grub-core/term/at_keyboard.c
> > > > @@ -234,7 +234,7 @@ grub_at_keyboard_getkey (struct
> > > > grub_term_input
> > > > *term __attribute__ ((unused)))
> > > > return GRUB_TERM_NO_KEY;
> > > > 
> > > > if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
> > > > -    return -1;
> > > > +    return GRUB_TERM_NO_KEY;
> > > > at_key = grub_inb (KEYBOARD_REG_DATA);
> > > > old_led = ps2_state.led_status;
> > > > ///////// end of patch /////////
> > > > 
> > > > 
> > > > My symptoms were to have an unresponsive keyboard: keys needed
> > > > to be pressed 10x and more to effectively be printed, sometimes
> > > > generating multiple key presses (after 1 or 2 sec of no
> > > > printing). Very problematic for typing passphrase in early
> > > > stage
> > > > (with GRUB_ENABLE_CRYPTODISK). When switching to 'console'
> > > > terminal input, keyboard works perfectly. It also worked great
> > > > with grub 2.02 packaged by Debian (2.02+dfsg1- 20). It was not
> > > > an
> > > > output issue, but an input one.
> > > 
> > > […]
> > > I think I had a similar issue and tried to fix it in commit
> > > d3a3543a
> > > (normal/menu: Do not treat error values as key presses) [1],
> > > present
> > > in GRUB 2.04. Do you have that commit in your tree?
> > 
> > Yes I have this/your commit in my tree.
> > 
> > ///////// your patch d3a3543a /////////
> > diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
> > index e7a83c2d6..d5e0c79a7 100644
> > --- a/grub-core/normal/menu.c
> > +++ b/grub-core/normal/menu.c
> > @@ -698,7 +698,8 @@ run_menu (grub_menu_t menu, int nested, int
> > *auto_boot)
> > 
> > c = grub_getkey_noblock ();
> > 
> > -      if (c != GRUB_TERM_NO_KEY)
> > +      /* Negative values are returned on error. */
> > +      if ((c != GRUB_TERM_NO_KEY) && (c > 0))
> > {
> > if (timeout >= 0)
> > {
> > ///////// end of your patch d3a3543a /////////
> > 
> > For what I understand, your patch seems to "only" address
> > normal/menu
> > timeout issue (but I might be wrong, I'm still very new to grub2
> > code),
> > but mine fixes the keyboard (if input is 'at_keyboard') wherever it
> > is
> > used in the normal/menu or in the grub terminal/shell or even with
> > the
> > cryptomount utility (typing passphrase was my issue at the
> > beginning).
> > 
> > To be clear, with the last checkout (commit 4e75b2ae3), that
> > includes
> > your commit d3a3543a, I have my keyboard not working reliably (as
> > described previously), and with my patch it works perfectly
> > (meaning
> > in the grub terminal/shell I can type commands seamlessly and even
> > use different keyboard layouts).
> 
> You are correct. Thank you for the analysis. Could you please create
> a
> "proper" commit with a commit message (most can be taken from your
> mail), and send that to this list?

The "proper" commit :

///////// show 261dd4318 /////////
at_keyboard: fix unreliable key presses

This patch fixes an issue that prevented the 'at_keyboard' module to work (for me).

The cause is a bad/wrong return value in the function 'grub_at_keyboard_getkey()' in \
file 'grub-core/term/at_keyboard.c' at line 237.

My symptoms were to have an unresponsive keyboard: keys needed to be pressed 10x and \
more to effectively be printed, sometimes generating multiple key presses (after 1 or \
2 sec of no printing). Very problematic for typing passphrase in early stage (with \
GRUB_ENABLE_CRYPTODISK). When switching to 'console' terminal input, keyboard works \
perfectly. It also worked great with grub 2.02 packaged by Debian (2.02+dfsg1-20).
It was not an output issue, but an input one.

I've managed to analyse the issue and found where it came from: the following commit:
---------- commit ----------
Commit: 216950a4eea1a1ead1c28eaca94e34ea2ef2ad19
Author: Vladimir Serbinenko <phcoder@gmail.com>
Date: Mon May 8 21:41:22 2017 +0200

at_keyboard: Split protocol from controller code.

On vexpress controller is different but protocol is the same, so reuse the code.
---------- end of commit ----------

3 lines where moved from the function 'fetch_key()' in file \
'grub-core/term/at_keyboard.c', to the begining of function \
'grub_at_keyboard_getkey()' (same file). But returning '-1' made sense when in \
function 'fetch_key()' but not anymore in function 'grub_at_keyboard_getkey()', which \
should return 'GRUB_TERM_NO_KEY'.

I think it was just an incomplete cut-paste, missing a small manual correction.
Better fix it.
///////// end of commit /////////

Please, feel free to edit/cut the commit message as you wish.

> By the way, do you only have this problem on one machine or all? Can
> it
> be reproduced in QEMU?

Actually I only have that issue with my libvirt-qemu-kvm virtual
machines (where I do grub tweaking and theming).
I've never used qemu directly, only through libvirt and with a GUI
(virt-manager).

But I can provide you the log of libvirt containing the qemu command,
and the dump of my VM configuration (and some host informations). See
below.

///////// log of libvirt: /var/log/libvirt/qemu/debian9.log /////////
019-09-10 21:27:15.157+0000: starting up libvirt version: 4.10.0, package: 2 (Guido \
Günther <agx@sigxcpu.org> Tue, 18 Dec 2018 12:55:10 +0100), qemu version: \
2.12.0Debian 1:2.12+dfsg-3+b1, kernel: 4.9.0-8-amd64, hostname: debian-host LC_ALL=C \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
QEMU_AUDIO_DRV=spice /usr/bin/kvm -name guest=debian9,debug-threads=on -S -object \
secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-debian9/master-key.aes \
-machine pc-i440fx-2.8,accel=kvm,usb=off,vmport=off,dump-guest-core=off -cpu Nehalem \
-m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid \
360d8792-c34f-43d6-bc80-149de68ff11b -no-user-config -nodefaults -chardev \
socket,id=charmonitor,fd=26,server,nowait -mon \
chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global \
kvm-pit.lost_tick_policy=delay -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 \
-global PIIX4_PM.disable_s4=1 -boot menu=on,strict=on -device \
ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x4.0x7 -device \
ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x4 \
-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 -device \
ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 -device \
lsi,id=scsi0,bus=pci.0,addr=0x6 -device ahci,id=sata0,bus=pci.0,addr=0x7 -device \
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive \
file=/var/lib/libvirt/images/debian-9.5.0-amd64-netinst.iso,format=raw,if=none,id=drive-ide0-0-0,readonly=on \
-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2 -drive \
file=/home/michael/VMs/test-btrfs1.qcow2,format=qcow2,if=none,id=drive-sata0-0-0 \
-device ide-hd,bus=sata0.0,drive=drive-sata0-0-0,id=sata0-0-0,bootindex=1 -drive \
file=/home/michael/VMs/test-btrfs2.qcow2,format=qcow2,if=none,id=drive-sata0-0-1 \
-device ide-hd,bus=sata0.1,drive=drive-sata0-0-1,id=sata0-0-1 -netdev \
tap,fd=28,id=hostnet0,vhost=on,vhostfd=29 -device \
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:68:f1:50,bus=pci.0,addr=0x3 \
-chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 \
-chardev socket,id=charchannel0,fd=30,server,nowait -device \
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \
-chardev spicevmc,id=charchannel1,name=vdagent -device \
virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=com.redhat.spice.0 \
-device usb-tablet,id=input0,bus=usb.0,port=1 -spice \
port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on \
-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \
-chardev spicevmc,id=charredir0,name=usbredir -device \
usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 -chardev \
spicevmc,id=charredir1,name=usbredir -device \
usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 -device \
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8 -sandbox \
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg \
timestamp=on

2019-09-10T21:27:15.760474Z qemu-system-x86_64: -chardev pty,id=charserial0: char \
device redirected to /dev/pts/0 (label charserial0) ///////// end of log /////////


///////// XML output of command: sudo virsh dumpxml debian9 /////////
<domain type='kvm' id='1'>
  <name>debian9</name>
  <uuid>360d8792-c34f-43d6-bc80-149de68ff11b</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.8'>hvm</type>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <vmport state='off'/>
  </features>
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>Nehalem</model>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='x2apic'/>
    <feature policy='require' name='hypervisor'/>
  </cpu>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/debian-9.5.0-amd64-
netinst.iso'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <boot order='2'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0'
unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/michael/VMs/test-btrfs1.qcow2'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <boot order='1'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0'
unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/michael/VMs/test-btrfs2.qcow2'/>
      <backingStore/>
      <target dev='sdb' bus='sata'/>
      <alias name='sata0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0'
unit='1'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04'
function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04'
function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04'
function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04'
function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01'
function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05'
function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='sata0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07'
function='0x0'/>
    </controller>
    <controller type='scsi' index='0' model='lsilogic'>
      <alias name='scsi0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06'
function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:68:f1:50'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03'
function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/0'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/0'>
      <source path='/dev/pts/0'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='unix'>
      <source mode='bind'
path='/var/lib/libvirt/qemu/channel/target/domain-1-
debian9/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0'
state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0'
state='disconnected'/>
      <alias name='channel1'/>
      <address type='virtio-serial' controller='0' bus='0' port='2'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'>
      <alias name='input1'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input2'/>
    </input>
    <graphics type='spice' port='5900' autoport='yes'
listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
      <image compression='off'/>
    </graphics>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384'
heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02'
function='0x0'/>
    </video>
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir0'/>
      <address type='usb' bus='0' port='2'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir1'/>
      <address type='usb' bus='0' port='3'/>
    </redirdev>
    <memballoon model='virtio'>
      <stats period='5'/>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08'
function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+64055:+64055</label>
    <imagelabel>+64055:+64055</imagelabel>
  </seclabel>
</domain>
///////// XML end of output /////////

Hope this helps.
If you need more informations, I'll be glad to dig.

> > PS: there is a typo in my introduction of my patch: it is at the
> > line
> > 237 and not 234 as mentioned. Do you think I should answer to my
> > first
> > email to say it (so people not reading this sub-thread will know)?
> 
> You can fix that in the commit message.
> 
> Please ask if you need further help.

Thank you very much for your help and kind support.

> Kind regards,
> 
> Paul
> 
> 
> > > [1]: 
> > > https://git.savannah.gnu.org/cgit/grub.git/commit/?id=d3a3543a5666c1dd180ae6027948ca753dcffc18
> > >  


[Attachment #5 (text/html)]

Hi Paul and everyone,<br><br>My turn to be sorry for the late reply.<br>I was on my \
first sailing cruise last week, no computer on board. Scary<br>(45 knots), beautiful \
and a real team effort. Like grub dev' ahah.<br><br>My answer inline \
below...<br><br>Best regards,<br><br>Michael<br><br>Le mardi 03 septembre 2019 Ã  \
13:48 +0200, Paul Menzel a écrit :<br>&gt; Dear Michael,<br>&gt; <br>&gt; <br>&gt; I \
am sorry for the late reply.<br>&gt; <br>&gt; <br>&gt; On 2019-08-29 00:24, Michael \
Bideau wrote:<br>&gt; <br>&gt; &gt; Le mardi 27 août 2019 à 11:57 +0200, Paul \
Menzel a écrit :<br>&gt; &gt; &gt; On 8/24/19 9:09 PM, Michael Bideau wrote:<br>&gt; \
&gt; &gt; <br>&gt; &gt; &gt; &gt; This patch fixes an issue that prevented the \
'at_keyboard'<br>&gt; &gt; &gt; &gt; module<br>&gt; &gt; &gt; &gt; to work (for \
me).<br>&gt; &gt; &gt; &gt; <br>&gt; &gt; &gt; &gt; The cause is a bad/wrong return \
value in the function<br>&gt; &gt; &gt; &gt; 'grub_at_keyboard_getkey()' in file \
<br>&gt; &gt; &gt; &gt; 'grub-core/term/at_keyboard.c' at line 234.<br>&gt; &gt; &gt; \
&gt; <br>&gt; &gt; &gt; &gt; ///////// patch /////////<br>&gt; &gt; &gt; &gt; diff \
--git a/grub-core/term/at_keyboard.c b/grub-<br>&gt; &gt; &gt; &gt; \
core/term/at_keyboard.c<br>&gt; &gt; &gt; &gt; index f0a986eb1..597111077 \
100644<br>&gt; &gt; &gt; &gt; --- a/grub-core/term/at_keyboard.c<br>&gt; &gt; &gt; \
&gt; +++ b/grub-core/term/at_keyboard.c<br>&gt; &gt; &gt; &gt; @@ -234,7 +234,7 @@ \
grub_at_keyboard_getkey (struct<br>&gt; &gt; &gt; &gt; grub_term_input<br>&gt; &gt; \
&gt; &gt; *term __attribute__ ((unused)))<br>&gt; &gt; &gt; &gt;      return \
GRUB_TERM_NO_KEY;<br>&gt; &gt; &gt; &gt;  <br>&gt; &gt; &gt; &gt;    if (! \
KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))<br>&gt; &gt; &gt; &gt; -    return \
-1;<br>&gt; &gt; &gt; &gt; +    return GRUB_TERM_NO_KEY;<br>&gt; &gt; &gt; &gt;    \
at_key = grub_inb (KEYBOARD_REG_DATA);<br>&gt; &gt; &gt; &gt;    old_led = \
ps2_state.led_status;<br>&gt; &gt; &gt; &gt; ///////// end of patch /////////<br>&gt; \
&gt; &gt; &gt; <br>&gt; &gt; &gt; &gt; <br>&gt; &gt; &gt; &gt; My symptoms were to \
have an unresponsive keyboard: keys needed<br>&gt; &gt; &gt; &gt; to be pressed 10x \
and more to effectively be printed, sometimes<br>&gt; &gt; &gt; &gt; generating \
multiple key presses (after 1 or 2 sec of no<br>&gt; &gt; &gt; &gt; printing). Very \
problematic for typing passphrase in early<br>&gt; &gt; &gt; &gt; stage<br>&gt; &gt; \
&gt; &gt; (with GRUB_ENABLE_CRYPTODISK). When switching to 'console'<br>&gt; &gt; \
&gt; &gt; terminal input, keyboard works perfectly. It also worked great<br>&gt; &gt; \
&gt; &gt; with grub 2.02 packaged by Debian (2.02+dfsg1- 20). It was not<br>&gt; &gt; \
&gt; &gt; an<br>&gt; &gt; &gt; &gt; output issue, but an input one.<br>&gt; &gt; &gt; \
<br>&gt; &gt; &gt; […]<br>&gt; &gt; &gt; I think I had a similar issue and tried to \
fix it in commit<br>&gt; &gt; &gt; d3a3543a<br>&gt; &gt; &gt; (normal/menu: Do not \
treat error values as key presses) [1],<br>&gt; &gt; &gt; present<br>&gt; &gt; &gt; \
in GRUB 2.04. Do you have that commit in your tree?<br>&gt; &gt; <br>&gt; &gt; Yes I \
have this/your commit in my tree.<br>&gt; &gt; <br>&gt; &gt; ///////// your patch \
d3a3543a /////////<br>&gt; &gt; diff --git a/grub-core/normal/menu.c \
b/grub-core/normal/menu.c<br>&gt; &gt; index e7a83c2d6..d5e0c79a7 100644<br>&gt; &gt; \
--- a/grub-core/normal/menu.c<br>&gt; &gt; +++ b/grub-core/normal/menu.c<br>&gt; &gt; \
@@ -698,7 +698,8 @@ run_menu (grub_menu_t menu, int nested, int<br>&gt; &gt; \
*auto_boot)<br>&gt; &gt;  <br>&gt; &gt;        c = grub_getkey_noblock ();<br>&gt; \
&gt;  <br>&gt; &gt; -      if (c != GRUB_TERM_NO_KEY)<br>&gt; &gt; +      /* Negative \
values are returned on error. */<br>&gt; &gt; +      if ((c != GRUB_TERM_NO_KEY) \
&amp;&amp; (c &gt; 0))<br>&gt; &gt;         {<br>&gt; &gt;           if (timeout \
&gt;= 0)<br>&gt; &gt;             {<br>&gt; &gt; ///////// end of your patch d3a3543a \
/////////<br>&gt; &gt; <br>&gt; &gt; For what I understand, your patch seems to \
"only" address<br>&gt; &gt; normal/menu<br>&gt; &gt; timeout issue (but I might be \
wrong, I'm still very new to grub2<br>&gt; &gt; code),<br>&gt; &gt; but mine fixes \
the keyboard (if input is 'at_keyboard') wherever it<br>&gt; &gt; is<br>&gt; &gt; \
used in the normal/menu or in the grub terminal/shell or even with<br>&gt; &gt; \
the<br>&gt; &gt; cryptomount utility (typing passphrase was my issue at the<br>&gt; \
&gt; beginning).<br>&gt; &gt; <br>&gt; &gt; To be clear, with the last checkout \
(commit 4e75b2ae3), that<br>&gt; &gt; includes<br>&gt; &gt; your commit d3a3543a, I \
have my keyboard not working reliably (as<br>&gt; &gt; described previously), and \
with my patch it works perfectly<br>&gt; &gt; (meaning<br>&gt; &gt; in the grub \
terminal/shell I can type commands seamlessly and even<br>&gt; &gt; use different \
keyboard layouts).<br>&gt; <br>&gt; You are correct. Thank you for the analysis. \
Could you please create<br>&gt; a<br>&gt; "proper" commit with a commit message (most \
can be taken from your<br>&gt; mail), and send that to this list?<br><br>The "proper" \
commit :<br><br>///////// show 261dd4318 /////////<br>at_keyboard: fix unreliable key \
presses<br><br>This patch fixes an issue that prevented the 'at_keyboard' module to \
work (for me).<br><br>The cause is a bad/wrong return value in the function \
'grub_at_keyboard_getkey()' in file 'grub-core/term/at_keyboard.c' at line \
237.<br><br>My symptoms were to have an unresponsive keyboard: keys needed to be \
pressed 10x and more to<br>effectively be printed, sometimes generating multiple key \
presses (after 1 or 2 sec of no printing).<br>Very problematic for typing passphrase \
in early stage (with GRUB_ENABLE_CRYPTODISK).<br>When switching to 'console' terminal \
input, keyboard works perfectly.<br>It also worked great with grub 2.02 packaged by \
Debian (2.02+dfsg1-20).<br>It was not an output issue, but an input one.<br><br>I've \
managed to analyse the issue and found where it came from: the following \
commit:<br>---------- commit ----------<br>Commit: \
216950a4eea1a1ead1c28eaca94e34ea2ef2ad19<br>Author: Vladimir Serbinenko \
&lt;phcoder@gmail.com&gt;<br>Date: Mon May 8 21:41:22 2017 +0200<br><br>at_keyboard: \
Split protocol from controller code.<br><br>On vexpress controller is different but \
protocol is the same, so reuse the code.<br>---------- end of commit \
----------<br><br>3 lines where moved from the function 'fetch_key()' in file \
'grub-core/term/at_keyboard.c', to the begining of function \
'grub_at_keyboard_getkey()' (same file).<br>But returning '-1' made sense when in \
function 'fetch_key()' but not anymore in function 'grub_at_keyboard_getkey()', which \
should return 'GRUB_TERM_NO_KEY'.<br><br>I think it was just an incomplete cut-paste, \
missing a small manual correction.<br>Better fix it.<br>///////// end of commit \
/////////<br><br>Please, feel free to edit/cut the commit message as you \
wish.<br><br>&gt; By the way, do you only have this problem on one machine or all? \
Can<br>&gt; it<br>&gt; be reproduced in QEMU?<br><br>Actually I only have that issue \
with my libvirt-qemu-kvm virtual<br>machines (where I do grub tweaking and \
theming).<br>I've never used qemu directly, only through libvirt and with a \
GUI<br>(virt-manager).<br><br>But I can provide you the log of libvirt containing the \
qemu command,<br>and the dump of my VM configuration (and some host informations). \
See<br>below.<br><br>///////// log of libvirt: /var/log/libvirt/qemu/debian9.log \
/////////<br>019-09-10 21:27:15.157+0000: starting up libvirt version: 4.10.0, \
package: 2 (Guido Günther &lt;agx@sigxcpu.org&gt; Tue, 18 Dec 2018 12:55:10 +0100), \
qemu version: 2.12.0Debian 1:2.12+dfsg-3+b1, kernel: 4.9.0-8-amd64, hostname: \
debian-host<br>LC_ALL=C \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
QEMU_AUDIO_DRV=spice /usr/bin/kvm -name guest=debian9,debug-threads=on -S -object \
secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-debian9/master-key.aes \
-machine pc-i440fx-2.8,accel=kvm,usb=off,vmport=off,dump-guest-core=off -cpu Nehalem \
-m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid \
360d8792-c34f-43d6-bc80-149de68ff11b -no-user-config -nodefaults -chardev \
socket,id=charmonitor,fd=26,server,nowait -mon \
chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global \
kvm-pit.lost_tick_policy=delay -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 \
-global PIIX4_PM.disable_s4=1 -boot menu=on,strict=on -device \
ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x4.0x7 -device \
ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x4 \
-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 -device \
ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 -device \
lsi,id=scsi0,bus=pci.0,addr=0x6 -device ahci,id=sata0,bus=pci.0,addr=0x7 -device \
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive \
file=/var/lib/libvirt/images/debian-9.5.0-amd64-netinst.iso,format=raw,if=none,id=drive-ide0-0-0,readonly=on \
-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2 -drive \
file=/home/michael/VMs/test-btrfs1.qcow2,format=qcow2,if=none,id=drive-sata0-0-0 \
-device ide-hd,bus=sata0.0,drive=drive-sata0-0-0,id=sata0-0-0,bootindex=1 -drive \
file=/home/michael/VMs/test-btrfs2.qcow2,format=qcow2,if=none,id=drive-sata0-0-1 \
-device ide-hd,bus=sata0.1,drive=drive-sata0-0-1,id=sata0-0-1 -netdev \
tap,fd=28,id=hostnet0,vhost=on,vhostfd=29 -device \
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:68:f1:50,bus=pci.0,addr=0x3 \
-chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 \
-chardev socket,id=charchannel0,fd=30,server,nowait -device \
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \
-chardev spicevmc,id=charchannel1,name=vdagent -device \
virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=com.redhat.spice.0 \
-device usb-tablet,id=input0,bus=usb.0,port=1 -spice \
port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on \
-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \
-chardev spicevmc,id=charredir0,name=usbredir -device \
usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 -chardev \
spicevmc,id=charredir1,name=usbredir -device \
usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 -device \
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8 -sandbox \
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg \
timestamp=on<br><br>2019-09-10T21:27:15.760474Z qemu-system-x86_64: -chardev \
pty,id=charserial0: char device redirected to /dev/pts/0 (label \
charserial0)<br>///////// end of log /////////<br><br><br>///////// XML output of \
command: sudo virsh dumpxml debian9 /////////<br>&lt;domain type='kvm' id='1'&gt;<br> \
&lt;name&gt;debian9&lt;/name&gt;<br>  \
&lt;uuid&gt;360d8792-c34f-43d6-bc80-149de68ff11b&lt;/uuid&gt;<br>  &lt;memory \
unit='KiB'&gt;1048576&lt;/memory&gt;<br>  &lt;currentMemory \
unit='KiB'&gt;1048576&lt;/currentMemory&gt;<br>  &lt;vcpu \
placement='static'&gt;1&lt;/vcpu&gt;<br>  &lt;resource&gt;<br>    \
&lt;partition&gt;/machine&lt;/partition&gt;<br>  &lt;/resource&gt;<br>  \
&lt;os&gt;<br>    &lt;type arch='x86_64' \
machine='pc-i440fx-2.8'&gt;hvm&lt;/type&gt;<br>    &lt;bootmenu enable='yes'/&gt;<br> \
&lt;/os&gt;<br>  &lt;features&gt;<br>    &lt;acpi/&gt;<br>    &lt;apic/&gt;<br>    \
&lt;vmport state='off'/&gt;<br>  &lt;/features&gt;<br>  &lt;cpu mode='custom' \
match='exact' check='full'&gt;<br>    &lt;model \
fallback='forbid'&gt;Nehalem&lt;/model&gt;<br>    &lt;feature policy='require' \
name='vme'/&gt;<br>    &lt;feature policy='require' name='x2apic'/&gt;<br>    \
&lt;feature policy='require' name='hypervisor'/&gt;<br>  &lt;/cpu&gt;<br>  &lt;clock \
offset='utc'&gt;<br>    &lt;timer name='rtc' tickpolicy='catchup'/&gt;<br>    \
&lt;timer name='pit' tickpolicy='delay'/&gt;<br>    &lt;timer name='hpet' \
present='no'/&gt;<br>  &lt;/clock&gt;<br>  \
&lt;on_poweroff&gt;destroy&lt;/on_poweroff&gt;<br>  \
&lt;on_reboot&gt;restart&lt;/on_reboot&gt;<br>  \
&lt;on_crash&gt;restart&lt;/on_crash&gt;<br>  &lt;pm&gt;<br>    &lt;suspend-to-mem \
enabled='no'/&gt;<br>    &lt;suspend-to-disk enabled='no'/&gt;<br>  &lt;/pm&gt;<br>  \
&lt;devices&gt;<br>    &lt;emulator&gt;/usr/bin/kvm&lt;/emulator&gt;<br>    &lt;disk \
type='file' device='cdrom'&gt;<br>      &lt;driver name='qemu' type='raw'/&gt;<br>    \
&lt;source file='/var/lib/libvirt/images/debian-9.5.0-amd64-<br>netinst.iso'/&gt;<br> \
&lt;backingStore/&gt;<br>      &lt;target dev='hda' bus='ide'/&gt;<br>      \
&lt;readonly/&gt;<br>      &lt;boot order='2'/&gt;<br>      &lt;alias \
name='ide0-0-0'/&gt;<br>      &lt;address type='drive' controller='0' bus='0' \
target='0'<br>unit='0'/&gt;<br>    &lt;/disk&gt;<br>    &lt;disk type='file' \
device='disk'&gt;<br>      &lt;driver name='qemu' type='qcow2'/&gt;<br>      \
&lt;source file='/home/michael/VMs/test-btrfs1.qcow2'/&gt;<br>      \
&lt;backingStore/&gt;<br>      &lt;target dev='sda' bus='sata'/&gt;<br>      &lt;boot \
order='1'/&gt;<br>      &lt;alias name='sata0-0-0'/&gt;<br>      &lt;address \
type='drive' controller='0' bus='0' target='0'<br>unit='0'/&gt;<br>    \
&lt;/disk&gt;<br>    &lt;disk type='file' device='disk'&gt;<br>      &lt;driver \
name='qemu' type='qcow2'/&gt;<br>      &lt;source \
file='/home/michael/VMs/test-btrfs2.qcow2'/&gt;<br>      &lt;backingStore/&gt;<br>    \
&lt;target dev='sdb' bus='sata'/&gt;<br>      &lt;alias name='sata0-0-1'/&gt;<br>     \
&lt;address type='drive' controller='0' bus='0' target='0'<br>unit='1'/&gt;<br>    \
&lt;/disk&gt;<br>    &lt;controller type='usb' index='0' model='ich9-ehci1'&gt;<br>   \
&lt;alias name='usb'/&gt;<br>      &lt;address type='pci' domain='0x0000' bus='0x00' \
slot='0x04'<br>function='0x7'/&gt;<br>    &lt;/controller&gt;<br>    &lt;controller \
type='usb' index='0' model='ich9-uhci1'&gt;<br>      &lt;alias name='usb'/&gt;<br>    \
&lt;master startport='0'/&gt;<br>      &lt;address type='pci' domain='0x0000' \
bus='0x00' slot='0x04'<br>function='0x0' multifunction='on'/&gt;<br>    \
&lt;/controller&gt;<br>    &lt;controller type='usb' index='0' \
model='ich9-uhci2'&gt;<br>      &lt;alias name='usb'/&gt;<br>      &lt;master \
startport='2'/&gt;<br>      &lt;address type='pci' domain='0x0000' bus='0x00' \
slot='0x04'<br>function='0x1'/&gt;<br>    &lt;/controller&gt;<br>    &lt;controller \
type='usb' index='0' model='ich9-uhci3'&gt;<br>      &lt;alias name='usb'/&gt;<br>    \
&lt;master startport='4'/&gt;<br>      &lt;address type='pci' domain='0x0000' \
bus='0x00' slot='0x04'<br>function='0x2'/&gt;<br>    &lt;/controller&gt;<br>    \
&lt;controller type='pci' index='0' model='pci-root'&gt;<br>      &lt;alias \
name='pci.0'/&gt;<br>    &lt;/controller&gt;<br>    &lt;controller type='ide' \
index='0'&gt;<br>      &lt;alias name='ide'/&gt;<br>      &lt;address type='pci' \
domain='0x0000' bus='0x00' slot='0x01'<br>function='0x1'/&gt;<br>    \
&lt;/controller&gt;<br>    &lt;controller type='virtio-serial' index='0'&gt;<br>      \
&lt;alias name='virtio-serial0'/&gt;<br>      &lt;address type='pci' domain='0x0000' \
bus='0x00' slot='0x05'<br>function='0x0'/&gt;<br>    &lt;/controller&gt;<br>    \
&lt;controller type='sata' index='0'&gt;<br>      &lt;alias name='sata0'/&gt;<br>     \
&lt;address type='pci' domain='0x0000' bus='0x00' \
slot='0x07'<br>function='0x0'/&gt;<br>    &lt;/controller&gt;<br>    &lt;controller \
type='scsi' index='0' model='lsilogic'&gt;<br>      &lt;alias name='scsi0'/&gt;<br>   \
&lt;address type='pci' domain='0x0000' bus='0x00' \
slot='0x06'<br>function='0x0'/&gt;<br>    &lt;/controller&gt;<br>    &lt;interface \


[Attachment #6 (text/plain)]

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic