From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 1/2] x86: correct is_pv_domain() when !CONFIG_PV
Date: Fri, 27 Nov 2020 17:54:57 +0100 [thread overview]
Message-ID: <54013074-1fc4-1047-0d00-2762fcbc9ade@suse.com> (raw)
In-Reply-To: <7c040eff-2746-59e3-b657-64f5df3c9085@suse.com>
On x86, idle and other system domains are implicitly PV. While I
couldn't spot any cases where this is actively a problem, some cases
required quite close inspection to be certain there couldn't e.g. be
some ASSERT_UNREACHABLE() that would trigger in this case. Let's be on
the safe side and make sure these always have is_pv_domain() returning
true.
For the build to still work, this requires a few adjustments elsewhere.
In particular is_pv_64bit_domain() now gains a CONFIG_PV dependency,
which means that is_pv_32bit_domain() || is_pv_64bit_domain() is no
longer guaranteed to be the same as is_pv_domain().
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -568,7 +568,7 @@ int __init construct_dom0(struct domain
if ( is_hvm_domain(d) )
rc = dom0_construct_pvh(d, image, image_headroom, initrd, cmdline);
- else if ( is_pv_domain(d) )
+ else if ( is_pv_64bit_domain(d) || is_pv_32bit_domain(d) )
rc = dom0_construct_pv(d, image, image_headroom, initrd, cmdline);
else
panic("Cannot construct Dom0. No guest interface available\n");
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1544,6 +1544,7 @@ arch_do_vcpu_op(
*/
static void load_segments(struct vcpu *n)
{
+#ifdef CONFIG_PV
struct cpu_user_regs *uregs = &n->arch.user_regs;
unsigned long gsb = 0, gss = 0;
bool compat = is_pv_32bit_vcpu(n);
@@ -1709,6 +1710,7 @@ static void load_segments(struct vcpu *n
regs->cs = FLAT_KERNEL_CS;
regs->rip = pv->failsafe_callback_eip;
}
+#endif
}
/*
@@ -1723,6 +1725,7 @@ static void load_segments(struct vcpu *n
*/
static void save_segments(struct vcpu *v)
{
+#ifdef CONFIG_PV
struct cpu_user_regs *regs = &v->arch.user_regs;
read_sregs(regs);
@@ -1748,6 +1751,7 @@ static void save_segments(struct vcpu *v
else
v->arch.pv.gs_base_user = gs_base;
}
+#endif
}
void paravirt_ctxt_switch_from(struct vcpu *v)
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -408,13 +408,13 @@ long arch_do_domctl(
case XEN_DOMCTL_set_address_size:
if ( is_hvm_domain(d) )
ret = -EOPNOTSUPP;
+ else if ( is_pv_64bit_domain(d) && domctl->u.address_size.size == 32 )
+ ret = switch_compat(d);
else if ( is_pv_domain(d) )
{
if ( ((domctl->u.address_size.size == 64) && !d->arch.pv.is_32bit) ||
((domctl->u.address_size.size == 32) && d->arch.pv.is_32bit) )
ret = 0;
- else if ( domctl->u.address_size.size == 32 )
- ret = switch_compat(d);
else
ret = -EINVAL;
}
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -985,7 +985,7 @@ static always_inline bool is_control_dom
static always_inline bool is_pv_domain(const struct domain *d)
{
- return IS_ENABLED(CONFIG_PV) &&
+ return IS_ENABLED(CONFIG_X86) &&
evaluate_nospec(!(d->options & XEN_DOMCTL_CDF_hvm));
}
@@ -1011,7 +1011,7 @@ static always_inline bool is_pv_32bit_vc
static always_inline bool is_pv_64bit_domain(const struct domain *d)
{
- if ( !is_pv_domain(d) )
+ if ( !IS_ENABLED(CONFIG_PV) || !is_pv_domain(d) )
return false;
#ifdef CONFIG_PV32
next prev parent reply other threads:[~2020-11-27 16:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-27 16:51 [PATCH 0/2] x86: is_pv*domain() adjustments Jan Beulich
2020-11-27 16:54 ` Jan Beulich [this message]
2021-04-12 9:34 ` [PATCH 1/2] x86: correct is_pv_domain() when !CONFIG_PV Roger Pau Monné
2021-04-12 10:07 ` Jan Beulich
2021-04-12 14:49 ` Roger Pau Monné
2021-04-12 15:24 ` Jan Beulich
2021-04-12 15:40 ` Roger Pau Monné
2021-04-12 15:51 ` Jan Beulich
2021-04-13 7:56 ` Roger Pau Monné
2021-04-13 8:02 ` Jan Beulich
2020-11-27 16:55 ` [PATCH 2/2] x86: use is_pv_64bit_domain() to avoid double evaluate_nospec() Jan Beulich
2021-04-09 8:06 ` Ping: [PATCH 0/2] x86: is_pv*domain() adjustments 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=54013074-1fc4-1047-0d00-2762fcbc9ade@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).