iPXE
Data Structures | Functions | Variables
efi_veto.c File Reference

EFI driver vetoes. More...

#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ipxe/settings.h>
#include <ipxe/pci.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/DriverBinding.h>
#include <ipxe/efi/Protocol/LoadedImage.h>
#include <ipxe/efi/Protocol/ComponentName.h>
#include <ipxe/efi/efi_veto.h>

Go to the source code of this file.

Data Structures

struct  efi_veto_candidate
 A driver veto candidate. More...
 
struct  efi_veto
 A driver veto. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int efi_veto_unload (struct efi_veto *veto)
 Unload an EFI driver. More...
 
static int efi_veto_disconnect (struct efi_veto *veto)
 Disconnect an EFI driver from all handles. More...
 
static int efi_veto_uninstall (struct efi_veto *veto)
 Uninstall an EFI driver binding protocol. More...
 
static int efi_veto_close_protocol (struct efi_veto *veto, EFI_HANDLE handle, EFI_GUID *protocol)
 Close protocol on handle potentially opened by an EFI driver. More...
 
static int efi_veto_close_handle (struct efi_veto *veto, EFI_HANDLE handle)
 Close handle potentially opened by an EFI driver. More...
 
static int efi_veto_close (struct efi_veto *veto)
 Close all remaining handles opened by an EFI driver. More...
 
static int efi_veto_destroy (struct efi_veto *veto)
 Terminate an EFI driver with extreme prejudice. More...
 
static int efi_veto_driver (struct efi_veto *veto)
 Veto an EFI driver. More...
 
static int efi_veto_ip4config (EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name)
 Veto Ip4ConfigDxe driver on some platforms. More...
 
static int efi_veto_hp_xhci (EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name)
 Veto HP XhciDxe driver. More...
 
static int efi_veto_vmware_uefipxebc (EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name)
 Veto VMware UefiPxeBcDxe driver. More...
 
static int efi_veto_dhcp6 (EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer __unused, const CHAR16 *name)
 Veto Dhcp6Dxe driver. More...
 
static int efi_veto_find (EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto)
 Find driver veto, if any. More...
 
void efi_veto (void)
 Remove any vetoed drivers. More...
 

Variables

static struct efi_veto_candidate efi_vetoes []
 Driver vetoes. More...
 

Detailed Description

EFI driver vetoes.

Definition in file efi_veto.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_veto_unload()

static int efi_veto_unload ( struct efi_veto veto)
static

Unload an EFI driver.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 78 of file efi_veto.c.

78  {
80  EFI_HANDLE driver = veto->driver;
81  EFI_HANDLE image = veto->image;
82  EFI_STATUS efirc;
83  int rc;
84 
85  /* Unload the driver */
86  if ( ( efirc = bs->UnloadImage ( image ) ) != 0 ) {
87  rc = -EEFI ( efirc );
88  DBGC ( driver, "EFIVETO %s could not unload",
89  efi_handle_name ( driver ) );
90  DBGC ( driver, " %s: %s\n", efi_handle_name ( image ),
91  strerror ( rc ) );
92  return rc;
93  }
94 
95  return 0;
96 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:67
#define DBGC(...)
Definition: compiler.h:505
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1967
An executable image.
Definition: image.h:24
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_SYSTEM_TABLE * efi_systab
Definition: efi.h:59

References EFI_SYSTEM_TABLE::BootServices, DBGC, efi_veto::driver, EEFI, efi_handle_name(), efi_systab, efi_veto::image, rc, strerror(), and EFI_BOOT_SERVICES::UnloadImage.

Referenced by efi_veto_driver().

◆ efi_veto_disconnect()

static int efi_veto_disconnect ( struct efi_veto veto)
static

Disconnect an EFI driver from all handles.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 104 of file efi_veto.c.

104  {
106  EFI_HANDLE driver = veto->driver;
107  EFI_HANDLE *handles;
109  UINTN count;
110  unsigned int i;
111  EFI_STATUS efirc;
112  int rc;
113 
114  /* Enumerate all handles */
115  if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
116  &count, &handles ) ) != 0 ) {
117  rc = -EEFI ( efirc );
118  DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
119  efi_handle_name ( driver ), strerror ( rc ) );
120  goto err_list;
121  }
122 
123  /* Disconnect driver from all handles, in reverse order */
124  for ( i = 0 ; i < count ; i++ ) {
125  handle = handles[ count - i - 1 ];
126  efirc = bs->DisconnectController ( handle, driver, NULL );
127  if ( ( efirc != 0 ) && ( efirc != EFI_NOT_FOUND ) ) {
128  rc = -EEFI ( efirc );
129  DBGC ( driver, "EFIVETO %s could not disconnect",
130  efi_handle_name ( driver ) );
131  DBGC ( driver, " %s: %s\n",
132  efi_handle_name ( handle ), strerror ( rc ) );
133  goto err_disconnect;
134  }
135  }
136 
137  /* Success */
138  rc = 0;
139  DBGC2 ( driver, "EFIVETO %s disconnected all handles\n",
140  efi_handle_name ( driver ) );
141 
142  err_disconnect:
143  bs->FreePool ( handles );
144  err_list:
145  return rc;
146 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1511
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
#define EFI_NOT_FOUND
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:128
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
uint16_t count
Number of entries.
Definition: ena.h:22
EFI_SYSTEM_TABLE * efi_systab
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:59
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1994
EFI_DISCONNECT_CONTROLLER DisconnectController
Definition: UefiSpec.h:1981

