Skip to content

Commit 5d6c397

Browse files
authored
feat: add support for Svrsw60t59b extension (#1135)
1 parent b1961b2 commit 5d6c397

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

spec/std/isa/ext/Svrsw60t59b.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) Jordan Carlin, Harvey Mudd College.
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# yaml-language-server: $schema=../../../schemas/ext_schema.json
5+
6+
$schema: "ext_schema.json#"
7+
kind: extension
8+
name: Svrsw60t59b
9+
long_name: PTE Reserved-for-Software Bits 60-59
10+
type: privileged
11+
description: |
12+
== "Svrsw60t59b" Extension for PTE Reserved-for-Software Bits 60-59, Version 1.0
13+
14+
If the Svrsw60t59b extension is implemented, then bits 60-59 of the page table
15+
entries (PTEs) are reserved for use by supervisor software and are ignored by
16+
the implementation.
17+
18+
If the Hypervisor (H) extension is also implemented, then bits 60-59 of the
19+
G-stage PTEs are reserved for use by supervisor software and are ignored by the
20+
implementation.
21+
22+
The Svrsw60t59b extension depends on Sv39.
23+
24+
[NOTE]
25+
====
26+
Operating systems frequently use reserved bits within PTEs to store metadata for
27+
advanced memory management features. Embedding these metadata bits directly within
28+
the PTEs allows for fast access with minimal overhead, avoiding costly lookups in
29+
auxiliary data structures. By default, Sv39 and Sv39x4 require a page fault and
30+
a guest-page fault exception, respectively, to be raised if bits 60-59 are not
31+
zero.
32+
====
33+
versions:
34+
- version: "1.0.0"
35+
state: ratified
36+
ratification_date: 2025-08
37+
requires:
38+
name: Sv39

spec/std/isa/isa/globals.isa

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,10 +1843,16 @@ function gstage_page_walk {
18431843
PteFlags pte_flags = pte[9:0];
18441844

18451845
# check if any reserved bits are set
1846-
# Sv32 has no reserved bits, and Sv39/48/57 all have reserved bits at 60:54
1847-
if ((VA_SIZE != 32) && (pte[60:54] != 0)) {
1846+
# Sv32 has no reserved bits, and Sv39/48/57 all have reserved bits at 58:54
1847+
if ((VA_SIZE != 32) && (pte[58:54] != 0)) {
18481848
raise_guest_page_fault(op, gpaddr, vaddr, tinst, effective_mode);
18491849
}
1850+
if (!implemented?(ExtensionName::Svrsw60t59b)) {
1851+
if ((PTESIZE >= 64) && pte[60:59] != 0) {
1852+
# 60:59 are reserved if Svrsw60t59b is not supported
1853+
raise_guest_page_fault(op, gpaddr, vaddr, tinst, effective_mode);
1854+
}
1855+
}
18501856
if (!implemented?(ExtensionName::Svnapot)) {
18511857
if ((PTESIZE >= 64) && pte[63] != 0) {
18521858
# N is reserved if Svnapot is not supported
@@ -2127,8 +2133,8 @@ function stage1_page_walk {
21272133
Boolean ss_page = (pte_flags.R == 0) && (pte_flags.W == 1) && (pte_flags.X == 0);
21282134

21292135
# check if any reserved bits are set
2130-
# Sv32 has no reserved bits, and Sv39/48/57 all have reserved bits at 60:54
2131-
if ((VA_SIZE != 32) && (pte[60:54] != 0)) {
2136+
# Sv32 has no reserved bits, and Sv39/48/57 all have reserved bits at 58:54
2137+
if ((VA_SIZE != 32) && (pte[58:54] != 0)) {
21322138
raise(page_fault_code, mode(), vaddr);
21332139
}
21342140

@@ -2156,6 +2162,13 @@ function stage1_page_walk {
21562162
}
21572163
}
21582164

2165+
if (!implemented?(ExtensionName::Svrsw60t59b)) {
2166+
if ((PTESIZE >= 64) && pte[60:59] != 0) {
2167+
# 60:59 are reserved if Svrsw60t59b is not supported
2168+
raise (page_fault_code, mode(), vaddr);
2169+
}
2170+
}
2171+
21592172
if (!implemented?(ExtensionName::Svnapot)) {
21602173
if ((PTESIZE >= 64) && (pte[63] != 0)) {
21612174
# N is reserved if Svnapot is not supported

0 commit comments

Comments
 (0)