From patchwork Thu Jun 16 11:49:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9180673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C03E760760 for ; Thu, 16 Jun 2016 11:50:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B06E126CFB for ; Thu, 16 Jun 2016 11:50:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5602282EE; Thu, 16 Jun 2016 11:50:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1AB7D26CFB for ; Thu, 16 Jun 2016 11:50:32 +0000 (UTC) Received: from localhost ([::1]:48669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDVod-0002F5-8X for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Jun 2016 07:50:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDVo5-00026A-OL for qemu-devel@nongnu.org; Thu, 16 Jun 2016 07:49:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDVo2-0000Mu-K3 for qemu-devel@nongnu.org; Thu, 16 Jun 2016 07:49:57 -0400 Received: from mga11.intel.com ([192.55.52.93]:45172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDVo2-0000MZ-AJ for qemu-devel@nongnu.org; Thu, 16 Jun 2016 07:49:54 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 16 Jun 2016 04:49:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,480,1459839600"; d="scan'208";a="976963435" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.13.126]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2016 04:49:50 -0700 From: Haozhong Zhang To: seabios@seabios.org Date: Thu, 16 Jun 2016 19:49:24 +0800 Message-Id: <20160616114924.21765-1-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.9.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [PATCH] fw/msr_feature_control: add support to set MSR_IA32_FEATURE_CONTROL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , qemu-devel@nongnu.org, Haozhong Zhang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Haozhong Zhang --- QEMU patch added fw_cfg file etc/msr_feature_control can be found at [1]. Note I mistakenly used u32 as the type of file content in that patch, which should be u64 and will be fixed. [1] https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg04389.html --- Makefile | 2 +- src/fw/msr_feature_control.c | 16 ++++++++++++++++ src/fw/paravirt.c | 3 +++ src/fw/smp.c | 6 +++++- src/util.h | 5 +++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/fw/msr_feature_control.c diff --git a/Makefile b/Makefile index 4930b3a..f38a075 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ SRC32FLAT=$(SRCBOTH) post.c e820map.c malloc.c romfile.c x86.c optionroms.c \ fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c fw/xen.c \ fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c \ hw/virtio-ring.c hw/virtio-pci.c hw/virtio-blk.c hw/virtio-scsi.c \ - hw/tpm_drivers.c + hw/tpm_drivers.c fw/msr_feature_control.c SRC32SEG=string.c output.c pcibios.c apm.c stacks.c hw/pci.c hw/serialio.c DIRS=src src/hw src/fw vgasrc diff --git a/src/fw/msr_feature_control.c b/src/fw/msr_feature_control.c new file mode 100644 index 0000000..35d4ab8 --- /dev/null +++ b/src/fw/msr_feature_control.c @@ -0,0 +1,16 @@ +#include "util.h" // msr_feature_control_setup +#include "x86.h" // wrmsr +#include "romfile.h" // romfile_find + +u64 feature_control_bits; + +void msr_feature_control_setup(void) +{ + struct romfile_s *f = romfile_find("etc/msr_feature_control"); + if (!f) + return; + + f->copy(f, &feature_control_bits, sizeof(feature_control_bits)); + if (feature_control_bits) + wrmsr(MSR_IA32_FEATURE_CONTROL, feature_control_bits); +} diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 8ed4380..640ee4c 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -153,6 +153,9 @@ qemu_platform_setup(void) mtrr_setup(); smp_setup(); + // Initialize MSR_IA32_FEATURE_CONTROL + msr_feature_control_setup(); + // Create bios tables pirtable_setup(); mptable_setup(); diff --git a/src/fw/smp.c b/src/fw/smp.c index 579acdb..8b57bf4 100644 --- a/src/fw/smp.c +++ b/src/fw/smp.c @@ -10,7 +10,7 @@ #include "output.h" // dprintf #include "romfile.h" // romfile_loadint #include "stacks.h" // yield -#include "util.h" // smp_setup +#include "util.h" // smp_setup, msr_feature_control_setup #include "x86.h" // wrmsr #define APIC_ICR_LOW ((u8*)BUILD_APIC_ADDR + 0x300) @@ -63,6 +63,10 @@ handle_smp(void) for (i=0; i