Re: svn commit: r297039 - head/sys/x86/x86

2016-03-25 Thread Konstantin Belousov
On Fri, Mar 25, 2016 at 07:13:54AM +1100, Bruce Evans wrote:
> On Thu, 24 Mar 2016, Konstantin Belousov wrote:
[Skipped lock adaptive spinning text for now].

> 
> >> My systems allow speed variations of about 4000:800 = 5:1 for one CPU and
> >> about 50:1 for different CPUs.  So the old method gave a variation of up
> >> to 50:1.  This can be reduced to only 5:1 using the boot-time calibration.
> > What do you mean by 'for different CPUs' ?  I understand that modern ESS
> > can give us CPU frequency between 800-4200MHz, which is what you mean
> > by 'for one CPU'.  We definitely do not care if 5usec timeout becomes
> > 25usecs, since we practically never time-out there at all.
> 
> Yes, I actually get 4400:800 on i4790K.
> 
> The ratio is even larger than that with a hard-coded limit because old
> CPUs are much slower than i4790K.  I sometimes run a 367 MHz (P2 class)
> CPU.  It is several times slower than a new CPU at the same clock
> frequency, and any throttling would make it even slower.
> 
> 50 times slower means that a reasonable emergency timeout of 60 seconds
> becomes 3000 seconds.  Local users would get tired of waiting and reset,
> and remote users might have to wait.
But you do not downclock a machine booted at the 4.0Ghz datasheet clock,
down to 367Mhz. For 400Mhz P2 machine, LAPIC would be calibrated at that
400Mhz rate.

> There is another thread about early DELAY() using the i8254 not working
> to calibrate the TSC.  That might be just because DELAY() is interrupted.
> DELAY() never bothered to disable interrupts.  Its early use for calibrating
> the TSC depends on interrupts mostly not happening then.  (My version is
> a bit more careful, but it still doesn't disable interrupts.  It
> establishes error bounds provided interrupts are shorter than the i8254
> wrap period.)  If the i8254 is virtual, then even disabling interrupts
> on the target wouldn't help, since the disabling would only be virtual.

Yes, the DELAY() calibration is something I wanted to ask about.
Could you, please, take a look at
https://reviews.freebsd.org/D5738
there is a code which would benefit from better (re-)calibration.

Below is the patch to implement calibration of the ipi_wait() busy loop.
On my sandybridge 3.4Ghz, I get the message
LAPIC: ipi_wait() us multiplier 37 (r 128652089678 tsc 3392383992)

diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 7e5087b..0842de5 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -162,6 +163,7 @@ int x2apic_mode;
 int lapic_eoi_suppression;
 static u_long lapic_timer_divisor;
 static struct eventtimer lapic_et;
+static uint64_t lapic_ipi_wait_mult;
 
 SYSCTL_NODE(_hw, OID_AUTO, apic, CTLFLAG_RD, 0, "APIC options");
 SYSCTL_INT(_hw_apic, OID_AUTO, x2apic_mode, CTLFLAG_RD, &x2apic_mode, 0, "");
@@ -391,6 +393,7 @@ lvt_mode(struct lapic *la, u_int pin, uint32_t value)
 static void
 native_lapic_init(vm_paddr_t addr)
 {
+   uint64_t r;
uint32_t ver;
u_int regs[4];
int i, arat;
@@ -484,6 +487,34 @@ native_lapic_init(vm_paddr_t addr)
TUNABLE_INT_FETCH("hw.lapic_eoi_suppression",
&lapic_eoi_suppression);
}
+
+#define LOOPS 100
+   /*
+* Calibrate the busy loop waiting for IPI ack in xAPIC mode.
+* lapic_ipi_wait_mult contains the number of iterations which
+* approximately delay execution for 1 microsecond (the
+* argument to native_lapic_ipi_wait() is in microseconds).
+*
+* We assume that TSC is present and already measured.
+* Possible TSC frequency jumps are irrelevant to the
+* calibration loop below, the CPU clock management code is
+* not yet started, and we do not enter sleep states.
+*/
+   KASSERT((cpu_feature & CPUID_TSC) != 0 && tsc_freq != 0,
+   ("TSC not initialized"));
+   r = rdtsc();
+   for (r = 0; r < LOOPS; r++) {
+   (void)lapic_read_icr_lo();
+   ia32_pause();
+   }
+   r = rdtsc() - r;
+   lapic_ipi_wait_mult = (r * 100) / tsc_freq / LOOPS;
+   if (bootverbose) {
+   printf("LAPIC: ipi_wait() us multiplier %jd (r %jd tsc %jd)\n",
+   (uintmax_t)lapic_ipi_wait_mult, (uintmax_t)r,
+   (uintmax_t)tsc_freq);
+   }
+#undef LOOPS
 }
 
 /*
@@ -1621,31 +1652,26 @@ SYSINIT(apic_setup_io, SI_SUB_INTR, SI_ORDER_THIRD, 
apic_setup_io, NULL);
  * private to the MD code.  The public interface for the rest of the
  * kernel is defined in mp_machdep.c.
  */
