From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787528; cv=pass; d=zohomail.com; s=zohoarc; b=Ks/FTRQ1bH7oj8rph9SofaBElqHhW3GuJplzAbAD/vt9QC/TsweFRUlVjhMIl0UJbupeBIp/AJJof/A6wTodExd0Vm3JpPA1R2391ZFkv8VmAR5rRfNfseKCZYSZdoU/vBl8WOO7oiaw/3B59IvG/PuF2P51LBcA/vuWQ6Erogs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787528; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FR4BawIl2nyLOoaRXHWpiEutGsBER4awTYitO3dxACs=; b=GoFdFFd2E9cjMO85JOg2tfS6Hs2EFbxRYCTdZcloIRuQxv4vwUhX1tuVgIFWP3BJsjKxHJSzf59mukOEOSX6ZAeIHx90gq1CUQ7AdoODo/zeD8SgOh8FViZsKvqfArukdTHiNorhTyAl9tcdcHGEuQ+th+rX+kMUJXYuUFrycyI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1686787528447919.4290539025587; Wed, 14 Jun 2023 17:05:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.549302.857757 (Exim 4.92) (envelope-from ) id 1q9aU6-0006Vj-0T; Thu, 15 Jun 2023 00:05:06 +0000 Received: by outflank-mailman (output) from mailman id 549302.857757; Thu, 15 Jun 2023 00:05:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aU5-0006VZ-Tz; Thu, 15 Jun 2023 00:05:05 +0000 Received: by outflank-mailman (input) for mailman id 549302; Thu, 15 Jun 2023 00:05:05 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aU5-0006Ty-7E for xen-devel@lists.xenproject.org; Thu, 15 Jun 2023 00:05:05 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20619.outbound.protection.outlook.com [2a01:111:f400:7eaa::619]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 469b7c6b-0b10-11ee-b232-6b7b168915f2; Thu, 15 Jun 2023 02:05:03 +0200 (CEST) Received: from MW4PR04CA0271.namprd04.prod.outlook.com (2603:10b6:303:89::6) by SA1PR12MB6969.namprd12.prod.outlook.com (2603:10b6:806:24c::14) 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:05:00 +0000 Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::fd) by MW4PR04CA0271.outlook.office365.com (2603:10b6:303:89::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37 via Frontend Transport; Thu, 15 Jun 2023 00:05:00 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT022.mail.protection.outlook.com (10.13.175.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.25 via Frontend Transport; Thu, 15 Jun 2023 00:04:30 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) 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:27 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) 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:03:55 -0500 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:03:55 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 469b7c6b-0b10-11ee-b232-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ER2yf5I9umHz63PNCorqZKGXapXaeDX2XJJZaLw/XDpXsWbPnpoePZ/NM6w8ZpwIaEV890ElfJm2lUK3VbTuREtZufOznHXZ4s2nkcvJz8sTf5v1HJ0u49xcAHtO1r1ljGcKmb9Q5UxWaOcn26owZopsulGYzhgOrLX+OjyBZiHOaviXWE/nHVqXKHQuULVZUUYnJSirX/LzBXbC8X4WS+iYPMkju3VZ4vjgfKyY7tQto/EpQC7AB+sFiM3mOM7pmwDMhZoTfLqpkScgS+IoLjIXglzfSXfInJ11ak3xoggpVy2HIJR2YlVEBdVJyV3jzE8iZeINWuYy6p82awnuAA== 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=FR4BawIl2nyLOoaRXHWpiEutGsBER4awTYitO3dxACs=; b=iw5299sIwsEPhUBXMO5q5LpvXBgceQh8C/YvvSm/o6jO+BuO2rNe6spreb3DOKfQ1HQfz98yJfh46Iy5rJ1XWwIOl168sMehKGeDHoNQvnyNWFsKejBkNKuE4O/Q/hJm5Jm20j1exppnbalmefD8v3rSOtxDytK5SJB+1b6vCCe6TS14x6YfYnhiOPUB6WEBb3TTo71058rXJ5N6nmfJ5+vjPnaYWqhf4m5GKD7fsG6QLWZ1fnTssyjOxaF05V7d5Bs5fbtUpqxrJFTCLY0+eUYZdX5hIg2zXT79AixN5t8H2ElP7Iz3LSW98Wx2pQbl6HQD4CwYHWXvc/XnrMdbaQ== 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=FR4BawIl2nyLOoaRXHWpiEutGsBER4awTYitO3dxACs=; b=G80Ir7+qKGAeT6VzGg4HMVWr7pS6LGUOYhDKBSCpFeXKbT9+e5r8FSWcybf9AWRegyGaio1+XjW0sunbtn3/8ApWaKbMhYdQ8lBg7X5zyrgMjk63Xf1EGiuh5ib5N954eTAqBLzwhXReKa825aiYkREZqeLvdGnb3c8F6yB27HE= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Stefano Stabellini , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Anthony Perard , Paul Durrant , "open list:X86 Xen CPUs" Subject: [QEMU][PATCH v8 01/11] hw/i386/xen/: move xen-mapcache.c to hw/xen/ Date: Wed, 14 Jun 2023 17:03:29 -0700 Message-ID: <20230615000340.1135-2-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: CO1NAM11FT022:EE_|SA1PR12MB6969:EE_ X-MS-Office365-Filtering-Correlation-Id: e5ff215b-b21f-46e6-d087-08db6d3428b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0FIX13yuapYmFOj6gXBvTq20lycg/oMtM4HGdh6knZwiFgojlya4EbSiC6lijn5NiBfN1SMliwPbR0rqfcTR820RQkmciQHtn/IO7I1KmVGiUchC1UTf6ZlgI2CGEcN5mlSLDeabCAlSr5V5DFKK4ibUqgB5TEE/35o09sqF77GdDuFn+FTR3+gl7P7qPsiPf7wHQ3cOehtDMQtMMjXWUAm+0gDCif3otockWPMZS4RtMXml+iAkmrVLwZxSKSQ4lW/NicwV1QeggxiwUQhoDa+RqwLNKuHtzusYX/4JXS0hu6pxMZv8+zAOof4QQhM82Offz7sg9Za73GVQIK24icXjsbcBvf6+hajfnizmPKQexbVWTS36h6y76vn2L1ipHH40QhdtLo1LbZR5Vmsk3uYlQ26vcbtOrpQsTuBysXnGne/JTiqas5yzmXCSlHgTTA1fYGoMxN57lWq+BdBTmGZJjmJEjs/3AvK6bsmzmcnob6ahNQ1rv8nACsaICFPtKqv8qUeWW9yKV2NLdIoUor4wExwhaATwORz4LGL7gdDDBB9m5s+fPDDeXHXi8vMyBuW2BEnQ7djYPJhs+CWnyNDATZoVzIafFOe/j/NGOuxXwkuoeE7Z2dSOn+vcaCTW6k1smqvZ9sIkIkSHAJ4g0WTEuORa75DN84qHemFbI/fXXHK8zhHtEk/gahLVO3Joxbh2WpO3S9PAYhC61+C643Oal+1Kb6la2l1lxtaTW1CPD2CNr0rQ2QSdphceKfRQXe5G28HQfnnQ//mQqwvQUw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199021)(36840700001)(40470700004)(46966006)(36756003)(86362001)(47076005)(478600001)(4326008)(6666004)(316002)(6916009)(54906003)(70206006)(70586007)(356005)(7416002)(8676002)(5660300002)(82310400005)(40480700001)(8936002)(44832011)(41300700001)(2616005)(2906002)(82740400003)(426003)(186003)(26005)(81166007)(1076003)(83380400001)(36860700001)(336012)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:04:30.5239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5ff215b-b21f-46e6-d087-08db6d3428b5 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6969 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787530050100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" xen-mapcache.c contains common functions which can be used for enabling Xen= on aarch64 with IOREQ handling. Moving it out from hw/i386/xen to hw/xen to ma= ke it accessible for both aarch64 and x86. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Reviewed-by: Paul Durrant --- hw/i386/meson.build | 1 + hw/i386/xen/meson.build | 1 - hw/i386/xen/trace-events | 5 ----- hw/xen/meson.build | 4 ++++ hw/xen/trace-events | 5 +++++ hw/{i386 =3D> }/xen/xen-mapcache.c | 0 6 files changed, 10 insertions(+), 6 deletions(-) rename hw/{i386 =3D> }/xen/xen-mapcache.c (100%) diff --git a/hw/i386/meson.build b/hw/i386/meson.build index 213e2e82b3..cfdbfdcbcb 100644 --- a/hw/i386/meson.build +++ b/hw/i386/meson.build @@ -33,5 +33,6 @@ subdir('kvm') subdir('xen') =20 i386_ss.add_all(xenpv_ss) +i386_ss.add_all(xen_ss) =20 hw_arch +=3D {'i386': i386_ss} diff --git a/hw/i386/xen/meson.build b/hw/i386/xen/meson.build index 2e64a34e16..3dc4c4f106 100644 --- a/hw/i386/xen/meson.build +++ b/hw/i386/xen/meson.build @@ -1,6 +1,5 @@ i386_ss.add(when: 'CONFIG_XEN', if_true: files( 'xen-hvm.c', - 'xen-mapcache.c', 'xen_apic.c', 'xen_pvdevice.c', )) diff --git a/hw/i386/xen/trace-events b/hw/i386/xen/trace-events index 5d6be61090..a0c89d91c4 100644 --- a/hw/i386/xen/trace-events +++ b/hw/i386/xen/trace-events @@ -21,8 +21,3 @@ xen_map_resource_ioreq(uint32_t id, void *addr) "id: %u a= ddr: %p" cpu_ioreq_config_read(void *req, uint32_t sbdf, uint32_t reg, uint32_t siz= e, uint32_t data) "I/O=3D%p sbdf=3D0x%x reg=3D%u size=3D%u data=3D0x%x" cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_t reg, uint32_t si= ze, uint32_t data) "I/O=3D%p sbdf=3D0x%x reg=3D%u size=3D%u data=3D0x%x" =20 -# xen-mapcache.c -xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 -xen_remap_bucket(uint64_t index) "index 0x%"PRIx64 -xen_map_cache_return(void* ptr) "%p" - diff --git a/hw/xen/meson.build b/hw/xen/meson.build index 19c6aabc7c..202752e557 100644 --- a/hw/xen/meson.build +++ b/hw/xen/meson.build @@ -26,3 +26,7 @@ else endif =20 specific_ss.add_all(when: ['CONFIG_XEN', xen], if_true: xen_specific_ss) + +xen_ss =3D ss.source_set() + +xen_ss.add(when: 'CONFIG_XEN', if_true: files('xen-mapcache.c')) diff --git a/hw/xen/trace-events b/hw/xen/trace-events index 55c9e1df68..f977c7c8c6 100644 --- a/hw/xen/trace-events +++ b/hw/xen/trace-events @@ -41,3 +41,8 @@ xs_node_vprintf(char *path, char *value) "%s %s" xs_node_vscanf(char *path, char *value) "%s %s" xs_node_watch(char *path) "%s" xs_node_unwatch(char *path) "%s" + +# xen-mapcache.c +xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 +xen_remap_bucket(uint64_t index) "index 0x%"PRIx64 +xen_map_cache_return(void* ptr) "%p" diff --git a/hw/i386/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c similarity index 100% rename from hw/i386/xen/xen-mapcache.c rename to hw/xen/xen-mapcache.c --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787522; cv=pass; d=zohomail.com; s=zohoarc; b=m1nn0I9xpxwg8k9P8vJim6iE67zSTOVYSjm83cLVhY9FrWAQVs6kH+tX8pmaPqxxJz4RkD5dkdTvjxlQhaUVOu20hX74Kyivy8+omWRZz1tY1DxgtRHeTy3OXZ+CyXpYcV1l48BsIbbFjusLZ8a4UtdbZVOkE7EDCCbxg9A3O70= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787522; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+esgy4HuztqSu8ROePQWFE/nHzxIBFggZqfdRu8CEMM=; b=iazYNCaUeQJIBY1qU+6SEM2Oes5Ze4tpJQImjRvZdcsfygml9G0h9ITtmC66LkflhXkojqWnoiRdkj1X0OvOaKp4ITXOVBYcKN9ry7Q9ZdvZxuzB9JEwEyXeuoLNRvJ9wuQnVAN2I0LJ/hyS3qdCym/xXgvNATsoKq5m+mmDC+M= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1686787522853734.191817623299; Wed, 14 Jun 2023 17:05:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.549301.857747 (Exim 4.92) (envelope-from ) id 1q9aTg-00066r-O3; Thu, 15 Jun 2023 00:04:40 +0000 Received: by outflank-mailman (output) from mailman id 549301.857747; Thu, 15 Jun 2023 00:04:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aTg-00066k-LO; Thu, 15 Jun 2023 00:04:40 +0000 Received: by outflank-mailman (input) for mailman id 549301; Thu, 15 Jun 2023 00:04:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aTf-00066e-Jk for xen-devel@lists.xenproject.org; Thu, 15 Jun 2023 00:04:39 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20619.outbound.protection.outlook.com [2a01:111:f400:7eab::619]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 35d4c57a-0b10-11ee-8611-37d641c3527e; Thu, 15 Jun 2023 02:04:36 +0200 (CEST) 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 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 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 35d4c57a-0b10-11ee-8611-37d641c3527e 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= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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 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 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787523829100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, MemoryReg= ion **ram_memory) state->exit.notify =3D xen_exit_notifier; qemu_add_exit_notifier(&state->exit); =20 - state->suspend.notify =3D xen_suspend_notifier; - qemu_register_suspend_notifier(&state->suspend); - - state->wakeup.notify =3D 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, MemoryReg= ion **ram_memory) goto err; } =20 - rc =3D 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 =3D - xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, - 1, &ioreq_pfn, NULL); - if (state->shared_vmport_page =3D=3D NULL) { - error_report("map shared vmport IO page returned error %d hand= le=3D%p", - errno, xen_xc); - goto err; - } - } else if (rc !=3D -ENOSYS) { - error_report("get vmport regs pfn returned error %d, rc=3D%d", - errno, rc); - goto err; - } - /* Note: cpus is empty at this point in init */ state->cpu_by_vcpu_id =3D g_new0(CPUState *, max_cpus); =20 @@ -1490,7 +1467,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegi= on **ram_memory) #else xen_map_cache_init(NULL, state); #endif - xen_ram_init(pcms, ms->ram_size, ram_memory); =20 qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state); =20 @@ -1511,6 +1487,31 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryReg= ion **ram_memory) QLIST_INIT(&xen_physmap); xen_read_physmap(state); =20 + state->suspend.notify =3D xen_suspend_notifier; + qemu_register_suspend_notifier(&state->suspend); + + state->wakeup.notify =3D xen_wakeup_notifier; + qemu_register_wakeup_notifier(&state->wakeup); + + rc =3D 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 =3D + xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, + 1, &ioreq_pfn, NULL); + if (state->shared_vmport_page =3D=3D NULL) { + error_report("map shared vmport IO page returned error %d hand= le=3D%p", + errno, xen_xc); + goto err; + } + } else if (rc !=3D -ENOSYS) { + error_report("get vmport regs pfn returned error %d, rc=3D%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 =3D false; =20 --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787526; cv=pass; d=zohomail.com; s=zohoarc; b=CU2r/0VipmsksbzyZzuOdzLLZAHsvumDq1HWeUMFKDN69IpmJHz+Z16BXSWqb+2PiKC41lr4ZiXSQy2kM9bhY+7dQMYc5m4Wxcx8gbykr8eNJn6PyfyFQs1U5PCC6Cl4knkzL0dc0s2zqXCCs13vot3Zia9NFLwM3fyo9Pl+Pcw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787526; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vvGrcK9HtrPihux4sSLpgxCYMLGl2A40aqt4BVUc2ZM=; b=Fwd0bfmnwUjhD5/ZojRDYG/OpT9CZ53xn5FLtp6Sgg3OWAquS4gKAb4INev/n1qulIvKMXjcTDIhlSzIrbj74FVi9I6fu6084FkNCCT38ySkphsWrH3JzGRQrdz+K1ddRwLJOeckhU//qW1ehTkPW4BjRnFoW6wu/u78tz110kg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686787526636685.9233973081037; Wed, 14 Jun 2023 17:05:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9aUG-0005l5-4w; Wed, 14 Jun 2023 20:05:16 -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 1q9aUE-0005jN-Te for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:05:14 -0400 Received: from mail-sn1nam02on2061d.outbound.protection.outlook.com ([2a01:111:f400:7ea9::61d] helo=NAM02-SN1-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 1q9aUC-0006q4-NG for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:05:14 -0400 Received: from MW4PR04CA0280.namprd04.prod.outlook.com (2603:10b6:303:89::15) by CH3PR12MB7689.namprd12.prod.outlook.com (2603:10b6:610:14d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Thu, 15 Jun 2023 00:05:08 +0000 Received: from CO1NAM11FT080.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::6a) by MW4PR04CA0280.outlook.office365.com (2603:10b6:303:89::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37 via Frontend Transport; Thu, 15 Jun 2023 00:05:07 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT080.mail.protection.outlook.com (10.13.174.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.23 via Frontend Transport; Thu, 15 Jun 2023 00:05:07 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) 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:59 -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:35 -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:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FgesDFrY7d8EJyIidvb3+4+X0SEXctsxrwiyh+UdHHyDHYerjVojHlz00XrXgWAVExwFSnlBAoGSGkXLjZsRUA3ATWNbzBKtz2G/KZp2cIpi9xpxEz1YnbYMgOXCAn+zQWVkYipdaO5q3YupNrIQ760JBT4bBGtR+k1gUsoVHh1YS8ZS9nhtXkOVOkWYwZOlFgFjGBUOFGXfNQE4OUAfvlNxhSTdQLyCMvjSZm851utUEp6YEo056t4tXAs9yvlimchaxCrpmW2pMcYgHx9zLdAcMncaH7JMmnaks5p5IXca/s/M8xGaOuTLaZJt8gonUdeZzARW1TA54bL6ZWJJrA== 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=vvGrcK9HtrPihux4sSLpgxCYMLGl2A40aqt4BVUc2ZM=; b=oBQuJrIA8NkAa0Ds7peXPtmrLTPTJtdhPoBHtAvgM7cqUc/uLMDNmG2Oej9QCyflM2mZrLeEMiOpWUFpkujI1oPXL/ZZlOCXT7RzJPwkslG+IbfcXTuEYitE/LieAWpKPmGpQRiplSDB2UWhO59TzRhDIlAjTvO5af1upIBGLM1PRzj878FHJD4E74SCB52KUlEe5zq7e5AAWIF2WP+zRhnF0bmyoIJCxBJ/L/xN5BscEVxYxXSh3gj0LqepevsvJSeami8Vz/Ns3S6XuJ3LNgq0HVC7TAsKrhokfnVvkABeB2urseEmZwICmdjCwd6GLF+OQJmie+Mh/6d8ld4ZsQ== 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=vvGrcK9HtrPihux4sSLpgxCYMLGl2A40aqt4BVUc2ZM=; b=YWjiFpLFwLLqr7CE6EY7aAMAcAiHxxOl0s3kq7J0AElXaKmK13q96d+rhhjnTC32XkQrUfTbXUqYGqzAlcgFfEro5Z1hoUKLOygweakSks2TDxENJDbSHLTGFWeYyG6RUewW0pLVG/Xq3kQ1p+/Aud5cWqLk7BdvNyj4jZD6qmI= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Stefano Stabellini , Vikram Garhwal , Anthony Perard , Paul Durrant , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "open list:X86 Xen CPUs" Subject: [QEMU][PATCH v8 03/11] hw/i386/xen/xen-hvm: move x86-specific fields out of XenIOState Date: Wed, 14 Jun 2023 17:03:31 -0700 Message-ID: <20230615000340.1135-4-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT080:EE_|CH3PR12MB7689:EE_ X-MS-Office365-Filtering-Correlation-Id: b85b4185-f432-4f3c-f020-08db6d342d99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LdXTCAS7mWxN3TDAR7AH3PAKxfFHwIqh9ta24gV0yhD5dlffDFxIDf++eVy2y/VwccEmW4X+9l6yNiSl30CMTqjxPF1NC1PAvX1yQc7ceMNIfDIv9mmSeXiOk6ek8XbCB0cIYE8iT3VJAa6lnTVUFaepgkOj1xkeiDcA4FCLtNG6sFghlmC2Ij2ZddoO8V9ddXRTVFSO2SXJirzkCWb/8pIPIQt7esClR4kb1L/YYyqAyg9183uwNElusDYYYtVdQbESFOQojx7oufg3d7VVl2R3UnCeog6pSnQn+VI+qEL3YLomcegddzOWFyiB64fskBlgp8LEn1qaawpHrf7p/rmMEJvzB0Yvgo3z0bO0Gdxre+FHNQFn7i7+VD3hEHNgcwGyAGpFqwEUYye2nVBaFTGivO3EwRdMjExhxsCHe2a3U8z8Ei++Ry84jdRIrg9n1Rp+Yp9N//T9GndKqYFLzPHnfVjI/wOuYnLbPUMZYkkU9s4gt+N/0u2nHiPRDhwIKDe1LAkWHAkqBayW1BsygZMiWNUMuBjDMvv9tJSRUWX7bTq+VIgdvn2jW8svKfEYJa1HAer9TTv4uI8xV6wQFxZLU+EhuwjMdAMw5JBPl1DuXOCqrlyEJiWgZ6TpOgoUbn7RVFLpT48gmU/5wZ5RII5E2g6ixhjeqVCzzJUBDvw9IouyWbggnwChwoiUTXPMiJbJzWSlsVA1oh+bSX9g8FdPMuyYPPc2qH/Frntk5ONlBhD5IeC047plZ3g1j9tzEeuXIe145Y/Gmi6k+/OMDQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199021)(40470700004)(46966006)(36840700001)(26005)(1076003)(356005)(81166007)(82740400003)(2616005)(36756003)(40460700003)(86362001)(186003)(40480700001)(82310400005)(36860700001)(66574015)(47076005)(5660300002)(44832011)(7416002)(6666004)(2906002)(83380400001)(54906003)(41300700001)(8936002)(8676002)(478600001)(4326008)(6916009)(70206006)(70586007)(316002)(426003)(336012)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:07.2282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b85b4185-f432-4f3c-f020-08db6d342d99 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT080.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7689 Received-SPF: softfail client-ip=2a01:111:f400:7ea9::61d; envelope-from=vikram.garhwal@amd.com; helo=NAM02-SN1-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787527921100005 From: Stefano Stabellini In preparation to moving most of xen-hvm code to an arch-neutral location, = move: - shared_vmport_page - log_for_dirtybit - dirty_bitmap - suspend - wakeup out of XenIOState struct as these are only used on x86, especially the ones related to dirty logging. Updated XenIOState can be used for both aarch64 and x86. Also, remove free_phys_offset as it was unused. Signed-off-by: Stefano Stabellini Signed-off-by: Vikram Garhwal Reviewed-by: Paul Durrant Reviewed-by: Alex Benn=C3=A9e --- hw/i386/xen/xen-hvm.c | 58 ++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 7a7764240e..01bf947f1c 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -74,6 +74,7 @@ struct shared_vmport_iopage { }; typedef struct shared_vmport_iopage shared_vmport_iopage_t; #endif +static shared_vmport_iopage_t *shared_vmport_page; =20 static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i) { @@ -96,6 +97,11 @@ typedef struct XenPhysmap { } XenPhysmap; =20 static QLIST_HEAD(, XenPhysmap) xen_physmap; +static const XenPhysmap *log_for_dirtybit; +/* Buffer used by xen_sync_dirty_bitmap */ +static unsigned long *dirty_bitmap; +static Notifier suspend; +static Notifier wakeup; =20 typedef struct XenPciDevice { PCIDevice *pci_dev; @@ -106,7 +112,6 @@ typedef struct XenPciDevice { typedef struct XenIOState { ioservid_t ioservid; shared_iopage_t *shared_page; - shared_vmport_iopage_t *shared_vmport_page; buffered_iopage_t *buffered_io_page; xenforeignmemory_resource_handle *fres; QEMUTimer *buffered_io_timer; @@ -126,14 +131,8 @@ typedef struct XenIOState { MemoryListener io_listener; QLIST_HEAD(, XenPciDevice) dev_list; DeviceListener device_listener; - hwaddr free_phys_offset; - const XenPhysmap *log_for_dirtybit; - /* Buffer used by xen_sync_dirty_bitmap */ - unsigned long *dirty_bitmap; =20 Notifier exit; - Notifier suspend; - Notifier wakeup; } XenIOState; =20 /* Xen specific function for piix pci */ @@ -463,10 +462,10 @@ static int xen_remove_from_physmap(XenIOState *state, } =20 QLIST_REMOVE(physmap, list); - if (state->log_for_dirtybit =3D=3D physmap) { - state->log_for_dirtybit =3D NULL; - g_free(state->dirty_bitmap); - state->dirty_bitmap =3D NULL; + if (log_for_dirtybit =3D=3D physmap) { + log_for_dirtybit =3D NULL; + g_free(dirty_bitmap); + dirty_bitmap =3D NULL; } g_free(physmap); =20 @@ -627,16 +626,16 @@ static void xen_sync_dirty_bitmap(XenIOState *state, return; } =20 - if (state->log_for_dirtybit =3D=3D NULL) { - state->log_for_dirtybit =3D physmap; - state->dirty_bitmap =3D g_new(unsigned long, bitmap_size); - } else if (state->log_for_dirtybit !=3D physmap) { + if (log_for_dirtybit =3D=3D NULL) { + log_for_dirtybit =3D physmap; + dirty_bitmap =3D g_new(unsigned long, bitmap_size); + } else if (log_for_dirtybit !=3D physmap) { /* Only one range for dirty bitmap can be tracked. */ return; } =20 rc =3D xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS, - npages, state->dirty_bitmap); + npages, dirty_bitmap); if (rc < 0) { #ifndef ENODATA #define ENODATA ENOENT @@ -651,7 +650,7 @@ static void xen_sync_dirty_bitmap(XenIOState *state, } =20 for (i =3D 0; i < bitmap_size; i++) { - unsigned long map =3D state->dirty_bitmap[i]; + unsigned long map =3D dirty_bitmap[i]; while (map !=3D 0) { j =3D ctzl(map); map &=3D ~(1ul << j); @@ -677,12 +676,10 @@ static void xen_log_start(MemoryListener *listener, static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *se= ction, int old, int new) { - XenIOState *state =3D container_of(listener, XenIOState, memory_listen= er); - if (old & ~new & (1 << DIRTY_MEMORY_VGA)) { - state->log_for_dirtybit =3D NULL; - g_free(state->dirty_bitmap); - state->dirty_bitmap =3D NULL; + log_for_dirtybit =3D NULL; + g_free(dirty_bitmap); + dirty_bitmap =3D NULL; /* Disable dirty bit tracking */ xen_track_dirty_vram(xen_domid, 0, 0, NULL); } @@ -1022,9 +1019,9 @@ static void handle_vmport_ioreq(XenIOState *state, io= req_t *req) { vmware_regs_t *vmport_regs; =20 - assert(state->shared_vmport_page); + assert(shared_vmport_page); vmport_regs =3D - &state->shared_vmport_page->vcpu_vmport_regs[state->send_vcpu]; + &shared_vmport_page->vcpu_vmport_regs[state->send_vcpu]; QEMU_BUILD_BUG_ON(sizeof(*req) < sizeof(*vmport_regs)); =20 current_cpu =3D state->cpu_by_vcpu_id[state->send_vcpu]; @@ -1472,7 +1469,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegi= on **ram_memory) =20 state->memory_listener =3D xen_memory_listener; memory_listener_register(&state->memory_listener, &address_space_memor= y); - state->log_for_dirtybit =3D NULL; =20 state->io_listener =3D xen_io_listener; memory_listener_register(&state->io_listener, &address_space_io); @@ -1487,19 +1483,19 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRe= gion **ram_memory) QLIST_INIT(&xen_physmap); xen_read_physmap(state); =20 - state->suspend.notify =3D xen_suspend_notifier; - qemu_register_suspend_notifier(&state->suspend); + suspend.notify =3D xen_suspend_notifier; + qemu_register_suspend_notifier(&suspend); =20 - state->wakeup.notify =3D xen_wakeup_notifier; - qemu_register_wakeup_notifier(&state->wakeup); + wakeup.notify =3D xen_wakeup_notifier; + qemu_register_wakeup_notifier(&wakeup); =20 rc =3D 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 =3D + shared_vmport_page =3D xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, 1, &ioreq_pfn, NULL); - if (state->shared_vmport_page =3D=3D NULL) { + if (shared_vmport_page =3D=3D NULL) { error_report("map shared vmport IO page returned error %d hand= le=3D%p", errno, xen_xc); goto err; --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787552; cv=pass; d=zohomail.com; s=zohoarc; b=giBn9iSY2hJQF329cK1JN8Hw1G2Nu4+NC3cVQyT6+2mfVuuCTwpn+MWfsu+cVBkfhRmENx+FHr4UjZ0W56ODGa/N8qPQR1EqnTmdlgS9DjdFw0mcETDMM4WojQfgMvQFOGnQJQOy7hm36kqqEIYXr3cHMHbmB8TVO8+uSDJCq3s= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787552; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NetFI3mOW5SjmdnTbZSgx/icyXfkTVKaHu4Wc/6TI7c=; b=BVu21JfWfCKAVgwXbhyrQNBRHN7tuwUyPM7tomyHp4xTB5H5mC+9z+h7O9fEJY4FdRmUQXxY/Q7tjBVKbhnaWIV4WJPL8/QIFASPIPmbwS+hbNibzZj8NbIBnORPnB0ygQbmKKjfG2DxQcU6Y9Nh9FfRIm6Lv4r7Q0oLTlYezLc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1686787552453495.9266564308141; Wed, 14 Jun 2023 17:05:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.549312.857817 (Exim 4.92) (envelope-from ) id 1q9aUM-0008Jm-65; Thu, 15 Jun 2023 00:05:22 +0000 Received: by outflank-mailman (output) from mailman id 549312.857817; Thu, 15 Jun 2023 00:05:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUM-0008IU-1t; Thu, 15 Jun 2023 00:05:22 +0000 Received: by outflank-mailman (input) for mailman id 549312; Thu, 15 Jun 2023 00:05:20 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUJ-0006Ty-SY for xen-devel@lists.xenproject.org; Thu, 15 Jun 2023 00:05:20 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [2a01:111:f400:7eae::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4f21bb4b-0b10-11ee-b232-6b7b168915f2; Thu, 15 Jun 2023 02:05:17 +0200 (CEST) Received: from MW4PR04CA0283.namprd04.prod.outlook.com (2603:10b6:303:89::18) by SA1PR12MB6871.namprd12.prod.outlook.com (2603:10b6:806:25f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.46; Thu, 15 Jun 2023 00:05:12 +0000 Received: from CO1NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::62) by MW4PR04CA0283.outlook.office365.com (2603:10b6:303:89::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37 via Frontend Transport; Thu, 15 Jun 2023 00:05:11 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT054.mail.protection.outlook.com (10.13.174.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.26 via Frontend Transport; Thu, 15 Jun 2023 00:05:10 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) 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:05:00 -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:39 -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:38 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4f21bb4b-0b10-11ee-b232-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cI2Te/Mjg0Agwrfu2juv5mY0TEUc4mH6a999hB2CTddoMZNxWKCT/vgDIA/bqZImqfK6nbLb+7FLoDT/6ya7NC/IVrRWdCnxChzH+QaICrprkXar+X7cYsGOPeR9MFP2+jXhbOpaMb3WRhdZmNkkYy/KN9bNspBWGHaiskGEyTJCyQxXzPUA4qFUk5JpzCziSrVMz1icGXBH3U9tCKZO1h77NDF9rnEb3/gsN5zhFQ/sywdxH7SVczps27x7RIMMlO/Dj/M8rhuKTfTcqsN9hj+0tHuhS/x3DvJPcl69DVugdCjObBbagNhTXAecvjTdrdANCvCIt5qlzTEaG6zO5Q== 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=NetFI3mOW5SjmdnTbZSgx/icyXfkTVKaHu4Wc/6TI7c=; b=Ir61jaHkx7Ti/oSdjKOVe6rdPXpzvlCL4SQB23AQfDVzm1yVlq+KCytUNaD8YBc3RgAmvVLDnon5UaESkkUj3JyiGTDCJVqnRTNxtLSeGaa6k0ZvLu1uRw83qegczoycaD4+Jy0W8rZ7814nAnUwoAkUGwlG66NPuYIA2EX1p1cGYS4RcoiMDiscBhq5ZTIlKTZV3tgdaliRHQUYc6pEJ/FCMTNY2r7V7CJphmZK/J/8g7ANZD0bp5PNjJGVoAT0pONYepSEK4nTTHB5Cew9U91FqVEWWI+dWzmTkW9A8VynekUjpxOtU91w2pblqrvOr2kuB3E98sF9juDEcQ6fRw== 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=NetFI3mOW5SjmdnTbZSgx/icyXfkTVKaHu4Wc/6TI7c=; b=Vu06Ifh9VearmpnW+J1r5NBBH6wpC9xuZX+z1P722VA/UHnjV4k9z0FbchEDHjmxJ89vqXDKOBMrVtPbC8OLViJ6uSyCdUVEjADkQzXg7Sdv/zYQDDqEmeu+XNK/RXBxRgo/2/jAsmhYS4f4Mrt7VyQdgK2eKXcJC4CRWOP7MGw= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Stefano Stabellini , Vikram Garhwal , Anthony Perard , Paul Durrant , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "open list:X86 Xen CPUs" Subject: [QEMU][PATCH v8 04/11] xen-hvm: reorganize xen-hvm and move common function to xen-hvm-common Date: Wed, 14 Jun 2023 17:03:32 -0700 Message-ID: <20230615000340.1135-5-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: CO1NAM11FT054:EE_|SA1PR12MB6871:EE_ X-MS-Office365-Filtering-Correlation-Id: 7930fd19-a4a0-4cb6-dedf-08db6d342fe3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: haN3wRSfiLLdxCpORRL4txicIFePwBRSLCgQaP5zcKsbNYK0PasDUSXFIE5YasKJmjFchBReSrw06Y3mC1O5Yj3xMSkn4bd99BdYktWpZcvIp9PLlqg8VxC7iSKNSTWLFRRA1oPB/a2jl6BSsroONmpCUlrXZHYg7tsW79QdfZglvMLzs5Knml8kQtkx8udBX9tc/fHD/LExwfjmo7J4fRtRXMFXJlWpotydPidIHZWb4GEcIriP8xVZ2XW72IsdlReL9yI86hw4HVIv+ROiFPY0hUdl5ao9R2lyLcHXXPPukJc4QphI4q+W3DJv7+jkdz8Q16U5TGQWeai164X3PZ68Mfk0lxcqX1AHiMN1JlQc+H8EwIO/C5rN9zpfTYLA0j4u1ZYXD3/xe4XuRH8FVelrRd0c1k2YGN+/HTHFioadnIYX8vPkT0Z8u+QV3hGbFIOjtApn0di3EvlA92tzMPE2IMyxQ++UMWuTsqJQdQZ5lcAgwlztAq5GI0Xg2oExmaZOJgGP70VxR327uZH9vtGr+EObIwGPEtUj0OczAP79UawbcblPNCA0bEpnd2j7+tHpa9aWRemXv/HKRlfb2apQllQFLKRM/rt4OUgj/ATPC2AgFQVCku2OUGZn/7HNFm6J5XQd94vRoRaOTlTTqsnie5Hbb2eB7rcjdijZdhTz2Krr98M5m4nPu+tuKyBQi+/68Ql33gYSTDQigr1pl99IAAhS1UCgElQBjop0rcGRzwPs3Z6Nfc9X9OHHwQ8tglhFStYrFjCd+xSUH4tXyw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(396003)(376002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(82310400005)(316002)(7416002)(86362001)(40460700003)(8676002)(41300700001)(40480700001)(26005)(82740400003)(83380400001)(5660300002)(81166007)(1076003)(356005)(6666004)(36860700001)(8936002)(44832011)(336012)(426003)(36756003)(47076005)(70586007)(4326008)(70206006)(478600001)(6916009)(186003)(30864003)(2906002)(54906003)(2616005)(36900700001)(559001)(579004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:10.9903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7930fd19-a4a0-4cb6-dedf-08db6d342fe3 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6871 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787553638100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini This patch does following: 1. creates arch_handle_ioreq() and arch_xen_set_memory(). This is done in preparation for moving most of xen-hvm code to an arch-neutral location, move the x86-specific portion of xen_set_memory to arch_xen_set_memory. Also, move handle_vmport_ioreq to arch_handle_ioreq. 2. Pure code movement: move common functions to hw/xen/xen-hvm-common.c Extract common functionalities from hw/i386/xen/xen-hvm.c and move them= to hw/xen/xen-hvm-common.c. These common functions are useful for creating an IOREQ server. xen_hvm_init_pc() contains the architecture independent code for creati= ng and mapping a IOREQ server, connecting memory and IO listeners, initial= izing a xen bus and registering backends. Moved this common xen code to a new function xen_register_ioreq() which can be used by both x86 and ARM mac= hines. Following functions are moved to hw/xen/xen-hvm-common.c: xen_vcpu_eport(), xen_vcpu_ioreq(), xen_ram_alloc(), xen_set_memory= (), xen_region_add(), xen_region_del(), xen_io_add(), xen_io_del(), xen_device_realize(), xen_device_unrealize(), cpu_get_ioreq_from_shared_memory(), cpu_get_ioreq(), do_inp(), do_outp(), rw_phys_req_item(), read_phys_req_item(), write_phys_req_item(), cpu_ioreq_pio(), cpu_ioreq_move(), cpu_ioreq_config(), handle_ioreq(), handle_buffered_iopage(), handle_buffered_io(), cpu_handle_ioreq(), xen_main_loop_prepare(), xen_hvm_change_state_handler(), xen_exit_notifier(), xen_map_ioreq_server(), destroy_hvm_domain() and xen_shutdown_fatal_error() 3. Removed static type from below functions: 1. xen_region_add() 2. xen_region_del() 3. xen_io_add() 4. xen_io_del() 5. xen_device_realize() 6. xen_device_unrealize() 7. xen_hvm_change_state_handler() 8. cpu_ioreq_pio() 9. xen_exit_notifier() 4. Replace TARGET_PAGE_SIZE with XC_PAGE_SIZE to match the page side with X= en. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Acked-by: Stefano Stabellini --- hw/i386/xen/trace-events | 14 - hw/i386/xen/xen-hvm.c | 1016 ++----------------------------- hw/xen/meson.build | 5 +- hw/xen/trace-events | 14 + hw/xen/xen-hvm-common.c | 860 ++++++++++++++++++++++++++ include/hw/i386/xen_arch_hvm.h | 11 + include/hw/xen/arch_hvm.h | 3 + include/hw/xen/xen-hvm-common.h | 99 +++ 8 files changed, 1054 insertions(+), 968 deletions(-) create mode 100644 hw/xen/xen-hvm-common.c create mode 100644 include/hw/i386/xen_arch_hvm.h create mode 100644 include/hw/xen/arch_hvm.h create mode 100644 include/hw/xen/xen-hvm-common.h diff --git a/hw/i386/xen/trace-events b/hw/i386/xen/trace-events index a0c89d91c4..5d0a8d6dcf 100644 --- a/hw/i386/xen/trace-events +++ b/hw/i386/xen/trace-events @@ -7,17 +7,3 @@ xen_platform_log(char *s) "xen platform: %s" xen_pv_mmio_read(uint64_t addr) "WARNING: read from Xen PV Device MMIO spa= ce (address 0x%"PRIx64")" xen_pv_mmio_write(uint64_t addr) "WARNING: write to Xen PV Device MMIO spa= ce (address 0x%"PRIx64")" =20 -# xen-hvm.c -xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: 0x%l= x, size 0x%lx" -xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_di= rty) "0x%"PRIx64" size 0x%lx, log_dirty %i" -handle_ioreq(void *req, uint32_t type, uint32_t dir, uint32_t df, uint32_t= data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) = "I/O=3D%p type=3D%d dir=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%= "PRIx64" count=3D%d size=3D%d" -handle_ioreq_read(void *req, uint32_t type, uint32_t df, uint32_t data_is_= ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=3D%p= read type=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%"PRIx64" coun= t=3D%d size=3D%d" -handle_ioreq_write(void *req, uint32_t type, uint32_t df, uint32_t data_is= _ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=3D%= p write type=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%"PRIx64" co= unt=3D%d size=3D%d" -cpu_ioreq_pio(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr, = uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=3D%p pio = dir=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%"PRIx64" count=3D%d = size=3D%d" -cpu_ioreq_pio_read_reg(void *req, uint64_t data, uint64_t addr, uint32_t s= ize) "I/O=3D%p pio read reg data=3D0x%"PRIx64" port=3D0x%"PRIx64" size=3D%d" -cpu_ioreq_pio_write_reg(void *req, uint64_t data, uint64_t addr, uint32_t = size) "I/O=3D%p pio write reg data=3D0x%"PRIx64" port=3D0x%"PRIx64" size=3D= %d" -cpu_ioreq_move(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr,= uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=3D%p cop= y dir=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%"PRIx64" count=3D%= d size=3D%d" -xen_map_resource_ioreq(uint32_t id, void *addr) "id: %u addr: %p" -cpu_ioreq_config_read(void *req, uint32_t sbdf, uint32_t reg, uint32_t siz= e, uint32_t data) "I/O=3D%p sbdf=3D0x%x reg=3D%u size=3D%u data=3D0x%x" -cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_t reg, uint32_t si= ze, uint32_t data) "I/O=3D%p sbdf=3D0x%x reg=3D%u size=3D%u data=3D0x%x" - diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 01bf947f1c..5dc5e80535 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -10,43 +10,21 @@ =20 #include "qemu/osdep.h" #include "qemu/units.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-migration.h" +#include "trace.h" =20 -#include "cpu.h" -#include "hw/pci/pci.h" -#include "hw/pci/pci_host.h" #include "hw/i386/pc.h" #include "hw/irq.h" -#include "hw/hw.h" #include "hw/i386/apic-msidef.h" -#include "hw/xen/xen_native.h" -#include "hw/xen/xen-legacy-backend.h" -#include "hw/xen/xen-bus.h" #include "hw/xen/xen-x86.h" -#include "qapi/error.h" -#include "qapi/qapi-commands-migration.h" -#include "qemu/error-report.h" -#include "qemu/main-loop.h" #include "qemu/range.h" -#include "sysemu/runstate.h" -#include "sysemu/sysemu.h" -#include "sysemu/xen.h" -#include "sysemu/xen-mapcache.h" -#include "trace.h" =20 -#include +#include "hw/xen/xen-hvm-common.h" +#include "hw/xen/arch_hvm.h" #include =20 -//#define DEBUG_XEN_HVM - -#ifdef DEBUG_XEN_HVM -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif - -static MemoryRegion ram_memory, ram_640k, ram_lo, ram_hi; +static MemoryRegion ram_640k, ram_lo, ram_hi; static MemoryRegion *framebuffer; static bool xen_in_migration; =20 @@ -74,27 +52,8 @@ struct shared_vmport_iopage { }; typedef struct shared_vmport_iopage shared_vmport_iopage_t; #endif -static shared_vmport_iopage_t *shared_vmport_page; =20 -static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i) -{ - return shared_page->vcpu_ioreq[i].vp_eport; -} -static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vc= pu) -{ - return &shared_page->vcpu_ioreq[vcpu]; -} - -#define BUFFER_IO_MAX_DELAY 100 - -typedef struct XenPhysmap { - hwaddr start_addr; - ram_addr_t size; - const char *name; - hwaddr phys_offset; - - QLIST_ENTRY(XenPhysmap) list; -} XenPhysmap; +static shared_vmport_iopage_t *shared_vmport_page; =20 static QLIST_HEAD(, XenPhysmap) xen_physmap; static const XenPhysmap *log_for_dirtybit; @@ -103,38 +62,6 @@ static unsigned long *dirty_bitmap; static Notifier suspend; static Notifier wakeup; =20 -typedef struct XenPciDevice { - PCIDevice *pci_dev; - uint32_t sbdf; - QLIST_ENTRY(XenPciDevice) entry; -} XenPciDevice; - -typedef struct XenIOState { - ioservid_t ioservid; - shared_iopage_t *shared_page; - buffered_iopage_t *buffered_io_page; - xenforeignmemory_resource_handle *fres; - QEMUTimer *buffered_io_timer; - CPUState **cpu_by_vcpu_id; - /* the evtchn port for polling the notification, */ - evtchn_port_t *ioreq_local_port; - /* evtchn remote and local ports for buffered io */ - evtchn_port_t bufioreq_remote_port; - evtchn_port_t bufioreq_local_port; - /* the evtchn fd for polling */ - xenevtchn_handle *xce_handle; - /* which vcpu we are serving */ - int send_vcpu; - - struct xs_handle *xenstore; - MemoryListener memory_listener; - MemoryListener io_listener; - QLIST_HEAD(, XenPciDevice) dev_list; - DeviceListener device_listener; - - Notifier exit; -} XenIOState; - /* Xen specific function for piix pci */ =20 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) @@ -247,42 +174,6 @@ static void xen_ram_init(PCMachineState *pcms, } } =20 -void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, - Error **errp) -{ - unsigned long nr_pfn; - xen_pfn_t *pfn_list; - int i; - - if (runstate_check(RUN_STATE_INMIGRATE)) { - /* RAM already populated in Xen */ - fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT - " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRAT= E\n", - __func__, size, ram_addr); - return; - } - - if (mr =3D=3D &ram_memory) { - return; - } - - trace_xen_ram_alloc(ram_addr, size); - - nr_pfn =3D size >> TARGET_PAGE_BITS; - pfn_list =3D g_malloc(sizeof (*pfn_list) * nr_pfn); - - for (i =3D 0; i < nr_pfn; i++) { - pfn_list[i] =3D (ram_addr >> TARGET_PAGE_BITS) + i; - } - - if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 0, = pfn_list)) { - error_setg(errp, "xen: failed to populate ram at " RAM_ADDR_FMT, - ram_addr); - } - - g_free(pfn_list); -} - static XenPhysmap *get_physmapping(hwaddr start_addr, ram_addr_t size) { XenPhysmap *physmap =3D NULL; @@ -472,144 +363,6 @@ static int xen_remove_from_physmap(XenIOState *state, return 0; } =20 -static void xen_set_memory(struct MemoryListener *listener, - MemoryRegionSection *section, - bool add) -{ - XenIOState *state =3D container_of(listener, XenIOState, memory_listen= er); - hwaddr start_addr =3D section->offset_within_address_space; - ram_addr_t size =3D int128_get64(section->size); - bool log_dirty =3D memory_region_is_logging(section->mr, DIRTY_MEMORY_= VGA); - hvmmem_type_t mem_type; - - if (section->mr =3D=3D &ram_memory) { - return; - } else { - if (add) { - xen_map_memory_section(xen_domid, state->ioservid, - section); - } else { - xen_unmap_memory_section(xen_domid, state->ioservid, - section); - } - } - - if (!memory_region_is_ram(section->mr)) { - return; - } - - if (log_dirty !=3D add) { - return; - } - - trace_xen_client_set_memory(start_addr, size, log_dirty); - - start_addr &=3D TARGET_PAGE_MASK; - size =3D TARGET_PAGE_ALIGN(size); - - if (add) { - if (!memory_region_is_rom(section->mr)) { - xen_add_to_physmap(state, start_addr, size, - section->mr, section->offset_within_region); - } else { - mem_type =3D HVMMEM_ram_ro; - if (xen_set_mem_type(xen_domid, mem_type, - start_addr >> TARGET_PAGE_BITS, - size >> TARGET_PAGE_BITS)) { - DPRINTF("xen_set_mem_type error, addr: "HWADDR_FMT_plx"\n", - start_addr); - } - } - } else { - if (xen_remove_from_physmap(state, start_addr, size) < 0) { - DPRINTF("physmapping does not exist at "HWADDR_FMT_plx"\n", st= art_addr); - } - } -} - -static void xen_region_add(MemoryListener *listener, - MemoryRegionSection *section) -{ - memory_region_ref(section->mr); - xen_set_memory(listener, section, true); -} - -static void xen_region_del(MemoryListener *listener, - MemoryRegionSection *section) -{ - xen_set_memory(listener, section, false); - memory_region_unref(section->mr); -} - -static void xen_io_add(MemoryListener *listener, - MemoryRegionSection *section) -{ - XenIOState *state =3D container_of(listener, XenIOState, io_listener); - MemoryRegion *mr =3D section->mr; - - if (mr->ops =3D=3D &unassigned_io_ops) { - return; - } - - memory_region_ref(mr); - - xen_map_io_section(xen_domid, state->ioservid, section); -} - -static void xen_io_del(MemoryListener *listener, - MemoryRegionSection *section) -{ - XenIOState *state =3D container_of(listener, XenIOState, io_listener); - MemoryRegion *mr =3D section->mr; - - if (mr->ops =3D=3D &unassigned_io_ops) { - return; - } - - xen_unmap_io_section(xen_domid, state->ioservid, section); - - memory_region_unref(mr); -} - -static void xen_device_realize(DeviceListener *listener, - DeviceState *dev) -{ - XenIOState *state =3D container_of(listener, XenIOState, device_listen= er); - - if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - PCIDevice *pci_dev =3D PCI_DEVICE(dev); - XenPciDevice *xendev =3D g_new(XenPciDevice, 1); - - xendev->pci_dev =3D pci_dev; - xendev->sbdf =3D PCI_BUILD_BDF(pci_dev_bus_num(pci_dev), - pci_dev->devfn); - QLIST_INSERT_HEAD(&state->dev_list, xendev, entry); - - xen_map_pcidev(xen_domid, state->ioservid, pci_dev); - } -} - -static void xen_device_unrealize(DeviceListener *listener, - DeviceState *dev) -{ - XenIOState *state =3D container_of(listener, XenIOState, device_listen= er); - - if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - PCIDevice *pci_dev =3D PCI_DEVICE(dev); - XenPciDevice *xendev, *next; - - xen_unmap_pcidev(xen_domid, state->ioservid, pci_dev); - - QLIST_FOREACH_SAFE(xendev, &state->dev_list, entry, next) { - if (xendev->pci_dev =3D=3D pci_dev) { - QLIST_REMOVE(xendev, entry); - g_free(xendev); - break; - } - } - } -} - static void xen_sync_dirty_bitmap(XenIOState *state, hwaddr start_addr, ram_addr_t size) @@ -717,277 +470,6 @@ static MemoryListener xen_memory_listener =3D { .priority =3D 10, }; =20 -static MemoryListener xen_io_listener =3D { - .name =3D "xen-io", - .region_add =3D xen_io_add, - .region_del =3D xen_io_del, - .priority =3D 10, -}; - -static DeviceListener xen_device_listener =3D { - .realize =3D xen_device_realize, - .unrealize =3D xen_device_unrealize, -}; - -/* get the ioreq packets from share mem */ -static ioreq_t *cpu_get_ioreq_from_shared_memory(XenIOState *state, int vc= pu) -{ - ioreq_t *req =3D xen_vcpu_ioreq(state->shared_page, vcpu); - - if (req->state !=3D STATE_IOREQ_READY) { - DPRINTF("I/O request not ready: " - "%x, ptr: %x, port: %"PRIx64", " - "data: %"PRIx64", count: %u, size: %u\n", - req->state, req->data_is_ptr, req->addr, - req->data, req->count, req->size); - return NULL; - } - - xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */ - - req->state =3D STATE_IOREQ_INPROCESS; - return req; -} - -/* use poll to get the port notification */ -/* ioreq_vec--out,the */ -/* retval--the number of ioreq packet */ -static ioreq_t *cpu_get_ioreq(XenIOState *state) -{ - MachineState *ms =3D MACHINE(qdev_get_machine()); - unsigned int max_cpus =3D ms->smp.max_cpus; - int i; - evtchn_port_t port; - - port =3D qemu_xen_evtchn_pending(state->xce_handle); - if (port =3D=3D state->bufioreq_local_port) { - timer_mod(state->buffered_io_timer, - BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIM= E)); - return NULL; - } - - if (port !=3D -1) { - for (i =3D 0; i < max_cpus; i++) { - if (state->ioreq_local_port[i] =3D=3D port) { - break; - } - } - - if (i =3D=3D max_cpus) { - hw_error("Fatal error while trying to get io event!\n"); - } - - /* unmask the wanted port again */ - qemu_xen_evtchn_unmask(state->xce_handle, port); - - /* get the io packet from shared memory */ - state->send_vcpu =3D i; - return cpu_get_ioreq_from_shared_memory(state, i); - } - - /* read error or read nothing */ - return NULL; -} - -static uint32_t do_inp(uint32_t addr, unsigned long size) -{ - switch (size) { - case 1: - return cpu_inb(addr); - case 2: - return cpu_inw(addr); - case 4: - return cpu_inl(addr); - default: - hw_error("inp: bad size: %04x %lx", addr, size); - } -} - -static void do_outp(uint32_t addr, - unsigned long size, uint32_t val) -{ - switch (size) { - case 1: - return cpu_outb(addr, val); - case 2: - return cpu_outw(addr, val); - case 4: - return cpu_outl(addr, val); - default: - hw_error("outp: bad size: %04x %lx", addr, size); - } -} - -/* - * Helper functions which read/write an object from/to physical guest - * memory, as part of the implementation of an ioreq. - * - * Equivalent to - * cpu_physical_memory_rw(addr + (req->df ? -1 : +1) * req->size * i, - * val, req->size, 0/1) - * except without the integer overflow problems. - */ -static void rw_phys_req_item(hwaddr addr, - ioreq_t *req, uint32_t i, void *val, int rw) -{ - /* Do everything unsigned so overflow just results in a truncated resu= lt - * and accesses to undesired parts of guest memory, which is up - * to the guest */ - hwaddr offset =3D (hwaddr)req->size * i; - if (req->df) { - addr -=3D offset; - } else { - addr +=3D offset; - } - cpu_physical_memory_rw(addr, val, req->size, rw); -} - -static inline void read_phys_req_item(hwaddr addr, - ioreq_t *req, uint32_t i, void *val) -{ - rw_phys_req_item(addr, req, i, val, 0); -} -static inline void write_phys_req_item(hwaddr addr, - ioreq_t *req, uint32_t i, void *val) -{ - rw_phys_req_item(addr, req, i, val, 1); -} - - -static void cpu_ioreq_pio(ioreq_t *req) -{ - uint32_t i; - - trace_cpu_ioreq_pio(req, req->dir, req->df, req->data_is_ptr, req->add= r, - req->data, req->count, req->size); - - if (req->size > sizeof(uint32_t)) { - hw_error("PIO: bad size (%u)", req->size); - } - - if (req->dir =3D=3D IOREQ_READ) { - if (!req->data_is_ptr) { - req->data =3D do_inp(req->addr, req->size); - trace_cpu_ioreq_pio_read_reg(req, req->data, req->addr, - req->size); - } else { - uint32_t tmp; - - for (i =3D 0; i < req->count; i++) { - tmp =3D do_inp(req->addr, req->size); - write_phys_req_item(req->data, req, i, &tmp); - } - } - } else if (req->dir =3D=3D IOREQ_WRITE) { - if (!req->data_is_ptr) { - trace_cpu_ioreq_pio_write_reg(req, req->data, req->addr, - req->size); - do_outp(req->addr, req->size, req->data); - } else { - for (i =3D 0; i < req->count; i++) { - uint32_t tmp =3D 0; - - read_phys_req_item(req->data, req, i, &tmp); - do_outp(req->addr, req->size, tmp); - } - } - } -} - -static void cpu_ioreq_move(ioreq_t *req) -{ - uint32_t i; - - trace_cpu_ioreq_move(req, req->dir, req->df, req->data_is_ptr, req->ad= dr, - req->data, req->count, req->size); - - if (req->size > sizeof(req->data)) { - hw_error("MMIO: bad size (%u)", req->size); - } - - if (!req->data_is_ptr) { - if (req->dir =3D=3D IOREQ_READ) { - for (i =3D 0; i < req->count; i++) { - read_phys_req_item(req->addr, req, i, &req->data); - } - } else if (req->dir =3D=3D IOREQ_WRITE) { - for (i =3D 0; i < req->count; i++) { - write_phys_req_item(req->addr, req, i, &req->data); - } - } - } else { - uint64_t tmp; - - if (req->dir =3D=3D IOREQ_READ) { - for (i =3D 0; i < req->count; i++) { - read_phys_req_item(req->addr, req, i, &tmp); - write_phys_req_item(req->data, req, i, &tmp); - } - } else if (req->dir =3D=3D IOREQ_WRITE) { - for (i =3D 0; i < req->count; i++) { - read_phys_req_item(req->data, req, i, &tmp); - write_phys_req_item(req->addr, req, i, &tmp); - } - } - } -} - -static void cpu_ioreq_config(XenIOState *state, ioreq_t *req) -{ - uint32_t sbdf =3D req->addr >> 32; - uint32_t reg =3D req->addr; - XenPciDevice *xendev; - - if (req->size !=3D sizeof(uint8_t) && req->size !=3D sizeof(uint16_t) = && - req->size !=3D sizeof(uint32_t)) { - hw_error("PCI config access: bad size (%u)", req->size); - } - - if (req->count !=3D 1) { - hw_error("PCI config access: bad count (%u)", req->count); - } - - QLIST_FOREACH(xendev, &state->dev_list, entry) { - if (xendev->sbdf !=3D sbdf) { - continue; - } - - if (!req->data_is_ptr) { - if (req->dir =3D=3D IOREQ_READ) { - req->data =3D pci_host_config_read_common( - xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, - req->size); - trace_cpu_ioreq_config_read(req, xendev->sbdf, reg, - req->size, req->data); - } else if (req->dir =3D=3D IOREQ_WRITE) { - trace_cpu_ioreq_config_write(req, xendev->sbdf, reg, - req->size, req->data); - pci_host_config_write_common( - xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, - req->data, req->size); - } - } else { - uint32_t tmp; - - if (req->dir =3D=3D IOREQ_READ) { - tmp =3D pci_host_config_read_common( - xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, - req->size); - trace_cpu_ioreq_config_read(req, xendev->sbdf, reg, - req->size, tmp); - write_phys_req_item(req->data, req, 0, &tmp); - } else if (req->dir =3D=3D IOREQ_WRITE) { - read_phys_req_item(req->data, req, 0, &tmp); - trace_cpu_ioreq_config_write(req, xendev->sbdf, reg, - req->size, tmp); - pci_host_config_write_common( - xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, - tmp, req->size); - } - } - } -} - static void regs_to_cpu(vmware_regs_t *vmport_regs, ioreq_t *req) { X86CPU *cpu; @@ -1031,226 +513,6 @@ static void handle_vmport_ioreq(XenIOState *state, i= oreq_t *req) current_cpu =3D NULL; } =20 -static void handle_ioreq(XenIOState *state, ioreq_t *req) -{ - trace_handle_ioreq(req, req->type, req->dir, req->df, req->data_is_ptr, - req->addr, req->data, req->count, req->size); - - if (!req->data_is_ptr && (req->dir =3D=3D IOREQ_WRITE) && - (req->size < sizeof (target_ulong))) { - req->data &=3D ((target_ulong) 1 << (8 * req->size)) - 1; - } - - if (req->dir =3D=3D IOREQ_WRITE) - trace_handle_ioreq_write(req, req->type, req->df, req->data_is_ptr, - req->addr, req->data, req->count, req->si= ze); - - switch (req->type) { - case IOREQ_TYPE_PIO: - cpu_ioreq_pio(req); - break; - case IOREQ_TYPE_COPY: - cpu_ioreq_move(req); - break; - case IOREQ_TYPE_VMWARE_PORT: - handle_vmport_ioreq(state, req); - break; - case IOREQ_TYPE_TIMEOFFSET: - break; - case IOREQ_TYPE_INVALIDATE: - xen_invalidate_map_cache(); - break; - case IOREQ_TYPE_PCI_CONFIG: - cpu_ioreq_config(state, req); - break; - default: - hw_error("Invalid ioreq type 0x%x\n", req->type); - } - if (req->dir =3D=3D IOREQ_READ) { - trace_handle_ioreq_read(req, req->type, req->df, req->data_is_ptr, - req->addr, req->data, req->count, req->siz= e); - } -} - -static bool handle_buffered_iopage(XenIOState *state) -{ - buffered_iopage_t *buf_page =3D state->buffered_io_page; - buf_ioreq_t *buf_req =3D NULL; - bool handled_ioreq =3D false; - ioreq_t req; - int qw; - - if (!buf_page) { - return 0; - } - - memset(&req, 0x00, sizeof(req)); - req.state =3D STATE_IOREQ_READY; - req.count =3D 1; - req.dir =3D IOREQ_WRITE; - - for (;;) { - uint32_t rdptr =3D buf_page->read_pointer, wrptr; - - xen_rmb(); - wrptr =3D buf_page->write_pointer; - xen_rmb(); - if (rdptr !=3D buf_page->read_pointer) { - continue; - } - if (rdptr =3D=3D wrptr) { - break; - } - buf_req =3D &buf_page->buf_ioreq[rdptr % IOREQ_BUFFER_SLOT_NUM]; - req.size =3D 1U << buf_req->size; - req.addr =3D buf_req->addr; - req.data =3D buf_req->data; - req.type =3D buf_req->type; - xen_rmb(); - qw =3D (req.size =3D=3D 8); - if (qw) { - if (rdptr + 1 =3D=3D wrptr) { - hw_error("Incomplete quad word buffered ioreq"); - } - buf_req =3D &buf_page->buf_ioreq[(rdptr + 1) % - IOREQ_BUFFER_SLOT_NUM]; - req.data |=3D ((uint64_t)buf_req->data) << 32; - xen_rmb(); - } - - handle_ioreq(state, &req); - - /* Only req.data may get updated by handle_ioreq(), albeit even th= at - * should not happen as such data would never make it to the guest= (we - * can only usefully see writes here after all). - */ - assert(req.state =3D=3D STATE_IOREQ_READY); - assert(req.count =3D=3D 1); - assert(req.dir =3D=3D IOREQ_WRITE); - assert(!req.data_is_ptr); - - qatomic_add(&buf_page->read_pointer, qw + 1); - handled_ioreq =3D true; - } - - return handled_ioreq; -} - -static void handle_buffered_io(void *opaque) -{ - XenIOState *state =3D opaque; - - if (handle_buffered_iopage(state)) { - timer_mod(state->buffered_io_timer, - BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIM= E)); - } else { - timer_del(state->buffered_io_timer); - qemu_xen_evtchn_unmask(state->xce_handle, state->bufioreq_local_po= rt); - } -} - -static void cpu_handle_ioreq(void *opaque) -{ - XenIOState *state =3D opaque; - ioreq_t *req =3D cpu_get_ioreq(state); - - handle_buffered_iopage(state); - if (req) { - ioreq_t copy =3D *req; - - xen_rmb(); - handle_ioreq(state, ©); - req->data =3D copy.data; - - if (req->state !=3D STATE_IOREQ_INPROCESS) { - fprintf(stderr, "Badness in I/O request ... not in service?!: " - "%x, ptr: %x, port: %"PRIx64", " - "data: %"PRIx64", count: %u, size: %u, type: %u\n", - req->state, req->data_is_ptr, req->addr, - req->data, req->count, req->size, req->type); - destroy_hvm_domain(false); - return; - } - - xen_wmb(); /* Update ioreq contents /then/ update state. */ - - /* - * We do this before we send the response so that the tools - * have the opportunity to pick up on the reset before the - * guest resumes and does a hlt with interrupts disabled which - * causes Xen to powerdown the domain. - */ - if (runstate_is_running()) { - ShutdownCause request; - - if (qemu_shutdown_requested_get()) { - destroy_hvm_domain(false); - } - request =3D qemu_reset_requested_get(); - if (request) { - qemu_system_reset(request); - destroy_hvm_domain(true); - } - } - - req->state =3D STATE_IORESP_READY; - qemu_xen_evtchn_notify(state->xce_handle, - state->ioreq_local_port[state->send_vcpu]); - } -} - -static void xen_main_loop_prepare(XenIOState *state) -{ - int evtchn_fd =3D -1; - - if (state->xce_handle !=3D NULL) { - evtchn_fd =3D qemu_xen_evtchn_fd(state->xce_handle); - } - - state->buffered_io_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, handle_= buffered_io, - state); - - if (evtchn_fd !=3D -1) { - CPUState *cpu_state; - - DPRINTF("%s: Init cpu_by_vcpu_id\n", __func__); - CPU_FOREACH(cpu_state) { - DPRINTF("%s: cpu_by_vcpu_id[%d]=3D%p\n", - __func__, cpu_state->cpu_index, cpu_state); - state->cpu_by_vcpu_id[cpu_state->cpu_index] =3D cpu_state; - } - qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state); - } -} - - -static void xen_hvm_change_state_handler(void *opaque, bool running, - RunState rstate) -{ - XenIOState *state =3D opaque; - - if (running) { - xen_main_loop_prepare(state); - } - - xen_set_ioreq_server_state(xen_domid, - state->ioservid, - (rstate =3D=3D RUN_STATE_RUNNING)); -} - -static void xen_exit_notifier(Notifier *n, void *data) -{ - XenIOState *state =3D container_of(n, XenIOState, exit); - - xen_destroy_ioreq_server(xen_domid, state->ioservid); - if (state->fres !=3D NULL) { - xenforeignmemory_unmap_resource(xen_fmem, state->fres); - } - - qemu_xen_evtchn_close(state->xce_handle); - xs_daemon_close(state->xenstore); -} - #ifdef XEN_COMPAT_PHYSMAP static void xen_read_physmap(XenIOState *state) { @@ -1310,175 +572,17 @@ static void xen_wakeup_notifier(Notifier *notifier,= void *data) xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); } =20 -static int xen_map_ioreq_server(XenIOState *state) -{ - void *addr =3D NULL; - xen_pfn_t ioreq_pfn; - xen_pfn_t bufioreq_pfn; - evtchn_port_t bufioreq_evtchn; - int rc; - - /* - * Attempt to map using the resource API and fall back to normal - * foreign mapping if this is not supported. - */ - QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_bufioreq !=3D 0); - QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_ioreq(0) !=3D 1); - state->fres =3D xenforeignmemory_map_resource(xen_fmem, xen_domid, - XENMEM_resource_ioreq_server, - state->ioservid, 0, 2, - &addr, - PROT_READ | PROT_WRITE, 0); - if (state->fres !=3D NULL) { - trace_xen_map_resource_ioreq(state->ioservid, addr); - state->buffered_io_page =3D addr; - state->shared_page =3D addr + TARGET_PAGE_SIZE; - } else if (errno !=3D EOPNOTSUPP) { - error_report("failed to map ioreq server resources: error %d handl= e=3D%p", - errno, xen_xc); - return -1; - } - - rc =3D xen_get_ioreq_server_info(xen_domid, state->ioservid, - (state->shared_page =3D=3D NULL) ? - &ioreq_pfn : NULL, - (state->buffered_io_page =3D=3D NULL) ? - &bufioreq_pfn : NULL, - &bufioreq_evtchn); - if (rc < 0) { - error_report("failed to get ioreq server info: error %d handle=3D%= p", - errno, xen_xc); - return rc; - } - - if (state->shared_page =3D=3D NULL) { - DPRINTF("shared page at pfn %lx\n", ioreq_pfn); - - state->shared_page =3D xenforeignmemory_map(xen_fmem, xen_domid, - PROT_READ | PROT_WRITE, - 1, &ioreq_pfn, NULL); - if (state->shared_page =3D=3D NULL) { - error_report("map shared IO page returned error %d handle=3D%p= ", - errno, xen_xc); - } - } - - if (state->buffered_io_page =3D=3D NULL) { - DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn); - - state->buffered_io_page =3D xenforeignmemory_map(xen_fmem, xen_dom= id, - PROT_READ | PROT_WR= ITE, - 1, &bufioreq_pfn, - NULL); - if (state->buffered_io_page =3D=3D NULL) { - error_report("map buffered IO page returned error %d", errno); - return -1; - } - } - - if (state->shared_page =3D=3D NULL || state->buffered_io_page =3D=3D N= ULL) { - return -1; - } - - DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn); - - state->bufioreq_remote_port =3D bufioreq_evtchn; - - return 0; -} - void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) { MachineState *ms =3D MACHINE(pcms); unsigned int max_cpus =3D ms->smp.max_cpus; - int i, rc; + int rc; xen_pfn_t ioreq_pfn; XenIOState *state; =20 - setup_xen_backend_ops(); - state =3D g_new0(XenIOState, 1); =20 - state->xce_handle =3D qemu_xen_evtchn_open(); - if (state->xce_handle =3D=3D NULL) { - perror("xen: event channel open"); - goto err; - } - - state->xenstore =3D xs_daemon_open(); - if (state->xenstore =3D=3D NULL) { - perror("xen: xenstore open"); - goto err; - } - - xen_create_ioreq_server(xen_domid, &state->ioservid); - - state->exit.notify =3D xen_exit_notifier; - qemu_add_exit_notifier(&state->exit); - - /* - * Register wake-up support in QMP query-current-machine API - */ - qemu_register_wakeup_support(); - - rc =3D xen_map_ioreq_server(state); - if (rc < 0) { - goto err; - } - - /* Note: cpus is empty at this point in init */ - state->cpu_by_vcpu_id =3D g_new0(CPUState *, max_cpus); - - rc =3D xen_set_ioreq_server_state(xen_domid, state->ioservid, true); - if (rc < 0) { - error_report("failed to enable ioreq server info: error %d handle= =3D%p", - errno, xen_xc); - goto err; - } - - state->ioreq_local_port =3D g_new0(evtchn_port_t, max_cpus); - - /* FIXME: how about if we overflow the page here? */ - for (i =3D 0; i < max_cpus; i++) { - rc =3D qemu_xen_evtchn_bind_interdomain(state->xce_handle, xen_dom= id, - xen_vcpu_eport(state->shared= _page, - i)); - if (rc =3D=3D -1) { - error_report("shared evtchn %d bind error %d", i, errno); - goto err; - } - state->ioreq_local_port[i] =3D rc; - } - - rc =3D qemu_xen_evtchn_bind_interdomain(state->xce_handle, xen_domid, - state->bufioreq_remote_port); - if (rc =3D=3D -1) { - error_report("buffered evtchn bind error %d", errno); - goto err; - } - state->bufioreq_local_port =3D rc; - - /* Init RAM management */ -#ifdef XEN_COMPAT_PHYSMAP - xen_map_cache_init(xen_phys_offset_to_gaddr, state); -#else - xen_map_cache_init(NULL, state); -#endif - - qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state); - - state->memory_listener =3D xen_memory_listener; - memory_listener_register(&state->memory_listener, &address_space_memor= y); - - state->io_listener =3D xen_io_listener; - memory_listener_register(&state->io_listener, &address_space_io); - - state->device_listener =3D xen_device_listener; - QLIST_INIT(&state->dev_list); - device_listener_register(&state->device_listener); - - xen_bus_init(); - xen_be_init(); + xen_register_ioreq(state, max_cpus, xen_memory_listener); =20 QLIST_INIT(&xen_physmap); xen_read_physmap(state); @@ -1518,59 +622,11 @@ err: exit(1); } =20 -void destroy_hvm_domain(bool reboot) -{ - xc_interface *xc_handle; - int sts; - int rc; - - unsigned int reason =3D reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; - - if (xen_dmod) { - rc =3D xendevicemodel_shutdown(xen_dmod, xen_domid, reason); - if (!rc) { - return; - } - if (errno !=3D ENOTTY /* old Xen */) { - perror("xendevicemodel_shutdown failed"); - } - /* well, try the old thing then */ - } - - xc_handle =3D xc_interface_open(0, 0, 0); - if (xc_handle =3D=3D NULL) { - fprintf(stderr, "Cannot acquire xenctrl handle\n"); - } else { - sts =3D xc_domain_shutdown(xc_handle, xen_domid, reason); - if (sts !=3D 0) { - fprintf(stderr, "xc_domain_shutdown failed to issue %s, " - "sts %d, %s\n", reboot ? "reboot" : "poweroff", - sts, strerror(errno)); - } else { - fprintf(stderr, "Issued domain %d %s\n", xen_domid, - reboot ? "reboot" : "poweroff"); - } - xc_interface_close(xc_handle); - } -} - void xen_register_framebuffer(MemoryRegion *mr) { framebuffer =3D mr; } =20 -void xen_shutdown_fatal_error(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "Will destroy the domain.\n"); - /* destroy the domain */ - qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); -} - void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) { if (unlikely(xen_in_migration)) { @@ -1602,3 +658,57 @@ void qmp_xen_set_global_dirty_log(bool enable, Error = **errp) memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION); } } + +void arch_xen_set_memory(XenIOState *state, MemoryRegionSection *section, + bool add) +{ + hwaddr start_addr =3D section->offset_within_address_space; + ram_addr_t size =3D int128_get64(section->size); + bool log_dirty =3D memory_region_is_logging(section->mr, DIRTY_MEMORY_= VGA); + hvmmem_type_t mem_type; + + if (!memory_region_is_ram(section->mr)) { + return; + } + + if (log_dirty !=3D add) { + return; + } + + trace_xen_client_set_memory(start_addr, size, log_dirty); + + start_addr &=3D TARGET_PAGE_MASK; + size =3D TARGET_PAGE_ALIGN(size); + + if (add) { + if (!memory_region_is_rom(section->mr)) { + xen_add_to_physmap(state, start_addr, size, + section->mr, section->offset_within_region); + } else { + mem_type =3D HVMMEM_ram_ro; + if (xen_set_mem_type(xen_domid, mem_type, + start_addr >> TARGET_PAGE_BITS, + size >> TARGET_PAGE_BITS)) { + DPRINTF("xen_set_mem_type error, addr: "HWADDR_FMT_plx"\n", + start_addr); + } + } + } else { + if (xen_remove_from_physmap(state, start_addr, size) < 0) { + DPRINTF("physmapping does not exist at "HWADDR_FMT_plx"\n", st= art_addr); + } + } +} + +void arch_handle_ioreq(XenIOState *state, ioreq_t *req) +{ + switch (req->type) { + case IOREQ_TYPE_VMWARE_PORT: + handle_vmport_ioreq(state, req); + break; + default: + hw_error("Invalid ioreq type 0x%x\n", req->type); + } + + return; +} diff --git a/hw/xen/meson.build b/hw/xen/meson.build index 202752e557..afd20754a1 100644 --- a/hw/xen/meson.build +++ b/hw/xen/meson.build @@ -29,4 +29,7 @@ specific_ss.add_all(when: ['CONFIG_XEN', xen], if_true: x= en_specific_ss) =20 xen_ss =3D ss.source_set() =20 -xen_ss.add(when: 'CONFIG_XEN', if_true: files('xen-mapcache.c')) +xen_ss.add(when: 'CONFIG_XEN', if_true: files( + 'xen-mapcache.c', + 'xen-hvm-common.c', +)) diff --git a/hw/xen/trace-events b/hw/xen/trace-events index f977c7c8c6..67a6c41926 100644 --- a/hw/xen/trace-events +++ b/hw/xen/trace-events @@ -42,6 +42,20 @@ xs_node_vscanf(char *path, char *value) "%s %s" xs_node_watch(char *path) "%s" xs_node_unwatch(char *path) "%s" =20 +# xen-hvm.c +xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: 0x%l= x, size 0x%lx" +xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_di= rty) "0x%"PRIx64" size 0x%lx, log_dirty %i" +handle_ioreq(void *req, uint32_t type, uint32_t dir, uint32_t df, uint32_t= data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) = "I/O=3D%p type=3D%d dir=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%= "PRIx64" count=3D%d size=3D%d" +handle_ioreq_read(void *req, uint32_t type, uint32_t df, uint32_t data_is_= ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=3D%p= read type=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%"PRIx64" coun= t=3D%d size=3D%d" +handle_ioreq_write(void *req, uint32_t type, uint32_t df, uint32_t data_is= _ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=3D%= p write type=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%"PRIx64" co= unt=3D%d size=3D%d" +cpu_ioreq_pio(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr, = uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=3D%p pio = dir=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%"PRIx64" count=3D%d = size=3D%d" +cpu_ioreq_pio_read_reg(void *req, uint64_t data, uint64_t addr, uint32_t s= ize) "I/O=3D%p pio read reg data=3D0x%"PRIx64" port=3D0x%"PRIx64" size=3D%d" +cpu_ioreq_pio_write_reg(void *req, uint64_t data, uint64_t addr, uint32_t = size) "I/O=3D%p pio write reg data=3D0x%"PRIx64" port=3D0x%"PRIx64" size=3D= %d" +cpu_ioreq_move(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr,= uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=3D%p cop= y dir=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%"PRIx64" count=3D%= d size=3D%d" +xen_map_resource_ioreq(uint32_t id, void *addr) "id: %u addr: %p" +cpu_ioreq_config_read(void *req, uint32_t sbdf, uint32_t reg, uint32_t siz= e, uint32_t data) "I/O=3D%p sbdf=3D0x%x reg=3D%u size=3D%u data=3D0x%x" +cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_t reg, uint32_t si= ze, uint32_t data) "I/O=3D%p sbdf=3D0x%x reg=3D%u size=3D%u data=3D0x%x" + # xen-mapcache.c xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 xen_remap_bucket(uint64_t index) "index 0x%"PRIx64 diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c new file mode 100644 index 0000000000..a31b067404 --- /dev/null +++ b/hw/xen/xen-hvm-common.c @@ -0,0 +1,860 @@ +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "qapi/error.h" +#include "trace.h" + +#include "hw/pci/pci_host.h" +#include "hw/xen/xen-hvm-common.h" +#include "hw/xen/xen-bus.h" +#include "hw/boards.h" +#include "hw/xen/arch_hvm.h" + +MemoryRegion ram_memory; + +void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, + Error **errp) +{ + unsigned long nr_pfn; + xen_pfn_t *pfn_list; + int i; + + if (runstate_check(RUN_STATE_INMIGRATE)) { + /* RAM already populated in Xen */ + fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT + " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRAT= E\n", + __func__, size, ram_addr); + return; + } + + if (mr =3D=3D &ram_memory) { + return; + } + + trace_xen_ram_alloc(ram_addr, size); + + nr_pfn =3D size >> TARGET_PAGE_BITS; + pfn_list =3D g_malloc(sizeof (*pfn_list) * nr_pfn); + + for (i =3D 0; i < nr_pfn; i++) { + pfn_list[i] =3D (ram_addr >> TARGET_PAGE_BITS) + i; + } + + if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 0, = pfn_list)) { + error_setg(errp, "xen: failed to populate ram at " RAM_ADDR_FMT, + ram_addr); + } + + g_free(pfn_list); +} + +static void xen_set_memory(struct MemoryListener *listener, + MemoryRegionSection *section, + bool add) +{ + XenIOState *state =3D container_of(listener, XenIOState, memory_listen= er); + + if (section->mr =3D=3D &ram_memory) { + return; + } else { + if (add) { + xen_map_memory_section(xen_domid, state->ioservid, + section); + } else { + xen_unmap_memory_section(xen_domid, state->ioservid, + section); + } + } + + arch_xen_set_memory(state, section, add); +} + +void xen_region_add(MemoryListener *listener, + MemoryRegionSection *section) +{ + memory_region_ref(section->mr); + xen_set_memory(listener, section, true); +} + +void xen_region_del(MemoryListener *listener, + MemoryRegionSection *section) +{ + xen_set_memory(listener, section, false); + memory_region_unref(section->mr); +} + +void xen_io_add(MemoryListener *listener, + MemoryRegionSection *section) +{ + XenIOState *state =3D container_of(listener, XenIOState, io_listener); + MemoryRegion *mr =3D section->mr; + + if (mr->ops =3D=3D &unassigned_io_ops) { + return; + } + + memory_region_ref(mr); + + xen_map_io_section(xen_domid, state->ioservid, section); +} + +void xen_io_del(MemoryListener *listener, + MemoryRegionSection *section) +{ + XenIOState *state =3D container_of(listener, XenIOState, io_listener); + MemoryRegion *mr =3D section->mr; + + if (mr->ops =3D=3D &unassigned_io_ops) { + return; + } + + xen_unmap_io_section(xen_domid, state->ioservid, section); + + memory_region_unref(mr); +} + +void xen_device_realize(DeviceListener *listener, + DeviceState *dev) +{ + XenIOState *state =3D container_of(listener, XenIOState, device_listen= er); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + PCIDevice *pci_dev =3D PCI_DEVICE(dev); + XenPciDevice *xendev =3D g_new(XenPciDevice, 1); + + xendev->pci_dev =3D pci_dev; + xendev->sbdf =3D PCI_BUILD_BDF(pci_dev_bus_num(pci_dev), + pci_dev->devfn); + QLIST_INSERT_HEAD(&state->dev_list, xendev, entry); + + xen_map_pcidev(xen_domid, state->ioservid, pci_dev); + } +} + +void xen_device_unrealize(DeviceListener *listener, + DeviceState *dev) +{ + XenIOState *state =3D container_of(listener, XenIOState, device_listen= er); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + PCIDevice *pci_dev =3D PCI_DEVICE(dev); + XenPciDevice *xendev, *next; + + xen_unmap_pcidev(xen_domid, state->ioservid, pci_dev); + + QLIST_FOREACH_SAFE(xendev, &state->dev_list, entry, next) { + if (xendev->pci_dev =3D=3D pci_dev) { + QLIST_REMOVE(xendev, entry); + g_free(xendev); + break; + } + } + } +} + +MemoryListener xen_io_listener =3D { + .name =3D "xen-io", + .region_add =3D xen_io_add, + .region_del =3D xen_io_del, + .priority =3D 10, +}; + +DeviceListener xen_device_listener =3D { + .realize =3D xen_device_realize, + .unrealize =3D xen_device_unrealize, +}; + +/* get the ioreq packets from share mem */ +static ioreq_t *cpu_get_ioreq_from_shared_memory(XenIOState *state, int vc= pu) +{ + ioreq_t *req =3D xen_vcpu_ioreq(state->shared_page, vcpu); + + if (req->state !=3D STATE_IOREQ_READY) { + DPRINTF("I/O request not ready: " + "%x, ptr: %x, port: %"PRIx64", " + "data: %"PRIx64", count: %u, size: %u\n", + req->state, req->data_is_ptr, req->addr, + req->data, req->count, req->size); + return NULL; + } + + xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */ + + req->state =3D STATE_IOREQ_INPROCESS; + return req; +} + +/* use poll to get the port notification */ +/* ioreq_vec--out,the */ +/* retval--the number of ioreq packet */ +static ioreq_t *cpu_get_ioreq(XenIOState *state) +{ + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int max_cpus =3D ms->smp.max_cpus; + int i; + evtchn_port_t port; + + port =3D qemu_xen_evtchn_pending(state->xce_handle); + if (port =3D=3D state->bufioreq_local_port) { + timer_mod(state->buffered_io_timer, + BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIM= E)); + return NULL; + } + + if (port !=3D -1) { + for (i =3D 0; i < max_cpus; i++) { + if (state->ioreq_local_port[i] =3D=3D port) { + break; + } + } + + if (i =3D=3D max_cpus) { + hw_error("Fatal error while trying to get io event!\n"); + } + + /* unmask the wanted port again */ + qemu_xen_evtchn_unmask(state->xce_handle, port); + + /* get the io packet from shared memory */ + state->send_vcpu =3D i; + return cpu_get_ioreq_from_shared_memory(state, i); + } + + /* read error or read nothing */ + return NULL; +} + +static uint32_t do_inp(uint32_t addr, unsigned long size) +{ + switch (size) { + case 1: + return cpu_inb(addr); + case 2: + return cpu_inw(addr); + case 4: + return cpu_inl(addr); + default: + hw_error("inp: bad size: %04x %lx", addr, size); + } +} + +static void do_outp(uint32_t addr, + unsigned long size, uint32_t val) +{ + switch (size) { + case 1: + return cpu_outb(addr, val); + case 2: + return cpu_outw(addr, val); + case 4: + return cpu_outl(addr, val); + default: + hw_error("outp: bad size: %04x %lx", addr, size); + } +} + +/* + * Helper functions which read/write an object from/to physical guest + * memory, as part of the implementation of an ioreq. + * + * Equivalent to + * cpu_physical_memory_rw(addr + (req->df ? -1 : +1) * req->size * i, + * val, req->size, 0/1) + * except without the integer overflow problems. + */ +static void rw_phys_req_item(hwaddr addr, + ioreq_t *req, uint32_t i, void *val, int rw) +{ + /* Do everything unsigned so overflow just results in a truncated resu= lt + * and accesses to undesired parts of guest memory, which is up + * to the guest */ + hwaddr offset =3D (hwaddr)req->size * i; + if (req->df) { + addr -=3D offset; + } else { + addr +=3D offset; + } + cpu_physical_memory_rw(addr, val, req->size, rw); +} + +static inline void read_phys_req_item(hwaddr addr, + ioreq_t *req, uint32_t i, void *val) +{ + rw_phys_req_item(addr, req, i, val, 0); +} +static inline void write_phys_req_item(hwaddr addr, + ioreq_t *req, uint32_t i, void *val) +{ + rw_phys_req_item(addr, req, i, val, 1); +} + + +void cpu_ioreq_pio(ioreq_t *req) +{ + uint32_t i; + + trace_cpu_ioreq_pio(req, req->dir, req->df, req->data_is_ptr, req->add= r, + req->data, req->count, req->size); + + if (req->size > sizeof(uint32_t)) { + hw_error("PIO: bad size (%u)", req->size); + } + + if (req->dir =3D=3D IOREQ_READ) { + if (!req->data_is_ptr) { + req->data =3D do_inp(req->addr, req->size); + trace_cpu_ioreq_pio_read_reg(req, req->data, req->addr, + req->size); + } else { + uint32_t tmp; + + for (i =3D 0; i < req->count; i++) { + tmp =3D do_inp(req->addr, req->size); + write_phys_req_item(req->data, req, i, &tmp); + } + } + } else if (req->dir =3D=3D IOREQ_WRITE) { + if (!req->data_is_ptr) { + trace_cpu_ioreq_pio_write_reg(req, req->data, req->addr, + req->size); + do_outp(req->addr, req->size, req->data); + } else { + for (i =3D 0; i < req->count; i++) { + uint32_t tmp =3D 0; + + read_phys_req_item(req->data, req, i, &tmp); + do_outp(req->addr, req->size, tmp); + } + } + } +} + +static void cpu_ioreq_move(ioreq_t *req) +{ + uint32_t i; + + trace_cpu_ioreq_move(req, req->dir, req->df, req->data_is_ptr, req->ad= dr, + req->data, req->count, req->size); + + if (req->size > sizeof(req->data)) { + hw_error("MMIO: bad size (%u)", req->size); + } + + if (!req->data_is_ptr) { + if (req->dir =3D=3D IOREQ_READ) { + for (i =3D 0; i < req->count; i++) { + read_phys_req_item(req->addr, req, i, &req->data); + } + } else if (req->dir =3D=3D IOREQ_WRITE) { + for (i =3D 0; i < req->count; i++) { + write_phys_req_item(req->addr, req, i, &req->data); + } + } + } else { + uint64_t tmp; + + if (req->dir =3D=3D IOREQ_READ) { + for (i =3D 0; i < req->count; i++) { + read_phys_req_item(req->addr, req, i, &tmp); + write_phys_req_item(req->data, req, i, &tmp); + } + } else if (req->dir =3D=3D IOREQ_WRITE) { + for (i =3D 0; i < req->count; i++) { + read_phys_req_item(req->data, req, i, &tmp); + write_phys_req_item(req->addr, req, i, &tmp); + } + } + } +} + +static void cpu_ioreq_config(XenIOState *state, ioreq_t *req) +{ + uint32_t sbdf =3D req->addr >> 32; + uint32_t reg =3D req->addr; + XenPciDevice *xendev; + + if (req->size !=3D sizeof(uint8_t) && req->size !=3D sizeof(uint16_t) = && + req->size !=3D sizeof(uint32_t)) { + hw_error("PCI config access: bad size (%u)", req->size); + } + + if (req->count !=3D 1) { + hw_error("PCI config access: bad count (%u)", req->count); + } + + QLIST_FOREACH(xendev, &state->dev_list, entry) { + if (xendev->sbdf !=3D sbdf) { + continue; + } + + if (!req->data_is_ptr) { + if (req->dir =3D=3D IOREQ_READ) { + req->data =3D pci_host_config_read_common( + xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, + req->size); + trace_cpu_ioreq_config_read(req, xendev->sbdf, reg, + req->size, req->data); + } else if (req->dir =3D=3D IOREQ_WRITE) { + trace_cpu_ioreq_config_write(req, xendev->sbdf, reg, + req->size, req->data); + pci_host_config_write_common( + xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, + req->data, req->size); + } + } else { + uint32_t tmp; + + if (req->dir =3D=3D IOREQ_READ) { + tmp =3D pci_host_config_read_common( + xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, + req->size); + trace_cpu_ioreq_config_read(req, xendev->sbdf, reg, + req->size, tmp); + write_phys_req_item(req->data, req, 0, &tmp); + } else if (req->dir =3D=3D IOREQ_WRITE) { + read_phys_req_item(req->data, req, 0, &tmp); + trace_cpu_ioreq_config_write(req, xendev->sbdf, reg, + req->size, tmp); + pci_host_config_write_common( + xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, + tmp, req->size); + } + } + } +} + +static void handle_ioreq(XenIOState *state, ioreq_t *req) +{ + trace_handle_ioreq(req, req->type, req->dir, req->df, req->data_is_ptr, + req->addr, req->data, req->count, req->size); + + if (!req->data_is_ptr && (req->dir =3D=3D IOREQ_WRITE) && + (req->size < sizeof (target_ulong))) { + req->data &=3D ((target_ulong) 1 << (8 * req->size)) - 1; + } + + if (req->dir =3D=3D IOREQ_WRITE) + trace_handle_ioreq_write(req, req->type, req->df, req->data_is_ptr, + req->addr, req->data, req->count, req->si= ze); + + switch (req->type) { + case IOREQ_TYPE_PIO: + cpu_ioreq_pio(req); + break; + case IOREQ_TYPE_COPY: + cpu_ioreq_move(req); + break; + case IOREQ_TYPE_TIMEOFFSET: + break; + case IOREQ_TYPE_INVALIDATE: + xen_invalidate_map_cache(); + break; + case IOREQ_TYPE_PCI_CONFIG: + cpu_ioreq_config(state, req); + break; + default: + arch_handle_ioreq(state, req); + } + if (req->dir =3D=3D IOREQ_READ) { + trace_handle_ioreq_read(req, req->type, req->df, req->data_is_ptr, + req->addr, req->data, req->count, req->siz= e); + } +} + +static bool handle_buffered_iopage(XenIOState *state) +{ + buffered_iopage_t *buf_page =3D state->buffered_io_page; + buf_ioreq_t *buf_req =3D NULL; + bool handled_ioreq =3D false; + ioreq_t req; + int qw; + + if (!buf_page) { + return 0; + } + + memset(&req, 0x00, sizeof(req)); + req.state =3D STATE_IOREQ_READY; + req.count =3D 1; + req.dir =3D IOREQ_WRITE; + + for (;;) { + uint32_t rdptr =3D buf_page->read_pointer, wrptr; + + xen_rmb(); + wrptr =3D buf_page->write_pointer; + xen_rmb(); + if (rdptr !=3D buf_page->read_pointer) { + continue; + } + if (rdptr =3D=3D wrptr) { + break; + } + buf_req =3D &buf_page->buf_ioreq[rdptr % IOREQ_BUFFER_SLOT_NUM]; + req.size =3D 1U << buf_req->size; + req.addr =3D buf_req->addr; + req.data =3D buf_req->data; + req.type =3D buf_req->type; + xen_rmb(); + qw =3D (req.size =3D=3D 8); + if (qw) { + if (rdptr + 1 =3D=3D wrptr) { + hw_error("Incomplete quad word buffered ioreq"); + } + buf_req =3D &buf_page->buf_ioreq[(rdptr + 1) % + IOREQ_BUFFER_SLOT_NUM]; + req.data |=3D ((uint64_t)buf_req->data) << 32; + xen_rmb(); + } + + handle_ioreq(state, &req); + + /* Only req.data may get updated by handle_ioreq(), albeit even th= at + * should not happen as such data would never make it to the guest= (we + * can only usefully see writes here after all). + */ + assert(req.state =3D=3D STATE_IOREQ_READY); + assert(req.count =3D=3D 1); + assert(req.dir =3D=3D IOREQ_WRITE); + assert(!req.data_is_ptr); + + qatomic_add(&buf_page->read_pointer, qw + 1); + handled_ioreq =3D true; + } + + return handled_ioreq; +} + +static void handle_buffered_io(void *opaque) +{ + XenIOState *state =3D opaque; + + if (handle_buffered_iopage(state)) { + timer_mod(state->buffered_io_timer, + BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIM= E)); + } else { + timer_del(state->buffered_io_timer); + qemu_xen_evtchn_unmask(state->xce_handle, state->bufioreq_local_po= rt); + } +} + +static void cpu_handle_ioreq(void *opaque) +{ + XenIOState *state =3D opaque; + ioreq_t *req =3D cpu_get_ioreq(state); + + handle_buffered_iopage(state); + if (req) { + ioreq_t copy =3D *req; + + xen_rmb(); + handle_ioreq(state, ©); + req->data =3D copy.data; + + if (req->state !=3D STATE_IOREQ_INPROCESS) { + fprintf(stderr, "Badness in I/O request ... not in service?!: " + "%x, ptr: %x, port: %"PRIx64", " + "data: %"PRIx64", count: %u, size: %u, type: %u\n", + req->state, req->data_is_ptr, req->addr, + req->data, req->count, req->size, req->type); + destroy_hvm_domain(false); + return; + } + + xen_wmb(); /* Update ioreq contents /then/ update state. */ + + /* + * We do this before we send the response so that the tools + * have the opportunity to pick up on the reset before the + * guest resumes and does a hlt with interrupts disabled which + * causes Xen to powerdown the domain. + */ + if (runstate_is_running()) { + ShutdownCause request; + + if (qemu_shutdown_requested_get()) { + destroy_hvm_domain(false); + } + request =3D qemu_reset_requested_get(); + if (request) { + qemu_system_reset(request); + destroy_hvm_domain(true); + } + } + + req->state =3D STATE_IORESP_READY; + qemu_xen_evtchn_notify(state->xce_handle, + state->ioreq_local_port[state->send_vcpu]); + } +} + +static void xen_main_loop_prepare(XenIOState *state) +{ + int evtchn_fd =3D -1; + + if (state->xce_handle !=3D NULL) { + evtchn_fd =3D qemu_xen_evtchn_fd(state->xce_handle); + } + + state->buffered_io_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, handle_= buffered_io, + state); + + if (evtchn_fd !=3D -1) { + CPUState *cpu_state; + + DPRINTF("%s: Init cpu_by_vcpu_id\n", __func__); + CPU_FOREACH(cpu_state) { + DPRINTF("%s: cpu_by_vcpu_id[%d]=3D%p\n", + __func__, cpu_state->cpu_index, cpu_state); + state->cpu_by_vcpu_id[cpu_state->cpu_index] =3D cpu_state; + } + qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state); + } +} + + +void xen_hvm_change_state_handler(void *opaque, bool running, + RunState rstate) +{ + XenIOState *state =3D opaque; + + if (running) { + xen_main_loop_prepare(state); + } + + xen_set_ioreq_server_state(xen_domid, + state->ioservid, + (rstate =3D=3D RUN_STATE_RUNNING)); +} + +void xen_exit_notifier(Notifier *n, void *data) +{ + XenIOState *state =3D container_of(n, XenIOState, exit); + + xen_destroy_ioreq_server(xen_domid, state->ioservid); + if (state->fres !=3D NULL) { + xenforeignmemory_unmap_resource(xen_fmem, state->fres); + } + + qemu_xen_evtchn_close(state->xce_handle); + xs_daemon_close(state->xenstore); +} + +static int xen_map_ioreq_server(XenIOState *state) +{ + void *addr =3D NULL; + xen_pfn_t ioreq_pfn; + xen_pfn_t bufioreq_pfn; + evtchn_port_t bufioreq_evtchn; + int rc; + + /* + * Attempt to map using the resource API and fall back to normal + * foreign mapping if this is not supported. + */ + QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_bufioreq !=3D 0); + QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_ioreq(0) !=3D 1); + state->fres =3D xenforeignmemory_map_resource(xen_fmem, xen_domid, + XENMEM_resource_ioreq_server, + state->ioservid, 0, 2, + &addr, + PROT_READ | PROT_WRITE, 0); + if (state->fres !=3D NULL) { + trace_xen_map_resource_ioreq(state->ioservid, addr); + state->buffered_io_page =3D addr; + state->shared_page =3D addr + XC_PAGE_SIZE; + } else if (errno !=3D EOPNOTSUPP) { + error_report("failed to map ioreq server resources: error %d handl= e=3D%p", + errno, xen_xc); + return -1; + } + + rc =3D xen_get_ioreq_server_info(xen_domid, state->ioservid, + (state->shared_page =3D=3D NULL) ? + &ioreq_pfn : NULL, + (state->buffered_io_page =3D=3D NULL) ? + &bufioreq_pfn : NULL, + &bufioreq_evtchn); + if (rc < 0) { + error_report("failed to get ioreq server info: error %d handle=3D%= p", + errno, xen_xc); + return rc; + } + + if (state->shared_page =3D=3D NULL) { + DPRINTF("shared page at pfn %lx\n", ioreq_pfn); + + state->shared_page =3D xenforeignmemory_map(xen_fmem, xen_domid, + PROT_READ | PROT_WRITE, + 1, &ioreq_pfn, NULL); + if (state->shared_page =3D=3D NULL) { + error_report("map shared IO page returned error %d handle=3D%p= ", + errno, xen_xc); + } + } + + if (state->buffered_io_page =3D=3D NULL) { + DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn); + + state->buffered_io_page =3D xenforeignmemory_map(xen_fmem, xen_dom= id, + PROT_READ | PROT_WR= ITE, + 1, &bufioreq_pfn, + NULL); + if (state->buffered_io_page =3D=3D NULL) { + error_report("map buffered IO page returned error %d", errno); + return -1; + } + } + + if (state->shared_page =3D=3D NULL || state->buffered_io_page =3D=3D N= ULL) { + return -1; + } + + DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn); + + state->bufioreq_remote_port =3D bufioreq_evtchn; + + return 0; +} + +void destroy_hvm_domain(bool reboot) +{ + xc_interface *xc_handle; + int sts; + int rc; + + unsigned int reason =3D reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; + + if (xen_dmod) { + rc =3D xendevicemodel_shutdown(xen_dmod, xen_domid, reason); + if (!rc) { + return; + } + if (errno !=3D ENOTTY /* old Xen */) { + perror("xendevicemodel_shutdown failed"); + } + /* well, try the old thing then */ + } + + xc_handle =3D xc_interface_open(0, 0, 0); + if (xc_handle =3D=3D NULL) { + fprintf(stderr, "Cannot acquire xenctrl handle\n"); + } else { + sts =3D xc_domain_shutdown(xc_handle, xen_domid, reason); + if (sts !=3D 0) { + fprintf(stderr, "xc_domain_shutdown failed to issue %s, " + "sts %d, %s\n", reboot ? "reboot" : "poweroff", + sts, strerror(errno)); + } else { + fprintf(stderr, "Issued domain %d %s\n", xen_domid, + reboot ? "reboot" : "poweroff"); + } + xc_interface_close(xc_handle); + } +} + +void xen_shutdown_fatal_error(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "Will destroy the domain.\n"); + /* destroy the domain */ + qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); +} + +void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, + MemoryListener xen_memory_listener) +{ + int i, rc; + + setup_xen_backend_ops(); + + state->xce_handle =3D qemu_xen_evtchn_open(); + if (state->xce_handle =3D=3D NULL) { + perror("xen: event channel open"); + goto err; + } + + state->xenstore =3D xs_daemon_open(); + if (state->xenstore =3D=3D NULL) { + perror("xen: xenstore open"); + goto err; + } + + xen_create_ioreq_server(xen_domid, &state->ioservid); + + state->exit.notify =3D xen_exit_notifier; + qemu_add_exit_notifier(&state->exit); + + /* + * Register wake-up support in QMP query-current-machine API + */ + qemu_register_wakeup_support(); + + rc =3D xen_map_ioreq_server(state); + if (rc < 0) { + goto err; + } + + /* Note: cpus is empty at this point in init */ + state->cpu_by_vcpu_id =3D g_malloc0(max_cpus * sizeof(CPUState *)); + + rc =3D xen_set_ioreq_server_state(xen_domid, state->ioservid, true); + if (rc < 0) { + error_report("failed to enable ioreq server info: error %d handle= =3D%p", + errno, xen_xc); + goto err; + } + + state->ioreq_local_port =3D g_malloc0(max_cpus * sizeof (evtchn_port_t= )); + + /* FIXME: how about if we overflow the page here? */ + for (i =3D 0; i < max_cpus; i++) { + rc =3D qemu_xen_evtchn_bind_interdomain(state->xce_handle, xen_dom= id, + xen_vcpu_eport(state->shared= _page, + i)); + if (rc =3D=3D -1) { + error_report("shared evtchn %d bind error %d", i, errno); + goto err; + } + state->ioreq_local_port[i] =3D rc; + } + + rc =3D qemu_xen_evtchn_bind_interdomain(state->xce_handle, xen_domid, + state->bufioreq_remote_port); + if (rc =3D=3D -1) { + error_report("buffered evtchn bind error %d", errno); + goto err; + } + state->bufioreq_local_port =3D rc; + + /* Init RAM management */ +#ifdef XEN_COMPAT_PHYSMAP + xen_map_cache_init(xen_phys_offset_to_gaddr, state); +#else + xen_map_cache_init(NULL, state); +#endif + + qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state); + + state->memory_listener =3D xen_memory_listener; + memory_listener_register(&state->memory_listener, &address_space_memor= y); + + state->io_listener =3D xen_io_listener; + memory_listener_register(&state->io_listener, &address_space_io); + + state->device_listener =3D xen_device_listener; + QLIST_INIT(&state->dev_list); + device_listener_register(&state->device_listener); + + xen_bus_init(); + + xen_be_init(); + + return; +err: + error_report("xen hardware virtual machine initialisation failed"); + exit(1); +} diff --git a/include/hw/i386/xen_arch_hvm.h b/include/hw/i386/xen_arch_hvm.h new file mode 100644 index 0000000000..1000f8f543 --- /dev/null +++ b/include/hw/i386/xen_arch_hvm.h @@ -0,0 +1,11 @@ +#ifndef HW_XEN_ARCH_I386_HVM_H +#define HW_XEN_ARCH_I386_HVM_H + +#include +#include "hw/xen/xen-hvm-common.h" + +void arch_handle_ioreq(XenIOState *state, ioreq_t *req); +void arch_xen_set_memory(XenIOState *state, + MemoryRegionSection *section, + bool add); +#endif diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h new file mode 100644 index 0000000000..26674648d8 --- /dev/null +++ b/include/hw/xen/arch_hvm.h @@ -0,0 +1,3 @@ +#if defined(TARGET_I386) || defined(TARGET_X86_64) +#include "hw/i386/xen_arch_hvm.h" +#endif diff --git a/include/hw/xen/xen-hvm-common.h b/include/hw/xen/xen-hvm-commo= n.h new file mode 100644 index 0000000000..f9559e2885 --- /dev/null +++ b/include/hw/xen/xen-hvm-common.h @@ -0,0 +1,99 @@ +#ifndef HW_XEN_HVM_COMMON_H +#define HW_XEN_HVM_COMMON_H + +#include "qemu/osdep.h" +#include "qemu/units.h" + +#include "cpu.h" +#include "hw/pci/pci.h" +#include "hw/hw.h" +#include "hw/xen/xen_native.h" +#include "hw/xen/xen-legacy-backend.h" +#include "sysemu/runstate.h" +#include "sysemu/sysemu.h" +#include "sysemu/xen.h" +#include "sysemu/xen-mapcache.h" +#include "qemu/error-report.h" +#include + +extern MemoryRegion ram_memory; +extern MemoryListener xen_io_listener; +extern DeviceListener xen_device_listener; + +//#define DEBUG_XEN_HVM + +#ifdef DEBUG_XEN_HVM +#define DPRINTF(fmt, ...) \ + do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) \ + do { } while (0) +#endif + +static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i) +{ + return shared_page->vcpu_ioreq[i].vp_eport; +} +static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vc= pu) +{ + return &shared_page->vcpu_ioreq[vcpu]; +} + +#define BUFFER_IO_MAX_DELAY 100 + +typedef struct XenPhysmap { + hwaddr start_addr; + ram_addr_t size; + const char *name; + hwaddr phys_offset; + + QLIST_ENTRY(XenPhysmap) list; +} XenPhysmap; + +typedef struct XenPciDevice { + PCIDevice *pci_dev; + uint32_t sbdf; + QLIST_ENTRY(XenPciDevice) entry; +} XenPciDevice; + +typedef struct XenIOState { + ioservid_t ioservid; + shared_iopage_t *shared_page; + buffered_iopage_t *buffered_io_page; + xenforeignmemory_resource_handle *fres; + QEMUTimer *buffered_io_timer; + CPUState **cpu_by_vcpu_id; + /* the evtchn port for polling the notification, */ + evtchn_port_t *ioreq_local_port; + /* evtchn remote and local ports for buffered io */ + evtchn_port_t bufioreq_remote_port; + evtchn_port_t bufioreq_local_port; + /* the evtchn fd for polling */ + xenevtchn_handle *xce_handle; + /* which vcpu we are serving */ + int send_vcpu; + + struct xs_handle *xenstore; + MemoryListener memory_listener; + MemoryListener io_listener; + QLIST_HEAD(, XenPciDevice) dev_list; + DeviceListener device_listener; + + Notifier exit; +} XenIOState; + +void xen_exit_notifier(Notifier *n, void *data); + +void xen_region_add(MemoryListener *listener, MemoryRegionSection *section= ); +void xen_region_del(MemoryListener *listener, MemoryRegionSection *section= ); +void xen_io_add(MemoryListener *listener, MemoryRegionSection *section); +void xen_io_del(MemoryListener *listener, MemoryRegionSection *section); +void xen_device_realize(DeviceListener *listener, DeviceState *dev); +void xen_device_unrealize(DeviceListener *listener, DeviceState *dev); + +void xen_hvm_change_state_handler(void *opaque, bool running, RunState rst= ate); +void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, + MemoryListener xen_memory_listener); + +void cpu_ioreq_pio(ioreq_t *req); +#endif /* HW_XEN_HVM_COMMON_H */ --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787541; cv=pass; d=zohomail.com; s=zohoarc; b=iWErD3YBijQKYREEUwEbuzZ2QowTGHO8rN0aCfyD1YXfWHfXfF1kwm+Zv7iG3066ew0CfLRYT6jnqNhNaC8RAbDdaFDPTTCTVrziD5U8CNhgB241xp9vquIwebiFmR/he635ljZ+JSc4+Pshci1fV1jyltidA3FyTJW2SCsL6WQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787541; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QhReVhB10vpU72bAY3AMOPyk1Ul54IekP2dQt2HzTMI=; b=NWYdpOa7BCNgg4v7n/c/LLVzuKgE0Rk886kXE3HNKfIayntl8TKE0fm4p3zK3BUB5SjjfT7omjuf3ti1BZyuST878CQ7redpy4drQosKWv6bOfecwpL/BuueJc5JwFboOyXWkwUP+eGRWXW9/2ghDX2DSdILmdvFbRg24Ej22rk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1686787541506587.370175779782; Wed, 14 Jun 2023 17:05:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.549310.857793 (Exim 4.92) (envelope-from ) id 1q9aUJ-0007Yt-Fj; Thu, 15 Jun 2023 00:05:19 +0000 Received: by outflank-mailman (output) from mailman id 549310.857793; Thu, 15 Jun 2023 00:05:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUJ-0007Vk-89; Thu, 15 Jun 2023 00:05:19 +0000 Received: by outflank-mailman (input) for mailman id 549310; Thu, 15 Jun 2023 00:05:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUH-0006qD-JW for xen-devel@lists.xenproject.org; Thu, 15 Jun 2023 00:05:17 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20626.outbound.protection.outlook.com [2a01:111:f400:7e83::626]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4d8b54d1-0b10-11ee-8611-37d641c3527e; Thu, 15 Jun 2023 02:05:15 +0200 (CEST) Received: from MW4PR03CA0038.namprd03.prod.outlook.com (2603:10b6:303:8e::13) by PH0PR12MB5645.namprd12.prod.outlook.com (2603:10b6:510:140::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Thu, 15 Jun 2023 00:05:12 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::49) by MW4PR03CA0038.outlook.office365.com (2603:10b6:303:8e::13) 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:05:11 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.25 via Frontend Transport; Thu, 15 Jun 2023 00:05:11 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) 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:05:00 -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:40 -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:40 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4d8b54d1-0b10-11ee-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fWqJWv4CJuvpySqo0+6Ebe1H6T3d+C6DMRre9jFtCXSto7Hd3SI+u0wb+MLwUVoRzgc7v4bNoDWTHM4QYOCNs9prXzDsVFXb32fYfVx3k9F3R3r5RMihQxYj8J6tY1lEN4pzkUm/x8nFgxWqYDez8qgub7LRm9WAVbZhjTbylMPYkr/TnXKJ+7aclpEVzf+EdssF2trkmIY7FA9m9C+zw6yBikq7hVK6h14RF1akeG/52ODnbcTqX6ezfL2wXq/2UM+mB1SqV9rK21/e4PtfvtTqLNBDYJfDAt4h9ppR84c+G5h0Vfe3jFco1VYQzr6c9DCB9Zl8p+SjYflhLCPJmw== 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=QhReVhB10vpU72bAY3AMOPyk1Ul54IekP2dQt2HzTMI=; b=Nz4kkFSwwsLVCRW3zDlqm4Cnidp8n8V8MuFQEiYZ/zOk1ARL/ELyNrxqD4LuqbaHZNrGWdghS1dVjWKFmNnam+l3eIgoNch/l+sJBC++mR4V5/ezjM6mRmXrUPWM7paYosym6jykMyGvBDn9KNYmddKl9KRXYDMSZ2PCVmWkfpAB8b8x+RUwXjqu9UtyDaQdrC0nh1ID1M6CDdHNbv5U+nQdTib57xtSlFURLKeV1ZOTlaJ6HiGTKX/hoFzv7CBZU7bS07DV4QxWbtPldA/ojM8aUd/hDP+/epxgplnERMEPH5N3vEyxjFRJkjddu3YUG/0TeLi53evvcnlWY1fwHg== 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=QhReVhB10vpU72bAY3AMOPyk1Ul54IekP2dQt2HzTMI=; b=VYdUPU3selH8INXbaj8Mm0878UfiuSvzh1bvT6ztD8aum/MmC2Po+mtPqEfozENbLE3UF5KuZFU0TI6C8DQNftvZrsoh/D1GR2pcz5ENgkraDWqD/busZ1yZH+drSVAD5tMax3mSgBFqfaVMCI5afHM8VfNiFKTN657iVvu4aRo= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Stefano Stabellini , Vikram Garhwal , Anthony Perard , Paul Durrant , "open list:X86 Xen CPUs" Subject: [QEMU][PATCH v8 05/11] include/hw/xen/xen_common: return error from xen_create_ioreq_server Date: Wed, 14 Jun 2023 17:03:33 -0700 Message-ID: <20230615000340.1135-6-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: CO1NAM11FT051:EE_|PH0PR12MB5645:EE_ X-MS-Office365-Filtering-Correlation-Id: e3521574-0481-4543-9174-08db6d342fec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wi+CBZe7JJw8ZmKTtcBgPGte0fnVfCFVBoBMzibtTeM5v4zrD+U7AvUUXHmjwAg1nBIRKDPwBXr+PKzRyvowauS17v8BkN/IsxDYME+wjG4VL7tg36DH10cjTa1jC/rLGI4P/P/u6+kLHhsdxUnOESygvnzQndWaEaJTdVoFSuRylZEPRWaXUQG+bHOinkZxEYdbtXET+Nn1BpqhW6XwnRYTFSO8LRp9GWaaFnCXMppO9JBKh9oxF/2jbOUPY2Y7l9YcIDBRhIzVCwXnwdIvwS0WQIe/833dP0K7WtIs9d7CN1r+9zBMNq5+FTYT5AjrmQWkNpWSyBzztwUo7isEtLU8EMhnVz+5KRVA1AOjHO3dZcwkL91mjFob/IIuQvIt5RCjb5FJc0wfBfovPpb9bgkKtZPo0dSCSCr7dBb4Xk3bHq76+27idyGCdMPIk1whsK4ZdXT7Y5yq6LEvImDRSIPcwarXsHQZGjZ1+gG/DWDubzhwphSZ24YWLl/CuSH39X1teCZMKSt5QMrfaiVwr5h79AA2ZQYGLyVJnZZMb7Y2nOP/7wtHejn6HUS6e79kRxDiG9a+2sFMu6RbghJj8yh5vuzsUuakRNMawRqCZQPYSEiARyremTfzEqT0ROUBERx/h9nTUqxEYTqLBLlqmXWe5vKnj0pahx78JwoxSB5FM98OsoXqT/K5ixjOg7N7f+HLrfSJxPfzAZilKWFloAeylEkjL92wYZevA3Tsw60uqW5VdhFH5TJO/l6pRN2KJrCQ9fi06XPcEAlqTndmyg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(5660300002)(8936002)(2906002)(8676002)(70586007)(70206006)(44832011)(54906003)(6666004)(4326008)(26005)(1076003)(41300700001)(316002)(6916009)(186003)(36860700001)(82740400003)(356005)(426003)(336012)(47076005)(83380400001)(2616005)(40460700003)(478600001)(40480700001)(82310400005)(36756003)(86362001)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:11.1410 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3521574-0481-4543-9174-08db6d342fec 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5645 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787543525100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini This is done to prepare for enabling xenpv support for ARM architecture. On ARM it is possible to have a functioning xenpv machine with only the PV backends and no IOREQ server. If the IOREQ server creation fails, continue to the PV backends initialization. Signed-off-by: Stefano Stabellini Signed-off-by: Vikram Garhwal Reviewed-by: Stefano Stabellini Reviewed-by: Paul Durrant --- include/hw/xen/xen_native.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/hw/xen/xen_native.h b/include/hw/xen/xen_native.h index f11eb423e3..4dce905fde 100644 --- a/include/hw/xen/xen_native.h +++ b/include/hw/xen/xen_native.h @@ -463,8 +463,8 @@ static inline void xen_unmap_pcidev(domid_t dom, PCI_FUNC(pci_dev->devfn)= ); } =20 -static inline void xen_create_ioreq_server(domid_t dom, - ioservid_t *ioservid) +static inline int xen_create_ioreq_server(domid_t dom, + ioservid_t *ioservid) { int rc =3D xendevicemodel_create_ioreq_server(xen_dmod, dom, HVM_IOREQSRV_BUFIOREQ_ATOM= IC, @@ -472,12 +472,14 @@ static inline void xen_create_ioreq_server(domid_t do= m, =20 if (rc =3D=3D 0) { trace_xen_ioreq_server_create(*ioservid); - return; + return rc; } =20 *ioservid =3D 0; use_default_ioreq_server =3D true; trace_xen_default_ioreq_server(); + + return rc; } =20 static inline void xen_destroy_ioreq_server(domid_t dom, --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787538; cv=pass; d=zohomail.com; s=zohoarc; b=EWwf+hgOJd+w2M+4Y4D9XoZDisF+J4RviVLxdmcdgw5gnd/L/NP+ul/fC1BDtfxMjzxyVjHsoRmQUU9/A0kGD7lj2CPK5GmAssWV0/DvHhmm0lQQpmQOegDnmL8pmpXp6Es9qzOwlj5nVhAnKbZwvStlSFvBiILwXeYM4jSuQEk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787538; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZW0E+n9RRUnGndVzyavBgx17Uvpm/5a+kbmKjIpu9A4=; b=bG2LVPI3M64M9w5PwFoXnE6ApDzmYUd9JNLjGRbl0EYrF6ATqrPSTWCRqiENgbDDxQWhfiYF7tSTEHsRitIfQVHl1SyP/kgkFiZ9t0GJrd+SNsLwsrbYjQs9euBS98KMWpjCuT08JA0CVlnHy9+hOcuAGu53wNSEoWRbFxMk38U= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1686787538933987.8534365205779; Wed, 14 Jun 2023 17:05:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.549309.857787 (Exim 4.92) (envelope-from ) id 1q9aUI-0007S1-Vl; Thu, 15 Jun 2023 00:05:18 +0000 Received: by outflank-mailman (output) from mailman id 549309.857787; Thu, 15 Jun 2023 00:05:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUI-0007Rs-RL; Thu, 15 Jun 2023 00:05:18 +0000 Received: by outflank-mailman (input) for mailman id 549309; Thu, 15 Jun 2023 00:05:16 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUG-0006qD-JM for xen-devel@lists.xenproject.org; Thu, 15 Jun 2023 00:05:16 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061d.outbound.protection.outlook.com [2a01:111:f400:fe5b::61d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4d49ac78-0b10-11ee-8611-37d641c3527e; Thu, 15 Jun 2023 02:05:14 +0200 (CEST) Received: from MW4PR04CA0297.namprd04.prod.outlook.com (2603:10b6:303:89::32) by LV8PR12MB9264.namprd12.prod.outlook.com (2603:10b6:408:1e8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.46; Thu, 15 Jun 2023 00:05:11 +0000 Received: from CO1NAM11FT080.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::64) by MW4PR04CA0297.outlook.office365.com (2603:10b6:303:89::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37 via Frontend Transport; Thu, 15 Jun 2023 00:05:11 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT080.mail.protection.outlook.com (10.13.174.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.23 via Frontend Transport; Thu, 15 Jun 2023 00:05:11 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) 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:05:00 -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:41 -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:41 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4d49ac78-0b10-11ee-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XOLOC3gYsY/XiNArEWvXiyIdGiPal329t9AhSeiX+QTYt2cbGR0Q4iNCuHQOYqNwy2XFS8JeuNTPTqBa1dyOjyx2iItOvCYykCvTTw+MurNR2eAVbOBpWFt58a+K0psX1eFHBlxi1g/DqtVhZ8HOxFoY4dLJCNPwbTVjXp7Z9EAn8vL0oD7SwYSF06TCOFNHa+NAT/3OVMhN0hZCRO5/W0S+C2BgmJjQjaUXWcE+TJg71jcDjaJNlSyrij0szwfyoIy4oNRAzS/AIjY4zoE0yewC2vVr3ZGQeHjlW2ayKjjAyM+Bt45APaRMIlAACSuOrHbz1gsG02Qx9aLseFLv/w== 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=ZW0E+n9RRUnGndVzyavBgx17Uvpm/5a+kbmKjIpu9A4=; b=agxGqRZl9xowsSaWFFt+qfUL47SDNnrm36X/j1QKbO3CGqQgrAtE0kUXwzwBP2OBDA+0iTKUYfaL4lh0aCKeDiZSEw5nVAn1Jata4GppUgxmdBGMI7RX0L0jg+56NL+HazJbBdIgx3glkuQj5BXx4pARImgU69icy+35M/is6ukAUDkMFZZBEDbU42ZR9slKBXZTWS7B5gKhMkDuFlDJ9B7RUAmZm5trOMCopfgBWqEPLXQXloWMqpmBQZzu1kecZ3pBYF9rc3z7IGZ1T6oHwg/9fFQrhRGcxl3cVUmorOfgDPou4kwvkIlhZiy7zwzaNbgwfJ5Pg5BCESaEQZRKog== 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=ZW0E+n9RRUnGndVzyavBgx17Uvpm/5a+kbmKjIpu9A4=; b=KwfEWYE1RYj7Hn1oxRyblfisG+7Nj90WCd7F/fD+K1uwMZpHNGiRcgg4ehotdsNPt+o7C6zNzi4jCuQbxou01ZYtOIlmbh2gHXUN8VWo9rGhrgbZQu2evHYXiCdeWtVsSld9BN/PcHmNKYeJg6Eb6inBXWaT3Wih/BxsX9r6Kvs= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Stefano Stabellini , Vikram Garhwal , Anthony Perard , Paul Durrant , "open list:X86 Xen CPUs" Subject: [QEMU][PATCH v8 06/11] hw/xen/xen-hvm-common: skip ioreq creation on ioreq registration failure Date: Wed, 14 Jun 2023 17:03:34 -0700 Message-ID: <20230615000340.1135-7-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: CO1NAM11FT080:EE_|LV8PR12MB9264:EE_ X-MS-Office365-Filtering-Correlation-Id: f75a5b45-9d96-46cb-1c35-08db6d342ff5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v5IT0s1Pcx8GVvmnrEedCYZMp0elMXcdr+dsGpoMBOfiTkCJGcVVsBRled1m1gylbLXKBsdOBOqLdRui0Dfmxu9tZBld2BuO04JiKkiCdE1ApzK5lJVTcOZ6baP6njeAkU8zcyRFWnrsQ/T3Pa2DvQa0Fbd2gYOR21oLYx9jlx32GFU4LbB+lroyyssBcWv9K0dTIDdZNqpByzf8Pz8U/iR1YG3m8vF3H3yTF9OdRW0YgrJlWnGpj0iJSTJEOwA24JjFlvNFEzbmP/PK9lEu32n25u+ynultWOKJrsR5dkdyMBVcRcCIbPQy3VjAWlDPDQZ7DXc6Cnljs0Tt+B1FtLhhkPtFWTgtaQa7MdgpQBHDvHBey8MHJ6bKTv9EwsOqqiu7bOiuEzoWLfUrlkf5gkyAmXTmqTB3/vOfUt4tQP6dk8lnnSghGOsPaXmOuQt5NQBTRtfX5rlMhVlnHkl5dnumLldUCzd1XRAPj61NvDXVfIQDFMBgWLzPOjuMbWp/Cq57MgFY2TKUDV2+RLCWyAAECizdTsEiLLtrWh/4A+n97gA+bXXq5szfhLM40gCa9AEOwJjOlcxZ3r3gpJlKniC1aMXMt6kylzsN8keDnJdzA+BOo+GefULzJ5iL32ldShPdoakm3U8zzhIFfiFM7WK75Z/VIO9/EkKtkd3/BfYnlYokNEQgR6HyFMIVlbDFUAvdABnq8KkCicsgO7ePMXYa+ANXAfqNO9q3VfvqrbAzJ9FEthz5tc/knyJDE+PUrEchaL1THqLZ9t0wYIp9Kg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(396003)(39860400002)(136003)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(54906003)(6666004)(70206006)(70586007)(316002)(36860700001)(478600001)(4326008)(6916009)(36756003)(86362001)(2616005)(426003)(1076003)(83380400001)(26005)(186003)(336012)(5660300002)(8936002)(8676002)(41300700001)(2906002)(82310400005)(44832011)(40480700001)(81166007)(82740400003)(356005)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:11.1814 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f75a5b45-9d96-46cb-1c35-08db6d342ff5 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT080.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9264 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787539899100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini On ARM it is possible to have a functioning xenpv machine with only the PV backends and no IOREQ server. If the IOREQ server creation fails continue to the PV backends initialization. Also, moved the IOREQ registration and mapping subroutine to new function xen_do_ioreq_register(). Signed-off-by: Stefano Stabellini Signed-off-by: Vikram Garhwal Reviewed-by: Stefano Stabellini Reviewed-by: Paul Durrant --- hw/xen/xen-hvm-common.c | 57 +++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index a31b067404..cb82f4b83d 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -764,27 +764,12 @@ void xen_shutdown_fatal_error(const char *fmt, ...) qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); } =20 -void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, - MemoryListener xen_memory_listener) +static void xen_do_ioreq_register(XenIOState *state, + unsigned int max_cpus, + MemoryListener xen_memory_liste= ner) { int i, rc; =20 - setup_xen_backend_ops(); - - state->xce_handle =3D qemu_xen_evtchn_open(); - if (state->xce_handle =3D=3D NULL) { - perror("xen: event channel open"); - goto err; - } - - state->xenstore =3D xs_daemon_open(); - if (state->xenstore =3D=3D NULL) { - perror("xen: xenstore open"); - goto err; - } - - xen_create_ioreq_server(xen_domid, &state->ioservid); - state->exit.notify =3D xen_exit_notifier; qemu_add_exit_notifier(&state->exit); =20 @@ -849,12 +834,46 @@ void xen_register_ioreq(XenIOState *state, unsigned i= nt max_cpus, QLIST_INIT(&state->dev_list); device_listener_register(&state->device_listener); =20 + return; + +err: + error_report("xen hardware virtual machine initialisation failed"); + exit(1); +} + +void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, + MemoryListener xen_memory_listener) +{ + int rc; + + setup_xen_backend_ops(); + + state->xce_handle =3D qemu_xen_evtchn_open(); + if (state->xce_handle =3D=3D NULL) { + perror("xen: event channel open"); + goto err; + } + + state->xenstore =3D xs_daemon_open(); + if (state->xenstore =3D=3D NULL) { + perror("xen: xenstore open"); + goto err; + } + + rc =3D xen_create_ioreq_server(xen_domid, &state->ioservid); + if (!rc) { + xen_do_ioreq_register(state, max_cpus, xen_memory_listener); + } else { + warn_report("xen: failed to create ioreq server"); + } + xen_bus_init(); =20 xen_be_init(); =20 return; + err: - error_report("xen hardware virtual machine initialisation failed"); + error_report("xen hardware virtual machine backend registration failed= "); exit(1); } --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787536; cv=pass; d=zohomail.com; s=zohoarc; b=YtgiQldqiH1Mas6en4addksH/Nz1q0yorufTgUuZk796Bog91lsEv19ewcWkWAz7El4tCbP1S7lqAuk/uBpol7/QaWVqSjWxHU5Uy0JMmCl9n/ItPYhyklEDB60ateB9YQnslE7AMFZVl48KoA/Z/UU5VYn8J2sA5y9+MriX2ig= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787536; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mOsqWHq5VHxUgGsBfaYThNjh0r5g1aFE14BtltHtrOE=; b=Rr4Qjt2e6CR3TzUybfmpZ0l5UkbCqP3d7lGTAmU5C3ysh7MPBqpEf8JZyP6APQeMX0FD2rPblL+B4M5/f4XQ10UZEIsA3B3SOv+70MvTkN6zA23rST1Umin7BeASx4+ljEAI/xQ1iRLDux9L1IccZFPXrFa1ozV3qaF/w6rZkd8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1686787536488190.7547853954061; Wed, 14 Jun 2023 17:05:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.549308.857777 (Exim 4.92) (envelope-from ) id 1q9aUH-0007A3-Lx; Thu, 15 Jun 2023 00:05:17 +0000 Received: by outflank-mailman (output) from mailman id 549308.857777; Thu, 15 Jun 2023 00:05:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUH-00079t-HH; Thu, 15 Jun 2023 00:05:17 +0000 Received: by outflank-mailman (input) for mailman id 549308; Thu, 15 Jun 2023 00:05:16 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUG-0006Ty-5F for xen-devel@lists.xenproject.org; Thu, 15 Jun 2023 00:05:16 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061e.outbound.protection.outlook.com [2a01:111:f400:7e8a::61e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4d7dce9b-0b10-11ee-b232-6b7b168915f2; Thu, 15 Jun 2023 02:05:15 +0200 (CEST) Received: from MW4PR04CA0304.namprd04.prod.outlook.com (2603:10b6:303:82::9) by SA1PR12MB8721.namprd12.prod.outlook.com (2603:10b6:806:38d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Thu, 15 Jun 2023 00:05:11 +0000 Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::d5) by MW4PR04CA0304.outlook.office365.com (2603:10b6:303:82::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37 via Frontend Transport; Thu, 15 Jun 2023 00:05:11 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT022.mail.protection.outlook.com (10.13.175.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.25 via Frontend Transport; Thu, 15 Jun 2023 00:05:11 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) 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:05:00 -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:42 -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:42 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4d7dce9b-0b10-11ee-b232-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jrIvBp3JGh6ZSlnwfU6e0PNgqqUzgE1V8Yp/PrednBbwjJCneUxlTgkTtKNIhaSYeVd5wBJIwzgfzv6+mv4rfOLQOjhpHK9DKH5CFYju9Rc2P1EiszIG+7WuxkNvd67AS3/gRRGLsAnXd43sCbPUVIW9Styq1bRUqZ+cOCRaR01uWvmJnhpbKgiHQNN1j4pckgk209CPlPop9B1q0lO7x3lPloI7gcvPQQ61QHUuSVdfOGGPQ0yNo2qc1ZG3xJ5wBbX2BM9Hj+InxG1udov75a0WXg26FxiFmVqQ2nFtyoH6n+ktsUVTWPw9+RJBiyAI/+Ofj0E4UiM+2GPrZIbXzw== 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=mOsqWHq5VHxUgGsBfaYThNjh0r5g1aFE14BtltHtrOE=; b=YKV/OBLphnLlthGUJSPvWkVFm5g/GDy/BvK/pXHcSHkFeBRCIggbbSR4IuL3ZdNoyd6zMV6Gdd2yDPOgihattlf+aPzPrX9yxrbfb+HmVOIb6ASxNdZiaZnAbl0YbKNFoFuWg5FJrgIE5KNoucbJZuqC2ggaRB2PLnlPZgLaziqkBEQPP3tq35m+Rji/uSrELEEtsj0EBKGpJFejw2olSZeiAW8Y2qDKjOYg4Rur9idVivNfg0LEeh/hGL7EYD96912+eCmzZHHT/cTzA9W6L1glm/Ixq5Pan9Z8BW6HJogujpzHDR1e1pO8NwOCGBncEkw23+yeLOCzaXFPHpsdxA== 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=mOsqWHq5VHxUgGsBfaYThNjh0r5g1aFE14BtltHtrOE=; b=OVVRWQbU5speFy+0MY5tRyLvhm8bmi8+OqWRTV7C4WIIKGNhmFtje5DmCRF99MHMiykhxlTHUpZAurvbeEc6Gw+E5xkY01mD5NyEgxeXu+R7dqA0hZwh5KcKGwofwDiJzU59thHOG4fhRznf0ys6cGkZ7ihAD59I+P8MULMZtqI= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Anthony Perard , Paul Durrant , "open list:X86 Xen CPUs" Subject: [QEMU][PATCH v8 07/11] hw/xen/xen-hvm-common: Use g_new and error_report Date: Wed, 14 Jun 2023 17:03:35 -0700 Message-ID: <20230615000340.1135-8-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: CO1NAM11FT022:EE_|SA1PR12MB8721:EE_ X-MS-Office365-Filtering-Correlation-Id: b88cc8d6-dd8c-4332-2b78-08db6d34301d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZvG/6GVMwnih8VNIYEZjOZRgz7xXzBE6C5wTwQMYcy8G0gNNw15QgY6ejG+bnotPF5K6ZXcf56+pGzaKCGQ+cmi8UzqI7XqNZOQP4Fobv8hzyij6LnJRm4yC1j17UrhHiTbHM8mKvj1A8a4MUjdWToN53AZHbXBkVkR+374LEmBcQIAr9A+Bb0SPpZlgWS5197rDy+5DlOfmNxSf1FjBCp5+/NOA3CYFMc5heX+hmEy4Ztxvl5ms5LAw/P8oA0yNUPqP4jZzpTuHNiELD32VPJ0nc/eizIRaOSFdf+qlxhuAr2CiewDrb7IlpVNYlKxV1Eh1ZeEbfA+8CJJmExY6ISDU8XLIefoALGHrNrtQXYlnjFSrOzksdQs6NwdfC1Svs7/LQf01Fv0l4rhbgtTLj20kgg766FRnXFQcBSGf6EdnDG5iWdpH8VSOLzRhnNLOncGaJD2OFtF93BAliUVqtjjjLr5hw8gp9laiexR4pOFCIa54W6yo4WWroCQDhFcrn0yhsoLfZt8AF2U43R5NRuh79+igS/+JTnDT6+etmQahyUu9Z7bWg70LEhzM5x8RHUbQL0M9u0Icaj6WpiRR9FWmbTitW7H4cnSPAd6atvps8AXZap+NqdOa8mp11LXbnlAbV6wM2id62v8lsXwZJRuaS1Rp0ZTLjFMY0bij/2gn4kOulRx6jWYozPeRLZg2JDkx3XOLjsBk8CpU6zdD4OfxVmx36t4CPIRyG1EakZtJbbSh97CCmMjvLKBhywvFodF6gxqrbpxJ/Y/GwUjPLA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199021)(40470700004)(36840700001)(46966006)(26005)(1076003)(47076005)(81166007)(40480700001)(356005)(82740400003)(41300700001)(316002)(478600001)(6916009)(4326008)(36860700001)(70206006)(70586007)(6666004)(186003)(2616005)(8936002)(2906002)(36756003)(8676002)(86362001)(5660300002)(44832011)(83380400001)(40460700003)(54906003)(336012)(426003)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:11.4596 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b88cc8d6-dd8c-4332-2b78-08db6d34301d 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8721 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787537338100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace g_malloc with g_new and perror with error_report. Signed-off-by: Vikram Garhwal Reviewed-by: Stefano Stabellini Reviewed-by: Paul Durrant --- hw/xen/xen-hvm-common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index cb82f4b83d..42339c96bd 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -33,7 +33,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, = MemoryRegion *mr, trace_xen_ram_alloc(ram_addr, size); =20 nr_pfn =3D size >> TARGET_PAGE_BITS; - pfn_list =3D g_malloc(sizeof (*pfn_list) * nr_pfn); + pfn_list =3D g_new(xen_pfn_t, nr_pfn); =20 for (i =3D 0; i < nr_pfn; i++) { pfn_list[i] =3D (ram_addr >> TARGET_PAGE_BITS) + i; @@ -730,7 +730,7 @@ void destroy_hvm_domain(bool reboot) return; } if (errno !=3D ENOTTY /* old Xen */) { - perror("xendevicemodel_shutdown failed"); + error_report("xendevicemodel_shutdown failed with error %d", e= rrno); } /* well, try the old thing then */ } @@ -784,7 +784,7 @@ static void xen_do_ioreq_register(XenIOState *state, } =20 /* Note: cpus is empty at this point in init */ - state->cpu_by_vcpu_id =3D g_malloc0(max_cpus * sizeof(CPUState *)); + state->cpu_by_vcpu_id =3D g_new0(CPUState *, max_cpus); =20 rc =3D xen_set_ioreq_server_state(xen_domid, state->ioservid, true); if (rc < 0) { @@ -793,7 +793,7 @@ static void xen_do_ioreq_register(XenIOState *state, goto err; } =20 - state->ioreq_local_port =3D g_malloc0(max_cpus * sizeof (evtchn_port_t= )); + state->ioreq_local_port =3D g_new0(evtchn_port_t, max_cpus); =20 /* FIXME: how about if we overflow the page here? */ for (i =3D 0; i < max_cpus; i++) { @@ -850,13 +850,13 @@ void xen_register_ioreq(XenIOState *state, unsigned i= nt max_cpus, =20 state->xce_handle =3D qemu_xen_evtchn_open(); if (state->xce_handle =3D=3D NULL) { - perror("xen: event channel open"); + error_report("xen: event channel open failed with error %d", errno= ); goto err; } =20 state->xenstore =3D xs_daemon_open(); if (state->xenstore =3D=3D NULL) { - perror("xen: xenstore open"); + error_report("xen: xenstore open failed with error %d", errno); goto err; } =20 --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787602; cv=pass; d=zohomail.com; s=zohoarc; b=gkjrBymLW3wKqVihsXzVodg/QVH/JeXvCkkGShGUaAR0FOW7sz6wsa1Nt//SGZKBXiP2fP7SJaR6QNQMszH/c+O51TTYQNFo6dR1262tn7lWTxH9uPhrOxHCNdaZgNeJmb7aotOkOecxcMnBEZmD2sW8Q9pg1LC0DsbzTR+5bKY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787602; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Tmh1dCxZuDVpegEWwz4s/MEsuA4Y58vGnEhunl81M9c=; b=c7rDexLUsV6DtlfK8BmI4hv/KhoJpXpLYtPy83g9Rri9jqvYczN0730qFs3fxrcZzoTGWQeKIlJiv7j4AtK53pcidMZYhRrnHFbPwxxdHZnmCHJx7hP4BinmDih/oK7YhMfCBgJBJm+X5iQnwPU+05MmElvzT/P1obA0Y28rV3Y= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168678760207160.635400785504544; Wed, 14 Jun 2023 17:06:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9aUX-0005yP-7i; Wed, 14 Jun 2023 20:05:35 -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 1q9aUJ-0005mh-AD for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:05:19 -0400 Received: from mail-dm6nam11on2060c.outbound.protection.outlook.com ([2a01:111:f400:7eaa::60c] helo=NAM11-DM6-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 1q9aUF-0006rF-9J for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:05:18 -0400 Received: from MW4PR04CA0281.namprd04.prod.outlook.com (2603:10b6:303:89::16) by PH7PR12MB5784.namprd12.prod.outlook.com (2603:10b6:510:1d3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Thu, 15 Jun 2023 00:05:12 +0000 Received: from CO1NAM11FT080.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::71) by MW4PR04CA0281.outlook.office365.com (2603:10b6:303:89::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37 via Frontend Transport; Thu, 15 Jun 2023 00:05:12 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT080.mail.protection.outlook.com (10.13.174.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.23 via Frontend Transport; Thu, 15 Jun 2023 00:05:11 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) 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:05:00 -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:43 -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:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lNPvy/iks6iDDr4imGqUF+i2+tyAc77KrUEOlJ75Y/przafgwx9TDJafoiZ5C8nCEG8YZyRSmCpb6z0UlfyH5fy7QAycVq7pU5zFsA1bTppB8RACr38sa+r5myT7ArueU6X6MKdigDaZu+tZ8MORllDnPsWI/GotsUZvMDoU4s738lCh0Z+4HcvFMfJ49YUgKzNuq8xcHixeZNY0Ix6R54YY/MgxscxZF8c5NaGCCgSNBHOJAMyh/F7weS+chbRKAmfTiqTphKW3LqTbvhZOASZNQzZs1TJLrAI+QfXPfHRkJkFqf5n/Djv54tJ7IPfLYmgZ2VwNjbWaJaGE/4YGPw== 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=Tmh1dCxZuDVpegEWwz4s/MEsuA4Y58vGnEhunl81M9c=; b=SHRolyw0499HPtGOQu4nePHXqadDnLOS8xqYa1I+2j3HK4Q3qz7NTZnJ055/OJSz+75SXZBtw1t11wSGQtrCRuVSKmB9mjXLAnv9r/Y7X/oZ1wvdNihvSKguJ9V7Mk6GZotKZFghXJtVB50nPiKcwP53rz4zRr4YkLiEMYfPXB6GvUCPuD8pFh2v6JPaNKRLM9UV7kRkztSmtPubXwbufIne4y1FnWdBt1ikSWDwhtJIL0HTGBJee1m1ljyvwh9gCvYa7uR/W+Dcb4gQsbFS9dOt/E5QxCuVpo28n97+fT1CSjyLbZFonnFfU3Nx1KY6FbZ2Ctzu/IAVEbrMc5/ySQ== 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=Tmh1dCxZuDVpegEWwz4s/MEsuA4Y58vGnEhunl81M9c=; b=lf0keIvGpAmmZwpUL0wj4XnEt0l8MWMtQrq7I3WZQwfseTT3NDJgSsZ7F4qG5/0ldzL6LWOkX1VdTA4Bw1mKAFA4vjFui2gtsuDlD+8EznSiSNbiqa0LkFuqgajBgwaopZAo4K1bTM8pItQMM3ogkCevC8/OxKAAfar0fg8KahA= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Stefano Stabellini , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [QEMU][PATCH v8 08/11] meson.build: do not set have_xen_pci_passthrough for aarch64 targets Date: Wed, 14 Jun 2023 17:03:36 -0700 Message-ID: <20230615000340.1135-9-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT080:EE_|PH7PR12MB5784:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a591755-6b9a-4550-a020-08db6d34305b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O0TQ7aBWRL+FNHMfzIIZgwWxvnkKn/+71GE0GEzLdoi/8LUcGvmX1ozN7CgI35fs6yRaL6emiBKIVbMXVaJ183/w/2rHWPMBUHMRk6ExM/Wrg2ktBwAoOf7EbimWiX67+SuZqQfrm8DOSLQh8ekz+WedVkyWVzpYqZwwozMzeS7tKae42DLtOQFJ4sR+Zzmx5vPDD8Gr67gFh59sitjIJ7ZBEB39xZybwfw4AY56pQsBZrCuisxR7MyJwrTGoWPtyhCiG5fHwffwyoSSi86xvBcu8pU8kQK0XVuVKH73oXvTTwotQg1vWPl1l73PXEPtSB8qU3FZVgOHDSjgL1QKS31310ScQaEVV6gerPgwWXn2mHXEk+WQ3gAyj/l/9rlaPFTIY+hOIaBuupobjH7lqNtgtiO0MCtKXUSAts4v1ol7sccfNODB/JOXEASINki2lgnI9McCB9fKurh997wV9rOicnRhcocu0vodePQtFcuG45UEMb8mYkcAn973pxjGhALy46adxo3oo/qaTm98nZQ/wp8bpiaSMOBn35iEwQCC+Iv5Se6+uLbbHD25LJl2FA95Ri7x1NHPg6lkJ4iP1qw4CM5d/Y34XFzIPYtw89F5xl58AKgXY4DcZk6unLifLyog8DQuNVYdk7FEUPFmMy3/OJ6lqH4Iou4YPaYgKcrOEQ1AX5Y/U4YR7iylFfVLntBLn+i00/ni54PJi6rpxPoxthJrVWhIbH7mQYY4do01Iq2ZcLcQEf850J4C5b6j/gxgxwJ1TFijE/dEx9pc2g== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199021)(36840700001)(40470700004)(46966006)(4744005)(8676002)(8936002)(82310400005)(2906002)(5660300002)(82740400003)(70586007)(70206006)(316002)(81166007)(4326008)(6916009)(356005)(36860700001)(47076005)(83380400001)(2616005)(54906003)(426003)(336012)(41300700001)(36756003)(478600001)(186003)(1076003)(26005)(40480700001)(6666004)(40460700003)(44832011)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:11.8532 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a591755-6b9a-4550-a020-08db6d34305b 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT080.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5784 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::60c; envelope-from=vikram.garhwal@amd.com; helo=NAM11-DM6-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787603592100003 From: Stefano Stabellini have_xen_pci_passthrough is only used for Xen x86 VMs. Signed-off-by: Stefano Stabellini Reviewed-by: Alex Benn=C3=A9e --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index 34306a6205..481865bfa9 100644 --- a/meson.build +++ b/meson.build @@ -1726,6 +1726,8 @@ have_xen_pci_passthrough =3D get_option('xen_pci_pass= through') \ error_message: 'Xen PCI passthrough requested but Xen not enabl= ed') \ .require(targetos =3D=3D 'linux', error_message: 'Xen PCI passthrough not available on this platf= orm') \ + .require(cpu =3D=3D 'x86' or cpu =3D=3D 'x86_64', + error_message: 'Xen PCI passthrough not available on this platf= orm') \ .allowed() =20 =20 --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787550; cv=pass; d=zohomail.com; s=zohoarc; b=ir6sFyhVXQtx/h6Qh916lD/shinEG9XZZQXILYgHaJV/RGKbKzo45Ha/hvWyzA72gP/+Yn/vOlkesk5G2NCcCyIkHCC7UeKMbMeuo6j/gijlu2BKHgecqa7v+PzKuyUuuiO2kmG2fW8gUaYnftQ8LyX3L88DAgej46eh86lKX5A= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787550; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rgu2qk6/ygfWhwigy5ZR1tCj2ULCOVuVMFI9miV2y6I=; b=QNSHbKAeS11rIGmSNrCJW1Fpq5qbZkeGROiErcv6pf9hlXAUWXbj+GADf3Hc3xGG2SzdjdALqvX0jY49K4mucUX5cJcHSFxOxl6ttXFGVrzJnbL7QFnJxQw0qFruqJ6st1llrvqeq2mfjVZgXAnsjVcK4D0dGFwpYw0qB//JX1U= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1686787550404578.6684888353325; Wed, 14 Jun 2023 17:05:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.549311.857807 (Exim 4.92) (envelope-from ) id 1q9aUK-0007zb-Oe; Thu, 15 Jun 2023 00:05:20 +0000 Received: by outflank-mailman (output) from mailman id 549311.857807; Thu, 15 Jun 2023 00:05:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUK-0007yB-Ip; Thu, 15 Jun 2023 00:05:20 +0000 Received: by outflank-mailman (input) for mailman id 549311; Thu, 15 Jun 2023 00:05:18 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aUI-0006qD-Jq for xen-devel@lists.xenproject.org; Thu, 15 Jun 2023 00:05:18 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [2a01:111:f400:7eae::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4e4d7568-0b10-11ee-8611-37d641c3527e; Thu, 15 Jun 2023 02:05:16 +0200 (CEST) Received: from MW4PR04CA0307.namprd04.prod.outlook.com (2603:10b6:303:82::12) by CH3PR12MB8582.namprd12.prod.outlook.com (2603:10b6:610:163::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Thu, 15 Jun 2023 00:05:12 +0000 Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::a6) by MW4PR04CA0307.outlook.office365.com (2603:10b6:303:82::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37 via Frontend Transport; Thu, 15 Jun 2023 00:05:12 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT022.mail.protection.outlook.com (10.13.175.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.25 via Frontend Transport; Thu, 15 Jun 2023 00:05:12 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) 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:05:01 -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:44 -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:44 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4e4d7568-0b10-11ee-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l3egmwnP33t7P6hKKRDXWvnP4yWb8RLFclYNBKt5K1XC/NtzAW4cX97Zpv/OiaWIhF3Op+0zZXi7x23V8ZRL4AzFUkiIPGtt+QWyOh4YP/bcwVInXzyTzu7+83tlCxhzmCniYdi5vt69M8ILpe35adCq1kE8VgPPaxP+CCKDlCChiZAhopO8UwakhK+nwcyPWHOGK3T8nDZhjmWew0LGszaL/r0saFSG1pbzXpqFjkQ81sMJavKavY/D8Vp07mY1llx5D7MwTkaKaW4HEzaWNNbpND2A5tnqMxNz8r3wKAEbuGu5/E/NHckH/Iz/W508YPUqhDpkzRB2kj2QzvBzEA== 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=rgu2qk6/ygfWhwigy5ZR1tCj2ULCOVuVMFI9miV2y6I=; b=nASZFC1OKQu2zcCqhEU0kZOb6GZvJybfEFU0uPY+aO8THkuyEDVRzZkNq8wXDwCWxnDjmhP1VnIn1r1/tRoYHEjOuE96ZXc+NwirovdFxeRuuAsT5B1lFq/NRDuLKjqE87uZADBP/w+sS5p/uOKeRG8W7BMCkdxyk1cfv8wk/4L9fIoOB0WEtuH3hSWinjH3g4ELXceuEtq92tySxHoDZY7r/Uzaw+Zdg4GFFaxqeTTOZ7sQQqvdteITX1m9iJJaYpsLYT2o4u3/mlJoio+JXcq9FPNFet4btVcXS5L+DFnBoXegrdnn3Vax9ZKAO/Oc3REcXoM+JBgaokFyYMiHfQ== 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=rgu2qk6/ygfWhwigy5ZR1tCj2ULCOVuVMFI9miV2y6I=; b=bB0fVVF9zkRjc93FgwNg5PZA3LeTnvWFzQjRRare1ItRvg6aROoGKULtbtOvHEQad3bYCmE9HitZcvuDgW2myzh+KYwCu55r8y4hQJp5gp24M4CLal1JNeU/TMgw3Dyq6hr7NeYQXNFf6ekdt40QyX7cHOdLQEs79qtNY3PKd1c= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Stefano Stabellini , Peter Maydell , Anthony Perard , "Paul Durrant" , "open list:ARM TCG CPUs" , "open list:X86 Xen CPUs" Subject: [QEMU][PATCH v8 09/11] hw/arm: introduce xenpvh machine Date: Wed, 14 Jun 2023 17:03:37 -0700 Message-ID: <20230615000340.1135-10-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: CO1NAM11FT022:EE_|CH3PR12MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: f441096a-5bf8-4ba3-7398-08db6d343088 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3VMKOM7ebS3BKXUHuCga8Ag6Ffl4UpUUlYS25KzPt70RbOnHauHPVzAysHrr5amQ4JmH/7UXA8UaQVERfWSerD3JvI3B657E5h4nEDdEdb6y2PYGYnRjLR5j9l0Vw4W56ERPhYOC1Takhj9ekLx512GlfWNW/At8h7jB+5W/b8ZCmXiBpQcCHMnlzZFvQBUFkHWhZdsPbieRAxaA/ASc/TCr24ApgLiChGhV0n9bmLl2dGp67XXjzd3XI0PrC9oafCxyG8Oi0rsazGsEDFEm6jM30Q7KWP2uDXF2F4MwPOHlp05ShFpS4v7WMgVzYCdtP0mT98Cs6B/wERXQRf9NrVcuoM2p4lxTHP2zZgg0QD3z5nvW0A7bSkMU/xy9ugyZuyBOsLFqK0/q2uVwOn9kGZ6VYH5/DHoF8pUUGHRa10HpwrRCJwQ8W5+mi4/Xw2RtaAqwfCHwkCv4Tidb41zYrS7/bm5+Pl6XSriekOMwOq9uq7bf2A/9ks92dW8+ATWH/fZusqdN3F9ck6AnYAAm3ZCqpXOz21CbFUSQH0DdVkKqM8l+WgQ1FeN9wIslYinfVmmAaG6ktFPciclKOzEMFfGlwRaKWaJSFY4cUXET9ot5OBRyV7gkhBWb9MlPMH4fB/RaJChI8/kyClFKWZFeUrtYTmiYSKGPakGlduleBg29FvPYbuebT+/XLA3AuMj5WyLdW2QcaMUg6cASZP6slOLs4SMv3SpMjnDUPZIaKOA2bEQ678adTHexfpIPM3uc X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(346002)(376002)(396003)(451199021)(46966006)(40470700004)(36840700001)(44832011)(4326008)(6916009)(40480700001)(70586007)(70206006)(36756003)(316002)(2906002)(66899021)(5660300002)(8936002)(8676002)(41300700001)(40460700003)(47076005)(54906003)(86362001)(82310400005)(478600001)(6666004)(1076003)(26005)(966005)(36860700001)(186003)(356005)(81166007)(82740400003)(83380400001)(426003)(336012)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:12.1626 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f441096a-5bf8-4ba3-7398-08db6d343088 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8582 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787551395100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new machine xenpvh which creates a IOREQ server to register/connect w= ith Xen Hypervisor. Optional: When CONFIG_TPM is enabled, it also creates a tpm-tis-device, add= s a TPM emulator and connects to swtpm running on host machine via chardev sock= et and support TPM functionalities for a guest domain. Extra command line for aarch64 xenpvh QEMU to connect to swtpm: -chardev socket,id=3Dchrtpm,path=3D/tmp/myvtpm2/swtpm-sock \ -tpmdev emulator,id=3Dtpm0,chardev=3Dchrtpm \ -machine tpm-base-addr=3D0x0c000000 \ swtpm implements a TPM software emulator(TPM 1.2 & TPM 2) built on libtpms = and provides access to TPM functionality over socket, chardev and CUSE interfac= e. Github repo: https://github.com/stefanberger/swtpm Example for starting swtpm on host machine: mkdir /tmp/vtpm2 swtpm socket --tpmstate dir=3D/tmp/vtpm2 \ --ctrl type=3Dunixio,path=3D/tmp/vtpm2/swtpm-sock & Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Reviewed-by: Stefano Stabellini --- docs/system/arm/xenpvh.rst | 34 +++++++ docs/system/target-arm.rst | 1 + hw/arm/meson.build | 2 + hw/arm/xen_arm.c | 181 ++++++++++++++++++++++++++++++++++ include/hw/arm/xen_arch_hvm.h | 9 ++ include/hw/xen/arch_hvm.h | 2 + 6 files changed, 229 insertions(+) create mode 100644 docs/system/arm/xenpvh.rst create mode 100644 hw/arm/xen_arm.c create mode 100644 include/hw/arm/xen_arch_hvm.h diff --git a/docs/system/arm/xenpvh.rst b/docs/system/arm/xenpvh.rst new file mode 100644 index 0000000000..e1655c7ab8 --- /dev/null +++ b/docs/system/arm/xenpvh.rst @@ -0,0 +1,34 @@ +XENPVH (``xenpvh``) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +This machine creates a IOREQ server to register/connect with Xen Hyperviso= r. + +When TPM is enabled, this machine also creates a tpm-tis-device at a user = input +tpm base address, adds a TPM emulator and connects to a swtpm application +running on host machine via chardev socket. This enables xenpvh to support= TPM +functionalities for a guest domain. + +More information about TPM use and installing swtpm linux application can = be +found at: docs/specs/tpm.rst. + +Example for starting swtpm on host machine: +.. code-block:: console + + mkdir /tmp/vtpm2 + swtpm socket --tpmstate dir=3D/tmp/vtpm2 \ + --ctrl type=3Dunixio,path=3D/tmp/vtpm2/swtpm-sock & + +Sample QEMU xenpvh commands for running and connecting with Xen: +.. code-block:: console + + qemu-system-aarch64 -xen-domid 1 \ + -chardev socket,id=3Dlibxl-cmd,path=3Dqmp-libxl-1,server=3Don,wait=3Do= ff \ + -mon chardev=3Dlibxl-cmd,mode=3Dcontrol \ + -chardev socket,id=3Dlibxenstat-cmd,path=3Dqmp-libxenstat-1,server=3Do= n,wait=3Doff \ + -mon chardev=3Dlibxenstat-cmd,mode=3Dcontrol \ + -xen-attach -name guest0 -vnc none -display none -nographic \ + -machine xenpvh -m 1301 \ + -chardev socket,id=3Dchrtpm,path=3Dtmp/vtpm2/swtpm-sock \ + -tpmdev emulator,id=3Dtpm0,chardev=3Dchrtpm -machine tpm-base-addr=3D0= x0C000000 + +In above QEMU command, last two lines are for connecting xenpvh QEMU to sw= tpm +via chardev socket. diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst index a12b6bca05..790ac1b8a2 100644 --- a/docs/system/target-arm.rst +++ b/docs/system/target-arm.rst @@ -107,6 +107,7 @@ undocumented; you can get a complete list by running arm/stm32 arm/virt arm/xlnx-versal-virt + arm/xenpvh =20 Emulated CPU architecture support =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/hw/arm/meson.build b/hw/arm/meson.build index 870ec67376..4f94f821b0 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -63,6 +63,8 @@ arm_ss.add(when: 'CONFIG_FSL_IMX7', if_true: files('fsl-i= mx7.c', 'mcimx7d-sabre. arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c')) arm_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcim= x6ul-evk.c')) arm_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) +arm_ss.add(when: 'CONFIG_XEN', if_true: files('xen_arm.c')) +arm_ss.add_all(xen_ss) =20 softmmu_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c')) softmmu_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4_boards.c')) diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c new file mode 100644 index 0000000000..19b1cb81ad --- /dev/null +++ b/hw/arm/xen_arm.c @@ -0,0 +1,181 @@ +/* + * QEMU ARM Xen PVH Machine + * + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qapi/qapi-commands-migration.h" +#include "qapi/visitor.h" +#include "hw/boards.h" +#include "hw/sysbus.h" +#include "sysemu/block-backend.h" +#include "sysemu/tpm_backend.h" +#include "sysemu/sysemu.h" +#include "hw/xen/xen-hvm-common.h" +#include "sysemu/tpm.h" +#include "hw/xen/arch_hvm.h" + +#define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") +OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) + +static MemoryListener xen_memory_listener =3D { + .region_add =3D xen_region_add, + .region_del =3D xen_region_del, + .log_start =3D NULL, + .log_stop =3D NULL, + .log_sync =3D NULL, + .log_global_start =3D NULL, + .log_global_stop =3D NULL, + .priority =3D 10, +}; + +struct XenArmState { + /*< private >*/ + MachineState parent; + + XenIOState *state; + + struct { + uint64_t tpm_base_addr; + } cfg; +}; + +void arch_handle_ioreq(XenIOState *state, ioreq_t *req) +{ + hw_error("Invalid ioreq type 0x%x\n", req->type); + + return; +} + +void arch_xen_set_memory(XenIOState *state, MemoryRegionSection *section, + bool add) +{ +} + +void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) +{ +} + +void qmp_xen_set_global_dirty_log(bool enable, Error **errp) +{ +} + +#ifdef CONFIG_TPM +static void xen_enable_tpm(XenArmState *xam) +{ + Error *errp =3D NULL; + DeviceState *dev; + SysBusDevice *busdev; + + TPMBackend *be =3D qemu_find_tpm_be("tpm0"); + if (be =3D=3D NULL) { + DPRINTF("Couldn't fine the backend for tpm0\n"); + return; + } + dev =3D qdev_new(TYPE_TPM_TIS_SYSBUS); + object_property_set_link(OBJECT(dev), "tpmdev", OBJECT(be), &errp); + object_property_set_str(OBJECT(dev), "tpmdev", be->id, &errp); + busdev =3D SYS_BUS_DEVICE(dev); + sysbus_realize_and_unref(busdev, &error_fatal); + sysbus_mmio_map(busdev, 0, xam->cfg.tpm_base_addr); + + DPRINTF("Connected tpmdev at address 0x%lx\n", xam->cfg.tpm_base_addr); +} +#endif + +static void xen_arm_init(MachineState *machine) +{ + XenArmState *xam =3D XEN_ARM(machine); + + xam->state =3D g_new0(XenIOState, 1); + + xen_register_ioreq(xam->state, machine->smp.cpus, xen_memory_listener); + +#ifdef CONFIG_TPM + if (xam->cfg.tpm_base_addr) { + xen_enable_tpm(xam); + } else { + DPRINTF("tpm-base-addr is not provided. TPM will not be enabled\n"= ); + } +#endif +} + +#ifdef CONFIG_TPM +static void xen_arm_get_tpm_base_addr(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam =3D XEN_ARM(obj); + uint64_t value =3D xam->cfg.tpm_base_addr; + + visit_type_uint64(v, name, &value, errp); +} + +static void xen_arm_set_tpm_base_addr(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam =3D XEN_ARM(obj); + uint64_t value; + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + + xam->cfg.tpm_base_addr =3D value; +} +#endif + +static void xen_arm_machine_class_init(ObjectClass *oc, void *data) +{ + + MachineClass *mc =3D MACHINE_CLASS(oc); + mc->desc =3D "Xen Para-virtualized PC"; + mc->init =3D xen_arm_init; + mc->max_cpus =3D 1; + mc->default_machine_opts =3D "accel=3Dxen"; + +#ifdef CONFIG_TPM + object_class_property_add(oc, "tpm-base-addr", "uint64_t", + xen_arm_get_tpm_base_addr, + xen_arm_set_tpm_base_addr, + NULL, NULL); + object_class_property_set_description(oc, "tpm-base-addr", + "Set Base address for TPM device= ."); + + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); +#endif +} + +static const TypeInfo xen_arm_machine_type =3D { + .name =3D TYPE_XEN_ARM, + .parent =3D TYPE_MACHINE, + .class_init =3D xen_arm_machine_class_init, + .instance_size =3D sizeof(XenArmState), +}; + +static void xen_arm_machine_register_types(void) +{ + type_register_static(&xen_arm_machine_type); +} + +type_init(xen_arm_machine_register_types) diff --git a/include/hw/arm/xen_arch_hvm.h b/include/hw/arm/xen_arch_hvm.h new file mode 100644 index 0000000000..8fd645e723 --- /dev/null +++ b/include/hw/arm/xen_arch_hvm.h @@ -0,0 +1,9 @@ +#ifndef HW_XEN_ARCH_ARM_HVM_H +#define HW_XEN_ARCH_ARM_HVM_H + +#include +void arch_handle_ioreq(XenIOState *state, ioreq_t *req); +void arch_xen_set_memory(XenIOState *state, + MemoryRegionSection *section, + bool add); +#endif diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h index 26674648d8..c7c515220d 100644 --- a/include/hw/xen/arch_hvm.h +++ b/include/hw/xen/arch_hvm.h @@ -1,3 +1,5 @@ #if defined(TARGET_I386) || defined(TARGET_X86_64) #include "hw/i386/xen_arch_hvm.h" +#elif defined(TARGET_ARM) || defined(TARGET_ARM_64) +#include "hw/arm/xen_arch_hvm.h" #endif --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787585; cv=pass; d=zohomail.com; s=zohoarc; b=Nr1b+BJ12MV8l7qmSImjqyDzeNmAecHMHt6lC6LzTPr28oYkoMCVpHhfm17PYh5sjQW6oyq9fKqfyOTujuZK8QqxweKJatVvViNoN2vlSSPCMEM0PGezJBSfrGnImOOY59P70bkaojiRACM/uvbhNwxA7qezJ7pvnyNP7BASn5s= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787585; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J2/440lErbRVHq/8o71SRNhv5jl2wKDCEr9Op4/IeM0=; b=T7i0lJqrJ/7T9zZTADAuMyg/A/JYpBOIjBlyjcWiHPnApJivcKbEed0Rn2PDU441kqicOv8np1Yk3U5dBGeb5zIUcErxz0UvSMhL2X4F7nhG4lr4B2xkSSSmOROVk6H31jFaTb965vNiNHJ2i3Ph9XhpG2FDAYFlEjIvkSt8fNs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686787585880460.47227001096394; Wed, 14 Jun 2023 17:06:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9aUN-0005pf-EB; Wed, 14 Jun 2023 20:05:23 -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 1q9aUG-0005lL-Fh for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:05:17 -0400 Received: from mail-bn7nam10on20602.outbound.protection.outlook.com ([2a01:111:f400:7e8a::602] helo=NAM10-BN7-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 1q9aUE-0006qw-If for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:05:16 -0400 Received: from MW4PR04CA0271.namprd04.prod.outlook.com (2603:10b6:303:89::6) by DM4PR12MB5342.namprd12.prod.outlook.com (2603:10b6:5:39f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Thu, 15 Jun 2023 00:05:10 +0000 Received: from CO1NAM11FT080.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::9) by MW4PR04CA0271.outlook.office365.com (2603:10b6:303:89::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37 via Frontend Transport; Thu, 15 Jun 2023 00:05:10 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT080.mail.protection.outlook.com (10.13.174.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.23 via Frontend Transport; Thu, 15 Jun 2023 00:05:10 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) 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:05:00 -0500 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:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nx5tAR5XuwPKrkGZq7wlodQo0AcFxwitoxH26zycfrAwZmEZVyC6biSF8SeTY4mSS+n3jj8Gv0aU7ISrC+SPQMXZn8Hx56V9EVrtUYlyQyqnxn3ZmyAFd/aCWNsBYqLI6LzFYMfzxGrFuJPvqqgyrKpfw1aF+kQ08ihnZyR5IQE8eyrhUZlGT1smbNzueRXgcr7Pwfe17hoEk2RfqRPufwxl0wHzFRh8RF4Q+fm1IbakSMUpk6G+m3L5vm95P170cN/Knr8CIfQGRzJEGvFyvLTVPgYBq9IomgXuW0gQNQUI1ICKhiLOMSvQ4aOiuNHQc9E4w02T1uaufdhDNNI8HA== 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=J2/440lErbRVHq/8o71SRNhv5jl2wKDCEr9Op4/IeM0=; b=WvTF2SsBRtdueq6lzX1mj1Bs+TAr6TI3WuVyKaMvqs1fvjTQyiGXpkfwHEBI9F1wLs1YnAcdtzzAGpIdh7Ogzr6Flrnb/6DsmkQxZ0KnhiGUIrv6LiaCwqs510yIFq7+bykZRoyzyZmCU19QGap0dl/TSf0B9svd6n7fujXsud4tKcI1D/eyVkJXjnS8LhBT5DjVH7vMEq/TJbe5OPfxiiABxLkTnjRjtzB9NuOoujomINN4acIRjsaIIehAUWmv7yXEYWvgLtMEHqDdfEpvMRPXFld2JRowgpzdPx1r/9oZbr2KfHztPntfutqVEmCcDHSnvgSLZ3c7vxrnt5o7DA== 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=J2/440lErbRVHq/8o71SRNhv5jl2wKDCEr9Op4/IeM0=; b=Iz5b6bhlFfe24ewz76uF+UMzkd0Jf5y+t9daWdIaAQU5tLuOqSkRK6lKxxO5abvRea8tKZcqLyN1z1QA0r3Epsfzcl8M+I1ILuRgZ1astFo+CW92BANiZ3F+mWwceafL/XUCA6sKP64y/tZ2dtKmBc4AKayMBlGjgOyvVVQT2uo= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Stefano Stabellini" , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [QEMU][PATCH v8 10/11] meson.build: enable xenpv machine build for ARM Date: Wed, 14 Jun 2023 17:03:38 -0700 Message-ID: <20230615000340.1135-11-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT080:EE_|DM4PR12MB5342:EE_ X-MS-Office365-Filtering-Correlation-Id: ec13d141-32e3-48de-0ef6-08db6d342f85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NiTzQLQITuOGDQ8kTxHHmwy3yfBSKXae268l8HRHMrFl8nvsDfkbYzAt6D2esE88w4TGpjdjXSx5s3A18qfc/mUZ7CUFlOiezJo1rgpNdJrrDslnEKcUei+cS3JA3WygVwEobvouv+EErySzCVchdy9jzVroV8B1RFWpshhWfSybcoLWSpqHtma0VDaEMiID7zESInoS3R6xxOcuqL7ua3GhbPTA7s1KpLaCouknHmOuuIet50xpANMttEgJTXws+gPd00n27VYpjnr9gqoiKsvElGnH/MSxJCjdAQYAh+lO3fOlVWGz9biWIsRLx/Yi79Whn0tqzrm3G1mjuPfFAq0rGFyNryNUX8WRmqBhq956t2JgYtFCop4EbdmDIRmN2OcRuJcaJ5bsDeBdH5W76fazdTeAW2v4jGCt9QFG0ORDePcDXiZcO0Ys0icfr1mFe6jriwIeg28lSId+JB9cd1/npnJJPKrd6mWsZl1NIVtEyBdXzNgqsWBE9CaA14dcOOyJ3DofFhtaBdbxRI96sQ3Roz6YpdSN1b7wkBan2qRh/LKT+WVSiBHrolaYUCO/qRgvOSXVj31QaP7AmWB9E/fsX8kDNOR2Nn4hZBDvZYA8lqF9SM35M58rGnIaLI8mVxH0BXlVeiqsCsaIw8iR4+dcCpU5jsM0E8appu6VKstCC4Wb5UXKXLnQQ7/767xccEgJYFnaiWnPLPXMlQrMS2Rsrm8n/D9P5gCqnRwQ5FQacA23qKF+uEB0kgEignL+Lo5fWLAB5G3hzsK3/bbDIQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199021)(36840700001)(40470700004)(46966006)(5660300002)(83380400001)(426003)(336012)(186003)(40480700001)(44832011)(66574015)(2906002)(4744005)(47076005)(2616005)(36860700001)(41300700001)(8936002)(26005)(40460700003)(8676002)(316002)(54906003)(6666004)(82740400003)(36756003)(478600001)(81166007)(82310400005)(356005)(4326008)(86362001)(70586007)(70206006)(6916009)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:10.4470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec13d141-32e3-48de-0ef6-08db6d342f85 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT080.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5342 Received-SPF: softfail client-ip=2a01:111:f400:7e8a::602; envelope-from=vikram.garhwal@amd.com; helo=NAM10-BN7-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787588055100007 Add CONFIG_XEN for aarch64 device to support build for ARM targets. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Reviewed-by: Alex Benn=C3=A9e --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 481865bfa9..cfa98e9e25 100644 --- a/meson.build +++ b/meson.build @@ -136,7 +136,7 @@ endif if cpu in ['x86', 'x86_64', 'arm', 'aarch64'] # i386 emulator provides xenpv machine type for multiple architectures accelerator_targets +=3D { - 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'], + 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu'], } endif if cpu in ['x86', 'x86_64'] --=20 2.17.1 From nobody Fri May 17 01:44:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1686787588; cv=pass; d=zohomail.com; s=zohoarc; b=bzf3pPEoTVT7SLhssQfbh9vEVh3OwrTlUnkyi+QvoTKmNr/kNZP8yZRiMbdMqZTSKVZltte5J3Wb7cB0OZs8w5ODk6NjekmnIBLX/52w2+8HgnHL35BgV79GFugWyMo7WSUXuWdMPlh55GBKu9X7z/PX/9kaQ6hvpmA8CL30EHM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686787588; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1GPFrVwyJAk/wj9M8BzLHdKddZTmQYLu+ViRsYgyOvo=; b=NhlOSy/qw1H1O0n42UlCRdWMZ2IjjzXib/VdSlra2lLQewmuCR33xeLv+UmqY/W1L/Vxgtd4ZtYIlmBC5Qpug3ss4QQJw3rmO3DIJZVu4+WyyR//Z0zrgiodUzSG2zkH/E/O6hd/rOfSPGi8X7IPreIl95a8FuPP1s8o7EW7GBs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686787588504130.52232091117196; Wed, 14 Jun 2023 17:06:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9aUN-0005qA-Qq; Wed, 14 Jun 2023 20:05:23 -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 1q9aUJ-0005ml-CF for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:05:19 -0400 Received: from mail-bn7nam10on20615.outbound.protection.outlook.com ([2a01:111:f400:7e8a::615] helo=NAM10-BN7-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 1q9aUH-0006rd-0t for qemu-devel@nongnu.org; Wed, 14 Jun 2023 20:05:19 -0400 Received: from MW4PR03CA0032.namprd03.prod.outlook.com (2603:10b6:303:8e::7) by MN2PR12MB4406.namprd12.prod.outlook.com (2603:10b6:208:268::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.25; Thu, 15 Jun 2023 00:05:13 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::11) by MW4PR03CA0032.outlook.office365.com (2603:10b6:303:8e::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:05:12 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.25 via Frontend Transport; Thu, 15 Jun 2023 00:05:12 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) 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:05:01 -0500 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:05:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HJOml4pZ+zH+ZeQOl3dIN9BImJbS/LTN0/CgaiiJQIhhprkvig2kJR2Ko5m5yvLYXOSaQMCX+6PHlpmmanmS4ZobqYDrOgQBJISy1wWS/Wl7vVbgFppuMcFRWEQW8vyJodnYXvWlSAUE8LvMzOfLqFbRSeuUSo53wj7wLpJbUJywE8ANfnAmiRN2m7Elo3oMVt3I9WKIzHkxQ99CnUlLQbilDhp5xGmEMg1ws8nDiRJfLaeGvXR6xtfXyWQ4wavg88zh7ZOntUvGe5JqnayGoRHd8Gv2Jk/jsLzPK7Eww/1BLWqXX/6bQDJOSCpksfVV8O9u2JY+tW3nBJLNgPEX+w== 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=1GPFrVwyJAk/wj9M8BzLHdKddZTmQYLu+ViRsYgyOvo=; b=XpG1s9rggJklgjhPvtRo27UZ1IDEwo9uvb3gbq2Sim5imk3Dlas1yvIrouP3BxdnKTYi+2O+EeK5zH6rfdd9lh230TJ28ySotJQYlx/yFzbrB5e9if4qHo/r+1vZgkk3vGajxTY0j1frVkauRQ9wMOpzvpYbnPaQvryEMOnoE/B9H2+mwhekIDGmY4Ln07UsgkzSWnoCImiKbdjLo23T7X8XKgPOtTNwT3nJSshzUHf6qaTb1V2sIlG77MxjaZ+WipQgL1WDi/k57YtHNhJm7Tk0/XN7wS7mCM/H51sIznC6aTssX8B+8ZgrtnT7wkSllzbtBhi9GC+Bos0NpChiJA== 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=1GPFrVwyJAk/wj9M8BzLHdKddZTmQYLu+ViRsYgyOvo=; b=wKf7xqNpiorRjodlxNh7As/n08jKIcrTH81gWaDZy7tNqcRnSXcNRMrPf/7rXWV9PI/y/6VRX4q+wLyd4ysnVd158VVtZT46ZY+/6XlWWybEpAJOgm1ls43GPe/GzPr2cr3zkZHkU/VbzxEdpRaXZ1uuDs818eNfRpeWu/e9EoA= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Thomas Huth" , Laurent Vivier , Paolo Bonzini Subject: [QEMU][PATCH v8 11/11] test/qtest: add xepvh to skip list for qtest Date: Wed, 14 Jun 2023 17:03:39 -0700 Message-ID: <20230615000340.1135-12-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: CO1NAM11FT051:EE_|MN2PR12MB4406:EE_ X-MS-Office365-Filtering-Correlation-Id: 09d52529-8d58-41f0-fcca-08db6d34309c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kGFeC6Bxi/5PFP8Ez5D9W1uoRs+FSeF7MewCIWHuEZlAwNpcZ75WJEuPMrzYJxHOwq62uJBZ1+XWWET9x8ECwRDvVivoWUHaRL9y0DvSQjWPZNFkpAQti/iRg1Bx1dBCYYkLK9kYV0oGLMalK3ySTtj+m4B0h2MJlnRuC60B+SbM/p8QKfIeH7ZvuBfnSODdBrNq5bhQoN1AIUBw5ShR1yZbvyRp6VKqE8PTYxbSRODUhusZspnIpyYh0n4Fn+7vkjj+rO4YGNhAeA+NiHE+H1Z+8tzrQKB7uTBrqhGOTRX0fi7dn09FvGACdGEwOZvrzEm2Ka0EF1cWG0/XTsFXiV4jt9dqhJlgMUi57Y9yAl16U3eTlChLmDtauP5ejDvxNe+hkabVW43W75IX6NqelM3d1vR184GKmcV4b3wXuNowmIxxcCAmxOaeq7EKg32p/uf8rls3L+8PvY9XLolevKBUcGYCNjm8JjaAg+KqAjTg9w/lPjMgJbg9REsPl2bGnb6arOxeELKhLQQcWhGf+ciK4ChzY+oXzTsuv6cfBJKObQkPSzws1SeL1L9oYLOKz02YZAyH50dEwNINnw8hjg/A8zYPwEJGRwm7+Q+XCjUnQUngVlgNz2/ilbgc+ufx8EbtAYznYm6rVpeVKss4QUMbuhkBmEWAtRSiS6D40pJLAeMs4WKCCS6PNt9kbfGll5goPf7TNzkpl6Q8RZIgVxi3VtcuaaFcF/ctn+3HlkucY50+NCt0zg6f88SR+YSif1yJ/a+1gWgxWxfm70HbQg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(376002)(396003)(39860400002)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(336012)(426003)(36860700001)(83380400001)(40460700003)(47076005)(4744005)(2906002)(2616005)(36756003)(82310400005)(86362001)(356005)(82740400003)(81166007)(40480700001)(54906003)(8936002)(8676002)(316002)(41300700001)(5660300002)(478600001)(70206006)(70586007)(6666004)(6916009)(4326008)(26005)(1076003)(186003)(44832011)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2023 00:05:12.2972 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09d52529-8d58-41f0-fcca-08db6d34309c 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4406 Received-SPF: softfail client-ip=2a01:111:f400:7e8a::615; envelope-from=vikram.garhwal@amd.com; helo=NAM10-BN7-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1686787590055100011 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Like existing xen machines, xenpvh also cannot be used for qtest. Signed-off-by: Vikram Garhwal --- tests/qtest/libqtest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 77de16227f..de03ef5f60 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1465,7 +1465,8 @@ void qtest_cb_for_every_machine(void (*cb)(const char= *machine), for (i =3D 0; machines[i].name !=3D NULL; i++) { /* Ignore machines that cannot be used for qtests */ if (!strncmp("xenfv", machines[i].name, 5) || - g_str_equal("xenpv", machines[i].name)) { + g_str_equal("xenpv", machines[i].name) || + g_str_equal("xenpvh", machines[i].name)) { continue; } if (!skip_old_versioned || --=20 2.17.1