From nobody Tue Jan 24 22:14:06 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P1h8H2spYz3bgNt; Tue, 24 Jan 2023 22:14:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P1h8H1RhSz3KfX; Tue, 24 Jan 2023 22:14:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Jcr58X+8NLKzBineahybFH3B6/sDGZjeDREDsmFPfLs=; b=L6wl5XJGmhYz1T1mwvJf6HSH70AnsNYIVzVqaLkaSOVbjJh5t7b0fccWmATJ4YbHbCoNyb IyqcceJxMaAaJdkizzswREfY16LQbyOGhImPKjJy/MYAMU1hMUFlmbdUm3F8Z/ZFcSuDFz HjT7kUoJpEa7odspsNXhXWjGaAh+O9Fv4izYc5wqONCGE4/JmOgQwKSeyeDU6s163QQwL7 xG7nPNcaLL+XdgMrtenejDCY0/DnUbCYoLwKoJBAsIdLEE0awj7q7FSh2kIy3wb9ZcYfyR rIBkAo5LeZAtYyORKr3IjalZ1FjtY/LuavL8a7tDO4so0fTy0JEdpX4t+ibvRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Jcr58X+8NLKzBineahybFH3B6/sDGZjeDREDsmFPfLs=; b=Rn0rB8IVH+DPAdz9G1sy2LZGxJ5hfuMh3i/Z/4KhdXwvVg6xWp5HqMnYlFh6gKg2HFDM9l xBAB0I5rv2ojjnwcRN+mYmVA2c3Vus5yGDU6VZC/jWtxUPGSKCrLvAHG0WuaWIBHsgP2h/ /PjHUIIqoqbC6i2T8FkbvlKAup1UjxK83Mwp32LSy14NYa9RIJfAACR8s8TzQWJE3dwftd OvgVFgDBWcjMU9RqXpEq5Eu0+9/MRo3MjQDM0xqoJKP5uZNZ0zFP8Zl1WqRzIqvDpJ3skf 2V2L7Am9hoKApA3tI2/xdB67oubz3f9iN7yFOrLfjUNuf981XTmQ9VeqVMVCxw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598447; a=rsa-sha256; cv=none; b=Dup6l//u+ZXLsPBTDY8Bmbpm6+WHnbhwvUiGLgUl8W5i0LrWRVfV6XlblSQLK8Z5o73UxD wi6v++b8QEa5OqOqOm8N5XRm61XJxYxPX8EDH8/TizYtpPpq7wWA6J4gXJg1NrOYTDSVVG 7WQIlIiNEE+lpJmwOnaBIy4PRaxezm9I8off79lRfHUX76FUyveRHKf7rGeCSE7I9HTNGv oxRd6LqunH5EPfLYiy0BLgEBTJ0mMoK2jqk29zXqGCGuY4Jy5Xyovm4UM3wPyML+HvsJ5S 8WrQgyTFkpKT1GqzIGCnLfvuqrXMMZjKxor4/bn8GzVNt/qt2m5Z5U6jISkYZA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P1h8G6bznzQfY; Tue, 24 Jan 2023 22:14:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30OME68j089362; Tue, 24 Jan 2023 22:14:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OME6Rm089361; Tue, 24 Jan 2023 22:14:06 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:14:06 GMT Message-Id: <202301242214.30OME6Rm089361@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: b5f753c82a11 - stable/13 - kboot: Allow loading fdt from different sources List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b5f753c82a116e50a5cc02db22fcccffb53c777b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b5f753c82a116e50a5cc02db22fcccffb53c777b commit b5f753c82a116e50a5cc02db22fcccffb53c777b Author: Warner Losh AuthorDate: 2022-12-09 05:07:52 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:44 +0000 kboot: Allow loading fdt from different sources Linux has /sys/firmware/fdt and /proc/device-tree to publish the dtb for the system. The former has it all in one file, while the latter breaks it out. Prefer the former since it's the more modern interface, but retain both since I don't have a PS3 to test to see if its kernel is new enough for /sys/firmware or not. In addition, do the proper fixup. Sponsored by: Netflix (cherry picked from commit 111610316e49dd6dc6b0b74455c1e4c81960faa8) --- stand/kboot/kbootfdt.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/stand/kboot/kbootfdt.c b/stand/kboot/kbootfdt.c index aafa436daf9f..3791b0c92ddd 100644 --- a/stand/kboot/kbootfdt.c +++ b/stand/kboot/kbootfdt.c @@ -94,11 +94,26 @@ fdt_platform_load_dtb(void) { void *buffer; size_t buflen = 409600; + int fd; + /* + * Should load /sys/firmware/fdt if it exists, otherwise we walk the + * tree from /proc/device-tree. The former is much easier than the + * latter and also the newer interface. But as long as we support the + * PS3 boot, we'll need the latter due to that kernel's age. It likely + * would be better to script the decision between the two, but that + * turns out to be tricky... + */ buffer = malloc(buflen); - fdt_create_empty_tree(buffer, buflen); - add_node_to_fdt(buffer, "/proc/device-tree", - fdt_path_offset(buffer, "/")); + fd = host_open("/sys/firmware/fdt", O_RDONLY, 0); + if (fd != -1) { + buflen = host_read(fd, buffer, buflen); + close(fd); + } else { + fdt_create_empty_tree(buffer, buflen); + add_node_to_fdt(buffer, "/proc/device-tree", + fdt_path_offset(buffer, "/")); + } fdt_arch_fixups(buffer); fdt_pack(buffer); @@ -112,12 +127,11 @@ fdt_platform_load_dtb(void) void fdt_platform_load_overlays(void) { - + fdt_load_dtb_overlays(NULL); } void fdt_platform_fixups(void) { - + fdt_apply_overlays(); } -