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/Protocol/ComponentName2.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, 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, 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, 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, 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 77 of file efi_veto.c.

77  {
79  EFI_HANDLE driver = veto->driver;
80  EFI_HANDLE image = veto->image;
81  EFI_STATUS efirc;
82  int rc;
83 
84  /* Unload the driver */
85  if ( ( efirc = bs->UnloadImage ( image ) ) != 0 ) {
86  rc = -EEFI ( efirc );
87  DBGC ( driver, "EFIVETO %s could not unload",
88  efi_handle_name ( driver ) );
89  DBGC ( driver, " %s: %s\n", efi_handle_name ( image ),
90  strerror ( rc ) );
91  return rc;
92  }
93 
94  return 0;
95 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
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:174
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:66
#define DBGC(...)
Definition: compiler.h:505
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1980
An executable image.
Definition: image.h:23
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:62
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_SYSTEM_TABLE * efi_systab
Definition: efi.h:61

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 103 of file efi_veto.c.

103  {
105  EFI_HANDLE driver = veto->driver;
106  EFI_HANDLE *handles;
108  UINTN count;
109  unsigned int i;
110  EFI_STATUS efirc;
111  int rc;
112 
113  /* Enumerate all handles */
114  if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
115  &count, &handles ) ) != 0 ) {
116  rc = -EEFI ( efirc );
117  DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
118  efi_handle_name ( driver ), strerror ( rc ) );
119  goto err_list;
120  }
121 
122  /* Disconnect driver from all handles, in reverse order */
123  for ( i = 0 ; i < count ; i++ ) {
124  handle = handles[ count - i - 1 ];
125  if ( ( rc = efi_disconnect ( handle, driver ) ) != 0 ) {
126  DBGC ( driver, "EFIVETO %s could not disconnect",
127  efi_handle_name ( driver ) );
128  DBGC ( driver, " %s: %s\n",
129  efi_handle_name ( handle ), strerror ( rc ) );
130  goto err_disconnect;
131  }
132  }
133 
134  /* Success */
135  rc = 0;
136  DBGC2 ( driver, "EFIVETO %s disconnected all handles\n",
137  efi_handle_name ( driver ) );
138 
139  err_disconnect:
140  bs->FreePool ( handles );
141  err_list:
142  return rc;
143 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
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:174
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1521
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:62
static unsigned int count
Number of entries.
Definition: dwmac.h:225
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
#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
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:61
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:2007
int efi_disconnect(EFI_HANDLE device, EFI_HANDLE driver)
Disconnect UEFI driver(s)
Definition: efi_connect.c:89

References AllHandles, EFI_SYSTEM_TABLE::BootServices, count, DBGC, DBGC2, efi_veto::driver, EEFI, efi_disconnect(), efi_handle_name(), 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 151 of file efi_veto.c.

151  {
153  EFI_HANDLE driver = veto->driver;
155  EFI_STATUS efirc;
156  int rc;
157 
158  /* Open driver binding protocol */
159  if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
160  &binding ) ) != 0 ) {
161  DBGC ( driver, "EFIVETO %s could not open driver binding "
162  "protocol: %s\n", efi_handle_name ( driver ),
163  strerror ( rc ) );
164  return rc;
165  }
166 
167  /* Uninstall driver binding protocol */
168  if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
170  binding, NULL ) ) != 0 ) {
171  rc = -EEFI ( efirc );
172  DBGC ( driver, "EFIVETO %s could not uninstall driver "
173  "binding protocol: %s\n",
174  efi_handle_name ( driver ), strerror ( rc ) );
175  return rc;
176  }
177 
178  DBGC2 ( driver, "EFIVETO %s uninstalled driver binding protocol\n",
179  efi_handle_name ( driver ) );
180  return 0;
181 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
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:174
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:62
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:2010
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:443
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_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:208
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:61

References EFI_SYSTEM_TABLE::BootServices, DBGC, DBGC2, efi_veto::driver, EEFI, efi_driver_binding_protocol_guid, efi_handle_name(), efi_open, efi_systab, NULL, 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 191 of file efi_veto.c.

