Re: Was there a Wiki on what we can do with GRUB2? And what happened to it?
On Tue, May 26, 2015 at 1:05 AM, Vladimir 'phcoder' Serbinenko wrote: > Wiki is gone because of lack of hosting. I still have last dump from it but > at that point all relevant info is probably in the manual > Should we remove reference to grub.enbug.org from README then? Currently this domain does not exist at all. > Le 12 mai 2015 05:54, "Gregg Levine" a écrit : >> >> Hello! >> I am revisiting an issue that surfaced on or about the beginning of >> November of 2008. I found the relevant messages in my Google Mail >> store and went over them, I also read the corresponding coreboot >> messages from the same period. >> >> The responding individual then mentions that what I was interested in, >> namely using Grub2 to bring up a payload of coreboot as an Elf file >> was indeed described on a Wiki. It happens I recall studying the pages >> then, but it seems the pages are gone now, although the Archive.org >> site may remember them. But I'm asking here first. >> - >> Gregg C Levine gregg.drw...@gmail.com >> "This signature fought the Time Wars, time and again." >> >> ___ >> Grub-devel mailing list >> Grub-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/grub-devel > > > ___ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel > ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 2/4] Cryptomount support key files
--- grub-core/disk/cryptodisk.c | 34 +++-- grub-core/disk/geli.c | 4 +++- grub-core/disk/luks.c | 46 +++-- include/grub/cryptodisk.h | 5 - 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 65b3a01..fbe7db9 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -41,6 +41,10 @@ static const struct grub_arg_option options[] = {"all", 'a', 0, N_("Mount all."), 0, 0}, {"boot", 'b', 0, N_("Mount all volumes with `boot' flag set."), 0, 0}, {"header", 'H', 0, N_("Read LUKS header from file"), 0, ARG_TYPE_STRING}, +{"keyfile", 'k', 0, N_("Key file"), 0, ARG_TYPE_STRING}, +{"key-size", 'K', 0, N_("Set key size (bits)"), 0, ARG_TYPE_INT}, +{"keyfile-offset", 'O', 0, N_("Key file offset (bytes)"), 0, ARG_TYPE_INT}, +{"keyfile-size", 'S', 0, N_("Key file data size (bytes)"), 0, ARG_TYPE_INT}, {0, 0, 0, 0, 0, 0} }; @@ -805,6 +809,8 @@ grub_util_cryptodisk_get_uuid (grub_disk_t disk) static int check_boot, have_it; static char *search_uuid; static grub_file_t hdr; +static grub_uint8_t *key, keyfile_buffer[GRUB_CRYPTODISK_MAX_KEYFILE_SIZE]; +static grub_size_t keyfile_size; static void cryptodisk_close (grub_cryptodisk_t dev) @@ -835,7 +841,7 @@ grub_cryptodisk_scan_device_real (const char *name, grub_disk_t source) if (!dev) continue; -err = cr->recover_key (source, dev, hdr); +err = cr->recover_key (source, dev, hdr, key, keyfile_size); if (err) { cryptodisk_close (dev); @@ -938,12 +944,36 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) hdr = grub_file_open (state[3].arg); if (!hdr) return grub_errno; - grub_printf ("\nUsing detached header %s\n", state[3].arg); } else hdr = NULL; have_it = 0; + + if (state[4].set) /* Key file */ +{ + grub_file_t keyfile; + int keyfile_offset; + + key = keyfile_buffer; + keyfile_offset = state[6].set ? grub_strtoul (state[6].arg, 0, 0) : 0; + keyfile_size = state[7].set ? grub_strtoul (state[7].arg, 0, 0) : \ +GRUB_CRYPTODISK_MAX_KEYFILE_SIZE; + + keyfile = grub_file_open (state[4].arg); + if (!keyfile) +return grub_errno; + + if (grub_file_seek (keyfile, keyfile_offset) == (grub_off_t)-1) +return grub_errno; + + keyfile_size = grub_file_read (keyfile, key, keyfile_size); + if (keyfile_size == (grub_size_t)-1) + return grub_errno; +} + else +key = NULL; + if (state[0].set) { grub_cryptodisk_t dev; diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index f4394eb..da6aa6a 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -401,7 +401,9 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, static grub_err_t recover_key (grub_disk_t source, grub_cryptodisk_t dev, -grub_file_t hdr __attribute__ ((unused)) ) +grub_file_t hdr __attribute__ ((unused)), +grub_uint8_t *key __attribute__ ((unused)), +grub_size_t keyfile_size __attribute__ ((unused)) ) { grub_size_t keysize; grub_uint8_t digest[GRUB_CRYPTO_MAX_MDLEN]; diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c index 66e64c0..0d0db9d 100644 --- a/grub-core/disk/luks.c +++ b/grub-core/disk/luks.c @@ -136,6 +136,8 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, ciphermode[sizeof (header.cipherMode)] = 0; grub_memcpy (hashspec, header.hashSpec, sizeof (header.hashSpec)); hashspec[sizeof (header.hashSpec)] = 0; + grub_memcpy (uuid, header.uuid, sizeof (header.uuid)); + uuid[sizeof (header.uuid)] = 0; ciph = grub_crypto_lookup_cipher_by_name (ciphername); if (!ciph) @@ -322,12 +324,16 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, static grub_err_t luks_recover_key (grub_disk_t source, grub_cryptodisk_t dev, - grub_file_t hdr) + grub_file_t hdr, + grub_uint8_t *keyfile_bytes, + grub_size_t keyfile_bytes_size) { struct grub_luks_phdr header; grub_size_t keysize; grub_uint8_t *split_key = NULL; - char passphrase[MAX_PASSPHRASE] = ""; + char interactive_passphrase[MAX_PASSPHRASE] = ""; + grub_uint8_t *passphrase; + grub_size_t passphrase_length; grub_uint8_t candidate_digest[sizeof (header.mkDigest)]; unsigned i; grub_size_t length; @@ -364,18 +370,30 @@ luks_recover_key (grub_disk_t source, if (!split_key) return grub_errno; - /* Get the passphrase from the user. */ - tmp = NULL; - if (source->partition) -tmp = grub_partition_get_name (source->partition); - grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), source->name, - source->partition ? "," : "", tmp
Cryptomount enhancements: detached headers, key-files and plain mode
These patches provide extensions to the "cryptomount" command. There are four patches: 1. Support LUKS detached headers so that the header can be separated from the data payload, e.g. by storing on external removable media such as a USB key. 2. Support key files so that passphrase entry can be suppressed. The passphrase can be stored in a "key file" that can be stored, for example, on external removable media such as a USB key. 3. Support plain dm-crypt mode. Allow plain volumes to be opened. This is largely a re-factoring of exisitng code to allow the crypto routines be used independently of LUKS. 4. Support for hyphens in UUID. The "-u" option of cryptomount accepts a UUID. This option allows that to be delimited with hyphens so that the same format can be given to Grub as is passed to the Linux kernel boot options. I can supply more information as required in reply to the individual patches. ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 4/4] Cryptomount support for hyphens in UUID
--- grub-core/disk/cryptodisk.c | 9 + grub-core/disk/luks.c | 1 + include/grub/cryptodisk.h | 3 +++ 3 files changed, 13 insertions(+) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index c519c55..b800d6f 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -113,6 +113,13 @@ gf_mul_be (grub_uint8_t *o, const grub_uint8_t *a, const grub_uint8_t *b) } } +void +grub_cryptodisk_uuid_dehyphenate(char *uuid) +{ + char *s, *d; + for (s=d=uuid;(*d=*s);d+=(*s++!='-')); +} + static gcry_err_code_t grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size, @@ -506,6 +513,7 @@ grub_cryptodisk_open (const char *name, grub_disk_t disk) if (grub_memcmp (name, "cryptouuid/", sizeof ("cryptouuid/") - 1) == 0) { + grub_cryptodisk_uuid_dehyphenate((char *)name + sizeof ("cryptouuid/")); for (dev = cryptodisk_list; dev != NULL; dev = dev->next) if (grub_strcasecmp (name + sizeof ("cryptouuid/") - 1, dev->uuid) == 0) break; @@ -1025,6 +1033,7 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) { grub_cryptodisk_t dev; + grub_cryptodisk_uuid_dehyphenate(args[0]); dev = grub_cryptodisk_get_by_uuid (args[0]); if (dev) { diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c index 069e72c..0e570cf 100644 --- a/grub-core/disk/luks.c +++ b/grub-core/disk/luks.c @@ -111,6 +111,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, hashspec[sizeof (header.hashSpec)] = 0; grub_memcpy (uuid, header.uuid, sizeof (header.uuid)); uuid[sizeof (header.uuid)] = 0; + grub_cryptodisk_uuid_dehyphenate (uuid); if (check_uuid && grub_strcasecmp (check_uuid, uuid) != 0) { diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h index 4076412..cfb0f0d 100644 --- a/include/grub/cryptodisk.h +++ b/include/grub/cryptodisk.h @@ -167,4 +167,7 @@ grub_cryptodisk_t grub_cryptodisk_get_by_source_disk (grub_disk_t disk); grub_cryptodisk_t grub_cryptodisk_create (grub_disk_t disk, char *uuid, char *ciphername, char *ciphermode, char *digest); +void +grub_cryptodisk_uuid_dehyphenate(char *uuid); + #endif -- 2.1.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 1/4] Cryptomount support LUKS detached header
--- grub-core/disk/cryptodisk.c | 23 +++ grub-core/disk/geli.c | 7 +-- grub-core/disk/luks.c | 45 + include/grub/cryptodisk.h | 5 +++-- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 82a3dcb..65b3a01 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -40,6 +40,7 @@ static const struct grub_arg_option options[] = /* TRANSLATORS: It's still restricted to cryptodisks only. */ {"all", 'a', 0, N_("Mount all."), 0, 0}, {"boot", 'b', 0, N_("Mount all volumes with `boot' flag set."), 0, 0}, +{"header", 'H', 0, N_("Read LUKS header from file"), 0, ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; @@ -803,6 +804,7 @@ grub_util_cryptodisk_get_uuid (grub_disk_t disk) static int check_boot, have_it; static char *search_uuid; +static grub_file_t hdr; static void cryptodisk_close (grub_cryptodisk_t dev) @@ -827,13 +829,13 @@ grub_cryptodisk_scan_device_real (const char *name, grub_disk_t source) FOR_CRYPTODISK_DEVS (cr) { -dev = cr->scan (source, search_uuid, check_boot); +dev = cr->scan (source, search_uuid, check_boot, hdr); if (grub_errno) return grub_errno; if (!dev) continue; -err = cr->recover_key (source, dev); +err = cr->recover_key (source, dev, hdr); if (err) { cryptodisk_close (dev); @@ -874,7 +876,7 @@ grub_cryptodisk_cheat_mount (const char *sourcedev, const char *cheat) FOR_CRYPTODISK_DEVS (cr) { -dev = cr->scan (source, search_uuid, check_boot); +dev = cr->scan (source, search_uuid, check_boot,0); if (grub_errno) return grub_errno; if (!dev) @@ -928,6 +930,19 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) if (argc < 1 && !state[1].set && !state[2].set) return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required"); + if (state[3].set) /* LUKS detached header */ +{ + if (state[0].set) /* Cannot use UUID lookup with detached header */ +return GRUB_ERR_BAD_ARGUMENT; + + hdr = grub_file_open (state[3].arg); + if (!hdr) +return grub_errno; + grub_printf ("\nUsing detached header %s\n", state[3].arg); +} + else +hdr = NULL; + have_it = 0; if (state[0].set) { @@ -1125,7 +1140,7 @@ GRUB_MOD_INIT (cryptodisk) { grub_disk_dev_register (&grub_cryptodisk_dev); cmd = grub_register_extcmd ("cryptomount", grub_cmd_cryptomount, 0, - N_("SOURCE|-u UUID|-a|-b"), + N_("SOURCE|-u UUID|-a|-b|-H file"), N_("Mount a crypto device."), options); grub_procfs_register ("luks_script", &luks_script); } diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index e9d2329..f4394eb 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -243,7 +244,8 @@ grub_util_get_geli_uuid (const char *dev) static grub_cryptodisk_t configure_ciphers (grub_disk_t disk, const char *check_uuid, - int boot_only) + int boot_only, + grub_file_t hdr __attribute__ ((unused)) ) { grub_cryptodisk_t newdev; struct grub_geli_phdr header; @@ -398,7 +400,8 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, } static grub_err_t -recover_key (grub_disk_t source, grub_cryptodisk_t dev) +recover_key (grub_disk_t source, grub_cryptodisk_t dev, +grub_file_t hdr __attribute__ ((unused)) ) { grub_size_t keysize; grub_uint8_t digest[GRUB_CRYPTO_MAX_MDLEN]; diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c index 86c50c6..66e64c0 100644 --- a/grub-core/disk/luks.c +++ b/grub-core/disk/luks.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -66,7 +67,7 @@ gcry_err_code_t AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, static grub_cryptodisk_t configure_ciphers (grub_disk_t disk, const char *check_uuid, - int check_boot) + int check_boot, grub_file_t hdr) { grub_cryptodisk_t newdev; const char *iptr; @@ -86,11 +87,21 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, int benbi_log = 0; grub_err_t err; + err = GRUB_ERR_NONE; + if (check_boot) return NULL; /* Read the LUKS header. */ - err = grub_disk_read (disk, 0, 0, sizeof (header), &header); + if (hdr) + { +grub_file_seek (hdr, 0); +if (grub_file_read (hdr, &header, sizeof (header)) != sizeof (header)) +err = GRUB_ERR_READ_ERROR; + } + else +err = grub_disk_read (disk, 0, 0, sizeof (header), &header); + if (err) { if (err == GRUB_ERR_OUT_OF_RANGE) @@ -304,12 +315,14 @@ configure_ciphers (grub_disk_t disk, const c
[PATCH 3/4] Cryptomount support plain dm-crypt
--- grub-core/disk/cryptodisk.c | 298 +++- grub-core/disk/luks.c | 205 +- include/grub/cryptodisk.h | 8 ++ 3 files changed, 309 insertions(+), 202 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index fbe7db9..c519c55 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -45,6 +45,11 @@ static const struct grub_arg_option options[] = {"key-size", 'K', 0, N_("Set key size (bits)"), 0, ARG_TYPE_INT}, {"keyfile-offset", 'O', 0, N_("Key file offset (bytes)"), 0, ARG_TYPE_INT}, {"keyfile-size", 'S', 0, N_("Key file data size (bytes)"), 0, ARG_TYPE_INT}, +{"plain", 'p', 0, N_("Plain (no LUKS header)"), 0, ARG_TYPE_NONE}, +{"cipher", 'c', 0, N_("Plain mode cipher"), 0, ARG_TYPE_STRING}, +{"digest", 'd', 0, N_("Plain mode passphrase digest (hash)"), 0, ARG_TYPE_STRING}, +{"offset", 'o', 0, N_("Plain mode data sector offset"), 0, ARG_TYPE_INT}, +{"size", 's', 0, N_("Size of raw device (sectors, defaults to whole device)"), 0, ARG_TYPE_INT}, {0, 0, 0, 0, 0, 0} }; @@ -928,6 +933,48 @@ grub_cryptodisk_scan_device (const char *name, return have_it && search_uuid ? 1 : 0; } +/* Hashes a passphrase into a key and stores it with cipher. */ +static gcry_err_code_t +set_passphrase (grub_cryptodisk_t dev, grub_size_t keysize, const char *passphrase) +{ + grub_uint8_t derived_hash[GRUB_CRYPTODISK_MAX_KEYLEN * 2], *dh = derived_hash; + char *p; + unsigned int round, i; + unsigned int len, size; + + /* Need no passphrase if there's no key */ + if (keysize == 0) +return GPG_ERR_INV_KEYLEN; + + /* Hack to support the "none" hash */ + if (dev->hash) +len = dev->hash->mdlen; + else +len = grub_strlen (passphrase); + + if (keysize > GRUB_CRYPTODISK_MAX_KEYLEN || len > GRUB_CRYPTODISK_MAX_KEYLEN) +return GPG_ERR_INV_KEYLEN; + + p = grub_malloc (grub_strlen (passphrase) + 2 + keysize / len); + if (!p) +return grub_errno; + + for (round = 0, size = keysize; size; round++, dh += len, size -= len) +{ + for (i = 0; i < round; i++) + p[i] = 'A'; + + grub_strcpy (p + i, passphrase); + + if (len > size) + len = size; + + grub_crypto_hash (dev->hash, dh, p, grub_strlen (p)); +} + + return grub_cryptodisk_setkey (dev, derived_hash, keysize); +} + static grub_err_t grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) { @@ -1033,7 +1080,64 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) return GRUB_ERR_NONE; } - err = grub_cryptodisk_scan_device_real (args[0], disk); + if (state[8].set) /* Plain mode */ +{ + char *cipher; + char *mode; + char *digest; + int offset, size, key_size; + + cipher = grub_strdup (state[9].set ? state[9].arg : GRUB_CRYPTODISK_PLAIN_CIPHER); + digest = grub_strdup (state[10].set ? state[10].arg : GRUB_CRYPTODISK_PLAIN_DIGEST); + offset = state[11].set ? grub_strtoul (state[11].arg, 0, 0) : 0; + size = state[12].set ? grub_strtoul (state[12].arg, 0, 0) : 0; + key_size = ( state[5].set ? grub_strtoul (state[5].arg, 0, 0) \ +: GRUB_CRYPTODISK_PLAIN_KEYSIZE ) / 8; + + /* no strtok, do it manually */ + mode = grub_strchr(cipher,'-'); + if (!mode) +return GRUB_ERR_BAD_ARGUMENT; + else +*mode++ = 0; + + grub_printf ("\nCipher='%s' mode='%s'\n", cipher, mode); + dev = grub_cryptodisk_create (disk, NULL, cipher, mode, digest); + + dev->offset = offset; + if (size) dev->total_length = size; + + if (key) + { + err = grub_cryptodisk_setkey (dev, key, key_size); + if (err) +return err; + } + else + { + char passphrase[GRUB_CRYPTODISK_MAX_PASSPHRASE] = ""; + + grub_printf_ (N_("Enter passphrase for %s: "), diskname); + if (!grub_password_get (passphrase, GRUB_CRYPTODISK_MAX_PASSPHRASE)) +return grub_error (GRUB_ERR_BAD_ARGUMENT, "Passphrase not supplied"); + + err = set_passphrase (dev, key_size, passphrase); + if (err) +{ + grub_crypto_cipher_close (dev->cipher); + return err; +} + } + + grub_cryptodisk_insert (dev, diskname, disk); + + grub_free (cipher); + grub_free (digest); + + err = GRUB_ERR_NONE; +} + else +err = grub_cryptodisk_scan_device_real (args[0], disk); grub_disk_close (disk); @@ -1164,13 +1268,203 @@ struct grub_procfs_entry luks_script = .get_contents = luks_script_get }; +grub_cryptodisk_t +grub_cryptodisk_create (grub_disk_t disk,
Re: [PATCH 3/4] Cryptomount support plain dm-crypt
A little explanation of what the patch does; most of the code in this patch already existed. I extracted the in-line code from "luks.c" that creates the crypto disk into a new cryptomount function called "grub_cryptodisk_create" that is then used by the luks module and is also avilable to the cryptomount module. I extracted the "set_passphrase" function from the "devmapper.c" committed (e7f405ab) in the "peter/devmapper" branch so that I could use it in cryptomount to hash a manually entered passphrase. I then wrote some additional options and a small block of code to implement plain mode using the above. signature.asc Description: OpenPGP digital signature ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [RFC PATCH 0/3] grub powerpc64 little-endian enablement
On 2015-06-15 14:15, Andrei Borzenkov wrote: В Thu, 28 Aug 2014 16:56:02 -0300 Paulo Flabiano Smorigo пишет: From: Paulo Flabiano Smorigo Hi, At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit. This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled. After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro. It can be devided in two parts: 1) Skip libgcc dependency just for ppc64el (patch 1 and 2); This is now default for all platforms 2) Check elf endianess and byteswap if necessary (patch 3); That's still pending. Yes, I'm aware of that. :) The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine. If thoses patches were accepted we will have an official solution. Nowadays, distros are taking diffrent approachs. Some of then are using the original solutions and others are using cross-compiler. Could you resend missing bits rebased to current head? Sure thing. I'll review it once more and send it to the ML later this week. -- Paulo Flabiano Smorigo IBM Linux Technology Center ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: Was there a Wiki on what we can do with GRUB2? And what happened to it?
Hello! No argument here. Currently the reason why I asked that question, isn't asking for a response because I'm not working on that problem - Gregg C Levine gregg.drw...@gmail.com "This signature fought the Time Wars, time and again." On Tue, Jun 16, 2015 at 3:41 AM, Andrei Borzenkov wrote: > On Tue, May 26, 2015 at 1:05 AM, Vladimir 'phcoder' Serbinenko > wrote: >> Wiki is gone because of lack of hosting. I still have last dump from it but >> at that point all relevant info is probably in the manual >> > > Should we remove reference to grub.enbug.org from README then? > Currently this domain does not exist at all. > >> Le 12 mai 2015 05:54, "Gregg Levine" a écrit : >>> >>> Hello! >>> I am revisiting an issue that surfaced on or about the beginning of >>> November of 2008. I found the relevant messages in my Google Mail >>> store and went over them, I also read the corresponding coreboot >>> messages from the same period. >>> >>> The responding individual then mentions that what I was interested in, >>> namely using Grub2 to bring up a payload of coreboot as an Elf file >>> was indeed described on a Wiki. It happens I recall studying the pages >>> then, but it seems the pages are gone now, although the Archive.org >>> site may remember them. But I'm asking here first. >>> - >>> Gregg C Levine gregg.drw...@gmail.com >>> "This signature fought the Time Wars, time and again." >>> >>> ___ >>> Grub-devel mailing list >>> Grub-devel@gnu.org >>> https://lists.gnu.org/mailman/listinfo/grub-devel >> >> >> ___ >> Grub-devel mailing list >> Grub-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/grub-devel >> > > ___ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [RFC PATCH 3/3] Suport for bi-endianess in elf file
On Thu, Aug 28, 2014 at 10:56 PM, Paulo Flabiano Smorigo wrote: > * grub-core/kern/elf.c: check and switch endianess with grub_{be,le}_to > cpu functions. > * grub-core/kern/elfXX.c: Likewise. > As a general comment - currently we need it for one platform only so let's wrap additional code in #ifdef __powerpc__ until any more users emerge, to avoid dead code on other platforms (especially size-critical like i386-pc). > Also-by: Tomohiro B Berry > --- > grub-core/kern/elf.c | 60 +++-- > grub-core/kern/elfXX.c | 73 > ++ > 2 files changed, 131 insertions(+), 2 deletions(-) > > diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c > index 5f99c43..de90811 100644 > --- a/grub-core/kern/elf.c > +++ b/grub-core/kern/elf.c > @@ -28,6 +28,11 @@ > > GRUB_MOD_LICENSE ("GPLv3+"); > > +void grub_elf32_check_endianess (grub_elf_t elf); > +void grub_elf64_check_endianess (grub_elf_t elf); > +grub_err_t grub_elf32_check_version (grub_elf_t elf); > +grub_err_t grub_elf64_check_version (grub_elf_t elf); > + > /* Check if EHDR is a valid ELF header. */ > static grub_err_t > grub_elf_check_header (grub_elf_t elf) > @@ -38,10 +43,22 @@ grub_elf_check_header (grub_elf_t elf) >|| e->e_ident[EI_MAG1] != ELFMAG1 >|| e->e_ident[EI_MAG2] != ELFMAG2 >|| e->e_ident[EI_MAG3] != ELFMAG3 > - || e->e_ident[EI_VERSION] != EV_CURRENT > - || e->e_version != EV_CURRENT) > + || e->e_ident[EI_VERSION] != EV_CURRENT) > return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF > magic")); > > + if (grub_elf_is_elf32 (elf)) > +{ > + grub_elf32_check_endianess (elf); > + grub_elf32_check_version (elf); > +} > + else if (grub_elf_is_elf64 (elf)) > +{ > + grub_elf64_check_endianess (elf); > + grub_elf64_check_version (elf); > +} This ignores any errors these functions may return. I would suggest #if defined(__powerpc__) if ((grub_elf_is_elf32 (elf)) grub_elf32_check_endianess (elf); ... > + else > +return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF > magic")); > + It probably should be "Uknown ELF class" here. #endif /* __powerpc__ */ if (e->e_version != EV_CURRENT) return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic")); >return GRUB_ERR_NONE; > } > > @@ -127,7 +144,20 @@ grub_elf_open (const char *name) > #define grub_elf_is_elfXX grub_elf_is_elf32 > #define grub_elfXX_load_phdrs grub_elf32_load_phdrs > #define ElfXX_Phdr Elf32_Phdr > +#define ElfXX_Ehdr Elf32_Ehdr > #define grub_uintXX_t grub_uint32_t > +#define grub_be_to_halfXX grub_be_to_cpu16 > +#define grub_be_to_wordXX grub_be_to_cpu32 > +#define grub_be_to_addrXX grub_be_to_cpu32 > +#define grub_be_to_offXX grub_be_to_cpu32 > +#define grub_be_to_XwordXX grub_be_to_wordXX Only addr and off are different between 32/64. Do we really need to define others? > +#define grub_le_to_halfXX grub_le_to_cpu16 > +#define grub_le_to_wordXX grub_le_to_cpu32 > +#define grub_le_to_addrXX grub_le_to_cpu32 > +#define grub_le_to_offXX grub_le_to_cpu32 > +#define grub_le_to_XwordXX grub_le_to_wordXX > +#define grub_elfXX_check_endianess grub_elf32_check_endianess > +#define grub_elfXX_check_version grub_elf32_check_version > > #include "elfXX.c" > > @@ -140,7 +170,20 @@ grub_elf_open (const char *name) > #undef grub_elf_is_elfXX > #undef grub_elfXX_load_phdrs > #undef ElfXX_Phdr > +#undef ElfXX_Ehdr > #undef grub_uintXX_t > +#undef grub_be_to_halfXX > +#undef grub_be_to_wordXX > +#undef grub_be_to_addrXX > +#undef grub_be_to_offXX > +#undef grub_be_to_XwordXX > +#undef grub_le_to_halfXX > +#undef grub_le_to_wordXX > +#undef grub_le_to_addrXX > +#undef grub_le_to_offXX > +#undef grub_le_to_XwordXX > +#undef grub_elfXX_check_endianess > +#undef grub_elfXX_check_version > > > /* 64-bit */ > @@ -153,6 +196,19 @@ grub_elf_open (const char *name) > #define grub_elf_is_elfXX grub_elf_is_elf64 > #define grub_elfXX_load_phdrs grub_elf64_load_phdrs > #define ElfXX_Phdr Elf64_Phdr > +#define ElfXX_Ehdr Elf64_Ehdr > #define grub_uintXX_t grub_uint64_t > +#define grub_be_to_halfXX grub_be_to_cpu16 > +#define grub_be_to_wordXX grub_be_to_cpu32 > +#define grub_be_to_addrXX grub_be_to_cpu64 > +#define grub_be_to_offXX grub_be_to_cpu64 > +#define grub_be_to_XwordXX grub_be_to_cpu64 > +#define grub_le_to_halfXX grub_le_to_cpu16 > +#define grub_le_to_wordXX grub_le_to_cpu32 > +#define grub_le_to_addrXX grub_le_to_cpu64 > +#define grub_le_to_offXX grub_le_to_cpu64 > +#define grub_le_to_XwordXX grub_le_to_cpu64 > +#define grub_elfXX_check_endianess grub_elf64_check_endianess > +#define grub_elfXX_check_version grub_elf64_check_version > > #include "elfXX.c" > diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c > index 1d09971..ecf9df6 100644 > --- a/grub-core/kern/elfXX.c > +++ b/grub-core/kern/elfXX.c > @@ -154,3 +154,76 @@ grub_elfXX_load (grub_elf_