Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp716831lqs; Fri, 14 Jun 2024 03:48:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2s9a6G5r6FrgTnv5GGOrG0vb5h+NU/JAO7Gu4bmDlFAnfU8IG/4hq3I46GqPJdIJSFDGDrNqY0pJFjvVWpQnlKcDbgNbVLuj7ARHEqQ== X-Google-Smtp-Source: AGHT+IG+WaBAsSwe1emiKsl8nrooSV6A86Sg3UCaG5N8BdT8bV+vjitlcq+MY7tUIiwD6MzLO2TB X-Received: by 2002:a17:906:aeda:b0:a6e:facf:f982 with SMTP id a640c23a62f3a-a6f60d2c79amr164472466b.23.1718362135842; Fri, 14 Jun 2024 03:48:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718362135; cv=pass; d=google.com; s=arc-20160816; b=c7idJArs9ZqKboFCPeziE/7djPANCUcdnTqMi+S9yIvEi9mXz1latWzs8WT0uDwFXk 66VO8sRsiRo4rHgEYITX40p16bq9J8CFX57fw1WmZWiTspZxWOPoEkEWDNiH5pKjQWNv 70SdZLdflj1RdtenCb/e+Iv9q18Qvh6Z8W3g7Bo4B//NiqRsqRaDk6lKjl9LRg4DwV67 p6D2uu6fIjhIz913Z22oeRkEONIffjVNJVkaRfvBsyShE3BdGTYHLWaD+zAvSdGX11Q0 IUBDgbtciPXOkTjELAVivDrgRTSyHawOIDckUy4Q/snEnW53IHkizkPF2q2JcdrH/PRH 9uRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=lUL9DtADki7Lf33X0zvwfeFRi0qz9BYYU3p3L7c+rOw=; fh=rdi9IMvYhWZkOWXeCyjfeNNHEyFxkioWBKtcgC0KjmE=; b=HG5yThV6RCQiSVIZHFKwCgfGVBhaqxBnPDkTNQ6Pf3S8d9mdfOJyQwTi+wKFXJcRUK Tf6SAayv2+2NgOlYCwO3pAHSexQvH+NrX58ZlyusRXW5CCkHaWofNhxwj7iAU0Eaijr1 RYbJWGclOqtliqTT0sqd6ruFSXLD8GIlLdTAz5lmIYFHexzIwSBPn17V3wofzWWPqIRZ sdUWvO7tp6ecn5GJfIstk6mAkU0+n/0uFZmYpPmNE2mmJlv5mGe9KcyiOLQVAF1RmQ/3 lYoxEVksfxmQmv/TBUMvo0m7yWlRF8Nxm/PTpXQEmwwUz7NPTmbVIe5HqUhpu7XID9eg N2qw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l12pj760; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-214801-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214801-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56dd61a4si165788166b.412.2024.06.14.03.48.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 03:48:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214801-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l12pj760; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-214801-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214801-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 116641F298AA for ; Fri, 14 Jun 2024 10:38:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C45931946A7; Fri, 14 Jun 2024 10:37:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l12pj760" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4A8819149D for ; Fri, 14 Jun 2024 10:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718361472; cv=none; b=hFtjM0z2kiF2rxegQe88pDSmNyGDzxFkeqVBMlj0VDyR6r+Eh9/NGkBtoncGX/OqmUedKjr7eTVAUf3lLayjHunRzn8HDYtHu4hHlFz/EJezkXU642G7RNN3QYEukklAj04XPraNRI6lXcqedVKWBz5Br90ZZ7ueMAuUB0O6NT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718361472; c=relaxed/simple; bh=6d6x9S+xsng22ZM841KrI1KmHKzkb9HeNiE+JCdILgg=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=O7Gjr6EQr0OZJK99qrzvDLnYdDMu9u31RpAe4rCXEqhs1+YVCbKau6+m+pn/iw5qSfuAzyE7M7L1LELmUBVB0ZXHwLeL8LQd2G/XQ4Tb8vBgo29HaMARc1ljyTORhcdtJXXEnkMM2BgJDfOO4Lc2+yy4HUHjW0Ojj85+L0JW+d8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l12pj760; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53119C2BD10; Fri, 14 Jun 2024 10:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718361472; bh=6d6x9S+xsng22ZM841KrI1KmHKzkb9HeNiE+JCdILgg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=l12pj760Pi+3KMNUyZna5O1uD0QzM7fxQIXO5+MPTO4S13WhFWEkIXlu/8I76KU9H kqksDXdTZRa7ITq8vyOCR2AesSw8RxFczHOOzr8flL/4gWMqNzvvdx20NByuZn3Yc6 pXEUg9v6fkDjonw9asnlDxB7ni435mM9/Lau4cCaXNE+mUBxeGQ2urD/dyQGxbBUfN nOKnQiA2zqP/Hj+8HOZNgINk9njE9F8TtHKfZq7SDgN8Ti1pYy8HMqjYtcPxniVPZG fQGSXB2OHqIwcOwd8h0/mreFN93MDD6xKTEizFAlkaq4cpsP+BpN+4uVnQ3OvcFRdw eNV2oWjjyYPQA== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sI4JY-003tLE-Lc; Fri, 14 Jun 2024 11:37:49 +0100 Date: Fri, 14 Jun 2024 11:37:47 +0100 Message-ID: <87cyoj3j44.wl-maz@kernel.org> From: Marc Zyngier To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, ryan.roberts@arm.com, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64/mm: Drop ESR_ELx_FSC_TYPE In-Reply-To: References: <20240613094538.3263536-1-anshuman.khandual@arm.com> <86y179jdbx.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, ryan.roberts@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 14 Jun 2024 03:24:53 +0100, Anshuman Khandual wrote: > On 6/13/24 16:53, Marc Zyngier wrote: > > On Thu, 13 Jun 2024 10:45:38 +0100, > > Anshuman Khandual wrote: > >> > >> Fault status codes at page table level 0, 1, 2 and 3 for access, permission > >> and translation faults are architecturally organized in a way, that masking > >> out ESR_ELx_FSC_TYPE, fetches Level 0 status code for the respective fault. > >> > >> Helpers like esr_fsc_is_[translation|permission|access_flag]_fault() mask > >> out ESR_ELx_FSC_TYPE before comparing against corresponding Level 0 status > >> code as the kernel does not yet care about the page table level, the fault > >> really occurred previously. > >> > >> This scheme is starting to crumble after FEAT_LPA2 when level -1 got added. > >> Fault status code for translation fault at level -1 is 0x2B which does not > >> follow ESR_ELx_FSC_TYPE, requiring esr_fsc_is_translation_fault() changes. > >> > >> This changes above helpers to compare against individual fault status code > >> values for each page table level and drop ESR_ELx_FSC_TYPE which is losing > >> its value as a common mask. > > > > I'd rather we do not drop the existing #defines, for a very > > self-serving reason: > > > > NV requires an implementation to synthesise fault syndromes, and these > > definition are extensively used to compose the syndrome information > > (see the NV MMU series at [1]). This is also heavily use to emulate > > the AT instructions (fault reporting in PAR_EL1.FST). > > > > Having additional helpers is fine. Dropping the base definitions > > isn't, and I'd like to avoid reintroducing them. > > You would like to just leave behind all the existing level 0 syndrome macro > definitions in place ? They are not level 0. They are values for the type of the fault. They are *abused* as level 0, but that's not what they are here for. > > #define ESR_ELx_FSC_ACCESS (0x08) > #define ESR_ELx_FSC_FAULT (0x04) > #define ESR_ELx_FSC_PERM (0x0C) + ESR_ELx_FSC_{TYPE,LEVEL}, because they are convenient macros to extract the type/level of a fault. NV further adds ESR_ELx_FSC_ADDRSZ which has been missing. > > Or which are rather > > #define ESR_ELx_FSC_ACCESS ESR_ELx_FSC_ACCESS_L0 > #define ESR_ELx_FSC_FAULT ESR_ELx_FSC_FAULT_L0 > #define ESR_ELx_FSC_PERM ESR_ELx_FSC_PERM_L0 I definitely prefer the former. > But just wondering why cannot ESR_ELx_FSC_[ACCESS|FAULT|PERM]_L0 definitions > be used directly in new use cases ? Because that is semantically wrong to add/or a level on something that *already* describes a level. Specially for the level -1 case. On top of that, what I dislike the most about this patch is that it defines discrete values for something that could be parametric at zero cost, just like ESR_ELx_FSC_SEA_TTW(). Yes, there is some additional complexity, but nothing that the compiler can't elide. For example, something like this: diff --git a/arch/arm64/include/asm/esr.h b/arch/arm64/include/asm/esr.h index 7abf09df7033..c320aeb1bb9a 100644 --- a/arch/arm64/include/asm/esr.h +++ b/arch/arm64/include/asm/esr.h @@ -121,6 +121,10 @@ #define ESR_ELx_FSC_SECC (0x18) #define ESR_ELx_FSC_SECC_TTW(n) (0x1c + (n)) +#define ESR_ELx_FSC_FAULT_nL (0x2C) +#define ESR_ELx_FSC_FAULT_L(n) (((n) < 0 ? ESR_ELx_FSC_FAULT_nL : \ + ESR_ELx_FSC_FAULT) + (n)) + /* ISS field definitions for Data Aborts */ #define ESR_ELx_ISV_SHIFT (24) #define ESR_ELx_ISV (UL(1) << ESR_ELx_ISV_SHIFT) Importantly, it avoids the ESR_ELx_FSC_FAULT_LN1 horror, and allows ESR_ELx_FSC_FAULT_L(-1) to be written. M. -- Without deviation from the norm, progress is not possible.