]> git.lizzy.rs Git - plan9front.git/log
plan9front.git
4 years agodevproc: restore psstate info string in procstopwait()
cinap_lenrek [Sun, 8 Sep 2019 16:53:12 +0000 (18:53 +0200)]
devproc: restore psstate info string in procstopwait()

4 years agomerge
cinap_lenrek [Sat, 7 Sep 2019 00:13:35 +0000 (02:13 +0200)]
merge

4 years agoInclude integer limits from generic stdint.h in system-specific stdint.h
Ori Bernstein [Sat, 7 Sep 2019 01:01:52 +0000 (18:01 -0700)]
Include integer limits from generic stdint.h in system-specific stdint.h

4 years agocc: fix void cast crash
cinap_lenrek [Sat, 7 Sep 2019 00:11:18 +0000 (02:11 +0200)]
cc: fix void cast crash

the following code reproduces the crash:

void
foo(void)
{
}

void
main(int argc, char **argv)
{
(void)(1 ? (void)0 : foo());
}

the problem is that side() gives a false positive on the OCOND
with later constant folding eleminating the acutal side effect
and OCAST ending up with two nested OCATS with the nested one
being zapped (type == T).

4 years agoAdd missing UINTsz_MIN defines to ape stdint.h
Ori Bernstein [Fri, 6 Sep 2019 23:33:11 +0000 (16:33 -0700)]
Add missing UINTsz_MIN defines to ape stdint.h

4 years agomerge
Ori Bernstein [Fri, 6 Sep 2019 18:57:08 +0000 (11:57 -0700)]
merge

4 years agosys/src/libventi: define VtEntryNoArchive constant
David du Colombier [Fri, 6 Sep 2019 18:55:35 +0000 (11:55 -0700)]
sys/src/libventi: define VtEntryNoArchive constant

4 years agosys/src/libventi: implement vtsha1 and vtsha1check functions
David du Colombier [Fri, 6 Sep 2019 18:55:18 +0000 (11:55 -0700)]
sys/src/libventi: implement vtsha1 and vtsha1check functions

4 years agosys/src/libventi: implement vtreconn and vtredial functions
David du Colombier [Fri, 6 Sep 2019 18:54:44 +0000 (11:54 -0700)]
sys/src/libventi: implement vtreconn and vtredial functions

4 years agoip/ipconfig: don't leave behind null address when dhcp gets interrupted
cinap_lenrek [Fri, 6 Sep 2019 16:48:35 +0000 (18:48 +0200)]
ip/ipconfig: don't leave behind null address when dhcp gets interrupted

cleanup the null address (::) when the command gets interrupted.

4 years agoAdd RFC2822 (email style) formatted dates to to date(1).
Ori Bernstein [Fri, 6 Sep 2019 15:25:21 +0000 (08:25 -0700)]
Add RFC2822 (email style) formatted dates to to date(1).

4 years agokernel: get rid of tmperrbuf and use syserrstr swapping instead in namec()
cinap_lenrek [Wed, 4 Sep 2019 00:44:39 +0000 (02:44 +0200)]
kernel: get rid of tmperrbuf and use syserrstr swapping instead in namec()

4 years agorune(2): complete source references
cinap_lenrek [Wed, 4 Sep 2019 00:41:22 +0000 (02:41 +0200)]
rune(2): complete source references

4 years agokernel: make exec clear errstr, stop side-channels and truncate on utf8 boundary
cinap_lenrek [Wed, 4 Sep 2019 00:40:41 +0000 (02:40 +0200)]
kernel: make exec clear errstr, stop side-channels and truncate on utf8 boundary

make exec() clear the per process error string
to avoid spurious errors and confusion.

the errstr() syscall used to always swap the
maximum buffer size with memmove(), which is
problematic as this gives access to the garbage
beyond the NUL byte. worse, newproc(), werrstr()
and rerrstr() only clear the first byte of the
input buffer. so random stack rubble could be
leaked across processes.

we change the errstr() syscall to not copy
beyond the NUL byte.

the manpage also documents that errstr() should
truncate on a utf8 boundary so we use utfecpy()
to ensure proper NUL termination.

4 years agobcm64: enable devgpio in kernel configuration (thanks qeed)
cinap_lenrek [Mon, 2 Sep 2019 17:38:44 +0000 (19:38 +0200)]
bcm64: enable devgpio in kernel configuration (thanks qeed)

4 years agondb/dnsquery, ndb/csquery: write ">" prompt to stderr (thanks kvik)
cinap_lenrek [Fri, 30 Aug 2019 18:17:19 +0000 (20:17 +0200)]
ndb/dnsquery, ndb/csquery: write ">" prompt to stderr (thanks kvik)

