From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Kyle Pelton <kyle.d.pelton@intel.com>,
Baoquan He <bhe@redhat.com>
Subject: Re: [PATCH] x86/mm: Handle physical-virtual alignment mismatch in phys_p4d_init()
Date: Fri, 21 Jun 2019 02:15:47 +0300 [thread overview]
Message-ID: <20190620231547.dkefu73blzte32wq@black.fi.intel.com> (raw)
In-Reply-To: <4ecd0603-e847-1cae-bafa-e892d79b7259@intel.com>
On Thu, Jun 20, 2019 at 02:42:55PM +0000, Dave Hansen wrote:
> On 6/20/19 4:22 AM, Kirill A. Shutemov wrote:
> > The commit relaxes KASLR alignment requirements and it can lead to
> > mismatch bentween 'i' and 'p4d_index(vaddr)' inside the loop in
> > phys_p4d_init(). The mismatch in its turn leads to clearing wrong p4d
> > entry and eventually to the oops.
>
> Just curious, but what does it relax the requirement to and from?
>
> I'm just not clearly spotting the actual bug.
Before the commit PAGE_OFFSET is always aligned to P4D_SIZE if we boot in
5-level paging mode. But now only PUD_SIZE alignment is guaranteed.
For phys_p4d_init() it means that paddr_next after the first iteration
can belong to the same p4d entry.
In the case I was able to reproduce the vaddr on the first iteration is
0xff4228027fe00000 and paddr is 0x33fe00000. On the second iteration vaddr
becomes 0xff42287f40000000 and paddr is 0x8000000000. The vaddr in both
cases bolong to the same p4d entry.
It screws up 'i' count: we miss the last entry in the page table
completely. And it confuses the branch under 'paddr >= paddr_end'
condition: the p4d entry can be cleared where must not to.
The patch makes phys_p4d_init() work like __kernel_physical_mapping_init()
which deals with phys-virt mismatch already.
I hope this explanation makes any sense :P
--
Kirill A. Shutemov
next prev parent reply other threads:[~2019-06-20 23:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 11:22 Kirill A. Shutemov
2019-06-20 14:42 ` Dave Hansen
2019-06-20 23:15 ` Kirill A. Shutemov [this message]
2019-06-20 23:27 ` Dave Hansen
2019-06-23 11:27 ` Thomas Gleixner
2019-06-21 9:02 ` Baoquan He
2019-06-21 10:54 ` Kirill A. Shutemov
2019-06-24 10:07 ` Baoquan He
2019-06-24 12:23 ` Kirill A. Shutemov
2019-06-24 13:43 ` Baoquan He
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=20190620231547.dkefu73blzte32wq@black.fi.intel.com \
--to=kirill.shutemov@linux.intel.com \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kirill@shutemov.name \
--cc=kyle.d.pelton@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®