All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Thomas <bthomas@virtualiron.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] vlapic.c - TDCR
Date: Thu, 09 Nov 2006 12:04:03 -0500	[thread overview]
Message-ID: <45535F83.6040401@virtualiron.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

Clean up two small APIC TDCR issues.  First, only save the bits that
can be set, so that a subsequent read can't see MBZ bits as set.
Next, be sure to initialize the timer_divide_count, which is derived
from the TDCR.  This avoids a potential divide-by-zero elsewhere in the
code.  Technically, the timer_divide_count initialization should be done
from the value of the TDCR, but it's in the init routine and the
registers were all just zeroed by the caller of the init routine.


Signed-off-by: Ben Thomas (ben@virtualiron.com)
-- 
------------------------------------------------------------------------
Ben Thomas                                         Virtual Iron Software
bthomas@virtualiron.com                            Tower 1, Floor 2
978-849-1214                                       900 Chelmsford Street
                                                    Lowell, MA 01851

[-- Attachment #2: 10048-vlapic_tdcr.patch --]
[-- Type: text/x-patch, Size: 1619 bytes --]

# Clean up two small APIC TDCR issues.  First, only save the bits that
# can be set, so that on a subsequent read can't see MBZ bits as set.
# Next, be sure to initialize the timer_divide_count, which is derived
# from the TDCR.  This avoids a potential divide-by-zero elsewhere in the
# code.  Technically, the timer_divide_count initialization should be done
# from the value of the TDCR, but it's in the init routine and the
# registers were all just zeroed.
#
# Signed-off-by: Ben Thomas (ben@virtualiron.com)

Index: xen-unstable.hg/xen/arch/x86/hvm/vlapic.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/x86/hvm/vlapic.c	2006-11-08 17:06:11.000000000 -0500
+++ xen-unstable.hg/xen/arch/x86/hvm/vlapic.c	2006-11-08 17:07:55.000000000 -0500
@@ -779,11 +779,11 @@
     {
         unsigned int tmp1, tmp2;
 
-        tmp1 = val & 0xf;
+        tmp1 = val & 0xb;		/* Only bits 0,1,3 are settable */
         tmp2 = ((tmp1 & 0x3) | ((tmp1 & 0x8) >> 1)) + 1;
         vlapic->timer_divide_count = 0x1 << (tmp2 & 0x7);
 
-        vlapic_set_reg(vlapic, APIC_TDCR, val);
+        vlapic_set_reg(vlapic, APIC_TDCR, tmp1);
 
         HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER, "timer divide count is 0x%x",
                     vlapic->timer_divide_count);
@@ -966,6 +966,7 @@
     vlapic->apic_base_msr = MSR_IA32_APICBASE_ENABLE | APIC_DEFAULT_PHYS_BASE;
 
     vlapic->flush_tpr_threshold = 0;
+    vlapic->timer_divide_count = 2;	/* TDCR of 0, means divide by 2 */
 
     vlapic->base_address = vlapic->apic_base_msr &
                            MSR_IA32_APICBASE_BASE;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2006-11-09 17:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=45535F83.6040401@virtualiron.com \
    --to=bthomas@virtualiron.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.