acidanthera / bugtracker

Acidanthera Bugtracker
385 stars 45 forks source link

Potential Incompatibility between newer HP Touchscreen Laptops and KeySupport #1354

Closed HansKeksnascher closed 3 years ago

HansKeksnascher commented 3 years ago

Hello there,

a bug exists in the UEFI firmware implementations of certain HP Premium Laptops with touchscreen (manufactured after 2017?) which causes the firmware to think, when you boot an .efi file from the internal storage, that the file is a diagnostic tool. Then it offers a touchscreen keyboard for the user. (see attached screenshot)

This bug prevents the macOS kernel from booting from internal storage, external one work fine. It just freezes at #[EB|LOG:EXITBS:START]

When Clover was used, the workaround was to grab PreLoader.efi from efitools and rename the CloverX64.efi to Loader.efi, so the bootchain was PreLoader.efi -> Loader.efi and the touchscreen keyboard was gone in the Clover menu.

When using OpenCore this workaround does nothing. Touchscreen keyboard is still here.

After some research I discovered, that setting UEFI -> Input -> KeySupport to False fixed my problem, the touchscreen keyboard was gone and I was able to boot. But the new problem was, that OpenCore doesn't recognize any keyboard input and my trackpad, which is connected via SMBUS, stopped working in macOS. I also tried using OpenUsbKbDxe.efi, Ps2KeyboardDxe.efi, Ps2MouseDxe.efi and UsbMouseDxe.efi without any success. I also played around with the UEFI -> Input -> KeySupportMode setting, but it also changed nothing.

Some more ressources regarding this problem:

My device is a HP Spectre x360 - 13-ae001ng (Intel Core i5-8250U Kaby Lake Refresh with Intel UHD Graphics 620). The used OpenCore version was 0.6.4.

Let me know if you need any additional information and thanks for your fantastic work.

freeze

TingyiChen commented 3 years ago

Need check,but i doubt there isn't such a port to attach.

TingyiChen commented 3 years ago

Just checked,I didn't found any pins looks like a serial port

vit9696 commented 3 years ago

Right, in this case please try unloading the drivers through shell one by one.

vit9696 commented 3 years ago

Also, I asked the colleagues and they said that it is always worth checking that the BIOS is latest on HP laptops. Please update if necessary.

TingyiChen commented 3 years ago

The file I sent is already the latest version of my model,released on Dec 28 2020

TingyiChen commented 3 years ago

Right, in this case please try unloading the drivers through shell one by one.

I'll check it

vit9696 commented 3 years ago

In addition to the above. I was able to identify several issues, which supposedly caused OpenRuntime and EfiBoot load failure yesterday. Below I included r6 for a try (Bootstrap.efi and BOOTx64.efi also need to be replaced in corresponding folders).

SoftKbd-r6.zip

TingyiChen commented 3 years ago

Just checked, still stuck at same log. And I found that some modules like SoftKbd doesn't support unload from EFI shell, it is still there after I unloaded it. No idea how to go further now... Here's the log: opencore-2021-01-24-030314.txt opencore-2021-01-24-030609.txt

vit9696 commented 3 years ago

Hrm, I do not see you loading macOS in these logs actually. Rather OpenShell is started:

Perform boot OpenShell.efi to dp VenHw(33B5C65A-5B82-403D-87A5-D4676250EC59)/VenHw(1237EC17-D3CE-401D-A841-B1D818F8AF1A) (36729018/1040384)
TingyiChen commented 3 years ago

See the first one,on that one I loaded mac I tried unload all touchscreen related efi driver and then boot,but failed

vit9696 commented 3 years ago

Right, see it now. Well, I am really unsure what to try. We clearly disable softkbd, and without having the verbose kernel log it is nearly impossible to tell what is going on there.

TingyiChen commented 3 years ago

I guess I should try to load opencore via grub or something else maybe...Or switch to clover

获取 Outlook for Androidhttps://aka.ms/ghei36


