From patchwork Tue Sep 5 20:41:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 111748 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp3336702qge; Tue, 5 Sep 2017 13:41:45 -0700 (PDT) X-Received: by 10.200.12.68 with SMTP id l4mr537443qti.340.1504644105208; Tue, 05 Sep 2017 13:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504644105; cv=none; d=google.com; s=arc-20160816; b=EVO3tr7e+G9N6YosxrjD7MSDrluLL1P4BoifBjAcmcWIFPrd6aCH9Ef/AoWUfGLPg1 qQ6JWDKTB/nvjtkNIdQROgfWnEd/lGviZb4Yia85BLGRU1jNHT9z9TUTALAqrizcQhO9 MQfd+0b3I6pD3hmvfZbkLpPHyug2GQI8nS7caClXPf+kFObxG73z9ncUOgBTulX4/Vvj Vtjprqg300ebFjc8ud0lrTpr/td4WFIu18VNQrBoT1gxTnUahx+glu4c4jE/Oqe7So+v 3ixCkgvcq0n3SerIBJx6lkZ7R+dp6m+IBT0SaA/q4nWJvoLvi4zxOgcbshyn66ldoOwm 26bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:arc-authentication-results; bh=imzGPAbRCb8lhIfaZ0eYe6TQiN2c1Cefjou4m/J1wHc=; b=v3AIEqfu0Er54dc8Ug7LnL+XWQEGhKdKEENcvllBZAr5mit42MjRBDafRk4l3GYayg LXl3toxkxhdgbPo/mABpLmGXzZfUhduWHidSAKdo3zLXaakjMIZ1HNq/CTkWwBs+5fD1 e91083wxifZDd6LGyDdjUIVx7Ui6I8XblDRkpB1iCf584Q41WhQWYFRsQUr807a1MiaN lN8TuhVxbGTbZdSZlxhGTlBolkGmx4o9Kv7rvj3o1NNJi8CuUOU2255cGWY3+pVklY/0 S9eCiBTaJDsT/yEmsMXD304EwWWtDlQlMyIIBHE3v5m/uaXDQWmZCwqtymhiD9gtTtDl a9Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LjJ7TJiY; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l65si1234538qkf.163.2017.09.05.13.41.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Sep 2017 13:41:45 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LjJ7TJiY; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKfH-00074p-0R for patch@linaro.org; Tue, 05 Sep 2017 16:41:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKez-000739-Fr for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpKeu-0003Ek-9c for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:25 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:35814) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpKeu-0003EH-04 for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:20 -0400 Received: by mail-wm0-x229.google.com with SMTP id f199so3390795wme.0 for ; Tue, 05 Sep 2017 13:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RB6JLrA+zBcwvK8JAbiBK4qIpXq/gJ6MGH4zst2m8i0=; b=LjJ7TJiY9TXdfhVtFCuJrLYkREmVaheyKFFiah7NPaRF3MLshLDtsG529cl6I7RVbD tWw2PXvYcwyUWS1gvYTn8/gK8lNVXLVWxaHJrHpbBFKlvvPghnW5HG1zBBryM9+T1itX CgjUxhcJFJigIPCIgqdP5i8vX0LGlRVh4s9C4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RB6JLrA+zBcwvK8JAbiBK4qIpXq/gJ6MGH4zst2m8i0=; b=masK8PeGKneyfiRKldkQ1tHFB6k4WLIqo/QynJUIXloKb/h7+olyQUdGxBGvpJbHGJ z4fQSvJ+u4dLfy71YPmyaZJw0KewwE/JWBwCGKTZfivawaqFIFze6HOjrQlRqNTBcji8 AWqP9SNDIEN42ayI8fqkJgI2weSUxIcWYb3RYGcdlMaZMrI1KwX2r+rnKUld4Cuw9rQv I19kobuZem6Wc/DJC/fJ9a4w+ep07aKpgtSC5P0kNPW4ZrUnkG/BL82buWtkkNS6YDN7 vXsz2mJ6wVXD0rLadAjO2j2/Qo9U8POMohrT55SvZXHZ+Vh624ivYd6CX0Rl7LhcN9f2 Zr0A== X-Gm-Message-State: AHPjjUjO6aI/Xa/dRp+8LUtqDGGiZQEZFvYMIac/AV4TfAGQdPgtjYhf dR+22DVQBw0Eoj3D4537wQ== X-Google-Smtp-Source: ADKCNb6P/09e1I2pnShSHufyecbhlXy1l6VRoOMckvrcKAro8UDsy+ZaVMydGLYPTA2wrDl0O4IBEw== X-Received: by 10.28.150.69 with SMTP id y66mr132939wmd.8.1504644078531; Tue, 05 Sep 2017 13:41:18 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id k52sm2291077wrf.62.2017.09.05.13.41.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2017 13:41:17 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 1/4] i386/x86_64: make linux header definitions arch-specific Date: Tue, 5 Sep 2017 21:41:11 +0100 Message-Id: <20170905204114.9462-2-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170905204114.9462-1-leif.lindholm@linaro.org> References: <20170905204114.9462-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::229 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Vladimir 'phcoder' Serbinenko , Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Rename GRUB_LINUX_MAGIC_SIGNATURE -> GRUB_LINUX_I386_MAGIC_SIGNATURE and linux_kernel_header -> linux_i386_kernel_header. Also change the include guard on grub/i386/linux.h to prevent clashes when including multiple linux.h headers (like in commands/file.c). Signed-off-by: Leif Lindholm --- OK, so one question here: in order to follow existing style, I have kept to the existing linux_ format. Is that the appropriate prefix, or should this be grub_linux_ like I originally used in the ARM series? Regardless, I intend to align the ARM patches to whatever format ends up being used for this patch. grub-core/commands/file.c | 6 +++--- grub-core/loader/i386/linux.c | 4 ++-- grub-core/loader/i386/pc/linux.c | 12 ++++++------ grub-core/loader/i386/xen_file.c | 4 ++-- include/grub/i386/linux.h | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 12fba99e0..63c84499b 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -497,7 +497,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) case IS_X86_LINUX32: case IS_X86_LINUX: { - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) break; if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) @@ -508,7 +508,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) /* FIXME: some really old kernels (< 1.3.73) will fail this. */ if (lh.header != - grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) break; @@ -521,7 +521,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and still not support 32-bit boot. */ if (lh.header != - grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0203) break; diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 083f9417c..44301e126 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -678,7 +678,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_uint8_t setup_sects; grub_size_t real_size, prot_size, prot_file_size; grub_ssize_t len; @@ -721,7 +721,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and still not support 32-bit boot. */ - if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0203) { grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot" diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index a293b17aa..b69cb7a3a 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -121,7 +121,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_uint8_t setup_sects; grub_size_t real_size; grub_ssize_t len; @@ -169,7 +169,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), maximal_cmdline_size = 256; - if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh.version) >= 0x0200) { grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL); @@ -322,7 +322,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) /* Clear the heap space. */ grub_memset (grub_linux_real_chunk @@ -387,7 +387,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_size_t size = 0; grub_addr_t addr_max, addr_min; - struct linux_kernel_header *lh; + struct linux_i386_kernel_header *lh; grub_uint8_t *initrd_chunk; grub_addr_t initrd_addr; grub_err_t err; @@ -405,9 +405,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } - lh = (struct linux_kernel_header *) grub_linux_real_chunk; + lh = (struct linux_i386_kernel_header *) grub_linux_real_chunk; - if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh->version) >= 0x0200)) { grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd"); diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index 99fad4cad..77a93e7b2 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -26,7 +26,7 @@ grub_elf_t grub_xen_file (grub_file_t file) { grub_elf_t elf; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_file_t off_file; grub_uint32_t payload_offset, payload_length; grub_uint8_t magic[6]; @@ -43,7 +43,7 @@ grub_xen_file (grub_file_t file) goto fail; if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55) - || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0208) { grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot"); diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index da0ca3b83..854e3e687 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -16,10 +16,10 @@ * along with GRUB. If not, see . */ -#ifndef GRUB_LINUX_MACHINE_HEADER -#define GRUB_LINUX_MACHINE_HEADER 1 +#ifndef GRUB_LINUX_I386_HEADER +#define GRUB_LINUX_I386_HEADER 1 -#define GRUB_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ +#define GRUB_LINUX_I386_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ #define GRUB_LINUX_DEFAULT_SETUP_SECTS 4 #define GRUB_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF #define GRUB_LINUX_MAX_SETUP_SECTS 64 @@ -85,7 +85,7 @@ enum }; /* For the Linux/i386 boot protocol version 2.10. */ -struct linux_kernel_header +struct linux_i386_kernel_header { grub_uint8_t code1[0x0020]; grub_uint16_t cl_magic; /* Magic number 0xA33F */ @@ -312,4 +312,4 @@ struct linux_kernel_params } GRUB_PACKED; #endif /* ! ASM_FILE */ -#endif /* ! GRUB_LINUX_MACHINE_HEADER */ +#endif /* ! GRUB_LINUX_I386_HEADER */