-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial memory versioning implementation.
It is incomplete and may be slow / buggy notably: 1) version checks are performed during capability permissions checks, using the iotlb to cache a pointer to version memory, which is allocated alongside tag memory in cheri_tagmem.c. It uses one byte per version instead of a nibble like the ARM MTE so a bit space inefficient. 2) Loads and stores via DDC will throw an exception if DDC is versioned. 3) No system register. Note that this is the result of rebasing against upstream and simultaneously squashing the previous branch. There had been quite a lot of upstream changes with conflicts and some not very interesting history so it turned out to be easier that way.
- Loading branch information
Showing
31 changed files
with
662 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* | ||
* Copyright (c) 2016-2017 Michael Clark <[email protected]> | ||
* Copyright (c) 2017-2018 SiFive, Inc. | ||
* Copyright (c) 2021 Microsoft <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
|
@@ -517,6 +518,9 @@ typedef enum { | |
rv_op_cgetaddr, | ||
rv_op_csealentry, | ||
rv_op_cloadtags, | ||
rv_op_cgetversion, | ||
rv_op_cloadversion, | ||
rv_op_cstoreversion, | ||
|
||
// Three operand | ||
rv_op_cspecialrw, | ||
|
@@ -537,6 +541,8 @@ typedef enum { | |
rv_op_ccseal, | ||
rv_op_ctestsubset, | ||
rv_op_cseqx, | ||
rv_op_csetversion, | ||
rv_op_camocdecversion, | ||
|
||
// FP loads/store | ||
rv_op_cflw, | ||
|
@@ -662,6 +668,7 @@ static const char rv_freg_name_sym[32][5] = { | |
#define rv_fmt_cd_rs1 "O\tC0,1" | ||
#define rv_fmt_rs1_offset "O\t1,o" | ||
#define rv_fmt_rs2_offset "O\t2,o" | ||
#define rv_fmt_cs1_rs2 "O\tC1,2" | ||
|
||
/* pseudo-instruction constraints */ | ||
|
||
|
@@ -1234,6 +1241,9 @@ const rv_opcode_data opcode_data[] = { | |
[rv_op_cgetaddr] = { "cgetaddr", rv_codec_r, rv_fmt_rd_cs1, NULL, 0, 0, 0 }, | ||
[rv_op_csealentry] = { "csealentry", rv_codec_r, rv_fmt_cd_cs1, NULL, 0, 0, 0 }, | ||
[rv_op_cloadtags] = { "cloadtags", rv_codec_r, rv_fmt_rd_cs1, NULL, 0, 0, 0 }, | ||
[rv_op_cgetversion] = { "cgetversion", rv_codec_r, rv_fmt_rd_cs1, NULL, 0, 0, 0 }, | ||
[rv_op_cloadversion] = { "cloadversion", rv_codec_r, rv_fmt_rd_cs1, NULL, 0, 0, 0 }, | ||
[rv_op_cstoreversion] = { "cstoreversion", rv_codec_r, rv_fmt_cs1_rs2, NULL, 0, 0, 0 }, | ||
|
||
// capmode loads: | ||
[rv_op_clb] = { "clb", rv_codec_i, rv_fmt_rd_offset_cs1, NULL, 0, 0, 0 }, | ||
|
@@ -1268,6 +1278,8 @@ const rv_opcode_data opcode_data[] = { | |
[rv_op_ccseal] = { "ccseal", rv_codec_r, rv_fmt_cd_cs1_cs2, NULL, 0, 0, 0 }, | ||
[rv_op_ctestsubset] = { "ctestsubset", rv_codec_r, rv_fmt_rd_cs1_cs2, NULL, 0, 0, 0 }, | ||
[rv_op_cseqx] = { "cseqx", rv_codec_r, rv_fmt_rd_cs1_cs2, NULL, 0, 0, 0 }, | ||
[rv_op_csetversion] = { "csetversion", rv_codec_r, rv_fmt_cd_cs1_rs2, NULL, 0, 0, 0 }, | ||
[rv_op_camocdecversion] = { "camocdecversion", rv_codec_r, rv_fmt_rd_cs1_cs2, 0, 0, 0 }, | ||
|
||
// FP load store | ||
[rv_op_cflw] = { "cflw", rv_codec_i, rv_fmt_frd_offset_cs1, NULL, 0, 0, 0 }, | ||
|
@@ -1503,6 +1515,17 @@ static rv_opcode decode_cheri_two_op(unsigned func) { | |
case 0b01111: return rv_op_cgetaddr; | ||
case 0b10001: return rv_op_csealentry; | ||
case 0b10010: return rv_op_cloadtags; | ||
case 0b10011: return rv_op_cgetversion; | ||
// case 0b10101: return rv_op-cloadversions; // XXX not yet | ||
case 0b10110: return rv_op_cloadversion; | ||
default: return rv_op_illegal; | ||
} | ||
} | ||
|
||
static rv_opcode decode_cheri_two_src_op(unsigned func) { | ||
switch (func) { | ||
//case 0b00001: return rv_op_cinvoke; TODO | ||
case 0b00010: return rv_op_cstoreversion; | ||
default: return rv_op_illegal; | ||
} | ||
} | ||
|
@@ -1517,7 +1540,9 @@ static rv_opcode decode_cheri_inst(rv_inst inst) { | |
switch (func) { | ||
// 0000000, unused | ||
CHERI_THREEOP_CASE(cspecialrw, 0000001, ..... ..... 000 ..... 1011011 @r) | ||
// 0000010-0000111 unused | ||
CHERI_THREEOP_CASE(csetversion, 0000010, ..... ..... 000 ..... 1011011 @r) | ||
CHERI_THREEOP_CASE(camocdecversion, 0000011, ..... ..... 000 ..... 1011011 @r) | ||
// 0000100-0000111 unused | ||
CHERI_THREEOP_CASE(csetbounds, 0001000, ..... ..... 000 ..... 1011011 @r) | ||
CHERI_THREEOP_CASE(csetboundsexact, 0001001, ..... ..... 000 ..... 1011011 @r) | ||
// 0001010 unused | ||
|
@@ -1540,7 +1565,9 @@ static rv_opcode decode_cheri_inst(rv_inst inst) { | |
// 1111011 unused | ||
// TODO: 1111100 Used for Stores (see below) | ||
// TODO: 1111101 Used for Loads (see below) | ||
// TODO: 1111110 Used for two source ops | ||
// 1111110 Used for two source ops | ||
case 0b111110: | ||
return decode_cheri_two_src_op((inst >> 7) & 0b11111); | ||
// 1111111 Used for Source & Dest ops (see above) | ||
case 0b111111: | ||
return decode_cheri_two_op((inst >> 20) & 0b11111); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
* Copyright (c) 2018-2020 Alex Richardson | ||
* Copyright (c) 2021 Microsoft <[email protected]> | ||
* All rights reserved. | ||
* | ||
* This software was developed by SRI International and the University of | ||
|
@@ -56,6 +57,8 @@ | |
* Morello embeds the user permissions in the middle of the hardware permissions. | ||
*/ | ||
|
||
#define CC_HAVE_VERSION 1 | ||
|
||
// The following macros are expected to be defined | ||
#undef CC_BITS | ||
#define CC_BITS 128 | ||
|
@@ -125,7 +128,12 @@ enum { | |
_CC_FIELD(HWPERMS, 123, 112), | ||
_CC_FIELD(RESERVED, 111, 110), | ||
_CC_FIELD(FLAGS, 109, 109), | ||
#ifdef CC_HAVE_VERSION | ||
_CC_FIELD(VERSION, 108, 105), | ||
_CC_FIELD(OTYPE, 104, 91), | ||
#else | ||
_CC_FIELD(OTYPE, 108, 91), | ||
#endif | ||
_CC_FIELD(EBT, 90, 64), | ||
|
||
_CC_FIELD(INTERNAL_EXPONENT, 90, 90), | ||
|
@@ -149,6 +157,7 @@ enum { | |
#define CC128_BOT_WIDTH CC128_FIELD_EXP_ZERO_BOTTOM_SIZE | ||
#define CC128_BOT_INTERNAL_EXP_WIDTH CC128_FIELD_EXP_NONZERO_BOTTOM_SIZE | ||
#define CC128_EXP_LOW_WIDTH CC128_FIELD_EXPONENT_LOW_PART_SIZE | ||
#define CC128_VERSION_BITS CC128_FIELD_VERSION_SIZE | ||
|
||
#ifdef CC_IS_MORELLO | ||
|
||
|
@@ -244,14 +253,25 @@ enum _CC_N(OTypes) { | |
|
||
_CC_STATIC_ASSERT_SAME(CC128_MANTISSA_WIDTH, CC128_FIELD_EXP_ZERO_BOTTOM_SIZE); | ||
|
||
#ifdef CC_HAVE_VERSION | ||
enum _CC_N(Versions) { | ||
CC128_VERSION_UNVERSIONED = 0, | ||
CC128_MAX_VERSION = ((1u << CC128_VERSION_BITS) - 1u), | ||
}; | ||
#endif | ||
|
||
#include "cheri_compressed_cap_common.h" | ||
|
||
// Sanity-check mask is the expected NULL encoding | ||
#ifdef CC_IS_MORELLO | ||
_CC_STATIC_ASSERT_SAME(CC128_NULL_XOR_MASK, UINT64_C(0x0000000040070007)); | ||
#else | ||
#ifdef CC_HAVE_VERSION | ||
_CC_STATIC_ASSERT_SAME(CC128_NULL_XOR_MASK, UINT64_C(0x000001fffc018004)); | ||
#else | ||
_CC_STATIC_ASSERT_SAME(CC128_NULL_XOR_MASK, UINT64_C(0x00001ffffc018004)); | ||
#endif | ||
#endif | ||
|
||
__attribute__((deprecated("Use cc128_compress_raw"))) static inline uint64_t | ||
compress_128cap_without_xor(const cc128_cap_t* csp) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
* Copyright (c) 2018-2020 Alex Richardson | ||
* Copyright (c) 2021 Microsoft <[email protected]> | ||
* All rights reserved. | ||
* | ||
* This software was developed by SRI International and the University of | ||
|
@@ -84,6 +85,7 @@ enum { | |
_CC_FIELD(EXPONENT_LOW_PART, 34, 32), | ||
_CC_FIELD(RESERVED, 31, 32), /* No reserved bits */ | ||
_CC_FIELD(UPERMS, 31, 32), /* No uperms */ | ||
_CC_FIELD(VERSION, 31, 32), /* No version */ | ||
}; | ||
#pragma GCC diagnostic pop | ||
_CC_STATIC_ASSERT_SAME(CC64_FIELD_UPERMS_SIZE, 0); | ||
|
Oops, something went wrong.