git: 0d805f0f6f25 - stable/13 - kboot: Add md_addr to metadata

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 22:13:55 UTC
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=0d805f0f6f25cc18faf46ae729d8e1b06e7dea66

commit 0d805f0f6f25cc18faf46ae729d8e1b06e7dea66
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-12-04 20:52:22 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-01-24 21:49:43 +0000

    kboot: Add md_addr to metadata
    
    Save the address of where the metadata is loaded.
    
    Sponsored by:           Netflix
    
    (cherry picked from commit 9f7269677c5e70283a16887e1e4b4a1ed95a96fb)
---
 stand/common/bootstrap.h | 1 +
 stand/common/modinfo.c   | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h
index cb1c96dc3b69..bbe97e80323b 100644
--- a/stand/common/bootstrap.h
+++ b/stand/common/bootstrap.h
@@ -201,6 +201,7 @@ struct file_metadata
 {
 	size_t		md_size;
 	uint16_t	md_type;
+	vm_offset_t	md_addr;	/* Valid after copied to kernel space */
 	struct file_metadata *md_next;
 	char		md_data[1];	/* data are immediately appended */
 };
diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c
index 0c00b2070274..381bd9dfd719 100644
--- a/stand/common/modinfo.c
+++ b/stand/common/modinfo.c
@@ -95,8 +95,10 @@
 #define MOD_METADATA(a, mm, c) {		\
     COPY32(MODINFO_METADATA | mm->md_type, a, c);\
     COPY32(mm->md_size, a, c);			\
-    if (c)					\
+    if (c) {					\
         archsw.arch_copyin(mm->md_data, a, mm->md_size);\
+	mm->md_addr = a;			\
+    }						\
     a += MOD_ALIGN(mm->md_size);		\
 }