From patchwork Tue Jan 17 02:35:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 9519819 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 5332C6020B for ; Tue, 17 Jan 2017 02:38:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 401B128342 for ; Tue, 17 Jan 2017 02:38:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34A0E283BB; Tue, 17 Jan 2017 02:38:24 +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 15FAB28342 for ; Tue, 17 Jan 2017 02:38:22 +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 1cTJcy-0006b0-6G; Tue, 17 Jan 2017 02:36:04 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTJcx-0006au-F2 for xen-devel@lists.xen.org; Tue, 17 Jan 2017 02:36:03 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id CC/BF-16730-2138D785; Tue, 17 Jan 2017 02:36:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEKsWRWlGSWpSXmKPExsWSoa+qpSvYXBt hsGuRpMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvGo+Rl7wbzgij2PHBsYlzh2MXJxsAi0MEt8 aL7E3MXIycEoEC/x7v4CVpCEkEATk8SO3avYQRJsAtYSr+bcAbNFBGQlVnfNYQcpYhaYwCTR8 f8tWEJYwELi7dlrLCA2i4CqRPfseWwgNq+Aj0TP5A1gNRICchInj01mhYgLSpyc+QSsnllAQu LgixfMEDVKEjO3NbCBLJAQaGeUmLZ1LViRkICWxOUjB9kginwlembsgrMXHX4M1bCSTeL6mfW MEM4lNonWZ4ehqnIkTvbPhTojW+LtpBYWiKIpTBKLZx5kgnAWskmcW3YIqkpG4tntc8wQid2s Ett7NwJdzgF0SLzErznOEPEZvBKre6ezQjSsYZOYM90aEhpSEu93nGSEsGUkNsyYA7VuIpvEi r4njBANEhLzTzcyT2BUnoUUIrOQQmQBI9MqRo3i1KKy1CJdQyO9pKLM9IyS3MTMHF1DA2O93N Ti4sT01JzEpGK95PzcTYzAtMAABDsYX3U7H2KU5GBSEuW9ml8bIcSXlJ9SmZFYnBFfVJqTWny IUYaDQ0mCN6cRKCdYlJqeWpGWmQNMUDBpCQ4eJRHeFJA0b3FBYm5xZjpE6hSjopQ47xKQhABI IqM0D64NlhQvMcpKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZg3C2QKT2ZeCdz0V0CLmYAWX9epB llckoiQkmpg5Jz1weRI7fQu4bd3W2Ni32+4aL5O+sruQ9NOhxz4YT37z9f+BZzhBm33V3ybF6 /CeWSN8/TuXgvXHq25l5+c22f3unLq1p0+r73ylbY9vfbwrs7cT32Os6P7md5d+M7EtVHLd7F POoOi0e66+75ecjIFS/RqNuhIXrEUsFZpb9iqpNXbIcBer8RSnJFoqMVcVJwIAHCD06iFAwAA X-Env-Sender: Suravee.Suthikulpanit@amd.com X-Msg-Ref: server-5.tower-31.messagelabs.com!1484620559!77645942!1 X-Originating-IP: [104.47.37.42] 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 17107 invoked from network); 17 Jan 2017 02:36:01 -0000 Received: from mail-cys01nam02on0042.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) (104.47.37.42) by server-5.tower-31.messagelabs.com with AES256-SHA256 encrypted SMTP; 17 Jan 2017 02:36:01 -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=6gW+daJMQKDZUk5xaY8fJuXPXZLgABH1lTp2JaozE3s=; b=uvCmTYDi+57DlOIIdvB9XjAacHfcTOe+cCt2YErWxeCAVVp81MZKiDlITs2JiLrk1I1wP74PKBLvA/Uo7UsYjpofqnFgmWTre9m13eGjJxpbCqNLOmdEp4U5Yc5wooBlFD5eGCVXi3YXlpcUat9wwfzMdMiqQcG0BhjZNHo1E1I= Received: from localhost.localdomain (114.109.128.54) by CY4PR12MB1446.namprd12.prod.outlook.com (10.172.71.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 02:35:55 +0000 From: Suravee Suthikulpanit To: Date: Mon, 16 Jan 2017 20:35:06 -0600 Message-ID: <1484620507-2708-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: HK2PR02CA0028.apcprd02.prod.outlook.com (10.163.104.166) To CY4PR12MB1446.namprd12.prod.outlook.com (10.172.71.138) X-MS-Office365-Filtering-Correlation-Id: d1715e73-8a09-4839-d359-08d43e81920a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR12MB1446; X-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HKuLqdovkj69kTTGqF13g==; 20:eBYJURWHPDYfniPxWVa1NaVuofpcZTP2W/EKCMf4XOJby65ehPtCGmD4JS2U20sqwnGkDBo7gctOP2Ah5vx3DxH7EzG3gVRIQ5l1XO7adGK20zB2dst7O86HbTredRvHj+AgVki5t8lk5mpLFTK+O5a7ZVeQfnqVWLxpwvxRgrjF9S8A+MBqHXf5R+XcB7BNzcNGck1LXn877yIPiTwIrVH1L6hoJ5huhhztgMwZh49IUiVc/GHwBJ8BICHzaeHtF9pOOsJlD4HC+gAjPJt0ytr8Av56cfL/jjCr2zE67dAmmV4louWij2l9IHfV16TgdxvaCoG758UZNjEwoiJ+5HJ+oBMPDxWC275zbh58VUtyZa20RLh0TxA22QIIpv+hoYqBfYkNcvYK6H57xTGJnAIq6HQWYRmyxa5VCPyp9EiSqrgMlTLE/QycrC9cwiVmP8JQ8N/1i2GhPGQ/4nLjkfzI9xxD0Hb/HZeAPcNI4kpSCRAeY3UnuFe2Pksg9kxk 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)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:CY4PR12MB1446; BCL:0; PCL:0; RULEID:; SRVR:CY4PR12MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 4:m0L/U5BDTA60FJt/JC355UJo4NGTC0bLZmduz3HrKzSKaYJrQ2Ow6Q2ORfXEpDSf4BkGne4Y7GqVCMy47W8b7tl7vzD4nsLzNFJ3U9jQT8+BgOAotikTmFfdQ3zgAQ+6KU/LAjkV514Z+H0fcn2UyOdzQkUFT0bg+TT2pcUB7T2sNC5APDU4DB++HD/q3/R7DhwDpH0fUFNx5rjs/4BZqtuh1UM0smvYv0oenX8T8CTl64+8gyYga+DC+x5MimLHXfr+cXsADy5L5tjJFUfO6cQBHxlOi3ZFb0/Hh5QltmoGV8p+NWZHg7hEtHJDMfT4IwlnC8s5Icy64/N6k3djsz/3u3r2V5Van1o47Hgw3GxK7XdM8oTp5jduVd2+pLJpE+L1bfat4LEF/sNnnTnH2R9ut0m7c5R2aCy8ZF3RMA1GNhuubt/qqmJv2CiUDRtZTZUWLYsio0E4sQta1yiTyO3bVRJnvDBV+jCMLW3udbewfX75oVMYQ+kxPMa2O6JPzLGLkIgUioZikx5zr+0Yn3lzMDyhnrcYbvElcLjzkT3repW8bZWH66YwxOK1TdrGcr+k09Syq4ZDIj52IHM/S6GnSBCpjTWo+Aboeq62GNOvJEsF/vyyRDlTCUiQ62DJPyr8US//NeGoUI1WtS2TWcpKxOX53mRCxIlHVttJU1+Qc8suPUfA+U8cH5bokEgPIv0NxJffRLAmoLioX77VoCtS54TTaDN0X03cFNeszUo= X-Forefront-PRVS: 01901B3451 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(39860400002)(39410400002)(39850400002)(39840400002)(39450400003)(52084003)(199003)(189002)(6486002)(68736007)(2906002)(8666007)(25786008)(6512007)(4326007)(189998001)(54906002)(38730400001)(50226002)(5660300001)(110136003)(6916009)(30001)(50986999)(8676002)(6116002)(3846002)(6506006)(48376002)(36756003)(6666003)(81156014)(81166006)(50466002)(33646002)(101416001)(2351001)(86362001)(105586002)(92566002)(66066001)(106356001)(7736002)(305945005)(47776003)(5003940100001)(42186005)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1446; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; CY4PR12MB1446; 23:5o4bpWAPCOlfizVYTPrNOBfDAjO2OH4FQ+COri2+A?= =?us-ascii?Q?tcb83xogXNDjsiVM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wluA0=; 24:/TtM2pV8jaPiiKk7yjeoGXy+m03TfFvXMer/tq12EgWFtJ7lZG1gOFE0Z9tbAa7N4ZxGzfWLZFnWxGM73lUnap8mzzjPxNJd730VKdx3Xj8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 7:r1VcE9ngIv4cljOc0+gcuKRTdySfIeqVowvLnwdVP2rSws9KSr9khTM/mmRq+gzawqFfqcZD9Az8arBB9ABZWTbcEsLbaee7wSj7WKbdZIsc1R9L2stavPowGdXaxnH00iDuG+j2ICAQl43jk+6CZwPs7SSsa3XBeSM6LW9W0P+1PxrDvd1k5+ksAur5LKACx6pSPZwqRsSfGQFMEmHdRunimYdiXcqVxlJsN0HQz1p1tfw5+VTIQyLtfwBndOytux5CWdHhH+Sl8Wsd3bERHKupGvCrnxeyLsmFRR6Oepcb/+/AfKzTvlY9XGocjXe9gBFyCnkSNrRz0CyvFAg4IngFCs3pFizLriyVqsh0+1Jl36GTqVusU3RjvMzh92k7fM5ZAkQAnSS7D6L4biNxElNtv2y/54hTtAXb/1sNU9juTEBnFCTr5oZaadrNeuqx5yUoDkLwYt77GanT4H5T1g==; 20:y0H0LQ4TFN0dqoM3XcKK+sSpt3sYFecbAYccU90nvrdk/0Mm/c6vodiqRRn/qx8lscIKFAAX+UrAuZjbuYWZY3KqZ/b55lBPku2VCRmWhb4A1kJAT560eCW+COsIU0Uf3t+H140+lfDTYuOvOZBGOV2c+2MRlwozhn1yHoAYSTvFQNQrrruJ4AeFo8bOEsitM2e7Gs1M6laxcZ24ovzHK+IlNFHc6QlcXZeQn9G9FC9oT9pyxUQgtRYPm1t1UTp+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2017 02:35:55.6392 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1446 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 V5] 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: Jan Beulich Cc: Andrew Cooper Cc: Konrad Rzeszutek Wilk Cc: Boris Ostrovsky Cc: Jun Nakajima Cc: Kevin Tian Acked-by: Jan Beulich Acked-by: Kevin Tian --- 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 | 75 ++++++++++++++++++++++++++++++-------- xen/include/asm-x86/hvm/domain.h | 29 +++++++++++++++ xen/include/asm-x86/hvm/hvm.h | 4 +- xen/include/asm-x86/hvm/vmx/vmcs.h | 59 ------------------------------ 4 files changed, 90 insertions(+), 77 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 7b2c50c..3db4ed9 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -198,18 +198,61 @@ 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). + */ + /* 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); + 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 +261,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 +944,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 +959,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 +4006,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..05ea822 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..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 {