Page MenuHomeFreeBSD

D55662.id.diff
No OneTemporary

D55662.id.diff

diff --git a/sys/amd64/amd64/efirt_support.S b/sys/amd64/amd64/efirt_support.S
--- a/sys/amd64/amd64/efirt_support.S
+++ b/sys/amd64/amd64/efirt_support.S
@@ -32,6 +32,13 @@
#include "assym.inc"
+/*
+ * int efi_rt_arch_call(struct efirt_callinfo *ec)
+ *
+ * Fault-recovery wrapper: saves callee-saved registers, installs
+ * pcb_onfault, delegates to efi_rt_dispatch() for the actual call,
+ * then restores registers. Returns 0 on success, EFAULT on fault.
+ */
.text
ENTRY(efi_rt_arch_call)
pushq %rbp
@@ -47,45 +54,17 @@
pushfq
popq %rax
movq %rax, EC_RFLAGS(%rdi)
+
movq PCPU(CURTHREAD), %rax
movq %rdi, TD_MD+MD_EFIRT_TMP(%rax)
- movq PCPU(CURPCB), %rsi
-
- movl EC_ARGCNT(%rdi), %ecx
- movl %ecx, %ebx
- movl $4, %eax
- cmpl %eax, %ecx
- cmovbl %eax, %ecx
- shll $3, %ecx
- subq %rcx, %rsp
- cmpl $0, %ebx
- jz 1f
- movq EC_ARG1(%rdi), %rcx
- decl %ebx
- jz 1f
- movq EC_ARG2(%rdi), %rdx
- decl %ebx
- jz 1f
- movq EC_ARG3(%rdi), %r8
- decl %ebx
- jz 1f
- movq EC_ARG4(%rdi), %r9
- decl %ebx
- jz 1f
- movq EC_ARG5(%rdi), %rax
- movq %rax, 4*8(%rsp)
- decl %ebx
- jz 1f
- movq $efi_rt_panic_str, %rdi
- call panic
-1: movq EC_FPTR(%rdi), %rax
+ movq PCPU(CURPCB), %rsi
movq $efi_rt_fault, PCB_ONFAULT(%rsi)
- callq *%rax
+
+ call efi_rt_dispatch
movq PCPU(CURTHREAD), %rbx
movq TD_MD+MD_EFIRT_TMP(%rbx), %rdi
- movq %rax, EC_EFI_STATUS(%rdi)
movq PCPU(CURPCB), %rsi
xorl %eax, %eax
movq %rax, PCB_ONFAULT(%rsi)
@@ -105,6 +84,10 @@
ret
END(efi_rt_arch_call)
+/*
+ * Fault entry point: trap handler redirects here on EFI RT fault.
+ * Clears pcb_onfault, returns EFAULT through the saved register frame.
+ */
ENTRY(efi_rt_fault)
xorl %eax, %eax
movq PCPU(CURPCB), %rsi
@@ -114,5 +97,3 @@
movq TD_MD+MD_EFIRT_TMP(%rbx), %rdi
jmp efi_rt_arch_call_tail
END(efi_rt_fault)
-
-efi_rt_panic_str: .asciz "efi_rt_arch_call: too many args"
diff --git a/sys/dev/efidev/efirt.c b/sys/dev/efidev/efirt.c
--- a/sys/dev/efidev/efirt.c
+++ b/sys/dev/efidev/efirt.c
@@ -527,8 +527,13 @@
&efi_rt_handle_faults, 0,
"Call EFI RT methods with fault handler wrapper around");
-static int
-efi_rt_arch_call_nofault(struct efirt_callinfo *ec)
+/*
+ * Invoke an EFI runtime service using compiler-generated ms_abi calls.
+ * EFIABI_ATTR casts let the compiler handle the SysV-to-MS ABI conversion
+ * with correct 16-byte stack alignment required by the MS x64 ABI.
+ */
+void
+efi_rt_dispatch(struct efirt_callinfo *ec)
{
switch (ec->ec_argcnt) {
@@ -561,10 +566,8 @@
ec->ec_arg4, ec->ec_arg5);
break;
default:
- panic("efi_rt_arch_call: %d args", (int)ec->ec_argcnt);
+ panic("efi_rt_dispatch: %d args", (int)ec->ec_argcnt);
}
-
- return (0);
}
static int
@@ -576,7 +579,7 @@
if (error != 0)
return (error);
error = efi_rt_handle_faults ? efi_rt_arch_call(ecp) :
- efi_rt_arch_call_nofault(ecp);
+ (efi_rt_dispatch(ecp), 0);
efi_leave();
if (error == 0)
error = efi_status_to_errno(ecp->ec_efi_status);
diff --git a/sys/sys/efi.h b/sys/sys/efi.h
--- a/sys/sys/efi.h
+++ b/sys/sys/efi.h
@@ -267,6 +267,7 @@
void efi_arch_leave(void);
vm_offset_t efi_phys_to_kva(vm_paddr_t);
int efi_rt_arch_call(struct efirt_callinfo *);
+void efi_rt_dispatch(struct efirt_callinfo *);
bool efi_create_1t1_map(struct efi_md *, int, int);
void efi_destroy_1t1_map(void);

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 6, 11:05 AM (14 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29318273
Default Alt Text
D55662.id.diff (3 KB)

Event Timeline