mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Wei Yang <richard.weiyang@gmail.com>,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Ingo Molnar <mingo@kernel.org>, Steve Wahl <steve.wahl@hpe.com>
Subject: Re: [Patch v3] x86/head/64: remove redundant check on level2_kernel_pgt's _PAGE_PRESENT bit
Date: Mon, 3 Jun 2024 11:50:06 -0700	[thread overview]
Message-ID: <9e9669a6-de37-4140-bdc5-7d660b8427c3@intel.com> (raw)
In-Reply-To: <20240523123539.14260-1-richard.weiyang@gmail.com>

On 5/23/24 05:35, Wei Yang wrote:
> --- a/arch/x86/kernel/head64.c
> +++ b/arch/x86/kernel/head64.c
> @@ -260,8 +260,7 @@ unsigned long __head __startup_64(unsigned long physaddr,
>  
>  	/* fixup pages that are part of the kernel image */
>  	for (; i <= pmd_index((unsigned long)_end); i++)
> -		if (pmd[i] & _PAGE_PRESENT)
> -			pmd[i] += load_delta;
> +		pmd[i] += load_delta;

So, I think this is correct.  But, man, I wish folks would go through
the git history and make it clear that they understand _how_ the code
got the way it is.

I suspect that the original _PAGE_PRESENT check wasn't even necessary if
cleanup_highmap() really did fix things up.  But this commit:

	2aa85f246c18 ("x86/boot/64: Make level2_kernel_pgt pages invalid
		       outside kernel area")

tweaked things to actively clear out PMDs that weren't populated in
Kirill's original loop.  It didn't touch the _PAGE_PRESENT check.  But
it certainly did imply that the PMD doesn't have any holes in it and
there's nothing int he middle that needs _PAGE_PRESENT cleared.

> level2_kernel_pgt compiled with _PAGE_PRESENT set. The check is
> redundant

This isn't super reassuring.  It also depends on nothing having munged
the page tables up to this point.  The code is also a bit cruel in that
it manipulates two different sets of PMDs with the same 'pmd' variable.

Also, is this comment still accurate after '2aa85f246c18'?

>          * Fixup the kernel text+data virtual addresses. Note that
>          * we might write invalid pmds, when the kernel is relocated
>          * cleanup_highmap() fixes this up along with the mappings
>          * beyond _end.


  parent reply	other threads:[~2024-06-03 18:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23 12:35 Wei Yang
2024-05-23 12:40 ` Kirill A . Shutemov
2024-06-03 18:50 ` Dave Hansen [this message]
2024-06-03 21:12   ` Wei Yang
2024-06-11  1:01   ` Wei Yang
2024-07-05  7:12 ` Wei Yang

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=9e9669a6-de37-4140-bdc5-7d660b8427c3@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=richard.weiyang@gmail.com \
    --cc=steve.wahl@hpe.com \
    --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®