Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1215867rdb; Mon, 19 Feb 2024 07:53:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUcigGv/Cc+H4x1GQY7gXECL2IUn+B9+/wH0dNPHWKXVJgMzNkJ6LK3fIoYant4ViJnB/W/vumioADZGWHf5VbHvWhfFs0bW+Lo+AhJ5Q== X-Google-Smtp-Source: AGHT+IG/rpQxTFntC0dOlQ0duuo/WMA08UfYzLx82BqWEYvBT+oyZ1hquCz52zIgqAT/SgzIFgjo X-Received: by 2002:a17:90a:4385:b0:299:51d3:7f6c with SMTP id r5-20020a17090a438500b0029951d37f6cmr4178067pjg.27.1708357991811; Mon, 19 Feb 2024 07:53:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708357991; cv=pass; d=google.com; s=arc-20160816; b=cXu/Uvb7dpgs4nb5M7P5P4NU32MOJyxeOPWZVhyjZJnFZYKMohbRbWbNP7jZ00/ykC LUkUMe//w024ydbNmKPnecyHJKZJx1rexVkZyszKiMadg8/BtAdjZvCejNcHlH6fmI1p AWdDi3JBe2mjoRWzHPPMsVRsR/KLh9wDBePTAst7aC1/GmKegnqi1GhUXKr0sYLZq4Hs lMNUHlOvSW+QcuP6VjnA0pvJcMxRtx5WdyzsJ1qxdC1MTKUsjh8/4Cm6Olq12fmvJ19E WyAKcmB5spuRzHGJCBL8qQe/ST6eVR6SrBx1kwoLPHo5woSOZMFibNwhoqkt1G6AKqED 4Wpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=36f1Xa2yDlJehdmcwvGpGMawUJyZInllaieSS0I6SjQ=; fh=QuLtuxP8s/6LbPp7ejXFubEGRqSLnUqtqV2muqo4CZw=; b=rBLLcHGvHboXgnKn8zXdxkHI9lpUm94DrcDyM57FFP/DVCTGwK0iQ1MR+Mun5KUdHy LOFt1hss5D/pPxNWU2jW1w0r/+EJRGKxpCf3VfzwaaEMgVJZTTyEq1tSQuSYdrAbPcxg cZ7q7B8Dhb07j9rNKAonB5mZlEpzVMUffK0YKsJb6g81ioDtpr9lXEnzby7Sy2s4nuuU k2aUbwFZuG8dqvCEfOrsGaulAh09pTAA/BaQDiq020jhb8ftCw/YMVJos+nUqLGCbapY HVVHfmPO+/bmy5txuEy4iTHQXwscJWSgmeGEISiqfXvERyHANpSCW9W8Du+i8k8k3ClK wdPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PHDsck8i; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71609-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71609-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i8-20020a17090a974800b002997a4298e2si3051955pjw.140.2024.02.19.07.53.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 07:53:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71609-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PHDsck8i; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71609-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71609-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3FA75B24C10 for ; Mon, 19 Feb 2024 15:44:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6073F3A1CC; Mon, 19 Feb 2024 15:43:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PHDsck8i" 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 7584439840; Mon, 19 Feb 2024 15:43:58 +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=1708357438; cv=none; b=AqsJG0y5lcUqWXLE2N9+ymS0m9kJCI6qEA3ohuU9cL2p4iM3Z7ZOC6a8jDcToquzphLoK9lAqGK//J9qFD82/4VG4icuK/hNR2CUgFDrzFrsCxVye3FqO2fS6BkQwXaWpchqsP7kMJc6HqJh8pJ9+dL3pWBf9TTL8GKUs0npl24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708357438; c=relaxed/simple; bh=Bohw/bQPmhHQbLkJwGb3KJCaLF1Qkwt6GeyegCF9liw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=bX0W7R6SdRCwf9YG83Dt4KV00wtQKHki2FPKWFPJo0bq6lrvxQ7Ws1R4Xy2wrOVmsd74w5MkvPRHEiCWQ/9IMG0YCD5noUOS5qQvTYB9QTnx34pZFBChHJmUmyjq64AZZlyeQgR1uXOM6YrIWqRB3R+cl4Qb7dDjDLV0BWKRiUY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PHDsck8i; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4BD7C43399; Mon, 19 Feb 2024 15:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708357437; bh=Bohw/bQPmhHQbLkJwGb3KJCaLF1Qkwt6GeyegCF9liw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=PHDsck8ig8UVnrcvTAdSJFp8/p7ksYDXvn4bgh61MVPcjWXGrOtRApdk+LepchXTX crE2kKhzja1AsBjOqV/DhkUNAyhreeSdwid8Zb+FZoiT7fPRMsPOTgnL8xGoWtkktw 1TBu37eGh/CCRzZS2kXxI5eOaghFtWuPQYuaqoHAb36L7vuK9jI+dPxq1Eksyu6XaO QDR46mJ1JdTFTtz6lImKbIypKVAXiP+P47+RBFT0NZPmxKzBTHlYR4kniicQMCsAZA qVTtTjm4vjuq8fh7p+AogP8twmWjOgHNtSFiQZ1knm+q2PiO3VRkdeS8BuXHSxorSA nkVVzVuQNQP3g== Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-512bde3d197so645483e87.0; Mon, 19 Feb 2024 07:43:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXFX+dcuCN3ssQtjuEtNx0+ta6j2xyVEZIWLgNx1+HvtUck2trV+WIbGYWhOPGAu2/cLwZyaDeOQNhg+s/7m+JEO6kxWpOcxBKmcqYWglhQiXuVXRStrSjwlpIOp5i7RxC3lBAxG2zjFQ== X-Gm-Message-State: AOJu0YzdAa9RzEoOgjswme2fdc4kmFBcDMfDUkJDgH9MRfv4FvykgjGH W+UjdKN5/is0ybkrc3oCMBEqRMLgnUBYtLHDZ4D0QvpeyX/D1x/gj3FPBiRS0F3jIlnunWp+QzQ cUJW6ALeUQUncT1mXgzN7krr+lKU= X-Received: by 2002:a05:6512:1590:b0:512:8d5d:6707 with SMTP id bp16-20020a056512159000b005128d5d6707mr8547694lfb.35.1708357436047; Mon, 19 Feb 2024 07:43:56 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240219135805.1c4138a3@canb.auug.org.au> <86bk8c4gyh.wl-maz@kernel.org> In-Reply-To: <86bk8c4gyh.wl-maz@kernel.org> From: Ard Biesheuvel Date: Mon, 19 Feb 2024 16:43:45 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: linux-next: manual merge of the kvm-arm tree with the arm64 tree To: Marc Zyngier Cc: Catalin Marinas , Stephen Rothwell , Christoffer Dall , Will Deacon , Linux Kernel Mailing List , Linux Next Mailing List , Oliver Upton , Mark Rutland Content-Type: text/plain; charset="UTF-8" On Mon, 19 Feb 2024 at 16:22, Marc Zyngier wrote: > > On Mon, 19 Feb 2024 12:14:18 +0000, > Catalin Marinas 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 > 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 Thanks for the fix. Acked-by: Ard Biesheuvel Tested-by: Ard Biesheuvel