Skip to contentSkip to conversation

xen: Add EFI support

PATCH Superseded Daniel Kiper 5 participants 43 messages May 16, 2014 – May 22, 2014

Subsystems (4)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover xen: Add EFI support

Hey,

This patch series adds EFI support for Xen dom0 guests. It is based on Jan Beulich and Tang Liang work. I was trying to take into account all previous comments, however, if I missed something sorry for that.

I am still not sure what to do with /sys/firmware/efi/config_table, /sys/firmware/efi/{fw_vendor,runtime,systab} files. On bare metal they contain physical addresses of relevant structures. However, in Xen case they does not make sens. So maybe they should contain invalid values (e.g. 0) or should not appear at all on Xen (I prefer last one). What do you think about that?

Daniel

 arch/x86/kernel/setup.c          |    6 +-
 arch/x86/platform/efi/efi.c      |   60 ++++++++++----
 arch/x86/xen/enlighten.c         |   26 ++++++
 drivers/xen/Kconfig              |    3 +
 drivers/xen/Makefile             |    1 +
 drivers/xen/efi.c                |  374 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/efi.h              |   13 +--
 include/xen/interface/platform.h |  123 +++++++++++++++++++++++++++
 8 files changed, 582 insertions(+), 24 deletions(-)

Daniel Kiper (5):
efi: Introduce EFI_DIRECT flag
xen: Define EFI related stuff
xen: Put EFI machinery in place arch/x86: Replace plain strings with constants arch/x86: Remove redundant set_bit() call

#1 lore raw

PATCH v4 1/5 efi: Introduce EFI_DIRECT flag

Introduce EFI_DIRECT flag. If it is set this means that Linux Kernel has direct access to EFI infrastructure. If not then kernel runs on EFI platform but it has not direct control on EFI stuff. This functionality is used in Xen dom0.

---
 arch/x86/kernel/setup.c     |    2 ++
 arch/x86/platform/efi/efi.c |   58 ++++++++++++++++++++++++++++++++-----------
 include/linux/efi.h         |   13 +++++-----
 3 files changed, 53 insertions(+), 20 deletions(-)
arch/x86/kernel/setup.c +2 -0
index 09c76d2..f41f648 100644
@@ -926,9 +926,11 @@ void __init setup_arch(char **cmdline_p)
 	if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
 		     "EL32", 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_DIRECT, &efi.flags);
 	} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
 		     "EL64", 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_DIRECT, &efi.flags);
 		set_bit(EFI_64BIT, &efi.flags);
 	}
 
arch/x86/platform/efi/efi.c +44 -14

131 lines not on this page · raw message

include/linux/efi.h +7 -6
index 6c100ff..4113c4e 100644
@@ -893,12 +893,13 @@ extern int __init efi_setup_pcdp_console(char *);
  * possible, remove EFI-related code altogether.
  */
 #define EFI_BOOT		0	/* Were we booted from EFI? */
-#define EFI_SYSTEM_TABLES	1	/* Can we use EFI system tables? */
-#define EFI_CONFIG_TABLES	2	/* Can we use EFI config tables? */
-#define EFI_RUNTIME_SERVICES	3	/* Can we use runtime services? */
-#define EFI_MEMMAP		4	/* Can we use EFI memory map? */
-#define EFI_64BIT		5	/* Is the firmware 64-bit? */
-#define EFI_ARCH_1		6	/* First arch-specific bit */
+#define EFI_DIRECT		1	/* Can we access EFI directly? */
+#define EFI_SYSTEM_TABLES	2	/* Can we use EFI system tables? */
+#define EFI_CONFIG_TABLES	3	/* Can we use EFI config tables? */
+#define EFI_RUNTIME_SERVICES	4	/* Can we use runtime services? */
+#define EFI_MEMMAP		5	/* Can we use EFI memory map? */
+#define EFI_64BIT		6	/* Is the firmware 64-bit? */
+#define EFI_ARCH_1		7	/* First arch-specific bit */
 
 #ifdef CONFIG_EFI
 /*
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 469

Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 16.05.14 at 22:41, <[email protected]> wrote:
arch/x86/platform/efi/efi.c +7 -0
@@ -457,6 +460,21 @@ void __init efi_free_boot_services(void)
 	efi_unmap_memmap();
 }
 
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;

Now that surely needs some explanation: I can't see how this can ever be correct, Xen or not being completely irrelevant.

Jan

#3 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 16.05.14 at 22:41, <[email protected]>…
arch/x86/platform/efi/efi.c +0 -0
@@ -457,6 +460,21 @@ void __init efi_free_boot_services(void)
 	efi_unmap_memmap();
 }
 
Quoted 10 lines

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 469

Quoted 7 lines
arch/x86/platform/efi/efi.c +7 -0
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;

Now that surely needs some explanation: I can't see how this can ever be correct, Xen or not being completely irrelevant.

I hope that efi_enabled(EFI_DIRECT) is obvious. However, in case of !efi_enabled(EFI_DIRECT) some structures are created artificially and they live in virtual address space. So that is why they should not be mapped. If you wish I could add relevant comment here.

Daniel

#4 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 22:46, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 16.05.14 at 22:41, <[email protected]> wrote:
arch/x86/platform/efi/efi.c +0 -0
@@ -457,6 +460,21 @@ void __init efi_free_boot_services(void)
 	efi_unmap_memmap();
 }
 
Quoted 10 lines

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 469

Quoted 7 lines
arch/x86/platform/efi/efi.c +7 -0
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;

Now that surely needs some explanation: I can't see how this can ever be correct, Xen or not being completely irrelevant.

Quoted 4 lines

I hope that efi_enabled(EFI_DIRECT) is obvious. However, in case of !efi_enabled(EFI_DIRECT) some structures are created artificially and they live in virtual address space. So that is why they should not be mapped. If you wish I could add relevant comment here.

That would be the very minimum I suppose. But I wonder whether you wouldn't be better off storing their physical addresses in the first place (and then decide whether you can stay with early_ioremap() or want/need to use early_memremap() if !EFI_DIRECT).

Jan

#5 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

In reply to Jan Beulich
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 16.05.14 at 22:41, <[email protected]> wrote:
arch/x86/platform/efi/efi.c +0 -0
@@ -457,6 +460,21 @@ void __init efi_free_boot_services(void)
 	efi_unmap_memmap();
 }
 
Quoted 10 lines

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 469

Quoted 7 lines
arch/x86/platform/efi/efi.c +7 -0
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;

Now that surely needs some explanation: I can't see how this can ever be correct, Xen or not being completely irrelevant.

I hope that efi_enabled(EFI_DIRECT) is obvious. However, in case of !efi_enabled(EFI_DIRECT) some structures are created artificially and they live in virtual address space. So that is why they should not be mapped. If you wish I could add relevant comment here.

Daniel

#6 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

In reply to Daniel Kiper

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 469

Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 16.05.14 at 22:41, <[email protected]> wrote:
arch/x86/platform/efi/efi.c +7 -0
@@ -457,6 +460,21 @@ void __init efi_free_boot_services(void)
 	efi_unmap_memmap();
 }
 
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;

Now that surely needs some explanation: I can't see how this can ever be correct, Xen or not being completely irrelevant.

Jan

#7 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

In reply to Daniel Kiper
Quoted 4 lines · Daniel Kiper

Introduce EFI_DIRECT flag. If it is set this means that Linux Kernel has direct access to EFI infrastructure. If not then kernel runs on EFI platform but it has not direct control on EFI stuff. This functionality is used in Xen dom0.

This is backwards. It should flag should indicate the weird platform not the standard, default one.

You also need to explain why this is needed rather than presenting a more complete EFI interface to PV guests. And you should explain why each use is necessary.

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 470

Quoted 8 lines
arch/x86/platform/efi/efi.c +8 -0
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;
+}

Er... Perhaps you mean BUG_ON(!efi_enabled(EFI_DIRECT))? Or return NULL?

Quoted 9 lines
include/linux/efi.h +0 -3
@@ -893,12 +893,13 @@ extern int __init efi_setup_pcdp_console(char *);
  * possible, remove EFI-related code altogether.
  */
 #define EFI_BOOT		0	/* Were we booted from EFI? */
-#define EFI_SYSTEM_TABLES	1	/* Can we use EFI system tables? */
-#define EFI_CONFIG_TABLES	2	/* Can we use EFI config tables? */
-#define EFI_RUNTIME_SERVICES	3	/* Can we use runtime services? */

include/linux/efi.h extern int __init efi_setup_pcdp_console(char *); · line 902

Quoted 10 lines
include/linux/efi.h +7 -3
-#define EFI_MEMMAP		4	/* Can we use EFI memory map? */
-#define EFI_64BIT		5	/* Is the firmware 64-bit? */
-#define EFI_ARCH_1		6	/* First arch-specific bit */
+#define EFI_DIRECT		1	/* Can we access EFI directly? */
+#define EFI_SYSTEM_TABLES	2	/* Can we use EFI system tables? */
+#define EFI_CONFIG_TABLES	3	/* Can we use EFI config tables? */
+#define EFI_RUNTIME_SERVICES	4	/* Can we use runtime services? */
+#define EFI_MEMMAP		5	/* Can we use EFI memory map? */
+#define EFI_64BIT		6	/* Is the firmware 64-bit? */
+#define EFI_ARCH_1		7	/* First arch-specific bit */

Unnecessary shuffling of these values. Why didn't you stick it after EFI_64BIT?

David

#8 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

Quoted 8 lines · David Vrabel
Quoted 4 lines · Daniel Kiper

Introduce EFI_DIRECT flag. If it is set this means that Linux Kernel has direct access to EFI infrastructure. If not then kernel runs on EFI platform but it has not direct control on EFI stuff. This functionality is used in Xen dom0.

This is backwards. It should flag should indicate the weird platform not the standard, default one.

Do you wish EFI_NO_DIRECT? I understand your idea but I would like to avoid this name because it is quite difficult to read e.g. !efi_enabled(EFI_NO_DIRECT). You must think a bit to know what is going on. However, maybe you have a better idea?

Quoted 3 lines

You also need to explain why this is needed rather than presenting a more complete EFI interface to PV guests. And you should explain why each use is necessary.

OK.

Quoted 10 lines

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 470

Quoted 8 lines
arch/x86/platform/efi/efi.c +8 -0
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;
+}

Er... Perhaps you mean BUG_ON(!efi_enabled(EFI_DIRECT))? Or return NULL?

It is correct. As I said earlier: in case of !efi_enabled(EFI_DIRECT) some structures are created artificially and they live in virtual address space. So that is why they should not be mapped.

Quoted 14 lines
Quoted 14 lines
include/linux/efi.h +2 -6
@@ -893,12 +893,13 @@ extern int __init efi_setup_pcdp_console(char *);
  * possible, remove EFI-related code altogether.
  */
 #define EFI_BOOT		0	/* Were we booted from EFI? */
