linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Russell King <linux@armlinux.org.uk>,
	Will Deacon <will@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH 1/2] arm64: mm: drop VM_FAULT_BADMAP/VM_FAULT_BADACCESS
Date: Thu, 11 Apr 2024 19:11:45 +0800	[thread overview]
Message-ID: <9946fd84-7e1c-45c1-8249-36890903760f@huawei.com> (raw)
In-Reply-To: <Zhe0eZMZX4QiZFWV@arm.com>



On 2024/4/11 17:59, Catalin Marinas wrote:
> On Wed, Apr 10, 2024 at 06:58:27PM +0800, Kefeng Wang wrote:
>> On 2024/4/10 9:30, Kefeng Wang wrote:
>>> On 2024/4/9 22:28, Catalin Marinas wrote:
>>>> On Sun, Apr 07, 2024 at 04:12:10PM +0800, Kefeng Wang wrote:
>>>>> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
>>>>> index 405f9aa831bd..61a2acae0dca 100644
>>>>> --- a/arch/arm64/mm/fault.c
>>>>> +++ b/arch/arm64/mm/fault.c
>>>>> @@ -500,9 +500,6 @@ static bool is_write_abort(unsigned long esr)
>>>>>        return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
>>>>>    }
>>>>> -#define VM_FAULT_BADMAP        ((__force vm_fault_t)0x010000)
>>>>> -#define VM_FAULT_BADACCESS    ((__force vm_fault_t)0x020000)
>>>>> -
>>>>>    static int __kprobes do_page_fault(unsigned long far, unsigned
>>>>> long esr,
>>>>>                       struct pt_regs *regs)
>>>>>    {
>>>>> @@ -513,6 +510,7 @@ static int __kprobes do_page_fault(unsigned
>>>>> long far, unsigned long esr,
>>>>>        unsigned int mm_flags = FAULT_FLAG_DEFAULT;
>>>>>        unsigned long addr = untagged_addr(far);
>>>>>        struct vm_area_struct *vma;
>>>>> +    int si_code;
>>>>
>>>> I think we should initialise this to 0. Currently all paths seem to set
>>>> si_code to something meaningful but I'm not sure the last 'else' close
>>>> in this patch is guaranteed to always cover exactly those earlier code
>>>> paths updating si_code. I'm not talking about the 'goto bad_area' paths
>>>> since they set 'fault' to 0 but the fall through after the second (under
>>>> the mm lock) handle_mm_fault().
> [...]
>>>>> +    fault = handle_mm_fault(vma, addr, mm_flags, regs);
>>>>>        /* Quick path to respond to signals */
>>>>>        if (fault_signal_pending(fault, regs)) {
>>>>>            if (!user_mode(regs))
>>>>> @@ -626,13 +628,11 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
>>>>>        mmap_read_unlock(mm);
>>>>>    done:
>>>>> -    /*
>>>>> -     * Handle the "normal" (no error) case first.
>>>>> -     */
>>>>> -    if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP |
>>>>> -                  VM_FAULT_BADACCESS))))
>>>>> +    /* Handle the "normal" (no error) case first. */
>>>>> +    if (likely(!(fault & VM_FAULT_ERROR)))
>>>>>            return 0;
>>
>> Another choice, we set si_code = SEGV_MAPERR here, since normal
>> pagefault don't use si_code, only the error patch need to initialize.
> 
> Yes, I think initialising it here would be fine. That's the fall-through
> case I was concerned about. All the other goto bad_area places already
> initialise si_code.
> 
Thanks for your confirm, will send v2 soon.



  reply	other threads:[~2024-04-11 11:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-07  8:12 [PATCH -next 0/2] mm: remove arch's private VM_FAULT_BADMAP/BADACCESS Kefeng Wang
2024-04-07  8:12 ` [PATCH 1/2] arm64: mm: drop VM_FAULT_BADMAP/VM_FAULT_BADACCESS Kefeng Wang
2024-04-09 14:28   ` Catalin Marinas
2024-04-10  1:30     ` Kefeng Wang
2024-04-10 10:58       ` Kefeng Wang
2024-04-11  9:59         ` Catalin Marinas
2024-04-11 11:11           ` Kefeng Wang [this message]
2024-04-10 11:24   ` Aishwarya TCV
2024-04-10 11:53     ` Kefeng Wang
2024-04-10 12:39       ` Cristian Marussi
2024-04-10 12:48         ` Kefeng Wang
2024-04-10 20:18           ` Andrew Morton
2024-04-07  8:12 ` [PATCH 2/2] arm: " Kefeng Wang

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=9946fd84-7e1c-45c1-8249-36890903760f@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@armlinux.org.uk \
    --cc=will@kernel.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