From nobody Thu Nov 12 09:23:16 2026 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 4jQFLD3DnJz70GvG for ; Thu, 12 Nov 2026 09:23:16 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jQFLD2Nxtz4sjh for ; Thu, 12 Nov 2026 09:23:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794475396; 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=YKOjqLhjZ6PoxDBYO94DL/rk3bhyAnMbEDMTZgsepyA=; b=GsNFZHw5XWbsjmRmJm5cQ9+wR+TN+GULUo68QnjxaR0FB4cTB9Aqw/BhAgfcK9kUpKp4GU 8d2a+uTCE1eh356cqsjaCVhljSWjWaL3VfwkU1Y9F9Q7NsiSc2pCT6uMdLm0Fb3VFHLcH9 3AU2SVAn1mO4I8zsa5NASRPxUIn1nn56Q3uwMNSn/KMLrdZ4fvvjlF8Lr2DjagE++r5oOB vLs+iz2DeNPrVprtPEhr0UqdGKRq830/IgQSWYFg7SDt1RkOvxK/nbLv6aWDbz1+PJuMKO pASZ8IhTW3GuWEHvktoTwLRp/I7z5q/zL6ARHjBc+fCAdqW1CHNqr3UsQtz+/Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794475396; b=cj9NEGRtKBiSW87bGaZU39aem+eWr/rMtthP2u62Pt/OL5b4j0n7HBH/CMxjRTUZH+ePs4 +Rjt8ELrw3q4mFSoaxDgTsoc0Ar7DyO9z4DUdWg4I4yf/s1JV4EeqNzBvLffwbLGELLzy5 kpJkmuiTz2+6x2TVfh49t71EhrMeiJ/3gyytoZamFuqgNXtJcc+dktI1HKoH2s/WCzsLc/ n17yNH8S0MBNjShrolUymzO8kQkOw75rE6Oy5pEMFSA0khy8XR11twlBm653MhJ8QB6kBo cs+W2mtHgYDC7qoTANU+SLYyR3Pk3cRP5q979r5Aa/l2bvRV/vIdHnoKOwMAnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794475396; 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=YKOjqLhjZ6PoxDBYO94DL/rk3bhyAnMbEDMTZgsepyA=; b=RsY1NW/BtgmKsNW4+91kVpRxm29AOw+WBJi32i7ykQGMNurCN2ZOwcWT41n+UL6C0/RSIm dD+UTutDZHG9JfWQPAnDuuk2pDrK1ImcZeHhZYLgoZmoWEfJKy/HHsQYfDt94xlgCcW/zW hcCbeMA15eZF/DDe+LvLrRBQ5R+c4UnDA+o1L8qRoswDDikis0wzaMqF6EkA4yohascoYX JmFPNmbCQLdYieKw4TPmThsOf++Vc/ENrQR2r9T71iWv1gmxazloBQbgsIt443a23rNZGe bclXyGvhUTxOWHFAAnbZO88id4EqEo/Nkcy4HPJDKZrd278MJrLWV9I3yVlwXQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jQFLD23vxzxG1 for ; Thu, 12 Nov 2026 09:23:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e882 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 12 Nov 2026 09:23:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Cochard Subject: git: 9ff8ab26dcac - main - loader.efi: Give the md probe a struct disk_devdesc List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olivier X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9ff8ab26dcacebb50183c5bd767e7c5939116598 Auto-Submitted: auto-generated Date: Thu, 12 Nov 2026 09:23:16 +0000 Message-Id: <6af58584.1e882.6195f2f5@gitrepo.freebsd.org> The branch main has been updated by olivier: URL: https://cgit.FreeBSD.org/src/commit/?id=9ff8ab26dcacebb50183c5bd767e7c5939116598 commit 9ff8ab26dcacebb50183c5bd767e7c5939116598 Author: Olivier Cochard AuthorDate: 2026-11-08 21:39:43 +0000 Commit: Olivier Cochard CommitDate: 2026-11-12 09:17:34 +0000 loader.efi: Give the md probe a struct disk_devdesc probe_md_currdev() named md through set_currdev_devsw(), which builds a plain struct devdesc. Once md uses disk_fmtdev(), that reads d_slice and d_partition past the end of the struct, and currdev becomes a name built from stack garbage. Use a struct disk_devdesc instead, and open the device first so the name shows the slice and partition actually found. When the image has no partition table, fall back to the whole image, as before. Add md_get_size() and move MD_BLOCK_SIZE to bootstrap.h so main.c can open the device. Reviewed by: imp Approved by: imp Sponsored by: Netflix Differential Revision: https://ron-dev.freebsd.org/FreeBSD/src/pulls/98 --- stand/common/bootstrap.h | 3 +++ stand/common/md.c | 17 ++++++++++++++++- stand/efi/loader/main.c | 32 +++++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index 7dab530a368a..c091dc3266e5 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -387,5 +387,8 @@ void set_currdev(const char *devname); extern struct devsw md_dev; int md_register(void *image, size_t size, unsigned int flags); void md_export_to_kernel(uint64_t start, uint64_t len); +int md_get_size(int unit, uint64_t *size); + +#define MD_BLOCK_SIZE 512 #endif /* !_BOOTSTRAP_H_ */ diff --git a/stand/common/md.c b/stand/common/md.c index c8692a8948fb..93301e39a2f5 100644 --- a/stand/common/md.c +++ b/stand/common/md.c @@ -32,7 +32,6 @@ #include "bootstrap.h" -#define MD_BLOCK_SIZE 512 #define MD_FLAG_MASK MD_FLAG_KERNEL struct md_info { @@ -95,6 +94,22 @@ md_get_info(int unit) return (NULL); } +/* + * Report a registered md's size, so probe_md_currdev() can hand it to + * disk_open() without reaching into the private struct md_info. + */ +int +md_get_size(int unit, uint64_t *size) +{ + struct md_info *md; + + md = md_get_info(unit); + if (md == NULL) + return (ENXIO); + *size = md->md_size; + return (0); +} + int md_register(void *image, size_t size, unsigned int flags) { diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index bac8cab552f5..1b8bed045253 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -328,9 +328,39 @@ static bool probe_md_currdev(void) { #ifdef LOADER_MD_SUPPORT + struct disk_devdesc dev; + uint64_t mediasize; bool rv; - set_currdev_devsw(&md_dev, 0); + /* + * md is a DEVT_DISK, so it needs a disk_devdesc: set_currdev_devsw() + * would pass a plain devdesc and devformat() would read the slice and + * partition off the end of it. Leave both wild for md_open() to + * resolve against whatever partition table the image carries. + */ + dev.dd.d_dev = &md_dev; + dev.dd.d_unit = 0; + dev.dd.d_opendata = NULL; + dev.d_slice = D_SLICEWILD; + dev.d_partition = D_PARTWILD; + dev.d_offset = 0; + + /* + * devformat() prints d_slice verbatim, and D_SLICEWILD is 0, which + * would name a slice that cannot exist. Open the device first so + * disk_open() writes the resolved slice and partition back, then + * name that. + */ + if (md_get_size(0, &mediasize) == 0 && + disk_open(&dev, mediasize, MD_BLOCK_SIZE) == 0) { + disk_close(&dev); + } else { + /* No partition table: use the whole image as the filesystem. */ + dev.d_slice = D_SLICENONE; + dev.d_partition = D_PARTNONE; + } + + set_currdev_devdesc((struct devdesc *)&dev); rv = sanity_check_currdev(); if (!rv) printf("MD not present\n");