kvik writes:

dnsquery(8) prints the interactive prompt on stdout together with
query results, making scripted usage unnecessarily difficult.

A straightforward solution is prompting on stderr instead: as
practiced by rc(1), among many others -- promptly taking care of
the issue:

; echo 9front.org mx | ndb/dnsquery >[2]/dev/null

4 years agorsa(2): document asn1encodeRSApriv() and asn1encodeRSApub() functions
cinap_lenrek [Fri, 30 Aug 2019 05:35:54 +0000 (07:35 +0200)]
rsa(2): document asn1encodeRSApriv() and asn1encodeRSApub() functions

4 years agoauth/rsa2asn1: implement private key export with -a flag (thanks kvik)
cinap_lenrek [Fri, 30 Aug 2019 05:34:35 +0000 (07:34 +0200)]
auth/rsa2asn1: implement private key export with -a flag (thanks kvik)

kvik writes:

I needed to convert the RSA private key that was laying around in
secstore into a format understood by UNIX® tools like SSH.

With asn12rsa(8) we can go from the ASN.1/DER to Plan 9 format, but not
back - so I wrote the libsec function asn1encodeRSApriv(2) and used it in
rsa2asn1(8) by adding the -a flag which causes the full private key to be
encoded and output.

4 years agopc64: map kernel text readonly and everything else no-execute
cinap_lenrek [Thu, 29 Aug 2019 05:35:22 +0000 (07:35 +0200)]
pc64: map kernel text readonly and everything else no-execute

the idea is to catch bugs and make kernel exploitation
harder by mapping the kernel text section readonly
and everything else no-execute.

l.s maps the KZERO address space using 2MB pages so
to get the 4K granularity for the text section we use
the new ptesplit() function to split that mapping up.

we need to set EFER no-execute enable bit early
in apbootstrap so secondary application processors
will understand the NX bit in our shared kernel page
tables. also APBOOTSTRAP needs to be kept executable.

rebootjump() needs to mark REBOOTADDR page executable.

4 years ago8l, 6l: fix "unknown relation: TEXT" xfol() bug (thanks mischief)
cinap_lenrek [Wed, 28 Aug 2019 19:01:16 +0000 (21:01 +0200)]
8l, 6l: fix "unknown relation: TEXT" xfol() bug (thanks mischief)

mischief reports:

this assembler input assembles with 6a but makes 6l crash.

 // 6a l.s
 // 6l l.6
 // _intrr: unknown relation: TEXT in _intrr
 // 6l 511: suicide: sys: trap: fault write addr=0x18 pc=0x20789c

 TEXT noteret(SB), 1, $-4
         CLI
         JMP _intrestore // works when commented

 TEXT _intrr(SB), 1, $-4
 _intrestore:
         RET

 TEXT _main(SB), 1, $-4
         RET

4 years agokernel: prohibit changing cache attributes (SG_CACHED|SG_DEVICE) in segattach(),...
cinap_lenrek [Tue, 27 Aug 2019 04:16:20 +0000 (06:16 +0200)]
kernel: prohibit changing cache attributes (SG_CACHED|SG_DEVICE) in segattach(), set SG_RONLY in data2txt()

the user should not be able to change the cache
attributes for a segment in segattach() as this
can cause the same memory to be mapped with
conflicting attributes in the cache.

SG_TEXT should always be mapped with SG_RONLY
attribute. so fix data2txt() to follow the rules.

4 years agokernel: make user stack segment non-executable
cinap_lenrek [Tue, 27 Aug 2019 02:04:46 +0000 (04:04 +0200)]
kernel: make user stack segment non-executable

4 years agopc64: implement NX bit discovery, map kernel mappings no-execute
cinap_lenrek [Tue, 27 Aug 2019 01:55:12 +0000 (03:55 +0200)]
pc64: implement NX bit discovery, map kernel mappings no-execute

4 years agokernel: catch execution read fault on SG_NOEXEC segment (for mips)
cinap_lenrek [Tue, 27 Aug 2019 01:48:51 +0000 (03:48 +0200)]
kernel: catch execution read fault on SG_NOEXEC segment (for mips)

4 years agokernel: catch execution read fault on SG_NOEXEC segment
cinap_lenrek [Tue, 27 Aug 2019 01:47:18 +0000 (03:47 +0200)]
kernel: catch execution read fault on SG_NOEXEC segment

fault() now has an additional pc argument that is
used to detect fault on a non-executable segment.
that is, we check on read fault if the segment
has the SG_NOEXEC attribute and the program counter
is within faulting page.

