Tuesday, September 11, 2018

JEP 342: The JVM and Spectre

JEP 342 ("Limit Speculative Execution") has transitioned from "Draft" state to "Candidate" state, but it has not yet been targeted to a specific JDK release (see graphic for steps in JEP process). Jesper Wilhelmsson has written that JEP 342 "covers the initial work to make use of new C++ compiler options to limit speculative execution in native code in the JDK." JEP 342's "Summary" succinctly describes its purpose, "Help developers and deployers defend against speculative-execution ('Spectre') vulnerabilities by providing a means to limit speculative execution, and enable further mitigations to be implemented in future releases."

JEP 342 aims to provide a "distinct, alternate JVM in the JDK that is compiled with" C++ "compiler options that limit the extent to which the CPU can do speculative execution" and which "can be selected at launch time." The JEP states that the plan is to "include a distinct, alternate JVM in the JDK that is compiled with these options and can be selected at launch time." The JEP 342 text describes the specific C++ compilers and options affected by this JEP:

JEP 342 describes the default execution of the java launcher to continue to be as it is today (nothing to avoid speculative execution), but with the availability of a command-line flag [-nonspeculative] to disable speculative execution. The decision was made to avoid always prohibiting speculative execution because it should "be up to the end user to decide whether to limit speculative execution." The ability to choose is important because, as the JEP states, the impact of "limiting speculative execution ... can be significant for the C and C++ code in the HotSpot JVM, but it is negligible for the C and C++ code outside of the JVM." It is worth noting here that the "non-JVM code" will always be compiled with the new C++ options addressing speculative execution given that there is very little performance impact in those areas.

Spectre has been one of multiple threats to software applications and it's nice to see new possibilities for dealing with these threats potentially coming to the JVM.

No comments: