If ARMv7 boots in HYP mode, switch to SVC32.
Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Differential D1810
Leave HYP mode upon startup jpa-semihalf.com on Feb 9 2015, 11:52 AM. Authored by Tags None Referenced Files
Details
If ARMv7 boots in HYP mode, switch to SVC32. Submitted by: Wojciech Macek <wma@semihalf.com>
Diff Detail
Event TimelineComment Actions This seems reasonable, but I'm not knowledgeable enough about hyper mode to know if this is really good or not.
Comment Actions What about when we're ready to do something with hyper mode? The Zen guys bug us every once in a while to check out their patches because they have Dom0 support for us now (not sure how complete it is), is this just going to make their lives even harder? (I guess if I had ever even glanced at their patches I might know the answer to that.)
Comment Actions Replies from Wojciech Macek (who doesn't have direct write access here)
Yep, it might be not necessary. I was testing it on the revision which did not have br_prod_tail atomic. I've just removed it and run the test again, but it will take about 24h, cause the reproduction rate is really low.
I wouldn't say that it prevents reordering here. It rather guarantees observability of the valid data. Im my scenario I'm running drdb_dequeue_sc/buf_ring_dequeue_sc few times in the loop. It's inline, so the compiler puts them inside the loop's body. I suspect, that the issue is possible only on cortex-a15, due to its long pipeline and advanced branch predictors. In normal case, where the ring is empty, the dequeue_sc returns NULL. But the core wants to optimize memmory accessess, so there is a chance that it preloads its readbuffers with a data that can be used in further code execution. The cons_head does not change within the function, so there is no reason why the core shouldn't early-load the br->br_ring[cons_head] pointer, which might be outdated. The core just has no knowledge that the data is valid only when prod_tail changes. Nevertheless, without rmb the buffer did not work properly - dequeue function returned some "old" mbuf which left there from the previous pass. This is basically how I found this bug.
Comment Actions You probably additionally should install a stub vector allowing to go back to HYP mode if necessary and deal with the timers. FYI, the corresponding Bitrig change is: https://github.com/Bluerise/bitrig/commit/e1f661110a9a2e38ae0c00c4e394194ee0491a78 Comment Actions From W. Macek: I don't like to mess with hyp vector here from two reasons. This patch is intended to be simple doing as few changes as it could. On the other hand, some uboots provide an interface for safe hw peripheral acces using smc instruction. I think that would require more talks to find a proper solution, which is not the part of the current fix.
Comment Actions It looks like there is support for eret in llvm http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141201/246665.html. Can you test with this, if it works we can pull it into FreeBSD. Comment Actions This patch doesn't work (Toolchain will not compile). Comment Actions Can you wait for a few days. The change is part of llvm 3.6 which should be imported soon. We would still need to either stop supporting gcc on armv6 or fix binutils to also handle the instructions.
Comment Actions We now have clang 3.6 in the tree so you should be able to use the instructions directly. Comment Actions Do you have any concerns regarding these changes? If so, please, let me know. Comment Actions This is Yes. We still care. While it may not be for long, we still support building arm with gcc in the tree. Comment Actions This is a polished version of previous commit:
Comment Actions This is yet another revision of this patch, after out-of-band discussion with Warner, so should be much closer to a final version. Comment Actions This fell off my todo list to review... Sorry. This looks good apart from the weird #ifdef nesting you have there.
|