All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>,
	kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Cc: drjones@redhat.com, dgibson@redhat.com, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2] powerpc: restore TOC pointer
Date: Fri, 22 Apr 2016 14:12:20 +0000	[thread overview]
Message-ID: <571A3144.2020406@redhat.com> (raw)
In-Reply-To: <1461323527-20148-1-git-send-email-lvivier@redhat.com>

On 22.04.2016 13:12, Laurent Vivier wrote:
> As the TOC pointer can be corrupted by the main program,
> we must restore it in the exception handler.
> 
> As we know where we are loaded, we can now compute it easily.
> 
> To compute it only in the common part of the exception handler
> (call_handler), store the address of call_handler at an absolute
> address in memory to be able to call the handler from the exception
> table (as SLOF does).
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v2: don't add SPAPR_KERNEL_LOAD_ADDR to r2 as
>     the TOC has been relocated and have directly the good
>     value. The problem has been reported by Thomas.

This seems to fix the issue with the emulator invalid-instruction test.
Thanks!

 Thomas


>  powerpc/cstart64.S | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
> index c47b67d..2d66032 100644
> --- a/powerpc/cstart64.S
> +++ b/powerpc/cstart64.S
> @@ -13,6 +13,8 @@
>  
>  #include "spapr.h"
>  
> +#define P_HANDLER	0x2ff8
> +
>  .section .init
>  
>  /*
> @@ -46,6 +48,11 @@ start:
>  	add	r4, r4, r31
>  	bl	relocate
>  
> +	/* compute address of call_handler */
> +
> +	LOAD_REG_ADDR(r4, call_handler)
> +	std	r4, P_HANDLER(0)
> +
>  	/* relocate vector table to base address 0x0 (MSR_IP = 0) */
>  
>  	/* source: r4, dest end: r5, destination: r6 */
> @@ -166,6 +173,11 @@ call_handler:
>  	mfsrr1	r0
>  	std	r0, _MSR(r1)
>  
> +	/* restore TOC pointer */
> +
> +	LOAD_REG_IMMEDIATE(r31, SPAPR_KERNEL_LOAD_ADDR)
> +	ld	r2, (p_toc - start)(r31)
> +
>  	/* FIXME: build stack frame */
>  
>  	/* call generic handler */
> @@ -221,7 +233,7 @@ call_handler:
>  	mfctr	r0
>  	std	r0,_CTR(r1)
>  
> -	LOAD_REG_ADDR(r0, call_handler)
> +	ld	r0, P_HANDLER(0)
>  	mtctr	r0
>  
>  	li	r0,\vec
> @@ -245,3 +257,5 @@ VECTOR(0x900)
>  	.align 7
>  	.globl __end_interrupts
>  __end_interrupts:
> +	.org	P_HANDLER
> +	.llong	0
> 


WARNING: multiple messages have this Message-ID (diff)
From: Thomas Huth <thuth@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>,
	kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Cc: drjones@redhat.com, dgibson@redhat.com, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2] powerpc: restore TOC pointer
Date: Fri, 22 Apr 2016 16:12:20 +0200	[thread overview]
Message-ID: <571A3144.2020406@redhat.com> (raw)
In-Reply-To: <1461323527-20148-1-git-send-email-lvivier@redhat.com>

On 22.04.2016 13:12, Laurent Vivier wrote:
> As the TOC pointer can be corrupted by the main program,
> we must restore it in the exception handler.
> 
> As we know where we are loaded, we can now compute it easily.
> 
> To compute it only in the common part of the exception handler
> (call_handler), store the address of call_handler at an absolute
> address in memory to be able to call the handler from the exception
> table (as SLOF does).
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v2: don't add SPAPR_KERNEL_LOAD_ADDR to r2 as
>     the TOC has been relocated and have directly the good
>     value. The problem has been reported by Thomas.

This seems to fix the issue with the emulator invalid-instruction test.
Thanks!

 Thomas


>  powerpc/cstart64.S | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
> index c47b67d..2d66032 100644
> --- a/powerpc/cstart64.S
> +++ b/powerpc/cstart64.S
> @@ -13,6 +13,8 @@
>  
>  #include "spapr.h"
>  
> +#define P_HANDLER	0x2ff8
> +
>  .section .init
>  
>  /*
> @@ -46,6 +48,11 @@ start:
>  	add	r4, r4, r31
>  	bl	relocate
>  
> +	/* compute address of call_handler */
> +
> +	LOAD_REG_ADDR(r4, call_handler)
> +	std	r4, P_HANDLER(0)
> +
>  	/* relocate vector table to base address 0x0 (MSR_IP = 0) */
>  
>  	/* source: r4, dest end: r5, destination: r6 */
> @@ -166,6 +173,11 @@ call_handler:
>  	mfsrr1	r0
>  	std	r0, _MSR(r1)
>  
> +	/* restore TOC pointer */
> +
> +	LOAD_REG_IMMEDIATE(r31, SPAPR_KERNEL_LOAD_ADDR)
> +	ld	r2, (p_toc - start)(r31)
> +
>  	/* FIXME: build stack frame */
>  
>  	/* call generic handler */
> @@ -221,7 +233,7 @@ call_handler:
>  	mfctr	r0
>  	std	r0,_CTR(r1)
>  
> -	LOAD_REG_ADDR(r0, call_handler)
> +	ld	r0, P_HANDLER(0)
>  	mtctr	r0
>  
>  	li	r0,\vec
> @@ -245,3 +257,5 @@ VECTOR(0x900)
>  	.align 7
>  	.globl __end_interrupts
>  __end_interrupts:
> +	.org	P_HANDLER
> +	.llong	0
> 


  reply	other threads:[~2016-04-22 14:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 11:12 [kvm-unit-tests PATCH v2] powerpc: restore TOC pointer Laurent Vivier
2016-04-22 11:12 ` Laurent Vivier
2016-04-22 14:12 ` Thomas Huth [this message]
2016-04-22 14:12   ` Thomas Huth

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=571A3144.2020406@redhat.com \
    --to=thuth@redhat.com \
    --cc=dgibson@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@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.