From nobody Thu Nov 28 08:48:35 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=1693004360; cv=pass; d=zohomail.com; s=zohoarc; b=YJfYFxBPpULfE98VqqYuBtoKtBbGQ+wBs3RuKnEyKCYSTP5HrBZGRXzjv9nzuytKQNn4Mc2ksZ1q+trXb5kw7+HsR7ZXDQUL+NNt6W95ImF20kwN6CbAEwS/sJrX1HqEZQTdrKAvIhu0OacVN2WOJMV12et+OpZIdQWmBUwV2L4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693004360; 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=2PtkiVtZv0hsvo+Gr9PfxuXUuxYO+eXlSYfO9PnntFs=; b=PtgWeUzBtFpim5awQfoLYrJcS310StqgSz0d0wnDvBgTibJl9C97dzvbL8fHTv7oCXJ9Y5sH/g0kEBcBPWqqsLD0PWh6JOpjMOLQSCKAYY8ZAU4cRtR/KjbKtgfZAddtFOnYV3H13Zn2JUu9bgrgdX9y+JdVKSuNGHK1cy8z40k= 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 1693004360710858.5421881916733; Fri, 25 Aug 2023 15:59:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZflL-0000Rv-TD; Fri, 25 Aug 2023 18:58:44 -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 1qZflK-0000Qo-Vz for qemu-devel@nongnu.org; Fri, 25 Aug 2023 18:58:43 -0400 Received: from mail-dm6nam11on2040.outbound.protection.outlook.com ([40.107.223.40] 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 1qZflG-0005ON-8t for qemu-devel@nongnu.org; Fri, 25 Aug 2023 18:58:42 -0400 Received: from PH8PR15CA0013.namprd15.prod.outlook.com (2603:10b6:510:2d2::16) by PH0PR12MB8176.namprd12.prod.outlook.com (2603:10b6:510:290::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30; Fri, 25 Aug 2023 22:53:31 +0000 Received: from SN1PEPF000252A1.namprd05.prod.outlook.com (2603:10b6:510:2d2:cafe::b3) by PH8PR15CA0013.outlook.office365.com (2603:10b6:510:2d2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30 via Frontend Transport; Fri, 25 Aug 2023 22:53:31 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF000252A1.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 22:53:31 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.27; Fri, 25 Aug 2023 17:53:29 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.27; Fri, 25 Aug 2023 17:53:29 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 25 Aug 2023 17:53:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L7OFTmoxqR+zKpd9OUbJlKxMS+Xu7Ly7JfBRhcd/oPoj6Q3Xv+OfCpc9puHX5FNR8DsA1XK45u+oRBKDBWavtQch4IM5hAcFxZjExqgrEEGyjeab/DiSRrvnlN3Yvtn7N3MQm6KeCxsQ9GY8gpkypMFVohlkmkwfpMfTCSD0UR7p+JczdV1lqFuuga4T+Yz49xGGOToEFvZFXICaxHlGH1Bbwyh6XV/ZTgPse2/muQDbv9LEtHzqWokXTEZ2RPyg7y+PGzRRCl6lDVTo5/saAueIdIx5/wU9PU4IQa5vaCScNd4kJ5iFnlh8wx68rXCZpgcF/3INpovWvRAQgr4xLg== 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=2PtkiVtZv0hsvo+Gr9PfxuXUuxYO+eXlSYfO9PnntFs=; b=BtOaEp8GNS4iNWOyMFmNpS5s6D9F2dj/tadXal7YoWUdZZZIruBMay9yf5WPnpCOoCCEJDXOoqjdENlSAtaSbhGHh4DnEKvGlfh0B3wafVbJ5BhBhpDitHSYj3uA4nJP8urRlVu4fcwYDqAd32gtn9IrMuGpMlv9oVwi5rLGiCnE6JPr8ro2zd7o6Ih50Bw12UsB/4dWl0lm9h71MccyontQSg51YX2hYuRr/qUfEEsrPsTYOvmptEjuvPM+2c1P1rD1CfZ1Hq6F6vnkb22hPyCkUbCvt/+KY/JyS/Om2Dy+tHtEMU2f7hRWLGnD8sTKyPOWIKCe8RBPNcf0VsrUBg== 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=2PtkiVtZv0hsvo+Gr9PfxuXUuxYO+eXlSYfO9PnntFs=; b=eJ6t148yVE6LnP7C5BYch1n1PKT1Ppn1KOabGXTUlhEnWyTYgauYBXkNkFFpMXxbqWD3zl47F914CijB4zY2NSL7amh4RKZOsFoO6IZ6o/5QKsIwWqiBSfqIZGhGwJb+hETrBGcCtZbuVAyNf90l1HRU3mPZ8V/qP3j8wCitJW8= 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=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , , Oleksandr Tyshchenko Subject: [QEMU][PATCH v3 1/2] xen_arm: Create virtio-mmio devices during initialization Date: Fri, 25 Aug 2023 15:53:25 -0700 Message-ID: <20230825225326.9438-2-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230825225326.9438-1-vikram.garhwal@amd.com> References: <20230825225326.9438-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A1:EE_|PH0PR12MB8176:EE_ X-MS-Office365-Filtering-Correlation-Id: 59316550-2900-4c60-758c-08dba5be1a98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R2OQTLyS8tzwc8HyDkAMZal3xoYHEzTrDviWGGUTjB+7Wsg8CUVylFCgo3FMnHKdRVL1sKWGJWH/KuV5rE33L4X89xwqVl7sU9Fp6w/uWnPQGEajqfxL2Lx7q4OxO81Xc4dXoIuH0L4Vwva8oBTh4618q1geKEV2hPwNMRUxzX+SCrz8wPlOCZKXXTkcwucUyYNP6OmMRBLoEtv1UFadDnQ+rLAM8vbb8W7Otkj1aGcE0TOzA82iSJof5xXdbxccRNIKsaiHok1p5pTMFe1UxRh0QjegGPSkEw/WIeTIX3HIi85pU06SJyoAGbOJpBI8BgO9r34zA0p/VzyDQeeU4ECeGV83CeQKq5MvvZ5d3RiLKTMGbqSWas8sLMQqN2LMLZgWN370m6r+2wXtbiMh1hNem0ohowkhx24gsQIKUXr4Hryg3MdNWJ9Iet+XGXgd6cgjExf10p7fsxOO6lBYIxAzLWdFY6fOoZH1ujZdLuCs+u42fZBWNGdcDPexuwgvQdTwtWiOR14Mo8Q8CH6zJMuDG9Jwc21QBpVJlrY10HNI15+ueOh519we7Sc9U9C1EHxysb9o85ur8DmYLmnHGPSpyPouLdPVYverdJSR0qsJrbhsGgrrFWrJHfFWj4G2j45ctsA52ddyOgy/hAVSBUJSDjOj8ZkO9mBve2aRn5+IYBzBPTB4EfdDyghCgZVobL3Xn0M6oisN9eFFaw/5PULDVRbDT83aVH2EPZDK0ydZ6vxHJCpIJK32p6OeummHNJBoR1XSBQ7eHDkhZP3Cew== 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:(13230031)(4636009)(136003)(396003)(346002)(376002)(39860400002)(82310400011)(1800799009)(451199024)(186009)(40470700004)(36840700001)(46966006)(1076003)(5660300002)(8676002)(8936002)(4326008)(2616005)(40480700001)(26005)(316002)(41300700001)(2906002)(70586007)(70206006)(54906003)(6916009)(44832011)(478600001)(81166007)(40460700003)(6666004)(36756003)(47076005)(36860700001)(83380400001)(336012)(426003)(86362001)(82740400003)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 22:53:31.0844 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59316550-2900-4c60-758c-08dba5be1a98 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: SN1PEPF000252A1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8176 Received-SPF: softfail client-ip=40.107.223.40; 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: 1693004362962100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko In order to use virtio backends we need to allocate virtio-mmio parameters (irq and base) and register corresponding buses. Use the constants defined in public header arch-arm.h to be aligned with the toolstack. So the number of current supported virtio-mmio devices is 10. For the interrupts triggering use already existing on Arm device-model hypercall. The toolstack should then insert the same amount of device nodes into guest device-tree. Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Vikram Garhwal --- hw/arm/xen_arm.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c index 1d3e6d481a..d1e9f7b488 100644 --- a/hw/arm/xen_arm.c +++ b/hw/arm/xen_arm.c @@ -26,6 +26,7 @@ #include "qapi/qapi-commands-migration.h" #include "qapi/visitor.h" #include "hw/boards.h" +#include "hw/irq.h" #include "hw/sysbus.h" #include "sysemu/block-backend.h" #include "sysemu/tpm_backend.h" @@ -59,6 +60,54 @@ struct XenArmState { } cfg; }; =20 +/* + * VIRTIO_MMIO_DEV_SIZE is imported from tools/libs/light/libxl_arm.c unde= r Xen + * repository. + * + * Origin: git://xenbits.xen.org/xen.git 2128143c114c + */ +#define VIRTIO_MMIO_DEV_SIZE 0x200 + +#define NR_VIRTIO_MMIO_DEVICES \ + (GUEST_VIRTIO_MMIO_SPI_LAST - GUEST_VIRTIO_MMIO_SPI_FIRST) + +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <=3D 41500 +static int xendevicemodel_set_irq_level( + xendevicemodel_handle *dmod, domid_t domid, uint32_t irq, + unsigned int level) +{ + return 0; +} +#endif + +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <=3D 41700 +#define GUEST_VIRTIO_MMIO_BASE xen_mk_ullong(0x02000000) +#define GUEST_VIRTIO_MMIO_SIZE xen_mk_ullong(0x00100000) +#define GUEST_VIRTIO_MMIO_SPI_FIRST 33 +#define GUEST_VIRTIO_MMIO_SPI_LAST 43 +#endif + +static void xen_set_irq(void *opaque, int irq, int level) +{ + xendevicemodel_set_irq_level(xen_dmod, xen_domid, irq, level); +} + +static void xen_create_virtio_mmio_devices(XenArmState *xam) +{ + int i; + + for (i =3D 0; i < NR_VIRTIO_MMIO_DEVICES; i++) { + hwaddr base =3D GUEST_VIRTIO_MMIO_BASE + i * VIRTIO_MMIO_DEV_SIZE; + qemu_irq irq =3D qemu_allocate_irq(xen_set_irq, NULL, + GUEST_VIRTIO_MMIO_SPI_FIRST + i); + + sysbus_create_simple("virtio-mmio", base, irq); + + DPRINTF("Created virtio-mmio device %d: irq %d base 0x%lx\n", + i, GUEST_VIRTIO_MMIO_SPI_FIRST + i, base); + } +} + void arch_handle_ioreq(XenIOState *state, ioreq_t *req) { hw_error("Invalid ioreq type 0x%x\n", req->type); @@ -110,6 +159,8 @@ static void xen_arm_init(MachineState *machine) =20 xen_register_ioreq(xam->state, machine->smp.cpus, &xen_memory_listener= ); =20 + xen_create_virtio_mmio_devices(xam); + #ifdef CONFIG_TPM if (xam->cfg.tpm_base_addr) { xen_enable_tpm(xam); --=20 2.17.1 From nobody Thu Nov 28 08:48:35 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=1693004360; cv=pass; d=zohomail.com; s=zohoarc; b=O/fVsl5xE5zJ3YUy2TcHUTFNPdRxrN8wfDjFBjkvOFBz8iMxvwyBWWDIC8x6VxCwOlTIWUD/juqaJePsY7yxwo32yvPUK6jtmKpTrqiXSyxveUwo8A83C7Vjmw+IuABFeAOB0cVifS67Z70ufXaGP+S1fpdz+nnsez6/SNuS6Oc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693004360; 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=oS+qTaZkjuy8pMj0ta6mNWBBIbBxUekfOoEXY9J2m9o=; b=n67NaeK8AYW0IMUfiFcTmkpOBRH8DhFSU9oNfkxKmGHcIi0SeB2hLhQq2ngOfULrvlYS1WxgLBHOV2QqGfcJy1VrkpyLSH90Q96ZFWPvJS3emrXzz9dlQjcqHz6wi7La9XA/C3XQxxlqIlC77p66OeAwIgwuX28drcF8sqeSJig= 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 1693004360644357.0842938639237; Fri, 25 Aug 2023 15:59:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZflJ-0000Ol-4t; Fri, 25 Aug 2023 18:58:41 -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 1qZflH-0000Nm-UK for qemu-devel@nongnu.org; Fri, 25 Aug 2023 18:58:39 -0400 Received: from mail-bn7nam10on2087.outbound.protection.outlook.com ([40.107.92.87] 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 1qZflE-0005Nz-AG for qemu-devel@nongnu.org; Fri, 25 Aug 2023 18:58:39 -0400 Received: from SA0PR11CA0161.namprd11.prod.outlook.com (2603:10b6:806:1bb::16) by SN7PR12MB7154.namprd12.prod.outlook.com (2603:10b6:806:2a5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 22:53:31 +0000 Received: from SA2PEPF00001509.namprd04.prod.outlook.com (2603:10b6:806:1bb:cafe::e1) by SA0PR11CA0161.outlook.office365.com (2603:10b6:806:1bb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34 via Frontend Transport; Fri, 25 Aug 2023 22:53:31 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001509.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 22:53: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.27; Fri, 25 Aug 2023 17:53:30 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.27; Fri, 25 Aug 2023 17:53:30 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 25 Aug 2023 17:53:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vm1mpsADDLPJJNZI08tMkg8jkTC2WbZmgBnul38aCm7tRXjWNg3Rv3U8e5OOvVFkEoaSbbGmvNjT0uCtqACuetqwaDGw7ctUC9+Dl1uhLBwmppD8l6d7Jx0yLCFy2He+x4Zve7FqVp5qIQ6zjyeBUgKDvX5qYQrY30DX6CgcqniY5KuenBEzeZfBwtMrZQP8oT2xHPvnmkXu9tOcf4ngi2zPSBvSoquVCw7Z921rI88+SuqaVksBrxQmKFPi1gfmkUYYs9e1dKUk5md1VWpWfnYf1r60k/p9W6Qmsj0ShwoJS+6GiJX06cYZfMEMFId1iEP1vgduoIMX4zEAkUxupQ== 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=oS+qTaZkjuy8pMj0ta6mNWBBIbBxUekfOoEXY9J2m9o=; b=A2hK8TCRa67s1V4Sb9LsYTOIisFR1S8V+rb6bwyyZSl2s1bNuFOV4Zj/rmfGcaiixjc0LF9Ze5TTqP/k8hJaY9bkt85Taon+PQbwBGsJow0YyRFAX34Qm6hT3yKytdUTejkL1iahHVldLTb9yEJ7p0wr6P2xsXg3lithq5s4biX0z1k6bKgC6ASHBC4+JInGn1n3Rwb3NEDM5UflwGbEZJ842mTWS+Q7Ko+3IEiW1LlfG63Dn2Zkktf6V9m2lvIJwHUwd5xvVSRGiNns/pPXBQA1SU1A84Rc/IbSfkRwjl1Zyxj8bxunq0002rAS0cMXfeX8neXPFdVcNTqhY+/pwA== 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=oS+qTaZkjuy8pMj0ta6mNWBBIbBxUekfOoEXY9J2m9o=; b=zjlLNG9bNCNG3bwTADvsxODsaWdDyOlSc7ceDBngkf6Ji1C8+P3PdOJ/OGccPgA6DUgB5WcBHubmWOU+HewgQRmqSDSR7PQOfLmR3cX7YXJadUY/NwN4w/TKQlyLATepvw/AZOKYj6znT+3OQs66GZ4HgSKXzwoLvJJqgUS7i4A= 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: , , Oleksandr Tyshchenko Subject: [QEMU][PATCH v3 2/2] xen_arm: Initialize RAM and add hi/low memory regions Date: Fri, 25 Aug 2023 15:53:26 -0700 Message-ID: <20230825225326.9438-3-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230825225326.9438-1-vikram.garhwal@amd.com> References: <20230825225326.9438-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001509:EE_|SN7PR12MB7154:EE_ X-MS-Office365-Filtering-Correlation-Id: ee1a2256-fe83-42ec-18e4-08dba5be1a80 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7PB7Gn/i7KrSjLs0/UY9cLdl27VNlXHXBGsL1Euo4iI7Zu8WB6cBEIPdL1/ZaFg2bJON8CtHt5Eac5vSfHOJuwouZtE3qUScvw2IWiBjxamf5jwlnCNX+pTD1//MEcdxZSYMl8k7Ng0DBCOU31uAAkMsdadM1HU5znwT8R0eDP6aMiZa/35jB/FedhDER1Cz9V0UFG7JvOcAaOsplgqkAhgyA1Yt6Q1D9eyfiY1xdwst0J2oLSDjjYiBjNZhUCPPxI2NPPlQAJ32T1MOWfJPzaPwtXFWnySBoZfStoC9U/E2QTXFpPH3KjRMIOq4hUHR0Z5PVdpGHYmZVFICeq3hosXvJkA7lBRMDq3zhIr+FRlkbypE+qaNG3Fl9KRLN7LfEKMxBx1oNKC053TpQaG7AO4wKCedAE4yoc2zK84OZGm6+RZaCbo6lzM134jS1vGCCzkc07YNwio1TF4pG2CLLp1CfAFQMwJNwHw5WIMtxLROstChD39ck07MGIbNd9ws/i2FsOyClyOQx0TcRWwozp7U+z268bt9Ke7Ly88+P9N0epK9G/Z6xGtWKPFtvcC/EYxjRZH1itfvQJk9kGIC0E2/mxDzgbNSRci/1QQeDfvVyJJLPAovSX/DCzQ+/RqJuXfUj/qNFaCqf05mbbVO9HMzCA9yQUnMSjPuK4IlTgAmEYRfvmVFsdn/b80o35i5RxgMb0ftwf6/9rtnub5L3gZtTzV/G7b/IMaS9Ps5X0G/pAV77KJ9CqsrJF+fEooX9o+TKnyYudy83TwKc3Uonw== 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:(13230031)(4636009)(346002)(396003)(136003)(39860400002)(376002)(186009)(82310400011)(451199024)(1800799009)(40470700004)(36840700001)(46966006)(40460700003)(2616005)(8676002)(8936002)(83380400001)(5660300002)(4326008)(426003)(336012)(36756003)(36860700001)(47076005)(44832011)(1076003)(26005)(40480700001)(82740400003)(6666004)(81166007)(6916009)(70586007)(70206006)(54906003)(316002)(478600001)(356005)(41300700001)(2906002)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 22:53:30.9247 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee1a2256-fe83-42ec-18e4-08dba5be1a80 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: SA2PEPF00001509.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7154 Received-SPF: softfail client-ip=40.107.92.87; 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: 1693004362972100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko In order to use virtio backends we need to initialize RAM for the xen-mapcache (which is responsible for mapping guest memory using foreign mapping) to work. Calculate and add hi/low memory regions based on machine->ram_size. Use the constants defined in public header arch-arm.h to be aligned with th= e xen toolstack. While using this machine, the toolstack should then pass real ram_size using "-m" arg. If "-m" is not given, create a QEMU machine without IOREQ and oth= er emulated devices like TPM and VIRTIO. This is done to keep this QEMU machine usable for /etc/init.d/xencommons. Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Vikram Garhwal --- hw/arm/xen_arm.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c index d1e9f7b488..aa8b6171ad 100644 --- a/hw/arm/xen_arm.c +++ b/hw/arm/xen_arm.c @@ -60,6 +60,8 @@ struct XenArmState { } cfg; }; =20 +static MemoryRegion ram_lo, ram_hi; + /* * VIRTIO_MMIO_DEV_SIZE is imported from tools/libs/light/libxl_arm.c unde= r Xen * repository. @@ -80,6 +82,14 @@ static int xendevicemodel_set_irq_level( } #endif =20 +#if defined(__i386__) || defined(__x86_64__) +#define GUEST_RAM_BANKS 2 +#define GUEST_RAM0_BASE 0x40000000ULL /* 3GB of low RAM @ 1GB */ +#define GUEST_RAM0_SIZE 0xc0000000ULL +#define GUEST_RAM1_BASE 0x0200000000ULL /* 1016GB of RAM @ 8GB */ +#define GUEST_RAM1_SIZE 0xfe00000000ULL +#endif + #if CONFIG_XEN_CTRL_INTERFACE_VERSION <=3D 41700 #define GUEST_VIRTIO_MMIO_BASE xen_mk_ullong(0x02000000) #define GUEST_VIRTIO_MMIO_SIZE xen_mk_ullong(0x00100000) @@ -108,6 +118,39 @@ static void xen_create_virtio_mmio_devices(XenArmState= *xam) } } =20 +static void xen_init_ram(MachineState *machine) +{ + MemoryRegion *sysmem =3D get_system_memory(); + ram_addr_t block_len, ram_size[GUEST_RAM_BANKS]; + + if (machine->ram_size <=3D GUEST_RAM0_SIZE) { + ram_size[0] =3D machine->ram_size; + ram_size[1] =3D 0; + block_len =3D GUEST_RAM0_BASE + ram_size[0]; + } else { + ram_size[0] =3D GUEST_RAM0_SIZE; + ram_size[1] =3D machine->ram_size - GUEST_RAM0_SIZE; + block_len =3D GUEST_RAM1_BASE + ram_size[1]; + } + + memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len, + &error_fatal); + + memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo", &ram_memory, + GUEST_RAM0_BASE, ram_size[0]); + memory_region_add_subregion(sysmem, GUEST_RAM0_BASE, &ram_lo); + DPRINTF("Initialized region xen.ram.lo: base 0x%llx size 0x%lx\n", + GUEST_RAM0_BASE, ram_size[0]); + + if (ram_size[1] > 0) { + memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi", &ram_memory, + GUEST_RAM1_BASE, ram_size[1]); + memory_region_add_subregion(sysmem, GUEST_RAM1_BASE, &ram_hi); + DPRINTF("Initialized region xen.ram.hi: base 0x%llx size 0x%lx\n", + GUEST_RAM1_BASE, ram_size[1]); + } +} + void arch_handle_ioreq(XenIOState *state, ioreq_t *req) { hw_error("Invalid ioreq type 0x%x\n", req->type); @@ -157,6 +200,14 @@ static void xen_arm_init(MachineState *machine) =20 xam->state =3D g_new0(XenIOState, 1); =20 + if (machine->ram_size =3D=3D 0) { + DPRINTF("ram_size not specified. QEMU machine started without IORE= Q" + "(no emulated devices including Virtio)\n"); + return; + } + + xen_init_ram(machine); + xen_register_ioreq(xam->state, machine->smp.cpus, &xen_memory_listener= ); =20 xen_create_virtio_mmio_devices(xam); @@ -204,6 +255,8 @@ static void xen_arm_machine_class_init(ObjectClass *oc,= void *data) mc->init =3D xen_arm_init; mc->max_cpus =3D 1; mc->default_machine_opts =3D "accel=3Dxen"; + /* Set explicitly here to make sure that real ram_size is passed */ + mc->default_ram_size =3D 0; =20 #ifdef CONFIG_TPM object_class_property_add(oc, "tpm-base-addr", "uint64_t", --=20 2.17.1