From: Andi Kleen <ak@linux.intel.com>
To: "Huang, Kai" <kai.huang@intel.com>
Cc: "kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"seanjc@google.com" <seanjc@google.com>
Subject: Re: [PATCHv2] x86/trampoline: Bypass compat mode in trampoline_start64() if not needed
Date: Mon, 8 Jan 2024 18:26:03 -0800 [thread overview]
Message-ID: <ZZyuu2UZuz8OvZ1B@tassilo> (raw)
In-Reply-To: <b69afad98d043ddfb685982c9977105f1b563485.camel@intel.com>
> This seems depends on the BIOS will always use 4-level paging. Can we make such
> assumption?
Yes I believe it's fine. All BIOS on 5 level capable systems currently
only use 4-level when passing control to someone else.
(although I cannot find the quote in the UEFI spec currently, will check
on that)
The UEFI run time environment is defined as 4-level. Changing that would
break compatibility OS supprt at least for run time services.
>
> > +
> > + /* Paging mode is correct proceed in 64-bit mode */
> > +
> > + LOCK_AND_LOAD_REALMODE_ESP lock_rip=1
> > +
> > + movw $__KERNEL_DS, %dx
> > + movl %edx, %ss
> > + addl $pa_real_mode_base, %esp
> > + movl %edx, %ds
> > + movl %edx, %es
> > + movl %edx, %fs
> > + movl %edx, %gs
> > +
> > + movl $pa_trampoline_pgd, %eax
> > + movq %rax, %cr3
> > +
> > + jmpq *tr_start(%rip)
>
> IIUC you won't be using __KERNEL_CS in this case? Not sure whether this matters
> though, because the spec says in 64-bit mode the hardware treats CS,DS,ES,SS as
> zero.
That's a good catch. Might be better to use __KERNEL_CS. Otherwise if a
IRET happens later and it tries to reload CS it might fault. Probably
doesn't happen before another reload happens anyways, but it's better
to avoid it.
-Andi
next prev parent reply other threads:[~2024-01-09 2:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-07 12:28 [PATCHv2] x86/trampoline: Bypass compat mode in trampoline_start64() if not needed Kirill A. Shutemov
2024-01-08 13:10 ` Huang, Kai
2024-01-08 13:33 ` kirill.shutemov
2024-01-09 2:26 ` Andi Kleen [this message]
2024-01-08 16:18 ` Sean Christopherson
2024-01-08 21:58 ` Kirill A. Shutemov
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=ZZyuu2UZuz8OvZ1B@tassilo \
--to=ak@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kai.huang@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=seanjc@google.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