mirror of
https://github.com/Dasharo/flashrom.git
synced 2026-03-06 14:49:20 -08:00
Rework internal bus handling and laptop bail-out
We used to bail out on any unknown laptop. However, modern systems with SPI flashes don't suffer from the original problem. Even if a flash chip is shared with the EC, the latter has to expect the host to send regular JEDEC SPI commands any time. So instead of bailing out, we limit the set of buses to probe. If we suspect to be running on a laptop, we only allow probing of SPI and opaque programmers. The user can still use the existing force options to probe all buses. This will obsolete some board-enables that could be moved to `print.c` in follow-up commits. Change-Id: I1dbda8cf0c10d7786106f14f0d18c3dcce35f0a3 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/28716 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Thomas Heijligen <src@posteo.de>
This commit is contained in:
+4
-1
@@ -600,12 +600,15 @@ int it8705f_write_enable(uint8_t port)
|
||||
uint8_t tmp;
|
||||
int ret = 0;
|
||||
|
||||
if (!(internal_buses_supported & BUS_PARALLEL))
|
||||
return 1;
|
||||
|
||||
enter_conf_mode_ite(port);
|
||||
tmp = sio_read(port, 0x24);
|
||||
/* Check if at least one flash segment is enabled. */
|
||||
if (tmp & 0xf0) {
|
||||
/* The IT8705F will respond to LPC cycles and translate them. */
|
||||
internal_buses_supported = BUS_PARALLEL;
|
||||
internal_buses_supported &= BUS_PARALLEL;
|
||||
/* Flash ROM I/F Writes Enable */
|
||||
tmp |= 0x04;
|
||||
msg_pdbg("Enabling IT8705F flash ROM interface write.\n");
|
||||
|
||||
+439
-376
File diff suppressed because it is too large
Load Diff
+16
-15
@@ -543,21 +543,22 @@ Example:
|
||||
.TP
|
||||
.B Laptops
|
||||
.sp
|
||||
Using flashrom on laptops is dangerous and may easily make your hardware
|
||||
unusable (see also the
|
||||
Using flashrom on older laptops that don't boot from the SPI bus is
|
||||
dangerous and may easily make your hardware unusable (see also the
|
||||
.B BUGS
|
||||
section). The embedded controller (EC) in these
|
||||
machines often interacts badly with flashing.
|
||||
section). The embedded controller (EC) in some
|
||||
machines may interact badly with flashing.
|
||||
More information is
|
||||
.URLB https://flashrom.org/Laptops "in the wiki" .
|
||||
For example the EC firmware sometimes resides on the same
|
||||
flash chip as the host firmware. While flashrom tries to change the contents of
|
||||
Problems occur when the flash chip is shared between BIOS
|
||||
and EC firmware, and the latter does not expect flashrom
|
||||
to access the chip. While flashrom tries to change the contents of
|
||||
that memory the EC might need to fetch new instructions or data from it and
|
||||
could stop working correctly. Probing for and reading from the chip may also
|
||||
irritate your EC and cause fan failure, backlight failure, sudden poweroff, and
|
||||
other nasty effects. flashrom will attempt to detect if it is running on a
|
||||
laptop and abort immediately for safety reasons if it clearly identifies the
|
||||
host computer as one. If you want to proceed anyway at your own risk, use
|
||||
other nasty effects. flashrom will attempt to detect if it is running on such a
|
||||
laptop and limit probing to SPI buses. If you want to probe the LPC bus
|
||||
anyway at your own risk, use
|
||||
.sp
|
||||
.B " flashrom \-p internal:laptop=force_I_want_a_brick"
|
||||
.sp
|
||||
@@ -568,8 +569,8 @@ You have been warned.
|
||||
.sp
|
||||
Currently we rely on the chassis type encoded in the DMI/SMBIOS data to detect
|
||||
laptops. Some vendors did not implement those bits correctly or set them to
|
||||
generic and/or dummy values. flashrom will then issue a warning and bail out
|
||||
like above. In this case you can use
|
||||
generic and/or dummy values. flashrom will then issue a warning and restrict
|
||||
buses like above. In this case you can use
|
||||
.sp
|
||||
.B " flashrom \-p internal:laptop=this_is_not_a_laptop"
|
||||
.sp
|
||||
@@ -1291,10 +1292,10 @@ channel.
|
||||
.SS
|
||||
.B Laptops
|
||||
.sp
|
||||
Using flashrom on laptops is dangerous and may easily make your hardware
|
||||
unusable. flashrom will attempt to detect if it is running on a laptop and abort
|
||||
immediately for safety reasons. Please see the detailed discussion of this topic
|
||||
and associated flashrom options in the
|
||||
Using flashrom on older laptops is dangerous and may easily make your hardware
|
||||
unusable. flashrom will attempt to detect if it is running on a susceptible
|
||||
laptop and restrict flash-chip probing for safety reasons. Please see the
|
||||
detailed discussion of this topic and associated flashrom options in the
|
||||
.B Laptops
|
||||
paragraph in the
|
||||
.B internal programmer
|
||||
|
||||
@@ -2010,7 +2010,7 @@ int via_init_spi(uint32_t mmio_base)
|
||||
/* Do we really need no write enable? Like the LPC one at D17F0 0x40 */
|
||||
|
||||
/* Not sure if it speaks all these bus protocols. */
|
||||
internal_buses_supported = BUS_LPC | BUS_FWH;
|
||||
internal_buses_supported &= BUS_LPC | BUS_FWH;
|
||||
ich_generation = CHIPSET_ICH7;
|
||||
register_spi_master(&spi_master_via);
|
||||
|
||||
|
||||
+39
-31
@@ -257,6 +257,8 @@ int internal_init(void)
|
||||
#endif
|
||||
|
||||
#if IS_X86
|
||||
is_laptop = 2; /* Assume that we don't know by default. */
|
||||
|
||||
dmi_init();
|
||||
|
||||
/* In case Super I/O probing would cause pretty explosions. */
|
||||
@@ -275,36 +277,13 @@ int internal_init(void)
|
||||
/* Check laptop whitelist. */
|
||||
board_handle_before_laptop();
|
||||
|
||||
/* Warn if a non-whitelisted laptop is detected. */
|
||||
if (is_laptop && !laptop_ok) {
|
||||
msg_perr("========================================================================\n");
|
||||
if (is_laptop == 1) {
|
||||
msg_perr("WARNING! You seem to be running flashrom on an unsupported laptop.\n");
|
||||
} else {
|
||||
msg_perr("WARNING! You may be running flashrom on an unsupported laptop. We could\n"
|
||||
"not detect this for sure because your vendor has not setup the SMBIOS\n"
|
||||
"tables correctly. You can enforce execution by adding\n"
|
||||
"'-p internal:laptop=this_is_not_a_laptop' to the command line, but\n"
|
||||
"please read the following warning if you are not sure.\n\n");
|
||||
}
|
||||
msg_perr("Laptops, notebooks and netbooks are difficult to support and we\n"
|
||||
"recommend to use the vendor flashing utility. The embedded controller\n"
|
||||
"(EC) in these machines often interacts badly with flashing.\n"
|
||||
"See the manpage and https://flashrom.org/Laptops for details.\n\n"
|
||||
"If flash is shared with the EC, erase is guaranteed to brick your laptop\n"
|
||||
"and write may brick your laptop.\n"
|
||||
"Read and probe may irritate your EC and cause fan failure, backlight\n"
|
||||
"failure and sudden poweroff.\n"
|
||||
"You have been warned.\n"
|
||||
"========================================================================\n");
|
||||
|
||||
if (force_laptop || (not_a_laptop && (is_laptop == 2))) {
|
||||
msg_perr("Proceeding anyway because user forced us to.\n");
|
||||
} else {
|
||||
msg_perr("Aborting.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Disable all internal buses by default if we are not sure
|
||||
* this isn't a laptop. Board-enables may override this,
|
||||
* non-legacy buses (SPI and opaque atm) are probed anyway.
|
||||
*/
|
||||
if (is_laptop && !(laptop_ok || force_laptop || (not_a_laptop && is_laptop == 2)))
|
||||
internal_buses_supported = BUS_NONE;
|
||||
|
||||
/* try to enable it. Failure IS an option, since not all motherboards
|
||||
* really need this to be done, etc., etc.
|
||||
@@ -327,7 +306,36 @@ int internal_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
register_par_master(&par_master_internal, internal_buses_supported);
|
||||
if (internal_buses_supported & BUS_NONSPI)
|
||||
register_par_master(&par_master_internal, internal_buses_supported);
|
||||
|
||||
/* Report if a non-whitelisted laptop is detected that likely uses a legacy bus. */
|
||||
if (is_laptop && !laptop_ok) {
|
||||
msg_pinfo("========================================================================\n");
|
||||
if (is_laptop == 1) {
|
||||
msg_pinfo("You seem to be running flashrom on an unknown laptop. Some\n"
|
||||
"internal buses have been disabled for safety reasons.\n\n");
|
||||
} else {
|
||||
msg_pinfo("You may be running flashrom on an unknown laptop. We could not\n"
|
||||
"detect this for sure because your vendor has not set up the SMBIOS\n"
|
||||
"tables correctly. Some internal buses have been disabled for\n"
|
||||
"safety reasons. You can enforce using all buses by adding\n"
|
||||
" -p internal:laptop=this_is_not_a_laptop\n"
|
||||
"to the command line, but please read the following warning if you\n"
|
||||
"are not sure.\n\n");
|
||||
}
|
||||
msg_perr("Laptops, notebooks and netbooks are difficult to support and we\n"
|
||||
"recommend to use the vendor flashing utility. The embedded controller\n"
|
||||
"(EC) in these machines often interacts badly with flashing.\n"
|
||||
"See the manpage and https://flashrom.org/Laptops for details.\n\n"
|
||||
"If flash is shared with the EC, erase is guaranteed to brick your laptop\n"
|
||||
"and write may brick your laptop.\n"
|
||||
"Read and probe may irritate your EC and cause fan failure, backlight\n"
|
||||
"failure and sudden poweroff.\n"
|
||||
"You have been warned.\n"
|
||||
"========================================================================\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,6 +226,7 @@ int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data);
|
||||
struct penable {
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
enum chipbustype buses;
|
||||
const enum test_state status;
|
||||
const char *vendor_name;
|
||||
const char *device_name;
|
||||
|
||||
Reference in New Issue
Block a user