logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git
commit: c38dfe51fd1553fd2b265d67d723b55c817370b9
parent fd9d8083718b83a7982003b5befb28253d17b40c
Author: Michael Forney <mforney@mforney.org>
Date:   Mon,  6 Sep 2021 20:44:43 -0700

tinyemu: Various portability fixes

Diffstat:

Mpkg/tinyemu/patch/0001-Don-t-return-expression-in-function-returning-void.patch20+++++++++++++++++---
Mpkg/tinyemu/patch/0002-Use-BearSSL-for-HMAC-SHA256-and-AES-CBC.patch4++--
Apkg/tinyemu/patch/0003-Avoid-use-of-case-ranges.patch89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/tinyemu/patch/0004-Add-portable-fallbacks-for-__builtin_clz-ll.patch58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/tinyemu/patch/0005-Avoid-statement-expressions-in-container_of-macro.patch28++++++++++++++++++++++++++++
Apkg/tinyemu/patch/0006-Remove-unused-empty-struct.patch26++++++++++++++++++++++++++
Apkg/tinyemu/patch/0007-Avoid-shifting-past-end-of-uint32_t-for-dtb-address.patch27+++++++++++++++++++++++++++
Mpkg/tinyemu/ver2+-
8 files changed, 248 insertions(+), 6 deletions(-)