-#define EFI_SYSTEM_TABLES	1	/* Can we use EFI system tables? */
-#define EFI_CONFIG_TABLES	2	/* Can we use EFI config tables? */
-#define EFI_RUNTIME_SERVICES	3	/* Can we use runtime services? */
-#define EFI_MEMMAP		4	/* Can we use EFI memory map? */
-#define EFI_64BIT		5	/* Is the firmware 64-bit? */
-#define EFI_ARCH_1		6	/* First arch-specific bit */
+#define EFI_DIRECT		1	/* Can we access EFI directly? */
+#define EFI_SYSTEM_TABLES	2	/* Can we use EFI system tables? */
Quoted 8 lines

include/linux/efi.h extern int __init efi_setup_pcdp_console(char *); · line 902

Quoted 5 lines
include/linux/efi.h +5 -0
+#define EFI_CONFIG_TABLES	3	/* Can we use EFI config tables? */
+#define EFI_RUNTIME_SERVICES	4	/* Can we use runtime services? */
+#define EFI_MEMMAP		5	/* Can we use EFI memory map? */
+#define EFI_64BIT		6	/* Is the firmware 64-bit? */
+#define EFI_ARCH_1		7	/* First arch-specific bit */

Unnecessary shuffling of these values. Why didn't you stick it after EFI_64BIT?

I was going to have EFI_DIRECT close to EFI_BOOT which is quite generic and platform independent name like EFI_BOOT. However, I do not insist on having it in that place.

Daniel

#9 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

Quoted 4 lines · Daniel Kiper

It is correct. As I said earlier: in case of !efi_enabled(EFI_DIRECT) some structures are created artificially and they live in virtual address space. So that is why they should not be mapped.

So, exploring Jan's idea, is it not possible to store the physical address and have early_ioremap() just work? Even if they're mapping in virtual address space they must have a corresponding physical address.

We really need to be keeping these kinds of special code paths to a minimum. Unless absolutely necessary there should be just one way to do things.

Quoted 3 lines

I was going to have EFI_DIRECT close to EFI_BOOT which is quite generic and platform independent name like EFI_BOOT. However, I do not insist on having it in that place.

Right, please don't shuffle these bits.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#10 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

In reply to David Vrabel
Quoted 8 lines · David Vrabel
Quoted 4 lines · Daniel Kiper

Introduce EFI_DIRECT flag. If it is set this means that Linux Kernel has direct access to EFI infrastructure. If not then kernel runs on EFI platform but it has not direct control on EFI stuff. This functionality is used in Xen dom0.

This is backwards. It should flag should indicate the weird platform not the standard, default one.

Do you wish EFI_NO_DIRECT? I understand your idea but I would like to avoid this name because it is quite difficult to read e.g. !efi_enabled(EFI_NO_DIRECT). You must think a bit to know what is going on. However, maybe you have a better idea?

Quoted 3 lines

You also need to explain why this is needed rather than presenting a more complete EFI interface to PV guests. And you should explain why each use is necessary.

OK.

Quoted 10 lines

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 470

Quoted 8 lines
arch/x86/platform/efi/efi.c +8 -0
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;
+}

Er... Perhaps you mean BUG_ON(!efi_enabled(EFI_DIRECT))? Or return NULL?

It is correct. As I said earlier: in case of !efi_enabled(EFI_DIRECT) some structures are created artificially and they live in virtual address space. So that is why they should not be mapped.

Quoted 14 lines
Quoted 14 lines
include/linux/efi.h +2 -6
@@ -893,12 +893,13 @@ extern int __init efi_setup_pcdp_console(char *);
  * possible, remove EFI-related code altogether.
  */
 #define EFI_BOOT		0	/* Were we booted from EFI? */
-#define EFI_SYSTEM_TABLES	1	/* Can we use EFI system tables? */
-#define EFI_CONFIG_TABLES	2	/* Can we use EFI config tables? */
-#define EFI_RUNTIME_SERVICES	3	/* Can we use runtime services? */
-#define EFI_MEMMAP		4	/* Can we use EFI memory map? */
-#define EFI_64BIT		5	/* Is the firmware 64-bit? */
-#define EFI_ARCH_1		6	/* First arch-specific bit */
+#define EFI_DIRECT		1	/* Can we access EFI directly? */
+#define EFI_SYSTEM_TABLES	2	/* Can we use EFI system tables? */
Quoted 8 lines

include/linux/efi.h extern int __init efi_setup_pcdp_console(char *); · line 902

Quoted 5 lines
include/linux/efi.h +5 -0
+#define EFI_CONFIG_TABLES	3	/* Can we use EFI config tables? */
+#define EFI_RUNTIME_SERVICES	4	/* Can we use runtime services? */
+#define EFI_MEMMAP		5	/* Can we use EFI memory map? */
+#define EFI_64BIT		6	/* Is the firmware 64-bit? */
+#define EFI_ARCH_1		7	/* First arch-specific bit */

Unnecessary shuffling of these values. Why didn't you stick it after EFI_64BIT?

I was going to have EFI_DIRECT close to EFI_BOOT which is quite generic and platform independent name like EFI_BOOT. However, I do not insist on having it in that place.

Daniel

#11 lore raw

Re: [PATCH v4 1/5] efi: Introduce EFI_DIRECT flag

In reply to Daniel Kiper
Quoted 4 lines · Daniel Kiper

Introduce EFI_DIRECT flag. If it is set this means that Linux Kernel has direct access to EFI infrastructure. If not then kernel runs on EFI platform but it has not direct control on EFI stuff. This functionality is used in Xen dom0.

This is backwards. It should flag should indicate the weird platform not the standard, default one.

You also need to explain why this is needed rather than presenting a more complete EFI interface to PV guests. And you should explain why each use is necessary.

arch/x86/platform/efi/efi.c void __init efi_free_boot_services(void) · line 470

Quoted 8 lines
arch/x86/platform/efi/efi.c +8 -0
+static void __init __iomem *efi_early_ioremap(resource_size_t phys_addr,
+							unsigned long size)
+{
+	if (efi_enabled(EFI_DIRECT))
+		return early_ioremap(phys_addr, size);
+
+	return (__force void __iomem *)phys_addr;
+}

Er... Perhaps you mean BUG_ON(!efi_enabled(EFI_DIRECT))? Or return NULL?

Quoted 9 lines
include/linux/efi.h +0 -3
@@ -893,12 +893,13 @@ extern int __init efi_setup_pcdp_console(char *);
  * possible, remove EFI-related code altogether.
  */
 #define EFI_BOOT		0	/* Were we booted from EFI? */
-#define EFI_SYSTEM_TABLES	1	/* Can we use EFI system tables? */
-#define EFI_CONFIG_TABLES	2	/* Can we use EFI config tables? */
-#define EFI_RUNTIME_SERVICES	3	/* Can we use runtime services? */

include/linux/efi.h extern int __init efi_setup_pcdp_console(char *); · line 902

Quoted 10 lines
include/linux/efi.h +7 -3
-#define EFI_MEMMAP		4	/* Can we use EFI memory map? */
-#define EFI_64BIT		5	/* Is the firmware 64-bit? */
-#define EFI_ARCH_1		6	/* First arch-specific bit */
+#define EFI_DIRECT		1	/* Can we access EFI directly? */
+#define EFI_SYSTEM_TABLES	2	/* Can we use EFI system tables? */
+#define EFI_CONFIG_TABLES	3	/* Can we use EFI config tables? */
+#define EFI_RUNTIME_SERVICES	4	/* Can we use runtime services? */
+#define EFI_MEMMAP		5	/* Can we use EFI memory map? */
+#define EFI_64BIT		6	/* Is the firmware 64-bit? */
+#define EFI_ARCH_1		7	/* First arch-specific bit */

Unnecessary shuffling of these values. Why didn't you stick it after EFI_64BIT?

David

#12 lore raw

PATCH v4 1/5 efi: Introduce EFI_DIRECT flag

In reply to Daniel Kiper

Introduce EFI_DIRECT flag. If it is set this means that Linux Kernel has direct access to EFI infrastructure. If not then kernel runs on EFI platform but it has not direct control on EFI stuff. This functionality is used in Xen dom0.

---
 arch/x86/kernel/setup.c     |    2 ++
 arch/x86/platform/efi/efi.c |   58 ++++++++++++++++++++++++++++++++-----------
 include/linux/efi.h         |   13 +++++-----
 3 files changed, 53 insertions(+), 20 deletions(-)
arch/x86/kernel/setup.c +2 -0
index 09c76d2..f41f648 100644
@@ -926,9 +926,11 @@ void __init setup_arch(char **cmdline_p)
 	if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
 		     "EL32", 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_DIRECT, &efi.flags);
 	} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
 		     "EL64", 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_DIRECT, &efi.flags);
 		set_bit(EFI_64BIT, &efi.flags);
 	}
 
arch/x86/platform/efi/efi.c +44 -14

131 lines not on this page · raw message

include/linux/efi.h +7 -6
index 6c100ff..4113c4e 100644
@@ -893,12 +893,13 @@ extern int __init efi_setup_pcdp_console(char *);
  * possible, remove EFI-related code altogether.
  */
 #define EFI_BOOT		0	/* Were we booted from EFI? */
