0004-Adaptation-for-a-read-only-boot-path-when-no-vboot-h.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. From 0ec9edead1d9de5f913333e6aa77bcd3de83a617 Mon Sep 17 00:00:00 2001
  2. From: Paul Kocialkowski <contact@paulk.fr>
  3. Date: Sun, 9 Aug 2015 12:09:35 +0200
  4. Subject: [PATCH 4/8] Adaptation for a read-only boot path when no vboot
  5. handoff data is found
  6. When no vboot handoff data is found, this makes the unified depthcharge build
  7. attempt to follow the read-only boot path.
  8. vboot_select_firmware is called to grab the kernel key from the firmware header,
  9. but it won't actually jump to a RW version of depthcharge.
  10. Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
  11. ---
  12. src/image/Makefile.inc | 1 +
  13. src/image/startrw_stub.c | 34 ++++++++++++++++++++++++++++++++++
  14. src/vboot/main.c | 17 ++++++++++++++++-
  15. src/vboot/util/commonparams-unified.c | 11 +++++++++--
  16. 4 files changed, 60 insertions(+), 3 deletions(-)
  17. create mode 100644 src/image/startrw_stub.c
  18. diff --git a/src/image/Makefile.inc b/src/image/Makefile.inc
  19. index 95aeda1..4b74c11 100644
  20. --- a/src/image/Makefile.inc
  21. +++ b/src/image/Makefile.inc
  22. @@ -18,6 +18,7 @@
  23. depthcharge-y += fmap.c
  24. depthcharge-y += index.c
  25. readonly-y += startrw.c
  26. +unified-y += startrw_stub.c
  27. trampoline-y += load_elf.c
  28. diff --git a/src/image/startrw_stub.c b/src/image/startrw_stub.c
  29. new file mode 100644
  30. index 0000000..8e40302
  31. --- /dev/null
  32. +++ b/src/image/startrw_stub.c
  33. @@ -0,0 +1,34 @@
  34. +/*
  35. + * Copyright 2012 Google Inc.
  36. + *
  37. + * See file CREDITS for list of people who contributed to this
  38. + * project.
  39. + *
  40. + * This program is free software; you can redistribute it and/or
  41. + * modify it under the terms of the GNU General Public License as
  42. + * published by the Free Software Foundation; either version 2 of
  43. + * the License, or (at your option) any later version.
  44. + *
  45. + * This program is distributed in the hope that it will be useful,
  46. + * but without any warranty; without even the implied warranty of
  47. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  48. + * GNU General Public License for more details.
  49. + *
  50. + * You should have received a copy of the GNU General Public License
  51. + * along with this program; if not, write to the Free Software
  52. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  53. + * MA 02111-1307 USA
  54. + */
  55. +
  56. +#include <libpayload.h>
  57. +#include <lzma.h>
  58. +
  59. +#include "base/elf.h"
  60. +#include "image/enter_trampoline.h"
  61. +#include "image/startrw.h"
  62. +#include "image/symbols.h"
  63. +
  64. +int start_rw_firmware(const void *compressed_image, uint32_t size)
  65. +{
  66. + return 0;
  67. +}
  68. diff --git a/src/vboot/main.c b/src/vboot/main.c
  69. index 7dc05f5..97a218d 100644
  70. --- a/src/vboot/main.c
  71. +++ b/src/vboot/main.c
  72. @@ -82,6 +82,20 @@ static int vboot_init_handoff()
  73. return vboot_do_init_out_flags(vboot_handoff->init_params.out_flags);
  74. }
  75. +static int vboot_init_ro()
  76. +{
  77. + // Set up the common param structure, clearing shared data.
  78. + if (common_params_init(1))
  79. + return 1;
  80. +
  81. + // Initialize vboot.
  82. + if (vboot_init())
  83. + return 1;
  84. +
  85. + // Select firmware.
  86. + return vboot_select_firmware();
  87. +}
  88. +
  89. int main(void)
  90. {
  91. // Let the world know we're alive.
  92. @@ -108,7 +122,8 @@ int main(void)
  93. // Set up the common param structure, not clearing shared data.
  94. if (vboot_init_handoff())
  95. - halt();
  96. + if (vboot_init_ro())
  97. + halt();
  98. /* Fastboot is only entered in recovery path */
  99. if (vboot_in_recovery())
  100. diff --git a/src/vboot/util/commonparams-unified.c b/src/vboot/util/commonparams-unified.c
  101. index 10fcb93..575dcfd 100644
  102. --- a/src/vboot/util/commonparams-unified.c
  103. +++ b/src/vboot/util/commonparams-unified.c
  104. @@ -28,7 +28,14 @@
  105. int find_common_params(void **blob, int *size)
  106. {
  107. struct vboot_handoff *vboot_handoff = lib_sysinfo.vboot_handoff;
  108. - *blob = &vboot_handoff->shared_data[0];
  109. - *size = ARRAY_SIZE(vboot_handoff->shared_data);
  110. +
  111. + if (vboot_handoff != NULL) {
  112. + *blob = &vboot_handoff->shared_data[0];
  113. + *size = ARRAY_SIZE(vboot_handoff->shared_data);
  114. + } else {
  115. + *blob = shared_data_blob;
  116. + *size = sizeof(shared_data_blob);
  117. + }
  118. +
  119. return 0;
  120. }
  121. --
  122. 2.8.0