public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Alexander Egorenkov <egorenar@linux.ibm.com>
Cc: wim@linux-watchdog.org, linux-watchdog@vger.kernel.org,
	linux-kernel@vger.kernel.org, hca@linux.ibm.com
Subject: Re: [PATCH 1/5] watchdog: diag288_wdt: get rid of register asm
Date: Fri, 3 Feb 2023 10:17:28 -0800	[thread overview]
Message-ID: <20230203181728.GA3172478@roeck-us.net> (raw)
In-Reply-To: <20230203073958.1585738-2-egorenar@linux.ibm.com>

On Fri, Feb 03, 2023 at 08:39:54AM +0100, Alexander Egorenkov wrote:
> Using register asm statements has been proven to be very error prone,
> especially when using code instrumentation where gcc may add function
> calls, which clobbers register contents in an unexpected way.
> 
> Therefore, get rid of register asm statements in watchdog code, and make
> sure this bug class cannot happen.
> 
> Moreover, remove the register r1 from the clobber list because this
> register is not changed by DIAG 288.
> 
> Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
> Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/diag288_wdt.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
> index 6ca5d9515d85..07ebbb709af4 100644
> --- a/drivers/watchdog/diag288_wdt.c
> +++ b/drivers/watchdog/diag288_wdt.c
> @@ -73,20 +73,19 @@ MODULE_ALIAS("vmwatchdog");
>  static int __diag288(unsigned int func, unsigned int timeout,
>  		     unsigned long action, unsigned int len)
>  {
> -	register unsigned long __func asm("2") = func;
> -	register unsigned long __timeout asm("3") = timeout;
> -	register unsigned long __action asm("4") = action;
> -	register unsigned long __len asm("5") = len;
> +	union register_pair r1 = { .even = func, .odd = timeout, };
> +	union register_pair r3 = { .even = action, .odd = len, };
>  	int err;
>  
>  	err = -EINVAL;
>  	asm volatile(
> -		"	diag	%1, %3, 0x288\n"
> -		"0:	la	%0, 0\n"
> +		"	diag	%[r1],%[r3],0x288\n"
> +		"0:	la	%[err],0\n"
>  		"1:\n"
>  		EX_TABLE(0b, 1b)
> -		: "+d" (err) : "d"(__func), "d"(__timeout),
> -		  "d"(__action), "d"(__len) : "1", "cc", "memory");
> +		: [err] "+d" (err)
> +		: [r1] "d" (r1.pair), [r3] "d" (r3.pair)
> +		: "cc", "memory");
>  	return err;
>  }
>  

  reply	other threads:[~2023-02-03 18:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03  7:39 [PATCH 0/5] diag288 watchdog fixes and improvements Alexander Egorenkov
2023-02-03  7:39 ` [PATCH 1/5] watchdog: diag288_wdt: get rid of register asm Alexander Egorenkov
2023-02-03 18:17   ` Guenter Roeck [this message]
2023-02-03  7:39 ` [PATCH 2/5] watchdog: diag288_wdt: remove power management Alexander Egorenkov
2023-02-03 18:23   ` Guenter Roeck
2023-02-03  7:39 ` [PATCH 3/5] watchdog: diag288_wdt: unify command buffer handling for diag288 zvm Alexander Egorenkov
2023-02-03 18:34   ` Guenter Roeck
2023-02-03  7:39 ` [PATCH 4/5] watchdog: diag288_wdt: de-duplicate diag_stat_inc() calls Alexander Egorenkov
2023-02-03 18:36   ` Guenter Roeck
2023-02-03  7:39 ` [PATCH 5/5] watchdog: diag288_wdt: unify lpar and zvm diag288 helpers Alexander Egorenkov
2023-02-03 18:37   ` Guenter Roeck
2023-02-06  9:59 ` [PATCH 0/5] diag288 watchdog fixes and improvements Heiko Carstens
2023-02-06 13:55   ` Guenter Roeck
2023-02-06 14:33     ` Heiko Carstens

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=20230203181728.GA3172478@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=egorenar@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@linux-watchdog.org \
    /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