Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bhupesh Sharma <bhsharma@redhat.com>
To: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Cc: "kexec@lists.infradead.org" <kexec@lists.infradead.org>
Subject: Re: [PATCH v2 1/2] makedumpfile/arm64: Add support for ARMv8.2-LPA (52-bit PA support)
Date: Tue, 26 Feb 2019 11:01:21 +0530	[thread overview]
Message-ID: <d3dee972-8549-d525-e62c-e4828d8c4813@redhat.com> (raw)
In-Reply-To: <4AE2DC15AC0B8543882A74EA0D43DBEC03568E41@BPXM09GP.gisp.nec.co.jp>

Hi Kazu,

On 02/22/2019 09:54 PM, Kazuhito Hagio wrote:
> Hi Bhupesh,
> 
> -----Original Message-----
>> Hi Kazu,
>>
>> Thanks for the review.
>>
>> On 02/21/2019 09:05 PM, Kazuhito Hagio wrote:
>>> Hi Bhupesh,
>>>
>>> -----Original Message-----
>>>> ARMv8.2-LPA architecture extension (if available on underlying hardware)
>>>> can support 52-bit physical addresses, while the kernel virtual
>>>> addresses remain 48-bit.
>>>>
>>>> This patch is in accordance with ARMv8 Architecture Reference Manual
>>>> version D.a
>>>>
>>>> Make sure that we read the 52-bit PA address capability from
>>>> 'MAX_PHYSMEM_BITS' variable (if available in vmcoreinfo) and
>>>> accordingly change the pte_to_phy() mask values and also traverse
>>>> the page-table walk accordingly.
>>>>
>>>> Also make sure that it works well for the existing 48-bit PA address
>>>> platforms and also on environments which use newer kernels with 52-bit
>>>> PA support but hardware which is not ARM8.2-LPA compliant.
>>>>
>>>> I have sent a kernel patch upstream to add 'MAX_PHYSMEM_BITS' to
>>>> vmcoreinfo for arm64 (see [0]).
>>>>
>>>> [0]. http://lists.infradead.org/pipermail/kexec/2019-February/022411.html
>>>>
>>>> Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
>>>
>>> This patch looks good to me.
>>> For two slight things below, I will remove them when merging.
>>>
>>>> +/*
>>>> + * Size mapped by an entry at level n ( 0 <= n <= 3)
>>>> + * We map (PAGE_SHIFT - 3) at all translation levels and PAGE_SHIFT bits
>>>> + * in the final page. The maximum number of translation levels supported by
>>>> + * the architecture is 4. Hence, starting at at level n, we have further
>>>> + * ((4 - n) - 1) levels of translation excluding the offset within the page.
>>>> + * So, the total number of bits mapped by an entry at level n is :
>>>> + *
>>>> + *  ((4 - n) - 1) * (PAGE_SHIFT - 3) + PAGE_SHIFT
>>>> + *
>>>> + * Rearranging it a bit we get :
>>>> + *   (4 - n) * (PAGE_SHIFT - 3) + 3
>>>> + */
>>>
>>> Will remove this comment.
>>
>> Ok.
>>
>>>> +#define pmd_offset_pgtbl_lvl_2(dir, vaddr) ((pmd_t *)dir)
>>>> +#define pmd_offset_pgtbl_lvl_3(dir, vaddr) (pud_page_paddr((*(dir))) + pmd_index(vaddr) *
>> sizeof(pmd_t))
>>>
>>> Will remove these two macros not in use.
>>
>> Ok.
>>
>>>
>>> And, as I said on another thread, I'm thinking to merge the following
>>> patch after your patch 1/2, it tested OK with 48-bit and 52-bit PA
>>> without NUMBER(MAX_PHYSMEM_BITS) in vmcoreinfo.
>>> Do you think of any case that this will not work well?
>>>
>>> diff --git a/arch/arm64.c b/arch/arm64.c
>>> index 29247a7..c7e60e0 100644
>>> --- a/arch/arm64.c
>>> +++ b/arch/arm64.c
>>> @@ -127,6 +127,9 @@ typedef unsigned long pgdval_t;
>>>     */
>>>    #define SECTIONS_SIZE_BITS	30
>>>
>>> +#define _MAX_PHYSMEM_BITS_48	48
>>> +#define _MAX_PHYSMEM_BITS_52	52
>>> +
>>>    /*
>>>     * Hardware page table definitions.
>>>     *
>>> @@ -402,17 +405,27 @@ get_stext_symbol(void)
>>>    	return(found ? kallsym : FALSE);
>>>    }
>>>
>>> +static int
>>> +set_max_physmem_bits_arm64(void)
>>> +{
>>> +	long array_len = ARRAY_LENGTH(mem_section);
>>> +
>>> +	info->max_physmem_bits = _MAX_PHYSMEM_BITS_48;
>>> +	if ((array_len == (NR_MEM_SECTIONS() / _SECTIONS_PER_ROOT_EXTREME()))
>>> +		|| (array_len == (NR_MEM_SECTIONS() / _SECTIONS_PER_ROOT())))
>>> +		return TRUE;
>>> +
>>> +	info->max_physmem_bits = _MAX_PHYSMEM_BITS_52;
>>> +	if ((array_len == (NR_MEM_SECTIONS() / _SECTIONS_PER_ROOT_EXTREME()))
>>> +		|| (array_len == (NR_MEM_SECTIONS() / _SECTIONS_PER_ROOT())))
>>> +		return TRUE;
>>> +
>>> +	return FALSE;
>>> +}
>>> +
>>>    int
>>>    get_machdep_info_arm64(void)
>>>    {
>>> -	/* Determine if the PA address range is 52-bits: ARMv8.2-LPA */
>>> -	if (NUMBER(MAX_PHYSMEM_BITS) != NOT_FOUND_NUMBER) {
>>> -		info->max_physmem_bits = NUMBER(MAX_PHYSMEM_BITS);
>>> -		if (info->max_physmem_bits == 52)
>>> -			lpa_52_bit_support_available = 1;
>>> -	} else
>>> -		info->max_physmem_bits = 48;
>>> -
>>>    	/* Check if va_bits is still not initialized. If still 0, call
>>>    	 * get_versiondep_info() to initialize the same.
>>>    	 */
>>> @@ -428,9 +441,24 @@ get_machdep_info_arm64(void)
>>>    	info->section_size_bits = SECTIONS_SIZE_BITS;
>>>
>>>    	DEBUG_MSG("kimage_voffset   : %lx\n", kimage_voffset);
>>> -	DEBUG_MSG("max_physmem_bits : %ld\n", info->max_physmem_bits);
>>>    	DEBUG_MSG("section_size_bits: %ld\n", info->section_size_bits);
>>>
>>> +	/* Determine if the PA address range is 52-bits: ARMv8.2-LPA */
>>> +	if (NUMBER(MAX_PHYSMEM_BITS) != NOT_FOUND_NUMBER) {
>>> +		info->max_physmem_bits = NUMBER(MAX_PHYSMEM_BITS);
>>> +		DEBUG_MSG("max_physmem_bits : %ld (vmcoreinfo)\n",
>>> +				info->max_physmem_bits);
>>> +	} else if (set_max_physmem_bits_arm64()) {
>>> +		DEBUG_MSG("max_physmem_bits : %ld (detected)\n",
>>> +				info->max_physmem_bits);
>>> +	} else {
>>> +		ERRMSG("Can't determine max_physmem_bits value\n");
>>> +		return FALSE;
>>> +	}
>>> +
>>> +	if (info->max_physmem_bits == 52)
>>> +		lpa_52_bit_support_available = 1;
>>> +
>>>    	return TRUE;
>>>    }
>>
>> I have not tested the above suggestion on a real hardware or emulation
>> model yet, but as we were discussing in the kernel patch review thread
>> (see [0]), IMO, we don't need to carry the above hoops for
>> 'MAX_PHYSMEM_BITS' calculation in makedumpfile code as it makes the code
>> less portable for a newer kernel version and also since other user-space
>> utilities (like crash) also need a mechanism to determine the PA_BITS
>> supported by the underlying kernel, so we can use the same uniform
>> method of using an exported 'MAX_PHYSMEM_BITS' value in the vmcoreinfo
>> so that all user-land applications can use the same.
>>
>> I think Dave A. (crash utility maintainer) also pointed to a similar
>> concern in the above thread.
> 
> I see. As I replied [1], I also think ideally we should export it.
> [1] http://lists.infradead.org/pipermail/kexec/2019-February/022474.html
> 
> Can we export it from kernel/crash_core.c?
> I'd like to avoid repeating such a discussion every time we need it
> for each architecture..

