From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,PDS_BAD_THREAD_QP_64,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 976C7C433B4 for ; Wed, 28 Apr 2021 21:34:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A51726144A for ; Wed, 28 Apr 2021 21:34:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A51726144A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbrpE-0007ov-IB for qemu-devel@archiver.kernel.org; Wed, 28 Apr 2021 17:34:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbnkq-0000Lk-5n for qemu-devel@nongnu.org; Wed, 28 Apr 2021 13:13:40 -0400 Received: from esa.hc3962-90.iphmx.com ([216.71.142.165]:35665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbnkn-0001Ct-6o for qemu-devel@nongnu.org; Wed, 28 Apr 2021 13:13:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qccesdkim1; t=1619630016; x=1620234816; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=SrWEjZGeoKr5e+Fclx9TnalV0U2dOwwtUiovQyD88ac=; b=sfnrV4/b0AkFO/M/EqOz80L5YpStNy5qTUv5ll+8tI4FhS8M2u/Hm5KL 8LHu2lW0KVIi32x1EuB9XjRYK+y4v4fyUH/TLK3grqSiwLzg1tEPVYA+y r7JBr1ttamY/rqFY+bJEMY80kDjUtfQRHI0Np1q1S27qeu/hm/UomF39M Y=; IronPort-SDR: R+jcR22mF8pDkJi6BHFXl3IzQ/7b0CeXN2vJgKdyZOIX4IUPpx6KKc50mkHJuy7SI+aDalGFm5 2xkqRM1UkTjk6dn5fgNvaz+eyGBSvWZ4S/OPHdVw4RzPv+tqvg/fu/yDbS2JvO9aLmNOWLyRkl uEXEQUCcm0WRxGAtZ7XM8+KKsOgEI4uaVYgrXP+ftoHAzT58bKHksLKzMlqJyjUt7YgeydUp99 fE0fUF+QxjX4M4IRO7ActAsPhZe0X24mqIE0qozZx0CR9QUeaArD54YO1o7SuJOCNJ7h2ET+eU gi0= X-IronPort-RemoteIP: 104.47.55.105 X-IronPort-MID: 30163 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED Received: from mail-mw2nam10lp2105.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.105]) by ob1.hc3962-90.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 17:13:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lXD8vvvHFh5Q4bXW3BUfi8pFjMgl5OGKqaUsjD366CVvX7oDkqjI790PPGxYqHY5Mn5j5WMz7fHSnloFpZGX71Fejqvq+M3YcYzZFlsqBtKeyV8NMNZZON3p8tuIvv/yrwv95jQVnDfoeKkMYzcEWgffCyWJDSafn1A+5/kcItG9my39XkTByV0J78cCtkxIPK1yL1kxtzuAWKBNy5BxrTbWl3b5uTHo+Iz+u+tDgaPdB1wA5kr+ymEEe1RYNPagViCDGK9VCAAoSxJBA9hqNUwZClJoOW9tgy2PXXILvMI0mpQ67GpM+7J7aED9tkdL8GquPFuqUxT6KKmLgXvkUQ== 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-SenderADCheck; bh=MR352cDrDmZUtd0ZrA0fIPtMJmUN0AwXT93caN5qdEo=; b=D2HMzj+LBn2bJEzc3z1GIgSjox2GfxYtu8duYqHLbFvp+h1Dk6bkZIGBh6zGbnq4yRBxpqyOlbW7dxt8BhUEJaBwNhpDHKMW8hrj3vJXg5EnoNl4aM7aasE0UdofFGeKygAcOVDSVnvGQAixBEpsjQO8O/0reLeTUwBwzAuWBJuSRYT9fjIytvdaJwjj/ve3LegdQC5zYnpy8O7BzyCiKPDJ+1a8yEE0KDrmCsiJ/lyU/yhTwd3dzj+P2DFmuxLRk1ncp5aZnhDcsqlguM5p8pWcG2M9l8j1aEv+sZRE2pZ/tfzzpnkvBzj+ombnvaYox5oEGl/19BbJJvHOIFKdXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=quicinc.com; dmarc=pass action=none header.from=quicinc.com; dkim=pass header.d=quicinc.com; arc=none Received: from BY5PR02MB6772.namprd02.prod.outlook.com (2603:10b6:a03:206::11) by BY5PR02MB6931.namprd02.prod.outlook.com (2603:10b6:a03:232::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Wed, 28 Apr 2021 17:13:32 +0000 Received: from BY5PR02MB6772.namprd02.prod.outlook.com ([fe80::e84f:f62a:4384:b16e]) by BY5PR02MB6772.namprd02.prod.outlook.com ([fe80::e84f:f62a:4384:b16e%6]) with mapi id 15.20.4065.026; Wed, 28 Apr 2021 17:13:32 +0000 From: Trilok Soni To: Viresh Kumar , "stratos-dev@op-lists.linaro.org" , "rust-vmm@lists.opendev.org" Subject: RE: [RUST] Add crate for generic vhost-user-i2c backend daemon Thread-Topic: [RUST] Add crate for generic vhost-user-i2c backend daemon Thread-Index: AQHXPCk3ArzJr3k09kiUN4EG3FfQgKrKKVcQ Date: Wed, 28 Apr 2021 17:13:32 +0000 Message-ID: References: <20210428122247.ymwshfuoojxzsebf@vireshk-i7> In-Reply-To: <20210428122247.ymwshfuoojxzsebf@vireshk-i7> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=quicinc.com; x-originating-ip: [76.176.58.9] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: efec7755-6ced-4bbc-6011-08d90a68f357 x-ms-traffictypediagnostic: BY5PR02MB6931: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nX2gA8UNhvtot8hIrj8LFSZhED4eeJF37Bc56Td6Er65WHH7b2jVqp2KfM9ruVr1Nwn12x1/SSP2QZzFSQt37J3gMHIxMGtYmav1oac9WetSWbRNsVSqyVEJV7m41xlYYB1W0TRsAGzis0AbyDQpdkRmdJuJHXalYpTigyZFDysvGNsDXIu/wxNMCeHAwMfulbbjKLi2IHU+lqf04FKktrdy9FVCqQXw5f11zT1cqezw5yybj2MO4qT8hOXRgeN9WUcN2pO+4UqHlXx8uIT2hgRh/qx47DKb/L6V3Sqj6xnvTMikwzTvsrwHBUV2DZIdgzdx/iy17/2DGFZOG6m2WL3vMQK2is30A70jZVDsY3QDwYboDybKZi1naVLQP3GV3VQeybs5pSUJb40F4exuwprVNw2n0yV2XSp56RsjjrlKxyMQTkMh6XrKxTORhdQO6Ivz/LUoPgEXMRfitbwkyihHs1FMr7yDz2AlNPhla5AmCLQcLPFFHN5MEf1M3OqxZmBb+haeMUi0am430LfaTyDk6g9c6fR8aTktHRXJ2VVjOwARGLu6Y9G1REBJarHSSM9DCUJWrQaJ5CKUg2lJ7gcE9WC97i4njYcE2vjmIuYc7sZVZcgpNWrfzeKVxMhE16u+WdncPX067Re5YkLTkdzVbnwPb8kgrn/+74k3e7+CFgkYJ9WEOFwh5gAKxlNYrBu/AOFV3h/nu5CIbLEzOLcUWmZHRe5YNgUIz7nMuRg= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR02MB6772.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(39860400002)(366004)(346002)(376002)(76116006)(122000001)(6506007)(66946007)(52536014)(53546011)(4326008)(33656002)(110136005)(8676002)(66476007)(38100700002)(7696005)(54906003)(478600001)(66556008)(7416002)(26005)(86362001)(9686003)(966005)(66574015)(55016002)(316002)(5660300002)(83380400001)(2906002)(8936002)(71200400001)(186003)(64756008)(66446008)(41533002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?iso-8859-1?Q?Y59BkFucfYQmNH217xyz/OSsI6T4RnFfnLDJ3CMBn/lOfQRYGsDwZtd6Il?= =?iso-8859-1?Q?hgwMjCaFR0UflxjlAJGUbkNXAuqPrrBGwjGdNp+PvmRfJ1aQdqxSqcBLH6?= =?iso-8859-1?Q?zERFlZDpLij3X6MQuni/rY0AMpyEyKp9cDkES3CEmNl3Np+gnjyp5NyJZe?= =?iso-8859-1?Q?4gKxvojqpfqAchf0qvuQTgPEQMISoLMjQVrww7qr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uDBuHS/XvRWRoioFG1bGVz1i5MN2WjA326e5Cb?= =?iso-8859-1?Q?o8mZAmWIP6Ps/R3cKJCgV7iF+BVzrFL5mPATSI3LUBpmhBYa7zS23wdkqk?= =?iso-8859-1?Q?kPpQjLUfGBH+uxhgfWlkruYELAHL3Qj3EKzPTTLV+4Ttq/CZijRl89PLXM?= =?iso-8859-1?Q?uChLMcqa0/iQcRWo/65HLHS4wKx/CngI7KLtFHIBt0xYY18W/Y2Nw1t36f?= =?iso-8859-1?Q?6uyl0tPTLd6gWyBVDHFpLKw4yrPXKT7haq/zd/9eyKz6Zw0=3D?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: quicinc.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR02MB6772.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: efec7755-6ced-4bbc-6011-08d90a68f357 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2021 17:13:32.3499 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 98e9ba89-e1a1-4e38-9007-8bdabc25de1d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: C34aKwiuEmOsIdsaVP6AlvD4tVUhlCaKNbvF6n1SAvApcWkGfpqtHWt5ks59B2bopJXkL974Ga9F8//siHr33Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR02MB6931 Received-SPF: pass client-ip=216.71.142.165; envelope-from=tsoni@quicinc.com; helo=esa.hc3962-90.iphmx.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 28 Apr 2021 17:32:10 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , Jie Deng , Bill Mills , "qemu-devel@nongnu.org" , Arnd Bergmann , Mike Holmes , =?iso-8859-1?Q?Alex_Benn=E9e?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Viresh, For rust-vmm, you need to create the new issue in the right project. You ca= n probably pick up vmm-reference project at rust-vmm and ask for the new cr= ate. You can also send email to rust-vmm mailing list but github "issues" f= eature is used heavily in the rust-vmm project. There is also bi-weekly mee= tings which is attended by me, Vatsa and rust-vmm developers where it can b= e put up as agenda.=20 The minimal requirement for the new crate is to have less (or almost none) = dependencies on other crates so that they can be independently tested in th= e rust-vmm CI. Anyways, please file a new issue and I will ask Vatsa and ot= hers to comment there.=20 https://github.com/rust-vmm/vhost-user-backend http://lists.opendev.org/pipermail/rust-vmm/2021-March/000406.html ---Trilok Soni -----Original Message----- From: Viresh Kumar =20 Sent: Wednesday, April 28, 2021 5:23 AM To: stratos-dev@op-lists.linaro.org; rust-vmm@lists.opendev.org Cc: Vincent Guittot ; Mike Holmes ; Bill Mills ; Alex Benn=E9e ; Arnd Bergmann ; Jie Deng ; qemu-devel@nongnu.org; Trilok Soni Subject: [RUST] Add crate for generic vhost-user-i2c backend daemon ------------------------------------------------------------------------- CAUTION: This email originated from outside of the organization. ------------------------------------------------------------------------- Hello, In my earlier attempt [1], I implemented the vhost-user-i2c backend deamon = for QEMU (though the code was generic enough to be used with any hypervisor= ). And here is a Rust implementation of the vhost-user-i2c backend daemon. Aga= in this is generic enough to be used with any hypervisor and can live in it= s own repository now: https://github.com/vireshk/vhost-user-i2c I am not sure what's the process to get this merged to Rust-vmm. Can someone help ? Is that the right thing to do ? -------------------------8<------------------------- Here are other details (which are same since the earlier Qemu attempt): This is an initial implementation of a generic vhost-user backend for the I= 2C bus. This is based of the virtio specifications (already merged) for the= I2C bus. The kernel virtio I2C driver is still under review, here [2] is the latest = version (v10): The backend is implemented as a vhost-user device because we want to experi= ment in making portable backends that can be used with multiple hypervisors= . We also want to support backends isolated in their own separate service = VMs with limited memory cross-sections with the principle guest. This is pa= rt of a wider initiative by Linaro called "project Stratos" for which you c= an find information here: https://collaborate.linaro.org/display/STR/Stratos+Home I2C Testing: ------------ I didn't have access to a real hardware where I can play with a I2C client = device (like RTC, eeprom, etc) to verify the working of the backend daemon,= so I decided to test it on my x86 box itself with hierarchy of two ARM64 g= uests. The first ARM64 guest was passed "-device ds1338,address=3D0x20" option, so= it could emulate a ds1338 RTC device, which connects to an I2C bus. Once the guest came up, ds1338 device instance was created within the guest= kernel by doing: echo ds1338 0x20 > /sys/bus/i2c/devices/i2c-0/new_device [ Note that this may end up binding the ds1338 device to its driver, which won't let our i2c daemon talk to the device. For that we need to manually unbind the device from the driver: echo 0-0020 > /sys/bus/i2c/devices/0-0020/driver/unbind ] After this is done, you will get /dev/rtc1. This is the device we wanted to= emulate, which will be accessed by the vhost-user-i2c backend daemon via t= he /dev/i2c-0 file present in the guest VM. At this point we need to start the backend daemon and give it a socket-path= to talk to from qemu (you can pass -v to it to get more detailed messages)= : target/debug/vhost-user-i2c --socket-path=3Dvi2c.sock -l 0:32 [ Here, 0:32 is the bus/device mapping, 0 for /dev/i2c-0 and 32 (i.e. 0x20) is client address of ds1338 that we used while creating the device. ] Now we need to start the second level ARM64 guest (from within the first guest) to get the i2c-virtio.c Linux driver up. The second level guest is p= assed the following options to connect to the same socket: -chardev socket,path=3Dvi2c.sock,id=3Dvi2c \ -device vhost-user-i2c-pci,chardev=3Dvi2c,id=3Di2c Once the second level guest boots up, we will see the i2c-virtio bus at /sy= s/bus/i2c/devices/i2c-X/. From there we can now make it emulate the ds1338 device again by doing: echo ds1338 0x20 > /sys/bus/i2c/devices/i2c-0/new_device [ This time we want ds1338's driver to be bound to the device, so it should= be enabled in the kernel as well. ] And we will get /dev/rtc1 device again here in the second level guest. Now we can play with the rtc device with help of hwclock utility and we can= see the following sequence of transfers happening if we try to update rtc'= s time from system time. hwclock -w -f /dev/rtc1 (in guest2) -> Reaches i2c-virtio.c (Linux bus driver in guest2) -> transfer over virtio -> Reaches the qemu's vhost-i2c device emulation (running over guest1) -= > Reaches the backend daemon vhost-user-i2c started earlier (in guest= 1) -> ioctl(/dev/i2c-0, I2C_RDWR, ..); (in guest1) -> reaches qemu's hw/rtc/ds1338.c (running over host) SMBUS Testing: -------------- I wasn't required to have such a tedious setup for testing out with SMBUS d= evices. I was able to emulate a SMBUS device on my x86 machine using i2c-st= ub driver. $ modprobe i2c-stub chip_addr=3D0x20 //Boot the arm64 guest now with i2c-virtio driver and then do: $ echo al3320a 0x20 > /sys/class/i2c-adapter/i2c-0/new_device $ cat /sys/bus/iio/devices/iio:device0/in_illuminance_raw That's it. I hope I was able to give a clear picture of my test setup here :) -- viresh [1] https://lore.kernel.org/qemu-devel/cover.1617278395.git.viresh.kumar@li= naro.org/ [2] https://lore.kernel.org/lkml/226a8d5663b7bb6f5d06ede7701eedb18d1bafa1.1= 616493817.git.jie.deng@intel.com/