Received: from eggs.gnu.org ([2001:4830:134:3::10]:44523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDvf9-0002Qs-OS for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:26:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDvf5-0001aw-O4 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:26:27 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:34832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDvf5-0001am-Gt for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:26:23 -0400 Received: by mail-qk0-x244.google.com with SMTP id b136so12339330qkg.2 for ; Fri, 17 Jun 2016 08:26:23 -0700 (PDT) Date: Fri, 17 Jun 2016 11:26:21 -0400 From: Kevin O'Connor Message-ID: <20160617152621.GA11617@morn.lan> References: <20160617072010.645-1-haozhong.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160617072010.645-1-haozhong.zhang@intel.com> Subject: Re: [Qemu-devel] [SeaBIOS] [PATCH v2] fw/msr_feature_control: add support to set MSR_IA32_FEATURE_CONTROL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Haozhong Zhang Cc: seabios@seabios.org, Paolo Bonzini , qemu-devel@nongnu.org On Fri, Jun 17, 2016 at 03:20:10PM +0800, Haozhong Zhang wrote: > OS usually expects BIOS to set certain bits in MSR_IA32_FEATURE_CONTROL > for some features (e.g. VMX and LMCE). QEMU provides a fw_cfg file > "etc/msr_feature_control" to advise bits that should be set in > MSR_IA32_FEATURE_CONTROL. If this file exists, SeaBIOS will set the > advised bits in that MSR. Thanks - see my comments below. > --- /dev/null > +++ b/src/fw/msr_feature_control.c > @@ -0,0 +1,16 @@ > +#include "util.h" // msr_feature_control_setup, wrmsr_smp > +#include "romfile.h" // romfile_find > + > +#define MSR_IA32_FEATURE_CONTROL 0x0000003a > + > +void msr_feature_control_setup(void) > +{ > + struct romfile_s *f = romfile_find("etc/msr_feature_control"); > + if (!f) > + return; > + > + u64 feature_control_bits; > + f->copy(f, &feature_control_bits, sizeof(feature_control_bits)); > + if (feature_control_bits) > + wrmsr_smp(MSR_IA32_FEATURE_CONTROL, feature_control_bits); > +} Can you use romfile_loadint() instead? Something like: u64 feature_control_bits = romfile_loadint("etc/msr_feature_control", 0); if (feature_control_bits) wrmsr_smp(MSR_IA32_FEATURE_CONTROL, feature_control_bits); That should avoid the need for the separate romfile_find() call and it has the added benefit of additional sanity checks. Also, I think this code is small enough it can be placed directly in paravirt.c and does not need its own c file. -Kevin