lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <95659e7f-090e-0ff7-3e89-1ed17df68e6d@arm.com>
Date:   Sat, 23 Jan 2021 16:04:26 +0000
From:   Suzuki K Poulose <suzuki.poulose@....com>
To:     Catalin Marinas <catalin.marinas@....com>,
        Marc Zyngier <maz@...nel.org>
Cc:     linux-arm-kernel@...ts.infradead.org, kvmarm@...ts.cs.columbia.edu,
        linux-kernel@...r.kernel.org, Will Deacon <will@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        David Brazdil <dbrazdil@...gle.com>,
        Alexandru Elisei <alexandru.elisei@....com>,
        Ard Biesheuvel <ardb@...nel.org>,
        Jing Zhang <jingzhangos@...gle.com>,
        Ajay Patil <pajay@....qualcomm.com>,
        Prasad Sodagudi <psodagud@...eaurora.org>,
        Srinivas Ramana <sramana@...eaurora.org>,
        James Morse <james.morse@....com>,
        Julien Thierry <julien.thierry.kdev@...il.com>,
        kernel-team@...roid.com
Subject: Re: [PATCH v4 10/21] arm64: cpufeature: Use IDreg override in
 __read_sysreg_by_encoding()

On 1/22/21 6:53 PM, Catalin Marinas wrote:
> On Mon, Jan 18, 2021 at 09:45:22AM +0000, Marc Zyngier wrote:
>> __read_sysreg_by_encoding() is used by a bunch of cpufeature helpers,
>> which should take the feature override into account. Let's do that.
>>
>> For a good measure (and because we are likely to need to further
>> down the line), make this helper available to the rest of the
>> non-modular kernel.
>>
>> Code that needs to know the *real* features of a CPU can still
>> use read_sysreg_s(), and find the bare, ugly truth.
>>
>> Signed-off-by: Marc Zyngier <maz@...nel.org>

>> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
>> index aaa075c6f029..48a011935d8c 100644
>> --- a/arch/arm64/kernel/cpufeature.c
>> +++ b/arch/arm64/kernel/cpufeature.c
>> @@ -1149,14 +1149,17 @@ u64 read_sanitised_ftr_reg(u32 id)
>>   EXPORT_SYMBOL_GPL(read_sanitised_ftr_reg);
>>   
>>   #define read_sysreg_case(r)	\
>> -	case r:		return read_sysreg_s(r)
>> +	case r:		val = read_sysreg_s(r); break;
>>   
>>   /*
>>    * __read_sysreg_by_encoding() - Used by a STARTING cpu before cpuinfo is populated.
>>    * Read the system register on the current CPU
>>    */
>> -static u64 __read_sysreg_by_encoding(u32 sys_id)
>> +u64 __read_sysreg_by_encoding(u32 sys_id)
>>   {
>> +	struct arm64_ftr_reg *regp;
>> +	u64 val;
>> +
>>   	switch (sys_id) {
>>   	read_sysreg_case(SYS_ID_PFR0_EL1);
>>   	read_sysreg_case(SYS_ID_PFR1_EL1);
>> @@ -1199,6 +1202,14 @@ static u64 __read_sysreg_by_encoding(u32 sys_id)
>>   		BUG();
>>   		return 0;
>>   	}
>> +
>> +	regp  = get_arm64_ftr_reg(sys_id);
>> +	if (regp && regp->override_mask && regp->override_val) {
>> +		val &= ~*regp->override_mask;
>> +		val |= (*regp->override_val & *regp->override_mask);
>> +	}
>> +
>> +	return val;
> 
> Ah, now the previous patch makes more sense. I don't particularly like
> this but I can't tell how to work around it. I was hoping that the
> overriding feature behaves more like a secondary CPU that limits all the
> overridden features. However, this approach would fail for FTR_EXACT
> cases (like PAC, though I wonder whether it fails already with your
> previous patch since the boot CPU value won't match the override, hence
> dropping to the safe one).
> 

Correct !For FTR_EXACT, we dont want to override a value that is not safe, e.g PAC.
This is handled correctly in the previous patch and thus we are covered.

Reviewed-by: Suzuki K Poulose <suzuki.poulose@....com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