From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322558; cv=pass; d=zohomail.com; s=zohoarc; b=UrhFmVSqkZd3avI2UVRzJdLp1+OesoQRrWQCxgqGoS3LnMkip4wvmY8qd/ufVngtrMZJKyfUKSQIIQ60pq09S9nb1cjq5N6W9nmt13SDLA8QrolyACpVkyR2wV02JRX+dUWgFyeJz9odUmU8ZI4ayofS4AAOWbDqPg7aIdv/uyo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322558; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZiXg4RaaWYgPdIkmGYs/6vFIpLjmbLaKb/fElO2iGok=; b=UWf5xCTxtcXQcem8EU3+46aT1l2Lgb7oChX9qQ67D7CdaWDiaBEtMW2C5JsPhYM9fKMnMZDB0XKlXjBbHy9B6WY7M/yB7oTCSwN4TEwI0KZtccK5cwT2dWAiQ3rWWddJmvvX9Wr/HpqK8Z7797k+ru4ygpG7ABHIPPvqLvDKE1M= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322558216686.0994052508407; Tue, 13 Apr 2021 07:02:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109767.209505 (Exim 4.92) (envelope-from ) id 1lWJcG-0004ri-Du; Tue, 13 Apr 2021 14:02:08 +0000 Received: by outflank-mailman (output) from mailman id 109767.209505; Tue, 13 Apr 2021 14:02:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcG-0004rb-AU; Tue, 13 Apr 2021 14:02:08 +0000 Received: by outflank-mailman (input) for mailman id 109767; Tue, 13 Apr 2021 14:02:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcF-0004rK-EV for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:07 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9f706b10-97a6-4ef3-8c94-0b990a922eb5; Tue, 13 Apr 2021 14:02:06 +0000 (UTC) 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: 9f706b10-97a6-4ef3-8c94-0b990a922eb5 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322526; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=0Z9bLa3Of6ehyx4kNWG7tTOMC4d6bLSrky0iA51bLt8=; b=f0NYHJDaTPgqlL+rhF/a9FlM2drqBdIm/sGmSPrFtO6E1ilpsodbmLtT ye6VEG0lE1FaOvx5P59Maq5gXaLWN7JAV6cMkGH4GIc+u1Vzw+6Pajh8W 5vTXx83fQrej7Bw4TqAL50Og7ikptGR7smpiXxbgp0h8AeYxDIH+v5o8v g=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: rTCzCnezs2/a1q15+916qSQliMPcyYRgcH8b6mORBVMV5k3PtPQCK7FD1P5Cg79kxPL1cCkElL 8snMS1sOugxYScpDYmQKx6C48cunOz1+YqXkS6wb0DFNohKZWy/YR80s2h+6w3N+GjGmUyW4oX M/Ba4JP1hN9yjJxAn+3SGG80kYOaG5FQnmMGjJrXr53NExKI/RCgiLntRAt8KXM6jsOwTJdf6e UgLGagThj0RusoDEY2NeithEi9tKuFzojJwOa+QvxbFUQCsJcgD1V929iJiF6tmYnrm7Z5XoQT 8So= X-SBRS: 5.2 X-MesageID: 42955851 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:V7Qx1q2LlN6n4cJdP6gNdQqjBTd3eYIsi2QD101hICF9Wvez0+ izgfUW0gL1gj4NWHcm3euNIrWEXGm0z/FIyKErF/OHUBP9sGWlaLtj44zr3iH6F0TFmtJ1/Z xLN5JzANiYNzVHpO7n/Qi1FMshytGb8KauwdzT1WtpUBsCUcBdxi1SYzzrdnFebg9AGJY/Cd 6g/cJBvTWtYjA6ac68C3kDUYH41qH2vbjhZgMLAANi1RmWgVqTmcPHOjW7/jNbaTNAxr8+7X PI+jaW2oyPu+y2oyWssVP7wI9RnLLau7l+LeyKzvMYMzD9zjuvDb4RIIGqmBAQjKWR5E0xkN /Kyi1QT/hbz3/KZGm6rV/M9mDboU8TwkTvw1OZnnfvyPaRLFlRa7sj9PBkWyDU5EY6sNZ33L gj5RPii7NtAQ7dhyO43tDUVnhR5zuJiEA/mu0ehWE3a/p4VJZtq+UkjSZoOaZFNif75Ic7Kf JpHcHR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iph I/x92TheeYe27Z3w/X1AELb55mwiKCQcmoBhiLFvMN29umOU6Uiq/v2fWNtl7MOHKGQnVdo5 ZEe0wWZtlCjTdnrLRf6FnMdoXH5mQ/k1Vf5jl7kEXKwYbO2haDIX17 X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="42955851" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVSHbZ+AuFB66qVIV+dDETUr3T2iIvOQJ3KwteRPqFS0TD87Zi+cHRGTYG5MsGrDVSvUrhV2f0LbqV2KIOsaOR3x+ANVVgmoYItXYTlC16vsHOsn9V1egj7cal+2jvHAcqjmLqNkV7FbvAWpGhBXc8d2nWbk7yaesGsxtPVweNR+oeM5zvL2keRnqdqZMwvaE+3nBWlDN7okpLv0Q39Y6Z+GrTVXAAcEYbG4RnH9NrUn/US0hfjJ/ZlOTQdrIYa0tFzkW430gJdTu9Oi74C9NNKLetW1d7KkWc4sWt/KeGu7BZtMN67cVfWMqddWXcQmkZ1Z8mzbx9LWfUEIWi//Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZiXg4RaaWYgPdIkmGYs/6vFIpLjmbLaKb/fElO2iGok=; b=d8Dq5X21ymlAiJOcAeJ1XUnp6jbeGwAD4PGccB8i0tEmo5NwOshm+21jJqcWYZVK366Chk9rxHWEZ9GmF0ypYqCjHOXWD6w5GS0BrFu3g0M1mQ6Z9X7F+X26M5RSKHgOoZDbMJnc8F+G3SrHXx9NDdiYEQy0vh1AyaS0CVKB9mVVGw9oZTQJUchH62x6lbqdqLejIm2NZTD9wDab2Ev1uy84URzGa0cir+XTyO99v+ZbftTLgqJcTeOI4ntGbDdXhdUrSaCJ57Ov0Zuts/irxFKn9w8wzs8K0KLyFjBfVX6laAEXDkZXdrHcjbjplL/4bwGFt1p4ifJahgr6uVqFzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZiXg4RaaWYgPdIkmGYs/6vFIpLjmbLaKb/fElO2iGok=; b=eJ5xqxkLinkGPcsVXnwbLFJTrgzUeQ+MTtJ37UJGmIIDreHUBVkg6sYlD2yL18g8DJpT4v+oBj8tuysUTG/agGmFbR001zqax6aJpgfj7FYPOOKyxdmTkBoOXjlGjdRvwqraHnUScSD3DGkQgIV3H6STsfKgA+wgeh52jDuj420= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu , Anthony PERARD , Jan Beulich Subject: [PATCH v2 01/21] libxl: don't ignore the return value from xc_cpuid_apply_policy Date: Tue, 13 Apr 2021 16:01:19 +0200 Message-ID: <20210413140140.73690-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0134.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:30::26) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb95fbd9-47ee-414c-36cd-08d8fe84b65d X-MS-TrafficTypeDiagnostic: DM4PR03MB6096: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xu+ohUAqjLQ049XEbtMgfk8/5ndfnbzurHyGlWfu+0zqa8qT31L8xvJIwKU+CTopQMLL2PooOIVpCiA7u+Qw7B6NM4XcwFPMI3jbcOJGIvFnBDq0GJ9PacqV9wu35SLaB2LRRSQOByUmOr21hb2jrX0oK6u6v5IMhjHUgXfA9OsxJwXhP2cpQJBsWvRt4/6hN/NooclFIDN9hjjFkGYuce/Ksm7HLBUQSmO8ZCo9+czDdaQBEDYDsJ3O//6zPlCXTzzIPW5rt4IjdZej0WS1t6D2T7Zx47ZVM89q0dm5paBNqfwDNA691/z5T7ouvn1vpwhvFgwLnCYQke9Bw8l3rslvKLtNg9h3yFnRWSxla4IRtyuHEe3uBCLNjJpK0DSwZ80KLS6obBFQtHgWasdoUidUuWy0P1OPwTxj8QvSEXWT34Cqth6UvKI8zrN+arvPnN6r1mhBkCYcIBJJjFqjfJJ27v+gYDyQdFs0SW6LD9kGjD9EJmvQR+PTrsSn6OoHVbaTgEcLimGciAUGZNJ6UK32LybhR7Ras+dt4Dt3/wooGIv0tK2Dl/nfenlPlhzdSSBJ6Kw5iKGtV8Wm99Skbm9k7GaA+evCQHcDp++Y9kc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(39850400004)(396003)(346002)(26005)(6916009)(86362001)(36756003)(83380400001)(186003)(8676002)(6666004)(16526019)(66476007)(66556008)(54906003)(2616005)(6496006)(5660300002)(956004)(38100700002)(478600001)(1076003)(4326008)(2906002)(8936002)(6486002)(316002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?N0F0UXJwa1dqbUNWL0oxckJWYlhCT2hiazVud1FCdG8ra0trY2xDQkh2NG1C?= =?utf-8?B?eEl4Z1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Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:02.2690 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Fi8tEj8wb3b41sumVcZ8BAFMe6WNwVKOX8Coevm0IIMsbxWTspotNiCZP50Gh3DgEUFfLKdNd6qWJiuK7rHk0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR03MB6096 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Also change libxl__cpuid_legacy to propagate the error from xc_cpuid_apply_policy into callers. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since 1: - Return ERROR_FAIL on error. --- tools/libs/light/libxl_cpuid.c | 15 +++++++++++---- tools/libs/light/libxl_create.c | 5 +++-- tools/libs/light/libxl_dom.c | 2 +- tools/libs/light/libxl_internal.h | 4 ++-- tools/libs/light/libxl_nocpuid.c | 5 +++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index 289c59c7420..539fc4869e6 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -419,11 +419,13 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_= list *cpuid, return 0; } =20 -void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore, - libxl_domain_build_info *info) +int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore, + libxl_domain_build_info *info) { + GC_INIT(ctx); bool pae =3D true; bool itsc; + int rc; =20 /* * Gross hack. Using libxl_defbool_val() here causes libvirt to crash= in @@ -462,8 +464,13 @@ void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domi= d, bool restore, itsc =3D (libxl_defbool_val(info->disable_migrate) || info->tsc_mode =3D=3D LIBXL_TSC_MODE_ALWAYS_EMULATE); =20 - xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0, - pae, itsc, nested_virt, info->cpuid); + rc =3D xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0, + pae, itsc, nested_virt, info->cpuid); + if (rc) + LOGE(ERROR, "Failed to apply CPUID policy"); + + GC_FREE; + return rc ? ERROR_FAIL : 0; } =20 static const char *input_names[2] =3D { "leaf", "subleaf" }; diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index 0c64268f66d..2faa96d9c68 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -1443,6 +1443,7 @@ int libxl__srm_callout_callback_static_data_done(unsi= gned int missing, =20 libxl_domain_config *d_config =3D dcs->guest_config; libxl_domain_build_info *info =3D &d_config->b_info; + int rc =3D 0; =20 /* * CPUID/MSR information is not present in pre Xen-4.14 streams. @@ -1452,9 +1453,9 @@ int libxl__srm_callout_callback_static_data_done(unsi= gned int missing, * stream doesn't contain any CPUID data. */ if (missing & XGR_SDD_MISSING_CPUID) - libxl__cpuid_legacy(ctx, dcs->guest_domid, true, info); + rc =3D libxl__cpuid_legacy(ctx, dcs->guest_domid, true, info); =20 - return 0; + return rc; } =20 void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn, diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c index 842a51c86cb..e9f58ee4b2b 100644 --- a/tools/libs/light/libxl_dom.c +++ b/tools/libs/light/libxl_dom.c @@ -384,7 +384,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, * being migrated-in/restored have CPUID handled during the * static_data_done() callback. */ if (!state->restore) - libxl__cpuid_legacy(ctx, domid, false, info); + rc =3D libxl__cpuid_legacy(ctx, domid, false, info); =20 return rc; } diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index c6a4a187f5b..44a2f3c8fe3 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -2052,8 +2052,8 @@ typedef yajl_gen_status (*libxl__gen_json_callback)(y= ajl_gen hand, void *); _hidden char *libxl__object_to_json(libxl_ctx *ctx, const char *type, libxl__gen_json_callback gen, void *p); =20 -_hidden void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool reto= re, - libxl_domain_build_info *info); +_hidden int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool retor= e, + libxl_domain_build_info *info); =20 /* Calls poll() again - useful to check whether a signaled condition * is still true. Cannot fail. Returns currently-true revents. */ diff --git a/tools/libs/light/libxl_nocpuid.c b/tools/libs/light/libxl_nocp= uid.c index f47336565b9..0630959e760 100644 --- a/tools/libs/light/libxl_nocpuid.c +++ b/tools/libs/light/libxl_nocpuid.c @@ -34,9 +34,10 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_lis= t *cpuid, return 0; } =20 -void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore, - libxl_domain_build_info *info) +int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore, + libxl_domain_build_info *info) { + return 0; } =20 yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand, --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322563; cv=pass; d=zohomail.com; s=zohoarc; b=AmeDOslnr4yOoEJVtUOVLrFlK115Xgk3OlY7mUZBm1b/fWxRkfce0f9lQE5qQpoxMFo32DsxTu3j1dPx3CdKKNMeH/4aBhrqjC3/rRgfCw5LFzvsne8s47I79omkqVO/c/MevCNabWDFFi8vh0YEjIR0T40SoifYB3ZelpG9Rsk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322563; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AoWJS/SFtHWRRkap7XLMIw8mpVF2QgzC+GpX7sO6F4c=; b=JgVepWgeKiVsLCuYHNBfWkMWaJ19dpsbVDzCpYL/ctZBiUDSHmWf9WoHddHFl47/kZVt/m2zUrBeyv0VQLxt+6LVY9FV6P7X7pOUdsIoFJVr5Kcg9mWDyDTX8DbwKwKces6SYsOMQ91PipgKDWHPtIPBaESu0ZPhDzKBUnUIipc= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322563942423.5257227698489; Tue, 13 Apr 2021 07:02:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109768.209516 (Exim 4.92) (envelope-from ) id 1lWJcL-0004un-Pb; Tue, 13 Apr 2021 14:02:13 +0000 Received: by outflank-mailman (output) from mailman id 109768.209516; Tue, 13 Apr 2021 14:02:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcL-0004ug-MX; Tue, 13 Apr 2021 14:02:13 +0000 Received: by outflank-mailman (input) for mailman id 109768; Tue, 13 Apr 2021 14:02:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcK-0004rK-98 for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:12 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 48c99015-3a53-41f1-8730-55d527821831; Tue, 13 Apr 2021 14:02:09 +0000 (UTC) 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: 48c99015-3a53-41f1-8730-55d527821831 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322529; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=OVrwr3BA9em1iIl+C3YJ3vNrkONASrz74AXCzhLJFEw=; b=OPhIvVgtDGgWBs1bHMIP9Sc/ELKEsdBbPMSjvpxr5y/+rseriBVD/uX9 gVkCS/AxV0/48a8H6Ltji90UuO/9rWV6UygI/Z8u41hBIqx+9779HxFFr kv13Oodh30zUHQMIcJR+uhRzkmVkhUWSO7Sex1BIWVqpBIk4EySLAn6Hw A=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: SeCTuAeuUTjiNEw5xG0CgRsQnlCMfV0xcotneONWGIvmP/zwSIl9G0eajD6fFwGIKOStOGSvNc aWpQsM6YXBerPURXrIm0E4kkHgNRVNCC56csl701RM3YFVY0RE6/DVxmWwfVx8QRNUueo2XSUk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8wojKQdPIxFtQYYzX6j4NuQFDFEuqsqOG 93ILbtlLKHtXC7lFy4q1lBC154NAJ48b/gW3RFqUshKEXva4sOvN2ZZCR00GaYIAR8C+fbCh RWqVgy2a/fFe3f+QkST/acdk6KhXoao3yHC70GnLeY2MvjcpQkSrA8WKJwEg3PPwdvmRljrV pCbANsfD6dKhrezYGeyLAEDuDWcNdxxC2xJ9RPlH7ZvUKA4f00SmAjRD6oW86PiQMITz5Z72 cBtJM3sf6lo3KCOGE/iOM3PBlpZH6MCLxLNgiDeb5Zg6vmYg12UGeMiwGLkh1bQBuYy2wiwk jaaQGEc/DCBVRQ/kpV1avn63tYXGSQdUAYUAEwjaRNUUD9/lpj2+6CYaS+l1aLYlwZ2+cHLX Xuej0JOD5jwNixyT+YkDuPDm8d250rJ+DRZY5TNY376zeIEsmlhKsGF/hb8NJZL9joqPYMSv /aVAmPLj/0YtlZrTC9lzIAAm1Tp3Ylm/+zh0Ggw2i8wXIlAf3dZH5hXKoWJtmA727iA9aEua 8J+e4djK+VCCHWbNXD9IT8KxhkATnXqXStT+4ppYtP1JhC/IdbLt3+a3/wyHpD3B8CN8/6m0 MVfbRj7Nn6S/pSVv1XXxgcw0Egm9uOJnY6qwDaAucxelc2kn/QVun5lIbgmP4KCk2FqBCYAy jmzwRtu9PEVTCEz7gUFuYZJnlXclE17B1Zjam/XryVLAWhbOdY+lWmdle7bb9GUaCAXZEdtA xz7d3Nv+iZcUPDqU3tlAo+BqJF6GC8R8yuRCqKBO5T6tS/fW22vZHC2r/7sB7HDR2ha0oZgo VZdUsfKuR74wNS87Ef42yVUaz4okUsjl1Exypo/2Sdg7Sb3A== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="42955875" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a3XokpEHaMnhaA3jpVQSpPGCz28oHwcnso4E3it17TPbnWfEDHblv6E8X4E05soRfgHwv31L2BFmgsUFzSytfOK43Yun9IPHImhhqtDxCauTodzGEi1SA5nCJ8UV9d7tdQSWJZ6aCj/YQe9bUmS47l7mH1rtp0/wcFDFLCo/59P1tuNGxLYU5Oy3bceztzWIaIS2IZzgWRM2zvYib3A6f6Lmi1219Oo163HQor46Jv9TccMW/qU+XGTblLTs8QCrlPcy47dfBEqXf0OyB7MObtndIvAhIzzY1ucyOe+kPL9Jx8pZBNA5479R+JVuR+VTGhjm+xGVh1NECS4WhnwsGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AoWJS/SFtHWRRkap7XLMIw8mpVF2QgzC+GpX7sO6F4c=; b=W7edqZkYpnseA/m33je5UCCLA8cwe5dCjViWAXgE14MGUdY32u/JuXBqI4QvejzLdbA6ECAPZJmiq03TKN7P58bBULr5t4VuAhcMFxrojAj8SprSq3WXZOaaarYC/P9EYyydxd4JPUnneQf3o7ECRrsVIs7J4lle8llAppBnYrWTB9TMzjJi2RFqwLuuMCmMK1nJ2G353Es8ynAvqgBT7QuV6EY+ayFb2xWSAogoCGgszZSJN2WnbtLpnRI5NGKZq0WkAou8dp2YRXCdJpXUD6QYE6kX91Ug+5oWasiQEaoMbrxm14xwODE630cyi1G4sWhGc30+ofwdhXNGgHp9kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AoWJS/SFtHWRRkap7XLMIw8mpVF2QgzC+GpX7sO6F4c=; b=sS7038EEzn81OYlq39E8SeFvBUnN5DNNw2ZRy4VvK9kUoB7OhJg4U7ZGcfI+93WAecHIrKI3pZCYB13Guw5tDdv5FF2WnXRNbUax6dvgoxahueGI9855/DlKY4cl0r8fNPbZDs/5fOukJjGiYkuiy5l8DPGbNDlwDabBnty1l3w= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu , Jan Beulich Subject: [PATCH v2 02/21] libs/guest: rename xc_get_cpu_policy_size to xc_cpu_policy_get_size Date: Tue, 13 Apr 2021 16:01:20 +0200 Message-ID: <20210413140140.73690-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0146.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1::9) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43a425bd-6181-4761-2d64-08d8fe84b9ab X-MS-TrafficTypeDiagnostic: DM4PR03MB6096: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s2asjK6QgMbZDc/csizUOK9m+dMKrGmxI/EyH2CXZWt35m93mly94Lgt1SUd5ueffb+p8ckGbcgCYEedtkYpjQKN1KmuAgEGtBbEuekmlsIa411aRJ19kb7g511Nv8l+CyNZrHi375ZZoykgc9fN1hbqSuHXWYY2jfK10Csf58vqdDClo8ki9oRhrn5p8eE79Knlxeuf0htt87LUi1gIurpPOrL3ujZ3SpBmd5b9djFpImb5O36ZqdkZLxIO4I5Wly9oo/8Yuf/c+7OfslAgdol5PUCdpyZ9RAtzxV+f16AZy3brNTpPy1T+HHpJtIy4qvfa1n7AOoNVcIjH5U1ZcGW8zfdPxQHKZEXjXJV44YE2aUadf9X0ldZwOrRKkbegvBMvWdA95QFhMKUayu1fO8Qzy2Zs298/admYVq5IdLUYgjT9itjrwtgmUQPzd36dCi+QcqxMywUPssj8NFum897/9dEwH8InzF4G9mfrtKZOqywyyiDTjHT4UCsvQFqQ1VK+DxrgLkRmbqeCXIRDrRnsRzZAA0YMrjkrx3xyRa+q+tslf9m3JkVNobipMI2bLT60+oNeo69cskPQdKnp4p0KGBiZbfJsSuUL4WmQK8Q= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(39850400004)(396003)(346002)(26005)(6916009)(86362001)(36756003)(83380400001)(186003)(8676002)(6666004)(16526019)(66476007)(66556008)(54906003)(2616005)(6496006)(5660300002)(956004)(38100700002)(478600001)(1076003)(4326008)(2906002)(8936002)(6486002)(316002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?MlBxYm5nOXpDZHlER3NBS1dCQm9HTmFOdWM3RTNTS0Y1cWE1d0d0TitCTnJi?= =?utf-8?B?VzlOWDNhRmNWb3Ixc3lmem5oZmxwR3RQTU1CZVJiamVnSXNpS1VETEdtYW93?= =?utf-8?B?TVllT1hzVDJPUXlhZ1JVM3UxQ0tSb2plSDBlbnRaSmVpaDhzZ2FiYWVORGRw?= =?utf-8?B?UC94YXpIMEFybXJRNHFNS01pTWdWbHBWMmpYbHY3UHJKYU5YTWh4QlY0Y2gv?= =?utf-8?B?MGZSUlkxa3VMclRoSDh1eVJnc0pDMXpibEdoVEVQZzNpd3RtRGlPYW1wTzFI?= =?utf-8?B?Nkh3eDM5a3hxalcvck44YmZtQ0s2Yi9NRWFZeWpUemt2SkNraWlVMzJaa3Jy?= =?utf-8?B?R1Zjb2laeEJKaW9FUFp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?utf-8?B?MGZnVlFHb0hxdUVuZW9vaW5WU0d6YXJ2MzVFNUgyUG5JN2NzUHJSVWdJNU0x?= =?utf-8?B?dGlsNG5ITldPQ2hLZTZ4WDhFYTRtcjNNaTRZK08zMzZ5dkdSUXk0VWZlVmVS?= =?utf-8?B?RTZGb0NmRHlzYUxyR2xya09TVDJsRVorWkdLUFFWeXFLbUN0eG0rOGZhc25z?= =?utf-8?B?RXl3SUFmbi9sYW9BMDlxdlFoREg4NWxQV2hLdnljWHdQQ2lPT0hCTkluSDJu?= =?utf-8?B?SHlwbFhiMmpCTkxvTVAwUEx2eHpnbnlRd0lhWG1MRnZyQXNIN3N2T1BQVmdZ?= =?utf-8?B?b3JuVzBjRnhFQ1JRN0NCR04yNFNpM2k5N055L09nbkRtQTlIM0V1dVdYQk90?= =?utf-8?B?NUIxNjZiZWEzTGVUNzdVQVA4SDBHK005Tmh2cG16amdlelZvOTZydXFMdVgy?= =?utf-8?B?RDVGR1dLVDNPTnVnMGV0bE1PTWhOcHAwZmwycC93V0I2VXdsc3k5c0FqUkFM?= =?utf-8?Q?Qha/tAjRnEuhTaH0p+54XOg13eKOSKbXgS0Xt+S?= X-MS-Exchange-CrossTenant-Network-Message-Id: 43a425bd-6181-4761-2d64-08d8fe84b9ab X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:07.9127 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: g2Fzh24Z/ay5DGmpo/3r0qkbvzyuHJJGNEwtO65VlejzaVUcXhDt6EfAGjOpMgprWOKf0WCn147TOExvFj0hNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR03MB6096 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Preparatory change to introduce a new set of xc_cpu_policy_* functions that will replace the current CPUID/MSR helpers. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Andrew Cooper --- tools/include/xenctrl.h | 2 +- tools/libs/guest/xg_cpuid_x86.c | 6 +++--- tools/libs/guest/xg_sr_common_x86.c | 2 +- tools/misc/xen-cpuid.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 318920166c5..e91ff92b9b1 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2594,7 +2594,7 @@ int xc_get_cpu_levelling_caps(xc_interface *xch, uint= 32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); =20 -int xc_get_cpu_policy_size(xc_interface *xch, uint32_t *nr_leaves, +int xc_cpu_policy_get_size(xc_interface *xch, uint32_t *nr_leaves, uint32_t *nr_msrs); int xc_get_system_cpu_policy(xc_interface *xch, uint32_t index, uint32_t *nr_leaves, xen_cpuid_leaf_t *leaves, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 5ea69ad3d51..cc5cae95725 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -109,7 +109,7 @@ const uint32_t *xc_get_static_cpu_featuremask( return masks[mask]; } =20 -int xc_get_cpu_policy_size(xc_interface *xch, uint32_t *nr_leaves, +int xc_cpu_policy_get_size(xc_interface *xch, uint32_t *nr_leaves, uint32_t *nr_msrs) { struct xen_sysctl sysctl =3D {}; @@ -302,7 +302,7 @@ static int xc_cpuid_xend_policy( goto fail; } =20 - rc =3D xc_get_cpu_policy_size(xch, &nr_leaves, &nr_msrs); + rc =3D xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs); if ( rc ) { PERROR("Failed to obtain policy info size"); @@ -448,7 +448,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, goto out; } =20 - rc =3D xc_get_cpu_policy_size(xch, &nr_leaves, &nr_msrs); + rc =3D xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs); if ( rc ) { PERROR("Failed to obtain policy info size"); diff --git a/tools/libs/guest/xg_sr_common_x86.c b/tools/libs/guest/xg_sr_c= ommon_x86.c index 3168c5485fd..4982519e055 100644 --- a/tools/libs/guest/xg_sr_common_x86.c +++ b/tools/libs/guest/xg_sr_common_x86.c @@ -50,7 +50,7 @@ int write_x86_cpu_policy_records(struct xc_sr_context *ct= x) uint32_t nr_leaves =3D 0, nr_msrs =3D 0; int rc; =20 - if ( xc_get_cpu_policy_size(xch, &nr_leaves, &nr_msrs) < 0 ) + if ( xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs) < 0 ) { PERROR("Unable to get CPU Policy size"); return -1; diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 2d04162d8d8..52596c08c90 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -462,7 +462,7 @@ int main(int argc, char **argv) if ( !xch ) err(1, "xc_interface_open"); =20 - if ( xc_get_cpu_policy_size(xch, &max_leaves, &max_msrs) ) + if ( xc_cpu_policy_get_size(xch, &max_leaves, &max_msrs) ) err(1, "xc_get_cpu_policy_size(...)"); if ( domid =3D=3D -1 ) printf("Xen reports there are maximum %u leaves and %u MSRs\n", --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322558; cv=pass; d=zohomail.com; s=zohoarc; b=gXEUlxu6rZDIwEpZYMyzTljlASwIfV3D78BjcenMRHDAW98KSCuwI9XijwIObbmQ/8TZOWudI3g3kxoad17bcQYAjVjPKxui8q94AyyO9S/fiRUPapD/0yNJaxOjcGUCLAnbO05KsuRdvm7Tj8IQDlaEhcSHkPW4PDWAnvm2UGg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322558; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XNG8CdU1lDvF/vM3JRvweREahb/itHxFfxS+2tlcVlw=; b=b+6r7FlYbq0PTqnKknnTDuUjIsRtwoUu82wfbQWWLQpt9qrgMd6B3KTcNiK5agZvZBvaUZpDkvJCATdBuqp/CqVAdl591olw8OBSoVLDPBgM668p1rbtjoKhbHzi9MiEnlJRO2B4hVtxmgRAIccGYsvEAw6us1wXAYh9fmtmH+k= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322558117108.38003498525893; Tue, 13 Apr 2021 07:02:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109769.209529 (Exim 4.92) (envelope-from ) id 1lWJcR-0004yg-2l; Tue, 13 Apr 2021 14:02:19 +0000 Received: by outflank-mailman (output) from mailman id 109769.209529; Tue, 13 Apr 2021 14:02:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcQ-0004yZ-Vt; Tue, 13 Apr 2021 14:02:18 +0000 Received: by outflank-mailman (input) for mailman id 109769; Tue, 13 Apr 2021 14:02:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcP-0004rK-9I for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:17 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b347eacb-f47b-491a-b78f-e06b12b7d42f; Tue, 13 Apr 2021 14:02:16 +0000 (UTC) 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: b347eacb-f47b-491a-b78f-e06b12b7d42f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322536; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=mB4obio716LwGQbmmtPzikOtLnuYNlelD6BrKRg8sk0=; b=TPi/xwKM/R3lOCiAZgO4AXJI6IeT3BVy8uZgr0NiZpcU2wOb7Q4Q2mDU qr8tdslZkbBtnBZdZXuDatqenZS1yv8YAv8hK+qa9xjZGJNvnUa7mNla1 C7xsJBR7TD7qqNs/Ng4Krb4I2wSw1EihWvlhoil139UIf4MCQEAPAgbCx A=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: NDbDpY8DBSNyLo8KErrFWsE7BS2gc3mmZsToRgTsST9nWEvtoJrbrgHJnu/IQLulH4eAgHb84k dx27Q6arg5IOdxoI4iFFqFLKUobTipHztRA/HUt3z3hg4Hqq4yaWFhrCwqHZ59fsR66vSj5LH0 mk/F1aG42TLEcPiGxnZ5NPs3NNMV/HPjkPVGEgPKXtNQTOcp6WYHSGJ/BaGHPm7d94kVk6EBH4 jE8shNYXuKTgmF1X4o8rJBFuDR0rsRB3IxjQ+wDcut8MA5Olb9VSnK6vNOvyzCKHQb2C8in/Dn 0tM= X-SBRS: 5.2 X-MesageID: 42955896 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:iDZwgKrpOz0K3Z/in5UjoKsaV5tgL9V00zAX/kB9WHVpW+afkN 2jm+le8BfyhioYVn1Io6H4BICrR3TA+ZlppbQAJLvKZniDhEKEJJxvhLGSoAHINi3l7+hG1b phda87L9vsDVd7h87m4A++V+snqeP3i5yAqvzZyx5WIz1CT4FFw0NHBh2AEktwLTM2YKYRMJ aH/MJIq36BVB0sH6aGL0IIVeTCuNHH/aiOCXVtaCIP0hWEjj+j9dfBcySw4xYEXztDhZck/G TV+jaJgJmLjvfT8H7h/l6Wx4hKmdfn19tIDNGBh4woChiEsGqVTbUkf4fHgRcYj6WE7k0wnN zFvhE6Vv4Dk0/5TyWQqRvp1xKI6kdI11bSjWKzuEDOherFaBICYvAtub5k X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="42955896" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ASAOl0eFExnNjB0xuoLpv+GwXwvyI+xqCLF/qEhzFfzW0drWZpXMn/vjX8v4pqfuDNyP0IzKSjsS+05elakml8SiN1kCaopCQFkpGaAny8p0aX4QSd2G0RN4I+gj14J9lr07vYWYOJr3U0+4lP8RPyQbZKbKEg4CJvmNmsB/sZmrXV0r5YY1mjlGlCWr7G0zbIzXOXD/5psd9QpExolv0bAuHhTeMiuLPGCCQNPGtrbY7YhbXtEfOnM7XKujEH5BAcCVlm8+Ar5UrOdgbyMNa16qkvlHw7h+RwqRe+1qb3IlOZStzq6QWviPRQd4mlf7Y7mMwOcOaDCdUsu3RnjCJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XNG8CdU1lDvF/vM3JRvweREahb/itHxFfxS+2tlcVlw=; b=mMrkboakucD4rTbRTYx/xEp4kDys9RM8yZbVmAsm9GTLgAZL4A4OJHzt1lfRUEsZBWETzbpnP36WYhQCr4MtQkqESjamGudTlq8nkFcTfid4G+47JHhW3ZUv6LifiCG6ipM8ttP5322TpUu0QyX/qlmaybmdpklU+RsuKAai9+6v8jmxCk2EEdlU1nXQHcOhN9YOb5QlFfXWWPP7dkAavT40NRU1u6Y3SatSEkAranwvwH3dYVNZGdp6G7ASXBkCB1TS76V99X56iiFMLd7HXCGcN+12eSBrJs30VQk4nYpcB/qrOg7eYdB2m/3R3DzYt6diA2JEsPHZNztaJnVFeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XNG8CdU1lDvF/vM3JRvweREahb/itHxFfxS+2tlcVlw=; b=kSj7/KquCoH3eIcW8cFOntyBLOP9kU2axF95kXMTR1vgLqy+ZrCh/v1iJVx9QmeN81Y6NDD/cUe/bR+cZM9gsc2oJpN7NTvLA2sZbX0xjJksOCmCPxf7RQF3BN7745wTgVda78+uhr/yU4NhL/RAjBbrj0XdtpX470A/ekP95Cw= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 03/21] libs/guest: introduce xc_cpu_policy_t Date: Tue, 13 Apr 2021 16:01:21 +0200 Message-ID: <20210413140140.73690-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0016.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::28) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6193172f-8a0f-4590-7d0c-08d8fe84bd26 X-MS-TrafficTypeDiagnostic: DS7PR03MB5542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: THCNHC3Qb1pEZ8hxvomoPX8bssJLx3MHz/qew1HspNkEtD0Wo8UN16nANoVb38WPXCU8wb9jTFldmrl06RCzez8NEf0T4GlxKWIca4Frp7JoEIYGej7/RBmO8B5rn78+mLDG8zkpmn6LJQXBIufId/McNn4ZJPq1snQC1dACK86qnjX9A9SXGE7p5yNaF/fOQxfu2G9I84vNeovEvnkZU2t7NDcUFvW6KP7roEpsk7LfwEhxCkdlygTIWqmYgZhZndf/EcxHcl+3ju8rvPtRVkSr12q6x7ozRBE4Ktk1AILHuE4S45GjuzkSOZXR7lJ4EBxbMq0FelVyTA3vExf7SFZmErI43IIKJrN1EcQTKzddYj8MjF4NFhcneL1FvEuTmWETfGERMjBwBo+vZrHSd5xFO7F+1JlffrtS0AVKvAiMnyejGoo3eKXZFujFwKw2IH77zF95BJYF2Urg49iKyIOtOOWmtqMyXt8PmVhD68arILFUfvLu4f6ExbAEN+0pepvBTvVxb0ZhAbznSb+DTh7DS3XEx+ZbOXOVUH3ZN2tQ2SPPjwn6gdmNAocTUbyef/60Rr/5Zf1blfRssh0O99ym1tUDTgHGar4wE/2EV/8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(366004)(39850400004)(346002)(376002)(2906002)(6916009)(6486002)(36756003)(66946007)(54906003)(1076003)(6666004)(5660300002)(66476007)(316002)(66556008)(8936002)(478600001)(186003)(2616005)(16526019)(86362001)(6496006)(26005)(38100700002)(8676002)(956004)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?SnlNUmd6YVVWckNrc2Vtb3l5bGwvSHNjcEczRWJneTlPekU4QWs0MVVuTVcx?= =?utf-8?B?Q0paanVNdDVsNnVHYWx1OTFQajdsblB6U2xkWlh0Y2ZESGMwcnpXaHk5d2hF?= =?utf-8?B?ZmY3N0xVTWFvUzRQMmcvUm43WnNwUldiZnNvZG12YlpQZXYvbWFxYllRMEpu?= =?utf-8?B?elpsWnVMZlUxeUtpK1lFVkdOendFNzd3SDQzbHV4RGR1ZFBkd3kybk8wRGdH?= =?utf-8?B?QWp4SEpHTG4rVGVya1FCVk11VnNqa1kvaGNqRThMUlF6KzJWeC9welJPZ2VM?= =?utf-8?B?aG1yQ3FORC9icW16UU8yQ2pSQXdLU2tMblMwbW84andQRnBVVzhhbTM1R3NV?= =?utf-8?B?WTEvWmxmWkpFWGZScTRFTDhKTWMyMUpsTDlyTk15NlJZY29Ic1ZURzNLZFUx?= =?utf-8?B?KzJqcDI1OXptbVVvWS8vaXNjNnVtVncwTnIxdjZSVEhVUDZ3WWtEMGE1TzAy?= =?utf-8?B?OGs1R2RDK0IvbWcydTZydmhUd0kxUDZVVEpoVGFOdVFPYm1ub0I5Z3dxNH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lQbWxaUTc1ejBP?= =?utf-8?B?SHBLUWo5TWROSE5kcWFMakdBejdUOEFBVUl4MWIxUk9vcjdQM0kwMHVncWFa?= =?utf-8?B?MzkzVVY4c1VkVDF2SGlvd3l2a0lraVZKdnpnMkRKTEpxTWZaTnF5dzZBQlNu?= =?utf-8?B?VFZnTm04c0t0cHdnWTZibU9JVVlDOFgxeFhSa2locEErbmRMbitsaXp2MVNX?= =?utf-8?B?RzUrQjE0NjVKT1NoUjU0VlV6WE9NWTMwbXl0UGxESThNQXdNZkJRUDZ6c01k?= =?utf-8?B?blBXU2o3elNtbUhhUGpKSnVNdHJDU2d3eFlPU2xZNnNxYVZLWU9qSGhnMnhi?= =?utf-8?Q?1dH3fMU2SQL6yejA3+X7f279vSADSK3SPIsYBZI?= X-MS-Exchange-CrossTenant-Network-Message-Id: 6193172f-8a0f-4590-7d0c-08d8fe84bd26 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:13.7615 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oKs27sWmeiUOYRmUzxyqOuZ/c2MtVuOQzeqgAagUo/uFwawuHPUEwqRJgdoQVyB0c0SmnnzF270nnWO4nVsLUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5542 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Introduce an opaque type that is used to store the CPUID and MSRs policies of a domain. Such type uses the existing {cpuid,msr}_policy structures to store the data, but doesn't expose the type to the users of the xenguest library. There are also two arrays to allow for easier serialization without requiring an allocation each time. Introduce an allocation (init) and freeing function (destroy) to manage the type. Note the type is not yet used anywhere. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Introduce two arrays to store serialized versions. --- tools/include/xenctrl.h | 6 ++++++ tools/libs/guest/xg_cpuid_x86.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index e91ff92b9b1..1aba814f01c 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2590,6 +2590,12 @@ int xc_psr_get_domain_data(xc_interface *xch, uint32= _t domid, int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket, xc_psr_feat_type type, xc_psr_hw_info *hw_info); =20 +typedef struct xc_cpu_policy *xc_cpu_policy_t; + +/* Create and free a xc_cpu_policy object. */ +xc_cpu_policy_t xc_cpu_policy_init(void); +void xc_cpu_policy_destroy(xc_cpu_policy_t policy); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index cc5cae95725..8e3a1a8cbf2 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -39,6 +39,13 @@ enum { #define bitmaskof(idx) (1u << ((idx) & 31)) #define featureword_of(idx) ((idx) >> 5) =20 +struct xc_cpu_policy { + struct cpuid_policy cpuid; + struct msr_policy msr; + xen_cpuid_leaf_t leaves[CPUID_MAX_SERIALISED_LEAVES]; + xen_msr_entry_t entries[MSR_MAX_SERIALISED_ENTRIES]; +}; + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps) { DECLARE_SYSCTL; @@ -660,3 +667,14 @@ out: =20 return rc; } + +xc_cpu_policy_t xc_cpu_policy_init(void) +{ + return calloc(1, sizeof(struct xc_cpu_policy)); +} + +void xc_cpu_policy_destroy(xc_cpu_policy_t policy) +{ + if ( policy ) + free(policy); +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322567; cv=pass; d=zohomail.com; s=zohoarc; b=laryxW2ywPyNTuofRyiCZqzTlZnZ89Qan+3XVZI8RkUS8+nUCkJGrTobVJ/2enl9dfoTPJnR2aCstWxcgnRk2r2TFS+QHnwIlZber42QgHCl9DBo1g0fKCh/eTugefnqoX2GQ8X8xrLSuhYSFXo4ix+KBxlBPFMNcaVZAlA7Uzg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322567; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6P/SnasJN8U82dOcBiB6I/f0U0K1k+7/Q7LtDAffDeY=; b=IVy8VP4J/SwfGG6X/d6KteUJuUFKBbdT9Nrv2TphnchWy5eiHJ0agac/CaLPA8HUeNCQPXmL7JvSzrItPUhNX+AXv+T9vebvS1NIkSOvkhqXz2loJrei88xOubVVSIDeVKfu2nwyLJ70TMFXAPTCSqva+Jt74AYT9QPILs3ITD8= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322566986453.04727068556315; Tue, 13 Apr 2021 07:02:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109770.209541 (Exim 4.92) (envelope-from ) id 1lWJcX-00053U-CF; Tue, 13 Apr 2021 14:02:25 +0000 Received: by outflank-mailman (output) from mailman id 109770.209541; Tue, 13 Apr 2021 14:02:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcX-00053L-8Q; Tue, 13 Apr 2021 14:02:25 +0000 Received: by outflank-mailman (input) for mailman id 109770; Tue, 13 Apr 2021 14:02:24 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcW-00052d-0C for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:24 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5b7db29d-1084-42cb-b665-9ae2c43f7373; Tue, 13 Apr 2021 14:02:23 +0000 (UTC) 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: 5b7db29d-1084-42cb-b665-9ae2c43f7373 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322543; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ovr7/YsUP39oXdKzt7Kk8fSJbiorDCwX07ke7Osg8Gc=; b=fi2J8ld5ELHNbVU27V6f+ln7C3z/kPXjbZiW7nR11irfX1qfgYkSiHfJ wvtRsPMvRHn+xoXtkF9myjO/CYnLzR1G0fBjjF2a3WtFovIQmu6LdIQnK EdZWsUsQf4xt9sgH2tCv0ZUa4chCwFiCD0WgFOFx0Rtq1AiXhvrUEZqXd g=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: Zp14r/kNJzYeinSih6yGez5dnzsPOTnNkIKP5E5mMjTg1o5KeUcGHsguFHr3TUpODXu4VG3zg1 YOkX6ubrhaoW6cOwJIXybBgx34sRXytxxldUhUbrrKzxiIYacJKqgSEUDRyywOWjoe5/yu0mgu HG/+3LThxnEJKcZJHoLyscH55xho23jbw0pKtFplc57NQmBE3NVKYhq24Qan6Eth3RkpIclGhy ugqF9Oxme2JC9eT5TvEcKx/8q0cIbeO9EJEz8Cl08hSF6Zbw46NHg7XzLs+JNSy62UleUNxfxR V+o= X-SBRS: 5.2 X-MesageID: 41866893 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:F72rGaF+VB3OFmT1pLqFMpHXdLJzesId70hD6mlYVQFVfsuEl8 qngfQc0lvOhCwMXWw78OrsBICrR3TA+ZlppbQAJLvKZniChEKEDqFHqbHjzTrpBjHk+odmv5 tIXqBiBLTLYmRSot395GCDfeoI5Pmi3OSWifzFz3FrJDsaCZ1IywtiEA6UHglXaWB9ZaYRL5 aX6spZqzfIQx1+AviTPXUZQ/PF4+TCiZOOW3U7LiQ64wqDhy7A0s+YLzGk2H4lMg9n8PMZ3k Xu1yf44aiitP/T8G6n60bjq654tfGk5t9KBMmngtUYJDP2mm+TFflccozHhh8ZiqWC70srjc ntrn4bTrhOwkKURE6Zi1/M3BTtyzkn4XOK8y7mvVLT5fbXaRh/Lugpv/M8TjLpr3AOkfs57Y dwm0WejJZTBQOoplWE2/H4EytEu2DxnWAvioco/htieLpbUpB9h6oF8nhYFZ8RdRiKk7wPIa 1VAMbQ6O0+SyL9U1np+m1mwNmbVn8uBBuxQk8bpsyP0zRN9UoJtncl+A== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41866893" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nQ4Y8ZA5AMUfBpf6/amurY82kCJ5uJ78eh6wrc8fxBKby1bc3SLKMiAk4a4mctw7yisEKfPoE6Vp7w3wex0cIlhhVIFRZbcuHObaPhEcisaUYgFc1PYleAvnqLNhToP+uSEo/rFWutEPgE5dKvjGIsigVADOgSPtHUkOjXVQWaFK29H87+qW/mEAkzjPxB05M22oAppWAq/vpJtBjBMirIgTuphxMgsaKoTSdNix3wODF0dUyhmVJdKMQI2248MkkEK9kRXxVOxb6EEIBlzmbJroRaBUVTesO6AwudZQQ6K15KeADU52kkYntgSNuQeGp5GLzAWesM/jcNFSKw+zXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6P/SnasJN8U82dOcBiB6I/f0U0K1k+7/Q7LtDAffDeY=; b=Pj733Uw5RGvl2LpBFwhJaKuG13CVHVXxGAgo1O3ZfG+9TdoRbBVL3xXzXFLnpLNThmk+jlIc4gb/vZBc+nKm8n2xWGMUP6WOGmyr7u0E+wgSDeZ6NB5V1Fl1wUqLu53juWYLTAvM9SYO1HslduTbFCvbFpTmAmcGmyj2U43UFGVsGpNEqOTcofTFQl+3xXDkID+Ja1TrPF1aMJglTOsmbPK2+5VEXKaTFZlSW33gH+TuI2xWznvclexaLII065X9jX8HL371qptqGffOpbu69x2DlqaDXA9BWTu4NY4kvGYXnU+NQiuCWD5g7F1kGhvoAbyfuhmuV2X0sFUZ/AUY9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6P/SnasJN8U82dOcBiB6I/f0U0K1k+7/Q7LtDAffDeY=; b=lX+TpiWF2XNzmwyxsDJpNCw6mqn5NIBWWbxvh15bItXOb39mRp5T8XZd4muaqxuxVha72ULeTQjqqp5tLtHlZ1w3rRsOtDa+17ArRCxIozyFcWgLq7vVXfT3gyw3sGCby8gzuhqrfoAjh6iJfwLWd5V2EwAClfSm0/7jzV5RB/A= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 04/21] libs/guest: introduce helper to fetch a system cpu policy Date: Tue, 13 Apr 2021 16:01:22 +0200 Message-ID: <20210413140140.73690-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0010.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::22) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 921b7890-1c3a-4d82-4348-08d8fe84c01c X-MS-TrafficTypeDiagnostic: DS7PR03MB5542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:127; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c7IIScWxMDQ7+9qfzTz1pxH4VJMhjglcOkYkjJmuYmg+WpE44x8grGJ+OQ2Qs/LHaeZxT6sLIZ94WB10sqOGrFB0x8aV+/dD2dEgZR3j//GcjVupAFE+RvyPZ492mieBBTu6E3Ip70f/HbdbbabJk/0Vzl7tyZdez/B3VCr6NAEIyXLdfzO+9llkgHa8ahwmKc8v8foMXbzbNLMd60DqHmiHqeN7l4eSx2yWCsJacFssB/QHXO+WDAj5JlVENKzFIFOH8B4KYZRVdKeVnZRqKFQ8JXumcW47l/aizvz+DLJboFhzanrc5AgcVlfgpuWSK9u9SnJIACfFIz9DDPF54Hhnc1U5/BMdl0kfRqc0YnaCkj+RlnvgioUx34laLC/XpRF+1uqPL69UBoB9L9qljQe90k8PbQcWwDPm7iEpISKBwCAAX3VRjlyQd22O2c9its4geITHgzxzI2nPPKd6I1fZxFxTxT22E2AOiqywN6wTZvfI50bs9gah8UTPh42xfsmodCnvkEfFNtusMf2uLBqSbnnop8xAhvd6khceX4uRor6BGPkb4fQNqOeQM2RQpMjB7qUNTWLHppgSQmq7/sOSkmqNyIleYvICjkPd6Ew= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(366004)(39850400004)(346002)(376002)(2906002)(6916009)(6486002)(36756003)(66946007)(54906003)(83380400001)(1076003)(6666004)(5660300002)(66476007)(316002)(66556008)(8936002)(478600001)(186003)(2616005)(16526019)(86362001)(6496006)(26005)(38100700002)(8676002)(956004)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?RVN3dGpDSXJiTGtKR1p5a3VuRkpkNnk5NmxzUDVid1htZ0IvTzJHMklscENJ?= =?utf-8?B?TTdnblV1QUxPQ29lM21mcGhaNjdQUHBPM3NRUU5DVzVNZmRKdUZQZHpJQjJm?= =?utf-8?B?MHlJM3NXazhLWW1taHp3dUZIUnlhRmw1SWFrdHQrVjhBbnVMWm5XWXZIdDRN?= =?utf-8?B?WkdTTFd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= =?utf-8?B?ZDNBR1ZSdnFzSmF6aktlSjNBcEsyU0ZsOTlnZTlDcUtRaU5iOEt3Yjl1RDJO?= =?utf-8?B?b0V3UmNPUHhRZG0zL0VuaGtiMmlTWXh2NGRpY3RaMjdmZ2hjaXdpemZ2dlNG?= =?utf-8?B?djJ1MzNkenQwT3N0dXFGT0dJMG9RRU9aUGdQc0w1WEdwNzFWRnAwR0dtL0c2?= =?utf-8?B?S2RGNWFqcWtGZS9nRXJvcUdhdHJ0Q1A5a0RCSjVjMWpGN1p6OW5uYWh1WUx6?= =?utf-8?B?UXd5ekpOcFBnbVhBSEtHWU9wNVhaeTJNdlA1c1hlR2RUQXRYYlFHd1d2ZHk2?= =?utf-8?B?azB4MjRiaytaTzZSaWUwVVVuNFNZYkNYVjhScllnM1NTZGE0OVVqbEhTVys3?= =?utf-8?B?QzF4Y1J6dHZhME9nSll2eCtTOFIvODYyYVkzWkRiSTRXRjBEWE90Nk1qZjBE?= =?utf-8?B?RnFvcUt1dHV6aWxKN3lmRnRnV3doZHVxZ2RnVlQwZjRCWXRYVkswUk1rWkFu?= =?utf-8?B?U0ZSUlV2UUlkZENHR3N0VG1yVk1RdGMyQmdHRTREMkE1d3dzdTY0MTVIN1NX?= =?utf-8?B?WUNvWFQ4OGR3THlJelZDdWJIamdYemhqKzRXSEdZK2kyeUpXNzJhSkdWSW1m?= =?utf-8?B?aUpDYVBIWVhuVlU5QkxQRGtZK3VHU1N4YTZhSzFYdU9rT3lBTVdnMHQ5OFhC?= =?utf-8?Q?tWa9A5Qo8YGm1jpajKo1NhuRTf3Ash3SVOGFl9n?= X-MS-Exchange-CrossTenant-Network-Message-Id: 921b7890-1c3a-4d82-4348-08d8fe84c01c X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:18.7221 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YWytHuSaQZneGV5Bufk4+EMLRnRy4cHiOKQFthuuoWuvQQoHH56B4e8WU8yNenR/Zy2EaNgKXT7t/HZoE/07YQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5542 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Such helper is based on the existing functions to fetch a CPUID and MSR policies, but uses the xc_cpu_policy_t type to return the data to the caller. Note some helper functions are introduced, those are split from xc_cpu_policy_get_system because they will be used by other functions also. No user of the interface introduced on the patch. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v1: - Always return -1 on error from xc_cpu_policy_get_system. - Only print detailed error messages if err_leaf or err_msr is !=3D -1. - Rename idx function parameter to policy_idx. --- tools/include/xenctrl.h | 4 +++ tools/libs/guest/xg_cpuid_x86.c | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 1aba814f01c..187df5c5d2d 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2596,6 +2596,10 @@ typedef struct xc_cpu_policy *xc_cpu_policy_t; xc_cpu_policy_t xc_cpu_policy_init(void); void xc_cpu_policy_destroy(xc_cpu_policy_t policy); =20 +/* Retrieve a system policy, or get/set a domains policy. */ +int xc_cpu_policy_get_system(xc_interface *xch, unsigned int policy_idx, + xc_cpu_policy_t policy); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 8e3a1a8cbf2..78fbc7db9d3 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -678,3 +678,57 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t policy) if ( policy ) free(policy); } + +static int deserialize_policy(xc_interface *xch, xc_cpu_policy_t policy, + unsigned int nr_leaves, unsigned int nr_entr= ies) +{ + uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; + int rc; + + rc =3D x86_cpuid_copy_from_buffer(&policy->cpuid, policy->leaves, + nr_leaves, &err_leaf, &err_subleaf); + if ( rc ) + { + if ( err_leaf !=3D -1 ) + ERROR("Failed to deserialise CPUID (err leaf %#x, subleaf %#x)= (%d =3D %s)", + err_leaf, err_subleaf, -rc, strerror(-rc)); + return rc; + } + + rc =3D x86_msr_copy_from_buffer(&policy->msr, policy->entries, + nr_entries, &err_msr); + if ( rc ) + { + if ( err_msr !=3D -1 ) + ERROR("Failed to deserialise MSR (err MSR %#x) (%d =3D %s)", + err_msr, -rc, strerror(-rc)); + return rc; + } + + return 0; +} + +int xc_cpu_policy_get_system(xc_interface *xch, unsigned int policy_idx, + xc_cpu_policy_t policy) +{ + unsigned int nr_leaves =3D ARRAY_SIZE(policy->leaves); + unsigned int nr_entries =3D ARRAY_SIZE(policy->entries); + int rc; + + rc =3D xc_get_system_cpu_policy(xch, policy_idx, &nr_leaves, policy->l= eaves, + &nr_entries, policy->entries); + if ( rc ) + { + PERROR("Failed to obtain %u policy", policy_idx); + return rc; + } + + rc =3D deserialize_policy(xch, policy, nr_leaves, nr_entries); + if ( rc ) + { + errno =3D -rc; + rc =3D -1; + } + + return rc; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322565; cv=pass; d=zohomail.com; s=zohoarc; b=fWeoDb0L5FFWbxGIUXBv0ehBsT2iKH4pCSfjZunwbGZICOGiTX+JYtjpM5MR0yoaLn6dh2NISn3yzyrzRUsGWuiaE8bgwkDL9tg6+iv/skJioK0K3VnYzrrsNVOGSuvBHt26JjLKF/FZuQ7D+oQSCMq1lFKo0XIz3ZJanpt+o8Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322565; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7iRy9GuGFLyRtl5I3ssxtVqxdTgRXM3rmBhXql49R5s=; b=MZulkjF7nIoUpouccJJhQKjnhL/LJAGZLynZsoLr0VPkPrnuCio/k9wcEVe2xRWI2Xh+TFmQQiW+p5Hvs/jehbLi4wVCXJkffK+WYalzJEKTCutOPHoYb7YY10LVPso2M1mRoc3i5Nr320K5vQA5Heuf+mPF6GpEbA0h1nnco0o= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322564965910.3048459611628; Tue, 13 Apr 2021 07:02:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109772.209553 (Exim 4.92) (envelope-from ) id 1lWJcb-00058B-SL; Tue, 13 Apr 2021 14:02:29 +0000 Received: by outflank-mailman (output) from mailman id 109772.209553; Tue, 13 Apr 2021 14:02:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcb-000583-Oq; Tue, 13 Apr 2021 14:02:29 +0000 Received: by outflank-mailman (input) for mailman id 109772; Tue, 13 Apr 2021 14:02:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJca-00055v-O3 for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:28 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 97c9e2fa-9949-4b1d-a14a-e3b47dc21392; Tue, 13 Apr 2021 14:02:27 +0000 (UTC) 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: 97c9e2fa-9949-4b1d-a14a-e3b47dc21392 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322547; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=WGVjcZJbLqz1e0K2Qv90XwMs+SAdnWmxpckssWf3UQY=; b=KnJRdZif6IhAZ05E7o7r9vSRM7Qixa/ypY4+thfB7LirB1Jl5SXtXbGj HSpXIwioa1o2RhkhMAIsdU2DS427G32aM70LdboyBaVsOVvyUC6LC2kTo +WQql1KVUhYdo0YHuAM98zzoiBe1KFJi6LwtyKb94/vRudp8igQWHqi2G 0=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: ny6wdbq1xxQnWPkZASog2YB8UKm3gHC6diJ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arcselector9901; d=microsoft.com; cv=none; b=S0UH35FCVfoJidA/NbGvIfQ3vUqiiuwkHizfhN7kk1PCBbY0ak1uc1hLgMNyCJQu1DcjqoSkOiVG929DUEtMzbyRKqR/npSRt5G2heuKv1vja9DpwDrRoKLP1cCM9uOK57O2fPhd1rGH7APqXW6uXREv/Chn1mF6EP2wGgJmZ4o90YfV4A9BRUjfxeVtxejr8aP4iS239Pa4Oe3HtZe09CvsIl3QdmPwXERqGItmSQboqPbFa85C4H+y76FGHRs6rG9UJujTJcqRbjrbTf+TeR1VpquUN5lZvRSIVPyHkxhT28XPkve2SBKONb6UFbX2APJHtrMQvVzzLyAPlTKR4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7iRy9GuGFLyRtl5I3ssxtVqxdTgRXM3rmBhXql49R5s=; b=MoMjLFeu0eSqLBEE5jsaJGwqw91VgXzhDyNKaJCkxDk/dzuuoIxd2v2QsB+stqx+XE36pk9vYnBAIHm2PB7f2zfLWwemRZnTuv/J67xWMAyHOmLMGwwM3vJc+Ud0b71hjleeZzC2IiN3qTiwbuepmHARZ2RLp/0hrEKiseTLJFrh/JV2NnFrcG9+bYJDyXQ5MORivKUbs7vyD4NwsgU8P36kNp2NCQg4K1U5KL3Hr2ndm3M+0SjSpYfko/wt9qSWQpgt4SZKf0ftH5Iuj5/oiiGzlK2IjO8V/UWBOxDLSBDE/rBlxn5MzrWlVzcjGL8EChGyETiIOro/cy6CTcCMFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7iRy9GuGFLyRtl5I3ssxtVqxdTgRXM3rmBhXql49R5s=; b=TdtqAeIsDqDormoIW/dyYdtKqYId6j57wKMHCf4NxDyE2qIAJD3SWWP6CMUmEt/AuBNL/wCwpPhiSIHHfOi9nhJkw77tpNWAgyom23YV+3fG/2RxFI1BrI9DjYxLCPNYfqxRMpBeMeO2IFSAqsir3A8XsKIsFpsHS/PUbJOzfac= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu , Jan Beulich Subject: [PATCH v2 05/21] libs/guest: introduce helper to fetch a domain cpu policy Date: Tue, 13 Apr 2021 16:01:23 +0200 Message-ID: <20210413140140.73690-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0022.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::34) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b192e6b-f1bf-4f4a-8614-08d8fe84c39b X-MS-TrafficTypeDiagnostic: DS7PR03MB5542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:612; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SwGd5gfYa7rwXBI15R6ZI7yv2qgTgGP5EgzHyQKonLf0/2PSmXFKh13n+JrjHhrjR+LwOE8mSlVR3DfdEGe7yj1nw9GXGD0M+odwFa0sKvJu0XTf4fc3u6dl7lKYhj+kiY/MFMBewLv9bquhk3gOwZBOvkELzSV2nJILiLh7IIYhDyMGKpF44P1WvCX7AO/VwnORwpfEoX9ET93GWiy5iTshH3tvoutdCwckoEc4ZlgX3GFHoPK2to8XBtm+d52/JcxC0s0u/wghy8A1bAm+g4JsZIYfrX4u9ggyNAoxow9a0FzDo+BVFvOt+8MG1YJpcMJQQW3tghomPWmvrM3myonIQiCNytuzCS9nNOFuQiNyYXieqQMQIajD5xPojLwOpEsVmb8dxXG5Aj9Oq41nddF11Ue0+TTYcaKmE0wZ0DggyGOnldx02hDfT4qKP0OW7fXe0Hj1WmjFluldwREtEMWJwPh22fXkLEmRl25Gec1NXMexXLeTvp0uoMtki0uVn3+JXYiXAQqmSeSNRb1RFtgnAMGjZh/MG+CsJM8zBCFnY+DpbgO9F8gSPBe1hZv7JV0EHRCE4n6GkNSgZZXfFRB4b+KX4MOfKAEFEB8DL4U= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(366004)(39850400004)(346002)(376002)(2906002)(6916009)(6486002)(36756003)(66946007)(54906003)(1076003)(5660300002)(66476007)(316002)(66556008)(8936002)(478600001)(186003)(2616005)(16526019)(86362001)(6496006)(26005)(38100700002)(8676002)(956004)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?T3ZDSUhqQ28yalZtMm1DOGxHV1lZK3hOZjRPN3V4WFl5M3ZpclFXTldDcThh?= =?utf-8?B?UFVDSElCUnR6QVYyVVBGMmZCOG9BYUxCN2tDaGNCUHlGRFEzWG1yVTA3V3N6?= =?utf-8?B?UFhSdHQxRlptaHpMOEI2M2hRdzZ6YUdGYWdHaHFFT0RqSmRWOHN0SEdhYUdE?= =?utf-8?B?aTlGV1FHWVE1eEFPR0w1NmRaYUVzN1hBbWpycUhuOENhSXZsRjVuT3dpVEV5?= =?utf-8?B?Z080TTk0a0FiSmlndzZtenBxVk05eTlWaGx2Rzdm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TEY1REl3S3NIb2F5T0RJ?= =?utf-8?B?MHRrRjBEanh5ODlsYWV0RElaTGlKM1RwSldlNzNyc0d4Nm5nYW5qY0hHT1pO?= =?utf-8?B?R2VYVjkyR3gxbEUvSkp6eVh5SjVUSFRGVE56SFZQOGpJTDdCci9lc2RxeDlN?= =?utf-8?B?NXdSdVgzMFlRcVRpYlVQN3JqankvTWhtdVYwSHVsUXRJbUlLSzV3bXNMT0pP?= =?utf-8?B?NzFnR0FKWXN3Y1JnTHlzY3dzR0FhNHVGcFFTc0RZbVBoekxhblNtVWJMWkNi?= =?utf-8?B?NXBMaFZtR0N4d2NadE5tV2VzZWNnbVhKQ2QyOWhqc0hMTFZFNGdCZWQ4UlZh?= =?utf-8?B?T1Qva1lmZ0Eybi9mV3VJTEtFWHRRSjhzRkRjSkdhek5Wakp2UnhMSENVREZG?= =?utf-8?B?Mm5kRU90VGR6ajIrdWIzSjVDQmd6bDJkWXlQYU1XK0czSTNZNGlocEM4dExM?= =?utf-8?B?bVhDbUUzYXI3b29xVHBGenNDVmFpUW44eXZubGRZaGY5Z0ZYWENmbFdyU0cr?= =?utf-8?B?YXpsUTdjMUFrSlR0REsyNUpxano3RUtPOGhEYTIyS1orU3V0blRGckZpY1FK?= =?utf-8?Q?T7HdEA7WY9haC7uC5Y7j5ms9mLSWWUVLR+O3Iuq?= X-MS-Exchange-CrossTenant-Network-Message-Id: 2b192e6b-f1bf-4f4a-8614-08d8fe84c39b X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:24.5948 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aBztJWLHqpR0WkZC30vqVhX+ZwEm99zFiE9cQZnhjmnxrLjEFXVDICUyOYhbmssHyuI/WFc63KNucr4pAp9O1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5542 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Such helper is based on the existing functions to fetch a CPUID and MSR policies, but uses the xc_cpu_policy_t type to return the data to the caller. No user of the interface introduced on the patch. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v1: - Uniformly return -1 on error from xc_cpu_policy_get_domain. --- tools/include/xenctrl.h | 2 ++ tools/libs/guest/xg_cpuid_x86.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 187df5c5d2d..34d979d11da 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2599,6 +2599,8 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t policy); /* Retrieve a system policy, or get/set a domains policy. */ int xc_cpu_policy_get_system(xc_interface *xch, unsigned int policy_idx, xc_cpu_policy_t policy); +int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, + xc_cpu_policy_t policy); =20 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 78fbc7db9d3..1394e503f3d 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -732,3 +732,28 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsign= ed int policy_idx, =20 return rc; } + +int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, + xc_cpu_policy_t policy) +{ + unsigned int nr_leaves =3D ARRAY_SIZE(policy->leaves); + unsigned int nr_entries =3D ARRAY_SIZE(policy->entries); + int rc; + + rc =3D xc_get_domain_cpu_policy(xch, domid, &nr_leaves, policy->leaves, + &nr_entries, policy->entries); + if ( rc ) + { + PERROR("Failed to obtain domain %u policy", domid); + return rc; + } + + rc =3D deserialize_policy(xch, policy, nr_leaves, nr_entries); + if ( rc ) + { + errno =3D -rc; + rc =3D -1; + } + + return rc; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322575; cv=pass; d=zohomail.com; s=zohoarc; b=f0Ssape9GS7CHYIaa0FyU6J51sxHAQTCxtwJic760sFE1FFrmu5krn1OBAzkzctTrC0vToXIvQ0g3YnqjT8m1Px93sOzAo0R5CGBmBBAch3lfZcbl3HCPxB3arWLBoIBrZrxOSEW42XQVts4VQ1nCOJNzsnL9nyByFJOtc3tIOg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322575; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+C8NC1XmcgG+hR7rhDwEzRtSVqk3ZTRRhzEbmJGLd68=; b=KV5S/bu4G+GIG4rIPo7FyD+gwL0SmIUoqHwXmBtRTamcANKcczfqK+MuACAdmYXQJdbCbWlqHldntrCRNCz/8kCjjszwJIEzLGEU+DhnaLrqb0h3SCxuiS4rzJaQt5H1GCaBTqW1itkVjCd/AIIPgA2rMC9GTyBDPjvNTWuBkr0= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322575247940.2629424622343; Tue, 13 Apr 2021 07:02:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109777.209565 (Exim 4.92) (envelope-from ) id 1lWJci-0005EH-6o; Tue, 13 Apr 2021 14:02:36 +0000 Received: by outflank-mailman (output) from mailman id 109777.209565; Tue, 13 Apr 2021 14:02:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJci-0005E8-34; Tue, 13 Apr 2021 14:02:36 +0000 Received: by outflank-mailman (input) for mailman id 109777; Tue, 13 Apr 2021 14:02:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcg-0005DI-Om for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:34 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 65ef5357-2709-4ae1-a310-e4e06467e70e; Tue, 13 Apr 2021 14:02:34 +0000 (UTC) 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: 65ef5357-2709-4ae1-a310-e4e06467e70e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322553; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=6EB34yxtREKRpQgddSh15DRCHEJ1cQ8hc+zSM5cFzGo=; b=ep/PBnF/ttdYAjbyppsd1tzVkqIPg4GGJgbRgQ4yaWjSFg6fQ2Nz29ZV uz82ukvkRoGk2jKJvWH+38GGFt+rBhkW31ow0fOsOhVhAn8y7yveMGMPy 9FdnOaz25TmcPjgGnOang6kxg994uVTRp2STTdBeUsAlwD2ouSh4KPOFi c=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: Sj/Xa0h65LTdNTab4d1DHs0sDv20l4Se/NuzOXOEUPv86hEb+/+HxMH9JU5lvU/TiR9FRg3NIq ArJRa34fNTxQDGBWBmG6AXmK11Uk+ZyJH3SCKJDNZFAT4/9tx+/x787SUDTSCM8McvLQMck6L8 st6Uq2bsa12otf0vA6FXePoNU7kGHi+XSMQjEw/DiqxQ3ewnZzEM5+AKopFiweZcxX42hT129L yvxfyZ5qH3BhY/2uBrKt6h4lXYAedggDTeiQCoV8ox4CGE3t5l3FmTNY0I6FCXNK9LKp+/39Xr ZH4= X-SBRS: 5.2 X-MesageID: 41483804 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:LH1h+aGQWsRdwelIpLqFMpHXdLJzesId70hD6mlYVQFVfsuEl8 qngfQc0lvOhCwMXWw78OrsBICrR3TA+ZlppbQAJLvKZniChEKEDqFHqbHjzTrpBjHk+odmv5 tIXqBiBLTLYmRSot395GCDfeoI5Pmi3OSWifzFz3FrJDsaCZ1IywtiEA6UHglXaWB9ZaYRL5 aX6spZqzfIQx1+AviTPXUZQ/PF4+TCiZOOW3U7LiQ64wqDhy7A0s+YLzGk2H4lMg9n8PMZ3k Xu1yf44aiitP/T8G6n60bjq654tfGk5t9KBMmngtUYJDP2mm+TFflccozHhh8ZiqWC70srjc ntrn4bTrhOwkKURE6Zi1/M3BTtyzkn4XOK8y7mvVLT5fbXaRh/Lugpv/M8TjLpr3AOkfs57Y dwm0WejJZTBQOoplWE2/H4EytEu2DxnWAvioco/htieLpbUpB9h6oF8nhYFZ8RdRiKk7wPIa 1VAMbQ6O0+SyL9U1np+m1mwNmbVn8uBBuxQk8bpsyP0zRN9UoJtncl+A== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41483804" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=joEvALicDJ1p3S8vig9ZE65tnZQWRau/K/sqzSa/PSfs2X8bZbID+cgsA7JmnmBGuTXZWVyDmIzNO0iOCrEkAlTBU5zcFYrM1uOgo1IphCbcttEs9u4jdywXTTXv6i3TDAC1SDKIgQ55gllklStD8bltYuegYe+y5i560hoLEIEJ2fMWk/N3Eer2HNcC8EkJ/Ua+z2ZwZA0zTqQGFJq/7saRo7d0w0rpfHL9vUT+BGa0A7ktTYV0GC56Lmf7vR/CnzGF8d0fcRsizZrbERTBVDONa9CSttoL8cZFdqai+oq3lEoHks0ybULoh+npVU87tZkp+vURG9hR+RA0asMuqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+C8NC1XmcgG+hR7rhDwEzRtSVqk3ZTRRhzEbmJGLd68=; b=e8x7s+BD5l63z9wD4u/e6dU5iwqd+JTcJXbfwRlsBd8vpsoctt56hjyA/clY4v18IdXT9+a8+BBD+ethVwo/XHFKadtLvk+01CCNaHo7/PUT3xXgP7oe3BcUq/NaIKT4+fLxES+grOYOITm9NHSa5lMkPpV64Zh4t1wTBU4+P4OW9cWVBDO64JEryhZ0VLUmDukQp00nfQcFCTRBJdjuhq6hO9RaVuOPJJHgpB2Dfb1bYYuYaV2kMVXCg5PlW6JaHyJNxa/LGXa+TFubFEADrD/80TxHc5zhcwD7/o3kFfOgxm8B3oYkpamrx2USo/OQhp9hLm3c8MYBlYkaP5jZ8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+C8NC1XmcgG+hR7rhDwEzRtSVqk3ZTRRhzEbmJGLd68=; b=pcRnrc531tj1Jbw7PBgmrV7/ez477ezNYVjyKGNYOAegRqGJjaEGmVZMnCFPNs3RziCciAqR6LauDKJ8FYwuVBJj0649rYRP75daVlv3fhwf2WTJ6BZ8okN/FPvufXN2gHrP+Hksz4DSwapKeaZnUOD3xaCz0VjqKr6AKhouBYI= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 06/21] libs/guest: introduce helper to serialize a cpu policy Date: Tue, 13 Apr 2021 16:01:24 +0200 Message-ID: <20210413140140.73690-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0099.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::15) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 480a7cde-3a81-40d6-6add-08d8fe84c719 X-MS-TrafficTypeDiagnostic: DS7PR03MB5542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: reCXnJjfy3n9vvTSfczOqbg4xaZvu9ikC2veci6I5QGYvjZds11ijWnwh75PR8bvI8oef+jjDd6KwiI4ejQeAjePp2z9rGNHR/xc8C13BiBD+ZDjZ+Vf4LoM48se8ajwyPzH2iPo7Tv/zmOQ8kiveBh9wrOz80mC0v4pzOhQIimbr02sMFyVNm5pMhOWPzQs5TN8CuSR0H+Su5kAP7vseBjprLwRXC5+xMjJ4XuVrFNULx+z5F/YBE25WKbgHG/Q/YpS7vBzyCaSoc6hAFcOsQ56y+J546xGbBTrXMnKwgj4SBMFFJ9P65X1q2WZ4NrYihFdXY3t1v6oyk+7UeR9bLvekAxK0kd9ub2vXLhDw1qZoa1ffdpKwm/+2F9F8vAwf1Lzh/07Y8ptV6+53UlATwF/qndy7Yf3PG3xyx4/pW6UuF7xIGamE0xvcOVaTVhtoe0zuUI7XTrdnVLKmpcU3diG2IL3qFsakjbZS2TbpzLYs1EREkjJjYmWU9h4v0FUn2ErddJ0mBByuVfr775nBhVBx1RJCrX9KR7q4KBHffaDl9+pU2tRJAKOuQJKgOFIBAqPL1v+rc+/GFset5fHTy8hncx99Ts8LthnQ3NXnwI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(366004)(39850400004)(346002)(376002)(2906002)(6916009)(6486002)(36756003)(66946007)(54906003)(83380400001)(1076003)(6666004)(5660300002)(66476007)(316002)(66556008)(8936002)(478600001)(186003)(2616005)(16526019)(86362001)(6496006)(26005)(38100700002)(8676002)(956004)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?WmFxc1hBV0luTG1mVDJRTXMyV2xtK282TEdDd3R1TUpTSHQzc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7cde-3a81-40d6-6add-08d8fe84c719 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:30.4565 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r69qJRuwc4bRB7kPxMRibOxmsJjOlInj41lHBDKVeD15e6tsxwImr56PK8imNcH5x4tEo/cvWc/3cWDXlIssJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5542 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Such helper allow converting a cpu policy into an array of xen_cpuid_leaf_t and xen_msr_entry_t elements, which matches the current interface of the CPUID/MSR functions. This is required in order for the user to be able to parse the CPUID/MSR data. No user of the interface introduced in this patch. Signed-off-by: Roger Pau Monn=C3=A9 --- tools/include/xenctrl.h | 5 +++++ tools/libs/guest/xg_cpuid_x86.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 34d979d11da..a4827b1ae6a 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2602,6 +2602,11 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsi= gned int policy_idx, int xc_cpu_policy_get_domain(xc_interface *xch, uint32_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 polic= y, + xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves, + xen_msr_entry_t *msrs, uint32_t *nr_msrs); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 1394e503f3d..918591a128c 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -757,3 +757,35 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32= _t domid, =20 return rc; } + +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 rc; + + if ( leaves ) + { + rc =3D x86_cpuid_copy_to_buffer(&p->cpuid, leaves, nr_leaves); + if ( rc ) + { + ERROR("Failed to serialize CPUID policy"); + errno =3D -rc; + return -1; + } + } + + if ( msrs ) + { + rc =3D x86_msr_copy_to_buffer(&p->msr, msrs, nr_msrs); + if ( rc ) + { + ERROR("Failed to serialize MSR policy"); + errno =3D -rc; + return -1; + } + } + + errno =3D 0; + return 0; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322589; cv=pass; d=zohomail.com; s=zohoarc; b=Rm70dwAUNcYrMbfZ4DcVPaLOuAWeXC1zE+uI6sUJYatMcR8vudMulinNfkbxIKtemit0+tynhgCaLGWyBnAQSNj0CTYxbMbcPsu32wpkOBBhjU2726rBoamy4HlV+ySHPYOZvx2gf5qzsRWIk16vYgvGWlIwPukcY4NbxDWZiGI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322589; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ts6808t8I7OOkQ2S6zJoNr6HGxOEnfocXKMyqX7zdFk=; b=kEOgETrk3UvYHiSYTDEHcfBdojGzBdLcpEG8ed91pON0wdOypKfc708ZCYIVBmVovtjm43qdFQoUfcivq36vz3BbjTWCK7kQ+D3+0H3yGHmril6xxobI9FCF4wElpBd/d797esWJw4HJ0umuP1FbfbR0hsUw8BY5bnyLayLpwyQ= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322589772788.0197813520701; Tue, 13 Apr 2021 07:03:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109781.209577 (Exim 4.92) (envelope-from ) id 1lWJco-0005Jq-Hp; Tue, 13 Apr 2021 14:02:42 +0000 Received: by outflank-mailman (output) from mailman id 109781.209577; Tue, 13 Apr 2021 14:02:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJco-0005Jh-Cn; Tue, 13 Apr 2021 14:02:42 +0000 Received: by outflank-mailman (input) for mailman id 109781; Tue, 13 Apr 2021 14:02:41 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcm-0005DI-TH for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:40 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 443fcc63-a9ef-4fcc-b101-606f42864a7c; Tue, 13 Apr 2021 14:02:39 +0000 (UTC) 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: 443fcc63-a9ef-4fcc-b101-606f42864a7c DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322559; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=xAaavw8tLgCKI5yDj7+ij6kDHsh9Urpoi2CfeTGi1ww=; b=PKxcJ8EgeIPpGDg5nI2ew8th5zs/t7FGpPRsdz/S1aVKC6SzXJq+BDbS Wi5+3f35QKNDbK/BOZ42k45QsHnbQx8KBazypUDOQpzzKb3YKvEhUHgLH Opek2BCBfU/yqyDjhW4rJmT8A835NITmNwxsQqOpZb/rObEe5BUgziBII w=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: mjzN2C9ug2pI8YZWOnJ8vtQRdzvPYsSriq45UkfvX5jS6Bn7WOPsCzVgA4LQ7MhbJuOGcjkUbW NOiGenB59l7jkEiRA4HhsYNJjc8E1pjLif6piuHmoLi6v4uXHgJ0udxlOD3XmSWJf6pT/8pJ1g Jl9z6ehzC8BuUChRUuZpRZuB4G21oxcOChY/9j5zQCnUC2DM5t0jmLrgR4DvlBjarGGgLFOHsK JByYgolWBgERtU2plNw2G18Kxozz/xKcOQfkuhx9+3cMdcMh0hBHfEu/wy/ryUxd4su9i6BQ2J oE0= X-SBRS: 5.2 X-MesageID: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Hxlcgh1rt2 9HVQ8BSibkZ3DToJTgqKZRKPDUdtF6jgvuC9VTs2jjuUKVotxqemEWRAe0UcmcgR8nQh1dgl EZyd5ZvJOw3RKUbUcviuUxN1NBLECaGqhPAgi+aIJIobzzYw1rQWCWhTuVtgErdgPRhjYvr1 2kCRfRVeDAA1JbtHwd6Krs/V9uXki2fk57aBlBwMZAPFWDnkw2/f6AZ6K13WfUV0ALxfsFNi rZJREIJBl1+tyx3BmJuTqLGHk83K8yNujFALlLScCU5lqdbKmz0Y0WFf5d+5hocO30uugQSO SFZku7Kij7B+5B4X3iml8VfA1P7F8qnvPj1Ee7sCyW3HsjDeHTJ1ojbbcBON2Y53XlQfHN8J gRt6NAgcKAdkHKLviBwuXrShQGDDX5i2u/VfspppBZprhajso6I7DrFR/zkEha1xA/JvrunE wQQK5H8KnMU7UfCvA6SmZ8xB4Vj9yBI0sgjxzuDsI/dV8riWXHP9nh2cu+lZMfRmmIpA79Ij CkglVg1saAeyuIzrgBDa0sZUxQdUgn8XxnldnyPbH4OUGPd+tZ+kC9PWL4WLhBSLKdEbFVih ph+dmHk6u2cCX/sTqg8AdTE+Zr82y9R9m1Dx/JMelU88aiMVDJu5CU2qeI/X7KYAr+TV8Zi4 1DfVERacoGqgBKtvxJ7gGCDortokwklFNC5ypAjVCF4Pn+3Fvm X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41476465" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+kWog2isXEbBsHil1Z7u11+uQFk/XcEz3JV90a+R6mao9tVCos8sWvDvYnMtj6uh2AC08JrTLicFgdF+co0FYmgzp8moOdZ+bOr3vVROxoCfDon7s2T5Wl9ISX29KS3cj2XuEULCLdbcldHruywJb4Y6V0Y52p1ZWMjZBK92KHHofGn+gjKHShuWqRc5CqF2nmIqwJOJykoB6lQ2/If9iqYo8IhRkPDQ1/ZkubYLwejZiaJNFOfP3D1QS4HabCK0i3Apms6v4Cc2ckJZliPfYOR/1AhLqmyji2BjeHYkqbqJj5ncJd3EVmy44ApZJy5NLy6RdcW5nmQcu2xdDI+2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ts6808t8I7OOkQ2S6zJoNr6HGxOEnfocXKMyqX7zdFk=; b=Yn2Oy3fq2h1KILOwZ5/dyDq5MrbsDfbvucfuL0vFD+7Zcd7W7Kp0LIsaJjUWo4qyAnnJQWWLOPAF6zNlq/enYxKjkJ6/r2RNwsbSvlbYLpUcXmSjMhFk1RVEn5SLDkbGte9gDmEwqIf++vMtXm31L7haS3BnemKyrKLUl9zRTH2cWe/kL8zKkg2HWairAUiXAzg1FQ8x2lj46z9uu3eOXabMF1FrkUH8WDVhCvjlD+9Chucep8AUtpt7q7+6tH7L1p7AR74El3oZ/qoLlJ+mK6GwpGyWpXdSDOOvOX6P1L7bHEmSRm37jcUD5PBCEAKBxga1HX91NtLbWg6Ppqg5cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ts6808t8I7OOkQ2S6zJoNr6HGxOEnfocXKMyqX7zdFk=; b=neSQTFRItJsIKQNC7TcC8QEtw0WagpoZ4nSkQ79aphkQkyxq99ZAvGlKiUx6LP15q+sZMCr7gH6NM8d21KtRc0l6AQNA8gTJBmNAun3ZfJ+N6hHpn0eSaL1kfa6bsLhxDMc8uAWOv83bPZj6JZrN47UPlliBqNyh83fYfalSqg4= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu , Jan Beulich Subject: [PATCH v2 07/21] tools: switch existing users of xc_get_{system,domain}_cpu_policy Date: Tue, 13 Apr 2021 16:01:25 +0200 Message-ID: <20210413140140.73690-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0110.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::26) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a2014e0-48e7-4c92-b709-08d8fe84caea X-MS-TrafficTypeDiagnostic: DM5PR03MB2553: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:76; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ltBqwAM+hGtRwnLp2PrwYzeLKzIMQgAtdgSrRE8pc3A0qPa6ZWl/fYCMgpbQI38rd6HJFc+It8c1wrlUWiSPyoChVtR5rskUaVAycK8kmp7pGXZ/MGphRwrTpqtrmUWXda+y6MFOnQU/PSoaZ1gb11tWxCIvDVU40p6gXewOG7pJbTi4aa2k8UA/VML1uJkd7qRpTxO1qAmpYJpd7JKEz6B/Zq2JcMyLFGsbn6hTfXbM9WLhBwGE/czv7qJODSXkUyxYQIcFfJedI66/keWTdQxBSnaiD7yU82/RwyxcsJfAYl41kRf1qBpYxyuXBe/zOAo7o0suSIK+5FHaxDmjdkRozCWLUpnOMNuTkjI0bugsBWYAPRu75YqlO5nndoptbnK8tfsmk9wFr9cj3fZzxN4EMULn6BIl8smvVSml6KOlKsHLXAJwJu9NPswCQCt1+k6xRGyg8aheSbXQtqaIDMyPgu9VkWp11I8hkpms7cOMhEnz9bU4XRIUGJkyYzQpVH3anG0m/7FTT9sK8FI/ubzH3rTR3dbjhMtUS6knk9I79WU0csMGTe9SeR3+6BX/Fz90tpc9m8umDsMRSr4aPxxtqmnUSztgZJ760MiZcsE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(396003)(346002)(39850400004)(8936002)(6496006)(186003)(83380400001)(38100700002)(2906002)(66476007)(86362001)(956004)(2616005)(8676002)(478600001)(66556008)(66946007)(6666004)(6486002)(16526019)(316002)(6916009)(36756003)(54906003)(1076003)(5660300002)(4326008)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?ekhqRXBTam5ud0RROXVXQ0JSOFFzUXRna3dER0FGL1J4M2UzQUpXUXpwVGcx?= =?utf-8?B?WkcyQ2RGbEYrS2F2eFg5Q1d1T2ZjMUtTOXREc0JVamMwcHhwU2hZanhNRk1w?= =?utf-8?B?T2xHalI0eW5sUGN1dy80TndmZDFwTWwra3VLNC9qZzJmL0xnMjBDOWJPaHh2?= =?utf-8?B?WHkzRVgzZWY1TXcvMXNPeHFyMVNNNmhid3hoczVNSGZad3FQS2dMeGlYWHZZ?= =?utf-8?B?WGR3OVZFT2ZsNGlNcUFmSlozV0xBdlhIS3VFcE5XR1ZlREZuekFrL2svcjVt?= =?utf-8?B?cDE3Y1Q5akRqcFlsc1FWQUdZZXNwcFRmOVVXb2w5S1VQaU4xLzlCWkRHVHhh?= =?utf-8?B?aXR2OWdsZEhmclF5WE14OHZxdUE4RXU4T20yVThrenEvYm9DMlc0OFNxNG03?= =?utf-8?B?VjROZGVZTHJrakhkTDJUTHZoMW5UVXF0K3hlVUVOSnl4a0xaaDI4VlE4YWhh?= =?utf-8?B?T0xZQkp5WGlPbGhCTlFFTC9p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dEVlTGNBazNoNmQxK09XQytNZHhWLzNCclBXeUFhdmRyN0xDZ0g2VjRJbkho?= =?utf-8?B?NDljWW9IUW42aE1yRERtcWg0U0NCOU5qcVgrdmtKVTVBQlF2WkZHOHczWVY5?= =?utf-8?B?L0J5NHArM1hQQm12a2k0UVdFNHRDL3NXYW5QR1c1RXl0STJ4MFc1MDZmYkg0?= =?utf-8?B?djYwTzZCWngzVVNYeEQ5RFFIejNZc2lBWHlBUjBDbDJtYnNBbUsrSkxZUjJ1?= =?utf-8?B?TU95bk0zaHRleml4T0s0WTdyb3lwL3V1U1hycFo5cXJqNUtqTitnalJoeCtN?= =?utf-8?B?TjBqUldlSEhuczkrZHJoQ05YaGpVZmMwR2daQnpFdklvNXJjRS9pUkNOWENo?= =?utf-8?Q?TxrAmphWfN1N/1NpaNY9POEJGYdiW1dytAUvkQf?= X-MS-Exchange-CrossTenant-Network-Message-Id: 3a2014e0-48e7-4c92-b709-08d8fe84caea X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:36.7508 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TbxUlADcVmrjuv+lRwyJVr7d73HXfTPFtW7kHp1Zl5SmCsG+1qIP4TiYgep92qCEXHJnCatlds1KXzxbNia1uQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2553 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) With the introduction of xc_cpu_policy_get_{system,domain} and xc_cpu_policy_serialise the current users of xc_get_{system,domain}_cpu_policy can be switched to the new interface. Note that xc_get_{system,domain}_cpu_policy is removed from the public interface and the functions are made static, since there are still internal consumers in xg_cpuid_x86.c Signed-off-by: Roger Pau Monn=C3=A9 --- tools/include/xenctrl.h | 6 ----- tools/libs/guest/xg_cpuid_x86.c | 39 ++++++++++++++--------------- tools/libs/guest/xg_sr_common_x86.c | 15 ++++++++--- tools/misc/xen-cpuid.c | 21 ++++++++++------ 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index a4827b1ae6a..e9a86d63bad 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2613,12 +2613,6 @@ int xc_get_cpu_featureset(xc_interface *xch, uint32_= t index, =20 int xc_cpu_policy_get_size(xc_interface *xch, uint32_t *nr_leaves, uint32_t *nr_msrs); -int xc_get_system_cpu_policy(xc_interface *xch, uint32_t index, - uint32_t *nr_leaves, xen_cpuid_leaf_t *leaves, - uint32_t *nr_msrs, xen_msr_entry_t *msrs); -int xc_get_domain_cpu_policy(xc_interface *xch, uint32_t domid, - uint32_t *nr_leaves, xen_cpuid_leaf_t *leaves, - uint32_t *nr_msrs, xen_msr_entry_t *msrs); int xc_set_domain_cpu_policy(xc_interface *xch, uint32_t domid, uint32_t nr_leaves, xen_cpuid_leaf_t *leaves, uint32_t nr_msrs, xen_msr_entry_t *msrs, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 918591a128c..208a247bb6e 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -135,9 +135,9 @@ int xc_cpu_policy_get_size(xc_interface *xch, uint32_t = *nr_leaves, return ret; } =20 -int xc_get_system_cpu_policy(xc_interface *xch, uint32_t index, - uint32_t *nr_leaves, xen_cpuid_leaf_t *leaves, - uint32_t *nr_msrs, xen_msr_entry_t *msrs) +static int get_system_cpu_policy(xc_interface *xch, uint32_t index, + uint32_t *nr_leaves, xen_cpuid_leaf_t *le= aves, + uint32_t *nr_msrs, xen_msr_entry_t *msrs) { struct xen_sysctl sysctl =3D {}; DECLARE_HYPERCALL_BOUNCE(leaves, @@ -173,9 +173,9 @@ int xc_get_system_cpu_policy(xc_interface *xch, uint32_= t index, return ret; } =20 -int xc_get_domain_cpu_policy(xc_interface *xch, uint32_t domid, - uint32_t *nr_leaves, xen_cpuid_leaf_t *leaves, - uint32_t *nr_msrs, xen_msr_entry_t *msrs) +static int get_domain_cpu_policy(xc_interface *xch, uint32_t domid, + uint32_t *nr_leaves, xen_cpuid_leaf_t *le= aves, + uint32_t *nr_msrs, xen_msr_entry_t *msrs) { DECLARE_DOMCTL; DECLARE_HYPERCALL_BOUNCE(leaves, @@ -329,7 +329,7 @@ static int xc_cpuid_xend_policy( /* Get the domain's current policy. */ nr_msrs =3D 0; nr_cur =3D nr_leaves; - rc =3D xc_get_domain_cpu_policy(xch, domid, &nr_cur, cur, &nr_msrs, NU= LL); + rc =3D get_domain_cpu_policy(xch, domid, &nr_cur, cur, &nr_msrs, NULL); if ( rc ) { PERROR("Failed to obtain d%d current policy", domid); @@ -340,10 +340,9 @@ static int xc_cpuid_xend_policy( /* Get the domain type's default policy. */ nr_msrs =3D 0; nr_def =3D nr_leaves; - rc =3D xc_get_system_cpu_policy(xch, - di.hvm ? XEN_SYSCTL_cpu_policy_hvm_defau= lt - : XEN_SYSCTL_cpu_policy_pv_defaul= t, - &nr_def, def, &nr_msrs, NULL); + rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault + : XEN_SYSCTL_cpu_policy_pv_defa= ult, + &nr_def, def, &nr_msrs, NULL); if ( rc ) { PERROR("Failed to obtain %s def policy", di.hvm ? "hvm" : "pv"); @@ -354,8 +353,8 @@ static int xc_cpuid_xend_policy( /* Get the host policy. */ nr_msrs =3D 0; nr_host =3D nr_leaves; - rc =3D xc_get_system_cpu_policy(xch, XEN_SYSCTL_cpu_policy_host, - &nr_host, host, &nr_msrs, NULL); + rc =3D get_system_cpu_policy(xch, XEN_SYSCTL_cpu_policy_host, + &nr_host, host, &nr_msrs, NULL); if ( rc ) { PERROR("Failed to obtain host policy"); @@ -486,9 +485,9 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, =20 /* Get the domain's default policy. */ nr_msrs =3D 0; - rc =3D xc_get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hv= m_default - : XEN_SYSCTL_cpu_policy_pv_d= efault, - &nr_leaves, leaves, &nr_msrs, NULL); + rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault + : XEN_SYSCTL_cpu_policy_pv_defa= ult, + &nr_leaves, leaves, &nr_msrs, NULL); if ( rc ) { PERROR("Failed to obtain %s default policy", di.hvm ? "hvm" : "pv"= ); @@ -715,8 +714,8 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigne= d int policy_idx, unsigned int nr_entries =3D ARRAY_SIZE(policy->entries); int rc; =20 - rc =3D xc_get_system_cpu_policy(xch, policy_idx, &nr_leaves, policy->l= eaves, - &nr_entries, policy->entries); + rc =3D get_system_cpu_policy(xch, policy_idx, &nr_leaves, policy->leav= es, + &nr_entries, policy->entries); if ( rc ) { PERROR("Failed to obtain %u policy", policy_idx); @@ -740,8 +739,8 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32_= t domid, unsigned int nr_entries =3D ARRAY_SIZE(policy->entries); int rc; =20 - rc =3D xc_get_domain_cpu_policy(xch, domid, &nr_leaves, policy->leaves, - &nr_entries, policy->entries); + rc =3D get_domain_cpu_policy(xch, domid, &nr_leaves, policy->leaves, + &nr_entries, policy->entries); if ( rc ) { PERROR("Failed to obtain domain %u policy", domid); diff --git a/tools/libs/guest/xg_sr_common_x86.c b/tools/libs/guest/xg_sr_c= ommon_x86.c index 4982519e055..15265e7a331 100644 --- a/tools/libs/guest/xg_sr_common_x86.c +++ b/tools/libs/guest/xg_sr_common_x86.c @@ -48,6 +48,7 @@ int write_x86_cpu_policy_records(struct xc_sr_context *ct= x) 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; int rc; =20 if ( xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs) < 0 ) @@ -58,20 +59,27 @@ int write_x86_cpu_policy_records(struct xc_sr_context *= ctx) =20 cpuid.data =3D malloc(nr_leaves * sizeof(xen_cpuid_leaf_t)); msrs.data =3D malloc(nr_msrs * sizeof(xen_msr_entry_t)); - if ( !cpuid.data || !msrs.data ) + policy =3D xc_cpu_policy_init(); + if ( !cpuid.data || !msrs.data || !policy ) { ERROR("Cannot allocate memory for CPU Policy"); rc =3D -1; goto out; } =20 - if ( xc_get_domain_cpu_policy(xch, ctx->domid, &nr_leaves, cpuid.data, - &nr_msrs, msrs.data) ) + if ( 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 ) @@ -94,6 +102,7 @@ int write_x86_cpu_policy_records(struct xc_sr_context *c= tx) 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 52596c08c90..8ac25581d68 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -458,9 +458,12 @@ int main(int argc, char **argv) uint32_t i, max_leaves, max_msrs; =20 xc_interface *xch =3D xc_interface_open(0, 0, 0); + xc_cpu_policy_t policy =3D xc_cpu_policy_init(); =20 if ( !xch ) err(1, "xc_interface_open"); + if ( !policy ) + err(1, "xc_cpu_policy_init"); =20 if ( xc_cpu_policy_get_size(xch, &max_leaves, &max_msrs) ) err(1, "xc_get_cpu_policy_size(...)"); @@ -481,10 +484,11 @@ int main(int argc, char **argv) uint32_t nr_leaves =3D max_leaves; uint32_t nr_msrs =3D max_msrs; =20 - if ( xc_get_domain_cpu_policy(xch, domid, &nr_leaves, leaves, - &nr_msrs, msrs) ) - err(1, "xc_get_domain_cpu_policy(, %d, %d,, %d,)", - domid, nr_leaves, nr_msrs); + 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); @@ -497,8 +501,7 @@ int main(int argc, char **argv) uint32_t nr_leaves =3D max_leaves; uint32_t nr_msrs =3D max_msrs; =20 - if ( xc_get_system_cpu_policy(xch, i, &nr_leaves, leaves, - &nr_msrs, msrs) ) + if ( xc_cpu_policy_get_system(xch, i, policy) ) { if ( errno =3D=3D EOPNOTSUPP ) { @@ -507,14 +510,18 @@ int main(int argc, char **argv) continue; } =20 - err(1, "xc_get_system_cpu_policy(, %s,,)", sys_policie= s[i]); + 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); } } =20 + xc_cpu_policy_destroy(policy); free(leaves); free(msrs); xc_interface_close(xch); --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322580; cv=pass; d=zohomail.com; s=zohoarc; b=DBv4AUv3pWOYP1m15oslqm/UWXph4AF6HRKk5ypurLR+BkW+z6pYbLay+ScNaIX9Q+KSySHd6bZbj90Afq8VZjev+EPCozWQemHiNmFjfeQcNbU6bvBQBXOagvQu3M0dP0gMlKegc/8gQElQ+922dMzQpEI3v2J79er4DcGtstI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322580; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ace5hGQHWZBVqrsl47aMLF18dvATzg1Wl0vS5Bxau5Y=; b=eAXTi8X2JNKWzMqsBzEGnMJ/XsWw7whVLidc2NiHtZHFNV88n205IoPQCHyQxevS06ThH0cw/rPM0prhyNo9/9UB6YXXljLCPX8PILFgfrOd0vVVGDUg6F6Ik/eUmfbkUOznCP+4cmV+cUvFYkaQQSOGZKmomauiCVhZ2F0I0hU= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322580538290.7860828694098; Tue, 13 Apr 2021 07:03:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109784.209589 (Exim 4.92) (envelope-from ) id 1lWJcs-0005OY-23; Tue, 13 Apr 2021 14:02:46 +0000 Received: by outflank-mailman (output) from mailman id 109784.209589; Tue, 13 Apr 2021 14:02: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 1lWJcr-0005OQ-T8; Tue, 13 Apr 2021 14:02:45 +0000 Received: by outflank-mailman (input) for mailman id 109784; Tue, 13 Apr 2021 14:02:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcq-0005IR-W3 for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:45 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9de22b63-6d0a-48a1-aa5b-b42364ee1380; Tue, 13 Apr 2021 14:02:44 +0000 (UTC) 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: 9de22b63-6d0a-48a1-aa5b-b42364ee1380 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322563; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=+ccNt1NnUZB51wrF9lVtU6rnw0ezqCu7LtS/VwdmaXE=; b=ZFZ3EEM+dzJrqwI8IzwbWGCAy7wNqP4KCmaMMuU3cVA59mNQbN9dw3rK NTJxmJe5IDRfi1lkdTgLgabELnMaBHKXWRisGJi8HPq1icWb3jK7wR6QZ snfUxhLiu4kY1wKhyFgQTdSH0mIiWYo4S+0CLxo7mzR8BxML42oXA/3sN 4=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 2NbV4rYqUDXgZ5UCmNABXCVnZ+KDdBd0ryP1I98GHYD1xaS79HzB4oY0jKiKqAkYMWROmm5tjr AtOhrPe8tde13VxDQo38sXg1sjULyNvM16ef19LppKCMQyJktyyQ8VkVe3lUtiNsTJHYfc5sjh iQ0oivb2GVlsQw3MNM/LMTD6tsN5lUAZxY5qe+2Sha2fdh+wFbaSRrnJ/KkkTK+we+XgzI5kzn wx3o3BkqnTAUmjF1XU9THVDApuIoC3G3jebACxyIKk8Oln3hYAzyU753UxlkgMpG4fzKPwp2zN wB4= X-SBRS: 5.2 X-MesageID: 41322176 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:ohTAla1Jdk1/K7i/S073TwqjBWhyeYIsi2QD101hICF9WtCEls yogfQQ3QL1jjFUY307hdWcIsC7LE/035hz/IUXIPOeTBDr0VHYSb1KwKnD53nbGyP4/vNAzq sIScJDIfD5EFQSt6nHySaiFdJI+re62YSJocub8Ht3VwFtbMhbnmVEIyKWCFd/SgUDJbdRLv qhz/FKrTahZngbB/7TbhU4dtPOusHRk9beaQMGbiRN1CC1kTiq5LTmeiLovSs2bjUn+9Yf2F mAqSPVzOGJs/a3yhjTvlWjlah+qZ/a5fZoQOCJgsgRAD3whgivf5QJYcz+gBkF5NuBxXxvvN 7QowoxH8kb0QKsQkiF5SHD9iOl8DEy52TswVWV6EGT3vDRdXYBJOdqwad6GyGpj3YIjZVH/4 9gm1+9jd5xCyjNmSzsjuK4Ly1Cpw6PjlcJ1dIIg2c3a/p4VJZh6bYx0WlyC5k6ECfz+OkcYZ JTJfCZ3vpQfF+ABkqp2FVH8ZipVnQ3KB+MXlIPjMyTyyRXh3B01SIjtbUioks= X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41322176" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ImeAnWUtT4HOIU1JcRi3DPv2dJlJVz26OK+V1BeChRMqR+Y/vglIbxDTXpU+Oos1lGhWSlmoKFPJhY/jjOxNFEoWxPrLpz/vybS/9wN/8M3TGwN2cAl+9akTy+kkYaRVNDVgwpVDvYqmQD6PQlymPKZ0rL+r7F8kqu5EbmWNqQANjGj9I2JdmuI3XNA/TiFMQWPWsg7MY0A+Y4eYok3fWciYRDITrA3AcA4zxjNvcEezV65j1M7eG+4lHuNuOJp6u+u77BnlhrHEEhVoqegotqM39PiPs4G3dWtBbEdpdRUC1xaIz22JBddNQMVcQH+SQqELnxmzvJOzht0uCwpSFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ace5hGQHWZBVqrsl47aMLF18dvATzg1Wl0vS5Bxau5Y=; b=HNaOC0qzi5Cr+RUbJP1PcqV8zbsoxoyItSsm0qSQlcfX7oK80ZTY0zAGSJDUeZie8YiYzYzSMFlMq/qfEJhIQqCadVyJsX2UexC57CKBoFQRaODp04bJmCk1TU+anPDTRdw0nkqjtmtDGK3mIQMkal55l/YzeX0vaY3QCQP+zCdhcug3RfSmYzOig0xzut00JhZbIhCzlstY8VbkHM9ip6KZ+87R9wafqrtYDL3j35KWr0t/lUDOR18eJFfH4lUscpr7L6VHdhU3O8BoWma4nLavYIS/13VV2u3j09c0g32WjnToIsVH8L73EIXGi8uwiKiXMIiW8yvXOakc24dwYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ace5hGQHWZBVqrsl47aMLF18dvATzg1Wl0vS5Bxau5Y=; b=nrSfj9EBW0fo0eS6hqr5Jw8o8mwkuA2WEZuotzLMM1/hLzr+GExpU/SXoHTlaFZLM7L+pqhXwghhgGZ9jDazwMiUAXlsZw2tsXUBR0KcqPjkGfXkmIO1KopAs99OpLs/sZRCPj0AR77dr0AZJJvckv3JHJeBn7/W4m2rkCE3Muw= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 08/21] libs/guest: introduce a helper to apply a cpu policy to a domain Date: Tue, 13 Apr 2021 16:01:26 +0200 Message-ID: <20210413140140.73690-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0103.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::19) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c3f6c4db-9226-4c75-9e5a-08d8fe84cd99 X-MS-TrafficTypeDiagnostic: DM5PR03MB2553: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QbaJTcdYwbS4Hftkmgy4BuKsisuCKehgtSzsiAqcrNddh4rGwloRznuiO+iyHaVQBEh1cXgSt98XjEFltXMs4jBuxWrdvb+3sgg4zpxdWPY36zqvJNFOBYgMVcnJz/PvM+WpZwNNdQRQTzKaPomCMVGJWeIHZo9LS+0gHIhZLFaCROMs2pmf9Fp1tG57lM/U2ZDcenHwCHg7IpOYW9sMpFlvBUf0K0mdeCQvi45POhDajb8vRnF+33jEIcJx4iRElxPe5nICCoqVw3in+UkQOhno8BV6ISxANgxFU7iGG+ZeOVEkZ7B2ps9HIFt6n8VzTd/lrRzVyD0d+b+Ak4msaPZ9N2DbBpmjPbnejRrTzFlvA6u61j/Sq7rLDFBc2tW0fJ17wSNS84vVIq5uyWRsyAJkjtZ+2Xsoe536D06JVVKHCmsDLUFRngVVX/oiWLTH+WuC3BZSYD/cgP9aRZc9F4s5s2GHfM7kYbGeWUHi/0sxRYTQa9fJgjSu6Xb1zJeS0x2lq4o3cvYH/I9dnD3yEy+f3dVDxoZYsUaX2q5kC1/hvqMiakAswUHVGipB+XOJuOsWR1GYke57E8XE5fdPW1D6nrjDKN7SdKVBUqQ3Z0I= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(396003)(346002)(39850400004)(8936002)(6496006)(186003)(38100700002)(2906002)(66476007)(86362001)(956004)(2616005)(8676002)(478600001)(66556008)(66946007)(6666004)(6486002)(16526019)(316002)(6916009)(36756003)(54906003)(1076003)(5660300002)(4326008)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?alM2Rmd4UEdHV2gwM2RubUlldU0vTmM3OGxJWk5WRkl5R1Z1VENzRUxwQTdl?= =?utf-8?B?MzZmem51VlNKVjBIejhLS0c3ZC9hOXh0aldkWWhEZEhNWE9ya1ovcTl6U2Fq?= =?utf-8?B?NWhQdVV0YlluZGpYbGlJRklzOWt2dnNVdlZlaDg1R29XdmhZTGwxblJtVEh0?= =?utf-8?B?RFdnaG9WS2dBNnJyR3p0SXp2Q1FDQlE5Ty9SOVFQbVgya0NVSCtBU1BZb2hh?= =?utf-8?B?UDhQUVdGME52dS9xVlNYYjBNSDE2eGtxNG9sb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Q5NTY3eUVkZ3gxR0NzcEhVdGVMdUhCWjVFNG0x?= =?utf-8?B?dzd5TFV6RXhwdTVEcDRyUEEzbjAwcVpnU0FVYWFsbVVVZjA2dzJ2YWMvOEJz?= =?utf-8?B?RlhrS3R3K1F5N3A4dDBIYUFjenJwWk8zMjB6NTFlYkZCNFNaeGc4bmFuZHF4?= =?utf-8?B?ejZ0OEhGVmhSZFpISjJCek9Hc2xBQ1k2MEpoNFRFL1hkQ0VxYUZ6aFpJTnlC?= =?utf-8?B?MHg1RG5BWHlwcnZqZGpkc2FoYjEwdlpwclVQWHFhc3RzU2FRcmc2MjZRRWI5?= =?utf-8?B?VWxOMThQRTFoMVAxUUhhNHFLYXNuTUdoS3VOZjh2ZXg3cFczZ3Q4T21WREhs?= =?utf-8?B?L1V4VXF2SEtLYlJramJ6Rld4NlBWY2xDYXZkeWx5bDVlZGE0eHRndXpQNE5Y?= =?utf-8?B?NWZtd0d5SVRhQnA0dEpGU0JRMFZ0Sld3bjYrUWNzcGtpTHdtM1B6QTVuQnJi?= =?utf-8?B?ZjlqazRUdnBYS0NCdko4UkE1SGlsUEN6TGxaK2pVdUFwZWwwdk5TazFYbHd5?= =?utf-8?B?ZkZKNlU2M0FqUEdGWS9pRURlYzZKbjAxOVZicXpldW5Lei9XK0t3dzNYM1NP?= =?utf-8?Q?WzowiovRUwib3f637tAo6YTVJi0UvUVnlTDAlW6?= X-MS-Exchange-CrossTenant-Network-Message-Id: c3f6c4db-9226-4c75-9e5a-08d8fe84cd99 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:41.2839 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: x0AO5Pq5+kolurdDtasd6/dgSgBN99V8Oh/C43+OSRqVuYZNeNbOg1RaXlAzQ9eFMoUxQUfjf3GoMyCvdsZZHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2553 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Such helper is very similar to the existing xc_set_domain_cpu_policy interface, but takes an opaque xc_cpu_policy_t instead of arrays of CPUID leaves and MSRs. No callers of the interface introduced in this patch. Signed-off-by: Roger Pau Monn=C3=A9 --- tools/include/xenctrl.h | 2 ++ tools/libs/guest/xg_cpuid_x86.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index e9a86d63bad..27cec1b93ff 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2601,6 +2601,8 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsig= ned int policy_idx, xc_cpu_policy_t policy); int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, xc_cpu_policy_t policy); +int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid, + const 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 polic= y, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 208a247bb6e..8b48c51a8ee 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -757,6 +757,35 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32= _t domid, return rc; } =20 +int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid, + const 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_entries =3D ARRAY_SIZE(policy->entries); + int rc; + + rc =3D xc_cpu_policy_serialise(xch, policy, policy->leaves, &nr_leaves, + policy->entries, &nr_entries); + if ( rc ) + return rc; + + rc =3D xc_set_domain_cpu_policy(xch, domid, nr_leaves, policy->leaves, + nr_entries, policy->entries, + &err_leaf, &err_subleaf, &err_msr); + if ( rc ) + { + ERROR("Failed to set domain %u policy (%d =3D %s)", domid, -rc, + strerror(-rc)); + if ( err_leaf !=3D -1 ) + ERROR("CPUID leaf %u subleaf %u", err_leaf, err_subleaf); + if ( err_msr !=3D -1 ) + ERROR("MSR index %#x\n", err_msr); + } + + return rc; +} + 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) --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322599; cv=pass; d=zohomail.com; s=zohoarc; b=KPNJNq/jjZdwtAsWqTWQIKi69zTcqZQ4Nz4UipCdYK58UjQyxhvSOHe472VBqpWYwBfPf5dnz1PbASvsUwLehCkam9TNeeFrDjMzhyvexjRapTCU8JPLXR1x5b6CmW7okeEkmIFajk1jAV8bmcBf+c2IxSnyN2XReOE+XdcRGew= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322599; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i3gNWM7lFDWsx1HrL86tq3Osjyogq5McpScOb4qDlhk=; b=O79/u/K02SJ8zjmn7xbeY5x6q+i85KcvClPs4ly9bRnUQT0rp+PlBVv844fevI6l/BKTT3mbYyNnShUQxZplKMa76hVqo1gPUuaXz+efMs0iq7GGbaTNklgTSkgJnp3P9SY0tEJXbrOK70SWK8tlU0HtlOs8I3DIByddNmvsjW0= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322599869669.0992798697367; Tue, 13 Apr 2021 07:03:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109791.209600 (Exim 4.92) (envelope-from ) id 1lWJcz-0005WY-A1; Tue, 13 Apr 2021 14:02:53 +0000 Received: by outflank-mailman (output) from mailman id 109791.209600; Tue, 13 Apr 2021 14:02:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcz-0005WO-6r; Tue, 13 Apr 2021 14:02:53 +0000 Received: by outflank-mailman (input) for mailman id 109791; Tue, 13 Apr 2021 14:02:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJcy-0005VP-88 for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:52 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4c4f8e8f-c4e2-46cc-88fb-18f4bbd2e007; Tue, 13 Apr 2021 14:02:51 +0000 (UTC) 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: 4c4f8e8f-c4e2-46cc-88fb-18f4bbd2e007 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322571; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=LlfT1DWe4NTaP55AtYF0ZPiSw7w08SLaktbWPptC3lk=; b=ReSNqZ82stdFrOIXSPvUnQk/Lm8rW2FEszCM1Z2M4ahUasIBASaDwzAy UppZHgK3t0hqLdJWPVJe9GKLOzIBWtAr/v0fSM/oCUF3QKaRp+3nksfoD vudgZiEZ2l3EcMlXaZdzE4VeQPlgXOnW+voEZ4n7UmM+0zICBe7YldIsl Q=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 1jvGi0w09W/ulosaOf2u+LuUA9Un+Hj3/H7riKjtwACkTx69RrnJRy8JGt2HBoBDZw5B4zm8yi cndbThvbg3PmfINl05LA+y1Eb9tNiYDqYDS4f5fui1IdQEjRALmEOOJiNXtIglc53tG+ehiHU5 CdTurR+xADd2YE2LeWFUh/cxCzqTm3n03n7rCYpWe7Ll8SA527NQRebCf/tIseZOM8nE6RRlJb Uc01aP4Xa64Y5JsN3We79LrznI/Su2XMVYN2MYOrp6q3mZaDznfL0CEMV61MHrE3DVuIWxyPHR 2Wo= X-SBRS: 5.2 X-MesageID: 41476493 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:HljoC6qrjcCs8YOYIWVgQ9UaV5vxL9V00zAX/kB9WHVpW+SFis Gjm+ka3xfoiDAXHEotg8yEJbPoex7h3LRy5pQcOqrnYRn+tAKTXeRfxKbB4xmlIS3x8eZByb xtGpIVNPTcBUV35PyU3CCWCNAlqePozImNpcPzi0hgVhtrbaYI1XYaNi++HldtTAdLQboVfa D92uN9qzCteWsaY62AbxFoY8H5q8DWj5WjWBYaBnccgzWmty+i67LxDnGjr3Qjeg5IqI1CzU H11zbXy4/mmPG9xx/a2Qbonu5rseqk8PRvLoihjsAULx/llwqnYp9wMofywQwdkaWUx3sB1P XKvhc8L+R/gkmhAl2dkF/W9CTLlBYo9nP4xleTjRLY0LPEbQN/MeVtr8Z9UHLimi4dleA56o 1n9SalkqASKhX6kCH097HzJmlXv3vxm1UOu6oulXBFOLFuD4N5nMgk025+NowPJy7+4JBPKp gUMOjsoMxbdl6XdBnizw9S6e3pWnwyGyGPSVQZtvqU1CBLnGt4w1Fw/r1noks9 X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41476493" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jc/rg7PTxVuMryOpNfOnTx6MKW5xHEACJNAVjF7sUjJaKMViygvNw6LTsl/q+OFX0xFJ9CWl+2dvSI7PPI4sfblY8fUuSQZVKhddNs0mwyexDL1iM6tnHCtYTTfx1XaEApEppKFATeICGQearybm7VMma+yNqrsUaVqDnh3lwiz0fci0zhhN4A6bLAWiCaDh1YW38GZ4ylZoG0X+0GBNZZ8BP6n8zWADjMWq0O2m4jSJFx8A8AOc5DIVvzFUF+6TjfM4VabLLX4wiDYb6y3zDTsWCGCYi8JkaX91+3bYC/Is3S/v8jTrBTysy6r5f9hV4+Q2mNvMmyqt4bME0yXXZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i3gNWM7lFDWsx1HrL86tq3Osjyogq5McpScOb4qDlhk=; b=fr7mU9a7uC95iKDbvQjRtR/mP95CAIUjOP2ULWOF9cx2rn5h/mF3vqSvtZpFU4qzmYBFN7e7somKfkJwM66F0jTgVh35eHQryV0vt5Hy5jIn8pL5IB30Ro4TIzEbadkQGbXSfoIqoUefQZX7Sl5BWWvNkl48GEzPR1fqQm+DZsUK7kZ2bXymTbeBBSy1ivmYjAT2unLYdc/uMmFH0cc9ITZlzW+b7r3aYctxtQn2Qsy0Wpv+nkWcS+cmJ4G3NiQ8SmO6BqLdZnEHkBweaIRGKf1joLU3LsppzIvaVziZHf9hdlhZdlqxJdjEi3cUwCtkeQEHjlyGxPpIpdcupUo9wA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i3gNWM7lFDWsx1HrL86tq3Osjyogq5McpScOb4qDlhk=; b=ajx0fmlhrLENhLz3hLRHQAHuvTX7t5N2/8xz7FJWr0ORxd273ujV1RWmRn9uqfdIYjVQwzm9jXPE29H8mRq/iiOzQNsTZMetsjOOKfV7JgnhvP/eB5w+wDGYcxn7Ywzk/u8v1DG7DvQeF6/gmiWhjxA+6nh/qufHcnZ3Mia9HgY= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 09/21] libs/guest: allow fetching a specific CPUID leaf from a cpu policy Date: Tue, 13 Apr 2021 16:01:27 +0200 Message-ID: <20210413140140.73690-10-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0117.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::33) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d2b021c-64b8-4464-8754-08d8fe84d0d3 X-MS-TrafficTypeDiagnostic: DM5PR03MB2553: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eUH13AqT7QdOPGOu+ebdMZelBXnIr19GCdgIiy8xEPia6uGTpuG43d01pFF3L2o4UauhteEqou+ETAuTZ3rZQS5WXgAF+ovKM/H1QqFqueCjcpw6yHr25Xcu/nSu+nazPHO7DfaPJHtadsgFo/xHxw4wWO/UZSLAJylgh3vnKyNG8ZAa9ucoDrnKphQ5RbkqQcSiwLOse5l9c8xORgvjNwfn+NAQ8CGxe26t8k/fw2VmXPJZUSJEaUAelCNPDpOEVIeY52JYaRpnilKh4OMCDeAZgJJelubwSvbqCil0dXyOHDE4y3d+5lyvrKmbD37UcT6+qZwnsCNvHbTHMQSf3BdPKi6KxqYLsuXt0AezRwqvMh1TpZ4lhLN0JO9lvKK9CkfZSRoBRT8nB76suM2R4jHyrgLjeXr6r3V4qRpIWHIDni4kLqDaJcnCf28M0Y+dLEievCnYhoINDbE7zCT4TxBMbWlSIyyo30/IUOFq5D8BrQubDYOdPlUWvuxzEnCxIwxUNMVohnV+AS2SHvftNbsVSyrWKOAPFcTVOp1gpYelalG8scwxh00I+rKsjJB0qPZRz+fpA7kskE8sPBhPNA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(396003)(346002)(39850400004)(8936002)(6496006)(186003)(83380400001)(38100700002)(2906002)(66476007)(86362001)(956004)(2616005)(8676002)(478600001)(66556008)(66946007)(6666004)(6486002)(16526019)(316002)(6916009)(36756003)(54906003)(1076003)(5660300002)(4326008)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?TnFzQVFpSXg3L3lHUUlRcmdkeXQySVFFN2xGOXE0SlhNWEpvUDRXazJlKzlH?= =?utf-8?B?U2dOVUpHVnVua0ZtQ0IyVFNtQ25PTXZybGJWZFJKU01LajVIeVR5UmJIMEk5?= =?utf-8?B?blBpZ1BYVFpHN3VaZGh5S0h3VEptd2hwL2tnL2FDTTh0Zm1OY3Q3ZTloT1lW?= =?utf-8?B?OTcyUjJNeHI5cGpYcjNKckVGSGJuS3I4Mk5pSWZxRFY4WTF5RU5jQkdFZmt6?= =?utf-8?B?bFU4YS80bU9GZEtuZ3pBZ2xXbmpyYU9FeSt4b1ZhdUVLOXZ3Y0hzcndpTTVz?= =?utf-8?B?VFl3ZWpIVGNWdWlPTGN6ZmpCWWdEN0Rkd1prRXQzSzdJNG1saW5kT2ZqT0ll?= =?utf-8?B?Rm8wSDlZN0pKWC9WVHJzSEFZUnBJNDNkZUtDeVlxVm1teHdscEFVSkxjUFYx?= =?utf-8?B?ejlJeWg0ajRJcStKbU1ZQVdhUzZXT2lLOEhKMm5kT0R1czVERERTQm9qbDkz?= =?utf-8?B?azNuZXc1Vy9vYTFoa3Nwa1BvRFJ4VmRocGIzdWFibFRQbnZxK2dYb3lwektY?= =?utf-8?B?WG1uNFphbS95MzNFblp1Snc3dXRBeEtwK2o1UE1LQ29PL0pqbUdtelU3RjY0?= =?utf-8?B?NHpXZjI1Z1hpMHFwRTV4Qk5nQ3kxZVcyeWd6aUZjRzJMNDJLR1cvanlRWXJM?= =?utf-8?B?cjR3alozMkRBSDBhcHd0ZDhYQml3OGZNZTJYcVdYV0Q0S05SZFEzbFEydmhM?= =?utf-8?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?B?c3B0aTRmZ0xEaWlGTEJrQVFRSVNRNHRkNmVrZERyWlZEMzZDS2JIMHF2dTZp?= =?utf-8?B?YmcvVmo1R05Qa0VQNWVSTit6SGIvRUdLZW4rbEVRYktidURTY0llc040aGlx?= =?utf-8?Q?AqyvNGZR8sp4qYp4n/nvnXFMN4MO+XP2zon8V+b?= X-MS-Exchange-CrossTenant-Network-Message-Id: 3d2b021c-64b8-4464-8754-08d8fe84d0d3 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:46.7732 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1osmuPCmby5rrRI2DCxLFzboJ1+tLtDJfUTGOjHYNXo0FM3GBvPsp1JClQZir5IxPJJp9PP59r3vy3D2xPXaKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2553 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Introduce an interface that returns a specific leaf/subleaf from a cpu policy in xen_cpuid_leaf_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Note that callers of find_leaf need to be slightly adjusted to use the new helper parameters. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Use find leaf. --- tools/include/xenctrl.h | 3 +++ tools/libs/guest/xg_cpuid_x86.c | 38 ++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 27cec1b93ff..cbca7209e34 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2608,6 +2608,9 @@ int xc_cpu_policy_set_domain(xc_interface *xch, uint3= 2_t domid, int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t polic= y, xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves, xen_msr_entry_t *msrs, uint32_t *nr_msrs); +int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t polic= y, + uint32_t leaf, uint32_t subleaf, + xen_cpuid_leaf_t *out); =20 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 8b48c51a8ee..d146c5bbc99 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -280,9 +280,9 @@ static int compare_leaves(const void *l, const void *r) =20 static xen_cpuid_leaf_t *find_leaf( xen_cpuid_leaf_t *leaves, unsigned int nr_leaves, - const struct xc_xend_cpuid *xend) + unsigned int leaf, unsigned int subleaf) { - const xen_cpuid_leaf_t key =3D { xend->leaf, xend->subleaf }; + const xen_cpuid_leaf_t key =3D { leaf, subleaf }; =20 return bsearch(&key, leaves, nr_leaves, sizeof(*leaves), compare_leave= s); } @@ -365,9 +365,12 @@ static int xc_cpuid_xend_policy( rc =3D -EINVAL; for ( ; xend->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++xend ) { - xen_cpuid_leaf_t *cur_leaf =3D find_leaf(cur, nr_cur, xend); - const xen_cpuid_leaf_t *def_leaf =3D find_leaf(def, nr_def, xend); - const xen_cpuid_leaf_t *host_leaf =3D find_leaf(host, nr_host, xen= d); + xen_cpuid_leaf_t *cur_leaf =3D find_leaf(cur, nr_cur, + xend->leaf, xend->subleaf); + const xen_cpuid_leaf_t *def_leaf =3D find_leaf(def, nr_def, + xend->leaf, xend->sub= leaf); + const xen_cpuid_leaf_t *host_leaf =3D find_leaf(host, nr_host, xen= d->leaf, + xend->subleaf); =20 if ( cur_leaf =3D=3D NULL || def_leaf =3D=3D NULL || host_leaf =3D= =3D NULL ) { @@ -817,3 +820,28 @@ int xc_cpu_policy_serialise(xc_interface *xch, const x= c_cpu_policy_t p, errno =3D 0; return 0; } + +int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t polic= y, + uint32_t leaf, uint32_t subleaf, + xen_cpuid_leaf_t *out) +{ + unsigned int nr_leaves =3D ARRAY_SIZE(policy->leaves); + xen_cpuid_leaf_t *tmp; + int rc; + + rc =3D xc_cpu_policy_serialise(xch, policy, policy->leaves, &nr_leaves, + NULL, 0); + if ( rc ) + return rc; + + tmp =3D find_leaf(policy->leaves, nr_leaves, leaf, subleaf); + if ( !tmp ) + { + /* Unable to find a matching leaf. */ + errno =3D ENOENT; + return -1; + } + + *out =3D *tmp; + return 0; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322595; cv=pass; d=zohomail.com; s=zohoarc; b=Tl5HOXSHcdxJJZs1XRxXG7G04Fi5YEIIW5knrOFQMgiGJ6rikmadIbjBXPbGViniNj4a7fW7n6sYYPxJ66VD6rnwubmFfNNgsay7wBB+rPhzJAO+uBYhamXqCHpB6x+Ta38EGmi809EWZTnNvt3oT1UbSeEeOljsXW4Z0X/He3M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322595; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QdjL53sxfL72OocLfvFBEO6t+rw9rfdKFRBd12scbro=; b=QXdHTvNmI7E/9VqrYLhJ/Bd4xHQuC8yzshd9FMIHzymiOw3g50SWcRczIOcOFAF2Cyw7iLUu9xJcq/37pLD6axy63CxxapO/mLpo0FEanh6Bc29oFvEy/weFp5wlwbI/HrAjWzO26JbgpeoMeBA5F8T2kHnClJMU96XR4T5HxYc= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322594939913.4648776832967; Tue, 13 Apr 2021 07:03:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109794.209613 (Exim 4.92) (envelope-from ) id 1lWJd3-0005av-MC; Tue, 13 Apr 2021 14:02:57 +0000 Received: by outflank-mailman (output) from mailman id 109794.209613; Tue, 13 Apr 2021 14:02:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJd3-0005am-IC; Tue, 13 Apr 2021 14:02:57 +0000 Received: by outflank-mailman (input) for mailman id 109794; Tue, 13 Apr 2021 14:02:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJd1-0005VP-Lw for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:02:55 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e7aa8d1c-a197-4003-8b03-da7179619109; Tue, 13 Apr 2021 14:02:54 +0000 (UTC) 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: e7aa8d1c-a197-4003-8b03-da7179619109 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322574; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=WrgzclkoEzTDmdIEIC5OF4WYt487TOXaBKzV0255Ehc=; b=cW1DwgZ2EH4UaWnCeb5YmY0ma/ucANYMiazLQj9leA1o7wQJIhnxp340 XFLudQOYx9/IbZ54jg6GJfv2jlSY53wCsbM8DiaTnPghqRGYDPirdGeja tfWETNdq3p62MkCZSnzNg6uMt7QIRBkXxCiEHxMoSUAnvyYHUo+BdHUAZ w=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 9xL1XWWUHkQE602k0AFIqXPVi8BFPmApmrtre0or53xCSVo4VK9l4NvIEvvUpAmP94oQ1q5YVd 3pAyPRn22vQf8wQh15DiL8tST94jxiW0X9pUxfnFqtinaWyVkhXgarB1FlMOji7lVqp5wHXGyl 5dfDtbOmoSPsdxvcUxf+SMt4r9y9g5S5bHSQ+3QHL1mcPSJWaRXQMPmF0/d6P1H0n8t71yV+1s jO7vxeKYFD6Pjm1+Heb2SOdB/a9IwzYcZiamajbIz2lh/XcXI3KCUzOYOmWhA5lHsoFZhndlwF Oo8= X-SBRS: 5.2 X-MesageID: 41476507 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:nS7wcq4XsyIXVmxItQPXwU2EI+orLtY04lQ7vn1ZYSd+NuSFis Gjm+ka3xfoiDAXHEot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vr1 2kCRfRVeDAA1JbtHwd6Krs/V9uXki2fk57aBlBwMZAPFWDnkw2/f6AZ6K13WfUV0ALxfsFNi rZJREIJBl1+tyx3BmJuTqLGHk83K8yNujFALlLScCU5lqdbKmz0Y0WFf5d+5hocO30uugQSO SFZku7Kij7B+5B4X3iml8VfA1P7F8qnvPj1Ee7sCyW3HsjDeHTJ1ojbbcBON2Y53XlQfHN8J gRt6NAgcKAdkHKLviBwuXrShQGDDX5i2u/VfspppBZprhajso6I7DrFR/zkEha1xA/JvrunE wQQK5H8KnMU7UfCvA6SmZ8xB4Vj9yBI0sgjxzuDsI/dV8riWXHP9nh2cu+lZMfRmmIpA79Ij CkglVg1saAeyuIzrgBDa0sZUxQdUgn8XxnldnyPbH4OUGPd+tZ+kC9PWL4WLhBSLKdEbFVih ph+dmHk6u2cCX/sTqg8AdTE+Zr82y9R9m1Dx/JMelU88aiMVDJu5CU2qeI/X7KYAr+TV8Zi4 1DfVERacoGqgBKtvxJ7gGCDortokwklFNC5ypAjVCF4Pn+3Fvm X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41476507" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LhusGuN/wA9Tg9JPTTttwO4yzdLd7ohDdhBwi6H2xR0DtA2q6lspK3C7RgcAfN95f3PM35XUBaHdYb2swDfzcButSV61nJQwjNKnSSDztIWaNpGOBnMv70KQeSqyl0Af0eX4E6149+V8TDC0CZ16t/QSj4csESHaSQ820g18qnVzm08Vga0Oro7hSI3r6yQlPSLJ37ADB3c/saCTwr5WTjecA7kZVaqYB8bnXZzwagAJ1AZT4OqOEAnmFCh/egOH48hXGe5ACH3ICKTbSGtavUNjVnEnpxzjIY/FHE2XUwHJhdMRe8jFlQO5wcEgldfAI76TqJSla6Ms3Q5tN1ZB6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QdjL53sxfL72OocLfvFBEO6t+rw9rfdKFRBd12scbro=; b=RzoL7xPis1aErWqhZMWfzxp0MhJGbRSVrXuX86GizC9zdFuKK5PrD4FW7oHCXQau+C6uQuOVvZH4brCz+uEb7+YKP8Pot+gOnl37hIRIja77ahoKD2fgjjZM0kD6nsTq7AespkDZxs7/b8O+fPwHhnfV3XztLiBomGtKguOsFJ3Iw6+vQDzEHqKHQVqKW1EtVGPp8mXg9QyXHoGBoJdzRu9xOgsLpXkudQQ+MwBrM1nF2hUH6BViTX3AwhV4r5kMxuOHY++sfnZ4zz3StiIDY7vS46ovsITJ4x7sfjqRd3CvgkkZWuMqklwGp76vOlFM8mz8XHDGy9pZ6ofWtlIdPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QdjL53sxfL72OocLfvFBEO6t+rw9rfdKFRBd12scbro=; b=d5ZVAc8StDCLtYrb/sD8RTJpFjsT+PxBY/sqXVPPRX5ZE68VmABGglQRVQnqX4n9gW7BXO8tMDYRw0kF0YuGZpXLTcG6TLViEjy0mNyQXqD7HFNpEEP8U6fis/xsvqXFOeTuSHvtWBx/NBFZ7L13nK662I1Spt/g8ZQuzkug1BA= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Jan Beulich , Wei Liu , Ian Jackson Subject: [PATCH v2 10/21] tests/cpu-policy: add sorted MSR test Date: Tue, 13 Apr 2021 16:01:28 +0200 Message-ID: <20210413140140.73690-11-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0114.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::30) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d3d20d3-3ccb-41f1-7c39-08d8fe84d3f1 X-MS-TrafficTypeDiagnostic: DM5PR03MB2553: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 48VIJXz3jh4b7mENzd/m/UVziWlbcSQy302XrYpX4/Nn51JaBAokO5ic5orHVyC/xAggYHIQJN/ufOaZJjPGe6kP/R1+vdmMtNLYwiNSmRwjR//0t0N3gVOs2asPfnazkKyNhFpsW7GhmtsR8nsHA2vcNNQ2tlMFeBgktQMyhAR04wTbbEpPp+YiSnk/DmWhLy2RLRjgU+1+A1tGqx5zAs8KtktPsMS0WOMmjmv9t5pHSGUZnYCcefj7sNnOFiL7OMWE40M0OwXqaYfqlRmMFQSQI9HUmZLGXpXg3lD6p0z8oFKhGLQzc1z8qeY0Rxl+ZQG0WWhgRWUtV1os0CaKk/YCSH+Hv1ISqrvUfs3pQ6tXrjRw4zkEeSETnzcxT4kf8RtbwyHKn3TSQwNjY4t4naPVVt6bX5M+AcA8CXJ2jOcyxK8wPXnkxs3eP9RxG5781ycloM1tzE0Fa6gfq8UKeGVJBinftOSMN3HCDXfka4IIGAJKN5rzVVTyGPOc3hKc7O3mMInGLiz0CJ2IWfSKexeEv5DVfnajMkniHIBOSe8X9WuQennAzCArsa5Ar+/w5MLBmKOrM7tQGayJSDWTFA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(396003)(346002)(39850400004)(8936002)(6496006)(186003)(38100700002)(2906002)(66476007)(86362001)(956004)(2616005)(8676002)(478600001)(66556008)(66946007)(6666004)(6486002)(16526019)(316002)(6916009)(36756003)(54906003)(1076003)(5660300002)(4326008)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?MUdFRmtNWm1YdGptYm9ZMVc5YTBETCs2QktnYkx2Uk9BZHdaY05aSytpSzdw?= =?utf-8?B?OWxRdlkzSHUvbnY2TitIbU5SN2dTbFF5MVVVdTVoaWlTUnhYeGR0eGhHWWZV?= =?utf-8?B?Y2dJeXFtejFxaVh6TThtR3VaSzFRRWpiWnVtcGVUWi91U3lKY2JiVmh0N3FL?= =?utf-8?B?Q0NtbHJ2Y3k1NzBML1FDb2RwS1BJN0ovSTFycko4a2hEY1hEUWFKQXJpTE8v?= =?utf-8?B?VWJVRW9SZWQ3cksyL3NWam9kUC9DQ294aUdZeXNmWkxLL1B4eVBJNWNhRDMr?= =?utf-8?B?TzhDWUtDUW1BZjNaSmsvR2liTkdqVmx5RGNaMEVCVEdqVE1nMkRESVB4R3Jw?= =?utf-8?B?aUpGdTZhdEtXUWRWY1dQbERpd1owU1V1ZlQ3Qk9oM2QvUnlZSlJURERKTDll?= =?utf-8?B?d3lmcVI4b3RRcE9YK2U1OUlLeGdlZ290b0RzRjVBVENwTGJhenBwci9EOWJR?= =?utf-8?B?SzJpWVh1c2FMNGVUbmlXZ3BaMWJiTjQyeDBDSkRlc1JuRmdJakcxT3Qxa3BH?= =?utf-8?B?RzV5SW00WGJOOU4wZVF5YzB3aXdIbHVxYjJxRlcxYmQxUFFCZnFEajdNbHVp?= =?utf-8?B?a0NoN3ZaWkZiVkJPcE5yMnVvZ1lldTkvVU8relMzMkt1WmZyb1FsUXdPc2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El5R09hT09GV0dQVkJhb0p5N2RU?= =?utf-8?B?QW85ZUM5WVNIaVdLUzMvSFZ0ZEg5WnIvdTEzLzZkZzZDNC91WmM5dlhXR1dJ?= =?utf-8?B?cHU2SmRWNzNFeGtPOGg3Qk1mbmQ0NngyZGxoejNhSUZGZXpyTm9jNEhFNkRm?= =?utf-8?B?TFp6MmtJNUJJVUxPcEFDMW9sVUc1RDFkYnBZcHkwSlVKTmtZZ2ZuQlFTVyty?= =?utf-8?Q?s6wBiBMLYwp7ActEBa2GZQadLoH01iOmX+e4ELx?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5d3d20d3-3ccb-41f1-7c39-08d8fe84d3f1 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:51.9863 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EmfiLvtKDedysUSzzvY4Jc2J7Ns8idIQXjQhlnoWFgXkGRrh2y1DJFMS0Qv2yCBzZ2gYqJYwgLmCYXqMvwYEfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2553 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Further changes will rely on MSR entries being sorted, so add a test to assert it. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - New in this version. --- tools/tests/cpu-policy/test-cpu-policy.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-pol= icy/test-cpu-policy.c index 0fa209f1ea7..ed450a09970 100644 --- a/tools/tests/cpu-policy/test-cpu-policy.c +++ b/tools/tests/cpu-policy/test-cpu-policy.c @@ -86,6 +86,16 @@ static bool leaves_are_sorted(const xen_cpuid_leaf_t *le= aves, unsigned int nr) return true; } =20 +static bool msrs_are_sorted(const xen_msr_entry_t *entries, unsigned int n= r) +{ + for ( unsigned int i =3D 1; i < nr; ++i ) + /* MSR index went backwards =3D> not sorted. */ + if ( entries[i - 1].idx > entries[i].idx ) + return false; + + return true; +} + static void test_cpuid_current(void) { struct cpuid_policy p; @@ -270,6 +280,13 @@ static void test_msr_serialise_success(void) goto test_done; } =20 + if ( !msrs_are_sorted(msrs, nr) ) + { + fail(" Test %s, MSR entries not sorted\n", + t->name); + goto test_done; + } + test_done: free(msrs); } --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322599; cv=pass; d=zohomail.com; s=zohoarc; b=gJ8XHz6z4rSmuFVTwQQnAVQVCYKzU6xPqs/gLILnsAfLtiw1YD4EVtb9xe5a/+iX1IgbfOiFuFml7tPkrrZ3sky2UZpFxCe/Rz+dgmkB8Jl58cXUKdcjC/NL8ysAgMCIvDn8yuW/nI+sozex1T9PaMoalPMnuvBJ9k3BJjRw0Go= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322599; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hKIl+cZikbO/4WJIAGz+bxYAoaTNWAIK2jf+mYY0UCM=; b=A+Lh8R9LRzcgzRpfRujXQa7Fo8GjfsouhLY7/yQyNXeo10NHiP7dkJ4eIDFDCXqSoaUFYb9O3zx1T28heUBw0oHDE6HObowMpQ/DFhEA9Nt66NXhYmTb/W8M10Obj77UwAkfklN1qRrhGvESVawZAEV4KWz0pJJtXSVn8yNEdyc= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 161832259947933.62463001149342; Tue, 13 Apr 2021 07:03:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109798.209625 (Exim 4.92) (envelope-from ) id 1lWJd8-0005h1-4R; Tue, 13 Apr 2021 14:03:02 +0000 Received: by outflank-mailman (output) from mailman id 109798.209625; Tue, 13 Apr 2021 14:03:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJd8-0005gt-1A; Tue, 13 Apr 2021 14:03:02 +0000 Received: by outflank-mailman (input) for mailman id 109798; Tue, 13 Apr 2021 14:03:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJd7-0005gB-BP for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:01 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d74273ce-9fab-49c4-b216-cdc065d6f58d; Tue, 13 Apr 2021 14:03:00 +0000 (UTC) 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: d74273ce-9fab-49c4-b216-cdc065d6f58d DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322580; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=JackXKtu3s4tq3Ai8UONDkNKZ36QopXBh8RsfgQrQMM=; b=bvkEMSWIpf+eqAWHvyk7yRy+AfkHksIf8ycrfqGLYoMSg71QlOjvgycx MRgq1hluWdnUly+Pj17QowuwiEqdy99x/UU8dgTauO3Xt1vrYR/B16I12 qAmO+oGIZ5YjtVcesd7DU+rH+cijJK8PjMupxi/kpJedZXoLn0sHJxDMe o=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: LD/cCgzU20nEzbpxCDgNVbICS5WNqeiSyyqTo6PDtO4Z9Bwbk9Z3s5R1EU0QsipCkVHlLndAv1 5XbpOlpILuTnalg0XQ7a+cgvjX0+OvjQ2YA2E0WdrojmwBMzby3vmHSAE9JG8LQSIvT/jBUdp7 lxhhDl6DmoIPkEhrb/brB/3bsvlOPCz3zH1pyoPVHx58AZyFm/HkU21yre+2ouxEdpewNlJnCC Mh9M+7lcodjEk8p9sZgJ1odEwSEtNCbQqOfpjr9OtD/rnqb/5o0iGbC6U48X6ucK78O8Ax0A59 +8M= X-SBRS: 5.2 X-MesageID: 42956030 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:T0IZcKhMHAzHEeHXjV0CZE9l83BQX19w3DAbvn1ZSRFFG/Gwv/ uF2NwGyB75jysQUnk8mdaGfJKNW2/Y6IQd2+YsFJ+Ydk3DtHGzJI9vqbHjzTrpBjHk+odmuZ tIW5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rMZiEKJBhyg/qt0gSOpTqEHXI655knM+DHFo4/e7XL1n7FEvzPqYg2W9tvuLp1PtHnteEGFd +FcwiONTXiFqcH3ReWqntNAlgDlFAU1dfTnDvr42iz0CRhXb78IFF6S6oaJN/ZxW7+XPqM2I h4i9VwnebYCBSEVve2jYXsKxhEIVfvhETzaccCg5Vdp7gzu7t+BIOza0qB6Fh3mDEFaP7pn0 YfSplh6L/POoVTb9UfEhgpi2YBpZCqFg8XqQT4De81QEE1g1LaN92P5aDUqbBHODz3mCLAfX 2W8yhQ5J7+LlO+/I9fL6I7OmJNbkcgrFxk4eOZboXVYT/aPd1rzR6fMnWndqVaR7XAMbIMrg xi69XNu+OMbSL31ETxujR8S5g+vlqPcIeXAAiWH/RP/MH/EVOQgrGy6Mr2tQzJc1KAGg0lrL wAU1cRYMRFgiQji4Ny8hHacN2JnmsV131E4T9mkVbx3JOB+2mzJzAeDTHk X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="42956030" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ndQWx12gb9xkL2GKqeL3NpeARs48k7hLbpNcwk5sEAnOrAH/6CNEiqgHWJ2JKBwrocnNULp4An71EFLVvdDE2xFfUejnZfjfT5qFbZXySOZ3ib+nWehsDf8dVnE4Dk8oHoBKF8gel+IyXcdhfus9rvpnV9Q41JySXvKU9+BJ4B+Ij8lch92rcsmRwaQVaklCLdiKUfV0GJzE2q7Thx8fT+ZvZhNYGKwPEv7TTAMBLoPuhyRpFWAo1D+M4q8MZGDPb0kh2c5CR4ThcDRdWYjrnKGMzZgrSvckBc6398bwhsnh17RffNCRo5host+px5DDiiwVpPQVehTi8vYiq409NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hKIl+cZikbO/4WJIAGz+bxYAoaTNWAIK2jf+mYY0UCM=; b=OWJQpY6jCTciNieYCrLfl7LWvYD+ngeTTrArie6Jhj1UY5e9i0pskFgwDE4ZFJ9UCdvXYTzTYNWPBexneu78R6WGo6jUqktex5TZnRrSEwcSEluwMNqJuzDU6cNv79zu63IJW6eM56NpXJDZaVJKSm64WdUkn5peZNwYn91fHpYgc2LuQPOz/BBcn43rxYUBVYo6Sm/qkijnXsYVV6bCiGnjASC2XCTIPlrov2RGsdH1vGVetxGBRN8tXkCx6AZVK/ko+sko6eoJRmkWulnFVQuidhCKcSB3r9z0NnYhr8/BfXJ9xn7+IbWtdAz56whI/hxZ+b7bMNe2d3vOLFogvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hKIl+cZikbO/4WJIAGz+bxYAoaTNWAIK2jf+mYY0UCM=; b=iJfSfWWvXa8cTWHaS2XtydeYO1kTKtb5TZZNJPvMtZYU76hxq+38pBa3YBcJ5F5oa7+Ez8IkspvJA1b+vSGa7vCqQEWqEpgeQ+rDRAt4pELOYqjjrrs7YL33jzBpv5OJrg4YtRDfqcnwE3iQ5fMAnokF5jNjaVwwIq5CLEMGbcc= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 11/21] libs/guest: allow fetching a specific MSR entry from a cpu policy Date: Tue, 13 Apr 2021 16:01:29 +0200 Message-ID: <20210413140140.73690-12-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0097.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::13) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11df82a2-ed1d-4bc8-161a-08d8fe84d707 X-MS-TrafficTypeDiagnostic: DS7PR03MB5542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QfpM/52ErScc9XWldGLD/ep+j1i1s8B6dJCe6IWKUmFBuMBT9OC15imF/TTXe8rQGOXNtfyRdJGzIK8atK4MKateV5BieaSsODa2T/0nqXQklFDwFW6cslTGsJArA7lYvj0v9jDrbiJ7hFa4aE5yGKAGRHxcLcVfKxiBjmOXXp2S8xS3SggbGgHi7KnUdtrOrBgvt/JZavkuDhm725VuAxubvpogyGK57WvuRooBDj6lPmOS4OzJ3mOyifDsUavzqhHkggE9A8HlgSpz2bAIqLZJZf6K61SiPEBj87WJXXri3IijLEs82Nve33+gBiqXtp92PE7mt7DSMOKzUocEcoqzGCH1i8QK4sJnE9mfAe/3bZ4cdbk63KC8TOwyN1jEnekD9vGLiQKrubXRyOl47ydpZrsWnipVIs+VHiXIlgqyvUBy6fBe9D1HFAp7gsBEoVzh5/TwzHn1DU8nCJ9yzgwEXxbhoUBkez5B6fLNxFvwLZiSxcQvL7q2iJDyU1EzwaDxKsnvK2DRr7sdC4dC9KJr0S9E4p9iiA1ckz0X2I3j5U/A4RqperxUVp3FSShv6Nl7XlAV5h3wBPNuYVPF/w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(366004)(39850400004)(346002)(376002)(2906002)(6916009)(6486002)(36756003)(66946007)(54906003)(1076003)(6666004)(5660300002)(66476007)(316002)(66556008)(8936002)(478600001)(186003)(2616005)(16526019)(86362001)(6496006)(26005)(38100700002)(8676002)(956004)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?SXRhNjRjWDhCOWpFMHNXd1BZYS90S3JGWUFsQ0VibHBBMEtTR2kyenhWQi9R?= =?utf-8?B?MnV5NkhoSEh5a29JNW5RdTYxZk83ZGxpaDJnbnN1WFRaeG5tRytnckpBQTNx?= =?utf-8?B?Y0V2R0l0N3JadTBzWmlac3VnR2pvZk10R3BZMVdqUGgzQnpDbmJEMUVLTDdJ?= =?utf-8?B?NWRpbWpObUNzeW9DNG4rZUpQUkVKN3B0SkdUdUd1UnpvaDdvZTZuU0RBN0d6?= =?utf-8?B?NFAwTDQvdnpSQnR0UWM3Tm1lNkxpS3QxTEJrT2wzN2JqSjVUVGlBLzlORndB?= =?utf-8?B?amZlNVpLdG1QNE5nMStVMTFYYmZIa1I0S3E5TDlhRGRRKzdCbGk3WVVxbG51?= =?utf-8?B?ZDdObmRMak1mUytDbm9VOEhsYzhBbDdDYi9keWVpdnBzWS83NlJnSlRhQi95?= =?utf-8?B?d1dIdU96b2JXZlp0U0J3RWVsUy9qN1JCQmZBTFZ1cTJUZTE1a0dMOC9xMTht?= =?utf-8?B?eEdMUWpVeVljcG9nRjQyVzlsbkw2VkNVRUp0Q3RyR0d6ZkViT1VUc3JCUko1?= =?utf-8?B?aXZNZ3Q3bHkyNHBYbHE4MVJsMlUxcEhNQjlrUFZkbWlIWGM2VzVJQkFDSWFi?= =?utf-8?B?V3N0ODQzUEhnRjRJdFo0alAxdUdmaE1vMWZBYVZlMDRJRTdYNHNNTWZpK3FX?= =?utf-8?B?QVlZZ2NpQzVWcm82ekRNR3gvSk1lT3h3aDNlcXNxOThybHJGVjBMT0ZOZGdm?= =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2hiRFZIS0xwNTVmUWpi?= =?utf-8?B?cVQweitqQXVCRHNhU04vVjhNQlg3cUUyQU9ELzhYMm4vWnVjOWZhNkxaQUhW?= =?utf-8?B?cXYwelQ3M3pDelk1dFY1blVETmQrYThPM0RkR3VKZEtHQU1mZGR5Z0lZUzh2?= =?utf-8?Q?40r+TJXI9ScOmF6d/PXWr+Tu6pHgBYG/tgNUNkY?= X-MS-Exchange-CrossTenant-Network-Message-Id: 11df82a2-ed1d-4bc8-161a-08d8fe84d707 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:02:57.1685 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GikvOeyyGXHpjAnq1J/cbYN1eHXKBeFMbZBMxwCnnXEdfQhc1+eEH8y89ekphtv8v5SQ0OG968DIbSG+OnluxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5542 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Introduce an interface that returns a specific MSR entry from a cpu policy in xen_msr_entry_t format. Provide a helper to perform a binary search against an array of MSR entries. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Introduce a helper to perform a binary search of the MSR entries array. --- tools/include/xenctrl.h | 2 ++ tools/libs/guest/xg_cpuid_x86.c | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index cbca7209e34..605c632cf30 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2611,6 +2611,8 @@ int xc_cpu_policy_serialise(xc_interface *xch, const = xc_cpu_policy_t policy, int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t polic= y, uint32_t leaf, uint32_t subleaf, xen_cpuid_leaf_t *out); +int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t policy, + uint32_t msr, xen_msr_entry_t *out); =20 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index d146c5bbc99..a4307d50ddb 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -845,3 +845,45 @@ int xc_cpu_policy_get_cpuid(xc_interface *xch, const x= c_cpu_policy_t policy, *out =3D *tmp; return 0; } + +static int compare_entries(const void *l, const void *r) +{ + const xen_msr_entry_t *lhs =3D l; + const xen_msr_entry_t *rhs =3D r; + + if ( lhs->idx =3D=3D rhs->idx ) + return 0; + return lhs->idx < rhs->idx ? -1 : 1; +} + +static xen_msr_entry_t *find_entry(xen_msr_entry_t *entries, + unsigned int nr_entries, unsigned int i= ndex) +{ + const xen_msr_entry_t key =3D { index }; + + return bsearch(&key, entries, nr_entries, sizeof(*entries), compare_en= tries); +} + +int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t policy, + uint32_t msr, xen_msr_entry_t *out) +{ + unsigned int nr_entries =3D ARRAY_SIZE(policy->entries); + xen_msr_entry_t *tmp; + int rc; + + rc =3D xc_cpu_policy_serialise(xch, policy, NULL, 0, + policy->entries, &nr_entries); + if ( rc ) + return rc; + + tmp =3D find_entry(policy->entries, nr_entries, msr); + if ( !tmp ) + { + /* Unable to find a matching MSR. */ + errno =3D ENOENT; + return -1; + } + + *out =3D *tmp; + return 0; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322604; cv=pass; d=zohomail.com; s=zohoarc; b=Qo1jB0PxK9+UDt6bW6Eg5Q8Lsuvx3yny85J6aCTmvsqfWXGlVceO+iQvuYxPmegkHNYNBUNUSb4xGxLRYhJTbfSYpY9On/SeIz3Dkx2k7/IW9iMQRsmRadnZ3/jz1BPvGhDI7l/nfbJkmZ2K70gjmd/1/YiEfgu4iDRYAj2P/Rc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322604; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V/ovcTNSHVs4ALtpeQdtZQbZnv807eSa9HwEL/5Y5Kk=; b=WYNbOOLKaOvuzYNZrlFfsAzD1hkt22hwZ9HnlV5n5HgYQneKL7rw7YgzttXnMbJ1cPLerAfEHZptmbaNu4cLHJaC4UXD+n6sLfEXxNDL+hp/Gr7noD2tSn+y2zT42IiF6BWZ9silaJPYJwkXmmJrOhlDF7zNk+P5yXWT6u5o58g= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322604290669.1838959280165; Tue, 13 Apr 2021 07:03:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109805.209637 (Exim 4.92) (envelope-from ) id 1lWJdF-0005oO-H8; Tue, 13 Apr 2021 14:03:09 +0000 Received: by outflank-mailman (output) from mailman id 109805.209637; Tue, 13 Apr 2021 14:03: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 1lWJdF-0005oB-Bk; Tue, 13 Apr 2021 14:03:09 +0000 Received: by outflank-mailman (input) for mailman id 109805; Tue, 13 Apr 2021 14:03:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdD-0005mn-J4 for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:07 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f7f60cad-cb01-4026-bd7d-e567c16b40d3; Tue, 13 Apr 2021 14:03:06 +0000 (UTC) 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: f7f60cad-cb01-4026-bd7d-e567c16b40d3 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322586; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=v1Ot1zwenjTIlLCkVwXbZOBCpx4o6Tu0RqBs8/jb2LM=; b=A2AJXdgsVdUB4SMGrBjvDYrKN3V0PC4OGZxOAHLsl0ml6v45jxIizgO1 ck1FCJg2s/fnGPnpvq+JrYuRTJmxVHxabP5loVuBsOa9fe6KCWwOwKu6q VM8c+Kozdh8HorjeOhkPXRA37544gtaELZ0yG8yyC/C53UZlEJXTpfGdd U=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: pads+fZocMdfPralEkVdCc7+eesbHaD5+4FC2xyB8mMd1S6CbO6VG6cN1myxqGjknYh9iMTHl8 Gwuw8Nzte7JcZezhsJwQ7iYj56iwLMJeF68nTXwooOJjZROUJbq4ORbUbb2W/BXLM7SUFhwv3W D8v/KZh8t14m6aCj6H55sbf9iIsMSDBqKO6rc4v1x8RezKC1QHuvap8jJqgcN2MDiM/aLKlMRi VkdWq7ECKJzzAm9wQz+uqWtdP8AjM1M8Ws4N/J867cl3IVpC80+qNh5Ceo+TUA2F9m+p5jrASd pDE= X-SBRS: 5.2 X-MesageID: 41476537 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:HGH8daGPqsBE/THqpLqFbZTXdLJzesId70hD6mlYcjYQWtCEls yogfQQ3QL1jjFUY307hdWcIsC7Lk/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeNJwTXzcQY76 tpdsFFZeHYJURmjMr8/QmzG8shxt7Cy6yzmeLC1R5WLD1CQYsI1XYcNi+wFEpqSA5aQacjHJ 2H6cZd4xamc3IbbsO0b0N1I9TrjdvNiZ7gfFo6FwcqgTP+8A+AxZzbN1yj3hkYWy5S2rtKyw b4uiHw+6nLiYDc9jbyzGnWhq4m+ufJ6twGP8CUj9hQFzOEsHfSWK1Ee5mv+A84u/uu7lFCqq i9nz4FM95o433cOkGZyCGdojXI6zol53/8xVLwuxKKyqaYNVFKefZpvo5XfgDU7EAtprhHod h29lmUqoZNClf4lDn9juK4Ji1CrFa+onYpjIco/htieLYZAYUhyLA3zQd+FZcNGz/C84Y3EO ViJ9G03ocpTXqqK1/epWVh29qqQzAaGQqH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UalHvNJ6cWzPRC0uZSRifTDxQvfeH+ccEQXhY pMaEwWYIBis1AZ/fIK+xn3bLf2rEIjm0ZZ+hd9mDfWq9Gb3Fs= X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41476537" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D4E/0ncLbEbIkLHSD2QqM3yIsfsOLhM2+qSp4qUzcDBcRSaBBN+39IkVqlCDJlHtPmReY0NKy3oJ9YK7QijKfbwp7PeilRzPoDeolol/pMS30g5SRqfNan86l1MCkSamCCFwa6dVjQf7B7lh7NDAnaA6q4/8/a+AjoayjwFgZacF68G2iwBRgbO9yJFgBGaQQf31j5H6QfcgWZwridCa8FvMFu+URaRks6S26Nocaag3MRx45Nd2uECC3qYa8UmDpCucMr3PiSXkEe6Z0GjgWKcO5X3V6DUPD3Bbs2uVP62vdm5OrXpf9l2HgaxHWY+zUL1jS6bsZqruoEA93SbdJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V/ovcTNSHVs4ALtpeQdtZQbZnv807eSa9HwEL/5Y5Kk=; b=OIk8/JXv6dyo6+B4mwtv7mTTqqw/42zqXsvv6d1gJcF2QEnddLBbJLSgAxQDfzgo99Q7r9FjRo7y+5NQOTrJBBGjx3d6+/nB5S1gf1DwW1c8EYziis9owBVzhJXZB0yumXUvEbikYbUROu+qxfPyPJusMv4pMA+y+SQQLZXH/9bSm3OMLJtIANbH/tNzx74wVKZw/b0kBfI5KWZgjG+e+mut/9Qq6kE92GeF/XgGj5eNMIBn0ZVPamgZuDqAH9j9B8pZoP2HiedjIf6JccYZpBEikWFTMlNtuHunOIJmNLcU4HtNOf+9UDgOi9jyv9sTiT+uqC5Q4teJi3ayi2BhXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V/ovcTNSHVs4ALtpeQdtZQbZnv807eSa9HwEL/5Y5Kk=; b=HVDA1IQxW6jHGPa//4AWPRGfXRH4r5Q+Z0itqPBux3aiGYGsu2+dFmf6SFP3cX+yyZkbdGC0FYqAPPlf0yMGzL8+iS1PA9VM7FAzSzHjHqYIFyGJUutIQQWv2o5lKstyK/pyTOXg9nqBOy0xQmw4j3rQHOsK0gmVoU4CnUOl+kY= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 12/21] libs/guest: allow updating a cpu policy CPUID data Date: Tue, 13 Apr 2021 16:01:30 +0200 Message-ID: <20210413140140.73690-13-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR1P264CA0027.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:2f::14) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 56670b14-1ee3-446d-7d76-08d8fe84da9f X-MS-TrafficTypeDiagnostic: DS7PR03MB5542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /A+yBMfMTlSkgIzffQiwtQ+cno9/ymEUVjzpGxbYCpXtNmZTOhSxrtWpNh2FR5rFidfeQ17WcnFvxbZth4JgRh6dEkz3XecfuJcel41s3qBmjPxy+SvXqsJx5mCvNaoUvgfhauvJ7fBxdJVWV+jfPOSYjvnKjR0j0VdIb5nj40gDE9NbS0xzxdK6yr7TFf9IooSKtZvUgb6sYgHYth6ktPVZLsXGRY5cBBjV0FFo2KIUmNPk2uCclJ2vNqu2Rk5aLpBvbh0zyDLTVjmTgmUH7GBfkA1bS6miEjDy6qiT1YbBSpWXAjLNuuK1Fru9L1BkRs4uzlON5CjMqwMWy8qdOwIA2x9zMhYQFcd+L0AiZ4VnG3r7dJa7gCRyEOpInDKWrnPj/8eVXUh+JD10eXHmecqsPo9xaoxPB+bL5H6pXEBbmUFS0xXH5MB0LMOsbysobnAWtSrUM+LIu1uqnPHeZEmbIgQnUqYXQ+X6qTR0ml8VGuPTh/w+F0vAWAMAyampHqihb5576dDOi6zy+Aeyt12aGVlRWC0YG2XLSkfkAS512hS3S66xxk2BQkEft3KUFVuLCk+8tKGhUSyjlF9fnQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(366004)(39850400004)(346002)(376002)(2906002)(6916009)(6486002)(36756003)(66946007)(54906003)(83380400001)(1076003)(6666004)(5660300002)(66476007)(316002)(66556008)(8936002)(478600001)(186003)(2616005)(16526019)(86362001)(6496006)(26005)(38100700002)(8676002)(956004)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?Y3NlNVgwRXdNNDJBQWlpWU1DSGo4Y2JCMUdZZWVDK1ZtQjQrL0lvOFdWMCtx?= =?utf-8?B?eXhkQWpXTkJac0ZSZFRsKy8zQ2FkTUxUbElnVjBzY3JXVGJwVzJLTVdadWpP?= =?utf-8?B?UmVuQkxuV3M1RTJz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= =?utf-8?B?VjUvM0NzbGxEY1RSbnRKK1VtT3FmYjFBWThEdFR3UGRLaEs3N3MwU2xzd2tq?= =?utf-8?B?UVIyNXNyaU4rcDR5L1NPSkZvbG5XK0RHSG5sMDFaa1V3clhWSGtYRG1aY1JO?= =?utf-8?B?YmRsUWNDNW9LN056SlMwOGFqQ2NobVI2TmRFSEdDVlV4a2ZvQnM1emV2TDNn?= =?utf-8?B?Titrb1Q5bGE1SmQ5VFREWGtBNDBDbllRdENLWFNKbU1oNDdzWDZYMHpRc2hz?= =?utf-8?B?NDBGVVY0MmNyVThiZnowLy9HaVlPY1dHaHdKM3cvc1NubkJxVHZBYlkzaWNR?= =?utf-8?B?UUI3Ylg4N2tJUlM4UWR5LytuMTNTQy9DNEtPem0zWEhqQm05Z2QzYWg5alVv?= =?utf-8?B?dDVtd3pGN1ExODE0cldTaUtNZlZOelpCVXlIL2pJWExadG1JVk1mNERuY2oy?= =?utf-8?B?T3pvT0d6NmZwalhLOS9ydm1NMGtxQkhuQWMxRTJjeW5BVlVybWlNWk1MNnI1?= =?utf-8?B?RTVFWVV5TTNUU2dWU0lrZU53VEtGelpDNUhXRkUzMkgvb0RhZDRzckZISTJ3?= =?utf-8?B?aFdEdXZ2K3NMb2dTbE1Vdmt2WjY0UjBpRDF2UE5DakYxU0xLdW55dEZDckpo?= =?utf-8?B?WWU2cHFibElndDIzNllQM3h6TVBmNzQ0NEVGZkh2ODBONXprczBGSFNYOTk3?= =?utf-8?B?WHBXOFh2ckVDaGZZbU9wU0hCVzcyQXZkQ3J1bHFjeThaMGxWczZMdUhBcWhv?= =?utf-8?Q?HaQBj24WK2vAG0cF3zTPbxa0O6uSXJ+AUpyvoVk?= X-MS-Exchange-CrossTenant-Network-Message-Id: 56670b14-1ee3-446d-7d76-08d8fe84da9f X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:03.1964 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1jCtZfcposT+YiT2kwGKWYqN47kFkSdwv5TqDKGHQOsL0OJsZe52Zqi+PXu3HCL4fSL0gswaG/S/fIZDW6FdYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5542 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Introduce a helper to update the CPUID policy using an array of xen_cpuid_leaf_t entries. Note the leaves present in the input xen_cpuid_leaf_t array will replace any existing leaves on the policy. No user of the interface introduced on this patch. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Don't use memcpy. - Drop logic to update the leaf manually - x86_cpuid_copy_from_buffer already does it. - Only print a failure message if err_leaf !=3D -1. --- tools/include/xenctrl.h | 3 +++ tools/libs/guest/xg_cpuid_x86.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 605c632cf30..49f919f16a7 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2613,6 +2613,9 @@ int xc_cpu_policy_get_cpuid(xc_interface *xch, const = xc_cpu_policy_t policy, xen_cpuid_leaf_t *out); int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t policy, uint32_t msr, xen_msr_entry_t *out); +int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_cpu_policy_t policy, + const xen_cpuid_leaf_t *leaves, + uint32_t nr); =20 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index a4307d50ddb..00595e14cc3 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -887,3 +887,23 @@ int xc_cpu_policy_get_msr(xc_interface *xch, const xc_= cpu_policy_t policy, *out =3D *tmp; return 0; } + +int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_cpu_policy_t policy, + const xen_cpuid_leaf_t *leaves, + uint32_t nr) +{ + unsigned int err_leaf =3D -1, err_subleaf =3D -1; + int rc =3D x86_cpuid_copy_from_buffer(&policy->cpuid, leaves, nr, + &err_leaf, &err_subleaf); + + if ( rc ) + { + if ( err_leaf !=3D -1 ) + ERROR("Failed to update CPUID (err leaf %#x, subleaf %#x) (%d = =3D %s)", + err_leaf, err_subleaf, -rc, strerror(-rc)); + errno =3D -rc; + rc =3D -1; + } + + return rc; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322612; cv=pass; d=zohomail.com; s=zohoarc; b=L71tF4tHJMWwAFVdD5NLi0VvtJ+mNgBHZoe68FS95+zPYZTHLQ83fwvagE7bsPAVv5ciMDUP/jXy0Tx/y5/EmpNmgXEh8YAKNak2kPLAAeWej2WNOkh1Yk29GVL9AKyJSBep7eDIXJGvPOAAqKbMJD/UVduBiQzxz3Rwx8w8k4k= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322612; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4zjRbsyq+DaWv6wnjrp/39MtyMLtRSSqzlhDBppNwHA=; b=KHdusDyEQ6wZ3VFcJGdaup5+qRsRGR+tUyoa8UgaN15PHrBGsj1+03u0UIjDOhOxCYbBYt+mzQ8SnppI6SRulxkZNnb8GH3frveL8+J5SAEAJMTVGSqKJsI0TktntKMRaW9abXGQ43SgIUSYfNjbvldSdIoxRVSH0ustJx4yAx4= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322612106377.4826691320759; Tue, 13 Apr 2021 07:03:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109807.209648 (Exim 4.92) (envelope-from ) id 1lWJdK-0005uF-RA; Tue, 13 Apr 2021 14:03:14 +0000 Received: by outflank-mailman (output) from mailman id 109807.209648; Tue, 13 Apr 2021 14:03:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdK-0005u2-Ma; Tue, 13 Apr 2021 14:03:14 +0000 Received: by outflank-mailman (input) for mailman id 109807; Tue, 13 Apr 2021 14:03:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdJ-0005sc-3M for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:13 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1fb40aef-70d4-467a-8144-dd57e73ae0be; Tue, 13 Apr 2021 14:03:12 +0000 (UTC) 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: 1fb40aef-70d4-467a-8144-dd57e73ae0be DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322592; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=uEN8vdruq4R26ejVTvoHnlj4zKLnkKaq8by+dBWlaWM=; b=X6QvBQVW6wgWmjPObBJpU3D3kSFDPDzGW8iarWPjLcJbbcM9c9Cvr1ZW p+Uvlr6/OobVTJLlj/oiu0X7OwDrvYmRXgNRIvBCG+F+qUCAiZXUW2FCE v+stWOC2GjGE/lGVd+Nt4SsSUsQfcsES4L59OTn+/1ZbEvyetkASSOBcI M=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: UvUOwl0n7404jnOeNInaf0XiQm+TDLJgyj1L8gyDMXm7gqmpkGJXB1DFE8eEr/Ow33Vzk131SN UEuZMtb8lMHd+2Hhy1Mhy4Q6F2ChXyZsHTq6Zy2chFtMWAWrpr5PS9IoiV+1udualNRPrfHjH4 6Z1t6052sy0bl3lRJQUoRlylWW/vQYcw33FRaiafF5x2xko1PsHBJDD30ySSVHtm/KNYNRTC9/ gUfsloqv/NLx0z0qJm1iXaAgNkuYzjg6szm2WAqwe+GZLkbm7N0iE4H8ieCJL7XvDyF6vcZAcv kqE= X-SBRS: 5.2 X-MesageID: 41613953 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:muOtX6sSYC+vRwxdcLCfb3YS7skCrIMji2hD6mlwRA09T+Wxi9 2ukPMH1RX9lTYWXzUalcqdPbSbKEmwybde544NMbC+GDT3oWfAFvAG0aLO4R3FXxf/+OlUyL t6f8FFYuHYIFBmga/BjzWQPM0nxLC8npyAocf74zNTQRpxa6dmhj0JaDqzNkFtXgFJCd4YOf OnhvZvnDardXQJYsnTPBBsM9TrnNHXiIngJScPGh9P0mKzpAm14733GQXw5GZ8bxpzx94ZkF TtokjCyYiI99q6zRLd0GG71eUtpPLRjuFtKebJpswcKjDHghulaoJ7S9S5zU0IidDq0nkGup 3hpAohItRS5hrqDx2IiCqo4SbM+nIP7GLv0lCRi3eLm72HeBsKT/BvqKgcVzmx0TtFgPhMlJ hl8kjcir9sSTTHpyj578igbWATqmOE5UAMvMRWs2ZSSuIlGdhshL1axmx5OrEaEhn37Yg2ed Med/301bJtfVSWY2uxhBgI/PWcGnA6HhKxSkMfoMCi0z9PgHBjz0cDrfZv50s9yA== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41613953" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwVANm0qhv5f/T6gaMK7OXEZyxJVMIQrbyFB3AFurCCogxs0xoGNxk65NVG5I2jDuKckeGKJYwl9rwTAN4xT0xjSrswH6ncNjWYGJ6e4bgL/0K92oNlTvxOoxWiZQCQh1+MZQ5uwhpc5gTVDzOzoDMBmp2Q9K+XjwVj8hqRAqJ+B8UkWbTm0zIQVg0kSm3WN83w63Lvqozpn8WEraruWwzJl5AYHi83wdbKE+dhdAsTlH5BHiYyAcjGBU4OYhGltaGNSed9DOIJXF95o39dQ2wLFMaDccFwOUSf6qP0RXKgEPu/K+fZPWMhxIjv1XpFE8gqLkgMKbwJyLmxV9WKOkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4zjRbsyq+DaWv6wnjrp/39MtyMLtRSSqzlhDBppNwHA=; b=dVwroCq1zzWGRtUBiZ+QSTsOACxThy4KsBpY5gobjrF5kOuf+n2c0JerA0+HwBQibTF0c3BifHaZUM2pdv8qdjIRrOVRwrVjRgvVwk0I4Ie1LGyckuE/8Dx3eMLWVG4q2QeESg/PZYHMR89hF5KUqznM8UIBRPgUJJsxbck2Y3ckjkvy2cU4NPaszXMqMqCC6k5cT0rxI1D1/rpXGs4k8nwzFt98VgYAOL6+RZE7qvhTBt/MRtN+sRRAbIxKMlVFsekx7bpY4hDHDE4ZyNEIGlH1dzTP4vP6+x8zRAkyS0EXXNu1oNRmBTs6HOUoa+5/goyvytiDWEoobMBxALWjnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4zjRbsyq+DaWv6wnjrp/39MtyMLtRSSqzlhDBppNwHA=; b=ay8pvTHaaoefeJzIGKHYTPuWm1BkIiEYI+AqI9O6zbWlhSLBwgFqwFtX6HxnSOHX/Lfh4HmAUhGxzRi9DFjb9vuhM6qiKk1H+OauL/BDmW+ehZuk8PpAi6plAH7ZOXA+cI+SqyTFvmCmSF3qZg6arQPa45X7cD6Gh6RnlWH4nuw= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 13/21] libs/guest: allow updating a cpu policy MSR data Date: Tue, 13 Apr 2021 16:01:31 +0200 Message-ID: <20210413140140.73690-14-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0157.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1::20) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c5831c7-9221-454a-6ee7-08d8fe84de13 X-MS-TrafficTypeDiagnostic: DM5PR03MB2553: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iP48MwPvjkxfeHds+UhOHvvY78axBKbnoz9h6a9+hPhXTvp+Q1JtDhCFSEbbWOwlakS6tSOTVrVxSPc07piAhAcwZobLde6d74fDc5wtrWJc8fKU3dzfFiBoAIIZe97pbDFLT9k7XcFAXGPr0PUUWBXqsCGgxkRqk2sV5uhebrYYB2C/oOPoanD2ygl8gQL+VQygC+WSOs7S27oPoN5UvJI2DtqUT9uofrTlD1lhG5EGFuffRAUpkJyKjqAEF8BYvHNWSfSwQAh2X1QPDmcgpWsuj0u0IxqawOT95tzJR28zgtzOlVsSnfhB71e5T382eRLFxUKHaq1Q9ruMPvE2ntiT8DzttY44HBYCVvTQRHdseOJEM5TGUAU+N8R1NyrzHhNj5yPABDEIBdXocjWNNQttUvZAp5BY9bPTN629mLRyrN9JB83/eA+25t2j13YRls3IcR8FzE8p+A+V/XlAmES6EN+v8mLJhQ4nCUwJQzWad0FXR8+CZZda/1sxJ7eDMFQ7XUPIsJG1X1t9yB/wcgSfKE71j6HdC10CgSeR/Ifn36SaoSThXz5o8Hx7aH+5VLUwWiJL2BnVfifw/PzEGA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(396003)(346002)(39850400004)(8936002)(6496006)(186003)(83380400001)(38100700002)(2906002)(66476007)(86362001)(956004)(2616005)(8676002)(478600001)(66556008)(66946007)(6666004)(6486002)(16526019)(316002)(6916009)(36756003)(54906003)(1076003)(5660300002)(4326008)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?ZzZ1amJLNm5WOXNtTWEwS1RlYVB2c3ZnVjE1TEFERnRZMVJFZlZtS3I0Z2Rh?= =?utf-8?B?YzYwbG1oMEM4WTAvQktZN0wvQm0xMGZNSE4wckk5aHJ0MlI3bHk1dk5lSDBR?= =?utf-8?B?VC9WWTNtem9QR3pQYk43U2EzUHd2b3QvOUgvYjU3dDl2M1ZGdXpiZFA4MVg5?= =?utf-8?B?M0lFeXdFREtxa2J4N1VDVHA1dXpFY0F1aG9ZdnBaNW02bzNVc2xrQVhhcUxu?= =?utf-8?B?azROcUhzdTd0Z3NLVjVBcU9VUVFkUG5xcjlQWEFRbEUyMUMydkQ5Snp2bXBQ?= =?utf-8?B?T0JaMEc4UzFWeERRWkFDRk1HK0ZKckFYbWhvOXYzaFJhMm8xd00wTThrNnFr?= =?utf-8?B?Q1hiUUtmWi9yOHY5M0hZaTJWZmM3TWJHK281d3dNUnVyL2Z0ZjJURHNQU29U?= =?utf-8?B?R3ZOMkQ1WnhpWXJlTWZ0RThkOWtRTEE0eWV6SnRLRnk2Ry8yQXBDWHRyaDdD?= =?utf-8?B?UHh0bFdUbmZldnBLcFg0K1JMUEV5SGczWU9WMytaR1crQ2ZXOWhpQ0F0dnZX?= =?utf-8?B?Vi9mdmF5OWI4dkJielczWGZvRDd1N0FmbG1id2p2TG94TWhhYmc0MEx5ZWgy?= =?utf-8?B?NVlKelFCcjR5b2RVSlpCZFIwYzU5dm5pcUxaWU9CN1NWU0RjV3ZJd0g2cFBa?= =?utf-8?B?eXN6RitPcHNQVFhaM1hQVG03L3QvV083SHRNYmd5U2lHdm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CtjbzhsTVU4NkxpTzZXZVUwT0kv?= =?utf-8?B?ckpqZzd4bWQxZlEwOVZEcVdXTHhhS0t4TS96Uk5aSTRQQ2d3M2tyd2diY21U?= =?utf-8?B?WVg0MlhaOU1ieGZrZE1NelR6OU5GQytMVWkzcFdUMmEyOU9XT3I2a3JUbFFL?= =?utf-8?Q?aAC6uRzvg2AwpXR1XAMD1CDSZkjQuYZPk3OyiUD?= X-MS-Exchange-CrossTenant-Network-Message-Id: 7c5831c7-9221-454a-6ee7-08d8fe84de13 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:09.1632 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pcWNFVqJ3mA7hl6vYTgE/RKSAyjN7eXZUXHdVq/x2mkJxmbhNov/vu/6x29R2IEGf2GCP7lcZgd5c/gtBY0QLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2553 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Introduce a helper to update the MSR policy using an array of xen_msr_entry_t entries. Note the MSRs present in the input xen_msr_entry_t array will replace any existing entries on the policy. No user of the interface introduced on this patch. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Drop logic to update entries manually. - Only print failure message if err_msr !=3D -1. --- tools/include/xenctrl.h | 2 ++ tools/libs/guest/xg_cpuid_x86.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 49f919f16a7..9a6d1b126d8 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2616,6 +2616,8 @@ int xc_cpu_policy_get_msr(xc_interface *xch, const 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); =20 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 00595e14cc3..26b09322dfa 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -907,3 +907,21 @@ int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_c= pu_policy_t policy, =20 return rc; } + +int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t policy, + const xen_msr_entry_t *msrs, uint32_t nr) +{ + unsigned int err_msr =3D -1; + int rc =3D x86_msr_copy_from_buffer(&policy->msr, msrs, nr, &err_msr); + + if ( rc ) + { + if ( err_msr !=3D -1 ) + ERROR("Failed to deserialise MSRS (err index %#x) (%d =3D %s)", + err_msr, -rc, strerror(-rc)); + errno =3D -rc; + rc =3D -1; + } + + return rc; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322618; cv=pass; d=zohomail.com; s=zohoarc; b=IlELxbzBCYCKpHFDxzvXRWTEbklRmru/i56zlXZlxjrfee5+IMT3VjA3bh6Qaci+BxGNDvQepAR+DFLlVjcAp0jkbBLBsfp7lvWdPkCDG2OIkkUf/iNZy7RXNsHmkC55NbTsBvH6DcU6Lqj0dJzWq8nWUAA/x1yS/ew87OadPSA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322618; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qDZhAJDB/rsUQo+Z4e8pQdhxsoyKmVpWA1PSI58wKuU=; b=YY9RJs8Ab9tb6rDpZjO9lpwfRfavbnvgqUYrXocsF4YrVcxMaNo8mU09b7URbXmQKq3R07eJs7HG7Mxx/JoUmZ+Qo0K+X6fd19ENqEjXkFFzE64nK2x27T4tI8f5EpGEiyFy7Oq2QX3cFhdAEzwxkykGLG013nJe4ylv1kMXcPA= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322618404443.1891940535771; Tue, 13 Apr 2021 07:03:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109813.209661 (Exim 4.92) (envelope-from ) id 1lWJdT-00063X-DX; Tue, 13 Apr 2021 14:03:23 +0000 Received: by outflank-mailman (output) from mailman id 109813.209661; Tue, 13 Apr 2021 14:03:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdT-00063O-91; Tue, 13 Apr 2021 14:03:23 +0000 Received: by outflank-mailman (input) for mailman id 109813; Tue, 13 Apr 2021 14:03:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdS-0005sc-8T for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:22 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 51725715-d4ea-43f4-8528-1a696ba6d6ea; Tue, 13 Apr 2021 14:03:18 +0000 (UTC) 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: 51725715-d4ea-43f4-8528-1a696ba6d6ea DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322597; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=XX1SugVBrNifC3XmPT1UGL6ovBU2ay/gnB824DeP1Ik=; b=Cc39JWoKjqLiS8RspJv8a4hSpqHiTdGaoxgC9B3Do/IKBfPwydKX8hj3 QmRZcxy31VqLsv1tNL77eiF2t12i/DavLPIkq8W8d9sU6zLqo+yc1542w Z7W5AxKSNBMFGx2tPeYqP8B6ieYi7YI2Q+2dgTo5K5VWmq85X8n+eLWYi w=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 3nWJMVmsW6HjXl3TYRVxnjG9n3P6b5QN3X9n711F0k7EzNNIPs08FxI4yGd+Vq4ZEdd9tEYyS9 tx7/zvVk8ozmKcYOx1Bo2K4mTquEYaIhq/lKcH1rqdDuRZzzr5FlVozYvOT95t8tFyQ9R05hwM SdD0Tu5oRSMePyhFjsUAnR4QX9mSQIdXwzl0Wveo8nc8RyrY5cStaEFioHL54nd4BE4DhduNnD gsdY420euYuCh8652VYSRShBm6eBkURjJScd/RfYAXUZLmGEiTEUOFgNnjI3gDgSauuMF/AS1R r8U= X-SBRS: 5.2 X-MesageID: 41476562 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:3XEvuqnR0tnhCZODHbm0AmYu1cbpDfOpj2dD5ilNYBxZY6Wkvu iUtrAyyQL0hDENWHsphNCHP+26TWnB8INuiLN/AZ6LZyOjnGezNolt4c/ZwzPmEzDj7eI178 tdWoBEIpnLAVB+5PyW3CCRD8sgzN6b8KqhmOfZyDNXQRt3brx7hj0ZNi+wOCRNNW17LLA+E4 eR4dcCmiGpfm4ZYt/+Kn4OWeXCoNOjruObXTctARk75A6SyQ658bKSKWnk4j4ycRNqhY0j/2 /MjhDj6syY3c2T5xfA2wbonvJrsfT7zN8rPr3vtuE0LXHWhh+sdMBdXdS5zUsIicWOzHpvr9 XWuRcnOK1ImgPsV0W4uwHk1QWl8BtG0Q6a9XaijXHuodP0SVsBYqIr7+IpEWqq12MasN5xy6 5N1W6C3qAndy/opyjh+8POEyhji0vcmwtSrccok3ddXYECAYUhyrA3wUU9KuZkIAvKrKojEO VoEfjG4udXfV6wfxnizxdS6e3pcXIpEhicRE8e/uSTzjhNhXh8i3AV3coFgx47hd4AYqgBw9 6BHrVjlblIQMNTRaVhBN0ZSc/yLmDWWxrDPE+bPFyPLtBJB1v977rMpJkl7uCjf5IFiLEono 7abV9evWkuP2rzFMynxvRwg1DwaVT4eQ6o5tBV5pB/tLG5bqHsKze/RFcnlNbli+kDA/fcR+ 24NPttcr7eBFqrPbwM8xz1WpFUJ3VbetYSoMwHV1WHpd+OBZbtssDdbfbPNJvgGTspQQrEcz k+dQm2AP8FwlGgW3f+jhSUcWjqYFbD8ZV5F7Wf3+V78vlJCqR89iwuzXip7MCCLjNP9oYsel FlHb/hmqSn4U2//WPC6XRVKgNQZ3wlpInIYjdvn0snIkn0ebEMt5G0YmZJxkaKIRd5UofwHB NAoU90vYa6NYaZyyxnK9/PCBPVs1Ij4FaxC7sMkKyK4snoPrkiCIw9ZaB3HQLXUzpvmQhrr2 9HQBQeRlDWEw7vjanNtu1WOMjvM/1HxCu7K89drnzS8W+Go9s0e3cdVzmyFfKMjR0WXDpSjF 1p+6o5iL6N8AzfblcXsaAdChlheW6XCLVJAECgaJ9Pkr7mQg12UFyHnCeXkR01Z2rs+XgDn2 CJF1zmRdj7Rn5m/lxI2Kfj9115Ml+QeE99cVhWm4xwH2augAc57ca7Io6Il0eBYFoLxe8QdA zfaTwJOwV02pSczxiOgguPEn0g27QjNuHQF64YbrnWw3+hQbf4050uLrtxxtJIJdruuugEXa ajYAeTNir/EP5s9AqPpHopURME3kUMoLfN4lnC42e51nJkXqaXD1RiWr0BI9aTq0LjXO2F1Z 1ljdQz+cu8W1+BHuKu+OXyVXpkLBiWnEudC8cPgrpQtbgptLRyE4LAOAG4nE1v7VEbFoPMiE gaQK5H+7jPNY9kQtwKd0tijy8UveXKCHFujxf/DeA/d2w8lnP3P9uG5LzTtLoka3fx0zfYCB 26+y1Z8+ytZVr66ZcqT4YxK39Rck4y9TBL+/6DbZTZDGyRBqt+1Wv/Fn+2a7lGTqeZXZ0Wsx Zh+tmN28uabTDx1gyVnTx1JMt1giuaaPL3JAKHAuhT9dOmfXyKn6ux+ca2yA7NdgHTUTVQua R1MWoKbspCjTE+jIo4lgiKI5aH3X4Noh95+jFollnkx468xnzUdHs2aDHkvg== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41476562" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PP3ZwZ0VgTXT92mijYjp5LG19kcwVniCezFwajGVbGphd3PlLSP4v3MuRfIFaV8ySYIyYQxldv5U3iV9eU3rhJcLGFCgls4s4GcYN2EUp54/F6Qa4zqIRh1JXppB/cLGOY0P5kVNrzubtrQ2uvk8vBH1YSvm5H/F/DobhDbtnOE1ob+X3vz1RsfmSn0EUvhR9g3ncseqQgBpzAz7S6Vwh8R00+kj0v/VSPYIYpEuflnf0j9J9IehHiQeKGeRfsLifNPtyEBa1beX9GCnO7ptchp2w+XJHoykaOOTIBGWMpLTJUgumHpK9Y6up54RSTCEwLZKR2MStrjPuBaQfNdSpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qDZhAJDB/rsUQo+Z4e8pQdhxsoyKmVpWA1PSI58wKuU=; b=h19POVAQunWfkCqXZGZn3OCtC00PQCc1Em8SuDn2A4Xia5cNNovmHEY9oebZFPEHTqBXyHewwOEeLeZNlAUALfgQBmJ45Mw/HtZCPeeOfgA1dvuquBgMZfagNpp2jTBUVbcr78l/8NNxV0/OiHoh/g4w+B8kBF4g5TdVKxMSkyJRfo2Mp/VtlmTh1/eKdIZm8VwXsjJrYnyuXcHh+sTwzGJRhsRDHDAMqp+9ZC+kHNfSTG2ycg+xLtJtMCq8+mtYpI0IAQKdjhs1wK4nk5XExJeYduuJOAHkGW8HJrGtWgP44R58G3kVun6++bZs4pPx/iNf86+JkyoSga4tvXk5Jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qDZhAJDB/rsUQo+Z4e8pQdhxsoyKmVpWA1PSI58wKuU=; b=cFxUb1fIRubkaC1putWAOfaK/NMLjcrZg3d5UyZ0wcVTgE+Sk7cUjf2xSOFmimilNkJAeOO9IeqAqbbq4KdDYtT/2IMN7bxUdzDdUq8KTG6SKOCA+wOa9pWI8W9peOSbB5h167Hs/H1rjlzQjjshwpe3o9W8+Xp0GeoavMlFHQ8= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 14/21] libs/guest: introduce helper to check cpu policy compatibility Date: Tue, 13 Apr 2021 16:01:32 +0200 Message-ID: <20210413140140.73690-15-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR1P264CA0022.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:2f::9) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: efdc4159-a63a-4dcf-9dda-08d8fe84e186 X-MS-TrafficTypeDiagnostic: DM5PR03MB2553: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a2oAP/yFTX6/8n6x/Hh76oJ9N2vaZXSPu44dvv1a+w8su5/0bzthNQFWZZkSLzQAXlHDDY/v2QPrB/eXP9uRaHROKHaFpQR7HDTLKx3lKAlPDIyk0xls8jmXa7I3hyXD5vhykpl/hjfbSeoGMLqlfinQC1XfIEsbhtiyi8FEGUq9NGyYq6X8oFUALNpOwC1VmZFtWO/f8x6EjxEoqoPBT2l2TcTk37kscKcf65b5rwamIjEZ55jhaXowySkvuBkvqgZTOkL04jrSNjMvGVBhG1p2ddMZVbZM6GmWt067TqcXiK3O9gQGED0Vypa35hd79bcRn4+vE5l5Fo1ayQFu/fT/hnSKUcEOGJkANifB5cBMCcVcJMywv4pELPcHgo9YETOIEAbuw2ADLL2zp7vWiMIXcjXj6Lc9EYO5Qu+RYensgsJBJJbaG3TcUnvY3jPpn8XDKe50WS+Fdl8aMv8+n4+Tia992VqkIb4/iei6Dtelo0V2iaImx2aX9fNoUJsPMuma9nRTCQPpZGXapKszCBuI6ZGIdmAGABA0InkYx/R2m/2UggD+mfCJfwtoIMgWe2dHBjgVMV41qa+P2z8LzgvDkZfIUG8o7TVwZbJXAKI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(396003)(346002)(39850400004)(8936002)(6496006)(186003)(83380400001)(38100700002)(2906002)(66476007)(86362001)(956004)(2616005)(8676002)(478600001)(66556008)(66946007)(6666004)(6486002)(16526019)(316002)(6916009)(36756003)(54906003)(1076003)(5660300002)(4326008)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?dmRpWHNJdGR2VEZ0dXdLbWRRdGIwUWZVQ0paWlViY3Y1ZTFOZGxQWVNlM0R0?= =?utf-8?B?UWRzYmU1R0dSdGNVV2w1UDVPeWNoZjdVazByS21MUkIwSU0yVVVkYTdkSHMy?= =?utf-8?B?WmhNWnh6OENxZ1pIUnV2ZUJRM2xIVTU1Q1RCcFZVTWNJR0FHQmNnWFdBc1Fj?= =?utf-8?B?UWFxZnZoL1A2T1l6WWI0d0lvTjVWUkhwZ2ZrWEdvUzQxMldHTWpFZHdHUSts?= =?utf-8?B?eml5V0Ura2pkWkFQUTJIRGtPYzlON1NBbXpGNFBPVlZyWlJ0azBxQk1QRkdt?= =?utf-8?B?K25YcWQrb2pnTFpKVFVPOXg5Rkg2bVc2QVVFVUFmWjVwMmhwZU9SZk51OFA5?= =?utf-8?B?UGdueHJiZjdQTmpMUWIzdElBajdiSldXb2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VrazRGRkI5azRrdzQyUHNZZ0d3NnY1b09Raldybm9FVUFN?= =?utf-8?B?dWZzaXdHaTdUVjFvNEFkZk51WUY2N1hlVjM4YytsYnRHeFBTandnNWF2cFor?= =?utf-8?B?OC9KSzByZ1IzZHh1ME1uc3ROQ1ZwSStVQXVuQndXL3Z3NmhWWlJYMXhCdVM2?= =?utf-8?B?blAyMWNuODVlWlVUOXZnaGI1SWUyWElzc0p5a0x1UDdUblFZaGtKZ1FtRWZJ?= =?utf-8?B?WEtYRTBFSjg5bUJMUWVNVE9xZUw5WXdOYzVtRUVjekRXYXg0Wnh5UXNTY29W?= =?utf-8?B?M2VqZU1leWpEMDk3bjlpWDhRTGYyL1pjWEVOcTliNUlGanUyZU9GclRhdUFN?= =?utf-8?B?eTQ3eFRPMEpZSDV5NjVnL3cxTHJXMnBvSDl3ZVZsdndXVlFrb0lVTTZQejIy?= =?utf-8?B?WFBUcHJtYktSMDJEY0FNRmM5eEVDUnQ4Q3F3MW5UdGVSNGRqT2l2eENTZXVL?= =?utf-8?Q?bP6KInMj/McpyWCo6huqyllhxu1rNm0+oljgXCg?= X-MS-Exchange-CrossTenant-Network-Message-Id: efdc4159-a63a-4dcf-9dda-08d8fe84e186 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:14.7785 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7hIOav2WbjNwSbrWFaROLkZYL4jnSDbZCBwqwAACZYCosVX65fF9DEWOdExlwvzzGtOYZ6MJPGK+1zWGwZmYbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2553 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Such helpers is just a wrapper to the existing x86_cpu_policies_are_compatible function. This requires building policy.c from libx86 on user land also. No user of the interface introduced. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Initialize err. - Explicitly name parameters as host and guest. --- tools/include/xenctrl.h | 4 ++++ tools/libs/guest/Makefile | 2 +- tools/libs/guest/xg_cpuid_x86.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 9a6d1b126d8..5f699c09509 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2619,6 +2619,10 @@ int xc_cpu_policy_update_cpuid(xc_interface *xch, xc= _cpu_policy_t policy, int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t policy, const xen_msr_entry_t *msrs, uint32_t nr); =20 +/* Compatibility calculations. */ +bool xc_cpu_policy_is_compatible(xc_interface *xch, const xc_cpu_policy_t = host, + const xc_cpu_policy_t guest); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/Makefile b/tools/libs/guest/Makefile index 604e1695d6a..6d2a1d5bbc0 100644 --- a/tools/libs/guest/Makefile +++ b/tools/libs/guest/Makefile @@ -40,7 +40,7 @@ $(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS +=3D -Wno-po= inter-sign ifeq ($(CONFIG_X86),y) # Add libx86 to the build vpath %.c ../../../xen/lib/x86 =20 -SRCS-y +=3D cpuid.c msr.c +SRCS-y +=3D cpuid.c msr.c policy.c endif =20 # new domain builder diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 26b09322dfa..bd2f31dd87f 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -925,3 +925,22 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cp= u_policy_t policy, =20 return rc; } + +bool xc_cpu_policy_is_compatible(xc_interface *xch, const xc_cpu_policy_t = host, + const xc_cpu_policy_t guest) +{ + struct cpu_policy_errors err =3D INIT_CPU_POLICY_ERRORS; + struct cpu_policy h =3D { &host->cpuid, &host->msr }; + struct cpu_policy g =3D { &guest->cpuid, &guest->msr }; + int rc =3D x86_cpu_policies_are_compatible(&h, &g, &err); + + if ( !rc ) + return true; + + if ( err.leaf !=3D -1 ) + ERROR("Leaf %#x subleaf %#x is not compatible", err.leaf, err.subl= eaf); + if ( err.msr !=3D -1 ) + ERROR("MSR index %#x is not compatible", err.msr); + + return false; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322623; cv=pass; d=zohomail.com; s=zohoarc; b=VawO8mg0mV4tezxVXRJTG8EvblINgi42DLeUUaUwjrpbiZmJpSkwC/7P5WNrLscBEvr8ECn5JjGqkf5akumahr/SiZbGLHn+ZzS3pw8O0o7lrg+ozvOpv/f4tL/dIXyXFFaaJauWRtEhxj0Us0nfvORpRZSjeXysdm2pvTF/O88= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322623; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Dc+lsGkoLxXeZ9V8GLxDMIl6AZXl0djGMA3EPzv8W5U=; b=Rg6lhCYgvr4Im0JWXATZvFgq2QqBo+9vS9biFzqmjgFjw10bcVtMcORANmnIh4BZZD6mpUFedcTwBGXyJSMzS0w2H6WAT2/1LQnUoyNfIa5XoxXG4B+tHtdec0TrLkD6aDs0a24AxsKiol4ZdQD9UenARhE88I0gtYhXIO81Ceo= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322623524475.8051656771247; Tue, 13 Apr 2021 07:03:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109815.209672 (Exim 4.92) (envelope-from ) id 1lWJdW-000682-PQ; Tue, 13 Apr 2021 14:03:26 +0000 Received: by outflank-mailman (output) from mailman id 109815.209672; Tue, 13 Apr 2021 14:03:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdW-00067r-Ko; Tue, 13 Apr 2021 14:03:26 +0000 Received: by outflank-mailman (input) for mailman id 109815; Tue, 13 Apr 2021 14:03:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdU-00061C-ON for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:24 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 345d3bb5-816f-421f-9baf-99c1469d0a13; Tue, 13 Apr 2021 14:03:22 +0000 (UTC) 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: 345d3bb5-816f-421f-9baf-99c1469d0a13 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322602; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=P7vZegBKQVl+IyYesoWXa6XMSoDS3GTeMrPPYL+vXSg=; b=NYTw2J3LXRIZgUv/X+cBV//HyHSuuqZxjKm+WumfmB2GeGypxKT711j0 AKzGYzqh7GVpXFT3MCzkXLVvi9DAq1yeXkKj8PvSvdaXoP03F6KSh0ZWu ZSzILfMEYhr7WWicmcRpTcxvH/VlpBAjcXjsL6tbQu/uUggvgJq1vwgG+ I=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: ReybT6KogXa0ELTILVm6G9a/Bu3uI0d3wWk4nXoA8A2cATtw0F9x3mOa/1VsVKZhl/gBI73nty 8HoGnVC/MZDz5vZ4IiviSZ87My8OcMveOk7G217r/9ToWVkjRYKnN9K6DIfpFYD/j1gNVPHe9Z 8jgH7gx6op+vAQ+vwf30NXc9+pq4IHAzNB74PUoH2atceXRWpCEh9Zk6qt4ulssXyk+j503UjK kJgixf5l3Jc8l1kI+b1JaAdA5T/R99l+5lHlZmKc9QMqWgMF8FKN+irXTQN6dw1iOtHxPcc4me oCw= X-SBRS: 5.2 X-MesageID: 41613969 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:mdrh16o70XB3PVlHx5JIu4AaV5uuKtV00zAX/kB9WHVpW+SivY SHgOkb2RjoiDwYRXEnnpS6NLOdRG7HnKQb3aA4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cWiQZGpcQHF3u48VLxWMhl9DlcuwIoaj2WqYbVUPhtwHOD beeD0IP0dF3NasziOYnz6ECFQrzpgjJfbmEbwmar3fs0ndbrGgpOUjJbt57ZxlPNfhvqs3Su qZYRaSNy69JOUz2QCZz0xVThVcmT0Bq7fP1xLk5mTjgyJ6LvrWPVh8R7YUZ/ub9HPpQv6U0J N/yfI51NHARlnZW5qj8+XwaTUGFzb45UiRZMssoYpPva0zuKBodqOrGQfg5TVi5lEGMMzwlE kiW6x177DKB593c6UpCldk12tssO7KEVAivQP3CNIvZF0Bj3fUONWS/rrDwIBfdXGplU/VMV mb/zY1xYa8YwKzkZobAbk3O2JYdQwV72lj5vqLc+TreU+XXtAG2FqxKXmmdrBBDICDBLULtx 5/p/WFhfWeeSa9+Afeu1JAU+9z2lfiZcO5GwSXH+FUt/S8JFSXm6OvpPeJsw2fc0rzV20owa tfdUIRacxfij4tyK0PuxLCNZDfkwYCiFtR4TZui1j3/JOpiV2rRH17DQ== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41613969" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eo2nELJLnbLtqD6I6ancgn3nd7+YlTZZVTaddpd9oxnERrmbPHy0ExxA/HImm8Csz3rwtzzi2lHHHDzHVn6MB+JdDOqylm5ioR/7J4O8++Lb6CiKgzG4mwyZmoM2Ou+mC+ga1VY5EgQYHHT/YiuZp0xgWWdQH5b/VgAroQErdN9maZ1XIs4WYKKVDpCYQSd9TLv3I0w46hh+h/0lFwEu6I+ZccWrpoNTHd3HGbopdoPEkv/3bnuKcKVcuJjWpQGbwMmseqSicMFQm/bFA6OKe3wIXtDKc/0c64uIfN2X17eRtMAfXruAvzrHWQBA8fyarOb5B6L3VCJYvdS6HnODeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dc+lsGkoLxXeZ9V8GLxDMIl6AZXl0djGMA3EPzv8W5U=; b=aXrjwAYxCXP8eATPEZNKVBZykfxtVTaeZW9mbzlElmpoX8YKrQKILNF6d00/nepdgSCoE4Beye1kmn0IxGMDPSrpvZWEOXgsi3JgAJkV9xRi++c1Py63/R5w83d9gWYSCzBRglvEQld+GHBtR+cZ0sBwnNPahge0XV3gwbDBfO6sTiHlyM6ssrULKhHq6+JaCM1tF424QQ4N6iZpinQ0F/UXaY9tzinC+61O8QfDe3hDN6h5pTPacFFl2/FSs3spP5FSMHpDpKk2RqmRHT4ReV43lCR8GEgxwPq3Q9uX4mR1AXFCakQu3pLpmCZhDiS/2c7mC4C1MwRlt/QrYK0NGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dc+lsGkoLxXeZ9V8GLxDMIl6AZXl0djGMA3EPzv8W5U=; b=VB/wgPdfL35wxlNKEjcNSClsN1dgRQbUZRyt/tvktA/sEeFL0PPf4TS7INl6N/NWCCyslkC9Ur0FbebfStqn8kgGm8vCpF303O3PPARg1PmRqSOesB+Wsu5TTrdgQcex0DzCmh0hVZXHQFEL/vBjqsiF9biR4Kw+NFQ6Zxc5gE8= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v2 15/21] libs/guest: obtain a compatible cpu policy from two input ones Date: Tue, 13 Apr 2021 16:01:33 +0200 Message-ID: <20210413140140.73690-16-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0093.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::33) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 958eb659-fce2-4b33-c0b1-08d8fe84e4b4 X-MS-TrafficTypeDiagnostic: DM5PR03MB2553: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m+h8U+VU8zche7Jo+QHnYzhr1DKC3fH17YRgR/a2cnbWyucCKyYA9V3eQP/cZ8Xe+arhUU8Nvkl5EpD0DHDBjMy24gVRMiYQItntB8lThU5AvkBZME5l7APPjbcevpgZIkGsB/NsLbH4E60Xf1sGLC6e0K/82fuvrMUyWoGJMSZ1rAgA9AE1mjv3hGoCng3uI6k/JNOO+FNIbWdhHMgWbMPLapwL4YZ4GM5e1aRaZac00mN7J9OJ7lRBi0v4b2dvEUYr7wTrGicS763/EyKr7dHrdetlNy/EUEuRnInDgx1uirqzmF+wlK4+34RSWPQm5bLg3Sys+bt7TDF7ApTgkWmwKoCoWMQsgU4NU3QxT6mdxQjrd49gWBaA3kuzeWLx/XEVC+ust/4/tgxalIDMDR0bwoU9MvT6eqvY9pwmBqV5VLMQceXBrmETufNBZViEs/S05s29eF7HPxSQc1xyuUmvrCS/+SQ+czoPhPV10XzA4QfxW4qlTIGHeCi0TL93XJ5LPiWUntxOyVFoK4G667F7tf3tSBHqNYOt12kzkj4/bp9HHJ1QFkG4CF4iFfXPBULYBVHPM9ufhZu6MlFTNjlYLVgWHObKbLwQIMRV03A= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(136003)(396003)(346002)(39850400004)(8936002)(6496006)(186003)(83380400001)(107886003)(38100700002)(2906002)(66476007)(86362001)(956004)(2616005)(8676002)(478600001)(66556008)(66946007)(6666004)(6486002)(16526019)(316002)(6916009)(36756003)(54906003)(1076003)(5660300002)(4326008)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?SWkyV200ajQ3Z3BYS0RESWFWbGYzeUpUc0VwZFhOQnR0TWcwajN2RjNmQ3NI?= =?utf-8?B?YTJzM0ZnV3BXZ3ZUZXhMZGtlTzcrOWozQmxWSC95T2FvRHdESVVTaVA4bXg2?= =?utf-8?B?QkM2UldhODMwUytDbE5ob2RnRU4yZ1JJbUx2RldKVzhTOG45eGNwcmFpQ1RV?= =?utf-8?B?QXFrT2xTREp2bElNblpUeWV5V3JXVEduVk9neHhaYjMvVWhOS1E4UGVWc1Zo?= =?utf-8?B?MWpKU2QybFVzVWpHWVEvWXBvaTV6ZWlvWUNWRjhyc3FscHY5OUVRTFB6bkRI?= =?utf-8?B?OEluOW5iWmpLT0lpKzJZV25wQ1hTcHNBNWp1c3QwR2JjNjYzRzBUcWI4anNR?= =?utf-8?B?Z3E2a3VkOFhpMGJnRlhOV3ZwZ2VQNHpJM1BTa0ZrUTU0c3lHQW1GT1JabStw?= =?utf-8?B?Syt1OEdpemFkYnFMdUdBUThleksyTFp0WWFzQ3NJMjNqbWVla3gxMytEL2w5?= =?utf-8?B?U1U3ZEU5ZXF3WTJuR0lPU01HazVsTXl6RzNBQkxzRnNzYWpwcHlOOVR1SnNT?= =?utf-8?B?NGVQUmF4SGE5djl6a1hPY0hqdDVqYnNwdDdxOHlYQXZlbk10L0p3endGZGhD?= =?utf-8?B?NDFPS2dVZ1BGQTRnTkVKRUV4WVMvUU5RMDFPeUI4VGVLZTZ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3OWM2eXV2UHZqNjNwZHBzQytnUW93QW96M1BmSm1m?= =?utf-8?B?QmN4MGZQQlpvRHREbFllbVJ2ZjFSRytzTEQyY3RFYk1vSlNzR0c3OXdmTEVQ?= =?utf-8?B?VlNIMm5zRUFzRlJkdzVUS2dpaUgyVyszYTFmWVVPb09GK0M5V2VpVDBMaVlp?= =?utf-8?B?TFp5NFdvOFNpMDVNVUVodUZ0M01FYi8zRWxwYnlRMmZralAyMVRBUE4wVmFh?= =?utf-8?Q?L8/XkFzxGzS0YAsUtiARm8oL/WAtasqor+yCJLw?= X-MS-Exchange-CrossTenant-Network-Message-Id: 958eb659-fce2-4b33-c0b1-08d8fe84e4b4 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:20.0448 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r03MpPPP20qqMRWRm0h/hzzMKozKy009boBr8Z4xv4OLfHsYAI/INAM4ItL2CsXTnvJwIcPsHrT4W/9qDTCbxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2553 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Introduce a helper to obtain a compatible cpu policy based on two input cpu policies. Currently this is done by and'ing all CPUID leaves and MSR entries, except for MSR_ARCH_CAPABILITIES which has the RSBA bit or'ed. The _AC macro is pulled from libxl_internal.h into xen-tools/libs.h since it's required in order to use the msr-index.h header. Note there's no need to place this helper in libx86, since the calculation of a compatible policy shouldn't be done from the hypervisor. No callers of the interface introduced. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Only AND the feature parts of cpuid. - Use a binary search to find the matching leaves and msr entries. - Remove default case from MSR level function. --- tools/include/xen-tools/libs.h | 5 ++ tools/include/xenctrl.h | 4 + tools/libs/guest/xg_cpuid_x86.c | 128 ++++++++++++++++++++++++++++++ tools/libs/light/libxl_internal.h | 2 - 4 files changed, 137 insertions(+), 2 deletions(-) diff --git a/tools/include/xen-tools/libs.h b/tools/include/xen-tools/libs.h index a16e0c38070..b9e89f9a711 100644 --- a/tools/include/xen-tools/libs.h +++ b/tools/include/xen-tools/libs.h @@ -63,4 +63,9 @@ #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w)= )-1)) #endif =20 +#ifndef _AC +#define __AC(X,Y) (X##Y) +#define _AC(X,Y) __AC(X,Y) +#endif + #endif /* __XEN_TOOLS_LIBS__ */ diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 5f699c09509..c41d794683c 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2622,6 +2622,10 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, xc_= cpu_policy_t policy, /* Compatibility calculations. */ bool xc_cpu_policy_is_compatible(xc_interface *xch, const xc_cpu_policy_t = host, const xc_cpu_policy_t guest); +int xc_cpu_policy_calc_compatible(xc_interface *xch, + const xc_cpu_policy_t p1, + const xc_cpu_policy_t p2, + xc_cpu_policy_t out); =20 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index bd2f31dd87f..6cfa4cb39d1 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -32,6 +32,7 @@ enum { #include }; =20 +#include #include =20 #include @@ -944,3 +945,130 @@ bool xc_cpu_policy_is_compatible(xc_interface *xch, c= onst xc_cpu_policy_t host, =20 return false; } + +static uint64_t level_msr(unsigned int index, uint64_t val1, uint64_t val2) +{ + uint64_t val =3D val1 & val2;; + + switch ( index ) + { + case MSR_ARCH_CAPABILITIES: + /* + * Set RSBA if present on any of the input values to notice the gu= est + * might run on vulnerable hardware at some point. + */ + val |=3D (val1 | val2) & ARCH_CAPS_RSBA; + break; + } + + return val; +} + +static bool level_leaf(xen_cpuid_leaf_t *l1, xen_cpuid_leaf_t *l2, + xen_cpuid_leaf_t *out) +{ + *out =3D (xen_cpuid_leaf_t){ }; + + switch ( l1->leaf ) + { + case 0x1: + case 0x80000001: + out->c =3D l1->c & l2->c; + out->d =3D l1->d & l2->d; + return true; + + case 0xd: + if ( l1->subleaf !=3D 1 ) + break; + out->a =3D l1->a & l2->a; + return true; + + case 0x7: + switch ( l1->subleaf ) + { + case 0: + out->b =3D l1->b & l2->b; + out->c =3D l1->c & l2->c; + out->d =3D l1->d & l2->d; + return true; + + case 1: + out->a =3D l1->a & l2->a; + return true; + } + break; + + case 0x80000007: + out->d =3D l1->d & l2->d; + return true; + + case 0x80000008: + out->b =3D l1->b & l2->b; + return true; + } + + return false; +} + +int xc_cpu_policy_calc_compatible(xc_interface *xch, + const xc_cpu_policy_t p1, + const xc_cpu_policy_t p2, + xc_cpu_policy_t out) +{ + unsigned int nr_leaves, nr_msrs, i, index; + unsigned int p1_nr_leaves, p2_nr_leaves; + unsigned int p1_nr_entries, p2_nr_entries; + int rc; + + p1_nr_leaves =3D p2_nr_leaves =3D ARRAY_SIZE(p1->leaves); + p1_nr_entries =3D p2_nr_entries =3D ARRAY_SIZE(p1->entries); + + rc =3D xc_cpu_policy_serialise(xch, p1, p1->leaves, &p1_nr_leaves, + p1->entries, &p1_nr_entries); + if ( rc ) + return rc; + rc =3D xc_cpu_policy_serialise(xch, p2, p2->leaves, &p2_nr_leaves, + p2->entries, &p2_nr_entries); + if ( rc ) + return rc; + + index =3D 0; + for ( i =3D 0; i < p1_nr_leaves; i++ ) + { + xen_cpuid_leaf_t *l1 =3D &p1->leaves[i]; + xen_cpuid_leaf_t *l2 =3D find_leaf(p2->leaves, p2_nr_leaves, + l1->leaf, l1->subleaf); + + if ( l2 && level_leaf(&out->leaves[index], l1, l2) ) + { + out->leaves[index].leaf =3D l1->leaf; + out->leaves[index].subleaf =3D l1->subleaf; + index++; + } + } + nr_leaves =3D index; + + index =3D 0; + for ( i =3D 0; i < p1_nr_entries; i++ ) + { + xen_msr_entry_t *l1 =3D &p1->entries[i]; + xen_msr_entry_t *l2 =3D find_entry(p2->entries, p2_nr_entries, l1-= >idx); + + if ( !l2 ) + continue; + + out->entries[index].idx =3D l1->idx; + out->entries[index].val =3D level_msr(l1->idx, l1->val, l2->val); + index++; + } + nr_msrs =3D index; + + rc =3D deserialize_policy(xch, out, nr_leaves, nr_msrs); + if ( rc ) + { + errno =3D -rc; + rc =3D -1; + } + + return rc; +} diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 44a2f3c8fe3..5709bcb93fa 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -126,8 +126,6 @@ #define PVSHIM_CMDLINE "pv-shim console=3Dxen,pv" =20 /* Size macros. */ -#define __AC(X,Y) (X##Y) -#define _AC(X,Y) __AC(X,Y) #define MB(_mb) (_AC(_mb, ULL) << 20) #define GB(_gb) (_AC(_gb, ULL) << 30) =20 --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322625; cv=pass; d=zohomail.com; s=zohoarc; b=J2B2WGdstDRD0JD1KZQSosga8fuYH/uZC+SxDAQZBPg4EphOZHjU8xuUws9b27CHmB85xoyJ2vQmPsnzEHZeUAwWZkPTmgrDtqp8TPKtZ4eCELxIdiR9jiyVR8iTB01/9UianCajX2OzxPINvaWryvJMpLztq8sRlbd7nEU2pq4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322625; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2r1voEZpGxTx5Po9C2mMe1JKE7C2WQQb65ZrKzQeT0o=; b=ECmIPRZdR4nY3+Vu6ZOWZCZU8aWHCydlVk0i1faA28Tj28egAbNhI/oMsKiJKgG/Ry3Mthf++feZnYuFWaLEaVjc6EtCr6q+lQXtjP/T8kbxdTKhV9xK8z/zsG5lIY65Qa6vp6hcLpAu9YfA2iwt1Jw2PaXCu8DFKcqiDMW22A0= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322625388249.99044503713515; Tue, 13 Apr 2021 07:03:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109821.209685 (Exim 4.92) (envelope-from ) id 1lWJdb-0006E2-BH; Tue, 13 Apr 2021 14:03:31 +0000 Received: by outflank-mailman (output) from mailman id 109821.209685; Tue, 13 Apr 2021 14:03:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdb-0006Ds-6R; Tue, 13 Apr 2021 14:03:31 +0000 Received: by outflank-mailman (input) for mailman id 109821; Tue, 13 Apr 2021 14:03:29 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdZ-00061C-RK for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:29 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e785078d-3c3f-4fef-b0cd-cc4fe7c3f96c; Tue, 13 Apr 2021 14:03:29 +0000 (UTC) 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: e785078d-3c3f-4fef-b0cd-cc4fe7c3f96c DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322608; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=oXBqzDHS0FunQwg8diVLE6ArqyB8CJV5O3X62tjR+BM=; b=iNxJA4V3XzV47Qztg7qCwdzt0ppQXQY8JGq2h9eul3Xr9GKm/MMI1V2N gmWiFDSRDYtTqCN7JGceW0Hq1JA3rmEmaiaEleBS2O7GDe055osG0Qdzp OokhVV5rN3IW6vtcvY/FQc0sn0OBqN3IuQSMiVlGVPyaMIi6NVpD04M1x 8=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: tfvxbq07lTg5oX2Z8AnOsJ5SekT4D10PZgd6qOPbJpRoOMS7CtAUfxzHKSeIPGRaPeSp/yB/yb RCWbSxMP7feK7HZIHOvjFwRGC954dK6KPyGfHhMdXT79WAzgXbQyhjAEu1kOtolVe+c4v9qBIb PQxtFOW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jjKw2cqFcuAkcjlq0ouuRLydZj6AwdE xiZJfukqaxo3iK7X/Fhl8ZfiZ1PwJw2vHNQnlKrQgFPwffarAYoeiSfmhUwT+hKgJgSdjVVC pSvU5+967yD5H4/1FtN/uXdkahy1cDrnODSJkR3oeZ493+R58+BpE6HIprFQvKEBRxsR1wqH hKbTIFQkO3LEKstYyVyLgvQM3Pfdh1hwmmZeROr2jEiEmarcYzAkcAUyWWSs6RiwY2Tz9yjl l8mpVvx4aoqHKKEy8Ske44OFpDZCCyDKhdBAqIXolSh4vmYRp9V2uMmDychSwiY2aCzTRguk XRaQmvPd3bCFtUvX5Vlpzn9155bU2xVUN9YHISi/w3KU32/lJIlcObbKu61GWcLmYYyuYGKT fffH85OQV13e260xaThRePHXgr3Y8VI+TYFbgvGoujnE+FGcmtr+UrDvVU9JFqOJTSqecNS/ uYYBLQAzXiCe8lsjbl0EoNCW1Rkj0Dnvzp0hG+szT98347HPbIIFNpA5scOMqR6mD4R/COlL V15OhFydeYAyHUUJqhz6qSUhtobjX0ikSyR/szqZ9Vsbkp3YEDV6XzYH/t7jV/wB46LM3Ij0 sQT6Rw3aDZNuZUDrkvUhMc2mBsqc+GI0QquDHnG+MSfVkiiHnAItOCioC43oYHMwmkrAv0NU L3yVwkw971Gw+C36UdEaQ+PCB/b1U98m1r+Iq5BsftITTvU+FI51yhNHChNJdbVaieAL0V6j J3+cuBkePSVy323mnrzHZGC5ML12asWsWpBg2QXcZO7tyhIFyJxpKQ3/Tbtka/dRKLL2IChY NEckQMbsNMzhka5bdHrRSae+jQuUIqk1xX/Dd9sEXis7LWuVvmIQ== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41483950" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mw0oyHNjje/jnNrlW7IMhNEK4DNIa4Yl9gekwZ9Cku/CH7rGF13Sxiiv+iLnr8yeak/MoMoJdIgtxlnRLz42mAKTheROdtwu4HT/Ts14eOHOVxa2e+FAAFMHUpLGKyGvdMDRX1x0UpZwx0KK5yLwS9UFrgPQQtFyWJwy3hOhs8DQhMO3BBRIdwQdYaIUJWA2GZZB/MhpsuRFuRGpFe9unOo5X/LVgvXYR76NBsxrtP/sMQ14aeU8xJAjdNAVFEnB8dYlAjRgHDKGcDAOq92Di/41MNWl4IiGpyhlV9WTTHDD3D+eSoaeA6o1uz6E+Thlj6JZ7OVGfDaKBN0M0TObuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2r1voEZpGxTx5Po9C2mMe1JKE7C2WQQb65ZrKzQeT0o=; b=glV+DgQuKchOE+Owvs8ukMAyWyGLm60a8z+fT8BVcBIfKBLDnMIYfPgBga0WGQV9PknHj/g6fQJWhrJVbUmIoXXdvZAQf3Bt+toxW2UKJjv3OKH6XaHTQLc3NP8zWrhvV+dBJs1Cujs+B3wcjf3UWRvRi7CoNmPhc1+w4yxtF6PXlaiy0n7QEdvAWY9yfZ+TboC0aAUI6doz3wAIl9bEdt5tdlpWRpkHSsplbJXmZhJjRMhrNnyjDBAk3ATxEZn0IsfkKDtcI2vVEkJWF6Oxniktuk/Ltdg7W/fJv4j0JuDneu0pP3bwhFvNMCoeJRavmtkvs0M7g3yNwr9B+PXV+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2r1voEZpGxTx5Po9C2mMe1JKE7C2WQQb65ZrKzQeT0o=; b=Gf83JbncVahbefDOWWuoD/977ZIKlbJJEVs8bgq1pFs7FoJRBbPR4j/7Xrbd25GZ1awus5wNRVWmsJhhydsZFEoxKVSijKXmiqh5rgYavzMn4hGxyLVByBdErgWcLA3kFFt8LO/7kXcI7tmPC7mpl6iye3Mhva3O9xtTW82PIe4= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 16/21] libs/guest: make a cpu policy compatible with older Xen versions Date: Tue, 13 Apr 2021 16:01:34 +0200 Message-ID: <20210413140140.73690-17-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0065.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::29) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ef1e11a-8ce4-4995-71ab-08d8fe84e7d5 X-MS-TrafficTypeDiagnostic: DM5PR03MB2969: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NXVVVVErsVWXsrbZaV65auWhAu/+4nK+lxu9j00UhkQKRj6xxT5fZvpkmgbLZoSd/KBG16FXC2iFfpZtPJtHpCjNRRRcBklbClHVOu7PBMPPRE9FhX8TkhsYuRruYp+39PbadphbL+8Qp+9cD80iTPheI4evKdpZa3UkPlnXiU9Mp1z2llYDfh78w4ZEF50Q1Zj+l5Utb2IQ/W/S7IKqsg4VHoQW2a7CaJ5jhANQJRm0z/Fl0eUl8HfBlUzv2I76weq/no6MynAeD2lFyT5EW0N6iqbJSCN7XbaD4dYC0rT2+BeaZE2dw51FOERs7qEwPHD8RtDm3GjIGoU+6/xHFBmDEl8jPt16FqV/sMMa6cRnpvGvUW0SU+Ha14R7hG+bKxLMum3eLCN0G9TrOg/c+iCwyJuq6roYOc3B1ooMsf4hI7pVJfNZm58bPajFTGoRmNaVpjDk1dkO25eSh5+H8Ad0MDa4BMCaXUV2bL4AOQQNP28wsLxRP80GSg0hieEjORF9kjtRToAGb/a8bCNqpCrsFhydrhbLAkavvIVX0QkFUYMczZjZP2RqdrHzFWD/0QZkdKcvGInGSNQZi461RZbX+GclnJBD9zSkqsWmFrc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(346002)(136003)(39850400004)(366004)(83380400001)(186003)(6496006)(316002)(2906002)(4326008)(36756003)(54906003)(6916009)(2616005)(6666004)(16526019)(26005)(478600001)(6486002)(1076003)(8676002)(8936002)(5660300002)(66556008)(66946007)(86362001)(66476007)(38100700002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?bXVjazUxVnN1QWg1dWVkU3dRM1JHeWtLQzZuSXEwdjlnbzZZTXppMnBIeXk4?= =?utf-8?B?VlM4QldRNWJOVGMvUm9aZEtRTGRhYWtrRlErY2VMMm5xTkRYQ0pOQXUvMzlq?= =?utf-8?B?S3NtWmt5d1U0ckZtelpLQm1kOHpmVFFrdys5UTBkbTI3OHRNdHdZaFdBL2xz?= =?utf-8?B?VU9uQzBkNmlCRThwZEx0RmFSZEVBSWRrRjlQaXBHZXRySFhTVkcxY2xLTlRm?= =?utf-8?B?OTNjd2hFdDVOT1A2YncyN216RW00eDRsWEl3ZUlMdFFmQ0FoTXhtWGlkTWRG?= =?utf-8?B?WkdqZEpnY284MnVHZFJYVFUyK0FZbTJiSUlsNkJEcm1hZzFkR1dieU5TRmdn?= =?utf-8?B?NDVP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8?B?SHdjck9rZE9YK3ZqTEpmNkRnRlA4UTV3MGxUdFdYMmlrelk2ZDM2U0ZYU0dL?= =?utf-8?B?OVRKb3gzdGliY1FrQmt4bzVWOEdkUnVNUlZUcU9Qc3NkbmVXaXFvbEE0dk1N?= =?utf-8?B?bUl3OHhsUXYzNnFuOEdMOEFHM05wdXh6bXNRNytVQnU3QWt5Q1d0ZVBHTVJH?= =?utf-8?B?cHVBSjROUU5TR2RkZDFtaldXT0VkeGJHZS85VE5DZmpseVhTMjN5ZWJDMXFD?= =?utf-8?B?VG1IWWJCV2tuc09XQUtqcTNwNnhwQWtPMEFpNndrb01LTTk3b1AyeEszelo0?= =?utf-8?B?MWZVbjlkbU9SZEMrY3JMT3JZeWt2RXhwZGphYnB0TjRSYjRoTHpVM291ZWc2?= =?utf-8?B?WjR0UTF2bWRDOFFzR3ZKYU8zM1VBaEF0NGJwYk9Ld0RCODZ1UU5jMDNGZXYy?= =?utf-8?B?SWR0TGdoUUdaMGVickxqcURtTXlLeGtRL1RaUTAzdXczMEJTdWFjci9MWnZY?= =?utf-8?Q?Hvpk8DYwEpgQmA3YMoJQg68TunYnBdWgvnO2kB3?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4ef1e11a-8ce4-4995-71ab-08d8fe84e7d5 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:25.3773 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GhYTjPzilf0yuDTc/veKg6EmyHVexle5bJPzaBYVzAYPqTQ/ZdHKZ8uy5iy13NiEghJVY2od/Jod51IkZXPsnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2969 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Older Xen versions used to expose some CPUID bits which are no longer exposed by default. In order to keep a compatible behavior with guests migrated from versions of Xen that don't encode the CPUID data on the migration stream introduce a function that sets the same bits as older Xen versions. This is pulled out from xc_cpuid_apply_policy which already has this logic present. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Move comments and explicitly mention pre-4.14 Xen. --- tools/include/xenctrl.h | 4 +++ tools/libs/guest/xg_cpuid_x86.c | 46 ++++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index c41d794683c..89a73fd6823 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2627,6 +2627,10 @@ int xc_cpu_policy_calc_compatible(xc_interface *xch, const xc_cpu_policy_t p2, xc_cpu_policy_t out); =20 +/* Make a policy compatible with pre-4.14 Xen versions. */ +int xc_cpu_policy_make_compatible(xc_interface *xch, xc_cpu_policy_t polic= y, + bool hvm); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 6cfa4cb39d1..6486ac4c673 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -446,6 +446,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, unsigned int i, nr_leaves, nr_msrs; xen_cpuid_leaf_t *leaves =3D NULL; struct cpuid_policy *p =3D NULL; + struct xc_cpu_policy policy =3D { }; uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; uint32_t host_featureset[FEATURESET_NR_ENTRIES] =3D {}; uint32_t len =3D ARRAY_SIZE(host_featureset); @@ -509,17 +510,14 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, } =20 /* - * Account for feature which have been disabled by default since Xen 4= .13, + * Account for features which have been disabled by default since Xen = 4.13, * so migrated-in VM's don't risk seeing features disappearing. */ if ( restore ) { - p->basic.rdrand =3D test_bit(X86_FEATURE_RDRAND, host_featureset); - - if ( di.hvm ) - { - p->feat.mpx =3D test_bit(X86_FEATURE_MPX, host_featureset); - } + policy.cpuid =3D *p; + xc_cpu_policy_make_compatible(xch, &policy, di.hvm); + *p =3D policy.cpuid; } =20 if ( featureset ) @@ -1072,3 +1070,37 @@ int xc_cpu_policy_calc_compatible(xc_interface *xch, =20 return rc; } + +int xc_cpu_policy_make_compatible(xc_interface *xch, xc_cpu_policy_t polic= y, + bool hvm) +{ + xc_cpu_policy_t host; + int rc; + + host =3D xc_cpu_policy_init(); + if ( !host ) + { + errno =3D ENOMEM; + return -1; + } + + rc =3D xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host, host); + if ( rc ) + { + ERROR("Failed to get host policy"); + goto out; + } + + /* + * Account for features which have been disabled by default since Xen = 4.13, + * so migrated-in VM's don't risk seeing features disappearing. + */ + policy->cpuid.basic.rdrand =3D host->cpuid.basic.rdrand; + + if ( hvm ) + policy->cpuid.feat.mpx =3D host->cpuid.feat.mpx; + + out: + xc_cpu_policy_destroy(host); + return rc; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322637; cv=pass; d=zohomail.com; s=zohoarc; b=VUFDs7X0cVA/YehsIoQbidgwlHhbPc0E5bBdVqhh6BP+PSnmXhePANFeIzk2ohKhazdj5PJ03fD7yjM/MvzonRTNe0ProWKr9GLuZSQPfbz3S3xG78G8aW7hd8ohZxooQ6Sv5La/YymPS3Kl9pfSIrN+cqUeeHB/h6cPEM4k5TQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322637; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ke3HLuqORzOFlUKMPs/d/zUjkzAyI5FfHtUyvohI96I=; b=ca/hrX/EUKyLIz1nPvzEAgYaDkPyogzbCBlvE5O8IMCQdRxDrJZekCe4IJTOATfx7elkEdZMXZQBJVcQsXgpjNeuuvA/fg5zNMn4C/Tpzd65ZtHm3tGhR9E5PPqlno8hKK7ZEqpNCSJ2QBC0jGIzW9QdX+e6u90tZvxJA3OMJeM= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322637428920.7921411120732; Tue, 13 Apr 2021 07:03:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109825.209697 (Exim 4.92) (envelope-from ) id 1lWJdh-0006Lz-MA; Tue, 13 Apr 2021 14:03:37 +0000 Received: by outflank-mailman (output) from mailman id 109825.209697; Tue, 13 Apr 2021 14:03:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdh-0006Lp-IJ; Tue, 13 Apr 2021 14:03:37 +0000 Received: by outflank-mailman (input) for mailman id 109825; Tue, 13 Apr 2021 14:03:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdg-0006KX-BV for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:36 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2658cdd3-a2f5-4515-ae80-ce5a6f63e98b; Tue, 13 Apr 2021 14:03:35 +0000 (UTC) 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: 2658cdd3-a2f5-4515-ae80-ce5a6f63e98b DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322614; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=SvFuPv+ayBPXc00cwLumU7gxLcmcG3dejOnRxECnnd8=; b=eELQFL8YO/zKB/kODPpXxzwoEtff2uTpzXZIEN6BSjnsiB4rlgKbjnIs DtNCRwXA1rE1luQV8Jfj6RG6F68phkpf6e+R8ZQjC/QEtTb7PdaEHruJJ aY3H0iqeE/i07Dv1CYUJhxZ5VWi9Fev2HKRXYxWpIltxK7I+KO1QNWvkz A=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: D26REcR3/iU4c4pPJrBtRS3QJvmZQWYNmYmIAb2sHOES7gYATs6AznOgGsoutsYk4gQLcrGPSB AqbRuQMZaomyVYjywhOagrDEIsySkG4I+ZprMVbrfynCSuYUIXCo+u9a8L1NE0zOZbzIllP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MKWyxZlX9KE9cql39iQFg1Ww4c+GbRdYtLYtQU d4KLT71oeypWy8+3f0/3xkUyAtSnp90fHFaTdntAUKO0T7ffIooNOEY11f23OBO1tZQ97JFh Vc43B647i+IZDV5S1KMaPoDkuqy18o4F6aRZYVnaOOoe3/fIkjM5ogUKttUSPRFxJ0ng5ugH xZaBANQ3LeEj+Gs9TnsLUkQMXkM/VsigaiJsBZ7VjFs1+HmM0pTnwHGwK1XdWvmgYoTTpMjl hX+6sS6YDw3gqHGC8auqAVIVdMYGOYDPZjAB6ebItZoLztZTp9VHyHnzCclhE1dFf77kl6vB 2TEQSkPdXwRnZNsHFR1ajntGl5cWiQZGpcQHF3u48VLxWMhl9DlcuwIoaj2WqYbVUPhtwHOD beeD0IP0dF3NasziOYnz6ECFQrzpgjJfbmEbwmar3fs0ndbrGgpOUjJbt57ZxlPNfhvqs3Su qZYRaSNy69JOUz2QCZz0xVThVcmT0Bq7fP1xLk5mTjgyJ6LvrWPVh8R7YUZ/ub9HPpQv6U0J N/yfI51NHARlnZW5qj8+XwaTUGFzb45UiRZMssoYpPva0zuKBodqOrGQfg5TVi5lEGMMzwlE kiW6x177DKB593c6UpCldk12tssO7KEVAivQP3CNIvZF0Bj3fUONWS/rrDwIBfdXGplU/VMV mb/zY1xYa8YwKzkZobAbk3O2JYdQwV72lj5vqLc+TreU+XXtAG2FqxKXmmdrBBDICDBLULtx 5/p/WFhfWeeSa9+Afeu1JAU+9z2lfiZcO5GwSXH+FUt/S8JFSXm6OvpPeJsw2fc0rzV20owa tfdUIRacxfij4tyK0PuxLCNZDfkwYCiFtR4TZui1j3/JOpiV2rRH17DQ== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41322379" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aR8cZTscSsAQVIPiB/sMjmQCwS3wI2SJjQyWIS6OyzvOtsvO3KW9mj903n7dQIPLRmVGJh8pkyQPz8oXuFAjasI0O/fu/Sg19jXrJjD7SqrhK47hjfYGuxy0699P4bisbCo94rcL/h1zkvo8XBXzlVb6c7PCO5GMlI8zNqzmr00hmvhGVUOKnhG5treZKvxeJO0ETN2IZdAr4xzGPWIeo5DWEVXwVzCSmWUsIHy2EDqrx83RPRYcZZ/zEG9fOnT+d0BVGHudDsi2KP3b/MpZOLN6UqmSnyUDToCkhvXPHyxC2qXrXTMe3e156naDeJUGBfYtekSe9HRLqFjr5KBlUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ke3HLuqORzOFlUKMPs/d/zUjkzAyI5FfHtUyvohI96I=; b=U6y2YQ+WHjT3fKwWcLLKEvyYbEOjUsbBzDDz3C8qH/oLX+rN8AaeJZHoxByBqnacsNFAsVqhI37QhmD9A0UnJ4moSyCYBjuyRcj4tn58wc7OasqTtmSbx+ZksbIM66n80y83GgW2/GbU+b4snxEqunN6uVC0UvGadReLiuL9WtQlb8F/P5RDoxJgoVJPVg9Mg2BpHmBbOHQTo/O8cor4Zev68YephgANveVViNaHxed69dTGK5RHFBjvf47rgsJzkpTuEJmwiSFy2TIDNu6VFW7C9R8bYJsyU/TIGOuF3iaF2/f3aTWxNhqAXuEhsYdDk3QE/+WBqrRVgFOqJ+rvPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ke3HLuqORzOFlUKMPs/d/zUjkzAyI5FfHtUyvohI96I=; b=GpYuKG/rdsVEI9/Wx71EDXV49WnbYWONniy0wvG2eOpVQWFS2f+rUNfcoz+V0+KFcqRF1aIvRswmFBKFeA5MbOvcIrJpPye+PP2xOhYkJyIhPC4QG033WvGPvg16RHYOvueA6pMrx9ci8gDLMLPGA6oHhWPsnC20EXONVOrw/Dg= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 17/21] libs/guest: introduce helper set cpu topology in cpu policy Date: Tue, 13 Apr 2021 16:01:35 +0200 Message-ID: <20210413140140.73690-18-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0168.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1::31) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d39fafd-e6f1-409b-7c42-08d8fe84eb90 X-MS-TrafficTypeDiagnostic: DM5PR03MB2969: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1169; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MVfyxhuEeeB1mL0HxJycAj3tyHOTCi85pXBevdaddypQCDwZt21xEzEt18HBF6+6Ii5twBFOMFMlvKvgE2ZSxbUwaCCtWDcVDG28T4XSM+bb1JMKRE8ll95IcgatU3gL/LxUJqtEJOZQPpnCeR9sbWhpA8+2NiYoNFjMYxUJf+7JVMUo3/HZW+6khVOBIRsu0SycAcod2e0ze+VGpTm5ZUA5RX32U8yltuCtrD1Cm6F8o2ZJZKhiy5IkHOJE7fC/hBiDC7/L230v17h9yz5ky9Tr3CJcDsnEXWAI91GpRT5lSJCg9iwMKu2ta6QHKuk06wcuvb2K4EdI8PO4sjhCfSkg6Odkrk1QF5u+z5fiyYP32OmsTQF5ZvKaNNj8VniMGu/8fhcfUL89LtVIRPrwncRDkvu8kWsjkFw5j7ZAAjGjg1f17h5DGiurG132SxLzDRfHJVrPMb8naZlKrLz3gUMdKpPBhl4uz5FiCALDuxF9/GavZ/nIc5lrhWUcACNmxCwE0bqCTrJgGXuwlWLvDqtdgnHdFt1dBnBqxXWWXTB4MwAnJQBxSIO3ALbHpTGgOtgkGI0+9w5s5fLQz3NI2CxCso3vkFLzbF/oSD92Jr0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(346002)(136003)(39850400004)(366004)(83380400001)(186003)(6496006)(316002)(2906002)(4326008)(36756003)(54906003)(6916009)(2616005)(16526019)(26005)(478600001)(6486002)(1076003)(8676002)(8936002)(5660300002)(66556008)(66946007)(86362001)(66476007)(38100700002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?K3Jxd1hQK2xDbUorRG1RSklkcCsyL0VEWmM5MERUYTgwaEV3RW9yL3pPTEU2?= =?utf-8?B?V2xJait4dlBWUVlwYUtzS1VFRXpFR1pFYUNkT0JUdlNXQkkrMDhEK2lIbThT?= =?utf-8?B?VGZhVjhkbHZjYm0rNVl4d05YbG5DKzBwZWV6RzdUZTJuT2J6bW5xMGVZMXEz?= =?utf-8?B?cHUwL0pLRzM4anJQd0h2cDNzY1VEQmUrRndWb3JBMjYvdkc3OU92NUszSGU2?= =?utf-8?B?Rk41UGtLdThGbUJZUnVQcTAvcy9RZEtwYTRQbFNocWlNdzA1djk0YTJzWllw?= =?utf-8?B?S0lPSVN1amh0dG9ZYlVISmhvL3VsbHdJRXYxUUR5djJrUTMyWDBBeXozNDRq?= =?utf-8?B?Y2g2VExOL2hNUEp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KzVva0lLdjVoMUwrVkFkNnBaV3Vob3prTUxjUnJ4dTJ6SFFvM0pjdGtZbFUz?= =?utf-8?B?N2hrQWZvUDhrRmtHcHJJeUsvb0lRMmEvVTdudjd4cHNJRitrZ3E3bnZCWVRm?= =?utf-8?B?QmR6OW8xcTJNWXRwa1ExRmplWWYvYXpWdzFFWWVubmF2U2pZUWN0WDRjQ0R1?= =?utf-8?B?bEZYL2JaRGVjb1BDMkEzUm1zTEp3S2x1eVl5b0lMd3ZNTHJjRXk4b0ttU1Y0?= =?utf-8?B?eEttMnpsVXZqN2picGlzbjlvQWEvZTBDazR3T3U2M2xNakhOMDRqU0I2Um5Q?= =?utf-8?B?WVdwTXQxOUtCaVc4VU1uZENpOGJoZTViUVFZNHY3VlUrK2N0ZlB3V3JSM3pP?= =?utf-8?B?clpiOGNFUUpwMnorWDZ2MHBMWHFOcjhIVDNIWVFuVkd2UFEzYUJHb21CR04z?= =?utf-8?B?cWo4bjU0bmJKQ1RhcWx5eHNNWnpkem5RMUtMVlk2VW5MTy9zOVRnUHdETHlj?= =?utf-8?Q?iomVmlZokOvA7LAWiUQeKI/qEltKBcgR4ZKEux+?= X-MS-Exchange-CrossTenant-Network-Message-Id: 8d39fafd-e6f1-409b-7c42-08d8fe84eb90 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:31.5547 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TYvGGoYpb5NRfQVkIoItik3NkEJdt9azkHYAC2GFH7BhXmt0dCfW0yPot7SGlg0Cbhd8w0W/ighPtN1AvxUb0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2969 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) This logic is pulled out from xc_cpuid_apply_policy and placed into a separate helper. Note the legacy part of the introduced function, as long term Xen will require a proper topology setter function capable of expressing a more diverse set of topologies. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- - s/xc_cpu_policy_topology/xc_cpu_policy_legacy_topology/ --- tools/include/xenctrl.h | 4 + tools/libs/guest/xg_cpuid_x86.c | 182 +++++++++++++++++--------------- 2 files changed, 103 insertions(+), 83 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 89a73fd6823..ec184bccd3f 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2631,6 +2631,10 @@ int xc_cpu_policy_calc_compatible(xc_interface *xch, int xc_cpu_policy_make_compatible(xc_interface *xch, xc_cpu_policy_t polic= y, bool hvm); =20 +/* Setup the legacy policy topology. */ +int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t polic= y, + bool hvm); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 6486ac4c673..83cd71148f7 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -443,13 +443,11 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, { int rc; xc_dominfo_t di; - unsigned int i, nr_leaves, nr_msrs; + unsigned int nr_leaves, nr_msrs; xen_cpuid_leaf_t *leaves =3D NULL; struct cpuid_policy *p =3D NULL; struct xc_cpu_policy policy =3D { }; uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; - uint32_t host_featureset[FEATURESET_NR_ENTRIES] =3D {}; - uint32_t len =3D ARRAY_SIZE(host_featureset); =20 if ( xc_domain_getinfo(xch, domid, 1, &di) !=3D 1 || di.domid !=3D domid ) @@ -472,22 +470,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t = domid, bool restore, (p =3D calloc(1, sizeof(*p))) =3D=3D NULL ) goto out; =20 - /* Get the host policy. */ - rc =3D xc_get_cpu_featureset(xch, XEN_SYSCTL_cpu_featureset_host, - &len, host_featureset); - if ( rc ) - { - /* Tolerate "buffer too small", as we've got the bits we need. */ - if ( errno =3D=3D ENOBUFS ) - rc =3D 0; - else - { - PERROR("Failed to obtain host featureset"); - rc =3D -errno; - goto out; - } - } - /* Get the domain's default policy. */ nr_msrs =3D 0; rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault @@ -575,70 +557,11 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, } } =20 - if ( !di.hvm ) - { - /* - * On hardware without CPUID Faulting, PV guests see real topology. - * As a consequence, they also need to see the host htt/cmp fields. - */ - p->basic.htt =3D test_bit(X86_FEATURE_HTT, host_featureset); - p->extd.cmp_legacy =3D test_bit(X86_FEATURE_CMP_LEGACY, host_featu= reset); - } - else - { - /* - * Topology for HVM guests is entirely controlled by Xen. For now= , we - * hardcode APIC_ID =3D vcpu_id * 2 to give the illusion of no SMT. - */ - p->basic.htt =3D true; - p->extd.cmp_legacy =3D false; - - /* - * Leaf 1 EBX[23:16] is Maximum Logical Processors Per Package. - * Update to reflect vLAPIC_ID =3D vCPU_ID * 2, but make sure to a= void - * overflow. - */ - if ( !(p->basic.lppp & 0x80) ) - p->basic.lppp *=3D 2; - - switch ( p->x86_vendor ) - { - case X86_VENDOR_INTEL: - for ( i =3D 0; (p->cache.subleaf[i].type && - i < ARRAY_SIZE(p->cache.raw)); ++i ) - { - p->cache.subleaf[i].cores_per_package =3D - (p->cache.subleaf[i].cores_per_package << 1) | 1; - p->cache.subleaf[i].threads_per_cache =3D 0; - } - break; - - case X86_VENDOR_AMD: - case X86_VENDOR_HYGON: - /* - * Leaf 0x80000008 ECX[15:12] is ApicIdCoreSize. - * Leaf 0x80000008 ECX[7:0] is NumberOfCores (minus one). - * Update to reflect vLAPIC_ID =3D vCPU_ID * 2. But avoid - * - overflow, - * - going out of sync with leaf 1 EBX[23:16], - * - incrementing ApicIdCoreSize when it's zero (which changes= the - * meaning of bits 7:0). - * - * UPDATE: I addition to avoiding overflow, some - * proprietary operating systems have trouble with - * apic_id_size values greater than 7. Limit the value to - * 7 for now. - */ - if ( p->extd.nc < 0x7f ) - { - if ( p->extd.apic_id_size !=3D 0 && p->extd.apic_id_size <= 0x7 ) - p->extd.apic_id_size++; - - p->extd.nc =3D (p->extd.nc << 1) | 1; - } - break; - } - } + policy.cpuid =3D *p; + rc =3D xc_cpu_policy_legacy_topology(xch, &policy, di.hvm); + if ( rc ) + goto out; + *p =3D policy.cpuid; =20 rc =3D x86_cpuid_copy_to_buffer(p, leaves, &nr_leaves); if ( rc ) @@ -1104,3 +1027,96 @@ int xc_cpu_policy_make_compatible(xc_interface *xch,= xc_cpu_policy_t policy, xc_cpu_policy_destroy(host); return rc; } + +int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t polic= y, + bool hvm) +{ + if ( !hvm ) + { + xc_cpu_policy_t host; + int rc; + + host =3D xc_cpu_policy_init(); + if ( !host ) + { + errno =3D ENOMEM; + return -1; + } + + rc =3D xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host, h= ost); + if ( rc ) + { + ERROR("Failed to get host policy"); + xc_cpu_policy_destroy(host); + return rc; + } + + + /* + * On hardware without CPUID Faulting, PV guests see real topology. + * As a consequence, they also need to see the host htt/cmp fields. + */ + policy->cpuid.basic.htt =3D host->cpuid.basic.htt; + policy->cpuid.extd.cmp_legacy =3D host->cpuid.extd.cmp_legacy; + } + else + { + unsigned int i; + + /* + * Topology for HVM guests is entirely controlled by Xen. For now= , we + * hardcode APIC_ID =3D vcpu_id * 2 to give the illusion of no SMT. + */ + policy->cpuid.basic.htt =3D true; + policy->cpuid.extd.cmp_legacy =3D false; + + /* + * Leaf 1 EBX[23:16] is Maximum Logical Processors Per Package. + * Update to reflect vLAPIC_ID =3D vCPU_ID * 2, but make sure to a= void + * overflow. + */ + if ( !(policy->cpuid.basic.lppp & 0x80) ) + policy->cpuid.basic.lppp *=3D 2; + + switch ( policy->cpuid.x86_vendor ) + { + case X86_VENDOR_INTEL: + for ( i =3D 0; (policy->cpuid.cache.subleaf[i].type && + i < ARRAY_SIZE(policy->cpuid.cache.raw)); ++i ) + { + policy->cpuid.cache.subleaf[i].cores_per_package =3D + (policy->cpuid.cache.subleaf[i].cores_per_package << 1) = | 1; + policy->cpuid.cache.subleaf[i].threads_per_cache =3D 0; + } + break; + + case X86_VENDOR_AMD: + case X86_VENDOR_HYGON: + /* + * Leaf 0x80000008 ECX[15:12] is ApicIdCoreSize. + * Leaf 0x80000008 ECX[7:0] is NumberOfCores (minus one). + * Update to reflect vLAPIC_ID =3D vCPU_ID * 2. But avoid + * - overflow, + * - going out of sync with leaf 1 EBX[23:16], + * - incrementing ApicIdCoreSize when it's zero (which changes= the + * meaning of bits 7:0). + * + * UPDATE: I addition to avoiding overflow, some + * proprietary operating systems have trouble with + * apic_id_size values greater than 7. Limit the value to + * 7 for now. + */ + if ( policy->cpuid.extd.nc < 0x7f ) + { + if ( policy->cpuid.extd.apic_id_size !=3D 0 && + policy->cpuid.extd.apic_id_size < 0x7 ) + policy->cpuid.extd.apic_id_size++; + + policy->cpuid.extd.nc =3D (policy->cpuid.extd.nc << 1) | 1; + } + break; + } + } + + return 0; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322640; cv=pass; d=zohomail.com; s=zohoarc; b=UeEMq3R2uXpaTBfXkLsH9gBdPXdmJti2Pojzb/DvNjiC4++1KWuA+g4AjJ73LGESV+CEqzekmyHOqo6uYY7HCYZTYPd6DCjUG8yq6zdRfD5w8w+J2wgQEMgIa1GCtZbMbbaVNubRS5PgJmOv3jUukpoWrYbGkeYlS3okkovvQDU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322640; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dhDbUZkOllUWicuxg47GICno5ICsaetEMRtEl5iO2+0=; b=Ppn4hrDkp0qkO5wo9+5vUJaj95Qy7y1sjcfAa4ObSbJ3jgToSGW6Mcy4+wgQpPF5mdqk/SIFHN2SzcfFBQ8PAaTwovotDi1nyX9ad5I358QqwAtSJyxoqvs1cpoeAHEUsDsWY13NpNWHYAj0neR/wjTEGtmo7Thk4EkZbyxgPO0= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 161832264002828.329490455708992; Tue, 13 Apr 2021 07:04:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109829.209709 (Exim 4.92) (envelope-from ) id 1lWJdm-0006Rv-60; Tue, 13 Apr 2021 14:03:42 +0000 Received: by outflank-mailman (output) from mailman id 109829.209709; Tue, 13 Apr 2021 14:03:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdm-0006Rm-29; Tue, 13 Apr 2021 14:03:42 +0000 Received: by outflank-mailman (input) for mailman id 109829; Tue, 13 Apr 2021 14:03:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdl-0006KX-5I for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:41 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 02147ad1-c3de-48ca-8106-a6755cb7693f; Tue, 13 Apr 2021 14:03:39 +0000 (UTC) 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: 02147ad1-c3de-48ca-8106-a6755cb7693f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322619; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=y5+wq5v92xJaRWVBJA3GfnjlX1XmtbKxgDkEMUjd/7g=; b=ZBzbBoLw7qUwCwwxaYsH/pxKvPxjI6LrwoMrf7O3IS0cqh2qRI9dp7Cy 6vQ8R5XA9qYvmDz6lmWGbyu97nDP3/G0z43+uy+pk9DgaHqhOMs8M1jkM 0Cfrdu1v+HkZIfPP5waf1tKMXkoQAPoC+L1mLqqz2VuoIGZ3Y+H0lg9wt 0=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: CxjGfYuM1jq6+8dncgah+SBVUc8hss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cselector9901; d=microsoft.com; cv=none; b=D2JvE0+ooWjkoP4e95ADW87M15OBVrGy6sw408MBCeoy3tNmm7tKOjfqw3pS356UDXjpB9PMPmTytxZ5TonYzgO4A/TlXdqWQlGXue9hz6nLFrngPFg55Vr7D+Qk4o/e1CDThaoUhF18iGyD3Qt82tFlnM+5oUPT5aC5d73u/ePscoZKEXFFeBP/bFfQ1PwYp6RQiLkq4jmZ7fVHjR+tRRh3h5cFw3hwjB8LVAV6yhM53L1oW/uoFHU5dQ/eQMXDMI8pAteGyzkSz8iaedZ2g71cJeFabVAI42c8kf9FPPkvTDR3pLgwUYx8bWPsMwvbKnQuzFrl8x719TFGk61N3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dhDbUZkOllUWicuxg47GICno5ICsaetEMRtEl5iO2+0=; b=BKgnFeQa8/RVaVfkH6gEuL7rPWsNxtvv9MI2UlNgwQZRF6ofbv7SVAYNdc20vHlAjT71OhhGb4fLcTlRk3OjyJRSN65LNGkYNZbKNarhq9YsrroE/X51K+GVsIHT+YklYFrwU1h0HTcG6Y9xWLtiNvaTh7AjCxYZ+0h2kOPyMIeEYzMrZNT4vAZGGX28GEuxESlcFFijlxneiKQLIq48OkAOshxzhunmc0tBc7LdC91DDJNMZi7zbK2b3pluxDOLQhXN3h/VZboYHOuFF5DFow56jo+bltexGDLPzJeAT5Ez1AMBa+KxvUxQiO6yli5aV+aDbcIjY060DqY8BNrAAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dhDbUZkOllUWicuxg47GICno5ICsaetEMRtEl5iO2+0=; b=IFTJdP5kdWdvX1DO/Yw2nJIuP9le24n1HeV/+CaxNUp8Wxrea9N6DvUJsYTprC4xJC/DBXb9LC0kGsCbz3pIJxlG6TQICybF9/joiEKK8GZf+9hGYSQ+VRn0vh+FfKm6FM5sWW4bWLyMLyCi5J8VWmhk5O/MaAoAsX0+LgT1rEo= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 18/21] libs/guest: rework xc_cpuid_xend_policy Date: Tue, 13 Apr 2021 16:01:36 +0200 Message-ID: <20210413140140.73690-19-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0163.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1::26) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ebbfea3f-dcd6-4205-08a4-08d8fe84eef3 X-MS-TrafficTypeDiagnostic: DM5PR03MB2969: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:65; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BNb3tyYF9AEA2J87W+GYK1OEjjC7FUwqNAjYvUC66HxgD76ltkDWvU53LETwA0G0JQTpfHykJaMZjsFR9OUawuSs9cC6bV5A5UliuRcZoYOAx68z/LMif2p1tIonFfU3goXmPLmLUEJy0q0SIPKFEAZafmVtIJ90/z6PJGx2v0MlJJxDFEvtekkYi2aoJSgrFE0kFBRSXsoD6Z1vm9DTOzPTgcj0A334sQKC1nGGfxpSlbkDV9/5FiN8VXlZUyCrz15OaXe0CAM2gls2XxqoYKTR8gEbTUVYiselUu0uXedYzsyq2r6jXutv3JQKUnrEwuMJgvkIoUMhR5nbGdmiLw3/2hs5Fux4DdfMkZdwFXa4cEp+NqxsntuDfNJ1s/L94nRvn6hIBAWyocwpSVhCMRHfE3yyPtCbhjA+0ctdgAs5vPcyZ98KZb0Yfts0Wt7LsOuZr9u6rXX7oV/ivvZvVMjUIFa8Rh/pGP3CVcazfXkqBeL343q3DdyVTP+0/FgIPdeh4+6e7Q5R8XBPCHgk1+Z+pRlXZIiIr4oYC2H3D3BeJHV1xyqKZs3e2c01qGZqtWMO6B6xawJPTlIP/GY2+YBFPRVN3gmP/fmqRgZ82dM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(346002)(136003)(39850400004)(366004)(83380400001)(186003)(6496006)(316002)(2906002)(4326008)(36756003)(54906003)(6916009)(2616005)(16526019)(26005)(478600001)(6486002)(1076003)(8676002)(8936002)(5660300002)(66556008)(66946007)(86362001)(66476007)(38100700002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?c0Q3REtUajhLWUtoYWlJZ3NJNW5UejVZWUthTzE1U2kyeW9BdnhMU1pIeWRM?= =?utf-8?B?c2VMNG1qS3RjYWNvdlRxcXM3djhpZzh2TTM5U1N0akRRQzJvL0FSc1NBS2M4?= =?utf-8?B?Lzc4RUQ5SGxtcno1MjNZOUtxMkpMSnhtY1doRVdlWkZRK3QrTnRnYkJqR0J3?= =?utf-8?B?a0NLbmhzL1hBZmMvSHFmR0s4Nll6dktJc3VEenVmbjVFSUM2K0ZjREhNcEt1?= =?utf-8?B?cmNSdlQ0WWpJYzl6TnBWSGljY0tmdG9sbkRmRWtyW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mFXSXF5QXh4ODh0T1pzUzJFU21WQVVoODhjKzRvUmh4VlZE?= =?utf-8?B?M0tPRStTcDBYM0dpSVhaLzMxcVVwakQzd3NBTVlFNUlRaFlmY2dMQ1RKbWJR?= =?utf-8?B?dnRBZ2I5eWd3dHd1Q1ltTmZGOHB6Wk1NT1hpdDBoTG9HaTRmSGNEWW5PRmRS?= =?utf-8?B?WXdVWHIwclVNVEJibEQvc29RangzWVFXcVYyN2ZUUVAxcDY2Z1V0Y3RlY3pz?= =?utf-8?B?bUZZc1ZPTmNXSFdkczdxRXgyb0YrbWc1TG9Ib1EydEVZMngwVnRPc0VwWFdj?= =?utf-8?B?dnlHOVprZHZESmhDdUxlZDdTc0FETnMxbHMySm1UaUdDZjhRYy9UOHBqendM?= =?utf-8?B?V1YwOExsKzRqS0g5d2QvaGx4N2duYVFLbXYxS2VBenRHMjhCT0lPdVRDUHZs?= =?utf-8?B?UnMwMk9KSFNzamo2eHVRV1pPUlZNOHBJMUZCZ0VNVkd6OWRGMFJwcGdLZmp6?= =?utf-8?B?Nmc0RVBJZ0FmbUZPcWpQbk1USnNQY3o0aWRHTW96dFNRWnVKaFQ4cVdVTFZP?= =?utf-8?B?VCtEZkE2SmE5QUVhaXRpR3lWV0MyMktmMUMrdzhFY0dKYkQrRHhsaXZGdzkv?= =?utf-8?Q?UetrT9WXuQGW6wsjn1FL9uUptLrtfdCtp7PJHmL?= X-MS-Exchange-CrossTenant-Network-Message-Id: ebbfea3f-dcd6-4205-08a4-08d8fe84eef3 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:37.2237 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vdQI8/0ShcO5vCUU8yRqMfMDVCB3C5aTDBNgAFguYRDA+o331dnaqHZgS6i1LUPfPHU8/nqZfhgN4a+ZBLXy5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2969 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Rename xc_cpuid_xend_policy to xc_cpu_policy_apply_cpuid and make it public. Modify the function internally to use the new xc_cpu_policy_* set of functions. Also don't apply the passed policy to a domain directly, and instead modify the provided xc_cpu_policy_t. The caller will be responsible of applying the modified cpu policy to the domain. Note that further patches will end up removing this function, as the callers should have the necessary helpers to modify an xc_cpu_policy_t themselves. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- tools/include/xenctrl.h | 4 + tools/libs/guest/xg_cpuid_x86.c | 182 ++++++++++++++------------------ 2 files changed, 84 insertions(+), 102 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index ec184bccd3f..ce0785f7654 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2635,6 +2635,10 @@ int xc_cpu_policy_make_compatible(xc_interface *xch,= xc_cpu_policy_t policy, int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t polic= y, bool hvm); =20 +/* Apply an xc_xend_cpuid object to the policy. */ +int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t policy, + const struct xc_xend_cpuid *cpuid, bool hvm); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 83cd71148f7..06e3e8131d7 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -288,124 +288,107 @@ static xen_cpuid_leaf_t *find_leaf( return bsearch(&key, leaves, nr_leaves, sizeof(*leaves), compare_leave= s); } =20 -static int xc_cpuid_xend_policy( - xc_interface *xch, uint32_t domid, const struct xc_xend_cpuid *xend) +int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t policy, + const struct xc_xend_cpuid *cpuid, bool hvm) { int rc; - xc_dominfo_t di; - unsigned int nr_leaves, nr_msrs; - uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; - /* - * Three full policies. The host, default for the domain type, - * and domain current. - */ - xen_cpuid_leaf_t *host =3D NULL, *def =3D NULL, *cur =3D NULL; - unsigned int nr_host, nr_def, nr_cur; - - if ( xc_domain_getinfo(xch, domid, 1, &di) !=3D 1 || - di.domid !=3D domid ) - { - ERROR("Failed to obtain d%d info", domid); - rc =3D -ESRCH; - goto fail; - } - - rc =3D xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs); - if ( rc ) - { - PERROR("Failed to obtain policy info size"); - rc =3D -errno; - goto fail; - } + xc_cpu_policy_t host =3D NULL, def =3D NULL; =20 - rc =3D -ENOMEM; - if ( (host =3D calloc(nr_leaves, sizeof(*host))) =3D=3D NULL || - (def =3D calloc(nr_leaves, sizeof(*def))) =3D=3D NULL || - (cur =3D calloc(nr_leaves, sizeof(*cur))) =3D=3D NULL ) - { - ERROR("Unable to allocate memory for %u CPUID leaves", nr_leaves); - goto fail; - } - - /* Get the domain's current policy. */ - nr_msrs =3D 0; - nr_cur =3D nr_leaves; - rc =3D get_domain_cpu_policy(xch, domid, &nr_cur, cur, &nr_msrs, NULL); - if ( rc ) + host =3D xc_cpu_policy_init(); + def =3D xc_cpu_policy_init(); + if ( !host || !def ) { - PERROR("Failed to obtain d%d current policy", domid); - rc =3D -errno; - goto fail; + PERROR("Failed to init policies"); + rc =3D -ENOMEM; + goto out; } =20 /* Get the domain type's default policy. */ - nr_msrs =3D 0; - nr_def =3D nr_leaves; - rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault + rc =3D xc_cpu_policy_get_system(xch, hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault : XEN_SYSCTL_cpu_policy_pv_defa= ult, - &nr_def, def, &nr_msrs, NULL); + def); if ( rc ) { - PERROR("Failed to obtain %s def policy", di.hvm ? "hvm" : "pv"); - rc =3D -errno; - goto fail; + PERROR("Failed to obtain %s def policy", hvm ? "hvm" : "pv"); + goto out; } =20 /* Get the host policy. */ - nr_msrs =3D 0; - nr_host =3D nr_leaves; - rc =3D get_system_cpu_policy(xch, XEN_SYSCTL_cpu_policy_host, - &nr_host, host, &nr_msrs, NULL); + rc =3D xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host, host); if ( rc ) { PERROR("Failed to obtain host policy"); - rc =3D -errno; - goto fail; + goto out; } =20 rc =3D -EINVAL; - for ( ; xend->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++xend ) + for ( ; cpuid->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++cpuid ) { - xen_cpuid_leaf_t *cur_leaf =3D find_leaf(cur, nr_cur, - xend->leaf, xend->subleaf); - const xen_cpuid_leaf_t *def_leaf =3D find_leaf(def, nr_def, - xend->leaf, xend->sub= leaf); - const xen_cpuid_leaf_t *host_leaf =3D find_leaf(host, nr_host, xen= d->leaf, - xend->subleaf); - - if ( cur_leaf =3D=3D NULL || def_leaf =3D=3D NULL || host_leaf =3D= =3D NULL ) + xen_cpuid_leaf_t cur_leaf; + xen_cpuid_leaf_t def_leaf; + xen_cpuid_leaf_t host_leaf; + + rc =3D xc_cpu_policy_get_cpuid(xch, policy, cpuid->leaf, cpuid->su= bleaf, + &cur_leaf); + if ( rc ) { - ERROR("Missing leaf %#x, subleaf %#x", xend->leaf, xend->suble= af); - goto fail; + ERROR("Failed to get current policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + goto out; + } + rc =3D xc_cpu_policy_get_cpuid(xch, def, cpuid->leaf, cpuid->suble= af, + &def_leaf); + if ( rc ) + { + ERROR("Failed to get def policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + goto out; + } + rc =3D xc_cpu_policy_get_cpuid(xch, host, cpuid->leaf, cpuid->subl= eaf, + &host_leaf); + if ( rc ) + { + ERROR("Failed to get host policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + goto out; } =20 - for ( unsigned int i =3D 0; i < ARRAY_SIZE(xend->policy); i++ ) + for ( unsigned int i =3D 0; i < ARRAY_SIZE(cpuid->policy); i++ ) { - uint32_t *cur_reg =3D &cur_leaf->a + i; - const uint32_t *def_reg =3D &def_leaf->a + i; - const uint32_t *host_reg =3D &host_leaf->a + i; + uint32_t *cur_reg =3D &cur_leaf.a + i; + const uint32_t *def_reg =3D &def_leaf.a + i; + const uint32_t *host_reg =3D &host_leaf.a + i; =20 - if ( xend->policy[i] =3D=3D NULL ) + if ( cpuid->policy[i] =3D=3D NULL ) continue; =20 for ( unsigned int j =3D 0; j < 32; j++ ) { bool val; =20 - if ( xend->policy[i][j] =3D=3D '1' ) + switch ( cpuid->policy[i][j] ) + { + case '1': val =3D true; - else if ( xend->policy[i][j] =3D=3D '0' ) + break; + + case '0': val =3D false; - else if ( xend->policy[i][j] =3D=3D 'x' ) + break; + + case 'x': val =3D test_bit(31 - j, def_reg); - else if ( xend->policy[i][j] =3D=3D 'k' || - xend->policy[i][j] =3D=3D 's' ) + break; + + case 'k': + case 's': val =3D test_bit(31 - j, host_reg); - else - { + break; + + default: ERROR("Bad character '%c' in policy[%d] string '%s'", - xend->policy[i][j], i, xend->policy[i]); - goto fail; + cpuid->policy[i][j], i, cpuid->policy[i]); + goto out; } =20 clear_bit(31 - j, cur_reg); @@ -413,25 +396,19 @@ static int xc_cpuid_xend_policy( set_bit(31 - j, cur_reg); } } - } =20 - /* Feed the transformed currrent policy back up to Xen. */ - rc =3D xc_set_domain_cpu_policy(xch, domid, nr_cur, cur, 0, NULL, - &err_leaf, &err_subleaf, &err_msr); - if ( rc ) - { - PERROR("Failed to set d%d's policy (err leaf %#x, subleaf %#x, msr= %#x)", - domid, err_leaf, err_subleaf, err_msr); - rc =3D -errno; - goto fail; + rc =3D xc_cpu_policy_update_cpuid(xch, policy, &cur_leaf, 1); + if ( rc ) + { + PERROR("Failed to set policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + goto out; + } } =20 - /* Success! */ - - fail: - free(cur); - free(def); - free(host); + out: + xc_cpu_policy_destroy(def); + xc_cpu_policy_destroy(host); =20 return rc; } @@ -439,7 +416,7 @@ static int xc_cpuid_xend_policy( int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore, const uint32_t *featureset, unsigned int nr_feat= ures, bool pae, bool itsc, bool nested_virt, - const struct xc_xend_cpuid *xend) + const struct xc_xend_cpuid *cpuid) { int rc; xc_dominfo_t di; @@ -563,6 +540,10 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t = domid, bool restore, goto out; *p =3D policy.cpuid; =20 + rc =3D xc_cpu_policy_apply_cpuid(xch, &policy, cpuid, di.hvm); + if ( rc ) + goto out; + rc =3D x86_cpuid_copy_to_buffer(p, leaves, &nr_leaves); if ( rc ) { @@ -580,9 +561,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, goto out; } =20 - if ( xend && (rc =3D xc_cpuid_xend_policy(xch, domid, xend)) ) - goto out; - rc =3D 0; =20 out: --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322644; cv=pass; d=zohomail.com; s=zohoarc; b=LtIhTGFrNYAQ29xaE9DpB0wIlCXhO0e1gCywlFOC2t/calHbZl6ZRZ1ojaUEKhhk8ACJM5vNO062rlpQ1SWKW7b7a8rNBP1g4o4ftRfKXJ390bKcD5W+A7GZq4PoRcJaYx8RFshzWFuxWIB1uG30iSJTmaP6ysUOufdz893vYBA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322644; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yfg3EpqS4Xb7uB8bCvTSbNySuLEELrQoy2D2h5/WPGY=; b=PouRmI3TTrEMdXAe35WCunX1OEs1bL86YrguFJEAuibasbm242+mbLaXdbS9MzlBJGcPFREH0KqNbD5jnXVSMv0JaoS21V1j0hIcV+fq7+oRCzBmNyZTA/rVnW9gOEl9TjmqVW38juS2sSB+r4lc/CkJt0C8M8SU7xNORFTrnjA= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322644697347.6681814826777; Tue, 13 Apr 2021 07:04:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109836.209721 (Exim 4.92) (envelope-from ) id 1lWJds-0006a5-Fu; Tue, 13 Apr 2021 14:03:48 +0000 Received: by outflank-mailman (output) from mailman id 109836.209721; Tue, 13 Apr 2021 14:03:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJds-0006Zx-Bt; Tue, 13 Apr 2021 14:03:48 +0000 Received: by outflank-mailman (input) for mailman id 109836; Tue, 13 Apr 2021 14:03:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdr-0006KX-Bn for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:47 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c487b8b6-adbe-429a-bc33-38996c013ab6; Tue, 13 Apr 2021 14:03:46 +0000 (UTC) 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: c487b8b6-adbe-429a-bc33-38996c013ab6 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322626; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=cq7WRx5BpsCYjEAJzUUXhgmQH5KGs74ng/5qh4MPnF4=; b=PY3XZBHfGoA7tdRr7tO2ZPJZrJSPmiDv+j2Ok28y8tm3YR1Uw7oDSG8j Jyc+AwqAB25N8PteJeU2YUpM2f90me5ZIRXaJMGFQ0gAGrARvpYBoGd3C g3dR0JfhZJcq+FOQBm2UL31coOoCemSiWNL84ukdCD5Ffl3xfWisU3wYq A=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: xzoOk2dYXHI5sGJAd5bxzv5J5AgygmBVfQ1pUdlD+YkSHSsmqN3o7qAhg0mXGknDp3LqvPVAY3 apgABNg3iyOhdj5uaJV0o9wBANuGLFM7WqM40QmgJRfC9IHA7RgcsZMR1IBiUvoq382qYt/UNR T4QEWK79eLxQqlW+QSUBtGkr5rQxQP7jW4I+Ik3rKV5cADXzDgqnTV44ncku254aojtPfGq1fw mvf2ltJG0N5kzhpj1bzKetMjxMFEFFi4H0PQxRGKc+exPmuWCkbe6FEr8p7K4FdSq7b3+nxSHw xW0= X-SBRS: 5.2 X-MesageID: 41614008 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:PoNK06HcFfkz5oBxpLqFbZTXdLJzesId70hD6mlYcjYQWtCEls yogfQQ3QL1jjFUY307hdWcIsC7Lk/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeNJwTXzcQY76 tpdsFFZeHYJURmjMr8/QmzG8shxt7Cy6yzmeLC1R5WLD1CQYsI1XYcNi+wFEpqSA5aQacjHJ 2H6cZd4xamc3IbbsO0b0N1I9TrjdvNiZ7gfFo6FwcqgTP+8A+AxZzbN1yj3hkYWy5S2rtKyw b4uiHw+6nLiYDc9jbyzGnWhq4m+ufJ6twGP8CUj9hQFzOEsHfSWK1Ee5mv+A84u/uu7lFCqq i9nz4FM95o433cOkGZyCGdojXI6zol53/8xVLwuxKKyqaYNVFKefZpvo5XfgDU7EAtprhHod h29lmUqoZNClf4lDn9juK4Ji1CrFa+onYpjIco/htieLYZAYUhyLA3zQd+FZcNGz/C84Y3EO ViJ9G03ocpTXqqK1/epWVh29qqQzAaGQqHWFELvoiv3yFRh20R9TpV+OUv2lM7sL4tQZhN4O rJdoxuibF1V8cTKYZwHv0IT8ebAnHEKCi8f166EBDCLuUqKnjNo5n47PEe/+exYqEFy5M0hd DoTE5YnXRaQTOvNeS+mLlwtjzdSmS0WjrgjutE4YJih7H6TL33dQWeVVEVlde6qfl3OLybZ9 +DfLZtR9PzJ2rnHohEmyfkXYNJFHUYWMoJ/vkhXVajpd/KN53KuuTXfO27HsuuLR8UHkfERl cTVjn6I8tNqmqxXGXjvRTXU3TxPmzzlKgAVZTyzqw28swgJ4dMug8ahRCS/ceQMwBPtaQwYQ 9bKLPjmaWrmHmu8Q/zniFUEysYKnwQzKTrUntMqwNPGVjza6w/t9KWfn0X+3ebOBllTYfzHB REr1p6vYK7RqbgixwKOpaCCCa3nnETrHWFQ9M3gauY//rofZs+E9IBQ6x+FQLCEjRvggZ0oG J/aAsJL3WvVQ/GuOGAttg5Fevff95zjEOAOshPs0/Ssk2auIUSXHcBZiWvVsSWmA4qYDJRij RKgugiqYvFvQzqBXo0gew+PlEJTGiMGrpJAD6IY5hulqnxdBt9SnqLgjKmmwg+E1CahHk6ty jEF2m5aPvLCl1StjRj3qHm/EhdW0+dc0hzA0oK+rFVJCDjgDJewOWLbq283y+tcVME2PgaKy yASyAVOBlSy9e+0wO1lD6OGW49/IgnOvXQAd0YAvfu80LoDLfNubANHvdS8pogCcvntfUTV/ mDPyCSNzH1BooSqnqoj0dgHBMxjnYqkfnlgkK4qEe52WMyGvrULhBNQaoBL9SV8mjjQLKp3f xC/KYIlNr1Fl+0TNiMjZzzRXpkDDj4pGatVeEmqZxOp8sJxfNONqiedQGN7W1N2RU1Edz9m0 wfSplq+bypAP4bQ+UiPwZiumcznNuBLEEXohX7L+83c1YqlWLaNbqyks31gItqJkWAoQfqUG PvixF1zrPgXyGZ06QdBL91CWNKaFIk4HAKxpLJS6TgTCGrffpE5ly0LzuUd6JcUrGMHfE1og xh69+F28+ReCyQ4nGcgRJLZoZP+X2gW8W8HUalHvNJ6cWzPRC0uZSRifTDxQvfeH+ccEQXhY pMaEwWYIBis1AZ/fIK+xn3bLf2rEIjm0ZZ+hd9mDfWq9Gb3Fs= X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41614008" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZOSJ6fs7Jda5qlJKKj1FRQheVCHhY02lQwEPzFZi5y7bl4SG4kqgvi+1VgkPDpWVhCCRCL56tZGsACXtYD3hF9tU9u4rMaokYpaqV0JweymuyUeWahY+HCEgKSVAgYPzCvPRQ2XyXSxWmIlHyRf2kLXfJoe11wZzGjQHMGiXncM30pRLEsiqs2ndE8LtcRilV/IE3dunNzlHmZV/TOEXrDmSDSdvfGOAqoEDXMnmryVSdxm0tz+Nv4Q8KDutGuPGmOeiS0BFPZGx4Y0QrCE+Ija8BY44QCjBhBfoIPHedFNUC/+9G1YvBex9F8k9mve4MZhV0ftLCzpswzDmt+1bag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yfg3EpqS4Xb7uB8bCvTSbNySuLEELrQoy2D2h5/WPGY=; b=bKxJukOyvWIKNlL6ThxCezHRGUu0aASvCJN9Wwlsm4mhJ1NCyN3Kb6CoK1lM5loHO+Rz3+ly4+kA6A8zVVTV7aj7SqMQCMTDw14sESRTbhNx+tm40tH+hosKlRsKTaWyA1kDXesIQ1BeaCNJkNJVs67JOUET/uPfy0pZ4B6S4Itw00bWIIoqbpmoMadoNmT3xFqVeYWS311dtyrZzNiJsUDgtiLJXnVELNXLDiHTUlIkous3s/KT+XM/zn70MVz3exCA8VXJVj12odTUwi1nT6D/TNS957grtDiBduU8DBAlcEeOYjB/uLLPxK9lnLoWFMsncUismloYDF57oMYPlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yfg3EpqS4Xb7uB8bCvTSbNySuLEELrQoy2D2h5/WPGY=; b=r2MA396HPbEKem0DYIL8tw+PEzo8w/8mWissdUQtIsS3unLfMorYieXtP4TPro/72MA/wUddLZWvUR4dqhhm1dt01dH8M37DAH+ASd6+qMh49sfMqh7hJMiXwm7pIJfpajpghzoiRuaXHOrsHRrroNqLY3Iayzx+WP3xeFCRkZI= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 19/21] libs/guest: apply a featureset into a cpu policy Date: Tue, 13 Apr 2021 16:01:37 +0200 Message-ID: <20210413140140.73690-20-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0054.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::18) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c20a9d9-7e3b-4209-de21-08d8fe84f22c X-MS-TrafficTypeDiagnostic: DM5PR03MB2969: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eulKJr/ewBlWyflw6ePV2lqjWX3P+cnD3YBhymmCKOGwQs8NJW0D/Z/Zq8qgkvz2PNpxsa1aEgyYkootf71QKGwMbiqKlN5Bn/725TD3LKOGSVmSLDUMuwlVEqrrqbXiyBlWUo4+giD+EahfhgFLkEOQjA6mxH0qm/nYrC/9focEvHo9WSeq4q8hRFzr65+Gm/blsVKTC4xruyfGzN88QfuXTqY2CHpk5hkrB+tqTnTrK+9KPR9KfF6nqPcl6c2EvX3E+oJkZBCu8XIkDltBxmPRPknMe71puheHgQY4Ay/KYnXo7aVmjN/soH0JldcgM0AzJHUA2VrpTC4PKDTlbX8iiHelFnsB8M66BLXTMLCiyVhy6E6VlbgrHu5ktFsI1PkrFHjdT7zB/llJEtAxdxZ4I4FDyujSs6SX+ZPI5E43tuGkaoEeBUzNl/TK99CO9GrI+ZQ0835MzcZ6PcChJicsfbesOZ7/EtllGOrtpWgkYnt5zciGu0LUIbb0QtHmyGBEZpS7W3IvWBG916SvLyagJAfrBBirqo+9kejLSXw+Ea4buboCqU8+uN3jlPcoOsDVWh3rwKc8LEbfyAcxaUBLXjlgGHHx6cCzuWChjhc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(346002)(136003)(39850400004)(366004)(83380400001)(186003)(6496006)(316002)(2906002)(4326008)(36756003)(54906003)(6916009)(2616005)(6666004)(16526019)(26005)(478600001)(6486002)(1076003)(8676002)(8936002)(5660300002)(66556008)(66946007)(86362001)(66476007)(38100700002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?ckMyanJqSGsrUDJXVzlMRjhsVVZ3SXNVWktJVHJpbXZGOU85bWp5aGs2blM0?= =?utf-8?B?OG5nVmtQRGVEUmFCNHh0VGJXRHUrZFlIcmZSOXFuRU51eitReVV0ayttWFph?= =?utf-8?B?U0dUdCtSclZyenE3SWgyYU9RalQrbVhqMk1yUEx6Z1NWK2hXNmpNRFVrN2I4?= =?utf-8?B?M0pJdlRzZWV5enJYcTZ1VGhEODhQTkd5UG91cW5sWWFmSXhZd0V0dDNWSmlU?= =?utf-8?B?cDRjeUNPSDllUVZScGRZVnRRNE5oYWJNQnBCVHdrOXZCOWVkVGNVVjFPdGZL?= =?utf-8?B?aVM2cXhyMHJXa3JhTElVUERiNWtuUmJSV2tBa0RmT2VjcDhiVldWb3M0NFZQ?= =?utf-8?B?am5UUlgrQk5OY3hFVGJzaHhNcVp2dWJ3REsrdnRTejdTM3IzZFRVQkNheE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ajFiVjg0dXlvVlliMlBzeGdZZjBB?= =?utf-8?B?SllSOVFXMzU2a1Jwd2ltNzVCYU1HYVl4RlEwTDdyV2ZRdGtSUnpqNUdDS0x3?= =?utf-8?B?M1JqYmJvdmJqRkhXZ0FMQUxPMnpBZjRwekZLTFJlaW43QjAzcUpRNEdTcVBa?= =?utf-8?B?S2ZpRnlMMDlHTFJCSm1aeGY1d3kzREFSMFFtR1IzY0N5TXFhYjBvZ3NRSHZt?= =?utf-8?B?ZDNweEN2SnFUcmtGMEhVcVkvQS9UNVJ3akNHR2xWVCt4cGVDRFk4WFIrOEZG?= =?utf-8?B?TG5SUHN0TEt2TTZsRHJVQWV1Z3AzWGFTWmVvRkphSjhWK0NKZkZwY0x1aEkz?= =?utf-8?B?TFMxTnFCSUlSY3krMkJvbVo2ZDlwc0VpQW14cFc5LzdvL2RQY0hRRTlSaFkv?= =?utf-8?B?bE9HalNHSnNuTDZlN1owTDFCWWpmSHNSYkw2eFBKdk96RHhCLytPeE1pN3Q5?= =?utf-8?Q?jeBg3vTqYvYUSoP94Qvd0iBF7SDYpCd3cZsmd4z?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4c20a9d9-7e3b-4209-de21-08d8fe84f22c X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:42.6608 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MGU0y1qrO/qX0kBv+NqlI6W64RCq9WKxlhAbOxFCYCU0d/e11g+HRSiRedo/mO39ayuhwYbksOS3bBvmeA3ZAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2969 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Pull out the code from xc_cpuid_apply_policy that applies a featureset to a cpu policy and place it on it's own standalone function that's part of the public interface. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- tools/include/xenctrl.h | 5 ++ tools/libs/guest/xg_cpuid_x86.c | 95 ++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 38 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index ce0785f7654..3fef954d1d1 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2639,6 +2639,11 @@ int xc_cpu_policy_legacy_topology(xc_interface *xch,= xc_cpu_policy_t policy, int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t policy, const struct xc_xend_cpuid *cpuid, bool hvm); =20 +/* Apply a featureset to the policy. */ +int xc_cpu_policy_apply_featureset(xc_interface *xch, xc_cpu_policy_t poli= cy, + const uint32_t *featureset, + unsigned int nr_features); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 06e3e8131d7..b0690d9799d 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -481,46 +481,15 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, =20 if ( featureset ) { - uint32_t disabled_features[FEATURESET_NR_ENTRIES], - feat[FEATURESET_NR_ENTRIES] =3D {}; - static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; - unsigned int i, b; - - /* - * The user supplied featureset may be shorter or longer than - * FEATURESET_NR_ENTRIES. Shorter is fine, and we will zero-exten= d. - * Longer is fine, so long as it only padded with zeros. - */ - unsigned int user_len =3D min(FEATURESET_NR_ENTRIES + 0u, nr_featu= res); - - /* Check for truncated set bits. */ - rc =3D -EOPNOTSUPP; - for ( i =3D user_len; i < nr_features; ++i ) - if ( featureset[i] !=3D 0 ) - goto out; - - memcpy(feat, featureset, sizeof(*featureset) * user_len); - - /* Disable deep dependencies of disabled features. */ - for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) - disabled_features[i] =3D ~feat[i] & deep_features[i]; - - for ( b =3D 0; b < sizeof(disabled_features) * CHAR_BIT; ++b ) + policy.cpuid =3D *p; + rc =3D xc_cpu_policy_apply_featureset(xch, &policy, featureset, + nr_features); + if ( rc ) { - const uint32_t *dfs; - - if ( !test_bit(b, disabled_features) || - !(dfs =3D x86_cpuid_lookup_deep_deps(b)) ) - continue; - - for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) - { - feat[i] &=3D ~dfs[i]; - disabled_features[i] &=3D ~dfs[i]; - } + ERROR("Failed to apply featureset to policy"); + goto out; } - - cpuid_featureset_to_policy(feat, p); + *p =3D policy.cpuid; } else { @@ -1098,3 +1067,53 @@ int xc_cpu_policy_legacy_topology(xc_interface *xch,= xc_cpu_policy_t policy, =20 return 0; } + +int xc_cpu_policy_apply_featureset(xc_interface *xch, xc_cpu_policy_t poli= cy, + const uint32_t *featureset, + unsigned int nr_features) +{ + uint32_t disabled_features[FEATURESET_NR_ENTRIES], + feat[FEATURESET_NR_ENTRIES] =3D {}; + static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; + unsigned int i, b; + + /* + * The user supplied featureset may be shorter or longer than + * FEATURESET_NR_ENTRIES. Shorter is fine, and we will zero-extend. + * Longer is fine, so long as it only padded with zeros. + */ + unsigned int user_len =3D min(FEATURESET_NR_ENTRIES + 0u, nr_features); + + /* Check for truncated set bits. */ + for ( i =3D user_len; i < nr_features; ++i ) + if ( featureset[i] !=3D 0 ) + { + errno =3D EOPNOTSUPP; + return -1; + } + + memcpy(feat, featureset, sizeof(*featureset) * user_len); + + /* Disable deep dependencies of disabled features. */ + for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) + disabled_features[i] =3D ~feat[i] & deep_features[i]; + + for ( b =3D 0; b < sizeof(disabled_features) * CHAR_BIT; ++b ) + { + const uint32_t *dfs; + + if ( !test_bit(b, disabled_features) || + !(dfs =3D x86_cpuid_lookup_deep_deps(b)) ) + continue; + + for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) + { + feat[i] &=3D ~dfs[i]; + disabled_features[i] &=3D ~dfs[i]; + } + } + + cpuid_featureset_to_policy(feat, &policy->cpuid); + + return 0; +} --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322657; cv=pass; d=zohomail.com; s=zohoarc; b=juLyaWcpQJ8nEvgoTSviEYY3UPodHxiejSyV25wVBaeR+255yssLbsVMm7RUhD9vcHqNTtDucJEwNvZgK8tjD60k0fuLaSlAqqcyhCtlW0AHrVxKb9wxzLfqk+eX5ikdvZXzi99CjFa9VHgJODII8GRqk7skZKOJJSz70EoI3Qg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322657; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ESxMv/ykLpGDWIhuuWTbo4Xni3atEDtt5kOgmKjenh0=; b=IblC5ZPCnDhXNJCjRvUIf2pA1igo3bbbog4lKEgEj5ceCU0zaw5AvULpmYk5mQxCxUAgacaOLQjo9p+HKrg5xubZV5u/O/vq9PZ3LWRrCN4NWSOap1pXbbBO0hqdUCVIMIGGhFKgUQusz+hqJUxYlJ9l5bmIRqbjvK4CZYg6Qto= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322657128435.5878531028999; Tue, 13 Apr 2021 07:04:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109844.209733 (Exim 4.92) (envelope-from ) id 1lWJe3-0006m0-2G; Tue, 13 Apr 2021 14:03:59 +0000 Received: by outflank-mailman (output) from mailman id 109844.209733; Tue, 13 Apr 2021 14:03:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJe2-0006ll-St; Tue, 13 Apr 2021 14:03:58 +0000 Received: by outflank-mailman (input) for mailman id 109844; Tue, 13 Apr 2021 14:03:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJe1-0006KX-9G for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:57 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b22a6313-700b-47c6-8043-5dbf28a6fce9; Tue, 13 Apr 2021 14:03:52 +0000 (UTC) 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: b22a6313-700b-47c6-8043-5dbf28a6fce9 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322632; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=1ZGNdKBhjvThEnMln1+LkfE1eKjpN3KTfKSH625bhak=; b=PbnrFhLkr94vYr4zBfwP9MkXVN3fqcVMRWuxDLEqc6rWGX8h4X74vlkL xd3KUqJEOLZdaSY2lXX0cnBA5OdlH3vKWpRM2VG5x8GA8O+PvpbiXV0db czbMlKGCz3/lc94QKGo0PUu6KvzJQok7tPQBajpe5ED5pqWbbU5Dcbke+ A=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 8gAufaKXGEGoDCe6F/F1z2FkpMfLa8gBEpX6ofA5UnhAwguadMcmbXbU/WFfe/EWUGwjieJXvv x2coIsckgwrbUJFpXsdOO4TurK1+uWGhMbzquwTDI6c+UoVFq9tvoAF4PqCXy08y4WW9bfoFRY 9XVNkLBpGh+REAWLo02V99sOp/9og9GnpUqpwqCaXTslNp2tQQg+IwUe1vVWXV1sUKaPOV/wsl zjf/AZAZbl7zQlDKFqKO5tpOEzOach1AGPqw1/KbLcmf044A5xsMlW8btlCzNcYSQdzRDXxdHN C1w= X-SBRS: 5.2 X-MesageID: 42956165 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:SDdhiq4TPknhxP4onAPXwU2EI+orLtY04lQ7vn1ZYSd+NuSFis Gjm+ka3xfoiDAXHEotg8yEJbPoexzh3LZPy800Ma25VAfr/FGpIoZr8Jf4z1TbdxHW3tV2kZ 1te60WMrDNJHBnkMf35xS5Gd48wN+BtJuln/va0m0Fd2BXQotLhj0JbjqzOEtwWQVAGN4FD5 Ka/MVKvH6Nfn4QY8S9CBA+LpT+jvfMk4/rZgN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1P7F8qnvPj1Ee7sCyW3HsjDeHTJ1ojbbcBON2Y53XlQfHN8J gRt6NAgcKAdkHKLviBwuXrShQGDDX5i2u/VfspppBZprhajso6I7DrFR/zkEha1xA/JvrunE wQQK5H8KnMU7UfCvA6SmZ8xB4Vj9yBI0sgjxzuDsI/dV8riWXHP9nh2cu+lZMfRmmIpA79Ij CkglVg1saAeyuIzrgBDa0sZUxQdUgn8XxnldnyPbH4OUGPd+tZ+kC9PWL4WLhBSLKdEbFVih ph+dmHk6u2cCX/sTqg8AdTE+Zr82y9R9m1Dx/JMelU88aiMVDJu5CU2qeI/X7KYAr+TV8Zi4 1DfVERacoGqgBKtvxJ7gGCDortokwklFNC5ypAjVCF4Pn+3Fvm X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="42956165" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5BqyPvZiwpyD6PI1ufOTnddjTPosRJJEyWJ0egR42CDlnUs8beoy93a0rjgv42Jm5zzKOOfRa/OWAi2c4E8v8eEGaJuZN761EnV6rozJRD8VdTxIX9ezqroAwKSK1V/5GpTQ4UBOU2cJA1+K7xo6Tua0JcL389dNoTxGk1M9qcKH037zCxNQ99DL108v0gzGmvd9hgzTTZY1VNrjv0A5IXj8KQEFFmldq+CRMpNVKa6gaHHIxGp12eYtCwlqexRjvzjYHrEYlyN77g1Rrcz1lWiK7bPDnJBLfMpNSalCcebjn0GiXSvVNXyxMWli7Yj2l7vxPQUC9OolG1Xst6oJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ESxMv/ykLpGDWIhuuWTbo4Xni3atEDtt5kOgmKjenh0=; b=f72CMt1U9wmMlKLtcEZ8XsBxvyff6nCTjhS2PDPuhGebhJypXrh+L8aM2Q0PgqgULFcxv7L2yWYSq2k/juElJBmzQ8VLmwHalSEFLdNBdU+ytkOqamU3Vd7E4ZW1EfLGH23ADcbgJK6w/ZO/XAYyHVqiyO65ykSDVR22mLqM6ObknCwPsbV0mWhpCC81x+0Ecc0X2L1GWW4w1NOWy9Q1mmskomeEx7BIjHO94MEcxoZ4FVhmUkS/a2qHG+dz4WtKyh69CX+58lgSw9bch1YjtE88M/gfNI812osd5kwV8EvaN2JsIjDSE8hjb40GS5auDKFYlCuFXgQTUIe8nhNsNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ESxMv/ykLpGDWIhuuWTbo4Xni3atEDtt5kOgmKjenh0=; b=MwHAdH5SouZ5jbYseZvDQB0wZplWETdAgm448rW+Yg/fE15VRD9aaq/XD+rqw4vzeF22Mi9Qi79TbJh8pqiG7xDm1EurKkP40/3vsIGIvkTon2RDEIE4+9JNAmsP65vb5z7LxhDrarkIJ5eRrmDIA5Fkhfdl6vTwK9moNkKetLw= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v2 20/21] libs/{light,guest}: implement xc_cpuid_apply_policy in libxl Date: Tue, 13 Apr 2021 16:01:38 +0200 Message-ID: <20210413140140.73690-21-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0066.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::30) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed5d0484-8858-4498-f588-08d8fe84f5e3 X-MS-TrafficTypeDiagnostic: DM5PR03MB2969: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:153; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TwJ9A6UkPp042MAhw2pkMO0Q81Ql8aqmNaoBnPRHv+LRlGAildlwJXfL9byXCFY0B1b6M6IFJujjhwNPFSlWaWWF6s7xBS73V1sxMqZSLNVQ7HyQRIHDrIl1Tv6drohRrygFF4WWTUZd+vKeJgYGqddH60bZuw9B3JyqGRROI3sJpIpaCwqfcxS0UB0qCzpnWJgn8m9YigRA+NYRosyW8u4bfZPARkuf8TyZzPP8+ZVHZ6IFu4TXMETp3mtwvfhecxraaI7Ks8XN33758Fbvxbc1VGER9ODiDWVQ2V0xc0DcRzpBCQnfnDnR98w6zbCp05x99P4hBu1XvUjg0fWU/oGR48BOvCiRsE9kES2y/DMHN0Gzv3FLRWDAoHvwkVOS/azFbnxd6pzB0bCDVBJgm5sJgbKz/tFaLm2qKxOwmNR7vxrlidMGN1uE99YaQd+e9tc+YYZeiDaiwABFvG8RP98xNA73vDmwAhnZrS2UAXIEa9gGo90lDKS3ZNAAOghagEyC8RY2lUpoR2N2IoPCNL66LL5I/UbzF5NLeBwOLOstjKU3vj1HFcX7bG+wPqehSFaNP0OSB4723lli1W2Dg4VNPsmoaaDxVlEXHqYD6aE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(346002)(136003)(39850400004)(366004)(83380400001)(186003)(6496006)(316002)(2906002)(4326008)(36756003)(54906003)(6916009)(2616005)(6666004)(107886003)(16526019)(26005)(478600001)(6486002)(1076003)(8676002)(8936002)(5660300002)(66556008)(66946007)(86362001)(66476007)(38100700002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?aTl1S2RFQ2J3TmFIYktQWXQrL1dZeTlZZkZITkxlSTBVMm1qWmZSS296NU5O?= =?utf-8?B?ZjVkSXhSbkh5ci9salFodkpDU1FIVkZxTHgxWUM3bFpMWEVBMWovQ0NGa2pS?= =?utf-8?B?dlR4Yk9KcnNlVXRIQk1jeXV4S0lxUG1lMXdyWTBTdHB1ajFxNzNQZlNsb3dY?= =?utf-8?B?cDdBZEd3UllOM1B6clBoTUZ3dHh0dDV5WnY0VUVMYXhQZkVDaUFVR1ZaOHBm?= =?utf-8?B?ckFOOG5lQUJMMERjMzhNczJNLzVoVXdBbVI4TGRPempPRHNIZktSLzVjYkM0?= =?utf-8?B?SjNNY0FjcW1va1RscnVVWXNVRGhnVVhVOENCc3FicnZzZHR3aUVmK3VnTnJV?= =?utf-8?B?NUMyNkJlWFFyM2hMa1h5NXplYkdLbmVKa3lDVHZFZ3Z6ZDM3V2x6NnlyNDBQ?= =?utf-8?B?THZwUTJ5QUp2NndqTnFaN2ZGTXpDR1JMMkIyMDdFMjFVZkM4ZnJ3TUxpQTNz?= =?utf-8?B?L3JiOEpFbDlNWVZjSUR5OFlOYkFGaTFVUHRmWng4bEtBcUJIcGtSc0xTalAw?= =?utf-8?B?VzBaRFI2VXJhclFWZWtac01ZWXFkQWw3RzJIMk5vQkRodWxNcXAram9uYlpQ?= =?utf-8?B?WFlLVHZmOCsrYjJRRVR1ejBIWTA4L0dWc3FFT2Y2anN0YzFOdDBKR2FJLzdI?= =?utf-8?B?Yk5vRnJTaTduUGkvWWdiSUpYZ2ZoKytyWGpGOUlCY2RUV2FXa2ZtdDVtd0xR?= =?utf-8?B?SXdQa2RtOHl2N2QrQjQyeXpPd3d2RFpaSURralJVci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ZEQ3cyZmRyQk96YUtlSERiQ1dWTlAz?= =?utf-8?B?ZXNnajVEME81OENXa0cvRTVqd0huQUhwc0RLUTJKWFhIQWdmSVFrYUlseVBU?= =?utf-8?Q?piqqdVyTc1+gyy2aV2doEFZrk0ytAO6KNRv91zr?= X-MS-Exchange-CrossTenant-Network-Message-Id: ed5d0484-8858-4498-f588-08d8fe84f5e3 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:48.8545 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ysKlc21lzfBBltJB+NthR0nry4CGKnA2jQxmMmQx5D6yOyy8CP7dsvTDeQEBRv5yBn/Vm17NVrlGrlvt+mgDjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2969 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) With the addition of the xc_cpu_policy_* now libxl can have better control over the cpu policy, this allows removing the xc_cpuid_apply_policy function and instead coding the required bits by libxl in libxl__cpuid_legacy directly. Remove xc_cpuid_apply_policy. Signed-off-by: Roger Pau Monn=C3=A9 --- tools/include/xenctrl.h | 18 ----- tools/libs/guest/xg_cpuid_x86.c | 126 -------------------------------- tools/libs/light/libxl_cpuid.c | 87 +++++++++++++++++++++- 3 files changed, 83 insertions(+), 148 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 3fef954d1d1..c6ee1142e8e 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1890,24 +1890,6 @@ struct xc_xend_cpuid { char *policy[4]; }; =20 -/* - * Make adjustments to the CPUID settings for a domain. - * - * This path is used in two cases. First, for fresh boots of the domain, = and - * secondly for migrate-in/restore of pre-4.14 guests (where CPUID data was - * missing from the stream). The @restore parameter distinguishes these - * cases, and the generated policy must be compatible with a 4.13. - * - * Either pass a full new @featureset (and @nr_features), or adjust indivi= dual - * features (@pae, @itsc, @nested_virt). - * - * Then (optionally) apply legacy XEND overrides (@xend) to the result. - */ -int xc_cpuid_apply_policy(xc_interface *xch, - uint32_t domid, bool restore, - const uint32_t *featureset, - unsigned int nr_features, bool pae, bool itsc, - bool nested_virt, const struct xc_xend_cpuid *xe= nd); int xc_mca_op(xc_interface *xch, struct xen_mc *mc); int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags, xc_cpumap_t cpumap, unsigned int nr_cpus); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index b0690d9799d..70ca4939392 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -413,132 +413,6 @@ int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_c= pu_policy_t policy, return rc; } =20 -int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore, - const uint32_t *featureset, unsigned int nr_feat= ures, - bool pae, bool itsc, bool nested_virt, - const struct xc_xend_cpuid *cpuid) -{ - int rc; - xc_dominfo_t di; - unsigned int nr_leaves, nr_msrs; - xen_cpuid_leaf_t *leaves =3D NULL; - struct cpuid_policy *p =3D NULL; - struct xc_cpu_policy policy =3D { }; - uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; - - if ( xc_domain_getinfo(xch, domid, 1, &di) !=3D 1 || - di.domid !=3D domid ) - { - ERROR("Failed to obtain d%d info", domid); - rc =3D -ESRCH; - goto out; - } - - rc =3D xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs); - if ( rc ) - { - PERROR("Failed to obtain policy info size"); - rc =3D -errno; - goto out; - } - - rc =3D -ENOMEM; - if ( (leaves =3D calloc(nr_leaves, sizeof(*leaves))) =3D=3D NULL || - (p =3D calloc(1, sizeof(*p))) =3D=3D NULL ) - goto out; - - /* Get the domain's default policy. */ - nr_msrs =3D 0; - rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault - : XEN_SYSCTL_cpu_policy_pv_defa= ult, - &nr_leaves, leaves, &nr_msrs, NULL); - if ( rc ) - { - PERROR("Failed to obtain %s default policy", di.hvm ? "hvm" : "pv"= ); - rc =3D -errno; - goto out; - } - - rc =3D x86_cpuid_copy_from_buffer(p, leaves, nr_leaves, - &err_leaf, &err_subleaf); - if ( rc ) - { - ERROR("Failed to deserialise CPUID (err leaf %#x, subleaf %#x) (%d= =3D %s)", - err_leaf, err_subleaf, -rc, strerror(-rc)); - goto out; - } - - /* - * Account for features which have been disabled by default since Xen = 4.13, - * so migrated-in VM's don't risk seeing features disappearing. - */ - if ( restore ) - { - policy.cpuid =3D *p; - xc_cpu_policy_make_compatible(xch, &policy, di.hvm); - *p =3D policy.cpuid; - } - - if ( featureset ) - { - policy.cpuid =3D *p; - rc =3D xc_cpu_policy_apply_featureset(xch, &policy, featureset, - nr_features); - if ( rc ) - { - ERROR("Failed to apply featureset to policy"); - goto out; - } - *p =3D policy.cpuid; - } - else - { - p->extd.itsc =3D itsc; - - if ( di.hvm ) - { - p->basic.pae =3D pae; - p->basic.vmx =3D nested_virt; - p->extd.svm =3D nested_virt; - } - } - - policy.cpuid =3D *p; - rc =3D xc_cpu_policy_legacy_topology(xch, &policy, di.hvm); - if ( rc ) - goto out; - *p =3D policy.cpuid; - - rc =3D xc_cpu_policy_apply_cpuid(xch, &policy, cpuid, di.hvm); - if ( rc ) - goto out; - - rc =3D x86_cpuid_copy_to_buffer(p, leaves, &nr_leaves); - if ( rc ) - { - ERROR("Failed to serialise CPUID (%d =3D %s)", -rc, strerror(-rc)); - goto out; - } - - rc =3D xc_set_domain_cpu_policy(xch, domid, nr_leaves, leaves, 0, NULL, - &err_leaf, &err_subleaf, &err_msr); - if ( rc ) - { - PERROR("Failed to set d%d's policy (err leaf %#x, subleaf %#x, msr= %#x)", - domid, err_leaf, err_subleaf, err_msr); - rc =3D -errno; - goto out; - } - - rc =3D 0; - -out: - free(p); - free(leaves); - - return rc; -} - xc_cpu_policy_t xc_cpu_policy_init(void) { return calloc(1, sizeof(struct xc_cpu_policy)); diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index 539fc4869e6..cadc8b2a05e 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -423,6 +423,8 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid,= bool restore, libxl_domain_build_info *info) { GC_INIT(ctx); + xc_cpu_policy_t policy =3D NULL; + bool hvm =3D info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM; bool pae =3D true; bool itsc; int rc; @@ -436,6 +438,42 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid= , bool restore, */ bool nested_virt =3D info->nested_hvm.val > 0; =20 + policy =3D xc_cpu_policy_init(); + if (!policy) { + LOGE(ERROR, "Failed to init CPU policy"); + rc =3D ERROR_FAIL; + goto out; + } + + rc =3D xc_cpu_policy_get_domain(ctx->xch, domid, policy); + if (rc) { + LOGE(ERROR, "Failed to fetch domain %u CPU policy", domid); + rc =3D ERROR_FAIL; + goto out; + } + + /* + * Account for feature which have been disabled by default since Xen 4= .13, + * so migrated-in VM's don't risk seeing features disappearing. + */ + if (restore) { + rc =3D xc_cpu_policy_make_compatible(ctx->xch, policy, hvm); + if (rc) { + LOGE(ERROR, "Failed to setup compatible CPU policy for domain = %u", + domid); + rc =3D ERROR_FAIL; + goto out; + } + } + + rc =3D xc_cpu_policy_legacy_topology(ctx->xch, policy, hvm); + if (rc) { + LOGE(ERROR, "Failed to setup CPU policy topology for domain %u", + domid); + rc =3D ERROR_FAIL; + goto out; + } + /* * For PV guests, PAE is Xen-controlled (it is the 'p' that differenti= ates * the xen-3.0-x86_32 and xen-3.0-x86_32p ABIs). It is mandatory as X= en @@ -446,8 +484,15 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid= , bool restore, * * HVM guests get a top-level choice of whether PAE is available. */ - if (info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM) + if (hvm) pae =3D libxl_defbool_val(info->u.hvm.pae); + rc =3D libxl_cpuid_parse_config(&info->cpuid, GCSPRINTF("pae=3D%d", pa= e)); + if (rc) { + LOG(ERROR, "Unable to set PAE CPUID flag: %d", rc); + rc =3D ERROR_FAIL; + goto out; + } + =20 /* * Advertising Invariant TSC to a guest means that the TSC frequency w= on't @@ -463,12 +508,46 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domi= d, bool restore, */ itsc =3D (libxl_defbool_val(info->disable_migrate) || info->tsc_mode =3D=3D LIBXL_TSC_MODE_ALWAYS_EMULATE); + rc =3D libxl_cpuid_parse_config(&info->cpuid, GCSPRINTF("invtsc=3D%d",= itsc)); + if (rc) { + LOG(ERROR, "Unable to set Invariant TSC CPUID flag: %d", rc); + rc =3D ERROR_FAIL; + goto out; + } + + /* Set Nested virt CPUID bits for HVM. */ + if (hvm) { + rc =3D libxl_cpuid_parse_config(&info->cpuid, GCSPRINTF("vmx=3D%d", + nested_virt)= ); + if (rc) { + LOG(ERROR, "Unable to set VMX CPUID flag: %d", rc); + rc =3D ERROR_FAIL; + goto out; + } + + rc =3D libxl_cpuid_parse_config(&info->cpuid, GCSPRINTF("svm=3D%d", + nested_virt)= ); + if (rc) { + LOG(ERROR, "Unable to set SVM CPUID flag: %d", rc); + rc =3D ERROR_FAIL; + goto out; + } + } + + /* Apply the bits from info->cpuid if any. */ + rc =3D xc_cpu_policy_apply_cpuid(ctx->xch, policy, info->cpuid, hvm); + if (rc) { + LOGE(ERROR, "Failed to apply CPUID changes"); + rc =3D ERROR_FAIL; + goto out; + } =20 - rc =3D xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0, - pae, itsc, nested_virt, info->cpuid); + rc =3D xc_cpu_policy_set_domain(ctx->xch, domid, policy); if (rc) - LOGE(ERROR, "Failed to apply CPUID policy"); + LOGE(ERROR, "Failed to set domain %u CPUID policy", domid); =20 + out: + xc_cpu_policy_destroy(policy); GC_FREE; return rc ? ERROR_FAIL : 0; } --=20 2.30.1 From nobody Sat Nov 30 01:53:53 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322660; cv=pass; d=zohomail.com; s=zohoarc; b=XI/IcHfUE8iSyZ/1Vgz8n31THwiSxYLCHYkAiP6ak2QywQPl1cOlKoMxnoLANraQNQfCc2LhbMtIDdlQxNwUoKQDFH77GQGGRJBLlwTraiYLk0ZZkkGaXP/xW7x37xiAsb8O5HoGzJNnHQogxZiZLj5czNeUZuFCgpg4j8llJgU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322660; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4Zx32cQTy4/2mKyZxLklN9EMm3hZTZZ5DreDlJpjcSA=; b=OhE9KT1aurxIhVpz+2wF4gjtgulJeEnKhHJS4u/miiGJSIMKRPoO9pTI8IjcdqmQueA0I9avj4mFqX0eODMaeu2CwTZ7vm2ewFMY8xK/F7HksOxI2BpN9f2u3IseYLUyg4gZ4HOMnfB61T+kia5lCt+3x+snRWHa5RiRI3Q0q7s= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322659872953.8406140130668; Tue, 13 Apr 2021 07:04:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109846.209745 (Exim 4.92) (envelope-from ) id 1lWJe6-0006r0-DV; Tue, 13 Apr 2021 14:04:02 +0000 Received: by outflank-mailman (output) from mailman id 109846.209745; Tue, 13 Apr 2021 14:04:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJe6-0006qs-8V; Tue, 13 Apr 2021 14:04:02 +0000 Received: by outflank-mailman (input) for mailman id 109846; Tue, 13 Apr 2021 14:04:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJe4-0006oj-KM for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:04:00 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a1dd7163-05d5-4bdb-a40b-534c9a1db758; Tue, 13 Apr 2021 14:03:59 +0000 (UTC) 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: a1dd7163-05d5-4bdb-a40b-534c9a1db758 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322639; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=QzwwOkwqoS7FecsC8ab+hi6QGGGojhwL/w3/xIfFNS0=; b=d4ngdGa3rC9mqAEwYFODP5VHYeWvi6oNDwuzdKdXDK7xpOl0DgYxl0yv vknCFL5mf5Q40GDBjds9DMIN2MYr95cT+fv/TK2J+2omyO8NAWOcmkS95 clLfyYGqt9uKOqlfu5TOQFtSCHI94GNw4SOSYnh9MqyG734N9AbFoRLIh o=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 801o5y8ArO4H+IwmsY+XelcXNY+C/snEXWlqK4dzbAL5TtOhFEToh7BTJWgcYlzYB5Blf+PVdl zTR4KnyAPF06hlJxfdB6XMQrDTr/dKZ3loG/Xtr1Bb0mdAlbYc7hntdUeX4PyE/ODRSq7LZu24 IO1NTq17J3res4E6F6jI2KQLvMT+pwCMMDltUAQRaGHhS3OuFJ/1zZcA1Jh4ACMok0HGwgiVR/ g+aKfggyIcfHarlLqNyWihJAov6dVmIxz/TOclOqBrWA/Ycze8VjZyfkEkdgM7na3AaLQqShV+ jNY= X-SBRS: 5.2 X-MesageID: 41322512 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:2x3PWa4k8s2QDmvRuQPXwTqFI+orLtY04lQ7vn1ZYSd+NuSFis Gjm+ka3xfoiDAXHEotg8yEJbPoewK+ybdc2qNUGbu5RgHptC+TLI9k5Zb/2DGIIU3D38Zn/+ Nbf6B6YeeQMXFTh8z3+RT9Nt4mzsWO/qzAv5au815GZ2hRGthdxi1+DRuWFVAzYQFAC4YwGp b03Ls2mxOLf3MLYsOnQkQURuSrnayKqLvKQz4jQyQm5g6HkC+y5NfBYnql9zoXTj8n+8ZezU HriAr8j5/T1M2T6hiZ7GPL6oQTpd2J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Tn3h1KaJttY+qx8tb4utbd1ApnQWSbJ0nYCxxklMMLoji olMdFGyaGENYl1c8MIfSVFulIvidSUNUMu9hf7G+kkYDgW/jDmFsLM57rDsrw0BEKd4AP2JF mE6iVYls21EherxPofC6gqJ35RZ1V54HN+/Pmaf4mVDAmxbelM8B67NXC6GYUtBJStCPEVrh xg5cuPkPLSfy3k2BrItT8+O7lQ6Q+cMIuPKRPJHfQN/82xOFyKjKfv6MmvjC3vQT/+b0gDn4 VKeUEZc8wrsEhtsKQnliypDqDnqEMslFVTpStqkVPgwYCq6mbWF0MuC3ySvrxGGT1IdnSYh8 XM9uaVkGnn6D9ewJ/ZCQNeeMpNF9V4dPm3Ew5+bcwL+Lim8Kokjn4dPFMgD2sghCv82O0j17 Gjw/nWU/DjD3CtOV9pw08yOqdk2igw7WdHeIyi6Jj4ZAMdHOsBGeE+6YBbiygBkCm503QMKx F28hU13YTMJEH9N3tyFaLyjZL76SJo05Sq+hlrvjFMgVuph1GXpkjtk8u0s3QyqXfBrgUPk9 TVeBIhxCBDtgBmxqR9Mn2CFW70KEn1RG/K8A== X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41322512" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aWdJ2DwP8uIgdlJmVhozPuTRRWQ8SLY3fdwVH14LYUa3vN2apBJKg9mFOpF3gBZhnIfa5dMXsnT+iMyRKtV4wbZMyrZdNlXxs67dqAOS3ToK4RBzC1ohQfYWAdE6gLNpLxG3Rtq7sLYRH02XUDagwubqfmL40cOTUoLFo+GEIzGfdXcS627/y+HBSEhcW8/EYiynhIHE+pc7C6966cV8phEyqnkjpHdjNxlXf9WFixJJph12Ad94TwUI1laOlTJuwaDsoKNdl/BVEJ1QgXxHrA/+PIPGEMblE+9uJuPUTNxx7jAe+yF0KTF7XJLSxcolOLTa/IPlVpW7CEPZK2ZgvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Zx32cQTy4/2mKyZxLklN9EMm3hZTZZ5DreDlJpjcSA=; b=OK99UAP8k8ah3pMc43IR3IzuExZwFtzCS/pWH4MKblK0Tos+WiYzXn7PbXfXwcSa6lyxiDuyP2hNIrTHaoh25Wo8yj3DTAFZKU0WBvoRqXg+C3bXnrKbFMrxlLgL8AqnhTSvkq310BvDBVA7ReV62hgcANuXfVzLmqHNROzCUP9BX5UqblYOAMOfa7kUmQmX0Au2YlN4dBwHjmk2txZH3DBOPyYO/et0tDAzea2pND5qFbtDhpiXp27isSLlj4djRkapEeVIexaBKaZgJ5wGXWe7xmFM7YOJdzdei2kVVC+MmftUv3YvfHjOJAV2XI4fTwdKvXoBSDgmvSFM8cZHsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Zx32cQTy4/2mKyZxLklN9EMm3hZTZZ5DreDlJpjcSA=; b=LcfVD4gILPZz5yOqcvX5q3DuG5XTuoG9alF6oGgxlfZjyLYuFPgv5fRlc3TE7PfPSouwqRVDzG3AKUheE5kV2LILKDJekXRp9EyqXOpeP/6t56KxTLOSP5PZZX/7j9nEbWfG2xS+Y0l+SGbU4hcK8HnYHXw10WijR3L4NaKtFT4= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v2 21/21] libs/guest: (re)move xc_cpu_policy_apply_cpuid Date: Tue, 13 Apr 2021 16:01:39 +0200 Message-ID: <20210413140140.73690-22-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0063.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::27) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27ab9fdf-274d-4f2e-da52-08d8fe84f961 X-MS-TrafficTypeDiagnostic: DS7PR03MB5605: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:272; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LlUfZdAJqmO4QlEL5nF4y6iBRXrNLZMAxE5c9mSijVrh1fiRnD04KQabjZY6RAAKyS4wdZ32gifPJZ7+9zG2fzxx4LhPjAyWd+3DwI/CRLOowPCB5EOOLCKzuikWAXgYK8BhyD6jWlbq1yT24qYbHFcSjjFETX+rm2RCRaA/Poe7XTMHDFjIxuG4WSUMD2QlugJfaXiTEqdLxppf8R7j5UcKB/cLFNM++sO8EO70QgAy0VUPh+4GNZCaGRaQ/ulV6wdsBRbKGq8+A3jUU6yqw8in4PjMmjFVqreUlWdqxyn/spSskD3NPv1qWadWQJZ7s5SPEH7VC1sEdIcR/oNo3iFfFnClLV8QUGQDZGOj50HOySXaqKNv6kPKArfj5zmOrKKyi+0pMzgroNadPGguZ0w1T2E+QpDNLL5Hqh80Ci/mlQ2CYnv3Tnda7hXvUYIMmsjwW9xqUio6s7seJm+v/lpaN3bpmEc2LQEWPml8iDGb58/0Q9axdD7xSIEx1d614RIWUgBZAoaToXleoacqz/oTUxnqCeDcVLdMtKChfH51rJW85SEcxgtVioXDUTgVAQYCxMNn+16v+Z6KxNbt5g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39850400004)(136003)(346002)(396003)(376002)(366004)(1076003)(6916009)(38100700002)(86362001)(478600001)(6496006)(6666004)(107886003)(2906002)(30864003)(83380400001)(956004)(26005)(66946007)(66556008)(66476007)(2616005)(16526019)(54906003)(36756003)(4326008)(8676002)(6486002)(8936002)(5660300002)(186003)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?TG5Ed1BtK0J3bzZHcEtSRzhneHNibGJnSHVWbWM5a3JqQ0c4dElOZDUyaS91?= =?utf-8?B?RDhQQ3cxZGx4SUd5YjhzKytQblU1ckY4dkNERXFmLzg2R2duS0E1WmlEcVdX?= =?utf-8?B?bGhCS0pxWk9Bb1E5eUJjOWFwdFNadHQvY2l5dk1OcC9TUGdVbDcrVWdmczNl?= =?utf-8?B?ZDU5ZUdUVVlSZGd0eXFxcHU4TlI0VnZuUzlBTjJ6V1VMT0JVL3lOWjRxRU92?= =?utf-8?B?eEZ6VHJZazJqbG85TEZVSUhkY0ZMbTdPbmdjaVVPalJPQWtkOXVRSFZ6d09S?= =?utf-8?B?MFFWQjJVWnhuYW5SQ1AvVUUyWG95b0x0QkRtemRrSHptOTZGeHQ4L0ZOUDBm?= =?utf-8?B?UzkyeUlnMEI5LzFJR2h5Z0thRUxnL1dMa0d3RnY1cG9SMlQ5UGNnLzRnMTdQ?= =?utf-8?B?YXFMYzVFMU1NdURRYXgzbFdKU1ZaWEV4MDArT1lzVDA5UjhWaGNJOEdIaFdh?= =?utf-8?B?UDVtcjlCazNXTDZyQktBNkxYUWFVdXhJUXloQU5vZjV0L2ZCWitPQ2QrTFFn?= =?utf-8?B?ZUIxWVRDZ2hFallBa091VlRFb3BxcjUrejNNU25rd2tXMFpPOFJicjU5eUx4?= =?utf-8?B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NWZXWUpjNjdG?= =?utf-8?B?RFN6WnMwQi9BK0FiaEtDdWRiR3U2bUxGWTVxVFBsUWhzTjNZM2JrTTFuZmd0?= =?utf-8?B?NVJZa0s1MkliZlNOR1BpZ0pnVXRzQXFSbENBL0swbkc5UjV0ZStnVHlsWVhQ?= =?utf-8?B?R0JEQWR3N1NXYklLcFVsVjBSWXFiSThJenhLRVgxckJ5VHdQL0JXRWVZaXgw?= =?utf-8?B?aDdVT2o2TWJUVm51UmdvTE1SL1VKMlVNUlpjVmc2YXhKQWtjYS9kS1pZRmpr?= =?utf-8?Q?9lj6bpj/xlsbYpjXvDrR/d+wy40Y5PBDFWmnKpe?= X-MS-Exchange-CrossTenant-Network-Message-Id: 27ab9fdf-274d-4f2e-da52-08d8fe84f961 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:54.8063 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: e0HOU1kVmtq6C/VQbTVYNrLsmqp9zGHyBmtdOfyme1Z2C8YFCZpWvdjAk8OdV/3+cOrkfeHcTs3eVRxg33V0Mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5605 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Move the logic from xc_cpu_policy_apply_cpuid into libxl, now that the xc_cpu_policy_* helpers allow modifying a cpu policy. By moving such parsing into libxl directly we can get rid of xc_xend_cpuid, as libxl will now implement it's own private type for storing CPUID information, which currently matches xc_xend_cpuid. Note the function logic is moved as-is, but requires adapting to the libxl coding style. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- tools/include/libxl.h | 6 +- tools/include/xenctrl.h | 30 ------- tools/libs/guest/xg_cpuid_x86.c | 125 --------------------------- tools/libs/light/libxl_cpuid.c | 136 +++++++++++++++++++++++++++++- tools/libs/light/libxl_internal.h | 26 ++++++ 5 files changed, 162 insertions(+), 161 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index ae7fe27c1f2..150b7ba85ac 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -1375,10 +1375,10 @@ void libxl_bitmap_init(libxl_bitmap *map); void libxl_bitmap_dispose(libxl_bitmap *map); =20 /* - * libxl_cpuid_policy is opaque in the libxl ABI. Users of both libxl and - * libxc may not make assumptions about xc_xend_cpuid. + * libxl_cpuid_policy is opaque in the libxl ABI. Users of libxl may not m= ake + * assumptions about libxl__cpuid_policy. */ -typedef struct xc_xend_cpuid libxl_cpuid_policy; +typedef struct libxl__cpuid_policy libxl_cpuid_policy; typedef libxl_cpuid_policy * libxl_cpuid_policy_list; void libxl_cpuid_dispose(libxl_cpuid_policy_list *cpuid_list); int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *l); diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index c6ee1142e8e..044d05321a3 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1864,32 +1864,6 @@ int xc_domain_debug_control(xc_interface *xch, =20 #if defined(__i386__) || defined(__x86_64__) =20 -/* - * CPUID policy data, expressed in the legacy XEND format. - * - * Policy is an array of strings, 32 chars long: - * policy[0] =3D eax - * policy[1] =3D ebx - * policy[2] =3D ecx - * policy[3] =3D edx - * - * The format of the string is the following: - * '1' -> force to 1 - * '0' -> force to 0 - * 'x' -> we don't care (use default) - * 'k' -> pass through host value - * 's' -> legacy alias for 'k' - */ -struct xc_xend_cpuid { - union { - struct { - uint32_t leaf, subleaf; - }; - uint32_t input[2]; - }; - char *policy[4]; -}; - int xc_mca_op(xc_interface *xch, struct xen_mc *mc); int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags, xc_cpumap_t cpumap, unsigned int nr_cpus); @@ -2617,10 +2591,6 @@ int xc_cpu_policy_make_compatible(xc_interface *xch,= xc_cpu_policy_t policy, int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t polic= y, bool hvm); =20 -/* Apply an xc_xend_cpuid object to the policy. */ -int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t policy, - const struct xc_xend_cpuid *cpuid, bool hvm); - /* Apply a featureset to the policy. */ int xc_cpu_policy_apply_featureset(xc_interface *xch, xc_cpu_policy_t poli= cy, const uint32_t *featureset, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 70ca4939392..5144b186028 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -288,131 +288,6 @@ static xen_cpuid_leaf_t *find_leaf( return bsearch(&key, leaves, nr_leaves, sizeof(*leaves), compare_leave= s); } =20 -int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t policy, - const struct xc_xend_cpuid *cpuid, bool hvm) -{ - int rc; - xc_cpu_policy_t host =3D NULL, def =3D NULL; - - host =3D xc_cpu_policy_init(); - def =3D xc_cpu_policy_init(); - if ( !host || !def ) - { - PERROR("Failed to init policies"); - rc =3D -ENOMEM; - goto out; - } - - /* Get the domain type's default policy. */ - rc =3D xc_cpu_policy_get_system(xch, hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault - : XEN_SYSCTL_cpu_policy_pv_defa= ult, - def); - if ( rc ) - { - PERROR("Failed to obtain %s def policy", hvm ? "hvm" : "pv"); - goto out; - } - - /* Get the host policy. */ - rc =3D xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host, host); - if ( rc ) - { - PERROR("Failed to obtain host policy"); - goto out; - } - - rc =3D -EINVAL; - for ( ; cpuid->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++cpuid ) - { - xen_cpuid_leaf_t cur_leaf; - xen_cpuid_leaf_t def_leaf; - xen_cpuid_leaf_t host_leaf; - - rc =3D xc_cpu_policy_get_cpuid(xch, policy, cpuid->leaf, cpuid->su= bleaf, - &cur_leaf); - if ( rc ) - { - ERROR("Failed to get current policy leaf %#x subleaf %#x", - cpuid->leaf, cpuid->subleaf); - goto out; - } - rc =3D xc_cpu_policy_get_cpuid(xch, def, cpuid->leaf, cpuid->suble= af, - &def_leaf); - if ( rc ) - { - ERROR("Failed to get def policy leaf %#x subleaf %#x", - cpuid->leaf, cpuid->subleaf); - goto out; - } - rc =3D xc_cpu_policy_get_cpuid(xch, host, cpuid->leaf, cpuid->subl= eaf, - &host_leaf); - if ( rc ) - { - ERROR("Failed to get host policy leaf %#x subleaf %#x", - cpuid->leaf, cpuid->subleaf); - goto out; - } - - for ( unsigned int i =3D 0; i < ARRAY_SIZE(cpuid->policy); i++ ) - { - uint32_t *cur_reg =3D &cur_leaf.a + i; - const uint32_t *def_reg =3D &def_leaf.a + i; - const uint32_t *host_reg =3D &host_leaf.a + i; - - if ( cpuid->policy[i] =3D=3D NULL ) - continue; - - for ( unsigned int j =3D 0; j < 32; j++ ) - { - bool val; - - switch ( cpuid->policy[i][j] ) - { - case '1': - val =3D true; - break; - - case '0': - val =3D false; - break; - - case 'x': - val =3D test_bit(31 - j, def_reg); - break; - - case 'k': - case 's': - val =3D test_bit(31 - j, host_reg); - break; - - default: - ERROR("Bad character '%c' in policy[%d] string '%s'", - cpuid->policy[i][j], i, cpuid->policy[i]); - goto out; - } - - clear_bit(31 - j, cur_reg); - if ( val ) - set_bit(31 - j, cur_reg); - } - } - - rc =3D xc_cpu_policy_update_cpuid(xch, policy, &cur_leaf, 1); - if ( rc ) - { - PERROR("Failed to set policy leaf %#x subleaf %#x", - cpuid->leaf, cpuid->subleaf); - goto out; - } - } - - out: - xc_cpu_policy_destroy(def); - xc_cpu_policy_destroy(host); - - return rc; -} - xc_cpu_policy_t xc_cpu_policy_init(void) { return calloc(1, sizeof(struct xc_cpu_policy)); diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index cadc8b2a05e..6be2d773d1d 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -291,7 +291,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *c= puid, const char* str) char *sep, *val, *endptr; int i; const struct cpuid_flags *flag; - struct xc_xend_cpuid *entry; + struct libxl__cpuid_policy *entry; unsigned long num; char flags[33], *resstr; =20 @@ -369,7 +369,7 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_li= st *cpuid, char *endptr; unsigned long value; uint32_t leaf, subleaf =3D XEN_CPUID_INPUT_UNUSED; - struct xc_xend_cpuid *entry; + struct libxl__cpuid_policy *entry; =20 /* parse the leaf number */ value =3D strtoul(str, &endptr, 0); @@ -419,6 +419,136 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_= list *cpuid, return 0; } =20 +static int apply_cpuid(libxl_ctx *ctx, xc_cpu_policy_t policy, + libxl_cpuid_policy_list cpuid, bool hvm) +{ + GC_INIT(ctx); + int rc; + xc_cpu_policy_t host =3D NULL, def =3D NULL; + + host =3D xc_cpu_policy_init(); + def =3D xc_cpu_policy_init(); + if (!host || !def) { + LOG(ERROR, "Failed to init policies"); + rc =3D ERROR_FAIL; + goto out; + } + + /* Get the domain type's default policy. */ + rc =3D xc_cpu_policy_get_system(ctx->xch, + hvm ? XEN_SYSCTL_cpu_policy_hvm_default + : XEN_SYSCTL_cpu_policy_pv_default, + def); + if (rc) { + LOGE(ERROR, "Failed to obtain %s def policy", hvm ? "hvm" : "pv"); + rc =3D ERROR_FAIL; + goto out; + } + + /* Get the host policy. */ + rc =3D xc_cpu_policy_get_system(ctx->xch, XEN_SYSCTL_cpu_policy_host, = host); + if (rc) { + LOGE(ERROR, "Failed to obtain host policy"); + rc =3D ERROR_FAIL; + goto out; + } + + for (; cpuid->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++cpuid) { + xen_cpuid_leaf_t cur_leaf; + xen_cpuid_leaf_t def_leaf; + xen_cpuid_leaf_t host_leaf; + + rc =3D xc_cpu_policy_get_cpuid(ctx->xch, policy, cpuid->leaf, + cpuid->subleaf, &cur_leaf); + if (rc) { + LOGE(ERROR, "Failed to get current policy leaf %#x subleaf %#x= ", + cpuid->leaf, cpuid->subleaf); + rc =3D ERROR_FAIL; + goto out; + } + rc =3D xc_cpu_policy_get_cpuid(ctx->xch, def, cpuid->leaf, cpuid->= subleaf, + &def_leaf); + if (rc) { + LOGE(ERROR, "Failed to get def policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + rc =3D ERROR_FAIL; + goto out; + } + rc =3D xc_cpu_policy_get_cpuid(ctx->xch, host, cpuid->leaf, + cpuid->subleaf, &host_leaf); + if (rc) { + LOGE(ERROR,"Failed to get host policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + rc =3D ERROR_FAIL; + goto out; + } + + for (unsigned int i =3D 0; i < ARRAY_SIZE(cpuid->policy); i++) + { + uint32_t *cur_reg =3D &cur_leaf.a + i; + const uint32_t *def_reg =3D &def_leaf.a + i; + const uint32_t *host_reg =3D &host_leaf.a + i; + + if (cpuid->policy[i] =3D=3D NULL) + continue; + +#define test_bit(i, r) !!(*(r) & (1u << (i))) +#define set_bit(i, r) (*(r) |=3D (1u << (i))) +#define clear_bit(i, r) (*(r) &=3D ~(1u << (i))) + for (unsigned int j =3D 0; j < 32; j++) { + bool val; + + switch (cpuid->policy[i][j]) { + case '1': + val =3D true; + break; + + case '0': + val =3D false; + break; + + case 'x': + val =3D test_bit(31 - j, def_reg); + break; + + case 'k': + case 's': + val =3D test_bit(31 - j, host_reg); + break; + + default: + LOG(ERROR,"Bad character '%c' in policy[%d] string '%s= '", + cpuid->policy[i][j], i, cpuid->policy[i]); + rc =3D ERROR_FAIL; + goto out; + } + + clear_bit(31 - j, cur_reg); + if (val) + set_bit(31 - j, cur_reg); + } +#undef clear_bit +#undef set_bit +#undef test_bit + } + + rc =3D xc_cpu_policy_update_cpuid(ctx->xch, policy, &cur_leaf, 1); + if ( rc ) + { + LOGE(ERROR,"Failed to set policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + rc =3D ERROR_FAIL; + goto out; + } + } + + out: + xc_cpu_policy_destroy(def); + xc_cpu_policy_destroy(host); + GC_FREE; + return rc; +} + int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore, libxl_domain_build_info *info) { @@ -535,7 +665,7 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid,= bool restore, } =20 /* Apply the bits from info->cpuid if any. */ - rc =3D xc_cpu_policy_apply_cpuid(ctx->xch, policy, info->cpuid, hvm); + rc =3D apply_cpuid(ctx, policy, info->cpuid, hvm); if (rc) { LOGE(ERROR, "Failed to apply CPUID changes"); rc =3D ERROR_FAIL; diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 5709bcb93fa..d130c073ac4 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -2050,6 +2050,32 @@ typedef yajl_gen_status (*libxl__gen_json_callback)(= yajl_gen hand, void *); _hidden char *libxl__object_to_json(libxl_ctx *ctx, const char *type, libxl__gen_json_callback gen, void *p); =20 +/* + * CPUID policy data, expressed in the internal libxl format. + * + * Policy is an array of strings, 32 chars long: + * policy[0] =3D eax + * policy[1] =3D ebx + * policy[2] =3D ecx + * policy[3] =3D edx + * + * The format of the string is the following: + * '1' -> force to 1 + * '0' -> force to 0 + * 'x' -> we don't care (use default) + * 'k' -> pass through host value + * 's' -> legacy alias for 'k' + */ +struct libxl__cpuid_policy { + union { + struct { + uint32_t leaf, subleaf; + }; + uint32_t input[2]; + }; + char *policy[4]; +}; + _hidden int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool retor= e, libxl_domain_build_info *info); =20 --=20 2.30.1