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: <20130115152254.GC2682@phenom.dumpdata.com>
Date:	Tue, 15 Jan 2013 10:22:54 -0500
From:	Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
To:	Stefano Stabellini <stefano.stabellini@...citrix.com>
Cc:	Yinghai Lu <yinghai@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...e.hu>, "H. Peter Anvin" <hpa@...or.com>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Borislav Petkov <bp@...en8.de>, Jan Kiszka <jan.kiszka@....de>,
	Jason Wessel <jason.wessel@...driver.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v7u1 10/31] x86, 64bit: Don't set max_pfn_mapped wrong
 value early on native path

On Tue, Jan 15, 2013 at 01:48:45PM +0000, Stefano Stabellini wrote:
> On Fri, 4 Jan 2013, Yinghai Lu wrote:
> > We are not having max_pfn_mapped set correctly until init_memory_mapping.
> > 
> > so don't print it initial value for 64bit
> > 
> > Also need to use KERNEL_IMAGE_SIZE directly for highmap cleanup.
> > 
> > Signed-off-by: Yinghai Lu <yinghai@...nel.org>
> > ---
> >  arch/x86/kernel/head64.c |    3 ---
> >  arch/x86/kernel/setup.c  |    2 ++
> >  arch/x86/mm/init_64.c    |    6 +++++-
> >  3 files changed, 7 insertions(+), 4 deletions(-)
> > 
> > diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
> > index a3fc233..7061d8b 100644
> > --- a/arch/x86/kernel/head64.c
> > +++ b/arch/x86/kernel/head64.c
> > @@ -146,9 +146,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
> >  	/* clear bss before set_intr_gate with early_idt_handler */
> >  	clear_bss();
> >  
> > -	/* XXX - this is wrong... we need to build page tables from scratch */
> > -	max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT;
> > -
> >  	for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) {
> >  #ifdef CONFIG_EARLY_PRINTK
> >  		set_intr_gate(i, &early_idt_handlers[i]);
> > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> > index 63160c6..04797e78 100644
> > --- a/arch/x86/kernel/setup.c
> > +++ b/arch/x86/kernel/setup.c
> > @@ -910,8 +910,10 @@ void __init setup_arch(char **cmdline_p)
> >  	setup_bios_corruption_check();
> >  #endif
> >  
> > +#ifdef CONFIG_X86_32
> >  	printk(KERN_DEBUG "initial memory mapped: [mem 0x00000000-%#010lx]\n",
> >  			(max_pfn_mapped<<PAGE_SHIFT) - 1);
> > +#endif
> >  
> >  	reserve_real_mode();
> >  
> > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> > index 9c5f2b1..98385a2 100644
> > --- a/arch/x86/mm/init_64.c
> > +++ b/arch/x86/mm/init_64.c
> > @@ -394,10 +394,14 @@ void __init init_extra_mapping_uc(unsigned long phys, unsigned long size)
> >  void __init cleanup_highmap(void)
> >  {
> >  	unsigned long vaddr = __START_KERNEL_map;
> > -	unsigned long vaddr_end = __START_KERNEL_map + (max_pfn_mapped << PAGE_SHIFT);
> > +	unsigned long vaddr_end = __START_KERNEL_map + KERNEL_IMAGE_SIZE;
> >  	unsigned long end = roundup((unsigned long)_brk_end, PMD_SIZE) - 1;
> >  	pmd_t *pmd = level2_kernel_pgt;
> >  
> > +	/* Xen has its own end somehow with abused max_pfn_mapped */
> > +	if (max_pfn_mapped)
> > +		vaddr_end = __START_KERNEL_map + (max_pfn_mapped << PAGE_SHIFT);
> 
> If you are going to put a comment like that in the code, could you
> please at least add some useful details, rather than a generic
> "somehow"? It doesn't seem very helpful to me or to any other hackers
> looking at the code.

Hm I think I actually pointed out to him in the previous reviews how
we alter it and that he should ingest some of those comments in this
patch.

> 
> The issue is even described as a comment in the code at the beginning of
> arch/x86/xen/mmu.c:xen_setup_kernel_pagetable:
> 
> /* max_pfn_mapped is the last pfn mapped in the initial memory
>  * mappings. Considering that on Xen after the kernel mappings we
>  * have the mappings of some pages that don't exist in pfn space, we
>  * set max_pfn_mapped to the last real pfn mapped. */
> 
> Now if max_pfn_mapped is supposed to represent the last pfn mapped in
> the initial memory mapping, then I think that the way Xen uses
> max_pfn_mapped is actually correct.
> 
> 
> The question is: has max_pfn_mapped actually changed meaning?
> Because if it hasn't I don't see why you need this change.
> 
> 
> 
> >  	for (; vaddr + PMD_SIZE - 1 < vaddr_end; pmd++, vaddr += PMD_SIZE) {
> >  		if (pmd_none(*pmd))
> >  			continue;
> > -- 
> > 1.7.10.4
> > 
> > --
> > 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/
> > 
--
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