cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

cpu_bits.h (1769B)


      1/*
      2 *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
      3 *
      4 *  This program is free software; you can redistribute it and/or modify
      5 *  it under the terms of the GNU General Public License as published by
      6 *  the Free Software Foundation; either version 2 of the License, or
      7 *  (at your option) any later version.
      8 *
      9 *  This program is distributed in the hope that it will be useful,
     10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 *  GNU General Public License for more details.
     13 *
     14 *  You should have received a copy of the GNU General Public License
     15 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
     16 */
     17
     18#ifndef HEXAGON_CPU_BITS_H
     19#define HEXAGON_CPU_BITS_H
     20
     21#include "qemu/bitops.h"
     22
     23#define HEX_EXCP_FETCH_NO_UPAGE  0x012
     24#define HEX_EXCP_INVALID_PACKET  0x015
     25#define HEX_EXCP_INVALID_OPCODE  0x015
     26#define HEX_EXCP_PRIV_NO_UREAD   0x024
     27#define HEX_EXCP_PRIV_NO_UWRITE  0x025
     28
     29#define HEX_EXCP_TRAP0           0x172
     30
     31#define PACKET_WORDS_MAX         4
     32
     33static inline uint32_t parse_bits(uint32_t encoding)
     34{
     35    /* The parse bits are [15:14] */
     36    return extract32(encoding, 14, 2);
     37}
     38
     39static inline uint32_t iclass_bits(uint32_t encoding)
     40{
     41    /* The instruction class is encoded in bits [31:28] */
     42    uint32_t iclass = extract32(encoding, 28, 4);
     43    /* If parse bits are zero, this is a duplex */
     44    if (parse_bits(encoding) == 0) {
     45        iclass += 16;
     46    }
     47    return iclass;
     48}
     49
     50static inline bool is_packet_end(uint32_t endocing)
     51{
     52    uint32_t bits = parse_bits(endocing);
     53    return ((bits == 0x3) || (bits == 0x0));
     54}
     55
     56int disassemble_hexagon(uint32_t *words, int nwords, bfd_vma pc, GString *buf);
     57
     58#endif