From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9uhL-0004sF-OA for qemu-devel@nongnu.org; Tue, 30 Jun 2015 08:31:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9uh8-0000tg-B9 for qemu-devel@nongnu.org; Tue, 30 Jun 2015 08:31:35 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:40528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9uh8-0000tT-1G for qemu-devel@nongnu.org; Tue, 30 Jun 2015 08:31:22 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 30 Jun 2015 13:31:19 +0100 Date: Tue, 30 Jun 2015 14:31:10 +0200 From: Greg Kurz Message-ID: <20150630143110.6507c553@bahia.local> In-Reply-To: <20150630120431.11866.32507.stgit@bahia.lab.toulouse-stg.fr.ibm.com> References: <20150630120431.11866.32507.stgit@bahia.lab.toulouse-stg.fr.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] spapr_vty: lookup should only return valid VTY objects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org On Tue, 30 Jun 2015 14:04:31 +0200 Greg Kurz wrote: > If a guest passes the reg property of a valid VIO object that is not a VTY > to either H_GET_TERM_CHAR or H_PUT_TERM_CHAR, QEMU hits a dynamic cast > assertion and aborts. > > PAPR+ says "Hypervisor checks the termno parameter for validity against the > Vterm IOA unit addresses assigned to the partition, else return H_Parameter." > > This patch adds a type check to ensure vty_lookup() either returns a pointer > to a valid VTY object or NULL. H_GET_TERM_CHAR and H_PUT_TERM_CHAR will > now return H_PARAMETER to the guest instead of crashing. > > The patch has no effect on the reg == 0 hack used to implement the RTAS call > display-character. > > Signed-off-by: Greg Kurz > --- Oops I forgot to Cc: the QEMU PPC mailing list... > hw/char/spapr_vty.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c > index 4e464bd15a54..7eeacde31d27 100644 > --- a/hw/char/spapr_vty.c > +++ b/hw/char/spapr_vty.c > @@ -228,7 +228,7 @@ VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg) > return spapr_vty_get_default(spapr->vio_bus); > } > > - return sdev; > + return object_dynamic_cast(sdev, TYPE_VIO_SPAPR_VTY_DEVICE); > } > > static void spapr_vty_register_types(void) > >