From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
To: kexec@lists.infradead.org
Subject: [PATCH v2 06/14] Initialize internal data according to sadump-related formats
Date: Fri, 28 Oct 2011 18:48:36 +0900 [thread overview]
Message-ID: <20111028094836.20940.7998.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20111028094454.20940.1209.stgit@localhost6.localdomain6>
Set page_size, nr_cpus and time stamp. Also, initialize bitmap table
in the same way as initialize_bitmap_memory() for kdump-compressed
format.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
---
makedumpfile.c | 28 +++++++++++
sadump_info.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sadump_info.h | 36 ++++++++++++++
sadump_mod.h | 2 +
4 files changed, 210 insertions(+), 0 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index 96faf60..c5ea9ce 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -119,6 +119,12 @@ get_max_mapnr(void)
info->max_mapnr = info->dh_memory->max_mapnr;
return TRUE;
}
+
+ if (info->flag_sadump) {
+ info->max_mapnr = sadump_get_max_mapnr();
+ return TRUE;
+ }
+
max_paddr = get_max_paddr();
info->max_mapnr = paddr_to_pfn(max_paddr);
@@ -2305,6 +2311,28 @@ initial(void)
if (!initialize_bitmap_memory())
return FALSE;
+ } else if (info->flag_sadump) {
+ int nr_cpus;
+
+ if (info->flag_elf_dumpfile) {
+ MSG("'-E' option is disable, ");
+ MSG("because %s is sadump %s format.\n",
+ info->name_memory, sadump_format_type_name());
+ return FALSE;
+ }
+
+ set_page_size(sadump_page_size());
+
+ if (!sadump_initialize_bitmap_memory())
+ return FALSE;
+
+ if (!sadump_get_nr_cpus(&nr_cpus))
+ return FALSE;
+
+ set_nr_cpus(nr_cpus);
+
+ (void) sadump_set_timestamp(&info->timestamp);
+
} else if (!get_phys_base())
return FALSE;
diff --git a/sadump_info.c b/sadump_info.c
index 2f66148..2efeb63 100644
--- a/sadump_info.c
+++ b/sadump_info.c
@@ -39,6 +39,7 @@ struct sadump_info {
unsigned long sub_hdr_offset;
uint32_t smram_cpu_state_size;
unsigned long data_offset;
+ unsigned long long *block_table;
};
static char *guid_to_str(efi_guid_t *guid, char *buf, size_t buflen);
@@ -505,6 +506,125 @@ error:
}
int
+sadump_initialize_bitmap_memory(void)
+{
+ struct sadump_header *sh = si->sh_memory;
+ struct dump_bitmap *bmp;
+ unsigned long dumpable_bitmap_offset, dumpable_bitmap_len;
+ unsigned long long section, max_section, pfn;
+ unsigned long long *block_table;
+
+ dumpable_bitmap_offset =
+ si->sub_hdr_offset +
+ sh->block_size * (sh->sub_hdr_size + sh->bitmap_blocks);
+
+ dumpable_bitmap_len = sh->block_size * sh->dumpable_bitmap_blocks;
+
+ bmp = malloc(sizeof(struct dump_bitmap));
+ if (bmp == NULL) {
+ ERRMSG("Can't allocate memory for the memory-bitmap. %s\n",
+ strerror(errno));
+ return FALSE;
+ }
+ bmp->fd = info->fd_memory;
+ bmp->file_name = info->name_memory;
+ bmp->no_block = -1;
+ memset(bmp->buf, 0, BUFSIZE_BITMAP);
+ bmp->offset = dumpable_bitmap_offset;
+
+ max_section = divideup(sh->max_mapnr, SADUMP_PF_SECTION_NUM);
+
+ block_table = calloc(sizeof(unsigned long long), max_section);
+ if (block_table == NULL) {
+ ERRMSG("Can't allocate memory for the block_table. %s\n",
+ strerror(errno));
+ free(bmp);
+ return FALSE;
+ }
+
+ for (section = 0; section < max_section; ++section) {
+ if (section > 0)
+ block_table[section] = block_table[section-1];
+ for (pfn = section * SADUMP_PF_SECTION_NUM;
+ pfn < (section + 1) * SADUMP_PF_SECTION_NUM;
+ ++pfn)
+ if (is_dumpable(bmp, pfn))
+ block_table[section]++;
+ }
+
+ info->bitmap_memory = bmp;
+ si->block_table = block_table;
+
+ return TRUE;
+}
+
+int
+sadump_get_nr_cpus(int *nr_cpus)
+{
+ unsigned long offset;
+ struct sadump_smram_cpu_state scs, zero;
+ uint32_t x_cpu;
+ int count;
+
+ memset(&zero, 0, sizeof(zero));
+
+ offset = si->sub_hdr_offset + sizeof(uint32_t) +
+ si->sh_memory->nr_cpus * sizeof(struct sadump_apic_state);
+
+ count = 0;
+ for (x_cpu = 0; x_cpu < si->sh_memory->nr_cpus; ++x_cpu) {
+ if (!read_device(&scs, sizeof(scs), &offset))
+ return FALSE;
+ if (memcmp(&scs, &zero, sizeof(scs)) != 0)
+ count++;
+ }
+
+ *nr_cpus = count;
+
+ DEBUG_MSG("sadump: nr_cpus: %d\n", *nr_cpus);
+
+ return TRUE;
+}
+
+int
+sadump_set_timestamp(struct timeval *ts)
+{
+ static struct tm t;
+ efi_time_t *e = &si->sph_memory->time_stamp;
+ time_t ti;
+
+ memset(&t, 0, sizeof(t));
+
+ t.tm_sec = e->second;
+ t.tm_min = e->minute;
+ t.tm_hour = e->hour;
+ t.tm_mday = e->day;
+ t.tm_mon = e->month - 1;
+ t.tm_year = e->year - 1900;
+
+ if (e->timezone != EFI_UNSPECIFIED_TIMEZONE)
+ t.tm_hour += e->timezone;
+
+ else
+ DEBUG_MSG("sadump: timezone information is missing\n");
+
+ ti = mktime(&t);
+ if (ti == (time_t)-1)
+ return FALSE;
+
+ ts->tv_sec = ti;
+ ts->tv_usec = 0;
+
+ return TRUE;
+}
+
+unsigned long long
+sadump_get_max_mapnr(void)
+{
+ return si->sh_memory->max_mapnr;
+}
+
+int
sadump_add_diskset_info(char *name_memory)
{
si->num_disks++;
@@ -523,12 +643,34 @@ sadump_add_diskset_info(char *name_memory)
return TRUE;
}
+long
+sadump_page_size(void)
+{
+ return si->sh_memory->block_size;
+}
+
char *
sadump_head_disk_name_memory(void)
{
return si->diskset_info[0].name_memory;
}
+char *
+sadump_format_type_name(void)
+{
+ switch (info->flag_sadump) {
+ case SADUMP_SINGLE_PARTITION:
+ return "single partition";
+ case SADUMP_DISKSET:
+ return "diskset";
+ case SADUMP_MEDIA_BACKUP:
+ return "media backup";
+ case SADUMP_UNKNOWN:
+ return "unknown";
+ }
+ return NULL;
+}
+
void
free_sadump_info(void)
{
@@ -551,6 +693,8 @@ free_sadump_info(void)
}
free(si->diskset_info);
}
+ if (si->block_table)
+ free(si->block_table);
}
#endif /* defined(__x86__) && defined(__x86_64__) */
diff --git a/sadump_info.h b/sadump_info.h
index c54d29f..0a04141 100644
--- a/sadump_info.h
+++ b/sadump_info.h
@@ -25,8 +25,14 @@
#if defined(__x86__) || defined(__x86_64__)
int check_and_get_sadump_header_info(char *filename);
+int sadump_initialize_bitmap_memory(void);
+int sadump_get_nr_cpus(int *nr_cpus);
+int sadump_set_timestamp(struct timeval *ts);
+unsigned long long sadump_get_max_mapnr(void);
int sadump_add_diskset_info(char *name_memory);
+long sadump_page_size(void);
char *sadump_head_disk_name_memory(void);
+char *sadump_format_type_name(void);
void free_sadump_info(void);
static inline int sadump_is_supported_arch(void)
@@ -45,17 +51,47 @@ static inline int check_and_get_sadump_header_info(char *filename)
return TRUE;
}
+static inline int sadump_initialize_bitmap_memory(void)
+{
+ return FALSE;
+}
+
+static inline int sadump_get_nr_cpus(int *nr_cpus)
+{
+ return 0;
+}
+
+static inline int sadump_set_timestamp(struct timeval *ts)
+{
+ return FALSE;
+}
+
+static inline unsigned long long sadump_get_max_mapnr(void)
+{
+ return 0;
+}
+
static inline int sadump_add_diskset_info(char *name_memory)
{
return TRUE;
}
+static inline long sadump_page_size(void)
+{
+ return 0;
+}
+
static inline char *
sadump_head_disk_name_memory(void)
{
return NULL;
}
+static inline char *sadump_format_type_name(void)
+{
+ return NULL;
+}
+
static inline void free_sadump_info(void)
{
return;
diff --git a/sadump_mod.h b/sadump_mod.h
index 3385123..efd059f 100644
--- a/sadump_mod.h
+++ b/sadump_mod.h
@@ -169,6 +169,8 @@ struct sadump_media_header {
char reserve[4044]; // reserve feild
};
+#define SADUMP_PF_SECTION_NUM 4096
+
#endif /* defined(__x86__) && defined(__x86_64__) */
/*
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2011-10-28 9:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-28 9:48 [PATCH v2 00/14] Support Fujitsu Stand Alone Dump Format HATAYAMA Daisuke
2011-10-28 9:48 ` [PATCH v2 01/14] Add sadump module header file HATAYAMA Daisuke
2011-10-28 9:48 ` [PATCH v2 02/14] Extend DumpInfo structure HATAYAMA Daisuke
2011-10-28 9:48 ` [PATCH v2 03/14] Implement command-line processing HATAYAMA Daisuke
2011-10-28 9:48 ` [PATCH v2 04/14] Verify and read VMCORE(s) in sadump-related formats HATAYAMA Daisuke
2011-10-28 9:48 ` [PATCH v2 05/14] Export helpers for bitmap table handling HATAYAMA Daisuke
2011-10-28 9:48 ` HATAYAMA Daisuke [this message]
2011-10-28 9:48 ` [PATCH v2 07/14] Initialize debug information for ELF note extraction HATAYAMA Daisuke
2011-10-28 9:48 ` [PATCH v2 08/14] Implement readmem() interface on sadump-related formats HATAYAMA Daisuke
2011-10-28 9:48 ` [PATCH v2 09/14] Estimate phys_base based on linux_banner position HATAYAMA Daisuke
2011-10-28 9:48 ` [PATCH v2 10/14] Generate and save VMCOREINFO and ELF note information HATAYAMA Daisuke
2011-12-20 8:18 ` Atsushi Kumagai
2011-12-20 9:31 ` HATAYAMA Daisuke
2011-12-21 8:22 ` Atsushi Kumagai
2011-12-21 8:39 ` HATAYAMA Daisuke
2011-10-28 9:49 ` [PATCH v2 11/14] Procees CPUs based on online ones HATAYAMA Daisuke
2011-10-28 9:49 ` [PATCH v2 12/14] Read kexec backup region HATAYAMA Daisuke
2011-10-28 9:49 ` [PATCH v2 13/14] Add description of sadump-related formts in usage information HATAYAMA Daisuke
2011-10-28 9:49 ` [PATCH v2 14/14] Add description of sadump-related formats in manual page HATAYAMA Daisuke
2011-10-28 12:05 ` [PATCH v2 00/14] Support Fujitsu Stand Alone Dump Format tachibana
2011-12-15 6:47 ` HATAYAMA Daisuke
2011-12-15 8:55 ` tachibana
2011-12-15 9:09 ` HATAYAMA Daisuke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111028094836.20940.7998.stgit@localhost6.localdomain6 \
--to=d.hatayama@jp.fujitsu.com \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.