Re: Use -z notext -z norelro for armv7 efiboot

2018-06-22 Thread Philip Guenther
On Fri, Jun 22, 2018 at 3:04 AM Mark Kettenis 
wrote:

> Creating relocations inside .text is inherent to the way we wrap an
> ELF shared object inside a PE executable.  But without -z notext
> lld(1) complains about this.  Also pass -z norelro to suppress the
> creation of a separate rodata segment that makes lld(1) complain about
> relocations against a read-only section.  This makes it possible to
> build efiboot with lld(1) on armv7.
>
> ok?
>

ok guenther@


Re: make process.ps_start an uptime instead of a realtime

2018-06-22 Thread Scott Cheloha
On Tue, Jun 05, 2018 at 03:57:48PM -0600, Todd C. Miller wrote:
> On Tue, 05 Jun 2018 16:30:14 -0500, Scott Cheloha wrote:
> 
> > Because the system clock can jump around, process start times
> > should be recorded as offsets from boot and only converted to
> > a time of day on request.
> >
> > This keeps ps(1)'s etime accurate and ensures processes are
> > correctly sorted by age in ps(1) and pgrep(1).
> 
> Looks good.
> 
> > I don't think we're losing much by declining to preserve the
> > time of day when the process forked.
> >
> > FreeBSD has made this change, though NetBSD has not.
> >
> > The attached patch isn't perfect, as there remains a small window
> > after kvm_getprocs is called where the system clock can jump again.
> > To circumvent that we'd need to compute the elapsed real time for
> > the process in the kernel, or pass out ps_start alongside the derived
> > time of day and let userspace compute the elapsed realtime with
> > the CLOCK_BOOTTIME clock.  Unsure how people feel about extending
> > kinfo_proc, though.
> 
> I really don't this is worth worrying about.  In the current state
> of things, if the system clock jumps the process start time as
> reported by ps will be incorrect anyway.  This seems like an
> improvement.
>
> > This change doesn't require any userspace recompilation for inspecting
> > a live kernel: on reboot -lkvm binaries behave as expected.
> 
> Great.  I was worried that consumers of p_ustart_{sec,usec} would
> need to change but I can see that is not the case.

Update: here is a completed patch.  This now adds bits to libkvm that
derive the process starting time in the coredump case.  It doesn't take
subseconds into account: for that we'd need to expose the timehands
definition to userspace.  So I left a comment marking the way forward
for the intrepid.

For the coredump case to work obviously libkvm itself will need to be
recompiled, as will statically linked binaries like ps(1), otherwise
you'll get zeroes for your process starting times and ps(1) will claim
all the processes on your cored system started in ~1970.  The interface
to libkvm is entirely unchanged, so I'm pretty sure this doesn't
require a version bump.

ps(1)'s etime column will still be incorrect in the coredump case because
it computes the elapsed time using the active kernel's time.  There is a
similar problem with the uptime line in w(1).  The attached patch itself
doesn't break these outputs, though, so I'll fix them in a separate patch.

The only port using p_ustart_{sec,usec} in a way that might be broken by
this change is sudo.  I talked to todd and he said that this change wouldn't
cause any problems, though.

ok?

--
Scott Cheloha