+
+/*
+ * Wait delay microseconds for IPI to be sent.  If delay is -1, we
+ * wait forever.
+ */
 static int
 native_lapic_ipi_wait(int delay)
 {
-   int x;
+   uint64_t i, counter;
 
/* LAPIC_ICR.APIC_DELSTAT_MASK is undefined in x2APIC mode */
-   if (x2apic_mode)
+   if (x2apic_

Re: svn commit: r297190 - head/sys/kern

2016-03-25 Thread Edward Tomasz Napierała
On 0325T0809, Bruce Evans wrote:
> On Thu, 24 Mar 2016, Edward Tomasz [utf-8] Napiera�~Ba wrote:
> 
> > On 0324T1015, Warner Losh wrote:
> >> On Thu, Mar 24, 2016 at 9:46 AM, Ian Lepore  wrote:
> >>
> >>> On Thu, 2016-03-24 at 16:01 +0100, Edward Tomasz Napierała wrote:
>  On 0324T1609, Alexander Motin wrote:
> > On 24.03.16 15:42, Edward Tomasz Napierała wrote:
> >> On 0324T1032, Jean-Sébastien Pédron wrote:
> >>> On 23/03/2016 18:45, Edward Tomasz Napierala wrote:
> > So maybe callouts are disabled in this situation. If there
> > is a way to
> > detect that, then vt(4) can go back to a "synchronous mode"
> > where it
> > refreshes the screen after each typed character, like it
> > does when ddb
> > is active.
> 
>  Looks like that's the case: for some reason the callouts
>  don't work.
>  This trivial hack is a (mostly) working workaround:
> 
>  Index: svn/head/sys/kern/kern_cons.c
>  =
>  ==
>  --- svn/head/sys/kern/kern_cons.c (revision 297210)
>  +++ svn/head/sys/kern/kern_cons.c (working copy)
>  @@ -430,6 +430,7 @@ cngets(char *cp, size_t size, int
>  visible)
>    lp = cp;
>    end = cp + size - 1;
>    for (;;) {
>  + pause("meh", 1);
> >>>
> >>> Could you please explain how this works to me? Does calling
> >>> pause() here
> >>> give a chance to interrupt handlers or other threads of
> >>> running?
> >>
> >> It looks like it allows the callout to run.  I've did an
> >> experiment
> >> and added a simple callout that printed something each second;
> >> during
> >> the root mount prompt it doesn't get run unless you type '.',
> >> which
> >> calls pause(9).
> >
> > Kernel threads run with absolute priorities, so if somehow this
> > threads
> > happen to have higher or equal priority then callout thread, or the
> > kernel is built without PREEMPTION, then the last may never be
> > executed
> > until this thread get to sleep or at least call sched_yield().
> 
>  The callout's td_priority seems to be 40; the thread running the
>  prompt
>  is 84, so it's lower.
> 
>  I've just noticed another curious thing, though: when you press
>  ScrLk,
>  the screen gets immediately refreshed; also, pressing arrows works
>  just
>  the way it should.  In other words, the refresh is broken except for
>  the ScrlLk mode, where it works as it should.
> >>>
> >>> Since cngets() is used only by the mountroot prompt and the geli pw
> >>> entry, pausing/yielding within the input loop seems like a good idea.
> >>>  It would allow for things like plugging in a usb device and having it
> >>> actually appear without having to enter a '.' several times.
> >>>
> >>> It would be nice if the pause were done with pause_sbt() and a shorter
> >>> timeout, maybe a millisecond or even 100uS.  Otherwise things like
> >>> pasting text at that prompt in a serial console is likely to drop
> >>> chars.
> >>>
> >>> Hmmm... speaking of the geli pw prompt... what's the locking situation
> >>> there?  Will there be any problems calling pause() from that context?
> >>
> >> PVM isn't an ideal priority to wait at. PWAIT would be better. However,
> >> if the only reason to call pause is run the scheduler after each character,
> >> perhaps a better solution would be to call kern_yield() instead? We could
> >> do that instead of cpu_waitspin() inside of cngetc, but that would break
> >> the debugger's use of it
> 
> Console drivers can't block or depend on timeouts.  Perhaps cngets() can,
> because it is only called in simple contexts, but the simple contexts
> make it especially easy for it to work using the same synchronous i/o that
> is needed in more complicated contexts.

Note that this particular problem doesn't seem to be caused by the console
driver as such.  One of the things I've tried was to add a callout that
prints out something each second, and then enter an infinite loop.  The
assumption is, the loop in proc0 should get preempted by the callout.
For some reason this doesn't happen.

> > I think we should first try to figure out why this doesn't work in the first
> > place.
> >
> > Basically, even though the interrupts are running, scheduler seems to be ok,
> > and the thread that's calling this has a lower priority than the callouts
> > thread, it can't be preempted.  This doesn't seem to be caused by vt(4);
> > with syscons the callouts don't get called either (it just doesn't break
> > the echo in this case).  To demonstrate the problem you can add add
> > a callout that calls printf each second and then does an infinite loop.
> 
> cngets() is even correctly wrapped by cngrab()/cnungrab().  This is supposed
> to put

svn commit: r297268 - head/sys/dev/iscsi

2016-03-25 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Mar 25 16:01:40 2016
New Revision: 297268
URL: https://svnweb.freebsd.org/changeset/base/297268

Log:
  Fix iSCSI initiator crash that could happen with out-of-memory
  conditions with in-flight IO and subsequent reconnection.
  
  PR:   199117
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D5673

Modified:
  head/sys/dev/iscsi/iscsi.c

Modified: head/sys/dev/iscsi/iscsi.c
==
--- head/sys/dev/iscsi/iscsi.c  Fri Mar 25 08:26:37 2016(r297267)
+++ head/sys/dev/iscsi/iscsi.c  Fri Mar 25 16:01:40 2016(r297268)
@@ -,6 +,7 @@ iscsi_action_scsiio(struct iscsi_session
 
error = icl_pdu_append_data(request, csio->data_ptr, len, 
M_NOWAIT);
if (error != 0) {
+   iscsi_outstanding_remove(is, io);
icl_pdu_free(request);
if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
xpt_freeze_devq(ccb->ccb_h.path, 1);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r297039 - head/sys/x86/x86

2016-03-25 Thread Bruce Evans

On Fri, 25 Mar 2016, Konstantin Belousov wrote:


On Fri, Mar 25, 2016 at 07:13:54AM +1100, Bruce Evans wrote:

On Thu, 24 Mar 2016, Konstantin Belousov wrote:

[Skipped lock adaptive spinning text for now].



My systems allow speed variations of about 4000:800 = 5:1 for one CPU and
about 50:1 for different CPUs.  So the old method gave a variation of up
to 50:1.  This can be reduced to only 5:1 using the boot-time calibration.

What do you mean by 'for different CPUs' ?  I understand that modern ESS
can give us CPU frequency between 800-4200MHz, which is what you mean
by 'for one CPU'.  We definitely do not care if 5usec timeout becomes
25usecs, since we practically never time-out there at all.


Yes, I actually get 4400:800 on i4790K.

The ratio is even larger than that with a hard-coded limit because old
CPUs are much slower than i4790K.  I sometimes run a 367 MHz (P2 class)
CPU.  It is several times slower than a new CPU at the same clock
frequency, and any throttling would make it even slower.

50 times slower means that a reasonable emergency timeout of 60 seconds
becomes 3000 seconds.  Local users would get tired of waiting and reset,
and remote users might have to wait.

But you do not downclock a machine booted at the 4.0Ghz datasheet clock,
down to 367Mhz. For 400Mhz P2 machine, LAPIC would be calibrated at that
400Mhz rate.


I was considering what happens with hard-coded (uncalibrated) timeout.


There is another thread about early DELAY() using the i8254 not working
to calibrate the TSC.  That might be just because DELAY() is interrupted.
DELAY() never bothered to disable interrupts.  Its early use for calibrating
the TSC depends on interrupts mostly not happening then.  (My version is
a bit more careful, but it still doesn't disable interrupts.  It
establishes error bounds provided interrupts are shorter than the i8254
wrap period.)  If the i8254 is virtual, then even disabling interrupts
on the target wouldn't help, since the disabling would only be virtual.


Yes, the DELAY() calibration is something I wanted to ask about.
Could you, please, take a look at
https://reviews.freebsd.org/D5738
there is a code which would benefit from better (re-)calibration.


I found that hard to read (using an old version of w3m, the UI is
horrible and the comments don't have enough context; then the old
version of w3m can't display files or diffs).

I use the following TSC calibration code in some kernels:

X static void
X xdel(int t0c, uint64_t *initial_tsc, uint64_t *final_tsc, int *delta_t0c)
X {
X   int high, low, n, next, prev;
X 
X 	outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);

X   *initial_tsc = rdtsc();
X   low = inb(TIMER_CNTR0);
X   high = inb(TIMER_CNTR0);
X   prev = (high << 8) | low;
X   for (n = 0; n < t0c; ) {
X   outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
X   *final_tsc = rdtsc();
X   low = inb(TIMER_CNTR0);
X   high = inb(TIMER_CNTR0);
X   next = (high << 8) | low;
X   if (next <= prev)
X   n += prev - next;
X   else
X   n += (timer0_max_count + prev) - next;
X   prev = next;
X   }
X   *delta_t0c = n;
X }
X 
X static uint64_t

X tsc_calibrate(void)
X {
X   uint64_t tsc_freq;
X   uint64_t tscval[2];
X   int xdelval;
X 
X 	xdel(100, &tscval[0], &tscval[1], &xdelval);

X   xdel(timer_freq, &tscval[0], &tscval[1], &xdelval);
X   tsc_freq = (tscval[1] - tscval[0]) * timer_freq / xdelval;
X   if (1 || bootverbose)
X   printf("TSC clock: %ju Hz\n", (uintmax_t)tsc_freq);
X   if (1 || bootverbose)
X   printf("raw: %ju %ju %d\n", tscval[0], tscval[1], xdelval);
X   return (tsc_freq);
X }

This uses the i8254.  xdel() is a specialized version of i8254 DELAY()
with getit() inline.  It returns the initial and final values of the
i8254 counter.  It doesn't handle interrupts or any other source of
large clock jitter.  What it measures more precisely is the measurement
overhead.  This is normally 2-5 usec.  With a timer frequency of about
1 MHz, a 5 usec error is about 5 ppm.  Compensating for this reduces
the error to below 1 ppm if there are no interrupts,

tsc_calibrate() calls xdel() twice to determine the measurement overhead.
It should be called one more time to warm up the cache.

In other kernels, I use the following version using DELAY() which is
good enough if DELAY() works and is not delayed by interrupts

X diff -c2 ./x86/x86/tsc.c~ ./x86/x86/tsc.c
X *** ./x86/x86/tsc.c~  Sun Feb 14 21:56:28 2016
X --- ./x86/x86/tsc.c   Sun Feb 14 22:01:46 2016
X ***
X *** 240,244 
X   {
X   u_int regs[4];
X ! uint64_t tsc1, tsc2;
X 
X   	if (cpu_high >= 6) {

X --- 240,244 
X   {
X   u_int regs[4];
X ! uint64_t tsc1, tsc2, tsc3;
X 
X   	if (cpu_high >= 6) {

X ***
X *** 306,313 
X   if (bootverbose)
X   printf("Calibrating

Re: svn commit: r297190 - head/sys/kern

2016-03-25 Thread Bruce Evans

On Fri, 25 Mar 2016, Edward Tomasz [utf-8] Napiera?~Ba wrote:


On 0325T0809, Bruce Evans wrote:

On Thu, 24 Mar 2016, Edward Tomasz [utf-8] Napiera?~Ba wrote:


On 0324T1015, Warner Losh wrote:

On Thu, Mar 24, 2016 at 9:46 AM, Ian Lepore  wrote:


On Thu, 2016-03-24 at 16:01 +0100, Edward Tomasz Napiera??a wrote:

[...]
I've just noticed another curious thing, though: when you press
ScrLk,
the screen gets immediately refreshed; also, pressing arrows works
just
the way it should.  In other words, the refresh is broken except for
the ScrlLk mode, where it works as it should.


Since cngets() is used only by the mountroot prompt and the geli pw
entry, pausing/yielding within the input loop seems like a good idea.
 It would allow for things like plugging in a usb device and having it
actually appear without having to enter a '.' several times.

It would be nice if the pause were done with pause_sbt() and a shorter
timeout, maybe a millisecond or even 100uS.  Otherwise things like
pasting text at that prompt in a serial console is likely to drop
chars.


Serial consoles should work already due to their use of grab/ungrab, and
this use being easier to get right for serial consoles.

I still see problems with sio.  It doesn't use grab/ungrab yet, although
grab/ungrab were designed by me in ~1988 for my serial drivers older than
sio.

Note that cngetc() was broken by multiple console support in ~2000.
Before that, cngetc() waited with device interrupts disabled.  This
prevented the interrupt handler eating the interrupts.  Now it polls
and is still broken since its polling loop is not wrapped by
grab/ungrab.  cngets() was broken before multiple consoles, but was
fairly usable.  You just had to type reasonably slowly so that the
characters arrive in the low-level polling loop while device interrupts
are disabled.


Hmmm... speaking of the geli pw prompt... what's the locking situation
there?  Will there be any problems calling pause() from that context?


PVM isn't an ideal priority to wait at. PWAIT would be better. However,
if the only reason to call pause is run the scheduler after each character,
perhaps a better solution would be to call kern_yield() instead? We could
do that instead of cpu_waitspin() inside of cngetc, but that would break
the debugger's use of it


Console drivers can't block or depend on timeouts.  Perhaps cngets() can,
because it is only called in simple contexts, but the simple contexts
make it especially easy for it to work using the same synchronous i/o that
is needed in more complicated contexts.


Note that this particular problem doesn't seem to be caused by the console
driver as such.  One of the things I've tried was to add a callout that
prints out something each second, and then enter an infinite loop.  The
assumption is, the loop in proc0 should get preempted by the callout.
For some reason this doesn't happen.


But it is a bug for (low level) console drivers to ever wait.  They should
assert that they don't.


I think we should first try to figure out why this doesn't work in the first
place.

Basically, even though the interrupts are running, scheduler seems to be ok,
and the thread that's calling this has a lower priority than the callouts
thread, it can't be preempted.  This doesn't seem to be caused by vt(4);
with syscons the callouts don't get called either (it just doesn't break
the echo in this case).  To demonstrate the problem you can add add
a callout that calls printf each second and then does an infinite loop.


cngets() is even correctly wrapped by cngrab()/cnungrab().  This is supposed
to put the console driver in a special synchronous mode for the duration of
the grabbing.  (Console drivers still need to be reentrant, so that they
can do i/o when the grabbed section is reentered for ddb or another
non-maskable trap.)  syscons and vt have similar too-simple grab handlers
which start with a screen switch in the !cold case.  This should refresh
the screen and/or switch it to special low-level console screen(s).


So basically, what you're suggesting is to make cngrab() set a flag that
switches vt, and its video drivers, into a mode that doesn't use any kind
of callouts, right?  That seems like a proper solution, but still doesn't
explain the root of the problem here.


Yes.  They already increment an xx_grabbed counter, but only use it to
do nothing for nested grabs.  (Doing nothing is too simple.)


Screen switching in ddb is noticeably more broken for vt than for syscons.
Indeed, it just doesn't work in vt (except for the initial switch to vty0).
This might be related.


Yeah; I remember some strange problems with keyboard state when
entering/leaving ddb.


Both syscons and vt hang fairly quickly in -current for the ddb command
's/p,1000'.  vt just hangs sooner.  I think I fixed this in an old version
of syscons, but I only tested the fix on systems with not as many CPUs as
the one that shows the most problems.  Printing after every instruction
in ddb is a 

svn commit: r297271 - head

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 19:12:41 2016
New Revision: 297271
URL: https://svnweb.freebsd.org/changeset/base/297271

Log:
  Update flags for external GCC.
  
  - The -L WORLDTMP/usr/lib is not needed as GCC is already adding in
-L =/usr/lib internally with --sysroot.  It does not do this for
header include paths though, thus passing -isystem =/usr/include is
still needed.
  
  For the forced libc++ usage:
  - Use -isystem rather than -I for libc++ headers.
  - Use -std=c++11 rather than gnu++11.
  - Use -nostdinc++ to ensure GCC's headers don't leak in.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Mar 25 19:12:38 2016(r297270)
+++ head/Makefile.inc1  Fri Mar 25 19:12:41 2016(r297271)
@@ -432,8 +432,11 @@ TARGET_ABI=gnueabi
 .endif
 .endif
 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
-XCFLAGS+=  -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
-XCXXFLAGS+=-I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 
-L${WORLDTMP}/../lib/libc++
+# GCC requires -isystem when using a cross-compiler.
+XCFLAGS+=  -isystem ${WORLDTMP}/usr/include
+# Force using libc++ for external GCC.
+XCXXFLAGS+=-isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
+   -nostdinc++ -L${WORLDTMP}/../lib/libc++
 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
 # due to CXX="${XCXX} ${XCXXFLAGS}".  bsd.dep.mk does use CXXFLAGS when
 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297269 - head

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 19:12:13 2016
New Revision: 297269
URL: https://svnweb.freebsd.org/changeset/base/297269

Log:
  LIBRARIES_ONLY should only be defined during install32.
  
  r245561 added it to prevent extra files from being installed during
  the install32 phase (to prevent duplicates in the meta log with -DNO_ROOT).
  The flag should not be passed during build32 though since it may
  prevent staging of includes during the 'make includes' phase on
  library directories.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.libcompat

Modified: head/Makefile.libcompat
==
--- head/Makefile.libcompat Fri Mar 25 16:01:40 2016(r297268)
+++ head/Makefile.libcompat Fri Mar 25 19:12:13 2016(r297269)
@@ -79,7 +79,6 @@ LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${L
 LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
CXX="${XCXX} ${LIBCOMPATCFLAGS}" \
DESTDIR=${LIBCOMPATTMP} \
-   -DLIBRARIES_ONLY \
-DNO_CPU_CFLAGS \
MK_CTF=no \
-DNO_LINT \
@@ -87,7 +86,8 @@ LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCO
 LIBCOMPATWMAKE+=   ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
MK_MAN=no MK_HTML=no
 LIBCOMPATIMAKE+=   
${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
-   MK_TOOLCHAIN=no ${IMAKE_INSTALL}
+   MK_TOOLCHAIN=no ${IMAKE_INSTALL} \
+   -DLIBRARIES_ONLY
 
 .if ${XCC:N${CCACHE_BIN}:M/*}
 LIBCOMPATCFLAGS+=  --sysroot=${WORLDTMP}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297270 - in head: . share/mk

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 19:12:38 2016
New Revision: 297270
URL: https://svnweb.freebsd.org/changeset/base/297270

Log:
  Build libcompat (lib32) with a --sysroot pointing into its stage directory.
  
  This overrides the cross-compiler's default sysroot to use the WORLD32's
  sysroot for building the lib32 libraries.  Previously the cross-compiler
  would default the sysroot to the 64bit WORLDTMP and -B/-L/-isystem flags
  were used to build using the lib32 files.  This leads to multiple issues
  discussed later.  Some extra headers are now needed to be staged since the
  64bit WORLDTMP is not referenced at all for headers.  The 64bit WORLDTMP
  is still used via PATH for build tools.  Overriding the default
  target/arch is retained in the CC/CXX overrides.
  
  This allows reverting the LDSCRIPT rewriting in installworld from r296921 and
  r235122, thus allowing read-only objdirs to work for installing again.
  
  This removes the need for _LDSCRIPTROOT.
  
  This allows progressing the change to always use --sysroot for the build
  rather than only relying on the cross-compiler's default sysroot.  The
  work for that is in D3970 and needed to resolve WITHOUT_CROSS_COMPILER
  not using a --sysroot [1].
  
  PR:   196193 [1]
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.inc1
  head/Makefile.libcompat
  head/share/mk/bsd.lib.mk
  head/share/mk/bsd.sys.mk

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Mar 25 19:12:13 2016(r297269)
+++ head/Makefile.inc1  Fri Mar 25 19:12:38 2016(r297270)
@@ -360,7 +360,6 @@ KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOB
 
 # world stage
 WMAKEENV=  ${CROSSENV} \
-   _LDSCRIPTROOT= \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
PATH=${TMPPATH}
 

Modified: head/Makefile.libcompat
==
--- head/Makefile.libcompat Fri Mar 25 19:12:13 2016(r297269)
+++ head/Makefile.libcompat Fri Mar 25 19:12:38 2016(r297270)
@@ -64,13 +64,17 @@ LIBCOMPAT_OBJTREE?= ${OBJTREE}${.CURDIR}
 LIBCOMPATTMP?= ${OBJTREE}${.CURDIR}/lib${libcompat}
 
 LIBCOMPATCFLAGS+=  ${LIBCOMPATCPUFLAGS} \
-   -isystem ${LIBCOMPATTMP}/usr/include/ \
-L${LIBCOMPATTMP}/usr/lib${libcompat} \
-   -B${LIBCOMPATTMP}/usr/lib${libcompat}
+   --sysroot=${LIBCOMPATTMP}
+
+# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for
+# Clang/GCC.
+LIBCOMPATCFLAGS+=  -B${LIBCOMPATTMP}/usr/lib${libcompat}
+# GCC requires -isystem when using a cross-compiler.
+LIBCOMPATCFLAGS+=  -isystem ${LIBCOMPATTMP}/usr/include
 
 # Yes, the flags are redundant.
 LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \
-   _LDSCRIPTROOT=${LIBCOMPATTMP} \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
PATH=${TMPPATH} \
LIBDIR=/usr/lib${libcompat} \
@@ -89,15 +93,16 @@ LIBCOMPATIMAKE+=${LIBCOMPATWMAKE:NINSTA
MK_TOOLCHAIN=no ${IMAKE_INSTALL} \
-DLIBRARIES_ONLY
 
-.if ${XCC:N${CCACHE_BIN}:M/*}
-LIBCOMPATCFLAGS+=  --sysroot=${WORLDTMP}
-.endif
-
 _LC_LIBDIRS.yes=   lib gnu/lib
 _LC_LIBDIRS.${MK_CDDL:tl}+=cddl/lib
 _LC_LIBDIRS.${MK_CRYPT:tl}+=   secure/lib
 _LC_LIBDIRS.${MK_KERBEROS:tl}+=kerberos5/lib
 
+_LC_INCDIRS=   \
+   include \
+   lib/ncurses/ncursesw \
+   ${_LC_LIBDIRS.yes}
+
 # Shared logic
 build${libcompat}: .PHONY
@echo
@@ -120,8 +125,7 @@ build${libcompat}: .PHONY
mkdir -p ${WORLDTMP}
ln -sf ${.CURDIR}/sys ${WORLDTMP}
 .for _t in obj includes
-   ${_+_}cd ${.CURDIR}/include; ${LIBCOMPATWMAKE} DIRPRFX=include/ ${_t}
-.for _dir in ${_LC_LIBDIRS.yes}
+.for _dir in ${_LC_INCDIRS}
${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} DIRPRFX=${_dir}/ ${_t}
 .endfor
 .endfor

Modified: head/share/mk/bsd.lib.mk
==
--- head/share/mk/bsd.lib.mkFri Mar 25 19:12:13 2016(r297269)
+++ head/share/mk/bsd.lib.mkFri Mar 25 19:12:38 2016(r297270)
@@ -215,26 +215,10 @@ ${SHLIB_NAME_FULL}: beforelinking
 .endif
 
 .if defined(SHLIB_LINK)
-# ${_LDSCRIPTROOT} is needed when cross-building
-# and when building 32 bits library shims.
-#
-# ${_LDSCRIPTROOT} is the directory prefix that will be used when generating
-# ld(1) scripts.  The crosstools' ld is configured to lookup libraries in an
-# alternative directory which is called "sysroot", so during buildworld 
binaries
-# won't be linked against the running system libraries but against the ones of
-# the current source tree.  ${_LDSCRIPTROOT} behavior is twisted because of
-# the location where we 

svn commit: r297272 - head

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 19:12:44 2016
New Revision: 297272
URL: https://svnweb.freebsd.org/changeset/base/297272

Log:
  Fix libcompat not handling some external toolchain flags.
  
  - Use libc++ with GCC.
  - Use CROSS_BINUTILS_PREFIX with -B (r280980 addressed this mostly already)
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.libcompat

Modified: head/Makefile.libcompat
==
--- head/Makefile.libcompat Fri Mar 25 19:12:41 2016(r297271)
+++ head/Makefile.libcompat Fri Mar 25 19:12:44 2016(r297272)
@@ -52,7 +52,8 @@ LIBSOFTWMAKEFLAGS=-DCOMPAT_SOFTF
 # Generic code for each type.
 # Set defaults based on type.
 libcompat= ${LIBCOMPAT:tl}
-_LIBCOMPAT_MAKEVARS=   _OBJTREE TMP CPUFLAGS CFLAGS WMAKEENV WMAKEFLAGS WMAKE
+_LIBCOMPAT_MAKEVARS=   _OBJTREE TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \
+   WMAKEFLAGS WMAKE
 .for _var in ${_LIBCOMPAT_MAKEVARS}
 .if !empty(LIB${LIBCOMPAT}${_var})
 LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}}
@@ -65,7 +66,8 @@ LIBCOMPATTMP?=${OBJTREE}${.CURDIR}/lib
 
 LIBCOMPATCFLAGS+=  ${LIBCOMPATCPUFLAGS} \
-L${LIBCOMPATTMP}/usr/lib${libcompat} \
-   --sysroot=${LIBCOMPATTMP}
+   --sysroot=${LIBCOMPATTMP} \
+   ${BFLAGS}
 
 # -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for
 # Clang/GCC.
@@ -73,6 +75,12 @@ LIBCOMPATCFLAGS+=-B${LIBCOMPATTMP}/usr/
 # GCC requires -isystem when using a cross-compiler.
 LIBCOMPATCFLAGS+=  -isystem ${LIBCOMPATTMP}/usr/include
 
+.if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
+# Force using libc++ for external GCC.
+LIBCOMPATCXXFLAGS+=-isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \
+   -nostdinc++ -L${LIBCOMPAT_OBJTREE}${.CURDIR}/lib/libc++
+.endif
+
 # Yes, the flags are redundant.
 LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
@@ -81,7 +89,7 @@ LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${L
SHLIBDIR=/usr/lib${libcompat} \
DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
 LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
-   CXX="${XCXX} ${LIBCOMPATCFLAGS}" \
+   CXX="${XCXX} ${LIBCOMPATCFLAGS} ${LIBCOMPATCXXFLAGS}" \
DESTDIR=${LIBCOMPATTMP} \
-DNO_CPU_CFLAGS \
MK_CTF=no \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r296921 - head/share/mk

2016-03-25 Thread Bryan Drewery
On 3/23/16 1:30 PM, Bryan Drewery wrote:
> On 3/22/2016 9:00 AM, Bryan Drewery wrote:
>> On 3/22/16 8:44 AM, Nikolai Lifanov wrote:
>>> On 03/22/16 11:26, Bryan Drewery wrote:
 On 3/22/16 4:39 AM, Jean-Sébastien Pédron wrote:
> Hi!
>
> I can't install world with a read-only /usr/obj anymore:
> https://gist.github.com/dumbbell/fd5940d2603bbadb14f0
>
> It looks related to r296921 but I don't fully understand our build
> system to be sure of that.
>
> What do you think?
>

 Definitely, but I don't think it would have worked before "r284345 | sjg
 | 2015-06-13" anyhow.

 The better fix here involves a lot of rework to the LIB32 build.  I
 might be able to come up with a hack to fix read-only /usr/obj here
 until the major LIB32 work can be done.

>>>
>>> Install with read-only obj worked for me before this change.
>>>
>>
>> With LIB32 enabled, on head? I don't see how after "r235122 | jlh |
>> 2012-05-07" made the change I restored.
>>
>>
> 
> FYI I am working on resolving this by making the lib32 build use a
> proper --sysroot.  It should be done in the next few days.
> 

This should now work again after r297270.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r297273 - in head/sys: ddb kern sys

2016-03-25 Thread Conrad E. Meyer
Author: cem
Date: Fri Mar 25 19:35:29 2016
New Revision: 297273
URL: https://svnweb.freebsd.org/changeset/base/297273

Log:
  Add td_swinvoltick to track last involuntary context switch
  
  Expose in DDB via "show thread."
  
  Reviewed by:  markj
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/ddb/db_ps.c
  head/sys/kern/kern_synch.c
  head/sys/sys/proc.h

Modified: head/sys/ddb/db_ps.c
==
--- head/sys/ddb/db_ps.cFri Mar 25 19:12:44 2016(r297272)
+++ head/sys/ddb/db_ps.cFri Mar 25 19:35:29 2016(r297273)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -302,6 +303,7 @@ DB_SHOW_COMMAND(thread, db_show_thread)
struct thread *td;
struct lock_object *lock;
bool comma;
+   int delta;
 
/* Determine which thread to examine. */
if (have_addr)
@@ -376,6 +378,16 @@ DB_SHOW_COMMAND(thread, db_show_thread)
td->td_wchan);
db_printf(" priority: %d\n", td->td_priority);
db_printf(" container lock: %s (%p)\n", lock->lo_name, lock);
+   if (td->td_swvoltick != 0) {
+   delta = (u_int)ticks - (u_int)td->td_swvoltick;
+   db_printf(" last voluntary switch: %d ms ago\n",
+   1000 * delta / hz);
+   }
+   if (td->td_swinvoltick != 0) {
+   delta = (u_int)ticks - (u_int)td->td_swinvoltick;
+   db_printf(" last involuntary switch: %d ms ago\n",
+   1000 * delta / hz);
+   }
 }
 
 DB_SHOW_COMMAND(proc, db_show_proc)

Modified: head/sys/kern/kern_synch.c
==
--- head/sys/kern/kern_synch.c  Fri Mar 25 19:12:44 2016(r297272)
+++ head/sys/kern/kern_synch.c  Fri Mar 25 19:35:29 2016(r297273)
@@ -438,8 +438,10 @@ mi_switch(int flags, struct thread *newt
if (flags & SW_VOL) {
td->td_ru.ru_nvcsw++;
td->td_swvoltick = ticks;
-   } else
+   } else {
td->td_ru.ru_nivcsw++;
+   td->td_swinvoltick = ticks;
+   }
 #ifdef SCHED_STATS
SCHED_STAT_INC(sched_switch_stats[flags & SW_TYPE_MASK]);
 #endif

Modified: head/sys/sys/proc.h
==
--- head/sys/sys/proc.h Fri Mar 25 19:12:44 2016(r297272)
+++ head/sys/sys/proc.h Fri Mar 25 19:35:29 2016(r297273)
@@ -254,6 +254,7 @@ struct thread {
int td_slptick; /* (t) Time at sleep. */
int td_blktick; /* (t) Time spent blocked. */
int td_swvoltick;   /* (t) Time at last SW_VOL switch. */
+   int td_swinvoltick; /* (t) Time at last SW_INVOL switch. */
u_int   td_cow; /* (*) Number of copy-on-write faults */
struct rusage   td_ru;  /* (t) rusage information. */
struct rusage_ext td_rux;   /* (t) Internal rusage information. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r297225 - in head/sys: net netinet netinet6

2016-03-25 Thread Bjoern A. Zeeb

On Thu, 24 Mar 2016, Gleb Smirnoff wrote:


On Thu, Mar 24, 2016 at 07:54:56AM +, George V. Neville-Neil wrote:
G> Author: gnn
G> Date: Thu Mar 24 07:54:56 2016
G> New Revision: 297225
G> URL: https://svnweb.freebsd.org/changeset/base/297225
G>
G> Log:
G>   FreeBSD previously provided route caching for TCP (and UDP). Re-add
G>   route caching for TCP, with some improvements. In particular, invalidate
G>   the route cache if a new route is added, which might be a better match.
G>   The cache is automatically invalidated if the old route is deleted.
G>
G>   Submitted by:   Mike Karels
G>   Reviewed by:gnn
G>   Differential Revision:  https://reviews.freebsd.org/D4306

I'm quite surprised to see this checked in, taking into account that the
D4306 has strong disagreement from melifaro@.

So, now we got two aids for poor routing: TCP route caching & flowtable.


I am uncertain by what you mean when you say "routing".

For as forwarding is concerned, this doesn't matter.

For as local connections are concerned, this is the start to scale
again.  You are saving 1-2 route lookups per first packet and 2-3
route lookups for any subsequent packet.  Worst case scenario your FIB
changes for each packet still improves the situation as in the first
packet situation.

Every lookup I don't have to do I don't have optimize a system for as
badly as I would otherwise have to.

Flowtable in my view, once this is fully flashed out, has no real
reason to be used anymore.

Everything else I think my initial reply and gnn's reply has covered.

/bz
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r297225 - in head/sys: net netinet netinet6

2016-03-25 Thread Adrian Chadd
[snip]

The thing flowtable gave you is the ability to set a per connection
(L4 match) to be able to set a destination MAC to forward to - so you
COULD build a complete load balancer in kernel.

Gleb stripped out the L4 bits to simplify it for netflix, which
removed that functionality.

I'd love to see it re-added back in and a userland API to let us do
that - then yes, we can build kernel load balancers for this stuff.

-a
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297276 - in head/contrib/byacc: . package package/debian package/pkgsrc

2016-03-25 Thread Jung-uk Kim
Author: jkim
Date: Fri Mar 25 22:32:26 2016
New Revision: 297276
URL: https://svnweb.freebsd.org/changeset/base/297276

Log:
  Merge byacc 20160324.

Modified:
  head/contrib/byacc/CHANGES
  head/contrib/byacc/MANIFEST
  head/contrib/byacc/VERSION
  head/contrib/byacc/aclocal.m4
  head/contrib/byacc/config.guess
  head/contrib/byacc/config.sub
  head/contrib/byacc/main.c
  head/contrib/byacc/package/byacc.spec
  head/contrib/byacc/package/debian/changelog
  head/contrib/byacc/package/debian/copyright
  head/contrib/byacc/package/mingw-byacc.spec
  head/contrib/byacc/package/pkgsrc/Makefile
  head/contrib/byacc/reader.c
Directory Properties:
  head/contrib/byacc/   (props changed)

Modified: head/contrib/byacc/CHANGES
==
--- head/contrib/byacc/CHANGES  Fri Mar 25 21:34:18 2016(r297275)
+++ head/contrib/byacc/CHANGES  Fri Mar 25 22:32:26 2016(r297276)
@@ -1,3 +1,28 @@
+2016-03-24  Thomas E. Dickey  
+
+   * reader.c: unused variable
+
+   * package/pkgsrc/Makefile, package/debian/copyright: bump
+
+2016-03-24  Jung-uk.Kim
+
+   * main.c:
+   correct logic for finding output suffix in the "-o" option, which 
matched
+   the first occurrence of ".c" in the name in 2005-08-13 changes rather 
than
+   at the end of the filename (patch by Jung-uk Kim)
+
+2016-03-24  Thomas E. Dickey  
+
+   * aclocal.m4:
+   update CF_WITH_MAN2HTML to use configured shell rather than /bin/sh
+
+   * VERSION, package/byacc.spec, package/debian/changelog, 
package/mingw-byacc.spec, package/pkgsrc/Makefile:
+   bump
+
+2016-01-25  Thomas E. Dickey  
+
+   * config.guess, config.sub: 2016-01-01
+
 2015-07-10  Thomas E. Dickey  
 
* lr0.c: fix a duplicate-free in the leak-checking
@@ -2275,7 +2300,7 @@
 
* vmsbuild.com: original version
 
-2000-02-23  Thomas E. Dickey  
+2000-02-23  dickey
 
* test/RCS, RCS: PERMIT FILE
 

Modified: head/contrib/byacc/MANIFEST
==
--- head/contrib/byacc/MANIFEST Fri Mar 25 21:34:18 2016(r297275)
+++ head/contrib/byacc/MANIFEST Fri Mar 25 22:32:26 2016(r297276)
@@ -1,4 +1,4 @@
-MANIFEST for byacc-20150711, version t20150711
+MANIFEST for byacc-20160324, version t20160324
 

 MANIFESTthis file
 ACKNOWLEDGEMENTSoriginal version of byacc - 1993

Modified: head/contrib/byacc/VERSION
==
--- head/contrib/byacc/VERSION  Fri Mar 25 21:34:18 2016(r297275)
+++ head/contrib/byacc/VERSION  Fri Mar 25 22:32:26 2016(r297276)
@@ -1 +1 @@
-20150711
+20160324

Modified: head/contrib/byacc/aclocal.m4
==
--- head/contrib/byacc/aclocal.m4   Fri Mar 25 21:34:18 2016
(r297275)
+++ head/contrib/byacc/aclocal.m4   Fri Mar 25 22:32:26 2016
(r297276)
@@ -1,7 +1,7 @@
-dnl $Id: aclocal.m4,v 1.38 2015/07/05 22:16:23 tom Exp $
+dnl $Id: aclocal.m4,v 1.39 2016/03/25 00:06:44 tom Exp $
 dnl Macros for byacc configure script (Thomas E. Dickey)
 dnl ---
-dnl Copyright 2004-2014,2015 Thomas E. Dickey
+dnl Copyright 2004-2015,2016 Thomas E. Dickey
 dnl 
 dnl Permission is hereby granted, free of charge, to any person obtaining a
 dnl copy of this software and associated documentation files (the
@@ -1121,7 +1121,7 @@ if test "$with_dmalloc" = yes ; then
 fi
 ])dnl
 dnl ---
-dnl CF_WITH_MAN2HTML version: 4 updated: 2015/05/03 19:10:48
+dnl CF_WITH_MAN2HTML version: 5 updated: 2015/08/20 04:51:36
 dnl 
 dnl Check for man2html and groff.  Optionally prefer man2html over groff.
 dnl Generate a shell script which hides the differences between the two.
@@ -1157,7 +1157,7 @@ esac
 
 MAN2HTML_TEMP="man2html.tmp"
cat >$MAN2HTML_TEMP <>$MAN2HTML_TEMP 

svn commit: r297278 - head

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 22:36:23 2016
New Revision: 297278
URL: https://svnweb.freebsd.org/changeset/base/297278

Log:
  External compiler: Remove redundant flags from CXXFLAGS.
  
  The use of XCXXFLAGS is to assign it to CXX in CROSSENV.
  XCFLAGS is also assigned here so there is no need to have
  --syroot and -B flags again.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Mar 25 22:36:13 2016(r297277)
+++ head/Makefile.inc1  Fri Mar 25 22:36:23 2016(r297278)
@@ -448,12 +448,10 @@ TARGET_TRIPLE?=   ${TARGET_ARCH:C/amd64/x8
 XCFLAGS+=  -target ${TARGET_TRIPLE}
 .endif
 XCFLAGS+=  --sysroot=${WORLDTMP} ${BFLAGS}
-XCXXFLAGS+=--sysroot=${WORLDTMP} ${BFLAGS}
 .else
 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
 BFLAGS+=   -B${CROSS_BINUTILS_PREFIX}
 XCFLAGS+=  ${BFLAGS}
-XCXXFLAGS+=${BFLAGS}
 .endif
 .endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297279 - head

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 22:36:26 2016
New Revision: 297279
URL: https://svnweb.freebsd.org/changeset/base/297279

Log:
  CROSS_BINUTILS_PREFIX: Reduce redundant logic.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Mar 25 22:36:23 2016(r297278)
+++ head/Makefile.inc1  Fri Mar 25 22:36:26 2016(r297279)
@@ -413,16 +413,16 @@ CROSSENV+=CC="${XCC} ${XCFLAGS}" CXX="$
RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
SIZE="${XSIZE}"
 
-# External compiler needs sysroot and target flags.
-.if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
-.if defined(CROSS_BINUTILS_PREFIX)
+.if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
-# directory, but the compiler will look in the right place for it's
+# directory, but the compiler will look in the right place for its
 # tools so we don't need to tell it where to look.
-.if exists(${CROSS_BINUTILS_PREFIX})
 BFLAGS+=   -B${CROSS_BINUTILS_PREFIX}
 .endif
-.else
+
+# External compiler needs sysroot and target flags.
+.if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
+.if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
 BFLAGS+=   -B${WORLDTMP}/usr/bin
 .endif
 .if ${TARGET} == "arm"
@@ -447,13 +447,13 @@ TARGET_ABI?=  unknown
 TARGET_TRIPLE?=${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
 XCFLAGS+=  -target ${TARGET_TRIPLE}
 .endif
-XCFLAGS+=  --sysroot=${WORLDTMP} ${BFLAGS}
+XCFLAGS+=  --sysroot=${WORLDTMP}
 .else
-.if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
-BFLAGS+=   -B${CROSS_BINUTILS_PREFIX}
+.endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
+
+.if !empty(BFLAGS)
 XCFLAGS+=  ${BFLAGS}
 .endif
-.endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
 
 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
 ${TARGET_ARCH} == "powerpc64")
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297280 - head/share/mk

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 22:36:29 2016
New Revision: 297280
URL: https://svnweb.freebsd.org/changeset/base/297280

Log:
  WITHOUT_TOOLCHAIN: Also exclude LLDB.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/share/mk/src.opts.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Fri Mar 25 22:36:26 2016(r297279)
+++ head/share/mk/src.opts.mk   Fri Mar 25 22:36:29 2016(r297280)
@@ -355,6 +355,7 @@ MK_CLANG:=  no
 MK_GCC:=   no
 MK_GDB:=   no
 MK_INCLUDES:=  no
+MK_LLDB:=  no
 .endif
 
 .if ${MK_CLANG} == "no"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297281 - head

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 22:36:32 2016
New Revision: 297281
URL: https://svnweb.freebsd.org/changeset/base/297281

Log:
  WITHOUT_TOOLCHAIN: Fix includes not being staged in WORLDTMP.
  
  This has been the case since r264930 and r274662.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Mar 25 22:36:29 2016(r297280)
+++ head/Makefile.inc1  Fri Mar 25 22:36:32 2016(r297281)
@@ -623,9 +623,9 @@ _includes:
 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
 # headers from default SUBDIR.  Do SUBDIR_OVERRIDE includes last.
${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
-   includes
+   MK_INCLUDES=yes includes
 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
-   ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
+   ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
 .endif
 _libraries:
@echo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297277 - head

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 25 22:36:13 2016
New Revision: 297277
URL: https://svnweb.freebsd.org/changeset/base/297277

Log:
  WITHOUT_CROSS_COMPILER: Fix this to use external compiler logic.
  
  Without this the default toolchain in /usr/bin/ would not use
  WORLDTMP via --sysroot, and would lack --target if cross-building.
  
  PR:   196193
  Related:  D3970
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Mar 25 22:32:26 2016(r297276)
+++ head/Makefile.inc1  Fri Mar 25 22:36:13 2016(r297277)
@@ -413,7 +413,8 @@ CROSSENV+=  CC="${XCC} ${XCFLAGS}" CXX="$
RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
SIZE="${XSIZE}"
 
-.if ${XCC:N${CCACHE_BIN}:M/*}
+# External compiler needs sysroot and target flags.
+.if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
 .if defined(CROSS_BINUTILS_PREFIX)
 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
 # directory, but the compiler will look in the right place for it's
@@ -454,7 +455,7 @@ BFLAGS+=-B${CROSS_BINUTILS_PREFIX}
 XCFLAGS+=  ${BFLAGS}
 XCXXFLAGS+=${BFLAGS}
 .endif
-.endif # ${XCC:M/*}
+.endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
 
 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
 ${TARGET_ARCH} == "powerpc64")
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297283 - in head: lib/clang/libllvmsupport lib/libc/net lib/libc/stdtime lib/libclang_rt/asan_dynamic lib/libz lib/msun/arm share/mk sys/boot/i386/boot0 sys/boot/i386/boot2 sys/boot/i3...

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Sat Mar 26 03:46:12 2016
New Revision: 297283
URL: https://svnweb.freebsd.org/changeset/base/297283

Log:
  Implement (ACFLAGS|CFLAGS|CXXFLAGS).SRC globally.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/lib/clang/libllvmsupport/Makefile
  head/lib/libc/net/Makefile.inc
  head/lib/libc/stdtime/Makefile.inc
  head/lib/libclang_rt/asan_dynamic/Makefile
  head/lib/libz/Makefile
  head/lib/msun/arm/Makefile.inc
  head/share/mk/bsd.README
  head/share/mk/bsd.sys.mk
  head/sys/boot/i386/boot0/Makefile
  head/sys/boot/i386/boot2/Makefile
  head/sys/boot/i386/btx/btx/Makefile
  head/sys/boot/i386/btx/btxldr/Makefile
  head/sys/boot/i386/cdboot/Makefile
  head/sys/boot/i386/gptboot/Makefile
  head/sys/boot/i386/gptzfsboot/Makefile
  head/sys/boot/i386/libi386/Makefile
  head/sys/boot/i386/pxeldr/Makefile
  head/sys/boot/i386/zfsboot/Makefile
  head/sys/boot/pc98/boot2/Makefile
  head/sys/boot/pc98/btx/btx/Makefile
  head/sys/boot/pc98/btx/btxldr/Makefile
  head/sys/boot/pc98/cdboot/Makefile

Modified: head/lib/clang/libllvmsupport/Makefile
==
--- head/lib/clang/libllvmsupport/Makefile  Sat Mar 26 03:46:04 2016
(r297282)
+++ head/lib/clang/libllvmsupport/Makefile  Sat Mar 26 03:46:12 2016
(r297283)
@@ -113,4 +113,3 @@ SRCS+=  StringPool.cpp
 # Ugly hack to work around CLOCK_PROCESS_CPUTIME_ID not being properly defined
 # between r239347 and r245428.
 CXXFLAGS.Process.cpp=  -DCLOCK_PROCESS_CPUTIME_ID=15
-CXXFLAGS+= ${CXXFLAGS.${.IMPSRC:T}}

Modified: head/lib/libc/net/Makefile.inc
==
--- head/lib/libc/net/Makefile.inc  Sat Mar 26 03:46:04 2016
(r297282)
+++ head/lib/libc/net/Makefile.inc  Sat Mar 26 03:46:12 2016
(r297283)
@@ -35,7 +35,6 @@ YFLAGS+=-p_nsyy
 LFLAGS+=-P_nsyy
 
 CFLAGS.nslexer.c= -DYY_BUF_SIZE=1024
-CFLAGS+=   ${CFLAGS.${.IMPSRC:T}}
 
 MAN+=  byteorder.3 ethers.3 eui64.3 \
getaddrinfo.3 gai_strerror.3 gethostbyname.3 \

Modified: head/lib/libc/stdtime/Makefile.inc
==
--- head/lib/libc/stdtime/Makefile.inc  Sat Mar 26 03:46:04 2016
(r297282)
+++ head/lib/libc/stdtime/Makefile.inc  Sat Mar 26 03:46:12 2016
(r297283)
@@ -12,7 +12,6 @@ SYM_MAPS+= ${LIBC_SRCTOP}/stdtime/Symbol
 CFLAGS+= -I${LIBC_SRCTOP}/../../contrib/tzcode/stdtime -I${LIBC_SRCTOP}/stdtime
 
 CFLAGS.localtime.c= -fwrapv
-CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
 
 MAN+=  ctime.3 strftime.3 strptime.3 time2posix.3
 MAN+=  tzfile.5

Modified: head/lib/libclang_rt/asan_dynamic/Makefile
==
--- head/lib/libclang_rt/asan_dynamic/Makefile  Sat Mar 26 03:46:04 2016
(r297282)
+++ head/lib/libclang_rt/asan_dynamic/Makefile  Sat Mar 26 03:46:12 2016
(r297283)
@@ -101,4 +101,3 @@ CXXFLAGS.ubsan_handlers_cxx.cc= -frtti
 CXXFLAGS.ubsan_type_hash.cc=   -frtti
 CXXFLAGS.ubsan_type_hash_itanium.cc=   -frtti
 CXXFLAGS.ubsan_type_hash_win.cc=   -frtti
-CXXFLAGS+= ${CXXFLAGS.${.IMPSRC:T}}

Modified: head/lib/libz/Makefile
==
--- head/lib/libz/Makefile  Sat Mar 26 03:46:04 2016(r297282)
+++ head/lib/libz/Makefile  Sat Mar 26 03:46:12 2016(r297283)
@@ -75,4 +75,3 @@ FILESDIR= ${LIBDATADIR}/pkgconfig
 
 ## XXX: clang integrated-as doesn't grok .intel_syntax directives yet
 #ACFLAGS.gvmat64.S=${CLANG_NO_IAS}
-#ACFLAGS+= ${ACFLAGS.${.IMPSRC:T}}

Modified: head/lib/msun/arm/Makefile.inc
==
--- head/lib/msun/arm/Makefile.inc  Sat Mar 26 03:46:04 2016
(r297282)
+++ head/lib/msun/arm/Makefile.inc  Sat Mar 26 03:46:12 2016
(r297283)
@@ -8,5 +8,3 @@ ARCH_SRCS = fenv-softfp.c fenv-vfp.c
 .endif
 
 CFLAGS.fenv-vfp.c= -mfpu=vfp -mfloat-abi=softfp
-CFLAGS+=   ${CFLAGS.${.IMPSRC:T}}
-

Modified: head/share/mk/bsd.README
==
--- head/share/mk/bsd.READMESat Mar 26 03:46:04 2016(r297282)
+++ head/share/mk/bsd.READMESat Mar 26 03:46:12 2016(r297283)
@@ -120,6 +120,10 @@ object.
 
 The following variables are common:
 
+ACFLAGS.${SRC}
+   Flags dependent on source file name.
+CFLAGS.${SRC}
+   Flags dependent on source file name.
 CFLAGS.${COMPILER_TYPE}
Flags dependent on compiler added to CXXFLAGS.
 CFLAGS.${MACHINE_ARCH}
@@ -131,6 +135,8 @@ CXXFLAGS.${COMPILER_TYPE}
Flags dependent on compiler added to CXXFLAGS.
 CXXFLAGS.${MACHINE_ARCH}
Architectural flags added to CXXFLAGS.
+CXXFLAGS.${S

svn commit: r297282 - in head: kerberos5/lib/libroken share/mk

2016-03-25 Thread Bryan Drewery
Author: bdrewery
Date: Sat Mar 26 03:46:04 2016
New Revision: 297282
URL: https://svnweb.freebsd.org/changeset/base/297282

Log:
  We don't have a CPPFLAGS, COPTS or CPUFLAGS.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/kerberos5/lib/libroken/Makefile
  head/share/mk/bsd.README
  head/share/mk/bsd.clang-analyze.mk
  head/share/mk/bsd.prog.mk
  head/share/mk/bsd.progs.mk

Modified: head/kerberos5/lib/libroken/Makefile
==
--- head/kerberos5/lib/libroken/MakefileFri Mar 25 22:36:32 2016
(r297281)
+++ head/kerberos5/lib/libroken/MakefileSat Mar 26 03:46:04 2016
(r297282)
@@ -76,7 +76,6 @@ SRCS= base64.c \
write_pid.c \
xfree.c
 
-CPPFLAGS+= -DBUILD_ROKEN_LIB
 CFLAGS+=-I${KRB5DIR}/lib/roken -I.
 
 CLEANFILES= roken.h

Modified: head/share/mk/bsd.README
==
--- head/share/mk/bsd.READMEFri Mar 25 22:36:32 2016(r297281)
+++ head/share/mk/bsd.READMESat Mar 26 03:46:04 2016(r297282)
@@ -309,7 +309,7 @@ PROGS_CXX   PROG and PROGS_CXX in one Make
SRCS.bar=   bar_src.c
 
The supported variables are BINDIR BINGRP BINMODE BINOWN
-   CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS DPSRCS LDADD
+   CFLAGS CXXFLAGS DPADD DPLIBS DPSRCS LDADD
LDFLAGS LIBADD MAN MLINKS PROGNAME SRCS.
 
 PROGNAME   The name that the above program will be installed as, if

Modified: head/share/mk/bsd.clang-analyze.mk
==
--- head/share/mk/bsd.clang-analyze.mk  Fri Mar 25 22:36:32 2016
(r297281)
+++ head/share/mk/bsd.clang-analyze.mk  Sat Mar 26 03:46:04 2016
(r297282)
@@ -58,14 +58,12 @@ CLANG_ANALYZE_CXXFLAGS= ${CXXFLAGS:N-Wa,
 
 .c.clang-analyzer:
${CC:N${CCACHE_BIN}} ${CLANG_ANALYZE_FLAGS} \
-   ${CLANG_ANALYZE_CFLAGS} ${CPPFLAGS} \
-   ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \
-   ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
+   ${CLANG_ANALYZE_CFLAGS} \
+   ${.IMPSRC}
 .cc.clang-analyzer .cpp.clang-analyzer .cxx.clang-analyzer .C.clang-analyzer:
${CXX:N${CCACHE_BIN}} ${CLANG_ANALYZE_CXX_FLAGS} \
-   ${CLANG_ANALYZE_CXXFLAGS} ${CPPFLAGS} \
-   ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \
-   ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
+   ${CLANG_ANALYZE_CXXFLAGS} \
+   ${.IMPSRC}
 
 CLANG_ANALYZE_SRCS= \
${SRCS:M*.[cC]} ${SRCS:M*.cc} \

Modified: head/share/mk/bsd.prog.mk
==
--- head/share/mk/bsd.prog.mk   Fri Mar 25 22:36:32 2016(r297281)
+++ head/share/mk/bsd.prog.mk   Sat Mar 26 03:46:04 2016(r297282)
@@ -8,6 +8,7 @@
 
 # XXX The use of COPTS in modern makefiles is discouraged.
 .if defined(COPTS)
+.warning COPTS should be CFLAGS.
 CFLAGS+=${COPTS}
 .endif
 

Modified: head/share/mk/bsd.progs.mk
==
--- head/share/mk/bsd.progs.mk  Fri Mar 25 22:36:32 2016(r297281)
+++ head/share/mk/bsd.progs.mk  Sat Mar 26 03:46:04 2016(r297282)
@@ -24,7 +24,7 @@ PROGS += ${PROGS_CXX}
 # just one of many
 PROG_OVERRIDE_VARS +=  BINDIR BINGRP BINOWN BINMODE DPSRCS MAN NO_WERROR \
PROGNAME SRCS WARNS
-PROG_VARS +=   CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LIBADD LINKS \
+PROG_VARS +=   CFLAGS CXXFLAGS DPADD DPLIBS LDADD LIBADD LINKS \
LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
 .for v in ${PROG_VARS:O:u}
 .if empty(${PROG_OVERRIDE_VARS:M$v})
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297284 - in head/sys/arm: arm at91 conf include

2016-03-25 Thread Michal Meloun
Author: mmel
Date: Sat Mar 26 06:55:55 2016
New Revision: 297284
URL: https://svnweb.freebsd.org/changeset/base/297284

Log:
  ARM: Teach LINUX_BOOT_ABI to recognize DT blob.
  This allow us to boot FreeBSD kernel (using uImage encapsulation) directly
  from U-boot using 'bootm' command or by Android fastboot loader.
  For now, kernel uImage must be marked as Linux, but we can add support for
  FreeBSD into U-Boot later.

Modified:
  head/sys/arm/arm/machdep.c
  head/sys/arm/at91/board_tsc4370.c
  head/sys/arm/conf/TEGRA124
  head/sys/arm/include/machdep.h

Modified: head/sys/arm/arm/machdep.c
==
--- head/sys/arm/arm/machdep.c  Sat Mar 26 03:46:12 2016(r297283)
+++ head/sys/arm/arm/machdep.c  Sat Mar 26 06:55:55 2016(r297284)
@@ -115,6 +115,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #ifdef FDT
+#include 
 #include 
 #include 
 #endif
@@ -959,7 +960,8 @@ makectx(struct trapframe *tf, struct pcb
  * Fake up a boot descriptor table
  */
 vm_offset_t
-fake_preload_metadata(struct arm_boot_params *abp __unused)
+fake_preload_metadata(struct arm_boot_params *abp __unused, void *dtb_ptr,
+size_t dtb_size)
 {
 #ifdef DDB
vm_offset_t zstart = 0, zend = 0;
@@ -997,6 +999,16 @@ fake_preload_metadata(struct arm_boot_pa
} else
 #endif
lastaddr = (vm_offset_t)&end;
+   if (dtb_ptr != NULL) {
+   /* Copy DTB to KVA space and insert it into module chain. */
+   lastaddr = roundup(lastaddr, sizeof(int));
+   fake_preload[i++] = MODINFO_METADATA | MODINFOMD_DTBP;
+   fake_preload[i++] = sizeof(uint32_t);
+   fake_preload[i++] = (uint32_t)lastaddr;
+   memmove((void *)lastaddr, dtb_ptr, dtb_size);
+   lastaddr += dtb_size;
+   lastaddr = roundup(lastaddr, sizeof(int));
+   }
fake_preload[i++] = 0;
fake_preload[i] = 0;
preload_metadata = (void *)fake_preload;
@@ -1023,20 +1035,35 @@ linux_parse_boot_param(struct arm_boot_p
struct arm_lbabi_tag *walker;
uint32_t revision;
uint64_t serial;
+#ifdef FDT
+   struct fdt_header *dtb_ptr;
+   uint32_t dtb_size;
+#endif
 
/*
 * Linux boot ABI: r0 = 0, r1 is the board type (!= 0) and r2
 * is atags or dtb pointer.  If all of these aren't satisfied,
-* then punt.
+* then punt. Unfortunately, it looks like DT enabled kernels
+* doesn't uses board type and U-Boot delivers 0 in r1 for them.
 */
-   if (!(abp->abp_r0 == 0 && abp->abp_r1 != 0 && abp->abp_r2 != 0))
-   return 0;
+   if (abp->abp_r0 != 0 || abp->abp_r2 == 0)
+   return (0);
+#ifdef FDT
+   /* Test if r2 point to valid DTB. */
+   dtb_ptr = (struct fdt_header *)abp->abp_r2;
+   if (fdt_check_header(dtb_ptr) == 0) {
+   dtb_size = fdt_totalsize(dtb_ptr);
+   return (fake_preload_metadata(abp, dtb_ptr, dtb_size));
+   }
+#endif
+   /* Old, ATAG based boot must have board type set. */
+   if (abp->abp_r1 == 0)
+   return (0);
 
board_id = abp->abp_r1;
walker = (struct arm_lbabi_tag *)
(abp->abp_r2 + KERNVIRTADDR - abp->abp_physaddr);
 
-   /* xxx - Need to also look for binary device tree */
if (ATAG_TAG(walker) != ATAG_CORE)
return 0;
 
@@ -1077,7 +1104,7 @@ linux_parse_boot_param(struct arm_boot_p
 
init_static_kenv(NULL, 0);
 
-   return fake_preload_metadata(abp);
+   return fake_preload_metadata(abp, NULL, 0);
 }
 #endif
 
@@ -1135,7 +1162,7 @@ default_parse_boot_param(struct arm_boot
return lastaddr;
 #endif
/* Fall back to hardcoded metadata. */
-   lastaddr = fake_preload_metadata(abp);
+   lastaddr = fake_preload_metadata(abp, NULL, 0);
 
return lastaddr;
 }

Modified: head/sys/arm/at91/board_tsc4370.c
==
--- head/sys/arm/at91/board_tsc4370.c   Sat Mar 26 03:46:12 2016
(r297283)
+++ head/sys/arm/at91/board_tsc4370.c   Sat Mar 26 06:55:55 2016
(r297284)
@@ -601,7 +601,7 @@ parse_boot_param(struct arm_boot_params 
inkernel_bootinfo = *(struct tsc_bootinfo *)(abp->abp_r1);
}
 
-   return fake_preload_metadata(abp);
+   return fake_preload_metadata(abp, NULL, 0);
 }
 
 ARM_BOARD(NONE, "TSC4370 Controller Board");

Modified: head/sys/arm/conf/TEGRA124
==
--- head/sys/arm/conf/TEGRA124  Sat Mar 26 03:46:12 2016(r297283)
+++ head/sys/arm/conf/TEGRA124  Sat Mar 26 06:55:55 2016(r297284)
@@ -28,6 +28,7 @@ options   SCHED_ULE   # ULE scheduler
 optionsPLATFORM# Platform based SoC
 optionsPLATFORM_SMP
 optionsSMP 

svn commit: r297285 - in head/sys/arm: arm include

2016-03-25 Thread Michal Meloun
Author: mmel
Date: Sat Mar 26 06:57:36 2016
New Revision: 297285
URL: https://svnweb.freebsd.org/changeset/base/297285

Log:
  ARM: Fix ATAG handling in LINUX_BOOT_API:
   - Don't convert atags address passed from U-Boot. It's real physical
 address (and we have 1:1 mapping).
   - Size of tags is encoded in words, not in bytes

Modified:
  head/sys/arm/arm/machdep.c
  head/sys/arm/include/atags.h

Modified: head/sys/arm/arm/machdep.c
==
--- head/sys/arm/arm/machdep.c  Sat Mar 26 06:55:55 2016(r297284)
+++ head/sys/arm/arm/machdep.c  Sat Mar 26 06:57:36 2016(r297285)
@@ -1035,6 +1035,7 @@ linux_parse_boot_param(struct arm_boot_p
struct arm_lbabi_tag *walker;
uint32_t revision;
uint64_t serial;
+   int size;
 #ifdef FDT
struct fdt_header *dtb_ptr;
uint32_t dtb_size;
@@ -1061,8 +1062,7 @@ linux_parse_boot_param(struct arm_boot_p
return (0);
 
board_id = abp->abp_r1;
-   walker = (struct arm_lbabi_tag *)
-   (abp->abp_r2 + KERNVIRTADDR - abp->abp_physaddr);
+   walker = (struct arm_lbabi_tag *)abp->abp_r2;
 
if (ATAG_TAG(walker) != ATAG_CORE)
return 0;
@@ -1079,8 +1079,9 @@ linux_parse_boot_param(struct arm_boot_p
case ATAG_INITRD2:
break;
case ATAG_SERIAL:
-   serial = walker->u.tag_sn.low |
-   ((uint64_t)walker->u.tag_sn.high << 32);
+   serial = walker->u.tag_sn.high;
+   serial <<= 32;
+   serial |= walker->u.tag_sn.low;
board_set_serial(serial);
break;
case ATAG_REVISION:
@@ -1089,8 +1090,12 @@ linux_parse_boot_param(struct arm_boot_p
break;
case ATAG_CMDLINE:
/* XXX open question: Parse this for boothowto? */
-   bcopy(walker->u.tag_cmd.command, linux_command_line,
- ATAG_SIZE(walker));
+   size = ATAG_SIZE(walker) -
+   sizeof(struct arm_lbabi_header);
+   size = min(size, sizeof(linux_command_line) - 1);
+   strncpy(linux_command_line, walker->u.tag_cmd.command,
+   size);
+   linux_command_line[size] = '\0';
break;
default:
break;

Modified: head/sys/arm/include/atags.h
==
--- head/sys/arm/include/atags.hSat Mar 26 06:55:55 2016
(r297284)
+++ head/sys/arm/include/atags.hSat Mar 26 06:57:36 2016
(r297285)
@@ -123,7 +123,7 @@ struct arm_lbabi_tag
 };
 
 #defineATAG_TAG(a)  (a)->tag_hdr.tag
-#define ATAG_SIZE(a) (a)->tag_hdr.size
+#define ATAG_SIZE(a) ((a)->tag_hdr.size * sizeof(uint32_t))
 #define ATAG_NEXT(a) (struct arm_lbabi_tag *)((char *)(a) + ATAG_SIZE(a))
 
 #endif /* __MACHINE_ATAGS_H__ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297286 - in head/sys: arm/arm dev/fdt

2016-03-25 Thread Michal Meloun
Author: mmel
Date: Sat Mar 26 06:59:01 2016
New Revision: 297286
URL: https://svnweb.freebsd.org/changeset/base/297286

Log:
  ARM: Parse command line delivered by U-Boot:
  - in atags
  - in DT blob (by using 'fdt chosen' U-Boot command)
  
  The command line must start with guard's string 'FreeBSD:' and can contain
  list of comma separated kenv strings. Also, boot modifier strings from
  boot.h are recognised and parsed into boothowto.
  
  The command line must be passed from U-Boot by setting of bootargs variable:
  'setenv bootargs FreeBSD:boot_single=1,vfs.root.mountfrom=ufs:/dev/ada0s1a'
  followed by 'fdt chosen' (only for DT based boot)

Modified:
  head/sys/arm/arm/machdep.c
  head/sys/dev/fdt/fdt_common.c
  head/sys/dev/fdt/fdt_common.h

Modified: head/sys/arm/arm/machdep.c
==
--- head/sys/arm/arm/machdep.c  Sat Mar 26 06:57:36 2016(r297285)
+++ head/sys/arm/arm/machdep.c  Sat Mar 26 06:59:01 2016(r297286)
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -74,6 +75,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -232,6 +234,7 @@ static struct pv_addr kernelstack;
 #if defined(LINUX_BOOT_ABI)
 #define LBABI_MAX_BANKS10
 
+#define CMDLINE_GUARD "FreeBSD:"
 uint32_t board_id;
 struct arm_lbabi_tag *atag_list;
 char linux_command_line[LBABI_MAX_COMMAND_LINE + 1];
@@ -1029,6 +1032,53 @@ pcpu0_init(void)
 }
 
 #if defined(LINUX_BOOT_ABI)
+
+/* Convert the U-Boot command line into FreeBSD kenv and boot options. */
+static void
+cmdline_set_env(char *cmdline, const char *guard)
+{
+   char *cmdline_next, *env;
+   size_t size, guard_len;
+   int i;
+
+   size = strlen(cmdline);
+   /* Skip leading spaces. */
+   for (; isspace(*cmdline) && (size > 0); cmdline++)
+   size--;
+
+   /* Test and remove guard. */
+   if (guard != NULL && guard[0] != '\0') {
+   guard_len  =  strlen(guard);
+   if (strncasecmp(cmdline, guard, guard_len) != 0){
+   init_static_kenv(cmdline, 0);
+   return;
+
+   cmdline += guard_len;
+   size -= guard_len;
+   }
+   }
+
+   /* Skip leading spaces. */
+   for (; isspace(*cmdline) && (size > 0); cmdline++)
+   size--;
+
+   /* Replace ',' with '\0'. */
+   /* TODO: implement escaping for ',' character. */
+   cmdline_next = cmdline;
+   while(strsep(&cmdline_next, ",") != NULL)
+   ;
+   init_static_kenv(cmdline, 0);
+   /* Parse boothowto. */
+   for (i = 0; howto_names[i].ev != NULL; i++) {
+   env = kern_getenv(howto_names[i].ev);
+   if (env != NULL) {
+   if (strtoul(env, NULL, 10) != 0)
+   boothowto |= howto_names[i].mask;
+   freeenv(env);
+   }
+   }
+}
+
 vm_offset_t
 linux_parse_boot_param(struct arm_boot_params *abp)
 {
@@ -1036,6 +1086,7 @@ linux_parse_boot_param(struct arm_boot_p
uint32_t revision;
uint64_t serial;
int size;
+   vm_offset_t lastaddr;
 #ifdef FDT
struct fdt_header *dtb_ptr;
uint32_t dtb_size;
@@ -1057,9 +1108,6 @@ linux_parse_boot_param(struct arm_boot_p
return (fake_preload_metadata(abp, dtb_ptr, dtb_size));
}
 #endif
-   /* Old, ATAG based boot must have board type set. */
-   if (abp->abp_r1 == 0)
-   return (0);
 
board_id = abp->abp_r1;
walker = (struct arm_lbabi_tag *)abp->abp_r2;
@@ -1089,10 +1137,9 @@ linux_parse_boot_param(struct arm_boot_p
board_set_revision(revision);
break;
case ATAG_CMDLINE:
-   /* XXX open question: Parse this for boothowto? */
size = ATAG_SIZE(walker) -
sizeof(struct arm_lbabi_header);
-   size = min(size, sizeof(linux_command_line) - 1);
+   size = min(size, LBABI_MAX_COMMAND_LINE);
strncpy(linux_command_line, walker->u.tag_cmd.command,
size);
linux_command_line[size] = '\0';
@@ -1107,9 +1154,9 @@ linux_parse_boot_param(struct arm_boot_p
bcopy(atag_list, atags,
(char *)walker - (char *)atag_list + ATAG_SIZE(walker));
 
-   init_static_kenv(NULL, 0);
-
-   return fake_preload_metadata(abp, NULL, 0);
+   lastaddr = fake_preload_metadata(abp, NULL, 0);
+   cmdline_set_env(linux_command_line, CMDLINE_GUARD);
+   return lastaddr;
 }
 #endif
 
@@ -1785,6 +1832,12 @@ initarm(struct arm_boot_params *abp)
if (OF_init((void *)dtbp) != 0)
panic("OF_init failed wi