4 years agokernel: expose no execute bit to portable mmu code as SG_NOEXEC / PTENOEXEC, add...
cinap_lenrek [Mon, 26 Aug 2019 20:34:38 +0000 (22:34 +0200)]
kernel: expose no execute bit to portable mmu code as SG_NOEXEC / PTENOEXEC, add PTECACHED bits

a portable SG_NOEXEC segment attribute was added to allow
non-executable (physical) segments. which will set the
PTENOEXEC bits for putmmu().

in the future, this can be used to make non-executable
stack / bss segments.

the SG_DEVICE attribute was added to distinguish between
mmio regions and uncached memory. only matterns on arm64.

on arm, theres the issue that PTEUNCACHED would have
no bits set when using the hardware bit definitions.
this is the reason bcm, kw, teg2 and omap kernels use
arteficial PTE constants. on zynq, the XN bit was used
as a hack to give PTEUNCACHED a non-zero value and when
the bit is clear then cache attributes where added to
the pte.

to fix this, PTECACHED constant was added.

the portable mmu code in fault.c will now explicitely set
PTECACHED bits for cached memory and PTEUNCACHED for
uncached memory. that way the hardware bit definitions
can be used everywhere.

4 years agovncv: fix snarf buffer realloc memory corruption
qwx [Mon, 26 Aug 2019 15:02:58 +0000 (17:02 +0200)]
vncv: fix snarf buffer realloc memory corruption

fix never updating p when snarf is reallocated,
resulting in memory corruption.

4 years agoemmc: 50MHz highspeed support (from richard miller)
cinap_lenrek [Sun, 25 Aug 2019 18:02:53 +0000 (20:02 +0200)]
emmc: 50MHz highspeed support (from richard miller)

4 years agobcm64: replace emmc2 driver with richard millers sdhc driver
cinap_lenrek [Sun, 25 Aug 2019 16:45:29 +0000 (18:45 +0200)]
bcm64: replace emmc2 driver with richard millers sdhc driver

the new driver supports 50MHz highspeed bus mode
and uses ADMA instead of SDMA.

4 years ago/sys/lib/dist/mkfile: adjust 2GB for pi3 and zynq img
cinap_lenrek [Sat, 24 Aug 2019 14:35:03 +0000 (16:35 +0200)]
/sys/lib/dist/mkfile: adjust 2GB for pi3 and zynq img

4 years ago/sys/lib/dist/mkfile: storage vendors idea of 2GB is deflating
cinap_lenrek [Sat, 24 Aug 2019 14:29:00 +0000 (16:29 +0200)]
/sys/lib/dist/mkfile: storage vendors idea of 2GB is deflating

4 years agobcm64: deal with discontinuous memory regions, avoid virtual memory aliasing, impleme...
cinap_lenrek [Fri, 23 Aug 2019 19:39:20 +0000 (21:39 +0200)]
bcm64: deal with discontinuous memory regions, avoid virtual memory aliasing, implement vmap() proper

on the 2GB and 4GB raspberry pi 4 variants, there are two
memory regions for ram:

[0x00000000..0x3e600000)
[0x40000000..0xfc000000)

the framebuffer is somewhere at the end of the first
GB of memory.

to handle these, we append the region base and limit
of the second region to *maxmem= like:

*maxmem=0x3e600000 0x40000000 0xfc000000

the mmu code has been changed to have non-existing
ram unmapped and mmukmap() now uses small 64K pages
instead of 512GB pages to avoid aliasing (framebuffer).

the VIRTPCI mapping has been removed as we now have
a proper vmap() implementation which assigns vritual
addresses automatically.

4 years agobcm: invalidate cache on Fbinfo after firmware completion
cinap_lenrek [Thu, 22 Aug 2019 00:54:06 +0000 (02:54 +0200)]
bcm: invalidate cache on Fbinfo after firmware completion

4 years agobcm: flush out early boot messages on uart and screen initialization
cinap_lenrek [Thu, 22 Aug 2019 00:52:21 +0000 (02:52 +0200)]
bcm: flush out early boot messages on uart and screen initialization

make early boot messages available by writing out
kmesg.buf after uart and screen initialization.

4 years ago/sys/lib/acid/kernel: fix procstk() for arm64, set kdir for arm/arm64 to bcm/bcm64
cinap_lenrek [Wed, 21 Aug 2019 17:34:24 +0000 (19:34 +0200)]
/sys/lib/acid/kernel: fix procstk() for arm64, set kdir for arm/arm64 to bcm/bcm64

4 years agobcm: set XN bits for kernel device mappings
cinap_lenrek [Wed, 21 Aug 2019 16:28:01 +0000 (18:28 +0200)]
bcm: set XN bits for kernel device mappings

