From patchwork Tue Aug 15 21:06:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354324 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 EC49EC0015E for ; Tue, 15 Aug 2023 21:07:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584058.914536 (Exim 4.92) (envelope-from ) id 1qW1Fz-0006xI-4a; Tue, 15 Aug 2023 21:07:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584058.914536; Tue, 15 Aug 2023 21:07:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qW1Fy-0006wV-RZ; Tue, 15 Aug 2023 21:07:14 +0000 Received: by outflank-mailman (input) for mailman id 584058; Tue, 15 Aug 2023 21:07:13 +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 1qW1Fx-0004ge-OZ for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:13 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b3a99d6a-3baf-11ee-9b0c-b553b5be7939; Tue, 15 Aug 2023 23:07:11 +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: b3a99d6a-3baf-11ee-9b0c-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133631; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T+zneU/ODd9BEL6CProAShU+q6Ysw7Qx5ZvQuObYDv8=; b=fL+kq3irB6oK5cXs86k341plqlccLVufi5zKnRxd/N+Q/YlQ8Lc0jaOf 6ro+ZXsW0kXr97ht/RvEHSoxvCalu/Y4pZd1xwHkOLIsyb0WRMce1/8Kf rk2dlPCiA3ncDnbHEsRZw1RYqKL8aQQ8BuSyxtRNH5axK+A+/H96WVf+9 c=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 118253079 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:FoW9dqAbQG759xVW/2jkw5YqxClBgxIJ4kV8jS/XYbTApG4l1jVRx mZND2qCPanYYWPxLd92bdyy9E0DvceEzNIxQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsspvlDs15K6p4GNB4wRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw8OFXQmVw/ LsiazUGdg2+ieXtm46eY7w57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdHL2M1N3wsYDUWUrsTILs4kP2lmT/UdDpApUjOjaE2/3LS3Ep6172F3N/9I4XaH5gOxhnJz o7A1zTDU0krHdrP8AS+0imi2sifvXLBWo1HQdVU8dY12QbOlwT/EiY+RVa95PW0lEO6c9ZeM FAPvDojq7Ao806mRcW7WAe3yFamlBMBX9tbE8Uh9RqAjKHT5m6xHXMYRzRMbNgnss4eRjEw0 FKN2dTzClRHr7m9WX+bsLCOoluaOzURLGIETT8JS00C+daLiL80ihXDX9NyCpmfh9f+GSzz6 z2SpS14jLIW5eYM06i45lHGxTGxvJ/CTg0yzgrSV2OhqAh+YeaNfIWu4EPH5O1BK66DR0Gdu 2IJncef6u0DF5CLm2qGR+BlNLuk/eqfOTvQx1tmBYA89i+F8mSmO4tX5VlWBEpvKNdCRjbvb 2faowYX75hWVEZGdocuPdj3UZ5zi/G9S5K8DKu8gsdyjoZZfginvyVQbAmqnGXmiFURn6ZkY qu+WJP5ZZoFMphPwD2zTuYb9LYkwCEi2G/eLazGIwSbPam2PyDMF+pcWLeaRqVgtf7f/l2Jm zpKH5HSoyizRtESdcU+HWQ7CVkRZUY2CpntwyC8Xr7Se1E2cI3N5hK4/F/AR2CHt/4I/gsr1 ivnMqO99LYYrSSeQThmklg5NNvSsW9X9BrXxxAEM1eywGQEao2y9qoZfJZfVeB5pbY6l6IoH qZVIpXo7hFzptPvoWh1UHUAhNY6KETDafymbkJJnwTTj7Y/HleUq7cIjyPk9TUUDzrfiCfNi +TI6+8verJaH14KJJ+POJqSI6aZ4SB1dBRaAxGZfbG+uSzErOBXFsAGpqRqfpxQcU+dmWPyO sT/KU5wmNQharQdqLHh7Z1oZa/yeweiNiK2x1Xm0Is= IronPort-HdrOrdr: A9a23:AUFtM6gLq5abiX9dJqlp8Do1lHBQX5913DAbv31ZSRFFG/Fw9v re6cjzsCWe5gr5N0tBpTn+Atj9fZqxz/9ICOoqTMSftXfdyQmVxehZhOOJ/9SKIVycygcy79 YET0B0YOeAcmST5azBjDVReLwbr+VuP8qT6Nv2/jNVaUVPVokl1gF+D2+gYz9LrMstP+tGKH JZjPA31wZJvB4sH7WG7wI+Loz+juyOrovifRkFQzY/8WC1/EqVwY+/KQGcwhAdFxhSwbIumF K17jDR1+GYqvSmzR2Z8GfW4/1t6bzc4+oGPtWIls8WbhPzjQqyDb4RPYGqjXQOueSy71Rvqv ngyi1QR/hb2jfqZ2Sophmo4QX6zzo0zHfnxTaj8ADeiP28fis+F81Cwb1UaQHY7U1IhqAH7J 52 X-Talos-CUID: 9a23:Jv/u5mjvJT4nqUfBge6LarJIrjJueHr9j3PuKgiCSmNiUKCoR1jLo59Bup87 X-Talos-MUID: 9a23:X+/gTgYKHLx0kOBT5wW93ABLMpdR3Z+OU05RtsUm6vOGOnkl X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="118253079" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Oleksii Kurochko , Shawn Anastasio , Henry Wang Subject: [PATCH v3 01/10] xen/version: Calculate xen_capabilities_info once at boot Date: Tue, 15 Aug 2023 22:06:41 +0100 Message-ID: <20230815210650.2735671-2-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 The arch_get_xen_caps() infrastructure is horribly inefficient for something that is constant after features have been resolved on boot. Every instance used snprintf() to format constants into a string (which gets shorter when %d gets resolved!), and which get double buffered on the stack. Switch to using string literals with the "3.0" inserted - these numbers haven't changed in 18 years (The Xen 3.0 release was Dec 5th 2005). Use initcalls to format the data into xen_cap_info, which is deliberately not of type xen_capabilities_info_t because a 1k array is a silly overhead for storing a maximum of 77 chars (the x86 version) and isn't liable to need any more space in the forseeable future. This speeds up the the XENVER_capabilities hypercall, but the purpose of the change is to allow us to introduce a better XENVER_* API that doesn't force the use of a 1k buffer on the stack. Signed-off-by: Andrew Cooper Reviewed-by: Stefano Stabellini Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Oleksii Kurochko CC: Shawn Anastasio CC: Henry Wang v3: * CC new-arch folks so they're aware v2: * New Moving to __initcall() also allows new architectures to not implement this API, and I'm going to recommend strongly that they dont. Its a very dubious way of signalling about 3 bits of info to the toolstack, and inefficient to use (the toolstack has to do string parsing on the result figure out if PV64/PV32/HVM is available). --- xen/arch/arm/setup.c | 20 +++++++------------- xen/arch/x86/setup.c | 31 ++++++++++--------------------- xen/common/kernel.c | 3 ++- xen/include/xen/hypercall.h | 2 -- xen/include/xen/version.h | 2 ++ 5 files changed, 21 insertions(+), 37 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 44ccea03ca14..3592c9ebc1cd 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -1286,24 +1287,17 @@ void __init start_xen(unsigned long boot_phys_offset, switch_stack_and_jump(idle_vcpu[0]->arch.cpu_info, init_done); } -void arch_get_xen_caps(xen_capabilities_info_t *info) +static int __init init_xen_cap_info(void) { - /* Interface name is always xen-3.0-* for Xen-3.x. */ - int major = 3, minor = 0; - char s[32]; - - (*info)[0] = '\0'; - #ifdef CONFIG_ARM_64 - snprintf(s, sizeof(s), "xen-%d.%d-aarch64 ", major, minor); - safe_strcat(*info, s); + safe_strcat(xen_cap_info, "xen-3.0-aarch64 "); #endif if ( cpu_has_aarch32 ) - { - snprintf(s, sizeof(s), "xen-%d.%d-armv7l ", major, minor); - safe_strcat(*info, s); - } + safe_strcat(xen_cap_info, "xen-3.0-armv7l "); + + return 0; } +__initcall(init_xen_cap_info); /* * Local variables: diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 2bfc1fd00f8c..206f0c50a136 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -2049,35 +2049,24 @@ void __init noreturn __start_xen(unsigned long mbi_p) unreachable(); } -void arch_get_xen_caps(xen_capabilities_info_t *info) +static int __init cf_check init_xen_cap_info(void) { - /* Interface name is always xen-3.0-* for Xen-3.x. */ - int major = 3, minor = 0; - char s[32]; - - (*info)[0] = '\0'; - if ( IS_ENABLED(CONFIG_PV) ) { - snprintf(s, sizeof(s), "xen-%d.%d-x86_64 ", major, minor); - safe_strcat(*info, s); + safe_strcat(xen_cap_info, "xen-3.0-x86_64 "); if ( opt_pv32 ) - { - snprintf(s, sizeof(s), "xen-%d.%d-x86_32p ", major, minor); - safe_strcat(*info, s); - } + safe_strcat(xen_cap_info, "xen-3.0-x86_32p "); } if ( hvm_enabled ) - { - snprintf(s, sizeof(s), "hvm-%d.%d-x86_32 ", major, minor); - safe_strcat(*info, s); - snprintf(s, sizeof(s), "hvm-%d.%d-x86_32p ", major, minor); - safe_strcat(*info, s); - snprintf(s, sizeof(s), "hvm-%d.%d-x86_64 ", major, minor); - safe_strcat(*info, s); - } + safe_strcat(xen_cap_info, + "hvm-3.0-x86_32 " + "hvm-3.0-x86_32p " + "hvm-3.0-x86_64 "); + + return 0; } +__initcall(init_xen_cap_info); int __hwdom_init xen_in_range(unsigned long mfn) { diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 52aa28762782..f822480a8ef3 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -30,6 +30,7 @@ enum system_state system_state = SYS_STATE_early_boot; static xen_commandline_t saved_cmdline; static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE; +char __ro_after_init xen_cap_info[128]; static int assign_integer_param(const struct kernel_param *param, uint64_t val) { @@ -537,7 +538,7 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) memset(info, 0, sizeof(info)); if ( !deny ) - arch_get_xen_caps(&info); + safe_strcpy(info, xen_cap_info); if ( copy_to_guest(arg, info, ARRAY_SIZE(info)) ) return -EFAULT; diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h index f307dfb59760..15b6be6ec818 100644 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -56,6 +56,4 @@ common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg); -void arch_get_xen_caps(xen_capabilities_info_t *info); - #endif /* __XEN_HYPERCALL_H__ */ diff --git a/xen/include/xen/version.h b/xen/include/xen/version.h index 93c58773630c..4856ad1b446d 100644 --- a/xen/include/xen/version.h +++ b/xen/include/xen/version.h @@ -19,6 +19,8 @@ const char *xen_deny(void); const char *xen_build_info(void); int xen_build_id(const void **p, unsigned int *len); +extern char xen_cap_info[128]; + #ifdef BUILD_ID void xen_build_init(void); int xen_build_id_check(const Elf_Note *n, unsigned int n_sz, From patchwork Tue Aug 15 21:06:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354332 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 28477C04FDF for ; Tue, 15 Aug 2023 21:07:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584049.914447 (Exim 4.92) (envelope-from ) id 1qW1Fq-0004gr-4d; Tue, 15 Aug 2023 21:07:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584049.914447; Tue, 15 Aug 2023 21:07:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qW1Fq-0004gk-0R; Tue, 15 Aug 2023 21:07:06 +0000 Received: by outflank-mailman (input) for mailman id 584049; Tue, 15 Aug 2023 21:07:05 +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 1qW1Fp-0004ge-3X for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:05 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ac71ad15-3baf-11ee-9b0c-b553b5be7939; Tue, 15 Aug 2023 23:07:01 +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: ac71ad15-3baf-11ee-9b0c-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=P9ncB1v6j5aDBItocB4oPyuTy7Lm3WylBJuWoQzKWS8=; b=e7ZXPq477sspb1lpBr2Jt3ajwXjbU8QbI6A229VcnV0Rv34tIZ0Q5dSG bkdDXQ/FObi9LDfF41tu1GWymRq0J1xEY17chDPbgVJh+38wkZr39J/lM dWwVWzweXiMJOy6WXDSx4KDsSRF48/KfT5r7rTlpA4KwfPLbiJf8QxB8I Q=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 119453627 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:Q3f6pKr+6otI6kBKMuoTbArxgXFeBmKEZRIvgKrLsJaIsI4StFCzt garIBmHbv+JazCjedx3Pd+/8h9X6pKDmt81TgZo+S4xF3hD85uZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GpwUmAWP6gR5weOziRNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAHMNSRWxg7O7+ZvhdLdD3dwCAZn7OoxK7xmMzRmBZRonaZXKQqGM7t5ExjYgwMtJGJ4yZ eJAN2ApNk6ZJUQSZBFOUslWcOSA3xETdxVxrl6PqLVxyG/U1AFri5DmMcbPe8zMTsJQ9qqdj jufrjikWU9Aa7RzzxKE6mi2l+bM2hjiWYQ1TIHl0P1Lh3Ockzl75Bo+CgLg/KjRZlSFc8JSL QkY9zQjqYA29Ve3VZ/tUhugunmGsxUAHd1KHIUS6giLxrDF/gWxCW0NTzoHY9sj3OcUbzE30 l6Cn/vyGCdi9raSTBq17ayIpDm/PSwUK24qZiIeSwYBpd75r+kbkRbnXttlVqmvgbXdGyz0w j2MhDgzgfMUl8Fj/6m08V3ImTuEuonCTglz4B7eGG2i8GtRaJa+Yo206XDS9ftaMJuCVV6Fo WQFnM6FqusJCPmltCGLWvRLI7iv6N6MKjiaillqd6TN7Bz0pSTlJ9oJpmgjegEwaJ1slSLVj FH7+gN24a1XbXaTRPVJPa3qE+UHnbjmGoGwPhzLVeZmbp90fQ6B2ShhY0+Mwmzg+HQRfbED1 YSzKpj1UytDYUhz5H/vHrpGj+d3rswr7TmLLa0X2ShLxlZ3iJS9bb4eeGWDYekihE9viFWEq o0PXydmJvg2bQEfXsU12dRORbzpBSJhbXwTlyCwXrfaSjeK4El7V5fsLUoJIuSJZZh9mObS5 W2aUURF0lf5jnCvAVzUOyo6Mu+zDMkv9CJT0ckQ0bGAgSRLXGpSxP1HK8tfkUcPpYSPMsKYv 9FaIp7dU5yjuxzM+igHbImVkWCRXE3DuO56BAL8OGJXV8c5F2T0FirMIlOHGN8mUnDm6qPTY tSIimvmfHb0b18/UZuKMKjxkAvZULp0sLsaYnYk6+J7IC3EmLWG4QSo5hPrC6ng8Sn++wY= IronPort-HdrOrdr: A9a23:gIaeYq5NvEtfbXWBZwPXwPfXdLJyesId70hD6qm+c20tTiX4rb HXoB1/73XJYVkqKRQdcLy7Scu9qDbnhP1ICOoqXItKPjOW3FdARbsKheDfKn/bexEWndQtsp uIHZIObuEYzmIXsS852mSF+hobr+VvOZrHudvj X-Talos-CUID: 9a23:r9KSeW52AH9LUz3+mdsst04zH/IhI3Dk5S3ufWDjEUdEGK2TRgrF X-Talos-MUID: 9a23:h7scbQg0+Fn+NjYm/aAjAMMpNd9y+bWnCwc2iJQAnJG4aApzGjCzg2Hi X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="119453627" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jason Andryuk , George Dunlap , "Jan Beulich" , Stefano Stabellini , "Wei Liu" , Julien Grall , Daniel De Graaf , Daniel Smith , "Henry Wang" Subject: [PATCH v3 02/10] xen/version: Introduce non-truncating deterministically-signed XENVER_* subops Date: Tue, 15 Aug 2023 22:06:42 +0100 Message-ID: <20230815210650.2735671-3-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 Recently in XenServer, we have encountered problems caused by both XENVER_extraversion and XENVER_commandline having fixed bounds. More than just the invariant size, the APIs/ABIs also broken by typedef-ing an array, and using an unqualified 'char' which has implementation-specific signed-ness. Provide brand new ops, which are capable of expressing variable length strings, and mark the older ops as broken. This fixes all issues around XENVER_extraversion being longer than 15 chars. Further work beyond just this API is needed to remove other assumptions about XENVER_commandline being 1023 chars long. Signed-off-by: Andrew Cooper Reviewed-by: Jason Andryuk Acked-by: Daniel P. Smith --- CC: George Dunlap CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Daniel De Graaf CC: Daniel Smith CC: Jason Andryuk CC: Henry Wang v3: * Modify dummy.h's xsm_xen_version() in the same way as flask. v2: * Remove xen_capabilities_info_t from the stack now that arch_get_xen_caps() has gone. * Use an arbitrary limit check much lower than INT_MAX. * Use "buf" rather than "string" terminology. * Expand the API comment. Tested by forcing XENVER_extraversion to be 20 chars long, and confirming that an untruncated version can be obtained. --- xen/common/kernel.c | 62 +++++++++++++++++++++++++++++++++++ xen/include/public/version.h | 63 ++++++++++++++++++++++++++++++++++-- xen/include/xlat.lst | 1 + xen/include/xsm/dummy.h | 3 ++ xen/xsm/flask/hooks.c | 4 +++ 5 files changed, 131 insertions(+), 2 deletions(-) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index f822480a8ef3..79c008c7ee5f 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -24,6 +24,7 @@ CHECK_build_id; CHECK_compile_info; CHECK_feature_info; +CHECK_varbuf; #endif enum system_state system_state = SYS_STATE_early_boot; @@ -498,6 +499,59 @@ static int __init cf_check param_init(void) __initcall(param_init); #endif +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; + + switch ( cmd ) + { + case XENVER_extraversion2: + str = xen_extra_version(); + break; + + case XENVER_changeset2: + str = xen_changeset(); + break; + + case XENVER_commandline2: + str = saved_cmdline; + break; + + case XENVER_capabilities2: + str = xen_cap_info; + break; + + default: + ASSERT_UNREACHABLE(); + return -ENODATA; + } + + sz = strlen(str); + + if ( sz > KB(64) ) /* Arbitrary limit. Avoid long-running operations. */ + return -E2BIG; + + if ( guest_handle_is_null(arg) ) /* Length request */ + return sz; + + if ( copy_from_guest(&user_str, arg, 1) ) + return -EFAULT; + + if ( user_str.len == 0 ) + return -EINVAL; + + if ( sz > user_str.len ) + return -ENOBUFS; + + if ( copy_to_guest_offset(arg, offsetof(struct xen_varbuf, buf), + str, sz) ) + return -EFAULT; + + return sz; +} + long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { bool_t deny = !!xsm_xen_version(XSM_OTHER, cmd); @@ -711,6 +765,14 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) return sz; } + + case XENVER_extraversion2: + case XENVER_capabilities2: + case XENVER_changeset2: + case XENVER_commandline2: + if ( deny ) + return -EPERM; + return xenver_varbuf_op(cmd, arg); } return -ENOSYS; diff --git a/xen/include/public/version.h b/xen/include/public/version.h index cbc4ef7a46e6..0dd6bbcb43cc 100644 --- a/xen/include/public/version.h +++ b/xen/include/public/version.h @@ -19,12 +19,20 @@ /* arg == NULL; returns major:minor (16:16). */ #define XENVER_version 0 -/* arg == xen_extraversion_t. */ +/* + * arg == xen_extraversion_t. + * + * This API/ABI is broken. Use XENVER_extraversion2 where possible. + */ #define XENVER_extraversion 1 typedef char xen_extraversion_t[16]; #define XEN_EXTRAVERSION_LEN (sizeof(xen_extraversion_t)) -/* arg == xen_compile_info_t. */ +/* + * arg == xen_compile_info_t. + * + * This API/ABI is broken and truncates data. + */ #define XENVER_compile_info 2 struct xen_compile_info { char compiler[64]; @@ -34,10 +42,20 @@ struct xen_compile_info { }; typedef struct xen_compile_info xen_compile_info_t; +/* + * arg == xen_capabilities_info_t. + * + * This API/ABI is broken. Use XENVER_capabilities2 where possible. + */ #define XENVER_capabilities 3 typedef char xen_capabilities_info_t[1024]; #define XEN_CAPABILITIES_INFO_LEN (sizeof(xen_capabilities_info_t)) +/* + * arg == xen_changeset_info_t. + * + * This API/ABI is broken. Use XENVER_changeset2 where possible. + */ #define XENVER_changeset 4 typedef char xen_changeset_info_t[64]; #define XEN_CHANGESET_INFO_LEN (sizeof(xen_changeset_info_t)) @@ -95,6 +113,11 @@ typedef struct xen_feature_info xen_feature_info_t; */ #define XENVER_guest_handle 8 +/* + * arg == xen_commandline_t. + * + * This API/ABI is broken. Use XENVER_commandline2 where possible. + */ #define XENVER_commandline 9 typedef char xen_commandline_t[1024]; @@ -110,6 +133,42 @@ struct xen_build_id { }; typedef struct xen_build_id xen_build_id_t; +/* + * Container for an arbitrary variable length buffer. + */ +struct xen_varbuf { + uint32_t len; /* IN: size of buf[] in bytes. */ + unsigned char buf[XEN_FLEX_ARRAY_DIM]; /* OUT: requested data. */ +}; +typedef struct xen_varbuf xen_varbuf_t; + +/* + * arg == xen_varbuf_t + * + * Equivalent to the original ops, but with a non-truncating API/ABI. + * + * These hypercalls can fail for a number of reasons. All callers must handle + * -XEN_xxx return values appropriately. + * + * Passing arg == NULL is a request for size, which will be signalled with a + * non-negative return value. Note: a return size of 0 may be legitimate for + * the requested subop. + * + * Otherwise, the input xen_varbuf_t provides the size of the following + * buffer. Xen will fill the buffer, and return the number of bytes written + * (e.g. if the input buffer was longer than necessary). + * + * Some subops may return binary data. Some subops may be expected to return + * textural data. These are returned without a NUL terminator, and while the + * contents is expected to be ASCII/UTF-8, Xen makes no guarentees to this + * effect. e.g. Xen has no control over the formatting used for the command + * line. + */ +#define XENVER_extraversion2 11 +#define XENVER_capabilities2 12 +#define XENVER_changeset2 13 +#define XENVER_commandline2 14 + #endif /* __XEN_PUBLIC_VERSION_H__ */ /* diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst index 9c41948514bf..a61ba85ed0ca 100644 --- a/xen/include/xlat.lst +++ b/xen/include/xlat.lst @@ -173,6 +173,7 @@ ? build_id version.h ? compile_info version.h ? feature_info version.h +? varbuf version.h ? xenoprof_init xenoprof.h ? xenoprof_passive xenoprof.h ? flask_access xsm/flask_op.h diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 8671af1ba4d3..a4a920f74e6e 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -828,9 +828,12 @@ static XSM_INLINE int cf_check xsm_xen_version(XSM_DEFAULT_ARG uint32_t op) block_speculation(); return 0; case XENVER_extraversion: + case XENVER_extraversion2: case XENVER_compile_info: case XENVER_capabilities: + case XENVER_capabilities2: case XENVER_changeset: + case XENVER_changeset2: case XENVER_pagesize: case XENVER_guest_handle: /* These MUST always be accessible to any guest by default. */ diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 78225f68c15c..a671dcd0322e 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1777,15 +1777,18 @@ static int cf_check flask_xen_version(uint32_t op) /* These sub-ops ignore the permission checks and return data. */ return 0; case XENVER_extraversion: + case XENVER_extraversion2: return avc_has_perm(dsid, SECINITSID_XEN, SECCLASS_VERSION, VERSION__XEN_EXTRAVERSION, NULL); case XENVER_compile_info: return avc_has_perm(dsid, SECINITSID_XEN, SECCLASS_VERSION, VERSION__XEN_COMPILE_INFO, NULL); case XENVER_capabilities: + case XENVER_capabilities2: return avc_has_perm(dsid, SECINITSID_XEN, SECCLASS_VERSION, VERSION__XEN_CAPABILITIES, NULL); case XENVER_changeset: + case XENVER_changeset2: return avc_has_perm(dsid, SECINITSID_XEN, SECCLASS_VERSION, VERSION__XEN_CHANGESET, NULL); case XENVER_pagesize: @@ -1795,6 +1798,7 @@ static int cf_check flask_xen_version(uint32_t op) return avc_has_perm(dsid, SECINITSID_XEN, SECCLASS_VERSION, VERSION__XEN_GUEST_HANDLE, NULL); case XENVER_commandline: + case XENVER_commandline2: return avc_has_perm(dsid, SECINITSID_XEN, SECCLASS_VERSION, VERSION__XEN_COMMANDLINE, NULL); case XENVER_build_id: 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+ zKWoz+oav0cHM3GwxSe1mi0v7/SvjL5AdtCOLnn9uE/1TV/wURMUUZLBDNXu8KRmkO4Ht5SN UEQ0i4vtrQpslymSMHnWB+1q2LCuQQTM/JSGeAn7ACGyoLP/h2UQGMDS1Zpc8c6vcU7QTgr0 F6hnN7zAzFr9rqPRhq16bO8vT60fy8PIgcqZzIATAYDy8nupsc0lB2nZvZuFrSkyOL8Hz7Yy iqP6iM5gt0uYdUjjvvhuwqd2nT1+8aPF1RujunKYo67xiBjXJCYebyL0FLw9+9tKp+pV3/Zt 3dRzqBy89syJZ2KkSWMRsAEE7eo++uJPVXgvLJ/I3Uy32/zoiD+JOi89Bk7fR40aZhcJVcFd WeJ4WtsCIlv0GxGhEOdS6a4EIwUwKfpDrwJvdiEP4MVMvCdmOJqlRyChHJ8PUi3zSDAcollY /93lPpA6l5DUMxaIMKeHbt17FPS7nlWKZnvbZ761Q+79rGVeWSYT7wIWHPXMLFjtfnY/FSKo 48PXydv9/m4eLeiChQ7DKZJdQxaRZTFLcGeRzNrmh6rfVM9RTBJ5w75yrI9YY1195m5Zc+Rl kxRrnRwkQKl7VWecFXiV5yWQO+3NXqJhS5hbHNE0JfB8yRLXLtDG49EKsZqIeF9qrM7pRO2J tFcE/i97j10Ymyv01wggVPV9eSOqDzDadqyAheY IronPort-HdrOrdr: A9a23:oMoVKKlFYxSjL0FPr4YlXLzQX6/pDfIU3DAbv31ZSRFFG/Fxl6 iV8sjzsiWE7gr5OUtQ4exoV5PhfZqxz/JICMwqTNKftWrdyQyVxeNZnOjfKlTbckWUnINgPO VbAsxD4bXLfCFHZK3BgTVQfexO/DD+ytHLudvj X-Talos-CUID: 9a23:m01ujWoXx3qaaqPFbS/eFW7mUeM/SmPg0kfzGkWTE39ETqSlUHnI86wxxg== X-Talos-MUID: 9a23:rtA+UQ9v1Yjl3h1VV7Sd1uiQf9Yx6Yq1LFoVqMUbmNiGbHUgFzPCjCviFw== X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; 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 From patchwork Tue Aug 15 21:06:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354330 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 102A4C04E69 for ; Tue, 15 Aug 2023 21:07:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584055.914491 (Exim 4.92) (envelope-from ) id 1qW1Fv-0005dC-AU; Tue, 15 Aug 2023 21:07:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584055.914491; Tue, 15 Aug 2023 21:07:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qW1Fv-0005av-3S; Tue, 15 Aug 2023 21:07:11 +0000 Received: by outflank-mailman (input) for mailman id 584055; Tue, 15 Aug 2023 21:07:09 +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 1qW1Ft-0004qk-Kq for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:09 +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 b0d4e002-3baf-11ee-8776-cb3800f73035; Tue, 15 Aug 2023 23:07:07 +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: b0d4e002-3baf-11ee-8776-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qzXigZ6hXPFsDOHOuxIekBwLTryZ1iaTCSKXT6kUlnI=; b=LOAthxilyAE/ata8/q8UqQ02quS/uUyvPCQP/wOLxZKNaJEnJc+uH0Fd sX+FxojshNljcR56wB/muu3gBh4MPYUWf17mhZNzVruekIh6ZdPO5TghS 1RmA1T5YlR6DI7QnlHn6ay0ON+HquTAOPCEiZLb4msBv9P0FpiD+TiPVQ Q=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 119588440 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:8jSiAqJ4shr4rEbhFE+RTZUlxSXFcZb7ZxGr2PjKsXjdYENS1jMPz TBOXGjUaayLNGCge9x2bIS/8hkPv8LSytMyQAJlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrawP9TlK6q4mhA7gVjPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5UG1lQy OIoCwkHRQqaquSv8KudEuJj05FLwMnDZOvzu1llxDDdS/0nXYrCU+PB4towMDUY354UW6yEP oxANGQpNU6bC/FMEg5/5JYWteGknHTgNRZfr0qYv/Ef6GnP1g1hlrPqNbI5f/TTHJQIzhbE+ jquE2LRBj1FGe2x5zm5zVGGiMrFwQDWVokLPejtnhJtqALKnTFCYPEMbnOrrP/8hkOgVtZ3L 00P5jFovaU07FasTNT2Q1u/unHslhwWVsdUEuY6wBqQ0aeS6AGcbkAfVSJIYtEisM4wRBQp2 0WPktevAiZg2JWKTVqN+7HSqim9UQAXMGsDaCksXQYDpd75r+kbgh3DQ9l5GYapn9b1Hnf22 DnMoy8g750fldUO1rm71Vnfjiiwu4PSSQoo+gTQWHnj5QR8DKanboqk80nG7t5PKY+YSh+Ku 31ss+iT6vofS66EkiOlSf8IWrqu4p643Cb02AA1WcN7rnL0piDlJNoLiN1jGKt3GuUeQSHUf n/wgAl6/oZ+OmKadIkvaI3kXqzG0pPcPdjiU/nVaP9HbZ5waBKL8UlSWKKA44z+uBNyyP9iY P93Ze7pVC9HUvo/kFJaUs9HidcWKjYCKXQ/rHwR5zCuyvKgaXGcUt/p23PeP7livMtoTOg4m uuz1vdmKT0FDYUSgQGNq+b/yGzmylBiXPjLRzR/LLLrH+afMDhJ5wXt6b0gYZd5uK9ei/3F+ HqwMmcBlgul3CebdVTVOikzAF8KYXqYhShnVRHAwH7ygyRzCWpRxPZ3m2QLkUkPq7U4kK8co wgtcMScGPVfIgkrCBxEBaQRWLdKLUzx7SrXZnrNXdTKV8I4L+A/0oO+L1SHGehnJnbfiPbSV JX7i16GHcJZGVs6ZCsUAdr2p26MUbEmsLoadyP1zhN7IS0ALKACx/TNs8IK IronPort-HdrOrdr: A9a23:Wm07g6xZ8HR7p8MaK0beKrPwFL1zdoMgy1knxilNoRw8SKKlfq eV7ZImPH7P+U4ssR4b+exoVJPtfZqYz+8R3WBzB8bEYOCFghrKEGgK1+KLqFeMJ8S9zJ846U 4JSdkGNDSaNzlHZKjBjzVQa+xQouW6zA== X-Talos-CUID: 9a23:Ny2t0G43/rFL4S2LZ9ss11QsBP07Ql7kxlzKOmK+EFZwbuWeRgrF X-Talos-MUID: 9a23:7q7u5AUW1BcUaY7q/DvA2xxTGulr35uNIk4om8kllsePLAUlbg== X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="119588440" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , George Dunlap , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Daniel De Graaf , Daniel Smith , "Jason Andryuk" , Henry Wang Subject: [PATCH v3 04/10] xen/version: Misc style fixes Date: Tue, 15 Aug 2023 22:06:44 +0100 Message-ID: <20230815210650.2735671-5-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 No functional change. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Reviewed-by: Daniel P. Smith --- CC: George Dunlap CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Daniel De Graaf CC: Daniel Smith CC: Jason Andryuk CC: Henry Wang --- xen/common/kernel.c | 11 +++++------ xen/common/version.c | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 4a051be1cbe0..24e778a44f7b 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -1,6 +1,6 @@ /****************************************************************************** * kernel.c - * + * * Copyright (c) 2002-2005 K A Fraser */ @@ -568,7 +568,7 @@ static long xenver_varbuf_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { - bool_t deny = !!xsm_xen_version(XSM_OTHER, cmd); + bool deny = xsm_xen_version(XSM_OTHER, cmd); switch ( cmd ) { @@ -612,7 +612,7 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) return -EFAULT; return 0; } - + case XENVER_platform_parameters: { const struct vcpu *curr = current; @@ -651,9 +651,8 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) } return 0; - } - + case XENVER_changeset: { xen_changeset_info_t chgset; @@ -680,7 +679,7 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( VM_ASSIST(d, pae_extended_cr3) ) fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb); if ( paging_mode_translate(d) ) - fi.submap |= + fi.submap |= (1U << XENFEAT_writable_page_tables) | (1U << XENFEAT_auto_translated_physmap); if ( is_hardware_domain(d) ) diff --git a/xen/common/version.c b/xen/common/version.c index d32013520863..8e738672debe 100644 --- a/xen/common/version.c +++ b/xen/common/version.c @@ -209,11 +209,11 @@ void __init xen_build_init(void) } } } -#endif +#endif /* CONFIG_X86 */ if ( !rc ) printk(XENLOG_INFO "build-id: %*phN\n", build_id_len, build_id_p); } -#endif +#endif /* BUILD_ID */ /* * Local variables: * mode: C From patchwork Tue Aug 15 21:06:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354323 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 5EE79C001E0 for ; Tue, 15 Aug 2023 21:07:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584056.914512 (Exim 4.92) (envelope-from ) id 1qW1Fw-0006Cc-QS; Tue, 15 Aug 2023 21:07:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584056.914512; Tue, 15 Aug 2023 21:07:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qW1Fw-0006Bo-FT; Tue, 15 Aug 2023 21:07:12 +0000 Received: by outflank-mailman (input) for mailman id 584056; Tue, 15 Aug 2023 21:07:10 +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 1qW1Fu-0004qk-LA for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:10 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b094ce54-3baf-11ee-8776-cb3800f73035; Tue, 15 Aug 2023 23:07:07 +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: b094ce54-3baf-11ee-8776-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133627; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pvCFpUc1O5soqHuUC/SvS++8o+N6bC9fqekuul4E2RI=; b=JMn/SVA5PuSUjdewXO2mLE+RiIegbHMtYmxy4C0k1JCFdi6vf8XBHL4B VUqzfFzsctw9rjB4uqqdOag5RwX0he1Fx8YkEIW5RbFfc8dK+vK9tysRL fIx7FNOktEDzeLwXGtc1XCoS0iNRCVgRA49sJEvyKn/BGrcYwu7a/bbUb M=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 118850005 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:xvg/FKDNpFKUchVW/z7jw5YqxClBgxIJ4kV8jS/XYbTApDkh0TYHn 2RKWD+DP6rZM2X0f49xOYTl8EsPu8WDyoIxQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsspvlDs15K6p4GNB4wRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwp/Z5LV1qy vciBgtcPhu9ve+a3qC/Vbw57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdHL2M1N3wsYDUWUrsTILs4kP2lmT/UdDpApUjOjaE2/3LS3Ep6172F3N/9I4XaFZgNxh7Fz o7A1zm6WhNFD+O28hSY+3yTgODskgjxYqtHQdVU8dY12QbOlwT/EiY+RVa95PW0lEO6c9ZeM FAPvDojq7Ao806mRcW7WAe3yFabujYMVtwWFPc1gCmPxbDT+B2xHXUfQ3hKb9lOiSMtbWV0j BnTxYqvXGEx9uTPEhpx64t4sxvvKSY5EUs9bhUqdlpV6OfZra0tnBbQG4ML/LGOsvX5HjT5w javpSc4hqkOgcNj65hX7WwrkBr3+MGXE1ddChH/Gzv8s1gnPNLNi5mAswCz0BpWEGqOorBtV lAgktPW0u0BBIrleMelELRUR+HBCxpo3VThbb9T83sJrWnFF52LJ9o4DNRCyKBBa59sRNMRS BWP0T69HbcKVJdQUYd5YpiqF+MhxrX6GNLuW5j8N4QfOMErKFPWo3E3NSZ8OlwBd2B2zckC1 WqzK57wXR7294w2pNZJewvt+eBynX1vrY8ibZv60w6mwdKjiI29EN843K+1Rrlhtsus+VyFm +uzwuPWk32zpsWiOHiImWPSRHhWRUUG6Wfe8JEKK7LbeFQ5QAnMyZb5mNscRmCspIwN/s+gw 513chUwJIbX7ZEfFTi3Vw== IronPort-HdrOrdr: A9a23:U805/K1+pLGA5+nhizu9lQqjBHYkLtp133Aq2lEZdPU0SKGlfq GV7ZEmPHrP4gr5N0tOpTntAse9qBDnhPxICOsqXYtKNTOO0AeVxelZhrcKqAeQeBEWmNQ96U 9hGZIOcuEZDzJB/LvHCN/TKadd/DGFmprY+ts31x1WPGVXgzkL1XYANu6ceHcGIzVuNN4CO7 e3wNFInDakcWR/VLXBOpFUN9KzweEijfjdEGc7OyI= X-Talos-CUID: 9a23:gQU59Wygnj7WDSPzZpkjBgVJCs4JTlnix03+GB7oAlhTRZGLW1uPrfY= X-Talos-MUID: 9a23:hVBQaQ8V6/dY/r0uRVz4uY2Qf5oru6bxM38kqrsbsse7MyNTNByXth3iFw== X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="118850005" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Anthony PERARD , Wei Liu , Juergen Gross Subject: [PATCH v3 05/10] tools/libxc: Move xc_version() out of xc_private.c into its own file Date: Tue, 15 Aug 2023 22:06:45 +0100 Message-ID: <20230815210650.2735671-6-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 kexec-tools uses xc_version(), meaning that it is not a private API. As we're going to extend the functionality substantially, move it to its own file. Signed-off-by: Andrew Cooper Acked-by: Anthony PERARD --- CC: Wei Liu CC: Anthony PERARD CC: Juergen Gross --- tools/libs/ctrl/Makefile.common | 1 + tools/libs/ctrl/xc_private.c | 66 -------------------------- tools/libs/ctrl/xc_private.h | 7 --- tools/libs/ctrl/xc_version.c | 83 +++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 73 deletions(-) create mode 100644 tools/libs/ctrl/xc_version.c diff --git a/tools/libs/ctrl/Makefile.common b/tools/libs/ctrl/Makefile.common index 0a09c28fd369..4e3680c123f6 100644 --- a/tools/libs/ctrl/Makefile.common +++ b/tools/libs/ctrl/Makefile.common @@ -16,6 +16,7 @@ OBJS-y += xc_pm.o OBJS-y += xc_cpu_hotplug.o OBJS-y += xc_vm_event.o OBJS-y += xc_vmtrace.o +OBJS-y += xc_version.o OBJS-y += xc_monitor.o OBJS-y += xc_mem_paging.o OBJS-y += xc_mem_access.o diff --git a/tools/libs/ctrl/xc_private.c b/tools/libs/ctrl/xc_private.c index 6293a45531d8..fd4a13a57a9d 100644 --- a/tools/libs/ctrl/xc_private.c +++ b/tools/libs/ctrl/xc_private.c @@ -490,72 +490,6 @@ int xc_sysctl(xc_interface *xch, struct xen_sysctl *sysctl) return do_sysctl(xch, sysctl); } -int xc_version(xc_interface *xch, int cmd, void *arg) -{ - DECLARE_HYPERCALL_BOUNCE(arg, 0, XC_HYPERCALL_BUFFER_BOUNCE_OUT); /* Size unknown until cmd decoded */ - size_t sz; - int rc; - - switch ( cmd ) - { - case XENVER_version: - sz = 0; - break; - case XENVER_extraversion: - sz = sizeof(xen_extraversion_t); - break; - case XENVER_compile_info: - sz = sizeof(xen_compile_info_t); - break; - case XENVER_capabilities: - sz = sizeof(xen_capabilities_info_t); - break; - case XENVER_changeset: - sz = sizeof(xen_changeset_info_t); - break; - case XENVER_platform_parameters: - sz = sizeof(xen_platform_parameters_t); - break; - case XENVER_get_features: - sz = sizeof(xen_feature_info_t); - break; - case XENVER_pagesize: - sz = 0; - break; - case XENVER_guest_handle: - sz = sizeof(xen_domain_handle_t); - break; - case XENVER_commandline: - sz = sizeof(xen_commandline_t); - break; - case XENVER_build_id: - { - xen_build_id_t *build_id = (xen_build_id_t *)arg; - sz = sizeof(*build_id) + build_id->len; - HYPERCALL_BOUNCE_SET_DIR(arg, XC_HYPERCALL_BUFFER_BOUNCE_BOTH); - break; - } - default: - ERROR("xc_version: unknown command %d\n", cmd); - return -EINVAL; - } - - HYPERCALL_BOUNCE_SET_SIZE(arg, sz); - - if ( (sz != 0) && xc_hypercall_bounce_pre(xch, arg) ) - { - PERROR("Could not bounce buffer for version hypercall"); - return -ENOMEM; - } - - rc = do_xen_version(xch, cmd, HYPERCALL_BUFFER(arg)); - - if ( sz != 0 ) - xc_hypercall_bounce_post(xch, arg); - - return rc; -} - unsigned long xc_make_page_below_4G( xc_interface *xch, uint32_t domid, unsigned long mfn) { diff --git a/tools/libs/ctrl/xc_private.h b/tools/libs/ctrl/xc_private.h index 8faabaea67f3..754da8840979 100644 --- a/tools/libs/ctrl/xc_private.h +++ b/tools/libs/ctrl/xc_private.h @@ -216,13 +216,6 @@ void xc__hypercall_buffer_cache_release(xc_interface *xch); * Hypercall interfaces. */ -static inline int do_xen_version(xc_interface *xch, int cmd, xc_hypercall_buffer_t *dest) -{ - DECLARE_HYPERCALL_BUFFER_ARGUMENT(dest); - return xencall2(xch->xcall, __HYPERVISOR_xen_version, - cmd, HYPERCALL_BUFFER_AS_ARG(dest)); -} - static inline int do_physdev_op(xc_interface *xch, int cmd, void *op, size_t len) { int ret = -1; diff --git a/tools/libs/ctrl/xc_version.c b/tools/libs/ctrl/xc_version.c new file mode 100644 index 000000000000..60e107dcee0b --- /dev/null +++ b/tools/libs/ctrl/xc_version.c @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ +/* + * xc_version.c + * + * Wrappers aound XENVER_* hypercalls + */ + +#include "xc_private.h" +#include + +static int do_xen_version(xc_interface *xch, int cmd, + xc_hypercall_buffer_t *dest) +{ + DECLARE_HYPERCALL_BUFFER_ARGUMENT(dest); + return xencall2(xch->xcall, __HYPERVISOR_xen_version, + cmd, HYPERCALL_BUFFER_AS_ARG(dest)); +} + +int xc_version(xc_interface *xch, int cmd, void *arg) +{ + DECLARE_HYPERCALL_BOUNCE(arg, 0, XC_HYPERCALL_BUFFER_BOUNCE_OUT); /* Size unknown until cmd decoded */ + size_t sz; + int rc; + + switch ( cmd ) + { + case XENVER_version: + sz = 0; + break; + case XENVER_extraversion: + sz = sizeof(xen_extraversion_t); + break; + case XENVER_compile_info: + sz = sizeof(xen_compile_info_t); + break; + case XENVER_capabilities: + sz = sizeof(xen_capabilities_info_t); + break; + case XENVER_changeset: + sz = sizeof(xen_changeset_info_t); + break; + case XENVER_platform_parameters: + sz = sizeof(xen_platform_parameters_t); + break; + case XENVER_get_features: + sz = sizeof(xen_feature_info_t); + break; + case XENVER_pagesize: + sz = 0; + break; + case XENVER_guest_handle: + sz = sizeof(xen_domain_handle_t); + break; + case XENVER_commandline: + sz = sizeof(xen_commandline_t); + break; + case XENVER_build_id: + { + xen_build_id_t *build_id = (xen_build_id_t *)arg; + sz = sizeof(*build_id) + build_id->len; + HYPERCALL_BOUNCE_SET_DIR(arg, XC_HYPERCALL_BUFFER_BOUNCE_BOTH); + break; + } + default: + ERROR("xc_version: unknown command %d\n", cmd); + return -EINVAL; + } + + HYPERCALL_BOUNCE_SET_SIZE(arg, sz); + + if ( (sz != 0) && xc_hypercall_bounce_pre(xch, arg) ) + { + PERROR("Could not bounce buffer for version hypercall"); + return -ENOMEM; + } + + rc = do_xen_version(xch, cmd, HYPERCALL_BUFFER(arg)); + + if ( sz != 0 ) + xc_hypercall_bounce_post(xch, arg); + + return rc; +} From patchwork Tue Aug 15 21:06:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354325 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 E916FC04A94 for ; Tue, 15 Aug 2023 21:07:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584050.914457 (Exim 4.92) (envelope-from ) id 1qW1Fr-0004vt-Gt; Tue, 15 Aug 2023 21:07:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584050.914457; Tue, 15 Aug 2023 21:07:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qW1Fr-0004vm-E0; Tue, 15 Aug 2023 21:07:07 +0000 Received: by outflank-mailman (input) for mailman id 584050; Tue, 15 Aug 2023 21:07:06 +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 1qW1Fq-0004ge-6g for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:06 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id af2461fc-3baf-11ee-9b0c-b553b5be7939; Tue, 15 Aug 2023 23:07:04 +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: af2461fc-3baf-11ee-9b0c-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UfkZMvSTOydVLRxmNKDfbvQp7DAjMWPXLA54Fw2pmto=; b=ijKlaDeGUs13HcRyMUVCGSOtvCd+A6K8N2Ev563mfVWFvgGSFmuIt0wL cukszLs9/vBBThz+WUoFauWvjOIABGqX6GsEC2IbqE0X7JnSrUUox9eVM V3T4P+oVlMnYOB+s8BD7BCqRFKttySQruuqo01aL8yGyz3+o5Jeu1y0xb 0=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 119453628 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:H1Vrx6IVD80HczSpFE+R95UlxSXFcZb7ZxGr2PjKsXjdYENS0jEAm zFOXzvUM6qLZDT9f9F+YIy2/EgH7ZfQzNdgQQplqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrawP9TlK6q4mhA7gVjPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c40AUZLx /hJJQkkNC7dqLmu4Z/rWu9j05FLwMnDZOvzu1llxDDdS/0nXYrCU+PB4towMDUY354UW6yEP oxANGQpNU6bC/FMEg5/5JYWteGknHTgNRZfr0qYv/Ef6GnP1g1hlrPqNbI5f/TTHJQJwx3G/ DKuE2LRXxU8ZIydzhO/0iy11ubtpzzpeY8OPejtnhJtqALKnTFCYPEMbnOrrP/8hkOgVtZ3L 00P5jFovaU07FasTNT2Q1u/unHslgEYc8pdFas98g7l4qjb+QGCHUAfUyVMLtchsaceSTU02 3eTktjuBDgpt6eaIU9x7Z/N82n0Y3JMazZfO2ldF1BtD8TfTJ8bzRLoS+RnQaOMp4fLRx6r2 xGn/Dg4iOBG5SIU7JmT8VfCijOqg5HGSA8p+wnaNl6YAhNFiJ2NPNLxtwWChRpUBMPAFwTa4 iBY8ySLxLpWZaxhghBhVwnk8FuBw/+eeAPRjld0d3XK32T8oiXzFWy8DdwXGauIDirmUWW0C KMwkVkLjHO2AJdNRfYuC79d8+xwkcDd+S3ND5g4lOZmbJlrbxOg9ypzf0OW1G2FuBFywPtmY 8vHIJn8VCZy5UFbIN2eHbt17FPW7npmmTO7qW7TnnxLLoZylFbKEOxYYTNin8gy7b+eoRW9z jqsH5Li9vmra8WnOnO/2ddKfTg3wY0TWcieRzp/KrTSfWKL2QgJV5fs/F/WU9c4wvkJzr2Wo SnVt40x4AOXuEAr4D6iMhhLAI4Dl74mxZ7nFUTA5WqV5kU= IronPort-HdrOrdr: A9a23:AqPREaCW22JhPBblHemT55DYdb4zR+YMi2TDGXoBMCC9E/bo7/ xG+c5w6faaskd1ZJhNo6HjBEDEewK+yXcX2+gs1NWZLW3bUQKTRekI0WKh+V3d8kbFh4lgPM lbAs5D4R7LYWSST/yW3OB1KbkdKRC8npyVuQ== X-Talos-CUID: 9a23:3/37WWH4VcIZJng7qmIk9GkRKMR0f0T0lkmODBSgKEs5WLuaHAo= X-Talos-MUID: 9a23:EI/1GQrolkXybKTE5Xsez2xmEpc44aOHMmBTiMUPmfObJw19Jx7I2Q== X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="119453628" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Anthony PERARD , Christian Lindig , Wei Liu , Juergen Gross , David Scott , Edwin Torok , Rob Hoes Subject: [PATCH v3 06/10] tools: Introduce a non-truncating xc_xenver_extraversion() Date: Tue, 15 Aug 2023 22:06:46 +0100 Message-ID: <20230815210650.2735671-7-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 ... which uses XENVER_extraversion2. In order to do sensibly, use manual hypercall buffer handling. Not only does this avoid an extra bounce buffer (we need to strip the xen_varbuf_t header anyway), it's also shorter and easlier to follow. Update libxl and the ocaml stubs to match. No API/ABI change in either. With this change made, `xl info` can now correctly access a >15 char extraversion: # xl info xen_version 4.18-unstable+REALLY LONG EXTRAVERSION Signed-off-by: Andrew Cooper Acked-by: Anthony PERARD Acked-by: Christian Lindig --- CC: Wei Liu CC: Anthony PERARD CC: Juergen Gross CC: Christian Lindig CC: David Scott CC: Edwin Torok CC: Rob Hoes Note: There is a marginal risk for a memory leak in the ocaml bindings, but it turns out we have the same bug elsewhere and fixing that is going to be rather complicated. --- tools/include/xenctrl.h | 6 +++ tools/libs/ctrl/xc_version.c | 75 +++++++++++++++++++++++++++++ tools/libs/light/libxl.c | 4 +- tools/ocaml/libs/xc/xenctrl_stubs.c | 9 ++-- 4 files changed, 87 insertions(+), 7 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index faec1dd82453..b839196bf4c4 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1593,6 +1593,12 @@ long xc_memory_op(xc_interface *xch, unsigned int cmd, void *arg, size_t len); int xc_version(xc_interface *xch, int cmd, void *arg); +/* + * Wrappers around XENVER_* subops. Callers must pass the returned pointer to + * free(). + */ +char *xc_xenver_extraversion(xc_interface *xch); + int xc_flask_op(xc_interface *xch, xen_flask_op_t *op); /* diff --git a/tools/libs/ctrl/xc_version.c b/tools/libs/ctrl/xc_version.c index 60e107dcee0b..2c14474feec5 100644 --- a/tools/libs/ctrl/xc_version.c +++ b/tools/libs/ctrl/xc_version.c @@ -81,3 +81,78 @@ int xc_version(xc_interface *xch, int cmd, void *arg) return rc; } + +/* + * Raw hypercall wrapper, letting us pass NULL and things which aren't of + * xc_hypercall_buffer_t *. + */ +static int do_xen_version_raw(xc_interface *xch, int cmd, void *hbuf) +{ + return xencall2(xch->xcall, __HYPERVISOR_xen_version, + cmd, (unsigned long)hbuf); +} + +/* + * Issues a xen_varbuf_t subop, using manual hypercall buffer handling to + * avoid unnecessary buffering. + * + * On failure, returns NULL. errno probably useful. + * On success, returns a pointer which must be freed with xencall_free_buffer(). + */ +static xen_varbuf_t *varbuf_op(xc_interface *xch, unsigned int subop) +{ + xen_varbuf_t *hbuf = NULL; + ssize_t sz; + + sz = do_xen_version_raw(xch, subop, NULL); + if ( sz < 0 ) + return NULL; + + hbuf = xencall_alloc_buffer(xch->xcall, sizeof(*hbuf) + sz); + if ( !hbuf ) + return NULL; + + hbuf->len = sz; + + sz = do_xen_version_raw(xch, subop, hbuf); + if ( sz < 0 ) + { + xencall_free_buffer(xch->xcall, hbuf); + return NULL; + } + + hbuf->len = sz; + return hbuf; +} + +/* + * Wrap varbuf_op() to obtain a simple string. Copy out of the hypercall + * buffer, stripping the xen_varbuf_t header and appending a NUL terminator. + * + * On failure, returns NULL, errno probably useful. + * On success, returns a pointer which must be free()'d. + */ +static char *varbuf_simple_string(xc_interface *xch, unsigned int subop) +{ + xen_varbuf_t *hbuf = varbuf_op(xch, subop); + char *res; + + if ( !hbuf ) + return NULL; + + res = malloc(hbuf->len + 1); + if ( res ) + { + memcpy(res, hbuf->buf, hbuf->len); + res[hbuf->len] = '\0'; + } + + xencall_free_buffer(xch->xcall, hbuf); + + return res; +} + +char *xc_xenver_extraversion(xc_interface *xch) +{ + return varbuf_simple_string(xch, XENVER_extraversion2); +} diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index 175d6dde0b80..f91f7271d5bf 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -582,7 +582,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) { GC_INIT(ctx); union { - xen_extraversion_t xen_extra; xen_compile_info_t xen_cc; xen_changeset_info_t xen_chgset; xen_capabilities_info_t xen_caps; @@ -601,8 +600,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->xen_version_major = xen_version >> 16; info->xen_version_minor = xen_version & 0xFF; - xc_version(ctx->xch, XENVER_extraversion, &u.xen_extra); - info->xen_version_extra = libxl__strdup(NOGC, u.xen_extra); + info->xen_version_extra = xc_xenver_extraversion(ctx->xch); xc_version(ctx->xch, XENVER_compile_info, &u.xen_cc); info->compiler = libxl__strdup(NOGC, u.xen_cc.compiler); diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c index 3703f48c74d1..379a7935a145 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -980,9 +980,8 @@ CAMLprim value stub_xc_version_version(value xch_val) CAMLparam1(xch_val); CAMLlocal1(result); xc_interface *xch = xch_of_val(xch_val); - xen_extraversion_t extra; + char *extra; long packed; - int retval; caml_enter_blocking_section(); packed = xc_version(xch, XENVER_version, NULL); @@ -992,10 +991,10 @@ CAMLprim value stub_xc_version_version(value xch_val) failwith_xc(xch); caml_enter_blocking_section(); - retval = xc_version(xch, XENVER_extraversion, &extra); + extra = xc_xenver_extraversion(xch); caml_leave_blocking_section(); - if (retval) + if (!extra) failwith_xc(xch); result = caml_alloc_tuple(3); @@ -1004,6 +1003,8 @@ CAMLprim value stub_xc_version_version(value xch_val) Store_field(result, 1, Val_int(packed & 0xffff)); Store_field(result, 2, caml_copy_string(extra)); + free(extra); + CAMLreturn(result); } From patchwork Tue Aug 15 21:06:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354329 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 0F1E6C0015E for ; Tue, 15 Aug 2023 21:07:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584051.914467 (Exim 4.92) (envelope-from ) id 1qW1Ft-0005C2-RZ; Tue, 15 Aug 2023 21:07:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584051.914467; Tue, 15 Aug 2023 21:07:09 +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-0005Br-LO; Tue, 15 Aug 2023 21:07:09 +0000 Received: by outflank-mailman (input) for mailman id 584051; 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-JA for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:07 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id af3c3bee-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: af3c3bee-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=1+RMVJk98RwcyuWOiYVPUBLbonGeMd8JnyJIvIqHGro=; b=S3/R/G1Po3//CVpx8g9s7VLojD+YPUo1k1yP+GGqcXRPFv/OwF2Czxz3 YUByPRy+OfFaGsvsTwiECYlGyH1/UX9uxUyTmdYxtkE33xhksXp2KETvX Senm3BfyJ8ZhVylZQnwouVYsS3yln5jhwOUhw39W3eGlpn1nIxwAfyq24 w=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 119453629 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:Yp1nC6LsQhehCEG1FE+R95UlxSXFcZb7ZxGr2PjKsXjdYENShjcEz mJOXm6DaKmPNzCje95+Od6+808B6pTXn9NlSAtlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrawP9TlK6q4mhA7gVjPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c40AUZLx /hJJQkkNC7dqLmu4Z/rWu9j05FLwMnDZOvzu1llxDDdS/0nXYrCU+PB4towMDUY354UW6yEP oxANGQpNU6bC/FMEg5/5JYWteGknHTgNRZfr0qYv/Ef6GnP1g1hlrPqNbI5f/TTHJQJwx3G/ DOuE2LRPAk7CoHEySi5wmupnsaSsBGhc6kTC+jtnhJtqALKnTFCYPEMbnOrrP/8hkOgVtZ3L 00P5jFovaU07FasTNT2Q1u/unHslgEYc8pdFas98g7l4qjb+QGCHUAfUyVMLtchsaceSTU02 3eTktjuBDgpt6eaIU9x7Z/N82n0Y3JMazZfO2ldF1BtD8TfTJ8bzRLoS+RnQaOMp4fLRx6r2 xGn/Dg4iOBG5SIU7JmT8VfCijOqg5HGSA8p+wnaNl6YAhNFiJ2NPNLxtwWChRpUBMPAFwTa4 iBY8ySLxLpWZaxhghBhVwnk8FuBw/+eeAPRjld0d3XK32T8oiXzFWy8DdwXGauIDirmUWW0C KMwkVkLjHO2AJdNRfYuC79d8+xwkcDd+S3ND5g4lOZmbJlrbxOg9ypzf0OW1G2FuBFywPtmY 8vHIJn8VCZy5UFbIN2eHbt17FPW7npmmTO7qW7TnnxLLoZylFbKEOxYYTNin8gy7b+eoRW9z jqsH5Li9vmra8WnOnO/2ddKfTg3wY0TWcieRzp/KrTSfWKL2QgJV5fs/F/WU9c4wvkJzr2Wo SnVt40x4AOXuEAr4D6iMhhLAI4Dl74mxZ7nFUTA5WqV5kU= IronPort-HdrOrdr: A9a23:OALUVa9HnoR3ZZNbVzZuk+DnI+orL9Y04lQ7vn2ZhyYlC/Bw9v re5MjzsCWftN9/YgBEpTntAtjjfZqYz+8X3WBzB9aftWvdyQ+VxehZhOOI/9SjIU3DH4VmpM BdmsZFebvN5JtB4foSIjPULz/t+ra6GWmT69vj8w== X-Talos-CUID: 9a23:Jxop8WHLqDOw1J6pqmIk9GkRKMR0f0T0lkmODBSgKEs5WLuaHAo= X-Talos-MUID: 9a23:u9DCXARXky+Iq4HuRXTSnBBcaZxo8ZieEUUVuMgriZOvHi1vbmI= X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="119453629" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Anthony PERARD , Christian Lindig , Wei Liu , Juergen Gross , David Scott , Edwin Torok , Rob Hoes Subject: [PATCH v3 07/10] tools: Introduce a non-truncating xc_xenver_capabilities() Date: Tue, 15 Aug 2023 22:06:47 +0100 Message-ID: <20230815210650.2735671-8-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 Update libxl and the ocaml stubs to match. No API/ABI change in either. Signed-off-by: Andrew Cooper Acked-by: Anthony PERARD Acked-by: Christian Lindig --- CC: Wei Liu CC: Anthony PERARD CC: Juergen Gross CC: Christian Lindig CC: David Scott CC: Edwin Torok CC: Rob Hoes --- tools/include/xenctrl.h | 1 + tools/libs/ctrl/xc_version.c | 5 +++++ tools/libs/light/libxl.c | 4 +--- tools/ocaml/libs/xc/xenctrl_stubs.c | 18 ++++++++++++++++-- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index b839196bf4c4..9bd5eed7397a 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1598,6 +1598,7 @@ int xc_version(xc_interface *xch, int cmd, void *arg); * free(). */ char *xc_xenver_extraversion(xc_interface *xch); +char *xc_xenver_capabilities(xc_interface *xch); int xc_flask_op(xc_interface *xch, xen_flask_op_t *op); diff --git a/tools/libs/ctrl/xc_version.c b/tools/libs/ctrl/xc_version.c index 2c14474feec5..512302a393ea 100644 --- a/tools/libs/ctrl/xc_version.c +++ b/tools/libs/ctrl/xc_version.c @@ -156,3 +156,8 @@ char *xc_xenver_extraversion(xc_interface *xch) { return varbuf_simple_string(xch, XENVER_extraversion2); } + +char *xc_xenver_capabilities(xc_interface *xch) +{ + return varbuf_simple_string(xch, XENVER_capabilities2); +} diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index f91f7271d5bf..ae6c5e04cd59 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -584,7 +584,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) union { xen_compile_info_t xen_cc; xen_changeset_info_t xen_chgset; - xen_capabilities_info_t xen_caps; xen_platform_parameters_t p_parms; xen_commandline_t xen_commandline; xen_build_id_t build_id; @@ -608,8 +607,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->compile_domain = libxl__strdup(NOGC, u.xen_cc.compile_domain); info->compile_date = libxl__strdup(NOGC, u.xen_cc.compile_date); - xc_version(ctx->xch, XENVER_capabilities, &u.xen_caps); - info->capabilities = libxl__strdup(NOGC, u.xen_caps); + info->capabilities = xc_xenver_capabilities(ctx->xch); xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset); info->changeset = libxl__strdup(NOGC, u.xen_chgset); diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c index 379a7935a145..e8da7d18d29d 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -1062,9 +1062,23 @@ CAMLprim value stub_xc_version_changeset(value xch_val) CAMLprim value stub_xc_version_capabilities(value xch_val) { - xen_capabilities_info_t ci; + CAMLparam1(xch_val); + CAMLlocal1(result); + xc_interface *xch = xch_of_val(xch_val); + char *capabilities; + + caml_enter_blocking_section(); + capabilities = xc_xenver_capabilities(xch); + caml_leave_blocking_section(); - return xc_version_single_string(xch_val, XENVER_capabilities, &ci); + if (!capabilities) + failwith_xc(xch); + + result = caml_copy_string(capabilities); + + free(capabilities); + + CAMLreturn(result); } From patchwork Tue Aug 15 21:06:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354328 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 3C28EC04A94 for ; Tue, 15 Aug 2023 21:07:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584053.914479 (Exim 4.92) (envelope-from ) id 1qW1Fu-0005Mk-Fu; 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 584053.914479; 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 1qW1Fu-0005KS-6k; Tue, 15 Aug 2023 21:07:10 +0000 Received: by outflank-mailman (input) for mailman id 584053; Tue, 15 Aug 2023 21:07:08 +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 1qW1Fs-0004ge-DC for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:08 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b087b55d-3baf-11ee-9b0c-b553b5be7939; Tue, 15 Aug 2023 23:07:06 +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: b087b55d-3baf-11ee-9b0c-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hU8HFMYeVIQ0k7mr1+LByODOt5SbiNcRsTDvsxssU9Q=; b=XU5OWBGuMqL93RvpwGAXyUpdNVjrTzFSFu+Z9Silyg8Bh2pYOVvBsBwA M/dmYW7EN1Zi8X7sAqeCGEc007AWsX1Fjj1gSWmGYC/Jg8wm0I+I3pXV+ Nf6O5/oBERQM5Z+kQbz3g8b2uejxQrkL1eZSAG7xQJ8sNWlQKlH4resSa s=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 119453630 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:69iqWq8nIenRqyUK5pURDrUDpn6TJUtcMsCJ2f8bNWPcYEJGY0x3z WQfXG7TafeKZmfxftt0O46x8UICsMLRz4M3SQQ4pSE8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ks21BjOkGlA5AdmNakW5AW2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkkN9 dsdGjRcYymq3dzo7+mja8Q8lsIseZyD0IM34hmMzBncBPciB5vCX7/L9ZlT2zJYasJmRKiEI ZBDMHw2MUqGOkcUUrsUIMtWcOOAr3/zaTBH7nmSorI6+TP7xw1tyrn9dtHSf7RmQO0MxxfE+ zmYpDyR7hcyBuWF2CSUsXCXicyfxTP5Y64bJLaxz6s/6LGU7jNKU0BHPbehmtGph0j7V99BJ kg8/is1sbN05EGtVsP6XRCzvDiDpBF0c8VUO/037keK0KW8ywSWHG8fVRZadccr8sQxQFQC2 laXkvvzCDdosbnTTmiSnop4thvrZ3JTdzVbI3ZZE01cuYKLTJwPYgznDdZEFZyx39DMMGvOn R/RtAkT16UVgptev0mkxmzvjzWpr5nPawc64ATLQ26ohj9EiJ6Zi5+AsgaCs6sZRGqNZhzY5 SVfxZDChAwbJcvV/BFhVtnhC11ACxytFDTHyWBiEJA6n9hG0y7yJNsAiN2SyaoADyrlRdMLS BWO0e+yzMUJVJdPUUOQS9voY/nGNYC6SbzYugn8N7KimKRZeg6d5z1JbkWNxW3rm0VEufhha M3CK5rwXClKUPQPIN+KqwA1i+ND+8zD7TmLGcCTI+qPgNJym0J5uZ9aaQDTP4jVHYuPoRnP8 sY3Cid540w3bQEKWQGOqdR7BQlTfRAG6WXe95Q/mhirflA3RwnMypb5ndscRmCSt/8Iy7qUp ivjBRcwJZiWrSSvFDhmo0tLMNvHNauTZ1piVcDwFT5EA0QeXLs= IronPort-HdrOrdr: A9a23:8zzviK5Xk5OeMwUwTgPXwPfXdLJyesId70hD6qm+c20tTiX4rb HXoB1/73XJYVkqKRQdcLy7Scu9qDbnhP1ICOoqXItKPjOW3FdARbsKheDfKn/bexEWndQtsp uIHZIObuEYzmIXsS852mSF+hobr+VvOZrHudvj X-Talos-CUID: 9a23:BgvHsm1aIEQnRj6B+2wU6rxfWcACd0/ZnXrpChWGV0kyUJy4GU+W9/Yx X-Talos-MUID: 9a23:0qnWiQm8x5G/5/tBbmPadnpQDd15/bXtCnsCssVeq8u/GSVAMD6k2WE= X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="119453630" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Anthony PERARD , Christian Lindig , Wei Liu , Juergen Gross , David Scott , Edwin Torok , Rob Hoes Subject: [PATCH v3 08/10] tools: Introduce a non-truncating xc_xenver_changeset() Date: Tue, 15 Aug 2023 22:06:48 +0100 Message-ID: <20230815210650.2735671-9-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 Update libxl and the ocaml stubs to match. No API/ABI change in either. Signed-off-by: Andrew Cooper Acked-by: Anthony PERARD Acked-by: Christian Lindig --- CC: Wei Liu CC: Anthony PERARD CC: Juergen Gross CC: Christian Lindig CC: David Scott CC: Edwin Torok CC: Rob Hoes --- tools/include/xenctrl.h | 1 + tools/libs/ctrl/xc_version.c | 5 +++++ tools/libs/light/libxl.c | 5 +---- tools/ocaml/libs/xc/xenctrl_stubs.c | 19 ++++++++----------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 9bd5eed7397a..0400d65acaed 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1599,6 +1599,7 @@ int xc_version(xc_interface *xch, int cmd, void *arg); */ char *xc_xenver_extraversion(xc_interface *xch); char *xc_xenver_capabilities(xc_interface *xch); +char *xc_xenver_changeset(xc_interface *xch); int xc_flask_op(xc_interface *xch, xen_flask_op_t *op); diff --git a/tools/libs/ctrl/xc_version.c b/tools/libs/ctrl/xc_version.c index 512302a393ea..9f2cae03dba8 100644 --- a/tools/libs/ctrl/xc_version.c +++ b/tools/libs/ctrl/xc_version.c @@ -161,3 +161,8 @@ char *xc_xenver_capabilities(xc_interface *xch) { return varbuf_simple_string(xch, XENVER_capabilities2); } + +char *xc_xenver_changeset(xc_interface *xch) +{ + return varbuf_simple_string(xch, XENVER_changeset2); +} diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index ae6c5e04cd59..9a3532ce139a 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -583,7 +583,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) GC_INIT(ctx); union { xen_compile_info_t xen_cc; - xen_changeset_info_t xen_chgset; xen_platform_parameters_t p_parms; xen_commandline_t xen_commandline; xen_build_id_t build_id; @@ -608,9 +607,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->compile_date = libxl__strdup(NOGC, u.xen_cc.compile_date); info->capabilities = xc_xenver_capabilities(ctx->xch); - - xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset); - info->changeset = libxl__strdup(NOGC, u.xen_chgset); + info->changeset = xc_xenver_changeset(ctx->xch); xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms); info->virt_start = u.p_parms.virt_start; diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c index e8da7d18d29d..8495d5bd9892 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -1035,28 +1035,25 @@ CAMLprim value stub_xc_version_compile_info(value xch_val) } -static value xc_version_single_string(value xch_val, int code, void *info) +CAMLprim value stub_xc_version_changeset(value xch_val) { CAMLparam1(xch_val); + CAMLlocal1(result); xc_interface *xch = xch_of_val(xch_val); - int retval; + char *changeset; caml_enter_blocking_section(); - retval = xc_version(xch, code, info); + changeset = xc_xenver_changeset(xch); caml_leave_blocking_section(); - if (retval) + if (!changeset) failwith_xc(xch); - CAMLreturn(caml_copy_string((char *)info)); -} + result = caml_copy_string(changeset); + free(changeset); -CAMLprim value stub_xc_version_changeset(value xch_val) -{ - xen_changeset_info_t ci; - - return xc_version_single_string(xch_val, XENVER_changeset, &ci); + CAMLreturn(result); } From patchwork Tue Aug 15 21:06:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354327 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 0D758C001E0 for ; Tue, 15 Aug 2023 21:07:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584054.914488 (Exim 4.92) (envelope-from ) id 1qW1Fv-0005ZE-4f; Tue, 15 Aug 2023 21:07:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584054.914488; Tue, 15 Aug 2023 21:07:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qW1Fu-0005Ts-O2; Tue, 15 Aug 2023 21:07:10 +0000 Received: by outflank-mailman (input) for mailman id 584054; Tue, 15 Aug 2023 21:07:08 +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 1qW1Fs-0004qk-Ko for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:07:08 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b0b6284e-3baf-11ee-8776-cb3800f73035; Tue, 15 Aug 2023 23:07:06 +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: b0b6284e-3baf-11ee-8776-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dRvwwNb8arl9aVga2t5ciWeg5th+ph8XwiUFmV/rbr4=; b=c2mXirnT7wS3v93MUQUCojRHB+eWnY8BVvFiblvC0AvdxwvMRfcNn3h/ AlaCa1XbyTIoIDzB//IfFvDKsXbBVgze4kdITBQ76vbh1NRnx7J18YORG LWUCSmL1BO5Ogld3vb8MIWtIODTZLj0btFr4wHyCoW34zQuJSCa87XkHw 4=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 119453631 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:vUCRTayYtdJSHQzhxgV6t+cgxirEfRIJ4+MujC+fZmUNrF6WrkUAy WAaXmmGO/aLNmf0eIogbt/jpEtXv5TTzN9kHgJt/CAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EoHUMja4mtC5QRuPK0T5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KSJO0 vkqLGEAVznZubyZm6qaZ7l8gMt2eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyMlKZOUYn1lQ/UfrSmM+BgHXlfiIeg1WSvactuEDYzRBr0airO93QEjCPbZwMzxrF/ TydpgwVBDkLc9DE0jGPq0mNm+rKsx3nX7tJEKOno6sCbFq7mTVIVUx+uUGAiem0jAuyVsxSL 2QQ+zEytu4i+UqzVN7/Uhak5nmesXY0RN54A+A8rgaXxcL84QmDAXMfZiVcc9Fgv8gzLQHGz XfQwYmvX2Y29uTIFzTErOz8QS6O1TY9bm8lYB0AHAY8yoPd/q5oljPiHsZlH/vg5jHqIg3Yz zePpSk4orwci88Xyqm2lWz6byKQSovhFVBsuFiONo6xxkYgPdP+OdT0gbTOxawYRLt1WGVtq 5TtdyK2yOkVRa+AmyWWKAnmNOH4vq3VWNEwbLMGInXAy9hP0yT+FWyzyGskTKuMDirjUWawC HI/QSsLuPdu0IKCNMebmb6ZBcUw1rTHHt/4TP3SZdcmSsEvJVXepn0yNBHAhjCFfK0QfUYXY 8vzTCpRJSxCVfQPIMSeFo/xLoPHNghhnDiOFPgXPjys0KaEZW79dFv2GALmUwzN14vd+F+92 48GZ6O3J+B3DLWWjt//rdRCcjjn7BETWfjLliCgXrXef1c6QDt/VKe5LHFIU9UNopm5X9zgp hmVMnK0AnKm7ZEbAW1mskxeVY4= IronPort-HdrOrdr: A9a23:M/qVTqnTOGIf9KV4PNn0UvBAmGHpDfIT3DAbv31ZSRFFG/FwWf re5cjztCWE8Ar5PUtLpTnuAtjkfZqxz+8W3WBVB8bAYOCEggqVxeNZnO/fKlTbckWUygce78 ddmsNFebrN5DZB/KDHCcqDf+rIAuPrzEllv4jjJr5WIz1XVw== X-Talos-CUID: 9a23:wAYWDmApH8Ma4qj6E2pn00smHpEoS1SH8in/eFeZJDZ5TrLAHA== X-Talos-MUID: 9a23:6GBvnguAF02CcPc2gM2nlXZub9xj6f2VKV0IlLs4p869bihuJGLI X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="119453631" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Anthony PERARD , Wei Liu , Juergen Gross Subject: [PATCH v3 09/10] tools: Introduce a non-truncating xc_xenver_cmdline() Date: Tue, 15 Aug 2023 22:06:49 +0100 Message-ID: <20230815210650.2735671-10-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 Update libxl to match. No API/ABI change. Signed-off-by: Andrew Cooper Acked-by: Anthony PERARD --- CC: Wei Liu CC: Anthony PERARD CC: Juergen Gross --- tools/include/xenctrl.h | 1 + tools/libs/ctrl/xc_version.c | 5 +++++ tools/libs/light/libxl.c | 4 +--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 0400d65acaed..1b6f2ac508e0 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1600,6 +1600,7 @@ int xc_version(xc_interface *xch, int cmd, void *arg); char *xc_xenver_extraversion(xc_interface *xch); char *xc_xenver_capabilities(xc_interface *xch); char *xc_xenver_changeset(xc_interface *xch); +char *xc_xenver_commandline(xc_interface *xch); int xc_flask_op(xc_interface *xch, xen_flask_op_t *op); diff --git a/tools/libs/ctrl/xc_version.c b/tools/libs/ctrl/xc_version.c index 9f2cae03dba8..02f6e9551b57 100644 --- a/tools/libs/ctrl/xc_version.c +++ b/tools/libs/ctrl/xc_version.c @@ -166,3 +166,8 @@ char *xc_xenver_changeset(xc_interface *xch) { return varbuf_simple_string(xch, XENVER_changeset2); } + +char *xc_xenver_commandline(xc_interface *xch) +{ + return varbuf_simple_string(xch, XENVER_commandline2); +} diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index 9a3532ce139a..04f037f3c199 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -584,7 +584,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) union { xen_compile_info_t xen_cc; xen_platform_parameters_t p_parms; - xen_commandline_t xen_commandline; xen_build_id_t build_id; } u; long xen_version; @@ -614,8 +613,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL); - xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline); - info->commandline = libxl__strdup(NOGC, u.xen_commandline); + info->commandline = xc_xenver_commandline(ctx->xch); u.build_id.len = sizeof(u) - sizeof(u.build_id); r = libxl__xc_version_wrap(gc, info, &u.build_id); From patchwork Tue Aug 15 21:06:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13354333 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 E99AEC41513 for ; Tue, 15 Aug 2023 21:10:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.584082.914546 (Exim 4.92) (envelope-from ) id 1qW1In-0002x6-JW; Tue, 15 Aug 2023 21:10:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 584082.914546; Tue, 15 Aug 2023 21:10:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qW1In-0002wx-GQ; Tue, 15 Aug 2023 21:10:09 +0000 Received: by outflank-mailman (input) for mailman id 584082; Tue, 15 Aug 2023 21:10:08 +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 1qW1Gi-0004ge-8l for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 21:08:00 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ce7e1033-3baf-11ee-9b0c-b553b5be7939; Tue, 15 Aug 2023 23:07:57 +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: ce7e1033-3baf-11ee-9b0c-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1692133677; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H8yVo7cfHcdVvMYigQJV38THfj5k/BX4q6OsZV/UvUY=; b=XB2llFITgSdQlfp5mIjmtHOW/Ty+aHCCq/f6JXWkpFoFEROr4uR2W7oO rA0axXRyLl8k59gPxRPj4BHcTEp3QaZxeElhP+U+16rKlJm2pLHJc2UdT 6sFB+KIBTdSfP17WUCzxhD4jgAf1z/p/jn0NsXd49if4ucUnRwngXnBIH A=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 118253182 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:xrwR667zc0g9Rv6rPjDUEwxRtC/HchMFZxGqfqrLsTDasY5as4F+v jYYWzyAM/bcYjfyed5+a4Tgo09UvMXTydIyTlE6+389Hi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9lU35ZwehBtC5gZlPaAS4QeE/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5my KUiBilRTBe6jOeR+u6mY7cxot04I5y+VG8fkikIITDxCP8nRdbIQrnQ5M8e1zA17ixMNa+AP YxDM2MpNUmeJUQVYT/7C7pn9AusrlD5fydVtxS+oq0v7nKI5AdwzKLsIJzefdniqcB9xx/I/ D+dpjSjav0cHOK+2wCgyVmivPberwXKXb82C6Xl3Mc/1TV/wURMUUZLBDNXu8KRmkO4Ht5SN UEQ0i4vtrQpslymSMHnWB+1q2LCuQQTM/JPF8Uq5QfLzbDbiy6bCXIDVSVpc8E9uYk9QjlC6 7OSt4q3X3o16uTTEC/DsO7O9lteJBT5M0c/PBUqVFcn5ODopaYJ0g/mEItHCbW624id9S7L/ xiGqy03hrM2hMEN1rmm8V2vvw9AtqQlXSZuuFyJAzvNAhdRIdf8Otf2sQSzAeNodt7xc7WXg JQTdyFyBsgqBIrFqiGCSf5l8FqBt6fca220bbKC8vAcG9WRF5yLJ904DNJWfh0B3iM4ldjBO Ra7hO+pzMUPVEZGlIcuC25LN+wkzLL7CfPuXe3OY9xFb/BZLVHWpng0ORLBgDC0wCDAdJ3T3 r/BLa6R4YsyU/w7nFJauc9MuVPU+szO7TyKHs2qp/hW+bGfeGSUWd843KimN4gEAFe/iFyNq b53bpLaoyizpcWiOkE7B6ZPdwFVRZX6bLiqw/FqmhmreVc7RT15UaGOmdvMueVNxsxoqwsBx VnlMmcw9bY1rSavxdmiApy7VI7SYA== IronPort-HdrOrdr: A9a23:oUZGOawzCm2LTCNUiixzKrPwE71zdoMgy1knxilNoNJuA7Wlfq GV7YwmPHrP4gr5N0tQ/OxoVJPwI080sKQFgrX5Xo3CYOCFghrNEGgK1+KLqAEIWRefygc379 YGT0ERMqyXMbG4t6rHCcuDfurIDOPpzElgv4nj80s= X-Talos-CUID: 9a23:vtrZw2ofIYAw7USazpSy4njmUf18SFPEkFXXGkS9Llw1VZTLFHuJ46wxxg== X-Talos-MUID: 9a23:SWw4HQYyQ/3xMuBTiR7+vhRZH8lS+rWcLnEIrLEZo5SuDHkl X-IronPort-AV: E=Sophos;i="6.01,175,1684814400"; d="scan'208";a="118253182" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Anthony PERARD , Wei Liu , Juergen Gross Subject: [PATCH v3 10/10] tools: Introduce a xc_xenver_buildid() wrapper Date: Tue, 15 Aug 2023 22:06:50 +0100 Message-ID: <20230815210650.2735671-11-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 ... which converts binary content to hex automatically. Update libxl to match. No API/ABI change. This removes a latent libxl bug for cases when the buildid is longer than 4092 bytes. Signed-off-by: Andrew Cooper Acked-by: Anthony PERARD --- CC: Wei Liu CC: Anthony PERARD CC: Juergen Gross --- tools/include/xenctrl.h | 1 + tools/libs/ctrl/xc_version.c | 33 +++++++++++++++++++++++++++ tools/libs/light/libxl.c | 44 +----------------------------------- 3 files changed, 35 insertions(+), 43 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 1b6f2ac508e0..7f51cb43b931 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1601,6 +1601,7 @@ char *xc_xenver_extraversion(xc_interface *xch); char *xc_xenver_capabilities(xc_interface *xch); char *xc_xenver_changeset(xc_interface *xch); char *xc_xenver_commandline(xc_interface *xch); +char *xc_xenver_buildid(xc_interface *xch); int xc_flask_op(xc_interface *xch, xen_flask_op_t *op); diff --git a/tools/libs/ctrl/xc_version.c b/tools/libs/ctrl/xc_version.c index 02f6e9551b57..54d1b9296696 100644 --- a/tools/libs/ctrl/xc_version.c +++ b/tools/libs/ctrl/xc_version.c @@ -171,3 +171,36 @@ char *xc_xenver_commandline(xc_interface *xch) { return varbuf_simple_string(xch, XENVER_commandline2); } + +static void str2hex(char *dst, const unsigned char *src, size_t n) +{ + static const unsigned char hex[] = "0123456789abcdef"; + + for ( ; n; n-- ) + { + unsigned char c = *src++; + + *dst++ = hex[c >> 4]; + *dst++ = hex[c & 0xf]; + } +} + +char *xc_xenver_buildid(xc_interface *xch) +{ + xen_varbuf_t *hbuf = varbuf_op(xch, XENVER_build_id); + char *res; + + if ( !hbuf ) + return NULL; + + res = malloc((hbuf->len * 2) + 1); + if ( res ) + { + str2hex(res, hbuf->buf, hbuf->len); + res[hbuf->len * 2] = '\0'; + } + + xencall_free_buffer(xch->xcall, hbuf); + + return res; +} diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index 04f037f3c199..a1fe16274d86 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -546,38 +546,6 @@ libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr) return ret; } -static int libxl__xc_version_wrap(libxl__gc *gc, libxl_version_info *info, - xen_build_id_t *build) -{ - int r; - - r = xc_version(CTX->xch, XENVER_build_id, build); - switch (r) { - case -EPERM: - case -ENODATA: - case 0: - info->build_id = libxl__strdup(NOGC, ""); - break; - - case -ENOBUFS: - break; - - default: - if (r > 0) { - unsigned int i; - - info->build_id = libxl__zalloc(NOGC, (r * 2) + 1); - - for (i = 0; i < r ; i++) - snprintf(&info->build_id[i * 2], 3, "%02hhx", build->buf[i]); - - r = 0; - } - break; - } - return r; -} - const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) { GC_INIT(ctx); @@ -587,7 +555,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) xen_build_id_t build_id; } u; long xen_version; - int r; libxl_version_info *info = &ctx->version_info; if (info->xen_version_extra != NULL) @@ -614,17 +581,8 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL); info->commandline = xc_xenver_commandline(ctx->xch); + info->build_id = xc_xenver_buildid(ctx->xch); - u.build_id.len = sizeof(u) - sizeof(u.build_id); - r = libxl__xc_version_wrap(gc, info, &u.build_id); - if (r == -ENOBUFS) { - xen_build_id_t *build_id; - - build_id = libxl__zalloc(gc, info->pagesize); - build_id->len = info->pagesize - sizeof(*build_id); - r = libxl__xc_version_wrap(gc, info, build_id); - if (r) LOGEV(ERROR, r, "getting build_id"); - } out: GC_FREE; return info;