Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp27819lqs; Thu, 13 Jun 2024 02:45:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAlU7VtJux4UnsQfREa6hMEVO2o8az0ohoIycHOLj0s65TSgEGaN0S1C5qTRNxiT8ZlbftXbgse8ImVlaKbiVHpZASNCSAKAEICA69iA== X-Google-Smtp-Source: AGHT+IFxD18o6aLk7xd5UDVVC+xmM4h/UAtj+hTXA8wtitp4c5aa96SXzf45M4hHidOW72exlxMn X-Received: by 2002:ac8:5781:0:b0:440:656a:4241 with SMTP id d75a77b69052e-4415ac75e6amr43160151cf.62.1718271958170; Thu, 13 Jun 2024 02:45:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718271958; cv=pass; d=google.com; s=arc-20160816; b=q672x5TsMNRmhSeS+dtqtgMeyErLHFR04knXdO7s6kzyr3Lw+jKvA0wMD/hpgrPFIK BjoTHo6BC974Y+FstEVjJ8N2x/vlzOE2z3F8BfepkAJypQ8qxFNw3c+N12nwb7xkzUaA xkrPaC3LLxdNoXb+0pJ1FlAS0o4dcr3yPVGelMb8SGi60NnttWD+9LP8+6beeYcpvf0r 3PqJ61fMBuLURJbblxrEOwWm02saaucl0X4vi3ijjrATbI7qjjXjFj56U3oNeGb6IdfE kdfbf5C6hJnwDCBtUDsjVSEvkvCO+OFO6GLU4YF4dNOefzy4GgAmgMJAkY3emtui4SKp sp0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=In0Zougz0wW3A2K9wsMBDeY7vG73Mat4r/0Mrhi7UqE=; fh=jn+ERyyyMYBGXX7aNbjmYUwPGCG1dtY2/dSbTDiyUTM=; b=uHolSDSIO90U22bPSNGZPliuYG1dwj8rIXLV/xJ2qEHfwnBwW66bnLTN2vfXnByeMW sJntVXpYlfR18hfIPulne/ef2uyUE2ytj5dhL7tjTD7F6BalwzejWHeuC6shsdEsUy6v kl9lLAT2kw7wlVDaEjNWp3EGnG6YZwgKM4yEYTzNa3bmorr9xlML8TOehf+RkufBHxaM RQdO1EbqHmrFWlCLLkA+uvCsaJH8Fv09zkW4yoSHN4vJB826tXqUZGYyfN2cC+Uqcn1T 34o3JXAGCCAaqaXEJ2oMfogIuuKLcAWRU/hbnMSgkRjuuMY3qkvUnA+9gf0Zq4N8b9dg 2dvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-212975-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-441f2fbaeb0si10481961cf.411.2024.06.13.02.45.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 02:45:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212975-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-212975-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E01C81C241E0 for ; Thu, 13 Jun 2024 09:45:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B6EE13C9DE; Thu, 13 Jun 2024 09:45:53 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5EDC283A12 for ; Thu, 13 Jun 2024 09:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718271952; cv=none; b=MALv9ZojgJAooSYd80HfILXoXuZRlw1aM+0gzkCukJ5r/gCvMvHvgI6YbrEhx/aGfj1orO67OB/iNAhEwhHXMG/rBPSPKXhXgex0n97BrpVcE+F6e5PtAG5aA0Y99hcKRrOZNu09rCQBHGL47asYmmFM2IifJJUJxY0nWMdGKkg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718271952; c=relaxed/simple; bh=SpDaa/PbNFuNoPtKhY62ianrBVgrywHyqQj33pLWZpA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=h9ekz80TXwVjZvuS/HnU2XSQjN4QEP+gI5m9V96m1l6D6vc7+4GbaEY8rtyIZxbBlMecAudaUsTXcasmVdGv1y+6X5oxIWmSk8KnHqE8kJ1Xguye/A3Fd1J3oMY5q6t44xNg/tEsaA/Xc0AR0sAxQWhpm84A9AImzWVUdiWWPwg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F2AD61063; Thu, 13 Jun 2024 02:46:13 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.44.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 871943F5A1; Thu, 13 Jun 2024 02:45:46 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, ryan.roberts@arm.com, Anshuman Khandual , Catalin Marinas , Will Deacon , Marc Zyngier , linux-kernel@vger.kernel.org Subject: [PATCH] arm64/mm: Drop ESR_ELx_FSC_TYPE Date: Thu, 13 Jun 2024 15:15:38 +0530 Message-Id: <20240613094538.3263536-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Cc: Catalin Marinas Cc: Will Deacon Cc: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This applies on 6.10-rc3 arch/arm64/include/asm/esr.h | 42 +++++++++++++++++++++++++++--------- arch/arm64/mm/fault.c | 4 ++-- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/arch/arm64/include/asm/esr.h b/arch/arm64/include/asm/esr.h index 7abf09df7033..8cc0311d3fba 100644 --- a/arch/arm64/include/asm/esr.h +++ b/arch/arm64/include/asm/esr.h @@ -109,14 +109,23 @@ /* Shared ISS fault status code(IFSC/DFSC) for Data/Instruction aborts */ #define ESR_ELx_FSC (0x3F) -#define ESR_ELx_FSC_TYPE (0x3C) #define ESR_ELx_FSC_LEVEL (0x03) #define ESR_ELx_FSC_EXTABT (0x10) #define ESR_ELx_FSC_MTE (0x11) #define ESR_ELx_FSC_SERROR (0x11) -#define ESR_ELx_FSC_ACCESS (0x08) -#define ESR_ELx_FSC_FAULT (0x04) -#define ESR_ELx_FSC_PERM (0x0C) +#define ESR_ELx_FSC_ACCESS_L0 (0x08) +#define ESR_ELx_FSC_ACCESS_L1 (0x09) +#define ESR_ELx_FSC_ACCESS_L2 (0x0A) +#define ESR_ELx_FSC_ACCESS_L3 (0x0B) +#define ESR_ELx_FSC_FAULT_LN1 (0x2B) +#define ESR_ELx_FSC_FAULT_L0 (0x04) +#define ESR_ELx_FSC_FAULT_L1 (0x05) +#define ESR_ELx_FSC_FAULT_L2 (0x06) +#define ESR_ELx_FSC_FAULT_L3 (0x07) +#define ESR_ELx_FSC_PERM_L0 (0x0C) +#define ESR_ELx_FSC_PERM_L1 (0x0D) +#define ESR_ELx_FSC_PERM_L2 (0x0E) +#define ESR_ELx_FSC_PERM_L3 (0x0F) #define ESR_ELx_FSC_SEA_TTW(n) (0x14 + (n)) #define ESR_ELx_FSC_SECC (0x18) #define ESR_ELx_FSC_SECC_TTW(n) (0x1c + (n)) @@ -388,20 +397,33 @@ static inline bool esr_is_data_abort(unsigned long esr) static inline bool esr_fsc_is_translation_fault(unsigned long esr) { - /* Translation fault, level -1 */ - if ((esr & ESR_ELx_FSC) == 0b101011) - return true; - return (esr & ESR_ELx_FSC_TYPE) == ESR_ELx_FSC_FAULT; + esr = esr & ESR_ELx_FSC; + + return (esr == ESR_ELx_FSC_FAULT_L3) || + (esr == ESR_ELx_FSC_FAULT_L2) || + (esr == ESR_ELx_FSC_FAULT_L1) || + (esr == ESR_ELx_FSC_FAULT_L0) || + (esr == ESR_ELx_FSC_FAULT_LN1); } static inline bool esr_fsc_is_permission_fault(unsigned long esr) { - return (esr & ESR_ELx_FSC_TYPE) == ESR_ELx_FSC_PERM; + esr = esr & ESR_ELx_FSC; + + return (esr == ESR_ELx_FSC_PERM_L3) || + (esr == ESR_ELx_FSC_PERM_L2) || + (esr == ESR_ELx_FSC_PERM_L1) || + (esr == ESR_ELx_FSC_PERM_L0); } static inline bool esr_fsc_is_access_flag_fault(unsigned long esr) { - return (esr & ESR_ELx_FSC_TYPE) == ESR_ELx_FSC_ACCESS; + esr = esr & ESR_ELx_FSC; + + return (esr == ESR_ELx_FSC_ACCESS_L3) || + (esr == ESR_ELx_FSC_ACCESS_L2) || + (esr == ESR_ELx_FSC_ACCESS_L1) || + (esr == ESR_ELx_FSC_ACCESS_L0); } /* Indicate whether ESR.EC==0x1A is for an ERETAx instruction */ diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 451ba7cbd5ad..7199aaff2a29 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -440,7 +440,7 @@ static void set_thread_esr(unsigned long address, unsigned long esr) */ esr &= ESR_ELx_EC_MASK | ESR_ELx_IL | ESR_ELx_CM | ESR_ELx_WNR; - esr |= ESR_ELx_FSC_FAULT; + esr |= ESR_ELx_FSC_FAULT_L0; break; case ESR_ELx_EC_IABT_LOW: /* @@ -449,7 +449,7 @@ static void set_thread_esr(unsigned long address, unsigned long esr) * reported with that DFSC value, so we clear them. */ esr &= ESR_ELx_EC_MASK | ESR_ELx_IL; - esr |= ESR_ELx_FSC_FAULT; + esr |= ESR_ELx_FSC_FAULT_L0; break; default: /* -- 2.30.2