Re: [PATCH] Extract initrd free logic from arch-specific code.
On 03/29/2018 10:27 AM, Russell King - ARM Linux wrote: > On Thu, Mar 29, 2018 at 09:37:52AM +1100, Oliver wrote: >> On Thu, Mar 29, 2018 at 9:14 AM, Russell King - ARM Linux >>> LD_DEAD_CODE_DATA_ELIMINATION is a symbol without a prompt, and from >>> what I can see, nothing selects it. Therefore, the symbol is always >>> disabled, and so the feature never gets used in mainline kernels. >>> >>> Brings up the obvious question - why is it there if it's completely >>> unused? (Maybe to cause confusion, and allowing a justification >>> for __weak ?) >> >> IIRC Nick had some patches to do the arch enablement for powerpc, but >> I'm not sure what happened to them though. I suspect it just fell down >> Nick's ever growing TODO list. > > I've given it a go on ARM, marking every linker-built table with KEEP() > and comparing the System.map files. The resulting kernel is around > 150k smaller, which seems good. > > However, it doesn't boot - and I don't know why. Booting the kernel > under kvmtool in a VM using virtio-console, I can find no way to get > any kernel messages out of it. Using lkvm debug, I can see that the > PC is stuck inside die(), and that's the only information I have. qemu-system-arm's "-s" option lets you hook to the hardware with gdb, as if using one of those jtags that speaks gdbserver protocol. It stops waiting for you to attach with 'target remote' it, then 'file vmlinux' to load the symbols... The miniconfig and qemu invocation I use for arm64 are attached, tested with 2.11.0 on a 4.14 kernel. You should be able to just "qemu-aarch64.sh -s" and then probably "target remote 127.0.0.1:1234"? (Been a while since I've used it, don't have a cross-gdb for arm64 lying around...) Sigh, I just tried -s and qemu 2.11.0 is _not_ waiting for gdb to attach on arm64, despite what the docs say: $ qemu-system-aarch64 --help | grep gdb -gdb devwait for gdb connection on 'dev' -s shorthand for -gdb tcp::1234 Another random regression in qemu, gee what a surprise. > It dies before bringing up the other CPUs, so it's a very early death. > > I don't think other console types are available under ARM64. I've often found useful the two line version of: https://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/ Which is generally some variant of: {char *XX = "blah"; while (*XX) {while (*SERIAL_STATUS_REGISTER & OUT_READY); *SERIAL_OUT = *XX++;}} (I.E. balu cheated not spinning checking the ready-for-next-byte bit, because qemu's always angry.) That trick lets you cut and paste a print statement into all sorts of early hardware nonsense, on most architectures. You just have to look up SERIAL_STATUS_REGISTER, OUT_OK_BIT, and SERIAL_OUT values for the serial port du jour. That said I've mostly used it in things like u-boot. I dunno at what point the kernel's done enough setup that direct banging on registers would stop working. (Works in the decompresion code, anyway.) And it assumes the port's set to the right speed (usually left there by the bootloader)... Rob # make ARCH=arm64 allnoconfig KCONFIG_ALLCONFIG=aarch64.miniconf # make ARCH=arm64 -j $(nproc) # boot arch/arm64/boot/Image CONFIG_MMU=y CONFIG_ARCH_MULTI_V7=y CONFIG_ARCH_VIRT=y CONFIG_SOC_DRA7XX=y CONFIG_ARCH_OMAP2PLUS_TYPICAL=y CONFIG_ARCH_ALPINE=y CONFIG_ARM_THUMB=y CONFIG_VDSO=y CONFIG_CPU_IDLE=y CONFIG_ARM_CPUIDLE=y CONFIG_KERNEL_MODE_NEON=y CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y CONFIG_RTC_CLASS=y CONFIG_RTC_HCTOSYS=y CONFIG_RTC_DRV_PL031=y CONFIG_NET_CORE=y CONFIG_VIRTIO_NET=y CONFIG_PCI=y CONFIG_PCI_HOST_GENERIC=y CONFIG_VIRTIO_BLK=y CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_MMIO=y CONFIG_ATA=y CONFIG_ATA_SFF=y CONFIG_ATA_BMDMA=y CONFIG_ATA_PIIX=y CONFIG_PATA_PLATFORM=y CONFIG_PATA_OF_PLATFORM=y CONFIG_ATA_GENERIC=y # CONFIG_EMBEDDED is not set CONFIG_EARLY_PRINTK=y CONFIG_BINFMT_ELF=y CONFIG_BINFMT_SCRIPT=y CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y CONFIG_BLK_DEV=y CONFIG_BLK_DEV_INITRD=y CONFIG_RD_GZIP=y CONFIG_BLK_DEV_LOOP=y CONFIG_EXT4_FS=y CONFIG_EXT4_USE_FOR_EXT2=y CONFIG_VFAT_FS=y CONFIG_FAT_DEFAULT_UTF8=y CONFIG_MISC_FILESYSTEMS=y CONFIG_SQUASHFS=y CONFIG_SQUASHFS_XATTR=y CONFIG_SQUASHFS_ZLIB=y CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y CONFIG_NET=y CONFIG_PACKET=y CONFIG_UNIX=y CONFIG_INET=y CONFIG_IPV6=y CONFIG_NETDEVICES=y #CONFIG_NET_CORE=y #CONFIG_NETCONSOLE=y CONFIG_ETHERNET=y qemu-aarch64.sh Description: application/shellscript ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] Extract initrd free logic from arch-specific code.
On 03/28/2018 05:14 PM, Russell King - ARM Linux wrote: > On Wed, Mar 28, 2018 at 02:04:22PM -0500, Rob Landley wrote: >> >> >> On 03/28/2018 11:48 AM, Russell King - ARM Linux wrote: >>> On Wed, Mar 28, 2018 at 10:58:51AM -0500, Rob Landley wrote: >>>> On 03/28/2018 10:26 AM, Shea Levy wrote: >>>>> Now only those architectures that have custom initrd free requirements >>>>> need to define free_initrd_mem. >>>> ... >>>>> --- a/arch/arc/mm/init.c >>>>> +++ b/arch/arc/mm/init.c >>>>> @@ -229,10 +229,3 @@ void __ref free_initmem(void) >>>>> { >>>>> free_initmem_default(-1); >>>>> } >>>>> - >>>>> -#ifdef CONFIG_BLK_DEV_INITRD >>>>> -void __init free_initrd_mem(unsigned long start, unsigned long end) >>>>> -{ >>>>> - free_reserved_area((void *)start, (void *)end, -1, "initrd"); >>>>> -} >>>>> -#endif >>>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig >>>>> index 3f972e83909b..19d1c5594e2d 100644 >>>>> --- a/arch/arm/Kconfig >>>>> +++ b/arch/arm/Kconfig >>>>> @@ -47,6 +47,7 @@ config ARM >>>>> select HARDIRQS_SW_RESEND >>>>> select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) >>>>> select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 >>>>> + select HAVE_ARCH_FREE_INITRD_MEM >>>>> select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU >>>>> select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU >>>>> select HAVE_ARCH_MMAP_RND_BITS if MMU >>>> >>>> Isn't this why weak symbols were invented? >>> >>> Weak symbols means that we end up with both the weakly-referenced code >>> and the arch code in the kernel image. That's fine if the weak code >>> is small. >> >> The kernel's been able to build with link time garbage collection since 2016: >> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b67067f1176d >> >> Wouldn't that remove the unused one? > > Probably, if anyone bothered to use that, which they don't. > > LD_DEAD_CODE_DATA_ELIMINATION is a symbol without a prompt, and from > what I can see, nothing selects it. Therefore, the symbol is always > disabled, and so the feature never gets used in mainline kernels. It looks like there are per-architecture linker scripts that need to be updated? So if an architecture supports it, it's always done (well, it probes for the toolchain supporting the flag). And if the architecture doesn't support it, the linker script needs to be updated to mark sections with "I know nothing seems to reference this at the ELF level but keep it anyway, we're pulling an assembly trick". > Brings up the obvious question - why is it there if it's completely > unused? (Maybe to cause confusion, and allowing a justification > for __weak ?) Presumably it will become the default on architectures as their linker scripts are converted. Once they're all converted the config symbol can go away. (Given the move to requiring gcc 4.7 or whatever it is, there can't be an architecture depending on a toolchain that _doesn't_ support it after that point. I doubt you can pair gcc 4.7 with a >12 year old binutils and expect good things...) Rob ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] Extract initrd free logic from arch-specific code.
On 03/28/2018 11:48 AM, Russell King - ARM Linux wrote: > On Wed, Mar 28, 2018 at 10:58:51AM -0500, Rob Landley wrote: >> On 03/28/2018 10:26 AM, Shea Levy wrote: >>> Now only those architectures that have custom initrd free requirements >>> need to define free_initrd_mem. >> ... >>> --- a/arch/arc/mm/init.c >>> +++ b/arch/arc/mm/init.c >>> @@ -229,10 +229,3 @@ void __ref free_initmem(void) >>> { >>> free_initmem_default(-1); >>> } >>> - >>> -#ifdef CONFIG_BLK_DEV_INITRD >>> -void __init free_initrd_mem(unsigned long start, unsigned long end) >>> -{ >>> - free_reserved_area((void *)start, (void *)end, -1, "initrd"); >>> -} >>> -#endif >>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig >>> index 3f972e83909b..19d1c5594e2d 100644 >>> --- a/arch/arm/Kconfig >>> +++ b/arch/arm/Kconfig >>> @@ -47,6 +47,7 @@ config ARM >>> select HARDIRQS_SW_RESEND >>> select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) >>> select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 >>> + select HAVE_ARCH_FREE_INITRD_MEM >>> select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU >>> select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU >>> select HAVE_ARCH_MMAP_RND_BITS if MMU >> >> Isn't this why weak symbols were invented? > > Weak symbols means that we end up with both the weakly-referenced code > and the arch code in the kernel image. That's fine if the weak code > is small. The kernel's been able to build with link time garbage collection since 2016: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b67067f1176d Wouldn't that remove the unused one? Rob ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] Extract initrd free logic from arch-specific code.
On 03/28/2018 10:26 AM, Shea Levy wrote: > Now only those architectures that have custom initrd free requirements > need to define free_initrd_mem. ... > --- a/arch/arc/mm/init.c > +++ b/arch/arc/mm/init.c > @@ -229,10 +229,3 @@ void __ref free_initmem(void) > { > free_initmem_default(-1); > } > - > -#ifdef CONFIG_BLK_DEV_INITRD > -void __init free_initrd_mem(unsigned long start, unsigned long end) > -{ > - free_reserved_area((void *)start, (void *)end, -1, "initrd"); > -} > -#endif > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > index 3f972e83909b..19d1c5594e2d 100644 > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -47,6 +47,7 @@ config ARM > select HARDIRQS_SW_RESEND > select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) > select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 > + select HAVE_ARCH_FREE_INITRD_MEM > select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU > select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU > select HAVE_ARCH_MMAP_RND_BITS if MMU Isn't this why weak symbols were invented? Confused, Rob ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap.
On 03/23/2018 02:06 PM, Matthew Wilcox wrote: > On Fri, Mar 23, 2018 at 02:00:24PM -0400, Rich Felker wrote: >> On Fri, Mar 23, 2018 at 05:48:06AM -0700, Matthew Wilcox wrote: >>> On Thu, Mar 22, 2018 at 07:36:36PM +0300, Ilya Smith wrote: Current implementation doesn't randomize address returned by mmap. All the entropy ends with choosing mmap_base_addr at the process creation. After that mmap build very predictable layout of address space. It allows to bypass ASLR in many cases. This patch make randomization of address on any mmap call. >>> >>> Why should this be done in the kernel rather than libc? libc is perfectly >>> capable of specifying random numbers in the first argument of mmap. >> >> Generally libc does not have a view of the current vm maps, and thus >> in passing "random numbers", they would have to be uniform across the >> whole vm space and thus non-uniform once the kernel rounds up to avoid >> existing mappings. > > I'm aware that you're the musl author, but glibc somehow manages to > provide etext, edata and end, demonstrating that it does know where at > least some of the memory map lies. You can parse /proc/self/maps, but it's really expensive and disgusting. Rob ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 1/3] futex: remove duplicated code
On 03/04/2017 07:05 AM, Russell King - ARM Linux wrote: > On Fri, Mar 03, 2017 at 01:27:10PM +0100, Jiri Slaby wrote: >> diff --git a/kernel/futex.c b/kernel/futex.c >> index b687cb22301c..c5ff9850952f 100644 >> --- a/kernel/futex.c >> +++ b/kernel/futex.c >> @@ -1457,6 +1457,42 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int >> nr_wake, u32 bitset) >> return ret; >> } >> >> +static int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) >> +{ >> +int op = (encoded_op >> 28) & 7; >> +int cmp = (encoded_op >> 24) & 15; >> +int oparg = (encoded_op << 8) >> 20; >> +int cmparg = (encoded_op << 20) >> 20; > > Hmm. oparg and cmparg look like they're doing these shifts to get sign > extension of the 12-bit values by assuming that "int" is 32-bit - > probably worth a comment, or for safety, they should be "s32" so it's > not dependent on the bit-width of "int". I thought Linux depended on the LP64 standard for all architectures? Standard: http://www.unix.org/whitepapers/64bit.html Rationale: http://www.unix.org/version2/whatsnew/lp64_wp.html So int has a defined bit width (32) on linux? Rob ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc