Skip to contentSkip to conversation

x86/hvm: Clean up the rest of bool_t from vm_event

PATCH In review Alexandru Stefan ISAILA 4 participants 6 messages Oct 29, 2018 – Nov 5, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/hvm: Clean up the rest of bool_t from vm_event

---
Changes since V1:
- Made style corrections suggested by Jan.

---
 xen/arch/x86/hvm/hvm.c            | 3 ++-
 xen/arch/x86/mm/mem_sharing.c     | 2 +-
 xen/arch/x86/mm/p2m.c             | 5 ++---
 xen/common/memory.c               | 2 +-
 xen/common/vm_event.c             | 4 ++--
 xen/include/asm-x86/mem_sharing.h | 2 +-
 xen/include/xen/vm_event.h        | 8 ++++----
 7 files changed, 13 insertions(+), 13 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -1
index a140e60c9c..a8566fb87c 100644
@@ -1905,7 +1905,8 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
     if ( sharing_enomem )
     {
         int rv;
-        if ( (rv = mem_sharing_notify_enomem(currd, gfn, 1)) < 0 )
+
+        if ( (rv = mem_sharing_notify_enomem(currd, gfn, true)) < 0 )
         {
             gdprintk(XENLOG_ERR, "Domain %hu attempt to unshare "
                      "gfn %lx, ENOMEM and no helper (rc %d)\n",
xen/arch/x86/mm/mem_sharing.c +1 -1
index 1dab2c8cc3..be09c8871a 100644
@@ -546,7 +546,7 @@ static int audit(void)
 }
 
 int mem_sharing_notify_enomem(struct domain *d, unsigned long gfn,
-                                bool_t allow_sleep) 
+                              bool allow_sleep)
 {
     struct vcpu *v = current;
     int rc;
xen/arch/x86/mm/p2m.c +2 -3
index a00a3c1bff..4bdc5e34e0 100644
@@ -448,7 +448,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l,
         /* Try to unshare. If we fail, communicate ENOMEM without
          * sleeping. */
         if ( mem_sharing_unshare_page(p2m->domain, gfn_l, 0) < 0 )
-            (void)mem_sharing_notify_enomem(p2m->domain, gfn_l, 0);
+            mem_sharing_notify_enomem(p2m->domain, gfn_l, false);
         mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order, NULL);
     }
 
@@ -839,8 +839,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
                  * Foreign domains are okay to place an event as they 
                  * won't go to sleep. */
                 (void)mem_sharing_notify_enomem(p2m->domain,
-                                                gfn_x(gfn_add(gfn, i)),
-                                                0);
+                                                gfn_x(gfn_add(gfn, i)), false);
                 return rc;
             }
             omfn = p2m->get_entry(p2m, gfn_add(gfn, i),
xen/common/memory.c +1 -1
index 987395fbb3..b68efd4d9f 100644
@@ -356,7 +356,7 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
         rc = mem_sharing_unshare_page(d, gmfn, 0);
         if ( rc )
         {
-            (void)mem_sharing_notify_enomem(d, gmfn, 0);
+            mem_sharing_notify_enomem(d, gmfn, false);
             goto out_put_gfn;
         }
         /* Maybe the mfn changed */
xen/common/vm_event.c +2 -2
index 6ffd18a448..26cfa2c605 100644
@@ -496,7 +496,7 @@ static int vm_event_wait_slot(struct vm_event_domain *ved)
     return rc;
 }
 
-bool_t vm_event_check_ring(struct vm_event_domain *ved)
+bool vm_event_check_ring(struct vm_event_domain *ved)
 {
     return (ved && ved->ring_page);
 }
@@ -514,7 +514,7 @@ bool_t vm_event_check_ring(struct vm_event_domain *ved)
  *
  */
 int __vm_event_claim_slot(struct domain *d, struct vm_event_domain *ved,
-                          bool_t allow_sleep)
+                          bool allow_sleep)
 {
     if ( !vm_event_check_ring(ved) )
         return -EOPNOTSUPP;
xen/include/asm-x86/mem_sharing.h +1 -1
index 91908924df..0e77b7d935 100644
@@ -84,7 +84,7 @@ static inline int mem_sharing_unshare_page(struct domain *d,
  * then it's the same as a foreign domain.
  */
 int mem_sharing_notify_enomem(struct domain *d, unsigned long gfn,
-                                bool_t allow_sleep);
+                              bool allow_sleep);
 int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg);
 int mem_sharing_domctl(struct domain *d, 
                        struct xen_domctl_mem_sharing_op *mec);