-#define EFI_SYSTEM_TABLES	1	/* Can we use EFI system tables? */
-#define EFI_CONFIG_TABLES	2	/* Can we use EFI config tables? */
-#define EFI_RUNTIME_SERVICES	3	/* Can we use runtime services? */
-#define EFI_MEMMAP		4	/* Can we use EFI memory map? */
-#define EFI_64BIT		5	/* Is the firmware 64-bit? */
-#define EFI_ARCH_1		6	/* First arch-specific bit */
+#define EFI_DIRECT		1	/* Can we access EFI directly? */
+#define EFI_SYSTEM_TABLES	2	/* Can we use EFI system tables? */
+#define EFI_CONFIG_TABLES	3	/* Can we use EFI config tables? */
+#define EFI_RUNTIME_SERVICES	4	/* Can we use runtime services? */
+#define EFI_MEMMAP		5	/* Can we use EFI memory map? */
+#define EFI_64BIT		6	/* Is the firmware 64-bit? */
+#define EFI_ARCH_1		7	/* First arch-specific bit */
 
 #ifdef CONFIG_EFI
 /*
Signature · 1 line
1.7.10.4
#13 lore raw

PATCH v4 2/5 xen: Define EFI related stuff

In reply to Daniel Kiper

Define EFI related stuff for Xen.

This patch is based on Jan Beulich and Tang Liang work.

v4 - suggestions/fixes:
- change some types from generic to Xen specific ones (suggested by Stefano Stabellini),
- do some formating changes
(suggested by Jan Beulich).

---
 include/xen/interface/platform.h |  123 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)
include/xen/interface/platform.h +123 -0
index f1331e3..55deeb7 100644
@@ -108,11 +108,113 @@ struct xenpf_platform_quirk {
 };
 DEFINE_GUEST_HANDLE_STRUCT(xenpf_platform_quirk_t);
 
+#define XENPF_efi_runtime_call    49
+#define XEN_EFI_get_time                      1
+#define XEN_EFI_set_time                      2
+#define XEN_EFI_get_wakeup_time               3
+#define XEN_EFI_set_wakeup_time               4
+#define XEN_EFI_get_next_high_monotonic_count 5
+#define XEN_EFI_get_variable                  6
+#define XEN_EFI_set_variable                  7
+#define XEN_EFI_get_next_variable_name        8
+#define XEN_EFI_query_variable_info           9
+#define XEN_EFI_query_capsule_capabilities   10
+#define XEN_EFI_update_capsule               11
+
+struct xenpf_efi_runtime_call {
+	uint32_t function;
+	/*
+	 * This field is generally used for per sub-function flags (defined
+	 * below), except for the XEN_EFI_get_next_high_monotonic_count case,
+	 * where it holds the single returned value.
+	 */
+	uint32_t misc;
+	xen_ulong_t status;
+	union {
+#define XEN_EFI_GET_TIME_SET_CLEARS_NS 0x00000001
+	struct {
+		struct xenpf_efi_time {
+			uint16_t year;
+			uint8_t month;
+			uint8_t day;
+			uint8_t hour;
+			uint8_t min;
+			uint8_t sec;
+			uint32_t ns;
+			int16_t tz;
+			uint8_t daylight;
+		} time;
+		uint32_t resolution;
+		uint32_t accuracy;
+	} get_time;
+
+	struct xenpf_efi_time set_time;
+
+#define XEN_EFI_GET_WAKEUP_TIME_ENABLED 0x00000001
+#define XEN_EFI_GET_WAKEUP_TIME_PENDING 0x00000002
+	struct xenpf_efi_time get_wakeup_time;
+
+#define XEN_EFI_SET_WAKEUP_TIME_ENABLE      0x00000001
+#define XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY 0x00000002
+	struct xenpf_efi_time set_wakeup_time;
+
+#define XEN_EFI_VARIABLE_NON_VOLATILE       0x00000001
+#define XEN_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
+#define XEN_EFI_VARIABLE_RUNTIME_ACCESS     0x00000004
+	struct {
+		GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
+		xen_ulong_t size;
+		GUEST_HANDLE(void) data;
+		struct xenpf_efi_guid {
+			uint32_t data1;
+			uint16_t data2;
+			uint16_t data3;
+			uint8_t data4[8];
+			} vendor_guid;
+		} get_variable, set_variable;
+
+	struct {
+		xen_ulong_t size;
+		GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
+		struct xenpf_efi_guid vendor_guid;
+		} get_next_variable_name;
+
+	struct {
+		uint32_t attr;
+		uint64_t max_store_size;
+		uint64_t remain_store_size;
+		uint64_t max_size;
+		} query_variable_info;
+
+	struct {
+		GUEST_HANDLE(void) capsule_header_array;
+		xen_ulong_t capsule_count;
+		uint64_t max_capsule_size;
+		uint32_t reset_type;
+		} query_capsule_capabilities;
+
+	struct {
+		GUEST_HANDLE(void) capsule_header_array;
+		xen_ulong_t capsule_count;
+		uint64_t sg_list; /* machine address */
+		} update_capsule;
+	} u;
+};
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_efi_runtime_call);
+
+#define  XEN_FW_EFI_VERSION        0
+#define  XEN_FW_EFI_CONFIG_TABLE   1
+#define  XEN_FW_EFI_VENDOR         2
+#define  XEN_FW_EFI_MEM_INFO       3
+#define  XEN_FW_EFI_RT_VERSION     4
+
 #define XENPF_firmware_info       50
 #define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
 #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
 #define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
+#define XEN_FW_EFI_INFO           4 /* from EFI */
 #define XEN_FW_KBD_SHIFT_FLAGS    5 /* Int16, Fn02: Get keyboard shift flags. */
+
 struct xenpf_firmware_info {
 	/* IN variables. */
 	uint32_t type;
@@ -144,6 +246,26 @@ struct xenpf_firmware_info {
 			GUEST_HANDLE(uchar) edid;
 		} vbeddc_info; /* XEN_FW_VBEDDC_INFO */
 
+		union xenpf_efi_info {
+			uint32_t version;
+			struct {
+				uint64_t addr;   /* EFI_CONFIGURATION_TABLE */
+				uint32_t nent;
+			} cfg;
+			struct {
+				uint32_t revision;
+				uint32_t bufsz;  /* input, in bytes */
+				GUEST_HANDLE(void) name;
+				/* UCS-2/UTF-16 string */
+				} vendor;
+			struct {
+				uint64_t addr;
+				uint64_t size;
+				uint64_t attr;
+				uint32_t type;
+				} mem;
+		} efi_info; /* XEN_FW_EFI_INFO */
+
 		uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */
 	} u;
 };
@@ -362,6 +484,7 @@ struct xen_platform_op {
 		struct xenpf_read_memtype      read_memtype;
 		struct xenpf_microcode_update  microcode;
 		struct xenpf_platform_quirk    platform_quirk;
+		struct xenpf_efi_runtime_call  efi_runtime_call;
 		struct xenpf_firmware_info     firmware_info;
 		struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
 		struct xenpf_change_freq       change_freq;
Signature · 1 line
1.7.10.4
#14 lore raw

Re: [PATCH v4 2/5] xen: Define EFI related stuff

Quoted 1 line · Daniel Kiper

Define EFI related stuff for Xen.

Define "stuff"? Please write a more descriptive commit message.

David

#15 lore raw

Re: [PATCH v4 2/5] xen: Define EFI related stuff

In reply to Daniel Kiper
Quoted 1 line · Daniel Kiper

Define EFI related stuff for Xen.

Define "stuff"? Please write a more descriptive commit message.

David

#16 lore raw

PATCH v4 2/5 xen: Define EFI related stuff

In reply to Daniel Kiper

Define EFI related stuff for Xen.

This patch is based on Jan Beulich and Tang Liang work.

v4 - suggestions/fixes:
- change some types from generic to Xen specific ones (suggested by Stefano Stabellini),
- do some formating changes
(suggested by Jan Beulich).

---
 include/xen/interface/platform.h |  123 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)
include/xen/interface/platform.h +123 -0
index f1331e3..55deeb7 100644
@@ -108,11 +108,113 @@ struct xenpf_platform_quirk {
 };
 DEFINE_GUEST_HANDLE_STRUCT(xenpf_platform_quirk_t);
 
+#define XENPF_efi_runtime_call    49
+#define XEN_EFI_get_time                      1
+#define XEN_EFI_set_time                      2
+#define XEN_EFI_get_wakeup_time               3
+#define XEN_EFI_set_wakeup_time               4
+#define XEN_EFI_get_next_high_monotonic_count 5
+#define XEN_EFI_get_variable                  6
+#define XEN_EFI_set_variable                  7
+#define XEN_EFI_get_next_variable_name        8
+#define XEN_EFI_query_variable_info           9
+#define XEN_EFI_query_capsule_capabilities   10
+#define XEN_EFI_update_capsule               11
+
+struct xenpf_efi_runtime_call {
+	uint32_t function;
+	/*
+	 * This field is generally used for per sub-function flags (defined
+	 * below), except for the XEN_EFI_get_next_high_monotonic_count case,
+	 * where it holds the single returned value.
+	 */
+	uint32_t misc;
+	xen_ulong_t status;
+	union {
+#define XEN_EFI_GET_TIME_SET_CLEARS_NS 0x00000001
+	struct {
+		struct xenpf_efi_time {
+			uint16_t year;
+			uint8_t month;
+			uint8_t day;
+			uint8_t hour;
+			uint8_t min;
+			uint8_t sec;
+			uint32_t ns;
+			int16_t tz;
+			uint8_t daylight;
+		} time;
+		uint32_t resolution;
+		uint32_t accuracy;
+	} get_time;
+
+	struct xenpf_efi_time set_time;
+
+#define XEN_EFI_GET_WAKEUP_TIME_ENABLED 0x00000001
+#define XEN_EFI_GET_WAKEUP_TIME_PENDING 0x00000002
+	struct xenpf_efi_time get_wakeup_time;
+
+#define XEN_EFI_SET_WAKEUP_TIME_ENABLE      0x00000001
+#define XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY 0x00000002
+	struct xenpf_efi_time set_wakeup_time;
+
+#define XEN_EFI_VARIABLE_NON_VOLATILE       0x00000001
+#define XEN_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
+#define XEN_EFI_VARIABLE_RUNTIME_ACCESS     0x00000004
+	struct {
+		GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
+		xen_ulong_t size;
+		GUEST_HANDLE(void) data;
+		struct xenpf_efi_guid {
+			uint32_t data1;
+			uint16_t data2;
+			uint16_t data3;
+			uint8_t data4[8];
+			} vendor_guid;
+		} get_variable, set_variable;
+
+	struct {
+		xen_ulong_t size;
+		GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
+		struct xenpf_efi_guid vendor_guid;
+		} get_next_variable_name;
+
+	struct {
+		uint32_t attr;
+		uint64_t max_store_size;
+		uint64_t remain_store_size;
+		uint64_t max_size;
+		} query_variable_info;
+
+	struct {
+		GUEST_HANDLE(void) capsule_header_array;
+		xen_ulong_t capsule_count;
+		uint64_t max_capsule_size;
+		uint32_t reset_type;
+		} query_capsule_capabilities;
+
+	struct {
+		GUEST_HANDLE(void) capsule_header_array;
+		xen_ulong_t capsule_count;
+		uint64_t sg_list; /* machine address */
+		} update_capsule;
+	} u;
+};
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_efi_runtime_call);
+
+#define  XEN_FW_EFI_VERSION        0
+#define  XEN_FW_EFI_CONFIG_TABLE   1
+#define  XEN_FW_EFI_VENDOR         2
+#define  XEN_FW_EFI_MEM_INFO       3
+#define  XEN_FW_EFI_RT_VERSION     4
+
 #define XENPF_firmware_info       50
 #define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
 #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
 #define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
+#define XEN_FW_EFI_INFO           4 /* from EFI */
 #define XEN_FW_KBD_SHIFT_FLAGS    5 /* Int16, Fn02: Get keyboard shift flags. */
+
 struct xenpf_firmware_info {
 	/* IN variables. */
 	uint32_t type;
@@ -144,6 +246,26 @@ struct xenpf_firmware_info {
 			GUEST_HANDLE(uchar) edid;
 		} vbeddc_info; /* XEN_FW_VBEDDC_INFO */
 
+		union xenpf_efi_info {
+			uint32_t version;
+			struct {
+				uint64_t addr;   /* EFI_CONFIGURATION_TABLE */
+				uint32_t nent;
+			} cfg;
+			struct {
+				uint32_t revision;
+				uint32_t bufsz;  /* input, in bytes */
+				GUEST_HANDLE(void) name;
+				/* UCS-2/UTF-16 string */
+				} vendor;
+			struct {
+				uint64_t addr;
+				uint64_t size;
+				uint64_t attr;
+				uint32_t type;
+				} mem;
+		} efi_info; /* XEN_FW_EFI_INFO */
+
 		uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */
 	} u;
 };
