how do you properly reset the balance of call/ret stack ?

Discussion created by Czerno on Mar 14, 2009
Latest reply on Mar 31, 2009 by stroia
call return stack balancing

Hi ! I hope this is the right forum for my question, else my apology & feel free to move it to the right forum. For several generations as far as I know, AMD x86 processors have maintained an internal cache of return address and code - or maybe two such caches, one for "near" and one for "far" calls. My question : since it is possible for the cache(s) to get out of sync [ in case call/ret are not in balanced pairs], what is the recommended/most economical way to reset the balance, assuming nothing on what the present state is ? I'd like to hear both of a solution that'll work across all X86 implementations (including the competitors) and an optimal solution specific to AMD processors - if such exist - might be using specific MSRs.