Index: lib/libkvm/kvm_proc2.c
===
RCS file: /cvs/src/lib/libkvm/kvm_proc2.c,v
retrieving revision 1.27
diff -u -p -r1.27 kvm_proc2.c
--- lib/libkvm/kvm_proc2.c  7 Nov 2016 00:26:33 -   1.27
+++ lib/libkvm/kvm_proc2.c  23 Jun 2018 00:12:14 -
@@ -119,13 +119,35 @@ kvm_proclist(kvm_t *kd, int op, int arg,
struct sigacts sa, *sap;
struct vmspace vm, *vmp;
struct plimit limits, *limp;
+   struct nlist nl[3];
pid_t parent_pid, leader_pid;
-   int cnt = 0;
-   int dothreads = 0;
+   time_t time_second, time_uptime;
+   int cnt, dothreads, i;
 
+   cnt = 0;
dothreads = op & KERN_PROC_SHOW_THREADS;
op &= ~KERN_PROC_SHOW_THREADS;
 
+   /* Determine the victim's age and time of death. */
+   memset(&nl, 0, sizeof(nl));
+   nl[0].n_name = "time_second";
+   nl[1].n_name = "time_uptime";
+   nl[2].n_name = NULL;
+   if (kvm_nlist(kd, nl) != 0) {
+   for (i = 0; nl[i].n_type != 0; i++)
+   continue;
+   _kvm_err(kd, kd->program, "%s: no such symbol", nl[i].n_name);
+   return (-1);
+   }
+   if (KREAD(kd, nl[0].n_value, &time_second)) {
+   _kvm_err(kd, kd->program, "can't read %s", nl[0].n_name);
+   return (-1);
+   }
+   if (KREAD(kd, nl[1].n_value, &time_uptime)) {
+   _kvm_err(kd, kd->program, "can't read %s", nl[1].n_name);
+   return (-1);
+   }
+
/*
 * Modelled on sysctl_doproc() in sys/kern/kern_sysctl.c
 */
@@ -288,6 +310,19 @@ kvm_proclist(kvm_t *kd, int op, int arg,
kp.p_tpgid = -1;
kp.p_tdev = NODEV;
}
+
+   /*
+* Derive the starting time for the process.
+*
+* XXX This ignores subseconds.  One solution would be
+* to expose the timehands definition to userspace and
+* grab th_offset/th_nanotime from the active timehands.
+* Pending that, just pretend every process forked at
+* the beginning of a nearby second.
+*/
+   kp.p_ustart

Re: Save and restore FPU state around signal handlers on armv7

2018-06-22 Thread Mark Kettenis
> Date: Fri, 22 Jun 2018 17:16:14 +0200 (CEST)
> From: Mark Kettenis 
> 
> It takes the alpha/hppa/mips64 approach of storing the state in struct
> sigcontext instead of using a pointer.  Using unsigned int and
> unsigned long long instead of uint32_t and uint64_t here to avoid
> having to include other headers.  But I suppose I could include
> include  and use __uint32_t and __uint64_t if people
> prefer that.
> 
> This is an ABI break.  Code that plays tricks with sigcontext, like
> copying structs around or looks at the internals will have to be
> recompiled.  But we don't really support that, so I'm inclined to just
> go aead.
> 
> This fixes the corruption in ksh/sh that is currently preventing snaps
> from being built.  At least in combination with the setjmp fix I
> mailed out wednesday and Dale's ast fix.
> 
> ok?

Better diff that gives the signal handler a clean FPU state and make
sure we reset the FPU state if the signal handler was the first to use
the FPU.  This no longer calls vfp_discard().  Instead it just sets
pcb_fpcpu to NULL.  That is enough to force reloading of the FPU
state.

ok?


Index: arch/arm/arm/sig_machdep.c
===
RCS file: /cvs/src/sys/arch/arm/arm/sig_machdep.c,v
retrieving revision 1.16
diff -u -p -r1.16 sig_machdep.c
--- arch/arm/arm/sig_machdep.c  12 Apr 2018 17:13:43 -  1.16
+++ arch/arm/arm/sig_machdep.c  22 Jun 2018 22:10:19 -
@@ -51,11 +51,11 @@
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 #include 
+
+#include 
 #include 
 
 #include 
@@ -80,6 +80,7 @@ sendsig(sig_t catcher, int sig, int retu
union sigval val)
 {
struct proc *p = curproc;
+   struct pcb *pcb = &p->p_addr->u_pcb;
struct trapframe *tf;
struct sigframe *fp, frame;
struct sigacts *psp = p->p_p->ps_sigacts;
@@ -130,6 +131,16 @@ sendsig(sig_t catcher, int sig, int retu
/* Save signal mask. */
frame.sf_sc.sc_mask = returnmask;
 
+   /* Save FPU registers. */
+   frame.sf_sc.sc_fpused = pcb->pcb_flags & PCB_FPU;
+   if (frame.sf_sc.sc_fpused) {
+   frame.sf_sc.sc_fpscr = pcb->pcb_fpstate.fp_scr;
+   memcpy(&frame.sf_sc.sc_fpreg, &pcb->pcb_fpstate.fp_reg,
+  sizeof(pcb->pcb_fpstate.fp_reg));
+   pcb->pcb_flags &= ~PCB_FPU;
+   pcb->pcb_fpcpu = NULL;
+   }
+
if (psp->ps_siginfo & sigmask(sig)) {
frame.sf_sip = &fp->sf_si;
initsiginfo(&frame.sf_si, sig, code, type, val);
@@ -176,6 +187,7 @@ sys_sigreturn(struct proc *p, void *v, r
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
+   struct pcb *pcb = &p->p_addr->u_pcb;
struct trapframe *tf;
 
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
@@ -227,6 +239,18 @@ sys_sigreturn(struct proc *p, void *v, r
 
/* Restore signal mask. */
p->p_sigmask = ksc.sc_mask & ~sigcantmask;
+
+   /* Restore FPU registers. */
+   if (ksc.sc_fpused) {
+   pcb->pcb_fpstate.fp_scr = ksc.sc_fpscr;
+   memcpy(&pcb->pcb_fpstate.fp_reg, &ksc.sc_fpreg,
+   sizeof(pcb->pcb_fpstate.fp_reg));
+   pcb->pcb_flags |= PCB_FPU;
+   pcb->pcb_fpcpu = NULL;
+   } else {
+   pcb->pcb_flags &= ~PCB_FPU;
+   pcb->pcb_fpcpu = NULL;
+   }
 
return (EJUSTRETURN);
 }
Index: arch/arm/include/signal.h
===
RCS file: /cvs/src/sys/arch/arm/include/signal.h,v
retrieving revision 1.9
diff -u -p -r1.9 signal.h
--- arch/arm/include/signal.h   10 May 2016 18:39:43 -  1.9
+++ arch/arm/include/signal.h   22 Jun 2018 22:10:19 -
@@ -82,6 +82,10 @@ struct sigcontext {
unsigned int sc_usr_lr;
unsigned int sc_svc_lr;
unsigned int sc_pc;
+
+   unsigned int sc_fpused;
+   unsigned int sc_fpscr;
+   unsigned long long sc_fpreg[32];
 };
 #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
 #endif /* !_LOCORE */



Re: DRI3/prime kernel implementation for OpenBSD

2018-06-22 Thread Mark Kettenis
And here is a version that supports radeon(4) as well.

Still looking for oks...


Index: dev/pci/drm/drmP.h
===
RCS file: /cvs/src/sys/dev/pci/drm/drmP.h,v
retrieving revision 1.217
diff -u -p -r1.217 drmP.h
--- dev/pci/drm/drmP.h  19 Feb 2018 08:59:52 -  1.217
+++ dev/pci/drm/drmP.h  22 Jun 2018 20:58:06 -
@@ -352,6 +352,12 @@ struct drm_pending_event {
void (*destroy)(struct drm_pending_event *event);
 };
 
+/* initial implementaton using a linked list - todo hashtab */
+struct drm_prime_file_private {
+   struct list_head head;
+   struct rwlock lock;
+};
+
 /** File private data */
 struct drm_file {
unsigned always_authenticated :1;
@@ -395,6 +401,8 @@ struct drm_file {
struct list_head event_list;
int event_space;
 
+   struct drm_prime_file_private prime;
+
struct selinfo rsel;
SPLAY_ENTRY(drm_file) link;
 };
@@ -480,6 +488,34 @@ struct drm_gem_object {
uint32_t pending_read_domains;
uint32_t pending_write_domain;
 
+   /**
+* dma_buf - dma buf associated with this GEM object
+*
+* Pointer to the dma-buf associated with this gem object (either
+* through importing or exporting). We break the resulting reference
+* loop when the last gem handle for this object is released.
+*
+* Protected by obj->object_name_lock
+*/
+   struct dma_buf *dma_buf;
+
+   /**
+* import_attach - dma buf attachment backing this object
+*
+* Any foreign dma_buf imported as a gem object has this set to the
+* attachment point for the device. This is invariant over the lifetime
+* of a gem object.
+*
+* The driver's ->gem_free_object callback is responsible for cleaning
+* up the dma_buf attachment and references acquired at import time.
+*
+* Note that the drm gem/prime core does not depend upon drivers setting
+* this field any more. So for drivers where this doesn't make sense
+* (e.g. virtual devices or a displaylink behind an usb bus) they can
+* simply leave it as NULL.
+*/
+   struct dma_buf_attachment *import_attach;
+
struct uvm_object uobj;
SPLAY_ENTRY(drm_gem_object) entry;
struct uvm_object *uao;
@@ -646,6 +682,20 @@ struct drm_driver {
int (*gem_fault)(struct drm_gem_object *, struct uvm_faultinfo *,
off_t, vaddr_t, vm_page_t *, int, int, vm_prot_t, int);
 
+   /* prime: */
+   /* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
+   int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file 
*file_priv,
+   uint32_t handle, uint32_t flags, int *prime_fd);
+   /* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */
+   int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file 
*file_priv,
+   int prime_fd, uint32_t *handle);
+   /* export GEM -> dmabuf */
+   struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
+   struct drm_gem_object *obj, int flags);
+   /* import dmabuf -> GEM */
+   struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
+   struct dma_buf *dma_buf);
+
int (*dumb_create)(struct drm_file *file_priv,
struct drm_device *dev, struct drm_mode_create_dumb *args);
int (*dumb_map_offset)(struct drm_file *file_priv,
@@ -981,6 +1031,18 @@ static inline wait_queue_head_t *drm_crt
 /* Modesetting support */
 extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe);
 extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
+
+extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
+   struct drm_gem_object *obj,
+   int flags);
+extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
+   struct drm_file *file_priv, uint32_t handle, uint32_t flags,
+   int *prime_fd);
+extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
+   struct dma_buf *dma_buf);
+extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
+   struct drm_file *file_priv, int prime_fd, uint32_t *handle);
+extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
 
 bool   drm_mode_parse_command_line_for_connector(const char *,
struct drm_connector *, struct drm_cmdline_mode *);
Index: dev/pci/drm/drm_drv.c
===
RCS file: /cvs/src/sys/dev/pci/drm/drm_drv.c,v
retrieving revision 1.157
diff -u -p -r1.157 drm_drv.c
--- dev/pci/drm/drm_drv.c   31 Jan 2018 05:04:41 -  1.157
+++ dev/pci/drm/drm_drv.c 

Re: [diff] httpd.conf.5 - consistent IPs, added examples

2018-06-22 Thread Stuart Henderson
On 2018/06/22 22:34, Mischa Peters wrote:
> 
> > On 22 Jun 2018, at 22:20, Sebastian Benoit  wrote:
> > 
> > Jason McIntyre(j...@kerhand.co.uk) on 2018.06.22 19:38:55 +0100:
> >>> On Fri, Jun 22, 2018 at 12:08:07AM +0200, Mischa wrote:
> >>> Hi tech@,
> >>> 
> >>> Changed httpd.conf.5 to be more consistent with IPs used, all 
> >>> documentation IPs now.
> >>> And added a couple of examples. 2 for dyamic pages, cgi and php.
> >>> One fairly common used rewrite rule for things like wordpress.
> >>> 
> >>> Mischa
> >>> 
> >> 
> >> hi.
> >> 
> >> the diff reads ok to me, but i cannot easily verify it because it does
> >> not apply cleanly.
> > 
> > The parts that dont apply are already commited parts from reyks rewrite
> > diff. They can be ignored.
> 
> My mistake. Will take a clean checkout. 
> 
> > However i dont know if we want all those examples. We will get them in
> > package readmes eventually.
> 
> I can also check out the pkg-readmes and expand those. As the php ones don’t 
> have any mention about the httpd.conf needs. Will check out Wordpress as well.

The php pkg-readme does have an httpd.conf snippet now.



signal to process or posix thread

2018-06-22 Thread Alexander Bluhm
Hi,

Since the recent futex(2) changes the posixtestsuite regress does
not finish within the given time frame.  Depending on some races
tests hang, e.g. this one:

/usr/local/libexec/posixtestsuite/conformance/interfaces/pthread_atfork/3-3.test

It spans a worker thread that allows to handle SIGUSR1 or SIGUSR2.
Two signal sending threads are created that kill the process with
SIGUSR1 or SIGUSR2 repectively.  The main thread and the signal
sending threads block these signals.  The signal handler in the
worker thread uses semaphores to acknowledge signals and then the
sending threads kill again.

It may happen that the worker thread is in the signal handler and
also blocks the signals.  Then all threads block them and ptsignal()
sends it to the main thread.  In the test program the main thread
blocks them forever and the process gets stuck.

According to POSIX any thread should process the signal when it
unblocks.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_01
If there are no threads in a call to a sigwait() function
selecting that signal, and if all threads within the process
block delivery of the signal, the signal shall remain pending
on the process until a thread calls a sigwait() function selecting
that signal, a thread unblocks delivery of the signal, or the
action associated with the signal is set to ignore the signal.

For this purpose NetBSD has l_sigpend for the thread and p_sigpend
for the process.

As prsignal() sends the signal to ps_mainproc if it cannot be
delivered immediately, we could also consider the main proc when
we check for pending signals.  This fixes my use case without beeing
to invasive.

ok?

bluhm

Index: kern/kern_sig.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/kern_sig.c,v
retrieving revision 1.220
diff -u -p -r1.220 kern_sig.c
--- kern/kern_sig.c 28 Apr 2018 03:13:04 -  1.220
+++ kern/kern_sig.c 22 Jun 2018 19:28:54 -
@@ -1155,14 +1155,18 @@ issignal(struct proc *p)
int s;
 
for (;;) {
-   mask = p->p_siglist & ~p->p_sigmask;
+   mask = p->p_siglist | pr->ps_mainproc->p_siglist;
+   mask &= ~p->p_sigmask;
if (pr->ps_flags & PS_PPWAIT)
mask &= ~stopsigmask;
if (mask == 0)  /* no signal to send */
return (0);
signum = ffs((long)mask);
mask = sigmask(signum);
-   atomic_clearbits_int(&p->p_siglist, mask);
+   if (p->p_siglist & mask)
+   atomic_clearbits_int(&p->p_siglist, mask);
+   else
+   atomic_clearbits_int(&pr->ps_mainproc->p_siglist, mask);
 
/*
 * We should see pending but ignored signals
Index: sys/signalvar.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/sys/signalvar.h,v
retrieving revision 1.30
diff -u -p -r1.30 signalvar.h
--- sys/signalvar.h 24 Mar 2018 04:13:59 -  1.30
+++ sys/signalvar.h 22 Jun 2018 19:28:54 -
@@ -68,7 +68,9 @@ structsigacts {
 /*
  * Check if process p has an unmasked signal pending.
  */
-#defineSIGPENDING(p)   (((p)->p_siglist & ~(p)->p_sigmask) != 0)
+#defineSIGPENDING(p)   
\
+   p)->p_siglist | (p)->p_p->ps_mainproc->p_siglist) & \
+   ~(p)->p_sigmask) != 0)
 
 /*
  * Determine signal that should be delivered to process p, the current
@@ -76,9 +78,11 @@ struct   sigacts {
  * action, the process stops in issignal().
  */
 #defineCURSIG(p)   
