From nobody Fri May 3 05:53:35 2024 Delivered-To: importer@patchew.org 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; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685685005; cv=none; d=zohomail.com; s=zohoarc; b=BlHI9ac/ASfjhRgf5nh883F/j3mTzKMi3ibLGuwF/7MTqin8D3Dat+hVHGbvbiuioXBYnFLQ3EyChWtkTp1k3+XpIFPvP+6dLi2WQ1iECyLgdRmeY+0voT9jKufXSUujPkmZ6pgvkSPSP9dfCZqsdn7dWZ9mHXmnlgzJNod70wg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685685005; h=Content-Transfer-Encoding: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=d+pJJng5fx4kFKejzKmDNFo2NgoyulchHXsMzQ/yQ64=; b=PpY2/jYfqsv9BjrrsfEYebFVzxGfyPNzX+ZW7iPhczwgFan3EBKMWrZRSyBiUbc5hD0Upx3QXq87YKMaPrVOI/47uvodx4cflZ1ZY7tUO2EjqRkdYqkZGy8lawQPgMHKKS+5l3i2IofAWG59RYoJwYYDdC2QiwFWBtZl4Ky+K9c= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1685685004849566.4304321222005; Thu, 1 Jun 2023 22:50:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.542926.847379 (Exim 4.92) (envelope-from ) id 1q4xfN-0005Aq-NW; Fri, 02 Jun 2023 05:49:37 +0000 Received: by outflank-mailman (output) from mailman id 542926.847379; Fri, 02 Jun 2023 05:49:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q4xfN-0005Aj-Kj; Fri, 02 Jun 2023 05:49:37 +0000 Received: by outflank-mailman (input) for mailman id 542926; Fri, 02 Jun 2023 05:49:36 +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 1q4xfM-0004uv-Qz for xen-devel@lists.xen.org; Fri, 02 Jun 2023 05:49:36 +0000 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [2607:f8b0:4864:20::335]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3ecb3489-0109-11ee-8611-37d641c3527e; Fri, 02 Jun 2023 07:49:32 +0200 (CEST) Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6af6df7f93aso1577128a34.0 for ; Thu, 01 Jun 2023 22:49:32 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id r14-20020a62e40e000000b0063b7a0b9cc5sm202964pfh.186.2023.06.01.22.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 22:49:30 -0700 (PDT) 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: 3ecb3489-0109-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685684971; x=1688276971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d+pJJng5fx4kFKejzKmDNFo2NgoyulchHXsMzQ/yQ64=; b=GeoQ7drCwRTbT9YQXikTijbbCD21G4p5krtLy9rertAbvNElam6icECXzLQAMPNc7u 2gbzDbe5LySEEf7M2NMey1MFdwYnAAw/GC24PKEJqC/DCKOBcaXC1uAORwChLGrT3lBc ivXFS9t/y8RLf/IbYCkozIevnHHzUT+Fcj/hPwbHW7l5qmEMyBuOJVHCvYReNhMyTKKe efC7E4nOL/xL2nltdLfwqp75ZZ4FO0Oe8BuZ7dH8nygR1JcacJJtAMoCSxUfIzNQwdg+ XcRZp/CCNcuEUUXmXNcM+NtTePP94ekZrH6V4BNoSYeEbkTCxqmJBVBpleNXQDjI288h hdDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685684971; x=1688276971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d+pJJng5fx4kFKejzKmDNFo2NgoyulchHXsMzQ/yQ64=; b=UA2d92D/x2WLFXF1M5NS4KHiU62n+P8DhBm5GhiIG23AtTILZtuZzJSHtCT6hT8dwq zQaOi6W5MSYZ4Djc6qj0bpLzeNdcghdhLaCAUF6rbXulsB/Q0whc8Q/TT3YbkGMwR0ub UyYkX9hqQjixR3SsmKpGFE/QYtwyEh0UCP3W3AK5tw2dRk9W5BHaVtGEzGEWJHYpr6Jq pbNQpV3/azNpYw3NMyZ5ivLQgtq/jPpngj/VB76QrbtlQ+327iT8H5uCCSzfhrI6/2Ox XZusFl4AzQISklTD2+AEavovjeZUtxUoExBtZ8eC5B8veQMCOcMCG3WsQMPTrEIOv8Ba X6cw== X-Gm-Message-State: AC+VfDwiF86VP/JHtKwtC4VrcdYcEpQBQhq+K+hik7QX8sTtr+P3dHed +bwITWPWYuL/JbaocwN4x70EW+UcNW18NTu8f+0= X-Google-Smtp-Source: ACHHUZ4ugx2VyoJYBxh6uY8zyuOFk/yvO4vMH2g4Zrzo6rhpAQk/BVCNJXcg9q+OlOuAXFll5Q5Bqw== X-Received: by 2002:a9d:77c5:0:b0:6a6:6121:dc60 with SMTP id w5-20020a9d77c5000000b006a66121dc60mr1478045otl.10.1685684971046; Thu, 01 Jun 2023 22:49:31 -0700 (PDT) From: Viresh Kumar To: xen-devel@lists.xen.org, Juergen Gross , Julien Grall , Anthony PERARD Cc: Viresh Kumar , Vincent Guittot , stratos-dev@op-lists.linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mathieu Poirier , Oleksandr Tyshchenko , Erik Schilling Subject: [PATCH V3 1/3] libxl: virtio: Remove unused frontend nodes Date: Fri, 2 Jun 2023 11:19:07 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685685007195100003 Content-Type: text/plain; charset="utf-8" Only the VirtIO backend will watch xenstore to find out when a new instance needs to be created for a guest, and read the parameters from there. VirtIO frontend are only virtio, so they will not do anything with the xenstore nodes. They can be removed. While at it, also add a comment to the libxl_virtio.c file. Signed-off-by: Viresh Kumar Reviewed-by: Anthony PERARD --- tools/libs/light/libxl_virtio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/libs/light/libxl_virtio.c b/tools/libs/light/libxl_virti= o.c index faada49e184e..f8a78e22d156 100644 --- a/tools/libs/light/libxl_virtio.c +++ b/tools/libs/light/libxl_virtio.c @@ -1,4 +1,9 @@ /* + * Setup VirtIO backend. This is intended to interact with a VirtIO + * backend that is watching xenstore, and create new VirtIO devices + * with the parameter found in xenstore (VirtIO frontend don't + * interact with xenstore.) + * * Copyright (C) 2022 Linaro Ltd. * * This program is free software; you can redistribute it and/or modify @@ -49,11 +54,6 @@ static int libxl__set_xenstore_virtio(libxl__gc *gc, uin= t32_t domid, flexarray_append_pair(back, "type", GCSPRINTF("%s", virtio->type)); flexarray_append_pair(back, "transport", GCSPRINTF("%s", transport)); =20 - flexarray_append_pair(front, "irq", GCSPRINTF("%u", virtio->irq)); - flexarray_append_pair(front, "base", GCSPRINTF("%#"PRIx64, virtio->bas= e)); - flexarray_append_pair(front, "type", GCSPRINTF("%s", virtio->type)); - flexarray_append_pair(front, "transport", GCSPRINTF("%s", transport)); - return 0; } =20 --=20 2.31.1.272.g89b43f80a514 From nobody Fri May 3 05:53:35 2024 Delivered-To: importer@patchew.org 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; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685685006; cv=none; d=zohomail.com; s=zohoarc; b=dmM0SvsMaXwACa4jo9Hy1rRzNy2/E3oj0eTpLqpGYgnQRKAy3WjdJmIApn6g+2+MGf2waWAGhbDDB+97CTX6AsT4f+Y4Z6BL9+vx477adE80sUQJtdvMwuBC1DwsJMwm9tWbHc5JOoBMrVyGGJbTv/RaNT1a6oIDI+FyltXxc+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685685006; h=Content-Transfer-Encoding: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=jBN/RWcDvPOwXwPxKLJ7hwpbCSP4ps6soF57y3YX9cs=; b=I+QI2ptjhcKK9BVKwoI0jUZavB6jRe3S8Kdzx4CrehFY2L1g8qSwZxvtuY7LSl1TrcToff+ipGEVE4xUOu5AFO8yxhETNkBXx/dG8A2gJCZy0BPQdbb4fouUJ/Qk6t+X5bZMxfT8O5w375GmoEfv56rTHgX5g+KvJ7XvTVj/u0I= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1685685006590233.22067923586644; Thu, 1 Jun 2023 22:50:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.542925.847369 (Exim 4.92) (envelope-from ) id 1q4xfM-0004vA-GD; Fri, 02 Jun 2023 05:49:36 +0000 Received: by outflank-mailman (output) from mailman id 542925.847369; Fri, 02 Jun 2023 05:49:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q4xfM-0004v3-Dc; Fri, 02 Jun 2023 05:49:36 +0000 Received: by outflank-mailman (input) for mailman id 542925; Fri, 02 Jun 2023 05:49:35 +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 1q4xfL-0004g6-LH for xen-devel@lists.xen.org; Fri, 02 Jun 2023 05:49:35 +0000 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [2607:f8b0:4864:20::534]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4070913b-0109-11ee-b231-6b7b168915f2; Fri, 02 Jun 2023 07:49:35 +0200 (CEST) Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-51b4ef5378bso1532511a12.1 for ; Thu, 01 Jun 2023 22:49:35 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id 21-20020a170902c11500b001ac94b33ab1sm352303pli.304.2023.06.01.22.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 22:49:33 -0700 (PDT) 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: 4070913b-0109-11ee-b231-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685684973; x=1688276973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jBN/RWcDvPOwXwPxKLJ7hwpbCSP4ps6soF57y3YX9cs=; b=LiRvyhpBsWDJitVSWNQaI/YdwbEFhNZ2v7osl22Vwh5mAvifREoEYlY5UW4Y/V6Vtv fF5uDnSA17Bo4PpIj9RtRPVPZxr14Ek8C52LRHpAiGqapviyDYvAoiugWbdVAe3adxwn yf63zomYB2e5c5KwG0z0iHzwr+Kf+qSNKi8qkFhdoOQhxGs3CmV1szqqUyhIdU1Slv26 7wxOzHlGAhiRi3j8OXXv51D22pAEOFmOzwev8pAtPqHR5qSMCs6q7eRsd6RwrspiPxpC gBfDLA5WVM5rtR57Jovt+zc26Rl2go16V138sZTQ8DfploIVOp9Nw8hF3H8TaPZDUMi6 9UqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685684973; x=1688276973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jBN/RWcDvPOwXwPxKLJ7hwpbCSP4ps6soF57y3YX9cs=; b=EVHqWinZQQhvugxJ4FM/taoT1YX8BglD7l2fAvYKyetSRvlBpwH33qNJYWsAxmVTP+ Vr/BauVPHb+zhOo8RXSmi/0/ni8t6mGVigrKffZMSTGA0VlT2nRtZItW1vqKE6HjgT3t D948Pijsul4Xew5AI5NQ01qy+c8wALh4mg1L+RKOfV2iPNjP7vZXhbU2HKClpcKoKCw5 TSZOUNdD8LpW7p32Qu1Km/wV6kL/Qn0r4g8h0UwKIF78locSwDbQsY9cpymM0SHLxMhe bz9RJSq+C0VUJz1S83Jnl5v090fm1yQzvwq5smRQq9a6I9MFJf9Br2Hrtftdy3+6PcNf jyVg== X-Gm-Message-State: AC+VfDywTQQkrz36/Wf7XxILCKudGIfs4WLB3JF14xxu1zKUoEudD8Fk PdKIUkjgs4Xe+QszTl7onGXsMZ4JcFuPs1vWh/0= X-Google-Smtp-Source: ACHHUZ6i8Yj/jn4nrWyKIq7yg+6FGl+3P9GNin6a55YolBhclgLGqi6thYCHu25BO4pR7fAOAlzXqA== X-Received: by 2002:a17:902:e5c4:b0:1af:981b:eeff with SMTP id u4-20020a170902e5c400b001af981beeffmr1424317plf.64.1685684973641; Thu, 01 Jun 2023 22:49:33 -0700 (PDT) From: Viresh Kumar To: xen-devel@lists.xen.org, Juergen Gross , Julien Grall , Anthony PERARD Cc: Viresh Kumar , Vincent Guittot , stratos-dev@op-lists.linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mathieu Poirier , Oleksandr Tyshchenko , Erik Schilling Subject: [PATCH V3 2/3] libxl: Call libxl__virtio_devtype.set_default() early enough Date: Fri, 2 Jun 2023 11:19:08 +0530 Message-Id: <61727b8e00dd9acb0621e98528bd5051d3bd5c58.1685684586.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685685008433100005 Content-Type: text/plain; charset="utf-8" The _setdefault() function for virtio devices is getting called after libxl__prepare_dtb(), which is late as libxl__prepare_dtb() expects the defaults to be already set by this time. Call libxl__virtio_devtype.set_default() from libxl__domain_config_setdefault(), in a similar way as other devices like disk, etc. Suggested-by: Anthony PERARD Signed-off-by: Viresh Kumar Reviewed-by: Anthony PERARD --- tools/libs/light/libxl_create.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index ec8eab02c207..36770af6d4ff 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -1068,7 +1068,7 @@ int libxl__domain_config_setdefault(libxl__gc *gc, uint32_t domid /* for logging, only */) { libxl_ctx *ctx =3D libxl__gc_owner(gc); - int ret; + int ret, i; bool pod_enabled =3D false; libxl_domain_create_info *c_info =3D &d_config->c_info; =20 @@ -1266,6 +1266,15 @@ int libxl__domain_config_setdefault(libxl__gc *gc, goto error_out; } =20 + for (i =3D 0; i < d_config->num_virtios; i++) { + ret =3D libxl__virtio_devtype.set_default(gc, domid, + &d_config->virtios[i], fal= se); + if (ret) { + LOGD(ERROR, domid, "Unable to set virtio defaults for device %= d", i); + goto error_out; + } + } + ret =3D 0; error_out: return ret; --=20 2.31.1.272.g89b43f80a514 From nobody Fri May 3 05:53:35 2024 Delivered-To: importer@patchew.org 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; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685685005; cv=none; d=zohomail.com; s=zohoarc; b=S5AJzExInIzIUQqxf2EX5WlYVuXgi1N0WU+ZT0aoL65GSafRsp2orSw/uSxKUHPdn6AqcV1yw6HDcK5zvhA8zfy2e2JAu0HBa3nXcD82ffbRWIWxYd+dC9I86v3YxfBijWYSRSOZzIRpncjIssjz2bu2JWY4Cej9FyRh+/1ehK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685685005; h=Content-Transfer-Encoding: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=VXMLaPMue+uL4pD6dz7ArFXAqp8Vlz5f6SfADwc6jPo=; b=jAPU3zBucO4izajc7/6O8S60et3CUWMBJFBGvJPzo8R+C+meJ6VFyRYAyT7nw74mFblbDvjkfZh5njGZX7VnMpUyrf51nhpCH+xNNvwKUK3lC+dn8zzmjvhny8oGmmFxhYYRkQxsXD8tRf0qWf2X1MkvOPKReJbFHz2MOEceTzo= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1685685004721372.35784617985416; Thu, 1 Jun 2023 22:50:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.542927.847390 (Exim 4.92) (envelope-from ) id 1q4xfQ-0005Rp-06; Fri, 02 Jun 2023 05:49:40 +0000 Received: by outflank-mailman (output) from mailman id 542927.847390; Fri, 02 Jun 2023 05:49:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q4xfP-0005Ri-T0; Fri, 02 Jun 2023 05:49:39 +0000 Received: by outflank-mailman (input) for mailman id 542927; Fri, 02 Jun 2023 05:49:38 +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 1q4xfO-0004g6-8s for xen-devel@lists.xen.org; Fri, 02 Jun 2023 05:49:38 +0000 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [2607:f8b0:4864:20::32a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 41ea7266-0109-11ee-b231-6b7b168915f2; Fri, 02 Jun 2023 07:49:37 +0200 (CEST) Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6af89b0f3e5so1660327a34.0 for ; Thu, 01 Jun 2023 22:49:37 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id u11-20020aa7848b000000b0063f2e729127sm225444pfn.144.2023.06.01.22.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 22:49:35 -0700 (PDT) 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: 41ea7266-0109-11ee-b231-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685684976; x=1688276976; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VXMLaPMue+uL4pD6dz7ArFXAqp8Vlz5f6SfADwc6jPo=; b=mFKvKglkt9XRUuGMPlMikCG6rF35/Nhu02q30dgjlKtMUvyc318gLqAgzc3UaqW/HK cC4qvSnl6IyT2KWCR8LySbB7ose3xHnZaNtYm/gZbPee5Vc0cAzlAgKTQ5QcIBXGriAQ JQVZ9hieYH2HVPaVZ5S4ode4K+ucy9EjxgIDZ1TqWU6TO+HnlIYs3k7qi7/5I3auWdhE Lowczm5av12kzP4JLWSghe4XhyXbFfp7HOMRhAvxQsLcqtib3fqIHiLVLhFJdRDVlSnY DokUjbb/f4BZaOuTozvNPtiD8JJvyCNUJfBlWdnadO/OBf0Ghxr1s2fx3h6Lggwo0bBn 1sVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685684976; x=1688276976; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VXMLaPMue+uL4pD6dz7ArFXAqp8Vlz5f6SfADwc6jPo=; b=I7kFoHiSt9+OOODY9w3C6NVoJgKsv2zKEDVIKrZhgyGT/CURwFtJqIsasZV7oqMVeG J9T0xobG1qeGl0NE7UgMWhKktcz6OSP5Nv1ayCgam4VWdpwb8VrWN8W4dkKMt7Zfyr6J 5aPUuwZh/icw5M2u8wHQF0JIo81CZCECKYnVh6cVTt1YRgY3zh9Lr723Ef6RQSFILx/U x687h2dTN45PhLrB5sFru8I7BDV+PIfhJJRxDHCLRNFRl2OEF6vbEBna9PvtnxanSJ5l kT2Om40DJtL17w9Cnrc6flpbCq3DuxZnvVzR63Sgx1awR57Js25J57ZYqXmN28EDqs2P +TQw== X-Gm-Message-State: AC+VfDxkb7ZPfZqrJBPaD29xdth8Ocm+cGwFpqVhxE1j0iA2SDuGiQI3 BNETKpbOv/S/RzuIz1eE6tiUCe1/CykWQ3FI980= X-Google-Smtp-Source: ACHHUZ6f+n9x8kcM5ICHaoBfBsV7DG9hnoFb65So2oOrBlPMKr91SCRowromT8FmV+i1HfrumhZBhw== X-Received: by 2002:a05:6830:e06:b0:6b0:ca4f:8504 with SMTP id do6-20020a0568300e0600b006b0ca4f8504mr1495774otb.27.1685684976286; Thu, 01 Jun 2023 22:49:36 -0700 (PDT) From: Viresh Kumar To: xen-devel@lists.xen.org, Juergen Gross , Julien Grall , Anthony PERARD Cc: Viresh Kumar , Vincent Guittot , stratos-dev@op-lists.linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mathieu Poirier , Oleksandr Tyshchenko , Erik Schilling Subject: [PATCH V3 3/3] libxl: arm: Add grant_usage parameter for virtio devices Date: Fri, 2 Jun 2023 11:19:09 +0530 Message-Id: <0e347b2f4817cc578a5f8e41bf70503ae8cf69e3.1685684586.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685685006332100001 Content-Type: text/plain; charset="utf-8" Currently, the grant mapping related device tree properties are added if the backend domain is not Dom0. While Dom0 is privileged and can do foreign mapping for the entire guest memory, it is still desired for Dom0 to access guest's memory via grant mappings and hence map only what is required. This commit adds the "grant_usage" parameter for virtio devices, which provides better control over the functionality. Signed-off-by: Viresh Kumar --- docs/man/xl.cfg.5.pod.in | 8 ++++++++ tools/golang/xenlight/helpers.gen.go | 6 ++++++ tools/golang/xenlight/types.gen.go | 1 + tools/libs/light/libxl_arm.c | 22 +++++++++++++--------- tools/libs/light/libxl_types.idl | 1 + tools/libs/light/libxl_virtio.c | 23 +++++++++++++++++++++-- tools/xl/xl_parse.c | 2 ++ 7 files changed, 52 insertions(+), 11 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 24ac92718288..3a40ac8cb322 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1619,6 +1619,14 @@ hexadecimal format, without the "0x" prefix and all = in lower case, like Specifies the transport mechanism for the Virtio device, only "mmio" is supported for now. =20 +=3Ditem B + +If this option is B, the Xen grants are always enabled. +If this option is B, the Xen grants are always disabled. + +If this option is missing, then the default grant setting will be used, +i.e. enable grants if backend-domid !=3D 0. + =3Dback =20 =3Ditem B diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 0a203d22321f..bf846dca8ec0 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -1792,6 +1792,9 @@ func (x *DeviceVirtio) fromC(xc *C.libxl_device_virti= o) error { x.BackendDomname =3D C.GoString(xc.backend_domname) x.Type =3D C.GoString(xc._type) x.Transport =3D VirtioTransport(xc.transport) +if err :=3D x.GrantUsage.fromC(&xc.grant_usage);err !=3D nil { +return fmt.Errorf("converting field GrantUsage: %v", err) +} x.Devid =3D Devid(xc.devid) x.Irq =3D uint32(xc.irq) x.Base =3D uint64(xc.base) @@ -1809,6 +1812,9 @@ xc.backend_domname =3D C.CString(x.BackendDomname)} if x.Type !=3D "" { xc._type =3D C.CString(x.Type)} xc.transport =3D C.libxl_virtio_transport(x.Transport) +if err :=3D x.GrantUsage.toC(&xc.grant_usage); err !=3D nil { +return fmt.Errorf("converting field GrantUsage: %v", err) +} xc.devid =3D C.libxl_devid(x.Devid) xc.irq =3D C.uint32_t(x.Irq) xc.base =3D C.uint64_t(x.Base) diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index a7c17699f80e..e0c6e91bb0ef 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -683,6 +683,7 @@ BackendDomid Domid BackendDomname string Type string Transport VirtioTransport +GrantUsage Defbool Devid Devid Irq uint32 Base uint64 diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 97c80d7ed0fa..bc2bd9649b95 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -922,7 +922,8 @@ static int make_xen_iommu_node(libxl__gc *gc, void *fdt) =20 /* The caller is responsible to complete / close the fdt node */ static int make_virtio_mmio_node_common(libxl__gc *gc, void *fdt, uint64_t= base, - uint32_t irq, uint32_t backend_dom= id) + uint32_t irq, uint32_t backend_dom= id, + bool grant_usage) { int res; gic_interrupt intr; @@ -945,7 +946,7 @@ static int make_virtio_mmio_node_common(libxl__gc *gc, = void *fdt, uint64_t base, res =3D fdt_property(fdt, "dma-coherent", NULL, 0); if (res) return res; =20 - if (backend_domid !=3D LIBXL_TOOLSTACK_DOMID) { + if (grant_usage) { uint32_t iommus_prop[2]; =20 iommus_prop[0] =3D cpu_to_fdt32(GUEST_PHANDLE_IOMMU); @@ -959,11 +960,12 @@ static int make_virtio_mmio_node_common(libxl__gc *gc= , void *fdt, uint64_t base, } =20 static int make_virtio_mmio_node(libxl__gc *gc, void *fdt, uint64_t base, - uint32_t irq, uint32_t backend_domid) + uint32_t irq, uint32_t backend_domid, + bool grant_usage) { int res; =20 - res =3D make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid= ); + res =3D make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid= , grant_usage); if (res) return res; =20 return fdt_end_node(fdt); @@ -1019,11 +1021,11 @@ static int make_virtio_mmio_node_gpio(libxl__gc *gc= , void *fdt) =20 static int make_virtio_mmio_node_device(libxl__gc *gc, void *fdt, uint64_t= base, uint32_t irq, const char *type, - uint32_t backend_domid) + uint32_t backend_domid, bool grant= _usage) { int res; =20 - res =3D make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid= ); + res =3D make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid= , grant_usage); if (res) return res; =20 /* Add device specific nodes */ @@ -1363,7 +1365,8 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_do= main_config *d_config, iommu_needed =3D true; =20 FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq, - disk->backend_domid) ); + disk->backend_domid, + disk->backend_domid !=3D LIBXL_= TOOLSTACK_DOMID) ); } } =20 @@ -1373,12 +1376,13 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_= domain_config *d_config, if (virtio->transport !=3D LIBXL_VIRTIO_TRANSPORT_MMIO) continue; =20 - if (virtio->backend_domid !=3D LIBXL_TOOLSTACK_DOMID) + if (libxl_defbool_val(virtio->grant_usage)) iommu_needed =3D true; =20 FDT( make_virtio_mmio_node_device(gc, fdt, virtio->base, virtio->irq, virtio->type, - virtio->backend_domid) ); + virtio->backend_domid, + libxl_defbool_val(virtio->gr= ant_usage)) ); } =20 /* diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index c10292e0d7e3..c5c0d1f91793 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -740,6 +740,7 @@ libxl_device_virtio =3D Struct("device_virtio", [ ("backend_domname", string), ("type", string), ("transport", libxl_virtio_transport), + ("grant_usage", libxl_defbool), ("devid", libxl_devid), # Note that virtio-mmio parameters (irq and base) are for internal # use by libxl and can't be modified. diff --git a/tools/libs/light/libxl_virtio.c b/tools/libs/light/libxl_virti= o.c index f8a78e22d156..19d834984777 100644 --- a/tools/libs/light/libxl_virtio.c +++ b/tools/libs/light/libxl_virtio.c @@ -23,8 +23,16 @@ static int libxl__device_virtio_setdefault(libxl__gc *gc= , uint32_t domid, libxl_device_virtio *virtio, bool hotplug) { - return libxl__resolve_domid(gc, virtio->backend_domname, - &virtio->backend_domid); + int rc; + + rc =3D libxl__resolve_domid(gc, virtio->backend_domname, + &virtio->backend_domid); + if (rc < 0) return rc; + + libxl_defbool_setdefault(&virtio->grant_usage, + virtio->backend_domid !=3D LIBXL_TOOLSTACK_DO= MID); + + return 0; } =20 static int libxl__device_from_virtio(libxl__gc *gc, uint32_t domid, @@ -48,11 +56,13 @@ static int libxl__set_xenstore_virtio(libxl__gc *gc, ui= nt32_t domid, flexarray_t *ro_front) { const char *transport =3D libxl_virtio_transport_to_string(virtio->tra= nsport); + const char *grant_usage =3D libxl_defbool_to_string(virtio->grant_usag= e); =20 flexarray_append_pair(back, "irq", GCSPRINTF("%u", virtio->irq)); flexarray_append_pair(back, "base", GCSPRINTF("%#"PRIx64, virtio->base= )); flexarray_append_pair(back, "type", GCSPRINTF("%s", virtio->type)); flexarray_append_pair(back, "transport", GCSPRINTF("%s", transport)); + flexarray_append_pair(back, "grant_usage", GCSPRINTF("%s", grant_usage= )); =20 return 0; } @@ -104,6 +114,15 @@ static int libxl__virtio_from_xenstore(libxl__gc *gc, = const char *libxl_path, } } =20 + tmp =3D NULL; + rc =3D libxl__xs_read_checked(gc, XBT_NULL, + GCSPRINTF("%s/grant_usage", be_path), &tmp= ); + if (rc) goto out; + + if (tmp) { + libxl_defbool_set(&virtio->grant_usage, strtoul(tmp, NULL, 0)); + } + tmp =3D NULL; rc =3D libxl__xs_read_checked(gc, XBT_NULL, GCSPRINTF("%s/type", be_path), &tmp); diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 1f6f47daf4e1..c66b11fd01b2 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1215,6 +1215,8 @@ static int parse_virtio_config(libxl_device_virtio *v= irtio, char *token) } else if (MATCH_OPTION("transport", token, oparg)) { rc =3D libxl_virtio_transport_from_string(oparg, &virtio->transpor= t); if (rc) return rc; + } else if (MATCH_OPTION("grant_usage", token, oparg)) { + libxl_defbool_set(&virtio->grant_usage, strtoul(oparg, NULL, 0)); } else { fprintf(stderr, "Unknown string \"%s\" in virtio spec\n", token); return -1; --=20 2.31.1.272.g89b43f80a514