192  {
194  EFI_HANDLE driver = veto->driver;
195  EFI_HANDLE image = veto->image;
199  UINTN count;
200  unsigned int i;
201  EFI_STATUS efirc;
202  int rc;
203 
204  /* Retrieve list of openers */
205  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
206  &count ) ) != 0 ) {
207  rc = -EEFI ( efirc );
208  DBGC ( driver, "EFIVETO %s could not retrieve openers",
209  efi_handle_name ( driver ) );
210  DBGC ( driver, " of %s %s: %s", efi_handle_name ( handle ),
211  efi_guid_ntoa ( protocol ), strerror ( rc ) );
212  goto err_list;
213  }
214 
215  /* Close anything opened by this driver */
216  for ( i = 0 ; i < count ; i++ ) {
217  opener = &openers[ count - i - 1 ];
218  if ( ( opener->AgentHandle != driver ) &&
219  ( opener->AgentHandle != image ) ) {
220  continue;
221  }
222  controller = opener->ControllerHandle;
223  DBGC_EFI_OPENER ( driver, handle, protocol, opener );
224  if ( ( efirc = bs->CloseProtocol ( handle, protocol, driver,
225  controller ) ) != 0 ) {
226  rc = -EEFI ( efirc );
227  DBGC ( driver, "EFIVETO %s could not close stray open",
228  efi_handle_name ( driver ) );
229  DBGC ( driver, " of %s: %s\n",
230  efi_handle_name ( handle ), strerror ( rc ) );
231  goto err_close;
232  }
233  }
234 
235  /* Success */
236  rc = 0;
237 
238  err_close:
239  bs->FreePool ( openers );
240  err_list:
241  return rc;
242 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
EFI Oprn Protocol Information Entry.
Definition: UefiSpec.h:1431
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:174
EFI_HANDLE ControllerHandle
Definition: UefiSpec.h:1433
EFI_HANDLE AgentHandle
Definition: UefiSpec.h:1432
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:66
#define DBGC(...)
Definition: compiler.h:505
An executable image.
Definition: image.h:23
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:2000
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:62
static unsigned int count
Number of entries.
Definition: dwmac.h:225
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
UINT64 UINTN
Unsigned value of native width.
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_guid.c:725
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:2001
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
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:61
#define DBGC_EFI_OPENER(...)
Definition: efi.h:342

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 251 of file efi_veto.c.

251  {
253  EFI_HANDLE driver = veto->driver;
254  EFI_GUID **protocols;
256  UINTN count;
257  unsigned int i;
258  EFI_STATUS efirc;
259  int rc;
260 
261  /* Retrieve list of protocols */
262  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
263  &count ) ) != 0 ) {
264  rc = -EEFI ( efirc );
265  DBGC ( driver, "EFIVETO %s could not retrieve protocols",
266  efi_handle_name ( driver ) );
267  DBGC ( driver, " for %s: %s\n",
268  efi_handle_name ( handle ), strerror ( rc ) );
269  goto err_list;
270  }
271 
272  /* Close each protocol */
273  for ( i = 0 ; i < count ; i++ ) {
274  protocol = protocols[ count - i - 1];
275  if ( ( rc = efi_veto_close_protocol ( veto, handle,
276  protocol ) ) != 0 )
277  goto err_close;
278  }
279 
280  /* Success */
281  rc = 0;
282 
283  err_close:
284  bs->FreePool ( protocols );
285  err_list:
286  return rc;
287 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
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:174
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:62
static unsigned int count
Number of entries.
Definition: dwmac.h:225
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:2006
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
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:191
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:61

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 295 of file efi_veto.c.

295  {
297  EFI_HANDLE driver = veto->driver;
298  EFI_HANDLE *handles;
300  UINTN count;
301  unsigned int i;
302  EFI_STATUS efirc;
303  int rc;
304 
305  /* Enumerate all handles */
306  if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
307  &count, &handles ) ) != 0 ) {
308  rc = -EEFI ( efirc );
309  DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
310  efi_handle_name ( driver ), strerror ( rc ) );
311  goto err_list;
312  }
313 
314  /* Close each handle */
315  for ( i = 0 ; i < count ; i++ ) {
316  handle = handles[ count - i - 1 ];
317  if ( ( rc = efi_veto_close_handle ( veto, handle ) ) != 0 )
318  goto err_close;
319  }
320 
321  /* Success */
322  rc = 0;
323  DBGC2 ( driver, "EFIVETO %s closed all remaining handles\n",
324  efi_handle_name ( driver ) );
325 
326  err_close:
327  bs->FreePool ( handles );
328  err_list:
329  return rc;
330 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
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:174
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:251
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1521
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:62
static unsigned int count
Number of entries.
Definition: dwmac.h:225
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
#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
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:61
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:2007

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 338 of file efi_veto.c.

