public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Russell King <rmk+kernel@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org,
	 Anshuman Khandual <anshuman.khandual@arm.com>,
	 Thomas Gleixner <tglx@linutronix.de>,
	Allison Randal <allison@lohutok.net>,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ARM: update __swp_entry_to_pte() to use PTE_TYPE_FAULT
Date: Thu, 20 May 2021 19:41:03 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.2105201917270.5752@eggly.anvils> (raw)
In-Reply-To: <E1lh9VH-0002Lz-Pd@rmk-PC.armlinux.org.uk>

On Thu, 13 May 2021, Russell King wrote:

> Swap entries use a faulting PTE which have the least two significant
> bits as zero. Due to this, the use of PTE_TYPE_FAULT was overlooked,
> but really should have been included in __swp_entry_to_pte().
> 
> Convert this macro to use PTE_TYPE_FAULT to properly document what is
> going on here, and use __pte() to convert the swp_entry_t to a pte_t.
> 
> This results in no change to the resulting kernel text.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Hmm.  Speaking as one who occasionally has to trawl through all
the architectures considering their __swp_entry() implementations,
I would much prefer you to drop this patch: I don't think it helps
anyone to insist on ORing in (something which when one searches
further turns out to be) 0.

But if you really want to keep it, please remember it's not just
__swp_entry_to_pte() that "needs" changing: __pte_to_swp_entry()
ought to mask it off, pte_clear() ought to set it, pte_none()
ought to compare against it, page table initialization ought
to memset with it, and probably more :)

Thanks,
Hugh

> ---
>  arch/arm/include/asm/pgtable.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
> index c02f24400369..c43e07d6046d 100644
> --- a/arch/arm/include/asm/pgtable.h
> +++ b/arch/arm/include/asm/pgtable.h
> @@ -303,7 +303,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
>  #define __swp_entry(type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) })
>  
>  #define __pte_to_swp_entry(pte)	((swp_entry_t) { pte_val(pte) })
> -#define __swp_entry_to_pte(swp)	((pte_t) { (swp).val })
> +#define __swp_entry_to_pte(swp)	__pte((swp).val | PTE_TYPE_FAULT)
>  
>  /*
>   * It is an error for the kernel to have more swap files than we can
> -- 
> 2.20.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      parent reply	other threads:[~2021-05-21  2:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13 11:27 [PATCH] ARM: update __swp_entry_to_pte() to use PTE_TYPE_FAULT Russell King
2021-05-17  7:47 ` Anshuman Khandual
2021-05-21  2:41 ` Hugh Dickins [this message]

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=alpine.LSU.2.11.2105201917270.5752@eggly.anvils \
    --to=hughd@google.com \
    --cc=allison@lohutok.net \
    --cc=anshuman.khandual@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=tglx@linutronix.de \
    /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