Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1659515ybf; Sun, 1 Mar 2020 15:06:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwwBXY8fGP8lKPcHQEooEyIbm1IqJST5VHUIsiVKMBzGbapByeXxuAWRi6gntsk7AdbFsqN X-Received: by 2002:aca:2207:: with SMTP id b7mr9961941oic.109.1583103972439; Sun, 01 Mar 2020 15:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583103972; cv=none; d=google.com; s=arc-20160816; b=XVhRS4KmS8RQ+AwqnnRA4a5lY/OD0AE84DkBS6RmGAu1Wn4+riGezTEaB/9pWfJWko ZT/QzTAIERyGHzF5UFXMqfSFvbFd/+h4dYNKb7qjARElOgCBS8135nbuhtx1flzAhmxP 10JgJGpgYq8shV+1UINunobKd9wrK0MeNJziDxwM36Odp2NLPkkMsM3toNa87InLATHb EjvdnDd3JV3DbD4oIxi5LuwMGZsJoi5ulGhodGLauv30J8IQE0YnGagMWVmBpPF+n92c FqmgkaqLiOx8wJ6DywLRN0wxFcfPA9evakXW6QhO95jOeZAY02prm2+1VhSd981yl6Px jZhg== 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=dB9kg8CzQGhH36dP05NVV6Pj3Y0sXP31eOWh9dPff/Y=; b=vJiHP+PyFDiPtUOdN7SZZFAL2JQR3KXwpCuz90ey3jK1kxs/hBlsY/ri7Ma40qPQ/Y ZqYm14P5nM4+Yiq4e2Tv4Y9Ad2+Xa6klWvtS5i9WPoaPlQXgqX7+FzRsuRYoL0ZbGUj0 DAjV6YS2i3xphfiP6fBsAJZOwkPvzY+x1MXs6/H2FIrnCZPRFrWhqKu1B5VeDCsZWlAf ufORwOrwSPlWBq0RMe3GH+NHG9s+oHdkJSNuLqF/opGr69HDuTcNSWdTPoOm2ogy1EiW d2x0wo65SHjXJVdQmJYzZ5bZN1cGgFE5dHBU86nzCY/Q3nnGWw+z+d6284B9llheLggW NyTA== 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 l6si5451299otk.134.2020.03.01.15.06.00; Sun, 01 Mar 2020 15:06:12 -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 S1727005AbgCAXFw (ORCPT + 99 others); Sun, 1 Mar 2020 18:05:52 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:44234 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbgCAXFm (ORCPT ); Sun, 1 Mar 2020 18:05:42 -0500 Received: by mail-qt1-f194.google.com with SMTP id j23so6222563qtr.11; Sun, 01 Mar 2020 15:05: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=dB9kg8CzQGhH36dP05NVV6Pj3Y0sXP31eOWh9dPff/Y=; b=GBf4jeZksNie4ik+NNAc6zq+F3z/8da5nRNB6ZECz6Udsf+uzW8+C4/PZJIYc33hG+ IyxgFCiiQ+OSwkvuDZXNV86vKwg/O8imdv5p4SZAi+CIFZVljy9iPTyXP5wG7bjlolOf 9zgKa24ZbE/B6cvP7mXub6sqpaBSxVLtFA32Ta8J19I/ZGeBqB8cn6fig5k97NLtgnWc PNNpMOZYayHEh4d0rG3on6emKqKsLSWHv6k0haJkuk9Dy0S5ziuRu2+BHn+xOED8bAre eRrneHUR6Ymyu0u9uNlntPLQpZF7J2ciTxRUREx2Ne1JpRi7H0VaQYW93i9xcwIJGHMN CMig== X-Gm-Message-State: APjAAAWCFLz3QYHkwJm4eyenzEFGx28Kd2DsC/yN4GazmPDDw5pwTdhZ NiHBq13+t3hNGVc5G3e3G5T246e9PcI= X-Received: by 2002:ac8:377a:: with SMTP id p55mr13203218qtb.87.1583103940680; Sun, 01 Mar 2020 15:05:40 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id x131sm8923906qka.1.2020.03.01.15.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 15:05: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 3/5] efi/x86: Add kernel preferred address to PE header Date: Sun, 1 Mar 2020 18:05:35 -0500 Message-Id: <20200301230537.2247550-4-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200301230537.2247550-1-nivedita@alum.mit.edu> References: <20200301230537.2247550-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 Store the kernel's link address as ImageBase in the PE header. Note that the PE specification requires the ImageBase to be 64k aligned. The preferred address should almost always satisfy that, except for 32-bit kernel if the configuration has been customized. Signed-off-by: Arvind Sankar --- arch/x86/boot/header.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 4ee25e28996f..0d8d2cb28fd9 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -138,10 +138,12 @@ optional_header: #endif extra_header_fields: + # PE specification requires ImageBase to be 64k-aligned + .set ImageBase, (LOAD_PHYSICAL_ADDR+0xffff) & ~0xffff #ifdef CONFIG_X86_32 - .long 0 # ImageBase + .long ImageBase # ImageBase #else - .quad 0 # ImageBase + .quad ImageBase # ImageBase #endif .long 0x20 # SectionAlignment .long 0x20 # FileAlignment -- 2.24.1