Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp553801imu; Fri, 9 Nov 2018 02:06:17 -0800 (PST) X-Google-Smtp-Source: AJdET5fcsT3x3a3oakZMTT8B5zDhtRt+4Rg7YZ381bzAElmTF1DxVnP5XmxN8owU5vgg8gjFSu0P X-Received: by 2002:a65:4b82:: with SMTP id t2mr6943174pgq.189.1541757977788; Fri, 09 Nov 2018 02:06:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541757977; cv=none; d=google.com; s=arc-20160816; b=Nj84t/QsdJbWX/2sszgvDQL18xPy8/FCv1AHadRon/tEFq1gQDBR14+81+opN5yd2z PBM335WWWRhAA9TGBKrjTXoE64GE54kTK4BxgAuUM4OcScgLv8N2UPyNDwWld0BIxZh8 ewhjUtKLLinpcVMAAatjxXgSlzLVWHYUAsHFwK+QA5WE7sWNUnOL9ckm7h+5tNIrAluV t0usqQ3XY+H1OcDi2+3u41OuzJYTB2MKbEDGBjAWG9t9WoNL6yRFQUs7q49ldfCK8Zcb hWbCnxPXDAl1K1UMVCFcmyrpj64XOMFbf/1NvsXfD3caGbbGqsZqNZp4CBUtWMkDOAh5 gwHw== 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:autocrypt:openpgp:from:references:cc:to:subject; bh=isWSm426BuVxo7FqDLu++njy12x39oN7Qc4SQxCB8wk=; b=bmvfWx94Vf+NvyVJnctcdEL13FLO9bIRjGG+xVIOqDShrziFO+uEODk4lAYL4WZG5/ ZB4J1z+eYoNYpCGYGS6JsT/9JJX9Ct+eM0MOuNz+qh0QbHsQCbShVYWvt4XmsCDi8Vva 7ZU4Ow92uNQgTBL27kpzR6SYPz6woAtqOGio68OxnhIQNfe/gwk1oxip1E0qmpGufjqc kOis58vQ5VQTn3bXVZNCvl+0dzTq4XJOpGSwY0WYWff01l9fB6ZD5qnV/RG3zxoGEb/N k35mMGCDDUmN/ZqVdmOIQijhZmIb/PB+vAVHO5NiojsQYpLoTMcvjFrHRZ5eSSTCT2pQ z+2w== 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 z21si6022559pgv.363.2018.11.09.02.05.46; Fri, 09 Nov 2018 02:06:17 -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 S1727760AbeKIToQ (ORCPT + 99 others); Fri, 9 Nov 2018 14:44:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:43734 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727596AbeKIToP (ORCPT ); Fri, 9 Nov 2018 14:44:15 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 29681AD94; Fri, 9 Nov 2018 10:04:21 +0000 (UTC) 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 , Ingo Molnar , Li Zhijian Cc: Peter Maydell , x86@kernel.org, hpa@zytor.com, 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: Juergen Gross Openpgp: preference=signencrypt Autocrypt: addr=jgross@suse.com; prefer-encrypt=mutual; keydata= xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOB ycWxw3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJve dYm8Of8Zd621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJ NwQpd369y9bfIhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvx XP3FAp2pkW0xqG7/377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEB AAHNHkp1ZXJnZW4gR3Jvc3MgPGpncm9zc0BzdXNlLmRlPsLAeQQTAQIAIwUCU4xw6wIbAwcL CQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAAAoJELDendYovxMvi4UH/Ri+OXlObzqMANruTd4N zmVBAZgx1VW6jLc8JZjQuJPSsd/a+bNr3BZeLV6lu4Pf1Yl2Log129EX1KWYiFFvPbIiq5M5 kOXTO8Eas4CaScCvAZ9jCMQCgK3pFqYgirwTgfwnPtxFxO/F3ZcS8jovza5khkSKL9JGq8Nk czDTruQ/oy0WUHdUr9uwEfiD9yPFOGqp4S6cISuzBMvaAiC5YGdUGXuPZKXLpnGSjkZswUzY d9BVSitRL5ldsQCg6GhDoEAeIhUC4SQnT9SOWkoDOSFRXZ+7+WIBGLiWMd+yKDdRG5RyP/8f 3tgGiB6cyuYfPDRGsELGjUaTUq3H2xZgIPfOwE0EU4xwFgEIAMsx+gDjgzAY4H1hPVXgoLK8 B93sTQFN9oC6tsb46VpxyLPfJ3T1A6Z6MVkLoCejKTJ3K9MUsBZhxIJ0hIyvzwI6aYJ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fgSaCnQ1izwgJQ jIpcG2fPCI2/hxf2oqXPYbKr1v4Z1wthmoyUgGN0LPTIm+B5vdY82wI5qe9uN6UOGyTH2B3p hRQUWqCwu2sqkI3LLbTdrnyDZaixT2T0f4tyF5Lfs+Ha8xVMhIyzNb1byDI5FKCb Message-ID: Date: Fri, 9 Nov 2018 11:04:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <38905d35-29af-b522-1629-b13e98a47a42@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/11/2018 10:57, Li Zhijian wrote: > On 11/9/2018 3:20 PM, Ingo Molnar wrote: >> * Li Zhijian wrote: >> >>>> If the kernel initrd creation process creates an initrd which >>>> is larger than 2GB and also claims that it can't be placed >>>> with any part of it above 2GB, then that sounds like a bug >>>> in the initrd creation process... >>> Exactly, it's a real problem. >>> >>> Add x86 maintainers and LKML: >>> >>> The background is that QEMU want to support up to 4G initrd. but >>> linux header ( >>> initrd_addr_max field) only allow 2G-1. >>> Is one of the below approaches reasonable: >>> 1) change initrd_addr_max to 4G-1 directly >>> simply(arch/x86/boot/header.S)? >>> 2) lie QEMU bootloader the initrd_addr_max is 4G-1 even though header >>> said 2G-1 >>> 3) any else >> A 10 years old comment from hpa says: >> >>    initrd_addr_max: .long 0x7fffffff >>                                          # (Header version 0x0203 or >> later) >>                                          # The highest safe address for >>                                          # the contents of an initrd >>                                          # The current kernel allows >> up to 4 GB, >>                                          # but leave it at 2 GB to avoid >>                                          # possible bootloader bugs. >> >> To avoid the potential of bugs lurking in dozens of major and hundreds of >> minor iterations of various Linux bootloaders I'd prefer a real solution >> and extend it - because if there's a 2GB initrd for some weird reason >> today there might be a 4GB one in two years. > > thank a lots. that's amazing. > > >> >> The real solution would be to: >> >>   - Extend the boot protocol with a 64-bit field, named initrd_addr64_max >>     or such. >>   - We don't change the old field - but if the new field is set by new >>     kernels then new bootloaders can use that as a new initrd_addr64_max >>     value. (or reject to load the kernel if the address is too high.) >> >>   - The kernel build should also emit a warning when building larger than >>     2GB initrds, with a list of bootloaders that support the new >> protocol. > > Actually i just knew QEMU(Seabios + optionrom(linuxboot_dma.bin)) can > support ~4GB initrd so far. > > i just drafted at patch to add this field. could you have a look. > another patch which is to document initrd_addr64_max is ongoing. > > commit db463ac9c1975f115d1ce2acb82d530c2b63b888 > Author: Li Zhijian > Date:   Fri Nov 9 17:24:14 2018 +0800 > >     x86: Add header field initrd_addr64_max >         Years ago, kernel had support load ~4GB initrd. But for some > weird reasons ( >     avoid possible bootloader bugs), it only allow leave initrd under > 2GB address >     space(see initrd_addr_max fild at arch/x86/boot/header.S). >         So modern bootloaders have not chance to load >=2G initrd > previously. >         To avoid the potential of bugs lurking in dozens of major and > hundreds of >     minor iterations of various Linux bootloaders. Ingo suggests to add > a new field >     initrd_addr64_max. If bootloader believes that it can load initrd to >>=2G >     address space, it can use initrd_addr64_max as the maximum loading > address in >     stead of the old field initrd_addr_max. > > diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S > index 4c881c8..5fc3ebe 100644 > --- a/arch/x86/boot/header.S > +++ b/arch/x86/boot/header.S > @@ -300,7 +300,7 @@ _start: >         # Part 2 of the header, from the old setup.S >   >                 .ascii  "HdrS"          # header signature > -               .word   0x020e          # header version number (>= 0x0105) > +               .word   0x020f          # header version number (>= 0x0105) >                                         # or else old loadlin-1.5 will > fail) >                 .globl realmode_swtch >  realmode_swtch:        .word   0, 0            # default_switch, SETUPSEG > @@ -562,6 +562,12 @@ acpi_rsdp_addr:            .quad 0                 > # 64-bit physical pointer to the >                                                 # ACPI RSDP table, added > with >                                                 # version 2.14 >   > +#ifdef CONFIG_INITRD_SIZE_4GB > +initrd_addr64_max:     .quad 0xffffffff        # allow ~4G initrd since > 2.15 > +#else > +initrd_addr64_max:     .quad 0 Shouldn't this be 0x7fffffff? And please update Documentation/x86/boot.txt Juergen