lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 1 Aug 2022 18:29:16 -0400
From:   Peter Xu <peterx@...hat.com>
To:     "Huang, Ying" <ying.huang@...el.com>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Andrea Arcangeli <aarcange@...hat.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        "Kirill A . Shutemov" <kirill@...temov.name>,
        Nadav Amit <nadav.amit@...il.com>,
        Hugh Dickins <hughd@...gle.com>,
        David Hildenbrand <david@...hat.com>,
        Vlastimil Babka <vbabka@...e.cz>
Subject: Re: [PATCH RFC 1/4] mm/swap: Add swp_offset_pfn() to fetch PFN from
 swap entry

On Mon, Aug 01, 2022 at 11:13:58AM +0800, Huang, Ying wrote:
> > +/*
> > + * This should only be called upon a pfn swap entry to get the PFN stored
> > + * in the swap entry.  Please refers to is_pfn_swap_entry() for definition
> > + * of pfn swap entry.
> > + */
> > +static inline unsigned long swp_offset_pfn(swp_entry_t entry)
> > +{
> 
> Is it good to call is_pfn_swap_entry() here for debug that can be
> eliminated in the production kernel?

Sure, I'll add a VM_BUG_ON() there in the next spin.

> 
> > +	return swp_offset(entry) & SWP_PFN_MASK;
> > +}
> > +
> >  /* check whether a pte points to a swap entry */
> >  static inline int is_swap_pte(pte_t pte)
> >  {
> > @@ -369,7 +387,7 @@ static inline int pte_none_mostly(pte_t pte)
> >  
> >  static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry)
> >  {
> > -	struct page *p = pfn_to_page(swp_offset(entry));
> > +	struct page *p = pfn_to_page(swp_offset_pfn(entry));
> >  
> >  	/*
> >  	 * Any use of migration entries may only occur while the
> > @@ -387,6 +405,9 @@ static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry)
> >   */
> >  static inline bool is_pfn_swap_entry(swp_entry_t entry)
> >  {
> > +	/* Make sure the swp offset can always store the needed fields */
> > +	BUILD_BUG_ON(SWP_TYPE_SHIFT < SWP_PFN_BITS);
> 
> 	BUILD_BUG_ON(SWP_TYPE_SHIFT <= SWP_PFN_BITS);

Logiclaly it's okay to have SWP_TYPE_SHIFT==SWP_PFN_BITS?

Thanks,

-- 
Peter Xu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