Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751149AbbGaJHV (ORCPT ); Fri, 31 Jul 2015 05:07:21 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:51639 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750786AbbGaJHR (ORCPT ); Fri, 31 Jul 2015 05:07:17 -0400 Date: Fri, 31 Jul 2015 17:06:52 +0800 From: joeyli To: Pavel Machek Cc: "Lee, Chun-Yi" , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Matthew Garrett , Len Brown , Josh Boyer , Vojtech Pavlik , Matt Fleming , Jiri Kosina , "H. Peter Anvin" Subject: Re: [RFC PATCH 04/16] x86/efi: Generating random number in EFI stub Message-ID: <20150731090652.GA13113@linux-rxt1.site> References: <1437056730-15247-1-git-send-email-jlee@suse.com> <1437056730-15247-5-git-send-email-jlee@suse.com> <20150728120112.GA9518@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150728120112.GA9518@amd> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1719 Lines: 70 Hi Pavel, Thanks for your review. On Tue, Jul 28, 2015 at 02:01:12PM +0200, Pavel Machek wrote: > Hi! > > > This patch adds the codes for generating random number array as the > > HMAC key that will used by later EFI stub codes. > > > > The original codes in efi_random copied from aslr and add the codes > > to accept input entropy and EFI debugging. In later patch will add > > the codes to get random number by EFI protocol. The separate codes > > can avoid impacting aslr function. > > > > Signed-off-by: Lee, Chun-Yi > > > +#define X86_FEATURE_EDX_TSC (1 << 4) > > +#define X86_FEATURE_ECX_RDRAND (1 << 30) > > Can you pull it from existing includes somewhere? > I didn't see similar definition in header. > > +static bool rdrand_feature(void) > > +{ > > + return (cpuid_ecx(0x1) & X86_FEATURE_ECX_RDRAND); > > +} > > + > > +static bool rdtsc_feature(void) > > +{ > > + return (cpuid_edx(0x1) & X86_FEATURE_EDX_TSC); > > +} > > Are these helpers neccessary? I will try to simplify it. > > > + if (rdrand_feature()) { > > + efi_printk(sys_table, " RDRAND"); > > + if (rdrand_long(&raw)) { > > + random ^= raw; > > + use_i8254 = false; > > + } > > + } > > + > > + if (rdtsc_feature()) { > > + efi_printk(sys_table, " RDTSC"); > > + rdtscll(raw); > > + > > + random ^= raw; > > + use_i8254 = false; > > + } > > You'll do two (expensive) cpuids calls here. > I will try to avoid call cpuid many times. Thanks a lot! Joey Lee -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/