From patchwork Tue Jan 3 14:04:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 9494903 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 B618860405 for ; Tue, 3 Jan 2017 14:08:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C510D26E69 for ; Tue, 3 Jan 2017 14:08:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7F7D2711E; Tue, 3 Jan 2017 14:08:31 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY 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 36AA926E69 for ; Tue, 3 Jan 2017 14:08:31 +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 1cOPjZ-0006eA-Uo; Tue, 03 Jan 2017 14:06:37 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOPjY-0006db-Na for xen-devel@lists.xen.org; Tue, 03 Jan 2017 14:06:36 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 3E/60-25337-CEFAB685; Tue, 03 Jan 2017 14:06:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHLMWRWlGSWpSXmKPExsXSO6nOVff1+uw Ig5+LVSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ozfTyYxF/yQr9i8bCJbA+MriS5GLg4hgQlM Eod6O1khnF+MEgd+LGOEcDYwSry89JwZqoxR4smbm+xdjJwcbAJGEmePTmcEsUUEpCWufb4M1 sEssIVR4u6UTSwgCWEBB4kDG9aygtgsAqoSk88fB2vgFfCU6Pz0AywuISAncfNcJzOIzSngJb F2x002EFsIqObvjKcsEDWGEqcfbmOcwMi3gJFhFaNGcWpRWWqRrqGlXlJRZnpGSW5iZo6uoYG ZXm5qcXFiempOYlKxXnJ+7iZGYLgwAMEOxh/LAg4xSnIwKYnyRjNkRwjxJeWnVGYkFmfEF5Xm pBYfYpTh4FCS4GUChp+QYFFqempFWmYOMHBh0hIcPEoivF/WAaV5iwsSc4sz0yFSpxgVpcR5J UH6BEASGaV5cG2waLnEKCslzMsIdIgQT0FqUW5mCar8K0ZxDkYlYd5IkPE8mXklcNNfAS1mAl q8PQBscUkiQkqqgTGiIDM659bKq2HfvvtwmDM36xwU81G3eKrJsUe6sa13XVXr3hi+aBW2OY8 fT48tFfq55sPmPwrXTE/sPhzfWj+tlXHDD4vzsc4rV+lJPGcqmtX5NytSieef0tznv7qWPNT4 kBWrkqh6QSt6vtPXQm3h18cEDMQ9e6J+fuue7qsk9sXDsTWTQYmlOCPRUIu5qDgRALbu/u6RA gAA X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1483452394!42937578!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59386 invoked from network); 3 Jan 2017 14:06:35 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-5.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 Jan 2017 14:06:35 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v03E4FQo004782 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 3 Jan 2017 14:04:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v03E4FVx006600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 3 Jan 2017 14:04:15 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v03E4E9x001234; Tue, 3 Jan 2017 14:04:14 GMT Received: from ostr-laptop.us.oracle.com (/10.152.23.90) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Jan 2017 06:04:14 -0800 From: Boris Ostrovsky To: xen-devel@lists.xen.org Date: Tue, 3 Jan 2017 09:04:11 -0500 Message-Id: <1483452256-2879-8-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483452256-2879-1-git-send-email-boris.ostrovsky@oracle.com> References: <1483452256-2879-1-git-send-email-boris.ostrovsky@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, Boris Ostrovsky , roger.pau@citrix.com Subject: [Xen-devel] [PATCH v6 07/12] pvh: Send an SCI on VCPU hotplug event 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Send and SCI when VCPU map is updated by domctl or when guest sets GPE0 enable bit and status bit is already set. Also update send_guest_global_virq() to handle cases when VCPU0 is offlined. Signed-off-by: Boris Ostrovsky --- Changes in v6: * Change conditions causing the SCI to be generated: - domctl write to VCPU map - Enabling a pending GPE0 event xen/arch/x86/hvm/acpi.c | 20 ++++++++++++++++++++ xen/common/event_channel.c | 7 +++++-- xen/include/xen/domain.h | 1 + xen/include/xen/event.h | 8 ++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/acpi.c b/xen/arch/x86/hvm/acpi.c index 9f0578e..946640e 100644 --- a/xen/arch/x86/hvm/acpi.c +++ b/xen/arch/x86/hvm/acpi.c @@ -4,6 +4,7 @@ */ #include #include +#include #include #include @@ -85,6 +86,17 @@ int hvm_acpi_domctl_access(struct domain *d, return -EFAULT; } + /* + * For simplicity don't verify whether CPU map changed and + * always send an SCI on a write (provided it's enabled). + */ + if ( is_write ) + { + d->arch.hvm_domain.acpi.gpe0_sts |= 1U << XEN_ACPI_GPE0_CPUHP_BIT; + if ( d->arch.hvm_domain.acpi.gpe0_en & (1U << XEN_ACPI_GPE0_CPUHP_BIT) ) + send_guest_global_virq(d, VIRQ_SCI); + } + return 0; } @@ -144,6 +156,7 @@ static int acpi_guest_access(int dir, unsigned int port, else { uint32_t v = *val; + uint16_t en_orig = *en; /* Status register is write-1-to-clear */ switch ( port & 3 ) @@ -170,6 +183,13 @@ static int acpi_guest_access(int dir, unsigned int port, *en = (((v & 0xff) << 8) | (*en & 0xff)) & *mask_en; break; } + + /* + * If an event became enabled and corresponding status bit is set + * then send an SCI to the guest. + */ + if ( (*en & ~en_orig) & *sts ) + send_guest_global_virq(d, VIRQ_SCI); } return X86EMUL_OKAY; diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 638dc5e..1d77373 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -727,7 +727,7 @@ void send_guest_vcpu_virq(struct vcpu *v, uint32_t virq) spin_unlock_irqrestore(&v->virq_lock, flags); } -static void send_guest_global_virq(struct domain *d, uint32_t virq) +void send_guest_global_virq(struct domain *d, uint32_t virq) { unsigned long flags; int port; @@ -739,7 +739,10 @@ static void send_guest_global_virq(struct domain *d, uint32_t virq) if ( unlikely(d == NULL) || unlikely(d->vcpu == NULL) ) return; - v = d->vcpu[0]; + /* Send to first available VCPU */ + for_each_vcpu(d, v) + if ( is_vcpu_online(v) ) + break; if ( unlikely(v == NULL) ) return; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index bce0ea1..b386038 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -52,6 +52,7 @@ void vcpu_destroy(struct vcpu *v); int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset); void unmap_vcpu_info(struct vcpu *v); +int arch_update_avail_vcpus(struct domain *d); int arch_domain_create(struct domain *d, unsigned int domcr_flags, struct xen_arch_domainconfig *config); diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 5008c80..74bd605 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -23,6 +23,14 @@ void send_guest_vcpu_virq(struct vcpu *v, uint32_t virq); /* + * send_guest_global_virq: Notify guest via a global VIRQ. + * @d: domain to which virtual IRQ should be sent. First + * online VCPU will be selected. + * @virq: Virtual IRQ number (VIRQ_*) + */ +void send_guest_global_virq(struct domain *d, uint32_t virq); + +/* * send_global_virq: Notify the domain handling a global VIRQ. * @virq: Virtual IRQ number (VIRQ_*) */