From nobody Sat Nov 30 03:31:16 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/T1M2T6hiZ7GPL6oQTpd2J8Ko8OOWpquw4bgrhkRypYoMJYczAgBkQrPu04Fgn1P ngyi1QQ/hb0H/acmGrrRaF4WCJu1pAhQ6GuDulqEDursDjSDUxB9Apv/MnTjLi90EisNtguZ g7p16xiptNARvM2AT76tTYPisa7HacnHs4neYfy0FYSIsVAYUh1rA3wUU9KuZnI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tBJStCPEVrh 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?cGhCOXhhdEhzTjFuN2pBWE1Pd0JtL3NKZHhFZmMrckEzMVNwTTJLTjloWmtx?= =?utf-8?B?K2RvdUM3bW1VV1F6emVGTGVhTVNaR1pWSXNGZUFEcnNjeEpWNEgzTHZUQkdn?= =?utf-8?B?RTRWaC9xenRhbTF1VWRxci9UW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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