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: <20070625232511.3fc07f8f.akpm@linux-foundation.org>
Date:	Mon, 25 Jun 2007 23:25:11 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	"Keshavamurthy, Anil S" <anil.s.keshavamurthy@...el.com>
Cc:	linux-kernel@...r.kernel.org, ak@...e.de, gregkh@...e.de,
	muli@...ibm.com, suresh.b.siddha@...el.com, arjan@...ux.intel.com,
	ashok.raj@...el.com, davem@...emloft.net, clameter@....com
Subject: Re: [Intel IOMMU 05/10] Intel IOMMU driver

On Tue, 19 Jun 2007 14:37:06 -0700 "Keshavamurthy, Anil S" <anil.s.keshavamurthy@...el.com> wrote:

> +/*
> + * Decoding Capability Register
> + */
> +#define cap_read_drain(c)	(((c) >> 55) & 1)
> +#define cap_write_drain(c)	(((c) >> 54) & 1)
> +#define cap_max_amask_val(c)	(((c) >> 48) & 0x3f)
> +#define cap_num_fault_regs(c)	((((c) >> 40) & 0xff) + 1)
> +#define cap_pgsel_inv(c)	(((c) >> 39) & 1)
> +
> +#define cap_super_page_val(c)	(((c) >> 34) & 0xf)
> +#define cap_super_offset(c)	(((find_first_bit(&cap_super_page_val(c), 4)) \
> +					* OFFSET_STRIDE) + 21)
> +
> +#define cap_fault_reg_offset(c)	((((c) >> 24) & 0x3ff) * 16)
> +#define cap_max_fault_reg_offset(c) \
> +	(cap_fault_reg_offset(c) + cap_num_fault_regs(c) * 16)
> +
> +#define cap_zlr(c)		(((c) >> 22) & 1)
> +#define cap_isoch(c)		(((c) >> 23) & 1)
> +#define cap_mgaw(c)		((((c) >> 16) & 0x3f) + 1)
> +#define cap_sagaw(c)		(((c) >> 8) & 0x1f)
> +#define cap_caching_mode(c)	(((c) >> 7) & 1)
> +#define cap_phmr(c)		(((c) >> 6) & 1)
> +#define cap_plmr(c)		(((c) >> 5) & 1)
> +#define cap_rwbf(c)		(((c) >> 4) & 1)
> +#define cap_afl(c)		(((c) >> 3) & 1)
> +#define cap_ndoms(c)		(((unsigned long)1) << (4 + 2 * ((c) & 0x7)))
> +/*
> + * Extended Capability Register
> + */
> +
> +#define ecap_niotlb_iunits(e)	((((e) >> 24) & 0xff) + 1)
> +#define ecap_iotlb_offset(e) 	((((e) >> 8) & 0x3ff) * 16)
> +#define ecap_max_iotlb_offset(e) \
> +	(ecap_iotlb_offset(e) + ecap_niotlb_iunits(e) * 16)
> +#define ecap_coherent(e)	((e) & 0x1)

None of these actually _need_ to be macros and it would be better to 
implement them in C.  That way things are more self-documenting, more
pleasant to read, more likely to get commented and you'll fix the
two bugs wherein the argument to a macro is evaluated more than once.

-
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