From patchwork Mon Jun 25 17:01:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 139871 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4237423lji; Mon, 25 Jun 2018 10:15:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJC8H/Z5Zd9g2vryA2ww3rnoYF9MIIMN8p2iK5V5M19EGCkG7nThWwR7PcUw/4lPZCrHkTE X-Received: by 2002:a37:82c7:: with SMTP id e190-v6mr11080085qkd.313.1529946939280; Mon, 25 Jun 2018 10:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529946939; cv=none; d=google.com; s=arc-20160816; b=byxuTzOShi7amsyBh75DONF5HdOL5lMmBE3cA6cA5Q7MMQnqnMzpjF8/w+mCBktAmS PNk4g4oVGHF/U8l/1qhsr+/7o/ZlEUwrQNGvNiz3ZdrUwq+cQUhcoRkcJArkaoCDqc8t NxxGXvoN8oXBPKIyuHdUNzYW8Nw8P/iJEhxj7NqOxX0oWkYduCzz/r+1yD4cMkb1qegh iGw122lUaAatQERJ+OjitFEjI+ObDt3WYqqV0sChkpIYn1D8egCGW0BZat0r/Oj5pyji Sao0CHE2IOzDLWuSgQzIqr5nk3pyLDqC2v6gd7RMw72uIcfErqsdjt6OXHvlxcnFgR0B oKyQ== 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=/zOsVJueT8TqpBuxlKSCYPhqk/WniLUjErmYAZmyOuY=; b=PtuWR3DCBVXTBpmYFf0XzpJvLJ44kHS6wvyB4j2tjCMSgRgswFdMfperG6Cym7AoBo G2IuGTx2at17D6nszl0B1iiMtkfAxYYkAG3d+9+M/pmYRS0YUT+wJwY4VFq3WW5ijzJJ WvIrv+8czw3lrC1ez7qgaFvJ7GLBqygeos8w/SpNely7ODfjJ7vyPbp+7M9M27DSi2Ib otYFWJMkjP2kq0jvR0skJuCuD8ku899qeWmLt73c4QFYeMKCQ9J8m34HSVRgVRIb6I5t 3nWnemAE+4W10jGW/Lt3LB0gTfn0rLMo4olW84bNYIdVbq0MN8ODClJW0DTBmSyR82uF 0lvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QdI5LoEV; 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 y3-v6si1100095qkc.401.2018.06.25.10.15.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 25 Jun 2018 10:15:39 -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=QdI5LoEV; 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]:48428 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXV5W-00040S-Fs for patch@linaro.org; Mon, 25 Jun 2018 13:15:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUrw-0002nL-RZ for grub-devel@gnu.org; Mon, 25 Jun 2018 13:01:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXUru-00009q-W9 for grub-devel@gnu.org; Mon, 25 Jun 2018 13:01:36 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:41978) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXUru-00009Q-Ok for grub-devel@gnu.org; Mon, 25 Jun 2018 13:01:34 -0400 Received: by mail-wr0-x22d.google.com with SMTP id h10-v6so14404035wrq.8 for ; Mon, 25 Jun 2018 10:01:34 -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=mkotTZ4KCtIRGED59CqXREq9kOxkR2zKzSgPtFOo+E4=; b=QdI5LoEVZUOH/qb14ErUZ+nApLrsJsaElv8j1j6QXJjXhFkUH6DccOkTZW31V9vVmA Lpb2hsUYm+MBP6yt2b9Xx1OJAsMRYXeuPCuep4ab61GZWsu4nsT2t9VZOI/mm2Q6oK26 GuNhlsoQFPKDwDMv+HIh3U081cTNa4IJQKIsg= 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=mkotTZ4KCtIRGED59CqXREq9kOxkR2zKzSgPtFOo+E4=; b=BgJwLsWxoM82giFMUPscOuGXcpOpNkXchXT6MeX8biSXjYVmv7JtUg+K+W9G1ZKk0z pjAm/TSSFs40j7GN+PYjgrTt+X1y0PUjeACg75ZKR6LG4l+fppjfJkrZldrEE/nnC3SE 4NOsDm44oi0r8lXyntq7wMcIlmYy5EtQBydyQQPWse44XdoMaEwqievMbEeQqXbyctAv i4930TmSb/SyCCZV7N4QKHbCEvtLOFr/YjOGDlmTHgRiwFseQSpL0hlNKvcpQVvt0m3j u6KRwrZXKi2sOjsATWeZ+QO6c8UWD2ucsewKzzqoySD8cSHIc/emOZFToK0E4i9nk6Wy NdBw== X-Gm-Message-State: APt69E2Ld1weGLANSYWnUzyWgzi8+ePyzXXSRjL8aishuF6Wj0fB0i2V q02uniSEohuPZQ+vdYOsnvMPrjcrdDU= X-Received: by 2002:adf:af27:: with SMTP id z36-v6mr2319288wrc.59.1529946093272; Mon, 25 Jun 2018 10:01:33 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id m58-v6sm23881459wrf.61.2018.06.25.10.01.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 10:01:32 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 1/2] commands/file: use definitions from arm/linux.h Date: Mon, 25 Jun 2018 18:01:28 +0100 Message-Id: <20180625170129.23106-2-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180625170129.23106-1-leif.lindholm@linaro.org> References: <20180625170129.23106-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:c0c::22d 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: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Clean up code for matching IS_ARM slightly by making use of struct linux_arm_kernel_header and GRUB_LINUX_ARM_MAGIC_SIGNATURE. Signed-off-by: Leif Lindholm --- grub-core/commands/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 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 63c84499b..b0fb524b3 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -383,21 +384,18 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) } case IS_ARM_LINUX: { - grub_uint32_t sig, sig_pi; - if (grub_file_read (file, &sig_pi, 4) != 4) + struct linux_arm_kernel_header lh; + if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) break; - /* Raspberry pi. */ - if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006)) + /* Short forward branch in A32 state (for Raspberry pi kernels). */ + if (lh.code0 == grub_cpu_to_le32_compile_time (0xea000006)) { ret = 1; break; } - if (grub_file_seek (file, 0x24) == (grub_size_t) -1) - break; - if (grub_file_read (file, &sig, 4) != 4) - break; - if (sig == grub_cpu_to_le32_compile_time (0x016f2818)) + if (lh.magic == + grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM_MAGIC_SIGNATURE)) { ret = 1; break;