Skip to content

Commit 8a1fc6c

Browse files
authored
Merge pull request #476 from cclerget/master-big-endian
Fix issue on big endian architecture. Increase jmp_buf size. Reduce OUTPUT_FORMAT hardcoding
2 parents 06ca3dd + c459324 commit 8a1fc6c

7 files changed

Lines changed: 23 additions & 18 deletions

File tree

arch/lkl/Kconfig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ config LKL
1414
select ARCH_WANT_FRAME_POINTERS
1515
select HAS_DMA
1616
select DMA_DIRECT_OPS
17-
select PHYS_ADDR_T_64BIT if 64BIT
18-
select 64BIT if "$(OUTPUT_FORMAT)" = "elf64-x86-64"
19-
select 64BIT if "$(OUTPUT_FORMAT)" = "pe-x86-64"
20-
select HAVE_UNDERSCORE_SYMBOL_PREFIX if "$(OUTPUT_FORMAT)" = "pe-i386"
21-
select 64BIT if "$(OUTPUT_FORMAT)" = "elf64-x86-64-freebsd"
22-
select 64BIT if "$(OUTPUT_FORMAT)" = "elf64-littleaarch64"
2317
select NET
2418
select MULTIUSER
2519
select INET
@@ -50,14 +44,20 @@ config OUTPUT_FORMAT
5044
config ARCH_DMA_ADDR_T_64BIT
5145
def_bool 64BIT
5246

47+
config PHYS_ADDR_T_64BIT
48+
def_bool 64BIT
49+
5350
config 64BIT
54-
def_bool n
51+
def_bool y if "$(EXEC_FORMAT)" = "elf64" || "$(OUTPUT_FORMAT)" = "pe-x86-64"
5552

5653
config COREDUMP
5754
def_bool n
5855

5956
config BIG_ENDIAN
60-
def_bool n
57+
def_bool y if "$(OUTPUT_FORMAT)" = "elf64-s390"
58+
59+
config CPU_BIG_ENDIAN
60+
def_bool BIG_ENDIAN
6161

6262
config GENERIC_CSUM
6363
def_bool y
@@ -73,7 +73,7 @@ config RWSEM_GENERIC_SPINLOCK
7373
default y
7474

7575
config HAVE_UNDERSCORE_SYMBOL_PREFIX
76-
bool
76+
def_bool y if "$(OUTPUT_FORMAT)" = "pe-i386"
7777
help
7878
Some architectures generate an _ in front of C symbols; things like
7979
module loading and assembly files need to know about this.

arch/lkl/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ include arch/lkl/auto.conf
22

33
KBUILD_CFLAGS += -fno-builtin
44

5-
ifneq (,$(filter $(OUTPUT_FORMAT),elf64-x86-64 elf32-i386 elf64-x86-64-freebsd elf32-littlearm elf64-littleaarch64))
5+
exec_format = $(firstword $(subst -, ,$(OUTPUT_FORMAT)))
6+
7+
ifneq (,$(filter elf64 elf32,$(exec_format)))
68
KBUILD_CFLAGS += -fPIC
7-
else ifneq (,$(filter $(OUTPUT_FORMAT),pe-i386 pe-x86-64 ))
9+
else ifneq (,$(filter pe,$(exec_format)))
810
ifneq ($(OUTPUT_FORMAT),pe-x86-64)
911
prefix=_
1012
endif

arch/lkl/auto.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export OUTPUT_FORMAT=$(shell $(LD) -r -print-output-format)
2+
export EXEC_FORMAT=$(shell echo $(OUTPUT_FORMAT) | cut -d - -f1)

arch/lkl/include/uapi/asm/host_ops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct lkl_sem;
77
struct lkl_tls_key;
88
typedef unsigned long lkl_thread_t;
99
struct lkl_jmp_buf {
10-
unsigned long buf[32];
10+
unsigned long buf[128];
1111
};
1212

1313
/**

tools/lkl/Makefile.autoconf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
POSIX_HOSTS=elf64-x86-64 elf32-i386 elf64-x86-64-freebsd elf32-littlearm elf64-littleaarch64
2-
NT_HOSTS=pe-i386 pe-x86-64
1+
POSIX_HOSTS=elf64 elf32
2+
NT_HOSTS=pe
33

44
define set_autoconf_var
55
$(shell echo "#define LKL_HOST_CONFIG_$(1) $(2)" \
@@ -99,8 +99,9 @@ define do_autoconf
9999
$(eval LD := $(CROSS_COMPILE)ld)
100100
$(eval CC := $(CROSS_COMPILE)gcc)
101101
$(eval LD_FMT := $(shell $(LD) -r -print-output-format))
102-
$(if $(filter $(LD_FMT),$(POSIX_HOSTS)),$(call posix_host,$(LD_FMT)))
103-
$(if $(filter $(LD_FMT),$(NT_HOSTS)),$(call nt_host,$(LD_FMT)))
102+
$(eval EXEC_FMT := $(shell echo $(LD_FMT) | cut -d "-" -f1))
103+
$(if $(filter $(EXEC_FMT),$(POSIX_HOSTS)),$(call posix_host,$(LD_FMT)))
104+
$(if $(filter $(EXEC_FMT),$(NT_HOSTS)),$(call nt_host,$(LD_FMT)))
104105
endef
105106

106107
export do_autoconf

tools/lkl/lib/endian.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define le16toh(x) (x)
1212
#define htole32(x) (x)
1313
#define htole16(x) (x)
14+
#define htole64(x) (x)
1415
#define le64toh(x) (x)
1516
#define htobe32(x) htonl(x)
1617
#define htobe16(x) htons(x)

tools/lkl/lib/virtio_blk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int blk_enqueue(struct virtio_dev *dev, int q, struct virtio_req *req)
5151

5252
lkl_req.type = le32toh(h->type);
5353
lkl_req.prio = le32toh(h->ioprio);
54-
lkl_req.sector = le32toh(h->sector);
54+
lkl_req.sector = le64toh(h->sector);
5555
lkl_req.buf = &req->buf[1];
5656
lkl_req.count = req->buf_count - 2;
5757

@@ -98,7 +98,7 @@ int lkl_disk_add(struct lkl_disk *disk)
9898
ret = -LKL_ENOMEM;
9999
goto out_free;
100100
}
101-
dev->config.capacity = capacity / 512;
101+
dev->config.capacity = htole64(capacity / 512);
102102

103103
ret = virtio_dev_setup(&dev->dev, 1, 32);
104104
if (ret)

0 commit comments

Comments
 (0)