References AllHandles, EFI_SYSTEM_TABLE::BootServices, count, DBGC, DBGC2, EFI_BOOT_SERVICES::DisconnectController, efi_veto::driver, EEFI, efi_handle_name(), EFI_NOT_FOUND, efi_systab, EFI_BOOT_SERVICES::FreePool, handle, EFI_BOOT_SERVICES::LocateHandleBuffer, NULL, rc, and strerror().

Referenced by efi_veto_destroy().

◆ efi_veto_uninstall()

static int efi_veto_uninstall ( struct efi_veto veto)
static

Uninstall an EFI driver binding protocol.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 154 of file efi_veto.c.

154  {
156  EFI_HANDLE driver = veto->driver;
157  union {
159  void *interface;
160  } binding;
161  EFI_STATUS efirc;
162  int rc;
163 
164  /* Open driver binding protocol */
165  if ( ( efirc = bs->OpenProtocol (
167  &binding.interface, efi_image_handle, driver,
168  EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
169  rc = -EEFI ( efirc );
170  DBGC ( driver, "EFIVETO %s could not open driver binding "
171  "protocol: %s\n", efi_handle_name ( driver ),
172  strerror ( rc ) );
173  return rc;
174  }
175 
176  /* Close driver binding protocol */
178  efi_image_handle, driver );
179 
180  /* Uninstall driver binding protocol */
181  if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
183  binding.binding, NULL ) ) != 0 ) {
184  rc = -EEFI ( efirc );
185  DBGC ( driver, "EFIVETO %s could not uninstall driver "
186  "binding protocol: %s\n",
187  efi_handle_name ( driver ), strerror ( rc ) );
188  return rc;
189  }
190 
191  DBGC2 ( driver, "EFIVETO %s uninstalled driver binding protocol\n",
192  efi_handle_name ( driver ) );
193  return 0;
194 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
#define DBGC(...)
Definition: compiler.h:505
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1987
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
An object interface.
Definition: interface.h:124
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1344
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:34
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1997
This protocol provides the services required to determine if a driver supports a given controller.
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1986
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:183
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:59

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, DBGC2, efi_veto::driver, EEFI, efi_driver_binding_protocol_guid, efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, NULL, EFI_BOOT_SERVICES::OpenProtocol, rc, strerror(), and EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces.

Referenced by efi_veto_destroy().

◆ efi_veto_close_protocol()

static int efi_veto_close_protocol ( struct efi_veto veto,
EFI_HANDLE  handle,
EFI_GUID protocol 
)
static

Close protocol on handle potentially opened by an EFI driver.

Parameters
vetoDriver veto
handlePotentially opened handle
protocolOpened protocol
Return values
rcReturn status code

Definition at line 204 of file efi_veto.c.

205  {
207  EFI_HANDLE driver = veto->driver;
208  EFI_HANDLE image = veto->image;
212  UINTN count;
213  unsigned int i;
214  EFI_STATUS efirc;
215  int rc;
216 
217  /* Retrieve list of openers */
218  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
219  &count ) ) != 0 ) {
220  rc = -EEFI ( efirc );
221  DBGC ( driver, "EFIVETO %s could not retrieve openers",
222  efi_handle_name ( driver ) );
223  DBGC ( driver, " of %s %s: %s", efi_handle_name ( handle ),
224  efi_guid_ntoa ( protocol ), strerror ( rc ) );
225  goto err_list;
226  }
227 
228  /* Close anything opened by this driver */
229  for ( i = 0 ; i < count ; i++ ) {
230  opener = &openers[ count - i - 1 ];
231  if ( ( opener->AgentHandle != driver ) &&
232  ( opener->AgentHandle != image ) ) {
233  continue;
234  }
235  controller = opener->ControllerHandle;
236  DBGC_EFI_OPENER ( driver, handle, protocol, opener );
237  if ( ( efirc = bs->CloseProtocol ( handle, protocol, driver,
238  controller ) ) != 0 ) {
239  rc = -EEFI ( efirc );
240  DBGC ( driver, "EFIVETO %s could not close stray open",
241  efi_handle_name ( driver ) );
242  DBGC ( driver, " of %s: %s\n",
243  efi_handle_name ( handle ), strerror ( rc ) );
244  goto err_close;
245  }
246  }
247 
248  /* Success */
249  rc = 0;
250 
251  err_close:
252  bs->FreePool ( openers );
253  err_list:
254  return rc;
255 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
EFI Oprn Protocol Information Entry.
Definition: UefiSpec.h:1421
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
EFI_HANDLE ControllerHandle
Definition: UefiSpec.h:1423
EFI_HANDLE AgentHandle
Definition: UefiSpec.h:1422
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:67
#define DBGC(...)
Definition: compiler.h:505
An executable image.
Definition: image.h:24
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1987
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:254
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:1988
uint8_t controller
CD-ROM controller number.
Definition: int13.h:18
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
uint16_t count
Number of entries.
Definition: ena.h:22
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
uint16_t handle
Handle.
Definition: smbios.h:16
Definition: efi.h:59
#define DBGC_EFI_OPENER(...)
Definition: efi.h:319

References EFI_OPEN_PROTOCOL_INFORMATION_ENTRY::AgentHandle, EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, controller, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY::ControllerHandle, count, DBGC, DBGC_EFI_OPENER, efi_veto::driver, EEFI, efi_guid_ntoa(), efi_handle_name(), efi_systab, EFI_BOOT_SERVICES::FreePool, handle, efi_veto::image, EFI_BOOT_SERVICES::OpenProtocolInformation, protocol, rc, and strerror().

Referenced by efi_veto_close_handle().

◆ efi_veto_close_handle()

static int efi_veto_close_handle ( struct efi_veto veto,
EFI_HANDLE  handle 
)
static

Close handle potentially opened by an EFI driver.

Parameters
vetoDriver veto
handlePotentially opened handle
Return values
rcReturn status code

Definition at line 264 of file efi_veto.c.

