From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D9F2466B65 for ; Tue, 14 Jul 2026 13:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784036011; cv=none; b=a3M+oFxleVpQfSl78DjXuaxZfB3mqVrdxuRc1+7xlcTB5BIi0YL9CZzz4L0sOlBAaHfAsuGXJfe9zwfX0xz3PqqJjvVHZYf7Os1IzhAzYEjnS2ritUhFdocbswQ8Wc++wQN9k50GRDVhS7TQBd9B4h+MYhxHiVTykwN1Ze3tA4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784036011; c=relaxed/simple; bh=ULDnWMH5nVc0QO2IzjbnmdovlthlsVSlWZXQDnkobP8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=W6zUZBdU4pZnkvYCdW30E4r1bOHxG1eghfPpApisRV4EEvVuHmkCL4DfdqW/b1HnlQ6QecKI83FqbSGOvglKHR1hpjCWitOkk8t54JAacMcpGFxLZdtQGYMnuavp3RgHhg6V0mmyqAXBP6zPJd8juau4CpU6hjStkOrAfLoycTc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Sek3loY4; arc=none smtp.client-ip=209.85.160.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sek3loY4" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-51c10ed63c0so286371cf.1 for ; Tue, 14 Jul 2026 06:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784036009; x=1784640809; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=ZffwBF6hhGkwheo3CTBU68dVv5rF3zKRAqSeKFNznAQ=; b=Sek3loY40sdCGkI2k/7eBa63qK+Fy7rI0SlCTzR18eb6KjJ9lZB42PIuODa4yY0xVP K/YoZxoofTVfyNJO4mFPsef0hXmctoOsXu3Oj1VV1Mxh8HoeCurkM1ncybkXOCHvqOxj DzgJ+2PYh2jBHmHMKdB4Zivaia3de3fzGJ0Gi306i0nwxFCrBSr4H+oFwKTOir2gsqNg BMffEzpYmSIco3N2ONMYPsKoRa8oOnIh5ZDAtKT997t+J/4alwBZh5CY2DqA7c1Az6hW UYnXy5+jey5ECSlhRlUO59Dbu1KxUa7+bZkYJkt8b5gK2VZurMY8RewUL+zg8eLM+BPN eGSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784036009; x=1784640809; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZffwBF6hhGkwheo3CTBU68dVv5rF3zKRAqSeKFNznAQ=; b=TKHEXxxl7dJb9IS4AEo8BBv0AxpwqqfzvkEMhg2PbCRqiyARKwJHpOBEXgUrPEzmDC /Fnn7ps/zOaLllpiHLRk2SZIU8umK10zxtO34ES4nwbuwfHKYV7rdqmOHCb68NnORFaB yUd/jbrWNysyAC+w++VHAmB7zHD0Lrvpg9lyLHS7YjQpCQcMaucGoy9IxU+Hz+4FKdvX jKsXPSRDjTzK80qx6KvjkC582KF3cYWuiXK+sVfxopfD/qf3hCd9lzhP6TNY37mLB1lr pRyX4Hx5bcwzSnFMl46zRhW9E1yhjnibD37yk6fheE8GCDCS99VTyIlurvNOfKPKQeSZ xYTQ== X-Forwarded-Encrypted: i=1; AHgh+RqSBRC/II0H0MbZ1ho1O2bBltQfCnr69BjVYi1B2Yz7CAMZYAYvpp95IpUnMdLoGpxLpao0t82gpENC5mU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzfo2D/5nCMSs+qa3vtVND/Ed0kNmVCPZX4YlSos5Lp0VpVrN+b s3jyB+HPWJ0HE/Qh4jNvYQMMqCjID0OPDkyGEUl2j0+FlzZ0lu2cytsgKsBa0FhuCg== X-Gm-Gg: AfdE7cnhaWb79EE59ArIcJ3nuhyyFzQbE+CvTlNwYD3TLlrWgq0kKi3d7m9ZsTAUFxZ O5U5qBeGnoPdNNFiL13LCmf8DdDXu9fQLFe8Vmc/lOhV/8Y7KILnVhfGqFcYfABr+Txbp5JPZyR 6QlkVq8A3tdQBFVSXoSmtRorVV0hH2MFoLa44xuLVyT+nJZS8OMiNc9NIrekh3B0DBewPitBs7I EbTG+pJb/e7GLU589657ksneSChD8Y+Sc9HTkALO2/FtAhExnn8qOgGNFZI9owOhhlcgumeqfqA 2TWEZy9Ol3yywheRZjNDKEac2eZ00jI7AF6DoZ87+NlkkU26irf7quUiyUAwnLgXKKx8fs9Vu/G Qaaai8N2XM07knJdjfl780hsYnaTF4LjQ0TYvDhjNMg9upGThIDwl7fL9W0I6IUqzetSGGdtHH7 aViyQLkvPnEiRstNw3ZRORWPhEJn7tTQYoGQMhFMsvCaYKjxo= X-Received: by 2002:a05:622a:4d:b0:51c:ba4f:9d19 with SMTP id d75a77b69052e-51d7bd752e0mr14354651cf.19.1784036008463; Tue, 14 Jul 2026 06:33:28 -0700 (PDT) Received: from google.com (10.129.124.34.bc.googleusercontent.com. [34.124.129.10]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-973a671434bsm3864983241.3.2026.07.14.06.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 06:33:27 -0700 (PDT) Date: Tue, 14 Jul 2026 13:33:21 +0000 From: Pranjal Shrivastava To: Nicolin Chen Cc: Will Deacon , Jason Gunthorpe , Kevin Tian , Lu Baolu , Robin Murphy , joro@8bytes.org, David Woodhouse , linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/5] iommu/arm-smmu-v3-iommufd: Convert cache invalidation to the core array loop Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jul 08, 2026 at 12:44:19PM -0700, Nicolin Chen wrote: > arm_vsmmu_cache_invalidate() allocated a buffer for the entire user request > array, walked the array converting each of the commands, and issued those > converted commands to the cmdq in CMDQ_BATCH_ENTRIES sized chunks, carrying > the sub-array bookkeeping all on its own. > > The iommufd core now iterates the invalidation array and re-invokes the op > with the not-yet-handled sub-array, so the driver only has to proceed with > a single chunk per call. > > Instead of a per-array allocation, use a fixed on-stack batch to copy from > the userspace array. If the copy fails due to nonzero padding (VMM violates > the ABI), fail the entire batch. > > Convert the whole batch before issuing any of it: a malformed command is a > userspace bug, so the first illegal command fails the batch as a unit, > issuing nothing and leaving array->entry_num at zero, the same way the copy > above bails on nonzero padding. A batch that converts cleanly is issued in > full, so the op returns either a handled count with no error or zero with > an error. > > A zero-length array now returns success once the data type gets validated, > matching the documented probe behavior, rather than the -EINVAL that the > full-array copy helper would previously return. > > This also fixes two long-standing bugs: > 1) On a conversion failure the old code reported commands that it had > converted but not yet issued, so user space advanced its consumer > index past invalidations that never reached the cmdq. > 2) A zero-length array was rejected with -EINVAL, although the uAPI > documents it as a valid request that only probes the data type. > > Reviewed-by: Kevin Tian > Assisted-by: Claude:claude-opus-4-8 > Signed-off-by: Nicolin Chen Reviewed-by: Pranjal Shrivastava Thanks, Praan