From patchwork Wed Jul 11 11:00:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 942429 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 41Qbhg4vcMzB4MQ for ; Wed, 11 Jul 2018 21:00:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732517AbeGKLEg (ORCPT ); Wed, 11 Jul 2018 07:04:36 -0400 Received: from 107-173-13-209-host.colocrossing.com ([107.173.13.209]:50286 "EHLO ozlabs.ru" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1732502AbeGKLEg (ORCPT ); Wed, 11 Jul 2018 07:04:36 -0400 Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id B97C3AE80018; Wed, 11 Jul 2018 06:59:31 -0400 (EDT) From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Cc: Alexey Kardashevskiy , David Gibson , kvm-ppc@vger.kernel.org, "Aneesh Kumar K.V" , Alex Williamson , Michael Ellerman , Nicholas Piggin , Paul Mackerras , Balbir Singh Subject: [PATCH kernel v6 0/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page Date: Wed, 11 Jul 2018 21:00:42 +1000 Message-Id: <20180711110044.15939-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org This is to improve page boundaries checking and should probably be cc:stable. I came accross this while debugging nvlink2 passthrough but the lack of checking might be exploited by the existing userspace. The get_user_pages() comment says it should be "phased out" but the only alternative seems to be get_user_pages_longterm(), should that be used instead (this is longterm reference elevation, however it is not DAX, whatever this implies)? get_user_pages_remote() seems unnecessarily complicated because of @locked. Changes: v6: * 2/2: read pageshift from pte v5: * 2/2: changed compound pages handling v4: * 2/2: implemented less strict but still safe max pageshift as David suggested v3: * enforced huge pages not to cross preregistered chunk boundaries v2: * 2/2: explicitly check for compound pages before calling compound_order() This is based on sha1 1e4b044 Linus Torvalds "Linux 4.18-rc4". Please comment. Thanks. Alexey Kardashevskiy (2): vfio/spapr: Use IOMMU pageshift rather than pagesize KVM: PPC: Check if IOMMU page is contained in the pinned physical page arch/powerpc/include/asm/mmu_context.h | 4 ++-- arch/powerpc/kvm/book3s_64_vio.c | 2 +- arch/powerpc/kvm/book3s_64_vio_hv.c | 6 ++++-- arch/powerpc/mm/mmu_context_iommu.c | 39 ++++++++++++++++++++++++++++++++-- drivers/vfio/vfio_iommu_spapr_tce.c | 10 ++++----- 5 files changed, 49 insertions(+), 12 deletions(-)