From patchwork Thu Jun 15 00:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikram Garhwal X-Patchwork-Id: 13280579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E754EB64DC for ; Thu, 15 Jun 2023 00:05:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9aTj-0005h8-PG; Wed, 14 Jun 2023 20:04:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9aTe-0005gk-Il for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:04:39 -0400 Received: from mail-mw2nam04on20622.outbound.protection.outlook.com ([2a01:111:f400:7e8c::622] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9aTc-0006bB-0T for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:04:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g/qta4WYWXT02KogmyjfQQpRKsyTRszJrDON3IJ0SeXQsHQTRghisuwZWFiBoDVupk7R9qyTjrOa4tMxiPIyBa/sNnrPJNmSNEtO4SUxaF9z0U3WG7TTi2U1CKoHolIu2szQq4+FlHECiju7sxsqI2b+pzrGHXhoehuuRNtQp8fBX98SOxkwpFWaVbyLjFD1zJNokj1Mdks3dfE8JdXSYew8XzXjERZnSEuERvSx+1piK4GgFlClCah0H5JdWkc9UQOTKD70NBD1nsZGaxKV+uet9lwPzJ00C6HmkAePvqAjyVuNWVmXnbfUn+pcxf74Ou1kPOA6fZ2yJHOm7OlpGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+esgy4HuztqSu8ROePQWFE/nHzxIBFggZqfdRu8CEMM=; b=j/7OMMSkJVV2YMpqSY+J0HclyzhCHV6omdoZZq2UC/du9E9pDNHO2FSfy4Bb2lRUzUVpWbAZ1V8AwWiKB0mMdt7MfB40LiQZIVTHPFfrpkLcclstcMJ8/vGBfCSjQ/wE+VTFWfgPixV3XoMPdRrpjj2KnUoSbAoB1FPnXPIj2nW8JH3CmoIhsCP82DC+wobOIbk1JR6nqaYpnr0iym8K6Lq2XadMWaA9dAxwOt+v3+76XPuoz45ypV5dvsTu3DAIvpEs5qerkwYuv34GASxrsPw1ciWv2VtYjwA/aHv3bHZ/6/9NoVQdaZImLoRRl/zDWYca3UZZbJZJF1pQtB2tkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+esgy4HuztqSu8ROePQWFE/nHzxIBFggZqfdRu8CEMM=; b=gCHYgMNfnXSjBSgQHMf/oiXTef1nJOk7eqq1vh4Bm1i0jcAWvtHgj84Iv6STH2rIYyAKyBbVPsJYjQvZV5Od/xKiydwMU2RUG4n/WMeKC8NGsZmlnMr9i6n7tsTyQTDxh/TlQhb8H4DK4V/msLis2mGiJgajA5+d9sF6KjgPqFY= Received: from SA0PR11CA0032.namprd11.prod.outlook.com (2603:10b6:806:d0::7) by SJ2PR12MB8941.namprd12.prod.outlook.com (2603:10b6:a03:542::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.29; Thu, 15 Jun 2023 00:04:32 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:d0:cafe::81) by SA0PR11CA0032.outlook.office365.com (2603:10b6:806:d0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.38 via Frontend Transport; Thu, 15 Jun 2023 00:04:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.27 via Frontend Transport; Thu, 15 Jun 2023 00:04:31 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 14 Jun 2023 19:04:28 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 14 Jun 2023 17:04:28 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Wed, 14 Jun 2023 19:04:27 -0500 From: Vikram Garhwal To: CC: , Vikram Garhwal , Stefano Stabellini , Anthony Perard , Paul Durrant , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "open list:X86 Xen CPUs" Subject: [QEMU][PATCH v8 02/11] hw/i386/xen: rearrange xen_hvm_init_pc Date: Wed, 14 Jun 2023 17:03:30 -0700 Message-ID: <20230615000340.1135-3-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230615000340.1135-1-vikram.garhwal@amd.com> References: <20230615000340.1135-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|SJ2PR12MB8941:EE_ X-MS-Office365-Filtering-Correlation-Id: b09b3bdf-e70e-46e4-7dae-08db6d341839 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9jsnC67hpUXGZWke6fRSpm7C1mDgAs5mVsc7mjh3Wh+L4Y329hHXu8ORYBqqqdS3BpDRV5KcOKtOdL75wJggEuzeBWZVho/cHaQ/MDzj3BXzvOS2glbVtQTKsIkNGK+r8U+sdm1xGo7zIU0dWFHXeXrm6+/Ij8GVECWgLjsKhjoN+xfcowBWSeLc86NcvgfMMBzp5cifF5hAhMkV4tybyAtmmf5H1JqpRRgv04OZMat/QsdJOl/arQxi0lxNfAKrXoF8PAvNn1totMCSSFPxLmxSjPIZR3TcQ6W6Uu4J2L78Ga4Fb44mEY0HYvEKWCqM6syniq1nopVHteLvuBGM8EImS38mHd9AhkDKVTEyvXUGM/teEezE1S7xvei33BRbO/dNOw3wWQ2VcgI6d3MCSlYNoxacdwP+lnxr7t15TG1T+ng7QVam7vKXNmz8maQ48cFOB2fymhA/5lJbNYBttD2t9o4FBtF1nyEzLUqxEbEdmT4/A9HhtNeONyUxvVQnhXkhxzuG85seJQGh3Tvd2ArFCDctyTUd+88gGXf9FG6KMiuULXY2Q5vaQvskZnXOJF11ZYaNPZl0nuTq6K+pmSpcsL0370SRmOJT7hBLweLvzdQJw9fpm12eBpJGqR3PE8oPL9L0ssxlFM+5SO8/FBUWehoV05eUGrTsLT/8hi80TtmFtTEFgYh7IVDcF998wII9fRTTLcKZlQO7gu6P5TOG5XiyEsnN/bVN4Hh/TnXBj893M5JstlNp6ebtlkGxS97wZG6TxL7I+MgD7VGm4A== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(136003)(376002)(396003)(451199021)(46966006)(40470700004)(36840700001)(70586007)(4326008)(70206006)(8936002)(8676002)(5660300002)(36756003)(6666004)(6916009)(478600001)(54906003)(41300700001)(40480700001)(40460700003)(316002)(81166007)(82740400003)(356005)(186003)(1076003)(7416002)(47076005)(26005)(86362001)(36860700001)(44832011)(2616005)(336012)(426003)(83380400001)(82310400005)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:04:31.4423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b09b3bdf-e70e-46e4-7dae-08db6d341839 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8941 Received-SPF: softfail client-ip=2a01:111:f400:7e8c::622; envelope-from=vikram.garhwal@amd.com; helo=NAM04-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In preparation to moving most of xen-hvm code to an arch-neutral location, move non IOREQ references to: - xen_get_vmport_regs_pfn - xen_suspend_notifier - xen_wakeup_notifier - xen_ram_init towards the end of the xen_hvm_init_pc() function. This is done to keep the common ioreq functions in one place which will be moved to new function in next patch in order to make it common to both x86 and aarch64 machines. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Reviewed-by: Paul Durrant --- hw/i386/xen/xen-hvm.c | 49 ++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index ab8f1b61ee..7a7764240e 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -1419,12 +1419,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) state->exit.notify = xen_exit_notifier; qemu_add_exit_notifier(&state->exit); - state->suspend.notify = xen_suspend_notifier; - qemu_register_suspend_notifier(&state->suspend); - - state->wakeup.notify = xen_wakeup_notifier; - qemu_register_wakeup_notifier(&state->wakeup); - /* * Register wake-up support in QMP query-current-machine API */ @@ -1435,23 +1429,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) goto err; } - rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn); - if (!rc) { - DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn); - state->shared_vmport_page = - xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, - 1, &ioreq_pfn, NULL); - if (state->shared_vmport_page == NULL) { - error_report("map shared vmport IO page returned error %d handle=%p", - errno, xen_xc); - goto err; - } - } else if (rc != -ENOSYS) { - error_report("get vmport regs pfn returned error %d, rc=%d", - errno, rc); - goto err; - } - /* Note: cpus is empty at this point in init */ state->cpu_by_vcpu_id = g_new0(CPUState *, max_cpus); @@ -1490,7 +1467,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) #else xen_map_cache_init(NULL, state); #endif - xen_ram_init(pcms, ms->ram_size, ram_memory); qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state); @@ -1511,6 +1487,31 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) QLIST_INIT(&xen_physmap); xen_read_physmap(state); + state->suspend.notify = xen_suspend_notifier; + qemu_register_suspend_notifier(&state->suspend); + + state->wakeup.notify = xen_wakeup_notifier; + qemu_register_wakeup_notifier(&state->wakeup); + + rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn); + if (!rc) { + DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn); + state->shared_vmport_page = + xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, + 1, &ioreq_pfn, NULL); + if (state->shared_vmport_page == NULL) { + error_report("map shared vmport IO page returned error %d handle=%p", + errno, xen_xc); + goto err; + } + } else if (rc != -ENOSYS) { + error_report("get vmport regs pfn returned error %d, rc=%d", + errno, rc); + goto err; + } + + xen_ram_init(pcms, ms->ram_size, ram_memory); + /* Disable ACPI build because Xen handles it */ pcms->acpi_build_enabled = false;