在 2020年10月07日 00:00, crash-utility-request@xxxxxxxxxx 写道: > Date: Tue, 6 Oct 2020 21:05:39 +0900 > From: HATAYAMA Daisuke <d.hatayama@xxxxxxxxxxx> > To: crash-utility@xxxxxxxxxx > Cc: HATAYAMA Daisuke <d.hatayama@xxxxxxxxxxx> > Subject: [PATCH] sadump: fix help -D lists > uninteresting register entries > Message-ID: <1601985939-1431-1-git-send-email-d.hatayama@xxxxxxxxxxx> > Content-Type: text/plain; charset="US-ASCII" > > Reserved fields in SMRAM CPU states could be non-zero even if the > corresponding APICs are NOT used. This breaks the assumption that > SMRAM CPU state is zero cleared if and only if the APIC corresponding > to the entry is NOT used. As the result, help -D lists uninteresting > entries as below: > > APIC ID: 14 > RIP: 0000000000000000 RSP: 0000000000000000 RBP: 0000000000000000 > RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 > RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 > R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 > R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 > R14: 0000000000000000 R15: 0000000000000000 > SMM REV: 00000000 SMM BASE 00000000 > CS : 00000000 DS: 00000000 SS: 00000000 ES: 00000000 FS: 00000000 > GS : 00000000 > CR0: 0000000000000000 CR3: 0000000000000000 CR4: 00000000 > GDT: 0000000000000000 LDT: 0000000000000000 IDT: 0000000000000000 > GDTlim: 00000000 LDTlim: 00000000 IDTlim: 00000000 > LDTR: 00000000 TR: 00000000 RFLAGS: 0000000000000000 > EPTP: 0000000000000000 EPTP_SETTING: 00000000 > DR6: 0000000000000000 DR7: 0000000000000000 > Ia32Efer: 0000000000000000 > IoMemAddr: 0000000000000000 IoEip: 0000000000000000 > IoMisc: 00000000 LdtInfo: 00000000 > IoInstructionRestart: 0000 AutoHaltRestart: 0000 > > To fix this issue, mask reserved fields before comparison. > Thanks for the fix, HATAYAMA. Acked-by: Lianbo Jiang <lijiang@xxxxxxxxxx> > Signed-off-by: HATAYAMA Daisuke <d.hatayama@xxxxxxxxxxx> > --- > sadump.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/sadump.c b/sadump.c > index 009e17a..f313528 100644 > --- a/sadump.c > +++ b/sadump.c > @@ -51,6 +51,7 @@ 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 uint64_t pfn_to_block(uint64_t pfn); > +static void mask_reserved_fields(struct sadump_smram_cpu_state *smram); > > struct sadump_data * > sadump_get_sadump_data(void) > @@ -1040,6 +1041,15 @@ int sadump_memory_dump(FILE *fp) > "cpu_state\n"); > return FALSE; > } > + /* > + * Reserved fields in SMRAM CPU states could > + * be non-zero even if the corresponding APICs > + * are NOT used. This breaks the assumption > + * that SMRAM CPU state is zero cleared if and > + * only if the APIC corresponding to the entry > + * is NOT used. > + */ > + mask_reserved_fields(&scs); > if (memcmp(&scs, &zero, sizeof(scs)) != 0) { > fprintf(fp, "\n"); > display_smram_cpu_state(aid, &scs); > @@ -1707,3 +1717,15 @@ sadump_get_cr3_idtr(ulong *cr3, ulong *idtr) > return TRUE; > } > #endif /* X86_64 */ > + > +static void > +mask_reserved_fields(struct sadump_smram_cpu_state *smram) > +{ > + memset(smram->Reserved1, 0, sizeof(smram->Reserved1)); > + memset(smram->Reserved2, 0, sizeof(smram->Reserved2)); > + memset(smram->Reserved3, 0, sizeof(smram->Reserved3)); > + memset(smram->Reserved4, 0, sizeof(smram->Reserved4)); > + memset(smram->Reserved5, 0, sizeof(smram->Reserved5)); > + memset(smram->Reserved6, 0, sizeof(smram->Reserved6)); > + memset(smram->Reserved7, 0, sizeof(smram->Reserved7)); > +} > -- 1.8.3.1 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility