Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5433503ybp; Mon, 14 Oct 2019 22:40:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+z07AVkEcVoek5tgpdWK2bSqE78aHYLgRkYTG1EnLuyq7VPJC+H/7AGpB4tWkhtGNT0uW X-Received: by 2002:a05:6402:1612:: with SMTP id f18mr32022564edv.66.1571118009503; Mon, 14 Oct 2019 22:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571118009; cv=none; d=google.com; s=arc-20160816; b=Rv7NhLDCqapA/xRXoFUoKNiek0JUB6k3CtHFnFnD0GEY+Hzkpg905DsXWDUsvzliu8 z/CKNFKwace97t12+UfK2lOpudZvuQR2L8gpZUFLEklvW7zQRerfoYFh+EqMLKs8RFYE O+pmIeQZyGwaQxuSSoJSC3hEZMTRSyPvxmGeHWt6n401RR+tt6JvmBk5SHMq4ubDDIFg c+vdXyVu/rUW0xiys7qSeUMg8ZUUIspqX8dRLL0BxjSKmo4fK91p3hApP7n1UwJI6flz Y93Bxd0i0s2Ms5ArpnPGy5xK+8D7vysRaqrAnVvYO7v9ZiCldbJClVSifksmZaQYUj6z bN5A== 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; bh=GX8bC+LvWnJ5dJICeG2nAc0CD2f9tU+0Yk6RVJKRFtA=; b=fzDWAFrfzizKha7TMKIfsuKFKrpWKr/Jkw6+/D/1OlZYgFBPvc/A8BiwMWflx4aySW EcVNxtj+y6nEPpyAzEwBqfxeAdYWG2fWlsoIU/0M7zScz/FoDdECU7KgP86MKQwGhRPl W5yRLzlwWl4cnf9qznVjK626xbSSgtSvJtGVlyxF+LNre3LK9w6K06sHebyWF8VfLtPI yrB4+j73RE6JJ5q+eoK0eMv+FjWzyric19jhvn+pveNSMShi+HFBAegcjcqJHveoL5aq ZbtQh9hmedQEGjOSq87kBkVbtr9UtHeLM9bhC8Up8sAvHAGhIZof68h+jh6emOP+HDvy SfHA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oq3si12557561ejb.220.2019.10.14.22.39.46; Mon, 14 Oct 2019 22:40:09 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728271AbfJOFYB (ORCPT + 99 others); Tue, 15 Oct 2019 01:24:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51132 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728265AbfJOFYB (ORCPT ); Tue, 15 Oct 2019 01:24:01 -0400 Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6217859FC for ; Tue, 15 Oct 2019 05:24:00 +0000 (UTC) Received: by mail-io1-f69.google.com with SMTP id t11so30212967ioc.13 for ; Mon, 14 Oct 2019 22:24:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GX8bC+LvWnJ5dJICeG2nAc0CD2f9tU+0Yk6RVJKRFtA=; b=gld90+XXU0shoZy+JcaLmfQx4IgZUBHkdD4We2sGNgzELATok5db6lpviae34lGkw2 IxhwzJ8ido4hCxMAl2Ld8KFygCYe4GWytRcHYkjmBeu0A4oTrJUQV01Dk8K2EIIA4fnE bOaRgJpqjxsaLH4GgSrD3bYeUm1nlPUBZpl3wKVRzdPZVv8RE/naMHDFvnMQWu4h3yf/ d/+tcXkZasww2yXBO6Y8mPesUYsuCv8YOSVbHRl7Zi7SI0bio6J6gub9baDVoQZtcsZN iyxOW0O6wNFnjiQ82I9dUd09iig7QQnxECqOPzIGrPOodHCpzFBKsSvDwTVDB6mlKzOI RKhw== X-Gm-Message-State: APjAAAWmYmSU7TRMEDcA3e7bKyQzsyBKPGGNevIcjb5EOvFvVLeZg3wG kxqDX+P86vpAvnbcFJzl5S7jEdWp6BVCrNlimWzL9Tk4fA78yZRqjBkc5VgLKnH1ga0X53PjbJ/ pPHUH0QQuSAZk02EvyShtZmLTVVQS1SiyVLvsXk/I X-Received: by 2002:a6b:d104:: with SMTP id l4mr6603812iob.50.1571117039945; Mon, 14 Oct 2019 22:23:59 -0700 (PDT) X-Received: by 2002:a6b:d104:: with SMTP id l4mr6603788iob.50.1571117039602; Mon, 14 Oct 2019 22:23:59 -0700 (PDT) MIME-Version: 1.0 References: <20191012034421.25027-1-kasong@redhat.com> <20191014101419.GA4715@zn.tnic> In-Reply-To: <20191014101419.GA4715@zn.tnic> From: Kairui Song Date: Tue, 15 Oct 2019 13:23:48 +0800 Message-ID: Subject: Re: [PATCH v3] x86, efi: never relocate kernel below lowest acceptable address To: Borislav Petkov Cc: Linux Kernel Mailing List , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , Matthew Garrett , Jarkko Sakkinen , Baoquan He , Dave Young , "the arch/x86 maintainers" , linux-efi 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, Oct 14, 2019 at 6:14 PM Borislav Petkov wrote: > > On Sat, Oct 12, 2019 at 11:44:21AM +0800, Kairui Song wrote: > > Currently, kernel fails to boot on some HyperV VMs when using EFI. > > And it's a potential issue on all platforms. > > > > It's caused a broken kernel relocation on EFI systems, when below three > > conditions are met: > > > > 1. Kernel image is not loaded to the default address (LOAD_PHYSICAL_ADDR) > > by the loader. > > 2. There isn't enough room to contain the kernel, starting from the > > default load address (eg. something else occupied part the region). > > 3. In the memmap provided by EFI firmware, there is a memory region > > starts below LOAD_PHYSICAL_ADDR, and suitable for containing the > > kernel. > > > > Efi stub will perform a kernel relocation when condition 1 is met. But > > due to condition 2, efi stub can't relocate kernel to the preferred > > address, so it fallback to query and alloc from EFI firmware for lowest > > Your spelling of "EFI" is like a random number generator in this > paragraph: "Efi", "efi" and "EFI". Can you please be more careful when > writing your commit messages? They're not some random text you hurriedly > jot down before sending the patch but a most important description of > why a change is being done. Sorry I just ignored the acronym usage problems, I did double check the text but didn't realize this is a problem... Will correct them. > > And if you don't see their importance now, just try doing some git > archeology, trying to understand why a change has been done in the past > and then encounter a commit message two-liner which doesn't say sh*t. > Then you'll start appreciating properly written commit messages. > > > usable memory region. > > > > It's incorrect to use the lowest memory address. In later stage, kernel > > will assume LOAD_PHYSICAL_ADDR as the minimal acceptable relocate address, > > but efi stub will end up relocating kernel below it. > > Why don't you simply explain what > choose_random_location()->find_random_virt_addr() does? That's the > problem you're solving, right? KASLR using LOAD_PHYSICAL_ADDR as the > minimum... > > > The later kernel decompressing code will forcefully correct the wrong > > kernel load location, > > ... or do you mean by that the dance in > arch/x86/boot/compressed/head_64.S where we move the kernel temporarily > to LOAD_PHYSICAL_ADDR for the decompression? The kernel move in arch/x86/boot/compressed/head_64.S is the problem I'm saying here. I thought it's a bad idea to include too much details about codes and details in the commit message, so tried to describe it without mentioning the implementation details. It's making things confusing indeed. I'll rethink about how the commit message should be composed... > > You can simply say that here... > OK, then I'll do so. Will update the commit message. -- Best Regards, Kairui Song