0001-southbridge-intel-common-spi-Add-Flash-lockdown-opti.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From 29a398fd71efa8ca63a98125ec4e5c1de96bcb85 Mon Sep 17 00:00:00 2001
  2. From: Timothy Pearson <tpearson@raptorengineeringinc.com>
  3. Date: Tue, 7 Apr 2015 13:45:06 -0500
  4. Subject: [PATCH 01/17] southbridge/intel/common/spi: Add Flash lockdown option
  5. Under certain circumstances it is desirable to prevent
  6. software from altering the contents of the Flash device.
  7. This Expert-mode option allows the hardware write protect
  8. to be set on bootup.
  9. Change-Id: I92d3c60a69f1688579d954d0476e30a6892cf4d5
  10. Signed-off-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
  11. ---
  12. src/southbridge/intel/common/Kconfig | 9 +++++++++
  13. src/southbridge/intel/common/spi.c | 20 ++++++++++++++------
  14. 2 files changed, 23 insertions(+), 6 deletions(-)
  15. diff --git a/src/southbridge/intel/common/Kconfig b/src/southbridge/intel/common/Kconfig
  16. index 949310b..52ada30 100644
  17. --- a/src/southbridge/intel/common/Kconfig
  18. +++ b/src/southbridge/intel/common/Kconfig
  19. @@ -1,2 +1,11 @@
  20. config SOUTHBRIDGE_INTEL_COMMON
  21. def_bool n
  22. +
  23. +config LOCK_DOWN_BIOS
  24. + bool "Lock down the Flash"
  25. + default n
  26. + depends on EXPERT
  27. + help
  28. + Lock down the Flash chip to prevent further modification by software.
  29. + WARNING: Altering the contents of the Flash chip further WILL require
  30. + a hardware programmer AND physical access to the Flash device!
  31. \ No newline at end of file
  32. diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c
  33. index 1d3ebf6..04f05ed 100644
  34. --- a/src/southbridge/intel/common/spi.c
  35. +++ b/src/southbridge/intel/common/spi.c
  36. @@ -2,6 +2,7 @@
  37. * Copyright (c) 2011 The Chromium OS Authors.
  38. * Copyright (C) 2009, 2010 Carl-Daniel Hailfinger
  39. * Copyright (C) 2011 Stefan Tauner
  40. + * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
  41. *
  42. * See file CREDITS for list of people who contributed to this
  43. * project.
  44. @@ -353,11 +354,19 @@ void spi_init(void)
  45. ich_set_bbar(0);
  46. - /* Disable the BIOS write protect so write commands are allowed. */
  47. - pci_read_config_byte(dev, 0xdc, &bios_cntl);
  48. - /* Deassert SMM BIOS Write Protect Disable. */
  49. - bios_cntl &= ~(1 << 5);
  50. - pci_write_config_byte(dev, 0xdc, bios_cntl | 0x1);
  51. + if (IS_ENABLED(CONFIG_LOCK_DOWN_BIOS)) {
  52. + /* Engage lockdown */
  53. + hsfs = readw_(&ich9_spi->hsfs);
  54. + hsfs = hsfs | HSFS_FLOCKDN;
  55. + writew_(hsfs, &ich9_spi->hsfs);
  56. + }
  57. + else {
  58. + /* Disable the BIOS write protect so write commands are allowed. */
  59. + pci_read_config_byte(dev, 0xdc, &bios_cntl);
  60. + /* Deassert SMM BIOS Write Protect Disable. */
  61. + bios_cntl &= ~(1 << 5);
  62. + pci_write_config_byte(dev, 0xdc, bios_cntl | 0x1);
  63. + }
  64. }
  65. #ifndef __SMM__
  66. static void spi_init_cb(void *unused)
  67. @@ -927,7 +936,6 @@ static int ich_hwseq_write(struct spi_flash *flash,
  68. return 0;
  69. }
  70. -
  71. static struct spi_flash *spi_flash_hwseq(struct spi_slave *spi)
  72. {
  73. struct spi_flash *flash = NULL;
  74. --
  75. 1.9.1