Skip to content

Commit

Permalink
acrn: support mwait emulation
Browse files Browse the repository at this point in the history
As we can only emulate unmonitored mwait, some adjust have to be
made for kernel idle routing when running as ACRN guest.
1. Mark ecx bit2 for mwait to indicate an unmonitored mwait.
2. Clear TIF_POLLING_NRFLAG so that kernel uses event to wakeup core.

Signed-off-by: Wu Zhou <[email protected]>
  • Loading branch information
izhouwu committed Nov 21, 2024
1 parent d427fd8 commit ca78549
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion arch/x86/include/asm/mwait.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <asm/cpufeature.h>
#include <asm/nospec-branch.h>
#include <asm/hypervisor.h>

#define MWAIT_SUBSTATE_MASK 0xf
#define MWAIT_CSTATE_MASK 0xf
Expand Down Expand Up @@ -115,8 +116,13 @@ static inline void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
}

__monitor((void *)&current_thread_info()->flags, 0, 0);
if (!need_resched())
if (!need_resched()) {
if (hypervisor_is_type(X86_HYPER_ACRN)) {
current_clr_polling();
ecx |= 0x4;
}
__mwait(eax, ecx);
}
}
current_clr_polling();
}
Expand Down

0 comments on commit ca78549

Please sign in to comment.