Compare commits

...

12 Commits

Author SHA1 Message Date
David Abdurachmanov 94b065692a
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2020-05-29 07:34:50 +03:00
David Abdurachmanov 10d29b54ee
Fix missing patch (riscv addappend)
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-30 15:59:51 +02:00
David Abdurachmanov 947bccf67b
Fix previous commit
- Add missing patch (forgot to add)
- Disable tests on riscv64

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-30 15:31:46 +02:00
David Abdurachmanov 42753e7364
Add 'addappend' support in extlinux for RISC-V (experimental)
addappend is similar to append, but does not overwrite exsiting boot
arguments (defined per board).

This is needed to support a single disk image for SiFive Unleashed and
QEMU virt machine.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-30 15:05:41 +02:00
David Abdurachmanov f7ed0d52e3
Match upstream Fedora master branch
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-30 14:53:59 +02:00
David Abdurachmanov 073986d8fc
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-30 14:52:49 +02:00
David Abdurachmanov 4fbd16b605
Do not apply uboot removal patch
This resolves build errors from the last merge.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-07-23 07:45:43 +03:00
David Abdurachmanov 53537b731f
Add missing patch
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-07-22 17:59:17 +03:00
David Abdurachmanov 38e5f01bab
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-07-22 17:50:45 +03:00
David Abdurachmanov fcd3f0568a
Remove wrongly committed patch and bump release
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-04-03 21:06:56 +02:00
David Abdurachmanov 063fbf5c5d
Update RISC-V patch
Ensure grubby uses U-Boot wrapped kernel and initramfs for extlinux
configuration on RISC-V.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-04-03 21:01:44 +02:00
David Abdurachmanov 57ece75e86
Bring back U-Boot wrapped images support for RISC-V (riscv64)
Currently it's the only way we can boot on RISC-V with U-Boot and
allow people to update kernels without manually replacing firmware.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-03-30 21:10:12 +01:00
2 changed files with 199 additions and 2 deletions

View File

