All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
	linuxppc-dev@lists.ozlabs.org,
	Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
	Christophe Lombard <christophe_lombard@fr.ibm.com>,
	Philippe Bergheaud <philippe.bergheaud@fr.ibm.com>
Cc: Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
	"Alastair D'Silva" <alastair@linux.ibm.com>,
	Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Subject: Re: [PATCH 1/2] powerpc: Avoid signed to unsigned conversion in set_thread_tidr()
Date: Fri, 24 Nov 2017 12:38:18 +0530	[thread overview]
Message-ID: <87fu94f925.fsf@vajain21.in.ibm.com> (raw)
In-Reply-To: <87lgiw19qd.fsf@concordia.ellerman.id.au>

Thanks Mpe for reviewing the patch

Michael Ellerman <mpe@ellerman.id.au> writes:

>> To fix this the patch assigns the return value of assign_thread_tidr()
>> to a temporary int and assigns it to thread.tidr iff its '> 0'.
>
> .. and changes the calling convention of the function.
>
> Now it returns -ve error values, or a +ve TIDR value when it succeeds,
> or possibly 0 if that's returned by assign_thread_tidr().
>
> Which I'm not sure you meant to do. If you did, you should at least
> document it.
>

Yes this is intentional and this was supposed to be the calling
convention of set_thread_tidr() in first place. At-least that what I
gather from subsequent cxl patch to add its support
http://patchwork.ozlabs.org/patch/840719/

set_thread_tidr() is a wrapper around assign_thread_tidr() which follows
similar calling convention i.e return -ve values for error and  +ve
value successfully allocated tidr. The way assign_thread_tidr() is
implemented it will never return a '0'.

Currently set_thread_tidr() will wrongly assign an incorrect tidr value
to SPRN_TIDR in case assign_thread_tidr() returns an error. This patch
fixes this issue and should not impact the existing calling convention
of set_thread_tidr(). The patch should not have an impact on the calling
convention of set_thread_tidr().

I also have unintentionally left a tidr leak in this patch and will send
a v2 with the fix and also updating the patch description mentioning the
calling convention of the function.

-- 
Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
Linux Technology Center, IBM India Pvt. Ltd.

  reply	other threads:[~2017-11-24  7:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23 12:47 [PATCH 1/2] powerpc: Avoid signed to unsigned conversion in set_thread_tidr() Vaibhav Jain
2017-11-23 12:47 ` [PATCH 2/2] powerpc: Do not assign thread.tidr if already assigned Vaibhav Jain
2017-11-24  6:17 ` [PATCH 1/2] powerpc: Avoid signed to unsigned conversion in set_thread_tidr() Michael Ellerman
2017-11-24  7:08   ` Vaibhav Jain [this message]
2017-11-27  3:44     ` Michael Ellerman
2017-11-27 17:05       ` Vaibhav Jain

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=87fu94f925.fsf@vajain21.in.ibm.com \
    --to=vaibhav@linux.vnet.ibm.com \
    --cc=alastair@linux.ibm.com \
    --cc=andrew.donnellan@au1.ibm.com \
    --cc=christophe_lombard@fr.ibm.com \
    --cc=fbarrat@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=philippe.bergheaud@fr.ibm.com \
    --cc=sukadev@linux.vnet.ibm.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 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.