Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1658642ybf; Sun, 1 Mar 2020 15:05:06 -0800 (PST) X-Google-Smtp-Source: APXvYqziUHV3R4LZdR4v5+bUeCNR3p0Av3X76KHvIkODrXf1tjLfx06sjomzP5pLbHEZLLqaLRQU X-Received: by 2002:aca:f055:: with SMTP id o82mr7063465oih.27.1583103906165; Sun, 01 Mar 2020 15:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583103906; cv=none; d=google.com; s=arc-20160816; b=annKQ7M1JQdpzufj/eCkllnA9L05pmIFxautViLdpYVAWEaCIL2O+qThPnHncl82Zg t8Mvru6T+1+SUbPAlBaIUsSuaVY008ywGBlwVFEIraeK4PleILRsB+8BzvBefNW4frcI bJkJZIEuWrTLrRGFIoMC2nzrIU11N3a36Jxm5S+reI/8zRMLsHld4o1/JZ2lzQieqOdv fsnxkkI5OOnnhDrqlTGO/ZUYt+xWf1tI4hUOABmr1VBGudDCE1oG7fp10YYVVAF9xwTH UkWZqEPodBfomV688RVTShXiWOlwUkC7F04quZ5RJsBcGZ8B/MUN9IMn8HXjinFInNtg BRDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2HzQt//Adq5EryedFfwKQ2AkRXxzw5ZnWMqIrRLIAO8=; b=I0JuUqdjukD/9jQi1KuDe0sX16Bd9SajtTJoolFbFQB8D2DEZeVH2LCcDjBFUFQgjy 3hcSgTQD/gNWbZTh4bGERkJzC33vKQOorj+gKfKwcG0GCToNN2EgAuKawNo/neQGdvPs lTeUSQFdBrP6xRxoumbEtzgg7IsyRKsWZHm/Z33tiS1ASHm3znLs8XuUkIoe3bmsgTMl RHqzPDeo/Osre7LmyV6v+J24RvOp1ckTqxngxSNmjmFaiEsZdK+yPGclXO7KTIJ658bF HRirvX/IMZKzNoAhqp7ekC2WDCExkTvu/zJTXFL4VBCDRIM1EGhJ2d8VLBHGSDas1RXn Vzpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26si5224372otr.159.2020.03.01.15.04.53; Sun, 01 Mar 2020 15:05:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726872AbgCAXEn (ORCPT + 99 others); Sun, 1 Mar 2020 18:04:43 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:42060 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbgCAXEm (ORCPT ); Sun, 1 Mar 2020 18:04:42 -0500 Received: by mail-qt1-f194.google.com with SMTP id r6so1641899qtt.9; Sun, 01 Mar 2020 15:04:41 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=2HzQt//Adq5EryedFfwKQ2AkRXxzw5ZnWMqIrRLIAO8=; b=NMrKX9aRe8u0AnkhkUzIWQoFCZWmGLo97GpM4uByezeE3AIfaaU4vfntW1IVMrmQxh OKaIy1eh6883jFUxvNNEu3+RUg8vXAFZuX6FYoSC0nSDeTa2zv3PH1ylUiK9arfQMrxS CLaaPR+rJDT95abFnwEGmU81wDgbpSLLyavQOnyBZTb04DK8FKYLL22R4fPDJbmK5Apu m5YqmE/91uiPTNcxNDJywHX/npCJEK0Trd1rVCWLmyKGffRmkcCSiG5EoWYQaHpeCh7O k/deTTje2XJU27+QZVbqazT91r8JLMFRVoll7F8Gtiq9XqPGkjkyQ/0zccHQIJtmv3lP vjPQ== X-Gm-Message-State: APjAAAX+Jo1yKv1PQnYQy0lRtt1ZB3nvxsyqNvPlrVcRO+xQ3a//h06q tFSRVx7jflu51uY8a2UgwleyW39SFRQ= X-Received: by 2002:ac8:b43:: with SMTP id m3mr13261685qti.191.1583103881183; Sun, 01 Mar 2020 15:04:41 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id n138sm9065082qkn.33.2020.03.01.15.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 15:04:40 -0800 (PST) From: Arvind Sankar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] x86/boot: Use unsigned comparison for addresses Date: Sun, 1 Mar 2020 18:04:36 -0500 Message-Id: <20200301230436.2246909-6-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200301230436.2246909-1-nivedita@alum.mit.edu> References: <20200301230436.2246909-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 e013bdc1237b..46bbe7ab4adf 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 6a4ff919008c..5d8338a693ce 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: -- 2.24.1