\
-   (((p)->p_siglist == 0 ||\
+   p)->p_siglist == 0 &&   \
+   (p)->p_p->ps_mainproc->p_siglist == 0) ||   \
(((p)->p_p->ps_flags & PS_TRACED) == 0 &&   \
-   ((p)->p_siglist & ~(p)->p_sigmask) == 0)) ? \
+   (((p)->p_siglist | (p)->p_p->ps_mainproc->p_siglist) &  \
+   ~(p)->p_sigmask) == 0)) ?   \
0 : issignal(p))
 
 /*



Re: [diff] httpd.conf.5 - consistent IPs, added examples

2018-06-22 Thread Mischa Peters


> On 22 Jun 2018, at 22:20, Sebastian Benoit  wrote:
> 
> Jason McIntyre(j...@kerhand.co.uk) on 2018.06.22 19:38:55 +0100:
>>> On Fri, Jun 22, 2018 at 12:08:07AM +0200, Mischa wrote:
>>> Hi tech@,
>>> 
>>> Changed httpd.conf.5 to be more consistent with IPs used, all documentation 
>>> IPs now.
>>> And added a couple of examples. 2 for dyamic pages, cgi and php.
>>> One fairly common used rewrite rule for things like wordpress.
>>> 
>>> Mischa
>>> 
>> 
>> hi.
>> 
>> the diff reads ok to me, but i cannot easily verify it because it does
>> not apply cleanly.
> 
> The parts that dont apply are already commited parts from reyks rewrite
> diff. They can be ignored.

My mistake. Will take a clean checkout. 

> However i dont know if we want all those examples. We will get them in
> package readmes eventually.

I can also check out the pkg-readmes and expand those. As the php ones don’t 
have any mention about the httpd.conf needs. Will check out Wordpress as well.

I do think adding extra examples can be helpful as its probably a knee jerk 
reaction for people to go to the man page, or man.openbsd.org. 

Mischa


> 
> Reyk?
> 
>> 
>> reyk?
>> 
>> jmc
>> 
>>> Index: httpd.conf.5
>>> ===
>>> RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
>>> retrieving revision 1.100
>>> diff -u -p -r1.100 httpd.conf.5
>>> --- httpd.conf.518 Jun 2018 06:04:25 -1.100
>>> +++ httpd.conf.521 Jun 2018 21:55:38 -
>>> @@ -97,7 +97,7 @@ Macros are not expanded inside quotes.
>>> .Pp
>>> For example:
>>> .Bd -literal -offset indent
>>> -ext_ip="10.0.0.1"
>>> +ext_ip="203.0.113.1"
>>> server "default" {
>>>listen on $ext_ip port 80
>>> }
>>> @@ -198,6 +198,8 @@ argument can be used with return codes i
>>> .Sq Location:
>>> header for redirection to a specified URI.
>>> .Pp
>>> +It is possible to rewrite the request to redirect it to a different
>>> +external location.
>>> The
>>> .Ar uri
>>> may contain predefined macros that will be expanded at runtime:
>>> @@ -396,10 +398,10 @@ the
>>> using pattern matching instead of shell globbing rules,
>>> see
>>> .Xr patterns 7 .
>>> -The pattern may contain captures that can be used in the
>>> -.Ar uri
>>> -of an enclosed
>>> +The pattern may contain captures that can be used in an enclosed
>>> .Ic block return
>>> +or
>>> +.Ic request rewrite
>>> option.
>>> .It Oo Ic no Oc Ic log Op Ar option
>>> Set the specified logging options.
>>> @@ -462,6 +464,19 @@ in a location.
>>> Configure the options for the request path.
>>> Valid options are:
>>> .Bl -tag -width Ds
>>> +.It Oo Ic no Oc Ic rewrite Ar path
>>> +Enable or disable rewriting of the request.
>>> +Unlike the redirection with
>>> +.Ic block return ,
>>> +this will change the request path internally before
>>> +.Nm httpd
>>> +makes a final decision about the matching location.
>>> +The
>>> +.Ar path
>>> +argument may contain predefined macros that will be expanded at runtime.
>>> +See the
>>> +.Ic block return
>>> +option for the list of supported macros.
>>> .It Ic strip Ar number
>>> Strip
>>> .Ar number
>>> @@ -699,7 +714,7 @@ server "www.b.example.com" {
>>> }
>>> 
>>> server "intranet.example.com" {
>>> -listen on 10.0.0.1 port 80
>>> +listen on 192.0.2.1 port 80
>>>root "/htdocs/intranet.example.com"
>>> }
>>> .Ed
>>> @@ -709,12 +724,43 @@ Simple redirections can be configured wi
>>> directive:
>>> .Bd -literal -offset indent
>>> server "example.com" {
>>> -listen on 10.0.0.1 port 80
>>> +listen on 203.0.113.1 port 80
>>>block return 301 "http://www.example.com$REQUEST_URI";
>>> }
>>> 
>>> server "www.example.com" {
>>> -listen on 10.0.0.1 port 80
>>> +listen on 203.0.113.1 port 80
>>> +}
>>> +.Ed
>>> +.Pp
>>> +Serving dynamic pages can be defined with the 
>>> +.Ic location
>>> +directive:
>>> +.Bd -literal -offset indent
>>> +server "www.example.com" {
>>> +listen on * port 80
>>> +location "/*.cgi*" {
>>> +fastcgi
>>> +root "/cgi-bin/"
>>> +}
>>> +location "/*.php*" {
>>> +fastcgi socket "/run/php-fpm.sock"
>>> +}
>>> +}
>>> +.Ed
>>> +.Pp
>>> +The request can also be rewritten with the
>>> +.Ic request rewrite
>>> +directive:
>>> +.Bd -literal -offset indent
>>> +server "www.example.com" {
>>> +listen on * port 80
>>> +location match "/old/(.*)" {
>>> +request rewrite "/new/%1"
>>> +}
>>> +location match "/([%a%d]+)" {
>>> +request rewrite "/dynamic/index.php?q=%1"
>>> +}
>>> }
>>> .Ed
>>> .Sh SEE ALSO
>>> 
>> 
> 



Re: [diff] httpd.conf.5 - consistent IPs, added examples

2018-06-22 Thread Jason McIntyre
On Fri, Jun 22, 2018 at 10:20:11PM +0200, Sebastian Benoit wrote:
> Jason McIntyre(j...@kerhand.co.uk) on 2018.06.22 19:38:55 +0100:
> > On Fri, Jun 22, 2018 at 12:08:07AM +0200, Mischa wrote:
> > > Hi tech@,
> > > 
> > > Changed httpd.conf.5 to be more consistent with IPs used, all 
> > > documentation IPs now.
> > > And added a couple of examples. 2 for dyamic pages, cgi and php.
> > > One fairly common used rewrite rule for things like wordpress.
> > > 
> > > Mischa
> > > 
> > 
> > hi.
> > 
> > the diff reads ok to me, but i cannot easily verify it because it does
> > not apply cleanly.
> 
> The parts that dont apply are already commited parts from reyks rewrite
> diff. They can be ignored.
> 
> However i dont know if we want all those examples. We will get them in
> package readmes eventually.
> 
> Reyk?
> 

hi.

i've been told already (offlist) that the ip changes don;t make any
sense (i had meant to make it clear in my mail that i couldn;t vouch
for the content).  i'll leave it for you guys to decide on its merit.

jmc

> > 
> > reyk?
> > 
> > jmc
> > 
> > > Index: httpd.conf.5
> > > ===
> > > RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
> > > retrieving revision 1.100
> > > diff -u -p -r1.100 httpd.conf.5
> > > --- httpd.conf.5  18 Jun 2018 06:04:25 -  1.100
> > > +++ httpd.conf.5  21 Jun 2018 21:55:38 -
> > > @@ -97,7 +97,7 @@ Macros are not expanded inside quotes.
> > >  .Pp
> > >  For example:
> > >  .Bd -literal -offset indent
> > > -ext_ip="10.0.0.1"
> > > +ext_ip="203.0.113.1"
> > >  server "default" {
> > >   listen on $ext_ip port 80
> > >  }
> > > @@ -198,6 +198,8 @@ argument can be used with return codes i
> > >  .Sq Location:
> > >  header for redirection to a specified URI.
> > >  .Pp
> > > +It is possible to rewrite the request to redirect it to a different
> > > +external location.
> > >  The
> > >  .Ar uri
> > >  may contain predefined macros that will be expanded at runtime:
> > > @@ -396,10 +398,10 @@ the
> > >  using pattern matching instead of shell globbing rules,
> > >  see
> > >  .Xr patterns 7 .
> > > -The pattern may contain captures that can be used in the
> > > -.Ar uri
> > > -of an enclosed
> > > +The pattern may contain captures that can be used in an enclosed
> > >  .Ic block return
> > > +or
> > > +.Ic request rewrite
> > >  option.
> > >  .It Oo Ic no Oc Ic log Op Ar option
> > >  Set the specified logging options.
> > > @@ -462,6 +464,19 @@ in a location.
> > >  Configure the options for the request path.
> > >  Valid options are:
> > >  .Bl -tag -width Ds
> > > +.It Oo Ic no Oc Ic rewrite Ar path
> > > +Enable or disable rewriting of the request.
> > > +Unlike the redirection with
> > > +.Ic block return ,
> > > +this will change the request path internally before
> > > +.Nm httpd
> > > +makes a final decision about the matching location.
> > > +The
> > > +.Ar path
> > > +argument may contain predefined macros that will be expanded at runtime.
> > > +See the
> > > +.Ic block return
> > > +option for the list of supported macros.
> > >  .It Ic strip Ar number
> > >  Strip
> > >  .Ar number
> > > @@ -699,7 +714,7 @@ server "www.b.example.com" {
> > >  }
> > >  
> > >  server "intranet.example.com" {
> > > - listen on 10.0.0.1 port 80
> > > + listen on 192.0.2.1 port 80
> > >   root "/htdocs/intranet.example.com"
> > >  }
> > >  .Ed
> > > @@ -709,12 +724,43 @@ Simple redirections can be configured wi
> > >  directive:
> > >  .Bd -literal -offset indent
> > >  server "example.com" {
> > > - listen on 10.0.0.1 port 80
> > > + listen on 203.0.113.1 port 80
> > >   block return 301 "http://www.example.com$REQUEST_URI";
> > >  }
> > >  
> > >  server "www.example.com" {
> > > - listen on 10.0.0.1 port 80
> > > + listen on 203.0.113.1 port 80
> > > +}
> > > +.Ed
> > > +.Pp
> > > +Serving dynamic pages can be defined with the 
> > > +.Ic location
> > > +directive:
> > > +.Bd -literal -offset indent
> > > +server "www.example.com" {
> > > + listen on * port 80
> > > + location "/*.cgi*" {
> > > + fastcgi
> > > + root "/cgi-bin/"
> > > + }
> > > + location "/*.php*" {
> > > + fastcgi socket "/run/php-fpm.sock"
> > > + }
> > > +}
> > > +.Ed
> > > +.Pp
> > > +The request can also be rewritten with the
> > > +.Ic request rewrite
> > > +directive:
> > > +.Bd -literal -offset indent
> > > +server "www.example.com" {
> > > + listen on * port 80
> > > + location match "/old/(.*)" {
> > > + request rewrite "/new/%1"
> > > + }
> > > + location match "/([%a%d]+)" {
> > > + request rewrite "/dynamic/index.php?q=%1"
> > > + }
> > >  }
> > >  .Ed
> > >  .Sh SEE ALSO
> > > 
> > 



Re: [diff] httpd.conf.5 - consistent IPs, added examples

2018-06-22 Thread Sebastian Benoit
Jason McIntyre(j...@kerhand.co.uk) on 2018.06.22 19:38:55 +0100:
> On Fri, Jun 22, 2018 at 12:08:07AM +0200, Mischa wrote:
> > Hi tech@,
> > 
> > Changed httpd.conf.5 to be more consistent with IPs used, all documentation 
> > IPs now.
> > And added a couple of examples. 2 for dyamic pages, cgi and php.
> > One fairly common used rewrite rule for things like wordpress.
> > 
> > Mischa
> > 
> 
> hi.
> 
> the diff reads ok to me, but i cannot easily verify it because it does
> not apply cleanly.

The parts that dont apply are already commited parts from reyks rewrite
diff. They can be ignored.

However i dont know if we want all those examples. We will get them in
package readmes eventually.

Reyk?

> 
> reyk?
> 
> jmc
> 
> > Index: httpd.conf.5
> > ===
> > RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
> > retrieving revision 1.100
> > diff -u -p -r1.100 httpd.conf.5
> > --- httpd.conf.518 Jun 2018 06:04:25 -  1.100
> > +++ httpd.conf.521 Jun 2018 21:55:38 -
> > @@ -97,7 +97,7 @@ Macros are not expanded inside quotes.
> >  .Pp
> >  For example:
> >  .Bd -literal -offset indent
> > -ext_ip="10.0.0.1"
> > +ext_ip="203.0.113.1"
> >  server "default" {
> > listen on $ext_ip port 80
> >  }
> > @@ -198,6 +198,8 @@ argument can be used with return codes i
> >  .Sq Location:
> >  header for redirection to a specified URI.
> >  .Pp
> > +It is possible to rewrite the request to redirect it to a different
> > +external location.
> >  The
> >  .Ar uri
> >  may contain predefined macros that will be expanded at runtime:
> > @@ -396,10 +398,10 @@ the
> >  using pattern matching instead of shell globbing rules,
> >  see
> >  .Xr patterns 7 .
> > -The pattern may contain captures that can be used in the
> > -.Ar uri
> > -of an enclosed
> > +The pattern may contain captures that can be used in an enclosed
> >  .Ic block return
> > +or
> > +.Ic request rewrite
> >  option.
> >  .It Oo Ic no Oc Ic log Op Ar option
> >  Set the specified logging options.
> > @@ -462,6 +464,19 @@ in a location.
> >  Configure the options for the request path.
> >  Valid options are:
> >  .Bl -tag -width Ds
> > +.It Oo Ic no Oc Ic rewrite Ar path
> > +Enable or disable rewriting of the request.
> > +Unlike the redirection with
> > +.Ic block return ,
> > +this will change the request path internally before
> > +.Nm httpd
> > +makes a final decision about the matching location.
> > +The
> > +.Ar path
> > +argument may contain predefined macros that will be expanded at runtime.
> > +See the
> > +.Ic block return
> > +option for the list of supported macros.
> >  .It Ic strip Ar number
> >  Strip
> >  .Ar number
> > @@ -699,7 +714,7 @@ server "www.b.example.com" {
> >  }
> >  
> >  server "intranet.example.com" {
> > -   listen on 10.0.0.1 port 80
> > +   listen on 192.0.2.1 port 80
> > root "/htdocs/intranet.example.com"
> >  }
> >  .Ed
> > @@ -709,12 +724,43 @@ Simple redirections can be configured wi
> >  directive:
> >  .Bd -literal -offset indent
> >  server "example.com" {
> > -   listen on 10.0.0.1 port 80
> > +   listen on 203.0.113.1 port 80
> > block return 301 "http://www.example.com$REQUEST_URI";
> >  }
> >  
> >  server "www.example.com" {
> > -   listen on 10.0.0.1 port 80
> > +   listen on 203.0.113.1 port 80
> > +}
> > +.Ed
> > +.Pp
> > +Serving dynamic pages can be defined with the 
> > +.Ic location
> > +directive:
> > +.Bd -literal -offset indent
> > +server "www.example.com" {
> > +   listen on * port 80
> > +   location "/*.cgi*" {
> > +   fastcgi
> > +   root "/cgi-bin/"
> > +   }
> > +   location "/*.php*" {
> > +   fastcgi socket "/run/php-fpm.sock"
> > +   }
> > +}
> > +.Ed
> > +.Pp
> > +The request can also be rewritten with the
> > +.Ic request rewrite
> > +directive:
> > +.Bd -literal -offset indent
> > +server "www.example.com" {
> > +   listen on * port 80
> > +   location match "/old/(.*)" {
> > +   request rewrite "/new/%1"
> > +   }
> > +   location match "/([%a%d]+)" {
> > +   request rewrite "/dynamic/index.php?q=%1"
> > +   }
> >  }
> >  .Ed
> >  .Sh SEE ALSO
> > 
> 



Re: regress/rtable coredump

2018-06-22 Thread Alexander Bluhm
On Fri, Jun 22, 2018 at 08:21:23PM +0200, Denis Fondras wrote:
> When trying to add multiple time the same prefix, ./fullfeed/fullfeed throws
> 'Segmentation fault (core dumped)'.
> 
> Here is a fix :

OK bluhm@

> Index: util.c
> ===
> RCS file: /cvs/src/regress/sys/net/rtable/util.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 util.c
> --- util.c27 Jul 2017 13:34:30 -  1.6
> +++ util.c22 Jun 2018 18:12:09 -
> @@ -110,7 +110,7 @@ route_insert(unsigned int rid, sa_family
>   rt_maskedcopy(dst, ndst, mask);
>  
>   if ((error = rtable_insert(rid, ndst, mask, NULL, 0, rt)) != 0) {
> - inet_net_satop(af, rt_key(rt), plen, ip, sizeof(ip));
> + inet_net_satop(af, ndst, plen, ip, sizeof(ip));
>   errx(1, "can't add route: %s, %s\n", ip, strerror(error));
>   }
>   nrt = rtable_lookup(rid, dst, mask, NULL, RTP_ANY);



Re: [diff] httpd.conf.5 - consistent IPs, added examples

2018-06-22 Thread Jason McIntyre
On Fri, Jun 22, 2018 at 12:08:07AM +0200, Mischa wrote:
> Hi tech@,
> 
> Changed httpd.conf.5 to be more consistent with IPs used, all documentation 
> IPs now.
> And added a couple of examples. 2 for dyamic pages, cgi and php.
> One fairly common used rewrite rule for things like wordpress.
> 
> Mischa
> 

hi.

the diff reads ok to me, but i cannot easily verify it because it does
not apply cleanly.

reyk?

jmc

> Index: httpd.conf.5
> ===
> RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
> retrieving revision 1.100
> diff -u -p -r1.100 httpd.conf.5
> --- httpd.conf.5  18 Jun 2018 06:04:25 -  1.100
> +++ httpd.conf.5  21 Jun 2018 21:55:38 -
> @@ -97,7 +97,7 @@ Macros are not expanded inside quotes.
>  .Pp
>  For example:
>  .Bd -literal -offset indent
> -ext_ip="10.0.0.1"
> +ext_ip="203.0.113.1"
>  server "default" {
>   listen on $ext_ip port 80
>  }
> @@ -198,6 +198,8 @@ argument can be used with return codes i
>  .Sq Location:
>  header for redirection to a specified URI.
>  .Pp
> +It is possible to rewrite the request to redirect it to a different
> +external location.
>  The
>  .Ar uri
>  may contain predefined macros that will be expanded at runtime:
> @@ -396,10 +398,10 @@ the
>  using pattern matching instead of shell globbing rules,
>  see
>  .Xr patterns 7 .
> -The pattern may contain captures that can be used in the
> -.Ar uri
> -of an enclosed
> +The pattern may contain captures that can be used in an enclosed
>  .Ic block return
> +or
> +.Ic request rewrite
>  option.
>  .It Oo Ic no Oc Ic log Op Ar option
>  Set the specified logging options.
> @@ -462,6 +464,19 @@ in a location.
>  Configure the options for the request path.
>  Valid options are:
>  .Bl -tag -width Ds
> +.It Oo Ic no Oc Ic rewrite Ar path
> +Enable or disable rewriting of the request.
> +Unlike the redirection with
> +.Ic block return ,
> +this will change the request path internally before
> +.Nm httpd
> +makes a final decision about the matching location.
> +The
> +.Ar path
> +argument may contain predefined macros that will be expanded at runtime.
> +See the
> +.Ic block return
> +option for the list of supported macros.
>  .It Ic strip Ar number
>  Strip
>  .Ar number
> @@ -699,7 +714,7 @@ server "www.b.example.com" {
>  }
>  
>  server "intranet.example.com" {
> - listen on 10.0.0.1 port 80
> + listen on 192.0.2.1 port 80
>   root "/htdocs/intranet.example.com"
>  }
>  .Ed
> @@ -709,12 +724,43 @@ Simple redirections can be configured wi
>  directive:
>  .Bd -literal -offset indent
>  server "example.com" {
> - listen on 10.0.0.1 port 80
> + listen on 203.0.113.1 port 80
>   block return 301 "http://www.example.com$REQUEST_URI";
>  }
>  
>  server "www.example.com" {
> - listen on 10.0.0.1 port 80
> + listen on 203.0.113.1 port 80
> +}
> +.Ed
> +.Pp
> +Serving dynamic pages can be defined with the 
> +.Ic location
> +directive:
> +.Bd -literal -offset indent
> +server "www.example.com" {
> + listen on * port 80
> + location "/*.cgi*" {
> + fastcgi
> + root "/cgi-bin/"
> + }
> + location "/*.php*" {
> + fastcgi socket "/run/php-fpm.sock"
> + }
> +}
> +.Ed
> +.Pp
> +The request can also be rewritten with the
> +.Ic request rewrite
> +directive:
> +.Bd -literal -offset indent
> +server "www.example.com" {
> + listen on * port 80
> + location match "/old/(.*)" {
> + request rewrite "/new/%1"
> + }
> + location match "/([%a%d]+)" {
> + request rewrite "/dynamic/index.php?q=%1"
> + }
>  }
>  .Ed
>  .Sh SEE ALSO
> 



regress/rtable coredump

2018-06-22 Thread Denis Fondras
When trying to add multiple time the same prefix, ./fullfeed/fullfeed throws
'Segmentation fault (core dumped)'.

Here is a fix :

Index: util.c
===
RCS file: /cvs/src/regress/sys/net/rtable/util.c,v
retrieving revision 1.6
diff -u -p -r1.6 util.c
--- util.c  27 Jul 2017 13:34:30 -  1.6
+++ util.c  22 Jun 2018 18:12:09 -
@@ -110,7 +110,7 @@ route_insert(unsigned int rid, sa_family
rt_maskedcopy(dst, ndst, mask);
 
if ((error = rtable_insert(rid, ndst, mask, NULL, 0, rt)) != 0) {
-   inet_net_satop(af, rt_key(rt), plen, ip, sizeof(ip));
+   inet_net_satop(af, ndst, plen, ip, sizeof(ip));
errx(1, "can't add route: %s, %s\n", ip, strerror(error));
}
nrt = rtable_lookup(rid, dst, mask, NULL, RTP_ANY);



Save and restore FPU state around signal handlers on armv7

2018-06-22 Thread Mark Kettenis
It takes the alpha/hppa/mips64 approach of storing the state in struct
sigcontext instead of using a pointer.  Using unsigned int and
unsigned long long instead of uint32_t and uint64_t here to avoid
having to include other headers.  But I suppose I could include
include  and use __uint32_t and __uint64_t if people
prefer that.

This is an ABI break.  Code that plays tricks with sigcontext, like
copying structs around or looks at the internals will have to be
recompiled.  But we don't really support that, so I'm inclined to just
go aead.

This fixes the corruption in ksh/sh that is currently preventing snaps
from being built.  At least in combination with the setjmp fix I
mailed out wednesday and Dale's ast fix.

ok?


Index: arch/arm/arm/sig_machdep.c
===
RCS file: /cvs/src/sys/arch/arm/arm/sig_machdep.c,v
retrieving revision 1.16
diff -u -p -r1.16 sig_machdep.c
--- arch/arm/arm/sig_machdep.c  12 Apr 2018 17:13:43 -  1.16
+++ arch/arm/arm/sig_machdep.c  22 Jun 2018 15:07:30 -
@@ -51,12 +51,13 @@
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 #include 
+
+#include 
 #include 
+#include 
 
 #include 
 
@@ -80,6 +81,7 @@ sendsig(sig_t catcher, int sig, int retu
union sigval val)
 {
struct proc *p = curproc;
+   struct pcb *pcb = &p->p_addr->u_pcb;
struct trapframe *tf;
struct sigframe *fp, frame;
struct sigacts *psp = p->p_p->ps_sigacts;
@@ -130,6 +132,15 @@ sendsig(sig_t catcher, int sig, int retu
/* Save signal mask. */
frame.sf_sc.sc_mask = returnmask;
 
