From patchwork Tue Aug 15 21:06:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354326 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 1689DC04E69 for ; Tue, 15 Aug 2023 21:07:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584052.914472 (Exim 4.92) (envelope-from ) id 1qW1Fu-0005Eg-2N; Tue, 15 Aug 2023 21:07:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584052.914472; Tue, 15 Aug 2023 21:07:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qW1Ft-0005Cu-U2; Tue, 15 Aug 2023 21:07:09 +0000 Received: by outflank-mailman (input) for mailman id 584052; Tue, 15 Aug 2023 21:07:07 +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 1qW1Fr-0004qk-QH for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:07 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id af357fec-3baf-11ee-8776-cb3800f73035; Tue, 15 Aug 2023 23:07:05 +0200 (CEST) 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: af357fec-3baf-11ee-8776-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=//kMpvC6KAHT9QpCz/eo4st7+6bf1i4Hc4JRmfZsfK8=; b=bXyRPppo2A8AEjfZClnkZxytzLhjTFRVQVWmQycXYUmngiittifPdf4V IEAGMg/SWYRuNfs54TVwpvc/Te8hhdssYSu6Oi4G1drrJfbzaDLPiPajw mpTEC8jDIEb2QQfNC2MGsQNYfvBvZUlEXwrdUqcP8A8NEIICmWgebjLdO 4=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 119588439 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:gw76Ya4ugpWQLihruQL+mgxRtO3HchMFZxGqfqrLsTDasY5as4F+v jYfUGmDOv7fNzD9KdgjOYu0oRlSuJDVxtZqTws6+y9kHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9lU35ZwehBtC5gZlPaAS4QeE/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5m1 uYgNg0TXjO6jcms2Z+9U9l1oJwoI5y+VG8fkikIITDxCP8nRdbIQrnQ5M8e1zA17ixMNa+AP YxDM2MpNUmeJUQVYT/7C7pn9AusrlD5fydVtxS+oq0v7nKI5AdwzKLsIJzefdniqcB9xx/J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; d="scan'208";a="119588439" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , George Dunlap , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Henry Wang Subject: [PATCH v3 03/10] xen/version: Fold build_id handling into xenver_varbuf_op() Date: Tue, 15 Aug 2023 22:06:43 +0100 Message-ID: <20230815210650.2735671-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230815210650.2735671-1-andrew.cooper3@citrix.com> References: <20230815210650.2735671-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 struct xen_build_id and struct xen_varbuf are identical from an ABI point of view, so XENVER_build_id can reuse xenver_varbuf_op() rather than having it's own almost identical copy of the logic. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Henry Wang v2: * New --- xen/common/kernel.c | 49 +++++++++++------------------------- xen/include/public/version.h | 5 +++- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 79c008c7ee5f..4a051be1cbe0 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -504,9 +504,22 @@ static long xenver_varbuf_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) struct xen_varbuf user_str; const char *str = NULL; size_t sz; + int rc; switch ( cmd ) { + case XENVER_build_id: + { + unsigned int local_sz; + + rc = xen_build_id((const void **)&str, &local_sz); + if ( rc ) + return rc; + + sz = local_sz; + goto have_len; + } + case XENVER_extraversion2: str = xen_extra_version(); break; @@ -530,6 +543,7 @@ static long xenver_varbuf_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) sz = strlen(str); + have_len: if ( sz > KB(64) ) /* Arbitrary limit. Avoid long-running operations. */ return -E2BIG; @@ -731,41 +745,6 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) } case XENVER_build_id: - { - xen_build_id_t build_id; - unsigned int sz; - int rc; - const void *p; - - if ( deny ) - return -EPERM; - - /* Only return size. */ - if ( !guest_handle_is_null(arg) ) - { - if ( copy_from_guest(&build_id, arg, 1) ) - return -EFAULT; - - if ( build_id.len == 0 ) - return -EINVAL; - } - - rc = xen_build_id(&p, &sz); - if ( rc ) - return rc; - - if ( guest_handle_is_null(arg) ) - return sz; - - if ( sz > build_id.len ) - return -ENOBUFS; - - if ( copy_to_guest_offset(arg, offsetof(xen_build_id_t, buf), p, sz) ) - return -EFAULT; - - return sz; - } - case XENVER_extraversion2: case XENVER_capabilities2: case XENVER_changeset2: diff --git a/xen/include/public/version.h b/xen/include/public/version.h index 0dd6bbcb43cc..1022604daa41 100644 --- a/xen/include/public/version.h +++ b/xen/include/public/version.h @@ -124,8 +124,10 @@ typedef char xen_commandline_t[1024]; /* * Return value is the number of bytes written, or XEN_Exx on error. * Calling with empty parameter returns the size of build_id. + * + * Note: structure only kept for backwards compatibility. Xen operates in + * terms of xen_varbuf_t. */ -#define XENVER_build_id 10 struct xen_build_id { uint32_t len; /* IN: size of buf[]. */ unsigned char buf[XEN_FLEX_ARRAY_DIM]; @@ -164,6 +166,7 @@ typedef struct xen_varbuf xen_varbuf_t; * effect. e.g. Xen has no control over the formatting used for the command * line. */ +#define XENVER_build_id 10 #define XENVER_extraversion2 11 #define XENVER_capabilities2 12 #define XENVER_changeset2 13