From cd7c5fe467f464bf571cbdc57136e3ff19870e75 Mon Sep 17 00:00:00 2001 From: Ivan Shapovalov Date: Tue, 28 Jul 2026 11:03:24 +0300 Subject: [PATCH] OvmfPkg/VirtioInputDxe: do not set ScanCode together with UnicodeChar EFI_INPUT_KEY's ->ScanCode and ->UnicodeChar are mutually exclusive. The value space of ->ScanCode only includes representations of keys that are not representable in Unicode (F1-F10, Esc, arrows etc.) and vice versa. Furthermore, the integer representations of those fields overlap. As such, writing ->UnicodeChar values into ->ScanCode is invalid and produces bogus EFI_INPUT_KEYs that would compare inequal to any well-formed values that might be passed into e.g. RegisterKeyNotifyEx. Do not set ->ScanCode when a Unicode value is produced for a printable character. Signed-off-by: Ivan Shapovalov Tested-by: Alexander Mikhalitsyn --- OvmfPkg/VirtioInputDxe/VirtioKeyboard.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/OvmfPkg/VirtioInputDxe/VirtioKeyboard.c b/OvmfPkg/VirtioInputDxe/VirtioKeyboard.c index afbd1eba17..07c58040f6 100644 --- a/OvmfPkg/VirtioInputDxe/VirtioKeyboard.c +++ b/OvmfPkg/VirtioInputDxe/VirtioKeyboard.c @@ -167,10 +167,8 @@ VirtioKeyboardConvertKeyCode ( default: if (Dev->KeyActive[KEY_LEFTSHIFT] || Dev->KeyActive[KEY_RIGHTSHIFT]) { - Key->ScanCode = MapShift[Code]; Key->UnicodeChar = MapShift[Code]; } else { - Key->ScanCode = Map[Code]; Key->UnicodeChar = Map[Code]; }