@ -0,0 +1,191 @@
From 468294997edf8b7ca6a3434d8ea31e10229255e9 Mon Sep 17 00:00:00 2001
From: David Abdurachmanov <david.abdurachmanov@sifive.com>
Date: Wed, 30 Oct 2019 13:02:02 +0000
Subject: [PATCH] riscv: add support for addappend in extlinux
This is experimental only to be used for RISC-V to support multiple
targets with a single images.
addappend does not overwrite existing boot arguments (defined per board)
and instead adds them at the end of existing ones.
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
---
grubby.c | 44 +++++++++++++++++++++++++++-----------------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/grubby.c b/grubby.c
index 5ca6895..60d4723 100644
--- a/grubby.c
+++ b/grubby.c
@@ -101,7 +101,8 @@ enum lineType_e {
LT_KERNEL_16 = 1 << 22,
LT_INITRD_16 = 1 << 23,
LT_DEVTREE = 1 << 24,
- LT_UNKNOWN = 1 << 25,
+ LT_KERNELARGSADD = 1 << 25,
+ LT_UNKNOWN = 1 << 26,
};
struct singleLine {
@@ -589,6 +590,7 @@ struct keywordTypes extlinuxKeywords[] = {
{ "kernel", LT_KERNEL, ' ' },
{ "initrd", LT_INITRD, ' ', ',' },
{ "append", LT_KERNELARGS, ' ' },
+ { "addappend", LT_KERNELARGSADD, ' ' },
{ "prompt", LT_UNKNOWN, ' ' },
{ "fdt", LT_DEVTREE, ' ' },
{ "fdtdir", LT_DEVTREE, ' ' },
@@ -760,6 +762,14 @@ static enum lineType_e preferredLineType(enum lineType_e type,
default:
return type;
}
+#elif defined(__riscv)
+ } else if (cfi == &extlinuxConfigType) {
+ switch (type) {
+ case LT_KERNELARGS:
+ return LT_KERNELARGSADD;
+ default:
+ return type;
+ }
#endif
}
return type;
@@ -945,7 +955,7 @@ static int lineWrite(FILE * out, struct singleLine * line,
continue;
}
- if (i == 1 && line->type == LT_KERNELARGS && cfi->argsInQuotes)
+ if (i == 1 && line->type == preferredLineType(LT_KERNELARGS, cfi) && cfi->argsInQuotes)
if (fputc('"', out) == EOF) return -1;
if (fprintf(out, "%s", line->elements[i].item) == -1) return -1;
@@ -953,7 +963,7 @@ static int lineWrite(FILE * out, struct singleLine * line,
if (fprintf(out, "%s", line->elements[i].indent) == -1) return -1;
}
- if (line->type == LT_KERNELARGS && cfi->argsInQuotes)
+ if (line->type == preferredLineType(LT_KERNELARGS, cfi) && cfi->argsInQuotes)
if (fputc('"', out) == EOF) return -1;
if (fprintf(out, "\n") == -1) return -1;
@@ -1341,7 +1351,7 @@ static struct grubConfig * readConfig(const char * inName,
line->elements[line->numElements - 2].indent;
line->elements[2].item = extras;
line->numElements = 3;
- } else if (line->type == LT_KERNELARGS && cfi->argsInQuotes) {
+ } else if (line->type == preferredLineType(LT_KERNELARGS, cfi) && cfi->argsInQuotes) {
/* Strip off any " which may be present; they'll be put back
on write. This is one of the few (the only?) places that grubby
canonicalizes the output */
@@ -1972,7 +1982,7 @@ static size_t subvolPrefix(const char *str)
}
int suitableImage(struct singleEntry * entry, const char * bootPrefix,
- int skipRemoved, int flags) {
+ int skipRemoved, int flags, struct grubConfig * cfg) {
struct singleLine * line;
char * fullName;
int i;
@@ -2026,7 +2036,7 @@ int suitableImage(struct singleEntry * entry, const char * bootPrefix,
/* didn't succeed in finding a LT_ROOT, let's try LT_KERNELARGS.
* grub+multiboot uses LT_MBMODULE for the args, so check that too.
*/
- line = getLineByType(LT_KERNELARGS|LT_MBMODULE, entry->lines);
+ line = getLineByType(preferredLineType(LT_KERNELARGS, cfg->cfi)|LT_MBMODULE, entry->lines);
/* failed to find one */
if (!line) {
@@ -2266,7 +2276,7 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix,
} else {
entry = findEntryByTitle(cfg, defTitle, &index);
}
- if (entry && suitableImage(entry, prefix, skipRemoved, flags)) {
+ if (entry && suitableImage(entry, prefix, skipRemoved, flags, cfg)) {
cfg->defaultImage = index;
if (indexPtr)
*indexPtr = index;
@@ -2276,7 +2286,7 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix,
}
} else if (cfg->defaultImage > -1) {
entry = findEntryByIndex(cfg, cfg->defaultImage);
- if (entry && suitableImage(entry, prefix, skipRemoved, flags)) {
+ if (entry && suitableImage(entry, prefix, skipRemoved, flags, cfg)) {
if (indexPtr) *indexPtr = cfg->defaultImage;
return entry;
}
@@ -2284,7 +2294,7 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix,
index = 0;
while ((entry = findEntryByIndex(cfg, index))) {
- if (suitableImage(entry, prefix, skipRemoved, flags)) {
+ if (suitableImage(entry, prefix, skipRemoved, flags, cfg)) {
int j;
for (j = 0; j < index; j++) {
entry2 = findEntryByIndex(cfg, j);
@@ -2424,7 +2434,7 @@ void setFallbackImage(struct grubConfig * config, int hasNew) {
}
}
-void displayEntry(struct singleEntry * entry, const char * prefix, int index) {
+void displayEntry(struct singleEntry * entry, const char * prefix, int index, struct grubConfig * cfg) {
struct singleLine * line;
char * root = NULL;
int i;
@@ -2458,7 +2468,7 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) {
}
printf("\"\n");
} else {
- line = getLineByType(LT_KERNELARGS, entry->lines);
+ line = getLineByType(preferredLineType(LT_KERNELARGS, cfg->cfi), entry->lines);
if (line) {
char * s;
@@ -2895,11 +2905,11 @@ int displayInfo(struct grubConfig * config, char * kernel,
if (line) printf("lba\n");
}
- displayEntry(entry, prefix, i);
+ displayEntry(entry, prefix, i, config);
i++;
while ((entry = findEntryByPath(config, kernel, prefix, &i))) {
- displayEntry(entry, prefix, i);
+ displayEntry(entry, prefix, i, config);
i++;
}
@@ -3277,7 +3287,7 @@ int updateActualImage(struct grubConfig * cfg, const char * image,
}
- useKernelArgs = (getKeywordByType(LT_KERNELARGS, cfg->cfi)
+ useKernelArgs = (getKeywordByType(preferredLineType(LT_KERNELARGS, cfg->cfi), cfg->cfi)
&& (!multibootArgs || cfg->cfi->mbConcatArgs));
useRoot = (getKeywordByType(LT_ROOT, cfg->cfi)
@@ -3293,10 +3303,10 @@ int updateActualImage(struct grubConfig * cfg, const char * image,
* LT_HYPER/LT_KERNEL/LT_MBMODULE lines.
*/
if (useKernelArgs) {
- line = getLineByType(LT_KERNELARGS, entry->lines);
+ line = getLineByType(preferredLineType(LT_KERNELARGS, cfg->cfi), entry->lines);
if (!line) {
/* no LT_KERNELARGS, need to add it */
- line = addLine(entry, cfg->cfi, LT_KERNELARGS,
+ line = addLine(entry, cfg->cfi, preferredLineType(LT_KERNELARGS, cfg->cfi),
cfg->secondaryIndent, NULL);
}
firstElement = 1;
@@ -4782,7 +4792,7 @@ int main(int argc, const char ** argv) {
config->defaultImage = 0;
entry = findEntryByIndex(config, config->defaultImage);
if (!entry) return 0;
- if (!suitableImage(entry, bootPrefix, 0, flags)) return 0;
+ if (!suitableImage(entry, bootPrefix, 0, flags, config)) return 0;
line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
if (!line) return 0;
--
2.24.0.rc1

View File

@ -1,6 +1,6 @@
Name: grubby
Version: 8.40
Release: 45%{?dist}
Release: 45.0.riscv64%{?dist}
Summary: Command line tool for updating bootloader configs
License: GPLv2+
URL: https://github.com/rhinstaller/grubby
@ -28,6 +28,9 @@ Patch0010: 0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch
Patch0011: 0011-Fix-stringop-overflow-warning.patch
Patch0012: 0012-Fix-maybe-uninitialized-warning.patch
# RISC-V (experimental)
Patch0020: 0001-riscv-add-support-for-addappend-in-extlinux.patch
BuildRequires: gcc
BuildRequires: pkgconfig glib2-devel popt-devel
BuildRequires: libblkid-devel git-core sed make
@ -68,7 +71,7 @@ git config --unset user.name
%set_build_flags
make %{?_smp_mflags} LDFLAGS="${LDFLAGS}"
%ifnarch aarch64 %{arm}
%ifnarch aarch64 %{arm} riscv64
%check
make test
%endif
@ -136,6 +139,9 @@ current boot environment.
%{_mandir}/man8/*.8*
%changelog
* Fri May 29 2020 David Abdurachmanov <david.abdurachmanov@sifive.com> - 8.40-45.0.riscv64
- Add 'addappend' support for extlinux for RISC-V (experimental)
* Wed May 13 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-45
- grubby-bls: don't replace options with kernelopts if values are the same