4 years agobcm64: do not use OTP_BOOTMODE_REG to determine OSC frequency (thanks richard miller)
cinap_lenrek [Mon, 19 Aug 2019 14:42:20 +0000 (16:42 +0200)]
bcm64: do not use OTP_BOOTMODE_REG to determine OSC frequency (thanks richard miller)

the register does not seem to be accessible on the Rpi 3b.
so instead hardcode oscfreq in the Soc structure.

4 years agodisk/format: implement long name support
cinap_lenrek [Sun, 18 Aug 2019 23:09:24 +0000 (01:09 +0200)]
disk/format: implement long name support

4 years agoadd missing device tree file for raspberry pi 4
cinap_lenrek [Sun, 18 Aug 2019 20:19:29 +0000 (22:19 +0200)]
add missing device tree file for raspberry pi 4

4 years agoadd raspberry pi 4 kernel and bootloader to pi3.img target
cinap_lenrek [Sun, 18 Aug 2019 19:43:04 +0000 (21:43 +0200)]
add raspberry pi 4 kernel and bootloader to pi3.img target

4 years agobcm64: add support for more than 1GB of ram (untested)
cinap_lenrek [Sun, 18 Aug 2019 19:16:30 +0000 (21:16 +0200)]
bcm64: add support for more than 1GB of ram (untested)

this adds a 4GB KMAP window into the kernel address space
so we can access all physical ram on raspberry pi 4 for
user pages.

note that kernel memory above KZERO is still limited
to 1GB because of DMA restrictions.

4 years agobcm64: add driver for emmc2 controller
cinap_lenrek [Sun, 18 Aug 2019 16:50:24 +0000 (18:50 +0200)]
bcm64: add driver for emmc2 controller

4 years agobcm: fix typo in gpio.c on unused AFedge0 constant
cinap_lenrek [Fri, 16 Aug 2019 17:35:46 +0000 (19:35 +0200)]
bcm: fix typo in gpio.c on unused AFedge0 constant

4 years agobcm64: poll gisb arbiter for asynchronous bus errors
cinap_lenrek [Fri, 16 Aug 2019 17:24:00 +0000 (19:24 +0200)]
bcm64: poll gisb arbiter for asynchronous bus errors

4 years agoethergenet: remove debugging
cinap_lenrek [Fri, 16 Aug 2019 17:22:28 +0000 (19:22 +0200)]
ethergenet: remove debugging

the hangs where caused by missing NX bits on the mmio mappings,
so the debug code is not needed anymore.

4 years agobcm64: set XN bits for kernel device mappings
cinap_lenrek [Fri, 16 Aug 2019 17:05:04 +0000 (19:05 +0200)]
bcm64: set XN bits for kernel device mappings

4 years agocc: use 7 octal digits for 21 bit runes
cinap_lenrek [Mon, 12 Aug 2019 17:15:02 +0000 (19:15 +0200)]
cc: use 7 octal digits for 21 bit runes

4 years agolibauth: do not set errstr in auth_rpc() for ARdone result (thanks majiru)
cinap_lenrek [Fri, 2 Aug 2019 17:06:23 +0000 (19:06 +0200)]
libauth: do not set errstr in auth_rpc() for ARdone result (thanks majiru)

4 years agobcm, bcm64: add vcore support for raspberry pi 3 GPIO expander
cinap_lenrek [Sun, 28 Jul 2019 09:39:57 +0000 (11:39 +0200)]
bcm, bcm64: add vcore support for raspberry pi 3 GPIO expander

4 years agobcm, bcm64: add BCM2711 support for gpiopull(), fix gpiomeminit(), cleanup
cinap_lenrek [Sat, 27 Jul 2019 18:00:53 +0000 (20:00 +0200)]
bcm, bcm64: add BCM2711 support for gpiopull(), fix gpiomeminit(), cleanup

according to the following linux change, BCM2711 uses a different
method for changing pullup/down mode:

https://github.com/raspberrypi/linux/commit/abcfd092860760087b87acbdda0963fe7906839c#diff-cf078559c38543ac72c5db99323e236d

gpiomeminit() was broken, using virtual address for the gpio physseg
instead of the physical one.

cleanup the code, avoid repetition by declaring static u32int *regs
variable. make local variable names consistent.

4 years agobcm64: fix wrong prescaler for generic timer on rpi4
cinap_lenrek [Sat, 27 Jul 2019 15:59:25 +0000 (17:59 +0200)]
bcm64: fix wrong prescaler for generic timer on rpi4

