From patchwork Mon Apr 29 13:42:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Barnes X-Patchwork-Id: 13646996 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 4C515C19F4F for ; Mon, 29 Apr 2024 13:43:02 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714081.1115076 (Exim 4.92) (envelope-from ) id 1s1RHQ-0006jJ-PS; Mon, 29 Apr 2024 13:42:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714081.1115076; Mon, 29 Apr 2024 13:42:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1RHQ-0006jC-Mj; Mon, 29 Apr 2024 13:42:52 +0000 Received: by outflank-mailman (input) for mailman id 714081; Mon, 29 Apr 2024 13:42:51 +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 1s1RHP-0006Ul-6a for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 13:42:51 +0000 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [2a00:1450:4864:20::431]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5e21342a-062e-11ef-909b-e314d9c70b13; Mon, 29 Apr 2024 15:42:49 +0200 (CEST) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-343e46ec237so3808001f8f.2 for ; Mon, 29 Apr 2024 06:42:49 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net (default-46-102-197-201.interdsl.co.uk. [46.102.197.201]) by smtp.gmail.com with ESMTPSA id f2-20020a5d50c2000000b0034c5b28c264sm8530404wrt.16.2024.04.29.06.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 06:42:48 -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: 5e21342a-062e-11ef-909b-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1714398168; x=1715002968; 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=GPqHn0dROWWlXbauIG0GZlybXJNpXzvYnmQkiXmKdag=; b=Y7mzQaickKA/96c18jM72TBpHtdS4VD/64OubHzTkEbYF5t9a9R9Lk0vd76U0UmvM4 wNkoGdxaIPatndRBH0M6paWjcrtrodsJNEAqidrO1oB39TfyC0s8jL5Yy+PCTE+2QnvR 0WmDRuQjZAXEh19CXUxj8hm7WjftqtasB95UI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714398168; x=1715002968; 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=GPqHn0dROWWlXbauIG0GZlybXJNpXzvYnmQkiXmKdag=; b=IUCaqMVPx0TtQqo7IulJfm6qQN/PqJHIlBgvT4DavWhP9g1u9gR4QtpL6JPndVR0p1 K4ACSMWLwQNHFwqRlJ9SdzWvW8KgwWJYT1GbnmEKNeGOJ7+QvgT6BL1zkiDiAVNhNRDa 5Ghld7OsB5XjDZzf/QzBiR379orjTPXMAmKQWPWKn5ZxD2tGFwWaxVewZCOBADJeRAFK 5qm98gBOKz2uWyKDGamUR1C9VLlLX19ZcfnuUWFGDo78m+u4eXf9RsoxNlbzU8mxdLdG fmXAZ8rUGjxCgOOP6mAFogJWyt1Yx1QyXqZy2cYJWyBNMeBS+UrmRJLkJAKwZIXh5AUk KcQA== X-Gm-Message-State: AOJu0YxryRG6Nbz2CRyMXfB/8uTM9FtzntHSYkQ/1+ENz/20hi3KUbvK +FRpmfM2/d6R1NNo5DxykJ3mCJbuNiDvxbuVDP8TUervPLVONgwuACJB8sDEdcRnPMyNt0tAalv + X-Google-Smtp-Source: AGHT+IHahA4exGqGIr2Dz6YoO3IIAkAZOLXXSZT7eEQyuZVqKpnA7eN6sAKil+iHoNkGOMPdYbuqEA== X-Received: by 2002:a5d:64a4:0:b0:34d:1a30:1e48 with SMTP id m4-20020a5d64a4000000b0034d1a301e48mr2308587wrp.21.1714398168394; Mon, 29 Apr 2024 06:42:48 -0700 (PDT) From: Matthew Barnes To: xen-devel@lists.xenproject.org Cc: Matthew Barnes , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [XEN PATCH v2 1/2] evtchn: Add error status indicators for evtchn_status hypercall Date: Mon, 29 Apr 2024 14:42:41 +0100 Message-Id: <2f9544433fd9bb5c4b7ccccbacc27bc928f57dfb.1714148012.git.matthew.barnes@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 When the evtchn_status hypercall fails, it is not possible to determine the cause of the error, since the library call returns -1 to the tool and not the errno. Because of this, lsevtchn is unable to determine whether to continue event channel enumeration upon an evtchn_status hypercall error. Add error status indicators for the eventchn_status hypercall for lsevtchn to terminate its loop on, and keep other errors as failed hypercalls. Signed-off-by: Matthew Barnes --- xen/common/event_channel.c | 12 +++++++++++- xen/include/public/event_channel.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index aceee0695f9f..0f11e71c3e6f 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1030,7 +1030,17 @@ int evtchn_status(evtchn_status_t *status) d = rcu_lock_domain_by_any_id(dom); if ( d == NULL ) - return -ESRCH; + { + status->status = EVTCHNSTAT_dom_invalid; + return 0; + } + + if ( !port_is_valid(d, port) ) + { + status->status = EVTCHNSTAT_port_invalid; + rcu_unlock_domain(d); + return 0; + } chn = _evtchn_from_port(d, port); if ( !chn ) diff --git a/xen/include/public/event_channel.h b/xen/include/public/event_channel.h index 0d91a1c4afab..29cbf43945b3 100644 --- a/xen/include/public/event_channel.h +++ b/xen/include/public/event_channel.h @@ -200,6 +200,8 @@ struct evtchn_status { #define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */ #define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */ #define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */ +#define EVTCHNSTAT_dom_invalid 6 /* Given domain ID is not a valid domain */ +#define EVTCHNSTAT_port_invalid 7 /* Given port is not within valid range */ uint32_t status; uint32_t vcpu; /* VCPU to which this channel is bound. */ union { From patchwork Mon Apr 29 13:42:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Barnes X-Patchwork-Id: 13646995 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 B42F9C4345F for ; Mon, 29 Apr 2024 13:43:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714082.1115081 (Exim 4.92) (envelope-from ) id 1s1RHR-0006ln-1R; Mon, 29 Apr 2024 13:42:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714082.1115081; Mon, 29 Apr 2024 13:42:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1RHQ-0006lO-Ty; Mon, 29 Apr 2024 13:42:52 +0000 Received: by outflank-mailman (input) for mailman id 714082; Mon, 29 Apr 2024 13:42:51 +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 1s1RHP-0006Ul-SN for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 13:42:51 +0000 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [2a00:1450:4864:20::42a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5e912b64-062e-11ef-909b-e314d9c70b13; Mon, 29 Apr 2024 15:42:49 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-346b96f1483so2402924f8f.1 for ; Mon, 29 Apr 2024 06:42:49 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net (default-46-102-197-201.interdsl.co.uk. [46.102.197.201]) by smtp.gmail.com with ESMTPSA id f2-20020a5d50c2000000b0034c5b28c264sm8530404wrt.16.2024.04.29.06.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 06:42:48 -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: 5e912b64-062e-11ef-909b-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1714398169; x=1715002969; 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=Y7z726VbGboV43t8nEqdtfREavwTzKooElDgc93ukhU=; b=LOIp7wc24ZptYFYz8QWEwv8+pqSViQ9xykuPbnWdqG0hNMiaEjUZoVBzPLpA9+8Ur2 wcwJkkPpf4q9dq6pY+VTeDcExjcxaj8FfJsgJMP/mXAXZR5digeaFQnA+WYdJhH2jaEX /iRIE3PtiE5bcrADsDNXVDSRTV+7tfczS0X1I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714398169; x=1715002969; 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=Y7z726VbGboV43t8nEqdtfREavwTzKooElDgc93ukhU=; b=YzBOpWsO0blFt+E/zKkwiLMj8rWbsPwCo4eO4dUQueeUaRBbMveXRmqubqBlymzrqr F/cKeDACnqMY8RW3Tda3YmJulgIiEEr3+fbyrxAfJn37zk3qhS4ExOu7b/sMZ/FzVhSL haXQHb5wpEbG57HgSlrJjDNUoYSvOJ7GrFEQNs7djO6l76vRWeqwGLL2MGxSKCHKQpwh m4Q3MbQWIsEWdUM3cQ3cWVGPfuc4maNbEtGP7kLJJ471ym4MWJSl7BNt19WO6CHFfhm3 hXNb+OGibBb98LmC65NJdM+tsNQkwnQla9NarNTWyn2i1imHv+SDZAD/f53J+dspwX/Z 35NA== X-Gm-Message-State: AOJu0YwJHqd8DwJTou1Im1FhzIWigqoI596Pov5isP3mUKyskiKfLuU9 eqHQzRwidUMp8/pe2uO/1Yr2tlvgyNWV/6NKw+cQE2sXvzAd76V9LqNICUr6VNDlzcVZol3A2Hi + X-Google-Smtp-Source: AGHT+IHlUjjSE7LEnN3jRtwdG59ObMZHUaWo4/aiHbW6pTFes1yk3qYVLIAc0KTyx+Kra3j2j0Zj7g== X-Received: by 2002:adf:e912:0:b0:34c:e1c2:6281 with SMTP id f18-20020adfe912000000b0034ce1c26281mr3688500wrm.2.1714398169099; Mon, 29 Apr 2024 06:42:49 -0700 (PDT) From: Matthew Barnes To: xen-devel@lists.xenproject.org Cc: Matthew Barnes , Anthony PERARD , Jan Beulich Subject: [XEN PATCH v2 2/2] tools/lsevtchn: Use new status identifiers in loop Date: Mon, 29 Apr 2024 14:42:42 +0100 Message-Id: <83f66a419e0df15d23f0dd8e1e5680658d0c136d.1714148012.git.matthew.barnes@cloud.com> 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. Continue the loop even on hypercall errors, and use the new status identifiers for the evtchn_status hypercall, namely "port invalid" and "domain invalid", to determine when to break the loop. Signed-off-by: Matthew Barnes --- tools/xcutils/lsevtchn.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c index d1710613ddc5..4a48620cd72a 100644 --- a/tools/xcutils/lsevtchn.c +++ b/tools/xcutils/lsevtchn.c @@ -24,11 +24,20 @@ int main(int argc, char **argv) status.port = port; rc = xc_evtchn_status(xch, &status); if ( rc < 0 ) - break; + continue; if ( status.status == EVTCHNSTAT_closed ) continue; + if ( status.status == EVTCHNSTAT_dom_invalid ) + { + printf("Domain ID '%d' does not correspond to valid domain.\n", domid); + break; + } + + if ( status.status == EVTCHNSTAT_port_invalid ) + break; + printf("%4d: VCPU %u: ", port, status.vcpu); switch ( status.status )