From patchwork Wed Jun 19 20:40:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 252664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C22DE2C00A0 for ; Thu, 20 Jun 2013 06:49:52 +1000 (EST) Received: from localhost ([::1]:35783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpPKA-0002YO-Ux for incoming@patchwork.ozlabs.org; Wed, 19 Jun 2013 16:49:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpPDY-0002vn-D4 for qemu-devel@nongnu.org; Wed, 19 Jun 2013 16:43:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpPDX-0005Vx-6R for qemu-devel@nongnu.org; Wed, 19 Jun 2013 16:43:00 -0400 Received: from e32.co.us.ibm.com ([32.97.110.150]:50708) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpPDX-0005Vr-09 for qemu-devel@nongnu.org; Wed, 19 Jun 2013 16:42:59 -0400 Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Jun 2013 14:42:58 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 19 Jun 2013 14:41:24 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 3CE643E4004F; Wed, 19 Jun 2013 14:40:34 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5JKeiKT077782; Wed, 19 Jun 2013 14:40:47 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5JKeiUp021139; Wed, 19 Jun 2013 14:40:44 -0600 Received: from titi.austin.rr.com ([9.49.221.0]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r5JKeaBa020317; Wed, 19 Jun 2013 14:40:42 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2013 15:40:25 -0500 Message-Id: <1371674435-14973-3-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1371674435-14973-1-git-send-email-aliguori@us.ibm.com> References: <1371674435-14973-1-git-send-email-aliguori@us.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13061920-5406-0000-0000-000009B47F04 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.110.150 Cc: Anthony Liguori , Alexey Kardashevskiy , Alex Graf , qemu-ppc@nongnu.org, Paul Mackerras , Andreas Faerber Subject: [Qemu-devel] [PATCH 02/12] qtest: add spapr hypercall support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Anthony Liguori --- qtest.c | 29 +++++++++++++++++++++++++++++ tests/libqtest.c | 18 ++++++++++++++++++ tests/libqtest.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/qtest.c b/qtest.c index 07a9612..f8c8f44 100644 --- a/qtest.c +++ b/qtest.c @@ -19,6 +19,9 @@ #include "hw/irq.h" #include "sysemu/sysemu.h" #include "sysemu/cpus.h" +#ifdef TARGET_PPC64 +#include "hw/ppc/spapr.h" +#endif #define MAX_IRQ 256 @@ -141,6 +144,13 @@ static bool qtest_opened; * where NUM is an IRQ number. For the PC, interrupts can be intercepted * simply with "irq_intercept_in ioapic" (note that IRQ0 comes out with * NUM=0 even though it is remapped to GSI 2). + * + * Platform specific (sPAPR): + * + * > papr_hypercall NR ARG0 ARG1 ... ARG8 + * < OK RET + * + * where NR, ARG[0-8] and RET are all integers. */ static int hex2nib(char ch) @@ -425,6 +435,25 @@ static void qtest_process_command(CharDriverState *chr, gchar **words) qtest_clock_warp(ns); qtest_send_prefix(chr); qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_get_clock_ns(vm_clock)); +#ifdef TARGET_PPC64 + } else if (strcmp(words[0], "papr_hypercall") == 0) { + uint64_t nr; + uint64_t args[9]; + uint64_t ret; + int i; + + memset(args, 0, sizeof(args)); + g_assert(words[1]); + nr = strtoull(words[1], NULL, 0); + for (i = 0; i < 9; i++) { + if (words[2 + i] == NULL) { + break; + } + args[i] = strtoull(words[2 + i], NULL, 0); + } + ret = spapr_hypercall(ppc_env_get_cpu(first_cpu), nr, args); + qtest_send(chr, "OK 0x%" PRIx64 "\n", ret); +#endif } else { qtest_send_prefix(chr); qtest_send(chr, "FAIL Unknown command `%s'\n", words[0]); diff --git a/tests/libqtest.c b/tests/libqtest.c index 879ffe9..81107cf 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -544,3 +544,21 @@ void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size) qtest_sendf(s, "\n"); qtest_rsp(s, 0); } + +uint64_t qtest_spapr_hcall9(QTestState *s, uint64_t nr, uint64_t a0, + uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, + uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8) +{ + gchar **args; + uint64_t value; + + qtest_sendf(s, "papr_hypercall 0x%" PRIx64 " 0x%" PRIx64 + " 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 + " 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 + "\n", nr, a0, a1, a2, a3, a4, a5, a6, a7, a8); + args = qtest_rsp(s, 2); + value = strtoull(args[1], NULL, 0); + g_strfreev(args); + + return value; +} diff --git a/tests/libqtest.h b/tests/libqtest.h index 437bda3..592f035 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -286,6 +286,19 @@ int64_t qtest_clock_step(QTestState *s, int64_t step); int64_t qtest_clock_set(QTestState *s, int64_t val); /** + * qtest_spapr_hcall9: + * @s: QTestState instance to operate on. + * @nr: The hypercall index + * @aN: The @Nth hypercall argument + * + * Issue an sPAPR hypercall + * + * Returns: The result of the hypercall. + */ +uint64_t qtest_spapr_hcall9(QTestState *s, uint64_t nr, uint64_t a0, + uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, + uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8); +/** * qtest_get_arch: * * Returns: The architecture for the QEMU executable under test. @@ -607,4 +620,37 @@ static inline int64_t clock_set(int64_t val) return qtest_clock_set(global_qtest, val); } +static inline uint64_t spapr_hcall0(uint64_t nr) +{ + return qtest_spapr_hcall9(global_qtest, nr, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +static inline uint64_t spapr_hcall1(uint64_t nr, uint64_t a0) +{ + return qtest_spapr_hcall9(global_qtest, nr, a0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +static inline uint64_t spapr_hcall2(uint64_t nr, uint64_t a0, uint64_t a1) +{ + return qtest_spapr_hcall9(global_qtest, nr, a0, a1, 0, 0, 0, 0, 0, 0, 0); +} + +static inline uint64_t spapr_hcall3(uint64_t nr, uint64_t a0, uint64_t a1, + uint64_t a2) +{ + return qtest_spapr_hcall9(global_qtest, nr, a0, a1, a2, 0, 0, 0, 0, 0, 0); +} + +static inline uint64_t spapr_hcall4(uint64_t nr, uint64_t a0, uint64_t a1, + uint64_t a2, uint64_t a3) +{ + return qtest_spapr_hcall9(global_qtest, nr, a0, a1, a2, a3, 0, 0, 0, 0, 0); +} + +static inline uint64_t spapr_hcall5(uint64_t nr, uint64_t a0, uint64_t a1, + uint64_t a2, uint64_t a3, uint64_t a4) +{ + return qtest_spapr_hcall9(global_qtest, nr, a0, a1, a2, a3, a4, 0, 0, 0, 0); +} + #endif