From: Jan Beulich <jbeulich@suse.com>
To: Alexandru Stefan ISAILA <aisaila@bitdefender.com>
Cc: "Petre Ovidiu PIRCALABU" <ppircalabu@bitdefender.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>, "Wei Liu" <wl@xen.org>,
"Razvan COJOCARU" <rcojocaru@bitdefender.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>,
"Tamas K Lengyel" <tamas@tklengyel.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH V4 2/4] x86/altp2m: Add hypercall to set a range of sve bits
Date: Wed, 18 Dec 2019 11:18:39 +0100 [thread overview]
Message-ID: <600c17a8-e205-ce7d-69bf-036c004459a0@suse.com> (raw)
In-Reply-To: <fe9f516c-7f8e-f3ac-cc30-e7e8a6f882fb@bitdefender.com>
On 18.12.2019 09:45, Alexandru Stefan ISAILA wrote:
>
>
> On 18.12.2019 10:13, Alexandru Stefan ISAILA wrote:
>>
>>>> +/*
>>>> + * Set/clear the #VE suppress bit for multiple pages. Only available on VMX.
>>>> + */
>>>> +int p2m_set_suppress_ve_multi(struct domain *d,
>>>> + struct xen_hvm_altp2m_suppress_ve_multi *sve)
>>>> +{
>>>> + struct p2m_domain *host_p2m = p2m_get_hostp2m(d);
>>>> + struct p2m_domain *ap2m = NULL;
>>>> + struct p2m_domain *p2m = host_p2m;
>>>> + uint64_t start = sve->first_gfn;
>>>> + int rc = 0;
>>>> + uint64_t max_phys_addr = (1UL << d->arch.cpuid->extd.maxphysaddr) - 1;
>>>> +
>>>> + if ( sve->view > 0 )
>>>> + {
>>>> + if ( sve->view >= MAX_ALTP2M ||
>>>> + d->arch.altp2m_eptp[array_index_nospec(sve->view, MAX_EPTP)] ==
>>>> + mfn_x(INVALID_MFN) )
>>>> + return -EINVAL;
>>>> +
>>>> + p2m = ap2m = d->arch.altp2m_p2m[array_index_nospec(sve->view,
>>>> + MAX_ALTP2M)];
>>>> + }
>>>> +
>>>> + p2m_lock(host_p2m);
>>>> +
>>>> + if ( ap2m )
>>>> + p2m_lock(ap2m);
>>>> +
>>>> + while ( sve->last_gfn >= start && start < max_phys_addr )
>>>
>>> Why don't you clip ->last_gfn ahead of the loop, saving one
>>> comparison per iteration?
>>
>> I've done this so it will have fewer lines but sure, I can have the
>> ->last_gfn check before the loop.
>
> Wouldn't there be a issue if start goes over ->last_gfn and there is no
> break for preemption? Then the loop will run until max_phys_addr.
I'm not sure I understand. My guess is a misunderstanding - I'm
asking to replace the right side of the &&, and it looks you
understood me to mean the least side. Note how I said "clip" in
my earlier reply, meaning you to update ->last_gfn ahead of the
loop if it's above (1UL << d->arch.cpuid->extd.maxphysaddr) - 1.
Perhaps this could even be done in the caller together with (and
possibly ahead of) the other sanity checking of incoming values.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-12-18 10:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-17 15:12 [Xen-devel] [PATCH V4 1/4] x86/mm: Add array_index_nospec to guest provided index values Alexandru Stefan ISAILA
2019-12-17 15:12 ` [Xen-devel] [PATCH V4 2/4] x86/altp2m: Add hypercall to set a range of sve bits Alexandru Stefan ISAILA
2019-12-17 17:00 ` Jan Beulich
2019-12-18 8:13 ` Alexandru Stefan ISAILA
2019-12-18 8:45 ` Alexandru Stefan ISAILA
2019-12-18 10:18 ` Jan Beulich [this message]
2019-12-18 10:32 ` Alexandru Stefan ISAILA
2019-12-17 15:12 ` [Xen-devel] [PATCH V4 3/4] x86/mm: Pull out the p2m specifics from p2m_init_altp2m_ept Alexandru Stefan ISAILA
2019-12-18 10:36 ` Jan Beulich
2019-12-17 15:12 ` [Xen-devel] [PATCH V4 4/4] x86/mm: Make use of the default access param from xc_altp2m_create_view Alexandru Stefan ISAILA
2019-12-18 10:45 ` Jan Beulich
2019-12-18 11:53 ` Alexandru Stefan ISAILA
2019-12-17 15:21 ` [Xen-devel] [PATCH V4 1/4] x86/mm: Add array_index_nospec to guest provided index values Tamas K Lengyel
2019-12-17 16:50 ` Jan Beulich
2019-12-18 8:06 ` Alexandru Stefan ISAILA
2019-12-18 9:57 ` Alexandru Stefan ISAILA
2019-12-18 10:06 ` Jan Beulich
2019-12-18 10:26 ` Alexandru Stefan ISAILA
2019-12-18 9:59 ` Jan Beulich
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=600c17a8-e205-ce7d-69bf-036c004459a0@suse.com \
--to=jbeulich@suse.com \
--cc=aisaila@bitdefender.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=julien@xen.org \
--cc=konrad.wilk@oracle.com \
--cc=ppircalabu@bitdefender.com \
--cc=rcojocaru@bitdefender.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tamas@tklengyel.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.