| 61 | } |
| 62 | |
| 63 | func (p *program) init() { |
| 64 | // struct bpf_cgroup_dev_ctx: https://elixir.bootlin.com/linux/v5.3.6/source/include/uapi/linux/bpf.h#L3423 |
| 65 | /* |
| 66 | u32 access_type |
| 67 | u32 major |
| 68 | u32 minor |
| 69 | */ |
| 70 | // R2 <- type (lower 16 bit of u32 access_type at R1[0]) |
| 71 | p.insts = append(p.insts, |
| 72 | asm.LoadMem(asm.R2, asm.R1, 0, asm.Half)) |
| 73 | |
| 74 | // R3 <- access (upper 16 bit of u32 access_type at R1[0]) |
| 75 | p.insts = append(p.insts, |
| 76 | asm.LoadMem(asm.R3, asm.R1, 0, asm.Word), |
| 77 | // RSh: bitwise shift right |
| 78 | asm.RSh.Imm32(asm.R3, 16)) |
| 79 | |
| 80 | // R4 <- major (u32 major at R1[4]) |
| 81 | p.insts = append(p.insts, |
| 82 | asm.LoadMem(asm.R4, asm.R1, 4, asm.Word)) |
| 83 | |
| 84 | // R5 <- minor (u32 minor at R1[8]) |
| 85 | p.insts = append(p.insts, |
| 86 | asm.LoadMem(asm.R5, asm.R1, 8, asm.Word)) |
| 87 | } |
| 88 | |
| 89 | // appendDevice needs to be called from the last element of OCI linux.resources.devices to the head element. |
| 90 | func (p *program) appendDevice(dev specs.LinuxDeviceCgroup) error { |