[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] libs/guest: Don't hide the indirection on xc_cpu_policy_t
- To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Wed, 5 May 2021 13:48:26 +0100
- 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
- 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=Ub4M/GWmyHWtkeJT2tdNFtjKNc4K3WCG6uiAH6ukya8=; b=VURdLGdke9j39ashAI/3tZTSBxHSn+ULVuW2Cqbs/pKg3eTo0WGbdiDYrFtzLizLayn9Fl6On4zvq3Bjgq81hG5/HS2kjG2FN6fLdfwHkeJYD8fmwuEEFOJiJyPZV4mPitxMCiVX9jMvlKlTLLzpLCwmDTZBsOdp7/BY2YCLT5pkyGq7qQGA92/YcePQLPs73rD167PWi8D9r829RO2QXw3FeAUv6e1p3b8jk4YxywAWgYNSmoDAZrJU4vDbnFeKnFeOBdm26Yw/Ji0n2yAWeyUyqUnwKNH8h6njO5g37mYrp/2aOLKHqNDKKWayEXIKcpvoUTCl9+130Y2Dpfo+WQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dGosTBbUazwChBWkWRQwmEIIG2XbvE5u/jdlzEulTuHFAYbqm1GQR+87suKbvBZeF6uYa2wwTu4grQpmd1nWT7yqd69wzbn+LGD008y7OgnQ12wnZalGSkMBRG4HDdC7QqKBl/DkSWNgG/2/7wmOMI21FoL5KteoaqK/NN/4wqgdkzYWJ8l+8XomVZAcfZQufcpucrF7NTnUZXIfJUIBuflRMSLVpHXE+jqB9BbpHC63XDESDu3zQ3k3qNXTYlyqdwC/8SUp7MXnHODGGjTkPO6MjUoHxzoQz9XU+0nDW2ery0K/h4v3QTLznQchs+F9Y95InMwTf5hsibC9AHhDBg==
- Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Wed, 05 May 2021 12:48:44 +0000
- Ironport-hdrordr: A9a23:b52ZXKp4K/VZ7T4snOPqkhYaV5v5L9V00zAX/kB9WHVpW+SFis Gjm+ka3xfoiDAXHEotg8yEJbPoex7h3LR+iLNwAZ6JWg76tGy0aLxz9IeK+UyFJwTS1M54kZ 1hfa93FcHqATFB5/rSzQGkH78br+Wv37uvgY7loUtFaSFPR+Ve4xxiCgCde3cGITVuIZYiDp KT6o5milObCBcqR/+2DHUEQOTPzuej/P7bSCULGgI97022hS6ogYSQLzGjwhwcXzlTqI1Sk1 TtrgqR3MSemsD+8DDw/Sv575NamNzuo+EzefCku4wuBRjHziqtbIRlcbWesD4yu/HH0idXrP D85y0OEu42x3TNfnykgRaF4Xie7B8er0XM5HXdoXz/rdf3TDg3YvAx+75xQ1/ixGcL+PRfuZ g7uF6xht5sIj7r2BnZ3ZzuUSpnk0KlyEBS6tI7vjhkfqY1LINKoZd3xjIyLL4wWBjUxaoAC+ dUAMTV9J9tACmnRkGchGVpzdC2N05DZyuucwwHssyR5TBcgGp0+Use3NAehXcN7vsGOuF529 g=
- Ironport-sdr: Z9ygEBp4flUhp/PoZOetOKPAwIRDwpSFB3P5f9krA4fwvrv4LA23BZC8aV0HGxYtpcNeJPMOGD /ceYYbNtAcWSw1R09+1l06lrSbf/yDOgzuTn6tE6hkJ1a3YlFhT2d5D8EIHD+8uHGnzbalCuSG caIhuEckjrzyv9xzmvEOsno3jRwHhqNus9OkVM3W/3+FX2+VYHD+7jb4BjW3MJUL/GflWDvukO DuH89nyOhNZCWfcf+zkU/8iNLZksBiHaovgTlsroVLNR05GjfMHsEPP/lYDJtFUfWqhUoh511Z pHA=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 05/05/2021 10:16, Roger Pau Monné wrote:
> On Tue, May 04, 2021 at 07:53:22PM +0100, Andrew Cooper wrote:
>> It is bad form in C, perhaps best demonstrated by trying to read
>> xc_cpu_policy_destroy(), and causes const qualification to have
>> less-than-obvious behaviour (the hidden pointer becomes const, not the thing
>> it points at).
> Would this also affect cpuid_leaf_buffer_t and msr_entry_buffer_t
> which hide an array behind a typedef?
They're a total pain because in userspace, they're plain arrays, and in
Xen, they're GUEST_HANDLE's.
Hiding arrays in a typedef like that (unlike hiding pointers) doesn't
change the interaction with const.
So the code there is correct AFAICT, even if it doesn't appear so.
>> xc_cpu_policy_set_domain() needs to drop its (now normal) const
>> qualification,
>> as the policy object is modified by the serialisation operation.
>>
>> This also shows up a problem with the x86_cpu_policies_are_compatible(),
>> where
>> the intermediate pointers are non-const.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Thanks.
>> ---
>> CC: Jan Beulich <JBeulich@xxxxxxxx>
>> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>> CC: Wei Liu <wl@xxxxxxx>
>>
>> Discovered while trying to start the integration into XenServer. This wants
>> fixing ASAP, before futher uses get added.
>>
>> Unsure what to do about x86_cpu_policies_are_compatible(). It would be nice
>> to have xc_cpu_policy_is_compatible() sensibly const'd, but maybe that means
>> we need a struct const_cpu_policy and that smells like it is spiralling out
>> of
>> control.
> Not sure TBH, I cannot think of any alternative right now, but
> introducing a const_cpu_policy feels kind of code duplication.
At least this is all internals. We've got time and flexibility to
experiment.
~Andrew
|