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: <a78f892e-ad61-4a51-9ffe-466b473d3cde@email.android.com>
Date:	Thu, 30 Jan 2014 05:45:50 -0800
From:	"H. Peter Anvin" <hpa@...or.com>
To:	David Woodhouse <dwmw2@...radead.org>,
	Ingo Molnar <mingo@...nel.org>
CC:	linux-kernel@...r.kernel.org, keescook@...omium.org,
	tglx@...utronix.de, hpa@...ux.intel.com,
	linux-tip-commits@...r.kernel.org
Subject: Re: [PATCH v2] x86, boot: Fix word-size assumptions in has_eflag () inline asm

This would seem like a job for <asm/asm.h>.

On January 30, 2014 3:00:28 AM PST, David Woodhouse <dwmw2@...radead.org> wrote:
>Commit dd78b97367bd575918204cc89107c1479d3fc1a7 ("x86, boot: Move CPU
>flags out of cpucheck") introduced ambiguous inline asm in the
>has_eflag() function. In 16-bit mode want the instruction to be
>'pushfl', but we just say 'pushf' and hope the compiler does what we
>wanted.
>
>When building with 'clang -m16', it won't, because clang doesn't use
>the horrid '.code16gcc' hack that even 'gcc -m16' uses internally.
>
>Say what we mean and don't make the compiler make assumptions.
>
>Signed-off-by: David Woodhouse <David.Woodhouse@...el.com>
>---
>
>Let me know if you'd rather have this as an incremental patch. I would
>have preferred checking for BITS_PER_LONG==64 rather than __x86_64__
>but it seems we set that to 64 even when building the 16-bit code.
>
> arch/x86/boot/cpuflags.c | 25 ++++++++++++++++++++-----
> 1 file changed, 20 insertions(+), 5 deletions(-)
>
>diff --git a/arch/x86/boot/cpuflags.c b/arch/x86/boot/cpuflags.c
>index a9fcb7c..431fa5f 100644
>--- a/arch/x86/boot/cpuflags.c
>+++ b/arch/x86/boot/cpuflags.c
>@@ -28,20 +28,35 @@ static int has_fpu(void)
> 	return fsw == 0 && (fcw & 0x103f) == 0x003f;
> }
> 
>+/*
>+ * For building the 16-bit code we want to explicitly specify 32-bit
>+ * push/pop operations, rather than just saying 'pushf' or 'popf' and
>+ * letting the compiler choose. But this is also included from the
>+ * compressed/ directory where it may be 64-bit code, and thus needs
>+ * to be 'pushfq' or 'popfq' in that case.
>+ */
>+#ifdef __x86_64__
>+#define PUSHF "pushfq"
>+#define POPF "popfq"
>+#else
>+#define PUSHF "pushfl"
>+#define POPF "popfl"
>+#endif
>+
> int has_eflag(unsigned long mask)
> {
> 	unsigned long f0, f1;
> 
>-	asm volatile("pushf	\n\t"
>-		     "pushf	\n\t"
>+	asm volatile(PUSHF "	\n\t"
>+		     PUSHF "	\n\t"
> 		     "pop %0	\n\t"
> 		     "mov %0,%1	\n\t"
> 		     "xor %2,%1	\n\t"
> 		     "push %1	\n\t"
>-		     "popf	\n\t"
>-		     "pushf	\n\t"
>+		     POPF "	\n\t"
>+		     PUSHF "	\n\t"
> 		     "pop %1	\n\t"
>-		     "popf"
>+		     POPF
> 		     : "=&r" (f0), "=&r" (f1)
> 		     : "ri" (mask));
> 

-- 
Sent from my mobile phone.  Please pardon brevity and lack of formatting.
--
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