All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Durrant <xadimgnik@gmail.com>
To: "'Jan Beulich'" <jbeulich@suse.com>
Cc: "'Paul Durrant'" <pdurrant@amazon.com>, "'Wei Liu'" <wl@xen.org>,
	"'Andrew Cooper'" <andrew.cooper3@citrix.com>,
	"'Roger Pau Monné'" <roger.pau@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: RE: [PATCH 06/10] viridian: add ExProcessorMasks variants of the flush hypercalls
Date: Thu, 19 Nov 2020 16:11:53 -0000	[thread overview]
Message-ID: <00cc01d6be8e$b24973c0$16dc5b40$@xen.org> (raw)
In-Reply-To: <dd6c4a0d-f611-7b81-8c95-72786891f311@suse.com>

> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: 12 November 2020 09:19
> To: Paul Durrant <paul@xen.org>
> Cc: Paul Durrant <pdurrant@amazon.com>; Wei Liu <wl@xen.org>; Andrew Cooper
> <andrew.cooper3@citrix.com>; Roger Pau Monné <roger.pau@citrix.com>; xen-devel@lists.xenproject.org
> Subject: Re: [PATCH 06/10] viridian: add ExProcessorMasks variants of the flush hypercalls
> 
> On 11.11.2020 21:07, Paul Durrant wrote:
> > --- a/xen/arch/x86/hvm/viridian/viridian.c
> > +++ b/xen/arch/x86/hvm/viridian/viridian.c
> > @@ -553,6 +553,83 @@ static unsigned int vpmask_next(struct hypercall_vpmask *vpmask, unsigned int
> vp
> >  	     (vp) < HVM_MAX_VCPUS; \
> >  	     (vp) = vpmask_next(vpmask, vp))
> >
> > +struct hypercall_vpset {
> > +        struct hv_vpset set;
> > +        uint64_t __bank_contents[64];
> 
> gcc documents this to be supported as an extension; did you check
> clang supports this, too?

By 'this', do you mean the assumption that that memory layout is consecutive?

> (I'd also prefer if the leading
> underscores could be dropped, but as you know I'm not the maintainer
> of this code.)
> 
> > +static unsigned int hv_vpset_nr_banks(struct hv_vpset *vpset)
> > +{
> > +    uint64_t bank_mask;
> > +    unsigned int nr = 0;
> > +
> > +    for ( bank_mask = vpset->valid_bank_mask; bank_mask; bank_mask >>= 1 )
> > +        if ( bank_mask & 1 )
> > +            nr++;
> > +
> > +    return nr;
> > +}
> 
> Simply use hweight64()?
> 

Ok.

> > +static uint16_t hv_vpset_to_vpmask(struct hv_vpset *set, size_t size,
> > +                                   struct hypercall_vpmask *vpmask)
> > +{
> > +    switch ( set->format )
> > +    {
> > +    case HV_GENERIC_SET_ALL:
> > +        vpmask_fill(vpmask);
> > +        return 0;
> > +
> > +    case HV_GENERIC_SET_SPARSE_4K:
> > +    {
> > +        uint64_t bank_mask;
> > +        unsigned int bank = 0, vp = 0;
> > +
> > +        vpmask_empty(vpmask);
> > +        for ( bank_mask = set->valid_bank_mask; bank_mask; bank_mask >>= 1 )
> > +        {
> > +            /* Make sure we won't dereference past the end of the array */
> > +            if ( (void *)(set->bank_contents + bank) >=
> > +                 (void *)set + size )
> > +            {
> > +                ASSERT_UNREACHABLE();
> > +                return -EINVAL;
> > +            }
> 
> Doesn't this come too late? I.e. don't you want to check instead
> (or also) that you won't overrun the space when copying in from
> the guest? And for the specific purpose here, doesn't it come too
> early, as you won't access any memory when the low bit of bank_mask
> isn't set?
> 

I'll dry-run this again. It may make more sense to move the check.

  Paul

> Jan



  reply	other threads:[~2020-11-19 16:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 20:07 [PATCH 00/10] viridian: add support for ExProcessorMasks Paul Durrant
2020-11-11 20:07 ` [PATCH 01/10] viridian: move flush hypercall implementation into separate function Paul Durrant
2020-11-11 20:07 ` [PATCH 02/10] viridian: move IPI " Paul Durrant
2020-11-12  8:37   ` Jan Beulich
2020-11-12  9:30     ` Durrant, Paul
2020-11-11 20:07 ` [PATCH 03/10] viridian: introduce a per-cpu hypercall_vpmask and accessor functions Paul Durrant
2020-11-12  8:45   ` Jan Beulich
2020-11-19 16:02     ` Paul Durrant
2020-11-19 16:41       ` Jan Beulich
2020-11-19 16:44         ` Durrant, Paul
2020-11-19 16:46           ` Jan Beulich
2020-11-11 20:07 ` [PATCH 04/10] viridian: use hypercall_vpmask in hvcall_ipi() Paul Durrant
2020-11-12  8:49   ` Jan Beulich
2020-11-19 16:04     ` Paul Durrant
2020-11-11 20:07 ` [PATCH 05/10] viridian: use softirq batching " Paul Durrant
2020-11-12  8:52   ` Jan Beulich
2020-11-19 16:08     ` Paul Durrant
2020-11-11 20:07 ` [PATCH 06/10] viridian: add ExProcessorMasks variants of the flush hypercalls Paul Durrant
2020-11-12  9:19   ` Jan Beulich
2020-11-19 16:11     ` Paul Durrant [this message]
2020-11-19 16:44       ` Jan Beulich
2020-11-19 16:47         ` Paul Durrant
2020-11-11 20:07 ` [PATCH 07/10] viridian: add ExProcessorMasks variant of the IPI hypercall Paul Durrant
2020-11-11 20:07 ` [PATCH 08/10] viridian: log initial invocation of each type of hypercall Paul Durrant
2020-11-12  9:22   ` Jan Beulich
2020-11-19 16:13     ` Paul Durrant
2020-11-11 20:07 ` [PATCH 09/10] viridian: add a new '_HVMPV_ex_processor_masks' bit into HVM_PARAM_VIRIDIAN Paul Durrant
2020-11-11 20:07 ` [PATCH 10/10] xl / libxl: add 'ex_processor_mask' into 'libxl_viridian_enlightenment' Paul Durrant

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='00cc01d6be8e$b24973c0$16dc5b40$@xen.org' \
    --to=xadimgnik@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=paul@xen.org \
    --cc=pdurrant@amazon.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.