Agent skill

Riscv Privileged

by mohitmishra786 in mohitmishra786/low-level-dev-skills

RISC-V privileged architecture skill for M/S/U modes and traps.

MITAuto-check passed

Install Riscv Privileged

skills CLI
$ npx skills add mohitmishra786/low-level-dev-skills --skill riscv-privileged -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install mohitmishra786/low-level-dev-skills riscv-privileged --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/platform/riscv-privileged .claude/skills/riscv-privileged && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
riscv-privileged
GitHub stars
252
Token cost
~1.6k tokens
SKILL.md length
290 words
Files
1
Skills in repo
138
Repo updated
First seen
Licence
MIT

At a glance

RISC-V privileged architecture skill for M/S/U modes and traps.

  • Works in 9 steps: Privilege levels → Key CSRs → Trap handling → …
  • PLIC/CLINT interrupts
  • SKILL.md covers Purpose, When to Use, Workflow and Common Problems, plus 1 more section
  • Calls git and make; reaches github.com

What it does

Riscv Privileged is an agent skill from mohitmishra786/low-level-dev-skills. RISC-V privileged architecture skill for M/S/U modes and traps. Use when handling CSRs, trap handlers, PLIC/CLINT interrupts, OpenSBI integration, page tables Sv39/Sv48, or QEMU virt testing. Activates on queries about RISC-V privileged, mstatus, mtvec, satp, OpenSBI, PLIC, or Sv39.

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The repository describes itself as: A curated suite of AI agent skills for systems and low-level programming with C/C++, Rust, and Zig toolchains, covering compilers, debuggers, profilers, build systems…. The licence is MIT.

When your agent uses it

  • PLIC/CLINT interrupts
  • OpenSBI integration
  • Page tables Sv39/Sv48
  • QEMU virt testing

Example prompts

  • “/riscv-privileged”

Workflow steps

9 steps, taken from the step headings in SKILL.md.

  1. Privilege levels
  2. Key CSRs
  3. Trap handling
  4. Trap vector setup
  5. CLINT and PLIC
  6. OpenSBI
  7. Page tables — Sv39
  8. QEMU virt testing
  9. Reference: xv6-RISC-V

What it can do on your machine

Read from SKILL.md and the folder at commit bdc5847. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git
    • make

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Riscv Privileged loads about 1.6k tokens when it runs. Until then it costs about 75 tokens; SKILL.md has 290 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~75
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from mohitmishra786/low-level-dev-skills at commit bdc5847, republished under its MIT licence (© mohitmishra786). 290 words, ~1,648 tokens.