xen/include/xen/vm_event.h +4 -4
index 2ff6e1c333..5302ee55c1 100644
@@ -30,7 +30,7 @@
 void vm_event_cleanup(struct domain *d);
 
 /* Returns whether a ring has been set up */
-bool_t vm_event_check_ring(struct vm_event_domain *ved);
+bool vm_event_check_ring(struct vm_event_domain *ved);
 
 /* Returns 0 on success, -ENOSYS if there is no ring, -EBUSY if there is no
  * available space and the caller is a foreign domain. If the guest itself
@@ -46,17 +46,17 @@ bool_t vm_event_check_ring(struct vm_event_domain *ved);
  * succeed.
  */
 int __vm_event_claim_slot(struct domain *d, struct vm_event_domain *ved,
-                          bool_t allow_sleep);
+                          bool allow_sleep);
 static inline int vm_event_claim_slot(struct domain *d,
                                       struct vm_event_domain *ved)
 {
-    return __vm_event_claim_slot(d, ved, 1);
+    return __vm_event_claim_slot(d, ved, true);
 }
 
 static inline int vm_event_claim_slot_nosleep(struct domain *d,
                                               struct vm_event_domain *ved)
 {
-    return __vm_event_claim_slot(d, ved, 0);
+    return __vm_event_claim_slot(d, ved, false);
 }
 
 void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved);
Signature · 7 lines
2.17.1


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

Any changes required for this to go in?

Regards,
Alex

Quoted 140 lines · Alexandru Stefan ISAILA

---
Changes since V1:
- Made style corrections suggested by Jan.

---
  xen/arch/x86/hvm/hvm.c            | 3 ++-
  xen/arch/x86/mm/mem_sharing.c     | 2 +-
  xen/arch/x86/mm/p2m.c             | 5 ++---
  xen/common/memory.c               | 2 +-
  xen/common/vm_event.c             | 4 ++--
  xen/include/asm-x86/mem_sharing.h | 2 +-
  xen/include/xen/vm_event.h        | 8 ++++----
  7 files changed, 13 insertions(+), 13 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -1
index a140e60c9c..a8566fb87c 100644
@@ -1905,7 +1905,8 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
      if ( sharing_enomem )
      {
          int rv;
-        if ( (rv = mem_sharing_notify_enomem(currd, gfn, 1)) < 0 )
+
+        if ( (rv = mem_sharing_notify_enomem(currd, gfn, true)) < 0 )
          {
              gdprintk(XENLOG_ERR, "Domain %hu attempt to unshare "
                       "gfn %lx, ENOMEM and no helper (rc %d)\n",
xen/arch/x86/mm/mem_sharing.c +1 -1
index 1dab2c8cc3..be09c8871a 100644
@@ -546,7 +546,7 @@ static int audit(void)
  }
 
  int mem_sharing_notify_enomem(struct domain *d, unsigned long gfn,
-                                bool_t allow_sleep)
+                              bool allow_sleep)
  {
      struct vcpu *v = current;
      int rc;
xen/arch/x86/mm/p2m.c +2 -3
index a00a3c1bff..4bdc5e34e0 100644
@@ -448,7 +448,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l,
          /* Try to unshare. If we fail, communicate ENOMEM without
           * sleeping. */
          if ( mem_sharing_unshare_page(p2m->domain, gfn_l, 0) < 0 )
-            (void)mem_sharing_notify_enomem(p2m->domain, gfn_l, 0);
+            mem_sharing_notify_enomem(p2m->domain, gfn_l, false);
          mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order, NULL);
      }
 
