From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752472AbdK3OQa (ORCPT ); Thu, 30 Nov 2017 09:16:30 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55260 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752332AbdK3OQ1 (ORCPT ); Thu, 30 Nov 2017 09:16:27 -0500 Subject: Re: [PATCH] vfio/iommu_type1: report the IOMMU aperture info To: Jean-Philippe Brucker , "alex.williamson@redhat.com" Cc: "cohuck@redhat.com" , "borntraeger@de.ibm.com" , "zyimin@linux.vnet.ibm.com" , "pasic@linux.vnet.ibm.com" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <1512041678-4563-1-git-send-email-pmorel@linux.vnet.ibm.com> <1ad1aff9-1651-d1a9-cd1b-07bfd7dd0817@arm.com> From: Pierre Morel Date: Thu, 30 Nov 2017 15:16:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1ad1aff9-1651-d1a9-cd1b-07bfd7dd0817@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 17113014-0016-0000-0000-000005075E0A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17113014-0017-0000-0000-000028434A75 Message-Id: <7cf3e03e-e9b4-0e27-098b-3bc391abcf96@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-30_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711300187 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/11/2017 13:57, Jean-Philippe Brucker wrote: > Hello, > > On 30/11/17 11:34, Pierre Morel wrote: > [...] >> +/** >> + * vfio_get_aperture - report minimal aperture of a vfio_iommu >> + * @iommu: the current vfio_iommu >> + * @start: a pointer to the aperture start >> + * @end : a pointer to the aperture end >> + * >> + * This function iterate on the domains using the given vfio_iommu >> + * and restrict the aperture to the minimal aperture common >> + * to all domains sharing this vfio_iommu. >> + */ >> +static void vfio_get_aperture(struct vfio_iommu *iommu, uint64_t *start, >> + uint64_t *end) >> +{ >> + struct iommu_domain_geometry geometry; >> + struct vfio_domain *domain; >> + >> + *start = 0; >> + *end = U64_MAX; > > I wonder if the default values should also reflect what the VFIO > implementation actually supports. Looking at vfio_dma_do_map, a 32-bit > host will reject any iova greater than 32 bits. In addition, > vfio_dma_do_unmap doesn't support unmapping the last page of a 64-bit > address space (existing IOMMUs would probably reject map requests with > IOVA > 52 bits anyway, but if they don't report a domain aperture, VFIO > can't guess it). > > I think it's convenient to use VFIO_IOMMU_UNMAP_DMA on the full address > space when an unmap-all is needed, maybe we could provide default aperture > values that help doing this? (~0U for 32-bit and (~0ULL - PAGE_SIZE) for > 64-bit) > > Thanks, > Jean > Thanks, I will take care of this. Pierre -- Pierre Morel Linux/KVM/QEMU in Böblingen - Germany