um: always include kconfig.h and compiler-version.h

Since commit a95b37e20d ("kbuild: get <linux/compiler_types.h> out of
<linux/kconfig.h>") we can safely include these files in userspace code.
Doing so simplifies matters as options do not need to be exported via
asm-offsets.h anymore.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20241103150506.1367695-2-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Benjamin Berg 2024-11-03 16:05:03 +01:00 committed by Johannes Berg
parent fce0128863
commit 2f278b5957
7 changed files with 16 additions and 31 deletions

View File

@ -71,7 +71,9 @@ KBUILD_AFLAGS += $(ARCH_INCLUDE)
USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
$(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \
-D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \ -D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
-idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \
-include $(srctree)/include/linux/compiler-version.h \
-include $(srctree)/include/linux/kconfig.h
#This will adjust *FLAGS accordingly to the platform. #This will adjust *FLAGS accordingly to the platform.
include $(srctree)/$(ARCH_DIR)/Makefile-os-Linux include $(srctree)/$(ARCH_DIR)/Makefile-os-Linux

View File

@ -15,21 +15,3 @@ DEFINE(UM_THREAD_SIZE, THREAD_SIZE);
DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC); DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC);
#ifdef CONFIG_PRINTK
DEFINE(UML_CONFIG_PRINTK, CONFIG_PRINTK);
#endif
#ifdef CONFIG_UML_X86
DEFINE(UML_CONFIG_UML_X86, CONFIG_UML_X86);
#endif
#ifdef CONFIG_64BIT
DEFINE(UML_CONFIG_64BIT, CONFIG_64BIT);
#endif
#ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT
DEFINE(UML_CONFIG_UML_TIME_TRAVEL_SUPPORT, CONFIG_UML_TIME_TRAVEL_SUPPORT);
#endif
#ifdef CONFIG_UML_MAX_USERSPACE_ITERATIONS
DEFINE(UML_CONFIG_UML_MAX_USERSPACE_ITERATIONS, CONFIG_UML_MAX_USERSPACE_ITERATIONS);
#else
DEFINE(UML_CONFIG_UML_MAX_USERSPACE_ITERATIONS, 0);
#endif

View File

@ -12,14 +12,13 @@ enum time_travel_mode {
TT_MODE_EXTERNAL, TT_MODE_EXTERNAL,
}; };
#if defined(UML_CONFIG_UML_TIME_TRAVEL_SUPPORT) || \ #if IS_ENABLED(CONFIG_UML_TIME_TRAVEL_SUPPORT)
defined(CONFIG_UML_TIME_TRAVEL_SUPPORT)
extern enum time_travel_mode time_travel_mode; extern enum time_travel_mode time_travel_mode;
extern int time_travel_should_print_bc_msg; extern int time_travel_should_print_bc_msg;
#else #else
#define time_travel_mode TT_MODE_OFF #define time_travel_mode TT_MODE_OFF
#define time_travel_should_print_bc_msg 0 #define time_travel_should_print_bc_msg 0
#endif /* (UML_)CONFIG_UML_TIME_TRAVEL_SUPPORT */ #endif /* CONFIG_UML_TIME_TRAVEL_SUPPORT */
void _time_travel_print_bc_msg(void); void _time_travel_print_bc_msg(void);
static inline void time_travel_print_bc_msg(void) static inline void time_travel_print_bc_msg(void)

View File

@ -38,7 +38,7 @@ extern void panic(const char *fmt, ...)
#define UM_KERN_DEBUG KERN_DEBUG #define UM_KERN_DEBUG KERN_DEBUG
#define UM_KERN_CONT KERN_CONT #define UM_KERN_CONT KERN_CONT
#ifdef UML_CONFIG_PRINTK #if IS_ENABLED(CONFIG_PRINTK)
#define printk(...) _printk(__VA_ARGS__) #define printk(...) _printk(__VA_ARGS__)
extern int _printk(const char *fmt, ...) extern int _printk(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));

View File

@ -65,7 +65,7 @@ static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc)
#define SIGALRM_MASK (1 << SIGALRM_BIT) #define SIGALRM_MASK (1 << SIGALRM_BIT)
int signals_enabled; int signals_enabled;
#ifdef UML_CONFIG_UML_TIME_TRAVEL_SUPPORT #if IS_ENABLED(CONFIG_UML_TIME_TRAVEL_SUPPORT)
static int signals_blocked, signals_blocked_pending; static int signals_blocked, signals_blocked_pending;
#endif #endif
static unsigned int signals_pending; static unsigned int signals_pending;
@ -75,7 +75,7 @@ static void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
{ {
int enabled = signals_enabled; int enabled = signals_enabled;
#ifdef UML_CONFIG_UML_TIME_TRAVEL_SUPPORT #if IS_ENABLED(CONFIG_UML_TIME_TRAVEL_SUPPORT)
if ((signals_blocked || if ((signals_blocked ||
__atomic_load_n(&signals_blocked_pending, __ATOMIC_SEQ_CST)) && __atomic_load_n(&signals_blocked_pending, __ATOMIC_SEQ_CST)) &&
(sig == SIGIO)) { (sig == SIGIO)) {
@ -297,7 +297,7 @@ void unblock_signals(void)
return; return;
signals_enabled = 1; signals_enabled = 1;
#ifdef UML_CONFIG_UML_TIME_TRAVEL_SUPPORT #if IS_ENABLED(CONFIG_UML_TIME_TRAVEL_SUPPORT)
deliver_time_travel_irqs(); deliver_time_travel_irqs();
#endif #endif
@ -389,7 +389,7 @@ int um_set_signals_trace(int enable)
return ret; return ret;
} }
#ifdef UML_CONFIG_UML_TIME_TRAVEL_SUPPORT #if IS_ENABLED(CONFIG_UML_TIME_TRAVEL_SUPPORT)
void mark_sigio_pending(void) void mark_sigio_pending(void)
{ {
/* /*

View File

@ -413,12 +413,14 @@ void userspace(struct uml_pt_regs *regs)
*/ */
if (time_travel_mode == TT_MODE_INFCPU || if (time_travel_mode == TT_MODE_INFCPU ||
time_travel_mode == TT_MODE_EXTERNAL) { time_travel_mode == TT_MODE_EXTERNAL) {
if (UML_CONFIG_UML_MAX_USERSPACE_ITERATIONS && #ifdef CONFIG_UML_MAX_USERSPACE_ITERATIONS
if (CONFIG_UML_MAX_USERSPACE_ITERATIONS &&
unscheduled_userspace_iterations++ > unscheduled_userspace_iterations++ >
UML_CONFIG_UML_MAX_USERSPACE_ITERATIONS) { CONFIG_UML_MAX_USERSPACE_ITERATIONS) {
tt_extra_sched_jiffies += 1; tt_extra_sched_jiffies += 1;
unscheduled_userspace_iterations = 0; unscheduled_userspace_iterations = 0;
} }
#endif
} }
time_travel_print_bc_msg(); time_travel_print_bc_msg();

View File

@ -52,8 +52,8 @@ void setup_machinename(char *machine_out)
struct utsname host; struct utsname host;
uname(&host); uname(&host);
#ifdef UML_CONFIG_UML_X86 #if IS_ENABLED(CONFIG_UML_X86)
# ifndef UML_CONFIG_64BIT # if !IS_ENABLED(CONFIG_64BIT)
if (!strcmp(host.machine, "x86_64")) { if (!strcmp(host.machine, "x86_64")) {
strcpy(machine_out, "i686"); strcpy(machine_out, "i686");
return; return;