Could this code damage my processor?

前端 未结 7 706
有刺的猬
有刺的猬 2021-02-05 18:50

A friend sent me that code and alleges that it could damage the processor. Is that true?

void damage_processor() {
    while (true) {
        // Assembly code th         


        
7条回答
  •  长情又很酷
    2021-02-05 19:44

    From userspace code? No. It'll cause a privilege exception and the kernel will terminate your program. From kernel code? I doubt it; you will be throwing exceptions, and you'd have to manually set up the fault handler to return to the code in question to keep doing it. There's also a decent chance you'll cause a triple fault if part of the CR3 move succeeds, since that controls the page table address and you'll probably get faults on instruction fetch, handler fetch, and then the double fault handler fetch. The CPU should just shut down if that happens.

    Check the Intel or AMD manuals for Systems programming, they'll tell you which exceptions will be thrown when writing invalid bits to the control registers.

提交回复
热议问题