From patchwork Thu Jan 12 04:47:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 9512133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 892C3601E5 for ; Thu, 12 Jan 2017 04:50:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C8E4285D6 for ; Thu, 12 Jan 2017 04:50:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71422285ED; Thu, 12 Jan 2017 04:50:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52674285D6 for ; Thu, 12 Jan 2017 04:50:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cRXJ6-0003fj-50; Thu, 12 Jan 2017 04:48:12 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cRXJ4-0003fY-QT for xen-devel@lists.xen.org; Thu, 12 Jan 2017 04:48:11 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 91/52-14064-A8A07785; Thu, 12 Jan 2017 04:48:10 +0000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: server-16.tower-206.messagelabs.com!1484196487!63615827!1 X-Originating-IP: [104.47.40.82] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37655 invoked from network); 12 Jan 2017 04:48:08 -0000 Received: from mail-co1nam03on0082.outbound.protection.outlook.com (HELO NAM03-CO1-obe.outbound.protection.outlook.com) (104.47.40.82) by server-16.tower-206.messagelabs.com with AES256-SHA256 encrypted SMTP; 12 Jan 2017 04:48:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kZw7Onr/zsKrlt030FqFpFLt8rfxDECBFqF/h59FhsQ=; b=bq3DSbsklCPQ8BGS8RAGFhAVXiLHVFUu3k5M+Eg8C364FZjri7dTLyxKKOvS+HumXd7jO22jys3br6FfzS30RmUt1UAlM6h2sKEu8wIsfqt8II0XpWxNDPeTofACw6gRhTqyf++RK+kOJPWPTDa81P0wLN/w1Ryk09wJtXpYPlI= Received: from localhost.localdomain (114.109.128.54) by BN6PR12MB1444.namprd12.prod.outlook.com (10.172.24.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.829.7; Thu, 12 Jan 2017 04:48:01 +0000 From: Suravee Suthikulpanit To: Date: Wed, 11 Jan 2017 22:47:08 -0600 Message-ID: <1484196428-8899-1-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [114.109.128.54] X-ClientProxiedBy: SG2PR01CA0063.apcprd01.prod.exchangelabs.com (10.165.10.31) To BN6PR12MB1444.namprd12.prod.outlook.com (10.172.24.21) X-MS-Office365-Filtering-Correlation-Id: 0d65a90d-9d38-40f6-c6fb-08d43aa632a4 X-Microsoft-Antispam: UriScan:; BCL:0; PC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aVTOq80EmtUzY22MlQPt54qN3dC+48vfa02HUGfxH/aZIy6RdqB/IfyGVGhr9sRnQh3g==; 20:PQpF8Dnwzfv8ttX+8mzqxb3z+l+pwXa+P9GON8/sdImO2e4SsIPPA4VNeZnwRzwz385wVRafb6hUgZvZ+GQeU7iujpAhMYOl5bEK251tYSyHV7ohxmiBTGNMuH2In0CgoztF5wuBHwWd8NzBkFG+5n6u6OfZs0HZS4UOCTWifm2fbKnnTp9/t80gE6iUoGWiNx4+QNNbant08mZ5xrGGIgRXs3zUrWSPc4D9aIV1ecfyhKQgu7ezRGargCe0MxLE2oCzq2vdms9d+xo2Z+bGCpq7frmt8gdyzg1jvcKZEji0meFegji8KlV8y/ohg4ECKTumMHknAyqnyeJqlAqVBQMuWFThjnJ8TiZYQUZ7+qO8CaDq9uxt37Uom+cfKVhU2KTPXmeyZGNqjaHszZfaU2cSXyKVN9sIEO00yZ4xpGNrT2QmngcfUyrS7a/MA1LVb+LupRKn/q/kDHWaa50rhtl068kyTdXqcXuVZVH27TEwmX6Jf0a2BYcucx7S935u X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(70601490899591)(146099531331640)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(6072148); SRVR:BN6PR12MB1444; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1444; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1444; 4:KcJYEtrgrl1UkgZs0hPDapGmKNX3xqYhBAlFUvxN92upALZrrd3RpyiElOodlvV2ZTqD3uNSisP0wASkP8cRzklC3zIhm40BMgeqJCVqqC6hcC2gBRfW0nSz1wmCCHjhW6CzMaaWSfVGWHQ6eCJeksalJknEiLoaHhU7OJCOQG9/pQptGxJ7QWuOYdQHOpdRoEBHilku5FVtkdhYhWLT87/fnMcnTQ6yu31yPU8PdFuzXxuBgAyR+O+QoM+ppUR+GdSPa8cx/6N96u9f1c6uQo4FK+MET2hQtk41JEsFoCR4AloQdGqUwdrBOB9hXtxBL6Jv8HcE9XhTyjdpuqIRUNbGXyQlmRu/W+wxP3Qy/7onTNPdQZEajL/UIgedQiJV1fPjAzuKt4S6/V/rY3opZO6RbM2JMUNrTFeTrDrgKx4J7eZM23dM5815eKE10j3OGAO8hnH47OGhDlj/ZLxoM7C1S+cqcqT/bt0unhLR9f5nYen9R6jiZWVL4hy/bZ3jfCgQCPjOVmk6B7GXJMFTPn4e+chR3TsSmHaC+qy/Rbsi3ezneDYUX6ZOfaLcuXpCWAZeABdyovsP+hJ2DlYpPITnsYF2xaXp9dqsRt9q7Ma74F9J51dYMLENTLgIF7vFJ3/GQH38ujnX0BLr/Wt23O+MMfgnYon1fVdE+1GE8urR3w2X3ySNxH7g1Uhm4wLa4AeZVaSJF1N39E/cvZFDpHaHRXyj7Ocrjlj+XkntCTI= X-Forefront-PRVS: 018577E36E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39840400002)(39860400002)(39450400003)(39410400002)(39850400002)(189002)(199003)(2906002)(50466002)(4326007)(42186005)(101416001)(81156014)(50986999)(6512007)(48376002)(81166006)(6506006)(50226002)(86362001)(305945005)(8666007)(25786008)(54906002)(8676002)(68736007)(110136003)(6916009)(189998001)(33646002)(47776003)(66066001)(7736002)(6486002)(97736004)(36756003)(2351001)(38730400001)(106356001)(5003940100001)(6116002)(3846002)(105586002)(92566002)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1444; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1444; 23:6j3bzmsCmnR8qoPc7J0pjXlBpDlshsYkmHeJ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Mx90vwgUxpnd3HMfddD/JRt5WteevcoC4yr59niCXCkGfgT14umvp73oT5JNZiN87K/XrloZVOuLsjFuSXKtINQI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1444; 7:B6yFSLlHfGxs4Camj9V4b9EJUUPeCaH3LO4wB/kBefKZnIjHrbj2xU8ud2UDS3GETSG9Pz3ek9GEtaC8iAPj7uLw0X4+nu9Yu2BqFxbGeFC7Sq/Ns+9KUi5PIO90jpA2ZQvfKez77EyXJHIlFq4ybXL6fl1QHzh+tnaUcLhJ7NFOHN6Rs24s5Fe15KLrx3NPPV90TAttkKFj3VtT5Xa9rfc8Igc3KxU2F0NvwarOddW3Q/vgesXdeZMkvWFaBhc5gUTt7dALwr5rl6ZPBpyJJK/FfC0ooLXZ/3qc8G0ZMKAEi4u4tYbDTtPAFcogDZ6x+eWwnHlChyWMhi9SvqMWHwzVtdfdH9Op8sAZrn9hrSVmuTjAUDTLLp4oziIWgUfx8hvaToNXSaenEGkYddEimNF4EC/Z4rEPD1wuDRKxLFjMGdTekKkSOGIW4xSlmWHA0dgc8qZbhs0bTnlKWan/kw==; 20:M5CCEDBLu8Nv8XbzW4IjzN6ZqoGXyQR+4ayWFDphOceV3eOB2CAIwqB2DdNAB1zPwmyxoZ0QICZYYGAHhPnqSm4h4qhyy8KONjulkWSZzN++KKfVJN9jF7PhqXp9uTa3EQo0jj5E3hFz0N1WmxGi0/wFHNAj0Cg9Mr2bOs7ElvUIo9dN+a3tL7PSZrppgoN23c8SV5qwFAg0P4/anbZiuoF9ynyZf8lhAc6JkmzLcr9LmpkNiuMUDgYtUbfOOGXX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2017 04:48:01.9855 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1444 Cc: kevin.tian@intel.com, jbeulich@suse.com, Jun Nakajima , andrew.cooper3@citrix.com, Suravee Suthikulpanit , sherry.hurwitz@amd.com Subject: [Xen-devel] [PATCH V3] x86/HVM: Introduce struct hvm_pi_ops X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current function pointers in struct vmx_domain for managing hvm posted interrupt can be used also by SVM AVIC. Therefore, this patch introduces the struct hvm_pi_ops in the struct hvm_domain to hold them. Signed-off-by: Suravee Suthikulpanit Cc: Andrew Cooper Cc: Konrad Rzeszutek Wilk Cc: Jan Beulich Cc: Kevin Tian Cc: Jun Nakajima --- Changes from V2: * Remove "pi_" prefix from the function pointers. * Reword and move VMX-specific description. NOTE: I have separated this patch out from the AMD AVIC patch series since this mainly affects HVM and VMX code. xen/arch/x86/hvm/vmx/vmx.c | 73 +++++++++++++++++++++++++++++--------- xen/include/asm-x86/hvm/domain.h | 34 ++++++++++++++++++ xen/include/asm-x86/hvm/hvm.h | 4 +-- xen/include/asm-x86/hvm/vmx/vmcs.h | 59 ------------------------------ 4 files changed, 93 insertions(+), 77 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 7b2c50c..0854e17 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -103,6 +103,47 @@ void vmx_pi_per_cpu_init(unsigned int cpu) spin_lock_init(&per_cpu(vmx_pi_blocking, cpu).lock); } +/* + * To handle posted interrupts correctly, we need to set the following + * state: + * + * * The PI notification vector (NV) + * * The PI notification destination processor (NDST) + * * The PI "suppress notification" bit (SN) + * * The vcpu pi "blocked" list + * + * VMX implements the runstate transitions as the following: + * + * A: runnable -> running + * - SN = 0 + * - NDST = v->processor + * If a VM is currently running, we want the PI delivered to the guest vcpu + * on the proper pcpu. + * + * B: running -> runnable + * - SN = 1 + * + * C: running -> blocked + * - SN = 0 + * - NV = pi_wakeup_vector + * - Add vcpu to blocked list + * If the vm is blocked, we want the PI delivered to Xen so that it can + * wake it up. + * + * D: blocked -> runnable + * - SN = 0 + * - NV = posted_intr_vector + * - Take vcpu off blocked list + * If the VM is currently either preempted or offline (i.e., not running + * because of some reason other than blocking waiting for an interrupt), + * there's nothing Xen can do -- we want the interrupt pending bit set in + * the guest, but we don't want to bother Xen with an interrupt (SN clear). + * + * There's a brief window of time between vmx_intr_assist() and checking + * softirqs where if an interrupt comes in it may be lost; so we need Xen + * to get an interrupt and raise a softirq so that it will go through the + * vmx_intr_assist() path again (SN clear, NV = posted_interrupt). + */ static void vmx_vcpu_block(struct vcpu *v) { unsigned long flags; @@ -204,12 +245,12 @@ void vmx_pi_hooks_assign(struct domain *d) if ( !iommu_intpost || !has_hvm_container_domain(d) ) return; - ASSERT(!d->arch.hvm_domain.vmx.vcpu_block); + ASSERT(!d->arch.hvm_domain.pi_ops.vcpu_block); - d->arch.hvm_domain.vmx.vcpu_block = vmx_vcpu_block; - d->arch.hvm_domain.vmx.pi_switch_from = vmx_pi_switch_from; - d->arch.hvm_domain.vmx.pi_switch_to = vmx_pi_switch_to; - d->arch.hvm_domain.vmx.pi_do_resume = vmx_pi_do_resume; + d->arch.hvm_domain.pi_ops.vcpu_block = vmx_vcpu_block; + d->arch.hvm_domain.pi_ops.switch_from = vmx_pi_switch_from; + d->arch.hvm_domain.pi_ops.switch_to = vmx_pi_switch_to; + d->arch.hvm_domain.pi_ops.do_resume = vmx_pi_do_resume; } /* This function is called when pcidevs_lock is held */ @@ -218,12 +259,12 @@ void vmx_pi_hooks_deassign(struct domain *d) if ( !iommu_intpost || !has_hvm_container_domain(d) ) return; - ASSERT(d->arch.hvm_domain.vmx.vcpu_block); + ASSERT(d->arch.hvm_domain.pi_ops.vcpu_block); - d->arch.hvm_domain.vmx.vcpu_block = NULL; - d->arch.hvm_domain.vmx.pi_switch_from = NULL; - d->arch.hvm_domain.vmx.pi_switch_to = NULL; - d->arch.hvm_domain.vmx.pi_do_resume = NULL; + d->arch.hvm_domain.pi_ops.vcpu_block = NULL; + d->arch.hvm_domain.pi_ops.switch_from = NULL; + d->arch.hvm_domain.pi_ops.switch_to = NULL; + d->arch.hvm_domain.pi_ops.do_resume = NULL; } static int vmx_domain_initialise(struct domain *d) @@ -901,8 +942,8 @@ static void vmx_ctxt_switch_from(struct vcpu *v) vmx_restore_host_msrs(); vmx_save_dr(v); - if ( v->domain->arch.hvm_domain.vmx.pi_switch_from ) - v->domain->arch.hvm_domain.vmx.pi_switch_from(v); + if ( v->domain->arch.hvm_domain.pi_ops.switch_from ) + v->domain->arch.hvm_domain.pi_ops.switch_from(v); } static void vmx_ctxt_switch_to(struct vcpu *v) @@ -916,8 +957,8 @@ static void vmx_ctxt_switch_to(struct vcpu *v) vmx_restore_guest_msrs(v); vmx_restore_dr(v); - if ( v->domain->arch.hvm_domain.vmx.pi_switch_to ) - v->domain->arch.hvm_domain.vmx.pi_switch_to(v); + if ( v->domain->arch.hvm_domain.pi_ops.switch_to ) + v->domain->arch.hvm_domain.pi_ops.switch_to(v); } @@ -3963,8 +4004,8 @@ void vmx_vmenter_helper(const struct cpu_user_regs *regs) struct hvm_vcpu_asid *p_asid; bool_t need_flush; - if ( curr->domain->arch.hvm_domain.vmx.pi_do_resume ) - curr->domain->arch.hvm_domain.vmx.pi_do_resume(curr); + if ( curr->domain->arch.hvm_domain.pi_ops.do_resume ) + curr->domain->arch.hvm_domain.pi_ops.do_resume(curr); if ( !cpu_has_vmx_vpid ) goto out; diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h index f34d784..f7674cd 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -72,6 +72,38 @@ struct hvm_ioreq_server { bool_t bufioreq_atomic; }; +/* + * This structure defines function hooks to support hardware-assisted + * virtual interrupt delivery to guest. (e.g. VMX PI and SVM AVIC). + * + * The way we implement this now is by looking at what needs to happen on + * the following runstate transitions: + * + * A: runnable -> running : switch_to + * B: running -> runnable : switch_from + * C: running -> blocked : vcpu_block + * D: blocked -> runnable : do_resume + * + * For transitions A and B, we add hooks into ctx_switch_{to,from} paths. + * + * For transition C, we add a new arch hook, arch_vcpu_block(), which is + * called from vcpu_block() and vcpu_do_poll(). + * + * For transition D, rather than add an extra arch hook on vcpu_wake, we + * add a hook on the vmentry path which checks to see if either of the two + * actions need to be taken. + * + * These hooks only need to be called when the domain in question actually + * has a physical device assigned to it, so we set and clear the callbacks + * as appropriate when device assignment changes. + */ +struct hvm_pi_ops { + void (*vcpu_block) (struct vcpu *); + void (*switch_from) (struct vcpu *v); + void (*switch_to) (struct vcpu *v); + void (*do_resume) (struct vcpu *v); +}; + struct hvm_domain { /* Guest page range used for non-default ioreq servers */ struct { @@ -148,6 +180,8 @@ struct hvm_domain { struct list_head list; } write_map; + struct hvm_pi_ops pi_ops; + union { struct vmx_domain vmx; struct svm_domain svm; diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 7e7462e..b1e4c75 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -638,8 +638,8 @@ unsigned long hvm_cr4_guest_reserved_bits(const struct vcpu *v, bool_t restore); struct vcpu *v_ = (v); \ struct domain *d_ = v_->domain; \ if ( has_hvm_container_domain(d_) && \ - (cpu_has_vmx && d_->arch.hvm_domain.vmx.vcpu_block) ) \ - d_->arch.hvm_domain.vmx.vcpu_block(v_); \ + (d_->arch.hvm_domain.pi_ops.vcpu_block) ) \ + d_->arch.hvm_domain.pi_ops.vcpu_block(v_); \ }) #endif /* __ASM_X86_HVM_HVM_H__ */ diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm/vmx/vmcs.h index 997f4f5..4ec8b08 100644 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h @@ -77,65 +77,6 @@ struct vmx_domain { unsigned long apic_access_mfn; /* VMX_DOMAIN_* */ unsigned int status; - - /* - * To handle posted interrupts correctly, we need to set the following - * state: - * - * * The PI notification vector (NV) - * * The PI notification destination processor (NDST) - * * The PI "suppress notification" bit (SN) - * * The vcpu pi "blocked" list - * - * If a VM is currently running, we want the PI delivered to the guest vcpu - * on the proper pcpu (NDST = v->processor, SN clear). - * - * If the vm is blocked, we want the PI delivered to Xen so that it can - * wake it up (SN clear, NV = pi_wakeup_vector, vcpu on block list). - * - * If the VM is currently either preempted or offline (i.e., not running - * because of some reason other than blocking waiting for an interrupt), - * there's nothing Xen can do -- we want the interrupt pending bit set in - * the guest, but we don't want to bother Xen with an interrupt (SN clear). - * - * There's a brief window of time between vmx_intr_assist() and checking - * softirqs where if an interrupt comes in it may be lost; so we need Xen - * to get an interrupt and raise a softirq so that it will go through the - * vmx_intr_assist() path again (SN clear, NV = posted_interrupt). - * - * The way we implement this now is by looking at what needs to happen on - * the following runstate transitions: - * - * A: runnable -> running - * - SN = 0 - * - NDST = v->processor - * B: running -> runnable - * - SN = 1 - * C: running -> blocked - * - NV = pi_wakeup_vector - * - Add vcpu to blocked list - * D: blocked -> runnable - * - NV = posted_intr_vector - * - Take vcpu off blocked list - * - * For transitions A and B, we add hooks into vmx_ctxt_switch_{from,to} - * paths. - * - * For transition C, we add a new arch hook, arch_vcpu_block(), which is - * called from vcpu_block() and vcpu_do_poll(). - * - * For transition D, rather than add an extra arch hook on vcpu_wake, we - * add a hook on the vmentry path which checks to see if either of the two - * actions need to be taken. - * - * These hooks only need to be called when the domain in question actually - * has a physical device assigned to it, so we set and clear the callbacks - * as appropriate when device assignment changes. - */ - void (*vcpu_block) (struct vcpu *); - void (*pi_switch_from) (struct vcpu *v); - void (*pi_switch_to) (struct vcpu *v); - void (*pi_do_resume) (struct vcpu *v); }; struct pi_desc {