@@ -362,6 +484,7 @@ struct xen_platform_op {
 		struct xenpf_read_memtype      read_memtype;
 		struct xenpf_microcode_update  microcode;
 		struct xenpf_platform_quirk    platform_quirk;
+		struct xenpf_efi_runtime_call  efi_runtime_call;
 		struct xenpf_firmware_info     firmware_info;
 		struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
 		struct xenpf_change_freq       change_freq;
Signature · 1 line
1.7.10.4
#17 lore raw

PATCH v4 3/5 xen: Put EFI machinery in place

In reply to Daniel Kiper

Put EFI machinery for Xen in place.

This patch is based on Jan Beulich and Tang Liang work.

v4 - suggestions/fixes:
- "just populate an efi_system_table_t object"
(suggested by Matt Fleming).

---
 arch/x86/xen/enlighten.c |   26 ++++
 drivers/xen/Kconfig      |    3 +
 drivers/xen/Makefile     |    1 +
 drivers/xen/efi.c        |  374 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 404 insertions(+)
 create mode 100644 drivers/xen/efi.c
arch/x86/xen/enlighten.c +26 -0
index c34bfc4..d5cc21f 100644
@@ -32,6 +32,7 @@
 #include <linux/gfp.h>
 #include <linux/memblock.h>
 #include <linux/edd.h>
+#include <linux/efi.h>
 
 #include <xen/xen.h>
 #include <xen/events.h>
@@ -150,6 +151,15 @@ struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info;
  */
 static int have_vcpu_info_placement = 1;
 
+#ifdef CONFIG_XEN_EFI
+extern efi_system_table_t __init *xen_efi_probe(void);
+#else
+static efi_system_table_t __init *xen_efi_probe(void)
+{
+	return NULL;
+}
+#endif
+
 struct tls_descs {
 	struct desc_struct desc[3];
 };
@@ -1519,6 +1529,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 {
 	struct physdev_set_iopl set_iopl;
 	int rc;
+	efi_system_table_t *efi_systab_xen;
 
 	if (!xen_start_info)
 		return;
@@ -1714,6 +1725,21 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen) {
+		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+				sizeof(boot_params.efi_info.efi_loader_signature));
+		boot_params.efi_info.efi_systab = (__u32)((__u64)efi_systab_xen);
+		boot_params.efi_info.efi_systab_hi = (__u32)((__u64)efi_systab_xen >> 32);
+
+		x86_platform.get_wallclock = efi_get_time;
+		x86_platform.set_wallclock = efi_set_rtc_mmss;
+
+		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_64BIT, &efi.flags);
+	}
+
 	/* Start the world */
 #ifdef CONFIG_X86_32
 	i386_start_kernel();
drivers/xen/Kconfig +3 -0
index 38fb36e..cead283 100644
@@ -240,4 +240,7 @@ config XEN_MCE_LOG
 config XEN_HAVE_PVMMU
        bool
 
+config XEN_EFI
+	def_bool X86_64 && EFI
+
 endmenu
drivers/xen/Makefile +1 -0
index 45e00af..c35de02 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_XEN_STUB)			+= xen-stub.o
 obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY)	+= xen-acpi-memhotplug.o
 obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU)	+= xen-acpi-cpuhotplug.o
 obj-$(CONFIG_XEN_ACPI_PROCESSOR)	+= xen-acpi-processor.o
+obj-$(CONFIG_XEN_EFI)			+= efi.o
 xen-evtchn-y				:= evtchn.o
 xen-gntdev-y				:= gntdev.o
 xen-gntalloc-y				:= gntalloc.o
drivers/xen/efi.c new file +374 -0

374 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#18 lore raw

Re: [Xen-devel] [PATCH v4 3/5] xen: Put EFI machinery in place

Quoted 22 lines · Daniel Kiper
drivers/xen/efi.c new file +21 -0
@@ -0,0 +1,374 @@
+/*
+ * EFI support for Xen.
+ *
+ * Copyright (C) 1999 VA Linux Systems
+ * Copyright (C) 1999 Walt Drummond <[email protected]>
+ * Copyright (C) 1999-2002 Hewlett-Packard Co.
+ *	David Mosberger-Tang <[email protected]>
+ *	Stephane Eranian <[email protected]>
+ * Copyright (C) 2005-2008 Intel Co.
+ *	Fenghua Yu <[email protected]>
+ *	Bibo Mao <[email protected]>
+ *	Chandramouli Narayanan <[email protected]>
+ *	Huang Ying <[email protected]>
+ * Copyright (C) 2011 Novell Co.
+ *	Jan Beulich <[email protected]>
+ * Copyright (C) 2011-2012 Oracle Co.
+ *	Liang Tang <[email protected]>
+ * Copyright (c) 2014 Daniel Kiper, Oracle Corporation
+ */
+
+#include <linux/bug.h>

drivers/xen/efi.c line 31

Quoted 10 lines
drivers/xen/efi.c new file +10 -0
+#include <linux/efi.h>
+#include <linux/init.h>
+#include <linux/string.h>
+
+#include <xen/interface/xen.h>
+#include <xen/interface/platform.h>
+
+#include <asm/xen/hypercall.h>
+
+#define call (op.u.efi_runtime_call)

I think not.

drivers/xen/efi.c line 36

Quoted 5 lines
drivers/xen/efi.c new file +5 -0
+#define DECLARE_CALL(what) \
+	struct xen_platform_op op; \
+	op.cmd = XENPF_efi_runtime_call; \
+	call.function = XEN_EFI_##what; \
+	call.misc = 0

Macros like this which explicitly create local variable with implicit names are evil when reading code.

If you want to do initialisation like this, then at least do something like:

#define INIT_EFI_CALL(what) \
{ .cmd = XENPF_efi_runtime_call, \
.u.efi_runtime_call.function = XEN_EFI_##what, \
.u.efi_runtime_call.misc = 0 }

And use it as:

struct xen_platform_op op = INIT_EFI_CALL(foo);

~Andrew

#19 lore raw

Re: [Xen-devel] [PATCH v4 3/5] xen: Put EFI machinery in place

Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 15:39, <[email protected]>…
Quoted 26 lines · Daniel Kiper
drivers/xen/efi.c new file +25 -0
@@ -0,0 +1,374 @@
+/*
+ * EFI support for Xen.
+ *
+ * Copyright (C) 1999 VA Linux Systems
+ * Copyright (C) 1999 Walt Drummond <[email protected]>
+ * Copyright (C) 1999-2002 Hewlett-Packard Co.
+ *	David Mosberger-Tang <[email protected]>
+ *	Stephane Eranian <[email protected]>
+ * Copyright (C) 2005-2008 Intel Co.
+ *	Fenghua Yu <[email protected]>
+ *	Bibo Mao <[email protected]>
+ *	Chandramouli Narayanan <mouli-VuQAYsv1563Yd54FQh9/[email protected]>
+ *	Huang Ying <[email protected]>
+ * Copyright (C) 2011 Novell Co.
+ *	Jan Beulich <JBeulich-IBi9RG/[email protected]>
+ * Copyright (C) 2011-2012 Oracle Co.
+ *	Liang Tang <[email protected]>
+ * Copyright (c) 2014 Daniel Kiper, Oracle Corporation
+ */
+
+#include <linux/bug.h>
+#include <linux/efi.h>
+#include <linux/init.h>
+#include <linux/string.h>
+
Quoted 8 lines

drivers/xen/efi.c line 31

Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+#include <xen/interface/xen.h>
+#include <xen/interface/platform.h>
+
+#include <asm/xen/hypercall.h>
+
+#define call (op.u.efi_runtime_call)

I think not.

