From patchwork Tue Mar 7 17:35:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 736309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3vd3j06yldz9s8V; Wed, 8 Mar 2017 04:35:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="RGx0TrUl"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1clJ1V-0004l0-R7; Tue, 07 Mar 2017 17:35:45 +0000 Received: from mail-it0-f42.google.com ([209.85.214.42]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1clJ1M-0004iQ-RD for kernel-team@lists.ubuntu.com; Tue, 07 Mar 2017 17:35:36 +0000 Received: by mail-it0-f42.google.com with SMTP id h10so75475324ith.1 for ; Tue, 07 Mar 2017 09:35:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=rzo7orvqMUj2ozHEUon+YkEAhSR+wsdrzP/9NykcWQk=; b=RGx0TrUlSVOReIplNaYX2SkHSKzVB64OkjZDush5urOKBbredx9en90GJr8+yO3ZQP 9COSEPN+Ul4E+JEqP+Dx7skpJL+MpXQtGlpRWWeTsFK7JrTGv75zvZDcwpDdWgXM9/Q5 eDtLJwQz94DPaT+adIfj/mEmjMeDckvkPQLRTAC87z2NxC7r0yAyliip9ZOjrm7inx4i bBO6A4jxV7bF6VHKLAaOx9nPBOw3J6VtYXmWRNEhZ72+1W0ALYxRUKIYGuXmAnEpSj6a nJcMW6LxIXaX/EVQe1CZQ3BFRyd6tCMDrIMWtUW9vmuVLj+Ei9RNhjJ1OZE3JwpCF8VO bc7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=rzo7orvqMUj2ozHEUon+YkEAhSR+wsdrzP/9NykcWQk=; b=a5L2z9WAfSbfI+Snk+FXcNOU3kDD/Wrd/56LenHzCjUvsjyWsGFTRt6e5RNv6KDI97 ceDwAaGtpLJlS5Rnf0tAm3Ip9g4Aw+tLpk2oNOAnqU0EN0sWI+7+yIcfFp6kH5+I1+ka H2oxOJBSQ7F+TM/optTpO6GQkGN40UHgTtDseUPASZOzIq01I1N7X9M/42XOyCiPgWyK G9Ll2Jp+ekkcc0HJg5SiNOcQSy18DrzD7aU0kgUOVTAgBs9929F5MK5LMWlxY5/9lEj6 noCZOesELsirZnLCpjjEoWe136v9LtBtu8ZXSeDFQWgHOXXGaCOZYvt17yXSOSN7mIaQ +ZNA== X-Gm-Message-State: AMke39mkJhZWG6BkaKL2Xt5Hw3Q5jM0fRUTgjk8ZyjFTRDGAW5zs3s+5JYrbb9jzjcuyNa9t X-Received: by 10.36.181.65 with SMTP id j1mr1953873iti.91.1488908135539; Tue, 07 Mar 2017 09:35:35 -0800 (PST) Received: from localhost.localdomain (host-98-127-250-84.bln-mt.client.bresnan.net. [98.127.250.84]) by smtp.gmail.com with ESMTPSA id e4sm392819ioe.7.2017.03.07.09.35.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Mar 2017 09:35:34 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/4] PCI: hv: Allocate physically contiguous hypercall params buffer Date: Tue, 7 Mar 2017 10:35:26 -0700 Message-Id: <1488908126-2221-5-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488908126-2221-1-git-send-email-tim.gardner@canonical.com> References: <1488908126-2221-1-git-send-email-tim.gardner@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Long Li BugLink: http://bugs.launchpad.net/bugs/1670518 hv_do_hypercall() assumes that we pass a segment from a physically contiguous buffer. A buffer allocated on the stack may not work if CONFIG_VMAP_STACK=y is set. Use kmalloc() to allocate this buffer. Reported-by: Haiyang Zhang Signed-off-by: Long Li Signed-off-by: Bjorn Helgaas Acked-by: K. Y. Srinivasan (cherry picked from commit 0de8ce3ee8e38cc66683438f715c79a2cc69539e) Signed-off-by: Tim Gardner --- drivers/pci/host/pci-hyperv.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 7ff8a48..166e217 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -380,6 +380,8 @@ struct hv_pcibus_device { struct msi_domain_info msi_info; struct msi_controller msi_chip; struct irq_domain *irq_domain; + struct retarget_msi_interrupt retarget_msi_interrupt_params; + spinlock_t retarget_msi_interrupt_lock; }; /* @@ -777,34 +779,40 @@ static void hv_irq_unmask(struct irq_data *data) { struct msi_desc *msi_desc = irq_data_get_msi_desc(data); struct irq_cfg *cfg = irqd_cfg(data); - struct retarget_msi_interrupt params; + struct retarget_msi_interrupt *params; struct hv_pcibus_device *hbus; struct cpumask *dest; struct pci_bus *pbus; struct pci_dev *pdev; int cpu; + unsigned long flags; dest = irq_data_get_affinity_mask(data); pdev = msi_desc_to_pci_dev(msi_desc); pbus = pdev->bus; hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); - memset(¶ms, 0, sizeof(params)); - params.partition_id = HV_PARTITION_ID_SELF; - params.source = 1; /* MSI(-X) */ - params.address = msi_desc->msg.address_lo; - params.data = msi_desc->msg.data; - params.device_id = (hbus->hdev->dev_instance.b[5] << 24) | + spin_lock_irqsave(&hbus->retarget_msi_interrupt_lock, flags); + + params = &hbus->retarget_msi_interrupt_params; + memset(params, 0, sizeof(*params)); + params->partition_id = HV_PARTITION_ID_SELF; + params->source = 1; /* MSI(-X) */ + params->address = msi_desc->msg.address_lo; + params->data = msi_desc->msg.data; + params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | (hbus->hdev->dev_instance.b[4] << 16) | (hbus->hdev->dev_instance.b[7] << 8) | (hbus->hdev->dev_instance.b[6] & 0xf8) | PCI_FUNC(pdev->devfn); - params.vector = cfg->vector; + params->vector = cfg->vector; for_each_cpu_and(cpu, dest, cpu_online_mask) - params.vp_mask |= (1ULL << vmbus_cpu_number_to_vp_number(cpu)); + params->vp_mask |= (1ULL << vmbus_cpu_number_to_vp_number(cpu)); + + hv_do_hypercall(HVCALL_RETARGET_INTERRUPT, params, NULL); - hv_do_hypercall(HVCALL_RETARGET_INTERRUPT, ¶ms, NULL); + spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags); pci_msi_unmask_irq(data); } @@ -2205,6 +2213,7 @@ static int hv_pci_probe(struct hv_device *hdev, INIT_LIST_HEAD(&hbus->resources_for_children); spin_lock_init(&hbus->config_lock); spin_lock_init(&hbus->device_list_lock); + spin_lock_init(&hbus->retarget_msi_interrupt_lock); sema_init(&hbus->enum_sem, 1); init_completion(&hbus->remove_event);