Received: by 10.223.176.5 with SMTP id f5csp2671500wra; Thu, 1 Feb 2018 04:19:47 -0800 (PST) X-Google-Smtp-Source: AH8x225O0QubycAOz6nHQzMOCxJhU5bQiaUPhWM6LArHF5eVAKPVsG9eIGQtmFJa52C0VMtE/+cr X-Received: by 10.99.126.71 with SMTP id o7mr10001069pgn.450.1517487587672; Thu, 01 Feb 2018 04:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517487587; cv=none; d=google.com; s=arc-20160816; b=hZHgBjeEhCku29HsCPZEDRAkUvexXqJN+Jb6eVxalnmrjywotaGG9eJFNZeTKabXCB IK4b17Mtm/DE5gzA7538NixKnd8PkLP+5vsLg13wyJRb4LzTbsNtveOtqYfP/beyZ3ex RPWinMeVUJubsMRyM4yhUGEw3/ZJQc/N74xaF6BgIAKfbbPwAKXSyp6zN/1rnfjpGmB5 UTC6ebhmvBD08Ovjtx63Xxo485QB8UZemafvcbqNQ5YnHNUHc3PjFDmxkhQLaK/n25C1 jhR+xwXXKga4BnaZCXSYmfM9ty4CCz+O6TT670BnOdSwOi7hJ7EDxsFBGWRby/WpgP3O liWw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Pcuhx8P7BZaAXTxtJjQBCVhFRQZfBUsqmMN1cQdsCxo=; b=Gk5wb6n5WVZAkWk2vu66nC+OrHAJiarwWEf5Hzhhhui9A/u0uDEOfhfU5IuHfnto03 M3rC63BD3OP12HHzP1bswEd8QCI5JQ6WuiZ90T+PSHtQOEbxtxEPoyoqUiMCWtcRjqVy x7ZIWGRXB0URwRIlK01E/hhAAx3uBs8h7JDTB0e35BoQhW/OitlJQU4dyCInkE51kfne ZCmR/YJicueLAxxakeDe+h1VX4BvjYbvaNFeheiJnTnEEQr3i/a0P6Kq+FD4xA0I2TcO hN3MbulDSd03F1I3dzIHtsZjHtK88eAR6kMZfs78ood2+7JbGozSObIXMjwGIo1aLFdW uGgw== ARC-Authentication-Results: i=1; mx.google.com; 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 a25si1369646pfl.324.2018.02.01.04.19.33; Thu, 01 Feb 2018 04:19:47 -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; 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 S1752489AbeBAMR3 (ORCPT + 99 others); Thu, 1 Feb 2018 07:17:29 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49286 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752450AbeBAMRZ (ORCPT ); Thu, 1 Feb 2018 07:17:25 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CC72980D; Thu, 1 Feb 2018 04:17:24 -0800 (PST) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D12953F25C; Thu, 1 Feb 2018 04:17:23 -0800 (PST) Subject: Re: [PATCH 1/2] iommu: Fix iommu_unmap and iommu_unmap_fast return type To: Suravee Suthikulpanit , iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jroedel@suse.de References: <1517363285-89304-1-git-send-email-suravee.suthikulpanit@amd.com> <1517363285-89304-2-git-send-email-suravee.suthikulpanit@amd.com> From: Robin Murphy Message-ID: <19766001-07c9-7b67-ae10-8b5467fff748@arm.com> Date: Thu, 1 Feb 2018 12:17:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/02/18 05:03, Suravee Suthikulpanit wrote: > Hi Robin, > > On 2/1/18 1:02 AM, Robin Murphy wrote: >> Hi Suravee, >> >> On 31/01/18 01:48, Suravee Suthikulpanit wrote: >>> Currently, iommu_unmap and iommu_unmap_fast return unmapped >>> pages with size_t.  However, the actual value returned could >>> be error codes (< 0), which can be misinterpreted as large >>> number of unmapped pages. Therefore, change the return type to ssize_t. >>> >>> Cc: Joerg Roedel >>> Cc: Alex Williamson >>> Signed-off-by: Suravee Suthikulpanit >>> --- >>>   drivers/iommu/amd_iommu.c   |  6 +++--- >>>   drivers/iommu/intel-iommu.c |  4 ++-- >> >> Er, there are a few more drivers than that implementing iommu_ops ;) > > Ahh right. >> >> It seems like it might be more sensible to fix the single instance of >> a driver returning -EINVAL (which appears to be a "should never happen >> if used correctly" kinda thing anyway) and leave the API-internal >> callback prototype as-is. I do agree the inconsistency of >> iommu_unmap() itself wants sorting, though (particularly the >> !IOMMU_API stubs which are wrong either way). >> >> Robin. > > Make sense. I'll leave the API alone, and change the code to not > returning error then. Actually, on a second look I think that check in amd_iommu is 99% redundant anyway, since PAGE_MODE_NONE is only normally set for IOMMU_DOMAIN_IDENTITY domains, thus iommu_unmap() would have bailed out from the __IOMMU_DOMAIN_PAGING check before ops->unmap could be called. AFAICS the only way to hit it at all is if a caller somehow managed to get hold of the dev_state->domain set up in amd_iommu_init_device(), then tried to unmap something from that, which seems such a very wrong thing to do it should probably just crash and burn with extreme prejudice anyway. Cheers, Robin.