??? (Read: What's wrong with putting this shortcut in place?)

Quoted 11 lines

drivers/xen/efi.c line 36

Quoted 5 lines
drivers/xen/efi.c new file +5 -0
+#define DECLARE_CALL(what) \
+	struct xen_platform_op op; \
+	op.cmd = XENPF_efi_runtime_call; \
+	call.function = XEN_EFI_##what; \
+	call.misc = 0

Macros like this which explicitly create local variable with implicit names are evil when reading code.

If you want to do initialisation like this, then at least do something like:

Quoted 8 lines

#define INIT_EFI_CALL(what) \

{ .cmd = XENPF_efi_runtime_call, \
   .u.efi_runtime_call.function = XEN_EFI_##what, \
   .u.efi_runtime_call.misc = 0 }

And use it as:

struct xen_platform_op op = INIT_EFI_CALL(foo);

That's minimal redundancy as a goal versus (to you, but not to me) legibility.

Jan

#20 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Andrew Cooper
Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 15:39, <[email protected]> wrote:
Quoted 26 lines · Daniel Kiper
drivers/xen/efi.c new file +25 -0
@@ -0,0 +1,374 @@
+/*
+ * EFI support for Xen.
+ *
+ * Copyright (C) 1999 VA Linux Systems
+ * Copyright (C) 1999 Walt Drummond <[email protected]>
+ * Copyright (C) 1999-2002 Hewlett-Packard Co.
+ *	David Mosberger-Tang <[email protected]>
+ *	Stephane Eranian <[email protected]>
+ * Copyright (C) 2005-2008 Intel Co.
+ *	Fenghua Yu <[email protected]>
+ *	Bibo Mao <[email protected]>
+ *	Chandramouli Narayanan <[email protected]>
+ *	Huang Ying <[email protected]>
+ * Copyright (C) 2011 Novell Co.
+ *	Jan Beulich <[email protected]>
+ * Copyright (C) 2011-2012 Oracle Co.
+ *	Liang Tang <[email protected]>
+ * Copyright (c) 2014 Daniel Kiper, Oracle Corporation
+ */
+
+#include <linux/bug.h>
+#include <linux/efi.h>
+#include <linux/init.h>
+#include <linux/string.h>
+
Quoted 8 lines

drivers/xen/efi.c line 31

Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+#include <xen/interface/xen.h>
+#include <xen/interface/platform.h>
+
+#include <asm/xen/hypercall.h>
+
+#define call (op.u.efi_runtime_call)

I think not.

??? (Read: What's wrong with putting this shortcut in place?)

Quoted 11 lines

drivers/xen/efi.c line 36

Quoted 5 lines
drivers/xen/efi.c new file +5 -0
+#define DECLARE_CALL(what) \
+	struct xen_platform_op op; \
+	op.cmd = XENPF_efi_runtime_call; \
+	call.function = XEN_EFI_##what; \
+	call.misc = 0

Macros like this which explicitly create local variable with implicit names are evil when reading code.

If you want to do initialisation like this, then at least do something like:

Quoted 8 lines

#define INIT_EFI_CALL(what) \

{ .cmd = XENPF_efi_runtime_call, \
   .u.efi_runtime_call.function = XEN_EFI_##what, \
   .u.efi_runtime_call.misc = 0 }

And use it as:

struct xen_platform_op op = INIT_EFI_CALL(foo);

That's minimal redundancy as a goal versus (to you, but not to me) legibility.

Jan

#21 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Daniel Kiper
Quoted 22 lines · Daniel Kiper
drivers/xen/efi.c new file +21 -0
@@ -0,0 +1,374 @@
+/*
+ * EFI support for Xen.
+ *
+ * Copyright (C) 1999 VA Linux Systems
+ * Copyright (C) 1999 Walt Drummond <[email protected]>
+ * Copyright (C) 1999-2002 Hewlett-Packard Co.
+ *	David Mosberger-Tang <[email protected]>
+ *	Stephane Eranian <[email protected]>
+ * Copyright (C) 2005-2008 Intel Co.
+ *	Fenghua Yu <[email protected]>
+ *	Bibo Mao <[email protected]>
+ *	Chandramouli Narayanan <[email protected]>
+ *	Huang Ying <[email protected]>
+ * Copyright (C) 2011 Novell Co.
+ *	Jan Beulich <[email protected]>
+ * Copyright (C) 2011-2012 Oracle Co.
+ *	Liang Tang <[email protected]>
+ * Copyright (c) 2014 Daniel Kiper, Oracle Corporation
+ */
+
+#include <linux/bug.h>

drivers/xen/efi.c line 31

Quoted 10 lines
drivers/xen/efi.c new file +10 -0
+#include <linux/efi.h>
+#include <linux/init.h>
+#include <linux/string.h>
+
+#include <xen/interface/xen.h>
+#include <xen/interface/platform.h>
+
+#include <asm/xen/hypercall.h>
+
+#define call (op.u.efi_runtime_call)

I think not.

drivers/xen/efi.c line 36

Quoted 5 lines
drivers/xen/efi.c new file +5 -0
+#define DECLARE_CALL(what) \
+	struct xen_platform_op op; \
+	op.cmd = XENPF_efi_runtime_call; \
+	call.function = XEN_EFI_##what; \
+	call.misc = 0

Macros like this which explicitly create local variable with implicit names are evil when reading code.

If you want to do initialisation like this, then at least do something like:

#define INIT_EFI_CALL(what) \
{ .cmd = XENPF_efi_runtime_call, \
.u.efi_runtime_call.function = XEN_EFI_##what, \
.u.efi_runtime_call.misc = 0 }

And use it as:

struct xen_platform_op op = INIT_EFI_CALL(foo);

~Andrew

#22 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Daniel Kiper

drivers/xen/Kconfig config XEN_MCE_LOG · line 244

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.05.14 at 22:41, <[email protected]> wrote:
drivers/xen/Kconfig +2 -0
@@ -240,4 +240,7 @@ config XEN_MCE_LOG
 config XEN_HAVE_PVMMU
        bool
 
+config XEN_EFI
+	def_bool X86_64 && EFI

Constructs like this are bogus - they needlessly add a line to .config when the expression evaluates to false.

config XEN_EFI

	def_bool y
	depends on X86_64 && EFI

is what avoids this.

Quoted 11 lines
drivers/xen/Kconfig +11 -0
+static efi_status_t xen_efi_get_variable(efi_char16_t *name,
+					 efi_guid_t *vendor,
+					 u32 *attr,
+					 unsigned long *data_size,
+					 void *data)
+{
+	int err;
+	DECLARE_CALL(get_variable);
+
+	set_xen_guest_handle(call.u.get_variable.name, name);
+	BUILD_BUG_ON(sizeof(*vendor) !=

drivers/xen/Kconfig config XEN_MCE_LOG

Quoted 10 lines
drivers/xen/Kconfig +10 -0
+		     sizeof(call.u.get_variable.vendor_guid));
+	memcpy(&call.u.get_variable.vendor_guid, vendor, sizeof(*vendor));
+	call.u.get_variable.size = *data_size;
+	set_xen_guest_handle(call.u.get_variable.data, data);
+	err = HYPERVISOR_dom0_op(&op);
+	if (err)
+		return EFI_UNSUPPORTED;
+
+	*data_size = call.u.get_variable.size;
+	*attr = call.misc; /* misc in struction is U32 variable*/

Iirc attr is an optional output, i.e. can be NULL, which hence needs to be checked for here. I remember that this was broken in the original EFI patch in our trees, so perhaps it would be good for you to re-check against recent sources of ours for eventual other bug fixes.

drivers/xen/Kconfig

Quoted 11 lines
drivers/xen/Kconfig +11 -0
+static efi_status_t xen_efi_query_variable_info(u32 attr,
+						u64 *storage_space,
+						u64 *remaining_space,
+						u64 *max_variable_size)
+{
+	int err;
+	DECLARE_CALL(query_variable_info);
+
+	if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
+		return EFI_UNSUPPORTED;
+

Here's a similar case - there is

	call.u.query_variable_info.attr = attr;

missing.

drivers/xen/Kconfig

Quoted 3 lines
drivers/xen/Kconfig +3 -0
+static efi_char16_t vendor[100] __initdata;
+static const efi_char16_t unknown[] __initconst =
+			{'U', 'N', 'K', 'N', 'O', 'W', 'N', '\0'};

If you enforced -fshort-wchar for the file's compilation, this could be written in a more legible manner (and probably you wouldn't need a named variable at all).

Jan

#23 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Daniel Kiper

drivers/xen/Kconfig config XEN_MCE_LOG · line 244

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.05.14 at 22:41, <[email protected]> wrote:
drivers/xen/Kconfig +2 -0
@@ -240,4 +240,7 @@ config XEN_MCE_LOG
 config XEN_HAVE_PVMMU
        bool
 
+config XEN_EFI
+	def_bool X86_64 && EFI

Constructs like this are bogus - they needlessly add a line to .config when the expression evaluates to false.

config XEN_EFI

	def_bool y
	depends on X86_64 && EFI

is what avoids this.

Quoted 11 lines
drivers/xen/Kconfig +11 -0
+static efi_status_t xen_efi_get_variable(efi_char16_t *name,
+					 efi_guid_t *vendor,
+					 u32 *attr,
+					 unsigned long *data_size,
+					 void *data)
+{
+	int err;
+	DECLARE_CALL(get_variable);
+
+	set_xen_guest_handle(call.u.get_variable.name, name);
+	BUILD_BUG_ON(sizeof(*vendor) !=

drivers/xen/Kconfig config XEN_MCE_LOG

Quoted 10 lines
drivers/xen/Kconfig +10 -0
+		     sizeof(call.u.get_variable.vendor_guid));
+	memcpy(&call.u.get_variable.vendor_guid, vendor, sizeof(*vendor));
+	call.u.get_variable.size = *data_size;
+	set_xen_guest_handle(call.u.get_variable.data, data);
+	err = HYPERVISOR_dom0_op(&op);
+	if (err)
+		return EFI_UNSUPPORTED;
+
+	*data_size = call.u.get_variable.size;
+	*attr = call.misc; /* misc in struction is U32 variable*/

Iirc attr is an optional output, i.e. can be NULL, which hence needs to be checked for here. I remember that this was broken in the original EFI patch in our trees, so perhaps it would be good for you to re-check against recent sources of ours for eventual other bug fixes.

drivers/xen/Kconfig

Quoted 11 lines
drivers/xen/Kconfig +11 -0
+static efi_status_t xen_efi_query_variable_info(u32 attr,
+						u64 *storage_space,
+						u64 *remaining_space,
+						u64 *max_variable_size)
+{
+	int err;
+	DECLARE_CALL(query_variable_info);
+
+	if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
+		return EFI_UNSUPPORTED;
+

Here's a similar case - there is

	call.u.query_variable_info.attr = attr;

missing.

drivers/xen/Kconfig

Quoted 3 lines
drivers/xen/Kconfig +3 -0
+static efi_char16_t vendor[100] __initdata;
+static const efi_char16_t unknown[] __initconst =
+			{'U', 'N', 'K', 'N', 'O', 'W', 'N', '\0'};

If you enforced -fshort-wchar for the file's compilation, this could be written in a more legible manner (and probably you wouldn't need a named variable at all).

Jan

#24 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Daniel Kiper
Quoted 1 line · Daniel Kiper

Put EFI machinery for Xen in place.

Put what machinery to do what?

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1736

Quoted 13 lines
arch/x86/xen/enlighten.c +9 -0
@@ -1714,6 +1725,21 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen) {
+		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+				sizeof(boot_params.efi_info.efi_loader_signature));
+		boot_params.efi_info.efi_systab = (__u32)((__u64)efi_systab_xen);
+		boot_params.efi_info.efi_systab_hi = (__u32)((__u64)efi_systab_xen >> 32);
+
+		x86_platform.get_wallclock = efi_get_time;

x86_platform.get_wallclock should always be xen_get_wallclock().

drivers/xen/efi.c line 1

Quoted 13 lines
arch/x86/xen/enlighten.c +6 -0
+		x86_platform.set_wallclock = efi_set_rtc_mmss;
+
+		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_64BIT, &efi.flags);
+	}
+
 	/* Start the world */
 #ifdef CONFIG_X86_32
 	i386_start_kernel();
drivers/xen/efi.c new file +1 -0
@@ -0,0 +1,374 @@
+ * Copyright (c) 2014 Daniel Kiper, Oracle Corporation

Is this really copyright by you personally and not Oracle?

drivers/xen/efi.c line 36

Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+#define call (op.u.efi_runtime_call)
+#define DECLARE_CALL(what) \
+	struct xen_platform_op op; \
+	op.cmd = XENPF_efi_runtime_call; \
+	call.function = XEN_EFI_##what; \
+	call.misc = 0

Macros that declare local variables are awful.

Use what Andrew suggested and something like

struct xen_blah *call = &op.u.efi_runtime_call;

Quoted 17 lines
drivers/xen/efi.c new file +17 -0
+static const struct efi efi_xen __initconst = {
+	.systab                   = NULL, /* Initialized later. */
+	.runtime_version	  = 0,    /* Initialized later. */
+	.mps                      = EFI_INVALID_TABLE_ADDR,
+	.acpi                     = EFI_INVALID_TABLE_ADDR,
+	.acpi20                   = EFI_INVALID_TABLE_ADDR,
+	.smbios                   = EFI_INVALID_TABLE_ADDR,
+	.sal_systab               = EFI_INVALID_TABLE_ADDR,
+	.boot_info                = EFI_INVALID_TABLE_ADDR,
+	.hcdp                     = EFI_INVALID_TABLE_ADDR,
+	.uga                      = EFI_INVALID_TABLE_ADDR,
+	.uv_systab                = EFI_INVALID_TABLE_ADDR,
+	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
+	.runtime                  = EFI_INVALID_TABLE_ADDR,
+	.config_table             = EFI_INVALID_TABLE_ADDR,
+	.get_time                 = xen_efi_get_time,
+	.set_time                 = xen_efi_set_time,

drivers/xen/efi.c line 314

Quoted 10 lines
drivers/xen/efi.c new file +10 -0
+	.get_wakeup_time          = xen_efi_get_wakeup_time,
+	.set_wakeup_time          = xen_efi_set_wakeup_time,
+	.get_variable             = xen_efi_get_variable,
+	.get_next_variable        = xen_efi_get_next_variable,
+	.set_variable             = xen_efi_set_variable,
+	.query_variable_info      = xen_efi_query_variable_info,
+	.update_capsule           = xen_efi_update_capsule,
+	.query_capsule_caps       = xen_efi_query_capsule_caps,
+	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
+	.reset_system             = NULL, /* Functionality provided by Xen. */

Xen provides functionality to reset (just maybe not via an EFI call). Should an implementation be provided that does this?

Quoted 8 lines
drivers/xen/efi.c new file +8 -0
+	.set_virtual_address_map  = NULL, /* Not used under Xen. */
+	.memmap                   = NULL, /* Not used under Xen. */
+	.flags			  = 0     /* Initialized later. */
+};
+
+efi_system_table_t __init *xen_efi_probe(void)
+{
+	struct xen_platform_op op = {

drivers/xen/efi.c line 332

Quoted 10 lines
drivers/xen/efi.c new file +10 -0
+		.cmd = XENPF_firmware_info,
+		.u.firmware_info = {
+			.type = XEN_FW_EFI_INFO,
+			.index = XEN_FW_EFI_CONFIG_TABLE
+		}
+	};
+	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
+	if (!xen_initial_domain() || HYPERVISOR_dom0_op(&op))
+		return NULL;
	if (!xen_initial_domain())
		return NULL;

	if (HYPERVISOR_dom0_op(&op) < 0)
		return NULL;

drivers/xen/efi.c line 344

Quoted 12 lines
drivers/xen/efi.c new file +12 -0
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (!HYPERVISOR_dom0_op(&op)) {

if (HYPERVISOR_dom0_op(&op) == 0)

David

#25 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

Quoted 9 lines · David Vrabel
Quoted 1 line · Daniel Kiper

Put EFI machinery for Xen in place.

Put what machinery to do what?

Quoted 4 lines
arch/x86/xen/enlighten.c +0 -0
@@ -1714,6 +1725,21 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
Quoted 11 lines

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1736

Quoted 9 lines
arch/x86/xen/enlighten.c +9 -0
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen) {
+		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+				sizeof(boot_params.efi_info.efi_loader_signature));
+		boot_params.efi_info.efi_systab = (__u32)((__u64)efi_systab_xen);
+		boot_params.efi_info.efi_systab_hi = (__u32)((__u64)efi_systab_xen >> 32);
+
+		x86_platform.get_wallclock = efi_get_time;

x86_platform.get_wallclock should always be xen_get_wallclock().

Hmmm... Make sens... Jan, why did you replace x86_platform.get_wallclock with efi_get_time() in your implementation?

Quoted 1 line

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1737

Quoted 1 line
arch/x86/xen/enlighten.c +1 -0
+		x86_platform.set_wallclock = efi_set_rtc_mmss;

Now I am not sure even about that. As I can see Linux Kernel running on bare metal EFI platform directly sets RTC omitting efi_set_rtc_mmss(). Am I missing something? IIRC, there was discussion about that once. But where and when?

Anyway, now I think that this initialization should be done in arch/x86/xen/time.c if needed.

Quoted 6 lines
Quoted 6 lines
arch/x86/xen/enlighten.c +5 -0
+
+		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_64BIT, &efi.flags);
+	}
+
 	/* Start the world */
