Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5378513rwl; Wed, 28 Dec 2022 18:18:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXs5rakUkBozP5jjSCqwGzCtNTQiXPLdb0KTao6LrgrraUgj/QS+s9fPfZdSph/c+Kq8ZWah X-Received: by 2002:a17:902:da86:b0:189:d0c9:f7d0 with SMTP id j6-20020a170902da8600b00189d0c9f7d0mr36754415plx.27.1672280305385; Wed, 28 Dec 2022 18:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672280305; cv=none; d=google.com; s=arc-20160816; b=gveO2l4vyYfRBhQfKjMEc8CnUApMoZsUamft+IauoMCAcShKhjOozxpaAJnEpA0BG8 EEngG3uq4AvZKglQAKRoumiay04tBEbD9Xe1yodKc+WVAGV7UJqvi/FnH43ibd/XPTsa G7Plhdz9nM2F+MerEMKqPUKEZ0u4IvJlHiPc+aW47FtMKttGGU8Pu0aO6dxdj8hPffv1 Fe/VR6sxlDMZjsaVZ9BB+G8yziQNxx1bwsr9un04uZOF90u/H8myntXAqy7mXwMtqgQk D2liUqGzgVYkRf42gQo1pMW2PR1nOczUyN8Ikp5seeVHkIXqOb2izGcgUbKcZq3mxj/O WtFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :dkim-signature:dkim-filter; bh=wDlVIMRzl48TIn6PdZnv8A8E3UHC34q713deYKTA5QA=; b=OTnLxRsoIrBKV1d2muBrbnHEfMaM38F/I5X3tQ4ycKZV5rkAtCzctyEMSFl8vFpst8 ewdb19j6sPuo98GBhKls2yTMoPDqQQHb5RCftvxnT4pKpof20JYZL560zPAXA0zir9+8 QHM+XmArZ2pQFZ/m4VTtlJ0P6Vcaq/IWeqfPAbNYlbxhaZV6v6Pue4kVCNvjjnkGVd7s z3zfPS/m6PzJSP45X98hAqmgk8r77h+YaczW4O5G9A7+zvjLZbLdeua4NB71c/dbvdMf LQeSvA9R6wvaCqr3NBc5BNszi45CB+y6jaU2UTNZm3ukr5fCcbBzPrYFcHAdvlztP0Yu R7hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2022120601 header.b=dEeZ8CBb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iz17-20020a170902ef9100b00178380f525bsi16356586plb.547.2022.12.28.18.17.57; Wed, 28 Dec 2022 18:18:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2022120601 header.b=dEeZ8CBb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230328AbiL2COG (ORCPT + 62 others); Wed, 28 Dec 2022 21:14:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbiL2COD (ORCPT ); Wed, 28 Dec 2022 21:14:03 -0500 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8760EB2E for ; Wed, 28 Dec 2022 18:14:01 -0800 (PST) Received: from [IPV6:2601:646:8600:40c1:5967:deb4:a714:2940] ([IPv6:2601:646:8600:40c1:5967:deb4:a714:2940]) (authenticated bits=0) by mail.zytor.com (8.17.1/8.17.1) with ESMTPSA id 2BT2Ddcr771066 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Wed, 28 Dec 2022 18:13:39 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 2BT2Ddcr771066 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2022120601; t=1672280020; bh=wDlVIMRzl48TIn6PdZnv8A8E3UHC34q713deYKTA5QA=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=dEeZ8CBbOy98d3JIHEBFW0m4LEt3a+syD3kFsaOaRonOYJN3emSdaRBTyT2KkhFx3 bsK1iEdGg9vJqFD7ZJVBjKO8B/hTq8JPveGkYpouKbHb8RTDuTJD54GLTxBv3iEhKZ eDxV3puw8rOpQIy1A5Pc6x7eVQfB3ruOg2oe6xFSyUhwAuQswhQY5BcmCxCC9hBlrF vut0sQX/QvOysHrNkeKVtgPZWJDVgzlRahiBDKm1mzokpk5CloO9cF3udiJ3KqIu2m EKEBgNpMYUWOWKaHmxrRarRdKKjKMMsYANmvoP/cuJHKik14vui8yt5aGGlYcQQy4+ BhE1attzrlsOA== Content-Type: multipart/mixed; boundary="------------zOvv02N0vbK1R1cRQLgodu5K" Message-ID: <0baf674b-c7e7-a010-375d-ea1132495c44@zytor.com> Date: Wed, 28 Dec 2022 18:13:34 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH qemu] x86: don't let decompressed kernel image clobber setup_data Content-Language: en-US From: "H. Peter Anvin" To: "Jason A. Donenfeld" Cc: pbonzini@redhat.com, ebiggers@kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, ardb@kernel.org, kraxel@redhat.com, bp@alien8.de, philmd@linaro.org References: <20221228143831.396245-1-Jason@zx2c4.com> <6cab26b5-06ae-468d-ac79-ecdecb86ef07@linaro.org> <9188EEE9-2759-4389-B39E-0FEBBA3FA57D@zytor.com> In-Reply-To: <9188EEE9-2759-4389-B39E-0FEBBA3FA57D@zytor.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RDNS_NONE, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------zOvv02N0vbK1R1cRQLgodu5K Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/28/22 15:58, H. Peter Anvin wrote: > On December 28, 2022 8:57:54 AM PST, "Jason A. Donenfeld" wrote: >> HELLO H. PETER ANVIN, >> E >> L >> L >> O >> >> On Wed, Dec 28, 2022 at 05:30:30PM +0100, Jason A. Donenfeld wrote: >>>> Fix looks good, glad you figured out the problem. >>> >>> I mean, kind of. The solution here sucks, especially given that in the >>> worst case, setup_data just gets dropped. I'm half inclined to consider >>> this a kernel bug instead, and add some code to relocate setup_data >>> prior to decompression, and then fix up all the links. It seems like >>> this would be a lot more robust. >>> >>> I just wish the people who wrote this stuff would chime in. I've had >>> x86@kernel.org CC'd but so far, no input from them. >> >> Apparently you are the x86 boot guru. What do you want to happen here? >> Your input would be very instrumental. >> >> Jason > > Hi! > > Glad you asked. > > So the kernel load addresses are parameterized in the kernel image > setup header. One of the things that are so parameterized are the > size and possible realignment of the kernel image in memory. > > I'm very confused where you are getting the 64 MB number from. There > should not be any such limitation. > > In general, setup_data should be able to go anywhere the initrd can > go, and so is subject to the same address cap (896 MB for old > kernels, 4 GB on newer ones; this address too is enumerated in the > header.) > > If you want to put setup_data above 4 GB, it *should* be ok if and > only if the kernel supports loading the initrd high, too (again, > enumerated in the header. > > TL;DR: put setup_data where you put the initrd (before or after > doesn't matter.) > > To be maximally conservative, link the setup_data list in order from > lowest to highest address; currently there is no such item of > relevance, but in the future there may be setup_data items needed by > the BIOS part of the bootstrap in which case they would have to be < > 1 MB and precede any items > 1 MB for obvious reasons. That being > said, with BIOS dying it is not all that likely that such entries > will ever be needed. > So let me try for an algorithm. Attached as a text file to avoid line break damage. -hpa --------------zOvv02N0vbK1R1cRQLgodu5K Content-Type: text/plain; charset=UTF-8; name="kernel-data-addresses.txt" Content-Disposition: attachment; filename="kernel-data-addresses.txt" Content-Transfer-Encoding: base64 SGVyZSBpcyBhbiBhdHRlbXB0ZWQgZGVzY3JpcHRpb24gd2l0aCBwc2V1ZG8tQyBjb2RlOgoK Rmlyc3Qgb2YgYWxsLCB0YWtlIGEgNEsgcGFnZSBvZiBtZW1vcnkgYW5kICppbml0aWFsaXpl IGl0IHRvIHplcm8qLgp7CiAgICAjaW5jbHVkZSA8YXNtL2Jvb3RwYXJhbS5oPgkvKiBGcm9t IHRoZSB1YXBpIGtlcm5lbCBzb3VyY2VzICovCgogICAgLyogQWxsb2NhdGVkIHNvbWV3aGVy ZSBpbiB5b3VyIGNvZGUuLi4gKi8KICAgIGV4dGVybiB1bnNpZ25lZCBjaGFyICprZXJuZWxf aW1hZ2U7CQkvKiBLZXJuZWwgZmlsZSAqLwogICAgZXh0ZXJuIHN0cnVjdCBib290X3BhcmFt cyAqYm9vdF9wYXJhbXM7CS8qIDRLIGJ1ZmZlciAqLwogICAgZXh0ZXJuIHVpbnQzMl90IGtl cm5lbF9pbWFnZV9zaXplOwkJLyogU2l6ZSBvZiBrZXJuZWwgZmlsZSAqLwoKICAgIC8qIENh bGxiYWNrcyBpbnRvIHlvdXIgY29kZSAqLwogICAgZXh0ZXJuIGJvb2wgaXNfYmlvc19ib290 KHZvaWQpOwogICAgZXh0ZXJuIHVpbnQzMl90IGVuZF9vZl9sb3dfbWVtb3J5KHZvaWQpOyAv KiBGb3IgQklPU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