Download SKILL.mdSave it as .claude/skills/riscv-privileged/SKILL.md (or your agent's skills folder).
name
riscv-privileged
description
RISC-V privileged architecture skill for M/S/U modes and traps. Use when handling CSRs, trap handlers, PLIC/CLINT interrupts, OpenSBI integration, page tables Sv39/Sv48, or QEMU virt testing. Activates on queries about RISC-V privileged, mstatus, mtvec, satp, OpenSBI, PLIC, or Sv39.

RISC-V Privileged Architecture

Purpose

Guide agents through the RISC-V privileged specification: M/S/U privilege modes, CSR registers, trap handling, PLIC and CLINT interrupt controllers, OpenSBI firmware integration, Sv39/Sv48 page tables, and QEMU virt machine testing.

When to Use

  • Writing an OS kernel or hypervisor for RISC-V
  • Implementing trap handlers and context switch
  • Integrating OpenSBI for S-mode firmware services
  • Configuring interrupt controllers on QEMU virt or hardware
  • Setting up virtual memory with Sv39 or Sv48
  • Porting xv6-RISC-V or bare-metal firmware

Workflow

1. Privilege levels
RISC-V privilege stack
├── M-mode (Machine) — firmware, OpenSBI, most privileged
├── S-mode (Supervisor) — OS kernel
└── U-mode (User) — applications

Embedded (no S-mode): M + U only
2. Key CSRs
CSRModePurpose
mstatus / sstatusM/SInterrupt enable, privilege state
mtvec / stvecM/STrap vector base address
mepc / sepcM/SException PC
mcause / scauseM/STrap cause code
mtval / stvalM/SFaulting address/instruction
satpSPage table root (mode + PPN)
mie / sieM/SInterrupt enable bits
mip / sipM/SInterrupt pending bits
c
// Read CSR (GCC extended asm)
static inline uint64_t read_csr_satp(void) {
    uint64_t val;
    asm volatile("csrr %0, satp" : "=r"(val));
    return val;
}

// Write CSR
static inline void write_csr_stvec(void *handler) {
    asm volatile("csrw stvec, %0" :: "r"(handler));
}
3. Trap handling
Trap types
├── Synchronous exceptions — ecall, page fault, illegal insn
└── Asynchronous interrupts — timer, external, software
c
// scause encoding (top bit: 1=interrupt, 0=exception)
void handle_trap(uint64_t scause, uint64_t sepc, uint64_t stval) {
    if (scause & (1UL << 63)) {
        // Interrupt
        switch (scause & 0xff) {
        case 5:  // Supervisor timer interrupt
            timer_interrupt();
            break;
        case 9:  // Supervisor external interrupt
            external_interrupt();
            break;
        }
    } else {
        // Exception
        switch (scause) {
        case 8:   // ecall from U-mode
            handle_syscall();
            break;
        case 12:  // Instruction page fault
        case 13:  // Load page fault
        case 15:  // Store page fault
            handle_page_fault(stval, scause);
            break;
        }
    }
}
4. Trap vector setup
assembly
# trapvec.S — direct mode (all traps to one handler)
.section .text.trap
.globl trap_entry
.align 4
trap_entry:
    # Save registers to trap frame
    csrrw sp, sscratch, sp   # switch to kernel stack
    # ... save caller-saved ...
    csrr a0, scause
    csrr a1, sepc
    csrr a2, stval
    call handle_trap
    # ... restore ...
    sret
c
write_csr_stvec(trap_entry);
// vectored mode: mtvec[1:0] = 01, base aligned to 4×entries
5. CLINT and PLIC
QEMU virt interrupt map
├── CLINT — timer and software interrupts (per-hart)
│   ├── mtime / mtimecmp — machine timer
│   └── msip — machine software interrupt
└── PLIC — external device interrupts (UART, virtio, etc.)
    ├── priority, pending, enable per source
    └── claim/complete per hart context
c
// Timer via SBI (preferred in S-mode) or direct CLINT in M-mode
// PLIC claim
uint32_t irq = plic_claim(hart_id);
handle_device_irq(irq);
plic_complete(hart_id, irq);
6. OpenSBI
bash
# Build OpenSBI with payload (your kernel)
git clone https://github.com/riscv-software-src/opensbi
cd opensbi
make PLATFORM=generic FW_PAYLOAD_PATH=../kernel.elf FW_PAYLOAD_OFFSET=0x80200000
# Output: build/platform/generic/firmware/fw_payload.elf

SBI calls from S-mode via ecall:

c
struct sbiret sbi_set_timer(uint64_t stime) {
    return sbi_ecall(0x54494D45, 0, stime, 0, 0, 0, 0, 0);
    // Extension ID 0x54494D45 = TIME
}

Common SBI extensions: Base, Timer, IPI, RFENCE, HSM.

7. Page tables — Sv39
Sv39: 39-bit virtual addresses, 3 levels
VPN[2] → L2 PTE → L1 PTE → L0 PTE → physical page

satp: MODE(4) | ASID(9) | PPN(44)
MODE = 8 for Sv39, 9 for Sv48
c
// PTE flags
#define PTE_V  (1L << 0)  // Valid
#define PTE_R  (1L << 1)  // Read
#define PTE_W  (1L << 2)  // Write
#define PTE_X  (1L << 3)  // Execute
#define PTE_U  (1L << 4)  // User accessible

uint64_t *walk_create(uint64_t *root, uint64_t va, int alloc);
void map_page(uint64_t *root, uint64_t va, uint64_t pa, int perm);

Sv48: 4 levels, 48-bit virtual addresses (QEMU virt default on RV64).

8. QEMU virt testing
bash
qemu-system-riscv64 \
  -machine virt \
  -cpu rv64 \
  -m 128M \
  -kernel kernel.elf \
  -bios default \
  -serial mon:stdio \
  -display none \
  -no-reboot

# With OpenSBI payload
qemu-system-riscv64 \
  -machine virt -m 128M \
  -kernel opensbi/build/.../fw_payload.elf \
  -serial stdio -nographic
bash
# GDB debug
qemu-system-riscv64 -s -S ...  # port 1234, wait
riscv64-unknown-elf-gdb kernel.elf
(gdb) target remote :1234
9. Reference: xv6-RISC-V
bash
git clone https://github.com/mit-pdos/xv6-riscv
make qemu
# Study: kernel/trap.c, kernel/vm.c, kernel/start.c, kernel/plic.c

Common Problems

SymptomCauseFix
Trap loop on bootstvec misalignedAlign to 4 bytes; check handler
Page fault on entrysatp enabled before mappingIdentity-map kernel first
Timer not firingSBI vs CLINT mismatchUse sbi_set_timer in S-mode
PLIC no interruptsEnable bit not setSet priority, enable, threshold
OpenSBI hangWrong payload offsetMatch FW_PAYLOAD_OFFSET to link addr
Illegal instructionCompressed insn not supportedEnable C extension in CPU config
  • skills/low-level-programming/assembly-riscv — RV32/RV64 ISA and psABI
  • skills/kernel/os-dev-scratch — OS dev concepts (x86 parallel)
  • skills/virtualization/qemu-kvm — QEMU usage patterns
  • skills/embedded/zephyr — Zephyr on RISC-V
  • skills/kernel/kernel-internals — Linux VM and scheduler analogies
  • skills/platform/arm-sve — other architecture platform skills

© mohitmishra786, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/platform/riscv-privileged of mohitmishra786/low-level-dev-skills.

Open the folder on GitHubat commit bdc5847

Compare with similar skills

Riscv Privileged next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Riscv Privileged compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Riscv Privileged this skillmohitmishra786/low-level-dev-skills252—~1.6kAutomated safety check: PassMIT
Dynamic Workflow Modeaffaan-m/ECC276k1 repos~1.3kAutomated safety check: PassMIT
Agent GitHub Modesruvnet/ruflo74k2 repos~1.7kAutomated safety check: PassMIT
Consent Modethedaviddias/Front-End-Checklist74k—~425Automated safety check: PassMIT
Studio Moderemotion-dev/remotion63k—~313Automated safety check: PassCustom licence
Visual Moderemotion-dev/remotion63k—~477Automated safety check: PassCustom licence

Similar skills

  • Design task-local harnesses, eval gates, and reusable skill extraction for Claude dynamic workflow mode and other adaptive agent harnesses.

    276k GitHub starsUsed in 1 repo~1.3k tokens
    Auto-check passed
  • Agent GitHub Modes

    ruvnet/ruflo

    Agent skill for github-modes - invoke with $agent-github-modes

    74k GitHub starsUsed in 2 repos~1.7k tokens
    DevelopmentAuto-check passed
  • Consent Mode

    thedaviddias/Front-End-Checklist

    A skill your agent uses when auditing slow page loads, heavy assets, or rendering delays related to Implement Google Consent Mode v2.

    74k GitHub stars~425 tokensUpdated 4 days ago
    Frontend & DesignAuto-check passed
  • Studio Mode

    remotion-dev/remotion

    Official

    Understand the capabilities and restrictions of each Remotion Studio mode.

    63k GitHub stars~313 tokensUpdated yesterday
    Media & CreativeAuto-check passed
  • Visual Mode

    remotion-dev/remotion

    Official

    Guidance for working on Remotion Studio Visual Mode, sequence identity, node paths, symbolicated stacks, override IDs, and hot reload behavior.

    63k GitHub stars~477 tokensUpdated yesterday
    Media & CreativeAuto-check passed
  • Dark Mode

    sickn33/agentic-awesome-skills

    Web and App implementation guide for Dark Mode Design. An agent skill from sickn33/agentic-awesome-skills.

    47k GitHub starsUsed in 1 repo~2.8k tokens
    Frontend & DesignAuto-check passed

More from mohitmishra786/low-level-dev-skills

All 138 skills in this repo
  • ARM and AArch64 Assembly

    mohitmishra786/low-level-dev-skills

    Guides reading and writing AArch64 and ARM Thumb assembly: compiler output, inline asm, registers, the AAPCS calling convention and NEON or SVE basics.

    252 GitHub stars~1.9k tokensUpdated 3 mo ago
    Auto-check passed
  • RISC-V Assembly Guide

    mohitmishra786/low-level-dev-skills

    Reference for RISC-V assembly on RV32 and RV64: register names and calling convention, extension naming, GCC and Clang inline asm, and QEMU with GDB debugging.

    252 GitHub stars~1.8k tokensUpdated 3 mo ago
    Auto-check passed
  • x86-64 Assembly Reference

    mohitmishra786/low-level-dev-skills

    Explains x86-64 registers, the System V AMD64 calling convention, and how to read compiler-generated or inline assembly.

    252 GitHub stars~1.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Bazel for C and C++

    mohitmishra786/low-level-dev-skills

    Guides your agent through Bazel for C/C++ projects: BUILD files, Bzlmod dependencies, toolchain registration, remote execution, dependency queries and sandbox debugging.

    252 GitHub stars~1.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Binary Hardening

    mohitmishra786/low-level-dev-skills

    Binary hardening skill for security-hardened C/C++ builds. An agent skill from mohitmishra786/low-level-dev-skills.

    252 GitHub stars~2k tokensUpdated 3 mo ago
    Auto-check passed
  • Binutils

    mohitmishra786/low-level-dev-skills

    GNU binutils skill for binary manipulation and analysis. An agent skill from mohitmishra786/low-level-dev-skills.

    252 GitHub stars~1.2k tokensUpdated 3 mo ago
    Auto-check passed

Questions about Riscv Privileged

What does Riscv Privileged do?

RISC-V privileged architecture skill for M/S/U modes and traps. Riscv Privileged is an agent skill from mohitmishra786/low-level-dev-skills. RISC-V privileged architecture skill for M/S/U modes and traps.

When should I use Riscv Privileged?

Riscv Privileged fits situations like: PLIC/CLINT interrupts; openSBI integration; page tables Sv39/Sv48; QEMU virt testing.

How do I install Riscv Privileged in Claude Code?

Run `npx skills add mohitmishra786/low-level-dev-skills --skill riscv-privileged -a claude-code`. Or copy the skill folder (skills/platform/riscv-privileged in mohitmishra786/low-level-dev-skills) into .claude/skills/riscv-privileged in your project. Claude Code loads it when a task matches its description.

How do I install Riscv Privileged in Codex?

Run `npx skills add mohitmishra786/low-level-dev-skills --skill riscv-privileged -a codex`. Or copy the skill folder (skills/platform/riscv-privileged in mohitmishra786/low-level-dev-skills) into .agents/skills/riscv-privileged in your project. Codex loads it when a task matches its description.

Can I use Riscv Privileged in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mohitmishra786/low-level-dev-skills --skill riscv-privileged -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/riscv-privileged, .gemini/skills/riscv-privileged, .github/skills/riscv-privileged and .opencode/skills/riscv-privileged in your project.

What does Riscv Privileged need to run?

Going by SKILL.md and its folder, Riscv Privileged needs the command-line tools its instructions call (git and make).

Does Riscv Privileged access the network?

SKILL.md names 1 domain. In commands or code: github.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Riscv Privileged safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Riscv Privileged use?

Riscv Privileged is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Riscv Privileged use?

About 1.6k tokens (SKILL.md is roughly 6.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Riscv Privileged?

Skills that share tags, products or a category with Riscv Privileged: Dynamic Workflow Mode (affaan-m/ECC, 276k stars), Agent GitHub Modes (ruvnet/ruflo, 74k stars), Consent Mode (thedaviddias/Front-End-Checklist, 74k stars) and Studio Mode (remotion-dev/remotion, 63k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Riscv Privileged?

mohitmishra786 (a GitHub user) maintains it in mohitmishra786/low-level-dev-skills, which has 252 GitHub stars. The repository holds 138 skills in this directory. The repository was last updated on June 27, 2026.

Source: mohitmishra786/low-level-dev-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.