From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web11.61.1614279297600546692 for ; Thu, 25 Feb 2021 10:54:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AR4KXUnV; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614279296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X37YelYHXBAhvSjFH2tykyMFZsoGaBCsXgGSLSG1E50=; b=AR4KXUnV1xfjhHJ8Dq2ER8kOo0kuFd5BtsEG0GImq/nbMxBAm8/2XKp9hJcmrsEHi/0gcW sjmbHVwf+fvVdkHthcklA//HKwsbOnWw6LL65jvrx0ZcvLkjYenDnpLlpfx8i+VD4xwBOg 7Sf2WdI1wQQo3T/D1KnpndBKDNChJk0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-JvOErFBnMgK3IF-klRDJKQ-1; Thu, 25 Feb 2021 13:54:54 -0500 X-MC-Unique: JvOErFBnMgK3IF-klRDJKQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63D4680196E; Thu, 25 Feb 2021 18:54:53 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-188.ams2.redhat.com [10.36.115.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B99E10013D6; Thu, 25 Feb 2021 18:54:52 +0000 (UTC) Subject: Re: implement about virtio-keyboard To: Zhu Yijun Cc: devel@edk2.groups.io, Ruiyu Ni , Ard Biesheuvel References: <81c4017a-ef40-f729-d304-956105910947@redhat.com> From: "Laszlo Ersek" Message-ID: <7e60715f-7b06-9751-8efb-fffba363959b@redhat.com> Date: Thu, 25 Feb 2021 19:54:51 +0100 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 02/24/21 03:55, Zhu Yijun wrote: > Thanks for the update. > > Now the usb tablet and keyboard are the only two usb devices on > aarch64, so I want to eliminate the "qemu-xhci" controller. > > I even think the situation that something more lightweight VMM instead > of QEMU may not support any USB controller, then virtio-input support > in UEFI is necessary. It's not necessary for me. It may be necessary for you. Feel free to contribute a virtio-input driver. > So if I want to implement this feature, can you give me some advice? I > see there are several keyboards in edk2, > VirtualKeyboardDxe/VirtualKeyboard.c looks more simple than usbkbd, > > can it be used as an example for reference? I've not dealt with EmbeddedPkg/Drivers/VirtualKeyboardDxe before. I don't know what kind of device this driver works with. The only commonality that VirtualKeyboardDxe might have with a possible virtio-input driver is that both of these drivers would be expected to produce EFI_SIMPLE_TEXT_INPUT_PROTOCOL. The virtio-input device is described in the virtio spec. You can see some virtio drivers under OvmfPkg. One of the simpler drivers there is VirtioRngDxe. Note that virtio-input, somewhat similarly to virtio-net, allows the host (= the device) to send events "asynchronously" to the guest (= the driver). This means that, because virtio is a request-response protocol, the driver would keep the virtio-input "eventq" populated with "requests" at all times. When there is an input event, the device "completes" a request with a "response", to inform the driver of a new input event. Anyhow, the virtio spec does explain this. Thanks, Laszlo > > Laszlo Ersek 于2021年2月23日周二 下午10:47写道: >> >> On 02/23/21 09:48, Zhu Yijun wrote: >>> Hi all, >>> I boot vm with the virtio keyboard on aarch64. It looks UEFI lacks >>> support for the virtio keyboard, so I can't do any keyboard input >>> before the linux kernel driver loads, i.e. edit the grub boot menu. Is >>> there any plan to support it? >> >> Not on my side. >> >> My team discussed virtio-input's relevance for ArmVirtQemu in September >> 2016. >> >> We decided not to bother about it, because: >> >> (1) XHCI was virtualization-friendly, both performance-wise and >> configuration-wise (unlike EHCI), >> >> (2) QEMU and libvirt were going to gain (... or had just gained ...) >> XHCI support, on aarch64 / "virt". >> >> >> So today, just use a "qemu-xhci" controller in your domain config >> please, in combination with a USB keyboard. (If you define a new aarch64 >> domain with libvirt, this should happen out of the box for you.) >> >> ArmVirtQemu includes all the edk2 drivers necessary for driving those >> devices, and ArmVirtQemu's PlatformBootManagerLib instance will connect >> the USB keyboard automatically. There shouldn't be a problem when typing >> in "grub". >> >> Thanks >> Laszlo >> >>> I find UsbKeyboardDevice attach on UsbIO which implements its >>> protocol interface structure(such as UsbGetInterfaceDescriptor, >>> UsbAsyncInterruptTransfer) defined by UEFI spec, but virtio not. So is >>> there some way to implement similar interfaces? >>> >>> Best regards, >>> Cheng Mao >>> >> >