lkml.org 
[lkml]   [2019]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] powerpc/64s: Fix possible corruption on big endian due to pgd/pud_present()
    Hi all,

    On Sat, Feb 16, 2019 at 09:55:11PM +1100, Balbir Singh wrote:
    > On Thu, Feb 14, 2019 at 05:23:39PM +1100, Michael Ellerman wrote:
    > > In v4.20 we changed our pgd/pud_present() to check for _PAGE_PRESENT
    > > rather than just checking that the value is non-zero, e.g.:
    > >
    > > static inline int pgd_present(pgd_t pgd)
    > > {
    > > - return !pgd_none(pgd);
    > > + return (pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT));
    > > }
    > >
    > > Unfortunately this is broken on big endian, as the result of the
    > > bitwise && is truncated to int, which is always zero because

    (Bitwise "&" of course).

    > Not sure why that should happen, why is the result an int? What
    > causes the casting of pgd_t & be64 to be truncated to an int.

    Yes, it's not obvious as written... It's simply that the return type of
    pgd_present is int. So it is truncated _after_ the bitwise and.


    Segher

    \
     
     \ /
      Last update: 2019-02-16 15:27    [W:2.338 / U:0.052 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site