lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aM30pgjLCvXtsW90@Asurada-Nvidia>
Date: Fri, 19 Sep 2025 17:26:14 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: <jgg@...dia.com>, <will@...nel.org>, <robin.murphy@....com>
CC: <joro@...tes.org>, <jean-philippe@...aro.org>, <miko.lenczewski@....com>,
	<balbirs@...dia.com>, <peterz@...radead.org>, <smostafa@...gle.com>,
	<kevin.tian@...el.com>, <praan@...gle.com>,
	<linux-arm-kernel@...ts.infradead.org>, <iommu@...ts.linux.dev>,
	<linux-kernel@...r.kernel.org>, <patches@...ts.linux.dev>
Subject: Re: [PATCH rfcv2 4/8] iommu/arm-smmu-v3: Introduce a per-domain
 arm_smmu_invs array

On Mon, Sep 08, 2025 at 04:26:58PM -0700, Nicolin Chen wrote:
> +/**
> + * arm_smmu_invs_unref() - Find in @invs for all entries in @to_unref, decrease
> + *                         the user counts without deletions
> + * @invs: the base invalidation array
> + * @to_unref: an array of invlidations to decrease their user counts
> + *
> + * Return: the number of trash entries in the array, for arm_smmu_invs_purge()
> + *
> + * This function will not fail. Any entry with users=0 will be marked as trash.
> + * All trash entries will remain in the @invs until being completely deleted by
> + * the next arm_smmu_invs_merge() or an arm_smmu_invs_purge() function call.
> + *
> + * This function must be locked and serialized with arm_smmu_invs_merge() and
> + * arm_smmu_invs_purge(), but do not lockdep on any lock for KUNIT test.
> + *
> + * Note that the @invs->num_invs will not be updated, even if the actual number
> + * of invalidations are decreased. Readers should take the read lock to iterate
> + * each entry and check its users counter until @inv->num_invs.
> + */
> +VISIBLE_IF_KUNIT
> +size_t arm_smmu_invs_unref(struct arm_smmu_invs *invs,
> +			   struct arm_smmu_invs *to_unref)
> +{
> +	size_t num_dels = 0;
> +	size_t i, j;
> +
> +	for (i = j = 0; i != invs->num_invs || j != to_unref->num_invs;) {
> +		int cmp;
> +
> +		if (!refcount_read(&invs->inv[i].users)) {
> +			num_dels++;
> +			i++;
> +			continue;
> +		}

Found that this should AND the condition "i < invs->num_invs".

Will fix in next version.

> +
> +		cmp = arm_smmu_invs_merge_cmp(invs, i, to_unref, j);
> +		if (cmp < 0) {
> +			/* not found in to_unref, leave alone */
> +			i++;
> +		} else if (cmp == 0) {
> +			/* same item */
> +			if (refcount_dec_and_test(&invs->inv[i].users))
> +				num_dels++;
> +			i++;
> +			j++;
> +		} else {
> +			/* item in to_unref is not in invs or already a trash */
> +			WARN_ON(true);
> +			j++;
> +		}
> +	}
> +	return num_dels;
> +}

Nicolin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