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]
Date:	Mon, 15 Jun 2015 18:09:57 +0100
From:	Matt Fleming <matt@...eblueprint.co.uk>
To:	"Jonathan (Zhixiong) Zhang" <zjzhang@...eaurora.org>
Cc:	Matt Fleming <matt.fleming@...el.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
	ying.huang@...el.com, fu.wei@...aro.org, al.stone@...aro.org,
	bp@...en8.de, linux-efi@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH V4 1/4] efi: x86: rearrange efi_mem_attributes()

On Fri, 12 Jun, at 06:01:44PM, Jonathan (Zhixiong) Zhang wrote:
> From: "Jonathan (Zhixiong) Zhang" <zjzhang@...eaurora.org>
> 
> x86 and ia64 implement efi_mem_attributes() differently. This
> function needs to be available for other arch (such as arm64)
> as well, such as for the purpose of ACPI/APEI.
> 
> ia64 efi does not setup memmap variable and does not set
> EFI_MEMMAP flag, so it needs to have its unique implementation
> of efi_mem_attributes().

Something like the above paragraph...
 
> @@ -517,3 +517,21 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
>  			 attr & EFI_MEMORY_UC      ? "UC"  : "");
>  	return buf;
>  }

needs to go here, i.e. as documentation for efi_mem_atributes(). You
need to explain why this function is marked as __weak at the function
definition site.

> +u64 __weak efi_mem_attributes(unsigned long phys_addr)
> +{
> +	efi_memory_desc_t *md;
> +	void *p;
> +
> +	if (!efi_enabled(EFI_MEMMAP))
> +		return 0;
> +
> +	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
> +		md = p;
> +		if ((md->phys_addr <= phys_addr) &&
> +		    (phys_addr < (md->phys_addr +
> +		    (md->num_pages << EFI_PAGE_SHIFT))))
> +			return md->attribute;
> +	}
> +	return 0;
> +}

because otherwise people are going to read this in the future and think,

 "efi_mem_attribute() doesn't quite work how I want it to for my arch,
 but it's __weak, so I'll override it"

which is absolutely not the practice we should be promoting.

How about something like this,

	/*
	 * efi_mem_attributes - lookup memmap attributes for physical address
	 * @phys_addr: the physical address to lookup
	 *
	 * Search in the EFI memory map for the region covering
	 * @phys_addr. Returns the EFI memory attributes if the region
	 * was found in the memory map, 0 otherwise.
	 *
	 * Despite being marked __weak most architectures should *not*
	 * override this function. It is __weak solely for the benefit
	 * of ia64 which has a funky EFI memory map that doesn't work
	 * the same way as other architectures.
	 */

-- 
Matt Fleming, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