From patchwork Sun Mar 8 08:08:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 206476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62DF2C18E5B for ; Sun, 8 Mar 2020 08:09:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CE462084E for ; Sun, 8 Mar 2020 08:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583654997; bh=+BIOo6Gvvso/C49TZvAFUtecF7m+6sMjMja0zZkaK8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1KITGx3RGhTlMUbpeYeBHKvuxU1TVn7kLW0mHf51rr4WqFVKWqyXR4S9xKPbly0NR ZI3HX8M/vxCTRjMXu3BFbLnCZyOUVRCd51PV7S7SQnliDMFB5AX71CutH0DqRwkfrq GEz2Dqjl9lf2OOrsSg6RQgnbT+hw7L1HJI7Nztuc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726604AbgCHIJx (ORCPT ); Sun, 8 Mar 2020 04:09:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:37392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbgCHIJx (ORCPT ); Sun, 8 Mar 2020 04:09:53 -0400 Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 873B5217F4; Sun, 8 Mar 2020 08:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583654992; bh=+BIOo6Gvvso/C49TZvAFUtecF7m+6sMjMja0zZkaK8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AEk6/p9h+5624RBvb/YhsAe7FYOammfe7cOdUQOe6Hi76WgrFuY2mSqst/3NfbbdN +vzwS+2E7Cbz24UOoWWKO0LBqebI9m6W5pPdihYucZwBZ8YxykTbNG3MQoj1mztgaC YLAOMfiUSjJL7E0DyKlEbDlvDfplZ+AydCSZH2J0= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Arvind Sankar , Christoph Hellwig , David Hildenbrand , Davidlohr Bueso , Guenter Roeck , Heinrich Schuchardt , Jonathan Corbet , Lukas Bulwahn , Masahiro Yamada , Nikolai Merinov , Tom Lendacky , Vladis Dronov Subject: [PATCH 13/28] x86/boot: Use unsigned comparison for addresses Date: Sun, 8 Mar 2020 09:08:44 +0100 Message-Id: <20200308080859.21568-14-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200308080859.21568-1-ardb@kernel.org> References: <20200308080859.21568-1-ardb@kernel.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Arvind Sankar The load address is compared with LOAD_PHYSICAL_ADDR using a signed comparison currently (using jge instruction). When loading a 64-bit kernel using the new efi32_pe_entry point added by commit 97aa276579b2 ("efi/x86: Add true mixed mode entry point into .compat section") using qemu with -m 3072, the firmware actually loads us above 2Gb, resulting in a very early crash. Use jae instruction to perform unsigned comparison instead, as physical addresses should be considered as unsigned. Signed-off-by: Arvind Sankar Link: https://lore.kernel.org/r/20200301230436.2246909-6-nivedita@alum.mit.edu Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/head_32.S | 2 +- arch/x86/boot/compressed/head_64.S | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S index 9ffc9454fd22..f250fc49cd61 100644 --- a/arch/x86/boot/compressed/head_32.S +++ b/arch/x86/boot/compressed/head_32.S @@ -105,7 +105,7 @@ SYM_FUNC_START(startup_32) notl %eax andl %eax, %ebx cmpl $LOAD_PHYSICAL_ADDR, %ebx - jge 1f + jae 1f #endif movl $LOAD_PHYSICAL_ADDR, %ebx 1: diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 08351d16ccc0..1199c4ef0c83 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -105,7 +105,7 @@ SYM_FUNC_START(startup_32) notl %eax andl %eax, %ebx cmpl $LOAD_PHYSICAL_ADDR, %ebx - jge 1f + jae 1f #endif movl $LOAD_PHYSICAL_ADDR, %ebx 1: @@ -305,7 +305,7 @@ SYM_CODE_START(startup_64) notq %rax andq %rax, %rbp cmpq $LOAD_PHYSICAL_ADDR, %rbp - jge 1f + jae 1f #endif movq $LOAD_PHYSICAL_ADDR, %rbp 1: