Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1801550pxb; Sat, 23 Jan 2021 06:08:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqJii5LGsWYesnms+koavU0NMAw+npljLB+BDJUtobqnSA+g+ZCnJ6WAP1WNVmHV/sIOo4 X-Received: by 2002:a05:6402:1701:: with SMTP id y1mr47357edu.251.1611410908028; Sat, 23 Jan 2021 06:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611410908; cv=none; d=google.com; s=arc-20160816; b=HS866y8ofLDrfgdb5aY0VR/A1hHhWtr5UT7qNUbuTS0K+0ZSpwfaTRZ8YUo0BTwrQD aSyQyc4rLEJSBEmNJR+Tj9LF6GPotoF6X1N82ZUJ24KmJF8oyeZyLRgRdIDzMM3RbuKS d1Se0vRaMD5z3fsbaZ7mr56MA70UjQ2bg/0IUYcB9wwwM+onRScB+MMskGhJWZN5myB8 ENJCeibEe12goAQdb4PT1R7XKMRPaw3qypNYIhITb6guS6aCCHKyPqJAif2cekl58woW um+d4g4SZ8X5iyrYZs+DFuIFNuT05amBpNzSXEIn6RCdhnGEWsS9XahtvO4bR25baNYP xNqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=UFg3tPmxeGusl7Ps5M10A3ocbmWRo9as5dxVtc+bQQA=; b=PMvagmypk+GvWlqXBdiJsrW5NnsW46Nxfcq6Fnsa/FQA/yiLmmmM9E9xUqDhDKWDmk foauSFUhquuQo01soR3xs8pHcXTsXBwlu+dvhV2XDDajro/Wd18jLGIo3Tsc4Fwe9vR3 IZIOc9tTNSMXJ0S4jgDpyzU4oQ2K6G6j/lvS5fjY1NJS7xvAWDyNFQyxxvVbHFHSOFT4 ggzJI399xDAP++vzNfmHHadRaA5sx1elJreLLEf6mQLZEV8SIhmwNRB0Q5Wmlnjc7nt4 3Sg3SOxuRf5YZNQqljL3GMEXCWdr+GByuV4LDHdDKg1pJnLFWTkwWLKNHiGve8jXcUCM 47gA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q13si4648169edd.419.2021.01.23.06.08.03; Sat, 23 Jan 2021 06:08:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725831AbhAWOFS (ORCPT + 99 others); Sat, 23 Jan 2021 09:05:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:33196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbhAWOFR (ORCPT ); Sat, 23 Jan 2021 09:05:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D92B222B51; Sat, 23 Jan 2021 14:04:33 +0000 (UTC) Date: Sat, 23 Jan 2021 14:04:31 +0000 From: Catalin Marinas To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Will Deacon , Mark Rutland , David Brazdil , Alexandru Elisei , Ard Biesheuvel , Jing Zhang , Ajay Patil , Prasad Sodagudi , Srinivas Ramana , James Morse , Julien Thierry , Suzuki K Poulose , kernel-team@android.com Subject: Re: [PATCH v4 13/21] arm64: Allow ID_AA64MMFR1_EL1.VH to be overridden from the command line Message-ID: References: <20210118094533.2874082-1-maz@kernel.org> <20210118094533.2874082-14-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210118094533.2874082-14-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 18, 2021 at 09:45:25AM +0000, Marc Zyngier wrote: > diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h > index fe0130d6c0ff..80a5f423444e 100644 > --- a/arch/arm64/include/asm/cpufeature.h > +++ b/arch/arm64/include/asm/cpufeature.h > @@ -814,6 +814,9 @@ static inline unsigned int get_vmid_bits(u64 mmfr1) > return 8; > } > > +extern u64 id_aa64mmfr1_val; > +extern u64 id_aa64mmfr1_mask; > + > u32 get_kvm_ipa_limit(void); > void dump_cpu_features(void); > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 48a011935d8c..5b9343d2e9f0 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -555,6 +555,9 @@ static const struct arm64_ftr_bits ftr_raz[] = { > > #define ARM64_FTR_REG(id, table) ARM64_FTR_REG_OVERRIDE(id, table, NULL, NULL) > > +u64 id_aa64mmfr1_val; > +u64 id_aa64mmfr1_mask; > + > static const struct __ftr_reg_entry { > u32 sys_id; > struct arm64_ftr_reg *reg; > @@ -602,7 +605,8 @@ static const struct __ftr_reg_entry { > > /* Op1 = 0, CRn = 0, CRm = 7 */ > ARM64_FTR_REG(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0), > - ARM64_FTR_REG(SYS_ID_AA64MMFR1_EL1, ftr_id_aa64mmfr1), > + ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR1_EL1, ftr_id_aa64mmfr1, > + &id_aa64mmfr1_val, &id_aa64mmfr1_mask), > ARM64_FTR_REG(SYS_ID_AA64MMFR2_EL1, ftr_id_aa64mmfr2), > > /* Op1 = 0, CRn = 1, CRm = 2 */ > diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c > index 392f93b67103..75d9845f489b 100644 > --- a/arch/arm64/kernel/idreg-override.c > +++ b/arch/arm64/kernel/idreg-override.c > @@ -10,6 +10,7 @@ > #include > > #include > +#include > #include > > struct reg_desc { > @@ -22,7 +23,18 @@ struct reg_desc { > } fields[]; > }; > > +static const struct reg_desc mmfr1 __initdata = { > + .name = "id_aa64mmfr1", > + .val = &id_aa64mmfr1_val, > + .mask = &id_aa64mmfr1_mask, > + .fields = { > + { "vh", ID_AA64MMFR1_VHE_SHIFT }, > + {} > + }, > +}; > + > static const struct reg_desc * const regs[] __initdata = { > + &mmfr1, > }; I'm ok in principle with how all these link together. I wonder however if we could skip the separate u64 variables and just have a struct reg_override with val and mask u64 rather than pointers. The ARM64_FTR_REG_OVERRIDE macro takes a pointer to this new struct reg_override and can access val/mask directly. Some 'const' may need to be dropped. -- Catalin