Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1242802imu; Fri, 9 Nov 2018 13:13:52 -0800 (PST) X-Google-Smtp-Source: AJdET5foQzolXvvrW7gix9Y7DfAmBORXmCvb0vBGVSiXRs5wh8/7PXFIThAtXrhQ4ikte56nluzP X-Received: by 2002:a63:77ce:: with SMTP id s197mr8840048pgc.89.1541798032640; Fri, 09 Nov 2018 13:13:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541798032; cv=none; d=google.com; s=arc-20160816; b=vhKZSWJM9+Ftb2FBKpEBtpkvvH5ALX0nS0ZUpDZ2SnVzHEHBfuUtwDC9FlMhYsc5UO zbL4lHWUOjYWXKzOJ6LV4t9fPJiDfVxoZoT7m4tlm5xFJSBQizfHKHydYnN/mch5mqxX VnBO0TPDCPx8ZoM36X0B/YQ5GCLkYcY1KRKYdhdVpXgeWaZ7SdPxJnn/0yOzLNfSZhc9 zoaZV2Caavq0H8H0grrZg7krnc9s0fCIiX5Bf5Dd2cNDWG+Z6GPOM8tvJJRLaT6Q6eht KTwezpRJvY7eqPEwVxZiCDXklGbmFc15mO8nnA+FqOG25ScDOzknd25+ehGHecD4XHjs 9XOg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Jct32dhYcNbe7sqlYo4fWOkioNkSmK6JaD3BHm0XWbY=; b=l1ff02lhkyrZ6EoNf7zMrbrpoRPU9yLwhkpXU8fs/YWeNtCVgAuuxxnpWL98nter/N yYZBzGtnS6x0YMcaf4+1Xqj0iqSlY/sprcya+o+6Cf9fwDe/1qS0bJV2uGV6TKl/6cqH 2JmOMGRyMumWi8rYnfSiiscE72Ty8ElJofnz7hu9PPqWbFnh2HwYFQQkPzXCc0cwnyI3 wzKHtyDIEm1PJf40AMU200p6+xFw3oPoHIJHn6OzLSc0QLI01dzS1pe+WcdDmvp6LDEy jd5zxLfyIAIxn6JDF7f8k0+m95VhmPPR6b5mSkSWK6Vmlcj9tL8FoWYltttI6UMIY7AJ s6pw== 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 s11-v6si7976676pgh.511.2018.11.09.13.13.35; Fri, 09 Nov 2018 13:13:52 -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 S1728260AbeKJGyD (ORCPT + 99 others); Sat, 10 Nov 2018 01:54:03 -0500 Received: from terminus.zytor.com ([198.137.202.136]:47255 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbeKJGyC (ORCPT ); Sat, 10 Nov 2018 01:54:02 -0500 Received: from hanvin-mobl2.amr.corp.intel.com (fmdmzpr03-ext.fm.intel.com [192.55.54.38]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id wA9LAn272522899 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 9 Nov 2018 13:10:50 -0800 Subject: Re: [Qemu-devel] [RFC/PoC PATCH 1/3] i386: set initrd_max to 4G - 1 to allow up to 4G initrd To: Li Zhijian , Juergen Gross , Ingo Molnar , Li Zhijian Cc: Peter Maydell , x86@kernel.org, bp@alien8.de, mingo@redhat.com, tglx@linutronix.de, QEMU Developers , Philip Li , linux-kernel@vger.kernel.org, Linus Torvalds , Peter Zijlstra , Kees Cook References: <1541674784-25936-1-git-send-email-lizhijian@cn.fujitsu.com> <1541674784-25936-2-git-send-email-lizhijian@cn.fujitsu.com> <20181109072015.GA86700@gmail.com> <38905d35-29af-b522-1629-b13e98a47a42@intel.com> From: "H. Peter Anvin" Message-ID: Date: Fri, 9 Nov 2018 13:10:49 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/9/18 5:40 AM, Li Zhijian wrote: > Just noticed that there is a field xloadflags at recent protocol >   60 Protocol 2.12:  (Kernel 3.8) Added the xloadflags field and > extension fields >   61                 to struct boot_params for loading bzImage and ramdisk >   62                 above 4G in 64bit. > [snip] >  617 Field name:     xloadflags >  618 Type:           read >  619 Offset/size:    0x236/2 >  620 Protocol:       2.12+ >  621 >  622   This field is a bitmask. >  623 >  624   Bit 0 (read): XLF_KERNEL_64 >  625         - If 1, this kernel has the legacy 64-bit entry point at > 0x200. >  626 >  627   Bit 1 (read): XLF_CAN_BE_LOADED_ABOVE_4G >  628         - If 1, kernel/boot_params/cmdline/ramdisk can be above 4G. >  629 > > maybe we can reuse this field and append a new Bit 5 > XLF_INITRD_MAX_SIZE_4G and increase header version. > For the old protocol version 2.12+, if  XLF_CAN_BE_LOADED_ABOVE_4G is > set, we can also realize ~4GB initrd is allowed. > > bootloader side: > if protocol >= 2.15 >    if XLF_INITRD_LOAD_BELOW_4G >       support ~4G initrd >    fi > else if protocol >=2.12 >    if XLF_CAN_BE_LOADED_ABOVE_4G >     support ~4G initrd >    fi > fi > The two are equivalent. Obviously you have to load above 4 GB if you have more than 4 GB of initrd. If XLF_CAN_BE_LOADED_ABOVE_4G is not set, then you most likely are on a 32-bit kernel and there are more fundamental limits (even if you were to load it above the 2 GB mark, you would be limited by the size of kernel memory.) So, in case you are wondering: the bootloader that broke when setting the initrd_max field above 2 GB was, of course, Grub. So just use XLF_CAN_BE_LOADED_ABOVE_4G. There is no need for a new flag or new field. Also note that the ext_ramdisk_image and ext_ramdisk_size are part of struct boot_params as opposed to struct setup_header, which means that they are not supported when entering via the 16-bit BIOS entry point, and I am willing to bet that there will be, ahem, "strangeness" if entered via the 32-bit entry point if at least the command line is loaded above the 4 GB mark; the initrd should be fine, though. This is obviosly not an issue in EFI environments, where we enter through the EFI handover entry point. The main reason these were not added to struct setup_header is that there are only 24 bytes left in that header and so space is highly precious. One way to deal with that if we really, really need to would be to add an initrd/initramfs type of setup_data. -hpa