264  {
266  EFI_HANDLE driver = veto->driver;
267  EFI_GUID **protocols;
269  UINTN count;
270  unsigned int i;
271  EFI_STATUS efirc;
272  int rc;
273 
274  /* Retrieve list of protocols */
275  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
276  &count ) ) != 0 ) {
277  rc = -EEFI ( efirc );
278  DBGC ( driver, "EFIVETO %s could not retrieve protocols",
279  efi_handle_name ( driver ) );
280  DBGC ( driver, " for %s: %s\n",
281  efi_handle_name ( handle ), strerror ( rc ) );
282  goto err_list;
283  }
284 
285  /* Close each protocol */
286  for ( i = 0 ; i < count ; i++ ) {
287  protocol = protocols[ count - i - 1];
288  if ( ( rc = efi_veto_close_protocol ( veto, handle,
289  protocol ) ) != 0 )
290  goto err_close;
291  }
292 
293  /* Success */
294  rc = 0;
295 
296  err_close:
297  bs->FreePool ( protocols );
298  err_list:
299  return rc;
300 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
128 bit buffer containing a unique identifier value.
Definition: Base.h:215
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:1993
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
uint16_t count
Number of entries.
Definition: ena.h:22
static int efi_veto_close_protocol(struct efi_veto *veto, EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol on handle potentially opened by an EFI driver.
Definition: efi_veto.c:204
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
uint16_t handle
Handle.
Definition: smbios.h:16
Definition: efi.h:59

References EFI_SYSTEM_TABLE::BootServices, count, DBGC, efi_veto::driver, EEFI, efi_handle_name(), efi_systab, efi_veto_close_protocol(), EFI_BOOT_SERVICES::FreePool, handle, protocol, EFI_BOOT_SERVICES::ProtocolsPerHandle, rc, and strerror().

Referenced by efi_veto_close().

◆ efi_veto_close()

static int efi_veto_close ( struct efi_veto veto)
static

Close all remaining handles opened by an EFI driver.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 308 of file efi_veto.c.

308  {
310  EFI_HANDLE driver = veto->driver;
311  EFI_HANDLE *handles;
313  UINTN count;
314  unsigned int i;
315  EFI_STATUS efirc;
316  int rc;
317 
318  /* Enumerate all handles */
319  if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
320  &count, &handles ) ) != 0 ) {
321  rc = -EEFI ( efirc );
322  DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
323  efi_handle_name ( driver ), strerror ( rc ) );
324  goto err_list;
325  }
326 
327  /* Close each handle */
328  for ( i = 0 ; i < count ; i++ ) {
329  handle = handles[ count - i - 1 ];
330  if ( ( rc = efi_veto_close_handle ( veto, handle ) ) != 0 )
331  goto err_close;
332  }
333 
334  /* Success */
335  rc = 0;
336  DBGC2 ( driver, "EFIVETO %s closed all remaining handles\n",
337  efi_handle_name ( driver ) );
338 
339  err_close:
340  bs->FreePool ( handles );
341  err_list:
342  return rc;
343 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
static int efi_veto_close_handle(struct efi_veto *veto, EFI_HANDLE handle)
Close handle potentially opened by an EFI driver.
Definition: efi_veto.c:264
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1511
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
uint16_t count
Number of entries.
Definition: ena.h:22
EFI_SYSTEM_TABLE * efi_systab
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:59
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1994

References AllHandles, EFI_SYSTEM_TABLE::BootServices, count, DBGC, DBGC2, efi_veto::driver, EEFI, efi_handle_name(), efi_systab, efi_veto_close_handle(), EFI_BOOT_SERVICES::FreePool, handle, EFI_BOOT_SERVICES::LocateHandleBuffer, NULL, rc, and strerror().

Referenced by efi_veto_destroy().

◆ efi_veto_destroy()

static int efi_veto_destroy ( struct efi_veto veto)
static

Terminate an EFI driver with extreme prejudice.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 351 of file efi_veto.c.

