* [PATCH v4] hvm: vmx/svm_cpu_up_prepare should be called only once
@ 2017-08-22 2:08 Boris Ostrovsky
2017-08-22 8:12 ` Jan Beulich
2017-08-24 5:28 ` Tian, Kevin
0 siblings, 2 replies; 3+ messages in thread
From: Boris Ostrovsky @ 2017-08-22 2:08 UTC (permalink / raw)
To: xen-devel
Cc: kevin.tian, suravee.suthikulpanit, andrew.cooper3, jbeulich,
jun.nakajima, Boris Ostrovsky
These routines are first called via CPU_UP_PREPARE notifier by
the BSP and then by the booting ASP from vmx_cpu_up()/_svm_cpu_up().
Avoid the unnecessary second call. Because BSP doesn't go through
CPU_UP_PREPARE it is a special case. We pass 'bsp' flag to newly
added _vmx_cpu_up() (just like it's already done for _svm_cpu_up())
so they can decide whether or not to call vmx/svm_cpu_up_prepare().
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
V4:
* Reverted to original (SVM) style per Jan's request.
xen/arch/x86/hvm/svm/svm.c | 2 +-
xen/arch/x86/hvm/vmx/vmcs.c | 9 +++++++--
xen/arch/x86/hvm/vmx/vmx.c | 2 +-
xen/include/asm-x86/hvm/vmx/vmcs.h | 1 +
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 0dc9442..3e7b9fc 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -1538,7 +1538,7 @@ static int _svm_cpu_up(bool bsp)
return -EINVAL;
}
- if ( (rc = svm_cpu_up_prepare(cpu)) != 0 )
+ if ( bsp && (rc = svm_cpu_up_prepare(cpu)) != 0 )
return rc;
write_efer(read_efer() | EFER_SVME);
diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 7854802..86cd316 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -603,7 +603,7 @@ void vmx_cpu_dead(unsigned int cpu)
vmx_pi_desc_fixup(cpu);
}
-int vmx_cpu_up(void)
+int _vmx_cpu_up(bool bsp)
{
u32 eax, edx;
int rc, bios_locked, cpu = smp_processor_id();
@@ -652,7 +652,7 @@ int vmx_cpu_up(void)
INIT_LIST_HEAD(&this_cpu(active_vmcs_list));
- if ( (rc = vmx_cpu_up_prepare(cpu)) != 0 )
+ if ( bsp && (rc = vmx_cpu_up_prepare(cpu)) != 0 )
return rc;
switch ( __vmxon(this_cpu(vmxon_region)) )
@@ -693,6 +693,11 @@ int vmx_cpu_up(void)
return 0;
}
+int vmx_cpu_up()
+{
+ return _vmx_cpu_up(false);
+}
+
void vmx_cpu_down(void)
{
struct list_head *active_vmcs_list = &this_cpu(active_vmcs_list);
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 67fc85b..f6da119 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2433,7 +2433,7 @@ const struct hvm_function_table * __init start_vmx(void)
{
set_in_cr4(X86_CR4_VMXE);
- if ( vmx_cpu_up() )
+ if ( _vmx_cpu_up(true) )
{
printk("VMX: failed to initialise.\n");
return NULL;
diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm/vmx/vmcs.h
index e3faf78..8fb9e3c 100644
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h
@@ -26,6 +26,7 @@ extern void setup_vmcs_dump(void);
extern int vmx_cpu_up_prepare(unsigned int cpu);
extern void vmx_cpu_dead(unsigned int cpu);
extern int vmx_cpu_up(void);
+extern int _vmx_cpu_up(bool bsp);
extern void vmx_cpu_down(void);
struct vmcs_struct {
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4] hvm: vmx/svm_cpu_up_prepare should be called only once
2017-08-22 2:08 [PATCH v4] hvm: vmx/svm_cpu_up_prepare should be called only once Boris Ostrovsky
@ 2017-08-22 8:12 ` Jan Beulich
2017-08-24 5:28 ` Tian, Kevin
1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2017-08-22 8:12 UTC (permalink / raw)
To: Boris Ostrovsky
Cc: andrew.cooper3, kevin.tian, jun.nakajima, suravee.suthikulpanit,
xen-devel
>>> On 22.08.17 at 04:08, <boris.ostrovsky@oracle.com> wrote:
> These routines are first called via CPU_UP_PREPARE notifier by
> the BSP and then by the booting ASP from vmx_cpu_up()/_svm_cpu_up().
>
> Avoid the unnecessary second call. Because BSP doesn't go through
> CPU_UP_PREPARE it is a special case. We pass 'bsp' flag to newly
> added _vmx_cpu_up() (just like it's already done for _svm_cpu_up())
> so they can decide whether or not to call vmx/svm_cpu_up_prepare().
>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] hvm: vmx/svm_cpu_up_prepare should be called only once
2017-08-22 2:08 [PATCH v4] hvm: vmx/svm_cpu_up_prepare should be called only once Boris Ostrovsky
2017-08-22 8:12 ` Jan Beulich
@ 2017-08-24 5:28 ` Tian, Kevin
1 sibling, 0 replies; 3+ messages in thread
From: Tian, Kevin @ 2017-08-24 5:28 UTC (permalink / raw)
To: Boris Ostrovsky, xen-devel@lists.xen.org
Cc: Nakajima, Jun, andrew.cooper3@citrix.com,
suravee.suthikulpanit@amd.com, jbeulich@suse.com
> From: Boris Ostrovsky [mailto:boris.ostrovsky@oracle.com]
> Sent: Tuesday, August 22, 2017 10:08 AM
>
> These routines are first called via CPU_UP_PREPARE notifier by
> the BSP and then by the booting ASP from vmx_cpu_up()/_svm_cpu_up().
>
> Avoid the unnecessary second call. Because BSP doesn't go through
> CPU_UP_PREPARE it is a special case. We pass 'bsp' flag to newly
> added _vmx_cpu_up() (just like it's already done for _svm_cpu_up())
> so they can decide whether or not to call vmx/svm_cpu_up_prepare().
>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-24 5:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22 2:08 [PATCH v4] hvm: vmx/svm_cpu_up_prepare should be called only once Boris Ostrovsky
2017-08-22 8:12 ` Jan Beulich
2017-08-24 5:28 ` Tian, Kevin
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).