#include "yagl_stats.h"
#include "yagl_object_map.h"
#include "sysemu/kvm.h"
+#include "sysemu/hax.h"
struct yagl_process_state
*yagl_process_state_create(struct yagl_server_state *ss,
ps->object_map = yagl_object_map_create();
QLIST_INIT(&ps->threads);
-#ifdef CONFIG_KVM
- if (kvm_enabled()) {
- cpu_synchronize_state(current_cpu);
+#if defined (CONFIG_KVM) || defined (CONFIG_HAX)
+ if (kvm_enabled() || hax_enabled()) {
+ if (kvm_enabled()) {
+ cpu_synchronize_state(current_cpu);
+ } else {
+#ifdef CONFIG_HAX
+ hax_cpu_synchronize_state(current_cpu);
+#endif
+ }
+ CPUX86State *env = current_cpu->env_ptr;
memcpy(&ps->cr[0],
- &((CPUX86State *)current_cpu->env_ptr)->cr[0],
- sizeof(ps->cr));
- ps->hflags = ((CPUX86State *)current_cpu->env_ptr)->hflags;
+ &((CPUX86State *)current_cpu->env_ptr)->cr[0],
+ sizeof(ps->cr));
+ ps->hflags = env->hflags;
+ ps->efer = env->efer;
}
#endif
uint32_t out_arrays_size;
};
-#ifdef CONFIG_KVM
+#if defined (CONFIG_KVM) || defined (CONFIG_HAX)
static __inline void yagl_cpu_synchronize_state(struct yagl_process_state *ps)
{
- if (kvm_enabled()) {
+ if (kvm_enabled() || hax_enabled()) {
+ CPUX86State *env = current_cpu->env_ptr;
memcpy(&((CPUX86State *)current_cpu->env_ptr)->cr[0],
- &ps->cr[0],
- sizeof(ps->cr));
- ((CPUX86State *)current_cpu->env_ptr)->hflags = ps->hflags;
+ &ps->cr[0],
+ sizeof(ps->cr));
+ env->hflags = ps->hflags;
+
+ // FIXME: Somtimes "hflags" is not synced propery on HAX.
+ // It can be bug on synchronizing CPU state
+ env->efer = ps->efer;
+ if (env->efer & MSR_EFER_LMA) {
+ env->hflags |= HF_LMA_MASK;
+ }
}
}
#else