Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1489619
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v5 6/6] x86/arch_prctl Add ARCH_[GET|SET]_CPUID |
| Date | 2016-09-23 00:30 +0200 |
| Message-ID | <skkFb-3MU-5@gated-at.bofh.it> (permalink) |
| References | <sjUUp-4cs-9@gated-at.bofh.it> <sjV45-4uN-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Sep 21, 2016 at 11:58 AM, Kyle Huey <me@kylehuey.com> wrote:
> Intel supports faulting on the CPUID instruction beginning with Ivy Bridge.
> When enabled, the processor will fault on attempts to execute the CPUID
> instruction with CPL>0. Exposing this feature to userspace will allow a
> ptracer to trap and emulate the CPUID instruction.
>
> When supported, this feature is controlled by toggling bit 0 of
> MSR_MISC_FEATURES_ENABLES. It is documented in detail in Section 2.3.2 of
> http://www.intel.com/content/dam/www/public/us/en/documents/application-notes/virtualization-technology-flexmigration-application-note.pdf
>
> + if (!test_and_set_thread_flag(TIF_NOCPUID))
> + /*
> + * Must flip the CPU state synchronously with
> + * TIF_NOCPUID in the current running context.
> + */
> + switch_cpuid_faulting(true);
If statements with multiple indented lines should have braces in my
book. See, for example, "goto fail".
static?
> +int set_cpuid_mode(struct task_struct *task, unsigned long val)
static?
> + * Called immediately after a successful exec.
> + */
> +void arch_post_exec(void)
> +{
> + /* If cpuid was previously disabled for this task, re-enable it. */
> + if (test_thread_flag(TIF_NOCPUID))
> + enable_cpuid();
> +}
> diff --git a/fs/exec.c b/fs/exec.c
> index 6fcfb3f..0272b7e 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1287,6 +1287,7 @@ void setup_new_exec(struct linux_binprm * bprm)
> else
> set_dumpable(current->mm, suid_dumpable);
>
> + arch_post_exec();
Let's call this arch_setup_new_exec().
> perf_event_exec();
> __set_task_comm(current, kbasename(bprm->filename), true);
>
> diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
> index 2b5b10e..22a3f61 100644
> --- a/include/linux/thread_info.h
> +++ b/include/linux/thread_info.h
> @@ -130,6 +130,10 @@ static inline void check_object_size(const void *ptr, unsigned long n,
> { }
> #endif /* CONFIG_HARDENED_USERCOPY */
>
> +#ifndef arch_post_exec
> +static inline void arch_post_exec(void) {}
> +#endif
> +
thread_info.h is a weird place for this IMO. Admittedly, elf.h isn't
a whole lot better.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v5 0/6] x86/arch_prctl Add ARCH_[GET|SET]_CPUID for controlling the CPUID instruction Kyle Huey <me@kylehuey.com> - 2016-09-21 21:00 +0200
[PATCH v5 6/6] x86/arch_prctl Add ARCH_[GET|SET]_CPUID Kyle Huey <me@kylehuey.com> - 2016-09-21 21:10 +0200
Re: [PATCH v5 6/6] x86/arch_prctl Add ARCH_[GET|SET]_CPUID Andy Lutomirski <luto@amacapital.net> - 2016-09-23 00:30 +0200
Re: [PATCH v5 6/6] x86/arch_prctl Add ARCH_[GET|SET]_CPUID Kyle Huey <me@kylehuey.com> - 2016-09-26 22:00 +0200
[PATCH v5 2/6] x86/arch_prctl/64 Rename do_arch_prctl to do_arch_prctl_64 Kyle Huey <me@kylehuey.com> - 2016-09-21 21:10 +0200
Re: [PATCH v5 2/6] x86/arch_prctl/64 Rename do_arch_prctl to do_arch_prctl_64 Andy Lutomirski <luto@amacapital.net> - 2016-09-23 00:20 +0200
[PATCH v5 1/6] x86/arch_prctl/64 Use SYSCALL_DEFINE2 to define sys_arch_prctl Kyle Huey <me@kylehuey.com> - 2016-09-21 21:10 +0200
csiph-web