From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH 4/4] x86/EFI: adjust EFI_MEMORY_WP handling for spec version 2.5 Date: Tue, 09 Jun 2015 14:54:21 +0100 Message-ID: <55770C2D0200007800082A4B@mail.emea.novell.com> References: <55770B190200007800082A2C@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartA692881D.0__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z2Jz0-0005pV-NQ for xen-devel@lists.xenproject.org; Tue, 09 Jun 2015 13:54:27 +0000 In-Reply-To: <55770B190200007800082A2C@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartA692881D.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline That flag now means cachability rather than protection, and a new flag EFI_MEMORY_RO got added in its place. Signed-off-by: Jan Beulich --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -32,6 +32,8 @@ /* Using SetVirtualAddressMap() is incompatible with kexec: */ #undef USE_SET_VIRTUAL_ADDRESS_MAP =20 +#define EFI_REVISION(major, minor) (((major) << 16) | (minor)) + #define SMBIOS3_TABLE_GUID \ { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, = 0xe3, 0x94} } #define SHIM_LOCK_PROTOCOL_GUID \ @@ -78,6 +80,7 @@ static int set_color(u32 mask, int bpp,=20 static bool_t match_guid(const EFI_GUID *guid1, const EFI_GUID *guid2); =20 static const EFI_BOOT_SERVICES *__initdata efi_bs; +static UINT32 __initdata efi_bs_revision; static EFI_HANDLE __initdata efi_ih; =20 static SIMPLE_TEXT_OUTPUT_INTERFACE *__initdata StdOut; @@ -713,6 +716,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY =20 efi_ih =3D ImageHandle; efi_bs =3D SystemTable->BootServices; + efi_bs_revision =3D efi_bs->Hdr.Revision; efi_rs =3D SystemTable->RuntimeServices; efi_ct =3D SystemTable->ConfigurationTable; efi_num_ct =3D SystemTable->NumberOfTableEntries; @@ -1220,6 +1224,9 @@ void __init efi_init_memory(void) prot |=3D _PAGE_PAT | MAP_SMALL_PAGES; else if ( desc->Attribute & (EFI_MEMORY_UC | EFI_MEMORY_UCE) ) prot |=3D _PAGE_PWT | _PAGE_PCD | MAP_SMALL_PAGES; + else if ( efi_bs_revision >=3D EFI_REVISION(2, 5) && + (desc->Attribute & EFI_MEMORY_WP) ) + prot |=3D _PAGE_PAT | _PAGE_PWT | MAP_SMALL_PAGES; else { printk(XENLOG_ERR "Unknown cachability for MFNs %#lx-%#lx%s\n"= , @@ -1229,7 +1236,8 @@ void __init efi_init_memory(void) prot |=3D _PAGE_PWT | _PAGE_PCD | MAP_SMALL_PAGES; } =20 - if ( desc->Attribute & EFI_MEMORY_WP ) + if ( desc->Attribute & (efi_bs_revision < EFI_REVISION(2, 5) + ? EFI_MEMORY_WP : EFI_MEMORY_RO) ) prot &=3D ~_PAGE_RW; if ( desc->Attribute & EFI_MEMORY_XP ) prot |=3D _PAGE_NX; --- a/xen/include/efi/efidef.h +++ b/xen/include/efi/efidef.h @@ -156,11 +156,15 @@ typedef enum { #define EFI_MEMORY_WT 0x0000000000000004 #define EFI_MEMORY_WB 0x0000000000000008 #define EFI_MEMORY_UCE 0x0000000000000010 =20 +#define EFI_MEMORY_WP 0x0000000000001000 =20 // physical memory protection on range=20 -#define EFI_MEMORY_WP 0x0000000000001000 #define EFI_MEMORY_RP 0x0000000000002000 #define EFI_MEMORY_XP 0x0000000000004000 +#define EFI_MEMORY_RO 0x0000000000020000 + +#define EFI_MEMORY_NV 0x0000000000008000 +#define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000 =20 // range requires a runtime mapping #define EFI_MEMORY_RUNTIME 0x8000000000000000 --=__PartA692881D.0__= Content-Type: text/plain; name="EFI-memory-attr-v25.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="EFI-memory-attr-v25.patch" x86/EFI: adjust EFI_MEMORY_WP handling for spec version 2.5=0A=0AThat flag = now means cachability rather than protection, and a new flag=0AEFI_MEMORY_R= O got added in its place.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/common/efi/boot.c=0A+++ b/xen/common/efi/boot.c=0A@@ = -32,6 +32,8 @@=0A /* Using SetVirtualAddressMap() is incompatible with = kexec: */=0A #undef USE_SET_VIRTUAL_ADDRESS_MAP=0A =0A+#define EFI_REVISION= (major, minor) (((major) << 16) | (minor))=0A+=0A #define SMBIOS3_TABLE_GUI= D \=0A { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, = 0x20, 0xe3, 0x94} }=0A #define SHIM_LOCK_PROTOCOL_GUID \=0A@@ -78,6 +80,7 = @@ static int set_color(u32 mask, int bpp, =0A static bool_t match_guid(con= st EFI_GUID *guid1, const EFI_GUID *guid2);=0A =0A static const EFI_BOOT_SE= RVICES *__initdata efi_bs;=0A+static UINT32 __initdata efi_bs_revision;=0A = static EFI_HANDLE __initdata efi_ih;=0A =0A static SIMPLE_TEXT_OUTPUT_INTER= FACE *__initdata StdOut;=0A@@ -713,6 +716,7 @@ efi_start(EFI_HANDLE = ImageHandle, EFI_SY=0A =0A efi_ih =3D ImageHandle;=0A efi_bs =3D = SystemTable->BootServices;=0A+ efi_bs_revision =3D efi_bs->Hdr.Revision;= =0A efi_rs =3D SystemTable->RuntimeServices;=0A efi_ct =3D = SystemTable->ConfigurationTable;=0A efi_num_ct =3D SystemTable->NumberO= fTableEntries;=0A@@ -1220,6 +1224,9 @@ void __init efi_init_memory(void)=0A= prot |=3D _PAGE_PAT | MAP_SMALL_PAGES;=0A else if ( = desc->Attribute & (EFI_MEMORY_UC | EFI_MEMORY_UCE) )=0A prot = |=3D _PAGE_PWT | _PAGE_PCD | MAP_SMALL_PAGES;=0A+ else if ( = efi_bs_revision >=3D EFI_REVISION(2, 5) &&=0A+ (desc->Attr= ibute & EFI_MEMORY_WP) )=0A+ prot |=3D _PAGE_PAT | _PAGE_PWT | = MAP_SMALL_PAGES;=0A else=0A {=0A printk(XENLOG_= ERR "Unknown cachability for MFNs %#lx-%#lx%s\n",=0A@@ -1229,7 +1236,8 @@ = void __init efi_init_memory(void)=0A prot |=3D _PAGE_PWT | = _PAGE_PCD | MAP_SMALL_PAGES;=0A }=0A =0A- if ( desc->Attribu= te & EFI_MEMORY_WP )=0A+ if ( desc->Attribute & (efi_bs_revision < = EFI_REVISION(2, 5)=0A+ ? EFI_MEMORY_WP : = EFI_MEMORY_RO) )=0A prot &=3D ~_PAGE_RW;=0A if ( = desc->Attribute & EFI_MEMORY_XP )=0A prot |=3D _PAGE_NX;=0A--- = a/xen/include/efi/efidef.h=0A+++ b/xen/include/efi/efidef.h=0A@@ -156,11 = +156,15 @@ typedef enum {=0A #define EFI_MEMORY_WT 0x000000000000= 0004=0A #define EFI_MEMORY_WB 0x0000000000000008=0A #define = EFI_MEMORY_UCE 0x0000000000000010 =0A+#define EFI_MEMORY_WP = 0x0000000000001000=0A =0A // physical memory protection on range = =0A-#define EFI_MEMORY_WP 0x0000000000001000=0A #define = EFI_MEMORY_RP 0x0000000000002000=0A #define EFI_MEMORY_XP = 0x0000000000004000=0A+#define EFI_MEMORY_RO 0x0000000000020000= =0A+=0A+#define EFI_MEMORY_NV 0x0000000000008000=0A+#define = EFI_MEMORY_MORE_RELIABLE 0x0000000000010000=0A =0A // range requires a = runtime mapping=0A #define EFI_MEMORY_RUNTIME 0x8000000000000000=0A --=__PartA692881D.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartA692881D.0__=--