From patchwork Thu Jun 7 08:44:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 926200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 411fH62qV2z9s01 for ; Thu, 7 Jun 2018 18:44:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932616AbeFGIoc (ORCPT ); Thu, 7 Jun 2018 04:44:32 -0400 Received: from 107-173-13-209-host.colocrossing.com ([107.173.13.209]:60795 "EHLO ozlabs.ru" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753423AbeFGIo3 (ORCPT ); Thu, 7 Jun 2018 04:44:29 -0400 Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 764DAAE80026; Thu, 7 Jun 2018 04:43:20 -0400 (EDT) From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Cc: Alexey Kardashevskiy , David Gibson , kvm-ppc@vger.kernel.org, Alex Williamson , Benjamin Herrenschmidt , Ram Pai , kvm@vger.kernel.org, Alistair Popple Subject: [RFC PATCH kernel 1/5] vfio/spapr_tce: Simplify page contained test Date: Thu, 7 Jun 2018 18:44:16 +1000 Message-Id: <20180607084420.29513-2-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180607084420.29513-1-aik@ozlabs.ru> References: <20180607084420.29513-1-aik@ozlabs.ru> Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org The test function takes a page struct pointer which is not used by either of two callers in any other way, make it simple and just pass a physical address there. This should cause no behavioral change now but later we may start supporting host addresses for memory devices which are not backed with page structs. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- drivers/vfio/vfio_iommu_spapr_tce.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index 759a5bd..2c4a048 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -249,8 +249,9 @@ static void tce_iommu_userspace_view_free(struct iommu_table *tbl, decrement_locked_vm(mm, cb >> PAGE_SHIFT); } -static bool tce_page_is_contained(struct page *page, unsigned page_shift) +static bool tce_page_is_contained(unsigned long hpa, unsigned page_shift) { + struct page *page = pfn_to_page(hpa >> PAGE_SHIFT); /* * Check that the TCE table granularity is not bigger than the size of * a page we just found. Otherwise the hardware can get access to @@ -549,7 +550,6 @@ static long tce_iommu_build(struct tce_container *container, enum dma_data_direction direction) { long i, ret = 0; - struct page *page; unsigned long hpa; enum dma_data_direction dirtmp; @@ -560,8 +560,7 @@ static long tce_iommu_build(struct tce_container *container, if (ret) break; - page = pfn_to_page(hpa >> PAGE_SHIFT); - if (!tce_page_is_contained(page, tbl->it_page_shift)) { + if (!tce_page_is_contained(hpa, tbl->it_page_shift)) { ret = -EPERM; break; } @@ -595,7 +594,6 @@ static long tce_iommu_build_v2(struct tce_container *container, enum dma_data_direction direction) { long i, ret = 0; - struct page *page; unsigned long hpa; enum dma_data_direction dirtmp; @@ -615,8 +613,7 @@ static long tce_iommu_build_v2(struct tce_container *container, if (ret) break; - page = pfn_to_page(hpa >> PAGE_SHIFT); - if (!tce_page_is_contained(page, tbl->it_page_shift)) { + if (!tce_page_is_contained(hpa, tbl->it_page_shift)) { ret = -EPERM; break; }