]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
is_hvm/pv_domain: block speculation
authorNorbert Manthey <nmanthey@amazon.de>
Thu, 14 Mar 2019 12:56:00 +0000 (13:56 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 5 Apr 2019 10:17:03 +0000 (12:17 +0200)
When checking for being an hvm domain, or PV domain, we have to make
sure that speculation cannot bypass that check, and eventually access
data that should not end up in cache for the current domain type.

This is part of the speculative hardening effort.

Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/include/xen/sched.h

index 0b8d6d492cb20b9c92b9f51c4fd8038c7e259609..748bb0f2f9f6a6cb9798fc3a38df909a28e89063 100644 (file)
@@ -920,7 +920,8 @@ void watchdog_domain_destroy(struct domain *d);
 
 static inline bool is_pv_domain(const struct domain *d)
 {
-    return IS_ENABLED(CONFIG_PV) ? d->guest_type == guest_type_pv : false;
+    return IS_ENABLED(CONFIG_PV)
+           ? evaluate_nospec(d->guest_type == guest_type_pv) : false;
 }
 
 static inline bool is_pv_vcpu(const struct vcpu *v)
@@ -951,7 +952,8 @@ static inline bool is_pv_64bit_vcpu(const struct vcpu *v)
 #endif
 static inline bool is_hvm_domain(const struct domain *d)
 {
-    return IS_ENABLED(CONFIG_HVM) ? d->guest_type == guest_type_hvm : false;
+    return IS_ENABLED(CONFIG_HVM)
+           ? evaluate_nospec(d->guest_type == guest_type_hvm) : false;
 }
 
 static inline bool is_hvm_vcpu(const struct vcpu *v)