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)
 
 FILE_SECBOOT (PERMITTED)
 
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  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ 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:2099
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:175
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:67
#define DBGC(...)
Definition: compiler.h:505
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1981
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:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
EFI Boot Services Table.
Definition: UefiSpec.h:1931
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
EFI_SYSTEM_TABLE * efi_systab
Definition: efi.h:62

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  if ( ( rc = efi_disconnect ( handle, driver ) ) != 0 ) {
127  DBGC ( driver, "EFIVETO %s could not disconnect",
128  efi_handle_name ( driver ) );
129  DBGC ( driver, " %s: %s\n",
130  efi_handle_name ( handle ), strerror ( rc ) );
131  goto err_disconnect;
132  }
133  }
134 
135  /* Success */
136  rc = 0;
137  DBGC2 ( driver, "EFIVETO %s disconnected all handles\n",
138  efi_handle_name ( driver ) );
139 
140  err_disconnect:
141  bs->FreePool ( handles );
142  err_list:
143  return rc;
144 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
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:175
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1522
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
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:79
EFI Boot Services Table.
Definition: UefiSpec.h:1931
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1950
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
EFI_SYSTEM_TABLE * efi_systab
uint16_t handle
Handle.
Definition: smbios.h:17
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
Definition: efi.h:62
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:2008
int efi_disconnect(EFI_HANDLE device, EFI_HANDLE driver)
Disconnect UEFI driver(s)
Definition: efi_connect.c:90

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

152  {
154  EFI_HANDLE driver = veto->driver;
156  EFI_STATUS efirc;
157  int rc;
158 
159  /* Open driver binding protocol */
160  if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
161  &binding ) ) != 0 ) {
162  DBGC ( driver, "EFIVETO %s could not open driver binding "
163  "protocol: %s\n", efi_handle_name ( driver ),
164  strerror ( rc ) );
165  return rc;
166  }
167 
168  /* Uninstall driver binding protocol */
169  if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
171  binding, NULL ) ) != 0 ) {
172  rc = -EEFI ( efirc );
173  DBGC ( driver, "EFIVETO %s could not uninstall driver "
174  "binding protocol: %s\n",
175  efi_handle_name ( driver ), strerror ( rc ) );
176  return rc;
177  }
178 
179  DBGC2 ( driver, "EFIVETO %s uninstalled driver binding protocol\n",
180  efi_handle_name ( driver ) );
181  return 0;
182 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
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:175
#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:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
EFI Boot Services Table.
Definition: UefiSpec.h:1931
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:2011
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:444
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:32
EFI_SYSTEM_TABLE * efi_systab
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:209
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
Definition: efi.h:62

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

193  {
195  EFI_HANDLE driver = veto->driver;
196  EFI_HANDLE image = veto->image;
200  UINTN count;
201  unsigned int i;
202  EFI_STATUS efirc;
203  int rc;
204 
205  /* Retrieve list of openers */
206  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
207  &count ) ) != 0 ) {
208  rc = -EEFI ( efirc );
209  DBGC ( driver, "EFIVETO %s could not retrieve openers",
210  efi_handle_name ( driver ) );
211  DBGC ( driver, " of %s %s: %s", efi_handle_name ( handle ),
212  efi_guid_ntoa ( protocol ), strerror ( rc ) );
213  goto err_list;
214  }
215 
216  /* Close anything opened by this driver */
217  for ( i = 0 ; i < count ; i++ ) {
218  opener = &openers[ count - i - 1 ];
219  if ( ( opener->AgentHandle != driver ) &&
220  ( opener->AgentHandle != image ) ) {
221  continue;
222  }
223  controller = opener->ControllerHandle;
224  DBGC_EFI_OPENER ( driver, handle, protocol, opener );
225  if ( ( efirc = bs->CloseProtocol ( handle, protocol, driver,
226  controller ) ) != 0 ) {
227  rc = -EEFI ( efirc );
228  DBGC ( driver, "EFIVETO %s could not close stray open",
229  efi_handle_name ( driver ) );
230  DBGC ( driver, " of %s: %s\n",
231  efi_handle_name ( handle ), strerror ( rc ) );
232  goto err_close;
233  }
234  }
235 
236  /* Success */
237  rc = 0;
238 
239  err_close:
240  bs->FreePool ( openers );
241  err_list:
242  return rc;
243 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
EFI Oprn Protocol Information Entry.
Definition: UefiSpec.h:1432
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:175
EFI_HANDLE ControllerHandle
Definition: UefiSpec.h:1434
EFI_HANDLE AgentHandle
Definition: UefiSpec.h:1433
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:2001
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
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:79
EFI Boot Services Table.
Definition: UefiSpec.h:1931
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:726
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1950
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:2002
uint8_t controller
CD-ROM controller number.
Definition: int13.h:18
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:19
uint16_t handle
Handle.
Definition: smbios.h:17
Definition: efi.h:62
#define DBGC_EFI_OPENER(...)
Definition: efi.h:343

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

