All of lore.kernel.org
 help / color / mirror / Atom feed
From: Norbert Manthey <nmanthey@amazon.de>
To: Jan Beulich <JBeulich@suse.com>
Cc: Tim Deegan <tim@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Dario Faggioli <dfaggioli@suse.com>,
	Martin Pohlack <mpohlack@amazon.de>,
	Julien Grall <julien.grall@arm.com>,
	David Woodhouse <dwmw@amazon.co.uk>,
	"Martin Mazein(amazein)" <amazein@amazon.de>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Julian Stecklina <jsteckli@amazon.de>,
	Bjoern Doebel <doebel@amazon.de>
Subject: Re: [PATCH SpectreV1+L1TF v4 08/11] xen/evtchn: block speculative out-of-bound accesses
Date: Thu, 24 Jan 2019 20:50:29 +0100	[thread overview]
Message-ID: <ea24d08b-7793-94b2-2b20-c55a0339858c@amazon.de> (raw)
In-Reply-To: <5C49EE5B0200007800210E17@prv1-mh.provo.novell.com>

On 1/24/19 17:56, Jan Beulich wrote:
>>>> On 23.01.19 at 12:57, <nmanthey@amazon.de> wrote:
>> --- a/xen/common/event_channel.c
>> +++ b/xen/common/event_channel.c
>> @@ -368,8 +368,14 @@ int evtchn_bind_virq(evtchn_bind_virq_t *bind, evtchn_port_t port)
>>      if ( virq_is_global(virq) && (vcpu != 0) )
>>          return -EINVAL;
>>  
>> +   /*
>> +    * Make sure the guest controlled value virq is bounded even during
>> +    * speculative execution.
>> +    */
>> +    virq = array_index_nospec(virq, ARRAY_SIZE(v->virq_to_evtchn));
> I think this wants to move ahead of the if() in context, to be independent
> of the particular implementation of virq_is_global() (the current shape of
> which is mostly fine, perhaps with the exception of the risk of the compiler
> translating the switch() there by way of a jump table). This also moves it
> closer to the if() the construct is a companion to.
I understand the concern. However, because the value of virq would be
changed before the virq_is_global check, couldn't that result in
returning a wrong error code? The potential out-of-bound value is
brought back into the valid range, so that the above check might fire
incorrectly?
>
>> @@ -816,6 +822,12 @@ int set_global_virq_handler(struct domain *d, uint32_t virq)
>>      if (!virq_is_global(virq))
>>          return -EINVAL;
>>  
>> +   /*
>> +    * Make sure the guest controlled value virq is bounded even during
>> +    * speculative execution.
>> +    */
>> +    virq = array_index_nospec(virq, ARRAY_SIZE(global_virq_handlers));
> Same here then.
>
>> @@ -931,7 +943,8 @@ long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id)
>>      struct evtchn *chn;
>>      long           rc = 0;
>>  
>> -    if ( (vcpu_id >= d->max_vcpus) || (d->vcpu[vcpu_id] == NULL) )
>> +    if ( (vcpu_id >= d->max_vcpus) ||
>> +         (d->vcpu[array_index_nospec(vcpu_id, d->max_vcpus)] == NULL) )
>>          return -ENOENT;
>>  
>>      spin_lock(&d->event_lock);
>> @@ -969,8 +982,10 @@ long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id)
>>          unlink_pirq_port(chn, d->vcpu[chn->notify_vcpu_id]);
>>          chn->notify_vcpu_id = vcpu_id;
>>          pirq_set_affinity(d, chn->u.pirq.irq,
>> -                          cpumask_of(d->vcpu[vcpu_id]->processor));
>> -        link_pirq_port(port, chn, d->vcpu[vcpu_id]);
>> +                          cpumask_of(d->vcpu[array_index_nospec(vcpu_id,
>> +                                                                d->max_vcpus)]->processor));
>> +        link_pirq_port(port, chn, d->vcpu[array_index_nospec(vcpu_id,
>> +                                                             d->max_vcpus)]);
> Using Andrew's new domain_vcpu() will improve readability, especially
> after your change, quite a bit here. But of course code elsewhere will
> benefit as well.

You mean I should use the domain_vcpu function in both hunks, because
due to the first one, the latter can never return NULL? I will rebase
the series on top of this fresh change, and use the domain_vcpu function
for the locations where I bound a vcpu_id.

Best,
Norbert

