From 45026bdbc6ea32354ca1646c18b2dc1e3144ad0d Mon Sep 17 00:00:00 2001 From: Sukuna0007Abhi Date: Thu, 4 Sep 2025 18:11:58 +0530 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20ssrdp.yaml=20file=20reference=20in=20?= =?UTF-8?q?mop.r.n.yaml=20>>=20>>=20ssrdp=20instruction=20is=20in=20Zicfis?= =?UTF-8?q?s=20directory,=20not=20Zicfilp.=20>>=20>>=20-=20Fix:=20inst/Zic?= =?UTF-8?q?filp/ssrdp.yaml#=20=E2=86=92=20inst/Zicfiss/ssrdp.yaml#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sukuna0007Abhi --- spec/std/isa/inst/Zimop/mop.r.n.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/std/isa/inst/Zimop/mop.r.n.yaml b/spec/std/isa/inst/Zimop/mop.r.n.yaml index 3c179290b3..f1829d2a4f 100644 --- a/spec/std/isa/inst/Zimop/mop.r.n.yaml +++ b/spec/std/isa/inst/Zimop/mop.r.n.yaml @@ -30,7 +30,7 @@ data_independent_timing: false hints: - { $ref: inst/Zicfilp/sspopchk.x1.yaml# } - { $ref: inst/Zicfilp/sspopchk.x5.yaml# } - - { $ref: inst/Zicfilp/ssrdp.yaml# } + - { $ref: inst/Zicfiss/ssrdp.yaml# } pseudoinstructions: - when: n == 0 to: mop.r.0 From bf502afc67ff673a3ce465093e529a06c201b42b Mon Sep 17 00:00:00 2001 From: Sukuna0007Abhi Date: Thu, 4 Sep 2025 19:52:10 +0530 Subject: [PATCH 2/2] feat: Add validation for instruction hint references Add validation to Udb::Instruction#validate method to check all hint entries by dereferencing them. This catches broken hint references early in the validation pipeline and provides clear error messages showing the specific instruction and hint index that failed. The validation runs as part of existing CI checks and will prevent future broken hint references from being introduced. Addresses mentor feedback on adding ref validation to catch issues like the recent inst/Zicfilp/ssrdp.yaml# -> inst/Zicfiss/ssrdp.yaml# fix. Signed-off-by: Sukuna0007Abhi --- tools/ruby-gems/udb/lib/udb/obj/instruction.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/ruby-gems/udb/lib/udb/obj/instruction.rb b/tools/ruby-gems/udb/lib/udb/obj/instruction.rb index 27c5f82e8f..9c38f3e6b7 100644 --- a/tools/ruby-gems/udb/lib/udb/obj/instruction.rb +++ b/tools/ruby-gems/udb/lib/udb/obj/instruction.rb @@ -327,6 +327,23 @@ def validate(resolver) Instruction.deprecated_validate_encoding(@data["encoding"]["RV64"], name) end end + + # Validate hint references + if @data.key?("hints") + @data["hints"].each_with_index do |hint, index| + if hint.key?("$ref") + begin + # Try to dereference the hint to validate it exists + hint_inst = @cfg_arch.ref(hint["$ref"]) + if hint_inst.nil? + raise "Invalid hint reference in instruction '#{name}' at hints[#{index}]: '#{hint["$ref"]}' - reference not found" + end + rescue => e + raise "Invalid hint reference in instruction '#{name}' at hints[#{index}]: '#{hint["$ref"]}' - #{e.message}" + end + end + end + end end def ==(other)