iPXE
efi_veto.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
21 
22 #include <stddef.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <errno.h>
26 #include <ipxe/settings.h>
27 #include <ipxe/pci.h>
28 #include <ipxe/efi/efi.h>
32 #include <ipxe/efi/efi_veto.h>
33 
34 /** @file
35  *
36  * EFI driver vetoes
37  *
38  */
39 
40 /** A driver veto candidate */
42  /** Veto name (for debugging) */
43  const char *name;
44  /**
45  * Check if driver is vetoed
46  *
47  * @v binding Driver binding protocol
48  * @v loaded Loaded image protocol
49  * @v wtf Component name protocol, if present
50  * @v manufacturer Manufacturer name, if present
51  * @v name Driver name (in "eng" language), if present
52  * @ret vetoed Driver is to be vetoed
53  */
54  int ( * veto ) ( EFI_DRIVER_BINDING_PROTOCOL *binding,
57  const char *manufacturer, const CHAR16 *name );
58 };
59 
60 /** A driver veto */
61 struct efi_veto {
62  /** Driver binding handle */
64  /** Driving binding protocol */
66  /** Image handle */
68  /** Loaded image protocol */
70 };
71 
72 /**
73  * Unload an EFI driver
74  *
75  * @v veto Driver veto
76  * @ret rc Return status code
77  */
78 static int efi_veto_unload ( struct efi_veto *veto ) {
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 }
97 
98 /**
99  * Disconnect an EFI driver from all handles
100  *
101  * @v veto Driver veto
102  * @ret rc Return status code
103  */
104 static int efi_veto_disconnect ( struct efi_veto *veto ) {
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 }
147 
148 /**
149  * Uninstall an EFI driver binding protocol
150  *
151  * @v veto Driver veto
152  * @ret rc Return status code
153  */
154 static int efi_veto_uninstall ( struct efi_veto *veto ) {
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 }
195 
196 /**
197  * Close protocol on handle potentially opened by an EFI driver
198  *
199  * @v veto Driver veto
200  * @v handle Potentially opened handle
201  * @v protocol Opened protocol
202  * @ret rc Return status code
203  */
205  EFI_GUID *protocol ) {
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 }
256 
257 /**
258  * Close handle potentially opened by an EFI driver
259  *
260  * @v veto Driver veto
261  * @v handle Potentially opened handle
262  * @ret rc Return status code
263  */
264 static int efi_veto_close_handle ( struct efi_veto *veto, EFI_HANDLE handle ) {
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 }
301 
302 /**
303  * Close all remaining handles opened by an EFI driver
304  *
305  * @v veto Driver veto
306  * @ret rc Return status code
307  */
308 static int efi_veto_close ( struct efi_veto *veto ) {
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 }
344 
345 /**
346  * Terminate an EFI driver with extreme prejudice
347  *
348  * @v veto Driver veto
349  * @ret rc Return status code
350  */
351 static int efi_veto_destroy ( struct efi_veto *veto ) {
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 }
371 
372 /**
373  * Veto an EFI driver
374  *
375  * @v veto Driver veto
376  * @ret rc Return status code
377  */
378 static int efi_veto_driver ( struct efi_veto *veto ) {
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 }
391 
392 /**
393  * Veto Ip4ConfigDxe driver on some platforms
394  *
395  * @v binding Driver binding protocol
396  * @v loaded Loaded image protocol
397  * @v wtf Component name protocol, if present
398  * @v manufacturer Manufacturer name, if present
399  * @v name Driver name, if present
400  * @ret vetoed Driver is to be vetoed
401  */
402 static int
406  const char *manufacturer, const CHAR16 *name ) {
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 }
424 
425 /**
426  * Veto HP XhciDxe driver
427  *
428  * @v binding Driver binding protocol
429  * @v loaded Loaded image protocol
430  * @v wtf Component name protocol, if present
431  * @v manufacturer Manufacturer name, if present
432  * @v name Driver name, if present
433  * @ret vetoed Driver is to be vetoed
434  */
435 static int
439  const char *manufacturer, const CHAR16 *name ) {
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 }
465 
466 /**
467  * Veto VMware UefiPxeBcDxe driver
468  *
469  * @v binding Driver binding protocol
470  * @v loaded Loaded image protocol
471  * @v wtf Component name protocol, if present
472  * @v manufacturer Manufacturer name, if present
473  * @v name Driver name, if present
474  * @ret vetoed Driver is to be vetoed
475  */
476 static int
480  const char *manufacturer, const CHAR16 *name ) {
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 }
496 
497 /**
498  * Veto Dhcp6Dxe driver
499  *
500  * @v binding Driver binding protocol
501  * @v loaded Loaded image protocol
502  * @v wtf Component name protocol, if present
503  * @v manufacturer Manufacturer name, if present
504  * @v name Driver name, if present
505  * @ret vetoed Driver is to be vetoed
506  */
510  const char *manufacturer __unused,
511  const CHAR16 *name ) {
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 }
522 
523 /** Driver vetoes */
524 static struct efi_veto_candidate efi_vetoes[] = {
525  {
526  .name = "Ip4Config",
527  .veto = efi_veto_ip4config,
528  },
529  {
530  .name = "HP Xhci",
531  .veto = efi_veto_hp_xhci,
532  },
533  {
534  .name = "VMware UefiPxeBc",
536  },
537  {
538  .name = "Dhcp6",
539  .veto = efi_veto_dhcp6,
540  },
541 };
542 
543 /**
544  * Find driver veto, if any
545  *
546  * @v driver Driver binding handle
547  * @v manufacturer Manufacturer name, if present
548  * @ret veto Driver veto to fill in
549  * @ret rc Return status code
550  */
551 static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
552  struct efi_veto *veto ) {
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 }
655 
656 /**
657  * Remove any vetoed drivers
658  *
659  */
660 void efi_veto ( void ) {
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 }
UEFI DriverBinding Protocol is defined in UEFI specification.
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
const char * name
Veto name (for debugging)
Definition: efi_veto.c:43
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
EFI Oprn Protocol Information Entry.
Definition: UefiSpec.h:1421
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
struct pci_class_id class
PCI class ID.
Definition: pci.h:253
#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
A PCI driver.
Definition: pci.h:247
EFI_HANDLE ControllerHandle
Definition: UefiSpec.h:1423
void efi_veto(void)
Remove any vetoed drivers.
Definition: efi_veto.c:660
EFI_HANDLE AgentHandle
Definition: UefiSpec.h:1422
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:67
static int efi_veto_driver(struct efi_veto *veto)
Veto an EFI driver.
Definition: efi_veto.c:378
128 bit buffer containing a unique identifier value.
Definition: Base.h:215
Error codes.
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1511
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_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:243
A driver veto candidate.
Definition: efi_veto.c:41
EFI driver vetoes.
unsigned short CHAR16
uint32_t class
Class.
Definition: pci.h:187
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1967
An executable image.
Definition: image.h:24
EFI Component Name Protocol as defined in the EFI 1.1 specification.
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1987
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
#define PCI_CLASS_SERIAL_USB_XHCI
xHCI USB controller
Definition: pci.h:140
#define PCI_CLASS_SERIAL
Definition: Pci22.h:266
UEFI 2.0 Loaded image protocol definition.
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
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
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 PCI_CLASS(base, sub, progif)
Construct PCI class.
Definition: pci.h:162
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int fetch_string_setting_copy(struct settings *settings, const struct setting *setting, char **data)
Fetch value of string setting.
Definition: settings.c:873
static int efi_veto_unload(struct efi_veto *veto)
Unload an EFI driver.
Definition: efi_veto.c:78
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1344
Configuration settings.
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
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
EFI Boot Services Table.
Definition: UefiSpec.h:1917
#define PCI_CLASS_SERIAL_USB
Definition: Pci22.h:272
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:34
PCI bus.
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
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1997
int(* veto)(EFI_DRIVER_BINDING_PROTOCOL *binding, EFI_LOADED_IMAGE_PROTOCOL *loaded, EFI_COMPONENT_NAME_PROTOCOL *wtf, const char *manufacturer, const CHAR16 *name)
Check if driver is vetoed.
Definition: efi_veto.c:54
UINT64 UINTN
Unsigned value of native width.
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
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_FREE_POOL FreePool
Definition: UefiSpec.h:1936
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:1988
EFI API.
static int efi_veto_destroy(struct efi_veto *veto)
Terminate an EFI driver with extreme prejudice.
Definition: efi_veto.c:351
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
EFI_LOADED_IMAGE_PROTOCOL * loaded
Loaded image protocol.
Definition: efi_veto.c:69
uint8_t controller
CD-ROM controller number.
Definition: int13.h:18
#define EFI_NOT_FOUND
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:128
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:1993
#define DBGC2(...)
Definition: compiler.h:522
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
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
Retrieve the set of handles from the handle database that support a specified protocol.
Definition: UefiSpec.h:1520
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
uint16_t protocol
Protocol ID.
Definition: stp.h:18
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
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
uint16_t handle
Handle.
Definition: smbios.h:16
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
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
String functions.
A driver veto.
Definition: efi_veto.c:61
Definition: efi.h:59
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1994
#define PCI_DRIVERS
PCI driver table.
Definition: pci.h:270
void * memset(void *dest, int character, size_t len) __nonnull
#define DBGC_EFI_OPENER(...)
Definition: efi.h:319
EFI_DISCONNECT_CONTROLLER DisconnectController
Definition: UefiSpec.h:1981