From nobody Mon Nov 25 22:37:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1715962156; cv=none; d=zohomail.com; s=zohoarc; b=jLtJJkcZoSkmfD4b1x5MshX7ycGlRGA3Uvl28pbh1t0OSrFT4b0DkC2mwY5tPMqU01Oj1/zTtwMn1k5nuqhcgezNfWm/GNIll1f+1AHHOomVxzKEshB7djsjbJtxbfs7DuekQzo9m4RVpQ0iSLZT6ISOGwPyCDuFVyp26jkOxFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715962156; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NRfRLYM2uaIOUr5UnCxOVm7BN+wzkpxkUR6EABqZEIM=; b=Gt4tp1uZZ7QopovDNZz1/Nm6FLpJ/Vzo6Uv63CWBrgOmU2mG5FW6vCynpVzUqsmThkm36C+0hajH2JsZWj45mhzo16R10r5YUV71sZJhTYNTQKXSychjNJ8I/nV/ejRxGsgIKxCW/mDiG5S3AcCRTQTjmTxRYUmCr6cQ7hP6/c0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1715962156009444.7862025503732; Fri, 17 May 2024 09:09:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.724317.1129563 (Exim 4.92) (envelope-from ) id 1s808U-00029l-Ee; Fri, 17 May 2024 16:08:46 +0000 Received: by outflank-mailman (output) from mailman id 724317.1129563; Fri, 17 May 2024 16:08:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s808U-00029a-A7; Fri, 17 May 2024 16:08:46 +0000 Received: by outflank-mailman (input) for mailman id 724317; Fri, 17 May 2024 16:08:45 +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 1s808T-0001vE-D5 for xen-devel@lists.xenproject.org; Fri, 17 May 2024 16:08:45 +0000 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [2a00:1450:4864:20::62a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bb6cc059-1467-11ef-b4bb-af5377834399; Fri, 17 May 2024 18:08:43 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a5a1054cf61so555671566b.1 for ; Fri, 17 May 2024 09:08:43 -0700 (PDT) Received: from EMEAENGAAD19049.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a60eabd3csm739104366b.108.2024.05.17.09.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 09:08:41 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bb6cc059-1467-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1715962122; x=1716566922; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NRfRLYM2uaIOUr5UnCxOVm7BN+wzkpxkUR6EABqZEIM=; b=Pov1zbFFcTy/bPVEPAoC1lbBrD60fkrDjgoEK4sjxvAP4haZU5WpwR1MUzl92lrwBy cbAtZ9h4hDKqQjmiygCb3SJcaOfNcmRFp9eJAT1RrcJ0P20KZ0aOFaP+YbolGTUIUq+d EwBqH8tuzH2BIS+hmX+cFPKunnxeuKUP8ojyw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715962122; x=1716566922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NRfRLYM2uaIOUr5UnCxOVm7BN+wzkpxkUR6EABqZEIM=; b=RzjPc8iVrgohLzfur3LITxwK6rO/rcaX7gElSpbK1Ib/Xd/kJbC8sxfELu3xXAK0Vx H1eO5xdLvSCIHZWjgljuv2CIFeMzjbqCdHz5RGH5p8Ekry9f9E2XAT21QzoDwEw/pFFE teAj8tsiFVYJhEWnYjZEkEgyMnhHY/PhwRaa1IP0e7de9qKKf+Wm5LwvBNrR4UxrSbA2 qXrLZgvxBy1krOeUd3LN/tb8Ov+4esfOkRWz/NT9CSAUa7tl8KZWEqhQYTOfJCBichII 7aIPOZOUY+27gWiNliz5AZb3CKSd9rLACUIlyYVzhM/4/SzCIjLWV21XRgYqWV6IsPSZ ZZpQ== X-Gm-Message-State: AOJu0Yz/wAiighj4RgohPOQmFshxiN7EedssCgUwAAzwK8fN0Akr1VfU 84V3yyxWtuHns+hfnQu7Nw5GnlBWMwsmOEQVTnHPZc1wUrqKGQMFm13UwtapKrKahfo8d41N+Ji + X-Google-Smtp-Source: AGHT+IGYuJX1kmCNe86D53+81GF3VMyvUiycUA9rCHz8TKzTSBHr6hVAAowzwLbNpyRoc4hNwxWmLw== X-Received: by 2002:a17:906:f883:b0:a5a:8d0f:3ad1 with SMTP id a640c23a62f3a-a5a8d0f4cc1mr965870366b.17.1715962122098; Fri, 17 May 2024 09:08:42 -0700 (PDT) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Anthony PERARD , Juergen Gross , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 1/2] tools/xg: Streamline cpu policy serialise/deserialise calls Date: Fri, 17 May 2024 17:08:34 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1715962157975100001 Content-Type: text/plain; charset="utf-8" The idea is to use xc_cpu_policy_t as a single object containing both the serialised and deserialised forms of the policy. Note that we need lengths for the arrays, as the serialised policies may be shorter than the array capacities. * Add the serialised lengths to the struct so we can distinguish between length and capacity of the serialisation buffers. * Remove explicit buffer+lengths in serialise/deserialise calls and use the internal buffer inside xc_cpu_policy_t instead. * Refactor everything to use the new serialisation functions. * Remove redundant serialization calls and avoid allocating dynamic memory aside from the policy objects in xen-cpuid. Also minor cleanup in the policy print call sites. No functional change intended. Signed-off-by: Alejandro Vallejo --- v2: * Removed v1/patch1. * Added the accessors suggested in feedback. --- tools/include/xenguest.h | 8 ++- tools/libs/guest/xg_cpuid_x86.c | 98 ++++++++++++++++++++--------- tools/libs/guest/xg_private.h | 2 + tools/libs/guest/xg_sr_common_x86.c | 54 ++++++---------- tools/misc/xen-cpuid.c | 43 ++++--------- 5 files changed, 104 insertions(+), 101 deletions(-) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index e01f494b772a..563811cd8dde 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -799,14 +799,16 @@ int xc_cpu_policy_set_domain(xc_interface *xch, uint3= 2_t domid, xc_cpu_policy_t *policy); =20 /* Manipulate a policy via architectural representations. */ -int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t *poli= cy, - xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves, - xen_msr_entry_t *msrs, uint32_t *nr_msrs); +int xc_cpu_policy_serialise(xc_interface *xch, xc_cpu_policy_t *policy); int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_cpu_policy_t *policy, const xen_cpuid_leaf_t *leaves, uint32_t nr); int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy, const xen_msr_entry_t *msrs, uint32_t nr); +int xc_cpu_policy_get_leaves(xc_interface *xch, const xc_cpu_policy_t *pol= icy, + const xen_cpuid_leaf_t **leaves, uint32_t *nr= ); +int xc_cpu_policy_get_msrs(xc_interface *xch, const xc_cpu_policy_t *polic= y, + const xen_msr_entry_t **msrs, uint32_t *nr); =20 /* Compatibility calculations. */ bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 4453178100ad..4f4b86b59470 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -834,14 +834,13 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t *policy) } } =20 -static int deserialize_policy(xc_interface *xch, xc_cpu_policy_t *policy, - unsigned int nr_leaves, unsigned int nr_entr= ies) +static int deserialize_policy(xc_interface *xch, xc_cpu_policy_t *policy) { uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; int rc; =20 rc =3D x86_cpuid_copy_from_buffer(&policy->policy, policy->leaves, - nr_leaves, &err_leaf, &err_subleaf); + policy->nr_leaves, &err_leaf, &err_sub= leaf); if ( rc ) { if ( err_leaf !=3D -1 ) @@ -851,7 +850,7 @@ static int deserialize_policy(xc_interface *xch, xc_cpu= _policy_t *policy, } =20 rc =3D x86_msr_copy_from_buffer(&policy->policy, policy->msrs, - nr_entries, &err_msr); + policy->nr_msrs, &err_msr); if ( rc ) { if ( err_msr !=3D -1 ) @@ -878,7 +877,10 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsign= ed int policy_idx, return rc; } =20 - rc =3D deserialize_policy(xch, policy, nr_leaves, nr_msrs); + policy->nr_leaves =3D nr_leaves; + policy->nr_msrs =3D nr_msrs; + + rc =3D deserialize_policy(xch, policy); if ( rc ) { errno =3D -rc; @@ -903,7 +905,10 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32= _t domid, return rc; } =20 - rc =3D deserialize_policy(xch, policy, nr_leaves, nr_msrs); + policy->nr_leaves =3D nr_leaves; + policy->nr_msrs =3D nr_msrs; + + rc =3D deserialize_policy(xch, policy); if ( rc ) { errno =3D -rc; @@ -917,17 +922,14 @@ int xc_cpu_policy_set_domain(xc_interface *xch, uint3= 2_t domid, xc_cpu_policy_t *policy) { uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; - unsigned int nr_leaves =3D ARRAY_SIZE(policy->leaves); - unsigned int nr_msrs =3D ARRAY_SIZE(policy->msrs); int rc; =20 - rc =3D xc_cpu_policy_serialise(xch, policy, policy->leaves, &nr_leaves, - policy->msrs, &nr_msrs); + rc =3D xc_cpu_policy_serialise(xch, policy); if ( rc ) return rc; =20 - rc =3D xc_set_domain_cpu_policy(xch, domid, nr_leaves, policy->leaves, - nr_msrs, policy->msrs, + rc =3D xc_set_domain_cpu_policy(xch, domid, policy->nr_leaves, policy-= >leaves, + policy->nr_msrs, policy->msrs, &err_leaf, &err_subleaf, &err_msr); if ( rc ) { @@ -942,34 +944,32 @@ int xc_cpu_policy_set_domain(xc_interface *xch, uint3= 2_t domid, return rc; } =20 -int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t *p, - xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves, - xen_msr_entry_t *msrs, uint32_t *nr_msrs) +int xc_cpu_policy_serialise(xc_interface *xch, xc_cpu_policy_t *p) { + unsigned int nr_leaves =3D ARRAY_SIZE(p->leaves); + unsigned int nr_msrs =3D ARRAY_SIZE(p->msrs); int rc; =20 - if ( leaves ) + rc =3D x86_cpuid_copy_to_buffer(&p->policy, p->leaves, &nr_leaves); + if ( rc ) { - rc =3D x86_cpuid_copy_to_buffer(&p->policy, leaves, nr_leaves); - if ( rc ) - { - ERROR("Failed to serialize CPUID policy"); - errno =3D -rc; - return -1; - } + ERROR("Failed to serialize CPUID policy"); + errno =3D -rc; + return -1; } =20 - if ( msrs ) + p->nr_leaves =3D nr_leaves; + + rc =3D x86_msr_copy_to_buffer(&p->policy, p->msrs, &nr_msrs); + if ( rc ) { - rc =3D x86_msr_copy_to_buffer(&p->policy, msrs, nr_msrs); - if ( rc ) - { - ERROR("Failed to serialize MSR policy"); - errno =3D -rc; - return -1; - } + ERROR("Failed to serialize MSR policy"); + errno =3D -rc; + return -1; } =20 + p->nr_msrs =3D nr_msrs; + errno =3D 0; return 0; } @@ -1012,6 +1012,42 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, xc_= cpu_policy_t *policy, return rc; } =20 +int xc_cpu_policy_get_leaves(xc_interface *xch, + const xc_cpu_policy_t *policy, + const xen_cpuid_leaf_t **leaves, + uint32_t *nr) +{ + if ( !policy ) + { + ERROR("Failed to fetch CPUID leaves from policy object"); + errno =3D -EINVAL; + return -1; + } + + *leaves =3D policy->leaves; + *nr =3D policy->nr_leaves; + + return 0; +} + +int xc_cpu_policy_get_msrs(xc_interface *xch, + const xc_cpu_policy_t *policy, + const xen_msr_entry_t **msrs, + uint32_t *nr) +{ + if ( !policy ) + { + ERROR("Failed to fetch MSRs from policy object"); + errno =3D -EINVAL; + return -1; + } + + *msrs =3D policy->msrs; + *nr =3D policy->nr_msrs; + + return 0; +} + bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, xc_cpu_policy_t *guest) { diff --git a/tools/libs/guest/xg_private.h b/tools/libs/guest/xg_private.h index d73947094f2e..a65dae818f3d 100644 --- a/tools/libs/guest/xg_private.h +++ b/tools/libs/guest/xg_private.h @@ -177,6 +177,8 @@ struct xc_cpu_policy { struct cpu_policy policy; xen_cpuid_leaf_t leaves[CPUID_MAX_SERIALISED_LEAVES]; xen_msr_entry_t msrs[MSR_MAX_SERIALISED_ENTRIES]; + uint32_t nr_leaves; + uint32_t nr_msrs; }; #endif /* x86 */ =20 diff --git a/tools/libs/guest/xg_sr_common_x86.c b/tools/libs/guest/xg_sr_c= ommon_x86.c index 563b4f016877..832047756e58 100644 --- a/tools/libs/guest/xg_sr_common_x86.c +++ b/tools/libs/guest/xg_sr_common_x86.c @@ -1,4 +1,5 @@ #include "xg_sr_common_x86.h" +#include "xg_sr_stream_format.h" =20 int write_x86_tsc_info(struct xc_sr_context *ctx) { @@ -45,54 +46,37 @@ int handle_x86_tsc_info(struct xc_sr_context *ctx, stru= ct xc_sr_record *rec) int write_x86_cpu_policy_records(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; - struct xc_sr_record cpuid =3D { .type =3D REC_TYPE_X86_CPUID_POLICY, }; - struct xc_sr_record msrs =3D { .type =3D REC_TYPE_X86_MSR_POLICY, }; - uint32_t nr_leaves =3D 0, nr_msrs =3D 0; - xc_cpu_policy_t *policy =3D NULL; + struct xc_sr_record record; + xc_cpu_policy_t *policy =3D xc_cpu_policy_init(); int rc; =20 - if ( xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs) < 0 ) - { - PERROR("Unable to get CPU Policy size"); - return -1; - } - - cpuid.data =3D malloc(nr_leaves * sizeof(xen_cpuid_leaf_t)); - msrs.data =3D malloc(nr_msrs * sizeof(xen_msr_entry_t)); - policy =3D xc_cpu_policy_init(); - if ( !cpuid.data || !msrs.data || !policy ) - { - ERROR("Cannot allocate memory for CPU Policy"); - rc =3D -1; - goto out; - } - - if ( xc_cpu_policy_get_domain(xch, ctx->domid, policy) ) + if ( !policy || xc_cpu_policy_get_domain(xch, ctx->domid, policy) ) { PERROR("Unable to get d%d CPU Policy", ctx->domid); rc =3D -1; goto out; } - if ( xc_cpu_policy_serialise(xch, policy, cpuid.data, &nr_leaves, - msrs.data, &nr_msrs) ) - { - PERROR("Unable to serialize d%d CPU Policy", ctx->domid); - rc =3D -1; - goto out; - } =20 - cpuid.length =3D nr_leaves * sizeof(xen_cpuid_leaf_t); - if ( cpuid.length ) + record =3D (struct xc_sr_record) { + .type =3D REC_TYPE_X86_CPUID_POLICY, + .data =3D policy->leaves, + .length =3D policy->nr_leaves * sizeof(*policy->leaves), + }; + if ( record.length ) { - rc =3D write_record(ctx, &cpuid); + rc =3D write_record(ctx, &record); if ( rc ) goto out; } =20 - msrs.length =3D nr_msrs * sizeof(xen_msr_entry_t); - if ( msrs.length ) + record =3D (struct xc_sr_record) { + .type =3D REC_TYPE_X86_MSR_POLICY, + .data =3D policy->msrs, + .length =3D policy->nr_msrs * sizeof(*policy->msrs), + }; + if ( record.length ) { - rc =3D write_record(ctx, &msrs); + rc =3D write_record(ctx, &record); if ( rc ) goto out; } @@ -100,8 +84,6 @@ int write_x86_cpu_policy_records(struct xc_sr_context *c= tx) rc =3D 0; =20 out: - free(cpuid.data); - free(msrs.data); xc_cpu_policy_destroy(policy); =20 return rc; diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 8893547bebce..1c9ba6d32060 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -409,17 +409,21 @@ static void dump_info(xc_interface *xch, bool detail) free(fs); } =20 -static void print_policy(const char *name, - xen_cpuid_leaf_t *leaves, uint32_t nr_leaves, - xen_msr_entry_t *msrs, uint32_t nr_msrs) +static void print_policy(xc_interface *xch, const char *name, const xc_cpu= _policy_t *policy) { - unsigned int l; + const xen_cpuid_leaf_t *leaves; + const xen_msr_entry_t *msrs; + uint32_t nr_leaves, nr_msrs; + + if ( xc_cpu_policy_get_leaves(xch, policy, &leaves, &nr_leaves) || + xc_cpu_policy_get_msrs(xch, policy, &msrs, &nr_msrs) ) + err(1, "print_policy()"); =20 printf("%s policy: %u leaves, %u MSRs\n", name, nr_leaves, nr_msrs); printf(" CPUID:\n"); printf(" %-8s %-8s -> %-8s %-8s %-8s %-8s\n", "leaf", "subleaf", "eax", "ebx", "ecx", "edx"); - for ( l =3D 0; l < nr_leaves; ++l ) + for ( uint32_t l =3D 0; l < nr_leaves; ++l ) { /* Skip empty leaves. */ if ( !leaves[l].a && !leaves[l].b && !leaves[l].c && !leaves[l].d ) @@ -432,7 +436,7 @@ static void print_policy(const char *name, =20 printf(" MSRs:\n"); printf(" %-8s -> %-16s\n", "index", "value"); - for ( l =3D 0; l < nr_msrs; ++l ) + for ( uint32_t l =3D 0; l < nr_msrs; ++l ) printf(" %08x -> %016"PRIx64"\n", msrs[l].idx, msrs[l].val); } @@ -539,8 +543,6 @@ int main(int argc, char **argv) [ XEN_SYSCTL_cpu_policy_pv_default ] =3D "PV Default", [ XEN_SYSCTL_cpu_policy_hvm_default ] =3D "HVM Default", }; - xen_cpuid_leaf_t *leaves; - xen_msr_entry_t *msrs; uint32_t i, max_leaves, max_msrs; =20 xc_interface *xch =3D xc_interface_open(0, 0, 0); @@ -557,36 +559,21 @@ int main(int argc, char **argv) printf("Xen reports there are maximum %u leaves and %u MSRs\n", max_leaves, max_msrs); =20 - leaves =3D calloc(max_leaves, sizeof(xen_cpuid_leaf_t)); - if ( !leaves ) - err(1, "calloc(max_leaves)"); - msrs =3D calloc(max_msrs, sizeof(xen_msr_entry_t)); - if ( !msrs ) - err(1, "calloc(max_msrs)"); - if ( domid !=3D -1 ) { char name[20]; - uint32_t nr_leaves =3D max_leaves; - uint32_t nr_msrs =3D max_msrs; =20 if ( xc_cpu_policy_get_domain(xch, domid, policy) ) err(1, "xc_cpu_policy_get_domain(, %d, )", domid); - if ( xc_cpu_policy_serialise(xch, policy, leaves, &nr_leaves, - msrs, &nr_msrs) ) - err(1, "xc_cpu_policy_serialise"); =20 snprintf(name, sizeof(name), "Domain %d", domid); - print_policy(name, leaves, nr_leaves, msrs, nr_msrs); + print_policy(xch, name, policy); } else { /* Get system policies */ for ( i =3D 0; i < ARRAY_SIZE(sys_policies); ++i ) { - uint32_t nr_leaves =3D max_leaves; - uint32_t nr_msrs =3D max_msrs; - if ( xc_cpu_policy_get_system(xch, i, policy) ) { if ( errno =3D=3D EOPNOTSUPP ) @@ -598,18 +585,12 @@ int main(int argc, char **argv) =20 err(1, "xc_cpu_policy_get_system(, %s, )", sys_policie= s[i]); } - if ( xc_cpu_policy_serialise(xch, policy, leaves, &nr_leav= es, - msrs, &nr_msrs) ) - err(1, "xc_cpu_policy_serialise"); =20 - print_policy(sys_policies[i], leaves, nr_leaves, - msrs, nr_msrs); + print_policy(xch, sys_policies[i], policy); } } =20 xc_cpu_policy_destroy(policy); - free(leaves); - free(msrs); xc_interface_close(xch); } else if ( mode =3D=3D MODE_INFO || mode =3D=3D MODE_DETAIL ) --=20 2.34.1