>
> Jan
>
>




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich
Ust-ID: DE 289 237 879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B

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

  reply	other threads:[~2019-01-24 19:56 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-23 11:51 SpectreV1+L1TF Patch Series Norbert Manthey
2019-01-23 11:51 ` [PATCH SpectreV1+L1TF v4 01/11] is_control_domain: block speculation Norbert Manthey
2019-01-23 13:07   ` Jan Beulich
2019-01-23 13:20     ` Julien Grall
2019-01-23 13:40       ` Jan Beulich
2019-01-23 13:20   ` Jan Beulich
2019-01-24 12:07     ` Norbert Manthey
2019-01-24 20:33       ` Andrew Cooper
2019-01-25  9:19         ` Jan Beulich
2019-01-23 11:51 ` [PATCH SpectreV1+L1TF v4 02/11] is_hvm/pv_domain: " Norbert Manthey
2019-01-23 11:51 ` [PATCH SpectreV1+L1TF v4 03/11] config: introduce L1TF_LFENCE option Norbert Manthey
2019-01-23 13:18   ` Jan Beulich
2019-01-24 12:11     ` Norbert Manthey
2019-01-23 13:24   ` Julien Grall
2019-01-23 13:39     ` Jan Beulich
2019-01-23 13:44       ` Julien Grall
2019-01-23 14:45         ` Jan Beulich
2019-01-24 12:21           ` Norbert Manthey
2019-01-24 21:29   ` Andrew Cooper
2019-01-25 10:14     ` Jan Beulich
2019-01-25 10:50       ` Norbert Manthey
2019-01-25 13:09         ` Jan Beulich
2019-01-27 20:28           ` Norbert Manthey
2019-01-28  7:35             ` Jan Beulich
2019-01-28  7:56               ` Norbert Manthey
2019-01-28  8:24                 ` Jan Beulich
2019-01-28 10:07                   ` Norbert Manthey
2019-01-31 22:39       ` Andrew Cooper
2019-02-01  8:02         ` Jan Beulich
2019-01-23 11:51 ` [PATCH SpectreV1+L1TF v4 04/11] x86/hvm: block speculative out-of-bound accesses Norbert Manthey
2019-01-31 19:31   ` Andrew Cooper
2019-02-01  9:06     ` Jan Beulich
2019-01-23 11:51 ` [PATCH SpectreV1+L1TF v4 05/11] common/grant_table: " Norbert Manthey
2019-01-23 13:37   ` Jan Beulich
2019-01-28 14:45     ` Norbert Manthey
2019-01-28 15:09       ` Jan Beulich
2019-01-29  8:33         ` Norbert Manthey
2019-01-29  9:46           ` Jan Beulich
2019-01-29 13:47             ` Norbert Manthey
2019-01-29 15:11               ` Jan Beulich
2019-01-30  8:06                 ` Norbert Manthey
2019-01-30 11:35                   ` Jan Beulich
2019-01-23 11:51 ` [PATCH SpectreV1+L1TF v4 06/11] common/memory: " Norbert Manthey
2019-01-23 11:57 ` [PATCH SpectreV1+L1TF v4 07/11] nospec: enable lfence on Intel Norbert Manthey
2019-01-24 22:29   ` Andrew Cooper
2019-01-27 20:09     ` Norbert Manthey
2019-01-23 11:57 ` [PATCH SpectreV1+L1TF v4 08/11] xen/evtchn: block speculative out-of-bound accesses Norbert Manthey
2019-01-24 16:56   ` Jan Beulich
2019-01-24 19:50     ` Norbert Manthey [this message]
2019-01-25  9:23       ` Jan Beulich
2019-01-23 11:57 ` [PATCH SpectreV1+L1TF v4 09/11] x86/vioapic: " Norbert Manthey
2019-01-25 16:34   ` Jan Beulich
2019-01-28 11:03     ` Norbert Manthey
2019-01-28 11:12       ` Jan Beulich
2019-01-28 12:20         ` Norbert Manthey
2019-01-23 11:57 ` [PATCH SpectreV1+L1TF v4 10/11] x86/hvm/hpet: " Norbert Manthey
2019-01-25 16:50   ` Jan Beulich
2019-01-23 11:57 ` [PATCH SpectreV1+L1TF v4 11/11] x86/CPUID: " Norbert Manthey
2019-01-24 21:05 ` SpectreV1+L1TF Patch Series Andrew Cooper
2019-01-28 13:56   ` Norbert Manthey
2019-01-28  8:28 ` Jan Beulich
     [not found] ` <5C4EBD1A0200007800211954@suse.com>
2019-01-28  8:47   ` Juergen Gross
2019-01-28  9:56     ` Jan Beulich
     [not found]       ` <9C03B9BA0200004637554D14@prv1-mh.provo.novell.com>
     [not found]         ` <00FAA7AF020000F8B1E090C7@prv1-mh.provo.novell.com>
     [not found]           ` <00FAE7AF020000F8B1E090C7@prv1-mh.provo.novell.com>
2019-01-31 15:05             ` [PATCH SpectreV1+L1TF v5 1/9] xen/evtchn: block speculative out-of-bound accesses Jan Beulich
2019-02-01 13:45               ` Norbert Manthey
2019-02-01 14:08                 ` Jan Beulich
2019-02-05 13:42                   ` Norbert Manthey
     [not found]           ` <00FA27AF020000F8B1E090C7@prv1-mh.provo.novell.com>
2019-01-31 16:05             ` [PATCH SpectreV1+L1TF v5 2/9] x86/vioapic: " Jan Beulich
2019-02-01 13:54               ` Norbert Manthey
     [not found]           ` <00F867AF020000F8B1E090C7@prv1-mh.provo.novell.com>
2019-01-31 16:19             ` [PATCH SpectreV1+L1TF v5 3/9] x86/hvm: " Jan Beulich
2019-01-31 20:02               ` Andrew Cooper
2019-02-01  8:23                 ` Jan Beulich
2019-02-01 14:06                   ` Norbert Manthey
2019-02-01 14:31                     ` Jan Beulich
2019-02-01 14:05               ` Norbert Manthey
     [not found]           ` <0101A7AF020000F8B1E090C7@prv1-mh.provo.novell.com>
2019-01-31 16:35             ` [PATCH SpectreV1+L1TF v5 4/9] spec: add l1tf-barrier Jan Beulich
2019-02-05 14:23               ` Norbert Manthey
2019-02-05 14:43                 ` Jan Beulich
2019-02-06 13:02                   ` Norbert Manthey
2019-02-06 13:20                     ` Jan Beulich
     [not found]           ` <0101E7AF020000F8B1E090C7@prv1-mh.provo.novell.com>
2019-01-31 17:05             ` [PATCH SpectreV1+L1TF v5 5/9] nospec: introduce evaluate_nospec Jan Beulich
2019-02-05 14:32               ` Norbert Manthey
2019-02-08 13:44                 ` SpectreV1+L1TF Patch Series v6 Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 1/9] xen/evtchn: block speculative out-of-bound accesses Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 2/9] x86/vioapic: " Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 3/9] x86/hvm: " Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 4/9] spec: add l1tf-barrier Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 5/9] nospec: introduce evaluate_nospec Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 6/9] is_control_domain: block speculation Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 7/9] is_hvm/pv_domain: " Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 8/9] common/grant_table: block speculative out-of-bound accesses Norbert Manthey
2019-02-08 13:44                   ` [PATCH SpectreV1+L1TF v6 9/9] common/memory: " Norbert Manthey
2019-02-08 14:32                   ` SpectreV1+L1TF Patch Series v6 Julien Grall
     [not found]               ` <A18FF6C80200006BB1E090C7@prv1-mh.provo.novell.com>
     [not found]                 ` <01CCAAAF02000039B1E090C7@prv1-mh.provo.novell.com>
     [not found]                   ` <01CCEAAF02000039B1E090C7@prv1-mh.provo.novell.com>
2019-02-12 13:08                     ` [PATCH SpectreV1+L1TF v6 1/9] xen/evtchn: block speculative out-of-bound accesses Jan Beulich
2019-02-14 13:10                       ` Norbert Manthey
2019-02-14 13:20                         ` Jan Beulich
     [not found]                   ` <01CC2AAF02000039B1E090C7@prv1-mh.provo.novell.com>
2019-02-12 13:16                     ` [PATCH SpectreV1+L1TF v6 2/9] x86/vioapic: " Jan Beulich
2019-02-14 13:16                       ` Norbert Manthey
     [not found]                   ` <01CE6AAF02000039B1E090C7@prv1-mh.provo.novell.com>
