WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] x86/apic: check maxlvt before accessing certain LVT

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] x86/apic: check maxlvt before accessing certain LVT fields
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Wed, 15 Jun 2011 16:36:40 +0100
Delivery-date: Wed, 15 Jun 2011 08:37:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
This follows Linux, including in not checking maxlvt for certain
accesses to APIC_LVTERR.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -727,7 +727,8 @@ int lapic_suspend(void)
     apic_pm_state.apic_dfr = apic_read(APIC_DFR);
     apic_pm_state.apic_spiv = apic_read(APIC_SPIV);
     apic_pm_state.apic_lvtt = apic_read(APIC_LVTT);
-    apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
+    if (maxlvt >= 4)
+        apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
 
     if (maxlvt >= 6) {
         apic_pm_state.apic_lvtcmci = apic_read(APIC_CMCI);
@@ -738,7 +739,8 @@ int lapic_suspend(void)
     apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
     apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
     apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
-    apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
+    if (maxlvt >= 5)
+        apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
 
     local_irq_save(flags);
     disable_local_APIC();
@@ -774,6 +776,7 @@ int lapic_resume(void)
     else
         resume_x2apic();
 
+    maxlvt = get_maxlvt();
     apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED);
     apic_write(APIC_ID, apic_pm_state.apic_id);
     apic_write(APIC_DFR, apic_pm_state.apic_dfr);
@@ -782,14 +785,15 @@ int lapic_resume(void)
     apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
     apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
     apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
-    apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
+    if (maxlvt >= 5)
+        apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
 
-    maxlvt = get_maxlvt();
     if (maxlvt >= 6) {
         apic_write(APIC_CMCI, apic_pm_state.apic_lvtcmci);
     }
 
-    apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
+    if (maxlvt >= 4)
+        apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
     apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
     apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
     apic_write(APIC_TMICT, apic_pm_state.apic_tmict);



Attachment: x86-apic-maxlvt-check.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] x86/apic: check maxlvt before accessing certain LVT fields, Jan Beulich <=