From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: Add SWP/SWPB emulation for ARMv7 processors (v2)
Date: Fri, 18 Dec 2009 18:20:07 +0000 [thread overview]
Message-ID: <20091218182007.GF5527@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20091218180406.32211.72790.stgit@e101986-lin>
On Fri, Dec 18, 2009 at 06:04:06PM +0000, Leif Lindholm wrote:
> +static int swp_handler(struct pt_regs *regs, unsigned int instr)
> +{
> + unsigned int address, destreg, data;
> + unsigned int res = 0;
> + long current_pid = sys_getpid();
Kernel functions calling system calls like this is frowned upon. We
know what the current PID is - it's available from current->pid. No
function call required.
> +/*
> + * Register handler and create status file in /proc/cpu
> + * Invoked as late_initcall, since not needed before init spawned.
> + */
> +static int __init swp_emulation_init(void)
> +{
> +#ifdef CONFIG_PROC_FS
> + struct proc_dir_entry *res;
> +
> +#ifndef CONFIG_ALIGNMENT_TRAP
> + res = proc_mkdir("cpu", NULL);
> + if (!res)
> + return -ENOMEM;
> +
> + res = create_proc_entry("swp_emulation", S_IRUGO, res);
> +#else
> + res = create_proc_entry("cpu/swp_emulation", S_IRUGO, NULL);
> +#endif
This needs to be cleaned up - we should probably always create the "cpu"
directory so that these don't have to worry about whether it exists or
not.
> + NOTE: when accessing uncached shared regions, LDREX/STREX rely
> + on an external transaction monitoring block called a global
> + monitor to maintain update atomicity. If your system does not
> + implement a global monitor, this option is not safe for programs
> + that are permitted to map uncached memory (CAP_SYS_RAWIO).
We can trap this case by looking at the L_PTE_MT_* bits in the pte
for the page we're going to be accessing - that's probably a good
idea to ensure that such accesses are trapped, rather than going
head and possibly risking silent corruption.
next prev parent reply other threads:[~2009-12-18 18:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-18 18:04 [PATCH] ARM: Add SWP/SWPB emulation for ARMv7 processors (v2) Leif Lindholm
2009-12-18 18:20 ` Russell King - ARM Linux [this message]
2009-12-18 19:48 ` Jamie Lokier
2009-12-18 20:01 ` Russell King - ARM Linux
2009-12-18 19:54 ` Jamie Lokier
2009-12-18 20:03 ` Russell King - ARM Linux
2009-12-19 17:18 ` Catalin Marinas
2009-12-19 17:28 ` Russell King - ARM Linux
2010-01-04 18:18 ` Leif Lindholm
2010-01-04 19:34 ` Jamie Lokier
2010-01-05 18:09 ` Leif Lindholm
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=20091218182007.GF5527@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).