2019-02-12 13:25                     ` [PATCH SpectreV1+L1TF v6 3/9] x86/hvm: " Jan Beulich
2019-02-12 14:05                       ` Norbert Manthey
2019-02-12 14:14                         ` Jan Beulich
2019-02-15  8:05                           ` Norbert Manthey
2019-02-15  8:55                             ` Jan Beulich
2019-02-15 10:50                               ` Norbert Manthey
2019-02-15 11:46                                 ` Jan Beulich
2019-02-18 14:47                                   ` Norbert Manthey
2019-02-18 15:56                                     ` Jan Beulich
     [not found]                   ` <01CFAAAF02000039B1E090C7@prv1-mh.provo.novell.com>
2019-02-12 13:44                     ` [PATCH SpectreV1+L1TF v6 4/9] spec: add l1tf-barrier Jan Beulich
2019-02-15  9:13                       ` Norbert Manthey
     [not found]                   ` <01CFEAAF02000039B1E090C7@prv1-mh.provo.novell.com>
2019-02-12 13:50                     ` [PATCH SpectreV1+L1TF v6 5/9] nospec: introduce evaluate_nospec Jan Beulich
2019-02-14 13:37                       ` Norbert Manthey
2019-02-12 14:12                     ` Jan Beulich
2019-02-14 13:42                       ` Norbert Manthey
     [not found]                   ` <01CF2AAF02000039B1E090C7@prv1-mh.provo.novell.com>
