From patchwork Tue Jul 2 16:35:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13720070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 936E5C3065C for ; Tue, 2 Jul 2024 16:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=d2PdP7fwhovm4zuFbTsGS+kYSr4P/6sfjgnZ9Yiz/Fk=; b=wAp7mVpa3VfP0IT+ls+Uo1hba/ 5zNJGJSJyAXgm86Xcc4DnUwdxXlJgTF+94mL5xQl6Ci2W+jwRMqhbOsFgz45z2F6JlmosK0B3w2/B hTqVpZXvvaDMgMfCNOt6pAuxVVwvA+vVb6qZ+40M15+cUIC/iEern6r3J2f5N1284M79I6V6cW9sW PUTehXEgQcPMkWKFaf/X1CcmERZuJwk77YzUshJSrmkZmlPO8nvu/HBWd7wgB8x3OS1YsGMAhCc29 J9TvJDASHobXYeiNyeRIpKY3DIgn51VN0Rek0bEdpmcnSQX+oTXYrR6vmJ3orjRvYntSOWkm30BGD +jMojhzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOgTt-00000007OSX-29Zc; Tue, 02 Jul 2024 16:35:49 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOgTR-00000007OIH-1o3O for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2024 16:35:22 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a7241b2fe79so487222666b.1 for ; Tue, 02 Jul 2024 09:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719938119; x=1720542919; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d2PdP7fwhovm4zuFbTsGS+kYSr4P/6sfjgnZ9Yiz/Fk=; b=M/lUKSEo2LObItUkRQ6RRK+tgHAcLL1u7OEnf7LelRavdssCjDH8de9jGwjxoqSoEQ 2O5ciJJQALSODvMK8xdkROuzf1LqJ88fUkwuaY8MF62KhXqRjpIIasQTUOMt+COuz0Rh X9Scn3LBZnF+brH8U3Q0w7FNtbzy6TpuYALgHIKgZ2TRmo631jwyJPul+X5wHlEFjbGA Fe0LSTLR+dkdri7oYk0NT/kGzWvgK+p3MIIGBy0kKY7hdRB4PPHW0S+d/ndUyCTdcPGd RLRa4aCzL3mbaJvZj7mmn9gcG3GXsnLbxO+sL1wdk/BsW2qviqubIysJvKKm1+PWIBi7 Xynw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719938119; x=1720542919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d2PdP7fwhovm4zuFbTsGS+kYSr4P/6sfjgnZ9Yiz/Fk=; b=LB1I/jCGHlfXoyAMxsuykBVOgfpNgDyyOFCTTi7vxsR3TsX6qJAzyWJwgY6KgdcdA4 2bSBQuxbzF1KWmnlEwbbVGN62RiorZWiUAruiQ6KyttiMVCSZc6O4H5FKe0XrQZYzVoK TmbyqCiWKomTxSnxZHGy1NUGCKFKzVo+ZGMS4WDspB00dzo47t/i58srpOrQvf7huvCB l6i4+DC9V1Q00s426BuZu4Mtbf7L7o+aIfesTagq8IPw3EocWY1hYTt+t4lPO5coA2BL 1+gXG4Stnk6uBTOXxf9pxxey69rV3AXGpuyMbG9LP8Fiat8ET40dSA0eirsXNW30xmpB 0Jsw== X-Forwarded-Encrypted: i=1; AJvYcCUOrN1fHL0xO70K3peFkFsXgqcYopZtdAH7ZwW1o0JqP9oqMqNaCskej4GhB0U57SJwhzSrIwFsJ6xTSsPuumD/jmENs3rhDk+c2pW0QaDcuYcRCOI= X-Gm-Message-State: AOJu0YzO/OKeyXgabCd0Y1z59Mr9yu136+67BCKYVuiqMQzYcacXA8cM 4kYFimx2VWGSsKuvi3zpslNuYPkdUFM7K3G5v01Owb1jvlj822ZXSmnVNecJZHQ= X-Google-Smtp-Source: AGHT+IFxmrxAj1VktUMByj7Xw6HSUJJNLn+Inx9C8W4+xXXqlzwq/OMRxn8bbZoKs8uozwXqJXHXKA== X-Received: by 2002:a17:906:db01:b0:a6f:4bf2:daa2 with SMTP id a640c23a62f3a-a751443c744mr799316366b.15.1719938117250; Tue, 02 Jul 2024 09:35:17 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab08cfccsm435948166b.148.2024.07.02.09.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 09:35:16 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CC8685F93D; Tue, 2 Jul 2024 17:35:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: pbonzini@redhat.com, drjones@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@arm.com, maz@kernel.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Anders Roxell , Andrew Jones , Alexandru Elisei , Eric Auger , kvmarm@lists.linux.dev (open list:ARM) Subject: [kvm-unit-tests PATCH v1 2/2] arm/mmu: widen the page size check to account for LPA2 Date: Tue, 2 Jul 2024 17:35:15 +0100 Message-Id: <20240702163515.1964784-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702163515.1964784-1-alex.bennee@linaro.org> References: <20240702163515.1964784-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240702_093521_492192_735D548C X-CRM114-Status: GOOD ( 13.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If FEAT_LPA2 is enabled there are different valid TGran values possible to indicate the granule is supported for 52 bit addressing. This will cause most tests to abort on QEMU's -cpu max with the error: lib/arm/mmu.c:216: assert failed: system_supports_granule(PAGE_SIZE): Unsupported translation granule 4096 Expand the test to tale this into account. Signed-off-by: Alex Bennée Cc: Anders Roxell --- lib/arm64/asm/processor.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h index 1c73ba32..4a213aec 100644 --- a/lib/arm64/asm/processor.h +++ b/lib/arm64/asm/processor.h @@ -110,31 +110,30 @@ static inline unsigned long get_id_aa64mmfr0_el1(void) #define ID_AA64MMFR0_TGRAN64_SHIFT 24 #define ID_AA64MMFR0_TGRAN16_SHIFT 20 -#define ID_AA64MMFR0_TGRAN4_SUPPORTED 0x0 -#define ID_AA64MMFR0_TGRAN64_SUPPORTED 0x0 -#define ID_AA64MMFR0_TGRAN16_SUPPORTED 0x1 +#define ID_AA64MMFR0_TGRAN4_OK 0x0 +#define ID_AA64MMFR0_TGRAN4_52_OK 0x1 +#define ID_AA64MMFR0_TGRAN64_OK 0x0 +#define ID_AA64MMFR0_TGRAN16_OK 0x1 +#define ID_AA64MMFR0_TGRAN16_52_OK 0x2 static inline bool system_supports_granule(size_t granule) { - u32 shift; u32 val; - u64 mmfr0; + u64 mmfr0 = get_id_aa64mmfr0_el1(); if (granule == SZ_4K) { - shift = ID_AA64MMFR0_TGRAN4_SHIFT; - val = ID_AA64MMFR0_TGRAN4_SUPPORTED; + val = ((mmfr0 >> ID_AA64MMFR0_TGRAN4_SHIFT) & 0xf); + return (val == ID_AA64MMFR0_TGRAN4_OK) || + (val == ID_AA64MMFR0_TGRAN4_52_OK); } else if (granule == SZ_16K) { - shift = ID_AA64MMFR0_TGRAN16_SHIFT; - val = ID_AA64MMFR0_TGRAN16_SUPPORTED; + val = ((mmfr0 >> ID_AA64MMFR0_TGRAN16_SHIFT) & 0xf); + return val == ID_AA64MMFR0_TGRAN16_OK; } else { assert(granule == SZ_64K); - shift = ID_AA64MMFR0_TGRAN64_SHIFT; - val = ID_AA64MMFR0_TGRAN64_SUPPORTED; + val = ((mmfr0 >> ID_AA64MMFR0_TGRAN64_SHIFT) & 0xf); + return (val == ID_AA64MMFR0_TGRAN64_OK) || + (val == ID_AA64MMFR0_TGRAN4_52_OK); } - - mmfr0 = get_id_aa64mmfr0_el1(); - - return ((mmfr0 >> shift) & 0xf) == val; } #endif /* !__ASSEMBLY__ */