Received: by 2002:a17:906:d9da:b0:a3d:1c09:7d3d with SMTP id qk26csp399947ejb; Wed, 14 Feb 2024 23:22:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUWCuilvhH6Utep+GgNAK0V+hDZldnFBD9iOSv6eU0FRlUTHoxZtu79IyY/90Eky/VehT9x0u9GwVkoLVXBv2fd0fzVYZXQ X-Google-Smtp-Source: AGHT+IElbwFk/32I48ra4zeF59vnYs8mChZasw+UolLmdQnTYUDfzPJQRDBx7J/hA9xLiMY66t7h X-Received: by 2002:a05:622a:1b91:b0:42c:74f8:1221 with SMTP id bp17-20020a05622a1b9100b0042c74f81221mr1268387qtb.33.1707981746312; Wed, 14 Feb 2024 23:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707981746; cv=none; d=google.com; s=arc-20160816; b=eAgK6vNxqI9jdqmJ4wVKvUB3qTZTpoE1wC1vY5biyelep4Y3ns9GI76kq2JYaTxfak SwezqMDn09lD2DhfACZWqZRzQ338eEwleRd5qK/eTEcUFTNk0eFyhT4/WSJuBRcfUWig AhPtjYC0UKeVg9WrMkCgV7Ngs9sZIZXTvXP7IshGezVnMVk68nU+MG8f6CQipOwN7/ub Q396Xg0UPHQ35I/ImqZbhfWsi+0OfA4lxX2UA+xSZ4xvMyVQyutbiEDVLFGX+0nrnMZY y5u2Nn0sDuxotsCR7sWhLB+tKiLkkXhOs1L3c7WIZAbrB3eMbYIKfgxvR6THBWi2eJkR 2PtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=kTPYKsLPweiGLixPJw7Ynw2sWN+4bAfBkl5lH6yS+wU=; fh=AFDdSAYdGTukerslaWjaZa1qoNV9QxsbQmocqA8F7Jc=; b=Ci3Mye2yUkmxCGS74cPw+E/bYaP7Z2qbcZ+cg8nMuNu+32ORtFY9QIhHoBYbqcPrYH CWbdt9GCCpieLrpckDzAszHorg3eXrYl3SfOpyQiYMjoMC00zen3EtwlehGVvBWNsOTQ jRNqRWeY6DTiwW7s4n91kpn9KORw/absYwDsJS8/75v3S0HsivQcVpX9HSwnmSO9POJs TetCCmiQYGmyndSUOvRW8BTUIldbpeVnZeR5c+VGuTVQY1YFKW8/oORqn0hc868k+LOL LZfp0FYCkiiV9EOuaPEeno2TYpbNKYOgRmyfJ7XWCIVvcZ69ABIQ9E52T5QbXuqo+5he MYgA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FIqG1b37; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y24-20020ac85258000000b0042db63f3e05si738314qtn.523.2024.02.14.23.22.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 23:22:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FIqG1b37; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raW4V-000342-U9; Thu, 15 Feb 2024 02:22:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raW4U-00033i-0o for qemu-devel@nongnu.org; Thu, 15 Feb 2024 02:22:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raW4S-0006g0-8J for qemu-devel@nongnu.org; Thu, 15 Feb 2024 02:22:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707981730; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kTPYKsLPweiGLixPJw7Ynw2sWN+4bAfBkl5lH6yS+wU=; b=FIqG1b37EAhiBQabJNTOuSaaM7tFJ+3TSl6vQbuGuhcf8+8UjsTJH7zdYuv/ol8ljoCavE 7nVViR4MZ04W3Ycla0AGBGvoJcPnkfOIsav8rqmyGJsoMOFbEhXxb8T2X7k3FoQtf6Snp+ fX7UPG8uIkNZUDYa9wlG4CJJFysiz1A= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-lMKyp5tDPGi8-kljFybgBA-1; Thu, 15 Feb 2024 02:22:08 -0500 X-MC-Unique: lMKyp5tDPGi8-kljFybgBA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-42793cd9d33so6336061cf.2 for ; Wed, 14 Feb 2024 23:22:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707981728; x=1708586528; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kTPYKsLPweiGLixPJw7Ynw2sWN+4bAfBkl5lH6yS+wU=; b=t1UJQMlZDb6e2eUlkicEZXxYsAVMvD+/GeKrz96o5q9oYK4Z2YNnz16XeA+cpRveGC OgTY3r9J+cx2RYpj2cyRxL9tH/rplKXviz/EszCtXm5mHuqx02o51ppn3n8edlriX7R5 knQZUkh14us91Vq5wFO+Jijee853DNK1+Y+PMx4eASk+NLxeQU5Vf/y3wlFUvlsKGm7G QPg6SjTrWIoJOI+gxtryY3D5HRH0N+JvDJ7JT9vN6xcaqXDBZPzmquqJqBFyuOTe6Szm pOT8n/+Swg4QelpBghQjU9D/l1/AyKpCZkUpSesla7gKedJBsLEskGf33UI0c/q4vDGd PX/g== X-Forwarded-Encrypted: i=1; AJvYcCUYT+y+wiS8sYWtrbVvqZ2OWdH0ypROw04Il/qEigpVzsHWYi364MESpSB0/oorMwZ9UacEiUEmtBOqrMG9we4pIYNaIsA= X-Gm-Message-State: AOJu0Yxra7rnBLbtg1qoCBiEBfswcptto377e3jJWyk2b37RUTdB83SR ihZWP9bCQNkvGumpK5dpIOdFiyHF7da5ahZ2xiFT6NZ01xfvmA5zw/WN7u+VlK5kqGtCjYQ3/E/ r/rPSN4R7or35REUK1Oz7Nx+ftOO6lBAxLt+UtVAHl0VtgWyfzf+r X-Received: by 2002:a05:622a:16:b0:42c:75b9:b67f with SMTP id x22-20020a05622a001600b0042c75b9b67fmr1126596qtw.31.1707981728006; Wed, 14 Feb 2024 23:22:08 -0800 (PST) X-Received: by 2002:a05:622a:16:b0:42c:75b9:b67f with SMTP id x22-20020a05622a001600b0042c75b9b67fmr1126590qtw.31.1707981727738; Wed, 14 Feb 2024 23:22:07 -0800 (PST) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id b1-20020ac85bc1000000b0042c5715b8d1sm332188qtb.76.2024.02.14.23.22.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Feb 2024 23:22:07 -0800 (PST) Message-ID: <522cfa0b-050a-4a93-acf5-62dfe71c8185@redhat.com> Date: Thu, 15 Feb 2024 08:22:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] hw/arm/smmuv3: add support for stage 1 access fault Content-Language: en-US To: Luc Michel , qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: Peter Maydell , Francisco Iglesias References: <20240213082211.3330400-1-luc.michel@amd.com> From: Eric Auger In-Reply-To: <20240213082211.3330400-1-luc.michel@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.531, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: eric.auger@redhat.com Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: 25m1yRaKtMZ/ Hi Luc, On 2/13/24 09:22, Luc Michel wrote: > An access fault is raised when the Access Flag is not set in the > looked-up PTE and the AFFD field is not set in the corresponding context > descriptor. This was already implemented for stage 2. Implement it for > stage 1 as well. > > Signed-off-by: Luc Michel > --- > > v2: drop erroneous submodule modification > > --- > > hw/arm/smmuv3-internal.h | 1 + > include/hw/arm/smmu-common.h | 1 + > hw/arm/smmu-common.c | 10 ++++++++++ > hw/arm/smmuv3.c | 1 + > 4 files changed, 13 insertions(+) > > diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h > index e987bc4686b..e4dd11e1e62 100644 > --- a/hw/arm/smmuv3-internal.h > +++ b/hw/arm/smmuv3-internal.h > @@ -622,10 +622,11 @@ static inline int pa_range(STE *ste) > #define CD_TSZ(x, sel) extract32((x)->word[0], (16 * (sel)) + 0, 6) > #define CD_TG(x, sel) extract32((x)->word[0], (16 * (sel)) + 6, 2) > #define CD_EPD(x, sel) extract32((x)->word[0], (16 * (sel)) + 14, 1) > #define CD_ENDI(x) extract32((x)->word[0], 15, 1) > #define CD_IPS(x) extract32((x)->word[1], 0 , 3) > +#define CD_AFFD(x) extract32((x)->word[1], 3 , 1) > #define CD_TBI(x) extract32((x)->word[1], 6 , 2) > #define CD_HD(x) extract32((x)->word[1], 10 , 1) > #define CD_HA(x) extract32((x)->word[1], 11 , 1) > #define CD_S(x) extract32((x)->word[1], 12, 1) > #define CD_R(x) extract32((x)->word[1], 13, 1) > diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h > index fd8d772da11..5ec2e6c1a43 100644 > --- a/include/hw/arm/smmu-common.h > +++ b/include/hw/arm/smmu-common.h > @@ -90,10 +90,11 @@ typedef struct SMMUTransCfg { > /* Shared fields between stage-1 and stage-2. */ > int stage; /* translation stage */ > bool disabled; /* smmu is disabled */ > bool bypassed; /* translation is bypassed */ > bool aborted; /* translation is aborted */ > + bool affd; /* AF fault disable */ > uint32_t iotlb_hits; /* counts IOTLB hits */ > uint32_t iotlb_misses; /* counts IOTLB misses*/ > /* Used by stage-1 only. */ > bool aa64; /* arch64 or aarch32 translation table */ > bool record_faults; /* record fault events */ > diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c > index 9a8ac45431a..09ff72e55f5 100644 > --- a/hw/arm/smmu-common.c > +++ b/hw/arm/smmu-common.c > @@ -362,10 +362,20 @@ static int smmu_ptw_64_s1(SMMUTransCfg *cfg, > &block_size); > trace_smmu_ptw_block_pte(stage, level, baseaddr, > pte_addr, pte, iova, gpa, > block_size >> 20); > } > + > + /* > + * If AFFD and PTE.AF are 0 => fault. (5.4. Context Descriptor) > + * An Access fault takes priority over a Permission fault. nit: you may precise that this holds because HTTU is not currently supported > + */ > + if (!PTE_AF(pte) && !cfg->affd) { > + info->type = SMMU_PTW_ERR_ACCESS; > + goto error; > + } > + > ap = PTE_AP(pte); > if (is_permission_fault(ap, perm)) { > info->type = SMMU_PTW_ERR_PERMISSION; > goto error; > } > diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c > index 68eeef3e1d4..c416b8c0030 100644 > --- a/hw/arm/smmuv3.c > +++ b/hw/arm/smmuv3.c > @@ -682,10 +682,11 @@ static int decode_cd(SMMUTransCfg *cfg, CD *cd, SMMUEventInfo *event) > > cfg->oas = oas2bits(CD_IPS(cd)); > cfg->oas = MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas); > cfg->tbi = CD_TBI(cd); > cfg->asid = CD_ASID(cd); > + cfg->affd = CD_AFFD(cd); > > trace_smmuv3_decode_cd(cfg->oas); > > /* decode data dependent on TT */ > for (i = 0; i <= 1; i++) { Besides, looks good to me Reviewed-by: Eric Auger Eric