252  {
254  EFI_HANDLE driver = veto->driver;
255  EFI_GUID **protocols;
257  UINTN count;
258  unsigned int i;
259  EFI_STATUS efirc;
260  int rc;
261 
262  /* Retrieve list of protocols */
263  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
264  &count ) ) != 0 ) {
265  rc = -EEFI ( efirc );
266  DBGC ( driver, "EFIVETO %s could not retrieve protocols",
267  efi_handle_name ( driver ) );
268  DBGC ( driver, " for %s: %s\n",
269  efi_handle_name ( handle ), strerror ( rc ) );
270  goto err_list;
271  }
272 
273  /* Close each protocol */
274  for ( i = 0 ; i < count ; i++ ) {
275  protocol = protocols[ count - i - 1];
276  if ( ( rc = efi_veto_close_protocol ( veto, handle,
277  protocol ) ) != 0 )
278  goto err_close;
279  }
280 
281  /* Success */
282  rc = 0;
283 
284  err_close:
285  bs->FreePool ( protocols );
286  err_list:
287  return rc;
288 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
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:175
128 bit buffer containing a unique identifier value.
Definition: Base.h:216
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
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:79
EFI Boot Services Table.
Definition: UefiSpec.h:1931
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1950
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:2007
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
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:192
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:19
uint16_t handle
Handle.
Definition: smbios.h:17
Definition: efi.h:62

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

296  {
298  EFI_HANDLE driver = veto->driver;
299  EFI_HANDLE *handles;
301  UINTN count;
302  unsigned int i;
303  EFI_STATUS efirc;
304  int rc;
305 
306  /* Enumerate all handles */
307  if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
308  &count, &handles ) ) != 0 ) {
309  rc = -EEFI ( efirc );
310  DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
311  efi_handle_name ( driver ), strerror ( rc ) );
312  goto err_list;
313  }
314 
315  /* Close each handle */
316  for ( i = 0 ; i < count ; i++ ) {
317  handle = handles[ count - i - 1 ];
318  if ( ( rc = efi_veto_close_handle ( veto, handle ) ) != 0 )
319  goto err_close;
320  }
321 
322  /* Success */
323  rc = 0;
324  DBGC2 ( driver, "EFIVETO %s closed all remaining handles\n",
325  efi_handle_name ( driver ) );
326 
327  err_close:
328  bs->FreePool ( handles );
329  err_list:
330  return rc;
331 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
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:175
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:252
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1522
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
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:79
EFI Boot Services Table.
Definition: UefiSpec.h:1931
UINT64 UINTN
Unsigned value of native width.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1950
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
EFI_SYSTEM_TABLE * efi_systab
uint16_t handle
Handle.
Definition: smbios.h:17
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
Definition: efi.h:62
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:2008

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

339  {
340  EFI_HANDLE driver = veto->driver;
341  int rc;
342 
343  /* Disconnect driver from all handles */
344  if ( ( rc = efi_veto_disconnect ( veto ) ) != 0 )
345  return rc;
346 
347  /* Uninstall driver binding protocol */
348  if ( ( rc = efi_veto_uninstall ( veto ) ) != 0 )
349  return rc;
350 
351  /* Close any remaining opened handles */
352  if ( ( rc = efi_veto_close ( veto ) ) != 0 )
353  return rc;
354 
355  DBGC ( driver, "EFIVETO %s forcibly removed\n",
356  efi_handle_name ( driver ) );
357  return 0;
358 }
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:152
#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:652
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:296
Definition: efi.h:62

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

366  {
367  int rc;
368 
369  /* Try gracefully unloading the driver */
370  if ( ( rc = efi_veto_unload ( veto ) ) == 0 )
371  return 0;
372 
373  /* If that fails, use a hammer */
374  if ( ( rc = efi_veto_destroy ( veto ) ) == 0 )
375  return 0;
376 
377  return rc;
378 }
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:339

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

392  {
393  static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
394  static const char *dell = "Dell Inc.";
395  static const char *itautec = "Itautec S.A.";
396 
397  /* Check manufacturer and driver name */
398  if ( ! manufacturer )
399  return 0;
400  if ( ! name )
401  return 0;
402  if ( ( strcmp ( manufacturer, dell ) != 0 ) &&
403  ( strcmp ( manufacturer, itautec ) != 0 ) )
404  return 0;
405  if ( memcmp ( name, ip4cfg, sizeof ( ip4cfg ) ) != 0 )
406  return 0;
407 
408  return 1;
409 }
const char * name
Definition: ath9k_hw.c:1986
unsigned short CHAR16
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:15
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:174
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:115

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

