From patchwork Fri Sep 21 08:18:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10609265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D753112B for ; Fri, 21 Sep 2018 08:23:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CCA32DAC8 for ; Fri, 21 Sep 2018 08:23:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30E8F2DACA; Fri, 21 Sep 2018 08:23:34 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 A87AB2DAC8 for ; Fri, 21 Sep 2018 08:23:32 +0000 (UTC) Received: from localhost ([::1]:54376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Gip-0007l3-SV for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 04:23:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3GeL-0003Y7-TA for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:18:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3GeJ-0000rh-55 for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:18:53 -0400 Received: from mail-eopbgr60092.outbound.protection.outlook.com ([40.107.6.92]:32788 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3GeI-0000gL-Sh for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:18:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gP9QO3cA6DLSG290YmJ/C8r0B7D7AWYJm0+M+7ejm+o=; b=cZjhUmsjHjFSKR3dXMGvV33ZQPdcw4xENcx8So/MGPGx58l/cIyIqQBriCYZYz5gm2W53g3qNT+uiBKuuuuUkq4OH3aQKg4/Jm/74es0WvDUAVcHUOtdMievMJ6n5yFR73AdSZ37mzby7Ko1oXZve9lfzbC2xQDJ3B2P6pkwskQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (185.231.240.5) by AM0PR08MB3586.eurprd08.prod.outlook.com (2603:10a6:208:e1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 08:18:46 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 11:18:29 +0300 Message-Id: <20180921081836.29230-2-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921081836.29230-1-rkagan@virtuozzo.com> References: <20180921081836.29230-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: VI1P193CA0009.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::19) To AM0PR08MB3586.eurprd08.prod.outlook.com (2603:10a6:208:e1::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92aa4807-820f-4d02-e8cb-08d61f9adab9 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3586; X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3586; 3:fU8daxIstPJbgXC/kmrcspVpQlleSz7ChYnaXE4p8KOYjSZMUy4GbdwMMSQnLtCtzQqDwaGMYbVmAEa1hGzJ4L0Za30MrTKgfjpbl+Mie0rpFM3bLiDu6Rq+rsGFDSZ5Gmex2VxeybZqUSYk/cWYqmSviy2kXU6fZNwNMUwMjZmzcjvcbMnSCqsio0riREp+GAEhfeZNAraUDnKzFV8zBAwnpDZOk2vADghtBisHfTdvtMsXkPgSo5Y/Pwmz/zIP; 25:Ex/Ed+0s3yfvcGmMEyDExoZfk3DJ7/8V1V1jF9vtXs25m0kh4d4WnkSMiHtY90y6Mo1EO1Mzxe8E4eoObOs6Mi5lg+m74EKWbwqBsat85S0BGkb8e2BrrnmZMza5ttDX4qGxw+jvrsHuTZSqD9NhS5peNJkXgIzYqaITUWYHHPp87bHy7/RLiIX/ghGwhbLS9W71mX571StS5OjDGa5Pt7VVTZ3V279UdTa5PGfg170GekIq1thnZ3Jm1biA0Y7D7zH03sIluiIJze1pyh2bQ/92rmwC5XRaoUQU7C2IdNki2mQPK91Rcsq7245+lZnKhZ0fteUMJcc4SPonkP5t2Q==; 31:T7qAD/PUctqkxHHNbvS3wvQElYo+zWWOOu+izvz8+Pgt4lI6YSp2ILjwTjtV1GlQhKRcDU+STz4CEfXehOeX89iq3g808w8XAh4z3VJEpVHD1x+fKR3SQBmrpAkfXSraXg71m/TvbgRbuiFpSBcvcU/hos96fLu6UatAPy57uCtaEsik35jMNXtdKSdIJ6OOli/1Uzv4sOStbYIhysL8864ShgWfjOeDsTryGDxP4wA= X-MS-TrafficTypeDiagnostic: AM0PR08MB3586: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3586; 20:MT2BbSbGcClgujs8H9v60YNX8pGKY9upQbtu8NdJPYMhGdWPoge9qXvgf1F65EvsuzJVtLu1QyFlsP8OZ3IukAiZiyXcxD0t1oz6M9Tqe2P0qin8pIntg65jeNgJKtNtbc1tJk2ovNS8J0VXnE9hiMXgob0YdODNy1nf9c4GNBvGGGsP2/gLskpXG9k02OsfKxAcvUn1bo7ilDuKvNPOujeagGtkggKC1tiMDmvU6nROiYye8c9N7mlhn4wXVwx2JPxSM9NoQXj1v5qqIOX6H4jaMHJPQHk7iq+Rdvcr0T04FJJjA2WH1SZ71HULHfQ2iQq5Kuy2K51N9DG0xGGrONrWyyRWtclZrvU4uGYgFvfeQZ3HGBjCv0xX1cxO4i7oOdkv8phT3Egkr23Z3OU33VvEbY4cew3hTakOmVPheO3oznuCNUsfk9yRgvDYrwkhdtiDmUpuNq2x7Gnot1+Nl6u/dwlch9iiQHRUAEWs1m8fGEUZx5WawuMbJ/GOS/1B; 4:1LcM+QZz8xLchoMpM0KQ5xxRLlG/T8Sh3oPhMAlavZ4Wyi9txS7xtsPyQQV6WPOp7FPxJpPpeYrZhmvmFmK7mZkGfNp3oqSyZ3ma7rSx809zVasI/xx0slkxQ83y69Uo2QSLpu7NyU/z3h8ThwiPOVsoFxLlfafPxvS7vyxPwB2bFOg/460o8Pid0j0+zLFQrMJ/ZMAeiM/InkhQMQy7CUFG0JuF/Ls/UzZW3Fz74LbeeMg7CexS8nFl7nhkkUAldU72mlbvZVD9eCHn7DNF1w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:AM0PR08MB3586; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3586; X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(39840400004)(376002)(366004)(346002)(189003)(199004)(2906002)(81156014)(50466002)(51416003)(305945005)(25786009)(2361001)(478600001)(316002)(7416002)(54906003)(86362001)(16586007)(26005)(52116002)(48376002)(8936002)(36756003)(76176011)(186003)(50226002)(386003)(69596002)(2351001)(53416004)(106356001)(6486002)(11346002)(476003)(446003)(8676002)(16526019)(5660300001)(2616005)(956004)(6506007)(81166006)(68736007)(6116002)(1076002)(6666003)(486006)(105586002)(97736004)(4326008)(7736002)(3846002)(47776003)(6512007)(66066001)(6916009)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3586; H:rkaganb.sw.ru; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR08MB3586; 23:53RcXXyAvSvxT6olVos7G7AlzxP/MF1K6YvchxOs8?= jMWgv3TErAwxxpIEQIQnzCQ23ffaWdk0x1FuMlAe4pjWbCGRtZhFNcQKP8fEiXFDVx9J9LQTB4pB0CuVcdIcNSYp/QrxPOI1ywKaxwEwPIG2Vn7dHXXAOSaa470Z3lJ3bhn0yEQZSCirbU/bVE5ZsVridzLqaByA2MbxLnyia1BpMI0Brh+f67+PkA8Yu+IJSO3BLJSfqMnlQf5fxu58wZD6D0ehCjD13iVB6TxXf/7a+W5U+MhFPu+laiIBYxaAWUpblRaZPYwfYCnXXxHvoSJ2sg0C/OY+Stf2LVwv2wF1lADBxh0bOQpBTnaVue6PVmJYCRcvNzU1jm78o/M3DXJAYwL37a+p4Pg4vVtQbsRPT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ltzBZbfNHxFmiapNDnPxZV2n5bYU3cndnbJCUsWWjYbI96TClIZOk+WquugnqDg6vkf SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3586; 20:WHPQWsxzjr1d/Xn9rDx9ywuDpkWfaEleoP3o/iWAh54KDlUCWEmrS8Ef0IwuWBH3nXl7F5m4NypXTmCD8/B6Ng8IySL0+iqDC1+DDzDvPwPRS1HMmweLyUA3fUUGIuiJEN/vY1bQXlq48SsZPnjwr+Q9ciFbKXcuEv1sNbRX6qc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 08:18:46.3294 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92aa4807-820f-4d02-e8cb-08d61f9adab9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3586 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.6.92 Subject: [Qemu-devel] [PATCH v2 1/8] hyperv_testdev: refactor for better maintainability 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: Vijayabhaskar Balakrishna , Eduardo Habkost , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Venu Busireddy , Liran Alon , Paolo Bonzini , Si-Wei Liu , Igor Mammedov , Boris Ostrovsky , Karl Heubaum Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make hyperv_testdev slightly easier to follow and enhance in future. For that, put the hyperv sint routes (wrapped in a helper structure) on a linked list rather than a fixed-size array. Besides, this way HvSintRoute can be treated as an opaque structure, allowing for easier refactoring of the core Hyper-V SynIC code in followup pathches. Signed-off-by: Roman Kagan --- hw/misc/hyperv_testdev.c | 116 +++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 61 deletions(-) diff --git a/hw/misc/hyperv_testdev.c b/hw/misc/hyperv_testdev.c index bf6bbfa8cf..de07d7e8c3 100644 --- a/hw/misc/hyperv_testdev.c +++ b/hw/misc/hyperv_testdev.c @@ -12,6 +12,7 @@ */ #include "qemu/osdep.h" +#include "qemu/queue.h" #include #include "hw/hw.h" #include "hw/qdev.h" @@ -20,12 +21,17 @@ #include "target/i386/hyperv.h" #include "kvm_i386.h" -#define HV_TEST_DEV_MAX_SINT_ROUTES 64 +typedef struct TestSintRoute { + QLIST_ENTRY(TestSintRoute) le; + uint8_t vp_index; + uint8_t sint; + HvSintRoute *sint_route; +} TestSintRoute; struct HypervTestDev { ISADevice parent_obj; MemoryRegion sint_control; - HvSintRoute *sint_route[HV_TEST_DEV_MAX_SINT_ROUTES]; + QLIST_HEAD(, TestSintRoute) sint_routes; }; typedef struct HypervTestDev HypervTestDev; @@ -39,88 +45,76 @@ enum { HV_TEST_DEV_SINT_ROUTE_SET_SINT }; -static int alloc_sint_route_index(HypervTestDev *dev) +static void sint_route_create(HypervTestDev *dev, + uint8_t vp_index, uint8_t sint) { - int i; + TestSintRoute *sint_route; - for (i = 0; i < ARRAY_SIZE(dev->sint_route); i++) { - if (dev->sint_route[i] == NULL) { - return i; - } - } - return -1; -} + sint_route = g_new0(TestSintRoute, 1); + assert(sint_route); -static void free_sint_route_index(HypervTestDev *dev, int i) -{ - assert(i >= 0 && i < ARRAY_SIZE(dev->sint_route)); - dev->sint_route[i] = NULL; + sint_route->vp_index = vp_index; + sint_route->sint = sint; + + sint_route->sint_route = kvm_hv_sint_route_create(vp_index, sint, NULL); + assert(sint_route->sint_route); + + QLIST_INSERT_HEAD(&dev->sint_routes, sint_route, le); } -static int find_sint_route_index(HypervTestDev *dev, uint32_t vp_index, - uint32_t sint) +static TestSintRoute *sint_route_find(HypervTestDev *dev, + uint8_t vp_index, uint8_t sint) { - HvSintRoute *sint_route; - int i; + TestSintRoute *sint_route; - for (i = 0; i < ARRAY_SIZE(dev->sint_route); i++) { - sint_route = dev->sint_route[i]; - if (sint_route && sint_route->vp_index == vp_index && - sint_route->sint == sint) { - return i; + QLIST_FOREACH(sint_route, &dev->sint_routes, le) { + if (sint_route->vp_index == vp_index && sint_route->sint == sint) { + return sint_route; } } - return -1; + assert(false); + return NULL; } -static void hv_synic_test_dev_control(HypervTestDev *dev, uint32_t ctl, - uint32_t vp_index, uint32_t sint) +static void sint_route_destroy(HypervTestDev *dev, + uint8_t vp_index, uint8_t sint) { - int i; - HvSintRoute *sint_route; + TestSintRoute *sint_route; - switch (ctl) { - case HV_TEST_DEV_SINT_ROUTE_CREATE: - i = alloc_sint_route_index(dev); - assert(i >= 0); - sint_route = kvm_hv_sint_route_create(vp_index, sint, NULL); - assert(sint_route); - dev->sint_route[i] = sint_route; - break; - case HV_TEST_DEV_SINT_ROUTE_DESTROY: - i = find_sint_route_index(dev, vp_index, sint); - assert(i >= 0); - sint_route = dev->sint_route[i]; - kvm_hv_sint_route_destroy(sint_route); - free_sint_route_index(dev, i); - break; - case HV_TEST_DEV_SINT_ROUTE_SET_SINT: - i = find_sint_route_index(dev, vp_index, sint); - assert(i >= 0); - sint_route = dev->sint_route[i]; - kvm_hv_sint_route_set_sint(sint_route); - break; - default: - break; - } + sint_route = sint_route_find(dev, vp_index, sint); + QLIST_REMOVE(sint_route, le); + kvm_hv_sint_route_destroy(sint_route->sint_route); + g_free(sint_route); +} + +static void sint_route_set_sint(HypervTestDev *dev, + uint8_t vp_index, uint8_t sint) +{ + TestSintRoute *sint_route; + + sint_route = sint_route_find(dev, vp_index, sint); + + kvm_hv_sint_route_set_sint(sint_route->sint_route); } static void hv_test_dev_control(void *opaque, hwaddr addr, uint64_t data, uint32_t len) { HypervTestDev *dev = HYPERV_TEST_DEV(opaque); - uint8_t ctl; + uint8_t sint = data & 0xFF; + uint8_t vp_index = (data >> 8ULL) & 0xFF; + uint8_t ctl = (data >> 16ULL) & 0xFF; - ctl = (data >> 16ULL) & 0xFF; switch (ctl) { case HV_TEST_DEV_SINT_ROUTE_CREATE: + sint_route_create(dev, vp_index, sint); + break; case HV_TEST_DEV_SINT_ROUTE_DESTROY: - case HV_TEST_DEV_SINT_ROUTE_SET_SINT: { - uint8_t sint = data & 0xFF; - uint8_t vp_index = (data >> 8ULL) & 0xFF; - hv_synic_test_dev_control(dev, ctl, vp_index, sint); + sint_route_destroy(dev, vp_index, sint); + break; + case HV_TEST_DEV_SINT_ROUTE_SET_SINT: + sint_route_set_sint(dev, vp_index, sint); break; - } default: break; } @@ -139,7 +133,7 @@ static void hv_test_dev_realizefn(DeviceState *d, Error **errp) HypervTestDev *dev = HYPERV_TEST_DEV(d); MemoryRegion *io = isa_address_space_io(isa); - memset(dev->sint_route, 0, sizeof(dev->sint_route)); + QLIST_INIT(&dev->sint_routes); memory_region_init_io(&dev->sint_control, OBJECT(dev), &synic_test_sint_ops, dev, "hyperv-testdev-ctl", 4);