Re: [PATCH 2/2 v2] kdump,vmcoreinfo: Export the value of sme mask to vmcoreinfo

From: Dave Young
Date: Wed Dec 05 2018 - 05:24:18 EST


On 12/02/18 at 11:08am, Lianbo Jiang wrote:
> For AMD machine with SME feature, makedumpfile tools need to know
> whether the crash kernel was encrypted or not. If SME is enabled
> in the first kernel, the crash kernel's page table(pgd/pud/pmd/pte)
> contains the memory encryption mask, so need to remove the sme mask
> to obtain the true physical address.
>
> Signed-off-by: Lianbo Jiang <lijiang@xxxxxxxxxx>
> ---
> arch/x86/kernel/machine_kexec_64.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
> index 4c8acdfdc5a7..1860fe24117d 100644
> --- a/arch/x86/kernel/machine_kexec_64.c
> +++ b/arch/x86/kernel/machine_kexec_64.c
> @@ -352,10 +352,24 @@ void machine_kexec(struct kimage *image)
>
> void arch_crash_save_vmcoreinfo(void)
> {
> + u64 sme_mask = sme_me_mask;
> +
> VMCOREINFO_NUMBER(phys_base);
> VMCOREINFO_SYMBOL(init_top_pgt);
> vmcoreinfo_append_str("NUMBER(pgtable_l5_enabled)=%d\n",
> pgtable_l5_enabled());
> + /*
> + * Currently, the local variable 'sme_mask' stores the value of
> + * sme_me_mask(bit 47), and also write the value of sme_mask to
> + * the vmcoreinfo.
> + * If need, the bit(sme_mask) might be redefined in the future,
> + * but the 'bit63' will be reserved.
> + * For example:
> + * [ misc ][ enc bit ][ other misc SME info ]
> + * 0000_0000_0000_0000_1000_0000_0000_0000_0000_0000_..._0000
> + * 63 59 55 51 47 43 39 35 31 27 ... 3
> + */
> + VMCOREINFO_NUMBER(sme_mask);

#define VMCOREINFO_NUMBER(name) \
vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name)

VMCOREINFO_NUMBER is defined as above, so it looks questionable to add
more users of that for different data types although it may work in real
world.

A new macro like below may be better, may need to choose a better name
though:
_VMCOREINFO_NUMBER(name, format, type)
so you can pass the format specifier and data types explictly


>
> #ifdef CONFIG_NUMA
> VMCOREINFO_SYMBOL(node_data);
> --
> 2.17.1
>

Thanks
Dave