From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEACEC2BA2B for ; Mon, 13 Apr 2020 21:54:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9387020644 for ; Mon, 13 Apr 2020 21:54:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EDprZIfy"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=atishpatra.org header.i=@atishpatra.org header.b="S9tY0EwJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9387020644 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=atishpatra.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g7/GtMKr9ENDlrSKSWKtnxywhvaiE9Obl0KIOae1VvQ=; b=EDprZIfyF167lC FBRFUTL2i2xANMpQ8bpgwcpask7uEeEKqOwhwDDZf9d1LvHbQLlySVwkk63UwFTrk9Yf0GspXorSX oiKBYvz51PtI13fiLwII+f/XzCHjCWCqSiwxxNP8j2Ug4CGjnP0/XLdF353mNm6zabDrUxQR8I93n PumcoJ0ff4JLLM+yxbETdTRGjC0A0R0dJ2bzxG8tpuM4HEOwago9pQii0HI4rwL/a/3iS05dp05eE /WoDpNeUTmYL1JiSvpWrVCJzSfJ6oW3cdUpqw3y9v4lkAGkcXqVEuxEm4OA8DonAAAWRaKsG99ynh EIiVaqeWKS+ZczRXhK8A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jO721-0008As-8y; Mon, 13 Apr 2020 21:54:17 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jO71v-00085i-BA for linux-arm-kernel@lists.infradead.org; Mon, 13 Apr 2020 21:54:12 +0000 Received: by mail-wm1-x343.google.com with SMTP id d77so10807869wmd.3 for ; Mon, 13 Apr 2020 14:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=n2YrxFswkx7hDllVIsDVbzNNztgUR6Vkh9Ws2W9v0sU=; b=S9tY0EwJ0DuckJovjeInEXlrGKO2+8M+UJjAQNxtSEHCABWcJrCv/FH8NxKGKNYGgk eyx0wTZ5zhhpfDX1eFiNK7yAbuWgJ3GrMZ0cinZzhaqluce2O7yyc1PXRfrsWqI0N7mH f9iB6dT8Fbpxh4Vmc19lHugKZi/s6WM4hqAbOWtMw5baLt1tc5TNXR7//SDq/IcUyAbw lQVSvBUJnK4g8MhUdHCQjuoczqcMFlRzHMDNpZZyLZb1d2p7bZac1MTQ21FKk2tHTMxV Pv7pBwT1bKUu8LgcDVVS+Vv37thyxOSQTxmqu9lBp7VR0gtifwgNeL7cbJwW86dACaYK rGEg== 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=n2YrxFswkx7hDllVIsDVbzNNztgUR6Vkh9Ws2W9v0sU=; b=Hzh8Y5X8fqmSYl7Gj0auGYHqMsntPU9FqJ3C6dpyTZmZuZtg3wLw1yZevNh8rI2zZc pAWZJ9zSg+ostVF8mbgIV52dW14tN6c3Dskte2iKvbSY7M+8W9B0gULVA9EhAlyXHdKP 5WCxLkhT4w3VNytWBmBBzrCJzHNXq120FOaYwuWHQR3fk2rgqhYpcZw2hVVK+QOD+L2T +/Aw3Ax3gWdXKD/Ia/mdolqQV5bKRY2kEEas2FaHUoP3FI1odzHCM6IQO7QW9ByiAaRD sMsIoiw7++dqVIGU0EY6/BQcneesm7W7SEy2A7BFiSGGRVW5H67xMuJRpF4VCnPzoiCU PzVA== X-Gm-Message-State: AGi0PuYtPLS2NkJQxuRU7/AKga/OLdWoU6O++yUcLgDxdExx6bi5K6zT lY5Ie1d53CRJ0eJOiGvYUoVAnQrOj18op8mKnq+A X-Google-Smtp-Source: APiQypLR+TgWBKP/kkMmQfl3pNKIeF2HWnQrkpYuKf4da4NMDuLoi6OHvBqTmJaukhMVepYAflj20L2qUMY42xQhy9s= X-Received: by 2002:a7b:cdfa:: with SMTP id p26mr9270601wmj.186.1586814849695; Mon, 13 Apr 2020 14:54:09 -0700 (PDT) MIME-Version: 1.0 References: <20200413155521.24698-1-ardb@kernel.org> In-Reply-To: <20200413155521.24698-1-ardb@kernel.org> From: Atish Patra Date: Mon, 13 Apr 2020 14:53:58 -0700 Message-ID: Subject: Re: [PATCH v2 0/8] efi/libstub: simplify arm64 kernel image loading To: Ard Biesheuvel X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200413_145411_476206_32DEB13E X-CRM114-Status: GOOD ( 22.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-efi@vger.kernel.org, catalin.marinas@arm.com, nivedita@alum.mit.edu, Jonathan.Cameron@huawei.com, will@kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 13, 2020 at 8:55 AM Ard Biesheuvel wrote: > > On arm64, the kernel image used to be virtually mapped via the linear > region, making the two mappings correlated in a way that required the > kernel to be located at the start of the linear region, or the memory > below would not be accessible. For this reason, the EFI stub loader > code for arm64 has the notion of a 'preferred offset' for the physical > placement of the kernel image, and tries to put the kernel there, or > at least as low as possible in physical memory (unless KASLR is active, > in which case the placement is randomized) > > When KASLR was introduced, the virtual mapping of the kernel was moved > into the vmalloc region, and now, regardless of whether KASLR support > is built in or active, the kernel can be placed anywhere in physical > memory without any detrimental side effects on the linear region. > > This means that we can drop the notion of 'preferred offset' entirely, > and invoke the kernel in place if the PE/COFF loader loaded it at the > right offset. If not, we can invoke the ordinary UEFI top down page > allocator to reallocate it elsewhere in memory. By updating the PE/COFF > metadata, we can inform the PE/COFF loader about the desired alignment, > making it less likely that we need to move the kernel image in the first > place. > > Ard Biesheuvel (8): > efi/libstub/random: align allocate size to EFI_ALLOC_ALIGN > efi/libstub/random: increase random alloc granularity > efi/libstub/arm64: replace 'preferred' offset with alignment check > efi/libstub/arm64: simplify randomized loading of kernel image > efi/libstub/arm64: align PE/COFF sections to segment alignment > efi/libstub: add API function to allocate aligned memory > efi/libstub/arm64: switch to ordinary page allocator for kernel image > efi/libstub: move efi_relocate_kernel() into separate source file > > arch/arm64/kernel/efi-header.S | 2 +- > arch/arm64/kernel/vmlinux.lds.S | 3 +- > drivers/firmware/efi/libstub/Makefile | 3 +- > drivers/firmware/efi/libstub/alignedmem.c | 57 ++++++ > drivers/firmware/efi/libstub/arm64-stub.c | 92 +++------- > drivers/firmware/efi/libstub/efistub.h | 18 +- > drivers/firmware/efi/libstub/mem.c | 191 +------------------- > drivers/firmware/efi/libstub/randomalloc.c | 6 +- > drivers/firmware/efi/libstub/relocate.c | 174 ++++++++++++++++++ > 9 files changed, 280 insertions(+), 266 deletions(-) > create mode 100644 drivers/firmware/efi/libstub/alignedmem.c > create mode 100644 drivers/firmware/efi/libstub/relocate.c > > -- > 2.17.1 > Oops. I just noticed this series after I sent out a v2. I see that efi_low_alloc is removed now and the handle_kernel_image is simplified for arm64. I will update the risc-v uefi series accordingly. Sorry for the noise. -- Regards, Atish _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel