tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Problems with implementing EFI runtime support for x86



Hello,

I am currently trying to implement efi runtime for x86-based ports, and I may need some guidance in terms of some issues that have emerged. My implementations are available here: https://github.com/3mdeb/NetBSD-src/pull/2/files and most notable changes are present in x86/x86/efi.c. Please excuse any bad practices and lack of knowledge on the subject, as I am only starting my journey of kernel
development.

As for what I have already done, I am basing my changes on ARM implementation by Jared McNeill (https://github.com/NetBSD/src/commit/1a8602b53e6f0adcbe8de4d4229ea4cfe80603ba),
with a few modifications. I extended the interface of EFI RT functions and
managed to map EFI runtime using a memmap provided by EFI.

The issue emerges when I try to execute any ABI call, e.g. gettime(). Logs:

uvm_fault(0xffffffff81908500, 0xffffb180a4165000, 4) -> e
fatal page fault in supervisor mode
trap type 6 code 0x11 rip ffffb180a416593e
kernel: page fault trap, code=0
Stopped in pid 0.0 (system) at ffffb180a416593e:	repe
?() at ffffb180a416593e
cpu_configure() at netbsd:cpu_configure+0x17
main() at netbsd

This is when I am trying to call a gettime function mapped to va using this
atrocity:
func_ptr = (efi_status (*)(struct efi_tm *, struct efi_tmcap *))
status = func_ptr(efi_debug_time, NULL);

Before I tried calling the function directly (a call to a physical address) from
a mapped RT services pointer with the same results (pagefaults).

Could anyone care to explain what am I missing to properly implement efi runtime support, or what I would need to correct - maybe efi_map_runtime() or efi_enter()
- as EFI RT on ARM has something more than just a mutex.

Getting EFI runtime implemented could be a big step in porting fwupd to NetBSD.

Kind regards,
Paweł



Home | Main Index | Thread Index | Old Index