Skip to contentSkip to conversation

hvm/svm: Enable vm events for SVM

PATCH In review Alexandru Isaila 4 participants 9 messages Feb 19, 2018 – Feb 20, 2018

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 asm-x86/monitor: Add MONITOR_EVENT_INTERRUPT to common capabilities

---
 xen/include/asm-x86/monitor.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/asm-x86/monitor.h +1 -1
index 59a2610..7a9e1e8 100644
@@ -80,13 +80,13 @@ static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
     capabilities = ((1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) |
+                    (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG));
 
     if ( cpu_has_vmx )
     {
         capabilities |= ((1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
                          (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
-                         (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) |
                          (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED));
 
         /* Since we know this is on VMX, we can just call the hvm func */
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] asm-x86/monitor: Add MONITOR_EVENT_INTERRUPT to common capabilities

Quoted 15 lines · Alexandru Isaila
---
 xen/include/asm-x86/monitor.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/asm-x86/monitor.h +1 -0
index 59a2610..7a9e1e8 100644
@@ -80,13 +80,13 @@ static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
     capabilities = ((1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) |
+                    (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) |

xen/include/asm-x86/monitor.h static inline uint32_t arch_monitor_get_capabilities(struct domain *d) · line 92

Quoted 10 lines
xen/include/asm-x86/monitor.h +0 -1
                     (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG));
 
     if ( cpu_has_vmx )
     {
         capabilities |= ((1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
                          (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
-                         (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) |
                          (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED));
 
         /* Since we know this is on VMX, we can just call the hvm func */

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

#3 lore raw

PATCH 2/2 hvm/svm: Implement CPUID events

In reply to Alexandru Isaila

At this moment the CPUID events for the AMD architecture are not forwarded to the monitor layer.

This patch adds the CPUID event to the common capabilities and then forwards the event to the monitor layer.

---
 xen/arch/x86/hvm/svm/svm.c    | 8 +++++++-
 xen/include/asm-x86/monitor.h | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/svm/svm.c +7 -1
index e36ad05..0f1c57d 100644
@@ -1804,6 +1804,7 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
     struct vcpu *curr = current;
     unsigned int inst_len;
     struct cpuid_leaf res;
+    int rc = 0;
 
     if ( (inst_len = __get_instruction_length(curr, INSTR_CPUID)) == 0 )
         return;
@@ -1822,7 +1823,12 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
     regs->rcx = res.c;
     regs->rdx = res.d;
 
-    __update_guest_eip(regs, inst_len);
+    rc = hvm_monitor_cpuid(inst_len, regs->eax, regs->ecx);
+
+    if ( !rc )
+    {
+        __update_guest_eip(regs, inst_len);
+    }
 }
 
 static void svm_vmexit_do_cr_access(
xen/include/asm-x86/monitor.h +1 -1
index 7a9e1e8..99ed4b87 100644
@@ -81,12 +81,12 @@ static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
                     (1U << XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) |
+                    (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG));
 
     if ( cpu_has_vmx )
     {
         capabilities |= ((1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
-                         (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
                          (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED));
 
         /* Since we know this is on VMX, we can just call the hvm func */
Signature · 7 lines
2.7.4


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

Re: [PATCH v1 2/2] hvm/svm: Implement CPUID events

Quoted 25 lines · Alexandru Isaila

At this moment the CPUID events for the AMD architecture are not forwarded to the monitor layer.

This patch adds the CPUID event to the common capabilities and then forwards the event to the monitor layer.

---
 xen/arch/x86/hvm/svm/svm.c    | 8 +++++++-
 xen/include/asm-x86/monitor.h | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/svm/svm.c +1 -0
index e36ad05..0f1c57d 100644
@@ -1804,6 +1804,7 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
     struct vcpu *curr = current;
     unsigned int inst_len;
     struct cpuid_leaf res;
+    int rc = 0;
 
     if ( (inst_len = __get_instruction_length(curr, INSTR_CPUID)) == 0 )
         return;

xen/arch/x86/hvm/svm/svm.c static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs) · line 1828

Quoted 7 lines
xen/arch/x86/hvm/svm/svm.c +3 -1
@@ -1822,7 +1823,12 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
     regs->rcx = res.c;
     regs->rdx = res.d;
 
-    __update_guest_eip(regs, inst_len);
+    rc = hvm_monitor_cpuid(inst_len, regs->eax, regs->ecx);
+
+    if ( !rc )

Missing the rc < 0 case handling.

Quoted 25 lines
xen/arch/x86/hvm/svm/svm.c +3 -0
+    {
+        __update_guest_eip(regs, inst_len);
+    }
 }
 
 static void svm_vmexit_do_cr_access(
xen/include/asm-x86/monitor.h +1 -2
index 7a9e1e8..99ed4b87 100644
@@ -81,12 +81,12 @@ static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
                     (1U << XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) |
+                    (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG));
 
     if ( cpu_has_vmx )
     {
         capabilities |= ((1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
-                         (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
                          (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED));
 
         /* Since we know this is on VMX, we can just call the hvm func */
--
Quoted 1 line

2.7.4

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

#5 lore raw

Re: [PATCH v1 2/2] hvm/svm: Implement CPUID events

Quoted 30 lines · Tamas K Lengyel
Quoted 28 lines · Alexandru Isaila

At this moment the CPUID events for the AMD architecture are not forwarded to the monitor layer.

This patch adds the CPUID event to the common capabilities and then forwards the event to the monitor layer.

---
 xen/arch/x86/hvm/svm/svm.c    | 8 +++++++-
 xen/include/asm-x86/monitor.h | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/svm/svm.c +1 -0
index e36ad05..0f1c57d 100644
@@ -1804,6 +1804,7 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
     struct vcpu *curr = current;
     unsigned int inst_len;
     struct cpuid_leaf res;
+    int rc = 0;
 
     if ( (inst_len = __get_instruction_length(curr, INSTR_CPUID)) == 0 )
         return;
@@ -1822,7 +1823,12 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
     regs->rcx = res.c;
     regs->rdx = res.d;
 
Quoted 10 lines

xen/arch/x86/hvm/svm/svm.c static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs) · line 1828

Quoted 4 lines
xen/arch/x86/hvm/svm/svm.c +3 -1
-    __update_guest_eip(regs, inst_len);
+    rc = hvm_monitor_cpuid(inst_len, regs->eax, regs->ecx);
+
+    if ( !rc )

Missing the rc < 0 case handling.

Quoted 3 lines
xen/arch/x86/hvm/svm/svm.c +3 -0
+    {
+        __update_guest_eip(regs, inst_len);
+    }

Please also lose the unnecessary scope here.

Thanks,
Razvan

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

#6 lore raw

Re: [PATCH v1 2/2] hvm/svm: Implement CPUID events

In reply to Tamas K Lengyel
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 19.02.18 at 16:25, <[email protected]> wrote:
Quoted 4 lines · Alexandru Isaila
xen/arch/x86/hvm/svm/svm.c +0 -0
@@ -1822,7 +1823,12 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
     regs->rcx = res.c;
     regs->rdx = res.d;
 
Quoted 10 lines

xen/arch/x86/hvm/svm/svm.c static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs) · line 1828

Quoted 4 lines
xen/arch/x86/hvm/svm/svm.c +3 -1
-    __update_guest_eip(regs, inst_len);
+    rc = hvm_monitor_cpuid(inst_len, regs->eax, regs->ecx);
+
+    if ( !rc )

Missing the rc < 0 case handling.

Quoted 3 lines
xen/arch/x86/hvm/svm/svm.c +3 -0
+    {
+        __update_guest_eip(regs, inst_len);
+    }

Also please omit the braces in cases like this one.

Jan

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

#7 lore raw

Re: [PATCH v1 2/2] hvm/svm: Implement CPUID events

In reply to Tamas K Lengyel
Quoted 35 lines · Tamas K Lengyel
Quoted 33 lines · Alexandru Isaila

At this moment the CPUID events for the AMD architecture are not forwarded to the monitor layer.

This patch adds the CPUID event to the common capabilities and then forwards the event to the monitor layer.

---
 xen/arch/x86/hvm/svm/svm.c    | 8 +++++++-
 xen/include/asm-x86/monitor.h | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/svm/svm.c +1 -0
index e36ad05..0f1c57d 100644
@@ -1804,6 +1804,7 @@ static void svm_vmexit_do_cpuid(struct
 cpu_user_regs *regs)
     struct vcpu *curr = current;
     unsigned int inst_len;
     struct cpuid_leaf res;
+    int rc = 0;
 
     if ( (inst_len = __get_instruction_length(curr, INSTR_CPUID))

== 0 )

         return;
xen/arch/x86/hvm/svm/svm.c +0 -0
@@ -1822,7 +1823,12 @@ static void svm_vmexit_do_cpuid(struct
 cpu_user_regs *regs)
     regs->rcx = res.c;
     regs->rdx = res.d;
 
Quoted 5 lines

xen/arch/x86/hvm/svm/svm.c static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs) · line 1828

Quoted 4 lines
xen/arch/x86/hvm/svm/svm.c +3 -1
-    __update_guest_eip(regs, inst_len);
+    rc = hvm_monitor_cpuid(inst_len, regs->eax, regs->ecx);
+
+    if ( !rc )

Missing the rc < 0 case handling.

Hi Tamas,

I think we can resolve this in 2 ways:
1. I do it like on the vmx side and take the __update_guest_eip out of the function, return the result from hvm_monitor_cpuid and handle the result in the case statement.
2. I can handle the !rc in the function and the rc < 0 in the case statement.

What do you prefer so we can skip version 3 of the patch?

~Alex

________________________
This email was scanned by Bitdefender
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw

Re: [PATCH v1 2/2] hvm/svm: Implement CPUID events

Quoted 41 lines · Alexandru Stefan ISAILA
Quoted 35 lines · Tamas K Lengyel
Quoted 33 lines · Alexandru Isaila

At this moment the CPUID events for the AMD architecture are not forwarded to the monitor layer.

This patch adds the CPUID event to the common capabilities and then forwards the event to the monitor layer.

---
 xen/arch/x86/hvm/svm/svm.c    | 8 +++++++-
 xen/include/asm-x86/monitor.h | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/svm/svm.c +1 -0
index e36ad05..0f1c57d 100644
@@ -1804,6 +1804,7 @@ static void svm_vmexit_do_cpuid(struct
 cpu_user_regs *regs)
     struct vcpu *curr = current;
     unsigned int inst_len;
     struct cpuid_leaf res;
+    int rc = 0;
 
     if ( (inst_len = __get_instruction_length(curr, INSTR_CPUID))

== 0 )

         return;
xen/arch/x86/hvm/svm/svm.c +0 -0
@@ -1822,7 +1823,12 @@ static void svm_vmexit_do_cpuid(struct
 cpu_user_regs *regs)
     regs->rcx = res.c;
     regs->rdx = res.d;
 
Quoted 5 lines

xen/arch/x86/hvm/svm/svm.c static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs) · line 1828

Quoted 4 lines
xen/arch/x86/hvm/svm/svm.c +3 -1
-    __update_guest_eip(regs, inst_len);
+    rc = hvm_monitor_cpuid(inst_len, regs->eax, regs->ecx);
+
+    if ( !rc )

Missing the rc < 0 case handling.

Quoted 6 lines

Hi Tamas,

I think we can resolve this in 2 ways:
1. I do it like on the vmx side and take the __update_guest_eip out of the function, return the result from hvm_monitor_cpuid and handle the result in the case statement.

+1, I think it helps if the flow is the same across vmx and svm as much as possible.

Thanks,
Tamas

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