Discussion:
[Xen-changelog] [xen master] x86: introduce is_pv_64bit_{vcpu, domain}
p***@xen.org
2018-11-04 04:57:57 UTC
Permalink
commit e386c47882ecc23c14aa895d2702f10bde878b55
Author: Wei Liu <***@citrix.com>
AuthorDate: Thu Oct 4 16:43:23 2018 +0100
Commit: Wei Liu <***@citrix.com>
CommitDate: Mon Oct 15 15:23:44 2018 +0100

x86: introduce is_pv_64bit_{vcpu,domain}

This is useful to rewrite the following pattern (v is PV vcpu)

if ( is_pv_32bit_vcpu(v) )
do_foo;
else
do_bar;

to

if ( is_pv_32bit_vcpu(v) )
do_foo;
else if ( is_pv_64bit_vcpu(v) )
do_bar;
else
ASSERT_UNREACHABLE;
.

Previously it is not possible to rely on DCE to eliminate the do_bar
part. It becomes possible with the new code structure.

Signed-off-by: Wei Liu <***@citrix.com>
Acked-by: Jan Beulich <***@suse.com>
---
xen/include/xen/sched.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 4b23805367..3171eabfd6 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -893,8 +893,17 @@ static inline bool is_pv_32bit_vcpu(const struct vcpu *v)
{
return is_pv_32bit_domain(v->domain);
}
-#endif

+static inline bool is_pv_64bit_domain(const struct domain *d)
+{
+ return is_pv_domain(d) && !d->arch.is_32bit_pv;
+}
+
+static inline bool is_pv_64bit_vcpu(const struct vcpu *v)
+{
+ return is_pv_64bit_domain(v->domain);
+}
+#endif
static inline bool is_hvm_domain(const struct domain *d)
{
return IS_ENABLED(CONFIG_HVM) ? d->guest_type == guest_type_hvm : false;
--
generated by git-patchbot for /home/xen/git/xen.git#master

Loading...