[RFC PATCH 05/15] Fix {lowest, highest}_modules_address() and is_kernel_text()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



fix {lowest,highest}_module_address() and is_kernel_text()

Signed-off-by: Kazuhito Hagio <k-hagio-ab@xxxxxxx>
---
 defs.h    |  6 ++++--
 symbols.c | 29 ++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/defs.h b/defs.h
index 4051eb8d134e..95e44e8cb87c 100644
--- a/defs.h
+++ b/defs.h
@@ -2988,8 +2988,10 @@ struct load_module {
 	int nr_mems;
 };
 
-#define IN_MODULE(A,L)		(_in_module(A, L, MOD_TEXT))
-#define IN_MODULE_INIT(A,L)	(_in_module(A, L, MOD_INIT_TEXT))
+#define IN_MODULE(A,L)		(_in_module_range(A, L, MOD_TEXT, MOD_RO_AFTER_INIT))
+#define IN_MODULE_INIT(A,L)	(_in_module_range(A, L, MOD_INIT_TEXT, MOD_INIT_RODATA))
+#define IN_MODULE_TEXT(A,L)	(_in_module_range(A, L, MOD_TEXT, MOD_TEXT) || \
+				_in_module_range(A, L, MOD_INIT_TEXT, MOD_INIT_TEXT))
 
 /*
 #define IN_MODULE(A,L) \
diff --git a/symbols.c b/symbols.c
index 5edc4844b3d8..ef00ce0b79ca 100644
--- a/symbols.c
+++ b/symbols.c
@@ -106,7 +106,7 @@ static void dump_node(struct struct_elem *, char *, unsigned char, unsigned char
 
 static int module_mem_type(ulong, struct load_module *);
 static ulong module_mem_end(ulong, struct load_module *);
-static int _in_module(ulong, struct load_module *, int);
+static int _in_module_range(ulong, struct load_module *, int, int);
 struct syment *value_search_module_v2(ulong, ulong *);
 
 static const char *module_start_tags[];
@@ -3119,7 +3119,10 @@ lowest_module_address(void)
 	lowest = (ulong)(-1);
 	for (i = 0; i < st->mods_installed; i++) {
 		lm = &st->load_modules[i];
-		low = lm->mod_base;
+		if (MODULE_MEMORY())
+			low = lm->mem[lm->address_order[0]].base;
+		else
+			low = lm->mod_base;
 		if (low < lowest)
 			lowest = low;
 	}
@@ -3133,11 +3136,16 @@ highest_module_address(void)
 	int i;
 	struct load_module *lm;
 	ulong high, highest;
+	struct module_memory *mem;
 
 	highest = 0;
 	for (i = 0; i < st->mods_installed; i++) {
 		lm = &st->load_modules[i];
-		high = lm->mod_base + lm->mod_size;
+		if (MODULE_MEMORY()) {
+			mem = &lm->mem[lm->address_order[lm->nr_mems-1]];
+			high = mem->base + mem->size;
+		} else
+			high = lm->mod_base + lm->mod_size;
 		if (high > highest)
 			highest = high;
 	}
@@ -3530,6 +3538,9 @@ is_kernel_text(ulong value)
 	        		if ((value >= start) && (value < end)) 
 	                		return TRUE;
 	                }
+		} else if (MODULE_MEMORY()) {
+			if (IN_MODULE_TEXT(value, lm))
+				return TRUE;
 		} else {
 			switch (kt->flags & (KMOD_V1|KMOD_V2))
 			{
@@ -14157,17 +14168,13 @@ symbol_complete_match(const char *match, struct syment *sp_last)
 }
 
 static int
-_in_module(ulong addr, struct load_module *lm, int type)
+_in_module_range(ulong addr, struct load_module *lm, int start, int end)
 {
 	ulong base, size;
-	int i, last;
+	int i;
 
 	if (MODULE_MEMORY()) {
-		if (type == MOD_TEXT)
-			last = MOD_RO_AFTER_INIT;
-		else
-			last = MOD_INIT_RODATA;
-		for (i = type ; i <= last; i++) {
+		for (i = start ; i <= end; i++) {
 			base = lm->mem[i].base;
 			size = lm->mem[i].size;
 			if (!base)
@@ -14178,7 +14185,7 @@ _in_module(ulong addr, struct load_module *lm, int type)
 		return FALSE;
 	}
 
-	if (type == MOD_TEXT) {
+	if (start == MOD_TEXT) {
 		base = lm->mod_base;
 		size = lm->mod_size;
 	} else {
-- 
2.31.1

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux