[Crash-utility] [PATCH 09/11] Make data relevant to physical memory have 64 bits length
HATAYAMA Daisuke
d.hatayama at jp.fujitsu.com
Thu Oct 20 10:43:01 UTC 2011
On X86 PAE, physical memory exceeds 32 bits and maximal 50 over. By
this, offset relative to dump device files, page frame numbers, blocks
numbers ---as many as page frame numbers in worst case --- and section
numbers must have type of 64 bit length.
Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
---
sadump.c | 39 ++++++++++++++++++++-------------------
sadump.h | 2 +-
2 files changed, 21 insertions(+), 20 deletions(-)
-------------- next part --------------
diff --git a/sadump.c b/sadump.c
index 73a4a6d..9ad5a24 100644
--- a/sadump.c
+++ b/sadump.c
@@ -32,11 +32,11 @@ static int read_dump_header(char *file);
static int add_disk(char *file);
static int open_dump_file(char *file);
static int open_disk(char *file);
-static ulong paddr_to_pfn(physaddr_t paddr);
-static inline int is_set_bit(char *bitmap, ulong pfn);
-static inline int page_is_ram(unsigned int nr);
-static inline int page_is_dumpable(unsigned int nr);
-static int lookup_diskset(ulong whole_offset, int *diskid, ulong *disk_offset);
+static uint64_t paddr_to_pfn(physaddr_t paddr);
+static inline int is_set_bit(char *bitmap, uint64_t pfn);
+static inline int page_is_ram(uint64_t nr);
+static inline int page_is_dumpable(uint64_t nr);
+static int lookup_diskset(uint64_t whole_offset, int *diskid, uint64_t *disk_offset);
static struct tm *efi_time_t_to_tm(const efi_time_t *e);
static char * guid_to_str(efi_guid_t *guid, char *buf, size_t buflen);
static int verify_magic_number(uint32_t magicnum[DUMP_PART_HEADER_MAGICNUM_SIZE]);
@@ -48,7 +48,7 @@ static void display_smram_cpu_state(int apicid, struct sadump_smram_cpu_state *s
static int cpu_to_apicid(int cpu, int *apicid);
static int get_sadump_smram_cpu_state(int cpu, struct sadump_smram_cpu_state *smram);
static int block_table_init(void);
-static ulong pfn_to_block(ulong pfn);
+static uint64_t pfn_to_block(uint64_t pfn);
struct sadump_data *
sadump_get_sadump_data(void)
@@ -684,14 +684,14 @@ uint sadump_page_size(void)
* Translate physical address in paddr to PFN number. This means normally that
* we just shift paddr by some constant.
*/
-static ulong
+static uint64_t
paddr_to_pfn(physaddr_t paddr)
{
return paddr >> sd->block_shift;
}
static inline int
-is_set_bit(char *bitmap, ulong pfn)
+is_set_bit(char *bitmap, uint64_t pfn)
{
ulong index, bit;
@@ -702,25 +702,26 @@ is_set_bit(char *bitmap, ulong pfn)
}
static inline int
-page_is_ram(unsigned int nr)
+page_is_ram(uint64_t nr)
{
return is_set_bit(sd->bitmap, nr);
}
static inline int
-page_is_dumpable(unsigned int nr)
+page_is_dumpable(uint64_t nr)
{
return is_set_bit(sd->dumpable_bitmap, nr);
}
static int
-lookup_diskset(ulong whole_offset, int *diskid, ulong *disk_offset)
+lookup_diskset(uint64_t whole_offset, int *diskid, uint64_t *disk_offset)
{
- ulong offset = whole_offset;
+ uint64_t offset = whole_offset;
int i;
for (i = 0; i < sd->sd_list_len; ++i) {
- ulong used_device_i, data_offset_i, ram_size;
+ uint64_t used_device_i, ram_size;
+ ulong data_offset_i;
used_device_i = sd->sd_list[i]->header->used_device;
data_offset_i = sd->sd_list[i]->data_offset;
@@ -744,7 +745,8 @@ lookup_diskset(ulong whole_offset, int *diskid, ulong *disk_offset)
int read_sadump(int fd, void *bufptr, int cnt, ulong addr, physaddr_t paddr)
{
physaddr_t curpaddr ATTRIBUTE_UNUSED;
- ulong pfn, page_offset, block, whole_offset, perdisk_offset;
+ uint64_t pfn, whole_offset, perdisk_offset, block;
+ ulong page_offset;
int dfd;
pfn = paddr_to_pfn(paddr);
@@ -1529,12 +1531,11 @@ void sadump_show_diskset(void)
static int block_table_init(void)
{
- ulong section, max_section, pfn;
- ulong *block_table;
+ uint64_t pfn, section, max_section, *block_table;
max_section = divideup(sd->dump_header->max_mapnr, SADUMP_PF_SECTION_NUM);
- block_table = calloc(sizeof(ulong), max_section);
+ block_table = calloc(sizeof(uint64_t), max_section);
if (!block_table) {
error(INFO, "sadump: cannot allocate memory for block_table\n");
return FALSE;
@@ -1555,9 +1556,9 @@ static int block_table_init(void)
return TRUE;
}
-static ulong pfn_to_block(ulong pfn)
+static uint64_t pfn_to_block(uint64_t pfn)
{
- ulong block, section, p;
+ uint64_t block, section, p;
section = pfn / SADUMP_PF_SECTION_NUM;
diff --git a/sadump.h b/sadump.h
index 9adffde..d108088 100644
--- a/sadump.h
+++ b/sadump.h
@@ -197,7 +197,7 @@ struct sadump_data {
int block_shift;
char *page_buf;
- ulong *block_table;
+ uint64_t *block_table;
int sd_list_len;
struct sadump_diskset_data **sd_list;
More information about the Crash-utility
mailing list