From: Thomas Huth <thuth@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>, lvivier@redhat.com
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org,
pbonzini@redhat.com, rkrcmar@redhat.com
Subject: Re: [PATCH] powerpc: Fix up RTAS invocation for new qemu versions
Date: Wed, 9 Oct 2019 12:35:35 +0200 [thread overview]
Message-ID: <07997795-3b64-5c85-e8a1-e9d81e57784e@redhat.com> (raw)
In-Reply-To: <20191004103844.32590-1-david@gibson.dropbear.id.au>
On 04/10/2019 12.38, David Gibson wrote:
> In order to call RTAS functions on powerpc kvm-unit-tests relies on the
> RTAS blob supplied by qemu. But new versions of qemu don't supply an RTAS
> blob: since the normal way for guests to get RTAS is to call the guest
> firmware's instantiate-rtas function, we now rely on that guest firmware
> to provide the RTAS code itself.
>
> But qemu-kvm-tests bypasses the usual guest firmware to just run itself,
s/qemu-kvm-tests/kvm-unit-tests/
> so we can't get the rtas blob from SLOF.
>
> But.. in fact the RTAS blob under qemu is a bit of a sham anyway - it's
> a tiny wrapper that forwards the RTAS call to a hypercall. So, we can
> just invoke that hypercall directly.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> lib/powerpc/asm/hcall.h | 3 +++
> lib/powerpc/rtas.c | 6 +++---
> powerpc/cstart64.S | 20 ++++++++++++++++----
> 3 files changed, 22 insertions(+), 7 deletions(-)
>
> So.. "new versions of qemu" in this case means ones that incorporate
> the pull request I just sent today.
>
> diff --git a/lib/powerpc/asm/hcall.h b/lib/powerpc/asm/hcall.h
> index a8bd7e3..1173fea 100644
> --- a/lib/powerpc/asm/hcall.h
> +++ b/lib/powerpc/asm/hcall.h
> @@ -24,6 +24,9 @@
> #define H_RANDOM 0x300
> #define H_SET_MODE 0x31C
>
> +#define KVMPPC_HCALL_BASE 0xf000
> +#define KVMPPC_H_RTAS (KVMPPC_HCALL_BASE + 0x0)
> +
> #ifndef __ASSEMBLY__
> /*
> * hcall_have_broken_sc1 checks if we're on a host with a broken sc1.
> diff --git a/lib/powerpc/rtas.c b/lib/powerpc/rtas.c
> index 2e7e0da..41c0a24 100644
> --- a/lib/powerpc/rtas.c
> +++ b/lib/powerpc/rtas.c
> @@ -46,9 +46,9 @@ void rtas_init(void)
> prop = fdt_get_property(dt_fdt(), node,
> "linux,rtas-entry", &len);
> if (!prop) {
> - printf("%s: /rtas/linux,rtas-entry: %s\n",
> - __func__, fdt_strerror(len));
> - abort();
> + /* We don't have a qemu provided RTAS blob, enter_rtas
> + * will use H_RTAS directly */
> + return;
> }
> data = (u32 *)prop->data;
> rtas_entry = (unsigned long)fdt32_to_cpu(*data);
> diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
> index ec673b3..972851f 100644
> --- a/powerpc/cstart64.S
> +++ b/powerpc/cstart64.S
> @@ -121,13 +121,25 @@ halt:
>
> .globl enter_rtas
> enter_rtas:
> + LOAD_REG_ADDR(r11, rtas_entry)
> + ld r10, 0(r11)
> +
> + cmpdi r10,0
> + bne external_rtas
> +
> + /* Use H_RTAS directly */
> + mr r4,r3
> + lis r3,KVMPPC_H_RTAS@h
> + ori r3,r3,KVMPPC_H_RTAS@l
> + b hcall
> +
> +external_rtas:
> + /* Use external RTAS blob */
> mflr r0
> std r0, 16(r1)
>
> - LOAD_REG_ADDR(r10, rtas_return_loc)
> - mtlr r10
> - LOAD_REG_ADDR(r11, rtas_entry)
> - ld r10, 0(r11)
> + LOAD_REG_ADDR(r11, rtas_return_loc)
> + mtlr r11
>
> mfmsr r11
> LOAD_REG_IMMEDIATE(r9, RTAS_MSR_MASK)
>
With the typo in the commit message fixed:
Reviewed-by: Thomas Huth <thuth@redhat.com>
Paolo, I currently don't have any other kvm-unit-test patches pending,
could you pick this up directly, please?
next prev parent reply other threads:[~2019-10-09 10:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 10:38 [PATCH] powerpc: Fix up RTAS invocation for new qemu versions David Gibson
2019-10-04 11:54 ` Paolo Bonzini
2019-10-05 8:11 ` David Gibson
2019-10-06 16:16 ` Paolo Bonzini
2019-10-07 5:22 ` David Gibson
2019-10-09 10:35 ` Thomas Huth [this message]
2019-10-09 11:12 ` Paolo Bonzini
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=07997795-3b64-5c85-e8a1-e9d81e57784e@redhat.com \
--to=thuth@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@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