338  {
339  EFI_HANDLE driver = veto->driver;
340  int rc;
341 
342  /* Disconnect driver from all handles */
343  if ( ( rc = efi_veto_disconnect ( veto ) ) != 0 )
344  return rc;
345 
346  /* Uninstall driver binding protocol */
347  if ( ( rc = efi_veto_uninstall ( veto ) ) != 0 )
348  return rc;
349 
350  /* Close any remaining opened handles */
351  if ( ( rc = efi_veto_close ( veto ) ) != 0 )
352  return rc;
353 
354  DBGC ( driver, "EFIVETO %s forcibly removed\n",
355  efi_handle_name ( driver ) );
356  return 0;
357 }
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:151
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:62
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
static int efi_veto_disconnect(struct efi_veto *veto)
Disconnect an EFI driver from all handles.
Definition: efi_veto.c:103
static int efi_veto_close(struct efi_veto *veto)
Close all remaining handles opened by an EFI driver.
Definition: efi_veto.c:295
Definition: efi.h:61

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 365 of file efi_veto.c.

365  {
366  int rc;
367 
368  /* Try gracefully unloading the driver */
369  if ( ( rc = efi_veto_unload ( veto ) ) == 0 )
370  return 0;
371 
372  /* If that fails, use a hammer */
373  if ( ( rc = efi_veto_destroy ( veto ) ) == 0 )
374  return 0;
375 
376  return rc;
377 }
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:77
static int efi_veto_destroy(struct efi_veto *veto)
Terminate an EFI driver with extreme prejudice.
Definition: efi_veto.c:338

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,
const char *  manufacturer,
const CHAR16 name 
)
static

Veto Ip4ConfigDxe driver on some platforms.

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

Definition at line 389 of file efi_veto.c.

391  {
392  static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
393  static const char *dell = "Dell Inc.";
394  static const char *itautec = "Itautec S.A.";
395 
396  /* Check manufacturer and driver name */
397  if ( ! manufacturer )
398  return 0;
399  if ( ! name )
400  return 0;
401  if ( ( strcmp ( manufacturer, dell ) != 0 ) &&
402  ( strcmp ( manufacturer, itautec ) != 0 ) )
403  return 0;
404  if ( memcmp ( name, ip4cfg, sizeof ( ip4cfg ) ) != 0 )
405  return 0;
406 
407  return 1;
408 }
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,
const char *  manufacturer,
const CHAR16 name 
)
static

Veto HP XhciDxe driver.

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

Definition at line 420 of file efi_veto.c.

422  {
423  static const CHAR16 xhci[] = L"Usb Xhci Driver";
424  static const char *hp = "HP";
425  struct pci_driver *driver;
426 
427  /* Check manufacturer and driver name */
428  if ( ! manufacturer )
429  return 0;
430  if ( ! name )
431  return 0;
432  if ( strcmp ( manufacturer, hp ) != 0 )
433  return 0;
434  if ( memcmp ( name, xhci, sizeof ( xhci ) ) != 0 )
435  return 0;
436 
437  /* Veto driver only if we have our own xHCI driver */
438  for_each_table_entry ( driver, PCI_DRIVERS ) {
439  if ( driver->class.class ==
442  return 1;
443  }
444  }
445 
446  return 0;
447 }
const char * name
Definition: ath9k_hw.c:1984
struct pci_class_id class
PCI class ID.
Definition: pci.h:257
A PCI driver.
Definition: pci.h:251
unsigned short CHAR16
uint32_t class
Class.
Definition: pci.h:191
#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:166
#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:274

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,
const char *  manufacturer,
const CHAR16 name 
)
static

Veto VMware UefiPxeBcDxe driver.

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

Definition at line 459 of file efi_veto.c.

