Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3547617ybt; Tue, 23 Jun 2020 05:11:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHAIEzhTKeNjsDHEhfcqsO30ZXCz7aQwCPhem1EqbYv2tjXTU5ZpndpXVQQOEVZhPlLp3e X-Received: by 2002:a50:e0ca:: with SMTP id j10mr22026155edl.313.1592914262726; Tue, 23 Jun 2020 05:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592914262; cv=none; d=google.com; s=arc-20160816; b=bF97EEGPkRTjK3zry1RYuL66gOi6FAkSu5xdIz1p7phK0FeRhMTaPcNw2EMJa8hu/+ UuYs1gTHF30EyVeFWP0g7ISR4Jn94CtPfMkvRR9A8xUkC1NnZUdzZHW8UU1vfBEFTlH2 paNPbM4jiSx4tPjF5ZoWr0iKxAJOS9LZOnLbA2a4AOrtvvPmm7OsoLlU9RzNacPvdHpx 396dfI4w0yt/S5UQD33IaUMPXl3y0KsPx8RzhzkA/lnWsi8fc5y+rQ+a1gZuruoQqzod yW/Bo1ySmLoIfyZNiyAq+ya3PZ5Bt6pT72l2jQfzPVGt50RgGYhJABS4xCHtcvLmMVG6 xZ/g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ViGxFrmAKxAjcAMItQ3yJ5NR+d/lYg2p2N4cNIacjM4=; b=ZF6RYz6Asl8/XuZ2r+3KA+jVowo4Ieh7m6Pmm+2zjdgDSo8uTHh/GUuwLM6JAtvpzn GSXkvYPXRPySvPGtfQojlPAFkP4MQzbJOPuWMg2g9rCZIOh8CRZlV23ITdmq7xuMXWmU oATmAnNRBBpwVDmiXrymaPpVmvgMjcdHk4jVGOKGQ4KJ2TkEH++BBFTGWXt6tiSyqOwI SmfonKNBxv6UD1DaWCC+O3iCJV/I8Is7cBAUhCCshCAiJaPCJpyOGoV+zmpD+8x4Tczt FdVvFOE0LBM/EMkAGX9ESccu+t4OW97VG89WdZsy7uqwO3Vquv03Wgp0EjVLddarW50D PXIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MxHcnnfY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o18si11100610ejr.423.2020.06.23.05.10.38; Tue, 23 Jun 2020 05:11:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MxHcnnfY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732591AbgFWMIa (ORCPT + 99 others); Tue, 23 Jun 2020 08:08:30 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:23818 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732333AbgFWMIa (ORCPT ); Tue, 23 Jun 2020 08:08:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592914109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ViGxFrmAKxAjcAMItQ3yJ5NR+d/lYg2p2N4cNIacjM4=; b=MxHcnnfY4F1ea2reXSD/Eu7X0ORkeDlfmhzLyk7guQfxMmemJ8ZWYex/brR7jj4Ee/ZKo2 5AiN5dugur5zVHBl5H59LfQ6lXAfW/QdCPuvNqZYWjukALxiErnIlFGO3ZIe2wFlHCAZI7 SIfsAk8apK5/nSZZxjy5PE2+PIgz/RA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-469-VDK155b3PuKYRbDgZ7WDrg-1; Tue, 23 Jun 2020 08:08:27 -0400 X-MC-Unique: VDK155b3PuKYRbDgZ7WDrg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 84AAD8035B9; Tue, 23 Jun 2020 12:08:05 +0000 (UTC) Received: from laptop.redhat.com (ovpn-114-197.ams2.redhat.com [10.36.114.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF2895DAA0; Tue, 23 Jun 2020 12:07:59 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, hch@lst.de Cc: m.szyprowski@samsung.com, robin.murphy@arm.com, peterz@infradead.org, akpm@linux-foundation.org, jean-philippe@linaro.org, bbhushan2@marvell.com Subject: [PATCH v2] dma-remap: Align the size in dma_common_*_remap() Date: Tue, 23 Jun 2020 14:07:55 +0200 Message-Id: <20200623120755.27710-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Running a guest with a virtio-iommu protecting virtio devices is broken since commit 515e5b6d90d4 ("dma-mapping: use vmap insted of reimplementing it"). Before the conversion, the size was page aligned in __get_vm_area_node(). Doing so fixes the regression. Fixes: 515e5b6d90d4 ("dma-mapping: use vmap insted of reimplementing it") Signed-off-by: Eric Auger --- v1 -> v2: - fix line over 80 characters --- kernel/dma/remap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c index e739a6eea6e7..78b23f089cf1 100644 --- a/kernel/dma/remap.c +++ b/kernel/dma/remap.c @@ -24,7 +24,8 @@ void *dma_common_pages_remap(struct page **pages, size_t size, { void *vaddr; - vaddr = vmap(pages, size >> PAGE_SHIFT, VM_DMA_COHERENT, prot); + vaddr = vmap(pages, PAGE_ALIGN(size) >> PAGE_SHIFT, + VM_DMA_COHERENT, prot); if (vaddr) find_vm_area(vaddr)->pages = pages; return vaddr; @@ -37,7 +38,7 @@ void *dma_common_pages_remap(struct page **pages, size_t size, void *dma_common_contiguous_remap(struct page *page, size_t size, pgprot_t prot, const void *caller) { - int count = size >> PAGE_SHIFT; + int count = PAGE_ALIGN(size) >> PAGE_SHIFT; struct page **pages; void *vaddr; int i; -- 2.20.1