Quoted 8 lines

drivers/xen/efi.c line 1

Quoted 6 lines
arch/x86/xen/enlighten.c +0 -0
 #ifdef CONFIG_X86_32
 	i386_start_kernel();
drivers/xen/efi.c new file +1 -0
@@ -0,0 +1,374 @@
+ * Copyright (c) 2014 Daniel Kiper, Oracle Corporation

Is this really copyright by you personally and not Oracle?

As I know it is correct but I will double check it.

Quoted 38 lines

drivers/xen/efi.c line 36

Quoted 8 lines
drivers/xen/efi.c new file +6 -0
+#define call (op.u.efi_runtime_call)
+#define DECLARE_CALL(what) \
+	struct xen_platform_op op; \
+	op.cmd = XENPF_efi_runtime_call; \
+	call.function = XEN_EFI_##what; \
+	call.misc = 0

Macros that declare local variables are awful.

Use what Andrew suggested and something like

struct xen_blah *call = &op.u.efi_runtime_call;

Quoted 22 lines
drivers/xen/efi.c new file +22 -0
+static const struct efi efi_xen __initconst = {
+	.systab                   = NULL, /* Initialized later. */
+	.runtime_version	  = 0,    /* Initialized later. */
+	.mps                      = EFI_INVALID_TABLE_ADDR,
+	.acpi                     = EFI_INVALID_TABLE_ADDR,
+	.acpi20                   = EFI_INVALID_TABLE_ADDR,
+	.smbios                   = EFI_INVALID_TABLE_ADDR,
+	.sal_systab               = EFI_INVALID_TABLE_ADDR,
+	.boot_info                = EFI_INVALID_TABLE_ADDR,
+	.hcdp                     = EFI_INVALID_TABLE_ADDR,
+	.uga                      = EFI_INVALID_TABLE_ADDR,
+	.uv_systab                = EFI_INVALID_TABLE_ADDR,
+	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
+	.runtime                  = EFI_INVALID_TABLE_ADDR,
+	.config_table             = EFI_INVALID_TABLE_ADDR,
+	.get_time                 = xen_efi_get_time,
+	.set_time                 = xen_efi_set_time,
+	.get_wakeup_time          = xen_efi_get_wakeup_time,
+	.set_wakeup_time          = xen_efi_set_wakeup_time,
+	.get_variable             = xen_efi_get_variable,
+	.get_next_variable        = xen_efi_get_next_variable,
+	.set_variable             = xen_efi_set_variable,
Quoted 8 lines

drivers/xen/efi.c line 314

Quoted 5 lines
drivers/xen/efi.c new file +5 -0
+	.query_variable_info      = xen_efi_query_variable_info,
+	.update_capsule           = xen_efi_update_capsule,
+	.query_capsule_caps       = xen_efi_query_capsule_caps,
+	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
+	.reset_system             = NULL, /* Functionality provided by Xen. */

Xen provides functionality to reset (just maybe not via an EFI call). Should an implementation be provided that does this?

I do not think so. efi.reset_system() would not be called on Xen because all reset related stuff is replaced by Xen reset specific functions. Please check arch/x86/xen/enlighten.c. Additionally, I think that situation is a bit similar to time issue. If we are running on Xen then we should ask Xen to do reset because Xen controls platform and it knows how to do that.

Quoted 16 lines
Quoted 16 lines
drivers/xen/efi.c new file +16 -0
+	.set_virtual_address_map  = NULL, /* Not used under Xen. */
+	.memmap                   = NULL, /* Not used under Xen. */
+	.flags			  = 0     /* Initialized later. */
+};
+
+efi_system_table_t __init *xen_efi_probe(void)
+{
+	struct xen_platform_op op = {
+		.cmd = XENPF_firmware_info,
+		.u.firmware_info = {
+			.type = XEN_FW_EFI_INFO,
+			.index = XEN_FW_EFI_CONFIG_TABLE
+		}
+	};
+	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
Quoted 8 lines

drivers/xen/efi.c line 332

Quoted 2 lines
drivers/xen/efi.c new file +2 -0
+	if (!xen_initial_domain() || HYPERVISOR_dom0_op(&op))
+		return NULL;
	if (!xen_initial_domain())
		return NULL;

	if (HYPERVISOR_dom0_op(&op) < 0)
		return NULL;

What is wrong with my if?

Quoted 6 lines
Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	op.cmd = XENPF_firmware_info;
Quoted 8 lines

drivers/xen/efi.c line 344

Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (!HYPERVISOR_dom0_op(&op)) {

if (HYPERVISOR_dom0_op(&op) == 0)

Ditto?

Daniel

#26 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 13:29, <[email protected]>…
Quoted 5 lines · David Vrabel
Quoted 4 lines · Daniel Kiper
arch/x86/xen/enlighten.c +0 -0
@@ -1714,6 +1725,21 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
Quoted 11 lines

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1736

Quoted 9 lines
arch/x86/xen/enlighten.c +9 -0
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen) {
+		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+				sizeof(boot_params.efi_info.efi_loader_signature));
+		boot_params.efi_info.efi_systab = (__u32)((__u64)efi_systab_xen);
+		boot_params.efi_info.efi_systab_hi = (__u32)((__u64)efi_systab_xen >> 32);
+
+		x86_platform.get_wallclock = efi_get_time;

x86_platform.get_wallclock should always be xen_get_wallclock().

Quoted 2 lines

Hmmm... Make sens... Jan, why did you replace x86_platform.get_wallclock with efi_get_time() in your implementation?

On the basis that (for Dom0 only) this is the equivalent of (and actually also falls back to) mach_get_cmos_time(). If on Dom0 .get_wallclock doesn't get set to mach_get_cmos_time() on pv-ops, then that line above should also be dropped.

Jan

#27 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Daniel Kiper
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 13:29, <[email protected]> wrote:
Quoted 5 lines · David Vrabel
Quoted 4 lines · Daniel Kiper
arch/x86/xen/enlighten.c +0 -0
@@ -1714,6 +1725,21 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
Quoted 11 lines

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1736

Quoted 9 lines
arch/x86/xen/enlighten.c +9 -0
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen) {
+		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+				sizeof(boot_params.efi_info.efi_loader_signature));
+		boot_params.efi_info.efi_systab = (__u32)((__u64)efi_systab_xen);
+		boot_params.efi_info.efi_systab_hi = (__u32)((__u64)efi_systab_xen >> 32);
+
+		x86_platform.get_wallclock = efi_get_time;

x86_platform.get_wallclock should always be xen_get_wallclock().

Quoted 2 lines

Hmmm... Make sens... Jan, why did you replace x86_platform.get_wallclock with efi_get_time() in your implementation?

On the basis that (for Dom0 only) this is the equivalent of (and actually also falls back to) mach_get_cmos_time(). If on Dom0 .get_wallclock doesn't get set to mach_get_cmos_time() on pv-ops, then that line above should also be dropped.

Jan

#28 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Daniel Kiper
Quoted 11 lines · Daniel Kiper
Quoted 9 lines

drivers/xen/efi.c line 332

Quoted 3 lines
drivers/xen/efi.c new file +2 -0
+	if (!xen_initial_domain() || HYPERVISOR_dom0_op(&op))
+		return NULL;
	if (!xen_initial_domain())
		return NULL;

	if (HYPERVISOR_dom0_op(&op) < 0)
		return NULL;

What is wrong with my if?

Style. The function returns -ve on error not a boolean success/fail.

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	op.cmd = XENPF_firmware_info;
Quoted 8 lines

