]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[pxe] Remove userptr_t from PXE API call dispatcher
authorMichael Brown <mcb30@ipxe.org>
Thu, 24 Apr 2025 22:36:32 +0000 (23:36 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 24 Apr 2025 22:38:50 +0000 (23:38 +0100)
Simplify the PXE API call dispatcher code by assuming that the PXE
parameter block is accessible via a direct pointer dereference.  This
avoids the need for the API call dispatcher to know the size of the
parameter block.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/include/pxe.h
src/arch/x86/interface/pxe/pxe_call.c

index 54649b5049655b98075d17f4ca4705552593fe42..8e7aa1ce7fa019b86deedd25cae6725668613910 100644 (file)
@@ -85,8 +85,6 @@ struct pxe_api_call {
         * @ret exit            PXE API call exit code
         */
        PXENV_EXIT_t ( * entry ) ( union u_PXENV_ANY *params );
-       /** Length of parameters */
-       uint16_t params_len;
        /** Opcode */
        uint16_t opcode;
 };
@@ -112,7 +110,6 @@ struct pxe_api_call {
                         ( union u_PXENV_ANY *params ) ) _entry )             \
                   : ( ( PXENV_EXIT_t ( * )                                   \
                         ( union u_PXENV_ANY *params ) ) _entry ) ),          \
-       .params_len = sizeof ( _params_type ),                                \
        .opcode = _opcode,                                                    \
        }
 
index f88943fb2af5ee7be97d54a75aa86d931e68b679..2721d23e57b52da62634c7a3f9ef75bfe06a690a 100644 (file)
@@ -144,10 +144,10 @@ static struct profiler * pxe_api_profiler ( unsigned int opcode ) {
  */
 __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
        uint16_t opcode = ix86->regs.bx;
-       userptr_t uparams = real_to_virt ( ix86->segs.es, ix86->regs.di );
        struct profiler *profiler = pxe_api_profiler ( opcode );
+       union u_PXENV_ANY *params =
+               real_to_virt ( ix86->segs.es, ix86->regs.di );
        struct pxe_api_call *call;
-       union u_PXENV_ANY params;
        PXENV_EXIT_t ret;
 
        /* Start profiling */
@@ -160,17 +160,13 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
                call = &pxenv_unknown_api;
        }
 
-       /* Copy parameter block from caller */
-       copy_from_user ( &params, uparams, 0, call->params_len );
-
        /* Set default status in case child routine fails to do so */
-       params.Status = PXENV_STATUS_FAILURE;
+       params->Status = PXENV_STATUS_FAILURE;
 
        /* Hand off to relevant API routine */
-       ret = call->entry ( &params );
+       ret = call->entry ( params );
 
-       /* Copy modified parameter block back to caller and return */
-       copy_to_user ( uparams, 0, &params, call->params_len );
+       /* Return exit code in %ax */
        ix86->regs.ax = ret;
 
        /* Stop profiling, if applicable */
@@ -195,24 +191,20 @@ int pxe_api_call_weak ( struct i386_all_regs *ix86 ) {
  * @ret ax             PXE exit code
  */
 __asmcall void pxe_loader_call ( struct i386_all_regs *ix86 ) {
-       userptr_t uparams = real_to_virt ( ix86->segs.es, ix86->regs.di );
-       struct s_UNDI_LOADER params;
+       struct s_UNDI_LOADER *params =
+               real_to_virt ( ix86->segs.es, ix86->regs.di );
        PXENV_EXIT_t ret;
 
-       /* Copy parameter block from caller */
-       copy_from_user ( &params, uparams, 0, sizeof ( params ) );
-
        /* Fill in ROM segment address */
        ppxe.UNDIROMID.segment = ix86->segs.ds;
 
        /* Set default status in case child routine fails to do so */
-       params.Status = PXENV_STATUS_FAILURE;
+       params->Status = PXENV_STATUS_FAILURE;
 
        /* Call UNDI loader */
-       ret = undi_loader ( &params );
+       ret = undi_loader ( params );
 
-       /* Copy modified parameter block back to caller and return */
-       copy_to_user ( uparams, 0, &params, sizeof ( params ) );
+       /* Return exit code in %ax */
        ix86->regs.ax = ret;
 }