From: Jan Kiszka <[email protected]>

Reorder reloading of cr3 and cr4 in case the latter enables PCID (which
Jailhouse does not use) and cr3 should be fully evaluated under that
feature.

Fixes a protection fault when disabling Jailhouse on PCID-enabled
systems (since kernel 4.14).

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/x86/setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hypervisor/arch/x86/setup.c b/hypervisor/arch/x86/setup.c
index d3777584..60466367 100644
--- a/hypervisor/arch/x86/setup.c
+++ b/hypervisor/arch/x86/setup.c
@@ -255,8 +255,9 @@ void arch_cpu_restore(struct per_cpu *cpu_data, int 
return_code)
        write_msr(MSR_IA32_PAT, cpu_data->pat);
        write_msr(MSR_EFER, cpu_data->linux_efer);
        write_cr0(cpu_data->linux_cr0);
-       write_cr3(cpu_data->linux_cr3);
        write_cr4(cpu_data->linux_cr4);
+       /* cr3 must be last in case cr4 enables PCID */
+       write_cr3(cpu_data->linux_cr3);
 
        /*
         * Copy Linux TSS descriptor into our GDT, clearing the busy flag,
-- 
2.12.3

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to