drivers/xen/efi.c line 344

Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (!HYPERVISOR_dom0_op(&op)) {

if (HYPERVISOR_dom0_op(&op) == 0)

Quoted 1 line

Ditto?

Again, style.

David

#29 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Daniel Kiper
Quoted 11 lines · Daniel Kiper
Quoted 9 lines

drivers/xen/efi.c line 332

Quoted 3 lines
drivers/xen/efi.c new file +2 -0
+	if (!xen_initial_domain() || HYPERVISOR_dom0_op(&op))
+		return NULL;
	if (!xen_initial_domain())
		return NULL;

	if (HYPERVISOR_dom0_op(&op) < 0)
		return NULL;

What is wrong with my if?

Style. The function returns -ve on error not a boolean success/fail.

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	op.cmd = XENPF_firmware_info;
Quoted 8 lines

drivers/xen/efi.c line 344

Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (!HYPERVISOR_dom0_op(&op)) {

if (HYPERVISOR_dom0_op(&op) == 0)

Quoted 1 line

Ditto?

Again, style.

David

#30 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to David Vrabel
Quoted 9 lines · David Vrabel
Quoted 1 line · Daniel Kiper

Put EFI machinery for Xen in place.

Put what machinery to do what?

Quoted 4 lines
arch/x86/xen/enlighten.c +0 -0
@@ -1714,6 +1725,21 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
Quoted 11 lines

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1736

Quoted 9 lines
arch/x86/xen/enlighten.c +9 -0
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen) {
+		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+				sizeof(boot_params.efi_info.efi_loader_signature));
+		boot_params.efi_info.efi_systab = (__u32)((__u64)efi_systab_xen);
+		boot_params.efi_info.efi_systab_hi = (__u32)((__u64)efi_systab_xen >> 32);
+
+		x86_platform.get_wallclock = efi_get_time;

x86_platform.get_wallclock should always be xen_get_wallclock().

Hmmm... Make sens... Jan, why did you replace x86_platform.get_wallclock with efi_get_time() in your implementation?

Quoted 1 line

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1737

Quoted 1 line
arch/x86/xen/enlighten.c +1 -0
+		x86_platform.set_wallclock = efi_set_rtc_mmss;

Now I am not sure even about that. As I can see Linux Kernel running on bare metal EFI platform directly sets RTC omitting efi_set_rtc_mmss(). Am I missing something? IIRC, there was discussion about that once. But where and when?

Anyway, now I think that this initialization should be done in arch/x86/xen/time.c if needed.

Quoted 6 lines
Quoted 6 lines
arch/x86/xen/enlighten.c +5 -0
+
+		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_64BIT, &efi.flags);
+	}
+
 	/* Start the world */
Quoted 8 lines

drivers/xen/efi.c line 1

Quoted 6 lines
arch/x86/xen/enlighten.c +0 -0
 #ifdef CONFIG_X86_32
 	i386_start_kernel();
drivers/xen/efi.c new file +1 -0
@@ -0,0 +1,374 @@
+ * Copyright (c) 2014 Daniel Kiper, Oracle Corporation

Is this really copyright by you personally and not Oracle?

As I know it is correct but I will double check it.

Quoted 38 lines

drivers/xen/efi.c line 36

Quoted 8 lines
drivers/xen/efi.c new file +6 -0
+#define call (op.u.efi_runtime_call)
+#define DECLARE_CALL(what) \
+	struct xen_platform_op op; \
+	op.cmd = XENPF_efi_runtime_call; \
+	call.function = XEN_EFI_##what; \
+	call.misc = 0

Macros that declare local variables are awful.

Use what Andrew suggested and something like

struct xen_blah *call = &op.u.efi_runtime_call;

Quoted 22 lines
drivers/xen/efi.c new file +22 -0
+static const struct efi efi_xen __initconst = {
+	.systab                   = NULL, /* Initialized later. */
+	.runtime_version	  = 0,    /* Initialized later. */
+	.mps                      = EFI_INVALID_TABLE_ADDR,
+	.acpi                     = EFI_INVALID_TABLE_ADDR,
+	.acpi20                   = EFI_INVALID_TABLE_ADDR,
+	.smbios                   = EFI_INVALID_TABLE_ADDR,
+	.sal_systab               = EFI_INVALID_TABLE_ADDR,
+	.boot_info                = EFI_INVALID_TABLE_ADDR,
+	.hcdp                     = EFI_INVALID_TABLE_ADDR,
+	.uga                      = EFI_INVALID_TABLE_ADDR,
+	.uv_systab                = EFI_INVALID_TABLE_ADDR,
+	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
+	.runtime                  = EFI_INVALID_TABLE_ADDR,
+	.config_table             = EFI_INVALID_TABLE_ADDR,
+	.get_time                 = xen_efi_get_time,
+	.set_time                 = xen_efi_set_time,
+	.get_wakeup_time          = xen_efi_get_wakeup_time,
+	.set_wakeup_time          = xen_efi_set_wakeup_time,
+	.get_variable             = xen_efi_get_variable,
+	.get_next_variable        = xen_efi_get_next_variable,
+	.set_variable             = xen_efi_set_variable,
Quoted 8 lines

drivers/xen/efi.c line 314

Quoted 5 lines
drivers/xen/efi.c new file +5 -0
+	.query_variable_info      = xen_efi_query_variable_info,
+	.update_capsule           = xen_efi_update_capsule,
+	.query_capsule_caps       = xen_efi_query_capsule_caps,
+	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
+	.reset_system             = NULL, /* Functionality provided by Xen. */

Xen provides functionality to reset (just maybe not via an EFI call). Should an implementation be provided that does this?

I do not think so. efi.reset_system() would not be called on Xen because all reset related stuff is replaced by Xen reset specific functions. Please check arch/x86/xen/enlighten.c. Additionally, I think that situation is a bit similar to time issue. If we are running on Xen then we should ask Xen to do reset because Xen controls platform and it knows how to do that.

Quoted 16 lines
Quoted 16 lines
drivers/xen/efi.c new file +16 -0
+	.set_virtual_address_map  = NULL, /* Not used under Xen. */
+	.memmap                   = NULL, /* Not used under Xen. */
+	.flags			  = 0     /* Initialized later. */
+};
+
+efi_system_table_t __init *xen_efi_probe(void)
+{
+	struct xen_platform_op op = {
+		.cmd = XENPF_firmware_info,
+		.u.firmware_info = {
+			.type = XEN_FW_EFI_INFO,
+			.index = XEN_FW_EFI_CONFIG_TABLE
+		}
+	};
+	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
Quoted 8 lines

drivers/xen/efi.c line 332

Quoted 2 lines
drivers/xen/efi.c new file +2 -0
+	if (!xen_initial_domain() || HYPERVISOR_dom0_op(&op))
+		return NULL;
	if (!xen_initial_domain())
		return NULL;

	if (HYPERVISOR_dom0_op(&op) < 0)
		return NULL;

What is wrong with my if?

Quoted 6 lines
Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	op.cmd = XENPF_firmware_info;
Quoted 8 lines

drivers/xen/efi.c line 344

Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (!HYPERVISOR_dom0_op(&op)) {

if (HYPERVISOR_dom0_op(&op) == 0)

Ditto?

Daniel

#31 lore raw

Re: [PATCH v4 3/5] xen: Put EFI machinery in place

In reply to Daniel Kiper
Quoted 1 line · Daniel Kiper

Put EFI machinery for Xen in place.

Put what machinery to do what?

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1736

Quoted 13 lines
arch/x86/xen/enlighten.c +9 -0
@@ -1714,6 +1725,21 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen) {
+		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+				sizeof(boot_params.efi_info.efi_loader_signature));
+		boot_params.efi_info.efi_systab = (__u32)((__u64)efi_systab_xen);
+		boot_params.efi_info.efi_systab_hi = (__u32)((__u64)efi_systab_xen >> 32);
+
+		x86_platform.get_wallclock = efi_get_time;

x86_platform.get_wallclock should always be xen_get_wallclock().

drivers/xen/efi.c line 1

Quoted 13 lines
arch/x86/xen/enlighten.c +6 -0
+		x86_platform.set_wallclock = efi_set_rtc_mmss;
+
+		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_64BIT, &efi.flags);
+	}
+
 	/* Start the world */
 #ifdef CONFIG_X86_32
 	i386_start_kernel();
drivers/xen/efi.c new file +1 -0
@@ -0,0 +1,374 @@
+ * Copyright (c) 2014 Daniel Kiper, Oracle Corporation

Is this really copyright by you personally and not Oracle?

drivers/xen/efi.c line 36

Quoted 6 lines
drivers/xen/efi.c new file +6 -0
+#define call (op.u.efi_runtime_call)
+#define DECLARE_CALL(what) \
+	struct xen_platform_op op; \
+	op.cmd = XENPF_efi_runtime_call; \
+	call.function = XEN_EFI_##what; \
+	call.misc = 0

Macros that declare local variables are awful.

Use what Andrew suggested and something like

struct xen_blah *call = &op.u.efi_runtime_call;

Quoted 17 lines
drivers/xen/efi.c new file +17 -0
+static const struct efi efi_xen __initconst = {
+	.systab                   = NULL, /* Initialized later. */
+	.runtime_version	  = 0,    /* Initialized later. */
+	.mps                      = EFI_INVALID_TABLE_ADDR,
+	.acpi                     = EFI_INVALID_TABLE_ADDR,
+	.acpi20                   = EFI_INVALID_TABLE_ADDR,
+	.smbios                   = EFI_INVALID_TABLE_ADDR,
+	.sal_systab               = EFI_INVALID_TABLE_ADDR,
+	.boot_info                = EFI_INVALID_TABLE_ADDR,
+	.hcdp                     = EFI_INVALID_TABLE_ADDR,
+	.uga                      = EFI_INVALID_TABLE_ADDR,
+	.uv_systab                = EFI_INVALID_TABLE_ADDR,
+	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
+	.runtime                  = EFI_INVALID_TABLE_ADDR,
+	.config_table             = EFI_INVALID_TABLE_ADDR,
+	.get_time                 = xen_efi_get_time,
+	.set_time                 = xen_efi_set_time,

drivers/xen/efi.c line 314

Quoted 10 lines
drivers/xen/efi.c new file +10 -0
+	.get_wakeup_time          = xen_efi_get_wakeup_time,
+	.set_wakeup_time          = xen_efi_set_wakeup_time,
+	.get_variable             = xen_efi_get_variable,
+	.get_next_variable        = xen_efi_get_next_variable,
+	.set_variable             = xen_efi_set_variable,
+	.query_variable_info      = xen_efi_query_variable_info,
+	.update_capsule           = xen_efi_update_capsule,
+	.query_capsule_caps       = xen_efi_query_capsule_caps,
+	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
+	.reset_system             = NULL, /* Functionality provided by Xen. */

Xen provides functionality to reset (just maybe not via an EFI call). Should an implementation be provided that does this?

Quoted 8 lines
drivers/xen/efi.c new file +8 -0
+	.set_virtual_address_map  = NULL, /* Not used under Xen. */
+	.memmap                   = NULL, /* Not used under Xen. */
+	.flags			  = 0     /* Initialized later. */
+};
+
+efi_system_table_t __init *xen_efi_probe(void)
+{
+	struct xen_platform_op op = {

drivers/xen/efi.c line 332

Quoted 10 lines
drivers/xen/efi.c new file +10 -0
+		.cmd = XENPF_firmware_info,
+		.u.firmware_info = {
+			.type = XEN_FW_EFI_INFO,
+			.index = XEN_FW_EFI_CONFIG_TABLE
+		}
+	};
+	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
+	if (!xen_initial_domain() || HYPERVISOR_dom0_op(&op))
+		return NULL;
	if (!xen_initial_domain())
		return NULL;

	if (HYPERVISOR_dom0_op(&op) < 0)
		return NULL;

drivers/xen/efi.c line 344

Quoted 12 lines
drivers/xen/efi.c new file +12 -0
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (!HYPERVISOR_dom0_op(&op)) {

if (HYPERVISOR_dom0_op(&op) == 0)

David

#32 lore raw

PATCH v4 3/5 xen: Put EFI machinery in place

In reply to Daniel Kiper

Put EFI machinery for Xen in place.

This patch is based on Jan Beulich and Tang Liang work.

v4 - suggestions/fixes:
- "just populate an efi_system_table_t object" (suggested by Matt Fleming).

---
 arch/x86/xen/enlighten.c |   26 ++++
 drivers/xen/Kconfig      |    3 +
 drivers/xen/Makefile     |    1 +
 drivers/xen/efi.c        |  374 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 404 insertions(+)
 create mode 100644 drivers/xen/efi.c
arch/x86/xen/enlighten.c +26 -0
index c34bfc4..d5cc21f 100644
@@ -32,6 +32,7 @@
 #include <linux/gfp.h>
 #include <linux/memblock.h>
 #include <linux/edd.h>
+#include <linux/efi.h>
 
 #include <xen/xen.h>
 #include <xen/events.h>
@@ -150,6 +151,15 @@ struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info;
  */
 static int have_vcpu_info_placement = 1;
 
+#ifdef CONFIG_XEN_EFI
+extern efi_system_table_t __init *xen_efi_probe(void);
+#else
+static efi_system_table_t __init *xen_efi_probe(void)
+{
+	return NULL;
+}
+#endif
+
 struct tls_descs {
 	struct desc_struct desc[3];
 };
@@ -1519,6 +1529,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 {
 	struct physdev_set_iopl set_iopl;
 	int rc;
+	efi_system_table_t *efi_systab_xen;
 
 	if (!xen_start_info)
 		return;
@@ -1714,6 +1725,21 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen) {
+		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+				sizeof(boot_params.efi_info.efi_loader_signature));
+		boot_params.efi_info.efi_systab = (__u32)((__u64)efi_systab_xen);
+		boot_params.efi_info.efi_systab_hi = (__u32)((__u64)efi_systab_xen >> 32);
+
+		x86_platform.get_wallclock = efi_get_time;
+		x86_platform.set_wallclock = efi_set_rtc_mmss;
+
+		set_bit(EFI_BOOT, &efi.flags);
+		set_bit(EFI_64BIT, &efi.flags);
+	}
+
 	/* Start the world */
 #ifdef CONFIG_X86_32
 	i386_start_kernel();
drivers/xen/Kconfig +3 -0
index 38fb36e..cead283 100644
@@ -240,4 +240,7 @@ config XEN_MCE_LOG
 config XEN_HAVE_PVMMU
        bool
 
+config XEN_EFI
+	def_bool X86_64 && EFI
+
 endmenu
drivers/xen/Makefile +1 -0
index 45e00af..c35de02 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_XEN_STUB)			+= xen-stub.o
 obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY)	+= xen-acpi-memhotplug.o
 obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU)	+= xen-acpi-cpuhotplug.o
 obj-$(CONFIG_XEN_ACPI_PROCESSOR)	+= xen-acpi-processor.o
+obj-$(CONFIG_XEN_EFI)			+= efi.o
 xen-evtchn-y				:= evtchn.o
 xen-gntdev-y				:= gntdev.o
 xen-gntalloc-y				:= gntalloc.o
drivers/xen/efi.c new file +374 -0

374 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#33 lore raw

PATCH v4 4/5 arch/x86: Replace plain strings with constants

In reply to Daniel Kiper
---
 arch/x86/kernel/setup.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/setup.c +2 -2
index f41f648..7a67f5d 100644
@@ -924,11 +924,11 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #ifdef CONFIG_EFI
 	if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-		     "EL32", 4)) {
+				EFI32_LOADER_SIGNATURE, 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
 		set_bit(EFI_DIRECT, &efi.flags);
 	} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-		     "EL64", 4)) {
+				EFI64_LOADER_SIGNATURE, 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
 		set_bit(EFI_DIRECT, &efi.flags);
 		set_bit(EFI_64BIT, &efi.flags);
Signature · 1 line
1.7.10.4
#34 lore raw

Re: [PATCH v4 4/5] arch/x86: Replace plain strings with constants

Quoted 13 lines · Daniel Kiper
---
 arch/x86/kernel/setup.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/setup.c +0 -0
index f41f648..7a67f5d 100644
@@ -924,11 +924,11 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #ifdef CONFIG_EFI
 	if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,

arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 934

Quoted 10 lines
arch/x86/kernel/setup.c +2 -2
-		     "EL32", 4)) {
+				EFI32_LOADER_SIGNATURE, 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
 		set_bit(EFI_DIRECT, &efi.flags);
 	} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-		     "EL64", 4)) {
+				EFI64_LOADER_SIGNATURE, 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
 		set_bit(EFI_DIRECT, &efi.flags);
 		set_bit(EFI_64BIT, &efi.flags);

Conceptually this change is a nice cleanup, but you've also changed the indentation. Please don't do that, stick with the existing format.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#35 lore raw

Re: [PATCH v4 4/5] arch/x86: Replace plain strings with constants

In reply to Daniel Kiper
Quoted 13 lines · Daniel Kiper
---
 arch/x86/kernel/setup.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/setup.c +0 -0
index f41f648..7a67f5d 100644
@@ -924,11 +924,11 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #ifdef CONFIG_EFI
 	if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,

arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 934

Quoted 10 lines
arch/x86/kernel/setup.c +2 -2
-		     "EL32", 4)) {
+				EFI32_LOADER_SIGNATURE, 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
 		set_bit(EFI_DIRECT, &efi.flags);
 	} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-		     "EL64", 4)) {
+				EFI64_LOADER_SIGNATURE, 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
 		set_bit(EFI_DIRECT, &efi.flags);
 		set_bit(EFI_64BIT, &efi.flags);

Conceptually this change is a nice cleanup, but you've also changed the indentation. Please don't do that, stick with the existing format.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#36 lore raw

PATCH v4 4/5 arch/x86: Replace plain strings with constants

In reply to Daniel Kiper
---
 arch/x86/kernel/setup.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/setup.c +2 -2
index f41f648..7a67f5d 100644
@@ -924,11 +924,11 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #ifdef CONFIG_EFI
 	if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-		     "EL32", 4)) {
+				EFI32_LOADER_SIGNATURE, 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
 		set_bit(EFI_DIRECT, &efi.flags);
 	} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-		     "EL64", 4)) {
+				EFI64_LOADER_SIGNATURE, 4)) {
 		set_bit(EFI_BOOT, &efi.flags);
 		set_bit(EFI_DIRECT, &efi.flags);
 		set_bit(EFI_64BIT, &efi.flags);
Signature · 1 line
1.7.10.4
#37 lore raw

PATCH v4 5/5 arch/x86: Remove redundant set_bit() call

In reply to Daniel Kiper

Remove redundant set_bit(EFI_SYSTEM_TABLES, &efi.flags) call. It is executed earlier in efi_systab_init().

---
 arch/x86/platform/efi/efi.c |    2 --
 1 file changed, 2 deletions(-)
arch/x86/platform/efi/efi.c +0 -2
index 7fcef06..e7008f0 100644
@@ -754,8 +754,6 @@ void __init efi_init(void)
 	if (efi_systab_init(efi_phys.systab))
 		return;
 
-	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
-
 	efi.config_table = (unsigned long)efi.systab->tables;
 	efi.fw_vendor	 = (unsigned long)efi.systab->fw_vendor;
 	efi.runtime	 = (unsigned long)efi.systab->runtime;
Signature · 1 line
1.7.10.4
#38 lore raw

Re: [PATCH v4 5/5] arch/x86: Remove redundant set_bit() call

Quoted 7 lines · Daniel Kiper

Remove redundant set_bit(EFI_SYSTEM_TABLES, &efi.flags) call. It is executed earlier in efi_systab_init().

---
 arch/x86/platform/efi/efi.c |    2 --
 1 file changed, 2 deletions(-)

Good catch.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#39 lore raw

Re: [PATCH v4 5/5] arch/x86: Remove redundant set_bit() call

In reply to Daniel Kiper
Quoted 7 lines · Daniel Kiper

Remove redundant set_bit(EFI_SYSTEM_TABLES, &efi.flags) call. It is executed earlier in efi_systab_init().

---
 arch/x86/platform/efi/efi.c |    2 --
 1 file changed, 2 deletions(-)

Good catch.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#40 lore raw

PATCH v4 5/5 arch/x86: Remove redundant set_bit() call

In reply to Daniel Kiper

Remove redundant set_bit(EFI_SYSTEM_TABLES, &efi.flags) call. It is executed earlier in efi_systab_init().

---
 arch/x86/platform/efi/efi.c |    2 --
 1 file changed, 2 deletions(-)
arch/x86/platform/efi/efi.c +0 -2
index 7fcef06..e7008f0 100644
@@ -754,8 +754,6 @@ void __init efi_init(void)
 	if (efi_systab_init(efi_phys.systab))
 		return;
 
-	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
-
 	efi.config_table = (unsigned long)efi.systab->tables;
 	efi.fw_vendor	 = (unsigned long)efi.systab->fw_vendor;
 	efi.runtime	 = (unsigned long)efi.systab->runtime;
Signature · 1 line
1.7.10.4
#41 lore raw
In reply to Daniel Kiper
Quoted 6 lines · Daniel Kiper

Hey,

This patch series adds EFI support for Xen dom0 guests. It is based on Jan Beulich and Tang Liang work. I was trying to take into account all previous comments, however, if I missed something sorry for that.

There needs to be a better description of this series. In particular, a description of why Xen PV guests are different and the overall design used.

Quoted 6 lines

I am still not sure what to do with /sys/firmware/efi/config_table, /sys/firmware/efi/{fw_vendor,runtime,systab} files. On bare metal they contain physical addresses of relevant structures. However, in Xen case they does not make sens. So maybe they should contain invalid values (e.g. 0) or should not appear at all on Xen (I prefer last one). What do you think about that?

Generally, dom0 has provided access to BIOS provided data structures. I think you should do the same here. They may be useful for diagnostics if nothing else.

David

#42 lore raw
In reply to Daniel Kiper
Quoted 6 lines · Daniel Kiper

Hey,

This patch series adds EFI support for Xen dom0 guests. It is based on Jan Beulich and Tang Liang work. I was trying to take into account all previous comments, however, if I missed something sorry for that.

There needs to be a better description of this series. In particular, a description of why Xen PV guests are different and the overall design used.

Quoted 6 lines

I am still not sure what to do with /sys/firmware/efi/config_table, /sys/firmware/efi/{fw_vendor,runtime,systab} files. On bare metal they contain physical addresses of relevant structures. However, in Xen case they does not make sens. So maybe they should contain invalid values (e.g. 0) or should not appear at all on Xen (I prefer last one). What do you think about that?

Generally, dom0 has provided access to BIOS provided data structures. I think you should do the same here. They may be useful for diagnostics if nothing else.

David