[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 01/10] unify update_runstate_area()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 19 Oct 2022 09:38:25 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=COQfJ9cXtlA7UIJk7VaHsvDyCd7LmdLVrgloG0YU3Gg=; b=jjryaKi0TlalE8tNftmC+dFFcMr2DauN0YpAfAqcGzrqzveQsjRpk6rnpYnyWUJlxWY8wpl6HqvNmYy6Z9lWL/UJUukHsxlxRAHz6TF4deGRlF1UBnfBdwITtTLBCbsIX9K5wi88zz943KPBgi6CcQ7/8hGafzaqAirQEjz+QsnSjXmtmrsEsgLx455RsP+OOylsoc60UuDREVJgpODvK+0H1BR1Gw77pXoyEuEhsyWyQ0dXlOlAgKDMNH66auBszoyVAqkYehNFgWG7Z7u9Cak2wBQfLDzN9Ekn9cIs5/+uJERG29WhRgOSrHSp+mvgQ5OIo3BELmoGx7SMnHCDwg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FZXSvtQuIDjkdFus1q3OLD+4gR7p7iKbr9kjMGS6aneK8qr17tB9PDmpAr9Y364yp+8WxqOTalInYBtnmD8/dATU94ilMXVV0BD7n69Th8ELz0+ud5TA/hq22PrRDLQDHJESM/26NFPJxOYhJlO5A4cClOk6fMMfx588ZFf2Ia0XM86y9PUzbxW3fFej1VyEmt7Wl6B7JyvVjvBpnlsxYClXRuGgE6GapFg3etDSJr8b53t2h0aIbJd6hOQ8h6T1Lh5j57YLQtGpWaVMt/+/aLfN6HrpOPfOMe2t6YVawOILeenniplpJlyJ1Y8GqKqHNGMGOwlks1WSsP5m7XHNZQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
  • Delivery-date: Wed, 19 Oct 2022 07:38:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

x86'es variant is a superset of Arm's, with CONFIG_COMPAT parts already
properly marked. The only other missing piece is
update_guest_memory_policy(): For the time being Arm simply gains an
empty struct and inline function.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -281,38 +281,6 @@ static void ctxt_switch_to(struct vcpu *
     WRITE_SYSREG(n->arch.mdcr_el2, MDCR_EL2);
 }
 
