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]
Message-ID: <20151112085418.GA18963@gmail.com>
Date:	Thu, 12 Nov 2015 09:54:18 +0100
From:	Ingo Molnar <mingo@...nel.org>
To:	"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc:	"Kirill A. Shutemov" <kirill@...temov.name>,
	Borislav Petkov <bp@...en8.de>, hpa@...or.com,
	tglx@...utronix.de, mingo@...hat.com, akpm@...ux-foundation.org,
	linux-mm@...ck.org, linux-kernel@...r.kernel.org, x86@...nel.org,
	jgross@...e.com, konrad.wilk@...cle.com, elliott@....com,
	boris.ostrovsky@...cle.com, Toshi Kani <toshi.kani@....com>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] x86/mm: fix regression with huge pages on PAE


* Kirill A. Shutemov <kirill.shutemov@...ux.intel.com> wrote:

> diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h
> index c5b7fb2774d0..cc071c6f7d4d 100644
> --- a/arch/x86/include/asm/page_types.h
> +++ b/arch/x86/include/asm/page_types.h
> @@ -9,19 +9,21 @@
>  #define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
>  #define PAGE_MASK	(~(PAGE_SIZE-1))
>  
> +#define PMD_PAGE_SIZE		(_AC(1, UL) << PMD_SHIFT)
> +#define PMD_PAGE_MASK		(~(PMD_PAGE_SIZE-1))
> +
> +#define PUD_PAGE_SIZE		(_AC(1, UL) << PUD_SHIFT)
> +#define PUD_PAGE_MASK		(~(PUD_PAGE_SIZE-1))
> +
>  #define __PHYSICAL_MASK		((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1))
>  #define __VIRTUAL_MASK		((1UL << __VIRTUAL_MASK_SHIFT) - 1)
>  
> -/* Cast PAGE_MASK to a signed type so that it is sign-extended if
> +/* Cast *PAGE_MASK to a signed type so that it is sign-extended if
>     virtual addresses are 32-bits but physical addresses are larger
>     (ie, 32-bit PAE). */
>  #define PHYSICAL_PAGE_MASK	(((signed long)PAGE_MASK) & __PHYSICAL_MASK)
> -
> -#define PMD_PAGE_SIZE		(_AC(1, UL) << PMD_SHIFT)
> -#define PMD_PAGE_MASK		(~(PMD_PAGE_SIZE-1))
> -
> -#define PUD_PAGE_SIZE		(_AC(1, UL) << PUD_SHIFT)
> -#define PUD_PAGE_MASK		(~(PUD_PAGE_SIZE-1))
> +#define PHYSICAL_PMD_PAGE_MASK	(((signed long)PMD_PAGE_MASK) & __PHYSICAL_MASK)
> +#define PHYSICAL_PUD_PAGE_MASK	(((signed long)PUD_PAGE_MASK) & __PHYSICAL_MASK)

that's a really odd way of writing it, 'long' is signed by default ...

There seems to be 150+ such cases in the kernel source though - weird.

More importantly, how does this improve things on 32-bit PAE kernels? If I follow 
the values correctly then PMD_PAGE_MASK is 'UL' i.e. 32-bit:

> +#define PMD_PAGE_SIZE                (_AC(1, UL) << PMD_SHIFT)
> +#define PMD_PAGE_MASK                (~(PMD_PAGE_SIZE-1))

thus PHYSICAL_PMD_PAGE_MASK is 32-bit too:

> +#define PHYSICAL_PMD_PAGE_MASK       (((signed long)PMD_PAGE_MASK) & __PHYSICAL_MASK)

so how is the bug fixed?

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