From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH RFC 06/31] xen/x86: Infrastructure to calculate guest featuresets Date: Wed, 16 Dec 2015 21:24:08 +0000 Message-ID: <1450301073-28191-7-git-send-email-andrew.cooper3@citrix.com> References: <1450301073-28191-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1450301073-28191-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Jan Beulich List-Id: xen-devel@lists.xenproject.org Guest featuresets are seeded from the host featureset, and the host featureset has calculated in the front of boot_cpu_data.x86_capability. Signed-off-by: Andrew Cooper --- CC: Jan Beulich --- xen/arch/x86/Makefile | 1 + xen/arch/x86/cpuid.c | 23 +++++++++++++++++++++++ xen/arch/x86/setup.c | 3 +++ xen/include/asm-x86/cpuid.h | 22 ++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 xen/arch/x86/cpuid.c create mode 100644 xen/include/asm-x86/cpuid.h diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 122cbe9..c1f6f73 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -15,6 +15,7 @@ obj-bin-y += bzimage.init.o obj-bin-y += clear_page.o obj-bin-y += copy_page.o obj-y += compat.o +obj-y += cpuid.o obj-y += debug.o obj-y += delay.o obj-bin-y += dmi_scan.init.o diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c new file mode 100644 index 0000000..099e145 --- /dev/null +++ b/xen/arch/x86/cpuid.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +uint32_t __read_mostly host_featureset[XEN_NR_FEATURESET_ENTRIES]; + +void __init calculate_featuresets(void) +{ + /* Host featureset. */ + memcpy(host_featureset, boot_cpu_data.x86_capability, + sizeof(host_featureset)); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 54995ed..d91c2fb 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -50,6 +50,7 @@ #include #include #include +#include /* opt_nosmp: If true, secondary processors are ignored. */ static bool_t __initdata opt_nosmp; @@ -1434,6 +1435,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) "Multiple initrd candidates, picking module #%u\n", initrdidx); + calculate_featuresets(); + /* * Temporarily clear SMAP in CR4 to allow user-accesses in construct_dom0(). * This saves a large number of corner cases interactions with diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h new file mode 100644 index 0000000..c303c74 --- /dev/null +++ b/xen/include/asm-x86/cpuid.h @@ -0,0 +1,22 @@ +#ifndef __X86_CPUID_H__ +#define __X86_CPUID_H__ + +#include +#include +#include + +extern uint32_t host_featureset[XEN_NR_FEATURESET_ENTRIES]; + +void calculate_featuresets(void); + +#endif /* !__X86_CPUID_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ -- 2.1.4