Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3829394ybf; Tue, 3 Mar 2020 13:42:32 -0800 (PST) X-Google-Smtp-Source: ADFU+vuzrP/2ndL1guB9W/UHKmCwj7Nx0wT6rpeRKftSNwdB4TisYnnvWhPuSPZVD2I59JosZ8Pt X-Received: by 2002:aca:c78e:: with SMTP id x136mr437699oif.116.1583271752027; Tue, 03 Mar 2020 13:42:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583271752; cv=none; d=google.com; s=arc-20160816; b=ZRVjCYuaHcE/0u0A+KEP9yFVJPseoNOLZFDhXGxr1DuKwUs025bA3FbzvzKKxB5rXx ZnlPqcDQaXD/eN0zy6wMZqH+rC9x4HWgs/rkhG80Gg0n4FpiEzmRJAwYDpcTw9/WVHuE UZBBy88xzZhkOgCqfND0bubgxiFpUUjn4IyXt1SSJgEn7pjjNXszP1nYHBCFZQ4z36f3 53m/Xt8r1l4aHuX6PFt/fXXySOFpYBVU7Ewtcw+bV66RJky/96We+EYtIpP4d6I2gScZ ueHlNnKzaZEEPaFqOTO4XfAIR9M2ejFyOxAonksvsUk6Bm67lh2t2cNef7HABEnefyQk XtlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1rfgDrwISvvkUj9jSyvyAijwv2a0V/cNiQptqCgug+Q=; b=WwWc3myq7LmewVnNeB1ZkFhoYElKgvBI4TPtSwosFAmp0jXPZBEZPitXlutY68hzil DnZUDS2h78VWQKghdr6hVQ1aRz1W8L0xyhk7shZtb7G9S8Yhr5Vrcr00/UGheDdu1dgE zv491YzyUcmMwi/PGPUlAe4pHYyzIOOylxW09/VYUhaHQW065RlhgfuAaJsy8IkUQXwo BbmZp+m+0M0Brrdh4napFUt+OV9mMUm7dRzLPKDTaydQ/FIC+LBvgbCRPnhR45ZXPWfL HDIMrOxTZFzYfoLS3EGhrmsCxh0z6Kov1Z1dC9OTRL0EREJs4qBY1deW5MegXl12J0Mx IIsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nzZjsN7o; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si35418oic.7.2020.03.03.13.42.20; Tue, 03 Mar 2020 13:42:32 -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; dkim=pass header.i=@kernel.org header.s=default header.b=nzZjsN7o; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730666AbgCCTLA (ORCPT + 99 others); Tue, 3 Mar 2020 14:11:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:47024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726899AbgCCTLA (ORCPT ); Tue, 3 Mar 2020 14:11:00 -0500 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 3B9F320CC7 for ; Tue, 3 Mar 2020 19:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583262659; bh=4NVTBacBsWlMTFEhPSv4sPsd4s0glorw7tyt6PZlIyU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nzZjsN7os5wMg6j+xQykpxFbL6DqCQ0AU7uFBA4+ZBZNqdvUKdBzmozDpk1/9W6Xb 5SyLhr8eQKWqQzLt/X3aWhZ0KPsQAsCgtwosBStNAPLjX29LPC2YGcvcM92b7t/hVC r8voHZh5jZ7jGt1CeZkgWnJNp4YkwkMQvFRsb170= Received: by mail-wr1-f45.google.com with SMTP id j16so5868166wrt.3 for ; Tue, 03 Mar 2020 11:10:59 -0800 (PST) X-Gm-Message-State: ANhLgQ3Dz87gbaeaYLsSa0s4zBMR14tMv0BM0fRulk0v6nOmZnpSSzQO PRWplGt4WImPUb64GY/jtbbCZ1bGqbmxn9lhC8rvtA== X-Received: by 2002:adf:e742:: with SMTP id c2mr6731528wrn.262.1583262657609; Tue, 03 Mar 2020 11:10:57 -0800 (PST) MIME-Version: 1.0 References: <20200301230537.2247550-1-nivedita@alum.mit.edu> <20200301230537.2247550-2-nivedita@alum.mit.edu> In-Reply-To: <20200301230537.2247550-2-nivedita@alum.mit.edu> From: Ard Biesheuvel Date: Tue, 3 Mar 2020 20:10:46 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/5] x86/boot/compressed/32: Save the output address instead of recalculating it To: Arvind Sankar Cc: linux-efi , "the arch/x86 maintainers" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2 Mar 2020 at 00:05, Arvind Sankar wrote: > > In preparation for being able to decompress starting at a different > address than startup_32, save the calculated output address instead of > recalculating it later. > Could you expand this a bit? Are you talking about *running* the decompressor code at another offset? Or about the space it uses. I think I know but I'd like to be sure :-) > We now keep track of three addresses: > %edx: startup_32 as we were loaded by bootloader > %ebx: new location of compressed kernel > %ebp: start of decompression buffer > > Signed-off-by: Arvind Sankar > --- > arch/x86/boot/compressed/head_32.S | 25 ++++++++++++------------- > 1 file changed, 12 insertions(+), 13 deletions(-) > > diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S > index 46bbe7ab4adf..894182500606 100644 > --- a/arch/x86/boot/compressed/head_32.S > +++ b/arch/x86/boot/compressed/head_32.S > @@ -75,11 +75,11 @@ SYM_FUNC_START(startup_32) > */ > leal (BP_scratch+4)(%esi), %esp > call 1f > -1: popl %ebp > - subl $1b, %ebp > +1: popl %edx > + subl $1b, %edx > > /* Load new GDT */ > - leal gdt(%ebp), %eax > + leal gdt(%edx), %eax > movl %eax, 2(%eax) > lgdt (%eax) > > @@ -92,13 +92,14 @@ SYM_FUNC_START(startup_32) > movl %eax, %ss > > /* > - * %ebp contains the address we are loaded at by the boot loader and %ebx > + * %edx contains the address we are loaded at by the boot loader and %ebx > * contains the address where we should move the kernel image temporarily > - * for safe in-place decompression. > + * for safe in-place decompression. %ebp contains the address that the kernel > + * will be decompressed to. > */ > > #ifdef CONFIG_RELOCATABLE > - movl %ebp, %ebx > + movl %edx, %ebx > movl BP_kernel_alignment(%esi), %eax > decl %eax > addl %eax, %ebx > @@ -110,10 +111,10 @@ SYM_FUNC_START(startup_32) > movl $LOAD_PHYSICAL_ADDR, %ebx > 1: > > + movl %ebx, %ebp // Save the output address for later > /* Target address to relocate to for decompression */ > - movl BP_init_size(%esi), %eax > - subl $_end, %eax > - addl %eax, %ebx > + addl BP_init_size(%esi), %ebx > + subl $_end, %ebx > > /* Set up the stack */ > leal boot_stack_end(%ebx), %esp > @@ -127,7 +128,7 @@ SYM_FUNC_START(startup_32) > * where decompression in place becomes safe. > */ > pushl %esi > - leal (_bss-4)(%ebp), %esi > + leal (_bss-4)(%edx), %esi > leal (_bss-4)(%ebx), %edi > movl $(_bss - startup_32), %ecx > shrl $2, %ecx > @@ -196,9 +197,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) > /* push arguments for extract_kernel: */ > pushl $z_output_len /* decompressed length, end of relocs */ > > - leal _end(%ebx), %eax > - subl BP_init_size(%esi), %eax > - pushl %eax /* output address */ > + pushl %ebp /* output address */ > > pushl $z_input_len /* input_len */ > leal input_data(%ebx), %eax > -- > 2.24.1 >