@@ -127,6 +127,9 @@ void monitor_ctrlreg_write_data(struct vcpu *v)
{
struct monitor_write_data *w = &v->arch.vm_event->write_data;
+ if ( likely(!w->writes_pending) )
+ return;
+
if ( w->do_write.msr )
{
hvm_msr_write_intercept(w->msr, w->value, 0);
@@ -260,12 +260,17 @@ struct pv_domain
};
struct monitor_write_data {
- struct {
- unsigned int msr : 1;
- unsigned int cr0 : 1;
- unsigned int cr3 : 1;
- unsigned int cr4 : 1;
- } do_write;
+ union {
+ struct {
+ unsigned int msr : 1;
+ unsigned int cr0 : 1;
+ unsigned int cr3 : 1;
+ unsigned int cr4 : 1;
+ } do_write;
+
+ /* Non-zero when at least one of do_write fields is 1. */
+ unsigned int writes_pending;
+ };
uint32_t msr;
uint64_t value;
Introduce writes_pending field in monitor_write_data structure to slightly optimize code @ monitor_write_data(): avoid having to check each bit when -all- bits are zero (which is likely). Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com> --- xen/arch/x86/monitor.c | 3 +++ xen/include/asm-x86/domain.h | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-)