From: Mikael Pettersson <mikpe@it.uu.se>
To: Robert Uhl <ruhl@xaipete.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Access to local APIC registers during an interrupt handler
Date: Sun, 12 Jun 2011 13:01:26 +0200 [thread overview]
Message-ID: <19956.40070.962218.422362@pilspetsen.it.uu.se> (raw)
In-Reply-To: <4DF389D1.4090909@xaipete.org>
Robert Uhl writes:
> Hi,
>
> I wrote a small interrupt handler (for a 64 bit system) which is
> installed by a kernel module in the IDT. My handler just increments a
> global variable and then jumps to the original interrupt handler. So
> Linux does (hopefully ;-) not notice my handler. With sysfs I can read
> the value of these interrupt counter and know exactly how often a
> specific interrupt occured.
> Of course on a multicore system the interrupts of all cores are counted
> together, but I want to separate between the cores. On newer CPUs I can
> use the instruction RDTSCP to get the CPU number in ECX, but on older
> CPUs it's unsupported.
> So I had the idea to use the local APIC ID to check on which core my
> handler is executed, even though sometimes local APIC ID != core number,
> but the ID should be at least unique.
> I get the address of the local APIC ID register at module init with
>
> u64 lapic_idregister = (u64) fix_to_virt(FIX_APIC_BASE) + 0x20;
>
> and use it in my interrupt handler (of course I push/pop all used
> registers):
>
> movq (lapic_idregister), %rcx
> movq (%rcx), %rcx
You're doing a 64-bit load from a 32-bit lapic register.
> But on real hardware the last instruction seems to cause a page fault or
> something (SUSE with 2.6.37.6, Fedora with 2.6.38.6), the system simply
> reboots. Without this instruction, the handler is executed without any
> problems.
> And in qemu with vanilla 2.6.37.6 and a buildroot system everything
> works fine!
If changing the above movq (%rcx), %rcx to use movl instead makes it
work in real HW, then you've found an accepts-invalid bug in qemu.
next prev parent reply other threads:[~2011-06-12 11:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 15:29 Robert Uhl
2011-06-12 11:01 ` Mikael Pettersson [this message]
2011-06-12 12:22 ` Robert Uhl
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=19956.40070.962218.422362@pilspetsen.it.uu.se \
--to=mikpe@it.uu.se \
--cc=linux-kernel@vger.kernel.org \
--cc=ruhl@xaipete.org \
/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
all inboxes | Powered by JetHome®