From patchwork Tue Mar 23 09:58:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 12157337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A07DFC433DB for ; Tue, 23 Mar 2021 10:00:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51BEF619B9 for ; Tue, 23 Mar 2021 10:00:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51BEF619B9 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.100558.191674 (Exim 4.92) (envelope-from ) id 1lOdpn-0007nF-D8; Tue, 23 Mar 2021 10:00:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 100558.191674; Tue, 23 Mar 2021 10:00: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 1lOdpn-0007n7-8w; Tue, 23 Mar 2021 10:00:23 +0000 Received: by outflank-mailman (input) for mailman id 100558; Tue, 23 Mar 2021 10:00: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 1lOdpl-0006c2-Ue for xen-devel@lists.xenproject.org; Tue, 23 Mar 2021 10:00:21 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 32db4eeb-74d3-4558-b643-b0ec1e9c8a9f; Tue, 23 Mar 2021 10:00:06 +0000 (UTC) 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: 32db4eeb-74d3-4558-b643-b0ec1e9c8a9f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1616493606; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=US6kAIf+2labk2oCST9gZ6uChRGzP0iC69NC7ePJygg=; b=BJErWs9/beJOB+kvaEcC/6x8Dq+z+Dk1KS5f7KilDEOsZtzYkyOw838Y EXfLA3b9efDoUdTJXxN5YoB+7aXrPKjT0+d0iQYEMwlskIVzMHpcXNRGz ukK40NVaOS3WDp+jGsrF1z/YDJgKz46cwNwF2R/Yjgsx67v2u/9r1oVg2 E=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: GVSMCNCdokr7gSpcFW22ITltZD8ODexzTt+VH+cZHrxf4xTk98NRvEB5x25qrcf/nKuvJg0+r3 DWi+bbARwa00W0oIY9khdGpDycK7xOyrPEOnS9gTeChH3NwDxSu0QiIothywpu6vz7AHuPCGGF dEuaj5zkNV0K2VBBI5IfKYlDGLLwZzc1rfBzZ2Qg/qdkpAk0XJlgsX8AxGKnjzwjg4Xde4j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QNKVnIfbEKvMjaZXpfx2KdJhh0T9rfFQ lWo1gfw9P0E7WggQQZT/63OGOTiHUe4E+QR5AHg6uZ+IPOYZUjFKsrX6R3CCTGHxF4ghxRtW 9GcQMIL3WvUw/GuOGAttg0DPuaX8RgiA2rSPQk0k73hAG5n4UTYVc1GxSpStWahA4yQSE8vC wKz4YvxICvt3KDC0saxN45PlpNb2r/OsMeMC21IL97tPTOV2hLPCG3rA3fsT8cPlHHzXk2uw XaXGqpUMCOOHRy/kx9+oLR0H4cTBTYQ2tALk1f9aVGUUrtnFFduNX7Ppab23eNa1cE3+EWOC zEZzxXOQ9129Wrzneu6Uq/PHE9xowZO+TXALE4Goujp0+FOcmGk7oLEORT+4sgPNfysvUTWe baYAONKijkYtlZkjC9tzIgOCNurmMjnu6t0Br57HKg1HpXO4ukHH12A7UaKcqb9W7qWrKB14 h4l8s8ua+1Pn/qYtCLjaHRYDgrEGKknUemC+Upo4tTp6Q8qf96GITaSyLB0DVfxwolRf2E5n 82UeB++vTMK4Vvd8sdd2ZQ+Ucojs2GKA8uvhbtCuEzcFkxhxbgTpu0yquNraBqDlyKpQP2N1 Xa6SFb8vvfVyaI1LIRCcsLUBBrQVl57G4n8PKJdoXWBgnvavpK+0CiNGShNLBaU6qIFNwr32 VHysDNm/XScSX22Ard52QmZq1P9nuqWsO0DkaHH/VS/9mzJFSLhe+r7aeI/UbKYCr+b15dg4 tPMVEUZIBEjDIpiYUsyCi8SqDtuCse4i5jyCAikkSow5Ss5WfQAFpPPgLYiIhHRDU7CAn3se 3VteyDkGnn6DdL2ZPfBF5dc9FHFd8XVJX2JU5VWLgtla/t+bEujCRFaAovCGB5iCmV5ZIY4Y uE X-IronPort-AV: E=Sophos;i="5.81,271,1610427600"; d="scan'208";a="39900265" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gXJ1iYuw4/bok+tKQ7fDpj75KpBnWo4cbSXSA/uzhFay4Clfuk6Yy+Xaga1sfOfENCEcLJm1fCuSMwXNf9RzMWr+6zlgesRerDbRR7AlWJ0dosMdKX6xJwLfvvxSGDbIx5FbsobMiOfkFSOpVE5+Ggd/Y+IwOK2Pf8rQhwtKW25nP7YDfwu4f9L89rYd7u8bChBwjwRryxZTlZlvKboUV+G/Vmwix/h5zlugyOHLvWJkEFhyyATFFD3lO53FqahAeCBsEhIeygeb0hVckq/uxH1HfYSoSOYI5Zn3PCNlLGrX2n7E5F5rp8gNuYA2EYiy9p5jR2iP4DCS7KvdfKe0nA== 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=x96POU3Rped/M3iZclAcVyiA8U+JKnNokSoJ4Bo8H4w=; b=QxxxS9mldxbpf9U1yhZOnwLE6bEk3bWXn9cIUhc8mvrYLFrT+ZrOJzK9HX8twmgpLPPa2/moPgsPrnQBAuzmWHFJ2iqSkwqrvAf/X2Wg2y9XC++4DAl2bMDK/2vwpXNc9UekJMPDsFasX2mvNqilVRWxf48Lgoed2CdAlgM3KkrHChhQ9QVMCMSxNnw9f6NQQD/cL8jl4j347Im5IeE0oHZtGL8s/YaF41sAJ9qOf3cLSHqsZ2DQ5+QVgNefTwbANlswGdOx4w4Fweny/pYgUwedZ8USyEQe3XNmusygdOM5Cj0eUYKK60r04cS9njej5hbM2Amy7P1jkdUlU0vq2g== 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=x96POU3Rped/M3iZclAcVyiA8U+JKnNokSoJ4Bo8H4w=; b=Gjt71eSLm2Rh1h7PKyIkj3J3bWVSc+qJcvBFSa4wkS7cPVWzSkDjt5eWNAbV4ImxEsAwG7kFoOTFqCYBIf2B9qpSQBqgVmZiw4iimiYn6EWfv4Mqow9+gklK8U/jRNIcRhfT2WnGOPz+6gULCswHaGX1RSacjj+jN8oXMsg3ZZo= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH 06/21] libs/guest: introduce helper to serialize a cpu policy Date: Tue, 23 Mar 2021 10:58:34 +0100 Message-ID: <20210323095849.37858-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210323095849.37858-1-roger.pau@citrix.com> References: <20210323095849.37858-1-roger.pau@citrix.com> X-ClientProxiedBy: MR2P264CA0151.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1::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: 5d183e04-e412-4789-dd82-08d8ede26cd2 X-MS-TrafficTypeDiagnostic: DM5PR03MB2633: 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: 9ElZibxGi0gY3rzpH2bdPuQKaMOd+JXXqyFRdbKV7brYJ/SP4ra9BnmIvvUHdrF61HfMvXJFFuieeqF4rOd+QAvzZkjPczBQrz1iwYdhTAW7RYsS08MjsYx0sHh9PfdEDJwF0R+0FRBruWhtKZTeLG38BAvApYKpVGwSWSbFU93VRYJYhyQocu5uFLI1/N91VU6CnRWJozdAaVCEazP+7PBZYuRKNFI5G0gCzsaH74ykwuRwd+QKrbJ5e/gU6dG7jT7cja7Et6vnpdmGp4bh1/pSpL0FNUeJoMqqs16P7/NsD5nEO63xjG7L31VMj54dEHucaxacq9UGQ5suhpm+ORCVqrU8JnczpGPYon+kQBaK2Y0VIWPDFaOQd6/k45sSc/yVl0hEuCIvJtwasKE9n0p2qEzTp4E5iA2O9qhAkCp9YXchFdmzEXN5dE7K1HPxG+SZSJjxL+lEVOzyPSduzxZWKBUEwAxvDNTSQUmuFgXPPjsGsBuvKasU/V2nsDyI0hx3CIQonHuoFiK0Se+ZdEB8cLXgMlRmTifGv4gE9n7ncwHC4ubCCH6Duvz3yAt2G4bvyKefM8KBl8zfKo2t0fWCG3HaOwYBe0UVIebdnGAUOKkzhv+yuNir8YAKeFNoS2yUQCogIZE29bFHVmZldR7da2TjuoCI/qWUwxa1PHQ= 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)(136003)(39860400002)(366004)(376002)(346002)(6486002)(6916009)(36756003)(6496006)(2906002)(8676002)(66476007)(5660300002)(186003)(66556008)(66946007)(8936002)(86362001)(4326008)(54906003)(83380400001)(1076003)(16526019)(316002)(2616005)(38100700001)(956004)(6666004)(478600001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?VgJa7aujtqNwgKxz6oomgNCAXnJRk7?= =?utf-8?q?nEWtL5gWF5tSzc7d37YI7ySxB2vmBp3lSdfLdNs2iaUdpaH0OaDqcGbBsu6gnZ3Wm?= =?utf-8?q?1EexyEGqltP0tRT/dd7AlK04uHBLmxK+0JIf7XIHC/uTk9owm3QSqcy5APJnxCI30?= =?utf-8?q?NwDnlCqqRasK8Rl/1ysSyP55QCo4prCw7CJxOgMwEJ7JcgC5ZYPKxAX4Rt9EVxZFW?= =?utf-8?q?1p3xB4pyiegdPAqXn85G0AXsfIkHWvjm4QtQ/1Z0Dnm/kyHwjFWeOKysZI6K68B0Z?= =?utf-8?q?AMfAs2hTcC4b5c2BUcFjBrBEbgnntaK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NfIFiCaxWmb54gX+dOhNmc3HDZD44Ai+v1cWwhlNLeMGE5?= =?utf-8?q?Y75W4A27ZHjcOzlIPiTRnzepWGO6IsdvSAZ5ZIQ7FrdsEH8/npoNr7AEPK7blcZ36?= =?utf-8?q?hPSI/btMhD/h6t?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5d183e04-e412-4789-dd82-08d8ede26cd2 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2021 10:00:01.9076 (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: lN9TRHtbaV08ZQ+u5C0zWpFawoQxB9E4CeaGr5Xfe66nK8L5KK7/2FySigun1/LIdJ8AU7aq/qvEhP2d87nL9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2633 X-OriginatorOrg: 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é --- 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 8b8b30a2764..983bb027a04 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2602,6 +2602,11 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned int idx, int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, xc_cpu_policy_t policy); +/* Manipulate a policy via architectural representations. */ +int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t policy, + 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_x86.c index 75ac70996ac..812ef14fbcd 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -811,3 +811,35 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, free(msrs); 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 = x86_cpuid_copy_to_buffer(p->cpuid, leaves, nr_leaves); + if ( rc ) + { + ERROR("Failed to serialize CPUID policy"); + errno = -rc; + return -1; + } + } + + if ( msrs ) + { + rc = x86_msr_copy_to_buffer(p->msr, msrs, nr_msrs); + if ( rc ) + { + ERROR("Failed to serialize MSR policy"); + errno = -rc; + return -1; + } + } + + errno = 0; + return 0; +}