From: Borislav Petkov <bp@alien8.de>
To: Jike Song <albcamus@gmail.com>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
David Woodhouse <dwmw@amazon.co.uk>,
Alan Cox <gnomes@lxorguk.ukuu.org.uk>,
Jiri Koshina <jikos@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Tim Chen <tim.c.chen@linux.intel.com>,
Andi Lutomirski <luto@amacapital.net>,
Andi Kleen <ak@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Paul Turner <pjt@google.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Greg KH <gregkh@linux-foundation.org>,
Dave Hansen <dave.hansen@intel.com>,
Kees Cook <keescook@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2] x86/mm/pti: remove dead logic during user pagetable population
Date: Sun, 7 Jan 2018 12:36:55 +0100 [thread overview]
Message-ID: <20180107113655.zaovtpdfyjboccae@pd.tnic> (raw)
In-Reply-To: <20180107103317.22613-1-albcamus@gmail.com>
On Sun, Jan 07, 2018 at 06:33:17PM +0800, Jike Song wrote:
> Look at one of the code snippets:
>
> 162 if (pgd_none(*pgd)) {
> 163 unsigned long new_p4d_page = __get_free_page(gfp);
> 164 if (!new_p4d_page)
> 165 return NULL;
> 166
> 167 if (pgd_none(*pgd)) {
> 168 set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(new_p4d_page)));
> 169 new_p4d_page = 0;
> 170 }
> 171 if (new_p4d_page)
> 172 free_page(new_p4d_page);
> 173 }
>
> There can't be any difference between two pgd_none(*pgd) at L162 and L167,
> so it's always false at L171.
I think this is a remnant from the kaiser version which did this:
if (pud_none(*pud)) {
unsigned long new_pmd_page = __get_free_page(gfp);
if (!new_pmd_page)
return NULL;
spin_lock(&shadow_table_allocation_lock);
if (pud_none(*pud))
set_pud(pud, __pud(_KERNPG_TABLE | __pa(new_pmd_page)));
else
free_page(new_pmd_page);
spin_unlock(&shadow_table_allocation_lock);
}
I was wondering too, why the duplicated checks.
Which has this explanation about the need for the locking:
/*
* At runtime, the only things we map are some things for CPU
* hotplug, and stacks for new processes. No two CPUs will ever
* be populating the same addresses, so we only need to ensure
* that we protect between two CPUs trying to allocate and
* populate the same page table page.
*
* Only take this lock when doing a set_p[4um]d(), but it is not
* needed for doing a set_pte(). We assume that only the *owner*
* of a given allocation will be doing this for _their_
* allocation.
*
* This ensures that once a system has been running for a while
* and there have been stacks all over and these page tables
* are fully populated, there will be no further acquisitions of
* this lock.
*/
static DEFINE_SPINLOCK(shadow_table_allocation_lock);
Now I have my suspicions why that's not needed anymore upstream but I'd
let tglx explain better.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
next prev parent reply other threads:[~2018-01-07 11:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-07 10:33 Jike Song
2018-01-07 11:36 ` Borislav Petkov [this message]
2018-01-07 12:05 ` Thomas Gleixner
2018-01-07 18:34 ` Dave Hansen
2018-01-08 16:03 ` [PATCH v3] " Jike Song
2018-01-08 20:43 ` [tip:x86/pti] x86/mm/pti: Remove dead logic in pti_user_pagetable_walk*() tip-bot for Jike Song
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=20180107113655.zaovtpdfyjboccae@pd.tnic \
--to=bp@alien8.de \
--cc=ak@linux.intel.com \
--cc=albcamus@gmail.com \
--cc=dave.hansen@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=gregkh@linux-foundation.org \
--cc=jikos@kernel.org \
--cc=keescook@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.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®