linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: Pedro Alves <palves@redhat.com>
Cc: mikey@neuling.org, avagin@openvz.org, oleg@redhat.com,
	linux-kernel@vger.kernel.org, michael@ellerman.id.au,
	linuxppc-dev@ozlabs.org
Subject: Re: [PATCH V2 2/3] powerpc, ptrace: Enable support for transactional memory register sets
Date: Tue, 20 May 2014 13:44:24 +0530	[thread overview]
Message-ID: <537B0EE0.4080406@linux.vnet.ibm.com> (raw)
In-Reply-To: <537A1889.8030801@redhat.com>

On 05/19/2014 08:13 PM, Pedro Alves wrote:
> On 05/19/2014 12:46 PM, Anshuman Khandual wrote:
> 
>>>> I couldn't actually find any arch that currently returns -ENODEV in
>>>> the "active" hook.  I see that binfmt_elf.c doesn't handle
>>>> regset->active() returning < 0.  Guess that may be why.  Looks like
>>>> something that could be cleaned up, to me.
>>>>
>> Also it does not consider the return value of regset->active(t->task, regset)
>> (whose objective is to figure out whether we need to request regset->n number
>> of elements or less than that) in the subsequent call to regset->get function.
> 
> Indeed.
> 
> TBC, do you plan on fixing this?  Otherwise ...

Sure, thinking something like this as mentioned below. But still not sure how to use
the return type of -ENODEV from the function regset->active(). Right now if any
regset does have the active hook and it returns anything but positive value, it will
be ignored and the control moves to the next regset in view. This prevents the thread
core note type being written to the core dump.

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index aa3cb62..80672fb 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1553,7 +1553,15 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
                if (regset->core_note_type && regset->get &&
                    (!regset->active || regset->active(t->task, regset))) {
                        int ret;
-                       size_t size = regset->n * regset->size;
+                       size_t size;
+
+                       /* Request only the active elements in the regset */
+                       if (!regset->active)
+                               size = regset->n * regset->size;
+                       else
+                               size = regset->active(t->task, regset)
+                                                               * regset->size;
+
                        void *data = kmalloc(size, GFP_KERNEL);
                        if (unlikely(!data))
                                return 0;

> 
>> Now coming to the installation of the .active hooks part for all the new regsets, it
>> should be pretty straight forward as well. Though its optional and used for elf_core_dump
>> purpose only, its worth adding them here. Example of an active function should be something
>> like this. The function is inexpensive as required.
>>
>> +static int tm_spr_active(struct task_struct *target,
>> +                               const struct user_regset *regset)
>> +{
>> +       if (!cpu_has_feature(CPU_FTR_TM))
>> +               return -ENODEV;
> 
> ... unfortunately this will do the wrong thing.

I am not sure whether I understand this correctly. Are you saying that its wrong to return
-ENODEV in this case as above ?


  reply	other threads:[~2014-05-20  8:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-05  7:54 [PATCH V2 0/3] Add new PowerPC specific ELF core notes Anshuman Khandual
2014-05-05  7:54 ` [PATCH V2 1/3] elf: Add some new PowerPC specifc note sections Anshuman Khandual
2014-05-05  7:54 ` [PATCH V2 2/3] powerpc, ptrace: Enable support for transactional memory register sets Anshuman Khandual
2014-05-13 17:13   ` Pedro Alves
2014-05-14  5:46     ` Anshuman Khandual
2014-05-14 11:15       ` Pedro Alves
     [not found]         ` <CAEjGV6y8-zOtOgxcg-6viNQh-RuzQCAy8JvJ+m-dc7XQnAkJmA@mail.gmail.com>
2014-05-14 11:22           ` Pedro Alves
2014-05-15  8:25         ` Anshuman Khandual
2014-05-15 12:08           ` Pedro Alves
2014-05-16  0:26             ` Michael Neuling
2014-05-19  9:12             ` Anshuman Khandual
2014-05-19 11:46             ` Anshuman Khandual
2014-05-19 14:43               ` Pedro Alves
2014-05-20  8:14                 ` Anshuman Khandual [this message]
2014-05-20 10:33                   ` Pedro Alves
2014-05-22  5:08                     ` Anshuman Khandual
2014-05-23 13:57                       ` Anshuman Khandual
2014-05-13 17:21   ` Pedro Alves
2014-05-14  5:49     ` Anshuman Khandual
2014-05-22  5:30     ` Michael Ellerman
2014-05-05  7:54 ` [PATCH V2 3/3] powerpc, ptrace: Enable support for miscellaneous registers Anshuman Khandual

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=537B0EE0.4080406@linux.vnet.ibm.com \
    --to=khandual@linux.vnet.ibm.com \
    --cc=avagin@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=michael@ellerman.id.au \
    --cc=mikey@neuling.org \
    --cc=oleg@redhat.com \
    --cc=palves@redhat.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: 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;
as well as URLs for NNTP newsgroup(s).