From: Andrew Cooper <andrew.cooper3@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 2 of 6] APIC: remove 'enabled_via_apicbase' variable
Date: Wed, 25 May 2011 15:32:04 +0100 [thread overview]
Message-ID: <17991cc69e887d6159c6.1306333924@andrewcoop> (raw)
In-Reply-To: <patchbomb.1306333922@andrewcoop>
The use of this varable was only sensible when the choice for local APIC
mode was between enabled or disabled. Now that x2apic is about, it is
wrong, and causes a protection fault in certain cases when trying to tear
down x2apic mode.
The only place where its use is relevent in the code is in
disable_local_APIC which is very out of date. It has now been updated
to be in line with the MultiProcessor Spec, as well as being able
to successfully shut down from x2apic mode without the possibility of
throwing a protection fault (which leads to a general protection fault).
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff -r 8d30fccc0771 -r 17991cc69e88 xen/arch/x86/apic.c
--- a/xen/arch/x86/apic.c Wed May 25 15:10:24 2011 +0100
+++ b/xen/arch/x86/apic.c Wed May 25 15:10:52 2011 +0100
@@ -165,8 +165,6 @@ void __init apic_intr_init(void)
/* Using APIC to generate smp_local_timer_interrupt? */
static bool_t __read_mostly using_apic_timer;
-static bool_t __read_mostly enabled_via_apicbase;
-
int get_physical_broadcast(void)
{
if (modern_apic())
@@ -330,6 +328,8 @@ void disconnect_bsp_APIC(int virt_wire_s
void disable_local_APIC(void)
{
+ u64 msr_contents;
+
clear_local_APIC();
/*
@@ -339,10 +339,39 @@ void disable_local_APIC(void)
apic_write_around(APIC_SPIV,
apic_read(APIC_SPIV) & ~APIC_SPIV_APIC_ENABLED);
- if (enabled_via_apicbase) {
- uint64_t msr_content;
- rdmsrl(MSR_IA32_APICBASE, msr_content);
- wrmsrl(MSR_IA32_APICBASE, msr_content & ~MSR_IA32_APICBASE_ENABLE);
+ /* Always disable the APIC */
+ rdmsrl(MSR_IA32_APICBASE, msr_contents);
+ msr_contents &= ~ ( MSR_IA32_APICBASE_ENABLE | MSR_IA32_APICBASE_EXTD );
+ wrmsrl(MSR_IA32_APICBASE, msr_contents);
+
+ /* If we are the boot processor, stick the local apic back to how we found
+ * it on boot. */
+ if( smp_processor_id() != 0 )
+ {
+
+ switch(apic_boot_mode)
+ {
+ case APIC_MODE_DISABLED:
+ break; /* Nothing to do - we did this above */
+ case APIC_MODE_XAPIC:
+ {
+ msr_contents |= MSR_IA32_APICBASE_ENABLE;
+ wrmsrl(MSR_IA32_APICBASE, msr_contents);
+ break;
+ }
+ case APIC_MODE_X2APIC:
+ {
+ msr_contents |= ( MSR_IA32_APICBASE_ENABLE | MSR_IA32_APICBASE_EXTD );
+ wrmsrl(MSR_IA32_APICBASE, msr_contents);
+ break;
+ }
+ default:
+ {
+ printk("Hit default case when reverting lapic to boot state on core #%d\n",
+ smp_processor_id());
+ break;
+ }
+ }
}
}
@@ -874,7 +903,6 @@ static int __init detect_init_APIC (void
wrmsrl(MSR_IA32_APICBASE,
msr_content | MSR_IA32_APICBASE_ENABLE
| APIC_DEFAULT_PHYS_BASE);
- enabled_via_apicbase = 1;
}
}
/*
next prev parent reply other threads:[~2011-05-25 14:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-25 14:32 [PATCH 0 of 6] Fix kexec in Xen (take 3) Andrew Cooper
2011-05-25 14:32 ` [PATCH 1 of 6] APIC: record local APIC state on boot Andrew Cooper
2011-05-25 14:32 ` Andrew Cooper [this message]
2011-05-25 14:32 ` [PATCH 3 of 6] APIC: add crash_disable_local_APIC Andrew Cooper
2011-05-25 14:32 ` [PATCH 4 of 6] IOMMU: Sanitise some of our pointer work Andrew Cooper
2011-05-25 17:28 ` Konrad Rzeszutek Wilk
2011-05-25 14:32 ` [PATCH 5 of 6] IOMMU: add crash_shutdown iommu_op Andrew Cooper
2011-05-25 14:32 ` [PATCH 6 of 6] KEXEC: disable iommu jumping into the kdump kernel Andrew Cooper
2011-05-25 15:01 ` [PATCH 0 of 6] Fix kexec in Xen (take 3) Wei Wang2
2011-05-25 16:14 ` Jan Beulich
2011-05-25 16:30 ` Andrew Cooper
2011-05-25 21:35 ` Keir Fraser
2011-05-26 9:12 ` Andrew Cooper
2011-05-26 9:19 ` 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=17991cc69e887d6159c6.1306333924@andrewcoop \
--to=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xensource.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).