File 55780aff-x86-EFI-fix-EFI_MEMORY_WP-handling.patch of Package xen.950

# Commit af23e79f46583abc18e8cffdec0b69297cfbdff0
# Date 2015-06-10 12:01:35 +0200
# Author Jan Beulich <jbeulich@suse.com>
# Committer Jan Beulich <jbeulich@suse.com>
x86/EFI: fix EFI_MEMORY_WP handling

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Backport: Also fix EFI_MEMORY_XP handling (along the lines of what
master commit abcf15fa8f ["x86: switch default mapping attributes
to non-executable"] does): We must not set the NX bit when the CPU
doesn't support it, as the bit being set may trigger Reserved Bit
faults in that case.

--- a/xen/arch/x86/efi/boot.c
+++ b/xen/arch/x86/efi/boot.c
@@ -1622,8 +1622,8 @@ void __init efi_init_memory(void)
         }
 
         if ( desc->Attribute & EFI_MEMORY_WP )
-            prot &= _PAGE_RW;
-        if ( desc->Attribute & EFI_MEMORY_XP )
+            prot &= ~_PAGE_RW;
+        if ( (desc->Attribute & EFI_MEMORY_XP) && cpu_has_nx )
             prot |= _PAGE_NX_BIT;
 
         if ( pfn_to_pdx(emfn - 1) < (DIRECTMAP_SIZE >> PAGE_SHIFT) &&
openSUSE Build Service is sponsored by