From patchwork Thu Apr 11 15:24:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Barnes X-Patchwork-Id: 13626152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9D1FC4345F for ; Thu, 11 Apr 2024 15:25:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.703991.1100052 (Exim 4.92) (envelope-from ) id 1ruwIP-0000gC-NG; Thu, 11 Apr 2024 15:25:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 703991.1100052; Thu, 11 Apr 2024 15:25:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ruwIP-0000g3-KL; Thu, 11 Apr 2024 15:25:01 +0000 Received: by outflank-mailman (input) for mailman id 703991; Thu, 11 Apr 2024 15:24:59 +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 1ruwIN-0000Mi-SN for xen-devel@lists.xenproject.org; Thu, 11 Apr 2024 15:24:59 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a8a462ce-f817-11ee-b908-491648fe20b8; Thu, 11 Apr 2024 17:24:59 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-417d14c3426so6478195e9.3 for ; Thu, 11 Apr 2024 08:24:59 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net ([2.223.45.79]) by smtp.gmail.com with ESMTPSA id jg25-20020a05600ca01900b004169836bf9asm5719725wmb.23.2024.04.11.08.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 08:24:58 -0700 (PDT) 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: a8a462ce-f817-11ee-b908-491648fe20b8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1712849098; x=1713453898; darn=lists.xenproject.org; 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=OjuqnmWYV0nc4dRzJON3TQC6x9O1cypmz7qzf7KldJU=; b=J8e9dd9Qs/jrEfzG3dmy+ej+y6Us7J60Z6w3HCZreJOMKuedN01mB44Pj1xHGxOj7Z EvHEAnGP7ZEWoiLcXgVvqcbjMYzkkoJK7x//rYVoC7pM2ytfWFWcXlyH9Evhs+IjuPS3 mo7XX0lsUQ1cRsU4Rxh/D2s8YIWLabUy2Gfzs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712849098; x=1713453898; 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=OjuqnmWYV0nc4dRzJON3TQC6x9O1cypmz7qzf7KldJU=; b=xDAqtBEzyo9LGQbbrZAFFDednyLIeqQyNlEI/QfJAkJXz6UEO4PK8+iX8mSE2lC2dl uqvtHYl4a08alEwRya4IUhjB0E3sLU8799Y14FyyO5Gij7HLCerrq4dkFcERKNumFt7Y 4mYnXE6LDZOB1WGHR/qgYP8qawCES15dOiBgCqjSGKHq86ICdOXew3WhLJgAPiNYfkJo YD7CWU/Y2Mz1Art8A7lySOpg0m9kHI3PLewoyi0f8t0jku6SRkSv06VWIGRAnOu2tCQR W6LcOYVZbvhyvX40jGyuckzuDtKir2rlRhXzuHsZXJjqKZVK6fxSDp1ZAqblLOJ835qd 3aTA== X-Gm-Message-State: AOJu0YzT9OuRtrnlJFhsZj4aJRLTDjMlo1/cK+wyJVENaAgOAOsiqOpw xtQ1lSwRumi7YnXc4y1phQGEQaxmPjMBXwX3MDG6yEAifyi8EjEhG20P/4kA+/9pZDX6AwHjtYJ c X-Google-Smtp-Source: AGHT+IF8OOPAtok9GOT+TbeQfHXvMOoeh4PkWlDFuo7e+puuSsXRp7cXKM8ugkRAh/8/otE2eE1sYw== X-Received: by 2002:a05:600c:a10:b0:416:731e:4a26 with SMTP id z16-20020a05600c0a1000b00416731e4a26mr84206wmp.38.1712849098668; Thu, 11 Apr 2024 08:24:58 -0700 (PDT) From: Matthew Barnes To: Xen-devel Cc: Matthew Barnes , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [XEN PATCH 1/2] xen/domctl: Add highest allocated evtchn port to getdomaininfo Date: Thu, 11 Apr 2024 16:24:10 +0100 Message-Id: <55a9cc8fa53e57f898d05463746cbabda821ce25.1712840924.git.matthew.barnes@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 For tools such as lsevtchn to enumerate through event channels, they need an upper bound on the port number. Add the highest allocated event channel port number for a domain in the xen_domctl_getdomaininfo struct, and populate it. The field is added above the padding to avoid implicit padding. Signed-off-by: Matthew Barnes --- xen/common/domctl.c | 1 + xen/include/public/domctl.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 43b0b074c3a6..1d1ee17f6f91 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -73,6 +73,7 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info) info->domain = d->domain_id; info->max_vcpu_id = XEN_INVALID_MAX_VCPU_ID; + info->highest_evtchn_port = read_atomic(&d->valid_evtchns); /* * - domain is marked as blocked only if all its vcpus are blocked diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a33f9ec32b08..d28d29180c75 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -145,7 +145,8 @@ struct xen_domctl_getdomaininfo { xen_domain_handle_t handle; uint32_t cpupool; uint8_t gpaddr_bits; /* Guest physical address space size. */ - uint8_t pad2[7]; + uint8_t pad2[3]; + evtchn_port_t highest_evtchn_port; /* Highest allocated event channel port. Used for enumeration */ struct xen_arch_domainconfig arch_config; }; typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t; From patchwork Thu Apr 11 15:24:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Barnes X-Patchwork-Id: 13626153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CF6AC4345F for ; Thu, 11 Apr 2024 15:25:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.703992.1100062 (Exim 4.92) (envelope-from ) id 1ruwIQ-0000vb-Tm; Thu, 11 Apr 2024 15:25:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 703992.1100062; Thu, 11 Apr 2024 15:25:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ruwIQ-0000vS-Qp; Thu, 11 Apr 2024 15:25:02 +0000 Received: by outflank-mailman (input) for mailman id 703992; Thu, 11 Apr 2024 15:25:01 +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 1ruwIO-0000Mi-Vu for xen-devel@lists.xenproject.org; Thu, 11 Apr 2024 15:25:00 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a94b3a9d-f817-11ee-b908-491648fe20b8; Thu, 11 Apr 2024 17:25:00 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-343f1957ffcso637264f8f.0 for ; Thu, 11 Apr 2024 08:25:00 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net ([2.223.45.79]) by smtp.gmail.com with ESMTPSA id jg25-20020a05600ca01900b004169836bf9asm5719725wmb.23.2024.04.11.08.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 08:24:58 -0700 (PDT) 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: a94b3a9d-f817-11ee-b908-491648fe20b8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1712849099; x=1713453899; darn=lists.xenproject.org; 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=xMI7WvuqX+Ej2NliaNj//U1NPJxEWYxQSV37pRh8e88=; b=A54e6Qbi8vS0XHwDt5zEPlOxtmBD5qlokbEMDT3+gQgsS1kArRjYYh93wtlXmGiTtw QUAP/0hgGbsIeOHLp1fkvq0RLiY/T3/ivJd81apiSpjJ+NW05hUjin9M432CcNURgQcC 615sDvQRBubPKAM/HzblisNirAPqHuo2HC3sU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712849099; x=1713453899; 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=xMI7WvuqX+Ej2NliaNj//U1NPJxEWYxQSV37pRh8e88=; b=U1OSs1kUARYrFy/X8spjk+obmbFou4bdds3dw75H6x1TV46M+cFhPPsRSDJxUnBILS GLAfGgzfzdYZ56yASay8A9nIMFZjxa7Rolqos8g1XGPWl2JBO2LeTYTZ5HqNtJaNVD4U XAD4FC9FtzfCmiAG+7fgkRNitF247b1WMZ1qEUxRj2NLyOmWSQ8p6IL7fo8MovfVLCMi f47nqyz4Xm6YRvksPZwno8riZa/SxZCBCV62blOZQ6PVE/80pqlI1froFlWTDkJLy4jA xXRBrQppW5CvYLC9aIZG19TLVtfxfCKKBpjkkbsfSQFpx5kFxmg/n5GZTyS4VKvBbrOg EbMg== X-Gm-Message-State: AOJu0YyUc65SfdgR9LaVePRmoJNtO2Wunda/2mxgpCMH5SZMwUoVaqdh DJpyHnriGDcIglcWza17QUlA1lQts31+TihG4wLTzgQEhWPu3+AXoZkuwo+Oy0w8qGq34OZ3Wz3 6 X-Google-Smtp-Source: AGHT+IH9Mnb75ahazlimxXm3WRe8tx+doVjGN9xELFybPpFETKZAgljT3+Hbi7moF1U4URfho75FWA== X-Received: by 2002:adf:cc89:0:b0:343:8bd6:97cf with SMTP id p9-20020adfcc89000000b003438bd697cfmr2238148wrj.35.1712849099350; Thu, 11 Apr 2024 08:24:59 -0700 (PDT) From: Matthew Barnes To: Xen-devel Cc: Matthew Barnes , Anthony PERARD Subject: [XEN PATCH 2/2] tools/lsevtchn: Use evtchn port upper bound for evtchn enumeration Date: Thu, 11 Apr 2024 16:24:11 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 lsevtchn terminates the loop when the hypercall returns an error, even if there are still event channels with higher port numbers to be enumerated over. Use the highest allocated event channel port number for a given domain to bound the loop so that all relevant event channels can be enumerated over. Signed-off-by: Matthew Barnes --- tools/xcutils/lsevtchn.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c index d1710613ddc5..7f8ad7c8e7ce 100644 --- a/tools/xcutils/lsevtchn.c +++ b/tools/xcutils/lsevtchn.c @@ -11,6 +11,7 @@ int main(int argc, char **argv) xc_interface *xch; int domid, port, rc; xc_evtchn_status_t status; + xc_domaininfo_t info; domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0; @@ -18,13 +19,16 @@ int main(int argc, char **argv) if ( !xch ) errx(1, "failed to open control interface"); - for ( port = 0; ; port++ ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) + errx(1, "failed to fetch domain info"); + + for ( port = 0; port <= info.highest_evtchn_port; port++ ) { status.dom = domid; status.port = port; rc = xc_evtchn_status(xch, &status); if ( rc < 0 ) - break; + continue; if ( status.status == EVTCHNSTAT_closed ) continue;