-/* Update per-VCPU guest runstate shared memory area (if registered). */
-static void update_runstate_area(struct vcpu *v)
-{
-    void __user *guest_handle = NULL;
-    struct vcpu_runstate_info runstate;
-
-    if ( guest_handle_is_null(runstate_guest(v)) )
-        return;
-
-    memcpy(&runstate, &v->runstate, sizeof(runstate));
-
-    if ( VM_ASSIST(v->domain, runstate_update_flag) )
-    {
-        guest_handle = &v->runstate_guest.p->state_entry_time + 1;
-        guest_handle--;
-        runstate.state_entry_time |= XEN_RUNSTATE_UPDATE;
-        __raw_copy_to_guest(guest_handle,
-                            (void *)(&runstate.state_entry_time + 1) - 1, 1);
-        smp_wmb();
-    }
-
-    __copy_to_guest(runstate_guest(v), &runstate, 1);
-
-    if ( guest_handle )
-    {
-        runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE;
-        smp_wmb();
-        __raw_copy_to_guest(guest_handle,
-                            (void *)(&runstate.state_entry_time + 1) - 1, 1);
-    }
-}
-
 static void schedule_tail(struct vcpu *prev)
 {
     ASSERT(prev != current);
--- a/xen/arch/arm/include/asm/domain.h
+++ b/xen/arch/arm/include/asm/domain.h
@@ -295,6 +295,11 @@ struct arch_vcpu_io {
     struct instr_details dabt_instr; /* when the instruction is decoded */
 };
 
+struct guest_memory_policy {};
+static inline void update_guest_memory_policy(struct vcpu *v,
+                                              struct guest_memory_policy *gmp)
+{}
+
 #endif /* __ASM_DOMAIN_H__ */
 
 /*
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1852,64 +1852,6 @@ void cf_check paravirt_ctxt_switch_to(st
         wrmsr_tsc_aux(v->arch.msrs->tsc_aux);
 }
 
-/* Update per-VCPU guest runstate shared memory area (if registered). */
-bool update_runstate_area(struct vcpu *v)
-{
-    bool rc;
-    struct guest_memory_policy policy = { .nested_guest_mode = false };
-    void __user *guest_handle = NULL;
-    struct vcpu_runstate_info runstate;
-
-    if ( guest_handle_is_null(runstate_guest(v)) )
-        return true;
-
-    update_guest_memory_policy(v, &policy);
-
-    memcpy(&runstate, &v->runstate, sizeof(runstate));
-
-    if ( VM_ASSIST(v->domain, runstate_update_flag) )
-    {
-#ifdef CONFIG_COMPAT
-        guest_handle = has_32bit_shinfo(v->domain)
-            ? &v->runstate_guest.compat.p->state_entry_time + 1
-            : &v->runstate_guest.native.p->state_entry_time + 1;
-#else
-        guest_handle = &v->runstate_guest.p->state_entry_time + 1;
-#endif
-        guest_handle--;
-        runstate.state_entry_time |= XEN_RUNSTATE_UPDATE;
-        __raw_copy_to_guest(guest_handle,
-                            (void *)(&runstate.state_entry_time + 1) - 1, 1);
-        smp_wmb();
-    }
-
-#ifdef CONFIG_COMPAT
-    if ( has_32bit_shinfo(v->domain) )
-    {
-        struct compat_vcpu_runstate_info info;
-
-        XLAT_vcpu_runstate_info(&info, &runstate);
-        __copy_to_guest(v->runstate_guest.compat, &info, 1);
-        rc = true;
-    }
-    else
-#endif
-        rc = __copy_to_guest(runstate_guest(v), &runstate, 1) !=
-             sizeof(runstate);
-
-    if ( guest_handle )
-    {
-        runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE;
-        smp_wmb();
-        __raw_copy_to_guest(guest_handle,
-                            (void *)(&runstate.state_entry_time + 1) - 1, 1);
-    }
-
-    update_guest_memory_policy(v, &policy);
-
-    return rc;
-}
-
 static void _update_runstate_area(struct vcpu *v)
 {
     if ( !update_runstate_area(v) && is_pv_vcpu(v) &&
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -681,7 +681,6 @@ void update_guest_memory_policy(struct v
 
 void domain_cpu_policy_changed(struct domain *d);
 
-bool update_runstate_area(struct vcpu *);
 bool update_secondary_system_time(struct vcpu *,
                                   struct vcpu_time_info *);
 
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1579,6 +1579,64 @@ int default_initialise_vcpu(struct vcpu
     return rc;
 }
 
+/* Update per-VCPU guest runstate shared memory area (if registered). */
+bool update_runstate_area(struct vcpu *v)
+{
+    bool rc;
+    struct guest_memory_policy policy = { };
+    void __user *guest_handle = NULL;
+    struct vcpu_runstate_info runstate;
+
+    if ( guest_handle_is_null(runstate_guest(v)) )
+        return true;
+
+    update_guest_memory_policy(v, &policy);
+
+    memcpy(&runstate, &v->runstate, sizeof(runstate));
+
+    if ( VM_ASSIST(v->domain, runstate_update_flag) )
+    {
+#ifdef CONFIG_COMPAT
+        guest_handle = has_32bit_shinfo(v->domain)
+            ? &v->runstate_guest.compat.p->state_entry_time + 1
+            : &v->runstate_guest.native.p->state_entry_time + 1;
+#else
+        guest_handle = &v->runstate_guest.p->state_entry_time + 1;
+#endif
+        guest_handle--;
+        runstate.state_entry_time |= XEN_RUNSTATE_UPDATE;
+        __raw_copy_to_guest(guest_handle,
+                            (void *)(&runstate.state_entry_time + 1) - 1, 1);
+        smp_wmb();
+    }
+
+#ifdef CONFIG_COMPAT
+    if ( has_32bit_shinfo(v->domain) )
+    {
+        struct compat_vcpu_runstate_info info;
+
+        XLAT_vcpu_runstate_info(&info, &runstate);
+        __copy_to_guest(v->runstate_guest.compat, &info, 1);
+        rc = true;
+    }
+    else
+#endif
+        rc = __copy_to_guest(runstate_guest(v), &runstate, 1) !=
+             sizeof(runstate);
+
+    if ( guest_handle )
+    {
+        runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE;
+        smp_wmb();
+        __raw_copy_to_guest(guest_handle,
+                            (void *)(&runstate.state_entry_time + 1) - 1, 1);
+    }
+
+    update_guest_memory_policy(v, &policy);
+
+    return rc;
+}
+
 long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
     long rc = 0;
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -98,6 +98,8 @@ void arch_get_info_guest(struct vcpu *,
 int arch_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg);
 int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg);
 
+bool update_runstate_area(struct vcpu *);
+
 int domain_relinquish_resources(struct domain *d);
 
 void dump_pageframe_info(struct domain *d);




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.