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

[PATCH] xen/vcpu: remove vcpu_set_singleshot_timer flags field


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 18 Apr 2023 17:42:23 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=CUnHgYjtSUltMVGFEA0os/QHQZE4foAxTSPRIIYyuQQ=; b=J62MtTDUe/c/avRQDCAkuRAsNVlius8NSj1Z+TeMY/9sprFmUnvA7giTrEaoC979tSuw1ql8EKhBCUjwPnU3KYiUbUYTEwyjsL3bztM+fh45T+GTw4P4Yy508aiHIJ5SNOooYAyjOE8MPoReZ3SOcEkP6nsszMsq9utDQ9N3+cWeGjEu5wjNImL3wjvZrKR6k54SsLRc879UGLZWcryszapgsd9Bm1267QlgPpg+sjh5QR5NNx5FKZnM59Gk6e43BVtklFNoakNxvPJJaGNdSPvrBBmaD3OFXneQElRY8WloZyMcG/HgfQplw8AGenMOnEiRXdenE93Y1eSumCGt1Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3goudBVEvvF3s4STo5N5Z/xrBZx56IGydA+KTIscPzlKfSePA8p5evZ2+q4kzqnWu4TOtXqIz/Bcc8E5AGF3DeKNjzLPtz1iYxMNP1ByCRFxf2z8FKBbdfBBX4t/GFaIdLHHJaj24dv3cIchiBBfyXtEYJ+6Gv1wkZHqi76KMLJCqF6ojUq0uU+KDk2yWI52QgIo1l6jFVC1Dyv9ptVS7IFYQgxFdXjPXdYrnA7a+qmk1mtLZ1BuJJQMH2oXGJ/KzYTEPN23BwrmxqCSRpp+uOI0yxBbIRJ77rCNpXMehWWQ/co6+rxk4SOqONKZQimUXi8v6FEUMJYf3ZTDr3yBw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, Community Manager <community.manager@xxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 18 Apr 2023 15:42:50 +0000
  • Ironport-data: A9a23:2XdY16rdIxtonwaPuFwtCLnRm/1eBmKcZBIvgKrLsJaIsI4StFCzt garIBnVafncZ2v0L4giPovkphgCucDQzoVjHAQ4pCE1ES5G+ZuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKm06WJwUmAWP6gR5weCzilNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXABIcfwGAneWp+rCmEPVNndZ6CMftMrpK7xmMzRmBZRonabbqZvyToPN9gnI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeeraYWJEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdpMT+3kqqA16LGV7lMUDAYSBX6dmsuSkl7gdsgPN B0F9yV7+MDe82TuFLERRSaQsHOC+xIRRddUO+k78x2WjLrZ5R6DAWoJRSIHb8Yp3OcWSDowx xm2ltXmLTV1tfueTnf13ryTqDavPykJPCkHbCkNQgYfy8nuppkpiRDCRcolF7S65vX3Ezztx zGBrAAlmq4ey8UM0s2T/03Dgj+qjojESEgy/Aq/dnm+8gpzaYqhZoqpwVvW9/BNKMCeVFbpl GcAs9iT6qYJF57lqcCWaOAEHbXs6/PbNjTZ2AdrB8N4qGjr/GO/d4dN5j04PF1uLssPZT7uZ gnUpB9V45hQenCtaMebfr6MNijj9oC4ffyNaxweRoAmjkRZHONfwBxTWA==
  • Ironport-hdrordr: A9a23:U8uNe6NgzWT0y8BcTvujsMiBIKoaSvp037BN7SxMoH1uHfBw8v rEoB1173HJYVoqOU3I++rwWpVoMEm9yXcd2+B4V9qftWLdyQiVxe9ZnOzf6gylNyri9vNMkY dMGpIObuEY1GIK6PoSNjPId+od/A==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The addition of the flags field in the vcpu_set_singleshot_timer in
505ef3ea8687 is an ABI breakage, as the size of the structure is
increased.

Remove such field addition and drop the implementation of the
VCPU_SSHOTTMR_future flag.  If a timer provides an expired timeout
value just inject the timer interrupt.

Bump the Xen interface version, and keep the flags field and
VCPU_SSHOTTMR_future available for guests using the old interface.

Note the removal of the field from the vcpu_set_singleshot_timer
struct allows removing the compat translation of the struct.

