Watchdog: introdouce ARM SBSA watchdog driver
Subsystems (12)
PATCH v6 2/8 ARM64: add SBSA Generic Watchdog device node in foundation-v8.dts
In reply to [email protected]From: Fu Wei <[email protected]>
This can be a example of adding SBSA Generic Watchdog device node into some dts files for the Soc which contains SBSA Generic Watchdog.
--- arch/arm64/boot/dts/arm/foundation-v8.dts | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/arm/foundation-v8.dts +10 -0
@@ -237,4 +237,14 @@ }; }; }; + watchdog@2a440000 { + compatible = "arm,sbsa-gwdt"; + reg = <0x0 0x2a440000 0 0x1000>, + <0x0 0x2a450000 0 0x1000>; + reg-names = "control", + "refresh"; + interrupts = <0 27 4>; + interrupt-names = "ws0"; + timeout-sec = <10 5>; + }; };
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 3/8 ARM64: add SBSA Generic Watchdog device node in amd-seattle-soc.dtsi
In reply to [email protected]From: Fu Wei <[email protected]>
This can be a example of adding SBSA Generic Watchdog device node into some dts files for the Soc which contains SBSA Generic Watchdog.
--- arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi +11 -0
@@ -84,6 +84,17 @@ clock-names = "uartclk", "apb_pclk"; }; + watchdog0: watchdog@e0bb0000 { + compatible = "arm,sbsa-gwdt"; + reg = <0x0 0xe0bb0000 0 0x1000>, + <0x0 0xe0bc0000 0 0x1000>; + reg-names = "refresh", + "control"; + interrupts = <0 337 4>; + interrupt-names = "ws0"; + timeout-sec = <10 5>; + }; + spi0: ssp@e1020000 { status = "disabled"; compatible = "arm,pl022", "arm,primecell";
Signature · 1 line
1.9.1
PATCH v6 4/8 Watchdog: introdouce "pretimeout" into framework
In reply to [email protected]From: Fu Wei <[email protected]>
Also update Documentation/watchdog/watchdog-kernel-api.txt to introduce:
(1)the new elements in the watchdog_device and watchdog_ops struct; (2)the new API "watchdog_init_timeouts"
Reasons:
(1)kernel already has two watchdog drivers are using "pretimeout":
drivers/char/ipmi/ipmi_watchdog.c drivers/watchdog/kempld_wdt.c(but the definition is different)
(2)some other drivers are going to use this: ARM SBSA Generic Watchdog
--- Documentation/watchdog/watchdog-kernel-api.txt | 47 ++++++++++-- drivers/watchdog/watchdog_core.c | 98 ++++++++++++++++++-------- drivers/watchdog/watchdog_dev.c | 53 ++++++++++++++ include/linux/watchdog.h | 39 ++++++++-- 4 files changed, 200 insertions(+), 37 deletions(-)
Documentation/watchdog/watchdog-kernel-api.txt +42 -5
@@ -49,6 +49,9 @@ struct watchdog_device { unsigned int timeout; unsigned int min_timeout; unsigned int max_timeout; + unsigned int pretimeout; + unsigned int min_pretimeout; + unsigned int max_pretimeout; void *driver_data; struct mutex lock; unsigned long status;
@@ -70,6 +73,9 @@ It contains following fields: * timeout: the watchdog timer's timeout value (in seconds). * min_timeout: the watchdog timer's minimum timeout value (in seconds). * max_timeout: the watchdog timer's maximum timeout value (in seconds). +* pretimeout: the watchdog timer's pretimeout value (in seconds). +* min_pretimeout: the watchdog timer's minimum pretimeout value (in seconds). +* max_pretimeout: the watchdog timer's maximum pretimeout value (in seconds). * bootstatus: status of the device after booting (reported with watchdog WDIOF_* status bits). * driver_data: a pointer to the drivers private data of a watchdog device.
@@ -92,6 +98,7 @@ struct watchdog_ops { int (*ping)(struct watchdog_device *); unsigned int (*status)(struct watchdog_device *); int (*set_timeout)(struct watchdog_device *, unsigned int); + int (*set_pretimeout)(struct watchdog_device *, unsigned int); unsigned int (*get_timeleft)(struct watchdog_device *); void (*ref)(struct watchdog_device *); void (*unref)(struct watchdog_device *);
@@ -153,9 +160,19 @@ they are supported. These optional routines/operations are: and -EIO for "could not write value to the watchdog". On success this routine should set the timeout value of the watchdog_device to the achieved timeout value (which may be different from the requested one - because the watchdog does not necessarily has a 1 second resolution). + because the watchdog does not necessarily has a 1 second resolution; + If the driver supports pretimeout, then the timeout value must be greater + than that). (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the watchdog's info structure). +* set_pretimeout: this routine checks and changes the pretimeout of the + watchdog timer device. It returns 0 on success, -EINVAL for "parameter out of + range" and -EIO for "could not write value to the watchdog". On success this + routine should set the pretimeout value of the watchdog_device to the + achieved pretimeout value (which may be different from the requested one + because the watchdog does not necessarily has a 1 second resolution). + (Note: the WDIOF_PRETIMEOUT needs to be set in the options field of the + watchdog's info structure). * get_timeleft: this routines returns the time that's left before a reset. * ref: the operation that calls kref_get on the kref of a dynamically allocated watchdog_device struct.
@@ -219,8 +236,28 @@ extern int watchdog_init_timeout(struct watchdog_device *wdd, unsigned int timeout_parm, struct device *dev); The watchdog_init_timeout function allows you to initialize the timeout field -using the module timeout parameter or by retrieving the timeout-sec property from -the device tree (if the module timeout parameter is invalid). Best practice is -to set the default timeout value as timeout value in the watchdog_device and -then use this function to set the user "preferred" timeout value. +using the module timeout parameter or by retrieving the first element of +the timeout-sec property from the device tree (if the module timeout parameter +is invalid). Best practice is to set the default timeout value as timeout value +in the watchdog_device and then use this function to set the user "preferred" +timeout value. +This routine returns zero on success and a negative errno code for failure. + +Some watchdog timers have two stage of timeouts (timeout and pretimeout), +to initialize the timeout and pretimeout fields at the same time, the following +function can be used: + +int watchdog_init_timeouts(struct watchdog_device *wdd, + unsigned int pretimeout_parm, + unsigned int timeout_parm, + struct device *dev); + +The watchdog_init_timeouts function allows you to initialize the pretimeout and +timeout fields using the module pretimeout and timeout parameter or by +retrieving the elements in the timeout-sec property (the first element is for +timeout, the second one is for pretimeout) from the device tree (if the module +pretimeout and timeout parameter are invalid). +Best practice is to set the default pretimeout and timeout value as pretimeout +and timeout value in the watchdog_device and then use this function to set the +user "preferred" pretimeout value. This routine returns zero on success and a negative errno code for failure.
drivers/watchdog/watchdog_core.c +70 -28
127 lines not on this page · raw message
drivers/watchdog/watchdog_dev.c +53 -0
65 lines not on this page · raw message
include/linux/watchdog.h +35 -4
@@ -25,6 +25,7 @@ struct watchdog_device;* @ping: The routine that sends a keepalive ping to the watchdog device. * @status: The routine that shows the status of the watchdog device. * @set_timeout:The routine for setting the watchdog devices timeout value. +* @set_pretimeout:The routine for setting the watchdog devices pretimeout value * @get_timeleft:The routine that get's the time that's left before a reset. * @ref: The ref operation for dyn. allocated watchdog_device structs * @unref: The unref operation for dyn. allocated watchdog_device structs
@@ -44,6 +45,7 @@ struct watchdog_ops {int (*ping)(struct watchdog_device *);unsigned int (*status)(struct watchdog_device *);int (*set_timeout)(struct watchdog_device *,unsigned int ); +int (*set_pretimeout)(struct watchdog_device *,unsigned int );unsigned int (*get_timeleft)(struct watchdog_device *);void (*ref)(struct watchdog_device *);void (*unref)(struct watchdog_device *);
@@ -62,6 +64,9 @@ struct watchdog_ops {* @timeout: The watchdog devices timeout value. * @min_timeout:The watchdog devices minimum timeout value. * @max_timeout:The watchdog devices maximum timeout value. +* @pretimeout: The watchdog devices pretimeout value. +* @min_pretimeout:The watchdog devices minimum pretimeout value. +* @max_pretimeout:The watchdog devices maximum pretimeout value. * @driver-data:Pointer to the drivers private data. * @lock: Lock for watchdog core internal use only. * @status: Field that contains the devices internal status bits.
@@ -86,6 +91,9 @@ struct watchdog_device {unsigned int timeout;unsigned int min_timeout;unsigned int max_timeout; +unsigned int pretimeout; +unsigned int min_pretimeout; +unsigned int max_pretimeout;void *driver_data;struct mutex lock;unsigned long status;
@@ -116,8 +124,22 @@ static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool noway/* Use the following function to check if a timeout value is invalid */ static inline bool watchdog_timeout_invalid (struct watchdog_device *wdd,unsigned int t) { -return ((wdd->max_timeout !=0 ) && - (t < wdd->min_timeout || t > wdd->max_timeout)); +return (wdd->max_timeout && + (t < wdd->min_timeout || t > wdd->max_timeout)) || + (wdd->pretimeout && t <= wdd->pretimeout); +} + +/* +* Use the following function to check if a pretimeout value is invalid. +* It can be "0", that means we don't use pretimeout. +* This function returns false, when pretimeout is 0. +*/ +static inline bool watchdog_pretimeout_invalid (struct watchdog_device *wdd, +unsigned int t) +{ +return t && ((wdd->max_pretimeout && + (t < wdd->min_pretimeout || t > wdd->max_pretimeout)) || + (wdd->timeout && t >= wdd->timeout)); }/* Use the following functions to manipulate watchdog driver specific data */
@@ -132,8 +154,17 @@ static inline void *watchdog_get_drvdata(struct watchdog_device *wdd) }/* drivers/watchdog/watchdog_core.c */ -extern int watchdog_init_timeout (struct watchdog_device *wdd, -unsigned int timeout_parm,struct device *dev); +int watchdog_init_timeouts (struct watchdog_device *wdd, +unsigned int pretimeout_parm, +unsigned int timeout_parm, +struct device *dev); +static inline int watchdog_init_timeout (struct watchdog_device *wdd, +unsigned int timeout_parm, +struct device *dev) +{ +return watchdog_init_timeouts (wdd,0 , timeout_parm, dev); +} +extern int watchdog_register_device (struct watchdog_device *);extern void watchdog_unregister_device (struct watchdog_device *);
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 0/8] Watchdog: introduce ARM SBSA watchdog driver
In reply to [email protected]Hi Guenter,
Any suggestion on this v6 patchset, for now , I only got :
(1) delete WCV output:
drivers/watchdog/sbsa_gwdt.c +1 -2
@@ -344,8 +342,7 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) status =readl_relaxed (gwdt->control_base +SBSA_GWDT_WCS );if (status &SBSA_GWDT_WCS_WS1 ) { -dev_warn (dev,"System reset by WDT(WCV: %llx)\n" , -sbsa_gwdt_get_wcv (wdd)); +dev_warn (dev,"System reset by WDT.\n" ); wdd->bootstatus |=WDIOF_CARDRESET ; }else if (status == (SBSA_GWDT_WCS_WS0 |SBSA_GWDT_WCS_EN )) { gwdt->ws0_mode = true;
any question or anything I can improve for this patchset?
Great thanks for your help.
Quoted 126 lines · On 23 June 2015 at 22:16, <[email protected]>…
From: Fu Wei <[email protected]>
This patchset:
(1)IntroduceDocumentation/devicetree/bindings/watchdog/sbsa-gwdt.txtfor FDT info of SBSA Generic Watchdog, and give two examples of adding SBSA Generic Watchdog device node into the dts files:
foundation-v8.dtsandamd-seattle-soc.dtsi.(2)Introduce "pretimeout" into the watchdog framework, and update
Documentation/watchdog/watchdog-kernel-api.txtto introduce:
(1)the new elements in thewatchdog_deviceandwatchdog_opsstruct; (2)the new API "watchdog_init_timeouts".(3)Introduce ARM SBSA watchdog driver:
a.Use linux kernel watchdog framework;
b.Work with FDT on ARM64;
c.Use "pretimeout" in watchdog framework;
d.Support getting timeout and pretimeout from parameter and FDT
at the driver init stage.
e.In the first timeout, do panic to save system context; f.In the second stage, user can still feed the dog without
cleaning WS0. By this feature, we can avoid the panic infinite loops, while backing up a large system context in a server.
g.In the second stage, can trigger WS1 by setting pretimeout = 0
if necessary.(4)Introduce ACPI GTDT parser:
drivers/acpi/gtdt.c
Parse SBSA Generic Watchdog Structure in GTDT table of ACPI, and create a platform device with that information.
This platform device can be used by This Watchdog driver.drivers/clocksource/arm_arch_timer.cis simplified by this GTDT support.This patchset has been tested with watchdog daemon (ACPI/FDT, module/build-in) on the following platforms:
(1)ARM Foundation v8 modelChangelog:
v6: Improve the dtb example files: reduce the register frame size to 4K.
Improve pretimeout support:
(1) improvewatchdog_init_timeoutsfunction
(2) renamewatchdog_check_min_max_timeoutsback to the original name
(1) improve watchdog_timeout_invalid/watchdog_pretimeout_invalid
Add the new features in thesbsa_gwdtdriver:
(1) In the second stage, user can feed the dog without cleaning WS0.
(2) In the second stage, user can trigger WS1 by setting pretimeout = 0.
(3) expand the max value of pretimeout, in case 10 second is not enough for a kdump kernel reboot in panic.v5: Improve pretimeout support:
(1)fix typo in documentation and comments.
(2)fix the timeout limits validation bug.
Simplifysbsa_gwdtdriver:
(1)integrate all the registers access functions into caller.v4: Refactor GTDT support code: remove it from
arch/arm64/kernel/acpi.c,put it into drivers/acpi/gtdt.c file. Integrate the GTDT code of drivers/clocksource/arm_arch_timer.c into drivers/acpi/gtdt.c. Improve pretimeout support, fix "pretimeout == 0" problem. Simplify sbsa_gwdt driver: (1)timeout/pretimeout limits setup; (2)keepalive function; (3)delete "clk == 0" check; (4)delete WS0 status bit check in interrupt routine; (5)sbsa_gwdt_set_wcv function.v3: Delete "export
arch_timer_get_rate" patch.
Driver back to usearch_timer_get_cntfrq.
Improvewatchdog_init_timeoutsfunction and update relevant documentation. Improvewatchdog_timeout_invalidandwatchdog_pretimeout_invalid. Improvefoundation-v8.dts: delete the unnecessary tag of device node. Remove "ARM64 ||COMPILE_TEST" fromKconfig.
Add comments inarch/arm64/kernel/acpi.c
Fix typoes and incorrect comments.v2: Improve watchdog-kernel-api.txt documentation for pretimeout support.
Export "arch_timer_get_rate" inarm_arch_timer.c.
Addwatchdog_init_timeoutsAPI for pretimeout support in framework. Improve suspend and resume foundation in driver
Improve timeout/pretimeout values init code in driver. Delete unnecessary items of thesbsa_gwdtstruct and #define. Delete all unnecessary debug info in driver.
Fix 64bit division bug.
Use thearch_timerinterface to get watchdog clock rate. AddMODULE_DEVICE_TABLEfor platform device id.
Fix typoes.v1: The first version upstream patchset to linux mailing list.
Fu Wei (8):
Documentation: add sbsa-gwdt.txt documentation
ARM64: add SBSA Generic Watchdog device node infoundation-v8.dts
ARM64: add SBSA Generic Watchdog device node inamd-seattle-soc.dtsi
Watchdog: introdouce "pretimeout" into framework
Watchdog: introduce ARM SBSA watchdog driver
ACPI: add GTDT table parse driver into ACPI driver
Watchdog: enable ACPI GTDT support for ARM SBSA watchdog driver
clocksource: simplify ACPI code inarm_arch_timer.c.../devicetree/bindings/watchdog/sbsa-gwdt.txt | 36 ++ Documentation/watchdog/watchdog-kernel-api.txt | 47 ++- arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi | 11 + arch/arm64/boot/dts/arm/foundation-v8.dts | 10 + arch/arm64/kernel/time.c | 4 +- drivers/acpi/Kconfig | 9 + drivers/acpi/Makefile | 1 + drivers/acpi/gtdt.c | 180 ++++++++ drivers/clocksource/Kconfig | 1 + drivers/clocksource/arm_arch_timer.c | 60 +-- drivers/watchdog/Kconfig | 15 + drivers/watchdog/Makefile | 1 + drivers/watchdog/sbsa_gwdt.c | 455 +++++++++++++++++++++ drivers/watchdog/watchdog_core.c | 98 +++-- drivers/watchdog/watchdog_dev.c | 53 +++ include/clocksource/arm_arch_timer.h | 8 + include/linux/acpi.h | 5 + include/linux/clocksource.h | 4 +- include/linux/watchdog.h | 39 +- 19 files changed, 947 insertions(+), 90 deletions(-) create mode 100644 Documentation/devicetree/bindings/watchdog/sbsa-gwdt.txt create mode 100644 drivers/acpi/gtdt.c create mode 100644 drivers/watchdog/sbsa_gwdt.c--
1.9.1
Signature · 14 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Guenter Roeck
maintainerRe: [PATCH v6 0/8] Watchdog: introduce ARM SBSA watchdog driver
Quoted 3 lines · Fu Wei
Hi Guenter,
Any suggestion on this v6 patchset, for now , I only got :
Problem is that each version of your patchset tends to introduce substantially new or different functionality, meaning the review has to pretty much start from scratch. Right now I just don't have time to do that, so you'll have to be a bit patient.
Guenter
Re: [PATCH v6 0/8] Watchdog: introduce ARM SBSA watchdog driver
Hi Guenter,
Great thanks for your time,
I can't tell you how much I appreciate your review! :-)
np, I will improve my patchset, once I get your suggestion. :-)
Quoted 15 lines · Guenter Roeck
Quoted 4 lines · Fu Wei
Hi Guenter,
Any suggestion on this v6 patchset, for now , I only got :
Problem is that each version of your patchset tends to introduce substantially
new or different functionality, meaning the review has to pretty much start from scratch. Right now I just don't have time to do that, so you'll have to be a bit patient.Guenter
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v6 0/8] Watchdog: introduce ARM SBSA watchdog driver
In reply to Guenter RoeckHi Guenter,
If you get some time, could you help me on this patchset again? Great thanks for your help!
Quoted 15 lines · Guenter Roeck
Quoted 4 lines · Fu Wei
Hi Guenter,
Any suggestion on this v6 patchset, for now , I only got :
Problem is that each version of your patchset tends to introduce substantially
new or different functionality, meaning the review has to pretty much start from scratch. Right now I just don't have time to do that, so you'll have to be a bit patient.Guenter
Signature · 14 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Guenter Roeck
maintainerRe: [PATCH v6 0/8] Watchdog: introduce ARM SBSA watchdog driver
Quoted 5 lines · Fu Wei
Hi Guenter,
If you get some time, could you help me on this patchset again? Great thanks for your help!
I am on vacation this week. Hopefully next week or two weeks from now, depending on my work load.
Guenter
Re: [PATCH v6 0/8] Watchdog: introduce ARM SBSA watchdog driver
Hi Guenter,
Great thanks for your info, looking forward to your feedback. :-)
Have a good vacation! :-)
Quoted 10 lines · Guenter Roeck
Quoted 5 lines · Fu Wei
Hi Guenter,
If you get some time, could you help me on this patchset again? Great thanks for your help!
I am on vacation this week. Hopefully next week or two weeks from now, depending on my work load.
Guenter
Signature · 14 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 5/8 Watchdog: introduce ARM SBSA watchdog driver
In reply to a message not in the archiveFrom: Fu Wei <[email protected]>
This driver bases on linux kernel watchdog framework, and use "pretimeout" in the framework. It supports getting timeout and pretimeout from parameter and FDT at the driver init stage. In first timeout, the interrupt routine run panic to save system context.
--- drivers/watchdog/Kconfig | 14 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sbsa_gwdt.c | 455 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 470 insertions(+) create mode 100644 drivers/watchdog/sbsa_gwdt.c
drivers/watchdog/Kconfig +14 -0
@@ -152,6 +152,20 @@ config ARM_SP805_WATCHDOG ARM Primecell SP805 Watchdog timer. This will reboot your system when the timeout is reached. +config ARM_SBSA_WATCHDOG + tristate "ARM SBSA Generic Watchdog" + depends on ARM64 + depends on ARM_ARCH_TIMER + select WATCHDOG_CORE + help + ARM SBSA Generic Watchdog. This watchdog has two Watchdog timeouts. + The first timeout will trigger a panic; the second timeout will + trigger a system reset. + More details: ARM DEN0029B - Server Base System Architecture (SBSA) + + To compile this driver as module, choose M here: The module + will be called sbsa_gwdt. + config AT91RM9200_WATCHDOG tristate "AT91RM9200 watchdog" depends on SOC_AT91RM9200 && MFD_SYSCON
drivers/watchdog/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o # ARM Architecture obj-$(CONFIG_ARM_SP805_WATCHDOG) += sp805_wdt.o +obj-$(CONFIG_ARM_SBSA_WATCHDOG) += sbsa_gwdt.o obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_CADENCE_WATCHDOG) += cadence_wdt.o
drivers/watchdog/sbsa_gwdt.c new file +455 -0
455 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v6 6/8 ACPI: add GTDT table parse driver into ACPI driver
From: Fu Wei <[email protected]>
This driver adds support for parsing SBSA Generic Watchdog Structure in GTDT, and creating a platform device with that information. This allows the operating system to obtain device data from the resource of platform device.
The platform device named "sbsa-gwdt" can be used by the ARM SBSA Generic Watchdog driver.
--- drivers/acpi/Kconfig | 9 ++++ drivers/acpi/Makefile | 1 + drivers/acpi/gtdt.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 drivers/acpi/gtdt.c
drivers/acpi/Kconfig +9 -0
@@ -433,4 +433,13 @@ config XPOWER_PMIC_OPREGION endif +config ACPI_GTDT + bool "ACPI GTDT Support" + depends on ARM64 + help + GTDT (Generic Timer Description Table) provides information + for per-processor timers and Platform (memory-mapped) timers + for ARM platforms. Select this option to provide information + needed for the timers init. + endif # ACPI
drivers/acpi/Makefile +1 -0
@@ -96,3 +96,4 @@ obj-$(CONFIG_ACPI_EXTLOG) += acpi_extlog.o obj-$(CONFIG_PMIC_OPREGION) += pmic/intel_pmic.o obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o +obj-$(CONFIG_ACPI_GTDT) += gtdt.o
drivers/acpi/gtdt.c new file +137 -0
137 lines not on this page · raw message
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 6/8] ACPI: add GTDT table parse driver into ACPI driver
Hi Rafael,
Any suggestion on the GTDT patch of this patch set? Please let me know if I can do anything to improve it. If it is OK for you, could you add a "Acked-by:"?
Great thanks for your time! :-)
Quoted 192 lines · On 23 June 2015 at 23:59, <[email protected]>…
From: Fu Wei <[email protected]>
This driver adds support for parsing SBSA Generic Watchdog Structure in GTDT, and creating a platform device with that information. This allows the operating system to obtain device data from the resource of platform device.
The platform device named "sbsa-gwdt" can be used by the ARM SBSA Generic Watchdog driver.
Signed-off-by Fu Wei <[email protected]>Signed-off-by Hanjun Guo <[email protected]>--- drivers/acpi/Kconfig | 9 ++++ drivers/acpi/Makefile | 1 + drivers/acpi/gtdt.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 drivers/acpi/gtdt.cdrivers/acpi/Kconfig +9
-0@@ -433,4 +433,13 @@ config XPOWER_PMIC_OPREGION endif +config ACPI_GTDT + bool "ACPI GTDT Support" + depends on ARM64 + help + GTDT (Generic Timer Description Table) provides information + for per-processor timers and Platform (memory-mapped) timers + for ARM platforms. Select this option to provide information + needed for the timers init. + endif # ACPIdrivers/acpi/Makefile +1
-0@@ -96,3 +96,4 @@ obj-$(CONFIG_ACPI_EXTLOG) += acpi_extlog.o obj-$(CONFIG_PMIC_OPREGION) += pmic/intel_pmic.o obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o +obj-$(CONFIG_ACPI_GTDT) += gtdt.odrivers/acpi/gtdt.c new file +137
-1@@ -0,0 +1,137 @@ +/* +* ARM Specific GTDT table Support +* +* Copyright (C) 2015, Linaro Ltd. +* Author: Fu Wei <[email protected]> +* Hanjun Guo <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/acpi.h> +#include <linux/device.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/platform_device.h> + +static int __init map_generic_timer_interrupt (u32 interrupt,u32 flags) +{ +int trigger, polarity; + +if (!interrupt) +return 0 ; + + trigger = (flags &ACPI_GTDT_INTERRUPT_MODE ) ?ACPI_EDGE_SENSITIVE + :ACPI_LEVEL_SENSITIVE ; + + polarity = (flags &ACPI_GTDT_INTERRUPT_POLARITY ) ?ACPI_ACTIVE_LOW + :ACPI_ACTIVE_HIGH ; + +return acpi_register_gsi (NULL , interrupt, trigger, polarity); +} + +/* +* Initialize a SBSA generic Watchdog platform device info from GTDT +* According to SBSA specification the size of refresh and control +* frames of SBSA Generic Watchdog is SZ_4K(Offset 0x000 – 0xFFF). +*/ +static int __init gtdt_import_sbsa_gwdt (struct acpi_gtdt_watchdog *wd, +int index) +{ +struct platform_device *pdev; +int irq =map_generic_timer_interrupt (wd->timer_interrupt, + wd->timer_flags); +struct resource res[] = { +DEFINE_RES_IRQ_NAMED (irq,"ws0" ), +DEFINE_RES_MEM_NAMED (wd->refresh_frame_address,SZ_4K , +"refresh" ), +DEFINE_RES_MEM_NAMED (wd->control_frame_address,SZ_4K , +"control" ), + }; + +pr_debug ("GTDT: a Watchdog GT(0x%llx/0x%llx gsi:%u flags:0x%x)\n" , + wd->refresh_frame_address, wd->control_frame_address, + wd->timer_interrupt, wd->timer_flags); + +if (!(wd->refresh_frame_address && + wd->control_frame_address && + wd->timer_interrupt)) { +pr_err ("GTDT: failed geting the device info.\n" ); +return -EINVAL ; + } + +if (irq <0 ) { +pr_err ("GTDT: failed to register GSI of the Watchdog GT.\n" ); +return -EINVAL ; + } + +/* +* Add a platform device named "sbsa-gwdt" to match the platform driver. +* "sbsa-gwdt": SBSA(Server Base System Architecture) Generic Watchdog +* The platform driver (like drivers/watchdog/sbsa_gwdt.c)can get device +* info below by matching this name. +*/ + pdev =platform_device_register_simple ("sbsa-gwdt" , index, res, +ARRAY_SIZE (res)); +if (IS_ERR (pdev)) { +acpi_unregister_gsi (wd->timer_interrupt); +return PTR_ERR (pdev); + } + +return 0 ; +} + +static int __init gtdt_platform_timer_parse (struct acpi_table_header *table) +{ +struct acpi_gtdt_header *header; +struct acpi_table_gtdt *gtdt; +void *gtdt_subtable; +int i, gwdt_index; +int ret =0 ; + +if (table->revision <2 ) { +pr_warn ("GTDT: Revision:%d doesn't support Platform Timers.\n" , + table->revision); +return 0 ; + } + + gtdt = container_of(table, struct acpi_table_gtdt, header); +if (!gtdt->platform_timer_count) { +pr_info ("GTDT: No Platform Timer structures.\n" ); +return 0 ; + } + + gtdt_subtable = (void *)gtdt + gtdt->platform_timer_offset; + +for (i =0 , gwdt_index =0 ; i < gtdt->platform_timer_count; i++) { +if (gtdt_subtable > (void *)table + table->length) { +pr_err ("GTDT: subtable pointer overflows, bad table\n" ); +return -EINVAL ; + } + header = (struct acpi_gtdt_header *)gtdt_subtable; +if (header->type ==ACPI_GTDT_TYPE_WATCHDOG ) { + ret =gtdt_import_sbsa_gwdt (gtdt_subtable, gwdt_index); +if (ret) +pr_err ("GTDT: failed to import subtable %d\n" , + i); +else + gwdt_index++; + } + gtdt_subtable += header->length; + } + +return ret; +} + +static int __init gtdt_platform_timer_init (void ) +{ +if (acpi_disabled) +return 0 ; + +return acpi_table_parse (ACPI_SIG_GTDT , gtdt_platform_timer_parse); +} + +device_initcall (gtdt_platform_timer_init); --1.9.1
Signature · 14 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 7/8 Watchdog: enable ACPI GTDT support for ARM SBSA watchdog driver
In reply to [email protected]From: Fu Wei <[email protected]>
This patch enables ACPI GTDT support for ARM SBSA watchdog driver automatically, if ACPI support is enabled.
--- drivers/watchdog/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/Kconfig +1 -0
@@ -157,6 +157,7 @@ config ARM_SBSA_WATCHDOG depends on ARM64 depends on ARM_ARCH_TIMER select WATCHDOG_CORE + select ACPI_GTDT if ACPI help ARM SBSA Generic Watchdog. This watchdog has two Watchdog timeouts. The first timeout will trigger a panic; the second timeout will
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 8/8 clocksource: simplify ACPI code in arm_arch_timer.c
In reply to [email protected]From: Fu Wei <[email protected]>
The patch update arm_arch_timer driver to use the function provided by the new GTDT driver of ACPI.
By this way, arm_arch_timer.c can be simplified, and separate all the ACPI GTDT knowledge from this timer driver.
--- arch/arm64/kernel/time.c | 4 +-- drivers/acpi/gtdt.c | 43 ++++++++++++++++++++++++++ drivers/clocksource/Kconfig | 1 + drivers/clocksource/arm_arch_timer.c | 60 +++++++----------------------------- include/clocksource/arm_arch_timer.h | 8 +++++ include/linux/acpi.h | 5 +++ include/linux/clocksource.h | 4 +-- 7 files changed, 72 insertions(+), 53 deletions(-)
arch/arm64/kernel/time.c +2 -2
@@ -75,9 +75,9 @@ void __init time_init(void)/* * Since ACPI or FDT will only one be available in the system, -* we can use acpi_generic_timer_init() here safely +* we can use arch_timer_acpi_init() here safely */ -acpi_generic_timer_init (); +arch_timer_acpi_init (); arch_timer_rate =arch_timer_get_rate ();if (!arch_timer_rate)
drivers/acpi/gtdt.c +43 -0
55 lines not on this page · raw message
drivers/clocksource/Kconfig +1 -0
@@ -109,6 +109,7 @@ config CLKSRC_EFM32 config ARM_ARCH_TIMER bool select CLKSRC_OF if OF + select ACPI_GTDT if ACPI config ARM_ARCH_TIMER_EVTSTREAM bool "Support for ARM architected timer event stream generation"
drivers/clocksource/arm_arch_timer.c +11 -49
79 lines not on this page · raw message
include/clocksource/arm_arch_timer.h +8 -0
@@ -43,6 +43,14 @@ enum arch_timer_reg {#define ARCH_TIMER_EVT_STREAM_FREQ 10000/* 100us */ +struct arch_timer_data { +int phys_secure_ppi; +int phys_nonsecure_ppi; +int virt_ppi; +int hyp_ppi; +bool c3stop; +}; +#ifdef CONFIG_ARM_ARCH_TIMER extern u32 arch_timer_get_rate (void );
include/linux/acpi.h +5 -0
@@ -458,6 +458,11 @@ void acpi_walk_dep_device_list(acpi_handle handle);struct platform_device *acpi_create_platform_device (struct acpi_device *);#define ACPI_PTR (_ptr) (_ptr) +#ifdef CONFIG_ACPI_GTDT +struct arch_timer_data ; +int __init gtdt_arch_timer_data_init (struct arch_timer_data *data); +#endif +#else /* !CONFIG_ACPI */ #define acpi_disabled 1
include/linux/clocksource.h +2 -2
@@ -254,9 +254,9 @@ static inline void clocksource_of_init(void) {}#endif #ifdef CONFIG_ACPI -void acpi_generic_timer_init (void ); +void arch_timer_acpi_init (void );#else -static inline void acpi_generic_timer_init (void ) { } +static inline void arch_timer_acpi_init (void ) { }#endif #endif /* _LINUX_CLOCKSOURCE_H */
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
v2 cover arm64: Add multiboot support (via fdt) for Xen boot
In reply to a message not in the archiveFrom: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
- The implementation for Xen is following <Multiboot on ARM Specification>:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
and xen/docs/misc/arm/device-tree/booting.txt in Xen source code.
- The multiboot/module commands have existed, so we use xen_hypervisor/xen_module instead.
- This Xen boot support is built into linux module for aarch64, and can not be used alone.
- Adding this functionality to the existing "linux" module is for reusing the existing code of devicetree.
- Add the support of xen_hypervisor/xen_module commands in util/grub.d/20_linux_xen.in
- Add the introduction of xen_hypervisor/xen_module commands in docs/grub.texi
- The example of this support is <How to boot Xen with GRUB on AArch64 the Foundation FVP model>
https://wiki.linaro.org/LEG/Engineering/Grub2/Xen_booting_on_Foundation_FVP_model_by_GRUB
Changelog:
v2: remove the patches which have been accepted.
according to Vladimir's suggestion, change the command manes and relevant code:
multiboot-->xen_hypervisor
module-->xen_module
improve the option parsing support for xen_hypervisor/xen_module commands. add a patch for adding xen_hypervisor/xen_module support
in util/grub.d/20_linux_xen.in.
update docs/grub.texi patch for the new command names.
v1: The first version upstream patchset to grub-devel mailing list
Fu Wei (3):
arm64: Add Xen boot support file
* util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
arm64: Add the introduction of xen_hypervisor/xen_module command in
docs/grub.texi
docs/grub.texi | 27 ++ grub-core/Makefile.core.def | 1 + grub-core/loader/arm64/linux.c | 6 + grub-core/loader/arm64/xen_boot.c | 615 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/xen_boot.h | 115 +++++++ util/grub.d/20_linux_xen.in | 14 +- 6 files changed, 775 insertions(+), 3 deletions(-) create mode 100644 grub-core/loader/arm64/xen_boot.c create mode 100644 include/grub/arm64/xen_boot.h
Signature · 1 line
1.8.3.1
PATCH v2 1/3 arm64: Add Xen boot support file
From: Fu Wei <[email protected]>
This patch adds Xen boot support file:grub-core/loader/arm64/xen_boot.cinclude/grub/arm64/xen_boot.h
This patch also adds commands register code and hearder file into grub-core/loader/arm64/linux.c
- This adds support for the Xen boot on ARM specification for arm64.
- The implementation for Xen is following <Multiboot on ARM Specification>:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
and xen/docs/misc/arm/device-tree/booting.txt in Xen source code.
- The multiboot/module commands have existed,
so we use xen_hypervisor/xen_module instead.
- This Xen boot support is built into linux module for aarch64.
- Adding this functionality to the existing "linux" module is for reusing the existing code of devicetree.
--- grub-core/Makefile.core.def | 1 + grub-core/loader/arm64/linux.c | 6 + grub-core/loader/arm64/xen_boot.c | 615 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/xen_boot.h | 115 +++++++ 4 files changed, 737 insertions(+) create mode 100644 grub-core/loader/arm64/xen_boot.c create mode 100644 include/grub/arm64/xen_boot.h
grub-core/Makefile.core.def +1 -0
@@ -1659,6 +1659,7 @@ module = { ia64_efi = loader/ia64/efi/linux.c; arm = loader/arm/linux.c; arm64 = loader/arm64/linux.c; + arm64 = loader/arm64/xen_boot.c; fdt = lib/fdt.c; common = loader/linux.c; common = lib/cmdline.c;
grub-core/loader/arm64/linux.c +6 -0
@@ -26,6 +26,7 @@#include <grub/mm.h> #include <grub/types.h> #include <grub/cpu/linux.h> +#include <grub/cpu/xen_boot.h> #include <grub/efi/efi.h> #include <grub/efi/pe32.h> #include <grub/i18n.h>
@@ -477,6 +478,9 @@ GRUB_MOD_INIT (linux) cmd_devicetree =grub_register_command ("devicetree" , grub_cmd_devicetree,0 ,N_ ("Load DTB file." )); + +grub_arm64_linux_register_xen_boot_command (mod, &loaded); + my_mod = mod; }
@@ -485,4 +489,6 @@ GRUB_MOD_FINI (linux)grub_unregister_command (cmd_linux);grub_unregister_command (cmd_initrd);grub_unregister_command (cmd_devicetree); + +grub_arm64_linux_unregister_xen_boot_command (); }
grub-core/loader/arm64/xen_boot.c new file +615 -0
615 lines not on this page · raw message
include/grub/arm64/xen_boot.h new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH v2 1/3] arm64: Add Xen boot support file
Quoted 6 lines · On 13.07.2015 10:53, [email protected] wrote:
From: Fu Wei <[email protected]>
This patch adds Xen boot support file:
grub-core/loader/arm64/xen_boot.cinclude/grub/arm64/xen_boot.h
Quoted 6 lines
This patch also adds commands register code and hearder file into
grub-core/loader/arm64/linux.c- This adds support for the Xen boot on ARM specification for arm64.
- The implementation for Xen is following <Multiboot on ARM Specification>:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
Please don't refer to this protocol as multiboot anywhere in grub or around because it's NOT multiboot and we don't want to confuse those 2 protocols.
Quoted 7 lines
and
xen/docs/misc/arm/device-tree/booting.txtin Xen source code.
- The multiboot/module commands have existed,
so we use xen_hypervisor/xen_module instead.
- This Xen boot support is built into linux module for aarch64.
- Adding this functionality to the existing "linux" module is for reusing the existing code of devicetree.
Please create separate module. Modules are dynamically linked.
Quoted 45 lines
Signed-off-by Fu Wei <[email protected]>--- grub-core/Makefile.core.def | 1 + grub-core/loader/arm64/linux.c | 6 + grub-core/loader/arm64/xen_boot.c | 615 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/xen_boot.h | 115 +++++++ 4 files changed, 737 insertions(+) create mode 100644 grub-core/loader/arm64/xen_boot.c create mode 100644 include/grub/arm64/xen_boot.hgrub-core/Makefile.core.def +1
-0@@ -1659,6 +1659,7 @@ module = { ia64_efi = loader/ia64/efi/linux.c; arm = loader/arm/linux.c; arm64 = loader/arm64/linux.c; + arm64 = loader/arm64/xen_boot.c; fdt = lib/fdt.c; common = loader/linux.c; common = lib/cmdline.c;grub-core/loader/arm64/linux.c +4
-0@@ -26,6 +26,7 @@#include <grub/mm.h> #include <grub/types.h> #include <grub/cpu/linux.h> +#include <grub/cpu/xen_boot.h> #include <grub/efi/efi.h> #include <grub/efi/pe32.h> #include <grub/i18n.h> @@ -477,6 +478,9 @@ GRUB_MOD_INIT (linux) cmd_devicetree =grub_register_command ("devicetree" , grub_cmd_devicetree,0 ,N_ ("Load DTB file." )); + +grub_arm64_linux_register_xen_boot_command (mod, &loaded); + my_mod = mod; }
grub-core/loader/arm64/linux.c GRUB_MOD_FINI (linux) · line 494
Quoted 6 lines
grub-core/loader/arm64/linux.c +2
-0@@ -485,4 +489,6 @@ GRUB_MOD_FINI (linux)grub_unregister_command (cmd_linux);grub_unregister_command (cmd_initrd);grub_unregister_command (cmd_devicetree); + +grub_arm64_linux_unregister_xen_boot_command (); }
Not needed with separate module.
Quoted 83 lines
grub-core/loader/arm64/xen_boot.c new file +77
-0@@ -0,0 +1,615 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2014 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <grub/cache.h> +#include <grub/charset.h> +#include <grub/command.h> +#include <grub/err.h> +#include <grub/file.h> +#include <grub/fdt.h> +#include <grub/linux.h> +#include <grub/list.h> +#include <grub/loader.h> +#include <grub/misc.h> +#include <grub/mm.h> +#include <grub/types.h> +#include <grub/cpu/linux.h> +#include <grub/cpu/xen_boot.h> +#include <grub/efi/efi.h> +#include <grub/efi/pe32.h> +#include <grub/i18n.h> +#include <grub/lib/cmdline.h> + +static grub_dl_t linux_mod; +static int *loaded; + +static struct xen_boot_binary *xen_hypervisor; +static struct xen_boot_binary *module_head; +static const grub_size_t module_default_align[] = { +MODULE_IMAGE_MIN_ALIGN , +MODULE_INITRD_MIN_ALIGN , +MODULE_OTHER_MIN_ALIGN , +MODULE_CUSTOM_MIN_ALIGN +}; + +static void *xen_boot_fdt; +static const compat_string_struct_t default_compat_string[] = { +FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_OTHER_COMPATIBLE ) +}; + + +/* Parse all the options of xen_module command. For now, we support +(1) --type <the compatible stream> +(2) --nounzip +We also set up the type of module in this function. +If there are some "--type" options in the command line, +we make a custom compatible stream in this function. */ +static grub_err_t +set_module_type (struct xen_boot_binary *module,int argc,char *argv[], +int *file_name_index) +{ +char **compat_string_temp_array = + (char **)grub_zalloc (sizeof (char *) * argc); +static module_type_t default_type =MODULE_IMAGE ; +grub_size_t total_size =0 ; +int num_types =0 , i; +char *temp =NULL ; + + *file_name_index =0 ; + +/* if there are some options we need to process. */
grub-core/loader/arm64/xen_boot.c line 87
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+while (argc >1 && !grub_strncmp (argv[0 ],"--" ,2 )) + { +if (!grub_strcmp (argv[0 ],"--type" )) + { + module->node_info.type =MODULE_CUSTOM ; +ARG_SHIFT (argc, argv); + total_size +=grub_strlen (argv[0 ]) +1 ; + compat_string_temp_array[num_types++] = argv[0 ]; +ARG_SHIFT (argc, argv); + (*file_name_index) +=2 ;
This (and subsequent) parsing is unecessarily complicated. Please create separate commands for different types
Quoted 24 lines
grub-core/loader/arm64/xen_boot.c new file +24
-0+ } +else if (!grub_strcmp (argv[0 ],"--nounzip" )) + { +grub_file_filter_disable_compression (); +ARG_SHIFT (argc, argv); + (*file_name_index) +=1 ; + } +else /* we can add more options process code here. */ + { +grub_dprintf ("xen_boot_loader" , +"Unknown option %s, skip.\n" , argv[0 ]); +ARG_SHIFT (argc, argv); + (*file_name_index) +=1 ; + } + } + +/* To prevent some wrong command lines using "--type" option */ +if (!argc) +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + +/* For the default module type : +The implementation is following <Multiboot on ARM Specification>: +Each module will be given a default compatibility property +based on the order in which the modules are added.
grub-core/loader/arm64/xen_boot.c line 121
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+ The 1st module: compatible = "multiboot,kernel", "multiboot,module" + The 2nd module: compatible = "multiboot,ramdisk", "multiboot,module" + All subsequent modules: compatible = "multiboot,module" + But this order will NOT be interfered with "--type"(MODULE_CUSTOM) + For more detail, please refer to: + http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot */ + if (module->node_info.type != MODULE_CUSTOM) + { +/* the module type is set by the load order */ + module->node_info.type = default_type;
Please don't make it order-dependent more than necessarry.
Quoted 42 lines
grub-core/loader/arm64/xen_boot.c new file +42
-0+switch (default_type) + { +case MODULE_IMAGE : + default_type =MODULE_INITRD ; +break ; + +case MODULE_INITRD : + default_type =MODULE_OTHER ; +break ; + +case MODULE_OTHER : +break ; + +default : + default_type =MODULE_IMAGE ;/* error, reset the type */ +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("invalid argument" )); + } + } +else + { +/* the module type is set by "--type"(MODULE_CUSTOM) */ + module->node_info.compat_string = temp = + (char *)grub_zalloc (total_size); + module->node_info.compat_string_size = total_size; +for (i =0 ; num_types >0 ; num_types--, i++, temp++) + { +grub_strcpy (temp, compat_string_temp_array[i]); + temp +=grub_strlen (compat_string_temp_array[i]); + } + } + +grub_free (compat_string_temp_array); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_hypervisor_params (void ) +{ +int chosen_node =0 ; +int retval; +
grub-core/loader/arm64/xen_boot.c line 173
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+ xen_boot_fdt =grub_linux_get_fdt (); +if (!xen_boot_fdt) +return grub_error (GRUB_ERR_BAD_OS ,"failed to get FDT" ); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_BAD_OS ,"failed to get chosen node in FDT" ); +
BAD_OS means that OS images are invalid. ERR_IO is a generic error for such cases.
grub-core/loader/arm64/xen_boot.c line 178
Quoted 5 lines
grub-core/loader/arm64/xen_boot.c new file +5
-0+grub_dprintf ("xen_boot_loader" , +"Xen Hypervisor cmdline : %s @ %p size:%d\n" , + xen_hypervisor->cmdline, xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); +
No need for "boot_". xen_loader is fine and mre consistent.
grub-core/loader/arm64/xen_boot.c line 184
Quoted 6 lines
grub-core/loader/arm64/xen_boot.c new file +6
-0+ retval =grub_fdt_set_prop (xen_boot_fdt, chosen_node,"bootargs" , + xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); +if (retval) +return grub_error (GRUB_ERR_BAD_OS ,"failed to install/update FDT" ); +
ditto
Quoted 143 lines
grub-core/loader/arm64/xen_boot.c new file +143
-0+return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_module_params (struct xen_boot_binary *module) +{ +int retval, chosen_node =0 , module_node =0 ; +char module_name[FDT_NODE_NAME_MAX_SIZE ]; + + retval =grub_snprintf (module_name,FDT_NODE_NAME_MAX_SIZE ,"module@%lx" , +xen_boot_address_align (module->start, + module->align)); +grub_dprintf ("xen_boot_loader" ,"Module node name %s \n" , module_name); + +if (retval < (int )sizeof ("module@" )) +return grub_error (GRUB_ERR_BAD_OS ,N_ ("failed to get FDT" )); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_BAD_OS ,"failed to get chosen node in FDT" ); + + module_node = +grub_fdt_find_subnode (xen_boot_fdt, chosen_node, module_name); +if (module_node <0 ) + module_node = +grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"compatible" , + module->node_info.compat_string, + (grub_uint32_t ) module->node_info. + compat_string_size); +if (retval) +return grub_error (GRUB_ERR_BAD_OS ,N_ ("failed to update FDT" )); + +grub_dprintf ("xen_boot_loader" ,"Module %s compatible = %s size = 0x%lx\n" , + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + retval =grub_fdt_set_reg64 (xen_boot_fdt, module_node, +xen_boot_address_align (module->start, + module->align), + module->size); +if (retval) +return grub_error (GRUB_ERR_BAD_OS ,N_ ("failed to update FDT" )); + +if (module->cmdline && module->cmdline_size >0 ) + { +grub_dprintf ("xen_boot_loader" , +"Module %s cmdline : %s @ %p size:%d\n" , module->name, + module->cmdline, module->cmdline, module->cmdline_size); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"bootargs" , + module->cmdline, module->cmdline_size +1 ); +if (retval) +return grub_error (GRUB_ERR_BAD_OS ,"failed to update FDT" ); + } +else + { +grub_dprintf ("xen_boot_loader" ,"Module %s has not bootargs!\n" , + module->name); + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +install_all_params (void ) +{ +grub_efi_guid_t fdt_guid =GRUB_EFI_DEVICE_TREE_GUID ; +grub_efi_boot_services_t *b; +grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; + status = b->install_configuration_table (&fdt_guid, xen_boot_fdt); +if (status !=GRUB_EFI_SUCCESS ) +return grub_error (GRUB_ERR_BAD_OS ,"failed to install FDT" ); + +grub_dprintf ("xen_boot_loader" , +"Installed/updated FDT configuration table @ %p\n" , + xen_boot_fdt); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +clean_all_params (void ) +{ +if (xen_boot_fdt) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) xen_boot_fdt, +BYTES_TO_PAGES (grub_fdt_get_totalsize + (xen_boot_fdt))); + xen_boot_fdt =NULL ; + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +finalize_params_xen_boot (void ) +{ +struct xen_boot_binary *module; + +if (xen_hypervisor) + { +if (prepare_xen_hypervisor_params () !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_boot_loader" , +"Failed to get Xen Hypervisor info!\n" ); + goto fail; + } + +/* Set module params info */ + FOR_LIST_ELEMENTS (module, module_head) + { +if (module->start && module->size >0 ) + { +grub_dprintf ("xen_boot_loader" ,"Module %s @ 0x%lx size:0x%lx\n" , + module->name, +xen_boot_address_align (module->start, module->align), + module->size); +if (prepare_xen_module_params (module) !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_boot_loader" ,"Module info error: %s!\n" , + module->name); + goto fail; + } + } + +if (install_all_params () ==GRUB_ERR_NONE ) +return GRUB_ERR_NONE ; + +fail: +clean_all_params (); +
grub-core/loader/arm64/xen_boot.c line 337
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+return grub_error (GRUB_ERR_BAD_OS ,"failed to install/update FDT" ); +} + + +static grub_err_t +xen_boot (void ) +{ +if (finalize_params_xen_boot () !=GRUB_ERR_NONE ) +return grub_errno; +
Better use err = finalize_params_xen_boot (); if (err) return err;
grub-core/loader/arm64/xen_boot.c line 345
Quoted 8 lines
grub-core/loader/arm64/xen_boot.c new file +8
-0+return grub_arm64_uefi_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); +} + +static void +single_binary_unload (struct xen_boot_binary *binary) +{
Just put if (!binary) return; It will save a lot of if's.
Quoted 68 lines
grub-core/loader/arm64/xen_boot.c new file +68
-0+if (binary && binary->start && binary->size >0 ) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) binary->start, +BYTES_TO_PAGES (binary->size + binary->align)); + } + +if (binary && binary->cmdline && binary->cmdline_size >0 ) + { +grub_free (binary->cmdline); +grub_dprintf ("xen_boot_loader" , +"Module %s cmdline memory free @ %p size: %d\n" , + binary->name, binary->cmdline, binary->cmdline_size); + } + +if (binary) + { +if (binary->node_info.type ==MODULE_CUSTOM ) +grub_free ((void *) binary->node_info.compat_string); +if (grub_strcmp (binary->name,XEN_HYPERVISOR_NAME )) +grub_list_remove (GRUB_AS_LIST (binary)); +grub_dprintf ("xen_boot_loader" , +"Module %s struct memory free @ %p size: 0x%lx\n" , + binary->name, binary,sizeof (binary)); +grub_free (binary); + } + +return ; +} + +static void +all_binaries_unload (void ) +{ +struct xen_boot_binary *binary; + + FOR_LIST_ELEMENTS (binary, module_head) + { +single_binary_unload (binary); + } + +if (xen_hypervisor) +single_binary_unload (xen_hypervisor); + +return ; +} + +static grub_err_t +xen_unload (void ) +{ + *loaded =0 ; +all_binaries_unload (); +clean_all_params (); +grub_dl_unref (linux_mod); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +xen_boot_binary_load (struct xen_boot_binary *binary,grub_file_t file, +int argc,char *argv[]) +{ + binary->size =grub_file_size (file); +grub_dprintf ("xen_boot_loader" ,"Xen_boot %s file size: 0x%lx\n" , + binary->name, binary->size); + + binary->start = (grub_addr_t )grub_efi_allocate_pages (0 , + (BYTES_TO_PAGES + (binary->size + + binary->align)));
grub-core/loader/arm64/xen_boot.c line 423
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+if (!binary->start) +return grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); + +grub_dprintf ("xen_boot_loader" ,"Xen_boot %s numpages: 0x%lx\n" , + binary->name,BYTES_TO_PAGES (binary->size + binary->align)); + +if (grub_file_read (file, (void *)xen_boot_address_align (binary->start, + binary->align), + binary->size) < (grub_ssize_t ) binary->size) + {
We use != throughout. It's safer.
grub-core/loader/arm64/xen_boot.c line 431
Quoted 8 lines
grub-core/loader/arm64/xen_boot.c new file +8
-0+single_binary_unload (binary); +return grub_error (GRUB_ERR_BAD_OS ,N_ ("premature end of file %s" ), + argv[0 ]); + } + +/* Skip the xen_boot binary file name */ +ARG_SHIFT (argc, argv); +
There shouldn't be any need for shifting. Just use argc - 1 and argv + 1
Quoted 41 lines
grub-core/loader/arm64/xen_boot.c new file +41
-0+if (argc >0 ) + { + binary->cmdline_size =grub_loader_cmdline_size (argc, argv); + binary->cmdline =grub_zalloc (binary->cmdline_size); +if (!binary->cmdline) + { +single_binary_unload (binary); +return grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); + } +grub_create_loader_cmdline (argc, argv, binary->cmdline, + binary->cmdline_size); +grub_dprintf ("xen_boot_loader" , +"Xen_boot %s cmdline @ %p %s, size: %d\n" , binary->name, + binary->cmdline, binary->cmdline, binary->cmdline_size); + } +else + { + binary->cmdline_size =0 ; + binary->cmdline =NULL ; + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +grub_cmd_xen_module (grub_command_t cmd __attribute__ ((unused)), +int argc,char *argv[]) +{ + +struct xen_boot_binary *module =NULL ; +int file_name_index =0 ; +grub_file_t file =0 ; + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail; + } + +if (!*loaded) + {
grub-core/loader/arm64/xen_boot.c line 482
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+grub_error (GRUB_ERR_BAD_ARGUMENT , +N_ ("you need to load the Xen Hypervisor first" )); + goto fail; + } + + module = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!module) +return grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +
Just return grub_errno; zalloc already calls grub_error
Quoted 26 lines
grub-core/loader/arm64/xen_boot.c new file +26
-0+/* process all the options and get module type */ +if (set_module_type (module, argc, argv, &file_name_index) !=GRUB_ERR_NONE ) + goto fail; +switch (module->node_info.type) + { +case MODULE_IMAGE : +case MODULE_INITRD : +case MODULE_OTHER : + module->node_info.compat_string = + default_compat_string[module->node_info.type].compat_string; + module->node_info.compat_string_size = + default_compat_string[module->node_info.type].size; +break ; + +case MODULE_CUSTOM : +/* we have set the node_info in set_module_type */ +break ; + +default : +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("invalid argument" )); + } + module->name = module->node_info.compat_string; + module->align = module_default_align[module->node_info.type]; + + grub_dprintf ("xen_boot_loader", "Init %s module and node info:\n" + "compatible %s\ncompat_string_size 0x%lx\n",
grub-core/loader/arm64/xen_boot.c line 518
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+ module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + file =grub_file_open (argv[file_name_index]); +if (!file) + goto fail; + + grub_errno =xen_boot_binary_load (module, file, argc - file_name_index, + argv + file_name_index); +
When you call grub_error. grub_errno is already set
Quoted 25 lines
grub-core/loader/arm64/xen_boot.c new file +25
-0+if (grub_errno ==GRUB_ERR_NONE ) +grub_list_push (GRUB_AS_LIST_P (&module_head),GRUB_AS_LIST (module)); + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) +single_binary_unload (module); + +return grub_errno; +} + +static grub_err_t +grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), +int argc,char *argv[]) +{ +struct xen_hypervisor_header sh; +grub_file_t file =NULL ; + +grub_dl_ref (linux_mod); + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail;
grub-core/loader/arm64/xen_boot.c line 553
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+ } + +/* For now, we don't support any option in xen_hypervisor command. +If there are some options, we skip them. */ +while (argc >1 && !grub_strncmp (argv[0 ],"--" ,2 )) + { +grub_dprintf ("xen_boot_loader" ,"Unknown option %s, skip.\n" , argv[0 ]); +ARG_SHIFT (argc, argv); + } +
Why do you need this? Just delete it.
grub-core/loader/arm64/xen_boot.c line 566
Quoted 13 lines
grub-core/loader/arm64/xen_boot.c new file +13
-0+ file =grub_file_open (argv[0 ]); +if (!file) + goto fail; + +if (grub_file_read (file, &sh,sizeof (sh)) < (long )sizeof (sh)) + goto fail; +if (grub_arm64_uefi_check_image + ((struct grub_arm64_linux_kernel_header *) &sh) !=GRUB_ERR_NONE ) + goto fail; +grub_file_seek (file,0 ); + +grub_loader_unset (); +
This is implicit in loader_set. Please add a comment why it needs to be explicit. I suppose it's to avoid unloading oneself.
grub-core/loader/arm64/xen_boot.c line 571
Quoted 5 lines
grub-core/loader/arm64/xen_boot.c new file +5
-0+ xen_hypervisor = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!xen_hypervisor) +return grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +
Ditto
Quoted 66 lines
grub-core/loader/arm64/xen_boot.c new file +44
-0+ xen_hypervisor->name =XEN_HYPERVISOR_NAME ; + xen_hypervisor->align = (grub_size_t ) sh.optional_header.section_alignment; + + grub_errno =xen_boot_binary_load (xen_hypervisor, file, argc, argv); +if (grub_errno ==GRUB_ERR_NONE ) + { +grub_loader_set (xen_boot, xen_unload,0 ); + *loaded =1 ; + } + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) + { + *loaded =0 ; +all_binaries_unload (); +grub_dl_unref (linux_mod); + } + +return grub_errno; +} + +static grub_command_t cmd_xen_hypervisor, cmd_xen_module; + +void +grub_arm64_linux_register_xen_boot_command (grub_dl_t mod,int *linux_loaded) +{ + cmd_xen_hypervisor = +grub_register_command ("xen_hypervisor" , grub_cmd_xen_hypervisor,0 , +N_ ("Load a xen hypervisor." )); + cmd_xen_module = +grub_register_command ("xen_module" , grub_cmd_xen_module,0 , +N_ ("Load a xen module." )); + linux_mod = mod; + loaded = linux_loaded; +} + +void +grub_arm64_linux_unregister_xen_boot_command (void ) +{ +grub_unregister_command (cmd_xen_hypervisor); +grub_unregister_command (cmd_xen_module); +}include/grub/arm64/xen_boot.h new file +16
-0@@ -0,0 +1,115 @@ +/* +* xen_boot.h - Xen boot header file for Xen boot via FDT +* on AArch64 architecture. +* Copyright (C) 2014 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License
include/grub/arm64/xen_boot.h line 26
Quoted 10 lines
include/grub/arm64/xen_boot.h new file +10
-0+* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef XEN_BOOT_HEADER +#define XEN_BOOT_HEADER 1 + +#include <grub/list.h> +#include <grub/types.h> +#include <grub/efi/pe32.h> /* required by struct xen_hypervisor_header */ +
This file doesn't really look like having anything reusable. Please put it directly into .c
Quoted 80 lines
include/grub/arm64/xen_boot.h new file +79
-0+#define XEN_HYPERVISOR_NAME "xen_hypervisor" + +#define MODULE_DEFAULT_ALIGN (0x0) +#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_OTHER_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN + +#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" +#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" +#define MODULE_OTHER_COMPATIBLE "multiboot,module" + +/* This maximum size is defined in Power.org ePAPR V1.1 +* https://www.power.org/documentation/epapr-version-1-1/ +* 2.2.1.1 Node Name Requirements +* node-name@unit-address +* 31 + 1(@) + 16(64bit address in hex format) + 1(\0) = 49 +*/ +#define FDT_NODE_NAME_MAX_SIZE (49) + +#define ARG_SHIFT (argc, argv) \ + do { \ + (argc)--; \ + (argv)++; \ + } while (0) + +struct compat_string_struct +{ +grub_size_t size; +const char *compat_string; +}; +typedef struct compat_string_struct compat_string_struct_t ; +#define FDT_COMPATIBLE (x) {.size = sizeof(x), .compat_string = (x)} + +enum module_type +{ +MODULE_IMAGE , +MODULE_INITRD , +MODULE_OTHER , +MODULE_CUSTOM +}; +typedef enum module_type module_type_t ; + +struct fdt_node_info +{ +module_type_t type; + +const char *compat_string; +grub_size_t compat_string_size; +}; + +struct xen_hypervisor_header +{ +struct grub_arm64_linux_kernel_header efi_head; + +/* This is always PE\0\0. */ +grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE ]; +/* The COFF file header. */ +struct grub_pe32_coff_header coff_header; +/* The Optional header. */ +struct grub_pe64_optional_header optional_header; +}; + +struct xen_boot_binary +{ +struct xen_boot_binary *next; +struct xen_boot_binary **prev; +const char *name; + +grub_addr_t start; +grub_size_t size; +grub_size_t align; + +char *cmdline; +int cmdline_size; + +struct fdt_node_info node_info; +}; +
include/grub/arm64/xen_boot.h line 115
Quoted 10 lines
include/grub/arm64/xen_boot.h new file +10
-0+void grub_arm64_linux_register_xen_boot_command (grub_dl_t mod,int *loaded); +void grub_arm64_linux_unregister_xen_boot_command (void ); + +static __inlinegrub_addr_t +xen_boot_address_align (grub_addr_t start,grub_size_t align) +{ +return (align ? (ALIGN_UP (start, align)) : start); +} + +#endif /* ! XEN_BOOT_HEADER */
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v2 1/3] arm64: Add Xen boot support file
Quoted 10 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · On 13.07.2015 10:53, [email protected] wrote:
From: Fu Wei <[email protected]>
This patch adds Xen boot support file:
grub-core/loader/arm64/xen_boot.cinclude/grub/arm64/xen_boot.hThis patch also adds commands register code and hearder file into
grub-core/loader/arm64/linux.c
Quoted 6 lines
Quoted 3 lines
- This adds support for the Xen boot on ARM specification for arm64.
- The implementation for Xen is following <Multiboot on ARM Specification>:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/MultibootPlease don't refer to this protocol as multiboot anywhere in grub or around because it's NOT multiboot and we don't want to confuse those 2 protocols.
That's fair enough, my hope was that the docs and communal knowledge about how to write a grub.cfg for Xen x86/multiboot could remain unchanged for Xen on arm (e.g. by using the same multiboot1 command names, which surely won't be reused on arm), but I can see why you would object to that and updating 20_linux_xen to DTRT on both arches solves the majority of that concern.
WRT to what to call it instead: I did try and design it[0] to not be Xen specific, so it would be nice to avoid making it so in the command names if possible. I suspect this may lead to a certain amount of bikeshedding, if so we should just call it something Xen specific and move on I think.
For a non-Xen specific name how about "fbm -- fdt boot module" protocol and associated commands fbm_kernel + fbm_module?
Ian.
[0]
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v2 1/3] arm64: Add Xen boot support file
In reply to Vladimir 'φ-coder/phcoder' SerbinenkoHi Vladimir,
I have submitted a new patchset (v3) for xen boot. this patchset follows all your comment here.
please help me again on this, Great thanks for your help.
Quoted 840 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines · On 13.07.2015 10:53, [email protected] wrote:
From: Fu Wei <[email protected]>
This patch adds Xen boot support file:
grub-core/loader/arm64/xen_boot.cinclude/grub/arm64/xen_boot.hQuoted 6 lines
This patch also adds commands register code and hearder file into
grub-core/loader/arm64/linux.c- This adds support for the Xen boot on ARM specification for arm64.
- The implementation for Xen is following <Multiboot on ARM Specification>:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/MultibootPlease don't refer to this protocol as multiboot anywhere in grub or around because it's NOT multiboot and we don't want to confuse those 2 protocols.
Quoted 7 lines
and
xen/docs/misc/arm/device-tree/booting.txtin Xen source code.
- The multiboot/module commands have existed,
so we use xen_hypervisor/xen_module instead.
- This Xen boot support is built into linux module for aarch64.
- Adding this functionality to the existing "linux" module is for reusing the existing code of devicetree.Please create separate module. Modules are dynamically linked.
Quoted 45 lines
Signed-off-by Fu Wei <[email protected]>--- grub-core/Makefile.core.def | 1 + grub-core/loader/arm64/linux.c | 6 + grub-core/loader/arm64/xen_boot.c | 615 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/xen_boot.h | 115 +++++++ 4 files changed, 737 insertions(+) create mode 100644 grub-core/loader/arm64/xen_boot.c create mode 100644 include/grub/arm64/xen_boot.hgrub-core/Makefile.core.def +1
-0@@ -1659,6 +1659,7 @@ module = { ia64_efi = loader/ia64/efi/linux.c; arm = loader/arm/linux.c; arm64 = loader/arm64/linux.c; + arm64 = loader/arm64/xen_boot.c; fdt = lib/fdt.c; common = loader/linux.c; common = lib/cmdline.c;grub-core/loader/arm64/linux.c +4
-0@@ -26,6 +26,7 @@#include <grub/mm.h> #include <grub/types.h> #include <grub/cpu/linux.h> +#include <grub/cpu/xen_boot.h> #include <grub/efi/efi.h> #include <grub/efi/pe32.h> #include <grub/i18n.h> @@ -477,6 +478,9 @@ GRUB_MOD_INIT (linux) cmd_devicetree =grub_register_command ("devicetree" , grub_cmd_devicetree,0 ,N_ ("Load DTB file." )); + +grub_arm64_linux_register_xen_boot_command (mod, &loaded); + my_mod = mod; }grub-core/loader/arm64/linux.c GRUB_MOD_FINI (linux) · line 494
Quoted 6 lines
grub-core/loader/arm64/linux.c +2
-0@@ -485,4 +489,6 @@ GRUB_MOD_FINI (linux)grub_unregister_command (cmd_linux);grub_unregister_command (cmd_initrd);grub_unregister_command (cmd_devicetree); + +grub_arm64_linux_unregister_xen_boot_command (); }Not needed with separate module.
Quoted 83 lines
grub-core/loader/arm64/xen_boot.c new file +77
-0@@ -0,0 +1,615 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2014 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <grub/cache.h> +#include <grub/charset.h> +#include <grub/command.h> +#include <grub/err.h> +#include <grub/file.h> +#include <grub/fdt.h> +#include <grub/linux.h> +#include <grub/list.h> +#include <grub/loader.h> +#include <grub/misc.h> +#include <grub/mm.h> +#include <grub/types.h> +#include <grub/cpu/linux.h> +#include <grub/cpu/xen_boot.h> +#include <grub/efi/efi.h> +#include <grub/efi/pe32.h> +#include <grub/i18n.h> +#include <grub/lib/cmdline.h> + +static grub_dl_t linux_mod; +static int *loaded; + +static struct xen_boot_binary *xen_hypervisor; +static struct xen_boot_binary *module_head; +static const grub_size_t module_default_align[] = { +MODULE_IMAGE_MIN_ALIGN , +MODULE_INITRD_MIN_ALIGN , +MODULE_OTHER_MIN_ALIGN , +MODULE_CUSTOM_MIN_ALIGN +}; + +static void *xen_boot_fdt; +static const compat_string_struct_t default_compat_string[] = { +FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_OTHER_COMPATIBLE ) +}; + + +/* Parse all the options of xen_module command. For now, we support +(1) --type <the compatible stream> +(2) --nounzip +We also set up the type of module in this function. +If there are some "--type" options in the command line, +we make a custom compatible stream in this function. */ +static grub_err_t +set_module_type (struct xen_boot_binary *module,int argc,char *argv[], +int *file_name_index) +{ +char **compat_string_temp_array = + (char **)grub_zalloc (sizeof (char *) * argc); +static module_type_t default_type =MODULE_IMAGE ; +grub_size_t total_size =0 ; +int num_types =0 , i; +char *temp =NULL ; + + *file_name_index =0 ; + +/* if there are some options we need to process. */ grub-core/loader/arm64/xen_boot.c line 87
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+while (argc >1 && !grub_strncmp (argv[0 ],"--" ,2 )) + { +if (!grub_strcmp (argv[0 ],"--type" )) + { + module->node_info.type =MODULE_CUSTOM ; +ARG_SHIFT (argc, argv); + total_size +=grub_strlen (argv[0 ]) +1 ; + compat_string_temp_array[num_types++] = argv[0 ]; +ARG_SHIFT (argc, argv); + (*file_name_index) +=2 ;This (and subsequent) parsing is unecessarily complicated. Please create separate commands for different types
Quoted 24 lines
grub-core/loader/arm64/xen_boot.c new file +24
-0+ } +else if (!grub_strcmp (argv[0 ],"--nounzip" )) + { +grub_file_filter_disable_compression (); +ARG_SHIFT (argc, argv); + (*file_name_index) +=1 ; + } +else /* we can add more options process code here. */ + { +grub_dprintf ("xen_boot_loader" , +"Unknown option %s, skip.\n" , argv[0 ]); +ARG_SHIFT (argc, argv); + (*file_name_index) +=1 ; + } + } + +/* To prevent some wrong command lines using "--type" option */ +if (!argc) +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + +/* For the default module type : +The implementation is following <Multiboot on ARM Specification>: +Each module will be given a default compatibility property +based on the order in which the modules are added. grub-core/loader/arm64/xen_boot.c line 121
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+ The 1st module: compatible = "multiboot,kernel", "multiboot,module" + The 2nd module: compatible = "multiboot,ramdisk", "multiboot,module" + All subsequent modules: compatible = "multiboot,module" + But this order will NOT be interfered with "--type"(MODULE_CUSTOM) + For more detail, please refer to: + http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot */ + if (module->node_info.type != MODULE_CUSTOM) + { +/* the module type is set by the load order */ + module->node_info.type = default_type;Please don't make it order-dependent more than necessarry.
Quoted 42 lines
grub-core/loader/arm64/xen_boot.c new file +42
-0+switch (default_type) + { +case MODULE_IMAGE : + default_type =MODULE_INITRD ; +break ; + +case MODULE_INITRD : + default_type =MODULE_OTHER ; +break ; + +case MODULE_OTHER : +break ; + +default : + default_type =MODULE_IMAGE ;/* error, reset the type */ +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("invalid argument" )); + } + } +else + { +/* the module type is set by "--type"(MODULE_CUSTOM) */ + module->node_info.compat_string = temp = + (char *)grub_zalloc (total_size); + module->node_info.compat_string_size = total_size; +for (i =0 ; num_types >0 ; num_types--, i++, temp++) + { +grub_strcpy (temp, compat_string_temp_array[i]); + temp +=grub_strlen (compat_string_temp_array[i]); + } + } + +grub_free (compat_string_temp_array); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_hypervisor_params (void ) +{ +int chosen_node =0 ; +int retval; +grub-core/loader/arm64/xen_boot.c line 173
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+ xen_boot_fdt =grub_linux_get_fdt (); +if (!xen_boot_fdt) +return grub_error (GRUB_ERR_BAD_OS ,"failed to get FDT" ); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_BAD_OS ,"failed to get chosen node in FDT" ); +
BAD_OSmeans that OS images are invalid.ERR_IOis a generic error for such cases.grub-core/loader/arm64/xen_boot.c line 178
Quoted 5 lines
grub-core/loader/arm64/xen_boot.c new file +5
-0+grub_dprintf ("xen_boot_loader" , +"Xen Hypervisor cmdline : %s @ %p size:%d\n" , + xen_hypervisor->cmdline, xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); +No need for "
boot_".xen_loaderis fine and mre consistent.grub-core/loader/arm64/xen_boot.c line 184
Quoted 6 lines
grub-core/loader/arm64/xen_boot.c new file +6
-0+ retval =grub_fdt_set_prop (xen_boot_fdt, chosen_node,"bootargs" , + xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); +if (retval) +return grub_error (GRUB_ERR_BAD_OS ,"failed to install/update FDT" ); +ditto
Quoted 143 lines
grub-core/loader/arm64/xen_boot.c new file +143
-0+return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_module_params (struct xen_boot_binary *module) +{ +int retval, chosen_node =0 , module_node =0 ; +char module_name[FDT_NODE_NAME_MAX_SIZE ]; + + retval =grub_snprintf (module_name,FDT_NODE_NAME_MAX_SIZE ,"module@%lx" , +xen_boot_address_align (module->start, + module->align)); +grub_dprintf ("xen_boot_loader" ,"Module node name %s \n" , module_name); + +if (retval < (int )sizeof ("module@" )) +return grub_error (GRUB_ERR_BAD_OS ,N_ ("failed to get FDT" )); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_BAD_OS ,"failed to get chosen node in FDT" ); + + module_node = +grub_fdt_find_subnode (xen_boot_fdt, chosen_node, module_name); +if (module_node <0 ) + module_node = +grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"compatible" , + module->node_info.compat_string, + (grub_uint32_t ) module->node_info. + compat_string_size); +if (retval) +return grub_error (GRUB_ERR_BAD_OS ,N_ ("failed to update FDT" )); + +grub_dprintf ("xen_boot_loader" ,"Module %s compatible = %s size = 0x%lx\n" , + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + retval =grub_fdt_set_reg64 (xen_boot_fdt, module_node, +xen_boot_address_align (module->start, + module->align), + module->size); +if (retval) +return grub_error (GRUB_ERR_BAD_OS ,N_ ("failed to update FDT" )); + +if (module->cmdline && module->cmdline_size >0 ) + { +grub_dprintf ("xen_boot_loader" , +"Module %s cmdline : %s @ %p size:%d\n" , module->name, + module->cmdline, module->cmdline, module->cmdline_size); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"bootargs" , + module->cmdline, module->cmdline_size +1 ); +if (retval) +return grub_error (GRUB_ERR_BAD_OS ,"failed to update FDT" ); + } +else + { +grub_dprintf ("xen_boot_loader" ,"Module %s has not bootargs!\n" , + module->name); + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +install_all_params (void ) +{ +grub_efi_guid_t fdt_guid =GRUB_EFI_DEVICE_TREE_GUID ; +grub_efi_boot_services_t *b; +grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; + status = b->install_configuration_table (&fdt_guid, xen_boot_fdt); +if (status !=GRUB_EFI_SUCCESS ) +return grub_error (GRUB_ERR_BAD_OS ,"failed to install FDT" ); + +grub_dprintf ("xen_boot_loader" , +"Installed/updated FDT configuration table @ %p\n" , + xen_boot_fdt); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +clean_all_params (void ) +{ +if (xen_boot_fdt) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) xen_boot_fdt, +BYTES_TO_PAGES (grub_fdt_get_totalsize + (xen_boot_fdt))); + xen_boot_fdt =NULL ; + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +finalize_params_xen_boot (void ) +{ +struct xen_boot_binary *module; + +if (xen_hypervisor) + { +if (prepare_xen_hypervisor_params () !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_boot_loader" , +"Failed to get Xen Hypervisor info!\n" ); + goto fail; + } + +/* Set module params info */ + FOR_LIST_ELEMENTS (module, module_head) + { +if (module->start && module->size >0 ) + { +grub_dprintf ("xen_boot_loader" ,"Module %s @ 0x%lx size:0x%lx\n" , + module->name, +xen_boot_address_align (module->start, module->align), + module->size); +if (prepare_xen_module_params (module) !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_boot_loader" ,"Module info error: %s!\n" , + module->name); + goto fail; + } + } + +if (install_all_params () ==GRUB_ERR_NONE ) +return GRUB_ERR_NONE ; + +fail: +clean_all_params (); +grub-core/loader/arm64/xen_boot.c line 337
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+return grub_error (GRUB_ERR_BAD_OS ,"failed to install/update FDT" ); +} + + +static grub_err_t +xen_boot (void ) +{ +if (finalize_params_xen_boot () !=GRUB_ERR_NONE ) +return grub_errno; +Better use err =
finalize_params_xen_boot(); if (err) return err;grub-core/loader/arm64/xen_boot.c line 345
Quoted 8 lines
grub-core/loader/arm64/xen_boot.c new file +8
-0+return grub_arm64_uefi_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); +} + +static void +single_binary_unload (struct xen_boot_binary *binary) +{Just put if (!binary) return; It will save a lot of if's.
Quoted 68 lines
grub-core/loader/arm64/xen_boot.c new file +68
-0+if (binary && binary->start && binary->size >0 ) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) binary->start, +BYTES_TO_PAGES (binary->size + binary->align)); + } + +if (binary && binary->cmdline && binary->cmdline_size >0 ) + { +grub_free (binary->cmdline); +grub_dprintf ("xen_boot_loader" , +"Module %s cmdline memory free @ %p size: %d\n" , + binary->name, binary->cmdline, binary->cmdline_size); + } + +if (binary) + { +if (binary->node_info.type ==MODULE_CUSTOM ) +grub_free ((void *) binary->node_info.compat_string); +if (grub_strcmp (binary->name,XEN_HYPERVISOR_NAME )) +grub_list_remove (GRUB_AS_LIST (binary)); +grub_dprintf ("xen_boot_loader" , +"Module %s struct memory free @ %p size: 0x%lx\n" , + binary->name, binary,sizeof (binary)); +grub_free (binary); + } + +return ; +} + +static void +all_binaries_unload (void ) +{ +struct xen_boot_binary *binary; + + FOR_LIST_ELEMENTS (binary, module_head) + { +single_binary_unload (binary); + } + +if (xen_hypervisor) +single_binary_unload (xen_hypervisor); + +return ; +} + +static grub_err_t +xen_unload (void ) +{ + *loaded =0 ; +all_binaries_unload (); +clean_all_params (); +grub_dl_unref (linux_mod); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +xen_boot_binary_load (struct xen_boot_binary *binary,grub_file_t file, +int argc,char *argv[]) +{ + binary->size =grub_file_size (file); +grub_dprintf ("xen_boot_loader" ,"Xen_boot %s file size: 0x%lx\n" , + binary->name, binary->size); + + binary->start = (grub_addr_t )grub_efi_allocate_pages (0 , + (BYTES_TO_PAGES + (binary->size + + binary->align)));grub-core/loader/arm64/xen_boot.c line 423
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+if (!binary->start) +return grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); + +grub_dprintf ("xen_boot_loader" ,"Xen_boot %s numpages: 0x%lx\n" , + binary->name,BYTES_TO_PAGES (binary->size + binary->align)); + +if (grub_file_read (file, (void *)xen_boot_address_align (binary->start, + binary->align), + binary->size) < (grub_ssize_t ) binary->size) + {We use != throughout. It's safer.
grub-core/loader/arm64/xen_boot.c line 431
Quoted 8 lines
grub-core/loader/arm64/xen_boot.c new file +8
-0+single_binary_unload (binary); +return grub_error (GRUB_ERR_BAD_OS ,N_ ("premature end of file %s" ), + argv[0 ]); + } + +/* Skip the xen_boot binary file name */ +ARG_SHIFT (argc, argv); +There shouldn't be any need for shifting. Just use argc - 1 and argv + 1
Quoted 41 lines
grub-core/loader/arm64/xen_boot.c new file +41
-0+if (argc >0 ) + { + binary->cmdline_size =grub_loader_cmdline_size (argc, argv); + binary->cmdline =grub_zalloc (binary->cmdline_size); +if (!binary->cmdline) + { +single_binary_unload (binary); +return grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); + } +grub_create_loader_cmdline (argc, argv, binary->cmdline, + binary->cmdline_size); +grub_dprintf ("xen_boot_loader" , +"Xen_boot %s cmdline @ %p %s, size: %d\n" , binary->name, + binary->cmdline, binary->cmdline, binary->cmdline_size); + } +else + { + binary->cmdline_size =0 ; + binary->cmdline =NULL ; + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +grub_cmd_xen_module (grub_command_t cmd __attribute__ ((unused)), +int argc,char *argv[]) +{ + +struct xen_boot_binary *module =NULL ; +int file_name_index =0 ; +grub_file_t file =0 ; + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail; + } + +if (!*loaded) + {grub-core/loader/arm64/xen_boot.c line 482
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+grub_error (GRUB_ERR_BAD_ARGUMENT , +N_ ("you need to load the Xen Hypervisor first" )); + goto fail; + } + + module = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!module) +return grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +Just return
grub_errno; zalloc already callsgrub_errorQuoted 26 lines
grub-core/loader/arm64/xen_boot.c new file +26
-0+/* process all the options and get module type */ +if (set_module_type (module, argc, argv, &file_name_index) !=GRUB_ERR_NONE ) + goto fail; +switch (module->node_info.type) + { +case MODULE_IMAGE : +case MODULE_INITRD : +case MODULE_OTHER : + module->node_info.compat_string = + default_compat_string[module->node_info.type].compat_string; + module->node_info.compat_string_size = + default_compat_string[module->node_info.type].size; +break ; + +case MODULE_CUSTOM : +/* we have set the node_info in set_module_type */ +break ; + +default : +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("invalid argument" )); + } + module->name = module->node_info.compat_string; + module->align = module_default_align[module->node_info.type]; + + grub_dprintf ("xen_boot_loader", "Init %s module and node info:\n" + "compatible %s\ncompat_string_size 0x%lx\n",grub-core/loader/arm64/xen_boot.c line 518
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+ module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + file =grub_file_open (argv[file_name_index]); +if (!file) + goto fail; + + grub_errno =xen_boot_binary_load (module, file, argc - file_name_index, + argv + file_name_index); +When you call
grub_error.grub_errnois already setQuoted 25 lines
grub-core/loader/arm64/xen_boot.c new file +25
-0+if (grub_errno ==GRUB_ERR_NONE ) +grub_list_push (GRUB_AS_LIST_P (&module_head),GRUB_AS_LIST (module)); + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) +single_binary_unload (module); + +return grub_errno; +} + +static grub_err_t +grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), +int argc,char *argv[]) +{ +struct xen_hypervisor_header sh; +grub_file_t file =NULL ; + +grub_dl_ref (linux_mod); + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail;grub-core/loader/arm64/xen_boot.c line 553
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+ } + +/* For now, we don't support any option in xen_hypervisor command. +If there are some options, we skip them. */ +while (argc >1 && !grub_strncmp (argv[0 ],"--" ,2 )) + { +grub_dprintf ("xen_boot_loader" ,"Unknown option %s, skip.\n" , argv[0 ]); +ARG_SHIFT (argc, argv); + } +Why do you need this? Just delete it.
grub-core/loader/arm64/xen_boot.c line 566
Quoted 13 lines
grub-core/loader/arm64/xen_boot.c new file +13
-0+ file =grub_file_open (argv[0 ]); +if (!file) + goto fail; + +if (grub_file_read (file, &sh,sizeof (sh)) < (long )sizeof (sh)) + goto fail; +if (grub_arm64_uefi_check_image + ((struct grub_arm64_linux_kernel_header *) &sh) !=GRUB_ERR_NONE ) + goto fail; +grub_file_seek (file,0 ); + +grub_loader_unset (); +This is implicit in
loader_set. Please add a comment why it needs to be explicit. I suppose it's to avoid unloading oneself.grub-core/loader/arm64/xen_boot.c line 571
Quoted 5 lines
grub-core/loader/arm64/xen_boot.c new file +5
-0+ xen_hypervisor = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!xen_hypervisor) +return grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +Ditto
Quoted 66 lines
grub-core/loader/arm64/xen_boot.c new file +44
-0+ xen_hypervisor->name =XEN_HYPERVISOR_NAME ; + xen_hypervisor->align = (grub_size_t ) sh.optional_header.section_alignment; + + grub_errno =xen_boot_binary_load (xen_hypervisor, file, argc, argv); +if (grub_errno ==GRUB_ERR_NONE ) + { +grub_loader_set (xen_boot, xen_unload,0 ); + *loaded =1 ; + } + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) + { + *loaded =0 ; +all_binaries_unload (); +grub_dl_unref (linux_mod); + } + +return grub_errno; +} + +static grub_command_t cmd_xen_hypervisor, cmd_xen_module; + +void +grub_arm64_linux_register_xen_boot_command (grub_dl_t mod,int *linux_loaded) +{ + cmd_xen_hypervisor = +grub_register_command ("xen_hypervisor" , grub_cmd_xen_hypervisor,0 , +N_ ("Load a xen hypervisor." )); + cmd_xen_module = +grub_register_command ("xen_module" , grub_cmd_xen_module,0 , +N_ ("Load a xen module." )); + linux_mod = mod; + loaded = linux_loaded; +} + +void +grub_arm64_linux_unregister_xen_boot_command (void ) +{ +grub_unregister_command (cmd_xen_hypervisor); +grub_unregister_command (cmd_xen_module); +}include/grub/arm64/xen_boot.h new file +16
-0@@ -0,0 +1,115 @@ +/* +* xen_boot.h - Xen boot header file for Xen boot via FDT +* on AArch64 architecture. +* Copyright (C) 2014 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License include/grub/arm64/xen_boot.h line 26
Quoted 10 lines
include/grub/arm64/xen_boot.h new file +10
-0+* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef XEN_BOOT_HEADER +#define XEN_BOOT_HEADER 1 + +#include <grub/list.h> +#include <grub/types.h> +#include <grub/efi/pe32.h> /* required by struct xen_hypervisor_header */ +This file doesn't really look like having anything reusable. Please put it directly into .c
Quoted 90 lines
include/grub/arm64/xen_boot.h new file +89
-0+#define XEN_HYPERVISOR_NAME "xen_hypervisor" + +#define MODULE_DEFAULT_ALIGN (0x0) +#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_OTHER_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN + +#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" +#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" +#define MODULE_OTHER_COMPATIBLE "multiboot,module" + +/* This maximum size is defined in Power.org ePAPR V1.1 +* https://www.power.org/documentation/epapr-version-1-1/ +* 2.2.1.1 Node Name Requirements +* node-name@unit-address +* 31 + 1(@) + 16(64bit address in hex format) + 1(\0) = 49 +*/ +#define FDT_NODE_NAME_MAX_SIZE (49) + +#define ARG_SHIFT (argc, argv) \ + do { \ + (argc)--; \ + (argv)++; \ + } while (0) + +struct compat_string_struct +{ +grub_size_t size; +const char *compat_string; +}; +typedef struct compat_string_struct compat_string_struct_t ; +#define FDT_COMPATIBLE (x) {.size = sizeof(x), .compat_string = (x)} + +enum module_type +{ +MODULE_IMAGE , +MODULE_INITRD , +MODULE_OTHER , +MODULE_CUSTOM +}; +typedef enum module_type module_type_t ; + +struct fdt_node_info +{ +module_type_t type; + +const char *compat_string; +grub_size_t compat_string_size; +}; + +struct xen_hypervisor_header +{ +struct grub_arm64_linux_kernel_header efi_head; + +/* This is always PE\0\0. */ +grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE ]; +/* The COFF file header. */ +struct grub_pe32_coff_header coff_header; +/* The Optional header. */ +struct grub_pe64_optional_header optional_header; +}; + +struct xen_boot_binary +{ +struct xen_boot_binary *next; +struct xen_boot_binary **prev; +const char *name; + +grub_addr_t start; +grub_size_t size; +grub_size_t align; + +char *cmdline; +int cmdline_size; + +struct fdt_node_info node_info; +}; + +void grub_arm64_linux_register_xen_boot_command (grub_dl_t mod,int *loaded); +void grub_arm64_linux_unregister_xen_boot_command (void ); + +static __inlinegrub_addr_t +xen_boot_address_align (grub_addr_t start,grub_size_t align) +{ +return (align ? (ALIGN_UP (start, align)) : start); +} + +#endif /* ! XEN_BOOT_HEADER */
Signature · 15 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 2/3 util/grub.d/20_linux_xen.in: Add arm64 support
In reply to [email protected]From: Fu Wei <[email protected]>
This patch adds the support of boot command on arm64 for XEN:
xen_hypervisor
xen_module
--- util/grub.d/20_linux_xen.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
util/grub.d/20_linux_xen.in +11 -3
@@ -120,16 +120,16 @@ linux_entry () else xen_rm_opts="no-real-mode edd=off" fi - multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} + ${multiboot_cmd} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} echo '$(echo "$lmessage" | grub_quote)' - module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} + ${module_cmd} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - module --nounzip ${rel_dirname}/${initrd} + ${module_cmd} --nounzip ${rel_dirname}/${initrd} EOF fi sed "s/^/$submenu_indentation/" << EOF
@@ -185,6 +185,14 @@ case "$machine" in *) GENKERNEL_ARCH="$machine" ;; esac +if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_cmd="module" +else + multiboot_cmd="xen_hypervisor" + module_cmd="xen_module" +fi + # Extra indentation to add to menu entries in a submenu. We're not in a submenu # yet, so it's empty. In a submenu it will be equal to '\t' (one tab). submenu_indentation=""
Signature · 1 line
1.8.3.1
Re: [PATCH v2 2/3] util/grub.d/20_linux_xen.in: Add arm64 support
В Mon, 13 Jul 2015 16:53:59 +0800
[email protected] пишет:
Quoted 37 lines
From: Fu Wei <[email protected]>
This patch adds the support of boot command on arm64 for XEN:
xen_hypervisor
xen_moduleSigned-off-by Fu Wei <[email protected]>--- util/grub.d/20_linux_xen.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)util/grub.d/20_linux_xen.in +3
-3@@ -120,16 +120,16 @@ linux_entry () else xen_rm_opts="no-real-mode edd=off" fi - multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} + ${multiboot_cmd} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} echo '$(echo "$lmessage" | grub_quote)' - module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} + ${module_cmd} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - module --nounzip ${rel_dirname}/${initrd} + ${module_cmd} --nounzip ${rel_dirname}/${initrd} EOF fi sed "s/^/$submenu_indentation/" << EOF@@ -185,6 +185,14 @@ case "$machine" in *) GENKERNEL_ARCH="$machine" ;;
util/grub.d/20_linux_xen.in case "$machine" in · line 195
Quoted 10 lines
util/grub.d/20_linux_xen.in +8
-0esac +if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_cmd="module" +else + multiboot_cmd="xen_hypervisor" + module_cmd="xen_module" +fi +
Strictly speaking, this is boot-time decision. As mentioned by Vladimir, better would be to provide alias xen_hypervisor and xen_module in multiboot for platforms supporting Xen (is MIPS really supported?) and use it consistently.
util/grub.d/20_linux_xen.in case "$machine" in · line 198
Quoted 3 lines
util/grub.d/20_linux_xen.in +0
-0# Extra indentation to add to menu entries in a submenu. We're not in a submenu # yet, so it's empty. In a submenu it will be equal to '\t' (one tab). submenu_indentation=""
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v2 2/3] util/grub.d/20_linux_xen.in: Add arm64 support
Quoted 5 lines · Andrei Borzenkov
Quoted 5 lines
util/grub.d/20_linux_xen.in +5
-0+if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_cmd="module" +else + multiboot_cmd="xen_hypervisor"
Quoted 8 lines
util/grub.d/20_linux_xen.in case "$machine" in · line 195
Quoted 3 lines
util/grub.d/20_linux_xen.in +3
-0+ module_cmd="xen_module" +fi +Strictly speaking, this is boot-time decision. As mentioned by Vladimir, better would be to provide alias
xen_hypervisorandxen_modulein multiboot for platforms supporting Xen (is MIPS really supported?) and use it consistently.
I had been thinking of this the other way around, e.g. on platforms which support Xen but not multiboot1 "multiboot" would be added as an alias for xen_hypervisor.
However so long as grub-mkconfig (via 20_linux_xen) work for everyone and that peoples existing hand-crafted x86/multiboot/Xen grub.cfg's continue to work then I think having the alias go either way would be fine.
BTW I had been going to suggest a function at the grub.cfg level which dispatched to the correct command, but I suppose an actual alias is better.
Ian.
Re: [Xen-devel] [PATCH v2 2/3] util/grub.d/20_linux_xen.in: Add arm64 support
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Andrei Borzenkov
util/grub.d/20_linux_xen.in case "$machine" in · line 190
Quoted 3 lines
util/grub.d/20_linux_xen.in +3
-0+if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_cmd="module"
And we should use the grub-file --is-multiboot2 to figure out if the Xen binary can also do that - and use multiboot2 protocol.
But that patch I can cobble after this one is done.
Quoted 31 lines
Quoted 10 lines
util/grub.d/20_linux_xen.in case "$machine" in · line 195
Quoted 5 lines
util/grub.d/20_linux_xen.in +5
-0+else + multiboot_cmd="xen_hypervisor" + module_cmd="xen_module" +fi +Strictly speaking, this is boot-time decision. As mentioned by Vladimir, better would be to provide alias
xen_hypervisorandxen_modulein multiboot for platforms supporting Xen (is MIPS really supported?) and use it consistently.I had been thinking of this the other way around, e.g. on platforms which support Xen but not multiboot1 "multiboot" would be added as an alias for
xen_hypervisor.However so long as grub-mkconfig (via 20_linux_xen) work for everyone and that peoples existing hand-crafted x86/multiboot/Xen grub.cfg's continue to work then I think having the alias go either way would be fine.
BTW I had been going to suggest a function at the grub.cfg level which dispatched to the correct command, but I suppose an actual alias is better.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 2/3] util/grub.d/20_linux_xen.in: Add arm64 support
In reply to Andrei BorzenkovHi Andrei,
Great thanks for your review.
So Are you suggesting this:
(1) in util/grub.d/20_linux_xen.in, we only use xen_hypervisor/xen_module.
(2) in xen_boot.c, we only register command xen_hypervisor/xen_module.
(3) in grub-core/loader/i386/xen.c, we *add*
---------------
cmd_xen_hypervisort = grub_register_command ("xen_hypervisor", grub_cmd_xen,
0, N_("Load Linux."));
cmd_xen_module = grub_register_command ("xen_module", grub_cmd_module,
0, N_("Load module."));---------------
(4)in grub-core/loader/multiboot.c, we *add*
---------------
#if defined (__i386__) || defined (__aarch64__)
cmd_xen_hypervisort =
grub_register_command ("xen_hypervisor", grub_cmd_multiboot,
0, N_("Load a multiboot kernel."));
cmd_xen_module =
grub_register_command ("xen_module", grub_cmd_module,
0, N_("Load a multiboot module."));
#endif
---------------
BTW, from the source code, MIPS isn't supported by multiboot, IS supported by multiboot2.
Please correct me. If I misunderstand your suggestion. :-)
Thanks again!
Quoted 60 lines · Andrei Borzenkov
В Mon, 13 Jul 2015 16:53:59 +0800
[email protected] пишет:Quoted 37 lines
From: Fu Wei <[email protected]>
This patch adds the support of boot command on arm64 for XEN:
xen_hypervisor
xen_moduleSigned-off-by Fu Wei <[email protected]>--- util/grub.d/20_linux_xen.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)util/grub.d/20_linux_xen.in +3
-3@@ -120,16 +120,16 @@ linux_entry () else xen_rm_opts="no-real-mode edd=off" fi - multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} + ${multiboot_cmd} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} echo '$(echo "$lmessage" | grub_quote)' - module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} + ${module_cmd} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - module --nounzip ${rel_dirname}/${initrd} + ${module_cmd} --nounzip ${rel_dirname}/${initrd} EOF fi sed "s/^/$submenu_indentation/" << EOF@@ -185,6 +185,14 @@ case "$machine" in *) GENKERNEL_ARCH="$machine" ;;util/grub.d/20_linux_xen.in case "$machine" in · line 195
Quoted 10 lines
util/grub.d/20_linux_xen.in +8
-0esac +if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_cmd="module" +else + multiboot_cmd="xen_hypervisor" + module_cmd="xen_module" +fi +Strictly speaking, this is boot-time decision. As mentioned by Vladimir, better would be to provide alias
xen_hypervisorandxen_modulein multiboot for platforms supporting Xen (is MIPS really supported?) and use it consistently.Quoted 3 lines
util/grub.d/20_linux_xen.in +0
-0# Extra indentation to add to menu entries in a submenu. We're not in a submenu # yet, so it's empty. In a submenu it will be equal to '\t' (one tab). submenu_indentation=""
Signature · 15 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v2 2/3] util/grub.d/20_linux_xen.in: Add arm64 support
Quoted 12 lines · Fu Wei
Hi Andrei,
Great thanks for your review.
So Are you suggesting this:
(1) in util/grub.d/20_linux_xen.in, we only use xen_hypervisor/xen_module.
(2) inxen_boot.c, we only register command xen_hypervisor/xen_module.
(3) ingrub-core/loader/i386/xen.c, we *add*
---------------
cmd_xen_hypervisort=grub_register_command("xen_hypervisor",grub_cmd_xen,
0,N_("Load Linux."));
cmd_xen_module=grub_register_command("xen_module",grub_cmd_module,
Quoted 1 line
0, N_("Load module."));No. This is for pvgrub2.
Quoted 11 lines
---------------
(4)ingrub-core/loader/multiboot.c, we *add*
---------------
#if defined (__i386__) || defined (__aarch64__)
cmd_xen_hypervisort=
grub_register_command("xen_hypervisor",grub_cmd_multiboot,
0,N_("Load a multiboot kernel."));
cmd_xen_module=
grub_register_command("xen_module",grub_cmd_module,
0,N_("Load a multiboot module."));
#endif
No. Don't mix arm64 xen with multiboot. Neither in command names nor in the descriptions.
Quoted 5 lines
---------------
BTW, from the source code, MIPS isn't supported by multiboot, IS supported by multiboot2.
Quoted 69 lines
Please correct me. If I misunderstand your suggestion. :-)
Thanks again!
Quoted 60 lines · Andrei Borzenkov
В Mon, 13 Jul 2015 16:53:59 +0800
[email protected] пишет:Quoted 37 lines
From: Fu Wei <[email protected]>
This patch adds the support of boot command on arm64 for XEN:
xen_hypervisor
xen_moduleSigned-off-by Fu Wei <[email protected]>--- util/grub.d/20_linux_xen.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)util/grub.d/20_linux_xen.in +3
-3@@ -120,16 +120,16 @@ linux_entry () else xen_rm_opts="no-real-mode edd=off" fi - multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} + ${multiboot_cmd} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} echo '$(echo "$lmessage" | grub_quote)' - module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} + ${module_cmd} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - module --nounzip ${rel_dirname}/${initrd} + ${module_cmd} --nounzip ${rel_dirname}/${initrd} EOF fi sed "s/^/$submenu_indentation/" << EOF@@ -185,6 +185,14 @@ case "$machine" in *) GENKERNEL_ARCH="$machine" ;;util/grub.d/20_linux_xen.in case "$machine" in · line 195
Quoted 10 lines
util/grub.d/20_linux_xen.in +8
-0esac +if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_cmd="module" +else + multiboot_cmd="xen_hypervisor" + module_cmd="xen_module" +fi +Strictly speaking, this is boot-time decision. As mentioned by Vladimir, better would be to provide alias
xen_hypervisorandxen_modulein multiboot for platforms supporting Xen (is MIPS really supported?) and use it consistently.Quoted 3 lines
util/grub.d/20_linux_xen.in +0
-0# Extra indentation to add to menu entries in a submenu. We're not in a submenu # yet, so it's empty. In a submenu it will be equal to '\t' (one tab). submenu_indentation=""
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 3/3 arm64: Add the introduction of Xen boot command
In reply to [email protected]From: Fu Wei <[email protected]>
This patch adds the introduction of xen_hypervisor/xen_module commands in docs/grub.texi
--- docs/grub.texi | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
docs/grub.texi +27 -0
@@ -3839,6 +3839,9 @@ you forget a command, you can run the command @command{help} @comment * vbeinfo:: List available video modes * verify_detached:: Verify detached digital signature * videoinfo:: List available video modes +@comment * xen_hypervisor/xen_module:: Xen boot command, for arm64 only +* xen_hypervisor:: Load xen hypervisor binary on arm64 +* xen_module:: Load module for xen hypervisor on arm64 @end menu
@@ -5102,6 +5105,30 @@ successfully. If validation fails, it is set to a non-zero value. List available video modes. If resolution is given, show only matching modes. @end deffn +@node xen_hypervisor +@subsection xen_hypervisor + +@deffn Command xen_hypervisor file [arguments] @dots{} +Load a Xen hypervisor binary from @var{file}. The rest of the +line is passed verbatim as the @dfn{kernel command-line}. Any Xen module must +be reloaded after using this command (@pxref{xen_module}). +This command is only available on ARM64 systems. +@end deffn + +@node xen_module +@subsection xen_module + +@deffn Command xen_module [--type <compatible stream>] file [arguments] +Load a module for xen hypervisor binary. The rest of the +line is passed verbatim as the module command line. +This command is only available on ARM64 systems. + +--type is an option which allow the module command to take "compatible" string. +This would override default compatible string for this module. +See @uref{http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot}, +to obtain more information. +@end deffn + @node Networking commands @section The list of networking commands
Signature · 1 line
1.8.3.1
Re: [Xen-devel] [PATCH v2 0/3] arm64: Add multiboot support (via fdt) for Xen boot
In reply to [email protected]Quoted 3 lines · On Mon, 2015-07-13 at 16:53 +0800, [email protected] wrote:
From: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
I have used this to PXE boot Xen on a mustang board. My (handcrafted) grub.cfg was:
set default=0
set timeout=5
menuentry 'pxe multiboot xen' {
echo "xen_hypervisor /trap/xen.efi"
xen_hypervisor /trap/xen.efi conswitch=x watchdog console=dtuart dtuart=/soc/serial@1c020000 dom0_mem=512M,max:512M echo "xen_module /trap/vmlinuz"
xen_module /trap/vmlinuz root=/dev/mapper/trap--vg-root ro console=hvc0
echo "xen_module /trap/initrd.gz"
xen_module /trap/initrd.gz
boot
}
I didn't yet try a local boot from hdd since I'm sure it would work equivalently and there still seems to be some discussion around how the update-grub side should fit together.
Thanks!
Ian.
Re: [Xen-devel] [PATCH v2 0/3] arm64: Add multiboot support (via fdt) for Xen boot
Hi Ian,
Great thanks for your testing, will add your tested-by in my next patchset :-)
Quoted 30 lines · Ian Campbell
Quoted 3 lines · On Mon, 2015-07-13 at 16:53 +0800, [email protected] wrote:
From: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
I have used this to PXE boot Xen on a mustang board. My (handcrafted) grub.cfg was:
set default=0
set timeout=5
menuentry 'pxe multiboot xen' {
echo "xen_hypervisor/trap/xen.efi"
xen_hypervisor/trap/xen.efi conswitch=x watchdog console=dtuart dtuart=/soc/serial@1c020000 dom0_mem=512M,max:512M echo "xen_module/trap/vmlinuz"
xen_module/trap/vmlinuz root=/dev/mapper/trap--vg-root ro console=hvc0
echo "xen_module/trap/initrd.gz"
xen_module/trap/initrd.gz
boot
}Tested-by Ian Campbell <[email protected]>I didn't yet try a local boot from hdd since I'm sure it would work equivalently and there still seems to be some discussion around how the update-grub side should fit together.
Thanks!
Ian.
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v2 0/3] arm64: Add multiboot support (via fdt) for Xen boot
In reply to [email protected]Quoted 8 lines · On 13.07.2015 10:53, [email protected] wrote:
From: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
- The implementation for Xen is following <Multiboot on ARM Specification>:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
andxen/docs/misc/arm/device-tree/booting.txtin Xen source code.
Quoted 9 lines
- The multiboot/module commands have existed, so we use xen_hypervisor/xen_module instead.
- This Xen boot support is built into linux module for aarch64, and can not be used alone.
- Adding this functionality to the existing "linux" module is for reusing the existing code of devicetree.
This is a misguided decision. Modules can depend on other modules. Ideally shared functionality should be in a separate module but having xen depend on linux is an OK stopgap solution. Putting everything in one module is bad.
Quoted 27 lines
- Add the support of xen_hypervisor/xen_module commands in util/grub.d/20_linux_xen.in
- Add the introduction of xen_hypervisor/xen_module commands in docs/grub.texi
- The example of this support is <How to boot Xen with GRUB on AArch64 the Foundation FVP model>
https://wiki.linaro.org/LEG/Engineering/Grub2/Xen_booting_on_Foundation_FVP_model_by_GRUBChangelog:
v2: remove the patches which have been accepted.
according to Vladimir's suggestion, change the command manes and relevant code:
multiboot-->xen_hypervisor
module-->xen_module
improve the option parsing support for xen_hypervisor/xen_module commands. add a patch for adding xen_hypervisor/xen_module support
in util/grub.d/20_linux_xen.in.
update docs/grub.texi patch for the new command names.v1: The first version upstream patchset to grub-devel mailing list
Fu Wei (3):
arm64: Add Xen boot support file
* util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
arm64: Add the introduction of xen_hypervisor/xen_module command in
docs/grub.texi
Quoted 10 lines
docs/grub.texi | 27 ++ grub-core/Makefile.core.def | 1 + grub-core/loader/arm64/linux.c | 6 + grub-core/loader/arm64/xen_boot.c | 615 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/xen_boot.h | 115 +++++++ util/grub.d/20_linux_xen.in | 14 +- 6 files changed, 775 insertions(+), 3 deletions(-) create mode 100644 grub-core/loader/arm64/xen_boot.c create mode 100644 include/grub/arm64/xen_boot.h
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
v3 cover arm64: Add Xen boot support (via fdt)
In reply to a message not in the archiveFrom: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
- Add and export some accessor functions of "loaded" flag and grub_linux_get_fdt function in include/grub/arm64/linux.h for xen boot.
- Introduce xen_hypervisor, xen_linux, xen_initrd and xen_xsm to load different binaries for xen boot.
Introduce xen_module to load common or custom module for xen boot.
- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.
- Add the support of xen_hypervisor, xen_linux and xen_initrd
in util/grub.d/20_linux_xen.in
- Add the introduction of all xen boot commands in docs/grub.texi
- The example of this support is <How to boot Xen with GRUB on AArch64 the Foundation FVP model>
https://wiki.linaro.org/LEG/Engineering/Grub2/Xen_booting_on_Foundation_FVP_model_by_GRUB
Changelog:
v3: create separate module for xen boot: xen_boot
create separate commands for different types of module delete order-dependent for commands of xen module simplify the code
v2: remove the patches which have been accepted.
according to Vladimir's suggestion, change the command manes and relevant code:
multiboot-->xen_hypervisor
module-->xen_module
improve the option parsing support for xen_hypervisor/xen_module commands. add a patch for adding xen_hypervisor/xen_module support
in util/grub.d/20_linux_xen.in.
update docs/grub.texi patch for the new command names.
v1: The first version upstream patchset to grub-devel mailing list
Fu Wei (4):
arm64: Add and export some accessor functions for xen boot
arm64: Add xen_boot module file
* util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
arm64: Add the introduction of xen boot commands in docs/grub.texi
docs/grub.texi | 56 ++++ grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/linux.c | 13 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/linux.h | 6 +- util/grub.d/20_linux_xen.in | 16 +- 6 files changed, 779 insertions(+), 4 deletions(-) create mode 100644 grub-core/loader/arm64/xen_boot.c
Signature · 1 line
1.8.3.1
PATCH v3 1/4 arm64: Add and export some accessor functions for xen boot
From: Fu Wei <[email protected]>
Add accessor functions of "loaded" flag ingrub-core/loader/arm64/linux.c.
Export accessor functions of "loaded" flag and grub_linux_get_fdt function in include/grub/arm64/linux.h.
Purpose: Reuse the existing code of devicetree in linux module.
--- grub-core/loader/arm64/linux.c | 13 +++++++++++++ include/grub/arm64/linux.h | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-)
grub-core/loader/arm64/linux.c +13 -0
@@ -48,6 +48,19 @@ static grub_addr_t initrd_end;static void *loaded_fdt;static void *fdt; +/* The accessor functions for "loaded" flag */ +int +grub_linux_get_loaded (void ) +{ +return loaded; +} + +void +grub_linux_set_loaded (int loaded_flag) +{ + loaded = loaded_flag; +} +static void *get_firmware_fdt (void ) {
include/grub/arm64/linux.h +5 -1
@@ -43,10 +43,14 @@ struct grub_arm64_linux_kernel_header };/* Declare the functions for getting dtb and checking/booting image */ -void *grub_linux_get_fdt (void );grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header *lh);grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr,grub_size_t size,char *args); +/* Export the accessor functions for gettin dtb and "loaded" flag */ +void EXPORT_FUNC (*grub_linux_get_fdt) (void); +int EXPORT_FUNC (grub_linux_get_loaded ) (void ); +void EXPORT_FUNC (grub_linux_set_loaded ) (int loaded_flag); +#endif /* ! GRUB_LINUX_CPU_HEADER */
Signature · 1 line
1.8.3.1
Re: [PATCH v3 1/4] arm64: Add and export some accessor functions for xen boot
Quoted 27 lines · On 23.07.2015 07:16, [email protected] wrote:
From: Fu Wei <[email protected]>
Add accessor functions of "loaded" flag in
grub-core/loader/arm64/linux.c.Export accessor functions of "loaded" flag and
grub_linux_get_fdtfunction ininclude/grub/arm64/linux.h.Purpose: Reuse the existing code of devicetree in linux module.
Signed-off-by Fu Wei <[email protected]>--- grub-core/loader/arm64/linux.c | 13 +++++++++++++ include/grub/arm64/linux.h | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-)grub-core/loader/arm64/linux.c +3
-0@@ -48,6 +48,19 @@ static grub_addr_t initrd_end;static void *loaded_fdt;static void *fdt; +/* The accessor functions for "loaded" flag */ +int +grub_linux_get_loaded (void )
grub-core/loader/arm64/linux.c static grub_addr_t initrd_end; · line 63
Quoted 10 lines
grub-core/loader/arm64/linux.c +10
-0+{ +return loaded; +} + +void +grub_linux_set_loaded (int loaded_flag) +{ + loaded = loaded_flag; +} +
Accessor functions are usually useless in GRUB. We have no public API to respect. So it only adds clutter. Also "loaded" flag is static for а good reason: it's specific to linux.c. I'm going to move fdt part to fdt.c and have uniform interface for both linux and xen.
Quoted 12 lines
grub-core/loader/arm64/linux.c +0
-0static void *get_firmware_fdt (void ) {include/grub/arm64/linux.h +0
-1@@ -43,10 +43,14 @@ struct grub_arm64_linux_kernel_header };/* Declare the functions for getting dtb and checking/booting image */ -void *grub_linux_get_fdt (void );
include/grub/arm64/linux.h struct grub_arm64_linux_kernel_header · line 55
Quoted 10 lines
include/grub/arm64/linux.h +5
-0grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header *lh);grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr,grub_size_t size,char *args); +/* Export the accessor functions for gettin dtb and "loaded" flag */ +void EXPORT_FUNC (*grub_linux_get_fdt) (void); +int EXPORT_FUNC (grub_linux_get_loaded ) (void ); +void EXPORT_FUNC (grub_linux_set_loaded ) (int loaded_flag); +
EXPORT_* are necessary only for core. Not for modules.
include/grub/arm64/linux.h struct grub_arm64_linux_kernel_header · line 56
Quoted 2 lines
include/grub/arm64/linux.h +0
-0#endif /* ! GRUB_LINUX_CPU_HEADER */
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v3 1/4] arm64: Add and export some accessor functions for xen boot
Hi Vladimir,
Good idea! I can see your patch for it in master branch.
Great thanks for your help, I will try this ASAP :-)
Quoted 69 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 27 lines · On 23.07.2015 07:16, [email protected] wrote:
From: Fu Wei <[email protected]>
Add accessor functions of "loaded" flag in
grub-core/loader/arm64/linux.c.Export accessor functions of "loaded" flag and
grub_linux_get_fdtfunction ininclude/grub/arm64/linux.h.Purpose: Reuse the existing code of devicetree in linux module.
Signed-off-by Fu Wei <[email protected]>--- grub-core/loader/arm64/linux.c | 13 +++++++++++++ include/grub/arm64/linux.h | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-)grub-core/loader/arm64/linux.c +3
-0@@ -48,6 +48,19 @@ static grub_addr_t initrd_end;static void *loaded_fdt;static void *fdt; +/* The accessor functions for "loaded" flag */ +int +grub_linux_get_loaded (void )grub-core/loader/arm64/linux.c static grub_addr_t initrd_end; · line 63
Quoted 10 lines
grub-core/loader/arm64/linux.c +10
-0+{ +return loaded; +} + +void +grub_linux_set_loaded (int loaded_flag) +{ + loaded = loaded_flag; +} +Accessor functions are usually useless in GRUB. We have no public API to respect. So it only adds clutter. Also "loaded" flag is static for а good reason: it's specific to
linux.c. I'm going to move fdt part tofdt.cand have uniform interface for both linux and xen.Quoted 12 lines
grub-core/loader/arm64/linux.c +0
-0static void *get_firmware_fdt (void ) {include/grub/arm64/linux.h +0
-1@@ -43,10 +43,14 @@ struct grub_arm64_linux_kernel_header };/* Declare the functions for getting dtb and checking/booting image */ -void *grub_linux_get_fdt (void );include/grub/arm64/linux.h struct grub_arm64_linux_kernel_header · line 55
Quoted 10 lines
include/grub/arm64/linux.h +5
-0grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header *lh);grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr,grub_size_t size,char *args); +/* Export the accessor functions for gettin dtb and "loaded" flag */ +void EXPORT_FUNC (*grub_linux_get_fdt) (void); +int EXPORT_FUNC (grub_linux_get_loaded ) (void ); +void EXPORT_FUNC (grub_linux_set_loaded ) (int loaded_flag); +EXPORT_* are necessary only for core. Not for modules.
Quoted 2 lines
include/grub/arm64/linux.h +0
-0#endif /* ! GRUB_LINUX_CPU_HEADER */
Signature · 15 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v3 2/4 arm64: Add xen_boot module file
In reply to [email protected]From: Fu Wei <[email protected]>
grub-core/loader/arm64/xen_boot.c
- This adds support for the Xen boot on ARM specification for arm64.
- Introduce xen_hypervisor, xen_linux, xen_initrd and xen_xsm to load different binaries for xen boot;
Introduce xen_module to load common or custom module for xen boot.
- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.
--- grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 692 insertions(+)
grub-core/Makefile.core.def +7 -0
@@ -1648,6 +1648,13 @@ module = { }; module = { + name = xen_boot; + common = lib/cmdline.c; + arm64 = loader/arm64/xen_boot.c; + enable = arm64; +}; + +module = { name = linux; x86 = loader/i386/linux.c; xen = loader/i386/xen.c;
grub-core/loader/arm64/xen_boot.c new file +685 -0
685 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH v3 2/4] arm64: Add xen_boot module file
Committed without the xen_module command. Its argument parsing was non-trivial and I don't quite get what its intent is. Can you resubmit?
Quoted 717 lines · On 23.07.2015 07:16, [email protected] wrote:
From: Fu Wei <[email protected]>
grub-core/loader/arm64/xen_boot.c- This adds support for the Xen boot on ARM specification for arm64.
- Introducexen_hypervisor,xen_linux,xen_initrdandxen_xsmto load different binaries for xen boot;
Introducexen_moduleto load common or custom module for xen boot.
- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.Signed-off-by Fu Wei <[email protected]>--- grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 692 insertions(+)grub-core/Makefile.core.def +7
-0@@ -1648,6 +1648,13 @@ module = { }; module = { + name = xen_boot; + common = lib/cmdline.c; + arm64 = loader/arm64/xen_boot.c; + enable = arm64; +}; + +module = { name = linux; x86 = loader/i386/linux.c; xen = loader/i386/xen.c;grub-core/loader/arm64/xen_boot.c new file +675
-0@@ -0,0 +1,685 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2014 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <grub/cache.h> +#include <grub/charset.h> +#include <grub/command.h> +#include <grub/err.h> +#include <grub/file.h> +#include <grub/fdt.h> +#include <grub/linux.h> +#include <grub/list.h> +#include <grub/loader.h> +#include <grub/misc.h> +#include <grub/mm.h> +#include <grub/types.h> +#include <grub/cpu/linux.h> +#include <grub/efi/efi.h> +#include <grub/efi/pe32.h> /* required by struct xen_hypervisor_header */ +#include <grub/i18n.h> +#include <grub/lib/cmdline.h> + +GRUB_MOD_LICENSE ("GPLv3+" ); + +#define XEN_HYPERVISOR_NAME "xen_hypervisor" + +#define MODULE_DEFAULT_ALIGN (0x0) +#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_XSM_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN + +/* #define MODULE_IMAGE_COMPATIBLE "xen,linux-image\0xen,module" +#define MODULE_INITRD_COMPATIBLE "xen,linux-image\0xen,module" +#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0xen,module" +#define MODULE_CUSTOM_COMPATIBLE "xen,module" */ +#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" +#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" +#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0multiboot,module" +#define MODULE_CUSTOM_COMPATIBLE "multiboot,module" + +/* This maximum size is defined in Power.org ePAPR V1.1 +* https://www.power.org/documentation/epapr-version-1-1/ +* 2.2.1.1 Node Name Requirements +* node-name@unit-address +* 31 + 1(@) + 16(64bit address in hex format) + 1(\0) = 49 +*/ +#define FDT_NODE_NAME_MAX_SIZE (49) + +#define ARG_SHIFT (argc, argv) \ + do { \ + (argc)--; \ + (argv)++; \ + } while (0) + +struct compat_string_struct +{ +grub_size_t size; +const char *compat_string; +}; +typedef struct compat_string_struct compat_string_struct_t ; +#define FDT_COMPATIBLE (x) {.size = sizeof(x), .compat_string = (x)} + +enum module_type +{ +MODULE_IMAGE , +MODULE_INITRD , +MODULE_XSM , +MODULE_CUSTOM +}; +typedef enum module_type module_type_t ; + +struct fdt_node_info +{ +module_type_t type; + +const char *compat_string; +grub_size_t compat_string_size; +}; + +struct xen_hypervisor_header +{ +struct grub_arm64_linux_kernel_header efi_head; + +/* This is always PE\0\0. */ +grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE ]; +/* The COFF file header. */ +struct grub_pe32_coff_header coff_header; +/* The Optional header. */ +struct grub_pe64_optional_header optional_header; +}; + +struct xen_boot_binary +{ +struct xen_boot_binary *next; +struct xen_boot_binary **prev; +const char *name; + +grub_addr_t start; +grub_size_t size; +grub_size_t align; + +char *cmdline; +int cmdline_size; + +struct fdt_node_info node_info; +}; + +static grub_dl_t my_mod; + +static struct xen_boot_binary *xen_hypervisor; +static struct xen_boot_binary *module_head; +static const grub_size_t module_default_align[] = { +MODULE_IMAGE_MIN_ALIGN , +MODULE_INITRD_MIN_ALIGN , +MODULE_XSM_MIN_ALIGN , +MODULE_CUSTOM_MIN_ALIGN +}; + +static void *xen_boot_fdt; +static const compat_string_struct_t default_compat_string[] = { +FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_XSM_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_CUSTOM_COMPATIBLE ) +}; + +static __inlinegrub_addr_t +xen_boot_address_align (grub_addr_t start,grub_size_t align) +{ +return (align ? (ALIGN_UP (start, align)) : start); +} + +/* Parse the option of xen_module command. For now, we support +(1) --type <the compatible stream> +We also set up the type of module in this function. +If there are some "--type" options in the command line, +we make a custom compatible stream in this function. */ +static grub_err_t +set_module_type (grub_command_t cmd,struct xen_boot_binary *module, +int argc,char *argv[],int *file_name_index) +{ +char **compat_string_temp_array; +grub_size_t total_size =0 ; +int num_types =0 , i; +char *temp =NULL ; + + *file_name_index =0 ; + +if (!grub_strcmp (cmd->name,"xen_linux" )) + module->node_info.type =MODULE_IMAGE ; +else if (!grub_strcmp (cmd->name,"xen_initrd" )) + module->node_info.type =MODULE_INITRD ; +else if (!grub_strcmp (cmd->name,"xen_xsm" )) + module->node_info.type =MODULE_XSM ; +else if (!grub_strcmp (cmd->name,"xen_module" )) + module->node_info.type =MODULE_CUSTOM ; + +/* if there are some options we need to process. */ +if (module->node_info.type ==MODULE_CUSTOM ) + { + compat_string_temp_array = + (char **)grub_zalloc (sizeof (char *) * argc); +if (!compat_string_temp_array) +return grub_errno; +/* the module type is set by "--type"(MODULE_CUSTOM) */ +while (argc >2 && !grub_strcmp (argv[0 ],"--type" )) + { + module->node_info.type =MODULE_CUSTOM ; +ARG_SHIFT (argc, argv); + total_size +=grub_strlen (argv[0 ]) +1 ; + compat_string_temp_array[num_types++] = argv[0 ]; +ARG_SHIFT (argc, argv); + (*file_name_index) +=2 ; + } + +if (total_size) + { + module->node_info.compat_string = temp = + (char *)grub_zalloc (total_size); +if (!temp) + { +grub_free (compat_string_temp_array); +return grub_errno; + } + + module->node_info.compat_string_size = total_size; +for (i =0 ; num_types >0 ; num_types--, i++, temp++) + { +grub_strcpy (temp, compat_string_temp_array[i]); + temp +=grub_strlen (compat_string_temp_array[i]); + } + } +else + { + module->node_info.compat_string = + default_compat_string[MODULE_CUSTOM ].compat_string; + module->node_info.compat_string_size = + default_compat_string[MODULE_CUSTOM ].size; + } + +grub_free (compat_string_temp_array); + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_hypervisor_params (void ) +{ +int chosen_node =0 ; +int retval; + + xen_boot_fdt =grub_linux_get_fdt (); +if (!xen_boot_fdt) +return grub_error (GRUB_ERR_IO ,"failed to get FDT" ); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_IO ,"failed to get chosen node in FDT" ); + +grub_dprintf ("xen_loader" , +"Xen Hypervisor cmdline : %s @ %p size:%d\n" , + xen_hypervisor->cmdline, xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); + + retval =grub_fdt_set_prop (xen_boot_fdt, chosen_node,"bootargs" , + xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); +if (retval) +return grub_error (GRUB_ERR_IO ,"failed to install/update FDT" ); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_module_params (struct xen_boot_binary *module) +{ +int retval, chosen_node =0 , module_node =0 ; +char module_name[FDT_NODE_NAME_MAX_SIZE ]; + + retval =grub_snprintf (module_name,FDT_NODE_NAME_MAX_SIZE ,"module@%lx" , +xen_boot_address_align (module->start, + module->align)); +grub_dprintf ("xen_loader" ,"Module node name %s \n" , module_name); + +if (retval < (int )sizeof ("module@" )) +return grub_error (GRUB_ERR_IO ,N_ ("failed to get FDT" )); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_IO ,"failed to get chosen node in FDT" ); + + module_node = +grub_fdt_find_subnode (xen_boot_fdt, chosen_node, module_name); +if (module_node <0 ) + module_node = +grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"compatible" , + module->node_info.compat_string, + (grub_uint32_t ) module-> + node_info.compat_string_size); +if (retval) +return grub_error (GRUB_ERR_IO ,N_ ("failed to update FDT" )); + +grub_dprintf ("xen_loader" ,"Module %s compatible = %s size = 0x%lx\n" , + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + retval =grub_fdt_set_reg64 (xen_boot_fdt, module_node, +xen_boot_address_align (module->start, + module->align), + module->size); +if (retval) +return grub_error (GRUB_ERR_IO ,N_ ("failed to update FDT" )); + +if (module->cmdline && module->cmdline_size >0 ) + { +grub_dprintf ("xen_loader" , +"Module %s cmdline : %s @ %p size:%d\n" , module->name, + module->cmdline, module->cmdline, module->cmdline_size); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"bootargs" , + module->cmdline, module->cmdline_size +1 ); +if (retval) +return grub_error (GRUB_ERR_IO ,"failed to update FDT" ); + } +else + { +grub_dprintf ("xen_loader" ,"Module %s has not bootargs!\n" , + module->name); + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +install_all_params (void ) +{ +grub_efi_guid_t fdt_guid =GRUB_EFI_DEVICE_TREE_GUID ; +grub_efi_boot_services_t *b; +grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; + status = b->install_configuration_table (&fdt_guid, xen_boot_fdt); +if (status !=GRUB_EFI_SUCCESS ) +return grub_error (GRUB_ERR_IO ,"failed to install FDT" ); + +grub_dprintf ("xen_loader" , +"Installed/updated FDT configuration table @ %p\n" , + xen_boot_fdt); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +clean_all_params (void ) +{ +if (xen_boot_fdt) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) xen_boot_fdt, +BYTES_TO_PAGES (grub_fdt_get_totalsize + (xen_boot_fdt))); + xen_boot_fdt =NULL ; + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +finalize_params_xen_boot (void ) +{ +struct xen_boot_binary *module; + +if (xen_hypervisor) + { +if (prepare_xen_hypervisor_params () !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_loader" ,"Failed to get Xen Hypervisor info!\n" ); + goto fail; + } + +/* Set module params info */ + FOR_LIST_ELEMENTS (module, module_head) + { +if (module->start && module->size >0 ) + { +grub_dprintf ("xen_loader" ,"Module %s @ 0x%lx size:0x%lx\n" , + module->name, +xen_boot_address_align (module->start, module->align), + module->size); +if (prepare_xen_module_params (module) !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_loader" ,"Module info error: %s!\n" , module->name); + goto fail; + } + } + +if (install_all_params () ==GRUB_ERR_NONE ) +return GRUB_ERR_NONE ; + +fail: +clean_all_params (); + +return grub_error (GRUB_ERR_IO ,"failed to install/update FDT" ); +} + + +static grub_err_t +xen_boot (void ) +{ +grub_err_t err =finalize_params_xen_boot (); +if (err) +return err; + +return grub_arm64_uefi_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); +} + +static void +single_binary_unload (struct xen_boot_binary *binary) +{ +if (!binary) +return ; + +if (binary->start && binary->size >0 ) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) binary->start, +BYTES_TO_PAGES (binary->size + binary->align)); + } + +if (binary->cmdline && binary->cmdline_size >0 ) + { +grub_free (binary->cmdline); +grub_dprintf ("xen_loader" , +"Module %s cmdline memory free @ %p size: %d\n" , + binary->name, binary->cmdline, binary->cmdline_size); + } + +if (binary->node_info.type ==MODULE_CUSTOM ) +grub_free ((void *) binary->node_info.compat_string); + +if (grub_strcmp (binary->name,XEN_HYPERVISOR_NAME )) +grub_list_remove (GRUB_AS_LIST (binary)); + +grub_dprintf ("xen_loader" , +"Module %s struct memory free @ %p size: 0x%lx\n" , + binary->name, binary,sizeof (binary)); +grub_free (binary); + +return ; +} + +static void +all_binaries_unload (void ) +{ +struct xen_boot_binary *binary; + + FOR_LIST_ELEMENTS (binary, module_head) + { +single_binary_unload (binary); + } + +if (xen_hypervisor) +single_binary_unload (xen_hypervisor); + +return ; +} + +static grub_err_t +xen_unload (void ) +{ +grub_linux_set_loaded (0 ); +all_binaries_unload (); +clean_all_params (); +grub_dl_unref (my_mod); + +return GRUB_ERR_NONE ; +} + +static void +xen_boot_binary_load (struct xen_boot_binary *binary,grub_file_t file, +int argc,char *argv[]) +{ + binary->size =grub_file_size (file); +grub_dprintf ("xen_loader" ,"Xen_boot %s file size: 0x%lx\n" , + binary->name, binary->size); + + binary->start = (grub_addr_t )grub_efi_allocate_pages (0 , + (BYTES_TO_PAGES + (binary->size + + binary->align))); +if (!binary->start) + { +grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +return ; + } + +grub_dprintf ("xen_loader" ,"Xen_boot %s numpages: 0x%lx\n" , + binary->name,BYTES_TO_PAGES (binary->size + binary->align)); + +if (grub_file_read (file, (void *)xen_boot_address_align (binary->start, + binary->align), + binary->size) != (grub_ssize_t ) binary->size) + { +single_binary_unload (binary); +grub_error (GRUB_ERR_BAD_OS ,N_ ("premature end of file %s" ), argv[0 ]); +return ; + } + +if (argc >1 ) + { + binary->cmdline_size =grub_loader_cmdline_size (argc -1 , argv +1 ); + binary->cmdline =grub_zalloc (binary->cmdline_size); +if (!binary->cmdline) + { +single_binary_unload (binary); +grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +return ; + } +grub_create_loader_cmdline (argc -1 , argv +1 , binary->cmdline, + binary->cmdline_size); +grub_dprintf ("xen_loader" , +"Xen_boot %s cmdline @ %p %s, size: %d\n" , binary->name, + binary->cmdline, binary->cmdline, binary->cmdline_size); + } +else + { + binary->cmdline_size =0 ; + binary->cmdline =NULL ; + } + + grub_errno =GRUB_ERR_NONE ; +return ; +} + +static grub_err_t +grub_cmd_xen_module (grub_command_t cmd,int argc,char *argv[]) +{ + +struct xen_boot_binary *module =NULL ; +int file_name_index =0 ; +grub_file_t file =0 ; + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail; + } + +if (!grub_linux_get_loaded ()) + { +grub_error (GRUB_ERR_BAD_ARGUMENT , +N_ ("you need to load the Xen Hypervisor first" )); + goto fail; + } + + module = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!module) +return grub_errno; + +/* process all the options and get module type */ +if (set_module_type (cmd, module, argc, argv, &file_name_index) != +GRUB_ERR_NONE ) + goto fail; +switch (module->node_info.type) + { +case MODULE_IMAGE : +case MODULE_INITRD : +case MODULE_XSM : + module->node_info.compat_string = + default_compat_string[module->node_info.type].compat_string; + module->node_info.compat_string_size = + default_compat_string[module->node_info.type].size; +break ; + +case MODULE_CUSTOM : +/* we have set the node_info in set_module_type */ +break ; + +default : +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("invalid argument" )); + } + module->name = module->node_info.compat_string; + module->align = module_default_align[module->node_info.type]; + +grub_dprintf ("xen_loader" ,"Init %s module and node info:\n" +"compatible %s\ncompat_string_size 0x%lx\n" , + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + file =grub_file_open (argv[file_name_index]); +if (!file) + goto fail; + +xen_boot_binary_load (module, file, argc - file_name_index, + argv + file_name_index); +if (grub_errno ==GRUB_ERR_NONE ) +grub_list_push (GRUB_AS_LIST_P (&module_head),GRUB_AS_LIST (module)); + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) +single_binary_unload (module); + +return grub_errno; +} + +static grub_err_t +grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), +int argc,char *argv[]) +{ +struct xen_hypervisor_header sh; +grub_file_t file =NULL ; + +grub_dl_ref (my_mod); + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail; + } + + file =grub_file_open (argv[0 ]); +if (!file) + goto fail; + +if (grub_file_read (file, &sh,sizeof (sh)) != (long )sizeof (sh)) + goto fail; +if (grub_arm64_uefi_check_image + ((struct grub_arm64_linux_kernel_header *) &sh) !=GRUB_ERR_NONE ) + goto fail; +grub_file_seek (file,0 ); + +/* if another module has called grub_loader_set, +we need to make sure that another module is unloaded properly */ +grub_loader_unset (); + + xen_hypervisor = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!xen_hypervisor) +return grub_errno; + + xen_hypervisor->name =XEN_HYPERVISOR_NAME ; + xen_hypervisor->align = (grub_size_t ) sh.optional_header.section_alignment; + +xen_boot_binary_load (xen_hypervisor, file, argc, argv); +if (grub_errno ==GRUB_ERR_NONE ) + { +grub_loader_set (xen_boot, xen_unload,0 ); +grub_linux_set_loaded (1 ); + } + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) + { +grub_linux_set_loaded (0 ); +all_binaries_unload (); +grub_dl_unref (my_mod); + } + +return grub_errno; +} + +static grub_command_t cmd_xen_hypervisor, cmd_xen_module; +static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm; + +GRUB_MOD_INIT (xen_boot) +{ + cmd_xen_hypervisor = +grub_register_command ("xen_hypervisor" , grub_cmd_xen_hypervisor,0 , +N_ ("Load a xen hypervisor." )); + cmd_xen_linux = +grub_register_command ("xen_linux" , grub_cmd_xen_module,0 , +N_ ("Load a xen linux kernel for dom0." )); + cmd_xen_initrd = +grub_register_command ("xen_initrd" , grub_cmd_xen_module,0 , +N_ ("Load a xen initrd for dom0." )); + cmd_xen_xsm = +grub_register_command ("xen_xsm" , grub_cmd_xen_module,0 , +N_ ("Load a xen security module." )); + cmd_xen_module = +grub_register_command ("xen_module" , grub_cmd_xen_module,0 , +N_ ("Load a xen module." )); + my_mod = mod;
grub-core/loader/arm64/xen_boot.c line 685
Quoted 10 lines
grub-core/loader/arm64/xen_boot.c new file +10
-0+} + +GRUB_MOD_FINI (xen_boot) +{ +grub_unregister_command (cmd_xen_hypervisor); +grub_unregister_command (cmd_xen_linux); +grub_unregister_command (cmd_xen_initrd); +grub_unregister_command (cmd_xen_xsm); +grub_unregister_command (cmd_xen_module); +}
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v3 2/4] arm64: Add xen_boot module file
Hi Vladimir,
yes, Thanks for your modification :-)
I just follow the xen boot protocol :
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
xen_module is just for "--type" option, I will discuss this with Xen developer for this.
If we need this option, I will resubmit it :-)
Great thanks!
Quoted 732 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Committed without the
xen_modulecommand. Its argument parsing was non-trivial and I don't quite get what its intent is. Can you resubmit?Quoted 727 lines · On 23.07.2015 07:16, [email protected] wrote:
From: Fu Wei <[email protected]>
grub-core/loader/arm64/xen_boot.c- This adds support for the Xen boot on ARM specification for arm64.
- Introducexen_hypervisor,xen_linux,xen_initrdandxen_xsmto load different binaries for xen boot;
Introducexen_moduleto load common or custom module for xen boot.
- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.Signed-off-by Fu Wei <[email protected]>--- grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 692 insertions(+)grub-core/Makefile.core.def +7
-0@@ -1648,6 +1648,13 @@ module = { }; module = { + name = xen_boot; + common = lib/cmdline.c; + arm64 = loader/arm64/xen_boot.c; + enable = arm64; +}; + +module = { name = linux; x86 = loader/i386/linux.c; xen = loader/i386/xen.c;grub-core/loader/arm64/xen_boot.c new file +685
-0@@ -0,0 +1,685 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2014 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <grub/cache.h> +#include <grub/charset.h> +#include <grub/command.h> +#include <grub/err.h> +#include <grub/file.h> +#include <grub/fdt.h> +#include <grub/linux.h> +#include <grub/list.h> +#include <grub/loader.h> +#include <grub/misc.h> +#include <grub/mm.h> +#include <grub/types.h> +#include <grub/cpu/linux.h> +#include <grub/efi/efi.h> +#include <grub/efi/pe32.h> /* required by struct xen_hypervisor_header */ +#include <grub/i18n.h> +#include <grub/lib/cmdline.h> + +GRUB_MOD_LICENSE ("GPLv3+" ); + +#define XEN_HYPERVISOR_NAME "xen_hypervisor" + +#define MODULE_DEFAULT_ALIGN (0x0) +#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_XSM_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN + +/* #define MODULE_IMAGE_COMPATIBLE "xen,linux-image\0xen,module" +#define MODULE_INITRD_COMPATIBLE "xen,linux-image\0xen,module" +#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0xen,module" +#define MODULE_CUSTOM_COMPATIBLE "xen,module" */ +#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" +#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" +#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0multiboot,module" +#define MODULE_CUSTOM_COMPATIBLE "multiboot,module" + +/* This maximum size is defined in Power.org ePAPR V1.1 +* https://www.power.org/documentation/epapr-version-1-1/ +* 2.2.1.1 Node Name Requirements +* node-name@unit-address +* 31 + 1(@) + 16(64bit address in hex format) + 1(\0) = 49 +*/ +#define FDT_NODE_NAME_MAX_SIZE (49) + +#define ARG_SHIFT (argc, argv) \ + do { \ + (argc)--; \ + (argv)++; \ + } while (0) + +struct compat_string_struct +{ +grub_size_t size; +const char *compat_string; +}; +typedef struct compat_string_struct compat_string_struct_t ; +#define FDT_COMPATIBLE (x) {.size = sizeof(x), .compat_string = (x)} + +enum module_type +{ +MODULE_IMAGE , +MODULE_INITRD , +MODULE_XSM , +MODULE_CUSTOM +}; +typedef enum module_type module_type_t ; + +struct fdt_node_info +{ +module_type_t type; + +const char *compat_string; +grub_size_t compat_string_size; +}; + +struct xen_hypervisor_header +{ +struct grub_arm64_linux_kernel_header efi_head; + +/* This is always PE\0\0. */ +grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE ]; +/* The COFF file header. */ +struct grub_pe32_coff_header coff_header; +/* The Optional header. */ +struct grub_pe64_optional_header optional_header; +}; + +struct xen_boot_binary +{ +struct xen_boot_binary *next; +struct xen_boot_binary **prev; +const char *name; + +grub_addr_t start; +grub_size_t size; +grub_size_t align; + +char *cmdline; +int cmdline_size; + +struct fdt_node_info node_info; +}; + +static grub_dl_t my_mod; + +static struct xen_boot_binary *xen_hypervisor; +static struct xen_boot_binary *module_head; +static const grub_size_t module_default_align[] = { +MODULE_IMAGE_MIN_ALIGN , +MODULE_INITRD_MIN_ALIGN , +MODULE_XSM_MIN_ALIGN , +MODULE_CUSTOM_MIN_ALIGN +}; + +static void *xen_boot_fdt; +static const compat_string_struct_t default_compat_string[] = { +FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_XSM_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_CUSTOM_COMPATIBLE ) +}; + +static __inlinegrub_addr_t +xen_boot_address_align (grub_addr_t start,grub_size_t align) +{ +return (align ? (ALIGN_UP (start, align)) : start); +} + +/* Parse the option of xen_module command. For now, we support +(1) --type <the compatible stream> +We also set up the type of module in this function. +If there are some "--type" options in the command line, +we make a custom compatible stream in this function. */ +static grub_err_t +set_module_type (grub_command_t cmd,struct xen_boot_binary *module, +int argc,char *argv[],int *file_name_index) +{ +char **compat_string_temp_array; +grub_size_t total_size =0 ; +int num_types =0 , i; +char *temp =NULL ; + + *file_name_index =0 ; + +if (!grub_strcmp (cmd->name,"xen_linux" )) + module->node_info.type =MODULE_IMAGE ; +else if (!grub_strcmp (cmd->name,"xen_initrd" )) + module->node_info.type =MODULE_INITRD ; +else if (!grub_strcmp (cmd->name,"xen_xsm" )) + module->node_info.type =MODULE_XSM ; +else if (!grub_strcmp (cmd->name,"xen_module" )) + module->node_info.type =MODULE_CUSTOM ; + +/* if there are some options we need to process. */ +if (module->node_info.type ==MODULE_CUSTOM ) + { + compat_string_temp_array = + (char **)grub_zalloc (sizeof (char *) * argc); +if (!compat_string_temp_array) +return grub_errno; +/* the module type is set by "--type"(MODULE_CUSTOM) */ +while (argc >2 && !grub_strcmp (argv[0 ],"--type" )) + { + module->node_info.type =MODULE_CUSTOM ; +ARG_SHIFT (argc, argv); + total_size +=grub_strlen (argv[0 ]) +1 ; + compat_string_temp_array[num_types++] = argv[0 ]; +ARG_SHIFT (argc, argv); + (*file_name_index) +=2 ; + } + +if (total_size) + { + module->node_info.compat_string = temp = + (char *)grub_zalloc (total_size); +if (!temp) + { +grub_free (compat_string_temp_array); +return grub_errno; + } + + module->node_info.compat_string_size = total_size; +for (i =0 ; num_types >0 ; num_types--, i++, temp++) + { +grub_strcpy (temp, compat_string_temp_array[i]); + temp +=grub_strlen (compat_string_temp_array[i]); + } + } +else + { + module->node_info.compat_string = + default_compat_string[MODULE_CUSTOM ].compat_string; + module->node_info.compat_string_size = + default_compat_string[MODULE_CUSTOM ].size; + } + +grub_free (compat_string_temp_array); + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_hypervisor_params (void ) +{ +int chosen_node =0 ; +int retval; + + xen_boot_fdt =grub_linux_get_fdt (); +if (!xen_boot_fdt) +return grub_error (GRUB_ERR_IO ,"failed to get FDT" ); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_IO ,"failed to get chosen node in FDT" ); + +grub_dprintf ("xen_loader" , +"Xen Hypervisor cmdline : %s @ %p size:%d\n" , + xen_hypervisor->cmdline, xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); + + retval =grub_fdt_set_prop (xen_boot_fdt, chosen_node,"bootargs" , + xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); +if (retval) +return grub_error (GRUB_ERR_IO ,"failed to install/update FDT" ); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_module_params (struct xen_boot_binary *module) +{ +int retval, chosen_node =0 , module_node =0 ; +char module_name[FDT_NODE_NAME_MAX_SIZE ]; + + retval =grub_snprintf (module_name,FDT_NODE_NAME_MAX_SIZE ,"module@%lx" , +xen_boot_address_align (module->start, + module->align)); +grub_dprintf ("xen_loader" ,"Module node name %s \n" , module_name); + +if (retval < (int )sizeof ("module@" )) +return grub_error (GRUB_ERR_IO ,N_ ("failed to get FDT" )); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_IO ,"failed to get chosen node in FDT" ); + + module_node = +grub_fdt_find_subnode (xen_boot_fdt, chosen_node, module_name); +if (module_node <0 ) + module_node = +grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"compatible" , + module->node_info.compat_string, + (grub_uint32_t ) module-> + node_info.compat_string_size); +if (retval) +return grub_error (GRUB_ERR_IO ,N_ ("failed to update FDT" )); + +grub_dprintf ("xen_loader" ,"Module %s compatible = %s size = 0x%lx\n" , + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + retval =grub_fdt_set_reg64 (xen_boot_fdt, module_node, +xen_boot_address_align (module->start, + module->align), + module->size); +if (retval) +return grub_error (GRUB_ERR_IO ,N_ ("failed to update FDT" )); + +if (module->cmdline && module->cmdline_size >0 ) + { +grub_dprintf ("xen_loader" , +"Module %s cmdline : %s @ %p size:%d\n" , module->name, + module->cmdline, module->cmdline, module->cmdline_size); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"bootargs" , + module->cmdline, module->cmdline_size +1 ); +if (retval) +return grub_error (GRUB_ERR_IO ,"failed to update FDT" ); + } +else + { +grub_dprintf ("xen_loader" ,"Module %s has not bootargs!\n" , + module->name); + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +install_all_params (void ) +{ +grub_efi_guid_t fdt_guid =GRUB_EFI_DEVICE_TREE_GUID ; +grub_efi_boot_services_t *b; +grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; + status = b->install_configuration_table (&fdt_guid, xen_boot_fdt); +if (status !=GRUB_EFI_SUCCESS ) +return grub_error (GRUB_ERR_IO ,"failed to install FDT" ); + +grub_dprintf ("xen_loader" , +"Installed/updated FDT configuration table @ %p\n" , + xen_boot_fdt); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +clean_all_params (void ) +{ +if (xen_boot_fdt) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) xen_boot_fdt, +BYTES_TO_PAGES (grub_fdt_get_totalsize + (xen_boot_fdt))); + xen_boot_fdt =NULL ; + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +finalize_params_xen_boot (void ) +{ +struct xen_boot_binary *module; + +if (xen_hypervisor) + { +if (prepare_xen_hypervisor_params () !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_loader" ,"Failed to get Xen Hypervisor info!\n" ); + goto fail; + } + +/* Set module params info */ + FOR_LIST_ELEMENTS (module, module_head) + { +if (module->start && module->size >0 ) + { +grub_dprintf ("xen_loader" ,"Module %s @ 0x%lx size:0x%lx\n" , + module->name, +xen_boot_address_align (module->start, module->align), + module->size); +if (prepare_xen_module_params (module) !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_loader" ,"Module info error: %s!\n" , module->name); + goto fail; + } + } + +if (install_all_params () ==GRUB_ERR_NONE ) +return GRUB_ERR_NONE ; + +fail: +clean_all_params (); + +return grub_error (GRUB_ERR_IO ,"failed to install/update FDT" ); +} + + +static grub_err_t +xen_boot (void ) +{ +grub_err_t err =finalize_params_xen_boot (); +if (err) +return err; + +return grub_arm64_uefi_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); +} + +static void +single_binary_unload (struct xen_boot_binary *binary) +{ +if (!binary) +return ; + +if (binary->start && binary->size >0 ) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) binary->start, +BYTES_TO_PAGES (binary->size + binary->align)); + } + +if (binary->cmdline && binary->cmdline_size >0 ) + { +grub_free (binary->cmdline); +grub_dprintf ("xen_loader" , +"Module %s cmdline memory free @ %p size: %d\n" , + binary->name, binary->cmdline, binary->cmdline_size); + } + +if (binary->node_info.type ==MODULE_CUSTOM ) +grub_free ((void *) binary->node_info.compat_string); + +if (grub_strcmp (binary->name,XEN_HYPERVISOR_NAME )) +grub_list_remove (GRUB_AS_LIST (binary)); + +grub_dprintf ("xen_loader" , +"Module %s struct memory free @ %p size: 0x%lx\n" , + binary->name, binary,sizeof (binary)); +grub_free (binary); + +return ; +} + +static void +all_binaries_unload (void ) +{ +struct xen_boot_binary *binary; + + FOR_LIST_ELEMENTS (binary, module_head) + { +single_binary_unload (binary); + } + +if (xen_hypervisor) +single_binary_unload (xen_hypervisor); + +return ; +} + +static grub_err_t +xen_unload (void ) +{ +grub_linux_set_loaded (0 ); +all_binaries_unload (); +clean_all_params (); +grub_dl_unref (my_mod); + +return GRUB_ERR_NONE ; +} + +static void +xen_boot_binary_load (struct xen_boot_binary *binary,grub_file_t file, +int argc,char *argv[]) +{ + binary->size =grub_file_size (file); +grub_dprintf ("xen_loader" ,"Xen_boot %s file size: 0x%lx\n" , + binary->name, binary->size); + + binary->start = (grub_addr_t )grub_efi_allocate_pages (0 , + (BYTES_TO_PAGES + (binary->size + + binary->align))); +if (!binary->start) + { +grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +return ; + } + +grub_dprintf ("xen_loader" ,"Xen_boot %s numpages: 0x%lx\n" , + binary->name,BYTES_TO_PAGES (binary->size + binary->align)); + +if (grub_file_read (file, (void *)xen_boot_address_align (binary->start, + binary->align), + binary->size) != (grub_ssize_t ) binary->size) + { +single_binary_unload (binary); +grub_error (GRUB_ERR_BAD_OS ,N_ ("premature end of file %s" ), argv[0 ]); +return ; + } + +if (argc >1 ) + { + binary->cmdline_size =grub_loader_cmdline_size (argc -1 , argv +1 ); + binary->cmdline =grub_zalloc (binary->cmdline_size); +if (!binary->cmdline) + { +single_binary_unload (binary); +grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +return ; + } +grub_create_loader_cmdline (argc -1 , argv +1 , binary->cmdline, + binary->cmdline_size); +grub_dprintf ("xen_loader" , +"Xen_boot %s cmdline @ %p %s, size: %d\n" , binary->name, + binary->cmdline, binary->cmdline, binary->cmdline_size); + } +else + { + binary->cmdline_size =0 ; + binary->cmdline =NULL ; + } + + grub_errno =GRUB_ERR_NONE ; +return ; +} + +static grub_err_t +grub_cmd_xen_module (grub_command_t cmd,int argc,char *argv[]) +{ + +struct xen_boot_binary *module =NULL ; +int file_name_index =0 ; +grub_file_t file =0 ; + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail; + } + +if (!grub_linux_get_loaded ()) + { +grub_error (GRUB_ERR_BAD_ARGUMENT , +N_ ("you need to load the Xen Hypervisor first" )); + goto fail; + } + + module = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!module) +return grub_errno; + +/* process all the options and get module type */ +if (set_module_type (cmd, module, argc, argv, &file_name_index) != +GRUB_ERR_NONE ) + goto fail; +switch (module->node_info.type) + { +case MODULE_IMAGE : +case MODULE_INITRD : +case MODULE_XSM : + module->node_info.compat_string = + default_compat_string[module->node_info.type].compat_string; + module->node_info.compat_string_size = + default_compat_string[module->node_info.type].size; +break ; + +case MODULE_CUSTOM : +/* we have set the node_info in set_module_type */ +break ; + +default : +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("invalid argument" )); + } + module->name = module->node_info.compat_string; + module->align = module_default_align[module->node_info.type]; + +grub_dprintf ("xen_loader" ,"Init %s module and node info:\n" +"compatible %s\ncompat_string_size 0x%lx\n" , + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + file =grub_file_open (argv[file_name_index]); +if (!file) + goto fail; + +xen_boot_binary_load (module, file, argc - file_name_index, + argv + file_name_index); +if (grub_errno ==GRUB_ERR_NONE ) +grub_list_push (GRUB_AS_LIST_P (&module_head),GRUB_AS_LIST (module)); + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) +single_binary_unload (module); + +return grub_errno; +} + +static grub_err_t +grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), +int argc,char *argv[]) +{ +struct xen_hypervisor_header sh; +grub_file_t file =NULL ; + +grub_dl_ref (my_mod); + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail; + } + + file =grub_file_open (argv[0 ]); +if (!file) + goto fail; + +if (grub_file_read (file, &sh,sizeof (sh)) != (long )sizeof (sh)) + goto fail; +if (grub_arm64_uefi_check_image + ((struct grub_arm64_linux_kernel_header *) &sh) !=GRUB_ERR_NONE ) + goto fail; +grub_file_seek (file,0 ); + +/* if another module has called grub_loader_set, +we need to make sure that another module is unloaded properly */ +grub_loader_unset (); + + xen_hypervisor = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!xen_hypervisor) +return grub_errno; + + xen_hypervisor->name =XEN_HYPERVISOR_NAME ; + xen_hypervisor->align = (grub_size_t ) sh.optional_header.section_alignment; + +xen_boot_binary_load (xen_hypervisor, file, argc, argv); +if (grub_errno ==GRUB_ERR_NONE ) + { +grub_loader_set (xen_boot, xen_unload,0 ); +grub_linux_set_loaded (1 ); + } + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) + { +grub_linux_set_loaded (0 ); +all_binaries_unload (); +grub_dl_unref (my_mod); + } + +return grub_errno; +} + +static grub_command_t cmd_xen_hypervisor, cmd_xen_module; +static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm; + +GRUB_MOD_INIT (xen_boot) +{ + cmd_xen_hypervisor = +grub_register_command ("xen_hypervisor" , grub_cmd_xen_hypervisor,0 , +N_ ("Load a xen hypervisor." )); + cmd_xen_linux = +grub_register_command ("xen_linux" , grub_cmd_xen_module,0 , +N_ ("Load a xen linux kernel for dom0." )); + cmd_xen_initrd = +grub_register_command ("xen_initrd" , grub_cmd_xen_module,0 , +N_ ("Load a xen initrd for dom0." )); + cmd_xen_xsm = +grub_register_command ("xen_xsm" , grub_cmd_xen_module,0 , +N_ ("Load a xen security module." )); + cmd_xen_module = +grub_register_command ("xen_module" , grub_cmd_xen_module,0 , +N_ ("Load a xen module." )); + my_mod = mod; +} + +GRUB_MOD_FINI (xen_boot) +{ +grub_unregister_command (cmd_xen_hypervisor); +grub_unregister_command (cmd_xen_linux); +grub_unregister_command (cmd_xen_initrd); +grub_unregister_command (cmd_xen_xsm); +grub_unregister_command (cmd_xen_module); +}
Signature · 15 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v3 2/4] arm64: Add xen_boot module file
Hi Vladimir,
After discussing with Ian Campbell, Since we already can load all
the necessary binaries for Xen boot on arm64 for now, we don't really need "xen_module" command now.
But maybe someday , xen need a new type of binary in boot time, then we still need this support.
So I will submit a "xen_module" command patch soon, in case we need it.
Great thanks ! :-)
Quoted 761 lines · Fu Wei
Hi Vladimir,
yes, Thanks for your modification :-)
I just follow the xen boot protocol :
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
xen_moduleis just for "--type" option, I will discuss this with Xen developer for this.
If we need this option, I will resubmit it :-)Great thanks!
Quoted 722 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Committed without the
xen_modulecommand. Its argument parsing was non-trivial and I don't quite get what its intent is. Can you resubmit?Quoted 719 lines · On 23.07.2015 07:16, [email protected] wrote:
From: Fu Wei <[email protected]>
grub-core/loader/arm64/xen_boot.c- This adds support for the Xen boot on ARM specification for arm64.
- Introducexen_hypervisor,xen_linux,xen_initrdandxen_xsmto load different binaries for xen boot;
Introducexen_moduleto load common or custom module for xen boot.
- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.Signed-off-by Fu Wei <[email protected]>--- grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 692 insertions(+)grub-core/Makefile.core.def +7
-0@@ -1648,6 +1648,13 @@ module = { }; module = { + name = xen_boot; + common = lib/cmdline.c; + arm64 = loader/arm64/xen_boot.c; + enable = arm64; +}; + +module = { name = linux; x86 = loader/i386/linux.c; xen = loader/i386/xen.c;grub-core/loader/arm64/xen_boot.c new file +678
-0@@ -0,0 +1,685 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2014 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <grub/cache.h> +#include <grub/charset.h> +#include <grub/command.h> +#include <grub/err.h> +#include <grub/file.h> +#include <grub/fdt.h> +#include <grub/linux.h> +#include <grub/list.h> +#include <grub/loader.h> +#include <grub/misc.h> +#include <grub/mm.h> +#include <grub/types.h> +#include <grub/cpu/linux.h> +#include <grub/efi/efi.h> +#include <grub/efi/pe32.h> /* required by struct xen_hypervisor_header */ +#include <grub/i18n.h> +#include <grub/lib/cmdline.h> + +GRUB_MOD_LICENSE ("GPLv3+" ); + +#define XEN_HYPERVISOR_NAME "xen_hypervisor" + +#define MODULE_DEFAULT_ALIGN (0x0) +#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_XSM_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN + +/* #define MODULE_IMAGE_COMPATIBLE "xen,linux-image\0xen,module" +#define MODULE_INITRD_COMPATIBLE "xen,linux-image\0xen,module" +#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0xen,module" +#define MODULE_CUSTOM_COMPATIBLE "xen,module" */ +#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" +#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" +#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0multiboot,module" +#define MODULE_CUSTOM_COMPATIBLE "multiboot,module" + +/* This maximum size is defined in Power.org ePAPR V1.1 +* https://www.power.org/documentation/epapr-version-1-1/ +* 2.2.1.1 Node Name Requirements +* node-name@unit-address +* 31 + 1(@) + 16(64bit address in hex format) + 1(\0) = 49 +*/ +#define FDT_NODE_NAME_MAX_SIZE (49) + +#define ARG_SHIFT (argc, argv) \ + do { \ + (argc)--; \ + (argv)++; \ + } while (0) + +struct compat_string_struct +{ +grub_size_t size; +const char *compat_string; +}; +typedef struct compat_string_struct compat_string_struct_t ; +#define FDT_COMPATIBLE (x) {.size = sizeof(x), .compat_string = (x)} + +enum module_type +{ +MODULE_IMAGE , +MODULE_INITRD , +MODULE_XSM , +MODULE_CUSTOM +}; +typedef enum module_type module_type_t ; + +struct fdt_node_info +{ +module_type_t type; + +const char *compat_string; +grub_size_t compat_string_size; +}; + +struct xen_hypervisor_header +{ +struct grub_arm64_linux_kernel_header efi_head; + +/* This is always PE\0\0. */ +grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE ]; +/* The COFF file header. */ +struct grub_pe32_coff_header coff_header; +/* The Optional header. */ +struct grub_pe64_optional_header optional_header; +}; + +struct xen_boot_binary +{ +struct xen_boot_binary *next; +struct xen_boot_binary **prev; +const char *name; + +grub_addr_t start; +grub_size_t size; +grub_size_t align; + +char *cmdline; +int cmdline_size; + +struct fdt_node_info node_info; +}; + +static grub_dl_t my_mod; + +static struct xen_boot_binary *xen_hypervisor; +static struct xen_boot_binary *module_head; +static const grub_size_t module_default_align[] = { +MODULE_IMAGE_MIN_ALIGN , +MODULE_INITRD_MIN_ALIGN , +MODULE_XSM_MIN_ALIGN , +MODULE_CUSTOM_MIN_ALIGN +}; + +static void *xen_boot_fdt; +static const compat_string_struct_t default_compat_string[] = { +FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_XSM_COMPATIBLE ), +FDT_COMPATIBLE (MODULE_CUSTOM_COMPATIBLE ) +}; + +static __inlinegrub_addr_t +xen_boot_address_align (grub_addr_t start,grub_size_t align) +{ +return (align ? (ALIGN_UP (start, align)) : start); +} + +/* Parse the option of xen_module command. For now, we support +(1) --type <the compatible stream> +We also set up the type of module in this function. +If there are some "--type" options in the command line, +we make a custom compatible stream in this function. */ +static grub_err_t +set_module_type (grub_command_t cmd,struct xen_boot_binary *module, +int argc,char *argv[],int *file_name_index) +{ +char **compat_string_temp_array; +grub_size_t total_size =0 ; +int num_types =0 , i; +char *temp =NULL ; + + *file_name_index =0 ; + +if (!grub_strcmp (cmd->name,"xen_linux" )) + module->node_info.type =MODULE_IMAGE ; +else if (!grub_strcmp (cmd->name,"xen_initrd" )) + module->node_info.type =MODULE_INITRD ; +else if (!grub_strcmp (cmd->name,"xen_xsm" )) + module->node_info.type =MODULE_XSM ; +else if (!grub_strcmp (cmd->name,"xen_module" )) + module->node_info.type =MODULE_CUSTOM ; + +/* if there are some options we need to process. */ +if (module->node_info.type ==MODULE_CUSTOM ) + { + compat_string_temp_array = + (char **)grub_zalloc (sizeof (char *) * argc); +if (!compat_string_temp_array) +return grub_errno; +/* the module type is set by "--type"(MODULE_CUSTOM) */ +while (argc >2 && !grub_strcmp (argv[0 ],"--type" )) + { + module->node_info.type =MODULE_CUSTOM ; +ARG_SHIFT (argc, argv); + total_size +=grub_strlen (argv[0 ]) +1 ; + compat_string_temp_array[num_types++] = argv[0 ]; +ARG_SHIFT (argc, argv); + (*file_name_index) +=2 ; + } + +if (total_size) + { + module->node_info.compat_string = temp = + (char *)grub_zalloc (total_size); +if (!temp) + { +grub_free (compat_string_temp_array); +return grub_errno; + } + + module->node_info.compat_string_size = total_size; +for (i =0 ; num_types >0 ; num_types--, i++, temp++) + { +grub_strcpy (temp, compat_string_temp_array[i]); + temp +=grub_strlen (compat_string_temp_array[i]); + } + } +else + { + module->node_info.compat_string = + default_compat_string[MODULE_CUSTOM ].compat_string; + module->node_info.compat_string_size = + default_compat_string[MODULE_CUSTOM ].size; + } + +grub_free (compat_string_temp_array); + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_hypervisor_params (void ) +{ +int chosen_node =0 ; +int retval; + + xen_boot_fdt =grub_linux_get_fdt (); +if (!xen_boot_fdt) +return grub_error (GRUB_ERR_IO ,"failed to get FDT" ); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_IO ,"failed to get chosen node in FDT" ); + +grub_dprintf ("xen_loader" , +"Xen Hypervisor cmdline : %s @ %p size:%d\n" , + xen_hypervisor->cmdline, xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); + + retval =grub_fdt_set_prop (xen_boot_fdt, chosen_node,"bootargs" , + xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); +if (retval) +return grub_error (GRUB_ERR_IO ,"failed to install/update FDT" ); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +prepare_xen_module_params (struct xen_boot_binary *module) +{ +int retval, chosen_node =0 , module_node =0 ; +char module_name[FDT_NODE_NAME_MAX_SIZE ]; + + retval =grub_snprintf (module_name,FDT_NODE_NAME_MAX_SIZE ,"module@%lx" , +xen_boot_address_align (module->start, + module->align)); +grub_dprintf ("xen_loader" ,"Module node name %s \n" , module_name); + +if (retval < (int )sizeof ("module@" )) +return grub_error (GRUB_ERR_IO ,N_ ("failed to get FDT" )); + + chosen_node =grub_fdt_find_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <0 ) + chosen_node =grub_fdt_add_subnode (xen_boot_fdt,0 ,"chosen" ); +if (chosen_node <1 ) +return grub_error (GRUB_ERR_IO ,"failed to get chosen node in FDT" ); + + module_node = +grub_fdt_find_subnode (xen_boot_fdt, chosen_node, module_name); +if (module_node <0 ) + module_node = +grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"compatible" , + module->node_info.compat_string, + (grub_uint32_t ) module-> + node_info.compat_string_size); +if (retval) +return grub_error (GRUB_ERR_IO ,N_ ("failed to update FDT" )); + +grub_dprintf ("xen_loader" ,"Module %s compatible = %s size = 0x%lx\n" , + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + retval =grub_fdt_set_reg64 (xen_boot_fdt, module_node, +xen_boot_address_align (module->start, + module->align), + module->size); +if (retval) +return grub_error (GRUB_ERR_IO ,N_ ("failed to update FDT" )); + +if (module->cmdline && module->cmdline_size >0 ) + { +grub_dprintf ("xen_loader" , +"Module %s cmdline : %s @ %p size:%d\n" , module->name, + module->cmdline, module->cmdline, module->cmdline_size); + + retval =grub_fdt_set_prop (xen_boot_fdt, module_node,"bootargs" , + module->cmdline, module->cmdline_size +1 ); +if (retval) +return grub_error (GRUB_ERR_IO ,"failed to update FDT" ); + } +else + { +grub_dprintf ("xen_loader" ,"Module %s has not bootargs!\n" , + module->name); + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +install_all_params (void ) +{ +grub_efi_guid_t fdt_guid =GRUB_EFI_DEVICE_TREE_GUID ; +grub_efi_boot_services_t *b; +grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; + status = b->install_configuration_table (&fdt_guid, xen_boot_fdt); +if (status !=GRUB_EFI_SUCCESS ) +return grub_error (GRUB_ERR_IO ,"failed to install FDT" ); + +grub_dprintf ("xen_loader" , +"Installed/updated FDT configuration table @ %p\n" , + xen_boot_fdt); + +return GRUB_ERR_NONE ; +} + +static grub_err_t +clean_all_params (void ) +{ +if (xen_boot_fdt) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) xen_boot_fdt, +BYTES_TO_PAGES (grub_fdt_get_totalsize + (xen_boot_fdt))); + xen_boot_fdt =NULL ; + } + +return GRUB_ERR_NONE ; +} + +static grub_err_t +finalize_params_xen_boot (void ) +{ +struct xen_boot_binary *module; + +if (xen_hypervisor) + { +if (prepare_xen_hypervisor_params () !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_loader" ,"Failed to get Xen Hypervisor info!\n" ); + goto fail; + } + +/* Set module params info */ + FOR_LIST_ELEMENTS (module, module_head) + { +if (module->start && module->size >0 ) + { +grub_dprintf ("xen_loader" ,"Module %s @ 0x%lx size:0x%lx\n" , + module->name, +xen_boot_address_align (module->start, module->align), + module->size); +if (prepare_xen_module_params (module) !=GRUB_ERR_NONE ) + goto fail; + } +else + { +grub_dprintf ("xen_loader" ,"Module info error: %s!\n" , module->name); + goto fail; + } + } + +if (install_all_params () ==GRUB_ERR_NONE ) +return GRUB_ERR_NONE ; + +fail: +clean_all_params (); + +return grub_error (GRUB_ERR_IO ,"failed to install/update FDT" ); +} + + +static grub_err_t +xen_boot (void ) +{ +grub_err_t err =finalize_params_xen_boot (); +if (err) +return err; + +return grub_arm64_uefi_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); +} + +static void +single_binary_unload (struct xen_boot_binary *binary) +{ +if (!binary) +return ; + +if (binary->start && binary->size >0 ) + { +grub_efi_free_pages ((grub_efi_physical_address_t ) binary->start, +BYTES_TO_PAGES (binary->size + binary->align)); + } + +if (binary->cmdline && binary->cmdline_size >0 ) + { +grub_free (binary->cmdline); +grub_dprintf ("xen_loader" , +"Module %s cmdline memory free @ %p size: %d\n" , + binary->name, binary->cmdline, binary->cmdline_size); + } + +if (binary->node_info.type ==MODULE_CUSTOM ) +grub_free ((void *) binary->node_info.compat_string); + +if (grub_strcmp (binary->name,XEN_HYPERVISOR_NAME )) +grub_list_remove (GRUB_AS_LIST (binary)); + +grub_dprintf ("xen_loader" , +"Module %s struct memory free @ %p size: 0x%lx\n" , + binary->name, binary,sizeof (binary)); +grub_free (binary); + +return ; +} + +static void +all_binaries_unload (void ) +{ +struct xen_boot_binary *binary; + + FOR_LIST_ELEMENTS (binary, module_head) + { +single_binary_unload (binary); + } + +if (xen_hypervisor) +single_binary_unload (xen_hypervisor); + +return ; +} + +static grub_err_t +xen_unload (void ) +{ +grub_linux_set_loaded (0 ); +all_binaries_unload (); +clean_all_params (); +grub_dl_unref (my_mod); + +return GRUB_ERR_NONE ; +} + +static void +xen_boot_binary_load (struct xen_boot_binary *binary,grub_file_t file, +int argc,char *argv[]) +{ + binary->size =grub_file_size (file); +grub_dprintf ("xen_loader" ,"Xen_boot %s file size: 0x%lx\n" , + binary->name, binary->size); + + binary->start = (grub_addr_t )grub_efi_allocate_pages (0 , + (BYTES_TO_PAGES + (binary->size + + binary->align))); +if (!binary->start) + { +grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +return ; + } + +grub_dprintf ("xen_loader" ,"Xen_boot %s numpages: 0x%lx\n" , + binary->name,BYTES_TO_PAGES (binary->size + binary->align)); + +if (grub_file_read (file, (void *)xen_boot_address_align (binary->start, + binary->align), + binary->size) != (grub_ssize_t ) binary->size) + { +single_binary_unload (binary); +grub_error (GRUB_ERR_BAD_OS ,N_ ("premature end of file %s" ), argv[0 ]); +return ; + } + +if (argc >1 ) + { + binary->cmdline_size =grub_loader_cmdline_size (argc -1 , argv +1 ); + binary->cmdline =grub_zalloc (binary->cmdline_size); +if (!binary->cmdline) + { +single_binary_unload (binary); +grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +return ; + } +grub_create_loader_cmdline (argc -1 , argv +1 , binary->cmdline, + binary->cmdline_size); +grub_dprintf ("xen_loader" , +"Xen_boot %s cmdline @ %p %s, size: %d\n" , binary->name, + binary->cmdline, binary->cmdline, binary->cmdline_size); + } +else + { + binary->cmdline_size =0 ; + binary->cmdline =NULL ; + } + + grub_errno =GRUB_ERR_NONE ; +return ; +} + +static grub_err_t +grub_cmd_xen_module (grub_command_t cmd,int argc,char *argv[]) +{ + +struct xen_boot_binary *module =NULL ; +int file_name_index =0 ; +grub_file_t file =0 ; + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail; + } + +if (!grub_linux_get_loaded ()) + { +grub_error (GRUB_ERR_BAD_ARGUMENT , +N_ ("you need to load the Xen Hypervisor first" )); + goto fail; + } + + module = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!module) +return grub_errno; + +/* process all the options and get module type */ +if (set_module_type (cmd, module, argc, argv, &file_name_index) != +GRUB_ERR_NONE ) + goto fail; +switch (module->node_info.type) + { +case MODULE_IMAGE : +case MODULE_INITRD : +case MODULE_XSM : + module->node_info.compat_string = + default_compat_string[module->node_info.type].compat_string; + module->node_info.compat_string_size = + default_compat_string[module->node_info.type].size; +break ; + +case MODULE_CUSTOM : +/* we have set the node_info in set_module_type */ +break ; + +default : +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("invalid argument" )); + } + module->name = module->node_info.compat_string; + module->align = module_default_align[module->node_info.type]; + +grub_dprintf ("xen_loader" ,"Init %s module and node info:\n" +"compatible %s\ncompat_string_size 0x%lx\n" , + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + file =grub_file_open (argv[file_name_index]); +if (!file) + goto fail; + +xen_boot_binary_load (module, file, argc - file_name_index, + argv + file_name_index); +if (grub_errno ==GRUB_ERR_NONE ) +grub_list_push (GRUB_AS_LIST_P (&module_head),GRUB_AS_LIST (module)); + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) +single_binary_unload (module); + +return grub_errno; +} + +static grub_err_t +grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), +int argc,char *argv[]) +{ +struct xen_hypervisor_header sh; +grub_file_t file =NULL ; + +grub_dl_ref (my_mod); + +if (!argc) + { +grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("filename expected" )); + goto fail; + } + + file =grub_file_open (argv[0 ]); +if (!file) + goto fail; + +if (grub_file_read (file, &sh,sizeof (sh)) != (long )sizeof (sh)) + goto fail; +if (grub_arm64_uefi_check_image + ((struct grub_arm64_linux_kernel_header *) &sh) !=GRUB_ERR_NONE ) + goto fail; +grub_file_seek (file,0 ); + +/* if another module has called grub_loader_set, +we need to make sure that another module is unloaded properly */ +grub_loader_unset (); + + xen_hypervisor = + (struct xen_boot_binary *)grub_zalloc (sizeof (struct xen_boot_binary )); +if (!xen_hypervisor) +return grub_errno; + + xen_hypervisor->name =XEN_HYPERVISOR_NAME ; + xen_hypervisor->align = (grub_size_t ) sh.optional_header.section_alignment; + +xen_boot_binary_load (xen_hypervisor, file, argc, argv); +if (grub_errno ==GRUB_ERR_NONE ) + { +grub_loader_set (xen_boot, xen_unload,0 ); +grub_linux_set_loaded (1 ); + } + +fail: +if (file) +grub_file_close (file); +if (grub_errno !=GRUB_ERR_NONE ) + { +grub_linux_set_loaded (0 ); +all_binaries_unload (); +grub_dl_unref (my_mod); + } + +return grub_errno; +} + +static grub_command_t cmd_xen_hypervisor, cmd_xen_module; +static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm; + +GRUB_MOD_INIT (xen_boot) +{ + cmd_xen_hypervisor = +grub_register_command ("xen_hypervisor" , grub_cmd_xen_hypervisor,0 , +N_ ("Load a xen hypervisor." )); + cmd_xen_linux = +grub_register_command ("xen_linux" , grub_cmd_xen_module,0 , +N_ ("Load a xen linux kernel for dom0." )); + cmd_xen_initrd = +grub_register_command ("xen_initrd" , grub_cmd_xen_module,0 , +N_ ("Load a xen initrd for dom0." )); + cmd_xen_xsm = +grub_register_command ("xen_xsm" , grub_cmd_xen_module,0 , +N_ ("Load a xen security module." )); + cmd_xen_module = +grub_register_command ("xen_module" , grub_cmd_xen_module,0 , +N_ ("Load a xen module." )); + my_mod = mod; +} + +GRUB_MOD_FINI (xen_boot)Quoted 10 lines
grub-core/loader/arm64/xen_boot.c line 685
Quoted 8 lines
grub-core/loader/arm64/xen_boot.c new file +7
-0+{ +grub_unregister_command (cmd_xen_hypervisor); +grub_unregister_command (cmd_xen_linux); +grub_unregister_command (cmd_xen_initrd); +grub_unregister_command (cmd_xen_xsm); +grub_unregister_command (cmd_xen_module); +}--
Best regards,Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Signature · 15 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v3 2/4] arm64: Add xen_boot module file
Quoted 7 lines · Fu Wei
Hi Vladimir,
After discussing with Ian Campbell, Since we already can load all the necessary binaries for Xen boot on arm64 for now, we don't really need "
xen_module" command now.
But maybe someday , xen need a new type of binary in boot time, then we still need this support.
You mean support for "--type" passed to the xen_module command, right? I thought the xen_module stuff had been applied. Or am I misunderstanding which bits have been applied?
Quoted 2 lines
So I will submit a "xen_module" command patch soon, in case we need it.
Just to clarify, my suggestion was to repost the bits which were omitted from the prior patches just so that they are available in the ML archives etc should anyone ever want to resurrect them in the future.
Ian.
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v3 2/4] arm64: Add xen_boot module file
Hi Ian,
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Fu Wei
Hi Vladimir,
After discussing with Ian Campbell, Since we already can load all
the necessary binaries for Xen boot on arm64 for now, we don't really need "xen_module" command now.
But maybe someday , xen need a new type of binary in boot time, then we still need this support.
Quoted 3 lines
You mean support for "--type" passed to the
xen_modulecommand, right? I thought thexen_modulestuff had been applied. Or am I misunderstanding which bits have been applied?
Actually, I mean: xen-module command is for "--type" support. If we don't need "--type" now, we can delete xen-module code(which has been deleted by Vladimir from my patch, so now, the upstream grub has not --type support).
Vladimir has applied most of my patch, except xen-module command code.
Quoted 7 lines
Quoted 3 lines
So I will submit a "
xen_module" command patch soon, in case we need
it.Just to clarify, my suggestion was to repost the bits which were omitted from the prior patches just so that they are available in the ML archives etc should anyone ever want to resurrect them in the future.
yes, that is what I am gonna do.
Quoted 3 lines
Ian.
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
PATCH v3 3/4 * util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
In reply to [email protected]From: Fu Wei <[email protected]>
This patch adds the support of boot command on aarch64 for XEN:
xen_hypervisor
xen_linux
xen_initrd
--- util/grub.d/20_linux_xen.in | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
util/grub.d/20_linux_xen.in +13 -3
@@ -120,16 +120,16 @@ linux_entry () else xen_rm_opts="no-real-mode edd=off" fi - multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} + ${multiboot_cmd} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} echo '$(echo "$lmessage" | grub_quote)' - module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} + ${module_linux_cmd} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - module --nounzip ${rel_dirname}/${initrd} + ${module_initrd_cmd} ${rel_dirname}/${initrd} EOF fi sed "s/^/$submenu_indentation/" << EOF
@@ -185,6 +185,16 @@ case "$machine" in *) GENKERNEL_ARCH="$machine" ;; esac +if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_linux_cmd="module" + module_initrd_cmd="module --nounzip" +else + multiboot_cmd="xen_hypervisor" + module_linux_cmd="xen_linux" + module_initrd_cmd="xen_initrd" +fi + # Extra indentation to add to menu entries in a submenu. We're not in a submenu # yet, so it's empty. In a submenu it will be equal to '\t' (one tab). submenu_indentation=""
Signature · 1 line
1.8.3.1
Re: [PATCH v3 3/4] * util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
util/grub.d/20_linux_xen.in case "$machine" in · line 197
Quoted 10 lines
util/grub.d/20_linux_xen.in +10
-0+if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_linux_cmd="module" + module_initrd_cmd="module --nounzip" +else + multiboot_cmd="xen_hypervisor" + module_linux_cmd="xen_linux" + module_initrd_cmd="xen_initrd" +fi +
Please do not hardcode an assumption that grub-mkconfig is executed on the same machine as GRUB is booted. I know that we have instances of such assumption in some cases but we'd like to eliminate them. Alternatives:
- Check arch on boot time
- Check that new xen commands are supported (define a new feature) Please add xen_* aliases on x86 as well
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 3/4] * util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
29.10.2015 18:25, Vladimir 'φ-coder/phcoder' Serbinenko пишет:
Quoted 6 lines
Quoted 6 lines
util/grub.d/20_linux_xen.in +6
-0+if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_linux_cmd="module" + module_initrd_cmd="module --nounzip" +else + multiboot_cmd="xen_hypervisor"
Quoted 8 lines
util/grub.d/20_linux_xen.in case "$machine" in · line 197
Quoted 4 lines
util/grub.d/20_linux_xen.in +4
-0+ module_linux_cmd="xen_linux" + module_initrd_cmd="xen_initrd" +fi +Please do not hardcode an assumption that grub-mkconfig is executed on the same machine as GRUB is booted. I know that we have instances of such assumption in some cases but we'd like to eliminate them. Alternatives:
- Check arch on boot time
This makes it even more difficult for os-prober to parse grub.cfg. We need some alternative before going this route.
Quoted 4 lines
- Check that new xen commands are supported (define a new feature) Please add xen_* aliases on x86 as well
Yes, that's better.
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v3 3/4] * util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
In reply to Vladimir 'φ-coder/phcoder' SerbinenkoHi Vladimir,
Great thanks for your suggestion! :-)
Quoted 16 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Review
Quoted 10 lines
(quoted diff) +10
-0+if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_linux_cmd="module" + module_initrd_cmd="module --nounzip" +else + multiboot_cmd="xen_hypervisor" + module_linux_cmd="xen_linux" + module_initrd_cmd="xen_initrd" +fi +Please do not hardcode an assumption that grub-mkconfig is executed on the same machine as GRUB is booted. I know that we have instances of such assumption in some cases but we'd like to eliminate them. Alternatives:
- Check arch on boot time
Quoted 2 lines
- Check that new xen commands are supported (define a new feature) Please add xen_* aliases on x86 as well
I would like to go this way, but could you provide some help or a little example for :
(1) How to check the new xen commands(or xen_boot module) (2)add xen_* aliases on x86, is that like something below?
grub-core/loader/i386/xen.c +4 -0
@@ -696,10 +696,14 @@ GRUB_MOD_INIT (xen) 0, N_("Load Linux.")); cmd_multiboot =grub_register_command ("multiboot" , grub_cmd_xen,0 ,N_ ("Load Linux." )); + cmd_multiboot =grub_register_command ("xen_hypervisor" , grub_cmd_xen, +0 ,N_ ("Load Linux." )); cmd_initrd =grub_register_command ("initrd" , grub_cmd_initrd,0 ,N_ ("Load initrd." )); cmd_module =grub_register_command ("module" , grub_cmd_module,0 ,N_ ("Load module." )); + cmd_module =grub_register_command ("xen_linux" , grub_cmd_module, +0 ,N_ ("Load module." )); my_mod = mod; }
But how to deal with xen_initrd ?
Could you help me ?
Great thanks !!
Quoted 2 lines
Signature · 15 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v3 3/4] * util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
Quoted 22 lines · Fu Wei
Hi Vladimir,
Great thanks for your suggestion! :-)
Quoted 14 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Review
Quoted 10 lines
(quoted diff) +10
-0+if [ "x$machine" != xaarch64 ]; then + multiboot_cmd="multiboot" + module_linux_cmd="module" + module_initrd_cmd="module --nounzip" +else + multiboot_cmd="xen_hypervisor" + module_linux_cmd="xen_linux" + module_initrd_cmd="xen_initrd" +fi +Please do not hardcode an assumption that grub-mkconfig is executed on the same machine as GRUB is booted. I know that we have instances of such assumption in some cases but we'd like to eliminate them. Alternatives:
- Check arch on boot time
Quoted 7 lines
Quoted 2 lines
- Check that new xen commands are supported (define a new feature) Please add xen_* aliases on x86 as well
I would like to go this way, but could you provide some help or a little example for :
(1) How to check the new xencommands(or xen_boot module)(2)add xen_* aliases on x86, is that like something below?
see grub-core/normal/main.c the features array.
Quoted 19 lines
grub-core/loader/i386/xen.c +4
-0@@ -696,10 +696,14 @@ GRUB_MOD_INIT (xen) 0, N_("Load Linux.")); cmd_multiboot =grub_register_command ("multiboot" , grub_cmd_xen,0 ,N_ ("Load Linux." )); + cmd_multiboot =grub_register_command ("xen_hypervisor" , grub_cmd_xen, +0 ,N_ ("Load Linux." )); cmd_initrd =grub_register_command ("initrd" , grub_cmd_initrd,0 ,N_ ("Load initrd." )); cmd_module =grub_register_command ("module" , grub_cmd_module,0 ,N_ ("Load module." )); + cmd_module =grub_register_command ("xen_linux" , grub_cmd_module, +0 ,N_ ("Load module." )); my_mod = mod; }
Quoted 3 lines
But how to deal with
xen_initrd?
Could you help me ?
Just another alias to module. Possibly you might want to add a code to xen_initrd tto check that xen_linux was already run
Quoted 7 lines
Great thanks !!
Quoted 2 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v3 3/4] * util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 4 lines
But how to deal with
xen_initrd?
Could you help me ?Just another alias to module. Possibly you might want to add a code to
xen_initrdtto check thatxen_linuxwas already run
I think we need to be careful here. We need to think about future extenstions (in particular to other architectures) and options handling. E.g. initrd never accepted any option and we cannot really add one probably now; but xen_initrd did IIRC (or may be I was mistaken with xen_module). What I mean, we should allow additional options from the very beginning, not just making it exact alias.
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
A message that is not in the archive (sent off-list or not yet received): CAEaD8JOHR9QXa=ySc36a-ECF-7MUBgvaSVFw_BZxrXrvZA5u_A@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAA91j0XKvpgVVWuv79AEv6bguxrQrV4q+eG5Xtw+UBvMSmDF-w@mail.gmail.com
Re: [PATCH v3 3/4] * util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
Quoted 11 lines · Andrei Borzenkov
Not really, although this is a good observation. Actually I think that
xen_initrdshould indeed have behavior 1, because what it does is provide initrd image to Linux kernel, and - although not often used - initrd image may be constructed by concatenation.But what I meant - initially it was intended to have
xen_modulewith some options. As soon as we add option parsing we must have defined way to differentiate between opption forxen_moduleitself and option for module loaded byxen_module. I.e. it should be possible to
xen_module--type=XXX some-module --option1=FOO --option2=bar
Yes, everything before the filename would be an option to command itself. We have a similar thing with multiboot command. Currently there are no options to xen_*, so no code to handle them. But it's impossible to get any confusion as if you currently specify any of such future options you'll get an error of bad file, so we won't break any compatibility. Do you see any reason to introduce flag-handling code now? Would it be for better error message?
PATCH v3 4/4 arm64: Add the introduction of xen boot commands in docs/grub.texi
In reply to [email protected]From: Fu Wei <[email protected]>
xen_hypervisor
xen_linux
xen_initrd
xen_xsm
xen_module
--- docs/grub.texi | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
docs/grub.texi +56 -0
@@ -3839,6 +3839,12 @@ you forget a command, you can run the command @command{help} @comment * vbeinfo:: List available video modes * verify_detached:: Verify detached digital signature * videoinfo:: List available video modes +@comment * xen_*:: Xen boot commands, for arm64 only +* xen_hypervisor:: Load xen hypervisor binary on arm64 +* xen_linux:: Load dom0 kernel for xen hypervisor on arm64 +* xen_initrd:: Load dom0 initrd for xen hypervisor on arm64 +* xen_xsm:: Load xen security module for xen hypervisor on arm64 +* xen_module:: Load custom module for xen hypervisor on arm64 @end menu
@@ -5102,6 +5108,56 @@ successfully. If validation fails, it is set to a non-zero value. List available video modes. If resolution is given, show only matching modes. @end deffn +@node xen_hypervisor +@subsection xen_hypervisor + +@deffn Command xen_hypervisor file [arguments] @dots{} +Load a Xen hypervisor binary from @var{file}. The rest of the +line is passed verbatim as the @dfn{kernel command-line}. Any Xen module must +be reloaded after using this command (@pxref{xen_module}). +This command is only available on ARM64 systems. +@end deffn + +@node xen_linux +@subsection xen_linux + +@deffn Command xen_linux file [arguments] +Load a dom0 kernel image for xen hypervisor binary. The rest of the +line is passed verbatim as the module command line. +This command is only available on ARM64 systems. +@end deffn + +@node xen_initrd +@subsection xen_initrd + +@deffn Command xen_initrd file +Load a dom0 initrd image for xen hypervisor binary. +This command is only available on ARM64 systems. +@end deffn + +@node xen_xsm +@subsection xen_xsm + +@deffn Command xen_xsm file +Load a xen security module for xen hypervisor binary. +This command is only available on ARM64 systems. +@end deffn + + +@node xen_module +@subsection xen_module + +@deffn Command xen_module [--type <compatible stream>] file [arguments] +Load a custom module for xen hypervisor binary. The rest of the +line is passed verbatim as the module command line. +This command is only available on ARM64 systems. + +--type is an option which allow the module command to take "compatible" string. +This would override default compatible string:"xen,module". The rest of the +line is passed verbatim as the module command line. +This command is only available on ARM64 systems. +@end deffn + @node Networking commands @section The list of networking commands
Signature · 1 line
1.8.3.1
Re: [PATCH v3 0/4] arm64: Add Xen boot support (via fdt)
In reply to [email protected]Hi Vladimir,
this patchset follows all your comment of v2 patchset. Do you have any suggestion on this patchset?
Great thanks for your help.
Quoted 59 lines · On 23 July 2015 at 13:16, <[email protected]> wrote:
From: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
- Add and export some accessor functions of "loaded" flag and
grub_linux_get_fdtfunction ininclude/grub/arm64/linux.hfor xen boot.- Introduce
xen_hypervisor,xen_linux,xen_initrdandxen_xsmto load different binaries for xen boot.
Introducexen_moduleto load common or custom module for xen boot.- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.
- Add the support of
xen_hypervisor,xen_linuxandxen_initrdin util/grub.d/20_linux_xen.in- Add the introduction of all xen boot commands in docs/grub.texi
- The example of this support is <How to boot Xen with GRUB on AArch64 the Foundation FVP model>
https://wiki.linaro.org/LEG/Engineering/Grub2/Xen_booting_on_Foundation_FVP_model_by_GRUBChangelog:
v3: create separate module for xen boot:xen_boot
create separate commands for different types of module delete order-dependent for commands of xen module simplify the codev2: remove the patches which have been accepted.
according to Vladimir's suggestion, change the command manes and relevant code:
multiboot-->xen_hypervisor
module-->xen_module
improve the option parsing support for xen_hypervisor/xen_module commands. add a patch for adding xen_hypervisor/xen_module support
in util/grub.d/20_linux_xen.in.
update docs/grub.texi patch for the new command names.v1: The first version upstream patchset to grub-devel mailing list
Fu Wei (4):
arm64: Add and export some accessor functions for xen boot
arm64: Addxen_bootmodule file
* util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
arm64: Add the introduction of xen boot commands in docs/grub.texidocs/grub.texi | 56 ++++ grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/linux.c | 13 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/linux.h | 6 +- util/grub.d/20_linux_xen.in | 16 +- 6 files changed, 779 insertions(+), 4 deletions(-) create mode 100644 grub-core/loader/arm64/xen_boot.c--
1.8.3.1
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v3 0/4] arm64: Add Xen boot support (via fdt)
Hi Vladimir,
Do you have any suggestion on this patchset? Do I need to improve anything?
Great thanks for your help.
Quoted 82 lines · Fu Wei
Hi Vladimir,
this patchset follows all your comment of v2 patchset. Do you have any suggestion on this patchset?
Great thanks for your help.
Quoted 56 lines · On 23 July 2015 at 13:16, <[email protected]> wrote:
From: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
- Add and export some accessor functions of "loaded" flag and
grub_linux_get_fdtfunction ininclude/grub/arm64/linux.hfor xen boot.- Introduce
xen_hypervisor,xen_linux,xen_initrdandxen_xsmto load different binaries for xen boot.
Introducexen_moduleto load common or custom module for xen boot.- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.
- Add the support of
xen_hypervisor,xen_linuxandxen_initrdin util/grub.d/20_linux_xen.in- Add the introduction of all xen boot commands in docs/grub.texi
- The example of this support is <How to boot Xen with GRUB on AArch64 the Foundation FVP model>
https://wiki.linaro.org/LEG/Engineering/Grub2/Xen_booting_on_Foundation_FVP_model_by_GRUBChangelog:
v3: create separate module for xen boot:xen_boot
create separate commands for different types of module delete order-dependent for commands of xen module simplify the codev2: remove the patches which have been accepted.
according to Vladimir's suggestion, change the command manes and relevant code:
multiboot-->xen_hypervisor
module-->xen_module
improve the option parsing support for xen_hypervisor/xen_module commands. add a patch for adding xen_hypervisor/xen_module support
in util/grub.d/20_linux_xen.in.
update docs/grub.texi patch for the new command names.v1: The first version upstream patchset to grub-devel mailing list
Fu Wei (4):
arm64: Add and export some accessor functions for xen boot
arm64: Addxen_bootmodule file
* util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
arm64: Add the introduction of xen boot commands in docs/grub.texidocs/grub.texi | 56 ++++ grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/linux.c | 13 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/linux.h | 6 +- util/grub.d/20_linux_xen.in | 16 +- 6 files changed, 779 insertions(+), 4 deletions(-) create mode 100644 grub-core/loader/arm64/xen_boot.cQuoted 3 lines
--
1.8.3.1--
Best regards,Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v3 0/4] arm64: Add Xen boot support (via fdt)
Hi Fu,
I backported your patches to the CentOS aarch64 grub2 rpm. I am testing it on X-Gene with EFI firmware. It works fine when booting Xen, but booting native kernels (no Xen) doesn't work anymore. Grub prints
error: out of memory.
Press any key to continue...
grub is still able to continue and load Linux, but then the kernel fails to boot with "Cannot open root device", even though the grub config is still same as before and the rootfs (which is xfs) hasn't changed. Reverting the patches solved the problem.
Do you have any ideas on what is causing the issue? Maybe the initramfs hasn't been properly loaded?
Thanks,
Stefano
Quoted 105 lines · Fu Wei
Hi Vladimir,
Do you have any suggestion on this patchset? Do I need to improve anything?
Great thanks for your help.
Quoted 82 lines · Fu Wei
Hi Vladimir,
this patchset follows all your comment of v2 patchset. Do you have any suggestion on this patchset?
Great thanks for your help.
Quoted 56 lines · On 23 July 2015 at 13:16, <[email protected]> wrote:
From: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
- Add and export some accessor functions of "loaded" flag and
grub_linux_get_fdtfunction ininclude/grub/arm64/linux.hfor xen boot.- Introduce
xen_hypervisor,xen_linux,xen_initrdandxen_xsmto load different binaries for xen boot.
Introducexen_moduleto load common or custom module for xen boot.- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.
- Add the support of
xen_hypervisor,xen_linuxandxen_initrdin util/grub.d/20_linux_xen.in- Add the introduction of all xen boot commands in docs/grub.texi
- The example of this support is <How to boot Xen with GRUB on AArch64 the Foundation FVP model>
https://wiki.linaro.org/LEG/Engineering/Grub2/Xen_booting_on_Foundation_FVP_model_by_GRUBChangelog:
v3: create separate module for xen boot:xen_boot
create separate commands for different types of module delete order-dependent for commands of xen module simplify the codev2: remove the patches which have been accepted.
according to Vladimir's suggestion, change the command manes and relevant code:
multiboot-->xen_hypervisor
module-->xen_module
improve the option parsing support for xen_hypervisor/xen_module commands. add a patch for adding xen_hypervisor/xen_module support
in util/grub.d/20_linux_xen.in.
update docs/grub.texi patch for the new command names.v1: The first version upstream patchset to grub-devel mailing list
Fu Wei (4):
arm64: Add and export some accessor functions for xen boot
arm64: Addxen_bootmodule file
* util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
arm64: Add the introduction of xen boot commands in docs/grub.texidocs/grub.texi | 56 ++++ grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/linux.c | 13 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/linux.h | 6 +- util/grub.d/20_linux_xen.in | 16 +- 6 files changed, 779 insertions(+), 4 deletions(-) create mode 100644 grub-core/loader/arm64/xen_boot.cQuoted 3 lines
--
1.8.3.1--
Best regards,Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v3 0/4] arm64: Add Xen boot support (via fdt)
Quoted 10 lines · Stefano Stabellini
Hi Fu,
I backported your patches to the CentOS aarch64 grub2 rpm. I am testing it on X-Gene with EFI firmware. It works fine when booting Xen, but booting native kernels (no Xen) doesn't work anymore. Grub prints
error: out of memory.
Press any key to continue...
Quoted 7 lines
grub is still able to continue and load Linux, but then the kernel fails to boot with "Cannot open root device", even though the grub config is still same as before and the rootfs (which is xfs) hasn't changed. Reverting the patches solved the problem.
Do you have any ideas on what is causing the issue? Maybe the initramfs hasn't been properly loaded?
It looks like the following chunk of commit f8451af8251a3866cb8b7307b9917dd5d34fbd0a "arm64: Export useful functions from linux.c" causes troubles:
grub-core/loader/linux.c +2 -1
@@ -205,7 +205,8 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->nfiles++; initrd_ctx->components[i].size =grub_file_size (initrd_ctx->components[i].file); - initrd_ctx->size +=ALIGN_UP (initrd_ctx->components[i].size,4 ); +if (argc !=1 ) + initrd_ctx->size +=ALIGN_UP (initrd_ctx->components[i].size,4 ); }if (newc)
Simply removing this change seems to fix the issue and Xen still boots fine.
Re: [PATCH v3 0/4] arm64: Add Xen boot support (via fdt)
Hi Stefano,
Sorry for late response, I will try to test my latest patch ASAP. but I don't see this problem before.
will let you know the result , thanks for your testing
Quoted 42 lines · Stefano Stabellini
Quoted 10 lines · Stefano Stabellini
Hi Fu,
I backported your patches to the CentOS aarch64 grub2 rpm. I am testing it on X-Gene with EFI firmware. It works fine when booting Xen, but booting native kernels (no Xen) doesn't work anymore. Grub prints
error: out of memory.
Press any key to continue...
Quoted 7 lines
grub is still able to continue and load Linux, but then the kernel fails to boot with "Cannot open root device", even though the grub config is still same as before and the rootfs (which is xfs) hasn't changed. Reverting the patches solved the problem.
Do you have any ideas on what is causing the issue? Maybe the initramfs hasn't been properly loaded?
It looks like the following chunk of commit
f8451af8251a3866cb8b7307b9917dd5d34fbd0a"arm64: Export useful functions fromlinux.c" causes troubles:grub-core/loader/linux.c +2
-1@@ -205,7 +205,8 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->nfiles++; initrd_ctx->components[i].size =grub_file_size (initrd_ctx->components[i].file); - initrd_ctx->size +=ALIGN_UP (initrd_ctx->components[i].size,4 ); +if (argc !=1 ) + initrd_ctx->size +=ALIGN_UP (initrd_ctx->components[i].size,4 ); }if (newc)Simply removing this change seems to fix the issue and Xen still boots fine.
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v3 0/4] arm64: Add Xen boot support (via fdt)
In reply to Stefano StabelliniHi Stefano,
I have tried my grub on Foundation model, but I did not get this error, I guess that is the UEFI problem ?
Quoted 130 lines · Stefano Stabellini
Hi Fu,
I backported your patches to the CentOS aarch64 grub2 rpm. I am testing it on X-Gene with EFI firmware. It works fine when booting Xen, but booting native kernels (no Xen) doesn't work anymore. Grub prints
error: out of memory.
Press any key to continue...
grub is still able to continue and load Linux, but then the kernel fails to boot with "Cannot open root device", even though the grub config is still same as before and the rootfs (which is xfs) hasn't changed. Reverting the patches solved the problem.
Do you have any ideas on what is causing the issue? Maybe the initramfs hasn't been properly loaded?
Thanks,
Stefano
Quoted 105 lines · Fu Wei
Hi Vladimir,
Do you have any suggestion on this patchset? Do I need to improve anything?
Great thanks for your help.
Quoted 74 lines · Fu Wei
Hi Vladimir,
this patchset follows all your comment of v2 patchset. Do you have any suggestion on this patchset?
Great thanks for your help.
Quoted 56 lines · On 23 July 2015 at 13:16, <[email protected]> wrote:
From: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
- Add and export some accessor functions of "loaded" flag and
grub_linux_get_fdtfunction ininclude/grub/arm64/linux.hfor xen boot.- Introduce
xen_hypervisor,xen_linux,xen_initrdandxen_xsmto load different binaries for xen boot.
Introducexen_moduleto load common or custom module for xen boot.- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.
- Add the support of
xen_hypervisor,xen_linuxandxen_initrdin util/grub.d/20_linux_xen.in- Add the introduction of all xen boot commands in docs/grub.texi
- The example of this support is <How to boot Xen with GRUB on AArch64 the Foundation FVP model>
https://wiki.linaro.org/LEG/Engineering/Grub2/Xen_booting_on_Foundation_FVP_model_by_GRUBChangelog:
v3: create separate module for xen boot:xen_boot
create separate commands for different types of module delete order-dependent for commands of xen module simplify the codev2: remove the patches which have been accepted.
according to Vladimir's suggestion, change the command manes and relevant code:
multiboot-->xen_hypervisor
module-->xen_module
improve the option parsing support for xen_hypervisor/xen_module commands. add a patch for adding xen_hypervisor/xen_module support
in util/grub.d/20_linux_xen.in.
update docs/grub.texi patch for the new command names.v1: The first version upstream patchset to grub-devel mailing list
Fu Wei (4):
arm64: Add and export some accessor functions for xen boot
arm64: Addxen_bootmodule file
* util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
arm64: Add the introduction of xen boot commands in docs/grub.texidocs/grub.texi | 56 ++++ grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/linux.c | 13 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/linux.h | 6 +- util/grub.d/20_linux_xen.in | 16 +- 6 files changed, 779 insertions(+), 4 deletions(-) create mode 100644 grub-core/loader/arm64/xen_boot.cQuoted 3 lines
--
1.8.3.1--
Best regards,Quoted 8 lines
Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021--
Best regards,Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v3 0/4] arm64: Add Xen boot support (via fdt)
Yes, it happens when booting from grub from UEFI firmware: I tested it on X-Gene.
Cheers,
Stefano
Quoted 152 lines · Fu Wei
Hi Stefano,
I have tried my grub on Foundation model, but I did not get this error, I guess that is the UEFI problem ?
Quoted 130 lines · Stefano Stabellini
Hi Fu,
I backported your patches to the CentOS aarch64 grub2 rpm. I am testing it on X-Gene with EFI firmware. It works fine when booting Xen, but booting native kernels (no Xen) doesn't work anymore. Grub prints
error: out of memory.
Press any key to continue...
grub is still able to continue and load Linux, but then the kernel fails to boot with "Cannot open root device", even though the grub config is still same as before and the rootfs (which is xfs) hasn't changed. Reverting the patches solved the problem.
Do you have any ideas on what is causing the issue? Maybe the initramfs hasn't been properly loaded?
Thanks,
Stefano
Quoted 105 lines · Fu Wei
Hi Vladimir,
Do you have any suggestion on this patchset? Do I need to improve anything?
Great thanks for your help.
Quoted 74 lines · Fu Wei
Hi Vladimir,
this patchset follows all your comment of v2 patchset. Do you have any suggestion on this patchset?
Great thanks for your help.
Quoted 56 lines · On 23 July 2015 at 13:16, <[email protected]> wrote:
From: Fu Wei <[email protected]>
- This adds support for the Xen boot on ARM specification for arm64.
- Add and export some accessor functions of "loaded" flag and
grub_linux_get_fdtfunction ininclude/grub/arm64/linux.hfor xen boot.- Introduce
xen_hypervisor,xen_linux,xen_initrdandxen_xsmto load different binaries for xen boot.
Introducexen_moduleto load common or custom module for xen boot.- This Xen boot support is a separated module for aarch64, but reuse the existing code of devicetree in linux module.
- Add the support of
xen_hypervisor,xen_linuxandxen_initrdin util/grub.d/20_linux_xen.in- Add the introduction of all xen boot commands in docs/grub.texi
- The example of this support is <How to boot Xen with GRUB on AArch64 the Foundation FVP model>
https://wiki.linaro.org/LEG/Engineering/Grub2/Xen_booting_on_Foundation_FVP_model_by_GRUBChangelog:
v3: create separate module for xen boot:xen_boot
create separate commands for different types of module delete order-dependent for commands of xen module simplify the codev2: remove the patches which have been accepted.
according to Vladimir's suggestion, change the command manes and relevant code:
multiboot-->xen_hypervisor
module-->xen_module
improve the option parsing support for xen_hypervisor/xen_module commands. add a patch for adding xen_hypervisor/xen_module support
in util/grub.d/20_linux_xen.in.
update docs/grub.texi patch for the new command names.v1: The first version upstream patchset to grub-devel mailing list
Fu Wei (4):
arm64: Add and export some accessor functions for xen boot
arm64: Addxen_bootmodule file
* util/grub.d/20_linux_xen.in: Add support of the XEN boot on aarch64
arm64: Add the introduction of xen boot commands in docs/grub.texidocs/grub.texi | 56 ++++ grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/linux.c | 13 + grub-core/loader/arm64/xen_boot.c | 685 ++++++++++++++++++++++++++++++++++++++ include/grub/arm64/linux.h | 6 +- util/grub.d/20_linux_xen.in | 16 +- 6 files changed, 779 insertions(+), 4 deletions(-) create mode 100644 grub-core/loader/arm64/xen_boot.cQuoted 3 lines
--
1.8.3.1--
Best regards,Quoted 8 lines
Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021--
Best regards,Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
PATCH 1/1 acpi, apei, arm64: APEI initial support for aarch64.
In reply to a message not in the archiveFrom: Tomasz Nowicki <[email protected]>
This commit provides APEI arch-specific bits for aarch64
Changelog:
Fu Wei:
Move arch_apei_flush_tlb_one() to arch/arm64/include/asm/apci.h. Delete arch/arm64/kernel/apei.c.
Add "#ifdef CONFIG_ACPI_APEI" for "acpi_disable_cmcff".
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/acpi.h | 11 +++++++++++ arch/arm64/kernel/acpi.c | 4 ++++ 3 files changed, 16 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -3,6 +3,7 @@ config ARM64 select ACPI_CCA_REQUIRED if ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI + select HAVE_ACPI_APEI if ACPI select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALL
arch/arm64/include/asm/acpi.h +11 -0
@@ -22,6 +22,7 @@#ifdef CONFIG_ACPI_APEI #include <linux/efi.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #endif /* Macros for consistency checks of the GICC subtable of MADT */
@@ -52,6 +53,9 @@ typedef u64 phys_cpuid_t;extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +extern int acpi_disable_cmcff; +#endif static inline void disable_acpi (void ) {
@@ -89,6 +93,13 @@ static inline bool acpi_has_cpu_in_madt(void)static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void ); +#ifdef CONFIG_ACPI_APEI +static inline void arch_apei_flush_tlb_one (unsigned long addr) +{ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); +} +#endif +#else static inline void acpi_init_cpus (void ) { }#endif /* CONFIG_ACPI */
arch/arm64/kernel/acpi.c +4 -0
@@ -36,6 +36,10 @@ EXPORT_SYMBOL(acpi_disabled);int acpi_pci_disabled =1 ;/* skip ACPI PCI scan and IRQ initialization */ EXPORT_SYMBOL (acpi_pci_disabled); +#ifdef CONFIG_ACPI_APEI +int acpi_disable_cmcff; +#endif +static bool param_acpi_off__initdata ;static bool param_acpi_force__initdata ;
Signature · 1 line
1.9.1
Re: [PATCH] acpi, apei, arm64: APEI initial support for aarch64.
Hi all,
This patch depends on https://lkml.org/lkml/2015/8/8/169
[PATCH V11 4/5] arm64: apei: implement arch_apei_get_mem_attributes(), which has been in the "next" branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git
FYI
Thanks
Quoted 84 lines · On 14 August 2015 at 20:35, <[email protected]> wrote:
From: Tomasz Nowicki <[email protected]>
This commit provides APEI arch-specific bits for aarch64
Changelog:
Fu Wei:
Movearch_apei_flush_tlb_one()toarch/arm64/include/asm/apci.h. Deletearch/arm64/kernel/apei.c.
Add "#ifdefCONFIG_ACPI_APEI" for "acpi_disable_cmcff".Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/acpi.h | 11 +++++++++++ arch/arm64/kernel/acpi.c | 4 ++++ 3 files changed, 16 insertions(+)arch/arm64/Kconfig +1
-0@@ -3,6 +3,7 @@ config ARM64 select ACPI_CCA_REQUIRED if ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI + select HAVE_ACPI_APEI if ACPI select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALLarch/arm64/include/asm/acpi.h +11
-0@@ -22,6 +22,7 @@#ifdef CONFIG_ACPI_APEI #include <linux/efi.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #endif /* Macros for consistency checks of the GICC subtable of MADT */ @@ -52,6 +53,9 @@ typedef u64 phys_cpuid_t;extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +extern int acpi_disable_cmcff; +#endif static inline void disable_acpi (void ) {@@ -89,6 +93,13 @@ static inline bool acpi_has_cpu_in_madt(void)static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void ); +#ifdef CONFIG_ACPI_APEI +static inline void arch_apei_flush_tlb_one (unsigned long addr) +{ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); +} +#endif +#else static inline void acpi_init_cpus (void ) { }#endif /* CONFIG_ACPI */ arch/arm64/kernel/acpi.c +4
-1@@ -36,6 +36,10 @@ EXPORT_SYMBOL(acpi_disabled);int acpi_pci_disabled =1 ;/* skip ACPI PCI scan and IRQ initialization */ EXPORT_SYMBOL (acpi_pci_disabled); +#ifdef CONFIG_ACPI_APEI +int acpi_disable_cmcff; +#endif +static bool param_acpi_off__initdata ;static bool param_acpi_force__initdata ; --1.9.1
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Zhang, Jonathan Zhixiong
Tested-byRe: [PATCH] acpi, apei, arm64: APEI initial support for aarch64.
Quoted 92 lines · Fu Wei
Hi all,
This patch depends on https://lkml.org/lkml/2015/8/8/169
[PATCH V11 4/5] arm64: apei: implementarch_apei_get_mem_attributes(), which has been in the "next" branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.gitFYI
ThanksQuoted 81 lines · On 14 August 2015 at 20:35, <[email protected]> wrote:
From: Tomasz Nowicki <[email protected]>
This commit provides APEI arch-specific bits for aarch64
Changelog:
Fu Wei:
Movearch_apei_flush_tlb_one()toarch/arm64/include/asm/apci.h. Deletearch/arm64/kernel/apei.c.
Add "#ifdefCONFIG_ACPI_APEI" for "acpi_disable_cmcff".Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/acpi.h | 11 +++++++++++ arch/arm64/kernel/acpi.c | 4 ++++ 3 files changed, 16 insertions(+)arch/arm64/Kconfig +1
-0@@ -3,6 +3,7 @@ config ARM64 select ACPI_CCA_REQUIRED if ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI + select HAVE_ACPI_APEI if ACPI select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALLarch/arm64/include/asm/acpi.h +11
-0@@ -22,6 +22,7 @@#ifdef CONFIG_ACPI_APEI #include <linux/efi.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #endif /* Macros for consistency checks of the GICC subtable of MADT */ @@ -52,6 +53,9 @@ typedef u64 phys_cpuid_t;extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +extern int acpi_disable_cmcff; +#endif static inline void disable_acpi (void ) {@@ -89,6 +93,13 @@ static inline bool acpi_has_cpu_in_madt(void)static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void ); +#ifdef CONFIG_ACPI_APEI +static inline void arch_apei_flush_tlb_one (unsigned long addr) +{ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); +} +#endif +#else static inline void acpi_init_cpus (void ) { }#endif /* CONFIG_ACPI */ arch/arm64/kernel/acpi.c +4
-0@@ -36,6 +36,10 @@ EXPORT_SYMBOL(acpi_disabled);int acpi_pci_disabled =1 ;/* skip ACPI PCI scan and IRQ initialization */ EXPORT_SYMBOL (acpi_pci_disabled); +#ifdef CONFIG_ACPI_APEI +int acpi_disable_cmcff; +#endif +static bool param_acpi_off__initdata ;static bool param_acpi_force__initdata ;
Quoted 6 lines
Quoted 3 lines
--
1.9.1
I tested this patch on an arm64 platform, the APEI functionalities work as expected.
Signature · 3 lines
Jonathan (Zhixiong) Zhang The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH] acpi, apei, arm64: APEI initial support for aarch64.
Hi all
Add Tomasz Nowicki <[email protected]> in the loop
Quoted 112 lines · Jonathan Zhixiong
Quoted 96 lines · Fu Wei
Hi all,
This patch depends on https://lkml.org/lkml/2015/8/8/169
[PATCH V11 4/5] arm64: apei: implementarch_apei_get_mem_attributes(), which has been in the "next" branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.gitFYI
ThanksQuoted 84 lines · On 14 August 2015 at 20:35, <[email protected]> wrote:
From: Tomasz Nowicki <[email protected]>
This commit provides APEI arch-specific bits for aarch64
Changelog:
Fu Wei:
Movearch_apei_flush_tlb_one()toarch/arm64/include/asm/apci.h. Deletearch/arm64/kernel/apei.c.
Add "#ifdefCONFIG_ACPI_APEI" for "acpi_disable_cmcff".Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/acpi.h | 11 +++++++++++ arch/arm64/kernel/acpi.c | 4 ++++ 3 files changed, 16 insertions(+)arch/arm64/Kconfig +1
-0@@ -3,6 +3,7 @@ config ARM64 select ACPI_CCA_REQUIRED if ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI + select HAVE_ACPI_APEI if ACPI select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALLarch/arm64/include/asm/acpi.h +11
-0@@ -22,6 +22,7 @@#ifdef CONFIG_ACPI_APEI #include <linux/efi.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #endif /* Macros for consistency checks of the GICC subtable of MADT */ @@ -52,6 +53,9 @@ typedef u64 phys_cpuid_t;extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +extern int acpi_disable_cmcff; +#endif static inline void disable_acpi (void ) {@@ -89,6 +93,13 @@ static inline bool acpi_has_cpu_in_madt(void)static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void ); +#ifdef CONFIG_ACPI_APEI +static inline void arch_apei_flush_tlb_one (unsigned long addr) +{ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); +} +#endif +#else static inline void acpi_init_cpus (void ) { }#endif /* CONFIG_ACPI */ arch/arm64/kernel/acpi.c +0
-0@@ -36,6 +36,10 @@ EXPORT_SYMBOL(acpi_disabled);int acpi_pci_disabled =1 ;/* skip ACPI PCI scan and IRQ initialization */
EXPORT_SYMBOL(acpi_pci_disabled);arch/arm64/kernel/acpi.c +4
-0+#ifdef CONFIG_ACPI_APEI +int acpi_disable_cmcff; +#endif +static bool param_acpi_off__initdata ;static bool param_acpi_force__initdata ;Quoted 6 lines
Quoted 3 lines
--
1.9.1I tested this patch on an arm64 platform, the APEI functionalities work as expected.
--
Jonathan (Zhixiong) Zhang
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH] acpi, apei, arm64: APEI initial support for aarch64.
In reply to [email protected]Quoted 53 lines · On Fri, Aug 14, 2015 at 01:35:53PM +0100, [email protected] wrote:
From: Tomasz Nowicki <[email protected]>
This commit provides APEI arch-specific bits for aarch64
Changelog:
Fu Wei:
Movearch_apei_flush_tlb_one()toarch/arm64/include/asm/apci.h. Deletearch/arm64/kernel/apei.c.
Add "#ifdefCONFIG_ACPI_APEI" for "acpi_disable_cmcff".Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/acpi.h | 11 +++++++++++ arch/arm64/kernel/acpi.c | 4 ++++ 3 files changed, 16 insertions(+)arch/arm64/Kconfig +1
-0@@ -3,6 +3,7 @@ config ARM64 select ACPI_CCA_REQUIRED if ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI + select HAVE_ACPI_APEI if ACPI select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALLarch/arm64/include/asm/acpi.h +4
-0@@ -22,6 +22,7 @@#ifdef CONFIG_ACPI_APEI #include <linux/efi.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #endif /* Macros for consistency checks of the GICC subtable of MADT */ @@ -52,6 +53,9 @@ typedef u64 phys_cpuid_t;extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +extern int acpi_disable_cmcff; +#endif static inline void disable_acpi (void ) {
arch/arm64/include/asm/acpi.h static inline bool acpi_has_cpu_in_madt(void) · line 101
Quoted 9 lines
arch/arm64/include/asm/acpi.h +6
-0@@ -89,6 +93,13 @@ static inline bool acpi_has_cpu_in_madt(void)static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void ); +#ifdef CONFIG_ACPI_APEI +static inline void arch_apei_flush_tlb_one (unsigned long addr) +{ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); +} +#endif
Looking at the callers of this function, I suspect we could downgrade it to a local CPU invalidation if we wanted. However, this isn't a hot-path so it's fine to stay like it is for now.
Will
Re: [PATCH] acpi, apei, arm64: APEI initial support for aarch64.
Quoted 57 lines · Will Deacon
Quoted 56 lines · On Fri, Aug 14, 2015 at 01:35:53PM +0100, [email protected] wrote:
From: Tomasz Nowicki <[email protected]>
This commit provides APEI arch-specific bits for aarch64
Changelog:
Fu Wei:
Movearch_apei_flush_tlb_one()toarch/arm64/include/asm/apci.h. Deletearch/arm64/kernel/apei.c.
Add "#ifdefCONFIG_ACPI_APEI" for "acpi_disable_cmcff".Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/acpi.h | 11 +++++++++++ arch/arm64/kernel/acpi.c | 4 ++++ 3 files changed, 16 insertions(+)arch/arm64/Kconfig +1
-0@@ -3,6 +3,7 @@ config ARM64 select ACPI_CCA_REQUIRED if ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI + select HAVE_ACPI_APEI if ACPI select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALLarch/arm64/include/asm/acpi.h +4
-0@@ -22,6 +22,7 @@#ifdef CONFIG_ACPI_APEI #include <linux/efi.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #endif /* Macros for consistency checks of the GICC subtable of MADT */ @@ -52,6 +53,9 @@ typedef u64 phys_cpuid_t;extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +extern int acpi_disable_cmcff; +#endif static inline void disable_acpi (void ) {@@ -89,6 +93,13 @@ static inline bool acpi_has_cpu_in_madt(void)static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void );
Quoted 10 lines
arch/arm64/include/asm/acpi.h static inline bool acpi_has_cpu_in_madt(void) · line 101
Quoted 6 lines
arch/arm64/include/asm/acpi.h +6
-0+#ifdef CONFIG_ACPI_APEI +static inline void arch_apei_flush_tlb_one (unsigned long addr) +{ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); +} +#endif Looking at the callers of this function, I suspect we could downgrade it to a local CPU invalidation if we wanted. However, this isn't a hot-path so it's fine to stay like it is for now.
I suppose if we run "tlbi vae1" instead of "tlbi vae1is", it will be more efficient without side effect, since both ghes_ioremap_pfn_irq() and ghes_iounmap_irq() happen in same atomic context. However, today arch/arm64/include/asm/tlbflush.h does not have a function tailored for such performance optimization. Does it make sense to add a parameter to flush_tlb_kernel_range() to allow caller to make a choice?
static inline void flush_tlb_kernel_range(unsigned long start,
unsigned long end, bool local)
There are only two others callers of flush_tlb_kernel_range().
Quoted 3 lines
Will
Signature · 3 lines
Jonathan (Zhixiong) Zhang The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH] acpi, apei, arm64: APEI initial support for aarch64.
Quoted 38 lines · Jonathan Zhixiong
Quoted 27 lines · Will Deacon
Quoted 26 lines · On Fri, Aug 14, 2015 at 01:35:53PM +0100, [email protected] wrote:
arch/arm64/include/asm/acpi.h +4
-0@@ -22,6 +22,7 @@#ifdef CONFIG_ACPI_APEI #include <linux/efi.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #endif /* Macros for consistency checks of the GICC subtable of MADT */ @@ -52,6 +53,9 @@ typedef u64 phys_cpuid_t;extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +extern int acpi_disable_cmcff; +#endif static inline void disable_acpi (void ) {@@ -89,6 +93,13 @@ static inline bool acpi_has_cpu_in_madt(void)static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void );Quoted 10 lines
arch/arm64/include/asm/acpi.h static inline bool acpi_has_cpu_in_madt(void) · line 101
Quoted 6 lines
arch/arm64/include/asm/acpi.h +6
-0+#ifdef CONFIG_ACPI_APEI +static inline void arch_apei_flush_tlb_one (unsigned long addr) +{ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); +} +#endif Looking at the callers of this function, I suspect we could downgrade it to a local CPU invalidation if we wanted. However, this isn't a hot-path so it's fine to stay like it is for now.
Quoted 9 lines
I suppose if we run "tlbi vae1" instead of "tlbi vae1is", it will be more efficient without side effect, since both
ghes_ioremap_pfn_irq()andghes_iounmap_irq()happen in same atomic context. However, todayarch/arm64/include/asm/tlbflush.hdoes not have a function tailored for such performance optimization. Does it make sense to add a parameter toflush_tlb_kernel_range()to allow caller to make a choice?
static inline void flush_tlb_kernel_range(unsigned long start,
unsigned long end, bool local)
There are only two others callers offlush_tlb_kernel_range().
I've already got some patches to add things like local_flush_tlb_all, which I'll post after the merge window (I'm currently rewriting a bunch of the switch_mm code to try to reduce the TLBI traffic).
If this isn't a hotpath (I don't think it is), then it's probably not worth making the optimisation without a system to benchmark it on.
Will
Re: [PATCH] acpi, apei, arm64: APEI initial support for aarch64.
Hi
Quoted 49 lines · Will Deacon
Quoted 38 lines · Jonathan Zhixiong
Quoted 27 lines · Will Deacon
Quoted 26 lines · On Fri, Aug 14, 2015 at 01:35:53PM +0100, [email protected] wrote:
arch/arm64/include/asm/acpi.h +4
-0@@ -22,6 +22,7 @@#ifdef CONFIG_ACPI_APEI #include <linux/efi.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #endif /* Macros for consistency checks of the GICC subtable of MADT */ @@ -52,6 +53,9 @@ typedef u64 phys_cpuid_t;extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +extern int acpi_disable_cmcff; +#endif static inline void disable_acpi (void ) {@@ -89,6 +93,13 @@ static inline bool acpi_has_cpu_in_madt(void)static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void );Quoted 10 lines
arch/arm64/include/asm/acpi.h static inline bool acpi_has_cpu_in_madt(void) · line 101
Quoted 6 lines
arch/arm64/include/asm/acpi.h +6
-0+#ifdef CONFIG_ACPI_APEI +static inline void arch_apei_flush_tlb_one (unsigned long addr) +{ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); +} +#endif Looking at the callers of this function, I suspect we could downgrade it to a local CPU invalidation if we wanted. However, this isn't a hot-path so it's fine to stay like it is for now.
Quoted 9 lines
I suppose if we run "tlbi vae1" instead of "tlbi vae1is", it will be more efficient without side effect, since both
ghes_ioremap_pfn_irq()andghes_iounmap_irq()happen in same atomic context. However, todayarch/arm64/include/asm/tlbflush.hdoes not have a function tailored for such performance optimization. Does it make sense to add a parameter toflush_tlb_kernel_range()to allow caller to make a choice?
static inline void flush_tlb_kernel_range(unsigned long start,
unsigned long end, bool local)
There are only two others callers offlush_tlb_kernel_range().
Quoted 3 lines
I've already got some patches to add things like
local_flush_tlb_all, which I'll post after the merge window (I'm currently rewriting a bunch of theswitch_mmcode to try to reduce the TLBI traffic).
If I understand correctly, these patches add new functions, instead of changing the existent one.
I thinks this way is better.
If we have new patch for optimizing TLB flushing, we can make a new patchset for this in the future.
Because this patch is only for enabling APEI on aarch64.
Quoted 3 lines
If this isn't a hotpath (I don't think it is), then it's probably not worth making the optimisation without a system to benchmark it on.
agree.
But please let me know if you have any suggestion on this patch. is this patch OK for you?
Quoted 2 lines
Will
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
v2 cover acpi, apei: add BERT support
In reply to a message not in the archiveFrom: Fu Wei <[email protected]>
ACPI/APEI is designed to verifiy/report H/W errors, like Corrected Error(CE) and Uncorrected Error(UC). It contains four tables: HEST, ERST, EINJ and BERT. The first three tables have been merged for a long time, but because of lacking BIOS support for BERT, the support for BERT is pending until now. Recently on ARM 64 platform it is has been supported. So here we come.
The following log is a BERT record after system reboot because of hitting a fatal error.
BERT: Obtained BERT iomem region <00000000fe801000-00000000fe802000> for BERT. [Hardware Error]: Error record from previous boot:
[Hardware Error]: event severity: fatal
[Hardware Error]: Error 0, type: fatal
[Hardware Error]: section_type: memory error [Hardware Error]: physical_address: 0x00000000fe800000 [Hardware Error]: physical_address_mask: 0x0000000000000fff [Hardware Error]: card: 0 module: 1 bank: 0 device: 1 row: 1 column: 1 bit_pos
Changelog:
v2: Delete EXPORT_SYMBOL_GPL(bert_disable), because "bert_disable" is only used
in bert.c for now.
Do some code-style cleanups.
v1: The first upstream version submitted in linux-acpi mailing list:
http://www.spinics.net/lists/linux-acpi/msg57384.html
Huang Ying (1):
ACPI, APEI, Boot Error Record Table (BERT) support
Tomasz Nowicki (1):
acpi, apei, bert: Clear error status at the end of error handling
Documentation/kernel-parameters.txt | 3 + drivers/acpi/apei/Makefile | 2 +- drivers/acpi/apei/bert.c | 165 ++++++++++++++++++++++++++++++++++++ include/acpi/apei.h | 1 + 4 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/apei/bert.c
Signature · 1 line
2.4.3
PATCH v2 1/2 acpi, apei: add Boot Error Record Table (BERT) support
From: Huang Ying <[email protected]>
Under normal circumstances, when a hardware error occurs, kernel will be notified via NMI, MCE or some other method, then kernel will process the error condition, report it, and recover it if possible. But sometime, the situation is so bad, so that firmware may choose to reset directly without notifying Linux kernel.
Linux kernel can use the Boot Error Record Table (BERT) to get the un-notified hardware errors that occurred in a previous boot. In this patch, the error information is reported via printk.
For more information about BERT, please refer to ACPI Specification version 6.0, section 18.3.1:
http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf
[Tony: Applied some cleanups suggested by Fu Wei]
[Fu Wei: delete EXPORT_SYMBOL_GPL(bert_disable), and do some cleanups]
--- Documentation/kernel-parameters.txt | 3 + drivers/acpi/apei/Makefile | 2 +- drivers/acpi/apei/bert.c | 162 ++++++++++++++++++++++++++++++++++++ include/acpi/apei.h | 1 + 4 files changed, 167 insertions(+), 1 deletion(-)
Documentation/kernel-parameters.txt +3 -0
@@ -554,6 +554,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. bootmem_debug [KNL] Enable bootmem allocator debug messages. + bert_disable [ACPI] + Disable Boot Error Record Table (BERT) support. + bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards) bttv.radio= Most important insmod options are available as kernel args too.
drivers/acpi/apei/Makefile +1 -1
@@ -3,4 +3,4 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o -apei-y := apei-base.o hest.o erst.o +apei-y := apei-base.o hest.o erst.o bert.o
drivers/acpi/apei/bert.c new file +162 -0
162 lines not on this page · raw message
include/acpi/apei.h +1 -0
@@ -23,6 +23,7 @@ extern bool ghes_disable;#else #define ghes_disable 1#endif +extern int bert_disable;#ifdef CONFIG_ACPI_APEI void __init acpi_hest_init (void );
Signature · 1 line
2.4.3
Borislav Petkov
reviewerRe: [PATCH v2 1/2] acpi, apei: add Boot Error Record Table (BERT) support
Quoted 38 lines · On Wed, Aug 19, 2015 at 12:44:16AM +0800, [email protected] wrote:
From: Huang Ying <[email protected]>
Under normal circumstances, when a hardware error occurs, kernel will be notified via NMI, MCE or some other method, then kernel will process the error condition, report it, and recover it if possible. But sometime, the situation is so bad, so that firmware may choose to reset directly without notifying Linux kernel.
Linux kernel can use the Boot Error Record Table (BERT) to get the un-notified hardware errors that occurred in a previous boot. In this patch, the error information is reported via printk.
For more information about BERT, please refer to ACPI Specification version 6.0, section 18.3.1:
http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf[Tony: Applied some cleanups suggested by Fu Wei]
[Fu Wei: deleteEXPORT_SYMBOL_GPL(bert_disable), and do some cleanups]Signed-off-by Huang Ying <[email protected]>Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Chen, Gong <[email protected]>Tested-by Fu Wei <[email protected]>Signed-off-by Tony Luck <[email protected]>Signed-off-by Fu Wei <[email protected]>--- Documentation/kernel-parameters.txt | 3 + drivers/acpi/apei/Makefile | 2 +- drivers/acpi/apei/bert.c | 162 ++++++++++++++++++++++++++++++++++++ include/acpi/apei.h | 1 + 4 files changed, 167 insertions(+), 1 deletion(-)Documentation/kernel-parameters.txt +0
-0
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 558
Quoted 5 lines
Documentation/kernel-parameters.txt +2
-0@@ -554,6 +554,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. bootmem_debug [KNL] Enable bootmem allocator debug messages. + bert_disable [ACPI] + Disable Boot Error Record Table (BERT) support.
Please document what that new parameter is good for.
Quoted 41 lines
Documentation/kernel-parameters.txt +1
-0+ bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards) bttv.radio= Most important insmod options are available as kernel args too.drivers/acpi/apei/Makefile +1
-1@@ -3,4 +3,4 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o -apei-y := apei-base.o hest.o erst.o +apei-y := apei-base.o hest.o erst.o bert.odrivers/acpi/apei/bert.c new file +21
-0@@ -0,0 +1,162 @@ +/* +* APEI Boot Error Record Table (BERT) support +* +* Copyright 2011 Intel Corp. +* Author: Huang Ying <[email protected]> +* +* Under normal circumstances, when a hardware error occurs, kernel +* will be notified via NMI, MCE or some other method, then kernel +* will process the error condition, report it, and recover it if +* possible. But sometime, the situation is so bad, so that firmware +* may choose to reset directly without notifying Linux kernel. +* +* Linux kernel can use the Boot Error Record Table (BERT) to get the +* un-notified hardware errors that occurred in a previous boot. +* +* For more information about BERT, please refer to ACPI Specification +* version 4.0, section 17.3.1 +* +* This file is licensed under GPLv2. +* +*/
drivers/acpi/apei/bert.c line 31
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/acpi.h> +#include <linux/io.h> + +#include "apei-internal.h" + +#define BERT_PFX "BERT: "
This is done with pr_fmt
drivers/acpi/apei/bert.c line 41
Quoted 9 lines
drivers/acpi/apei/bert.c new file +9
-0+static int bert_disable; + +static void __init bert_print_all (struct acpi_hest_generic_status *region, +unsigned int region_len) +{ +struct acpi_hest_generic_status *estatus = region; +int remain = region_len; +u32 estatus_len; +int first =1 ;
if (!estatus->block_status) return;
drivers/acpi/apei/bert.c line 44
Quoted 2 lines
drivers/acpi/apei/bert.c new file +2
-0+while (remain >sizeof (struct acpi_hest_generic_status )) { +/* No more error record */
... records */
drivers/acpi/apei/bert.c line 46
Quoted 2 lines
drivers/acpi/apei/bert.c new file +2
-0+if (!estatus->block_status) +break ;
This test should happen when you enter the function (see above) and when you assign to estatus, i.e. below, at the end of the while loop body:
estatus = (void *)estatus + estatus_len; if (!estatus->block_status) break;
drivers/acpi/apei/bert.c line 52
Quoted 6 lines
drivers/acpi/apei/bert.c new file +6
-0+ + estatus_len =cper_estatus_len (estatus); +if (estatus_len <sizeof (struct acpi_hest_generic_status ) || + remain < estatus_len) { + pr_err(FW_BUG BERT_PFX + "Invalid error status block with length %u\n",
"Invalid status block length (%u)"
drivers/acpi/apei/bert.c line 58
Quoted 6 lines
drivers/acpi/apei/bert.c new file +6
-0+ estatus_len); +return ; + } + +if (cper_estatus_check (estatus)) { + pr_err(FW_BUG BERT_PFX "Invalid error status block\n");
"Invalid error record."
drivers/acpi/apei/bert.c line 63
Quoted 5 lines
drivers/acpi/apei/bert.c new file +5
-0+ goto next; + } + +if (first) { +pr_info (HW_ERR "Error record from previous boot:\n" );
Error records<--- plural.
drivers/acpi/apei/bert.c line 63
Quoted 2 lines
drivers/acpi/apei/bert.c new file +2
-0+ first =0 ; + }
We have pr_info_once() for this.
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+ + cper_estatus_print(KERN_INFO HW_ERR, estatus); +next: + estatus = (void *)estatus + estatus_len; + remain -= estatus_len; + } +} + +static int __init setup_bert_disable (char *str) +{
drivers/acpi/apei/bert.c line 85
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+ bert_disable =1 ; + +return 0 ; +} +__setup ("bert_disable" , setup_bert_disable); + +static int __init bert_check_table (struct acpi_table_bert *bert_tab) +{ +if (bert_tab->header.length <sizeof (struct acpi_table_bert )) +return -EINVAL ;
\n here
drivers/acpi/apei/bert.c line 86
Quoted 1 line
drivers/acpi/apei/bert.c new file +1
-0+ if (bert_tab->region_length &&
This test looks redundant if you're going to compare it to the size of the BERT region struct below.
Quoted 15 lines
drivers/acpi/apei/bert.c new file +15
-0+ bert_tab->region_length < sizeof(struct acpi_bert_region)) + return -EINVAL; + +return 0 ; +} + +static int __init bert_init (void ) +{ +struct acpi_hest_generic_status *bert_region; +struct acpi_table_bert *bert_tab; +unsigned int region_len; +acpi_status status; +struct resource *r; +int rc = -EINVAL ; +
drivers/acpi/apei/bert.c line 111
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+if (acpi_disabled) + goto out; + +if (bert_disable) { +pr_info (BERT_PFX "Boot Error Record Table (BERT) support is disabled.\n" ); + goto out; + } + + status =acpi_get_table (ACPI_SIG_BERT ,0 , + (struct acpi_table_header **)&bert_tab);
No need to break that line, just leave it stick out.
drivers/acpi/apei/bert.c line 113
Quoted 2 lines
drivers/acpi/apei/bert.c new file +2
-0+if (status ==AE_NOT_FOUND ) { +pr_err (BERT_PFX "Table is not found!\n" );
This will get issued on *all* machines which don't have BERT - which is the majority now, I'm afraid - and that information is useless to people. It's not like they can do anything about it short of overriding their own firmware.
So please remove that printk.
drivers/acpi/apei/bert.c line 124
Quoted 11 lines
drivers/acpi/apei/bert.c new file +11
-0+ goto out; + }else if (ACPI_FAILURE (status)) { +const char *msg =acpi_format_exception (status); + +pr_err (BERT_PFX "Failed to get table, %s\n" , msg); + goto out; + } + + rc =bert_check_table (bert_tab); +if (rc) { + pr_err(FW_BUG BERT_PFX "BERT table is invalid\n");
Prefix already has "BERT". Either write it out:
"BERT: Boot Error Record Table invalid"
or make it shorter:
"BERT: table invalid."
drivers/acpi/apei/bert.c line 132
Quoted 8 lines
drivers/acpi/apei/bert.c new file +8
-0+ goto out; + } + + region_len = bert_tab->region_length; +if (!region_len) { + rc =0 ; + goto out; + }
Huh, we just checked ->region_length in bert_check_table(). This test is redundant.
Quoted 15 lines
drivers/acpi/apei/bert.c new file +15
-0+ + r =request_mem_region (bert_tab->address, region_len,"APEI BERT" ); +if (!r) { +pr_err (BERT_PFX "Can't request iomem region <%016llx-%016llx>\n" , + (unsigned long long )bert_tab->address, + (unsigned long long )bert_tab->address + region_len -1 ); + rc = -EIO ; + goto out; + } + + bert_region =ioremap_cache (bert_tab->address, region_len); +if (!bert_region) { + rc = -ENOMEM ; + goto out_release; + }
drivers/acpi/apei/bert.c line 157
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+ +bert_print_all (bert_region, region_len); + +iounmap (bert_region); + +out_release: +release_mem_region (bert_tab->address, region_len); +out: +if (rc) + bert_disable =1 ;
This assignment is redundant. We're not testing it anywhere else after bert_init() has run.
Quoted 21 lines
drivers/acpi/apei/bert.c new file +5
-0+ +return rc; +} + +late_initcall (bert_init);include/acpi/apei.h +1
-0@@ -23,6 +23,7 @@ extern bool ghes_disable;#else #define ghes_disable 1#endif +extern int bert_disable;#ifdef CONFIG_ACPI_APEI void __init acpi_hest_init (void );Signature · 1 line
2.4.3
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Re: [PATCH v2 1/2] acpi, apei: add Boot Error Record Table (BERT) support
Hi Borislav,
Thanks for your review.
I totally agree all your comment
I have made a new patch, and that is in testing, I will post it ASAP
Quoted 313 lines · Borislav Petkov
Quoted 38 lines · On Wed, Aug 19, 2015 at 12:44:16AM +0800, [email protected] wrote:
From: Huang Ying <[email protected]>
Under normal circumstances, when a hardware error occurs, kernel will be notified via NMI, MCE or some other method, then kernel will process the error condition, report it, and recover it if possible. But sometime, the situation is so bad, so that firmware may choose to reset directly without notifying Linux kernel.
Linux kernel can use the Boot Error Record Table (BERT) to get the un-notified hardware errors that occurred in a previous boot. In this patch, the error information is reported via printk.
For more information about BERT, please refer to ACPI Specification version 6.0, section 18.3.1:
http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf[Tony: Applied some cleanups suggested by Fu Wei]
[Fu Wei: deleteEXPORT_SYMBOL_GPL(bert_disable), and do some cleanups]Signed-off-by Huang Ying <[email protected]>Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Chen, Gong <[email protected]>Tested-by Fu Wei <[email protected]>Signed-off-by Tony Luck <[email protected]>Signed-off-by Fu Wei <[email protected]>--- Documentation/kernel-parameters.txt | 3 + drivers/acpi/apei/Makefile | 2 +- drivers/acpi/apei/bert.c | 162 ++++++++++++++++++++++++++++++++++++ include/acpi/apei.h | 1 + 4 files changed, 167 insertions(+), 1 deletion(-)Documentation/kernel-parameters.txt +0
-0Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 558
Quoted 5 lines
Documentation/kernel-parameters.txt +2
-0@@ -554,6 +554,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. bootmem_debug [KNL] Enable bootmem allocator debug messages. + bert_disable [ACPI] + Disable Boot Error Record Table (BERT) support.Please document what that new parameter is good for.
Quoted 41 lines
Documentation/kernel-parameters.txt +1
-0+ bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards) bttv.radio= Most important insmod options are available as kernel args too.drivers/acpi/apei/Makefile +1
-1@@ -3,4 +3,4 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o -apei-y := apei-base.o hest.o erst.o +apei-y := apei-base.o hest.o erst.o bert.odrivers/acpi/apei/bert.c new file +21
-0@@ -0,0 +1,162 @@ +/* +* APEI Boot Error Record Table (BERT) support +* +* Copyright 2011 Intel Corp. +* Author: Huang Ying <[email protected]> +* +* Under normal circumstances, when a hardware error occurs, kernel +* will be notified via NMI, MCE or some other method, then kernel +* will process the error condition, report it, and recover it if +* possible. But sometime, the situation is so bad, so that firmware +* may choose to reset directly without notifying Linux kernel. +* +* Linux kernel can use the Boot Error Record Table (BERT) to get the +* un-notified hardware errors that occurred in a previous boot. +* +* For more information about BERT, please refer to ACPI Specification +* version 4.0, section 17.3.1 +* +* This file is licensed under GPLv2. +* +*/ drivers/acpi/apei/bert.c line 31
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/acpi.h> +#include <linux/io.h> + +#include "apei-internal.h" + +#define BERT_PFX "BERT: "This is done with
pr_fmtdrivers/acpi/apei/bert.c line 41
Quoted 9 lines
drivers/acpi/apei/bert.c new file +9
-0+static int bert_disable; + +static void __init bert_print_all (struct acpi_hest_generic_status *region, +unsigned int region_len) +{ +struct acpi_hest_generic_status *estatus = region; +int remain = region_len; +u32 estatus_len; +int first =1 ;if (!estatus->block_status) return;drivers/acpi/apei/bert.c line 44
Quoted 2 lines
drivers/acpi/apei/bert.c new file +2
-0+while (remain >sizeof (struct acpi_hest_generic_status )) { +/* No more error record */ ... records */drivers/acpi/apei/bert.c line 46
Quoted 2 lines
drivers/acpi/apei/bert.c new file +2
-0+if (!estatus->block_status) +break ;This test should happen when you enter the function (see above) and when you assign to estatus, i.e. below, at the end of the while loop body:
estatus = (void *)estatus + estatus_len; if (!estatus->block_status) break;drivers/acpi/apei/bert.c line 52
Quoted 6 lines
drivers/acpi/apei/bert.c new file +6
-0+ + estatus_len =cper_estatus_len (estatus); +if (estatus_len <sizeof (struct acpi_hest_generic_status ) || + remain < estatus_len) { + pr_err(FW_BUG BERT_PFX + "Invalid error status block with length %u\n","Invalid status block length (%u)"
drivers/acpi/apei/bert.c line 58
Quoted 6 lines
drivers/acpi/apei/bert.c new file +6
-0+ estatus_len); +return ; + } + +if (cper_estatus_check (estatus)) { + pr_err(FW_BUG BERT_PFX "Invalid error status block\n");"Invalid error record."
drivers/acpi/apei/bert.c line 63
Quoted 5 lines
drivers/acpi/apei/bert.c new file +5
-0+ goto next; + } + +if (first) { +pr_info (HW_ERR "Error record from previous boot:\n" );Error records<--- plural.
drivers/acpi/apei/bert.c line 63
Quoted 2 lines
drivers/acpi/apei/bert.c new file +2
-0+ first =0 ; + }We have
pr_info_once()for this.Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+ + cper_estatus_print(KERN_INFO HW_ERR, estatus); +next: + estatus = (void *)estatus + estatus_len; + remain -= estatus_len; + } +} + +static int __init setup_bert_disable (char *str) +{drivers/acpi/apei/bert.c line 85
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+ bert_disable =1 ; + +return 0 ; +} +__setup ("bert_disable" , setup_bert_disable); + +static int __init bert_check_table (struct acpi_table_bert *bert_tab) +{ +if (bert_tab->header.length <sizeof (struct acpi_table_bert )) +return -EINVAL ;\n here
drivers/acpi/apei/bert.c line 86
Quoted 1 line
drivers/acpi/apei/bert.c new file +1
-0+ if (bert_tab->region_length &&This test looks redundant if you're going to compare it to the size of the BERT region struct below.
Quoted 15 lines
drivers/acpi/apei/bert.c new file +15
-0+ bert_tab->region_length < sizeof(struct acpi_bert_region)) + return -EINVAL; + +return 0 ; +} + +static int __init bert_init (void ) +{ +struct acpi_hest_generic_status *bert_region; +struct acpi_table_bert *bert_tab; +unsigned int region_len; +acpi_status status; +struct resource *r; +int rc = -EINVAL ; +drivers/acpi/apei/bert.c line 111
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+if (acpi_disabled) + goto out; + +if (bert_disable) { +pr_info (BERT_PFX "Boot Error Record Table (BERT) support is disabled.\n" ); + goto out; + } + + status =acpi_get_table (ACPI_SIG_BERT ,0 , + (struct acpi_table_header **)&bert_tab);No need to break that line, just leave it stick out.
drivers/acpi/apei/bert.c line 113
Quoted 2 lines
drivers/acpi/apei/bert.c new file +2
-0+if (status ==AE_NOT_FOUND ) { +pr_err (BERT_PFX "Table is not found!\n" );This will get issued on *all* machines which don't have BERT - which is the majority now, I'm afraid - and that information is useless to people. It's not like they can do anything about it short of overriding their own firmware.
So please remove that printk.
drivers/acpi/apei/bert.c line 124
Quoted 11 lines
drivers/acpi/apei/bert.c new file +11
-0+ goto out; + }else if (ACPI_FAILURE (status)) { +const char *msg =acpi_format_exception (status); + +pr_err (BERT_PFX "Failed to get table, %s\n" , msg); + goto out; + } + + rc =bert_check_table (bert_tab); +if (rc) { + pr_err(FW_BUG BERT_PFX "BERT table is invalid\n");Prefix already has "BERT". Either write it out:
"BERT: Boot Error Record Table invalid"
or make it shorter:
"BERT: table invalid."
drivers/acpi/apei/bert.c line 132
Quoted 8 lines
drivers/acpi/apei/bert.c new file +8
-0+ goto out; + } + + region_len = bert_tab->region_length; +if (!region_len) { + rc =0 ; + goto out; + }Huh, we just checked ->region_length in
bert_check_table(). This test is redundant.Quoted 15 lines
drivers/acpi/apei/bert.c new file +15
-0+ + r =request_mem_region (bert_tab->address, region_len,"APEI BERT" ); +if (!r) { +pr_err (BERT_PFX "Can't request iomem region <%016llx-%016llx>\n" , + (unsigned long long )bert_tab->address, + (unsigned long long )bert_tab->address + region_len -1 ); + rc = -EIO ; + goto out; + } + + bert_region =ioremap_cache (bert_tab->address, region_len); +if (!bert_region) { + rc = -ENOMEM ; + goto out_release; + }drivers/acpi/apei/bert.c line 157
Quoted 10 lines
drivers/acpi/apei/bert.c new file +10
-0+ +bert_print_all (bert_region, region_len); + +iounmap (bert_region); + +out_release: +release_mem_region (bert_tab->address, region_len); +out: +if (rc) + bert_disable =1 ;This assignment is redundant. We're not testing it anywhere else after
bert_init()has run.Quoted 18 lines
drivers/acpi/apei/bert.c new file +5
-0+ +return rc; +} + +late_initcall (bert_init);include/acpi/apei.h +1
-1@@ -23,6 +23,7 @@ extern bool ghes_disable;#else #define ghes_disable 1#endif +extern int bert_disable;#ifdef CONFIG_ACPI_APEI void __init acpi_hest_init (void ); --Quoted 3 lines
2.4.3
--
Regards/Gruss,
Boris.ECO tip #101: Trim your mails when you reply.
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Borislav Petkov
reviewerRe: [PATCH v2 1/2] acpi, apei: add Boot Error Record Table (BERT) support
Quoted 5 lines · Fu Wei
Hi Borislav,
Thanks for your review.
I totally agree all your comment
I have made a new patch, and that is in testing, I will post it ASAP
Ok, but please do not top-post.
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.PATCH v2 2/2 acpi, apei, bert: Clear error status at the end of error handling
In reply to [email protected]From: Tomasz Nowicki <[email protected]>
Once error log is printed out clear error status so it would not be print during next boot again.
--- drivers/acpi/apei/bert.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/apei/bert.c +3 -0
@@ -65,6 +65,9 @@ static void __init bert_print_all(struct acpi_hest_generic_status *region, } cper_estatus_print(KERN_INFO HW_ERR, estatus); + +/* Clear error status */ + estatus->block_status =0 ; next: estatus = (void *)estatus + estatus_len; remain -= estatus_len;
Signature · 1 line
2.4.3
Borislav Petkov
reviewerRe: [PATCH v2 2/2] acpi, apei, bert: Clear error status at the end of error handling
Quoted 19 lines · On Wed, Aug 19, 2015 at 12:44:17AM +0800, [email protected] wrote:
From: Tomasz Nowicki <[email protected]>
Once error log is printed out clear error status so it would not be print during next boot again.
Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Chen, Gong <[email protected]>Signed-off-by Tony Luck <[email protected]>--- drivers/acpi/apei/bert.c | 3 +++ 1 file changed, 3 insertions(+)drivers/acpi/apei/bert.c +0
-0
drivers/acpi/apei/bert.c static void __init bert_print_all(struct acpi_hest_generic_status *region, · line 73
Quoted 9 lines
drivers/acpi/apei/bert.c +3
-0@@ -65,6 +65,9 @@ static void __init bert_print_all(struct acpi_hest_generic_status *region, } cper_estatus_print(KERN_INFO HW_ERR, estatus); + +/* Clear error status */ + estatus->block_status =0 ; next: estatus = (void *)estatus + estatus_len; remain -= estatus_len;
This one should be merged with the previous patch.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Re: [Linaro-acpi] [PATCH v2 0/2] acpi, apei: add BERT support
In reply to [email protected]Quoted 11 lines · On Tue, Aug 18, 2015 at 11:44 AM, <[email protected]> wrote:
From: Fu Wei <[email protected]>
ACPI/APEI is designed to verifiy/report H/W errors, like Corrected Error(CE) and Uncorrected Error(UC). It contains four tables: HEST, ERST, EINJ and BERT. The first three tables have been merged for a long time, but because of lacking BIOS support for BERT, the support for BERT is pending until now. Recently on ARM 64 platform it is has been supported. So here we come.
The following log is a BERT record after system reboot because of hitting a fatal error.
Both patches:
on a 4.3 kernel. We'd like to see these patches merged for 4.5.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [Linaro-acpi] [PATCH v2 0/2] acpi, apei: add BERT support
Hi Tyler,
Great thanks for your testing,
But I just made a new one according to Borislav's suggestion. Please help us again, if you get some time. :-)
Thanks
Quoted 23 lines · Timur Tabi
Quoted 11 lines · On Tue, Aug 18, 2015 at 11:44 AM, <[email protected]> wrote:
From: Fu Wei <[email protected]>
ACPI/APEI is designed to verifiy/report H/W errors, like Corrected Error(CE) and Uncorrected Error(UC). It contains four tables: HEST, ERST, EINJ and BERT. The first three tables have been merged for a long time, but because of lacking BIOS support for BERT, the support for BERT is pending until now. Recently on ARM 64 platform it is has been supported. So here we come.
The following log is a BERT record after system reboot because of hitting a fatal error.
Both patches:
Tested-by Tyler Baicar <[email protected]>on a 4.3 kernel. We'd like to see these patches merged for 4.5.
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
v7 cover Watchdog: introduce ARM SBSA watchdog driver
In reply to a message not in the archiveFrom: Fu Wei <[email protected]>
This patchset:
(1)Introduce Documentation/devicetree/bindings/watchdog/sbsa-gwdt.txt for FDT info of SBSA Generic Watchdog, and give two examples of adding SBSA Generic Watchdog device node into the dts files:
foundation-v8.dts and amd-seattle-soc.dtsi.
(2)Introduce "pretimeout" into the watchdog framework, and update Documentation/watchdog/watchdog-kernel-api.txt to introduce:
(1)the new elements in the watchdog_device and watchdog_ops struct; (2)the new API "watchdog_init_timeouts".
(3)Introduce ARM SBSA watchdog driver:
a.Use linux kernel watchdog framework;
b.Work with FDT on ARM64;
c.Use "pretimeout" in watchdog framework;
d.Support getting timeout and pretimeout from parameter and FDT
at the driver init stage.
e.In the first timeout, do panic to save system context; f.In the second stage, user can still feed the dog without
cleaning WS0. By this feature, we can avoid the panic infinite loops, while backing up a large system context in a server.
g.In the second stage, can trigger WS1 by setting pretimeout = 0
if necessary.
(4)Introduce ACPI GTDT parser: drivers/acpi/gtdt.c
Parse SBSA Generic Watchdog Structure in GTDT table of ACPI, and create a platform device with that information.
This platform device can be used by This Watchdog driver. drivers/clocksource/arm_arch_timer.c is simplified by this GTDT support.
This patchset has been tested with watchdog daemon (ACPI/FDT, module/build-in) on the following platforms:
(1)ARM Foundation v8 model
Changelog:
v7: Rebase to latest kernel version(4.2-rc7).
Improve FDT support: geting resource by order, instead of name. According to the FDT support, Update the example dts file, gtdt.c and sbsa_gwdt.c.
Pass the sparse test, and fix the warning.
Fix the max_pretimeout and max_timeout value overflow bug. Delete the WCV output value.
v6: Improve the dtb example files: reduce the register frame size to 4K.
Improve pretimeout support:
(1) improve watchdog_init_timeouts function
(2) rename watchdog_check_min_max_timeouts back to the original name
(1) improve watchdog_timeout_invalid/watchdog_pretimeout_invalid
Add the new features in the sbsa_gwdt driver:
(1) In the second stage, user can feed the dog without cleaning WS0.
(2) In the second stage, user can trigger WS1 by setting pretimeout = 0.
(3) expand the max value of pretimeout, in case 10 second is not enough for a kdump kernel reboot in panic.
v5: Improve pretimeout support:
(1)fix typo in documentation and comments.
(2)fix the timeout limits validation bug.
Simplify sbsa_gwdt driver:
(1)integrate all the registers access functions into caller.
v4: Refactor GTDT support code: remove it from arch/arm64/kernel/acpi.c,
put it into drivers/acpi/gtdt.c file.
Integrate the GTDT code of drivers/clocksource/arm_arch_timer.c into
drivers/acpi/gtdt.c.
Improve pretimeout support, fix "pretimeout == 0" problem.
Simplify sbsa_gwdt driver:
(1)timeout/pretimeout limits setup;
(2)keepalive function;
(3)delete "clk == 0" check;
(4)delete WS0 status bit check in interrupt routine;
(5)sbsa_gwdt_set_wcv function.v3: Delete "export arch_timer_get_rate" patch.
Driver back to use arch_timer_get_cntfrq.
Improve watchdog_init_timeouts function and update relevant documentation. Improve watchdog_timeout_invalid and watchdog_pretimeout_invalid. Improve foundation-v8.dts: delete the unnecessary tag of device node. Remove "ARM64 || COMPILE_TEST" from Kconfig.
Add comments in arch/arm64/kernel/acpi.c
Fix typoes and incorrect comments.
v2: Improve watchdog-kernel-api.txt documentation for pretimeout support.
Export "arch_timer_get_rate" in arm_arch_timer.c.
Add watchdog_init_timeouts API for pretimeout support in framework. Improve suspend and resume foundation in driver
Improve timeout/pretimeout values init code in driver. Delete unnecessary items of the sbsa_gwdt struct and #define. Delete all unnecessary debug info in driver.
Fix 64bit division bug.
Use the arch_timer interface to get watchdog clock rate. Add MODULE_DEVICE_TABLE for platform device id.
Fix typoes.
v1: The first version upstream patchset to linux mailing list.
Fu Wei (8):
Documentation: add sbsa-gwdt.txt documentation
ARM64: add SBSA Generic Watchdog device node in foundation-v8.dts
ARM64: add SBSA Generic Watchdog device node in amd-seattle-soc.dtsi
Watchdog: introdouce "pretimeout" into framework
Watchdog: introduce ARM SBSA watchdog driver
ACPI: add GTDT table parse driver into ACPI driver
Watchdog: enable ACPI GTDT support for ARM SBSA watchdog driver
clocksource: simplify ACPI code in arm_arch_timer.c
.../devicetree/bindings/watchdog/sbsa-gwdt.txt | 32 ++ Documentation/watchdog/watchdog-kernel-api.txt | 47 ++- arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi | 8 + arch/arm64/boot/dts/arm/foundation-v8.dts | 7 + arch/arm64/kernel/time.c | 4 +- drivers/acpi/Kconfig | 9 + drivers/acpi/Makefile | 1 + drivers/acpi/gtdt.c | 178 ++++++++ drivers/clocksource/Kconfig | 1 + drivers/clocksource/arm_arch_timer.c | 60 +-- drivers/watchdog/Kconfig | 15 + drivers/watchdog/Makefile | 1 + drivers/watchdog/sbsa_gwdt.c | 459 +++++++++++++++++++++ drivers/watchdog/watchdog_core.c | 98 +++-- drivers/watchdog/watchdog_dev.c | 53 +++ include/clocksource/arm_arch_timer.h | 8 + include/linux/acpi.h | 5 + include/linux/clocksource.h | 4 +- include/linux/watchdog.h | 39 +- 19 files changed, 939 insertions(+), 90 deletions(-) create mode 100644 Documentation/devicetree/bindings/watchdog/sbsa-gwdt.txt create mode 100644 drivers/acpi/gtdt.c create mode 100644 drivers/watchdog/sbsa_gwdt.c
Signature · 1 line
2.4.3
PATCH v7 1/8 Documentation: add sbsa-gwdt.txt documentation
From: Fu Wei <[email protected]>
The sbsa-gwdt.txt documentation in devicetree/bindings/watchdog is for introducing SBSA(Server Base System Architecture) Generic Watchdog device node info into FDT.
--- .../devicetree/bindings/watchdog/sbsa-gwdt.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+)
Documentation/devicetree/bindings/watchdog/sbsa-gwdt.txt new file +32 -0
@@ -0,0 +1,32 @@ +* SBSA(Server Base System Architecture) Generic Watchdog + +The SBSA Generic Watchdog Timer is used for resetting the system after +two stages of timeout. +More details: ARM-DEN-0029 - Server Base System Architecture (SBSA) + +Required properties: +- compatible : Should at least contain "arm,sbsa-gwdt". + +- reg : Specifies base physical address of the two register frames + and length of memory mapped region, order: + 1: Watchdog control frame + 2: Refresh frame. + +- interrupts : Should at least contain WS0 interrupt, + the WS1 interrupt is optional, order: + 1: WS0 interrupt + 2: WS1 interrupt + +Optional properties +- timeout-sec : Watchdog pre-timeout and timeout values (in seconds). + The first is timeout values, then pre-timeout. + +Example for FVP Foundation Model v8: + +watchdog@2a440000 { + compatible = "arm,sbsa-gwdt"; + reg = <0x0 0x2a440000 0 0x1000>, + <0x0 0x2a450000 0 0x1000>; + interrupts = <0 27 4>; + timeout-sec = <10 5>; +};
Signature · 1 line
2.4.3
PATCH v7 2/8 ARM64: add SBSA Generic Watchdog device node in foundation-v8.dts
In reply to [email protected]From: Fu Wei <[email protected]>
This can be a example of adding SBSA Generic Watchdog device node into some dts files for the Soc which contains SBSA Generic Watchdog.
--- arch/arm64/boot/dts/arm/foundation-v8.dts | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/arm/foundation-v8.dts +7 -0
@@ -237,4 +237,11 @@ }; }; }; + watchdog@2a440000 { + compatible = "arm,sbsa-gwdt"; + reg = <0x0 0x2a440000 0 0x1000>, + <0x0 0x2a450000 0 0x1000>; + interrupts = <0 27 4>; + timeout-sec = <10 5>; + }; };
Signature · 1 line
2.4.3
Re: [PATCH v7 2/8] ARM64: add SBSA Generic Watchdog device node in foundation-v8.dts
Quoted 16 lines · On 08/25/15 at 01:01am, [email protected] wrote:
From: Fu Wei <[email protected]>
This can be a example of adding SBSA Generic Watchdog device node into some dts files for the Soc which contains SBSA Generic Watchdog.
Acked-by Arnd Bergmann <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/boot/dts/arm/foundation-v8.dts | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm64/boot/dts/arm/foundation-v8.dts +0
-0
arch/arm64/boot/dts/arm/foundation-v8.dts line 245
Quoted 9 lines
arch/arm64/boot/dts/arm/foundation-v8.dts +6
-0@@ -237,4 +237,11 @@ }; }; }; + watchdog@2a440000 { + compatible = "arm,sbsa-gwdt"; + reg = <0x0 0x2a440000 0 0x1000>, + <0x0 0x2a450000 0 0x1000>; + interrupts = <0 27 4>; + timeout-sec = <10 5>;
I assume 10 is timeout, 5 is pre timeout, but in the driver code the default value is 30/10, I think the example dts[i] should use same default values as in code.
BTW, for kdump kernel Pratyush is working on kdump on wdt enabled system. Basiclly we expect one configure longer timeout, and kick it in shorter period so we can get a chance to save vmcore. 10s sounds too short for the case..
Quoted 5 lines
arch/arm64/boot/dts/arm/foundation-v8.dts +1
-0+ }; };Signature · 1 line
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 2/8] ARM64: add SBSA Generic Watchdog device node in foundation-v8.dts
Quoted 30 lines · Dave Young
Quoted 16 lines · On 08/25/15 at 01:01am, [email protected] wrote:
From: Fu Wei <[email protected]>
This can be a example of adding SBSA Generic Watchdog device node into some dts files for the Soc which contains SBSA Generic Watchdog.
Acked-by Arnd Bergmann <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/boot/dts/arm/foundation-v8.dts | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm64/boot/dts/arm/foundation-v8.dts +0
-0arch/arm64/boot/dts/arm/foundation-v8.dts line 245
Quoted 9 lines
arch/arm64/boot/dts/arm/foundation-v8.dts +6
-0@@ -237,4 +237,11 @@ }; }; }; + watchdog@2a440000 { + compatible = "arm,sbsa-gwdt"; + reg = <0x0 0x2a440000 0 0x1000>, + <0x0 0x2a450000 0 0x1000>; + interrupts = <0 27 4>; + timeout-sec = <10 5>;I assume 10 is timeout, 5 is pre timeout, but in the driver code the default value is 30/10, I think the example dts[i] should use same default values as in code.
Quoted 3 lines
BTW, for kdump kernel Pratyush is working on kdump on wdt enabled system. Basiclly we expect one configure longer timeout, and kick it in shorter period so we can get a chance to save vmcore. 10s sounds too short for the case..
Specially if D-cache is not enabled in ARM64 kexec-tool/purgatory then its more than 2 min. Geoff has yet not agreed [1] to take D-cache support in purgatory.
[1] https://www.mail-archive.com/[email protected]/msg12881.html
~Pratyush
Re: [PATCH v7 2/8] ARM64: add SBSA Generic Watchdog device node in foundation-v8.dts
Hi Pratyush,
Quoted 31 lines · Pratyush Anand
Quoted 30 lines · Dave Young
Quoted 16 lines · On 08/25/15 at 01:01am, [email protected] wrote:
From: Fu Wei <[email protected]>
This can be a example of adding SBSA Generic Watchdog device node into some dts files for the Soc which contains SBSA Generic Watchdog.
Acked-by Arnd Bergmann <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/boot/dts/arm/foundation-v8.dts | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm64/boot/dts/arm/foundation-v8.dts +0
-0arch/arm64/boot/dts/arm/foundation-v8.dts line 245
Quoted 9 lines
arch/arm64/boot/dts/arm/foundation-v8.dts +6
-0@@ -237,4 +237,11 @@ }; }; }; + watchdog@2a440000 { + compatible = "arm,sbsa-gwdt"; + reg = <0x0 0x2a440000 0 0x1000>, + <0x0 0x2a450000 0 0x1000>; + interrupts = <0 27 4>; + timeout-sec = <10 5>;I assume 10 is timeout, 5 is pre timeout, but in the driver code the default value is 30/10, I think the example dts[i] should use same default values as in code.
Quoted 8 lines
Quoted 3 lines
BTW, for kdump kernel Pratyush is working on kdump on wdt enabled system. Basiclly we expect one configure longer timeout, and kick it in shorter period so we can get a chance to save vmcore. 10s sounds too short for the case..
Specially if D-cache is not enabled in ARM64 kexec-tool/purgatory then its more than 2 min. Geoff has yet not agreed [1] to take D-cache support in purgatory.
[1] https://www.mail-archive.com/[email protected]/msg12881.html
Great thanks for your info.
I thinks I may need to make the default pretimeout longer in example, may be at least 30s(for kdump kernel with D-cache)
any thought?
Quoted 2 lines
~Pratyush
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v7 2/8] ARM64: add SBSA Generic Watchdog device node in foundation-v8.dts
In reply to Dave YoungHi Dave,
Quoted 21 lines · Dave Young
Quoted 20 lines · On 08/25/15 at 01:01am, [email protected] wrote:
From: Fu Wei <[email protected]>
This can be a example of adding SBSA Generic Watchdog device node into some dts files for the Soc which contains SBSA Generic Watchdog.
Acked-by Arnd Bergmann <[email protected]>Signed-off-by Fu Wei <[email protected]>--- arch/arm64/boot/dts/arm/foundation-v8.dts | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm64/boot/dts/arm/foundation-v8.dts +1
-0@@ -237,4 +237,11 @@ }; }; }; + watchdog@2a440000 {
Quoted 8 lines
arch/arm64/boot/dts/arm/foundation-v8.dts line 245
Quoted 5 lines
arch/arm64/boot/dts/arm/foundation-v8.dts +5
-0+ compatible = "arm,sbsa-gwdt"; + reg = <0x0 0x2a440000 0 0x1000>, + <0x0 0x2a450000 0 0x1000>; + interrupts = <0 27 4>; + timeout-sec = <10 5>;I assume 10 is timeout, 5 is pre timeout, but in the driver code the default value is 30/10, I think the example dts[i] should use same default values as in code.
yes, that is good idea, will make them to be the same. :-)
Quoted 4 lines
BTW, for kdump kernel Pratyush is working on kdump on wdt enabled system. Basiclly we expect one configure longer timeout, and kick it in shorter period so we can get a chance to save vmcore. 10s sounds too short for the case..
Thanks for your info.
So that means: we may need that long timeout support in the second stage. WOR is not enough for the second stage in most of kdump case.
Quoted 6 lines
Quoted 6 lines
arch/arm64/boot/dts/arm/foundation-v8.dts +1
-1+ }; }; --2.4.3
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
PATCH v7 3/8 ARM64: add SBSA Generic Watchdog device node in amd-seattle-soc.dtsi
In reply to [email protected]From: Fu Wei <[email protected]>
This can be a example of adding SBSA Generic Watchdog device node into some dts files for the Soc which contains SBSA Generic Watchdog.
--- arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/amd/amd-seattle-soc.dtsi +8 -0
@@ -84,6 +84,14 @@ clock-names = "uartclk", "apb_pclk"; }; + watchdog0: watchdog@e0bb0000 { + compatible = "arm,sbsa-gwdt"; + reg = <0x0 0xe0bc0000 0 0x1000>, + <0x0 0xe0bb0000 0 0x1000>; + interrupts = <0 337 4>; + timeout-sec = <10 5>; + }; + spi0: ssp@e1020000 { status = "disabled"; compatible = "arm,pl022", "arm,primecell";
Signature · 1 line
2.4.3
PATCH v7 4/8 Watchdog: introdouce "pretimeout" into framework
In reply to [email protected]From: Fu Wei <[email protected]>
Also update Documentation/watchdog/watchdog-kernel-api.txt to introduce:
(1)the new elements in the watchdog_device and watchdog_ops struct; (2)the new API "watchdog_init_timeouts"
Reasons:
(1)kernel already has two watchdog drivers are using "pretimeout":
drivers/char/ipmi/ipmi_watchdog.c drivers/watchdog/kempld_wdt.c(but the definition is different)
(2)some other drivers are going to use this: ARM SBSA Generic Watchdog
--- Documentation/watchdog/watchdog-kernel-api.txt | 47 ++++++++++-- drivers/watchdog/watchdog_core.c | 98 ++++++++++++++++++-------- drivers/watchdog/watchdog_dev.c | 53 ++++++++++++++ include/linux/watchdog.h | 39 ++++++++-- 4 files changed, 200 insertions(+), 37 deletions(-)
Documentation/watchdog/watchdog-kernel-api.txt +42 -5
@@ -53,6 +53,9 @@ struct watchdog_device { unsigned int timeout; unsigned int min_timeout; unsigned int max_timeout; + unsigned int pretimeout; + unsigned int min_pretimeout; + unsigned int max_pretimeout; void *driver_data; struct mutex lock; unsigned long status;
@@ -75,6 +78,9 @@ It contains following fields: * timeout: the watchdog timer's timeout value (in seconds). * min_timeout: the watchdog timer's minimum timeout value (in seconds). * max_timeout: the watchdog timer's maximum timeout value (in seconds). +* pretimeout: the watchdog timer's pretimeout value (in seconds). +* min_pretimeout: the watchdog timer's minimum pretimeout value (in seconds). +* max_pretimeout: the watchdog timer's maximum pretimeout value (in seconds). * bootstatus: status of the device after booting (reported with watchdog WDIOF_* status bits). * driver_data: a pointer to the drivers private data of a watchdog device.
@@ -99,6 +105,7 @@ struct watchdog_ops { int (*ping)(struct watchdog_device *); unsigned int (*status)(struct watchdog_device *); int (*set_timeout)(struct watchdog_device *, unsigned int); + int (*set_pretimeout)(struct watchdog_device *, unsigned int); unsigned int (*get_timeleft)(struct watchdog_device *); void (*ref)(struct watchdog_device *); void (*unref)(struct watchdog_device *);
@@ -160,9 +167,19 @@ they are supported. These optional routines/operations are: and -EIO for "could not write value to the watchdog". On success this routine should set the timeout value of the watchdog_device to the achieved timeout value (which may be different from the requested one - because the watchdog does not necessarily has a 1 second resolution). + because the watchdog does not necessarily has a 1 second resolution; + If the driver supports pretimeout, then the timeout value must be greater + than that). (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the watchdog's info structure). +* set_pretimeout: this routine checks and changes the pretimeout of the + watchdog timer device. It returns 0 on success, -EINVAL for "parameter out of + range" and -EIO for "could not write value to the watchdog". On success this + routine should set the pretimeout value of the watchdog_device to the + achieved pretimeout value (which may be different from the requested one + because the watchdog does not necessarily has a 1 second resolution). + (Note: the WDIOF_PRETIMEOUT needs to be set in the options field of the + watchdog's info structure). * get_timeleft: this routines returns the time that's left before a reset. * ref: the operation that calls kref_get on the kref of a dynamically allocated watchdog_device struct.
@@ -226,8 +243,28 @@ extern int watchdog_init_timeout(struct watchdog_device *wdd, unsigned int timeout_parm, struct device *dev); The watchdog_init_timeout function allows you to initialize the timeout field -using the module timeout parameter or by retrieving the timeout-sec property from -the device tree (if the module timeout parameter is invalid). Best practice is -to set the default timeout value as timeout value in the watchdog_device and -then use this function to set the user "preferred" timeout value. +using the module timeout parameter or by retrieving the first element of +the timeout-sec property from the device tree (if the module timeout parameter +is invalid). Best practice is to set the default timeout value as timeout value +in the watchdog_device and then use this function to set the user "preferred" +timeout value. +This routine returns zero on success and a negative errno code for failure. + +Some watchdog timers have two stage of timeouts (timeout and pretimeout), +to initialize the timeout and pretimeout fields at the same time, the following +function can be used: + +int watchdog_init_timeouts(struct watchdog_device *wdd, + unsigned int pretimeout_parm, + unsigned int timeout_parm, + struct device *dev); + +The watchdog_init_timeouts function allows you to initialize the pretimeout and +timeout fields using the module pretimeout and timeout parameter or by +retrieving the elements in the timeout-sec property (the first element is for +timeout, the second one is for pretimeout) from the device tree (if the module +pretimeout and timeout parameter are invalid). +Best practice is to set the default pretimeout and timeout value as pretimeout +and timeout value in the watchdog_device and then use this function to set the +user "preferred" pretimeout value. This routine returns zero on success and a negative errno code for failure.
drivers/watchdog/watchdog_core.c +70 -28
127 lines not on this page · raw message
drivers/watchdog/watchdog_dev.c +53 -0
65 lines not on this page · raw message
include/linux/watchdog.h +35 -4
@@ -25,6 +25,7 @@ struct watchdog_device;* @ping: The routine that sends a keepalive ping to the watchdog device. * @status: The routine that shows the status of the watchdog device. * @set_timeout:The routine for setting the watchdog devices timeout value. +* @set_pretimeout:The routine for setting the watchdog devices pretimeout value * @get_timeleft:The routine that get's the time that's left before a reset. * @ref: The ref operation for dyn. allocated watchdog_device structs * @unref: The unref operation for dyn. allocated watchdog_device structs
@@ -44,6 +45,7 @@ struct watchdog_ops {int (*ping)(struct watchdog_device *);unsigned int (*status)(struct watchdog_device *);int (*set_timeout)(struct watchdog_device *,unsigned int ); +int (*set_pretimeout)(struct watchdog_device *,unsigned int );unsigned int (*get_timeleft)(struct watchdog_device *);void (*ref)(struct watchdog_device *);void (*unref)(struct watchdog_device *);
@@ -62,6 +64,9 @@ struct watchdog_ops {* @timeout: The watchdog devices timeout value. * @min_timeout:The watchdog devices minimum timeout value. * @max_timeout:The watchdog devices maximum timeout value. +* @pretimeout: The watchdog devices pretimeout value. +* @min_pretimeout:The watchdog devices minimum pretimeout value. +* @max_pretimeout:The watchdog devices maximum pretimeout value. * @driver-data:Pointer to the drivers private data. * @lock: Lock for watchdog core internal use only. * @status: Field that contains the devices internal status bits.
@@ -88,6 +93,9 @@ struct watchdog_device {unsigned int timeout;unsigned int min_timeout;unsigned int max_timeout; +unsigned int pretimeout; +unsigned int min_pretimeout; +unsigned int max_pretimeout;void *driver_data;struct mutex lock;unsigned long status;
@@ -119,8 +127,22 @@ static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool noway/* Use the following function to check if a timeout value is invalid */ static inline bool watchdog_timeout_invalid (struct watchdog_device *wdd,unsigned int t) { -return ((wdd->max_timeout !=0 ) && - (t < wdd->min_timeout || t > wdd->max_timeout)); +return (wdd->max_timeout && + (t < wdd->min_timeout || t > wdd->max_timeout)) || + (wdd->pretimeout && t <= wdd->pretimeout); +} + +/* +* Use the following function to check if a pretimeout value is invalid. +* It can be "0", that means we don't use pretimeout. +* This function returns false, when pretimeout is 0. +*/ +static inline bool watchdog_pretimeout_invalid (struct watchdog_device *wdd, +unsigned int t) +{ +return t && ((wdd->max_pretimeout && + (t < wdd->min_pretimeout || t > wdd->max_pretimeout)) || + (wdd->timeout && t >= wdd->timeout)); }/* Use the following functions to manipulate watchdog driver specific data */
@@ -135,8 +157,17 @@ static inline void *watchdog_get_drvdata(struct watchdog_device *wdd) }/* drivers/watchdog/watchdog_core.c */ -extern int watchdog_init_timeout (struct watchdog_device *wdd, -unsigned int timeout_parm,struct device *dev); +int watchdog_init_timeouts (struct watchdog_device *wdd, +unsigned int pretimeout_parm, +unsigned int timeout_parm, +struct device *dev); +static inline int watchdog_init_timeout (struct watchdog_device *wdd, +unsigned int timeout_parm, +struct device *dev) +{ +return watchdog_init_timeouts (wdd,0 , timeout_parm, dev); +} +extern int watchdog_register_device (struct watchdog_device *);extern void watchdog_unregister_device (struct watchdog_device *);
Signature · 1 line
2.4.3
PATCH v7 5/8 Watchdog: introduce ARM SBSA watchdog driver
In reply to [email protected]From: Fu Wei <[email protected]>
This driver bases on linux kernel watchdog framework, and use "pretimeout" in the framework. It supports getting timeout and pretimeout from parameter and FDT at the driver init stage. In first timeout, the interrupt routine run panic to save system context.
--- drivers/watchdog/Kconfig | 14 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sbsa_gwdt.c | 459 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 474 insertions(+)
drivers/watchdog/Kconfig +14 -0
@@ -173,6 +173,20 @@ config ARM_SP805_WATCHDOG ARM Primecell SP805 Watchdog timer. This will reboot your system when the timeout is reached. +config ARM_SBSA_WATCHDOG + tristate "ARM SBSA Generic Watchdog" + depends on ARM64 + depends on ARM_ARCH_TIMER + select WATCHDOG_CORE + help + ARM SBSA Generic Watchdog. This watchdog has two Watchdog timeouts. + The first timeout will trigger a panic; the second timeout will + trigger a system reset. + More details: ARM DEN0029B - Server Base System Architecture (SBSA) + + To compile this driver as module, choose M here: The module + will be called sbsa_gwdt. + config AT91RM9200_WATCHDOG tristate "AT91RM9200 watchdog" depends on SOC_AT91RM9200 && MFD_SYSCON
drivers/watchdog/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o # ARM Architecture obj-$(CONFIG_ARM_SP805_WATCHDOG) += sp805_wdt.o +obj-$(CONFIG_ARM_SBSA_WATCHDOG) += sbsa_gwdt.o obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_CADENCE_WATCHDOG) += cadence_wdt.o
drivers/watchdog/sbsa_gwdt.c new file +459 -0
459 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH v7 5/8] Watchdog: introduce ARM SBSA watchdog driver
drivers/watchdog/sbsa_gwdt.c line 321
Quoted 6 lines · On 08/24/2015 01:01 PM, [email protected] wrote:
drivers/watchdog/sbsa_gwdt.c new file +6
-0+/* +* Get the frequency of system counter from the cp15 interface of ARM +* Generic timer. We don't need to check it, because if it returns "0", +* system would panic in very early stage. +*/ + gwdt->clk =arch_timer_get_cntfrq ();
Just thinking out loud...
What happens later if we virtualize this device within KVM/QEMU/Xen and then live migrate to another system in which the frequency changes?
Jon.
Guenter Roeck
maintainerRe: [PATCH v7 5/8] Watchdog: introduce ARM SBSA watchdog driver
Quoted 11 lines · Jon Masters
drivers/watchdog/sbsa_gwdt.c line 321
Quoted 6 lines · On 08/24/2015 01:01 PM, [email protected] wrote:
drivers/watchdog/sbsa_gwdt.c new file +6
-0+/* +* Get the frequency of system counter from the cp15 interface of ARM +* Generic timer. We don't need to check it, because if it returns "0", +* system would panic in very early stage. +*/ + gwdt->clk =arch_timer_get_cntfrq ();Just thinking out loud...
Quoted 3 lines
What happens later if we virtualize this device within KVM/QEMU/Xen and then live migrate to another system in which the frequency changes?
I don't know, but I would suspect that we might end up in all kinds of trouble if clocks can change like that, and not just in this driver. Many drivers make the assumption that clock rates are not changed under the hood. If it can happen, shouldn't there be a callback into the drivers using the affected clock(s) ?
Also, it seems to me that changing a clock like that would be inherently unsafe. For example, what will happen if the system is stopped and migrated right after the clock frequency is read, but before the returned value is used ? Can that happen ? Or does it only happen during suspend/resume cycles, if it happens ?
Thanks,
Guenter
Guenter Roeck
maintainerRe: [PATCH v7 5/8] Watchdog: introduce ARM SBSA watchdog driver
In reply to Jon MastersQuoted 11 lines · Jon Masters
drivers/watchdog/sbsa_gwdt.c line 321
Quoted 6 lines · On 08/24/2015 01:01 PM, [email protected] wrote:
drivers/watchdog/sbsa_gwdt.c new file +6
-0+/* +* Get the frequency of system counter from the cp15 interface of ARM +* Generic timer. We don't need to check it, because if it returns "0", +* system would panic in very early stage. +*/ + gwdt->clk =arch_timer_get_cntfrq ();Just thinking out loud...
Quoted 3 lines
What happens later if we virtualize this device within KVM/QEMU/Xen and then live migrate to another system in which the frequency changes?
Thinking about it, this scenario would cause severe trouble. I think clocks (like I would assume pretty much all other hardware parameters / registers) need to be virtualized and must not change.
Example: clock is set to 100 kHz on original system, and 400 kHz on new system. Timeout is set to 30s, and registers are programmed accordingly. User space sends heartbeats every 15 seconds.
In this scenario, the watchdog would time out after 30/4 = 7.5 seconds on the new system, or in other words almost immediately.
This would be even worse if the original system had a clock of, say, 10 kHz and the new system would use 400 kHz. This just doesn't work.
Guenter
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 5/8] Watchdog: introduce ARM SBSA watchdog driver
Hi Guenter, Jon,
Quoted 28 lines · Guenter Roeck
Quoted 13 lines · Jon Masters
drivers/watchdog/sbsa_gwdt.c line 321
Quoted 8 lines · On 08/24/2015 01:01 PM, [email protected] wrote:
(quoted diff) +2
-0+ /* + * Get the frequency of system counter from the cp15 interface ofARM
+ * Generic timer. We don't need to check it, because if it
returns "0",drivers/watchdog/sbsa_gwdt.c new file +3
-0+* system would panic in very early stage. +*/ + gwdt->clk =arch_timer_get_cntfrq ();Quoted 5 lines
Just thinking out loud...
What happens later if we virtualize this device within KVM/QEMU/Xen and then live migrate to another system in which the frequency changes?
Thinking about it, this scenario would cause severe trouble. I think clocks (like I would assume pretty much all other hardware parameters / registers) need to be virtualized and must not change.
Example: clock is set to 100 kHz on original system, and 400 kHz on new system. Timeout is set to 30s, and registers are programmed accordingly. User space sends heartbeats every 15 seconds.
Quoted 5 lines
In this scenario, the watchdog would time out after 30/4 = 7.5 seconds on the new system, or in other words almost immediately.
This would be even worse if the original system had a clock of, say, 10 kHz and the new system would use 400 kHz. This just doesn't work.
I have rechecked the SBSA spec and "Architecture Reference Manual(ARM)", I think we don't need to worry about "the frequency changes", let me explain this, but if I misunderstand something, please correct me!
(1) what is the clock source (or reference) of SBSA watchdog timer? SBSA spec(2.3) has answered this well at page 23:
---------------------------
The Watchdog uses the Generic Timer system count value as the timebase against which the decision to trigger an interrupt is made.
---------------------------
(2) Can the frequency of the Generic Timer System counter be changed? At ARMv8 ARM, D6.1.1 System counter :
---------------------------
The Generic Timer provides a system counter with the following specification:
Frequency
Increments at *a fixed frequency*, typically in the range 1-50MHz. Can support one or more alternative operating modes in which it increments by larger amounts at a lower frequency, typically for power-saving.
To support lower-power operating modes, the counter can increment by larger amounts at a lower frequency. For example, a 10MHz system counter might either increment either:
• By 1 at 10MHz.
• By 500 at 20kHz,
when the system lowers the clock frequency, to reduce power consumption. In this case, the counter must support transitions between high-frequency, high-precision operation, and lower-frequency, lower-precision operation, without any impact on the required accuracy of the counter.
---------------------------
So even the frequency of the Generic Timer System counter be changed by some reason(typically for power-saving), this won't affect the timeout(and pretimeout) of watchdog, the actual time will be always right.
*we were talking about real hardware above. Now we think about virtualization.*
(3) if the virtual watchdog device in KVM/QEMU/Xen is migrated to another system in which the frequency changes, will it affect the "dog feeding procedure"?
I don't think so.
if the frequency changes, the frequency of System counter is changed. But in ARM system, System counter is a global reference for all clocks or timers(per-cpu and Memory-mapped).
So if System counter is getting faster, everything in this virtual
machine is getting faster, and vice versa.
Now we use the example above
if clock is set to 100 kHz on original system, and 400 kHz on new system. Timeout is set to 30s, and registers are programmed accordingly. User space sends heartbeats every 15 seconds.
In this scenario, On the new system, the watchdog would time out after 30/4 = 7.5 seconds.
* User space sends heartbeats every 15/4 = 3.25 second now , but NOT 15 seconds.*
If everything goes well, system will keep running.
Hope I understand the question correctly, please correct me if I miss something or said anything wrong.
Great thanks for your feedback!
Quoted 3 lines
Guenter
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v7 5/8] Watchdog: introduce ARM SBSA watchdog driver
In reply to [email protected]Quoted 79 lines · On 08/25/15 at 01:01am, [email protected] wrote:
From: Fu Wei <[email protected]>
This driver bases on linux kernel watchdog framework, and use "pretimeout" in the framework. It supports getting timeout and pretimeout from parameter and FDT at the driver init stage. In first timeout, the interrupt routine run panic to save system context.
Signed-off-by Fu Wei <[email protected]>--- drivers/watchdog/Kconfig | 14 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sbsa_gwdt.c | 459 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 474 insertions(+)drivers/watchdog/Kconfig +14
-0@@ -173,6 +173,20 @@ config ARM_SP805_WATCHDOG ARM Primecell SP805 Watchdog timer. This will reboot your system when the timeout is reached. +config ARM_SBSA_WATCHDOG + tristate "ARM SBSA Generic Watchdog" + depends on ARM64 + depends on ARM_ARCH_TIMER + select WATCHDOG_CORE + help + ARM SBSA Generic Watchdog. This watchdog has two Watchdog timeouts. + The first timeout will trigger a panic; the second timeout will + trigger a system reset. + More details: ARM DEN0029B - Server Base System Architecture (SBSA) + + To compile this driver as module, choose M here: The module + will be called sbsa_gwdt. + config AT91RM9200_WATCHDOG tristate "AT91RM9200 watchdog" depends on SOC_AT91RM9200 && MFD_SYSCONdrivers/watchdog/Makefile +1
-0@@ -30,6 +30,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o # ARM Architecture obj-$(CONFIG_ARM_SP805_WATCHDOG) += sp805_wdt.o +obj-$(CONFIG_ARM_SBSA_WATCHDOG) += sbsa_gwdt.o obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_CADENCE_WATCHDOG) += cadence_wdt.odrivers/watchdog/sbsa_gwdt.c new file +21
-0@@ -0,0 +1,459 @@ +/* +* SBSA(Server Base System Architecture) Generic Watchdog driver +* +* Copyright (c) 2015, Linaro Ltd. +* Author: Fu Wei <[email protected]> +* Suravee Suthikulpanit <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* The SBSA Generic watchdog driver is compatible with the pretimeout +* concept of Linux kernel. +* The timeout and pretimeout are determined by WCV or WOR. +* The first watch period is set by writing WCV directly, that can +* support more than 10s timeout at the maximum system counter
drivers/watchdog/sbsa_gwdt.c line 31
Quoted 10 lines
drivers/watchdog/sbsa_gwdt.c new file +10
-0+* frequency (400MHz). +* When WS0 is triggered, the second watch period (pretimeout) is +* determined by one of these registers: +* (1)WOR: 32bit register, this gives a maximum watch period of +* around 10s at the maximum system counter frequency. It's loaded +* automatically by hardware. +* (2)WCV: If the pretimeout value is greater then "max_wor_timeout", +* it will be loaded in WS0 interrupt routine. If system is in +* ws0_mode (reboot by kexec/kdump in panic with watchdog enabled +* and WS0 == true), the ping operation will only reload WCV.
Below is the field comment about ws0_mode, it says ws0_mode is only for rebooting in second stage timeout, but kexec/kdump can reboot in either first or second stage
* @ws0_mode: indicate the system boot in the second stage timeout.
Quoted 431 lines
drivers/watchdog/sbsa_gwdt.c new file +428
-0+* More details about the hardware specification of this device: +* ARM DEN0029B - Server Base System Architecture (SBSA) +* +* Kernel/API: P------------------| pretimeout +* |----------------------------------------T timeout +* SBSA GWDT: P---WOR (or WCV)---WS1 pretimeout +* |-------WCV----------WS0~~~(ws0_mode)~~~~T timeout +*/ + +#include <linux/io.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/uaccess.h> +#include <linux/watchdog.h> +#include <asm/arch_timer.h> + +/* SBSA Generic Watchdog register definitions */ +/* refresh frame */ +#define SBSA_GWDT_WRR 0x000 + +/* control frame */ +#define SBSA_GWDT_WCS 0x000 +#define SBSA_GWDT_WOR 0x008 +#define SBSA_GWDT_WCV_LO 0x010 +#define SBSA_GWDT_WCV_HI 0x014 + +/* refresh/control frame */ +#define SBSA_GWDT_W_IIDR 0xfcc +#define SBSA_GWDT_IDR 0xfd0 + +/* Watchdog Control and Status Register */ +#define SBSA_GWDT_WCS_EN BIT(0) +#define SBSA_GWDT_WCS_WS0 BIT(1) +#define SBSA_GWDT_WCS_WS1 BIT(2) + +/** +* struct sbsa_gwdt - Internal representation of the SBSA GWDT +* @wdd: kernel watchdog_device structure +* @clk: store the System Counter clock frequency, in Hz. +* @ws0_mode: indicate the system boot in the second stage timeout. +* @max_wor_timeout: the maximum timeout value for WOR (in seconds). +* @refresh_base: Virtual address of the watchdog refresh frame +* @control_base: Virtual address of the watchdog control frame +*/ +struct sbsa_gwdt { +struct watchdog_device wdd; +u32 clk; +bool ws0_mode; +int max_wor_timeout; +void __iomem *refresh_base; +void __iomem *control_base; +}; + +#define to_sbsa_gwdt (e) container_of(e, struct sbsa_gwdt, wdd) + +#define DEFAULT_TIMEOUT 30/* seconds, the 1st + 2nd watch periods*/ +#define DEFAULT_PRETIMEOUT 10/* seconds, the 2nd watch period*/ + +static unsigned int timeout; +module_param (timeout, uint,0 ); +MODULE_PARM_DESC (timeout, + "Watchdog timeout in seconds. (>=0, default=" + __MODULE_STRING(DEFAULT_TIMEOUT) ")"); + +static unsigned int pretimeout; +module_param (pretimeout, uint,0 ); +MODULE_PARM_DESC (pretimeout, + "Watchdog pretimeout in seconds. (>=0, default=" + __MODULE_STRING(DEFAULT_PRETIMEOUT) ")"); + +static bool nowayout =WATCHDOG_NOWAYOUT ; +module_param (nowayout, bool,S_IRUGO ); +MODULE_PARM_DESC (nowayout, + "Watchdog cannot be stopped once started (default=" + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); + +/* +* help functions for accessing 64bit WCV register +*/ +static u64 sbsa_gwdt_get_wcv (struct watchdog_device *wdd) +{ +u32 wcv_lo, wcv_hi; +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); + +do { + wcv_hi =readl_relaxed (gwdt->control_base +SBSA_GWDT_WCV_HI ); + wcv_lo =readl_relaxed (gwdt->control_base +SBSA_GWDT_WCV_LO ); + }while (wcv_hi !=readl_relaxed (gwdt->control_base + +SBSA_GWDT_WCV_HI )); + +return (((u64 )wcv_hi <<32 ) | wcv_lo); +} + +static void sbsa_gwdt_set_wcv (struct watchdog_device *wdd,unsigned int t) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); +u64 wcv; + + wcv =arch_counter_get_cntvct () + (u64 )t * gwdt->clk; + +writel_relaxed (upper_32_bits (wcv), + gwdt->control_base +SBSA_GWDT_WCV_HI ); +writel_relaxed (lower_32_bits (wcv), + gwdt->control_base +SBSA_GWDT_WCV_LO ); +} + +/* +* inline functions for reloading 64bit WCV register +*/ +static inline void reload_pretimeout_to_wcv (struct watchdog_device *wdd) +{ +sbsa_gwdt_set_wcv (wdd, wdd->pretimeout); +} + +static inline void reload_first_stage_to_wcv (struct watchdog_device *wdd) +{ +sbsa_gwdt_set_wcv (wdd, wdd->timeout - wdd->pretimeout); +} + +/* +* watchdog operation functions +*/ +static int sbsa_gwdt_set_timeout (struct watchdog_device *wdd, +unsigned int timeout) +{ + wdd->timeout = timeout; + +return 0 ; +} + +static int sbsa_gwdt_set_pretimeout (struct watchdog_device *wdd, +unsigned int pretimeout) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); +u32 wor; + + wdd->pretimeout = pretimeout; + +/* If ws0_mode == true, we won't touch WOR */ +if (!gwdt->ws0_mode) { +if (!pretimeout) +/* +* If pretimeout is 0, it gives driver a timeslot (1s) +* to update WCV after an explicit refresh +* (sbsa_gwdt_start) +*/ + wor = gwdt->clk; +else +if (pretimeout > gwdt->max_wor_timeout) + wor =U32_MAX ; +else + wor = pretimeout * gwdt->clk; + +/* wtite WOR, that will cause an explicit watchdog refresh */ +writel_relaxed (wor, gwdt->control_base +SBSA_GWDT_WOR ); + } + +return 0 ; +} + +static unsigned int sbsa_gwdt_get_timeleft (struct watchdog_device *wdd) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); +u64 timeleft =sbsa_gwdt_get_wcv (wdd) -arch_counter_get_cntvct (); + +do_div (timeleft, gwdt->clk); + +return timeleft; +} + +static int sbsa_gwdt_keepalive (struct watchdog_device *wdd) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); + +if (gwdt->ws0_mode) +reload_pretimeout_to_wcv (wdd); +else +reload_first_stage_to_wcv (wdd); + +return 0 ; +} + +static int sbsa_gwdt_start (struct watchdog_device *wdd) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); + +/* If ws0_mode == true, the watchdog is enabled */ +if (!gwdt->ws0_mode) +/* writing WCS will cause an explicit watchdog refresh */ +writel_relaxed (SBSA_GWDT_WCS_EN , + gwdt->control_base +SBSA_GWDT_WCS ); + +return sbsa_gwdt_keepalive (wdd); +} + +static int sbsa_gwdt_stop (struct watchdog_device *wdd) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); + +writel_relaxed (0 , gwdt->control_base +SBSA_GWDT_WCS ); +/* +* Writing WCS has caused an explicit watchdog refresh. +* Both watchdog signals are deasserted, so clean ws0_mode flag. +*/ + gwdt->ws0_mode = false; + +return 0 ; +} + +static irqreturn_t sbsa_gwdt_interrupt (int irq,void *dev_id) +{ +struct sbsa_gwdt *gwdt = (struct sbsa_gwdt *)dev_id; +struct watchdog_device *wdd = &gwdt->wdd; + +/* We don't use pretimeout, trigger WS1 now */ +if (!wdd->pretimeout) +sbsa_gwdt_set_wcv (wdd,0 ); + +/* +* The pretimeout is valid, go panic +* If pretimeout is greater then "max_wor_timeout", +* reload the right value to WCV, then panic +*/ +if (wdd->pretimeout > gwdt->max_wor_timeout) +reload_pretimeout_to_wcv (wdd); +panic ("SBSA Watchdog pre-timeout" ); + +return IRQ_HANDLED ; +} + +static struct watchdog_info sbsa_gwdt_info = { + .identity ="SBSA Generic Watchdog" , + .options =WDIOF_SETTIMEOUT | +WDIOF_KEEPALIVEPING | +WDIOF_MAGICCLOSE | +WDIOF_PRETIMEOUT | +WDIOF_CARDRESET , +}; + +static struct watchdog_ops sbsa_gwdt_ops = { + .owner =THIS_MODULE , + .start = sbsa_gwdt_start, + .stop = sbsa_gwdt_stop, + .ping = sbsa_gwdt_keepalive, + .set_timeout = sbsa_gwdt_set_timeout, + .set_pretimeout = sbsa_gwdt_set_pretimeout, + .get_timeleft = sbsa_gwdt_get_timeleft, +}; + +static int sbsa_gwdt_probe (struct platform_device *pdev) +{ +void __iomem *rf_base, *cf_base; +struct device *dev = &pdev->dev; +struct watchdog_device *wdd; +struct sbsa_gwdt *gwdt; +struct resource *res; +int ret, irq; +u32 status; + + gwdt =devm_kzalloc (dev,sizeof (*gwdt),GFP_KERNEL ); +if (!gwdt) +return -ENOMEM ; +platform_set_drvdata (pdev, gwdt); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + cf_base =devm_ioremap_resource (dev, res); +if (IS_ERR (cf_base)) +return PTR_ERR (cf_base); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); + rf_base =devm_ioremap_resource (dev, res); +if (IS_ERR (rf_base)) +return PTR_ERR (rf_base); + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +dev_err (dev,"unable to get ws0 interrupt.\n" ); +return irq; + } + +/* +* Get the frequency of system counter from the cp15 interface of ARM +* Generic timer. We don't need to check it, because if it returns "0", +* system would panic in very early stage. +*/ + gwdt->clk =arch_timer_get_cntfrq (); + gwdt->refresh_base = rf_base; + gwdt->control_base = cf_base; + gwdt->max_wor_timeout =U32_MAX / gwdt->clk; + gwdt->ws0_mode = false; + + wdd = &gwdt->wdd; + wdd->parent = dev; + wdd->info = &sbsa_gwdt_info; + wdd->ops = &sbsa_gwdt_ops; +watchdog_set_drvdata (wdd, gwdt); +watchdog_set_nowayout (wdd, nowayout); + + wdd->min_pretimeout =0 ; + wdd->min_timeout =1 ; + +/* +* Because the maximum of gwdt->clk is 400MHz and the maximum of WCV is +* U64_MAX, so the result of (U64_MAX / gwdt->clk) is always greater +* than U32_MAX. And the maximum of "unsigned int" is U32_MAX on ARM64. +* So we set the maximum value of pretimeout and timeout below. +*/ + wdd->max_pretimeout =U32_MAX -1 ; + wdd->max_timeout =U32_MAX ; + + wdd->pretimeout =DEFAULT_PRETIMEOUT ; + wdd->timeout =DEFAULT_TIMEOUT ; +watchdog_init_timeouts (wdd, pretimeout, timeout, dev); + + status =readl_relaxed (gwdt->control_base +SBSA_GWDT_WCS ); +if (status &SBSA_GWDT_WCS_WS1 ) { +dev_warn (dev,"System reset by WDT.\n" ); + wdd->bootstatus |=WDIOF_CARDRESET ; + }else if (status == (SBSA_GWDT_WCS_WS0 |SBSA_GWDT_WCS_EN )) { + gwdt->ws0_mode = true; + } + + ret =devm_request_irq (dev, irq, sbsa_gwdt_interrupt,0 , + pdev->name, gwdt); +if (ret) { +dev_err (dev,"unable to request IRQ %d\n" , irq); +return ret; + } + + ret =watchdog_register_device (wdd); +if (ret) +return ret; + +/* If ws0_mode == true, the line won't update WOR */ +sbsa_gwdt_set_pretimeout (wdd, wdd->pretimeout); + +/* +* If watchdog is already enabled, do a ping operation +* to keep system running +*/ +if (status &SBSA_GWDT_WCS_EN ) +sbsa_gwdt_keepalive (wdd); + +dev_info (dev,"Initialized with %ds timeout, %ds pretimeout @ %u Hz%s\n" , + wdd->timeout, wdd->pretimeout, gwdt->clk, + status &SBSA_GWDT_WCS_EN ? + gwdt->ws0_mode ?" [second stage]" :" [enabled]" : +"" ); + +return 0 ; +} + +static void sbsa_gwdt_shutdown (struct platform_device *pdev) +{ +struct sbsa_gwdt *gwdt =platform_get_drvdata (pdev); + +sbsa_gwdt_stop (&gwdt->wdd); +} + +static int sbsa_gwdt_remove (struct platform_device *pdev) +{ +struct sbsa_gwdt *gwdt =platform_get_drvdata (pdev); + +watchdog_unregister_device (&gwdt->wdd); + +return 0 ; +} + +/* Disable watchdog if it is active during suspend */ +static int __maybe_unused sbsa_gwdt_suspend (struct device *dev) +{ +struct sbsa_gwdt *gwdt =dev_get_drvdata (dev); + +if (watchdog_active (&gwdt->wdd)) +sbsa_gwdt_stop (&gwdt->wdd); + +return 0 ; +} + +/* Enable watchdog and configure it if necessary */ +static int __maybe_unused sbsa_gwdt_resume (struct device *dev) +{ +struct sbsa_gwdt *gwdt =dev_get_drvdata (dev); + +if (watchdog_active (&gwdt->wdd)) +sbsa_gwdt_start (&gwdt->wdd); + +return 0 ; +} + +static const struct dev_pm_ops sbsa_gwdt_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (sbsa_gwdt_suspend, sbsa_gwdt_resume) +}; + +static const struct of_device_id sbsa_gwdt_of_match[] = { + { .compatible ="arm,sbsa-gwdt" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, sbsa_gwdt_of_match); + +static const struct platform_device_id sbsa_gwdt_pdev_match[] = { + { .name ="sbsa-gwdt" , }, + {}, +}; +MODULE_DEVICE_TABLE (platform, sbsa_gwdt_pdev_match); + +static struct platform_driver sbsa_gwdt_driver = { + .driver = { + .name ="sbsa-gwdt" , + .pm = &sbsa_gwdt_pm_ops, + .of_match_table = sbsa_gwdt_of_match, + }, + .probe = sbsa_gwdt_probe, + .remove = sbsa_gwdt_remove, + .shutdown = sbsa_gwdt_shutdown, + .id_table = sbsa_gwdt_pdev_match, +}; + +module_platform_driver (sbsa_gwdt_driver); + +MODULE_DESCRIPTION ("SBSA Generic Watchdog Driver" ); +MODULE_AUTHOR ("Fu Wei <[email protected]>" ); +MODULE_AUTHOR ("Suravee Suthikulpanit <[email protected]>" ); +MODULE_LICENSE ("GPL v2" );Signature · 1 line
2.4.3
Re: [PATCH v7 5/8] Watchdog: introduce ARM SBSA watchdog driver
Hi Dave,
Quoted 86 lines · Dave Young
Quoted 85 lines · On 08/25/15 at 01:01am, [email protected] wrote:
From: Fu Wei <[email protected]>
This driver bases on linux kernel watchdog framework, and use "pretimeout" in the framework. It supports getting timeout and pretimeout from parameter and FDT at the driver init stage. In first timeout, the interrupt routine run panic to save system context.
Signed-off-by Fu Wei <[email protected]>--- drivers/watchdog/Kconfig | 14 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sbsa_gwdt.c | 459 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 474 insertions(+)drivers/watchdog/Kconfig +14
-0@@ -173,6 +173,20 @@ config ARM_SP805_WATCHDOG ARM Primecell SP805 Watchdog timer. This will reboot your system when the timeout is reached. +config ARM_SBSA_WATCHDOG + tristate "ARM SBSA Generic Watchdog" + depends on ARM64 + depends on ARM_ARCH_TIMER + select WATCHDOG_CORE + help + ARM SBSA Generic Watchdog. This watchdog has two Watchdog timeouts. + The first timeout will trigger a panic; the second timeout will + trigger a system reset. + More details: ARM DEN0029B - Server Base System Architecture (SBSA) + + To compile this driver as module, choose M here: The module + will be called sbsa_gwdt. + config AT91RM9200_WATCHDOG tristate "AT91RM9200 watchdog" depends on SOC_AT91RM9200 && MFD_SYSCONdrivers/watchdog/Makefile +1
-0@@ -30,6 +30,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o # ARM Architecture obj-$(CONFIG_ARM_SP805_WATCHDOG) += sp805_wdt.o +obj-$(CONFIG_ARM_SBSA_WATCHDOG) += sbsa_gwdt.o obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o obj-$(CONFIG_CADENCE_WATCHDOG) += cadence_wdt.odrivers/watchdog/sbsa_gwdt.c new file +27
-0@@ -0,0 +1,459 @@ +/* +* SBSA(Server Base System Architecture) Generic Watchdog driver +* +* Copyright (c) 2015, Linaro Ltd. +* Author: Fu Wei <[email protected]> +* Suravee Suthikulpanit <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* The SBSA Generic watchdog driver is compatible with the pretimeout +* concept of Linux kernel. +* The timeout and pretimeout are determined by WCV or WOR. +* The first watch period is set by writing WCV directly, that can +* support more than 10s timeout at the maximum system counter +* frequency (400MHz). +* When WS0 is triggered, the second watch period (pretimeout) is +* determined by one of these registers: +* (1)WOR: 32bit register, this gives a maximum watch period of +* around 10s at the maximum system counter frequency. It's loaded +* automatically by hardware.
Quoted 8 lines
drivers/watchdog/sbsa_gwdt.c line 31
Quoted 4 lines
drivers/watchdog/sbsa_gwdt.c new file +4
-0+* (2)WCV: If the pretimeout value is greater then "max_wor_timeout", +* it will be loaded in WS0 interrupt routine. If system is in +* ws0_mode (reboot by kexec/kdump in panic with watchdog enabled +* and WS0 == true), the ping operation will only reload WCV. Below is the field comment about
ws0_mode, it saysws0_modeis only for rebooting in second stage timeout, but kexec/kdump can reboot in either first or second stage
Great thanks for your feedback.
yes, if kexec/kdump reboot the system before the WS0, ws0_mode may not be set. in this case, if WS0 is triggered during the reboot(AFAIK, panic will disable irq, and in the early boot stage of system, irq is disabled, too.), ws0_mode will be set at the next "open" in kdump kernel
if WS0 haven't triggered until the watchdog is opened again in kdump kernel , ws0_mode won't be set.
ws0_mode doesn't indicate if the system is in the kdump kernel, it indicates that if WS0 is triggered, when the watchdog is initialized.
Do I answer your question?
Quoted 434 lines
* @ws0_mode: indicate the system boot in the second stage timeout.
Quoted 431 lines
drivers/watchdog/sbsa_gwdt.c new file +428
-1+* More details about the hardware specification of this device: +* ARM DEN0029B - Server Base System Architecture (SBSA) +* +* Kernel/API: P------------------| pretimeout +* |----------------------------------------T timeout +* SBSA GWDT: P---WOR (or WCV)---WS1 pretimeout +* |-------WCV----------WS0~~~(ws0_mode)~~~~T timeout +*/ + +#include <linux/io.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/uaccess.h> +#include <linux/watchdog.h> +#include <asm/arch_timer.h> + +/* SBSA Generic Watchdog register definitions */ +/* refresh frame */ +#define SBSA_GWDT_WRR 0x000 + +/* control frame */ +#define SBSA_GWDT_WCS 0x000 +#define SBSA_GWDT_WOR 0x008 +#define SBSA_GWDT_WCV_LO 0x010 +#define SBSA_GWDT_WCV_HI 0x014 + +/* refresh/control frame */ +#define SBSA_GWDT_W_IIDR 0xfcc +#define SBSA_GWDT_IDR 0xfd0 + +/* Watchdog Control and Status Register */ +#define SBSA_GWDT_WCS_EN BIT(0) +#define SBSA_GWDT_WCS_WS0 BIT(1) +#define SBSA_GWDT_WCS_WS1 BIT(2) + +/** +* struct sbsa_gwdt - Internal representation of the SBSA GWDT +* @wdd: kernel watchdog_device structure +* @clk: store the System Counter clock frequency, in Hz. +* @ws0_mode: indicate the system boot in the second stage timeout. +* @max_wor_timeout: the maximum timeout value for WOR (in seconds). +* @refresh_base: Virtual address of the watchdog refresh frame +* @control_base: Virtual address of the watchdog control frame +*/ +struct sbsa_gwdt { +struct watchdog_device wdd; +u32 clk; +bool ws0_mode; +int max_wor_timeout; +void __iomem *refresh_base; +void __iomem *control_base; +}; + +#define to_sbsa_gwdt (e) container_of(e, struct sbsa_gwdt, wdd) + +#define DEFAULT_TIMEOUT 30/* seconds, the 1st + 2nd watch periods*/ +#define DEFAULT_PRETIMEOUT 10/* seconds, the 2nd watch period*/ + +static unsigned int timeout; +module_param (timeout, uint,0 ); +MODULE_PARM_DESC (timeout, + "Watchdog timeout in seconds. (>=0, default=" + __MODULE_STRING(DEFAULT_TIMEOUT) ")"); + +static unsigned int pretimeout; +module_param (pretimeout, uint,0 ); +MODULE_PARM_DESC (pretimeout, + "Watchdog pretimeout in seconds. (>=0, default=" + __MODULE_STRING(DEFAULT_PRETIMEOUT) ")"); + +static bool nowayout =WATCHDOG_NOWAYOUT ; +module_param (nowayout, bool,S_IRUGO ); +MODULE_PARM_DESC (nowayout, + "Watchdog cannot be stopped once started (default=" + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); + +/* +* help functions for accessing 64bit WCV register +*/ +static u64 sbsa_gwdt_get_wcv (struct watchdog_device *wdd) +{ +u32 wcv_lo, wcv_hi; +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); + +do { + wcv_hi =readl_relaxed (gwdt->control_base +SBSA_GWDT_WCV_HI ); + wcv_lo =readl_relaxed (gwdt->control_base +SBSA_GWDT_WCV_LO ); + }while (wcv_hi !=readl_relaxed (gwdt->control_base + +SBSA_GWDT_WCV_HI )); + +return (((u64 )wcv_hi <<32 ) | wcv_lo); +} + +static void sbsa_gwdt_set_wcv (struct watchdog_device *wdd,unsigned int t) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); +u64 wcv; + + wcv =arch_counter_get_cntvct () + (u64 )t * gwdt->clk; + +writel_relaxed (upper_32_bits (wcv), + gwdt->control_base +SBSA_GWDT_WCV_HI ); +writel_relaxed (lower_32_bits (wcv), + gwdt->control_base +SBSA_GWDT_WCV_LO ); +} + +/* +* inline functions for reloading 64bit WCV register +*/ +static inline void reload_pretimeout_to_wcv (struct watchdog_device *wdd) +{ +sbsa_gwdt_set_wcv (wdd, wdd->pretimeout); +} + +static inline void reload_first_stage_to_wcv (struct watchdog_device *wdd) +{ +sbsa_gwdt_set_wcv (wdd, wdd->timeout - wdd->pretimeout); +} + +/* +* watchdog operation functions +*/ +static int sbsa_gwdt_set_timeout (struct watchdog_device *wdd, +unsigned int timeout) +{ + wdd->timeout = timeout; + +return 0 ; +} + +static int sbsa_gwdt_set_pretimeout (struct watchdog_device *wdd, +unsigned int pretimeout) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); +u32 wor; + + wdd->pretimeout = pretimeout; + +/* If ws0_mode == true, we won't touch WOR */ +if (!gwdt->ws0_mode) { +if (!pretimeout) +/* +* If pretimeout is 0, it gives driver a timeslot (1s) +* to update WCV after an explicit refresh +* (sbsa_gwdt_start) +*/ + wor = gwdt->clk; +else +if (pretimeout > gwdt->max_wor_timeout) + wor =U32_MAX ; +else + wor = pretimeout * gwdt->clk; + +/* wtite WOR, that will cause an explicit watchdog refresh */ +writel_relaxed (wor, gwdt->control_base +SBSA_GWDT_WOR ); + } + +return 0 ; +} + +static unsigned int sbsa_gwdt_get_timeleft (struct watchdog_device *wdd) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); +u64 timeleft =sbsa_gwdt_get_wcv (wdd) -arch_counter_get_cntvct (); + +do_div (timeleft, gwdt->clk); + +return timeleft; +} + +static int sbsa_gwdt_keepalive (struct watchdog_device *wdd) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); + +if (gwdt->ws0_mode) +reload_pretimeout_to_wcv (wdd); +else +reload_first_stage_to_wcv (wdd); + +return 0 ; +} + +static int sbsa_gwdt_start (struct watchdog_device *wdd) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); + +/* If ws0_mode == true, the watchdog is enabled */ +if (!gwdt->ws0_mode) +/* writing WCS will cause an explicit watchdog refresh */ +writel_relaxed (SBSA_GWDT_WCS_EN , + gwdt->control_base +SBSA_GWDT_WCS ); + +return sbsa_gwdt_keepalive (wdd); +} + +static int sbsa_gwdt_stop (struct watchdog_device *wdd) +{ +struct sbsa_gwdt *gwdt =to_sbsa_gwdt (wdd); + +writel_relaxed (0 , gwdt->control_base +SBSA_GWDT_WCS ); +/* +* Writing WCS has caused an explicit watchdog refresh. +* Both watchdog signals are deasserted, so clean ws0_mode flag. +*/ + gwdt->ws0_mode = false; + +return 0 ; +} + +static irqreturn_t sbsa_gwdt_interrupt (int irq,void *dev_id) +{ +struct sbsa_gwdt *gwdt = (struct sbsa_gwdt *)dev_id; +struct watchdog_device *wdd = &gwdt->wdd; + +/* We don't use pretimeout, trigger WS1 now */ +if (!wdd->pretimeout) +sbsa_gwdt_set_wcv (wdd,0 ); + +/* +* The pretimeout is valid, go panic +* If pretimeout is greater then "max_wor_timeout", +* reload the right value to WCV, then panic +*/ +if (wdd->pretimeout > gwdt->max_wor_timeout) +reload_pretimeout_to_wcv (wdd); +panic ("SBSA Watchdog pre-timeout" ); + +return IRQ_HANDLED ; +} + +static struct watchdog_info sbsa_gwdt_info = { + .identity ="SBSA Generic Watchdog" , + .options =WDIOF_SETTIMEOUT | +WDIOF_KEEPALIVEPING | +WDIOF_MAGICCLOSE | +WDIOF_PRETIMEOUT | +WDIOF_CARDRESET , +}; + +static struct watchdog_ops sbsa_gwdt_ops = { + .owner =THIS_MODULE , + .start = sbsa_gwdt_start, + .stop = sbsa_gwdt_stop, + .ping = sbsa_gwdt_keepalive, + .set_timeout = sbsa_gwdt_set_timeout, + .set_pretimeout = sbsa_gwdt_set_pretimeout, + .get_timeleft = sbsa_gwdt_get_timeleft, +}; + +static int sbsa_gwdt_probe (struct platform_device *pdev) +{ +void __iomem *rf_base, *cf_base; +struct device *dev = &pdev->dev; +struct watchdog_device *wdd; +struct sbsa_gwdt *gwdt; +struct resource *res; +int ret, irq; +u32 status; + + gwdt =devm_kzalloc (dev,sizeof (*gwdt),GFP_KERNEL ); +if (!gwdt) +return -ENOMEM ; +platform_set_drvdata (pdev, gwdt); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + cf_base =devm_ioremap_resource (dev, res); +if (IS_ERR (cf_base)) +return PTR_ERR (cf_base); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); + rf_base =devm_ioremap_resource (dev, res); +if (IS_ERR (rf_base)) +return PTR_ERR (rf_base); + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +dev_err (dev,"unable to get ws0 interrupt.\n" ); +return irq; + } + +/* +* Get the frequency of system counter from the cp15 interface of ARM +* Generic timer. We don't need to check it, because if it returns "0", +* system would panic in very early stage. +*/ + gwdt->clk =arch_timer_get_cntfrq (); + gwdt->refresh_base = rf_base; + gwdt->control_base = cf_base; + gwdt->max_wor_timeout =U32_MAX / gwdt->clk; + gwdt->ws0_mode = false; + + wdd = &gwdt->wdd; + wdd->parent = dev; + wdd->info = &sbsa_gwdt_info; + wdd->ops = &sbsa_gwdt_ops; +watchdog_set_drvdata (wdd, gwdt); +watchdog_set_nowayout (wdd, nowayout); + + wdd->min_pretimeout =0 ; + wdd->min_timeout =1 ; + +/* +* Because the maximum of gwdt->clk is 400MHz and the maximum of WCV is +* U64_MAX, so the result of (U64_MAX / gwdt->clk) is always greater +* than U32_MAX. And the maximum of "unsigned int" is U32_MAX on ARM64. +* So we set the maximum value of pretimeout and timeout below. +*/ + wdd->max_pretimeout =U32_MAX -1 ; + wdd->max_timeout =U32_MAX ; + + wdd->pretimeout =DEFAULT_PRETIMEOUT ; + wdd->timeout =DEFAULT_TIMEOUT ; +watchdog_init_timeouts (wdd, pretimeout, timeout, dev); + + status =readl_relaxed (gwdt->control_base +SBSA_GWDT_WCS ); +if (status &SBSA_GWDT_WCS_WS1 ) { +dev_warn (dev,"System reset by WDT.\n" ); + wdd->bootstatus |=WDIOF_CARDRESET ; + }else if (status == (SBSA_GWDT_WCS_WS0 |SBSA_GWDT_WCS_EN )) { + gwdt->ws0_mode = true; + } + + ret =devm_request_irq (dev, irq, sbsa_gwdt_interrupt,0 , + pdev->name, gwdt); +if (ret) { +dev_err (dev,"unable to request IRQ %d\n" , irq); +return ret; + } + + ret =watchdog_register_device (wdd); +if (ret) +return ret; + +/* If ws0_mode == true, the line won't update WOR */ +sbsa_gwdt_set_pretimeout (wdd, wdd->pretimeout); + +/* +* If watchdog is already enabled, do a ping operation +* to keep system running +*/ +if (status &SBSA_GWDT_WCS_EN ) +sbsa_gwdt_keepalive (wdd); + +dev_info (dev,"Initialized with %ds timeout, %ds pretimeout @ %u Hz%s\n" , + wdd->timeout, wdd->pretimeout, gwdt->clk, + status &SBSA_GWDT_WCS_EN ? + gwdt->ws0_mode ?" [second stage]" :" [enabled]" : +"" ); + +return 0 ; +} + +static void sbsa_gwdt_shutdown (struct platform_device *pdev) +{ +struct sbsa_gwdt *gwdt =platform_get_drvdata (pdev); + +sbsa_gwdt_stop (&gwdt->wdd); +} + +static int sbsa_gwdt_remove (struct platform_device *pdev) +{ +struct sbsa_gwdt *gwdt =platform_get_drvdata (pdev); + +watchdog_unregister_device (&gwdt->wdd); + +return 0 ; +} + +/* Disable watchdog if it is active during suspend */ +static int __maybe_unused sbsa_gwdt_suspend (struct device *dev) +{ +struct sbsa_gwdt *gwdt =dev_get_drvdata (dev); + +if (watchdog_active (&gwdt->wdd)) +sbsa_gwdt_stop (&gwdt->wdd); + +return 0 ; +} + +/* Enable watchdog and configure it if necessary */ +static int __maybe_unused sbsa_gwdt_resume (struct device *dev) +{ +struct sbsa_gwdt *gwdt =dev_get_drvdata (dev); + +if (watchdog_active (&gwdt->wdd)) +sbsa_gwdt_start (&gwdt->wdd); + +return 0 ; +} + +static const struct dev_pm_ops sbsa_gwdt_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (sbsa_gwdt_suspend, sbsa_gwdt_resume) +}; + +static const struct of_device_id sbsa_gwdt_of_match[] = { + { .compatible ="arm,sbsa-gwdt" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, sbsa_gwdt_of_match); + +static const struct platform_device_id sbsa_gwdt_pdev_match[] = { + { .name ="sbsa-gwdt" , }, + {}, +}; +MODULE_DEVICE_TABLE (platform, sbsa_gwdt_pdev_match); + +static struct platform_driver sbsa_gwdt_driver = { + .driver = { + .name ="sbsa-gwdt" , + .pm = &sbsa_gwdt_pm_ops, + .of_match_table = sbsa_gwdt_of_match, + }, + .probe = sbsa_gwdt_probe, + .remove = sbsa_gwdt_remove, + .shutdown = sbsa_gwdt_shutdown, + .id_table = sbsa_gwdt_pdev_match, +}; + +module_platform_driver (sbsa_gwdt_driver); + +MODULE_DESCRIPTION ("SBSA Generic Watchdog Driver" ); +MODULE_AUTHOR ("Fu Wei <[email protected]>" ); +MODULE_AUTHOR ("Suravee Suthikulpanit <[email protected]>" ); +MODULE_LICENSE ("GPL v2" ); --2.4.3
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v7 5/8] Watchdog: introduce ARM SBSA watchdog driver
Quoted 51 lines
Quoted 33 lines
Quoted 33 lines
drivers/watchdog/sbsa_gwdt.c new file +27
-0@@ -0,0 +1,459 @@ +/* +* SBSA(Server Base System Architecture) Generic Watchdog driver +* +* Copyright (c) 2015, Linaro Ltd. +* Author: Fu Wei <[email protected]> +* Suravee Suthikulpanit <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* The SBSA Generic watchdog driver is compatible with the pretimeout +* concept of Linux kernel. +* The timeout and pretimeout are determined by WCV or WOR. +* The first watch period is set by writing WCV directly, that can +* support more than 10s timeout at the maximum system counter +* frequency (400MHz). +* When WS0 is triggered, the second watch period (pretimeout) is +* determined by one of these registers: +* (1)WOR: 32bit register, this gives a maximum watch period of +* around 10s at the maximum system counter frequency. It's loaded +* automatically by hardware. Quoted 8 lines
drivers/watchdog/sbsa_gwdt.c line 31
Quoted 4 lines
drivers/watchdog/sbsa_gwdt.c new file +4
-0+* (2)WCV: If the pretimeout value is greater then "max_wor_timeout", +* it will be loaded in WS0 interrupt routine. If system is in +* ws0_mode (reboot by kexec/kdump in panic with watchdog enabled +* and WS0 == true), the ping operation will only reload WCV. Below is the field comment about
ws0_mode, it saysws0_modeis only for rebooting in second stage timeout, but kexec/kdump can reboot in either first or second stageGreat thanks for your feedback.
yes, if kexec/kdump reboot the system before the WS0,
ws0_modemay not be set. in this case, if WS0 is triggered during thereboot(AFAIK, panic will disable irq, and in the early boot stage of system, irq is disabled, too.),ws0_modewill be set at the next "open" in kdump kernel
if WS0 haven't triggered until the watchdog is opened again in kdump kernel ,ws0_modewon't be set.
Quoted 4 lines
ws0_modedoesn't indicate if the system is in the kdump kernel, it indicates that if WS0 is triggered, when the watchdog is initialized.Do I answer your question?
Yes, thanks for explanation. So it sounds better to change the comment like below? from
(reboot by kexec/kdump in panic with watchdog enabled and WS0 == true) to
(reboot in the pre-timeout stage and WS0 == true)
Thanks
Dave
Re: [PATCH v7 5/8] Watchdog: introduce ARM SBSA watchdog driver
Hi Dave,
Quoted 54 lines · Dave Young
Quoted 54 lines
Quoted 33 lines
Quoted 33 lines
drivers/watchdog/sbsa_gwdt.c new file +27
-0@@ -0,0 +1,459 @@ +/* +* SBSA(Server Base System Architecture) Generic Watchdog driver +* +* Copyright (c) 2015, Linaro Ltd. +* Author: Fu Wei <[email protected]> +* Suravee Suthikulpanit <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* The SBSA Generic watchdog driver is compatible with the pretimeout +* concept of Linux kernel. +* The timeout and pretimeout are determined by WCV or WOR. +* The first watch period is set by writing WCV directly, that can +* support more than 10s timeout at the maximum system counter +* frequency (400MHz). +* When WS0 is triggered, the second watch period (pretimeout) is +* determined by one of these registers: +* (1)WOR: 32bit register, this gives a maximum watch period of +* around 10s at the maximum system counter frequency. It's loaded +* automatically by hardware. Quoted 8 lines
drivers/watchdog/sbsa_gwdt.c line 31
Quoted 4 lines
drivers/watchdog/sbsa_gwdt.c new file +4
-0+* (2)WCV: If the pretimeout value is greater then "max_wor_timeout", +* it will be loaded in WS0 interrupt routine. If system is in +* ws0_mode (reboot by kexec/kdump in panic with watchdog enabled +* and WS0 == true), the ping operation will only reload WCV. Below is the field comment about
ws0_mode, it saysws0_modeis only for rebooting in second stage timeout, but kexec/kdump can reboot in either first or second stageGreat thanks for your feedback.
yes, if kexec/kdump reboot the system before the WS0,
ws0_modemay not be set. in this case, if WS0 is triggered during thereboot(AFAIK, panic will disable irq, and in the early boot stage of system, irq is disabled, too.),ws0_modewill be set at the next "open" in kdump kernel
if WS0 haven't triggered until the watchdog is opened again in kdump kernel ,ws0_modewon't be set.
ws0_modedoesn't indicate if the system is in the kdump kernel, it indicates that if WS0 is triggered, when the watchdog is initialized.
Quoted 7 lines
Quoted 1 line
Do I answer your question?
Yes, thanks for explanation. So it sounds better to change the comment like below? from
(reboot by kexec/kdump in panic with watchdog enabled and WS0 == true) to
(reboot in the pre-timeout stage and WS0 == true)
" in the pre-timeout stage" means " WS0 == true", so I think we should say:
(reboot with watchdog enabled and WS0 == true)
Thanks for your suggestion.
Quoted 3 lines
Thanks
Dave
Signature · 14 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v7 6/8 ACPI: add GTDT table parse driver into ACPI driver
In reply to [email protected]From: Fu Wei <[email protected]>
This driver adds support for parsing SBSA Generic Watchdog Structure in GTDT, and creating a platform device with that information. This allows the operating system to obtain device data from the resource of platform device.
The platform device named "sbsa-gwdt" can be used by the ARM SBSA Generic Watchdog driver.
--- drivers/acpi/Kconfig | 9 ++++ drivers/acpi/Makefile | 1 + drivers/acpi/gtdt.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+)
drivers/acpi/Kconfig +9 -0
@@ -479,4 +479,13 @@ config XPOWER_PMIC_OPREGION endif +config ACPI_GTDT + bool "ACPI GTDT Support" + depends on ARM64 + help + GTDT (Generic Timer Description Table) provides information + for per-processor timers and Platform (memory-mapped) timers + for ARM platforms. Select this option to provide information + needed for the timers init. + endif # ACPI
drivers/acpi/Makefile +1 -0
@@ -93,5 +93,6 @@ obj-$(CONFIG_ACPI_EXTLOG) += acpi_extlog.o obj-$(CONFIG_PMIC_OPREGION) += pmic/intel_pmic.o obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o +obj-$(CONFIG_ACPI_GTDT) += gtdt.o video-objs += acpi_video.o video_detect.o
drivers/acpi/gtdt.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH v7 7/8 Watchdog: enable ACPI GTDT support for ARM SBSA watchdog driver
In reply to [email protected]From: Fu Wei <[email protected]>
This patch enables ACPI GTDT support for ARM SBSA watchdog driver automatically, if ACPI support is enabled.
--- drivers/watchdog/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/Kconfig +1 -0
@@ -178,6 +178,7 @@ config ARM_SBSA_WATCHDOG depends on ARM64 depends on ARM_ARCH_TIMER select WATCHDOG_CORE + select ACPI_GTDT if ACPI help ARM SBSA Generic Watchdog. This watchdog has two Watchdog timeouts. The first timeout will trigger a panic; the second timeout will
Signature · 1 line
2.4.3
PATCH v7 8/8 clocksource: simplify ACPI code in arm_arch_timer.c
In reply to [email protected]From: Fu Wei <[email protected]>
The patch update arm_arch_timer driver to use the function provided by the new GTDT driver of ACPI.
By this way, arm_arch_timer.c can be simplified, and separate all the ACPI GTDT knowledge from this timer driver.
--- arch/arm64/kernel/time.c | 4 +-- drivers/acpi/gtdt.c | 43 ++++++++++++++++++++++++++ drivers/clocksource/Kconfig | 1 + drivers/clocksource/arm_arch_timer.c | 60 +++++++----------------------------- include/clocksource/arm_arch_timer.h | 8 +++++ include/linux/acpi.h | 5 +++ include/linux/clocksource.h | 4 +-- 7 files changed, 72 insertions(+), 53 deletions(-)
arch/arm64/kernel/time.c +2 -2
@@ -75,9 +75,9 @@ void __init time_init(void)/* * Since ACPI or FDT will only one be available in the system, -* we can use acpi_generic_timer_init() here safely +* we can use arch_timer_acpi_init() here safely */ -acpi_generic_timer_init (); +arch_timer_acpi_init (); arch_timer_rate =arch_timer_get_rate ();if (!arch_timer_rate)
drivers/acpi/gtdt.c +43 -0
55 lines not on this page · raw message
drivers/clocksource/Kconfig +1 -0
@@ -119,6 +119,7 @@ config CLKSRC_STM32 config ARM_ARCH_TIMER bool select CLKSRC_OF if OF + select ACPI_GTDT if ACPI config ARM_ARCH_TIMER_EVTSTREAM bool "Support for ARM architected timer event stream generation"
drivers/clocksource/arm_arch_timer.c +11 -49
79 lines not on this page · raw message
include/clocksource/arm_arch_timer.h +8 -0
@@ -43,6 +43,14 @@ enum arch_timer_reg {#define ARCH_TIMER_EVT_STREAM_FREQ 10000/* 100us */ +struct arch_timer_data { +int phys_secure_ppi; +int phys_nonsecure_ppi; +int virt_ppi; +int hyp_ppi; +bool c3stop; +}; +#ifdef CONFIG_ARM_ARCH_TIMER extern u32 arch_timer_get_rate (void );
include/linux/acpi.h +5 -0
@@ -449,6 +449,11 @@ void acpi_walk_dep_device_list(acpi_handle handle);struct platform_device *acpi_create_platform_device (struct acpi_device *);#define ACPI_PTR (_ptr) (_ptr) +#ifdef CONFIG_ACPI_GTDT +struct arch_timer_data ; +int __init gtdt_arch_timer_data_init (struct arch_timer_data *data); +#endif +#else /* !CONFIG_ACPI */ #define acpi_disabled 1
include/linux/clocksource.h +2 -2
@@ -253,9 +253,9 @@ static inline void clocksource_of_init(void) {}#endif #ifdef CONFIG_ACPI -void acpi_generic_timer_init (void ); +void arch_timer_acpi_init (void );#else -static inline void acpi_generic_timer_init (void ) { } +static inline void arch_timer_acpi_init (void ) { }#endif #endif /* _LINUX_CLOCKSOURCE_H */
Signature · 6 lines
2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
On Tue, 25 Aug 2015, [email protected] wrote:
You Cc the world and some more on your patch, but you fail to add the maintainers of the clocksource code to the Cc list. Sigh.
Quoted 6 lines
From: Fu Wei <[email protected]>
The patch update
arm_arch_timerdriver to use the function provided by the new GTDT driver of ACPI.
By this way,arm_arch_timer.ccan be simplified, and separate all the ACPI GTDT knowledge from this timer driver.
That's not a proper changelog and this patch want's to be split in two:
1) Implement the new ACPI function
2) Make use of it
Quoted 17 lines
index 0aa135d..99505bb 100644
drivers/clocksource/arm_arch_timer.c +0
-10@@ -817,68 +817,30 @@ CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", arch_timer_mem_init);#ifdef CONFIG_ACPI -static int __init map_generic_timer_interrupt (u32 interrupt,u32 flags) -{ -int trigger, polarity; - -if (!interrupt) -return 0 ; - - trigger = (flags &ACPI_GTDT_INTERRUPT_MODE ) ?ACPI_EDGE_SENSITIVE - :ACPI_LEVEL_SENSITIVE ; -
drivers/clocksource/arm_arch_timer.c CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", · line 822
Quoted 10 lines
drivers/clocksource/arm_arch_timer.c +1
-7- polarity = (flags &ACPI_GTDT_INTERRUPT_POLARITY ) ?ACPI_ACTIVE_LOW - :ACPI_ACTIVE_HIGH ; - -return acpi_register_gsi (NULL , interrupt, trigger, polarity); -} -/* Initialize per-processor generic timer */ -static int __init arch_timer_acpi_init (struct acpi_table_header *table) +void __init arch_timer_acpi_init (void ) {
And how is that supposed to work when we have next generation CPUs which implement a different timer? You break multisystem kernels that way.
Thanks,
tglx
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Hi Thomas,
Quoted 4 lines · Thomas Gleixner
On Tue, 25 Aug 2015, [email protected] wrote:
You Cc the world and some more on your patch, but you fail to add the maintainers of the clocksource code to the Cc list. Sigh.
my fault
So sorry for that, I will add the maintainers of clocksource into cc list.
Quoted 8 lines
Quoted 7 lines
From: Fu Wei <[email protected]>
The patch update
arm_arch_timerdriver to use the function provided by the new GTDT driver of ACPI.
By this way,arm_arch_timer.ccan be simplified, and separate all the ACPI GTDT knowledge from this timer driver.
Quoted 5 lines
That's not a proper changelog and this patch want's to be split in two:
1) Implement the new ACPI function
2) Make use of it
Yes, you are right , will improve this
Quoted 24 lines
Quoted 24 lines
index 0aa135d..99505bb 100644
drivers/clocksource/arm_arch_timer.c +0
-16@@ -817,68 +817,30 @@ CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", arch_timer_mem_init);#ifdef CONFIG_ACPI -static int __init map_generic_timer_interrupt (u32 interrupt,u32 flags) -{ -int trigger, polarity; - -if (!interrupt) -return 0 ; - - trigger = (flags &ACPI_GTDT_INTERRUPT_MODE ) ?ACPI_EDGE_SENSITIVE - :ACPI_LEVEL_SENSITIVE ; - - polarity = (flags &ACPI_GTDT_INTERRUPT_POLARITY ) ?ACPI_ACTIVE_LOW - :ACPI_ACTIVE_HIGH ; - -return acpi_register_gsi (NULL , interrupt, trigger, polarity); -} -
Quoted 8 lines
drivers/clocksource/arm_arch_timer.c CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", · line 822
Quoted 4 lines
drivers/clocksource/arm_arch_timer.c +1
-1/* Initialize per-processor generic timer */ -static int __init arch_timer_acpi_init (struct acpi_table_header *table) +void __init arch_timer_acpi_init (void ) {And how is that supposed to work when we have next generation CPUs which implement a different timer? You break multisystem kernels that way.
yes, you are right, If there is a next generation CPUs which implement a different timer, (maybe) this driver can not work. we may need a new timer driver.
But,
(1) for now, aarch64 core always has the arch timer(this timer is part of aarch64 architecture).
and the existing code make ARM64 kernel "select ARM_ARCH_TIMER "
(2) GTDT is designed for generic timer, so in this call " arch_timer_acpi_init" we parse the gtdt info.
(3) once we have a ARM64 CPUs which implement a different timer, we may need to select a right timer in the config stage.
and this timer may not be described in GTDT. So we can implement another arch_timer_acpi_init by that time in new timer driver.. if the new time still uses GTDT(or new version GTDT), we may need to update gtdt.c for new timer by that time.
but before we really have this new timer, I think this code is OK to use.
Do I understand your comment correctly? :-)
Quoted 4 lines
Thanks,
tglx
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Quoted 13 lines · Fu Wei
Quoted 8 lines
drivers/clocksource/arm_arch_timer.c CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", · line 822
Quoted 4 lines
/* Initialize per-processor generic timer */
drivers/clocksource/arm_arch_timer.c +1
-1-static int __init arch_timer_acpi_init (struct acpi_table_header *table) +void __init arch_timer_acpi_init (void ) {And how is that supposed to work when we have next generation CPUs which implement a different timer? You break multisystem kernels that way.
yes, you are right, If there is a next generation CPUs which implement a different timer, (maybe) this driver can not work. we may need a new timer driver.
Quoted 12 lines
But,
(1) for now, aarch64 core always has the arch timer(this timer is part of aarch64 architecture).
and the existing code make ARM64 kernel "selectARM_ARCH_TIMER"
(2) GTDT is designed for generic timer, so in this call "arch_timer_acpi_init" we parse the gtdt info.
(3) once we have a ARM64 CPUs which implement a different timer, we may need to select a right timer in the config stage.
and this timer may not be described in GTDT. So we can implement anotherarch_timer_acpi_initby that time in new timer driver.. if the new time still uses GTDT(or new version GTDT), we may need to updategtdt.cfor new timer by that time.
That's simply wrong. You want to build kernels which run on both cpus and the selection of the timer happens at runtime depending on the ACPI info. We do the same thing with device tree.
Quoted 1 line
but before we really have this new timer, I think this code is OK to use.
I don't think so, but I leave this decision to the ARM64 maintainers.
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Hi Thomas,
Thanks for the comments, I got some questions and
reply below.
Quoted 9 lines · Thomas Gleixner
Quoted 8 lines · Fu Wei
Quoted 8 lines
drivers/clocksource/arm_arch_timer.c CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", · line 822
Quoted 4 lines
/* Initialize per-processor generic timer */
drivers/clocksource/arm_arch_timer.c +1
-1-static int __init arch_timer_acpi_init (struct acpi_table_header *table) +void __init arch_timer_acpi_init (void ) {And how is that supposed to work when we have next generation CPUs which implement a different timer? You break multisystem kernels that way.
Sorry, I think I missed some context here that I don't understand why the code here will break multisystem kernels? I'm trying to understand the problem here and update the code :)
Quoted 18 lines
Quoted 5 lines
yes, you are right, If there is a next generation CPUs which implement a different timer, (maybe) this driver can not work. we may need a new timer driver.
Quoted 12 lines
But,
(1) for now, aarch64 core always has the arch timer(this timer is part of aarch64 architecture).
and the existing code make ARM64 kernel "selectARM_ARCH_TIMER"
(2) GTDT is designed for generic timer, so in this call "arch_timer_acpi_init" we parse the gtdt info.
(3) once we have a ARM64 CPUs which implement a different timer, we may need to select a right timer in the config stage.
and this timer may not be described in GTDT. So we can implement anotherarch_timer_acpi_initby that time in new timer driver.. if the new time still uses GTDT(or new version GTDT), we may need to updategtdt.cfor new timer by that time.
Quoted 3 lines
That's simply wrong. You want to build kernels which run on both cpus and the selection of the timer happens at runtime depending on the ACPI info. We do the same thing with device tree.
I think the code can do that if I understand correctly. The code for now is that we only support arch timer on ARM64, and this patch set is adding SBSA watchdog timer support which need same function in arch timer, so we move that function to common place.
We will load the driver (arch timer, memory mapped timer) when the ACPI table defines them, which when new timer is coming, that will defined in the ACPI table and load the driver as needed.
Please correct me if I misse something, thanks.
Hanjun
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Quoted 43 lines · Hanjun Guo
Quoted 10 lines · Thomas Gleixner
Quoted 9 lines · Fu Wei
Quoted 9 lines
Quoted 5 lines
/* Initialize per-processor generic timer */
-static int__initarch_timer_acpi_init(struct acpi_table_header *table)
+void__initarch_timer_acpi_init(void)
{And how is that supposed to work when we have next generation CPUs which implement a different timer? You break multisystem kernels that way.
Sorry, I think I missed some context here that I don't understand why the code here will break multisystem kernels? I'm trying to understand the problem here and update the code :)
Quoted 18 lines
Quoted 5 lines
yes, you are right, If there is a next generation CPUs which implement a different timer, (maybe) this driver can not work. we may need a new timer driver.
Quoted 12 lines
But,
(1) for now, aarch64 core always has the arch timer(this timer is part of aarch64 architecture).
and the existing code make ARM64 kernel "selectARM_ARCH_TIMER"
(2) GTDT is designed for generic timer, so in this call "arch_timer_acpi_init" we parse the gtdt info.
(3) once we have a ARM64 CPUs which implement a different timer, we may need to select a right timer in the config stage.
and this timer may not be described in GTDT. So we can implement anotherarch_timer_acpi_initby that time in new timer driver.. if the new time still uses GTDT(or new version GTDT), we may need to updategtdt.cfor new timer by that time.Quoted 3 lines
That's simply wrong. You want to build kernels which run on both cpus and the selection of the timer happens at runtime depending on the ACPI info. We do the same thing with device tree.
I think the code can do that if I understand correctly. The code for now is that we only support arch timer on ARM64, and this patch set is adding SBSA watchdog timer support which need same function in arch timer, so we move that function to common place.
Quoted 5 lines
We will load the driver (arch timer, memory mapped timer) when the ACPI table defines them, which when new timer is coming, that will defined in the ACPI table and load the driver as needed.
Please correct me if I misse something, thanks.
arch_timer_acpi_init() is called from the architecture boot code. So how is that supposed to work with different timers?
Are you going to have bla_timer_acpi_init() and foo_timer_acpi_init() calls as well?
Why not having a something like DT has: DECLARE_....
and the arch_timer_acpi_init() using that to figure out which of the timers to initialize.
Thanks,
tglx
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Quoted 53 lines · Thomas Gleixner
Quoted 43 lines · Hanjun Guo
Quoted 10 lines · Thomas Gleixner
Quoted 9 lines · Fu Wei
Quoted 9 lines
Quoted 5 lines
/* Initialize per-processor generic timer */-static int
__initarch_timer_acpi_init(struct acpi_table_header *table)
+void__initarch_timer_acpi_init(void)
{And how is that supposed to work when we have next generation CPUs which implement a different timer? You break multisystem kernels that way.
Sorry, I think I missed some context here that I don't understand why the code here will break multisystem kernels? I'm trying to understand the problem here and update the code :)
Quoted 18 lines
Quoted 5 lines
yes, you are right, If there is a next generation CPUs which implement a different timer, (maybe) this driver can not work. we may need a new timer driver.
Quoted 12 lines
But,
(1) for now, aarch64 core always has the arch timer(this timer is part of aarch64 architecture).
and the existing code make ARM64 kernel "selectARM_ARCH_TIMER"
(2) GTDT is designed for generic timer, so in this call "arch_timer_acpi_init" we parse the gtdt info.
(3) once we have a ARM64 CPUs which implement a different timer, we may need to select a right timer in the config stage.
and this timer may not be described in GTDT. So we can implement anotherarch_timer_acpi_initby that time in new timer driver.. if the new time still uses GTDT(or new version GTDT), we may need to updategtdt.cfor new timer by that time.Quoted 3 lines
That's simply wrong. You want to build kernels which run on both cpus and the selection of the timer happens at runtime depending on the ACPI info. We do the same thing with device tree.
I think the code can do that if I understand correctly. The code for now is that we only support arch timer on ARM64, and this patch set is adding SBSA watchdog timer support which need same function in arch timer, so we move that function to common place.
Quoted 5 lines
We will load the driver (arch timer, memory mapped timer) when the ACPI table defines them, which when new timer is coming, that will defined in the ACPI table and load the driver as needed.
Please correct me if I misse something, thanks.
arch_timer_acpi_init()is called from the architecture boot code. So how is that supposed to work with different timers?
Quoted 7 lines
Are you going to have
bla_timer_acpi_init()andfoo_timer_acpi_init()calls as well?Why not having a something like DT has:
DECLARE_....and the
arch_timer_acpi_init()using that to figure out which of the timers to initialize.
Ah, ok, I can fully understand you now, thanks for your patience.
Yes, I agree with you, so this is not a problem for this patch, but for the code implementation of previous code. Actually we are on the road to do as you suggested, we introduced something like #define ACPI_DECLARE(table, name, table_id, subtable, data, fn) [1] in the GICv3 and GIC self probe patch set, and I said that infrastructure can be used as clock declare too, we just trying to not add such dependence on that patch set (it's still on discussion),
[1]: https://lkml.org/lkml/2015/7/29/236
If that is ok with you, we will introduce similar DECLARE_ thing for clock declare.
Thanks
Hanjun
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Quoted 72 lines · Hanjun Guo
Quoted 53 lines · Thomas Gleixner
Quoted 43 lines · Hanjun Guo
Quoted 10 lines · Thomas Gleixner
Quoted 9 lines · Fu Wei
Quoted 9 lines
Quoted 5 lines
/* Initialize per-processor generic timer */-static int
__initarch_timer_acpi_init(struct acpi_table_header *table)
+void__initarch_timer_acpi_init(void)
{And how is that supposed to work when we have next generation CPUs which implement a different timer? You break multisystem kernels that way.
Sorry, I think I missed some context here that I don't understand why the code here will break multisystem kernels? I'm trying to understand the problem here and update the code :)
Quoted 18 lines
Quoted 5 lines
yes, you are right, If there is a next generation CPUs which implement a different timer, (maybe) this driver can not work. we may need a new timer driver.
Quoted 12 lines
But,
(1) for now, aarch64 core always has the arch timer(this timer is part of aarch64 architecture).
and the existing code make ARM64 kernel "selectARM_ARCH_TIMER"
(2) GTDT is designed for generic timer, so in this call "arch_timer_acpi_init" we parse the gtdt info.
(3) once we have a ARM64 CPUs which implement a different timer, we may need to select a right timer in the config stage.
and this timer may not be described in GTDT. So we can implement anotherarch_timer_acpi_initby that time in new timer driver.. if the new time still uses GTDT(or new version GTDT), we may need to updategtdt.cfor new timer by that time.Quoted 3 lines
That's simply wrong. You want to build kernels which run on both cpus and the selection of the timer happens at runtime depending on the ACPI info. We do the same thing with device tree.
I think the code can do that if I understand correctly. The code for now is that we only support arch timer on ARM64, and this patch set is adding SBSA watchdog timer support which need same function in arch timer, so we move that function to common place.
Quoted 5 lines
We will load the driver (arch timer, memory mapped timer) when the ACPI table defines them, which when new timer is coming, that will defined in the ACPI table and load the driver as needed.
Please correct me if I misse something, thanks.
arch_timer_acpi_init()is called from the architecture boot code. So how is that supposed to work with different timers?Quoted 7 lines
Are you going to have
bla_timer_acpi_init()andfoo_timer_acpi_init()calls as well?Why not having a something like DT has:
DECLARE_....and the
arch_timer_acpi_init()using that to figure out which of the timers to initialize.Ah, ok, I can fully understand you now, thanks for your patience.
Yes, I agree with you, so this is not a problem for this patch, but for the code implementation of previous code. Actually we are on the road to do as you suggested, we introduced something like #define
ACPI_DECLARE(table, name, table_id, subtable, data, fn)[1] in the GICv3 and GIC self probe patch set, and I said that infrastructure can be used as clock declare too, we just trying to not add such dependence on that patch set (it's still on discussion),
Quoted 4 lines
[1]: https://lkml.org/lkml/2015/7/29/236
If that is ok with you, we will introduce similar
DECLARE_thing for clock declare.
Or we can drop this patch from this patch set, and clean up this patch when the ACPI_DECLARE() infrastructure is ready for upstream.
Thanks
Hanjun
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Quoted 4 lines · Hanjun Guo
Quoted 4 lines
[1]: https://lkml.org/lkml/2015/7/29/236
If that is ok with you, we will introduce similar
DECLARE_thing for clock declare.
Yes.
Quoted 2 lines
Or we can drop this patch from this patch set, and clean up this patch when the
ACPI_DECLARE()infrastructure is ready for upstream.
Works either way. I just noticed that hard coded init thing and decided to rant about it :)
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Hi Thomas, Hanjun
Quoted 7 lines · Thomas Gleixner
Quoted 4 lines · Hanjun Guo
Quoted 4 lines
[1]: https://lkml.org/lkml/2015/7/29/236
If that is ok with you, we will introduce similar
DECLARE_thing for clock declare.Yes.
Thanks
Quoted 6 lines
Quoted 3 lines
Or we can drop this patch from this patch set, and clean up this patch when the
ACPI_DECLARE()infrastructure is ready for upstream.Works either way. I just noticed that hard coded init thing and decided to rant about it :)
OK, good idea, this patch will be improve by DECLARE_ thing, then upstream. drop this from this patchset.
Great thanks for your help
Quoted 8 lines
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
Re: [PATCH v7 8/8] clocksource: simplify ACPI code in arm_arch_timer.c
Quoted 17 lines · Fu Wei
Hi Thomas, Hanjun
Quoted 7 lines · Thomas Gleixner
Quoted 4 lines · Hanjun Guo
Quoted 4 lines
[1]: https://lkml.org/lkml/2015/7/29/236
If that is ok with you, we will introduce similar
DECLARE_thing for clock declare.Yes.
Thanks
Quoted 4 lines
Quoted 3 lines
Or we can drop this patch from this patch set, and clean up this patch when the
ACPI_DECLARE()infrastructure is ready for upstream.
Quoted 7 lines
Quoted 2 lines
Works either way. I just noticed that hard coded init thing and decided to rant about it :)
OK, good idea, this patch will be improve by
DECLARE_thing, then upstream. drop this from this patchset.Great thanks for your help
You probably want to keep an eye on this:
https://lwn.net/Articles/657238/
which implements the necessary infrastructure. I'd appreciate if you could give it a go to find out if it works for you.
Thanks,
M.
Signature · 5 lines
Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 0/8] Watchdog: introduce ARM SBSA watchdog driver
In reply to [email protected]Hi Fu Wei,
Quoted 32 lines · On 25/08/2015:01:01:15 AM, [email protected] wrote:
From: Fu Wei <[email protected]>
This patchset:
(1)IntroduceDocumentation/devicetree/bindings/watchdog/sbsa-gwdt.txtfor FDT info of SBSA Generic Watchdog, and give two examples of adding SBSA Generic Watchdog device node into the dts files:
foundation-v8.dtsandamd-seattle-soc.dtsi.(2)Introduce "pretimeout" into the watchdog framework, and update
Documentation/watchdog/watchdog-kernel-api.txtto introduce:
(1)the new elements in thewatchdog_deviceandwatchdog_opsstruct; (2)the new API "watchdog_init_timeouts".(3)Introduce ARM SBSA watchdog driver:
a.Use linux kernel watchdog framework;
b.Work with FDT on ARM64;
c.Use "pretimeout" in watchdog framework;
d.Support getting timeout and pretimeout from parameter and FDT
at the driver init stage.
e.In the first timeout, do panic to save system context; f.In the second stage, user can still feed the dog without
cleaning WS0. By this feature, we can avoid the panic infinite loops, while backing up a large system context in a server.
g.In the second stage, can trigger WS1 by setting pretimeout = 0
if necessary.(4)Introduce ACPI GTDT parser:
drivers/acpi/gtdt.c
Parse SBSA Generic Watchdog Structure in GTDT table of ACPI, and create a platform device with that information.
This platform device can be used by This Watchdog driver.drivers/clocksource/arm_arch_timer.cis simplified by this GTDT support.
Quoted 4 lines
This patchset has been tested with watchdog daemon (ACPI/FDT, module/build-in) on the following platforms:
(1)ARM Foundation v8 model
I tested it with kdump on fedora-arm64 Seattle platform. I enabled watchdog using systemd (with 30s timeout), insured that watchdog is active and then crashed the system. I can see that kdump kernel loads sbsa_wdt and activates watchdog, still vmcore copy is done successfully.
My test kernel is here [1]
~Pratyush
[1] https://github.com/pratyushanand/linux/commits/wdt/sbsa-test-kexec
Re: [PATCH v7 0/8] Watchdog: introduce ARM SBSA watchdog driver
Hi Pratyush,
Great thanks for your testing, this info is very helpful. :-) my new patchset will come out soon.
Quoted 49 lines · Pratyush Anand
Hi Fu Wei,
Quoted 32 lines · On 25/08/2015:01:01:15 AM, [email protected] wrote:
From: Fu Wei <[email protected]>
This patchset:
(1)IntroduceDocumentation/devicetree/bindings/watchdog/sbsa-gwdt.txtfor FDT info of SBSA Generic Watchdog, and give two examples of adding SBSA Generic Watchdog device node into the dts files:
foundation-v8.dtsandamd-seattle-soc.dtsi.(2)Introduce "pretimeout" into the watchdog framework, and update
Documentation/watchdog/watchdog-kernel-api.txtto introduce:
(1)the new elements in thewatchdog_deviceandwatchdog_opsstruct; (2)the new API "watchdog_init_timeouts".(3)Introduce ARM SBSA watchdog driver:
a.Use linux kernel watchdog framework;
b.Work with FDT on ARM64;
c.Use "pretimeout" in watchdog framework;
d.Support getting timeout and pretimeout from parameter and FDT
at the driver init stage.
e.In the first timeout, do panic to save system context; f.In the second stage, user can still feed the dog without
cleaning WS0. By this feature, we can avoid the panic infinite loops, while backing up a large system context in a server.
g.In the second stage, can trigger WS1 by setting pretimeout = 0
if necessary.(4)Introduce ACPI GTDT parser:
drivers/acpi/gtdt.c
Parse SBSA Generic Watchdog Structure in GTDT table of ACPI, and create a platform device with that information.
This platform device can be used by This Watchdog driver.drivers/clocksource/arm_arch_timer.cis simplified by this GTDT support.Quoted 4 lines
This patchset has been tested with watchdog daemon (ACPI/FDT, module/build-in) on the following platforms:
(1)ARM Foundation v8 modelI tested it with kdump on fedora-arm64 Seattle platform. I enabled watchdog using systemd (with 30s timeout), insured that watchdog is active and then crashed the system. I can see that kdump kernel loads
sbsa_wdtand activates watchdog, still vmcore copy is done successfully.
My test kernel is here [1]~Pratyush
[1] https://github.com/pratyushanand/linux/commits/wdt/sbsa-test-kexec
Signature · 10 lines
Best regards, Fu Wei Software Engineer Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch Ph: +86 21 61221326(direct) Ph: +86 186 2020 4684 (mobile) Room 1512, Regus One Corporate Avenue,Level 15, One Corporate Avenue,222 Hubin Road,Huangpu District, Shanghai,China 200021
v2 cover arm64,xen: add xen_boot support into grup-mkconfig
In reply to a message not in the archiveFrom: Fu Wei <[email protected]>
This patchset add xen_boot support into grup-mkconfig for generating xen boot entrances automatically
Also update the docs/grub.texi for new xen_boot commands.
This patchset has been tested on Foudation model with a bug fix:
http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00205.html
ChangeLog:
v2: add "--nounzip" option support in xen_module
use "feature_xen_boot" instead of "grub_xen_boot" update the introduction of xen boot commands in docs/grub.texi
v1 :first upstream patchset:
http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00264.html
Fu Wei (4):
arm64: add "--nounzip" option support in xen_module command
* util/grub.d/20_linux_xen.in: Add xen_boot command support i386,xen: Add xen_hypervisor and xen_module aliases for i386
arm64: update the introduction of xen boot commands in
docs/grub.texi
docs/grub.texi | 32 +++++++++----------------------- grub-core/loader/arm64/xen_boot.c | 17 +++++++++++++++++ grub-core/loader/i386/xen.c | 7 +++++++ grub-core/normal/main.c | 2 +- util/grub.d/20_linux_xen.in | 13 ++++++++++--- 5 files changed, 44 insertions(+), 27 deletions(-)
Signature · 1 line
2.5.0