351  {
352  EFI_HANDLE driver = veto->driver;
353  int rc;
354 
355  /* Disconnect driver from all handles */
356  if ( ( rc = efi_veto_disconnect ( veto ) ) != 0 )
357  return rc;
358 
359  /* Uninstall driver binding protocol */
360  if ( ( rc = efi_veto_uninstall ( veto ) ) != 0 )
361  return rc;
362 
363  /* Close any remaining opened handles */
364  if ( ( rc = efi_veto_close ( veto ) ) != 0 )
365  return rc;
366 
367  DBGC ( driver, "EFIVETO %s forcibly removed\n",
368  efi_handle_name ( driver ) );
369  return 0;
370 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int efi_veto_uninstall(struct efi_veto *veto)
Uninstall an EFI driver binding protocol.
Definition: efi_veto.c:154
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
static int efi_veto_disconnect(struct efi_veto *veto)
Disconnect an EFI driver from all handles.
Definition: efi_veto.c:104
static int efi_veto_close(struct efi_veto *veto)
Close all remaining handles opened by an EFI driver.
Definition: efi_veto.c:308
Definition: efi.h:59

References DBGC, efi_veto::driver, efi_handle_name(), efi_veto_close(), efi_veto_disconnect(), efi_veto_uninstall(), and rc.

Referenced by efi_veto_driver().

◆ efi_veto_driver()

static int efi_veto_driver ( struct efi_veto veto)
static

Veto an EFI driver.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 378 of file efi_veto.c.

378  {
379  int rc;
380 
381  /* Try gracefully unloading the driver */
382  if ( ( rc = efi_veto_unload ( veto ) ) == 0 )
383  return 0;
384 
385  /* If that fails, use a hammer */
386  if ( ( rc = efi_veto_destroy ( veto ) ) == 0 )
387  return 0;
388 
389  return rc;
390 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int efi_veto_unload(struct efi_veto *veto)
Unload an EFI driver.
Definition: efi_veto.c:78
static int efi_veto_destroy(struct efi_veto *veto)
Terminate an EFI driver with extreme prejudice.
Definition: efi_veto.c:351

References efi_veto_destroy(), efi_veto_unload(), and rc.

Referenced by efi_veto().

◆ efi_veto_ip4config()

static int efi_veto_ip4config ( EFI_DRIVER_BINDING_PROTOCOL *binding  __unused,
EFI_LOADED_IMAGE_PROTOCOL *loaded  __unused,
EFI_COMPONENT_NAME_PROTOCOL *wtf  __unused,
const char *  manufacturer,
const CHAR16 name 
)
static

Veto Ip4ConfigDxe driver on some platforms.

Parameters
bindingDriver binding protocol
loadedLoaded image protocol
wtfComponent name protocol, if present
manufacturerManufacturer name, if present
nameDriver name, if present
Return values
vetoedDriver is to be vetoed

Definition at line 403 of file efi_veto.c.

406  {
407  static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
408  static const char *dell = "Dell Inc.";
409  static const char *itautec = "Itautec S.A.";
410 
411  /* Check manufacturer and driver name */
412  if ( ! manufacturer )
413  return 0;
414  if ( ! name )
415  return 0;
416  if ( ( strcmp ( manufacturer, dell ) != 0 ) &&
417  ( strcmp ( manufacturer, itautec ) != 0 ) )
418  return 0;
419  if ( memcmp ( name, ip4cfg, sizeof ( ip4cfg ) ) != 0 )
420  return 0;
421 
422  return 1;
423 }
const char * name
Definition: ath9k_hw.c:1984
unsigned short CHAR16
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114

References manufacturer, memcmp(), name, and strcmp().

◆ efi_veto_hp_xhci()

static int efi_veto_hp_xhci ( EFI_DRIVER_BINDING_PROTOCOL *binding  __unused,
EFI_LOADED_IMAGE_PROTOCOL *loaded  __unused,
EFI_COMPONENT_NAME_PROTOCOL *wtf  __unused,
const char *  manufacturer,
const CHAR16 name 
)
static

Veto HP XhciDxe driver.

Parameters
bindingDriver binding protocol
loadedLoaded image protocol
wtfComponent name protocol, if present
manufacturerManufacturer name, if present
nameDriver name, if present
Return values
vetoedDriver is to be vetoed

Definition at line 436 of file efi_veto.c.

439  {
440  static const CHAR16 xhci[] = L"Usb Xhci Driver";
441  static const char *hp = "HP";
442  struct pci_driver *driver;
443 
444  /* Check manufacturer and driver name */
445  if ( ! manufacturer )
446  return 0;
447  if ( ! name )
448  return 0;
449  if ( strcmp ( manufacturer, hp ) != 0 )
450  return 0;
451  if ( memcmp ( name, xhci, sizeof ( xhci ) ) != 0 )
452  return 0;
453 
454  /* Veto driver only if we have our own xHCI driver */
455  for_each_table_entry ( driver, PCI_DRIVERS ) {
456  if ( driver->class.class ==
459  return 1;
460  }
461  }
462 
463  return 0;
464 }
const char * name
Definition: ath9k_hw.c:1984
struct pci_class_id class
PCI class ID.
Definition: pci.h:253
A PCI driver.
Definition: pci.h:247
unsigned short CHAR16
uint32_t class
Class.
Definition: pci.h:187
#define PCI_CLASS_SERIAL_USB_XHCI
xHCI USB controller
Definition: pci.h:140
#define PCI_CLASS_SERIAL
Definition: Pci22.h:266
#define PCI_CLASS(base, sub, progif)
Construct PCI class.
Definition: pci.h:162
#define PCI_CLASS_SERIAL_USB
Definition: Pci22.h:272
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define PCI_DRIVERS
PCI driver table.
Definition: pci.h:270

References pci_class_id::class, pci_driver::class, for_each_table_entry, manufacturer, memcmp(), name, PCI_CLASS, PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB, PCI_CLASS_SERIAL_USB_XHCI, PCI_DRIVERS, and strcmp().

◆ efi_veto_vmware_uefipxebc()

static int efi_veto_vmware_uefipxebc ( EFI_DRIVER_BINDING_PROTOCOL *binding  __unused,
EFI_LOADED_IMAGE_PROTOCOL *loaded  __unused,
EFI_COMPONENT_NAME_PROTOCOL *wtf  __unused,
const char *  manufacturer,
const CHAR16 name 
)
static

Veto VMware UefiPxeBcDxe driver.

Parameters
bindingDriver binding protocol
loadedLoaded image protocol
wtfComponent name protocol, if present
manufacturerManufacturer name, if present
nameDriver name, if present
Return values
vetoedDriver is to be vetoed

Definition at line 477 of file efi_veto.c.

480  {
481  static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
482  static const char *vmware = "VMware, Inc.";
483 
484  /* Check manufacturer and driver name */
485  if ( ! manufacturer )
486  return 0;
487  if ( ! name )
488  return 0;
489  if ( strcmp ( manufacturer, vmware ) != 0 )
490  return 0;
491  if ( memcmp ( name, uefipxebc, sizeof ( uefipxebc ) ) != 0 )
492  return 0;
493 
494  return 1;
495 }
const char * name
Definition: ath9k_hw.c:1984
unsigned short CHAR16
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114

References manufacturer, memcmp(), name, and strcmp().

◆ efi_veto_dhcp6()

static int efi_veto_dhcp6 ( EFI_DRIVER_BINDING_PROTOCOL *binding  __unused,
EFI_LOADED_IMAGE_PROTOCOL *loaded  __unused,
EFI_COMPONENT_NAME_PROTOCOL *wtf  __unused,
const char *manufacturer  __unused,
const CHAR16 name 
)
static

Veto Dhcp6Dxe driver.

Parameters
bindingDriver binding protocol
loadedLoaded image protocol
wtfComponent name protocol, if present
manufacturerManufacturer name, if present
nameDriver name, if present
Return values
vetoedDriver is to be vetoed

Definition at line 507 of file efi_veto.c.

511  {
512  static const CHAR16 dhcp6[] = L"DHCP6 Protocol Driver";
513 
514  /* Check driver name */
515  if ( ! name )
516  return 0;
517  if ( memcmp ( name, dhcp6, sizeof ( dhcp6 ) ) != 0 )
518  return 0;
519 
520  return 1;
521 }
const char * name
Definition: ath9k_hw.c:1984
unsigned short CHAR16
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114

References memcmp(), and name.

◆ efi_veto_find()

static int efi_veto_find ( EFI_HANDLE  driver,
const char *  manufacturer,
struct efi_veto veto 
)
static

Find driver veto, if any.

Parameters
driverDriver binding handle
manufacturerManufacturer name, if present
Return values
vetoDriver veto to fill in
rcReturn status code

Definition at line 551 of file efi_veto.c.

552  {
554  union {
556  void *interface;
557  } binding;
558  union {
560  void *interface;
561  } loaded;
562  union {
564  void *interface;
565  } wtf;
566  CHAR16 *name;
567  unsigned int i;
569  EFI_STATUS efirc;
570  int rc;
571 
572  DBGC2 ( &efi_vetoes, "EFIVETO checking %s\n",
573  efi_handle_name ( driver ) );
574 
575  /* Mark as not vetoed */
576  memset ( veto, 0, sizeof ( *veto ) );
577 
578  /* Open driver binding protocol */
579  if ( ( efirc = bs->OpenProtocol (
581  &binding.interface, efi_image_handle, driver,
582  EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
583  rc = -EEFI ( efirc );
584  DBGC ( driver, "EFIVETO %s could not open driver binding "
585  "protocol: %s\n", efi_handle_name ( driver ),
586  strerror ( rc ) );
587  goto err_binding;
588  }
589  image = binding.binding->ImageHandle;
590 
591  /* Open loaded image protocol */
592  if ( ( efirc = bs->OpenProtocol (
594  &loaded.interface, efi_image_handle, image,
595  EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
596  rc = -EEFI ( efirc );
597  DBGC ( driver, "EFIVETO %s could not open",
598  efi_handle_name ( driver ) );
599  DBGC ( driver, " %s loaded image protocol: %s\n",
600  efi_handle_name ( image ), strerror ( rc ) );
601  goto err_loaded;
602  }
603 
604  /* Open component name protocol, if present*/
605  if ( ( efirc = bs->OpenProtocol (
607  &wtf.interface, efi_image_handle, driver,
608  EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
609  /* Ignore failure; is not required to be present */
610  wtf.interface = NULL;
611  }
612 
613  /* Get driver name, if available */
614  if ( wtf.wtf &&
615  ( ( efirc = wtf.wtf->GetDriverName ( wtf.wtf, "eng",
616  &name ) == 0 ) ) ) {
617  /* Driver has a name */
618  } else {
619  /* Ignore failure; name is not required to be present */
620  name = NULL;
621  }
622 
623  /* Check vetoes */
624  for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
625  sizeof ( efi_vetoes[0] ) ) ; i++ ) {
626  if ( efi_vetoes[i].veto ( binding.binding, loaded.loaded,
627  wtf.wtf, manufacturer, name ) ) {
628  DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
629  efi_handle_name ( driver ),
630  efi_vetoes[i].name );
631  veto->driver = driver;
632  veto->binding = binding.binding;
633  veto->image = image;
634  veto->loaded = loaded.loaded;
635  break;
636  }
637  }
638 
639  /* Success */
640  rc = 0;
641 
642  /* Close protocols */
643  if ( wtf.wtf ) {
645  efi_image_handle, driver );
646  }
649  err_loaded:
651  efi_image_handle, driver );
652  err_binding:
653  return rc;
654 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:67
#define DBGC(...)
Definition: compiler.h:505
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:243
unsigned short CHAR16
An executable image.
Definition: image.h:24
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1987
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
Can be used on any image handle to obtain information about the loaded image.
Definition: LoadedImage.h:45
char wtf[42]
Authenticator response string.
Definition: mschapv2.h:18
An object interface.
Definition: interface.h:124
static struct efi_veto_candidate efi_vetoes[]
Driver vetoes.
Definition: efi_veto.c:524
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1344
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:34
This protocol provides the services required to determine if a driver supports a given controller.
EFI_DRIVER_BINDING_PROTOCOL * binding
Driving binding protocol.
Definition: efi_veto.c:65
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
EFI_LOADED_IMAGE_PROTOCOL * loaded
Loaded image protocol.
Definition: efi_veto.c:69
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1986
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition: efi_guid.c:131
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:183
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:59
void * memset(void *dest, int character, size_t len) __nonnull

References efi_veto::binding, EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, DBGC2, efi_veto::driver, EEFI, efi_component_name_protocol_guid, efi_driver_binding_protocol_guid, efi_handle_name(), efi_image_handle, efi_loaded_image_protocol_guid, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, efi_vetoes, efi_veto::image, efi_veto::loaded, manufacturer, memset(), name, NULL, EFI_BOOT_SERVICES::OpenProtocol, rc, strerror(), and wtf.

Referenced by efi_veto().

◆ efi_veto()

void efi_veto ( void  )

Remove any vetoed drivers.

Definition at line 660 of file efi_veto.c.

660  {
662  struct efi_veto veto;
663  EFI_HANDLE *drivers;
665  UINTN count;
666  unsigned int i;
667  char *manufacturer;
668  EFI_STATUS efirc;
669  int rc;
670 
671  /* Locate all driver binding protocol handles */
672  if ( ( efirc = bs->LocateHandleBuffer (
674  NULL, &count, &drivers ) ) != 0 ) {
675  rc = -EEFI ( efirc );
676  DBGC ( &efi_vetoes, "EFIVETO could not list all drivers: "
677  "%s\n", strerror ( rc ) );
678  return;
679  }
680 
681  /* Get manufacturer name */
682  fetch_string_setting_copy ( NULL, &manufacturer_setting,
683  &manufacturer );
684  DBGC ( &efi_vetoes, "EFIVETO manufacturer is \"%s\"\n", manufacturer );
685 
686  /* Unload any vetoed drivers */
687  for ( i = 0 ; i < count ; i++ ) {
688  driver = drivers[ count - i - 1 ];
689  if ( ( rc = efi_veto_find ( driver, manufacturer,
690  &veto ) ) != 0 ) {
691  DBGC ( driver, "EFIVETO %s could not determine "
692  "vetoing: %s\n",
693  efi_handle_name ( driver ), strerror ( rc ) );
694  continue;
695  }
696  if ( ! veto.driver )
697  continue;
698  if ( ( rc = efi_veto_driver ( &veto ) ) != 0 ) {
699  DBGC ( driver, "EFIVETO %s could not veto: %s\n",
700  efi_handle_name ( driver ), strerror ( rc ) );
701  }
702  }
703 
704  /* Free manufacturer name */
705  free ( manufacturer );
706 
707  /* Free handle list */
708  bs->FreePool ( drivers );
709 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
static int efi_veto_driver(struct efi_veto *veto)
Veto an EFI driver.
Definition: efi_veto.c:378
#define DBGC(...)
Definition: compiler.h:505
static int efi_veto_find(EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto)
Find driver veto, if any.
Definition: efi_veto.c:551
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
static struct efi_veto_candidate efi_vetoes[]
Driver vetoes.
Definition: efi_veto.c:524
int fetch_string_setting_copy(struct settings *settings, const struct setting *setting, char **data)
Fetch value of string setting.
Definition: settings.c:873
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
EFI Boot Services Table.
Definition: UefiSpec.h:1917
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
uint16_t count
Number of entries.
Definition: ena.h:22
Retrieve the set of handles from the handle database that support a specified protocol.
Definition: UefiSpec.h:1520
EFI_SYSTEM_TABLE * efi_systab
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:183
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A driver veto.
Definition: efi_veto.c:61
Definition: efi.h:59
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1994

References EFI_SYSTEM_TABLE::BootServices, ByProtocol, count, DBGC, efi_veto::driver, EEFI, efi_driver_binding_protocol_guid, efi_handle_name(), efi_systab, efi_veto_driver(), efi_veto_find(), efi_vetoes, fetch_string_setting_copy(), free, EFI_BOOT_SERVICES::FreePool, EFI_BOOT_SERVICES::LocateHandleBuffer, manufacturer, NULL, rc, and strerror().

Referenced by efi_probe().

Variable Documentation

◆ efi_vetoes

struct efi_veto_candidate efi_vetoes[]
static
Initial value:
= {
{
.name = "Ip4Config",
},
{
.name = "HP Xhci",
},
{
.name = "VMware UefiPxeBc",
},
{
.name = "Dhcp6",
.veto = efi_veto_dhcp6,
},
}
static int efi_veto_hp_xhci(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name)
Veto HP XhciDxe driver.
Definition: efi_veto.c:436
static int efi_veto_ip4config(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name)
Veto Ip4ConfigDxe driver on some platforms.
Definition: efi_veto.c:403
static int efi_veto_dhcp6(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer __unused, const CHAR16 *name)
Veto Dhcp6Dxe driver.
Definition: efi_veto.c:507
static int efi_veto_vmware_uefipxebc(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name)
Veto VMware UefiPxeBcDxe driver.
Definition: efi_veto.c:477

Driver vetoes.

Definition at line 524 of file efi_veto.c.

Referenced by efi_veto(), and efi_veto_find().