+   /* Save FPU registers. */
+   frame.sf_sc.sc_fpused = pcb->pcb_flags & PCB_FPU;
+   if (frame.sf_sc.sc_fpused) {
+   frame.sf_sc.sc_fpscr = pcb->pcb_fpstate.fp_scr;
+   memcpy(&frame.sf_sc.sc_fpreg, &pcb->pcb_fpstate.fp_reg,
+  sizeof(pcb->pcb_fpstate.fp_reg));
+   pcb->pcb_flags &= ~PCB_FPU;
+   }
+
if (psp->ps_siginfo & sigmask(sig)) {
frame.sf_sip = &fp->sf_si;
initsiginfo(&frame.sf_si, sig, code, type, val);
@@ -176,6 +187,7 @@ sys_sigreturn(struct proc *p, void *v, r
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
+   struct pcb *pcb = &p->p_addr->u_pcb;
struct trapframe *tf;
 
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
@@ -227,6 +239,17 @@ sys_sigreturn(struct proc *p, void *v, r
 
/* Restore signal mask. */
p->p_sigmask = ksc.sc_mask & ~sigcantmask;
+
+   /* Restore FPU registers. */
+   if (ksc.sc_fpused) {
+   if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
+   vfp_discard(p);
+
+   pcb->pcb_fpstate.fp_scr = ksc.sc_fpscr;
+   memcpy(&pcb->pcb_fpstate.fp_reg, &ksc.sc_fpreg,
+   sizeof(pcb->pcb_fpstate.fp_reg));
+   pcb->pcb_flags |= PCB_FPU;
+   }
 
return (EJUSTRETURN);
 }
Index: arch/arm/include/signal.h
===
RCS file: /cvs/src/sys/arch/arm/include/signal.h,v
retrieving revision 1.9
diff -u -p -r1.9 signal.h
--- arch/arm/include/signal.h   10 May 2016 18:39:43 -  1.9
+++ arch/arm/include/signal.h   22 Jun 2018 15:07:30 -
@@ -82,6 +82,10 @@ struct sigcontext {
unsigned int sc_usr_lr;
unsigned int sc_svc_lr;
unsigned int sc_pc;
+
+   unsigned int sc_fpused;
+   unsigned int sc_fpscr;
+   unsigned long long sc_fpreg[32];
 };
 #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
 #endif /* !_LOCORE */



Re: use __func__ in iked util.c log_debug

2018-06-22 Thread Gleydson Soares
On Fri, Jun 22, 2018 at 08:58:24AM -0400, Rob Pierce wrote:
> ok?

looks good to me,

> 
> Index: util.c
> ===
> RCS file: /cvs/src/sbin/iked/util.c,v
> retrieving revision 1.35
> diff -u -p -r1.35 util.c
> --- util.c13 Dec 2017 08:27:06 -  1.35
> +++ util.c22 Jun 2018 12:52:09 -
> @@ -703,7 +703,7 @@ expand_string(char *label, size_t len, c
>   char *p, *q;
>  
>   if ((tmp = calloc(1, len)) == NULL) {
> - log_debug("expand_string: calloc");
> + log_debug("%s: calloc", __func__);
>   return (-1);
>   }
>   p = q = label;
> @@ -711,7 +711,7 @@ expand_string(char *label, size_t len, c
>   *q = '\0';
>   if ((strlcat(tmp, p, len) >= len) ||
>   (strlcat(tmp, repl, len) >= len)) {
> - log_debug("expand_string: string too long");
> + log_debug("%s: string too long", __func__);
>   free(tmp);
>   return (-1);
>   }
> @@ -719,7 +719,7 @@ expand_string(char *label, size_t len, c
>   p = q;
>   }
>   if (strlcat(tmp, p, len) >= len) {
> - log_debug("expand_string: string too long");
> + log_debug("%s: string too long", __func__);
>   free(tmp);
>   return (-1);
>   }
> 



use __func__ in iked util.c log_debug

2018-06-22 Thread Rob Pierce
ok?

Index: util.c
===
RCS file: /cvs/src/sbin/iked/util.c,v
retrieving revision 1.35
diff -u -p -r1.35 util.c
--- util.c  13 Dec 2017 08:27:06 -  1.35
+++ util.c  22 Jun 2018 12:52:09 -
@@ -703,7 +703,7 @@ expand_string(char *label, size_t len, c
char *p, *q;
 
if ((tmp = calloc(1, len)) == NULL) {
-   log_debug("expand_string: calloc");
+   log_debug("%s: calloc", __func__);
return (-1);
}
p = q = label;
@@ -711,7 +711,7 @@ expand_string(char *label, size_t len, c
*q = '\0';
if ((strlcat(tmp, p, len) >= len) ||
(strlcat(tmp, repl, len) >= len)) {
-   log_debug("expand_string: string too long");
+   log_debug("%s: string too long", __func__);
free(tmp);
return (-1);
}
@@ -719,7 +719,7 @@ expand_string(char *label, size_t len, c
p = q;
}
if (strlcat(tmp, p, len) >= len) {
-   log_debug("expand_string: string too long");
+   log_debug("%s: string too long", __func__);
free(tmp);
return (-1);
}



Use -z notext -z norelro for armv7 efiboot

2018-06-22 Thread Mark Kettenis
Creating relocations inside .text is inherent to the way we wrap an
ELF shared object inside a PE executable.  But without -z notext
lld(1) complains about this.  Also pass -z norelro to suppress the
creation of a separate rodata segment that makes lld(1) complain about
relocations against a read-only section.  This makes it possible to
build efiboot with lld(1) on armv7.

ok?


Index: arch/armv7/stand/efiboot/Makefile
===
RCS file: /cvs/src/sys/arch/armv7/stand/efiboot/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- arch/armv7/stand/efiboot/Makefile   11 May 2018 11:58:59 -  1.10
+++ arch/armv7/stand/efiboot/Makefile   22 Jun 2018 09:56:53 -
@@ -17,7 +17,8 @@ EFIDIR=   ${S}/stand/efi
 OBJCOPY?=  objcopy
 OBJDUMP?=  objdump
 
-LDFLAGS+=-nostdlib -T ${.CURDIR}/ldscript.arm -Bsymbolic -shared
+LDFLAGS+=  -nostdlib -T ${.CURDIR}/ldscript.arm -Bsymbolic -shared
+LDFLAGS+=  -z notext -z norelro
 
 .PATH: ${S}/stand/boot
 SRCS+= boot.c cmd.c vars.c



Re: About differences with GNU patch(1)

2018-06-22 Thread Jeremie Courreges-Anglas
On Fri, Jun 22 2018, Vadim Zhukov  wrote:
> So after a few discussions I propose to add --dry-run as synonim for -C
> in our patch(1). Quick summary:
>
>   * GNU got --dry-run earlier than us;
>   * --dry-run way more popular name than --check for such functionality;
>   * FreeBSD and NetBSD has the same for a long time already;
>   * We don't care about long option names generally, anyway.
>
> On the second option, --binary, since we have no functionality and
> I see no demand for it, lets just keep things as is. Failing with
> "unkonwn option" message is clear indicator that requested functionality
> isn't supported.
>
> Builds and runs on (almost) -CURRENT. Okay or not?

ok jca@ but please update the manpage, something like that I guess...

Index: patch.1
===
RCS file: /d/cvs/src/usr.bin/patch/patch.1,v
retrieving revision 1.31
diff -u -p -p -u -r1.31 patch.1
--- patch.1 11 Apr 2018 10:06:50 -  1.31
+++ patch.1 22 Jun 2018 09:46:27 -
@@ -99,7 +99,7 @@ This is equivalent to specifying
 This option is currently the default, unless
 .Fl -posix
 is specified.
-.It Fl C , Fl Fl check
+.It Fl C , Fl Fl check , Fl Fl dry-run
 Checks that the patch would apply cleanly, but does not modify anything.
 .It Fl c , Fl Fl context
 Forces

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: About differences with GNU patch(1)

2018-06-22 Thread Vadim Zhukov
So after a few discussions I propose to add --dry-run as synonim for -C
in our patch(1). Quick summary:

  * GNU got --dry-run earlier than us;
  * --dry-run way more popular name than --check for such functionality;
  * FreeBSD and NetBSD has the same for a long time already;
  * We don't care about long option names generally, anyway.

On the second option, --binary, since we have no functionality and
I see no demand for it, lets just keep things as is. Failing with
"unkonwn option" message is clear indicator that requested functionality
isn't supported.

Builds and runs on (almost) -CURRENT. Okay or not?

--
  WBR,
Vadim Zhukov


Index: patch.c
===
RCS file: /cvs/src/usr.bin/patch/patch.c,v
retrieving revision 1.65
diff -u -p -r1.65 patch.c
--- patch.c 7 Apr 2018 14:55:13 -   1.65
+++ patch.c 22 Jun 2018 09:12:53 -
@@ -454,6 +454,7 @@ get_some_switches(void)
{"context", no_argument,0,  'c'},
{"debug",   required_argument,  0,  'x'},
{"directory",   required_argument,  0,  'd'},
+   {"dry-run", no_argument,0,  'C'},
{"ed",  no_argument,0,  'e'},
{"force",   no_argument,0,  'f'},
{"forward", no_argument,0,  'N'},



Re: DRI3/prime diff for xenocara

2018-06-22 Thread Stuart Henderson
On 2018/06/20 21:20, Mark Kettenis wrote:
> This enables various DRI3-related bits in xenocara.  Matthieu warns me
> that this will make the Mesa libraries depend on libxshmfence wich
> he thinks will lead to WANTLIB churn in ports...
> 
> Is that going to be a problem?

That's not going to be a problem.