[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d809734-af87-cbf6-80b4-5b10bd819b35@intel.com>
Date: Mon, 27 Sep 2021 16:57:29 -0700
From: Sohil Mehta <sohil.mehta@...el.com>
To: Thomas Gleixner <tglx@...utronix.de>, <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>,
Andy Lutomirski <luto@...nel.org>,
Jens Axboe <axboe@...nel.dk>,
Christian Brauner <christian@...uner.io>,
Peter Zijlstra <peterz@...radead.org>,
Shuah Khan <shuah@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Jonathan Corbet <corbet@....net>,
Ashok Raj <ashok.raj@...el.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
"Gayatri Kammela" <gayatri.kammela@...el.com>,
Zeng Guang <guang.zeng@...el.com>,
"Dan Williams" <dan.j.williams@...el.com>,
Randy E Witt <randy.e.witt@...el.com>,
Ravi V Shankar <ravi.v.shankar@...el.com>,
Ramesh Thomas <ramesh.thomas@...el.com>,
<linux-api@...r.kernel.org>, <linux-arch@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>
Subject: Re: [RFC PATCH 06/13] x86/uintr: Introduce uintr receiver syscalls
On 9/23/2021 4:52 PM, Thomas Gleixner wrote:
> On Mon, Sep 13 2021 at 13:01, Sohil Mehta wrote:
>
> +/* UPID Notification control status */
> +#define UPID_ON 0x0 /* Outstanding notification */
> +#define UPID_SN 0x1 /* Suppressed notification */
> Come on. This are bits in upid.status, right? So why can't the comment
> above these defines says so and why can't the names not reflect that?
I'll fix this.
>> +struct uintr_upid_ctx {
>> + struct uintr_upid *upid;
>> + refcount_t refs;
> Please use tabular format for struct members.
Will do.
>> +};
>> +
>> +struct uintr_receiver {
>> + struct uintr_upid_ctx *upid_ctx;
>> +};
> So we need a struct to wrap a pointer to another struct. Why?
The struct will have more members added later. Should the wrapper be
created then?
I didn't want to add members that are not used in this patch.
>> +inline bool uintr_arch_enabled(void)
> What's this arch_enabled indirection for? Is this used anywhere in
> non-architecture code?
I'll remove this indirection.
It is a remnant of some older code that had uintr_fd managed outside of
the x86 code.
>> +{
>> + return static_cpu_has(X86_FEATURE_UINTR);
>> +}
>> +
>> +static inline bool is_uintr_receiver(struct task_struct *t)
>> +{
>> + return !!t->thread.ui_recv;
>> +}
>> +
>> +static inline u32 cpu_to_ndst(int cpu)
>> +{
>> + u32 apicid = (u32)apic->cpu_present_to_apicid(cpu);
>> +
>> + WARN_ON_ONCE(apicid == BAD_APICID);
> Brilliant. If x2apic is not enabled then this case returns
I'll fix this.
>> + if (!x2apic_enabled())
>> + return (apicid << 8) & 0xFF00;
> (BAD_APICID << 8) & 0xFF00 == 0xFF ....
>
>> +int do_uintr_unregister_handler(void)
>> +{
>> + struct task_struct *t = current;
>> + struct fpu *fpu = &t->thread.fpu;
>> + struct uintr_receiver *ui_recv;
>> + u64 msr64;
>> +
>> + if (!is_uintr_receiver(t))
>> + return -EINVAL;
>> +
>> + pr_debug("recv: Unregister handler and clear MSRs for task=%d\n",
>> + t->pid);
>> +
>> + /*
>> + * TODO: Evaluate usage of fpregs_lock() and get_xsave_addr(). Bugs
>> + * have been reported recently for PASID and WRPKRU.
> Again. Which bugs and why haven't they been evaluated before posting?
I apologize again. This comment is no longer valid.
>> + * UPID and ui_recv will be referenced during context switch. Need to
>> + * disable preemption while modifying the MSRs, UPID and ui_recv thread
>> + * struct.
>> + */
>> + fpregs_lock();
> And because you need to disable preemption you need to use
> fpregs_lock(), right? That's not what fpregs_lock() is about.
>
Got it. I'll evaluate the use of fpregs_lock() at all places.
>> + wrmsrl(MSR_IA32_UINTR_MISC, msr64);
>> + wrmsrl(MSR_IA32_UINTR_PD, 0ULL);
>> + wrmsrl(MSR_IA32_UINTR_RR, 0ULL);
>> + wrmsrl(MSR_IA32_UINTR_STACKADJUST, 0ULL);
>> + wrmsrl(MSR_IA32_UINTR_HANDLER, 0ULL);
>> + } else {
>> + struct uintr_state *p;
>> +
>> + p = get_xsave_addr(&fpu->state.xsave, XFEATURE_UINTR);
>> + if (p) {
>> + p->handler = 0;
>> + p->stack_adjust = 0;
>> + p->upid_addr = 0;
>> + p->uinv = 0;
>> + p->uirr = 0;
>> + }
> So p == NULL is expected here?
I'll fix this and other usages of get_xsave_addr().
Thanks,
Sohil
Powered by blists - more mailing lists