[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH] Added the logic to decode 32 bit ldr/str post-indexing instructions


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 22 Nov 2021 09:09:39 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dvlyTqJeCrv6l1qVRD5aGFi88tWPfO20qhQ4Pb3EkZI=; b=Un2u3aKGzw3QVJyYIttPyj31WvmaaGGD/CeKdlZdNGWBaFK3P4pSjAFpIGKpU3CkcrK63zSU+TS3wac+ujLK1XkyUZbIgN1dmOzK2ozExbBMtlfROeSXR1+C5Iw5e0dWD7YPnOds0EqsJJVrtOlgdwDA1MnthKQhVq6AMhcovLireNei/HheG8qVzgD+QSW6XqFObdbfc7wSs8BXaOwf9WEvDElJjHmwIK1mEZZpTjfFuHQB5fq6GMCbxA6c/l+/IiZLl/HGLrTQQYItYBXUIG3UY3y7gfDzkEO4e3BYddFKgHz17nFGRm5gejV5OGBTvjMnJNsDLQA5KCF9Fzn/eA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DgACxG9RNAaa6gkrMUO14/wWd3I74hiTMbSif4jJ3baMOosUYb6whIPgbTohf/uxa8jRDPtwAfbyuRtbGW0Xv+CO8eMfPbqRfgoSzgFJLsWXRe3WBCBIvdpCUa/XyT5JscwsOuWbe4QZdfsiOdzBvAmEy0O84yfHKapacw4XhhET9jdp7DnDb81FEsunzWQtedHT1b7LVJ4+LF4G8uVD+imV17rL3q9E5aUefh+lQHHJxnQuurpB7hDxx6WthywpmXef4iLcQLFidGJcb4nxKF2cNpECSDNU163M/qa7WCQbwMj0mfGX+um1346zcM2HZmkRc/ojoI4+lhhvFBQ5Ew==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, stefano.stabellini@xxxxxxxxxx, julien@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, bertrand.marquis@xxxxxxx, rahul.singh@xxxxxxx, ayankuma@xxxxxxxxxx
  • Delivery-date: Mon, 22 Nov 2021 08:09:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.11.2021 02:41, Stefano Stabellini wrote:
> On Fri, 19 Nov 2021, Ayan Kumar Halder wrote:
>> +static int decode_64bit_loadstore_postindexing(register_t pc, struct 
>> hsr_dabt *dabt)
>> +{
>> +    uint32_t instr;
>> +    int size;
>> +    int v;
>> +    int opc;
>> +    int rt;
>> +    int imm9;
>> +
>> +    /* For details on decoding, refer to Armv8 Architecture reference manual
>> +     * Section - "Load/store register (immediate post-indexed)", Pg 318
>> +    */
>> +    if ( raw_copy_from_guest(&instr, (void * __user)pc, sizeof (instr)) )
>> +        return -EFAULT;
>> +
>> +    /* First, let's check for the fixed values */
>> +
>> +    /*  As per the "Encoding table for the Loads and Stores group", Pg 299
>> +     * op4 = 1 - Load/store register (immediate post-indexed)
>> +     */
>> +    if ( extract32(instr, 10, 2) != 1 )
>> +        goto bad_64bit_loadstore;
>> +
>> +    /* For the following, refer to "Load/store register (immediate 
>> post-indexed)"
>> +     * to get the fixed values at various bit positions.
>> +     */
>> +    if ( extract32(instr, 21, 1) != 0 )
>> +        goto bad_64bit_loadstore;
>> +
>> +    if ( extract32(instr, 24, 2) != 0 )
>> +        goto bad_64bit_loadstore;
>> +
>> +    if ( extract32(instr, 27, 3) != 7 )
>> +        goto bad_64bit_loadstore;
>> +
>> +    size = extract32(instr, 30, 2);
>> +    v = extract32(instr, 26, 1);
>> +    opc = extract32(instr, 22, 1);
>> +
>> +    /* At the moment, we support STR(immediate) - 32 bit variant and
>> +     * LDR(immediate) - 32 bit variant only.
>> +     */
>> +    if (!((size==2) && (v==0) && ((opc==0) || (opc==1))))
>> +        goto bad_64bit_loadstore;
> 
> The opc field is actually 2 bits, not 1. I think we should get both
> bits for opc even if some of the configurations are not interesting.

Even more so that checking the value extracted from a 1-bit field
against both 0 and 1 is pointless.

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.