the raspberry pi 4 uses 54 instead of 19.2 MHz crystal.
detect which frequency is used by reading OTP bootmode
register:

https://www.raspberrypi.org/documentation/hardware/raspberrypi/otpbits.md

Bit 1: sets the oscillator frequency to 19.2MHz

4 years agoethergenet: fix flow control negotiation
cinap_lenrek [Thu, 25 Jul 2019 15:44:47 +0000 (17:44 +0200)]
ethergenet: fix flow control negotiation

4 years agobcm, bcm64: clean dma destination buffer before issuing dma in case of non cache...
cinap_lenrek [Thu, 25 Jul 2019 11:55:17 +0000 (13:55 +0200)]
bcm, bcm64: clean dma destination buffer before issuing dma in case of non cache-line-size aligned buffer

4 years agobcm64: add config for raspberry pi 4
cinap_lenrek [Thu, 25 Jul 2019 07:12:40 +0000 (09:12 +0200)]
bcm64: add config for raspberry pi 4

4 years agobcm64: work in progress genet ethernet driver for raspberry pi 4
cinap_lenrek [Thu, 25 Jul 2019 07:11:53 +0000 (09:11 +0200)]
bcm64: work in progress genet ethernet driver for raspberry pi 4

4 years agobcm64: reorganize virtual memory map for rapberry pi4
cinap_lenrek [Thu, 25 Jul 2019 07:10:07 +0000 (09:10 +0200)]
bcm64: reorganize virtual memory map for rapberry pi4

4 years agobcm64: update io.h for pci express and raspberry pi 4
cinap_lenrek [Thu, 25 Jul 2019 07:08:35 +0000 (09:08 +0200)]
bcm64: update io.h for pci express and raspberry pi 4

4 years agobcm64: add pci express driver for raspberry pi 4
cinap_lenrek [Thu, 25 Jul 2019 07:04:50 +0000 (09:04 +0200)]
bcm64: add pci express driver for raspberry pi 4

4 years agobcm64: add gic interrupt controller driver for raspberry pi 4
cinap_lenrek [Thu, 25 Jul 2019 07:02:47 +0000 (09:02 +0200)]
bcm64: add gic interrupt controller driver for raspberry pi 4

4 years agobcm64: add gisb arbiter driver to catch bus timeouts
cinap_lenrek [Thu, 25 Jul 2019 07:01:44 +0000 (09:01 +0200)]
bcm64: add gisb arbiter driver to catch bus timeouts

4 years agobcm, bcm64: make irq.$O optional and add intrdisable(), use intrenable()
cinap_lenrek [Thu, 25 Jul 2019 06:58:58 +0000 (08:58 +0200)]
bcm, bcm64: make irq.$O optional and add intrdisable(), use intrenable()

the raspberry pi 4 has a new interrupt controller and
pci support, so get rid of intrenable() macro and
properly make intrenable function with tbdf argument.

4 years agobcm64: strip debug symbols to make sure .img file is multiple of 4 bytes
cinap_lenrek [Thu, 25 Jul 2019 06:52:46 +0000 (08:52 +0200)]
bcm64: strip debug symbols to make sure .img file is multiple of 4 bytes

the raspberry pi4 firmware refuses to enable the GIC interrup controller
for arm64 when the .img file is not a multiple of 4 bytes. yes, this
is insane and nowhere documented.

4 years agobcm, bcm64: add dmaflush() function and make virtio size and virtual address configur...
cinap_lenrek [Thu, 25 Jul 2019 06:41:37 +0000 (08:41 +0200)]
bcm, bcm64: add dmaflush() function and make virtio size and virtual address configurable in Soc.virtio and Soc.iosize

4 years agobcm, bcm64: add support for device tree parameter passing
cinap_lenrek [Thu, 25 Jul 2019 06:19:12 +0000 (08:19 +0200)]
bcm, bcm64: add support for device tree parameter passing

the new raspberry pi 4 firmware for arm64 seems to have
broken atag support. so we now parse the device tree
structure to get the bootargs and memory configuration.

4 years agousbxhci: implement portable dma flush operations and move to port/
cinap_lenrek [Wed, 17 Jul 2019 08:30:06 +0000 (10:30 +0200)]
usbxhci: implement portable dma flush operations and move to port/

4 years agousbehci: introduce dmaflush() function to handle portable cache invalidation for...
cinap_lenrek [Wed, 17 Jul 2019 08:24:50 +0000 (10:24 +0200)]
usbehci: introduce dmaflush() function to handle portable cache invalidation for device drivers

4 years agomerge
cinap_lenrek [Thu, 11 Jul 2019 05:49:52 +0000 (07:49 +0200)]
merge

