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

Re: [PATCH] x86/xen: Add support for HVMOP_set_evtchn_upcall_vector


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, Jane Malalane <Jane.Malalane@xxxxxxxxxx>, LKML <linux-kernel@xxxxxxxxxxxxxxx>
  • From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Date: Mon, 18 Jul 2022 09:59:15 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.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=Zden/FfAFlA7VwHfl5uNLpSbJmIbDIrWCPOjDyL5dBY=; b=NK96SJc7mTwcGtoP47V+2tnWNxRo6RBio40uG+X56NoyGOql6+dm4+dGZufwWwgctqF4ChAk6f5nbHAlE3YUP8d3m5BE+puUl8DFGHOPAzqTI+6ig8/Y+OWwiTh2b/zj3Wub9zHi58inbQarOjxD0dnMvRcxmiyuzQfYFLhqzG1Fc0Ci/aiE/MnV5SNvsbOJMhmgSwDIF+YgHnTylkNjTIaCdPThZJD6cktVtNpzTFfQqE9Rn2KbGRbLE8DAoLZjcG4BhQNptMIr45lDL/Nj0ZKABFkap61Xaq+MOwvMgzFHBGZYyg9Qk51+Wuw5ZYSFmp+swEza6hNLd49n71DRAA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ns11Sq/7gOMCZMr+TgXaQiIXGYdEi2Cx4h5o4q4P2Vv5plqCguAvre2x0g+pVVmU/1XJtJRWTvon48Oq41Yf+dIoqODzyC72QdA43kynP5scehbHYczKjeWq9yFKjlb7j+Z4EVFp++7onk+KBSVZeymgxRdh0vQ1t2LBdGwRuhVILldNgWgzI+mEZJcZ9FO1zGNSwvXJcSzStyizfp1o72RPg6g9sdXM5ig0nF7yk/Ans/D6SszzqY9XTEm0+gca3W1XAa9ieKFkLIq8h4liCam3U5vCoEuFWsnxegMkD4gUPuoMbHoZdCPROk73ZOjpa90rKQNG6PKCEeDjOrIuow==
  • Cc: Juergen Gross <jgross@xxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, "x86@xxxxxxxxxx" <x86@xxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Maximilian Heyne <mheyne@xxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Colin Ian King <colin.king@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 18 Jul 2022 13:59:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 7/18/22 4:56 AM, Andrew Cooper wrote:
On 15/07/2022 14:10, Boris Ostrovsky wrote:
On 7/15/22 5:50 AM, Andrew Cooper wrote:
On 15/07/2022 09:18, Jane Malalane wrote:
On 14/07/2022 00:27, Boris Ostrovsky wrote:
        xen_hvm_smp_init();
        WARN_ON(xen_cpuhp_setup(xen_cpu_up_prepare_hvm,
xen_cpu_dead_hvm));
diff --git a/arch/x86/xen/suspend_hvm.c b/arch/x86/xen/suspend_hvm.c
index 9d548b0c772f..be66e027ef28 100644
--- a/arch/x86/xen/suspend_hvm.c
+++ b/arch/x86/xen/suspend_hvm.c
@@ -5,6 +5,7 @@
    #include <xen/hvm.h>
    #include <xen/features.h>
    #include <xen/interface/features.h>
+#include <xen/events.h>
    #include "xen-ops.h"
@@ -14,6 +15,23 @@ void xen_hvm_post_suspend(int suspend_cancelled)
            xen_hvm_init_shared_info();
            xen_vcpu_restore();
        }
-    xen_setup_callback_vector();
+    if (xen_ack_upcall) {
+        unsigned int cpu;
+
+        for_each_online_cpu(cpu) {
+            xen_hvm_evtchn_upcall_vector_t op = {
+                    .vector = HYPERVISOR_CALLBACK_VECTOR,
+                    .vcpu = per_cpu(xen_vcpu_id, cpu),
+            };
+
+            BUG_ON(HYPERVISOR_hvm_op(HVMOP_set_evtchn_upcall_vector,
+                         &op));
+            /* Trick toolstack to think we are enlightened. */
+            if (!cpu)
+                BUG_ON(xen_set_callback_via(1));
What are you trying to make the toolstack aware of? That we have *a*
callback (either global or percpu)?
Yes, specifically for the check in libxl__domain_pvcontrol_available.
And others.

This is all a giant bodge, but basically a lot of tooling uses the
non-zero-ness of the CALLBACK_VIA param to determine whether the VM has
Xen-aware drivers loaded or not.

The value 1 is a CALLBACK_VIA value which encodes GSI 1, and the only
reason this doesn't explode everywhere is because the
evtchn_upcall_vector registration takes priority over GSI delivery.

This is decades of tech debt piled on top of tech debt.

Feels like it (setting the callback parameter) is something that the
hypervisor should do --- no need to expose guests to this.
Sensible or not, it is the ABI.

Linux still needs to work (nicely) with older Xen's in the world, and we
can't just retrofit a change in the hypervisor which says "btw, this ABI
we've just changed now has a side effect of modifying a field that you
also logically own".


The hypercall has been around for a while so I understand ABI concerns there 
but XEN_HVM_CPUID_UPCALL_VECTOR was introduced only a month ago. Why not tie 
presence of this bit to no longer having to explicitly set the callback field?


-boris




 


Rackspace

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