Skip to content

Add basic riscv64 architecture support#18

Merged
jpm-canonical merged 6 commits into
canonical:mainfrom
vhaudiquet:riscv64
Jun 18, 2026
Merged

Add basic riscv64 architecture support#18
jpm-canonical merged 6 commits into
canonical:mainfrom
vhaudiquet:riscv64

Conversation

@vhaudiquet

Copy link
Copy Markdown
Contributor

This adds basic riscv64 architecture support.
It allows building the snap on riscv64, and then running basic commands:

ubuntu@p550:~$ lscompute
{
  "cpus": [
    {
      "architecture": "riscv64",
      "isa": [
        "rv64imafdch",
        "zicsr",
        "zifencei",
        "zba",
        "zbb",
        "sscofpmf"
      ]
    }
  ],
  "memory": {
    "total-ram": 16743100416,
    "total-swap": 0
  },
  "disk": {
    "/var/lib/snapd/snaps": {
      "total": 125930070016,
      "avail": 14488858624
    }
  },
  "devices": [
    {
      "bus": "pci",
      "slot": "0000:00:00.0",
      "bus-number": "0x0",
      "device-class": "0x604",
      "vendor-id": "0x1FE1",
      "device-id": "0x2030",
      "subvendor-id": "0x0",
      "subdevice-id": "0x0",
      "vendor-name": "Beijing ESWIN Computing Technology Co., Ltd.",
      "device-name": "EIC7700 Root Complex"
    },
    {
      "bus": "usb",
      "bus-number": 3,
      "device-number": 2,
      "vendor-id": "0x5E3",
      "product-id": "0x610",
      "vendor-name": "Genesys Logic, Inc.",
      "product-name": "Hub"
    },
    {
      "bus": "usb",
      "bus-number": 4,
      "device-number": 2,
      "vendor-id": "0x5E3",
      "product-id": "0x620",
      "vendor-name": "Genesys Logic, Inc.",
      "product-name": "GL3523 Hub"
    },
    {
      "bus": "usb",
      "bus-number": 1,
      "device-number": 1,
      "vendor-id": "0x1D6B",
      "product-id": "0x2",
      "vendor-name": "Linux Foundation",
      "product-name": "2.0 root hub"
    },
    {
      "bus": "usb",
      "bus-number": 2,
      "device-number": 1,
      "vendor-id": "0x1D6B",
      "product-id": "0x3",
      "vendor-name": "Linux Foundation",
      "product-name": "3.0 root hub"
    },
    {
      "bus": "usb",
      "bus-number": 3,
      "device-number": 1,
      "vendor-id": "0x1D6B",
      "product-id": "0x2",
      "vendor-name": "Linux Foundation",
      "product-name": "2.0 root hub"
    },
    {
      "bus": "usb",
      "bus-number": 4,
      "device-number": 1,
      "vendor-id": "0x1D6B",
      "product-id": "0x3",
      "vendor-name": "Linux Foundation",
      "product-name": "3.0 root hub"
    }
  ]
}

See also Original PR to inference-snaps-cli

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds baseline riscv64 support to lscompute’s CPU detection and Snap packaging, plus a new SiFive P550 Premier machine fixture to exercise the end-to-end pipeline on riscv64.

Changes:

  • Extend CPU parsing/model to include a riscv64 isa field sourced from /proc/cpuinfo.
  • Update Snap build logic so nvidia-smi is only pulled/used on supported architectures and provides a stub elsewhere.
  • Add a new test_data/machines/sifive-p550-premier fixture and tests covering riscv64 dispatch + full Info() pipeline.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test_data/machines/sifive-p550-premier/machine-root/sys/bus/pci/devices/0000:00:00.0/vendor Adds PCI vendor ID fixture data for the P550 machine.
test_data/machines/sifive-p550-premier/machine-root/sys/bus/pci/devices/0000:00:00.0/subsystem_vendor Adds PCI subsystem vendor fixture data for the P550 machine.
test_data/machines/sifive-p550-premier/machine-root/sys/bus/pci/devices/0000:00:00.0/subsystem_device Adds PCI subsystem device fixture data for the P550 machine.
test_data/machines/sifive-p550-premier/machine-root/sys/bus/pci/devices/0000:00:00.0/device Adds PCI device ID fixture data for the P550 machine.
test_data/machines/sifive-p550-premier/machine-root/sys/bus/pci/devices/0000:00:00.0/class Adds PCI class fixture data for the P550 machine.
test_data/machines/sifive-p550-premier/machine-root/run/disk-stats.json Adds disk stats fixture data for end-to-end machine parsing.
test_data/machines/sifive-p550-premier/machine-root/proc/sys/kernel/arch Adds riscv64 arch fixture input for architecture detection.
test_data/machines/sifive-p550-premier/machine-root/proc/meminfo Adds meminfo fixture input for memory parsing.
test_data/machines/sifive-p550-premier/machine-root/proc/cpuinfo Adds riscv64 cpuinfo fixture input for CPU parsing.
snap/snapcraft.yaml Makes nvidia-smi packaging arch-aware and provides a stub on unsupported arches.
pkg/machine/cpu/types.go Adds isa field to CPU output model and internal proc structure for riscv64.
pkg/machine/cpu/proc_cpuinfo.go Adds riscv64 /proc/cpuinfo parsing and dispatcher routing.
pkg/machine/cpu/proc_cpuinfo_test.go Adds riscv64 cpuinfo fixture and dispatcher test coverage.
pkg/machine/cpu/cpu.go Maps parsed riscv64 ISA into the exported CpuInfo.
pkg/machine/cpu/cpu_test.go Adds riscv64 end-to-end fixture test coverage for Info() and infoFromRawData().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/machine/cpu/proc_cpuinfo.go

@jpm-canonical jpm-canonical left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have access to a riscv machine, nor can I get access to one on testflinger.

I did a code review, and I am happy with these changes.

I also added another riscv64 machine to the test_data. We had this test set from before but never added it here because riscv was not supported. This machine also passes the tests.

vhaudiquet and others added 6 commits June 18, 2026 10:00
Scoped nvidia-smi part to amd64/arm64, with wrapper error message on riscv64

Signed-off-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Signed-off-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Signed-off-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Signed-off-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Signed-off-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
@jpm-canonical jpm-canonical merged commit c8220ea into canonical:main Jun 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants