From: Andy Lutomirski <luto@amacapital.net> To: Yu-cheng Yu <yu-cheng.yu@intel.com> Cc: LKML <linux-kernel@vger.kernel.org>, linux-doc@vger.kernel.org, Linux-MM <linux-mm@kvack.org>, linux-arch <linux-arch@vger.kernel.org>, X86 ML <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, "H. J. Lu" <hjl.tools@gmail.com>, "Shanbhogue, Vedvyas" <vedvyas.shanbhogue@intel.com>, "Ravi V. Shankar" <ravi.v.shankar@intel.com>, Dave Hansen <dave.hansen@linux.intel.com>, Jonathan Corbet <corbet@lwn.net>, Oleg Nesterov <oleg@redhat.com>, Arnd Bergmann <arnd@arndb.de>, mike.kravetz@oracle.com Subject: Re: [PATCH 7/7] x86/cet: Add PTRACE interface for CET Date: Thu, 7 Jun 2018 11:32:36 -0700 [thread overview] Message-ID: <CALCETrXx4FHLad8XhrP-RrBtXnmALf7Myy4wVO+u-SKxa_D01Q@mail.gmail.com> (raw) In-Reply-To: <20180607143855.3681-8-yu-cheng.yu@intel.com> On Thu, Jun 7, 2018 at 7:42 AM Yu-cheng Yu <yu-cheng.yu@intel.com> wrote: > > Add PTRACE interface for CET MSRs. > > Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com> > --- > arch/x86/include/asm/fpu/regset.h | 7 ++++--- > arch/x86/kernel/fpu/regset.c | 41 +++++++++++++++++++++++++++++++++++++++ > arch/x86/kernel/ptrace.c | 16 +++++++++++++++ > include/uapi/linux/elf.h | 1 + > 4 files changed, 62 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/include/asm/fpu/regset.h b/arch/x86/include/asm/fpu/regset.h > index d5bdffb9d27f..edad0d889084 100644 > --- a/arch/x86/include/asm/fpu/regset.h > +++ b/arch/x86/include/asm/fpu/regset.h > @@ -7,11 +7,12 @@ > > #include <linux/regset.h> > > -extern user_regset_active_fn regset_fpregs_active, regset_xregset_fpregs_active; > +extern user_regset_active_fn regset_fpregs_active, regset_xregset_fpregs_active, > + cetregs_active; > extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get, > - xstateregs_get; > + xstateregs_get, cetregs_get; > extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set, > - xstateregs_set; > + xstateregs_set, cetregs_set; > > /* > * xstateregs_active == regset_fpregs_active. Please refer to the comment > diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c > index bc02f5144b95..7008eb084d36 100644 > --- a/arch/x86/kernel/fpu/regset.c > +++ b/arch/x86/kernel/fpu/regset.c > @@ -160,6 +160,47 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset, > return ret; > } > > +int cetregs_active(struct task_struct *target, const struct user_regset *regset) > +{ > +#ifdef CONFIG_X86_INTEL_CET > + if (target->thread.cet.shstk_enabled || target->thread.cet.ibt_enabled) > + return regset->n; > +#endif > + return 0; > +} > + > +int cetregs_get(struct task_struct *target, const struct user_regset *regset, > + unsigned int pos, unsigned int count, > + void *kbuf, void __user *ubuf) > +{ > + struct fpu *fpu = &target->thread.fpu; > + struct cet_user_state *cetregs; > + > + if (!boot_cpu_has(X86_FEATURE_SHSTK)) > + return -ENODEV; This whole series has a boot_cpu_has, static_cpu_has, and cpu_feature_enabled all over. Please settle on just one, preferably static_cpu_has. > + > + cetregs = get_xsave_addr(&fpu->state.xsave, XFEATURE_MASK_SHSTK_USER); > + > + fpu__prepare_read(fpu); > + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, cetregs, 0, -1); > +} > + > +int cetregs_set(struct task_struct *target, const struct user_regset *regset, > + unsigned int pos, unsigned int count, > + const void *kbuf, const void __user *ubuf) > +{ > + struct fpu *fpu = &target->thread.fpu; > + struct cet_user_state *cetregs; > + > + if (!boot_cpu_has(X86_FEATURE_SHSTK)) > + return -ENODEV; > + > + cetregs = get_xsave_addr(&fpu->state.xsave, XFEATURE_MASK_SHSTK_USER); > + > + fpu__prepare_write(fpu); > + return user_regset_copyin(&pos, &count, &kbuf, &ubuf, cetregs, 0, -1); Is this called for core dumping on current? If so, please make sure it's correct. (I think it is for get but maybe not for set.)
WARNING: multiple messages have this Message-ID (diff)
From: Andy Lutomirski <luto@amacapital.net> To: Yu-cheng Yu <yu-cheng.yu@intel.com> Cc: LKML <linux-kernel@vger.kernel.org>, linux-doc@vger.kernel.org, Linux-MM <linux-mm@kvack.org>, linux-arch <linux-arch@vger.kernel.org>, X86 ML <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, "H. J. Lu" <hjl.tools@gmail.com>, "Shanbhogue, Vedvyas" <vedvyas.shanbhogue@intel.com>, "Ravi V. Shankar" <ravi.v.shankar@intel.com>, Dave Hansen <dave.hansen@linux.intel.com>, Jonathan Corbet <corbet@lwn.net>, Oleg Nesterov <oleg@redhat.com>, Arnd Bergmann <arnd@arndb.de>, mike.kravetz@oracle.com Subject: Re: [PATCH 7/7] x86/cet: Add PTRACE interface for CET Date: Thu, 7 Jun 2018 11:32:36 -0700 [thread overview] Message-ID: <CALCETrXx4FHLad8XhrP-RrBtXnmALf7Myy4wVO+u-SKxa_D01Q@mail.gmail.com> (raw) In-Reply-To: <20180607143855.3681-8-yu-cheng.yu@intel.com> On Thu, Jun 7, 2018 at 7:42 AM Yu-cheng Yu <yu-cheng.yu@intel.com> wrote: > > Add PTRACE interface for CET MSRs. > > Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com> > --- > arch/x86/include/asm/fpu/regset.h | 7 ++++--- > arch/x86/kernel/fpu/regset.c | 41 +++++++++++++++++++++++++++++++++++++++ > arch/x86/kernel/ptrace.c | 16 +++++++++++++++ > include/uapi/linux/elf.h | 1 + > 4 files changed, 62 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/include/asm/fpu/regset.h b/arch/x86/include/asm/fpu/regset.h > index d5bdffb9d27f..edad0d889084 100644 > --- a/arch/x86/include/asm/fpu/regset.h > +++ b/arch/x86/include/asm/fpu/regset.h > @@ -7,11 +7,12 @@ > > #include <linux/regset.h> > > -extern user_regset_active_fn regset_fpregs_active, regset_xregset_fpregs_active; > +extern user_regset_active_fn regset_fpregs_active, regset_xregset_fpregs_active, > + cetregs_active; > extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get, > - xstateregs_get; > + xstateregs_get, cetregs_get; > extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set, > - xstateregs_set; > + xstateregs_set, cetregs_set; > > /* > * xstateregs_active == regset_fpregs_active. Please refer to the comment > diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c > index bc02f5144b95..7008eb084d36 100644 > --- a/arch/x86/kernel/fpu/regset.c > +++ b/arch/x86/kernel/fpu/regset.c > @@ -160,6 +160,47 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset, > return ret; > } > > +int cetregs_active(struct task_struct *target, const struct user_regset *regset) > +{ > +#ifdef CONFIG_X86_INTEL_CET > + if (target->thread.cet.shstk_enabled || target->thread.cet.ibt_enabled) > + return regset->n; > +#endif > + return 0; > +} > + > +int cetregs_get(struct task_struct *target, const struct user_regset *regset, > + unsigned int pos, unsigned int count, > + void *kbuf, void __user *ubuf) > +{ > + struct fpu *fpu = &target->thread.fpu; > + struct cet_user_state *cetregs; > + > + if (!boot_cpu_has(X86_FEATURE_SHSTK)) > + return -ENODEV; This whole series has a boot_cpu_has, static_cpu_has, and cpu_feature_enabled all over. Please settle on just one, preferably static_cpu_has. > + > + cetregs = get_xsave_addr(&fpu->state.xsave, XFEATURE_MASK_SHSTK_USER); > + > + fpu__prepare_read(fpu); > + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, cetregs, 0, -1); > +} > + > +int cetregs_set(struct task_struct *target, const struct user_regset *regset, > + unsigned int pos, unsigned int count, > + const void *kbuf, const void __user *ubuf) > +{ > + struct fpu *fpu = &target->thread.fpu; > + struct cet_user_state *cetregs; > + > + if (!boot_cpu_has(X86_FEATURE_SHSTK)) > + return -ENODEV; > + > + cetregs = get_xsave_addr(&fpu->state.xsave, XFEATURE_MASK_SHSTK_USER); > + > + fpu__prepare_write(fpu); > + return user_regset_copyin(&pos, &count, &kbuf, &ubuf, cetregs, 0, -1); Is this called for core dumping on current? If so, please make sure it's correct. (I think it is for get but maybe not for set.) -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-06-07 18:33 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-07 14:38 [PATCH 0/7] Control Flow Enforcement - Part (4) Yu-cheng Yu 2018-06-07 14:38 ` Yu-cheng Yu 2018-06-07 14:38 ` [PATCH 1/7] x86/cet: Add Kconfig option for user-mode Indirect Branch Tracking Yu-cheng Yu 2018-06-07 14:38 ` Yu-cheng Yu 2018-06-07 16:43 ` Randy Dunlap 2018-06-07 16:43 ` Randy Dunlap 2018-06-07 14:38 ` [PATCH 2/7] x86/cet: User-mode indirect branch tracking support Yu-cheng Yu 2018-06-07 14:38 ` Yu-cheng Yu 2018-06-07 14:38 ` [PATCH 3/7] mm/mmap: Add IBT bitmap size to address space limit check Yu-cheng Yu 2018-06-07 14:38 ` Yu-cheng Yu 2018-06-07 18:39 ` Andy Lutomirski 2018-06-07 18:39 ` Andy Lutomirski 2018-06-07 14:38 ` [PATCH 4/7] x86/cet: add arcp_prctl functions for indirect branch tracking Yu-cheng Yu 2018-06-07 14:38 ` Yu-cheng Yu 2018-06-07 14:38 ` [PATCH 5/7] x86: Insert endbr32/endbr64 to vDSO Yu-cheng Yu 2018-06-07 14:38 ` Yu-cheng Yu 2018-06-07 20:50 ` Andy Lutomirski 2018-06-07 20:50 ` Andy Lutomirski 2018-06-07 22:03 ` H.J. Lu 2018-06-07 22:03 ` H.J. Lu 2018-06-07 23:00 ` Andy Lutomirski 2018-06-07 23:00 ` Andy Lutomirski 2018-06-08 0:31 ` H.J. Lu 2018-06-08 0:31 ` H.J. Lu 2018-06-08 0:47 ` Andy Lutomirski 2018-06-08 0:47 ` Andy Lutomirski 2018-06-07 14:38 ` [PATCH 6/7] tools: Add cetcmd Yu-cheng Yu 2018-06-07 14:38 ` Yu-cheng Yu 2018-06-07 14:38 ` [PATCH 7/7] x86/cet: Add PTRACE interface for CET Yu-cheng Yu 2018-06-07 14:38 ` Yu-cheng Yu 2018-06-07 18:32 ` Andy Lutomirski [this message] 2018-06-07 18:32 ` Andy Lutomirski
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=CALCETrXx4FHLad8XhrP-RrBtXnmALf7Myy4wVO+u-SKxa_D01Q@mail.gmail.com \ --to=luto@amacapital.net \ --cc=arnd@arndb.de \ --cc=corbet@lwn.net \ --cc=dave.hansen@linux.intel.com \ --cc=hjl.tools@gmail.com \ --cc=hpa@zytor.com \ --cc=linux-arch@vger.kernel.org \ --cc=linux-doc@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mike.kravetz@oracle.com \ --cc=mingo@redhat.com \ --cc=oleg@redhat.com \ --cc=ravi.v.shankar@intel.com \ --cc=tglx@linutronix.de \ --cc=vedvyas.shanbhogue@intel.com \ --cc=x86@kernel.org \ --cc=yu-cheng.yu@intel.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.