Skip to content

Commit

Permalink
HACK to work around a TLB exception when booting
Browse files Browse the repository at this point in the history
When building the kernel with dev branch clang I get the following when
booting:
```
Trap cause = 2 (TLB miss (load or instr. fetch) - kernel mode)
[ thread pid 2 tid 100015 ]
Stopped at      ata_zac_mgmt_in+0x29c4: lbu     at,1016(v1)
```

The actual location is `path->device->inq_flags |= SID_DMA` inside
probefunc in ata_xpt.c. The crash doesn't happen with the nosp branch
but the only difference I can see in the generated code is that the dev
branch hoists the load of path->device before the if statement.
What's even weirder is that when I single step with GDB it will fail
when loading exactly the address that is printed by the printf().
  • Loading branch information
arichardson committed Oct 19, 2017
1 parent 3cbfcb4 commit 44e9de3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sys/cam/ata/ata_xpt.c
Expand Up @@ -459,6 +459,13 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
/* If SIM disagree - renegotiate. */
if (mode != wantmode)
goto negotiate;

/* XXXAR: without the printf the following load of
* path->device_inq_flags causes a TLB miss when compiled
* with the latest clang. Possibly there is some strict
* aliasing error? */
printf("ata_xpt crash workaround: path=%p, path->device=%p\n",
path, path->device);
/* Remember what transport thinks about DMA. */
if (mode < ATA_DMA)
path->device->inq_flags &= ~SID_DMA;
Expand Down

0 comments on commit 44e9de3

Please sign in to comment.