461  {
462  static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
463  static const char *vmware = "VMware, Inc.";
464 
465  /* Check manufacturer and driver name */
466  if ( ! manufacturer )
467  return 0;
468  if ( ! name )
469  return 0;
470  if ( strcmp ( manufacturer, vmware ) != 0 )
471  return 0;
472  if ( memcmp ( name, uefipxebc, sizeof ( uefipxebc ) ) != 0 )
473  return 0;
474 
475  return 1;
476 }
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,
const char *manufacturer  __unused,
const CHAR16 name 
)
static

Veto Dhcp6Dxe driver.

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

Definition at line 487 of file efi_veto.c.

490  {
491  static const CHAR16 dhcp6[] = L"DHCP6 Protocol Driver";
492 
493  /* Check driver name */
494  if ( ! name )
495  return 0;
496  if ( memcmp ( name, dhcp6, sizeof ( dhcp6 ) ) != 0 )
497  return 0;
498 
499  return 1;
500 }
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 530 of file efi_veto.c.

531  {
536  CHAR16 *name;
537  unsigned int i;
539  EFI_STATUS efirc;
540  int rc;
541 
542  /* Mark as not vetoed */
543  memset ( veto, 0, sizeof ( *veto ) );
544 
545  /* Open driver binding protocol */
546  if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
547  &binding ) ) != 0 ) {
548  DBGC ( driver, "EFIVETO %s could not open driver binding "
549  "protocol: %s\n", efi_handle_name ( driver ),
550  strerror ( rc ) );
551  return rc;
552  }
553  image = binding->ImageHandle;
554 
555  /* Open loaded image protocol */
557  &loaded ) ) != 0 ) {
558  DBGC ( driver, "EFIVETO %s could not open",
559  efi_handle_name ( driver ) );
560  DBGC ( driver, " %s loaded image protocol: %s\n",
561  efi_handle_name ( image ), strerror ( rc ) );
562  return rc;
563  }
564 
565  /* Open component name protocol, if present */
567  &wtf2 ) ) != 0 ) {
568  /* Ignore failure; is not required to be present */
569  }
570 
571  /* Open obsolete component name protocol, if present */
573  &wtf ) ) != 0 ) {
574  /* Ignore failure; is not required to be present */
575  }
576 
577  /* Get driver name, if available */
578  if ( ( wtf2 && ( ( efirc = wtf2->GetDriverName ( wtf2, "en",
579  &name ) == 0 ) ) ) ||
580  ( wtf && ( ( efirc = wtf->GetDriverName ( wtf, "eng",
581  &name ) == 0 ) ) ) ) {
582  /* Driver has a name */
583  } else {
584  /* Ignore failure; name is not required to be present */
585  name = NULL;
586  }
587 
588  /* Check vetoes */
589  DBGC2 ( &efi_vetoes, "EFIVETO checking %s [%p,%p)\n",
590  efi_handle_name ( driver ), loaded->ImageBase,
591  ( loaded->ImageBase + loaded->ImageSize ) );
592  for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
593  sizeof ( efi_vetoes[0] ) ) ; i++ ) {
594  if ( efi_vetoes[i].veto ( binding, loaded, manufacturer,
595  name ) ) {
596  DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
597  efi_handle_name ( driver ),
598  efi_vetoes[i].name );
599  veto->driver = driver;
600  veto->binding = binding;
601  veto->image = image;
602  veto->loaded = loaded;
603  break;
604  }
605  }
606 
607  return 0;
608 }
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...
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:66
UINT64 ImageSize
The size in bytes of the loaded image.
Definition: LoadedImage.h:70
#define DBGC(...)
Definition: compiler.h:505
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:272
unsigned short CHAR16
An executable image.
Definition: image.h:23
VOID * ImageBase
The base address at which the image was loaded.
Definition: LoadedImage.h:69
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:62
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
static struct efi_veto_candidate efi_vetoes[]
Driver vetoes.
Definition: efi_veto.c:503
EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:443
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:64
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:160
EFI_HANDLE ImageHandle
The image handle of the UEFI driver that produced this instance of the EFI_DRIVER_BINDING_PROTOCOL.
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
EFI_LOADED_IMAGE_PROTOCOL * loaded
Loaded image protocol.
Definition: efi_veto.c:68
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition: efi_guid.c:156
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:208
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:61
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, DBGC2, efi_component_name2_protocol_guid, efi_component_name_protocol_guid, efi_driver_binding_protocol_guid, efi_handle_name(), efi_loaded_image_protocol_guid, efi_open, efi_vetoes, _EFI_COMPONENT_NAME2_PROTOCOL::GetDriverName, EFI_LOADED_IMAGE_PROTOCOL::ImageBase, _EFI_DRIVER_BINDING_PROTOCOL::ImageHandle, EFI_LOADED_IMAGE_PROTOCOL::ImageSize, manufacturer, memset(), name, NULL, rc, strerror(), efi_veto_candidate::veto, and wtf.