4 years agokernel: move common ethermii to port/
cinap_lenrek [Thu, 11 Jul 2019 05:47:39 +0000 (07:47 +0200)]
kernel: move common ethermii to port/

4 years agodevuart: make sure uart is enabled in uartkick()
cinap_lenrek [Thu, 11 Jul 2019 05:45:34 +0000 (07:45 +0200)]
devuart: make sure uart is enabled in uartkick()

5 years agowalk(1): add history section
Alex Musolino [Tue, 2 Jul 2019 14:04:31 +0000 (23:34 +0930)]
walk(1): add history section

5 years agotinc(8): add history section
Alex Musolino [Tue, 2 Jul 2019 12:54:10 +0000 (22:24 +0930)]
tinc(8): add history section

5 years agousbxhci: fix mysterious ENABLESLOT failures (update to XHCI spec revision 1.2 (2019))
cinap_lenrek [Tue, 2 Jul 2019 03:34:13 +0000 (05:34 +0200)]
usbxhci: fix mysterious ENABLESLOT failures (update to XHCI spec revision 1.2 (2019))

Ori Bernstein had Sunrise Point-H USB 3.0 xHCI Controller that would mysteriously
crash on the 5th ENABLESLOT command. This was reproducable by even just allocating
slots in a loop right after init.

It turns out, the 1.2 spec extended the Max Scratchpad Buffers in HCSPARAMS2 so our
driver would not allocate enougth scratchpad buffers and controller firmware would
crash once it went beyond our allocated scratchpad buffer array.

This change also fixes:

- ignore bits 16:31 in PAGESIZE register
- preserve bits 10:31 in the CONFIG register
- handle ADDESSDEV command failure (so it can be retried)

5 years agopc64: preallocate mmupool page tables
cinap_lenrek [Fri, 28 Jun 2019 16:12:13 +0000 (18:12 +0200)]
pc64: preallocate mmupool page tables

preallocate 2% of user pages for page tables and MMU structures
and keep them mapped in the VMAP range. this leaves more space
in the KZERO window and avoids running out of kernel memory on
machines with large amounts of memory.

5 years agoape: reimplement rename() - fixing compiler warnings and handling more error cases
cinap_lenrek [Mon, 24 Jun 2019 18:09:04 +0000 (20:09 +0200)]
ape: reimplement rename() - fixing compiler warnings and handling more error cases

handle empty filename, dot and dotdot. handle mismatching from/to directory/file
type. cleanup destination file on error. error when attempting to copy non-empty
directories.

little test program:

#include <unistd.h>
#include <stdio.h>

int
main(int argc, char *argv[])
{
if(argc != 3){
fprintf(stderr, "usage: %s old new\n", argv[0]);
return 1;
}
if(rename(argv[1], argv[2])){
perror("rename");
return 1;
}
return 0;
}

5 years ago8c, 6c: LEA x, R; MOV (R), R -> MOV x, R
cinap_lenrek [Mon, 24 Jun 2019 17:38:46 +0000 (19:38 +0200)]
8c, 6c: LEA x, R; MOV (R), R -> MOV x, R

5 years ago8c, 6c: avoid allocating index registers when we don't have to
cinap_lenrek [Mon, 24 Jun 2019 17:36:01 +0000 (19:36 +0200)]
8c, 6c: avoid allocating index registers when we don't have to

when a operation receives a chain of OINDEX nodes as its operands,
each indexing step used to allocate a new index register. this
is wastefull an can result in running out of fixed registers on 386
for code such as: x = a[a[a[a[i]]]].

instead we attempt to reuse the destination register of the operation
as the index register if it is not otherwise referenced. this results
in the index chain to use a single register for index and result and
leaves registers free to be used for something usefull instead.

for 6c, try to avoid R13 as well as BP index base register.

5 years ago8c: skip 64-bit regpair allocation for OINDEX nodes in cgen64()
cinap_lenrek [Mon, 24 Jun 2019 17:25:13 +0000 (19:25 +0200)]
8c: skip 64-bit regpair allocation for OINDEX nodes in cgen64()

OINDEX can only return TLONG result on 386 so give it
a register instead of a regpair and let gmove() handle
the conversion.

5 years agoape: revert rename() change
cinap_lenrek [Sun, 23 Jun 2019 20:35:14 +0000 (22:35 +0200)]
ape: revert rename() change

new implementation gets stuck in a infinite loop. backing
this out for now.

5 years agoTurn on warnings when building libap.
Ori Bernstein [Fri, 21 Jun 2019 17:00:58 +0000 (10:00 -0700)]
Turn on warnings when building libap.

