From: Greg Kurz <groug@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] xics/spapr: Prevent RTAS/hypercalls emulation to be used by in-kernel XICS
Date: Fri, 14 Jun 2019 07:37:46 +0200 [thread overview]
Message-ID: <20190614073746.1095f3c5@bahia.lan> (raw)
In-Reply-To: <20190614013459.GA11158@umbus.fritz.box>
[-- Attachment #1: Type: text/plain, Size: 5526 bytes --]
On Fri, 14 Jun 2019 11:34:59 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> On Thu, Jun 13, 2019 at 06:44:54PM +0200, Greg Kurz wrote:
> > The XICS-related RTAS calls and hypercalls in QEMU are supposed to be
> > called only when the KVM in-kernel XICS is in use.
>
> I've applied this, but reversed the sense of the sentence above, which
> appears to be the intent.
>
Oops indeed... Thanks !
> >
> > Add some explicit checks to detect that, print an error message and report
> > an hardware error to the guest.
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> > hw/intc/xics_spapr.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 46 insertions(+)
> >
> > diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
> > index 5a1835e8b1ed..d470ab5f7a2a 100644
> > --- a/hw/intc/xics_spapr.c
> > +++ b/hw/intc/xics_spapr.c
> > @@ -41,11 +41,31 @@
> > * Guest interfaces
> > */
> >
> > +static bool check_in_kernel_xics(const char *func)
> > +{
> > + if (kvm_irqchip_in_kernel()) {
> > + error_report("pseries: %s must never be called for in-kernel XICS",
> > + func);
> > + return true;
> > + }
> > +
> > + return false;
> > +}
> > +
> > +#define CHECK_IN_KERNEL_XICS_HCALL \
> > + do { \
> > + if (check_in_kernel_xics(__func__)) { \
> > + return H_HARDWARE; \
> > + } \
> > + } while (0)
> > +
> > static target_ulong h_cppr(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > target_ulong opcode, target_ulong *args)
> > {
> > target_ulong cppr = args[0];
> >
> > + CHECK_IN_KERNEL_XICS_HCALL;
> > +
> > icp_set_cppr(spapr_cpu_state(cpu)->icp, cppr);
> > return H_SUCCESS;
> > }
> > @@ -56,6 +76,8 @@ static target_ulong h_ipi(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > target_ulong mfrr = args[1];
> > ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), args[0]);
> >
> > + CHECK_IN_KERNEL_XICS_HCALL;
> > +
> > if (!icp) {
> > return H_PARAMETER;
> > }
> > @@ -69,6 +91,8 @@ static target_ulong h_xirr(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > {
> > uint32_t xirr = icp_accept(spapr_cpu_state(cpu)->icp);
> >
> > + CHECK_IN_KERNEL_XICS_HCALL;
> > +
> > args[0] = xirr;
> > return H_SUCCESS;
> > }
> > @@ -78,6 +102,8 @@ static target_ulong h_xirr_x(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > {
> > uint32_t xirr = icp_accept(spapr_cpu_state(cpu)->icp);
> >
> > + CHECK_IN_KERNEL_XICS_HCALL;
> > +
> > args[0] = xirr;
> > args[1] = cpu_get_host_ticks();
> > return H_SUCCESS;
> > @@ -88,6 +114,8 @@ static target_ulong h_eoi(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > {
> > target_ulong xirr = args[0];
> >
> > + CHECK_IN_KERNEL_XICS_HCALL;
> > +
> > icp_eoi(spapr_cpu_state(cpu)->icp, xirr);
> > return H_SUCCESS;
> > }
> > @@ -99,6 +127,8 @@ static target_ulong h_ipoll(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > uint32_t mfrr;
> > uint32_t xirr;
> >
> > + CHECK_IN_KERNEL_XICS_HCALL;
> > +
> > if (!icp) {
> > return H_PARAMETER;
> > }
> > @@ -111,6 +141,14 @@ static target_ulong h_ipoll(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > return H_SUCCESS;
> > }
> >
> > +#define CHECK_IN_KERNEL_XICS_RTAS(rets) \
> > + do { \
> > + if (check_in_kernel_xics(__func__)) { \
> > + rtas_st((rets), 0, RTAS_OUT_HW_ERROR); \
> > + return; \
> > + } \
> > + } while (0)
> > +
> > static void rtas_set_xive(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > uint32_t token,
> > uint32_t nargs, target_ulong args,
> > @@ -119,6 +157,8 @@ static void rtas_set_xive(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > ICSState *ics = spapr->ics;
> > uint32_t nr, srcno, server, priority;
> >
> > + CHECK_IN_KERNEL_XICS_RTAS(rets);
> > +
> > if ((nargs != 3) || (nret != 1)) {
> > rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> > return;
> > @@ -152,6 +192,8 @@ static void rtas_get_xive(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > ICSState *ics = spapr->ics;
> > uint32_t nr, srcno;
> >
> > + CHECK_IN_KERNEL_XICS_RTAS(rets);
> > +
> > if ((nargs != 1) || (nret != 3)) {
> > rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> > return;
> > @@ -182,6 +224,8 @@ static void rtas_int_off(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > ICSState *ics = spapr->ics;
> > uint32_t nr, srcno;
> >
> > + CHECK_IN_KERNEL_XICS_RTAS(rets);
> > +
> > if ((nargs != 1) || (nret != 1)) {
> > rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> > return;
> > @@ -213,6 +257,8 @@ static void rtas_int_on(PowerPCCPU *cpu, SpaprMachineState *spapr,
> > ICSState *ics = spapr->ics;
> > uint32_t nr, srcno;
> >
> > + CHECK_IN_KERNEL_XICS_RTAS(rets);
> > +
> > if ((nargs != 1) || (nret != 1)) {
> > rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> > return;
> >
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-06-14 5:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 16:44 [Qemu-devel] [PATCH 0/3] xics/kvm: Fix issues with older KVMs on POWER9 hosts Greg Kurz
2019-06-13 16:44 ` [Qemu-devel] [PATCH 1/3] xics/spapr: Prevent RTAS/hypercalls emulation to be used by in-kernel XICS Greg Kurz
2019-06-14 1:34 ` David Gibson
2019-06-14 5:37 ` Greg Kurz [this message]
2019-06-13 16:44 ` [Qemu-devel] [PATCH 2/3] xics/spapr: Register RTAS/hypercalls once at machine init Greg Kurz
2019-06-14 1:38 ` David Gibson
2019-06-13 16:45 ` [Qemu-devel] [PATCH 3/3] xics/spapr: Detect old KVM XICS on POWER9 hosts Greg Kurz
2019-06-14 1:40 ` David Gibson
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=20190614073746.1095f3c5@bahia.lan \
--to=groug@kaod.org \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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;
as well as URLs for NNTP newsgroup(s).