Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4488372ybx; Mon, 4 Nov 2019 14:15:33 -0800 (PST) X-Google-Smtp-Source: APXvYqzN/9x/ozXRDhjBU28rmbPX7iposVHvfkpXH2KOyDay3EgnS1uMxWsEgP5M5Q0vQi34LzAQ X-Received: by 2002:a50:bac2:: with SMTP id x60mr14559401ede.114.1572905733213; Mon, 04 Nov 2019 14:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905733; cv=none; d=google.com; s=arc-20160816; b=YK8XFc5zltkVgk4/ji/54MDfo0ANup3dUAWQ2ptlZnPJB9GenYcPW2E2gWfJtdKT5Y r+LQ3DtHlRIWO96pvigzzRMHlFctnd2HwCr6+oRSFa9xyfklKpT84OBBOyYMMxlKsHP3 q4G/vyyPqfi4Mc/mqNqJb75FjL9MXY8VdF/XAhA7PO8qziAbfVYX0AO2LBHkIGCYk9BL bEj0803N6CCfw/1ufnVh9VQYefLjQD4Aa4F5tEdd33J15QotDkEGCs8ZxtWTDxmOC08z RMSAC5AcZ1XhD8/XmAIf3El7jmXVK3Soj0kW9OEIGobDx81xxU6EVi8rzJdVFdfU3NFR ci/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5/PIR7RxXw3WSkrYlylioDXBW0Hf8aLrhH6OuQDeqsA=; b=D5FH2I7l9vjoe26kgfUxZq1ik2XlqRfEr9jsMU2wWZDdMv/sFplvBlPfL9rUrCrPxD V5FEdwuyJzQVzslXj6HOObP0HCxxU162jlqm3eTkDGYFw8IBX33UkrUFE+nYDnqHNULf UfbmGP8HJBfuoGuCz7Qvnxnoizrm1UDOZ5zaTeCWUeFoR9fg0R8qtadGKN+j4rSw253o f/B4Xk9FfTLgdyljUjCGg5XoZ1+2F6KOe7nAbVutrS6OiuQLX5vrSmrDZU+l+AjgF4I0 zXeDJNNnwJ+ZpBaV5gtLuylK+Opp0Ndl7AsAK13q4zPfiik18DuuEIdTD11RedHKM99b dFJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ckM8W2+7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si9155467edd.373.2019.11.04.14.15.09; Mon, 04 Nov 2019 14:15:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ckM8W2+7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390105AbfKDWHY (ORCPT + 99 others); Mon, 4 Nov 2019 17:07:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:39814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389454AbfKDWHV (ORCPT ); Mon, 4 Nov 2019 17:07:21 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 265392084D; Mon, 4 Nov 2019 22:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905240; bh=ILWaVFAbM7pu+olaK2zDZOwCaPUffqfJMirgEEEL1/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ckM8W2+7SteDDjgBu4QH6CYTPEpSxknOcrRZDv3Xe6IXIrkyfjbWwwmLHtUx+IWRc AdtGm9ENiZZyhccS98DjLAGTfVqFj/RrOY+2mGPPBMpkuM0G3QmRyVWooNVt0uwR1h 89Jk8UN8/YSw90r33pDeyjgq1CNRDEJE5P9GgoUU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Halil Pasic , Marc Hartmayer , Robin Murphy , Christoph Hellwig , Cornelia Huck , Christian Borntraeger , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.3 076/163] s390/cio: fix virtio-ccw DMA without PV Date: Mon, 4 Nov 2019 22:44:26 +0100 Message-Id: <20191104212145.658884661@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Halil Pasic [ Upstream commit 05668e1d74b84c53fbe0f28565e4c9502a6b8a67 ] Commit 37db8985b211 ("s390/cio: add basic protected virtualization support") breaks virtio-ccw devices with VIRTIO_F_IOMMU_PLATFORM for non Protected Virtualization (PV) guests. The problem is that the dma_mask of the ccw device, which is used by virtio core, gets changed from 64 to 31 bit, because some of the DMA allocations do require 31 bit addressable memory. For PV the only drawback is that some of the virtio structures must end up in ZONE_DMA because we have the bounce the buffers mapped via DMA API anyway. But for non PV guests we have a problem: because of the 31 bit mask guests bigger than 2G are likely to try bouncing buffers. The swiotlb however is only initialized for PV guests, because we don't want to bounce anything for non PV guests. The first such map kills the guest. Since the DMA API won't allow us to specify for each allocation whether we need memory from ZONE_DMA (31 bit addressable) or any DMA capable memory will do, let us use coherent_dma_mask (which is used for allocations) to force allocating form ZONE_DMA while changing dma_mask to DMA_BIT_MASK(64) so that at least the streaming API will regard the whole memory DMA capable. Signed-off-by: Halil Pasic Reported-by: Marc Hartmayer Suggested-by: Robin Murphy Fixes: 37db8985b211 ("s390/cio: add basic protected virtualization support") Link: https://lore.kernel.org/lkml/20190930153803.7958-1-pasic@linux.ibm.com Reviewed-by: Christoph Hellwig Reviewed-by: Cornelia Huck Signed-off-by: Christian Borntraeger Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- drivers/s390/cio/cio.h | 1 + drivers/s390/cio/css.c | 7 ++++++- drivers/s390/cio/device.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h index ba7d2480613b9..dcdaba689b20c 100644 --- a/drivers/s390/cio/cio.h +++ b/drivers/s390/cio/cio.h @@ -113,6 +113,7 @@ struct subchannel { enum sch_todo todo; struct work_struct todo_work; struct schib_config config; + u64 dma_mask; char *driver_override; /* Driver name to force a match */ } __attribute__ ((aligned(8))); diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 1fbfb0a93f5f1..831850435c23b 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -232,7 +232,12 @@ struct subchannel *css_alloc_subchannel(struct subchannel_id schid, * belong to a subchannel need to fit 31 bit width (e.g. ccw). */ sch->dev.coherent_dma_mask = DMA_BIT_MASK(31); - sch->dev.dma_mask = &sch->dev.coherent_dma_mask; + /* + * But we don't have such restrictions imposed on the stuff that + * is handled by the streaming API. + */ + sch->dma_mask = DMA_BIT_MASK(64); + sch->dev.dma_mask = &sch->dma_mask; return sch; err: diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index c421899be20f2..027ef1dde5a7a 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -710,7 +710,7 @@ static struct ccw_device * io_subchannel_allocate_dev(struct subchannel *sch) if (!cdev->private) goto err_priv; cdev->dev.coherent_dma_mask = sch->dev.coherent_dma_mask; - cdev->dev.dma_mask = &cdev->dev.coherent_dma_mask; + cdev->dev.dma_mask = sch->dev.dma_mask; dma_pool = cio_gp_dma_create(&cdev->dev, 1); if (!dma_pool) goto err_dma_pool; -- 2.20.1