From c59841dc49fdd33ade4d5302cd1784df7fe4d36e Mon Sep 17 00:00:00 2001 From: James Ball Date: Wed, 4 Dec 2024 10:21:06 -0800 Subject: [PATCH] Back out code to attempt to ensure required extension versions are in the DB. --- arch/csr/menvcfg.yaml | 3 ++- arch/csr/senvcfg.yaml | 7 ++++--- arch/ext/S.yaml | 8 +++++++- arch/ext/Sm.yaml | 1 + lib/arch_obj_models/extension.rb | 8 -------- lib/arch_obj_models/portfolio.rb | 26 +++++++++----------------- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/arch/csr/menvcfg.yaml b/arch/csr/menvcfg.yaml index 31b2d7e99..e1732fe2a 100644 --- a/arch/csr/menvcfg.yaml +++ b/arch/csr/menvcfg.yaml @@ -6,7 +6,8 @@ name: menvcfg address: 0x30A long_name: Machine Environment Configuration description: | - Contains bits to enable/disable extensions + Contains fields that control certain characteristics of the execution environment + for modes less privileged than M-mode. The `menvcfg` CSR controls certain characteristics of the execution environment for modes less diff --git a/arch/csr/senvcfg.yaml b/arch/csr/senvcfg.yaml index e804e5aae..025095bbb 100644 --- a/arch/csr/senvcfg.yaml +++ b/arch/csr/senvcfg.yaml @@ -5,14 +5,15 @@ kind: csr name: senvcfg address: 0x10A long_name: Supervisor Environment Configuration -description: Contains bits to enable/disable extensions +description: | + Contains fields that control certain characteristics of the U-mode execution environment. priv_mode: S length: 64 definedBy: allOf: - - name: Sm - version: ">=1.12" - name: S + version: ">=1.12" + - name: U fields: CBZE: location: 7 diff --git a/arch/ext/S.yaml b/arch/ext/S.yaml index 34e33bc92..1b6a3ec96 100644 --- a/arch/ext/S.yaml +++ b/arch/ext/S.yaml @@ -6,12 +6,18 @@ name: S type: privileged long_name: Supervisor mode versions: +- version: "1.11.0" + state: ratified + ratification_date: 2019-06 + requires: + name: U + version: ">= 1.0.0" - version: "1.12.0" state: ratified ratification_date: 2021-12 requires: name: U - version: "= 1.12.0" + version: ">= 1.0.0" description: | This chapter describes the RISC-V supervisor-level architecture, which contains a common core that is used with various supervisor-level diff --git a/arch/ext/Sm.yaml b/arch/ext/Sm.yaml index 47b5a40a6..1686c9922 100644 --- a/arch/ext/Sm.yaml +++ b/arch/ext/Sm.yaml @@ -460,6 +460,7 @@ params: schema: type: string enum: [little, big, dynamic] + # TODO: Only little available in Sm 1.11 MISA_CSR_IMPLEMENTED: description: | Whether or not the `misa` CSR returns zero or a non-zero value. diff --git a/lib/arch_obj_models/extension.rb b/lib/arch_obj_models/extension.rb index 8f652766a..443480360 100644 --- a/lib/arch_obj_models/extension.rb +++ b/lib/arch_obj_models/extension.rb @@ -637,14 +637,6 @@ def satisfying_versions(archdef) ext.versions.select { |v| @requirement.satisfied_by?(v.version) } end - # @return [Boolean] True if any extension version satifies this requirement - # @param [Extension] The extension object that contains one or more versions - def satisfied_by_ext?(ext) - return false if ext.nil? - - ext.versions.any? { |v| @requirement.satisfied_by?(v.version) } - end - # @overload # @param extension_version [ExtensionVersion] A specific extension version # @return [Boolean] whether or not the extension_version meets this requirement diff --git a/lib/arch_obj_models/portfolio.rb b/lib/arch_obj_models/portfolio.rb index 701c57f4d..002d3dd94 100644 --- a/lib/arch_obj_models/portfolio.rb +++ b/lib/arch_obj_models/portfolio.rb @@ -136,6 +136,14 @@ def in_scope_ext_reqs(desired_presence = nil) missing_ext = false @data["extensions"]&.each do |ext_name, ext_data| + # Does extension even exist? + # If not, don't raise an error right away so we can find all of the missing extensions and report them all. + ext = arch_def.extension(ext_name) + if ext.nil? + puts "Extension #{ext_name} for #{name} not found in database" + missing_ext = true + end + actual_presence = ext_data["presence"] # Could be a String or Hash raise "Missing extension presence for extension #{ext_name}" if actual_presence.nil? @@ -143,24 +151,8 @@ def in_scope_ext_reqs(desired_presence = nil) actual_presence_obj = ExtensionPresence.new(actual_presence) if desired_presence.nil? || (actual_presence_obj == desired_presence_converted) - version_data = ext_data["version"] - - ext_req = - ExtensionRequirement.new(ext_name, version_data, presence: actual_presence_obj, + in_scope_ext_reqs << ExtensionRequirement.new(ext_name, ext_data["version"], presence: actual_presence_obj, note: ext_data["note"], req_id: "REQ-EXT-" + ext_name) - - # Does extension even exist? - # If not, don't raise an error right away so we can find all of the missing extensions and report them all. - ext = arch_def.extension(ext_name) - if ext.nil? - puts "Extension #{ext_name} for #{name} not found in database" - missing_ext = true - else - # Okay, so extension exists. Can the extension requirement be met? - raise "No version of extension #{ext_name} in #{name} satifies the extension requirement #{version_data}" unless ext_req.satisfied_by_ext?(ext) - end - - in_scope_ext_reqs << ext_req end end