From nobody Tue Dec 2 02:59:11 2025 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (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 4298B32E12B for ; Mon, 17 Nov 2025 18:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763405335; cv=none; b=sJRpEOAe72IihvkZuIoMtt1JPE9JoMPeBs3TbFT6zFAjWLqUV3dKw1nXTP8ImJsaGijFC0IFZTGNG0v18vNcSyr7lh1vHXHN9MKm9vw52Wnof/CQgTEN1wCRwY6kr/pPRtfMItFX6QPjMgnOHZUUhwiM7VqSsj998frZIZRdhj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763405335; c=relaxed/simple; bh=hrcmq+7BKS+7RyD2MLzXmh7hMuGNu7NQQpndrNeBtvg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pHN4QwLxSTy6JFJyt5ilRqQ6Xhgs/mTNYjSjZ4elD9Bm1XRQMWQghagR+UJ+ZMENpdfWOIZ9Nj2js4gRKC0i+oLnSxh3Hv1Fzwva7BWVJ59gKFriYtiAxuYNAmjEsP7AmKXXQzTKiQk/rZBTg90t5SxUCVoj6iJ2Oiug16xAh1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--smostafa.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sQHkDu10; arc=none smtp.client-ip=209.85.221.74 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=flex--smostafa.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sQHkDu10" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-42b56125e77so2137904f8f.3 for ; Mon, 17 Nov 2025 10:48:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763405330; x=1764010130; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=7Pr/AhyDI18gHyudCTe0PajcLVV2Ma7cRe8uP5zP/9Y=; b=sQHkDu10vS1g1VjR8CPENx16vQeAHGCFnZlVFC3KeS6ckf/KC+UDDqygCS7XQ0Bn3m 8rZpHPWvJYTRA2zdylFlHxevUwiaGGpW+tLUH0THHCAHnYrEQQ1Tp/wXams5Y2ytXII9 ++Icl+TQKXAZEqNsgKHsLKwbqGxz0Bn7xPJ9Ig6PBV5brcb1Pf5aHuiZCwEmFecZBRCk EZIIBYqfCQtxgUsKHZlv95I93edo+UmwHf4P1G1cLKGwA+t8ZIikzM3L5r415brpRM0+ X97mRjSaPzNCUkJyK8aMqNZPiEDl9nB0RACLw2W0ipM99+foyIVLle1Fy/oqHUzyCpJ2 VNYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763405330; x=1764010130; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=7Pr/AhyDI18gHyudCTe0PajcLVV2Ma7cRe8uP5zP/9Y=; b=gN1oP3pctr/1tjPEolmNdn7E0wuYdnj1YQupeFJgJRV7M9gJ46WxnJO8Lh9GZpkbub QFkhEOUAF1xybLjqOzMNBqAi/FZeuwYmQz95+e5dXTzeD33hYI1Ad/HVXxNGJpQDzIpX 8eorPTcZmeW9WcprvwQJxskO4DMIYq8oGcKW1xNhIByLt6CSa1PMEEEL0Zjbu2qqUCb9 BEUPIZJGovNQa+YC558yszwCTKYFDCnX6Z4w503OnI3VEfQ42r38n8kkWJjBYCr5UZBB eV3UDMxBy7lO4itmFnKQPUmBCqlOVz57vOHqq5mJj6gMN9+RlrDJWh2lIVR5KA0nJQ8X r5eQ== X-Forwarded-Encrypted: i=1; AJvYcCVT95KaS+p+A4dmT9uTie3DPyB55cUDl0oFXrPvmZrusFLUfkabvrjDrIH8baUnEvVGymKKJnUeccO41oo=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/I0gCKFB0k7bG3fVt4HHaoQcuG/WngrwFhmxF0eFuRYRTmrNI ebyGGdvbTJZ+A0nwkCkEc9n3Kx4GWW2FzHsAxZj/0hywGZoZs3jSLXyruJt0w00AU4jJNcVmbRS dz8Kb2p92ohAQZg== X-Google-Smtp-Source: AGHT+IEp1GJrifJg25A7HBsu430z3IudVIoooo816bFplXawdroOYHu2KCfVFavBNdBdQ4MlmLiDzZJPVbDY1w== X-Received: from wrbee4.prod.google.com ([2002:a05:6000:2104:b0:42b:3308:563]) (user=smostafa job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:1849:b0:429:d725:4125 with SMTP id ffacd0b85a97d-42b5959e88dmr13794450f8f.54.1763405329830; Mon, 17 Nov 2025 10:48:49 -0800 (PST) Date: Mon, 17 Nov 2025 18:48:11 +0000 In-Reply-To: <20251117184815.1027271-1-smostafa@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251117184815.1027271-1-smostafa@google.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <20251117184815.1027271-25-smostafa@google.com> Subject: [PATCH v5 24/27] iommu/arm-smmu-v3-kvm: Emulate GBPA From: Mostafa Saleh To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, iommu@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, joro@8bytes.org, jean-philippe@linaro.org, jgg@ziepe.ca, praan@google.com, danielmentz@google.com, mark.rutland@arm.com, qperret@google.com, tabba@google.com, Mostafa Saleh Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The last bit of emulation is GBPA. it must be always set to ABORT, as when the SMMU is disabled it=E2=80=99s not allowed for the host to bypass the SMMU. That =E2=80=98s is done by setting the GBPA to ABORT at init time, and host writes are always ignored and host reads always return ABORT. Signed-off-by: Mostafa Saleh --- .../iommu/arm/arm-smmu-v3/pkvm/arm-smmu-v3.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/pkvm/arm-smmu-v3.c b/drivers/iom= mu/arm/arm-smmu-v3/pkvm/arm-smmu-v3.c index fbe1e13fc15d..0a2ce6c06f4f 100644 --- a/drivers/iommu/arm/arm-smmu-v3/pkvm/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/pkvm/arm-smmu-v3.c @@ -115,6 +115,14 @@ static int smmu_unshare_pages(phys_addr_t addr, size_t= size) return 0; } =20 +static int smmu_abort_gbpa(struct hyp_arm_smmu_v3_device *smmu) +{ + writel_relaxed(GBPA_UPDATE | GBPA_ABORT, smmu->base + ARM_SMMU_GBPA); + /* Wait till UPDATE is cleared. */ + return smmu_wait(false, + readl_relaxed(smmu->base + ARM_SMMU_GBPA) =3D=3D GBPA_ABORT); +} + static bool smmu_cmdq_has_space(struct arm_smmu_queue *cmdq, u32 n) { struct arm_smmu_ll_queue *llq =3D &cmdq->llq; @@ -435,6 +443,10 @@ static int smmu_init_device(struct hyp_arm_smmu_v3_dev= ice *smmu) if (ret) goto out_ret; =20 + ret =3D smmu_abort_gbpa(smmu); + if (ret) + goto out_ret; + return 0; =20 out_ret: @@ -672,10 +684,13 @@ static bool smmu_dabt_device(struct hyp_arm_smmu_v3_d= evice *smmu, smmu->host_ste_cfg =3D val; } goto out_ret; - /* Passthrough the register access for bisectiblity, handled later */ case ARM_SMMU_GBPA: - mask =3D read_write; - break; + /* Ignore write, always read to abort. */ + if (!is_write) + regs->regs[rd] =3D GBPA_ABORT; + + WARN_ON(len !=3D sizeof(u32)); + goto out_ret; case ARM_SMMU_CR0: if (is_write) { bool last_cmdq_en =3D is_cmdq_enabled(smmu); --=20 2.52.0.rc1.455.g30608eb744-goog