xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: stefano.stabellini@eu.citrix.com, tim@xen.org,
	patches@linaro.org, xen-devel@lists.xen.org
Subject: Re: [PATCH v4 1/2] xen/arm: Start to implement an ARM decoder instruction
Date: Thu, 08 Aug 2013 13:13:56 +0100	[thread overview]
Message-ID: <52038B84.30500@linaro.org> (raw)
In-Reply-To: <1375960084.970.68.camel@kazak.uk.xensource.com>

On 08/08/2013 12:08 PM, Ian Campbell wrote:
> On Tue, 2013-08-06 at 19:31 +0100, Julien Grall wrote:
>> Some erratas on ARM processor requires to decode the instruction.
> 
> Errata is already the plural of Erratum, I think.
> 
>> The decoder will, obviously, decode and fill the ISS fields of the hsr_dabt.
>>
>> For the moment, the decoder only supports:
>>     - THUMB2 store instruction
>>     - THUMB single load/store instruction
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>>
>> ---
>>     Changes in v4:
>>         - Add warning about the purpose of this function
>>         - Add helper to update ISS (register, sign, size) field of DABT
>>         - Improve decoding for THUMB 2 store instruction
>>         - Only decode thumb instruction if it's a 32-bit guest
>> ---
>>  xen/arch/arm/Makefile |    1 +
>>  xen/arch/arm/decode.c |  168 +++++++++++++++++++++++++++++++++++++++++++++++++
>>  xen/arch/arm/decode.h |   49 +++++++++++++++
>>  3 files changed, 218 insertions(+)
>>  create mode 100644 xen/arch/arm/decode.c
>>  create mode 100644 xen/arch/arm/decode.h
>>
>> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
>> index 5ae5831..5c13a65 100644
>> --- a/xen/arch/arm/Makefile
>> +++ b/xen/arch/arm/Makefile
>> @@ -30,6 +30,7 @@ obj-y += vtimer.o
>>  obj-y += vpl011.o
>>  obj-y += hvm.o
>>  obj-y += device.o
>> +obj-y += decode.o
>>  
>>  #obj-bin-y += ....o
>>  
>> diff --git a/xen/arch/arm/decode.c b/xen/arch/arm/decode.c
>> new file mode 100644
>> index 0000000..0e7d8ba
>> --- /dev/null
>> +++ b/xen/arch/arm/decode.c
>> @@ -0,0 +1,168 @@
>> +/*
>> + * xen/arch/arm/decode.c
>> + *
>> + * Instruction decoder
>> + *
>> + * Julien Grall <julien.grall@linaro.org>
>> + * Copyright (C) 2013 Linaro Limited.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <xen/types.h>
>> +#include <xen/sched.h>
>> +#include <asm/current.h>
>> +#include <asm/guest_access.h>
>> +#include <xen/lib.h>
>> +
>> +#include "decode.h"
>> +
>> +static void update_dabt(struct hsr_dabt *dabt, int reg,
>> +                        uint8_t size, bool_t sign)
>> +{
>> +    dabt->reg = reg;
>> +    dabt->size = size;
>> +    dabt->sign = sign;
>> +}
>> +
>> +/* TODO: Handle all THUMB2 instruction other than simple store */
> 
> I think we decided to remove this (and the other one).
>> +static int decode_thumb2(register_t pc, struct hsr_dabt *dabt, uint16_t hw1)
>> +{
>> +    uint16_t hw2;
>> +    int rc;
>> +    uint16_t rt;
>> +
>> +    rc = raw_copy_from_guest(&hw2, (void *__user)(pc + 2), sizeof (hw2));
>> +    if ( rc )
>> +        return rc;
>> +
>> +    rt = (hw2 >> 12) & 0x7;
>> +
>> +    switch ( (hw1 >> 9) & 0xf )
>> +    {
>> +    case 12:
>> +    {
>> +        bool_t sign = !!(hw1 & (1 << 8));
>> +        bool_t load = !!(hw1 & (1 << 4));
> 
> !! is unneeded with the bool type I think.

I have tried to remove the !! and gcc complained:
decode.c:52:28: error: overflow in implicit constant conversion
[-Werror=overflow]
         bool_t sign = (hw1 & (1 << 8));
                            ^

This is because bool_t is defined as char so the value will overflow.

-- 
Julien Grall

  parent reply	other threads:[~2013-08-08 12:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 18:31 [PATCH v4 0/2] Implement errata 766422 Julien Grall
2013-08-06 18:31 ` [PATCH v4 1/2] xen/arm: Start to implement an ARM decoder instruction Julien Grall
2013-08-08 11:08   ` Ian Campbell
2013-08-08 11:52     ` Julien Grall
2013-08-08 12:13     ` Julien Grall [this message]
2013-08-06 18:31 ` [PATCH v4 2/2] xen/arm: errata 766422: decode thumb store during data abort Julien Grall
2013-08-08 11:09   ` Ian Campbell
2013-08-08 12:04     ` Julien Grall
2013-08-08 12:12       ` Ian Campbell

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=52038B84.30500@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=patches@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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).