2019-02-12 14:11                     ` [PATCH SpectreV1+L1TF v6 6/9] is_control_domain: block speculation Jan Beulich
2019-02-14 13:45                       ` Norbert Manthey
     [not found]                   ` <23D9419E02000017B1E090C7@prv1-mh.provo.novell.com>
2019-02-12 14:31                     ` [PATCH SpectreV1+L1TF v6 9/9] common/memory: block speculative out-of-bound accesses Jan Beulich
2019-02-14 14:04                       ` Norbert Manthey
     [not found]                   ` <01CEAAAF02000039B1E090C7@prv1-mh.provo.novell.com>
2019-02-13 11:50                     ` [PATCH SpectreV1+L1TF v6 8/9] common/grant_table: " Jan Beulich
2019-02-15  9:55                       ` Norbert Manthey
2019-02-15 10:34                         ` Jan Beulich
2019-02-18 13:49                           ` Norbert Manthey
2019-02-18 16:08                             ` Jan Beulich
2019-02-19 21:47                               ` Norbert Manthey
     [not found]           ` <0104A7AF020000F8B1E090C7@prv1-mh.provo.novell.com>
2019-02-06 14:52             ` [PATCH SpectreV1+L1TF v5 " Jan Beulich
2019-02-06 15:06               ` Norbert Manthey
2019-02-06 15:53                 ` Jan Beulich
2019-02-07  9:50                   ` Norbert Manthey
2019-02-07 10:20                     ` Norbert Manthey
2019-02-07 14:00                       ` Jan Beulich
2019-02-07 16:20                         ` Norbert Manthey
     [not found]           ` <010527AF020000F8B1E090C7@prv1-mh.provo.novell.com>
2019-02-06 15:03             ` [PATCH SpectreV1+L1TF v5 6/9] is_control_domain: block speculation Jan Beulich
2019-02-06 15:36               ` Norbert Manthey
2019-02-06 16:01                 ` Jan Beulich
2019-02-07 10:02                   ` Norbert Manthey
     [not found]           ` <20F3469E02000096B1E090C7@prv1-mh.provo.novell.com>
2019-02-06 15:25             ` [PATCH SpectreV1+L1TF v5 9/9] common/memory: block speculative out-of-bound accesses Jan Beulich
2019-02-06 15:39               ` Norbert Manthey
2019-02-06 16:08                 ` Jan Beulich
2019-02-07  7:20                   ` Norbert Manthey
2019-01-28 10:01 SpectreV1+L1TF Patch Series Juergen Gross
2019-01-29 14:43 ` SpectreV1+L1TF Patch Series v5 Norbert Manthey
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 1/9] xen/evtchn: block speculative out-of-bound accesses Norbert Manthey
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 2/9] x86/vioapic: " Norbert Manthey
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 3/9] x86/hvm: " Norbert Manthey
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 4/9] spec: add l1tf-barrier Norbert Manthey
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 5/9] nospec: introduce evaluate_nospec Norbert Manthey
2019-02-08  9:20     ` Julien Grall
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 6/9] is_control_domain: block speculation Norbert Manthey
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 7/9] is_hvm/pv_domain: " Norbert Manthey
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 8/9] common/grant_table: block speculative out-of-bound accesses Norbert Manthey
2019-01-29 14:43   ` [PATCH SpectreV1+L1TF v5 9/9] common/memory: " Norbert Manthey

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=ea24d08b-7793-94b2-2b20-c55a0339858c@amazon.de \
    --to=nmanthey@amazon.de \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=amazein@amazon.de \
    --cc=andrew.cooper3@citrix.com \
    --cc=dfaggioli@suse.com \
    --cc=doebel@amazon.de \
    --cc=dwmw@amazon.co.uk \
    --cc=jsteckli@amazon.de \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=mpohlack@amazon.de \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --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.