From: Vitaly Cheptsov notifications@github.com Sent: Monday, January 25, 2021 12:54:29 AM To: acidanthera/bugtracker bugtracker@noreply.github.com Cc: Isaac Chen tingyi364@gmail.com; Comment comment@noreply.github.com Subject: Re: [acidanthera/bugtracker] Potential Incompatibility between newer HP Touchscreen Laptops and KeySupport (#1354)

Right, see it now. Well, I am really unsure what to try. We clearly disable softkbd, and without having the verbose kernel log it is nearly impossible to tell what is going on there.

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/acidanthera/bugtracker/issues/1354#issuecomment-766393411, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADSDAESIXHMS3C6CNDAUFS3S3RGELANCNFSM4USAPWMA.

vit9696 commented 3 years ago

Let me know if you succeed. Currently I do not see any special thing between what we do and what another operating system bootloader does. If you manage to find a chainload that works, it might help to understand the issue.

vit9696 commented 3 years ago

Regarding Preloader, can you tell me how did you use it? I expect that you put Preloader.efi to EFI/BOOT/BOOTx64.efi, and rename OpenCore's BOOTx64.efi to Loader.efi. Is that how you did it? Could you retry this with master and r6?

TingyiChen commented 3 years ago

Regarding Preloader, can you tell me how did you use it? I expect that you put Preloader.efi to EFI/BOOT/BOOTx64.efi, and rename OpenCore's BOOTx64.efi to Loader.efi. Is that how you did it? Could you retry this with master and r6?

Put Preloader.efi into EFI\OC, rename OpenCore.efi to loader.efi That's how it worked with clover

Could you retry this with master and r6?

I'll try it

vit9696 commented 3 years ago

No, that will not work for sure, you must invoke Bootstrap.efi/BOOTx64.efi (even renamed), not OpenCore.efi.

TingyiChen commented 3 years ago

Hmmm,I'll check it then

TingyiChen commented 3 years ago

I just tried replace BOOTX64.efi, the log just shown at the center of the screen during early oc init,but still failed to boot... Log: opencore-2021-01-25-070248.txt

vit9696 commented 3 years ago

So, you did the following:

  1. Put Preloader.efi to EFI\BOOT\Preloader.efi
  2. Renamed BOOTx64.efi to Loader.efi
  3. Ensured that Bootstrap is disabled in OC
  4. Added Preloader.efi to BIOS boot options
  5. Ensured that Preloader is the actual boot option used

Tried booting and it failed? Correct?

TingyiChen commented 3 years ago

Yes,still failed.Just stuck at the same log entry

vit9696 commented 3 years ago

Fun. There was a suggestion to use windows bootloader chainloading. Perhaps you can try (like this: https://www.applelife.ru/posts/918772). Point it to Bootstrap.efi.

TingyiChen commented 3 years ago

I'll check it now

gnodipac886 commented 3 years ago

I also have a Spectre (2020, 10th gen) running into the same issue. Happy to help. I think starting from Preloader is definitely a good way to go! :)

vit9696 commented 3 years ago

In addition to trying Windows bootloader I request trying the following. In https://github.com/acidanthera/OpenCorePkg/commit/1651cefe7fd0df3b5cc8553c6dadf1e226fe98f5 I added a patch that inserts an early reboot on kernel startup. Please add it to your setup and tell me the behaviour you can observe: a reboot or a stall:

For both Big Sur and Catalina. You could use dmg recovery for either if you do not have them installed.

TingyiChen commented 3 years ago

All rebooted after OC logs,both from USB and SSD I doubt there is some issue with Display related things

vit9696 commented 3 years ago

Good, so we do reach vstart. The issue is that the kernel dies before onscreen print is available. Let's find the function the kernel dies. Always test on both USB and SSD as at some time the patch may not be able to reboot your system.

It is easier to do it based off catalina. Start with _i386_init. See the source: https://opensource.apple.com/source/xnu/xnu-6153.141.1/osfmk/i386/i386_init.c.auto.html

Note, some functions are not exported in release builds. Use nm command on /System/Library/Kernels/kernel to check the name.

TingyiChen commented 3 years ago

I'll try do it. Testing on Big Sur now

TingyiChen commented 3 years ago

I tried invoke machine_startup,device rebooted Which func should try next?

vit9696 commented 3 years ago

machine_startup is here: https://opensource.apple.com/source/xnu/xnu-7195.50.7.100.1/osfmk/i386/AT386/model_dep.c.auto.html, you can download sources and find the relevant functions with grep or any other editor. The main thing after is kernel_bootstrap (https://opensource.apple.com/source/xnu/xnu-7195.50.7.100.1/osfmk/kern/startup.c.auto.html). However, the issue with Big Sur is that it no longer initialises things directly, but instead uses indirect constructions like kernel_startup_initialize_upto. It may be difficult to locate the precise point due to that. Still, worth trying.

TingyiChen commented 3 years ago

Looks like some symbols are not exported,can't find them via nm. I doubt it is hard to go next. I tried all exported symbols,all worked and restarted

vit9696 commented 3 years ago

It is not hard as we can go farther up to things like bsd_init. If it is difficult to locate the flow Catalina is your friend. If you need more guidance, let me know more about the points you can reach.

vit9696 commented 3 years ago

For Catalina my suggestions for patch testing:

_vstart
_i386_init
_i386_vm_init
_machine_startup
_kernel_bootstrap
_telemetry_init
_thread_init
TingyiChen commented 3 years ago

I'll check these funcs Little busy these days..May delay

TingyiChen commented 3 years ago

_kernel_bootstrap is not found via nm tried rest all funcs all triggered device restart I doubt there is something wrong with GOP or some display related things. Kernel may started but failed to display it on screen?

vit9696 commented 3 years ago

Are you sure that it clearly reaches _thread_init? I.e. in the log you see it successfully patched, and without this patch the system just freezes?

TingyiChen commented 3 years ago

I'll check log later Without the patch it just freezed

vit9696 commented 3 years ago

If yes, then try this patch:

Base: __ZN15AppleEFIRuntime5startEP9IOService
Identifier: com.apple.driver.AppleEFIRuntime
Find: empty
Replace: 31 C0 C3

It really is strange that it does not boot further…

vit9696 commented 3 years ago

As for GOP, I am starting to suspect that. According to the patches the system does seem to go much further than the onscreen console init, and it might in fact be starting, just failing to init. Try these things, separately from the patch above:

  1. Make sure you do not have debug=xx arguments.
  2. Wait for really long for the system to start (e.g. 10 minutes).
  3. Enable DirectGopRendering and send me the log (also try to start, but wait less, like 2-3 mins).
TingyiChen commented 3 years ago

If yes, then try this patch:

Base: __ZN15AppleEFIRuntime5startEP9IOService
Identifier: com.apple.driver.AppleEFIRuntime
Find: empty
Replace: 31 C0 C3

It really is strange that it does not boot further…

Tried,device freezed after EXITBS:START...Weird

vit9696 commented 3 years ago

Tried,device freezed after EXITBS:START...Weird

No, not weird. I believe we concluded that it is unlikely a UEFI memory management issue for your case. As we were able to get past the initialisation via reboot patches, and this patch disables post-initialisation UEFI support, yet nothing changed.

Please try the stuff above.

TingyiChen commented 3 years ago

I noticed that when the device freezed, press the power button just once can power off the device, looks kernel or power management driver not working normally?

vit9696 commented 3 years ago

Well, even if it is, it should already show something onscreen. We need to understand why it does not happen, and trying direct rendering (https://github.com/acidanthera/bugtracker/issues/1354#issuecomment-769691735) would be my first try.

TingyiChen commented 3 years ago

Tried with it.Still the same Here's the log: opencore-2021-01-29-112820.txt

vit9696 commented 3 years ago

I see no output from OpenCore, this was a release build, please fix.

TingyiChen commented 3 years ago

Switched to 0.6.5 Debug Log: opencore-2021-01-31-085818.txt Sorry for the late reply..

vit9696 commented 3 years ago

Hmm, and does the UI and EfiBoot output show onscreen normally? If you enable OpenCanopy, is it ok and glitch free? The GOP looks just fine, but for some reason it seems to stop being available after boot.

TingyiChen commented 3 years ago

All fine,just stuck there...

vit9696 commented 3 years ago

Maybe we should print the GOP params and MMAP when booting from USB and SSD. For the latter you could use MmapDump, this is an utility that comes from OC. For the former I will need to add custom prints later. Please do MmapDump first.

TingyiChen commented 3 years ago

ssd.txt usb.txt Here are logs,printed with 0.6.5 DEBUG version

vit9696 commented 3 years ago

I do not see MmapDump logs here. You need to run UEFI Shell and redirect MmapDump.efi output to file.