Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start AP with SIPI instead of INIT-SIPI-SIPI #3

Open
wants to merge 1 commit into
base: stable-4.14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions xen/arch/x86/alternative.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define MAX_PATCH_LEN (255-1)

extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
bool __xen_run_by_SKINIT = false;

#ifdef K8_NOP1
static const unsigned char k8nops[] init_or_livepatch_const = {
Expand Down Expand Up @@ -353,7 +354,6 @@ static int __init nmi_apply_alternatives(const struct cpu_user_regs *regs,
return 1;
}


/*
* This routine is called with local interrupt disabled and used during
* bootup.
Expand Down Expand Up @@ -383,11 +383,14 @@ static void __init _alternative_instructions(bool force)
*/
if (cpuid_ecx(0x80000001) & 0x1000)
{
/* Check is R_INIT bit set to determinate if xen was run by SKINIT */
/*
* Check is R_INIT bit set to determinate if xen was run by SKINIT
*/
rdmsrl(MSR_K8_VM_CR, msr_content);
if (msr_content & K8_VMCR_R_INIT)
{
printk(KERN_INFO "K8_VMCR_R_INIT is set \n");
printk(KERN_INFO "Xen was run by SKINIT \n");
__xen_run_by_SKINIT = true;

/* Clear INIT_R*/
msr_content &= ~K8_VMCR_R_INIT;
Expand All @@ -398,7 +401,6 @@ static void __init _alternative_instructions(bool force)
printk(KERN_INFO "GIF is set \n");
}
}

ASSERT(!local_irq_is_enabled());

/* Set what operation to perform /before/ setting the callback. */
Expand Down
82 changes: 45 additions & 37 deletions xen/arch/x86/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
#include <asm/tboot.h>
#include <irq_vectors.h>
#include <mach_apic.h>
#include <asm/hvm/svm/svm.h>

extern bool __xen_run_by_SKINIT;

unsigned long __read_mostly trampoline_phys;

Expand Down Expand Up @@ -413,6 +416,8 @@ void start_secondary(void *unused)

/* We can take interrupts now: we're officially "up". */
local_irq_enable();
if (__xen_run_by_SKINIT)
svm_stgi();
mtrr_ap_init();

startup_cpu_idle_loop();
Expand All @@ -431,49 +436,52 @@ static int wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip)
apic_write(APIC_ESR, 0);
apic_read(APIC_ESR);

Dprintk("Asserting INIT.\n");
if (!__xen_run_by_SKINIT)
{
Dprintk("Asserting INIT.\n");

/*
* Turn INIT on target chip via IPI
*/
apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT,
phys_apicid);
/*
* Turn INIT on target chip via IPI
*/
apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT,
phys_apicid);

if ( !x2apic_enabled )
{
Dprintk("Waiting for send to finish...\n");
timeout = 0;
do {
Dprintk("+");
udelay(100);
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
} while ( send_status && (timeout++ < 1000) );
if ( !x2apic_enabled )
{
Dprintk("Waiting for send to finish...\n");
timeout = 0;
do {
Dprintk("+");
udelay(100);
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
} while ( send_status && (timeout++ < 1000) );

mdelay(10);
mdelay(10);

Dprintk("Deasserting INIT.\n");
Dprintk("Deasserting INIT.\n");

apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid);
apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid);

Dprintk("Waiting for send to finish...\n");
timeout = 0;
do {
Dprintk("+");
udelay(100);
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
} while ( send_status && (timeout++ < 1000) );
}
else if ( tboot_in_measured_env() )
{
/*
* With tboot AP is actually spinning in a mini-guest before
* receiving INIT. Upon receiving INIT ipi, AP need time to VMExit,
* update VMCS to tracking SIPIs and VMResume.
*
* While AP is in root mode handling the INIT the CPU will drop
* any SIPIs
*/
udelay(10);
Dprintk("Waiting for send to finish...\n");
timeout = 0;
do {
Dprintk("+");
udelay(100);
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
} while ( send_status && (timeout++ < 1000) );
}
else if ( tboot_in_measured_env() )
{
/*
* With tboot AP is actually spinning in a mini-guest before
* receiving INIT. Upon receiving INIT ipi, AP need time to VMExit,
* update VMCS to tracking SIPIs and VMResume.
*
* While AP is in root mode handling the INIT the CPU will drop
* any SIPIs
*/
udelay(10);
}
}

maxlvt = get_maxlvt();
Expand Down