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: <ZYK5D/KfzpEjQr+8@gmail.com>
Date: Wed, 20 Dec 2023 10:51:11 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Vegard Nossum <vegard.nossum@...cle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
	Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
	"H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org,
	Brian Gerst <brgerst@...il.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Linus Torvalds <torvalds@...uxfoundation.org>
Subject: Re: [PATCH 1/5] x86: provide new infrastructure for GDT descriptors


* Vegard Nossum <vegard.nossum@...cle.com> wrote:

> @@ -27,14 +77,14 @@ struct desc_struct {
>  		.base0		= (u16) (base),			\
>  		.base1		= ((base) >> 16) & 0xFF,	\
>  		.base2		= ((base) >> 24) & 0xFF,	\
> -		.type		= (flags & 0x0f),		\
> -		.s		= (flags >> 4) & 0x01,		\
> -		.dpl		= (flags >> 5) & 0x03,		\
> -		.p		= (flags >> 7) & 0x01,		\
> -		.avl		= (flags >> 12) & 0x01,		\
> -		.l		= (flags >> 13) & 0x01,		\
> -		.d		= (flags >> 14) & 0x01,		\
> -		.g		= (flags >> 15) & 0x01,		\
> +		.type		= ((flags) & 0x0f),		\
> +		.s		= ((flags) >> 4) & 0x01,	\
> +		.dpl		= ((flags) >> 5) & 0x03,	\
> +		.p		= ((flags) >> 7) & 0x01,	\
> +		.avl		= ((flags) >> 12) & 0x01,	\
> +		.l		= ((flags) >> 13) & 0x01,	\
> +		.d		= ((flags) >> 14) & 0x01,	\
> +		.g		= ((flags) >> 15) & 0x01,	\

Yeah, so how about writing it like this:

 #define GDT_ENTRY_INIT(flags, base, limit)			\
	{							\
		.limit0		= ((limit) >>  0) & 0xFFFF,	\
		.limit1		= ((limit) >> 16) & 0x000F,	\
		.base0		= ((base)  >>  0) & 0xFFFF,	\
		.base1		= ((base)  >> 16) & 0x00FF,	\
		.base2		= ((base)  >> 24) & 0x00FF,	\
		.type		= ((flags) >>  0) & 0x000F,	\
		.s		= ((flags) >>  4) & 0x0001,	\
		.dpl		= ((flags) >>  5) & 0x0003,	\
		.p		= ((flags) >>  7) & 0x0001,	\
		.avl		= ((flags) >> 12) & 0x0001,	\
		.l		= ((flags) >> 13) & 0x0001,	\
		.d		= ((flags) >> 14) & 0x0001,	\
		.g		= ((flags) >> 15) & 0x0001,	\
	}

This encodes it all in a very simple format, without C syntactic
variations: bit position and mask.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