From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 51D3C3E1CF6 for ; Fri, 8 May 2026 13:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778248660; cv=none; b=uk/b2sgSQYXC46PPvPF73gPqjzoeIF4ZjGebt1rWuskgUPbPKbSMYDFLokJuRWCt1Fb/3dlGfL90lT27um0bd5g2oFSNoMy8iYeZZPlGyNU9s/HEEMlhlmX8m2waCjOOr46nDH4/U1Uu4Kx/1YiMVF/+b22Bv2tUqKzhhodxfmM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778248660; c=relaxed/simple; bh=7yau3d87sObHanjQIMBqjvHJ1Z5ikCcehMsXFQiWwa0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Marz/KTHGdOz2OxZzVUtjaj3lHH+GdnQBT/gv/u+36yxp7dQHPZ4JHkNTTKtmymH6IVRCki1chfYb5nweYFt3DHSytNmsPfN17T8u0JMn9AEfpYJYcJ0LJ48z8vT5fmSz1PAA4FN7yW91BODhYGy/kNEFEWt4q4gfSLCNkAk/UM= 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=sL0XmMu6; arc=none smtp.client-ip=209.85.214.181 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="sL0XmMu6" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2b2e8b95bdbso87305ad.0 for ; Fri, 08 May 2026 06:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778248658; x=1778853458; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2CGBwXFExFaRTA0wwGYcIL+GR6BKdaPP0X35HwC1TKY=; b=sL0XmMu6vcY9V3vKFBu/qKJPzVmUA9bY7lZ6dKISc3ulcfh1EZ0mUQqtOpc4ZalJ9S 1bYgLS/qlcbkfOZn7vfK7zR4cW8vcpynNqxpwijSY/G9smg3c8aHGm8XKXIQzlmfbxEA 22S6FjYqetYXq0Y7veVjR0UQYj9Ge1j2s/ASxRCO3K3vRHJMmrq0cBoDUCuMEc7IR/qQ YTc6xCNZkRPGLMMAPpPve+l300KW12m6w9E0/KLjKtE8d0IeA5iXDPN25zNXRewlYOTZ jP4AEoqPKg2aKHnoM6R6wCn8g5yOoKXx6Fb7JUNcTPrq57rYZJSVIyQalc0m8aUZPBWG 16fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778248658; x=1778853458; h=in-reply-to:content-disposition: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; bh=2CGBwXFExFaRTA0wwGYcIL+GR6BKdaPP0X35HwC1TKY=; b=e+XWvdwohU/HEfKHmDOJfra+zEZ8P1Ko6q9X/45qJXT/Ow9oGuQpz66FvXllPCHYSe Shz4GnWxCpi+6u2FtX9wRzv+VQfxXtQM9Sy7m7XIMpymNZ3asfDBOKGxz6hpBipRS04p Z3n0E68KzRjtEceqedqx6B4AI0EJja/7JuH9aRdsyRImk+816I2+PhpRRMOjVPoppv8X zgUMWc9Z1RPBv++EsBa83AreSPMIZ8wiyw2IiMlJN/mN28mxf/gE+bzv3vlf+4Z13dHr kpA/+zgT9zYtmGGpDJXrbOBZIp8w7+2Z1O0AP9pWGANscnp7A/o7vUVv3f0q6D2PWV7b UQFA== X-Forwarded-Encrypted: i=1; AFNElJ8Stz0Nsq0eHO52AKcJCTBYn7/5lZFaiA0oTQ7lQZX5uXGL8othX9eQ59HBtACAXkQLk2/PEJ4wqVHIoJU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3RcFqb1uYDIFFVXJ3IDb5qAXRLPSolgt1BwCejWpYurfJ2N4Y aZXa8kRiuQ7zoypB38q/h5RAf55YZ+RvBwxEk6msCk8n4UlHoa3qJqHzQ0QPbMChVw== X-Gm-Gg: Acq92OEG1adHkzYSgmObbwyRk7Dk9ydTSXQx68lCXXx/Rq8ptxEn5vKYg/q/EBYNIYk DYaozM7qUOQEC4FeCrAa36J/aTWEze/X6xZAvr8S9Ccy0JhWHpnnmo65dFtN/49y/2wgp6U0fvO opBFluEadGFBaaErUwjrk1m97/hpfAp9s9XffYFP459ef55tlZ0kVKKlzZZYFgRIadkxSvR81QL P7if/TzsAEjCi9TRny/Zqx/9ZL/hDUrwY50nazPXV/2GCcP5mTosbI4sF9rt4A09TfjHMyflGnZ CJ7MMuX6UXe0QljAplfd03AJYwJpZrvFsovs9AsW8T4pU/1q2my2A9t9lBdFzjrNUYBeyidlhtA BMMulvJxDkmb+e95TEX1/Vx0IyjCyZo8ksfGygALANILWoG63qczfIEM8c15Td7w5SbnAy6Tw5k PHG2ue9/gg1hWIxT+77aSgpQAfJR83CNYeh+XxBCefv60SbEdLBvhUBfFKlD/HzW/IfSqw X-Received: by 2002:a17:903:1b66:b0:2a7:6c4e:5914 with SMTP id d9443c01a7336-2bae9ab0221mr3968545ad.6.1778248656937; Fri, 08 May 2026 06:57:36 -0700 (PDT) Received: from google.com (44.234.124.34.bc.googleusercontent.com. [34.124.234.44]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3664da41fcasm2594450a91.2.2026.05.08.06.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2026 06:57:36 -0700 (PDT) Date: Fri, 8 May 2026 13:57:30 +0000 From: Pranjal Shrivastava To: Robin Murphy Cc: Jason Gunthorpe , Nicolin Chen , Will Deacon , Joerg Roedel , Jean-Philippe Brucker , Catalin Marinas , =?utf-8?Q?Miko=C5=82aj?= Lenczewski , linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits Message-ID: References: <20260503135413.1108138-1-nicolinc@nvidia.com> <20260508123550.GB9254@nvidia.com> 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 Fri, May 08, 2026 at 02:31:11PM +0100, Robin Murphy wrote: > On 2026-05-08 2:12 pm, Pranjal Shrivastava wrote: > > On Fri, May 08, 2026 at 09:35:50AM -0300, Jason Gunthorpe wrote: > > > On Thu, May 07, 2026 at 10:30:14PM +0000, Pranjal Shrivastava wrote: > > > > > @@ -92,6 +92,16 @@ void arm_smmu_make_sva_cd(struct arm_smmu_cd *target, > > > > > target->data[1] = cpu_to_le64(virt_to_phys(mm->pgd) & > > > > > CTXDESC_CD_1_TTB0_MASK); > > > > > + > > > > > + /* > > > > > + * Enable Hardware Access and Dirty updates (DBM) if supported. > > > > > + * This is safe to enable by default, as PTE_WRITE and PTE_DBM > > > > > + * share the same bit. > > > > > + */ > > > > > + if (master->smmu->features & ARM_SMMU_FEAT_HA) > > > > > + target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HA); > > > > > + if (master->smmu->features & ARM_SMMU_FEAT_HD) > > > > > + target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HD); > > > > > > > > IIUC, we should be setting these if IO_PGTABLE_QUIRK_ARM_HD is present? > > > > > > SVA does not use IO_PGTABLE at all, and it directly constructs its own > > > CD. > > > > > > No relation between those two flows. > > > > I understand that but I mean we need to know if the system supports > > HTTU ? Like for SMMU we use the IO_PGTABLE_QUIRK, shouldn't we be > > checking if the CPU's tables support HTTU? > > > > Are we assuming that if the SMMU IDR presents HTTU capability the MMU > > would also have it? I think an unconditional enablement is risky as we > > may not have system-wide HTTU support. > > > > If we look at arm_smmu_master_sva_supported, the driver already > > maintains a strict agreement between the CPU and SMMU for SVA. > > It checks sanitized CPU ID registers for things like PARANGE & ASIDBITS, > > and it uses system_supports_bbml2_noabort() to decide whether to enable > > FEAT_BBML2. > > > > Shouldn't we follow this exact same pattern for HTTU ? > > We should probably be checking cpu_has_hw_af() (from asm/cpufeature.h) > > in the SVA support check or here if we wanna enable HTTU. > > It might make sense to depend on CONFIG_ARM64_HW_AFDBM - when that is > enabled, then IIRC we already expect to cope with some CPUs not supporting > hardware updates, so it should still be fine for an SMMU to make them even > if no CPU does. However, if it's disabled then I'm not sure if missing > access flag faults (if SMMU HA silently sets them) might be an issue - for > dirty, we'd just never put down the Writeable-Clean permission so enabling > SMMU HD wouldn't do anything anyway. I see, so IIUC, you mean if IS_ENABLED(CONFIG_ARM64_HW_AFDBM) but CPU doesn't enable HTTU, it is perfectly safe to let the SMMU do HTT updates, Since the fault handlers are already expecting HW-triggered updates? Which means our check would be something like: if (IS_ENABLED(CONFIG_ARM64_HW_AFDBM) { if (smmu->features & FEAT_HA) ... } instead of cpu_has_hw_af()? Thanks, Praan