From patchwork Tue Mar 23 09:58:33 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: 12157331 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 E401CC433DB for ; Tue, 23 Mar 2021 10:00:19 +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 9D6FC619AB for ; Tue, 23 Mar 2021 10:00:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D6FC619AB 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.100552.191650 (Exim 4.92) (envelope-from ) id 1lOdpR-0006ta-Nb; Tue, 23 Mar 2021 10:00:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 100552.191650; Tue, 23 Mar 2021 10:00:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lOdpR-0006s8-Im; Tue, 23 Mar 2021 10:00:01 +0000 Received: by outflank-mailman (input) for mailman id 100552; Tue, 23 Mar 2021 10:00: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 1lOdpQ-0006iw-10 for xen-devel@lists.xenproject.org; Tue, 23 Mar 2021 10:00:00 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5283454a-2c91-43a8-b4f5-40d42cda4fee; Tue, 23 Mar 2021 09:59:59 +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: 5283454a-2c91-43a8-b4f5-40d42cda4fee DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1616493599; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=sKTDxYJ3rj7iDKcoGoTCGrSKTjWKjCAlgiHohEHoEzI=; b=C7/phOo+BQQc99HiH15nG6eILjbcUvmWtgaV4PLtZ5KN4Uk0Yjjo9olg 7oNlvtC1pwY+uo6scR+ZbQConk6Pr+1+B6eEXEyFTp1TYIwhYazz0jY9p ROATDUSxr9c9Bck0FdRvfxRW7gkHOp/gyP7pe014DIKHsjUUf51uXzisp g=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 05RJMFpPOZsEkpnGZ4UWBWfrkNvB7rlXZK1avQKDnL2LNL8pcGWvqp33TA0n0La6yYR3KoWAaR FXmCZ4XShXC2KxuTLZOm7tqVVeQkoYAWz3tOep4RcCACLwFSD8yD+7F5pZLHQyQQffOrMEH1B8 9NN+zWkRCbjsq9mVLs/qVMUvLlyXZ6V0atOK3Xm9Ieb0BOJmB6XdXxrucsUBGuJI5znnUBAK05 zFcBS+Fc28lcpgFdxHHCDYaf7G9DUTAdq5TH81Oatd1p3bTPCbNem5Rf7+Tc17m6SCH4BMHndZ HKw= X-SBRS: 5.2 X-MesageID: 40261142 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:8NXDdaxVIRa8umfn2WASKrPxqe4kLtp033Aq2lEZdDV8Sebdv9 yynfgdyB//gCsQXnZlotybJKycWxrnmqJdybI6eZOvRhPvtmftFoFt6oP+3ybtcheTysd07o 0lSaR3DbTLYGRSpdrm4QW+DtYryMSG9qftvuvF03JxV2hRCp1IxS0RMHf+LmRdQg5aCZ0lUK eG7s1cqDa6PVgRZMK3Bn4KNtKz2+HjvpTgfBIAGlob+BCD5AnYlYLSPjq5+lMlUz1Jyao/6m StqWLEz4iqrv3T8G6760b99JJT8eGRqOdrJMvJscQNLyWptwDAXvUbZ5SnnBQY5N6i80wrlt 6kmWZRA+1W52nKdm+45TvBsjOQqQoG0HPpxV+GjXaLm6WQL1hbeqkx975xSRfX51Etu9txys twrhiknqFaEA/am2DF78XIPisa53acm2YokuIYkhVkIOwjQYJWxLZvmX99IdMrGSL3750fC+ 9+DM3Qz+Y+SyLlU1np+kZo29CiRXI1A1OvRVUDoNWc13xskGl+1FZw/r1Sol4wsLYGD7VU7e XNNapl0JlIU88tdKp4QMMMW9G+BGDhSQ/FWVjibmjPJeUiATbgupT36LI66KWBY5oT1qY/n5 zHTRdxqXMyU1iGM7zP4LR7tjT2BEmtVzXkzc9To7JjvKfnebbtOSqfDHgzjsqbpekFCMGzYY fzBLtmR9vYaUf+E4dA2APzH7NIL2MFbcETstEnH32UpMbmLZDrq/z7fP7fKKGFK0dnZkrPRl 84GBTjLsRJ6U6mHlXihgLKZn/rckvjubJ8eZKqutQ7+cwoDMlhowIVgVO26oWgMjtZqJE7e0 N4PffCmqO/rm+mwHbQ4wxSS15gJ3cQxI+lf2JBpAcMPU+xW60Eoc+jdWdb22bCARNjUcXMEk p6q05s8ay6a7ycrBpSRe6PAya/tT8+tXiKR5ATlumo/sH+YK41CZ4gRehWDgXEFxt8nC5ws2 ddYAo4RkvSfwmeypmNvdgxPqXyZtN8iACkLYp/snTEr3iRoskpWz8mRTK0aNWWhgwvXjJQoV V0/8Yk8f29sAfqDVF6rPUzMVVKZmjSJL5dFgyKaL9Zna3RdBhqQX2HgiGbjB8PanPnnn9i9V DJHGmxQ7XmE1BdsndX3uLR/FR4en60UmhwZnp52LcNXljuizJW66umd6Cz22yeZh8+2ekbKi jCeiZXCBhp3cqL2BmcnyuiGX0qyo41BPHUCK0uftjoqzWQAbzNsZtDM+5f/Z5jOtyrj/QCVv iHfRSJaBz/EOEk1mWu1wAYERgxjENht/zm2BfotjflmFE+BOffO1RgSfUwJcqG423tWvaP19 FYgLsOzJ+NG1S0TuTD76fdKwNnAFf0h0WdSukzs5Bava4ortJIbtHmeAqN8EsC5Qk0Kcf/qV gXT6t66o3QI4MHRb1mRwtpun4S0OmVJEQlsgbKEvYzUFEkgXjcJc6I6dPz2M0SK3zEgAPxPF WFmhcth8vtbm+m1bQADbg3LnkTQE8g6G569OfqTfybNCyaM8VC9kG9KHmzbft0T7WEA6wZql Jf78uTl+GaMwr+1wa4h0o3Hot+t0KmS9i1GgSCBKph9MG7I02Fhu+S2/GI5Q2HAAeTWgA/no 1KdUsZc8RFhH0DteQMo1ePY52yhFkknVtY6SxgjXj31OGdkT7mIX0= X-IronPort-AV: E=Sophos;i="5.81,271,1610427600"; d="scan'208";a="40261142" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ikA4WW9FVNw8sQq9FVBmUh2iYFw9X8pd5utQylRER89bmHB7IM1Q73QOfIgqgOrueBwlcy9rzxVuD0GiL+stTP01zHWwzTF2jNK3aPabZQ0wteb+TtTEYT5OabZa8gZ6v1wNuaRJvLxsLUKZL8cDBB5EbDeKulc5EmIiREUfUzbCGt+lul3LnlNaZALQr1SNMCsWPbL0RDEZZmbPhtLp/bhVo4dadAplTCuVomw6Ad45ORump55z7kpFiXWnVcCLtj6tYGXuoIw8kVmnhM0Q2+4RwmJHSHh9ff6Z+l6cmDBuNsrqF3lad9d+8c55W44KXivR6hDs8LiE8Hm4x5W+Gg== 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=XiniRgb9Usi7cOKyAntrG74P2w6ZoVZ1eSYmJ4efxZU=; b=PdEDnW8tL8CSRxxAukw/wrUPNe7sjHUYj8wARYpMVvtWW+fbfYvG6UkFcGlaHkXqTJ/4ymSusy1va8xxRrBTDjB49GYP1vPZrTPiKR9ldSjKF2nKvtczaDOtNdlBVb2ZGvtIl8K9PcFXSLQwyYCYheNjjNnfP/h3Unlil+JpSDJV1UxjYxfYF0WrZb4nCLzpZilyyoLv++YsMCeiKDzGFSPO27wIgORZ8vBACikK13WQxag7Q0AaPZNajo3RwBkbcs9XqEDRXNaucHvybVz55lj0Yqw/2FWd6C/QMP8c08FZkqsLiPKNg5ARoCORgIcpPf3f95EhZcvBlrW4E3wnKQ== 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=XiniRgb9Usi7cOKyAntrG74P2w6ZoVZ1eSYmJ4efxZU=; b=RBOajU+Tjs0IsUqY2oJPzIPeEOy8aOQqNpcQXvkBUyrHpeO2jWy2zJdNTB4PSP64At1fJgyXMaqV+AcH6elYkXUvyF5kayK3vBe8XzqbtQWSThe3ctK+iQN3vulb0j8hEq9QWu+uKdHIy//VGyipWaOWpCM3BKQ39QPpu5ttsXw= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH 05/21] libs/guest: introduce helper to fetch a domain cpu policy Date: Tue, 23 Mar 2021 10:58:33 +0100 Message-ID: <20210323095849.37858-6-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: MR2P264CA0124.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:30::16) 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: 31fd0c1b-e2e9-4a97-4847-08d8ede26874 X-MS-TrafficTypeDiagnostic: DM5PR03MB2633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:529; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K8GrBI1odyLIpbb0bCGG8EdkjagxIrpA1WBzJiz7XN3Y9RIFGI6HhdgnuLFtCwtvZbXzGdyvcMhvWIK1J0AdZot3HVidqqsCG5ME0sek4NAVVEibR2Sxx8KKZV619TIhr68uG7yxRhCT1DN7GnXgxWr5Tau3cxY+ZeTLWI3HsvPi6BeuL8HpcOXo+xPfskJAFfycoSyV0tQXbCjyO0GRJlT3N3YUoFs7OsjH+cWJFBBDbXDN+VdY675tiwLgAgIw8Q7ZIRLU50Tjd0EGgYUH7XaoVW+Z/wNH5bN6CjX8+gTNN88ALyxCmBFwfp9e5q6OnZue9GzVgzNKyiXMkdKaoaywv1TqkQvt/r8Yuu5xcrNXmNzkZcXl+vrR43ych4baXTD4afXsdaN4X1zunFTi4qNIkaMnyK7+0nGS/siWAeZO9goo8MFkWkJcNXo+4HR8iYCUfdtTexl8DL7DjQRH8vZ2s039m3nICcI15P93fQRyHYOWjYCVhJhah+BNcNE+058+/lD/l9jNZSw1nVphDfQx80QJ85MDIfG9SkQl+2f3M4Xcu4YZQvHeAlQMV8P/s6Ulie2lJlzFwUGyUfiBg0EjCqZ+Lsqb8mDVmpwhfNClRoykxZORAUg7vVGNPq+9wu8ercLsys/nYK1fx4Z6y0RSYdvo2jJ4bzsxfmZImv4= 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)(1076003)(16526019)(316002)(2616005)(38100700001)(956004)(6666004)(478600001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?zl1vtnp4DXEJauVvYjiOv950O23VfY?= =?utf-8?q?K0mcT1BJycsdySfnCuX/CVcdJMWwo9R4xcA89CniiMeIcqbvXJqlLWxTRzNYPfJay?= =?utf-8?q?l/nG2uO4yiRT7kfGLVHR1FpJ8yeNuIzIlMAEVWYH7OtU7Cb2tQzBQecDWaX8vbfxl?= =?utf-8?q?ELeI6eSNJ0LoQ/KKGv0REVaZ62KPOMgdJHNGnaGW3J1XQnQgxaolXpX8rfLb2430x?= =?utf-8?q?NEnuT6c05mC4rGGDnwzLGQW/98HGeCTS/Wfw2HzmBgY55q6cH7W4Jsmo1k5vQLsWk?= =?utf-8?q?4nBPrOQeNOCACG4KhP8PLfM3u0YF0NUrdlDx2Frz7x2nXBh5ELcmqaPbl7eP0i4yT?= =?utf-8?q?1kTYD2HtkGR5RZYR486Oo/ZXYOBgxLxZMDilYG/yGc+OjQoDGNlOCbqy2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NHmjGVq+j5kV?= =?utf-8?q?7CWC+6tWqTqMSr?= X-MS-Exchange-CrossTenant-Network-Message-Id: 31fd0c1b-e2e9-4a97-4847-08d8ede26874 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2021 09:59:54.5848 (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: o3flLIZS9a+/qHR8u2FBopZvPkjJX6OnSDjyqkq9bjb7eU3e5ND+EhFilGQkNXBbcCutF68/ItZ/Er5X4aWPTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2633 X-OriginatorOrg: 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é Reviewed-by: Jan Beulich --- tools/include/xenctrl.h | 2 ++ tools/libs/guest/xg_cpuid_x86.c | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index fc8e4b28781..8b8b30a2764 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 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_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_x86.c index 3710fb63839..75ac70996ac 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -777,3 +777,37 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned int idx, free(msrs); return rc; } + +int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, + xc_cpu_policy_t policy) +{ + unsigned int nr_leaves, nr_msrs; + xen_cpuid_leaf_t *leaves = NULL; + xen_msr_entry_t *msrs = NULL; + int rc; + + rc = allocate_buffers(xch, &nr_leaves, &leaves, &nr_msrs, &msrs); + if ( rc ) + { + errno = -rc; + return -1; + } + + rc = xc_get_domain_cpu_policy(xch, domid, &nr_leaves, leaves, &nr_msrs, + msrs); + if ( rc ) + { + PERROR("Failed to obtain domain %u policy", domid); + rc = -1; + goto out; + } + + rc = deserialize_policy(xch, policy, nr_leaves, leaves, nr_msrs, msrs); + if ( rc ) + errno = -rc; + + out: + free(leaves); + free(msrs); + return rc; +}