← RTL Design Interviews · SoC Architecture Interviews

Interview Question · Define the Hardware–Software Contract

Who Authorizes the Camera Write?

L3 SeniorL4 Staffhardware software contracts

The Question

The interviewer asks

A guest programs a camera DMA address. The guest may rearrange its memory, but must never overwrite another guest. Draw the access that actually needs checking.

Reveal the Model Answer

Check the camera request on its way to memory. Hardware supplies a stream ID to select a translation context. An I/O memory management unit (IOMMU) first applies the guest mapping. The hypervisor’s second table limits which physical pages that guest can reach. The ap_soc has no IOMMU. S10.7 places one in ap_phone.

Self-Check

Tick each key point you covered in your answer.

What Interviewers Want to Hear (Senior)

Preserve the offset and identify exactly where each fault occurs.

Choose Your Follow-up

I’ve answered the opening question

Choose the route closest to your reasoning. Answer the follow-up aloud, then open the closing question.

I mapped the buffer for the guest.

S10.7 ends this offer with “physical=8000903c”. What address can the guest choose and what part survives both translations?

Reveal the Model Answer

Guest page 4 maps to page 2, yielding 203c. Only the hypervisor maps page 2 to physical page 80009. Offset 03c survives both lookups. At e3 write is high and SRAM reports one write with byte 63.

Self-Check

Tick each key point you covered in your answer.

Pick the Guest Isolation Boundary

Would checking the driver’s register writes suffice? What changes if the lookup takes too long for the camera?

Reveal the Model Answer

Enforce both translations on device accesses. A register check alone misses later DMA. The model spends e1 and e2 looking up the successful request. Caching translations saves lookup time but adds state. Before reassignment, stop the old stream, drain its writes, remove its mapping and clear remembered translations.

Self-Check

Tick each key point you covered in your answer.

I trusted a present guest entry.

Stream 3 next offers 503c. Its first lookup succeeds. What would show that the guest failed to give itself additional physical memory?

Reveal the Model Answer

Stage 1 returns 303c. The hypervisor has no entry for page 3. The result is “write=0 fault=1” and target writes stays one. Check no target accepted any write, including one to the zero shown on the idle address wires.

Self-Check

Tick each key point you covered in your answer.

Pick the Guest Isolation Boundary

Would checking the driver’s register writes suffice? What changes if the lookup takes too long for the camera?

Reveal the Model Answer

Enforce both translations on device accesses. A register check alone misses later DMA. The model spends e1 and e2 looking up the successful request. Caching translations saves lookup time but adds state. Before reassignment, stop the old stream, drain its writes, remove its mapping and clear remembered translations.

Self-Check

Tick each key point you covered in your answer.

I reused a known good address.

The third offer uses exactly the address that succeeded first. Why is target writes still one?

Reveal the Model Answer

Stream 7 has no context. Reject before reading either page table. Only the count staying at writes=1 distinguishes rejection here. The byte at 903c would read 63 after a second identical write too.

Self-Check

Tick each key point you covered in your answer.

Pick the Guest Isolation Boundary

Would checking the driver’s register writes suffice? What changes if the lookup takes too long for the camera?

Reveal the Model Answer

Enforce both translations on device accesses. A register check alone misses later DMA. The model spends e1 and e2 looking up the successful request. Caching translations saves lookup time but adds state. Before reassignment, stop the old stream, drain its writes, remove its mapping and clear remembered translations.

Self-Check

Tick each key point you covered in your answer.

I checked the first byte.

A 6 KiB buffer starts at 403c in stream 3. Which pages need mappings, and with which right?

Reveal the Model Answer

The last byte is 583b. Guest pages 4 and 5 both need write permission at stage one. Each resulting page also needs a writable stage-two mapping. The first successful byte tests only page 4.

Self-Check

Tick each key point you covered in your answer.

Pick the Guest Isolation Boundary

Would checking the driver’s register writes suffice? What changes if the lookup takes too long for the camera?

Reveal the Model Answer

Enforce both translations on device accesses. A register check alone misses later DMA. The model spends e1 and e2 looking up the successful request. Caching translations saves lookup time but adds state. Before reassignment, stop the old stream, drain its writes, remove its mapping and clear remembered translations.

Self-Check

Tick each key point you covered in your answer.

What People Get Wrong

Common wrong answers and why they fail.

Misconception

The guest can choose its own stream ID.

A driver could then select another device’s tables. Hardware supplies the ID.

Source S10.7, rule 2.

Misconception

Fault address zero means the target wrote ROM.

The target samples a write only with write asserted.

Source S10.7, second result and unchanged target write count.

Learn It, Then Prove It