<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 26, 2018 at 3:02 PM, Li Wang <span dir="ltr"><<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif">Hi LKML & LTP,</div><div style="font-family:arial,helvetica,sans-serif"><br></div><div style="font-family:arial,helvetica,sans-serif">LTP/meltdown.c fails on upstream kernel-v4.17-rc2 with both kvm and bare-metal system. Please attention!!!<br></div></div></blockquote><div><br></div><div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">The failure was only occurred on kvm system not include bare-matal. Sorry for that.</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">After a simple discussion with Jan, we guess the reason is that commit 8c06c774 (x86/pti: Leave kernel text global for !PCID)</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">involves new function pti_kernel_image_global_ok(void) which makes kernel use global pages when pti_mode == PTI_AUTO,</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">then LTP meltdown.c obviously easy to read the linux_banner content there. <br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">After rebooting kernel with parameter "pti=on", the FAIL is gone. So, from the result, seems LTP/meltdown.c should be improved.<br></div></div><div><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Btw, I'm not very good at this, If anything I was wrong, pls feel free to correct me.</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">============</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"> 391 * Global pages and PCIDs are both ways to make kernel TLB entries<br> 392 * live longer, reduce TLB misses and improve kernel performance.<br> 393 * But, leaving all kernel text Global makes it potentially accessible<br> 394 * to Meltdown-style attacks which make it trivial to find gadgets or<br> 395 * defeat KASLR.<br> 396 *<br> 397 * Only use global pages when it is really worth it.<br> 398 */<br> 399 static inline bool pti_kernel_image_global_ok(void)<br> 400 {<br> 401 /*<br> 402 * Systems with PCIDs get litlle benefit from global<br> 403 * kernel text and are not worth the downsides.<br> 404 */<br> 405 if (cpu_feature_enabled(X86_FEATURE_PCID))<br> 406 return false;<br> 407 <br> 408 /*<br> 409 * Only do global kernel image for pti=auto. Do the most<br> 410 * secure thing (not global) if pti=on specified.<br> 411 */<br> 412 if (pti_mode != PTI_AUTO)<br> 413 return false;<br> 414 <br> 415 /*<br> 416 * K8 may not tolerate the cleared _PAGE_RW on the userspace<br> 417 * global kernel image pages. Do the safe thing (disable<br> 418 * global kernel image). This is unlikely to ever be<br> 419 * noticed because PTI is disabled by default on AMD CPUs.<br> 420 */<br> 421 if (boot_cpu_has(X86_FEATURE_K8))<br> 422 return false;<br> 423 <br> 424 return true;<br> 425 }<br><br></div></div><br clear="all"><br>-- <br><div class="gmail_signature">Li Wang<br><a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a></div>
</div></div>