[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <410ccb21-49d8-4ec0-3f23-07e37c694bbe@intel.com>
Date: Fri, 1 Oct 2021 16:00:44 -0700
From: Sohil Mehta <sohil.mehta@...el.com>
To: Thomas Gleixner <tglx@...utronix.de>,
Andy Lutomirski <luto@...nel.org>,
the arch/x86 maintainers <x86@...nel.org>
CC: Tony Luck <tony.luck@...el.com>,
Dave Hansen <dave.hansen@...el.com>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>, Jens Axboe <axboe@...nel.dk>,
Christian Brauner <christian@...uner.io>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Shuah Khan <shuah@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Jonathan Corbet <corbet@....net>,
Raj Ashok <ashok.raj@...el.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
Gayatri Kammela <gayatri.kammela@...el.com>,
Zeng Guang <guang.zeng@...el.com>,
"Williams, Dan J" <dan.j.williams@...el.com>,
Randy E Witt <randy.e.witt@...el.com>,
"Shankar, Ravi V" <ravi.v.shankar@...el.com>,
Ramesh Thomas <ramesh.thomas@...el.com>,
Linux API <linux-api@...r.kernel.org>,
<linux-arch@...r.kernel.org>,
"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
<linux-kselftest@...r.kernel.org>
Subject: Re: [RFC PATCH 11/13] x86/uintr: Introduce uintr_wait() syscall
On 10/1/2021 2:29 PM, Thomas Gleixner wrote:
> So we'd end up with two XSAVES on context switch. We can simply do:
> XSAVES();
> fpu.state.xtsate.uintr.uinv = 0;
I am a bit confused. Do we need to set UINV to 0 explicitly?
If XSAVES gets called twice during context switch then the UINV in the
XSTATE buffer automatically gets set to 0. Since XSAVES saves the
current UINV value in the MISC_MSR which was already set to 0 by the
previous XSAVES.
Though, this probably happens due to pure luck than intentional design :)
> which allows to do as many XRSTORS in a row as we want. Only the final
> one on the way to user space will have to restore the real vector if the
> register state is not valid:
>
> if (fpu_state_valid()) {
> if (needs_uinv(current)
> wrmsrl(UINV, vector);
> } else {
> if (needs_uinv(current)
> fpu.state.xtsate.uintr.uinv = vector;
> XRSTORS();
> }
I might have missed some subtle difference. Has this logic changed from
what you previously suggested for arch_exit_to_user_mode_prepare()?
if (xrstors_pending)) {
// Update the saved xstate for xrstors
// Unconditionally update the UINV since it could have been
overwritten by calling XSAVES twice.
current->xstate.uintr.uinv = UINTR_NOTIFICATION_VECTOR;
current->xstate.uintr.uirr |= pir;
} else {
// Manually restore UIRR and UINV
rdmsrl(IA32_UINTR_RR, uirr);
wrmsrl(IA32_UINTR_RR, uirr | pir);
misc.val64 = 0;
misc.uittsz = current->uintr->uittsz;
misc.uinv = UINTR_NOTIFICATION_VECTOR;
wrmsrl(IA32_UINTR_MISC, misc.val64);
}
> Hmm?
The one case I can see this failing is if there was another XRSTORS
after the "final" restore in arch_exit_to_user_mode_prepare()? I think
that is not possible but I am not an expert on this. Did I misunderstand
something?
Thanks,
Sohil
Powered by blists - more mailing lists