For ape, we never enabled warnings in cflags.
Turning it on brings up a lot of warnings. Most are noise,
but a few caught unused variables and trunctaions of pointers.
to smaller integers (int, long).

A few warnings remain.

5 years agogs: apply mitigations against CVE-2017-8291 (thanks jsmoody)
cinap_lenrek [Fri, 21 Jun 2019 16:57:20 +0000 (18:57 +0200)]
gs: apply mitigations against CVE-2017-8291 (thanks jsmoody)

To reproduce:
gs -q -dNOPAUSE -dSAFER '-sDEVICE=ppmraw' '-sOutputFile=/dev/null' <<.
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: -0 -0 100 100

/size_from  10000      def
/size_step    500      def
/size_to   65000      def
/enlarge    1000      def

%/bigarr 65000 array def

0
size_from size_step size_to {
    pop
    1 add
} for

/buffercount exch def

/buffersizes buffercount array def

0
size_from size_step size_to {
    buffersizes exch 2 index exch put
    1 add
} for
pop

/buffers buffercount array def

0 1 buffercount 1 sub {
    /ind exch def
    buffersizes ind get /cursize exch def
    cursize string /curbuf exch def
    buffers ind curbuf put
    cursize 16 sub 1 cursize 1 sub {
        curbuf exch 255 put
    } for
} for

/buffersearchvars [0 0 0 0 0] def
/sdevice [0] def

enlarge array aload

{
    .eqproc
    buffersearchvars 0 buffersearchvars 0 get 1 add put
    buffersearchvars 1 0 put
    buffersearchvars 2 0 put
    buffercount {
        buffers buffersearchvars 1 get get
        buffersizes buffersearchvars 1 get get
        16 sub get
        254 le {
            buffersearchvars 2 1 put
            buffersearchvars 3 buffers buffersearchvars 1 get get put
            buffersearchvars 4 buffersizes buffersearchvars 1 get get 16 sub put
        } if
        buffersearchvars 1 buffersearchvars 1 get 1 add put
    } repeat

    buffersearchvars 2 get 1 ge {
        exit
    } if
    %(.) print
} loop

.eqproc
.eqproc
.eqproc
sdevice 0
currentdevice
buffersearchvars 3 get buffersearchvars 4 get 16#7e put
buffersearchvars 3 get buffersearchvars 4 get 1 add 16#12 put
buffersearchvars 3 get buffersearchvars 4 get 5 add 16#ff put
put

buffersearchvars 0 get array aload

sdevice 0 get
16#3e8 0 put

sdevice 0 get
16#3b0 0 put

sdevice 0 get
16#3f0 0 put

currentdevice null false mark /OutputFile (%pipe%echo gotce)
.putdeviceparams
1 true .outputpage
.rsdparams
%{ } loop
0 0 .quit
%asdf

.

5 years agocwfs: remove orphaned lrand.c
cinap_lenrek [Thu, 20 Jun 2019 12:15:20 +0000 (14:15 +0200)]
cwfs: remove orphaned lrand.c

5 years agocwfs: remove old some assert() debugging
cinap_lenrek [Thu, 20 Jun 2019 12:06:29 +0000 (14:06 +0200)]
cwfs: remove old some assert() debugging

5 years agobcm, kw, omap, teg2: implement setregisters()
cinap_lenrek [Thu, 20 Jun 2019 11:17:36 +0000 (13:17 +0200)]
bcm, kw, omap, teg2: implement setregisters()

5 years agocwfs: fix root access time qid path comparsion
cinap_lenrek [Thu, 20 Jun 2019 11:15:26 +0000 (13:15 +0200)]
cwfs: fix root access time qid path comparsion

5 years agoupas/smtp: handle temporary authentication failures
cinap_lenrek [Thu, 20 Jun 2019 10:13:51 +0000 (12:13 +0200)]
upas/smtp: handle temporary authentication failures

under heavy load, factotum can return a "too much activity" error,
which upas/smtpd and upas/smtp should consider a temporary error
instead of a permanent one.

5 years agorc-httpd: serve markdown with text/plain content-type
Alex Musolino [Thu, 20 Jun 2019 06:56:03 +0000 (16:26 +0930)]
rc-httpd: serve markdown with text/plain content-type

5 years agopc64: actually fix it, what was i THINKING
cinap_lenrek [Wed, 19 Jun 2019 22:36:51 +0000 (00:36 +0200)]
pc64: actually fix it, what was i THINKING

5 years agopc64: fix compiler warning in rebootjump() entry calculation
cinap_lenrek [Wed, 19 Jun 2019 22:32:54 +0000 (00:32 +0200)]
pc64: fix compiler warning in rebootjump() entry calculation

