Skip to contentSkip to conversation

tests/xen-access: disable CR4 write events on application exit

PATCH Superseded Razvan Cojocaru 2 participants 4 messages Jan 29, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/xen-access: disable CR4 write events on application exit

On exit, xen-access did not unsubscribe from CR4 write vm_events, potentially leaving the guest stuck.

---
 tools/tests/xen-access/xen-access.c | 2 ++
 1 file changed, 2 insertions(+)
tools/tests/xen-access/xen-access.c +2 -0
index 9d960e2..c572550 100644
@@ -654,6 +654,8 @@ int main(int argc, char *argv[])
                 rc = xc_monitor_cpuid(xch, domain_id, 0);
             if ( desc_access )
                 rc = xc_monitor_descriptor_access(xch, domain_id, 0);
+            if ( write_ctrlreg_cr4 )
+                rc = xc_monitor_write_ctrlreg(xch, domain_id, VM_EVENT_X86_CR4, 0, 1, 0, 1);
 
             if ( privcall )
                 rc = xc_monitor_privileged_call(xch, domain_id, 0);
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 13 lines · Razvan Cojocaru

On exit, xen-access did not unsubscribe from CR4 write vm_events, potentially leaving the guest stuck.

---
 tools/tests/xen-access/xen-access.c | 2 ++
 1 file changed, 2 insertions(+)
tools/tests/xen-access/xen-access.c +0 -0
index 9d960e2..c572550 100644

tools/tests/xen-access/xen-access.c int main(int argc, char *argv[]) · line 658

Quoted 5 lines
tools/tests/xen-access/xen-access.c +2 -0
@@ -654,6 +654,8 @@ int main(int argc, char *argv[])
                 rc = xc_monitor_cpuid(xch, domain_id, 0);
             if ( desc_access )
                 rc = xc_monitor_descriptor_access(xch, domain_id, 0);
+            if ( write_ctrlreg_cr4 )
+                rc = xc_monitor_write_ctrlreg(xch, domain_id, VM_EVENT_X86_CR4, 0, 1, 0, 1);

Any reason for the sync and onchangeonly parts to be set to 1 here? I don't think it has any effect when you are disabling an event.

Tamas

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 10 lines · Tamas K Lengyel
Quoted 8 lines · Razvan Cojocaru

On exit, xen-access did not unsubscribe from CR4 write vm_events, potentially leaving the guest stuck.

---
 tools/tests/xen-access/xen-access.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 13 lines

tools/tests/xen-access/xen-access.c int main(int argc, char *argv[]) · line 658

Quoted 10 lines
tools/tests/xen-access/xen-access.c +2 -0
index 9d960e2..c572550 100644
@@ -654,6 +654,8 @@ int main(int argc, char *argv[])
                 rc = xc_monitor_cpuid(xch, domain_id, 0);
             if ( desc_access )
                 rc = xc_monitor_descriptor_access(xch, domain_id, 0);
+            if ( write_ctrlreg_cr4 )
+                rc = xc_monitor_write_ctrlreg(xch, domain_id, VM_EVENT_X86_CR4, 0, 1, 0, 1);

Any reason for the sync and onchangeonly parts to be set to 1 here? I don't think it has any effect when you are disabling an event.

Nope, they don't matter at all. I've just copied the "enable" line, removed the mask so that the line would not go beyond 80 columns and kept the rest as it was.

If the parameter after the index (VM_EVENT_X86_CR4) is 0, the others don't matter.

But I can set them all to 0 if you prefer.

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 25 lines · Razvan Cojocaru
Quoted 10 lines · Tamas K Lengyel
Quoted 8 lines · Razvan Cojocaru

On exit, xen-access did not unsubscribe from CR4 write vm_events, potentially leaving the guest stuck.

---
 tools/tests/xen-access/xen-access.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 13 lines

tools/tests/xen-access/xen-access.c int main(int argc, char *argv[]) · line 658

Quoted 10 lines
tools/tests/xen-access/xen-access.c +2 -0
index 9d960e2..c572550 100644
@@ -654,6 +654,8 @@ int main(int argc, char *argv[])
                 rc = xc_monitor_cpuid(xch, domain_id, 0);
             if ( desc_access )
                 rc = xc_monitor_descriptor_access(xch, domain_id, 0);
+            if ( write_ctrlreg_cr4 )
+                rc = xc_monitor_write_ctrlreg(xch, domain_id, VM_EVENT_X86_CR4, 0, 1, 0, 1);

Any reason for the sync and onchangeonly parts to be set to 1 here? I don't think it has any effect when you are disabling an event.

Quoted 8 lines

Nope, they don't matter at all. I've just copied the "enable" line, removed the mask so that the line would not go beyond 80 columns and kept the rest as it was.

If the parameter after the index (VM_EVENT_X86_CR4) is 0, the others don't matter.

But I can set them all to 0 if you prefer.

Just to keep things clean I would appreciate that.

Thanks,
Tamas

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel