From patchwork Tue Oct 31 20:43:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 10035395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F3856602B9 for ; Tue, 31 Oct 2017 20:47:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E59132834A for ; Tue, 31 Oct 2017 20:47:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D956C28578; Tue, 31 Oct 2017 20:47:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F15A2834A for ; Tue, 31 Oct 2017 20:47:15 +0000 (UTC) Received: from localhost ([::1]:47320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9dRK-0002fW-KE for patchwork-qemu-devel@patchwork.kernel.org; Tue, 31 Oct 2017 16:47:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9dO7-00010i-Aa for qemu-devel@nongnu.org; Tue, 31 Oct 2017 16:43:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9dO4-0004DO-PM for qemu-devel@nongnu.org; Tue, 31 Oct 2017 16:43:55 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56388) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e9dO4-0004CJ-Hi for qemu-devel@nongnu.org; Tue, 31 Oct 2017 16:43:52 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9VKeoji086163 for ; Tue, 31 Oct 2017 16:43:51 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dxv42nqf3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 31 Oct 2017 16:43:51 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 31 Oct 2017 14:43:50 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 31 Oct 2017 14:43:47 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9VKhknV8061322; Tue, 31 Oct 2017 13:43:46 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91E7AC603E; Tue, 31 Oct 2017 14:43:46 -0600 (MDT) Received: from localhost.localdomain (unknown [9.85.136.158]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id E5ECBC603C; Tue, 31 Oct 2017 14:43:44 -0600 (MDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Tue, 31 Oct 2017 18:43:29 -0200 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171031204330.14803-1-danielhb@linux.vnet.ibm.com> References: <20171031204330.14803-1-danielhb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17103120-8235-0000-0000-00000C7EA671 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007988; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00939263; UDB=6.00473526; IPR=6.00719524; BA=6.00005666; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017811; XFM=3.00000015; UTC=2017-10-31 20:43:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17103120-8236-0000-0000-00003E43733D Message-Id: <20171031204330.14803-4-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-31_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710310252 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 3/4] tests: ibm, configure-connector RTAS call implementation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 'ibm,configure-connector' hypercall is used by the guest OS to start the configuration of a given device, where the machine configures the said device and all its sub-devices, giving back FDTs to the caller for each sub-device. This hypercall is supposed to be called multiple times by the guest OS until it returns RTAS_OUT_SUCESS (code 0), indicating that the device is now properly configured and ready to be used, or a return value < 0 when an error occurs. This patch implements the 'ibm,configure-connector' RTAS hypercall in tests/libqos/rtas.c, with an extra test case for it inside tests/rtas-tests.c. Signed-off-by: Daniel Henrique Barboza --- tests/libqos/rtas.c | 35 +++++++++++++++++++++++++++ tests/libqos/rtas.h | 1 + tests/rtas-test.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) diff --git a/tests/libqos/rtas.c b/tests/libqos/rtas.c index ade572a84f..1cb9e2b495 100644 --- a/tests/libqos/rtas.c +++ b/tests/libqos/rtas.c @@ -184,3 +184,38 @@ int qrtas_set_indicator(QGuestAllocator *alloc, uint32_t type, uint32_t idx, return ret[0]; } + +/* + * ibm,configure-connector as defined by PAPR 2.7+, 13.5.3.5 + * + * nargs = 2 + * nrets = 1 + * + * args[0] and args[1] compose the 64 bit Work Area address. + * + * This call will configure not only the device reported in the first + * offset of the Work Area but all of its siblingis as well, returning + * the FDT of each configured sub-device as well as a return code + * 'Next child', 'Next property' or 'Previous parent'. When the whole + * configuration is done, 'Configuration completed' (0) is returned. + * + * configure-connector will always reply with status code 'Next child'(2) + * on the first successful call. The DRC configuration will be + * completed when configure-connector returns status 0. Any return + * status < 0 indicates an error. + */ +int qrtas_ibm_configure_connector(QGuestAllocator *alloc, uintptr_t wa_addr) +{ + uint32_t args[2], ret[1]; + int res; + + args[0] = (uint32_t)(wa_addr); + args[1] = (uint32_t)(wa_addr >> 32); + + res = qrtas_call(alloc, "ibm,configure-connector", 2, args, 1, ret); + if (res != 0) { + return -1; + } + + return ret[0]; +} diff --git a/tests/libqos/rtas.h b/tests/libqos/rtas.h index 9dfa18f32b..35c44fb967 100644 --- a/tests/libqos/rtas.h +++ b/tests/libqos/rtas.h @@ -16,4 +16,5 @@ int qrtas_check_exception(QGuestAllocator *alloc, uint32_t mask, uint32_t buf_addr, uint32_t buf_len); int qrtas_set_indicator(QGuestAllocator *alloc, uint32_t type, uint32_t idx, uint32_t new_state); +int qrtas_ibm_configure_connector(QGuestAllocator *alloc, uintptr_t wa_addr); #endif /* LIBQOS_RTAS_H */ diff --git a/tests/rtas-test.c b/tests/rtas-test.c index 2c34b6e83c..b3538bf878 100644 --- a/tests/rtas-test.c +++ b/tests/rtas-test.c @@ -15,6 +15,8 @@ #define SPAPR_DR_ALLOCATION_STATE_USABLE 1 #define SPAPR_DR_ISOLATION_STATE_UNISOLATED 1 +#define CC_WA_LEN 4096 + static void test_rtas_get_time_of_day(void) { QOSState *qs; @@ -169,6 +171,70 @@ static void test_rtas_set_indicator(void) qtest_shutdown(qs); } +static void test_rtas_ibm_configure_connector(void) +{ + QOSState *qs; + uint64_t ret; + uintptr_t guest_buf_addr, guest_drc_addr; + uint32_t drc_index; + uint8_t *buf = g_malloc0(EVENT_LOG_LEN); + + qs = qtest_spapr_boot("-machine pseries -cpu POWER8_v2.0 " + "-smp 1,sockets=4,cores=1,threads=1,maxcpus=4"); + + guest_buf_addr = guest_alloc(qs->alloc, EVENT_LOG_LEN * sizeof(uint8_t)); + qtest_qmp_device_add("power8_v2.0-spapr-cpu-core", "id-1", + "'core-id':'1'"); + + ret = qrtas_check_exception(qs->alloc, EVENT_MASK_EPOW, + guest_buf_addr, EVENT_LOG_LEN); + + memread(guest_buf_addr, buf, EVENT_LOG_LEN); + guest_free(qs->alloc, guest_buf_addr); + + g_assert_cmpint(ret, ==, 0); + + /* + * Same 108 bytes offset magic used and explained in + * test_rtas_set_indicator. + */ + drc_index = be32toh(*((uint32_t *)(buf + 108))); + g_free(buf); + + ret = qrtas_set_indicator(qs->alloc, RTAS_SENSOR_TYPE_ALLOCATION_STATE, + drc_index, SPAPR_DR_ALLOCATION_STATE_USABLE); + g_assert_cmpint(ret, ==, 0); + + ret = qrtas_set_indicator(qs->alloc, RTAS_SENSOR_TYPE_ISOLATION_STATE, + drc_index, SPAPR_DR_ISOLATION_STATE_UNISOLATED); + g_assert_cmpint(ret, ==, 0); + + /* + * Call ibm,configure-connector to finish the hotplugged device + * configuration, putting its DRC into 'ready' state. + * + * We're not interested in the generated FDTs during the config + * process, thus we simply keep calling configure-connector + * until it returns SUCCESS(0) or an error. + * + * The full explanation logic behind this process can be found + * at PAPR 2.7+, 13.5.3.5. + */ + guest_drc_addr = guest_alloc(qs->alloc, CC_WA_LEN * sizeof(uint32_t)); + writel(guest_drc_addr, drc_index); + writel(guest_drc_addr + sizeof(uint32_t), 0); + + do { + ret = qrtas_ibm_configure_connector(qs->alloc, guest_drc_addr); + } while (ret > 0); + + guest_free(qs->alloc, guest_drc_addr); + + g_assert_cmpint(ret, ==, 0); + + qtest_shutdown(qs); +} + int main(int argc, char *argv[]) { const char *arch = qtest_get_arch(); @@ -185,6 +251,8 @@ int main(int argc, char *argv[]) qtest_add_func("rtas/rtas-check-exception-hotplug-event", test_rtas_check_exception_hotplug_event); qtest_add_func("rtas/test_rtas_set_indicator", test_rtas_set_indicator); + qtest_add_func("rtas/test_rtas_ibm_configure_connector", + test_rtas_ibm_configure_connector); return g_test_run(); }