@@ -839,8 +839,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
                   * Foreign domains are okay to place an event as they
                   * won't go to sleep. */
                  (void)mem_sharing_notify_enomem(p2m->domain,
-                                                gfn_x(gfn_add(gfn, i)),
-                                                0);
+                                                gfn_x(gfn_add(gfn, i)), false);
                  return rc;
              }
              omfn = p2m->get_entry(p2m, gfn_add(gfn, i),
xen/common/memory.c +1 -1
index 987395fbb3..b68efd4d9f 100644
@@ -356,7 +356,7 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
          rc = mem_sharing_unshare_page(d, gmfn, 0);
          if ( rc )
          {
-            (void)mem_sharing_notify_enomem(d, gmfn, 0);
+            mem_sharing_notify_enomem(d, gmfn, false);
              goto out_put_gfn;
          }
          /* Maybe the mfn changed */
xen/common/vm_event.c +2 -2
index 6ffd18a448..26cfa2c605 100644
@@ -496,7 +496,7 @@ static int vm_event_wait_slot(struct vm_event_domain *ved)
      return rc;
  }
 
-bool_t vm_event_check_ring(struct vm_event_domain *ved)
+bool vm_event_check_ring(struct vm_event_domain *ved)
  {
      return (ved && ved->ring_page);
  }
@@ -514,7 +514,7 @@ bool_t vm_event_check_ring(struct vm_event_domain *ved)
   *
   */
  int __vm_event_claim_slot(struct domain *d, struct vm_event_domain *ved,
-                          bool_t allow_sleep)
+                          bool allow_sleep)
  {
      if ( !vm_event_check_ring(ved) )
          return -EOPNOTSUPP;
xen/include/asm-x86/mem_sharing.h +1 -1
index 91908924df..0e77b7d935 100644
@@ -84,7 +84,7 @@ static inline int mem_sharing_unshare_page(struct domain *d,
   * then it's the same as a foreign domain.
   */
  int mem_sharing_notify_enomem(struct domain *d, unsigned long gfn,
-                                bool_t allow_sleep);
+                              bool allow_sleep);
  int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg);
  int mem_sharing_domctl(struct domain *d,
                         struct xen_domctl_mem_sharing_op *mec);
xen/include/xen/vm_event.h +3 -3
index 2ff6e1c333..5302ee55c1 100644
@@ -30,7 +30,7 @@
  void vm_event_cleanup(struct domain *d);
 
  /* Returns whether a ring has been set up */
-bool_t vm_event_check_ring(struct vm_event_domain *ved);
+bool vm_event_check_ring(struct vm_event_domain *ved);
 
  /* Returns 0 on success, -ENOSYS if there is no ring, -EBUSY if there is no
   * available space and the caller is a foreign domain. If the guest itself
@@ -46,17 +46,17 @@ bool_t vm_event_check_ring(struct vm_event_domain *ved);
   * succeed.
   */
  int __vm_event_claim_slot(struct domain *d, struct vm_event_domain *ved,
-                          bool_t allow_sleep);
+                          bool allow_sleep);
  static inline int vm_event_claim_slot(struct domain *d,
                                        struct vm_event_domain *ved)
  {
-    return __vm_event_claim_slot(d, ved, 1);
+    return __vm_event_claim_slot(d, ved, true);

xen/include/xen/vm_event.h bool_t vm_event_check_ring(struct vm_event_domain *ved); · line 62

Quoted 10 lines
xen/include/xen/vm_event.h +1 -1
  }
 
  static inline int vm_event_claim_slot_nosleep(struct domain *d,
                                                struct vm_event_domain *ved)
  {
-    return __vm_event_claim_slot(d, ved, 0);
+    return __vm_event_claim_slot(d, ved, false);
  }
 
  void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved);

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

#2 lore raw
In reply to Alexandru Stefan ISAILA
Quoted 49 lines · Alexandru Stefan ISAILA

---
Changes since V1:
- Made style corrections suggested by Jan.

---
 xen/arch/x86/hvm/hvm.c            | 3 ++-
 xen/arch/x86/mm/mem_sharing.c     | 2 +-
 xen/arch/x86/mm/p2m.c             | 5 ++---
 xen/common/memory.c               | 2 +-
 xen/common/vm_event.c             | 4 ++--
 xen/include/asm-x86/mem_sharing.h | 2 +-
 xen/include/xen/vm_event.h        | 8 ++++----
 7 files changed, 13 insertions(+), 13 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -1
