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] [day] [month] [year] [list]
Message-ID: <718f4b0c-20d9-8588-1268-e5b26690899d@arm.com>
Date:   Tue, 9 Mar 2021 20:22:38 +0530
From:   Anshuman Khandual <anshuman.khandual@....com>
To:     Will Deacon <will@...nel.org>, Marc Zyngier <maz@...nel.org>
Cc:     linux-arm-kernel@...ts.infradead.org,
        James Morse <james.morse@....com>,
        Catalin Marinas <catalin.marinas@....com>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Ard Biesheuvel <ardb@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        kvmarm@...ts.cs.columbia.edu, linux-efi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arm64/mm: Fix __enable_mmu() for new TGRAN range values



On 3/9/21 7:35 PM, Will Deacon wrote:
> On Mon, Mar 08, 2021 at 02:42:00PM +0000, Marc Zyngier wrote:
>> On Fri, 05 Mar 2021 14:36:09 +0000,
>> Anshuman Khandual <anshuman.khandual@....com> wrote:
>>> -	switch (cpuid_feature_extract_unsigned_field(mmfr0, tgran_2)) {
>>> -	default:
>>> -	case 1:
>>> +	tgran_2 = cpuid_feature_extract_unsigned_field(mmfr0, tgran_2_shift);
>>> +	if (tgran_2 == ID_AA64MMFR0_TGRAN_2_SUPPORTED_NONE) {
>>>  		kvm_err("PAGE_SIZE not supported at Stage-2, giving up\n");
>>>  		return -EINVAL;
>>> -	case 0:
>>> +	} else if (tgran_2 == ID_AA64MMFR0_TGRAN_2_SUPPORTED_DEFAULT) {
>>>  		kvm_debug("PAGE_SIZE supported at Stage-2 (default)\n");
>>> -		break;
>>> -	case 2:
>>> +	} else if (tgran_2 >= ID_AA64MMFR0_TGRAN_2_SUPPORTED_MIN &&
>>> +		   tgran_2 <= ID_AA64MMFR0_TGRAN_2_SUPPORTED_MAX) {
>>>  		kvm_debug("PAGE_SIZE supported at Stage-2 (advertised)\n");
>>> -		break;
>>> +	} else {
>>> +		kvm_err("Unsupported value, giving up\n");
>>> +		return -EINVAL;
>>
>> nit: this doesn't say *what* value is unsupported, and I really
>> preferred the switch-case version, such as this:
>>
>> diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
>> index 1f22b36a0eff..d267e4b1aec6 100644
>> --- a/arch/arm64/kvm/reset.c
>> +++ b/arch/arm64/kvm/reset.c
>> @@ -312,15 +312,18 @@ int kvm_set_ipa_limit(void)
>>  
>>  	switch (cpuid_feature_extract_unsigned_field(mmfr0, tgran_2)) {
>>  	default:
>> -	case 1:
>> +	case ID_AA64MMFR0_TGRAN_2_SUPPORTED_NONE:
>>  		kvm_err("PAGE_SIZE not supported at Stage-2, giving up\n");
>>  		return -EINVAL;
>> -	case 0:
>> +	case ID_AA64MMFR0_TGRAN_2_SUPPORTED_DEFAULT:
>>  		kvm_debug("PAGE_SIZE supported at Stage-2 (default)\n");
>>  		break;
>> -	case 2:
>> +	case ID_AA64MMFR0_TGRAN_2_SUPPORTED_MIN ... ID_AA64MMFR0_TGRAN_2_SUPPORTED_MAX:
>>  		kvm_debug("PAGE_SIZE supported at Stage-2 (advertised)\n");
>>  		break;
>> +	default:
>> +		kvm_err("Unsupported value for TGRAN_2, giving up\n");
>> +		return -EINVAL;
>>  	}
>>  
>>  	kvm_ipa_limit = id_aa64mmfr0_parange_to_phys_shift(parange);
>>
>>
>> Otherwise:
>>
>> Acked-by: Marc Zyngier <maz@...nel.org>
> 
> Anshuman -- please can you spin a v2 with the switch syntax as suggested
> above by Marc?

Sure, will do.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