From patchwork Tue Jan 17 04:21:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 9519903 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 23C1460244 for ; Tue, 17 Jan 2017 04:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 151EA2840B for ; Tue, 17 Jan 2017 04:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 076CC2842E; Tue, 17 Jan 2017 04:24:56 +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 E73382840B for ; Tue, 17 Jan 2017 04:24:54 +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 1cTLHs-0004ii-5l; Tue, 17 Jan 2017 04:22:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTLHq-0004ic-Qw for xen-devel@lists.xen.org; Tue, 17 Jan 2017 04:22:23 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 63/2B-31966-EFB9D785; Tue, 17 Jan 2017 04:22:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA1WSfUgTcRjH+91t5yVenNPwaWgvS0OkmUKlGJg VlRlCVISktM46t9mmstvCEkFDaA0Vsz+a81BJITQjURPBIpwvMEURTYqU+iMrna4XtTct7W43 rZ6/vjyf53m+Dw8PiSvm5UqSzTezphzGoCL8Zbo9u9TqperCtBh7d1x8w5d6WRJK7utaxk6h8 3J9TmZu/kW5rqesE8vjz+bPNLuwItR/yIb8SRldgoNj7h1hQxtJRGvg45s6uQgU9A0MFlfeyk RA0AfAzU/6iTqYDoMHNt5PLMLpCgysqx4vCKLjoY+/i4taRkdAb1uVV1N0Kvycee4dBPRWcPX fkUv5QHBVTXnzOA3QPT2NSzUqqOooIkQDoK0IXnUsIBEo6CgY6+0mpKJUmP/wHa3p4vJimdTQ SEBx6Yqve5SA33P35FKVASb5Kj9JXwFPZYlvpQYMnn0tlBqGCFh4WYFJIBTeTwzjEuiSQ62nS PAjhT00sMQfkfJ2ChbLX/sm2QkYayqQjqGET50uJOlQaLHzvv1uE8DPjPgcAGoHi/EKtNPxz0 Ec/xykDmFNKJJjTVdZkzp2b3SmSa/VmY2M3qCOjdkXbWQ5jtGyBiaTi76Ua2xFwi9sEKITDQ2 ecKItJKbaTAXZC9MUmzJzL1/TMZxOY7IYWM6JQklSBZTVIbBAE6tl87P0BuGh1jCQAapgqlXE FJfHGDm9VkIDaIcyhHokAloEOkvOetvaK46iMGUQhYRFFAF5rMmoN//P3SiERKog6ok4JUCfY 16f7haMMcH4xe4C0djM/EXKIpQe2t7W81R7OuOM53A4bK+OmL0/xpOebOf4/qT0Y9RA04Xj/s S2xm8ZltnHEdnNpYnDKfWfuV+JqcnlkS7juYPqWtfyzawaR2/leMvDpKOGCk2iIa6mLLamqee H2y23dRivo+mxkVG+bmr1pDUhIT78ljHYMtGd4tfOOfFVjUrG6ZjYKNzEMX8Ajg4aMYUDAAA= X-Env-Sender: Suravee.Suthikulpanit@amd.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1484626937!80386570!1 X-Originating-IP: [104.47.38.45] 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 14407 invoked from network); 17 Jan 2017 04:22:18 -0000 Received: from mail-bl2nam02on0045.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) (104.47.38.45) by server-4.tower-206.messagelabs.com with AES256-SHA256 encrypted SMTP; 17 Jan 2017 04:22:18 -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=MWWZ+q/ANJ2xLxqOnh2CpXFCPwJjdQgacNH4s+fkSNc=; b=TaCMSLjO54R6qH9EvA7VjKO7C+4zw+flWYLjazrsf9xjOdF/s6lTxzmzaQWBDwO4UyCq8crJ6iCRFW9TCkNT2mbjB0/4vJSTHLiEWEzBO3SPInTVVwf5TtfXth8lbtdmw5AItuU1eokSkCp4jp9AeGLmg2CUaUaAWDemej8JKq4= Received: from localhost.localdomain (114.109.128.54) by DM5PR12MB1449.namprd12.prod.outlook.com (10.172.38.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Tue, 17 Jan 2017 04:22:12 +0000 From: Suravee Suthikulpanit To: Date: Mon, 16 Jan 2017 22:21:44 -0600 Message-ID: <1484626904-11346-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: PS1PR0401CA0056.apcprd04.prod.outlook.com (10.170.176.24) To DM5PR12MB1449.namprd12.prod.outlook.com (10.172.38.138) X-MS-Office365-Filtering-Correlation-Id: f0cd2182-8fde-4353-af17-08d43e906b39 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM5PR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aZwEKTmhti44JLc3ju/3xxUYMDOTIX4C5SmuUrSz4lhtuyU0rmzQFRT13tTOc9SA==; 20:/BBSQfhEj3qwLWKTeIbPZ4BVR9pBXhfLPCX4YHH5tPVUn7afBCRe9mQG/jp6hYRW0pAdSyX3yUaCSxcJ+vHw5Yt0W2BHCpxszgj4w2DqQHX4YMS8a4yJaqqPTS4hLXkxgN+TJBYHIK+L4vXNpnxeyHV/ILfSKdGFy9zAsVOaB7HCIcslpz2RcU7Xao/g8EniJ76HPuwisFa7awuMEO5Ijm67vLRDafNFvIdU2C0dhcv6qHPXFWV4gZzEDotjxjlIBgFAkwqCNMtuUeAGyLypJvGkK8Z+No+rc1gUF41HE9cAbiKCRTKfDj1QdqDou9pCDEDnnRS4m/IqqctsjRE+rhALcRMGGwXDZgVdEw11JrrrrLkZvya4AfSe/98yw86O7AA2CCWb1lJy61O2jwUdhGBU+RIBWiwTkYvAQ4u6mFJ9w+u9cPJ+DlxG36nI7PcKLenFOK8w7vRKWriLghQWon+gUziuGrltHFBRE8H0tJVzF2XXbmb1Rqqdf/g8ywFg 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)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123558021)(20161123564025)(20161123562025)(6072148); SRVR:DM5PR12MB1449; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1449; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1449; 4:uKQUP0F/YQGEvL17R6VONuBYrW8mChTgxZ9jpr6Q4afk4eh24UxHX2wrXDo9Wh/UVS1viTaIJzv6FhK2G/cMFwuipZKHV2wvZyEu39vF3uC98Q7c/z7SGAko4Uvx8IYA0KfAkLjdgdHIKNl+K1tXERIWUk5F8kTVDeceRQ2Uh3kud4LbdLJQCuisZh0dJkOzLtuFglHeqN6ZunSI5j36VJifB15UDpfgEKsix2xBJJrX9vLeNcFqd/hcCnVMdr9xl9rFoWtvlEdw5/IaGpA0zzZaXCrbkK505G6kUNVgUeil+T9uXvdK4hLxpUM3nLYKLVcNWscpi3NCYzim/Xqsugbc22h5rf4G/VDbIfBwQZL8nfRr7qRyss34hVP5WRYDJgulsSsSmWPopoqnj/ezBXC0tl2iHcXvhmNaY3MaJ1WPeAsa73K9HkB2drptx9Pt5MccKxGAsyFsApiPt21vDfLnWwKncXL5dHz83nNuqg8UIRn9m8c77FNT8PYGzoEqkYKoaSqeotuCJIzJiGXx+HX6gNN0aDYt9ZjXBiJqJkI1b+H/A6AuMgPKufVS8I0xSc4/zKl92CMCe3vfBNVn2Uc0IMkNbr/V+RecxEJ9bIGBqoDSMlKdM6x70NEh2W3WoxSdka3n4o4KTnnVx/Gf9uARplxfUekO4lqQ7bCjCyO4V1Jh1kTgKtDfBX8c7g9a5F7QzZDttGtV7K0psjUR2IuDFsln38YLwbDs0SM3L3P0iyy8c0USDnsuq/fqX8YYxotH0kctLP4jGNrccf+BAQ== X-Forefront-PRVS: 01901B3451 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(39410400002)(39850400002)(39840400002)(39860400002)(189002)(199003)(52084003)(5660300001)(92566002)(6666003)(50466002)(6916009)(6506006)(8666007)(33646002)(189998001)(5003940100001)(54906002)(110136003)(6486002)(25786008)(38730400001)(50986999)(2351001)(305945005)(8676002)(81166006)(7736002)(97736004)(101416001)(86362001)(68736007)(42186005)(3846002)(6116002)(106356001)(105586002)(81156014)(36756003)(50226002)(47776003)(4326007)(66066001)(2906002)(48376002)(6512007)(30001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1449; 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-Di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-CrossTenant-OriginalArrivalTime: 17 Jan 2017 04:22:12.4156 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1449 Cc: kevin.tian@intel.com, JBeulich@suse.com, konrad.wilk@oracle.com, Jun Nakajima , andrew.cooper3@citrix.com, Suravee Suthikulpanit , sherry.hurwitz@amd.com, Boris Ostrovsky Subject: [Xen-devel] [PATCH V6] 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 struct hvm_pi_ops, which is declared in struct hvm_domain. Signed-off-by: Suravee Suthikulpanit Cc: Jan Beulich Cc: Andrew Cooper Cc: Konrad Rzeszutek Wilk Cc: Boris Ostrovsky Cc: Jun Nakajima Cc: Kevin Tian --- Change in V6: * Change hvm_domain.pi_ops to be a pointer (per Boris's suggestion). Change in V5: * Fix stray blanks in struct hvm_pi_ops declaration. Changes in V4: * Re-word comments for the struct hvm_pi_ops. * Move the comment for VMX per Kevin's request. xen/arch/x86/hvm/vmx/vmx.c | 82 +++++++++++++++++++++++++++++--------- xen/include/asm-x86/hvm/domain.h | 29 ++++++++++++++ xen/include/asm-x86/hvm/hvm.h | 5 ++- xen/include/asm-x86/hvm/vmx/vmcs.h | 59 --------------------------- 4 files changed, 96 insertions(+), 79 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 7b2c50c..7a86718 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -198,18 +198,65 @@ static void vmx_pi_do_resume(struct vcpu *v) spin_unlock_irqrestore(pi_blocking_list_lock, flags); } +/* + * 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: ... -> 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 -> ... + * - SN = 1 + * + * C: ... -> 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: ... -> vmentry + * - 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 struct hvm_pi_ops vmx_pi_ops = +{ + .switch_from = vmx_pi_switch_from, + .switch_to = vmx_pi_switch_to, + .vcpu_block = vmx_vcpu_block, + .do_resume = vmx_pi_do_resume, +}; + /* This function is called when pcidevs_lock is held */ 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); - - 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; + ASSERT(!d->arch.hvm_domain.pi_ops); + d->arch.hvm_domain.pi_ops = &vmx_pi_ops; } /* This function is called when pcidevs_lock is held */ @@ -218,12 +265,8 @@ 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); - - 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; + ASSERT(d->arch.hvm_domain.pi_ops); + d->arch.hvm_domain.pi_ops = NULL; } static int vmx_domain_initialise(struct domain *d) @@ -901,8 +944,9 @@ 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 && + 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 +960,9 @@ 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 && + v->domain->arch.hvm_domain.pi_ops->switch_to ) + v->domain->arch.hvm_domain.pi_ops->switch_to(v); } @@ -3963,8 +4008,9 @@ 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 && + 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..ef6ffb3 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -72,6 +72,33 @@ 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). + * + * These hooks are defined by the underlying arch-specific code + * as needed. For example: + * - When the domain is enabled with virtual IPI delivery + * - When the domain is enabled with virtual I/O int delivery + * and actually has a physical device assigned . + */ +struct hvm_pi_ops { + /* Hook into ctx_switch_from. */ + void (*switch_from)(struct vcpu *v); + + /* Hook into ctx_switch_to. */ + void (*switch_to)(struct vcpu *v); + + /* + * Hook into arch_vcpu_block(), which is called + * from vcpu_block() and vcpu_do_poll(). + */ + void (*vcpu_block)(struct vcpu *); + + /* Hook into the vmentry path. */ + void (*do_resume)(struct vcpu *v); +}; + struct hvm_domain { /* Guest page range used for non-default ioreq servers */ struct { @@ -148,6 +175,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..0fe9f36 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -638,8 +638,9 @@ 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 && \ + 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 {