Fixes: 505ef3ea8687 ('Add flags field to VCPUOP_set_singlsehot_timer.')
Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 CHANGELOG.md                    |  2 ++
 xen/common/compat/domain.c      | 18 +++++-------------
 xen/common/domain.c             | 13 ++++++++++---
 xen/include/public/vcpu.h       | 12 +++++++-----
 xen/include/public/xen-compat.h |  2 +-
 xen/include/xlat.lst            |  2 +-
 6 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5dbf8b06d72c..b0d9bf4edbda 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ The format is based on [Keep a 
Changelog](https://keepachangelog.com/en/1.0.0/)
 ### Changed
  - Repurpose command line gnttab_max_{maptrack_,}frames options so they don't
    cap toolstack provided values.
+ - Remove flags field from vcpu_set_periodic_timer: its introduction was an
+   ABI breakage.
 
 ### Added
  - On x86, support for features new in Intel Sapphire Rapids CPUs:
diff --git a/xen/common/compat/domain.c b/xen/common/compat/domain.c
index c4254905359e..ffc73a9a1dc9 100644
--- a/xen/common/compat/domain.c
+++ b/xen/common/compat/domain.c
@@ -16,6 +16,10 @@ EMIT_FILE;
 CHECK_vcpu_set_periodic_timer;
 #undef xen_vcpu_set_periodic_timer
 
+#define xen_vcpu_set_singleshot_timer vcpu_set_singleshot_timer
+CHECK_vcpu_set_singleshot_timer;
+#undef xen_vcpu_set_singleshot_timer
+
 #define xen_vcpu_info vcpu_info
 CHECK_SIZE_(struct, vcpu_info);
 #undef xen_vcpu_info
@@ -97,6 +101,7 @@ int compat_common_vcpu_op(int cmd, struct vcpu *v,
     case VCPUOP_is_up:
     case VCPUOP_set_periodic_timer:
     case VCPUOP_stop_periodic_timer:
+    case VCPUOP_set_singleshot_timer:
     case VCPUOP_stop_singleshot_timer:
     case VCPUOP_register_vcpu_info:
         rc = common_vcpu_op(cmd, v, arg);
@@ -116,19 +121,6 @@ int compat_common_vcpu_op(int cmd, struct vcpu *v,
         break;
     }
 
-    case VCPUOP_set_singleshot_timer:
-    {
-        struct compat_vcpu_set_singleshot_timer cmp;
-        struct vcpu_set_singleshot_timer *nat;
-
-        if ( copy_from_guest(&cmp, arg, 1) )
-            return -EFAULT;
-        nat = COMPAT_ARG_XLAT_VIRT_BASE;
-        XLAT_vcpu_set_singleshot_timer(nat, &cmp);
-        rc = do_vcpu_op(cmd, vcpuid, guest_handle_from_ptr(nat, void));
-        break;
-    }
-
     default:
         rc = -ENOSYS;
         break;
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 626debbae095..6a440590fe2a 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1762,9 +1762,16 @@ long common_vcpu_op(int cmd, struct vcpu *v, 
XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( copy_from_guest(&set, arg, 1) )
             return -EFAULT;
 
-        if ( (set.flags & VCPU_SSHOTTMR_future) &&
-             (set.timeout_abs_ns < NOW()) )
-            return -ETIME;
+        if ( set.timeout_abs_ns < NOW() )
+        {
+            /*
+             * Simplify the logic if the timeout has already expired and just
+             * inject the event.
+             */
+            stop_timer(&v->singleshot_timer);
+            send_timer_event(v);
+            break;
+        }
 
         migrate_timer(&v->singleshot_timer, smp_processor_id());
         set_timer(&v->singleshot_timer, set.timeout_abs_ns);
diff --git a/xen/include/public/vcpu.h b/xen/include/public/vcpu.h
index 81a3b3a7438c..6d86a661bd67 100644
--- a/xen/include/public/vcpu.h
+++ b/xen/include/public/vcpu.h
@@ -144,15 +144,17 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_set_periodic_timer_t);
 #define VCPUOP_stop_singleshot_timer 9 /* arg == NULL */
 struct vcpu_set_singleshot_timer {
     uint64_t timeout_abs_ns;   /* Absolute system time value in nanoseconds. */
-    uint32_t flags;            /* VCPU_SSHOTTMR_??? */
+#if __XEN_INTERFACE_VERSION__ < 0x00040f00
+    uint32_t flags;            /* Ignored. */
+#endif
 };
 typedef struct vcpu_set_singleshot_timer vcpu_set_singleshot_timer_t;
 DEFINE_XEN_GUEST_HANDLE(vcpu_set_singleshot_timer_t);
 
-/* Flags to VCPUOP_set_singleshot_timer. */
- /* Require the timeout to be in the future (return -ETIME if it's passed). */
-#define _VCPU_SSHOTTMR_future (0)
-#define VCPU_SSHOTTMR_future  (1U << _VCPU_SSHOTTMR_future)
+#if __XEN_INTERFACE_VERSION__ < 0x00040f00
+/* Ignored. */
+#define VCPU_SSHOTTMR_future  1
+#endif
 
 /*
  * Register a memory location in the guest address space for the
diff --git a/xen/include/public/xen-compat.h b/xen/include/public/xen-compat.h
index 97fe6984989a..dc43cc9567c0 100644
--- a/xen/include/public/xen-compat.h
+++ b/xen/include/public/xen-compat.h
@@ -10,7 +10,7 @@
 #ifndef __XEN_PUBLIC_XEN_COMPAT_H__
 #define __XEN_PUBLIC_XEN_COMPAT_H__
 
-#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040e00
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040f00
 
 #if defined(__XEN__) || defined(__XEN_TOOLS__)
 /* Xen is built with matching headers and implements the latest interface. */
diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst
index d601a8a98421..5463961ce26b 100644
--- a/xen/include/xlat.lst
+++ b/xen/include/xlat.lst
@@ -168,7 +168,7 @@
 ?      vcpu_register_vcpu_info         vcpu.h
 !      vcpu_runstate_info              vcpu.h
 ?      vcpu_set_periodic_timer         vcpu.h
-!      vcpu_set_singleshot_timer       vcpu.h
+?      vcpu_set_singleshot_timer       vcpu.h
 ?      build_id                        version.h
 ?      compile_info                    version.h
 ?      feature_info                    version.h
-- 
2.40.0




 


Rackspace

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