Referenced by efi_veto().

◆ efi_veto()

void efi_veto ( void  )

Remove any vetoed drivers.

Definition at line 614 of file efi_veto.c.

614  {
616  struct efi_veto veto;
617  EFI_HANDLE *drivers;
619  UINTN count;
620  unsigned int i;
621  char *manufacturer;
622  EFI_STATUS efirc;
623  int rc;
624 
625  /* Locate all driver binding protocol handles */
626  if ( ( efirc = bs->LocateHandleBuffer (
628  NULL, &count, &drivers ) ) != 0 ) {
629  rc = -EEFI ( efirc );
630  DBGC ( &efi_vetoes, "EFIVETO could not list all drivers: "
631  "%s\n", strerror ( rc ) );
632  return;
633  }
634 
635  /* Get manufacturer name */
636  fetch_string_setting_copy ( NULL, &manufacturer_setting,
637  &manufacturer );
638  DBGC ( &efi_vetoes, "EFIVETO manufacturer is \"%s\"\n", manufacturer );
639 
640  /* Unload any vetoed drivers */
641  for ( i = 0 ; i < count ; i++ ) {
642  driver = drivers[ count - i - 1 ];
643  if ( ( rc = efi_veto_find ( driver, manufacturer,
644  &veto ) ) != 0 ) {
645  DBGC ( driver, "EFIVETO %s could not determine "
646  "vetoing: %s\n",
647  efi_handle_name ( driver ), strerror ( rc ) );
648  continue;
649  }
650  if ( ! veto.driver )
651  continue;
652  if ( ( rc = efi_veto_driver ( &veto ) ) != 0 ) {
653  DBGC ( driver, "EFIVETO %s could not veto: %s\n",
654  efi_handle_name ( driver ), strerror ( rc ) );
655  }
656  }
657 
658  /* Free manufacturer name */
659  free ( manufacturer );
660 
661  /* Free handle list */
662  bs->FreePool ( drivers );
663 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
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:174
static int efi_veto_driver(struct efi_veto *veto)
Veto an EFI driver.
Definition: efi_veto.c:365
#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:530
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:62
static struct efi_veto_candidate efi_vetoes[]
Driver vetoes.
Definition: efi_veto.c:503
static unsigned int count
Number of entries.
Definition: dwmac.h:225
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:652
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:1930
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
Retrieve the set of handles from the handle database that support a specified protocol.
Definition: UefiSpec.h:1530
EFI_SYSTEM_TABLE * efi_systab
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:208
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A driver veto.
Definition: efi_veto.c:60
Definition: efi.h:61
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:2007

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_vmware_uefipxebc(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, const char *manufacturer, const CHAR16 *name)
Veto VMware UefiPxeBcDxe driver.
Definition: efi_veto.c:459
static int efi_veto_ip4config(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, const char *manufacturer, const CHAR16 *name)
Veto Ip4ConfigDxe driver on some platforms.
Definition: efi_veto.c:389
static int efi_veto_hp_xhci(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, const char *manufacturer, const CHAR16 *name)
Veto HP XhciDxe driver.
Definition: efi_veto.c:420
static int efi_veto_dhcp6(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, const char *manufacturer __unused, const CHAR16 *name)
Veto Dhcp6Dxe driver.
Definition: efi_veto.c:487

Driver vetoes.

Definition at line 503 of file efi_veto.c.

Referenced by efi_veto(), and efi_veto_find().