All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Thomas Huth <thuth@redhat.com>, kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, kvm-ppc@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH] powerpc: Fix endless loop that occurs without a device tree
Date: Wed, 31 May 2017 10:29:45 +0200	[thread overview]
Message-ID: <2c4d3717-b15b-031b-0ffd-257acb9bd873@redhat.com> (raw)
In-Reply-To: <1496156844-29196-1-git-send-email-thuth@redhat.com>

On 30/05/2017 17:07, Thomas Huth wrote:
> When running a powerpc kvm-unit-test, and there is accidentially
> no device tree available, the test ends up in an endless loop,
> spamming the console with "rtas_node: /rtas: FDT_ERR_BADMAGIC"
> messages: Somewhere the code calls abort() due to the missing
> device tree, and abort() calls exit() which in turn tries to
> shut down the VM with rtas_power_off(). rtas_power_off() needs
> the device tree again to look up the right RTAS token and we
> then end up in the next iteration.
> Fix it by adding some proper checks to rtas_power_off() and
> rtas_token().
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  lib/powerpc/rtas.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/powerpc/rtas.c b/lib/powerpc/rtas.c
> index 3407e25..a1c560b 100644
> --- a/lib/powerpc/rtas.c
> +++ b/lib/powerpc/rtas.c
> @@ -74,6 +74,9 @@ int rtas_token(const char *service)
>  	const struct fdt_property *prop;
>  	u32 *token;
>  
> +	if (!dt_available())
> +		return RTAS_UNKNOWN_SERVICE;
> +
>  	prop = fdt_get_property(dt_fdt(), rtas_node(), service, NULL);
>  	if (prop) {
>  		token = (u32 *)prop->data;
> @@ -116,6 +119,14 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
>  
>  void rtas_power_off(void)
>  {
> -	int ret = rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1);
> +	int token, ret;
> +
> +	token = rtas_token("power-off");
> +	if (token < 0) {
> +		puts("RTAS power-off not available\n");
> +		return;
> +	}
> +
> +	ret = rtas_call(token, 2, 1, NULL, -1, -1);
>  	printf("RTAS power-off returned %d\n", ret);
>  }
> 
Reviewed-by: Laurent Vivier <lvivier@redhat.com>

WARNING: multiple messages have this Message-ID (diff)
From: Laurent Vivier <lvivier@redhat.com>
To: Thomas Huth <thuth@redhat.com>, kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, kvm-ppc@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH] powerpc: Fix endless loop that occurs without a device tree
Date: Wed, 31 May 2017 08:29:45 +0000	[thread overview]
Message-ID: <2c4d3717-b15b-031b-0ffd-257acb9bd873@redhat.com> (raw)
In-Reply-To: <1496156844-29196-1-git-send-email-thuth@redhat.com>

On 30/05/2017 17:07, Thomas Huth wrote:
> When running a powerpc kvm-unit-test, and there is accidentially
> no device tree available, the test ends up in an endless loop,
> spamming the console with "rtas_node: /rtas: FDT_ERR_BADMAGIC"
> messages: Somewhere the code calls abort() due to the missing
> device tree, and abort() calls exit() which in turn tries to
> shut down the VM with rtas_power_off(). rtas_power_off() needs
> the device tree again to look up the right RTAS token and we
> then end up in the next iteration.
> Fix it by adding some proper checks to rtas_power_off() and
> rtas_token().
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  lib/powerpc/rtas.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/powerpc/rtas.c b/lib/powerpc/rtas.c
> index 3407e25..a1c560b 100644
> --- a/lib/powerpc/rtas.c
> +++ b/lib/powerpc/rtas.c
> @@ -74,6 +74,9 @@ int rtas_token(const char *service)
>  	const struct fdt_property *prop;
>  	u32 *token;
>  
> +	if (!dt_available())
> +		return RTAS_UNKNOWN_SERVICE;
> +
>  	prop = fdt_get_property(dt_fdt(), rtas_node(), service, NULL);
>  	if (prop) {
>  		token = (u32 *)prop->data;
> @@ -116,6 +119,14 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
>  
>  void rtas_power_off(void)
>  {
> -	int ret = rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1);
> +	int token, ret;
> +
> +	token = rtas_token("power-off");
> +	if (token < 0) {
> +		puts("RTAS power-off not available\n");
> +		return;
> +	}
> +
> +	ret = rtas_call(token, 2, 1, NULL, -1, -1);
>  	printf("RTAS power-off returned %d\n", ret);
>  }
> 
Reviewed-by: Laurent Vivier <lvivier@redhat.com>


  parent reply	other threads:[~2017-05-31  8:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 15:07 [kvm-unit-tests PATCH] powerpc: Fix endless loop that occurs without a device tree Thomas Huth
2017-05-30 15:07 ` Thomas Huth
2017-05-30 15:19 ` Paolo Bonzini
2017-05-30 15:19   ` Paolo Bonzini
2017-05-30 16:13   ` Thomas Huth
2017-05-30 16:13     ` Thomas Huth
2017-05-30 17:36     ` Paolo Bonzini
2017-05-30 17:36       ` Paolo Bonzini
2017-05-31  8:21 ` Andrew Jones
2017-05-31  8:21   ` Andrew Jones
2017-05-31  8:32   ` Thomas Huth
2017-05-31  8:32     ` Thomas Huth
2017-05-31  9:00     ` Laurent Vivier
2017-05-31  9:00       ` Laurent Vivier
2017-05-31  9:27       ` Thomas Huth
2017-05-31  9:27         ` Thomas Huth
2017-05-31  8:29 ` Laurent Vivier [this message]
2017-05-31  8:29   ` Laurent Vivier

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=2c4d3717-b15b-031b-0ffd-257acb9bd873@redhat.com \
    --to=lvivier@redhat.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@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 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.