|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC v1 46/74] xen/guest: fetch vCPU ID from Xen
From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
If available.
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
To be moved before "x86/guest: enable event channels upcalls"
---
xen/arch/x86/guest/xen.c | 24 +++++++++++++++++++++---
xen/arch/x86/time.c | 4 +++-
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen.c
index 0a4c02a8cd..0f2c5d7413 100644
--- a/xen/arch/x86/guest/xen.c
+++ b/xen/arch/x86/guest/xen.c
@@ -37,6 +37,8 @@ static uint8_t evtchn_upcall_vector;
extern char hypercall_page[];
static struct rangeset *mem;
+DEFINE_PER_CPU(unsigned int, vcpu_id);
+
static void __init find_xen_leaves(void)
{
uint32_t eax, ebx, ecx, edx, base;
@@ -95,10 +97,24 @@ static void map_shared_info(void)
set_fixmap(FIX_XEN_SHARED_INFO, mfn_x(mfn) << PAGE_SHIFT);
}
+static void set_vcpu_id(void)
+{
+ uint32_t eax, ebx, ecx, edx;
+
+ ASSERT(xen_cpuid_base);
+
+ /* Fetch vcpu id from cpuid. */
+ cpuid(xen_cpuid_base + 4, &eax, &ebx, &ecx, &edx);
+ if ( eax & XEN_HVM_CPUID_VCPU_ID_PRESENT )
+ this_cpu(vcpu_id) = ebx;
+ else
+ this_cpu(vcpu_id) = smp_processor_id();
+}
+
static void xen_evtchn_upcall(struct cpu_user_regs *regs)
{
- unsigned int cpu = smp_processor_id();
- struct vcpu_info *vcpu_info = &XEN_shared_info->vcpu_info[cpu];
+ struct vcpu_info *vcpu_info =
+ &XEN_shared_info->vcpu_info[this_cpu(vcpu_id)];
vcpu_info->evtchn_upcall_pending = 0;
xchg(&vcpu_info->evtchn_pending_sel, 0);
@@ -110,7 +126,7 @@ static void xen_evtchn_upcall(struct cpu_user_regs *regs)
static void ap_setup_event_channels(bool clear)
{
- unsigned int i, cpu = smp_processor_id();
+ unsigned int i, cpu = this_cpu(vcpu_id);
struct vcpu_info *vcpu_info = &XEN_shared_info->vcpu_info[cpu];
int rc;
@@ -191,12 +207,14 @@ void __init hypervisor_setup(void)
init_memmap();
map_shared_info();
+ set_vcpu_id();
init_evtchn();
}
void hypervisor_ap_setup(void)
{
+ set_vcpu_id();
ap_setup_event_channels(false);
}
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 886fc45248..85bcb9b28a 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -533,6 +533,8 @@ static struct platform_timesource __initdata plt_tsc =
* Xen clock source is a variant of TSC source.
*/
+DECLARE_PER_CPU(unsigned int, vcpu_id);
+
static u64 xen_timer_cpu_frequency(void)
{
struct vcpu_time_info *info = &XEN_shared_info->vcpu_info[0].time;
@@ -575,7 +577,7 @@ static u64 last_value;
static u64 read_xen_timer(void)
{
struct vcpu_time_info *info;
- unsigned int cpu = smp_processor_id();
+ unsigned int cpu = this_cpu(vcpu_id);
u32 version;
u64 ret;
u64 last;
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |