From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Stepan Moskovchenko <stepanm@codeaurora.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
linux-kernel@vger.kernel.org, bryanh@codeaurora.org,
David Brown <davidb@codeaurora.org>,
Leif Lindholm <leif.lindholm@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm: Add condition code check to SWP emulator
Date: Sun, 20 Nov 2011 08:41:11 +0000 [thread overview]
Message-ID: <20111120084111.GM9581@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1321751070-7932-1-git-send-email-stepanm@codeaurora.org>
On Sat, Nov 19, 2011 at 05:04:30PM -0800, Stepan Moskovchenko wrote:
> +static int check_condition(struct pt_regs *regs, unsigned int insn)
> +{
> + unsigned int base_cond, neg, cond = 0;
> + unsigned int cpsr_z, cpsr_c, cpsr_n, cpsr_v;
> +
> + cpsr_n = (regs->ARM_cpsr & PSR_N_BIT) ? 1 : 0;
> + cpsr_z = (regs->ARM_cpsr & PSR_Z_BIT) ? 1 : 0;
> + cpsr_c = (regs->ARM_cpsr & PSR_C_BIT) ? 1 : 0;
> + cpsr_v = (regs->ARM_cpsr & PSR_V_BIT) ? 1 : 0;
> +
> + /* Upper 3 bits indicate condition, lower bit incicates negation */
> + base_cond = insn >> 29;
> + neg = insn & BIT(28) ? 1 : 0;
> +
> + switch (base_cond) {
> + case 0x0: /* equal */
> + cond = cpsr_z;
> + break;
> +
> + case 0x1: /* carry set */
> + cond = cpsr_c;
> + break;
> +
> + case 0x2: /* minus / negative */
> + cond = cpsr_n;
> + break;
> +
> + case 0x3: /* overflow */
> + cond = cpsr_v;
> + break;
> +
> + case 0x4: /* unsigned higher */
> + cond = (cpsr_c == 1) && (cpsr_z == 0);
> + break;
> +
> + case 0x5: /* signed greater / equal */
> + cond = (cpsr_n == cpsr_v);
> + break;
> +
> + case 0x6: /* signed greater */
> + cond = (cpsr_z == 0) && (cpsr_n == cpsr_v);
> + break;
> +
> + case 0x7: /* always */
> + cond = 1;
> + break;
> + };
> +
> + return cond && !neg;
There's a much better algorithm to check this. See the bottom of
arch/arm/nwfpe/fpopcode.c.
It would probably be best for there to be a common function for doing
this kind of check, rather than having several implementations of it
scattered around the kernel.
next prev parent reply other threads:[~2011-11-20 8:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAHkRjk6Ynfh9+UbTuAtyiXCOF-yDbTNxi0ikF5ttwHViisZRZA@mail.gmail.com>
2011-11-20 1:04 ` Stepan Moskovchenko
2011-11-20 8:41 ` Russell King - ARM Linux [this message]
2011-11-20 10:55 ` Catalin Marinas
2011-11-21 18:35 ` 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=20111120084111.GM9581@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=bryanh@codeaurora.org \
--cc=catalin.marinas@arm.com \
--cc=davidb@codeaurora.org \
--cc=leif.lindholm@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stepanm@codeaurora.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®