Re: Request for testing malloc and multi-threaded applications
On Thu, Dec 27, 2018 at 09:39:56AM +0100, Otto Moerbeek wrote: > > Very little feedback so far. This diff can only give me valid feedback > if the coverage of systems and use cases is wide. If I do not get > more feedback, I have to base my decisions on my own testing, which > will benefit my systems and use cases, but might harm yours. > > So, ladies and gentlemen, start your tests! Another reminder. I like to make progress on this. That means I need tests for various use-cases. Thanks -Otto > > > On Wed, Dec 19, 2018 at 11:20:19AM +0100, Otto Moerbeek wrote: > > > On Wed, Dec 19, 2018 at 10:52:03AM +0100, Otto Moerbeek wrote: > > > > > Hi, > > > > > > This diff implements a more flexible approach for the number of pools > > > malloc uses in the multi-threaded case. At the momemt I do not intend > > > to commit this as-is, I first need this to get some feedback on what > > > the proper default should be. > > > > > > Currently the number of pools is fixed at 4. More pools mean less > > > contention for allocations, but free becomes more expensive since a > > > thread might need to check other pools increasing contention. > > > > > > I'd like to know how this diff behaves using your favorite > > > mutli-threaded application. Often this will be a web-browser I guess. > > > > > > Test instructions: > > > > > > 0. Make sure you are running current. > > > > > > 1. Do a baseline test of your application. > > > > > > 2. Apply diff, build and install userland. > > > > > > 3. Run your test application with MALLOC_OPTIONS=value, where value is: > > > "", +, -, ++, -- and +++. > > > > > > e.g. > > > > > > MALLOC_OPTIONS=++ chrome > > > > > > Note performance. Do multiple tests to get better statistics. > > > > > > If you're not able to do full tests, at least general observations are > > > welcome. Tell a bit about the system you tested on (e.g. number of > > > cores). Note that due to randomization, different runs might show > > > different performance numbers since the pools shared by subsets of > > > threads can turn out differently. > > > > > > Thanks, > > > > > > -Otto > > > > New diff with problem noted by Janne Johansson fixed. > > > > Index: include/thread_private.h > > === > > RCS file: /cvs/src/lib/libc/include/thread_private.h,v > > retrieving revision 1.33 > > diff -u -p -r1.33 thread_private.h > > --- include/thread_private.h5 Dec 2017 13:45:31 - 1.33 > > +++ include/thread_private.h19 Dec 2018 10:18:38 - > > @@ -7,7 +7,7 @@ > > > > #include /* for FILE and __isthreaded */ > > > > -#define _MALLOC_MUTEXES 4 > > +#define _MALLOC_MUTEXES 32 > > void _malloc_init(int); > > #ifdef __LIBC__ > > PROTO_NORMAL(_malloc_init); > > Index: stdlib/malloc.c > > === > > RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v > > retrieving revision 1.257 > > diff -u -p -r1.257 malloc.c > > --- stdlib/malloc.c 10 Dec 2018 07:57:49 - 1.257 > > +++ stdlib/malloc.c 19 Dec 2018 10:18:38 - > > @@ -143,6 +143,8 @@ struct dir_info { > > size_t cheap_reallocs; > > size_t malloc_used; /* bytes allocated */ > > size_t malloc_guarded; /* bytes used for guards */ > > + size_t pool_searches; /* searches for pool */ > > + size_t other_pool; /* searches in other pool */ > > #define STATS_ADD(x,y) ((x) += (y)) > > #define STATS_SUB(x,y) ((x) -= (y)) > > #define STATS_INC(x) ((x)++) > > @@ -179,7 +181,9 @@ struct chunk_info { > > }; > > > > struct malloc_readonly { > > - struct dir_info *malloc_pool[_MALLOC_MUTEXES]; /* Main bookkeeping > > information */ > > + /* Main bookkeeping information */ > > + struct dir_info *malloc_pool[_MALLOC_MUTEXES]; > > + u_int malloc_mutexes; /* how much in actual use? */ > > int malloc_mt; /* multi-threaded mode? */ > > int malloc_freecheck; /* Extensive double free check */ > > int malloc_freeunmap; /* mprotect free pages PROT_NONE? */ > > @@ -267,7 +271,7 @@ getpool(void) > > return mopts.malloc_pool[0]; > > else > > return mopts.malloc_pool[TIB_GET()->tib_tid & > > - (_MALLOC_MUTEXES - 1)]; > > + (mopts.malloc_mutexes - 1)]; > > } > > > > static __dead void > > @@ -316,6 +320,16 @@ static void > > omalloc_parseopt(char opt) > > { > > switch (opt) { > > + case '+': > > + mopts.malloc_mutexes <<= 1; > > + if (mopts.malloc_mutexes > _MALLOC_MUTEXES) > > + mopts.malloc_mutexes = _MALLOC_MUTEXES; > > + break; > > + case '-': > > + mopts.malloc_mutexes >>= 1; > > + if (mopts.malloc_mutexes < 1) > > + mopts.malloc_mutexes = 1; > > + break; > >
Re: unveil file(1)
> unveil isn't really buying much if you pledge "rpath" immediately after, > so if you want just add another pledge here instead, that is fine. "rpath" is obviously cheaper than unveil of even 1 file.
Re: unveil file(1)
On Thu, Jan 03, 2019 at 08:26:00PM -0500, Ted Unangst wrote: > Ted Unangst wrote: > > Bryan Steele wrote: > > > It is not possible to unveil(2) all arguments passed to file(1), as this > > > would require walking *argv. Instead, we can unveil("/", "r") to permit > > > readonly access to the entire filesystem, while restricting all execute > > > write, and create operations. > > > > Why not? Because of the limit? We can still try unveil up to a certain > > limit. > > > > > This only provides some additional early protection for the parent, as > > > the privsep magic(5) parser already pledged tightly. > > > > > > It might be possible to use pledge instead, but this since this process > > > doesn't do much more than opening files and passing descriptors, unveil > > > alone should be enough.. > > > > I think if we want to enforce read only access, pledge is still the way to > > go. > > > > This seems to work. > > oops, forgot the error checking for some unveil calls. this is better. > > > Index: file.c > === > RCS file: /cvs/src/usr.bin/file/file.c,v > retrieving revision 1.66 > diff -u -p -r1.66 file.c > --- file.c15 Jan 2018 19:45:51 - 1.66 > +++ file.c4 Jan 2019 01:24:47 - > @@ -168,6 +168,19 @@ main(int argc, char **argv) > } else if (argc == 0) > usage(); > > + if (argc < 64) { > + if (unveil("/etc/magic", "r") == -1) > + err(1, "unveil"); > + for (idx = 0; idx < argc; idx++) > + if (unveil(argv[idx], "r") == -1) > + err(1, "unveil"); > + if (unveil(NULL, NULL) == -1) > + err(1, "unveil"); > + } > + Agreeing with what Theo said.. It is actually common to run file(1) on directories with a lot of files, i.e: file *|grep. espie@ hit this is in ports when I ade the similar mistake of trying to pre-open files. unveil isn't really buying much if you pledge "rpath" immediately after, so if you want just add another pledge here instead, that is fine. > + if (pledge("stdio rpath getpw recvfd sendfd id proc", NULL) == -1) > + err(1, "pledge"); > + > magicfp = NULL; > if (geteuid() != 0 && !issetugid()) { > home = getenv("HOME");
Re: unveil file(1)
Ted Unangst wrote: > Ted Unangst wrote: > > Bryan Steele wrote: > > > It is not possible to unveil(2) all arguments passed to file(1), as this > > > would require walking *argv. Instead, we can unveil("/", "r") to permit > > > readonly access to the entire filesystem, while restricting all execute > > > write, and create operations. > > > > Why not? Because of the limit? We can still try unveil up to a certain > > limit. > > > > > This only provides some additional early protection for the parent, as > > > the privsep magic(5) parser already pledged tightly. > > > > > > It might be possible to use pledge instead, but this since this process > > > doesn't do much more than opening files and passing descriptors, unveil > > > alone should be enough.. > > > > I think if we want to enforce read only access, pledge is still the way to > > go. > > > > This seems to work. > > oops, forgot the error checking for some unveil calls. this is better. > > > Index: file.c > === > RCS file: /cvs/src/usr.bin/file/file.c,v > retrieving revision 1.66 > diff -u -p -r1.66 file.c > --- file.c15 Jan 2018 19:45:51 - 1.66 > +++ file.c4 Jan 2019 01:24:47 - > @@ -168,6 +168,19 @@ main(int argc, char **argv) > } else if (argc == 0) > usage(); > > + if (argc < 64) { > + if (unveil("/etc/magic", "r") == -1) > + err(1, "unveil"); > + for (idx = 0; idx < argc; idx++) > + if (unveil(argv[idx], "r") == -1) > + err(1, "unveil"); > + if (unveil(NULL, NULL) == -1) > + err(1, "unveil"); > + } > + > + if (pledge("stdio rpath getpw recvfd sendfd id proc", NULL) == -1) > + err(1, "pledge"); > + > magicfp = NULL; > if (geteuid() != 0 && !issetugid()) { > home = getenv("HOME"); > I absolutely do not OK this. You are abusing kernel resources.
Re: unveil file(1)
Ted Unangst wrote: > Bryan Steele wrote: > > It is not possible to unveil(2) all arguments passed to file(1), as this > > would require walking *argv. Instead, we can unveil("/", "r") to permit > > readonly access to the entire filesystem, while restricting all execute > > write, and create operations. > > Why not? Because of the limit? We can still try unveil up to a certain > limit. Absolutely not. Unveiled paths are held vnodes. When you allow processes to have a gigantic pile of them, and allow many processes a gigantic pile of such vnodes, system performance *will* be impacted. The design of unveil is supposed to encourage developers to narrowly define their usage, but at the same time to unveil all argv[] before opening them because then you are hogging resources. So I think your advice here is misguided.
Re: unveil file(1)
Ted Unangst wrote: > Bryan Steele wrote: > > It is not possible to unveil(2) all arguments passed to file(1), as this > > would require walking *argv. Instead, we can unveil("/", "r") to permit > > readonly access to the entire filesystem, while restricting all execute > > write, and create operations. > > Why not? Because of the limit? We can still try unveil up to a certain > limit. > > > This only provides some additional early protection for the parent, as > > the privsep magic(5) parser already pledged tightly. > > > > It might be possible to use pledge instead, but this since this process > > doesn't do much more than opening files and passing descriptors, unveil > > alone should be enough.. > > I think if we want to enforce read only access, pledge is still the way to go. > > This seems to work. oops, forgot the error checking for some unveil calls. this is better. Index: file.c === RCS file: /cvs/src/usr.bin/file/file.c,v retrieving revision 1.66 diff -u -p -r1.66 file.c --- file.c 15 Jan 2018 19:45:51 - 1.66 +++ file.c 4 Jan 2019 01:24:47 - @@ -168,6 +168,19 @@ main(int argc, char **argv) } else if (argc == 0) usage(); + if (argc < 64) { + if (unveil("/etc/magic", "r") == -1) + err(1, "unveil"); + for (idx = 0; idx < argc; idx++) + if (unveil(argv[idx], "r") == -1) + err(1, "unveil"); + if (unveil(NULL, NULL) == -1) + err(1, "unveil"); + } + + if (pledge("stdio rpath getpw recvfd sendfd id proc", NULL) == -1) + err(1, "pledge"); + magicfp = NULL; if (geteuid() != 0 && !issetugid()) { home = getenv("HOME");
Re: unveil file(1)
Bryan Steele wrote: > It is not possible to unveil(2) all arguments passed to file(1), as this > would require walking *argv. Instead, we can unveil("/", "r") to permit > readonly access to the entire filesystem, while restricting all execute > write, and create operations. Why not? Because of the limit? We can still try unveil up to a certain limit. > This only provides some additional early protection for the parent, as > the privsep magic(5) parser already pledged tightly. > > It might be possible to use pledge instead, but this since this process > doesn't do much more than opening files and passing descriptors, unveil > alone should be enough.. I think if we want to enforce read only access, pledge is still the way to go. This seems to work. Index: file.c === RCS file: /cvs/src/usr.bin/file/file.c,v retrieving revision 1.66 diff -u -p -r1.66 file.c --- file.c 15 Jan 2018 19:45:51 - 1.66 +++ file.c 4 Jan 2019 01:22:31 - @@ -168,6 +168,17 @@ main(int argc, char **argv) } else if (argc == 0) usage(); + if (argc < 64) { + unveil("/etc/magic", "r"); + for (idx = 0; idx < argc; idx++) + if (unveil(argv[idx], "r") == -1) + err(1, "unveil"); + unveil(NULL, NULL); + } + + if (pledge("stdio rpath getpw recvfd sendfd id proc", NULL) == -1) + err(1, "pledge"); + magicfp = NULL; if (geteuid() != 0 && !issetugid()) { home = getenv("HOME");
unveil file(1)
It is not possible to unveil(2) all arguments passed to file(1), as this would require walking *argv. Instead, we can unveil("/", "r") to permit readonly access to the entire filesystem, while restricting all execute write, and create operations. This only provides some additional early protection for the parent, as the privsep magic(5) parser already pledged tightly. It might be possible to use pledge instead, but this since this process doesn't do much more than opening files and passing descriptors, unveil alone should be enough.. Needs the recent unveil(2) commit in -current by Bob Beck. ok? Index: file.c === RCS file: /cvs/src/usr.bin/file/file.c,v retrieving revision 1.66 diff -u -p -u -r1.66 file.c --- usr.bin/file/file.c 15 Jan 2018 19:45:51 - 1.66 +++ usr.bin/file/file.c 3 Jan 2019 23:07:41 - @@ -168,6 +168,11 @@ main(int argc, char **argv) } else if (argc == 0) usage(); + if (unveil("/", "r") == -1) + err(1, "unveil"); + if (unveil(NULL, NULL) == -1) + err(1, "unveil"); + magicfp = NULL; if (geteuid() != 0 && !issetugid()) { home = getenv("HOME");
Re: teach arm64 to print unconfigured simplebus devices
ok by me. > On 3 Jan 2019, at 21:47, Jonathan Gray wrote: > > On Wed, Jan 02, 2019 at 04:08:53PM +1000, David Gwynne wrote: >> This makes it more obvious what interesting things there are to hack on. >> >> Thoughts? ok? >> >> For example, from an od1000: >> >> dlg@o1000 fdt$ dmesg | grep 'not configured' > > The whitespace is wrong on 'return (UNCONF)' > > The same diff for armv7 on cubox: > > "dma-apbh" at simplebus0 not configured > "hdmi" at simplebus0 not configured > "gpu" at simplebus0 not configured > "gpu" at simplebus0 not configured > "timer" at simplebus0 not configured > "interrupt-controller" at simplebus0 not configured > "l2-cache" at simplebus0 not configured > "snvs-lpgpr" at syscon0 not configured > "mux-controller" at syscon1 not configured > "ipu1_csi0_mux" at syscon1 not configured > "ipu2_csi1_mux" at syscon1 not configured > "spdif" at simplebus2 not configured > "asrc" at simplebus2 not configured > "vpu" at simplebus1 not configured > "pwm" at simplebus1 not configured > "gpt" at simplebus1 not configured > "ccm" at simplebus1 not configured > "regulator-1p1" at simplebus3 not configured > "regulator-3p0" at simplebus3 not configured > "regulator-2p5" at simplebus3 not configured > "regulator-vddcore" at simplebus3 not configured > "regulator-vddpu" at simplebus3 not configured > "regulator-vddsoc" at simplebus3 not configured > "usbphy" at simplebus1 not configured > "usbphy" at simplebus1 not configured > "snvs" at simplebus1 not configured > "src" at simplebus1 not configured > "iomuxc-gpr" at simplebus1 not configured > "iomuxc" at simplebus1 not configured > "sdma" at simplebus1 not configured > "caam" at simplebus4 not configured > "usbmisc" at simplebus4 not configured > "mmdc" at simplebus4 not configured > "ocotp" at simplebus4 not configured > "vdoa" at simplebus4 not configured > "ipu" at simplebus0 not configured > "sram" at simplebus0 not configured > "gpu" at simplebus0 not configured > "ipu" at simplebus0 not configured > > Index: simplebus.c > === > RCS file: /cvs/src/sys/arch/arm/simplebus/simplebus.c,v > retrieving revision 1.13 > diff -u -p -r1.13 simplebus.c > --- simplebus.c 27 Apr 2017 22:41:46 - 1.13 > +++ simplebus.c 3 Jan 2019 11:39:56 - > @@ -115,6 +115,26 @@ simplebus_submatch(struct device *self, > return 0; > } > > +int > +simplebus_print(void *aux, const char *pnp) > +{ > + struct fdt_attach_args *fa = aux; > + char name[32]; > + > + if (!pnp) > + return (QUIET); > + > + if (OF_getprop(fa->fa_node, "name", name, sizeof(name)) > 0) { > + name[sizeof(name) - 1] = 0; > + printf("\"%s\"", name); > + } else > + printf("node %u", fa->fa_node); > + > + printf(" at %s", pnp); > + > + return (UNCONF); > +} > + > /* > * Look for a driver that wants to be attached to this node. > */ > @@ -180,7 +200,8 @@ simplebus_attach_node(struct device *sel > OF_getpropintarray(node, "interrupts", fa.fa_intr, len); > } > > - config_found_sm(self, , NULL, simplebus_submatch); > + config_found_sm(self, , sc->sc_early ? NULL : simplebus_print, > + simplebus_submatch); > > free(fa.fa_reg, M_DEVBUF, fa.fa_nreg * sizeof(struct fdt_reg)); > free(fa.fa_intr, M_DEVBUF, fa.fa_nintr * sizeof(uint32_t)); >
Re: ohci at fdt (for pine64)
> On 3 Jan 2019, at 20:54, Mark Kettenis wrote: > >> Date: Thu, 3 Jan 2019 12:53:58 +1000 >> From: David Gwynne >> >> this adds support for the ohci controllers seen on the pine64. >> >> it is very quick and very dirty, but it works. i'm able to use a usb1 >> serial dongle now where it didnt even connect before. > > Heh, I thought there would be some ehci to ohci handover issues. USB > 2.0 devices still work with this enabled as well? Yes. It's ehci that handles the handover, ohci is oblivious. > >> >> i believe it relies on the ehci companion setting up the phy. > > Yes. The way that happens is a bit of a hack and maybe at some point > the code needs to be split out in its own driver. But this should be > good enought for now. Cool. > >> ok? > > Basically, yes, but a few comments/nits below. > >> Index: files.fdt >> === >> RCS file: /cvs/src/sys/dev/fdt/files.fdt,v >> retrieving revision 1.74 >> diff -u -p -r1.74 files.fdt >> --- files.fdt27 Aug 2018 21:09:47 - 1.74 >> +++ files.fdt3 Jan 2019 02:49:07 - >> @@ -109,6 +109,9 @@ file dev/fdt/if_dwge_fdt.c dwge_fdt >> attach ehci at fdt with ehci_fdt >> file dev/fdt/ehci_fdt.c ehci_fdt >> >> +attach ohci at fdt with ohci_fdt >> +filedev/fdt/ohci_fdt.c ohci_fdt >> + >> attach sdhc at fdt with sdhc_fdt >> file dev/fdt/sdhc_fdt.c sdhc_fdt >> >> Index: ohci_fdt.c >> === >> RCS file: ohci_fdt.c >> diff -N ohci_fdt.c >> --- /dev/null1 Jan 1970 00:00:00 - >> +++ ohci_fdt.c 3 Jan 2019 02:49:07 - >> @@ -0,0 +1,200 @@ >> +/* $OpenBSD: ohci_fdt.c,v 1.4 2018/08/06 10:52:30 patrick Exp $ */ >> + >> +/* >> + * Copyright (c) 2005, 2019 David Gwynne >> + * Copyright (c) 2017 Mark Kettenis >> + * >> + * Permission to use, copy, modify, and distribute this software for any >> + * purpose with or without fee is hereby granted, provided that the above >> + * copyright notice and this permission notice appear in all copies. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES >> + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF >> + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR >> + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES >> + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN >> + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF >> + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> + >> +struct ohci_fdt_softc { >> +struct ohci_softc sc; >> +int sc_node; >> +void*sc_ih; >> +}; >> + >> +int ohci_fdt_match(struct device *, void *, void *); >> +voidohci_fdt_attach(struct device *, struct device *, void *); >> +int ohci_fdt_detach(struct device *, int); >> + >> +struct cfattach ohci_fdt_ca = { >> +sizeof(struct ohci_fdt_softc), >> +ohci_fdt_match, >> +ohci_fdt_attach, >> +ohci_fdt_detach, >> +ohci_activate >> +}; > > I'd format this the same way as was done for ehci at fdt, but shrug. > >> + >> +static void ohci_fdt_attach_deferred(struct device *); > > Please avoid static. ok. > >> +int >> +ohci_fdt_match(struct device *parent, void *match, void *aux) >> +{ >> +struct fdt_attach_args *faa = aux; >> + >> +return OF_is_compatible(faa->fa_node, "generic-ohci"); >> +} >> + >> +void >> +ohci_fdt_attach(struct device *parent, struct device *self, void *aux) >> +{ >> +struct ohci_fdt_softc *sc = (struct ohci_fdt_softc *)self; >> +struct fdt_attach_args *faa = aux; >> +char *devname = sc->sc.sc_bus.bdev.dv_xname; >> + >> +if (faa->fa_nreg < 1) { >> +printf(": no registers\n"); >> +return; >> +} >> + >> +sc->sc_node = faa->fa_node; >> +sc->sc.iot = faa->fa_iot; >> +sc->sc.sc_bus.dmatag = faa->fa_dmat; >> +sc->sc.sc_size = faa->fa_reg[0].size; >> + >> +if (bus_space_map(sc->sc.iot, faa->fa_reg[0].addr, >> +faa->fa_reg[0].size, 0, >sc.ioh)) { >> +printf(": can't map registers\n"); >> +goto out; >> +} >> + >> +pinctrl_byname(sc->sc_node, "default"); >> + >> +clock_enable_all(sc->sc_node); >> +reset_deassert_all(sc->sc_node); >> + >> +/* Record what interrupts were enabled by SMM/BIOS. */ >> +sc->sc.sc_intre = bus_space_read_4(sc->sc.iot, sc->sc.ioh, >> +OHCI_INTERRUPT_ENABLE); >> + >> +/* Disable interrupts, so we don't get any
Re: pfctl: unbreak build under OPT_DEBUG
Hello, On Thu, Jan 03, 2019 at 08:22:52PM +0100, Klemens Nanni wrote: > In pfctl_optimize.c r1.39 I removed the `af' parameter from `unmask()' > but accidently zapped the macro's closing paranthese. > > Since DEBUG() is needlessly under an OPT_DEBUG guard here, this was not > effecting normal builds. > > Add the missing ')' and remove the ifdef. > > Relevant defines includede here for your convenience: > > /* #define OPT_DEBUG› 1 */ > #ifdef OPT_DEBUG > # define DEBUG(str, v...) \ > printf("%s: " str "\n", __FUNCTION__ , ## v) > #else > # define DEBUG(str, v...) ((void)0) > #endif > > OK? OK sashan
pfctl: unbreak build under OPT_DEBUG
In pfctl_optimize.c r1.39 I removed the `af' parameter from `unmask()' but accidently zapped the macro's closing paranthese. Since DEBUG() is needlessly under an OPT_DEBUG guard here, this was not effecting normal builds. Add the missing ')' and remove the ifdef. Relevant defines includede here for your convenience: /* #define OPT_DEBUG› 1 */ #ifdef OPT_DEBUG # define DEBUG(str, v...) \ printf("%s: " str "\n", __FUNCTION__ , ## v) #else # define DEBUG(str, v...) ((void)0) #endif OK? Index: sbin/pfctl/pfctl_optimize.c === RCS file: /cvs/src/sbin/pfctl/pfctl_optimize.c,v retrieving revision 1.39 diff -u -p -r1.39 pfctl_optimize.c --- sbin/pfctl/pfctl_optimize.c 6 Sep 2018 15:07:33 - 1.39 +++ sbin/pfctl/pfctl_optimize.c 3 Jan 2019 19:07:46 - @@ -1232,11 +1232,9 @@ add_opt_table(struct pfctl *pf, struct p node_host.ifname = ifname; node_host.weight = addr->weight; -#ifdef OPT_DEBUG DEBUG("<%s> adding %s/%d", (*tbl)->pt_name, inet_ntop(af, _host.addr.v.a.addr, buf, sizeof(buf)), - unmask(_host.addr.v.a.mask); -#endif /* OPT_DEBUG */ + unmask(_host.addr.v.a.mask)); if (append_addr_host((*tbl)->pt_buf, _host, 0, 0)) { warn("failed to add host");
Re: Patch to enable building of Octeon kernel with clang
On Thu, Jan 03, 2019 at 04:06:25PM +0100, Janne Johansson wrote: > Den tors 3 jan. 2019 kl 15:25 skrev Visa Hankala : > > > > On Thu, Jan 03, 2019 at 01:16:05PM +0300, Mikhael Skvortsov wrote: > > > Tested by running GENERIC.MP built by > > > make CC=clang COMPILER_VERSION=clang > > > on a CN6120 device. > [...] > > > Index: sys/arch/octeon/dev/octcrypto_asm.S > > > === > > > RCS file: /cvs/src/sys/arch/octeon/dev/octcrypto_asm.S,v > > > retrieving revision 1.1 > > > diff -u -p -u -r1.1 octcrypto_asm.S > > > --- sys/arch/octeon/dev/octcrypto_asm.S9 Apr 2018 13:46:15 - > > > 1.1 > > > +++ sys/arch/octeon/dev/octcrypto_asm.S3 Jan 2019 09:34:57 - > > > @@ -648,7 +648,7 @@ LEAF(octcrypto_ghash_init, 0) > > > dmtc2t0, MT_GFM_RESINP > > > jrra > > > dmtc2t1, MT_GFM_RESINP+1 > > > -END(octcrypto_ghash_set_state) > > > +END(octcrypto_ghash_init) > > This at least seem like a regular mistake in the existing code, > regardless of the rest of the changes/fixups for clang. You are right. I have committed that part.
Re: Patch to enable building of Octeon kernel with clang
Den tors 3 jan. 2019 kl 15:25 skrev Visa Hankala : > > On Thu, Jan 03, 2019 at 01:16:05PM +0300, Mikhael Skvortsov wrote: > > Tested by running GENERIC.MP built by > > make CC=clang COMPILER_VERSION=clang > > on a CN6120 device. [...] > > Index: sys/arch/octeon/dev/octcrypto_asm.S > > === > > RCS file: /cvs/src/sys/arch/octeon/dev/octcrypto_asm.S,v > > retrieving revision 1.1 > > diff -u -p -u -r1.1 octcrypto_asm.S > > --- sys/arch/octeon/dev/octcrypto_asm.S9 Apr 2018 13:46:15 -1.1 > > +++ sys/arch/octeon/dev/octcrypto_asm.S3 Jan 2019 09:34:57 - > > @@ -648,7 +648,7 @@ LEAF(octcrypto_ghash_init, 0) > > dmtc2t0, MT_GFM_RESINP > > jrra > > dmtc2t1, MT_GFM_RESINP+1 > > -END(octcrypto_ghash_set_state) > > +END(octcrypto_ghash_init) This at least seem like a regular mistake in the existing code, regardless of the rest of the changes/fixups for clang. -- May the most significant bit of your life be positive.
Re: Patch to enable building of Octeon kernel with clang
On Thu, Jan 03, 2019 at 01:16:05PM +0300, Mikhael Skvortsov wrote: > Tested by running GENERIC.MP built by > make CC=clang COMPILER_VERSION=clang > on a CN6120 device. Thank you. I have something similar pending and will commit soonish. Certain things have to be done in concert with loongson and sgi. > Index: sys/arch/mips64/mips64/fp_emulate.c > === > RCS file: /cvs/src/sys/arch/mips64/mips64/fp_emulate.c,v > retrieving revision 1.20 > diff -u -p -u -r1.20 fp_emulate.c > --- sys/arch/mips64/mips64/fp_emulate.c22 Oct 2018 17:31:25 -1.20 > +++ sys/arch/mips64/mips64/fp_emulate.c3 Jan 2019 09:34:57 - > @@ -158,8 +158,14 @@ MipsFPTrap(struct trapframe *tf) > sr = getsr(); > setsr(sr | SR_COP_1_BIT); > > -__asm__ volatile ("cfc1 %0, $31" : "=r" (fsr)); > -__asm__ volatile ("cfc1 %0, $31" : "=r" (fsr)); > +__asm__ volatile (".set push\n\t" > + ".set hardfloat\n\t" > + "cfc1 %0, $31\n\t" > + ".set pop" : "=r" (fsr)); > +__asm__ volatile (".set push\n\t" > + ".set hardfloat\n\t" > + "cfc1 %0, $31\n\t" > + ".set pop" : "=r" (fsr)); > > /* > * If this is not an unimplemented operation, but a genuine > @@ -399,7 +405,10 @@ deliver: > tf->fsr = fsr; > > if (CPU_HAS_FPU(ci)) { > -__asm__ volatile ("ctc1 %0, $31" :: "r" (fsr)); > +__asm__ volatile (".set push\n\t" > + ".set hardfloat\n\t" > + "ctc1 %0, $31\n\t" > + ".set pop" :: "r" (fsr)); > /* disable fpu before returning to trap() */ > setsr(sr); > } > Index: sys/arch/mips64/mips64/lcore_float.S > === > RCS file: /cvs/src/sys/arch/mips64/mips64/lcore_float.S,v > retrieving revision 1.22 > diff -u -p -u -r1.22 lcore_float.S > --- sys/arch/mips64/mips64/lcore_float.S3 Oct 2012 11:18:23 -1.22 > +++ sys/arch/mips64/mips64/lcore_float.S3 Jan 2019 09:34:57 - > @@ -39,6 +39,7 @@ > > .setmips3 > .setnoreorder# Noreorder is default style! > +.sethardfloat > > > /* > * > Index: sys/arch/mips64/mips64/tlbhandler.S > === > RCS file: /cvs/src/sys/arch/mips64/mips64/tlbhandler.S,v > retrieving revision 1.48 > diff -u -p -u -r1.48 tlbhandler.S > --- sys/arch/mips64/mips64/tlbhandler.S13 Dec 2018 16:35:07 -1.48 > +++ sys/arch/mips64/mips64/tlbhandler.S3 Jan 2019 09:34:57 - > @@ -337,7 +337,7 @@ sys_stk_chk: > GET_CPU_INFO(k1, k0) > PTR_Lk1, CI_CURPROCPADDR(k1) > PTR_SUBU k0, sp, k1# check to see if we have a > -sltiuk0, 2048# valid kernel stack > +sltiuk0, k0, 2048# valid kernel stack > beqzk0, go_k_general# yes, handle. > nop > > @@ -414,7 +414,8 @@ LEAF(tlb_flush, 0) > mtc0ta1, COP_0_TLB_INDEX# Set the index register. > #ifdef CPU_OCTEON > dmtc0v0, COP_0_TLB_HI# Mark entry high as invalid > -PTR_ADDU v0, v0, 2 * PAGE_SIZE > +lita2, 2 * PAGE_SIZE > +PTR_ADDU v0, v0, ta2 > #endif > adduta1, ta1, 1# Increment index. > TLB_HAZARD > Index: sys/arch/octeon/conf/Makefile.octeon > === > RCS file: /cvs/src/sys/arch/octeon/conf/Makefile.octeon,v > retrieving revision 1.51 > diff -u -p -u -r1.51 Makefile.octeon > --- sys/arch/octeon/conf/Makefile.octeon31 Oct 2018 10:15:47 -1.51 > +++ sys/arch/octeon/conf/Makefile.octeon3 Jan 2019 09:34:57 - > @@ -43,6 +43,10 @@ CMACHFLAGS+=-fno-stack-protector > .if ${IDENT:M-DSMALL_KERNEL} > SORTR=cat > .endif > +.if ${COMPILER_VERSION:Mclang} > +NO_INTEGR_AS= -no-integrated-as > +CWARNFLAGS+=-Wno-address-of-packed-member -Wno-constant-conversion > +.endif > > DEBUG?=-g > COPTS?=-O2 > @@ -100,7 +104,7 @@ LINKFLAGS+=-S > assym.h: $S/kern/genassym.sh Makefile \ > ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf > cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ > -sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF > assym.P > assym.h.tmp > +sh $S/kern/genassym.sh ${CC} ${NO_INTEGR_AS} ${CFLAGS} > ${CPPFLAGS} -MF assym.P > assym.h.tmp > sed '1s/.*/assym.h: \\/' assym.P > assym.d > sort -u assym.h.tmp > assym.h > > Index: sys/arch/octeon/dev/octcrypto_asm.S > === > RCS file: /cvs/src/sys/arch/octeon/dev/octcrypto_asm.S,v > retrieving revision 1.1 > diff -u -p -u -r1.1 octcrypto_asm.S > ---
Re: revised patch: tail(1) do not try to reopen stdin
On 1/3/19 11:08 AM, leo_...@volny.cz wrote: > Alright, these ones get rid of is_stdin altogether. Isn't it better this > way? > Looks OK to me, anyone else want to OK this? martijn@ >--zeurkous. > > Index: src/usr.bin/tail/extern.h > === > RCS file: /cvs/src/usr.bin/tail/extern.h,v > retrieving revision 1.12 > diff -u -p -r1.12 extern.h > --- src/usr.bin/tail/extern.h 19 Nov 2015 17:50:04 - 1.12 > +++ src/usr.bin/tail/extern.h 3 Jan 2019 10:00:59 - > @@ -55,4 +55,3 @@ void oerr(void); > void printfname(const char *); > > extern int fflag, rflag, rval; > -extern int is_stdin; > > Index: src/usr.bin/tail/forward.c > === > RCS file: /cvs/src/usr.bin/tail/forward.c,v > retrieving revision 1.31 > diff -u -p -r1.31 forward.c > --- src/usr.bin/tail/forward.c5 Jul 2016 05:06:27 - 1.31 > +++ src/usr.bin/tail/forward.c3 Jan 2019 10:00:59 - > @@ -335,7 +335,8 @@ tfreopen(struct tailfile *tf) { > struct tailfile **treopen, *ttf; > int i; > > - if (tf && ((stat(tf->fname, ) != 0) || sb.st_ino != tf->sb.st_ino)) { > + if (tf && !(tf->fp == stdin) && > + ((stat(tf->fname, ) != 0) || sb.st_ino != tf->sb.st_ino)) { > if (afiles < ++nfiles) { > afiles += AFILESINCR; > treopen = reallocarray(reopen, afiles, sizeof(*reopen)); > > Index: src/usr.bin/tail/tail.c > === > RCS file: /cvs/src/usr.bin/tail/tail.c,v > retrieving revision 1.21 > diff -u -p -r1.21 tail.c > --- src/usr.bin/tail/tail.c 3 Feb 2016 12:23:57 - 1.21 > +++ src/usr.bin/tail/tail.c 3 Jan 2019 10:00:59 - > @@ -45,7 +45,6 @@ > #include "extern.h" > > int fflag, rflag, rval; > -int is_stdin; > > static void obsolete(char **); > static void usage(void); > @@ -173,7 +172,6 @@ main(int argc, char *argv[]) > > tf[0].fname = "stdin"; > tf[0].fp = stdin; > - is_stdin = 1; > > if (fstat(fileno(stdin), &(tf[0].sb))) { > ierr(tf[0].fname); >
Re: teach arm64 to print unconfigured simplebus devices
On Wed, Jan 02, 2019 at 04:08:53PM +1000, David Gwynne wrote: > This makes it more obvious what interesting things there are to hack on. > > Thoughts? ok? > > For example, from an od1000: > > dlg@o1000 fdt$ dmesg | grep 'not configured' The whitespace is wrong on 'return (UNCONF)' The same diff for armv7 on cubox: "dma-apbh" at simplebus0 not configured "hdmi" at simplebus0 not configured "gpu" at simplebus0 not configured "gpu" at simplebus0 not configured "timer" at simplebus0 not configured "interrupt-controller" at simplebus0 not configured "l2-cache" at simplebus0 not configured "snvs-lpgpr" at syscon0 not configured "mux-controller" at syscon1 not configured "ipu1_csi0_mux" at syscon1 not configured "ipu2_csi1_mux" at syscon1 not configured "spdif" at simplebus2 not configured "asrc" at simplebus2 not configured "vpu" at simplebus1 not configured "pwm" at simplebus1 not configured "gpt" at simplebus1 not configured "ccm" at simplebus1 not configured "regulator-1p1" at simplebus3 not configured "regulator-3p0" at simplebus3 not configured "regulator-2p5" at simplebus3 not configured "regulator-vddcore" at simplebus3 not configured "regulator-vddpu" at simplebus3 not configured "regulator-vddsoc" at simplebus3 not configured "usbphy" at simplebus1 not configured "usbphy" at simplebus1 not configured "snvs" at simplebus1 not configured "src" at simplebus1 not configured "iomuxc-gpr" at simplebus1 not configured "iomuxc" at simplebus1 not configured "sdma" at simplebus1 not configured "caam" at simplebus4 not configured "usbmisc" at simplebus4 not configured "mmdc" at simplebus4 not configured "ocotp" at simplebus4 not configured "vdoa" at simplebus4 not configured "ipu" at simplebus0 not configured "sram" at simplebus0 not configured "gpu" at simplebus0 not configured "ipu" at simplebus0 not configured Index: simplebus.c === RCS file: /cvs/src/sys/arch/arm/simplebus/simplebus.c,v retrieving revision 1.13 diff -u -p -r1.13 simplebus.c --- simplebus.c 27 Apr 2017 22:41:46 - 1.13 +++ simplebus.c 3 Jan 2019 11:39:56 - @@ -115,6 +115,26 @@ simplebus_submatch(struct device *self, return 0; } +int +simplebus_print(void *aux, const char *pnp) +{ + struct fdt_attach_args *fa = aux; + char name[32]; + + if (!pnp) + return (QUIET); + + if (OF_getprop(fa->fa_node, "name", name, sizeof(name)) > 0) { + name[sizeof(name) - 1] = 0; + printf("\"%s\"", name); + } else + printf("node %u", fa->fa_node); + + printf(" at %s", pnp); + + return (UNCONF); +} + /* * Look for a driver that wants to be attached to this node. */ @@ -180,7 +200,8 @@ simplebus_attach_node(struct device *sel OF_getpropintarray(node, "interrupts", fa.fa_intr, len); } - config_found_sm(self, , NULL, simplebus_submatch); + config_found_sm(self, , sc->sc_early ? NULL : simplebus_print, + simplebus_submatch); free(fa.fa_reg, M_DEVBUF, fa.fa_nreg * sizeof(struct fdt_reg)); free(fa.fa_intr, M_DEVBUF, fa.fa_nintr * sizeof(uint32_t));
revised patch: tail(1) do not try to reopen stdin
Alright, these ones get rid of is_stdin altogether. Isn't it better this way? --zeurkous. Index: src/usr.bin/tail/extern.h === RCS file: /cvs/src/usr.bin/tail/extern.h,v retrieving revision 1.12 diff -u -p -r1.12 extern.h --- src/usr.bin/tail/extern.h 19 Nov 2015 17:50:04 - 1.12 +++ src/usr.bin/tail/extern.h 3 Jan 2019 10:00:59 - @@ -55,4 +55,3 @@ void oerr(void); void printfname(const char *); extern int fflag, rflag, rval; -extern int is_stdin; Index: src/usr.bin/tail/forward.c === RCS file: /cvs/src/usr.bin/tail/forward.c,v retrieving revision 1.31 diff -u -p -r1.31 forward.c --- src/usr.bin/tail/forward.c 5 Jul 2016 05:06:27 - 1.31 +++ src/usr.bin/tail/forward.c 3 Jan 2019 10:00:59 - @@ -335,7 +335,8 @@ tfreopen(struct tailfile *tf) { struct tailfile **treopen, *ttf; int i; - if (tf && ((stat(tf->fname, ) != 0) || sb.st_ino != tf->sb.st_ino)) { + if (tf && !(tf->fp == stdin) && + ((stat(tf->fname, ) != 0) || sb.st_ino != tf->sb.st_ino)) { if (afiles < ++nfiles) { afiles += AFILESINCR; treopen = reallocarray(reopen, afiles, sizeof(*reopen)); Index: src/usr.bin/tail/tail.c === RCS file: /cvs/src/usr.bin/tail/tail.c,v retrieving revision 1.21 diff -u -p -r1.21 tail.c --- src/usr.bin/tail/tail.c 3 Feb 2016 12:23:57 - 1.21 +++ src/usr.bin/tail/tail.c 3 Jan 2019 10:00:59 - @@ -45,7 +45,6 @@ #include "extern.h" int fflag, rflag, rval; -int is_stdin; static void obsolete(char **); static void usage(void); @@ -173,7 +172,6 @@ main(int argc, char *argv[]) tf[0].fname = "stdin"; tf[0].fp = stdin; - is_stdin = 1; if (fstat(fileno(stdin), &(tf[0].sb))) { ierr(tf[0].fname);
Re: ohci at fdt (for pine64)
> Date: Thu, 3 Jan 2019 12:53:58 +1000 > From: David Gwynne > > this adds support for the ohci controllers seen on the pine64. > > it is very quick and very dirty, but it works. i'm able to use a usb1 > serial dongle now where it didnt even connect before. Heh, I thought there would be some ehci to ohci handover issues. USB 2.0 devices still work with this enabled as well? > > i believe it relies on the ehci companion setting up the phy. Yes. The way that happens is a bit of a hack and maybe at some point the code needs to be split out in its own driver. But this should be good enought for now. > ok? Basically, yes, but a few comments/nits below. > Index: files.fdt > === > RCS file: /cvs/src/sys/dev/fdt/files.fdt,v > retrieving revision 1.74 > diff -u -p -r1.74 files.fdt > --- files.fdt 27 Aug 2018 21:09:47 - 1.74 > +++ files.fdt 3 Jan 2019 02:49:07 - > @@ -109,6 +109,9 @@ file dev/fdt/if_dwge_fdt.c dwge_fdt > attach ehci at fdt with ehci_fdt > file dev/fdt/ehci_fdt.c ehci_fdt > > +attach ohci at fdt with ohci_fdt > +file dev/fdt/ohci_fdt.c ohci_fdt > + > attach sdhc at fdt with sdhc_fdt > file dev/fdt/sdhc_fdt.c sdhc_fdt > > Index: ohci_fdt.c > === > RCS file: ohci_fdt.c > diff -N ohci_fdt.c > --- /dev/null 1 Jan 1970 00:00:00 - > +++ ohci_fdt.c3 Jan 2019 02:49:07 - > @@ -0,0 +1,200 @@ > +/* $OpenBSD: ohci_fdt.c,v 1.4 2018/08/06 10:52:30 patrick Exp $ */ > + > +/* > + * Copyright (c) 2005, 2019 David Gwynne > + * Copyright (c) 2017 Mark Kettenis > + * > + * Permission to use, copy, modify, and distribute this software for any > + * purpose with or without fee is hereby granted, provided that the above > + * copyright notice and this permission notice appear in all copies. > + * > + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES > + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF > + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR > + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES > + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > + */ > + > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +struct ohci_fdt_softc { > + struct ohci_softc sc; > + int sc_node; > + void*sc_ih; > +}; > + > +int ohci_fdt_match(struct device *, void *, void *); > +void ohci_fdt_attach(struct device *, struct device *, void *); > +int ohci_fdt_detach(struct device *, int); > + > +struct cfattach ohci_fdt_ca = { > + sizeof(struct ohci_fdt_softc), > + ohci_fdt_match, > + ohci_fdt_attach, > + ohci_fdt_detach, > + ohci_activate > +}; I'd format this the same way as was done for ehci at fdt, but shrug. > + > +static void ohci_fdt_attach_deferred(struct device *); Please avoid static. > +int > +ohci_fdt_match(struct device *parent, void *match, void *aux) > +{ > + struct fdt_attach_args *faa = aux; > + > + return OF_is_compatible(faa->fa_node, "generic-ohci"); > +} > + > +void > +ohci_fdt_attach(struct device *parent, struct device *self, void *aux) > +{ > + struct ohci_fdt_softc *sc = (struct ohci_fdt_softc *)self; > + struct fdt_attach_args *faa = aux; > + char *devname = sc->sc.sc_bus.bdev.dv_xname; > + > + if (faa->fa_nreg < 1) { > + printf(": no registers\n"); > + return; > + } > + > + sc->sc_node = faa->fa_node; > + sc->sc.iot = faa->fa_iot; > + sc->sc.sc_bus.dmatag = faa->fa_dmat; > + sc->sc.sc_size = faa->fa_reg[0].size; > + > + if (bus_space_map(sc->sc.iot, faa->fa_reg[0].addr, > + faa->fa_reg[0].size, 0, >sc.ioh)) { > + printf(": can't map registers\n"); > + goto out; > + } > + > + pinctrl_byname(sc->sc_node, "default"); > + > + clock_enable_all(sc->sc_node); > + reset_deassert_all(sc->sc_node); > + > + /* Record what interrupts were enabled by SMM/BIOS. */ > + sc->sc.sc_intre = bus_space_read_4(sc->sc.iot, sc->sc.ioh, > + OHCI_INTERRUPT_ENABLE); > + > + /* Disable interrupts, so we don't get any spurious ones. */ > + bus_space_write_4(sc->sc.iot, sc->sc.ioh, OHCI_INTERRUPT_DISABLE, > + OHCI_MIE); > + > + bus_space_barrier(sc->sc.iot, sc->sc.ioh, 0, sc->sc.sc_size, > + BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE); > + bus_space_write_4(sc->sc.iot, sc->sc.ioh,
Re: teach arm64 to print unconfigured simplebus devices
> From: David Gwynne > Date: Thu, 3 Jan 2019 09:39:29 +1000 > > > On 2 Jan 2019, at 21:16, Mark Kettenis wrote: > > > >> dlg@o1000 fdt$ dmesg | grep 'not configured' > >> "v2m" at ampintc0 not configured > > > > Hmm, ampintcmsi(4) should attach to that one. Doesn't it attach > > on your machine? Or is there something not quite right in your > > printing logic? > > My build box was still somewhere in 6.3, so it's likely support was > added after I checked out the code. I'm upgrading it now. > > After installing a snap I get: > > ampintcmsi0 at ampintc0: nspi 256 Good!. > >> "clk100mhz_0" at simplebus0 not configured > >> "clk375mhz" at simplebus0 not configured > >> "clk333mhz" at simplebus0 not configured > >> "clk500mhz_0" at simplebus0 not configured > >> "clk500mhz_1" at simplebus0 not configured > >> "clk250mhz_4" at simplebus0 not configured > >> "clk100mhz_1" at simplebus0 not configured > > > > These are clocks that we support without a specific driver that we > > probably should knock out. That can be done later though. > > When you say "knock out" do you mean blacklist matching on them, or > to knock out a small driver to implement the functionality? Probably just blacklist them. But let's wait with that a bit. I'd like to see a few dmesgs with all the "not configured" devices in there. So ok kettenis@ on the diff.
Patch to enable building of Octeon kernel with clang
Tested by running GENERIC.MP built by make CC=clang COMPILER_VERSION=clang on a CN6120 device. Index: sys/arch/mips64/mips64/fp_emulate.c === RCS file: /cvs/src/sys/arch/mips64/mips64/fp_emulate.c,v retrieving revision 1.20 diff -u -p -u -r1.20 fp_emulate.c --- sys/arch/mips64/mips64/fp_emulate.c22 Oct 2018 17:31:25 -1.20 +++ sys/arch/mips64/mips64/fp_emulate.c3 Jan 2019 09:34:57 - @@ -158,8 +158,14 @@ MipsFPTrap(struct trapframe *tf) sr = getsr(); setsr(sr | SR_COP_1_BIT); -__asm__ volatile ("cfc1 %0, $31" : "=r" (fsr)); -__asm__ volatile ("cfc1 %0, $31" : "=r" (fsr)); +__asm__ volatile (".set push\n\t" + ".set hardfloat\n\t" + "cfc1 %0, $31\n\t" + ".set pop" : "=r" (fsr)); +__asm__ volatile (".set push\n\t" + ".set hardfloat\n\t" + "cfc1 %0, $31\n\t" + ".set pop" : "=r" (fsr)); /* * If this is not an unimplemented operation, but a genuine @@ -399,7 +405,10 @@ deliver: tf->fsr = fsr; if (CPU_HAS_FPU(ci)) { -__asm__ volatile ("ctc1 %0, $31" :: "r" (fsr)); +__asm__ volatile (".set push\n\t" + ".set hardfloat\n\t" + "ctc1 %0, $31\n\t" + ".set pop" :: "r" (fsr)); /* disable fpu before returning to trap() */ setsr(sr); } Index: sys/arch/mips64/mips64/lcore_float.S === RCS file: /cvs/src/sys/arch/mips64/mips64/lcore_float.S,v retrieving revision 1.22 diff -u -p -u -r1.22 lcore_float.S --- sys/arch/mips64/mips64/lcore_float.S3 Oct 2012 11:18:23 -1.22 +++ sys/arch/mips64/mips64/lcore_float.S3 Jan 2019 09:34:57 - @@ -39,6 +39,7 @@ .setmips3 .setnoreorder# Noreorder is default style! +.sethardfloat /* * Index: sys/arch/mips64/mips64/tlbhandler.S === RCS file: /cvs/src/sys/arch/mips64/mips64/tlbhandler.S,v retrieving revision 1.48 diff -u -p -u -r1.48 tlbhandler.S --- sys/arch/mips64/mips64/tlbhandler.S13 Dec 2018 16:35:07 -1.48 +++ sys/arch/mips64/mips64/tlbhandler.S3 Jan 2019 09:34:57 - @@ -337,7 +337,7 @@ sys_stk_chk: GET_CPU_INFO(k1, k0) PTR_Lk1, CI_CURPROCPADDR(k1) PTR_SUBU k0, sp, k1# check to see if we have a -sltiuk0, 2048# valid kernel stack +sltiuk0, k0, 2048# valid kernel stack beqzk0, go_k_general# yes, handle. nop @@ -414,7 +414,8 @@ LEAF(tlb_flush, 0) mtc0ta1, COP_0_TLB_INDEX# Set the index register. #ifdef CPU_OCTEON dmtc0v0, COP_0_TLB_HI# Mark entry high as invalid -PTR_ADDU v0, v0, 2 * PAGE_SIZE +lita2, 2 * PAGE_SIZE +PTR_ADDU v0, v0, ta2 #endif adduta1, ta1, 1# Increment index. TLB_HAZARD Index: sys/arch/octeon/conf/Makefile.octeon === RCS file: /cvs/src/sys/arch/octeon/conf/Makefile.octeon,v retrieving revision 1.51 diff -u -p -u -r1.51 Makefile.octeon --- sys/arch/octeon/conf/Makefile.octeon31 Oct 2018 10:15:47 -1.51 +++ sys/arch/octeon/conf/Makefile.octeon3 Jan 2019 09:34:57 - @@ -43,6 +43,10 @@ CMACHFLAGS+=-fno-stack-protector .if ${IDENT:M-DSMALL_KERNEL} SORTR=cat .endif +.if ${COMPILER_VERSION:Mclang} +NO_INTEGR_AS= -no-integrated-as +CWARNFLAGS+=-Wno-address-of-packed-member -Wno-constant-conversion +.endif DEBUG?=-g COPTS?=-O2 @@ -100,7 +104,7 @@ LINKFLAGS+=-S assym.h: $S/kern/genassym.sh Makefile \ ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ -sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp +sh $S/kern/genassym.sh ${CC} ${NO_INTEGR_AS} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp sed '1s/.*/assym.h: \\/' assym.P > assym.d sort -u assym.h.tmp > assym.h Index: sys/arch/octeon/dev/octcrypto_asm.S === RCS file: /cvs/src/sys/arch/octeon/dev/octcrypto_asm.S,v retrieving revision 1.1 diff -u -p -u -r1.1 octcrypto_asm.S --- sys/arch/octeon/dev/octcrypto_asm.S9 Apr 2018 13:46:15 -1.1 +++ sys/arch/octeon/dev/octcrypto_asm.S3 Jan 2019 09:34:57 - @@ -648,7 +648,7 @@ LEAF(octcrypto_ghash_init, 0) dmtc2t0, MT_GFM_RESINP jrra dmtc2t1, MT_GFM_RESINP+1 -END(octcrypto_ghash_set_state) +END(octcrypto_ghash_init) /* * void octcrypto_ghash_finish(uint64_t *x)