5 years agostdio: fix putc(), plan9 version
cinap_lenrek [Wed, 19 Jun 2019 22:04:58 +0000 (00:04 +0200)]
stdio: fix putc(), plan9 version

5 years agoape: fix stdio putc() macro, avoiding "result of operation not used" warning
cinap_lenrek [Wed, 19 Jun 2019 21:59:25 +0000 (23:59 +0200)]
ape: fix stdio putc() macro, avoiding "result of operation not used" warning

moving _IO_CHMASK masking on the right hand side fixes it.

5 years agocc: remove nullwarn() from OCAST codegen, zap void casts
cinap_lenrek [Wed, 19 Jun 2019 21:50:33 +0000 (23:50 +0200)]
cc: remove nullwarn() from OCAST codegen, zap void casts

implicit casts would cause spurious "result of operation not used"
warnings such as ape's stdio putc() macro.

make (void) casts non-ops when the casted expression has no
side effects. this avoid spurious warning with ape's assert()
macro.

5 years agocwfs: properly handle 64 bit qid path
cinap_lenrek [Wed, 19 Jun 2019 20:58:16 +0000 (22:58 +0200)]
cwfs: properly handle 64 bit qid path

for historical reasons, kenfs stores directory entries in pre 9p2000
format with directories having the QPDIR bit 31 set in the qid path.

however, the 64 bit fileserver allows 64 bit qid paths.

given that we do not support pre 9p2000 clients and do not rely on
the QPDIR, but want to keep the block check tags consistent, we will
*INVERT* the QPDIR bit in directory entry qid paths for directories.

this preserves the on-disk semantics (for < 31 bit qmax) but does
not complicate qid generation and recovery. also makes it easy to
convert between directory entry qid and 9p format.

5 years agopcc: back out -+ flag removal to allow gracefull upgrade path with new pcc but old cpp
cinap_lenrek [Wed, 19 Jun 2019 13:15:35 +0000 (15:15 +0200)]
pcc: back out -+ flag removal to allow gracefull upgrade path with new pcc but old cpp

5 years agoAlways turn on the -+ flag in cpp
Ori Bernstein [Wed, 19 Jun 2019 05:47:15 +0000 (22:47 -0700)]
Always turn on the -+ flag in cpp

C99 comments have been the default in compilers for something like 20 years
now. This means we don't need to remember to turn it on when porting software,
and gets rid of cryptic errors about unterminated character constants when
someone writes something like:

// Didn't need to...

We still accept the flag to avoid breaking mkfiles, but we do nothing with it.

This also removes the documentation, since the option does nothing now.

5 years agoImport compiler warnings and bugfixes from Charles.
Ori Bernstein [Wed, 19 Jun 2019 05:17:19 +0000 (22:17 -0700)]
Import compiler warnings and bugfixes from Charles.

This change imports a few warnings and minor fixes from Charles branch
here: https://bitbucket.org/plan9-from-bell-labs/plan9.

The changes included here:

changeset:   1374:9185dc017be0
summary:     declare castucom; move a declaration into order;
             use cast instead of ULL suffix
changeset:   1353:5fe8380b1818
summary:     supporting functions:
             1. castucom to match unlikely mask operation;
                2. be sure to snap both sides of pointer subtraction completely;
             3. add extra operators as side-effect free
changeset:   1352:90058c092d66
summary:     1. correct result type for mixed-mode assignment operators
             2. detect divide by zero (erik);
             3. detect masks misformed by sign-extension;
             4. diagnose mixed old/new prototypes

5 years agomerge
cinap_lenrek [Tue, 18 Jun 2019 11:29:29 +0000 (13:29 +0200)]
merge

5 years ago8c, 6c: fix INDEX node #reg calculation
cinap_lenrek [Tue, 18 Jun 2019 11:28:15 +0000 (13:28 +0200)]
8c, 6c: fix INDEX node #reg calculation

5 years agoDelete dead code.
Ori Bernstein [Tue, 18 Jun 2019 04:12:35 +0000 (21:12 -0700)]
Delete dead code.

Nothing is using (or even building) bound.[ch]

5 years agorc-httpd: set charset=utf-8 for all text/* content types
Alex Musolino [Mon, 17 Jun 2019 03:47:16 +0000 (13:17 +0930)]
rc-httpd: set charset=utf-8 for all text/* content types

5 years agorc-httpd: only emit charset option for text/plain content type
Alex Musolino [Mon, 17 Jun 2019 03:43:40 +0000 (13:13 +0930)]
rc-httpd: only emit charset option for text/plain content type