423  {
424  static const CHAR16 xhci[] = L"Usb Xhci Driver";
425  static const char *hp = "HP";
426  struct pci_driver *driver;
427 
428  /* Check manufacturer and driver name */
429  if ( ! manufacturer )
430  return 0;
431  if ( ! name )
432  return 0;
433  if ( strcmp ( manufacturer, hp ) != 0 )
434  return 0;
435  if ( memcmp ( name, xhci, sizeof ( xhci ) ) != 0 )
436  return 0;
437 
438  /* Veto driver only if we have our own xHCI driver */
439  for_each_table_entry ( driver, PCI_DRIVERS ) {
440  if ( driver->class.class ==
443  return 1;
444  }
445  }
446 
447  return 0;
448 }
const char * name
Definition: ath9k_hw.c:1986
struct pci_class_id class
PCI class ID.
Definition: pci.h:258
A PCI driver.
Definition: pci.h:252
unsigned short CHAR16
uint32_t class
Class.
Definition: pci.h:192
#define PCI_CLASS_SERIAL_USB_XHCI
xHCI USB controller
Definition: pci.h:141
#define PCI_CLASS_SERIAL
Definition: Pci22.h:267
#define PCI_CLASS(base, sub, progif)
Construct PCI class.
Definition: pci.h:167
#define PCI_CLASS_SERIAL_USB
Definition: Pci22.h:273
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:386
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:15
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:174
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:115
#define PCI_DRIVERS
PCI driver table.
Definition: pci.h:275

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

462  {
463  static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
464  static const char *vmware = "VMware, Inc.";
465 
466  /* Check manufacturer and driver name */
467  if ( ! manufacturer )
468  return 0;
469  if ( ! name )
470  return 0;
471  if ( strcmp ( manufacturer, vmware ) != 0 )
472  return 0;
473  if ( memcmp ( name, uefipxebc, sizeof ( uefipxebc ) ) != 0 )
474  return 0;
475 
476  return 1;
477 }
const char * name
Definition: ath9k_hw.c:1986
unsigned short CHAR16
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:15
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:174
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:115

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

491  {
492  static const CHAR16 dhcp6[] = L"DHCP6 Protocol Driver";
493 
494  /* Check driver name */
495  if ( ! name )
496  return 0;
497  if ( memcmp ( name, dhcp6, sizeof ( dhcp6 ) ) != 0 )
498  return 0;
499 
500  return 1;
501 }
const char * name
Definition: ath9k_hw.c:1986
unsigned short CHAR16
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:115

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

532  {
537  CHAR16 *name;
538  unsigned int i;
540  EFI_STATUS efirc;
541  int rc;
542 
543  /* Mark as not vetoed */
544  memset ( veto, 0, sizeof ( *veto ) );
545 
546  /* Open driver binding protocol */
547  if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
548  &binding ) ) != 0 ) {
549  DBGC ( driver, "EFIVETO %s could not open driver binding "
550  "protocol: %s\n", efi_handle_name ( driver ),
551  strerror ( rc ) );
552  return rc;
553  }
554  image = binding->ImageHandle;
555 
556  /* Open loaded image protocol */
558  &loaded ) ) != 0 ) {
559  DBGC ( driver, "EFIVETO %s could not open",
560  efi_handle_name ( driver ) );
561  DBGC ( driver, " %s loaded image protocol: %s\n",
562  efi_handle_name ( image ), strerror ( rc ) );
563  return rc;
564  }
565 
566  /* Open component name protocol, if present */
568  &wtf2 ) ) != 0 ) {
569  /* Ignore failure; is not required to be present */
570  }
571 
572  /* Open obsolete component name protocol, if present */
574  &wtf ) ) != 0 ) {
575  /* Ignore failure; is not required to be present */
576  }
577 
578  /* Get driver name, if available */
579  if ( ( wtf2 && ( ( efirc = wtf2->GetDriverName ( wtf2, "en",
580  &name ) == 0 ) ) ) ||
581  ( wtf && ( ( efirc = wtf->GetDriverName ( wtf, "eng",
582  &name ) == 0 ) ) ) ) {
583  /* Driver has a name */
584  } else {
585  /* Ignore failure; name is not required to be present */
586  name = NULL;
587  }
588 
589  /* Check vetoes */
590  DBGC2 ( &efi_vetoes, "EFIVETO checking %s [%p,%p)\n",
591  efi_handle_name ( driver ), loaded->ImageBase,
592  ( loaded->ImageBase + loaded->ImageSize ) );
593  for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
594  sizeof ( efi_vetoes[0] ) ) ; i++ ) {
595  if ( efi_vetoes[i].veto ( binding, loaded, manufacturer,
596  name ) ) {
597  DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
598  efi_handle_name ( driver ),
599  efi_vetoes[i].name );
600  veto->driver = driver;
601  veto->binding = binding;
602  veto->image = image;
603  veto->loaded = loaded;
604  break;
605  }
606  }
607 
608  return 0;
609 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1986
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:67
UINT64 ImageSize
The size in bytes of the loaded image.
Definition: LoadedImage.h:71
#define DBGC(...)
Definition: compiler.h:505
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:273
unsigned short CHAR16
An executable image.
Definition: image.h:24
VOID * ImageBase
The base address at which the image was loaded.
Definition: LoadedImage.h:70
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:46
char wtf[42]
Authenticator response string.
Definition: mschapv2.h:18
static struct efi_veto_candidate efi_vetoes[]
Driver vetoes.
Definition: efi_veto.c:504
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:79
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:444
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
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:161
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:15
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:32
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition: efi_guid.c:157
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:209
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
Definition: efi.h:62
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 615 of file efi_veto.c.

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

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:460
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:390
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:421
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:488

Driver vetoes.

Definition at line 504 of file efi_veto.c.

Referenced by efi_veto(), and efi_veto_find().