From: "Bae, Chang Seok" <chang.seok.bae@intel.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>, Andi Kleen <ak@linux.intel.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"Shankar, Ravi V" <ravi.v.shankar@intel.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/fsgsbase/64: Fix the base write helper functions
Date: Wed, 31 Oct 2018 18:50:28 +0000 [thread overview]
Message-ID: <362EF130-C3AF-4C3B-883E-48DCBC5EA5C3@intel.com> (raw)
In-Reply-To: <CALCETrUddNZYHKgRarNkHANTnahUCtO5o5YrrNfwCqTmFKGefw@mail.gmail.com>
> On Oct 30, 2018, at 14:25, Andy Lutomirski <luto@kernel.org> wrote:
>
> On Tue, Oct 30, 2018 at 10:28 AM Chang S. Bae <chang.seok.bae@intel.com> wrote:
>>
>> Factor out the code to change index from x86_fsbase_write_cpu() and
>> x86_gsbase_write_cpu_inactive(). Now the code is located in
>> do_arch_prctl_64().
>>
>
>> @@ -359,9 +351,7 @@ unsigned long x86_fsbase_read_task(struct task_struct *task)
>> {
>> unsigned long fsbase;
>>
>> - if (task == current)
>> - fsbase = x86_fsbase_read_cpu();
>> - else if (task->thread.fsindex == 0)
>> + if (task->thread.fsindex == 0)
>
> I'm okay with this change but, if you do it, please add:
>
> WARN_ON_ONCE(task == current);
>
> and make it be in a separate patch.
>
Okay. Let me unchange those read functions, as it does what is claimed to do.
>> gsbase = task->thread.gsbase;
>> else
>> gsbase = x86_fsgsbase_read_task(task, task->thread.gsindex);
>> @@ -392,12 +380,8 @@ int x86_fsbase_write_task(struct task_struct *task, unsigned long fsbase)
>> if (unlikely(fsbase >= TASK_SIZE_MAX))
>> return -EPERM;
>>
>> - preempt_disable();
>> task->thread.fsbase = fsbase;
>> - if (task == current)
>> - x86_fsbase_write_cpu(fsbase);
>> task->thread.fsindex = 0;
>
> I'm confused. You're still setting fsindex to zero here.
>
These task write functions are getting thiner, although I agree
the index update should move out.
> ret = x86_gsbase_write_task(task, arg);
> if (ret == 0) {
> /* ARCH_SET_GS has always overwritten the index and the base. Zero
> is the most sensible value to put in the index, and is the only value
> that makes any sense if FSGSBASE is unavailable. */
> if (task == current)
> loadseg(GS, 0);
> else
> task->thread.gsindex = 0;
> }
Thank you for the clarification. I think writing base should come right after loadseg().
Chang
next prev parent reply other threads:[~2018-10-31 18:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-30 17:27 Chang S. Bae
2018-10-30 17:54 ` Bae, Chang Seok
2018-10-30 21:25 ` Andy Lutomirski
2018-10-31 18:50 ` Bae, Chang Seok [this message]
2018-10-31 18:49 Chang S. Bae
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=362EF130-C3AF-4C3B-883E-48DCBC5EA5C3@intel.com \
--to=chang.seok.bae@intel.com \
--cc=ak@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=ravi.v.shankar@intel.com \
--cc=tglx@linutronix.de \
/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®