Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1237657ybf; Thu, 27 Feb 2020 07:17:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxcseitcu7h3S4HcLyOloggk/8tPH5/3N1PQ6oSR1HrJTdoDpSbfjNFYp6pbEwha2gMS39R X-Received: by 2002:a05:6830:1e14:: with SMTP id s20mr128452otr.322.1582816638157; Thu, 27 Feb 2020 07:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582816638; cv=none; d=google.com; s=arc-20160816; b=AkwX1jgl0g+9YpHR/hqQe6X/FRV6zgt3jIJpSjSI8mgA6eUFXidSZmFzQScLnuZ8Uc N/9gHarbbnpn2GYtcWMju5iRakH9ax2TzH6Le4PLg0XdOZBsMiUzsnmtYdKVq2IlkF5k TbcY7a0rDJXppXEEZG+/zAjyQ15Fd7dmhrk7RX/xQR8n2M9MKucs2jC2AYqT+NN/aRYr 0HR7D7YqCO4Zuq9GnNtXRseEwEQP+1+9MJxDFFYd2sAdQLGNVM1yqPVrnBmRcmF34rzH wYo43mqwB8MDo4AgMoZBXIrlMsFrcvbhLur4r7PbnWAdfN96iGhAyfwrwyPdD853dFBv H5+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=WlXFvdOo+6yWEzwT1XC3KPZhgv50NpBAuaNpJg/kpbM=; b=vG2OjeENKD0M23wDpkpMLc3LL+oejVjKlWTjjevQjaW3GIbEVPDcYrD9T+HeO+Q9TA Spo1kqA1tPRRLBI/fgWQ/suSKUN7Vi2B8jEXPQYaYXYLIwjPtBbDsTYbrtyNbspklK4v Tv54kdvjOXSJV0EAg9mF0O6IOxSTng3NyeyE89TzaUB7BIGDFkcNWKK1ReDpdmMx6HYr 6NEYqBhDlbuK7+xmC4itZsFjvTqy6nwhY5KTomx8M5SnJflsAFMXNjMp49VVVoriapIL WzQ1BJRTL4wyAfun7WW3fQZwOJmuOJA2p6FUG4V3s0KXHi1Bos0IK3xJTi65UmIYq9Ol 1sUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VpCvudHL; 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 u13si1857233otg.56.2020.02.27.07.17.05; Thu, 27 Feb 2020 07:17:18 -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=fail header.i=@gmail.com header.s=20161025 header.b=VpCvudHL; 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 S1729652AbgB0PQt (ORCPT + 99 others); Thu, 27 Feb 2020 10:16:49 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:43388 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729174AbgB0PQt (ORCPT ); Thu, 27 Feb 2020 10:16:49 -0500 Received: by mail-qk1-f196.google.com with SMTP id q18so3425977qki.10; Thu, 27 Feb 2020 07:16:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WlXFvdOo+6yWEzwT1XC3KPZhgv50NpBAuaNpJg/kpbM=; b=VpCvudHLe5sWCh9mziPxV5NeC851zU5dJsWYAZEIhc3JENeYiezxfqhDKx094w2Wer 5V3gG3tQJ58w/mXV66o8VptoCjEG0hj0dH0fc8j+XhGsx2V86L24P2wttxmgmX+WBtXa MUQ02A4MJM6IrmdsY9ME3yj/YNAOAj3PDMKXWTMEqpw8sy+KZszp+BoCokoKze/piumn Cz3XAqs2/svBXcZyQmDrhv1LFvBpkvFU75j1JhtwFRQVfYIPPtLo3Q3J1gDhwI44Gdk+ DAgzv3soAm0+koay1uVZoyWn9fEwLHlWvmyE1VanYLACi5AJrvoHIEDnEQ6JkuhQQ4Yl bGpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=WlXFvdOo+6yWEzwT1XC3KPZhgv50NpBAuaNpJg/kpbM=; b=YmDgcqvKfQ+aWCIsRdQ68CAcHtA45HnMasD9el7NVD4XsFXconPJPeKygozXBjEvEW ZnvMMv8xwl0ctI/H7irsmtgX/ud4v38XqxUT3GKfz1rlDOoas2Abrw+Orxk6jJKABNay JSQfynZCfqgCFQ6ojXRt2NPBwg6snQJQB5AVz9AJhSZMX+KKM3kx8RYJ1U0UEPmABcE1 R8Z398DqQ0rocf80ZzdVFsGFuk8Vl+WAgP/izMZAWNLmbVYq8ymkqpRNju1eFPy1hBB7 2nL16WjTi0Wj9nEtxlAsy3HF8UWFk8+CmAkUSGKubX9HYtddMzNaTplX4gHAeKjz/mMY E29Q== X-Gm-Message-State: APjAAAUh/p7HcGUglicelL9VtwVCkv4k1vypPVQYsON/KxZARyMzPGL8 X0gTrU2EEOUigPUAHN8W3vo= X-Received: by 2002:a37:f502:: with SMTP id l2mr5484725qkk.76.1582816606616; Thu, 27 Feb 2020 07:16:46 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id m6sm3291361qki.24.2020.02.27.07.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 07:16:46 -0800 (PST) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Thu, 27 Feb 2020 10:16:44 -0500 To: Ingo Molnar Cc: Arvind Sankar , Ard Biesheuvel , linux-efi@vger.kernel.org, Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov Subject: Re: [PATCH v2 1/1] x86/boot/compressed: Fix reloading of GDTR post-relocation Message-ID: <20200227151643.GA3498170@rani.riverdale.lan> References: <20200226204515.2752095-1-nivedita@alum.mit.edu> <20200226230031.3011645-2-nivedita@alum.mit.edu> <20200227081229.GA29411@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200227081229.GA29411@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 27, 2020 at 09:12:29AM +0100, Ingo Molnar wrote: > > * Arvind Sankar wrote: > > > Commit ef5a7b5eb13e ("efi/x86: Remove GDT setup from efi_main") > > introduced GDT setup into the 32-bit kernel's startup_32, and reloads > > the GDTR after relocating the kernel for paranoia's sake. > > > > Commit 32d009137a56 ("x86/boot: Reload GDTR after copying to the end of > > the buffer") introduced a similar GDTR reload in the 64-bit kernel. > > > > The GDTR is adjusted by init_size - _end, however this may not be the > > correct offset to apply if the kernel was loaded at a misaligned address > > or below LOAD_PHYSICAL_ADDR, as in that case the decompression buffer > > has an additional offset from the original load address. > > > > This should never happen for a conformant bootloader, but we're being > > paranoid anyway, so just store the new GDT address in there instead of > > adding any offsets, which is simpler as well. > > > > Signed-off-by: Arvind Sankar > > Fixes: ef5a7b5eb13e ("efi/x86: Remove GDT setup from efi_main") > > Fixes: 32d009137a56 ("x86/boot: Reload GDTR after copying to the end of the buffer") > > Have you or anyone else observed this condition practice, or have a > suspicion that this could happen - or is this a mostly theoretical > concern? > > Thanks, > > Ingo Right now it's a theoretical concern. I'm working on another patch, to tell the EFI firmware PE loader what the kernel's preferred address is, so that we can avoid having to relocate the kernel in the EFI stub in most cases (ie if the PE loader manages to load us at that address). With those changes, the required adjustment won't be init_size - _end any more, and while fixing it up there, I noticed that it could already be the case that the required adjustment is different. Thanks.