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: <20220202075159.GB18398@lst.de>
Date:   Wed, 2 Feb 2022 08:51:59 +0100
From:   Christoph Hellwig <hch@....de>
To:     guoren@...nel.org
Cc:     palmer@...belt.com, arnd@...db.de, anup@...infault.org,
        gregkh@...uxfoundation.org, liush@...winnertech.com,
        wefu@...hat.com, drew@...gleboard.org, wangjunqiang@...as.ac.cn,
        hch@....de, linux-arch@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org,
        linux-csky@...r.kernel.org, linux-s390@...r.kernel.org,
        sparclinux@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
        linux-parisc@...r.kernel.org, linux-mips@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, x86@...nel.org,
        Guo Ren <guoren@...ux.alibaba.com>
Subject: Re: [PATCH V5 15/21] riscv: compat: Add hw capability check for elf

On Tue, Feb 01, 2022 at 11:05:39PM +0800, guoren@...nel.org wrote:
> +bool compat_elf_check_arch(Elf32_Ehdr *hdr)
> +{
> +	if (compat_mode_support && (hdr->e_machine == EM_RISCV))
> +		return true;
> +	else
> +		return false;
> +}

This can be simplified to:

	return compat_mode_support && hdr->e_machine == EM_RISCV;

I'd also rename compat_mode_support to compat_mode_supported

> +
> +static int compat_mode_detect(void)
> +{
> +	unsigned long tmp = csr_read(CSR_STATUS);
> +
> +	csr_write(CSR_STATUS, (tmp & ~SR_UXL) | SR_UXL_32);
> +
> +	if ((csr_read(CSR_STATUS) & SR_UXL) != SR_UXL_32) {
> +		pr_info("riscv: 32bit compat mode detect failed\n");
> +		compat_mode_support = false;
> +	} else {
> +		compat_mode_support = true;
> +		pr_info("riscv: 32bit compat mode detected\n");
> +	}

I don't think we need these printks here.

Also this could be simplified to:

	compat_mode_supported = (csr_read(CSR_STATUS) & SR_UXL) == SR_UXL_32;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