index a140e60c9c..a8566fb87c 100644
@@ -1905,7 +1905,8 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
     if ( sharing_enomem )
     {
         int rv;
-        if ( (rv = mem_sharing_notify_enomem(currd, gfn, 1)) < 0 )
+
+        if ( (rv = mem_sharing_notify_enomem(currd, gfn, true)) < 0 )
         {
             gdprintk(XENLOG_ERR, "Domain %hu attempt to unshare "
                      "gfn %lx, ENOMEM and no helper (rc %d)\n",
xen/arch/x86/mm/mem_sharing.c +1 -1
index 1dab2c8cc3..be09c8871a 100644
@@ -546,7 +546,7 @@ static int audit(void)
 }
 
 int mem_sharing_notify_enomem(struct domain *d, unsigned long gfn,
-                                bool_t allow_sleep) 
+                              bool allow_sleep)
 {
     struct vcpu *v = current;
     int rc;
xen/arch/x86/mm/p2m.c +0 -0
index a00a3c1bff..4bdc5e34e0 100644

xen/arch/x86/mm/p2m.c mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l, · line 451

Quoted 5 lines
xen/arch/x86/mm/p2m.c +1 -1
@@ -448,7 +448,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l,
         /* Try to unshare. If we fail, communicate ENOMEM without
          * sleeping. */
         if ( mem_sharing_unshare_page(p2m->domain, gfn_l, 0) < 0 )
-            (void)mem_sharing_notify_enomem(p2m->domain, gfn_l, 0);
+            mem_sharing_notify_enomem(p2m->domain, gfn_l, false);

Why do you remove the (void) cast here...

xen/arch/x86/mm/p2m.c guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, · line 842

Quoted 10 lines
xen/arch/x86/mm/p2m.c +1 -2
         mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order, NULL);
     }
 
@@ -839,8 +839,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
                  * Foreign domains are okay to place an event as they 
                  * won't go to sleep. */
                 (void)mem_sharing_notify_enomem(p2m->domain,
-                                                gfn_x(gfn_add(gfn, i)),
-                                                0);
+                                                gfn_x(gfn_add(gfn, i)), false);

...but not here?

-George

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

#3 lore raw
Quoted 61 lines · George Dunlap
Quoted 49 lines · Alexandru Stefan ISAILA

---
Changes since V1:
- Made style corrections suggested by Jan.

---
 xen/arch/x86/hvm/hvm.c            | 3 ++-
 xen/arch/x86/mm/mem_sharing.c     | 2 +-
 xen/arch/x86/mm/p2m.c             | 5 ++---
 xen/common/memory.c               | 2 +-
 xen/common/vm_event.c             | 4 ++--
 xen/include/asm-x86/mem_sharing.h | 2 +-
 xen/include/xen/vm_event.h        | 8 ++++----
 7 files changed, 13 insertions(+), 13 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -1
index a140e60c9c..a8566fb87c 100644
@@ -1905,7 +1905,8 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
     if ( sharing_enomem )
     {
         int rv;
-        if ( (rv = mem_sharing_notify_enomem(currd, gfn, 1)) < 0 )
+
+        if ( (rv = mem_sharing_notify_enomem(currd, gfn, true)) < 0 )
         {
             gdprintk(XENLOG_ERR, "Domain %hu attempt to unshare "
                      "gfn %lx, ENOMEM and no helper (rc %d)\n",
xen/arch/x86/mm/mem_sharing.c +1 -1
index 1dab2c8cc3..be09c8871a 100644
@@ -546,7 +546,7 @@ static int audit(void)
 }
 
 int mem_sharing_notify_enomem(struct domain *d, unsigned long gfn,
-                                bool_t allow_sleep) 
+                              bool allow_sleep)
 {
     struct vcpu *v = current;
     int rc;
xen/arch/x86/mm/p2m.c +0 -0
index a00a3c1bff..4bdc5e34e0 100644

xen/arch/x86/mm/p2m.c mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l, · line 451

Quoted 5 lines
xen/arch/x86/mm/p2m.c +1 -1
@@ -448,7 +448,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l,
         /* Try to unshare. If we fail, communicate ENOMEM without
          * sleeping. */
         if ( mem_sharing_unshare_page(p2m->domain, gfn_l, 0) < 0 )
-            (void)mem_sharing_notify_enomem(p2m->domain, gfn_l, 0);
+            mem_sharing_notify_enomem(p2m->domain, gfn_l, false);

Why do you remove the (void) cast here...

Quoted 3 lines
xen/arch/x86/mm/p2m.c +0 -0
         mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order, NULL);
     }
 
