From patchwork Tue Mar 7 17:30:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 736306 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 3vd3bv3Tj5z9s8V; Wed, 8 Mar 2017 04:31:23 +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="a8w9889D"; 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 1clIxE-0004OC-7f; Tue, 07 Mar 2017 17:31:20 +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 1clIx8-0004MG-ET for kernel-team@lists.ubuntu.com; Tue, 07 Mar 2017 17:31:14 +0000 Received: by mail-it0-f42.google.com with SMTP id m27so18560570iti.0 for ; Tue, 07 Mar 2017 09:31:14 -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=0Cj2W4nnrw0q4DKDSrOwwsZxf2MYFw+hm4OOmTSpXxs=; b=a8w9889D5AqDM0SPm6b1+Pc+sCv4kerkatdZVgn0o2s/tFSrCokQ6lFj90FsETbrag naBjDtG0brGzi+AjmhcBV0BIGICbEm5BU5E9u21zhZz6DZeIMeKZyS2g3d3CYd9l/qsC jOax9je1GCALjzCoWzlOWT66pBgE5rATENR08Xz50T2aETFdMUY2rhWxPKUZA9xjGJz1 9vXiI6YmcpqOp2i2P32eoITUHBGFH8mx5Ph7tvmxrbtZf8U+s1Os/4y5mZHxBx9RizDx nTpPTgjUA0eQSh7sK9/mbmQ53W+T7V/hEN+ZiNUTylXUuuuPIG5ZLcP4EnpcBp2A9hhJ unsA== 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=0Cj2W4nnrw0q4DKDSrOwwsZxf2MYFw+hm4OOmTSpXxs=; b=d07sUwufe/NP1aEXBbfu0hkDNH0E4vjs+fZlk1Xj63budjUB8oVmNRj0SN6XPnwkJp s75jDMWJo637paeKr8DWTD32wx003YDVMYnPAGnVy96sKImkpyMT6CAuNLEhBeexRIup DIgsONgGhmShkynH818yHusxM1gfgS6tlnBp0zsm6wQTtcQabAtugiDs2Jl0cdsGOH0N HwOArotPmnLU1eJbqujLjx1nuCV8iJywitMSuoKFmI9ecwl3ZOai61Nbo25W0+YHmZ7f zLdHsdIuQlEKVXUBbqy6UR5+fXrPivQot2EJNTx+Cj43UoOAnaHjWnZ57OWXi0J2912S th6g== X-Gm-Message-State: AMke39lvQjn24Sp6cFEIDt2D1QhrdyqbqbjQy1lsQfPA+jNWkjBxPk3QLvqh8y+wnKFAkeVr X-Received: by 10.36.77.140 with SMTP id l134mr22220404itb.33.1488907873083; Tue, 07 Mar 2017 09:31:13 -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 a21sm6521285itc.28.2017.03.07.09.31.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Mar 2017 09:31:12 -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:30:48 -0700 Message-Id: <1488907848-1872-5-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488907848-1872-1-git-send-email-tim.gardner@canonical.com> References: <1488907848-1872-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 94fd791..a48045d 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -378,6 +378,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; }; /* @@ -774,34 +776,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); } @@ -2186,6 +2194,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);