From: Keir Fraser <keir.fraser@eu.citrix.com>
To: "Jiang, Yunhong" <yunhong.jiang@intel.com>,
Jan Beulich <JBeulich@novell.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: RE: [PATCH] Allocate vmcs pages when system booting
Date: Mon, 18 Jan 2010 08:11:41 +0000 [thread overview]
Message-ID: <C779C83E.67A3%keir.fraser@eu.citrix.com> (raw)
In-Reply-To: <C779330E.6783%keir.fraser@eu.citrix.com>
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
On 17/01/2010 21:35, "Keir Fraser" <keir.fraser@eu.citrix.com> wrote:
> On 17/01/2010 02:02, "Jiang, Yunhong" <yunhong.jiang@intel.com> wrote:
>
>> Do you agree this method?
>
> I will come up with a patch tomorrow for you to try.
Does the attached patch work okay for you?
-- Keir
[-- Attachment #2: 00-hvm-cpu-prepare --]
[-- Type: application/octet-stream, Size: 4515 bytes --]
diff -r 7a8cee80597e xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Sun Jan 17 18:20:04 2010 +0000
+++ b/xen/arch/x86/hvm/svm/svm.c Mon Jan 18 08:10:28 2010 +0000
@@ -809,6 +809,16 @@
return 0;
}
+static int svm_cpu_prepare(unsigned int cpu)
+{
+ if ( ((hsa[cpu] == NULL) &&
+ ((hsa[cpu] = alloc_host_save_area()) == NULL)) ||
+ ((root_vmcb[cpu] == NULL) &&
+ ((root_vmcb[cpu] = alloc_vmcb()) == NULL)) )
+ return -ENOMEM;
+ return 0;
+}
+
static int svm_cpu_up(struct cpuinfo_x86 *c)
{
u32 eax, edx, phys_hsa_lo, phys_hsa_hi;
@@ -823,10 +833,7 @@
return 0;
}
- if ( ((hsa[cpu] == NULL) &&
- ((hsa[cpu] = alloc_host_save_area()) == NULL)) ||
- ((root_vmcb[cpu] == NULL) &&
- ((root_vmcb[cpu] = alloc_vmcb()) == NULL)) )
+ if ( svm_cpu_prepare(cpu) != 0 )
return 0;
write_efer(read_efer() | EFER_SVME);
@@ -1231,6 +1238,7 @@
static struct hvm_function_table __read_mostly svm_function_table = {
.name = "SVM",
+ .cpu_prepare = svm_cpu_prepare,
.cpu_down = svm_cpu_down,
.domain_initialise = svm_domain_initialise,
.domain_destroy = svm_domain_destroy,
diff -r 7a8cee80597e xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c Sun Jan 17 18:20:04 2010 +0000
+++ b/xen/arch/x86/hvm/vmx/vmcs.c Mon Jan 18 08:10:28 2010 +0000
@@ -320,6 +320,19 @@
local_irq_restore(flags);
}
+int vmx_cpu_prepare(unsigned int cpu)
+{
+ if ( this_cpu(host_vmcs) != NULL )
+ return 0;
+
+ this_cpu(host_vmcs) = vmx_alloc_vmcs();
+ if ( this_cpu(host_vmcs) != NULL )
+ return 0;
+
+ printk("CPU%d: Could not allocate host VMCS\n", cpu);
+ return -ENOMEM;
+}
+
int vmx_cpu_up(void)
{
u32 eax, edx;
@@ -367,15 +380,8 @@
INIT_LIST_HEAD(&this_cpu(active_vmcs_list));
- if ( this_cpu(host_vmcs) == NULL )
- {
- this_cpu(host_vmcs) = vmx_alloc_vmcs();
- if ( this_cpu(host_vmcs) == NULL )
- {
- printk("CPU%d: Could not allocate host VMCS\n", cpu);
- return 0;
- }
- }
+ if ( vmx_cpu_prepare(cpu) != 0 )
+ return 0;
switch ( __vmxon(virt_to_maddr(this_cpu(host_vmcs))) )
{
diff -r 7a8cee80597e xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Sun Jan 17 18:20:04 2010 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c Mon Jan 18 08:10:28 2010 +0000
@@ -1377,6 +1377,7 @@
static struct hvm_function_table __read_mostly vmx_function_table = {
.name = "VMX",
+ .cpu_prepare = vmx_cpu_prepare,
.domain_initialise = vmx_domain_initialise,
.domain_destroy = vmx_domain_destroy,
.vcpu_initialise = vmx_vcpu_initialise,
diff -r 7a8cee80597e xen/arch/x86/smpboot.c
--- a/xen/arch/x86/smpboot.c Sun Jan 17 18:20:04 2010 +0000
+++ b/xen/arch/x86/smpboot.c Mon Jan 18 08:10:28 2010 +0000
@@ -1518,7 +1518,11 @@
int __devinit __cpu_up(unsigned int cpu)
{
- int ret = 0;
+ int ret;
+
+ ret = hvm_cpu_prepare(cpu);
+ if (ret)
+ return ret;
/*
* We do warm boot only on cpus that had booted earlier
diff -r 7a8cee80597e xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h Sun Jan 17 18:20:04 2010 +0000
+++ b/xen/include/asm-x86/hvm/hvm.h Mon Jan 18 08:10:28 2010 +0000
@@ -111,6 +111,7 @@
int (*event_pending)(struct vcpu *v);
int (*do_pmu_interrupt)(struct cpu_user_regs *regs);
+ int (*cpu_prepare)(unsigned int cpu);
int (*cpu_up)(void);
void (*cpu_down)(void);
@@ -290,11 +291,15 @@
void hvm_set_rdtsc_exiting(struct domain *d, bool_t enable);
int hvm_gtsc_need_scale(struct domain *d);
+static inline int
+hvm_cpu_prepare(unsigned int cpu)
+{
+ return (hvm_funcs.cpu_prepare ? hvm_funcs.cpu_prepare(cpu) : 0);
+}
+
static inline int hvm_cpu_up(void)
{
- if ( hvm_funcs.cpu_up )
- return hvm_funcs.cpu_up();
- return 1;
+ return (hvm_funcs.cpu_up ? hvm_funcs.cpu_up() : 1);
}
static inline void hvm_cpu_down(void)
diff -r 7a8cee80597e xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h Sun Jan 17 18:20:04 2010 +0000
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h Mon Jan 18 08:10:28 2010 +0000
@@ -26,6 +26,7 @@
extern void start_vmx(void);
extern void vmcs_dump_vcpu(struct vcpu *v);
extern void setup_vmcs_dump(void);
+extern int vmx_cpu_prepare(unsigned int cpu);
extern int vmx_cpu_up(void);
extern void vmx_cpu_down(void);
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2010-01-18 8:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-12 10:52 [PATCH] Allocate vmcs pages when system booting Jiang, Yunhong
2009-11-12 11:22 ` Keir Fraser
2009-11-12 14:58 ` Jiang, Yunhong
2009-11-12 15:04 ` Keir Fraser
2009-11-12 15:15 ` Jiang, Yunhong
2010-01-15 9:06 ` Jiang, Yunhong
2010-01-15 9:30 ` Jan Beulich
2010-01-15 10:31 ` Keir Fraser
2010-01-17 2:02 ` Jiang, Yunhong
2010-01-17 21:35 ` Keir Fraser
2010-01-18 8:11 ` Keir Fraser [this message]
2010-01-18 8:22 ` Jiang, Yunhong
2010-03-18 10:45 ` Jan Beulich
2010-03-18 10:51 ` Keir Fraser
2010-03-19 2:17 ` Jiang, Yunhong
2010-01-15 10:28 ` Keir Fraser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C779C83E.67A3%keir.fraser@eu.citrix.com \
--to=keir.fraser@eu.citrix.com \
--cc=JBeulich@novell.com \
--cc=xen-devel@lists.xensource.com \
--cc=yunhong.jiang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).