Quoted 9 lines

xen/arch/x86/mm/p2m.c guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, · line 842

Quoted 7 lines
xen/arch/x86/mm/p2m.c +1 -2
@@ -839,8 +839,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
                  * Foreign domains are okay to place an event as they 
                  * won't go to sleep. */
                 (void)mem_sharing_notify_enomem(p2m->domain,
-                                                gfn_x(gfn_add(gfn, i)),
-                                                0);
+                                                gfn_x(gfn_add(gfn, i)), false);

...but not here?

That's what Jan has recommended here:

https://lists.xenproject.org/archives/html/xen-devel/2018-10/msg02289.html

Thanks,
Razvan

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

#4 lore raw
In reply to George Dunlap
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 05.11.18 at 17:17, <[email protected]> wrote:

xen/arch/x86/mm/p2m.c mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l, · line 451

Quoted 8 lines · Alexandru Stefan ISAILA
xen/arch/x86/mm/p2m.c +1 -1
@@ -448,7 +448,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l,
         /* Try to unshare. If we fail, communicate ENOMEM without
          * sleeping. */
         if ( mem_sharing_unshare_page(p2m->domain, gfn_l, 0) < 0 )
-            (void)mem_sharing_notify_enomem(p2m->domain, gfn_l, 0);
+            mem_sharing_notify_enomem(p2m->domain, gfn_l, false);

Why do you remove the (void) cast here...

Quoted 3 lines
xen/arch/x86/mm/p2m.c +0 -0
         mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order, NULL);
     }
 
Quoted 9 lines

xen/arch/x86/mm/p2m.c guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, · line 842

Quoted 7 lines
xen/arch/x86/mm/p2m.c +1 -2
@@ -839,8 +839,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
                  * Foreign domains are okay to place an event as they 
                  * won't go to sleep. */
                 (void)mem_sharing_notify_enomem(p2m->domain,
-                                                gfn_x(gfn_add(gfn, i)),
-                                                0);
+                                                gfn_x(gfn_add(gfn, i)), false);

...but not here?

I had asked that it strictly be removed from lines touched anyway, and I left it to their discretion to leave alone neighboring lines. Of course it would have helped if the description said so.

Jan

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

Acked-by
#5 lore raw
Quoted 26 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 05.11.18 at 17:17, <[email protected]> wrote:

xen/arch/x86/mm/p2m.c mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l, · line 451

Quoted 8 lines · Alexandru Stefan ISAILA
xen/arch/x86/mm/p2m.c +1 -1
@@ -448,7 +448,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l,
         /* Try to unshare. If we fail, communicate ENOMEM without
          * sleeping. */
         if ( mem_sharing_unshare_page(p2m->domain, gfn_l, 0) < 0 )
-            (void)mem_sharing_notify_enomem(p2m->domain, gfn_l, 0);
+            mem_sharing_notify_enomem(p2m->domain, gfn_l, false);

Why do you remove the (void) cast here...

Quoted 3 lines
xen/arch/x86/mm/p2m.c +0 -0
         mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order, NULL);
     }
 
Quoted 9 lines

xen/arch/x86/mm/p2m.c guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, · line 842

Quoted 7 lines
xen/arch/x86/mm/p2m.c +1 -2
@@ -839,8 +839,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
                  * Foreign domains are okay to place an event as they 
                  * won't go to sleep. */
                 (void)mem_sharing_notify_enomem(p2m->domain,
-                                                gfn_x(gfn_add(gfn, i)),
-                                                0);
+                                                gfn_x(gfn_add(gfn, i)), false);

...but not here?

Quoted 3 lines

I had asked that it strictly be removed from lines touched anyway, and I left it to their discretion to leave alone neighboring lines. Of course it would have helped if the description said so.

Right. In that case:

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