cbfs: Remove broken remnants of PAYLOAD_INFO feature

PAYLOAD_INFO is a very old feature that can add a key/value information
section to a payload file. It seems to have only ever been generated by
coreinfo and never really read by anything.

Since CB:1721 in 2012, the feature has been inadvertently broken in
practice since the `.note.pinfo` sections that contain the information
get discarded from the payload before cbfstool gets to see them. Since
CB:28647 in 2018, support for the section in the SELF loader was
(inadvertently?) dropped, so if someone actually fed cbfstool a payload
ELF that did have a `.note.pinfo` section, modern coreboot would refuse
to boot the payload entirely (which is probably not a good state to
leave things in).

This patch removes the code to generate PAYLOAD_INFO entries entirely,
but leaves the support to parse and extract those sections from old
payloads in place in cbfstool.

Change-Id: I40d8e9b76a171ebcdaa2eae02d54a1ca5e592c85
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/81087
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Julius Werner
2024-03-06 13:34:44 -08:00
parent 092a1398f6
commit 06e3dcac45
6 changed files with 14 additions and 91 deletions

View File

@@ -55,9 +55,7 @@ int parse_elf_to_payload(const struct buffer *input, struct buffer *output,
{
Elf64_Phdr *phdr;
Elf64_Ehdr ehdr;
Elf64_Shdr *shdr;
char *header;
char *strtab;
int headers;
int segments = 1;
int isize = 0, osize = 0;
@@ -70,39 +68,15 @@ int parse_elf_to_payload(const struct buffer *input, struct buffer *output,
if (!compress)
return -1;
if (elf_headers(input, &ehdr, &phdr, &shdr) < 0)
if (elf_headers(input, &ehdr, &phdr, NULL) < 0)
return -1;
DEBUG("start: parse_elf_to_payload\n");
headers = ehdr.e_phnum;
header = input->data;
strtab = &header[shdr[ehdr.e_shstrndx].sh_offset];
/* Count the number of headers - look for the .notes.pinfo
* section */
for (i = 0; i < ehdr.e_shnum; i++) {
char *name;
if (i == ehdr.e_shstrndx)
continue;
if (shdr[i].sh_size == 0)
continue;
name = (char *)(strtab + shdr[i].sh_name);
if (!strcmp(name, ".note.pinfo")) {
segments++;
isize += (unsigned int)shdr[i].sh_size;
}
}
/* Now, regular headers - we only care about PT_LOAD headers,
* because that's what we're actually going to load
*/
/* Count the number of segment headers - we only care about PT_LOAD
headers, because that's what we're actually going to load */
for (i = 0; i < headers; i++) {
if (phdr[i].p_type != PT_LOAD)
continue;
@@ -144,30 +118,6 @@ int parse_elf_to_payload(const struct buffer *input, struct buffer *output,
*/
segments = 0;
for (i = 0; i < ehdr.e_shnum; i++) {
char *name;
if (i == ehdr.e_shstrndx)
continue;
if (shdr[i].sh_size == 0)
continue;
name = (char *)(strtab + shdr[i].sh_name);
if (!strcmp(name, ".note.pinfo")) {
segs[segments].type = PAYLOAD_SEGMENT_PARAMS;
segs[segments].load_addr = 0;
segs[segments].len = (unsigned int)shdr[i].sh_size;
segs[segments].offset = doffset;
memcpy((unsigned long *)(output->data + doffset),
&header[shdr[i].sh_offset], shdr[i].sh_size);
doffset += segs[segments].len;
osize += segs[segments].len;
segments++;
}
}
for (i = 0; i < headers; i++) {
if (phdr[i].p_type != PT_LOAD)
continue;
@@ -223,7 +173,6 @@ int parse_elf_to_payload(const struct buffer *input, struct buffer *output,
out:
if (segs) free(segs);
if (shdr) free(shdr);
if (phdr) free(phdr);
return ret;
}