diff --git a/pkg/tinyemu/patch/0001-Don-t-return-expression-in-function-returning-void.patch b/pkg/tinyemu/patch/0001-Don-t-return-expression-in-function-returning-void.patch @@ -1,4 +1,4 @@ -From 4eb4d3cbddf520f0db68973d1fd95da6d282539c Mon Sep 17 00:00:00 2001 +From 7bcefc4f212311a59a83d78d2f9aae6ce11b1538 Mon Sep 17 00:00:00 2001 From: Michael Forney <mforney@mforney.org> Date: Tue, 2 Jul 2019 17:51:44 -0700 Subject: [PATCH] Don't return expression in function returning void @@ -6,7 +6,8 @@ Subject: [PATCH] Don't return expression in function returning void --- iomem.c | 2 +- temu.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) + vga.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iomem.c b/iomem.c index c63ada0..8a90bb6 100644 @@ -34,6 +35,19 @@ index 7c07f3b..02696a8 100644 } static void slirp_select_fill1(EthernetDevice *net, int *pfd_max, +diff --git a/vga.c b/vga.c +index 908a320..948d590 100644 +--- a/vga.c ++++ b/vga.c +@@ -613,7 +613,7 @@ static uint32_t vga_read_ ## base(void *opaque, uint32_t addr, int size_log2)\ + }\ + static void vga_write_ ## base(void *opaque, uint32_t addr, uint32_t val, int size_log2)\ + {\ +- return vga_ioport_write(opaque, base + addr, val);\ ++ vga_ioport_write(opaque, base + addr, val);\ + } + + VGA_IO(0x3c0) -- -2.22.0 +2.32.0 diff --git a/pkg/tinyemu/patch/0002-Use-BearSSL-for-HMAC-SHA256-and-AES-CBC.patch b/pkg/tinyemu/patch/0002-Use-BearSSL-for-HMAC-SHA256-and-AES-CBC.patch @@ -1,4 +1,4 @@ -From d08311dfe9776fcb5e1b5ca3a4efe0402ad704be Mon Sep 17 00:00:00 2001 +From 2e18341d2d69f10dafd06fbeb3782d41e65fdf87 Mon Sep 17 00:00:00 2001 From: Michael Forney <mforney@mforney.org> Date: Fri, 15 Nov 2019 21:47:49 -0800 Subject: [PATCH] Use BearSSL for HMAC-SHA256 and AES-CBC @@ -139,5 +139,5 @@ index 35b6a4b..952bb69 100644 #ifdef _WIN32 #include <winsock2.h> -- -2.24.0 +2.32.0 diff --git a/pkg/tinyemu/patch/0003-Avoid-use-of-case-ranges.patch b/pkg/tinyemu/patch/0003-Avoid-use-of-case-ranges.patch @@ -0,0 +1,89 @@ +From 8d660bf668aa05e9b5cf10f2fe6171c0462ad34d Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 6 Sep 2021 19:47:41 -0700 +Subject: [PATCH] Avoid use of case ranges + +--- + pci.c | 39 ++------------------------------------- + vga.c | 5 ++--- + 2 files changed, 4 insertions(+), 40 deletions(-) + +diff --git a/pci.c b/pci.c +index d37b737..f0cf05b 100644 +--- a/pci.c ++++ b/pci.c +@@ -291,46 +291,11 @@ static void pci_device_config_write8(PCIDevice *d, uint32_t addr, + switch(d->config[0x0e]) { + case 0x00: + case 0x80: +- switch(addr) { +- case 0x00: +- case 0x01: +- case 0x02: +- case 0x03: +- case 0x08: +- case 0x09: +- case 0x0a: +- case 0x0b: +- case 0x0e: +- case 0x10 ... 0x27: /* base */ +- case 0x30 ... 0x33: /* rom */ +- case 0x3d: +- can_write = 0; +- break; +- default: +- can_write = 1; +- break; +- } ++ can_write = addr >= 0x40 || 1ull << addr & 0xdff0ff000000b0f0; + break; + default: + case 0x01: +- switch(addr) { +- case 0x00: +- case 0x01: +- case 0x02: +- case 0x03: +- case 0x08: +- case 0x09: +- case 0x0a: +- case 0x0b: +- case 0x0e: +- case 0x38 ... 0x3b: /* rom */ +- case 0x3d: +- can_write = 0; +- break; +- default: +- can_write = 1; +- break; +- } ++ can_write = addr >= 0x40 || 1ull << addr & 0xd0ffffffffffb0f0; + break; + } + if (can_write) +diff --git a/vga.c b/vga.c +index 948d590..afe4c3f 100644 +--- a/vga.c ++++ b/vga.c +@@ -506,9 +506,6 @@ static void vga_ioport_write(VGAState *s, uint32_t addr, uint32_t val) + } else { + index = s->ar_index & 0x1f; + switch(index) { +- case 0x00 ... 0x0f: +- s->ar[index] = val & 0x3f; +- break; + case 0x10: + s->ar[index] = val & ~0x10; + break; +@@ -525,6 +522,8 @@ static void vga_ioport_write(VGAState *s, uint32_t addr, uint32_t val) + s->ar[index] = val & ~0xf0; + break; + default: ++ if (index <= 0x0f) ++ s->ar[index] = val & 0x3f; + break; + } + } +-- +2.32.0 + diff --git a/pkg/tinyemu/patch/0004-Add-portable-fallbacks-for-__builtin_clz-ll.patch b/pkg/tinyemu/patch/0004-Add-portable-fallbacks-for-__builtin_clz-ll.patch @@ -0,0 +1,58 @@ +From b87edf043bc03527ac702d1fdc678e930f77a082 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 6 Sep 2021 19:55:08 -0700 +Subject: [PATCH] Add portable fallbacks for __builtin_clz[ll] + +--- + softfp.c | 26 ++++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +diff --git a/softfp.c b/softfp.c +index 2a1aad0..801ecc3 100644 +--- a/softfp.c ++++ b/softfp.c +@@ -35,7 +35,25 @@ static inline int clz32(uint32_t a) + if (a == 0) { + r = 32; + } else { ++#ifdef __GNUC__ + r = __builtin_clz(a); ++#else ++ int t; ++ ++ t = ((a & 0xffff0000) == 0) << 4; ++ a >>= 16 - t; ++ r = t; ++ t = ((a & 0xff00) == 0) << 3; ++ a >>= 8 - t; ++ r |= t; ++ t = ((a & 0xf0) == 0) << 2; ++ a >>= 4 - t; ++ r |= t; ++ t = ((a & 0xc) == 0) << 1; ++ a >>= 2 - t; ++ r |= t; ++ r += 2 - a & -((a & 2) == 0); ++#endif + } + return r; + } +@@ -47,7 +65,15 @@ static inline int clz64(uint64_t a) + r = 64; + } else + { ++#ifdef __GNUC__ + r = __builtin_clzll(a); ++#else ++ int t; ++ ++ t = ((a & 0xffffffff00000000) == 0) << 8; ++ a >>= 32 - t; ++ r = t | clz32(a); ++#endif + } + return r; + } +-- +2.32.0 + diff --git a/pkg/tinyemu/patch/0005-Avoid-statement-expressions-in-container_of-macro.patch b/pkg/tinyemu/patch/0005-Avoid-statement-expressions-in-container_of-macro.patch @@ -0,0 +1,28 @@ +From 29eff3ebdf14cc6238208648a389f92adcedf1d1 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 6 Sep 2021 19:55:48 -0700 +Subject: [PATCH] Avoid statement-expressions in container_of macro + +--- + slirp/ip_input.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/slirp/ip_input.c b/slirp/ip_input.c +index 50ab951..ca004c9 100644 +--- a/slirp/ip_input.c ++++ b/slirp/ip_input.c +@@ -41,9 +41,8 @@ + #include "slirp.h" + #include "ip_icmp.h" + +-#define container_of(ptr, type, member) ({ \ +- const typeof( ((type *)0)->member ) *__mptr = (ptr); \ +- (type *)( (char *)__mptr - offsetof(type,member) );}) ++#define container_of(ptr, type, member) \ ++ (type *)((char *)ptr - offsetof(type, member)) + + static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp); + static void ip_freef(Slirp *slirp, struct ipq *fp); +-- +2.32.0 + diff --git a/pkg/tinyemu/patch/0006-Remove-unused-empty-struct.patch b/pkg/tinyemu/patch/0006-Remove-unused-empty-struct.patch @@ -0,0 +1,26 @@ +From 81c6a8b860e86fabbe4576ecb744696a3ae21a37 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 6 Sep 2021 19:56:26 -0700 +Subject: [PATCH] Remove unused empty struct + +--- + x86_machine.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/x86_machine.c b/x86_machine.c +index db8f6bb..160933f 100644 +--- a/x86_machine.c ++++ b/x86_machine.c +@@ -2206,9 +2206,6 @@ static void pc_vm_send_mouse_event(VirtMachine *s1, int dx, int dy, int dz, + } + } + +-struct screen_info { +-} __attribute__((packed)); +- + /* from plex86 (BSD license) */ + struct __attribute__ ((packed)) linux_params { + /* screen_info structure */ +-- +2.32.0 + diff --git a/pkg/tinyemu/patch/0007-Avoid-shifting-past-end-of-uint32_t-for-dtb-address.patch b/pkg/tinyemu/patch/0007-Avoid-shifting-past-end-of-uint32_t-for-dtb-address.patch @@ -0,0 +1,27 @@ +From 56469bedea5af4f06923e086a65da3131b2239bd Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 6 Sep 2021 20:39:50 -0700 +Subject: [PATCH] Avoid shifting past end of uint32_t for dtb address + +Make it clear that the shifting of the dtb address is intended to +strip the upper 0x1000 bit, since that is the base PC address. +--- + riscv_machine.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/riscv_machine.c b/riscv_machine.c +index a7149fd..6e407c8 100644 +--- a/riscv_machine.c ++++ b/riscv_machine.c +@@ -810,7 +810,7 @@ static void copy_bios(RISCVMachine *s, const uint8_t *buf, int buf_len, + q = (uint32_t *)(ram_ptr + 0x1000); + q[0] = 0x297 + 0x80000000 - 0x1000; /* auipc t0, jump_addr */ + q[1] = 0x597; /* auipc a1, dtb */ +- q[2] = 0x58593 + ((fdt_addr - 4) << 20); /* addi a1, a1, dtb */ ++ q[2] = 0x58593 + ((fdt_addr - 0x1004) << 20); /* addi a1, a1, dtb */ + q[3] = 0xf1402573; /* csrr a0, mhartid */ + q[4] = 0x00028067; /* jalr zero, t0, jump_addr */ + } +-- +2.32.0 + diff --git a/pkg/tinyemu/ver b/pkg/tinyemu/ver @@ -1 +1 @@ -20191221 r0 +20191221 r1