Sure. I will try and convince the maintainers of other archs (x86 and  
ppc) for a common export via 'kernel/crash_core.c'. I will continue this  
discussion with the other maintainers on the kernel thread.

In the meanwhile, from makedumpfile p-o-v, I will send a v3 to address  
your concerns on the LVA patch (v1), which I seem to have missed while  
sending out the v2.

Thanks,
Bhupesh



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2019-02-26  5:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-16 20:24 [PATCH v2 0/2] makedumpfile/arm64: Add support for ARMv8.2 extensions Bhupesh Sharma
2019-02-16 20:24 ` [PATCH v2 1/2] makedumpfile/arm64: Add support for ARMv8.2-LPA (52-bit PA support) Bhupesh Sharma
2019-02-21 15:35   ` Kazuhito Hagio
2019-02-22  4:50     ` Bhupesh Sharma
2019-02-22 16:24       ` Kazuhito Hagio
2019-02-26  5:31         ` Bhupesh Sharma [this message]
2019-02-16 20:24 ` [PATCH v2 2/2] makedumpfile/arm64: Add support for ARMv8.2-LVA (52-bit user-space VA support) Bhupesh Sharma

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=d3dee972-8549-d525-e62c-e4828d8c4813@redhat.com \
    --to=bhsharma@redhat.com \
    --cc=k-hagio@ab.jp.nec.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox