Skip to contentSkip to conversation

xen/arm: Add Kconfig option for CONFIG_EARLY_PRINTK

RFC PATCH In review Elliott Mitchell 2 participants 2 messages Aug 28, 2020

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 xen/arm: Add Kconfig option for CONFIG_EARLY_PRINTK

Support for a very early console has existed for ARM for quite some time. Previously EARLY_PRINTK had to be passed in as a Make variable, instead of as a configuration option. Create the option to allow selecting via .config.

---
This is mostly RFC due to insufficient testing. I am hopeful this successfully changes things to have the Kconfig CONFIG_EARLY_PRINTK option replace the environment/Make variable EARLY_PRINTK.

---
 xen/arch/arm/Kconfig        | 12 ++++++++++++
 xen/arch/arm/Makefile       |  2 +-
 xen/arch/arm/Rules.mk       | 34 +++++++++++++++-------------------
 xen/arch/arm/arm32/Makefile |  2 +-
 xen/arch/arm/arm64/Makefile |  2 +-
 5 files changed, 30 insertions(+), 22 deletions(-)
xen/arch/arm/Kconfig +12 -0
index 0ef8a99ad9..a176d42a0c 100644
@@ -241,3 +241,15 @@ source "arch/arm/platforms/Kconfig"
 source "common/Kconfig"
 
 source "drivers/Kconfig"
+
+if DEBUG || EXPERT
+
+config EARLY_PRINTK
+	string "Enable early hard-coded console for printk"
+	help
+          Setup a serial device early during boot for logging message.  Used
+	  for very early bring-up.
+
+	  See docs/misc/arm/early-printk.txt
+
+endif
xen/arch/arm/Makefile +1 -1
index 70f532e42a..0bf975b44d 100644
@@ -16,7 +16,7 @@ obj-y += device.o
 obj-y += domain.o
 obj-y += domain_build.init.o
 obj-y += domctl.o
-obj-$(EARLY_PRINTK) += early_printk.o
+obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
 obj-y += gic.o
 obj-y += gic-v2.o
 obj-$(CONFIG_GICV3) += gic-v3.o
xen/arch/arm/Rules.mk +15 -19
index 3d9a0ed357..4aef62cc9c 100644
@@ -22,12 +22,15 @@ ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n)
 CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE
 endif
 
-EARLY_PRINTK := n
-
-ifeq ($(CONFIG_DEBUG),y)
+ifneq ($(CONFIG_EARLY_PRINTK),)
 
 # See docs/misc/arm/early-printk.txt for syntax
 
+ifneq ($(CONFIG_DEBUG),y)
+# Early printk is dependant on a debug build.
+$(error CONFIG_EARLY_PRINTK enabled for non-debug build)
+endif
+
 EARLY_PRINTK_brcm           := 8250,0xF040AB00,2
 EARLY_PRINTK_dra7           := 8250,0x4806A000,2
 EARLY_PRINTK_fastmodel      := pl011,0x1c090000,115200
@@ -54,6 +57,10 @@ else
 EARLY_PRINTK_CFG := $(subst $(comma), ,$(CONFIG_EARLY_PRINTK))
 endif
 
+ifeq ($(EARLY_PRINTK_CFG),)
+$(error Unknown CONFIG_EARLY_PRINTK setting)
+endif
+
 # Extract configuration from string
 EARLY_PRINTK_INC := $(word 1,$(EARLY_PRINTK_CFG))
 EARLY_UART_BASE_ADDRESS := $(word 2,$(EARLY_PRINTK_CFG))
@@ -76,22 +83,11 @@ CFLAGS-y += -DEARLY_PRINTK_VERSION_NONE
 endif
 endif
 
-ifneq ($(EARLY_PRINTK_INC),)
-EARLY_PRINTK := y
-endif
-
-CFLAGS-$(EARLY_PRINTK) += -DCONFIG_EARLY_PRINTK
+CFLAGS-y += -DCONFIG_EARLY_PRINTK
 CFLAGS-$(EARLY_PRINTK_INIT_UART) += -DEARLY_PRINTK_INIT_UART
-CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
-CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
-CFLAGS-$(EARLY_PRINTK) += -DEARLY_UART_BASE_ADDRESS=$(EARLY_UART_BASE_ADDRESS)
-CFLAGS-$(EARLY_PRINTK) += -DEARLY_UART_REG_SHIFT=$(EARLY_UART_REG_SHIFT)
-
-else # !CONFIG_DEBUG
-
-ifneq ($(CONFIG_EARLY_PRINTK),)
-# Early printk is dependant on a debug build.
-$(error CONFIG_EARLY_PRINTK enabled for non-debug build)
-endif
+CFLAGS-y += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
+CFLAGS-y += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
+CFLAGS-y += -DEARLY_UART_BASE_ADDRESS=$(EARLY_UART_BASE_ADDRESS)
+CFLAGS-y += -DEARLY_UART_REG_SHIFT=$(EARLY_UART_REG_SHIFT)
 
 endif
xen/arch/arm/arm32/Makefile +1 -1
index 0ac254f347..13eeefae13 100644
@@ -1,6 +1,6 @@
 subdir-y += lib
 
-obj-$(EARLY_PRINTK) += debug.o
+obj-$(CONFIG_EARLY_PRINTK) += debug.o
 obj-y += domctl.o
 obj-y += domain.o
 obj-y += entry.o
xen/arch/arm/arm64/Makefile +1 -1
index c4f3a28a0d..86572014d0 100644
@@ -2,7 +2,7 @@ subdir-y += lib
 
 obj-y += cache.o
 obj-$(CONFIG_HARDEN_BRANCH_PREDICTOR) += bpi.o
-obj-$(EARLY_PRINTK) += debug.o
+obj-$(CONFIG_EARLY_PRINTK) += debug.o
 obj-y += domctl.o
 obj-y += domain.o
 obj-y += entry.o
Signature · 5 lines
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         [email protected]  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
#1 lore raw

Hi Elliott,

Quoted 11 lines · Elliott Mitchell

Support for a very early console has existed for ARM for quite some time. Previously EARLY_PRINTK had to be passed in as a Make variable, instead of as a configuration option. Create the option to allow selecting via .config.

---
This is mostly RFC due to insufficient testing. I am hopeful this successfully changes things to have the Kconfig CONFIG_EARLY_PRINTK option replace the environment/Make variable EARLY_PRINTK.

We already moved early printk to Kconfig in Xen 4.14. Which tree are you using?

Cheers,

Signature · 1 line
Julien Grall