All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Sergey Dyasli <sergey.dyasli@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>,
	Daniel de Graaf <dgdegra@tycho.nsa.gov>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH v2 12/13] x86/sysctl: Implement XEN_SYSCTL_get_cpu_policy
Date: Wed, 18 Jul 2018 00:45:05 -0600	[thread overview]
Message-ID: <5B4EE1F102000078001D5301@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <c4c02662-2fbc-dd10-301c-6fe8836bbd52@citrix.com>

>>> On 17.07.18 at 18:50, <andrew.cooper3@citrix.com> wrote:
> On 16/07/18 12:54, Jan Beulich wrote:
>>>>> On 13.07.18 at 22:03, <andrew.cooper3@citrix.com> wrote:
>>> @@ -322,6 +323,76 @@ long arch_do_sysctl(
>>>          break;
>>>      }
>>>  
>>> +    case XEN_SYSCTL_get_cpu_policy:
>>> +    {
>>> +        const struct cpu_policy *policy;
>>> +
>>> +        /* Bad policy index? */
>>> +        if ( sysctl->u.cpu_policy.index >= ARRAY_SIZE(system_policies) )
>>> +        {
>>> +            ret = -EINVAL;
>>> +            break;
>>> +        }
>>> +        policy = &system_policies[
>>> +            array_index_nospec(sysctl->u.cpu_policy.index,
>>> +                               ARRAY_SIZE(system_policies))];
>>> +
>>> +        /* Request for maximum number of leaves/MSRs? */
>>> +        if ( guest_handle_is_null(sysctl->u.cpu_policy.cpuid_policy) )
>>> +        {
>>> +            sysctl->u.cpu_policy.nr_leaves = CPUID_MAX_SERIALISED_LEAVES;
>>> +            if ( __copy_field_to_guest(u_sysctl, sysctl,
>>> +                                       u.cpu_policy.nr_leaves) )
>>> +            {
>>> +                ret = -EFAULT;
>>> +                break;
>>> +            }
>> Could I talk you into avoiding the redundancy here and fold this
>> copying with ...
>>
>>> +        }
>>> +        if ( guest_handle_is_null(sysctl->u.cpu_policy.msr_policy) )
>>> +        {
>>> +            sysctl->u.cpu_policy.nr_msrs = MSR_MAX_SERIALISED_ENTRIES;
>>> +            if ( __copy_field_to_guest(u_sysctl, sysctl,
>>> +                                       u.cpu_policy.nr_msrs) )
>>> +            {
>>> +                ret = -EFAULT;
>>> +                break;
>>> +            }
>>> +        }
>>> +
>>> +        /* Serialise the information the caller wants. */
>>> +        if ( !guest_handle_is_null(sysctl->u.cpu_policy.cpuid_policy) )
>>> +        {
>>> +            if ( (ret = x86_cpuid_copy_to_buffer(
>>> +                      policy->cpuid,
>>> +                      sysctl->u.cpu_policy.cpuid_policy,
>>> +                      &sysctl->u.cpu_policy.nr_leaves)) )
>>> +                break;
>>> +
>>> +            if ( __copy_field_to_guest(u_sysctl, sysctl,
>>> +                                       u.cpu_policy.nr_leaves)  )
>>> +            {
>>> +                ret = -EFAULT;
>>> +                break;
>>> +            }
>> ... this (and the MSR ones respectively), by moving both out of and
>> past their outer if()-s? This would the also call for two if/else-if pairs
>> instead of four if()-s.
> 
> I

???

>>> --- a/xen/include/public/sysctl.h
>>> +++ b/xen/include/public/sysctl.h
>>> @@ -1075,12 +1075,25 @@ struct xen_sysctl_set_parameter {
>>>   *  - Default_*: Default set of features a PV or HVM guest can use.  This is
>>>   *               the security supported set.
>>>   */
>>> +struct xen_sysctl_cpu_policy {
>>>  #define XEN_SYSCTL_cpu_policy_raw          0
>>>  #define XEN_SYSCTL_cpu_policy_host         1
>>>  #define XEN_SYSCTL_cpu_policy_pv_max       2
>>>  #define XEN_SYSCTL_cpu_policy_hvm_max      3
>>>  #define XEN_SYSCTL_cpu_policy_pv_default   4
>>>  #define XEN_SYSCTL_cpu_policy_hvm_default  5
>>> +    uint32_t index;       /* IN: Which policy to query? */
>>> +    uint32_t nr_leaves;   /* IN/OUT: Number of leaves in/written to
>>> +                           * 'cpuid_policy', or the maximum number of leaves
>>> +                           * if the guest handle is NULL. */
>>> +    uint32_t nr_msrs;     /* IN/OUT: Number of MSRs in/written to
>>> +                           * 'msr_policy', or the maximum number of MSRs if
>>> +                           * the guest handle is NULL. */
>>> +    XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) cpuid_policy; /* OUT: */
>>> +    XEN_GUEST_HANDLE_64(xen_msr_entry_t) msr_policy;    /* OUT: */
>> Stray colons in the comments?
>>
>> I'm also not overly happy to see there's still no explicit padding here.
>> I know you dislike it, but I think as long as we have no better
>> replacement to the interface versioning, we should at least try to
>> limit the number of bumps it needs, and that calls for making padding
>> explicit, zeroing it for output and checking it to be zero when input,
>> so that the field can be assigned meaning subsequently. Otherwise
>> why did we tell others to add explicit padding over the last so many
>> years, without you voicing your opinion to the contrary?
> 
> I've never (knowingly) requested padding in the unstable interface. 
> I've certainly requested rearrangements for better packing, and
> requested padding for bits of the stable ABI.

I don't recall you requesting such, indeed, but I also don't recall you
objecting to me (and iirc also a few others) doing so.

> The sysctl structure itself is full of holes, and this is not an
> appropriate time or place to be making partial changes to the ABI.

Well, I'm not going to insist, since as you say it's inconsistent at
present anyway. But we'll want to settle on one of the other
model for new additions, and then consider converting existing
ones accordingly.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-07-18  6:45 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 20:03 [PATCH v2 00/13] x86: CPUID and MSR policy marshalling support Andrew Cooper
2018-07-13 20:03 ` [PATCH v2 01/13] x86/msr: Drop stale comment for vcpu_msrs.spec_ctrl Andrew Cooper
2018-07-16  7:21   ` Jan Beulich
2018-07-16  9:37   ` Roger Pau Monné
2018-07-16 11:02     ` Andrew Cooper
2018-07-13 20:03 ` [PATCH v2 02/13] libx86: Introduce libx86/cpuid.h Andrew Cooper
2018-07-16  9:23   ` Jan Beulich
2018-07-16 10:22     ` Andrew Cooper
2018-07-16 10:51       ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 03/13] libx86: generate cpuid-autogen.h in the libx86 include dir Andrew Cooper
2018-07-16  9:31   ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 04/13] libx86: Share struct cpuid_policy with userspace Andrew Cooper
2018-07-16  9:38   ` Jan Beulich
2018-07-16  9:51     ` Andrew Cooper
2018-07-16 10:04       ` Jan Beulich
2018-07-16 10:16         ` Andrew Cooper
2018-07-16 10:24           ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 05/13] libx86: introduce a libx86 shared library Andrew Cooper
2018-07-16  9:02   ` Wei Liu
2018-07-16 10:17   ` Jan Beulich
2018-07-16 10:35     ` Andrew Cooper
2018-07-16 10:52       ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 06/13] libx86: Introduce libx86/msr.h and share msr_policy with userspace Andrew Cooper
2018-07-16  9:41   ` Roger Pau Monné
2018-07-16 10:19   ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 07/13] libx86: Introduce a helper to serialise cpuid_policy objects Andrew Cooper
2018-07-16  9:18   ` Wei Liu
2018-07-16  9:45     ` Jan Beulich
2018-07-16 10:39       ` Andrew Cooper
2018-07-16 10:55         ` Jan Beulich
2018-07-16 10:45   ` Jan Beulich
2018-07-17 10:02     ` Andrew Cooper
2018-07-17 11:58       ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 08/13] libx86: Introduce a helper to serialise msr_policy objects Andrew Cooper
2018-07-16  9:24   ` Wei Liu
2018-07-16 10:47   ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 09/13] libx86: Introduce a helper to deserialise cpuid_policy objects Andrew Cooper
2018-07-16  9:57   ` Wei Liu
2018-07-17 10:09     ` Andrew Cooper
2018-07-13 20:03 ` [PATCH v2 10/13] libx86: introduce a helper to deserialise msr_policy objects Andrew Cooper
2018-07-16 10:07   ` Wei Liu
2018-07-16 11:36   ` Jan Beulich
2018-07-17 10:17     ` Andrew Cooper
2018-07-17 12:01       ` Jan Beulich
2018-07-17 16:06         ` Andrew Cooper
2018-07-17 16:23           ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 11/13] x86: Introduce struct cpu_policy to refer to a group of individual policies Andrew Cooper
2018-07-16  9:55   ` Roger Pau Monné
2018-07-16 10:32   ` Wei Liu
2018-07-16 12:04   ` Jan Beulich
2018-07-16 12:16     ` Andrew Cooper
2018-07-16 12:29       ` Jan Beulich
2018-07-16 13:15         ` Andrew Cooper
2018-07-16 13:23           ` Jan Beulich
2018-07-13 20:03 ` [PATCH v2 12/13] x86/sysctl: Implement XEN_SYSCTL_get_cpu_policy Andrew Cooper
2018-07-16 10:16   ` Roger Pau Monné
2018-07-16 10:58     ` Andrew Cooper
2018-07-16 11:04       ` Jan Beulich
2018-07-16 11:54   ` Jan Beulich
2018-07-17 16:50     ` Andrew Cooper
2018-07-18  6:45       ` Jan Beulich [this message]
2018-07-13 20:03 ` [PATCH v2 13/13] x86/domctl: Implement XEN_DOMCTL_get_cpu_policy Andrew Cooper
2018-07-16 10:26   ` Roger Pau Monné
2018-07-17 17:08     ` Andrew Cooper
2018-07-16 12:00   ` Jan Beulich
2018-07-30  2:14   ` Chao Gao
2018-08-17 21:22   ` Daniel De Graaf
2018-07-30  2:46 ` [PATCH v2 00/13] x86: CPUID and MSR policy marshalling support Chao Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5B4EE1F102000078001D5301@prv1-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=roger.pau@citrix.com \
    --cc=sergey.dyasli@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.