Message ID | 20240219135805.1c4138a3@canb.auug.org.au |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-70667-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1052029dyc; Sun, 18 Feb 2024 18:58:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUDVfQ3pkFgpgAu2XWv0pH7GdVyfuD1Bb0gXR4+ptvE1A5mcaq26+NeLr7am8jrLbkzyDhD0wOcivWxE/pmEtFNupOCZQ== X-Google-Smtp-Source: AGHT+IGK0OWLHxzB+RbMcOBIDGRInPFD+dJRMtFQRV3JzUxh04nfjwn9nRFlzStamPCB1DFQT512 X-Received: by 2002:ac2:4c41:0:b0:512:b4cf:ae3 with SMTP id o1-20020ac24c41000000b00512b4cf0ae3mr558940lfk.19.1708311510197; Sun, 18 Feb 2024 18:58:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708311510; cv=pass; d=google.com; s=arc-20160816; b=AUXzVeEK7w2GmKyzMVtkzP7WKB3tMcUUA8mvdplvYcaJ6LGajbZg1YSJ2IdLRvSRm6 n5U5g4yrPrwPkyiQBLmUs1ezPXNfYPiFZErInEpS917z+BZq795u2QxhpUtGAKP8Gqg7 0ZqvJsX4zxh1mT5kht5d0LKgXXakcHOjvjaBKfHl7CwGOm9YQkMkvYg0j1o1bUbkh5oN 6EhEG26B0hxocblfCrIvox0f3bMWGiS1FYVm9dbI0lHFpdOV1QoeZojojrg92tK0NF6e Y7nSa8mv6iJmG9IprpVYX1/fTMwsaXaLBoi5yMwse1MepiYTyRf2kmURorCzZLD3HolI /KHQ== 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 :message-id:subject:cc:to:from:date:dkim-signature; bh=7XaKWVD9KB3AwSX0RxGYmJEUX1mxEDnJZN5p2hnu4+o=; fh=puOr4SAqW6yfL6m7uFuw/13vQy0j76aqHRhyDXhr3OM=; b=fRdJbdBgNWtdWQOt8pj+Gtiv7ad/P7UmmJJjvBNPwjN59amXAtCpnZgtxnqWL5DJ0H ofv6sGERi1NLnZQqpStx/6yqp+D46g4CrRTSpCwdAYB5ZbTqpNB9AxJHUQL5PHUJhkuW HzSNWk+PFvIxYwBq0FVZk6/citZGHQItfyrx7atP933/hKxaPiT1LdxF6Ain9x13gQ6e sWcSJXg2fCPTKL2W9aj8/vjBoD9x7mpTgm+4ZJh0QZtzXgJ2OEoz7GyRrwkalKXAmpJC PFw+7l8WfqRKP52wwrdY19d2ER/hLf6EnUKtCY5o2gsvPe8Dx5F4Jzy8jrApoRFHmY8l 2Y7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@canb.auug.org.au header.s=201702 header.b=tirE7gwQ; arc=pass (i=1 spf=pass spfdomain=canb.auug.org.au dkim=pass dkdomain=canb.auug.org.au dmarc=pass fromdomain=canb.auug.org.au); spf=pass (google.com: domain of linux-kernel+bounces-70667-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70667-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canb.auug.org.au Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ht21-20020a170907609500b00a3e77af9118si852153ejc.194.2024.02.18.18.58.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 18:58:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70667-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@canb.auug.org.au header.s=201702 header.b=tirE7gwQ; arc=pass (i=1 spf=pass spfdomain=canb.auug.org.au dkim=pass dkdomain=canb.auug.org.au dmarc=pass fromdomain=canb.auug.org.au); spf=pass (google.com: domain of linux-kernel+bounces-70667-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70667-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canb.auug.org.au 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 C7FE61F21734 for <ouuuleilei@gmail.com>; Mon, 19 Feb 2024 02:58:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E087443F; Mon, 19 Feb 2024 02:58:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canb.auug.org.au header.i=@canb.auug.org.au header.b="tirE7gwQ" Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (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 1A8BB1FC8; Mon, 19 Feb 2024 02:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=150.107.74.76 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708311493; cv=none; b=MW3ZY9eA4I5SCIzmCIB5Zky5+LlV1adP9IRtqSNVNDIpb+ZDZrMjYcUnPxo6yJTW1+MDvCme1QFGjn6/ec/vNvxoGjX3noLLYq6EDaaf8pvCkFgFECjMoFb9eD9tnZyumWRHCMnF4Re37PHLMV6Ehixx9pOefZRB2Vk3y5CQW7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708311493; c=relaxed/simple; bh=gctggYPLGlntgRouCIS1Y5xS9wy4M1dICUmfSMUaA2g=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=VUdRpB3+kBR4sPJZ0/TJKQniuevH6zkE/dSzj26apPVGudwUaimCP+/sR+pK+euUAQbx1WQuudd2HecO7PLtnmrOFWDuWVP6maMLG7P5sBohVZijs19BSW5MSOxlhLEhRVI8opf3Olpg/FhSNgkGJfZDT+2ZfUTeOjvJ5OTOViM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canb.auug.org.au; spf=pass smtp.mailfrom=canb.auug.org.au; dkim=pass (2048-bit key) header.d=canb.auug.org.au header.i=@canb.auug.org.au header.b=tirE7gwQ; arc=none smtp.client-ip=150.107.74.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canb.auug.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canb.auug.org.au DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canb.auug.org.au; s=201702; t=1708311488; bh=7XaKWVD9KB3AwSX0RxGYmJEUX1mxEDnJZN5p2hnu4+o=; h=Date:From:To:Cc:Subject:From; b=tirE7gwQkigdBfOiXJLEWoOdlMv7xicMQ+bb8KwBI0l75izAOwmj+ROEHmIl/ZKdE hqlrvppMFDuW4rCs5n+diq7qeGSS5nyfTnXfaWoYgMxcNP8NHtklGzy8TgftO41Kxz GmKWlt82Uah4fykXuWZnuAbHPHm4zad8eXEkl4irt4d8KzzYBUZAlcljnEdDBKrFZH 7vFI1hyIlGaSeaHZwtUXZejUlA5uHfb+b02iyDUI1i2YKSxR4ZqWQFMN3ZRt1WN2Dv 4pnT030y9o2LJS1YKqltYqSCwv03x+mXrfXwl93nnRsB5mLtOPTnKWWRiRUKdVVqmH k0CuP4d9znDXw== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4TdRzz2BrNz4wcK; Mon, 19 Feb 2024 13:58:06 +1100 (AEDT) Date: Mon, 19 Feb 2024 13:58:05 +1100 From: Stephen Rothwell <sfr@canb.auug.org.au> To: Christoffer Dall <cdall@cs.columbia.edu>, Marc Zyngier <maz@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org> Cc: Ard Biesheuvel <ardb@kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, Linux Next Mailing List <linux-next@vger.kernel.org>, Oliver Upton <oliver.upton@linux.dev> Subject: linux-next: manual merge of the kvm-arm tree with the arm64 tree Message-ID: <20240219135805.1c4138a3@canb.auug.org.au> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/0lq+TnyNw/r+bgBwPDvE7v7"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791294450283205485 X-GMAIL-MSGID: 1791294450283205485 |
Series |
linux-next: manual merge of the kvm-arm tree with the arm64 tree
|
|
Commit Message
Stephen Rothwell
Feb. 19, 2024, 2:58 a.m. UTC
Hi all, Today's linux-next merge of the kvm-arm tree got a conflict in: arch/arm64/kernel/cpufeature.c between commits: 9cce9c6c2c3b ("arm64: mm: Handle LVA support as a CPU feature") 352b0395b505 ("arm64: Enable 52-bit virtual addressing for 4k and 16k granule configs") from the arm64 tree and commit: da9af5071b25 ("arm64: cpufeature: Detect HCR_EL2.NV1 being RES0") from the kvm-arm tree. I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.
Comments
On Mon, Feb 19, 2024 at 01:58:05PM +1100, Stephen Rothwell wrote: > diff --cc arch/arm64/kernel/cpufeature.c > index 0be9296e9253,f309fd542c20..000000000000 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@@ -721,13 -754,12 +756,14 @@@ static const struct __ftr_reg_entry > &id_aa64isar2_override), > > /* Op1 = 0, CRn = 0, CRm = 7 */ > - ARM64_FTR_REG(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0), > + ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0, > + &id_aa64mmfr0_override), > ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR1_EL1, ftr_id_aa64mmfr1, > &id_aa64mmfr1_override), > - ARM64_FTR_REG(SYS_ID_AA64MMFR2_EL1, ftr_id_aa64mmfr2), > + ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR2_EL1, ftr_id_aa64mmfr2, > + &id_aa64mmfr2_override), > ARM64_FTR_REG(SYS_ID_AA64MMFR3_EL1, ftr_id_aa64mmfr3), > + ARM64_FTR_REG(SYS_ID_AA64MMFR4_EL1, ftr_id_aa64mmfr4), > > /* Op1 = 1, CRn = 0, CRm = 0 */ > ARM64_FTR_REG(SYS_GMID_EL1, ftr_gmid), > @@@ -2701,33 -2817,13 +2779,40 @@@ static const struct arm64_cpu_capabilit > .type = ARM64_CPUCAP_SYSTEM_FEATURE, > .matches = has_lpa2, > }, > +#ifdef CONFIG_ARM64_VA_BITS_52 > + { > + .capability = ARM64_HAS_VA52, > + .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, > + .matches = has_cpuid_feature, > + .field_width = 4, > +#ifdef CONFIG_ARM64_64K_PAGES > + .desc = "52-bit Virtual Addressing (LVA)", > + .sign = FTR_SIGNED, > + .sys_reg = SYS_ID_AA64MMFR2_EL1, > + .field_pos = ID_AA64MMFR2_EL1_VARange_SHIFT, > + .min_field_value = ID_AA64MMFR2_EL1_VARange_52, > +#else > + .desc = "52-bit Virtual Addressing (LPA2)", > + .sys_reg = SYS_ID_AA64MMFR0_EL1, > +#ifdef CONFIG_ARM64_4K_PAGES > + .sign = FTR_SIGNED, > + .field_pos = ID_AA64MMFR0_EL1_TGRAN4_SHIFT, > + .min_field_value = ID_AA64MMFR0_EL1_TGRAN4_52_BIT, > +#else > + .sign = FTR_UNSIGNED, > + .field_pos = ID_AA64MMFR0_EL1_TGRAN16_SHIFT, > + .min_field_value = ID_AA64MMFR0_EL1_TGRAN16_52_BIT, > +#endif > +#endif > + }, > +#endif > + { > + .desc = "NV1", > + .capability = ARM64_HAS_HCR_NV1, > + .type = ARM64_CPUCAP_SYSTEM_FEATURE, > + .matches = has_nv1, > + ARM64_CPUID_FIELDS_NEG(ID_AA64MMFR4_EL1, E2H0, NI_NV1) > + }, > {}, > }; Thanks Stephen. It looks fine.
On Mon, 19 Feb 2024 12:14:18 +0000, Catalin Marinas <catalin.marinas@arm.com> wrote: > > On Mon, Feb 19, 2024 at 01:58:05PM +1100, Stephen Rothwell wrote: > > diff --cc arch/arm64/kernel/cpufeature.c > > index 0be9296e9253,f309fd542c20..000000000000 > > --- a/arch/arm64/kernel/cpufeature.c > > +++ b/arch/arm64/kernel/cpufeature.c > > @@@ -721,13 -754,12 +756,14 @@@ static const struct __ftr_reg_entry > > &id_aa64isar2_override), > > > > /* Op1 = 0, CRn = 0, CRm = 7 */ > > - ARM64_FTR_REG(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0), > > + ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0, > > + &id_aa64mmfr0_override), > > ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR1_EL1, ftr_id_aa64mmfr1, > > &id_aa64mmfr1_override), > > - ARM64_FTR_REG(SYS_ID_AA64MMFR2_EL1, ftr_id_aa64mmfr2), > > + ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR2_EL1, ftr_id_aa64mmfr2, > > + &id_aa64mmfr2_override), > > ARM64_FTR_REG(SYS_ID_AA64MMFR3_EL1, ftr_id_aa64mmfr3), > > + ARM64_FTR_REG(SYS_ID_AA64MMFR4_EL1, ftr_id_aa64mmfr4), > > > > /* Op1 = 1, CRn = 0, CRm = 0 */ > > ARM64_FTR_REG(SYS_GMID_EL1, ftr_gmid), > > @@@ -2701,33 -2817,13 +2779,40 @@@ static const struct arm64_cpu_capabilit > > .type = ARM64_CPUCAP_SYSTEM_FEATURE, > > .matches = has_lpa2, > > }, > > +#ifdef CONFIG_ARM64_VA_BITS_52 > > + { > > + .capability = ARM64_HAS_VA52, > > + .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, > > + .matches = has_cpuid_feature, > > + .field_width = 4, > > +#ifdef CONFIG_ARM64_64K_PAGES > > + .desc = "52-bit Virtual Addressing (LVA)", > > + .sign = FTR_SIGNED, > > + .sys_reg = SYS_ID_AA64MMFR2_EL1, > > + .field_pos = ID_AA64MMFR2_EL1_VARange_SHIFT, > > + .min_field_value = ID_AA64MMFR2_EL1_VARange_52, > > +#else > > + .desc = "52-bit Virtual Addressing (LPA2)", > > + .sys_reg = SYS_ID_AA64MMFR0_EL1, > > +#ifdef CONFIG_ARM64_4K_PAGES > > + .sign = FTR_SIGNED, > > + .field_pos = ID_AA64MMFR0_EL1_TGRAN4_SHIFT, > > + .min_field_value = ID_AA64MMFR0_EL1_TGRAN4_52_BIT, > > +#else > > + .sign = FTR_UNSIGNED, > > + .field_pos = ID_AA64MMFR0_EL1_TGRAN16_SHIFT, > > + .min_field_value = ID_AA64MMFR0_EL1_TGRAN16_52_BIT, > > +#endif > > +#endif > > + }, > > +#endif > > + { > > + .desc = "NV1", > > + .capability = ARM64_HAS_HCR_NV1, > > + .type = ARM64_CPUCAP_SYSTEM_FEATURE, > > + .matches = has_nv1, > > + ARM64_CPUID_FIELDS_NEG(ID_AA64MMFR4_EL1, E2H0, NI_NV1) > > + }, > > {}, > > }; > > Thanks Stephen. It looks fine. Actually, it breaks 52bit support in a "subtle" way (multiple reports on the list and IRC, all pointing to failures on QEMU). The KVM tree adds support for feature ranges, which this code is totally unaware of, and only provides the min value and not the max. Things go wrong from there. I propose to fix it like below, which makes it robust against the KVM changes (patch applies to arm64/for-next/core). I have tested it in combination with kvmarm/next, with 4kB and 16kB (LVA2), as well as 64kB (LVA). Thanks, M. From f24638a5f41424faf47f3d9035e6dcbd3800fcb6 Mon Sep 17 00:00:00 2001 From: Marc Zyngier <maz@kernel.org> Date: Mon, 19 Feb 2024 15:13:22 +0000 Subject: [PATCH] arm64: Use Signed/Unsigned enums for TGRAN{4,16,64} and VARange Open-coding the feature matching parameters for LVA/LVA2 leads to issues with upcoming changes to the cpufeature code. By making TGRAN{4,16,64} and VARange signed/unsigned as per the architecture, we can use the existing macros, making the feature match robust against those changes. Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/kernel/cpufeature.c | 15 +++------------ arch/arm64/tools/sysreg | 8 ++++---- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 8f9665e8774b..2119e9dd0c4e 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -2791,24 +2791,15 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .capability = ARM64_HAS_VA52, .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, .matches = has_cpuid_feature, - .field_width = 4, #ifdef CONFIG_ARM64_64K_PAGES .desc = "52-bit Virtual Addressing (LVA)", - .sign = FTR_SIGNED, - .sys_reg = SYS_ID_AA64MMFR2_EL1, - .field_pos = ID_AA64MMFR2_EL1_VARange_SHIFT, - .min_field_value = ID_AA64MMFR2_EL1_VARange_52, + ARM64_CPUID_FIELDS(ID_AA64MMFR2_EL1, VARange, 52) #else .desc = "52-bit Virtual Addressing (LPA2)", - .sys_reg = SYS_ID_AA64MMFR0_EL1, #ifdef CONFIG_ARM64_4K_PAGES - .sign = FTR_SIGNED, - .field_pos = ID_AA64MMFR0_EL1_TGRAN4_SHIFT, - .min_field_value = ID_AA64MMFR0_EL1_TGRAN4_52_BIT, + ARM64_CPUID_FIELDS(ID_AA64MMFR0_EL1, TGRAN4, 52_BIT) #else - .sign = FTR_UNSIGNED, - .field_pos = ID_AA64MMFR0_EL1_TGRAN16_SHIFT, - .min_field_value = ID_AA64MMFR0_EL1_TGRAN16_52_BIT, + ARM64_CPUID_FIELDS(ID_AA64MMFR0_EL1, TGRAN16, 52_BIT) #endif #endif }, diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index fa3fe0856880..670a33fca3bc 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -1540,16 +1540,16 @@ Enum 35:32 TGRAN16_2 0b0010 IMP 0b0011 52_BIT EndEnum -Enum 31:28 TGRAN4 +SignedEnum 31:28 TGRAN4 0b0000 IMP 0b0001 52_BIT 0b1111 NI EndEnum -Enum 27:24 TGRAN64 +SignedEnum 27:24 TGRAN64 0b0000 IMP 0b1111 NI EndEnum -Enum 23:20 TGRAN16 +UnsignedEnum 23:20 TGRAN16 0b0000 NI 0b0001 IMP 0b0010 52_BIT @@ -1697,7 +1697,7 @@ Enum 23:20 CCIDX 0b0000 32 0b0001 64 EndEnum -Enum 19:16 VARange +UnsignedEnum 19:16 VARange 0b0000 48 0b0001 52 EndEnum
On Mon, Feb 19, 2024 at 03:22:14PM +0000, Marc Zyngier wrote: > From f24638a5f41424faf47f3d9035e6dcbd3800fcb6 Mon Sep 17 00:00:00 2001 > From: Marc Zyngier <maz@kernel.org> > Date: Mon, 19 Feb 2024 15:13:22 +0000 > Subject: [PATCH] arm64: Use Signed/Unsigned enums for TGRAN{4,16,64} and > VARange > > Open-coding the feature matching parameters for LVA/LVA2 leads to > issues with upcoming changes to the cpufeature code. > > By making TGRAN{4,16,64} and VARange signed/unsigned as per the > architecture, we can use the existing macros, making the feature > match robust against those changes. > > Signed-off-by: Marc Zyngier <maz@kernel.org> I think this is the right thing to do; the patch itself looks good to me, so FWIW: Acked-by: Mark Rutland <mark.rutland@arm.com> Mark. > --- > arch/arm64/kernel/cpufeature.c | 15 +++------------ > arch/arm64/tools/sysreg | 8 ++++---- > 2 files changed, 7 insertions(+), 16 deletions(-) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 8f9665e8774b..2119e9dd0c4e 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -2791,24 +2791,15 @@ static const struct arm64_cpu_capabilities arm64_features[] = { > .capability = ARM64_HAS_VA52, > .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, > .matches = has_cpuid_feature, > - .field_width = 4, > #ifdef CONFIG_ARM64_64K_PAGES > .desc = "52-bit Virtual Addressing (LVA)", > - .sign = FTR_SIGNED, > - .sys_reg = SYS_ID_AA64MMFR2_EL1, > - .field_pos = ID_AA64MMFR2_EL1_VARange_SHIFT, > - .min_field_value = ID_AA64MMFR2_EL1_VARange_52, > + ARM64_CPUID_FIELDS(ID_AA64MMFR2_EL1, VARange, 52) > #else > .desc = "52-bit Virtual Addressing (LPA2)", > - .sys_reg = SYS_ID_AA64MMFR0_EL1, > #ifdef CONFIG_ARM64_4K_PAGES > - .sign = FTR_SIGNED, > - .field_pos = ID_AA64MMFR0_EL1_TGRAN4_SHIFT, > - .min_field_value = ID_AA64MMFR0_EL1_TGRAN4_52_BIT, > + ARM64_CPUID_FIELDS(ID_AA64MMFR0_EL1, TGRAN4, 52_BIT) > #else > - .sign = FTR_UNSIGNED, > - .field_pos = ID_AA64MMFR0_EL1_TGRAN16_SHIFT, > - .min_field_value = ID_AA64MMFR0_EL1_TGRAN16_52_BIT, > + ARM64_CPUID_FIELDS(ID_AA64MMFR0_EL1, TGRAN16, 52_BIT) > #endif > #endif > }, > diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg > index fa3fe0856880..670a33fca3bc 100644 > --- a/arch/arm64/tools/sysreg > +++ b/arch/arm64/tools/sysreg > @@ -1540,16 +1540,16 @@ Enum 35:32 TGRAN16_2 > 0b0010 IMP > 0b0011 52_BIT > EndEnum > -Enum 31:28 TGRAN4 > +SignedEnum 31:28 TGRAN4 > 0b0000 IMP > 0b0001 52_BIT > 0b1111 NI > EndEnum > -Enum 27:24 TGRAN64 > +SignedEnum 27:24 TGRAN64 > 0b0000 IMP > 0b1111 NI > EndEnum > -Enum 23:20 TGRAN16 > +UnsignedEnum 23:20 TGRAN16 > 0b0000 NI > 0b0001 IMP > 0b0010 52_BIT > @@ -1697,7 +1697,7 @@ Enum 23:20 CCIDX > 0b0000 32 > 0b0001 64 > EndEnum > -Enum 19:16 VARange > +UnsignedEnum 19:16 VARange > 0b0000 48 > 0b0001 52 > EndEnum > -- > 2.39.2 > > > -- > Without deviation from the norm, progress is not possible.
On Mon, 19 Feb 2024 at 16:22, Marc Zyngier <maz@kernel.org> wrote: > > On Mon, 19 Feb 2024 12:14:18 +0000, > Catalin Marinas <catalin.marinas@arm.com> wrote: > > > > On Mon, Feb 19, 2024 at 01:58:05PM +1100, Stephen Rothwell wrote: > > > diff --cc arch/arm64/kernel/cpufeature.c > > > index 0be9296e9253,f309fd542c20..000000000000 > > > --- a/arch/arm64/kernel/cpufeature.c > > > +++ b/arch/arm64/kernel/cpufeature.c > > > @@@ -721,13 -754,12 +756,14 @@@ static const struct __ftr_reg_entry > > > &id_aa64isar2_override), > > > > > > /* Op1 = 0, CRn = 0, CRm = 7 */ > > > - ARM64_FTR_REG(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0), > > > + ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0, > > > + &id_aa64mmfr0_override), > > > ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR1_EL1, ftr_id_aa64mmfr1, > > > &id_aa64mmfr1_override), > > > - ARM64_FTR_REG(SYS_ID_AA64MMFR2_EL1, ftr_id_aa64mmfr2), > > > + ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR2_EL1, ftr_id_aa64mmfr2, > > > + &id_aa64mmfr2_override), > > > ARM64_FTR_REG(SYS_ID_AA64MMFR3_EL1, ftr_id_aa64mmfr3), > > > + ARM64_FTR_REG(SYS_ID_AA64MMFR4_EL1, ftr_id_aa64mmfr4), > > > > > > /* Op1 = 1, CRn = 0, CRm = 0 */ > > > ARM64_FTR_REG(SYS_GMID_EL1, ftr_gmid), > > > @@@ -2701,33 -2817,13 +2779,40 @@@ static const struct arm64_cpu_capabilit > > > .type = ARM64_CPUCAP_SYSTEM_FEATURE, > > > .matches = has_lpa2, > > > }, > > > +#ifdef CONFIG_ARM64_VA_BITS_52 > > > + { > > > + .capability = ARM64_HAS_VA52, > > > + .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, > > > + .matches = has_cpuid_feature, > > > + .field_width = 4, > > > +#ifdef CONFIG_ARM64_64K_PAGES > > > + .desc = "52-bit Virtual Addressing (LVA)", > > > + .sign = FTR_SIGNED, > > > + .sys_reg = SYS_ID_AA64MMFR2_EL1, > > > + .field_pos = ID_AA64MMFR2_EL1_VARange_SHIFT, > > > + .min_field_value = ID_AA64MMFR2_EL1_VARange_52, > > > +#else > > > + .desc = "52-bit Virtual Addressing (LPA2)", > > > + .sys_reg = SYS_ID_AA64MMFR0_EL1, > > > +#ifdef CONFIG_ARM64_4K_PAGES > > > + .sign = FTR_SIGNED, > > > + .field_pos = ID_AA64MMFR0_EL1_TGRAN4_SHIFT, > > > + .min_field_value = ID_AA64MMFR0_EL1_TGRAN4_52_BIT, > > > +#else > > > + .sign = FTR_UNSIGNED, > > > + .field_pos = ID_AA64MMFR0_EL1_TGRAN16_SHIFT, > > > + .min_field_value = ID_AA64MMFR0_EL1_TGRAN16_52_BIT, > > > +#endif > > > +#endif > > > + }, > > > +#endif > > > + { > > > + .desc = "NV1", > > > + .capability = ARM64_HAS_HCR_NV1, > > > + .type = ARM64_CPUCAP_SYSTEM_FEATURE, > > > + .matches = has_nv1, > > > + ARM64_CPUID_FIELDS_NEG(ID_AA64MMFR4_EL1, E2H0, NI_NV1) > > > + }, > > > {}, > > > }; > > > > Thanks Stephen. It looks fine. > > Actually, it breaks 52bit support in a "subtle" way (multiple reports > on the list and IRC, all pointing to failures on QEMU). The KVM tree > adds support for feature ranges, which this code is totally unaware > of, and only provides the min value and not the max. Things go wrong > from there. > > I propose to fix it like below, which makes it robust against the KVM > changes (patch applies to arm64/for-next/core). I have tested it in > combination with kvmarm/next, with 4kB and 16kB (LVA2), as well as > 64kB (LVA). > > Thanks, > > M. > > From f24638a5f41424faf47f3d9035e6dcbd3800fcb6 Mon Sep 17 00:00:00 2001 > From: Marc Zyngier <maz@kernel.org> > Date: Mon, 19 Feb 2024 15:13:22 +0000 > Subject: [PATCH] arm64: Use Signed/Unsigned enums for TGRAN{4,16,64} and > VARange > > Open-coding the feature matching parameters for LVA/LVA2 leads to > issues with upcoming changes to the cpufeature code. > > By making TGRAN{4,16,64} and VARange signed/unsigned as per the > architecture, we can use the existing macros, making the feature > match robust against those changes. > > Signed-off-by: Marc Zyngier <maz@kernel.org> Thanks for the fix. Acked-by: Ard Biesheuvel <ardb@kernel.org> Tested-by: Ard Biesheuvel <ardb@kernel.org>
On Mon, Feb 19, 2024 at 03:22:14PM +0000, Marc Zyngier wrote: > From f24638a5f41424faf47f3d9035e6dcbd3800fcb6 Mon Sep 17 00:00:00 2001 > From: Marc Zyngier <maz@kernel.org> > Date: Mon, 19 Feb 2024 15:13:22 +0000 > Subject: [PATCH] arm64: Use Signed/Unsigned enums for TGRAN{4,16,64} and > VARange > > Open-coding the feature matching parameters for LVA/LVA2 leads to > issues with upcoming changes to the cpufeature code. > > By making TGRAN{4,16,64} and VARange signed/unsigned as per the > architecture, we can use the existing macros, making the feature > match robust against those changes. > > Signed-off-by: Marc Zyngier <maz@kernel.org> Thanks Marc. I applied it on top of the arm64 for-next/stage1-lpa2 branch.
diff --cc arch/arm64/kernel/cpufeature.c index 0be9296e9253,f309fd542c20..000000000000 --- a/arch/arm64/kernel/cpufeature.c